qemu-cr16/hw/pci
Kevin Wolf 8c65f73b31 pcie_sriov: Fix PCI_SRIOV_* accesses in pcie_sriov_pf_exit()
PCI_SRIOV_* are offsets into the SR-IOV capability, not into the PCI
config space. pcie_sriov_pf_exit() erroneously takes them as the latter,
which makes it read PCI_HEADER_TYPE and PCI_BIST when it tries to read
PCI_SRIOV_TOTAL_VF.

In many cases we're lucky enough that the PCI config space will be 0
there, so we just skip the whole for loop, but this isn't guaranteed.
For example, setting the multifunction bit on the PF and then doing a
'device_del' on it will get a larger number and cause a segfault.

Fix this and access the real PCI_SRIOV_* fields in the capability.

Cc: qemu-stable@nongnu.org
Fixes: 19e55471d4 ('pcie_sriov: Allow user to create SR-IOV device')
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Message-Id: <20251205145718.55136-1-kwolf@redhat.com>
(cherry picked from commit f73e5ed9bc4cfacf041323a6b40a85e6b6459b75)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2026-02-06 00:45:06 +03:00
..
Kconfig kconfig: Add PCIe devices to s390x machines 2023-07-14 11:10:57 +02:00
meson.build meson: remove CONFIG_ALL 2023-12-31 09:11:28 +01:00
msi.c include: Rename sysemu/ -> system/ 2024-12-20 17:44:56 +01:00
msix.c hw/pci: Make msix_init take a uint32_t for nentries 2025-11-25 22:41:40 +01:00
pci-hmp-cmds.c qapi: Move include/qapi/qmp/ to include/qobject/ 2025-02-10 15:33:16 +01:00
pci-internal.h hw/pci/aer: Make PCIE AER error injection facility available for other emulation to use. 2023-03-07 12:39:00 -05:00
pci-qmp-cmds.c pci: Move QMP commands to new hw/pci/pci-qmp-cmds.c 2022-12-19 16:15:17 +01:00
pci-stub.c hw/pci: remove return after g_assert_not_reached() 2024-09-24 13:53:35 +02:00
pci.c migration: Fix regression of passing error_fatal into vmstate_load_state() 2025-11-03 16:04:10 -05:00
pci_bridge.c qom: Make InterfaceInfo[] uses const 2025-04-25 17:00:41 +02:00
pci_host.c hw/pci-host: Remove unused pci_host_data_be_ops 2025-05-20 08:04:18 +02:00
pcie.c pcie: Add a way to get the outstanding page request allocation (pri) from the config space. 2025-10-05 09:01:08 -04:00
pcie_aer.c hw/pci: Constify VMState 2023-12-30 07:38:06 +11:00
pcie_doe.c hw/pci: PCIe Data Object Exchange emulation 2022-11-07 13:12:19 -05:00
pcie_host.c include/hw/pci: Split pci_device.h off pci.h 2023-01-08 01:54:22 -05:00
pcie_port.c hw/pci/pcie_port: Fix pcie_slot_is_hotpluggbale_bus typo 2025-05-08 14:22:12 +02:00
pcie_sriov.c pcie_sriov: Fix PCI_SRIOV_* accesses in pcie_sriov_pf_exit() 2026-02-06 00:45:06 +03:00
shpc.c hw/pci: add some convenient trace-events for pcie and shpc hotplug 2024-03-11 22:09:42 +01:00
slotid_cap.c include/hw/pci: Split pci_device.h off pci.h 2023-01-08 01:54:22 -05:00
trace-events hw/pci/pci.c: Turn DPRINTF into trace events 2025-05-09 23:49:26 +03:00
trace.h trace: switch position of headers to what Meson requires 2020-08-21 06:18:24 -04:00