KVM: nVMX: Really make emulated nested preemption timer pinned
authorJim Mattson <jmattson@google.com>
Fri, 8 May 2020 20:36:41 +0000 (13:36 -0700)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 15 May 2020 16:26:24 +0000 (12:26 -0400)
The PINNED bit is ignored by hrtimer_init. It is only considered when
starting the timer.

When the hrtimer isn't pinned to the same logical processor as the
vCPU thread to be interrupted, the emulated VMX-preemption timer
often fails to adhere to the architectural specification.

Fixes: f15a75eedc18e ("KVM: nVMX: make emulated nested preemption timer pinned")
Signed-off-by: Jim Mattson <jmattson@google.com>
Reviewed-by: Peter Shier <pshier@google.com>
Reviewed-by: Oliver Upton <oupton@google.com>
Message-Id: <20200508203643.85477-2-jmattson@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/vmx/nested.c

index 25f130d3158bb64b2fb8f9067b7180d5b8698ace..3d50e50de6266ebf2a4ead936c37ea5430a1df27 100644 (file)
@@ -2113,7 +2113,7 @@ static void vmx_start_preemption_timer(struct kvm_vcpu *vcpu)
        preemption_timeout *= 1000000;
        do_div(preemption_timeout, vcpu->arch.virtual_tsc_khz);
        hrtimer_start(&vmx->nested.preemption_timer,
-                     ns_to_ktime(preemption_timeout), HRTIMER_MODE_REL);
+                     ns_to_ktime(preemption_timeout), HRTIMER_MODE_REL_PINNED);
 }
 
 static u64 nested_vmx_calc_efer(struct vcpu_vmx *vmx, struct vmcs12 *vmcs12)