From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=66.187.233.73; helo=mx1.redhat.com; envelope-from=lersek@redhat.com; receiver=edk2-devel@lists.01.org Received: from mx1.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) (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 85E9F21AE30DB for ; Tue, 11 Sep 2018 07:55:34 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E6715FE37E; Tue, 11 Sep 2018 14:55:33 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-120-36.rdu2.redhat.com [10.10.120.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id 19E012156889; Tue, 11 Sep 2018 14:55:32 +0000 (UTC) To: Jian J Wang , edk2-devel@lists.01.org Cc: Hao A Wu , Dandan Bi , Eric Dong References: <20180911044729.5020-1-jian.j.wang@intel.com> From: Laszlo Ersek Message-ID: Date: Tue, 11 Sep 2018 16:55:32 +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: <20180911044729.5020-1-jian.j.wang@intel.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Tue, 11 Sep 2018 14:55:33 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Tue, 11 Sep 2018 14:55:33 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'lersek@redhat.com' RCPT:'' Subject: Re: [PATCH] UefiCpuPkg/CpuMpPei: suppress compiler complaining X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Sep 2018 14:55:35 -0000 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Jian, On 09/11/18 06:47, Jian J Wang wrote: > BZ#: https://bugzilla.tianocore.org/show_bug.cgi?id=1166 > > Cc: Dandan Bi > Cc: Hao A Wu > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Jian J Wang > --- > UefiCpuPkg/CpuMpPei/CpuPaging.c | 23 ++++++++++++++++------- > 1 file changed, 16 insertions(+), 7 deletions(-) (1) Please remember to CC the package maintainers / reviewers on patches. "Maintainers.txt" lists Eric (M) and myself (R) for UefiCpuPkg. It's OK to CC other people as well, of course. (2) Bug 1166 mentions "warning C4701: potentially uninitialized local variable 'StackBase' used". If that warning is invalid (= the variable can never be read unassigned), then we have some suggested language for that; please see . Furthermore: > > diff --git a/UefiCpuPkg/CpuMpPei/CpuPaging.c b/UefiCpuPkg/CpuMpPei/CpuPaging.c > index bcb942a8e5..a63421a1af 100644 > --- a/UefiCpuPkg/CpuMpPei/CpuPaging.c > +++ b/UefiCpuPkg/CpuMpPei/CpuPaging.c > @@ -517,7 +517,7 @@ GetStackBase ( > IN OUT VOID *Buffer > ) > { > - EFI_PHYSICAL_ADDRESS StackBase; > + volatile EFI_PHYSICAL_ADDRESS StackBase; (3) "volatile" seems unrelated; I suggest dropping it. (Especially without the comment mentioned in TianoCore#607, "volatile" is totally unjustified and confusing.) > > StackBase = (EFI_PHYSICAL_ADDRESS)(UINTN)&StackBase; > StackBase += BASE_4KB; > @@ -554,6 +554,8 @@ SetupStackGuardPage ( > MpInitLibGetNumberOfProcessors(&NumberOfProcessors, NULL); > MpInitLibWhoAmI (&Bsp); > for (Index = 0; Index < NumberOfProcessors; ++Index) { > + StackBase = 0; > + > if (Index == Bsp) { > Hob.Raw = GetHobList (); > while ((Hob.Raw = GetNextHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, Hob.Raw)) != NULL) { > @@ -570,12 +572,19 @@ SetupStackGuardPage ( > // > MpInitLibStartupThisAP(GetStackBase, Index, NULL, 0, (VOID *)&StackBase, NULL); > } > - // > - // Set Guard page at stack base address. > - // > - ConvertMemoryPageAttributes(StackBase, EFI_PAGE_SIZE, 0); > - DEBUG ((DEBUG_INFO, "Stack Guard set at %lx [cpu%lu]!\n", > - (UINT64)StackBase, (UINT64)Index)); > + > + if (StackBase == 0) { > + DEBUG ((DEBUG_ERROR, "Stack base address was not found for [cpu%lu]!\n", > + (UINT64)Index)); > + ASSERT(StackBase != 0); (4) On the other hand, if it *can* happen in practice that the stack base is not found (and in that case, we should halt), then: * the subject line is wrong, because the compiler warning is *valid*, and we don't suppress it, but fix the issue caught by the compiler; * we must not proceed in a RELEASE build either, therefore an ASSERT is insufficient. A CpuDeadLoop() is necessary. (Again, this only applies if StackBase may be zero here by design.) Thanks Laszlo > + } else { > + // > + // Set Guard page at stack base address. > + // > + ConvertMemoryPageAttributes(StackBase, EFI_PAGE_SIZE, 0); > + DEBUG ((DEBUG_INFO, "Stack Guard set at %lx [cpu%lu]!\n", > + (UINT64)StackBase, (UINT64)Index)); > + } > } > > // >