Core: Remove the index member in runtime data structure
Remove the index member in runtime data structure to minimize
the memory usage. Refine the implementation of
tfm_spm_partition_get_privileged_mode by passing partition
flags instead of partition index.
Change-Id: I6d2bc92dccfb8fe79ca282e5648625ff6c780ef2
Signed-off-by: Summer Qin <summer.qin@arm.com>
diff --git a/secure_fw/core/ipc/tfm_svcalls.c b/secure_fw/core/ipc/tfm_svcalls.c
index 9a0fe75..2565b22 100644
--- a/secure_fw/core/ipc/tfm_svcalls.c
+++ b/secure_fw/core/ipc/tfm_svcalls.c
@@ -151,7 +151,7 @@
tfm_panic();
}
privileged = tfm_spm_partition_get_privileged_mode(
- partition->runtime_data.index);
+ partition->static_data->partition_flags);
if (!ns_caller) {
inptr = (psa_invec *)args[2];
@@ -423,7 +423,7 @@
tfm_panic();
}
privileged = tfm_spm_partition_get_privileged_mode(
- partition->runtime_data.index);
+ partition->static_data->partition_flags);
/*
* Write the message to the service buffer. It is a fatal error if the
@@ -554,7 +554,7 @@
partition = msg->service->partition;
privileged = tfm_spm_partition_get_privileged_mode(
- partition->runtime_data.index);
+ partition->static_data->partition_flags);
/*
* It is a fatal error if message handle does not refer to a request
@@ -711,7 +711,7 @@
partition = msg->service->partition;
privileged = tfm_spm_partition_get_privileged_mode(
- partition->runtime_data.index);
+ partition->static_data->partition_flags);
/*
* It is a fatal error if message handle does not refer to a request
diff --git a/secure_fw/core/tfm_boot_data.c b/secure_fw/core/tfm_boot_data.c
index d98cc79..446baeb 100644
--- a/secure_fw/core/tfm_boot_data.c
+++ b/secure_fw/core/tfm_boot_data.c
@@ -101,7 +101,8 @@
tfm_panic();
}
privileged =
- tfm_spm_partition_get_privileged_mode(partition->runtime_data.index);
+ tfm_spm_partition_get_privileged_mode(partition->static_data->
+ partition_flags);
if (tfm_memory_check(buf_start, buf_size, false, TFM_MEMORY_ACCESS_RW,
privileged) != IPC_SUCCESS) {
diff --git a/secure_fw/spm/spm_api.h b/secure_fw/spm/spm_api.h
index aebcc5a..b9b344a 100644
--- a/secure_fw/spm/spm_api.h
+++ b/secure_fw/spm/spm_api.h
@@ -108,7 +108,6 @@
* Service signal mask passed by
* psa_wait()
*/
- uint32_t index; /* Partition index */
};
#ifdef TFM_PSA_API
@@ -415,12 +414,12 @@
/**
* \brief Get the current partition mode.
*
- * \param[in] partition_idx Index of current partition
+ * \param[in] partition_flags Flags of current partition
*
* \retval TFM_PARTITION_PRIVILEGED_MODE Privileged mode
* \retval TFM_PARTITION_UNPRIVILEGED_MODE Unprivileged mode
*/
-uint32_t tfm_spm_partition_get_privileged_mode(uint32_t partition_idx);
+uint32_t tfm_spm_partition_get_privileged_mode(uint32_t partition_flags);
/******************** Service handle management functions ********************/
diff --git a/secure_fw/spm/spm_api_ipc.c b/secure_fw/spm/spm_api_ipc.c
index 6a7231f..2b701ed 100644
--- a/secure_fw/spm/spm_api_ipc.c
+++ b/secure_fw/spm/spm_api_ipc.c
@@ -437,9 +437,9 @@
return IPC_ERROR_MEMORY_CHECK;
}
-uint32_t tfm_spm_partition_get_privileged_mode(uint32_t partition_idx)
+uint32_t tfm_spm_partition_get_privileged_mode(uint32_t partition_flags)
{
- if (tfm_spm_partition_get_flags(partition_idx) & SPM_PART_FLAG_PSA_ROT) {
+ if (partition_flags & SPM_PART_FLAG_PSA_ROT) {
return TFM_PARTITION_PRIVILEGED_MODE;
} else {
return TFM_PARTITION_UNPRIVILEGED_MODE;
@@ -463,7 +463,6 @@
for (i = 0; i < g_spm_partition_db.partition_count; i++) {
partition = &g_spm_partition_db.partitions[i];
tfm_spm_hal_configure_default_isolation(partition->platform_data);
- partition->runtime_data.index = i;
if ((tfm_spm_partition_get_flags(i) & SPM_PART_FLAG_IPC) == 0) {
continue;
}