38 #ifndef __ARCH_ARM_TABLE_WALKER_HH__ 39 #define __ARCH_ARM_TABLE_WALKER_HH__ 48 #include "params/ArmTableWalker.hh" 75 virtual bool xn()
const = 0;
76 virtual uint8_t
ap()
const = 0;
80 virtual std::string
dbgHeader()
const = 0;
84 panic(
"texcb() not implemented for this class\n");
88 panic(
"shareable() not implemented for this class\n");
122 return "Inserting Section Descriptor into TLB\n";
138 return bits(data, 18);
145 panic(
"Super sections not implemented\n");
146 return mbits(data, 31, 20);
152 panic(
"Super sections not implemented\n");
153 return mbits(data, 31, 20) |
mbits(va, 19, 0);
161 panic(
"Super sections not implemented\n");
162 return bits(data, 31, 20);
168 return !
bits(data, 17);
174 return bits(data, 4);
180 return (
bits(data, 15) << 2) |
bits(data, 11, 10);
192 return mbits(data, 31, 10);
202 return bits(data, 2) |
bits(data, 3) << 1 |
bits(data, 14, 12) << 2;
208 return bits(data, 16);
233 if (
type() == PageTable)
234 return !
bits(data, 3);
236 return !
bits(data, 19);
272 return "Inserting L2 Descriptor into TLB\n";
277 return l1Parent->
domain();
282 return l1Parent->
secure(have_security, currState);
287 return large() ? 16 : 12;
293 return bits(data, 1, 0) == 0;
299 return bits(data, 1) == 0;
305 return large() ?
bits(data, 15) :
bits(data, 0);
311 return !
bits(data, 11);
317 return bits(data, 5, 4) | (
bits(data, 9) << 2);
324 (
bits(data, 2) | (
bits(data, 3) << 1) | (
bits(data, 14, 12) << 2)) :
325 (
bits(data, 2) | (
bits(data, 3) << 1) | (
bits(data, 8, 6) << 2));
331 return large() ?
bits(data, 31, 16) :
bits(data, 31, 12);
338 return mbits(data, 31, 16) |
mbits(va, 15, 0);
340 return mbits(data, 31, 12) |
mbits(va, 11, 0);
346 return bits(data, 10);
403 return "Inserting Page descriptor into TLB\n";
406 return "Inserting Block descriptor into TLB\n";
429 switch (
bits(data, 1, 0)) {
456 panic(
"Invalid AArch64 VM granule size\n");
458 }
else if (
type() == Page) {
465 panic(
"Invalid AArch64 VM granule size\n");
468 panic(
"AArch64 page table entry must be block or page\n");
485 return mbits(data, 47, n) |
mbits(va, n - 1, 0);
486 return mbits(data, 39, n) |
mbits(va, n - 1, 0);
500 assert(
type() == Table);
502 return mbits(data, 47, grainSize);
504 return mbits(data, 39, 12);
510 assert(
type() == Table);
513 int stride = grainSize - 3;
514 int va_lo = stride * (3 - (
lookupLevel + 1)) + grainSize;
515 int va_hi = va_lo + stride - 1;
516 pa = nextTableAddr() | (
bits(va, va_hi, va_lo) << 3);
519 pa = nextTableAddr() | (
bits(va, 29, 21) << 3);
521 pa = nextTableAddr() | (
bits(va, 20, 12) << 3);
530 return bits(data, 54);
537 return bits(data, 53);
544 return bits(data, 52);
554 }
else if (currState->
aarch64) {
555 if (currState->
el ==
EL2 || currState->
el ==
EL3) {
562 return !
bits(data, 11);
569 return bits(data, 10);
576 return bits(data, 9, 8);
584 return bits(data, 7, 6);
591 return !
bits(data, 7);
598 return bits(data, 6);
604 static uint8_t
ap(
bool rw,
bool user)
606 return ((!rw) << 2) | (user << 1);
620 return bits(data, 4, 2);
627 return bits(data, 5, 2);
647 assert(
type() == Table);
648 return !
bits(data, 63);
654 assert(
type() == Table);
655 return bits(data, 62, 61);
661 assert(
type() == Table);
662 return !
bits(data, 62);
669 assert(
type() == Table);
670 return !
bits(data, 61);
676 assert(
type() == Table);
677 return bits(data, 60);
683 assert(
type() == Table);
684 return bits(data, 59);
814 std::string
name()
const {
return tableWalker->
name(); }
888 return dynamic_cast<const Params *
>(
_params);
891 void init()
override;
907 uint16_t
asid, uint8_t _vmid,
909 bool timing,
bool functional,
bool secure,
978 #endif //__ARCH_ARM_TABLE_WALKER_HH__
#define panic(...)
This implements a cprintf based panic() function.
void regStats() override
Callback to set stat parameters.
bool large() const
What is the size of the mapping?
void memAttrsLPAE(ThreadContext *tc, TlbEntry &te, LongDescriptor &lDescriptor)
Ports are used to interface objects to each other.
bool contiguousHint() const
Contiguous hint bit.
void doL2DescriptorWrapper()
void init() override
init() is called after all C++ SimObjects have been created and all ports are connected.
bool isFetch
If the access is a fetch (for execution, and no-exec) must be checked?
LookupLevel lookupLevel
Current lookup level for this descriptor.
bool shareable() const
If the section is shareable.
L1Descriptor()
Default ctor.
virtual TlbEntry::DomainType domain() const =0
uint32_t data
The raw bits of the entry.
virtual Addr pfn() const =0
const PortID InvalidPortID
void doL3LongDescriptorWrapper()
unsigned numSquashable
The number of walks belonging to squashed instructions that can be removed from the pendingQueue per ...
Addr l2Addr() const
Address of L2 descriptor if it exists.
Addr paddr() const
Return the physcal address of the entry, bits in position.
std::list< WalkerState * > stateQueues[MAX_LOOKUP_LEVELS]
Queues of requests for all the different lookup levels.
virtual uint64_t getRawData() const
TableWalker * tableWalker
GrainSize grainSize
Width of the granule size in bits.
bool pending
If a timing translation is currently in progress.
EventFunctionWrapper doL2LongDescEvent
Declaration of a request, the overall memory request consisting of the parts of the request that are ...
Bitfield< 21, 20 > stride
EntryType type() const
Return the descriptor type.
std::shared_ptr< Request > RequestPtr
virtual std::string dbgHeader() const
static uint8_t pageSizeNtoStatBin(uint8_t N)
Stats::Vector statWalksShortTerminatedAtLevel
bool secureTable() const
Whether the subsequent levels of lookup are secure.
Fault testWalk(Addr pa, Addr size, TlbEntry::DomainType domain, LookupLevel lookup_level)
TableWalker(const Params *p)
bool isWrite
If the access is a write.
bool invalid() const
Is the entry invalid.
Stats::Histogram statPendingWalks
DrainState drain() override
Notify an object that it needs to drain its state.
virtual uint8_t texcb() const
bool haveSecurity
Cached copies of system-level properties.
Stats::Scalar statWalksShortDescriptor
bool timing
If the mode is timing or atomic.
uint8_t memAttr() const
Memory attributes, only used by stage 2 translations.
uint8_t ap() const
Three bit access protection flags.
bool isUncacheable
True if table walks are uncacheable (for table descriptors)
bool secure(bool have_security, WalkerState *currState) const
Stats::Scalar statSquashedBefore
A vector of scalar stats.
void processWalkWrapper()
bool hpd
Hierarchical access permission disable.
CPSR cpsr
Cached copy of the cpsr as it existed when translation began.
bool rw() const
Read/write access protection flag.
bool stage2Req
Flag indicating if a second stage of lookup is required.
TLB::Translation * transState
Translation state for delayed requests.
HTCR htcr
Cached copy of the htcr as it existed when translation began.
void doL2LongDescriptorWrapper()
uint8_t texcb() const
Memory region attributes: ARM DDI 0406B: B3-32.
Addr pfn() const
Return the physical frame, bits shifted right.
uint8_t attrIndx() const
Attribute index.
ThreadContext is the external interface to all thread state for anything outside of the CPU...
virtual uint64_t getRawData() const
EventFunctionWrapper doL0LongDescEvent
virtual std::string dbgHeader() const
Fault walk(const RequestPtr &req, ThreadContext *tc, uint16_t asid, uint8_t _vmid, bool _isHyp, TLB::Mode mode, TLB::Translation *_trans, bool timing, bool functional, bool secure, TLB::ArmTranslationType tranType, bool _stage2Req)
This is a simple scalar statistic, like a counter.
Addr vaddr
The virtual address that is being translated with tagging removed.
virtual bool secure(bool have_security, WalkerState *currState) const =0
DrainState
Object drain/handover states.
DmaPort * port
Port shared by the two table walkers.
uint8_t offsetBits() const
Return the bit width of the page/block offset.
void memAttrs(ThreadContext *tc, TlbEntry &te, SCTLR sctlr, uint8_t texcb, bool s)
Addr pfn() const
Return the physical frame, bits shifted right.
bool haveVirtualization() const
EventFunctionWrapper doL1DescEvent
virtual uint8_t offsetBits() const =0
bool xn() const
Is the translation not allow execution?
bool haveLargeAsid64() const
HCR hcr
Cached copy of the htcr as it existed when translation began.
MasterID masterId
Master id assigned by the MMU.
Addr paddr(Addr va) const
Return complete physical address given a VA.
Stats::Vector statWalksLongTerminatedAtLevel
bool dirty() const
This entry needs to be written back to memory.
bool secure(bool have_security, WalkerState *currState) const
Returns true if this entry targets the secure physical address map.
bool global(WalkerState *currState) const
Is the translation global (no asid used)?
void insertTableEntry(DescriptorBase &descriptor, bool longDescriptor)
int physAddrRange
Current physical address range in bits.
Fault fault
The fault that we are going to return.
const Params * params() const
static LookupLevel toLookupLevel(uint8_t lookup_level_as_int)
virtual bool xn() const =0
uint64_t Tick
Tick count type.
static uint8_t ap(bool rw, bool user)
Return the AP bits as compatible with the AP[2:0] format.
bool _dirty
This entry has been modified (access flag set) and needs to be written back to memory.
The ClockedObject class extends the SimObject with a clock and accessor functions to relate ticks to ...
virtual uint8_t offsetBits() const
bool global(WalkerState *currState) const
Is the translation global (no asid used)?
void setMMU(Stage2MMU *m, MasterID master_id)
ExceptionLevel el
Current exception level.
EventFunctionWrapper doL3LongDescEvent
uint8_t apTable() const
Two bit access protection flags for subsequent levels of lookup.
void doL1LongDescriptorWrapper()
bool dirty() const
This entry needs to be written back to memory.
Addr pfn() const
Return the physical frame, bits shifted right.
ClockedObject declaration and implementation.
bool isSecure
If the access comes from the secure state.
bool fetchDescriptor(Addr descAddr, uint8_t *data, int numBytes, Request::Flags flags, int queueIndex, Event *event, void(TableWalker::*doDescriptor)())
void doLongDescriptorWrapper(LookupLevel curr_lookup_level)
bool supersection() const
Is the page a Supersection (16MB)?
bool xnTable() const
Is execution allowed on subsequent lookup levels?
Event * LongDescEventByLevel[4]
bool dirty() const
This entry needs to be written back to memory.
Stats::Histogram statWalkServiceTime
Fault generateLongDescFault(ArmFault::FaultSource src)
TLB::ArmTranslationType tranType
The translation type that has been requested.
bool functional
If the atomic mode should be functional.
SCTLR sctlr
Cached copy of the sctlr as it existed when translation began.
void doL0LongDescriptorWrapper()
virtual bool global(WalkerState *currState) const =0
virtual uint8_t offsetBits() const
Port & getPort(const std::string &if_name, PortID idx=InvalidPortID) override
Get a port with a given name and index.
static unsigned adjustTableSizeAArch64(unsigned tsz)
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
virtual bool shareable() const
uint8_t userTable() const
User/privileged mode protection flag for subsequent levels of lookup.
void completeDrain()
Checks if all state is cleared and if so, completes drain.
SCTLR sctlr
Cached copy of the sctlr as it existed when translation began.
Addr paddr(Addr va) const
Return the physcal address of the entry, bits in position.
uint8_t ap() const
2-bit access protection flags
bool _dirty
This entry has been modified (access flag set) and needs to be written back to memory.
Stats::Histogram statWalkWaitTime
L2Descriptor()
Default ctor.
Stats::Scalar statSquashedAfter
static const unsigned REQUESTED
TLB * tlb
TLB that is initiating these table walks.
SCR scr
Cached copy of the scr as it existed when translation began.
bool shareable() const
If the section is shareable.
void drainResume() override
Resume execution after a successful drain.
uint8_t texcb() const
Memory region attributes: ARM DDI 0406B: B3-32.
bool xn() const
Is execution allowed on this mapping?
virtual uint8_t ap() const =0
virtual uint64_t getRawData() const
virtual TlbEntry::DomainType domain() const
virtual const std::string name() const
std::list< WalkerState * > pendingQueue
Queue of requests that have passed are waiting because the walker is currently busy.
Tick startTime
Timestamp for calculating elapsed time in service (for stats)
Stats::Scalar statWalks
Statistics.
uint64_t data
The raw bits of the entry.
ThreadContext * tc
Thread context that we're doing the walk for.
bool pxn() const
Is privileged execution allowed on this mapping? (LPAE only)
static const unsigned COMPLETED
virtual uint64_t getRawData() const =0
bool xn() const
Is execution allowed on this mapping?
EventFunctionWrapper doProcessEvent
const SimObjectParams * _params
Cached copy of the object parameters.
LongDescriptor longDesc
Long-format descriptor (LPAE and AArch64)
unsigned levels
Page entries walked during service (for stats)
Level 2 page table descriptor.
TlbEntry::DomainType domain() const
Domain Client/Manager: ARM DDI 0406B: B3-31.
TlbEntry::DomainType domain() const
virtual std::string dbgHeader() const
void doL1DescriptorWrapper()
BaseTLB::Mode mode
Save mode for use in delayed response.
uint16_t asid
ASID that we're servicing the request under.
Stats::Scalar statWalksLongDescriptor
VTCR_t vtcr
Cached copy of the vtcr as it existed when translation began.
Stats::Vector2d statRequestOrigin
Addr paddr(Addr va) const
Return the complete physical address given a VA.
L1Descriptor l1Desc
Short-format descriptors.
void nextWalk(ThreadContext *tc)
uint32_t data
The raw bits of the entry.
virtual std::string dbgHeader() const =0
bool secure(bool have_security, WalkerState *currState) const
Returns true if this entry targets the secure physical address map.
Addr nextDescAddr(Addr va) const
Return the address of the next descriptor.
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
EntryType
Descriptor type.
FaultSource
Generic fault source enums used to index into {short/long/aarch64}DescFaultSources[] to get the actua...
uint8_t sh() const
2-bit shareability field
Addr paddr() const
Return the physical address of the entry.
L2Descriptor(L1Descriptor &parent)
bool secureLookup
Helper variables used to implement hierarchical access permissions when the long-desc.
Stage2MMU * stage2Mmu
The MMU to forward second stage look upts to.
A 2-Dimensional vecto of scalar stats.
EntryType
Type of page table entry ARM DDI 0406B: B3-8.
bool aarch64
True if the current lookup is performed in AArch64 state.
T mbits(T val, int first, int last)
Mask off the given bits in place like bits() but without shifting.
bool aarch64
If the access is performed in AArch64 state.
T bits(T val, int first, int last)
Extract the bitfield from position 'first' to 'last' (inclusive) from 'val' and right justify it...
Fault processWalkAArch64()
ArmTableWalkerParams Params
const bool isStage2
Indicates whether this table walker is part of the stage 2 mmu.
bool af() const
Returns true if the access flag (AF) is set.
void setAp0()
Set access flag that this entry has been touched.
static bool checkAddrSizeFaultAArch64(Addr addr, int currPhysAddrRange)
Returns true if the address exceeds the range permitted by the system-wide setting or by the TCR_ELx ...
uint8_t ap() const
Three bit access protection flags.
bool user() const
User/privileged level access protection flag.
std::shared_ptr< FaultBase > Fault
EventFunctionWrapper doL1LongDescEvent
Addr nextTableAddr() const
Return the address of the next page table.
Long-descriptor format (LPAE)
void setAf()
Set access flag that this entry has been touched.
bool pxnTable() const
Is privileged execution allowed on subsequent lookup levels?
void memAttrsAArch64(ThreadContext *tc, TlbEntry &te, LongDescriptor &lDescriptor)
Addr vaddr_tainted
The virtual address that is being translated.
EventFunctionWrapper doL2DescEvent
RequestPtr req
Request that is currently being serviced.
bool delayed
Whether the response is delayed in timing mode due to additional lookups.
uint8_t rwTable() const
R/W protection flag for subsequent levels of lookup.
void setAp0()
Set access flag that this entry has been touched.
TLB::Translation * stage2Tran
A pointer to the stage 2 translation that's in progress.
Stats::Vector statPageSizes
bool global(WalkerState *currState) const
Is the translation global (no asid used)?
bool _dirty
This entry has been modified (access flag set) and needs to be written back to memory.