Skip to content

Commit 00a44cd

Browse files
James Morsewildea01
authored andcommitted
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: James Morse <james.morse@arm.com> Acked-by: Marc Zyngier <marc.zyngier@arm.com> Signed-off-by: Will Deacon <will.deacon@arm.com>
1 parent e7227d0 commit 00a44cd

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

arch/arm64/kernel/hyp-stub.S

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,16 @@ ENDPROC(\label)
101101
*/
102102

103103
ENTRY(__hyp_get_vectors)
104+
str lr, [sp, #-16]!
104105
mov x0, xzr
105-
// fall through
106-
ENTRY(__hyp_set_vectors)
107106
hvc #0
107+
ldr lr, [sp], #16
108108
ret
109109
ENDPROC(__hyp_get_vectors)
110+
111+
ENTRY(__hyp_set_vectors)
112+
str lr, [sp, #-16]!
113+
hvc #0
114+
ldr lr, [sp], #16
115+
ret
110116
ENDPROC(__hyp_set_vectors)

arch/arm64/kvm/hyp.S

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,18 @@
3838
* A function pointer with a value of 0 has a special meaning, and is
3939
* used to implement __hyp_get_vectors in the same way as in
4040
* arch/arm64/kernel/hyp_stub.S.
41+
* HVC behaves as a 'bl' call and will clobber lr.
4142
*/
4243
ENTRY(__kvm_call_hyp)
43-
alternative_if_not ARM64_HAS_VIRT_HOST_EXTN
44+
alternative_if_not ARM64_HAS_VIRT_HOST_EXTN
45+
str lr, [sp, #-16]!
4446
hvc #0
47+
ldr lr, [sp], #16
4548
ret
4649
alternative_else
4750
b __vhe_hyp_call
4851
nop
52+
nop
53+
nop
4954
alternative_endif
5055
ENDPROC(__kvm_call_hyp)

arch/arm64/kvm/hyp/hyp-entry.S

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,19 +42,17 @@
4242
* Shuffle the parameters before calling the function
4343
* pointed to in x0. Assumes parameters in x[1,2,3].
4444
*/
45-
sub sp, sp, #16
46-
str lr, [sp]
4745
mov lr, x0
4846
mov x0, x1
4947
mov x1, x2
5048
mov x2, x3
5149
blr lr
52-
ldr lr, [sp]
53-
add sp, sp, #16
5450
.endm
5551

5652
ENTRY(__vhe_hyp_call)
53+
str lr, [sp, #-16]!
5754
do_el2_call
55+
ldr lr, [sp], #16
5856
/*
5957
* We used to rely on having an exception return to get
6058
* an implicit isb. In the E2H case, we don't have it anymore.

0 commit comments

Comments
 (0)