From eab1ed54bfb6038a0c1ada79de409a5506e4dae0 Mon Sep 17 00:00:00 2001 From: Rakshit Goyal Date: Mon, 29 Apr 2024 11:03:20 +0530 Subject: [PATCH] feat(arm): add a macro for SPMC manifest base address In RESET_TO_BL31, the SPMC manifest base address that is utilized by bl32_image_ep_info has to be statically defined as DT is not available. Common arm code sets this to the top of SRAM using macros but it can be different for some platforms. Hence, introduce the macro PLAT_ARM_SPMC_MANIFEST_BASE that could be re-defined by platform as per their use-case. Platforms that utilize arm_def.h would use the existing value from arm common code. Signed-off-by: Rakshit Goyal Change-Id: I4491749ad2b5794e06c9bd11ff61e2e64f21a948 --- include/plat/arm/common/arm_def.h | 17 ++++++++++++++++- plat/arm/common/arm_bl31_setup.c | 11 ++--------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/include/plat/arm/common/arm_def.h b/include/plat/arm/common/arm_def.h index ec5f90bf1..3ce6a91dd 100644 --- a/include/plat/arm/common/arm_def.h +++ b/include/plat/arm/common/arm_def.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2024, Arm Limited and Contributors. All rights reserved. + * Copyright (c) 2015-2025, Arm Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -753,6 +753,21 @@ MEASURED_BOOT # endif /* defined(SPD_none) && !SPM_MM || !SPMC_AT_EL3 */ #endif /* defined(__aarch64__) && !JUNO_AARCH32_EL3_RUNTIME */ +#if RESET_TO_BL31 && defined(SPD_spmd) && defined(PLAT_ARM_SPMC_MANIFEST_BASE) +#define ARM_SPMC_MANIFEST_BASE PLAT_ARM_SPMC_MANIFEST_BASE +#else + +/* + * SPM expects SPM Core manifest base address in x0, which in !RESET_TO_BL31 + * case loaded after base of non shared SRAM(after 4KB offset of SRAM). But in + * RESET_TO_BL31 case all non shared SRAM is allocated to BL31, so to avoid + * overwriting of manifest keep it in the last page. + */ +#define ARM_SPMC_MANIFEST_BASE (ARM_TRUSTED_SRAM_BASE + \ + PLAT_ARM_TRUSTED_SRAM_SIZE -\ + PAGE_SIZE) +#endif + /******************************************************************************* * FWU Images: NS_BL1U, BL2U & NS_BL2U defines. ******************************************************************************/ diff --git a/plat/arm/common/arm_bl31_setup.c b/plat/arm/common/arm_bl31_setup.c index 478799512..ce1545f5e 100644 --- a/plat/arm/common/arm_bl31_setup.c +++ b/plat/arm/common/arm_bl31_setup.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2024, Arm Limited and Contributors. All rights reserved. + * Copyright (c) 2015-2025, Arm Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -210,14 +210,7 @@ void __init arm_bl31_early_platform_setup(void *from_bl2, uintptr_t soc_fw_confi bl32_image_ep_info.spsr = arm_get_spsr_for_bl32_entry(); #if defined(SPD_spmd) - /* SPM (hafnium in secure world) expects SPM Core manifest base address - * in x0, which in !RESET_TO_BL31 case loaded after base of non shared - * SRAM(after 4KB offset of SRAM). But in RESET_TO_BL31 case all non - * shared SRAM is allocated to BL31, so to avoid overwriting of manifest - * keep it in the last page. - */ - bl32_image_ep_info.args.arg0 = ARM_TRUSTED_SRAM_BASE + - PLAT_ARM_TRUSTED_SRAM_SIZE - PAGE_SIZE; + bl32_image_ep_info.args.arg0 = ARM_SPMC_MANIFEST_BASE; #endif # endif /* BL32_BASE */