From: Stefan Hajnoczi <stefanha@redhat.com>
To: Kevin Wolf <kwolf@redhat.com>
Cc: qemu-devel@nongnu.org, mst@redhat.com, akihiko.odaki@daynix.com,
qemu-stable@nongnu.org
Subject: Re: [PATCH] virtio: Fix crash when sriov-pf is set for non-PCI-Express device
Date: Thu, 4 Dec 2025 16:36:02 -0500 [thread overview]
Message-ID: <20251204213602.GA1259496@fedora> (raw)
In-Reply-To: <20251204172657.174391-1-kwolf@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 1315 bytes --]
On Thu, Dec 04, 2025 at 06:26:57PM +0100, Kevin Wolf wrote:
> Setting the sriov-pf property on devices that aren't PCI Express causes
> an assertion failure:
>
> $ qemu-system-x86_64 \
> -blockdev null-co,node-name=null \
> -blockdev null-co,node-name=null2 \
> -device virtio-blk,drive=null,id=pf \
> -device virtio-blk,sriov-pf=pf,drive=null2
> qemu-system-x86_64: ../hw/pci/pcie.c:1062: void pcie_add_capability(PCIDevice *, uint16_t, uint8_t, uint16_t, uint16_t): Assertion `offset >= PCI_CONFIG_SPACE_SIZE' failed.
>
> This is because proxy->last_pcie_cap_offset is only initialised to a
> non-zero value in virtio_pci_realize() if it's a PCI Express device, and
> then virtio_pci_device_plugged() still tries to use it.
>
> To fix this, just skip the SR-IOV code for !pci_is_express(). Then the
> next thing pci_qdev_realize() does is call pcie_sriov_register_device(),
> which returns the appropriate error.
>
> Cc: qemu-stable@nongnu.org
> Fixes: d0c280d3fac6 ('pcie_sriov: Make a PCI device with user-created VF ARI-capable')
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
> hw/virtio/virtio-pci.c | 20 +++++++++++---------
> 1 file changed, 11 insertions(+), 9 deletions(-)
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
prev parent reply other threads:[~2025-12-04 21:36 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-04 17:26 [PATCH] virtio: Fix crash when sriov-pf is set for non-PCI-Express device Kevin Wolf
2025-12-04 21:36 ` Stefan Hajnoczi [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=20251204213602.GA1259496@fedora \
--to=stefanha@redhat.com \
--cc=akihiko.odaki@daynix.com \
--cc=kwolf@redhat.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-stable@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.