From nobody Tue May 7 22:15:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+61306+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+61306+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one) Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1592245853902773.1345488410467; Mon, 15 Jun 2020 11:30:53 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id iOAcYY1788612xMRU3WcS784; Mon, 15 Jun 2020 11:30:53 -0700 X-Received: from NAM10-MW2-obe.outbound.protection.outlook.com (NAM10-MW2-obe.outbound.protection.outlook.com []) by mx.groups.io with SMTP id smtpd.web11.25051.1592245852109014167 for ; Mon, 15 Jun 2020 11:30:52 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dTyyz9+vS8Z4XeILrfHd1RXUXJh07yW8Q+hrAEq8dp7dm9r3PF8cW250K9F+ZlLM2uddi2Y/XB9spiDiotGZ1fI0RJEzIZgTKpORxganeMlZygKCDV5Jb/7iCGjkjkMwu/80WgvW/iqplMKvkGNX3Y2FuuxcTbMLEva4cz6YFKpkMyx0SNyOwMgoUmHW3HXay3Mym0gZt6HCxmk6ZNbgBuPsHFJpn+RBUTC2ZumAqXGbrqlVXR9s/aSX2SvvnDr/PNFVZNATsZwf/FTzx2pUBL+PjBNWxuMrgJM5Lgsq7yagsVeMXPMhcLcwIqQDXGbooSsAWyeQIc8XtmpQyMplAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=YW1vbVytOJADWHRc6z90yztky286Y3P5HYAq+wqcXiU=; b=Tc2BTJZejE5dn55qnYqX5Ic4UoHjRSUPXEEqtdFGiWCSJzUfW15iVLpj2UtiyiH2PtvYpVxUxivoY9vGhN6zxJ54T3mGEERHaXaVLtexyW5u7elDlvc3h27WIAzprnkPWdsMalRCPTKIGEZo1eNv6CrTlfTrmmd+RMzKbsK8PRbrp4SopMmvJEeBVNu3GuqZzBQh6Odd0Yz9aQXg9y28zISiQYGHqvMRKJZGNRzbUKSUx+cl0CcQvz9t5a8gYKKCDaDGR5Dt5+UVXyO7Mfy/cNKTKKNi8J/kH9fDUv9Zctk4whv84/X703+XJv5/fipbz57Vkq6WNWSAbKjHbQRlhA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none X-Received: from SN1PR12MB2352.namprd12.prod.outlook.com (2603:10b6:802:25::13) by SN1PR12MB2495.namprd12.prod.outlook.com (2603:10b6:802:32::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3088.24; Mon, 15 Jun 2020 18:30:51 +0000 X-Received: from SN1PR12MB2352.namprd12.prod.outlook.com ([fe80::156e:ce6d:a148:274e]) by SN1PR12MB2352.namprd12.prod.outlook.com ([fe80::156e:ce6d:a148:274e%7]) with mapi id 15.20.3088.025; Mon, 15 Jun 2020 18:30:51 +0000 From: "Kirkendall, Garrett" To: devel@edk2.groups.io Cc: Eric Dong , Ray Ni , Laszlo Ersek Subject: [edk2-devel] [PATCH v1 1/2] UefiCpuPkg: Move StandardSignatureIsAuthenticAMD to BaseUefiCpuLib Date: Mon, 15 Jun 2020 13:30:28 -0500 Message-Id: <20200615183029.4577-2-Garrett.Kirkendall@amd.com> In-Reply-To: <20200615183029.4577-1-Garrett.Kirkendall@amd.com> References: <20200615183029.4577-1-Garrett.Kirkendall@amd.com> X-ClientProxiedBy: SA9PR03CA0020.namprd03.prod.outlook.com (2603:10b6:806:20::25) To SN1PR12MB2352.namprd12.prod.outlook.com (2603:10b6:802:25::13) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-Received: from biosdev-01.amd.com (165.204.78.2) by SA9PR03CA0020.namprd03.prod.outlook.com (2603:10b6:806:20::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3088.27 via Frontend Transport; Mon, 15 Jun 2020 18:30:50 +0000 X-Originating-IP: [165.204.78.2] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 16cb6403-e27c-45b3-4f25-08d8115a3b30 X-MS-TrafficTypeDiagnostic: SN1PR12MB2495: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: 5loBRaHXSOBSzCftdy38ZlbHlVT6jBp2/UyBH8XZh8Uhs9wy3DEEWIWC5NpgHPtGrfBBD1AFzYGCf5zn7eVKsc2bCpItyJRM7rFoalQ8Af9mZXWgV6UzbVhqxgWdvc+N+OjTv8XYZEdYCGU9ggYLpwpf9PmU/M7EwgA/QWu9rxGUVKpVg3Mb+7mSe4kPIIRw4riT4gkUgAM78ANqS7ZKQ1uOYIRpkEszWJ63WgzJowywOISEugZbdb4/vPy3864AnphHVwXSpaXWWIItKMVYKG7KTninMaZ7j3MJSQpY2pyA3tgZJcdNCB2/Xy/Hnz40olGkvsZIAjSf8Jq1w5Nfmw== X-MS-Exchange-AntiSpam-MessageData: fuU8jcJ+ujkGsArWtP8VggFlmUBM6ITVCFItb2HIJ1bO5LZt0OmVud+EqK6EuY637XxDECm4B7wAW+GqtX0PLFlnje+z4DqY+zHPb37irWg/oFIzzsjtW75EepgTcqajLEtAvCFKwuvRKC90tWnsZp/ZvPnFdxRq0tmpdyD+hyTODsBKAAgBdjrECsuxr97ri2pcIAktMSXVwnLWoSg2pAgsKMhQzm4ZDoWCPtghfB2ATKE84J77221J+CeAUWVWxfdaV2+E8WkJB/3oAg4PWFFPU++gc4qon+g2werM490QVmEQCedEq3HVVRcRiPdnlINpEbzjYP6lWDTmQ0VaC233pgQN5vZxwz2e/bxF5QdguGAIUN9N4XAkoKe9u5lJjP0PNB6Xz4/1gtquPtfmgHjuf1VD9TMxauwvPkulHFLOAfYP6UeQFhrhcKh/3fEE/OiVP65WkfI2KNVVZjV77gui9R6DT2aGr4RYJ+2TaQY= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 16cb6403-e27c-45b3-4f25-08d8115a3b30 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jun 2020 18:30:51.2284 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: mlJynaqdNClW/ZKBIg86CpBIvOhajG+mmbHbFB+cVsBTbUubFfU4/FIfNFDBGMi9oQgr9M6vidD4xJjIhhu8nw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB2495 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,garrett.kirkendall@amd.com X-Gm-Message-State: IqSenurOFCqX1ZyDERjob9phx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1592245853; bh=qJAgyKZNIFYKTSKyTufdosN62VtNvmGah9M3HaHsh2U=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=k/a93Qlbda9Ar3OQA/B3yf/oMgGKg2NDmoyG+g+zc0xGWsw9XiUdL1LKjrdVw8tWx2H DElU+BpCkgiyr0zswupo2lURsUdYq0OvexQWc26YzsPLh4L79wWT0X+jQ4/FPoOzNb8gR UczduqxBFZPPcA8+UzxcwzVuNlzaJRIQL5E= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Refactor StandardSignatureIsAuthenticAMD into BaseUefiCpuLib from separate copies in BaseXApicLib, BaseXApicX2ApicLib, and MpInitLib. This allows for future use of StandarSignatureIsAuthinticAMD without creating more instances in other modules. This function allows IA32/X64 code to determine if it is running on an AMD brand processor. UefiCpuLib is already included directly or indirectly in all modified modules. Complete move is made in this change. Cc: Eric Dong Cc: Ray Ni Cc: Laszlo Ersek Signed-off-by: Garrett Kirkendall Reviewed-by: Eric Dong Reviewed-by: Laszlo Ersek --- UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf | 7 ++++ UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.inf | 2 ++ UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.inf | 2 ++ UefiCpuPkg/Include/Library/UefiCpuLib.h | 14 ++++++++ UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.c | 38 ++++++++= ++++++++++++ UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.c | 25 ++------= ----- UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.c | 25 ++------= ----- UefiCpuPkg/Library/MpInitLib/MpLib.c | 23 --------= ---- 8 files changed, 67 insertions(+), 69 deletions(-) diff --git a/UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf b/UefiCpu= Pkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf index 006b7acbf14e..34d3a7bb4303 100644 --- a/UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf +++ b/UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf @@ -4,6 +4,7 @@ # The library routines are UEFI specification compliant. # # Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.
+# Copyright (c) 2020, AMD Inc. All rights reserved.
# SPDX-License-Identifier: BSD-2-Clause-Patent # ## @@ -29,6 +30,12 @@ [Sources.IA32] [Sources.X64] X64/InitializeFpu.nasm =20 +[Sources] + BaseUefiCpuLib.c + [Packages] MdePkg/MdePkg.dec UefiCpuPkg/UefiCpuPkg.dec + +[LibraryClasses] + BaseLib diff --git a/UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.inf b/UefiCpuPkg/= Library/BaseXApicLib/BaseXApicLib.inf index bdb2ff372677..561baa44b0e6 100644 --- a/UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.inf +++ b/UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.inf @@ -5,6 +5,7 @@ # where local APIC is disabled. # # Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.
+# Copyright (c) 2020, AMD Inc. All rights reserved.
# SPDX-License-Identifier: BSD-2-Clause-Patent # ## @@ -37,6 +38,7 @@ [LibraryClasses] TimerLib IoLib PcdLib + UefiCpuLib =20 [Pcd] gUefiCpuPkgTokenSpaceGuid.PcdCpuInitIpiDelayInMicroSeconds ## SOMETIMES= _CONSUMES diff --git a/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.inf b= /UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.inf index ac1e0a1c9896..1e2a4f8b790f 100644 --- a/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.inf +++ b/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.inf @@ -5,6 +5,7 @@ # where local APIC is disabled. # # Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.
+# Copyright (c) 2020, AMD Inc. All rights reserved.
# SPDX-License-Identifier: BSD-2-Clause-Patent # ## @@ -37,6 +38,7 @@ [LibraryClasses] TimerLib IoLib PcdLib + UefiCpuLib =20 [Pcd] gUefiCpuPkgTokenSpaceGuid.PcdCpuInitIpiDelayInMicroSeconds ## SOMETIMES= _CONSUMES diff --git a/UefiCpuPkg/Include/Library/UefiCpuLib.h b/UefiCpuPkg/Include/L= ibrary/UefiCpuLib.h index 82e53bab3a0f..5326e7246301 100644 --- a/UefiCpuPkg/Include/Library/UefiCpuLib.h +++ b/UefiCpuPkg/Include/Library/UefiCpuLib.h @@ -5,6 +5,7 @@ to be UEFI specification compliant. =20 Copyright (c) 2009, Intel Corporation. All rights reserved.
+ Copyright (c) 2020, AMD Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -29,4 +30,17 @@ InitializeFloatingPointUnits ( VOID ); =20 +/** + Determine if the standard CPU signature is "AuthenticAMD". + + @retval TRUE The CPU signature matches. + @retval FALSE The CPU signature does not match. + +**/ +BOOLEAN +EFIAPI +StandardSignatureIsAuthenticAMD ( + VOID + ); + #endif diff --git a/UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.c b/UefiCpuPk= g/Library/BaseUefiCpuLib/BaseUefiCpuLib.c new file mode 100644 index 000000000000..c2cc3ff9a709 --- /dev/null +++ b/UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.c @@ -0,0 +1,38 @@ +/** @file + This library defines some routines that are generic for IA32 family CPU. + + The library routines are UEFI specification compliant. + + Copyright (c) 2020, AMD Inc. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include + +#include +#include + +/** + Determine if the standard CPU signature is "AuthenticAMD". + + @retval TRUE The CPU signature matches. + @retval FALSE The CPU signature does not match. + +**/ +BOOLEAN +EFIAPI +StandardSignatureIsAuthenticAMD ( + VOID + ) +{ + UINT32 RegEbx; + UINT32 RegEcx; + UINT32 RegEdx; + + AsmCpuid (CPUID_SIGNATURE, NULL, &RegEbx, &RegEcx, &RegEdx); + return (RegEbx =3D=3D CPUID_SIGNATURE_AUTHENTIC_AMD_EBX && + RegEcx =3D=3D CPUID_SIGNATURE_AUTHENTIC_AMD_ECX && + RegEdx =3D=3D CPUID_SIGNATURE_AUTHENTIC_AMD_EDX); +} diff --git a/UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.c b/UefiCpuPkg/Li= brary/BaseXApicLib/BaseXApicLib.c index 33ea15ca2916..52bd90d33428 100644 --- a/UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.c +++ b/UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.c @@ -4,7 +4,7 @@ This local APIC library instance supports xAPIC mode only. =20 Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved.
- Copyright (c) 2017, AMD Inc. All rights reserved.
+ Copyright (c) 2017 - 2020, AMD Inc. All rights reserved.
=20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -21,33 +21,12 @@ #include #include #include +#include =20 // // Library internal functions // =20 -/** - Determine if the standard CPU signature is "AuthenticAMD". - - @retval TRUE The CPU signature matches. - @retval FALSE The CPU signature does not match. - -**/ -BOOLEAN -StandardSignatureIsAuthenticAMD ( - VOID - ) -{ - UINT32 RegEbx; - UINT32 RegEcx; - UINT32 RegEdx; - - AsmCpuid (CPUID_SIGNATURE, NULL, &RegEbx, &RegEcx, &RegEdx); - return (RegEbx =3D=3D CPUID_SIGNATURE_AUTHENTIC_AMD_EBX && - RegEcx =3D=3D CPUID_SIGNATURE_AUTHENTIC_AMD_ECX && - RegEdx =3D=3D CPUID_SIGNATURE_AUTHENTIC_AMD_EDX); -} - /** Determine if the CPU supports the Local APIC Base Address MSR. =20 diff --git a/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.c b/U= efiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.c index d0f92b33dc8c..cdcbca046191 100644 --- a/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.c +++ b/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.c @@ -5,7 +5,7 @@ which have xAPIC and x2APIC modes. =20 Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved.
- Copyright (c) 2017, AMD Inc. All rights reserved.
+ Copyright (c) 2017 - 2020, AMD Inc. All rights reserved.
=20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -22,33 +22,12 @@ #include #include #include +#include =20 // // Library internal functions // =20 -/** - Determine if the standard CPU signature is "AuthenticAMD". - - @retval TRUE The CPU signature matches. - @retval FALSE The CPU signature does not match. - -**/ -BOOLEAN -StandardSignatureIsAuthenticAMD ( - VOID - ) -{ - UINT32 RegEbx; - UINT32 RegEcx; - UINT32 RegEdx; - - AsmCpuid (CPUID_SIGNATURE, NULL, &RegEbx, &RegEcx, &RegEdx); - return (RegEbx =3D=3D CPUID_SIGNATURE_AUTHENTIC_AMD_EBX && - RegEcx =3D=3D CPUID_SIGNATURE_AUTHENTIC_AMD_ECX && - RegEdx =3D=3D CPUID_SIGNATURE_AUTHENTIC_AMD_EDX); -} - /** Determine if the CPU supports the Local APIC Base Address MSR. =20 diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/MpIn= itLib/MpLib.c index ab7a8ed6633a..9b0660a5d4ea 100644 --- a/UefiCpuPkg/Library/MpInitLib/MpLib.c +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c @@ -13,29 +13,6 @@ EFI_GUID mCpuInitMpLibHobGuid =3D CPU_INIT_MP_LIB_HOB_GUID; =20 =20 -/** - Determine if the standard CPU signature is "AuthenticAMD". - - @retval TRUE The CPU signature matches. - @retval FALSE The CPU signature does not match. - -**/ -STATIC -BOOLEAN -StandardSignatureIsAuthenticAMD ( - VOID - ) -{ - UINT32 RegEbx; - UINT32 RegEcx; - UINT32 RegEdx; - - AsmCpuid (CPUID_SIGNATURE, NULL, &RegEbx, &RegEcx, &RegEdx); - return (RegEbx =3D=3D CPUID_SIGNATURE_AUTHENTIC_AMD_EBX && - RegEcx =3D=3D CPUID_SIGNATURE_AUTHENTIC_AMD_ECX && - RegEdx =3D=3D CPUID_SIGNATURE_AUTHENTIC_AMD_EDX); -} - /** The function will check if BSP Execute Disable is enabled. =20 --=20 2.27.0 -=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 (#61306): https://edk2.groups.io/g/devel/message/61306 Mute This Topic: https://groups.io/mt/74901068/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 Tue May 7 22:15:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+61307+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+61307+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one) Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1592245854723779.6623489256599; Mon, 15 Jun 2020 11:30:54 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id DX0cYY1788612xA578KgJ2Rt; Mon, 15 Jun 2020 11:30:54 -0700 X-Received: from NAM10-MW2-obe.outbound.protection.outlook.com (NAM10-MW2-obe.outbound.protection.outlook.com []) by mx.groups.io with SMTP id smtpd.web11.25051.1592245852109014167 for ; Mon, 15 Jun 2020 11:30:53 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Uqa3FBuUtKOUM/o9g5J1vg39s8Rv41bBdpMLBpalTxbgLM4tl2HSXlS0kNTU4ClpzLWWqcgD+9bc0Z/9Nt1Ww0A3biCgnN6vkJOiyfTWCs11ubpzdoNqgJ80zPqWn8fKCPiYb5MSvyqb4wjOGkx7EF3O+Q10EHRhfkpXtiFSbEZwLiNqbrCmf7ES7CGbCMV8hB6sw18iaO/RLeA/5A/W0T93zmTpS0T62qRNGnf51hCWiJY9riQDjlQts0j0KL+X77xzfEJlz7bizPSnTZYitVNwpafsFCtetUIkhwdOpXPATlIBNWf4ScMO4/siuebmk/vt0LoqGNVZpZdb7fAkyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=QZrxmedJDL0wM+Pqp12QCnktTs/w8SnpkwyR//p7e1E=; b=DJXOv1CrJ+HyEqML6fAQuzgPHGhteyu3izdSlZxKOCQyeA60FizvaD9AXm7xtwUqOCNdW1uAtXDb4fxhqoCTQODVMOnzm3NOmep7JJqpGvSKL1klqIirb3R8l6PYxKt4lCq/LRwu6W0m3dks6ksi5wR8MNJlv48HkP3UAXphqWZ34PbW3jULvBieYWdh4HEwPbO7yeTOYRgC7YyBB2l4nZicSZ9CLaViJr1aRUfBMeSmh4c6E8slul1k3JtkpGBvWOuAKmtaqcYf2HpgSqvojRoyLKQ966ooswa2L+V+nv8NS66vW9tPHURAc+fNGCww5iPgApWawFzkFtd1XhMkxA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none X-Received: from SN1PR12MB2352.namprd12.prod.outlook.com (2603:10b6:802:25::13) by SN1PR12MB2495.namprd12.prod.outlook.com (2603:10b6:802:32::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3088.24; Mon, 15 Jun 2020 18:30:51 +0000 X-Received: from SN1PR12MB2352.namprd12.prod.outlook.com ([fe80::156e:ce6d:a148:274e]) by SN1PR12MB2352.namprd12.prod.outlook.com ([fe80::156e:ce6d:a148:274e%7]) with mapi id 15.20.3088.025; Mon, 15 Jun 2020 18:30:51 +0000 From: "Kirkendall, Garrett" To: devel@edk2.groups.io Cc: Eric Dong , Ray Ni , Laszlo Ersek Subject: [edk2-devel] [PATCH v1 2/2] UefiCpuPkg: PiSmmCpuDxeSmm skip MSR_IA32_MISC_ENABLE manipulation on AMD Date: Mon, 15 Jun 2020 13:30:29 -0500 Message-Id: <20200615183029.4577-3-Garrett.Kirkendall@amd.com> In-Reply-To: <20200615183029.4577-1-Garrett.Kirkendall@amd.com> References: <20200615183029.4577-1-Garrett.Kirkendall@amd.com> X-ClientProxiedBy: SA9PR03CA0020.namprd03.prod.outlook.com (2603:10b6:806:20::25) To SN1PR12MB2352.namprd12.prod.outlook.com (2603:10b6:802:25::13) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-Received: from biosdev-01.amd.com (165.204.78.2) by SA9PR03CA0020.namprd03.prod.outlook.com (2603:10b6:806:20::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3088.27 via Frontend Transport; Mon, 15 Jun 2020 18:30:51 +0000 X-Originating-IP: [165.204.78.2] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 55f62374-a785-4050-11b4-08d8115a3b77 X-MS-TrafficTypeDiagnostic: SN1PR12MB2495: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2150; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: P/5jhf3g6czMb9ow3hBNEG+V2ALUzMEizs/IbfvEby81k8olTjMWK8u4EIH3lOx8Q4PhTH0c+0pR2DrOWZl4WavzJ8xiAM4DHLHHoWMwSGifJFw1mLhvwsq97ecrpfs3nwOA5Bnz2gz++1zI0hQxyQX98IuDKR8NU4+3U97rgwwZgDuKxuE48SKJGfhLIsERK5MEIT9og2UdDDb4WcpPvQN7Z8SNc3LIO7d52cNHNLdY28aZ/1TSdF+5suiCxadLFlheQdLrkK+FHAbAU4Qhv6L77CA8dIw51G3XkuvjxHLC0mXDxziqzUhvsDNN7LIk1DqLZZJMovuGFVShUVh/ew== X-MS-Exchange-AntiSpam-MessageData: 7RlXyQsW34JRAbD3TGjzdSppeVr5j3esZMu82sGt8JEM8J+iCptfzXIGEbcQclmOXIvMHCdaY0Gmh9dLegTU6XacDwGw/me7YgqTmR8jAU5Nc7PqL3VywoL5Myn1z40DeBRX6LUq9j0gDqHMxRQ4No+sYqh7hMAkifypP0iWqy265v0A6x9HqYBvxo1VqFjE10+uCT1lpDPnhP/J7XN0QTbSXcxlary11I1i4BFJMxGvpftYbFOc9KEPrvhUixa92Px6mj+dLxbmWZk4XAi7Yy6HIu7C3VYGNYDkasuH2jj8bfsvIowSQ8QREDrEVoG7ixBOCNChPNxJziQiTXbHA/t6cZIv4hEWAJDt+Kwp0vn252RPyEsoEje2I2eUDsngHrirFvkqwypjbTtesTsugQYfCS+uJIQDel6Ca/r9RkZvZ6Stvw6lQHxG8ervlJcV48FXrc/GCLP+p5h6n5y+i3U7sTM7z03ZxQ+1Sjvg+L4= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 55f62374-a785-4050-11b4-08d8115a3b77 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jun 2020 18:30:51.7122 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ceLpXr/qCuW5ugbj9SzBHO37EIvVpfHeZ7Xlx6TMJ4Il/UpxgfbNvbGmDhSL0tlzi8hXlByKRNtTo3lEB6Cf+g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB2495 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,garrett.kirkendall@amd.com X-Gm-Message-State: T5O81qoe9MyxVSf0PCzIozVNx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1592245854; bh=CgqAHgd0gpUSEqMPMylWWZZRyhNSGjFfGZ6YWWy+hi4=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=ekSnBNA9tsT/x6b1snPtP4rQxyccAojj6SNlo4Cgml3nb6O3JvmYZwFgkC/lA9Vim5i De5g9ZMI4oRPlrj/VHRYQWuFcAIpexBAN/wYRd3S4/vq9LfYAg0tSUBGqHMBjnXfpqnp6 1481e+zu68s5S7fHjc/LumWoHPVIcT6ndYA= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" AMD does not support MSR_IA32_MISC_ENABLE. Accessing that register causes and exception on AMD processors. If Execution Disable is supported, and if the processor is an AMD processor skip manipulating MSR_IA32_MISC_ENABLE[34] XD Disable bit. Cc: Eric Dong Cc: Ray Ni Cc: Laszlo Ersek Signed-off-by: Garrett Kirkendall --- UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfileInternal.h | 3 +++ UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.c | 9 ++++++++- UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.nasm | 19 +++++++++++++++++-- UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.nasm | 20 ++++++++++++++++++-- 4 files changed, 46 insertions(+), 5 deletions(-) diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfileInternal.h b/UefiCpuPkg/Pi= SmmCpuDxeSmm/SmmProfileInternal.h index 43f6935cf9dc..0f6e0c9c98ad 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfileInternal.h +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfileInternal.h @@ -2,6 +2,7 @@ SMM profile internal header file. =20 Copyright (c) 2012 - 2018, Intel Corporation. All rights reserved.
+Copyright (c) 2020, AMD Incorporated. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -13,6 +14,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include #include #include +#include #include =20 #include "SmmProfileArch.h" @@ -99,6 +101,7 @@ extern SMM_S3_RESUME_STATE *mSmmS3ResumeState; extern UINTN gSmiExceptionHandlers[]; extern BOOLEAN mXdSupported; X86_ASSEMBLY_PATCH_LABEL gPatchXdSupported; +X86_ASSEMBLY_PATCH_LABEL gPatchMsrIA32MiscEnableSupported; extern UINTN *mPFEntryCount; extern UINT64 (*mLastPFEntryValue)[MAX_PF_ENTRY_COUNT]; extern UINT64 *(*mLastPFEntryPointer)[MAX_PF_ENTRY_COUN= T]; diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.c b/UefiCpuPkg/PiSmmCpuDx= eSmm/SmmProfile.c index c47b5573e366..146600e6c3b4 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.c +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.c @@ -2,7 +2,7 @@ Enable SMM profile. =20 Copyright (c) 2012 - 2019, Intel Corporation. All rights reserved.
-Copyright (c) 2017, AMD Incorporated. All rights reserved.
+Copyright (c) 2017 - 2020, AMD Incorporated. All rights reserved.
=20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -1015,6 +1015,13 @@ CheckFeatureSupported ( mXdSupported =3D FALSE; PatchInstructionX86 (gPatchXdSupported, mXdSupported, 1); } + + if (StandardSignatureIsAuthenticAMD()) { + // + // AMD processors do not support MSR_IA32_MISC_ENABLE + // + PatchInstructionX86 (gPatchMsrIA32MiscEnableSupported, FALSE, 1); + } } =20 if (mBtsSupported) { diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.nasm b/UefiCpuPkg/PiSm= mCpuDxeSmm/Ia32/SmiEntry.nasm index f96de9bdeb43..e4ef5899f274 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.nasm +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.nasm @@ -1,5 +1,6 @@ ;-------------------------------------------------------------------------= ----- ; ; Copyright (c) 2016 - 2019, Intel Corporation. All rights reserved.
+; Copyright (c) 2020, AMD Incorporated. All rights reserved.
; SPDX-License-Identifier: BSD-2-Clause-Patent ; ; Module Name: @@ -59,6 +60,7 @@ global ASM_PFX(gPatchSmiStack) global ASM_PFX(gPatchSmbase) extern ASM_PFX(mXdSupported) global ASM_PFX(gPatchXdSupported) +global ASM_PFX(gPatchMsrIA32MiscEnableSupported) extern ASM_PFX(gSmiHandlerIdtr) =20 extern ASM_PFX(mCetSupported) @@ -153,17 +155,30 @@ ASM_PFX(gPatchSmiCr3): ASM_PFX(gPatchXdSupported): cmp al, 0 jz @SkipXd + +; Clear XD Disable bit if supported + mov al, strict byte 1 ; source operand may be patched +ASM_PFX(gPatchMsrIA32MiscEnableSupported): + cmp al, 1 + jz MsrIA32MiscEnableSupported + +; MSR_IA32_MISC_ENABLE not supported + xor edx, edx + push edx + jmp EnableNxe + ; ; Check XD disable bit ; +MsrIA32MiscEnableSupported: mov ecx, MSR_IA32_MISC_ENABLE rdmsr push edx ; save MSR_IA32_MISC_ENABLE[63-32] test edx, BIT2 ; MSR_IA32_MISC_ENABLE[34] - jz .5 + jz EnableNxe and dx, 0xFFFB ; clear XD Disable bit if it is set wrmsr -.5: +EnableNxe: mov ecx, MSR_EFER rdmsr or ax, MSR_EFER_XD ; enable NXE diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.nasm b/UefiCpuPkg/PiSmm= CpuDxeSmm/X64/SmiEntry.nasm index 8bfba55b5d08..5a4678c7aa63 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.nasm +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.nasm @@ -1,5 +1,6 @@ ;-------------------------------------------------------------------------= ----- ; ; Copyright (c) 2016 - 2019, Intel Corporation. All rights reserved.
+; Copyright (c) 2020, AMD Incorporated. All rights reserved.
; SPDX-License-Identifier: BSD-2-Clause-Patent ; ; Module Name: @@ -67,6 +68,7 @@ extern ASM_PFX(CpuSmmDebugExit) global ASM_PFX(gPatchSmbase) extern ASM_PFX(mXdSupported) global ASM_PFX(gPatchXdSupported) +global ASM_PFX(gPatchMsrIA32MiscEnableSupported) global ASM_PFX(gPatchSmiStack) global ASM_PFX(gPatchSmiCr3) global ASM_PFX(gPatch5LevelPagingNeeded) @@ -152,18 +154,32 @@ SkipEnable5LevelPaging: ASM_PFX(gPatchXdSupported): cmp al, 0 jz @SkipXd + +; Clear XD Disable bit if supported + mov al, strict byte 1 ; source operand may be patched +ASM_PFX(gPatchMsrIA32MiscEnableSupported): + cmp al, 1 + jz MsrIA32MiscEnableSupported + +; MSR_IA32_MISC_ENABLE not supported + sub esp, 4 + xor rdx, rdx + push rdx + jmp EnableNxe + ; ; Check XD disable bit ; +MsrIA32MiscEnableSupported: mov ecx, MSR_IA32_MISC_ENABLE rdmsr sub esp, 4 push rdx ; save MSR_IA32_MISC_ENABLE[63-32] test edx, BIT2 ; MSR_IA32_MISC_ENABLE[34] - jz .0 + jz EnableNxe and dx, 0xFFFB ; clear XD Disable bit if it is set wrmsr -.0: +EnableNxe: mov ecx, MSR_EFER rdmsr or ax, MSR_EFER_XD ; enable NXE --=20 2.27.0 -=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 (#61307): https://edk2.groups.io/g/devel/message/61307 Mute This Topic: https://groups.io/mt/74901070/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-