UefiCpuPkg/MpInitLib: Load uCode once for each core.
authorEric Dong <eric.dong@intel.com>
Thu, 12 Jul 2018 10:21:01 +0000 (18:21 +0800)
committerEric Dong <eric.dong@intel.com>
Wed, 18 Jul 2018 04:43:30 +0000 (12:43 +0800)
The SDM requires only one thread per core to load the
microcode.

This change enables this solution.

Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Eric Dong <eric.dong@intel.com>
Acked-by: Laszlo Ersek <lersek@redhat.com>
Regression-tested-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
UefiCpuPkg/Library/MpInitLib/Microcode.c

index 30ceaa4..efda143 100644 (file)
@@ -61,6 +61,7 @@ MicrocodeDetect (
   VOID                                    *MicrocodeData;\r
   MSR_IA32_PLATFORM_ID_REGISTER           PlatformIdMsr;\r
   UINT32                                  ProcessorFlags;\r
+  UINT32                                  ThreadId;\r
 \r
   if (CpuMpData->MicrocodePatchRegionSize == 0) {\r
     //\r
@@ -77,6 +78,14 @@ MicrocodeDetect (
     return;\r
   }\r
 \r
+  GetProcessorLocationByApicId (GetInitialApicId (), NULL, NULL, &ThreadId);\r
+  if (ThreadId != 0) {\r
+    //\r
+    // Skip loading microcode if it is not the first thread in one core.\r
+    //\r
+    return;\r
+  }\r
+\r
   ExtendedTableLength = 0;\r
   //\r
   // Here data of CPUID leafs have not been collected into context buffer, so\r