From: "duntan" <dun.tan@intel.com>
To: "devel@edk2.groups.io" <devel@edk2.groups.io>,
"Tan, Dun" <dun.tan@intel.com>
Cc: "Gao, Liming" <gaoliming@byosoft.com.cn>,
"Ni, Ray" <ray.ni@intel.com>,
"Wang, Jian J" <jian.j.wang@intel.com>,
Ard Biesheuvel <ardb+tianocore@kernel.org>
Subject: Re: [edk2-devel] [Patch V6 02/14] MdeModulePkg: Remove other attribute protection in UnsetGuardPage
Date: Wed, 14 Jun 2023 09:40:50 +0000 [thread overview]
Message-ID: <BN9PR11MB5483D112291BC2F2172C092FE55AA@BN9PR11MB5483.namprd11.prod.outlook.com> (raw)
In-Reply-To: <1766F2F16F7E8059.6460@groups.io>
Hi all,
Could you please help to review this patch?
Thanks,
Dun
-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of duntan
Sent: Friday, June 9, 2023 5:16 PM
To: devel@edk2.groups.io
Cc: Gao, Liming <gaoliming@byosoft.com.cn>; Ni, Ray <ray.ni@intel.com>; Wang, Jian J <jian.j.wang@intel.com>; Ard Biesheuvel <ardb+tianocore@kernel.org>
Subject: [edk2-devel] [Patch V6 02/14] MdeModulePkg: Remove other attribute protection in UnsetGuardPage
In UnsetGuardPage(), before SmmReadyToLock, remove NX and RO memory attribute protection for guarded page since EfiConventionalMemory in SMRAM is RW and executable before SmmReadyToLock. If UnsetGuardPage() happens after SmmReadyToLock, then apply EFI_MEMORY_XP to the guarded page to make sure EfiConventionalMemory in SMRAM is NX since EfiConventionalMemory in SMRAM is marked as NX in PiSmmCpuDxe driver when SmmReadyToLock.
Signed-off-by: Dun Tan <dun.tan@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
---
MdeModulePkg/Core/PiSmmCore/HeapGuard.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/MdeModulePkg/Core/PiSmmCore/HeapGuard.c b/MdeModulePkg/Core/PiSmmCore/HeapGuard.c
index 8f3bab6fee..25310122ca 100644
--- a/MdeModulePkg/Core/PiSmmCore/HeapGuard.c
+++ b/MdeModulePkg/Core/PiSmmCore/HeapGuard.c
@@ -553,9 +553,23 @@ UnsetGuardPage (
mSmmMemoryAttribute,
BaseAddress,
EFI_PAGE_SIZE,
- EFI_MEMORY_RP
+
+ EFI_MEMORY_RP|EFI_MEMORY_RO|EFI_MEMORY_XP
);
ASSERT_EFI_ERROR (Status);
+
+ if (gST == NULL) {
+ //
+ // Make sure EfiConventionalMemory is NX after SmmReadyToLock
+ //
+ Status = mSmmMemoryAttribute->SetMemoryAttributes (
+ mSmmMemoryAttribute,
+ BaseAddress,
+ EFI_PAGE_SIZE,
+ EFI_MEMORY_XP
+ );
+ ASSERT_EFI_ERROR (Status);
+ }
+
mOnGuarding = FALSE;
}
}
--
2.31.1.windows.1
prev parent reply other threads:[~2023-06-14 9:41 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-09 9:16 [Patch V6 00/14] Use CpuPageTableLib to create and update smm page table duntan
2023-06-09 9:16 ` [Patch V6 01/14] OvmfPkg:Remove code that apply AddressEncMask to non-leaf entry duntan
2023-06-09 9:16 ` [Patch V6 02/14] MdeModulePkg: Remove other attribute protection in UnsetGuardPage duntan
2023-06-16 8:16 ` [edk2-devel] " Wang, Jian J
[not found] ` <1766F2F0DD510904.28667@groups.io>
2023-06-14 9:40 ` [edk2-devel] [Patch V6 01/14] OvmfPkg:Remove code that apply AddressEncMask to non-leaf entry duntan
[not found] ` <1766F2F16F7E8059.6460@groups.io>
2023-06-14 9:40 ` duntan [this message]
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=BN9PR11MB5483D112291BC2F2172C092FE55AA@BN9PR11MB5483.namprd11.prod.outlook.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