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 B964C22729616 for ; Thu, 12 Apr 2018 10:51:23 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0B3718DC38; Thu, 12 Apr 2018 17:51:23 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-120-142.rdu2.redhat.com [10.10.120.142]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2A2DBD7DF9; Thu, 12 Apr 2018 17:51:21 +0000 (UTC) To: "Kinney, Michael D" , "Bi, Dandan" , "edk2-devel@lists.01.org" Cc: "Dong, Eric" References: <20180412085014.107784-1-dandan.bi@intel.com> <7dd6846f-fe34-ad7b-ae20-dc7d55ef84f5@redhat.com> From: Laszlo Ersek Message-ID: <8ddbdeb8-57c8-1352-1ae7-c2a0047a35a3@redhat.com> Date: Thu, 12 Apr 2018 19:51:21 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Thu, 12 Apr 2018 17:51:23 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Thu, 12 Apr 2018 17:51:23 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'lersek@redhat.com' RCPT:'' Subject: Re: [patch] UefiCpuPkg/PiSmmCpuDxeSmm: Add "extern" keyword for "gPatchxxx" X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Apr 2018 17:51:24 -0000 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit On 04/12/18 18:47, Kinney, Michael D wrote: > Laszlo, > > I think I would rather see the ECC tool fixed. I didn't dare suggest that, but I agree it's a superior solution. When I tried ECC last time, I was surprised how powerful it was, so if it recognized even this case, that would certainly fit its quality :) Thanks! Laszlo > > Mike > >> -----Original Message----- >> From: edk2-devel [mailto:edk2-devel- >> bounces@lists.01.org] On Behalf Of Laszlo Ersek >> Sent: Thursday, April 12, 2018 2:34 AM >> To: Bi, Dandan ; edk2- >> devel@lists.01.org >> Cc: Dong, Eric >> Subject: Re: [edk2] [patch] UefiCpuPkg/PiSmmCpuDxeSmm: >> Add "extern" keyword for "gPatchxxx" >> >> Hello Dandan, >> >> On 04/12/18 10:50, Dandan Bi wrote: >>> Background description: >>> In SmmProfileInternal.h, ECC check tool report an >> issue at line 103. >>> Detailed ECC Error info:Variable definition appears >> in header file. >>> Include files should contain only public or only >> private data and >>> cannot contain code or define data variables >>> >>> ECC report similar issues in PiSmmCpuDxeSmm.h. >>> >>> Then we review all the new introduced "gPatchxxx", >> since they have >>> been defined in the nasm file, we can add "extern" >> keyword for them >>> in the C source or header files. >>> >>> Cc: Eric Dong >>> Cc: Laszlo Ersek >>> Contributed-under: TianoCore Contribution Agreement >> 1.1 >>> Signed-off-by: Dandan Bi >>> --- >>> UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h | 8 >> ++++---- >>> UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfileInternal.h | 2 >> +- >>> UefiCpuPkg/PiSmmCpuDxeSmm/SmramSaveState.c | 6 >> +++--- >>> UefiCpuPkg/PiSmmCpuDxeSmm/X64/Semaphore.c | 4 >> ++-- >>> 4 files changed, 10 insertions(+), 10 deletions(-) >> >> This is a bug (a false positive) in the ECC tool. The >> following >> declaration: >> >>> X86_ASSEMBLY_PATCH_LABEL gPatchSmmCr0; >> >> does not declare an *object* (a variable). Instead, it >> declares a >> *function* (and not a pointer to a function!), because >> (from >> "MdePkg/Include/Library/BaseLib.h"): >> >>> /// >>> /// Type definition for representing labels in NASM >> source code that allow for >>> /// the patching of immediate operands of IA32 and >> X64 instructions. >>> /// >>> /// While the type is technically defined as a >> function type (note: not a >>> /// pointer-to-function type), such labels in NASM >> source code never stand for >>> /// actual functions, and identifiers declared with >> this function type should >>> /// never be called. This is also why the EFIAPI >> calling convention specifier >>> /// is missing from the typedef, and why the typedef >> does not follow the usual >>> /// edk2 coding style for function (or pointer-to- >> function) typedefs. The VOID >>> /// return type and the VOID argument list are merely >> artifacts. >>> /// >>> typedef VOID (X86_ASSEMBLY_PATCH_LABEL) (VOID); >> >> That is, when you see >> >>> X86_ASSEMBLY_PATCH_LABEL gPatchSmmCr0; >> >> That is identical to the following function >> declaration: >> >>> VOID gPatchSmmCr0 (VOID); >> >> Now, the ISO C99 standard says: >> >>> 6.2.2 Linkages of identifiers >>> >>> [...] >>> >>> 5 If the declaration of an identifier for a >> function has no >>> storage-class specifier, its linkage is >> determined exactly as if >>> it were declared with the storage-class specifier >> /extern/. [...] >> >> Thus, the report from ECC is a false positive. >> >> I don't mind the patch (the changes don't make any >> difference at the >> C-language level, see the spec above); however, the >> commit message >> should be 100% clear that the patch works around a >> limitation with the >> ECC tool. >> >> Can you please submit v2 with an updated commit >> message? >> >> Thanks! >> Laszlo >> _______________________________________________ >> edk2-devel mailing list >> edk2-devel@lists.01.org >> https://lists.01.org/mailman/listinfo/edk2-devel