]> git.proxmox.com Git - mirror_edk2.git/blobdiff - UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/PageTbl.c
UefiCpuPkg/PiSmmCpuDxeSmm: implement non-stop mode for SMM
[mirror_edk2.git] / UefiCpuPkg / PiSmmCpuDxeSmm / Ia32 / PageTbl.c
index 9300a232e4a6658ba6720c618defbd5cff7f795b..a32b736089ab7eb74cf23df1dca40eef8ad4075c 100644 (file)
@@ -38,7 +38,9 @@ SmmInitPageTable (
 \r
   mPhysicalAddressBits = 32;\r
 \r
-  if (FeaturePcdGet (PcdCpuSmmProfileEnable)) {\r
+  if (FeaturePcdGet (PcdCpuSmmProfileEnable) ||\r
+      HEAP_GUARD_NONSTOP_MODE ||\r
+      NULL_DETECTION_NONSTOP_MODE) {\r
     //\r
     // Set own Page Fault entry instead of the default one, because SMM Profile\r
     // feature depends on IRET instruction to do Single Step\r
@@ -129,6 +131,11 @@ SmiPFHandler (
           DumpModuleInfoByIp ((UINTN)SystemContext.SystemContextIa32->Eip);\r
         );\r
       }\r
+\r
+      if (HEAP_GUARD_NONSTOP_MODE) {\r
+        GuardPagePFHandler (SystemContext.SystemContextIa32->ExceptionData);\r
+        goto Exit;\r
+      }\r
     }\r
     CpuDeadLoop ();\r
   }\r
@@ -146,6 +153,26 @@ SmiPFHandler (
       );\r
       CpuDeadLoop ();\r
     }\r
+\r
+    //\r
+    // If NULL pointer was just accessed\r
+    //\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.SystemContextIa32->Eip);\r
+      );\r
+\r
+      if (NULL_DETECTION_NONSTOP_MODE) {\r
+        GuardPagePFHandler (SystemContext.SystemContextIa32->ExceptionData);\r
+        goto Exit;\r
+      }\r
+\r
+      CpuDeadLoop ();\r
+    }\r
+\r
     if (IsSmmCommBufferForbiddenAddress (PFAddress)) {\r
       DumpCpuContext (InterruptType, SystemContext);\r
       DEBUG ((DEBUG_ERROR, "Access SMM communication forbidden address (0x%x)!\n", PFAddress));\r
@@ -156,19 +183,6 @@ SmiPFHandler (
     }\r
   }\r
 \r
-  //\r
-  // If NULL pointer was just accessed\r
-  //\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.SystemContextIa32->Eip);\r
-    );\r
-    CpuDeadLoop ();\r
-  }\r
-\r
   if (FeaturePcdGet (PcdCpuSmmProfileEnable)) {\r
     SmmProfilePFHandler (\r
       SystemContext.SystemContextIa32->Eip,\r
@@ -179,6 +193,7 @@ SmiPFHandler (
     SmiDefaultPFHandler ();\r
   }\r
 \r
+Exit:\r
   ReleaseSpinLock (mPFLock);\r
 }\r
 \r