[edk2-devel] [PATCH v2 2/2] MdeModulePkg/VirtualMemory: fix 5-level paging assert

Gerd Hoffmann posted 2 patches 7 months, 2 weeks ago
[edk2-devel] [PATCH v2 2/2] MdeModulePkg/VirtualMemory: fix 5-level paging assert
Posted by Gerd Hoffmann 7 months, 2 weeks ago
The ResetVector decides at runtime (depending on CPU capabilities)
whenever it uses 5-level paging or not.  Firmware builds with 5-level
paging enabled (PcdEnable5LevelPageTable=TRUE) may run run in 4-level
paging mode.  The code handles that just fine, by looking at the la57
bit in cr4 instead of checking PcdEnable5LevelPageTable.

So the ASSERT is too strict.  Change it to ensure the build was
configured with PcdEnable5LevelPageTable=TRUE when running in 5-level
paging mode.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c b/MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c
index 46528e4f719d..9e194ef8cc55 100644
--- a/MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c
+++ b/MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c
@@ -745,7 +745,9 @@ CreateIdentityMappingPageTables (
     //
     Cr4.UintN         = AsmReadCr4 ();
     Page5LevelSupport = (Cr4.Bits.LA57 != 0);
-    ASSERT (PcdGetBool (PcdEnable5LevelPageTable) == Page5LevelSupport);
+    if (Page5LevelSupport) {
+      ASSERT (PcdGetBool (PcdEnable5LevelPageTable));
+    }
   } else {
     //
     // If cpu runs in 32bit protected mode PEI, Page table Level in DXE is decided by PCD and feature capability.
-- 
2.43.0



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#114375): https://edk2.groups.io/g/devel/message/114375
Mute This Topic: https://groups.io/mt/103950406/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-