From: Alex Williamson <alex.williamson@redhat.com>
To: Jason Gunthorpe <jgg@ziepe.ca>
Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org,
quic_bqiang@quicinc.com, kvalo@kernel.org, prestwoj@gmail.com,
linux-wireless@vger.kernel.org, ath11k@lists.infradead.org,
dwmw2@infradead.org, iommu@lists.linux.dev, kernel@quicinc.com,
johannes@sipsolutions.net, jtornosm@redhat.com
Subject: Re: [PATCH RFC/RFT] vfio/pci-quirks: Quirk for ath wireless
Date: Thu, 15 Aug 2024 10:59:05 -0600 [thread overview]
Message-ID: <20240815105905.19d69576.alex.williamson@redhat.com> (raw)
In-Reply-To: <20240813233724.GS1985367@ziepe.ca>
On Tue, 13 Aug 2024 20:37:24 -0300
Jason Gunthorpe <jgg@ziepe.ca> wrote:
> On Tue, Aug 13, 2024 at 03:03:20PM -0600, Alex Williamson wrote:
>
> > How does the guest know to write a remappable vector format? How does
> > the guest know the host interrupt architecture? For example why would
> > an aarch64 guest program an MSI vector of 0xfee... if the host is x86?
>
> All excellent questions.
>
> Emulating real interrupt controllers in the VM is probably impossible
> in every scenario. But certainly x86 emulating x86 and ARM emulating
> ARM would be usefully achievable.
>
> hyperv did a neat thing where their remapping driver seems to make VMM
> traps and looks kind of like the VMM gives it the platform specific
> addr/data pair.
>
> It is a big ugly problem for sure, and we definately have painted
> ourselves into a corner where the OS has no idea if IMS techniques
> work properly or it is broken. :( :(
>
> But I think there may not be a terribly impossible path where at least
> the guest could be offered a, say, virtio-irq in addition to the
> existing platform controllers that would process IMS for it.
>
> > The idea of guest owning the physical MSI address space sounds great,
> > but is it practical?
>
> In many cases yes, it is, but more importantly it is the only sane way
> to support these IMS like techniques broadly since IMS is by
> definition not generally trappable.
>
> > Is it something that would be accomplished while
> > this device is still relevant?
>
> I don't know, I fear not. But it keeps coming up. Too many things
> don't work right with the trapping approach, including this.
>
> > The Windows driver is just programming the MSI capability to use 16
> > vectors. We configure those vectors on the host at the time the
> > capability is written. Whereas the Linux driver is only using a single
> > vector and therefore writing the same MSI address and data at the
> > locations noted in the trace, the Windows driver is writing different
> > data values at different locations to make use of those vectors. This
> > note is simply describing that we can't directly write the physical
> > data value into the device, we need to determine which vector offset
> > the guest is using and provide the same offset from the host data
> > register value.
>
> I see, it seems to be assuming also that these extra interrupt sources
> are generating the same MSI message as the main MSI, not something
> else. That is more a SW quirk of Windows, I expect. I don't think
> Linux would do that..
>
> This is probably the only way to approach this, trap and emulate the
> places in the device that program additional interrupt sources and do
> a full MSI-like flow to set them up in the kernel.
Your last sentence here seems to agree with this approach, but
everything else suggests disapproval, so I don't know where you're
going here.
I have no specs for this device, nor any involvement from the device
vendor, so the idea of creating a vfio-pci variant driver to setup an
irq_domain and augment a device specific SET_IRQs ioctls not only sounds
tremendously more complicated (host and VMM), it's simply not possible
with the knowledge we have at hand. Making this device work in a VM is
dead in the water if that's the bar to achieve.
I observe that the device configures MSI vectors and then writes that
same vector address/data elsewhere into the device. Whether the device
can trigger those vectors based only on the MSI capability programming
and a secondary source piggybacks on those vectors or if this is just a
hack by Qualcomm to use an MSI capability to acquire some vectors which
are exclusively used by the secondary hardware, I have no idea. Who
can even say if this is just a cost saving measure that a PCI config
space is slapped into a platform device and there's simply no hw/fw
support to push the vector data into the hardware and the driver
bridges the gap.
The solution here is arguably fragile, we're relying on having a
sufficiently unique MSI address that we can recognize writes with that
value in order to both replace it with the host value and mark the
location of the data register. If someone with some hardware insight
wants to come along and provide a reference for static locations of
these writes, I'd certainly welcome it. My sample size is one, which
is why this is posted as an RFT.
I do not believe that introducing a vfio device feature that disables
virtualization of the MSI address/data _only_ at the vfio interface
(not to a QEMU VM) provides some implicit support of this device
behavior. These values are already available to a privileged user in
the host and the same is available for an MSI-X use case by directly
reading the MSI-X vector table. The only point of the vfio device
feature is that we need a vehicle to expose the MSI phsyical
address/data values through he vfio channel, without additional host
privileges. The virtualized values are essentially unused by QEMU, so
why not give QEMU a way to turn off the virtualization to expose the
host values. Thanks,
Alex
next prev parent reply other threads:[~2024-08-15 16:59 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-08 13:17 ath11k and vfio-pci support James Prestwood
2024-01-10 9:00 ` Kalle Valo
2024-01-10 13:04 ` James Prestwood
2024-01-10 13:49 ` Kalle Valo
2024-01-10 14:55 ` James Prestwood
2024-01-11 3:51 ` Baochen Qiang
2024-01-11 8:16 ` Kalle Valo
2024-01-11 12:48 ` James Prestwood
2024-01-11 13:11 ` Kalle Valo
2024-01-11 13:38 ` James Prestwood
2024-01-12 2:04 ` Baochen Qiang
2024-01-12 12:47 ` James Prestwood
2024-01-14 12:37 ` Baochen Qiang
2024-01-14 14:36 ` Kalle Valo
2024-01-15 17:46 ` Alex Williamson
2024-01-16 10:08 ` Baochen Qiang
2024-01-16 10:41 ` David Woodhouse
2024-01-16 15:29 ` Jason Gunthorpe
2024-01-16 18:28 ` Alex Williamson
2024-01-16 21:10 ` Jeff Johnson
2024-01-17 5:47 ` Baochen Qiang
2024-03-21 19:14 ` Johannes Berg
2024-01-16 13:05 ` James Prestwood
2024-01-17 5:26 ` Baochen Qiang
2024-01-17 13:20 ` James Prestwood
2024-01-17 13:43 ` Kalle Valo
2024-01-17 14:25 ` James Prestwood
2024-01-18 2:09 ` Baochen Qiang
2024-01-19 17:52 ` James Prestwood
2024-01-19 17:57 ` Kalle Valo
2024-01-19 18:07 ` James Prestwood
2024-01-26 18:20 ` James Prestwood
2024-01-27 4:31 ` Baochen Qiang
2024-08-12 16:59 ` [PATCH RFC/RFT] vfio/pci: Create feature to disable MSI virtualization Alex Williamson
2024-08-13 16:30 ` Jason Gunthorpe
2024-08-13 17:30 ` Thomas Gleixner
2024-08-13 23:39 ` Jason Gunthorpe
2024-12-13 9:10 ` David Woodhouse
2025-01-03 14:31 ` Jason Gunthorpe
2025-01-03 14:47 ` David Woodhouse
2025-01-03 15:19 ` Jason Gunthorpe
2024-08-13 21:14 ` Alex Williamson
2024-08-13 23:16 ` Jason Gunthorpe
2024-08-14 14:55 ` Alex Williamson
2024-08-14 15:20 ` Jason Gunthorpe
2024-08-12 17:00 ` [PATCH RFC/RFT] vfio/pci-quirks: Quirk for ath wireless Alex Williamson
2024-08-13 16:43 ` Jason Gunthorpe
2024-08-13 21:03 ` Alex Williamson
2024-08-13 23:37 ` Jason Gunthorpe
2024-08-15 16:59 ` Alex Williamson [this message]
2024-08-15 17:19 ` Jason Gunthorpe
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=20240815105905.19d69576.alex.williamson@redhat.com \
--to=alex.williamson@redhat.com \
--cc=ath11k@lists.infradead.org \
--cc=dwmw2@infradead.org \
--cc=iommu@lists.linux.dev \
--cc=jgg@ziepe.ca \
--cc=johannes@sipsolutions.net \
--cc=jtornosm@redhat.com \
--cc=kernel@quicinc.com \
--cc=kvalo@kernel.org \
--cc=kvm@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=prestwoj@gmail.com \
--cc=qemu-devel@nongnu.org \
--cc=quic_bqiang@quicinc.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).