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>
diff --git a/secure_fw/include/load/partition_defs.h b/secure_fw/include/load/partition_defs.h
index 014f833..74d04d0 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 @@
     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 1e7b4ca..f2f9c3d 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 63520cf..e401111 100644
--- a/secure_fw/spm/cmsis_psa/spm_ipc.c
+++ b/secure_fw/spm/cmsis_psa/spm_ipc.c
@@ -692,6 +692,7 @@
 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 @@
             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 @@
 {
 #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();