VOID\r
);\r
\r
+/**\r
+ Get page table base address and the depth of the page table.\r
+\r
+ @param[out] Base Page table base address.\r
+ @param[out] FiveLevels TRUE means 5 level paging. FALSE means 4 level paging.\r
+**/\r
+VOID\r
+GetPageTable (\r
+ OUT UINTN *Base,\r
+ OUT BOOLEAN *FiveLevels OPTIONAL\r
+ )\r
+{\r
+ *Base = ((mInternalCr3 == 0) ?\r
+ (AsmReadCr3 () & PAGING_4K_ADDRESS_MASK_64) :\r
+ mInternalCr3);\r
+ if (FiveLevels != NULL) {\r
+ *FiveLevels = FALSE;\r
+ }\r
+}\r
+\r
/**\r
Create PageTable for SMM use.\r
\r
UINT64 *L1PageTable;\r
UINT64 *L2PageTable;\r
UINT64 *L3PageTable;\r
+ UINTN PageTableBase;\r
BOOLEAN IsSplitted;\r
BOOLEAN PageTableSplitted;\r
BOOLEAN CetEnabled;\r
DEBUG ((DEBUG_INFO, "Start...\n"));\r
PageTableSplitted = FALSE;\r
\r
- L3PageTable = (UINT64 *)GetPageTableBase ();\r
+ GetPageTable (&PageTableBase, NULL);\r
+ L3PageTable = (UINT64 *)PageTableBase;\r
\r
- SmmSetMemoryAttributesEx ((EFI_PHYSICAL_ADDRESS)(UINTN)L3PageTable, SIZE_4KB, EFI_MEMORY_RO, &IsSplitted);\r
+ SmmSetMemoryAttributesEx ((EFI_PHYSICAL_ADDRESS)PageTableBase, SIZE_4KB, EFI_MEMORY_RO, &IsSplitted);\r
PageTableSplitted = (PageTableSplitted || IsSplitted);\r
\r
for (Index3 = 0; Index3 < 4; Index3++) {\r