From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from aserp2120.oracle.com (aserp2120.oracle.com [141.146.126.78]) by mx.groups.io with SMTP id smtpd.web11.2142.1610049331141846464 for ; Thu, 07 Jan 2021 11:55:31 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=gEbHbdcL; spf=pass (domain: oracle.com, ip: 141.146.126.78, mailfrom: ankur.a.arora@oracle.com) Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 107JtUhX013659; Thu, 7 Jan 2021 19:55:30 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2020-01-29; bh=gijpHcUNlhFrTzLprEiH0hU+xpUrDvx2pVL7Fn5M7gQ=; b=gEbHbdcLdAJednTHMeNtTQOpp0sJga48su6s9a5gLBFJUkDF8aHo83zrJ7ntLCCEOjiV ceCwD9OLmc5GXVpJL0dXRUGdGckVpHrfGJHjwvk8Kl5z4LpLlMU3ThjOcmI3LQBfP7Xt DeqFcMxRYLqTJyGt530zAJr6wb59MweocS3GouG8UUabhbxyneDRDGVYgAcSJBDhMqIR ffjKH79cOc3pkKJUkLrNMLvR+VDd6CinoyNg4P92yIRICiYR1EGO92RSneXrxme6I3Pe s98s5M1PZZx2hr3ja2T12iwXf9uxvs/RRitHwNG8AttQgjaoEhvd3U/avWJi51IJoH6E /Q== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2120.oracle.com with ESMTP id 35wepme2js-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 07 Jan 2021 19:55:30 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 107JaWWq023991; Thu, 7 Jan 2021 19:55:30 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3030.oracle.com with ESMTP id 35v4ree7ru-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Jan 2021 19:55:30 +0000 Received: from abhmp0002.oracle.com (abhmp0002.oracle.com [141.146.116.8]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 107JtSrd021829; Thu, 7 Jan 2021 19:55:28 GMT Received: from localhost.localdomain (/70.36.60.91) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 07 Jan 2021 11:55:28 -0800 From: "Ankur Arora" To: devel@edk2.groups.io Cc: lersek@redhat.com, imammedo@redhat.com, boris.ostrovsky@oracle.com, Ankur Arora , Eric Dong , Ray Ni , Rahul Kumar , Aaron Young Subject: [PATCH v2 06/10] UefiCpuPkg/PiSmmCpuDxeSmm: initialize IsBsp Date: Thu, 7 Jan 2021 11:55:11 -0800 Message-Id: <20210107195515.106158-7-ankur.a.arora@oracle.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20210107195515.106158-1-ankur.a.arora@oracle.com> References: <20210107195515.106158-1-ankur.a.arora@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9857 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 bulkscore=0 suspectscore=0 spamscore=0 adultscore=0 malwarescore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2101070114 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9857 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 bulkscore=0 spamscore=0 impostorscore=0 phishscore=0 lowpriorityscore=0 suspectscore=0 priorityscore=1501 mlxscore=0 malwarescore=0 clxscore=1015 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2101070115 Content-Transfer-Encoding: quoted-printable Initialize IsBsp early to ensure that this variable reflects the BSP status correctly. Also replace this check: if (mSmmMpSyncData->BspIndex =3D=3D (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 Cc: Ray Ni Cc: Laszlo Ersek Cc: Rahul Kumar Cc: Igor Mammedov Cc: Boris Ostrovsky Cc: Aaron Young Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3132 Signed-off-by: Ankur Arora --- UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c b/UefiCpuPkg/PiSmmCpuDxe= Smm/MpService.c index 4bcd217917d7..e7ea44eb86fc 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c @@ -1565,7 +1565,12 @@ SmiRendezvous ( {=0D EFI_STATUS Status;=0D BOOLEAN ValidSmi;=0D - BOOLEAN IsBsp;=0D +=0D + //=0D + // IsBsp starts out as false. Once a CPU gets elected as BSP,=0D + // it will transition its value to true.=0D + //=0D + BOOLEAN IsBsp =3D FALSE;=0D BOOLEAN BspInProgress;=0D UINTN Index;=0D UINTN Cr2;=0D @@ -1656,7 +1661,6 @@ SmiRendezvous ( //=0D // Elect BSP=0D //=0D - IsBsp =3D FALSE;=0D if (FeaturePcdGet (PcdCpuSmmEnableBspElection)) {=0D if (!mSmmMpSyncData->SwitchBsp || mSmmMpSyncData->CandidateBsp[Cpu= Index]) {=0D //=0D @@ -1679,6 +1683,8 @@ SmiRendezvous ( (UINT32)-1,=0D (UINT32)CpuIndex=0D );=0D +=0D + IsBsp =3D mSmmMpSyncData->BspIndex =3D=3D (UINT32)CpuIndex;=0D }=0D }=0D }=0D @@ -1686,7 +1692,7 @@ SmiRendezvous ( //=0D // "mSmmMpSyncData->BspIndex =3D=3D CpuIndex" means this is the BSP= =0D //=0D - if (mSmmMpSyncData->BspIndex =3D=3D CpuIndex) {=0D + if (IsBsp) {=0D =0D //=0D // Clear last request for SwitchBsp.=0D --=20 2.9.3