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,12 +627,12 @@ 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 // @@ -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