From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 3309681EF8 for ; Thu, 17 Nov 2016 05:33:43 -0800 (PST) Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga104.jf.intel.com with ESMTP; 17 Nov 2016 05:33:48 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,506,1473145200"; d="scan'208";a="32435922" Received: from jyao1-mobl.ccr.corp.intel.com ([10.254.213.87]) by fmsmga005.fm.intel.com with ESMTP; 17 Nov 2016 05:33:46 -0800 From: Jiewen Yao To: edk2-devel@lists.01.org Cc: Laszlo Ersek , Jeff Fan , Michael D Kinney Date: Thu, 17 Nov 2016 21:33:39 +0800 Message-Id: <1479389619-16016-1-git-send-email-jiewen.yao@intel.com> X-Mailer: git-send-email 2.7.4.windows.1 Subject: [PATCH] UefiCpuPkg/PiSmmCpu: Check XdSupport before set NX. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Nov 2016 13:33:43 -0000 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 --- 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