diff options
author | Jian J Wang <jian.j.wang@intel.com> | 2018-08-20 11:31:00 +0800 |
---|---|---|
committer | Jian J Wang <jian.j.wang@intel.com> | 2018-08-30 07:22:30 +0800 |
commit | dcc026217fdc363f55c217039fc43d344f69fed6 (patch) | |
tree | e4604fd52c48ec0bf0d463a2c8ca455f18d8102a /UefiCpuPkg/CpuDxe/CpuMp.c | |
parent | 16b918bbaf51211a32ae04d9d8a5ba6ccca25a6a (diff) | |
download | edk2-dcc026217fdc363f55c217039fc43d344f69fed6.tar.gz edk2-dcc026217fdc363f55c217039fc43d344f69fed6.tar.bz2 edk2-dcc026217fdc363f55c217039fc43d344f69fed6.zip |
UefiCpuPkg/CpuDxe: implement non-stop mode for uefi
Same as SMM profile feature, a special #PF is used to set page attribute
to 'present' and a special #DB handler to reset it back to 'not-present',
right after the instruction causing #PF got executed.
Since the new #PF handler won't enter into dead-loop, the instruction
which caused the #PF will get chance to re-execute with accessible pages.
The exception message will still be printed out on debug console so that
the developer/QA can find that there's potential heap overflow or null
pointer access occurred.
Cc: Eric Dong <eric.dong@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jian J Wang <jian.j.wang@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
Acked-by: Laszlo Ersek <lersek@redhat.com>
Diffstat (limited to 'UefiCpuPkg/CpuDxe/CpuMp.c')
-rw-r--r-- | UefiCpuPkg/CpuDxe/CpuMp.c | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/UefiCpuPkg/CpuDxe/CpuMp.c b/UefiCpuPkg/CpuDxe/CpuMp.c index 82145e7624..5b3c87d244 100644 --- a/UefiCpuPkg/CpuDxe/CpuMp.c +++ b/UefiCpuPkg/CpuDxe/CpuMp.c @@ -673,10 +673,6 @@ InitializeMpExceptionStackSwitchHandlers ( UINT8 *GdtBuffer;
UINT8 *StackTop;
- if (!PcdGetBool (PcdCpuStackGuard)) {
- return;
- }
-
ExceptionNumber = FixedPcdGetSize (PcdCpuStackSwitchExceptionList);
NewStackSize = FixedPcdGet32 (PcdCpuKnownGoodStackSize) * ExceptionNumber;
@@ -791,6 +787,32 @@ InitializeMpExceptionStackSwitchHandlers ( }
/**
+ Initializes MP exceptions handlers for special features, such as Heap Guard
+ and Stack Guard.
+**/
+VOID
+InitializeMpExceptionHandlers (
+ VOID
+ )
+{
+ //
+ // Enable non-stop mode for #PF triggered by Heap Guard or NULL Pointer
+ // Detection.
+ //
+ if (HEAP_GUARD_NONSTOP_MODE || NULL_DETECTION_NONSTOP_MODE) {
+ RegisterCpuInterruptHandler (EXCEPT_IA32_DEBUG, DebugExceptionHandler);
+ RegisterCpuInterruptHandler (EXCEPT_IA32_PAGE_FAULT, PageFaultExceptionHandler);
+ }
+
+ //
+ // Setup stack switch for Stack Guard feature.
+ //
+ if (PcdGetBool (PcdCpuStackGuard)) {
+ InitializeMpExceptionStackSwitchHandlers ();
+ }
+}
+
+/**
Initialize Multi-processor support.
**/
@@ -814,9 +836,9 @@ InitializeMpSupport ( DEBUG ((DEBUG_INFO, "Detect CPU count: %d\n", mNumberOfProcessors));
//
- // Initialize exception stack switch handlers for each logic processor.
+ // Initialize special exception handlers for each logic processor.
//
- InitializeMpExceptionStackSwitchHandlers ();
+ InitializeMpExceptionHandlers ();
//
// Update CPU healthy information from Guided HOB
|