diff options
-rw-r--r-- | platform/include/tfm_spm_hal.h | 21 | ||||
-rw-r--r-- | secure_fw/spm/cmsis_psa/spm_ipc.c | 14 | ||||
-rw-r--r-- | secure_fw/spm/cmsis_psa/spm_ipc.h | 10 | ||||
-rw-r--r-- | secure_fw/spm/cmsis_psa/tfm_spm_db_ipc.inc.template | 48 |
4 files changed, 29 insertions, 64 deletions
diff --git a/platform/include/tfm_spm_hal.h b/platform/include/tfm_spm_hal.h index 7aaafeba6b..11da3c9aa5 100644 --- a/platform/include/tfm_spm_hal.h +++ b/platform/include/tfm_spm_hal.h @@ -37,27 +37,6 @@ enum irq_target_state_t { TFM_IRQ_TARGET_STATE_NON_SECURE, }; -#ifdef TFM_PSA_API -/** - * \brief Holds SPM db fields that define the memory regions used by a - * partition. - */ -struct tfm_spm_partition_memory_data_t -{ -#if TFM_LVL == 3 - uint32_t data_start; /* Start of the private data region of current - * partition. Specifically, the private data - * includes RW, ZI and the partition stack below. - */ - uint32_t data_limit; /* Address of the byte beyond the end of the data - * region of this partition. - */ -#endif - uint32_t stack_bottom; /* The bottom of the stack for the partition. */ - uint32_t stack_top; /* The top of the stack for the partition. */ -}; -#endif - #ifdef TFM_FIH_PROFILE_ON #ifdef CONFIG_TFM_ENABLE_MEMORY_PROTECT /** diff --git a/secure_fw/spm/cmsis_psa/spm_ipc.c b/secure_fw/spm/cmsis_psa/spm_ipc.c index 3c20fedeaa..65b1bd72f5 100644 --- a/secure_fw/spm/cmsis_psa/spm_ipc.c +++ b/secure_fw/spm/cmsis_psa/spm_ipc.c @@ -659,7 +659,6 @@ uint32_t tfm_spm_init(void) /* Skip NULL checking on statically reserved arraries. */ partition->p_static = &static_data_list[i]; - partition->memory_data = &memory_data_list[i]; if (!(partition->p_static->flags & SPM_PART_FLAG_IPC)) { tfm_core_panic(); @@ -722,8 +721,9 @@ uint32_t tfm_spm_init(void) tfm_core_thrd_init(pth, (tfm_core_thrd_entry_t)partition->p_static->entry, NULL, - (uintptr_t)partition->memory_data->stack_top, - (uintptr_t)partition->memory_data->stack_bottom); + (uintptr_t)(partition->p_static->stack_base_addr + + partition->p_static->stack_size), + (uintptr_t)partition->p_static->stack_base_addr); pth->prior = partition->p_static->priority; @@ -819,15 +819,15 @@ void tfm_pendsv_do_schedule(struct tfm_arch_ctx_t *p_actx) /* FIXME: only MPU-based implementations are supported currently */ #ifdef TFM_FIH_PROFILE_ON FIH_CALL(tfm_hal_mpu_update_partition_boundary, fih_rc, - p_next_partition->memory_data->data_start, - p_next_partition->memory_data->data_limit); + p_next_partition->p_static->mems.start, + p_next_partition->p_static->mems.limit); if (fih_not_eq(fih_rc, fih_int_encode(TFM_HAL_SUCCESS))) { tfm_core_panic(); } #else /* TFM_FIH_PROFILE_ON */ if (tfm_hal_mpu_update_partition_boundary( - p_next_partition->memory_data->data_start, - p_next_partition->memory_data->data_limit) + p_next_partition->p_static->mems.start, + p_next_partition->p_static->mems.limit) != TFM_HAL_SUCCESS) { tfm_core_panic(); } diff --git a/secure_fw/spm/cmsis_psa/spm_ipc.h b/secure_fw/spm/cmsis_psa/spm_ipc.h index d83b7db1e6..332098003d 100644 --- a/secure_fw/spm/cmsis_psa/spm_ipc.h +++ b/secure_fw/spm/cmsis_psa/spm_ipc.h @@ -97,6 +97,11 @@ struct tfm_msg_body_t { struct bi_list_node_t msg_node; /* For list operators */ }; +struct partition_memory_t { + uintptr_t start; + uintptr_t limit; +}; + /** * Holds the fields of the partition DB used by the SPM code. The values of * these fields are calculated at compile time, and set during initialisation @@ -115,6 +120,9 @@ struct partition_static_t { uintptr_t platform_data; /* Platform specific data */ uint32_t ndeps; /* Numbers of depended services */ uint32_t *deps; /* Pointer to dependency arrays */ +#if TFM_LVL == 3 + struct partition_memory_t mems; /* Partition memories */ +#endif }; /** @@ -132,8 +140,6 @@ struct partition_t { uint32_t signals_allowed; uint32_t signals_waiting; uint32_t signals_asserted; - /** A list of platform_data pointers */ - const struct tfm_spm_partition_memory_data_t *memory_data; }; struct spm_partition_db_t { diff --git a/secure_fw/spm/cmsis_psa/tfm_spm_db_ipc.inc.template b/secure_fw/spm/cmsis_psa/tfm_spm_db_ipc.inc.template index b2e1308816..ad9e8a1d9c 100644 --- a/secure_fw/spm/cmsis_psa/tfm_spm_db_ipc.inc.template +++ b/secure_fw/spm/cmsis_psa/tfm_spm_db_ipc.inc.template @@ -140,8 +140,14 @@ const struct partition_static_t static_data_list[] = #endif .priority = TFM_PRIORITY_LOW, .entry = tfm_nspm_thread_entry, - .stack_base_addr = 0, - .stack_size = 0 + .stack_base_addr = PART_REGION_ADDR(ARM_LIB_STACK, $$ZI$$Base), + .stack_size = S_PSP_STACK_SIZE, +#if TFM_LVL == 3 + .mems = { + .start = PART_REGION_ADDR(ARM_LIB_STACK, $$ZI$$Base), + .limit = PART_REGION_ADDR(ARM_LIB_STACK, $$ZI$$Limit), + }, +#endif }, {% for partition in partitions %} @@ -172,8 +178,8 @@ const struct partition_static_t static_data_list[] = , .priority = TFM_PRIORITY({{partition.manifest.priority}}), .entry = {{partition.manifest.entry_point}}, - .stack_base_addr = 0, - .stack_size = 0, + .stack_base_addr = (uint32_t){{partition.manifest.name.lower()}}_stack, + .stack_size = (uint32_t){{partition.manifest.stack_size}}, {% if partition.manifest.mmio_regions %} .platform_data = (uintptr_t)platform_data_list_{{partition.manifest.name}}, {% else %}{# if partition.manifest.mmio_regions #} @@ -185,38 +191,12 @@ const struct partition_static_t static_data_list[] = {% else %} .deps = NULL, {% endif %} - {{'},'}} - {% if partition.attr.conditional %} -#endif /* {{partition.attr.conditional}} */ - {% endif %} - -{% endfor %} -}; - -/**************************************************************************/ -/** The memory data of the partition list */ -/**************************************************************************/ -const struct tfm_spm_partition_memory_data_t memory_data_list[] = -{ - { -#if TFM_LVL == 3 - .data_start = PART_REGION_ADDR(ARM_LIB_STACK, $$ZI$$Base), - .data_limit = PART_REGION_ADDR(ARM_LIB_STACK, $$ZI$$Limit), -#endif - .stack_bottom = PART_REGION_ADDR(ARM_LIB_STACK, $$ZI$$Base), - .stack_top = PART_REGION_ADDR(ARM_LIB_STACK, $$ZI$$Limit), - }, -{% for partition in partitions %} - {% if partition.attr.conditional %} -#ifdef {{partition.attr.conditional}} - {% endif %} - {{'{'}} #if TFM_LVL == 3 - .data_start = PART_REGION_ADDR(PT_{{partition.manifest.name}}_PRIVATE, _DATA_START$$Base), - .data_limit = PART_REGION_ADDR(PT_{{partition.manifest.name}}_PRIVATE, _DATA_END$$Base), + .mems = { + .start = PART_REGION_ADDR(PT_{{partition.manifest.name}}_PRIVATE, _DATA_START$$Base), + .limit = PART_REGION_ADDR(PT_{{partition.manifest.name}}_PRIVATE, _DATA_END$$Base), + }, #endif - .stack_bottom = (uint32_t){{partition.manifest.name.lower()}}_stack, - .stack_top = (uint32_t)({{partition.manifest.name.lower()}}_stack + {{partition.manifest.stack_size}}), {{'},'}} {% if partition.attr.conditional %} #endif /* {{partition.attr.conditional}} */ |