]> git.proxmox.com Git - mirror_edk2.git/commitdiff
UefiCpuPkg/MpInitLib: Skip reading PlatformId on AMD processors. edk2-stable202002
authorLeo Duran <leo.duran@amd.com>
Sat, 29 Feb 2020 15:05:45 +0000 (23:05 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Mon, 2 Mar 2020 05:47:06 +0000 (05:47 +0000)
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>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
UefiCpuPkg/Library/MpInitLib/MpLib.c
UefiCpuPkg/Library/MpInitLib/MpLib.h [changed mode: 0644->0755]

index d0fbc17ce5516ae0ab07bde8460fa07f185b8426..64a4c3546e22f254b463a2b4ee279b6e118aba64 100644 (file)
@@ -2,6 +2,8 @@
   CPU MP Initialize Library common functions.\r
 \r
   Copyright (c) 2016 - 2020, Intel Corporation. All rights reserved.<BR>\r
   CPU MP Initialize Library common functions.\r
 \r
   Copyright (c) 2016 - 2020, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2020, AMD Inc. All rights reserved.<BR>\r
+\r
   SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
   SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
 EFI_GUID mCpuInitMpLibHobGuid = CPU_INIT_MP_LIB_HOB_GUID;\r
 \r
 \r
 EFI_GUID mCpuInitMpLibHobGuid = CPU_INIT_MP_LIB_HOB_GUID;\r
 \r
+\r
+/**\r
+  Determine if the standard CPU signature is "AuthenticAMD".\r
+\r
+  @retval TRUE  The CPU signature matches.\r
+  @retval FALSE The CPU signature does not match.\r
+\r
+**/\r
+STATIC\r
+BOOLEAN\r
+StandardSignatureIsAuthenticAMD (\r
+  VOID\r
+  )\r
+{\r
+  UINT32  RegEbx;\r
+  UINT32  RegEcx;\r
+  UINT32  RegEdx;\r
+\r
+  AsmCpuid (CPUID_SIGNATURE, NULL, &RegEbx, &RegEcx, &RegEdx);\r
+  return (RegEbx == CPUID_SIGNATURE_AUTHENTIC_AMD_EBX &&\r
+          RegEcx == CPUID_SIGNATURE_AUTHENTIC_AMD_ECX &&\r
+          RegEdx == CPUID_SIGNATURE_AUTHENTIC_AMD_EDX);\r
+}\r
+\r
 /**\r
   The function will check if BSP Execute Disable is enabled.\r
 \r
 /**\r
   The function will check if BSP Execute Disable is enabled.\r
 \r
@@ -564,8 +590,13 @@ InitializeApData (
   CpuMpData->CpuData[ProcessorNumber].Waiting    = FALSE;\r
   CpuMpData->CpuData[ProcessorNumber].CpuHealthy = (BistData == 0) ? TRUE : FALSE;\r
 \r
   CpuMpData->CpuData[ProcessorNumber].Waiting    = FALSE;\r
   CpuMpData->CpuData[ProcessorNumber].CpuHealthy = (BistData == 0) ? TRUE : FALSE;\r
 \r
-  PlatformIdMsr.Uint64 = AsmReadMsr64 (MSR_IA32_PLATFORM_ID);\r
-  CpuMpData->CpuData[ProcessorNumber].PlatformId = (UINT8) PlatformIdMsr.Bits.PlatformId;\r
+  //\r
+  // NOTE: PlatformId is not relevant on AMD platforms.\r
+  //\r
+  if (!StandardSignatureIsAuthenticAMD ()) {\r
+    PlatformIdMsr.Uint64 = AsmReadMsr64 (MSR_IA32_PLATFORM_ID);\r
+    CpuMpData->CpuData[ProcessorNumber].PlatformId = (UINT8)PlatformIdMsr.Bits.PlatformId;\r
+  }\r
 \r
   AsmCpuid (\r
     CPUID_VERSION_INFO,\r
 \r
   AsmCpuid (\r
     CPUID_VERSION_INFO,\r
old mode 100644 (file)
new mode 100755 (executable)
index 455cb3f..0c89f8a
@@ -2,6 +2,8 @@
   Common header file for MP Initialize Library.\r
 \r
   Copyright (c) 2016 - 2020, Intel Corporation. All rights reserved.<BR>\r
   Common header file for MP Initialize Library.\r
 \r
   Copyright (c) 2016 - 2020, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2020, AMD Inc. All rights reserved.<BR>\r
+\r
   SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
   SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
@@ -12,6 +14,7 @@
 #include <PiPei.h>\r
 \r
 #include <Register/Intel/Cpuid.h>\r
 #include <PiPei.h>\r
 \r
 #include <Register/Intel/Cpuid.h>\r
+#include <Register/Amd/Cpuid.h>\r
 #include <Register/Intel/Msr.h>\r
 #include <Register/Intel/LocalApic.h>\r
 #include <Register/Intel/Microcode.h>\r
 #include <Register/Intel/Msr.h>\r
 #include <Register/Intel/LocalApic.h>\r
 #include <Register/Intel/Microcode.h>\r