From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:49032) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T8uLD-0005Pm-AZ for qemu-devel@nongnu.org; Tue, 04 Sep 2012 10:43:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T8uL3-0000gT-Pk for qemu-devel@nongnu.org; Tue, 04 Sep 2012 10:42:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:27928) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T8uL3-0000gK-Fv for qemu-devel@nongnu.org; Tue, 04 Sep 2012 10:42:49 -0400 Message-ID: <5046135B.2080200@redhat.com> Date: Tue, 04 Sep 2012 16:42:35 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1346640974-30974-1-git-send-email-mmogilvi_qemu@miniinfo.net> <1346640974-30974-6-git-send-email-mmogilvi_qemu@miniinfo.net> <50446F9A.4070809@web.de> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v4 5/5] i8259: fix dynamically masking slave IRQs with IMR register List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Maciej W. Rozycki" Cc: Jan Kiszka , Matthew Ogilvie , qemu-devel@nongnu.org Il 04/09/2012 16:29, Maciej W. Rozycki ha scritto: > So first of all, the *output* of the 8259A is always edge triggered, > regardless of whether it's the master or one of the slaves (only one slave > is used in the PC/AT architecture, but up to eight are supported; the > PC/XT had none). I swear I read all your message :) but this seems to be the crux. It means that something like this ought to fix the bug too. Matthew, can you post your code or test it? diff --git a/hw/i8259.c b/hw/i8259.c index 53daf78..3dc1dff 100644 --- a/hw/i8259.c +++ b/hw/i8259.c @@ -104,12 +104,11 @@ static void pic_update_irq(PICCommonState *s) int irq; irq = pic_get_irq(s); + qemu_irq_lower(s->int_out[0]); if (irq >= 0) { DPRINTF("pic%d: imr=%x irr=%x padd=%d\n", s->master ? 0 : 1, s->imr, s->irr, s->priority_add); qemu_irq_raise(s->int_out[0]); - } else { - qemu_irq_lower(s->int_out[0]); } } The logic of the in-kernel 8259 is a bit different, but something like this should do it, too: diff --git a/arch/x86/kvm/i8259.c b/arch/x86/kvm/i8259.c index 81cf4fa..feb6d5b 100644 --- a/arch/x86/kvm/i8259.c +++ b/arch/x86/kvm/i8259.c @@ -174,9 +174,11 @@ static void pic_update_irq(struct kvm_pic *s) /* * if irq request by slave pic, signal master PIC */ + pic_set_irq1(&s->pics[0], 2, 0); pic_set_irq1(&s->pics[0], 2, 1); + } else if (s->pics[0].irr & (1 << 2)) pic_set_irq1(&s->pics[0], 2, 0); - } + irq = pic_get_irq(&s->pics[0]); pic_irq_request(s->kvm, irq >= 0); } Both patches untested. Paolo