public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] UefiCpuPkg/PiSmmCpu: Check XdSupport before set NX.
@ 2016-11-17 13:33 Jiewen Yao
  2016-11-17 15:58 ` Laszlo Ersek
  0 siblings, 1 reply; 3+ messages in thread
From: Jiewen Yao @ 2016-11-17 13:33 UTC (permalink / raw)
  To: edk2-devel; +Cc: Laszlo Ersek, Jeff Fan, Michael D Kinney

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



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] UefiCpuPkg/PiSmmCpu: Check XdSupport before set NX.
  2016-11-17 13:33 [PATCH] UefiCpuPkg/PiSmmCpu: Check XdSupport before set NX Jiewen Yao
@ 2016-11-17 15:58 ` Laszlo Ersek
  2016-11-18  0:44   ` Fan, Jeff
  0 siblings, 1 reply; 3+ messages in thread
From: Laszlo Ersek @ 2016-11-17 15:58 UTC (permalink / raw)
  To: Jiewen Yao, edk2-devel; +Cc: Michael D Kinney, Jeff Fan

On 11/17/16 14:33, Jiewen Yao wrote:
> 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;
> 

Tested-by: Laszlo Ersek <lersek@redhat.com>

Thanks!
Laszlo


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] UefiCpuPkg/PiSmmCpu: Check XdSupport before set NX.
  2016-11-17 15:58 ` Laszlo Ersek
@ 2016-11-18  0:44   ` Fan, Jeff
  0 siblings, 0 replies; 3+ messages in thread
From: Fan, Jeff @ 2016-11-18  0:44 UTC (permalink / raw)
  To: Laszlo Ersek, Yao, Jiewen, edk2-devel@ml01.01.org; +Cc: Kinney, Michael D

Reviewed-by: Jeff Fan <jeff.fan@intel.com>

-----Original Message-----
From: Laszlo Ersek [mailto:lersek@redhat.com] 
Sent: Thursday, November 17, 2016 11:58 PM
To: Yao, Jiewen; edk2-devel@ml01.01.org
Cc: Kinney, Michael D; Fan, Jeff
Subject: Re: [edk2] [PATCH] UefiCpuPkg/PiSmmCpu: Check XdSupport before set NX.

On 11/17/16 14:33, Jiewen Yao wrote:
> 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;
> 

Tested-by: Laszlo Ersek <lersek@redhat.com>

Thanks!
Laszlo


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-11-18  0:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-17 13:33 [PATCH] UefiCpuPkg/PiSmmCpu: Check XdSupport before set NX Jiewen Yao
2016-11-17 15:58 ` Laszlo Ersek
2016-11-18  0:44   ` Fan, Jeff

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox