fix(runtime): run RSI handler with FPU/SVE traps enabled
If REC has used FPU/SVE, RSI handler will be entered with traps
disabled. This fix enables FPU/SVE traps for all RSI calls and restores
the trap register upon exit.
When RMM built with RMM_FPU_USE_AT_REL2=ON, by saving and restoring the
trap register, fixes a crash seen in RMM when REC has used FPU and
attestation/measurement services unconditionally enabled traps through
FPU_ALLOW call.
Signed-off-by: Arunachalam Ganapathy <arunachalam.ganapathy@arm.com>
Change-Id: Ic04c4c6b0c815266e76cb751021857e6dcfee7e5
diff --git a/runtime/core/exit.c b/runtime/core/exit.c
index 5ee59ab..abcde63 100644
--- a/runtime/core/exit.c
+++ b/runtime/core/exit.c
@@ -404,6 +404,15 @@
return true;
}
+ /*
+ * If the REC is allowed to access SIMD, then we will enter RMM with
+ * SIMD traps disabled. So enable SIMD traps as RMM by default runs with
+ * SIMD traps enabled
+ */
+ if (rec_is_simd_allowed(rec)) {
+ simd_disable();
+ }
+
switch (function_id) {
case SMCCC_VERSION:
rec->regs[0] = SMCCC_VERSION_NUMBER;
@@ -569,6 +578,11 @@
break;
}
+ /* Re-enable SIMD access if REC is allowed to access */
+ if (rec_is_simd_allowed(rec)) {
+ simd_enable(rec_simd_type(rec));
+ }
+
/* Log RSI call */
RSI_LOG_EXIT(function_id, rec->regs[0], ret_to_rec);
return ret_to_rec;