aboutsummaryrefslogtreecommitdiff
path: root/secure_fw
diff options
context:
space:
mode:
authorMingyang Sun <mingyang.sun@arm.com>2021-06-04 17:49:56 +0800
committerKen Liu <ken.liu@arm.com>2021-06-08 08:47:39 +0200
commit61f8fbc280ebb103ac48ecda84dd2ef77852dc69 (patch)
treea5528bd664e95cee7175a6673ee9e09dfb2751fd /secure_fw
parent327bc844621fe6d6702c55479e35348c6c8bfa11 (diff)
downloadtrusted-firmware-m-61f8fbc280ebb103ac48ecda84dd2ef77852dc69.tar.gz
HAL: Replace the 'idx' input param with 'privileged'
In tfm_spm_hal_configure_default_isolation(), a partition index is passed in to query the partition privilege. Change to pass in privilege directly instead of the partition index. Change-Id: Id046431cc8e224a94e83a71564ba2843fabf8ed7 Signed-off-by: Mingyang Sun <mingyang.sun@arm.com>
Diffstat (limited to 'secure_fw')
-rw-r--r--secure_fw/spm/cmsis_func/spm_func.c12
-rw-r--r--secure_fw/spm/cmsis_psa/spm_ipc.c28
-rw-r--r--secure_fw/spm/include/tfm_platform_core_api.h9
3 files changed, 23 insertions, 26 deletions
diff --git a/secure_fw/spm/cmsis_func/spm_func.c b/secure_fw/spm/cmsis_func/spm_func.c
index 1144b441c..62e006013 100644
--- a/secure_fw/spm/cmsis_func/spm_func.c
+++ b/secure_fw/spm/cmsis_func/spm_func.c
@@ -1224,6 +1224,7 @@ fih_int tfm_spm_partition_init(void)
int32_t args[4] = {0};
fih_int fail_cnt = FIH_INT_INIT(0);
uint32_t idx;
+ bool privileged;
const struct platform_data_t **platform_data_p;
#ifdef TFM_FIH_PROFILE_ON
fih_int fih_rc = FIH_FAILURE;
@@ -1235,14 +1236,19 @@ fih_int tfm_spm_partition_init(void)
platform_data_p = part->platform_data_list;
if (platform_data_p != NULL) {
while ((*platform_data_p) != NULL) {
+ if (tfm_is_partition_privileged(idx)) {
+ privileged = true;
+ } else {
+ privileged = false;
+ }
#ifdef TFM_FIH_PROFILE_ON
- FIH_CALL(tfm_spm_hal_configure_default_isolation, fih_rc, idx,
- *platform_data_p);
+ FIH_CALL(tfm_spm_hal_configure_default_isolation, fih_rc,
+ privileged, *platform_data_p);
if (fih_not_eq(fih_rc, fih_int_encode(TFM_PLAT_ERR_SUCCESS))) {
fail_cnt = fih_int_encode(fih_int_decode(fail_cnt) + 1);
}
#else /* TFM_FIH_PROFILE_ON */
- if (tfm_spm_hal_configure_default_isolation(idx,
+ if (tfm_spm_hal_configure_default_isolation(privileged,
*platform_data_p) != TFM_PLAT_ERR_SUCCESS) {
fail_cnt++;
}
diff --git a/secure_fw/spm/cmsis_psa/spm_ipc.c b/secure_fw/spm/cmsis_psa/spm_ipc.c
index d8d90607d..b657d4e7d 100644
--- a/secure_fw/spm/cmsis_psa/spm_ipc.c
+++ b/secure_fw/spm/cmsis_psa/spm_ipc.c
@@ -334,14 +334,6 @@ uint32_t tfm_spm_partition_get_privileged_mode(uint32_t partition_flags)
}
}
-bool tfm_is_partition_privileged(uint32_t partition_idx)
-{
- uint32_t flags = tfm_spm_partition_get_flags(partition_idx);
-
- return tfm_spm_partition_get_privileged_mode(flags) ==
- TFM_PARTITION_PRIVILEGED_MODE;
-}
-
struct service_t *tfm_spm_get_service_by_sid(uint32_t sid)
{
struct service_t *p_serv = connection_services_listhead;
@@ -643,7 +635,8 @@ int32_t tfm_memory_check(const void *buffer, size_t len, bool ns_caller,
uint32_t tfm_spm_init(void)
{
- uint32_t i, j, part_idx = 0;
+ uint32_t i, j;
+ bool privileged;
struct partition_t *partition;
struct tfm_core_thread_t *pth, *p_ns_entry_thread = NULL;
const struct platform_data_t *platform_data_p;
@@ -671,6 +664,15 @@ uint32_t tfm_spm_init(void)
p_cmninf = partition->p_ldinf;
/* Init mmio assets */
+ if (p_cmninf->nassets > 0) {
+ if (tfm_spm_partition_get_privileged_mode(p_cmninf->flags) ==
+ TFM_PARTITION_PRIVILEGED_MODE) {
+ privileged = true;
+ } else {
+ privileged = false;
+ }
+ }
+
p_asset_load = (struct asset_desc_t *)LOAD_INFO_ASSET(p_cmninf);
for (i = 0; i < p_cmninf->nassets; i++) {
/* Skip the memory-based asset */
@@ -696,13 +698,13 @@ uint32_t tfm_spm_init(void)
}
#ifdef TFM_FIH_PROFILE_ON
- FIH_CALL(tfm_spm_hal_configure_default_isolation, fih_rc, part_idx,
- platform_data_p);
+ FIH_CALL(tfm_spm_hal_configure_default_isolation, fih_rc,
+ privileged, platform_data_p);
if (fih_not_eq(fih_rc, fih_int_encode(TFM_PLAT_ERR_SUCCESS))) {
tfm_core_panic();
}
#else /* TFM_FIH_PROFILE_ON */
- if (tfm_spm_hal_configure_default_isolation(part_idx,
+ if (tfm_spm_hal_configure_default_isolation(privileged,
platform_data_p) != TFM_PLAT_ERR_SUCCESS) {
tfm_core_panic();
}
@@ -755,8 +757,6 @@ uint32_t tfm_spm_init(void)
if (tfm_core_thrd_start(pth) != THRD_SUCCESS) {
tfm_core_panic();
}
-
- part_idx++;
}
/*
diff --git a/secure_fw/spm/include/tfm_platform_core_api.h b/secure_fw/spm/include/tfm_platform_core_api.h
index f79190b24..de532549e 100644
--- a/secure_fw/spm/include/tfm_platform_core_api.h
+++ b/secure_fw/spm/include/tfm_platform_core_api.h
@@ -23,13 +23,4 @@
*/
void tfm_access_violation_handler(void);
-/**
- * \brief Return whether a secure partition is privileged.
- *
- * \param[in] partition_idx The index of the partition in the partition_list.
- *
- * \return True if the partition is privileged, false otherwise.
- */
-bool tfm_is_partition_privileged(uint32_t partition_idx);
-
#endif /* __TFM_PLATFORM_CORE_API_H__ */