From nobody Fri Apr 26 16:31:58 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+43653+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+43653+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1562926384; cv=none; d=zoho.com; s=zohoarc; b=LcrVLHtz1cRmzF92Mx++EX8zqVPnta3wWb4vhaPtF9aSQi005DJS1QzQ0CuV4r/jGj+x0Py5t0d63+epWPLS1MNEDpKzO7+xhkSGljfdgTpqp802CPMNqq+sdIqqc2e570SJU9eOkcS7rUf2TE9xWrYfVmHly1jBrisTU0prYQ8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562926384; h=Content-Transfer-Encoding:Cc:Date:From:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To:ARC-Authentication-Results; bh=CmIw6prmS1eX2SVQmFMTsQA6+3qCgiroelShno4BfbQ=; b=oL2Z/NmeFaYt5ydwSFFOZir8V6BNFm7oa89UyF7A4RZsbecxeWdFjG0m3gtCIMmj9Y0SHTYEdmRUtAsguLkm1PeJcDxVKwJrdHkE9g3RbGBTlmf5YPMnchqMYIGPuHZYsJiNtEZPnVvr0M9XOWrdjaeNZGBs69dk8a8Sqim4rXM= 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+43653+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 1562926384704820.1001999304656; Fri, 12 Jul 2019 03:13:04 -0700 (PDT) Return-Path: X-Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by groups.io with SMTP; Fri, 12 Jul 2019 03:13:02 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Jul 2019 03:13:01 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,482,1557212400"; d="scan'208";a="168281958" X-Received: from shwdeopenpsi068.ccr.corp.intel.com ([10.239.158.38]) by fmsmga007.fm.intel.com with ESMTP; 12 Jul 2019 03:12:59 -0700 From: "Zeng, Star" To: devel@edk2.groups.io Cc: Star Zeng , Laszlo Ersek , Eric Dong , Ray Ni , Chandana Kumar , Kevin Li Subject: [edk2-devel] [PATCH] UefiCpuPkg CpuCommonFeaturesLib: Enhance Ppin code Date: Fri, 12 Jul 2019 18:12:58 +0800 Message-Id: <20190712101258.17512-1-star.zeng@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,star.zeng@intel.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1562926383; bh=7TqLXitzL+No4ZJj4JSz7fbD7Hyqtj1Q9TEKQmy1mcs=; h=Cc:Date:From:Reply-To:Subject:To; b=XPXmzx7gQ8GNY6BkQVLNMIZaubuA+Uk3QfPOBaRSXD39ULFHn/XCB3jWrw4EyaCjFS8 H0XYnQkTVv9KaIzlOpdIa+AQqr+h/AGryReVCpcgErx8xsahnzi0HsxTue+Y82cE40Xx9 BsIQ4LNvXnsdH8nxBFxL/7v12reJRyKt07Q= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1961 Enhance Ppin code to enable and unlock for TRUE State, and disable and lock for FALSE State. Note: enable and lock could not be set both. Cc: Laszlo Ersek Cc: Eric Dong Cc: Ray Ni Cc: Chandana Kumar Cc: Kevin Li Signed-off-by: Star Zeng Reviewed-by: Eric Dong Reviewed-by: Ray Ni --- .../CpuCommonFeaturesLib/CpuCommonFeatures.h | 15 +++++ .../CpuCommonFeaturesLib.c | 2 +- .../Library/CpuCommonFeaturesLib/Ppin.c | 65 +++++++++++++++---- 3 files changed, 70 insertions(+), 12 deletions(-) diff --git a/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeatures.h b/= UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeatures.h index 9e784e916a85..8406c6c1619f 100644 --- a/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeatures.h +++ b/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeatures.h @@ -863,6 +863,21 @@ FeatureControlGetConfigData ( IN UINTN NumberOfProcessors ); =20 +/** + Prepares for the data used by CPU feature detection and initialization. + + @param[in] NumberOfProcessors The number of CPUs in the platform. + + @return Pointer to a buffer of CPU related configuration data. + + @note This service could be called by BSP only. +**/ +VOID * +EFIAPI +PpinGetConfigData ( + IN UINTN NumberOfProcessors + ); + /** Detects if Protected Processor Inventory Number feature supported on cur= rent processor. diff --git a/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.c= b/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.c index 7cc692efb649..fd43b8d66290 100644 --- a/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.c +++ b/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.c @@ -203,7 +203,7 @@ CpuCommonFeaturesLibConstructor ( if (IsCpuFeatureSupported (CPU_FEATURE_PPIN)) { Status =3D RegisterCpuFeature ( "PPIN", - NULL, + PpinGetConfigData, PpinSupport, PpinInitialize, CPU_FEATURE_PPIN, diff --git a/UefiCpuPkg/Library/CpuCommonFeaturesLib/Ppin.c b/UefiCpuPkg/Li= brary/CpuCommonFeaturesLib/Ppin.c index e8a4de8dcf60..8067cf44d015 100644 --- a/UefiCpuPkg/Library/CpuCommonFeaturesLib/Ppin.c +++ b/UefiCpuPkg/Library/CpuCommonFeaturesLib/Ppin.c @@ -8,6 +8,28 @@ =20 #include "CpuCommonFeatures.h" =20 +/** + Prepares for the data used by CPU feature detection and initialization. + + @param[in] NumberOfProcessors The number of CPUs in the platform. + + @return Pointer to a buffer of CPU related configuration data. + + @note This service could be called by BSP only. +**/ +VOID * +EFIAPI +PpinGetConfigData ( + IN UINTN NumberOfProcessors + ) +{ + VOID *ConfigData; + + ConfigData =3D AllocateZeroPool (sizeof (MSR_IVY_BRIDGE_PPIN_CTL_REGISTE= R) * NumberOfProcessors); + ASSERT (ConfigData !=3D NULL); + return ConfigData; +} + /** Detects if Protected Processor Inventory Number feature supported on cur= rent processor. @@ -34,6 +56,7 @@ PpinSupport ( ) { MSR_IVY_BRIDGE_PLATFORM_INFO_1_REGISTER PlatformInfo; + MSR_IVY_BRIDGE_PPIN_CTL_REGISTER *MsrPpinCtrl; =20 if ((CpuInfo->DisplayFamily =3D=3D 0x06) && ((CpuInfo->DisplayModel =3D=3D 0x3E) || // Xeon E5 V2 @@ -47,7 +70,12 @@ PpinSupport ( // Check whether platform support this feature. // PlatformInfo.Uint64 =3D AsmReadMsr64 (MSR_IVY_BRIDGE_PLATFORM_INFO_1); - return (PlatformInfo.Bits.PPIN_CAP !=3D 0); + if (PlatformInfo.Bits.PPIN_CAP !=3D 0) { + MsrPpinCtrl =3D (MSR_IVY_BRIDGE_PPIN_CTL_REGISTER *) ConfigData; + ASSERT (MsrPpinCtrl !=3D NULL); + MsrPpinCtrl[ProcessorNumber].Uint64 =3D AsmReadMsr64 (MSR_IVY_BRIDGE= _PPIN_CTL); + return TRUE; + } } =20 return FALSE; @@ -73,6 +101,7 @@ PpinSupport ( @retval RETURN_DEVICE_ERROR Device can't change state because it has be= en locked. =20 + @note This service could be called by BSP only. **/ RETURN_STATUS EFIAPI @@ -83,16 +112,18 @@ PpinInitialize ( IN BOOLEAN State ) { - MSR_IVY_BRIDGE_PPIN_CTL_REGISTER MsrPpinCtrl; + MSR_IVY_BRIDGE_PPIN_CTL_REGISTER *MsrPpinCtrl; + + MsrPpinCtrl =3D (MSR_IVY_BRIDGE_PPIN_CTL_REGISTER *) ConfigData; + ASSERT (MsrPpinCtrl !=3D NULL); =20 // - // Check whether device already lock this register. - // If already locked, just base on the request state and + // Check whether processor already lock this register. + // If already locked, just based on the request state and // the current state to return the status. // - MsrPpinCtrl.Uint64 =3D AsmReadMsr64 (MSR_IVY_BRIDGE_PPIN_CTL); - if (MsrPpinCtrl.Bits.LockOut !=3D 0) { - return MsrPpinCtrl.Bits.Enable_PPIN =3D=3D State ? RETURN_SUCCESS : RE= TURN_DEVICE_ERROR; + if (MsrPpinCtrl[ProcessorNumber].Bits.LockOut !=3D 0) { + return MsrPpinCtrl[ProcessorNumber].Bits.Enable_PPIN =3D=3D State ? RE= TURN_SUCCESS : RETURN_DEVICE_ERROR; } =20 // @@ -106,13 +137,25 @@ PpinInitialize ( return RETURN_SUCCESS; } =20 - CPU_REGISTER_TABLE_WRITE_FIELD ( + if (State) { + // + // Enable and Unlock. + // + MsrPpinCtrl[ProcessorNumber].Bits.Enable_PPIN =3D 1; + MsrPpinCtrl[ProcessorNumber].Bits.LockOut =3D 0; + } else { + // + // Disable and Lock. + // + MsrPpinCtrl[ProcessorNumber].Bits.Enable_PPIN =3D 0; + MsrPpinCtrl[ProcessorNumber].Bits.LockOut =3D 1; + } + + CPU_REGISTER_TABLE_WRITE64 ( ProcessorNumber, Msr, MSR_IVY_BRIDGE_PPIN_CTL, - MSR_IVY_BRIDGE_PPIN_CTL_REGISTER, - Bits.Enable_PPIN, - (State) ? 1 : 0 + MsrPpinCtrl[ProcessorNumber].Uint64 ); =20 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 (#43653): https://edk2.groups.io/g/devel/message/43653 Mute This Topic: https://groups.io/mt/32440401/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-