]> git.proxmox.com Git - mirror_edk2.git/commitdiff
UefiCpuPkg/MpInitLib: Remove redundant microcode fields in CPU_MP_DATA
authorHao A Wu <hao.a.wu@intel.com>
Tue, 24 Dec 2019 07:02:23 +0000 (15:02 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Thu, 2 Jan 2020 03:10:36 +0000 (03:10 +0000)
Previous commits have introduced below fields in structure CPU_AP_DATA:

  UINT32                         ProcessorSignature;
  UINT8                          PlatformId;
  UINT64                         MicrocodeEntryAddr;

which store the information of:

A. CPUID
B. Platform ID
C. Detected microcode patch entry address (including the microcode patch
   header)

for each processor within system.

Therefore, the below fields in structure CPU_MP_DATA:

  UINT32                         ProcessorSignature;
  UINT32                         ProcessorFlags;
  UINT64                         MicrocodeDataAddress;
  UINT32                         MicrocodeRevision;

which store the BSP's information of:

A. CPUID
B. Platform ID
C. The address and revision of detected microcode patch

are redundant and can be removed.

Cc: Eric Dong <eric.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Star Zeng <star.zeng@intel.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: Eric Dong <eric.dong@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
UefiCpuPkg/Library/MpInitLib/Microcode.c
UefiCpuPkg/Library/MpInitLib/MpLib.h

index 4162b4a8dcfe5d22cd2eed08b79fe420606abdb0..3da5bfb9cf2f9a4a4293a0967b80323e6480474c 100644 (file)
@@ -85,6 +85,7 @@ MicrocodeDetect (
   UINTN                                   Index;\r
   UINT8                                   PlatformId;\r
   CPUID_VERSION_INFO_EAX                  Eax;\r
+  CPU_AP_DATA                             *CpuData;\r
   UINT32                                  CurrentRevision;\r
   UINT32                                  LatestRevision;\r
   UINTN                                   TotalSize;\r
@@ -92,16 +93,9 @@ MicrocodeDetect (
   UINT32                                  InCompleteCheckSum32;\r
   BOOLEAN                                 CorrectMicrocode;\r
   VOID                                    *MicrocodeData;\r
-  MSR_IA32_PLATFORM_ID_REGISTER           PlatformIdMsr;\r
-  UINT32                                  ProcessorFlags;\r
   UINT32                                  ThreadId;\r
   BOOLEAN                                 IsBspCallIn;\r
 \r
-  //\r
-  // set ProcessorFlags to suppress incorrect compiler/analyzer warnings\r
-  //\r
-  ProcessorFlags = 0;\r
-\r
   if (CpuMpData->MicrocodePatchRegionSize == 0) {\r
     //\r
     // There is no microcode patches\r
@@ -127,28 +121,25 @@ MicrocodeDetect (
   }\r
 \r
   ExtendedTableLength = 0;\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
+  Eax.Uint32 = CpuMpData->CpuData[ProcessorNumber].ProcessorSignature;\r
+  PlatformId = CpuMpData->CpuData[ProcessorNumber].PlatformId;\r
 \r
   //\r
   // Check whether AP has same processor with BSP.\r
   // If yes, direct use microcode info saved by BSP.\r
   //\r
   if (!IsBspCallIn) {\r
-    if ((CpuMpData->ProcessorSignature == Eax.Uint32) &&\r
-        (CpuMpData->ProcessorFlags & (1 << PlatformId)) != 0) {\r
-        MicrocodeData = (VOID *)(UINTN) CpuMpData->MicrocodeDataAddress;\r
-        LatestRevision = CpuMpData->MicrocodeRevision;\r
-        goto Done;\r
+    //\r
+    // Get the CPU data for BSP\r
+    //\r
+    CpuData = &(CpuMpData->CpuData[CpuMpData->BspNumber]);\r
+    if ((CpuData->ProcessorSignature == Eax.Uint32) &&\r
+        (CpuData->PlatformId == PlatformId) &&\r
+        (CpuData->MicrocodeEntryAddr != 0)) {\r
+      MicrocodeEntryPoint = (CPU_MICROCODE_HEADER *)(UINTN) CpuData->MicrocodeEntryAddr;\r
+      MicrocodeData       = (VOID *) (MicrocodeEntryPoint + 1);\r
+      LatestRevision      = MicrocodeEntryPoint->UpdateRevision;\r
+      goto Done;\r
     }\r
   }\r
 \r
@@ -216,7 +207,6 @@ MicrocodeDetect (
         CheckSum32 += MicrocodeEntryPoint->Checksum;\r
         if (CheckSum32 == 0) {\r
           CorrectMicrocode = TRUE;\r
-          ProcessorFlags = MicrocodeEntryPoint->ProcessorFlags;\r
         }\r
       } else if ((MicrocodeEntryPoint->DataSize != 0) &&\r
                  (MicrocodeEntryPoint->UpdateRevision > LatestRevision)) {\r
@@ -260,7 +250,6 @@ MicrocodeDetect (
                     // Find one\r
                     //\r
                     CorrectMicrocode = TRUE;\r
-                    ProcessorFlags = ExtendedTable->ProcessorFlag;\r
                     break;\r
                   }\r
                 }\r
@@ -332,18 +321,6 @@ Done:
       ReleaseSpinLock(&CpuMpData->MpLock);\r
     }\r
   }\r
-\r
-  if (IsBspCallIn && (LatestRevision != 0)) {\r
-    //\r
-    // Save BSP processor info and microcode info for later AP use.\r
-    //\r
-    CpuMpData->ProcessorSignature   = Eax.Uint32;\r
-    CpuMpData->ProcessorFlags       = ProcessorFlags;\r
-    CpuMpData->MicrocodeDataAddress = (UINTN) MicrocodeData;\r
-    CpuMpData->MicrocodeRevision    = LatestRevision;\r
-    DEBUG ((DEBUG_INFO, "BSP Microcode:: signature [0x%08x], ProcessorFlags [0x%08x], \\r
-       MicroData [0x%08x], Revision [0x%08x]\n", Eax.Uint32, ProcessorFlags, (UINTN) MicrocodeData, LatestRevision));\r
-  }\r
 }\r
 \r
 /**\r
index 5f50e79744cb506bedb834b36b440d39b646feef..6609c958ce8a63b29f92f5656d58152cdf30babf 100644 (file)
@@ -263,11 +263,6 @@ struct _CPU_MP_DATA {
   BOOLEAN                        PeriodicMode;\r
   BOOLEAN                        TimerInterruptState;\r
 \r
-  UINT32                         ProcessorSignature;\r
-  UINT32                         ProcessorFlags;\r
-  UINT64                         MicrocodeDataAddress;\r
-  UINT32                         MicrocodeRevision;\r
-\r
   //\r
   // Whether need to use Init-Sipi-Sipi to wake up the APs.\r
   // Two cases need to set this value to TRUE. One is in HLT\r