KVM: nVMX: Don't "put" vCPU or host state when switching VMCS
authorSean Christopherson <sean.j.christopherson@intel.com>
Tue, 7 May 2019 16:06:31 +0000 (09:06 -0700)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 18 Jun 2019 09:46:55 +0000 (11:46 +0200)
commit13b964a29d66333c1957dbd51f2c9e138c546f7a
treec3ece7599e79a1e7860e4b95b8ebd6526602b2f9
parentb464f57e133d8c751ca1fb4af039c808b873876b
KVM: nVMX: Don't "put" vCPU or host state when switching VMCS

When switching between vmcs01 and vmcs02, KVM isn't actually switching
between guest and host.  If guest state is already loaded (the likely,
if not guaranteed, case), keep the guest state loaded and manually swap
the loaded_cpu_state pointer after propagating saved host state to the
new vmcs0{1,2}.

Avoiding the switch between guest and host reduces the latency of
switching between vmcs01 and vmcs02 by several hundred cycles, and
reduces the roundtrip time of a nested VM by upwards of 1000 cycles.

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