KVM: VMX: Optimize VMX instruction error and fault handling
authorSean Christopherson <sean.j.christopherson@intel.com>
Fri, 19 Jul 2019 20:41:07 +0000 (13:41 -0700)
committerPaolo Bonzini <pbonzini@redhat.com>
Wed, 25 Sep 2019 13:30:02 +0000 (15:30 +0200)
commit52a9fcbc73a30375cad8d9e7b519e1ad97b0880a
tree812106f6a34356896c0e3cb25c2b76cf60987208
parent4b526de50e39b38cd828396267379183c7c21354
KVM: VMX: Optimize VMX instruction error and fault handling

Rework the VMX instruction helpers using asm-goto to branch directly
to error/fault "handlers" in lieu of using __ex(), i.e. the generic
____kvm_handle_fault_on_reboot().  Branching directly to fault handling
code during fixup avoids the extra JMP that is inserted after every VMX
instruction when using the generic "fault on reboot" (see commit
3901336ed9887, "x86/kvm: Don't call kvm_spurious_fault() from .fixup").

Opportunistically clean up the helpers so that they all have consistent
error handling and messages.

Leave the usage of ____kvm_handle_fault_on_reboot() (via __ex()) in
kvm_cpu_vmxoff() and nested_vmx_check_vmentry_hw() as is.  The VMXOFF
case is not a fast path, i.e. the cleanliness of __ex() is worth the
JMP, and the extra JMP in nested_vmx_check_vmentry_hw() is unavoidable.

Note, VMREAD cannot get the asm-goto treatment as output operands aren't
compatible with GCC's asm-goto due to internal compiler restrictions.

Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/vmx/ops.h
arch/x86/kvm/vmx/vmx.c