public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Jiewen Yao <jiewen.yao@intel.com>
To: edk2-devel@lists.01.org
Cc: Laszlo Ersek <lersek@redhat.com>, Jeff Fan <jeff.fan@intel.com>,
	Michael D Kinney <michael.d.kinney@intel.com>
Subject: [PATCH] UefiCpuPkg/PiSmmCpu: Check XdSupport before set NX.
Date: Thu, 17 Nov 2016 21:33:39 +0800	[thread overview]
Message-ID: <1479389619-16016-1-git-send-email-jiewen.yao@intel.com> (raw)

When XD is not supported, the BIT63 is reserved.
We should not set BIT63 in the page table.

Test OVMF IA32/IA32X64 with XD enabled/disabled.

Analyzed-by: Laszlo Ersek <lersek@redhat.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Jeff Fan <jeff.fan@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
---
 UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c
index b4f8861..c85e025 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c
@@ -209,10 +209,12 @@ ConvertPageEntryAttribute (
     }
   }
   if ((Attributes & EFI_MEMORY_XP) != 0) {
-    if (IsSet) {
-      NewPageEntry |= IA32_PG_NX;
-    } else {
-      NewPageEntry &= ~IA32_PG_NX;
+    if (mXdSupported) {
+      if (IsSet) {
+        NewPageEntry |= IA32_PG_NX;
+      } else {
+        NewPageEntry &= ~IA32_PG_NX;
+      }
     }
   }
   *PageEntry = NewPageEntry;
-- 
2.7.4.windows.1



             reply	other threads:[~2016-11-17 13:33 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-17 13:33 Jiewen Yao [this message]
2016-11-17 15:58 ` [PATCH] UefiCpuPkg/PiSmmCpu: Check XdSupport before set NX Laszlo Ersek
2016-11-18  0:44   ` Fan, Jeff

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=1479389619-16016-1-git-send-email-jiewen.yao@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