From: "Marek Marczykowski-Górecki" <marmarek@invisiblethingslab.com>
To: Jason Andryuk <jandryuk@gmail.com>
Cc: qemu-devel@nongnu.org,
Stefano Stabellini <sstabellini@kernel.org>,
Anthony Perard <anthony.perard@citrix.com>,
Paul Durrant <paul@xen.org>,
"open list:X86 Xen CPUs" <xen-devel@lists.xenproject.org>
Subject: Re: [PATCH 2/2] Do not access /dev/mem in MSI-X PCI passthrough on Xen
Date: Wed, 16 Nov 2022 22:40:02 +0100 [thread overview]
Message-ID: <Y3VYs/sS4VddrBCK@mail-itl> (raw)
In-Reply-To: <CAKf6xpvpsJuMZx98vLJ7CAmUWG-vW91Am0L8817eD8nmAN4NUw@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 3147 bytes --]
On Wed, Nov 16, 2022 at 02:15:22PM -0500, Jason Andryuk wrote:
> On Mon, Nov 14, 2022 at 2:21 PM Marek Marczykowski-Górecki
> <marmarek@invisiblethingslab.com> wrote:
> >
> > The /dev/mem is used for two purposes:
> > - reading PCI_MSIX_ENTRY_CTRL_MASKBIT
> > - reading Pending Bit Array (PBA)
> >
> > The first one was originally done because when Xen did not send all
> > vector ctrl writes to the device model, so QEMU might have outdated old
> > register value. This has been changed in Xen, so QEMU can now use its
> > cached value of the register instead.
> >
> > The Pending Bit Array (PBA) handling is for the case where it lives on
> > the same page as the MSI-X table itself. Xen has been extended to handle
> > this case too (as well as other registers that may live on those pages),
> > so QEMU handling is not necessary anymore.
> >
> > Removing /dev/mem access is useful to work within stubdomain, and
> > necessary when dom0 kernel runs in lockdown mode.
> >
> > Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
>
> I put the Xen, QEMU, and xen-pciback patches into OpenXT and gave a
> little test. When pci_permissive=0, iwlwifi fails to load its
> firmware. With pci_permissive=1, it looks like MSI-X is enabled. (I
> previously included your libxl allow_interrupt_control patch - that
> seemed to get regular MSIs working prior to the MSI-X patches.) I
> also removed the OpenXT equivalent of 0005-Disable-MSI-X-caps.patch.
> I am testing with Linux 5.4.y, so that could be another factor.
Can you confirm the allow_interrupt_control is set by libxl? Also,
vanilla 5.4 doesn't have the allow_interrupt_control patch at all, and you
may have an earlier version that had "allow_msi_enable" as the sysfs
file name.
> One strange thing is the lspci output. Dom0 shows MSI-X enabled.
> Meanwhile NDVM (sys-net) does not show the MSI-X capability. If you
> `hexdump -C /sys/bus/pci/devices/$dev/config` you can see MSI-X
> enabled, but you also see that the MSI capability has 00 as the next
> pointer, so lspci stops parsing.
This 00 value is written by Linux[1] (sic!) and then qemu incorrectly
allowing the write and happily emulating that zero. The other qemu patch
in this series ought to fix that (as in: properly refuse the write), do
you have it included?
[1] https://github.com/torvalds/linux/blob/master/drivers/net/wireless/intel/iwlwifi/pcie/drv.c#L1721
> MSI cap stubdom:
> 00000040 10 00 92 00 c0 0e 00 00 10 0c 10 00 00 00 00 00 |................|
> 0x41 -> next 0x00
> MSI cap dom0:
> 00000040 10 80 92 00 c0 0e 00 10 10 0c 10 00 00 00 00 00 |................|
> 0x41 -> next 0x80
>
> MSI-X:
> 00000080 11 00 0f 80 00 20 00 00 00 30 00 00 00 00 00 00
>
> AFAIU, the value 0x80 at offset 0x83 is MSI-X Enabled.
>
> I had a boot where assignment failed with the hypervisor printing:
> d12: assign (0000:00:14.3) failed (-16)
> Rebooting the laptop seemed to clear that.
Zombie of previous domain? Not set as "assignable" first?
--
Best Regards,
Marek Marczykowski-Górecki
Invisible Things Lab
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2022-11-16 21:42 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-14 19:20 [PATCH 1/2] hw/xen/xen_pt: Call default handler only if no custom one is set Marek Marczykowski-Górecki
2022-11-14 19:20 ` [PATCH 2/2] Do not access /dev/mem in MSI-X PCI passthrough on Xen Marek Marczykowski-Górecki
2022-11-14 19:39 ` Andrew Cooper
2022-11-14 22:44 ` Marek Marczykowski-Górecki
2022-11-15 8:14 ` Jan Beulich
2022-11-15 11:38 ` Marek Marczykowski-Górecki
2022-11-15 14:05 ` Jan Beulich
2022-11-16 19:15 ` Jason Andryuk
2022-11-16 21:40 ` Marek Marczykowski-Górecki [this message]
2022-11-17 3:34 ` Marek Marczykowski-Górecki
2022-11-17 8:04 ` Jan Beulich
2022-11-17 11:15 ` Marek Marczykowski-Górecki
2022-11-17 17:29 ` Jason Andryuk
2022-11-22 17:12 ` [PATCH 1/2] hw/xen/xen_pt: Call default handler only if no custom one is set Anthony PERARD via
2023-09-26 23:25 ` Marek Marczykowski-Górecki
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=Y3VYs/sS4VddrBCK@mail-itl \
--to=marmarek@invisiblethingslab.com \
--cc=anthony.perard@citrix.com \
--cc=jandryuk@gmail.com \
--cc=paul@xen.org \
--cc=qemu-devel@nongnu.org \
--cc=sstabellini@kernel.org \
--cc=xen-devel@lists.xenproject.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).