From: "Laszlo Ersek" <lersek@redhat.com>
To: devel@edk2.groups.io, Mark.Wilson@amd.com
Cc: Eric Dong <eric.dong@intel.com>, Ray Ni <ray.ni@intel.com>
Subject: Re: [edk2-devel] [PATCH v1 1/1] UefiCpuPkg: Clean up save state boundary checks and comments.
Date: Mon, 19 Oct 2020 20:06:34 +0200 [thread overview]
Message-ID: <e44c0619-81a2-7cfa-fdb2-92dedff30516@redhat.com> (raw)
In-Reply-To: <f9bd4986-37ed-a8ea-cedd-7bab7b17b42c@redhat.com>
On 10/19/20 20:03, Laszlo Ersek wrote:
> Hi Mark,
>
> On 10/15/20 18:32, Mark Wilson wrote:
>> 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.
>> * Update related comments to better describe code.
>>
>> 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 | 26 ++++++++++----------
>> 1 file changed, 13 insertions(+), 13 deletions(-)
>
> I suggest separating the cosmetic changes (such as the whitespace fixes)
> from the cleanups (comments etc) to different patches.
>
> Also, please run "BaseTools/Scripts/SetupGit.py" in your edk2 clone.
Furthermore, I suggest a bit more specific subject:
UefiCpuPkg/PiSmmCpuDxeSmm: clean up save state boundary checks and comments
(I think this subject length, i.e. 75 characters, should still satisfy "PatchCheck.py".)
Sorry about the piecemeal observations; trying to deal with a bit of a backlog.
Thanks
Laszlo
>>
>> diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/SmramSaveState.c b/UefiCpuPkg/PiSmmCpuDxeSmm/SmramSaveState.c
>> index 661cc51f361a..4a872e400b7a 100644
>> --- a/UefiCpuPkg/PiSmmCpuDxeSmm/SmramSaveState.c
>> +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/SmramSaveState.c
>> @@ -297,8 +297,8 @@ ReadSaveStateRegisterByIndex (
>> //
>>
>> // Write return buffer
>>
>> //
>>
>> - ASSERT(CpuSaveState != NULL);
>>
>> - CopyMem(Buffer, (UINT8 *)CpuSaveState + mSmmCpuWidthOffset[RegisterIndex].Offset32, Width);
>>
>> + ASSERT (CpuSaveState != NULL);
>>
>> + CopyMem (Buffer, (UINT8 *)CpuSaveState + mSmmCpuWidthOffset[RegisterIndex].Offset32, Width);
>>
>> } else {
>>
>> //
>>
>> // If 64-bit mode width is zero, then the specified register can not be accessed
>>
>> @@ -315,14 +315,14 @@ 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) {
>>
>> + CopyMem (Buffer, (UINT8 *)CpuSaveState + mSmmCpuWidthOffset[RegisterIndex].Offset64Lo, MIN(4, Width));
>>
>> + 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);
>>
>> + CopyMem ((UINT8 *)Buffer + 4, (UINT8 *)CpuSaveState + mSmmCpuWidthOffset[RegisterIndex].Offset64Hi, Width - 4);
>>
>> }
>>
>> }
>>
>> return EFI_SUCCESS;
>>
>> @@ -522,7 +522,7 @@ WriteSaveStateRegister (
>> // Write SMM State register
>>
>> //
>>
>> ASSERT (CpuSaveState != NULL);
>>
>> - CopyMem((UINT8 *)CpuSaveState + mSmmCpuWidthOffset[RegisterIndex].Offset32, Buffer, Width);
>>
>> + CopyMem ((UINT8 *)CpuSaveState + mSmmCpuWidthOffset[RegisterIndex].Offset32, Buffer, Width);
>>
>> } else {
>>
>> //
>>
>> // If 64-bit mode width is zero, then the specified register can not be accessed
>>
>> @@ -539,14 +539,14 @@ 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) {
>>
>> + CopyMem ((UINT8 *)CpuSaveState + mSmmCpuWidthOffset[RegisterIndex].Offset64Lo, Buffer, MIN (4, Width));
>>
>> + 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);
>>
>> + CopyMem ((UINT8 *)CpuSaveState + mSmmCpuWidthOffset[RegisterIndex].Offset64Hi, (UINT8 *)Buffer + 4, Width - 4);
>>
>> }
>>
>> }
>>
>> return EFI_SUCCESS;
>>
>
next prev parent reply other threads:[~2020-10-19 18:06 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-15 16:32 [PATCH v1 0/1] Clean up save state boundary checks and comments in functions ReadSaveStateRegisterByIndex and WriteSaveStateRegister Mark Wilson
2020-10-15 16:32 ` [PATCH v1 1/1] UefiCpuPkg: Clean up save state boundary checks and comments Mark Wilson
2020-10-19 18:03 ` [edk2-devel] " Laszlo Ersek
2020-10-19 18:06 ` Laszlo Ersek [this message]
2020-11-11 16:20 ` Mark Wilson
2020-11-11 22:37 ` 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=e44c0619-81a2-7cfa-fdb2-92dedff30516@redhat.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