From: "Ni, Ray" <ray.ni@intel.com>
To: devel@edk2.groups.io
Cc: Eric Dong <eric.dong@intel.com>,
Jiewen Yao <jiewen.yao@intel.com>,
Jian J Wang <jian.j.wang@intel.com>,
Laszlo Ersek <lersek@redhat.com>
Subject: [PATCH v2 2/2] UefiCpuPkg/PiSmmCpu: PcdCpuSmmAccessOut controls SMM access-out policy
Date: Thu, 1 Aug 2019 00:38:52 +0800 [thread overview]
Message-ID: <20190731163852.191708-3-ray.ni@intel.com> (raw)
In-Reply-To: <20190731163852.191708-1-ray.ni@intel.com>
This patch skips to update page table for non-SMRAM memory when
PcdCpuSmmAccessOut is TRUE.
So that when SMM accesses out, no page fault is triggered at all.
Signed-off-by: Ray Ni <ray.ni@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
---
UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c | 21 +++++++++++++++++----
UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c | 2 +-
2 files changed, 18 insertions(+), 5 deletions(-)
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c
index 69a04dfb23..427c33fb01 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c
@@ -130,6 +130,11 @@ UINT8 mPhysicalAddressBits;
UINT32 mSmmCr0;
UINT32 mSmmCr4;
+//
+// Cache of PcdCpuSmmAccessOut
+//
+BOOLEAN mSmmAccessOut;
+
/**
Initialize IDT to setup exception handlers for SMM.
@@ -610,6 +615,12 @@ PiCpuSmmEntry (
mSmmCodeAccessCheckEnable = PcdGetBool (PcdCpuSmmCodeAccessCheckEnable);
DEBUG ((EFI_D_INFO, "PcdCpuSmmCodeAccessCheckEnable = %d\n", mSmmCodeAccessCheckEnable));
+ //
+ // Save the PcdCpuSmmAccessOut value into a global variable.
+ //
+ mSmmAccessOut = PcdGetBool (PcdCpuSmmAccessOut);
+ DEBUG ((DEBUG_INFO, "PcdCpuSmmAccessOut = %d\n", mSmmAccessOut));
+
//
// Save the PcdPteMemoryEncryptionAddressOrMask value into a global variable.
// Make sure AddressEncMask is contained to smallest supported address field.
@@ -1431,10 +1442,12 @@ PerformRemainingTasks (
//
SetMemMapAttributes ();
- //
- // For outside SMRAM, we only map SMM communication buffer or MMIO.
- //
- SetUefiMemMapAttributes ();
+ if (!mSmmAccessOut) {
+ //
+ // For outside SMRAM, we only map SMM communication buffer or MMIO.
+ //
+ SetUefiMemMapAttributes ();
+ }
//
// Set page table itself to be read-only
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c
index a3b62f7787..6699aac65d 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c
@@ -1029,7 +1029,7 @@ SmiPFHandler (
goto Exit;
}
- if (mCpuSmmStaticPageTable && IsSmmCommBufferForbiddenAddress (PFAddress)) {
+ if (IsSmmCommBufferForbiddenAddress (PFAddress)) {
DumpCpuContext (InterruptType, SystemContext);
DEBUG ((DEBUG_ERROR, "Access SMM communication forbidden address (0x%lx)!\n", PFAddress));
DEBUG_CODE (
--
2.21.0.windows.1
next prev parent reply other threads:[~2019-07-31 16:39 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-31 16:38 [PATCH v2 0/2] Add new PCD PcdCpuSmmAccessOut to control SMM access out Ni, Ray
2019-07-31 16:38 ` [PATCH v2 1/2] UefiCpuPkg: Add " Ni, Ray
2019-07-31 22:21 ` [edk2-devel] " Laszlo Ersek
2019-08-01 6:38 ` Ni, Ray
2019-07-31 16:38 ` Ni, Ray [this message]
2019-07-31 23:13 ` [edk2-devel] [PATCH v2 2/2] UefiCpuPkg/PiSmmCpu: PcdCpuSmmAccessOut controls SMM access-out policy Laszlo Ersek
2019-07-31 23:46 ` Laszlo Ersek
2019-08-01 0:08 ` Laszlo Ersek
2019-08-01 0:02 ` Yao, Jiewen
2019-08-01 1:27 ` Ni, Ray
2019-08-01 1:38 ` Yao, Jiewen
2019-08-01 2:23 ` Ni, Ray
2019-08-01 3:10 ` Yao, Jiewen
2019-08-01 6:25 ` Ni, Ray
2019-08-02 1:41 ` Laszlo Ersek
2019-08-02 2:04 ` Laszlo Ersek
2019-08-02 2:46 ` Yao, Jiewen
2019-08-02 22:06 ` Laszlo Ersek
2019-08-03 2:23 ` Yao, Jiewen
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=20190731163852.191708-3-ray.ni@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