From 9ce15fe8910580efca46b9f102e117402ce769db Mon Sep 17 00:00:00 2001 From: Imre Kis Date: Wed, 9 Feb 2022 16:33:07 +0100 Subject: [PATCH] fix(plat/arm): fix SP count limit without dual root CoT Remove reserved range for platform provider owned SPs if the dual root CoT is disabled and allow SPs to populate the range up to MAX_SP_IDS. Signed-off-by: Imre Kis Change-Id: Ib4ec18f6530d2515ada21d2c0c388d55aa479d26 --- plat/arm/common/fconf/arm_fconf_sp.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/plat/arm/common/fconf/arm_fconf_sp.c b/plat/arm/common/fconf/arm_fconf_sp.c index 95e08730c..18c83c795 100644 --- a/plat/arm/common/fconf/arm_fconf_sp.c +++ b/plat/arm/common/fconf/arm_fconf_sp.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2020-2022, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -30,13 +30,16 @@ int fconf_populate_arm_sp(uintptr_t config) union uuid_helper_t uuid_helper; unsigned int index = 0; uint32_t val32; - bool is_plat_owned = false; const unsigned int sip_start = SP_PKG1_ID; unsigned int sip_index = sip_start; +#if defined(ARM_COT_dualroot) const unsigned int sip_end = sip_start + MAX_SP_IDS / 2; + /* Allocating index range for platform SPs */ const unsigned int plat_start = SP_PKG5_ID; unsigned int plat_index = plat_start; const unsigned int plat_end = plat_start + MAX_SP_IDS / 2; + bool is_plat_owned = false; +#endif /* ARM_COT_dualroot */ /* As libfdt use void *, we can't avoid this cast */ const void *dtb = (void *)config; @@ -51,12 +54,18 @@ int fconf_populate_arm_sp(uintptr_t config) } fdt_for_each_subnode(sp_node, dtb, node) { - if ((index == MAX_SP_IDS) || (sip_index == sip_end) - || (plat_index == plat_end)) { + if (index == MAX_SP_IDS) { ERROR("FCONF: Reached max number of SPs\n"); return -1; } +#if defined(ARM_COT_dualroot) + if ((sip_index == sip_end) || (plat_index == plat_end)) { + ERROR("FCONF: Reached max number of plat/SiP SPs\n"); + return -1; + } +#endif /* ARM_COT_dualroot */ + /* Read UUID */ err = fdtw_read_uuid(dtb, sp_node, "uuid", 16, (uint8_t *)&uuid_helper); @@ -96,7 +105,7 @@ int fconf_populate_arm_sp(uintptr_t config) /* Owner is an optional field, no need to catch error */ fdtw_read_string(dtb, sp_node, "owner", arm_sp.owner[index], ARM_SP_OWNER_NAME_LEN); -#endif + /* If owner is empty mark it as SiP owned */ if ((strncmp(arm_sp.owner[index], "SiP", ARM_SP_OWNER_NAME_LEN) == 0) || @@ -121,7 +130,9 @@ int fconf_populate_arm_sp(uintptr_t config) policies[plat_index].dev_handle = &fip_dev_handle; policies[plat_index].check = open_fip; plat_index++; - } else { + } else +#endif /* ARM_COT_dualroot */ + { sp_mem_params_descs[index].image_id = sip_index; policies[sip_index].image_spec = (uintptr_t)&arm_sp.uuids[index];