From: David Woodhouse <dwmw2@infradead.org>
To: qemu-devel@nongnu.org
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
"Paul Durrant" <paul@xen.org>,
"Joao Martins" <joao.m.martins@oracle.com>,
"Ankur Arora" <ankur.a.arora@oracle.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Thomas Huth" <thuth@redhat.com>,
"Alex Bennée" <alex.bennee@linaro.org>,
"Juan Quintela" <quintela@redhat.com>,
"Dr . David Alan Gilbert" <dgilbert@redhat.com>,
"Claudio Fontana" <cfontana@suse.de>,
"Julien Grall" <julien@xen.org>,
"Michael S. Tsirkin" <mst@redhat.com>,
"arcel Apfelbaum" <marcel.apfelbaum@gmail.com>
Subject: [RFC PATCH 0/5] Xen PIRQ support
Date: Sat, 14 Jan 2023 00:39:04 +0000 [thread overview]
Message-ID: <20230114003909.284331-1-dwmw2@infradead.org> (raw)
This continues to build on the basic Xen on KVM platform support from
https://lore.kernel.org/qemu-devel/20230110122042.1562155-1-dwmw2@infradead.org/
We're working on hooking up the PV backend devices, and the biggest
remaining noticeably missing part was PIRQ support. This allows a Xen
guest to route GSI and MSI interrupts to event channels instead of being
delivered via the emulated I/OAPIC or local APIC respectively.
It starts relatively simple, with the basic hypercalls and infrastructure
for tracking/migrating the PIRQ table (and as I type this I've just
remembered I forgot to write the post_load function to reconstitute the
data structures which explicitly *state* that they need to be rebuilt).
I'm particularly interested in opinions on the hook in gsi_handler()
which lets the Xen emulation 'eat' the event instead of passing it to
the I/OAPIC.
I did ponder replacing the qemu_irq in gsi_state->ioapic_irq[n] when
GSI#n is redirected to a PIRQ, but I figured that was worse.
I definitely need to rethink the locking a little bit to avoid the
potential for deadlock when gsi_handler calls back into the evtchn code
to translate the event channel GSI. It's non-trivial to drop the lock
before sending the IRQ; maybe just a different lock with a smaller
scope. A previous implementation of event channels was a bit more
lockless, with atomic updates of the port table (the port_info fits in a
uint64_t). But now we have all the interesting fast paths accelerated in
the kernel that didn't seem worth it, so I went with simple locking...
too simple, it seems.
There's a similar recursive locking issue when pirq_bind_port() wants to
call kvm_update_msi_routes_all(), but is already holding the lock that
we'd take again when called to redo a translation. (And I still don't
much like the way that kvm_update_msi_routes_all() has to have a list of
PCI devices and actually recalculates the routes at all, instead of just
detaching the IRQFD and letting them be recalculated on demand. But I
was trying to avoid actually fixing that this week).
David Woodhouse (5):
i386/xen: Implement HYPERVISOR_physdev_op
hw/xen: Implement emulated PIRQ hypercall support
hw/xen: Support GSI mapping to PIRQ
hw/xen: [FIXME] Avoid deadlock in xen_evtchn_set_gsi()
hw/xen: Support MSI mapping to PIRQ
hw/i386/kvm/trace-events | 4 ++
hw/i386/kvm/trace.h | 1 +
hw/i386/kvm/xen-stubs.c | 11 ++++
hw/i386/kvm/xen_evtchn.c | 461 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
hw/i386/kvm/xen_evtchn.h | 22 +++++++
hw/i386/x86.c | 15 +++++
hw/pci/msi.c | 13 ++++
hw/pci/msix.c | 7 ++-
hw/pci/pci.c | 14 +++++
meson.build | 1 +
target/i386/kvm/kvm.c | 12 +++-
target/i386/kvm/kvm_i386.h | 2 +
target/i386/kvm/xen-compat.h | 19 ++++++
target/i386/kvm/xen-emu.c | 136 +++++++++++++++++++++++++++++++++++++++++-
14 files changed, 712 insertions(+), 6 deletions(-)
next reply other threads:[~2023-01-14 0:39 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-14 0:39 David Woodhouse [this message]
2023-01-14 0:39 ` [RFC PATCH 1/5] i386/xen: Implement HYPERVISOR_physdev_op David Woodhouse
2023-01-14 0:39 ` [RFC PATCH 2/5] hw/xen: Implement emulated PIRQ hypercall support David Woodhouse
2023-01-14 0:39 ` [RFC PATCH 3/5] hw/xen: Support GSI mapping to PIRQ David Woodhouse
2023-01-14 0:39 ` [RFC PATCH 4/5] hw/xen: [FIXME] Avoid deadlock in xen_evtchn_set_gsi() David Woodhouse
2023-01-16 11:27 ` David Woodhouse
2023-01-14 0:39 ` [RFC PATCH 5/5] hw/xen: Support MSI mapping to PIRQ David Woodhouse
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=20230114003909.284331-1-dwmw2@infradead.org \
--to=dwmw2@infradead.org \
--cc=alex.bennee@linaro.org \
--cc=ankur.a.arora@oracle.com \
--cc=cfontana@suse.de \
--cc=dgilbert@redhat.com \
--cc=joao.m.martins@oracle.com \
--cc=julien@xen.org \
--cc=marcel.apfelbaum@gmail.com \
--cc=mst@redhat.com \
--cc=paul@xen.org \
--cc=pbonzini@redhat.com \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
--cc=thuth@redhat.com \
/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).