Skip to content

Commit 2351165

Browse files
jiaxinwumergify[bot]
authored andcommitted
UefiCpuPkg/PiSmmCpuDxeSmm: Clarification for BSP & APs Sync Flow
This patch does not impact functionality. It aims to clarify the synchronization flow between the BSP and APs to enhance code readability and understanding: Steps tianocore#6 and tianocore#11 are the basic synchronization requirements for all cases. Steps #1 is additional requirements if the MmCpuSyncModeTradition mode is selected. Steps #1, #2, #3, tianocore#4, tianocore#5, tianocore#7, tianocore#8, tianocore#9, and tianocore#10 are additional requirements if the system needs to configure the MTRR. Steps tianocore#9 and tianocore#10 are additional requirements if the system needs to support the mSmmDebugAgentSupport. Signed-off-by: Jiaxin Wu <[email protected]>
1 parent d2a41d1 commit 2351165

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c

+22-22
Original file line numberDiff line numberDiff line change
@@ -522,13 +522,13 @@ BSPHandler (
522522
//
523523
// Wait for all APs to get ready for programming MTRRs
524524
//
525-
SmmCpuSyncWaitForAPs (mSmmMpSyncData->SyncContext, ApCount, CpuIndex);
525+
SmmCpuSyncWaitForAPs (mSmmMpSyncData->SyncContext, ApCount, CpuIndex); /// #1: Wait APs
526526

527527
if (SmmCpuFeaturesNeedConfigureMtrrs ()) {
528528
//
529529
// Signal all APs it's time for backup MTRRs
530530
//
531-
ReleaseAllAPs ();
531+
ReleaseAllAPs (); /// #2: Signal APs
532532

533533
//
534534
// SmmCpuSyncWaitForAPs() may wait for ever if an AP happens to enter SMM at
@@ -543,12 +543,12 @@ BSPHandler (
543543
//
544544
// Wait for all APs to complete their MTRR saving
545545
//
546-
SmmCpuSyncWaitForAPs (mSmmMpSyncData->SyncContext, ApCount, CpuIndex);
546+
SmmCpuSyncWaitForAPs (mSmmMpSyncData->SyncContext, ApCount, CpuIndex); /// #3: Wait APs
547547

548548
//
549549
// Let all processors program SMM MTRRs together
550550
//
551-
ReleaseAllAPs ();
551+
ReleaseAllAPs (); /// #4: Signal APs
552552

553553
//
554554
// SmmCpuSyncWaitForAPs() may wait for ever if an AP happens to enter SMM at
@@ -560,7 +560,7 @@ BSPHandler (
560560
//
561561
// Wait for all APs to complete their MTRR programming
562562
//
563-
SmmCpuSyncWaitForAPs (mSmmMpSyncData->SyncContext, ApCount, CpuIndex);
563+
SmmCpuSyncWaitForAPs (mSmmMpSyncData->SyncContext, ApCount, CpuIndex); /// #5: Wait APs
564564
}
565565
}
566566

@@ -625,18 +625,18 @@ BSPHandler (
625625
// Notify all APs to exit
626626
//
627627
*mSmmMpSyncData->InsideSmm = FALSE;
628-
ReleaseAllAPs ();
628+
ReleaseAllAPs (); /// #6: Signal APs
629629

630630
if (SmmCpuFeaturesNeedConfigureMtrrs ()) {
631631
//
632632
// Wait for all APs the readiness to program MTRRs
633633
//
634-
SmmCpuSyncWaitForAPs (mSmmMpSyncData->SyncContext, ApCount, CpuIndex);
634+
SmmCpuSyncWaitForAPs (mSmmMpSyncData->SyncContext, ApCount, CpuIndex); /// #7: Wait APs
635635

636636
//
637637
// Signal APs to restore MTRRs
638638
//
639-
ReleaseAllAPs ();
639+
ReleaseAllAPs (); /// #8: Signal APs
640640

641641
//
642642
// Restore OS MTRRs
@@ -649,12 +649,12 @@ BSPHandler (
649649
//
650650
// Wait for all APs to complete their pending tasks including MTRR programming if needed.
651651
//
652-
SmmCpuSyncWaitForAPs (mSmmMpSyncData->SyncContext, ApCount, CpuIndex);
652+
SmmCpuSyncWaitForAPs (mSmmMpSyncData->SyncContext, ApCount, CpuIndex); /// #9: Wait APs
653653

654654
//
655655
// Signal APs to Reset states/semaphore for this processor
656656
//
657-
ReleaseAllAPs ();
657+
ReleaseAllAPs (); /// #10: Signal APs
658658
}
659659

660660
if (mSmmDebugAgentSupport) {
@@ -679,7 +679,7 @@ BSPHandler (
679679
// Gather APs to exit SMM synchronously. Note the Present flag is cleared by now but
680680
// WaitForAllAps does not depend on the Present flag.
681681
//
682-
SmmCpuSyncWaitForAPs (mSmmMpSyncData->SyncContext, ApCount, CpuIndex);
682+
SmmCpuSyncWaitForAPs (mSmmMpSyncData->SyncContext, ApCount, CpuIndex); /// #11: Wait APs
683683

684684
//
685685
// At this point, all APs should have exited from APHandler().
@@ -805,14 +805,14 @@ APHandler (
805805
//
806806
// Notify BSP of arrival at this point
807807
//
808-
SmmCpuSyncReleaseBsp (mSmmMpSyncData->SyncContext, CpuIndex, BspIndex);
808+
SmmCpuSyncReleaseBsp (mSmmMpSyncData->SyncContext, CpuIndex, BspIndex); /// #1: Signal BSP
809809
}
810810

811811
if (SmmCpuFeaturesNeedConfigureMtrrs ()) {
812812
//
813813
// Wait for the signal from BSP to backup MTRRs
814814
//
815-
SmmCpuSyncWaitForBsp (mSmmMpSyncData->SyncContext, CpuIndex, BspIndex);
815+
SmmCpuSyncWaitForBsp (mSmmMpSyncData->SyncContext, CpuIndex, BspIndex); /// #2: Wait BSP
816816

817817
//
818818
// Backup OS MTRRs
@@ -822,12 +822,12 @@ APHandler (
822822
//
823823
// Signal BSP the completion of this AP
824824
//
825-
SmmCpuSyncReleaseBsp (mSmmMpSyncData->SyncContext, CpuIndex, BspIndex);
825+
SmmCpuSyncReleaseBsp (mSmmMpSyncData->SyncContext, CpuIndex, BspIndex); /// #3: Signal BSP
826826

827827
//
828828
// Wait for BSP's signal to program MTRRs
829829
//
830-
SmmCpuSyncWaitForBsp (mSmmMpSyncData->SyncContext, CpuIndex, BspIndex);
830+
SmmCpuSyncWaitForBsp (mSmmMpSyncData->SyncContext, CpuIndex, BspIndex); /// #4: Wait BSP
831831

832832
//
833833
// Replace OS MTRRs with SMI MTRRs
@@ -837,14 +837,14 @@ APHandler (
837837
//
838838
// Signal BSP the completion of this AP
839839
//
840-
SmmCpuSyncReleaseBsp (mSmmMpSyncData->SyncContext, CpuIndex, BspIndex);
840+
SmmCpuSyncReleaseBsp (mSmmMpSyncData->SyncContext, CpuIndex, BspIndex); /// #5: Signal BSP
841841
}
842842

843843
while (TRUE) {
844844
//
845845
// Wait for something to happen
846846
//
847-
SmmCpuSyncWaitForBsp (mSmmMpSyncData->SyncContext, CpuIndex, BspIndex);
847+
SmmCpuSyncWaitForBsp (mSmmMpSyncData->SyncContext, CpuIndex, BspIndex); /// #6: Wait BSP
848848

849849
//
850850
// Check if BSP wants to exit SMM
@@ -884,12 +884,12 @@ APHandler (
884884
//
885885
// Notify BSP the readiness of this AP to program MTRRs
886886
//
887-
SmmCpuSyncReleaseBsp (mSmmMpSyncData->SyncContext, CpuIndex, BspIndex);
887+
SmmCpuSyncReleaseBsp (mSmmMpSyncData->SyncContext, CpuIndex, BspIndex); /// #7: Signal BSP
888888

889889
//
890890
// Wait for the signal from BSP to program MTRRs
891891
//
892-
SmmCpuSyncWaitForBsp (mSmmMpSyncData->SyncContext, CpuIndex, BspIndex);
892+
SmmCpuSyncWaitForBsp (mSmmMpSyncData->SyncContext, CpuIndex, BspIndex); /// #8: Wait BSP
893893

894894
//
895895
// Restore OS MTRRs
@@ -902,12 +902,12 @@ APHandler (
902902
//
903903
// Notify BSP the readiness of this AP to Reset states/semaphore for this processor
904904
//
905-
SmmCpuSyncReleaseBsp (mSmmMpSyncData->SyncContext, CpuIndex, BspIndex);
905+
SmmCpuSyncReleaseBsp (mSmmMpSyncData->SyncContext, CpuIndex, BspIndex); /// #9: Signal BSP
906906

907907
//
908908
// Wait for the signal from BSP to Reset states/semaphore for this processor
909909
//
910-
SmmCpuSyncWaitForBsp (mSmmMpSyncData->SyncContext, CpuIndex, BspIndex);
910+
SmmCpuSyncWaitForBsp (mSmmMpSyncData->SyncContext, CpuIndex, BspIndex); /// #10: Wait BSP
911911
}
912912

913913
//
@@ -918,7 +918,7 @@ APHandler (
918918
//
919919
// Notify BSP the readiness of this AP to exit SMM
920920
//
921-
SmmCpuSyncReleaseBsp (mSmmMpSyncData->SyncContext, CpuIndex, BspIndex);
921+
SmmCpuSyncReleaseBsp (mSmmMpSyncData->SyncContext, CpuIndex, BspIndex); /// #11: Signal BSP
922922
}
923923

924924
/**

0 commit comments

Comments
 (0)