gem5  v20.1.0.0
tlb.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2001-2005 The Regents of The University of Michigan
3  * Copyright (c) 2007 MIPS Technologies, Inc.
4  * Copyright (c) 2020 Barkhausen Institut
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions are
9  * met: redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer;
11  * redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the distribution;
14  * neither the name of the copyright holders nor the names of its
15  * contributors may be used to endorse or promote products derived from
16  * this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30 
31 #ifndef __ARCH_RISCV_TLB_HH__
32 #define __ARCH_RISCV_TLB_HH__
33 
34 #include <list>
35 
36 #include "arch/generic/tlb.hh"
37 #include "arch/riscv/isa.hh"
38 #include "arch/riscv/isa_traits.hh"
39 #include "arch/riscv/pagetable.hh"
40 #include "arch/riscv/utility.hh"
41 #include "base/statistics.hh"
42 #include "mem/request.hh"
43 #include "params/RiscvTLB.hh"
44 #include "sim/sim_object.hh"
45 
46 class ThreadContext;
47 
48 /* To maintain compatibility with other architectures, we'll
49  simply create an ITLB and DTLB that will point to the real TLB */
50 namespace RiscvISA {
51 
52 class Walker;
53 
54 class TLB : public BaseTLB
55  {
57 
58  protected:
59  size_t size;
61  TlbEntryTrie trie; // for quick access
62  EntryList freeList; // free entries
63  uint64_t lruSeq;
64 
66 
67  struct TlbStats : public Stats::Group{
68  TlbStats(Stats::Group *parent);
69 
78 
82  } stats;
83 
84  public:
85  typedef RiscvTLBParams Params;
86  TLB(const Params *p);
87 
88  Walker *getWalker();
89 
90  void takeOverFrom(BaseTLB *otlb) override {}
91 
92  TlbEntry *insert(Addr vpn, const TlbEntry &entry);
93  void flushAll() override;
94  void demapPage(Addr vaddr, uint64_t asn) override;
95 
97  Mode mode, PTESv39 pte);
99 
101 
102  // Checkpointing
103  void serialize(CheckpointOut &cp) const override;
104  void unserialize(CheckpointIn &cp) override;
105 
107 
108  Fault translateAtomic(const RequestPtr &req,
109  ThreadContext *tc, Mode mode) override;
110  void translateTiming(const RequestPtr &req, ThreadContext *tc,
111  Translation *translation, Mode mode) override;
113  ThreadContext *tc, Mode mode) override;
114  Fault finalizePhysical(const RequestPtr &req,
115  ThreadContext *tc, Mode mode) const override;
116 
117  private:
118  uint64_t nextSeq() { return ++lruSeq; }
119 
120  TlbEntry *lookup(Addr vpn, uint16_t asid, Mode mode, bool hidden);
121 
122  void evictLRU();
123  void remove(size_t idx);
124 
125  Fault translate(const RequestPtr &req, ThreadContext *tc,
126  Translation *translation, Mode mode, bool &delayed);
127  Fault doTranslate(const RequestPtr &req, ThreadContext *tc,
128  Translation *translation, Mode mode, bool &delayed);
129 };
130 
131 }
132 
133 #endif // __RISCV_MEMORY_HH__
RiscvISA::TlbEntry
Definition: pagetable.hh:78
RiscvISA::TLB::getMemPriv
PrivilegeMode getMemPriv(ThreadContext *tc, Mode mode)
Definition: tlb.cc:318
ArmISA::status
Bitfield< 5, 0 > status
Definition: miscregs_types.hh:417
RiscvISA::TLB::TlbStats
Definition: tlb.hh:67
RiscvISA::TLB::demapPage
void demapPage(Addr vaddr, uint64_t asn) override
Definition: tlb.cc:166
RiscvISA::mode
mode
Definition: pagetable.hh:42
RiscvISA::TLB::translate
Fault translate(const RequestPtr &req, ThreadContext *tc, Translation *translation, Mode mode, bool &delayed)
Definition: tlb.cc:328
RiscvISA::TLB::freeList
EntryList freeList
Definition: tlb.hh:62
RiscvISA::TLB::insert
TlbEntry * insert(Addr vpn, const TlbEntry &entry)
Definition: tlb.cc:136
RiscvISA::TLB::TlbStats::write_acv
Stats::Scalar write_acv
Definition: tlb.hh:76
tlb.hh
RiscvISA::TLB::serialize
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: tlb.cc:462
BaseTLB::Mode
Mode
Definition: tlb.hh:57
RiscvISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:323
RiscvISA::TLB::TlbStats::write_hits
Stats::Scalar write_hits
Definition: tlb.hh:74
RiscvISA::TLB::lruSeq
uint64_t lruSeq
Definition: tlb.hh:63
RequestPtr
std::shared_ptr< Request > RequestPtr
Definition: request.hh:82
RiscvISA::asid
Bitfield< 59, 44 > asid
Definition: pagetable.hh:43
std::vector
STL vector class.
Definition: stl.hh:37
RiscvISA::TLB::Params
RiscvTLBParams Params
Definition: tlb.hh:85
RiscvISA::TLB::translateFunctional
Fault translateFunctional(const RequestPtr &req, ThreadContext *tc, Mode mode) override
Definition: tlb.cc:408
RiscvISA::TLB::TlbStats::read_accesses
Stats::Scalar read_accesses
Definition: tlb.hh:73
RiscvISA::TLB
Definition: tlb.hh:54
RiscvISA::TLB::translateWithTLB
Addr translateWithTLB(Addr vaddr, uint16_t asid, Mode mode)
Definition: tlb.cc:263
Trie< Addr, TlbEntry >
isa.hh
request.hh
RiscvISA::TLB::evictLRU
void evictLRU()
Definition: tlb.cc:87
BaseTLB
Definition: tlb.hh:50
RiscvISA
Definition: fs_workload.cc:36
Stats::Scalar
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:2533
RiscvISA::vaddr
vaddr
Definition: pra_constants.hh:275
cp
Definition: cprintf.cc:40
RiscvISA::TLB::remove
void remove(size_t idx)
Definition: tlb.cc:203
RiscvISA::TLB::createPagefault
Fault createPagefault(Addr vaddr, Mode mode)
Definition: tlb.cc:250
ThreadContext
ThreadContext is the external interface to all thread state for anything outside of the CPU.
Definition: thread_context.hh:88
sim_object.hh
Fault
std::shared_ptr< FaultBase > Fault
Definition: types.hh:240
statistics.hh
RiscvISA::Walker
Definition: pagetable_walker.hh:57
RiscvISA::PrivilegeMode
PrivilegeMode
Definition: isa.hh:56
RiscvISA::TLB::translateTiming
void translateTiming(const RequestPtr &req, ThreadContext *tc, Translation *translation, Mode mode) override
Definition: tlb.cc:395
RiscvISA::TLB::TlbStats::misses
Stats::Formula misses
Definition: tlb.hh:80
RiscvISA::TLB::TlbStats::read_misses
Stats::Scalar read_misses
Definition: tlb.hh:71
RiscvISA::TLB::lookup
TlbEntry * lookup(Addr vpn, uint16_t asid, Mode mode, bool hidden)
Definition: tlb.cc:102
RiscvISA::TLB::unserialize
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: tlb.cc:477
RiscvISA::TLB::trie
TlbEntryTrie trie
Definition: tlb.hh:61
RiscvISA::TLB::finalizePhysical
Fault finalizePhysical(const RequestPtr &req, ThreadContext *tc, Mode mode) const override
Do post-translation physical address finalization.
Definition: tlb.cc:455
RiscvISA::TLB::flushAll
void flushAll() override
Remove all entries from the TLB.
Definition: tlb.cc:193
RiscvISA::TLB::EntryList
std::list< TlbEntry * > EntryList
Definition: tlb.hh:56
RiscvISA::TLB::TlbStats::read_acv
Stats::Scalar read_acv
Definition: tlb.hh:72
RiscvISA::TLB::TlbStats::TlbStats
TlbStats(Stats::Group *parent)
Definition: tlb.cc:499
Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
RiscvISA::TLB::doTranslate
Fault doTranslate(const RequestPtr &req, ThreadContext *tc, Translation *translation, Mode mode, bool &delayed)
Definition: tlb.cc:271
RiscvISA::TLB::takeOverFrom
void takeOverFrom(BaseTLB *otlb) override
Take over from an old tlb context.
Definition: tlb.hh:90
RiscvISA::TLB::TlbStats::hits
Stats::Formula hits
Definition: tlb.hh:79
RiscvISA::TLB::TlbStats::write_misses
Stats::Scalar write_misses
Definition: tlb.hh:75
RiscvISA::TLB::TlbStats::accesses
Stats::Formula accesses
Definition: tlb.hh:81
RiscvISA::TLB::walker
Walker * walker
Definition: tlb.hh:65
RiscvISA::TLB::TlbStats::write_accesses
Stats::Scalar write_accesses
Definition: tlb.hh:77
RiscvISA::TLB::translateAtomic
Fault translateAtomic(const RequestPtr &req, ThreadContext *tc, Mode mode) override
Definition: tlb.cc:388
Stats::Formula
A formula for statistics that is calculated when printed.
Definition: statistics.hh:3037
Stats::Group
Statistics container.
Definition: group.hh:83
RiscvISA::TLB::checkPermissions
Fault checkPermissions(STATUS status, PrivilegeMode pmode, Addr vaddr, Mode mode, PTESv39 pte)
Definition: tlb.cc:216
CheckpointOut
std::ostream CheckpointOut
Definition: serialize.hh:63
utility.hh
RiscvISA::TLB::stats
RiscvISA::TLB::TlbStats stats
RiscvISA::TLB::TLB
TLB(const Params *p)
Definition: tlb.cc:68
std::list< TlbEntry * >
RiscvISA::TLB::nextSeq
uint64_t nextSeq()
Definition: tlb.hh:118
CheckpointIn
Definition: serialize.hh:67
RiscvISA::TLB::TlbStats::read_hits
Stats::Scalar read_hits
Definition: tlb.hh:70
pagetable.hh
RiscvISA::TLB::getWalker
Walker * getWalker()
Definition: tlb.cc:81
RiscvISA::TLB::tlb
std::vector< TlbEntry > tlb
Definition: tlb.hh:60
RiscvISA::TLB::size
size_t size
Definition: tlb.hh:59
isa_traits.hh

Generated on Wed Sep 30 2020 14:01:59 for gem5 by doxygen 1.8.17