fix(serror): use custom argument for incrementing elr_elx
Add a custom argument to increment the elr_elx after handling SError.
In some cases, to prevent re-triggering the instruction, ELR needs
to be incremented by 4. In other cases, it may not be necessary.
This argument is passed to the handler, which then decides whether
to increment elr_elx by setting the passed argument accordingly after
handling the SError.
Change-Id: I404f3c5e24f894502a8d00c73649be0b2dd540fa
Signed-off-by: Manish V Badarkhe <Manish.Badarkhe@arm.com>
diff --git a/lib/exceptions/aarch64/serror.c b/lib/exceptions/aarch64/serror.c
index 437c5d0..a57514b 100644
--- a/lib/exceptions/aarch64/serror.c
+++ b/lib/exceptions/aarch64/serror.c
@@ -9,9 +9,9 @@
#include <debug.h>
#include <serror.h>
-static exception_handler_t custom_serror_handler;
+static serr_exception_handler_t custom_serror_handler;
-void register_custom_serror_handler(exception_handler_t handler)
+void register_custom_serror_handler(serr_exception_handler_t handler)
{
custom_serror_handler = handler;
}
@@ -25,19 +25,15 @@
{
uint64_t elr_elx = IS_IN_EL2() ? read_elr_el2() : read_elr_el1();
bool resume = false;
+ bool incr_elr_elx = false;
if (custom_serror_handler == NULL) {
return false;
}
- resume = custom_serror_handler();
+ resume = custom_serror_handler(&incr_elr_elx);
- /*
- * TODO: if there is a test exepecting an Aync EA and expects to resume,
- * then there needs to be additional info from test handler as to whether
- * elr can be incremented or not.
- */
- if (resume) {
+ if (resume && incr_elr_elx) {
/* Move ELR to next instruction to allow tftf to continue */
if (IS_IN_EL2()) {
write_elr_el2(elr_elx + 4U);