From nobody Tue Feb 10 14:33:23 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+68776+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+68776+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1607957108; cv=none; d=zohomail.com; s=zohoarc; b=cy4YjqDRnD8r2s7cwzFmDi+rrqjykFJDEzAUmYqA+IEVoXwbX+e32BDbFe7fkzEN7xyeVhH3Vg4ZT2DmZtOgFOZ1H0VsWXQxMi/z1tnfU6JvIarn6q78xQNq6i1bW+Xc4uwhq5d8R8T98JoihAj1UJqxmgo3WgIYrHDm+5ek//Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607957108; h=Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=JipOVOPfxwIVe3upLv0vsdYysyMv+VjBr3qPNDNm+J8=; b=W9qFknNdBa+PRXo3gfv/Imgh5Exld72W/SkTwjmh/GA7bhkc3xT1Fqh6zye/Wb3xK6cWNofN04tRFgmySVoXnYAxgJyThkU7BUH+IKoVhW1nLUVT+lhJ10NvQ+qVAQ4lv2aTyj4HyAk94YnKgmnC2wXgaHFhHZFDRakakhEfdUY= 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+68776+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 1607957108058783.2872549094303; Mon, 14 Dec 2020 06:45:08 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id ZW6qYY1788612xRPJuOD4zo2; Mon, 14 Dec 2020 06:45:04 -0800 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web11.35887.1607956973239729601 for ; Mon, 14 Dec 2020 06:42:53 -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 E7CD930E; Mon, 14 Dec 2020 06:42:52 -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 F3E8C3F66E; Mon, 14 Dec 2020 06:42:50 -0800 (PST) From: "Sughosh Ganu" To: devel@edk2.groups.io Cc: Sami Mujawar , Ard Biesheuvel , Leif Lindholm , Sahil Malhotra , Achin Gupta Subject: [edk2-devel] [PATCH v2 10/13] StandaloneMmMmuLib: Add option to use FF-A calls to get memory region's permissions Date: Mon, 14 Dec 2020 20:12:13 +0530 Message-Id: <20201214144216.26328-11-sughosh.ganu@linaro.org> In-Reply-To: <20201214144216.26328-1-sughosh.ganu@linaro.org> References: <20201214144216.26328-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: 9mFIb2McG2yiHy1bCgiMuF5vx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1607957104; bh=VPNGDcQb+0ZEWdo9BQlTVEfYn40EZnEj1uSDoyKrU4g=; h=Cc:Date:From:Reply-To:Subject:To; b=h799wLf5LLljirWx/TYNX3eZtQ+ERJ9rmTUumMptwihcYvLGGNXX/N+Eplpy4mXYAtC wB4tMFuxTZE35I1t2Dfatd7uVcr1l0A+qmSdAZOnUOcBHvF6lYnuEMqplSwbjNDhrdW5q sitH8CJMoWjRVbxzrmngEi1Be2NKOGvAeJA= 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 getting 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 --- ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.inf | 3 + ArmPkg/Include/IndustryStandard/ArmFfaSvc.h | 18 +++= +++ ArmPkg/Library/StandaloneMmMmuLib/AArch64/ArmMmuStandaloneMmLib.c | 66 +++= ++++++++++++++--- 3 files changed, 78 insertions(+), 9 deletions(-) diff --git a/ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.inf b/= ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.inf index 85973687f5..a29dd800b5 100644 --- a/ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.inf +++ b/ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.inf @@ -23,6 +23,9 @@ ArmPkg/ArmPkg.dec MdePkg/MdePkg.dec =20 +[Pcd] + gArmTokenSpaceGuid.PcdFfaEnable + [LibraryClasses] ArmLib CacheMaintenanceLib diff --git a/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h b/ArmPkg/Include/I= ndustryStandard/ArmFfaSvc.h index bdf6ce4676..65b8343ade 100644 --- a/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h +++ b/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h @@ -23,4 +23,22 @@ #define SPM_MAJOR_VERSION_FFA 1 #define SPM_MINOR_VERSION_FFA 0 =20 +#define ARM_FFA_SPM_RET_SUCCESS 0 +#define ARM_FFA_SPM_RET_NOT_SUPPORTED -1 +#define ARM_FFA_SPM_RET_INVALID_PARAMETERS -2 +#define ARM_FFA_SPM_RET_NO_MEMORY -3 +#define ARM_FFA_SPM_RET_BUSY -4 +#define ARM_FFA_SPM_RET_INTERRUPTED -5 +#define ARM_FFA_SPM_RET_DENIED -6 +#define ARM_FFA_SPM_RET_RETRY -7 +#define ARM_FFA_SPM_RET_ABORTED -8 + +// For now, the destination id to be used in the FF-A calls +// is being hard-coded. Subsequently, support will be added +// to get the endpoint id's dynamically +// This is the endpoint id used by the optee os's implementation +// of the spmc. +// https://github.com/OP-TEE/optee_os/blob/master/core/arch/arm/kernel/stm= m_sp.c#L66 +#define ARM_FFA_DESTINATION_ENDPOINT_ID 3 + #endif // ARM_FFA_SVC_H_ diff --git a/ArmPkg/Library/StandaloneMmMmuLib/AArch64/ArmMmuStandaloneMmLi= b.c b/ArmPkg/Library/StandaloneMmMmuLib/AArch64/ArmMmuStandaloneMmLib.c index 362b1a0f8a..893e291907 100644 --- a/ArmPkg/Library/StandaloneMmMmuLib/AArch64/ArmMmuStandaloneMmLib.c +++ b/ArmPkg/Library/StandaloneMmMmuLib/AArch64/ArmMmuStandaloneMmLib.c @@ -16,6 +16,7 @@ #include #include #include +#include =20 STATIC EFI_STATUS @@ -24,20 +25,67 @@ GetMemoryPermissions ( OUT UINT32 *MemoryAttributes ) { + INT32 Ret; ARM_SVC_ARGS GetMemoryPermissionsSvcArgs =3D {0}; - - GetMemoryPermissionsSvcArgs.Arg0 =3D ARM_SVC_ID_SP_GET_MEM_ATTRIBUTES_AA= RCH64; - GetMemoryPermissionsSvcArgs.Arg1 =3D BaseAddress; - GetMemoryPermissionsSvcArgs.Arg2 =3D 0; - GetMemoryPermissionsSvcArgs.Arg3 =3D 0; + BOOLEAN FfaEnabled; + + FfaEnabled =3D FeaturePcdGet (PcdFfaEnable); + if (FfaEnabled) { + GetMemoryPermissionsSvcArgs.Arg0 =3D ARM_SVC_ID_FFA_MSG_SEND_DIRECT_RE= Q_AARCH64; + GetMemoryPermissionsSvcArgs.Arg1 =3D ARM_FFA_DESTINATION_ENDPOINT_ID; + GetMemoryPermissionsSvcArgs.Arg2 =3D 0; + GetMemoryPermissionsSvcArgs.Arg3 =3D ARM_SVC_ID_SP_GET_MEM_ATTRIBUTES_= AARCH64; + GetMemoryPermissionsSvcArgs.Arg4 =3D BaseAddress; + } else { + GetMemoryPermissionsSvcArgs.Arg0 =3D ARM_SVC_ID_SP_GET_MEM_ATTRIBUTES_= AARCH64; + GetMemoryPermissionsSvcArgs.Arg1 =3D BaseAddress; + GetMemoryPermissionsSvcArgs.Arg2 =3D 0; + GetMemoryPermissionsSvcArgs.Arg3 =3D 0; + } =20 ArmCallSvc (&GetMemoryPermissionsSvcArgs); - if (GetMemoryPermissionsSvcArgs.Arg0 =3D=3D ARM_SVC_SPM_RET_INVALID_PARA= MS) { - *MemoryAttributes =3D 0; - return EFI_INVALID_PARAMETER; + if (FfaEnabled) { + Ret =3D GetMemoryPermissionsSvcArgs.Arg3; + + switch (Ret) { + case ARM_FFA_SPM_RET_INVALID_PARAMETERS: + *MemoryAttributes =3D 0; + return EFI_INVALID_PARAMETER; + + case ARM_FFA_SPM_RET_DENIED: + *MemoryAttributes =3D 0; + return EFI_NOT_READY; + + case ARM_FFA_SPM_RET_NOT_SUPPORTED: + *MemoryAttributes =3D 0; + return EFI_UNSUPPORTED; + + case ARM_FFA_SPM_RET_BUSY: + *MemoryAttributes =3D 0; + return EFI_NOT_READY; + + case ARM_FFA_SPM_RET_ABORTED: + *MemoryAttributes =3D 0; + return EFI_ABORTED; + } + + *MemoryAttributes =3D GetMemoryPermissionsSvcArgs.Arg3; + } else { + Ret =3D GetMemoryPermissionsSvcArgs.Arg0; + + switch (Ret) { + case ARM_SVC_SPM_RET_INVALID_PARAMS: + *MemoryAttributes =3D 0; + return EFI_INVALID_PARAMETER; + + case ARM_SVC_SPM_RET_NOT_SUPPORTED: + *MemoryAttributes =3D 0; + return EFI_UNSUPPORTED; + } + + *MemoryAttributes =3D GetMemoryPermissionsSvcArgs.Arg0; } =20 - *MemoryAttributes =3D GetMemoryPermissionsSvcArgs.Arg0; return EFI_SUCCESS; } =20 --=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 (#68776): https://edk2.groups.io/g/devel/message/68776 Mute This Topic: https://groups.io/mt/78951507/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-