Logically, we can split up the vmexit_handler in two parts: the early phase,
after which x0-x4 may be clobbered, and the entry phase, that pushes the rest
of the context and enters the exit handler.

These two phases can be rolled out via macros. Later, we use these macro to add
additional (i.e., calling SMCCC_ARCH_WORKAROUND_1) code between the phases.

Signed-off-by: Ralf Ramsauer <[email protected]>
---
 hypervisor/arch/arm64/entry.S | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/hypervisor/arch/arm64/entry.S b/hypervisor/arch/arm64/entry.S
index 498a8d64..f5abee3e 100644
--- a/hypervisor/arch/arm64/entry.S
+++ b/hypervisor/arch/arm64/entry.S
@@ -270,9 +270,7 @@ bootstrap_vectors:
        ventry  .
        ventry  .
 
-
-.macro handle_vmexit handler
-       .align  7
+.macro handle_vmexit_early
        /* We need to save EL1 context, reserve some space on the stack */
        sub     sp, sp, #(16 * 16)
        /* And push [x1-x4] early, we need registers to work on */
@@ -291,7 +289,9 @@ bootstrap_vectors:
        ldr     x4, [x3]
        add     x4, x4, #1
        str     x4, [x3]
+.endm
 
+.macro handle_vmexit_late handler
        /* Fill the rest of the union registers. Should comply with 
NUM_USR_REGS */
        stp     x5, x6, [sp, #(3 * 16)]
        stp     x7, x8, [sp, #(4 * 16)]
@@ -315,6 +315,16 @@ bootstrap_vectors:
        b       __vmreturn
 .endm
 
+.macro handle_vmexit handler
+       .align  7
+       handle_vmexit_early
+       handle_vmexit_late \handler
+.endm
+
+/*
+ * These are the default vectors. They are used on early startup and if no
+ * Spectre v2 mitigation is available.
+ */
        .align 11
 hyp_vectors:
        ventry  .
-- 
2.20.1

-- 
You received this message because you are subscribed to the Google Groups 
"Jailhouse" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to