From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (NAM10-DM6-obe.outbound.protection.outlook.com [40.107.93.57]) by mx.groups.io with SMTP id smtpd.web10.11409.1689261873679361867 for ; Thu, 13 Jul 2023 08:24:33 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@nvidia.com header.s=selector2 header.b=h6IraLNZ; spf=permerror, err=parse error for token &{10 18 %{i}._ip.%{h}._ehlo.%{d}._spf.vali.email}: invalid domain name (domain: nvidia.com, ip: 40.107.93.57, mailfrom: gmahadevan@nvidia.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Rppi9XjxeAbnmsb1w0B0sttHs7YvJG9PiiP0qwfk+BxvA2UaEnBwClE+oeodn9+g2Set6DTvmgEk3KnKeyZYoYhef6jAjtgIKZwa8KYbQoEvKYBOeAiC3EigiDwMGeMMciRMnPhU3P1wpRIUGnvao46MEzSww9UCh9T9v/Y3xJNK8B8jMlR0GMiUE+uY6HR3tBVF62afr2V39O96zf8Ncb7fq/ZiR+rPl/rzFpzPOfKxx4iY1xFS4b1plTeQZfvrHwTkhgBrbFYd2YmOZCDwtay2IClJoN+kJyJA0G5XGx/TeQ++b8OOeZgheKJrdmeIWOcWQkFX80FXF42UxoDpKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=XA99A3IkTpwvQYIKZos1rETyqd1ICWMfu02hmM6yTB8=; b=SE0lgL0jVwJGzlTwJ6ybPtC1eaNclImtYbpj1cpgSD6/2temOvkoGzCxoQ1KueqNTvt+wnDV+YAbqKgUu27FxUxjDM1gsT9KIZLG8uKCmCMT9qtW3MQxt5aMw8iMGJ5fyXW7a3OGyRyb5XEZRoL7Q4b55FqVZ0RXlZqup97XLwlStPl1roazgPJtW94QZagx2LsiHQQgkTxd8zmGjqm/CawseY7SP66Wzrw0xCzwtE4BFkJrQbZXe0mQTQVOzrz70AJwo4lgrZNC2HdgcaZKtbHz8l4fmdZ04d9SZmGuWBK7w3ipN/VinRgQYIFRf3IpCcQnhKOoQ3Qbe1GK+/MNyg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XA99A3IkTpwvQYIKZos1rETyqd1ICWMfu02hmM6yTB8=; b=h6IraLNZ7OdyO/r7n+VJzFyC8FyKpH4sjcnfIePV9s2UDkGlBRlHoyojcLiLdpdmhHD8qJrONyVfMyer86aNrZSNCUdgPHGgQ2LxV8a+k12BoaMU6LfIwwRqiUqfpm1HRmPa+A81d3EJ+H2ZZZvWEXvxq4qAfHBPNGILnfJsh0gF34F0y0UppnmiHD+9OJqSYNFI2S6AD6Xngu00hXwSxEJISfxO0qCQjm15/m3X7254HhOsCLuyfCVJKW1aLzcDCUYJCdKGGFeweWe7QhXFCGXbVwEwzwbNLEZv3INngD2mdgchSYrw5RD7rJ9aHoTEdEVXotcfcYIi7ctlQWt38Q== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from CY5PR12MB6297.namprd12.prod.outlook.com (2603:10b6:930:22::19) by PH7PR12MB6740.namprd12.prod.outlook.com (2603:10b6:510:1ab::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.31; Thu, 13 Jul 2023 15:24:30 +0000 Received: from CY5PR12MB6297.namprd12.prod.outlook.com ([fe80::cc7d:38f9:a163:1106]) by CY5PR12MB6297.namprd12.prod.outlook.com ([fe80::cc7d:38f9:a163:1106%5]) with mapi id 15.20.6588.022; Thu, 13 Jul 2023 15:24:30 +0000 Message-ID: <92ce5fad-2b6d-ede2-98e8-117d974000ef@nvidia.com> Date: Thu, 13 Jul 2023 09:24:28 -0600 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [edk2-devel] [edk2-platforms][PATCH V1 09/20] StandaloneMmPkg: parse SP manifest and populate new boot information To: devel@edk2.groups.io, nishant.sharma@arm.com Cc: Ard Biesheuvel , Sami Mujawar , Thomas Abraham , Sayanta Pattanayak , Achin Gupta References: <20230711143658.781597-1-nishant.sharma@arm.com> <20230711143658.781597-10-nishant.sharma@arm.com> From: "Girish Mahadevan" In-Reply-To: <20230711143658.781597-10-nishant.sharma@arm.com> X-ClientProxiedBy: BL1P221CA0001.NAMP221.PROD.OUTLOOK.COM (2603:10b6:208:2c5::12) To CY5PR12MB6297.namprd12.prod.outlook.com (2603:10b6:930:22::19) Return-Path: gmahadevan@nvidia.com MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY5PR12MB6297:EE_|PH7PR12MB6740:EE_ X-MS-Office365-Filtering-Correlation-Id: c864f091-2b14-4468-06ef-08db83b540eb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XXN2A4djJq6YxNYg/ZGCQGD8Rbk6rgqFYXCu1oaha1lLjn55JQItp8uSxlyK8WVGOfHMGLp56Fzq5WB6W1UWAVUHbTrans2ZL3yNw2+RD0z0kO5IWcCuv0Sa+IHLZk9Mp1uT9JYt7O2YHIkiAkwpGyUDaLxjNhGclea/8Q53Z7VHvyBXELKJPaFoCqwPxanxX8wYdc41YtpGSsVAK/mzE9ubFHKE0eGkli38I7MSvUzxcAsrhS1iOS3Xgjf8fLZ8nMfbZAFUrNfTkEBiqxY/vK8U8v3EkvecTIuBW+XIqp43k5w05X+6oKysqptVX71igUz+pzbvtKsb0/GgsFBYMDBwfb7F81HxxHkPRdIZQdJZDlsuh0lwmSTkk51PEj1bQem2UijaauACzHhXwFNgVuI3dQX3V1rtNdUNmCGT225Z1pXYPNsfCX85Wb0JxMAL5CcexPOBkfimeEvaMxeQN1XnOfX6xN8RC3r3gkeNuvoTPaLgTtMv0iee34EBZ72jZslGuKksermhoRcT1nZqp/2Bic6KPFEKIkRWzToaTwBkSc3TNA2KN4dfFuVMqhdq1hQvk4WNhoOTPVDxpMn1F5Xu9upfhlC77BQitoxiNtOFMah7BDxTlT29q3NJi422UPSaAqZRqbZCg4Za8WBTIQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY5PR12MB6297.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(6029001)(4636009)(39860400002)(136003)(396003)(366004)(376002)(346002)(451199021)(478600001)(83380400001)(966005)(53546011)(2616005)(186003)(6506007)(26005)(36756003)(6512007)(6486002)(316002)(2906002)(41300700001)(30864003)(38100700002)(66946007)(66476007)(66556008)(4326008)(86362001)(31696002)(8936002)(31686004)(8676002)(5660300002)(54906003)(66899021)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?dFd5Vzh6WVc2bnYwRDh3ZjdFWTdUTEtVd2tRaFd2NXNvNXlTTVRWelk3Ujhk?= =?utf-8?B?Y3VPZzRtby84Mjk1cHR0ZStoWDIyUGRLVlNYMHJVczV6UFpBd1YvSCtzOHU0?= =?utf-8?B?V0d6Vi92cUltTk1EMHM3YXNQWFNBcGxTMFlCQTJWTmFnbXUrYmlPYU5zT1lm?= =?utf-8?B?TFQ3enRJSno3TDU0Y1p5RlNGejJGOUlGODRhR2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UW5DSTdaY1R2TWl1RDRoN0lZWFdYblAvS21zYnNZMWs2NzA1?= =?utf-8?B?bkVEODFDd2c4akZFN1NGd2ZsT2RjMUkyVkZEbzBQVlVCMTBiZndwcWtId0sr?= =?utf-8?Q?OeqhaHDQgTMThgwkvyp7d6P42?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: c864f091-2b14-4468-06ef-08db83b540eb X-MS-Exchange-CrossTenant-AuthSource: CY5PR12MB6297.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jul 2023 15:24:30.6898 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: yiAZmKDCrrL5tZv80YYm7PkrMBxs3xLvJbWkQbY2CAipgYDWwX0RcqbcWQpLdtvH/RnVa/bxSMwBQncJb/94NA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6740 Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit I had one comment , in-line. Thanks Girish On 7/11/2023 8:36 AM, Nishant Sharma via groups.io wrote: > External email: Use caution opening links or attachments > > > 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/StandaloneMmCoreEntryPoint.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 > > -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 > > **/ > diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c > index 9f6af55c86c4..505786aff07c 100644 > --- a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c > +++ b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c > @@ -38,6 +38,10 @@ SPDX-License-Identifier: BSD-2-Clause-Patent > > #define BOOT_PAYLOAD_VERSION 1 > > +#define FFA_PAGE_4K 0 > +#define FFA_PAGE_16K 1 > +#define FFA_PAGE_64K 2 > + > PI_MM_ARM_TF_CPU_DRIVER_ENTRYPOINT CpuDriverEntryPoint = NULL; > > /** > @@ -106,6 +110,7 @@ GetAndPrintBootinformation ( > } > > return PayloadBootInfo; > +} > > /** > An StMM SP implements partial support for FF-A v1.0. The FF-A ABIs are used to > @@ -266,6 +271,308 @@ DelegatedEventLoop ( > } > } > > +STATIC > +BOOLEAN > +CheckDescription ( > + IN VOID * DtbAddress, > + IN INT32 Offset, > + OUT CHAR8 * Description, > + OUT UINT32 Size > + ) > +{ > + CONST CHAR8 * Property; > + INT32 LenP; > + > + Property = fdt_getprop (DtbAddress, Offset, "description", &LenP); > + if (Property == NULL) { > + return FALSE; > + } > + > + return CompareMem (Description, Property, MIN(Size, (UINT32)LenP)) == 0; > + > +} > + > +STATIC > +EFI_STATUS > +ReadProperty32 ( > + IN VOID * DtbAddress, > + IN INT32 Offset, > + IN CHAR8 * Property, > + OUT UINT32 * Value > + ) > +{ > + CONST UINT32 * Property32; > + > + Property32 = fdt_getprop (DtbAddress, Offset, Property, NULL); > + if (Property32 == NULL) { > + DEBUG (( > + DEBUG_ERROR, > + "%s: Missing in FF-A boot information manifest\n", > + Property > + )); > + return EFI_INVALID_PARAMETER; > + } > + > + *Value = 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 = fdt_getprop (DtbAddress, Offset, Property, NULL); > + if (Property64 == NULL) { > + DEBUG (( > + DEBUG_ERROR, > + "%s: Missing in FF-A boot information manifest\n", > + Property > + )); > + return EFI_INVALID_PARAMETER; > + } > + > + *Value = 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 = 0; > + > + FoundBuffer = CheckDescription ( > + DtbAddress, > + Node, > + Region, > + RegionStrSize > + ); > + if (!FoundBuffer) { > + return FALSE; > + } > + > + DEBUG ((DEBUG_INFO, "Found Node: %a\n", Region)); > + Status = ReadProperty64 ( > + DtbAddress, > + Node, > + "base-address", > + Address > + ); > + if (Status != EFI_SUCCESS) { > + DEBUG ((DEBUG_ERROR, "base-address missing in DTB")); > + return FALSE; > + } > + DEBUG (( > + DEBUG_INFO, > + "base = 0x%llx\n", > + *Address > + )); > + > + Status = ReadProperty32 ( > + DtbAddress, > + Node, > + "pages-count", > + (UINT32*)Size > + ); > + if (Status != EFI_SUCCESS) { > + DEBUG ((DEBUG_ERROR, "pages-count missing in DTB")); > + return FALSE; > + } > + > + DEBUG ((DEBUG_ERROR, "pages-count: 0x%lx\n", *Size)); > + > + *Size = *Size * PageSize; > + DEBUG (( > + DEBUG_INFO, > + "Size = 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 extracted. > + > + @param [in, out] StmmBootInfo Pointer to a pre-allocated boot info structure 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 = FALSE; > + BOOLEAN FoundSharedBuffer = FALSE; > + BOOLEAN FoundHeap = FALSE; > + UINT32 PageSize; > + > + Offset = fdt_node_offset_by_compatible (DtbAddress, -1, "arm,ffa-manifest-1.0"); > + DEBUG ((DEBUG_INFO, "Offset = %d \n", Offset)); > + if (Offset < 0) { > + DEBUG ((DEBUG_ERROR, "Missing FF-A boot information in manifest\n")); > + return EFI_NOT_FOUND; > + } > + > + Status = ReadProperty64 ( > + DtbAddress, > + Offset, > + "load-address", > + &StmmBootInfo->SpMemBase > + ); > + if (Status != EFI_SUCCESS) { > + return Status; > + } > + DEBUG ((DEBUG_INFO, "sp mem base = 0x%llx\n", StmmBootInfo->SpMemBase)); > + > + Status = ReadProperty64 ( > + DtbAddress, > + Offset, > + "image-size", > + &StmmBootInfo->SpMemSize > + ); > + if (Status != EFI_SUCCESS) { > + return Status; > + } > + DEBUG ((DEBUG_INFO, "sp mem size = 0x%llx\n", StmmBootInfo->SpMemSize)); > + > + Status = ReadProperty32 (DtbAddress, Offset, "xlat-granule", &PageSize); > + if (Status != EFI_SUCCESS) { > + return Status; > + } > + > + /* EFI_PAGE_SIZE is 4KB */ > + switch (PageSize) { > + case FFA_PAGE_4K: > + PageSize = EFI_PAGE_SIZE; > + break; > + > + case FFA_PAGE_16K: > + PageSize = 4 * EFI_PAGE_SIZE; > + break; > + > + case FFA_PAGE_64K: > + PageSize = 16 * EFI_PAGE_SIZE; > + break; > + > + default: > + DEBUG ((DEBUG_ERROR, "Invalid page type = %lu\n", PageSize)); > + return EFI_INVALID_PARAMETER; > + break; > + }; > + > + DEBUG ((DEBUG_INFO, "Page Size = 0x%lx\n", PageSize)); > + > + Offset = 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 = fdt_first_subnode (DtbAddress, Offset); > + Node > 0; > + Node = fdt_next_subnode (DtbAddress, Node)) { > + if (!FoundNsCommBuffer) { > + FoundNsCommBuffer = ReadRegionInfo ( > + DtbAddress, > + Node, > + "ns-comm", > + sizeof ("ns-comm") - 1, > + PageSize, > + &StmmBootInfo->SpNsCommBufBase, > + &StmmBootInfo->SpNsCommBufSize > + ); > + } > + > + if (!FoundHeap) { > + FoundHeap = ReadRegionInfo ( > + DtbAddress, > + Node, > + "heap", > + sizeof ("heap") - 1, > + PageSize, > + &StmmBootInfo->SpHeapBase, > + &StmmBootInfo->SpHeapSize > + ); > + } > + > + if (!FoundSharedBuffer) { > + FoundSharedBuffer = 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 that > + // this is a uniprocessor SP that is capable of migration. So, it is fine if > + // it sees 0 as both its physical and linear cpu id > + StmmBootInfo->CpuInfo.Mpidr = 0; > + StmmBootInfo->CpuInfo.LinearId = 0; > + StmmBootInfo->CpuInfo.Flags = 0; > + > + return EFI_SUCCESS; > +} [GM] Outside of the mandatory properties, I expect that there could be some custom fields in the dtb manifest. Can you add a means for a vendor to hook in parsing properties that only apply to them. An OEM Library ? > + > /** > Query the SPM version, check compatibility and return success if compatible. > > @@ -343,6 +650,49 @@ InitArmSvcArgs ( > } > } > > + > +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 == NULL) { > + DEBUG ((DEBUG_ERROR, "FF-A Boot information is NULL\n")); > + return EFI_INVALID_PARAMETER; > + } > + > + // Check boot information magic number. > + FfaBootInfo = (EFI_FFA_BOOT_INFO_HEADER *) BootInfoAddr; > + if (FfaBootInfo->Magic != FFA_INIT_DESC_SIGNATURE) { > + DEBUG (( > + DEBUG_ERROR, "FfaBootInfo Magic no. is invalid 0x%ux\n", > + FfaBootInfo->Magic > + )); > + return EFI_INVALID_PARAMETER; > + } > + > + > + FfaBootInfoDesc = > + (EFI_FFA_BOOT_INFO_DESC *)((UINT8 *)BootInfoAddr + > + FfaBootInfo->OffsetBootInfoDesc); > + > + if (FfaBootInfoDesc->Type == > + (FFA_BOOT_INFO_TYPE(FFA_BOOT_INFO_TYPE_STD) | > + FFA_BOOT_INFO_TYPE_ID(FFA_BOOT_INFO_TYPE_ID_FDT))) { > + *SpManifestAddr = (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. > > @@ -363,6 +713,7 @@ ModuleEntryPoint ( > { > PE_COFF_LOADER_IMAGE_CONTEXT ImageContext; > EFI_SECURE_PARTITION_BOOT_INFO *PayloadBootInfo; > + EFI_STMM_BOOT_INFO StmmBootInfo = {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 = FALSE; > > if (FixedPcdGet32 (PcdFfaEnable) != 0) { > @@ -384,18 +737,36 @@ ModuleEntryPoint ( > goto finish; > } > > - PayloadBootInfo = GetAndPrintBootinformation (SharedBufAddress); > - if (PayloadBootInfo == NULL) { > - Status = EFI_UNSUPPORTED; > - goto finish; > + // If only FF-A is used, the DTB address is passed in the Boot information > + // structure. Else, the Boot info is copied from Sharedbuffer. > + if (UseOnlyFfaAbis) { > + Status = GetSpManifest (&DtbAddress, SharedBufAddress); > + if (Status != EFI_SUCCESS) { > + goto finish; > + } > + > + // Extract boot information from the DTB > + Status = PopulateBootinformation (&StmmBootInfo, (VOID *) DtbAddress); > + if (Status != EFI_SUCCESS) { > + goto finish; > + } > + > + // Stash the base address of the boot firmware volume > + BfvAddress = (EFI_FIRMWARE_VOLUME_HEADER *) StmmBootInfo.SpMemBase; > + } else { > + PayloadBootInfo = GetAndPrintBootinformation (SharedBufAddress); > + if (PayloadBootInfo == NULL) { > + Status = EFI_UNSUPPORTED; > + goto finish; > + } > + > + // Stash the base address of the boot firmware volume > + BfvAddress = (EFI_FIRMWARE_VOLUME_HEADER *) PayloadBootInfo->SpImageBase; > } > > + > // Locate PE/COFF File information for the Standalone MM core module > - Status = LocateStandaloneMmCorePeCoffData ( > - (EFI_FIRMWARE_VOLUME_HEADER *)(UINTN)PayloadBootInfo->SpImageBase, > - &TeData, > - &TeDataSize > - ); > + Status = LocateStandaloneMmCorePeCoffData (BfvAddress, &TeData, &TeDataSize); > > if (EFI_ERROR (Status)) { > goto finish; > -- > 2.34.1 > > > > -=-=-=-=-=-= > 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/6098446 > Group Owner: devel+owner@edk2.groups.io > Unsubscribe: https://edk2.groups.io/g/devel/unsub [gmahadevan@nvidia.com] > -=-=-=-=-=-= > >