From nobody Wed May 15 01:03:02 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+108661+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+108661+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1694733046; cv=none; d=zohomail.com; s=zohoarc; b=gbfGvabtHjaaoT4iuQXTsrUCQLyyLMx44BuePh5C+f46oAuGIuyBUBL2RkoPIbbf+w1fKwPvEJiYfvB+y0Yx86PRiICRpwCfK0hnLoiVM7d5k0c9jnWw7nMRFeH/bxRZzOv4lI0gEzRhk8b6Tr4pn05l8w7uR6CkS+NjCVOvDLs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694733046; 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=0H6NCHdjugWDfBSDvGAcXCJRalPzac0O8yEMu5/N9Do=; b=Gro0uJV7z+rxlVVV4RsSHQy9r6apoeWJ/Ct0SbcS/bgnH0510ef/j5HFy0p9plabRGkh6t8VpBEVrYiWYXgmwov6YlgkUNdDtdgGxCLTdgWFu/rqTgVDvVIuOaOXTreco31L51Vdvj4T+YM7w7bAztm1NEAQQk3uwvFPl4AWzqk= 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+108661+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 16947330466410.5853967381200391; Thu, 14 Sep 2023 16:10:46 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=x9iTyWSKhT5tRAb1P63cK1Im2YMFsOj15I4In13V5oM=; 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=1694733046; v=1; b=KacBfOZ09YXZx3bj/8vlkLiLQdcAsupAuTeYU/yksTokPT2lBf0ZQfXBTs5kFNcyNz4w8PV2 nHG1avbjPIIZyWHbwGtRIosTArKvn/KlD7iUhV/JBOS1hc3vIQR0WcloOs49iquIcXp4ZYI9kVU s9XrIIM1DaRssJiKAgdjh0Bs= X-Received: by 127.0.0.2 with SMTP id fPcCYY1788612xPx1W7s0edr; Thu, 14 Sep 2023 16:10:46 -0700 X-Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) by mx.groups.io with SMTP id smtpd.web10.9111.1694733045558542331 for ; Thu, 14 Sep 2023 16:10:45 -0700 X-Received: by mail-pf1-f176.google.com with SMTP id d2e1a72fcca58-68fac346f6aso1368624b3a.3 for ; Thu, 14 Sep 2023 16:10:45 -0700 (PDT) X-Gm-Message-State: qSQjQRPKwjKuU39I44t5iUylx1787277AA= X-Google-Smtp-Source: AGHT+IHUlVRXqr+ArEZz72TgsU63BMy4+qPdS6ECjk504iGr/z2YA8B1JZKVUAn9MZkI3yS484B1kw== X-Received: by 2002:a05:6a20:748d:b0:137:74f8:62ee with SMTP id p13-20020a056a20748d00b0013774f862eemr236875pzd.18.1694733044467; Thu, 14 Sep 2023 16:10:44 -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 d24-20020aa78e58000000b0066a4e561beesm1865591pfr.173.2023.09.14.16.10.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 16:10:44 -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, Tuan Phan Subject: [edk2-devel] [PATCH v2 1/2] StandaloneMmPkg: Make StandaloneMmCpu driver platform independent Date: Thu, 14 Sep 2023 16:10:36 -0700 Message-Id: <20230914231037.23950-2-tphan@ventanamicro.com> In-Reply-To: <20230914231037.23950-1-tphan@ventanamicro.com> References: <20230914231037.23950-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: 1694733046926100001 Content-Type: text/plain; charset="utf-8" StandaloneMmCpu now can supports more platforms like RISC-V besides ARM/AARCH64. Signed-off-by: Tuan Phan Reviewed-by: Sami Mujawar Reviewed-by: levi.yun --- .../Drivers/StandaloneMmCpu/EventHandle.c | 25 +++-------- .../Drivers/StandaloneMmCpu/StandaloneMmCpu.c | 42 +++++++++---------- .../StandaloneMmCpu/StandaloneMmCpu.inf | 9 ++-- .../StandaloneMmCpu.h | 22 +++++++--- StandaloneMmPkg/StandaloneMmPkg.dec | 2 +- 5 files changed, 46 insertions(+), 54 deletions(-) rename StandaloneMmPkg/{Drivers/StandaloneMmCpu =3D> Include}/StandaloneMm= Cpu.h (82%) diff --git a/StandaloneMmPkg/Drivers/StandaloneMmCpu/EventHandle.c b/Standa= loneMmPkg/Drivers/StandaloneMmCpu/EventHandle.c index 818e147f874c..dc11d4375a02 100644 --- a/StandaloneMmPkg/Drivers/StandaloneMmCpu/EventHandle.c +++ b/StandaloneMmPkg/Drivers/StandaloneMmCpu/EventHandle.c @@ -3,6 +3,7 @@ Copyright (c) 2016 HP Development Company, L.P. Copyright (c) 2016 - 2021, Arm Limited. All rights reserved. Copyright (c) 2021, Linaro Limited + Copyright (c) 2023, Ventana Micro System Inc. All rights reserved. =20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -11,8 +12,6 @@ #include #include =20 -#include -#include #include #include #include @@ -22,10 +21,7 @@ #include #include =20 -#include -#include - -#include "StandaloneMmCpu.h" +#include =20 EFI_STATUS EFIAPI @@ -108,7 +104,7 @@ CheckBufferAddr ( } =20 /** - The PI Standalone MM entry point for the TF-A CPU driver. + The PI Standalone MM entry point for the CPU driver. =20 @param [in] EventId The event Id. @param [in] CpuNumber The CPU number. @@ -121,7 +117,7 @@ CheckBufferAddr ( @retval EFI_UNSUPPORTED Operation not supported. **/ EFI_STATUS -PiMmStandaloneArmTfCpuDriverEntry ( +PiMmStandaloneMmCpuDriverEntry ( IN UINTN EventId, IN UINTN CpuNumber, IN UINTN NsCommBufferAddr @@ -135,17 +131,6 @@ PiMmStandaloneArmTfCpuDriverEntry ( DEBUG ((DEBUG_INFO, "Received event - 0x%x on cpu %d\n", EventId, CpuNum= ber)); =20 Status =3D EFI_SUCCESS; - // - // 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 EventId) && - (ARM_SVC_ID_FFA_MSG_SEND_DIRECT_REQ !=3D EventId)) - { - DEBUG ((DEBUG_ERROR, "UnRecognized Event - 0x%x\n", EventId)); - return EFI_INVALID_PARAMETER; - } =20 // Perform parameter validation of NsCommBufferAddr if (NsCommBufferAddr =3D=3D (UINTN)NULL) { @@ -177,7 +162,7 @@ PiMmStandaloneArmTfCpuDriverEntry ( } =20 // X1 contains the VA of the normal world memory accessible from - // S-EL0 + // secure world. CopyMem (GuidedEventContext, (CONST VOID *)NsCommBufferAddr, NsCommBuffe= rSize); =20 // Stash the pointer to the allocated Event Context for this CPU diff --git a/StandaloneMmPkg/Drivers/StandaloneMmCpu/StandaloneMmCpu.c b/St= andaloneMmPkg/Drivers/StandaloneMmCpu/StandaloneMmCpu.c index 3d1dc6181bd9..c5ec1a5a80c5 100644 --- a/StandaloneMmPkg/Drivers/StandaloneMmCpu/StandaloneMmCpu.c +++ b/StandaloneMmPkg/Drivers/StandaloneMmCpu/StandaloneMmCpu.c @@ -3,6 +3,7 @@ Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
Copyright (c) 2016 HP Development Company, L.P. Copyright (c) 2016 - 2021, Arm Limited. All rights reserved. + Copyright (c) 2023, Ventana Micro System Inc. All rights reserved. =20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -10,10 +11,7 @@ =20 #include #include -#include #include -#include -#include #include #include =20 @@ -22,7 +20,7 @@ #include #include =20 -#include "StandaloneMmCpu.h" +#include =20 // GUID to identify HOB with whereabouts of communication buffer with Norm= al // World @@ -31,7 +29,7 @@ extern EFI_GUID gEfiStandaloneMmNonSecureBufferGuid; // GUID to identify HOB where the entry point of this CPU driver will be // populated to allow the entry point driver to invoke it upon receipt of = an // event -extern EFI_GUID gEfiArmTfCpuDriverEpDescriptorGuid; +extern EFI_GUID gEfiMmCpuDriverEpDescriptorGuid; =20 // // Private copy of the MM system table for future use @@ -96,17 +94,17 @@ StandaloneMmCpuInitialize ( IN EFI_MM_SYSTEM_TABLE *SystemTable // not actual systemtable ) { - ARM_TF_CPU_DRIVER_EP_DESCRIPTOR *CpuDriverEntryPointDesc; - EFI_CONFIGURATION_TABLE *ConfigurationTable; - MP_INFORMATION_HOB_DATA *MpInformationHobData; - EFI_MMRAM_DESCRIPTOR *NsCommBufMmramRange; - EFI_STATUS Status; - EFI_HANDLE DispatchHandle; - UINT32 MpInfoSize; - UINTN Index; - UINTN ArraySize; - VOID *HobStart; - EFI_MMRAM_HOB_DESCRIPTOR_BLOCK *MmramRangesHob; + MM_CPU_DRIVER_EP_DESCRIPTOR *CpuDriverEntryPointDesc; + EFI_CONFIGURATION_TABLE *ConfigurationTable; + MP_INFORMATION_HOB_DATA *MpInformationHobData; + EFI_MMRAM_DESCRIPTOR *NsCommBufMmramRange; + EFI_STATUS Status; + EFI_HANDLE DispatchHandle; + UINT32 MpInfoSize; + UINTN Index; + UINTN ArraySize; + VOID *HobStart; + EFI_MMRAM_HOB_DESCRIPTOR_BLOCK *MmramRangesHob; =20 ASSERT (SystemTable !=3D NULL); mMmst =3D SystemTable; @@ -133,7 +131,7 @@ StandaloneMmCpuInitialize ( } =20 // Retrieve the Hoblist from the MMST to extract the details of the NS - // communication buffer that has been reserved by S-EL1/EL3 + // communication buffer that has been reserved for StandaloneMmPkg ConfigurationTable =3D mMmst->MmConfigurationTable; for (Index =3D 0; Index < mMmst->NumberOfTableEntries; Index++) { if (CompareGuid (&gEfiHobListGuid, &(ConfigurationTable[Index].VendorG= uid))) { @@ -154,11 +152,11 @@ StandaloneMmCpuInitialize ( // Status =3D GetGuidedHobData ( HobStart, - &gEfiArmTfCpuDriverEpDescriptorGuid, + &gEfiMmCpuDriverEpDescriptorGuid, (VOID **)&CpuDriverEntryPointDesc ); if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "ArmTfCpuDriverEpDesc HOB data extraction failed = - 0x%x\n", Status)); + DEBUG ((DEBUG_ERROR, "MmCpuDriverEpDesc HOB data extraction failed - 0= x%x\n", Status)); return Status; } =20 @@ -166,10 +164,10 @@ StandaloneMmCpuInitialize ( DEBUG (( DEBUG_INFO, "Sharing Cpu Driver EP *0x%lx =3D 0x%lx\n", - (UINTN)CpuDriverEntryPointDesc->ArmTfCpuDriverEpPtr, - (UINTN)PiMmStandaloneArmTfCpuDriverEntry + (UINTN)CpuDriverEntryPointDesc->MmCpuDriverEpPtr, + (UINTN)PiMmStandaloneMmCpuDriverEntry )); - *(CpuDriverEntryPointDesc->ArmTfCpuDriverEpPtr) =3D PiMmStandaloneArmTfC= puDriverEntry; + *(CpuDriverEntryPointDesc->MmCpuDriverEpPtr) =3D PiMmStandaloneMmCpuDriv= erEntry; =20 // Find the descriptor that contains the whereabouts of the buffer for // communication with the Normal world. diff --git a/StandaloneMmPkg/Drivers/StandaloneMmCpu/StandaloneMmCpu.inf b/= StandaloneMmPkg/Drivers/StandaloneMmCpu/StandaloneMmCpu.inf index 1fcb17d89d36..486ccbac1b7c 100644 --- a/StandaloneMmPkg/Drivers/StandaloneMmCpu/StandaloneMmCpu.inf +++ b/StandaloneMmPkg/Drivers/StandaloneMmCpu/StandaloneMmCpu.inf @@ -1,9 +1,10 @@ ## @file -# Standalone MM CPU driver for ARM Standard Platforms +# Standalone MM CPU driver # # Copyright (c) 2009, Apple Inc. All rights reserved.
# Copyright (c) 2016 HP Development Company, L.P. # Copyright (c) 2017 - 2021, Arm Limited. All rights reserved. +# Copyright (c) 2023, Ventana Micro System Inc. All rights reserved. # # SPDX-License-Identifier: BSD-2-Clause-Patent ## @@ -19,18 +20,14 @@ =20 [Sources] StandaloneMmCpu.c - StandaloneMmCpu.h EventHandle.c =20 [Packages] - ArmPkg/ArmPkg.dec MdePkg/MdePkg.dec MdeModulePkg/MdeModulePkg.dec StandaloneMmPkg/StandaloneMmPkg.dec =20 [LibraryClasses] - ArmLib - ArmSvcLib BaseMemoryLib DebugLib HobLib @@ -46,7 +43,7 @@ gZeroGuid gMpInformationHobGuid gEfiStandaloneMmNonSecureBufferGuid - gEfiArmTfCpuDriverEpDescriptorGuid + gEfiMmCpuDriverEpDescriptorGuid =20 [Depex] TRUE diff --git a/StandaloneMmPkg/Drivers/StandaloneMmCpu/StandaloneMmCpu.h b/St= andaloneMmPkg/Include/StandaloneMmCpu.h similarity index 82% rename from StandaloneMmPkg/Drivers/StandaloneMmCpu/StandaloneMmCpu.h rename to StandaloneMmPkg/Include/StandaloneMmCpu.h index 3d4698ec1957..1dce7c132ec2 100644 --- a/StandaloneMmPkg/Drivers/StandaloneMmCpu/StandaloneMmCpu.h +++ b/StandaloneMmPkg/Include/StandaloneMmCpu.h @@ -7,14 +7,26 @@ =20 **/ =20 -#ifndef _ARM_TF_CPU_DRIVER_H_ -#define _ARM_TF_CPU_DRIVER_H_ +#ifndef MM_CPU_DRIVER_H_ +#define MM_CPU_DRIVER_H_ =20 #include #include #include #include =20 +typedef +EFI_STATUS +(*PI_MM_CPU_DRIVER_ENTRYPOINT) ( + IN UINTN EventId, + IN UINTN CpuNumber, + IN UINTN NsCommBufferAddr + ); + +typedef struct { + PI_MM_CPU_DRIVER_ENTRYPOINT *MmCpuDriverEpPtr; +} MM_CPU_DRIVER_EP_DESCRIPTOR; + // // CPU driver initialization specific declarations // @@ -35,7 +47,7 @@ extern MP_INFORMATION_HOB_DATA *mMpInformationHobD= ata; extern EFI_MM_CONFIGURATION_PROTOCOL mMmConfig; =20 /** - The PI Standalone MM entry point for the TF-A CPU driver. + The PI Standalone MM entry point for the CPU driver. =20 @param [in] EventId The event Id. @param [in] CpuNumber The CPU number. @@ -48,7 +60,7 @@ extern EFI_MM_CONFIGURATION_PROTOCOL mMmConfig; @retval EFI_UNSUPPORTED Operation not supported. **/ EFI_STATUS -PiMmStandaloneArmTfCpuDriverEntry ( +PiMmStandaloneMmCpuDriverEntry ( IN UINTN EventId, IN UINTN CpuNumber, IN UINTN NsCommBufferAddr @@ -79,4 +91,4 @@ PiMmCpuTpFwRootMmiHandler ( IN OUT UINTN *CommBufferSize OPTIONAL ); =20 -#endif +#endif /* MM_CPU_DRIVER_H_ */ diff --git a/StandaloneMmPkg/StandaloneMmPkg.dec b/StandaloneMmPkg/Standalo= neMmPkg.dec index 46784d94e421..f7cb9e8e2687 100644 --- a/StandaloneMmPkg/StandaloneMmPkg.dec +++ b/StandaloneMmPkg/StandaloneMmPkg.dec @@ -46,5 +46,5 @@ gEfiMmPeiMmramMemoryReserveGuid =3D { 0x0703f912, 0xbf8d, 0x4e2= a, { 0xbe, 0x07, 0xab, 0x27, 0x25, 0x25, 0xc5, 0x92 }} =20 gEfiStandaloneMmNonSecureBufferGuid =3D { 0xf00497e3, 0xbfa2, 0x41a= 1, { 0x9d, 0x29, 0x54, 0xc2, 0xe9, 0x37, 0x21, 0xc5 }} - gEfiArmTfCpuDriverEpDescriptorGuid =3D { 0x6ecbd5a1, 0xc0f8, 0x470= 2, { 0x83, 0x01, 0x4f, 0xc2, 0xc5, 0x47, 0x0a, 0x51 }} + gEfiMmCpuDriverEpDescriptorGuid =3D { 0x6ecbd5a1, 0xc0f8, 0x470= 2, { 0x83, 0x01, 0x4f, 0xc2, 0xc5, 0x47, 0x0a, 0x51 }} =20 --=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 (#108661): https://edk2.groups.io/g/devel/message/108661 Mute This Topic: https://groups.io/mt/101369646/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 Wed May 15 01:03:02 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+108662+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+108662+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1694733049; cv=none; d=zohomail.com; s=zohoarc; b=VhUevZ2cUaiXFyoZ+zHNqUX1Ju73NbU1zRQMlMkmnxePmNJfrt1gzW9VzoNfAwU/KHPMB6E+cJBsH2DwRLh7MSCvj+imqUy3wxAaXqCweBLbRClu/SbDReDA+b7/8ETs8JfOVnmJuKVrbsyLbOkNK74tIPW4Uil6doQSzr2/Bso= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694733049; 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=72c+zo8pQUF/r/FUrCi5XVmZ7fukb9ySDoNWo0Mq180=; b=gyqwqPMHETYF9QnLGgmTLjUp4dQDmN84CVWADUd3WcAQdQvTP/lYZCmiPdPcCZ1mawM0QdATRi4A/PJJwR0IQ2vR+A0n7OFVqrBDOb4bZmb5Q2owXBDAe5gpKEG1QPDhMqSVLPU5RD0Auk3zCjlKu1KW60mURniTYEYhkcTQjOM= 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+108662+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1694733049948234.4546379548849; Thu, 14 Sep 2023 16:10:49 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=969yr8NZ3APYY2lVCzvc06LvzQ46bAlvfWmP5oeI1X0=; 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=1694733049; v=1; b=NuvFiokLVbvKWUcSN8ejVEle2tna5qSG5M2t8i3jNA3vF34dPnGqTeGQz4qlikNk4smg9ia1 tdCuEB6DAQR31eNN0ec5af4wFivn0FRgXzT0UxpJuSxgSUUaTf5Tg353sWEx/uAy34sblg2PhR0 TojVi7RFbY0iOWwVt57dca6Q= X-Received: by 127.0.0.2 with SMTP id mjr7YY1788612x9wq8ABYATn; Thu, 14 Sep 2023 16:10:49 -0700 X-Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) by mx.groups.io with SMTP id smtpd.web10.9112.1694733046886226404 for ; Thu, 14 Sep 2023 16:10:46 -0700 X-Received: by mail-pf1-f173.google.com with SMTP id d2e1a72fcca58-68fbb10dea4so1238807b3a.3 for ; Thu, 14 Sep 2023 16:10:46 -0700 (PDT) X-Gm-Message-State: xMXZhaJKN3jqQPRP99Nx9NFax1787277AA= X-Google-Smtp-Source: AGHT+IH1p/0/SfdZFZAx2Od2IpkAr/nLrsSxzMSIbW4c5sFDng0WVUp7emgbLFuJ2+65mzRgmiyZ7w== X-Received: by 2002:a05:6a00:1ac6:b0:690:45cc:bd37 with SMTP id f6-20020a056a001ac600b0069045ccbd37mr68121pfv.18.1694733045904; Thu, 14 Sep 2023 16:10:45 -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 d24-20020aa78e58000000b0066a4e561beesm1865591pfr.173.2023.09.14.16.10.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 16:10:45 -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, Tuan Phan Subject: [edk2-devel] [PATCH v2 2/2] StandaloneMmPkg: Arm: Update to use the new StandaloneMmCpu driver Date: Thu, 14 Sep 2023 16:10:37 -0700 Message-Id: <20230914231037.23950-3-tphan@ventanamicro.com> In-Reply-To: <20230914231037.23950-1-tphan@ventanamicro.com> References: <20230914231037.23950-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: 1694733051173100001 Content-Type: text/plain; charset="utf-8" Update entry point library for Arm to use the new platform independent StandaloneMmCpu driver. Signed-off-by: Tuan Phan Reviewed-by: levi.yun --- .../Library/Arm/StandaloneMmCoreEntryPoint.h | 17 ++------ .../Arm/CreateHobList.c | 43 ++++++++++--------- .../Arm/StandaloneMmCoreEntryPoint.c | 15 ++++++- .../StandaloneMmCoreEntryPoint.inf | 2 +- 4 files changed, 40 insertions(+), 37 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..900e0252ef9f 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,6 +141,18 @@ DelegatedEventLoop ( DEBUG ((DEBUG_INFO, "X6 : 0x%x\n", (UINT32)EventCompleteSvcArgs->Arg6= )); DEBUG ((DEBUG_INFO, "X7 : 0x%x\n", (UINT32)EventCompleteSvcArgs->Arg7= )); =20 + // + // 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)); + continue; + } + FfaEnabled =3D FeaturePcdGet (PcdFfaEnable); if (FfaEnabled) { Status =3D CpuDriverEntryPoint ( 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 (#108662): https://edk2.groups.io/g/devel/message/108662 Mute This Topic: https://groups.io/mt/101369647/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-