Commit Graph
20151 Commits
Author SHA1 Message Date
Jamin Lin caa779d1a2 hw/misc/aspeed_scu: Add AST1080 A0 silicon revision definition
Add a new silicon revision constant AST1080_A0_SILICON_REV for the
AST1080 SoC. This allows the SCU model and related SoC layers to
identify and handle AST1080 A0 revision properly in the same way as
other Aspeed SoC families.

Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Link: https://lore.kernel.org/qemu-devel/20261015063625.186708-4-jamin_lin@aspeedtech.com
Signed-off-by: Cédric Le Goater <clg@redhat.com>
2026-10-31 06:52:19 +01:00
Jamin Lin 4530b40b5b hw/misc/aspeed_scu: Correct AST1040 A0 revision ID
Correct the AST1040 A0 silicon revision ID from 0x81000000 to 0x80000000.

Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Link: https://lore.kernel.org/qemu-devel/20261028023154.48395-5-jamin_lin@aspeedtech.com
Signed-off-by: Cédric Le Goater <clg@redhat.com>
2026-10-31 06:52:18 +01:00
Richard Henderson 7f36b1fbeb Merge tag 'pull-tcg-20261030' of https://gitlab.com/rth7680/qemu into staging
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>
2026-10-30 08:16:19 -05:00
Richard Henderson 82e6d899d9 tcg: Add tcg_gen_lea_{i32,i64,tl}
Reviewed-by: Matt Turner <mattst88@gmail.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2026-10-30 07:06:16 -05:00
Richard Henderson a075f67f45 tcg: Add INDEX_op_lea
Add an opcode for compound address formation.

Reviewed-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2026-10-30 07:06:15 -05:00
Richard Henderson 00bf6778e2 tcg: Adjust NONNULL annotation on *_diff functions
In tcg/sparc64 we use tcg_tbrel_diff with NULL as a negative
addend in a relocation.

Fixes: b0b6701a40 ("tcg: Annotate functions in tcg.h with QEMU_*_NONNULL")
Reported-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Tested-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
2026-10-30 07:06:15 -05:00
dridiha 397086dd55 hw/ufs: Add support for REPORT_LUNS SCSI command for Well Known LUNs
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>
2026-10-30 14:52:17 +09:00
Richard Henderson b574eaf640 Merge tag 'for_upstream' of https://git.kernel.org/pub/scm/virt/kvm/mst/qemu into staging
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>
2026-10-29 13:47:40 -05:00
Nariman Sayed 592bb52d87 virtio-net: add mtu-from-tap property for automatic MTU detection
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>
2026-10-29 14:27:26 -04:00
Nariman Sayed e583f293aa net: add generic get_mtu NetClientInfo callback
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>
2026-10-29 14:27:26 -04:00
Zhenzhong Duan 223c9cbbcb intel_iommu_accel: Accept PRQ response for passthrough device
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>
2026-10-29 14:27:25 -04:00
Zhenzhong Duan 903d288508 backends/iommufd: Extend iommufd_backend_alloc_hwpt() with fault_id
We should set flags IOMMU_HWPT_FAULT_ID_VALID when pass in a fault
object id in the caller.

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>
Reviewed-by: Nicolin Chen <nicolinc@nvidia.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-4-zhenzhong.duan@intel.com>
2026-10-29 14:27:25 -04:00
Zhenzhong Duan e8b3b3ef53 backends/iommufd: Introduce iommufd_backend_alloc_faultq
Add a new helper for IOMMU_FAULT_QUEUE_ALLOC ioctl to allocate a fault
handling object which will be used in hwpt allocation.

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>
Reviewed-by: Nicolin Chen <nicolinc@nvidia.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-3-zhenzhong.duan@intel.com>
2026-10-29 14:27:25 -04:00
Sairaj Kodilkar 8628286abc x86-iommu: Introduce x86_iommu_device_get() for x86-iommu retrieval
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>
2026-10-29 14:27:25 -04:00
Daniel P. Berrangé c1ba12f16d hw/pci-bridge: split CXL PXB into separate file
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>
2026-10-29 14:27:25 -04:00
Vladimir Sementsov-Ogievskiy e3b12d0c55 util/event_notifier: more strict API
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>
2026-10-29 14:27:25 -04:00
Yuho Choi 7cdfef9521 vhost-user: remove shared object entries during cleanup
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>
2026-10-29 14:27:25 -04:00
David Vrabel 73962cc5f0 hw/pci-bridge: Add generic PCIe switch upstream and downstream ports
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>
2026-10-29 14:27:25 -04:00
Junjie Cao 567e29e2fd hw/cxl: add cxl_destroy_mailbox_t3() as the mailbox teardown counterpart
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>
2026-10-29 14:27:25 -04:00
Junjie Cao ce8cae0027 hw/cxl: convert cxl-type3 to three-phase reset
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>
2026-10-29 14:27:25 -04:00
Andrey Drobyshev 182067a740 vhost-vsock: hand off device ownership across CPR
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>
2026-10-29 14:26:57 -04:00
Andrey Drobyshev 39a6b34b9f vhost: release ownership on exit
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>
2026-10-29 14:26:57 -04:00
Andrey Drobyshev 10b7a99ddf vhost: release ownership when the incoming migration fails
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>
2026-10-29 14:26:57 -04:00
Andrey Drobyshev 4a59633f52 migration: add MIG_EVENT_INCOMING_FAILED
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>
2026-10-29 14:26:56 -04:00
Andrey Drobyshev ded34b83bf vhost: release ownership in vhost_dev_cleanup()
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>
2026-10-29 14:26:56 -04:00
Andrey Drobyshev d6c94ebd9c vhost: add vhost_dev_is_initialized() helper
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>
2026-10-29 14:26:56 -04:00
Andrey Drobyshev bdf00dc5e5 vhost: add vhost_dev_set_owner() / vhost_dev_reset_owner() helpers
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>
2026-10-29 14:26:56 -04:00
Andrey Drobyshev ed64317188 vhost: factor out vhost_dev_init_backend()
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>
2026-10-29 14:26:56 -04:00
Andrey Drobyshev 5d16a6f526 vhost: add vhost_reset_owner op
Add a VhostOps callback issuing VHOST_RESET_OWNER, wired up for the kernel
backend.  The CPR (checkpoint-restore) path uses it to release device
ownership on the source so the destination can reclaim it later with
VHOST_SET_OWNER.

Originally-by: Mark Kanda <mark.kanda@oracle.com>
Originally-by: Steve Sistare <steven.sistare@oracle.com>
Originally-by: Ben Chaney <bchaney@akamai.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-7-36c38bd15ffc@virtuozzo.com>
2026-10-29 14:26:56 -04:00
Andrey Drobyshev 37a6b95d39 vhost-vsock: block CPR migration modes
CPR migration with a vhost-vsock device currently crashes the target
QEMU.  The device ownership is not handed over, so while the source
QEMU still holds the guest CID hashed in the kernel, the target's freshly
opened vhost-vsock device fails to set the same CID in realize():

  qemu-system-x86_64: -device vhost-vsock-pci,id=vsock0,guest-cid=3:
  vhost-vsock: unable to set guest cid: Address already in use

Add an unconditional migration blocker for the CPR modes, so that such
a migration fails early and gracefully instead.  The following patches
implement the actual vhost-vsock CPR support, and the blocker is lifted
once it's fully working.

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-6-36c38bd15ffc@virtuozzo.com>
2026-10-29 14:26:56 -04:00
Andrey Drobyshev de80025348 migration/cpr: forbid saving duplicate CprFds into hash table
In its current form, the mechanism for saving CPR FDs into hash table
has flaws.

The CPR fd hash table uses the same CprFd for both key and value, and
is created with a key destroy function.  Inserting a second element
with the same (name, id) key leads to a use after free.  According to
GLib docs [1], g_hash_table_insert() keeps the old key, replaces the
value with the new element, and destroys the new key.  Thus when
inserting 2 CprFd elements fd1 and fd2 with equal keys we get:

  g_hash_table_insert(table, fd1, fd1);  /* table has fd1 -> fd1 */
  g_hash_table_insert(table, fd2, fd2);  /* table has fd1 -> fd2, fd2 freed */

Any subsequent cpr_find_fd() for that key then returns freed memory.

This is reachable whenever two CPR-aware objects register fds under the
same name, and it happens long before an actual CPR, since cpr_save_fd()
is typically called from .realize(), i.e. at boot time.

Apart from the UAF itself, when the user decides to perform CPR migration,
on CPR target we'd get corrupted FD from the hash table and fail somewhere
in .realize() for affected devices.

As a solution, let's altogether prohibit adding CprFds with duplicate
keys.  Since FDs are being registered for a subsequent CPR right at the
startup in .realize(), that'll allow us to error out and exit QEMU (or
fail a device hotplug op) gracefully instead of delaying potential
problems for later.  To do so, let's make cpr_save_fd() return 'bool'
instead of 'void' and provide an 'errp' argument to it.  That way caller
becomes responsible for checking the return value and propagating the
error.

Also update all the callers to use the adjusted interface to keep things
compilable and bisectable.

[1] https://docs.gtk.org/glib/type_func.HashTable.insert.html

Fixes: a181df93bb ("migration/cpr: use hashtable for cpr fds")
Reviewed-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Cédric Le Goater <clg@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-1-36c38bd15ffc@virtuozzo.com>
2026-10-29 14:26:56 -04:00
Richard Henderson 0259ddcb9d Merge tag 'hw-misc-20261027' of https://github.com/philmd/qemu into staging
Misc HW patches

- Don't complain about spaces before 'Fixes' tags in scripts/checkpatch.pl
- Various fixes (SD card, i.MX, SH4 UART, CAN, PCIe, ...)
- Widen QEMU_ARCH_* and arch_bitmask to 64-bit
- MAINTAINERS updates

# -----BEGIN PGP SIGNATURE-----
#
# iQJPBAABCAA5FiEE+qvnXhKRciHc/Wuy4+MsLN6twN4FAmrhtHobFIAAAAAABAAO
# bWFudTIsMi41KzEuMTIsMCwzAAoJEOPjLCzercDejMsP/18i0YGbBmuB9Bfxvbms
# WIW6q5rZiS44hSVJHxlpvrhDX1gkBKxbE9AAJ+xMjuqDAw2pSawSK+v7AAigLbfu
# hzrGYw/PBvbAAUXsStJuTbCTtmftVhLyPd7YEJs6+2LWhqwwwN/jixHPinunOFdK
# nZmWBNyWIMYV0r46a450nEHGjEjQBWtZhBBFYcYQ6L8LW1StdjFMkHnviqRD0d3N
# pz++eLTpbDYb9Pyfr7dvFhUWtkBGTCYB6iuvFzJ8S8VWDbG2Gc00DTdP3QMXF8S7
# 2Fp9c8iwqi4tm17qT8+Do3Jv27Dt43wz5ZVinmS1oHacZl5xTP+BgI+f1FA4IWR1
# vCc2f0mmZbk+DjvuZKuCRcRaA7oKtnDEZvuoRb+2r+8YaMOJgszQJNfyBBOQFpfN
# kfmVy8MVzTB0Ps3TrSID7ZyzU1IYEa4YLnq/7L5iXlgjrnAimelEMcd9SjNdohHk
# oqzrvgTh0eimj5qpwg+pKE22y7iHtUhM/jA35IM3g6oERyM0yv7bKjGeHthoZv5V
# 1v5OjjD6DAItNTA+O/WqS27YhNICNE5mqwu2jzqw8ZcPA4OshbcgEJ9VaxASd3qI
# eZURqYx2qnoHR2M3weG0LZTJSlr2wIsWtVbF2ZN6odzKkYfoY2CzQMjBfTSD8+fa
# g4L11zpAhKYzoHpw+UE2fMAA
# =jdKk
# -----END PGP SIGNATURE-----
# gpg: Signature made Wed 28 Oct 2026 03:38:18 AM CDT
# gpg:                using RSA key FAABE75E12917221DCFD6BB2E3E32C2CDEADC0DE
# gpg: Good signature from "Philippe Mathieu-Daudé (F4BUG) <f4bug@amsat.org>" [unknown]
# gpg: Signature notation: manu=2,2.5+1.12,0,3
# gpg: WARNING: This key is not certified with a trusted signature!
# gpg:          There is no indication that the signature belongs to the owner.
# Primary key fingerprint: FAAB E75E 1291 7221 DCFD  6BB2 E3E3 2C2C DEAD C0DE

* tag 'hw-misc-20261027' of https://github.com/philmd/qemu: (58 commits)
  qemu/arch-defs: increase width of QEMU_ARCH_* masks enums to be 64 bits
  qemu/arch-defs: Use SYS_EMU_TARGET__MAX to define QEMU_ARCH_ALL
  qemu/arch-defs: extract QEMU_ARCH_BIT for QEMU_ARCH_* enums
  hw/display/xlnx_dp: Make assertions clearer
  hw/misc/allwinner-h3-dramc: Avoid shift by negative amount
  hw/net/cadence_gem: Check guest-provided queue numbers in screening registers
  hw/net/can/flexcan: Fix FLEXCAN_CRCR_MBCRC definition
  hw/pci-host/aspeed_pcie: Fix global MSI setting during class initialization
  hw/char/sh_serial: fix break detection flag
  hw/char/sh_serial: use rx_cnt for available FIFO space
  hw/char/sh_serial: fix RDF flag clear on FIFO reset
  MAINTAINERS: Update Gustavo's email address
  hw/arm: remove pci-bridge/pci_expander_bridge.h from virt.c
  hw/watchdog/wdt_imx2: Trace with QOM path
  hw/net/lan9118_phy: Trace with QOM path
  hw/net/imx_fec: Trace with QOM path where easily possible
  hw/usb/imx-usb-phy: Avoid casting from void *
  hw/misc/imx*_ccm: Avoid casting from void *
  hw/intc/imx_avic: Avoid casting from void *
  hw/char/imx_serial: Avoid casting from void *
  ...

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2026-10-28 06:21:44 -05:00
Yonggang Luo 8930d9cca2 qemu/arch-defs: increase width of QEMU_ARCH_* masks enums to be 64 bits
SYS_EMU_TARGET__MAX is already 29, nearing the 32-target limit.
So increase width of QEMU_ARCH_* masks enums and related types;
So that we can add needed Linux user-mode targets to EmuTarget;
And also enabled the possibility add more system-mode targets in future.

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Message-ID: <20261027061504.2213-4-luoyonggang@gmail.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
2026-10-28 09:25:48 +01:00
Yonggang Luo 35f1e3fb6f qemu/arch-defs: Use SYS_EMU_TARGET__MAX to define QEMU_ARCH_ALL
This is more precise, so we can iterate all target_arch with QEMU_ARCH_ALL

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Message-ID: <20261027061504.2213-3-luoyonggang@gmail.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
2026-10-28 09:25:48 +01:00
Yonggang Luo 0b1f2d1121 qemu/arch-defs: extract QEMU_ARCH_BIT for QEMU_ARCH_* enums
Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Message-ID: <20261027061504.2213-2-luoyonggang@gmail.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
2026-10-28 09:25:48 +01:00
Bernhard Beschow f024c81826 hw/arm/fsl-imx8m: Fix typo
This is IMX8MP and IMX8MM, not IMX6.

Fixes: 0c105b2615 ("hw/arm/fsl-imx8mp: Add Ethernet controller")
Fixes: 857670200c ("hw/arm/fsl-imx8mm: Adding support for ENET ethernet controller")
Reviewed-by: Gaurav Sharma <gaurav.sharma_7@nxp.com>
Reviewed-by: Bin Meng <bin.meng@processmission.com>
Signed-off-by: Bernhard Beschow <shentey@gmail.com>
Message-ID: <20261006083445.30362-32-shentey@gmail.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
2026-10-28 09:25:43 +01:00
Bernhard Beschow d7691605e0 hw/arm/fsl-imx7: Derive from TYPE_SYS_BUS_DEVICE
Deriving from TYPE_SYS_BUS_DEVICE fixes the SoC object to be reset
upon machine reset.

Remove clearing user-creatable which is implicit for SysBus-based
devices.

Reviewed-by: Bin Meng <bin.meng@processmission.com>
Signed-off-by: Bernhard Beschow <shentey@gmail.com>
Message-ID: <20261006083445.30362-17-shentey@gmail.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
2026-10-28 09:25:39 +01:00
Bernhard Beschow 44aa5fb16d hw/arm/fsl-imx6ul: Derive from TYPE_SYS_BUS_DEVICE
Deriving from TYPE_SYS_BUS_DEVICE fixes the SoC object to be reset
upon machine reset.

Remove clearing user-creatable which is implicit for SysBus-based
devices.

Reviewed-by: Bin Meng <bin.meng@processmission.com>
Signed-off-by: Bernhard Beschow <shentey@gmail.com>
Message-ID: <20261006083445.30362-16-shentey@gmail.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
2026-10-28 09:25:39 +01:00
Bernhard Beschow 050462fac9 hw/arm/fsl-imx6: Derive from TYPE_SYS_BUS_DEVICE
Deriving from TYPE_SYS_BUS_DEVICE fixes the SoC object to be reset
upon machine reset.

Remove clearing user-creatable which is implicit for SysBus-based
devices.

Reviewed-by: Bin Meng <bin.meng@processmission.com>
Signed-off-by: Bernhard Beschow <shentey@gmail.com>
Message-ID: <20261006083445.30362-15-shentey@gmail.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
2026-10-28 09:25:39 +01:00
Bernhard Beschow 1555a14f19 hw/arm/fsl-imx31: Derive from TYPE_SYS_BUS_DEVICE
Deriving from TYPE_SYS_BUS_DEVICE fixes the SoC object to be reset
upon machine reset.

Remove clearing user-creatable which is implicit for SysBus-based
devices.

Reviewed-by: Bin Meng <bin.meng@processmission.com>
Signed-off-by: Bernhard Beschow <shentey@gmail.com>
Message-ID: <20261006083445.30362-14-shentey@gmail.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
2026-10-28 09:25:39 +01:00
Bernhard Beschow 8390abfa91 hw/arm/fsl-imx25: Derive from TYPE_SYS_BUS_DEVICE
Deriving from TYPE_SYS_BUS_DEVICE fixes the SoC object to be reset
upon machine reset.

Remove clearing user-creatable which is implicit for SysBus-based
devices.

Reviewed-by: Bin Meng <bin.meng@processmission.com>
Signed-off-by: Bernhard Beschow <shentey@gmail.com>
Message-ID: <20261006083445.30362-13-shentey@gmail.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
2026-10-28 09:25:39 +01:00
Bernhard Beschow d9abd0253b hw/watchdog/wdt_imx2: Remove redundant attributes
Since WDT and WDE are write one once bits, their values always
correspond with their respective locked attributes. Thus, the attributes
are redundant. Take advantage of this observation to simplify the code.

Note that removing the attributes changes the vmstate structure which
constitutes a migration break. This is allowed since QEMU does not
guarantee migration compatibility for i.MX devices between feature
releases.

Signed-off-by: Bernhard Beschow <shentey@gmail.com>
Reviewed-by: Bin Meng <bin.meng@processmission.com>
Message-ID: <20261006083445.30362-5-shentey@gmail.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
2026-10-28 09:25:37 +01:00
Bernhard Beschow 98d21eef2c hw/watchdog/wdt_imx2: Clear WDT lock on reset
The WDT bit gets reset and becomes writeable after power on reset which
imx2_wdt_reset() represents. While the WDT bit in the WCR register
already gets reset, its locked attribute wasn't. Fix this inconsistency
by adding the missing unlock of its locked attribute.

Cc: qemu-stable@nongnu.org
Fixes: daca13d495 ("hw/watchdog: Implement full i.MX watchdog support")
Reported-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Bin Meng <bin.meng@processmission.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Bernhard Beschow <shentey@gmail.com>
Message-ID: <20261006083445.30362-4-shentey@gmail.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
2026-10-28 09:25:37 +01:00
Richard Henderson c81ee5d570 Merge tag 'pull-ppc-for-11.2-sf-20261028' of https://gitlab.com/harshpb/qemu into staging
ppc queue for 2026-10-28

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCAAdFiEEa4EM1tK+EPOIPSFCRUTplPnWj7sFAmrhhToACgkQRUTplPnW
# j7uZnw/+OvWVsLH/lDUYqmpzZcYCqsJ9t/L407RcT5FvzTOpMiH95s7u8Hif/siz
# ZV4iCP+kwwcsTFLjvLoCpCo+iY90XoeB1ThfNYmLQsJP75ze3HtAzRbk9L4NLNbK
# xUdyRtAYDEb4peB5UTlwPufxS768swjYl3vybZUdz3TiGW06D/Lzz2c47ScZRUeo
# TyU37T//v1bS+j5pIkosqfL8BegCUSvwdA3xIRbwX6rzyqawRZKWT9PHc7oEs+JA
# 7FtsYhUFkaH7rfSyYVMb/hLs/RadvU17s0WBP025pibf/xjO0BCeFelUS1JZYolU
# MrSMlbJJCJRh6G3KeHnd9ZUin8Ogsrw82xI/IRNoF5WzyO946mMvRxvv1wW36Av8
# SZG/F+LkeQ1spq/S0ngASunOiSLxfDpQ4Rs9Q8e3tNZljl693/Ax3mmtpJqRInDe
# FxTEcx2dP+9xPVEoGCjiPSCoKg0ovhDwvRjhvaAOrbnDcXSwTalqfJ8WdhJMVb7G
# Jx+GppFe/x+xR0c/+BfvG138GbqWPo/javCNiJ7ScJ6aerPN8nCE4pFs+gxXqp8b
# 7cfKMihRpbgYC6vC5NY3smC3lvglLo70X6okx4UTJkABm/XiXRE70kS0vvCa/93t
# xGJmI/oYH8kOB2PusBtTHoqb7/cP/x3GflXyQ67qDC+bcSdxA/4=
# =wHdy
# -----END PGP SIGNATURE-----
# gpg: Signature made Wed 28 Oct 2026 12:16:42 AM CDT
# gpg:                using RSA key 6B810CD6D2BE10F3883D21424544E994F9D68FBB
# gpg: Good signature from "Harsh Prateek Bora <harsh.prateek.bora@gmail.com>" [undefined]
# gpg:                 aka "Harsh Prateek Bora <harshpb@linux.ibm.com>" [undefined]
# gpg: WARNING: This key is not certified with a trusted signature!
# gpg:          There is no indication that the signature belongs to the owner.
# Primary key fingerprint: 6B81 0CD6 D2BE 10F3 883D  2142 4544 E994 F9D6 8FBB

* tag 'pull-ppc-for-11.2-sf-20261028' of https://gitlab.com/harshpb/qemu:
  spapr-vscsi: clamp adapter info DMA write length to struct size
  hw/ppc/spapr: Add the "rtas-version" property to /rtas
  hw/net/spapr_llan: validate RxBufPool fields on migration load
  tests/functional/ppc64: extend ppc64 powernv net device tests
  tests/functional/ppc64: extend pseries migration tests
  hw/pci-host/pnv_phb4: fix guest-triggerable abort on 8-byte config access

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2026-10-28 03:08:07 -05:00
Showta Ishizaki 40c0f489a8 hw/ppc/spapr: Add the "rtas-version" property to /rtas
PAPR requires every property listed in its table of /rtas device tree
properties to be present before the OS is booted (R-7.2.6-3 and Table
20 in PAPR v10.60; the same requirement is in LoPAR 2.9 and LoPAPR
1.1). One of them is "rtas-version", an integer encoding of the RTAS
interface version, and PAPR says it describes version 1 of that
interface.

spapr_dt_rtas() sets "rtas-size", "rtas-error-log-max" and
"rtas-event-scan-rate" but never "rtas-version", so a client that reads
it finds no RTAS: NetBSD's RTAS driver fails to attach when the
property is absent.

Set it to 1, the version PAPR describes.

Reviewed-by: Amit Machhiwal <amachhiw@linux.ibm.com>
Tested-by: Amit Machhiwal <amachhiw@linux.ibm.com>
Signed-off-by: Showta Ishizaki <zakinko@snowrabbit.org>
Link: https://lore.kernel.org/qemu-devel/20261005161859.3119EC92F0@bambi.snowrabbit.org
Signed-off-by: Harsh Prateek Bora <harshpb@linux.ibm.com>
2026-10-28 10:45:51 +05:30
Richard Henderson 29b1dc631d Merge tag 'block-pull-request' of https://gitlab.com/stefanha/qemu into staging
Pull request

Niklas Cassel and Sam Li's fixes and cleanups for zoned storage.

# -----BEGIN PGP SIGNATURE-----
#
# iQEzBAABCgAdFiEEhpWov9P5fNqsNXdanKSrs4Grc8gFAmrhC+8ACgkQnKSrs4Gr
# c8jHyAf7BkY+13DliYP8OGeFUxuhtTegGvjdgj4HDuQ7oMd9qgqI7LPr3O00wxFY
# 1a+yitUsB2dPK0w2ktydF2wsF5AJ+ysPloDXiJTeuYH+Tjb3Kh9KNEwiPaH2l3qq
# MsOsj8UAzCH+FLL+q5kUpnmnOw1UhQuY1WOiiIVCnFTu8x78WZxWRurYLiSQG9Ld
# Nsy8j6UKFmqKE1be531D6Ltsrd+Tx7wTafI4JhFGaxDc8+kBYscn+nshUjv5SdST
# X3TAJ0G8xVzt3rsTO7cqo5dwhTT/9tHc99skTmuJHJOVNWiXpn279rOdH5CGNjd/
# qusjskanLzj5TSquP9moPhGJ9DBdBQ==
# =B3yU
# -----END PGP SIGNATURE-----
# gpg: Signature made Tue 27 Oct 2026 03:39:11 PM CDT
# gpg:                using RSA key 8695A8BFD3F97CDAAC35775A9CA4ABB381AB73C8
# gpg: Good signature from "Stefan Hajnoczi <stefanha@redhat.com>" [unknown]
# gpg:                 aka "Stefan Hajnoczi <stefanha@gmail.com>" [unknown]
# gpg: WARNING: This key is not certified with a trusted signature!
# gpg:          There is no indication that the signature belongs to the owner.
# Primary key fingerprint: 8695 A8BF D3F9 7CDA AC35  775A 9CA4 ABB3 81AB 73C8

* tag 'block-pull-request' of https://gitlab.com/stefanha/qemu:
  block: do not use CoroutineIOCompletion to hold a return value
  file-posix: reject a zone append to a full or conventional zone
  file-posix: reject a zone append past the device capacity
  block: remove BlockLimits.max_append_sectors
  virtio-blk: add a max-append-sectors property
  file-posix: remove the zone append write granularity check
  block: reject a zone append that is larger than a zone
  block: reject zone appends that are not a multiple of the sector size
  hw/block: reject a zoned device that the block sizes cannot address
  virtio-blk: check the write granularity of writes to sequential zones
  hw/block: derive the zone write granularity from the block sizes
  block: add a helper to check if a zone is conventional
  block: add a helper for the index of the zone an offset falls in
  virtio-blk: do not merge requests across a zone boundary
  block: widen BlockLimits.zone_size to uint64_t

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2026-10-27 20:02:57 -05:00
Niklas Cassel 7462fa2d7d file-posix: reject a zone append to a full or conventional zone
raw_co_prw() replaces the offset of a zone append with the write pointer
of the addressed zone, which assumes that the stored value names a
position inside that zone. It does not in two cases.

A full zone has its write pointer recorded at the end of the zone, since
get_zones_wp() stores start + len for BLK_ZONE_COND_FULL. That is the
first sector of the following zone, so the append is submitted there. The
kernel accepts it whenever that zone is empty, because it is a legal
write at its write pointer, and the completion path advances the wrong
zone because it recomputes the zone index from the replaced offset. The
data is written to a zone that was never addressed and success is
returned:

  zone 2 finished, then a 4 KiB append to zone 2:
  After zap done, the append sector is 0x180000     <- zone 3
  zone 2: wptr 0x180000, zcond:14 (full)
  zone 3: wptr 0x180008                             <- advanced

A conventional zone has no write pointer at all, and its array entry
carries only the type marker in the top bit, so the offset becomes
negative and the write fails with EINVAL. That is harmless but it reports
nothing about the actual mistake.

Reject both while the write pointer lock is held, since the state has to
be read and acted on atomically. check_zoned_request() in virtio-blk
refuses an append to a conventional zone, so that case needs a caller
that goes to the driver directly, but nothing there examines whether a
zone is full, so a guest can reach the misdirected write.

Fixes: 4751d09adc ("block: introduce zone append write for zoned devices")
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Niklas Cassel <cassel@kernel.org>
Message-id: 20260921142819.2916043-15-cassel@kernel.org
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2026-10-27 16:30:35 -04:00
Niklas Cassel f1c0f0ba7a block: remove BlockLimits.max_append_sectors
The field described the largest zone append that a backend accepts. It
had one writer and one reader, and neither is left.

file-posix filled it from the zone_append_max_bytes queue attribute,
which bounds REQ_OP_ZONE_APPEND, an operation it never issues: Linux has
no userspace interface for one, so raw_co_zone_append() substitutes the
write pointer of the zone for the offset and the request reaches the
host as a plain pwritev().

The transfer limit does not apply either, no more than it does to an
ordinary write. This driver reports max_hw_transfer but never sets
BlockLimits.max_transfer, which is what bdrv_aligned_pwritev() splits
by, so a request of any size goes to the host kernel whole and is split
there: on a null_blk device whose zone_append_max_bytes is 130560, a
16 MiB append completes and advances the write pointer by 16 MiB. That
is safe for a sequential zone, as Linux issues the fragments of a split
write in order, with zone write plugging since 6.10 and zone write
locking before that.

virtio-blk was the reader, and now takes what it reports to a guest from
a property instead.

Remove the field and the assignment that filled it. Keeping it would be
worse than not having it: a driver that set it, believing something
enforced it, would be silently ignored.

Signed-off-by: Niklas Cassel <cassel@kernel.org>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-id: 20260921142819.2916043-13-cassel@kernel.org
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2026-10-27 16:30:35 -04:00
Niklas Cassel ba94683d49 virtio-blk: add a max-append-sectors property
The maximum zone append size that the device reports to its driver was
taken from BlockLimits.max_append_sectors, a limit of the host disk that
the backend happens to sit on. A guest reads it out of the configuration
space, so it becomes part of what the guest has been told about its
device, and migrating that guest to a host whose disks report something
smaller leaves it appending more than the device accepts.

Make it a property, as max-discard-sectors and max-write-zeroes-sectors
already are, so that the value a guest is given is part of the device
model and does not change under it. Nothing from BlockLimits reaches the
configuration space any more.

Zero is a valid value here, unlike for those two. There is no feature bit
for zone append, and a maximum of zero is how the specification has a
device say that it does not support the operation (virtio 1.4, 5.2.5.2).
It is also what a ZBC or ZAC disk is: such a disk has no zone append
command at all, and Linux emulates one in its block layer.

What is reported is capped by the size of a zone. The specification asks
for the largest append that can be carried out, and one larger than a
zone never can be, so the default would otherwise advertise a size that
the block layer refuses. The cap tells a guest nothing about the host
that zone_sectors has not already told it.

Signed-off-by: Niklas Cassel <cassel@kernel.org>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-id: 20260921142819.2916043-12-cassel@kernel.org
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2026-10-27 16:30:35 -04:00
Niklas Cassel 12c6132806 hw/block: reject a zoned device that the block sizes cannot address
The write granularity that a frontend reports is derived from the logical
and the physical block size, which are properties of the device model,
while the granularity that the medium requires and the write pointers
that it holds belong to the backend. Nothing ties them together, and
where they disagree a guest is told about a device it cannot use.

A backend can require a coarser granularity than the block sizes express.
A 512e host managed disk has a logical block size of 512 and requires
writes to a sequential zone to be a multiple of 4096, so attaching it
with a finer physical block size reports a granularity that the disk will
not accept, and the guest is given a plain I/O error for a request that
it was told was valid.

The write pointers can disagree in the same way. They outlive any
particular use of the device, while the block sizes are chosen afresh
every time it is attached, so a zone written with logical_block_size=512
leaves a write pointer that logical_block_size=4096 cannot address. A
zone report expresses it in 512 byte sectors, so the guest is told about
a position that does not fall on a logical block boundary, which it can
neither read nor write, and the zone can then only be recovered by
resetting it. The reverse is harmless: a pointer laid down with a larger
logical block size is still a multiple of a smaller one.

Check both at realize time, along with the zone size and the zone
capacity, and refuse to start otherwise. The write pointers are already
held in memory by the driver, so this costs no I/O.

The check uses blkconf_zone_write_granularity(), the same value that a
frontend reports to its guest and validates requests against, so the
three cannot disagree.

Signed-off-by: Niklas Cassel <cassel@kernel.org>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-id: 20260921142819.2916043-8-cassel@kernel.org
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2026-10-27 16:30:35 -04:00