x86, kvm, vmx: Don't set LOAD_IA32_EFER when host and guest match
authorAndy Lutomirski <luto@amacapital.net>
Mon, 10 Nov 2014 19:19:15 +0000 (11:19 -0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Wed, 12 Nov 2014 15:27:21 +0000 (16:27 +0100)
There's nothing to switch if the host and guest values are the same.
I am unable to find evidence that this makes any difference
whatsoever.

Signed-off-by: Andy Lutomirski <luto@amacapital.net>
[I could see a difference on Nehalem.  From 5 runs:

 userspace exit, guest!=host   12200 11772 12130 12164 12327
 userspace exit, guest=host    11983 11780 11920 11919 12040
 lightweight exit, guest!=host  3214  3220  3238  3218  3337
 lightweight exit, guest=host   3178  3193  3193  3187  3220

 This passes the t-test with 99% confidence for userspace exit,
 98.5% confidence for lightweight exit. - Paolo]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/vmx.c

index 0d25fc16d98bb505a1328ece7c5ab74be3db9bc7..330a08aa0291e12ecc9e872abcb70997a71bb0ab 100644 (file)
@@ -1673,7 +1673,9 @@ static bool update_transition_efer(struct vcpu_vmx *vmx, int efer_offset)
                guest_efer = vmx->vcpu.arch.efer;
                if (!(guest_efer & EFER_LMA))
                        guest_efer &= ~EFER_LME;
-               add_atomic_switch_msr(vmx, MSR_EFER, guest_efer, host_efer);
+               if (guest_efer != host_efer)
+                       add_atomic_switch_msr(vmx, MSR_EFER,
+                                             guest_efer, host_efer);
                return false;
        }