Simplify noreturn exception vectors for current EL
All handlers for current EL exceptions panic and never return. Create
noreturn_* variants of exception vector macros without a return path.
Also rename the C handlers to make it clearer in the assembly that these
are not expected to return.
This is done in preparation for inserting speculation barriers after
ERETs, removing the _sp0 handlers which use all the 32 instructions
available in a vector table entry.
Change-Id: If6616686d9a28820ed223e4d3d0e9cdfc3271e52
diff --git a/src/arch/aarch64/exception_macros.S b/src/arch/aarch64/exception_macros.S
index 642ee98..ef820b7 100644
--- a/src/arch/aarch64/exception_macros.S
+++ b/src/arch/aarch64/exception_macros.S
@@ -94,6 +94,15 @@
.endm
/**
+ * Variant of current_exception_sp0 which assumes the handler never returns.
+ */
+.macro noreturn_current_exception_sp0 elx:req handler:req
+ msr spsel, #1
+ save_volatile_to_stack \elx
+ b \handler
+.endm
+
+/**
* This is a generic handler for exceptions taken at the current EL while using
* SPx. It saves volatile registers, calls the C handler, restores volatile
* registers, then returns.
@@ -107,3 +116,11 @@
bl \handler
b restore_from_stack_and_return
.endm
+
+/**
+ * Variant of current_exception_spx which assumes the handler never returns.
+ */
+.macro noreturn_current_exception_spx elx:req handler:req
+ save_volatile_to_stack \elx
+ b \handler
+.endm
diff --git a/src/arch/aarch64/hypervisor/exceptions.S b/src/arch/aarch64/hypervisor/exceptions.S
index ed218cb..fe89da8 100644
--- a/src/arch/aarch64/hypervisor/exceptions.S
+++ b/src/arch/aarch64/hypervisor/exceptions.S
@@ -107,35 +107,35 @@
.balign 0x800
vector_table_el2:
sync_cur_sp0:
- current_exception_sp0 el2 sync_current_exception
+ noreturn_current_exception_sp0 el2 sync_current_exception_noreturn
.balign 0x80
irq_cur_sp0:
- current_exception_sp0 el2 irq_current_exception
+ noreturn_current_exception_sp0 el2 irq_current_exception_noreturn
.balign 0x80
fiq_cur_sp0:
- current_exception_sp0 el2 fiq_current_exception
+ noreturn_current_exception_sp0 el2 fiq_current_exception_noreturn
.balign 0x80
serr_cur_sp0:
- current_exception_sp0 el2 serr_current_exception
+ noreturn_current_exception_sp0 el2 serr_current_exception_noreturn
.balign 0x80
sync_cur_spx:
- current_exception_spx el2 sync_current_exception
+ noreturn_current_exception_spx el2 sync_current_exception_noreturn
.balign 0x80
irq_cur_spx:
- current_exception_spx el2 irq_current_exception
+ noreturn_current_exception_spx el2 irq_current_exception_noreturn
.balign 0x80
fiq_cur_spx:
- current_exception_spx el2 fiq_current_exception
+ noreturn_current_exception_spx el2 fiq_current_exception_noreturn
.balign 0x80
serr_cur_spx:
- current_exception_spx el2 serr_current_exception
+ noreturn_current_exception_spx el2 serr_current_exception_noreturn
.balign 0x80
sync_lower_64:
diff --git a/src/arch/aarch64/hypervisor/handler.c b/src/arch/aarch64/hypervisor/handler.c
index 53ae4d0..bc2b998 100644
--- a/src/arch/aarch64/hypervisor/handler.c
+++ b/src/arch/aarch64/hypervisor/handler.c
@@ -180,7 +180,7 @@
}
}
-noreturn void irq_current_exception(uintreg_t elr, uintreg_t spsr)
+noreturn void irq_current_exception_noreturn(uintreg_t elr, uintreg_t spsr)
{
(void)elr;
(void)spsr;
@@ -188,7 +188,7 @@
panic("IRQ from current");
}
-noreturn void fiq_current_exception(uintreg_t elr, uintreg_t spsr)
+noreturn void fiq_current_exception_noreturn(uintreg_t elr, uintreg_t spsr)
{
(void)elr;
(void)spsr;
@@ -196,7 +196,7 @@
panic("FIQ from current");
}
-noreturn void serr_current_exception(uintreg_t elr, uintreg_t spsr)
+noreturn void serr_current_exception_noreturn(uintreg_t elr, uintreg_t spsr)
{
(void)elr;
(void)spsr;
@@ -204,7 +204,7 @@
panic("SERR from current");
}
-noreturn void sync_current_exception(uintreg_t elr, uintreg_t spsr)
+noreturn void sync_current_exception_noreturn(uintreg_t elr, uintreg_t spsr)
{
uintreg_t esr = read_msr(esr_el2);
uintreg_t ec = GET_ESR_EC(esr);