From nobody Sun Feb 8 07:52:40 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+78711+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+78711+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=linux.microsoft.com ARC-Seal: i=1; a=rsa-sha256; t=1628175453; cv=none; d=zohomail.com; s=zohoarc; b=lYkFxvUO3FgXkA+nqTSGeyCSbpDVLLd3iIrgssPDbGY5M2bk+E0JGzAgjg4cIa9oVwiwliC1Wk7j2Qv/3rxU8YGVg3OUcfCxyZ5kFtPD1t37OlQinJEz2xuWaiBi0C77q3hzO+FcyRdDy4JPqUPDXDcA9WvQkVz2ZtPZckR3sSg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1628175453; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=ld4WDHW9ujuYmdHHje59MkH7KXOn3oVBZYOKDOZZJjU=; b=I/0XlUIoBEEIX93UqY5PkZUE1UY64NL5n3+zy78vyJ/+YNUh2mpONSy8LWlXbg2EGh5B5vcT3lxscFRWeFisMaYZ+P7WvZbxWJ9/KrCvtdl7H1syuGIjuUVA6GZvbsLQJV0d4Gan6/ZrEJKNsV5+5wkZNeM8FRemOF0P5cOUUdI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+78711+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1628175453350131.76453542767842; Thu, 5 Aug 2021 07:57:33 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 82x9YY1788612xZnKOTirLKS; Thu, 05 Aug 2021 07:57:33 -0700 X-Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mx.groups.io with SMTP id smtpd.web10.9902.1628175452546461631 for ; Thu, 05 Aug 2021 07:57:32 -0700 X-Received: from localhost.localdomain (unknown [167.220.2.74]) by linux.microsoft.com (Postfix) with ESMTPSA id 2AE0220B36EA; Thu, 5 Aug 2021 07:57:32 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 2AE0220B36EA From: "Michael Kubacki" To: devel@edk2.groups.io Cc: Chasel Chiu , Nate DeSimone , Liming Gao , Eric Dong Subject: [edk2-devel] [edk2-platforms][PATCH v1 1/5] MinPlatformPkg/TestPointCheckLib: Fix MessageLength cast issue Date: Thu, 5 Aug 2021 10:57:02 -0400 Message-Id: <20210805145706.2470-2-mikuback@linux.microsoft.com> In-Reply-To: <20210805145706.2470-1-mikuback@linux.microsoft.com> References: <20210805145706.2470-1-mikuback@linux.microsoft.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,mikuback@linux.microsoft.com X-Gm-Message-State: QDgBdUqTaMwaYRA1JdF9NhlCx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1628175453; bh=YDTGy+kTx+mImBDacUogsojGox5KjdR8QdH5AeDyOy0=; h=Cc:Date:From:Reply-To:Subject:To; b=jk7hWc7f0mHDRf1Ovt6uzayhbHdN8i+gO/vAbW2rHR7YtW9pBXltw4zf1UtdnRRpLwf NqQ9HqP2x2BEPph9aqKhAQJXWx3MohmT26N0wf726lQy4w7vSSnP9S0Fpq+6Mg/blWiy/ pDMSo+WKdJFh3rcNx/ifd0+Ny9+PJ3WYoVs= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1628175455009100001 Content-Type: text/plain; charset="utf-8" From: Michael Kubacki REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3D3531 The MessageLength field of EFI_MM_COMMUNICATE_HEADER as defined in MdePkg/Include/Protocol/MmCommunication.h was updated to a fixed size as opposed to UINTN to avoid ambiguity between different caller enviornments. This change updates the MessageLength usage in MinPlatformPkg to support the new field structure, in turn, fixing a build issue. Original edk2 change: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3398 Cc: Chasel Chiu Cc: Nate DeSimone Cc: Liming Gao Cc: Eric Dong Signed-off-by: Michael Kubacki Reviewed-by: Nate DeSimone --- Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckSmiHa= ndlerInstrument.c | 4 ++-- Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeTestPointC= heckLib.c | 15 ++++++++++++++- Platform/Intel/MinPlatformPkg/Test/TestPointStubDxe/TestPointStubDxe.c = | 10 +++++----- Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeTestPointC= heckLib.inf | 1 + 4 files changed, 22 insertions(+), 8 deletions(-) diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/D= xeCheckSmiHandlerInstrument.c b/Platform/Intel/MinPlatformPkg/Test/Library/= TestPointCheckLib/DxeCheckSmiHandlerInstrument.c index 3ceeb821fb95..80e8d26f4e1d 100644 --- a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheck= SmiHandlerInstrument.c +++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheck= SmiHandlerInstrument.c @@ -106,7 +106,7 @@ GetSmiHandlerProfileDatabase( CommGetInfo->Header.ReturnStatus =3D (UINT64)-1; CommGetInfo->DataSize =3D 0; =20 - CommSize =3D sizeof(EFI_GUID) + sizeof(UINTN) + CommHeader->MessageLengt= h; + CommSize =3D OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data) + (UINTN)CommH= eader->MessageLength; Status =3D SmmCommunication->Communicate(SmmCommunication, CommBuffer, &= CommSize); if (EFI_ERROR(Status)) { DEBUG ((DEBUG_INFO, "SmiHandlerProfile: SmmCommunication - %r\n", Stat= us)); @@ -139,7 +139,7 @@ GetSmiHandlerProfileDatabase( CommGetData->Header.DataLength =3D sizeof(*CommGetData); CommGetData->Header.ReturnStatus =3D (UINT64)-1; =20 - CommSize =3D sizeof(EFI_GUID) + sizeof(UINTN) + CommHeader->MessageLengt= h; + CommSize =3D OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data) + (UINTN)CommH= eader->MessageLength; Buffer =3D (UINT8 *)CommHeader + CommSize; Size -=3D CommSize; =20 diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/D= xeTestPointCheckLib.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPoin= tCheckLib/DxeTestPointCheckLib.c index c012e0afcbaa..e5efbd059954 100644 --- a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeTestP= ointCheckLib.c +++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeTestP= ointCheckLib.c @@ -12,6 +12,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include #include #include +#include #include #include #include @@ -520,6 +521,7 @@ TestPointDxeSmmReadyToBootSmmPageProtection ( UINTN MemoryAttributesTabl= eSize; EFI_STATUS Status; UINTN CommSize; + UINT64 LongCommSize; UINT8 *CommBuffer; EFI_SMM_COMMUNICATE_HEADER *CommHeader; EFI_SMM_COMMUNICATION_PROTOCOL *SmmCommunication; @@ -620,7 +622,18 @@ TestPointDxeSmmReadyToBootSmmPageProtection ( (UINTN)CommData->UefiMemoryAttributeTableSize ); =20 - CommSize =3D OFFSET_OF(EFI_SMM_COMMUNICATE_HEADER, Data) + CommHeader->M= essageLength; + Status =3D SafeUint64Add (OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data), = CommHeader->MessageLength, &LongCommSize); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_INFO, "TestPointDxeSmmReadyToBootSmmPageProtection: Long= CommSize calculation - %r\n", Status)); + return EFI_SUCCESS; + } + + Status =3D SafeUint64ToUintn (LongCommSize, &CommSize); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_INFO, "TestPointDxeSmmReadyToBootSmmPageProtection: Comm= Size conversion - %r\n", Status)); + return EFI_SUCCESS; + } + Status =3D SmmCommunication->Communicate(SmmCommunication, CommBuffer, &= CommSize); if (EFI_ERROR(Status)) { DEBUG ((DEBUG_INFO, "TestPointDxeSmmReadyToBootSmmPageProtection: SmmC= ommunication - %r\n", Status)); diff --git a/Platform/Intel/MinPlatformPkg/Test/TestPointStubDxe/TestPointS= tubDxe.c b/Platform/Intel/MinPlatformPkg/Test/TestPointStubDxe/TestPointStu= bDxe.c index 3cc5ccfef6f4..8416b36f56ae 100644 --- a/Platform/Intel/MinPlatformPkg/Test/TestPointStubDxe/TestPointStubDxe.c +++ b/Platform/Intel/MinPlatformPkg/Test/TestPointStubDxe/TestPointStubDxe.c @@ -122,7 +122,7 @@ GetTestPointDataSmm ( CommGetInfo->Header.ReturnStatus =3D (UINT64)-1; CommGetInfo->DataSize =3D 0; =20 - CommSize =3D sizeof(EFI_GUID) + sizeof(UINTN) + CommHeader->MessageLengt= h; + CommSize =3D OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data) + (UINTN)CommH= eader->MessageLength; Status =3D SmmCommunication->Communicate(SmmCommunication, CommBuffer, &= CommSize); if (EFI_ERROR(Status)) { DEBUG ((DEBUG_INFO, "SmiHandlerTestPoint: SmmCommunication - %r\n", St= atus)); @@ -155,7 +155,7 @@ GetTestPointDataSmm ( CommGetData->Header.DataLength =3D sizeof(*CommGetData); CommGetData->Header.ReturnStatus =3D (UINT64)-1; =20 - CommSize =3D sizeof(EFI_GUID) + sizeof(UINTN) + CommHeader->MessageLengt= h; + CommSize =3D OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data) + (UINTN)CommH= eader->MessageLength; Buffer =3D (UINT8 *)CommHeader + CommSize; Size -=3D CommSize; =20 @@ -233,7 +233,7 @@ PublishSmmTestPoint ( TestPoint =3D mSmmTestPointDatabase; while ((UINTN)TestPoint < (UINTN)mSmmTestPointDatabase + mSmmTestPointDa= tabaseSize) { TestPointSize =3D GetTestPointInfoSize (TestPoint, (UINTN)mSmmTestPoin= tDatabase + mSmmTestPointDatabaseSize - (UINTN)TestPoint); - =20 + TestPointLibSetTable (TestPoint, TestPointSize); =20 TestPoint =3D (ADAPTER_INFO_PLATFORM_TEST_POINT *)((UINTN)TestPoint + = TestPointSize); @@ -286,7 +286,7 @@ OnReadyToBoot ( EFI_EVENT ReadyToBootLaterEvent; =20 gBS->CloseEvent (Event); - =20 + Status =3D gBS->CreateEvent ( EVT_NOTIFY_SIGNAL, TPL_CALLBACK, @@ -295,7 +295,7 @@ OnReadyToBoot ( &ReadyToBootLaterEvent ); ASSERT_EFI_ERROR (Status); - =20 + gBS->SignalEvent (ReadyToBootLaterEvent); } =20 diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/D= xeTestPointCheckLib.inf b/Platform/Intel/MinPlatformPkg/Test/Library/TestPo= intCheckLib/DxeTestPointCheckLib.inf index 2ae1db4ee483..54b4015d6767 100644 --- a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeTestP= ointCheckLib.inf +++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeTestP= ointCheckLib.inf @@ -32,6 +32,7 @@ [LibraryClasses] TestPointLib PciSegmentLib PciSegmentInfoLib + SafeIntLib =20 [Packages] MinPlatformPkg/MinPlatformPkg.dec --=20 2.28.0.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#78711): https://edk2.groups.io/g/devel/message/78711 Mute This Topic: https://groups.io/mt/84686303/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-