]> git.ipfire.org Git - thirdparty/qemu.git/log
thirdparty/qemu.git
2 months agohw/usb/hcd-ehci.h: Fix coding style issues reported by checkpatch
Jamin Lin [Wed, 11 Mar 2026 07:26:17 +0000 (08:26 +0100)] 
hw/usb/hcd-ehci.h: Fix coding style issues reported by checkpatch

No functional change.

Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20260424080508.53992-4-jamin_lin@aspeedtech.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
2 months agohw/usb/hcd-ehci: Remove unused EHCIfstn structure and dead code
Jamin Lin [Fri, 24 Apr 2026 08:05:12 +0000 (08:05 +0000)] 
hw/usb/hcd-ehci: Remove unused EHCIfstn structure and dead code

The EHCIfstn structure, defined according to EHCI spec section 3.7,
is currently unused in the EHCI implementation. Remove it to reduce
unused code and improve maintainability.

Additionally, drop a block of disabled (#if 0) code in
ehci_state_advqueue() that was never implemented. This code path
is incomplete and has no functional impact.

No functional change.

Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Message-ID: <20260424080508.53992-3-jamin_lin@aspeedtech.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
2 months agohw/arm/virt: Do not select Kconfig symbol PCI_EXPRESS
Philippe Mathieu-Daudé [Wed, 22 Apr 2026 09:22:31 +0000 (11:22 +0200)] 
hw/arm/virt: Do not select Kconfig symbol PCI_EXPRESS

The PCIe bus is not provided by the Virt machine but by
its GPEX host bridge (selected via PCI_EXPRESS_GENERIC_BRIDGE).

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20260423170229.64655-4-philmd@linaro.org>

2 months agohw/cxl: Define cxl_fmws_get_all_sorted() stub
Philippe Mathieu-Daudé [Wed, 22 Apr 2026 09:11:09 +0000 (11:11 +0200)] 
hw/cxl: Define cxl_fmws_get_all_sorted() stub

Add a stub for cxl_fmws_get_all_sorted() to fix building
a QEMU configured with the '--without-default-devices' option:

  Undefined symbols for architecture arm64:
    "_cxl_fmws_get_all_sorted", referenced from:
        _cxl_build_cedt in hw_acpi_cxl.c.o

Note, the CXL <-> ACPI Kconfig relationship is a bit convoluted.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20260423170229.64655-3-philmd@linaro.org>

2 months agohw/sh4/sh7750: Remove forgotten abort() in the MM_ITLB_DATA handler
Thomas Huth [Wed, 22 Apr 2026 07:54:29 +0000 (09:54 +0200)] 
hw/sh4/sh7750: Remove forgotten abort() in the MM_ITLB_DATA handler

QEMU currently aborts when the guest writes to the MM_ITLB_DATA register:

 echo "writel 0xf3000000 0x11223344" | \
  ./qemu-system-sh4 -M r2d -display none -accel qtest -qtest stdio
 [I 0.000000] OPENED
 [R +0.004476] writel 0xf3000000 0x11223344
 Aborted                    (core dumped)

Looking at the history of the code, the abort() here has likely just
been forgotten when the register handler had been implemented (it used
to be a reminder about unimplemented functionality initially):

 https://gitlab.com/qemu-project/qemu/-/commit/9f97309a70f12df5f9104f1f

Thus simply remove the abort() now to get rid of the problem.

Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3420
Signed-off-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20260422075429.341409-1-thuth@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
2 months agohw/misc: Fix the valid access size to the avr-power device
Thomas Huth [Tue, 21 Apr 2026 08:29:35 +0000 (10:29 +0200)] 
hw/misc: Fix the valid access size to the avr-power device

Accessing the device with in non-single byte mode currently causes
QEMU to abort:

 $ echo "writew 0x800064 0x4142" | \
   ./qemu-system-avr -M mega2560 -display none -qtest stdio -accel qtest
 [I 0.000000] OPENED
 [R +0.001784] writew 0x800064 0x4142
 qemu-system-avr: ../../devel/qemu/hw/misc/avr_power.c:58: avr_mask_write:
  Assertion `offset == 0' failed.
 Aborted                    (core dumped)

Set the valid max access size to 1 to fix the problem.

Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3393
Signed-off-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20260421082935.85995-1-thuth@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
2 months agohw/ppc/amigaone: remove duplicate include
Osama Abdelkader [Mon, 20 Apr 2026 16:40:58 +0000 (18:40 +0200)] 
hw/ppc/amigaone: remove duplicate include

hw/ppc/ppc.h is included twice

Signed-off-by: Osama Abdelkader <osama.abdelkader@gmail.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: BALATON Zoltan <balaton@eik.bme.hu>
Message-ID: <20260420164058.335872-1-osama.abdelkader@gmail.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
2 months agohw/hyperv: remove duplicate include
Osama Abdelkader [Mon, 20 Apr 2026 16:34:53 +0000 (18:34 +0200)] 
hw/hyperv: remove duplicate include

exec/target_page.h is included twice

Signed-off-by: Osama Abdelkader <osama.abdelkader@gmail.com>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Message-ID: <20260420163452.327350-2-osama.abdelkader@gmail.com>
Reviewed-by: Maciej S. Szmigiero <maciej.szmigiero@oracle.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20260420163844.332663-1-osama.abdelkader@gmail.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
2 months agohw/virtio/virtio-iommu: remove duplicate include
Osama Abdelkader [Mon, 20 Apr 2026 16:30:50 +0000 (18:30 +0200)] 
hw/virtio/virtio-iommu: remove duplicate include

qemu/reserved-region.h is included twice

Signed-off-by: Osama Abdelkader <osama.abdelkader@gmail.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20260420163050.321668-1-osama.abdelkader@gmail.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
2 months agohw/arm, hw/ppc: Remove unnecessary audio.h includes from board code
Peter Maydell [Fri, 17 Apr 2026 09:38:05 +0000 (10:38 +0100)] 
hw/arm, hw/ppc: Remove unnecessary audio.h includes from board code

Some boards (mostly arm, but also ppc/prep) include audio.h, but they
don't need anything from it.  Drop the unnecessary include lines.

These seem to have been introduced with commits 2b16397264a8e,
b8ab0303de, which added the machine-default audiodev handling, but as
far as I can tell they were unecessary right from the start, as the
machine_add_audiodev_property() function has always been in boards.h.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Message-ID: <20260417093805.1076954-1-peter.maydell@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
2 months agoati-vga: mask out lock bit from CUR_OFFSET in cursor offset calculation
Junjie Cao [Tue, 14 Apr 2026 21:35:23 +0000 (05:35 +0800)] 
ati-vga: mask out lock bit from CUR_OFFSET in cursor offset calculation

Bit 31 of CUR_OFFSET is the cursor lock bit, not part of the actual
cursor address (bits 26:4).  Although the callers already check for the
lock bit and return early, mask it out with 0x07fffff0 when computing
the cursor source offset so the calculation only uses the address bits.

Suggested-by: BALATON Zoltan <balaton@eik.bme.hu>
Signed-off-by: Junjie Cao <junjie.cao@intel.com>
Reviewed-by: BALATON Zoltan <balaton@eik.bme.hu>
Message-ID: <20260414213523.1125859-2-junjie.cao@intel.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
2 months agoati-vga: fix unsigned integer overflow in cursor bounds checks
Junjie Cao [Tue, 14 Apr 2026 14:14:58 +0000 (22:14 +0800)] 
ati-vga: fix unsigned integer overflow in cursor bounds checks

The cursor bounds checks compare (srcoff + N) against vram_size, but
both sides are uint32_t so the addition can wrap past UINT32_MAX when
srcoff underflows from the cur_hv_offs subtraction, causing the check
to be bypassed.

Rewrite the checks as (srcoff > vram_size - N) to avoid the
overflow-prone addition, matching the style already used in
ati_mm_read() and ati_mm_write().

Cc: qemu-stable@nongnu.org
Fixes: 2f1fbe6ee9b5 ("ati-vga: Make sure hardware cursor data is within vram")
Signed-off-by: Junjie Cao <junjie.cao@intel.com>
Message-ID: <20260414141458.1076014-1-junjie.cao@intel.com>
Reviewed-by: BALATON Zoltan <balaton@eik.bme.hu>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
2 months agohw/ppc/e500: fix bus-frequency property hardcoded to zero in CPU FDT node
Vivien LEGER [Sat, 11 Apr 2026 15:45:35 +0000 (17:45 +0200)] 
hw/ppc/e500: fix bus-frequency property hardcoded to zero in CPU FDT node

The bus-frequency property in the CPU FDT node was hardcoded to 0.
This is incorrect - it should reflect the actual platform bus clock
frequency, as firmware and RTOSes use it to derive peripheral clock
rates.

Notably, the RTEMS QorIQ BSP uses bus-frequency to program the MPIC
global timer interval. With bus-frequency=0, the timer interval
overflows to ~85 seconds, preventing any clock interrupts from firing.

Fix by adding a bus_freq field to PPCE500MachineClass and using it in
the FDT generator. Set bus_freq = PLATFORM_CLK_FREQ_HZ (400MHz) for
existing machines, matching the existing clock_freq value.

Signed-off-by: Vivien LEGER <vivien.leger@gmail.com>
Reviewed-by: Bernhard Beschow <shentey@gmail.com>
Message-ID: <20260411154535.1451361-1-vivien.leger@gmail.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
2 months agohw/arm/smmuv3: Avoid including CONFIG_DEVICES in hw/ header
Philippe Mathieu-Daudé [Tue, 10 Mar 2026 11:06:19 +0000 (12:06 +0100)] 
hw/arm/smmuv3: Avoid including CONFIG_DEVICES in hw/ header

By turning the inline functions into stubs we can avoid the
use of target-specific CONFIG_DEVICES include in a hw/ header,
allowing to build the source files including it as common objects.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Shameer Kolothum <skolothumtho@nvidia.com>
Message-Id: <20260410200031.18572-3-philmd@linaro.org>

2 months agohw/arm/smmuv3: Have smmuv3_accel_init() take an Error* parameter
Philippe Mathieu-Daudé [Thu, 9 Apr 2026 11:35:56 +0000 (13:35 +0200)] 
hw/arm/smmuv3: Have smmuv3_accel_init() take an Error* parameter

By giving smmuv3_accel_init() the ability to populate an error,
we can fail early in smmu_realize() when CONFIG_ARM_SMMUV3_ACCEL
is not available, simplifying smmu_validate_property().

Suggested-by: Shameer Kolothum Thodi <skolothumtho@nvidia.com>
Co-developed-by: Shameer Kolothum Thodi <skolothumtho@nvidia.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Shameer Kolothum <skolothumtho@nvidia.com>
Message-Id: <20260410200031.18572-2-philmd@linaro.org>

2 months agophysmem: Simplify dirty memory type checks with loop
Bin Guo [Wed, 1 Apr 2026 10:00:05 +0000 (18:00 +0800)] 
physmem: Simplify dirty memory type checks with loop

In physical_memory_range_includes_clean(), we have three nearly identical
if-statements checking different DIRTY_MEMORY types (VGA, CODE, MIGRATION).
This code duplication makes maintenance harder and increases the risk of
inconsistencies when adding new dirty memory types.

Replace the repetitive checks with a simple loop that iterates through
all DIRTY_MEMORY_NUM types, checking only those specified in the mask.
This reduces code size and makes it easier to add new dirty memory types
in the future.

Signed-off-by: Bin Guo <guobin@linux.alibaba.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20260401100005.20651-1-guobin@linux.alibaba.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
2 months agohw/tpm: add PPI support to tpm-tis-device for ARM64 virt
Mohammadfaiz Bawa [Fri, 27 Mar 2026 17:32:09 +0000 (23:02 +0530)] 
hw/tpm: add PPI support to tpm-tis-device for ARM64 virt

Add PPI memory region and ACPI _STA, _DSM to tpm-tis-sysbus so
Windows 11 ARM64 guests no longer log Event ID 15 errors from
tpm.sys on every boot.

Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>
Signed-off-by: Mohammadfaiz Bawa <mbawa@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20260327173209.148180-4-mbawa@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
2 months agohw/acpi/tpm: parameterize PPI base address in tpm_build_ppi_acpi
Mohammadfaiz Bawa [Fri, 27 Mar 2026 17:32:08 +0000 (23:02 +0530)] 
hw/acpi/tpm: parameterize PPI base address in tpm_build_ppi_acpi

Add a ppi_base parameter to tpm_build_ppi_acpi() instead of
hardcoding TPM_PPI_ADDR_BASE. This prepares for ARM64 support where
PPI memory is dynamically allocated by the platform bus and the
address is not known at compile time.

Update the x86 callers (ISA TIS and CRB) to pass TPM_PPI_ADDR_BASE
explicitly. No behavioral change.

Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>
Signed-off-by: Mohammadfaiz Bawa <mbawa@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20260327173209.148180-3-mbawa@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
2 months agodocs/specs/tpm: document PPI support on ARM64 virt
Mohammadfaiz Bawa [Fri, 27 Mar 2026 17:32:07 +0000 (23:02 +0530)] 
docs/specs/tpm: document PPI support on ARM64 virt

Document that tpm-tis-device on the ARM virt machine supports PPI
with dynamically allocated MMIO via the platform bus, unlike x86
where PPI is at the fixed address 0xFED45000.

Also add hw/arm/virt-acpi-build.c and hw/acpi/tpm.c to the list
of files related to TPM ACPI tables.

Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>
Signed-off-by: Mohammadfaiz Bawa <mbawa@redhat.com>
Message-ID: <20260327173209.148180-2-mbawa@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
2 months agoqom: Restrict compat properties API to system emulation
Philippe Mathieu-Daudé [Wed, 25 Mar 2026 14:47:12 +0000 (15:47 +0100)] 
qom: Restrict compat properties API to system emulation

Move compat properties API definitions to their own file
unit, compile it only when system emulation is configured.
Add a pair of stubs for user emulation.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Michael Tokarev <mjt@tls.msk.ru>
Message-Id: <20260325151728.45378-6-philmd@linaro.org>

2 months agoqom: Declare compat properties API in 'qom/compat-properties.h'
Philippe Mathieu-Daudé [Wed, 25 Mar 2026 14:47:02 +0000 (15:47 +0100)] 
qom: Declare compat properties API in 'qom/compat-properties.h'

While most of QEMU files use the QOM concept, few of them
use the compatibility properties API (mostly use in system
emulation). Move its prototype to a new "qom/compat-properties.h"
header, keeping "qom/object.h" for generic QOM.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Michael Tokarev <mjt@tls.msk.ru>
Message-Id: <20260325151728.45378-5-philmd@linaro.org>

2 months agoqom: Declare GlobalProperty structure in 'qom/compat-properties.h'
Philippe Mathieu-Daudé [Wed, 25 Mar 2026 14:44:40 +0000 (15:44 +0100)] 
qom: Declare GlobalProperty structure in 'qom/compat-properties.h'

While GlobalProperty is expected to only be used by QDev board
layer, it is used by the lower QOM API, so define it in the
qom/ namespace. This helps to build binary which use QOM but
don't need the QDev layer.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Michael Tokarev <mjt@tls.msk.ru>
Message-Id: <20260325151728.45378-4-philmd@linaro.org>

2 months agohw/core: Move compat_props_add() to 'hw/core/boards.h'
Philippe Mathieu-Daudé [Wed, 25 Mar 2026 14:43:15 +0000 (15:43 +0100)] 
hw/core: Move compat_props_add() to 'hw/core/boards.h'

compat_props_add() is only used by board models, no need
to expose it to any device model. Restrict by defining it
only in "hw/core/boards.h".

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Michael Tokarev <mjt@tls.msk.ru>
Message-Id: <20260325151728.45378-3-philmd@linaro.org>

2 months agohw: add compat machines for 11.1
Cornelia Huck [Tue, 31 Mar 2026 14:03:47 +0000 (16:03 +0200)] 
hw: add compat machines for 11.1

Add 11.1 machine types for arm/i440fx/m68k/q35/s390x/spapr.

Reviewed-by: Eric Farman <farman@linux.ibm.com> # s390
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Message-ID: <20260331140347.653404-1-cohuck@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
2 months agosystem/memory: Constify various AddressSpace arguments (flatview)
Philippe Mathieu-Daudé [Thu, 19 Mar 2026 12:26:31 +0000 (13:26 +0100)] 
system/memory: Constify various AddressSpace arguments (flatview)

Mark the AddressSpace structure const when it is only accessed
read-only.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Message-Id: <20260319191017.12636-2-philmd@linaro.org>

2 months agohw/hyperv: Replace legacy ld_phys() -> address_space_ld()
Philippe Mathieu-Daudé [Thu, 19 Mar 2026 08:02:18 +0000 (09:02 +0100)] 
hw/hyperv: Replace legacy ld_phys() -> address_space_ld()

Prefer the address_space_ld/st API over the legacy ld/st_phys()
because it allow checking for bus access fault, which shouldn't
happen here.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Acked-by: Maciej S. Szmigiero <maciej.szmigiero@oracle.com>
Message-ID: <20260319082954.65069-1-philmd@linaro.org>

2 months agohw/ppc/spapr: Un-inline rtas_load/store() helpers
Philippe Mathieu-Daudé [Wed, 18 Mar 2026 16:37:41 +0000 (17:37 +0100)] 
hw/ppc/spapr: Un-inline rtas_load/store() helpers

The 32-bit binary doesn't use these helpers, so don't need to
compile them. Rather than using 64-bit target #ifdef'ry in a
global header, un-inline the calls since the helpers are called
from I/O (cold) path.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Harsh Prateek Bora <harshpb@linux.ibm.com>
Reviewed-by: Chinmay Rath <rathc@linux.ibm.com>
Acked-by: Glenn Miles <milesg@linux.ibm.com>
Message-Id: <20260319111936.68041-2-philmd@linaro.org>

2 months agohw/tpm: Simplify tpm_ppi_enabled()
Philippe Mathieu-Daudé [Tue, 17 Mar 2026 11:42:09 +0000 (12:42 +0100)] 
hw/tpm: Simplify tpm_ppi_enabled()

TPM instances don't expose any "ppi" property anymore,
remove that dead code.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>
Message-Id: <20260317120241.16320-6-philmd@linaro.org>

2 months agohw/tpm: Propagate @ppi_enabled to tpm_tis_reset() and remove in TPMState
Philippe Mathieu-Daudé [Tue, 17 Mar 2026 11:41:31 +0000 (12:41 +0100)] 
hw/tpm: Propagate @ppi_enabled to tpm_tis_reset() and remove in TPMState

Of the TPM devices using FIFO mode, only the ISA variant has
PPI, and calls tpm_ppi_init() to initialize the PPI state.
Propagate @ppi_enabled to tpm_tis_reset() so it only resets
the PPI part when requested (ISA case) otherwise the PPI is in
uninitialized state. Remove the now unused TPMState::ppi_enabled
field. Set the generic TPMIfClass::ppi_enabled so ACPI subsystem
can keep checking its availability.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>
Message-Id: <20260317120241.16320-5-philmd@linaro.org>

2 months agohw/tpm: Remove CRBState::ppi_enabled field
Philippe Mathieu-Daudé [Tue, 17 Mar 2026 11:32:06 +0000 (12:32 +0100)] 
hw/tpm: Remove CRBState::ppi_enabled field

The CRBState::ppi_enabled boolean was only set in the
hw_compat_3_1[] array, via the 'ppi=false' property.
We removed all machines using that array, and the array
itself in commit a861ffef237 ("hw/core/machine: Remove
the hw_compat_3_1[] array"). We can safely remove the
now unused property. Since CRB devices always use PPI,
simplify removing the CRBState::ppi_enabled field.
Set the generic TPMIfClass::ppi_enabled so ACPI subsystem
can keep checking its availability.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>
Message-Id: <20260317120241.16320-4-philmd@linaro.org>

2 months agohw/tpm: Add TPMIfClass::ppi_enabled field
Philippe Mathieu-Daudé [Tue, 17 Mar 2026 11:31:42 +0000 (12:31 +0100)] 
hw/tpm: Add TPMIfClass::ppi_enabled field

Each TPM derived device has a @ppi_enabled field, itself
exposed as a QOM property. External layers (like the ACPI
subsystem) wanting to know whether a device implements PPI
has to check for the QOM property available. This can be
simplified by declaring a single field in the TPM interface.

Here we add such field to TPMIfClass, before converting each
TPM devices to use it in the following commits.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>
Message-Id: <20260317120241.16320-3-philmd@linaro.org>

2 months agohw/tpm: Factor tpm_ppi_enabled() out
Philippe Mathieu-Daudé [Tue, 17 Mar 2026 11:26:56 +0000 (12:26 +0100)] 
hw/tpm: Factor tpm_ppi_enabled() out

Factor out tpm_ppi_enabled() before modifying it in a unique place.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>
Message-Id: <20260317120241.16320-2-philmd@linaro.org>

2 months agohw/xtensa: Include full path to target 'cpu.h' header
Philippe Mathieu-Daudé [Fri, 13 Mar 2026 05:08:50 +0000 (06:08 +0100)] 
hw/xtensa: Include full path to target 'cpu.h' header

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Message-Id: <20260313062055.2188-36-philmd@linaro.org>

2 months agohw/tricore: Include full path to target 'cpu.h' header
Philippe Mathieu-Daudé [Fri, 13 Mar 2026 05:10:23 +0000 (06:10 +0100)] 
hw/tricore: Include full path to target 'cpu.h' header

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Message-Id: <20260313062055.2188-35-philmd@linaro.org>

2 months agohw/sparc: Include full path to target 'cpu.h' header
Philippe Mathieu-Daudé [Fri, 13 Mar 2026 05:10:19 +0000 (06:10 +0100)] 
hw/sparc: Include full path to target 'cpu.h' header

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Message-Id: <20260313062055.2188-34-philmd@linaro.org>

2 months agohw/sh4: Include full path to target 'cpu.h' header
Philippe Mathieu-Daudé [Fri, 13 Mar 2026 05:10:10 +0000 (06:10 +0100)] 
hw/sh4: Include full path to target 'cpu.h' header

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Message-Id: <20260313062055.2188-33-philmd@linaro.org>

2 months agohw/s390x: Include full path to target 'cpu.h' header
Philippe Mathieu-Daudé [Fri, 13 Mar 2026 05:07:41 +0000 (06:07 +0100)] 
hw/s390x: Include full path to target 'cpu.h' header

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Message-Id: <20260313062055.2188-32-philmd@linaro.org>

2 months agohw/riscv: Include full path to target 'cpu.h' header
Philippe Mathieu-Daudé [Fri, 13 Mar 2026 05:07:29 +0000 (06:07 +0100)] 
hw/riscv: Include full path to target 'cpu.h' header

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Message-Id: <20260313062055.2188-31-philmd@linaro.org>

2 months agohw/ppc: Include full path to target 'cpu.h' header
Philippe Mathieu-Daudé [Fri, 13 Mar 2026 05:07:16 +0000 (06:07 +0100)] 
hw/ppc: Include full path to target 'cpu.h' header

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Message-Id: <20260313062055.2188-30-philmd@linaro.org>

2 months agohw/or1k: Include full path to target 'cpu.h' header
Philippe Mathieu-Daudé [Fri, 13 Mar 2026 05:09:51 +0000 (06:09 +0100)] 
hw/or1k: Include full path to target 'cpu.h' header

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Message-Id: <20260313062055.2188-29-philmd@linaro.org>

2 months agohw/mips: Include full path to target 'cpu.h' header
Philippe Mathieu-Daudé [Fri, 13 Mar 2026 05:09:08 +0000 (06:09 +0100)] 
hw/mips: Include full path to target 'cpu.h' header

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Message-Id: <20260313062055.2188-28-philmd@linaro.org>

2 months agohw/microblaze: Include full path to target 'cpu.h' header
Philippe Mathieu-Daudé [Fri, 13 Mar 2026 05:09:43 +0000 (06:09 +0100)] 
hw/microblaze: Include full path to target 'cpu.h' header

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Message-Id: <20260313062055.2188-27-philmd@linaro.org>

2 months agohw/m68k: Include full path to target 'cpu.h' header
Philippe Mathieu-Daudé [Fri, 13 Mar 2026 05:09:21 +0000 (06:09 +0100)] 
hw/m68k: Include full path to target 'cpu.h' header

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Message-Id: <20260313062055.2188-26-philmd@linaro.org>

2 months agohw/i386: Include full path to target 'cpu.h' header
Philippe Mathieu-Daudé [Fri, 13 Mar 2026 05:10:00 +0000 (06:10 +0100)] 
hw/i386: Include full path to target 'cpu.h' header

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Message-Id: <20260313062055.2188-25-philmd@linaro.org>

2 months agohw/hppa: Include full path to target 'cpu.h' header
Philippe Mathieu-Daudé [Fri, 13 Mar 2026 05:08:15 +0000 (06:08 +0100)] 
hw/hppa: Include full path to target 'cpu.h' header

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Message-Id: <20260313062055.2188-24-philmd@linaro.org>

2 months agohw/avr: Include full path to target 'cpu.h' header
Philippe Mathieu-Daudé [Fri, 13 Mar 2026 05:08:10 +0000 (06:08 +0100)] 
hw/avr: Include full path to target 'cpu.h' header

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Message-Id: <20260313062055.2188-23-philmd@linaro.org>

2 months agohw/arm: Include full path to target 'cpu.h' header
Philippe Mathieu-Daudé [Fri, 13 Mar 2026 05:08:01 +0000 (06:08 +0100)] 
hw/arm: Include full path to target 'cpu.h' header

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Message-Id: <20260313062055.2188-22-philmd@linaro.org>

2 months agohw/alpha: Include full path to target 'cpu.h' header
Philippe Mathieu-Daudé [Fri, 13 Mar 2026 05:07:47 +0000 (06:07 +0100)] 
hw/alpha: Include full path to target 'cpu.h' header

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Message-Id: <20260313062055.2188-21-philmd@linaro.org>

2 months agohw/misc/cpc: Include missing 'hw/core/cpu.h' header
Philippe Mathieu-Daudé [Fri, 13 Mar 2026 04:42:44 +0000 (05:42 +0100)] 
hw/misc/cpc: Include missing 'hw/core/cpu.h' header

The "hw/core/cpu.h" header is indirectly included. Include it
explicitly otherwise we get when refactoring unrelated headers:

  ../hw/misc/mips_cpc.c:36:53: error: unknown type name 'run_on_cpu_data'
     36 | static void mips_cpu_reset_async_work(CPUState *cs, run_on_cpu_data data)
        |                                                     ^
  ../hw/misc/mips_cpc.c:40:5: error: call to undeclared function 'cpu_reset'
       40 |     cpu_reset(cs);
          |     ^
  ../hw/misc/riscv_cpc.c:34:54: error: unknown type name 'run_on_cpu_data'
     34 | static void riscv_cpu_reset_async_work(CPUState *cs, run_on_cpu_data data)
        |                                                      ^
  ../hw/misc/riscv_cpc.c:39:5: error: call to undeclared function 'cpu_reset'
     39 |     cpu_reset(cs);
        |     ^

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Message-Id: <20260313062055.2188-17-philmd@linaro.org>

2 months agohw/core/cpu: Expose CPUState::start_powered_off docstring
Philippe Mathieu-Daudé [Tue, 26 Aug 2025 14:29:12 +0000 (16:29 +0200)] 
hw/core/cpu: Expose CPUState::start_powered_off docstring

The comment about @start_powered_off is buried within the
CPUState structure. Hoist it to the structure docstring
comment.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20260423170229.64655-6-philmd@linaro.org>

2 months agohw/avr: Build as common unit files
Philippe Mathieu-Daudé [Fri, 13 Mar 2026 04:52:01 +0000 (05:52 +0100)] 
hw/avr: Build as common unit files

Nothing there is target-specific anymore.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Message-Id: <20260313062055.2188-38-philmd@linaro.org>

2 months agoMerge tag 'pull-11.1-virtio-gpu-hotfixes-230426-1' of https://gitlab.com/stsquad...
Stefan Hajnoczi [Fri, 24 Apr 2026 00:51:57 +0000 (20:51 -0400)] 
Merge tag 'pull-11.1-virtio-gpu-hotfixes-230426-1' of https://gitlab.com/stsquad/qemu into staging

virtio-gpu fixes:

  - fix build on Windows due to EGL assumption
  - fix use-after-free on virgl resource

# -----BEGIN PGP SIGNATURE-----
#
# iQEzBAABCgAdFiEEZoWumedRZ7yvyN81+9DbCVqeKkQFAmnqN/sACgkQ+9DbCVqe
# KkR+cAf+INMexc1Wzc81XUs3UamDOPQmIKTu/36P7K3PrVwvwtb/KhIjlgsiUDjy
# thP9wZcMVJNA8heCFOp3kMzydEBbZ3Ywiz5TWulrvGrwBwPDf93+bTlgr1cDzDwI
# bi2CjR4NUHtICGC/6Smh9UbRLMh5FkGB/XpyXr+Gkl+THT4s+evQXP8xYuvbfKZj
# qKsxz2oaCZNqYJRfUPBxNLaiS7VRGVJBaOLSuhLUegQZ4T0CzcyprOfreOfjolwC
# hmGcC1w/Sb1EJZkgE9ZKi30AMXS4NuHfMXHNCI76xIMYd/c9/B19AVUv3ZVIbuNs
# vAdamiBnIRffPLGhttOqhLCndNHGHA==
# =uXFe
# -----END PGP SIGNATURE-----
# gpg: Signature made Thu 23 Apr 2026 11:17:15 EDT
# gpg:                using RSA key 6685AE99E75167BCAFC8DF35FBD0DB095A9E2A44
# gpg: Good signature from "Alex Bennée (Master Work Key) <alex.bennee@linaro.org>" [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: 6685 AE99 E751 67BC AFC8  DF35 FBD0 DB09 5A9E 2A44

* tag 'pull-11.1-virtio-gpu-hotfixes-230426-1' of https://gitlab.com/stsquad/qemu:
  hw/display: don't accidentally autofree existing virgl resources
  ui/sdl2: Fix assumption of EGL presence at runtime

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2 months agoMerge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging
Stefan Hajnoczi [Fri, 24 Apr 2026 00:51:46 +0000 (20:51 -0400)] 
Merge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging

* accel/mshv: ioeventfd fixes
* memory: avoid memmove in flatview_simplify()
* first batch of clang-cl support patches for qemu-ga
* target/i386: fix emulator issue
* target/i386: fix strList leak
* target/i386: emulate: include name of unhandled instruction
* target/i386/tcg: fix decoding of MOVBE and CRC32 in 16-bit mode
* thread-win32: replace CRITICAL_SECTION with SRWLOCK
* target/i386: fix missing PF_INSTR in SIGSEGV context
* util: actually use in pthread_condattr_setclock
* vapic: restore IRQ polling for non-kernel irqchip backends

# -----BEGIN PGP SIGNATURE-----
#
# iQFIBAABCgAyFiEE8TM4V0tmI4mGbHaCv/vSX3jHroMFAmnp9BYUHHBib256aW5p
# QHJlZGhhdC5jb20ACgkQv/vSX3jHroN0Vwf/SCepaTVfA+XXU9ZQLKBch2uPusxM
# iphUdCFyKytydITrIuTQlAQ4EyfnlTouj1qn7SE/cKuRpl9J1Z/eFUGjg0wsDIYM
# J++3wZfGP0foUDYep2bdRQnTiKqgTC93DQUk2mxahdKLqWTo6lSijM0o9NvBvRT1
# ntItGt0KPH1D0eK/cr7+yA4LoMpVzyx+OUHIP+2egJ2el3eRbcI2z6yRPBIAKcSa
# 7xFHcUmHB8gkLdgKX0Lsn80zL69w/au5cwDnjS1k24iZbl3pFsnVVKkgPMSs0Ekm
# Z81nW7s74Woo7VAhrn8A3sYZmJY6wVWNhM1uI3S3Tkg03yGumRrLVAm7tw==
# =hjOY
# -----END PGP SIGNATURE-----
# gpg: Signature made Thu 23 Apr 2026 06:27:34 EDT
# gpg:                using RSA key F13338574B662389866C7682BFFBD25F78C7AE83
# gpg:                issuer "pbonzini@redhat.com"
# gpg: Good signature from "Paolo Bonzini <bonzini@gnu.org>" [full]
# gpg:                 aka "Paolo Bonzini <pbonzini@redhat.com>" [full]
# Primary key fingerprint: 46F5 9FBD 57D6 12E7 BFD4  E2F7 7E15 100C CD36 69B1
#      Subkey fingerprint: F133 3857 4B66 2389 866C  7682 BFFB D25F 78C7 AE83

* tag 'for-upstream' of https://gitlab.com/bonzini/qemu: (25 commits)
  target/i386: emulate: include name of unhandled instruction
  memory: Optimize flatview_simplify() to eliminate redundant memmove calls
  meson: add missing semicolon in pthread_condattr_setclock test
  thread-win32: replace CRITICAL_SECTION with SRWLOCK
  target/i386/tcg: fix decoding of MOVBE and CRC32 in 16-bit mode
  accel/mshv: return correct errno value from ioeventfd failure
  accel/mshv: fix ioeventfd deassignment to forward correct datamatch value
  target/i386/mshv: Fix segment regression in MMIO emu
  meson: Don't require nm for non-modular builds
  storage-daemon: use same link arguments as other tools
  util: Remove unused sys/param.h
  util: Remove unused dirent.h
  osdep: Remove unused strings.h
  hw/ppc: Use glib2 instead of strcasecmp/strncasecmp
  target/xtensa: Use glib2 instead of strcasecmp/strncasecmp
  target/ppc: Use glib2 instead of strcasecmp/strncasecmp
  target/riscv: Use glib2 instead of strcasecmp/strncasecmp
  target/sparc: Use glib2 instead of strcasecmp/strncasecmp
  io: Use glib2 instead of strcasecmp/strncasecmp
  block: Use glib2 instead of strcasecmp/strncasecmp
  ...

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2 months agoMerge tag 'pull-target-arm-20260423' of https://gitlab.com/pm215/qemu into staging
Stefan Hajnoczi [Fri, 24 Apr 2026 00:51:23 +0000 (20:51 -0400)] 
Merge tag 'pull-target-arm-20260423' of https://gitlab.com/pm215/qemu into staging

target-arm queue:
 * virt: Allow user to specify cache topology
 * target/arm: Move OMAP CP15 register definitions to cpregs-omap.c
 * target/arm: cleanups for single-binary work
 * MAINTAINERS: remove people who are no longer active in the project

# -----BEGIN PGP SIGNATURE-----
#
# iQJNBAABCAA3FiEE4aXFk81BneKOgxXPPCUl7RQ2DN4FAmnp7eQZHHBldGVyLm1h
# eWRlbGxAbGluYXJvLm9yZwAKCRA8JSXtFDYM3uxPD/9LdXmnEt8UokGKk8sU5cT9
# +zgUC3tMRrKDF3bBtOWe07OwnLtccgdsf6+fnSh0Jzlac7xMRCU9OxGon6mAq+bh
# Pj9Nie/DI7bGDXN7Q0MKOyI9wxDJl3wTekurDID3Enafebdp1xOB/BF0G72LSn0d
# b9ID7PYXJQafd5AIJ52nXaewPlqyd2iYn1YvcS8IK2Ht2qVt2qAVRkpt+fAGWfD5
# XlC1pNF2Mpfezu1Gj2BNJqZTNdDdFgMG7nuhdjqnPENHrN4+7lHFUtwBmsDslkWU
# pDhOx7P9GaRlN4TVwnY6WKJyp3J5Uo9l8m+2P9XXqba+e0yJ9jUyA2J1HXKBaQZY
# JTNqfuNgfQN+cMg9Iiad98btzOAJfsgO9ndvTGNrKxEbIMwRreSnKrgzUobAp+6j
# 62Sik2tAsdtzis3/zdq/sIbblx93CLfUka5vqP9c1SEcRU/cvhT8JigEZcXDjT0T
# bJtCF5UKA9GcP6Uq24xcDjMCmnUruGSTjnN1Af/gCD9RU5+Y+bLP7c+8IboaEM97
# yCfdrUEdy1j5tZ0UQlxMTH9Pe+6WwjigN4OqA+vHZDJI83+5XnRSqqXEWC1g5E2T
# XWcckVYldpKqGR6TOgEUP1aWMsLjbxwu9zeBEhRR5LbwOMfi7K1uIXRQvYvfGfEJ
# ak6nBgfFxyK4A7S8OHFstQ==
# =BDx3
# -----END PGP SIGNATURE-----
# gpg: Signature made Thu 23 Apr 2026 06:01:08 EDT
# gpg:                using RSA key E1A5C593CD419DE28E8315CF3C2525ED14360CDE
# gpg:                issuer "peter.maydell@linaro.org"
# gpg: Good signature from "Peter Maydell <peter.maydell@linaro.org>" [full]
# gpg:                 aka "Peter Maydell <pmaydell@gmail.com>" [full]
# gpg:                 aka "Peter Maydell <pmaydell@chiark.greenend.org.uk>" [full]
# gpg:                 aka "Peter Maydell <peter@archaic.org.uk>" [unknown]
# Primary key fingerprint: E1A5 C593 CD41 9DE2 8E83  15CF 3C25 25ED 1436 0CDE

* tag 'pull-target-arm-20260423' of https://gitlab.com/pm215/qemu: (59 commits)
  MAINTAINERS: Remove Xie Changlong
  MAINTAINERS: Remove Xiao Guangrong
  MAINTAINERS: Remove Wen Congyang
  MAINTAINERS: Remove Yanan Wang
  MAINTAINERS: Remove Vijai Kumar K
  MAINTAINERS: Remove Su Hang
  MAINTAINERS: Remove Shannon Zhao
  MAINTAINERS: Remove Ryo ONODERA
  MAINTAINERS: Remove Ronnie Sahlberg
  MAINTAINERS: Remove Luigi Rizzo
  MAINTAINERS: Remove Qiuhao Li
  MAINTAINERS: Remove Jia Liu
  MAINTAINERS: Remove Paul Burton
  MAINTAINERS: Remove Aarushi Mehta
  MAINTAINERS: Remove Marcel Apfelbaum
  MAINTAINERS: Remove Magnus Damm
  MAINTAINERS: Remove Mahmoud Mandour
  MAINTAINERS: Remove Bastian Koppelmann
  MAINTAINERS: Remove Huai-Cheng Kuo
  MAINTAINERS: Remove Dongjiu Geng
  ...

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2 months agotarget/hexagon: Change DisasContext packet type
Marco Liebel [Thu, 22 Jan 2026 22:34:23 +0000 (14:34 -0800)] 
target/hexagon: Change DisasContext packet type

The pkt variable inside DisasContext is of type Packet * and gets
assigned to a local variable in decode_and_translate_packet. Right now
there seems to be no problem with it but future changes to e.g.
hexagon_tr_transalte_packet are potentially dangerous if pkt is accessed
after the local variable goes out of scope.

Since packets are being translated one at a time, the type of pkt can be
changed to just Packet to avoid risk of having a dangling pointer.

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>
2 months agoHexagon (target/hexagon) Remove snprint_a_pkt_debug
Taylor Simpson [Tue, 17 Feb 2026 21:22:45 +0000 (14:22 -0700)] 
Hexagon (target/hexagon) Remove snprint_a_pkt_debug

Function is not used

Signed-off-by: Taylor Simpson <ltaylorsimpson@gmail.com>
Reviewed-by: Anton Johansson <anjo@rev.ng>
Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
2 months agotests/tcg/hexagon: Add test for revision-gated instruction decoding
Brian Cain [Tue, 17 Feb 2026 21:22:44 +0000 (14:22 -0700)] 
tests/tcg/hexagon: Add test for revision-gated instruction decoding

Add check_rev_gating, a linux-user test that verifies the decoder
rejects instructions from a newer CPU revision than the one selected
by the ELF binary's e_flags.

Co-authored-by: Taylor Simpson <ltaylorsimpson@gmail.com>
Co-authored-by: Matheus Tavares Bernardino <matheus.bernardino@oss.qualcomm.com>
Reviewed-by: Marco Liebel <marco.liebel@oss.qualcomm.com>
Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
2 months agoHexagon (target/hexagon) Disassembly of invalid packets
Taylor Simpson [Tue, 17 Feb 2026 21:22:43 +0000 (14:22 -0700)] 
Hexagon (target/hexagon) Disassembly of invalid packets

We pass the Hexagon CPU definition to disassemble_hexagon.  This allows
decode_packet to know if the opcodes are supported.

Note that we print valid instructions in a packet when one or more is
invalid.  Rather than this
0x0002128c:  0x1eae4fec { <invalid>
0x00021290:  0x1c434c04 <invalid>
0x00021294:  0x1e03edf0 <invalid> }

We print this
0x0002128c:  0x1eae4fec { <invalid>
0x00021290:  0x1c434c04 V4.w = vadd(V12.w,V3.w)
0x00021294:  0x1e03edf0 V16 = V13 }

Co-authored-by: Matheus Tavares Bernardino <matheus.bernardino@oss.qualcomm.com>
Co-authored-by: Brian Cain <brian.cain@oss.qualcomm.com>
Signed-off-by: Taylor Simpson <ltaylorsimpson@gmail.com>
Reviewed-by: Anton Johansson <anjo@rev.ng>
Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
2 months agoHexagon (target/hexagon) Check each opcode against current CPU definition
Taylor Simpson [Tue, 17 Feb 2026 21:22:42 +0000 (14:22 -0700)] 
Hexagon (target/hexagon) Check each opcode against current CPU definition

During decoding, check that the opcode is supported in the current
Hexagon CPU definition

Co-authored-by: Matheus Tavares Bernardino <matheus.bernardino@oss.qualcomm.com>
Co-authored-by: Brian Cain <brian.cain@oss.qualcomm.com>
Signed-off-by: Taylor Simpson <ltaylorsimpson@gmail.com>
Reviewed-by: Anton Johansson <anjo@rev.ng>
Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
2 months agoHexagon (target/hexagon) Introduce tag_rev_info.c.inc
Matheus Tavares Bernardino [Tue, 17 Feb 2026 21:22:41 +0000 (14:22 -0700)] 
Hexagon (target/hexagon) Introduce tag_rev_info.c.inc

Table that records which CPU revision introduced or removed
for each opcode

Co-authored-by: Brian Cain <brian.cain@oss.qualcomm.com>
Co-authored-by: Taylor Simpson <ltaylorsimpson@gmail.com>
Signed-off-by: Taylor Simpson <ltaylorsimpson@gmail.com>
Reviewed-by: Anton Johansson <anjo@rev.ng>
Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
2 months agoHexagon (target/hexagon) Add Hexagon definition field to DisasContext
Taylor Simpson [Tue, 17 Feb 2026 21:22:40 +0000 (14:22 -0700)] 
Hexagon (target/hexagon) Add Hexagon definition field to DisasContext

Initialize the field in hexagon_tr_init_disas_context

Co-authored-by: Matheus Tavares Bernardino <matheus.bernardino@oss.qualcomm.com>
Co-authored-by: Brian Cain <brian.cain@oss.qualcomm.com>
Signed-off-by: Taylor Simpson <ltaylorsimpson@gmail.com>
Reviewed-by: Anton Johansson <anjo@rev.ng>
Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
2 months agoHexagon (linux-user/hexagon) Identify Hexagon version in ELF file
Taylor Simpson [Tue, 17 Feb 2026 21:22:39 +0000 (14:22 -0700)] 
Hexagon (linux-user/hexagon) Identify Hexagon version in ELF file

Return proper Hexagon CPU version from get_elf_cpu_model

Co-authored-by: Matheus Tavares Bernardino <matheus.bernardino@oss.qualcomm.com>
Co-authored-by: Brian Cain <brian.cain@oss.qualcomm.com>
Signed-off-by: Taylor Simpson <ltaylorsimpson@gmail.com>
Reviewed-by: Anton Johansson <anjo@rev.ng>
Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
2 months agoHexagon (target/hexagon) Properly handle Hexagon CPU version
Taylor Simpson [Tue, 17 Feb 2026 21:22:38 +0000 (14:22 -0700)] 
Hexagon (target/hexagon) Properly handle Hexagon CPU version

Add the following CPU versions that were previously missing
    v5
    v55
    v60
    v61
    v62
    v65

Create a CPUHexagonDef struct to represent the definition of a core
    Currently contains an enum with the known Hexagon CPU versions
Add a field to HexagonCPUClass to note the Hexagon definition

Co-authored-by: Matheus Tavares Bernardino <matheus.bernardino@oss.qualcomm.com>
Co-authored-by: Brian Cain <brian.cain@oss.qualcomm.com>
Signed-off-by: Taylor Simpson <ltaylorsimpson@gmail.com>
Reviewed-by: Anton Johansson <anjo@rev.ng>
Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
2 months agomigration/qemu-file: drop incorrect const from qemu_get_buffer_at buf
Junjie Cao [Mon, 20 Apr 2026 20:13:17 +0000 (04:13 +0800)] 
migration/qemu-file: drop incorrect const from qemu_get_buffer_at buf

qemu_get_buffer_at() reads data *into* buf -- it should not be const.
Drop the qualifier and remove the now-unnecessary cast.

Signed-off-by: Junjie Cao <junjie.cao@intel.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Peter Xu <peterx@redhat.com>
Link: https://lore.kernel.org/qemu-devel/20260420201317.30199-4-junjie.cao@intel.com
Signed-off-by: Fabiano Rosas <farosas@suse.de>
2 months agomigration/file: switch file_write_ramblock_iov to pwritev_all
Junjie Cao [Mon, 20 Apr 2026 20:13:16 +0000 (04:13 +0800)] 
migration/file: switch file_write_ramblock_iov to pwritev_all

file_write_ramblock_iov() uses single-shot qio_channel_pwritev() and
only checks for ret < 0.  A short write (0 <= ret < requested) would be
treated as success.

Switch to qio_channel_pwritev_all() which retries until all bytes are
written or an error occurs.

Fixes: f427d90b98 ("migration/multifd: Support outgoing mapped-ram stream format")
Signed-off-by: Junjie Cao <junjie.cao@intel.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
Link: https://lore.kernel.org/qemu-devel/20260420201317.30199-3-junjie.cao@intel.com
Signed-off-by: Fabiano Rosas <farosas@suse.de>
2 months agomigration/qemu-file: switch buffer_at functions to positioned I/O _all helpers
Junjie Cao [Mon, 20 Apr 2026 20:13:15 +0000 (04:13 +0800)] 
migration/qemu-file: switch buffer_at functions to positioned I/O _all helpers

qemu_put_buffer_at() and qemu_get_buffer_at() have the same pattern as
the bug fixed in multifd_file_recv_data(): the ssize_t return value from
the channel layer is stored in a size_t variable, and a short transfer
would be mishandled rather than retried.

Switch to qio_channel_pwrite_all() / qio_channel_pread_all() which
handle short transfers internally and make the code more robust and
consistent with the rest of the positioned I/O call sites.

Fixes: 7f5b50a401 ("migration/qemu-file: add utility methods for working with seekable channels")
Signed-off-by: Junjie Cao <junjie.cao@intel.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
Link: https://lore.kernel.org/qemu-devel/20260420201317.30199-2-junjie.cao@intel.com
Signed-off-by: Fabiano Rosas <farosas@suse.de>
2 months agotests/qtest/migration: fix fd leak in ufd_version_check
Trieu Huynh [Sun, 19 Apr 2026 11:03:04 +0000 (18:03 +0700)] 
tests/qtest/migration: fix fd leak in ufd_version_check

ufd_version_check() opens a userfaultfd via uffd_open() but never closes
it on any path where the open succeeded: the UFFDIO_API failure path,
the missing-ioctls path, and the success path all returned without
calling close(ufd).

Convert to a goto-out pattern consistent with uffd_open() used in
util/userfaultfd.c and migration/postcopy-ram.c, ensuring the fd is
always closed before returning.

Signed-off-by: Trieu Huynh <vikingtc4@gmail.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
Link: https://lore.kernel.org/qemu-devel/20260419110304.8661-1-viking4@gmail.com
Signed-off-by: Fabiano Rosas <farosas@suse.de>
2 months agotests/unit: add pread/pwrite _all tests for io channel file
Junjie Cao [Mon, 13 Apr 2026 21:45:49 +0000 (05:45 +0800)] 
tests/unit: add pread/pwrite _all tests for io channel file

Add unit tests for the new qio_channel_pread{v,}_all{,_eof}() and
qio_channel_pwrite{v,}_all() APIs.

The basic tests write data to a file channel, then read it back at
various offsets using both the single-buffer and iovec variants to
make sure the round-trip produces identical content.  The _eof tests
verify all three return cases -- full read (1), clean EOF (0), and
partial-then-EOF (-1 with error set) -- and check that the strict
wrappers (preadv_all / pread_all) treat a clean EOF as an error.

All tests are guarded by CONFIG_PREADV since the underlying channel
methods require preadv(2).

Signed-off-by: Junjie Cao <junjie.cao@intel.com>
Reviewed-by: Fabiano Rosas <farosas@suse.de>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Acked-by: Daniel P. Berrangé <berrange@redhat.com>
Link: https://lore.kernel.org/qemu-devel/20260413214549.926435-5-junjie.cao@intel.com
Signed-off-by: Fabiano Rosas <farosas@suse.de>
2 months agomigration/file: fix type mismatch and NULL deref in multifd_file_recv_data
Junjie Cao [Mon, 13 Apr 2026 21:45:48 +0000 (05:45 +0800)] 
migration/file: fix type mismatch and NULL deref in multifd_file_recv_data

multifd_file_recv_data() stores the return value of qio_channel_pread()
(ssize_t) in a size_t variable.  On I/O error the -1 return value wraps
to SIZE_MAX, producing a nonsensical read size in the error message.

More critically, a short read (0 <= ret < data->size) is possible when
the migration file is truncated.  In that case qio_channel_pread()
returns a non-negative value without setting *errp.  The function then
calls error_prepend(errp, ...) which dereferences *errp -- a NULL
pointer -- crashing QEMU.

Fix both issues by switching to qio_channel_pread_all() introduced in
a previous patch, which retries on short reads and treats end-of-file
as an error, so the caller no longer needs to check the byte count
manually.  Add ERRP_GUARD() so that error_prepend() works correctly
even when errp is &error_fatal or NULL.

Fixes: a49d15a38d3d ("migration/multifd: Support incoming mapped-ram stream format")
Suggested-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Junjie Cao <junjie.cao@intel.com>
Reviewed-by: Fabiano Rosas <farosas@suse.de>
Link: https://lore.kernel.org/qemu-devel/20260413214549.926435-4-junjie.cao@intel.com
Signed-off-by: Fabiano Rosas <farosas@suse.de>
2 months agoio/channel: introduce qio_channel_pwrite{v,}_all()
Junjie Cao [Mon, 13 Apr 2026 21:45:47 +0000 (05:45 +0800)] 
io/channel: introduce qio_channel_pwrite{v,}_all()

Add positioned write helpers that retry on short writes, matching
the pread_all family from the previous patch.

  qio_channel_pwritev_all()  -- retry loop; returns 0 on success,
                                 -1 on error.
  qio_channel_pwrite_all()   -- single-buffer convenience wrapper.

Signed-off-by: Junjie Cao <junjie.cao@intel.com>
Reviewed-by: Fabiano Rosas <farosas@suse.de>
Link: https://lore.kernel.org/qemu-devel/20260413214549.926435-3-junjie.cao@intel.com
Signed-off-by: Fabiano Rosas <farosas@suse.de>
2 months agoio/channel: introduce qio_channel_pread{v, }_all{, _eof}()
Junjie Cao [Mon, 13 Apr 2026 21:45:46 +0000 (05:45 +0800)] 
io/channel: introduce qio_channel_pread{v, }_all{, _eof}()

qio_channel_pread() and qio_channel_preadv() perform a single
positioned read and may return a short result.  Callers that need all
bytes currently have to open-code a retry loop or simply treat a short
read as an error.

Introduce four new helpers following the existing read_all / readv_all
pattern:

  qio_channel_preadv_all_eof()  -- retry loop; returns 1 on success,
                                    0 on clean EOF, -1 on error.
  qio_channel_preadv_all()      -- wraps _eof; treats early EOF as
                                    error; returns 0 / -1.
  qio_channel_pread_all_eof()   -- single-buffer convenience wrapper
                                    around preadv_all_eof().
  qio_channel_pread_all()       -- single-buffer convenience wrapper
                                    around preadv_all().

These advance the file offset internally after each partial read.
All four are marked coroutine_mixed_fn, consistent with the existing
_all helpers.

Suggested-by: Peter Xu <peterx@redhat.com>
Signed-off-by: Junjie Cao <junjie.cao@intel.com>
Reviewed-by: Fabiano Rosas <farosas@suse.de>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Acked-by: Daniel P. Berrangé <berrange@redhat.com>
Link: https://lore.kernel.org/qemu-devel/20260413214549.926435-2-junjie.cao@intel.com
Signed-off-by: Fabiano Rosas <farosas@suse.de>
2 months agomigration: validate page_size in mapped-ram header before use
Trieu Huynh [Sun, 5 Apr 2026 09:44:47 +0000 (16:44 +0700)] 
migration: validate page_size in mapped-ram header before use

mapped_ram_read_header() reads page_size from the migration stream and
stores it in MappedRamHeader, but does not validate that the value is
non-zero before it is later used in parse_ramblock_mapped_ram():

num_pages = length / header.page_size;

If a corrupted or malformed migration stream provides invalid, guest
resumes either with corrupted memory or crashes unexpectedly (eg.
page_size = 0)

Add validation in mapped_ram_read_header() to reject invalid page_size
values early and return an error instead of continuing with an invalid
header.

Steps to reproduce:

Create a migration snapshot with mapped-ram enabled:
(qemu) migrate_set_capability mapped-ram on
(qemu) migrate file:/tmp/qemu-snapshots/snapshot.bin
Modify the snapshot so that MappedRamHeader.page_size becomes diff with
target psize. (0/512/8192/1GB).
Restore the snapshot:
(qemu) migrate_set_capability mapped-ram on
(qemu) migrate_incoming file:/tmp/qemu-snapshots/snapshot.bin

As-is:
* [0]: Floating point exception (core dumped)
* [512/8192]: Silent corruption
* [1GB]: "post load hook failed for: kvm-tpr-opt" (EPERM)
To-be:
* All: qemu-system-x86_64: Migration mapped-ram header has invalid
  page_size [val] (expected 4096)

Signed-off-by: Trieu Huynh <vikingtc4@gmail.com>
Reviewed-by: Fabiano Rosas <farosas@suse.de>
Reviewed-by: Peter Xu <peterx@redhat.com>
Link: https://lore.kernel.org/qemu-devel/20260405094447.11347-1-viking4@gmail.com
Signed-off-by: Fabiano Rosas <farosas@suse.de>
2 months agotests/unit/test-vmstate: add tests for VMS_ARRAY_OF_POINTER_AUTO_ALLOC
Alexander Mikhalitsyn [Wed, 1 Apr 2026 20:28:44 +0000 (16:28 -0400)] 
tests/unit/test-vmstate: add tests for VMS_ARRAY_OF_POINTER_AUTO_ALLOC

Add tests for VMSTATE_VARRAY_OF_POINTER_TO_STRUCT_UINT32_ALLOC.

Signed-off-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@futurfusion.io>
[peterx: Removed two tests due to macro not used, rebase, fix warning]
Signed-off-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Juraj Marcin <jmarcin@redhat.com>
Link: https://lore.kernel.org/qemu-devel/20260401202844.673494-12-peterx@redhat.com
Signed-off-by: Fabiano Rosas <farosas@suse.de>
2 months agovmstate: Stop checking size for nullptr compression
Fabiano Rosas [Wed, 1 Apr 2026 20:28:43 +0000 (16:28 -0400)] 
vmstate: Stop checking size for nullptr compression

The NULL pointer marker code applies only to VMS_ARRAY_OF_POINTER,
where the size is never NULL. Move the setting of is_null under
VMS_ARRAY_OF_POINTER, so we can stop checking the size.

Reviewed-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@futurfusion.io>
Signed-off-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Juraj Marcin <jmarcin@redhat.com>
Link: https://lore.kernel.org/qemu-devel/20260401202844.673494-11-peterx@redhat.com
Signed-off-by: Fabiano Rosas <farosas@suse.de>
2 months agovmstate: Implement VMS_ARRAY_OF_POINTER_AUTO_ALLOC
Peter Xu [Wed, 1 Apr 2026 20:28:42 +0000 (16:28 -0400)] 
vmstate: Implement VMS_ARRAY_OF_POINTER_AUTO_ALLOC

Introduce a new flag, VMS_ARRAY_OF_POINTER_AUTO_ALLOC, for VMSD field.  It
must be used together with VMS_ARRAY_OF_POINTER.

It can be used to allow migration of an array of pointers where the
pointers may point to NULLs.

Note that we used to allow migration of a NULL pointer within an array that
is being migrated. That corresponds to the code around vmstate_info_nullptr
where we may get/put one byte showing that the element of an array is NULL.

That usage is fine but very limited, it's because even if it will migrate a
NULL pointer with a marker, it still works in a way that both src and dest
QEMUs must know exactly which elements of the array are non-NULL, so
instead of dynamically loading an array (which can have NULL pointers), it
actually only verifies the known NULL pointers are still NULL pointers
after migration.

Also, in that case since dest QEMU knows exactly which element is NULL,
which is not NULL, dest QEMU's device code will manage all allocations for
the elements before invoking vmstate_load_vmsd().

That's not enough per evolving needs of new device states that may want to
provide real dynamic array of pointers, like what Alexander proposed here
with the NVMe device migration:

https://lore.kernel.org/r/20260317102708.126725-1-alexander@mihalicyn.com

This patch is an alternative approach to address the problem.

Along with the flag, introduce two new macros:

  VMSTATE_VARRAY_OF_POINTER_TO_STRUCT_UINT{8|32}_ALLOC()

Which will be used very soon in the NVMe series.

Reviewed-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@futurfusion.io>
Tested-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@futurfusion.io>
Signed-off-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Juraj Marcin <jmarcin@redhat.com>
Link: https://lore.kernel.org/qemu-devel/20260401202844.673494-10-peterx@redhat.com
Signed-off-by: Fabiano Rosas <farosas@suse.de>
2 months agovmstate: Implement load of ptr marker in vmstate core
Peter Xu [Wed, 1 Apr 2026 20:28:41 +0000 (16:28 -0400)] 
vmstate: Implement load of ptr marker in vmstate core

The loader side of ptr marker is pretty straightforward, instead of playing
the inner_field trick, just do the load manually assuming the marker layout
is a stable ABI (which it is true already).

This will remove some logic while loading VMSD, and hopefully it makes it
slightly easier to read.  Unfortunately, we still need to keep the sender
side because of the JSON blob we're maintaining..

This paves way for future processing of non-NULL markers as well.

When at it, not check "size" anymore for existing NULL markers, and move it
under the same VMS_ARRAY_OF_POINTER section because that's the only place
that NULL marker can happen (which guarantess size==host ptr size, which is
non-zero).

Reviewed-by: Fabiano Rosas <farosas@suse.de>
Reviewed-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@futurfusion.io>
Signed-off-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Juraj Marcin <jmarcin@redhat.com>
Link: https://lore.kernel.org/qemu-devel/20260401202844.673494-9-peterx@redhat.com
Signed-off-by: Fabiano Rosas <farosas@suse.de>
2 months agovmstate: Allow vmstate_info_nullptr to emit non-NULL markers
Peter Xu [Wed, 1 Apr 2026 20:28:40 +0000 (16:28 -0400)] 
vmstate: Allow vmstate_info_nullptr to emit non-NULL markers

We used to have one vmstate called "nullptr" which is only used to generate
one-byte hint to say one pointer is NULL.

Let's extend its use so that it will generate another byte to say the
pointer is non-NULL.

With that, the name of the info struct (or functions) do not apply anymore.
Update correspondingly.

Update analyze-migration.py to work with the new layout.

No functional change intended yet.

Reviewed-by: Fabiano Rosas <farosas@suse.de>
Reviewed-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@futurfusion.io>
Signed-off-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Juraj Marcin <jmarcin@redhat.com>
Link: https://lore.kernel.org/qemu-devel/20260401202844.673494-8-peterx@redhat.com
Signed-off-by: Fabiano Rosas <farosas@suse.de>
2 months agovmstate: Introduce vmstate_save_field_with_vmdesc()
Peter Xu [Wed, 1 Apr 2026 20:28:39 +0000 (16:28 -0400)] 
vmstate: Introduce vmstate_save_field_with_vmdesc()

Introduce a helper to do both the JSON blob generations and save vmstate.
This further shrinks the function a bit.  More importantly, we'll need to
save two fields in one loop very soon in the future with the JSON blob.

Reviewed-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@futurfusion.io>
Reviewed-by: Fabiano Rosas <farosas@suse.de>
Signed-off-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Juraj Marcin <jmarcin@redhat.com>
Link: https://lore.kernel.org/qemu-devel/20260401202844.673494-7-peterx@redhat.com
Signed-off-by: Fabiano Rosas <farosas@suse.de>
2 months agovmstate: Rename VMS_NULLPTR_MARKER to VMS_MARKER_PTR_NULL
Peter Xu [Wed, 1 Apr 2026 20:28:38 +0000 (16:28 -0400)] 
vmstate: Rename VMS_NULLPTR_MARKER to VMS_MARKER_PTR_NULL

Prepare for a new MARKER for non-NULL pointer.

Reviewed-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@futurfusion.io>
Reviewed-by: Fabiano Rosas <farosas@suse.de>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Juraj Marcin <jmarcin@redhat.com>
Link: https://lore.kernel.org/qemu-devel/20260401202844.673494-6-peterx@redhat.com
Signed-off-by: Fabiano Rosas <farosas@suse.de>
2 months agovmstate: Update max_elems early and check field compressable once
Peter Xu [Wed, 1 Apr 2026 20:28:37 +0000 (16:28 -0400)] 
vmstate: Update max_elems early and check field compressable once

QEMU has a trick in vmstate_save_vmsd_v(), where it will try to compress
multiple JSON entries into one with a count to avoid duplicated entries.

That only applies to the cases where vmsd_can_compress() should return
true.  For example, vmsd_desc_field_start() later (who will take the
updated max_elems as the last parameter) will ignore the value passed in
when vmsd_can_compress() returns false.

Do that check once at the start of loop, and use it to update max_elems, so
that max_elems keeps 1 for uncompressable VMSD fields, which is more
straightforward.

This also paves way to make this counter work for ptr marker VMSD fields
too.

No functional change intended in this patch alone.

Reviewed-by: Fabiano Rosas <farosas@suse.de>
Reviewed-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@futurfusion.io>
Signed-off-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Juraj Marcin <jmarcin@redhat.com>
Link: https://lore.kernel.org/qemu-devel/20260401202844.673494-5-peterx@redhat.com
Signed-off-by: Fabiano Rosas <farosas@suse.de>
2 months agovmstate: Do not set size for VMS_ARRAY_OF_POINTER
Peter Xu [Wed, 1 Apr 2026 20:28:36 +0000 (16:28 -0400)] 
vmstate: Do not set size for VMS_ARRAY_OF_POINTER

When VMS_ARRAY_OF_POINTER is specified, it means the vmstate field is an
array of pointers.

The size of the element is not relevant to whatever it is stored inside: it
is always the host pointer size.

Let's reserve the "size" field in this case for future use, update
vmstate_size() so as to make it still work for array of pointers properly.

When at this, provide rich documentation on how size / size_offset works in
vmstate.

Reviewed-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@futurfusion.io>
Reviewed-by: Fabiano Rosas <farosas@suse.de>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Juraj Marcin <jmarcin@redhat.com>
Link: https://lore.kernel.org/qemu-devel/20260401202844.673494-4-peterx@redhat.com
Signed-off-by: Fabiano Rosas <farosas@suse.de>
2 months agovmstate: Pass in struct itself for VMSTATE_VARRAY_OF_POINTER_UINT32
Peter Xu [Wed, 1 Apr 2026 20:28:35 +0000 (16:28 -0400)] 
vmstate: Pass in struct itself for VMSTATE_VARRAY_OF_POINTER_UINT32

Passing in a pointer almost never helps.  Convert it to pass in struct for
further refactoring on VMS_ARRAY_OF_POINTER.

Reviewed-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@futurfusion.io>
Reviewed-by: Fabiano Rosas <farosas@suse.de>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Juraj Marcin <jmarcin@redhat.com>
Link: https://lore.kernel.org/qemu-devel/20260401202844.673494-3-peterx@redhat.com
Signed-off-by: Fabiano Rosas <farosas@suse.de>
2 months agovmstate: Pass in struct itself for VMSTATE_ARRAY_OF_POINTER
Peter Xu [Wed, 1 Apr 2026 20:28:34 +0000 (16:28 -0400)] 
vmstate: Pass in struct itself for VMSTATE_ARRAY_OF_POINTER

Passing in a pointer almost never helps.  Convert it to pass in struct for
further refactoring on VMS_ARRAY_OF_POINTER.

Reviewed-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@futurfusion.io>
Reviewed-by: Fabiano Rosas <farosas@suse.de>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Juraj Marcin <jmarcin@redhat.com>
Link: https://lore.kernel.org/qemu-devel/20260401202844.673494-2-peterx@redhat.com
[delete spurious hunk touching roms/seabios]
Signed-off-by: Fabiano Rosas <farosas@suse.de>
2 months agomigration: fix QIOChannelFile leak on error in file_connect_outgoing
Trieu Huynh [Sat, 28 Mar 2026 12:12:14 +0000 (21:12 +0900)] 
migration: fix QIOChannelFile leak on error in file_connect_outgoing

Commit 03a680c978 changed g_autoptr(QIOChannelFile) to a plain pointer
but failed to restore the necessary object_unref() calls on error paths.
Previously, these were handled implicitly by the g_autoptr cleanup
mechanism.

Two error paths currently leak the QIOChannelFile object and its
underlying file descriptor:

  1. When ftruncate() fails (e.g., on character or block devices).
  2. When qio_channel_io_seek() fails after the channel is created.

In environments that retry migration automatically (e.g., libvirt),
these FDs accumulate until QEMU hits RLIMIT_NOFILE and fails with
EMFILE (Too many open files).

Add the missing object_unref() calls to both error paths to ensure
resources are properly released.

Signed-off-by: Trieu Huynh <vikingtc4@gmail.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
Link: https://lore.kernel.org/qemu-devel/20260328121215.159532-1-vikingtc4@gmail.com
Signed-off-by: Fabiano Rosas <farosas@suse.de>
2 months agotests/qtest/migration: Add mapped-ram/postcopy validation test
Takeru Hayasaka [Fri, 27 Mar 2026 16:46:58 +0000 (16:46 +0000)] 
tests/qtest/migration: Add mapped-ram/postcopy validation test

The migration capability checks reject enabling postcopy-ram together
with mapped-ram, but there is no qtest covering this incompatibility.

Add a validation test that verifies QMP rejects the combination in
both capability ordering cases and returns the expected error.

This keeps the existing capability boundary covered without changing
migration behavior.

Signed-off-by: Takeru Hayasaka <hayatake396@gmail.com>
Link: https://lore.kernel.org/qemu-devel/20260327164705.1990226-1-hayatake396@gmail.com
[unlink src_serial]
Signed-off-by: Fabiano Rosas <farosas@suse.de>
2 months agomigration: Tweak description of migration property multifd-compression
Markus Armbruster [Thu, 26 Mar 2026 07:42:47 +0000 (08:42 +0100)] 
migration: Tweak description of migration property multifd-compression

Help for the migration pseudo-device shows property
"multifd-compression" like this:

  multifd-compression=<MultiFDCompression> - multifd_compression values (none/zlib/zstd/qpl/uadk/qatzip) (default: none)

Change it to

  multifd-compression=<MultiFDCompression> - multifd compression method (none/zlib/zstd/qpl/uadk/qatzip) (default: none)

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Link: https://lore.kernel.org/qemu-devel/20260326074247.188674-4-armbru@redhat.com
Signed-off-by: Fabiano Rosas <farosas@suse.de>
2 months agomigration/vmstate-types: move to new migration APIs
Vladimir Sementsov-Ogievskiy [Wed, 4 Mar 2026 21:23:02 +0000 (00:23 +0300)] 
migration/vmstate-types: move to new migration APIs

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Reviewed-by: Peter Xu <peterx@redhat.com>
Link: https://lore.kernel.org/qemu-devel/20260304212303.667141-19-vsementsov@yandex-team.ru
Signed-off-by: Fabiano Rosas <farosas@suse.de>
2 months agomigration: drop VMStateField.err_hint
Vladimir Sementsov-Ogievskiy [Wed, 4 Mar 2026 21:23:01 +0000 (00:23 +0300)] 
migration: drop VMStateField.err_hint

The field is unused, all users of VMSTATE_*_EQUAL pass _err_hint=NULL.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Acked-by: Eric Farman <farman@linux.ibm.com> # s390
Reviewed-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
Reviewed-by: Peter Xu <peterx@redhat.com>
Link: https://lore.kernel.org/qemu-devel/20260304212303.667141-18-vsementsov@yandex-team.ru
Signed-off-by: Fabiano Rosas <farosas@suse.de>
2 months agohw/s390x/css: drop use of .err_hint for vmstate
Vladimir Sementsov-Ogievskiy [Wed, 4 Mar 2026 21:23:00 +0000 (00:23 +0300)] 
hw/s390x/css: drop use of .err_hint for vmstate

That's the only usage through the whole base. Doesn't
worth keeping the whole complexity. And 2.7 machines were
long ago.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Reviewed-by: Eric Farman <farman@linux.ibm.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
Link: https://lore.kernel.org/qemu-devel/20260304212303.667141-17-vsementsov@yandex-team.ru
Signed-off-by: Fabiano Rosas <farosas@suse.de>
2 months agomigration/savevm: move to new migration APIs
Vladimir Sementsov-Ogievskiy [Wed, 4 Mar 2026 21:22:59 +0000 (00:22 +0300)] 
migration/savevm: move to new migration APIs

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Reviewed-by: Peter Xu <peterx@redhat.com>
Link: https://lore.kernel.org/qemu-devel/20260304212303.667141-16-vsementsov@yandex-team.ru
Signed-off-by: Fabiano Rosas <farosas@suse.de>
2 months agomigration/cpr: move to new migration APIs
Vladimir Sementsov-Ogievskiy [Wed, 4 Mar 2026 21:22:58 +0000 (00:22 +0300)] 
migration/cpr: move to new migration APIs

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Reviewed-by: Peter Xu <peterx@redhat.com>
Link: https://lore.kernel.org/qemu-devel/20260304212303.667141-15-vsementsov@yandex-team.ru
Signed-off-by: Fabiano Rosas <farosas@suse.de>
2 months agomigration: introduce vmstate_load_vmsd() and vmstate_save_vmsd()
Vladimir Sementsov-Ogievskiy [Wed, 4 Mar 2026 21:22:57 +0000 (00:22 +0300)] 
migration: introduce vmstate_load_vmsd() and vmstate_save_vmsd()

Introduce new APIs, returning bool.
The analysis
https://lore.kernel.org/qemu-devel/aQDdRn8t0B8oE3gf@x1.local/
shows, that vmstate_load_state() return value actually only
used to check for success, specific errno values doesn't make
sense.

With this commit we introduce new functions with modern bool
interface, and in following commits we'll update the
code base to use them, starting from migration/ code, and
finally we will remove old vmstate_load_state() and
vmstate_save_state().

This patch reworks existing functions to new one, so that
old interfaces are simple wrappers, which will be easy to
remove later.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Reviewed-by: Peter Xu <peterx@redhat.com>
Link: https://lore.kernel.org/qemu-devel/20260304212303.667141-14-vsementsov@yandex-team.ru
Signed-off-by: Fabiano Rosas <farosas@suse.de>
2 months agomigration: VMStateInfo: introduce new handlers with errp
Vladimir Sementsov-Ogievskiy [Wed, 4 Mar 2026 21:22:56 +0000 (00:22 +0300)] 
migration: VMStateInfo: introduce new handlers with errp

Add new APIs with errp, to allow handlers report good
error messages. We'll convert existing handlers soon.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Reviewed-by: Peter Xu <peterx@redhat.com>
Link: https://lore.kernel.org/qemu-devel/20260304212303.667141-13-vsementsov@yandex-team.ru
Signed-off-by: Fabiano Rosas <farosas@suse.de>
2 months agomigration: convert vmstate_subsection_save/load functions to bool
Vladimir Sementsov-Ogievskiy [Wed, 4 Mar 2026 21:22:55 +0000 (00:22 +0300)] 
migration: convert vmstate_subsection_save/load functions to bool

Convert them to bool return value, as preparation to further
convertion of vmstate_save/load_state().

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Reviewed-by: Peter Xu <peterx@redhat.com>
Link: https://lore.kernel.org/qemu-devel/20260304212303.667141-12-vsementsov@yandex-team.ru
Signed-off-by: Fabiano Rosas <farosas@suse.de>
2 months agomigration: factor out vmstate_post_load() from vmstate_load_state()
Vladimir Sementsov-Ogievskiy [Wed, 4 Mar 2026 21:22:54 +0000 (00:22 +0300)] 
migration: factor out vmstate_post_load() from vmstate_load_state()

Simplify vmstate_load_state() which is rather big, and simplify further
refactoring.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Reviewed-by: Peter Xu <peterx@redhat.com>
Link: https://lore.kernel.org/qemu-devel/20260304212303.667141-11-vsementsov@yandex-team.ru
Signed-off-by: Fabiano Rosas <farosas@suse.de>
2 months agomigration: factor out vmstate_load_field() from vmstate_load_state()
Vladimir Sementsov-Ogievskiy [Wed, 4 Mar 2026 21:22:53 +0000 (00:22 +0300)] 
migration: factor out vmstate_load_field() from vmstate_load_state()

Simplify vmstate_load_state() which is rather big, and simplify further
refactoring.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Reviewed-by: Peter Xu <peterx@redhat.com>
Link: https://lore.kernel.org/qemu-devel/20260304212303.667141-10-vsementsov@yandex-team.ru
Signed-off-by: Fabiano Rosas <farosas@suse.de>
2 months agomigration: factor out vmstate_pre_load() from vmstate_load_state()
Vladimir Sementsov-Ogievskiy [Wed, 4 Mar 2026 21:22:52 +0000 (00:22 +0300)] 
migration: factor out vmstate_pre_load() from vmstate_load_state()

Simplify vmstate_load_state() which is rather big, and simplify further
refactoring.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Reviewed-by: Peter Xu <peterx@redhat.com>
Link: https://lore.kernel.org/qemu-devel/20260304212303.667141-9-vsementsov@yandex-team.ru
Signed-off-by: Fabiano Rosas <farosas@suse.de>
2 months agomigration: factor out vmstate_save_field() from vmstate_save_state()
Vladimir Sementsov-Ogievskiy [Wed, 4 Mar 2026 21:22:51 +0000 (00:22 +0300)] 
migration: factor out vmstate_save_field() from vmstate_save_state()

Simplify vmstate_save_state() which is rather big, and simplify further
refactoring.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Reviewed-by: Peter Xu <peterx@redhat.com>
Link: https://lore.kernel.org/qemu-devel/20260304212303.667141-8-vsementsov@yandex-team.ru
Signed-off-by: Fabiano Rosas <farosas@suse.de>
2 months agomigration: factor out vmstate_pre_save() from vmstate_save_state()
Vladimir Sementsov-Ogievskiy [Wed, 4 Mar 2026 21:22:50 +0000 (00:22 +0300)] 
migration: factor out vmstate_pre_save() from vmstate_save_state()

Simplify vmstate_save_state() which is rather big, and simplify further
refactoring.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Reviewed-by: Peter Xu <peterx@redhat.com>
Link: https://lore.kernel.org/qemu-devel/20260304212303.667141-7-vsementsov@yandex-team.ru
Signed-off-by: Fabiano Rosas <farosas@suse.de>
2 months agomigration: vmstate_save/load_state(): refactor tracing errors
Vladimir Sementsov-Ogievskiy [Wed, 4 Mar 2026 21:22:49 +0000 (00:22 +0300)] 
migration: vmstate_save/load_state(): refactor tracing errors

To simplify further changes (convertion to bool+errp APIs),
let's rework some error paths:

- get rid of int ret in traces, as we are moving to bool+errp APIs
- split traces to _fail / _success (seems better than add boolean
  result to the message).
- prefer short error paths (return immediately on error)
- around trace_vmstate_load_field_error(), do not call
  qemu_file_set_error(), if the erroc comes from qemu_file_get_error()

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Reviewed-by: Peter Xu <peterx@redhat.com>
Link: https://lore.kernel.org/qemu-devel/20260304212303.667141-6-vsementsov@yandex-team.ru
Signed-off-by: Fabiano Rosas <farosas@suse.de>