From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.43, mailfrom: ray.ni@intel.com) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by groups.io with SMTP; Wed, 11 Sep 2019 10:37:49 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Sep 2019 10:37:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,489,1559545200"; d="scan'208";a="384775796" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by fmsmga005.fm.intel.com with ESMTP; 11 Sep 2019 10:37:48 -0700 Received: from fmsmsx120.amr.corp.intel.com (10.18.124.208) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 11 Sep 2019 10:37:48 -0700 Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by fmsmsx120.amr.corp.intel.com (10.18.124.208) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 11 Sep 2019 10:37:48 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.32]) by SHSMSX103.ccr.corp.intel.com ([169.254.4.140]) with mapi id 14.03.0439.000; Thu, 12 Sep 2019 01:37:46 +0800 From: "Ni, Ray" To: "Nikodem, Damian" , "devel@edk2.groups.io" CC: "Dong, Eric" , "You, Benjamin" , Laszlo Ersek , "Rusocki, Krzysztof" Subject: Re: [PATCH v3] UefiCpuPkg: Fix potential spinLock issue in SmmStartupThisAp Thread-Topic: [PATCH v3] UefiCpuPkg: Fix potential spinLock issue in SmmStartupThisAp Thread-Index: AQHVaHo0MgjLuXlpcEKMmiYOwNwE46cmvg1A Date: Wed, 11 Sep 2019 17:37:44 +0000 Deferred-Delivery: Wed, 11 Sep 2019 17:37:00 +0000 Message-ID: <734D49CCEBEEF84792F5B80ED585239D5C2D164D@SHSMSX104.ccr.corp.intel.com> References: <20190911082301.1488-1-damian.nikodem@intel.com> In-Reply-To: <20190911082301.1488-1-damian.nikodem@intel.com> Accept-Language: en-US, zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiZjg2ZjhiYmEtZmNiZi00MzViLWFjNmYtZjlmMWQzYTI5MjU4IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiQU90THFyUlJSaXNmZ1l2UkpocWZCblpxQnNhbnhITW9pSDg5U0dRYUNRRjhubTlmanQxQUE2MkZpRUhFZkdVRiJ9 x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.2.0.6 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Return-Path: ray.ni@intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Ray Ni > -----Original Message----- > From: Nikodem, Damian > Sent: Wednesday, September 11, 2019 1:23 AM > To: devel@edk2.groups.io > Cc: Nikodem, Damian ; Dong, Eric ; Ni, Ray ; You, > Benjamin ; Laszlo Ersek ; Ruso= cki, Krzysztof > Subject: [PATCH v3] UefiCpuPkg: Fix potential spinLock issue in SmmStartu= pThisAp >=20 > Due to needs a tackling the deficiency of the AP API, is necessary to ens= ure that in non-blocking mode > previous AP executed command is finished before start new one. >=20 > To remedy above: > 1) execute AcquireSpinLock instead AcquireSpinLockOrFail - this will en= sure time "window" to eliminate potential > race condition beetwen BSP and AP spinLock release in non-blocking m= ode. > This also will eliminate possibility to start executing new AP funct= ion before last is finished. > 2) remove returns EFI_STATUS - EFI_NOT_READY - in new scenario returned= status is not necessary to caller. >=20 > Signed-off-by: Damian Nikodem > Cc: Eric Dong > Cc: Ray Ni > Cc: Benjamin You > Cc: Laszlo Ersek > Cc: Krzysztof Rusocki >=20 > diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c b/UefiCpuPkg/PiSmmCpuD= xeSmm/MpService.c > index d8d2b6f444..0685637c2b 100644 > --- a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c > +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c > @@ -1235,14 +1235,9 @@ InternalSmmStartupThisAp ( > return EFI_INVALID_PARAMETER; > } >=20 > - if (Token =3D=3D NULL) { > - AcquireSpinLock (mSmmMpSyncData->CpuData[CpuIndex].Busy); > - } else { > - if (!AcquireSpinLockOrFail (mSmmMpSyncData->CpuData[CpuIndex].Busy))= { > - DEBUG((DEBUG_ERROR, "Can't acquire mSmmMpSyncData->CpuData[%d].Bus= y\n", CpuIndex)); > - return EFI_NOT_READY; > - } > + AcquireSpinLock (mSmmMpSyncData->CpuData[CpuIndex].Busy); >=20 > + if (Token !=3D NULL) { > *Token =3D (MM_COMPLETION) CreateToken (); > }