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>
diff --git a/lib/fih/inc/fih.h b/lib/fih/inc/fih.h
index 0f0684a..b0d0390 100644
--- a/lib/fih/inc/fih.h
+++ b/lib/fih/inc/fih.h
@@ -138,7 +138,11 @@
 __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 @@
  * 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 @@
  */
 #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 @@
 #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 915bc53..87e5406 100644
--- a/lib/fih/src/fih.c
+++ b/lib/fih/src/fih.c
@@ -69,6 +69,7 @@
 __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 2a809dd..047207e 100644
--- a/secure_fw/spm/cmsis_func/main.c
+++ b/secure_fw/spm/cmsis_func/main.c
@@ -155,6 +155,9 @@
         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 41bd91a..b9dec4b 100644
--- a/secure_fw/spm/cmsis_psa/main.c
+++ b/secure_fw/spm/cmsis_psa/main.c
@@ -155,6 +155,9 @@
         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");