]> git.proxmox.com Git - mirror_edk2.git/blobdiff - UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/PageTbl.c
UefiCpuPkg/PiSmmCpuDxeSmm: Remove mInternalCr3 in PiSmmCpuDxeSmm
[mirror_edk2.git] / UefiCpuPkg / PiSmmCpuDxeSmm / Ia32 / PageTbl.c
index 8ec8790c05b690a06ad163e8b568d5a4d1c44c45..97058a2810c5c82242f7afe90d31a1d279adbd6e 100644 (file)
@@ -28,26 +28,6 @@ EnableCet (
   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
@@ -297,10 +277,10 @@ SetPageTableAttributes (
     DEBUG ((DEBUG_INFO, "Start...\n"));\r
     PageTableSplitted = FALSE;\r
 \r
-    GetPageTable (&PageTableBase, NULL);\r
-    L3PageTable = (UINT64 *)PageTableBase;\r
+    PageTableBase = AsmReadCr3 () & PAGING_4K_ADDRESS_MASK_64;\r
+    L3PageTable   = (UINT64 *)PageTableBase;\r
 \r
-    SmmSetMemoryAttributesEx ((EFI_PHYSICAL_ADDRESS)PageTableBase, SIZE_4KB, EFI_MEMORY_RO, &IsSplitted);\r
+    SmmSetMemoryAttributesEx (PageTableBase, FALSE, (EFI_PHYSICAL_ADDRESS)PageTableBase, SIZE_4KB, EFI_MEMORY_RO, &IsSplitted);\r
     PageTableSplitted = (PageTableSplitted || IsSplitted);\r
 \r
     for (Index3 = 0; Index3 < 4; Index3++) {\r
@@ -309,7 +289,7 @@ SetPageTableAttributes (
         continue;\r
       }\r
 \r
-      SmmSetMemoryAttributesEx ((EFI_PHYSICAL_ADDRESS)(UINTN)L2PageTable, SIZE_4KB, EFI_MEMORY_RO, &IsSplitted);\r
+      SmmSetMemoryAttributesEx (PageTableBase, FALSE, (EFI_PHYSICAL_ADDRESS)(UINTN)L2PageTable, SIZE_4KB, EFI_MEMORY_RO, &IsSplitted);\r
       PageTableSplitted = (PageTableSplitted || IsSplitted);\r
 \r
       for (Index2 = 0; Index2 < SIZE_4KB/sizeof (UINT64); Index2++) {\r
@@ -323,7 +303,7 @@ SetPageTableAttributes (
           continue;\r
         }\r
 \r
-        SmmSetMemoryAttributesEx ((EFI_PHYSICAL_ADDRESS)(UINTN)L1PageTable, SIZE_4KB, EFI_MEMORY_RO, &IsSplitted);\r
+        SmmSetMemoryAttributesEx (PageTableBase, FALSE, (EFI_PHYSICAL_ADDRESS)(UINTN)L1PageTable, SIZE_4KB, EFI_MEMORY_RO, &IsSplitted);\r
         PageTableSplitted = (PageTableSplitted || IsSplitted);\r
       }\r
     }\r