Skip to contentSkip to conversation

KVM: Fix tsc deadline timer without irqchip_in_kernel()

PATCH In review Avi Kivity 2 participants 5 messages Oct 2, 2011

Subsystems (3)
lore
Share & tools
lore

Avi Kivity

author
#0 lore raw

PATCH 1/1 KVM: Fix tsc deadline timer without irqchip_in_kernel()

vcpu->arch.apic may be NULL.

---
 arch/x86/kvm/x86.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)
arch/x86/kvm/x86.c +7 -2
index 83b839f..aa11707 100644
@@ -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)
Signature · 1 line
1.7.6.3
#1 lore raw
Quoted 22 lines · Avi Kivity

vcpu->arch.apic may be NULL.

---
 arch/x86/kvm/x86.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)
arch/x86/kvm/x86.c +2 -0
index 83b839f..aa11707 100644
@@ -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 &&

arch/x86/kvm/x86.c static void update_cpuid(struct kvm_vcpu *vcpu) · line 625

Quoted 10 lines
arch/x86/kvm/x86.c +5 -2
 		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;

Coding style... While at it, you could also fix braces for that else.

Jan

author
#2 lore raw
Quoted 13 lines · Jan Kiszka
Quoted 4 lines

@@ -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);

Quoted 8 lines

- 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;

Quoted 2 lines

Coding style... While at it, you could also fix braces for that else.

Too late... committed and pushed, and Marcelo holds the baton now.

Signature · 1 line
error compiling committee.c: too many arguments to function
#3 lore raw
Quoted 14 lines · Avi Kivity
Quoted 13 lines · Jan Kiszka
Quoted 12 lines

@@ -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;

Quoted 4 lines
Quoted 2 lines

Coding style... While at it, you could also fix braces for that else.

Too late... committed and pushed, and Marcelo holds the baton now.

Err, sorry, this was false alarm anyway: Its perfectly valid kernel style - for the kernel, not qemu. :)

Jan

author
#4 lore raw
Quoted 15 lines · Jan Kiszka
Quoted 14 lines · Avi Kivity
Quoted 13 lines · Jan Kiszka
Quoted 12 lines

@@ -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;

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

Coding style... While at it, you could also fix braces for that else.

Too late... committed and pushed, and Marcelo holds the baton now.

Err, sorry, this was false alarm anyway: Its perfectly valid kernel style - for the kernel, not qemu. :)

Actually CodingStyle does recomment consistent bracing in the if { multiline } else singleline case.

Signature · 1 line
error compiling committee.c: too many arguments to function