[edk2-devel] [PATCH v2 4/6] MdeModulePkg: SmiHandlerProfileInfo: Updated MessageLength calculation
Wu, Hao A
hao.a.wu at intel.com
Wed Jun 23 01:33:20 UTC 2021
> -----Original Message-----
> From: devel at edk2.groups.io <devel at edk2.groups.io> On Behalf Of Kun Qin
> Sent: Friday, June 18, 2021 5:03 PM
> To: devel at edk2.groups.io
> Cc: Wang, Jian J <jian.j.wang at intel.com>; Wu, Hao A <hao.a.wu at intel.com>;
> Dong, Eric <eric.dong at intel.com>; Ni, Ray <ray.ni at intel.com>
> Subject: [edk2-devel] [PATCH v2 4/6] MdeModulePkg: SmiHandlerProfileInfo:
> Updated MessageLength calculation
>
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3398
>
> This change replaced the calculation of communication buffer size from
> explicitly adding the size of each member with the OFFSET macro function.
> This will make the structure field defition change transparent to consumers.
>
> Cc: Jian J Wang <jian.j.wang at intel.com>
> Cc: Hao A Wu <hao.a.wu at intel.com>
> Cc: Eric Dong <eric.dong at intel.com>
> Cc: Ray Ni <ray.ni at intel.com>
>
> Signed-off-by: Kun Qin <kuqin12 at gmail.com>
> ---
>
> Notes:
> v2:
> - Updated comments by removing "BZ" tags [Hao]
Reviewed-by: Hao A Wu <hao.a.wu at intel.com>
Best Regards,
Hao Wu
>
> MdeModulePkg/Application/SmiHandlerProfileInfo/SmiHandlerProfileInfo.c
> | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git
> a/MdeModulePkg/Application/SmiHandlerProfileInfo/SmiHandlerProfileInfo
> .c
> b/MdeModulePkg/Application/SmiHandlerProfileInfo/SmiHandlerProfileInfo
> .c
> index 4153074b7a80..4bfd5946caba 100644
> ---
> a/MdeModulePkg/Application/SmiHandlerProfileInfo/SmiHandlerProfileInfo
> .c
> +++
> b/MdeModulePkg/Application/SmiHandlerProfileInfo/SmiHandlerProfileIn
> +++ fo.c
> @@ -116,7 +116,10 @@ GetSmiHandlerProfileDatabase(
> CommGetInfo->Header.ReturnStatus = (UINT64)-1;
> CommGetInfo->DataSize = 0;
>
> - CommSize = sizeof(EFI_GUID) + sizeof(UINTN) + CommHeader-
> >MessageLength;
> + //
> + // The CommHeader->MessageLength contains a definitive value, thus
> UINTN cast is safe here.
> + //
> + CommSize = OFFSET_OF(EFI_SMM_COMMUNICATE_HEADER, Data) +
> + (UINTN)CommHeader->MessageLength;
> Status = SmmCommunication->Communicate(SmmCommunication,
> CommBuffer, &CommSize);
> if (EFI_ERROR(Status)) {
> Print(L"SmiHandlerProfile: SmmCommunication - %r\n", Status); @@ -
> 149,7 +152,10 @@ GetSmiHandlerProfileDatabase(
> CommGetData->Header.DataLength = sizeof(*CommGetData);
> CommGetData->Header.ReturnStatus = (UINT64)-1;
>
> - CommSize = sizeof(EFI_GUID) + sizeof(UINTN) + CommHeader-
> >MessageLength;
> + //
> + // The CommHeader->MessageLength contains a definitive value, thus
> UINTN cast is safe here.
> + //
> + CommSize = OFFSET_OF(EFI_SMM_COMMUNICATE_HEADER, Data) +
> + (UINTN)CommHeader->MessageLength;
> Buffer = (UINT8 *)CommHeader + CommSize;
> Size -= CommSize;
>
> --
> 2.31.1.windows.1
>
>
>
>
>
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#76881): https://edk2.groups.io/g/devel/message/76881
Mute This Topic: https://groups.io/mt/83624118/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-
More information about the edk2-devel-archive
mailing list