]> git.proxmox.com Git - mirror_edk2.git/blobdiff - UefiCpuPkg/CpuDxe/CpuMp.c
UefiCpuPkg/CpuDxe: implement non-stop mode for uefi
[mirror_edk2.git] / UefiCpuPkg / CpuDxe / CpuMp.c
index 82145e762443ebdf9791d1e1757b2d87d02a53cc..5b3c87d24414a041649d4e45d113b3130080bda4 100644 (file)
@@ -673,10 +673,6 @@ InitializeMpExceptionStackSwitchHandlers (
   UINT8                           *GdtBuffer;\r
   UINT8                           *StackTop;\r
 \r
-  if (!PcdGetBool (PcdCpuStackGuard)) {\r
-    return;\r
-  }\r
-\r
   ExceptionNumber = FixedPcdGetSize (PcdCpuStackSwitchExceptionList);\r
   NewStackSize = FixedPcdGet32 (PcdCpuKnownGoodStackSize) * ExceptionNumber;\r
 \r
@@ -790,6 +786,32 @@ InitializeMpExceptionStackSwitchHandlers (
   }\r
 }\r
 \r
+/**\r
+  Initializes MP exceptions handlers for special features, such as Heap Guard\r
+  and Stack Guard.\r
+**/\r
+VOID\r
+InitializeMpExceptionHandlers (\r
+  VOID\r
+  )\r
+{\r
+  //\r
+  // Enable non-stop mode for #PF triggered by Heap Guard or NULL Pointer\r
+  // Detection.\r
+  //\r
+  if (HEAP_GUARD_NONSTOP_MODE || NULL_DETECTION_NONSTOP_MODE) {\r
+    RegisterCpuInterruptHandler (EXCEPT_IA32_DEBUG, DebugExceptionHandler);\r
+    RegisterCpuInterruptHandler (EXCEPT_IA32_PAGE_FAULT, PageFaultExceptionHandler);\r
+  }\r
+\r
+  //\r
+  // Setup stack switch for Stack Guard feature.\r
+  //\r
+  if (PcdGetBool (PcdCpuStackGuard)) {\r
+    InitializeMpExceptionStackSwitchHandlers ();\r
+  }\r
+}\r
+\r
 /**\r
   Initialize Multi-processor support.\r
 \r
@@ -814,9 +836,9 @@ InitializeMpSupport (
   DEBUG ((DEBUG_INFO, "Detect CPU count: %d\n", mNumberOfProcessors));\r
 \r
   //\r
-  // Initialize exception stack switch handlers for each logic processor.\r
+  // Initialize special exception handlers for each logic processor.\r
   //\r
-  InitializeMpExceptionStackSwitchHandlers ();\r
+  InitializeMpExceptionHandlers ();\r
 \r
   //\r
   // Update CPU healthy information from Guided HOB\r