public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Ma, Maurice" <maurice.ma@intel.com>
To: "Jiang, Guomin" <guomin.jiang@intel.com>,
	"devel@edk2.groups.io" <devel@edk2.groups.io>
Cc: "Dong, Guo" <guo.dong@intel.com>, "Ni, Ray" <ray.ni@intel.com>,
	"You, Benjamin" <benjamin.you@intel.com>
Subject: Re: [Patch V2 1/1] UefiPayloadPkg/PayloadLoaderPeim: Force UINTN before save Ptr
Date: Thu, 10 Feb 2022 14:58:51 +0000	[thread overview]
Message-ID: <CO1PR11MB494530E78A1D932FF1A480C5892F9@CO1PR11MB4945.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20220210030302.2016-1-guomin.jiang@intel.com>

Reviewed-by: Maurice Ma <maurice.ma@intel.com>

> -----Original Message-----
> From: Jiang, Guomin <guomin.jiang@intel.com>
> Sent: Wednesday, February 9, 2022 19:03
> To: devel@edk2.groups.io
> Cc: Dong, Guo <guo.dong@intel.com>; Ni, Ray <ray.ni@intel.com>; Ma,
> Maurice <maurice.ma@intel.com>; You, Benjamin <benjamin.you@intel.com>
> Subject: [Patch V2 1/1] UefiPayloadPkg/PayloadLoaderPeim: Force UINTN
> before save Ptr
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3818
> 
> It will have some potential issue when memory larger than 2G because the high
> memory address will be fill with 0xFFFFFFFF when do the operation of UINT64 +
> INTN.
> 
> V2:
> 1. Force the data type to UINTN to avoid high dword be filled with 0xFFFFFFFF 2.
> Keep INTN because the offset may postive or negative.
> 
> Cc: Guo Dong <guo.dong@intel.com>
> Cc: Ray Ni <ray.ni@intel.com>
> Cc: Maurice Ma <maurice.ma@intel.com>
> Cc: Benjamin You <benjamin.you@intel.com>
> Signed-off-by: Guomin Jiang <guomin.jiang@intel.com>
> ---
>  UefiPayloadPkg/PayloadLoaderPeim/ElfLib/Elf64Lib.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/UefiPayloadPkg/PayloadLoaderPeim/ElfLib/Elf64Lib.c
> b/UefiPayloadPkg/PayloadLoaderPeim/ElfLib/Elf64Lib.c
> index dc47a05c6e4a..68200fcadd3f 100644
> --- a/UefiPayloadPkg/PayloadLoaderPeim/ElfLib/Elf64Lib.c
> +++ b/UefiPayloadPkg/PayloadLoaderPeim/ElfLib/Elf64Lib.c
> @@ -143,7 +143,7 @@ ProcessRelocation64 (
>            DEBUG ((DEBUG_INFO, "Unsupported relocation type %02X\n", Type));
>            ASSERT (FALSE);
>          } else {
> -          *Ptr += Delta;
> +          *Ptr = *(UINTN *)Ptr + Delta;
>          }
> 
>          break;
> @@ -177,12 +177,12 @@ ProcessRelocation64 (
>            // Calculation: B + A
>            //
>            if (RelaType == SHT_RELA) {
> -            *Ptr = Delta + Rela->r_addend;
> +            *Ptr = Delta + (UINTN)Rela->r_addend;
>            } else {
>              //
>              // A is stored in the field of relocation for REL type.
>              //
> -            *Ptr = Delta + *Ptr;
> +            *Ptr = Delta + *(UINTN *)Ptr;
>            }
>          } else {
>            //
> --
> 2.30.0.windows.2


      parent reply	other threads:[~2022-02-10 14:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-10  3:03 [Patch V2 1/1] UefiPayloadPkg/PayloadLoaderPeim: Force UINTN before save Ptr Guomin Jiang
2022-02-10  5:34 ` Ni, Ray
2022-02-10 14:58 ` Ma, Maurice [this message]

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=CO1PR11MB494530E78A1D932FF1A480C5892F9@CO1PR11MB4945.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