]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
arm64: kvm: Move lr save/restore from do_el2_call into EL1
authorJames Morse <james.morse@arm.com>
Wed, 27 Apr 2016 16:47:02 +0000 (17:47 +0100)
committerWill Deacon <will.deacon@arm.com>
Thu, 28 Apr 2016 11:05:46 +0000 (12:05 +0100)
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: James Morse <james.morse@arm.com>
Acked-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
arch/arm64/kernel/hyp-stub.S
arch/arm64/kvm/hyp.S
arch/arm64/kvm/hyp/hyp-entry.S

index a272f335c289dcb5f52144c815edf6938757a218..7eab8acbbbd9fa099a6d562652f83e8965fa6a72 100644 (file)
@@ -101,10 +101,16 @@ ENDPROC(\label)
  */
 
 ENTRY(__hyp_get_vectors)
+       str     lr, [sp, #-16]!
        mov     x0, xzr
-       // fall through
-ENTRY(__hyp_set_vectors)
        hvc     #0
+       ldr     lr, [sp], #16
        ret
 ENDPROC(__hyp_get_vectors)
+
+ENTRY(__hyp_set_vectors)
+       str     lr, [sp, #-16]!
+       hvc     #0
+       ldr     lr, [sp], #16
+       ret
 ENDPROC(__hyp_set_vectors)
index 48f19a37b3df552a08db7b186a65ae4fad4b32e4..4ee5612f43ea5985372dcf75e357a7e24b3c820a 100644 (file)
  * 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
  * arch/arm64/kernel/hyp_stub.S.
+ * HVC behaves as a 'bl' call and will clobber lr.
  */
 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
+       ldr     lr, [sp], #16
        ret
 alternative_else
        b       __vhe_hyp_call
        nop
+       nop
+       nop
 alternative_endif
 ENDPROC(__kvm_call_hyp)
index 3488894397ffa528f951a2337c0f12bd5035c089..43b4b28159d99e64157516512e1470c17791a15a 100644 (file)
         * Shuffle the parameters before calling the function
         * pointed to in x0. Assumes parameters in x[1,2,3].
         */
-       sub     sp, sp, #16
-       str     lr, [sp]
        mov     lr, x0
        mov     x0, x1
        mov     x1, x2
        mov     x2, x3
        blr     lr
-       ldr     lr, [sp]
-       add     sp, sp, #16
 .endm
 
 ENTRY(__vhe_hyp_call)
+       str     lr, [sp, #-16]!
        do_el2_call
+       ldr     lr, [sp], #16
        /*
         * We used to rely on having an exception return to get
         * an implicit isb. In the E2H case, we don't have it anymore.