MdeModulePkg/DxeIpl: Implement NULL pointer detection
NULL pointer detection is done by making use of paging mechanism of CPU. During page table setup, if enabled, the first 4-K page (0-4095) will be marked as NOT PRESENT. Any code which unintentionally access memory between 0-4095 will trigger a Page Fault exception which warns users that there's potential illegal code in BIOS. This also means that legacy code which has to access memory between 0-4095 should be cautious to temporarily disable this feature before the access and re-enable it afterwards; or disalbe this feature at all. Cc: Star Zeng <star.zeng@intel.com> Cc: Eric Dong <eric.dong@intel.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Michael Kinney <michael.d.kinney@intel.com> Cc: Ayellet Wolman <ayellet.wolman@intel.com> Suggested-by: Ayellet Wolman <ayellet.wolman@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jian J Wang <jian.j.wang@intel.com> Reviewed-by: Star Zeng <star.zeng@intel.com> Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
This commit is contained in:
@@ -240,4 +240,29 @@ Decompress (
|
||||
OUT UINTN *OutputSize
|
||||
);
|
||||
|
||||
/**
|
||||
Clear legacy memory located at the first 4K-page.
|
||||
|
||||
This function traverses the whole HOB list to check if memory from 0 to 4095
|
||||
exists and has not been allocated, and then clear it if so.
|
||||
|
||||
@param HoStart The start of HobList passed to DxeCore.
|
||||
|
||||
**/
|
||||
VOID
|
||||
ClearFirst4KPage (
|
||||
IN VOID *HobStart
|
||||
);
|
||||
|
||||
/**
|
||||
Return configure status of NULL pointer detection feature
|
||||
|
||||
@return TRUE NULL pointer detection feature is enabled
|
||||
@return FALSE NULL pointer detection feature is disabled
|
||||
**/
|
||||
BOOLEAN
|
||||
IsNullDetectionEnabled (
|
||||
VOID
|
||||
);
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user