gem5 v24.0.0.0
Loading...
Searching...
No Matches
tlb.hh
Go to the documentation of this file.
1/*
2 * Copyright (c) 2010-2013, 2016, 2019-2022, 2024 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
55namespace gem5
56{
57
58class ThreadContext;
59
60namespace ArmISA {
61
62class TableWalker;
63class TLB;
64class TLBIOp;
65
67{
68 public:
70 virtual ~TlbTestInterface() {}
71
80 virtual Fault translationCheck(const RequestPtr &req, bool is_priv,
83
95 virtual Fault walkCheck(const RequestPtr &walk_req,
96 Addr va, bool is_secure,
97 Addr is_priv, BaseMMU::Mode mode,
99 enums::ArmLookupLevel lookup_level) = 0;
100};
101
102class TLB : public BaseTLB
103{
104 protected:
106
108 int size;
109
112
118 std::unordered_map<enums::ArmLookupLevel, bool> partialLevels;
119
124
126
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
210 void printTlb() const;
211
212 void demapPage(Addr vaddr, uint64_t asn) override
213 {
214 // needed for x86 only
215 panic("demapPage() is not implemented.\n");
216 }
217
218 Fault
220 BaseMMU::Mode mode) override
221 {
222 panic("unimplemented");
223 }
224
225 void
227 BaseMMU::Translation *translation,
228 BaseMMU::Mode mode) override
229 {
230 panic("unimplemented");
231 }
232
233 Fault
235 BaseMMU::Mode mode) const override
236 {
237 panic("unimplemented");
238 }
239
240 void regProbePoints() override;
241
252 Port *getTableWalkerPort() override;
253
254 // Caching misc register values here.
255 // Writing to misc registers needs to invalidate them.
256 // translateFunctional/translateSe/translateFs checks if they are
257 // invalid and call updateMiscReg if necessary.
258
259 private:
268 void _flushMva(Addr mva, uint64_t asn, bool secure_lookup,
269 bool ignore_asn, ExceptionLevel target_el,
270 bool in_host, TypeTLB entry_type);
271
278
281 TlbEntry *match(const Lookup &lookup_data);
282};
283
284} // namespace ArmISA
285} // namespace gem5
286
287#endif // __ARCH_ARM_TLB_HH__
TableWalker * getTableWalker()
Definition tlb.hh:186
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
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:226
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:234
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:212
Fault translateAtomic(const RequestPtr &req, ThreadContext *tc, BaseMMU::Mode mode) override
Definition tlb.hh:219
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
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(const RequestPtr &walk_req, 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.
Statistics container.
Definition group.hh:93
This is a simple scalar statistic, like a counter.
#define panic(...)
This implements a cprintf based panic() function.
Definition logging.hh:188
Bitfield< 4, 0 > mode
Definition misc_types.hh:74
Bitfield< 7, 4 > domain
uint16_t vmid_t
Definition types.hh:57
Bitfield< 8 > va
Bitfield< 0 > p
std::unique_ptr< PMU > PMUUPtr
Definition pmu.hh:60
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36
std::shared_ptr< FaultBase > Fault
Definition types.hh:249
std::shared_ptr< Request > RequestPtr
Definition request.hh:94
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 Tue Jun 18 2024 16:24:00 for gem5 by doxygen 1.11.0