]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
KVM: VMX: Preserve callee-save registers in vCPU-run asm sub-routine
authorSean Christopherson <sean.j.christopherson@intel.com>
Fri, 25 Jan 2019 15:41:18 +0000 (07:41 -0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Wed, 20 Feb 2019 21:48:17 +0000 (22:48 +0100)
...to make it callable from C code.

Note that because KVM chooses to be ultra paranoid about guest register
values, all callee-save registers are still cleared after VM-Exit even
though the host's values are now reloaded from the stack.

Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/vmx/vmenter.S
arch/x86/kvm/vmx/vmx.c

index e06a3f33311efdb737487ad046da868a26037892..d325f1d6110b53b58c403eb73d194799a80f67ed 100644 (file)
@@ -92,6 +92,16 @@ ENDPROC(vmx_vmexit)
 ENTRY(__vmx_vcpu_run)
        push %_ASM_BP
        mov  %_ASM_SP, %_ASM_BP
+#ifdef CONFIG_X86_64
+       push %r15
+       push %r14
+       push %r13
+       push %r12
+#else
+       push %edi
+       push %esi
+#endif
+       push %_ASM_BX
 
        /*
         * Save @regs, _ASM_ARG2 may be modified by vmx_update_host_rsp() and
@@ -195,6 +205,17 @@ ENTRY(__vmx_vcpu_run)
 
        /* "POP" @regs. */
        add $WORD_SIZE, %_ASM_SP
+       pop %_ASM_BX
+
+#ifdef CONFIG_X86_64
+       pop %r12
+       pop %r13
+       pop %r14
+       pop %r15
+#else
+       pop %esi
+       pop %edi
+#endif
        pop %_ASM_BP
        ret
 
index 9a1d27e77684ecf3a093d05eb407dd8d566e864f..43723d0007be4f918e0bd0a7dd5bbabdd1f34c64 100644 (file)
@@ -6456,10 +6456,7 @@ static void vmx_vcpu_run(struct kvm_vcpu *vcpu)
 #endif
              : "cc", "memory"
 #ifdef CONFIG_X86_64
-               , "rbx", "rcx"
-               , "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15"
-#else
-               , "ebx", "edi", "esi"
+               , "rcx", "r8", "r9", "r10", "r11"
 #endif
              );