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 14F1A211280ED for ; Tue, 11 Sep 2018 07:01:00 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3E37240770C6; Tue, 11 Sep 2018 14:01:00 +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 695E22026D6B; Tue, 11 Sep 2018 14:00:59 +0000 (UTC) To: Jian J Wang , edk2-devel@lists.01.org Cc: Star Zeng , Benjamin You , Eric Dong References: <20180910032225.10044-1-jian.j.wang@intel.com> From: Laszlo Ersek Message-ID: Date: Tue, 11 Sep 2018 16:00:58 +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: <20180910032225.10044-1-jian.j.wang@intel.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Tue, 11 Sep 2018 14:01:00 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Tue, 11 Sep 2018 14:01:00 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'lersek@redhat.com' RCPT:'' Subject: Re: [PATCH] UefiCpuPkg/PiSmmCpuDxeSmm: add message for S3 config error 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:01:01 -0000 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit On 09/10/18 05:22, Jian J Wang wrote: > BZ#: https://bugzilla.tianocore.org/show_bug.cgi?id=1165 > > HOB gEfiAcpiVariableGuid is a must have data for S3 resume if > PcdAcpiS3Enable is set to TRUE. Current code in CpuS3.c doesn't > embody this strong binding between them. An error message and > ASSERT is added by this patch to warn platform developer about > it. > > Cc: Star Zeng > Cc: Benjamin You > Cc: Eric Dong > Cc: Laszlo Ersek > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Jian J Wang > --- > UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c > index abd8a5a07b..f371667c44 100644 > --- a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c > +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c > @@ -744,6 +744,9 @@ InitSmmS3ResumeState ( > if (sizeof (UINTN) == sizeof (UINT32)) { > SmmS3ResumeState->Signature = SMM_S3_RESUME_SMM_32; > } > + } else { > + DEBUG ((DEBUG_ERROR, "ERROR: HOB(gEfiAcpiVariableGuid) needed by S3 resume doesn't exist!\n")); > + ASSERT (FALSE); > } > > // > I have some superficial comments for this patch. (1) in case the "if" has an "else" branch, I think it's better style to use "==" in the condition than "!=". To me, if (GuidHob != NULL) { // // do a bunch of stuff // } else { // // error // } is more difficult to read than: if (GuidHob == NULL) { // // error // } else { // // do a bunch of stuff // } in particular if the "bunch of stuff" includes nested "if" statements. (2) I think the error message could be improved. I'd suggest removing the word "ERROR", since DEBUG_ERROR already sets the error level / mask. (3) Furthermore, I suggest not logging the name "gEfiAcpiVariableGuid" textually, as a string -- in edk2 we generally log GUIDs by value, and log parsers / translators usually look for GUID values. Thus I suggest using %g with &gEfiAcpiVariableGuid. (4) Please consider logging the module name and/or the function name too, with "%a", and gEfiCallerBaseName and/or __FUNCTION__. "gEfiCallerBaseName" is usually only helpful with libraries (because they can be linked into multiple drivers), but __FUNCTION__ is more frequently helpful. Thanks Laszlo