public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH v2] UefiCpuPkg/SecCore: Correct print format for stack information
@ 2016-11-16  7:55 Jeff Fan
  2016-11-16 16:23 ` Laszlo Ersek
  0 siblings, 1 reply; 2+ messages in thread
From: Jeff Fan @ 2016-11-16  7:55 UTC (permalink / raw)
  To: edk2-devel; +Cc: Laszlo Ersek, Andrew Fish, Feng Tian, Michael D Kinney

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 <lersek@redhat.com>
Cc: Andrew Fish <afish@apple.com>
Cc: Feng Tian <feng.tian@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <jeff.fan@intel.com>
---
 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
     ));
 
   //
-- 
2.9.3.windows.2



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] UefiCpuPkg/SecCore: Correct print format for stack information
  2016-11-16  7:55 [PATCH v2] UefiCpuPkg/SecCore: Correct print format for stack information Jeff Fan
@ 2016-11-16 16:23 ` Laszlo Ersek
  0 siblings, 0 replies; 2+ messages in thread
From: Laszlo Ersek @ 2016-11-16 16:23 UTC (permalink / raw)
  To: Jeff Fan, edk2-devel; +Cc: Andrew Fish, Feng Tian, Michael D Kinney

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 <lersek@redhat.com>
> Cc: Andrew Fish <afish@apple.com>
> Cc: Feng Tian <feng.tian@intel.com>
> Cc: Michael D Kinney <michael.d.kinney@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Jeff Fan <jeff.fan@intel.com>
> ---
>  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 <lersek@redhat.com>

Thanks
Laszlo


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-11-16 16:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-16  7:55 [PATCH v2] UefiCpuPkg/SecCore: Correct print format for stack information Jeff Fan
2016-11-16 16:23 ` Laszlo Ersek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox