From: David Woodhouse <dwmw2@infradead.org>
To: qemu-devel <qemu-devel@nongnu.org>
Cc: "Michael S. Tsirkin" <mst@redhat.com>,
Marcel Apfelbaum <marcel.apfelbaum@gmail.com>,
Joel Upham <jupham125@gmail.com>
Subject: [PATCH] hw/isa/ich9: Add comment on imperfect emulation of PIC vs. I/O APIC routing
Date: Wed, 30 Aug 2023 20:59:43 +0100 [thread overview]
Message-ID: <112a09643b8191c4eae7d92fa247a861ab90a9ee.camel@infradead.org> (raw)
[-- Attachment #1: Type: text/plain, Size: 1931 bytes --]
From: David Woodhouse <dwmw@amazon.co.uk>
As noted in the comment, the PCI INTx lines are supposed to be routed
to *both* the PIC and the I/O APIC. It's just that we don't cope with
the concept of an IRQ being asserted to two *different* pins on the
two irqchips.
So we have this hack of routing to I/O APIC only if the PIRQ routing to
the PIC is disabled. Which seems to work well enough, even when I try
hard to break it with kexec. But should be explicitly documented and
understood.
Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
---
hw/isa/lpc_ich9.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/hw/isa/lpc_ich9.c b/hw/isa/lpc_ich9.c
index 9c47a2f6c7..399fd04b6b 100644
--- a/hw/isa/lpc_ich9.c
+++ b/hw/isa/lpc_ich9.c
@@ -304,6 +304,21 @@ static PCIINTxRoute ich9_route_intx_pin_to_irq(void *opaque, int pirq_pin)
route.irq = -1;
}
} else {
+ /*
+ * Strictly speaking, this is wrong. The PIRQ should be routed
+ * to *both* the I/O APIC and the PIC, on different pins. The
+ * I/O APIC has a fixed mapping to IRQ16-23, while the PIC is
+ * routed according to the PIRQx_ROUT configuration. But QEMU
+ * doesn't (yet) cope with the concept of pin numbers differing
+ * between PIC and I/O APIC, and neither does the in-kernel KVM
+ * irqchip support. So we route to the I/O APIC *only* if the
+ * routing to the PIC is disabled in the PIRQx_ROUT settings.
+ *
+ * This seems to work even if we boot a Linux guest with 'noapic'
+ * to make it use the legacy PIC, and then kexec directly into a
+ * new kernel which uses the I/O APIC. The new kernel explicitly
+ * disables the PIRQ routing even though it doesn't need to care.
+ */
route.irq = ich9_pirq_to_gsi(pirq_pin);
}
--
2.34.1
[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5965 bytes --]
reply other threads:[~2023-08-30 20:01 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=112a09643b8191c4eae7d92fa247a861ab90a9ee.camel@infradead.org \
--to=dwmw2@infradead.org \
--cc=jupham125@gmail.com \
--cc=marcel.apfelbaum@gmail.com \
--cc=mst@redhat.com \
--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).