From mboxrd@z Thu Jan 1 00:00:00 1970 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 Authentication-Results: mx.groups.io; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector2-amdcloud-onmicrosoft-com header.b=0TmsOZ4R; 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=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 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=YW1vbVytOJADWHRc6z90yztky286Y3P5HYAq+wqcXiU=; b=0TmsOZ4RZxkdHVFGWEKoSY9LNuailPns3moR7jsve2uFm0FG4NPKnrgjXpbPGORI6QeE4IGOX7Z2Ijo6KuCuW8uB7Fyzx5AcJiX0/JXrZRj5yBJk4re2ephhngIGUDfya01autHbnEUzdOVNt5cRIqmkQ5LRYkSj5m+lAupEQ0A= 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 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 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: [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> X-Mailer: git-send-email 2.27.0 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) 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 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-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: 16cb6403-e27c-45b3-4f25-08d8115a3b30 X-MS-TrafficTypeDiagnostic: SN1PR12MB2495: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-Forefront-PRVS: 04359FAD81 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5loBRaHXSOBSzCftdy38ZlbHlVT6jBp2/UyBH8XZh8Uhs9wy3DEEWIWC5NpgHPtGrfBBD1AFzYGCf5zn7eVKsc2bCpItyJRM7rFoalQ8Af9mZXWgV6UzbVhqxgWdvc+N+OjTv8XYZEdYCGU9ggYLpwpf9PmU/M7EwgA/QWu9rxGUVKpVg3Mb+7mSe4kPIIRw4riT4gkUgAM78ANqS7ZKQ1uOYIRpkEszWJ63WgzJowywOISEugZbdb4/vPy3864AnphHVwXSpaXWWIItKMVYKG7KTninMaZ7j3MJSQpY2pyA3tgZJcdNCB2/Xy/Hnz40olGkvsZIAjSf8Jq1w5Nfmw== 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)(39860400002)(396003)(136003)(346002)(376002)(366004)(36756003)(6916009)(478600001)(6666004)(4326008)(83380400001)(8676002)(316002)(8936002)(2616005)(956004)(54906003)(86362001)(66476007)(66556008)(66946007)(1076003)(6486002)(16526019)(7696005)(52116002)(26005)(5660300002)(2906002)(186003);DIR:OUT;SFP:1101; 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 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 --- 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