summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiaxin Wu <jiaxin.wu@intel.com>2023-12-15 16:45:38 +0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2023-12-26 07:18:26 +0000
commit3a4ec6de01209a0310a6e4c63d6941e7a592a457 (patch)
treee2c0b26632a7e94d9fba7fc5c486e3bcabf69cfe
parente1b62f3e28a95847c6ab23ae3a07a640d7e300cf (diff)
downloadedk2-3a4ec6de01209a0310a6e4c63d6941e7a592a457.tar.gz
edk2-3a4ec6de01209a0310a6e4c63d6941e7a592a457.tar.bz2
edk2-3a4ec6de01209a0310a6e4c63d6941e7a592a457.zip
UefiCpuPkg/PiSmmCpuDxeSmm: Align BSP and AP sync logic for SMI exit
Below piece of code is the BSP and AP sync logic for SMI exit. 1. AP after finish the scheduled procedure: if (SmmCpuFeaturesNeedConfigureMtrrs ()) { SmmCpuSyncReleaseBsp (); SmmCpuSyncWaitForBsp (); ... } SmmCpuSyncReleaseBsp (); SmmCpuSyncWaitForBsp (); SmmCpuSyncReleaseBsp (); 2. BSP after return from SmmCoreEntry: SmmCpuSyncWaitForAPs (); if (SmmCpuFeaturesNeedConfigureMtrrs ()) { ReleaseAllAPs (); ... SmmCpuSyncWaitForAPs (); } ReleaseAllAPs (); SmmCpuSyncWaitForAPs(); This patch is to make BSP same as AP sync logic: if (SmmCpuFeaturesNeedConfigureMtrrs ()) { SmmCpuSyncWaitForAPs (); ReleaseAllAPs (); ... } SmmCpuSyncWaitForAPs (); ReleaseAllAPs (); SmmCpuSyncWaitForAPs(); With the change, it will be easy to understand the sync flow as below: BSP: SmmCpuSyncWaitForAPs <-- AP: SmmCpuSyncReleaseBsp BSP: ReleaseAllAPs --> AP: SmmCpuSyncWaitForBsp This patch doesn't have function impact. Cc: Laszlo Ersek <lersek@redhat.com> Cc: Eric Dong <eric.dong@intel.com> Cc: Ray Ni <ray.ni@intel.com> Cc: Zeng Star <star.zeng@intel.com> Cc: Gerd Hoffmann <kraxel@redhat.com> Cc: Rahul Kumar <rahul1.kumar@intel.com> Signed-off-by: Jiaxin Wu <jiaxin.wu@intel.com> Reviewed-by: Ray Ni <ray.ni@Intel.com>
-rw-r--r--UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
index 324e85d6b5..bd2c9f841b 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
@@ -627,13 +627,13 @@ BSPHandler (
*mSmmMpSyncData->InsideSmm = FALSE;
ReleaseAllAPs ();
- //
- // Wait for all APs to complete their pending tasks
- //
- SmmCpuSyncWaitForAPs (mSmmMpSyncData->SyncContext, ApCount, CpuIndex);
-
if (SmmCpuFeaturesNeedConfigureMtrrs ()) {
//
+ // Wait for all APs the readiness to program MTRRs
+ //
+ SmmCpuSyncWaitForAPs (mSmmMpSyncData->SyncContext, ApCount, CpuIndex);
+
+ //
// Signal APs to restore MTRRs
//
ReleaseAllAPs ();
@@ -643,13 +643,13 @@ BSPHandler (
//
SmmCpuFeaturesReenableSmrr ();
MtrrSetAllMtrrs (&Mtrrs);
-
- //
- // Wait for all APs to complete MTRR programming
- //
- SmmCpuSyncWaitForAPs (mSmmMpSyncData->SyncContext, ApCount, CpuIndex);
}
+ //
+ // Wait for all APs to complete their pending tasks including MTRR programming if needed.
+ //
+ SmmCpuSyncWaitForAPs (mSmmMpSyncData->SyncContext, ApCount, CpuIndex);
+
if (mSmmDebugAgentSupport) {
//
// Stop source level debug in BSP handler, the code below will not be