64 case 1:
return pte & 0x1;
65 case 2:
return pte & 0x1;
66 case 3:
return (pte & 0x1) && (pte & 0x2);
75 case 1:
return !(pte & 0x2);
76 case 2:
return !(pte & 0x2);
85 return stage2 ?
bits(pte, 7, 6)==3 :
bits(pte, 7)==0;
93 case 1:
return mbits(pte, 39, 30);
94 case 2:
return mbits(pte, 39, 21);
95 case 3:
return mbits(pte, 39, 12);
99 return mbits(pte, 39, 12);
110 case 1:
return bits(
va, std::min(26+
n, tsz - 1), 30) << 3;
break;
111 case 2:
return bits(
va, std::min(29, tsz - 1), 21) << 3;
break;
112 case 3:
return bits(
va, std::min(20, tsz - 1), 12) << 3;
break;
121 case 1:
return ~mask(30);
122 case 2:
return ~mask(21);
123 case 3:
return bits(pte, 52) ? ~mask(16) : ~mask(12);
142 return LookupLevel::L1;
148 return LookupLevel::L3;
155 case 0:
return pte & 0x1;
156 case 1:
return pte & 0x1;
157 case 2:
return pte & 0x1;
158 case 3:
return (pte & 0x1) && (pte & 0x2);
167 case 0:
return false;
168 case 1:
return !(pte & 0x2);
169 case 2:
return !(pte & 0x2);
178 return stage2 ?
bits(pte, 7, 6)==3 :
bits(pte, 7)==0;
187 case 1:
return mbits(pte, 47, 30);
188 case 2:
return mbits(pte, 47, 21);
189 case 3:
return mbits(pte, 47, 12);
193 return mbits(pte, 47, 12);
201 case 0:
return bits(
va, std::min(47, tsz - 1), 39) << 3;
break;
202 case 1:
return bits(
va, std::min(38, tsz - 1), 30) << 3;
break;
203 case 2:
return bits(
va, std::min(29, tsz - 1), 21) << 3;
break;
204 case 3:
return bits(
va, std::min(20, tsz - 1), 12) << 3;
break;
214 case 1:
return ~mask(30);
215 case 2:
return ~mask(21);
216 case 3:
return bits(pte, 52) ? ~mask(16) : ~mask(12);
236 if (tsz >= 16 && tsz <= 24)
return LookupLevel::L0;
237 if (tsz >= 25 && tsz <= 33)
return LookupLevel::L1;
238 if (tsz >= 34 && tsz <= 39)
return LookupLevel::L2;
240 panic(
"Unsupported TnSZ: %d\n", tsz);
247 case 0:
return LookupLevel::L2;
248 case 1:
return LookupLevel::L1;
249 case 2:
return LookupLevel::L0;
250 default:
panic(
"Unsupported VTCR_EL2.SL0: %d",
sl0);
257 return LookupLevel::L3;
264 case 0:
return pte & 0x1;
265 case 1:
return pte & 0x1;
266 case 2:
return pte & 0x1;
267 case 3:
return (pte & 0x1) && (pte & 0x2);
276 case 0:
return false;
277 case 1:
return false;
278 case 2:
return !(pte & 0x2);
287 return stage2 ?
bits(pte, 7, 6) == 3 :
bits(pte, 7) == 0;
296 case 1:
return mbits(pte, 47, 36);
297 case 2:
return mbits(pte, 47, 25);
298 case 3:
return mbits(pte, 47, 14);
302 return mbits(pte, 47, 14);
310 case 0:
return bits(
va, std::min(47, tsz - 1), 47) << 3;
break;
311 case 1:
return bits(
va, std::min(46, tsz - 1), 36) << 3;
break;
312 case 2:
return bits(
va, std::min(35, tsz - 1), 25) << 3;
break;
313 case 3:
return bits(
va, std::min(24, tsz - 1), 14) << 3;
break;
323 case 1:
return ~mask(36);
325 case 2:
return bits(pte, 52) ? ~mask(30) : ~mask(25);
327 case 3:
return bits(pte, 52) ? ~mask(21) : ~mask(14);
347 if (tsz == 16)
return LookupLevel::L0;
348 if (tsz >= 17 && tsz <= 27)
return LookupLevel::L1;
349 if (tsz >= 28 && tsz <= 38)
return LookupLevel::L2;
350 if (tsz == 39)
return LookupLevel::L3;
352 panic(
"Unsupported TnSZ: %d\n", tsz);
359 case 0:
return LookupLevel::L3;
360 case 1:
return LookupLevel::L2;
361 case 2:
return LookupLevel::L1;
362 default:
panic(
"Unsupported VTCR_EL2.SL0: %d",
sl0);
369 return LookupLevel::L3;
376 case 1:
return pte & 0x1;
377 case 2:
return pte & 0x1;
378 case 3:
return (pte & 0x1) && (pte & 0x2);
387 case 1:
return false;
388 case 2:
return !(pte & 0x2);
397 return stage2 ?
bits(pte, 7, 6)==3 :
bits(pte, 7)==0;
406 case 2:
return mbits(pte, 47, 29);
407 case 3:
return mbits(pte, 47, 16);
411 return mbits(pte, 47, 16);
419 case 1:
return bits(
va, std::min(47, tsz - 1), 42) << 3;
break;
420 case 2:
return bits(
va, std::min(41, tsz - 1), 29) << 3;
break;
421 case 3:
return bits(
va, std::min(28, tsz - 1), 16) << 3;
break;
431 case 2:
return ~mask(29);
432 case 3:
return bits(pte, 52) ? ~mask(21) : ~mask(16);
451 if (tsz >= 12 && tsz <= 21)
return LookupLevel::L1;
452 if (tsz >= 22 && tsz <= 34)
return LookupLevel::L2;
453 if (tsz >= 35 && tsz <= 39)
return LookupLevel::L3;
455 panic(
"Unsupported TnSZ: %d\n", tsz);
462 case 0:
return LookupLevel::L3;
463 case 1:
return LookupLevel::L2;
464 case 2:
return LookupLevel::L1;
465 default:
panic(
"Unsupported VTCR_EL2.SL0: %d",
sl0);
472 return LookupLevel::L3;
482 switch (trans_granule) {
487 panic(
"Unknown translation granule size %d", trans_granule);
constexpr T bits(T val, unsigned first, unsigned last)
Extract the bitfield from position 'first' to 'last' (inclusive) from 'val' and right justify it.
constexpr T mbits(T val, unsigned first, unsigned last)
Mask off the given bits in place like bits() but without shifting.
#define panic(...)
This implements a cprintf based panic() function.
const PageTableOps * getPageTableOps(GrainSize trans_granule)
const GrainSize GrainMap_tg1[]
const GrainSize GrainMap_tg0[]
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
enums::ArmLookupLevel LookupLevel
Addr walkMask(unsigned level) const
virtual unsigned walkBits(unsigned level) const =0
Addr pageMask(pte_t pte, unsigned level) const override
bool isValid(pte_t pte, unsigned level) const override
bool isLeaf(pte_t pte, unsigned level) const override
bool isWritable(pte_t pte, unsigned level, bool stage2) const override
Addr nextLevelPointer(pte_t pte, unsigned level) const override
Addr index(Addr va, unsigned level, int tsz) const override
unsigned walkBits(unsigned level) const override
LookupLevel firstLevel(uint8_t tsz) const override
LookupLevel lastLevel() const override
Addr index(Addr va, unsigned level, int tsz) const override
LookupLevel firstS2Level(uint8_t sl0) const override
unsigned walkBits(unsigned level) const override
Addr pageMask(pte_t pte, unsigned level) const override
bool isLeaf(pte_t pte, unsigned level) const override
LookupLevel firstLevel(uint8_t tsz) const override
bool isValid(pte_t pte, unsigned level) const override
LookupLevel lastLevel() const override
Addr nextLevelPointer(pte_t pte, unsigned level) const override
bool isWritable(pte_t pte, unsigned level, bool stage2) const override
unsigned walkBits(unsigned level) const override
Addr pageMask(pte_t pte, unsigned level) const override
LookupLevel firstS2Level(uint8_t sl0) const override
bool isWritable(pte_t pte, unsigned level, bool stage2) const override
Addr index(Addr va, unsigned level, int tsz) const override
Addr nextLevelPointer(pte_t pte, unsigned level) const override
LookupLevel lastLevel() const override
bool isValid(pte_t pte, unsigned level) const override
bool isLeaf(pte_t pte, unsigned level) const override
LookupLevel firstLevel(uint8_t tsz) const override
Addr nextLevelPointer(pte_t pte, unsigned level) const override
LookupLevel lastLevel() const override
bool isValid(pte_t pte, unsigned level) const override
unsigned walkBits(unsigned level) const override
Addr index(Addr va, unsigned level, int tsz) const override
LookupLevel firstLevel(uint8_t tsz) const override
Addr pageMask(pte_t pte, unsigned level) const override
bool isWritable(pte_t pte, unsigned level, bool stage2) const override
LookupLevel firstS2Level(uint8_t sl0) const override
bool isLeaf(pte_t pte, unsigned level) const override