From patchwork Mon Oct 1 04:56:36 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Ogilvie X-Patchwork-Id: 188218 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 8744A2C00E1 for ; Mon, 1 Oct 2012 15:24:44 +1000 (EST) Received: from localhost ([::1]:44706 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TIYA4-0000Db-GU for incoming@patchwork.ozlabs.org; Mon, 01 Oct 2012 01:03:20 -0400 Received: from eggs.gnu.org ([208.118.235.92]:59122) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TIY9H-0006cG-F4 for qemu-devel@nongnu.org; Mon, 01 Oct 2012 01:02:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TIY9G-0007gf-AK for qemu-devel@nongnu.org; Mon, 01 Oct 2012 01:02:31 -0400 Received: from qmta09.emeryville.ca.mail.comcast.net ([76.96.30.96]:42095) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TIY9G-0007gS-26 for qemu-devel@nongnu.org; Mon, 01 Oct 2012 01:02:30 -0400 Received: from omta10.emeryville.ca.mail.comcast.net ([76.96.30.28]) by qmta09.emeryville.ca.mail.comcast.net with comcast id 5gwa1k0020cQ2SLA9h2VYt; Mon, 01 Oct 2012 05:02:29 +0000 Received: from mmogilvi.homeip.net ([24.9.53.136]) by omta10.emeryville.ca.mail.comcast.net with comcast id 5gxT1k00R2wKXRC8WgxU6n; Mon, 01 Oct 2012 04:57:29 +0000 Received: by mmogilvi.homeip.net (Postfix, from userid 501) id BF9601E9601C; Sun, 30 Sep 2012 22:57:27 -0600 (MDT) From: Matthew Ogilvie To: qemu-devel@nongnu.org Date: Sun, 30 Sep 2012 22:56:36 -0600 Message-Id: <1349067398-9578-7-git-send-email-mmogilvi_qemu@miniinfo.net> X-Mailer: git-send-email 1.7.10.2.484.gcd07cc5 In-Reply-To: <1349067398-9578-1-git-send-email-mmogilvi_qemu@miniinfo.net> References: <1349067398-9578-1-git-send-email-mmogilvi_qemu@miniinfo.net> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 76.96.30.96 Cc: Paolo Bonzini , Jan Kiszka , Matthew Ogilvie , "Maciej W. Rozycki" , Avi Kivity Subject: [Qemu-devel] [PATCH v6 6/8] i8259: fix so that dropping IRQ level always clears the interrupt request X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Intel's definition of "edge triggered" means: "asserted with a low-to-high transition at the time an interrupt is registered and then kept high until the interrupt is served via one of the EOI mechanisms or goes away unhandled." So the only difference between edge triggered and level triggered is in the leading edge, with no difference in the trailing edge. This bug manifested itself when the guest was Microport UNIX System V/386 v2.1 (ca. 1987), because it would sometimes mask off IRQ14 in the slave IMR after it had already been asserted. The master would still try to deliver an interrupt even though IRQ2 had dropped again, resulting in a spurious interupt (IRQ15) and a panicked kernel. Output from a test program: ----------- Real hardware [Pentium 4]: cmdRead unmask IRR=4005 mask IRR=4001 sti unmask irq14 IRR=0001 DONE [I also see a final IRR=0000 occasionally. Probably just happened to ask it while the timer (IRQ0) line is low. It masks off most IRQ's, including timer.] ----------- Unpatched qemu: cmdRead unmask IRR=4015 mask IRR=4015 sti irq15 unmask IRR=4015 DONE [Presumably IRQ4 (0x10 - qemu's serial device model?) had a transient edge during initialization, but had been masked off even before I masked it off?] ----------- Patched qemu: cmdRead unmask IRR=4005 mask IRR=4001 sti unmask irq14 IRR=0001 DONE ----------- Signed-off-by: Matthew Ogilvie --- hw/i8259.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/i8259.c b/hw/i8259.c index 6587666..c011787 100644 --- a/hw/i8259.c +++ b/hw/i8259.c @@ -157,6 +157,7 @@ static void pic_set_irq(void *opaque, int irq, int level) } s->last_irr |= mask; } else { + s->irr &= ~mask; s->last_irr &= ~mask; } }