Report FAR_EL2's value on injecting EL1 exception

Propagate the value of FAR_EL2 to FAR_EL1 when injecting an
exception, only when the value is defined and known.

Fixes a bug where EL1 resumes running although it cannot
determine the faulting address from FAR_EL1.

Signed-off-by: Fuad Tabba <tabba@google.com>
Change-Id: If6c72b74a89251b2f18d14b96af63dc3adc1b739
diff --git a/test/vmapi/common/exception_handler.c b/test/vmapi/common/exception_handler.c
index e820a3a..c3c3334 100644
--- a/test/vmapi/common/exception_handler.c
+++ b/test/vmapi/common/exception_handler.c
@@ -93,7 +93,16 @@
 bool exception_handler_yield_unknown(void)
 {
 	uintreg_t esr_el1 = read_msr(ESR_EL1);
+	uintreg_t far_el1 = read_msr(FAR_EL1);
+
 	EXPECT_EQ(GET_ESR_EC(esr_el1), EC_UNKNOWN);
+
+	/*
+	 * For unknown exceptions, the value of far_el1 is UNKNOWN.
+	 * Hafnium sets it to 0.
+	 */
+	EXPECT_EQ(far_el1, 0);
+
 	return exception_handler_yield();
 }
 
@@ -105,7 +114,11 @@
 bool exception_handler_yield_data_abort(void)
 {
 	uintreg_t esr_el1 = read_msr(ESR_EL1);
+	uintreg_t far_el1 = read_msr(FAR_EL1);
+
 	EXPECT_EQ(GET_ESR_EC(esr_el1), EC_DATA_ABORT_SAME_EL);
+	EXPECT_NE(far_el1, 0);
+
 	return exception_handler_yield();
 }
 
@@ -117,7 +130,11 @@
 bool exception_handler_yield_instruction_abort(void)
 {
 	uintreg_t esr_el1 = read_msr(ESR_EL1);
+	uintreg_t far_el1 = read_msr(FAR_EL1);
+
 	EXPECT_EQ(GET_ESR_EC(esr_el1), EC_INSTRUCTION_ABORT_SAME_EL);
+	EXPECT_NE(far_el1, 0);
+
 	return exception_handler_yield();
 }