kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] KVM: Fix tsc deadline timer without irqchip_in_kernel()
@ 2011-10-02  9:51 Avi Kivity
  2011-10-02 16:28 ` Jan Kiszka
  0 siblings, 1 reply; 5+ messages in thread
From: Avi Kivity @ 2011-10-02  9:51 UTC (permalink / raw)
  To: kvm, Marcelo Tosatti; +Cc: Jinsong Liu

vcpu->arch.apic may be NULL.

Signed-off-by: Avi Kivity <avi@redhat.com>
---
 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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-10-02 17:01 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-02  9:51 [PATCH] KVM: Fix tsc deadline timer without irqchip_in_kernel() Avi Kivity
2011-10-02 16:28 ` Jan Kiszka
2011-10-02 16:30   ` Avi Kivity
2011-10-02 16:33     ` Jan Kiszka
2011-10-02 17:01       ` Avi Kivity

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).