If we want to call SMCCC very early in the exit path, we have to store x0-x3 as early as possible. Rearrange the exit path accordingly.
Due to the structure of union registers, we also have to push x4 while not necessarily required. But this makes things easier at the moment. Nevertheless, we will benefit from that later: we will use x4 to hold variables that need to be preserved between SMC calls. Additionally, decorate things with a few comments. Signed-off-by: Ralf Ramsauer <[email protected]> --- hypervisor/arch/arm64/entry.S | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/hypervisor/arch/arm64/entry.S b/hypervisor/arch/arm64/entry.S index da8c15ce..2d6c69b2 100644 --- a/hypervisor/arch/arm64/entry.S +++ b/hypervisor/arch/arm64/entry.S @@ -269,10 +269,20 @@ bootstrap_vectors: .macro handle_vmexit exit_reason .align 7 - /* Fill the union registers. Should comply with NUM_USR_REGS */ + /* 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 */ stp x1, x2, [sp, #(1 * 16)] stp x3, x4, [sp, #(2 * 16)] + + /* x1 is available, use it to hold the exit reason */ + mov x1, #\exit_reason + /* ... and push it together with x0 */ + stp x1, x0, [sp, #(0 * 16)] + + /* [x0-x4] may now be clobbered. */ + + /* 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)] stp x9, x10, [sp, #(5 * 16)] @@ -287,9 +297,6 @@ bootstrap_vectors: stp x27, x28, [sp, #(14 * 16)] stp x29, x30, [sp, #(15 * 16)] - mov x1, #\exit_reason - stp x1, x0, [sp, #(0 * 16)] - mov x29, xzr /* reset fp,lr */ mov x30, xzr mov x0, sp -- 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.
