From nobody Sat Feb 7 06:49:14 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+106809+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+106809+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1689086254; cv=none; d=zohomail.com; s=zohoarc; b=We4ZykpGtg7WnXdohiI6w0WgibkkoVSLXIjNxqV3hatZAeklafjBUDI7QfsNv3gu6URj2wn1DE5u1z9SG/onGLZlGdsjB4xLrwI+CluvVM7HLeRaYzPDAno2zFx+4sF7b6vYvQ6B8OViLzhx7aynGv6JGolk4KFXPJY4fEzGKNA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1689086254; 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=No+u6meHVhEtdfGrf6UJXhkY3pPIarQgnHezvJI460o=; b=O5YubYBMTpOLH0wpjrHpd+21McUKgem8dpwjrdwL40z9bWdGGkX2J2d6UoyDsoHWEQl5PYvwvrre5bWINxB0T4CHuFWNnpCI3o/9uh8WOWyhOw8mYlOsgINSIIJwiX4wNZq2bCryl2lihCS+Fd0xZgKfirpXjkCpzYFFfUK8PME= 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+106809+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 1689086254032354.12796039056946; Tue, 11 Jul 2023 07:37:34 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=NkP5Rq5uDbyKlq9UdP3BVsvxKj5xUunLE1DGfwmE1xI=; c=relaxed/simple; d=groups.io; h=X-Received:X-Received:X-Received:X-Received:From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Precedence:List-Unsubscribe:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:X-Gm-Message-State:Content-Transfer-Encoding; s=20140610; t=1689086253; v=1; b=cwIwusPY+vcVAHjnjw9uZPG7EPYwwgsnr6PCQ7iOQpY2Ima+ecSz77ZBC5blyJAmEYeUbyP1 X/8EDGSJ/EZlzYTzGU+BicOMv+X9ffGz74BC0Zm5cR/tbh27dRyylmLrS3MOiyRSg8uj8RmBM+g WDM0TMeDClxkpeZhJKgNVr8U= X-Received: by 127.0.0.2 with SMTP id 6RnLYY1788612x2z6ovuYk9J; Tue, 11 Jul 2023 07:37:33 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web11.1247.1689086252921640808 for ; Tue, 11 Jul 2023 07:37:33 -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 C96EC2F4; Tue, 11 Jul 2023 07:38:14 -0700 (PDT) X-Received: from usa.arm.com (iss-desktop02.cambridge.arm.com [10.1.196.79]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id C50C73F740; Tue, 11 Jul 2023 07:37:31 -0700 (PDT) From: "Nishant Sharma" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Sami Mujawar , Thomas Abraham , Sayanta Pattanayak , Achin Gupta Subject: [edk2-devel] [edk2-platforms][PATCH V1 17/20] ArmPkg/MmCommunicationDxe: Unmap FF-A RX/TX buffers during ExitBootServices Date: Tue, 11 Jul 2023 15:36:55 +0100 Message-Id: <20230711143658.781597-18-nishant.sharma@arm.com> In-Reply-To: <20230711143658.781597-1-nishant.sharma@arm.com> References: <20230711143658.781597-1-nishant.sharma@arm.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,nishant.sharma@arm.com X-Gm-Message-State: PNR0qbX96PV4x3nxe2plQCCKx1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1689086254710100068 Content-Type: text/plain; charset="utf-8" From: Achin Gupta An FF-A partition can map only a single RX/TX buffer pair with the framework. The DXE MM communication driver maps its pair before ExitBootServices is called. The OS cannot re-use this pair once it boots subsequently and loads its own FF-A driver. This patch ensures that the DXE MM communication driver unmaps its buffer pair when ExitBootServices is called so that the OS can register its own pair if required. Signed-off-by: Achin Gupta Signed-off-by: Nishant Sharma --- ArmPkg/Include/IndustryStandard/ArmFfaSvc.h | 10 ++++ ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c | 49 +++++++++++++++++= +++ 2 files changed, 59 insertions(+) diff --git a/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h b/ArmPkg/Include/I= ndustryStandard/ArmFfaSvc.h index ebdf29e8d69a..f78442a465e1 100644 --- a/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h +++ b/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h @@ -122,6 +122,16 @@ (((content) & FFA_BOOT_INFO_FLAG_CONTENT_MASK) \ << FFA_BOOT_INFO_FLAG_CONTENT_SHIFT) =20 +/* Fromat SP ID info. */ +#define FFA_PARTITION_ID_SHIFT 16 +#define FFA_PARTITION_ID_WIDTH 16 +#define FFA_PARTITION_ID_MASK \ + (((1U << FFA_PARTITION_ID_WIDTH) - 1) \ + << FFA_PARTITION_ID_SHIFT) +#define FFA_PARTITION_ID(partid) \ + ((partid << FFA_PARTITION_ID_SHIFT) & \ + FFA_PARTITION_ID_MASK) + // Descriptor to pass boot information as per the FF-A v1.1 spec. typedef struct { UINT32 Name[4]; diff --git a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c b/ArmPkg/D= rivers/MmCommunicationDxe/MmCommunication.c index 8a4d46e4f80a..39a1b329b9ea 100644 --- a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c +++ b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c @@ -43,6 +43,9 @@ STATIC ARM_MEMORY_REGION_DESCRIPTOR mNsCommBuffMemRegion; // Notification event when virtual address map is set. STATIC EFI_EVENT mSetVirtualAddressMapEvent; =20 +// Notification event when exit boot services is called. +STATIC EFI_EVENT mExitBootServicesEvent; + // // Handle to install the MM Communication Protocol // @@ -255,6 +258,39 @@ NotifySetVirtualAddressMap ( } } =20 +/** + Notification callback on ExitBootServices event. + + This function notifies the MM communication protocol interface on + ExitBootServices event and releases the FF-A RX/TX buffer. + + @param Event ExitBootServices event. + @param Context A context when the ExitBootServices triggered. + + @retval EFI_SUCCESS The function executed successfully. + @retval Other Some error occurred when executing this function. + +**/ +STATIC +VOID +EFIAPI +NotifyExitBootServices ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + ARM_SMC_ARGS SmcArgs =3D {0}; + + SmcArgs.Arg0 =3D ARM_SVC_ID_FFA_RXTX_UNMAP_AARCH32; + SmcArgs.Arg1 =3D FFA_PARTITION_ID(mFfaPartId); + ArmCallSmc (&SmcArgs); + + // We do not bother checking the error code of the RXTX_UNMAP invocation + // since we did map the buffers and this call must succeed. + return; + +} + STATIC EFI_STATUS GetMmCompatibility ( @@ -452,6 +488,19 @@ MmCommunication2Initialize ( goto CleanAddedMemorySpace; } =20 + // Register notification callback when ExitBootservices is called to + // unregister the FF-A RX/TX buffer pair. This allows the OS to register= its + // own buffer pair. + if (FixedPcdGet32 (PcdFfaEnable) !=3D 0) { + Status =3D gBS->CreateEvent ( + EVT_SIGNAL_EXIT_BOOT_SERVICES, + TPL_NOTIFY, + NotifyExitBootServices, + NULL, + &mExitBootServicesEvent + ); + ASSERT_EFI_ERROR (Status); + } // Register notification callback when virtual address is associated // with the physical address. // Create a Set Virtual Address Map event. --=20 2.34.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 (#106809): https://edk2.groups.io/g/devel/message/106809 Mute This Topic: https://groups.io/mt/100079891/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-