Build: Apply global array as partition stacks [tf-m]
Remove the sections defined for stack in linker script/scatter file,
apply the global array as partition stacks.
Signed-off-by: Ken Liu <ken.liu@arm.com>
Change-Id: I88de2b4f7fdad66ba80ad84eabb6b8d2e37472fc
diff --git a/platform/ext/common/armclang/tfm_common_s.sct.template b/platform/ext/common/armclang/tfm_common_s.sct.template
index d2e9ba7..41466f8 100644
--- a/platform/ext/common/armclang/tfm_common_s.sct.template
+++ b/platform/ext/common/armclang/tfm_common_s.sct.template
@@ -207,17 +207,6 @@
*({{manifest.manifest.name}}_ATTR_ZI)
}
- {% if manifest.attr.tfm_partition_ipc %}
-#if defined (TFM_PSA_API)
- {{manifest.manifest.name}}_LINKER_STACK +0 ALIGN 128 EMPTY {{manifest.manifest.stack_size}} {
- }
-#endif
- {% else %}
-#if defined (TFM_PSA_API)
- {{manifest.manifest.name}}_LINKER_STACK +0 ALIGN 128 EMPTY 0 {
- }
-#endif
- {% endif %}
{% if manifest.attr.conditional %}
#endif /* {{manifest.attr.conditional}} */
{% endif %}
@@ -290,17 +279,6 @@
*({{manifest.manifest.name}}_ATTR_ZI)
}
- {% if manifest.attr.tfm_partition_ipc %}
-#if defined (TFM_PSA_API)
- {{manifest.manifest.name}}_LINKER_STACK +0 ALIGN 128 EMPTY {{manifest.manifest.stack_size}} {
- }
-#endif
- {% else %}
-#if defined (TFM_PSA_API)
- {{manifest.manifest.name}}_LINKER_STACK +0 ALIGN 128 EMPTY 0 {
- }
-#endif
- {% endif %}
{% if manifest.attr.conditional %}
#endif /* {{manifest.attr.conditional}} */
{% endif %}
diff --git a/platform/ext/common/armclang/tfm_isolation_l3.sct.template b/platform/ext/common/armclang/tfm_isolation_l3.sct.template
index b5c5fc0..2126134 100644
--- a/platform/ext/common/armclang/tfm_isolation_l3.sct.template
+++ b/platform/ext/common/armclang/tfm_isolation_l3.sct.template
@@ -160,14 +160,6 @@
*({{manifest.manifest.name}}_ATTR_ZI)
}
- {% if manifest.attr.tfm_partition_ipc %}
- {{manifest.manifest.name}}_LINKER_STACK +0 ALIGN 128 EMPTY {{manifest.manifest.stack_size}} {
- }
- {% else %}
- {{manifest.manifest.name}}_LINKER_STACK +0 ALIGN 128 EMPTY 0 {
- }
- {% endif %}
-
PT_{{manifest.manifest.name}}_PRIVATE_DATA_END +0 ALIGN 32 {
/* Position tag */
}
@@ -213,14 +205,6 @@
*({{manifest.manifest.name}}_ATTR_ZI)
}
- {% if manifest.attr.tfm_partition_ipc %}
- {{manifest.manifest.name}}_LINKER_STACK +0 ALIGN 128 EMPTY {{manifest.manifest.stack_size}} {
- }
- {% else %}
- {{manifest.manifest.name}}_LINKER_STACK +0 ALIGN 128 EMPTY 0 {
- }
- {% endif %}
-
PT_{{manifest.manifest.name}}_PRIVATE_DATA_END +0 ALIGN 32 {
/* Position tag */
}
diff --git a/platform/ext/common/gcc/tfm_common_s.ld.template b/platform/ext/common/gcc/tfm_common_s.ld.template
index f530492..fcc818f 100644
--- a/platform/ext/common/gcc/tfm_common_s.ld.template
+++ b/platform/ext/common/gcc/tfm_common_s.ld.template
@@ -117,13 +117,7 @@
{% endif %}
LONG (ADDR(.{{manifest.manifest.name}}_LINKER_BSS))
LONG (SIZEOF(.{{manifest.manifest.name}}_LINKER_BSS))
- {% if manifest.attr.tfm_partition_ipc %}
-#if defined(TFM_PSA_API)
- LONG (ADDR(.{{manifest.manifest.name}}_LINKER_STACK))
- LONG (SIZEOF(.{{manifest.manifest.name}}_LINKER_STACK))
-#endif
- {% endif %}
- {% if manifest.attr.conditional %}
+ {% if manifest.attr.conditional %}
#endif /* {{manifest.attr.conditional}} */
{% endif %}
{% endfor %}
@@ -444,17 +438,6 @@
Image$${{manifest.manifest.name}}_LINKER_DATA$$ZI$$Base = ADDR(.{{manifest.manifest.name}}_LINKER_BSS);
Image$${{manifest.manifest.name}}_LINKER_DATA$$ZI$$Limit = ADDR(.{{manifest.manifest.name}}_LINKER_BSS) + SIZEOF(.{{manifest.manifest.name}}_LINKER_BSS);
- {% if manifest.attr.tfm_partition_ipc %}
-#if defined (TFM_PSA_API)
- .{{manifest.manifest.name}}_LINKER_STACK : ALIGN(128)
- {
- . += {{manifest.manifest.stack_size}};
- } > RAM
- Image$${{manifest.manifest.name}}_LINKER_STACK$$ZI$$Base = ADDR(.{{manifest.manifest.name}}_LINKER_STACK);
- Image$${{manifest.manifest.name}}_LINKER_STACK$$ZI$$Limit = ADDR(.{{manifest.manifest.name}}_LINKER_STACK) + SIZEOF(.{{manifest.manifest.name}}_LINKER_STACK);
-#endif
- {% endif %}
-
{% if manifest.attr.conditional %}
#endif /* {{manifest.attr.conditional}} */
{% endif %}
@@ -594,17 +577,6 @@
Image$${{manifest.manifest.name}}_LINKER_DATA$$ZI$$Base = ADDR(.{{manifest.manifest.name}}_LINKER_BSS);
Image$${{manifest.manifest.name}}_LINKER_DATA$$ZI$$Limit = ADDR(.{{manifest.manifest.name}}_LINKER_BSS) + SIZEOF(.{{manifest.manifest.name}}_LINKER_BSS);
- {% if manifest.attr.tfm_partition_ipc %}
-#if defined (TFM_PSA_API)
- .{{manifest.manifest.name}}_LINKER_STACK : ALIGN(128)
- {
- . += {{manifest.manifest.stack_size}};
- } > RAM
- Image$${{manifest.manifest.name}}_LINKER_STACK$$ZI$$Base = ADDR(.{{manifest.manifest.name}}_LINKER_STACK);
- Image$${{manifest.manifest.name}}_LINKER_STACK$$ZI$$Limit = ADDR(.{{manifest.manifest.name}}_LINKER_STACK) + SIZEOF(.{{manifest.manifest.name}}_LINKER_STACK);
-#endif
- {% endif %}
-
{% if manifest.attr.conditional %}
#endif /* {{manifest.attr.conditional}} */
{% endif %}
diff --git a/platform/ext/common/gcc/tfm_isolation_l3.ld.template b/platform/ext/common/gcc/tfm_isolation_l3.ld.template
index ea770c8..a223459 100644
--- a/platform/ext/common/gcc/tfm_isolation_l3.ld.template
+++ b/platform/ext/common/gcc/tfm_isolation_l3.ld.template
@@ -90,10 +90,6 @@
{% endif %}
LONG (ADDR(.{{manifest.manifest.name}}_RWZI_BSS))
LONG (SIZEOF(.{{manifest.manifest.name}}_RWZI_BSS))
- {% if manifest.attr.tfm_partition_ipc %}
- LONG (ADDR(.{{manifest.manifest.name}}_LINKER_STACK))
- LONG (SIZEOF(.{{manifest.manifest.name}}_LINKER_STACK))
- {% endif %}
{% if manifest.attr.conditional %}
#endif /* {{manifest.attr.conditional}} */
{% endif %}
@@ -329,17 +325,6 @@
Image$$ER_{{manifest.manifest.name}}_RWZI$$ZI$$Base = ADDR(.{{manifest.manifest.name}}_RWZI_BSS);
Image$$ER_{{manifest.manifest.name}}_RWZI$$ZI$$Limit = ADDR(.{{manifest.manifest.name}}_RWZI_BSS) + SIZEOF(.{{manifest.manifest.name}}_RWZI_BSS);
- {% if manifest.attr.tfm_partition_ipc %}
-
- .{{manifest.manifest.name}}_LINKER_STACK : ALIGN(128)
- {
- . += {{manifest.manifest.stack_size}};
- } > RAM
- Image$${{manifest.manifest.name}}_LINKER_STACK$$ZI$$Base = ADDR(.{{manifest.manifest.name}}_LINKER_STACK);
- Image$${{manifest.manifest.name}}_LINKER_STACK$$ZI$$Limit = ADDR(.{{manifest.manifest.name}}_LINKER_STACK) + SIZEOF(.{{manifest.manifest.name}}_LINKER_STACK);
-
- {% endif %}
-
/* Position tag */
. = ALIGN(32);
Image$$PT_{{manifest.manifest.name}}_PRIVATE_DATA_END$$Base = .;
@@ -415,17 +400,6 @@
Image$$ER_{{manifest.manifest.name}}_RWZI$$ZI$$Base = ADDR(.{{manifest.manifest.name}}_RWZI_BSS);
Image$$ER_{{manifest.manifest.name}}_RWZI$$ZI$$Limit = ADDR(.{{manifest.manifest.name}}_RWZI_BSS) + SIZEOF(.{{manifest.manifest.name}}_RWZI_BSS);
- {% if manifest.attr.tfm_partition_ipc %}
-
- .{{manifest.manifest.name}}_LINKER_STACK : ALIGN(128)
- {
- . += {{manifest.manifest.stack_size}};
- } > RAM
- Image$${{manifest.manifest.name}}_LINKER_STACK$$ZI$$Base = ADDR(.{{manifest.manifest.name}}_LINKER_STACK);
- Image$${{manifest.manifest.name}}_LINKER_STACK$$ZI$$Limit = ADDR(.{{manifest.manifest.name}}_LINKER_STACK) + SIZEOF(.{{manifest.manifest.name}}_LINKER_STACK);
-
- {% endif %}
-
/* Position tag */
. = ALIGN(32);
Image$$PT_{{manifest.manifest.name}}_PRIVATE_DATA_END$$Base = .;
diff --git a/platform/ext/common/iar/tfm_common_s.icf.template b/platform/ext/common/iar/tfm_common_s.icf.template
index 9947064..7c6742a 100644
--- a/platform/ext/common/iar/tfm_common_s.icf.template
+++ b/platform/ext/common/iar/tfm_common_s.icf.template
@@ -164,15 +164,6 @@
{% endif %}
};
- {% if manifest.attr.tfm_partition_ipc %}
-#if defined (TFM_PSA_API)
-define block {{manifest.manifest.name}}_LINKER_STACK with alignment = 128, size = {{manifest.manifest.stack_size}} { };
-#endif
- {% else %}
-#if defined (TFM_PSA_API)
-define block {{manifest.manifest.name}}_LINKER_STACK with alignment = 128, size = 0 { };
-#endif
- {% endif %}
{% if manifest.attr.conditional %}
#endif /* {{manifest.attr.conditional}} */
{% endif %}
@@ -243,15 +234,6 @@
{% endif %}
};
- {% if manifest.attr.tfm_partition_ipc %}
-#if defined (TFM_PSA_API)
-define block {{manifest.manifest.name}}_LINKER_STACK with alignment = 128, size = {{manifest.manifest.stack_size}} { };
-#endif
- {% else %}
-#if defined (TFM_PSA_API)
-define block {{manifest.manifest.name}}_LINKER_STACK with alignment = 128, size = 0 { };
-#endif
- {% endif %}
{% if manifest.attr.conditional %}
#endif /* {{manifest.attr.conditional}} */
{% endif %}
@@ -381,9 +363,6 @@
{% endif %}
block {{manifest.manifest.name}}_LINKER_DATA,
-#if defined (TFM_PSA_API)
- block {{manifest.manifest.name}}_LINKER_STACK,
-#endif
{% if manifest.attr.conditional %}
#endif /* {{manifest.attr.conditional}} */
{% endif %}
@@ -432,9 +411,6 @@
{% endif %}
block {{manifest.manifest.name}}_LINKER_DATA,
-#if defined (TFM_PSA_API)
- block {{manifest.manifest.name}}_LINKER_STACK,
-#endif
{% if manifest.attr.conditional %}
#endif /* {{manifest.attr.conditional}} */
{% endif %}
diff --git a/platform/ext/target/nordic_nrf/common/core/gcc/nordic_nrf_s.ld.template b/platform/ext/target/nordic_nrf/common/core/gcc/nordic_nrf_s.ld.template
index b42cb3c..838d742 100644
--- a/platform/ext/target/nordic_nrf/common/core/gcc/nordic_nrf_s.ld.template
+++ b/platform/ext/target/nordic_nrf/common/core/gcc/nordic_nrf_s.ld.template
@@ -137,13 +137,7 @@
{% endif %}
LONG (ADDR(.{{manifest.manifest.name}}_LINKER_BSS))
LONG (SIZEOF(.{{manifest.manifest.name}}_LINKER_BSS))
- {% if manifest.attr.tfm_partition_ipc %}
-#if defined(TFM_PSA_API)
- LONG (ADDR(.{{manifest.manifest.name}}_LINKER_STACK))
- LONG (SIZEOF(.{{manifest.manifest.name}}_LINKER_STACK))
-#endif
- {% endif %}
- {% if manifest.attr.conditional %}
+ {% if manifest.attr.conditional %}
#endif /* {{manifest.attr.conditional}} */
{% endif %}
{% endfor %}
@@ -463,17 +457,6 @@
Image$${{manifest.manifest.name}}_LINKER_DATA$$ZI$$Base = ADDR(.{{manifest.manifest.name}}_LINKER_BSS);
Image$${{manifest.manifest.name}}_LINKER_DATA$$ZI$$Limit = ADDR(.{{manifest.manifest.name}}_LINKER_BSS) + SIZEOF(.{{manifest.manifest.name}}_LINKER_BSS);
- {% if manifest.attr.tfm_partition_ipc %}
-#if defined (TFM_PSA_API)
- .{{manifest.manifest.name}}_LINKER_STACK : ALIGN(128)
- {
- . += {{manifest.manifest.stack_size}};
- } > RAM
- Image$${{manifest.manifest.name}}_LINKER_STACK$$ZI$$Base = ADDR(.{{manifest.manifest.name}}_LINKER_STACK);
- Image$${{manifest.manifest.name}}_LINKER_STACK$$ZI$$Limit = ADDR(.{{manifest.manifest.name}}_LINKER_STACK) + SIZEOF(.{{manifest.manifest.name}}_LINKER_STACK);
-#endif
- {% endif %}
-
{% if manifest.attr.conditional %}
#endif /* {{manifest.attr.conditional}} */
{% endif %}
@@ -613,17 +596,6 @@
Image$${{manifest.manifest.name}}_LINKER_DATA$$ZI$$Base = ADDR(.{{manifest.manifest.name}}_LINKER_BSS);
Image$${{manifest.manifest.name}}_LINKER_DATA$$ZI$$Limit = ADDR(.{{manifest.manifest.name}}_LINKER_BSS) + SIZEOF(.{{manifest.manifest.name}}_LINKER_BSS);
- {% if manifest.attr.tfm_partition_ipc %}
-#if defined (TFM_PSA_API)
- .{{manifest.manifest.name}}_LINKER_STACK : ALIGN(128)
- {
- . += {{manifest.manifest.stack_size}};
- } > RAM
- Image$${{manifest.manifest.name}}_LINKER_STACK$$ZI$$Base = ADDR(.{{manifest.manifest.name}}_LINKER_STACK);
- Image$${{manifest.manifest.name}}_LINKER_STACK$$ZI$$Limit = ADDR(.{{manifest.manifest.name}}_LINKER_STACK) + SIZEOF(.{{manifest.manifest.name}}_LINKER_STACK);
-#endif
- {% endif %}
-
{% if manifest.attr.conditional %}
#endif /* {{manifest.attr.conditional}} */
{% endif %}
diff --git a/secure_fw/spm/cmsis_psa/arch/tfm_arch.c b/secure_fw/spm/cmsis_psa/arch/tfm_arch.c
index 4709223..36e3b32 100644
--- a/secure_fw/spm/cmsis_psa/arch/tfm_arch.c
+++ b/secure_fw/spm/cmsis_psa/arch/tfm_arch.c
@@ -58,24 +58,20 @@
void *param, uintptr_t pfn,
uintptr_t stk_btm, uintptr_t stk_top)
{
- /*
- * For security consideration, set unused registers into ZERO;
- * and only necessary registers are set here.
- */
struct tfm_state_context_t *p_stat_ctx=
(struct tfm_state_context_t *)tfm_arch_seal_thread_stack(stk_top);
/*
- * Shift back SP to leave space for holding base context
+ * Shift back SP to leave space for holding common state context
* since thread is kicked off through exception return.
*/
p_stat_ctx--;
- /* State context is considerate at thread start.*/
+ /* First the common state context - ZERO it before usage. */
spm_memset(p_stat_ctx, 0, sizeof(*p_stat_ctx));
tfm_arch_init_state_ctx(p_stat_ctx, param, pfn);
- /* Initialize architecture context */
+ /* Then the architecture-specific context. */
spm_memset(p_actx, 0, sizeof(*p_actx));
tfm_arch_init_actx(p_actx, (uint32_t)p_stat_ctx, (uint32_t)stk_btm);
}
diff --git a/secure_fw/spm/cmsis_psa/tfm_spm_db_ipc.inc.template b/secure_fw/spm/cmsis_psa/tfm_spm_db_ipc.inc.template
index 8fd3e40..dfa8e5d 100644
--- a/secure_fw/spm/cmsis_psa/tfm_spm_db_ipc.inc.template
+++ b/secure_fw/spm/cmsis_psa/tfm_spm_db_ipc.inc.template
@@ -60,12 +60,11 @@
{% if manifest.attr.conditional %}
#ifdef {{manifest.attr.conditional}}
{% endif %}
-REGION_DECLARE(Image$$, {{manifest.manifest.name}}_LINKER, _STACK$$ZI$$Base);
-REGION_DECLARE(Image$$, {{manifest.manifest.name}}_LINKER, _STACK$$ZI$$Limit);
#if TFM_LVL == 3
REGION_DECLARE(Image$$, PT_{{manifest.manifest.name}}_PRIVATE, _DATA_START$$Base);
REGION_DECLARE(Image$$, PT_{{manifest.manifest.name}}_PRIVATE, _DATA_END$$Base);
#endif
+extern uint8_t {{manifest.manifest.name.lower()}}_stack[];
{% if manifest.attr.conditional %}
#endif /* {{manifest.attr.conditional}} */
{% endif %}
@@ -223,8 +222,8 @@
.data_start = PART_REGION_ADDR(PT_{{manifest.manifest.name}}_PRIVATE, _DATA_START$$Base),
.data_limit = PART_REGION_ADDR(PT_{{manifest.manifest.name}}_PRIVATE, _DATA_END$$Base),
#endif
- .stack_bottom = PART_REGION_ADDR({{manifest.manifest.name}}_LINKER, _STACK$$ZI$$Base),
- .stack_top = PART_REGION_ADDR({{manifest.manifest.name}}_LINKER, _STACK$$ZI$$Limit),
+ .stack_bottom = (uint32_t){{manifest.manifest.name.lower()}}_stack,
+ .stack_top = (uint32_t)({{manifest.manifest.name.lower()}}_stack + {{manifest.manifest.stack_size}}),
{{'},'}}
{% if manifest.attr.conditional %}
#endif /* {{manifest.attr.conditional}} */
@@ -261,4 +260,4 @@
.partitions = partition_list,
};
-#endif /* __TFM_SPM_DB_IPC_INC__ */
\ No newline at end of file
+#endif /* __TFM_SPM_DB_IPC_INC__ */