Arch: Abstract PSPLIM setting
Add tfm_core_arch_set_psplim() to abstract PSPLIM setting.
Implement tfm_core_arch_set_psplim() on Armv8-M.
Change-Id: Ia23c8bb4e5b8c985dffaaa8bb8a7b4b485608be9
Signed-off-by: David Hu <david.hu@arm.com>
diff --git a/secure_fw/core/arch/include/tfm_arch_v8m.h b/secure_fw/core/arch/include/tfm_arch_v8m.h
index f0c4bca..03af669 100644
--- a/secure_fw/core/arch/include/tfm_arch_v8m.h
+++ b/secure_fw/core/arch/include/tfm_arch_v8m.h
@@ -76,4 +76,14 @@
return (lr & EXC_RETURN_SECURE_STACK);
}
+/**
+ * \brief Set PSPLIM register.
+ *
+ * \param[in] psplim Register value to be written into PSPLIM.
+ */
+__STATIC_INLINE void tfm_arch_set_psplim(uint32_t psplim)
+{
+ (void)__set_PSPLIM(psplim);
+}
+
#endif
diff --git a/secure_fw/core/tfm_core.c b/secure_fw/core/tfm_core.c
index e51f280..5ba4585 100644
--- a/secure_fw/core/tfm_core.c
+++ b/secure_fw/core/tfm_core.c
@@ -199,7 +199,7 @@
REGION_DECLARE(Image$$, ARM_LIB_STACK, $$ZI$$Base)[];
uint32_t psp_stack_bottom = (uint32_t)REGION_NAME(Image$$, ARM_LIB_STACK, $$ZI$$Base);
- __set_PSPLIM(psp_stack_bottom);
+ tfm_arch_set_psplim(psp_stack_bottom);
if (tfm_spm_partition_init() != SPM_ERR_OK) {
/* Certain systems might refuse to boot altogether if partitions fail
diff --git a/secure_fw/core/tfm_func_api.c b/secure_fw/core/tfm_func_api.c
index 5620525..0f875c4 100644
--- a/secure_fw/core/tfm_func_api.c
+++ b/secure_fw/core/tfm_func_api.c
@@ -367,7 +367,7 @@
(uint32_t *)partition_psp);
}
__set_PSP(psp);
- __set_PSPLIM(partition_psplim);
+ tfm_arch_set_psplim(partition_psplim);
}
#else
if (desc_ptr->iovec_api == TFM_SFN_API_IOVEC) {
@@ -395,7 +395,7 @@
(uint32_t *)partition_psp);
}
__set_PSP(psp);
- __set_PSPLIM(partition_psplim);
+ tfm_arch_set_psplim(partition_psplim);
#endif
tfm_spm_partition_set_state(caller_partition_idx,
@@ -480,7 +480,7 @@
__set_PSP(ret_part_data->stack_ptr);
REGION_DECLARE(Image$$, ARM_LIB_STACK, $$ZI$$Base)[];
uint32_t psp_stack_bottom = (uint32_t)REGION_NAME(Image$$, ARM_LIB_STACK, $$ZI$$Base);
- __set_PSPLIM(psp_stack_bottom);
+ tfm_arch_set_psplim(psp_stack_bottom);
/* FIXME: The condition should be removed once all the secure service
* calls are done via the iovec veneers
@@ -502,7 +502,8 @@
(struct tfm_exc_stack_t *)ret_part_data->stack_ptr);
*excReturn = ret_part_data->lr;
__set_PSP(ret_part_data->stack_ptr);
- __set_PSPLIM(tfm_spm_partition_get_stack_bottom(return_partition_idx));
+ tfm_arch_set_psplim(
+ tfm_spm_partition_get_stack_bottom(return_partition_idx));
/* Clear the context entry before returning */
tfm_spm_partition_set_stack(
current_partition_idx, psp + sizeof(struct tfm_exc_stack_t));