public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Marc Zyngier <maz@kernel.org>
To: Jason Gunthorpe <jgg@ziepe.ca>
Cc: chenxiang <chenxiang66@hisilicon.com>,
	alex.williamson@redhat.com, kvm@vger.kernel.org,
	qemu-devel@nongnu.org, linuxarm@huawei.com
Subject: Re: [PATCH v2] vfio/pci: Verify each MSI vector to avoid invalid MSI vectors
Date: Sat, 26 Nov 2022 11:15:14 +0000	[thread overview]
Message-ID: <871qpquful.wl-maz@kernel.org> (raw)
In-Reply-To: <Y3+xTLC0io6wvPpf@ziepe.ca>

On Thu, 24 Nov 2022 18:00:44 +0000,
Jason Gunthorpe <jgg@ziepe.ca> wrote:
> 
> On Wed, Nov 23, 2022 at 09:42:36AM +0800, chenxiang via wrote:
> > From: Xiang Chen <chenxiang66@hisilicon.com>
> > 
> > Currently the number of MSI vectors comes from register PCI_MSI_FLAGS
> > which should be power-of-2 in qemu, in some scenaries it is not the same as
> > the number that driver requires in guest, for example, a PCI driver wants
> > to allocate 6 MSI vecotrs in guest, but as the limitation, it will allocate
> > 8 MSI vectors. So it requires 8 MSI vectors in qemu while the driver in
> > guest only wants to allocate 6 MSI vectors.
> > 
> > When GICv4.1 is enabled, it iterates over all possible MSIs and enable the
> > forwarding while the guest has only created some of mappings in the virtual
> > ITS, so some calls fail. The exception print is as following:
> > vfio-pci 0000:3a:00.1: irq bypass producer (token 000000008f08224d) registration
> > fails:66311
> 
> With Thomas's series to make MSI more dynamic this could spell future
> problems, as future kernels might have different ordering.

Enabling MSIs on the endpoint before they are programmed in the
interrupt controller? I don't think that's a realistic outcome.

> It is just architecturally wrong to tie the MSI programming at the PCI
> level with the current state of the guest's virtual interrupt
> controller.

There is no architectural ties between the two at all. There is an
optimisation that allows direct injection if you do it in a non
braindead order. Nothing breaks if you don't, you just have wasted
memory, performance, power and area. You're welcome.

> Physical hardware doesn't do this, virtual emulation shouldn't either.

If you want to fix VFIO, be my guest. My rambling about the sorry
state of this has been in the kernel for 5 years (ed8703a506a8).

> People are taking too many liberties with trapping the PCI MSI
> registers through VFIO. :(

Do you really want to leave access to the MSI BAR to userspace? The
number of ways this can go wrong is mind-boggling. Starting with
having to rebuild the interrupt translation tables on the host side to
follow what the guest does, instead of keeping the two independent.

	M.

-- 
Without deviation from the norm, progress is not possible.

  reply	other threads:[~2022-11-26 11:15 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-23  1:42 [PATCH v2] vfio/pci: Verify each MSI vector to avoid invalid MSI vectors chenxiang
2022-11-23 12:08 ` Marc Zyngier
2022-11-23 19:55   ` Alex Williamson
2022-11-24 13:19     ` Marc Zyngier
2022-11-26  6:33   ` chenxiang (M)
2022-11-26 10:58     ` Marc Zyngier
2022-11-24 18:00 ` Jason Gunthorpe
2022-11-26 11:15   ` Marc Zyngier [this message]
2022-11-28 18:01     ` 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=871qpquful.wl-maz@kernel.org \
    --to=maz@kernel.org \
    --cc=alex.williamson@redhat.com \
    --cc=chenxiang66@hisilicon.com \
    --cc=jgg@ziepe.ca \
    --cc=kvm@vger.kernel.org \
    --cc=linuxarm@huawei.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