gem5  v22.1.0.0
tlb.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2010-2013, 2016, 2019-2022 Arm Limited
3  * All rights reserved
4  *
5  * The license below extends only to copyright in the software and shall
6  * not be construed as granting a license to any other intellectual
7  * property including but not limited to intellectual property relating
8  * to a hardware implementation of the functionality of the software
9  * licensed hereunder. You may use the software subject to the license
10  * terms below provided that you ensure that this notice is replicated
11  * unmodified and in its entirety in all distributions of the software,
12  * modified or unmodified, in source code or in binary form.
13  *
14  * Copyright (c) 2001-2005 The Regents of The University of Michigan
15  * All rights reserved.
16  *
17  * Redistribution and use in source and binary forms, with or without
18  * modification, are permitted provided that the following conditions are
19  * met: redistributions of source code must retain the above copyright
20  * notice, this list of conditions and the following disclaimer;
21  * redistributions in binary form must reproduce the above copyright
22  * notice, this list of conditions and the following disclaimer in the
23  * documentation and/or other materials provided with the distribution;
24  * neither the name of the copyright holders nor the names of its
25  * contributors may be used to endorse or promote products derived from
26  * this software without specific prior written permission.
27  *
28  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39  */
40 
41 #ifndef __ARCH_ARM_TLB_HH__
42 #define __ARCH_ARM_TLB_HH__
43 
44 
45 #include "arch/arm/faults.hh"
46 #include "arch/arm/pagetable.hh"
47 #include "arch/arm/utility.hh"
48 #include "arch/generic/tlb.hh"
49 #include "base/statistics.hh"
50 #include "enums/TypeTLB.hh"
51 #include "mem/request.hh"
52 #include "params/ArmTLB.hh"
53 #include "sim/probe/pmu.hh"
54 
55 namespace gem5
56 {
57 
58 class ThreadContext;
59 
60 namespace ArmISA {
61 
62 class TableWalker;
63 class TLB;
64 class TLBIOp;
65 
67 {
68  public:
70  virtual ~TlbTestInterface() {}
71 
80  virtual Fault translationCheck(const RequestPtr &req, bool is_priv,
83 
96  virtual Fault walkCheck(Addr pa, Addr size, Addr va, bool is_secure,
97  Addr is_priv, BaseMMU::Mode mode,
99  enums::ArmLookupLevel lookup_level) = 0;
100 };
101 
102 class TLB : public BaseTLB
103 {
104  protected:
106 
108  int size;
109 
111  bool isStage2;
112 
118  std::unordered_map<enums::ArmLookupLevel, bool> partialLevels;
119 
124 
126 
127  struct TlbStats : public statistics::Group
128  {
129  TlbStats(TLB &parent);
130 
131  const TLB &tlb;
132 
133  // Access Stats
144 
151  } stats;
152 
155 
156  int rangeMRU; //On lookup, only move entries ahead when outside rangeMRU
158 
159  public:
160  using Params = ArmTLBParams;
162  using LookupLevel = enums::ArmLookupLevel;
163 
164  TLB(const Params &p);
165  TLB(const Params &p, int _size, TableWalker *_walker);
166 
170  TlbEntry *lookup(const Lookup &lookup_data);
171 
178  TlbEntry *multiLookup(const Lookup &lookup_data);
179 
180  virtual ~TLB();
181 
182  void takeOverFrom(BaseTLB *otlb) override;
183 
184  void setTableWalker(TableWalker *table_walker);
185 
187 
188  int getsize() const { return size; }
189 
190  bool walkCache() const { return _walkCache; }
191 
192  void setVMID(vmid_t _vmid) { vmid = _vmid; }
193 
195  void insert(TlbEntry &pte);
196 
198  void multiInsert(TlbEntry &pte);
199 
203  void flushAll() override;
204 
205 
208  void flush(const TLBIOp &tlbi_op);
209 
212 
213  Fault walkTrickBoxCheck(Addr pa, bool is_secure, Addr va, Addr sz,
214  bool is_exec, bool is_write,
216  LookupLevel lookup_level);
217 
218  void printTlb() const;
219 
220  void demapPage(Addr vaddr, uint64_t asn) override
221  {
222  // needed for x86 only
223  panic("demapPage() is not implemented.\n");
224  }
225 
226  Fault
228  BaseMMU::Mode mode) override
229  {
230  panic("unimplemented");
231  }
232 
233  void
235  BaseMMU::Translation *translation,
236  BaseMMU::Mode mode) override
237  {
238  panic("unimplemented");
239  }
240 
241  Fault
243  BaseMMU::Mode mode) const override
244  {
245  panic("unimplemented");
246  }
247 
248  void regProbePoints() override;
249 
260  Port *getTableWalkerPort() override;
261 
262  // Caching misc register values here.
263  // Writing to misc registers needs to invalidate them.
264  // translateFunctional/translateSe/translateFs checks if they are
265  // invalid and call updateMiscReg if necessary.
266 
267  private:
276  void _flushMva(Addr mva, uint64_t asn, bool secure_lookup,
277  bool ignore_asn, ExceptionLevel target_el,
278  bool in_host, TypeTLB entry_type);
279 
286 
289  TlbEntry *match(const Lookup &lookup_data);
290 };
291 
292 } // namespace ArmISA
293 } // namespace gem5
294 
295 #endif // __ARCH_ARM_TLB_HH__
int size
TLB Size.
Definition: tlb.hh:108
TLB(const Params &p, int _size, TableWalker *_walker)
void takeOverFrom(BaseTLB *otlb) override
Take over from an old tlb context.
Definition: tlb.cc:336
bool walkCache() const
Definition: tlb.hh:190
TlbEntry * lookup(const Lookup &lookup_data)
Lookup an entry in the TLB.
Definition: tlb.cc:157
TableWalker * tableWalker
Definition: tlb.hh:125
void setTableWalker(TableWalker *table_walker)
Definition: tlb.cc:99
void setVMID(vmid_t _vmid)
Definition: tlb.hh:192
TlbEntry * multiLookup(const Lookup &lookup_data)
Lookup an entry in the TLB and in the next levels by following the nextLevel pointer.
Definition: tlb.cc:204
ArmTLBParams Params
Definition: tlb.hh:160
void flush(const TLBIOp &tlbi_op)
Flush TLB entries.
Definition: tlb.cc:318
int getsize() const
Definition: tlb.hh:188
void regProbePoints() override
Register probe points for this object.
Definition: tlb.cc:399
void printTlb() const
Definition: tlb.cc:284
TLB(const Params &p)
Definition: tlb.cc:61
virtual ~TLB()
Definition: tlb.cc:93
Port * getTableWalkerPort() override
Get the table walker port.
Definition: tlb.cc:405
probing::PMUUPtr ppRefills
PMU probe for TLB refills.
Definition: tlb.hh:154
bool _walkCache
True if the TLB caches partial translations.
Definition: tlb.hh:123
Fault trickBoxCheck(const RequestPtr &req, BaseMMU::Mode mode, TlbEntry::DomainType domain)
void insert(TlbEntry &pte)
Insert a PTE in the current TLB.
Definition: tlb.cc:241
void translateTiming(const RequestPtr &req, ThreadContext *tc, BaseMMU::Translation *translation, BaseMMU::Mode mode) override
Definition: tlb.hh:234
void multiInsert(TlbEntry &pte)
Insert a PTE in the current TLB and in the higher levels.
Definition: tlb.cc:270
std::unordered_map< enums::ArmLookupLevel, bool > partialLevels
Hash map containing one entry per lookup level The TLB is caching partial translations from the key l...
Definition: tlb.hh:118
void _flushMva(Addr mva, uint64_t asn, bool secure_lookup, bool ignore_asn, ExceptionLevel target_el, bool in_host, TypeTLB entry_type)
Remove any entries that match both a va and asn.
Fault finalizePhysical(const RequestPtr &req, ThreadContext *tc, BaseMMU::Mode mode) const override
Do post-translation physical address finalization.
Definition: tlb.hh:242
vmid_t vmid
Definition: tlb.hh:157
void checkPromotion(TlbEntry *entry, BaseMMU::Mode mode)
Check if the tlb entry passed as an argument needs to be "promoted" as a unified entry: this should h...
Definition: tlb.cc:227
gem5::ArmISA::TLB::TlbStats stats
TlbEntry * match(const Lookup &lookup_data)
Helper function looking up for a matching TLB entry Does not update stats; see lookup method instead.
Definition: tlb.cc:106
void demapPage(Addr vaddr, uint64_t asn) override
Definition: tlb.hh:220
Fault translateAtomic(const RequestPtr &req, ThreadContext *tc, BaseMMU::Mode mode) override
Definition: tlb.hh:227
TableWalker * getTableWalker()
Definition: tlb.hh:186
enums::ArmLookupLevel LookupLevel
Definition: tlb.hh:162
TlbEntry * table
Definition: tlb.hh:105
bool isStage2
Indicates this TLB caches IPA->PA translations.
Definition: tlb.hh:111
void flushAll() override
Reset the entire TLB.
Definition: tlb.cc:298
Fault walkTrickBoxCheck(Addr pa, bool is_secure, Addr va, Addr sz, bool is_exec, bool is_write, TlbEntry::DomainType domain, LookupLevel lookup_level)
virtual ~TlbTestInterface()
Definition: tlb.hh:70
virtual Fault translationCheck(const RequestPtr &req, bool is_priv, BaseMMU::Mode mode, TlbEntry::DomainType domain)=0
Check if a TLB translation should be forced to fail.
virtual Fault walkCheck(Addr pa, Addr size, Addr va, bool is_secure, Addr is_priv, BaseMMU::Mode mode, TlbEntry::DomainType domain, enums::ArmLookupLevel lookup_level)=0
Check if a page table walker access should be forced to fail.
Ports are used to interface objects to each other.
Definition: port.hh:62
ThreadContext is the external interface to all thread state for anything outside of the CPU.
A formula for statistics that is calculated when printed.
Definition: statistics.hh:2540
Statistics container.
Definition: group.hh:94
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:1931
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:178
Bitfield< 4, 0 > mode
Definition: misc_types.hh:74
Bitfield< 7, 4 > domain
Definition: misc_types.hh:430
uint16_t vmid_t
Definition: types.hh:57
Bitfield< 39, 12 > pa
Definition: misc_types.hh:663
Bitfield< 8 > va
Definition: misc_types.hh:282
Bitfield< 54 > p
Definition: pagetable.hh:70
std::unique_ptr< PMU > PMUUPtr
Definition: pmu.hh:61
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
std::shared_ptr< FaultBase > Fault
Definition: types.hh:248
std::shared_ptr< Request > RequestPtr
Definition: request.hh:92
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147
Declaration of a request, the overall memory request consisting of the parts of the request that are ...
Declaration of Statistics objects.
statistics::Formula writeAccesses
Definition: tlb.hh:146
statistics::Formula hits
Definition: tlb.hh:148
statistics::Scalar readHits
Definition: tlb.hh:137
statistics::Scalar instHits
Definition: tlb.hh:135
statistics::Scalar flushedEntries
Definition: tlb.hh:143
statistics::Formula misses
Definition: tlb.hh:149
statistics::Formula readAccesses
Definition: tlb.hh:145
statistics::Formula accesses
Definition: tlb.hh:150
statistics::Scalar inserts
Definition: tlb.hh:141
statistics::Scalar flushTlb
Definition: tlb.hh:142
TlbStats(TLB &parent)
Definition: tlb.cc:340
statistics::Scalar readMisses
Definition: tlb.hh:138
statistics::Scalar writeHits
Definition: tlb.hh:139
statistics::Scalar writeMisses
Definition: tlb.hh:140
statistics::Formula instAccesses
Definition: tlb.hh:147
statistics::Scalar instMisses
Definition: tlb.hh:136
statistics::Scalar partialHits
Definition: tlb.hh:134

Generated on Wed Dec 21 2022 10:22:15 for gem5 by doxygen 1.9.1