From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM02-BL2-obe.outbound.protection.outlook.com (NAM02-BL2-obe.outbound.protection.outlook.com []) by mx.groups.io with SMTP id smtpd.web11.10052.1592493784863331489 for ; Thu, 18 Jun 2020 08:23:05 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector2-amdcloud-onmicrosoft-com header.b=WmNnnliG; spf=none, err=SPF record not found (domain: amd.com, ip: , mailfrom: garrett.kirkendall@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TiJ0BkTpWeOcWDGAqz47OuyyKwO7cXrSjKB0iE5mi0Zn2MPKTVQWAkTfjGH6FYoN8xoTFzbo0hpA2n+q7/pzoq6uul0il+6GB58UNwXhzzrCSNbiKia7mugyuAVzRH0hC8gO7aZCffOrFLXMbnl9GqBcJaLNobi5wF4Ujn06kP451Z2AkTjd5vo9lLov5Fhu0IVs/31EH9cp3uncRL2q9nPlECnVyIWdGfbfoXcs2W1rYMJxepiRuo3ef46nXWWfZ12xeqsAjtwumZ5l6qnD/oI/PjKCZAhWAaFmd7s+D7XCvtD9EwvrxdRqPtE685okdB/Z0pQZoTqef6N7B7cuCw== 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=zUM81YlBi07HOtoSezUaDT+XKTXGL4kLfBpgX+sXwuA=; b=keIcDX8P5RJGTwXx5bGyCpDPIbGwOhG3tBMctPxuKo9nsNI++KjeS4FWUpZKvPuFoD6ywf7Wb7kHCX4kQlzol4wggkbdaoi+VMaORww8B5symYjO13H4CXuZDgzBG0gQs6gqxfMXBpYlAY0850+EB4E+uIUgrpT+MQpBJqwa1dbSyo97JCwXhkpVaDfsjd0XFVSVaybdBhPR5x7AT6FhseHEnwNYY+kfeXZNNSU3eSzoIhoZ2YIJNofRqaZp6KHy3TsBQopTEWfheBOyQymvMYvhsPamKRD0Nu4neTN4DaVNctwwbbT4amrNPY+XybY7Dq5tyIuhF0AS3LhanPmOXg== 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector2-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zUM81YlBi07HOtoSezUaDT+XKTXGL4kLfBpgX+sXwuA=; b=WmNnnliGsvl7SOzYSCs1zLxT+ttY3+5rN3wtppoKD5g1ZljoEXbTjOnJHv5Pp1+HSb0F2cD2h6OCN/jsLghepir1V/t72bzW9OVZVgMp/hvFkEvOXS6rdlaW2MchJncPlxw4IG8n4LYi9/hG09OkFlsji2MKUiq043XhdCGGGUY= Authentication-Results: edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; dmarc=none action=none header.from=amd.com; Received: from SN1PR12MB2352.namprd12.prod.outlook.com (2603:10b6:802:25::13) by SN1PR12MB2573.namprd12.prod.outlook.com (2603:10b6:802:2b::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.22; Thu, 18 Jun 2020 15:23:03 +0000 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.3109.021; Thu, 18 Jun 2020 15:23:03 +0000 From: "Kirkendall, Garrett" To: devel@edk2.groups.io Cc: Eric Dong , Ray Ni , Laszlo Ersek Subject: [PATCH v2 1/2] UefiCpuPkg: Move StandardSignatureIsAuthenticAMD to BaseUefiCpuLib Date: Thu, 18 Jun 2020 10:22:44 -0500 Message-Id: <20200618152245.6483-2-Garrett.Kirkendall@amd.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200618152245.6483-1-Garrett.Kirkendall@amd.com> References: <20200618152245.6483-1-Garrett.Kirkendall@amd.com> X-ClientProxiedBy: DM5PR20CA0042.namprd20.prod.outlook.com (2603:10b6:3:13d::28) To SN1PR12MB2352.namprd12.prod.outlook.com (2603:10b6:802:25::13) Return-Path: Garrett.Kirkendall@amd.com MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from biosdev-01.amd.com (165.204.78.2) by DM5PR20CA0042.namprd20.prod.outlook.com (2603:10b6:3:13d::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.22 via Frontend Transport; Thu, 18 Jun 2020 15:23:03 +0000 X-Mailer: git-send-email 2.27.0 X-Originating-IP: [165.204.78.2] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 56da8785-f4a8-404e-36ea-08d8139b7e5f X-MS-TrafficTypeDiagnostic: SN1PR12MB2573: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-Forefront-PRVS: 0438F90F17 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dcfSG9CCzSM4N5jfquHYNCLyl0F/LHSWB7rntEH2Ha6qdjku2vSbG29eCSfjhJAJYYGJq5CZO3qutpjidGxYCqDi2SHg/BusjE7eHjQcCORcvuvyirVKZwePolIDeuVC7RWulVufaDwaLAze/zBr3mkaUclQ8SftB8BgSns6C4huAvzrGfpeNPg9sdgwk5DR9mUtwYhDZlB2RBC3g6eufivOJrojPRwRK/+LSoqsiYQWtUOj/IUlBf56Yof+TZZBlQoZ2EGJis9WOnDyFEP66ZldufhKqQ6UN/VuJQe22HAlP/EA7aWEzWfHBM1GxUDZ7GUZ/Dt5he4F0PHcOhAqZQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN1PR12MB2352.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(6029001)(4636009)(366004)(39860400002)(376002)(346002)(396003)(136003)(4326008)(1076003)(956004)(6666004)(478600001)(52116002)(7696005)(316002)(54906003)(16526019)(186003)(26005)(2616005)(86362001)(6916009)(66476007)(8936002)(8676002)(83380400001)(36756003)(2906002)(66556008)(5660300002)(66946007)(6486002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: f154/EcxKmmCrrRHRqp43cnuvYS6DrQMRHmTsJpfTTW0orFyZLbqEzVvbV9aXGpHpFZvba2+JZWVESx+L4Vv/x5uzsI0xAwjcgYfd88ARPWv7YtEtHr+2r8HQZ93xvUI86jXl4mIY3VZpzuLImF/Z5SLN5WcxBXHQlvilNGXFR5m8ZY5SJ3MWoIzPCjGQtRW8y4+25Iy3WzbpgNqfUZ2Ml7zr1NET80cftWm/u1qAaAY6CLRj84q/3qXBDabSIUsthEeea75isF4eyIL7i2GPrI7mLiK2ckon5PkYtxiDEXTQdFCo6FyQFdlz5gpZG8n2/MNeyedWIlAUjSwTh5Xhed4pn4a0DyliQ5zc1/QkxN9TvulbZ1wSfgW7XHd4pRHO+6riG3mVg7Swa3U4uwNyutSk6frxzuGS2mvZ5i9rHz1PFYRtw12YwXOSOxIwCQYXagmS5ZR0v8sBG4U3RabJ42wt+KeyDS8l9YkbWoDrzA= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 56da8785-f4a8-404e-36ea-08d8139b7e5f X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jun 2020 15:23:03.7031 (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: a0kaSwDaS1CQtSyHhzCWGZDXPeV1UCOcrnn+AWWXJZ+mkB1hKAfNiZKjTQs4w5b8cmy3wi5Z+KxhYlC7uA7KtA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB2573 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain 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: Laszlo Ersek Reviewed-by: Eric Dong --- 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.=0D #=0D # Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.
= =0D +# Copyright (c) 2020, AMD Inc. All rights reserved.
=0D # SPDX-License-Identifier: BSD-2-Clause-Patent=0D #=0D ##=0D @@ -29,6 +30,12 @@ [Sources.IA32] [Sources.X64]=0D X64/InitializeFpu.nasm=0D =0D +[Sources]=0D + BaseUefiCpuLib.c=0D +=0D [Packages]=0D MdePkg/MdePkg.dec=0D UefiCpuPkg/UefiCpuPkg.dec=0D +=0D +[LibraryClasses]=0D + BaseLib=0D 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.=0D #=0D # Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.
= =0D +# Copyright (c) 2020, AMD Inc. All rights reserved.
=0D # SPDX-License-Identifier: BSD-2-Clause-Patent=0D #=0D ##=0D @@ -37,6 +38,7 @@ [LibraryClasses] TimerLib=0D IoLib=0D PcdLib=0D + UefiCpuLib=0D =0D [Pcd]=0D gUefiCpuPkgTokenSpaceGuid.PcdCpuInitIpiDelayInMicroSeconds ## SOMETIMES= _CONSUMES=0D 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.=0D #=0D # Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.
= =0D +# Copyright (c) 2020, AMD Inc. All rights reserved.
=0D # SPDX-License-Identifier: BSD-2-Clause-Patent=0D #=0D ##=0D @@ -37,6 +38,7 @@ [LibraryClasses] TimerLib=0D IoLib=0D PcdLib=0D + UefiCpuLib=0D =0D [Pcd]=0D gUefiCpuPkgTokenSpaceGuid.PcdCpuInitIpiDelayInMicroSeconds ## SOMETIMES= _CONSUMES=0D 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.=0D =0D Copyright (c) 2009, Intel Corporation. All rights reserved.
=0D + Copyright (c) 2020, AMD Inc. All rights reserved.
=0D SPDX-License-Identifier: BSD-2-Clause-Patent=0D =0D **/=0D @@ -29,4 +30,17 @@ InitializeFloatingPointUnits ( VOID=0D );=0D =0D +/**=0D + Determine if the standard CPU signature is "AuthenticAMD".=0D +=0D + @retval TRUE The CPU signature matches.=0D + @retval FALSE The CPU signature does not match.=0D +=0D +**/=0D +BOOLEAN=0D +EFIAPI=0D +StandardSignatureIsAuthenticAMD (=0D + VOID=0D + );=0D +=0D #endif=0D 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=0D + This library defines some routines that are generic for IA32 family CPU.= =0D +=0D + The library routines are UEFI specification compliant.=0D +=0D + Copyright (c) 2020, AMD Inc. All rights reserved.
=0D + SPDX-License-Identifier: BSD-2-Clause-Patent=0D +=0D +**/=0D +=0D +#include =0D +#include =0D +=0D +#include =0D +#include =0D +=0D +/**=0D + Determine if the standard CPU signature is "AuthenticAMD".=0D +=0D + @retval TRUE The CPU signature matches.=0D + @retval FALSE The CPU signature does not match.=0D +=0D +**/=0D +BOOLEAN=0D +EFIAPI=0D +StandardSignatureIsAuthenticAMD (=0D + VOID=0D + )=0D +{=0D + UINT32 RegEbx;=0D + UINT32 RegEcx;=0D + UINT32 RegEdx;=0D +=0D + AsmCpuid (CPUID_SIGNATURE, NULL, &RegEbx, &RegEcx, &RegEdx);=0D + return (RegEbx =3D=3D CPUID_SIGNATURE_AUTHENTIC_AMD_EBX &&=0D + RegEcx =3D=3D CPUID_SIGNATURE_AUTHENTIC_AMD_ECX &&=0D + RegEdx =3D=3D CPUID_SIGNATURE_AUTHENTIC_AMD_EDX);=0D +}=0D 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.=0D =0D Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved.
=0D - Copyright (c) 2017, AMD Inc. All rights reserved.
=0D + Copyright (c) 2017 - 2020, AMD Inc. All rights reserved.
=0D =0D SPDX-License-Identifier: BSD-2-Clause-Patent=0D =0D @@ -21,33 +21,12 @@ #include =0D #include =0D #include =0D +#include =0D =0D //=0D // Library internal functions=0D //=0D =0D -/**=0D - Determine if the standard CPU signature is "AuthenticAMD".=0D -=0D - @retval TRUE The CPU signature matches.=0D - @retval FALSE The CPU signature does not match.=0D -=0D -**/=0D -BOOLEAN=0D -StandardSignatureIsAuthenticAMD (=0D - VOID=0D - )=0D -{=0D - UINT32 RegEbx;=0D - UINT32 RegEcx;=0D - UINT32 RegEdx;=0D -=0D - AsmCpuid (CPUID_SIGNATURE, NULL, &RegEbx, &RegEcx, &RegEdx);=0D - return (RegEbx =3D=3D CPUID_SIGNATURE_AUTHENTIC_AMD_EBX &&=0D - RegEcx =3D=3D CPUID_SIGNATURE_AUTHENTIC_AMD_ECX &&=0D - RegEdx =3D=3D CPUID_SIGNATURE_AUTHENTIC_AMD_EDX);=0D -}=0D -=0D /**=0D Determine if the CPU supports the Local APIC Base Address MSR.=0D =0D 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.=0D =0D Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved.
=0D - Copyright (c) 2017, AMD Inc. All rights reserved.
=0D + Copyright (c) 2017 - 2020, AMD Inc. All rights reserved.
=0D =0D SPDX-License-Identifier: BSD-2-Clause-Patent=0D =0D @@ -22,33 +22,12 @@ #include =0D #include =0D #include =0D +#include =0D =0D //=0D // Library internal functions=0D //=0D =0D -/**=0D - Determine if the standard CPU signature is "AuthenticAMD".=0D -=0D - @retval TRUE The CPU signature matches.=0D - @retval FALSE The CPU signature does not match.=0D -=0D -**/=0D -BOOLEAN=0D -StandardSignatureIsAuthenticAMD (=0D - VOID=0D - )=0D -{=0D - UINT32 RegEbx;=0D - UINT32 RegEcx;=0D - UINT32 RegEdx;=0D -=0D - AsmCpuid (CPUID_SIGNATURE, NULL, &RegEbx, &RegEcx, &RegEdx);=0D - return (RegEbx =3D=3D CPUID_SIGNATURE_AUTHENTIC_AMD_EBX &&=0D - RegEcx =3D=3D CPUID_SIGNATURE_AUTHENTIC_AMD_ECX &&=0D - RegEdx =3D=3D CPUID_SIGNATURE_AUTHENTIC_AMD_EDX);=0D -}=0D -=0D /**=0D Determine if the CPU supports the Local APIC Base Address MSR.=0D =0D 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;=0D =0D =0D -/**=0D - Determine if the standard CPU signature is "AuthenticAMD".=0D -=0D - @retval TRUE The CPU signature matches.=0D - @retval FALSE The CPU signature does not match.=0D -=0D -**/=0D -STATIC=0D -BOOLEAN=0D -StandardSignatureIsAuthenticAMD (=0D - VOID=0D - )=0D -{=0D - UINT32 RegEbx;=0D - UINT32 RegEcx;=0D - UINT32 RegEdx;=0D -=0D - AsmCpuid (CPUID_SIGNATURE, NULL, &RegEbx, &RegEcx, &RegEdx);=0D - return (RegEbx =3D=3D CPUID_SIGNATURE_AUTHENTIC_AMD_EBX &&=0D - RegEcx =3D=3D CPUID_SIGNATURE_AUTHENTIC_AMD_ECX &&=0D - RegEdx =3D=3D CPUID_SIGNATURE_AUTHENTIC_AMD_EDX);=0D -}=0D -=0D /**=0D The function will check if BSP Execute Disable is enabled.=0D =0D --=20 2.27.0