aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManish Pandey <manish.pandey2@arm.com>2020-02-25 11:38:19 +0000
committerManish Pandey <manish.pandey2@arm.com>2020-03-04 14:02:31 +0000
commitcb3b534457f38c302ebef9f0b2555ffa8c549b65 (patch)
tree746d912978e2fc083d8a911504f6a59cf643487c
parent8f066f6167f47a29a46e66d1210f5afbf94a8c40 (diff)
downloadplatform_external_arm-trusted-firmware-cb3b534457f38c302ebef9f0b2555ffa8c549b65.tar.gz
platform_external_arm-trusted-firmware-cb3b534457f38c302ebef9f0b2555ffa8c549b65.tar.bz2
platform_external_arm-trusted-firmware-cb3b534457f38c302ebef9f0b2555ffa8c549b65.zip
SPMD: loading Secure Partition payloads
This patch implements loading of Secure Partition packages using existing framework of loading other bl images. The current framework uses a statically defined array to store all the possible image types and at run time generates a link list and traverse through it to load different images. To load SPs, a new array of fixed size is introduced which will be dynamically populated based on number of SPs available in the system and it will be appended to the loadable images list. Change-Id: I8309f63595f2a71b28a73b922d20ccba9c4f6ae4 Signed-off-by: Manish Pandey <manish.pandey2@arm.com>
-rw-r--r--include/plat/arm/common/fconf_arm_sp_getter.h4
-rw-r--r--plat/arm/common/arm_bl2_setup.c7
-rw-r--r--plat/arm/common/arm_image_load.c55
-rw-r--r--plat/arm/common/fconf/arm_fconf_sp.c37
4 files changed, 95 insertions, 8 deletions
diff --git a/include/plat/arm/common/fconf_arm_sp_getter.h b/include/plat/arm/common/fconf_arm_sp_getter.h
index 57fd92edf..38c30fbf9 100644
--- a/include/plat/arm/common/fconf_arm_sp_getter.h
+++ b/include/plat/arm/common/fconf_arm_sp_getter.h
@@ -13,6 +13,8 @@
/* arm_sp getter */
#define arm__sp_getter(prop) arm_sp.prop
+#define ARM_SP_MAX_SIZE U(0x10000)
+
struct arm_sp_t {
unsigned int number_of_sp;
union uuid_helper_t uuids[MAX_SP_IDS];
@@ -23,4 +25,6 @@ int fconf_populate_arm_sp(uintptr_t config);
extern struct arm_sp_t arm_sp;
+extern bl_mem_params_node_t sp_mem_params_descs[MAX_SP_IDS];
+
#endif /* FCONF_ARM_SP_GETTER_H */
diff --git a/plat/arm/common/arm_bl2_setup.c b/plat/arm/common/arm_bl2_setup.c
index dd392085d..136e65a1f 100644
--- a/plat/arm/common/arm_bl2_setup.c
+++ b/plat/arm/common/arm_bl2_setup.c
@@ -205,6 +205,13 @@ int arm_bl2_handle_post_image_load(unsigned int image_id)
******************************************************************************/
int arm_bl2_plat_handle_post_image_load(unsigned int image_id)
{
+#if defined(SPD_spmd)
+ /* For Secure Partitions we don't need post processing */
+ if ((image_id >= (MAX_NUMBER_IDS - MAX_SP_IDS)) &&
+ (image_id < MAX_NUMBER_IDS)) {
+ return 0;
+ }
+#endif
return arm_bl2_handle_post_image_load(image_id);
}
diff --git a/plat/arm/common/arm_image_load.c b/plat/arm/common/arm_image_load.c
index 2faaa76c4..593199d46 100644
--- a/plat/arm/common/arm_image_load.c
+++ b/plat/arm/common/arm_image_load.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016-2018, ARM Limited and Contributors. All rights reserved.
+ * Copyright (c) 2016-2020, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@@ -7,6 +7,9 @@
#include <assert.h>
#include <common/bl_common.h>
#include <common/desc_image_load.h>
+#if defined(SPD_spmd)
+#include <plat/arm/common/fconf_arm_sp_getter.h>
+#endif
#include <plat/arm/common/plat_arm.h>
#include <plat/common/platform.h>
@@ -29,12 +32,62 @@ void plat_flush_next_bl_params(void)
next_bl_params_cpy_ptr);
}
+#if defined(SPD_spmd)
+/*******************************************************************************
+ * This function appends Secure Partitions to list of loadable images.
+ ******************************************************************************/
+void plat_add_sp_images_load_info(struct bl_load_info *load_info)
+{
+ bl_load_info_node_t *node_info = load_info->head;
+ unsigned int index = 0;
+
+ if (sp_mem_params_descs[index].image_id == 0) {
+ ERROR("No Secure Partition Image available\n");
+ return;
+ }
+
+ /* Traverse through the bl images list */
+ do {
+ node_info = node_info->next_load_info;
+ } while (node_info->next_load_info != NULL);
+
+ for (; index < MAX_SP_IDS; index++) {
+ /* Populate the image information */
+ node_info->image_id = sp_mem_params_descs[index].image_id;
+ node_info->image_info = &sp_mem_params_descs[index].image_info;
+
+ if ((index + 1U) == MAX_SP_IDS) {
+ INFO("Reached Max number of SPs\n");
+ return;
+ }
+
+ if (sp_mem_params_descs[index + 1U].image_id == 0) {
+ return;
+ }
+
+ node_info->next_load_info =
+ &sp_mem_params_descs[index + 1U].load_node_mem;
+ node_info = node_info->next_load_info;
+
+ }
+}
+#endif
+
/*******************************************************************************
* This function returns the list of loadable images.
******************************************************************************/
struct bl_load_info *plat_get_bl_image_load_info(void)
{
+#if defined(SPD_spmd)
+ bl_load_info_t *bl_load_info;
+
+ bl_load_info = get_bl_load_info_from_mem_params_desc();
+ plat_add_sp_images_load_info(bl_load_info);
+
+ return bl_load_info;
+#else
return get_bl_load_info_from_mem_params_desc();
+#endif
}
/*******************************************************************************
diff --git a/plat/arm/common/fconf/arm_fconf_sp.c b/plat/arm/common/fconf/arm_fconf_sp.c
index 0e5cfff95..bb88aff6f 100644
--- a/plat/arm/common/fconf/arm_fconf_sp.c
+++ b/plat/arm/common/fconf/arm_fconf_sp.c
@@ -7,6 +7,7 @@
#include <assert.h>
#include <common/debug.h>
+#include <common/desc_image_load.h>
#include <common/fdt_wrappers.h>
#include <drivers/io/io_storage.h>
#include <lib/object_pool.h>
@@ -19,12 +20,16 @@
#ifdef IMAGE_BL2
+bl_mem_params_node_t sp_mem_params_descs[MAX_SP_IDS];
+
struct arm_sp_t arm_sp;
int fconf_populate_arm_sp(uintptr_t config)
{
int sp_node, node, err;
union uuid_helper_t uuid_helper;
+ unsigned int index = 0;
+ const unsigned int sp_start_index = MAX_NUMBER_IDS - MAX_SP_IDS;
/* As libfdt use void *, we can't avoid this cast */
const void *dtb = (void *)config;
@@ -46,10 +51,10 @@ int fconf_populate_arm_sp(uintptr_t config)
return -1;
}
- arm_sp.uuids[arm_sp.number_of_sp] = uuid_helper;
+ arm_sp.uuids[index] = uuid_helper;
err = fdtw_read_cells(dtb, sp_node, "load-address", 1,
- &arm_sp.load_addr[arm_sp.number_of_sp]);
+ &arm_sp.load_addr[index]);
if (err < 0) {
ERROR("FCONF: cannot read SP load address\n");
return -1;
@@ -61,11 +66,28 @@ int fconf_populate_arm_sp(uintptr_t config)
uuid_helper.word[1],
uuid_helper.word[2],
uuid_helper.word[3],
- arm_sp.load_addr[arm_sp.number_of_sp]);
-
- arm_sp.number_of_sp++;
-
- if (arm_sp.number_of_sp >= MAX_SP_IDS) {
+ arm_sp.load_addr[index]);
+
+ /* Add SP information in mem param descriptor */
+ sp_mem_params_descs[index].image_id = sp_start_index + index;
+ SET_PARAM_HEAD(&sp_mem_params_descs[index].image_info,
+ PARAM_IMAGE_BINARY, VERSION_2, 0);
+ sp_mem_params_descs[index].image_info.image_max_size =
+ ARM_SP_MAX_SIZE;
+ sp_mem_params_descs[index].next_handoff_image_id =
+ INVALID_IMAGE_ID;
+ sp_mem_params_descs[index].image_info.image_base =
+ arm_sp.load_addr[index];
+
+ /* Add SP information in IO policies structure */
+ policies[sp_start_index + index].image_spec =
+ (uintptr_t)&arm_sp.uuids[index];
+ policies[sp_start_index + index].dev_handle = &fip_dev_handle;
+ policies[sp_start_index + index].check = open_fip;
+
+ index++;
+
+ if (index >= MAX_SP_IDS) {
ERROR("FCONF: reached max number of SPs\n");
return -1;
}
@@ -76,6 +98,7 @@ int fconf_populate_arm_sp(uintptr_t config)
return sp_node;
}
+ arm_sp.number_of_sp = index;
return 0;
}