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>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Signed-off-by: Mark Wilson <Mark.Wilson@amd.com>
This commit is contained in:
Mark Wilson 2020-11-13 08:05:18 +08:00 committed by mergify[bot]
parent 3b3f882288
commit b170806518
1 changed files with 6 additions and 6 deletions

View File

@ -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);
}
@ -546,12 +546,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);
}