summaryrefslogtreecommitdiffstats
path: root/MdeModulePkg/Core/Dxe
diff options
context:
space:
mode:
authorJian J Wang <jian.j.wang@intel.com>2018-04-11 16:35:05 +0800
committerStar Zeng <star.zeng@intel.com>2018-07-27 19:25:14 +0800
commit147ee65a3456f6ba121659b125635075fa6dec15 (patch)
tree622f591cb1c12e1c8f116e752aa23d66329eaf14 /MdeModulePkg/Core/Dxe
parent8b9a35f88b08d50c9103eaa610ccb29055e0bea3 (diff)
downloadedk2-147ee65a3456f6ba121659b125635075fa6dec15.tar.gz
edk2-147ee65a3456f6ba121659b125635075fa6dec15.tar.bz2
edk2-147ee65a3456f6ba121659b125635075fa6dec15.zip
MdeModulePkg/DxeCore: add sanity check for SetMemoryAttributes
Heap Guard feature needs enough memory and paging to work. Otherwise calling SetMemoryAttributes to change page attribute will fail. This patch add necessary check of result of calling SetMemoryAttributes. This can help users to debug their problem in enabling this feature. Cc: Star Zeng <star.zeng@intel.com> Cc: Eric Dong <eric.dong@intel.com> Cc: Jiewen Yao <jiewen.yao@intel.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: Star Zeng <star.zeng@intel.com> (cherry picked from commit a5cd613cdbf1edef1a98536fb2723b5d88bd53cd)
Diffstat (limited to 'MdeModulePkg/Core/Dxe')
-rw-r--r--MdeModulePkg/Core/Dxe/Mem/HeapGuard.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/MdeModulePkg/Core/Dxe/Mem/HeapGuard.c b/MdeModulePkg/Core/Dxe/Mem/HeapGuard.c
index fd6aeee8da..9d765c98f6 100644
--- a/MdeModulePkg/Core/Dxe/Mem/HeapGuard.c
+++ b/MdeModulePkg/Core/Dxe/Mem/HeapGuard.c
@@ -580,6 +580,8 @@ SetGuardPage (
IN EFI_PHYSICAL_ADDRESS BaseAddress
)
{
+ EFI_STATUS Status;
+
if (gCpu == NULL) {
return;
}
@@ -593,7 +595,8 @@ SetGuardPage (
// Note: This might overwrite other attributes needed by other features,
// such as NX memory protection.
//
- gCpu->SetMemoryAttributes (gCpu, BaseAddress, EFI_PAGE_SIZE, EFI_MEMORY_RP);
+ Status = gCpu->SetMemoryAttributes (gCpu, BaseAddress, EFI_PAGE_SIZE, EFI_MEMORY_RP);
+ ASSERT_EFI_ERROR (Status);
mOnGuarding = FALSE;
}
@@ -613,6 +616,7 @@ UnsetGuardPage (
)
{
UINT64 Attributes;
+ EFI_STATUS Status;
if (gCpu == NULL) {
return;
@@ -638,7 +642,8 @@ UnsetGuardPage (
// such as memory protection (NX). Please make sure they are not enabled
// at the same time.
//
- gCpu->SetMemoryAttributes (gCpu, BaseAddress, EFI_PAGE_SIZE, Attributes);
+ Status = gCpu->SetMemoryAttributes (gCpu, BaseAddress, EFI_PAGE_SIZE, Attributes);
+ ASSERT_EFI_ERROR (Status);
mOnGuarding = FALSE;
}