[edk2-devel] [PATCH 1/3] UefiCpuPkg: Remove the duplicate loading of microcode in DXE stage
Yuanhao Xie
yuanhao.xie at intel.com
Thu Nov 3 05:37:45 UTC 2022
From: Yuanhao <yuanhao.xie at intel.com>
If both in the DXE and PEI phase Mp initialization is excuted, the
microcode loading during Mp initialization of the DXE stage can be
removed regardless of the bit modes.
Signed-off-by: Yuanhao Xie <yuanhao.xie at intel.com>
Cc: Eric Dong <eric.dong at intel.com>
Cc: Ray Ni <ray.ni at intel.com>
Cc: Rahul Kumar <rahul1.kumar at intel.com>
---
UefiCpuPkg/Library/MpInitLib/MpLib.c | 58 +++++++++++++++++++++++++++++++++++++++++-----------------
1 file changed, 41 insertions(+), 17 deletions(-)
diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/MpInitLib/MpLib.c
index 1c053f87a4..5430688946 100644
--- a/UefiCpuPkg/Library/MpInitLib/MpLib.c
+++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c
@@ -432,6 +432,27 @@ ApFuncEnableX2Apic (
SetApicMode (LOCAL_APIC_MODE_X2APIC);
}
+/**
+ Sync BSP's MTRR table to AP during waking upAp
+
+ @param[in, out] Buffer Pointer to private data buffer.
+**/
+VOID
+EFIAPI
+ApMtrrSync (
+ IN OUT VOID *Buffer
+ )
+{
+ CPU_MP_DATA *CpuMpData;
+
+ CpuMpData = (CPU_MP_DATA *)Buffer;
+
+ //
+ // Sync BSP's MTRR table to AP
+ //
+ MtrrSetAllMtrrs (&CpuMpData->MtrrTable);
+}
+
/**
Do sync on APs.
@@ -1977,6 +1998,23 @@ MpInitLibInitialize (
//
CollectProcessorCount (CpuMpData);
}
+
+ if (!GetMicrocodePatchInfoFromHob (
+ &CpuMpData->MicrocodePatchAddress,
+ &CpuMpData->MicrocodePatchRegionSize
+ ))
+ {
+ //
+ // The microcode patch information cache HOB does not exist, which means
+ // the microcode patches data has not been loaded into memory yet
+ //
+ ShadowMicrocodeUpdatePatch (CpuMpData);
+ }
+
+ //
+ // Detect and apply Microcode on BSP
+ //
+ MicrocodeDetect (CpuMpData, CpuMpData->BspNumber);
} else {
//
// APs have been wakeup before, just get the CPU Information
@@ -1994,22 +2032,6 @@ MpInitLibInitialize (
}
}
- if (!GetMicrocodePatchInfoFromHob (
- &CpuMpData->MicrocodePatchAddress,
- &CpuMpData->MicrocodePatchRegionSize
- ))
- {
- //
- // The microcode patch information cache HOB does not exist, which means
- // the microcode patches data has not been loaded into memory yet
- //
- ShadowMicrocodeUpdatePatch (CpuMpData);
- }
-
- //
- // Detect and apply Microcode on BSP
- //
- MicrocodeDetect (CpuMpData, CpuMpData->BspNumber);
//
// Store BSP's MTRR setting
//
@@ -2026,9 +2048,11 @@ MpInitLibInitialize (
// in DXE.
//
CpuMpData->InitFlag = ApInitReconfig;
+ WakeUpAP (CpuMpData, TRUE, 0, ApMtrrSync, CpuMpData, TRUE);
+ } else {
+ WakeUpAP (CpuMpData, TRUE, 0, ApInitializeSync, CpuMpData, TRUE);
}
- WakeUpAP (CpuMpData, TRUE, 0, ApInitializeSync, CpuMpData, TRUE);
//
// Wait for all APs finished initialization
//
--
2.36.1.windows.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#95883): https://edk2.groups.io/g/devel/message/95883
Mute This Topic: https://groups.io/mt/94751256/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-
More information about the edk2-devel-archive
mailing list