All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dmytro Maluka <dmy@semihalf.com>
To: eric.auger@redhat.com, Micah Morton <mortonm@chromium.org>
Cc: Alex Williamson <alex.williamson@redhat.com>,
	kvm@vger.kernel.org, Sean Christopherson <seanjc@google.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Rong L Liu <rong.l.liu@intel.com>,
	Tomasz Nowicki <tn@semihalf.com>,
	Grzegorz Jaszczyk <jaz@semihalf.com>,
	Dmitry Torokhov <dtor@google.com>
Subject: Re: Add vfio-platform support for ONESHOT irq forwarding?
Date: Thu, 7 Jul 2022 11:15:33 +0200	[thread overview]
Message-ID: <d6f3205c-6229-3b58-cdc2-a5d0f6cfb98f@semihalf.com> (raw)
In-Reply-To: <0a974041-0c61-e98b-d335-76f94618b5a7@redhat.com>

Hi Eric,

On 7/7/22 10:25 AM, Eric Auger wrote:
>> Again, this doesn't seem to be true. Just as explained in my above
>> reply to Alex, the guest deactivates (EOI) the vIRQ already after the
>> completion of the vIRQ hardirq handler, not the vIRQ thread.
>>
>> So VFIO unmask handler gets called too early, before the interrupt
>> gets serviced and acked in the vIRQ thread.
> Fair enough, on vIRQ hardirq handler the physical IRQ gets unmasked.
> This event occurs on guest EOI, which triggers the resamplefd. But what
> is the state of the vIRQ? Isn't it stil masked until the vIRQ thread
> completes, preventing the physical IRQ from being propagated to the guest?

Even if vIRQ is still masked by the time when 
vfio_automasked_irq_handler() signals the eventfd (which in itself is 
not guaranteed, I guess), I believe KVM is buffering this event, so 
after the vIRQ is unmasked, this new IRQ will be injected to the guest 
anyway.

>> It seems the obvious fix is to postpone sending irq ack notifications
>> in KVM from EOI to unmask (for oneshot interrupts only). Luckily, we
>> don't need to provide KVM with the info that the given interrupt is
>> oneshot. KVM can just find it out from the fact that the interrupt is
>> masked at the time of EOI.
> you mean the vIRQ right?

Right.

> Before going further and we invest more time in that thread, please
> could you give us additional context info and confidence
> in/understanding of the stakes. This thread is from Jan 2021 and was
> discontinued for a while. vfio-platform currently only is enabled on ARM
> and maintained for very few devices which properly implement reset
> callbacks and duly use an underlying IOMMU.

Sure. We are not really using vfio-platform for the devices we are 
concerned with, since those are not DMA capable devices, and some of 
them are not really platform devices but I2C or SPI devices. Instead we 
are using (hopefully temporarily) Micah's module for forwarding 
arbitrary IRQs [1][2] which mostly reimplements the VFIO irq forwarding 
mechanism.

Also with a few simple hacks I managed to use vfio-platform for the same 
thing (just as a PoC) and confirmed, unsurprisingly, that the problems 
with oneshot interrupts are observed with vfio-platform as well.

[1] 
https://chromium.googlesource.com/chromiumos/third_party/kernel/+/refs/heads/chromeos-5.10-manatee/virt/lib/platirqforward.c

[2] 
https://lkml.kernel.org/kvm/CAJ-EccPU8KpU96PM2PtroLjdNVDbvnxwKwWJr2B+RBKuXEr7Vw@mail.gmail.com/T/

Thanks,
Dmytro

  reply	other threads:[~2022-07-07  9:17 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-25 15:46 Add vfio-platform support for ONESHOT irq forwarding? Micah Morton
2021-01-25 17:31 ` Auger Eric
2021-01-25 18:32   ` Micah Morton
2021-01-26  8:48     ` Auger Eric
2021-01-26 15:31       ` Micah Morton
2021-01-26 16:05         ` Auger Eric
2021-01-25 20:36 ` Alex Williamson
2021-01-26  8:53   ` Auger Eric
2021-01-26 15:15     ` Micah Morton
2021-01-26 16:19       ` Auger Eric
2021-01-27 15:58         ` Micah Morton
2021-01-29 19:57           ` Micah Morton
2021-01-30 16:38             ` Auger Eric
2022-07-06 15:25               ` Dmytro Maluka
2022-07-06 20:39                 ` Sean Christopherson
2022-07-07  7:38                   ` Dmytro Maluka
2022-07-07 15:00                     ` Sean Christopherson
2022-07-07 17:38                       ` Dmytro Maluka
2022-07-12 16:02                         ` Liu, Rong L
2022-08-04 14:44                           ` Eric Auger
2022-08-08 21:15                             ` Liu, Rong L
2022-07-07  8:25                 ` Eric Auger
2022-07-07  9:15                   ` Dmytro Maluka [this message]
2022-07-25 22:03                     ` Liu, Rong L
2022-08-04 14:39                       ` Eric Auger
2022-08-08 17:34                         ` Liu, Rong L

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=d6f3205c-6229-3b58-cdc2-a5d0f6cfb98f@semihalf.com \
    --to=dmy@semihalf.com \
    --cc=alex.williamson@redhat.com \
    --cc=dtor@google.com \
    --cc=eric.auger@redhat.com \
    --cc=jaz@semihalf.com \
    --cc=kvm@vger.kernel.org \
    --cc=mortonm@chromium.org \
    --cc=pbonzini@redhat.com \
    --cc=rong.l.liu@intel.com \
    --cc=seanjc@google.com \
    --cc=tn@semihalf.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.