public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Leo Duran <leo.duran@amd.com>
To: devel@edk2.groups.io
Cc: Leo Duran <leo.duran@amd.com>, Eric Dong <eric.dong@intel.com>,
	Ray Ni <ray.ni@intel.com>, Laszlo Ersek <lersek@redhat.com>
Subject: [PATCH 2/2] UefiCpuPkg: MpInitLib: Exclude code no pertinent to AMD processors.
Date: Tue, 25 Feb 2020 13:39:26 -0600	[thread overview]
Message-ID: <1582659566-9893-3-git-send-email-leo.duran@amd.com> (raw)
In-Reply-To: <1582659566-9893-1-git-send-email-leo.duran@amd.com>

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2556

This patch uses the newly exported StandardSignatureIsAuthenticAMD function
from LocalApicLib, to divert code paths not pertinent to AMD processors.
Specifically, the PlatformId MSR and embedded Microcode patches are not
relevant on AMD-based platforms.

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/Microcode.c | 17 +++++++++++++++--
 UefiCpuPkg/Library/MpInitLib/MpLib.c     | 11 +++++++++--
 2 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/UefiCpuPkg/Library/MpInitLib/Microcode.c b/UefiCpuPkg/Library/MpInitLib/Microcode.c
index 1562959..750681d 100644
--- a/UefiCpuPkg/Library/MpInitLib/Microcode.c
+++ b/UefiCpuPkg/Library/MpInitLib/Microcode.c
@@ -2,6 +2,8 @@
   Implementation of loading microcode on processors.
 
   Copyright (c) 2015 - 2020, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2020, AMD Inc. All rights reserved.<BR>
+
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -97,9 +99,13 @@ MicrocodeDetect (
   UINT32                                  ThreadId;
   BOOLEAN                                 IsBspCallIn;
 
-  if (CpuMpData->MicrocodePatchRegionSize == 0) {
+  //
+  // NOTE: Embedded Microcode patches are not relevant on AMD platforms.
+  //
+  if (CpuMpData->MicrocodePatchRegionSize == 0 ||
+      StandardSignatureIsAuthenticAMD ()) {
     //
-    // There is no microcode patches
+    // There are no microcode patches
     //
     return;
   }
@@ -350,6 +356,13 @@ IsProcessorMatchedMicrocodePatch (
   UINTN          Index;
   CPU_AP_DATA    *CpuData;
 
+  //
+  // NOTE: PlatformId or embedded Microcode patches are not relevant on AMD platforms.
+  //
+  if (StandardSignatureIsAuthenticAMD ()) {
+    return FALSE;
+  }
+
   for (Index = 0; Index < CpuMpData->CpuCount; Index++) {
     CpuData = &CpuMpData->CpuData[Index];
     if ((ProcessorSignature == CpuData->ProcessorSignature) &&
diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/MpInitLib/MpLib.c
index d0fbc17..290e7bf 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
 
 **/
@@ -564,8 +566,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,
-- 
2.7.4


  parent reply	other threads:[~2020-02-25 19:40 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-25 19:39 [PATCH 0/2] UefiCpuPkg/Library: Fix bug in MpInitLib Leo Duran
2020-02-25 19:39 ` [PATCH 1/2] UefiCpuPkg: LocalApicLib: Export StandardSignatureIsAuthenticAMD function Leo Duran
2020-02-26  1:13   ` Dong, Eric
2020-02-26  2:41     ` Duran, Leo
2020-02-26  5:05       ` Dong, Eric
2020-02-26 10:13         ` [edk2-devel] " Laszlo Ersek
2020-02-26 15:03           ` Duran, Leo
2020-02-26 16:19             ` Laszlo Ersek
2020-02-26 15:59         ` Duran, Leo
2020-02-25 19:39 ` Leo Duran [this message]
2020-02-26  7:45   ` [PATCH 2/2] UefiCpuPkg: MpInitLib: Exclude code no pertinent to AMD processors Ni, Ray
2020-02-26  7:56     ` Siyuan, Fu
2020-02-26  0:54 ` [edk2-devel] [PATCH 0/2] UefiCpuPkg/Library: Fix bug in MpInitLib Laszlo Ersek
2020-02-26  7:57   ` Ni, Ray
2020-02-26  8:56     ` Liming Gao
2020-02-26 15:11       ` Duran, Leo
2020-02-26 16:24         ` Laszlo Ersek
2020-02-26 16:35           ` Duran, Leo
2020-02-26 15:25     ` Duran, Leo
2020-02-26 15:46       ` Duran, Leo
2020-02-26 16:20         ` Laszlo Ersek
2020-02-26 16:39           ` Duran, Leo
2020-02-26 16:46             ` Duran, Leo
2020-02-26 17:45             ` Laszlo Ersek
2020-02-26 17:51               ` Duran, Leo
2020-02-27  5:55                 ` Ni, Ray
2020-02-27 18:17                   ` Duran, Leo
2020-02-28  6:47                     ` Ni, Ray
2020-02-28 16:38                       ` 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=1582659566-9893-3-git-send-email-leo.duran@amd.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