From nobody Thu May 2 23:22:32 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+50324+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+50324+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1573450610; cv=none; d=zoho.com; s=zohoarc; b=L9kzSMRzkoSby1VxpfpJuNB1BSuQ9d2Z/lmQrUKSmsMht6Jy64avmZn8cbdTMPMXFI/3psu5MXwnosobp+OtDSSnmF2u8mlMJ1eVEpfEoI5sLsGmNvm9SomBX5j+1/nrZPPik5qp9UAS/vYj22xRUntto6QTVc6LlirSK5HMmJ8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573450610; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=f34steKtyig5qCIx8tr3JeJ+1RQYgqy4DGmrRLaH1gg=; b=e0Vykoz9RPuDiVZNv/ilMlTN7quqiAhTDXnUh82/ohlWhusgnKL5PsSFyqcK6s/3xx5l2Oh1PV1oTIg5EyB+O4+Q8f1/ZwK1jMFLaBUPgi942mOxjk9atzArnp8+Rhr8hHHZ8Wc1KCwRbMDpf4IDsZLnEmCBFGCWJ5zdIn+v8Kw= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+50324+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1573450610335275.2934375349189; Sun, 10 Nov 2019 21:36:50 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id 93xLYY1788612xP9eDZ6Nx7A; Sun, 10 Nov 2019 21:36:49 -0800 X-Received: from mga07.intel.com (mga07.intel.com []) by mx.groups.io with SMTP id smtpd.web09.10.1573450589791256882 for ; Sun, 10 Nov 2019 21:36:30 -0800 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Nov 2019 21:36:29 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,291,1569308400"; d="scan'208";a="247277550" X-Received: from ray-dev.ccr.corp.intel.com ([10.239.9.9]) by FMSMGA003.fm.intel.com with ESMTP; 10 Nov 2019 21:36:29 -0800 From: "Ni, Ray" To: devel@edk2.groups.io Cc: Eric Dong , Laszlo Ersek Subject: [edk2-devel] [PATCH 1/2] UefiCpuPkg/CpuCommonFeaturesLib: Remove XD enable/disable logic Date: Mon, 11 Nov 2019 13:35:14 +0800 Message-Id: <20191111053515.261224-2-ray.ni@intel.com> In-Reply-To: <20191111053515.261224-1-ray.ni@intel.com> References: <20191111053515.261224-1-ray.ni@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,ray.ni@intel.com X-Gm-Message-State: 8xwoZiJs8Xjf1UA3c4egItJ2x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1573450609; bh=QaRKaiRgNu37I1bTOKRz1g3qYWjzAewYWbDoHSsJTOU=; h=Cc:Date:From:Reply-To:Subject:To; b=ODOySsQKeXOAEjESfEZhJ5HfqLN8iKWQZVsI90jJveA63BBUsX6wScKCrX369OkRNYR KcfWQHCtEbJ/2O0X1QlHOZdvZ7sTwcVmn58wNVyiMvEBmj5cVeBSnXK15IsNBm71oX408 KIf/dC8PcyqiYjhds1FL6kLYiRxcOT15XzA= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2329 XD (ExecutionDisable) feature, when turned on, allows page table entry BIT63 set to 1 indicating the memory pointed by the page table is disallowed to execute. DxeIpl::CreateIdentityMappingPageTables() enables the XD when CPU supports it. Later DxeCore modifies the page table to set the BIT63 to protect the stack/heap to disallow code execution in stack/heap. UefiCpuPkg/CpuCommonFeaturesLib enables/disables the XD feature according to PcdCpuFeaturesSetting. When XD is disabled, GP fault is generated immediately because some page entries have BIT63 set. To fix this issue, this patch removes the XD feature logic from UefiCpuPkg/CpuCommonFeaturesLib so the XD feature is only taken care of by DxeIpl. Signed-off-by: Ray Ni Cc: Eric Dong Cc: Laszlo Ersek Acked-by: Laszlo Ersek Reviewed-by: Eric Dong --- .../CpuCommonFeaturesLib.c | 11 --- .../CpuCommonFeaturesLib.inf | 3 +- .../CpuCommonFeaturesLib/ExecuteDisable.c | 95 ------------------- 3 files changed, 1 insertion(+), 108 deletions(-) delete mode 100644 UefiCpuPkg/Library/CpuCommonFeaturesLib/ExecuteDisable.c diff --git a/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.c= b/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.c index 238632f88a..3ebd9392a9 100644 --- a/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.c +++ b/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.c @@ -66,17 +66,6 @@ CpuCommonFeaturesLibConstructor ( ); ASSERT_EFI_ERROR (Status); } - if (IsCpuFeatureSupported (CPU_FEATURE_XD)) { - Status =3D RegisterCpuFeature ( - "Execute Disable", - NULL, - ExecuteDisableSupport, - ExecuteDisableInitialize, - CPU_FEATURE_XD, - CPU_FEATURE_END - ); - ASSERT_EFI_ERROR (Status); - } if (IsCpuFeatureSupported (CPU_FEATURE_FASTSTRINGS)) { Status =3D RegisterCpuFeature ( "FastStrings", diff --git a/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.i= nf b/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.inf index 6347c8997d..7fbcd8da0e 100644 --- a/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.inf +++ b/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.inf @@ -4,7 +4,7 @@ # This library registers CPU features defined in Intel(R) 64 and IA-32 # Architectures Software Developer's Manual. # -# Copyright (c) 2017 - 2018, Intel Corporation. All rights reserved.
+# Copyright (c) 2017 - 2019, Intel Corporation. All rights reserved.
# # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -34,7 +34,6 @@ [Sources] C1e.c ClockModulation.c Eist.c - ExecuteDisable.c FastStrings.c FeatureControl.c LimitCpuIdMaxval.c diff --git a/UefiCpuPkg/Library/CpuCommonFeaturesLib/ExecuteDisable.c b/Uef= iCpuPkg/Library/CpuCommonFeaturesLib/ExecuteDisable.c deleted file mode 100644 index 75ea16309d..0000000000 --- a/UefiCpuPkg/Library/CpuCommonFeaturesLib/ExecuteDisable.c +++ /dev/null @@ -1,95 +0,0 @@ -/** @file - Execute Disable feature. - - Copyright (c) 2017, Intel Corporation. All rights reserved.
- SPDX-License-Identifier: BSD-2-Clause-Patent - -**/ - -#include "CpuCommonFeatures.h" - -/** - Detects if Execute Disable feature supported on current processor. - - @param[in] ProcessorNumber The index of the CPU executing this functio= n. - @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFOR= MATION - structure for the CPU executing this functi= on. - @param[in] ConfigData A pointer to the configuration buffer retur= ned - by CPU_FEATURE_GET_CONFIG_DATA. NULL if - CPU_FEATURE_GET_CONFIG_DATA was not provide= d in - RegisterCpuFeature(). - - @retval TRUE Execute Disable feature is supported. - @retval FALSE Execute Disable feature is not supported. - - @note This service could be called by BSP/APs. -**/ -BOOLEAN -EFIAPI -ExecuteDisableSupport ( - IN UINTN ProcessorNumber, - IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, - IN VOID *ConfigData OPTIONAL - ) -{ - UINT32 Eax; - CPUID_EXTENDED_CPU_SIG_EDX Edx; - - AsmCpuid (CPUID_EXTENDED_FUNCTION, &Eax, NULL, NULL, NULL); - if (Eax <=3D CPUID_EXTENDED_FUNCTION) { - // - // Extended CPUID functions are not supported on this processor. - // - return FALSE; - } - - AsmCpuid (CPUID_EXTENDED_CPU_SIG, NULL, NULL, NULL, &Edx.Uint32); - return (Edx.Bits.NX !=3D 0); -} - -/** - Initializes Execute Disable feature to specific state. - - @param[in] ProcessorNumber The index of the CPU executing this functio= n. - @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFOR= MATION - structure for the CPU executing this functi= on. - @param[in] ConfigData A pointer to the configuration buffer retur= ned - by CPU_FEATURE_GET_CONFIG_DATA. NULL if - CPU_FEATURE_GET_CONFIG_DATA was not provide= d in - RegisterCpuFeature(). - @param[in] State If TRUE, then the Execute Disable feature m= ust be enabled. - If FALSE, then the Execute Disable feature = must be disabled. - - @retval RETURN_SUCCESS Execute Disable feature is initialized. - - @note This service could be called by BSP only. -**/ -RETURN_STATUS -EFIAPI -ExecuteDisableInitialize ( - IN UINTN ProcessorNumber, - IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, - IN VOID *ConfigData, OPTIONAL - IN BOOLEAN State - ) -{ - // - // The scope of the MSR_IA32_EFER is core for below processor type, only= program - // MSR_IA32_EFER for thread 0 in each core. - // - if (IS_SILVERMONT_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayMod= el)) { - if (CpuInfo->ProcessorInfo.Location.Thread !=3D 0) { - return RETURN_SUCCESS; - } - } - - CPU_REGISTER_TABLE_WRITE_FIELD ( - ProcessorNumber, - Msr, - MSR_IA32_EFER, - MSR_IA32_EFER_REGISTER, - Bits.NXE, - (State) ? 1 : 0 - ); - return RETURN_SUCCESS; -} --=20 2.21.0.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#50324): https://edk2.groups.io/g/devel/message/50324 Mute This Topic: https://groups.io/mt/52189308/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Thu May 2 23:22:32 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+50325+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+50325+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1573450611; cv=none; d=zoho.com; s=zohoarc; b=g6ATUY4aHiabV7rc4Uh2u1sc83tn/S6wv2KWqkJ4pZUodNa6a9/RDcGMDIZN2V5PamIey4NEuW/vx0zBGwMDcW4aOki3PuOhXciKuCDIwNEg9TZnape6AIJQwRpBfV2Y70WDtYMLsj6Opfi5dSvyX6Tb+oBoj1H7Pn7FA4fc9n0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573450611; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=Nkrw4cuXj23hhsZGTCBLZ6J1hnfHc+p3mbMgM4s87fI=; b=dFPHWRvWOBaoZI0dMHGySOZEE0sve+tGYEYtfB3ZiqDIKELSw2NeMNKZDLOn6jyTF3ggTTq4mZ9n2yj0tCylmjRLXF+j5/rCr+MeKWFBilJgQpdH5AmAu9JDjdgktJy8W4hTDuIfylGfARV7i7nBf/aqVzTnQQFP0WCHtf5cyXU= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+50325+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1573450611166347.27979532161555; Sun, 10 Nov 2019 21:36:51 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id 4qFVYY1788612xnUWxizI26f; Sun, 10 Nov 2019 21:36:50 -0800 X-Received: from mga07.intel.com (mga07.intel.com []) by mx.groups.io with SMTP id smtpd.web09.10.1573450589791256882 for ; Sun, 10 Nov 2019 21:36:31 -0800 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Nov 2019 21:36:30 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,291,1569308400"; d="scan'208";a="247277606" X-Received: from ray-dev.ccr.corp.intel.com ([10.239.9.9]) by FMSMGA003.fm.intel.com with ESMTP; 10 Nov 2019 21:36:30 -0800 From: "Ni, Ray" To: devel@edk2.groups.io Cc: Eric Dong , Laszlo Ersek Subject: [edk2-devel] [PATCH 2/2] UefiCpuPkg/RegisterCpuFeature: Remove CPU_FEATURE_XD macro Date: Mon, 11 Nov 2019 13:35:15 +0800 Message-Id: <20191111053515.261224-3-ray.ni@intel.com> In-Reply-To: <20191111053515.261224-1-ray.ni@intel.com> References: <20191111053515.261224-1-ray.ni@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,ray.ni@intel.com X-Gm-Message-State: FXRoGjRlT5HJEYCqE8LWbYH5x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1573450610; bh=0mvUEHIUlV0f7dCAT396DRdHmtiF4MksT6rykuE1gHU=; h=Cc:Date:From:Reply-To:Subject:To; b=SV4pbcYDcZFG0tPEs4DeDDQvv1hS+8QfWlJXYYjtr1EJ9BRPvGho+Kda5lnXx1idstp YIWj+AHeXhYbNDrq83o91FAYsn9y4aZfWbGD489PD4bBriNIV3e7Ii9Y7AgBWp4vSe7qz BAbQtzAr6B1KyVv6uBzWaNwnTdsjegZ5vSA= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2329 Signed-off-by: Ray Ni Cc: Eric Dong Cc: Laszlo Ersek Reviewed-by: Eric Dong --- UefiCpuPkg/Include/Library/RegisterCpuFeaturesLib.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UefiCpuPkg/Include/Library/RegisterCpuFeaturesLib.h b/UefiCpuP= kg/Include/Library/RegisterCpuFeaturesLib.h index 5bd464b32e..f370373d63 100644 --- a/UefiCpuPkg/Include/Library/RegisterCpuFeaturesLib.h +++ b/UefiCpuPkg/Include/Library/RegisterCpuFeaturesLib.h @@ -25,7 +25,7 @@ #define CPU_FEATURE_MWAIT 2 #define CPU_FEATURE_ACPI 3 #define CPU_FEATURE_EIST 4 -#define CPU_FEATURE_XD 5 +#define CPU_FEATURE_RESERVED_5 5 #define CPU_FEATURE_FASTSTRINGS 6 #define CPU_FEATURE_VMX 7 #define CPU_FEATURE_SMX 8 --=20 2.21.0.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#50325): https://edk2.groups.io/g/devel/message/50325 Mute This Topic: https://groups.io/mt/52189326/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-