From nobody Fri May 10 05:43:06 2024 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+106793+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+106793+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1689086237; cv=none; d=zohomail.com; s=zohoarc; b=AfCN6+Lo+9lkbGcCecTdiaQiUWtmBi5iOf9xIPxGJ5DNytGkjpt1WWQD6WgEKXH4MYbYXqQvfi78/rAD5bRR6Y4S91h3I53RhUEZ8tocBPFXOf+AnUChlaJmJ1Y+MJ5sdH7cakuYHOq22WzG2PmAcBEyyf83ry40leND7+3oRRI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1689086237; 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=UsmdSIqhqra6GMuhaK/HJsf2GWjKtt/fKKLrof7BQTk=; b=Zd5tN7dH4KSXpkU8rDH5oQNFOMYlcRZ4UASrQWw9VEvcRHobSESQ+x7Xy84pxiCZ4hbTQcfW3mPNvjbj5MVJs6G0N4Bj6961Pyvyg1iZyIGw3R03ZFlwWrE1m8i6Ix3D0EdWwZru+pC91PiesvfUVPtFKKwWwkGg7pboV2SU7Wo= 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+106793+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 1689086237114884.6273175516715; Tue, 11 Jul 2023 07:37:17 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=x7HJQRQA/RzvZZNZlKw9JlGb+TEfqsQKI5fpNlV86TE=; 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=1689086236; v=1; b=q+g30E0Kzx8cFcEBzW6PTROUzhOeZsX6X85gwrX6X6Y8v1ctitw4UJ8RbfVdWjztDjgYLLt4 eFOkDXAa/ZPIpV3MiGVGazRhQdMS702TaxM5LNP7lFS4gJ5hkVnX/CGVzbezhgvGjIqs75dWIue DgnjpvEvp5acun3ZNhTYEBHg= X-Received: by 127.0.0.2 with SMTP id p6MzYY1788612x8te9wOVdxQ; Tue, 11 Jul 2023 07:37:16 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web11.1227.1689086235536945552 for ; Tue, 11 Jul 2023 07:37:15 -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 733402F4; Tue, 11 Jul 2023 07:37:57 -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 553EA3F740; Tue, 11 Jul 2023 07:37:14 -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 01/20] ArmPkg: Change PcdFfaEnable flag datatype Date: Tue, 11 Jul 2023 15:36:39 +0100 Message-Id: <20230711143658.781597-2-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: J3WJ56ybkxO029uroReAIi0Dx1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1689086238801100007 Content-Type: text/plain; charset="utf-8" FeatureFlag type PCD flags are declared by typecasting an integer value to BOOLEAN. These flags cannot be use in assembly code as assembler does not recognise C primitive types. Change the flag data type from BOOLEAN to UINT32. Signed-off-by: Nishant Sharma --- ArmPkg/ArmPkg.dec = | 14 +++++++------- ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.inf = | 4 ++-- StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPo= int.inf | 4 ++-- ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.c = | 8 ++++---- StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEnt= ryPoint.c | 8 ++++---- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/ArmPkg/ArmPkg.dec b/ArmPkg/ArmPkg.dec index 1a16d044c94b..c36c23e2e059 100644 --- a/ArmPkg/ArmPkg.dec +++ b/ArmPkg/ArmPkg.dec @@ -155,13 +155,6 @@ # hardware coherency (i.e., no virtualization or cache coherent DMA) gArmTokenSpaceGuid.PcdNormalMemoryNonshareableOverride|FALSE|BOOLEAN|0x0= 0000043 =20 -[PcdsFeatureFlag.AARCH64, PcdsFeatureFlag.ARM] - ## Used to select method for requesting services from S-EL1.

- # TRUE - Selects FF-A calls for communication between S-EL0 and SPMC.=
- # FALSE - Selects SVC calls for communication between S-EL0 and SPMC.<= BR> - # @Prompt Enable FF-A support. - gArmTokenSpaceGuid.PcdFfaEnable|FALSE|BOOLEAN|0x0000005B - [PcdsFixedAtBuild.common] gArmTokenSpaceGuid.PcdTrustzoneSupport|FALSE|BOOLEAN|0x00000006 =20 @@ -298,6 +291,13 @@ # not currently supported. gArmTokenSpaceGuid.PcdArmNonSecModeTransition|0x3c9|UINT32|0x0000003E =20 + ## Used to select method for requesting services from S-EL1.

+ # 1 - Selects FF-A calls for communication between S-EL0 and SPMC.
+ # 0 - Selects SVC calls for communication between S-EL0 and SPMC.
+ # Using unsigned integer as boolean does not work on assembler. + # @Prompt Enable FF-A support. + gArmTokenSpaceGuid.PcdFfaEnable|0|UINT32|0x0000005B + =20 # # These PCDs are also defined as 'PcdsDynamic' or 'PcdsPatchableInModule' = to be diff --git a/ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.inf b/= ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.inf index ff20e5898051..3c733585f573 100644 --- a/ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.inf +++ b/ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.inf @@ -1,6 +1,6 @@ #/** @file # -# Copyright (c) 2017 - 2021, Arm Limited. All rights reserved.
+# Copyright (c) 2017 - 2023, Arm Limited. All rights reserved. # # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -23,7 +23,7 @@ ArmPkg/ArmPkg.dec MdePkg/MdePkg.dec =20 -[FeaturePcd.ARM, FeaturePcd.AARCH64] +[FixedPcd] gArmTokenSpaceGuid.PcdFfaEnable =20 [LibraryClasses] diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneM= mCoreEntryPoint.inf b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/St= andaloneMmCoreEntryPoint.inf index 75cfb98c0e75..dc6d3d859911 100644 --- a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEn= tryPoint.inf +++ b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEn= tryPoint.inf @@ -1,7 +1,7 @@ ## @file # Module entry point library for DXE core. # -# Copyright (c) 2017 - 2021, Arm Ltd. All rights reserved.
+# Copyright (c) 2017 - 2023, Arm Ltd. All rights reserved. # # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -51,7 +51,7 @@ gEfiStandaloneMmNonSecureBufferGuid gEfiArmTfCpuDriverEpDescriptorGuid =20 -[FeaturePcd.ARM, FeaturePcd.AARCH64] +[FixedPcd] gArmTokenSpaceGuid.PcdFfaEnable =20 # diff --git a/ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.c b/Ar= mPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.c index d55aff76201e..1a41a289ef17 100644 --- a/ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.c +++ b/ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.c @@ -1,7 +1,7 @@ /** @file File managing the MMU for ARMv8 architecture in S-EL0 =20 - Copyright (c) 2017 - 2021, Arm Limited. All rights reserved.
+ Copyright (c) 2017 - 2023, Arm Limited. All rights reserved. Copyright (c) 2021, Linaro Limited SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -54,7 +54,7 @@ SendMemoryPermissionRequest ( } =20 ArmCallSvc (SvcArgs); - if (FeaturePcdGet (PcdFfaEnable)) { + if (FixedPcdGet32 (PcdFfaEnable) !=3D 0) { // Get/Set 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 @@ -163,7 +163,7 @@ GetMemoryPermissions ( // Prepare the message parameters. // See [1], Section 13.5.5.1 MM_SP_MEMORY_ATTRIBUTES_GET_AARCH64. ZeroMem (&SvcArgs, sizeof (ARM_SVC_ARGS)); - if (FeaturePcdGet (PcdFfaEnable)) { + if (FixedPcdGet32 (PcdFfaEnable) !=3D 0) { // See [2], Section 10.2 FFA_MSG_SEND_DIRECT_REQ. SvcArgs.Arg0 =3D ARM_SVC_ID_FFA_MSG_SEND_DIRECT_REQ; SvcArgs.Arg1 =3D ARM_FFA_DESTINATION_ENDPOINT_ID; @@ -218,7 +218,7 @@ RequestMemoryPermissionChange ( // Prepare the message parameters. // See [1], Section 13.5.5.2 MM_SP_MEMORY_ATTRIBUTES_SET_AARCH64. ZeroMem (&SvcArgs, sizeof (ARM_SVC_ARGS)); - if (FeaturePcdGet (PcdFfaEnable)) { + if (FixedPcdGet32 (PcdFfaEnable) !=3D 0) { // See [2], Section 10.2 FFA_MSG_SEND_DIRECT_REQ. SvcArgs.Arg0 =3D ARM_SVC_ID_FFA_MSG_SEND_DIRECT_REQ; SvcArgs.Arg1 =3D ARM_FFA_DESTINATION_ENDPOINT_ID; diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/Standal= oneMmCoreEntryPoint.c b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/= Arm/StandaloneMmCoreEntryPoint.c index 96de10405af8..5dd1d9747995 100644 --- a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCo= reEntryPoint.c +++ b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCo= reEntryPoint.c @@ -2,7 +2,7 @@ Entry point to the Standalone MM Foundation when initialized during the = SEC phase on ARM platforms =20 -Copyright (c) 2017 - 2021, Arm Ltd. All rights reserved.
+Copyright (c) 2017 - 2023, Arm Ltd. All rights reserved. SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -140,7 +140,7 @@ DelegatedEventLoop ( DEBUG ((DEBUG_INFO, "X6 : 0x%x\n", (UINT32)EventCompleteSvcArgs->Arg6= )); DEBUG ((DEBUG_INFO, "X7 : 0x%x\n", (UINT32)EventCompleteSvcArgs->Arg7= )); =20 - FfaEnabled =3D FeaturePcdGet (PcdFfaEnable); + FfaEnabled =3D FixedPcdGet32 (PcdFfaEnable !=3D 0); if (FfaEnabled) { Status =3D CpuDriverEntryPoint ( EventCompleteSvcArgs->Arg0, @@ -225,7 +225,7 @@ GetSpmVersion ( UINT32 SpmVersion; ARM_SVC_ARGS SpmVersionArgs; =20 - if (FeaturePcdGet (PcdFfaEnable)) { + if (FixedPcdGet32 (PcdFfaEnable) !=3D 0) { SpmVersionArgs.Arg0 =3D ARM_SVC_ID_FFA_VERSION_AARCH32; SpmVersionArgs.Arg1 =3D mSpmMajorVerFfa << SPM_MAJOR_VER_SHIFT; SpmVersionArgs.Arg1 |=3D mSpmMinorVerFfa; @@ -293,7 +293,7 @@ InitArmSvcArgs ( OUT INT32 *Ret ) { - if (FeaturePcdGet (PcdFfaEnable)) { + if (FixedPcdGet32 (PcdFfaEnable) !=3D 0) { InitMmFoundationSvcArgs->Arg0 =3D ARM_SVC_ID_FFA_MSG_SEND_DIRECT_RESP; InitMmFoundationSvcArgs->Arg1 =3D 0; InitMmFoundationSvcArgs->Arg2 =3D 0; --=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 (#106793): https://edk2.groups.io/g/devel/message/106793 Mute This Topic: https://groups.io/mt/100079870/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- From nobody Fri May 10 05:43:06 2024 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+106794+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+106794+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1689086237; cv=none; d=zohomail.com; s=zohoarc; b=ZO57fjwj/R8303EqgrLlQWIjqWWcBX42oPkvI27pFGmqEr+GEQbN6bP5W/THukWmpZeeFp411Tgro2BU2pS4h8iOaG6yHiXSMWn/ByzRPZ5abaMzUSj/nG3scH4Sy4vgVzjCaNP0bye6TdWB2Ym5W5Biy4WeQNsHsnCpJFRB11M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1689086237; 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=i7bmNpNhB7K/7hKr7DAXNgpjmJuPMAyj90zFJslbZQE=; b=K0S5g3QBfwPHowhEnusM1QVC1dwv+qQ3gETihx4KD0gAIb0n9EWO9jj5Z97PbGNKdVlVhS3nEdOI04Vgw+eooXMy59L/BOBK4fvCsxCLqFxxLHf9snYM87/T6YAPMvIkjqpv7kIGRy/XvOCJ5Jm49o5rb9EnDwheghL6vfTqr+8= 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+106794+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 1689086237665884.4361990162558; Tue, 11 Jul 2023 07:37:17 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=bpiQpWfeeiF71A50u0F6yVxNCA8Pr5oJaNsa7GVS1h0=; 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=1689086237; v=1; b=mVBzRb4IqXs7qi2nyvXjAsZQgmV81msHZp0RuhUyx72uukiY1/WU8E/xz7vdlaTwebukdMeU 3SkCJkuRD+TamzeQAG2Jd/f6Dcs/LCXWlf7Zxg+NBl7D2TVNuwMbZ8Wqz170jfeT9qCUNATijY7 kwTNdEHOj9TfjDTSL/OLKm80= X-Received: by 127.0.0.2 with SMTP id VJkIYY1788612x05Vh1zwHo1; Tue, 11 Jul 2023 07:37:17 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web11.1228.1689086236695707927 for ; Tue, 11 Jul 2023 07:37:16 -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 88C68C15; Tue, 11 Jul 2023 07:37:58 -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 6B07D3F740; Tue, 11 Jul 2023 07:37:15 -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 02/20] StandaloneMmPkg: Allocate and initialise SP stack from internal memory Date: Tue, 11 Jul 2023 15:36:40 +0100 Message-Id: <20230711143658.781597-3-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: ocJI7Sa1OjS0Y7xGcTJ54DoJx1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1689086238798100006 Content-Type: text/plain; charset="utf-8" From: Achin Gupta This patch removes the dependency on the SPM to allocate and initialise stack memory for the StMM SP. This is done by reserving 8K worth of memory in the StMM image at a page aligned address in the data section. Then, instead of jumping directly to the C entrypoint, an assembler entrypoint is invoked. This entrypoint locates the stack memory, changes its permissions using FF-A ABIs, sets the stack pointer and invokes the C entrypoint. Signed-off-by: Achin Gupta Signed-off-by: Nishant Sharma --- StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPo= int.inf | 1 + StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEnt= ryPoint.c | 2 +- StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/AArch64/ModuleEntry= Point.S | 68 ++++++++++++++++++++ 3 files changed, 70 insertions(+), 1 deletion(-) diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneM= mCoreEntryPoint.inf b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/St= andaloneMmCoreEntryPoint.inf index dc6d3d859911..10fafa43ce59 100644 --- a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEn= tryPoint.inf +++ b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEn= tryPoint.inf @@ -25,6 +25,7 @@ Arm/StandaloneMmCoreEntryPoint.c Arm/SetPermissions.c Arm/CreateHobList.c + Arm/AArch64/ModuleEntryPoint.S =20 [Sources.X64] X64/StandaloneMmCoreEntryPoint.c diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/Standal= oneMmCoreEntryPoint.c b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/= Arm/StandaloneMmCoreEntryPoint.c index 5dd1d9747995..ce867fe85158 100644 --- a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCo= reEntryPoint.c +++ b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCo= reEntryPoint.c @@ -316,7 +316,7 @@ InitArmSvcArgs ( **/ VOID EFIAPI -_ModuleEntryPoint ( +ModuleEntryPoint ( IN VOID *SharedBufAddress, IN UINT64 SharedBufSize, IN UINT64 cookie1, diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/AArch64= /ModuleEntryPoint.S b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Ar= m/AArch64/ModuleEntryPoint.S new file mode 100644 index 000000000000..174bc83ebd64 --- /dev/null +++ b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/AArch64/Module= EntryPoint.S @@ -0,0 +1,68 @@ +// +// Copyright (c) 2023, ARM Limited. All rights reserved. +// +// SPDX-License-Identifier: BSD-2-Clause-Patent +// +// + +#include + +#define FFA_DATA_RW 0x1 + +.align 12 +StackBase: +.space 8192 +StackEnd: + +.macro FfaMemPermSet start:req end:req perm:req +adrp x29, \start +add x29, x29, :lo12: \start + +adrp x30, \end +add x30, x30, :lo12:\end + +/* x30 =3D end - begin */ +sub x30, x30, x29 +/* x28 =3D x30 >> 12 (number of pages) */ +mov x28, #12 +lsrv x28, x30, x28 + +mov w0, #0x89 +movk w0, #0x8400, lsl #16 +mov x1, x29 +mov x2, x28 +mov w3, #\perm + +svc #0 + +mov w1, #0x61 +movk w1, #0x8400, lsl #16 +cmp w1, w0 +b.ne . +.endm + + ASM_FUNC(_ModuleEntryPoint) +MOV32 (w8, FixedPcdGet32(PcdFfaEnable)) + cbz w8, FfaNotEnabled + // Stash boot information registers from the SPMC + mov x8, x0 + mov x9, x1 + mov x10, x2 + mov x11, x3 + + // Set the correct permissions on stack memory + FfaMemPermSet StackBase StackEnd FFA_DATA_RW + + // Initialise SP + adr x0, StackEnd + mov sp, x0 + + // Restore boot information registers from the SPMC + mov x0, x8 + mov x1, x9 + mov x2, x10 + mov x3, x11 + + // Invoke the C entrypoint + FfaNotEnabled: + b ModuleEntryPoint --=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 (#106794): https://edk2.groups.io/g/devel/message/106794 Mute This Topic: https://groups.io/mt/100079871/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- From nobody Fri May 10 05:43:06 2024 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+106795+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+106795+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1689086239; cv=none; d=zohomail.com; s=zohoarc; b=E+IMRZkjOut0/385oEfj5OY1wwo1gJk1gN2nfv6PDUuQwXmyh3rzq7Z1WYXPdcfITsPB6QLSR4T2o4QlONmbg1hYjgD07AJEvCo1IWjtijQlK7VJHuvvmghSkLGGvDWhH7x7iPPjhf7K5cZsUMUUbNoGSqiRqvgJwQ06UpDFaBs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1689086239; 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=lOKH28Um8g7QRVTLSD2YrQP14zmJN1BV9kQlzNyh8lE=; b=PG6ypcKd6clmoGZHEomKrX3RbOyshuxz9E0Qp5k08J3IwrgxlX/EUt9p9ec5HgseCFcsW76Q2CID/4608fiMKWOXB4iiwZQbKAfrl3HDd1XvJkyWTdBgkdVqg9NUzIRW/Gwiikdv93BIV7DdYanhysVv1JAg5kbBQZM59PEb9j8= 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+106795+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 1689086239088437.94353735652066; Tue, 11 Jul 2023 07:37:19 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=ROJnLRp+EDOqcD5M3sPjSJtPvUC8STUb4AfoS8GTAA4=; 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=1689086238; v=1; b=WLutpUL8gqDDoo5nKAkGNRSMQlsEa/2W0yBRAK67skETllM7nMMy0NWADKP7UtGFBJ/qT11/ Or7hFFHzzzbM+BipVI9kzQTbpz08nA5EMkmQWfSlSUXqH9otX4x2IuTAJk+NZVuZ3SdrFp4boCo F6wHzWg84KvmU2KsG2h8Gzo4= X-Received: by 127.0.0.2 with SMTP id 22JyYY1788612xdTXwgWlENj; Tue, 11 Jul 2023 07:37:18 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web10.1266.1689086237785603966 for ; Tue, 11 Jul 2023 07:37:18 -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 9EA2DD75; Tue, 11 Jul 2023 07:37:59 -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 80E2F3F740; Tue, 11 Jul 2023 07:37:16 -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 03/20] StandaloneMmPkg: Include libfdt in the StMM Date: Tue, 11 Jul 2023 15:36:41 +0100 Message-Id: <20230711143658.781597-4-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: xXH3mnhy0wQ8r6dIrnvdexaox1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1689086241473100015 Content-Type: text/plain; charset="utf-8" From: Achin Gupta The StMM SP will extract boot information from its manifest instead of a C data structure populated by the SPM. The manifest will be passed by the SPM. This patch includes support for libfdt to prepare for parsing the manifest in future patches. Signed-off-by: Sayanta Pattanayak Signed-off-by: Nishant Sharma --- StandaloneMmPkg/StandaloneMmPkg.dsc = | 3 ++- StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPo= int.inf | 3 +++ StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEnt= ryPoint.c | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/StandaloneMmPkg/StandaloneMmPkg.dsc b/StandaloneMmPkg/Standalo= neMmPkg.dsc index 8012f93b7dcc..0060eddb900c 100644 --- a/StandaloneMmPkg/StandaloneMmPkg.dsc +++ b/StandaloneMmPkg/StandaloneMmPkg.dsc @@ -2,7 +2,7 @@ # Standalone MM Platform. # # Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.
-# Copyright (c) 2016 - 2021, Arm Limited. All rights reserved.
+# Copyright (c) 2016 - 2023, Arm Limited. All rights reserved.
# Copyright (C) Microsoft Corporation
# # SPDX-License-Identifier: BSD-2-Clause-Patent @@ -49,6 +49,7 @@ HobLib|StandaloneMmPkg/Library/StandaloneMmHobLib/StandaloneMmHobLib.inf IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf MemLib|StandaloneMmPkg/Library/StandaloneMmMemLib/StandaloneMmMemLib.inf + FdtLib|EmbeddedPkg/Library/FdtLib/FdtLib.inf MemoryAllocationLib|StandaloneMmPkg/Library/StandaloneMmCoreMemoryAlloca= tionLib/StandaloneMmCoreMemoryAllocationLib.inf MmServicesTableLib|MdePkg/Library/StandaloneMmServicesTableLib/Standalon= eMmServicesTableLib.inf PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneM= mCoreEntryPoint.inf b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/St= andaloneMmCoreEntryPoint.inf index 10fafa43ce59..80af62450e22 100644 --- a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEn= tryPoint.inf +++ b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEn= tryPoint.inf @@ -31,6 +31,7 @@ X64/StandaloneMmCoreEntryPoint.c =20 [Packages] + EmbeddedPkg/EmbeddedPkg.dec MdePkg/MdePkg.dec MdeModulePkg/MdeModulePkg.dec StandaloneMmPkg/StandaloneMmPkg.dec @@ -41,10 +42,12 @@ [LibraryClasses] BaseLib DebugLib + FdtLib =20 [LibraryClasses.ARM, LibraryClasses.AARCH64] StandaloneMmMmuLib ArmSvcLib + FdtLib =20 [Guids] gMpInformationHobGuid diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/Standal= oneMmCoreEntryPoint.c b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/= Arm/StandaloneMmCoreEntryPoint.c index ce867fe85158..682b55b5478a 100644 --- a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCo= reEntryPoint.c +++ b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCo= reEntryPoint.c @@ -15,6 +15,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include #include =20 +#include #include #include #include --=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 (#106795): https://edk2.groups.io/g/devel/message/106795 Mute This Topic: https://groups.io/mt/100079873/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- From nobody Fri May 10 05:43:06 2024 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+106796+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+106796+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1689086241; cv=none; d=zohomail.com; s=zohoarc; b=KE0gz4YSatIO2iLcjNKBFJ9ClNrisiAwn+vRgN4UaEpGwY6XImbYmpONd2Lvoo4K/DTYqdPBhWjP+tdzX2TE2fAwuwvubJZFpXJO1bjjwKbOx3wi/6bhamcddhmx349aJIkEkewuf0haoXjfF596fT3QogUA10ouOSMe4dgODb0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1689086241; 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=w4AkLcWlNr9LBKASb6qOU6JhPd1K/1uOOyCDnvwtw90=; b=b6VMhqX5tmmMbTKWOqRs3lH/uZsnZiVYMLF9ZYVerjvXHp6hgqL4bANrdhwdurAg8knIjXdP0x3gvj1upYvc3uhWVWY4GMFetieCJQoq5lSlFEPH/PoKAJyzUKDQ9BYawfo9EQzAHY8yI7JkYgS0MRZ+QyT+bT0D0GurRcOZpVk= 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+106796+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 1689086241310963.9618750828702; Tue, 11 Jul 2023 07:37:21 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=V/aXS7/r7NOgWvCsmtEmUZRMEEjTZkellL6spfgrSlA=; 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=1689086239; v=1; b=KHFjAVdJi87QmvqJEIRmcnjYxG/mzhZ9YPOzLq1syXBiRB2pGZvIaAbAEL3klfb2+FeT+xM6 /dv9VcvuUcXcste6Hr9pdZPY3qr4q6oWzsWn6Lnr505nz6Xln9ECKVTkQqL3aKYZH475XVYis2k wj0rPEdaVcfGWlPqrCcIS3Yo= X-Received: by 127.0.0.2 with SMTP id TcjqYY1788612xedXeBUF4b9; Tue, 11 Jul 2023 07:37:19 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web11.1230.1689086238870353729 for ; Tue, 11 Jul 2023 07:37:19 -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 B44381FB; Tue, 11 Jul 2023 07:38:00 -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 96B7E3F740; Tue, 11 Jul 2023 07:37:17 -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 04/20] ArmPkg: Add data structures to receive FF-A boot information Date: Tue, 11 Jul 2023 15:36:42 +0100 Message-Id: <20230711143658.781597-5-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: YhZqraPVvoaTSDOc2NFpssoYx1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1689086242702100018 Content-Type: text/plain; charset="utf-8" From: Achin Gupta The SPMC will pass the manifest to the StMM SP which contains the boot information required for SP initialisation. This patch defines the data structures defined in Section 5.4 of the FF-A v1.1 BETA0 spec to enable this support. The manifest is identified by the TF-A UUID_TOS_FW_CONFIG. Signed-off-by: Achin Gupta Signed-off-by: Nishant Sharma --- ArmPkg/Include/IndustryStandard/ArmFfaSvc.h | 69 +++++++++++++++++++- 1 file changed, 68 insertions(+), 1 deletion(-) diff --git a/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h b/ArmPkg/Include/I= ndustryStandard/ArmFfaSvc.h index 4126a4985bb2..54cc96598032 100644 --- a/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h +++ b/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h @@ -3,7 +3,7 @@ communication between S-EL0 and the Secure Partition Manager(SPM) =20 - Copyright (c) 2020, ARM Limited. All rights reserved. + Copyright (c) 2020 - 2023, ARM Limited. All rights reserved. =20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -53,4 +53,71 @@ // 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 =20 +/*************************************************************************= ***** + * Boot information protocol as per the FF-A v1.1 spec. + *************************************************************************= ****/ +#define FFA_INIT_DESC_SIGNATURE 0x00000FFA + +/* Boot information type. */ +#define FFA_BOOT_INFO_TYPE_STD 0x0U +#define FFA_BOOT_INFO_TYPE_IMPL 0x1U + +#define FFA_BOOT_INFO_TYPE_MASK 0x1U +#define FFA_BOOT_INFO_TYPE_SHIFT 0x7U +#define FFA_BOOT_INFO_TYPE(type) \ + (((type) & FFA_BOOT_INFO_TYPE_MASK) \ + << FFA_BOOT_INFO_TYPE_SHIFT) + +/* Boot information identifier. */ +#define FFA_BOOT_INFO_TYPE_ID_FDT 0x0U +#define FFA_BOOT_INFO_TYPE_ID_HOB 0x1U + +#define FFA_BOOT_INFO_TYPE_ID_MASK 0x3FU +#define FFA_BOOT_INFO_TYPE_ID_SHIFT 0x0U +#define FFA_BOOT_INFO_TYPE_ID(type) \ + (((type) & FFA_BOOT_INFO_TYPE_ID_MASK) \ + << FFA_BOOT_INFO_TYPE_ID_SHIFT) + +/* Format of Flags Name field. */ +#define FFA_BOOT_INFO_FLAG_NAME_STRING 0x0U +#define FFA_BOOT_INFO_FLAG_NAME_UUID 0x1U + +#define FFA_BOOT_INFO_FLAG_NAME_MASK 0x3U +#define FFA_BOOT_INFO_FLAG_NAME_SHIFT 0x0U +#define FFA_BOOT_INFO_FLAG_NAME(type) \ + (((type) & FFA_BOOT_INFO_FLAG_NAME_MASK) \ + << FFA_BOOT_INFO_FLAG_NAME_SHIFT) + +/* Format of Flags Contents field. */ +#define FFA_BOOT_INFO_FLAG_CONTENT_ADR 0x0U +#define FFA_BOOT_INFO_FLAG_CONTENT_VAL 0x1U + +#define FFA_BOOT_INFO_FLAG_CONTENT_MASK 0x1U +#define FFA_BOOT_INFO_FLAG_CONTENT_SHIFT 0x2U +#define FFA_BOOT_INFO_FLAG_CONTENT(content) \ + (((content) & FFA_BOOT_INFO_FLAG_CONTENT_MASK) \ + << FFA_BOOT_INFO_FLAG_CONTENT_SHIFT) + +// Descriptor to pass boot information as per the FF-A v1.1 spec. +typedef struct { + UINT32 Name[4]; + UINT8 Type; + UINT8 Reserved; + UINT16 Flags; + UINT32 SizeBotInfo; + UINT64 Content; +} EFI_FFA_BOOT_INFO_DESC; + +// Descriptor that contains boot info blobs size, number of desc it cointa= ins +// size of each descriptor and offset to the first descriptor. +typedef struct { + UINT32 Magic; // 0xFFA^M + UINT32 Version; + UINT32 SizeBootInfoBlob; + UINT32 SizeBootInfoDesc; + UINT32 CountBootInfoDesc; + UINT32 OffsetBootInfoDesc; + UINT64 Reserved; +} EFI_FFA_BOOT_INFO_HEADER; + #endif // ARM_FFA_SVC_H_ --=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 (#106796): https://edk2.groups.io/g/devel/message/106796 Mute This Topic: https://groups.io/mt/100079874/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- From nobody Fri May 10 05:43:06 2024 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+106797+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+106797+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1689086241; cv=none; d=zohomail.com; s=zohoarc; b=kgOYigdFmb79bWIKFH1G2P6NujXEm9M4GlPB8CyijqVHt+TLSaCUj9Jza651BLoFGoETJiNp2d4K79PN0RdP4VL4Uk4YYkLeYks+3sSwmwooM7Vzx7333J/NISmwKB5hIK1LaBoNm6WRkbpOIi3dPGp4l0Qf6/aAQ7epUomHYxE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1689086241; 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=esLqRLICL06egGO9+EvpV/K8cOPpHFgrdr7noIGJgyY=; b=NOou41vo5h55EWqGH6c6Mg1hl0Twqe1MrRHy1OYslIxARWjENIG7cMKtRdpFvnqf0QO0YDPf9m+7orNb6Uzf00dp65iuZ4CRMl62fbKTcuNF/7K751v0bqMeJFOYzx1JXcktwOAIuXJrUzetzgeaJRXIWKLu9tz7Y5fkhwyqZfQ= 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+106797+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 1689086241421168.82036882889577; Tue, 11 Jul 2023 07:37:21 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=Ufxf45iwP7dNYIiL16H9c4QlVHVpatiAp/yaxP4JyhQ=; 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=1689086240; v=1; b=U4pS2EIquYkIpGYHgzJbQO7wczxiD6hfO0okyu2jTwRWdXRWqiTzmY6qkxYaM1L/DZYboSsl evigO2Mf/+C+4x9gudvaiyvi+G9lAwWeIE/Wpgg+kp76rAQB11wqsAOz2mdyZrZ79pqLPOMuJkn fwFLje7q9L4T7WzHoQ+7xw2A= X-Received: by 127.0.0.2 with SMTP id ZdmzYY1788612xmHUIIk5FCa; Tue, 11 Jul 2023 07:37:20 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web10.1268.1689086239923198865 for ; Tue, 11 Jul 2023 07:37:20 -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 CA24F2F4; Tue, 11 Jul 2023 07:38:01 -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 AC6E83F740; Tue, 11 Jul 2023 07:37:18 -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 05/20] ArmPkg/ArmFfaSvc: Add helper macros and fids Date: Tue, 11 Jul 2023 15:36:43 +0100 Message-Id: <20230711143658.781597-6-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: JoNtYPDqeIaIi9c1Rzvg0T6ox1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1689086242631100017 Content-Type: text/plain; charset="utf-8" From: Achin Gupta Add new fid for Success, error and wait. Also add macro to generate FFA verions. Signed-off-by: Achin Gupta Signed-off-by: Nishant Sharma --- ArmPkg/Include/IndustryStandard/ArmFfaSvc.h | 21 +++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h b/ArmPkg/Include/I= ndustryStandard/ArmFfaSvc.h index 54cc96598032..c80d783fad3f 100644 --- a/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h +++ b/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h @@ -21,6 +21,11 @@ #define ARM_SVC_ID_FFA_MSG_SEND_DIRECT_RESP_AARCH32 0x84000070 #define ARM_SVC_ID_FFA_MSG_SEND_DIRECT_REQ_AARCH64 0xC400006F #define ARM_SVC_ID_FFA_MSG_SEND_DIRECT_RESP_AARCH64 0xC4000070 +#define ARM_SVC_ID_FFA_SUCCESS_AARCH32 0x84000061 +#define ARM_SVC_ID_FFA_SUCCESS_AARCH64 0xC4000061 +#define ARM_SVC_ID_FFA_ERROR_AARCH32 0x84000060 +#define ARM_SVC_ID_FFA_ERROR_AARCH64 0xC4000060 +#define ARM_SVC_ID_FFA_MSG_WAIT_AARCH32 0x8400006B =20 /* Generic IDs when using AArch32 or AArch64 execution state */ #ifdef MDE_CPU_AARCH64 @@ -35,7 +40,7 @@ #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_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 @@ -45,6 +50,20 @@ #define ARM_FFA_SPM_RET_RETRY -7 #define ARM_FFA_SPM_RET_ABORTED -8 =20 +// FF-A version helper macros +#define FFA_VERSION_MAJOR_SHIFT 16 +#define FFA_VERSION_MAJOR_MASK 0x7FFF +#define FFA_VERSION_MINOR_SHIFT 0 +#define FFA_VERSION_MINOR_MASK 0xFFFF +#define FFA_VERSION_BIT31_MASK (0x1u << 31) + +#define MAKE_FFA_VERSION(major, minor) \ + ((((major) & FFA_VERSION_MAJOR_MASK) << FFA_VERSION_MAJOR_SHIFT) | \ + (((minor) & FFA_VERSION_MINOR_MASK) << FFA_VERSION_MINOR_SHIFT)) + +#define FFA_VERSION_COMPILED MAKE_FFA_VERSION(SPM_MAJOR_VERSION= _FFA, \ + SPM_MINOR_VERSION_FFA) + // 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 --=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 (#106797): https://edk2.groups.io/g/devel/message/106797 Mute This Topic: https://groups.io/mt/100079876/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- From nobody Fri May 10 05:43:06 2024 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+106798+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+106798+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1689086244; cv=none; d=zohomail.com; s=zohoarc; b=QgWy3nuG+T5c94kQzV0YB212Re/6EanBeRO2E35mY6zz4Pz++wVTTXl5Xsj1GCW4lvB6L+pM+JPQlUlJdpBBZsLWtI+4VKJ4j1+0d636fLu8r4ubtnbe6lyT4vTefwhJdcfvEJ52kg2UR8Kq8KyywwgR1cylWfkCm7TQQppjgvQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1689086244; 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=CHlVqYHm66nmu5NtCjxcRkMUSpwrX6IVz1gBglljWPg=; b=W2mLyNi3ku/8JQcKJQCy0Nm6fVi1IZjLtAMLo1BzfRH+gb0p/Hfw+6Dw9CEG+itro+JSUhAkldq//Ky57nymZRXluXzyhLhp8mXl2X9Qawu6YD0/vFu1L63mvK45FJbioSAALOyyVwhIY0xP4ghUKwQYBPcl7seFkDehGkIOERE= 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+106798+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 1689086243726822.9109590195275; Tue, 11 Jul 2023 07:37:23 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=yM/dDYFfESp86BnT2lFCrFfr4KnHtLUoGXkr0ZmzVI8=; 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=1689086243; v=1; b=vvrZv+6iSfnFhdBHvZeUiA/0xkoU0hvgvKkj5xXf4no/TYlmfxmarH4LMgmR2XHRc6SCqcZZ +xQng6WZ+raD6cWHz+F2G4A25fgfjWW96UtMS3SEJHA+Eq7dmqikCyQfoamy2Omyps+KLA1hb/C DexF+MrO16oHkeqvdBkar5EY= X-Received: by 127.0.0.2 with SMTP id nLg4YY1788612xqIgbUhb41v; Tue, 11 Jul 2023 07:37:23 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web10.1270.1689086240976003632 for ; Tue, 11 Jul 2023 07:37:21 -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 E04BD1FB; Tue, 11 Jul 2023 07:38:02 -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 C24B13F740; Tue, 11 Jul 2023 07:37:19 -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 06/20] ArmPkg: Add support for FFA_MEM_PERM_GET/SET ABIs Date: Tue, 11 Jul 2023 15:36:44 +0100 Message-Id: <20230711143658.781597-7-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: xj2leTVnprAYD9LuUxnYekOOx1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1689086244891100026 Content-Type: text/plain; charset="utf-8" From: Achin Gupta This patch uses the FFA_MEM_PERM_GET/SET ABIs to tweak the permissions of a set of pages if FF-A v1.1 and above is supported by the SPMC. For FF-A v1.0 the previous method through FFA_MSG_SEND_DIRECT_REQ/RESP is used. Signed-off-by: Achin Gupta Signed-off-by: Nishant Sharma --- ArmPkg/Include/IndustryStandard/ArmFfaSvc.h | 2 + ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.c | 132 ++++++++++= +++++++--- 2 files changed, 120 insertions(+), 14 deletions(-) diff --git a/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h b/ArmPkg/Include/I= ndustryStandard/ArmFfaSvc.h index c80d783fad3f..7987678c996e 100644 --- a/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h +++ b/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h @@ -23,6 +23,8 @@ #define ARM_SVC_ID_FFA_MSG_SEND_DIRECT_RESP_AARCH64 0xC4000070 #define ARM_SVC_ID_FFA_SUCCESS_AARCH32 0x84000061 #define ARM_SVC_ID_FFA_SUCCESS_AARCH64 0xC4000061 +#define ARM_SVC_ID_FFA_MEM_PERM_SET_AARCH32 0x84000089 +#define ARM_SVC_ID_FFA_MEM_PERM_GET_AARCH32 0x84000088 #define ARM_SVC_ID_FFA_ERROR_AARCH32 0x84000060 #define ARM_SVC_ID_FFA_ERROR_AARCH64 0xC4000060 #define ARM_SVC_ID_FFA_MSG_WAIT_AARCH32 0x8400006B diff --git a/ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.c b/Ar= mPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.c index 1a41a289ef17..76ef214bcb85 100644 --- a/ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.c +++ b/ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.c @@ -25,6 +25,66 @@ #include #include =20 + +/** + Utility function to determine whether ABIs in FF-A v1.1 to set and get + memory permissions can be used. Ideally, this should be invoked once in = the + library constructor and set a flag that can be used at runtime. However,= the + StMM Core invokes this library before constructors are called and before= the + StMM image itself is relocated. + + @retval EFI_SUCCESS The availability of ABIs was correctly determine= d. + @retval Other value Software stack is misconfigured. + +**/ +STATIC +BOOLEAN +UseFfaMemPermAbis ( + VOID + ) +{ + ARM_SVC_ARGS SvcArgs; + UINT32 SpmcFfaVersion; + STATIC UINT16 SpmcMajorVer =3D 0; + STATIC UINT16 SpmcMinorVer =3D 0; + + // Use prefetched version info. if either is not 0, then the version is + // already fetched. + if ((SpmcMajorVer | SpmcMinorVer) !=3D 0) { + return (SpmcMajorVer =3D=3D SPM_MAJOR_VERSION_FFA) && (SpmcMinorVer >= =3D SPM_MINOR_VERSION_FFA); + } + + // Nothing to do if FF-A has not be enabled + if (FixedPcdGet32 (PcdFfaEnable) =3D=3D 0) { + return FALSE; + } + + // Prepare the message parameters. + ZeroMem (&SvcArgs, sizeof (ARM_SVC_ARGS)); + SvcArgs.Arg0 =3D ARM_SVC_ID_FFA_VERSION_AARCH32; + SvcArgs.Arg1 =3D FFA_VERSION_COMPILED; + + // Invoke the ABI + ArmCallSvc (&SvcArgs); + + // Check if FF-A is supported and what version + SpmcFfaVersion =3D SvcArgs.Arg0; + + // Damn! FF-A is not supported at all even though we specified v1.0 as o= ur + // version. However, the feature flag has been turned on. This is a + // misconfigured software stack. So, return an error and assert in a deb= ug build. + if (SpmcFfaVersion =3D=3D ARM_FFA_SPM_RET_NOT_SUPPORTED) { + ASSERT (0); + return FALSE; + } + + SpmcMajorVer =3D (SpmcFfaVersion >> FFA_VERSION_MAJOR_SHIFT) & FFA_VERSI= ON_MAJOR_MASK; + SpmcMinorVer =3D (SpmcFfaVersion >> FFA_VERSION_MINOR_SHIFT) & FFA_VERSI= ON_MINOR_MASK; + + return (SpmcMajorVer =3D=3D SPM_MAJOR_VERSION_FFA) && (SpmcMinorVer >=3D= SPM_MINOR_VERSION_FFA); +} + + /** Send memory permission request to target. =20 @param [in, out] SvcArgs Pointer to SVC arguments to send. On @@ -55,6 +115,36 @@ SendMemoryPermissionRequest ( =20 ArmCallSvc (SvcArgs); if (FixedPcdGet32 (PcdFfaEnable) !=3D 0) { + + // Check if FF-A memory permission ABIs were used. + if (UseFfaMemPermAbis()) { + switch (SvcArgs->Arg0) { + + case ARM_SVC_ID_FFA_ERROR_AARCH32: + case ARM_SVC_ID_FFA_ERROR_AARCH64: + switch (SvcArgs->Arg2) { + case ARM_FFA_SPM_RET_INVALID_PARAMETERS: + return EFI_INVALID_PARAMETER; + case ARM_FFA_SPM_RET_NOT_SUPPORTED: + return EFI_UNSUPPORTED; + default: + // Undefined error code received. + ASSERT (0); + return EFI_INVALID_PARAMETER; + } + + case ARM_SVC_ID_FFA_SUCCESS_AARCH32: + case ARM_SVC_ID_FFA_SUCCESS_AARCH64: + *RetVal =3D SvcArgs->Arg2; + return EFI_SUCCESS; + + default: + // Undefined error code received. + ASSERT (0); + return EFI_INVALID_PARAMETER; + } + } + // Get/Set 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 @@ -164,12 +254,18 @@ GetMemoryPermissions ( // See [1], Section 13.5.5.1 MM_SP_MEMORY_ATTRIBUTES_GET_AARCH64. ZeroMem (&SvcArgs, sizeof (ARM_SVC_ARGS)); if (FixedPcdGet32 (PcdFfaEnable) !=3D 0) { - // See [2], Section 10.2 FFA_MSG_SEND_DIRECT_REQ. - SvcArgs.Arg0 =3D ARM_SVC_ID_FFA_MSG_SEND_DIRECT_REQ; - SvcArgs.Arg1 =3D ARM_FFA_DESTINATION_ENDPOINT_ID; - SvcArgs.Arg2 =3D 0; - SvcArgs.Arg3 =3D ARM_SVC_ID_SP_GET_MEM_ATTRIBUTES; - SvcArgs.Arg4 =3D BaseAddress; + // Check if FF-A memory permission ABIs can be used. + if (UseFfaMemPermAbis()) { + SvcArgs.Arg0 =3D ARM_SVC_ID_FFA_MEM_PERM_GET_AARCH32; + SvcArgs.Arg1 =3D BaseAddress; + } else { + // See [2], Section 10.2 FFA_MSG_SEND_DIRECT_REQ. + SvcArgs.Arg0 =3D ARM_SVC_ID_FFA_MSG_SEND_DIRECT_REQ; + SvcArgs.Arg1 =3D ARM_FFA_DESTINATION_ENDPOINT_ID; + SvcArgs.Arg2 =3D 0; + SvcArgs.Arg3 =3D ARM_SVC_ID_SP_GET_MEM_ATTRIBUTES; + SvcArgs.Arg4 =3D BaseAddress; + } } else { SvcArgs.Arg0 =3D ARM_SVC_ID_SP_GET_MEM_ATTRIBUTES; SvcArgs.Arg1 =3D BaseAddress; @@ -219,14 +315,22 @@ RequestMemoryPermissionChange ( // See [1], Section 13.5.5.2 MM_SP_MEMORY_ATTRIBUTES_SET_AARCH64. ZeroMem (&SvcArgs, sizeof (ARM_SVC_ARGS)); if (FixedPcdGet32 (PcdFfaEnable) !=3D 0) { - // See [2], Section 10.2 FFA_MSG_SEND_DIRECT_REQ. - SvcArgs.Arg0 =3D ARM_SVC_ID_FFA_MSG_SEND_DIRECT_REQ; - SvcArgs.Arg1 =3D ARM_FFA_DESTINATION_ENDPOINT_ID; - SvcArgs.Arg2 =3D 0; - SvcArgs.Arg3 =3D ARM_SVC_ID_SP_SET_MEM_ATTRIBUTES; - SvcArgs.Arg4 =3D BaseAddress; - SvcArgs.Arg5 =3D EFI_SIZE_TO_PAGES (Length); - SvcArgs.Arg6 =3D Permissions; + // Check if FF-A memory permission ABIs can be used. + if (UseFfaMemPermAbis()) { + SvcArgs.Arg0 =3D ARM_SVC_ID_FFA_MEM_PERM_SET_AARCH32; + SvcArgs.Arg1 =3D BaseAddress; + SvcArgs.Arg2 =3D EFI_SIZE_TO_PAGES (Length); + SvcArgs.Arg3 =3D Permissions; + } else { + // See [2], Section 10.2 FFA_MSG_SEND_DIRECT_REQ. + SvcArgs.Arg0 =3D ARM_SVC_ID_FFA_MSG_SEND_DIRECT_REQ; + SvcArgs.Arg1 =3D ARM_FFA_DESTINATION_ENDPOINT_ID; + SvcArgs.Arg2 =3D 0; + SvcArgs.Arg3 =3D ARM_SVC_ID_SP_SET_MEM_ATTRIBUTES; + SvcArgs.Arg4 =3D BaseAddress; + SvcArgs.Arg5 =3D EFI_SIZE_TO_PAGES (Length); + SvcArgs.Arg6 =3D Permissions; + } } else { SvcArgs.Arg0 =3D ARM_SVC_ID_SP_SET_MEM_ATTRIBUTES; SvcArgs.Arg1 =3D BaseAddress; --=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 (#106798): https://edk2.groups.io/g/devel/message/106798 Mute This Topic: https://groups.io/mt/100079878/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- From nobody Fri May 10 05:43:06 2024 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+106799+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+106799+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1689086243; cv=none; d=zohomail.com; s=zohoarc; b=Imdf0GTfO0tsca7WzGueldu2fJadA4fVYjttWnXPGBzMzlkq5Q3Rn6jWbe/K4i9xp/6snq6Ipm1p5CnBobgA0dnJLIGFxwQh0olZaa9RH1Os3dxMs9lbB3S34pr4Yno1XI6dQza9yRSYIPUCbZP5Aj8wgYSB8xKCr23ZV2JjHXM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1689086243; 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=EIwZaK3KBEw0MXWLkIWU5tWbiEL9AzPOCNK0vALmII4=; b=WLoI2ZnVk9e7n0vN7z7LvwExkZ+ebOkXwNXszhP6YE0WwIFFHQvCUHwF1TszdYcblRgRPrc4bTHHliqhd7bLYgxQ7Qe9LLtjx1oRCeteqsaV9HxG+zA1w2xNrTr+UHNoE8gutJsGtuA9TT8DOYutMlxtIZ7lzqZunbHnrra4mhY= 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+106799+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 1689086243062541.7836263972516; Tue, 11 Jul 2023 07:37:23 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=fzialcYbUVbpBaasDNvWm/ErKaguAq+1ugoIDGUCLd0=; 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=1689086242; v=1; b=aV/78V90mBbfd3DhcgnQbwm75haT9CeK9P2obFcir++VS7etb89KjgIW+5YIpOwpjswwv6cD xGmuK1uKlBzcU0AblVcTcSuoBKSeGY1CktjBmV7bkfFWdaR98P/3mF6+uXeux5dw7PuPD6NcU8R xbTBK7SSlFCqY9DfMqLFE+w4= X-Received: by 127.0.0.2 with SMTP id So8wYY1788612x2yBKvFFt3d; Tue, 11 Jul 2023 07:37:22 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web11.1232.1689086242061438071 for ; Tue, 11 Jul 2023 07:37:22 -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 022452F4; Tue, 11 Jul 2023 07:38:04 -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 D85E13F740; Tue, 11 Jul 2023 07:37:20 -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 07/20] StandaloneMmPkg: define new data structure to stage FF-A boot information Date: Tue, 11 Jul 2023 15:36:45 +0100 Message-Id: <20230711143658.781597-8-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: AmG0xtOShpVhXElDaNJJrBknx1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1689086244678100024 Content-Type: text/plain; charset="utf-8" From: Achin Gupta With FF-A v1.1, the SPMC sends a reduced amount of boot information as compared to the original SPM implementation. For example, the stack layout, MP information etc. This information could be accommodated in the old data structure but this is too complicated. This patch defines a new structure to clearly separate FF-A v1.1 and other functionality. Signed-off-by: Achin Gupta Signed-off-by: Nishant Sharma --- StandaloneMmPkg/Include/Library/Arm/StandaloneMmCoreEntryPoint.h | 21 ++++= ++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/StandaloneMmPkg/Include/Library/Arm/StandaloneMmCoreEntryPoint= .h b/StandaloneMmPkg/Include/Library/Arm/StandaloneMmCoreEntryPoint.h index 41bf0f132b4f..c965192c702e 100644 --- a/StandaloneMmPkg/Include/Library/Arm/StandaloneMmCoreEntryPoint.h +++ b/StandaloneMmPkg/Include/Library/Arm/StandaloneMmCoreEntryPoint.h @@ -47,6 +47,27 @@ typedef struct { EFI_SECURE_PARTITION_CPU_INFO *CpuInfo; } EFI_SECURE_PARTITION_BOOT_INFO; =20 + +/** + This structure is used to stage boot information required to initialize = the + standalone MM environment when FF-A is used as the interface between this + secure partition and the SPMC. This structure supersedes + EFI_SECURE_PARTITION_BOOT_INFO and reduces the amount of information tha= t must + be passed by the SPMC for SP initialization. +**/ +typedef struct { + UINT64 SpMemBase; + UINT64 SpMemSize; + UINT64 SpNsCommBufBase; + UINT64 SpNsCommBufSize; + UINT64 SpSharedBufBase; + UINT64 SpSharedBufSize; + UINT64 SpHeapBase; + UINT64 SpHeapSize; + /* UP migrate-able FF-A SP requires awareness of only 1 cpu */ + EFI_SECURE_PARTITION_CPU_INFO CpuInfo; +} EFI_STMM_BOOT_INFO; + typedef EFI_STATUS (*PI_MM_ARM_TF_CPU_DRIVER_ENTRYPOINT) ( --=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 (#106799): https://edk2.groups.io/g/devel/message/106799 Mute This Topic: https://groups.io/mt/100079879/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- From nobody Fri May 10 05:43:06 2024 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+106800+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+106800+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1689086244; cv=none; d=zohomail.com; s=zohoarc; b=htPKgOBfrTjwMGeDCs3cttInvkRFS3a1ButAHRapI+vvIoe3RzQ4NQJlP1SElF1Htm4qDIwPQ1gXcUQFM2K4XILtuw0wuGtP5R/sTmIytnJB0EPF4WE01lx4XGTc0R9zV91yES1XWJvUXi8BiBgAsbw18ajr6/3z83M8spgBu/M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1689086244; 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=wfbP4m5tRZ2YWdDHHDAgMITlSpuRtiIg3qQ7TDul7x0=; b=bZ1cOS28mgPenUcFJAJW+IjnzJRaI08vFLl9eLdBhFpMoEbPD0Gr7N8cyWe09W5SMGiIvEdJayI/i+9QrTHAdZOhzWTVS/yZiuROOhEBeo9zi1OyvB7KWKJtL+fQpy7bhy0MM9DOk012Rp4LlsZQE6NDUx7HPSoCZVCVEQoTl7o= 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+106800+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 1689086244749410.29216986674726; Tue, 11 Jul 2023 07:37:24 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=mljBc2dzO+7YkrfMXBheY9obsUR8uu3iCXP91Lt3gRM=; 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=1689086244; v=1; b=AWzBi3b+g3W6dUFwPSDXfMkuspY5ULuAUyWIaj/zf7qDS+PwN0FyQhjC3ug6TIeVy1p0Nwp5 dsU6fREr0mDwWTGZOfLx0X/QIN/r7uoUmjcI1nDKJpXZbOgpPSu7vkqw7fyRGdJZkuraPyyUfIP 9hFoLrPzU/ke2qCt3Own+SNM= X-Received: by 127.0.0.2 with SMTP id wjUAYY1788612xRao2HbZmKO; Tue, 11 Jul 2023 07:37:24 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web11.1233.1689086243199488614 for ; Tue, 11 Jul 2023 07:37:23 -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 178631FB; Tue, 11 Jul 2023 07:38:05 -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 EE2773F740; Tue, 11 Jul 2023 07:37:21 -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 08/20] StandaloneMmPkg: Add backwards compatible support to detect FF-A v1.1 Date: Tue, 11 Jul 2023 15:36:46 +0100 Message-Id: <20230711143658.781597-9-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: quBEwrjW3yNe63GRo9QBZH4hx1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1689086246739100031 Content-Type: text/plain; charset="utf-8" From: Achin Gupta For better or worse, an StMM SP can communicate with the SPM through one of these interfaces. 1. SPM_MM interface 2. FF-A v1.0 interface 3. FF-A v1.1 interface 2) implements only minimal FF-A support. It reuses the initialisation ABI defined by 1) and wraps the remaining communicaton in FFA_MSG_SEND_DIRECT_REQ/RESP ABIs. 3) uses FF-A ABIs from the spec for both initialisation and communication. Detecting these variations in the GetSpmVersion() function is tedious. This patch restores the original function that discovered configuration 1). It defines a new function to discover presence of FF-A and differentiate between v1.0 and v1.1. Signed-off-by: Achin Gupta Signed-off-by: Nishant Sharma --- StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEnt= ryPoint.c | 132 +++++++++++++------- 1 file changed, 87 insertions(+), 45 deletions(-) diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/Standal= oneMmCoreEntryPoint.c b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/= Arm/StandaloneMmCoreEntryPoint.c index 682b55b5478a..9f6af55c86c4 100644 --- a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCo= reEntryPoint.c +++ b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCo= reEntryPoint.c @@ -32,13 +32,9 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #define SPM_MAJOR_VER_MASK 0xFFFF0000 #define SPM_MINOR_VER_MASK 0x0000FFFF #define SPM_MAJOR_VER_SHIFT 16 -#define FFA_NOT_SUPPORTED -1 =20 -STATIC CONST UINT32 mSpmMajorVer =3D SPM_MAJOR_VERSION; -STATIC CONST UINT32 mSpmMinorVer =3D SPM_MINOR_VERSION; - -STATIC CONST UINT32 mSpmMajorVerFfa =3D SPM_MAJOR_VERSION_FFA; -STATIC CONST UINT32 mSpmMinorVerFfa =3D SPM_MINOR_VERSION_FFA; +#define SPM_MAJOR_VER 0 +#define SPM_MINOR_VER 1 =20 #define BOOT_PAYLOAD_VERSION 1 =20 @@ -110,6 +106,70 @@ GetAndPrintBootinformation ( } =20 return PayloadBootInfo; + +/** + An StMM SP implements partial support for FF-A v1.0. The FF-A ABIs are u= sed to + get and set permissions of memory pages in collaboration with the SPMC a= nd + signalling completion of initialisation. The original Arm MM communicati= on + interface is used for communication with the Normal world. A TF-A specif= ic + interface is used for initialising the SP. + + With FF-A v1.1, the StMM SP uses only FF-A ABIs for initialisation and + communication. This is subject to support for FF-A v1.1 in the SPMC. If = this + is not the case, the StMM implementation reverts to the FF-A v1.0 + behaviour. Any of this is applicable only if the feature flag PcdFfaEnab= le is + TRUE. + + This function helps the caller determine whether FF-A v1.1 or v1.0 are + available and if only FF-A ABIs can be used at runtime. +**/ +STATIC +EFI_STATUS +CheckFfaCompatibility (BOOLEAN *UseOnlyFfaAbis) +{ + UINT16 SpmcMajorVer; + UINT16 SpmcMinorVer; + UINT32 SpmcVersion; + ARM_SVC_ARGS SpmcVersionArgs =3D {0}; + + // Sanity check in case of a spurious call. + if (FixedPcdGet32 (PcdFfaEnable) =3D=3D 0) { + return EFI_UNSUPPORTED; + } + + // Send the SPMC our version to see whether it supports the same or not. + SpmcVersionArgs.Arg0 =3D ARM_SVC_ID_FFA_VERSION_AARCH32; + SpmcVersionArgs.Arg1 =3D FFA_VERSION_COMPILED; + + ArmCallSvc (&SpmcVersionArgs); + SpmcVersion =3D SpmcVersionArgs.Arg0; + + // If the SPMC barfs then bail. + if (SpmcVersion =3D=3D ARM_FFA_SPM_RET_NOT_SUPPORTED) { + return EFI_UNSUPPORTED; + } + + // Extract the SPMC version + SpmcMajorVer =3D (SpmcVersion >> FFA_VERSION_MAJOR_SHIFT) & FFA_VERSION_= MAJOR_MASK; + SpmcMinorVer =3D (SpmcVersion >> FFA_VERSION_MINOR_SHIFT) & FFA_VERSION_= MINOR_MASK; + + // If the major versions differ then all bets are off. + if (SpmcMajorVer !=3D SPM_MAJOR_VERSION_FFA) { + return EFI_UNSUPPORTED; + } + + // We advertised v1.1 as our version. If the SPMC supports it, it must r= eturn + // the same or a compatible version. If it does not then FF-A ABIs canno= t be + // used for all communication. + if (SpmcMinorVer >=3D SPM_MINOR_VERSION_FFA) { + *UseOnlyFfaAbis =3D TRUE; + } else { + *UseOnlyFfaAbis =3D FALSE; + } + + // We have validated that there is a compatible FF-A + // implementation. So. return success. + return EFI_SUCCESS; } =20 /** @@ -219,34 +279,19 @@ GetSpmVersion ( ) { EFI_STATUS Status; - UINT16 CalleeSpmMajorVer; - UINT16 CallerSpmMajorVer; - UINT16 CalleeSpmMinorVer; - UINT16 CallerSpmMinorVer; + UINT16 SpmMajorVersion; + UINT16 SpmMinorVersion; UINT32 SpmVersion; ARM_SVC_ARGS SpmVersionArgs; =20 - if (FixedPcdGet32 (PcdFfaEnable) !=3D 0) { - SpmVersionArgs.Arg0 =3D ARM_SVC_ID_FFA_VERSION_AARCH32; - SpmVersionArgs.Arg1 =3D mSpmMajorVerFfa << SPM_MAJOR_VER_SHIFT; - SpmVersionArgs.Arg1 |=3D mSpmMinorVerFfa; - CallerSpmMajorVer =3D mSpmMajorVerFfa; - CallerSpmMinorVer =3D mSpmMinorVerFfa; - } else { - SpmVersionArgs.Arg0 =3D ARM_SVC_ID_SPM_VERSION_AARCH32; - CallerSpmMajorVer =3D mSpmMajorVer; - CallerSpmMinorVer =3D mSpmMinorVer; - } + SpmVersionArgs.Arg0 =3D ARM_SVC_ID_SPM_VERSION_AARCH32; =20 ArmCallSvc (&SpmVersionArgs); =20 SpmVersion =3D SpmVersionArgs.Arg0; - if (SpmVersion =3D=3D FFA_NOT_SUPPORTED) { - return EFI_UNSUPPORTED; - } =20 - CalleeSpmMajorVer =3D ((SpmVersion & SPM_MAJOR_VER_MASK) >> SPM_MAJOR_VE= R_SHIFT); - CalleeSpmMinorVer =3D ((SpmVersion & SPM_MINOR_VER_MASK) >> 0); + SpmMajorVersion =3D ((SpmVersion & SPM_MAJOR_VER_MASK) >> SPM_MAJOR_VER_= SHIFT); + SpmMinorVersion =3D ((SpmVersion & SPM_MINOR_VER_MASK) >> 0); =20 // Different major revision values indicate possibly incompatible functi= ons. // For two revisions, A and B, for which the major revision values are @@ -255,25 +300,17 @@ GetSpmVersion ( // revision A must work in a compatible way with revision B. // However, it is possible for revision B to have a higher // function count than revision A. - if ((CalleeSpmMajorVer =3D=3D CallerSpmMajorVer) && - (CalleeSpmMinorVer >=3D CallerSpmMinorVer)) - { - DEBUG (( - DEBUG_INFO, - "SPM Version: Major=3D0x%x, Minor=3D0x%x\n", - CalleeSpmMajorVer, - CalleeSpmMinorVer - )); + if ((SpmMajorVersion =3D=3D SPM_MAJOR_VER) && + (SpmMinorVersion >=3D SPM_MINOR_VER)) { + DEBUG ((DEBUG_INFO, "SPM Version: Major=3D0x%x, Minor=3D0x%x\n", + SpmMajorVersion, SpmMinorVersion)); Status =3D EFI_SUCCESS; } else { - DEBUG (( - DEBUG_INFO, - "Incompatible SPM Versions.\n Callee Version: Major=3D0x%x, Minor=3D= 0x%x.\n Caller: Major=3D0x%x, Minor>=3D0x%x.\n", - CalleeSpmMajorVer, - CalleeSpmMinorVer, - CallerSpmMajorVer, - CallerSpmMinorVer - )); + DEBUG ((DEBUG_INFO, "Incompatible SPM Versions.\n")); + DEBUG ((DEBUG_INFO, "Current Version: Major=3D0x%x, Minor=3D0x%x.\n", + SpmMajorVersion, SpmMinorVersion)); + DEBUG ((DEBUG_INFO, "Expected: Major=3D0x%x, Minor>=3D0x%x.\n", + SPM_MAJOR_VER, SPM_MINOR_VER)); Status =3D EFI_UNSUPPORTED; } =20 @@ -335,9 +372,14 @@ ModuleEntryPoint ( VOID *TeData; UINTN TeDataSize; EFI_PHYSICAL_ADDRESS ImageBase; + BOOLEAN UseOnlyFfaAbis =3D FALSE; =20 - // Get Secure Partition Manager Version Information - Status =3D GetSpmVersion (); + if (FixedPcdGet32 (PcdFfaEnable) !=3D 0) { + Status =3D CheckFfaCompatibility (&UseOnlyFfaAbis); + } else { + // Get Secure Partition Manager Version Information + Status =3D GetSpmVersion (); + } if (EFI_ERROR (Status)) { goto finish; } --=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 (#106800): https://edk2.groups.io/g/devel/message/106800 Mute This Topic: https://groups.io/mt/100079880/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- From nobody Fri May 10 05:43:06 2024 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+106801+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+106801+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1689086246; cv=none; d=zohomail.com; s=zohoarc; b=IrEdRRtOrLcoJ8FzE6V+68ViwJGLxJOIC6Bc/auDjMi5WadelKF297ZEkyWaCKIp+I6iL/Bw+jwGMyArVyOqOnjkgL84p3bKgZnaBqtvbPQmaixCbeXGJNSHY46d3ICF1JnyHhcO4XIOu2kMIGqNy5hM50mfJxSLR6hqg56ZrNY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1689086246; 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=KeIhsYbrCxdu7pIYrlSIwex6DqOPSZjJjHAMAEpGu0g=; b=kHP1P5S9KhwfES57O2BAIVAoPRYkTBozCGPxG3n2LXnqE56CpxPfVoBMOJt5UAQBzLx0+P9Jeyc594UBvrZF3ilLVgFZIDNwVevpvJXpAju9chMPTPzOXWrt8hzkAHujAW+w4XuQ+gpnZpYaQFNexx7ATxD6b61GGhUvv6TZ06U= 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+106801+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 1689086246201227.8440142944346; Tue, 11 Jul 2023 07:37:26 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=bDBFbsjQS5bfbaumjKVs+dpeQb7KKW15gzhvhHH5Etk=; 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=1689086245; v=1; b=Os6Z/ODojNg5/CRVtTO1DGhzMtqKsBRToP9c5yWTP4rzAbLwYE07aj7VN6S1eLNTpMbgDMTv iMYwsbd8a9/1tkVKcb1/cU0epSapWQX9XPaXUFjvlMZJaEUfXj5v4cVt0tmHKFpLMylw0n7zd2B zO3KBqeZhHM9cbFj0mBlXGls= X-Received: by 127.0.0.2 with SMTP id jCdOYY1788612xsITE7TUOAX; Tue, 11 Jul 2023 07:37:25 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web11.1236.1689086244288038659 for ; Tue, 11 Jul 2023 07:37:24 -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 2DA0F2F4; Tue, 11 Jul 2023 07:38:06 -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 0FB213F740; Tue, 11 Jul 2023 07:37:22 -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 09/20] StandaloneMmPkg: parse SP manifest and populate new boot information Date: Tue, 11 Jul 2023 15:36:47 +0100 Message-Id: <20230711143658.781597-10-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: KFjIOQ6zbqF63jpXg2cDiYZ7x1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1689086246657100030 Content-Type: text/plain; charset="utf-8" From: Achin Gupta This patch discovers the SP manifest in DT format passed by the SPMC. It then parses it to obtain the boot information required to initialise the SP. Signed-off-by: Achin Gupta Signed-off-by: Sayanta Pattanayak Signed-off-by: Nishant Sharma --- StandaloneMmPkg/Include/Library/Arm/StandaloneMmCoreEntryPoint.h = | 2 +- StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEnt= ryPoint.c | 389 +++++++++++++++++++- 2 files changed, 381 insertions(+), 10 deletions(-) diff --git a/StandaloneMmPkg/Include/Library/Arm/StandaloneMmCoreEntryPoint= .h b/StandaloneMmPkg/Include/Library/Arm/StandaloneMmCoreEntryPoint.h index c965192c702e..90d67a2f25b5 100644 --- a/StandaloneMmPkg/Include/Library/Arm/StandaloneMmCoreEntryPoint.h +++ b/StandaloneMmPkg/Include/Library/Arm/StandaloneMmCoreEntryPoint.h @@ -2,7 +2,7 @@ Entry point to the Standalone MM Foundation when initialized during the = SEC phase on ARM platforms =20 -Copyright (c) 2017 - 2021, Arm Ltd. All rights reserved.
+Copyright (c) 2017 - 2023, Arm Ltd. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/Standal= oneMmCoreEntryPoint.c b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/= Arm/StandaloneMmCoreEntryPoint.c index 9f6af55c86c4..505786aff07c 100644 --- a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCo= reEntryPoint.c +++ b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCo= reEntryPoint.c @@ -38,6 +38,10 @@ SPDX-License-Identifier: BSD-2-Clause-Patent =20 #define BOOT_PAYLOAD_VERSION 1 =20 +#define FFA_PAGE_4K 0 +#define FFA_PAGE_16K 1 +#define FFA_PAGE_64K 2 + PI_MM_ARM_TF_CPU_DRIVER_ENTRYPOINT CpuDriverEntryPoint =3D NULL; =20 /** @@ -106,6 +110,7 @@ GetAndPrintBootinformation ( } =20 return PayloadBootInfo; +} =20 /** An StMM SP implements partial support for FF-A v1.0. The FF-A ABIs are u= sed to @@ -266,6 +271,308 @@ DelegatedEventLoop ( } } =20 +STATIC +BOOLEAN +CheckDescription ( + IN VOID * DtbAddress, + IN INT32 Offset, + OUT CHAR8 * Description, + OUT UINT32 Size + ) +{ + CONST CHAR8 * Property; + INT32 LenP; + + Property =3D fdt_getprop (DtbAddress, Offset, "description", &LenP); + if (Property =3D=3D NULL) { + return FALSE; + } + + return CompareMem (Description, Property, MIN(Size, (UINT32)LenP)) =3D=3D= 0; + +} + +STATIC +EFI_STATUS +ReadProperty32 ( + IN VOID * DtbAddress, + IN INT32 Offset, + IN CHAR8 * Property, + OUT UINT32 * Value + ) +{ + CONST UINT32 * Property32; + + Property32 =3D fdt_getprop (DtbAddress, Offset, Property, NULL); + if (Property32 =3D=3D NULL) { + DEBUG (( + DEBUG_ERROR, + "%s: Missing in FF-A boot information manifest\n", + Property + )); + return EFI_INVALID_PARAMETER; + } + + *Value =3D fdt32_to_cpu (*Property32); + + return EFI_SUCCESS; +} + +STATIC +EFI_STATUS +ReadProperty64 ( + IN VOID * DtbAddress, + IN INT32 Offset, + IN CHAR8 * Property, + OUT UINT64 * Value + ) +{ + CONST UINT64 * Property64; + + Property64 =3D fdt_getprop (DtbAddress, Offset, Property, NULL); + if (Property64 =3D=3D NULL) { + DEBUG (( + DEBUG_ERROR, + "%s: Missing in FF-A boot information manifest\n", + Property + )); + return EFI_INVALID_PARAMETER; + } + + *Value =3D fdt64_to_cpu (*Property64); + + return EFI_SUCCESS; +} + +STATIC +BOOLEAN +ReadRegionInfo ( + IN VOID *DtbAddress, + IN INT32 Node, + IN CHAR8 *Region, + IN UINTN RegionStrSize, + IN UINT32 PageSize, + OUT UINT64 *Address, + OUT UINT64 *Size + ) +{ + BOOLEAN FoundBuffer; + INTN Status =3D 0; + + FoundBuffer =3D CheckDescription ( + DtbAddress, + Node, + Region, + RegionStrSize + ); + if (!FoundBuffer) { + return FALSE; + } + + DEBUG ((DEBUG_INFO, "Found Node: %a\n", Region)); + Status =3D ReadProperty64 ( + DtbAddress, + Node, + "base-address", + Address + ); + if (Status !=3D EFI_SUCCESS) { + DEBUG ((DEBUG_ERROR, "base-address missing in DTB")); + return FALSE; + } + DEBUG (( + DEBUG_INFO, + "base =3D 0x%llx\n", + *Address + )); + + Status =3D ReadProperty32 ( + DtbAddress, + Node, + "pages-count", + (UINT32*)Size + ); + if (Status !=3D EFI_SUCCESS) { + DEBUG ((DEBUG_ERROR, "pages-count missing in DTB")); + return FALSE; + } + + DEBUG ((DEBUG_ERROR, "pages-count: 0x%lx\n", *Size)); + + *Size =3D *Size * PageSize; + DEBUG (( + DEBUG_INFO, + "Size =3D 0x%llx\n", + *Size + )); + + return TRUE; +} + +/** + + Populates FF-A boot information structure. + + This function receives the address of a DTB from which boot information = defind + by FF-A and required to initialize the standalone environment is extract= ed. + + @param [in, out] StmmBootInfo Pointer to a pre-allocated boot info stru= cture to be + populated. + @param [in] DtbAddress Address of the Device tree from where boot + information will be fetched. +**/ +STATIC +EFI_STATUS +PopulateBootinformation ( + IN OUT EFI_STMM_BOOT_INFO *StmmBootInfo, + IN VOID *DtbAddress +) +{ + INTN Status; + INT32 Offset; + INT32 Node; + BOOLEAN FoundNsCommBuffer =3D FALSE; + BOOLEAN FoundSharedBuffer =3D FALSE; + BOOLEAN FoundHeap =3D FALSE; + UINT32 PageSize; + + Offset =3D fdt_node_offset_by_compatible (DtbAddress, -1, "arm,ffa-manif= est-1.0"); + DEBUG ((DEBUG_INFO, "Offset =3D %d \n", Offset)); + if (Offset < 0) { + DEBUG ((DEBUG_ERROR, "Missing FF-A boot information in manifest\n")); + return EFI_NOT_FOUND; + } + + Status =3D ReadProperty64 ( + DtbAddress, + Offset, + "load-address", + &StmmBootInfo->SpMemBase + ); + if (Status !=3D EFI_SUCCESS) { + return Status; + } + DEBUG ((DEBUG_INFO, "sp mem base =3D 0x%llx\n", StmmBootInfo->SpMemBase= )); + + Status =3D ReadProperty64 ( + DtbAddress, + Offset, + "image-size", + &StmmBootInfo->SpMemSize + ); + if (Status !=3D EFI_SUCCESS) { + return Status; + } + DEBUG ((DEBUG_INFO, "sp mem size =3D 0x%llx\n", StmmBootInfo->SpMemSize= )); + + Status =3D ReadProperty32 (DtbAddress, Offset, "xlat-granule", &PageSize= ); + if (Status !=3D EFI_SUCCESS) { + return Status; + } + + /* EFI_PAGE_SIZE is 4KB */ + switch (PageSize) { + case FFA_PAGE_4K: + PageSize =3D EFI_PAGE_SIZE; + break; + + case FFA_PAGE_16K: + PageSize =3D 4 * EFI_PAGE_SIZE; + break; + + case FFA_PAGE_64K: + PageSize =3D 16 * EFI_PAGE_SIZE; + break; + + default: + DEBUG ((DEBUG_ERROR, "Invalid page type =3D %lu\n", PageSize)); + return EFI_INVALID_PARAMETER; + break; + }; + + DEBUG ((DEBUG_INFO, "Page Size =3D 0x%lx\n", PageSize)); + + Offset =3D fdt_subnode_offset_namelen ( + DtbAddress, + Offset, + "memory-regions", + sizeof("memory-regions") - 1 + ); + if (Offset < 1) { + DEBUG (( + DEBUG_ERROR, + "%s: Missing in FF-A boot information manifest\n", + "memory-regions" + )); + return EFI_INVALID_PARAMETER; + } + + for ( + Node =3D fdt_first_subnode (DtbAddress, Offset); + Node > 0; + Node =3D fdt_next_subnode (DtbAddress, Node)) { + if (!FoundNsCommBuffer) { + FoundNsCommBuffer =3D ReadRegionInfo ( + DtbAddress, + Node, + "ns-comm", + sizeof ("ns-comm") - 1, + PageSize, + &StmmBootInfo->SpNsCommBufBase, + &StmmBootInfo->SpNsCommBufSize + ); + } + + if (!FoundHeap) { + FoundHeap =3D ReadRegionInfo ( + DtbAddress, + Node, + "heap", + sizeof ("heap") - 1, + PageSize, + &StmmBootInfo->SpHeapBase, + &StmmBootInfo->SpHeapSize + ); + } + + if (!FoundSharedBuffer) { + FoundSharedBuffer =3D ReadRegionInfo ( + DtbAddress, + Node, + "shared-buff", + sizeof ("shared-buff") - 1, + PageSize, + &StmmBootInfo->SpSharedBufBase, + &StmmBootInfo->SpSharedBufSize + ); + } + } + + if (!FoundNsCommBuffer) { + DEBUG ((DEBUG_ERROR, "Failed to find ns-comm buffer info\n")); + return EFI_INVALID_PARAMETER; + } + + if (!FoundHeap) { + DEBUG ((DEBUG_ERROR, "Failed to find heap buffer info\n")); + return EFI_INVALID_PARAMETER; + } + + if (!FoundSharedBuffer) { + DEBUG ((DEBUG_ERROR, "Failed to find shared buffer info\n")); + return EFI_INVALID_PARAMETER; + } + + // Populate CPU information under the assumption made in the FF-A spec t= hat + // this is a uniprocessor SP that is capable of migration. So, it is fin= e if + // it sees 0 as both its physical and linear cpu id + StmmBootInfo->CpuInfo.Mpidr =3D 0; + StmmBootInfo->CpuInfo.LinearId =3D 0; + StmmBootInfo->CpuInfo.Flags =3D 0; + + return EFI_SUCCESS; +} + /** Query the SPM version, check compatibility and return success if compati= ble. =20 @@ -343,6 +650,49 @@ InitArmSvcArgs ( } } =20 + +STATIC +EFI_STATUS +GetSpManifest ( + IN OUT UINT64 **SpManifestAddr, + IN VOID *BootInfoAddr + ) +{ + EFI_FFA_BOOT_INFO_HEADER *FfaBootInfo; + EFI_FFA_BOOT_INFO_DESC *FfaBootInfoDesc; + + // Paranoid check to avoid an inadvertent NULL pointer dereference. + if (BootInfoAddr =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "FF-A Boot information is NULL\n")); + return EFI_INVALID_PARAMETER; + } + + // Check boot information magic number. + FfaBootInfo =3D (EFI_FFA_BOOT_INFO_HEADER *) BootInfoAddr; + if (FfaBootInfo->Magic !=3D FFA_INIT_DESC_SIGNATURE) { + DEBUG (( + DEBUG_ERROR, "FfaBootInfo Magic no. is invalid 0x%ux\n", + FfaBootInfo->Magic + )); + return EFI_INVALID_PARAMETER; + } + + + FfaBootInfoDesc =3D + (EFI_FFA_BOOT_INFO_DESC *)((UINT8 *)BootInfoAddr + + FfaBootInfo->OffsetBootInfoDesc); + + if (FfaBootInfoDesc->Type =3D=3D + (FFA_BOOT_INFO_TYPE(FFA_BOOT_INFO_TYPE_STD) | + FFA_BOOT_INFO_TYPE_ID(FFA_BOOT_INFO_TYPE_ID_FDT))) { + *SpManifestAddr =3D (UINT64 *) FfaBootInfoDesc->Content; + return EFI_SUCCESS; + } + + DEBUG ((DEBUG_ERROR, "SP manifest not found \n")); + return EFI_NOT_FOUND; +} + /** The entry point of Standalone MM Foundation. =20 @@ -363,6 +713,7 @@ ModuleEntryPoint ( { PE_COFF_LOADER_IMAGE_CONTEXT ImageContext; EFI_SECURE_PARTITION_BOOT_INFO *PayloadBootInfo; + EFI_STMM_BOOT_INFO StmmBootInfo =3D {0}; ARM_SVC_ARGS InitMmFoundationSvcArgs; EFI_STATUS Status; INT32 Ret; @@ -372,6 +723,8 @@ ModuleEntryPoint ( VOID *TeData; UINTN TeDataSize; EFI_PHYSICAL_ADDRESS ImageBase; + UINT64 *DtbAddress; + EFI_FIRMWARE_VOLUME_HEADER *BfvAddress; BOOLEAN UseOnlyFfaAbis =3D FALSE; =20 if (FixedPcdGet32 (PcdFfaEnable) !=3D 0) { @@ -384,18 +737,36 @@ ModuleEntryPoint ( goto finish; } =20 - PayloadBootInfo =3D GetAndPrintBootinformation (SharedBufAddress); - if (PayloadBootInfo =3D=3D NULL) { - Status =3D EFI_UNSUPPORTED; - goto finish; + // If only FF-A is used, the DTB address is passed in the Boot informati= on + // structure. Else, the Boot info is copied from Sharedbuffer. + if (UseOnlyFfaAbis) { + Status =3D GetSpManifest (&DtbAddress, SharedBufAddress); + if (Status !=3D EFI_SUCCESS) { + goto finish; + } + + // Extract boot information from the DTB + Status =3D PopulateBootinformation (&StmmBootInfo, (VOID *) DtbAddress= ); + if (Status !=3D EFI_SUCCESS) { + goto finish; + } + + // Stash the base address of the boot firmware volume + BfvAddress =3D (EFI_FIRMWARE_VOLUME_HEADER *) StmmBootInfo.SpMemBase; + } else { + PayloadBootInfo =3D GetAndPrintBootinformation (SharedBufAddress); + if (PayloadBootInfo =3D=3D NULL) { + Status =3D EFI_UNSUPPORTED; + goto finish; + } + + // Stash the base address of the boot firmware volume + BfvAddress =3D (EFI_FIRMWARE_VOLUME_HEADER *) PayloadBootInfo->SpImage= Base; } =20 + // Locate PE/COFF File information for the Standalone MM core module - Status =3D LocateStandaloneMmCorePeCoffData ( - (EFI_FIRMWARE_VOLUME_HEADER *)(UINTN)PayloadBootInfo->SpImage= Base, - &TeData, - &TeDataSize - ); + Status =3D LocateStandaloneMmCorePeCoffData (BfvAddress, &TeData, &TeDat= aSize); =20 if (EFI_ERROR (Status)) { goto finish; --=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 (#106801): https://edk2.groups.io/g/devel/message/106801 Mute This Topic: https://groups.io/mt/100079881/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- From nobody Fri May 10 05:43:06 2024 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+106802+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+106802+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1689086247; cv=none; d=zohomail.com; s=zohoarc; b=TU72A9qLNS+MQ+8JZ0Zc13FKhdm1hSS3PxQvC0HMVuGWuEBsw8Ldm/ZyfhMnG0cMGq3vDwcEjJb6yuWi8zPyFubSQ3EBedSFZO9Z+mqK9CXkfQsFIjcqxQ9uum+M3YJT62L/CDrIktX7SGmq3FMU+sNU8TUeu6YNoVdtV+2VjXs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1689086247; 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=jAlot1g58m+O2VeRfaV0WJ9HNZ3Ybw8SVZoF30N8Cno=; b=cxyhZ4QTn4k1UsB9+p2PsGKc5lIdBk7QiiUVCrybxFZJ8KvRFemx6zOzKumBGsfnq5PfYkAk7Sv5OyPMkuw3PyzPXFCFYdWxDRpRLFOFkgA4iGC3QBUyVC9AK4ghS0CwM3kTDvFTZcsN5J7C3yY7Frru6/JFQTtYoZSjIW161zk= 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+106802+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 1689086246689418.2933780912447; Tue, 11 Jul 2023 07:37:26 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=VHyNkahJlxiDMruuNOrXxP8p7aXJVNaKzyrQIshKT+A=; 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=1689086246; v=1; b=HCRauhdb6WtyWIdXupe+3Au+6fVEW1zzVCCRzIMY0QS2EtwepaJTixS+lbOuVdhKRB9Q1mG0 FZ4gvycMDoXnVtR2kV3jeXt4OILt28ujlMGnklMc6MPKFTN8JZb1zt7cahySkDSQjom+1eVOUrh OqC28lfPgMFK5MLwEhl9Ko0M= X-Received: by 127.0.0.2 with SMTP id FJUTYY1788612xvnBs4XR8fB; Tue, 11 Jul 2023 07:37:26 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web10.1273.1689086245339188894 for ; Tue, 11 Jul 2023 07:37:25 -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 4316C1FB; Tue, 11 Jul 2023 07:38:07 -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 255CF3F740; Tue, 11 Jul 2023 07:37:24 -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 10/20] StandaloneMmPkg: Populate Hoblist for SP init from StMM boot information Date: Tue, 11 Jul 2023 15:36:48 +0100 Message-Id: <20230711143658.781597-11-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: JYlV2J5RL9UlQEUBiVywddyVx1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1689086248691100040 Content-Type: text/plain; charset="utf-8" From: Achin Gupta This patch adds support for creating a hoblist from the reduced boot information retrieved from the SP manifest. Signed-off-by: Achin Gupta Signed-off-by: Nishant Sharma --- StandaloneMmPkg/Include/Library/Arm/StandaloneMmCoreEntryPoint.h = | 16 ++ StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/CreateHobList.c = | 186 +++++++++++++++++++- StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEnt= ryPoint.c | 6 +- 3 files changed, 206 insertions(+), 2 deletions(-) diff --git a/StandaloneMmPkg/Include/Library/Arm/StandaloneMmCoreEntryPoint= .h b/StandaloneMmPkg/Include/Library/Arm/StandaloneMmCoreEntryPoint.h index 90d67a2f25b5..9daa76324221 100644 --- a/StandaloneMmPkg/Include/Library/Arm/StandaloneMmCoreEntryPoint.h +++ b/StandaloneMmPkg/Include/Library/Arm/StandaloneMmCoreEntryPoint.h @@ -170,6 +170,22 @@ CreateHobListFromBootInfo ( IN EFI_SECURE_PARTITION_BOOT_INFO *PayloadBootInfo ); =20 +/** + Use the boot information passed by the SPMC to populate a HOB list + suitable for consumption by the MM Core and drivers. + + @param [in, out] CpuDriverEntryPoint Address of MM CPU driver entrypo= int + @param [in] StmmBootInfo Boot information passed by privi= leged + firmware + +**/ +VOID * +EFIAPI +CreateHobListFromStmmBootInfo ( + IN OUT PI_MM_ARM_TF_CPU_DRIVER_ENTRYPOINT *CpuDriverEntryPoint, + IN EFI_STMM_BOOT_INFO *StmmBootInfo + ); + /** The entry point of Standalone MM Foundation. =20 diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/CreateH= obList.c b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/CreateHob= List.c index 2ac2d354f06a..4592089a6020 100644 --- a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/CreateHobList.c +++ b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/CreateHobList.c @@ -2,7 +2,7 @@ Creates HOB during Standalone MM Foundation entry point on ARM platforms. =20 -Copyright (c) 2017 - 2021, Arm Ltd. All rights reserved.
+Copyright (c) 2017 - 2023, Arm Ltd. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -203,3 +203,187 @@ CreateHobListFromBootInfo ( =20 return HobStart; } + +STATIC +VOID +CreateMmramInformationHobFromImageLayout ( + IN EFI_STMM_BOOT_INFO *StmmBootInfo, + IN EFI_HOB_HANDOFF_INFO_TABLE *HobStart +) +{ + UINT32 *Idx; + UINT32 BufferSize; + EFI_MMRAM_HOB_DESCRIPTOR_BLOCK *MmramRangesHob; + EFI_MMRAM_DESCRIPTOR *MmramRanges; + + // Find the size of the GUIDed HOB with SRAM ranges. This excludes any m= emory + // shared with the normal world or the SPMC. It includes the memory allo= cated + // to the SP image, used and unused heap. + BufferSize =3D sizeof (EFI_MMRAM_HOB_DESCRIPTOR_BLOCK); + BufferSize +=3D 4 * sizeof (EFI_MMRAM_DESCRIPTOR); + + // Create a GUIDed HOB with SRAM ranges + MmramRangesHob =3D BuildGuidHob (&gEfiMmPeiMmramMemoryReserveGuid, Buffe= rSize); + + // Initialise the number of MMRAM memory regions + MmramRangesHob->NumberOfMmReservedRegions =3D 0; + Idx =3D &MmramRangesHob->NumberOfMmReservedRegions ; + + // Fill up the MMRAM ranges + MmramRanges =3D &MmramRangesHob->Descriptor[0]; + + // Base and size of memory occupied by the Standalone MM image + MmramRanges[*Idx].PhysicalStart =3D StmmBootInfo->SpMemBase; + MmramRanges[*Idx].CpuStart =3D StmmBootInfo->SpMemBase; + MmramRanges[*Idx].PhysicalSize =3D StmmBootInfo->SpMemSize; + MmramRanges[*Idx].RegionState =3D EFI_CACHEABLE | EFI_ALLOCATED; + (*Idx)++; + + // Base and size of memory occupied by the Standalone MM image + MmramRanges[*Idx].PhysicalStart =3D StmmBootInfo->SpSharedBufBase; + MmramRanges[*Idx].CpuStart =3D StmmBootInfo->SpSharedBufBase; + MmramRanges[*Idx].PhysicalSize =3D StmmBootInfo->SpSharedBufSize; + MmramRanges[*Idx].RegionState =3D EFI_CACHEABLE | EFI_ALLOCATED; + (*Idx)++; + + // Base and size of memory occupied by the hoblist + MmramRanges[*Idx].PhysicalStart =3D (EFI_PHYSICAL_ADDRESS) (UINTN) HobSt= art; + MmramRanges[*Idx].CpuStart =3D (EFI_PHYSICAL_ADDRESS) (UINTN) HobSt= art; + MmramRanges[*Idx].PhysicalSize =3D HobStart->EfiFreeMemoryBottom - (EFI= _PHYSICAL_ADDRESS) (UINTN) HobStart; + MmramRanges[*Idx].RegionState =3D EFI_CACHEABLE | EFI_ALLOCATED; + (*Idx)++; + + // Base and size of heap memory shared by all cpus + MmramRanges[*Idx].PhysicalStart =3D HobStart->EfiFreeMemoryBottom; + MmramRanges[*Idx].CpuStart =3D HobStart->EfiFreeMemoryBottom; + MmramRanges[*Idx].PhysicalSize =3D HobStart->EfiFreeMemoryTop - HobStar= t->EfiFreeMemoryBottom; + MmramRanges[*Idx].RegionState =3D EFI_CACHEABLE; + (*Idx)++; + + // Sanity check number of MMRAM regions + ASSERT (MmramRangesHob->NumberOfMmReservedRegions =3D=3D 3); + + return; +} + +STATIC +VOID +CreateMpInformationHobFromCpuInfo ( + IN EFI_SECURE_PARTITION_CPU_INFO *CpuInfo +) +{ + MP_INFORMATION_HOB_DATA *MpInformationHobData; + EFI_PROCESSOR_INFORMATION *ProcInfoBuffer; + UINT32 BufferSize; + UINT32 Flags; + + // Find the size of the GUIDed HOB with MP information + BufferSize =3D sizeof (MP_INFORMATION_HOB_DATA); + BufferSize +=3D sizeof (EFI_PROCESSOR_INFORMATION); + + // Create a Guided MP information HOB to enable the ARM TF CPU driver to + // perform per-cpu allocations. + MpInformationHobData =3D BuildGuidHob (&gMpInformationHobGuid, BufferSiz= e); + + // Populate the MP information HOB under the assumption that this is a + // uniprocessor partition. Hence, only a single CPU is exposed to the MM= Core. + MpInformationHobData->NumberOfProcessors =3D 1; + MpInformationHobData->NumberOfEnabledProcessors =3D 1; + + // Populate the processor information + ProcInfoBuffer =3D MpInformationHobData->ProcessorInfoBuffer; + ProcInfoBuffer[0].ProcessorId =3D CpuInfo[0].Mpidr; + ProcInfoBuffer[0].Location.Package =3D GET_CLUSTER_ID(CpuInfo[0].Mpidr); + ProcInfoBuffer[0].Location.Core =3D GET_CORE_ID(CpuInfo[0].Mpidr); + ProcInfoBuffer[0].Location.Thread =3D GET_CORE_ID(CpuInfo[0].Mpidr); + + // Populate the processor information flags + Flags =3D PROCESSOR_ENABLED_BIT | PROCESSOR_HEALTH_STATUS_BIT | PROCESSO= R_AS_BSP_BIT; + ProcInfoBuffer[0].StatusFlag =3D Flags; + + return; +} + +/** + Use the FF-A boot information passed by the SPMC to populate a HOB list + suitable for consumption by the MM Core and drivers. + + @param [in, out] CpuDriverEntryPoint Address of MM CPU driver entrypo= int + @param [in] StmmBootInfo Boot information passed by the S= PMC + +**/ +VOID * +CreateHobListFromStmmBootInfo ( + IN OUT PI_MM_ARM_TF_CPU_DRIVER_ENTRYPOINT *CpuDriverEntryPoint, + IN EFI_STMM_BOOT_INFO *StmmBootInfo +) +{ + EFI_HOB_HANDOFF_INFO_TABLE *HobStart; + EFI_RESOURCE_ATTRIBUTE_TYPE Attributes; + EFI_MMRAM_DESCRIPTOR *NsCommBufMmramRange; + ARM_TF_CPU_DRIVER_EP_DESCRIPTOR *CpuDriverEntryPointDesc; + + // Create a hoblist with a PHIT and EOH + HobStart =3D HobConstructor ( + (VOID *) (UINTN) StmmBootInfo->SpMemBase, + (UINTN) StmmBootInfo->SpMemSize, + (VOID *) (UINTN) StmmBootInfo->SpHeapBase, + (VOID *) (UINTN) (StmmBootInfo->SpHeapBase + StmmBootInfo->= SpHeapSize) + ); + + // Check that the Hoblist starts at the bottom of the Heap + ASSERT (HobStart =3D=3D (VOID *) (UINTN) StmmBootInfo->SpHeapBase); + + // Build a Boot Firmware Volume HOB + BuildFvHob (StmmBootInfo->SpMemBase, StmmBootInfo->SpMemSize); + + // Build a resource descriptor Hob that describes the available physical + // memory range + Attributes =3D ( + EFI_RESOURCE_ATTRIBUTE_PRESENT | + EFI_RESOURCE_ATTRIBUTE_INITIALIZED | + EFI_RESOURCE_ATTRIBUTE_TESTED | + EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE | + EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE | + EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE | + EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE + ); + + BuildResourceDescriptorHob ( + EFI_RESOURCE_SYSTEM_MEMORY, + Attributes, + (UINTN) StmmBootInfo->SpMemBase, + StmmBootInfo->SpMemSize + ); + + // Create an MP information hob from cpu information passed in the boot + // information structure + CreateMpInformationHobFromCpuInfo(&StmmBootInfo->CpuInfo); + + // Create a Guided HOB to tell the ARM TF CPU driver the location and le= ngth + // of the communication buffer shared with the Normal world. + NsCommBufMmramRange =3D (EFI_MMRAM_DESCRIPTOR *) BuildGuidHob ( + &gEfiStandaloneMmNonSec= ureBufferGuid, + sizeof (EFI_MMRAM_DESCR= IPTOR) + ); + NsCommBufMmramRange->PhysicalStart =3D StmmBootInfo->SpNsCommBufBase; + NsCommBufMmramRange->CpuStart =3D StmmBootInfo->SpNsCommBufBase; + NsCommBufMmramRange->PhysicalSize =3D StmmBootInfo->SpNsCommBufSize; + NsCommBufMmramRange->RegionState =3D EFI_CACHEABLE | EFI_ALLOCATED; + + // Create a Guided HOB to enable the ARM TF CPU driver to share its entry + // point and populate it with the address of the shared buffer + CpuDriverEntryPointDesc =3D + (ARM_TF_CPU_DRIVER_EP_DESCRIPTOR *) BuildGuidHob ( + &gEfiArmTfCpuDriverEpDescriptorGuid, + sizeof (ARM_TF_CPU_DRIVER_EP_DESCRIPTOR) + ); + + *CpuDriverEntryPoint =3D NULL; + CpuDriverEntryPointDesc->ArmTfCpuDriverEpPtr =3D CpuDriverEntryPoint; + + // Create Mmram range hob from SP image layout + CreateMmramInformationHobFromImageLayout(StmmBootInfo, HobStart); + + return HobStart; +} diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/Standal= oneMmCoreEntryPoint.c b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/= Arm/StandaloneMmCoreEntryPoint.c index 505786aff07c..8131b1984969 100644 --- a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCo= reEntryPoint.c +++ b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCo= reEntryPoint.c @@ -823,7 +823,11 @@ ModuleEntryPoint ( // // Create Hoblist based upon boot information passed by privileged softw= are // - HobStart =3D CreateHobListFromBootInfo (&CpuDriverEntryPoint, PayloadBoo= tInfo); + if (UseOnlyFfaAbis) { + HobStart =3D CreateHobListFromStmmBootInfo (&CpuDriverEntryPoint, &Stm= mBootInfo); + } else { + HobStart =3D CreateHobListFromBootInfo (&CpuDriverEntryPoint, PayloadB= ootInfo); + } =20 // // Call the MM Core entry point --=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 (#106802): https://edk2.groups.io/g/devel/message/106802 Mute This Topic: https://groups.io/mt/100079882/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- From nobody Fri May 10 05:43:06 2024 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+106803+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+106803+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1689086247; cv=none; d=zohomail.com; s=zohoarc; b=Tyx1XEjwLpQikpNopGdgLgovz4rHYTZ4WJv/EPMJ1lv68BtoKmlLG7NhlHx08yJzLEmFwJD3c6zbm2F+UzHMnyy0VGggESm5vnQz92VVJYVIqm6/2E9YuSO9SRePB6sWmrCeuKuEZ+/MAOen21gxY+FHLqQtHF8/w272I9VjBIw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1689086247; 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=GfRze4OMdBJTnYxE9K68deBT5CcsZzfTD0xX2OxcWx0=; b=UZ/EM0gCwRPw9FPHf55HicC5HRjRxKEN9EpdYOxs95M/FCQZu7QPX7jqMYm+C+Lg1V18FC/4IRpn6k0in8ZM/yMszpHmWODnaCVl9A3ufolLCIGiBNpWZoaIxBzPpeCVIJX1zEVNq3WWGr6y29ns0jUE87UTuoO7pajkB4uDX/Q= 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+106803+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 1689086247553122.50619770313597; Tue, 11 Jul 2023 07:37:27 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=f64OS4HKk2bNpjQIKASAT3TkdqfcfE/4od+1IIKIk54=; 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=1689086247; v=1; b=mMwWTheAWk2KmVmjvvAPFDr0a8dhClGh33b9FzvsKsw4vYoPEMLB1wtr/umh76SMOxEpHYG+ XGEKXJ6DvN0PvwAe1+NaFxDKEnz3xx9PQXI3P8UpDYT65w/KBeilxKcGAVmRsD6MsTEeqfBJ6KD vq8RqNp2aKe8bCeDG+dbfFfk= X-Received: by 127.0.0.2 with SMTP id nzFwYY1788612xrvQYhzHrf6; Tue, 11 Jul 2023 07:37:27 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web10.1274.1689086246420024141 for ; Tue, 11 Jul 2023 07:37:26 -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 5882EC15; Tue, 11 Jul 2023 07:38:08 -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 3AF423F740; Tue, 11 Jul 2023 07:37:25 -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 11/20] StandaloneMmPkg: Skip zero sized sections while tweaking page permissions Date: Tue, 11 Jul 2023 15:36:49 +0100 Message-Id: <20230711143658.781597-12-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: OzJMw30wvM8iP9rPvS2zVJRRx1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1689086249388100047 Content-Type: text/plain; charset="utf-8" From: Achin Gupta This patch skips zero sized sections in the StMM SP image e.g. .reloc since there is no point in attempting to change their permissions. Signed-off-by: Achin Gupta Signed-off-by: Nishant Sharma --- StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/SetPermissions.c | = 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/SetPerm= issions.c b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/SetPermi= ssions.c index 5c6bd0e1d7d2..891e79b32b6f 100644 --- a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/SetPermissions= .c +++ b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/SetPermissions= .c @@ -2,7 +2,7 @@ Locate, get and update PE/COFF permissions during Standalone MM Foundation Entry point on ARM platforms. =20 -Copyright (c) 2017 - 2021, Arm Ltd. All rights reserved.
+Copyright (c) 2017 - 2023, Arm Ltd. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -118,6 +118,22 @@ UpdateMmFoundationPeCoffPermissions ( ImageContext->ImageAddress, SectionHeader.PointerToRawData )); + DEBUG (( + DEBUG_INFO, + "%a: Section %d of image at 0x%lx has %d bytes size\n", + __func__, Index, + ImageContext->ImageAddress, + SectionHeader.Misc.VirtualSize + )); + + // Skip sections with a size of 0 + if (SectionHeader.Misc.VirtualSize =3D=3D 0) { + DEBUG (( + DEBUG_INFO, + "%a: Skipping section %a \n", __func__, SectionHeader.Name + )); + continue; + } =20 // // If the section is marked as XN then remove the X attribute. Further= more, --=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 (#106803): https://edk2.groups.io/g/devel/message/106803 Mute This Topic: https://groups.io/mt/100079883/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- From nobody Fri May 10 05:43:06 2024 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+106804+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+106804+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1689086248; cv=none; d=zohomail.com; s=zohoarc; b=SDGfDhjRYlHORdv1jIn6Uys5T3Ym9GBegLbnSHy/poidKXOLReHhif1ixh+bDF48YTx8z1PL4tcGH3uqwWP++Gqtt22+XsoWD9vf03OpjaJ51pe/M4ptXcoMv6HaDKoU+9hSD0JJb8zN8TAeshO4qeeuOWSW21hq4RsiQ4dAlqw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1689086248; 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=+asN74hOxRoNDXZn1BDxZNTCXmSb7F/XBrlljOn1Y9c=; b=YohS5KEzPVYSqkIeje6LWlqzvdStWrNLc55SobGDDalvgWrN6KGPpejLhtVV/pUNiB1Vc526M6oQMl1AmcczI2ZHMI3CP3C3vgn6X+ZVu51VLNwtIyV5thAorh6Qt4R0vbyMDbUdOacy5/fpSZspa4olo6wbk0jEb/54ADXNmxs= 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+106804+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 1689086248429609.8255219297649; Tue, 11 Jul 2023 07:37:28 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=zrTHw44PTuvI7lqictNbYyA3mKRSM0mIxowu7JRSGGk=; 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=1689086248; v=1; b=aw/HpmGpHuRvX7qhfUR4wfFDFj1iJm2qdQ/EISAJ5xFUX9Vc1N/wnH1yeyzMALKCp/b8Zkid ukwcwG185g9ww1xR/3AJgnA7Jlh+nsal7RePMd3SS7XmG0wwCareAe8cTFoAqQpOFH4aNxAtKfy r8HM60I4a48WpDpsRg9w1h/I= X-Received: by 127.0.0.2 with SMTP id 04s0YY1788612xM7qbr0aygU; Tue, 11 Jul 2023 07:37:28 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web11.1240.1689086247507308090 for ; Tue, 11 Jul 2023 07:37:27 -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 6DECF2F4; Tue, 11 Jul 2023 07:38:09 -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 5082E3F740; Tue, 11 Jul 2023 07:37:26 -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 12/20] StandaloneMmPkg: Add global check for FF-A abis Date: Tue, 11 Jul 2023 15:36:50 +0100 Message-Id: <20230711143658.781597-13-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: kashQijy5JQaz7IpnpjSYWk8x1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1689086248862100045 Content-Type: text/plain; charset="utf-8" From: Achin Gupta This patch copies the value of the corresponding stack variable to a global variable so that it can be used to determine whether FF-A v1.1 or earlier ABIs should be used for communication with the SPMC. Signed-off-by: Achin Gupta Signed-off-by: Nishant Sharma --- StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEnt= ryPoint.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/Standal= oneMmCoreEntryPoint.c b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/= Arm/StandaloneMmCoreEntryPoint.c index 8131b1984969..a763bf8509b2 100644 --- a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCo= reEntryPoint.c +++ b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCo= reEntryPoint.c @@ -42,6 +42,12 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #define FFA_PAGE_16K 1 #define FFA_PAGE_64K 2 =20 +// Local variable to help Standalone MM Core decide whether FF-A ABIs can = be +// used for all communication. This variable is usable only after the StMM= image +// has been relocated and all image section permissions have been correctly +// updated. +STATIC BOOLEAN mUseOnlyFfaAbis =3D FALSE; + PI_MM_ARM_TF_CPU_DRIVER_ENTRYPOINT CpuDriverEntryPoint =3D NULL; =20 /** @@ -639,6 +645,13 @@ InitArmSvcArgs ( ) { if (FixedPcdGet32 (PcdFfaEnable) !=3D 0) { + + // With FF-A v1.1 invoke FFA_MSG_WAIT to signal completion of SP init. + if (mUseOnlyFfaAbis) { + InitMmFoundationSvcArgs->Arg0 =3D ARM_SVC_ID_FFA_MSG_WAIT_AARCH32; + return; + } + InitMmFoundationSvcArgs->Arg0 =3D ARM_SVC_ID_FFA_MSG_SEND_DIRECT_RESP; InitMmFoundationSvcArgs->Arg1 =3D 0; InitMmFoundationSvcArgs->Arg2 =3D 0; @@ -820,6 +833,9 @@ ModuleEntryPoint ( ASSERT_EFI_ERROR (Status); } =20 + // Update the global copy now that the image has been relocated. + mUseOnlyFfaAbis =3D UseOnlyFfaAbis; + // // Create Hoblist based upon boot information passed by privileged softw= are // --=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 (#106804): https://edk2.groups.io/g/devel/message/106804 Mute This Topic: https://groups.io/mt/100079884/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- From nobody Fri May 10 05:43:06 2024 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+106805+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+106805+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1689086249; cv=none; d=zohomail.com; s=zohoarc; b=c1M87co5lVrDM8pjIo0N5NP560bn9aI5p9EPukyKOyGTFoubITtq2uGrNjXGEuaHzmI98k8q+8/4adScM/z2XqnnxtfQnq5NvzPxwmmWZPBtzZFcARG3GaQoSPa+dUMFnFwhJ9J6V+Bf2SUK3/6HgRKf6PThNMrdONw+SxdaJ6E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1689086249; 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=4ifqxCyP1qYmTdM2z5029bylzQr+wohgPtVLlmcyZ3I=; b=SlypCXlrEK+ZwC8Rjg6kE5TJqeGkXIH3Ql5M2/Ih+TBu5IJoSnrq8xIYCFXkdU3rGchU/jqfRzzbdGpLI3xCMv1OlHQZMJDbg6k+TfsGvCrtGuv2M7I38B5aD6N7dYSnWv85oAnE+mteJOKRkjYP/zlkzGD78WqV5vuOzUlR3Zg= 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+106805+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 1689086249677572.6584811037434; Tue, 11 Jul 2023 07:37:29 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=4XYvqkV66ZFKGkK9JlZCT24BNAwZZRBOVfVs0LNNVkw=; 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=1689086249; v=1; b=WD7emiw242xsILSsg1vNoTWDCTWcgvdrqPzYQfQQ3kWrSo/sQNugleds3SWY6kTcyRmjgFHF uwOoFhy2ki0w40L4QAjvdmLmuSM4TpEtSIgTQWt3bm6Acwf1jtdfFn4FE87bNkTjjKjq4J31X/d zs6uEuA4UFobG+TROqiMke+k= X-Received: by 127.0.0.2 with SMTP id 5FBbYY1788612xUexIGH4wbx; Tue, 11 Jul 2023 07:37:29 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web11.1242.1689086248670767458 for ; Tue, 11 Jul 2023 07:37:28 -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 8C88FC15; Tue, 11 Jul 2023 07:38:10 -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 660793F740; Tue, 11 Jul 2023 07:37:27 -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 13/20] ArmPkg: Bump the StMM SP FF-A minor version to 1 Date: Tue, 11 Jul 2023 15:36:51 +0100 Message-Id: <20230711143658.781597-14-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: gSvnYwV3rty7iQkMm512LtJZx1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1689086250852100053 Content-Type: text/plain; charset="utf-8" From: Achin Gupta Signed-off-by: Achin Gupta Signed-off-by: Nishant Sharma --- ArmPkg/Include/IndustryStandard/ArmFfaSvc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h b/ArmPkg/Include/I= ndustryStandard/ArmFfaSvc.h index 7987678c996e..4a51f9fb56af 100644 --- a/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h +++ b/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h @@ -40,7 +40,7 @@ #endif =20 #define SPM_MAJOR_VERSION_FFA 1 -#define SPM_MINOR_VERSION_FFA 0 +#define SPM_MINOR_VERSION_FFA 1 =20 #define ARM_FFA_SPM_RET_SUCCESS 0 #define ARM_FFA_SPM_RET_NOT_SUPPORTED -1 --=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 (#106805): https://edk2.groups.io/g/devel/message/106805 Mute This Topic: https://groups.io/mt/100079886/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- From nobody Fri May 10 05:43:06 2024 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+106806+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+106806+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1689086251; cv=none; d=zohomail.com; s=zohoarc; b=hxLl1f1Sp1GJVgtCDkrTjgcE26Vs7lJM8U0D0Yxi9A5rl0WqEc9keHXlm5dMsxkO4rlKadazpyODZB+TNyCrDJoacH+PkLGxoHIJjAfQyHtDP0UihMMkc4c++5UoAH6LvqpFdpu22bGrAKZArlJJ0yUxTMhLueZfDkkek4WydNQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1689086251; 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=/SSYfe1CaK3lJsdOusUZ4pxg5f46PWudzAn7Km0gZwo=; b=c/Od7jAYNrty03SonKNXEIA4BJEsMuDy9OKy/iQY8a3u4+gFZubuJicAUJSItb7MYXyH6EFwYs/M1aJYCZdSnqof3fmqpdX03lffktjEUji0iS/DsMzlbmYx2VY/y8NirqHUPJcsfIz/hzSWFzDfKHcEvZAV2pXKr9JQyu5o25U= 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+106806+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 1689086251301901.3505703607685; Tue, 11 Jul 2023 07:37:31 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=FSHNyyWbfVtP2Jil3xkGvEVahXBLx7jrMIlFJ0y6KQM=; 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=1689086250; v=1; b=jlAbs4s3UL8l6OGhNsxf6Hzx1ojQHFki/e9xiiy14OPtClqIRKUdi9i7VMf/rQdIB5TmDoQ1 LzNgJuOwPml6DS0Fvd5SuDNxdEp0LyljHpG8ekgWBv0mn9iBosVldirY4VoJGT85YEk/ojlvCG+ gQFpELYi5dyLP4yjEwniLb14= X-Received: by 127.0.0.2 with SMTP id X2FoYY1788612xvre5jIWAob; Tue, 11 Jul 2023 07:37:30 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web11.1243.1689086249724439219 for ; Tue, 11 Jul 2023 07:37:29 -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 A1F9C1FB; Tue, 11 Jul 2023 07:38:11 -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 848D63F740; Tue, 11 Jul 2023 07:37:28 -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 14/20] ArmPkg/MmCommunicationDxe: Introduce FF-A version check Date: Tue, 11 Jul 2023 15:36:52 +0100 Message-Id: <20230711143658.781597-15-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: HIMCdI4UXfUm8xCPlcXYg8yAx1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1689086252866100058 Content-Type: text/plain; charset="utf-8" From: Achin Gupta This patch adds support for querying whether FF-A v1.1 is supported by the FF-A impplementation. Signed-off-by: Achin Gupta Signed-off-by: Nishant Sharma --- ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf | 3 +++ ArmPkg/Drivers/MmCommunicationDxe/MmCommunicate.h | 7 ++++++- ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c | 17 ++++++++++++---= -- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf b/ArmPkg= /Drivers/MmCommunicationDxe/MmCommunication.inf index 05b6de73ff34..c15b1a7a86ae 100644 --- a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf +++ b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf @@ -31,6 +31,9 @@ ArmPkg/ArmPkg.dec MdePkg/MdePkg.dec =20 +[FixedPcd] + gArmTokenSpaceGuid.PcdFfaEnable + [LibraryClasses] ArmLib ArmSmcLib diff --git a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunicate.h b/ArmPkg/Dri= vers/MmCommunicationDxe/MmCommunicate.h index 5c5fcb576856..71edf7f49174 100644 --- a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunicate.h +++ b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunicate.h @@ -16,7 +16,12 @@ #define MM_MAJOR_VER(x) (((x) & MM_MAJOR_VER_MASK) >> MM_MAJOR_VER_SHIFT) #define MM_MINOR_VER(x) ((x) & MM_MINOR_VER_MASK) =20 +#if (FixedPcdGet32 (PcdFfaEnable) =3D=3D 1) #define MM_CALLER_MAJOR_VER 0x1UL -#define MM_CALLER_MINOR_VER 0x0 +#define MM_CALLER_MINOR_VER 0x1UL +#else +#define MM_CALLER_MAJOR_VER 0x1UL +#define MM_CALLER_MINOR_VER 0x0UL +#endif =20 #endif /* MM_COMMUNICATE_H_ */ diff --git a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c b/ArmPkg/D= rivers/MmCommunicationDxe/MmCommunication.c index 85d9034555f0..a6fcd590a65b 100644 --- a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c +++ b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c @@ -18,6 +18,7 @@ =20 #include =20 +#include #include =20 #include "MmCommunicate.h" @@ -250,14 +251,20 @@ GetMmCompatibility ( { EFI_STATUS Status; UINT32 MmVersion; - ARM_SMC_ARGS MmVersionArgs; + ARM_SMC_ARGS SmcArgs =3D {0}; =20 - // MM_VERSION uses SMC32 calling conventions - MmVersionArgs.Arg0 =3D ARM_SMC_ID_MM_VERSION_AARCH32; + if (FixedPcdGet32 (PcdFfaEnable) !=3D 0) { + SmcArgs.Arg0 =3D ARM_SVC_ID_FFA_VERSION_AARCH32; + SmcArgs.Arg1 =3D MM_CALLER_MAJOR_VER << MM_MAJOR_VER_SHIFT; + SmcArgs.Arg1 |=3D MM_CALLER_MINOR_VER; + } else { + // MM_VERSION uses SMC32 calling conventions + SmcArgs.Arg0 =3D ARM_SMC_ID_MM_VERSION_AARCH32; + } =20 - ArmCallSmc (&MmVersionArgs); + ArmCallSmc (&SmcArgs); =20 - MmVersion =3D MmVersionArgs.Arg0; + MmVersion =3D SmcArgs.Arg0; =20 if ((MM_MAJOR_VER (MmVersion) =3D=3D MM_CALLER_MAJOR_VER) && (MM_MINOR_VER (MmVersion) >=3D MM_CALLER_MINOR_VER)) --=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 (#106806): https://edk2.groups.io/g/devel/message/106806 Mute This Topic: https://groups.io/mt/100079887/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- From nobody Fri May 10 05:43:06 2024 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+106807+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+106807+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1689086252; cv=none; d=zohomail.com; s=zohoarc; b=L0AEEd/fjuvMkRhzrji+dQY6dg+3qpIfFheErLdIE+wnSww1fbUQeb6jB/7aYTzfdrIvYvpLy3P85MFiAkDGdmiaSSy4rJ0RidlznZkaUaa6cakfHHimgUB7wqcN3bAwKCHexl3AF9+reIcfHDowDW1IP4Vl5KauFouT4n1M7Bo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1689086252; 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=KOLeOE/DfUJrVJjZooSSxu27SrdxyE127GuFjqIv5PA=; b=RGCKS/iv53082UfQ46ziNUxmGcxCVADOPJxhbDtomtc5RolPNF5bzqfVmczd5TnnE7zUpwLEtiLaAZHzrZXfD9h+rhbi9UocCQ+HCkCHKDWls2t63Kysieh5QiogtNovAU7xK3JarrMywcf4GkUDyREDZwNDynLnbZ7JVluen1A= 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+106807+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 1689086252835650.059188979515; Tue, 11 Jul 2023 07:37:32 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=iuy+QqCmqWBRLigBwpUDL3prfzZqN08xhr/EGsd5e+w=; 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=1689086252; v=1; b=Zd2gMxKGy3XmfhmNmjLQskwGyJ6boE2WV0MmHUSsinlxDjhNnES7IAgJB/vXNu9PratOeAyf 1X/85m5veQUd5Uzx2BLPlUH7aqdC4nyOLR3qRGBHDSrMNk88Rdgz4xCYMcxv2emLEQnxniJatdC ne0rhMKvjDNBErOMq7fTRlsI= X-Received: by 127.0.0.2 with SMTP id ijpKYY1788612xJLVhd9B1Rp; Tue, 11 Jul 2023 07:37:32 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web10.1277.1689086250840632971 for ; Tue, 11 Jul 2023 07:37:30 -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 B786D2F4; Tue, 11 Jul 2023 07:38:12 -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 9A04B3F740; Tue, 11 Jul 2023 07:37:29 -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 15/20] ArmPkg/MmCommunicationDxe: Add support for obtaining FF-A partition ID Date: Tue, 11 Jul 2023 15:36:53 +0100 Message-Id: <20230711143658.781597-16-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: YABwW53HRNqpxUdRejkchckwx1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1689086254695100067 Content-Type: text/plain; charset="utf-8" From: Achin Gupta This patch invokes the FFA_ID_GET to obtain and stash the ID of the the FF-A partition that implements the DXE MM communication driver. This ID is used in subsequent patches for sending and receiving MM communication protocol requests and responses that are packaged as FF-A messages. Signed-off-by: Achin Gupta Signed-off-by: Nishant Sharma --- ArmPkg/Include/IndustryStandard/ArmFfaSvc.h | 1 + ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c | 22 +++++++++++++++++= +++ 2 files changed, 23 insertions(+) diff --git a/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h b/ArmPkg/Include/I= ndustryStandard/ArmFfaSvc.h index 4a51f9fb56af..20eeb822ea56 100644 --- a/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h +++ b/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h @@ -17,6 +17,7 @@ #define ARM_FFA_SVC_H_ =20 #define ARM_SVC_ID_FFA_VERSION_AARCH32 0x84000063 +#define ARM_SVC_ID_FFA_ID_GET_AARCH32 0x84000069 #define ARM_SVC_ID_FFA_MSG_SEND_DIRECT_REQ_AARCH32 0x8400006F #define ARM_SVC_ID_FFA_MSG_SEND_DIRECT_RESP_AARCH32 0x84000070 #define ARM_SVC_ID_FFA_MSG_SEND_DIRECT_REQ_AARCH64 0xC400006F diff --git a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c b/ArmPkg/D= rivers/MmCommunicationDxe/MmCommunication.c index a6fcd590a65b..f907ccf7349f 100644 --- a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c +++ b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c @@ -23,6 +23,11 @@ =20 #include "MmCommunicate.h" =20 +// +// Partition ID if FF-A support is enabled +// +STATIC UINT16 mFfaPartId; + // // Address, Length of the pre-allocated buffer for communication with the = secure // world. @@ -288,6 +293,23 @@ GetMmCompatibility ( Status =3D EFI_UNSUPPORTED; } =20 + // If FF-A is supported then discover our ID. + if (FixedPcdGet32 (PcdFfaEnable) !=3D 0) { + + // Get our ID + ZeroMem(&SmcArgs, sizeof(SmcArgs)); + SmcArgs.Arg0 =3D ARM_SVC_ID_FFA_ID_GET_AARCH32; + ArmCallSmc (&SmcArgs); + if (SmcArgs.Arg0 =3D=3D ARM_SVC_ID_FFA_ERROR_AARCH32) { + DEBUG ((DEBUG_ERROR, "Unable to retrieve FF-A partition ID (%d).\n",= SmcArgs.Arg2)); + return EFI_UNSUPPORTED; + } + DEBUG ((DEBUG_INFO, "FF-A partition ID =3D 0x%lx.\n", SmcArgs.Arg2)); + mFfaPartId =3D SmcArgs.Arg2; + + return EFI_SUCCESS; + } + return Status; } =20 --=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 (#106807): https://edk2.groups.io/g/devel/message/106807 Mute This Topic: https://groups.io/mt/100079888/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- From nobody Fri May 10 05:43:06 2024 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+106808+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+106808+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1689086253; cv=none; d=zohomail.com; s=zohoarc; b=gjc7GI+t9f4pm2My7LP5O5gETa6P0uKIRnuSMtdWRZRX6YoZlBBcDD6TFn49Fw7iN4lWj2H9T8C3+RrEQEoU2AKQ3A9TWcbjMDrc/Hv4kA62bX2AXXKxVsyTFhqupXu0n+np4RrADZeNLW8muP8SuXJIcwCj45A0wHltNa0TjfM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1689086253; 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=WGhL+OvVj2MqVCh5Mor+qid3N58SvOC/feAHetrRs6Y=; b=e2GNRTax2CjcjMv6gQoZRiNZf2oqYlu2WaV3+3aatURIayInFRdmhz4MXRugAL0uXaj3omExsGPchdvgvqAy1LGlVxmfkpJkR3qu4No6MrEzqdFbiAl8npIP1INQn4oeb8tD7bbdj2KfwaqjraqyOo/Jt4GYMZiCLC51RmLOgrU= 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+106808+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 1689086253313203.2197064712425; Tue, 11 Jul 2023 07:37:33 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=UM4xhLbs1Ic5PuRQvpMUpE+fPO27AVlv7Eto8Tc0XjM=; 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=pMQm41YjqDeNT4VzsHdUeFTe4JvFxP96aPWKrwIq5mpGWZ0EA94G+Lq5lzVP6JUoRrXy1u2C l3DE/mzLJ/shHVL7tgVo6JNpyBtmhFPhtA4fE+9o1MGcYKbYjKgO8xeBX0xK8sef4nsMaMT00gH DnaO/wcTMjQXRslQ11i8or3U= X-Received: by 127.0.0.2 with SMTP id iCWkYY1788612xIkQgK3qs1s; 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.web10.1278.1689086251887077554 for ; Tue, 11 Jul 2023 07:37:31 -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 CD0601FB; Tue, 11 Jul 2023 07:38:13 -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 AF7883F740; Tue, 11 Jul 2023 07:37:30 -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 16/20] ArmPkg/MmCommunicationDxe: Register FF-A RX/TX buffers Date: Tue, 11 Jul 2023 15:36:54 +0100 Message-Id: <20230711143658.781597-17-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: Od52R1GimR9U7cfUIOsM7loxx1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1689086254501100061 Content-Type: text/plain; charset="utf-8" From: Achin Gupta This patch statically allocates an FF-A RX/TX buffer pair and registers them with the framework. This enables discovery of the StMM SP in a subsequent patch. Signed-off-by: Achin Gupta Signed-off-by: Nishant Sharma --- ArmPkg/Include/IndustryStandard/ArmFfaSvc.h | 2 ++ ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c | 20 +++++++++++++++++= +-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h b/ArmPkg/Include/I= ndustryStandard/ArmFfaSvc.h index 20eeb822ea56..ebdf29e8d69a 100644 --- a/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h +++ b/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h @@ -17,6 +17,8 @@ #define ARM_FFA_SVC_H_ =20 #define ARM_SVC_ID_FFA_VERSION_AARCH32 0x84000063 +#define ARM_SVC_ID_FFA_RXTX_MAP_AARCH32 0x84000066 +#define ARM_SVC_ID_FFA_RXTX_MAP_AARCH64 0xC4000066 #define ARM_SVC_ID_FFA_ID_GET_AARCH32 0x84000069 #define ARM_SVC_ID_FFA_MSG_SEND_DIRECT_REQ_AARCH32 0x8400006F #define ARM_SVC_ID_FFA_MSG_SEND_DIRECT_RESP_AARCH32 0x84000070 diff --git a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c b/ArmPkg/D= rivers/MmCommunicationDxe/MmCommunication.c index f907ccf7349f..8a4d46e4f80a 100644 --- a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c +++ b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c @@ -28,6 +28,12 @@ // STATIC UINT16 mFfaPartId; =20 +// +// RX/TX pair if FF-A support is enabled +// +STATIC UINT8 FfaRxBuf[EFI_PAGE_SIZE] __attribute__ ((aligned (EFI_PAGE_SIZ= E))); +STATIC UINT8 FfaTxBuf[EFI_PAGE_SIZE] __attribute__ ((aligned (EFI_PAGE_SIZ= E))); + // // Address, Length of the pre-allocated buffer for communication with the = secure // world. @@ -293,9 +299,8 @@ GetMmCompatibility ( Status =3D EFI_UNSUPPORTED; } =20 - // If FF-A is supported then discover our ID. + // If FF-A is supported then discover our ID and register our RX/TX buff= ers. if (FixedPcdGet32 (PcdFfaEnable) !=3D 0) { - // Get our ID ZeroMem(&SmcArgs, sizeof(SmcArgs)); SmcArgs.Arg0 =3D ARM_SVC_ID_FFA_ID_GET_AARCH32; @@ -307,6 +312,17 @@ GetMmCompatibility ( DEBUG ((DEBUG_INFO, "FF-A partition ID =3D 0x%lx.\n", SmcArgs.Arg2)); mFfaPartId =3D SmcArgs.Arg2; =20 + // Register our RX/TX pair + SmcArgs.Arg0 =3D ARM_SVC_ID_FFA_RXTX_MAP_AARCH64; + SmcArgs.Arg1 =3D (UINTN) FfaTxBuf; + SmcArgs.Arg2 =3D (UINTN) FfaRxBuf; + SmcArgs.Arg3 =3D EFI_PAGE_SIZE / SIZE_4KB; + ArmCallSmc (&SmcArgs); + if (SmcArgs.Arg0 =3D=3D ARM_SVC_ID_FFA_ERROR_AARCH32) { + DEBUG ((DEBUG_ERROR, "Unable to register FF-A RX/TX buffers (%d).\n"= , SmcArgs.Arg2)); + return EFI_UNSUPPORTED; + } + return EFI_SUCCESS; } =20 --=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 (#106808): https://edk2.groups.io/g/devel/message/106808 Mute This Topic: https://groups.io/mt/100079889/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- From nobody Fri May 10 05:43:06 2024 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- From nobody Fri May 10 05:43:06 2024 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+106810+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+106810+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1689086255; cv=none; d=zohomail.com; s=zohoarc; b=W+ARxR2Y+NWIfWyVwxxwpinU/rYenmRImuieQ2xdJksIVDFzY9skr8mo6VlclvfcD4sROiXcOTszZA0B6UgF1FndbOM/jybnAiMj9n9/p8fMgWVNt1JXiRPTx/FEUCFpJFRpmIvFGfG8CrBzYdUnq5G7fRA1G5U0UfiMM4nzSys= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1689086255; 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=6nKUSZSYJwd3CuwlT3E3e9AJThjWGQ+cbK7yZtjc+p8=; b=nRYqoA7gT2axi1IOivrBoT4l7EHG8mUSzXkkfmuUAueMOy2gnIaGYak+7/WrLJ0Ya4UmnDIdKPsyKNg7v6Jnpn90xmzPRUE20B82UzY9THCeP/HCa4W8xPtO3wB4rAVw0PYLAOX5CLq15gzgkrKIzWmHgILWwK1zLxBxSo7IzhA= 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+106810+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 1689086255059712.04217092881; Tue, 11 Jul 2023 07:37:35 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=phO/yjAKs8IKzEjN3c1mclEiUCktXECK1IHmqRb1PJA=; 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=1689086254; v=1; b=DEfqgm3wDEV4def+ai6MggJa+e4HJzPZt5Sky65pqlB3T3uoJY7x9zovFD634w659GT64ZLc UKstAnWZI0SAEd+TS+q6J6Z18RNItv6wrjaz9yqgvY8xU0If0xhlrkexPd0ja3UdBR7ICtXgySn NXKDG0zzrupXkr10wVZ45984= X-Received: by 127.0.0.2 with SMTP id pj3yYY1788612xv0d2pK5OFJ; Tue, 11 Jul 2023 07:37:34 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web11.1250.1689086253937089093 for ; Tue, 11 Jul 2023 07:37:34 -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 DEA8D1FB; Tue, 11 Jul 2023 07:38:15 -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 C0A883F740; Tue, 11 Jul 2023 07:37:32 -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 18/20] ArmPkg/MmCommunicationDxe: Discover the StMM SP Date: Tue, 11 Jul 2023 15:36:56 +0100 Message-Id: <20230711143658.781597-19-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: skUlOxTvNl8JxCFozlmIAOElx1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1689086256723100072 Content-Type: text/plain; charset="utf-8" From: Achin Gupta This patch adds support for discovering the presence of the SP using the EFI_MM_COMMUNICATION_PROTOCOL GUID that implements Standalone MM drivers. This is done by querying the framework through FFA_PARTITION_INFO_GET whether any partition that implements the EFI_MM_COMMUNICATION_PROTOCOL is present or not. The partition ID and its properties are stashed for use in subsequent communication with the StMM SP. Signed-off-by: Achin Gupta Signed-off-by: Nishant Sharma --- ArmPkg/Include/IndustryStandard/ArmFfaSvc.h | 24 +++++ ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c | 93 +++++++++++++++++= ++- 2 files changed, 114 insertions(+), 3 deletions(-) diff --git a/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h b/ArmPkg/Include/I= ndustryStandard/ArmFfaSvc.h index f78442a465e1..530af8bd3c2e 100644 --- a/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h +++ b/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h @@ -19,6 +19,9 @@ #define ARM_SVC_ID_FFA_VERSION_AARCH32 0x84000063 #define ARM_SVC_ID_FFA_RXTX_MAP_AARCH32 0x84000066 #define ARM_SVC_ID_FFA_RXTX_MAP_AARCH64 0xC4000066 +#define ARM_SVC_ID_FFA_RX_RELEASE_AARCH32 0x84000065 +#define ARM_SVC_ID_FFA_RXTX_UNMAP_AARCH32 0x84000067 +#define ARM_SVC_ID_FFA_PARTITION_INFO_GET_AARCH32 0x84000068 #define ARM_SVC_ID_FFA_ID_GET_AARCH32 0x84000069 #define ARM_SVC_ID_FFA_MSG_SEND_DIRECT_REQ_AARCH32 0x8400006F #define ARM_SVC_ID_FFA_MSG_SEND_DIRECT_RESP_AARCH32 0x84000070 @@ -154,4 +157,25 @@ typedef struct { UINT64 Reserved; } EFI_FFA_BOOT_INFO_HEADER; =20 +// FF-A partition information descriptor +typedef struct { + UINT16 PartId; + UINT16 EcCnt; + UINT32 PartProps; + UINT32 PartGuid[4]; +} EFI_FFA_PART_INFO_DESC; + +#define PART_INFO_PROP_MASK 0x3f +#define PART_INFO_PROP_SHIFT 0 +#define PART_INFO_PROP_DIR_MSG_RECV_BIT (1u << 0) +#define PART_INFO_PROP_DIR_MSG_SEND_BIT (1u << 1) +#define PART_INFO_PROP_INDIR_MSG_BIT (1u << 2) +#define PART_INFO_PROP_NOTIFICATIONS_BIT (1u << 3) +#define PART_INFO_PROP_EP_TYPE_MASK 0x3 +#define PART_INFO_PROP_EP_TYPE_SHIFT 4 +#define PART_INFO_PROP_EP_PE 0 +#define PART_INFO_PROP_EP_SEPID_IND 1 +#define PART_INFO_PROP_EP_SEPID_DEP 2 +#define PART_INFO_PROP_EP_AUX 3 + #endif // ARM_FFA_SVC_H_ diff --git a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c b/ArmPkg/D= rivers/MmCommunicationDxe/MmCommunication.c index 39a1b329b9ea..94a5d96c051d 100644 --- a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c +++ b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c @@ -8,6 +8,7 @@ =20 #include #include +#include #include #include #include @@ -28,6 +29,11 @@ // STATIC UINT16 mFfaPartId; =20 +// Partition information of the StMM SP if FF-A support is enabled +// TODO: Revisit assumption that there is only a single StMM SP +// +STATIC EFI_FFA_PART_INFO_DESC mStmmPartInfo; + // // RX/TX pair if FF-A support is enabled // @@ -298,7 +304,9 @@ GetMmCompatibility ( { EFI_STATUS Status; UINT32 MmVersion; + UINT32 SmccUuid[4]; ARM_SMC_ARGS SmcArgs =3D {0}; + EFI_GUID MmCommProtGuid =3D EFI_MM_COMMUNICATION_PROTOCOL_GUID; =20 if (FixedPcdGet32 (PcdFfaEnable) !=3D 0) { SmcArgs.Arg0 =3D ARM_SVC_ID_FFA_VERSION_AARCH32; @@ -335,14 +343,21 @@ GetMmCompatibility ( Status =3D EFI_UNSUPPORTED; } =20 - // If FF-A is supported then discover our ID and register our RX/TX buff= ers. + // If FF-A is supported then discover the StMM SP's presence, ID, our ID= and + // register our RX/TX buffers. if (FixedPcdGet32 (PcdFfaEnable) !=3D 0) { + EFI_FFA_PART_INFO_DESC *StmmPartInfo; + // Get our ID ZeroMem(&SmcArgs, sizeof(SmcArgs)); SmcArgs.Arg0 =3D ARM_SVC_ID_FFA_ID_GET_AARCH32; ArmCallSmc (&SmcArgs); if (SmcArgs.Arg0 =3D=3D ARM_SVC_ID_FFA_ERROR_AARCH32) { - DEBUG ((DEBUG_ERROR, "Unable to retrieve FF-A partition ID (%d).\n",= SmcArgs.Arg2)); + DEBUG (( + DEBUG_ERROR, + "Unable to retrieve FF-A partition ID (%d).\n", + SmcArgs.Arg2 + )); return EFI_UNSUPPORTED; } DEBUG ((DEBUG_INFO, "FF-A partition ID =3D 0x%lx.\n", SmcArgs.Arg2)); @@ -355,11 +370,83 @@ GetMmCompatibility ( SmcArgs.Arg3 =3D EFI_PAGE_SIZE / SIZE_4KB; ArmCallSmc (&SmcArgs); if (SmcArgs.Arg0 =3D=3D ARM_SVC_ID_FFA_ERROR_AARCH32) { - DEBUG ((DEBUG_ERROR, "Unable to register FF-A RX/TX buffers (%d).\n"= , SmcArgs.Arg2)); + DEBUG (( + DEBUG_ERROR, + "Unable to register FF-A RX/TX buffers (%d).\n", + SmcArgs.Arg2 + )); return EFI_UNSUPPORTED; } =20 + // Discover the StMM SP after converting the EFI_GUID to a format TF-A= will + // understand. + SmcArgs.Arg0 =3D ARM_SVC_ID_FFA_PARTITION_INFO_GET_AARCH32; + MmCommProtGuid.Data2 +=3D MmCommProtGuid.Data3; + MmCommProtGuid.Data3 =3D MmCommProtGuid.Data2 - MmCommProtGuid.Data3; + MmCommProtGuid.Data2 =3D MmCommProtGuid.Data2 - MmCommProtGuid.Data3; + CopyMem ((VOID *) SmccUuid, (VOID *) &MmCommProtGuid, sizeof(EFI_GUID)= ); + SmcArgs.Arg1 =3D SmccUuid[0]; + SmcArgs.Arg2 =3D SmccUuid[1]; + SmcArgs.Arg3 =3D SmccUuid[2]; + SmcArgs.Arg3 =3D SwapBytes32(SmcArgs.Arg3); + SmcArgs.Arg4 =3D SmccUuid[3]; + SmcArgs.Arg4 =3D SwapBytes32(SmcArgs.Arg4); + ArmCallSmc (&SmcArgs); + if (SmcArgs.Arg0 =3D=3D ARM_SVC_ID_FFA_ERROR_AARCH32) { + DEBUG (( + DEBUG_ERROR, + "Unable to discover FF-A StMM SP (%d).\n", + SmcArgs.Arg2 + )); + goto ffa_init_error; + } + + // Retrieve the partition information from the RX buffer + StmmPartInfo =3D (EFI_FFA_PART_INFO_DESC *) FfaRxBuf; + + // TODO: Sanity check the partition type. + DEBUG ((DEBUG_INFO, "Discovered FF-A StMM SP.")); + DEBUG (( + DEBUG_INFO, + "ID =3D 0x%lx, Execution contexts =3D %d, Properties =3D 0x%lx. \n", + StmmPartInfo->PartId, + StmmPartInfo->EcCnt, + StmmPartInfo->PartProps + )); + + // Make a local copy + mStmmPartInfo =3D *StmmPartInfo; + + // Release the RX buffer + ZeroMem(&SmcArgs, sizeof(SmcArgs)); + SmcArgs.Arg0 =3D ARM_SVC_ID_FFA_RX_RELEASE_AARCH32; + SmcArgs.Arg1 =3D mFfaPartId; + ArmCallSmc (&SmcArgs); + + // This should really never fail since there is only a single CPU boot= ing + // and another CPU could not have released the RX buffer before us. + if (SmcArgs.Arg0 =3D=3D ARM_SVC_ID_FFA_ERROR_AARCH32) { + DEBUG (( + DEBUG_ERROR, + "Unable to release FF-A RX buffer (%d).\n", + SmcArgs.Arg2 + )); + ASSERT (0); + goto ffa_init_error; + } + return EFI_SUCCESS; + + ffa_init_error: + // Release the RX/TX pair before exiting. + ZeroMem(&SmcArgs, sizeof(SmcArgs)); + SmcArgs.Arg0 =3D ARM_SVC_ID_FFA_RXTX_UNMAP_AARCH32; + SmcArgs.Arg1 =3D mFfaPartId << 16; // TODO: Use a macro for shift + ArmCallSmc (&SmcArgs); + + // We do not bother checking the error code of the RXTX_UNMAP invocati= on + // since we did map the buffers and this call must succeed. + return EFI_UNSUPPORTED; } =20 return Status; --=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 (#106810): https://edk2.groups.io/g/devel/message/106810 Mute This Topic: https://groups.io/mt/100079892/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- From nobody Fri May 10 05:43:06 2024 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+106811+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+106811+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1689086256; cv=none; d=zohomail.com; s=zohoarc; b=SmVBa7pFnGppbODRyxODi7xAieCkKMI7pJdhkBie4wBRORAG2vHwbPIns99UeooccnLcD4lUXx935DTqqkVwj4PYPw950f8+l4j6dinkWqoSddG4umuTqZudMtjOTcRr8HT++CGmWiN4YuEqms6SVCpedOexgyqQejqmkdoWfIk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1689086256; 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=Z6Jfj4oyHEIOUKUXQgeW9YdcH9q3XWlzgEetlvNEwfY=; b=Y0Lm+7XbViCe4WeRgVrB1Cw/+T7xGif0C8DT3HtcI66RKOVf4CMpXWZxqP/bvhmKyV6uTSvHofNQzUnvQVVRHeMCgyKuqJikEy7TMyz9+150DGQYAKpdlDZzQgLAa8NCDvGXzvSvy9p/j2yhjE43LcD2IlAP0pEs9/2fDJfgGpA= 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+106811+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 1689086256100887.8699939360853; Tue, 11 Jul 2023 07:37:36 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=Z8/gPS8TEkvjdN6K5PwS+TnpORGmba2yOOB95Wff3IQ=; 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=1689086255; v=1; b=ksNYSuDc06Poe6O03+u+5VJYzzG/4b33AOtJA361xrHf0TpMR2Ud+gNACJRrc6DjIjg+O03Y xzT/+QRaMN/QFBKQ4V9kzXny3QQ3sutiGOjhdtZwU2Lql1JmIUC5fgMsLkXDLypHm5OeUkP7D0M 6/eycaYpo43CxkuFP1uM2+Xo= X-Received: by 127.0.0.2 with SMTP id UxNbYY1788612xWzuGUFTYxI; Tue, 11 Jul 2023 07:37:35 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web10.1282.1689086255159855820 for ; Tue, 11 Jul 2023 07:37:35 -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 1B1D32F4; Tue, 11 Jul 2023 07:38:17 -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 D669B3F740; Tue, 11 Jul 2023 07:37:33 -0700 (PDT) From: "Nishant Sharma" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Sami Mujawar , Thomas Abraham , Sayanta Pattanayak , Achin Gupta , Aditya Angadi Subject: [edk2-devel] [edk2-platforms][PATCH V1 19/20] ArmPkg/MmCommunicationDxe: Use the FF-A transport for MM requests Date: Tue, 11 Jul 2023 15:36:57 +0100 Message-Id: <20230711143658.781597-20-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: mCyozbRru1Ptr0pJGAqpPjFJx1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1689086256545100071 Content-Type: text/plain; charset="utf-8" From: Achin Gupta This patch packages requests for accessing a Standalone MM driver through the MM communication protocol as FF-A direct messages. Corresponding changes in Standalone MM Core ensure that responses are packaged in the same way. Signed-off-by: Achin Gupta Co-developed-by: Aditya Angadi Signed-off-by: Nishant Sharma --- ArmPkg/Include/IndustryStandard/ArmFfaSvc.h | 2 + ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c | 141 +++++++++++++---= ---- 2 files changed, 97 insertions(+), 46 deletions(-) diff --git a/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h b/ArmPkg/Include/I= ndustryStandard/ArmFfaSvc.h index 530af8bd3c2e..493997346143 100644 --- a/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h +++ b/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h @@ -23,6 +23,7 @@ #define ARM_SVC_ID_FFA_RXTX_UNMAP_AARCH32 0x84000067 #define ARM_SVC_ID_FFA_PARTITION_INFO_GET_AARCH32 0x84000068 #define ARM_SVC_ID_FFA_ID_GET_AARCH32 0x84000069 +#define ARM_SVC_ID_FFA_RUN_AARCH32 0x8400006D #define ARM_SVC_ID_FFA_MSG_SEND_DIRECT_REQ_AARCH32 0x8400006F #define ARM_SVC_ID_FFA_MSG_SEND_DIRECT_RESP_AARCH32 0x84000070 #define ARM_SVC_ID_FFA_MSG_SEND_DIRECT_REQ_AARCH64 0xC400006F @@ -31,6 +32,7 @@ #define ARM_SVC_ID_FFA_SUCCESS_AARCH64 0xC4000061 #define ARM_SVC_ID_FFA_MEM_PERM_SET_AARCH32 0x84000089 #define ARM_SVC_ID_FFA_MEM_PERM_GET_AARCH32 0x84000088 +#define ARM_SVC_ID_FFA_INTERRUPT_AARCH32 0x84000062 #define ARM_SVC_ID_FFA_ERROR_AARCH32 0x84000060 #define ARM_SVC_ID_FFA_ERROR_AARCH64 0xC4000060 #define ARM_SVC_ID_FFA_MSG_WAIT_AARCH32 0x8400006B diff --git a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c b/ArmPkg/D= rivers/MmCommunicationDxe/MmCommunication.c index 94a5d96c051d..a70318581bd2 100644 --- a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c +++ b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c @@ -100,6 +100,7 @@ MmCommunication2Communicate ( ARM_SMC_ARGS CommunicateSmcArgs; EFI_STATUS Status; UINTN BufferSize; + UINTN Ret; =20 Status =3D EFI_ACCESS_DENIED; BufferSize =3D 0; @@ -160,60 +161,108 @@ MmCommunication2Communicate ( return Status; } =20 - // SMC Function ID - CommunicateSmcArgs.Arg0 =3D ARM_SMC_ID_MM_COMMUNICATE_AARCH64; - - // Cookie - CommunicateSmcArgs.Arg1 =3D 0; - // Copy Communication Payload CopyMem ((VOID *)mNsCommBuffMemRegion.VirtualBase, CommBufferVirtual, Bu= fferSize); =20 - // comm_buffer_address (64-bit physical address) - CommunicateSmcArgs.Arg2 =3D (UINTN)mNsCommBuffMemRegion.PhysicalBase; + // Use the FF-A interface if enabled. + if (FixedPcdGet32 (PcdFfaEnable) !=3D 0) { + // FF-A Interface ID for direct message communication + CommunicateSmcArgs.Arg0 =3D ARM_SVC_ID_FFA_MSG_SEND_DIRECT_REQ_AARCH64; =20 - // comm_size_address (not used, indicated by setting to zero) - CommunicateSmcArgs.Arg3 =3D 0; + // FF-A Destination EndPoint ID, not used as of now + CommunicateSmcArgs.Arg1 =3D mFfaPartId << 16 | mStmmPartInfo.PartId; =20 + // Reserved for future use(MBZ) + CommunicateSmcArgs.Arg2 =3D 0x0; + + // comm_buffer_address (64-bit physical address) + CommunicateSmcArgs.Arg3 =3D (UINTN)mNsCommBuffMemRegion.PhysicalBase; + + // Cookie + CommunicateSmcArgs.Arg4 =3D 0x0; + + // Not Used + CommunicateSmcArgs.Arg5 =3D 0; + + // comm_size_address (not used, indicated by setting to zero) + CommunicateSmcArgs.Arg6 =3D 0; + } else { + // SMC Function ID + CommunicateSmcArgs.Arg0 =3D ARM_SMC_ID_MM_COMMUNICATE_AARCH64; + + // Cookie + CommunicateSmcArgs.Arg1 =3D 0; + + // comm_buffer_address (64-bit physical address) + CommunicateSmcArgs.Arg2 =3D (UINTN)mNsCommBuffMemRegion.PhysicalBase; + + // comm_size_address (not used, indicated by setting to zero) + CommunicateSmcArgs.Arg3 =3D 0; + } + +ffa_intr_loop: // Call the Standalone MM environment. ArmCallSmc (&CommunicateSmcArgs); =20 - switch (CommunicateSmcArgs.Arg0) { - case ARM_SMC_MM_RET_SUCCESS: - ZeroMem (CommBufferVirtual, BufferSize); - // On successful return, the size of data being returned is inferred= from - // MessageLength + Header. - CommunicateHeader =3D (EFI_MM_COMMUNICATE_HEADER *)mNsCommBuffMemReg= ion.VirtualBase; - BufferSize =3D CommunicateHeader->MessageLength + - sizeof (CommunicateHeader->HeaderGuid) + - sizeof (CommunicateHeader->MessageLength); - - CopyMem ( - CommBufferVirtual, - (VOID *)mNsCommBuffMemRegion.VirtualBase, - BufferSize - ); - Status =3D EFI_SUCCESS; - break; - - case ARM_SMC_MM_RET_INVALID_PARAMS: - Status =3D EFI_INVALID_PARAMETER; - break; - - case ARM_SMC_MM_RET_DENIED: - Status =3D EFI_ACCESS_DENIED; - break; - - case ARM_SMC_MM_RET_NO_MEMORY: - // Unexpected error since the CommSize was checked for zero length - // prior to issuing the SMC - Status =3D EFI_OUT_OF_RESOURCES; - ASSERT (0); - break; - - default: - Status =3D EFI_ACCESS_DENIED; - ASSERT (0); + Ret =3D CommunicateSmcArgs.Arg0; + + if (FixedPcdGet32 (PcdFfaEnable) !=3D 0) { + if (Ret =3D=3D ARM_SVC_ID_FFA_INTERRUPT_AARCH32) { + DEBUG ((DEBUG_INFO, "Resuming interrupted FF-A call \n")); + + // FF-A Interface ID for running the interrupted partition + CommunicateSmcArgs.Arg0 =3D ARM_SVC_ID_FFA_RUN_AARCH32; + + // FF-A Destination EndPoint and vCPU ID, TODO: We are assuming vCPU= 0 of the + // StMM SP since it is UP. + CommunicateSmcArgs.Arg1 =3D mStmmPartInfo.PartId << 16; + + // Loop if the call was interrupted + goto ffa_intr_loop; + } + } + + if (((FixedPcdGet32 (PcdFfaEnable) !=3D 0) && + (Ret =3D=3D ARM_SVC_ID_FFA_MSG_SEND_DIRECT_RESP)) || + (Ret =3D=3D ARM_SMC_MM_RET_SUCCESS)) { + 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; + BufferSize =3D CommunicateHeader->MessageLength + + sizeof (CommunicateHeader->HeaderGuid) + + sizeof (CommunicateHeader->MessageLength); + + CopyMem (CommBufferVirtual, (VOID *)mNsCommBuffMemRegion.VirtualBase, + BufferSize); + Status =3D EFI_SUCCESS; + return Status; + } + + if (FixedPcdGet32 (PcdFfaEnable) !=3D 0) { + Ret =3D CommunicateSmcArgs.Arg2; + } + + // Error Codes are same for FF-A and SMC interface + switch (Ret) { + case ARM_SMC_MM_RET_INVALID_PARAMS: + Status =3D EFI_INVALID_PARAMETER; + break; + + case ARM_SMC_MM_RET_DENIED: + Status =3D EFI_ACCESS_DENIED; + break; + + case ARM_SMC_MM_RET_NO_MEMORY: + // Unexpected error since the CommSize was checked for zero length + // prior to issuing the SMC + Status =3D EFI_OUT_OF_RESOURCES; + ASSERT (0); + break; + + default: + Status =3D EFI_ACCESS_DENIED; + ASSERT (0); } =20 return Status; --=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 (#106811): https://edk2.groups.io/g/devel/message/106811 Mute This Topic: https://groups.io/mt/100079893/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- From nobody Fri May 10 05:43:06 2024 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+106812+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+106812+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1689086257; cv=none; d=zohomail.com; s=zohoarc; b=TfN49LdtJShBbww4ZC2GAU8GPMDGCEdzgPqtEvubGhDSYfQZIPpU7/y6xs1+1+jh2dx+lW+rSXMTrehBDqts1xGMsSfhk023uvcSauiQDZ0ujssxffi+S7lpJl6/8Yv0izr8cQaJDBtHYPMT/bDZ1QlDBzEeGukLD+4Nec7C/3g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1689086257; 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=gtKAGumGtZrbZRVi+C2v7TwPSF2IFcvPxl90d3LBI4M=; b=RHKhmMoMtmZlYpBTu/YAKkc+kSlLRlVmqLOIOO0iSYLvbE6a+zQQvgAuaTs2ef70DyCZZgYZuPEXPXY5FRg1EJtC5xtSekCh0W2sPOGBdMWg94R4jZ8QAyN/af4oZS5hkkpUzGnKKS+eamb3mQXKdFpQeqe4yDzJ8Ma5Cj7iFsw= 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+106812+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 1689086257301404.0836192212066; Tue, 11 Jul 2023 07:37:37 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=GElSZwfgmOGotpdDWtNI0KCDmnm8B1AyO6lbvQO3gc8=; 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=1689086256; v=1; b=vOW1DTnrB+6Ft9IPcVLfjs/+jXKQm5UB5dlL1J55G9lPbXL+ea4Ls+lZIO+obnMPd4kfAbvt 1myeScdX+Xvbxbo9nBXM3zIB391Vix9/CVcodW6KpE113w1K7FyAIGkOmnqI6WEnvTtqjC0j3Ko L2n7KnfIoXeSKvMmwwkzL/DA= X-Received: by 127.0.0.2 with SMTP id j1y2YY1788612xDolkLqfYjj; Tue, 11 Jul 2023 07:37:36 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web10.1284.1689086256208468876 for ; Tue, 11 Jul 2023 07:37:36 -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 306D71FB; Tue, 11 Jul 2023 07:38:18 -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 1288B3F740; Tue, 11 Jul 2023 07:37:34 -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 20/20] StandaloneMmPkg: Add support for MM requests as FF-A direct messages Date: Tue, 11 Jul 2023 15:36:58 +0100 Message-Id: <20230711143658.781597-21-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: YGFbYoHiNtjo5jRnm2wkgpAex1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1689086258753100079 Content-Type: text/plain; charset="utf-8" From: Achin Gupta This patch adds support for correctly receiving a request for a Standalome MM driver service using the MM communication protocol packaged as an FF-A direct request message. Signed-off-by: Achin Gupta Signed-off-by: Nishant Sharma --- StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEnt= ryPoint.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/Standal= oneMmCoreEntryPoint.c b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/= Arm/StandaloneMmCoreEntryPoint.c index a763bf8509b2..e0987cba21f9 100644 --- a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCo= reEntryPoint.c +++ b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCo= reEntryPoint.c @@ -198,6 +198,8 @@ DelegatedEventLoop ( BOOLEAN FfaEnabled; EFI_STATUS Status; UINTN SvcStatus; + UINT16 SenderPartId; + UINT16 ReceiverPartId; =20 while (TRUE) { ArmCallSvc (EventCompleteSvcArgs); @@ -214,9 +216,12 @@ DelegatedEventLoop ( =20 FfaEnabled =3D FixedPcdGet32 (PcdFfaEnable !=3D 0); if (FfaEnabled) { + SenderPartId =3D EventCompleteSvcArgs->Arg1 >> 16; + ReceiverPartId =3D EventCompleteSvcArgs->Arg1 & 0xffff; Status =3D CpuDriverEntryPoint ( EventCompleteSvcArgs->Arg0, - EventCompleteSvcArgs->Arg6, + // Assume CPU number 0 + 0, EventCompleteSvcArgs->Arg3 ); if (EFI_ERROR (Status)) { @@ -266,7 +271,7 @@ DelegatedEventLoop ( =20 if (FfaEnabled) { EventCompleteSvcArgs->Arg0 =3D ARM_SVC_ID_FFA_MSG_SEND_DIRECT_RESP; - EventCompleteSvcArgs->Arg1 =3D 0; + EventCompleteSvcArgs->Arg1 =3D ReceiverPartId << 16 | SenderPartId; EventCompleteSvcArgs->Arg2 =3D 0; EventCompleteSvcArgs->Arg3 =3D ARM_SVC_ID_SP_EVENT_COMPLETE; EventCompleteSvcArgs->Arg4 =3D SvcStatus; --=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 (#106812): https://edk2.groups.io/g/devel/message/106812 Mute This Topic: https://groups.io/mt/100079894/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-