Commit 00a44cda authored by James Morse's avatar James Morse Committed by Will Deacon

arm64: kvm: Move lr save/restore from do_el2_call into EL1

Today the 'hvc' calling KVM or the hyp-stub is expected to preserve all
registers. KVM saves/restores the registers it needs on the EL2 stack using
do_el2_call(). The hyp-stub has no stack, later patches need to be able to
be able to clobber the link register.

Move the link register save/restore to the the call sites.
Signed-off-by: default avatarJames Morse <james.morse@arm.com>
Acked-by: default avatarMarc Zyngier <marc.zyngier@arm.com>
Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
parent e7227d0e
...@@ -101,10 +101,16 @@ ENDPROC(\label) ...@@ -101,10 +101,16 @@ ENDPROC(\label)
*/ */
ENTRY(__hyp_get_vectors) ENTRY(__hyp_get_vectors)
str lr, [sp, #-16]!
mov x0, xzr mov x0, xzr
// fall through
ENTRY(__hyp_set_vectors)
hvc #0 hvc #0
ldr lr, [sp], #16
ret ret
ENDPROC(__hyp_get_vectors) ENDPROC(__hyp_get_vectors)
ENTRY(__hyp_set_vectors)
str lr, [sp, #-16]!
hvc #0
ldr lr, [sp], #16
ret
ENDPROC(__hyp_set_vectors) ENDPROC(__hyp_set_vectors)
...@@ -38,13 +38,18 @@ ...@@ -38,13 +38,18 @@
* A function pointer with a value of 0 has a special meaning, and is * A function pointer with a value of 0 has a special meaning, and is
* used to implement __hyp_get_vectors in the same way as in * used to implement __hyp_get_vectors in the same way as in
* arch/arm64/kernel/hyp_stub.S. * arch/arm64/kernel/hyp_stub.S.
* HVC behaves as a 'bl' call and will clobber lr.
*/ */
ENTRY(__kvm_call_hyp) ENTRY(__kvm_call_hyp)
alternative_if_not ARM64_HAS_VIRT_HOST_EXTN alternative_if_not ARM64_HAS_VIRT_HOST_EXTN
str lr, [sp, #-16]!
hvc #0 hvc #0
ldr lr, [sp], #16
ret ret
alternative_else alternative_else
b __vhe_hyp_call b __vhe_hyp_call
nop nop
nop
nop
alternative_endif alternative_endif
ENDPROC(__kvm_call_hyp) ENDPROC(__kvm_call_hyp)
...@@ -42,19 +42,17 @@ ...@@ -42,19 +42,17 @@
* Shuffle the parameters before calling the function * Shuffle the parameters before calling the function
* pointed to in x0. Assumes parameters in x[1,2,3]. * pointed to in x0. Assumes parameters in x[1,2,3].
*/ */
sub sp, sp, #16
str lr, [sp]
mov lr, x0 mov lr, x0
mov x0, x1 mov x0, x1
mov x1, x2 mov x1, x2
mov x2, x3 mov x2, x3
blr lr blr lr
ldr lr, [sp]
add sp, sp, #16
.endm .endm
ENTRY(__vhe_hyp_call) ENTRY(__vhe_hyp_call)
str lr, [sp, #-16]!
do_el2_call do_el2_call
ldr lr, [sp], #16
/* /*
* We used to rely on having an exception return to get * We used to rely on having an exception return to get
* an implicit isb. In the E2H case, we don't have it anymore. * an implicit isb. In the E2H case, we don't have it anymore.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment