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 BEC2D81EEA for ; Wed, 16 Nov 2016 08:23:03 -0800 (PST) Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (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 58DDA8050D; Wed, 16 Nov 2016 16:23:08 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-80.phx2.redhat.com [10.3.116.80]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id uAGGN6Ph022682; Wed, 16 Nov 2016 11:23:07 -0500 To: Jeff Fan , edk2-devel@ml01.01.org References: <20161116075506.9008-1-jeff.fan@intel.com> Cc: Andrew Fish , Feng Tian , Michael D Kinney From: Laszlo Ersek Message-ID: Date: Wed, 16 Nov 2016 17:23:06 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <20161116075506.9008-1-jeff.fan@intel.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 16 Nov 2016 16:23:08 +0000 (UTC) Subject: Re: [PATCH v2] UefiCpuPkg/SecCore: Correct print format for stack information 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: Wed, 16 Nov 2016 16:23:03 -0000 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit On 11/16/16 08:55, Jeff Fan wrote: > v2: > Per Laszlo and Andrew's comments at > https://lists.01.org/pipermail/edk2-devel/2016-November/004759.html > SecCoreData->StackBase is VOID * type. We should use %p to dump VOID * type. > SecCoreData->StackSize is UINTN type, but %x only could print unsinged-int > type. We will cast it to UINT32 firstly and then use %x to print it. > > Cc: Laszlo Ersek > Cc: Andrew Fish > Cc: Feng Tian > Cc: Michael D Kinney > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Jeff Fan > --- > UefiCpuPkg/SecCore/SecMain.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/UefiCpuPkg/SecCore/SecMain.c b/UefiCpuPkg/SecCore/SecMain.c > index 2ebbc22..077d0db 100644 > --- a/UefiCpuPkg/SecCore/SecMain.c > +++ b/UefiCpuPkg/SecCore/SecMain.c > @@ -239,10 +239,10 @@ SecStartupPhase2( > > DEBUG (( > DEBUG_INFO, > - "%a() Stack Base: 0x%lx, Stack Size: 0x%lx\n", > + "%a() Stack Base: 0x%p, Stack Size: 0x%x\n", > __FUNCTION__, > SecCoreData->StackBase, > - SecCoreData->StackSize > + (UINT32) SecCoreData->StackSize > )); > > // > In the general case, I like to print UINTN values by: - converting them to UINT64, - printing them with %Lx (or %Lu). This works reliably regardless of 32-bit vs. 64-bit. However, I see that a stack size larger than MAX_UINT32 (~4GB) is quite unlikely even for a 64-bit SEC phase :) Thus, the UINT32 cast won't cause actual truncation. Reviewed-by: Laszlo Ersek Thanks Laszlo