From: Avi Kivity Subject: [PATCH] KVM: Fix tsc deadline timer without irqchip_in_kernel() Date: Sun, 2 Oct 2011 11:51:06 +0200 Message-ID: <1317549066-10582-1-git-send-email-avi@redhat.com> Cc: "Jinsong Liu" To: kvm@vger.kernel.org, Marcelo Tosatti Return-path: Received: from mx1.redhat.com ([209.132.183.28]:1167 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751994Ab1JBJvX (ORCPT ); Sun, 2 Oct 2011 05:51:23 -0400 Sender: kvm-owner@vger.kernel.org List-ID: vcpu->arch.apic may be NULL. Signed-off-by: Avi Kivity --- arch/x86/kvm/x86.c | 9 +++++++-- 1 files changed, 7 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 83b839f..aa11707 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -600,6 +600,8 @@ static bool guest_cpuid_has_fsgsbase(struct kvm_vcpu *vcpu) static void update_cpuid(struct kvm_vcpu *vcpu) { struct kvm_cpuid_entry2 *best; + struct kvm_lapic *apic = vcpu->arch.apic; + u32 timer_mode_mask; best = kvm_find_cpuid_entry(vcpu, 1, 0); if (!best) @@ -615,9 +617,12 @@ static void update_cpuid(struct kvm_vcpu *vcpu) if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL && best->function == 0x1) { best->ecx |= bit(X86_FEATURE_TSC_DEADLINE_TIMER); - vcpu->arch.apic->lapic_timer.timer_mode_mask = (3 << 17); + timer_mode_mask = 3 << 17; } else - vcpu->arch.apic->lapic_timer.timer_mode_mask = (1 << 17); + timer_mode_mask = 1 << 17; + + if (apic) + apic->lapic_timer.timer_mode_mask = timer_mode_mask; } int kvm_set_cr4(struct kvm_vcpu *vcpu, unsigned long cr4) -- 1.7.6.3