refactor(arm): refactor secure TL initialization

The initialization logic for the secure transfer list is currently
scattered and duplicated across platform setup code. This not only leads
to inefficiency but also complicates access to transfer lists from other
parts of the code without invoking setup functions. For instance,
arm_bl2_setup_next_ep_info acts as a thin wrapper in arm_bl2_setup.c to
provide access to the secure transfer list.

To streamline the interface, all setup code has been consolidated into a
central location.

Change-Id: I99d2a567ff39df88baa57e7e08607fccb8af189c
Signed-off-by: Harrison Mutai <harrison.mutai@arm.com>
This commit is contained in:
Harrison Mutai 2024-09-23 11:15:12 +00:00
parent 24e1ae2f0e
commit d570571994
6 changed files with 22 additions and 31 deletions

View file

@ -427,6 +427,7 @@ void plat_arm_sp_min_early_platform_setup(u_register_t arg0, u_register_t arg1,
extern plat_psci_ops_t plat_arm_psci_pm_ops;
extern const mmap_region_t plat_arm_mmap[];
extern const unsigned int arm_pm_idle_states[];
extern struct transfer_list_header *secure_tl;
/* secure watchdog */
void plat_arm_secure_wdt_start(void);

View file

@ -48,8 +48,6 @@ static const arm_gpt_info_t arm_gpt_info = {
void bl2_early_platform_setup2(u_register_t arg0, u_register_t arg1, u_register_t arg2, u_register_t arg3)
{
struct transfer_list_entry *te __unused;
#if TRANSFER_LIST
arg0 = arg3;
#endif

View file

@ -64,9 +64,7 @@ static meminfo_t bl1_tzram_layout;
/* Boolean variable to hold condition whether firmware update needed or not */
static bool is_fwu_needed;
#if TRANSFER_LIST
static struct transfer_list_header *secure_tl;
#endif
struct transfer_list_header *secure_tl;
struct meminfo *bl1_plat_sec_mem_layout(void)
{
@ -90,6 +88,12 @@ void arm_bl1_early_platform_setup(void)
/* Allow BL1 to see the whole Trusted RAM */
bl1_tzram_layout.total_base = ARM_BL_RAM_BASE;
bl1_tzram_layout.total_size = ARM_BL_RAM_SIZE;
#if TRANSFER_LIST
secure_tl = transfer_list_ensure((void *)PLAT_ARM_EL3_FW_HANDOFF_BASE,
PLAT_ARM_FW_HANDOFF_SIZE);
assert(secure_tl != NULL);
#endif
}
void bl1_early_platform_setup(void)
@ -171,14 +175,6 @@ void arm_bl1_platform_setup(void)
}
#if TRANSFER_LIST
secure_tl = transfer_list_init((void *)PLAT_ARM_EL3_FW_HANDOFF_BASE,
PLAT_ARM_FW_HANDOFF_SIZE);
if (secure_tl == NULL) {
ERROR("Secure transfer list initialisation failed!\n");
panic();
}
te = transfer_list_add(secure_tl, TL_TAG_TB_FW_CONFIG,
ARM_TB_FW_CONFIG_MAX_SIZE, NULL);
assert(te != NULL);

View file

@ -66,8 +66,7 @@ CASSERT(BL2_BASE >= ARM_FW_CONFIG_LIMIT, assert_bl2_base_overflows);
#pragma weak arm_bl2_plat_handle_post_image_load
static struct transfer_list_header *secure_tl __unused;
static struct transfer_list_header *ns_tl __unused;
struct transfer_list_header *secure_tl __unused;
/*******************************************************************************
* BL1 has passed the extents of the trusted SRAM that should be visible to BL2
@ -129,15 +128,14 @@ void bl2_plat_preload_setup(void)
#if TRANSFER_LIST
/* Assume the secure TL hasn't been initialised if BL2 is running at EL3. */
#if RESET_TO_BL2
secure_tl = transfer_list_init((void *)PLAT_ARM_EL3_FW_HANDOFF_BASE,
PLAT_ARM_FW_HANDOFF_SIZE);
secure_tl = transfer_list_ensure((void *)PLAT_ARM_EL3_FW_HANDOFF_BASE,
PLAT_ARM_FW_HANDOFF_SIZE);
if (secure_tl == NULL) {
ERROR("Secure transfer list initialisation failed!\n");
panic();
}
#endif
arm_transfer_list_dyn_cfg_init(secure_tl);
#else
#if ARM_FW_CONFIG_LOAD_ENABLE

View file

@ -25,8 +25,8 @@
#include <plat/common/platform.h>
#include <platform_def.h>
static struct transfer_list_header *secure_tl __unused;
static struct transfer_list_header *ns_tl __unused;
struct transfer_list_header *secure_tl;
struct transfer_list_header *ns_tl __unused;
/*
* Placeholder variables for copying the arguments that have been passed to
@ -367,14 +367,13 @@ void arm_bl31_platform_setup(void)
struct transfer_list_entry *te __unused;
#if TRANSFER_LIST && !RESET_TO_BL31
ns_tl = transfer_list_init((void *)FW_NS_HANDOFF_BASE,
PLAT_ARM_FW_HANDOFF_SIZE);
ns_tl = transfer_list_ensure((void *)FW_NS_HANDOFF_BASE,
PLAT_ARM_FW_HANDOFF_SIZE);
if (ns_tl == NULL) {
ERROR("Non-secure transfer list initialisation failed!");
ERROR("Non-secure transfer list initialisation failed!\n");
panic();
}
/* BL31 may modify the HW_CONFIG so defer copying it until later. */
te = transfer_list_find(secure_tl, TL_TAG_FDT);
assert(te != NULL);

View file

@ -7,7 +7,7 @@
#include <plat/arm/common/plat_arm.h>
#include <platform_def.h>
void arm_transfer_list_dyn_cfg_init(struct transfer_list_header *secure_tl)
void arm_transfer_list_dyn_cfg_init(struct transfer_list_header *tl)
{
struct transfer_list_entry *te;
bl_mem_params_node_t *next_param_node =
@ -19,8 +19,7 @@ void arm_transfer_list_dyn_cfg_init(struct transfer_list_header *secure_tl)
* mechanism. Pre-allocate a TE for the configuration and update the
* load information so the configuration is loaded directly into the TE.
*/
te = transfer_list_add(secure_tl, TL_TAG_FDT, PLAT_ARM_HW_CONFIG_SIZE,
NULL);
te = transfer_list_add(tl, TL_TAG_FDT, PLAT_ARM_HW_CONFIG_SIZE, NULL);
assert(te != NULL);
next_param_node->image_info.h.attr &= ~IMAGE_ATTRIB_SKIP_LOADING;
@ -30,7 +29,7 @@ void arm_transfer_list_dyn_cfg_init(struct transfer_list_header *secure_tl)
}
void arm_transfer_list_populate_ep_info(bl_mem_params_node_t *next_param_node,
struct transfer_list_header *secure_tl)
struct transfer_list_header *tl)
{
uint32_t next_exe_img_id;
entry_point_info_t *ep;
@ -45,7 +44,7 @@ void arm_transfer_list_populate_ep_info(bl_mem_params_node_t *next_param_node,
next_exe_img_id)];
assert(next_param_node != NULL);
te = transfer_list_add(secure_tl, TL_TAG_EXEC_EP_INFO64,
te = transfer_list_add(tl, TL_TAG_EXEC_EP_INFO64,
sizeof(entry_point_info_t),
&next_param_node->ep_info);
assert(te != NULL);
@ -72,5 +71,5 @@ void arm_transfer_list_populate_ep_info(bl_mem_params_node_t *next_param_node,
next_exe_img_id = next_param_node->next_handoff_image_id;
}
flush_dcache_range((uintptr_t)secure_tl, secure_tl->size);
flush_dcache_range((uintptr_t)tl, tl->size);
}