From nobody Tue Feb 10 06:58:45 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+70368+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+70368+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1610691284; cv=none; d=zohomail.com; s=zohoarc; b=A3JbbJU02uJZyqFiUxrpncsVAoJESKe6QhP1fdpGufZVokFqRcRgTr182+BxADSezQ8tHcX9kluhH9mCaAtlsQPM406UsHJkq9qw4e4fEZ+rkj3ZzYgXaoZzsiykCQZifeKc36Fh520HKeL6NaCoRIFwNOdr81XHUiAuMnmCJyY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610691284; h=Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=4mcA4/1JDow6ZtsgwPh4oiFKT8WpdmEwjFfXil/A7c4=; b=ZniI/oZ277WF0g+TyuRlYoF72bzVkXMDnpUJ3o3DHgthgzkV6t+Mg+WkxcH4DVEiN6WNvo+Y+1KjvcOHjPRzB77bqEcecs71ROoycWDAZoaabruYyHIlTjgZESWLFbdQHbyfHoVE31wps9Dtqv1diXAsDcdV+vg6NeLO308KWmc= 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+70368+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1610691284983636.3109893580613; Thu, 14 Jan 2021 22:14:44 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id 0fEGYY1788612x2i1yfv82aG; Thu, 14 Jan 2021 22:14:44 -0800 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web08.518.1610691284091592372 for ; Thu, 14 Jan 2021 22:14:44 -0800 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 CCCC1ED1; Thu, 14 Jan 2021 22:14:43 -0800 (PST) X-Received: from a076522.blr.arm.com (a076522.blr.arm.com [10.162.16.44]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id AB3BC3F70D; Thu, 14 Jan 2021 22:14:41 -0800 (PST) From: "Sughosh Ganu" To: devel@edk2.groups.io Cc: Sami Mujawar , Ard Biesheuvel , Leif Lindholm , Sahil Malhotra , Ilias Apalodimas , Achin Gupta Subject: [edk2-devel] [PATCH v3 11/13] StandaloneMmMmuLib: Allow FF-A calls to set memory region's attributes Date: Fri, 15 Jan 2021 11:44:02 +0530 Message-Id: <20210115061404.13552-12-sughosh.ganu@linaro.org> In-Reply-To: <20210115061404.13552-1-sughosh.ganu@linaro.org> References: <20210115061404.13552-1-sughosh.ganu@linaro.org> 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,sughosh.ganu@linaro.org X-Gm-Message-State: fbdHaQ0SA5yuDfqQVLTIHJmVx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1610691284; bh=apvfpVTGMCoeZognHunPnAQJxJN7abYzZoU4PwkryYY=; h=Cc:Date:From:Reply-To:Subject:To; b=Y+vhmZpn+7BM1u9pISrCMdGnISG4nKG2kzZJYoQCBDxJXGmIBuqcNvk/qrzbETD2fbM prTY1ek7SWD5lCI0SQZe8BiWFVTG7hYmVin55juK7OXAuTVXNXNdX6jANs3/IZHmEeP4K S9xPXthwnj0xvViezcLWbbLpDYaL/Qsw80U= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Achin Gupta Allow setting memory region's permissions using either of the Firmware Framework(FF-A) ABI transport or through the earlier used SVC calls. Signed-off-by: Achin Gupta Co-developed-by: Sughosh Ganu --- Changes since V2: * Check for the return value in Arg0 after the Direct Request call to handle errors returned * Put a comment to reflect the fact that FFA_INTERRUPT and FFA_SUCCESS response won't be expected in return to a Direct Request call to set the memory attributes ArmPkg/Library/StandaloneMmMmuLib/AArch64/ArmMmuStandaloneMmLib.c | 88 +++= ++++++++++++----- 1 file changed, 65 insertions(+), 23 deletions(-) diff --git a/ArmPkg/Library/StandaloneMmMmuLib/AArch64/ArmMmuStandaloneMmLi= b.c b/ArmPkg/Library/StandaloneMmMmuLib/AArch64/ArmMmuStandaloneMmLib.c index 14fe781630..a30369af9c 100644 --- a/ArmPkg/Library/StandaloneMmMmuLib/AArch64/ArmMmuStandaloneMmLib.c +++ b/ArmPkg/Library/StandaloneMmMmuLib/AArch64/ArmMmuStandaloneMmLib.c @@ -116,47 +116,89 @@ RequestMemoryPermissionChange ( IN UINTN Permissions ) { - EFI_STATUS Status; + INT32 Ret; + BOOLEAN FfaEnabled; ARM_SVC_ARGS ChangeMemoryPermissionsSvcArgs; =20 ZeroMem (&ChangeMemoryPermissionsSvcArgs, sizeof (ARM_SVC_ARGS)); =20 - ChangeMemoryPermissionsSvcArgs.Arg0 =3D ARM_SVC_ID_SP_SET_MEM_ATTRIBUTES= _AARCH64; - ChangeMemoryPermissionsSvcArgs.Arg1 =3D BaseAddress; - ChangeMemoryPermissionsSvcArgs.Arg2 =3D EFI_SIZE_TO_PAGES(Length); - ChangeMemoryPermissionsSvcArgs.Arg3 =3D Permissions; + FfaEnabled =3D FeaturePcdGet (PcdFfaEnable); + + if (FfaEnabled) { + ChangeMemoryPermissionsSvcArgs.Arg0 =3D ARM_SVC_ID_FFA_MSG_SEND_DIRECT= _REQ_AARCH64; + ChangeMemoryPermissionsSvcArgs.Arg1 =3D ARM_FFA_DESTINATION_ENDPOINT_I= D; + ChangeMemoryPermissionsSvcArgs.Arg2 =3D 0; + ChangeMemoryPermissionsSvcArgs.Arg3 =3D ARM_SVC_ID_SP_SET_MEM_ATTRIBUT= ES_AARCH64; + ChangeMemoryPermissionsSvcArgs.Arg4 =3D BaseAddress; + ChangeMemoryPermissionsSvcArgs.Arg5 =3D EFI_SIZE_TO_PAGES (Length); + ChangeMemoryPermissionsSvcArgs.Arg6 =3D Permissions; + } else { + ChangeMemoryPermissionsSvcArgs.Arg0 =3D ARM_SVC_ID_SP_SET_MEM_ATTRIBUT= ES_AARCH64; + ChangeMemoryPermissionsSvcArgs.Arg1 =3D BaseAddress; + ChangeMemoryPermissionsSvcArgs.Arg2 =3D EFI_SIZE_TO_PAGES (Length); + ChangeMemoryPermissionsSvcArgs.Arg3 =3D Permissions; + } =20 ArmCallSvc (&ChangeMemoryPermissionsSvcArgs); =20 - Status =3D ChangeMemoryPermissionsSvcArgs.Arg0; + if (FfaEnabled) { + // Setting memory attributes is an atomic call, with + // StandaloneMm at S-EL0 being the caller and the SPM + // core being the callee. Thus there won't be a + // FFA_INTERRUPT or FFA_SUCCESS response to the Direct + // Request sent above. This will have to be considered + // for other Direct Request calls which are not atomic + // We therefore check only for Direct Response by the + // callee. + if (ChangeMemoryPermissionsSvcArgs.Arg0 !=3D + ARM_SVC_ID_FFA_MSG_SEND_DIRECT_RESP_AARCH64) { + // If Arg0 is not a Direct Response, that means we + // have an FF-A error. We need to check Arg2 for the + // FF-A error code. + Ret =3D ChangeMemoryPermissionsSvcArgs.Arg2; + switch (Ret) { + case ARM_FFA_SPM_RET_INVALID_PARAMETERS: + return EFI_INVALID_PARAMETER; =20 - switch (Status) { - case ARM_SVC_SPM_RET_SUCCESS: - Status =3D EFI_SUCCESS; - break; + case ARM_FFA_SPM_RET_DENIED: + return EFI_NOT_READY; + + case ARM_FFA_SPM_RET_NOT_SUPPORTED: + return EFI_UNSUPPORTED; + + case ARM_FFA_SPM_RET_BUSY: + return EFI_NOT_READY; + + case ARM_FFA_SPM_RET_ABORTED: + return EFI_ABORTED; + } + } else if (ChangeMemoryPermissionsSvcArgs.Arg0 =3D=3D + ARM_SVC_ID_FFA_MSG_SEND_DIRECT_RESP_AARCH64) { + // A Direct Response means FF-A success + // Now check the payload for errors + // The callee sends back the return value + // in Arg3 + Ret =3D ChangeMemoryPermissionsSvcArgs.Arg3; + } + } else { + Ret =3D ChangeMemoryPermissionsSvcArgs.Arg0; + } =20 + switch (Ret) { case ARM_SVC_SPM_RET_NOT_SUPPORTED: - Status =3D EFI_UNSUPPORTED; - break; + return EFI_UNSUPPORTED; =20 case ARM_SVC_SPM_RET_INVALID_PARAMS: - Status =3D EFI_INVALID_PARAMETER; - break; + return EFI_INVALID_PARAMETER; =20 case ARM_SVC_SPM_RET_DENIED: - Status =3D EFI_ACCESS_DENIED; - break; + return EFI_ACCESS_DENIED; =20 case ARM_SVC_SPM_RET_NO_MEMORY: - Status =3D EFI_BAD_BUFFER_SIZE; - break; - - default: - Status =3D EFI_ACCESS_DENIED; - ASSERT (0); + return EFI_BAD_BUFFER_SIZE; } =20 - return Status; + return EFI_SUCCESS; } =20 EFI_STATUS --=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 (#70368): https://edk2.groups.io/g/devel/message/70368 Mute This Topic: https://groups.io/mt/79696448/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-