From nobody Tue Feb 10 02:49:31 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+58729+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+58729+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1588786082; cv=none; d=zohomail.com; s=zohoarc; b=Zla9bWMmfONLugSTsg6pZlOPGx6nEavtvzpMmXn2c87I9wmZ7zHDWp+SCARB9iAP3NJ4nmGGtAPJ8sQTU5hcYoe3aQ4Lw4Xegwbk6ZB3qBHaKLnqH7W07fEwi7Ahx8+U1yKHnDICl8NNMgfEKLrEFS5ql6qfSl6cWkRE/LwPQ9U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588786082; h=Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=E6+qCXimtrNnekdzWvRu2koF961iD8cxoasqU/nW8KE=; b=c5sQMKkICaCuLPiNwH67uwyLNqzFx7Poi52wY1ajJnET+jd+CrMnJGB1CMvfpU3iMxn5pyP+alLHDRBn32FJ20O3zkbj65PJ3N790TRhYVVCtUEPD0vT1+SA19lZYhRuRBMeBQNcYws3x9EmKaro3L6jBGfzNnKARCGs6MKWf/0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+58729+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1588786082134666.6907069671377; Wed, 6 May 2020 10:28:02 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id piwlYY1788612xzEPiDd316l; Wed, 06 May 2020 10:28:01 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web12.64.1588786080993556733 for ; Wed, 06 May 2020 10:28:01 -0700 X-Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 9F4361042; Wed, 6 May 2020 10:28:00 -0700 (PDT) X-Received: from e123331-lin.nice.arm.com (unknown [10.37.8.179]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id F02B23F71F; Wed, 6 May 2020 10:27:57 -0700 (PDT) From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Michael D Kinney , Liming Gao , Jian J Wang , Hao A Wu , Leif Lindholm , Sami Mujawar , Jiewen Yao Subject: [edk2-devel] [PATCH resend 3/7] ArmPkg/MmCommunicationDxe: expose MM Communicate 2 protocol Date: Wed, 6 May 2020 19:27:30 +0200 Message-Id: <20200506172734.2475-4-ard.biesheuvel@arm.com> In-Reply-To: <20200506172734.2475-1-ard.biesheuvel@arm.com> References: <20200506172734.2475-1-ard.biesheuvel@arm.com> Precedence: Bulk List-Unsubscribe: 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,ard.biesheuvel@arm.com X-Gm-Message-State: 3mhrEUgnVKUixys9I8htfwtwx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1588786081; bh=HmVJHtGlIEJM+ok00J6Y4/1lmr93a7pbUmi2HGkDQPM=; h=Cc:Date:From:Reply-To:Subject:To; b=iqdW2p0p7DTehBGWSIllDK4i2OV4TcrYMwAc94qALKqv7aiTwHUlUgz1A6SBkJP5TOP sZyrY0gdWSeSbnqmsWpsPOYM3Sa12CK1v95ujqcA9tf9/6zkNEI+c8QsZ0IFpYNWuyWmB WZCEVKAJZGSn6LZsSBxB/8RyDpewyMYS7UM= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Implement the new MmCommunication2 protocol which supports the use of standalone MM at runtime inside an address space that has been virtually remapped by the OS. Note that the implementation of the old MM Communicate protocol is removed: it never worked correctly so there is no point in keeping it. Signed-off-by: Ard Biesheuvel Reviewed-by: Leif Lindholm Reviewed-by: Sami Mujawar --- ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c | 81 +++++++++------= ----- ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf | 6 +- 2 files changed, 41 insertions(+), 46 deletions(-) diff --git a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c b/ArmPkg/D= rivers/MmCommunicationDxe/MmCommunication.c index a9e06be1adc2..9457eaf1d809 100644 --- a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c +++ b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c @@ -1,6 +1,6 @@ /** @file =20 - Copyright (c) 2016-2018, ARM Limited. All rights reserved. + Copyright (c) 2016-2020, ARM Limited. All rights reserved. =20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -16,7 +16,7 @@ #include #include =20 -#include +#include =20 #include =20 @@ -39,39 +39,34 @@ STATIC EFI_HANDLE mMmCommunicateHandle; /** Communicates with a registered handler. =20 - This function provides an interface to send and receive messages to the - Standalone MM environment on behalf of UEFI services. This function is = part - of the MM Communication Protocol that may be called in physical mode pri= or to - SetVirtualAddressMap() and in virtual mode after SetVirtualAddressMap(). + This function provides a service to send and receive messages from a reg= istered UEFI service. =20 - @param[in] This The EFI_MM_COMMUNICATION_PROTOCOL - instance. - @param[in, out] CommBuffer A pointer to the buffer to convey - into MMRAM. - @param[in, out] CommSize The size of the data buffer being - passed in. This is optional. + @param[in] This The EFI_MM_COMMUNICATION_PROTOCOL instanc= e. + @param[in] CommBufferPhysical Physical address of the MM communication = buffer + @param[in] CommBufferVirtual Virtual address of the MM communication b= uffer + @param[in] CommSize The size of the data buffer being passed = in. On exit, the size of data + being returned. Zero if the handler does = not wish to reply with any data. + This parameter is optional and may be NUL= L. + + @retval EFI_SUCCESS The message was successfully posted. + @retval EFI_INVALID_PARAMETER CommBufferPhysical was NULL or CommBuffer= Virtual was NULL. + @retval EFI_BAD_BUFFER_SIZE The buffer is too large for the MM implem= entation. + If this error is returned, the MessageLen= gth field + in the CommBuffer header or the integer p= ointed by + CommSize, are updated to reflect the maxi= mum payload + size the implementation can accommodate. + @retval EFI_ACCESS_DENIED The CommunicateBuffer parameter or CommSi= ze parameter, + if not omitted, are in address range that= cannot be + accessed by the MM environment. =20 - @retval EFI_SUCCESS The message was successfully posted. - @retval EFI_INVALID_PARAMETER The CommBuffer was NULL. - @retval EFI_BAD_BUFFER_SIZE The buffer size is incorrect for the= MM - implementation. If this error is - returned, the MessageLength field in - the CommBuffer header or the integer - pointed by CommSize are updated to r= eflect - the maximum payload size the - implementation can accommodate. - @retval EFI_ACCESS_DENIED The CommunicateBuffer parameter - or CommSize parameter, if not omitte= d, - are in address range that cannot be - accessed by the MM environment **/ -STATIC EFI_STATUS EFIAPI -MmCommunicationCommunicate ( - IN CONST EFI_MM_COMMUNICATION_PROTOCOL *This, - IN OUT VOID *CommBuffer, - IN OUT UINTN *CommSize OPTIONAL +MmCommunication2Communicate ( + IN CONST EFI_MM_COMMUNICATION2_PROTOCOL *This, + IN OUT VOID *CommBufferPhysical, + IN OUT VOID *CommBufferVirtual, + IN OUT UINTN *CommSize OPTIONAL ) { EFI_MM_COMMUNICATE_HEADER *CommunicateHeader; @@ -87,11 +82,11 @@ MmCommunicationCommunicate ( // // Check parameters // - if (CommBuffer =3D=3D NULL) { + if (CommBufferVirtual =3D=3D NULL) { return EFI_INVALID_PARAMETER; } =20 - CommunicateHeader =3D CommBuffer; + CommunicateHeader =3D CommBufferVirtual; // CommBuffer is a mandatory parameter. Hence, Rely on // MessageLength + Header to ascertain the // total size of the communication payload rather than @@ -136,7 +131,7 @@ MmCommunicationCommunicate ( CommunicateSmcArgs.Arg1 =3D 0; =20 // Copy Communication Payload - CopyMem ((VOID *)mNsCommBuffMemRegion.VirtualBase, CommBuffer, BufferSiz= e); + CopyMem ((VOID *)mNsCommBuffMemRegion.VirtualBase, CommBufferVirtual, Bu= fferSize); =20 // comm_buffer_address (64-bit physical address) CommunicateSmcArgs.Arg2 =3D (UINTN)mNsCommBuffMemRegion.PhysicalBase; @@ -149,7 +144,7 @@ MmCommunicationCommunicate ( =20 switch (CommunicateSmcArgs.Arg0) { case ARM_SMC_MM_RET_SUCCESS: - ZeroMem (CommBuffer, BufferSize); + ZeroMem (CommBufferVirtual, BufferSize); // On successful return, the size of data being returned is inferred f= rom // MessageLength + Header. CommunicateHeader =3D (EFI_MM_COMMUNICATE_HEADER *)mNsCommBuffMemRegio= n.VirtualBase; @@ -158,7 +153,7 @@ MmCommunicationCommunicate ( sizeof (CommunicateHeader->MessageLength); =20 CopyMem ( - CommBuffer, + CommBufferVirtual, (VOID *)mNsCommBuffMemRegion.VirtualBase, BufferSize ); @@ -191,8 +186,8 @@ MmCommunicationCommunicate ( // // MM Communication Protocol instance // -EFI_MM_COMMUNICATION_PROTOCOL mMmCommunication =3D { - MmCommunicationCommunicate +STATIC EFI_MM_COMMUNICATION2_PROTOCOL mMmCommunication2 =3D { + MmCommunication2Communicate }; =20 /** @@ -293,7 +288,7 @@ MmGuidedEventNotify ( Header.Data[0] =3D 0; =20 Size =3D sizeof (Header); - MmCommunicationCommunicate (&mMmCommunication, &Header, &Size); + MmCommunication2Communicate (&mMmCommunication2, &Header, &Header, &Size= ); } =20 /** @@ -312,7 +307,7 @@ MmGuidedEventNotify ( **/ EFI_STATUS EFIAPI -MmCommunicationInitialize ( +MmCommunication2Initialize ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) @@ -363,9 +358,9 @@ MmCommunicationInitialize ( // Install the communication protocol Status =3D gBS->InstallProtocolInterface ( &mMmCommunicateHandle, - &gEfiMmCommunicationProtocolGuid, + &gEfiMmCommunication2ProtocolGuid, EFI_NATIVE_INTERFACE, - &mMmCommunication + &mMmCommunication2 ); if (EFI_ERROR(Status)) { DEBUG ((DEBUG_ERROR, "MmCommunicationInitialize: " @@ -402,8 +397,8 @@ MmCommunicationInitialize ( UninstallProtocol: gBS->UninstallProtocolInterface ( mMmCommunicateHandle, - &gEfiMmCommunicationProtocolGuid, - &mMmCommunication + &gEfiMmCommunication2ProtocolGuid, + &mMmCommunication2 ); =20 CleanAddedMemorySpace: diff --git a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf b/ArmPkg= /Drivers/MmCommunicationDxe/MmCommunication.inf index 505228704ea5..2465fb77c58e 100644 --- a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf +++ b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf @@ -2,7 +2,7 @@ # # DXE MM Communicate driver # -# Copyright (c) 2016 - 2018, ARM Limited. All rights reserved. +# Copyright (c) 2016 - 2020, ARM Limited. All rights reserved. # # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -14,7 +14,7 @@ [Defines] FILE_GUID =3D 09EE81D3-F15E-43F4-85B4-CB9873DA5D6B MODULE_TYPE =3D DXE_RUNTIME_DRIVER VERSION_STRING =3D 1.0 - ENTRY_POINT =3D MmCommunicationInitialize + ENTRY_POINT =3D MmCommunication2Initialize =20 # # The following is for reference only and not required by @@ -40,7 +40,7 @@ [LibraryClasses] UefiDriverEntryPoint =20 [Protocols] - gEfiMmCommunicationProtocolGuid ## PRODUCES + gEfiMmCommunication2ProtocolGuid ## PRODUCES =20 [Guids] gEfiEndOfDxeEventGroupGuid --=20 2.17.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 (#58729): https://edk2.groups.io/g/devel/message/58729 Mute This Topic: https://groups.io/mt/74033569/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-