SW cannot write the read-only(RO) bits of a register
and write-only(WO) bits of a register return 0 when read.
Added ro_mask[] for each register that defines which
bits in that register are RO.
When writing to a register, the RO-bits are not updated.
When reading a register, clear the WO bits and return the updated value.
Tested the registers PHB_DMA_SYNC, PHB_PCIE_HOTPLUG_STATUS, PHB_PCIE_LMR,
PHB_PCIE_DLP_TRWCTL, PHB_LEM_ERROR_AND_MASK and PHB_LEM_ERROR_OR_MASK
by writing all 1's and reading back the value.
The WO bits in these registers should read back as 0.
Add .class_size in pnv_phb4_type_info.
Signed-off-by: Saif Abrar <saif.abrar@linux.ibm.com>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Caleb Schlossin <calebs@linux.ibm.com>
Reviewed-by: Aditya Gupta <adityag@linux.ibm.com>
Reviewed-by: Michael Kowal <kowal@linux.ibm.com>
Link: https://lore.kernel.org/qemu-devel/20261029171047.3862430-5-saif.abrar@linux.ibm.com
Signed-off-by: Harsh Prateek Bora <harshpb@linux.ibm.com>
Sticky bits retain their values on reset and are not overwritten with
the reset value.
Added sticky reset logic for all required registers,
i.e. CFG core, PBL core, PHB error registers, PCIE stack registers and
REGB error registers.
Tested by writing all 1's to the reg PHB_PBL_ERR_INJECT.
This will set the bits in the reg PHB_PBL_ERR_STATUS.
Reset the PBL core by setting PHB_PCIE_CRESET_PBL in reg PHB_PCIE_CRESET.
Verify that the sticky bits in the PHB_PBL_ERR_STATUS reg are still set.
Signed-off-by: Saif Abrar <saif.abrar@linux.ibm.com>
Reviewed-by: Caleb Schlossin <calebs@linux.ibm.com>
Reviewed-by: Michael Kowal <kowal@linux.ibm.com>
Link: https://lore.kernel.org/qemu-devel/20261029171047.3862430-4-saif.abrar@linux.ibm.com
Signed-off-by: Harsh Prateek Bora <harshpb@linux.ibm.com>
A channel closes its fd when the last reference to it is dropped.
Closing stdio fds is typically unwanted, so warn when they are passed to
qio_channel_file_new_fd().
Change the documentation of qio_channel_file_new_fd() to explicitly say
that passing stdio descriptors is incorrect.
Signed-off-by: Filip Hejsek <filip.hejsek@gmail.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-ID: <20261017-fix-stdio-close-v3-2-cfff0122a2a4@gmail.com>
Add a "guest" flag to QemuClipboardPeer and set it on vdagent peer.
Use the flag to keep track of number of registered guest peers and
allow to query for their presence with
qemu_clipboard_guest_peer_present().
This change makes it possible for a clipboard peer to determine if
any guest side peers are present so they can tell whether a guest is
actually able to participate in clipboard exchange.
Signed-off-by: Lukasz Kornicki <lucas.kornicki@nutanix.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-ID: <20261030141442.264308-3-lucas.kornicki@nutanix.com>
Add a new QEMU_CLIPBOARD_PEER_UPDATE notify type which carries
a payload with affected peer and whether it just registered or
unregistered.
All existing notifier handlers are updated to explicitly ignore
the new event so that the enum switch remains exhaustive.
Signed-off-by: Lukasz Kornicki <lucas.kornicki@nutanix.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-ID: <20261030141442.264308-2-lucas.kornicki@nutanix.com>
vfio queue:
* Extend vfio-user protocol to support multiple file descriptors
for sparse mmap regions
* Add per-subregion file descriptor and offset to VFIOMmap
* Add setup_sparse_mmaps hook to VFIODeviceIOOps
* Implement client-side multi-FD sparse mmap support in vfio-user
* Reorganize pci.h declarations into sections for readability
* Use version mapping for MTL/ARL quirk selection in IGD passthrough
# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCAAdFiEEoPZlSPBIlev+awtgUaNDx8/77KEFAmrliBAACgkQUaNDx8/7
# 7KGmLA/9FytkLXWuXOjFUJTQQ7fkfIMYwxQLEEy8AAijRBa1kM9LCeXNlOWO7HtN
# AVsRA98hNbcXQYdThiqqapM/G/JkjENkusYMPqrwaIwKfCanNUWlf74vQDQ8sAcV
# tmBNo2Squ9kfSN3n/w9kMNC4TtJKqCrIIQ2s1u5OE6zMVt0D3t/hb3jpBInzlxzp
# 0GWJIs275XBVO5woNbWG9O182Id9Mz2hbpvBKoxmUIPpabFZMzPvC9rgoZv6Pfmi
# TUogxpVTex+T+XGZ9F7SH5sNAAl26FNYAr/Py72Y0umtnzUoL/R8cIuWN5LvJoq8
# KJP52wJcSjnFEmcnXj5tESTGkXRF65I7vYzYBPgaYnnt7qvyaL8SYOHwg1uKe7vO
# WchUNS8w3xo26g++D6QUrZ+881w47r/8Ct2bS0zn0OxVPe0eTiBO7uNLL6Gq8As9
# KXzz/zKLdDhWLBuqxzCs3TSBOkYZ1WxmdXMv2XrOG1law634jDH6zygVRno2M4qQ
# iy8hJgRqU9DHjyolQNJRHie1/oeQbyl4E29926jYYTMHRxe6755npqW/K2eXm0q4
# n4d1GMDX5GfyTi/au6Y4t/GDTQZQ3Cc1BZr4bB01nah96Ncx1TEZaCriRQc1W7SM
# PChxl2GCprTygHPksuK2a09VF6EV68tEP6k+SfcWP+dfqs1reT4=
# =6dBA
# -----END PGP SIGNATURE-----
# gpg: Signature made Fri 30 Oct 2026 11:17:52 PM PDT
# gpg: using RSA key A0F66548F04895EBFE6B0B6051A343C7CFFBECA1
# gpg: Good signature from "Cédric Le Goater <clg@redhat.com>" [full]
# gpg: aka "Cédric Le Goater <clg@kaod.org>" [full]
* tag 'pull-vfio-20261031' of https://github.com/legoater/qemu:
vfio/igd: Use version mapping for MTL/ARL quirk selection
vfio/pci: Reorganize pci.h declarations into sections
vfio-user: support multiple FDs for sparse mmap regions
vfio: add setup_sparse_mmaps hook to VFIODeviceIOOps
vfio: add 'fd' and 'fd_offset' to VFIOMmap
vfio-user: add multi-fd region mmap capability
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
The PCA9545 is a 4-channel I2C mux/switch. What sets it apart from the
plain PCA9546 is its interrupt logic: one INTn input per channel and a
shared INT output, both active low, asserted whenever any channel
interrupt is active.
Model this behind a new has_irq class flag. The PCA9545 gains four named
"interrupt" GPIO inputs and an "interrupt-out" output, and its control
read-back merges the latched status nibble; the plain PCA9546/PCA9548
switches keep their previous behaviour.
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Signed-off-by: Emmanuel Blot <emmanuel.blot@free.fr>
Link: https://lore.kernel.org/qemu-devel/20261015-bmc-minerva-v3-5-7d50c8a108e5@free.fr
Signed-off-by: Cédric Le Goater <clg@redhat.com>
Add an HLX context pool and select the active context from CCR.XE3
and CCR.XA3. Preserve it across reset, migration and debugger writes.
Commit CCR changes at the packet boundary and end the TB.
Add a CCR enablement test.
Signed-off-by: Marco Liebel <marco.liebel@oss.qualcomm.com>
Reviewed-by: Brian Cain <brian.cain@oss.qualcomm.com>
Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
Make IgvmMemoryRegion a QOM object, embedding MemoryRegion, and use it
as the region owner. The IGVM list and memory subsystem can now hold
references independently, and QOM frees after the last reference is
dropped, fixing leaks reported by ASAN while running tests.
- object_unparent() is no longer needed, children are automatically unref
- switch to memory_region_init_ram_flags_nomigrate() as other helpers
expect a DEVICE
Tested-by: Gerd Hoffmann <kraxel@redhat.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
accel/tcg: Fix false awakening of gdb
accel/tcg: Do not flush and retry in place in tb_gen_code
tcg: Adjust NONNULL annotation on *_diff functions
tcg: Add tcg_gen_lea_{i32,i64,tl}
target/alpha: Use tcg_gen_lea_i64 for S{4,8}ADD{L,Q}
target/loongarch: Use tcg_gen_lea_tl for ALSL
target/riscv: Use tcg_gen_lea_tl for SH*ADD
target/s390x: Use tcg_gen_lea_i64 in get_address
target/i386: Use tcg_gen_lea_tl in gen_lea_modrm_1
target/mips: Use tcg_gen_lea() for [D]LSA and MXU S32LD*V opcodes
# -----BEGIN PGP SIGNATURE-----
#
# iQFRBAABCgA7FiEEekgeeIaLTbaoWgXAZN846K9+IV8FAmrkmGIdHHJpY2hhcmQu
# aGVuZGVyc29uQGxpbmFyby5vcmcACgkQZN846K9+IV/5Xgf9HJVBSOjBsW69SkQD
# 353u0YoAsfNCly6zSEqevaGqKZxRVwqyI1C6NzlP8e7FraxKphJGdizH6W3LeNia
# M6laDKkcnoPNkHDfHajZAkK8l7Uu7jW7CMf6jN21ZHSjUXf6RV9Oqbx1ZL5HtyF8
# CoGfuQPtruHu8ajPQKyWiCLf+8noDRVLug70lIjF65y7SET/YrbbcySFKZvUzdaV
# hwofOFe785bhKyvWeOGJldo/zP5UsqEn4qYIoeHWyBUIttP9p2E25Dzym4mC0lG/
# n5p5a4x54m4kCi3ORa3kb/zhrAEv7RO3j1lSmnDQdw3mE3nHIPiIqnf163Jg2akg
# AyEBiQ==
# =szoO
# -----END PGP SIGNATURE-----
# gpg: Signature made Fri 30 Oct 2026 08:15:14 AM CDT
# gpg: using RSA key 7A481E78868B4DB6A85A05C064DF38E8AF7E215F
# gpg: issuer "richard.henderson@linaro.org"
# gpg: Good signature from "Richard Henderson <richard.henderson@linaro.org>" [ultimate]
* tag 'pull-tcg-20261030' of https://gitlab.com/rth7680/qemu:
tcg/s390x: Implement INDEX_op_lea
tcg/riscv64: Implement INDEX_op_lea
tcg/aarch64: Implement INDEX_op_lea
tcg/loongarch64: Implement INDEX_op_lea
tcg/loongarch64: Import SLADD insns
tcg/x86_64: Implement INDEX_op_lea
tcg/x86_64: Introduce TCG_REG_NONE
target/i386: Use tcg_gen_lea_tl in gen_lea_modrm_1
target/s390x: Use tcg_gen_lea_i64 in get_address
target/riscv: Use tcg_gen_lea_tl for SH*ADD
target/mips: Use tcg_gen_lea() for [D]LSA and MXU S32LD*V opcodes
target/loongarch: Use tcg_gen_lea_tl for ALSL
target/alpha: Use tcg_gen_lea_i64 for S{4,8}ADD{L,Q}
tcg/optimize: Handle INDEX_op_lea
tcg: Add tcg_gen_lea_{i32,i64,tl}
tcg: Add INDEX_op_lea
accel/tcg: Do not flush and retry in place in tb_gen_code
accel/tcg: Fix false awakening of gdb
tcg: Adjust NONNULL annotation on *_diff functions
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
According to the UFS specification, the REPORT_LUNS SCSI command can query
Well Known LUNs by setting CDB[2] to 0x01 (select Well Known LUNs) or 0x02
(select all LUNs).
Currently, the UFS emulation layer lacks handling for these CDB[2] select
report values, causing command failures when guests attempt to report Well
Known LUNs.
This patch adds support for handling CDB[2] values 0x01 and 0x02 in the
REPORT_LUNS command, returning the appropriate Well Known LUN descriptors
in the SCSI response payload.
Signed-off-by: Hamza Dridi <dridiha98@gmail.com>
Reviewed-by: Jeuk Kim <jeuk20.kim@samsung.com>
Signed-off-by: Jeuk Kim <jeuk20.kim@samsung.com>
pci, vhost, virtio, iommu, acpi: features, fixes
multiboot can again load 64 bit images
vdpa-dev now implements guest_notifier_mask/pending
pci bridge can now configure the negotiated bandwidth
tap can now auto-detect host mtu and expose to guest
amd iommu can now attach on non system bus
vhost-user spec now has its own mailing list
Fixes, cleanups all over the place.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
# -----BEGIN PGP SIGNATURE-----
#
# iQFDBAABCgAtFiEEXQn9CHHI+FuUyooNKB8NuNKNVGkFAmrjkJ0PHG1zdEByZWRo
# YXQuY29tAAoJECgfDbjSjVRpY1YH/0r+PhxgcRVVrroGkIxaTaPfOpTj1UkGPmND
# OcjcVCKPXBJF+rve1ZOE4HF8VvbEU1fD1tJ6w+Hto78tjmaVEDvE7gVbhX3YRHv9
# LubC75aTJBYixn/wcS/LUyLAf50+3DD3T+yy83obaJmxHwFyO3CJh2CIMSQxTbSe
# zGPA0noriSSMKEnfbTtikj6NHvFIhdnYipkUaWjGefEbdzXumBhcAF2C7eee9H5m
# 1Nz1Zvjx7BMoArviiZ6EWpGwWPBp0fKwTa7Idcv9K5v6YfWhgVp/gPploCCvulEA
# SMYRqQbbQ41801jR8kY9mV5w5ZFUeNENqplbOR3y6dYtr2w+H2k=
# =JvkM
# -----END PGP SIGNATURE-----
# gpg: Signature made Thu 29 Oct 2026 01:29:49 PM CDT
# gpg: using RSA key 5D09FD0871C8F85B94CA8A0D281F0DB8D28D5469
# gpg: issuer "mst@redhat.com"
# gpg: Good signature from "Michael S. Tsirkin <mst@kernel.org>" [unknown]
# gpg: aka "Michael S. Tsirkin <mst@redhat.com>" [unknown]
# gpg: WARNING: The key's User ID is not certified with a trusted signature!
# gpg: There is no indication that the signature belongs to the owner.
# Primary key fingerprint: 0270 606B 6F3C DF3D 0B17 0970 C350 3912 AFBE 8E67
# Subkey fingerprint: 5D09 FD08 71C8 F85B 94CA 8A0D 281F 0DB8 D28D 5469
* tag 'for_upstream' of https://git.kernel.org/pub/scm/virt/kvm/mst/qemu: (77 commits)
virtio-net: add mtu-from-tap property for automatic MTU detection
net: add generic get_mtu NetClientInfo callback
net/tap: add tap_fd_get_mtu() to query host tap MTU
hw/virtio/virtio-mem: Fix error message on invalid NUMA node
intel_iommu_accel: Teardown FAULTQ resources in bottom half
intel_iommu_accel: Accept PRQ response for passthrough device
intel_iommu_accel: Add PRQ injection for passthrough device
backends/iommufd: Extend iommufd_backend_alloc_hwpt() with fault_id
backends/iommufd: Introduce iommufd_backend_alloc_faultq
intel_iommu_accel: Guard VTDAccelPASIDCacheEntry definition
amd_iommu: Allow IOMMU to attachment on non-system (pcie.0) bus
acpi-build: Create PCI topology using amd iommu root bus
amd_iommu: Introduce root bus
i386/kvm: Use x86_iommu_device_get() for per-device IOMMU lookup
intel_iommu: Add support for get_x86_iommu callback
amd_iommu: Add support for get_x86_iommu callback
x86-iommu: Introduce x86_iommu_device_get() for x86-iommu retrieval
amd_iommu: Assign ioapic_as only when interrupt remapping is supported.
vhost-user: add dedicated mailing list
virtio-snd: don't use virtio_snd_pcm_get_stream() in virtio_snd_post_load()
...
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Currently, exposing the host tap device's MTU to the guest via
VIRTIO_NET_F_MTU requires manually specifying host_mtu= on the
virtio-net-pci device, duplicating the MTU already configured on
the host's tap interface.
Add a new mtu-from-tap boolean property (default off, preserving
existing behavior). When enabled, the netdev peer's MTU is queried
via the generic qemu_get_mtu() and used to set net_conf.mtu and
enable VIRTIO_NET_F_MTU, regardless of the backend's type.
This detection must happen in virtio_net_device_realize(), before
virtio_net_set_config_size() computes the virtio config space
size from host_features. Performing the detection later (e.g. in
the get_features_ex() callback, which runs after the NIC and its
config space are already sized) results in the mtu config field
falling outside the sized config space, and the guest reading
back an unmapped garbage value (0xffff) instead of the intended
MTU.
Since qemu_new_nic() has not yet been called at this point in
realize(), the peer is accessed via n->nic_conf.peers.ncs[0]
(populated during property parsing, before realize() runs, via
the netdev= property) rather than through n->nic.
Signed-off-by: Nariman Sayed <narimansayed28@gmail.com>
Tested-by: Aniket Sahu <asahu1x@linux.ibm.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Eugenio Pérez <eperezma@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Message-ID: <20261007050718.926-4-narimansayed28@gmail.com>
Add a get_mtu callback to NetClientInfo, along with a qemu_get_mtu()
wrapper following the existing qemu_has_ufo()-style pattern, so that
device models can query a netdev backend's host MTU generically
without needing to know or check its backend type.
Wire this up for the tap backend via tap_get_mtu(), which is now
static and only referenced through net_tap_info.get_mtu, matching
the existing pattern used by tap_has_ufo() and similar callbacks.
This allows other backends (e.g. vhost-user, vhost-vdpa) to
implement get_mtu in the future without requiring changes to any
code that calls qemu_get_mtu().
Suggested-by: Eugenio Perez Martin <eperezma@redhat.com>
Signed-off-by: Nariman Sayed <narimansayed28@gmail.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Eugenio Pérez <eperezma@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Message-ID: <20261007050718.926-3-narimansayed28@gmail.com>
Propagate guest's PRQ response to host by writing to fault_fd.
Create a new VTDPRQEntry to cache cookie for each fault group,
this cookie is used to mark the fault group on host side.
If there is either PRQ overflow or full error condition, propagate
a success response to host for LPIG request with the PRQ requests
dropped. For other error conditions, propagate response of invalid
request.
Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
Reviewed-by: Clement Mathieu--Drif <clement.mathieu--drif@bull.com>
Reviewed-by: Yi Liu <yi.l.liu@intel.com>
Tested-by: Xudong Hao <xudong.hao@intel.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Message-ID: <20261020091955.1607161-6-zhenzhong.duan@intel.com>
kvm_arch_fixup_msi_route() and kvm_arch_add_msi_route_post() use
x86_iommu_get_default() whenever an IOMMU is present. This selects the
correct unit only when a single IOMMU is attached to the system bus.
The following patches allow an IOMMU to attach to a different bus and
isolate the subset of devices below it. Each IOMMU then serves only part
of the PCI topology, so interrupt remapping must determine the IOMMU that
actually serves a given device.
Add x86_iommu_device_get() to locate the IOMMU bus for a PCI device and
retrieve its X86IOMMUState through a new get_x86_iommu callback.
Signed-off-by: Sairaj Kodilkar <sarunkod@amd.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Message-ID: <20261014053433.24564-3-sarunkod@amd.com>
If CONFIG_CXL=n is added to the Kconfig, the build fails to link
the PXB device:
/usr/bin/ld.bfd: libsystem.a.p/hw_pci-bridge_pci_expander_bridge.c.o: in function `pxb_cxl_realize':
/home/berrange/src/virt/qemu/build/../hw/pci-bridge/pci_expander_bridge.c:202:(.text+0x330): undefined reference to `cxl_component_register_block_init'
/usr/bin/ld.bfd: libsystem.a.p/hw_pci-bridge_pci_expander_bridge.c.o: in function `pxb_cxl_dev_reset':
/home/berrange/src/virt/qemu/build/../hw/pci-bridge/pci_expander_bridge.c:309:(.text+0x768): undefined reference to `cxl_component_register_init_common'
We cannot use CONFIG_CXL in pci_expander_bridge.c because the
identifier is poisoned. Instead the CXL pieces must be split
off into a separate source file which can be conditionally
built.
With this change, the stubs file is no longer required, since
the code referencing the stub was already protected by CONFIG_CXL.
Fixes: 6e4e3ae936 ("hw/cxl/component: Implement host bridge MMIO (8.2.5, table 142)")
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Message-ID: <20260928095646.3555447-3-berrange@redhat.com>
We have .initialized in EventNotifier to track was it actually
initialized, and we have a comment that @fd passed to
event_notifier_init_fd() must be an eventfd object.
Still, there are two specific users, which ignore these things,
and use -1 as specific value storing in notifier, to mark it
"uninitialized".
Let's make strict API:
- store only valid FDs in initialized notifier
- _set() asserts that passed fd is valid
- _get() asserts that notifier is initialized (actually, except
the two specific cases we rework, all other callers are not
prepared to notifier being uninitialized when _get() is called.
In this case _get() returns 0 (which is a valid fd), and caller
will mistakenly use it, which is worse than abort())
- for two specific cases, implement additional getter for .initialized
field itself
- zeroed notifier is uninitialized(.initialized is false)
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Message-ID: <20260911185800.134135-1-vsementsov@yandex-team.ru>
SHARED_OBJECT_ADD publishes a borrowed vhost_dev pointer in the global
UUID table. If an exporter goes away without sending SHARED_OBJECT_REMOVE,
vhost_user_backend_cleanup() frees dev->opaque but leaves these entries
behind. A later lookup from another backend can dereference the NULL
opaque pointer, or access a freed vhost_dev if its containing allocation
has also been released.
Remove all entries exported by the device after closing its backend
request channel and before freeing its state. Match both the resource
type and owner pointer so other exporters and dma-buf entries are kept.
Add unit coverage for multiple UUIDs per owner, unrelated resources,
repeated cleanup, UUID reuse, and an uninitialized or empty table.
Fixes: 1609476662 ("vhost-user: add shared_object msg")
Signed-off-by: Yuho Choi <oss.patchbox@gmail.com>
Reviewed-by: Albert Esteve <aesteve@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Message-ID: <20260910053012.1395885-1-oss.patchbox@gmail.com>
The TI XIO3130 PCIe switch is a vintage Gen1 device, so we add generic
PCIe upstream and downstream port devices that are Gen6.
In guests with pairs of passthrough PCIe devices (e.g, a GPU+NIC pair)
often need to place the devices behind a common (emulated) PCIe switch
so in-guest software (such as NCCL) can correctly determine that P2P
transactions between the devices is possible.
NCCL also needs to be able to determine the available PCIe
bandwidth. If such a guest sees the TI XIO3130 PCIe switch, then it
incorrectly calculates only 2.5 GT/s and x1 is available, but the real
hardware might be 32 GT/s and x16.
Instead of enhancing the existing switch and claiming it is more
capable than the real hardware we add additional generic PCIe upstream
and downstream port devices, which matches the existing generic PCIe
root port device.
The speed and width of the ports are configurable.
Signed-off-by: David Vrabel <david.vrabel@nutanix.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Message-ID: <20260928152431.310363-2-david.vrabel@nutanix.com>
The primary CCI teardown is open-coded, guarded by .initialized, at
the two places that need it: the reset path (before
cxl_device_register_init_t3() brings the mailbox back up) and
ct3_exit().
Factor it into cxl_destroy_mailbox_t3(), the teardown counterpart of
cxl_initialize_mailbox_t3(), keeping the .initialized guard inside the
helper: the primary CCI is only brought up from the reset path, so the
first reset after realize and an unrealize before any reset must both
skip the teardown.
No functional change.
Suggested-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Signed-off-by: Junjie Cao <junjie.cao@intel.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Message-ID: <20260729144645.1552511-5-junjie.cao@intel.com>
Replace the deprecated device_class_set_legacy_reset() registration
with the three-phase resettable interface, following the pattern
already established by the CXL root port (cxl_rp_reset_hold).
Only the hold phase is needed; enter and exit are left NULL. The
parent hold phase is chained for correctness: TYPE_PCI_DEVICE installs
no hold phase today, so parent_phases.hold is currently NULL and the
chained call is a no-op, but capturing and invoking it is the correct
forward-compatible pattern and mirrors cxl_rp_reset_hold().
No functional change — the reset body is identical; only the
registration path and function signature change.
Signed-off-by: Junjie Cao <junjie.cao@intel.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Message-ID: <20260729144645.1552511-4-junjie.cao@intel.com>
The previous patches reuse the source vhost FD on the destination,
however both source and target still call vhost_dev_init() (VHOST_SET_OWNER)
in realize(). For cpr-transfer the destination realizes while the source
still owns the shared FD, so its SET_OWNER would fail - ownership has to be
handed over explicitly.
Do this through the device's CPR vmstate hooks. Namely, release device
ownership in pre_save, reclaim in post_load, re-acquire on restart:
- .pre_save() releases ownership on the source (VHOST_RESET_OWNER) once
the VM is stopped, for the FD-preserving CPR modes (cpr-transfer and
cpr-exec).
- .realize(), for an incoming CPR, only sets up the virtio device and
queries the backend features by calling vhost_dev_init_backend().
It doesn't take device ownership and doesn't touch the VQs which
still-running source might use. The full init is deferred to
.post_load().
- .post_load() reclaims it on the destination: the full vhost_dev_init()
(VHOST_SET_OWNER) on the preserved FD, plus sets the guest cid, before
the device is started at vm_start. It also marks the ownership as
handed over ('owner_handed_over'), so that it's released if this
target goes away.
- .set_status() refuses to start a device whose init hasn't completed
yet (incoming CPR before post_load).
- .set_status() re-acquires ownership before starting the device if
pre_save released it and this QEMU is about to run the guest again:
the migration failed, or it completed and the management resumed the
source (e.g. cpr-transfer target died).
With the handoff in place, lift the CPR blocker.
Note: this requires kernel side support of VHOST_RESET_OWNER operation
for vhost-vsock. Otherwise CPR attempt fails in .pre_save().
Suggested-by: Dongli Zhang <dongli.zhang@oracle.com>
Signed-off-by: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
Acked-by: Stefano Garzarella <sgarzare@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Message-ID: <20261012-up-vsock-vhost-v5-v16-19-36c38bd15ffc@virtuozzo.com>
A CPR target that has taken the device ownership in post_load() doesn't
always reach vhost_dev_cleanup(): a target which has loaded the state
but hasn't been started yet, e.g. one started with -S, may be quit
normally, with the source being resumed instead. Devices aren't
unrealized on quit, so the ownership stays with the dead process. The
source still holds the FD, so the kernel never releases the device, and
the source can't take it back after being resumed -> SET_OWNER fails
with EBUSY.
Add an exit notifier to each vhost_dev, registered for its lifetime,
that releases the ownership if still held. This covers every orderly
exit. A target killed with SIGKILL or crashing still leaves the device
unrecoverable.
Reported-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
Signed-off-by: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
Acked-by: Stefano Garzarella <sgarzare@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Message-ID: <20261012-up-vsock-vhost-v5-v16-18-36c38bd15ffc@virtuozzo.com>
A CPR target that has taken the device ownership in post_load() doesn't
always reach vhost_dev_cleanup(): a subsequent load error, e.g. a
truncated migration stream footer, makes QEMU exit() right away, and the
ownership stays with the dead process. The source still holds the FD,
so the kernel never releases the device, and the source can't take it
back after being resumed -> SET_OWNER fails with EBUSY.
Releasing the ownership at exit isn't enough either: with the
return-path capability the target reports the failure to the source
before exiting, and the source resumes right away, racing with the
target's exit for the ownership. And with exit-on-error=false the
target doesn't exit at all.
Add a migration notifier to each vhost_dev, registered for its lifetime
for the CPR modes, that releases the ownership if still held on
MIG_EVENT_INCOMING_FAILED. It runs before the failure is published in
any way.
Reported-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
Signed-off-by: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
Acked-by: Stefano Garzarella <sgarzare@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Message-ID: <20261012-up-vsock-vhost-v5-v16-17-36c38bd15ffc@virtuozzo.com>
A device may take over a resource from the source in post_load(), e.g.
vhost-vsock acquires the device ownership on a CPR target. If the
incoming migration fails afterwards, there's currently no way for the
device to give that resource back before the failure is published, i.e.
before the source is told about it over the return path and resumes, or
the management sees the MIGRATION event on the target and resumes the
source, or the target exits.
Add a migration event for that, sent to the migration notifiers from
the failure path of process_incoming_migration_co() before the failure
is published.
Reviewed-by: Peter Xu <peterx@redhat.com>
Signed-off-by: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Message-ID: <20261012-up-vsock-vhost-v5-v16-16-36c38bd15ffc@virtuozzo.com>
vhost_dev_cleanup() closes the backend FD, but that doesn't release the
device ownership taken with VHOST_SET_OWNER if the same file is open
elsewhere. That's the case on a CPR target: the source keeps the FD,
so if the target fails after SET_OWNER, either inside vhost_dev_init()
or later in its caller, the ownership stays with the target. Once the
source is resumed it can't take the device back, SET_OWNER fails with
EBUSY.
Track the ownership with a new 'owner' flag in struct vhost_dev, set and
cleared by vhost_dev_set_owner() and vhost_dev_reset_owner(), and issue
VHOST_RESET_OWNER in vhost_dev_cleanup() as the common teardown for all
those paths. Only do it if the ownership was handed over to us by
another process, which is marked by the device with a new bool flag
'owner_handed_over'. Upon ownership release failure, we have nothing to
unwind at this point (CPR target teardown), so we just report the failure.
Reported-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
Suggested-by: Stefano Garzarella <sgarzare@redhat.com>
Signed-off-by: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Message-ID: <20261012-up-vsock-vhost-v5-v16-15-36c38bd15ffc@virtuozzo.com>
The upcoming CPR support for vhost-vsock defers the full vhost_dev_init()
to .post_load(). On an incoming CPR .realize() only sets up the backend,
so we need a way to tell a fully initialized vhost device from a partially
initialized one.
Add an explicit 'bool initialized' field, set once vhost_dev_init()
succeeds, and cleared only in vhost_dev_cleanup() (by memset(0)). Also add
a public vhost_dev_is_initialized() helper.
Suggested-by: Stefano Garzarella <sgarzare@redhat.com>
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Signed-off-by: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Message-ID: <20261012-up-vsock-vhost-v5-v16-14-36c38bd15ffc@virtuozzo.com>
Wrap the set_owner/reset_owner backend ops in dev-level helpers, matching
other vhost_dev_* wrappers, so device code can take or release ownership
without reaching into vhost_ops directly. vhost_dev_init() now uses
vhost_dev_set_owner(). Both return -ENOSYS if the backend has no such op.
No functional change. These are used by the following vhost-vsock patch to
hand a device between owners during CPR.
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Signed-off-by: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Message-ID: <20261012-up-vsock-vhost-v5-v16-13-36c38bd15ffc@virtuozzo.com>
Split the first part of vhost_dev_init(): selecting the backend, calling
its .vhost_init() and reading the supported features - into a new
vhost_dev_init_backend() helper, and call it from vhost_dev_init().
This is in preparation for CPR restore of vhost-vsock, which needs to learn
the backend's features at realize time to negotiate them when loading the
incoming virtio state, but also must defer taking ownership of the device
to post_load. vhost_dev_init_backend() does exactly the pre-ownership part.
As a result VHOST_SET_OWNER now follows the feature query rather than
precedes it. This should be safe, as no backend requires ownership before
VHOST_GET_FEATURES - the kernel and vdpa backends do not check ownership
for it, and vhost-user already does query features from its .vhost_init()
before set_owner().
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Signed-off-by: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Message-ID: <20261012-up-vsock-vhost-v5-v16-11-36c38bd15ffc@virtuozzo.com>