Go to the documentation of this file.
46 #include "debug/TLB.hh"
47 #include "debug/TLBVerbose.hh"
49 #include "params/RiscvTLB.hh"
65 return (
static_cast<Addr>(
asid) << 48) | vpn;
69 :
BaseTLB(
p), size(
p->size),
tlb(size), lruSeq(0), stats(this)
71 for (
size_t x = 0;
x <
size;
x++) {
72 tlb[
x].trieHandle = NULL;
93 for (
size_t i = 1;
i <
size;
i++) {
128 DPRINTF(TLBVerbose,
"lookup(vpn=%#x, asid=%#x): %s ppn %#x\n",
129 vpn,
asid, entry ?
"hit" :
"miss", entry ? entry->
paddr : 0);
138 DPRINTF(
TLB,
"insert(vpn=%#x, asid=%#x): ppn=%#x pte=%#x size=%#x\n",
145 newEntry->
pte = entry.
pte;
146 assert(newEntry->
vaddr == vpn);
159 newEntry->
vaddr = vpn;
170 if (vpn == 0 &&
asid == 0)
174 if (vpn != 0 &&
asid != 0) {
180 for (
size_t i = 0;
i <
size;
i++) {
181 if (
tlb[
i].trieHandle) {
196 for (
size_t i = 0;
i <
size;
i++) {
197 if (
tlb[
i].trieHandle)
205 DPRINTF(
TLB,
"remove(vpn=%#x, asid=%#x): ppn=%#x pte=%#x size=%#x\n",
209 assert(
tlb[idx].trieHandle);
211 tlb[idx].trieHandle = NULL;
222 DPRINTF(
TLB,
"PTE has no read perm, raising PF\n");
226 DPRINTF(
TLB,
"PTE has no write perm, raising PF\n");
230 DPRINTF(
TLB,
"PTE has no exec perm, raising PF\n");
237 DPRINTF(
TLB,
"PTE is not user accessible, raising PF\n");
241 DPRINTF(
TLB,
"PTE is only user accessible, raising PF\n");
259 return std::make_shared<AddressFault>(
vaddr, code);
266 assert(
e !=
nullptr);
282 if (translation !=
nullptr || fault !=
NoFault) {
288 assert(
e !=
nullptr);
298 DPRINTF(
TLB,
"Dirty bit not set, repeating PT walk\n");
300 if (translation !=
nullptr || fault !=
NoFault) {
310 DPRINTF(TLBVerbose,
"translate(vpn=%#x, asid=%#x): %#x\n",
311 vaddr, satp.asid, paddr);
312 req->setPaddr(paddr);
322 if (
mode != Mode::Execute &&
status.mprv == 1)
344 req->setPaddr(req->getVaddr());
353 if (!delayed && fault ==
NoFault &&
bits(req->getPaddr(), 63)) {
361 fault = make_shared<AddressFault>(req->getVaddr(), code);
373 assert(req->getSize() > 0);
374 if (req->getVaddr() + req->getSize() - 1 < req->getVaddr())
375 return make_shared<GenericPageTableFault>(req->getVaddr());
379 Fault fault =
p->pTable->translate(req);
419 satp.mode != AddrXlateMode::BARE) {
423 tc, paddr, logBytes,
mode);
428 paddr |= masked_addr;
444 return std::make_shared<GenericPageTableFault>(req->getVaddr());
450 req->setPaddr(paddr);
470 for (uint32_t
x = 0;
x <
size;
x++) {
471 if (
tlb[
x].trieHandle != NULL)
483 fatal(
"TLB size less than the one in checkpoint!");
488 for (uint32_t
x = 0;
x < _size;
x++) {
500 :
Stats::Group(parent),
502 ADD_STAT(read_misses,
"read misses"),
503 ADD_STAT(read_accesses,
"read accesses"),
505 ADD_STAT(write_misses,
"write misses"),
506 ADD_STAT(write_accesses,
"write accesses"),
507 ADD_STAT(hits,
"Total TLB (read and write) hits", read_hits + write_hits),
508 ADD_STAT(misses,
"Total TLB (read and write) misses",
509 read_misses + write_misses),
510 ADD_STAT(accesses,
"Total TLB (read and write) accesses",
511 read_accesses + write_accesses)
516 RiscvTLBParams::create()
518 return new TLB(
this);
#define fatal(...)
This implements a cprintf based fatal() function.
PrivilegeMode getMemPriv(ThreadContext *tc, Mode mode)
virtual void finish(const Fault &fault, const RequestPtr &req, ThreadContext *tc, Mode mode)=0
void unserializeSection(CheckpointIn &cp, const char *name)
Unserialize an a child object.
void demapPage(Addr vaddr, uint64_t asn) override
Fault translate(const RequestPtr &req, ThreadContext *tc, Translation *translation, Mode mode, bool &delayed)
#define UNSERIALIZE_SCALAR(scalar)
TlbEntry * insert(Addr vpn, const TlbEntry &entry)
Value * remove(Handle handle)
Method to delete a value from the trie.
Handle insert(Key key, unsigned width, Value *val)
Method which inserts a key/value pair into the trie.
void serialize(CheckpointOut &cp) const override
Serialize an object.
EmulationPageTable * pTable
std::shared_ptr< Request > RequestPtr
bool FullSystem
The FullSystem variable can be used to determine the current mode of simulation.
virtual Process * getProcessPtr()=0
Fault translateFunctional(const RequestPtr &req, ThreadContext *tc, Mode mode) override
Stats::Scalar read_accesses
Addr translateWithTLB(Addr vaddr, uint16_t asid, Mode mode)
Value * lookup(Key key)
Method which looks up the Value corresponding to a particular key.
const Entry * lookup(Addr vaddr)
Lookup function.
Fault start(ThreadContext *_tc, BaseTLB::Translation *translation, const RequestPtr &req, BaseTLB::Mode mode)
@ PHYSICAL
The virtual address is also the physical address.
static const unsigned MaxBits
Fault createPagefault(Addr vaddr, Mode mode)
ThreadContext is the external interface to all thread state for anything outside of the CPU.
static Addr buildKey(Addr vpn, uint16_t asid)
#define ADD_STAT(n,...)
Convenience macro to add a stat to a statistics group.
std::shared_ptr< FaultBase > Fault
void translateTiming(const RequestPtr &req, ThreadContext *tc, Translation *translation, Mode mode) override
Stats::Scalar read_misses
TlbEntry * lookup(Addr vpn, uint16_t asid, Mode mode, bool hidden)
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Fault finalizePhysical(const RequestPtr &req, ThreadContext *tc, Mode mode) const override
Do post-translation physical address finalization.
void flushAll() override
Remove all entries from the TLB.
constexpr decltype(nullptr) NoFault
TlbStats(Stats::Group *parent)
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
#define SERIALIZE_SCALAR(scalar)
Fault doTranslate(const RequestPtr &req, ThreadContext *tc, Translation *translation, Mode mode, bool &delayed)
Stats::Scalar write_misses
virtual void markDelayed()=0
Signal that the translation has been delayed due to a hw page table walk.
Overload hash function for BasicBlockRange type.
Stats::Scalar write_accesses
Fault translateAtomic(const RequestPtr &req, ThreadContext *tc, Mode mode) override
virtual RegVal readMiscReg(RegIndex misc_reg)=0
Fault checkPermissions(STATUS status, PrivilegeMode pmode, Addr vaddr, Mode mode, PTESv39 pte)
std::ostream CheckpointOut
RiscvISA::TLB::TlbStats stats
bool fixupFault(Addr vaddr)
Attempt to fix up a fault at vaddr by allocating a page on the stack.
TlbEntryTrie::Handle trieHandle
Fault startFunctional(ThreadContext *_tc, Addr &addr, unsigned &logBytes, BaseTLB::Mode mode)
std::string csprintf(const char *format, const Args &...args)
std::vector< TlbEntry > tlb
virtual BaseTLB * getDTBPtr()=0
T bits(T val, int first, int last)
Extract the bitfield from position 'first' to 'last' (inclusive) from 'val' and right justify it.
Generated on Wed Sep 30 2020 14:01:59 for gem5 by doxygen 1.8.17