From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mx.groups.io with SMTP id smtpd.web10.6404.1688707749454802251 for ; Thu, 06 Jul 2023 22:29:14 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=jD+mlo2L; spf=pass (domain: intel.com, ip: 134.134.136.20, mailfrom: ray.ni@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1688707754; x=1720243754; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=4s+dz+o7R/i3njKKQ5tQh6CfsDGGb0LBuzpsaCeR1aw=; b=jD+mlo2LuCBVQ2k+2Ba9m0jJ2B8Iq8dZa9uE2+f2v63YJR3ODmFJh/ro sKaoqN8jxDLbDQ0P9XH9Mpyu1fgPnL/jqeC6k3EtX7hBgtZvsYq0jmW5x 9fGZHSPnpP0ws+OU04/tq7xcDBw9C8C4Zvv66et0Epv/rtaPW9uRbdfXi WJCHbepFVIjPgMYpNgHkJ+/rv9ZEinVb7B2vR98GGgDf/kfScFgCfiH+S o7x3286YUQboAccZAWIvNjomgIkOeGcFIrk+Zb9K7nW8tnL1x+4wNdTJU Nu4NjPZA2VvLkDIfjs2vvti+3fspT+EVfcQpA6sxF0Gue2V31m7bqyUIr Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10763"; a="353650684" X-IronPort-AV: E=Sophos;i="6.01,187,1684825200"; d="scan'208";a="353650684" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jul 2023 22:29:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10763"; a="833232040" X-IronPort-AV: E=Sophos;i="6.01,187,1684825200"; d="scan'208";a="833232040" Received: from shwdeopenlab706.ccr.corp.intel.com ([10.239.55.95]) by fmsmga002.fm.intel.com with ESMTP; 06 Jul 2023 22:29:12 -0700 From: "Ni, Ray" To: devel@edk2.groups.io Cc: Eric Dong , Rahul Kumar , Gerd Hoffmann Subject: [PATCH 4/4] UefiCpuPkg/CpuFeatures: Deprecate CPU_FEATURE_X2APIC Date: Fri, 7 Jul 2023 13:29:01 +0800 Message-Id: <20230707052901.869-5-ray.ni@intel.com> X-Mailer: git-send-email 2.39.1.windows.1 In-Reply-To: <20230707052901.869-1-ray.ni@intel.com> References: <20230707052901.869-1-ray.ni@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Since MpLib supports to sync BSP's initial APIC mode to APs, platform can set BSP to X2 APIC mode before MpLib runs and expect MpLib syncs the X2 APIC mode to all APs. With such capability in MpLib, CpuCommonFeaturesLib's X2 APIC enable logic is dropped for simplificity. Such code removal also removes the confusion regarding how platform controls the X2 APIC enabling. Signed-off-by: Ray Ni Cc: Eric Dong Cc: Rahul Kumar Cc: Gerd Hoffmann --- .../Include/Library/RegisterCpuFeaturesLib.h | 2 +- .../CpuCommonFeaturesLib/CpuCommonFeatures.h | 69 +-------- .../CpuCommonFeaturesLib.c | 14 +- .../CpuCommonFeaturesLib.inf | 1 - .../Library/CpuCommonFeaturesLib/X2Apic.c | 138 ------------------ 5 files changed, 3 insertions(+), 221 deletions(-) delete mode 100644 UefiCpuPkg/Library/CpuCommonFeaturesLib/X2Apic.c diff --git a/UefiCpuPkg/Include/Library/RegisterCpuFeaturesLib.h b/UefiCpuP= kg/Include/Library/RegisterCpuFeaturesLib.h index 36459afc5e..ac5419141e 100644 --- a/UefiCpuPkg/Include/Library/RegisterCpuFeaturesLib.h +++ b/UefiCpuPkg/Include/Library/RegisterCpuFeaturesLib.h @@ -44,7 +44,7 @@ #define CPU_FEATURE_C_STATE 21=0D #define CPU_FEATURE_TM 22=0D #define CPU_FEATURE_TM2 23=0D -#define CPU_FEATURE_X2APIC 24=0D +#define CPU_FEATURE_X2APIC 24 ///< deprecated, do= not use it to enable X2 APIC.=0D #define CPU_FEATURE_RESERVED_25 25=0D #define CPU_FEATURE_RESERVED_26 26=0D #define CPU_FEATURE_RESERVED_27 27=0D diff --git a/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeatures.h b/= UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeatures.h index 5434a45f6a..22ecab82e8 100644 --- a/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeatures.h +++ b/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeatures.h @@ -1,7 +1,7 @@ /** @file=0D CPU Common features library header file.=0D =0D - Copyright (c) 2017 - 2019, Intel Corporation. All rights reserved.
=0D + Copyright (c) 2017 - 2013, Intel Corporation. All rights reserved.
=0D SPDX-License-Identifier: BSD-2-Clause-Patent=0D =0D **/=0D @@ -781,73 +781,6 @@ C1eInitialize ( IN BOOLEAN State=0D );=0D =0D -/**=0D - Prepares for the data used by CPU feature detection and initialization.= =0D -=0D - @param[in] NumberOfProcessors The number of CPUs in the platform.=0D -=0D - @return Pointer to a buffer of CPU related configuration data.=0D -=0D - @note This service could be called by BSP only.=0D -**/=0D -VOID *=0D -EFIAPI=0D -X2ApicGetConfigData (=0D - IN UINTN NumberOfProcessors=0D - );=0D -=0D -/**=0D - Detects if X2Apci feature supported on current processor.=0D -=0D - Detect if X2Apci has been already enabled.=0D -=0D - @param[in] ProcessorNumber The index of the CPU executing this functio= n.=0D - @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFOR= MATION=0D - structure for the CPU executing this functi= on.=0D - @param[in] ConfigData A pointer to the configuration buffer retur= ned=0D - by CPU_FEATURE_GET_CONFIG_DATA. NULL if=0D - CPU_FEATURE_GET_CONFIG_DATA was not provide= d in=0D - RegisterCpuFeature().=0D -=0D - @retval TRUE X2Apci feature is supported.=0D - @retval FALSE X2Apci feature is not supported.=0D -=0D - @note This service could be called by BSP/APs.=0D -**/=0D -BOOLEAN=0D -EFIAPI=0D -X2ApicSupport (=0D - IN UINTN ProcessorNumber,=0D - IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo,=0D - IN VOID *ConfigData OPTIONAL=0D - );=0D -=0D -/**=0D - Initializes X2Apci feature to specific state.=0D -=0D - @param[in] ProcessorNumber The index of the CPU executing this functio= n.=0D - @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFOR= MATION=0D - structure for the CPU executing this functi= on.=0D - @param[in] ConfigData A pointer to the configuration buffer retur= ned=0D - by CPU_FEATURE_GET_CONFIG_DATA. NULL if=0D - CPU_FEATURE_GET_CONFIG_DATA was not provide= d in=0D - RegisterCpuFeature().=0D - @param[in] State If TRUE, then the X2Apci feature must be en= abled.=0D - If FALSE, then the X2Apci feature must be d= isabled.=0D -=0D - @retval RETURN_SUCCESS X2Apci feature is initialized.=0D -=0D - @note This service could be called by BSP only.=0D -**/=0D -RETURN_STATUS=0D -EFIAPI=0D -X2ApicInitialize (=0D - IN UINTN ProcessorNumber,=0D - IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo,=0D - IN VOID *ConfigData OPTIONAL,=0D - IN BOOLEAN State=0D - );=0D -=0D /**=0D Prepares for the data used by CPU feature detection and initialization.= =0D =0D diff --git a/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.c= b/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.c index 7f0e1004b9..cc8807c19d 100644 --- a/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.c +++ b/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.c @@ -2,7 +2,7 @@ This library registers CPU features defined in Intel(R) 64 and IA-32=0D Architectures Software Developer's Manual.=0D =0D - Copyright (c) 2017 - 2020, Intel Corporation. All rights reserved.
=0D + Copyright (c) 2017 - 2023, Intel Corporation. All rights reserved.
=0D SPDX-License-Identifier: BSD-2-Clause-Patent=0D =0D **/=0D @@ -192,18 +192,6 @@ CpuCommonFeaturesLibConstructor ( ASSERT_EFI_ERROR (Status);=0D }=0D =0D - if (IsCpuFeatureSupported (CPU_FEATURE_X2APIC)) {=0D - Status =3D RegisterCpuFeature (=0D - "X2Apic",=0D - X2ApicGetConfigData,=0D - X2ApicSupport,=0D - X2ApicInitialize,=0D - CPU_FEATURE_X2APIC,=0D - CPU_FEATURE_END=0D - );=0D - ASSERT_EFI_ERROR (Status);=0D - }=0D -=0D if (IsCpuFeatureSupported (CPU_FEATURE_PPIN)) {=0D Status =3D RegisterCpuFeature (=0D "PPIN",=0D diff --git a/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.i= nf b/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.inf index 1b823155b1..1a95e745b5 100644 --- a/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.inf +++ b/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.inf @@ -40,7 +40,6 @@ MachineCheck.c=0D MonitorMwait.c=0D PendingBreak.c=0D - X2Apic.c=0D Ppin.c=0D ProcTrace.c=0D =0D diff --git a/UefiCpuPkg/Library/CpuCommonFeaturesLib/X2Apic.c b/UefiCpuPkg/= Library/CpuCommonFeaturesLib/X2Apic.c deleted file mode 100644 index 220f307e5a..0000000000 --- a/UefiCpuPkg/Library/CpuCommonFeaturesLib/X2Apic.c +++ /dev/null @@ -1,138 +0,0 @@ -/** @file=0D - X2Apic feature.=0D -=0D - Copyright (c) 2017, Intel Corporation. All rights reserved.
=0D - SPDX-License-Identifier: BSD-2-Clause-Patent=0D -=0D -**/=0D -=0D -#include "CpuCommonFeatures.h"=0D -=0D -/**=0D - Prepares for the data used by CPU feature detection and initialization.= =0D -=0D - @param[in] NumberOfProcessors The number of CPUs in the platform.=0D -=0D - @return Pointer to a buffer of CPU related configuration data.=0D -=0D - @note This service could be called by BSP only.=0D -**/=0D -VOID *=0D -EFIAPI=0D -X2ApicGetConfigData (=0D - IN UINTN NumberOfProcessors=0D - )=0D -{=0D - BOOLEAN *ConfigData;=0D -=0D - ConfigData =3D AllocateZeroPool (sizeof (BOOLEAN) * NumberOfProcessors);= =0D - ASSERT (ConfigData !=3D NULL);=0D - return ConfigData;=0D -}=0D -=0D -/**=0D - Detects if X2Apci feature supported on current processor.=0D -=0D - Detect if X2Apci has been already enabled.=0D -=0D - @param[in] ProcessorNumber The index of the CPU executing this functio= n.=0D - @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFOR= MATION=0D - structure for the CPU executing this functi= on.=0D - @param[in] ConfigData A pointer to the configuration buffer retur= ned=0D - by CPU_FEATURE_GET_CONFIG_DATA. NULL if=0D - CPU_FEATURE_GET_CONFIG_DATA was not provide= d in=0D - RegisterCpuFeature().=0D -=0D - @retval TRUE X2Apci feature is supported.=0D - @retval FALSE X2Apci feature is not supported.=0D -=0D - @note This service could be called by BSP/APs.=0D -**/=0D -BOOLEAN=0D -EFIAPI=0D -X2ApicSupport (=0D - IN UINTN ProcessorNumber,=0D - IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo,=0D - IN VOID *ConfigData OPTIONAL=0D - )=0D -{=0D - BOOLEAN *X2ApicEnabled;=0D -=0D - ASSERT (ConfigData !=3D NULL);=0D - X2ApicEnabled =3D (BOOLEAN *)ConfigData;=0D - //=0D - // *ConfigData indicates if X2APIC enabled on current processor=0D - //=0D - X2ApicEnabled[ProcessorNumber] =3D (GetApicMode () =3D=3D LOCAL_APIC_MOD= E_X2APIC) ? TRUE : FALSE;=0D -=0D - return (CpuInfo->CpuIdVersionInfoEcx.Bits.x2APIC =3D=3D 1);=0D -}=0D -=0D -/**=0D - Initializes X2Apci feature to specific state.=0D -=0D - @param[in] ProcessorNumber The index of the CPU executing this functio= n.=0D - @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFOR= MATION=0D - structure for the CPU executing this functi= on.=0D - @param[in] ConfigData A pointer to the configuration buffer retur= ned=0D - by CPU_FEATURE_GET_CONFIG_DATA. NULL if=0D - CPU_FEATURE_GET_CONFIG_DATA was not provide= d in=0D - RegisterCpuFeature().=0D - @param[in] State If TRUE, then the X2Apci feature must be en= abled.=0D - If FALSE, then the X2Apci feature must be d= isabled.=0D -=0D - @retval RETURN_SUCCESS X2Apci feature is initialized.=0D -=0D - @note This service could be called by BSP only.=0D -**/=0D -RETURN_STATUS=0D -EFIAPI=0D -X2ApicInitialize (=0D - IN UINTN ProcessorNumber,=0D - IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo,=0D - IN VOID *ConfigData OPTIONAL,=0D - IN BOOLEAN State=0D - )=0D -{=0D - BOOLEAN *X2ApicEnabled;=0D -=0D - //=0D - // The scope of the MSR_IA32_APIC_BASE is core for below processor type,= only program=0D - // MSR_IA32_APIC_BASE for thread 0 in each core.=0D - //=0D - if (IS_SILVERMONT_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayMod= el)) {=0D - if (CpuInfo->ProcessorInfo.Location.Thread !=3D 0) {=0D - return RETURN_SUCCESS;=0D - }=0D - }=0D -=0D - ASSERT (ConfigData !=3D NULL);=0D - X2ApicEnabled =3D (BOOLEAN *)ConfigData;=0D - if (X2ApicEnabled[ProcessorNumber]) {=0D - PRE_SMM_CPU_REGISTER_TABLE_WRITE_FIELD (=0D - ProcessorNumber,=0D - Msr,=0D - MSR_IA32_APIC_BASE,=0D - MSR_IA32_APIC_BASE_REGISTER,=0D - Bits.EXTD,=0D - 1=0D - );=0D - } else {=0D - //=0D - // Enable X2APIC mode only if X2APIC is not enabled,=0D - // Needn't to disabe X2APIC mode again if X2APIC is not enabled=0D - //=0D - if (State) {=0D - CPU_REGISTER_TABLE_WRITE_FIELD (=0D - ProcessorNumber,=0D - Msr,=0D - MSR_IA32_APIC_BASE,=0D - MSR_IA32_APIC_BASE_REGISTER,=0D - Bits.EXTD,=0D - 1=0D - );=0D - }=0D - }=0D -=0D - return RETURN_SUCCESS;=0D -}=0D --=20 2.39.1.windows.1