public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: nkvangup <narendra.k.vanguput@intel.com>
To: edk2-devel@lists.01.org
Cc: Vanguput Narendra K <narendra.k.vanguput@intel.com>,
	Eric Dong <eric.dong@intel.com>, Ray Ni <ray.ni@intel.com>,
	Laszlo Ersek <lersek@redhat.com>,
	Yao Jiewen <jiewen.yao@intel.com>
Subject: [PATCH v4] UefiCpuPkg\CpuSmm: Save & restore CR2 on-demand paging in SMM
Date: Mon, 18 Mar 2019 20:08:25 +0530	[thread overview]
Message-ID: <20190318143825.17352-1-narendra.k.vanguput@intel.com> (raw)

BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1593

For every SMI occurrence, save and restore CR2 register only when SMM
on-demand paging support is enabled in 64 bit operation mode.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Vanguput Narendra K <narendra.k.vanguput@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Yao Jiewen <jiewen.yao@intel.com>
---
 UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c   | 22 ++++++++++++++--------
 UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c |  2 +-
 2 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
index 3b0b3b52ac..0c07b31c4f 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
@@ -28,6 +28,7 @@ UINTN                                       mSemaphoreSize;
 SPIN_LOCK                                   *mPFLock = NULL;
 SMM_CPU_SYNC_MODE                           mCpuSmmSyncMode;
 BOOLEAN                                     mMachineCheckSupported = FALSE;
+BOOLEAN                                     mCpuSmmStaticPageTable = TRUE;
 
 /**
   Performs an atomic compare exchange operation to get semaphore.
@@ -1111,10 +1112,13 @@ SmiRendezvous (
 
   ASSERT(CpuIndex < mMaxNumberOfCpus);
 
-  //
-  // Save Cr2 because Page Fault exception in SMM may override its value
-  //
-  Cr2 = AsmReadCr2 ();
+    if (!mCpuSmmStaticPageTable) {
+    //
+    // Save and restore Cr2 when using on-demand paging for above 4G memory because Page Fault
+    // exception in SMM may override its value
+    //
+    Cr2 = AsmReadCr2 ();
+  }
 
   //
   // Perform CPU specific entry hooks
@@ -1253,10 +1257,12 @@ SmiRendezvous (
 
 Exit:
   SmmCpuFeaturesRendezvousExit (CpuIndex);
-  //
-  // Restore Cr2
-  //
-  AsmWriteCr2 (Cr2);
+    if (!mCpuSmmStaticPageTable) {
+    //
+    // Restore Cr2
+    //
+    AsmWriteCr2 (Cr2);
+  }
 }
 
 /**
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c
index 2c77cb47a4..e444b8a031 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c
@@ -21,7 +21,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 
 LIST_ENTRY                          mPagePool = INITIALIZE_LIST_HEAD_VARIABLE (mPagePool);
 BOOLEAN                             m1GPageTableSupport = FALSE;
-BOOLEAN                             mCpuSmmStaticPageTable;
+extern BOOLEAN                      mCpuSmmStaticPageTable;
 
 /**
   Disable CET.
-- 
2.16.2.windows.1



             reply	other threads:[~2019-03-18 14:38 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-18 14:38 nkvangup [this message]
2019-03-20 16:31 ` [PATCH v4] UefiCpuPkg\CpuSmm: Save & restore CR2 on-demand paging in SMM Laszlo Ersek
2019-03-20 17:27   ` Vanguput, Narendra K
2019-03-21  0:56     ` Dong, Eric
2019-03-21  2:48       ` Vanguput, Narendra K

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=20190318143825.17352-1-narendra.k.vanguput@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