From patchwork Mon May 18 11:16:49 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gleb Natapov X-Patchwork-Id: 24520 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n4IBGsYa003276 for ; Mon, 18 May 2009 11:16:54 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751727AbZERLQu (ORCPT ); Mon, 18 May 2009 07:16:50 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752656AbZERLQu (ORCPT ); Mon, 18 May 2009 07:16:50 -0400 Received: from mx2.redhat.com ([66.187.237.31]:35255 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751665AbZERLQt (ORCPT ); Mon, 18 May 2009 07:16:49 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n4IBGpaV009293 for ; Mon, 18 May 2009 07:16:51 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n4IBGom1030375; Mon, 18 May 2009 07:16:50 -0400 Received: from dhcp-1-237.tlv.redhat.com (dhcp-1-237.tlv.redhat.com [10.35.1.237]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n4IBGnWG012474; Mon, 18 May 2009 07:16:50 -0400 Received: by dhcp-1-237.tlv.redhat.com (Postfix, from userid 13519) id 6DAC018D463; Mon, 18 May 2009 14:16:49 +0300 (IDT) Date: Mon, 18 May 2009 14:16:49 +0300 From: Gleb Natapov To: avi@redhat.com Cc: kvm@vger.kernel.org Subject: Re: [PATCH] If interrupt injection is not possible do not scan IRR. Message-ID: <20090518111649.GA14536@redhat.com> References: <1242636246-11547-2-git-send-email-gleb@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1242636246-11547-2-git-send-email-gleb@redhat.com> X-Scanned-By: MIMEDefang 2.58 on 172.16.27.26 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Forget to remove debug output before submitting. Resending. Signed-off-by: Gleb Natapov --- Gleb. -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/x86/kvm/i8259.c b/arch/x86/kvm/i8259.c index 1ccb50c..d32ceac 100644 --- a/arch/x86/kvm/i8259.c +++ b/arch/x86/kvm/i8259.c @@ -218,6 +218,11 @@ int kvm_pic_read_irq(struct kvm *kvm) struct kvm_pic *s = pic_irqchip(kvm); pic_lock(s); + if (!s->output) { + pic_unlock(s); + return -1; + } + s->output = 0; irq = pic_get_irq(&s->pics[0]); if (irq >= 0) { pic_intack(&s->pics[0], irq); diff --git a/arch/x86/kvm/irq.c b/arch/x86/kvm/irq.c index 96dfbb6..e93405a 100644 --- a/arch/x86/kvm/irq.c +++ b/arch/x86/kvm/irq.c @@ -78,7 +78,6 @@ int kvm_cpu_get_interrupt(struct kvm_vcpu *v) if (vector == -1) { if (kvm_apic_accept_pic_intr(v)) { s = pic_irqchip(v->kvm); - s->output = 0; /* PIC */ vector = kvm_pic_read_irq(v->kvm); } } diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 44e87a5..854e8c9 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -3174,10 +3174,10 @@ static void inject_pending_irq(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) vcpu->arch.nmi_injected = true; kvm_x86_ops->set_nmi(vcpu); } - } else if (kvm_cpu_has_interrupt(vcpu)) { - if (kvm_x86_ops->interrupt_allowed(vcpu)) { - kvm_queue_interrupt(vcpu, kvm_cpu_get_interrupt(vcpu), - false); + } else if (kvm_x86_ops->interrupt_allowed(vcpu)) { + int vec = kvm_cpu_get_interrupt(vcpu); + if (vec != -1) { + kvm_queue_interrupt(vcpu, vec, false); kvm_x86_ops->set_irq(vcpu); } }