Inject data/instruction abort exception instead of unknown reason
When the exception is caused by an instruction or data abort, inject it into
the EL1 instead of the (default) unknown reason. This gives the EL1 more
information and could help in handling or debugging these exceptions.
Bug: 147474217
Change-Id: I4db0c35322e2239ecde8b8144921c364d77bcc86
diff --git a/test/vmapi/common/BUILD.gn b/test/vmapi/common/BUILD.gn
index 48be642..081c90e 100644
--- a/test/vmapi/common/BUILD.gn
+++ b/test/vmapi/common/BUILD.gn
@@ -21,4 +21,5 @@
"exception_handler.c",
"spci.c",
]
+ include_dirs = [ "//src/arch/aarch64" ]
}
diff --git a/test/vmapi/common/exception_handler.c b/test/vmapi/common/exception_handler.c
index c58a5b8..14fe1e1 100644
--- a/test/vmapi/common/exception_handler.c
+++ b/test/vmapi/common/exception_handler.c
@@ -19,6 +19,7 @@
#include "vmapi/hf/call.h"
#include "../msr.h"
+#include "sysregs.h"
#include "test/hftest.h"
/**
@@ -81,7 +82,7 @@
* EL1 exception handler to use in unit test VMs.
* Yields control back to the hypervisor and sends the number of exceptions.
*/
-bool exception_handler_yield(void)
+static bool exception_handler_yield(void)
{
dlog("%s function is triggered!\n", __func__);
++exception_handler_exception_count;
@@ -93,6 +94,42 @@
}
/**
+ * EL1 exception handler to use in unit test VMs.
+ * Yields control back to the hypervisor and sends the number of exceptions.
+ * Asserts that the Exception Class is Unknown.
+ */
+bool exception_handler_yield_unknown(void)
+{
+ uintreg_t esr_el1 = read_msr(ESR_EL1);
+ EXPECT_EQ(GET_ESR_EC(esr_el1), EC_UNKNOWN);
+ return exception_handler_yield();
+}
+
+/**
+ * EL1 exception handler to use in unit test VMs.
+ * Yields control back to the hypervisor and sends the number of exceptions.
+ * Asserts that the Exception Class is Data Abort (same EL).
+ */
+bool exception_handler_yield_data_abort(void)
+{
+ uintreg_t esr_el1 = read_msr(ESR_EL1);
+ EXPECT_EQ(GET_ESR_EC(esr_el1), EC_DATA_ABORT_SAME_EL);
+ return exception_handler_yield();
+}
+
+/**
+ * EL1 exception handler to use in unit test VMs.
+ * Yields control back to the hypervisor and sends the number of exceptions.
+ * Asserts that the Exception Class is Instruction Abort (same EL).
+ */
+bool exception_handler_yield_instruction_abort(void)
+{
+ uintreg_t esr_el1 = read_msr(ESR_EL1);
+ EXPECT_EQ(GET_ESR_EC(esr_el1), EC_INSTRUCTION_ABORT_SAME_EL);
+ return exception_handler_yield();
+}
+
+/**
* Returns the number of times the instruction handler was invoked.
*/
int exception_handler_get_num(void)