From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.120]) by mx.groups.io with SMTP id smtpd.web11.139.1592321385822570437 for ; Tue, 16 Jun 2020 08:29:46 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=HewFRz86; spf=pass (domain: redhat.com, ip: 205.139.110.120, mailfrom: lersek@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1592321385; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BZQlaZf7f+jn8qVGUL/NyROwapcdb7itHLFn/LxVdMg=; b=HewFRz86lxNdq3pXC2yRxC0decXoPwwC1UP2v2CR7n3b/6TpnKjfguocn1IQUGQljEdegV bzD/pHY0c8bsXOSZOm78SEFsTruplNDxdwao5d6gP9NTiotVyusujiDAHSV8de1VUUSXx9 WQc3bHYfM6R3B0kCmpopXNZg4vLkueQ= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-310-kthw1IJPNICPsfMXR_c_Ow-1; Tue, 16 Jun 2020 11:29:40 -0400 X-MC-Unique: kthw1IJPNICPsfMXR_c_Ow-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 734EC18FE860; Tue, 16 Jun 2020 15:29:39 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-113-248.ams2.redhat.com [10.36.113.248]) by smtp.corp.redhat.com (Postfix) with ESMTP id 00EC879303; Tue, 16 Jun 2020 15:29:37 +0000 (UTC) Subject: Re: [PATCH v1 1/2] UefiCpuPkg: Move StandardSignatureIsAuthenticAMD to BaseUefiCpuLib To: Garrett Kirkendall , devel@edk2.groups.io Cc: Eric Dong , Ray Ni References: <20200615183029.4577-1-Garrett.Kirkendall@amd.com> <20200615183029.4577-2-Garrett.Kirkendall@amd.com> From: "Laszlo Ersek" Message-ID: <1674e057-cf7a-ab14-2c84-c48f791fce4f@redhat.com> Date: Tue, 16 Jun 2020 17:29:37 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20200615183029.4577-2-Garrett.Kirkendall@amd.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit On 06/15/20 20:30, Garrett Kirkendall wrote: > 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/UefiCpuPkg/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 > > +[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 > > [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 > > [Pcd] > gUefiCpuPkgTokenSpaceGuid.PcdCpuInitIpiDelayInMicroSeconds ## SOMETIMES_CONSUMES > diff --git a/UefiCpuPkg/Include/Library/UefiCpuLib.h b/UefiCpuPkg/Include/Library/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. > > Copyright (c) 2009, Intel Corporation. All rights reserved.
> + Copyright (c) 2020, AMD Inc. All rights reserved.
> SPDX-License-Identifier: BSD-2-Clause-Patent > > **/ > @@ -29,4 +30,17 @@ InitializeFloatingPointUnits ( > VOID > ); > > +/** > + 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/UefiCpuPkg/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 == CPUID_SIGNATURE_AUTHENTIC_AMD_EBX && > + RegEcx == CPUID_SIGNATURE_AUTHENTIC_AMD_ECX && > + RegEdx == CPUID_SIGNATURE_AUTHENTIC_AMD_EDX); > +} > diff --git a/UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.c b/UefiCpuPkg/Library/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. > > 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.
> > SPDX-License-Identifier: BSD-2-Clause-Patent > > @@ -21,33 +21,12 @@ > #include > #include > #include > +#include > > // > // Library internal functions > // > > -/** > - 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 == CPUID_SIGNATURE_AUTHENTIC_AMD_EBX && > - RegEcx == CPUID_SIGNATURE_AUTHENTIC_AMD_ECX && > - RegEdx == CPUID_SIGNATURE_AUTHENTIC_AMD_EDX); > -} > - > /** > Determine if the CPU supports the Local APIC Base Address MSR. > > diff --git a/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.c b/UefiCpuPkg/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. > > 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.
> > SPDX-License-Identifier: BSD-2-Clause-Patent > > @@ -22,33 +22,12 @@ > #include > #include > #include > +#include > > // > // Library internal functions > // > > -/** > - 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 == CPUID_SIGNATURE_AUTHENTIC_AMD_EBX && > - RegEcx == CPUID_SIGNATURE_AUTHENTIC_AMD_ECX && > - RegEdx == CPUID_SIGNATURE_AUTHENTIC_AMD_EDX); > -} > - > /** > Determine if the CPU supports the Local APIC Base Address MSR. > > diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/MpInitLib/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 = CPU_INIT_MP_LIB_HOB_GUID; > > > -/** > - 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 == CPUID_SIGNATURE_AUTHENTIC_AMD_EBX && > - RegEcx == CPUID_SIGNATURE_AUTHENTIC_AMD_ECX && > - RegEdx == CPUID_SIGNATURE_AUTHENTIC_AMD_EDX); > -} > - > /** > The function will check if BSP Execute Disable is enabled. > > Reviewed-by: Laszlo Ersek