Skip to content

Commit

Permalink
fix: Read TTBR0_EL1 when EL is 0
Browse files Browse the repository at this point in the history
  • Loading branch information
xusine committed Sep 26, 2024
1 parent c43a822 commit ebccb72
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions components/MMU/TTResolvers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ TTResolver::TTResolver(bool abro, _TTResolver_Shptr_T aGranule, address_t aTTBR,
, PAddressWidth(PAddrWidth)
, regimeTG(aGranule)
{
DBG_Assert(aTTBR != 0);
TnSz = regimeTG->getIAddrOffset();
IAddressWidth = 64 - regimeTG->getIAddrSize();
}
Expand All @@ -26,6 +27,7 @@ address_t
TTResolver::resolve(address_t inputAddress)
{
DBG_(VVerb, (<< "TTBR RAW: " << std::hex << RawTTBRReg << std::dec));
DBG_Assert(RawTTBRReg != 0);
address_t output = extractBitsWithBounds(RawTTBRReg, TTBR_MSB, TTBR_LSB);
DBG_(VVerb, (<< "TTBR EXTRACT: " << std::hex << output << std::dec));
output = output << TTBR_LSB;
Expand Down
7 changes: 7 additions & 0 deletions components/MMU/pageWalk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,13 @@ PageWalk::InitialTranslationSetup(TranslationTransport& aTranslation)
statefulPointer->ELRegime = currentEL();

uint8_t EL = statefulPointer->ELRegime;

if (EL == 0) {
DBG_Assert(statefulPointer->isBR0);
// For Linux, the page table of El0 is in EL1's register.
EL = 1;
};

uint64_t initialTTBR;
if (statefulPointer->isBR0)
initialTTBR = theMMU->mmu_regs.TTBR0[EL];
Expand Down

0 comments on commit ebccb72

Please sign in to comment.