From 5fef2c7069a846754dda2f6416b11d5554f05ac3 Mon Sep 17 00:00:00 2001 From: Jian J Wang Date: Wed, 11 Apr 2018 16:35:32 +0800 Subject: [PATCH] MdeModulePkg/SmmCore: 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 Cc: Eric Dong Cc: Jiewen Yao Cc: Ruiyu Ni Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jian J Wang Reviewed-by: Star Zeng --- MdeModulePkg/Core/PiSmmCore/HeapGuard.c | 30 +++++++++++++++---------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/MdeModulePkg/Core/PiSmmCore/HeapGuard.c b/MdeModulePkg/Core/PiSmmCore/HeapGuard.c index d5556eb79c..d9e54b96cb 100644 --- a/MdeModulePkg/Core/PiSmmCore/HeapGuard.c +++ b/MdeModulePkg/Core/PiSmmCore/HeapGuard.c @@ -592,14 +592,17 @@ SetGuardPage ( IN EFI_PHYSICAL_ADDRESS BaseAddress ) { + EFI_STATUS Status; + if (mSmmMemoryAttribute != NULL) { mOnGuarding = TRUE; - mSmmMemoryAttribute->SetMemoryAttributes ( - mSmmMemoryAttribute, - BaseAddress, - EFI_PAGE_SIZE, - EFI_MEMORY_RP - ); + Status = mSmmMemoryAttribute->SetMemoryAttributes ( + mSmmMemoryAttribute, + BaseAddress, + EFI_PAGE_SIZE, + EFI_MEMORY_RP + ); + ASSERT_EFI_ERROR (Status); mOnGuarding = FALSE; } } @@ -619,14 +622,17 @@ UnsetGuardPage ( IN EFI_PHYSICAL_ADDRESS BaseAddress ) { + EFI_STATUS Status; + if (mSmmMemoryAttribute != NULL) { mOnGuarding = TRUE; - mSmmMemoryAttribute->ClearMemoryAttributes ( - mSmmMemoryAttribute, - BaseAddress, - EFI_PAGE_SIZE, - EFI_MEMORY_RP - ); + Status = mSmmMemoryAttribute->ClearMemoryAttributes ( + mSmmMemoryAttribute, + BaseAddress, + EFI_PAGE_SIZE, + EFI_MEMORY_RP + ); + ASSERT_EFI_ERROR (Status); mOnGuarding = FALSE; } } -- 2.39.2