From nobody Mon Feb 9 02:28:38 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+79399+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+79399+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1629176927; cv=none; d=zohomail.com; s=zohoarc; b=hJBXZqWfZS8F/S016pkVpx2gha8NqTIeM0AOJ/JNdFpM6TuJZ8roUATppqOx9Gw442N4Z4UCuNW4DNtYE/cLKp0/j8sESXsKzUPcy1tc2boFBM37GujzZEPrYBEHNMWSfhzXB7bA4U4RXec3fEVZw3c+uGFtA9ExV/W+c0HnnCU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629176927; h=Content-Type: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=9e4EhVig4/+2nVjG9vsES5d/CHm4W7naXVRpc5c9qMM=; b=B6srv3OvL/26CE14bCcqBXzZM3uH39FEjH5AEsoq2sn2cWfAu2W11TdfuaV9SsqulhPSr4GeLTfTfI223WWiUXU1cEq1PTBzL4+OmhizyHdS4AesoypBYxEfCs0/Gf6Uvufd0zdRH2RI2xhwi20qtt34AO65ROWBgaPEdq4Ee/w= 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+79399+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 1629176927778607.2881262381399; Mon, 16 Aug 2021 22:08:47 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 6DfqYY1788612xJOWNVJwPYf; Mon, 16 Aug 2021 22:08:47 -0700 X-Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com [209.85.216.47]) by mx.groups.io with SMTP id smtpd.web11.34913.1629176927034237213 for ; Mon, 16 Aug 2021 22:08:47 -0700 X-Received: by mail-pj1-f47.google.com with SMTP id bo18so30288198pjb.0 for ; Mon, 16 Aug 2021 22:08:46 -0700 (PDT) X-Gm-Message-State: ZOQtAGcfRDweJyrecEqXCh1Rx1787277AA= X-Google-Smtp-Source: ABdhPJyYzeX7fhkYbfc2Ty20gurzv0lY1eQpFMiKfGGuKQBQ1W1vSYppOXW229ibBhiFHZHMFBktIA== X-Received: by 2002:a17:90a:a96:: with SMTP id 22mr1684387pjw.156.1629176926419; Mon, 16 Aug 2021 22:08:46 -0700 (PDT) X-Received: from localhost.localdomain ([50.35.88.161]) by smtp.gmail.com with ESMTPSA id i5sm737965pjk.47.2021.08.16.22.08.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Aug 2021 22:08:46 -0700 (PDT) From: "Kun Qin" To: devel@edk2.groups.io Cc: Michael D Kinney , Liming Gao , Zhiguang Liu , Hao A Wu , =?UTF-8?q?Marvin=20H=C3=A4user?= , Bret Barkelew , Michael Kubacki Subject: [edk2-devel] [PATCH v3 2/7] MdePkg: MmCommunication: Introduce EFI_MM_COMMUNICATE_HEADER_V3 to MdePkg Date: Mon, 16 Aug 2021 22:08:02 -0700 Message-Id: <20210817050807.766-3-kuqin12@gmail.com> In-Reply-To: <20210817050807.766-1-kuqin12@gmail.com> References: <20210817050807.766-1-kuqin12@gmail.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,kuqin12@gmail.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1629176927; bh=4XNqF/LXqewbcdDbeAY7Af2FRZadK4U/CdoIKwfN+OI=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=q34ZSpLEV6VNShwdcpXy8MdSfS+cXEK3xJBB0OHlbPRH7atEz41WF/P5bbOgPe9GNPl L4BpwrZeJ1k1AYy6XfufzFyiDZWflmAJf393pAkm1M1X2sycTkMGbB9Zk8QvcR/MFKbuf x3MAdSr8R18YYZrJInZTmiAVlhUn6kvKkhc= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1629176928414100005 REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3398 REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3430 This change introduces a new definition for MM communicate header structure, intending to provide better portability between different architectures (IA32 & X64) and adapt to flexible array supported by modern compilers. The original MessageLength field of EFI_MM_COMMUNICATE_HEADER, as a generic definition, was used for both PEI and DXE MM communication. On a system that supports PEI MM launch, but operates PEI in 32bit mode and MM foundation in 64bit, the current EFI_MM_COMMUNICATE_HEADER definition will cause structure parse error due to UINTN used. This introduction removes the architecture dependent field by defining this field as UINT64. The new signature could help identifying whether the data received is compiliant with this new data structure, which will help for binary release modules to identify usage of legacy data structure. Version field is also added to indicate the current version of header in case there is need for minor modification in the future. The data field of MM communicate message is replaced with flexible array to allow users not having to consume extra data during communicate and author code more intrinsically. Cc: Michael D Kinney Cc: Liming Gao Cc: Zhiguang Liu Cc: Hao A Wu Cc: Marvin H=C3=A4user Cc: Bret Barkelew Cc: Michael Kubacki Signed-off-by: Kun Qin --- Notes: v3: - Newly introduced communicate v3 - Used flexible arrays [Marvin] - Added static assert [Michael] MdePkg/Include/Pi/PiMultiPhase.h | 55 ++++++++++++++++++++ MdePkg/MdePkg.dec | 5 ++ 2 files changed, 60 insertions(+) diff --git a/MdePkg/Include/Pi/PiMultiPhase.h b/MdePkg/Include/Pi/PiMultiPh= ase.h index 89280d9d3506..8c60338091b3 100644 --- a/MdePkg/Include/Pi/PiMultiPhase.h +++ b/MdePkg/Include/Pi/PiMultiPhase.h @@ -103,6 +103,17 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #define EFI_SMRAM_CLOSED EFI_MMRAM_CLOSED #define EFI_SMRAM_LOCKED EFI_MMRAM_LOCKED =20 +/// +/// MM Communicate header constants +/// +#define COMMUNICATE_HEADER_V3_GUID \ + { \ + 0x68e8c853, 0x2ba9, 0x4dd7, { 0x9a, 0xc0, 0x91, 0xe1, 0x61, 0x55, 0xc9= , 0x35 } \ + } + +#define EFI_MM_COMMUNICATE_HEADER_V3_SIGNATURE 0x4D434833 // "MCH3" +#define EFI_MM_COMMUNICATE_HEADER_V3_VERSION 3 + /// /// Structure describing a MMRAM region and its accessibility attributes. /// @@ -149,6 +160,48 @@ typedef struct _EFI_MM_RESERVED_MMRAM_REGION { UINT64 MmramReservedSize; } EFI_MM_RESERVED_MMRAM_REGION; =20 +#pragma pack(1) + +/// +/// To avoid confusion in interpreting frames, the buffer communicating to= MM core through +/// EFI_MM_COMMUNICATE3 or later should always start with EFI_MM_COMMUNICA= TE_HEADER_V3. +/// +typedef struct { + /// + /// Indicator GUID for MM core that the communication buffer is complian= t with this v3 header. + /// Must be gCommunicateHeaderV3Guid. + /// + EFI_GUID HeaderGuid; + /// + /// Signature to indicate data is compliant with new MM communicate head= er structure. + /// Must be "MCH3". + /// + UINT32 Signature; + /// + /// MM communicate data format version, MM foundation entry point should= check if incoming + /// data is a supported format before proceeding. + /// Must be 3. + /// + UINT32 Version; + /// + /// Allows for disambiguation of the message format. + /// + EFI_GUID MessageGuid; + /// + /// Describes the size of MessageData (in bytes) and does not include th= e size of the header. + /// + UINT64 MessageSize; + /// + /// Designates an array of bytes that is MessageSize in size. + /// + UINT8 MessageData[]; +} EFI_MM_COMMUNICATE_HEADER_V3; + +#pragma pack() + +STATIC_ASSERT ((sizeof (EFI_MM_COMMUNICATE_HEADER_V3) =3D=3D OFFSET_OF (EF= I_MM_COMMUNICATE_HEADER_V3, MessageData)), \ + "sizeof (EFI_MM_COMMUNICATE_HEADER_V3) does not align with the beginning= of flexible array MessageData"); + typedef enum { EFI_PCD_TYPE_8, EFI_PCD_TYPE_16, @@ -208,4 +261,6 @@ EFI_STATUS IN VOID *ProcedureArgument ); =20 +extern EFI_GUID gCommunicateHeaderV3Guid; + #endif diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec index a28a2daaffa8..411079a4343e 100644 --- a/MdePkg/MdePkg.dec +++ b/MdePkg/MdePkg.dec @@ -823,6 +823,11 @@ [Guids] # gLinuxEfiInitrdMediaGuid =3D {0x5568e427, 0x68fc, 0x4f3d, {0xac, 0= x74, 0xca, 0x55, 0x52, 0x31, 0xcc, 0x68}} =20 + # + # GUID indicates the MM communication data is compliant with v3 communic= ation header. + # + gCommunicateHeaderV3Guid =3D { 0x68e8c853, 0x2ba9, 0x4dd7, { 0x9a,= 0xc0, 0x91, 0xe1, 0x61, 0x55, 0xc9, 0x35 } } + [Guids.IA32, Guids.X64] ## Include/Guid/Cper.h gEfiIa32X64ErrorTypeCacheCheckGuid =3D { 0xA55701F5, 0xE3EF, 0x43de, { 0= xAC, 0x72, 0x24, 0x9B, 0x57, 0x3F, 0xAD, 0x2C }} --=20 2.32.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 (#79399): https://edk2.groups.io/g/devel/message/79399 Mute This Topic: https://groups.io/mt/84941519/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-