From: David Woodhouse <dwmw2@infradead.org>
To: Peter Xu <peterx@redhat.com>
Cc: "Michael S. Tsirkin" <mst@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>,
qemu-devel <qemu-devel@nongnu.org>
Subject: Re: [PATCH] hw/intc/ioapic: Update KVM routes before redelivering IRQ, on RTE update
Date: Sat, 11 Mar 2023 10:40:58 +0000 [thread overview]
Message-ID: <612c04cb7eea15a084904c836fe0c5eb021aee28.camel@infradead.org> (raw)
In-Reply-To: <ZAuPV0kTb0ruFihj@x1n>
[-- Attachment #1: Type: text/plain, Size: 2344 bytes --]
On Fri, 2023-03-10 at 15:13 -0500, Peter Xu wrote:
>
> >
> > It'll *broadly* look like the existing kvm_irqchip_* functions but be a
> > lot simpler to use.
>
> IIUC what's missing is the reverse chain of notifications from e.g. IRTE to
> the device, either via MSIs or via some pins of IOAPIC.
For the translation we don't need a reverse path.
When a range of 'cookies' is invalidated, the generic irqroute code
just kicks the irqfd out of the routing table.
That means the device code gets notified by its *own* eventfd. It tries
to say "deliver <this> virq", gets a "nope, it's invalid", and then
reprovides the original MSI information to be (re)translated (and to
raise a fault if it's invalid now).
Looks a bit like this...
if (timer.gsi == static_cast<uint32_t>(-1))
return -1;
if (irqchip_try_deliver_gsi(timer.gsi) >= 0)
return 0;
struct kvm_msi msi = read_timer_msi_reg(timer);
if (irqchip_update_msi(timer.gsi, &msi, deliver_now = true) < 0)
errno = 0;
Now, for the interrupt *acknowledge* (kvm_resample_fd_notify) we
absolutely need a reverse path, and we need that anyway regardless of
KVM routing — VFIO and the Xen event channel GSI can both be massively
cleaned up if we have that wired up from the EOI/intack. But that's
*mostly* a separate issue, except that of course we want to wire that
resamplefd up in the routing table *too* and make things consistent in
userspace vs. KVM.
> I don't think I have very good knowledge on the whole IRQ path yet so I
> can't really tell anything useful, but what you said looks like a good
> thing to have. If it can cleanup things besides achieving the goal of
> fault irq reporting it could be more worthwhile.
Yeah, that's definitely the intent.
When I first started playing with this in order to implement interrupt
remapping in my other VMM, I carefully drew out state diagrams in
pencil, tracking which eventfd was connected to userspace/KVM in
different states across first-trigger/masking/unmasking/live-update,
with a large 'WTF!!!' on the one of the state transitions from masked
to unmasked, when the IRQ happened anyway.
For QEMU I haven't even been able to write it out, because the logic is
split across different devices and handled differently in each. I think
it can be really simple.
[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5965 bytes --]
prev parent reply other threads:[~2023-03-11 10:41 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-05 18:43 [PATCH] hw/intc/ioapic: Update KVM routes before redelivering IRQ, on RTE update David Woodhouse
2023-03-05 22:36 ` Peter Xu
2023-03-06 6:51 ` David Woodhouse
2023-03-06 9:25 ` David Woodhouse
2023-03-06 16:39 ` Peter Xu
2023-03-06 17:28 ` David Woodhouse
2023-03-08 23:09 ` Peter Xu
2023-03-09 9:16 ` David Woodhouse
2023-03-09 16:55 ` Peter Xu
2023-03-09 19:56 ` David Woodhouse
2023-03-10 17:52 ` David Woodhouse
2023-03-10 20:13 ` Peter Xu
2023-03-11 10:40 ` David Woodhouse [this message]
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=612c04cb7eea15a084904c836fe0c5eb021aee28.camel@infradead.org \
--to=dwmw2@infradead.org \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peterx@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).