qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Matthew Ogilvie <mmogilvi_qemu@miniinfo.net>
To: qemu-devel@nongnu.org
Cc: "Maciej W. Rozycki" <macro@linux-mips.org>,
	Jan Kiszka <jan.kiszka@web.de>,
	Matthew Ogilvie <mmogilvi_qemu@miniinfo.net>,
	Gleb Natapov <gleb@redhat.com>
Subject: [Qemu-devel] [PATCH v8 06/10] i8259: fix so that dropping IRQ level always clears the interrupt request
Date: Sun, 16 Dec 2012 16:56:25 -0700	[thread overview]
Message-ID: <1355702189-6994-7-git-send-email-mmogilvi_qemu@miniinfo.net> (raw)
In-Reply-To: <1355702189-6994-1-git-send-email-mmogilvi_qemu@miniinfo.net>

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 <mmogilvi_qemu@miniinfo.net>
---

There is a risk that some other device models depend on the broken
behavior.  See my question about qemu_irq_pulse() in the cover
letter.

 hw/i8259.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/i8259.c b/hw/i8259.c
index 60c25ba..95587cd 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;
         }
     }
-- 
1.7.10.2.484.gcd07cc5

  parent reply	other threads:[~2012-12-16 23:56 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-16 23:56 [Qemu-devel] [PATCH v8 00/10] i8254, i8259 and running Microport UNIX (ca 1987) Matthew Ogilvie
2012-12-16 23:56 ` [Qemu-devel] [PATCH v8 01/10] fix some debug printf format strings Matthew Ogilvie
2012-12-16 23:56 ` [Qemu-devel] [PATCH v8 02/10] vl: fix -hdachs/-hda argument order parsing issues Matthew Ogilvie
2012-12-16 23:56 ` [Qemu-devel] [PATCH v8 03/10] qemu-options.hx: mention retrace= VGA option Matthew Ogilvie
2012-12-16 23:56 ` [Qemu-devel] [PATCH v8 04/10] vga: add some optional CGA compatibility hacks Matthew Ogilvie
2012-12-16 23:56 ` [Qemu-devel] [PATCH v8 05/10] fix i8254 output logic to match the spec Matthew Ogilvie
2012-12-16 23:56 ` Matthew Ogilvie [this message]
2012-12-16 23:56 ` [Qemu-devel] [PATCH v8 07/10] i8259: refactor pic_set_irq level logic Matthew Ogilvie
2012-12-16 23:56 ` [Qemu-devel] [PATCH v8 08/10] qtest: fix qemu_irq_intercept_out() Matthew Ogilvie
2012-12-16 23:56 ` [Qemu-devel] [PATCH v8 09/10] qtest: add set_irq_{in, out} infrastructure for testing interrupt controllers Matthew Ogilvie
2012-12-16 23:56 ` [Qemu-devel] [PATCH v8 10/10] add test/pic-test.c Matthew Ogilvie

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=1355702189-6994-7-git-send-email-mmogilvi_qemu@miniinfo.net \
    --to=mmogilvi_qemu@miniinfo.net \
    --cc=gleb@redhat.com \
    --cc=jan.kiszka@web.de \
    --cc=macro@linux-mips.org \
    --cc=qemu-devel@nongnu.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).