kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] KVM: x86: Don't deliver PIC interrupts to disabled APICs
@ 2008-10-20  8:50 Jan Kiszka
  2008-10-20 11:51 ` Sheng Yang
  2008-10-20 12:06 ` [PATCH] KVM: x86: Don't deliver PIC interrupts to disabled APICs - v2 Jan Kiszka
  0 siblings, 2 replies; 14+ messages in thread
From: Jan Kiszka @ 2008-10-20  8:50 UTC (permalink / raw)
  To: kvm-devel; +Cc: Yang, Sheng, Avi Kivity

The locic of kvm_apic_accept_pic_intr has a minor, practically hardly
relevant incorrectness: PIC interrupts are still delivered even if the
APIC of VPU0 (BSP) is disabled. This does not comply with the Virtual
Wire mode according to the Intel MP spec.

To avoid side effects, the BSP APIC is now enabled on reset.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 arch/x86/kvm/lapic.c |   19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

Index: b/arch/x86/kvm/lapic.c
===================================================================
--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -933,7 +933,8 @@ void kvm_lapic_reset(struct kvm_vcpu *vc
 	update_divide_count(apic);
 	atomic_set(&apic->timer.pending, 0);
 	if (vcpu->vcpu_id == 0)
-		vcpu->arch.apic_base |= MSR_IA32_APICBASE_BSP;
+		vcpu->arch.apic_base |=
+			MSR_IA32_APICBASE_BSP | MSR_IA32_APICBASE_ENABLE;
 	apic_update_ppr(apic);
 
 	apic_debug(KERN_INFO "%s: vcpu=%p, id=%d, base_msr="
@@ -1089,17 +1090,15 @@ int kvm_apic_has_interrupt(struct kvm_vc
 
 int kvm_apic_accept_pic_intr(struct kvm_vcpu *vcpu)
 {
+	struct kvm_lapic *apic = vcpu->arch.apic;
 	u32 lvt0 = apic_get_reg(vcpu->arch.apic, APIC_LVT0);
-	int r = 0;
 
-	if (vcpu->vcpu_id == 0) {
-		if (!apic_hw_enabled(vcpu->arch.apic))
-			r = 1;
-		if ((lvt0 & APIC_LVT_MASKED) == 0 &&
-		    GET_APIC_DELIVERY_MODE(lvt0) == APIC_MODE_EXTINT)
-			r = 1;
-	}
-	return r;
+	/* Virtual Wire mode, but we only deliver to the BSP. */
+	if (vcpu->vcpu_id == 0 && apic_hw_enabled(apic)
+	    && !(lvt0 & APIC_LVT_MASKED)
+	    && GET_APIC_DELIVERY_MODE(lvt0) == APIC_MODE_EXTINT)
+		return 1;
+	return 0;
 }
 
 void kvm_inject_apic_timer_irqs(struct kvm_vcpu *vcpu)

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

end of thread, other threads:[~2008-10-23  8:12 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-20  8:50 [PATCH] KVM: x86: Don't deliver PIC interrupts to disabled APICs Jan Kiszka
2008-10-20 11:51 ` Sheng Yang
2008-10-20 11:56   ` Jan Kiszka
2008-10-20 12:02     ` Jan Kiszka
2008-10-20 12:06 ` [PATCH] KVM: x86: Don't deliver PIC interrupts to disabled APICs - v2 Jan Kiszka
2008-10-20 12:22   ` Sheng Yang
2008-10-22 10:22   ` Avi Kivity
2008-10-22 14:08   ` Avi Kivity
2008-10-22 15:09     ` Jan Kiszka
2008-10-22 15:12       ` Jan Kiszka
2008-10-22 15:39         ` Jan Kiszka
2008-10-22 20:44           ` Jan Kiszka
2008-10-23  1:51             ` Yang, Sheng
2008-10-23  8:11               ` Jan Kiszka

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).