From nobody Fri May 3 18:08:02 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1500000562759371.83435557885366; Thu, 13 Jul 2017 19:49:22 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 6E92A21D147CD; Thu, 13 Jul 2017 19:47:29 -0700 (PDT) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (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 C11AF2095D8DA for ; Thu, 13 Jul 2017 19:47:28 -0700 (PDT) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Jul 2017 19:49:17 -0700 Received: from ydong10-win10.ccr.corp.intel.com ([10.239.158.51]) by orsmga003.jf.intel.com with ESMTP; 13 Jul 2017 19:49:16 -0700 X-Original-To: edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.40,357,1496127600"; d="scan'208";a="992840963" From: Eric Dong To: edk2-devel@lists.01.org Date: Fri, 14 Jul 2017 10:49:11 +0800 Message-Id: <1500000554-21960-2-git-send-email-eric.dong@intel.com> X-Mailer: git-send-email 2.7.0.windows.1 In-Reply-To: <1500000554-21960-1-git-send-email-eric.dong@intel.com> References: <1500000554-21960-1-git-send-email-eric.dong@intel.com> Subject: [edk2] [Patch 1/4] UefiCpuPkg: Add PPIN related MSR for Xeon E5. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jeff Fan MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Eric Dong Cc: Jeff Fan --- UefiCpuPkg/Include/Register/Msr.h | 1 + UefiCpuPkg/Include/Register/Msr/XeonE5v2Msr.h | 91 +++++++++++++++++++++++= ++++ 2 files changed, 92 insertions(+) create mode 100644 UefiCpuPkg/Include/Register/Msr/XeonE5v2Msr.h diff --git a/UefiCpuPkg/Include/Register/Msr.h b/UefiCpuPkg/Include/Registe= r/Msr.h index 0ac8d5b..8dbd6f7 100644 --- a/UefiCpuPkg/Include/Register/Msr.h +++ b/UefiCpuPkg/Include/Register/Msr.h @@ -45,5 +45,6 @@ #include #include #include +#include =20 #endif diff --git a/UefiCpuPkg/Include/Register/Msr/XeonE5v2Msr.h b/UefiCpuPkg/Inc= lude/Register/Msr/XeonE5v2Msr.h new file mode 100644 index 0000000..29ba125 --- /dev/null +++ b/UefiCpuPkg/Include/Register/Msr/XeonE5v2Msr.h @@ -0,0 +1,91 @@ +/** @file + MSR Definitions for Intel(R) Xeon(R) Processor E5 v2 Family. + + Provides defines for Machine Specific Registers(MSR) indexes. Data struc= tures + are provided for MSRs that contain one or more bit fields. If the MSR v= alue + returned is a single 32-bit or 64-bit value, then a data structure is not + provided for that MSR. + + Copyright (c) 2017, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BS= D License + which accompanies this distribution. The full text of the license may b= e found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMP= LIED. + + @par Specification Reference: + Intel(R) 64 and IA-32 Architectures Software Developer's Manual, Volume = 3, + September 2016, Chapter 35 Model-Specific-Registers (MSR), Section 35.8. + +**/ + +#ifndef __XEON_E5_V2_MSR_H__ +#define __XEON_E5_V2_MSR_H__ + +#include + +/** + Is Intel(R) Xeon(R) Processor E5 V2 Family? + + @param DisplayFamily Display Family ID + @param DisplayModel Display Model ID + + DisplayModel =3D=3D 0x3E Intel Xeon processors E5 V2 + + @retval TRUE Yes, it is. + @retval FALSE No, it isn't. +**/ +#define IS_XEON_E5_V2_PROCESSOR(DisplayFamily, DisplayModel) \ + (DisplayFamily =3D=3D 0x06 && \ + ( \ + DisplayModel =3D=3D 0x3E \ + ) \ + ) + +#define MSR_XEON_E5_V2_PIN_CTL 0x0000004E + +/** + MSR information returned for MSR index #MSR_XEON_E7_FEATURE_CONFIG +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] LockOut (R/WO) 1 =3D Locked; 0 =3D unlocked + /// Set 1 to prevent further writes to MSR_PPIN_CTL. Writing 1 to + /// MSR_PPINCTL[bit 0] is permitted only if MSR_PPIN_CTL[bit 1] is + /// clear, Default is 0. + /// BIOS should provide an opt-in menu to enable the user to turn on + /// MSR_PPIN_CTL[bit 1] for privileged inventory initialization agent = to + /// access MSR_PPIN. After reading MSR_PPIN, the privileged + /// inventory initialization agent should write '1b' to MSR_PPIN_CTL + /// to disable further access to MSR_PPIN and prevent unauthorized + /// modification to MSR_PPIN_CTL + /// + UINT32 LockOut:1; + /// [Bit 1] Enable_PPIN (R/W) 1 =3D Enabled; 0 =3D Disabled + /// If 1, enables MSR_PPIN to be accessible using RDMSR. Once set, + /// attempt to write 1 to MSR_PPIN_CTL[bit 0] will cause #GP. + /// If 0, an attempt to read MSR_PPIN will cause #GP. Default is 0 + /// + UINT32 EnablePpin:1; + UINT32 Reserved1:30; + UINT32 Reserved2:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_XEON_E5_V2_PIN_CTL_REGISTER; + +#define MSR_XEON_E5_V2_PLATFORM_INFO 0x000000CE + +#endif \ No newline at end of file --=20 2.7.0.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Fri May 3 18:08:02 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1500000565241232.2440225400312; Thu, 13 Jul 2017 19:49:25 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id AE25321B06E62; Thu, 13 Jul 2017 19:47:31 -0700 (PDT) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (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 D2E9521D147DC for ; Thu, 13 Jul 2017 19:47:29 -0700 (PDT) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Jul 2017 19:49:18 -0700 Received: from ydong10-win10.ccr.corp.intel.com ([10.239.158.51]) by orsmga003.jf.intel.com with ESMTP; 13 Jul 2017 19:49:17 -0700 X-Original-To: edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.40,357,1496127600"; d="scan'208";a="992840967" From: Eric Dong To: edk2-devel@lists.01.org Date: Fri, 14 Jul 2017 10:49:12 +0800 Message-Id: <1500000554-21960-3-git-send-email-eric.dong@intel.com> X-Mailer: git-send-email 2.7.0.windows.1 In-Reply-To: <1500000554-21960-1-git-send-email-eric.dong@intel.com> References: <1500000554-21960-1-git-send-email-eric.dong@intel.com> Subject: [edk2] [Patch 2/4] UefiCpuPkg RegisterCpuFeaturesLib: Add error handling. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jeff Fan MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Disable CPU feature may return error, add error handling code to handle it instead of assert it. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Eric Dong Cc: Jeff Fan --- .../Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c | 9 +++++= +++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitializ= e.c b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c index e91a438..7a76730 100644 --- a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c +++ b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c @@ -536,7 +536,14 @@ AnalysisProcessorFeatures ( } } else { Status =3D CpuFeatureInOrder->InitializeFunc (ProcessorNumber, Cpu= Info, CpuFeatureInOrder->ConfigData, FALSE); - ASSERT_EFI_ERROR (Status); + if (EFI_ERROR (Status)) { + if (CpuFeatureInOrder->FeatureName !=3D NULL) { + DEBUG ((DEBUG_WARN, "Warning :: Failed to enable Feature Name = =3D %a.\n", CpuFeatureInOrder->FeatureName)); + } else { + DEBUG ((DEBUG_WARN, "Warning :: Failed to enable Feature Mask = =3D ")); + DumpCpuFeatureMask (CpuFeatureInOrder->FeatureMask); + } + } } Entry =3D Entry->ForwardLink; } --=20 2.7.0.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Fri May 3 18:08:02 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1500000567946771.2587122033381; Thu, 13 Jul 2017 19:49:27 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id E8F4D21B06E66; Thu, 13 Jul 2017 19:47:31 -0700 (PDT) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (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 B48A621D147DD for ; Thu, 13 Jul 2017 19:47:30 -0700 (PDT) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Jul 2017 19:49:19 -0700 Received: from ydong10-win10.ccr.corp.intel.com ([10.239.158.51]) by orsmga003.jf.intel.com with ESMTP; 13 Jul 2017 19:49:18 -0700 X-Original-To: edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.40,357,1496127600"; d="scan'208";a="992840971" From: Eric Dong To: edk2-devel@lists.01.org Date: Fri, 14 Jul 2017 10:49:13 +0800 Message-Id: <1500000554-21960-4-git-send-email-eric.dong@intel.com> X-Mailer: git-send-email 2.7.0.windows.1 In-Reply-To: <1500000554-21960-1-git-send-email-eric.dong@intel.com> References: <1500000554-21960-1-git-send-email-eric.dong@intel.com> Subject: [edk2] [Patch 3/4] UefiCpuPkg: Add feature definition for PPIN. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jeff Fan MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Eric Dong Cc: Jeff Fan --- UefiCpuPkg/Include/Library/RegisterCpuFeaturesLib.h | 1 + 1 file changed, 1 insertion(+) diff --git a/UefiCpuPkg/Include/Library/RegisterCpuFeaturesLib.h b/UefiCpuP= kg/Include/Library/RegisterCpuFeaturesLib.h index 4aa3529..10286ed 100644 --- a/UefiCpuPkg/Include/Library/RegisterCpuFeaturesLib.h +++ b/UefiCpuPkg/Include/Library/RegisterCpuFeaturesLib.h @@ -70,6 +70,7 @@ #define CPU_FEATURE_THREE_STRICK_COUNTER (32+8) #define CPU_FEATURE_APIC_TPR_UPDATE_MESSAGE (32+9) #define CPU_FEATURE_ENERGY_PERFORMANCE_BIAS (32+10) +#define CPU_FEATURE_PPIN (32+11) =20 #define CPU_FEATURE_BEFORE_ALL BIT27 #define CPU_FEATURE_AFTER_ALL BIT28 --=20 2.7.0.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Fri May 3 18:08:02 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 150000057052583.94826648246442; Thu, 13 Jul 2017 19:49:30 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 3957121B06E6B; Thu, 13 Jul 2017 19:47:34 -0700 (PDT) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (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 9EFC321B06E60 for ; Thu, 13 Jul 2017 19:47:31 -0700 (PDT) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Jul 2017 19:49:20 -0700 Received: from ydong10-win10.ccr.corp.intel.com ([10.239.158.51]) by orsmga003.jf.intel.com with ESMTP; 13 Jul 2017 19:49:19 -0700 X-Original-To: edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.40,357,1496127600"; d="scan'208";a="992840976" From: Eric Dong To: edk2-devel@lists.01.org Date: Fri, 14 Jul 2017 10:49:14 +0800 Message-Id: <1500000554-21960-5-git-send-email-eric.dong@intel.com> X-Mailer: git-send-email 2.7.0.windows.1 In-Reply-To: <1500000554-21960-1-git-send-email-eric.dong@intel.com> References: <1500000554-21960-1-git-send-email-eric.dong@intel.com> Subject: [edk2] [Patch 4/4] UefiCpuPkg CpuCommonFeaturesLib: Enable Ppin feature. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jeff Fan MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Eric Dong Cc: Jeff Fan --- .../CpuCommonFeaturesLib/CpuCommonFeatures.h | 55 +++++++++++ .../CpuCommonFeaturesLib/CpuCommonFeaturesLib.c | 11 +++ .../CpuCommonFeaturesLib/CpuCommonFeaturesLib.inf | 1 + UefiCpuPkg/Library/CpuCommonFeaturesLib/Ppin.c | 107 +++++++++++++++++= ++++ 4 files changed, 174 insertions(+) create mode 100644 UefiCpuPkg/Library/CpuCommonFeaturesLib/Ppin.c diff --git a/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeatures.h b/= UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeatures.h index 9c6e0b4..c03e5ab 100644 --- a/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeatures.h +++ b/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeatures.h @@ -854,4 +854,59 @@ FeatureControlGetConfigData ( IN UINTN NumberOfProcessors ); =20 +/** + Detects if Protected Processor Inventory Number feature supported on cur= rent=20 + 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 Enhanced Intel SpeedStep feature is supported. + @retval FALSE Enhanced Intel SpeedStep feature is not supported. + + @note This service could be called by BSP/APs. +**/ +BOOLEAN +EFIAPI +PpinSupport ( + IN UINTN ProcessorNumber, + IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, + IN VOID *ConfigData OPTIONAL + ); + +/** + Initializes Protected Processor Inventory Number feature to specific sta= te. + + @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 Protected Processor Inven= tory=20 + Number feature must be enabled. + If FALSE, then the Protected Processor Inve= ntory=20 + Number feature must be disabled. + + @retval RETURN_SUCCESS Protected Processor Inventory Number featur= e is=20 + initialized. + @retval RETURN_DEVICE_ERROR Device can't change state because it has be= en=20 + locked. + +**/ +RETURN_STATUS +EFIAPI +PpinInitialize ( + IN UINTN ProcessorNumber, + IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, + IN VOID *ConfigData, OPTIONAL + IN BOOLEAN State + ); + #endif diff --git a/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.c= b/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.c index 2bd32ab..b88b7d1 100644 --- a/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.c +++ b/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.c @@ -206,6 +206,17 @@ CpuCommonFeaturesLibConstructor ( ); ASSERT_EFI_ERROR (Status); } + if (IsCpuFeatureSupported (CPU_FEATURE_PPIN)) { + Status =3D RegisterCpuFeature ( + "PPIN", + NULL, + PpinSupport, + PpinInitialize, + CPU_FEATURE_PPIN, + CPU_FEATURE_END + ); + ASSERT_EFI_ERROR (Status); + } =20 return RETURN_SUCCESS; } diff --git a/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.i= nf b/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.inf index e68936b..202d560 100644 --- a/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.inf +++ b/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.inf @@ -47,6 +47,7 @@ MonitorMwait.c PendingBreak.c X2Apic.c + Ppin.c =20 [Packages] MdePkg/MdePkg.dec diff --git a/UefiCpuPkg/Library/CpuCommonFeaturesLib/Ppin.c b/UefiCpuPkg/Li= brary/CpuCommonFeaturesLib/Ppin.c new file mode 100644 index 0000000..5c213e3 --- /dev/null +++ b/UefiCpuPkg/Library/CpuCommonFeaturesLib/Ppin.c @@ -0,0 +1,107 @@ +/** @file + Protected Processor Inventory Number(PPIN) feature. + + Copyright (c) 2017, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BS= D License + which accompanies this distribution. The full text of the license may b= e found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMP= LIED. + +**/ + +#include "CpuCommonFeatures.h" + +/** + Detects if Protected Processor Inventory Number feature supported on cur= rent=20 + 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 Enhanced Intel SpeedStep feature is supported. + @retval FALSE Enhanced Intel SpeedStep feature is not supported. + + @note This service could be called by BSP/APs. +**/ +BOOLEAN +EFIAPI +PpinSupport ( + IN UINTN ProcessorNumber, + IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, + IN VOID *ConfigData OPTIONAL + ) +{ + UINT64 MsrValue; + + if (IS_XEON_E5_V2_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayMod= el)) { + // + // Check whether platform support this feature. + // + MsrValue =3D AsmReadMsr64 (MSR_XEON_E5_V2_PLATFORM_INFO); + return ((MsrValue & BIT23) !=3D 0); + } + + return FALSE; +} + +/** + Initializes Protected Processor Inventory Number feature to specific sta= te. + + @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 Protected Processor Inven= tory=20 + Number feature must be enabled. + If FALSE, then the Protected Processor Inve= ntory=20 + Number feature must be disabled. + + @retval RETURN_SUCCESS Protected Processor Inventory Number featur= e is=20 + initialized. + @retval RETURN_DEVICE_ERROR Device can't change state because it has be= en=20 + locked. + +**/ +RETURN_STATUS +EFIAPI +PpinInitialize ( + IN UINTN ProcessorNumber, + IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, + IN VOID *ConfigData, OPTIONAL + IN BOOLEAN State + ) +{ + MSR_XEON_E5_V2_PIN_CTL_REGISTER MsrPpinCtrl; + + // + // Check whether device already lock this register. + // If already locked, just base on the request state and + // the current state to return the status. + // + MsrPpinCtrl.Uint64 =3D AsmReadMsr64 (MSR_XEON_E5_V2_PIN_CTL); + if (MsrPpinCtrl.Bits.LockOut !=3D 0) { + return MsrPpinCtrl.Bits.EnablePpin =3D=3D State ? RETURN_SUCCESS : RET= URN_DEVICE_ERROR; + } + + CPU_REGISTER_TABLE_WRITE_FIELD ( + ProcessorNumber, + Msr, + MSR_XEON_E5_V2_PIN_CTL, + MSR_XEON_E5_V2_PIN_CTL_REGISTER, + Bits.EnablePpin, + (State) ? 1 : 0 + ); + + return RETURN_SUCCESS; +} --=20 2.7.0.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel