feat(ras): move wait logic from assembley to C
SDEI test uses a flag to be updated through SDEI handler to ensure that
test has passed, this logic was implemented in assembly, move this logic
in C to make it easily readable.
Signed-off-by: Manish Pandey <manish.pandey2@arm.com>
Change-Id: I4c92aa7a6fbeb5fcdb4c67b0166627a539609f18
diff --git a/tftf/tests/misc_tests/inject_ras_error.S b/tftf/tests/misc_tests/inject_ras_error.S
index 280edb8..1798a90 100644
--- a/tftf/tests/misc_tests/inject_ras_error.S
+++ b/tftf/tests/misc_tests/inject_ras_error.S
@@ -21,14 +21,8 @@
* x0: Fault record number to program
* x1: Injected fault properties
* x2: Type of error to be generated
- * x3: Memory location to wait for, or 0 if no waiting is required
*/
func inject_ras_error_record
- /* Clear SError received flag if necessary */
- cbz x3, 1f
- str xzr, [x3, #0]
- dsb st
-1:
/* Choose Error record 0 on the PE */
msr ERRSELR_EL1, x0
isb
@@ -46,25 +40,10 @@
msr ERXPFGCTL_EL1, x2
isb
- /* If no waiting is required, jump to end */
- cbz x3, 3f
-
- sevl
-
-2:
- wfe
- dsb st
- ldr x0, [x3, #0]
- cbz x0, 2b
-
-3:
ret
endfunc inject_ras_error_record
-/*
- * Inject Unrecoverable error through fault record 0. Wait until serror_received
- * is set by the handler in response to receving the event.
- */
+/* Inject Unrecoverable error through fault record 0. */
func inject_unrecoverable_ras_error
/* Inject fault into record 0 */
mov x0, #0
@@ -76,10 +55,6 @@
/* Injected fault control */
mov x2, #ERXPFGCTL_UEU_BIT
- /* Wait address */
- adrp x3, serror_received
- add x3, x3, :lo12:serror_received
-
b inject_ras_error_record
endfunc inject_unrecoverable_ras_error
@@ -96,9 +71,6 @@
/* Injected fault control */
mov x2, #ERXPFGCTL_UC_BIT
- /* Nothing to wait for */
- mov x3, xzr
-
b inject_ras_error_record
endfunc inject_uncontainable_ras_error
diff --git a/tftf/tests/misc_tests/test_single_fault.c b/tftf/tests/misc_tests/test_single_fault.c
index dd30572..cacd0a7 100644
--- a/tftf/tests/misc_tests/test_single_fault.c
+++ b/tftf/tests/misc_tests/test_single_fault.c
@@ -11,7 +11,7 @@
#ifdef __aarch64__
-uint64_t sdei_event_received;
+static volatile uint64_t sdei_event_received;
extern void inject_unrecoverable_ras_error(void);
extern int serror_sdei_event_handler(int ev, uint64_t arg);
@@ -51,6 +51,11 @@
inject_unrecoverable_ras_error();
+ /* Wait until the SError fires */
+ do {
+ dmbish();
+ } while (sdei_event_received == 0);
+
return TEST_RESULT_SUCCESS;
}