Initialize IsBsp early to ensure that this variable reflects the BSP
status correctly.
Also replace this check:
if (mSmmMpSyncData->BspIndex == (UINT32)CpuIndex)
with:
if (IsBsp)
Note that there's a window of time when these two diverge, when the BSP,
at exit from BSPHandler(), resets mSmmMpSyncData->BspIndex.
Cc: Eric Dong <eric.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Cc: Igor Mammedov <imammedo@redhat.com>
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: Aaron Young <aaron.young@oracle.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3132
Signed-off-by: Ankur Arora <ankur.a.arora@oracle.com>
---
UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
index 4bcd217917d7..e7ea44eb86fc 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
@@ -1565,7 +1565,12 @@ SmiRendezvous (
{
EFI_STATUS Status;
BOOLEAN ValidSmi;
- BOOLEAN IsBsp;
+
+ //
+ // IsBsp starts out as false. Once a CPU gets elected as BSP,
+ // it will transition its value to true.
+ //
+ BOOLEAN IsBsp = FALSE;
BOOLEAN BspInProgress;
UINTN Index;
UINTN Cr2;
@@ -1656,7 +1661,6 @@ SmiRendezvous (
//
// Elect BSP
//
- IsBsp = FALSE;
if (FeaturePcdGet (PcdCpuSmmEnableBspElection)) {
if (!mSmmMpSyncData->SwitchBsp || mSmmMpSyncData->CandidateBsp[CpuIndex]) {
//
@@ -1679,6 +1683,8 @@ SmiRendezvous (
(UINT32)-1,
(UINT32)CpuIndex
);
+
+ IsBsp = mSmmMpSyncData->BspIndex == (UINT32)CpuIndex;
}
}
}
@@ -1686,7 +1692,7 @@ SmiRendezvous (
//
// "mSmmMpSyncData->BspIndex == CpuIndex" means this is the BSP
//
- if (mSmmMpSyncData->BspIndex == CpuIndex) {
+ if (IsBsp) {
//
// Clear last request for SwitchBsp.
--
2.9.3
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#69973): https://edk2.groups.io/g/devel/message/69973
Mute This Topic: https://groups.io/mt/79507540/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-