All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@siemens.com>
To: kvm-devel <kvm@vger.kernel.org>
Cc: "Yang, Sheng" <sheng.yang@intel.com>, Avi Kivity <avi@redhat.com>
Subject: [PATCH] KVM: x86: Don't deliver PIC interrupts to disabled APICs - v2
Date: Mon, 20 Oct 2008 14:06:13 +0200	[thread overview]
Message-ID: <48FC7435.4020707@siemens.com> (raw)
In-Reply-To: <48FC4671.90409@siemens.com>

[ taking Sheng's comments into account ]

The logic 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.

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

Index: b/arch/x86/kvm/lapic.c
===================================================================
--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -1089,17 +1089,18 @@ int kvm_apic_has_interrupt(struct kvm_vc
 
 int kvm_apic_accept_pic_intr(struct kvm_vcpu *vcpu)
 {
-	u32 lvt0 = apic_get_reg(vcpu->arch.apic, APIC_LVT0);
-	int r = 0;
+	struct kvm_lapic *apic = vcpu->arch.apic;
+	u32 lvt0 = apic_get_reg(apic, APIC_LVT0);
 
-	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.
+	 * Note that apic_sw_enabled() is covered by testing for !LVT_MASKED.
+	 */
+	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)

  parent reply	other threads:[~2008-10-20 12:06 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` Jan Kiszka [this message]
2008-10-20 12:22   ` [PATCH] KVM: x86: Don't deliver PIC interrupts to disabled APICs - v2 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=48FC7435.4020707@siemens.com \
    --to=jan.kiszka@siemens.com \
    --cc=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=sheng.yang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.