]> git.proxmox.com Git - mirror_edk2.git/commitdiff
UefiCpuPkg/MpInitLib: Avoid call PcdGet* in Ap & Bsp.
authorEric Dong <eric.dong@intel.com>
Thu, 19 Oct 2017 02:40:16 +0000 (10:40 +0800)
committerEric Dong <eric.dong@intel.com>
Fri, 20 Oct 2017 02:30:46 +0000 (10:30 +0800)
MicrocodeDetect function will run by every threads, and it will
use PcdGet to get PcdCpuMicrocodePatchAddress and
PcdCpuMicrocodePatchRegionSize, if change both PCD default to dynamic,
system will in non-deterministic behavior.

By design, UEFI/PI services are single threaded and not re-entrant
so Multi processor code should not use UEFI/PI services. Here, Pcd
protocol/PPI is used to access dynamic PCDs so it would result in
non-deterministic behavior.

This code get PCD value in BSP and save them in CPU_MP_DATA for Ap.

https://bugzilla.tianocore.org/show_bug.cgi?id=726

Cc: Crystal Lee <CrystalLee@ami.com.tw>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
UefiCpuPkg/Library/MpInitLib/Microcode.c
UefiCpuPkg/Library/MpInitLib/MpLib.c
UefiCpuPkg/Library/MpInitLib/MpLib.h

index 982995be7d02ddcd1715424ef206827700817ef7..9d61da6c23c779c47ec50d750bf40a4907516a18 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Implementation of loading microcode on processors.\r
 \r
-  Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -42,8 +42,6 @@ MicrocodeDetect (
   IN CPU_MP_DATA             *CpuMpData\r
   )\r
 {\r
-  UINT64                                  MicrocodePatchAddress;\r
-  UINT64                                  MicrocodePatchRegionSize;\r
   UINT32                                  ExtendedTableLength;\r
   UINT32                                  ExtendedTableCount;\r
   CPU_MICROCODE_EXTENDED_TABLE            *ExtendedTable;\r
@@ -61,9 +59,7 @@ MicrocodeDetect (
   VOID                                    *MicrocodeData;\r
   MSR_IA32_PLATFORM_ID_REGISTER           PlatformIdMsr;\r
 \r
-  MicrocodePatchAddress    = PcdGet64 (PcdCpuMicrocodePatchAddress);\r
-  MicrocodePatchRegionSize = PcdGet64 (PcdCpuMicrocodePatchRegionSize);\r
-  if (MicrocodePatchRegionSize == 0) {\r
+  if (CpuMpData->MicrocodePatchRegionSize == 0) {\r
     //\r
     // There is no microcode patches\r
     //\r
@@ -93,8 +89,8 @@ MicrocodeDetect (
 \r
   LatestRevision = 0;\r
   MicrocodeData  = NULL;\r
-  MicrocodeEnd = (UINTN) (MicrocodePatchAddress + MicrocodePatchRegionSize);\r
-  MicrocodeEntryPoint = (CPU_MICROCODE_HEADER *) (UINTN) MicrocodePatchAddress;\r
+  MicrocodeEnd = (UINTN) (CpuMpData->MicrocodePatchAddress + CpuMpData->MicrocodePatchRegionSize);\r
+  MicrocodeEntryPoint = (CPU_MICROCODE_HEADER *) (UINTN) CpuMpData->MicrocodePatchAddress;\r
   do {\r
     //\r
     // Check if the microcode is for the Cpu and the version is newer\r
index 924b9097f28e9a2a17f3be1e89df304ebe6eb7ae..f3ee6d443614598f26d6f98c28f43c9bfba6867c 100644 (file)
@@ -1458,6 +1458,8 @@ MpInitLibInitialize (
   CpuMpData->SwitchBspFlag    = FALSE;\r
   CpuMpData->CpuData          = (CPU_AP_DATA *) (CpuMpData + 1);\r
   CpuMpData->CpuInfoInHob     = (UINT64) (UINTN) (CpuMpData->CpuData + MaxLogicalProcessorNumber);\r
+  CpuMpData->MicrocodePatchAddress    = PcdGet64 (PcdCpuMicrocodePatchAddress);\r
+  CpuMpData->MicrocodePatchRegionSize = PcdGet64 (PcdCpuMicrocodePatchRegionSize);\r
   InitializeSpinLock(&CpuMpData->MpLock);\r
   //\r
   // Save BSP's Control registers to APs\r
index 19defdaf4ba4f1567c0074701fec3210349cfc2d..84ae24f88d774537b930a5e54dcaa6e1decbdf67 100644 (file)
@@ -233,6 +233,8 @@ struct _CPU_MP_DATA {
   UINT8                          Vector;\r
   BOOLEAN                        PeriodicMode;\r
   BOOLEAN                        TimerInterruptState;\r
+  UINT64                         MicrocodePatchAddress;\r
+  UINT64                         MicrocodePatchRegionSize;\r
 };\r
 \r
 extern EFI_GUID mCpuInitMpLibHobGuid;\r