]> git.proxmox.com Git - mirror_edk2.git/blobdiff - UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c
UefiCpuPkg/PiSmmCpuDxeSmm: patch "gSmiStack" with PatchInstructionX86()
[mirror_edk2.git] / UefiCpuPkg / PiSmmCpuDxeSmm / X64 / PageTbl.c
index f3791ce89792e92887ead38bd08e610d4de7fd38..0fe944fc18cc9402c0217110ba723363ec0ae855 100644 (file)
@@ -851,12 +851,12 @@ SmiPFHandler (
   }\r
 \r
   //\r
-  // If a page fault occurs in SMM range\r
+  // If a page fault occurs in non-SMRAM range.\r
   //\r
   if ((PFAddress < mCpuHotPlugData.SmrrBase) ||\r
       (PFAddress >= mCpuHotPlugData.SmrrBase + mCpuHotPlugData.SmrrSize)) {\r
-    DumpCpuContext (InterruptType, SystemContext);\r
     if ((SystemContext.SystemContextX64->ExceptionData & IA32_PF_EC_ID) != 0) {\r
+      DumpCpuContext (InterruptType, SystemContext);\r
       DEBUG ((DEBUG_ERROR, "Code executed on IP(0x%lx) out of SMM range after SMM is locked!\n", PFAddress));\r
       DEBUG_CODE (\r
         DumpModuleInfoByIp (*(UINTN *)(UINTN)SystemContext.SystemContextX64->Rsp);\r
@@ -864,6 +864,7 @@ SmiPFHandler (
       CpuDeadLoop ();\r
     }\r
     if (IsSmmCommBufferForbiddenAddress (PFAddress)) {\r
+      DumpCpuContext (InterruptType, SystemContext);\r
       DEBUG ((DEBUG_ERROR, "Access SMM communication forbidden address (0x%lx)!\n", PFAddress));\r
       DEBUG_CODE (\r
         DumpModuleInfoByIp ((UINTN)SystemContext.SystemContextX64->Rip);\r
@@ -877,6 +878,7 @@ SmiPFHandler (
   //\r
   if ((PcdGet8 (PcdNullPointerDetectionPropertyMask) & BIT1) != 0 &&\r
       (PFAddress < EFI_PAGE_SIZE)) {\r
+    DumpCpuContext (InterruptType, SystemContext);\r
     DEBUG ((DEBUG_ERROR, "!!! NULL pointer access !!!\n"));\r
     DEBUG_CODE (\r
       DumpModuleInfoByIp ((UINTN)SystemContext.SystemContextX64->Rip);\r
@@ -914,7 +916,27 @@ SetPageTableAttributes (
   BOOLEAN               IsSplitted;\r
   BOOLEAN               PageTableSplitted;\r
 \r
-  if (!mCpuSmmStaticPageTable) {\r
+  //\r
+  // Don't do this if\r
+  //  - no static page table; or\r
+  //  - SMM heap guard feature enabled; or\r
+  //      BIT2: SMM page guard enabled\r
+  //      BIT3: SMM pool guard enabled\r
+  //  - SMM profile feature enabled\r
+  //\r
+  if (!mCpuSmmStaticPageTable ||\r
+      ((PcdGet8 (PcdHeapGuardPropertyMask) & (BIT3 | BIT2)) != 0) ||\r
+      FeaturePcdGet (PcdCpuSmmProfileEnable)) {\r
+    //\r
+    // Static paging and heap guard could not be enabled at the same time.\r
+    //\r
+    ASSERT (!(mCpuSmmStaticPageTable &&\r
+              (PcdGet8 (PcdHeapGuardPropertyMask) & (BIT3 | BIT2)) != 0));\r
+\r
+    //\r
+    // Static paging and SMM profile could not be enabled at the same time.\r
+    //\r
+    ASSERT (!(mCpuSmmStaticPageTable && FeaturePcdGet (PcdCpuSmmProfileEnable)));\r
     return ;\r
   }\r
 \r