Hi Gerd, Thanks, Chao On 2024/3/15 17:09, Gerd Hoffmann wrote: > On Mon, Mar 11, 2024 at 05:38:17PM +0800, Chao Li wrote: >> Added PcdCpuMmuIsEnabled to instruct that the CPU MMU is enabled. >> >> BZ:https://bugzilla.tianocore.org/show_bug.cgi?id=4584 >> >> Cc: Ray Ni >> Cc: Rahul Kumar >> Cc: Gerd Hoffmann >> Signed-off-by: Chao Li >> --- >> UefiCpuPkg/UefiCpuPkg.dec | 5 +++++ >> 1 file changed, 5 insertions(+) >> >> diff --git a/UefiCpuPkg/UefiCpuPkg.dec b/UefiCpuPkg/UefiCpuPkg.dec >> index a23a90ec99..b27cf88aee 100644 >> --- a/UefiCpuPkg/UefiCpuPkg.dec >> +++ b/UefiCpuPkg/UefiCpuPkg.dec >> @@ -486,5 +486,10 @@ [PcdsDynamic, PcdsDynamicEx] >> # @Prompt GHCB Hypervisor Features >> gUefiCpuPkgTokenSpaceGuid.PcdGhcbHypervisorFeatures|0x0|UINT64|0x60000018 >> >> + ## This dynamic PCD indicates whether CPU MMU is enabled. >> + # TRUE - CPU MMU is enabled. >> + # FASLE - CPU MMU have not enabled. >> + gUefiCpuPkgTokenSpaceGuid.PcdCpuMmuIsEnabled|FALSE|BOOLEAN|0x60000023 > Why create a PCD for this? Can't you simply read the control register > to figure whenever paging is enabled or not? This is a good question. When I designed the API of SetMemoryRegionAttributes, it only contained 4 parameters, namely Start, Size, Attribut and Mask(refer to ARM version), and the MmuInitLib needs call this API to configure or initialize the MMU. SetMemoryRegionAttributes will call a private function called UpdateRegionMapping, it needs to know if the MMU is started to do different logic(such as wether should be invalidated TLB when filling the tables for the first time, etc), therefore, there create a new PCD to let it know this. BTW, ARM and RISC-V have the same logic. > > take care, > Gerd > > > > > -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#116793): https://edk2.groups.io/g/devel/message/116793 Mute This Topic: https://groups.io/mt/104859880/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-