summaryrefslogtreecommitdiffstats
path: root/MdeModulePkg/Core
diff options
context:
space:
mode:
authorJian J Wang <devel@edk2.groups.io>2019-11-06 21:13:32 +0000
committerJian J Wang <jian.j.wang@intel.com>2019-11-09 10:59:56 +0800
commitf9d0e5daa058f0cf4caa8edad0dfa2a3a390f1b0 (patch)
tree62b0ec3b72a397648939a184dda1f4f143aae74c /MdeModulePkg/Core
parentf55c76b301f15d287b58cd86dd59be978dc753a3 (diff)
downloadedk2-f9d0e5daa058f0cf4caa8edad0dfa2a3a390f1b0.tar.gz
edk2-f9d0e5daa058f0cf4caa8edad0dfa2a3a390f1b0.tar.bz2
edk2-f9d0e5daa058f0cf4caa8edad0dfa2a3a390f1b0.zip
MdeModulePkg/DxeIplPeim: reserve page 0 for NULL pointer detection
When a boot loader examines the memory map, it can see that location 0 is available memory. If it chooses to use that memory, and PcdNullPointerDetectionPropertyMask is enabled, use of memory in page 0 will cause an exception. This does occur when running the memtest86 program. Leaving page 0 available is for legacy support purpose. Since we have deprecated the support of legacy, the solution is just reserving it so that it cannot be allocated for other uses. Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1885 Cc: Dandan Bi <dandan.bi@intel.com> Cc: Liming Gao <liming.gao@intel.com> Cc: Ray Ni <ray.ni@intel.com> Cc: Hao A Wu <hao.a.wu@intel.com> Cc: Sean Brogan <sean.brogan@microsoft.com> Signed-off-by: Jian J Wang <jian.j.wang@intel.com> Reviewed-by: Ray Ni <ray.ni@intel.com>
Diffstat (limited to 'MdeModulePkg/Core')
-rw-r--r--MdeModulePkg/Core/DxeIplPeim/Ia32/DxeLoadFunc.c4
-rw-r--r--MdeModulePkg/Core/DxeIplPeim/X64/DxeLoadFunc.c4
2 files changed, 8 insertions, 0 deletions
diff --git a/MdeModulePkg/Core/DxeIplPeim/Ia32/DxeLoadFunc.c b/MdeModulePkg/Core/DxeIplPeim/Ia32/DxeLoadFunc.c
index 172d7cd1c6..6e8ca824d4 100644
--- a/MdeModulePkg/Core/DxeIplPeim/Ia32/DxeLoadFunc.c
+++ b/MdeModulePkg/Core/DxeIplPeim/Ia32/DxeLoadFunc.c
@@ -246,8 +246,12 @@ HandOffToDxeCore (
EFI_PEI_VECTOR_HANDOFF_INFO_PPI *VectorHandoffInfoPpi;
BOOLEAN BuildPageTablesIa32Pae;
+ //
+ // Clear page 0 and mark it as allocated if NULL pointer detection is enabled.
+ //
if (IsNullDetectionEnabled ()) {
ClearFirst4KPage (HobList.Raw);
+ BuildMemoryAllocationHob (0, EFI_PAGES_TO_SIZE (1), EfiBootServicesData);
}
Status = PeiServicesAllocatePages (EfiBootServicesData, EFI_SIZE_TO_PAGES (STACK_SIZE), &BaseOfStack);
diff --git a/MdeModulePkg/Core/DxeIplPeim/X64/DxeLoadFunc.c b/MdeModulePkg/Core/DxeIplPeim/X64/DxeLoadFunc.c
index 2867610bff..f465eb1d8a 100644
--- a/MdeModulePkg/Core/DxeIplPeim/X64/DxeLoadFunc.c
+++ b/MdeModulePkg/Core/DxeIplPeim/X64/DxeLoadFunc.c
@@ -36,8 +36,12 @@ HandOffToDxeCore (
EFI_VECTOR_HANDOFF_INFO *VectorInfo;
EFI_PEI_VECTOR_HANDOFF_INFO_PPI *VectorHandoffInfoPpi;
+ //
+ // Clear page 0 and mark it as allocated if NULL pointer detection is enabled.
+ //
if (IsNullDetectionEnabled ()) {
ClearFirst4KPage (HobList.Raw);
+ BuildMemoryAllocationHob (0, EFI_PAGES_TO_SIZE (1), EfiBootServicesData);
}
//