aboutsummaryrefslogtreecommitdiff
path: root/secure_fw
diff options
context:
space:
mode:
authorMingyang Sun <mingyang.sun@arm.com>2021-05-11 11:44:19 +0800
committerKen Liu <ken.liu@arm.com>2021-05-19 04:54:29 +0200
commitf085184fe5399b3659b98a8fae04ebb8c7f54927 (patch)
treeaaddbab1a084dcd3ecf36a6d80061d4e4fb5a34c /secure_fw
parent69ee5f694aa34ded27009a479d7a9362a3a92f22 (diff)
downloadtrusted-firmware-m-f085184fe5399b3659b98a8fae04ebb8c7f54927.tar.gz
SPM: Fix warning of variable length data
Fix the warnings from armclang of variable length data not placed at the end of struct. Change-Id: I39cdb66b9f20691fa937334a5fc8ac4af9a92e9a Signed-off-by: Mingyang Sun <mingyang.sun@arm.com>
Diffstat (limited to 'secure_fw')
-rw-r--r--secure_fw/include/load/partition_defs.h8
-rw-r--r--secure_fw/include/load/partition_static_load.h2
-rw-r--r--secure_fw/spm/cmsis_psa/spm_ipc.c9
3 files changed, 13 insertions, 6 deletions
diff --git a/secure_fw/include/load/partition_defs.h b/secure_fw/include/load/partition_defs.h
index 014f8332f..74d04d0db 100644
--- a/secure_fw/include/load/partition_defs.h
+++ b/secure_fw/include/load/partition_defs.h
@@ -36,7 +36,12 @@
#define SPM_PART_FLAG_PSA_ROT (1U << 8)
#define SPM_PART_FLAG_IPC (1U << 9)
-/* Common partition structure type */
+/*
+ * Common partition structure type, the extendable data is right after it.
+ * Extendable data has different size for each partition, and must be 4-byte
+ * aligned. It includes: stack and heap position, dependencies, services and
+ * assets data.
+ */
struct partition_static_info_t {
uint32_t psa_ff_ver; /* Encode the version with magic */
uint32_t pid; /* Partition ID */
@@ -47,7 +52,6 @@ struct partition_static_info_t {
uint32_t ndeps; /* Dependency number */
uint32_t nservices; /* Service number */
uint32_t nassets; /* Asset numbers */
- uintptr_t vars[]; /* Struct extendable indicator */
} __attribute__((aligned(4)));
#endif /* __PARTITION_DEFS_H__ */
diff --git a/secure_fw/include/load/partition_static_load.h b/secure_fw/include/load/partition_static_load.h
index 1e7b4cab3..f2f9c3d61 100644
--- a/secure_fw/include/load/partition_static_load.h
+++ b/secure_fw/include/load/partition_static_load.h
@@ -36,7 +36,7 @@
(ps_ptr)->nassets * sizeof(struct asset_desc_t))
#define STATIC_INF_DEPS(ps_ptr) \
- ((uintptr_t)(ps_ptr)->vars + STATIC_INFO_EXT_LENGTH * sizeof(uintptr_t))
+ ((uintptr_t)(ps_ptr + 1) + STATIC_INFO_EXT_LENGTH * sizeof(uintptr_t))
#define STATIC_INF_SERVICE(ps_ptr) \
((uintptr_t)STATIC_INF_DEPS(ps_ptr) + (ps_ptr)->ndeps * sizeof(uint32_t))
#define STATIC_INF_ASSET(ps_ptr) \
diff --git a/secure_fw/spm/cmsis_psa/spm_ipc.c b/secure_fw/spm/cmsis_psa/spm_ipc.c
index 63520cfe6..e40111112 100644
--- a/secure_fw/spm/cmsis_psa/spm_ipc.c
+++ b/secure_fw/spm/cmsis_psa/spm_ipc.c
@@ -692,6 +692,7 @@ bool tfm_validate_partition_static(struct partition_static_info_t *p_cmninf)
uint32_t tfm_spm_init(void)
{
uint32_t i, j;
+ uintptr_t *p_ext_static_info;
struct partition_t *partition;
struct service_t *service;
struct tfm_core_thread_t *pth, *p_ns_entry_thread = NULL;
@@ -801,12 +802,14 @@ uint32_t tfm_spm_init(void)
tfm_core_panic();
}
+ /* Extendable partition static info is right after p_cmninf. */
+ p_ext_static_info = (uintptr_t *)(p_cmninf + 1);
tfm_core_thrd_init(
pth,
POSITION_TO_ENTRY(p_cmninf->entry, tfm_core_thrd_entry_t),
NULL,
- (uintptr_t)(p_cmninf->vars[0] + p_cmninf->stack_size),
- (uintptr_t)p_cmninf->vars[0]);
+ p_ext_static_info[0] + p_cmninf->stack_size,
+ p_ext_static_info[0]);
pth->prior = TO_THREAD_PRIORITY(PARTITION_GET_PRIOR(p_cmninf->flags));
@@ -868,7 +871,7 @@ void tfm_pendsv_do_schedule(struct tfm_arch_ctx_t *p_actx)
{
#if TFM_LVL != 1
struct partition_t *p_next_partition;
- struct partition_static_info_t *p_part_static;
+ const struct partition_static_info_t *p_part_static;
uint32_t is_privileged;
#endif
struct tfm_core_thread_t *pth_next = tfm_core_thrd_get_next();