From: Jian J Wang <jian.j.wang@intel.com>
To: edk2-devel@lists.01.org
Cc: Star Zeng <star.zeng@intel.com>, Eric Dong <eric.dong@intel.com>,
Jiewen Yao <jiewen.yao@intel.com>, Ruiyu Ni <ruiyu.ni@intel.com>
Subject: [PATCH 2/2] MdeModulePkg/SmmCore: add sanity check for SetMemoryAttributes
Date: Wed, 11 Apr 2018 16:38:46 +0800 [thread overview]
Message-ID: <20180411083846.7300-3-jian.j.wang@intel.com> (raw)
In-Reply-To: <20180411083846.7300-1-jian.j.wang@intel.com>
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>
---
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.16.2.windows.1
next prev parent reply other threads:[~2018-04-11 8:38 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-11 8:38 [PATCH 0/2] add sanity check for SetMemoryAttributes Jian J Wang
2018-04-11 8:38 ` [PATCH 1/2] MdeModulePkg/DxeCore: " Jian J Wang
2018-04-11 8:38 ` Jian J Wang [this message]
2018-04-12 5:54 ` [PATCH 0/2] " Zeng, Star
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180411083846.7300-3-jian.j.wang@intel.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox