// ITB/DTB page table entry
struct PTE
{
- void serialize(std::ostream &os)
+ void serialize(CheckpointOut &cp) const
{
panic("Need to implement PTE serialization\n");
}
- void unserialize(Checkpoint *cp, const std::string §ion)
+ void unserialize(CheckpointIn &cp)
{
panic("Need to implement PTE serialization\n");
}
};
// ITB/DTB table entry
-struct TlbEntry
+struct TlbEntry : public Serializable
{
public:
enum class MemoryType : std::uint8_t {
// True if the entry was brought in from a non-secure page table
bool nstid;
// Exception level on insert, AARCH64 EL0&1, AARCH32 -> el=1
- uint8_t el;
+ ExceptionLevel el;
// Type of memory
bool nonCacheable; // Can we wrap this in mtype?
bool pxn; // Privileged Execute Never (LPAE only)
//Construct an entry that maps to physical address addr for SE mode
- TlbEntry(Addr _asn, Addr _vaddr, Addr _paddr) :
+ TlbEntry(Addr _asn, Addr _vaddr, Addr _paddr,
+ bool uncacheable, bool read_only) :
pfn(_paddr >> PageShift), size(PageBytes - 1), vpn(_vaddr >> PageShift),
attributes(0), lookupLevel(L1), asid(_asn), vmid(0), N(0),
- innerAttrs(0), outerAttrs(0), ap(0), hap(0x3),
+ innerAttrs(0), outerAttrs(0), ap(read_only ? 0x3 : 0), hap(0x3),
domain(DomainType::Client), mtype(MemoryType::StronglyOrdered),
longDescFormat(false), isHyp(false), global(false), valid(true),
- ns(true), nstid(true), el(0), nonCacheable(false), shareable(false),
- outerShareable(false), xn(0), pxn(0)
+ ns(true), nstid(true), el(EL0), nonCacheable(uncacheable),
+ shareable(false), outerShareable(false), xn(0), pxn(0)
{
// no restrictions by default, hap = 0x3
// @todo Check the memory type
+ if (read_only)
+ warn("ARM TlbEntry does not support read-only mappings\n");
}
TlbEntry() :
pfn(0), size(0), vpn(0), attributes(0), lookupLevel(L1), asid(0),
vmid(0), N(0), innerAttrs(0), outerAttrs(0), ap(0), hap(0x3),
domain(DomainType::Client), mtype(MemoryType::StronglyOrdered),
- longDescFormat(false), isHyp(false), global(false), valid(true),
- ns(true), nstid(true), el(0), nonCacheable(false),
+ longDescFormat(false), isHyp(false), global(false), valid(false),
+ ns(true), nstid(true), el(EL0), nonCacheable(false),
shareable(false), outerShareable(false), xn(0), pxn(0)
{
// no restrictions by default, hap = 0x3
bool
match(Addr va, uint8_t _vmid, bool hypLookUp, bool secure_lookup,
- uint8_t target_el) const
+ ExceptionLevel target_el) const
{
return match(va, 0, _vmid, hypLookUp, secure_lookup, true, target_el);
}
bool
match(Addr va, uint16_t asn, uint8_t _vmid, bool hypLookUp,
- bool secure_lookup, bool ignore_asn, uint8_t target_el) const
+ bool secure_lookup, bool ignore_asn, ExceptionLevel target_el) const
{
bool match = false;
Addr v = vpn << N;
if (valid && va >= v && va <= v + size && (secure_lookup == !nstid) &&
(hypLookUp == isHyp))
{
- if (target_el == 2 || target_el == 3)
- match = (el == target_el);
- else
- match = (el == 0) || (el == 1);
+ match = checkELMatch(target_el);
+
if (match && !ignore_asn) {
match = global || (asn == asid);
}
return match;
}
+ bool
+ checkELMatch(ExceptionLevel target_el) const
+ {
+ if (target_el == EL2 || target_el == EL3) {
+ return (el == target_el);
+ } else {
+ return (el == EL0) || (el == EL1);
+ }
+ }
+
Addr
pAddr(Addr va) const
{
}
void
- serialize(std::ostream &os)
+ serialize(CheckpointOut &cp) const override
{
SERIALIZE_SCALAR(longDescFormat);
SERIALIZE_SCALAR(pfn);
SERIALIZE_SCALAR(ap);
SERIALIZE_SCALAR(hap);
uint8_t domain_ = static_cast<uint8_t>(domain);
- paramOut(os, "domain", domain_);
+ paramOut(cp, "domain", domain_);
}
void
- unserialize(Checkpoint *cp, const std::string §ion)
+ unserialize(CheckpointIn &cp) override
{
UNSERIALIZE_SCALAR(longDescFormat);
UNSERIALIZE_SCALAR(pfn);
UNSERIALIZE_SCALAR(ap);
UNSERIALIZE_SCALAR(hap);
uint8_t domain_;
- paramIn(cp, section, "domain", domain_);
+ paramIn(cp, "domain", domain_);
domain = static_cast<DomainType>(domain_);
}