]> git.proxmox.com Git - mirror_edk2.git/commitdiff
UefiCpuPkg/MpInitLib: Always get CPUID & PlatformID in MicrocodeDetect()
authorHao A Wu <hao.a.wu@intel.com>
Wed, 22 Jan 2020 07:45:43 +0000 (15:45 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Thu, 6 Feb 2020 00:31:28 +0000 (00:31 +0000)
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=2498

Commit fd30b00707 updated the logic in function MicrocodeDetect() that
will directly use the CPUID and PlatformID information from the 'CpuData'
field in the CPU_MP_DATA structure, instead of collecting these
information for each processor via AsmCpuid() and AsmReadMsr64() calls
respectively.

At that moment, this approach worked fine for APs. Since:
a) When the APs are waken up for the 1st time (1st MpInitLibInitialize()
   entry at PEI phase), the function InitializeApData() will be called for
   each AP and the CPUID and PlatformID information will be collected.

b) During the 2nd entry of MpInitLibInitialize() at DXE phase, when the
   APs are waken up again, the function InitializeApData() will not be
   called, which means the CPUID and PlatformID information will not be
   collected. However, the below logics in MicrocodeDetect() function:

  CurrentRevision = GetCurrentMicrocodeSignature ();
  IsBspCallIn     = (ProcessorNumber == (UINTN)CpuMpData->BspNumber) ? TRUE : FALSE;
  if (CurrentRevision != 0 && !IsBspCallIn) {
    //
    // Skip loading microcode if it has been loaded successfully
    //
    return;
  }

   will ensure that the microcode detection and application will be
   skipped due to the fact that such process has already been done in the
   PEI phase.

But after commit 396e791059, which removes the above skip loading logic,
the CPUID and PlatformID information on APs will be used upon the 2nd
entry of the MpInitLibInitialize(). But since the CPUID and PlatformID
information has not been collected, it will bring issue to the microcode
detection process.

This commit will update the logic in MicrocodeDetect() back to always
collecting the CPUID and PlatformID information explicitly.

Cc: Eric Dong <eric.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Siyuan Fu <siyuan.fu@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Signed-off-by: Hao A Wu <hao.a.wu@intel.com>
Reviewed-by: Siyuan Fu <siyuan.fu@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
UefiCpuPkg/Library/MpInitLib/Microcode.c

index 9389e52ae519a1df30d16b5f30aa219cd6a29acb..247f835b09fc6ac792de1a8cafd3df05f0a06b92 100644 (file)
@@ -93,6 +93,7 @@ MicrocodeDetect (
   UINT32                                  InCompleteCheckSum32;\r
   BOOLEAN                                 CorrectMicrocode;\r
   VOID                                    *MicrocodeData;\r
+  MSR_IA32_PLATFORM_ID_REGISTER           PlatformIdMsr;\r
   UINT32                                  ThreadId;\r
   BOOLEAN                                 IsBspCallIn;\r
 \r
@@ -115,8 +116,18 @@ MicrocodeDetect (
   }\r
 \r
   ExtendedTableLength = 0;\r
-  Eax.Uint32 = CpuMpData->CpuData[ProcessorNumber].ProcessorSignature;\r
-  PlatformId = CpuMpData->CpuData[ProcessorNumber].PlatformId;\r
+  //\r
+  // Here data of CPUID leafs have not been collected into context buffer, so\r
+  // GetProcessorCpuid() cannot be used here to retrieve CPUID data.\r
+  //\r
+  AsmCpuid (CPUID_VERSION_INFO, &Eax.Uint32, NULL, NULL, NULL);\r
+\r
+  //\r
+  // The index of platform information resides in bits 50:52 of MSR IA32_PLATFORM_ID\r
+  //\r
+  PlatformIdMsr.Uint64 = AsmReadMsr64 (MSR_IA32_PLATFORM_ID);\r
+  PlatformId = (UINT8) PlatformIdMsr.Bits.PlatformId;\r
+\r
 \r
   //\r
   // Check whether AP has same processor with BSP.\r