Go to the documentation of this file.
52 #include "debug/TLB.hh"
63 :
BaseTLB(
p), configAddress(0), size(
p->size),
64 tlb(size), lruSeq(0), m5opRange(
p->
system->m5opRange()), stats(this)
67 fatal(
"TLBs must have a non-zero size.\n");
69 for (
int x = 0;
x <
size;
x++) {
70 tlb[
x].trieHandle = NULL;
85 for (
unsigned i = 1;
i <
size;
i++) {
90 assert(
tlb[lru].trieHandle);
92 tlb[lru].trieHandle = NULL;
102 assert(newEntry->
vaddr == vpn);
114 newEntry->
vaddr = vpn;
124 if (entry && update_lru)
133 for (
unsigned i = 0;
i <
size;
i++) {
134 if (
tlb[
i].trieHandle) {
136 tlb[
i].trieHandle = NULL;
151 DPRINTF(
TLB,
"Invalidating all non global entries.\n");
152 for (
unsigned i = 0;
i <
size;
i++) {
153 if (
tlb[
i].trieHandle && !
tlb[
i].global) {
155 tlb[
i].trieHandle = NULL;
197 DPRINTF(
TLB,
"Addresses references internal memory.\n");
201 panic(
"CPUID memory space not yet implemented!\n");
207 return std::make_shared<GeneralProtection>(0);
209 req->setPaddr(req->getVaddr());
210 req->setLocalAccessor(
213 return localMiscRegAccess(read, regNum, tc, pkt);
225 assert(!(IOPort & ~0xFFFF));
226 if (IOPort == 0xCF8 && req->getSize() == 4) {
227 req->setPaddr(req->getVaddr());
228 req->setLocalAccessor(
231 return localMiscRegAccess(
235 }
else if ((IOPort & ~
mask(2)) == 0xCFC) {
252 panic(
"Access to unrecognized internal address space %#x.\n",
261 Addr paddr = req->getPaddr();
267 req->setLocalAccessor(
271 PseudoInst::pseudoInst<X86PseudoInstABI, true>(tc, func, ret);
279 LocalApicBase localApicBase =
299 paddr - apicRange.
start()));
309 Mode mode,
bool &delayedResponse,
bool timing)
315 delayedResponse =
false;
332 if (m5Reg.mode != LongMode) {
333 DPRINTF(
TLB,
"Not in long mode. Checking segment protection.\n");
338 return std::make_shared<GeneralProtection>(0);
343 return std::make_shared<GeneralProtection>(0);
345 return std::make_shared<GeneralProtection>(0);
352 unsigned logSize = sizeOverride ? (unsigned)m5Reg.altAddr
353 : (
unsigned)m5Reg.defAddr;
354 int size = (1 << logSize) * 8;
358 DPRINTF(
TLB,
"Checking an expand down segment.\n");
359 warn_once(
"Expand down segments are untested.\n");
361 return std::make_shared<GeneralProtection>(0);
364 return std::make_shared<GeneralProtection>(0);
382 "address %#x at pc %#x.\n",
391 if (timing || fault !=
NoFault) {
393 delayedResponse =
true;
403 return std::make_shared<PageFault>(
vaddr,
true,
mode,
406 Addr alignedVaddr =
p->pTable->pageAlign(
vaddr);
407 DPRINTF(
TLB,
"Mapping %#x to %#x\n", alignedVaddr,
410 p->pTable->pid(), alignedVaddr, pte->
paddr,
419 "doing protection checks.\n", entry->
paddr);
421 bool inUser = (m5Reg.cpl == 3 &&
424 bool badWrite = (!entry->
writable && (inUser || cr0.wp));
425 if ((inUser && !entry->
user) || (
mode ==
Write && badWrite)) {
429 return std::make_shared<PageFault>(
vaddr,
true,
mode, inUser,
432 if (storeCheck && badWrite) {
435 return std::make_shared<PageFault>(
vaddr,
true,
Write, inUser,
441 req->setPaddr(paddr);
448 req->setPaddr(
vaddr);
454 req->setPaddr(
vaddr);
463 bool delayedResponse;
492 return std::make_shared<PageFault>(
vaddr,
true,
mode,
true,
false);
497 req->setPaddr(paddr);
505 bool delayedResponse;
509 if (!delayedResponse)
522 :
Stats::Group(parent),
523 ADD_STAT(rdAccesses,
"TLB accesses on read requests"),
524 ADD_STAT(wrAccesses,
"TLB accesses on write requests"),
525 ADD_STAT(rdMisses,
"TLB misses on read requests"),
526 ADD_STAT(wrMisses,
"TLB misses on write requests")
539 for (uint32_t
x = 0;
x <
size;
x++) {
540 if (
tlb[
x].trieHandle != NULL)
552 fatal(
"TLB size less than the one in checkpoint!");
557 for (uint32_t
x = 0;
x < _size;
x++) {
576 X86TLBParams::create()
#define fatal(...)
This implements a cprintf based fatal() function.
virtual RegVal readMiscRegNoEffect(RegIndex misc_reg) const =0
virtual void finish(const Fault &fault, const RequestPtr &req, ThreadContext *tc, Mode mode)=0
std::vector< TlbEntry > tlb
void unserializeSection(CheckpointIn &cp, const char *name)
Unserialize an a child object.
#define UNSERIALIZE_SCALAR(scalar)
void writeData(uint8_t *p) const
Copy data from the packet to the memory at the provided pointer.
const Addr PhysAddrPrefixPciConfig
Port & getPort(const std::string &if_name, PortID idx=InvalidPortID) override
Get a port with a given name and index.
Value * remove(Handle handle)
Method to delete a value from the trie.
void flushAll() override
Remove all entries from the TLB.
Handle insert(Key key, unsigned width, Value *val)
Method which inserts a key/value pair into the trie.
static MiscRegIndex MISCREG_SEG_LIMIT(int index)
const Addr PhysAddrPrefixIO
EmulationPageTable * pTable
bool contains(const Addr &a) const
Determine if the range contains an address.
std::shared_ptr< Request > RequestPtr
Port * getTableWalkerPort() override
Get the table walker port.
static void decodeAddrOffset(Addr offset, uint8_t &func)
bool FullSystem
The FullSystem variable can be used to determine the current mode of simulation.
virtual Process * getProcessPtr()=0
Fault translateInt(bool read, RequestPtr req, ThreadContext *tc)
T mbits(T val, int first, int last)
Mask off the given bits in place like bits() but without shifting.
Value * lookup(Key key)
Method which looks up the Value corresponding to a particular key.
bool msrAddrToIndex(MiscRegIndex ®Num, Addr addr)
Find and return the misc reg corresponding to an MSR address.
const Addr IntAddrPrefixIO
const Addr IntAddrPrefixMask
const Entry * lookup(Addr vaddr)
Lookup function.
void setData(const uint8_t *p)
Copy data into the packet from the provided pointer.
static MiscRegIndex MISCREG_SEG_SEL(int index)
Fault translate(const RequestPtr &req, ThreadContext *tc, Translation *translation, Mode mode, bool &delayedResponse, bool timing)
TlbEntryTrie::Handle trieHandle
@ STRICT_ORDER
The request is required to be strictly ordered by CPU models and is non-speculative.
Bitfield< 14 > expandDown
static const unsigned MaxBits
Fault startFunctional(ThreadContext *_tc, Addr &addr, unsigned &logBytes, BaseTLB::Mode mode)
ThreadContext is the external interface to all thread state for anything outside of the CPU.
The AddrRange class encapsulates an address range, and supports a number of tests to check if two ran...
Fault start(ThreadContext *_tc, BaseTLB::Translation *translation, const RequestPtr &req, BaseTLB::Mode mode)
#define ADD_STAT(n,...)
Convenience macro to add a stat to a statistics group.
TlbEntry * insert(Addr vpn, const TlbEntry &entry)
std::shared_ptr< FaultBase > Fault
const Request::FlagsType M5_VAR_USED SegmentFlagMask
Ports are used to interface objects to each other.
void translateTiming(const RequestPtr &req, ThreadContext *tc, Translation *translation, Mode mode) override
virtual ContextID contextId() const =0
static MiscRegIndex MISCREG_SEG_ATTR(int index)
TlbEntry * lookup(Addr va, bool update_lru=true)
@ UNCACHEABLE
The request is to an uncacheable address.
void unserialize(CheckpointIn &cp) override
Unserialize an object.
constexpr decltype(nullptr) NoFault
@ MISCREG_PCI_CONFIG_ADDRESS
This is exposed globally, independent of the ISA.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
void demapPage(Addr va, uint64_t asn) override
void setConfigAddress(uint32_t addr)
#define SERIALIZE_SCALAR(scalar)
static Addr x86LocalAPICAddress(const uint8_t id, const uint16_t addr)
const Addr IntAddrPrefixMSR
X86ISA::TLB::TlbStats stats
void serialize(CheckpointOut &cp) const override
Serialize an object.
Fault finalizePhysical(const RequestPtr &req, ThreadContext *tc, Mode mode) const override
Do post-translation physical address finalization.
virtual void markDelayed()=0
Signal that the translation has been delayed due to a hw page table walk.
Addr start() const
Get the start address of the range.
T insertBits(T val, int first, int last, B bit_val)
Returns val with bits first to last set to the LSBs of bit_val.
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
virtual RegVal readMiscReg(RegIndex misc_reg)=0
virtual void setMiscReg(RegIndex misc_reg, RegVal val)=0
Fault translateFunctional(const RequestPtr &req, ThreadContext *tc, Mode mode) override
Cycles is a wrapper class for representing cycle counts, i.e.
BitfieldType< SegDescriptorLimit > limit
void setLE(T v)
Set the value in the data pointer to v as little endian.
std::ostream CheckpointOut
static MiscRegIndex MISCREG_SEG_BASE(int index)
bool fixupFault(Addr vaddr)
Attempt to fix up a fault at vaddr by allocating a page on the stack.
TlbStats(Stats::Group *parent)
virtual Addr instAddr() const =0
std::string csprintf(const char *format, const Args &...args)
Fault translateAtomic(const RequestPtr &req, ThreadContext *tc, Mode mode) override
#define panic(...)
This implements a cprintf based panic() function.
const Addr IntAddrPrefixCPUID
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