From d402bd4853e7d96dcff9c92c217ccd26aa2c550e Mon Sep 17 00:00:00 2001 From: Bugra Eryilmaz Date: Tue, 13 Aug 2024 12:01:55 +0000 Subject: [PATCH] Fix: EL state --- components/MMU/pageWalk.cpp | 15 ++++++++++++++- components/MMU/pageWalk.hpp | 3 +++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/components/MMU/pageWalk.cpp b/components/MMU/pageWalk.cpp index df90f46f..52c10969 100644 --- a/components/MMU/pageWalk.cpp +++ b/components/MMU/pageWalk.cpp @@ -296,7 +296,7 @@ PageWalk::InitialTranslationSetup(TranslationTransport& aTranslation) statefulPointer->requiredTableLookups = 4 - initialLevel; statefulPointer->currentLookupLevel = initialLevel; statefulPointer->granuleSize = theMMU->getGranuleSize(statefulPointer->isBR0); - statefulPointer->ELRegime = 1; /*currentEL();*/ + statefulPointer->ELRegime = currentEL(); uint8_t EL = statefulPointer->ELRegime; uint64_t initialTTBR; @@ -406,6 +406,19 @@ PageWalk::hasMemoryRequest() return !theMemoryTranslations.empty(); } + +uint8_t +PageWalk::currentEL() +{ + return extract32(currentPSTATE(), 2, 2); +} + +uint32_t +PageWalk::currentPSTATE() +{ + return Flexus::Qemu::API::qemu_api.read_register(theNode, Flexus::Qemu::API::PSTATE, 0); +} + // TODO?? // TTEDescriptor PageWalk::getNextTTDescriptor(TranslationTransport & aTr ) { // DBG_Assert(false); } diff --git a/components/MMU/pageWalk.hpp b/components/MMU/pageWalk.hpp index 2891104f..7fe22b49 100644 --- a/components/MMU/pageWalk.hpp +++ b/components/MMU/pageWalk.hpp @@ -96,6 +96,9 @@ class PageWalk TTEDescriptor getNextTTDescriptor(TranslationTransport& aTranslation); + uint8_t currentEL(); + uint32_t currentPSTATE(); + uint32_t theNode; };