From 1a0ebff784c11f0b11f203b56eeb3180f994c0b9 Mon Sep 17 00:00:00 2001 From: Harrison Mutai Date: Thu, 2 May 2024 12:40:20 +0000 Subject: [PATCH] feat(arm): add fw handoff support for RESET_TO_BL31 Change-Id: I78f3c5606f0221bb5fc613a973a7d3fe187db35b Signed-off-by: Harrison Mutai --- plat/arm/board/fvp/fvp_common.c | 2 +- plat/arm/board/fvp/platform.mk | 15 +++++++++++---- plat/arm/common/arm_bl31_setup.c | 21 ++++++++++++++++++++- plat/arm/common/arm_common.mk | 14 ++++++++++++++ 4 files changed, 46 insertions(+), 6 deletions(-) diff --git a/plat/arm/board/fvp/fvp_common.c b/plat/arm/board/fvp/fvp_common.c index 9dc47c959..0c5a76cca 100644 --- a/plat/arm/board/fvp/fvp_common.c +++ b/plat/arm/board/fvp/fvp_common.c @@ -210,7 +210,7 @@ const mmap_region_t plat_arm_mmap[] = { #ifdef MAP_FW_NS_HANDOFF MAP_FW_NS_HANDOFF, #endif -#ifdef MAP_EL3_FW_HANDOFF +#if defined(MAP_EL3_FW_HANDOFF) && !RESET_TO_BL31 MAP_EL3_FW_HANDOFF, #endif { 0 } diff --git a/plat/arm/board/fvp/platform.mk b/plat/arm/board/fvp/platform.mk index 6d6364607..cef7bdfcc 100644 --- a/plat/arm/board/fvp/platform.mk +++ b/plat/arm/board/fvp/platform.mk @@ -323,10 +323,6 @@ else BL31_SOURCES += drivers/delay_timer/generic_delay_timer.c endif -ifeq (${TRANSFER_LIST}, 1) -include lib/transfer_list/transfer_list.mk -endif - # Add the FDT_SOURCES and options for Dynamic Config (only for Unix env) ifdef UNIX_MK FVP_TB_FW_CONFIG := ${BUILD_PLAT}/fdts/${PLAT}_tb_fw_config.dtb @@ -386,6 +382,17 @@ $(eval $(call TOOL_ADD_PAYLOAD,${FVP_TB_FW_CONFIG},--tb-fw-config,${FVP_TB_FW_CO $(eval $(call TOOL_ADD_PAYLOAD,${FVP_HW_CONFIG},--hw-config,${FVP_HW_CONFIG})) endif +ifeq (${TRANSFER_LIST}, 1) +include lib/transfer_list/transfer_list.mk + +ifeq ($(RESET_TO_BL31), 1) +HW_CONFIG := ${FVP_HW_CONFIG} +FW_HANDOFF_SIZE := 20000 + +$(eval $(call add_define,ARM_PRELOADED_DTB_OFFSET)) +endif +endif + # Enable dynamic mitigation support by default DYNAMIC_WORKAROUND_CVE_2018_3639 := 1 diff --git a/plat/arm/common/arm_bl31_setup.c b/plat/arm/common/arm_bl31_setup.c index b7941ecdf..632e84c2d 100644 --- a/plat/arm/common/arm_bl31_setup.c +++ b/plat/arm/common/arm_bl31_setup.c @@ -128,6 +128,24 @@ struct entry_point_info *bl31_plat_get_next_image_ep_info(uint32_t type) void __init arm_bl31_early_platform_setup(u_register_t arg0, u_register_t arg1, u_register_t arg2, u_register_t arg3) { +#if RESET_TO_BL31 + /* Populate entry point information for BL33 */ + SET_PARAM_HEAD(&bl33_image_ep_info, PARAM_EP, VERSION_1, 0); + /* + * Tell BL31 where the non-trusted software image + * is located and the entry state information + */ + bl33_image_ep_info.pc = plat_get_ns_image_entrypoint(); + + bl33_image_ep_info.spsr = arm_get_spsr_for_bl33_entry(); + SET_SECURITY_STATE(bl33_image_ep_info.h.attr, NON_SECURE); + + bl33_image_ep_info.args.arg0 = + FW_NS_HANDOFF_BASE + ARM_PRELOADED_DTB_OFFSET; + bl33_image_ep_info.args.arg1 = TRANSFER_LIST_SIGNATURE | + REGISTER_CONVENTION_VERSION_MASK; + bl33_image_ep_info.args.arg3 = FW_NS_HANDOFF_BASE; +#else struct transfer_list_entry *te = NULL; struct entry_point_info *ep; @@ -160,6 +178,7 @@ void __init arm_bl31_early_platform_setup(u_register_t arg0, u_register_t arg1, } } } +#endif /* RESET_TO_BL31 */ } #else void __init arm_bl31_early_platform_setup(void *from_bl2, uintptr_t soc_fw_config, @@ -501,7 +520,7 @@ void __init bl31_plat_arch_setup(void) arm_bl31_plat_arch_setup(); -#if TRANSFER_LIST && !RESET_TO_BL2 +#if TRANSFER_LIST && !(RESET_TO_BL2 || RESET_TO_BL31) te = transfer_list_find(secure_tl, TL_TAG_FDT); assert(te != NULL); diff --git a/plat/arm/common/arm_common.mk b/plat/arm/common/arm_common.mk index f5919ab5e..2c1888d88 100644 --- a/plat/arm/common/arm_common.mk +++ b/plat/arm/common/arm_common.mk @@ -458,3 +458,17 @@ ifeq (${RECLAIM_INIT_CODE}, 1) $(error To reclaim init code xlat tables v2 must be used) endif endif + +TRANSFER_LIST_BIN := ${BUILD_PLAT}/tl.bin + +.PHONY: tl +tl: ${HW_CONFIG} + @echo " TLC ${TRANSFER_LIST_BIN}" + $(Q)${PYTHON} -m tools.tlc.tlc create --fdt ${HW_CONFIG} -s ${FW_HANDOFF_SIZE} ${TRANSFER_LIST_BIN} + $(Q)$(eval ARM_PRELOADED_DTB_OFFSET := `tlc info --fdt-offset ${TRANSFER_LIST_BIN}`) + +ifeq (${TRANSFER_LIST}, 1) + ifeq (${RESET_TO_BL31}, 1) + bl31: tl + endif +endif