aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaef Coles <raef.coles@arm.com>2020-12-22 11:50:02 +0000
committerAnton Komlev <Anton.Komlev@arm.com>2021-03-19 10:14:01 +0100
commit0241dc658a153f1afd98943b06570e37902841bc (patch)
treef6ab83b7ae09a3b58ae14c0d63681aaa801c487b
parentd975819863eb8c30aea16160fd4e4c1267d86f87 (diff)
downloadtrusted-firmware-m-0241dc658a153f1afd98943b06570e37902841bc.tar.gz
FIH: Improve labelling for testing tool
Change-Id: I1c89eb8daaa941b99f6c513a946d9896af54de7f Signed-off-by: Raef Coles <raef.coles@arm.com> Signed-off-by: David Hu <david.hu@arm.com>
-rw-r--r--lib/fih/inc/fih.h13
-rw-r--r--lib/fih/src/fih.c1
-rw-r--r--secure_fw/spm/cmsis_func/main.c3
-rw-r--r--secure_fw/spm/cmsis_psa/main.c3
4 files changed, 17 insertions, 3 deletions
diff --git a/lib/fih/inc/fih.h b/lib/fih/inc/fih.h
index 0f0684a033..b0d039081f 100644
--- a/lib/fih/inc/fih.h
+++ b/lib/fih/inc/fih.h
@@ -138,7 +138,11 @@ extern fih_int FIH_FAILURE;
__attribute__((noinline)) __attribute__((used)) void fih_panic_loop(void);
#define FIH_PANIC fih_panic_loop()
#else /* FIH_ENABLE_GLOBAL_FAIL */
-#define FIH_PANIC while (1) {}
+#define FIH_PANIC \
+ do { \
+ FIH_LABEL("FAILURE_LOOP"); \
+ while (1) {} \
+ } while (0)
#endif /* FIH_ENABLE_GLOBAL_FAIL */
/*
@@ -437,7 +441,8 @@ void fih_cfi_decrement(void);
* Label for interacting with FIH testing tool. Can be parsed from the elf file
* after compilation. Does not require debug symbols.
*/
-#define FIH_LABEL(str) __asm volatile ("FIH_LABEL_" str "_%=:" ::);
+#define FIH_LABEL(str) __asm volatile ("FIH_LABEL_" str "_0_%=:" ::)
+#define FIH_LABEL_CRITICAL_POINT() FIH_LABEL("FIH_CRITICAL_POINT")
/*
* Main FIH calling macro. return variable is second argument. Does some setup
@@ -457,7 +462,7 @@ void fih_cfi_decrement(void);
*/
#define FIH_CALL(f, ret, ...) \
do { \
- FIH_LABEL("FIH_CALL_START"); \
+ FIH_LABEL("FIH_CALL_START_" # f); \
FIH_CFI_PRECALL_BLOCK; \
ret = FIH_FAILURE; \
fih_delay(); \
@@ -513,6 +518,8 @@ typedef int32_t fih_int;
#define FIH_CFI_STEP_DECREMENT()
#define FIH_CFI_STEP_ERR_RESET()
+#define FIH_LABEL_CRITICAL_POINT()
+
#endif /* TFM_FIH_PROFILE_ON */
#ifdef __cplusplus
diff --git a/lib/fih/src/fih.c b/lib/fih/src/fih.c
index 915bc53ed6..87e5406f0c 100644
--- a/lib/fih/src/fih.c
+++ b/lib/fih/src/fih.c
@@ -69,6 +69,7 @@ __attribute__((used))
__attribute__((noinline))
void fih_panic_loop(void)
{
+ FIH_LABEL("FAILURE_LOOP");
__asm volatile ("b fih_panic_loop");
__asm volatile ("b fih_panic_loop");
__asm volatile ("b fih_panic_loop");
diff --git a/secure_fw/spm/cmsis_func/main.c b/secure_fw/spm/cmsis_func/main.c
index 2a809dded7..047207eaa9 100644
--- a/secure_fw/spm/cmsis_func/main.c
+++ b/secure_fw/spm/cmsis_func/main.c
@@ -155,6 +155,9 @@ int main(void)
tfm_core_panic();
}
+ /* All isolation should have been set up at this point */
+ FIH_LABEL_CRITICAL_POINT();
+
/* Print the TF-M version */
SPMLOG_INFMSG("\033[1;34mBooting TFM v"VERSION_FULLSTR"\033[0m\r\n");
diff --git a/secure_fw/spm/cmsis_psa/main.c b/secure_fw/spm/cmsis_psa/main.c
index 41bd91ab31..b9dec4b395 100644
--- a/secure_fw/spm/cmsis_psa/main.c
+++ b/secure_fw/spm/cmsis_psa/main.c
@@ -155,6 +155,9 @@ int main(void)
tfm_core_panic();
}
+ /* All isolation should have been set up at this point */
+ FIH_LABEL_CRITICAL_POINT();
+
/* Print the TF-M version */
SPMLOG_INFMSG("\033[1;34mBooting TFM v"VERSION_FULLSTR"\033[0m\r\n");