From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: redhat.com, ip: 209.132.183.28, mailfrom: lersek@redhat.com) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by groups.io with SMTP; Wed, 11 Sep 2019 07:45:56 -0700 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8C767191865A; Wed, 11 Sep 2019 14:45:55 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-127.ams2.redhat.com [10.36.116.127]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2B5B860BEC; Wed, 11 Sep 2019 14:45:53 +0000 (UTC) Subject: Re: [PATCH v3] UefiCpuPkg: Fix potential spinLock issue in SmmStartupThisAp To: Damian Nikodem , devel@edk2.groups.io Cc: Eric Dong , Ray Ni , Benjamin You , Krzysztof Rusocki References: <20190911082301.1488-1-damian.nikodem@intel.com> From: "Laszlo Ersek" Message-ID: <0cdd6b09-8d44-9aa3-df53-89c69aa7cf80@redhat.com> Date: Wed, 11 Sep 2019 16:45:53 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20190911082301.1488-1-damian.nikodem@intel.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.70]); Wed, 11 Sep 2019 14:45:55 +0000 (UTC) Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit On 09/11/19 10:23, Damian Nikodem wrote: > Due to needs a tackling the deficiency of the AP API, is necessary to ensure that in non-blocking mode > previous AP executed command is finished before start new one. > > To remedy above: > 1) execute AcquireSpinLock instead AcquireSpinLockOrFail - this will ensure time "window" to eliminate potential > race condition beetwen BSP and AP spinLock release in non-blocking mode. > This also will eliminate possibility to start executing new AP function before last is finished. > 2) remove returns EFI_STATUS - EFI_NOT_READY - in new scenario returned status is not necessary to caller. > > Signed-off-by: Damian Nikodem > Cc: Eric Dong > Cc: Ray Ni > Cc: Benjamin You > Cc: Laszlo Ersek > Cc: Krzysztof Rusocki Eric, Ray, please don't wait for my feedback on this one. It would be prudent for me to test this, but I got no time. Thanks Laszlo > diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c b/UefiCpuPkg/PiSmmCpuDxeSmm/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; > } > > - if (Token == NULL) { > - AcquireSpinLock (mSmmMpSyncData->CpuData[CpuIndex].Busy); > - } else { > - if (!AcquireSpinLockOrFail (mSmmMpSyncData->CpuData[CpuIndex].Busy)) { > - DEBUG((DEBUG_ERROR, "Can't acquire mSmmMpSyncData->CpuData[%d].Busy\n", CpuIndex)); > - return EFI_NOT_READY; > - } > + AcquireSpinLock (mSmmMpSyncData->CpuData[CpuIndex].Busy); > > + if (Token != NULL) { > *Token = (MM_COMPLETION) CreateToken (); > } > -------------------------------------------------------------------- > > Intel Technology Poland sp. z o.o. > ul. Slowackiego 173 | 80-298 Gdansk | Sad Rejonowy Gdansk Polnoc | VII Wydzial Gospodarczy Krajowego Rejestru Sadowego - KRS 101882 | NIP 957-07-52-316 | Kapital zakladowy 200.000 PLN. > > Ta wiadomosc wraz z zalacznikami jest przeznaczona dla okreslonego adresata i moze zawierac informacje poufne. W razie przypadkowego otrzymania tej wiadomosci, prosimy o powiadomienie nadawcy oraz trwale jej usuniecie; jakiekolwiek > przegladanie lub rozpowszechnianie jest zabronione. > This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). If you are not the intended recipient, please contact the sender and delete all copies; any review or distribution by > others is strictly prohibited. >