qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* question about handling MSI-X by VFIO
@ 2020-01-21 13:36 Thanos Makatos
  2020-01-21 17:19 ` Alex Williamson
  0 siblings, 1 reply; 3+ messages in thread
From: Thanos Makatos @ 2020-01-21 13:36 UTC (permalink / raw)
  To: qemu-devel; +Cc: Alex Williamson, Felipe Franciosi

I'm passing through a virtual PCI device to a QEMU guest via VFIO/mdev and I
notice that MSI-X interrupts are disabled in the device (MSIXCAP.MXC.MXE is
zero) and the BARs containing the table and PBA (4 and 5 in my case) are never
accessed.  However, whenever I fire an MSI-X interrupt from the virtual device
(although I'm not supposed to do so as they're disabled), the guest seems to
correctly receive it. I've started looking at hw/vfio/pci.c and it seems that
VFIO handles MSI-X interrupts there, including masking etc?


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: question about handling MSI-X by VFIO
  2020-01-21 13:36 question about handling MSI-X by VFIO Thanos Makatos
@ 2020-01-21 17:19 ` Alex Williamson
  2020-01-23 15:01   ` Thanos Makatos
  0 siblings, 1 reply; 3+ messages in thread
From: Alex Williamson @ 2020-01-21 17:19 UTC (permalink / raw)
  To: Thanos Makatos; +Cc: qemu-devel, Felipe Franciosi

On Tue, 21 Jan 2020 13:36:26 +0000
Thanos Makatos <thanos.makatos@nutanix.com> wrote:

> I'm passing through a virtual PCI device to a QEMU guest via VFIO/mdev and I
> notice that MSI-X interrupts are disabled in the device (MSIXCAP.MXC.MXE is
> zero) and the BARs containing the table and PBA (4 and 5 in my case) are never
> accessed.  However, whenever I fire an MSI-X interrupt from the virtual device
> (although I'm not supposed to do so as they're disabled), the guest seems to
> correctly receive it. I've started looking at hw/vfio/pci.c and it seems that
> VFIO handles MSI-X interrupts there, including masking etc?

Yes, the vector table and PBA are emulated in QEMU, the latter lazily
only when vectors are masked, iirc.  The backing device vector table
should never be directly accessed by the user (it can be, but you can
just discard those accesses), MSI-X is configured via the
VFIO_DEVICE_SET_IRQS ioctl, which configures the eventfd through which
an mdev driver would trigger an MSI.  When you say that you "fire and
MSI-X interrupt from the virtual device" does this mean that you're
signaling via one of these eventfds?  It looks to me like emulating the
MSI-X enable bit in the MSI-X capability is probably the responsibility
of the mdev vendor driver.  With vfio-pci the VFIO_DEVICE_SET_IRQS ioctl
would enable MSI-X on the physical device and the MSI-X capability seen
by the user would reflect that.  Are you missing a bit of code that
updates the mdev config space as part of the SET_IRQS ioctl?  Thanks,

Alex



^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: question about handling MSI-X by VFIO
  2020-01-21 17:19 ` Alex Williamson
@ 2020-01-23 15:01   ` Thanos Makatos
  0 siblings, 0 replies; 3+ messages in thread
From: Thanos Makatos @ 2020-01-23 15:01 UTC (permalink / raw)
  To: Alex Williamson; +Cc: qemu-devel, Felipe Franciosi

> > I'm passing through a virtual PCI device to a QEMU guest via VFIO/mdev
> and I
> > notice that MSI-X interrupts are disabled in the device (MSIXCAP.MXC.MXE
> is
> > zero) and the BARs containing the table and PBA (4 and 5 in my case) are
> never
> > accessed.  However, whenever I fire an MSI-X interrupt from the virtual
> device
> > (although I'm not supposed to do so as they're disabled), the guest seems
> to
> > correctly receive it. I've started looking at hw/vfio/pci.c and it seems that
> > VFIO handles MSI-X interrupts there, including masking etc?
> 
> Yes, the vector table and PBA are emulated in QEMU, the latter lazily
> only when vectors are masked, iirc.  The backing device vector table
> should never be directly accessed by the user (it can be, but you can
> just discard those accesses), MSI-X is configured via the
> VFIO_DEVICE_SET_IRQS ioctl, which configures the eventfd through which
> an mdev driver would trigger an MSI.  When you say that you "fire and
> MSI-X interrupt from the virtual device" does this mean that you're
> signaling via one of these eventfds?  It looks to me like emulating the
> MSI-X enable bit in the MSI-X capability is probably the responsibility
> of the mdev vendor driver.  With vfio-pci the VFIO_DEVICE_SET_IRQS ioctl
> would enable MSI-X on the physical device and the MSI-X capability seen
> by the user would reflect that.  Are you missing a bit of code that
> updates the mdev config space as part of the SET_IRQS ioctl?  Thanks,

Indeed I fire interrupts via the eventfd and it works correctly. I just
couldn't understand how it could possibly work since the table and PBA BARs 
were never accessed and the MSI-X enable bit was not set.  It makes perfect
sense now why it works since QEMU does it all.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-01-23 16:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-21 13:36 question about handling MSI-X by VFIO Thanos Makatos
2020-01-21 17:19 ` Alex Williamson
2020-01-23 15:01   ` Thanos Makatos

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).