From nobody Tue Feb 10 13:17:44 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+71825+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+71825+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1613716611; cv=none; d=zohomail.com; s=zohoarc; b=DQwWupuWPWtUzYuIkWPtj6k3wz+w+2fefdE4L6Wg9gZWlj6PMggeDhmpwLYlQHDVm8jzANzPRuAQuTGH4BATeqvN4Dtk2ZElJEDVC+upHyZB2dE0P48bxmShhOQGLxmB5D2u+IKoTpjZZiDj5tRfeykWmbrFD+K8rMrKcVmbbnM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1613716611; h=Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=ckkdkiZmYH7o2B9XxhNFukrN5baRNA+UXn+xe79FdOE=; b=UEXgrbbtV2G3iHSwvKq+K2vW7o23Ugyn/PqXAC1y4CXibU2eiWLX2G/1IZHKxhnzMasZgoDdliudh20O+F+rE4Xg9/in3O7nIlM5pqMu6mDs13PkiPENrtK7oerRoT/xe4O+0Jd8nIhdb3CCsmyPnLmbwdTNWeHTsHZkpEivwQA= 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+71825+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 1613716611189480.47175885987747; Thu, 18 Feb 2021 22:36:51 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id mUZuYY1788612xKNLb5lgkI6; Thu, 18 Feb 2021 22:36:50 -0800 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web09.5209.1613716605286922211 for ; Thu, 18 Feb 2021 22:36:45 -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 DBA101FB; Thu, 18 Feb 2021 22:36:44 -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 377F03F73B; Thu, 18 Feb 2021 22:36:42 -0800 (PST) From: "Sughosh Ganu" To: devel@edk2.groups.io Cc: Sami Mujawar , Ilias Apalodimas , Ard Biesheuvel , Achin Gupta Subject: [edk2-devel] [PATCH v5 12/14] ArmPkg: Allow FF-A calls to set memory region's attributes Date: Fri, 19 Feb 2021 12:06:05 +0530 Message-Id: <20210219063607.27920-13-sughosh.ganu@linaro.org> In-Reply-To: <20210219063607.27920-1-sughosh.ganu@linaro.org> References: <20210219063607.27920-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: odhDhfficXxr7btzelfkgPogx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1613716610; bh=B4X/DYbpSUg46HJL0irfe9nC/+OXU2erb1lp4sZz+14=; h=Cc:Date:From:Reply-To:Subject:To; b=O1yAb8MIaNiK91ueQs09yN8HfM0oQqGBKxvHtA2xhVKwVc4O/TMsDajprb7GDmF5X2Y WhgHu4C6N1zA1BZotiZNYmI7uos9v8fEt3Wh9+RLoKwBGZ4elO/APwBqxlxkm351BPHP+ 6KdeDGHrpNSk0P3qv5eoCk66sfox8onMSDs= 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 Reviewed-by: Sami Mujawar --- Changes since V4: None 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 (#71825): https://edk2.groups.io/g/devel/message/71825 Mute This Topic: https://groups.io/mt/80750057/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-