KVM: LAPIC: guarantee the timer is in tsc-deadline mode
authorWanpeng Li <wanpeng.li@hotmail.com>
Mon, 24 Oct 2016 10:23:10 +0000 (18:23 +0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Wed, 2 Nov 2016 20:32:17 +0000 (21:32 +0100)
Check apic_lvtt_tscdeadline() mode directly instead of apic_lvtt_oneshot()
and apic_lvtt_period() to guarantee the timer is in tsc-deadline mode when
rdmsr MSR_IA32_TSCDEADLINE.

Suggested-by: Radim Krčmář <rkrcmar@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Radim Krčmář <rkrcmar@redhat.com>
Cc: Yunhong Jiang <yunhong.jiang@intel.com>
Signed-off-by: Wanpeng Li <wanpeng.li@hotmail.com>
Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
arch/x86/kvm/lapic.c

index dad743e3c1f532f431c93da7b43795fb7cc4e3cc..dce6c0bf2a21a2a07be92cc33c5a2cfa543e83ca 100644 (file)
@@ -1711,8 +1711,8 @@ u64 kvm_get_lapic_tscdeadline_msr(struct kvm_vcpu *vcpu)
 {
        struct kvm_lapic *apic = vcpu->arch.apic;
 
-       if (!lapic_in_kernel(vcpu) || apic_lvtt_oneshot(apic) ||
-                       apic_lvtt_period(apic))
+       if (!lapic_in_kernel(vcpu) ||
+               !apic_lvtt_tscdeadline(apic))
                return 0;
 
        return apic->lapic_timer.tscdeadline;