From 750ec4cabd074e0d8d4958efc0788c20e229d352 Mon Sep 17 00:00:00 2001 From: Jiewen Yao Date: Thu, 17 Nov 2016 21:32:25 +0800 Subject: [PATCH] UefiCpuPkg/PiSmmCpu: Check XdSupport before set NX. 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 Cc: Laszlo Ersek Cc: Jeff Fan Cc: Michael D Kinney Cc: Laszlo Ersek Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jiewen Yao Reviewed-by: Jeff Fan Tested-by: Laszlo Ersek --- 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 b4f8861607..c85e025424 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;