public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Ni, Ray" <ray.ni@intel.com>
To: "devel@edk2.groups.io" <devel@edk2.groups.io>,
	"Ni, Ray" <ray.ni@intel.com>, Leo Duran <leo.duran@amd.com>
Cc: "Dong, Eric" <eric.dong@intel.com>, Laszlo Ersek <lersek@redhat.com>
Subject: Re: [edk2-devel] [PATCH] UefiCpuPkg/MpInitLib: Skip reading PlatformId on AMD processors.
Date: Mon, 2 Mar 2020 04:21:47 +0000	[thread overview]
Message-ID: <734D49CCEBEEF84792F5B80ED585239D5C473F36@SHSMSX104.ccr.corp.intel.com> (raw)
In-Reply-To: <15F85A23C0D08039.4290@groups.io>

Reviewed-by: Ray Ni <ray.ni@intel.com>
I will add the "STATIC" when pushing.

> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Ni, Ray
> Sent: Monday, March 2, 2020 10:00 AM
> To: Leo Duran <leo.duran@amd.com>; devel@edk2.groups.io
> Cc: Dong, Eric <eric.dong@intel.com>; Laszlo Ersek <lersek@redhat.com>
> Subject: Re: [edk2-devel] [PATCH] UefiCpuPkg/MpInitLib: Skip reading
> PlatformId on AMD processors.
> 
> Leo,
> The function name is the same as another local function defined in
> LocalApicLib.
> You may need to add a STATIC keyword for this local function, or change it to
> a
> different name.
> 
> Thanks,
> Ray
> 
> > -----Original Message-----
> > From: Leo Duran <leo.duran@amd.com>
> > Sent: Saturday, February 29, 2020 11:06 PM
> > To: devel@edk2.groups.io
> > Cc: Leo Duran <leo.duran@amd.com>; Dong, Eric <eric.dong@intel.com>;
> Ni,
> > Ray <ray.ni@intel.com>; Laszlo Ersek <lersek@redhat.com>
> > Subject: [PATCH] UefiCpuPkg/MpInitLib: Skip reading PlatformId on AMD
> > processors.
> >
> > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2556
> >
> > This patch uses CPUID signature check to skip reading the PlatformId MSR,
> > which is not implemented on AMD processors.
> >
> > The PlatformId is used for loading microcode patches, which is also not
> > supported and AMD-based platforms. To mitigate the PlatformId
> > dependency,
> > PcdCpuMicrocodePatchAddress and PcdCpuMicrodePatchRegionSize must
> > be set
> > to 0 (default value), in order to bypass microcode loading code paths.
> >
> > Cc: Eric Dong <eric.dong@intel.com>
> > Cc: Ray Ni <ray.ni@intel.com>
> > Cc: Laszlo Ersek <lersek@redhat.com>
> > Signed-off-by: Leo Duran <leo.duran@amd.com>
> > ---
> >  UefiCpuPkg/Library/MpInitLib/MpLib.c | 34
> > ++++++++++++++++++++++++++++++++--
> >  UefiCpuPkg/Library/MpInitLib/MpLib.h |  3 +++
> >  2 files changed, 35 insertions(+), 2 deletions(-)
> >  mode change 100644 => 100755 UefiCpuPkg/Library/MpInitLib/MpLib.h
> >
> > diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c
> > b/UefiCpuPkg/Library/MpInitLib/MpLib.c
> > index d0fbc17..d2200c3 100644
> > --- a/UefiCpuPkg/Library/MpInitLib/MpLib.c
> > +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c
> > @@ -2,6 +2,8 @@
> >    CPU MP Initialize Library common functions.
> >
> >    Copyright (c) 2016 - 2020, Intel Corporation. All rights reserved.<BR>
> > +  Copyright (c) 2020, AMD Inc. All rights reserved.<BR>
> > +
> >    SPDX-License-Identifier: BSD-2-Clause-Patent
> >
> >  **/
> > @@ -10,6 +12,29 @@
> >
> >  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.
> > +
> > +**/
> > +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.
> >
> > @@ -564,8 +589,13 @@ InitializeApData (
> >    CpuMpData->CpuData[ProcessorNumber].Waiting    = FALSE;
> >    CpuMpData->CpuData[ProcessorNumber].CpuHealthy = (BistData == 0) ?
> > TRUE : FALSE;
> >
> > -  PlatformIdMsr.Uint64 = AsmReadMsr64 (MSR_IA32_PLATFORM_ID);
> > -  CpuMpData->CpuData[ProcessorNumber].PlatformId = (UINT8)
> > PlatformIdMsr.Bits.PlatformId;
> > +  //
> > +  // NOTE: PlatformId is not relevant on AMD platforms.
> > +  //
> > +  if (!StandardSignatureIsAuthenticAMD ()) {
> > +    PlatformIdMsr.Uint64 = AsmReadMsr64 (MSR_IA32_PLATFORM_ID);
> > +    CpuMpData->CpuData[ProcessorNumber].PlatformId =
> > (UINT8)PlatformIdMsr.Bits.PlatformId;
> > +  }
> >
> >    AsmCpuid (
> >      CPUID_VERSION_INFO,
> > diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.h
> > b/UefiCpuPkg/Library/MpInitLib/MpLib.h
> > old mode 100644
> > new mode 100755
> > index 455cb3f..0c89f8a
> > --- a/UefiCpuPkg/Library/MpInitLib/MpLib.h
> > +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.h
> > @@ -2,6 +2,8 @@
> >    Common header file for MP Initialize Library.
> >
> >    Copyright (c) 2016 - 2020, Intel Corporation. All rights reserved.<BR>
> > +  Copyright (c) 2020, AMD Inc. All rights reserved.<BR>
> > +
> >    SPDX-License-Identifier: BSD-2-Clause-Patent
> >
> >  **/
> > @@ -12,6 +14,7 @@
> >  #include <PiPei.h>
> >
> >  #include <Register/Intel/Cpuid.h>
> > +#include <Register/Amd/Cpuid.h>
> >  #include <Register/Intel/Msr.h>
> >  #include <Register/Intel/LocalApic.h>
> >  #include <Register/Intel/Microcode.h>
> > --
> > 2.7.4
> 
> 
> 


  parent reply	other threads:[~2020-03-02  4:21 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-29 15:05 [PATCH v4] UefiCpuPkg: Fix bug in MpInitLib Leo Duran
2020-02-29 15:05 ` [PATCH] UefiCpuPkg/MpInitLib: Skip reading PlatformId on AMD processors Leo Duran
2020-02-29 19:50   ` Laszlo Ersek
2020-03-02  1:59   ` Ni, Ray
     [not found]   ` <15F85A23C0D08039.4290@groups.io>
2020-03-02  4:21     ` Ni, Ray [this message]
2020-04-17  8:14   ` [edk2-devel] " Gary Lin
2020-04-20  9:41     ` Laszlo Ersek
2020-04-21 18:47       ` Duran, Leo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=734D49CCEBEEF84792F5B80ED585239D5C473F36@SHSMSX104.ccr.corp.intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox