public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Ni, Ray" <ray.ni@intel.com>
To: Mark Wilson <Mark.Wilson@amd.com>,
	"devel@edk2.groups.io" <devel@edk2.groups.io>
Cc: "Dong, Eric" <eric.dong@intel.com>
Subject: Re: [PATCH v3 1/1] UefiCpuPkg: Clean up save state boundary checks and comments.
Date: Thu, 26 Aug 2021 17:55:23 +0000	[thread overview]
Message-ID: <CO1PR11MB493008EFCD38D93453A9DA4B8CC79@CO1PR11MB4930.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20201113000518.338-2-Mark.Wilson@amd.com>

Though CopyMem() copies nothing when Length equals to 0, I agree this patch to totally skip the CopyMem() call.

Reviewed-by: Ray Ni <ray.ni@intel.com>

> -----Original Message-----
> From: Mark Wilson <Mark.Wilson@amd.com>
> Sent: Friday, November 13, 2020 8:05 AM
> To: devel@edk2.groups.io
> Cc: Dong, Eric <eric.dong@intel.com>; Ni, Ray <ray.ni@intel.com>
> Subject: [PATCH v3 1/1] UefiCpuPkg: Clean up save state boundary checks and comments.
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2956
> 
> In functions ReadSaveStateRegisterByIndex and WriteSaveStateRegister:
> * check width > 4 instead of >= 4 when writing upper 32 bytes.
>   - This improves the code but will not affect functionality.
> 
> Cc: Eric Dong <eric.dong@intel.com>
> Cc: Ray Ni <ray.ni@intel.com>
> Signed-off-by: Mark Wilson <Mark.Wilson@amd.com>
> ---
>  UefiCpuPkg/PiSmmCpuDxeSmm/SmramSaveState.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/SmramSaveState.c b/UefiCpuPkg/PiSmmCpuDxeSmm/SmramSaveState.c
> index 661cc51f361a..0ab5e1ba0f14 100644
> --- a/UefiCpuPkg/PiSmmCpuDxeSmm/SmramSaveState.c
> +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/SmramSaveState.c
> @@ -315,12 +315,12 @@ ReadSaveStateRegisterByIndex (
>      }
> 
> 
> 
>      //
> 
> -    // Write lower 32-bits of return buffer
> 
> +    // Write at most 4 of the lower bytes of the return buffer
> 
>      //
> 
>      CopyMem(Buffer, (UINT8 *)CpuSaveState + mSmmCpuWidthOffset[RegisterIndex].Offset64Lo, MIN(4, Width));
> 
> -    if (Width >= 4) {
> 
> +    if (Width > 4) {
> 
>        //
> 
> -      // Write upper 32-bits of return buffer
> 
> +      // Write at most 4 of the upper bytes of the return buffer
> 
>        //
> 
>        CopyMem((UINT8 *)Buffer + 4, (UINT8 *)CpuSaveState + mSmmCpuWidthOffset[RegisterIndex].Offset64Hi, Width - 4);
> 
>      }
> 
> @@ -539,12 +539,12 @@ WriteSaveStateRegister (
>      }
> 
> 
> 
>      //
> 
> -    // Write lower 32-bits of SMM State register
> 
> +    // Write at most 4 of the lower bytes of SMM State register
> 
>      //
> 
>      CopyMem((UINT8 *)CpuSaveState + mSmmCpuWidthOffset[RegisterIndex].Offset64Lo, Buffer, MIN (4, Width));
> 
> -    if (Width >= 4) {
> 
> +    if (Width > 4) {
> 
>        //
> 
> -      // Write upper 32-bits of SMM State register
> 
> +      // Write at most 4 of the upper bytes of SMM State register
> 
>        //
> 
>        CopyMem((UINT8 *)CpuSaveState + mSmmCpuWidthOffset[RegisterIndex].Offset64Hi, (UINT8 *)Buffer + 4, Width - 4);
> 
>      }
> 
> --
> 2.28.0.windows.1


  reply	other threads:[~2021-08-26 17:55 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-13  0:05 [PATCH v2 0/1] UefiCpuPkg: Clean up save state boundary checks and comments Mark Wilson
2020-11-13  0:05 ` [PATCH v3 1/1] " Mark Wilson
2021-08-26 17:55   ` Ni, Ray [this message]
2020-11-13 22:43 ` [edk2-devel] [PATCH v2 0/1] " 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=CO1PR11MB493008EFCD38D93453A9DA4B8CC79@CO1PR11MB4930.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