From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 997ADAC0BA7 for ; Tue, 19 Dec 2023 05:12:29 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=xXGAwwaTJWl0Zk3dcRbHL2w3xIC/XjhHAC0ACiOz8qw=; c=relaxed/simple; d=groups.io; h=ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results:From:To:CC:Subject:Thread-Topic:Thread-Index:Date:Message-ID:References:In-Reply-To:Accept-Language:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20140610; t=1702962748; v=1; b=Ek4SFv3xXRBHBPhxqC+iCRDDN/14piF4XYtwn/tSlkz7TmE2zDxSpym9AgjG8R3WSqgspggw dSA8hf06P6/wsvZiCM2yzgLegaF/rp2EkYnjN5nc+S8UHE5g6rWIE5LHsAKcN8io7pKBo7/gDdH JkOONe+kRDVUF/lWwxVy5orw= X-Received: by 127.0.0.2 with SMTP id fIV5YY7687511xwJbSIpUvtc; Mon, 18 Dec 2023 21:12:28 -0800 X-Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.43]) by mx.groups.io with SMTP id smtpd.web11.6043.1702962747268572380 for ; Mon, 18 Dec 2023 21:12:27 -0800 X-IronPort-AV: E=McAfee;i="6600,9927,10928"; a="481800144" X-IronPort-AV: E=Sophos;i="6.04,287,1695711600"; d="scan'208";a="481800144" X-Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Dec 2023 21:12:26 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10928"; a="841759073" X-IronPort-AV: E=Sophos;i="6.04,287,1695711600"; d="scan'208";a="841759073" X-Received: from fmsmsx602.amr.corp.intel.com ([10.18.126.82]) by fmsmga008.fm.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 18 Dec 2023 21:12:26 -0800 X-Received: from fmsmsx611.amr.corp.intel.com (10.18.126.91) by fmsmsx602.amr.corp.intel.com (10.18.126.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Mon, 18 Dec 2023 21:12:26 -0800 X-Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx611.amr.corp.intel.com (10.18.126.91) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Mon, 18 Dec 2023 21:12:25 -0800 X-Received: from fmsedg602.ED.cps.intel.com (10.1.192.136) by fmsmsx610.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35 via Frontend Transport; Mon, 18 Dec 2023 21:12:25 -0800 X-Received: from NAM11-BN8-obe.outbound.protection.outlook.com (104.47.58.168) by edgegateway.intel.com (192.55.55.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Mon, 18 Dec 2023 21:12:25 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jPQ3OBenVnHXKTdQq61YAhVyAlwLAXfolP95tnNtFKYxyChHHS2Qc66mtsi1Cc+JIE21m/l6goRN8usYHUuJmzebkcYKF+aMH/gWJOKqs25sA2G2+f4ullK+ikLUUwom/T5B1W3VMjdz7fEXRfhJTMOlBxAH8hWx7CoFF0cj/2SlYcbdvKVnMCqtnemlJHVpiQAhQDpICfuW0bg4FX1cgJgi3XtQMkqWpHJllkTO3ld6s0K8SxYrQETYvV4IICCOvw+z6szjtXEVf7W8VYzEELwGT7ZX7rVnlyh1U3P+H7OUAIzHUSiOzF29BYvxQ4Z9ovBTacqOVbCfhFcBYMjy5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=TsR1cZNg+o1Tdt/rBhLLzbwCLHOBz+sRMMMogJY82UQ=; b=VaN0G5iQ3TZqY3uluidXa38rcDlYe2LZTSsDqBmQLkz5uQrzpQBRW7tcXLkhSUnGEN14GS9Eu1Vt2wDrIhNhcH373hI/oJ+YWY2KbOWnvtcOnPwQO/elMnfZW4EtMjB3eCS9iqzIRLc0wBjj/Dvd/1govfMG4FoBp5h3zdjK86AczhBDvS7RoJu9zvQnqjgG2i3XVqiI/QvVExx2eaKHu9FT14fx8tkZOiyovmvzfu1VQ9dfsaNt5oDQJsjvNrsRUrg6v8D+vqQlnuAI5iLoM2QhiSFGOoGTBINDa7LsnkYngr5pywGMaHtUmTw5Vv3fDCSk12wPyp8Ilbq6B3thiw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none X-Received: from CO1PR11MB5026.namprd11.prod.outlook.com (2603:10b6:303:9c::13) by LV3PR11MB8458.namprd11.prod.outlook.com (2603:10b6:408:1bb::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7091.38; Tue, 19 Dec 2023 05:12:22 +0000 X-Received: from CO1PR11MB5026.namprd11.prod.outlook.com ([fe80::8d55:7a7e:cfc9:aca4]) by CO1PR11MB5026.namprd11.prod.outlook.com ([fe80::8d55:7a7e:cfc9:aca4%4]) with mapi id 15.20.7091.034; Tue, 19 Dec 2023 05:12:22 +0000 From: "Yuanhao Xie" To: "Ni, Ray" CC: "Li, Zhihao" , "Kumar, Rahul R" , Gerd Hoffmann , "Wu, Jiaxin" , "devel@edk2.groups.io" Subject: Re: [edk2-devel] [Patch V3] UefiCpuPkg/PiSmmCpuDxeSmm: SmmCpuRendezvous ensure all Aps in Present. Thread-Topic: [Patch V3] UefiCpuPkg/PiSmmCpuDxeSmm: SmmCpuRendezvous ensure all Aps in Present. Thread-Index: AQHaLzlPM/lLVHEvCUWqdmmvZ4Z2l7CwAZYAgAATMFA= Date: Tue, 19 Dec 2023 05:12:22 +0000 Message-ID: References: <20231215092953.2395-1-yuanhao.xie@intel.com> In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: CO1PR11MB5026:EE_|LV3PR11MB8458:EE_ x-ms-office365-filtering-correlation-id: 7d6a96a0-6e3e-4457-08f4-08dc005114d6 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam-message-info: RFfzxBQaZ62Mr2ccS7m3u2VYhkIR0V3gCXdfNScwA5E3lNlhEX9Xzdt7ZocRLqZzQpgixItOnZYgcX6mbvNedYYu8tWWA4LGJEIkUkUoIJKl/LjI/EYLl2CDY2wS2IHdVhWp3/TJVT85u/srL5sCiMa9fyiYP84rqwcRO0SatAmKXe8VBh1bXt4uig4efmkPWHA2/Ky/6Qg+TTZNcvaiUqnd7TYL37aEuwggTeatHIbMo1dNgh1BPyBGJYzVe9o+1BXokGLIAUIGLZpMPwEM2xN9FZ2fqIcR5rsV+3c/Gk54zYaMjK2qLexyv5ZvQj4kb5vUjEYpToWgW51kEKBGUmwVFEej1e7M6vM6EWY+RBCy0Zo58ZhUt33JnTPuxRSGF9Dnib9h9Vs56YrwoEUoLdlZXCcpXxMcLpNVCUXzkncyiZqRRf19hd50B2oq58DgAckkiLYHpLA/LNjYtCc7unr2Z/Z3XEP2+vIDNPwUa2feptV9ERSzzXPszFwYiqowtRIPXFXpaqT8ihCM39SoPmlVCjUChq0E2H/1P7J7RPY9DUSUPlihXduQVr3VdB8UEh1MY4Oc0tvn3CJI5daShSVmbRtpjH8PyngwSV9Jbx+YZUOcjQ8LkVmwN+LURi2T x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?bByxipnNp+W80p0qO10X2bFp+PRkPr6QchBPfJPjWlLGx5FfBq553GO8X5bp?= =?us-ascii?Q?spRpvCnhMgLZW1Ly6OT1Ohyox3vTtZm4/WZa+O5MN3joYRb/etXXzpg+qDhi?= =?us-ascii?Q?G9JmF5DFhJDrz9ZU/rfnZJ4s1nRcnbaKs+4XDjunhV4xDdxU1h7sC6+1JnTj?= =?us-ascii?Q?MZqPGzTcKPPC1mffjvNxudZt2CUKIegC48KjAhLw0byIJ0srEFOIhXxVXNrR?= =?us-ascii?Q?gDH5kGVuBZSiwpitfuK5io+aOcAsMQzsePE+EQh5EIZXh47k1HT1IjkUNDej?= =?us-ascii?Q?OGQwxZ1ki3ph9gQB7JLJJXUPXcOQANf2a0X1gd2NfMdN9B8mUlsqPJRhoC0l?= =?us-ascii?Q?lNeOv2pYKMFizkT0+ul43bGDG6y17VDn0uxfNNMNEbvZ+d5n1smU+L6XXOwm?= =?us-ascii?Q?ED5xHuxXMRzkdxl+qGErC9H/qKewVzeS+bUhlwTdSVWGeOxerwta+lzeSLRK?= =?us-ascii?Q?ZEC9+plpprfGO40jqZMFuIH8BToNkMxGJP1Lbu29Zse43CaXGol63EaW3X52?= =?us-ascii?Q?igg5ITT5SbZ1/NfGWmuzam68CLcTB1LD+E4bYvAdcw/wNaTY4ugcdjsXTcP9?= =?us-ascii?Q?VJeTl4XC52lgabDZQj9TXkTYQCHyMEggX/IokfjtjnXkWFExdrRK8RBobqbt?= =?us-ascii?Q?GyxpZAuzWcTkANi5VYsjPhNUHS6dMzwJYtz8Ehw6NdAKNZEpIkDwzi0sM9kP?= =?us-ascii?Q?utjagPvleVafSH3O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X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: CO1PR11MB5026.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7d6a96a0-6e3e-4457-08f4-08dc005114d6 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Dec 2023 05:12:22.1537 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: aaPvyacUnZQfTwO9B6dguU7xC/PzV5+ruA+Cp01tQAZpowEpcJ6EQ+LQ0bmcRQAM7xFctUCuEpqyL4pcGRVeng== X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR11MB8458 X-OriginatorOrg: intel.com Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,yuanhao.xie@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: XpWhogMYrbdx7GOWofBdeJGNx7686176AA= Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=Ek4SFv3x; arc=reject ("signature check failed: fail, {[1] = sig:microsoft.com:reject}"); dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=intel.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io Hi Ray, It means that: The "SmmCpuRendezvous" function has a bug in that it summons all APs into S= MM, but there is a time gap before they are set as "present." During this w= indow, if using the "setVariable" operation, it can cause issues because "s= etVariable" requires all APs to be in SMM and marked as "present." Therefor= e, this patch adds extra logic to "SmmCpuRendezvous" to check if the APs ar= e already "present" before proceeding. Thanks, Yuanhao -----Original Message----- From: Ni, Ray =20 Sent: Tuesday, December 19, 2023 12:01 PM To: Xie, Yuanhao ; devel@edk2.groups.io Cc: Li, Zhihao ; Kumar, Rahul R ; Gerd Hoffmann ; Wu, Jiaxin Subject: RE: [Patch V3] UefiCpuPkg/PiSmmCpuDxeSmm: SmmCpuRendezvous ensure = all Aps in Present. Yuanhao, Zhihao, Can you kindly explain a bit more about this sentence in commit message " S= MM read save state requires AP must be present."? Thanks, Ray > -----Original Message----- > From: Xie, Yuanhao > Sent: Friday, December 15, 2023 5:30 PM > To: devel@edk2.groups.io > Cc: Xie, Yuanhao ; Li, Zhihao=20 > ; Ni, Ray ; Kumar, Rahul R=20 > ; Gerd Hoffmann ; Wu,=20 > Jiaxin > Subject: [Patch V3] UefiCpuPkg/PiSmmCpuDxeSmm: SmmCpuRendezvous ensure=20 > all Aps in Present. >=20 > SMM read save state requires AP must be present. > This patch aim to avoid the AP not ready for save state check. > Furthermore, SmmWaitForApArrival has two callers: SmmCpuRendezvous and=20 > BSPHandler, the behavior of the two callers can be consistent by add=20 > the while loop to check the present of the APs to SmmCpuRendezvous. >=20 > Signed-off-by: Zhihao Li > Cc: Ray Ni > Cc: Rahul Kumar > Cc: Gerd Hoffmann > Cc: Jiaxin Wu > --- > UefiCpuPkg/PiSmmCpuDxeSmm/CpuService.c | 27 > +++++++++++++++++++++++++++ > UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h | 13 +++++++++++++ > 2 files changed, 40 insertions(+) >=20 > diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuService.c > b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuService.c > index c0485b0519..3e98955319 100644 > --- a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuService.c > +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuService.c > @@ -416,8 +416,15 @@ SmmCpuRendezvous ( > IN BOOLEAN BlockingMode > ) > { > + UINTN Index; > + UINTN PresentCount; > + UINT32 BlockedCount; > + UINT32 DisabledCount; > EFI_STATUS Status; >=20 > + BlockedCount =3D 0; > + DisabledCount =3D 0; > + > // > // Return success immediately if all CPUs are already synchronized. > // > @@ -436,6 +443,26 @@ SmmCpuRendezvous ( > // There are some APs outside SMM, Wait for all avaiable APs to arri= ve. > // > SmmWaitForApArrival (); > + > + // > + // Make sure all APs have their Present flag set > + // > + while (TRUE) { > + PresentCount =3D 0; > + for (Index =3D 0; Index < mMaxNumberOfCpus; Index++) { > + if (*(mSmmMpSyncData->CpuData[Index].Present)) { > + PresentCount++; > + } > + } > + > + GetSmmDelayedBlockedDisabledCount (NULL, &BlockedCount, > &DisabledCount); > + if (PresentCount =3D=3D mMaxNumberOfCpus - BlockedCount - > DisabledCount ) { > + break; > + } > + > + CpuPause (); > + } > + > Status =3D mSmmMpSyncData->AllApArrivedWithException ? > EFI_SUCCESS : EFI_TIMEOUT; > } else { > // > diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h > b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h > index f18345881b..e3538957fb 100644 > --- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h > +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h > @@ -1552,6 +1552,19 @@ SmmWaitForApArrival ( > VOID > ); >=20 > +/** > + Returns the Number of SMM Delayed & Blocked & Disabled Thread Count. > + @param[in,out] DelayedCount The Number of SMM Delayed Thread > Count. > + @param[in,out] BlockedCount The Number of SMM Blocked Thread > Count. > + @param[in,out] DisabledCount The Number of SMM Disabled Thread > Count. > +**/ > +VOID > +GetSmmDelayedBlockedDisabledCount ( > + IN OUT UINT32 *DelayedCount, > + IN OUT UINT32 *BlockedCount, > + IN OUT UINT32 *DisabledCount > + ); > + > /** > Write unprotect read-only pages if Cr0.Bits.WP is 1. >=20 > -- > 2.39.1.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#112689): https://edk2.groups.io/g/devel/message/112689 Mute This Topic: https://groups.io/mt/103187773/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-