KVM: SVM: move VMLOAD/VMSAVE to C code
authorPaolo Bonzini <pbonzini@redhat.com>
Tue, 9 Feb 2021 12:10:43 +0000 (07:10 -0500)
committerPaolo Bonzini <pbonzini@redhat.com>
Mon, 15 Mar 2021 08:43:23 +0000 (04:43 -0400)
Thanks to the new macros that handle exception handling for SVM
instructions, it is easier to just do the VMLOAD/VMSAVE in C.
This is safe, as shown by the fact that the host reload is
already done outside the assembly source.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/svm/svm.c
arch/x86/kvm/svm/vmenter.S

index 74f2658..e91b228 100644 (file)
@@ -3717,7 +3717,9 @@ static noinstr void svm_vcpu_enter_exit(struct kvm_vcpu *vcpu)
        } else {
                struct svm_cpu_data *sd = per_cpu(svm_data, vcpu->cpu);
 
+               vmload(svm->vmcb_pa);
                __svm_vcpu_run(svm->vmcb_pa, (unsigned long *)&vcpu->arch.regs);
+               vmsave(svm->vmcb_pa);
 
                vmload(__sme_page_pa(sd->save_area));
        }
index 6feb8c0..343108b 100644 (file)
@@ -79,12 +79,6 @@ SYM_FUNC_START(__svm_vcpu_run)
 
        /* Enter guest mode */
        sti
-1:     vmload %_ASM_AX
-       jmp 3f
-2:     cmpb $0, kvm_rebooting
-       jne 3f
-       ud2
-       _ASM_EXTABLE(1b, 2b)
 
 3:     vmrun %_ASM_AX
        jmp 5f
@@ -93,13 +87,7 @@ SYM_FUNC_START(__svm_vcpu_run)
        ud2
        _ASM_EXTABLE(3b, 4b)
 
-5:     vmsave %_ASM_AX
-       jmp 7f
-6:     cmpb $0, kvm_rebooting
-       jne 7f
-       ud2
-       _ASM_EXTABLE(5b, 6b)
-7:
+5:
        cli
 
 #ifdef CONFIG_RETPOLINE