From nobody Sun Feb 8 11:25:52 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+109179+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+109179+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1695935656; cv=none; d=zohomail.com; s=zohoarc; b=foBE01C+cpNdv/rr1ctzu9LPRgoitOMWZyyJbxJ+pzbdQ0KWutMN8/0UMlFEcB/Ehe4zVWHNFMuvTeMelAQFI7c5FPmsyVfF9qoQf7M8fyvEgeH4MKbP9HdBieqcwDcsKHdISTswggRmKKnzlsTVSUcVeJvHWDryPq85oLTd9/s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695935656; 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=8RjgsLzDh2xNs6doZnnLzI0X95N4rT+kNeWgopjvA2A=; b=V9gwsTqXFNBjOiFOPskFvWioe3jcLLaAaKanfMIxz81qU21FKBWiJ4jBFp9MUN/bCx2nwOpJmj7J9cvg3o5eCk64qWs8MZy0ZUAigTwRIBwW4/3NEA0skm4h8KVu3BBmfXbDRQdDFc54mHPsy66wV/NuuUgcA/bHGdW1eibGP9w= 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+109179+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1695935656269435.44168907412757; Thu, 28 Sep 2023 14:14:16 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=H78fNZiEFnczXo5oxkUJasd5UrKq/4XmSGfWlntIVJE=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1695935655; v=1; b=vYMGV6kffLVEQbIEuuYUik8F7reIJ9IDB4ey7L2sY8bMK3zZKOd53SoYMWdVkPI8LXZoF5aw l1x0DI40L5cWgAd5+OcRCWWYG84LSJXU4jZMLx8n2Y/2xrSFttLvnMHSismKyGBNBiE2zLlMqP+ SmAJDGO+qIs4Xka7kWY+m0yo= X-Received: by 127.0.0.2 with SMTP id SkMrYY1788612xVyhzhztZfw; Thu, 28 Sep 2023 14:14:15 -0700 X-Received: from mail-il1-f174.google.com (mail-il1-f174.google.com [209.85.166.174]) by mx.groups.io with SMTP id smtpd.web10.4142.1695935654987305095 for ; Thu, 28 Sep 2023 14:14:15 -0700 X-Received: by mail-il1-f174.google.com with SMTP id e9e14a558f8ab-351437112c1so27389125ab.3 for ; Thu, 28 Sep 2023 14:14:14 -0700 (PDT) X-Gm-Message-State: y23Bk0E6xTRNL1o1mWyeL6dfx1787277AA= X-Google-Smtp-Source: AGHT+IH+M/nkpcQ+ENnWudajtQqc/o/P7i3+76ws7JuEH42rDVFKFVoDF/Qri/XrPmgiKezw4BakJA== X-Received: by 2002:a05:6e02:58e:b0:350:efac:12 with SMTP id c14-20020a056e02058e00b00350efac0012mr2261844ils.0.1695935653811; Thu, 28 Sep 2023 14:14:13 -0700 (PDT) X-Received: from localhost.localdomain (c-98-210-194-104.hsd1.ca.comcast.net. [98.210.194.104]) by smtp.gmail.com with ESMTPSA id fn12-20020a056638640c00b0042b3e04510asm4881554jab.98.2023.09.28.14.14.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Sep 2023 14:14:13 -0700 (PDT) From: "Tuan Phan" To: devel@edk2.groups.io Cc: ardb+tianocore@kernel.org, sami.mujawar@arm.com, ray.ni@intel.com, huangming@linux.alibaba.com, sunilvl@ventanamicro.com, yong.li@intel.com, yeoreum.yun@arm.com, Tuan Phan Subject: [edk2-devel] [PATCH v3 2/2] StandaloneMmPkg: Arm: Update to use the new StandaloneMmCpu driver Date: Thu, 28 Sep 2023 14:14:04 -0700 Message-Id: <20230928211404.27533-3-tphan@ventanamicro.com> In-Reply-To: <20230928211404.27533-1-tphan@ventanamicro.com> References: <20230928211404.27533-1-tphan@ventanamicro.com> MIME-Version: 1.0 Precedence: Bulk 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,tphan@ventanamicro.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1695935657166100009 Content-Type: text/plain; charset="utf-8" Update entry point library for Arm to use the new architecture independent StandaloneMmCpu driver. Signed-off-by: Tuan Phan Reviewed-by: levi.yun Reviewed-by: Sami Mujawar --- .../Library/Arm/StandaloneMmCoreEntryPoint.h | 17 +---- .../Arm/CreateHobList.c | 43 ++++++------ .../Arm/StandaloneMmCoreEntryPoint.c | 69 +++++++++++-------- .../StandaloneMmCoreEntryPoint.inf | 2 +- 4 files changed, 67 insertions(+), 64 deletions(-) diff --git a/StandaloneMmPkg/Include/Library/Arm/StandaloneMmCoreEntryPoint= .h b/StandaloneMmPkg/Include/Library/Arm/StandaloneMmCoreEntryPoint.h index 41bf0f132b4f..dbb81610ff8e 100644 --- a/StandaloneMmPkg/Include/Library/Arm/StandaloneMmCoreEntryPoint.h +++ b/StandaloneMmPkg/Include/Library/Arm/StandaloneMmCoreEntryPoint.h @@ -10,6 +10,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #ifndef __STANDALONEMMCORE_ENTRY_POINT_H__ #define __STANDALONEMMCORE_ENTRY_POINT_H__ =20 +#include #include #include =20 @@ -47,18 +48,6 @@ typedef struct { EFI_SECURE_PARTITION_CPU_INFO *CpuInfo; } EFI_SECURE_PARTITION_BOOT_INFO; =20 -typedef -EFI_STATUS -(*PI_MM_ARM_TF_CPU_DRIVER_ENTRYPOINT) ( - IN UINTN EventId, - IN UINTN CpuNumber, - IN UINTN NsCommBufferAddr - ); - -typedef struct { - PI_MM_ARM_TF_CPU_DRIVER_ENTRYPOINT *ArmTfCpuDriverEpPtr; -} ARM_TF_CPU_DRIVER_EP_DESCRIPTOR; - typedef RETURN_STATUS (*REGION_PERMISSION_UPDATE_FUNC) ( IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length @@ -145,8 +134,8 @@ LocateStandaloneMmCorePeCoffData ( VOID * EFIAPI CreateHobListFromBootInfo ( - IN OUT PI_MM_ARM_TF_CPU_DRIVER_ENTRYPOINT *CpuDriverEntryPoint, - IN EFI_SECURE_PARTITION_BOOT_INFO *PayloadBootInfo + IN OUT PI_MM_CPU_DRIVER_ENTRYPOINT *CpuDriverEntryPoint, + IN EFI_SECURE_PARTITION_BOOT_INFO *PayloadBootInfo ); =20 /** diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/CreateH= obList.c b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/CreateHob= List.c index 2ac2d354f06a..80ed532352af 100644 --- a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/CreateHobList.c +++ b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/CreateHobList.c @@ -13,6 +13,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include #include =20 +#include #include #include #include @@ -39,7 +40,7 @@ extern EFI_GUID gEfiStandaloneMmNonSecureBufferGuid; // GUID to identify HOB where the entry point of the CPU driver will be // populated to allow this entry point driver to invoke it upon receipt of= an // event -extern EFI_GUID gEfiArmTfCpuDriverEpDescriptorGuid; +extern EFI_GUID gEfiMmCpuDriverEpDescriptorGuid; =20 /** Use the boot information passed by privileged firmware to populate a HOB= list @@ -52,22 +53,22 @@ extern EFI_GUID gEfiArmTfCpuDriverEpDescriptorGuid; **/ VOID * CreateHobListFromBootInfo ( - IN OUT PI_MM_ARM_TF_CPU_DRIVER_ENTRYPOINT *CpuDriverEntryPoint, - IN EFI_SECURE_PARTITION_BOOT_INFO *PayloadBootInfo + IN OUT PI_MM_CPU_DRIVER_ENTRYPOINT *CpuDriverEntryPoint, + IN EFI_SECURE_PARTITION_BOOT_INFO *PayloadBootInfo ) { - EFI_HOB_HANDOFF_INFO_TABLE *HobStart; - EFI_RESOURCE_ATTRIBUTE_TYPE Attributes; - UINT32 Index; - UINT32 BufferSize; - UINT32 Flags; - EFI_MMRAM_HOB_DESCRIPTOR_BLOCK *MmramRangesHob; - EFI_MMRAM_DESCRIPTOR *MmramRanges; - EFI_MMRAM_DESCRIPTOR *NsCommBufMmramRange; - MP_INFORMATION_HOB_DATA *MpInformationHobData; - EFI_PROCESSOR_INFORMATION *ProcInfoBuffer; - EFI_SECURE_PARTITION_CPU_INFO *CpuInfo; - ARM_TF_CPU_DRIVER_EP_DESCRIPTOR *CpuDriverEntryPointDesc; + EFI_HOB_HANDOFF_INFO_TABLE *HobStart; + EFI_RESOURCE_ATTRIBUTE_TYPE Attributes; + UINT32 Index; + UINT32 BufferSize; + UINT32 Flags; + EFI_MMRAM_HOB_DESCRIPTOR_BLOCK *MmramRangesHob; + EFI_MMRAM_DESCRIPTOR *MmramRanges; + EFI_MMRAM_DESCRIPTOR *NsCommBufMmramRange; + MP_INFORMATION_HOB_DATA *MpInformationHobData; + EFI_PROCESSOR_INFORMATION *ProcInfoBuffer; + EFI_SECURE_PARTITION_CPU_INFO *CpuInfo; + MM_CPU_DRIVER_EP_DESCRIPTOR *CpuDriverEntryPointDesc; =20 // Create a hoblist with a PHIT and EOH HobStart =3D HobConstructor ( @@ -144,13 +145,13 @@ CreateHobListFromBootInfo ( =20 // 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 *)BuildGuid= Hob ( - &gEfiArmT= fCpuDriverEpDescriptorGuid, - sizeof (A= RM_TF_CPU_DRIVER_EP_DESCRIPTOR) - ); + CpuDriverEntryPointDesc =3D (MM_CPU_DRIVER_EP_DESCRIPTOR *)BuildGuidHob ( + &gEfiMmCpuDri= verEpDescriptorGuid, + sizeof (MM_CP= U_DRIVER_EP_DESCRIPTOR) + ); =20 - *CpuDriverEntryPoint =3D NULL; - CpuDriverEntryPointDesc->ArmTfCpuDriverEpPtr =3D CpuDriverEntryPoint; + *CpuDriverEntryPoint =3D NULL; + CpuDriverEntryPointDesc->MmCpuDriverEpPtr =3D CpuDriverEntryPoint; =20 // Find the size of the GUIDed HOB with SRAM ranges BufferSize =3D sizeof (EFI_MMRAM_HOB_DESCRIPTOR_BLOCK); diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/Standal= oneMmCoreEntryPoint.c b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/= Arm/StandaloneMmCoreEntryPoint.c index 96de10405af8..70306be2495e 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 @@ -41,7 +42,7 @@ STATIC CONST UINT32 mSpmMinorVerFfa =3D SPM_MINOR_VERSIO= N_FFA; =20 #define BOOT_PAYLOAD_VERSION 1 =20 -PI_MM_ARM_TF_CPU_DRIVER_ENTRYPOINT CpuDriverEntryPoint =3D NULL; +PI_MM_CPU_DRIVER_ENTRYPOINT CpuDriverEntryPoint =3D NULL; =20 /** Retrieve a pointer to and print the boot information passed by privileged @@ -140,34 +141,46 @@ 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); - if (FfaEnabled) { - Status =3D CpuDriverEntryPoint ( - EventCompleteSvcArgs->Arg0, - EventCompleteSvcArgs->Arg6, - EventCompleteSvcArgs->Arg3 - ); - if (EFI_ERROR (Status)) { - DEBUG (( - DEBUG_ERROR, - "Failed delegated event 0x%x, Status 0x%x\n", - EventCompleteSvcArgs->Arg3, - Status - )); - } + // + // ARM TF passes SMC FID of the MM_COMMUNICATE interface as the Event = ID upon + // receipt of a synchronous MM request. Use the Event ID to distinguish + // between synchronous and asynchronous events. + // + if ((ARM_SMC_ID_MM_COMMUNICATE !=3D (UINT32)EventCompleteSvcArgs->Arg0= ) && + (ARM_SVC_ID_FFA_MSG_SEND_DIRECT_REQ !=3D (UINT32)EventCompleteSvcA= rgs->Arg0)) + { + DEBUG ((DEBUG_ERROR, "UnRecognized Event - 0x%x\n", (UINT32)EventCom= pleteSvcArgs->Arg0)); + Status =3D EFI_INVALID_PARAMETER; } else { - Status =3D CpuDriverEntryPoint ( - EventCompleteSvcArgs->Arg0, - EventCompleteSvcArgs->Arg3, - EventCompleteSvcArgs->Arg1 - ); - if (EFI_ERROR (Status)) { - DEBUG (( - DEBUG_ERROR, - "Failed delegated event 0x%x, Status 0x%x\n", - EventCompleteSvcArgs->Arg0, - Status - )); + FfaEnabled =3D FeaturePcdGet (PcdFfaEnable); + if (FfaEnabled) { + Status =3D CpuDriverEntryPoint ( + EventCompleteSvcArgs->Arg0, + EventCompleteSvcArgs->Arg6, + EventCompleteSvcArgs->Arg3 + ); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "Failed delegated event 0x%x, Status 0x%x\n", + EventCompleteSvcArgs->Arg3, + Status + )); + } + } else { + Status =3D CpuDriverEntryPoint ( + EventCompleteSvcArgs->Arg0, + EventCompleteSvcArgs->Arg3, + EventCompleteSvcArgs->Arg1 + ); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "Failed delegated event 0x%x, Status 0x%x\n", + EventCompleteSvcArgs->Arg0, + Status + )); + } } } =20 diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneM= mCoreEntryPoint.inf b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/St= andaloneMmCoreEntryPoint.inf index 75cfb98c0e75..d41d7630b614 100644 --- a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEn= tryPoint.inf +++ b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEn= tryPoint.inf @@ -49,7 +49,7 @@ gMpInformationHobGuid gEfiMmPeiMmramMemoryReserveGuid gEfiStandaloneMmNonSecureBufferGuid - gEfiArmTfCpuDriverEpDescriptorGuid + gEfiMmCpuDriverEpDescriptorGuid =20 [FeaturePcd.ARM, FeaturePcd.AARCH64] gArmTokenSpaceGuid.PcdFfaEnable --=20 2.25.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 (#109179): https://edk2.groups.io/g/devel/message/109179 Mute This Topic: https://groups.io/mt/101646679/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-