From: Alex Williamson <alex.williamson@redhat.com>
To: Jason Gunthorpe <jgg@nvidia.com>
Cc: Nicolin Chen <nicolinc@nvidia.com>,
tglx@linutronix.de, Robin Murphy <robin.murphy@arm.com>,
maz@kernel.org, bhelgaas@google.com, leonro@nvidia.com,
shameerali.kolothum.thodi@huawei.com, dlemoal@kernel.org,
kevin.tian@intel.com, smostafa@google.com,
andriy.shevchenko@linux.intel.com, reinette.chatre@intel.com,
eric.auger@redhat.com, ddutile@redhat.com, yebin10@huawei.com,
brauner@kernel.org, apatel@ventanamicro.com,
shivamurthy.shastri@linutronix.de, anna-maria@linutronix.de,
nipun.gupta@amd.com, marek.vasut+renesas@mailbox.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org,
kvm@vger.kernel.org
Subject: Re: [PATCH RFCv1 0/7] vfio: Allow userspace to specify the address for each MSI vector
Date: Wed, 13 Nov 2024 14:11:22 -0700 [thread overview]
Message-ID: <20241113141122.2518c55a.alex.williamson@redhat.com> (raw)
In-Reply-To: <20241113013430.GC35230@nvidia.com>
On Tue, 12 Nov 2024 21:34:30 -0400
Jason Gunthorpe <jgg@nvidia.com> wrote:
> On Tue, Nov 12, 2024 at 01:54:58PM -0800, Nicolin Chen wrote:
> > On Mon, Nov 11, 2024 at 01:09:20PM +0000, Robin Murphy wrote:
> > > On 2024-11-09 5:48 am, Nicolin Chen wrote:
> > > > To solve this problem the VMM should capture the MSI IOVA allocated by the
> > > > guest kernel and relay it to the GIC driver in the host kernel, to program
> > > > the correct MSI IOVA. And this requires a new ioctl via VFIO.
> > >
> > > Once VFIO has that information from userspace, though, do we really need
> > > the whole complicated dance to push it right down into the irqchip layer
> > > just so it can be passed back up again? AFAICS
> > > vfio_msi_set_vector_signal() via VFIO_DEVICE_SET_IRQS already explicitly
> > > rewrites MSI-X vectors, so it seems like it should be pretty
> > > straightforward to override the message address in general at that
> > > level, without the lower layers having to be aware at all, no?
> >
> > Didn't see that clearly!! It works with a simple following override:
> > --------------------------------------------------------------------
> > @@ -497,6 +497,10 @@ static int vfio_msi_set_vector_signal(struct vfio_pci_core_device *vdev,
> > struct msi_msg msg;
> >
> > get_cached_msi_msg(irq, &msg);
> > + if (vdev->msi_iovas) {
> > + msg.address_lo = lower_32_bits(vdev->msi_iovas[vector]);
> > + msg.address_hi = upper_32_bits(vdev->msi_iovas[vector]);
> > + }
> > pci_write_msi_msg(irq, &msg);
> > }
> >
> > --------------------------------------------------------------------
> >
> > With that, I think we only need one VFIO change for this part :)
>
> Wow, is that really OK from a layering perspective? The comment is
> pretty clear on the intention that this is to resync the irq layer
> view of the device with the physical HW.
>
> Editing the msi_msg while doing that resync smells bad.
>
> Also, this is only doing MSI-X, we should include normal MSI as
> well. (it probably should have a resync too?)
This was added for a specific IBM HBA that clears the vector table
during a built-in self test, so it's possible the MSI table being in
config space never had the same issue, or we just haven't encountered
it. I don't expect anything else actually requires this.
> I'd want Thomas/Marc/Alex to agree.. (please read the cover letter for
> context)
It seems suspect to me too. In a sense it is still just synchronizing
the MSI address, but to a different address space.
Is it possible to do this with the existing write_msi_msg callback on
the msi descriptor? For instance we could simply translate the msg
address and call pci_write_msi_msg() (while avoiding an infinite
recursion). Or maybe there should be an xlate_msi_msg callback we can
register. Or I suppose there might be a way to insert an irqchip that
does the translation on write. Thanks,
Alex
next prev parent reply other threads:[~2024-11-13 21:11 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-09 5:48 Nicolin Chen
2024-11-09 5:48 ` [PATCH RFCv1 1/7] genirq/msi: Allow preset IOVA in struct msi_desc for MSI doorbell address Nicolin Chen
2024-11-09 5:48 ` [PATCH RFCv1 2/7] irqchip/gic-v3-its: Bypass iommu_cookie if desc->msi_iova is preset Nicolin Chen
2024-11-09 5:48 ` [PATCH RFCv1 3/7] PCI/MSI: Pass in msi_iova to msi_domain_insert_msi_desc Nicolin Chen
2024-11-09 5:48 ` [PATCH RFCv1 4/7] PCI/MSI: Allow __pci_enable_msi_range to pass in iova Nicolin Chen
2024-11-11 9:30 ` Andy Shevchenko
2024-11-09 5:48 ` [PATCH RFCv1 5/7] PCI/MSI: Extract a common __pci_alloc_irq_vectors function Nicolin Chen
2024-11-11 9:33 ` Andy Shevchenko
2024-11-09 5:48 ` [PATCH RFCv1 6/7] PCI/MSI: Add pci_alloc_irq_vectors_iovas helper Nicolin Chen
2024-11-11 9:34 ` Andy Shevchenko
2024-11-12 22:14 ` Nicolin Chen
2024-11-09 5:48 ` [PATCH RFCv1 7/7] vfio/pci: Allow preset MSI IOVAs via VFIO_IRQ_SET_ACTION_PREPARE Nicolin Chen
2024-11-11 13:09 ` [PATCH RFCv1 0/7] vfio: Allow userspace to specify the address for each MSI vector Robin Murphy
2024-11-11 14:14 ` Marc Zyngier
2024-11-12 22:13 ` Nicolin Chen
2024-11-12 21:54 ` Nicolin Chen
2024-11-13 1:34 ` Jason Gunthorpe
2024-11-13 21:11 ` Alex Williamson [this message]
2024-11-14 15:35 ` Robin Murphy
2024-11-20 13:17 ` Eric Auger
2024-11-20 14:03 ` Jason Gunthorpe
2024-11-28 11:15 ` Thomas Gleixner
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=20241113141122.2518c55a.alex.williamson@redhat.com \
--to=alex.williamson@redhat.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=anna-maria@linutronix.de \
--cc=apatel@ventanamicro.com \
--cc=bhelgaas@google.com \
--cc=brauner@kernel.org \
--cc=ddutile@redhat.com \
--cc=dlemoal@kernel.org \
--cc=eric.auger@redhat.com \
--cc=jgg@nvidia.com \
--cc=kevin.tian@intel.com \
--cc=kvm@vger.kernel.org \
--cc=leonro@nvidia.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=marek.vasut+renesas@mailbox.org \
--cc=maz@kernel.org \
--cc=nicolinc@nvidia.com \
--cc=nipun.gupta@amd.com \
--cc=reinette.chatre@intel.com \
--cc=robin.murphy@arm.com \
--cc=shameerali.kolothum.thodi@huawei.com \
--cc=shivamurthy.shastri@linutronix.de \
--cc=smostafa@google.com \
--cc=tglx@linutronix.de \
--cc=yebin10@huawei.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
all inboxes | Powered by JetHome®