kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marc Zyngier <maz@kernel.org>
To: Andre Przywara <andre.przywara@arm.com>
Cc: kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu,
	kernel-team@android.com,
	Alexandru Elisei <alexandru.elisei@arm.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Will Deacon <will@kernel.org>
Subject: Re: [PATCH][kvmtool] virtio/pci: Correctly handle MSI-X masking while MSI-X is disabled
Date: Thu, 26 Aug 2021 18:50:22 +0100	[thread overview]
Message-ID: <87zgt4nli9.wl-maz@kernel.org> (raw)
In-Reply-To: <7c2abc6a-164a-b07e-a39e-756b83a98f0c@arm.com>

On Thu, 26 Aug 2021 18:07:55 +0100,
Andre Przywara <andre.przywara@arm.com> wrote:
> 
> On 8/25/21 6:44 PM, Marc Zyngier wrote:
> 
> >> Actually, let me correct myself. I tested the wrong configuration (why
> >> isn't --force-pci the bloody default in kvmtool?).
> 
> I guess because there is no --force-mmio, and PCI on ARM was kind of
> daunting back then ;-)

I remember that. But maybe we should change that default...

> >> Having dug further, it isn't the config space that causes problems,
> >> but the programming of the MSI-X vectors. I'm starting to suspect the
> >> layout of the MSI-X bar in kvmtool.
> > 
> > OK, this is hilarious. Sort of. The MSI-X bar sizing is bonkers: you
> > can't fit 33 MSIs there (33 being the number of MSI-X that kvmtool
> > advertises), and you will have notionally overwritten the PBA as
> > well. Amusingly, the last write ends up being misdecoded as a config
> > space access...
> 
> Ah, very good find indeed, many thanks for the debugging!
> 
> I am only halfway through the code by now, but wouldn't you need to
> adjust the PBA offset in the MSIX capability as well? This is still
> stuck at that (misnamed) PCI_IO_SIZE, in
> virtio/pci.c:virtio_pci__init(): vpci->pci_hdr.msix.pba_offset =
> And IIUC this has to match the decoding in virtio_pci__msix_mmio_callback().

Indeed. I had this:

	Region 2: Memory at 50000800 (32-bit, non-prefetchable) [size=1K]
	Capabilities: [40] MSI-X: Enable+ Count=33 Masked-
		Vector table: BAR=2 offset=00000000
		PBA: BAR=2 offset=00000100

and with the PBA fix, I get:

	Region 2: Memory at 50000800 (32-bit, non-prefetchable) [size=1K]
	Capabilities: [40] MSI-X: Enable+ Count=33 Masked-
		Vector table: BAR=2 offset=00000000
		PBA: BAR=2 offset=00000210

which looks more sane. But man, this code is crufty as hell. I'll post
an updated patch later, once I've cleaned up a couple more things.

Thanks,

	M.

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

      reply	other threads:[~2021-08-26 17:50 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-21 12:07 [PATCH][kvmtool] virtio/pci: Correctly handle MSI-X masking while MSI-X is disabled Marc Zyngier
2021-08-23 16:48 ` Andre Przywara
2021-08-24 14:32   ` Marc Zyngier
2021-08-25 15:33     ` Marc Zyngier
2021-08-25 17:44       ` Marc Zyngier
2021-08-26 17:07         ` Andre Przywara
2021-08-26 17:50           ` Marc Zyngier [this message]

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=87zgt4nli9.wl-maz@kernel.org \
    --to=maz@kernel.org \
    --cc=alexandru.elisei@arm.com \
    --cc=andre.przywara@arm.com \
    --cc=kernel-team@android.com \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.cs.columbia.edu \
    --cc=tglx@linutronix.de \
    --cc=will@kernel.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;
as well as URLs for NNTP newsgroup(s).