* [PATCH v2 0/1] UefiCpuPkg: Clean up save state boundary checks and comments. @ 2020-11-13 0:05 Mark Wilson 2020-11-13 0:05 ` [PATCH v3 1/1] " Mark Wilson 2020-11-13 22:43 ` [edk2-devel] [PATCH v2 0/1] " Laszlo Ersek 0 siblings, 2 replies; 4+ messages in thread From: Mark Wilson @ 2020-11-13 0:05 UTC (permalink / raw) To: devel 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. Mark Wilson (1): UefiCpuPkg: Clean up save state boundary checks and comments. UefiCpuPkg/PiSmmCpuDxeSmm/SmramSaveState.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) -- 2.28.0.windows.1 ^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v3 1/1] UefiCpuPkg: Clean up save state boundary checks and comments. 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 ` Mark Wilson 2021-08-26 17:55 ` Ni, Ray 2020-11-13 22:43 ` [edk2-devel] [PATCH v2 0/1] " Laszlo Ersek 1 sibling, 1 reply; 4+ messages in thread From: Mark Wilson @ 2020-11-13 0:05 UTC (permalink / raw) To: devel; +Cc: Eric Dong, Ray Ni 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 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v3 1/1] UefiCpuPkg: Clean up save state boundary checks and comments. 2020-11-13 0:05 ` [PATCH v3 1/1] " Mark Wilson @ 2021-08-26 17:55 ` Ni, Ray 0 siblings, 0 replies; 4+ messages in thread From: Ni, Ray @ 2021-08-26 17:55 UTC (permalink / raw) To: Mark Wilson, devel@edk2.groups.io; +Cc: Dong, Eric 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 ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [edk2-devel] [PATCH v2 0/1] UefiCpuPkg: Clean up save state boundary checks and comments. 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 @ 2020-11-13 22:43 ` Laszlo Ersek 1 sibling, 0 replies; 4+ messages in thread From: Laszlo Ersek @ 2020-11-13 22:43 UTC (permalink / raw) To: Eric Dong, Ray Ni; +Cc: devel, mark.wilson On 11/13/20 01:05, Mark Wilson wrote: > 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. > > Mark Wilson (1): > UefiCpuPkg: Clean up save state boundary checks and comments. > > UefiCpuPkg/PiSmmCpuDxeSmm/SmramSaveState.c | 12 ++++++------ > 1 file changed, 6 insertions(+), 6 deletions(-) > Eric, Ray: please review this patch; I'm swamped. Thanks Laszlo ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-08-26 17:55 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 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 2020-11-13 22:43 ` [edk2-devel] [PATCH v2 0/1] " Laszlo Ersek
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox