vmbase: Handle very early exceptions
Introduce a vector table to provide a predictable behavior when
exceptions are raised before the Rust runtime is ready i.e. before
vector_table_el1 may be used. With this table, exceptions are "handled"
by attempting a PSCI_SYSTEM_RESET call and hanging if that returns. For
example, this may prevent a malicious host from triggering a fault when
entry.S accesses .data or .bss in entry.S and getting arbitrary code
execution from VBAR_EL1.
Bug: 237659918
Test: atest vmbase_example.integration_test
Signed-off-by: Pierre-Clément Tosi <ptosi@google.com>
Change-Id: I5106e32b3118ec691ea6a7a80516d8c29918563c
diff --git a/vmbase/entry.S b/vmbase/entry.S
index 490e841..490c2f3 100644
--- a/vmbase/entry.S
+++ b/vmbase/entry.S
@@ -84,6 +84,9 @@
entry:
/* Load and apply the memory management configuration, ready to enable MMU and caches. */
+ adr x30, vector_table_panic
+ msr vbar_el1, x30
+
adrp x30, idmap
msr ttbr0_el1, x30