Skip to content

Commit f7ef280

Browse files
committed
KVM: SVM: adjust register allocation for __svm_vcpu_run()
32-bit ABI uses RAX/RCX/RDX as its argument registers, so they are in the way of instructions that hardcode their operands such as RDMSR/WRMSR or VMLOAD/VMRUN/VMSAVE. In preparation for moving vmload/vmsave to __svm_vcpu_run(), keep the pointer to the struct vcpu_svm in %rdi. In particular, it is now possible to load svm->vmcb01.pa in %rax without clobbering the struct vcpu_svm pointer. No functional change intended. Cc: stable@vger.kernel.org Fixes: a149180 ("x86: Add magic AMD return-thunk") Reviewed-by: Sean Christopherson <seanjc@google.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent 16fdc1d commit f7ef280

1 file changed

Lines changed: 19 additions & 19 deletions

File tree

arch/x86/kvm/svm/vmenter.S

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -54,29 +54,29 @@ SYM_FUNC_START(__svm_vcpu_run)
5454
/* Save @vmcb. */
5555
push %_ASM_ARG1
5656

57-
/* Move @svm to RAX. */
58-
mov %_ASM_ARG2, %_ASM_AX
57+
/* Move @svm to RDI. */
58+
mov %_ASM_ARG2, %_ASM_DI
59+
60+
/* "POP" @vmcb to RAX. */
61+
pop %_ASM_AX
5962

6063
/* Load guest registers. */
61-
mov VCPU_RCX(%_ASM_AX), %_ASM_CX
62-
mov VCPU_RDX(%_ASM_AX), %_ASM_DX
63-
mov VCPU_RBX(%_ASM_AX), %_ASM_BX
64-
mov VCPU_RBP(%_ASM_AX), %_ASM_BP
65-
mov VCPU_RSI(%_ASM_AX), %_ASM_SI
66-
mov VCPU_RDI(%_ASM_AX), %_ASM_DI
64+
mov VCPU_RCX(%_ASM_DI), %_ASM_CX
65+
mov VCPU_RDX(%_ASM_DI), %_ASM_DX
66+
mov VCPU_RBX(%_ASM_DI), %_ASM_BX
67+
mov VCPU_RBP(%_ASM_DI), %_ASM_BP
68+
mov VCPU_RSI(%_ASM_DI), %_ASM_SI
6769
#ifdef CONFIG_X86_64
68-
mov VCPU_R8 (%_ASM_AX), %r8
69-
mov VCPU_R9 (%_ASM_AX), %r9
70-
mov VCPU_R10(%_ASM_AX), %r10
71-
mov VCPU_R11(%_ASM_AX), %r11
72-
mov VCPU_R12(%_ASM_AX), %r12
73-
mov VCPU_R13(%_ASM_AX), %r13
74-
mov VCPU_R14(%_ASM_AX), %r14
75-
mov VCPU_R15(%_ASM_AX), %r15
70+
mov VCPU_R8 (%_ASM_DI), %r8
71+
mov VCPU_R9 (%_ASM_DI), %r9
72+
mov VCPU_R10(%_ASM_DI), %r10
73+
mov VCPU_R11(%_ASM_DI), %r11
74+
mov VCPU_R12(%_ASM_DI), %r12
75+
mov VCPU_R13(%_ASM_DI), %r13
76+
mov VCPU_R14(%_ASM_DI), %r14
77+
mov VCPU_R15(%_ASM_DI), %r15
7678
#endif
77-
78-
/* "POP" @vmcb to RAX. */
79-
pop %_ASM_AX
79+
mov VCPU_RDI(%_ASM_DI), %_ASM_DI
8080

8181
/* Enter guest mode */
8282
sti

0 commit comments

Comments
 (0)