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>
This commit is contained in:
@@ -57,6 +57,12 @@
|
||||
EFI_MEMORY_RO \
|
||||
)
|
||||
|
||||
#define HEAP_GUARD_NONSTOP_MODE \
|
||||
((PcdGet8 (PcdHeapGuardPropertyMask) & (BIT6|BIT1|BIT0)) > BIT6)
|
||||
|
||||
#define NULL_DETECTION_NONSTOP_MODE \
|
||||
((PcdGet8 (PcdNullPointerDetectionPropertyMask) & (BIT6|BIT0)) > BIT6)
|
||||
|
||||
/**
|
||||
Flush CPU data cache. If the instruction cache is fully coherent
|
||||
with all DMA operations then function can just return EFI_SUCCESS.
|
||||
@@ -273,7 +279,40 @@ RefreshGcdMemoryAttributesFromPaging (
|
||||
VOID
|
||||
);
|
||||
|
||||
/**
|
||||
Special handler for #DB exception, which will restore the page attributes
|
||||
(not-present). It should work with #PF handler which will set pages to
|
||||
'present'.
|
||||
|
||||
@param ExceptionType Exception type.
|
||||
@param SystemContext Pointer to EFI_SYSTEM_CONTEXT.
|
||||
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
DebugExceptionHandler (
|
||||
IN EFI_EXCEPTION_TYPE InterruptType,
|
||||
IN EFI_SYSTEM_CONTEXT SystemContext
|
||||
);
|
||||
|
||||
/**
|
||||
Special handler for #PF exception, which will set the pages which caused
|
||||
#PF to be 'present'. The attribute of those pages should be restored in
|
||||
the subsequent #DB handler.
|
||||
|
||||
@param ExceptionType Exception type.
|
||||
@param SystemContext Pointer to EFI_SYSTEM_CONTEXT.
|
||||
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
PageFaultExceptionHandler (
|
||||
IN EFI_EXCEPTION_TYPE InterruptType,
|
||||
IN EFI_SYSTEM_CONTEXT SystemContext
|
||||
);
|
||||
|
||||
extern BOOLEAN mIsAllocatingPageTable;
|
||||
extern UINTN mNumberOfProcessors;
|
||||
|
||||
#endif
|
||||
|
||||
|
Reference in New Issue
Block a user