From patchwork Tue Aug 4 12:30:28 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gleb Natapov X-Patchwork-Id: 39103 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 n74CUkRM007016 for ; Tue, 4 Aug 2009 12:30:46 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755407AbZHDMac (ORCPT ); Tue, 4 Aug 2009 08:30:32 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1755406AbZHDMac (ORCPT ); Tue, 4 Aug 2009 08:30:32 -0400 Received: from mx2.redhat.com ([66.187.237.31]:57058 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755385AbZHDMab (ORCPT ); Tue, 4 Aug 2009 08:30:31 -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 n74CUWc9004936 for ; Tue, 4 Aug 2009 08:30:32 -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 n74CUVVx005788; Tue, 4 Aug 2009 08:30:31 -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 n74CUUXq024177; Tue, 4 Aug 2009 08:30:30 -0400 Received: by dhcp-1-237.tlv.redhat.com (Postfix, from userid 13519) id EF8BF137B28; Tue, 4 Aug 2009 15:30:29 +0300 (IDT) From: Gleb Natapov To: avi@redhat.com Cc: kvm@vger.kernel.org Subject: [PATCH 2/3] Call ack notifiers from PIC when guest OS acks an IRQ. Date: Tue, 4 Aug 2009 15:30:28 +0300 Message-Id: <1249389029-12801-3-git-send-email-gleb@redhat.com> In-Reply-To: <1249389029-12801-1-git-send-email-gleb@redhat.com> References: <1249389029-12801-1-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 Currently they are called when irq vector is been delivered. Calling ack notifiers at this point is wrong. Device assignment ack notifier enables host interrupts, but guest not yet had a chance to clear interrupt condition in a device. Signed-off-by: Gleb Natapov --- arch/x86/kvm/i8259.c | 18 ++++-------------- 1 files changed, 4 insertions(+), 14 deletions(-) diff --git a/arch/x86/kvm/i8259.c b/arch/x86/kvm/i8259.c index d27320c..3aacd33 100644 --- a/arch/x86/kvm/i8259.c +++ b/arch/x86/kvm/i8259.c @@ -41,25 +41,16 @@ static void pic_lock(struct kvm_pic *s) static void pic_unlock(struct kvm_pic *s) __releases(&s->lock) { - struct kvm *kvm = s->kvm; - unsigned acks = s->pending_acks; - struct kvm_vcpu *vcpu; - - s->pending_acks = 0; - spin_unlock(&s->lock); - - while (acks) { - kvm_notify_acked_irq(kvm, SELECT_PIC(__ffs(acks)), - __ffs(acks)); - acks &= acks - 1; - } } static void pic_clear_isr(struct kvm_kpic_state *s, int irq) { s->isr &= ~(1 << irq); s->isr_ack |= (1 << irq); + if (s != &s->pics_state->pics[0]) + irq += 8; + kvm_notify_acked_irq(s->pics_state->kvm, SELECT_PIC(irq), irq); } void kvm_pic_clear_isr_ack(struct kvm *kvm) @@ -240,7 +231,6 @@ int kvm_pic_read_irq(struct kvm *kvm) } pic_update_irq(s); pic_unlock(s); - kvm_notify_acked_irq(kvm, SELECT_PIC(irq), irq); return intno; } @@ -260,7 +250,7 @@ void kvm_pic_reset(struct kvm_kpic_state *s) if (vcpu0 && kvm_apic_accept_pic_intr(vcpu0)) if (s->irr & (1 << irq) || s->isr & (1 << irq)) { n = irq + irqbase; - s->pics_state->pending_acks |= 1 << n; + kvm_notify_acked_irq(kvm, SELECT_PIC(n), n); } } s->last_irr = 0;