]> git.proxmox.com Git - mirror_edk2.git/blobdiff - UefiCpuPkg/Library/MpInitLib/Microcode.c
UefiCpuPkg/MpInitLib: Produce EDKII microcode patch HOB
[mirror_edk2.git] / UefiCpuPkg / Library / MpInitLib / Microcode.c
index 330fd99623347ef172542b9bceaa708cd29ef424..4162b4a8dcfe5d22cd2eed08b79fe420606abdb0 100644 (file)
@@ -65,13 +65,15 @@ GetCurrentMicrocodeSignature (
          It does not guarantee that the data has not been modified.\r
          CPU has its own mechanism to verify Microcode Binary part.\r
 \r
          It does not guarantee that the data has not been modified.\r
          CPU has its own mechanism to verify Microcode Binary part.\r
 \r
-  @param[in]  CpuMpData    The pointer to CPU MP Data structure.\r
-  @param[in]  IsBspCallIn  Indicate whether the caller is BSP or not.\r
+  @param[in]  CpuMpData        The pointer to CPU MP Data structure.\r
+  @param[in]  ProcessorNumber  The handle number of the processor. The range is\r
+                               from 0 to the total number of logical processors\r
+                               minus 1.\r
 **/\r
 VOID\r
 MicrocodeDetect (\r
   IN CPU_MP_DATA             *CpuMpData,\r
 **/\r
 VOID\r
 MicrocodeDetect (\r
   IN CPU_MP_DATA             *CpuMpData,\r
-  IN BOOLEAN                 IsBspCallIn\r
+  IN UINTN                   ProcessorNumber\r
   )\r
 {\r
   UINT32                                  ExtendedTableLength;\r
   )\r
 {\r
   UINT32                                  ExtendedTableLength;\r
@@ -93,6 +95,7 @@ MicrocodeDetect (
   MSR_IA32_PLATFORM_ID_REGISTER           PlatformIdMsr;\r
   UINT32                                  ProcessorFlags;\r
   UINT32                                  ThreadId;\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
   //\r
   // set ProcessorFlags to suppress incorrect compiler/analyzer warnings\r
@@ -107,6 +110,7 @@ MicrocodeDetect (
   }\r
 \r
   CurrentRevision = GetCurrentMicrocodeSignature ();\r
   }\r
 \r
   CurrentRevision = GetCurrentMicrocodeSignature ();\r
+  IsBspCallIn     = (ProcessorNumber == (UINTN)CpuMpData->BspNumber) ? TRUE : FALSE;\r
   if (CurrentRevision != 0 && !IsBspCallIn) {\r
     //\r
     // Skip loading microcode if it has been loaded successfully\r
   if (CurrentRevision != 0 && !IsBspCallIn) {\r
     //\r
     // Skip loading microcode if it has been loaded successfully\r
@@ -295,6 +299,16 @@ MicrocodeDetect (
   } while (((UINTN) MicrocodeEntryPoint < MicrocodeEnd));\r
 \r
 Done:\r
   } while (((UINTN) MicrocodeEntryPoint < MicrocodeEnd));\r
 \r
 Done:\r
+  if (LatestRevision != 0) {\r
+    //\r
+    // Save the detected microcode patch entry address (including the\r
+    // microcode patch header) for each processor.\r
+    // It will be used when building the microcode patch cache HOB.\r
+    //\r
+    CpuMpData->CpuData[ProcessorNumber].MicrocodeEntryAddr =\r
+      (UINTN) MicrocodeData -  sizeof (CPU_MICROCODE_HEADER);\r
+  }\r
+\r
   if (LatestRevision > CurrentRevision) {\r
     //\r
     // BIOS only authenticate updates that contain a numerically larger revision\r
   if (LatestRevision > CurrentRevision) {\r
     //\r
     // BIOS only authenticate updates that contain a numerically larger revision\r