From: "Michael D Kinney" <michael.d.kinney@intel.com>
To: "Ni, Ray" <ray.ni@intel.com>, Gerd Hoffmann <kraxel@redhat.com>,
"devel@edk2.groups.io" <devel@edk2.groups.io>
Cc: "Dong, Eric" <eric.dong@intel.com>,
Oliver Steffen <osteffen@redhat.com>,
"Kumar, Rahul R" <rahul.r.kumar@intel.com>,
Pawel Polawski <ppolawsk@redhat.com>,
Laszlo Ersek <lersek@redhat.com>,
"Kinney, Michael D" <michael.d.kinney@intel.com>
Subject: Re: [PATCH 1/1] UefiCpuPkg/PiSmmCpuDxeSmm: fix format string
Date: Fri, 24 Mar 2023 15:35:17 +0000 [thread overview]
Message-ID: <CO1PR11MB4929064E2D66FF54D1D2163ED2849@CO1PR11MB4929.namprd11.prod.outlook.com> (raw)
In-Reply-To: <CO1PR11MB4929BCCB0F9A512DBB876262D2849@CO1PR11MB4929.namprd11.prod.outlook.com>
And from Laszlo's responses, 3 total options.
1) Keep %d and change BufferPages to type UINT32.
2) Change to %Ld and change BufferPages to type UINT64.
3) Change to %Ld and typecast BufferPages to UINT64 in DEBUG().
All 3 will work. Best suggestion is (3) from Laszlo.
Mike
> -----Original Message-----
> From: Kinney, Michael D <michael.d.kinney@intel.com>
> Sent: Friday, March 24, 2023 8:27 AM
> To: Ni, Ray <ray.ni@intel.com>; Gerd Hoffmann <kraxel@redhat.com>; devel@edk2.groups.io
> Cc: Dong, Eric <eric.dong@intel.com>; Oliver Steffen <osteffen@redhat.com>; Kumar, Rahul R <rahul.r.kumar@intel.com>;
> Pawel Polawski <ppolawsk@redhat.com>; Laszlo Ersek <lersek@redhat.com>; Kinney, Michael D <michael.d.kinney@intel.com>
> Subject: RE: [PATCH 1/1] UefiCpuPkg/PiSmmCpuDxeSmm: fix format string
>
> 1) Keep %d and change BufferPages to type UINT32.
> 2) Change to %Ld and change BufferPages to type UINT64.>
> Mike
>
> > -----Original Message-----
> > From: Ni, Ray <ray.ni@intel.com>
> > Sent: Friday, March 24, 2023 7:00 AM
> > To: Gerd Hoffmann <kraxel@redhat.com>; devel@edk2.groups.io; Kinney, Michael D <michael.d.kinney@intel.com>
> > Cc: Dong, Eric <eric.dong@intel.com>; Oliver Steffen <osteffen@redhat.com>; Kumar, Rahul R <rahul.r.kumar@intel.com>;
> > Pawel Polawski <ppolawsk@redhat.com>; Laszlo Ersek <lersek@redhat.com>
> > Subject: RE: [PATCH 1/1] UefiCpuPkg/PiSmmCpuDxeSmm: fix format string
> >
> > Gerd,
> > "%d" tells "int" type value is in the stack.
> > This actually works in both 32bit and 64bit case assuming the BufferPages is less than MAX_UINT32.
> >
> > But if using "%Lu", it tells that "uint_64" type value is in the stack.
> > This precisely describes the stack content in 64bit mode.
> > But it may print random value in the stack as high-32 bit in 32bit mode.
> >
> > @Kinney, Michael D, any comments?
> >
> > Thanks,
> > Ray
> >
> >
> > > -----Original Message-----
> > > From: Gerd Hoffmann <kraxel@redhat.com>
> > > Sent: Friday, March 24, 2023 9:42 PM
> > > To: devel@edk2.groups.io
> > > Cc: Dong, Eric <eric.dong@intel.com>; Gerd Hoffmann <kraxel@redhat.com>;
> > > Oliver Steffen <osteffen@redhat.com>; Kumar, Rahul R
> > > <rahul.r.kumar@intel.com>; Ni, Ray <ray.ni@intel.com>; Pawel Polawski
> > > <ppolawsk@redhat.com>; Laszlo Ersek <lersek@redhat.com>
> > > Subject: [PATCH 1/1] UefiCpuPkg/PiSmmCpuDxeSmm: fix format string
> > >
> > > BufferPages is UINTN, so we need "%Lu" when printing it.
> > >
> > > Fixes: 4f441d024bee ("UefiCpuPkg/PiSmmCpuDxeSmm: fix error handling")
> > > Reported-by: Laszlo Ersek <lersek@redhat.com>
> > > Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> > > ---
> > > UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c | 2 +-
> > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c
> > > b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c
> > > index cf69161caa4b..08663b1b1ab4 100644
> > > --- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c
> > > +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c
> > > @@ -880,7 +880,7 @@ PiCpuSmmEntry (
> > > BufferPages = EFI_SIZE_TO_PAGES (SIZE_32KB + TileSize *
> > > (mMaxNumberOfCpus - 1));
> > > Buffer = AllocateAlignedCodePages (BufferPages, SIZE_4KB);
> > > if (Buffer == NULL) {
> > > - DEBUG ((DEBUG_ERROR, "Failed to allocate %d pages.\n", BufferPages));
> > > + DEBUG ((DEBUG_ERROR, "Failed to allocate %Lu pages.\n",
> > > BufferPages));
> > > CpuDeadLoop ();
> > > return EFI_OUT_OF_RESOURCES;
> > > }
> > > --
> > > 2.39.2
next prev parent reply other threads:[~2023-03-24 15:35 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-24 13:41 [PATCH 1/1] UefiCpuPkg/PiSmmCpuDxeSmm: fix format string Gerd Hoffmann
2023-03-24 13:59 ` Ni, Ray
2023-03-24 15:27 ` Michael D Kinney
2023-03-24 15:35 ` Michael D Kinney [this message]
2023-03-24 14:56 ` Laszlo Ersek
2023-03-24 14:58 ` Laszlo Ersek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CO1PR11MB4929064E2D66FF54D1D2163ED2849@CO1PR11MB4929.namprd11.prod.outlook.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox