52#include "debug/TLB.hh"
53#include "debug/TLBVerbose.hh"
54#include "params/ArmTLB.hh"
59using namespace ArmISA;
63 isStage2(
p.is_stage2),
66 stats(*this), rangeMRU(1), vmid(0)
68 for (
int lvl = LookupLevel::L0;
69 lvl < LookupLevel::Num_ArmLookupLevel; lvl++) {
72 p.partial_levels.begin(),
73 p.partial_levels.end(),
78 if (it !=
p.partial_levels.end()) {
84 if (lvl != LookupLevel::Num_ArmLookupLevel - 1) {
114 LookupLevel::Num_ArmLookupLevel, {0,
nullptr}};
132 for (
auto it = hits.rbegin(); it != hits.rend(); it++) {
133 const auto& [idx, entry] = *it;
144 for (
int i = idx;
i > 0;
i--)
146 table[0] = tmp_entry;
163 DPRINTF(TLBVerbose,
"Lookup %#x, asn %#x -> %s vmn 0x%x secure %d "
164 "ppn %#x size: %#x pa: %#x ap:%d ns:%d nstid:%d g:%d asid: %d "
166 lookup_data.
va, lookup_data.
asn, retval ?
"hit" :
"miss",
168 retval ? retval->
pfn : 0, retval ? retval->
size : 0,
169 retval ? retval->
pAddr(lookup_data.
va) : 0,
170 retval ? retval->
ap : 0,
171 retval ? retval->
ns : 0, retval ? retval->
nstid : 0,
172 retval ? retval->
global : 0, retval ? retval->
asid : 0,
212 te =
tlb->multiLookup(lookup_data);
230 TypeTLB::instruction : TypeTLB::data;
235 if (!(entry->
type & acc_type))
236 entry->
type = TypeTLB::unified;
243 DPRINTF(
TLB,
"Inserting entry into TLB with pfn:%#x size:%#x vpn: %#x"
244 " asid:%d vmid:%d N:%d global:%d valid:%d nc:%d xn:%d"
245 " ap:%#x domain:%#x ns:%d nstid:%d, regime: %s\n", entry.
pfn,
248 entry.
ap,
static_cast<uint8_t
>(entry.
domain), entry.
ns,
252 DPRINTF(
TLB,
" - Replacing Valid entry %#x, asn %d vmn %d ppn %#x "
253 "size: %#x ap:%d ns:%d nstid:%d g:%d regime: %s\n",
261 for (
int i =
size - 1;
i > 0; --
i)
279 next_level->multiInsert(entry);
341 : statistics::
Group(&parent),
tlb(parent),
342 ADD_STAT(partialHits, statistics::units::Count::get(),
343 "partial translation hits"),
344 ADD_STAT(instHits, statistics::units::Count::get(),
"Inst hits"),
345 ADD_STAT(instMisses, statistics::units::Count::get(),
"Inst misses"),
346 ADD_STAT(readHits, statistics::units::Count::get(),
"Read hits"),
347 ADD_STAT(readMisses, statistics::units::Count::get(),
"Read misses"),
348 ADD_STAT(writeHits, statistics::units::Count::get(),
"Write hits"),
349 ADD_STAT(writeMisses, statistics::units::Count::get(),
"Write misses"),
350 ADD_STAT(inserts, statistics::units::Count::get(),
351 "Number of times an entry is inserted into the TLB"),
352 ADD_STAT(flushTlb, statistics::units::Count::get(),
353 "Number of times a TLB invalidation was requested"),
354 ADD_STAT(flushedEntries, statistics::units::Count::get(),
355 "Number of entries that have been flushed from TLB"),
356 ADD_STAT(readAccesses, statistics::units::Count::get(),
"Read accesses",
357 readHits + readMisses),
358 ADD_STAT(writeAccesses, statistics::units::Count::get(),
"Write accesses",
359 writeHits + writeMisses),
360 ADD_STAT(instAccesses, statistics::units::Count::get(),
"Inst accesses",
361 instHits + instMisses),
362 ADD_STAT(hits, statistics::units::Count::get(),
363 "Total TLB (inst and data) hits",
364 readHits + writeHits + instHits),
365 ADD_STAT(misses, statistics::units::Count::get(),
366 "Total TLB (inst and data) misses",
367 readMisses + writeMisses + instMisses),
368 ADD_STAT(accesses, statistics::units::Count::get(),
369 "Total TLB (inst and data) accesses",
370 readAccesses + writeAccesses + instAccesses)
375 if (
tlb.
type() == TypeTLB::data) {
385 if (
tlb.
type() & TypeTLB::instruction) {
virtual bool match(TlbEntry *entry, vmid_t curr_vmid) const =0
void takeOverFrom(BaseTLB *otlb) override
Take over from an old tlb context.
TlbEntry * lookup(const Lookup &lookup_data)
Lookup an entry in the TLB.
TableWalker * tableWalker
void setTableWalker(TableWalker *table_walker)
TlbEntry * multiLookup(const Lookup &lookup_data)
Lookup an entry in the TLB and in the next levels by following the nextLevel pointer.
void flush(const TLBIOp &tlbi_op)
Flush TLB entries.
void regProbePoints() override
Register probe points for this object.
Port * getTableWalkerPort() override
Get the table walker port.
probing::PMUUPtr ppRefills
PMU probe for TLB refills.
bool _walkCache
True if the TLB caches partial translations.
void insert(TlbEntry &pte)
Insert a PTE in the current TLB.
void multiInsert(TlbEntry &pte)
Insert a PTE in the current TLB and in the higher levels.
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...
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...
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.
enums::ArmLookupLevel LookupLevel
void flushAll() override
Reset the entire TLB.
Port & getTableWalkerPort()
BaseTLB * nextLevel() const
Ports are used to interface objects to each other.
ProbePointArg generates a point for the class of Arg.
Derived & flags(Flags _flags)
Set the flags and marks this stat to print at the end of simulation.
#define ADD_STAT(n,...)
Convenience macro to add a stat to a statistics group.
ProbeManager * getProbeManager()
Get the probe manager for this object.
static const char * regimeToStr(TranslationRegime regime)
const FlagsType nozero
Don't print if this is zero.
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
statistics::Formula writeAccesses
statistics::Scalar readHits
statistics::Scalar instHits
statistics::Scalar flushedEntries
statistics::Formula readAccesses
statistics::Scalar inserts
statistics::Scalar flushTlb
statistics::Scalar readMisses
statistics::Scalar writeHits
statistics::Scalar writeMisses
statistics::Formula instAccesses
statistics::Scalar instMisses
statistics::Scalar partialHits
Addr pAddr(Addr va) const
The file contains the definition of a set of TLB Invalidate Instructions.