From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id BEAB981EBB for ; Tue, 29 Nov 2016 12:49:00 -0800 (PST) Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F1BFB804F2; Tue, 29 Nov 2016 20:48:58 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-57.phx2.redhat.com [10.3.116.57]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id uATKmvHF009932; Tue, 29 Nov 2016 15:48:57 -0500 To: Jeff Fan , edk2-devel@ml01.01.org References: <20161129075130.15192-1-jeff.fan@intel.com> Cc: Michael D Kinney , Jiewen Yao , Feng Tian From: Laszlo Ersek Message-ID: Date: Tue, 29 Nov 2016 21:48:56 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.0 MIME-Version: 1.0 In-Reply-To: <20161129075130.15192-1-jeff.fan@intel.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 29 Nov 2016 20:48:59 +0000 (UTC) Subject: Re: [PATCH] UefiCpuPkg/PiSmmCpuDxeSmm: Clear some semaphores on S3 boot path X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Nov 2016 20:49:00 -0000 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit On 11/29/16 08:51, Jeff Fan wrote: > Some semaphores are not cleared on S3 boot path. For example, > mSmmMpSyncData->CpuData[CpuIndex].Present. It may still keeps the value set at > SMM runtime during S3 resume. It may causes BSP have the wrong judgement on SMM > AP's present state. > > We have one related fix at e78a2a49ee6b0c0d7c6997c87ace31d7761cf636. But that is > not completed. > > This fix is to clear Busy/Run/Present semaphores in InitializeMpSyncData(). > > Cc: Laszlo Ersek > Cc: Feng Tian > Cc: Jiewen Yao > Cc: Michael D Kinney > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Jeff Fan > --- > UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c > index cfbf59e..a873b68 100644 > --- a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c > +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c > @@ -1357,6 +1357,9 @@ InitializeMpSyncData ( > (UINT32 *)((UINTN)mSmmCpuSemaphores.SemaphoreCpu.Run + mSemaphoreSize * CpuIndex); > mSmmMpSyncData->CpuData[CpuIndex].Present = > (BOOLEAN *)((UINTN)mSmmCpuSemaphores.SemaphoreCpu.Present + mSemaphoreSize * CpuIndex); > + *(mSmmMpSyncData->CpuData[CpuIndex].Busy) = 0; > + *(mSmmMpSyncData->CpuData[CpuIndex].Run) = 0; > + *(mSmmMpSyncData->CpuData[CpuIndex].Present) = FALSE; > } > } > } > Even after this patch, the values pointed-to by the following fields of SemaphoreGlobal are not cleared: PFLock, CodeAccessCheckLock, MemoryMappedLock. Is that okay? The values pointed-to by the following fields of SemaphoreMsr are not cleared either: Msr, AvailableCounter. Is that okay? Can we imitate e78a2a49ee6b0c0d7c6997c87ace31d7761cf636 here; namely, can we save "SemaphoreBlock" and "TotalSize" from InitializeSmmCpuSemaphores() in global variables (in SMRAM), and then just do another ZeroMem() here? That would cover the currently listed objects (*Counter, *InsideSmm, *AllCpusInSync), and everything else too, in a future-proof way. In fact, I wonder if the ZeroMem() could be moved into InitializeMpSyncData() from InitializeSmmCpuSemaphores(). Of course, if some pointed-to objects must not be cleared, then the ZeroMem() is not appropriate. Thanks! Laszlo