Compare commits

...
2876 Commits
Author SHA1 Message Date
Michael Tokarev e545d8bb9d Update version for 11.0.2 release
Signed-off-by: Michael Tokarev <[email protected]>
2026-06-25 14:08:38 +03:00
Akshit Yadav 1a212f09df linux-user: Fix AT_PHDR when program headers are relocated into their own segment
When a binary is patched or relocated such that the program header table is
moved into a separate PT_LOAD segment (rather than sitting at the start of the
first loadable segment), QEMU's AT_PHDR auxv entry becomes incorrect. The
loader was computing AT_PHDR as load_addr + e_phoff, which assumes the headers
are mapped 1:1 from file offset 0. This breaks when the headers are elsewhere.

The Linux kernel instead locates the PT_LOAD segment that contains e_phoff,
then computes the in-memory address as p_vaddr + (e_phoff - p_offset). This
correctly handles relocated headers.

Fix by:
1. Add phdr_addr field to image_info to cache the resolved address.
2. Initialize to load_addr + e_phoff (fallback for headers outside any PT_LOAD).
3. In the PT_LOAD mapping loop, detect if the segment contains e_phoff and
   override with the segment-relative address.
4. Use info->phdr_addr for AT_PHDR instead of the incorrect formula.

Signed-off-by: Akshit Yadav <[email protected]>
Reviewed-by: Helge Deller <[email protected]>
(cherry picked from commit 156e536a7b)
Signed-off-by: Michael Tokarev <[email protected]>
2026-06-24 16:34:52 +03:00
Aditya Gupta eb6e366ec9 hw/pci: Replace assert with bounds check and return
As reported in https://gitlab.com/qemu-project/qemu/-/work_items/3334,
callers of 'pci_host_config_{read,write}_common' can pass length as 8,
causing an assert failure

The original issue with pnv_phb3 triggering the assert was fixed in a
previous commit

Instead of asserting on invalid length, check if the length is valid
(<=4), otherwise return (with the failure error code in read)

Reported-by: Zexiang Zhang <[email protected]>
Signed-off-by: Aditya Gupta <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Message-Id: <[email protected]>
(cherry picked from commit c7209c5671)
Signed-off-by: Michael Tokarev <[email protected]>
2026-06-24 16:34:52 +03:00
Aditya Gupta 2fbc7d3258 ppc/pnv_phb3: Error out on invalid config access
PHB in Power8 supports 8 byte registers, and hence the ops structure
allows accessing of 8 bytes in 'pnv_phb3_reg_ops'

Both 'pnv_phb3_reg_read' & 'pnv_phb3_reg_write' pass the arguments as is
to 'pnv_phb3_config_{read,write}', if offset is PHB_CONFIG_DATA.

This when called with size as 8, causes following assert failure in
'pci_host_config_read_common' & 'pci_host_config_write_common':

    assert(len <= 4);

Validate that size is <=4, before jumping to pci_host_config_{read,write}_common

Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3334
Reported-by: Zexiang Zhang <[email protected]>
Fixes: 9ae1329ee2 ("ppc/pnv: Add models for POWER8 PHB3 PCIe Host bridge")
Signed-off-by: Aditya Gupta <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Message-Id: <[email protected]>
(cherry picked from commit 2181097812)
Signed-off-by: Michael Tokarev <[email protected]>
2026-06-24 16:34:52 +03:00
Matt Turner a35a6ea811 linux-user/xtensa: fix unlock of uninitialized frame pointer on sigreturn
If lock_user_struct fails, frame is uninitialized but the badframe
label unconditionally calls unlock_user_struct on it. Handle the
lock failure inline so badframe is only reached with a valid lock.

Signed-off-by: Matt Turner <[email protected]>
Cc: [email protected]
Reviewed-by: Helge Deller <[email protected]>
Signed-off-by: Helge Deller <[email protected]>
(cherry picked from commit 54e08dbe8f)
Signed-off-by: Michael Tokarev <[email protected]>
2026-06-24 16:34:52 +03:00
Matt Turner 325a52f543 linux-user/xtensa: save/restore FP registers across signal delivery
Add support for saving and restoring f0-f15 across signal delivery.
The target_xtensa_xtregs_fp struct carries 32-bit f-regs for cores
with XTENSA_OPTION_FP_COPROCESSOR; target_xtensa_xtregs_dfp carries
64-bit f-regs for cores with XTENSA_OPTION_DFP_COPROCESSOR.

Lock the xtregs region via lock_user before reading on sigreturn,
since sc_xtregs is a user-space pointer that may lie outside the
locked sigframe.

Signed-off-by: Matt Turner <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Helge Deller <[email protected]>
(cherry picked from commit 6858e3a71c)
Signed-off-by: Michael Tokarev <[email protected]>
2026-06-24 16:34:52 +03:00
Matt Turner 0e656ebb28 target/xtensa: add cpu_set_fcr/fsr helpers to sync fp_status
Factor FCR→fp_status and FSR→fp_status synchronisation out of the
wur_fpu{2k,}_fcr/wur_fpu_fsr helpers into cpu_set_fcr(), cpu_set_fsr(),
and cpu_get_fsr(). Signal delivery code needs to restore the FP rounding
mode and exception flags without duplicating the flag-mapping tables.

cpu_set_fcr() applies the union mask 0xfffff07f (superset of the
wur_fpu_fcr mask 0x0000007f and the wur_fpu2k_fcr mask 0xfffff07f) so
that FCR bits valid only on fpu2k configs are preserved while MBZ bits
7-11 are always cleared.

Signed-off-by: Matt Turner <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Helge Deller <[email protected]>
(cherry picked from commit 7e859bacea)
Signed-off-by: Michael Tokarev <[email protected]>
2026-06-24 16:34:52 +03:00
Scott J. Goldman 271af539f5 target/arm/hvf: Stop pre-allocating cpreg_vmstate arrays
Commit ab2ddc7b66 ("target/arm/machine: Use VMSTATE_VARRAY_INT32_ALLOC
for cpreg arrays") moved cpreg_vmstate_indexes / cpreg_vmstate_values
to be allocated by VMSTATE_VARRAY_INT32_ALLOC and added an assertion
in cpu_pre_load() that they are NULL on entry. The same commit dropped
the redundant g_renew()/array_len assignments from the kvm, whpx and
helper.c cpu init paths, but the hvf cpu init path still pre-allocates
them.

The result is that loading a snapshot or migration stream into an HVF
guest immediately aborts:

    ERROR:target/arm/machine.c:1043:cpu_pre_load:
        assertion failed: (!cpu->cpreg_vmstate_indexes)

Drop the leftover cpreg_vmstate_indexes / cpreg_vmstate_values
allocations and the cpreg_vmstate_array_len assignment from
hvf_arch_init_vcpu(), matching what was already done for the other
arm accelerators.

Signed-off-by: Scott J. Goldman <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
(cherry picked from commit 06fd39e426)
Signed-off-by: Michael Tokarev <[email protected]>
2026-06-24 16:34:52 +03:00
Ryan Zhang 2fea261575 ui/sdl2: Set GL ES profile before creating initial GL context
When the user selects GLES via '-display sdl,gl=es', we need to set
SDL_GL_CONTEXT_PROFILE_MASK to SDL_GL_CONTEXT_PROFILE_ES before
calling SDL_GL_CreateContext(). This ensures SDL_GL_LoadLibrary()
loads the correct GLES driver instead of the desktop OpenGL driver.

Fix the below issue: qemu-system-aarch64: /usr/src/debug/libepoxy
/1.5.10/src/dispatch_common.c:872: epoxy_get_proc_address: Assertion
`0 && "Couldn't find current GLX or EGL context.\n"' failed.

sdl2_gl_create_context() already sets the profile mask correctly for
ES mode, but the initial context created in sdl2_window_create() is
missing the same treatment.

Fixes:da3f7a3ab9ea0091955b58f8909dfcee01f4043e ("ui/sdl: try to instantiate the matching opengl renderer")

Signed-off-by: [email protected]
Reviewed-by: Marc-André Lureau <[email protected]>
Message-ID: <DU2PR04MB9018BB3650BA218438C01F2A83042@DU2PR04MB9018.eurprd04.prod.outlook.com>
(cherry picked from commit 490a3e1867)
Signed-off-by: Michael Tokarev <[email protected]>
2026-06-24 16:34:35 +03:00
Akihiko Odaki 45ebaadb27 ui/sdl2: Explicitly specify EGL platform
Mesa's eglGetDisplay() chooses the native EGL platform from
EGL_PLATFORM, limited autodetection, or the build-time default. If that
selects Wayland while SDL is using the X11 video backend, Mesa can treat
the X11 Display pointer as a wl_display and crash during eglInitialize().

Probe EGL with the X11 platform explicitly before enabling
SDL_HINT_VIDEO_X11_FORCE_EGL.

Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3540
Signed-off-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Reviewed-by: Marc-André Lureau <[email protected]>
Message-ID: <[email protected].i.u-tokyo.ac.jp>
(cherry picked from commit 6157908503)
Signed-off-by: Michael Tokarev <[email protected]>
2026-06-24 10:36:22 +03:00
Christian Schoenebeck a7f9127b59 hw/9pfs: reject . and .. in Twstat rename
The other Trename and Trenameat handlers already reject "." and ".."
as new name on rename requests by returning -EISDIR in this case.

The legacy Twstat rename handler is missing this validation. While passing
"." or ".." does not trigger a crash as fixed by the previous patch (since
the fs backend driver's system calls handle these gracefully), it creates
a behavioral inconsistency, as it is semantically meaningless to rename a
file to a directory reference in the first place.

Fix this by rejecting "." and ".." in Twstat rename handler with -EISDIR
to match behavior of Trename and Trenameat handlers.

Fixes: 8cf89e007a ("virtio-9p: Add P9_TWSTAT support")
Link: https://lore.kernel.org/qemu-devel/662333331d371c6c343c8091161de8eaa121880e.1780072238.git.qemu_oss@crudebyte.com
Signed-off-by: Christian Schoenebeck <[email protected]>
(cherry picked from commit 08750e31fc)
Signed-off-by: Michael Tokarev <[email protected]>
2026-06-19 08:47:15 +03:00
Christian Schoenebeck 00737c895c hw/9pfs: fix abort due to illegal name with Twstat rename
The legacy Twstat 9p request can be used to rename files and directories.
Unlike the other, more recent rename requests like Trename and Trenameat,
Twstat does not validate the submitted new name before passing it to
v9fs_complete_rename().

A priviliged guest user with direct communication access to 9p server
could pass a string containing '/' as new name, which causes an assertion
fault (DoS) in local_name_to_path().

Fix this by rejecting such strings by checking the client supplied new
name with name_is_illegal(), similar to how Trename and Trenameat handlers
do already.

Reported-by: Feifan Qian <[email protected]>
Fixes: 8cf89e007a ("virtio-9p: Add P9_TWSTAT support")
Link: https://lore.kernel.org/qemu-devel/ba09716828e82992f9d8cac7f00eee0bc1c43c61.1780072238.git.qemu_oss@crudebyte.com
Signed-off-by: Christian Schoenebeck <[email protected]>
(cherry picked from commit 7f5445e7e4)
Signed-off-by: Michael Tokarev <[email protected]>
2026-06-19 08:47:15 +03:00
Mathias Krause 91ac276542 gdbstub: Update x86 control register bits
The control register bits haven't been updated in a few years, making
them lack behind features QEMU ganied in these years.

Update them to the current version of the SDM and sort the 32bit version
to be in line with all the other definitions (descending order).

This should remove confusion when debugging, for example, CET-enabled
guests:

- before the change:
  (gdb) info registers cr4
  cr4            0x8000f0            [ PGE MCE PAE PSE ]

- after the change:
  (gdb) info registers cr4
  cr4            0x8000f0            [ CET PGE MCE PAE PSE ]

Signed-off-by: Mathias Krause <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
(cherry picked from commit 88d39a2937)
Signed-off-by: Michael Tokarev <[email protected]>
2026-06-19 08:43:16 +03:00
Paolo Bonzini 77e8e0a3ae target/i386: apply mod to immediate count of an RCL/RCR operation
RCR and RCL instructions with a count of 9 are the same as if the
count was 0, but they generated incorrect code because the can_be_zero
flag is false.  This causes 0 to underflow into -1 at
tcg_gen_subi_tl(count, count, 1).

Fix by absorbing the modulo computation into gen_shift_count(), now
renamed gen_shift_count_1(), so that it can handle both reductions.

Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3452
Signed-off-by: Paolo Bonzini <[email protected]>
(cherry picked from commit e38d0afade)
Signed-off-by: Michael Tokarev <[email protected]>
2026-06-19 08:37:21 +03:00
Gerd Hoffmann 41d5a45d24 hw/uefi: fix parse_hexstr
Make sure we actually have two input characters available before going
to parse two hex digits.  Fixes one byte buffer overflow of the output
buffer in case the input string has an odd number of characters.

Fixes: CVE-2026-48915
Fixes: 12058948ab ("hw/uefi: add var-service-json.c + qapi for NV vars.")
Reported-by: Feifan Qian <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Gerd Hoffmann <[email protected]>
Message-ID: <[email protected]>
(cherry picked from commit d6601a7e1c)
Signed-off-by: Michael Tokarev <[email protected]>
2026-06-18 00:29:44 +03:00
Abhigyan Kumar 80fd822559 target/riscv: mask vxrm csrw write to the low 2 bits
Citing the RISC-V specification:

    "The vector fixed-point rounding-mode register holds a two-bit
    read-write rounding-mode field in the least-significant bits
    (vxrm[1:0]). The upper bits, vxrm[XLEN-1:2], should be written as
    zeros."

QEMU wrote full value into env->vxrm causing read of upper bits too.
Used existing macros for bit-masking. Previous had a hard-coded value.

Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3470
Signed-off-by: Abhigyan Kumar <[email protected]>
Reviewed-by: Alistair Francis <[email protected]>
Reviewed-by: Daniel Henrique Barboza <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
(cherry picked from commit 9f550a0b63)
Signed-off-by: Michael Tokarev <[email protected]>
2026-06-17 08:32:51 +03:00
Daniel Henrique Barboza a74e04e798 disas/riscv.c: fix inst_length()
inst_length() can return 0 if 'inst' happens to not match any known
encoding (like [1]).  Returning 0 is not desirable, even for unknown
encodings, given that it will cause a loop in target_disas() later on.

The most recent version of the RISC-V unpriv spec ditched the
sophisticated instruction-length encoding.  We're now supporting only
16-bit and 32-bit length instructions, where:

"All the 32-bit instructions in the base ISA have their lowest two bits
set to 11.  The optional compressed 16-bit instruction-set extensions
have their lowest two bits equal to 00, 01, or 10."

So the code is now simpler, never returning 0, and in fact it's the same
thing we're already doing in insn_len() from target/riscv/internals.h.
Due to include shenarigans we can't use that function in disas/riscv.c,
but I believe we can cut ourselves some slack this time and not lose
sleep over a 1 line of duplicated logic.  We're documenting it though!

[1] https://gitlab.com/qemu-project/qemu/-/work_items/3479

Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3479
Signed-off-by: Daniel Henrique Barboza <[email protected]>
Reviewed-by: Alistair Francis <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
(cherry picked from commit 758dce9c98)
Signed-off-by: Michael Tokarev <[email protected]>
2026-06-17 08:32:09 +03:00
Daniel Henrique Barboza b70e1f3995 target/riscv/tcg: disable svnapot if satp_mode < sv39
We did a recent change to disable svpbmt if satp_mode < sv39 that was
discovered via a gitlab report.

This time we don't have an opened bug but the problem is similar: RISC-V
privileged ISA, chapter '"Svnapot" Extension for NAPOT Translation
Contiguity, Version 1.0' states:

"The Svnapot extension depends on the Sv39 extension."

Do the same thing with svnapot, including the user warning in case we
try to enable it without the required satp_mode:

$ ./build/qemu-system-riscv64 -M virt,dumpdtb=fdt.dtb \
     -cpu max,sv39=off,sv48=off,sv57=off,sv64=off,svnapot=on
qemu-system-riscv64: warning: svnapot requires at least satp sv39, current satp mode: none

Signed-off-by: Daniel Henrique Barboza <[email protected]>
Reviewed-by: Alistair Francis <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
(cherry picked from commit 601c8494c6)
Signed-off-by: Michael Tokarev <[email protected]>
2026-06-17 08:31:57 +03:00
Daniel Henrique Barboza d7f41618b9 target/riscv/cpu_helper.c: add PMA access fault
We're not doing anything special w.r.t PMA (Physical Memory Access)
related faults, handling them like regular faults that will eventually
turn to be regular page faults.

Turns out we can't do that.  Priv spec section "Virtual Address
Translation Process" mentions:

"If a store to the PTE at address a+va.vpn[i]×PTESIZE would violate a
PMA or PMP check, raise an access-fault exception corresponding to the
original access type."

This means that we should handle PMA violations with access faults, like
we're already doing with PMP.  One clear code path where we should throw
a PMA failure, exposed by [1], is the error return from
address_space_ld* call.

There's a separated issue with the error code being returned by them (it
always return DECODE_ERROR even with 'rejected' reads) that we're going
to work around it by assuming that we did a good job with the PTE
address sanitization beforehand, and interpret that the error here is
related to PMA.  This is of course not ideal but fixing this QEMU API is
out of scope for this work.

All this said, we'll set the new pmp_pma_violation flag when we have
either a PMP or a PMA fault, and everything else shall fall into place.

[1] https://gitlab.com/qemu-project/qemu/-/work_items/3502

Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3502
Signed-off-by: Daniel Henrique Barboza <[email protected]>
Reviewed-by: Alistair Francis <[email protected]>
Reviewed-by: Chao Liu <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
(cherry picked from commit 8e090ecfa9)
Signed-off-by: Michael Tokarev <[email protected]>
2026-06-17 08:31:22 +03:00
Daniel Henrique Barboza c261475005 target/riscv/cpu_helper.c: fault with reserved PTE.PBMT val
We need to fault during any access done while PTE bits 62-61 are both
set, according to the RISC-V priv spec.

Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3494
Signed-off-by: Daniel Henrique Barboza <[email protected]>
Reviewed-by: Alistair Francis <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
(cherry picked from commit 3e33da68f1)
Signed-off-by: Michael Tokarev <[email protected]>
2026-06-17 08:30:02 +03:00
Daniel Henrique Barboza 2ba95623e1 target/riscv/insn_trans/trans_rvzicbo.c.inc: save opcode before helpers
All helpers from this file can trigger ILLEGAL_INSN exceptions via
check_zicbo_envcfg() directly, bypassing the usual exception code from
translate.c.   If we don't save the opcode before each helper,
riscv_raise_exception() is triggered and env->bins won't be unwind during
cpu_loop_exit_restore() (code path cpu_restore_state ->
cpu_restore_state_from_tb() -> restore_state_to_opc()).

And finally, in riscv_cpu_do_interrupt(), we will set (m)tval = 0 when we can,
instead, set it to the cbo opcode that generated the exception.

Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3380
Signed-off-by: Daniel Henrique Barboza <[email protected]>
Reviewed-by: Alistair Francis <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
(cherry picked from commit d6c5855c76)
Signed-off-by: Michael Tokarev <[email protected]>
2026-06-17 08:29:53 +03:00
Daniel Henrique Barboza 49ee7bf6dc disas/riscv.c: add 'cbo' insns to disassembler
We forgot to add 'cbo' insns to disas/riscv.c.  The result is that the
disassembler recognizes all of them as 'lq', an insn that happens to
share the same opcode space.

While we're at it reorder cbo_* entries in insn32.decode using opcode
order instead of insn name.

Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3480
Signed-off-by: Daniel Henrique Barboza <[email protected]>
Reviewed-by: Chao Liu <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
(cherry picked from commit 9273cda722)
Signed-off-by: Michael Tokarev <[email protected]>
2026-06-17 08:29:24 +03:00
Daniel Henrique Barboza 343cb3cf68 target/riscv/csr.c: fix mstatus.UXL reserved value
By the priv spec the value "3" is marked as 'Reserved' for mstatus.UXL.
Handle a mstatus.UXL = 3 write by writing the current 'xl' instead.

Fixes: https://gitlab.com/qemu-project/qemu/-/work_items/3367
Signed-off-by: Daniel Henrique Barboza <[email protected]>
Acked-by: Alistair Francis <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
(cherry picked from commit ddfd33f196)
Signed-off-by: Michael Tokarev <[email protected]>
2026-06-17 08:29:14 +03:00
Daniel Henrique Barboza 260bdfef90 target/riscv/csr.c: do not allow mstatus MPV/GVA writes
The priv spec states the following about mstatus.MPV:

"The MPV bit (Machine Previous Virtualization Mode) is written by the
implementation whenever a trap is taken into M-mode."

And, about mstatus.GVA:

"Field GVA (Guest Virtual Address) is written by the implementation
whenever a trap is taken into M-mode."

Both are written during riscv_cpu_do_interrupt().  They're not supposed
to be written by userspace.  As far as write_mstatus goes these fields
are read only.  The same applies for mstatush.MPV/mstatush.GVA.

Fixes: 03dd405dd5 ("target/riscv: Support MSTATUS.MPV/GVA only when RVH is enabled")
Signed-off-by: Daniel Henrique Barboza <[email protected]>
Acked-by: Alistair Francis <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
(cherry picked from commit 18645f1957)
Signed-off-by: Michael Tokarev <[email protected]>
2026-06-17 08:28:58 +03:00
Daniel Henrique Barboza 244000e2d5 target/riscv/tcg: disable svpbmt if satp_mode < sv39
Priv spec chapter "Svpbmt Extension for Page-Based Memory Types, Version
1.0" mentions that "The Svpbmt extension depends on the Sv39
extension.".

We're not doing any satp checks when enabling svpbmt.  This causes
problems with the riscv32 'max' CPU that happens to be enabling svpbmt
even though it doesn't support the required satp mode.  In fact all rv32
CPUs are allowing menvcfg.PBMTE writes, which doesn't make sense for
them in any circunstance since svpbmt is not possible for rv32 at this
moment [1].

This also impacts rv64 CPUs that are running in satp 'bare' mode and are
reporting svpbmt in the riscv,isa.

All these problems can be solved by disabling svpbmt if satp_mode is not
at least sv39.  The problem reported in [1] goes away because we'll
never enable MENVCFG_PBMTE write mask in write_menvcfgh().  We're also
become consistent with how svpbmt is enabled for rv64.

In case the user enables svpbmt in the command line using an invalid setup,
not just disable svpbmt but also throw a warning:

$ ./build/qemu-system-riscv64 -M virt,dumpdtb=fdt.dtb \
    -cpu max,sv39=off,sv48=off,sv57=off,sv64=off,svpbmt=on
qemu-system-riscv64: warning: svpbmt requires at least satp sv39, current satp mode: none

[1] https://gitlab.com/qemu-project/qemu/-/work_items/3473

Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3473
Signed-off-by: Daniel Henrique Barboza <[email protected]>
Reviewed-by: Chao Liu <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
(cherry picked from commit 109856754c)
Signed-off-by: Michael Tokarev <[email protected]>
2026-06-17 08:24:25 +03:00
Daniel Henrique Barboza 8f9caaab91 target/riscv/cpu_helper.c: allow LOAD_ADDR_MIS promotion to AMO fault
promote_load_fault() is missing the promotion of misaligned AMO load
addresses, i.e. RISCV_EXCP_LOAD_ADDR_MIS should be promoted to
RISCV_EXCP_STORE_AMO_ADDR_MIS when RISCV_UW2_ALWAYS_STORE_AMO (i.e.
always_storeamo is true).

All other load AMO faults are already being covered.

Cc: [email protected]
Fixes: 98f21c30f5 ("target/riscv: AMO operations always raise store/AMO fault")
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3503
Signed-off-by: Daniel Henrique Barboza <[email protected]>
Reviewed-by: Alistair Francis <[email protected]>
Reviewed-by: Chao Liu <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
(cherry picked from commit d85a4ec06a)
Signed-off-by: Michael Tokarev <[email protected]>
2026-06-16 22:38:15 +03:00
Eugenio Pérez 205f7b9d8d virtio: Allow to fill a whole virtqueue in order
As the while steps < max_steps is already one less than the vq size, the
right maximum max_steps variable is queue length, not the maximum
possible remainder of % vq->vring.num.

Fixes: b44135daa3 ("virtio: virtqueue_ordered_fill - VIRTIO_F_IN_ORDER support")
Signed-off-by: Eugenio Pérez <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Message-Id: <[email protected]>
(cherry picked from commit eceff0982f)
Signed-off-by: Michael Tokarev <[email protected]>
2026-06-16 19:27:23 +03:00
Alejandro Jimenez 24666f2b91 amd_iommu: Reject non-decreasing NextLevel in fetch_pte()
The AMD-Vi specification requires that the NextLevel field for a page table
entry must not be greater or equal to the current page table entry level.
Enforce this to avoid infinite page walk loops on corrupted or buggy guest
page tables.

The initial implementation of fetch_pte() did not implement this check, but
was not vulnerable since the page walk code explicitly decremented the level
instead of retrieving it from the page table entry.

Cc: [email protected]
Reviewed-by: Sairaj Kodilkar <[email protected]>
Signed-off-by: Alejandro Jimenez <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Message-Id: <[email protected]>
(cherry picked from commit 291aa70ad2)
Signed-off-by: Michael Tokarev <[email protected]>
2026-06-16 19:16:26 +03:00
Alejandro Jimenez 52908f2cc1 amd_iommu: Follow root pointer before page walk and use 1-based levels
DTE[Mode] and PTE NextLevel encode page table levels as 1-based values, but
fetch_pte() currently uses a 0-based level counter, making the logic
harder to follow and requiring conversions between DTE mode and level.

Switch the page table walk logic to use 1-based level accounting in
fetch_pte() and the relevant macro helpers. To further simplify the page
walking loop, split the root page table access from the walk i.e. rework
fetch_pte() to follow the DTE Page Table Root Pointer and retrieve the top
level pagetable entry before entering the loop, then iterate only over the
PDE/PTE entries.

The reworked algorithm fixes a page walk bug where the page size was
calculated for the next level before checking if the current PTE was already
a leaf/hugepage. That caused hugepage mappings to be reported as 4K pages,
leading to performance degradation and failures in some setups.

Fixes: a74bb3110a ("amd_iommu: Add helpers to walk AMD v1 Page Table format")
Cc: [email protected]
Reported-by: David Hoppenbrouwers <[email protected]>
Reviewed-By: David Hoppenbrouwers <[email protected]>
Reviewed-by: Sairaj Kodilkar <[email protected]>
Signed-off-by: Alejandro Jimenez <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Message-Id: <[email protected]>
(cherry picked from commit 786550e2d3)
Signed-off-by: Michael Tokarev <[email protected]>
2026-06-16 19:16:15 +03:00
Stefano Garzarella cb326591b3 libvduse: fix buffer overflow in vduse_queue_read_indirect_desc()
vduse_queue_read_indirect_desc() copies an indirect descriptor table
into a buffer in chunks when the table crosses a memory region
boundary. The destination is a struct vring_desc pointer but is
advanced by a byte count, so each increment moves the pointer by
read_len elements instead of read_len bytes, writing beyond the
buffer.

Use a char pointer for the destination so that the arithmetic
advances correctly.

While at it, change the source from a struct vring_desc pointer
to a void pointer: when the table is split across regions,
iova_to_va() can return a pointer into the middle of a descriptor,
so casting it to a struct vring_desc pointer is wrong. The pointer is
only used as a memcpy() source, so a void pointer is fine.

Fixes: CVE-2026-6425
Fixes: a6caeee811 ("libvduse: Add VDUSE (vDPA Device in Userspace) library")
Cc: [email protected]
Reported-by: DARKNAVY <[email protected]>
Signed-off-by: Stefano Garzarella <[email protected]>
Reviewed-by: Daniel P. Berrangé <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Message-Id: <[email protected]>
(cherry picked from commit 9f1b6d013d)
Signed-off-by: Michael Tokarev <[email protected]>
2026-06-16 19:15:43 +03:00
Stefano Garzarella 92d7bb038e libvhost-user: fix buffer overflow in virtqueue_read_indirect_desc()
virtqueue_read_indirect_desc() copies an indirect descriptor table
into a buffer in chunks when the table crosses a memory region
boundary. The destination is a struct vring_desc pointer but is
advanced by a byte count, so each increment moves the pointer by
read_len elements instead of read_len bytes, writing beyond the
buffer.

Use a char pointer for the destination so that the arithmetic
advances correctly.

While at it, change the source from a struct vring_desc pointer
to a void pointer: when the table is split across regions,
vu_gpa_to_va() can return a pointer into the middle of a descriptor,
so casting it to a struct vring_desc pointer is wrong. The pointer is
only used as a memcpy() source, so a void pointer is fine.

Fixes: CVE-2026-6425
Fixes: 293084a719 ("libvhost-user: Support across-memory-boundary access")
Cc: [email protected]
Reported-by: DARKNAVY <[email protected]>
Signed-off-by: Stefano Garzarella <[email protected]>
Reviewed-by: Daniel P. Berrangé <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Message-Id: <[email protected]>
(cherry picked from commit 85805ee887)
Signed-off-by: Michael Tokarev <[email protected]>
2026-06-16 19:15:20 +03:00
Costas Argyris 36d1385019 tests/qtest: Add amd-iommu command buffer head wrap test
Add a qtest for AMD IOMMU command buffer head pointer wraparound.
The test programs a command buffer, fills it with COMPLETION_WAIT commands,
advances the tail to consume all but the final entry, then wraps the tail
to zero to force the final command to advance CmdHeadPtr past the end of
the buffer. The guest-visible CmdHeadPtr register must then wrap back to zero.

This covers the case fixed by an earlier CmdHeadPtr wraparound patch.

The Linux kernel AMD IOMMU driver is not affected by this bug because it
uses COMPLETION_WAIT with a memory store doorbell to detect command progress.

Signed-off-by: Costas Argyris <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Message-Id: <[email protected]>
(cherry picked from commit 8a1c09cbd3)
Signed-off-by: Michael Tokarev <[email protected]>
2026-06-16 17:45:53 +03:00
Alejandro Jimenez 7d07b86a62 amd_iommu: Update command buffer head ptr in MMIO region after wraparound
When processing a command, amdvi_cmdbuf_run() increments cmdbuf_head and
writes it to the emulated MMIO register space before checking whether it
has reached the end of the command buffer.

If the incremented value reaches the end of the buffer and the tail pointer
is zero, the loop exits and the COMMAND_HEAD offset still contains an
unwrapped value. There are no errors in command processing since internal
cmdbuf_head state is always correctly updated, but the spec defines the
CmdHeadPtr field in MMIO Offset 2000h Command Buffer Head Pointer Register
as RW i.e. guest-visible, so it should be kept consistent.

Wrap cmdbuf_head before updating COMMAND_HEAD so the MMIO-visible register
always matches the internal command buffer head pointer position.

Cc: [email protected]
Signed-off-by: Alejandro Jimenez <[email protected]>
Reviewed-by: Sairaj Kodilkar <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Message-Id: <[email protected]>
(cherry picked from commit 3c98e446af)
Signed-off-by: Michael Tokarev <[email protected]>
2026-06-16 17:45:41 +03:00
Paolo Bonzini 1aea3c267d amd_iommu: restrict command buffer head/tail ranges to ring size
The AMD IOMMU command buffer is a ring buffer of cmdbuf_len (a power
of two) entries.  Each entry is 16 bytes and the head pointer cycles
through the set:

  [0, 16, 32, ..., (cmdbuf_len - 1) * AMDVI_COMMAND_SIZE]

The tail pointer is written by the guest through the COMMAND_TAIL MMIO
register (offset 0x2008); the while loop in amdvi_cmdbuf_run() only
terminates when head == tail.  If tail is set to a value higher than
cmdbuf_len * 16, head will cycle through all the elements of the ring
buffer indefinitely, without ever matching tail.  Fix this by further
masking tail (and head, for consistency) against the size of the
ring buffer.

Reported-by: Yunhe Wang <[email protected]>
Cc: [email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
Reviewed-by: Alejandro Jimenez <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Message-Id: <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
(cherry picked from commit 3097d54016)
Signed-off-by: Michael Tokarev <[email protected]>
2026-06-16 17:45:21 +03:00
Dominique Martinet ad16d5938d linux-user: add preadv2/preadv2
Some programs apparently use these, like the python test suite.

The flags argument (rwf_t) is an int, with values shared on all arches
and does not need translating.

This was tested manually with the following python script:
```
import os
fd = os.open('test', os.O_RDWR|os.O_CREAT)
os.pwritev(fd, [b'test', b'ok'], 0, os.RWF_HIPRI)
buf = [bytearray(3), bytearray(10)]
os.preadv(fd, buf, 0, os.RWF_HIPRI)
print(buf[0])
print(buf[1])
```

Signed-off-by: Dominique Martinet <[email protected]>
Reviewed-by: Helge Deller <[email protected]>
Signed-off-by: Helge Deller <[email protected]>
(cherry picked from commit fb4c08147b)
Signed-off-by: Michael Tokarev <[email protected]>
2026-06-14 08:53:07 +03:00
Thomas Huth 0528c5b23f system/rtc: Fix a possible year-2038 integer overflow problem
rtc_realtime_clock_offset is initialized with:

  rtc_realtime_clock_offset = qemu_clock_get_ms(QEMU_CLOCK_REALTIME) / 1000;

And QEMU_CLOCK_REALTIME might be based on gettimeofday() in certain
cases (see get_clock_realtime() in include/qemu/timer.h). So this
counter will exceed 32 bits in the year 2038, thus we should not
store this value in a normal integer variable. Change it to a time_t
to fix the problem.
And while we're at it, also adjust the nearby rtc_host_datetime_offset
variable to be on the safe side in the related code.

Signed-off-by: Thomas Huth <[email protected]>
Reviewed-by: Daniel P. Berrangé <[email protected]>
Reviewed-by: Laurent Vivier <[email protected]>
Reviewed-by: Michael Tokarev <[email protected]>
Signed-off-by: Michael Tokarev <[email protected]>
(cherry picked from commit ae84c738e4)
Signed-off-by: Michael Tokarev <[email protected]>
2026-06-14 08:51:01 +03:00
Xinhui Yang 7e6f47e08c linux-user/strace: add fsmount series of syscalls
Following the addition of fsmount(2) series of syscalls in the syscall
handler, strace support is added, with a dedicated function to print the
parameters of fsconfig(2), which contains parameters that can be
interpreted as multiple types.

Snippet of the strace dump when running `mount -t tmpfs tmpfs /media`:

18 fsopen(tmpfs,1) = 3
18 read(3,0x407fcf1c,8191) = -1 errno=61 (No data available)
18 fsconfig(3,FSCONFIG_SET_STRING,"source","tmpfs",0) = 0
18 read(3,0x407fce3c,8191) = -1 errno=61 (No data available)
18 fsconfig(3,FSCONFIG_CMD_CREATE,NULL,NULL,0) = 0
18 read(3,0x407fce3c,8191) = -1 errno=61 (No data available)
18 fsmount(3,1,0) = 4
18 read(3,0x407fce3c,8191) = -1 errno=61 (No data available)
18 statx(4,"",AT_EMPTY_PATH|AT_STATX_SYNC_AS_STAT,0x1000,0x407fee98) = 0
18 move_mount(4,,-100,/media,4) = 0
18 read(3,0x407fcfcc,8191) = -1 errno=61 (No data available)
18 close(3) = 0
18 close(4) = 0

v2: Fixed build on RHEL9 due to missing syscalls (Helge)

Signed-off-by: Xinhui Yang <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Helge Deller <[email protected]>
(cherry picked from commit 6e0aa9f6c7)
Signed-off-by: Michael Tokarev <[email protected]>
2026-06-11 23:29:20 +03:00
Xinhui Yang ee1ac6a68f linux-user: implement fsmount(2) series of syscalls
This series of syscalls replaces the old mount(2) syscall with a series
of syscalls that operates around a filesystem context. This series of
syscalls is available since Linux 5.2 and glibc 2.36+.

Their users include systemd since v259 and libmount from util-linux, and
possibly other widely used projects.

Preliminary checks are implemented to ensure the validity of the
interface.

v2: Add syscall wrappers in case the build machine does not
support the fsmount() syscalls. (added by Helge Deller)

Signed-off-by: Xinhui Yang <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Helge Deller <[email protected]>
(cherry picked from commit 767c32fe69)
Signed-off-by: Michael Tokarev <[email protected]>
2026-06-11 23:29:20 +03:00
Richard Henderson f80b72b4a5 fpu: Handle all rounding modes in partsN_uncanon_normal
Missed float_round_nearest_even_max when recomputing round.

CC: [email protected]
Fixes: 72330260cd ("softfloat: Add float_round_nearest_even_max")
Reported-by: Peter Maydell <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
(cherry picked from commit a6a1f92d5a)
Signed-off-by: Michael Tokarev <[email protected]>
2026-06-11 23:28:19 +03:00
Munkhbaatar Enkhbaatar 3ab9adb3cb hw/usb/hcd-ohci: Clean up USBPacket before freeing ISO TD packet
ohci_service_iso_td() allocates a USBPacket and frees it after synchronous
completion, but it does not call usb_packet_cleanup() first.

Call usb_packet_cleanup() before g_free() so resources owned by USBPacket
are released.

Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3463

Signed-off-by: Munkhbaatar Enkhbaatar <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
(cherry picked from commit 163f9a4e06)
Signed-off-by: Michael Tokarev <[email protected]>
2026-06-11 22:27:44 +03:00
Fabiano Rosas b29be616b8 qed: Don't try to flush during incoming migration
It's not possible to access the image file while there is an incoming
migration in progress, the QEMU process doesn't hold any locks to the
storage at this point so nodes are inactive. Attempting to flush leads
to an assert at bdrv_co_write_req_prepare():

   assert(!(bs->open_flags & BDRV_O_INACTIVE))

The issue is reproducible by running iotest 181 on a host under cpu
load. The migration must coincide with the header already containing
the QED_F_NEED_CHECK flag.

The sequence of events is as follows, with the respective call stacks
referenced below:

During block device init, bdrv_qed_attach_aio_context() starts the
'need_check' timer. The timer will not fire during incoming migration
as it uses QEMU_CLOCK_VIRTUAL (to avoid this very issue, as the code
comment indicates).                                                   (0)

However, there's still bdrv_qed_drain_begin() which uses the fact that
the timer is live to decide whether to start the
qed_need_check_timer_entry() directly.                                (1)

The qed_need_check_timer_entry() eventually calls into
qed_write_header() -> bdrv_co_pwrite() leading to the assert.         (2)

Skip creating the 'need_check' timer whenever the image is inactive.

The stacks:

(0) == issues timer_mod ==
 #6  in qed_start_need_check_timer       at ../block/qed.c:340
 #7  in bdrv_qed_attach_aio_context      at ../block/qed.c:373
 #8  in bdrv_qed_do_open                 at ../block/qed.c:556
 #9  in bdrv_qed_open_entry              at ../block/qed.c:582
 #10 in coroutine_trampoline             at ../util/coroutine-ucontext.c:175
 #0  in qemu_coroutine_switch<+120>      at ../util/coroutine-ucontext.c:321
 #1  in qemu_aio_coroutine_enter<+356>   at ../util/qemu-coroutine.c:293
 #2  in aio_co_enter<+179>               at ../util/async.c:710
 #3  in aio_co_wake<+53>                 at ../util/async.c:695
 #4  in thread_pool_co_cb<+47>           at ../util/thread-pool.c:283
 #5  in thread_pool_completion_bh<+241>  at ../util/thread-pool.c:202
 #6  in aio_bh_call<+109>                at ../util/async.c:173
 #7  in aio_bh_poll<+299>                at ../util/async.c:220
 #8  in aio_poll<+690>                   at ../util/aio-posix.c:745
 #9  in bdrv_qed_open<+392>              at ../block/qed.c:607
 #10 in bdrv_open_driver<+327>           at ../block.c:1678
 #11 in bdrv_open_common<+1619>          at ../block.c:2008
 #12 in bdrv_open_inherit<+2556>         at ../block.c:4191
 #13 in bdrv_open<+118>                  at ../block.c:4286
 #14 in blk_new_open<+199>               at ../block/block-backend.c:458
 #15 in blockdev_init<+2011>             at ../blockdev.c:612
 #16 in drive_new<+3008>                 at ../blockdev.c:1008
 #17 in drive_init_func<+51>             at ../system/vl.c:662
 #18 in qemu_opts_foreach<+227>          at ../util/qemu-option.c:1148
 #19 in configure_blockdev<+350>         at ../system/vl.c:721
 #20 in qemu_create_early_backends<+343> at ../system/vl.c:2076
 #21 in qemu_init<+12483>                at ../system/vl.c:3778
 #22 in main<+46>                        at ../system/main.c:71

(1) == sees timer_pending ==
 #6  in bdrv_qed_drain_begin             at ../block/qed.c:391
 #7  in bdrv_do_drained_begin            at ../block/io.c:366
 #8  in bdrv_do_drained_begin_quiesce    at ../block/io.c:386
 #9  in bdrv_child_cb_drained_begin      at ../block.c:1207
 #10 in bdrv_parent_drained_begin_single at ../block/io.c:133
 #11 in bdrv_parent_drained_begin        at ../block/io.c:64
 #12 in bdrv_do_drained_begin            at ../block/io.c:364
 #13 in bdrv_drained_begin               at ../block/io.c:393
 #14 in blk_drain                        at ../block/block-backend.c:2101
 #15 in blk_unref                        at ../block/block-backend.c:544
 #16 in bdrv_open_inherit                at ../block.c:4197
 #17 in bdrv_open                        at ../block.c:4286
 #18 in blk_new_open                     at ../block/block-backend.c:458
 #19 in blockdev_init                    at ../blockdev.c:612
 #20 in drive_new                        at ../blockdev.c:1008
 #21 in drive_init_func                  at ../system/vl.c:662
 #22 in qemu_opts_foreach                at ../util/qemu-option.c:1148
 #23 in configure_blockdev               at ../system/vl.c:721
 #24 in qemu_create_early_backends       at ../system/vl.c:2076
 #25 in qemu_init                        at ../system/vl.c:3778
 #26 in main                             at ../system/main.c:71

(2) == crashes ==
 #5  in __assert_fail (assertion="!(bs->open_flags & BDRV_O_INACTIVE)", file="../block/io.c", line=1977
 #6  in bdrv_co_write_req_prepare  at ../block/io.c:1977
 #7  in bdrv_aligned_pwritev       at ../block/io.c:2099
 #8  in bdrv_co_pwritev_part       at ../block/io.c:2316
 #9  in bdrv_co_pwritev            at ../block/io.c:2233
 #10 in bdrv_co_pwrite             at ../include/block/block_int-io.h:77
 #11 in qed_write_header           at ../block/qed.c:128
 #12 in qed_need_check_timer       at ../block/qed.c:305
 #13 in qed_need_check_timer_entry at ../block/qed.c:319

Note that this issue is not exactly the same as what's been reported
in Gitlab, but given how easily this reproduces, I imagine it has to
be happening in that setup as well.

Link: https://gitlab.com/qemu-project/qemu/-/work_items/3515
Signed-off-by: Fabiano Rosas <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Stefan Hajnoczi <[email protected]>
Reviewed-by: Kevin Wolf <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
(cherry picked from commit 7e573b660f)
Signed-off-by: Michael Tokarev <[email protected]>
2026-06-11 06:58:25 +03:00
Fiona Ebner e9a930bb27 iotests: test shared mmap for fuse export
This test would have worked before commit 8599559580 ("fuse: Set
direct_io and parallel_direct_writes") and is working again since
commit HEAD~1 ("block/export/fuse: set FUSE_DIRECT_IO_ALLOW_MMAP flag
to fix regression").

Signed-off-by: Fiona Ebner <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Kevin Wolf <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
(cherry picked from commit ba20257d9b)
Signed-off-by: Michael Tokarev <[email protected]>
2026-06-11 06:56:14 +03:00
Fiona Ebner 636c8430cc block/export/fuse: set FUSE_DIRECT_IO_ALLOW_MMAP flag to fix regression
Commit 8599559580 ("fuse: Set direct_io and parallel_direct_writes")
broke use cases that require mmap() with MAP_SHARED on the export. In
particular, swtpm_setup using its 'file://' protocol requires this.
From the kernel documentation [0]:

> To allow shared mmap, the FUSE_DIRECT_IO_ALLOW_MMAP flag may be
> enabled in the FUSE_INIT reply.

Set the FUSE_DIRECT_IO_ALLOW_MMAP flag to restore compatibility with
users requiring shared mmap. The FUSE_INIT_EXT flag needs to be set
for the flags2 member to have an effect.

[0]: https://www.kernel.org/doc/html/next/filesystems/fuse/fuse-io.html

Cc: [email protected]
Fixes: 8599559580 ("fuse: Set direct_io and parallel_direct_writes")
Signed-off-by: Fiona Ebner <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Kevin Wolf <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
(cherry picked from commit d1664a4058)
Signed-off-by: Michael Tokarev <[email protected]>
2026-06-11 06:53:20 +03:00
Fiona Ebner 2ae11f5049 block/export/fuse: use struct fuse_init_in
The code is switched to use the current 'struct fuse_init_in' in
preparation to use the FUSE_DIRECT_IO_ALLOW_MMAP feature, which is
part of the flags2 member that got added in protocol version 5.36.

To not break compatibility with older kernels, the check for whether
the full header of an operation was read in co_read_from_fuse_fd()
needs to be adapted. In particular, for a FUSE_INIT operation, the
protocol version must be considered, because the length of the header
changed with protocol version 7.36. Always using the length of the
old, shorter struct was inaccurate, since for newer protocol versions
this might mean accepting a truncated read for FUSE_INIT.

Users of the init header that want to use parts of the extended
structure must check with the using_old_fuse_init_in() helper function
if they may do so.

Cc: [email protected]
Fixes: a94a1d7699 ("fuse: Manually process requests (without libfuse)")
Signed-off-by: Fiona Ebner <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Kevin Wolf <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
(cherry picked from commit 817cc2d045)
Signed-off-by: Michael Tokarev <[email protected]>
2026-06-11 06:52:49 +03:00
Thomas Lamprecht d7fca23e0a qcow2: Fix data loss on zero write with detect-zeroes=unmap
Commit b8bfb1478d ("qcow2: Fix corruption on discard during write with
COW") added a wait_for_dependencies() at the start of
qcow2_subcluster_zeroize(). That fixes the inconsistency it set out to
fix, but turns the lock-protected pre-check in the caller,
qcow2_co_pwrite_zeroes(), into a stale one: the wait yields s->lock,
so an in-flight allocating write whose QCowL2Meta is already on
s->cluster_allocs (but whose L2 entry is not yet linked) gets to link
its entry during the yield. When the zeroize wakes, the cluster is now
NORMAL, and with BDRV_REQ_MAY_UNMAP the free path in zero_in_l2_slice()
unmaps the just-written cluster, silently dropping the data write's
payload.

This is reachable with detect-zeroes=unmap (the default for VirtIO
disks with discard on in Proxmox VE), under which the block layer
auto-promotes all-zero buffers to BDRV_REQ_ZERO_WRITE |
BDRV_REQ_MAY_UNMAP. A memory-constrained Debian guest running 'apt
full-upgrade' on such a disk reproduces it as random SIGSEGVs:
swapped-out code pages come back as zero.

Wait for in-flight dependencies before the lock-protected check in
qcow2_co_pwrite_zeroes(). If a write linked its L2 entry during the
wait, the type check now fails and the block layer falls back to a
bounce-buffered zero write that only touches the requested subrange,
preserving the racing write's data. Promote wait_for_dependencies() to
qcow2_wait_for_dependencies() so qcow2.c can call it.

Fixes: b8bfb1478d ("qcow2: Fix corruption on discard during write with COW")
Fixes: 7534bb105b ("qcow2: Fix corruption on discard during write with COW") in 11.0.x series
Cc: [email protected]
Tested-by: Fiona Ebner <[email protected]>
Reviewed-by: Fiona Ebner <[email protected]>
Signed-off-by: Thomas Lamprecht <[email protected]>
Message-ID: <[email protected]>
[kwolf: Reverted unnecessary change to 'nr' assignment]
Reviewed-by: Kevin Wolf <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
(cherry picked from commit 1d47eb6898)
Signed-off-by: Michael Tokarev <[email protected]>
2026-06-11 06:51:20 +03:00
Kevin Wolf 7596703755 iotests/046: Test that discard/write_zeroes wait for dependencies
This is a regression test for the bug fixed in the previous commit where
discard and write_zeroes operations wouldn't consider their dependencies
in s->cluster_allocs. Without the fix, this results in a corrupted
image.

Signed-off-by: Kevin Wolf <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Denis V. Lunev <[email protected]>
Tested-by: Denis V. Lunev <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
(cherry picked from commit 389f5bcc74)
Signed-off-by: Michael Tokarev <[email protected]>
2026-06-11 06:48:34 +03:00
Kevin Wolf 7534bb105b qcow2: Fix corruption on discard during write with COW
Most code in qcow2 that accesses (and potentially modifies) L2 tables
does so while holding s->lock.

There is one exception, which is allocating writes. They hold the lock
initially while allocating clusters, but drop it for writing the guest
payload before taking the lock again for updating the L2 tables. This
allows concurrent requests that touch other parts of the image file to
continue in parallel and is an important performance optimisation.

However, this means that other requests that run while the lock is
dropped for writing guest data must synchronise with the list of
allocating requests in s->cluster_allocs and wait if they would overlap.
For writes, this is done in handle_dependencies(), but discard and write
zeros operations neglect to synchronise with s->cluster_allocs.

This means that discard can free a cluster whose L2 entry will already
be modified in qcow2_alloc_cluster_link_l2() by a previously started
write. In the case of a pre-allocated zero cluster that is in the
process of being overwritten, this means that discard can lead to a
situation where the cluster is still mapped (because the write will
restore the L2 entry just without the zero flag), but its refcount has
been decreased, resulting in a corrupted image.

Add the missing synchronisation to qcow2_cluster_discard() and
qcow2_subcluster_zeroize() to fix the problem.

Cc: [email protected]
Reported-by: Denis V. Lunev <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Denis V. Lunev <[email protected]>
Tested-by: Denis V. Lunev <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
(cherry picked from commit b8bfb1478d)
Signed-off-by: Michael Tokarev <[email protected]>
2026-06-11 06:48:34 +03:00
Kevin Wolf 5ea9da3a01 qemu-io: Add 'aio_discard' command
Testing interactions between multiple requests that include discard
requests require that qemu-io can do the discard asynchronously, like it
already does for reads and writes. To this effect, add an 'aio_discard'
command.

Signed-off-by: Kevin Wolf <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Denis V. Lunev <[email protected]>
Tested-by: Denis V. Lunev <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
(cherry picked from commit 7f8466e2ce)
Signed-off-by: Michael Tokarev <[email protected]>
2026-06-11 06:48:34 +03:00
Stefan Hajnoczi f5e2c6906c virtio-blk: add missing VIRTIO_BLK_T_SCSI_CMD size check (CVE-2026-48914)
Check that the iovec containing struct virtio_scsi_inhdr is large enough
before storing an error value there.

Feifan Qian <[email protected]> pointed out that this can be used to
corrupt heap memory when the descriptor uses an MMIO address and a
length of 1, forcing QEMU to allocate a 1-byte heap bounce buffer.
virtio_stl_p() stores 4 bytes and therefore corrupts whatever is beyond
the bounce buffer.

Fixes: CVE-2026-48914
Fixes: f34e73cd69 ("virtio-blk: report non-zero status when failing SG_IO requests")
Reported-by: Feifan Qian <[email protected]>
Cc: Paolo Bonzini <[email protected]>
Signed-off-by: Stefan Hajnoczi <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Kevin Wolf <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
(cherry picked from commit aeea0c2804)
Signed-off-by: Michael Tokarev <[email protected]>
2026-06-11 06:38:44 +03:00
Fiona Ebner a27aa952a5 block/io: fallback to bounce buffer if BLKZEROOUT is not supported because of alignment
Commit 5634622bcb ("file-posix: allow BLKZEROOUT with -t writeback")
enables the BLKZEROOUT ioctl when using 'writeback' cache, regressing
certain 'qemu-img convert' invocations, because of a pre-existing
issue. Namely, the BLKZEROOUT ioctl might fail with errno EINVAL when
the request is shorter than the block size of the block device.
Fallback to the bounce buffer, similar to when the ioctl is not
supported at all, rather than treating such an error as fatal.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3257
Resolves: https://bugzilla.proxmox.com/show_bug.cgi?id=7197
Cc: [email protected]
Signed-off-by: Fiona Ebner <[email protected]>
Message-ID: <[email protected]>
[Added TODO comment describing a larger fix that could be implemented in
the future.
--Stefan]
Signed-off-by: Stefan Hajnoczi <[email protected]>
(cherry picked from commit b4e28c304b)
Signed-off-by: Michael Tokarev <[email protected]>
2026-06-08 20:27:51 +03:00
Jithu Joseph 55b445a534 hw/i3c: fix CMD/data FIFO depth reset values to match real silicon
The Linux DW-I3C master driver infers controller queue depths at probe
by reading two status registers that report free queue slots, which at
probe (queues empty) equals the full depth.  It then uses those values
to gate every I3C transfer -- any batch whose word count exceeds the
advertised depth is rejected with -EOPNOTSUPP.

  QUEUE_STATUS_LEVEL        (0x4c) [7:0] -> cmdfifodepth  (cmd slots)
  DATA_BUFFER_STATUS_LEVEL  (0x50) [7:0] -> datafifodepth (32-bit words)

Per the AST2600 datasheet the reset values are 0x10 and 0x40 (16 cmd
slots, 64 words = 256 B).  QEMU was advertising 0x02 and 0x10, making
the kernel believe the controller can only do 64-byte transfers.  The
visible symptom was -EOPNOTSUPP on any I3C transfer whose payload
exceeded 64 B (datafifodepth = 0x10 = 16 words = 64 B).

The underlying FIFOs in QEMU were already allocated at the right size
(fifo32_create takes word counts; the existing defaults give 16 cmd
slots and 64 data words).  Only the advertised reset values were wrong.

Correct the reset values in dw_i3c_resets[], and additionally drive the
advertised depths from the queue-capacity configs in the reset handlers
(as is already done for the device/char table pointers), so a configured
override is reflected in what the guest reads instead of being silently
ignored.  The advertised fields are 8-bit, so the depth saturates at 255
regardless of the wider capacity configs.

With this fix the guest sees datafifodepth=64 words and accepts
transfers up to 256 B.

Fixes: e974c69575 ("hw/i3c/dw-i3c: Add more reset values")
Cc: [email protected]
Signed-off-by: Jithu Joseph <[email protected]>
Reviewed-by: Jamin Lin <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
(cherry picked from commit 2d3dc20d9d)
Signed-off-by: Michael Tokarev <[email protected]>
2026-06-08 20:27:28 +03:00
Farhan Ali 54d1f797ea s390x/pci: Fix interrupt forwarding disable for interpreted devices
Remove the FH_MASK_ENABLE check when disabling interrupt forwarding
during device reset. This check was broken for the default case in
the switch statement above, preventing proper cleanup of interrupt
forwarding.

The pbdev->aif check in s390_pci_kvm_aif_disable() already guards
against double-disabling of interrupt forwarding.

Cc: [email protected]
Reported-by: Niklas Schnelle <[email protected]>
Signed-off-by: Farhan Ali <[email protected]>
Reviewed-by: Matthew Rosato <[email protected]>
Tested-by: Omar Elghoul <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Cornelia Huck <[email protected]>
(cherry picked from commit 442f727b8b)
Signed-off-by: Michael Tokarev <[email protected]>
2026-06-07 07:25:43 +03:00
Alexandra Winter a8a7e13c24 target/s390x: Make container ids in SysIB_15x 1-based
The Container Id in a container-type TLE of SysIB_15x is defined as 8-bit
unsigned nonzero integer. Make stsi fc 15 emulation architecture compliant,
by starting the container ids at 1 for the lowest numbered container.

The qemu misbehaviour without this patch becomes obvious due to a recently
proposed kernel fix. Older linux kernels pass the container ids from stsi
fc15 unchanged to sysfs, i.e. starting at 1 on s390 hardware. This resulted
in off-by-one values when compared to the values from HMC. A Linux kernel
fix is being proposed to correct the sysfs topology ids by -1, so they
start at 0, e.g. when displayed by 'lscpu -ye'. In case a KVM guest with a
fixed kernel runs on a host with a qemu without this fix, this can result
in container ids erroneously being shown as 255.
Example (Fixed guest on unfixed qemu):
$ lscpu -ye
CPU NODE DRAWER BOOK SOCKET CORE L1d:L1i:L2 ONLINE CONFIGURED POLARIZATION ADDRESS
  0    0    255  255    255    0 0:0:0         yes yes        vert-medium  0
  1    0    255  255      0    1 1:1:1         yes yes        vert-medium  1
After this fix:
$ lscpu -ye
CPU NODE DRAWER BOOK SOCKET CORE L1d:L1i:L2 ONLINE CONFIGURED POLARIZATION ADDRESS
  0    0      0    0      0    0 0:0:0         yes yes        vert-medium  0
  1    0      0    0      1    1 1:1:1         yes yes        vert-medium  1

Fixes: f4f54b582f ("target/s390x/cpu topology: handle STSI(15) and build the SYSIB")
Signed-off-by: Alexandra Winter <[email protected]>
Acked-by: Hendrik Brueckner <[email protected]>
Acked-by: Christian Borntraeger <[email protected]>
Reviewed-by: Gautam Gala <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Cornelia Huck <[email protected]>
(cherry picked from commit 1f1ccb6f3c)
Signed-off-by: Michael Tokarev <[email protected]>
2026-06-07 07:23:12 +03:00
Stefan Hajnoczi ca66c7ab2b lcitool: remove Cirrus CI support
Remove GitLab CI integration for Cirrus CI now that nothing uses it
anymore.

Signed-off-by: Stefan Hajnoczi <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Warner Losh <[email protected]>
Reviewed-by: Alex Bennée <[email protected]>
Message-id: [email protected]
Signed-off-by: Stefan Hajnoczi <[email protected]>
(cherry picked from commit 29c042c6e9)
Signed-off-by: Michael Tokarev <[email protected]>
2026-06-04 22:59:55 +03:00
Stefan Hajnoczi 250ae60686 gitlab: remove x64-freebsd-14-build Cirrus job
Cirrus has shut down and the x64-freebsd-14-build is failing:
https://gitlab.com/qemu-project/qemu/-/jobs/14656732122

Remove the x64-freebsd-14-build job to get the CI pipeline passing
again. The next commit will be to remove Cirrus integration from the
GitLab YAML and lcitool since it is no longer used.

Signed-off-by: Stefan Hajnoczi <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Warner Losh <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-id: [email protected]
Signed-off-by: Stefan Hajnoczi <[email protected]>
(cherry picked from commit 4023f38b50)
Signed-off-by: Michael Tokarev <[email protected]>
2026-06-04 22:59:39 +03:00
Alex Bennée 0cf6b8d5f3 gitlab: add initial MacOS 15 on gitlab runner
The gitlab runners are currently in beta but available to projects on
the Premium and Ultimate plans (which QEMU is via the Open Source
program).

We install some compilers via brew so we can run some of the check-tcg
softmmu test cases.

We disable rust as the version is too old.

We disable plugins because we haven't taught the test harness about
.dynlib vs .so yet.

There is a discrepancy between the vars and version of MacOS because
lcitool needs teaching about other versions (although I don't think it
matters as brew is shared across versions).

Reviewed-by: Pierrick Bouvier <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alex Bennée <[email protected]>
(cherry picked from commit 7684e78132)
Signed-off-by: Michael Tokarev <[email protected]>
2026-06-04 22:59:39 +03:00
Alex Bennée e56949d599 ci: drop cirrus MacOS build
CirrusCI is closing down soon so time to migrate.

Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alex Bennée <[email protected]>
(cherry picked from commit 984b192bdf)
Signed-off-by: Michael Tokarev <[email protected]>
2026-06-04 22:58:36 +03:00
Denis V. Lunev a1bf8c5f97 tests/unit: add test-envlist covering setenv/unsetenv name matching
util/envlist had no test coverage. Add tests/unit/test-envlist
exercising the public envlist API and pinning down the prefix-match
hazard fixed in the previous commit:

  - envlist_unsetenv("FOO") must not remove an entry named "FOOBAR";
  - envlist_setenv("FOO=...") must not replace an existing "FOOBAR=..."
    entry placed earlier in the list (envlist_setenv() inserts at the
    head, so the first prefix match wins under the old strncmp rule).

Also cover the rest of the contract: head-insertion order observed
through envlist_to_environ(), replacement of an existing variable,
the count argument of envlist_to_environ(), and the documented EINVAL
paths (NULL inputs, setenv without '=', unsetenv with '=').

Signed-off-by: Denis V. Lunev <[email protected]>
Reviewed-by: Stefan Hajnoczi <[email protected]>
Message-id: [email protected]
Cc: Stefan Hajnoczi <[email protected]>
Cc: Markus Armbruster <[email protected]>
Cc: Paolo Bonzini <[email protected]>
Signed-off-by: Stefan Hajnoczi <[email protected]>
(cherry picked from commit 05221c600a)
Signed-off-by: Michael Tokarev <[email protected]>
2026-06-04 22:57:10 +03:00
Denis V. Lunev ad43a20289 util/envlist: fix prefix-match in envlist_unsetenv() name lookup
envlist_unsetenv() looked up the entry to remove with
strncmp(entry->ev_var, env, strlen(env)). The comparison length is
the requested name's length, so any stored entry whose name *starts*
with that name compares equal. envlist_setenv() inserts at the head
of the list, so the first hit wins: with FOO=... stored first and
FOOBAR=... stored afterward, envlist_unsetenv("FOO") iterates from
the head, matches FOOBAR=... on the prefix, and drops it instead of
FOO=...

linux-user and bsd-user reach this code via the -U command-line
switch, so the bug is reachable from a normal qemu-user invocation.

envlist_setenv() used the same strncmp pattern but with
envname_len = (eq_sign - env + 1), so the '=' byte sat inside the
compared window and acted as an implicit boundary. setenv was
therefore not buggy -- but the safety lived in the byte layout of
ev_var rather than in the entry, so a future edit could easily
drift the two sites apart again.

Store the name length on each entry at insertion time and compare
with explicit length equality plus memcmp via a small helper. Use
the helper at both lookup sites so the boundary becomes a
structural property of the entry: envlist_unsetenv() stops
prefix-matching, and envlist_setenv()'s self-search no longer
depends on the '=' byte serving as a sentinel.

Fixes: 04a6dfebb6 ("linux-user: Add generic env variable handling")
Signed-off-by: Denis V. Lunev <[email protected]>
Reviewed-by: Stefan Hajnoczi <[email protected]>
Message-id: [email protected]
Cc: Stefan Hajnoczi <[email protected]>
Cc: Markus Armbruster <[email protected]>
Cc: Paolo Bonzini <[email protected]>
Signed-off-by: Stefan Hajnoczi <[email protected]>
(cherry picked from commit c131ae56c1)
Signed-off-by: Michael Tokarev <[email protected]>
2026-06-04 22:56:55 +03:00
sin99xx c394949ff2 9pfs: fix missing rename lock in v9fs_co_readdir_many (CVE-2026-48004)
v9fs_co_readdir_many() dispatches do_readdir_many() to a worker thread
that reads V9fsFidState's path.data without holding a rename lock.

A concurrent rename request, e.g. of its parent dir, causes the FID's
absolute path to be altered by freeing the old path string and
assigning a new one. This causes a heap-use-after-free race condition
while do_readdir_many() is still accessing the old object.

This allows a DoS by an unprivileged guest user.

Fix this by wrapping the worker thread dispatch block within a pair of
v9fs_path_read_lock() and v9fs_path_unlock() calls, like it's done at
other places.

Fixes: 2149675b19 ("9pfs: add new function v9fs_co_readdir_many()")
Fixes: CVE-2026-48004
Reported-by: sin99xx <[email protected]>
Signed-off-by: sin99xx <[email protected]>
[Christian Schoenebeck: add commit log message]
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Christian Schoenebeck <[email protected]>
(cherry picked from commit 5a8da7e979)
Signed-off-by: Michael Tokarev <[email protected]>
2026-06-01 20:57:06 +03:00
Christian Schoenebeck c81813227f tests/9pfs: add deep absolute path test
Add fs_deep_absolute_path test that creates a deep directory
structure with an absolute path length exceeding 16-bit range
(i.e. >65536) to verify the previous buffer overflow fix.

This is a slow test (may take several seconds) and therefore
registered as "slow" test and not running by default.

Use -m slow to run this test.

Link: https://gitlab.com/qemu-project/qemu/-/issues/3358
Link: https://lore.kernel.org/qemu-devel/933552b2cfc2c442fac7f4e68c777dce20ee8d7e.1779126034.git.qemu_oss@crudebyte.com
Signed-off-by: Christian Schoenebeck <[email protected]>
(cherry picked from commit 198627807a)
Signed-off-by: Michael Tokarev <[email protected]>
2026-06-01 20:57:06 +03:00
Christian Schoenebeck a967be3368 tests/qtest/libqos: add qvirtqueue_reset_pool() for descriptor pool reset
Add a function to reset the virtqueue descriptor pool state without
reinitializing the device. This is useful for tests that issue a high
number of requests and are limited by the simplified virtio test
driver's descriptor tracking, which decrements num_free but never
increments it back.

The function is safe for synchronous test code where requests are
sent and completed before the next request is issued.

Acked-by: Fabiano Rosas <[email protected]>
Link: https://lore.kernel.org/qemu-devel/96cf23eea1204b34443218fe76bd4a5eaf9163e8.1779126034.git.qemu_oss@crudebyte.com
Signed-off-by: Christian Schoenebeck <[email protected]>
(cherry picked from commit be33c56898)
Signed-off-by: Michael Tokarev <[email protected]>
2026-06-01 20:57:06 +03:00
Christian Schoenebeck 689a3360b9 hw/9pfs: let callers of v9fs_path_sprintf() and v9fs_fix_path() handle errors
This patch mitigates issues with very large absolute paths.

- Add error handling to all v9fs_path_sprintf() calls in
  local_name_to_path()

- Update callers of v9fs_fix_path() to check return values.

- When path formatting fails, clunk the affected FIDs to prevent use of
  invalid paths.

- Use g_autofree for temporary variables to simplify code.

Even though paths are usually limited to PATH_MAX (typically 4k) on guest,
this limitation can be circumvented by using *at() functions on guest and
creating very deep directory structures. This was a problem for QEMU 9p
server, as it currently tracks the absolute path for each FID internally
that always requires assembly of a (potentially ver large) absolute path.

A true long-term fix would be getting rid of storing an absolute path for
each FID internally. However that would likely be a massive change with
uncertain implications.

This patch therefore just mitigates the problem by immediately clunking
(i.e. closing) all FIDs whose path exceed a limit that we could handle.
As this only accounts to very unusual large absolute paths not ever been
reported on (sane) production machines, this is currently considered an
acceptable mitigation that should only (counter)affect malicious attempts.

Fixes: 2f008a8c97 ("hw/9pfs: Use the correct signed type ...")
Reported-by: Wang Jihe <[email protected]>
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3358
Link: https://lore.kernel.org/qemu-devel/1d11dcbfc95b811dcdb48c6d7f3894d0ebd073a2.1779126034.git.qemu_oss@crudebyte.com
Signed-off-by: Christian Schoenebeck <[email protected]>
(cherry picked from commit 3802c0e755)
Signed-off-by: Michael Tokarev <[email protected]>
2026-06-01 20:57:06 +03:00
Christian Schoenebeck ae45e8f2d7 hw/9pfs: add error handling to v9fs_fix_path()
Update v9fs_fix_path() to return int and propagate errors from
v9fs_path_sprintf(). This allows callers to detect and handle
path formatting failures.

Link: https://lore.kernel.org/qemu-devel/a0592741a918b7cbe751980ec7ec0c03f505924c.1779126034.git.qemu_oss@crudebyte.com
Signed-off-by: Christian Schoenebeck <[email protected]>
(cherry picked from commit 54dd352c59)
Signed-off-by: Michael Tokarev <[email protected]>
2026-06-01 20:57:06 +03:00
Christian Schoenebeck 8ceeaa588d hw/9pfs: change V9fsPath.size to size_t and v9fs_path_sprintf() return type
- Change V9fsPath.size from uint16_t to size_t to support paths larger
  than 65536 bytes.

- Change v9fs_path_sprintf() return type from void to int to allow error
  reporting.

Link: https://lore.kernel.org/qemu-devel/2d2348d94ff43fbe4cc0aea24fb312c5c15ee809.1779126034.git.qemu_oss@crudebyte.com
Signed-off-by: Christian Schoenebeck <[email protected]>
(cherry picked from commit dbaf84e148)
Signed-off-by: Michael Tokarev <[email protected]>
2026-06-01 20:57:06 +03:00
Christian Schoenebeck e1ffb20025 hw/9pfs: add NULL check in v9fs_path_is_ancestor()
Add NULL check for s1->data and s2->data before using them in
string operations. This prevents potential crashes when dealing
with uninitialized paths.

This is just a defensive measure. We are currently never passing
NULL to this function.

Link: https://lore.kernel.org/qemu-devel/3348c4d683f061c23083bd45994d527be4fb7cbc.1779126034.git.qemu_oss@crudebyte.com
Signed-off-by: Christian Schoenebeck <[email protected]>
(cherry picked from commit abb0cc02fb)
Signed-off-by: Michael Tokarev <[email protected]>
2026-06-01 20:57:06 +03:00
Matt Turner 7a8e4361f7 linux-user/s390x: restore fpu_status rounding mode from FPC on sigreturn
QEMU keeps the s390x floating-point control register (FPC) in env->fpc.
The rounding mode bits [2:0] of FPC are reflected into the derived
env->fpu_status via set_float_rounding_mode(); every architectural
write to FPC goes through HELPER(sfpc) which keeps the two in sync.

restore_sigregs() restored FPC with a direct assignment:

    __get_user(env->fpc, &sc->fpregs.fpc);

This wrote env->fpc correctly but never updated env->fpu_status, so on
sigreturn the interrupted code resumed with whatever rounding mode the
signal handler last installed in fpu_status.

Factor the two-step "write fpc + sync fpu_status" logic out of
HELPER(sfpc) into cpu_s390x_load_fpc(), declare it in cpu.h, and call
it from restore_sigregs() in place of the direct assignment.

cpu_s390x_load_fpc() partially reuses the sanity check from
HELPER(sfpc): if the FPC value has an invalid rounding mode or reserved
bits set, it falls back to 0, matching the kernel's fpu_lfpc_safe()
behavior where a corrupt signal frame value causes a specification
exception and 0 is used instead.

HELPER(sfpc) now calls cpu_s390x_load_fpc() after its full
specification-exception check, including the FEAT_FLOATING_POINT_EXT
test that is not needed for the signal restore path.

Fixes: 2941e0fa05 ("linux-user/s390x: Save/restore fpc when handling a signal")
Cc: [email protected]
Signed-off-by: Matt Turner <[email protected]>
Signed-off-by: Helge Deller <[email protected]>
(cherry picked from commit 2762cd51ee)
Signed-off-by: Michael Tokarev <[email protected]>
2026-06-01 20:27:32 +03:00
Matt Turner 568f82fbe4 linux-user/sh4: restore FP rounding mode on sigreturn
The SH4 FPSCR rounding-mode (RM) and denormal (DN) bits are not held
only in env->fpscr: they are also reflected into the derived
env->fp_status via set_float_rounding_mode()/set_flush_to_zero(). The
guest keeps the two in sync by routing every write to FPSCR through
helper_ld_fpscr().

restore_sigcontext() wrote the saved value straight into env->fpscr and
never touched env->fp_status, so on sigreturn the interrupted code
resumed with whatever FP rounding mode and flush-to-zero setting the
signal handler last installed. (regs->flags = 0 forces the FR/SZ/PR TB
flags to be recomputed, but fp_status is runtime float state, not a TB
flag, so it was left stale.) This is the FP analogue of the T/M/Q bit
problem just fixed for the integer status register.

Factor the FPSCR -> fp_status synchronisation out of helper_ld_fpscr()
into cpu_load_fpscr() and use it from restore_sigcontext() so the
rounding mode round-trips correctly across signal delivery.

Fixes: c3b5bc8ab3 ("SH4: Signal handling for the user space emulator, by Magnus Damm.")
Cc: [email protected]
Reviewed-by: Yoshinori Sato <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Matt Turner <[email protected]>
Signed-off-by: Helge Deller <[email protected]>
(cherry picked from commit a740f17ed0)
Signed-off-by: Michael Tokarev <[email protected]>
2026-06-01 20:25:10 +03:00
Matt Turner 07aca8fcdb linux-user/sh4: preserve T/M/Q bits across signal delivery
QEMU keeps the SH4 T, M and Q status-register bits outside env->sr, in
the dedicated env->sr_t, env->sr_m and env->sr_q fields; cpu_read_sr()
folds them back into the architectural SR value and cpu_write_sr()
splits them back out.

setup_sigcontext() saved the bare env->sr (so the T/M/Q bits were always
zero in the signal frame) and restore_sigcontext() wrote the value
straight back into env->sr without updating sr_t/sr_m/sr_q. As a result
the T bit was never preserved across signal delivery: on sigreturn the
interrupted code resumed with whatever T value the signal handler last
left behind. Any conditional branch (or addc/subc/rotcl/div1, etc.)
immediately following the interrupted instruction could then take the
wrong path.

This is the cause of the long-standing intermittent failures of the
tests/tcg/multiarch/signals.c test on sh4, which was marked BROKEN. With
a SIGRTMIN timer firing every millisecond across many threads, the race
was hit a few percent of the time and corrupted the guest heap, surfacing
as a SIGSEGV in memset, a malloc assertion, or an rseq registration abort.

Traced on a deterministic rr recording: a cmp/hi set T=0, the timer
signal interrupted the very next instruction (a bf), the handler left
T=1, and the resumed bf took glibc calloc's MORECORE_CLEARS branch,
using the old top-chunk size as the clear length for a freshly split
small chunk and running memset off the end of the heap.

Fix setup_sigcontext()/restore_sigcontext() to use cpu_read_sr() and
cpu_write_sr() so the T, M and Q bits round-trip correctly, and drop the
BROKEN annotation on the sh4 signals test.

Fixes: c3b5bc8ab3 ("SH4: Signal handling for the user space emulator, by Magnus Damm.")
Cc: [email protected]
Reviewed-by: Yoshinori Sato <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Matt Turner <[email protected]>
Signed-off-by: Helge Deller <[email protected]>
(cherry picked from commit 6bf4c0295c)
Signed-off-by: Michael Tokarev <[email protected]>
2026-06-01 20:24:56 +03:00
Matt Turner defa1f394b linux-user/mips: save/restore FCSR across signal delivery
QEMU keeps the MIPS FPU control/status register (FCSR, fcr31) in
env->active_fpu.fcr31.  The rounding mode, flush-to-zero (FS), and
NaN-2008 mode bits in fcr31 are reflected into the derived
env->active_fpu.fp_status via set_float_rounding_mode() and friends;
every architectural write to FCSR goes through helper_ctc1() which
calls restore_fp_status() to keep the two in sync.

Both target_sigcontext variants (O32 and N32/N64) have an sc_fpc_csr
field that holds FCSR, but setup_sigcontext() never wrote it and
restore_sigcontext() never read it.  As a result:

  - The signal frame always delivered sc_fpc_csr == 0 to the handler,
    so sigaction(SA_SIGINFO) handlers that inspect the interrupted
    context see the wrong FCSR.

  - On sigreturn, active_fpu.fcr31 retained whatever value the signal
    handler last installed (if any), and active_fpu.fp_status was
    never resynced.  Interrupted code resumed with the wrong rounding
    mode, FS flag, and NaN-2008 semantics.

Fix setup_sigcontext() to save fcr31 into sc_fpc_csr.  Fix
restore_sigcontext() to read it back (masked to fcr31_rw_bitmask as
the kernel does) and call cpu_mips_restore_fp_status() to resync
fp_status from the restored fcr31.

Add cpu_mips_restore_fp_status() in target/mips/fpu.c (which already
defines ieee_rm and includes fpu_helper.h), and declare it in cpu.h.

Fixes: 084d0497a0 ("mips-linux-user: Save and restore fpu and dsp from sigcontext")
Cc: [email protected]
Signed-off-by: Matt Turner <[email protected]>
Signed-off-by: Helge Deller <[email protected]>
(cherry picked from commit 84b920ccb5)
Signed-off-by: Michael Tokarev <[email protected]>
2026-06-01 20:22:37 +03:00
Matt Turner f4806650a2 linux-user/ppc: restore fp_status from FPSCR on sigreturn
restore_user_regs() restores the PPC FPSCR with a direct assignment:

    env->fpscr = (uint32_t) fpscr;

ppc_store_fpscr() exists precisely to write FPSCR and keep the derived
env->fp_status in sync: it calls fpscr_set_rounding_mode() to update
the softfloat rounding mode, and set_float_rebias_overflow/underflow()
to reflect the FP_OE/FP_UE enable bits.  The direct assignment bypasses
all of this.

On sigreturn, interrupted code resumes with whatever rounding mode and
overflow/underflow-rebias state the signal handler last installed in
fp_status, rather than the state that was saved at signal delivery.

Replace the direct assign with ppc_store_fpscr().  The FPSCR_MTFS_MASK
applied inside ppc_store_fpscr() only excludes the computed FP_FEX and
FP_VX bits, which it re-derives correctly from the exception and enable
bits in the restored value.

Fixes: bcd4933a23 ("linux-user: ppc signal handling")
Cc: [email protected]
Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Matt Turner <[email protected]>
Signed-off-by: Helge Deller <[email protected]>
(cherry picked from commit 3f50dd4666)
Signed-off-by: Michael Tokarev <[email protected]>
2026-06-01 20:22:14 +03:00
Peter Maydell a615c04ebc hw/net/rocker_of_dpa: Avoid unaligned accesses in _of_dpa_flow_match()
_of_dpa_flow_match() tries to do masked comparisons of OfDpaFlowkey
structs by casting pointers to them to uint64_t* and then doing the
memory accesses as 64-bit. This is undefined behaviour because the
pointers might not be 64-bit aligned, and the UB sanitizer spots this:

../../hw/net/rocker/rocker_of_dpa.c:321:20: runtime error: load of misaligned address 0x512000164044 for type 'uint64_t' (aka 'unsigned long'), which requires 8 byte alignment
0x512000164044: note: pointer points here
  02 00 00 00 00 00 ff ff  00 00 00 00 ff ff ff ff  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
              ^

We do know that OfDpaFlowKey structs must be at least aligned enough
for uint32_t accesses, because that's the type of the first field.
Switch to using uint32_t accesses in the loop.

Because the "width" field is always set via the FLOW_KEY_WIDTH macro
and not exposed to the guest, we can adjust the macro to store the
number of uint32_t to be checked rather than needing to change the
loop boundary in the match function.

Cc: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
Signed-off-by: Jason Wang <[email protected]>
(cherry picked from commit 71d027cfee)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-29 23:03:53 +03:00
Peter Maydell e752dc57a1 hw/net/rocker_of_dpa: Check group ID pointers are not NULL
In of_dpa_cmd_add_l2_flood(), we use rocker_tlv_parse_nested()
to fill in a tlvs[] array. If the guest command is valid then
the entries should be pointers to TLV data items with group IDs.
However, if the guest gives us bogus data then rocker_tlv_parse_nested()
indicates this by leaving the tlvs[] entries NULL. In the other
places that use this function, we check for this before using
the value, but here we forgot, and the result is that QEMU can
crash:

#0  __memcpy_avx_unaligned_erms () at ../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S:331
#1  0x00005555574f7137 in __asan_memcpy ()
#2  0x0000555558106792 in ldl_he_p (ptr=0x8) at /home/pm215/qemu/include/qemu/bswap.h:278
#3  0x0000555558106755 in ldl_le_p (ptr=0x8) at /home/pm215/qemu/include/qemu/bswap.h:311
#4  0x00005555580f85ed in rocker_tlv_get_le32 (tlv=0x0) at ../../hw/net/rocker/rocker_tlv.h:114
#5  0x000055555810a8ad in of_dpa_cmd_add_l2_flood (of_dpa=0x506000082e38, group=0x503000b4e440, group_tlvs=0x7fff68702c20)
    at ../../hw/net/rocker/rocker_of_dpa.c:2032
#6  0x0000555558108a74 in of_dpa_cmd_group_do (of_dpa=0x506000082e38, group_id=1073741824, group=0x503000b4e440, group_tlvs=0x7fff68702c20)
    at ../../hw/net/rocker/rocker_of_dpa.c:2115
#7  0x0000555558108730 in of_dpa_cmd_group_add (of_dpa=0x506000082e38, group_id=1073741824, group_tlvs=0x7fff68702c20)
    at ../../hw/net/rocker/rocker_of_dpa.c:2135
#8  0x00005555580f66ec in of_dpa_group_cmd
    (of_dpa=0x506000082e38, info=0x514000072e40, buf=0x5070002356c0 "\001", cmd=7, group_tlvs=0x7fff68702c20)
    at ../../hw/net/rocker/rocker_of_dpa.c:2194

Check for NULL values and return an error.

Cc: [email protected]
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/1851
Signed-off-by: Peter Maydell <[email protected]>
Signed-off-by: Jason Wang <[email protected]>
(cherry picked from commit 8526b7d6b6)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-29 23:03:37 +03:00
Peter Maydell 5d69b29970 target/arm: SME BFCVT, BFCVTN have "Alternate BFloat16 behaviors"
The Arm ARM A1.5.10 notes that some instructions have "Alternate
Bfloat16 behaviors" when FPCR.AH == 1.  We implement these using the
FPST_AH and FPST_AH_F16 fp_status words.  The list includes the SME
BFVCT (single-precision to BFloat16) and BFCVTN, but we forgot to
make those use FPST_AH_F16 when we implemented them. (We get the
ASIMD and SVE insns on the list right.)

Add the missing logic to select the right FPST.

Cc: [email protected]
Fixes: 465d36db0e ("target/arm: Implement SME2 BFCVT, BFCVTN, FCVT, FCVTN")
Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
Message-id: [email protected]
(cherry picked from commit ca33de9844)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-29 22:56:24 +03:00
Peter Maydell cc117d60ca target/arm: Don't assert if 64-bit EL2 AT insn sees a Domain fault
The Domain fault type can only happen for 32-bit short-format
descriptors.  This means that it almost never needs to be encoded in
a long-format fault status code.  However, there is one corner case
where we do need to report it as a long-format FSC: if a 64-bit EL2
does an AT insn on an AArch32 EL1&0 translation regime that is using
short-descriptors and that translation operation hits a Domain fault,
then this is reported in the PAR_EL1 in long-format.

The PAR_EL1 register description defines that this should be reported
as 0b111101 for a level 1 Domain fault or 0b111110 for a level 2
Domain fault.

The Arm ARM pseudocode special cases this in the function
AArch64_PARFaultStatus() (because no other "fault to LFSC" code path
can be a Domain fault).  For QEMU, implement it in arm_fi_to_lfsc().

Cc: [email protected]
Fixes: 1fa498fe0d ("target/arm: Provide fault type enum and FSR conversion functions")
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3512
Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-id: [email protected]
(cherry picked from commit bb95753047)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-29 22:55:59 +03:00
Richard Henderson 66e27eebb6 target/arm: Enable REVD for SVE2.1
Cc: [email protected]
Signed-off-by: Richard Henderson <[email protected]>
Message-id: [email protected]
Reviewed-by: Peter Maydell <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
(cherry picked from commit f12e7ba6f4)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-29 22:53:01 +03:00
Chenyi Qiang b6e4902db0 vfio/container: Restrict dma_map_file() to shared RAM or RAM devices
vfio_container_dma_map() uses dma_map_file() whenever a RAMBlock has an
fd and the VFIO IOMMU backend supports file-based DMA mapping. That is
not correct for private file-backed guest RAM.

dma_map_file() resolves PFNs from the backing file, but private guest
RAM mappings (MAP_PRIVATE) can run on different PFNs than the file
because they are subject to copy-on-write (COW) anomalies. As a result,
using dma_map_file() on a privately mapped RAMBlock can program DMA
against pages that do not back QEMU's actual guest memory.

Fix this by using dma_map_file() only for shared mapped RAMBlocks
(MAP_SHARED) or RAM device regions.

Fixes: fb32965b6d ("vfio/iommufd: use IOMMU_IOAS_MAP_FILE")
Reported-by: Farrah Chen <[email protected]>
Closes: https://bugzilla.kernel.org/show_bug.cgi?id=220776
Reviewed-by: Zhenzhong Duan <[email protected]>
Suggested-by: Cédric Le Goater <[email protected]>
Signed-off-by: Chenyi Qiang <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Reviewed-by: Cédric Le Goater <[email protected]>
Signed-off-by: Cédric Le Goater <[email protected]>
(cherry picked from commit e6c47bebdf)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-28 08:59:19 +03:00
GuoHan Zhao 8502282188 vfio-user: reject zero migration page size capability
check_migr_pgsize() validates that no page-size bits smaller than
VFIO_USER_DEF_PGSIZE are set, but it still accepts pgsize=0. This can replace
the default migration page size with an unusable value.

Reject a zero migration page size during version capability parsing, matching
the lower-bound check used for the DMA page-size capability.

Fixes: 36227628d8 (vfio-user: implement message send infrastructure)
Signed-off-by: GuoHan Zhao <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
(cherry picked from commit 497b5c5b05)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-28 08:52:03 +03:00
GuoHan Zhao b71979a932 vfio-user: reject zero DMA page size capability
check_pgsizes() validates that no page-size bits smaller than
VFIO_USER_DEF_PGSIZE are set, but it still accepts pgsizes=0. This lets a
malformed server overwrite the default page-size mask with zero.

Later vfio_user_setup() asserts that proxy->dma_pgsizes is non-zero, so device
realization aborts instead of reporting a version capability error. Reject a
zero DMA page-size mask during version capability parsing.

Fixes: 36227628d8 (vfio-user: implement message send infrastructure)
Signed-off-by: GuoHan Zhao <[email protected]>
Reviewed-by: John Levon <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
(cherry picked from commit ab89d02dac)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-28 08:52:03 +03:00
Peter Maydell f0a2a8a3b3 target/arm: Set correct fp flags for FLOGB when FPCR.AH = 1
Our implementation of the FLOGB insn does the operations entirely
in the helper function, without needing to use fpu functions.
This means it needs to handle all the fp status flags itself.
We aren't setting float_flag_input_denormal_used when we
use (i.e. do not flush to zero) an input denormal, which means
that FPCR.IDC isn't set when it should be for FPCR.AH=1.
We missed this when we added float_flag_input_denormal_used
and made the fpu/ code set it.

Add the missing float_raise().

Cc: [email protected]
Fixes: d38a57a3f ("target/arm: Enable FEAT_AFP for '-cpu max'")
Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Alex Bennée <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-id: [email protected]
(cherry picked from commit 23ece2805f)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-26 22:15:28 +03:00
Peter Maydell 8f4bc211bd target/arm: Use FPST_A64_F16 for SVE FCVTLT_hs
We should be using the F16-specific float_status for conversions from
half-precision, because halfprec inputs never set Input Denormal.  If
we use the FPST_A64 fpstatus then we will incorrectly set FPCR.IDC
for input-denormals when FPCR.AH=1.

In commit e07b48995a we updated most of the halfprec-to-other
conversion insns to use FPST_A64_F16 as part of implementing
FEAT_AHP.  However we missed the SVE FCVTLT instruction, which has a
halfprec-to-single encoding.

Correct the FPST we use for the hs variant of FCVTLT.

Cc: [email protected]
Fixes: e07b48995a ("target/arm: Use FPST_A64_F16 for halfprec-to-other conversions")a
Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Alex Bennée <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-id: [email protected]
(cherry picked from commit aa42300f86)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-26 22:12:48 +03:00
Peter Maydell 199f2f421a target/arm: SVE2 FMAXP, FMINP must honour AH=1
The behaviour of floating-point maximum and minimum insns has
some odd special cases when FPCR.AH=1. We get this right in most
places (for instance, the ASIMD FMAXP, FMINP) but forgot about
it for the SVE2 versions of FMAXP and FMINP.

Cc: [email protected]
Fixes: 384433e709 ("target/arm: Implement FPCR.AH semantics for FMINP and FMAXP")
Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Alex Bennée <[email protected]>
Message-id: [email protected]
(cherry picked from commit 446050c4df)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-26 22:04:04 +03:00
Denis V. Lunev a24ef7392c block/linux-aio: bound ioq_submit() recursion depth
qemu_laio_process_completions() wraps its body in defer_call_begin /
defer_call_end. Inside the section, completion callbacks wake coroutines
that queue new aiocbs; laio_do_submit() defers laio_deferred_fn. At the
bottom of qemu_laio_process_completions() the defer_call_end() fires
laio_deferred_fn, which calls ioq_submit(), closing the cycle:

  ioq_submit
    -> io_submit(2)                           // some sync completions
    -> qemu_laio_process_completions          // defer_call_begin
         -> aio_co_wake                       // resumes coroutine
              -> laio_do_submit
                   -> defer_call(laio_deferred_fn, s)   // enqueued
         -> defer_call_end                    // nesting drops to 0
              -> laio_deferred_fn
                   -> ioq_submit              // +1 stack frame, loop

When io_submit(2) returns asynchronously (O_DIRECT) the cycle
terminates in one extra frame: the fresh aiocb is still in flight, no
completion is drained, no coroutine wakes, no new submission queues.
When submissions complete synchronously (non-O_DIRECT, or per-descriptor
drivers such as vmdk) each level enqueues more work for the next
defer_call_end() to drain, so recursion grows without bound and QEMU
crashes with SIGSEGV on the thread guard page.

The cycle was closed by two performance commits, each correct in
isolation:

  076682885d ("block/linux-aio: convert to blk_io_plug_call() API")
    -- introduced laio_deferred_fn and wired
       laio_do_submit -> defer_call(laio_deferred_fn, s).

  84d61e5f36 ("virtio: use defer_call() in virtio_irqfd_notify()")
    -- added defer_call_begin/end around qemu_laio_process_completions
       so virtio-irqfd notifications batch across a completion pass.

The supported aio=native + cache=none pairing keeps submissions
asynchronous, so the cycle stays bounded; nothing in the code enforces
that contract. Observed in production as a SIGSEGV during a backup job
configured with --cached + aio=native; reproducible on upstream with
qemu-io against vmdk.

Cap ioq_submit() recursion with a counter on LaioQueue, which is only
accessed from the AioContext home thread. On overflow, return without
submitting. The pending work is drained by s->completion_bh, which
qemu_laio_process_completions() has already scheduled on entry -- no
work is lost; one event-loop round-trip of latency is paid only when
the bound is hit, which cannot happen on a supported configuration.

Signed-off-by: Denis V. Lunev <[email protected]>
CC: Kevin Wolf <[email protected]>
CC: Hanna Reitz <[email protected]>
CC: Stefan Hajnoczi <[email protected]>
CC: Paolo Bonzini <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Stefan Hajnoczi <[email protected]>
(cherry picked from commit 6864bec553)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-26 22:02:10 +03:00
Jinjie Ruan 6ccf7cb645 mc146818rtc: Fix get_guest_rtc_ns() overflow bug
In get_guest_rtc_ns(), "s->base_rtc" is uint64_t, which multiplied by
"NANOSECONDS_PER_SECOND" may overflow the uint64_t type, which will
cause the QEMU Linux Virtual Machine's RTC time to jump and in turn
triggers a kernel Soft Lockup and ultimately leads to a crash.

Fix it by avoiding adding s->base_rtc in get_guest_rtc_ns_offset(),
because get_guest_rtc_ns() is used either take the remainder of
NANOSECONDS_PER_SECOND or take the quotient of NANOSECONDS_PER_SECOND.

Fixes: 56038ef623 ("RTC: Update the RTC clock only when reading it")
Signed-off-by: Jinjie Ruan <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Cc: [email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
(cherry picked from commit 4b6c088c88)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-26 22:01:46 +03:00
Paolo Bonzini 8fe938347f apic: fix delivery bitmask with modified xAPIC ids
Self-IPIs (or all-but-self IPIs) in QEMU can cause a out-of-bounds access
to deliver_bitmask, because the access uses the APIC ID register which
is writable by the guest.  However, foreach_apic uses the delivery
bitmask indexes to look up the local_apics[] array, which is indexed
by *initial* APIC id.  Using the right id fixes both a possible heap
write overflow if the modified APIC id is too large for max_apic_words,
and a mis-delivery of both self and all-but-self IPIs.

Reported-by: Wei Che Kao <[email protected]>
Cc: [email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
(cherry picked from commit 153dc2fa7b)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-26 21:55:57 +03:00
Paolo Bonzini c02143e02c lsi53c895a: clear tag byte when processing messages
Instead of simply ORing the message byte, clear what
was there before.

Cc: [email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
(cherry picked from commit 4494dec8c2)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-26 21:55:57 +03:00
Paolo Bonzini 936662d8ca lsi53c895a: fix use-after-free of cancelled request
When processing the Message Out phase, the lsi53c895a controller
can cancel a request and the continue by processing more messages.
When this happens, it is important that a cancelled request is not
processed further, because scsi_req_cancel can cause the request
to be freed.

Right now this is happening in two cases, but not when cancelling
the entire queue of requests after an ABORT, CLEAR QUEUE or
BUS DEVICE RESET message.  In that case, a subsequent ABORT TAG
message can use a dangling current_req.

There are three possible fixes:

- add a missing check inside the loop, clearing current_req
  if p->req == current_req.  This is obvious but complicates the
  code inside the foreach loop.

- change the conditional prior to the loop from "if (s->current)"
  to "if (current_req)".  This would work, because s->current != NULL
  implies current_req != NULL, and would clear current_req correctly.
  However it is less obvious because the point of the code
  is to clear the entire queue, which consists of s->current
  and s->queue; current_req is not special here.

- delay the retrieval of current_req until an ABORT TAG message
  is seen.  This is the most correct option, because the SCSI
  protocol only deals with tags; requests are a QEMU concept
  that only makes sense for the purpose of calling into the
  SCSI layer.

Reported-by: Wei Che Kao <[email protected]>
Cc: [email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
(cherry picked from commit 5297a0fc65)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-26 21:55:57 +03:00
Heechan Kang bccd2c7d60 ui: fix validation of VNC extended clipboard data length
QEMU's VNC extended clipboard handler inflates a client-controlled
compressed clipboard payload. The code checks the declared text size
against the total inflated buffer size:

    if (tsize < size)

but then copies from:

    tbuf = buf + 4;
    qemu_clipboard_set_data(..., tsize, tbuf, true);

The correct bound is the remaining data length after the 4-byte length
field, not the total inflated buffer length.

As a result, a VNC client can make QEMU copy up to 3 bytes past the end
of the inflated heap buffer. With a second VNC client, those copied
bytes are observable through the normal VNC extended clipboard PROVIDE
path.

Fixes: CVE-2026-8343
Reported-by: Heechan Kang <[email protected]>
Reported-by: Feifan Qian <[email protected]>
Reviewed-by: Daniel P. Berrangé <[email protected]>
Signed-off-by: Heechan Kang <[email protected]>
[DB: added #include and 'return' statements]
Signed-off-by: Daniel P. Berrangé <[email protected]>
Reviewed-by: Marc-André Lureau <[email protected]>
Message-ID: <[email protected]>
(cherry picked from commit e56b4bbff1)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-26 18:38:17 +03:00
Daniel P. Berrangé 5228799f15 ui/vnc: fix OOB read updating VNC update frequency stats
Incorrect loop bounds in vnc_update_freq result in iterating past the
last row and past the last column in the VNC stats array. With suitably
chosen dimensions this could be a OOB read that accesses memory beyond
the VncDisplay struct that the stats array is embedded in.

Should this hit a guard page, it could trigger a guest crash. If it
does not, then the VNC frequency stats will be updated with garbage.

Fixes: CVE-2026-48003
Reported-by: boy juju <[email protected]>
Reviewed-by: Marc-André Lureau <[email protected]>
Signed-off-by: Daniel P. Berrangé <[email protected]>
Message-ID: <[email protected]>
(cherry picked from commit d0c7b82d3a)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-26 18:37:56 +03:00
Daniel P. Berrangé 52155a6aff ui/vnc: fix OOB write in lossy rect worker code
Incorrect calculation of the boundary condition when tracking lossy
rectangles in the worker thread will result in an OOB write which
can corrupt further worker state, and/or trigger any guard pages
that may lie beyond the VncWorker struct. This can be triggered
through careful choice of the display resolution in the guest
OS by an unprivileged user.

Fixes: CVE-2026-48002
Reported-by: Marc-André Lureau <[email protected]>
Signed-off-by: Daniel P. Berrangé <[email protected]>
Message-ID: <[email protected]>
[Marc-André - added assert() suggest by [email protected]]
Signed-off-by: Marc-André Lureau <[email protected]>
(cherry picked from commit 46ee49034d)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-26 18:32:52 +03:00
Daniel P. Berrangé 00589953cc ui/vnc: fix OOB write in VNC stats array
The VncSurface struct maintains update statistics in an array:

    VncRectStat stats[VNC_STAT_ROWS][VNC_STAT_COLS];

where the dimensions are defined as:

  #define VNC_STAT_RECT  64
  #define VNC_STAT_COLS (VNC_MAX_WIDTH / VNC_STAT_RECT)
  #define VNC_STAT_ROWS (VNC_MAX_HEIGHT / VNC_STAT_RECT)

If VNC_MAX_WIDTH / VNC_MAX_HEIGHT are not an exact multiple of
VNC_STAT_REC, the COLS/ROWS will be undersized by 1.

Unfortunately:

  #define VNC_MAX_HEIGHT 2160

is not a multiple of 64, so there is potential for OOB reads and
writes in the 'stats' array, if the guest surface is over 2112
pixels in height. An array overflow occurs when vnc_update_stats()
records new statistics, either scribbling over data later in the
VncDisplay struct that 'stats' is embedded in, or performing an
OOB write on the allocated struct memory.

Fixes: CVE-2026-48002
Reported-by: boy juju <[email protected]>
Reviewed-by: Marc-André Lureau <[email protected]>
Signed-off-by: Daniel P. Berrangé <[email protected]>
Message-ID: <[email protected]>
(cherry picked from commit c3c6226fa4)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-26 18:32:31 +03:00
Daniel P. Berrangé dde0087a1b ui/vnc: fix OOB read access in VNC SASL mechname array
When reading the SASL mechname array off the VNC connection, if
malicious, the received data may contain embedded NULs. If this
happens the memory buffer returned by g_strndup may be shorter
than the original data. Unfortunately the code continued to
index into this buffer with an offset equal to the original
length. This is a potential OOB read of the array.

Fixes: 5847d9e1 (ui/vnc: simplify and avoid strncpy)
Reported-by: boy juju <[email protected]>
Reviewed-by: Marc-André Lureau <[email protected]>
Signed-off-by: Daniel P. Berrangé <[email protected]>
Message-ID: <[email protected]>
(cherry picked from commit ae18df638f)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-26 18:32:31 +03:00
Matt Turner 6011135032 linux-user/mips64: fix mipsn32 elf_core_copy_regs entry width
For mipsn32 (TARGET_ABI32=y, TARGET_LONG_BITS=64):
  abi_ulong = uint32_t (4 bytes) — for pointers and ABI-sized fields
  target_ulong = uint64_t (8 bytes) — for general-purpose registers

linux-user/elfload.c allocates target_elf_prstatus using the
mips64/target_elf.h definition where target_elf_gregset_t has
target_ulong reserved[45] (8 bytes each, 360 bytes total).

However, in linux-user/mips64/elfload.c, #include "target_elf.h" inside
the included mips/elfload.c resolves to mips/target_elf.h (compiler
searches the file's own directory first), where the union uses abi_ulong
reserved[45].  For mipsn32 this gives 4-byte entries (180 bytes), not
the 8-byte entries (360 bytes) that elfload.c actually allocated.

Writing via r->reserved[34] therefore lands at byte offset 34*4=136
instead of the correct 34*8=272, silently zeroing the EPC in the core
file.

Fix by casting the pointer to target_ulong * so writes always use 8-byte
slots and land at the offsets matching the allocated layout.

This does not change behavior for mips64 (N64) where abi_ulong already
equals target_ulong (both 8 bytes).

Signed-off-by: Matt Turner <[email protected]>
Cc: [email protected]
Signed-off-by: Helge Deller <[email protected]>
(cherry picked from commit 6033df08e9)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-26 18:28:47 +03:00
Matt Turner a3b7cb02ba linux-user/mips64: fix elf_core_copy_regs register layout in core files
mips64/elfload.c uses #include "../mips/elfload.c" to share code. When
the compiler processes mips/elfload.c the quoted #include "target_elf.h"
resolves relative to the including file's directory, so it picks up
mips/target_elf.h instead of mips64/target_elf.h.  mips/target_elf.h
pulls in mips/target_ptrace.h, whose target_pt_regs has a pad0[6] field
before regs[].  As a result elf_core_copy_regs writes:

  r->pt.regs[i]   -> reserved[6+i]   (shifted by 6 from the correct index)
  r->pt.cp0_epc   -> reserved[40]    (correct mips64 N64 index is 34)

The Linux kernel and glibc both use the mips64 N64 layout (no pad0): EPC
at reserved[34].  Debuggers and libunwind reading the core with N64
constants therefore see a completely wrong register set — EPC points to
GP, RA holds the branch target instead of the link address, etc.

Fix by:
 - Guarding the mips32 elf_core_copy_regs in mips/elfload.c with #ifndef
   TARGET_MIPS64 so it is not compiled for mips64/mipsn32 targets.
 - Providing a mips64-specific elf_core_copy_regs in mips64/elfload.c
   that writes directly to r->reserved[i] with the correct N64 indices,
   bypassing the struct field names that are tainted by the wrong header
   include.

The mipsn32 (TARGET_ABI_MIPSN32) and mips64el targets are covered by the
same mips64/elfload.c and benefit from the same fix.

Signed-off-by: Matt Turner <[email protected]>
Cc: [email protected]
Signed-off-by: Helge Deller <[email protected]>
(cherry picked from commit dd3a906d35)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-26 18:20:27 +03:00
Portia Stephens 8854550cdf target/riscv: Make hpmcounterh return the upper 32-bits
The counter value was not being bitshifted for a hpmcounterh read
resulting in hpmcounterh returning the bottom 32-bits.

Fixes:  cfc96df65e ("target/riscv: Remove upper_half from riscv_pmu_ctr_get_fixed_counters_val")
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3498
Cc: [email protected]
Signed-off-by: Portia Stephens <[email protected]>
Reviewed-by: Alistair Francis <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
(cherry picked from commit 0228410837)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-26 11:32:59 +03:00
Daniel Henrique Barboza 5cf3aa87b2 target/riscv/csr.c: fix read of pmpaddr(0-63) CSRs
The priv spec defines, for RV64, that the upper 10 bits of
pmpaddr0-pmpaddr63 are WARL and are supposed to be cleared.

After this patch, using the bug reproducer in [1], writing
ffffffffffffffff in pmpaddr0 and reading it back now results in
003fffffffffffff.  Here's the 'diff -cp' dump before and after
this change:

*************** IN:
*** 5272,5278 ****
   pmpcfg10 0000000000000000
   pmpcfg12 0000000000000000
   pmpcfg14 0000000000000000
!  pmpaddr0 ffffffffffffffff
   pmpaddr1 0000000000000000
   pmpaddr2 0000000000000000
   pmpaddr3 0000000000000000
Reviewed-by: Alistair Francis <[email protected]>
Message-ID: <[email protected]>

Signed-off-by: Alistair Francis <[email protected]>
(cherry picked from commit 53cc9747ed)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-26 11:32:51 +03:00
Zishun Yi d125c17ede target/riscv: clear mseccfg on reset for all dependent extensions
Currently, the `mseccfg` CSR is only cleared to 0 during reset if the
`ext_smepmp` is enabled. However, this register is now shared by
several other extensions such as `zkr`, `smmpm`, and `zicfilp`.

Fix by clearing `mseccfg` if any dependent extension is present, and
adjusting the relevant comments.

This vulnerability was discovered and reported by SpecHunter, an
AI-driven architecture specification analysis tool.

Link: https://github.com/yizishun/rv-isa-sec/blob/master/output/riscv-svvptc/pr-134/qemu.txt
Signed-off-by: Zishun Yi <[email protected]>
Reviewed-by: Daniel Henrique Barboza <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
(cherry picked from commit 8158a74f0a)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-26 11:32:45 +03:00
Alistair Francis b37104e31a target/riscv: Update the local interrupt mask
The RISC-V spec describes bits 0-15 as standard fixed interrupts. The
AIA spec on the other hand describes bits 0-12 as standard fixed
interrupts. This conflict causes issues for us as we don't dynamically
determine if AIA is enabled when setting the *delegable_ints consts.

This means currently we incorrectly treat the LCOFIP bit as delegable,
even if AIA is disabled, which is incorrect (see the issues mentioned
below).

The AIA spec indicates that implementations can determine which bits of
13-63 in mvien are writable, so let's just make it bits 15-63 to match
the main spec.

Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3133
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3134
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3135
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3138
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3140
Signed-off-by: Alistair Francis <[email protected]>
Reviewed-by: Daniel Henrique Barboza <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
(cherry picked from commit 27f9566dcd)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-26 11:32:38 +03:00
Zishun Yi c86fc498f7 target/riscv: Add mseccfg to VMStateDescription
Currently, the Machine Security Configuration Register (mseccfg) was
missing from the live migration state. This omission causes the register
to be reset to zero on the destination host after migration.

Fixed by adding vmstate_mseccfg subsection

This vulnerability was discovered and reported by SpecHunter, an
AI-driven architecture specification analysis tool.

Link: https://github.com/yizishun/rv-isa-sec/blob/a22e4459cd026ae970791dfbd9cfe5d110fbd46b/output/riscv-isa-manual/pr-1879/qemu.txt#L121
Signed-off-by: Zishun Yi <[email protected]>
Reviewed-by: Alistair Francis <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
(cherry picked from commit eccb1d6940)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-26 10:05:11 +03:00
Zishun Yi a0617f269b target/riscv/pmp: Fix integer overflow in TOR and NA4 address computation
According to the RISC-V Privileged Manual: "The Sv32 page-based
virtual-memory scheme described in sv32 supports 34-bit physical
addresses for RV32, so the PMP scheme must support addresses wider than
XLEN for RV32."

However, the current QEMU implementation uses `target_ulong` (which
resolves to `uint32_t` on RV32) for PMP address variables.  When
shifting these addresses left (e.g., `this_addr << 2`), an integer
overflow occurs, truncating the high bits of the 34-bit physical
address.

Fix this issue by changing the types of PMP address variables
(`this_addr` and `prev_addr`) to `hwaddr`.

This issue was discovered and reported by SpecHunter, an AI-driven
architecture specification analysis tool.

Link: https://github.com/yizishun/rv-isa-sec/blob/master/output/riscv-isa-manual/pr-2472/qemu.txt
Signed-off-by: Zishun Yi <[email protected]>
Reviewed-by: Alistair Francis <[email protected]>
Reviewed-by: Daniel Henrique Barboza <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
(cherry picked from commit 612f22c19d)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-26 10:04:59 +03:00
Abhigyan Kumar 0b2ca8a66a target/riscv: Fix medeleg[11] read-only zero bit for M-mode ECALL
RISC-V Privileged Specification 3.1.8 (Machine Trap Delegation Registers
(medeleg and mideleg)) mentions:

"For exceptions that cannot occur in less privileged modes, the
corresponding medeleg bits should be read-only zero. In particular,
medeleg[11] is read-only zero."

QEMU incorrectly included RISCV_EXCP_M_ECALL in DELEGABLE_EXCPS. It
allowed the 11th bit to be written and read as set. Fixed by removing it
from the DELEGABLE_EXCPS mask, adhering to the specification.

Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3438
Signed-off-by: Abhigyan Kumar <[email protected]>
Reviewed-by: Alistair Francis <[email protected]>
Message-ID: <[email protected]>
[ Changes by AF:
 - Remove comment
]
Signed-off-by: Alistair Francis <[email protected]>
(cherry picked from commit a0946caf1d)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-26 10:04:50 +03:00
Frank Chang 74ce371e7c hw/char: Check interrupt after txctrl register is written
It's possible that the transmit watermark level (txctrl.txcnt) is
updated when the user writes to txctrl register, which may decrease the
transmit watermark level to less than the number of entries in the
transmit FIFO. In such a case, the interrupt should be raised so we need to
call sifive_uart_update_irq() to check and update interrupt when txctrl
register is written. Otherwise, the interrupt will have to be delayed
until next TX FIFO transmission is processed.

Suggested-by: Chao Liu <[email protected]>
Signed-off-by: Frank Chang <[email protected]>
Reviewed-by: Jim Shu <[email protected]>
Reviewed-by: Alistair Francis <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
(cherry picked from commit e07077a766)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-26 10:01:34 +03:00
Anton Blanchard fb5c86c6a6 target/riscv: rvv: Handle source overlap of vector widening reduction instructions
Widening reductions read vs2 as a vector of SEW elements and vs1[0] as a
scalar of 2*SEW. The ISA does not allow the same vector register to be read
with different EEWs, so they must not overlap.

vs1 is read as a scalar from element 0, so it is treated as a single vector
register (independent of LMUL) when checking overlap.

Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3208
Signed-off-by: Anton Blanchard <[email protected]>
Acked-by: Alistair Francis <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
(cherry picked from commit caf3bef5f0)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-26 09:56:41 +03:00
Zishun Yi 78d5c57083 target/riscv: Allow mseccfg access based on ext_zicfilp
The Zicfilp extension adds the MLPE field to the mseccfg CSR. According
to the RISC-V Privileged Specification, mseccfg exists if any extension
that adds a field to it is implemented.

Currently, the `have_mseccfg()` predicate function checks for Smepmp,
Zkr, and Smmpm, but misses Zicfilp. As a result, if a CPU is configured
with `zicfilp=true` but without the other extensions, accessing the
mseccfg CSR will incorrectly raise an illegal instruction exception.

This patch adds the missing check for `ext_zicfilp` to ensure the CSR
is properly accessible when the Zicfilp extension is enabled.

This issue was discovered and reported by SpecHunter, an AI-driven
architecture specification analysis tool.

Link: https://github.com/yizishun/rv-isa-sec/blob/master/output/riscv-isa-manual/pr-2561/qemu.txt
Signed-off-by: Zishun Yi <[email protected]>
Reviewed-by: Chao Liu <[email protected]>
Reviewed-by: Daniel Henrique Barboza <[email protected]>
Reviewed-by: Alistair Francis <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
(cherry picked from commit 2494836232)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-26 09:56:33 +03:00
Andrew Jones 81e9484f4d hw/riscv/riscv-iommu: Fix Svnapot 64KB pages
The Svnapot extension encodes a 64KB leaf PTE by setting PTE_N and
storing bits [3:0] of the PPN as a NAPOT size indicator. The IOMMU
model wasn't checking PTE_N and therefore was using the raw (NAPOT-
encoded) PPN directly in the physical address, yielding an address
32 KB above the correct base.

Fix both riscv_iommu_spa_fetch() and pdt_memory_read() by mirroring
the Svnapot handling already present in target/riscv/cpu_helper.c:

  napot_bits  = ctz64(ppn) + 1          /* 4 for 64KB */
  napot_mask  = (1 << napot_bits) - 1   /* 0xF */
  phys_base   = PPN_PHYS(ppn & ~napot_mask)
  page_offset = addr & (PPN_PHYS(napot_mask) | (TARGET_PAGE_SIZE - 1))

The spec only defines napot_bits == 4 (64KB); any other value is
treated as a reserved encoding.

This is a fix, rather than new feature support, because the spec
says "IOMMU implementations must support the Svnapot standard
extension for NAPOT Translation Contiguity."

Fixes: 0c54acb824 ("hw/riscv: add RISC-V IOMMU base emulation")
Cc: [email protected]
Signed-off-by: Andrew Jones <[email protected]>
Reviewed-by: Daniel Henrique Barboza <[email protected]>
Reviewed-by: Nutty Liu <[email protected]>
Reviewed-by: Tomasz Jeznach <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
(cherry picked from commit fcbd93e96b)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-26 09:55:51 +03:00
Frank Chang 7e66ab1290 target/riscv: Update MISA.X for non-standard extensions
MISA.X is set if there are any non-standard extensions.
We should set MISA.X when any of the vendor extensions is enabled.

Signed-off-by: Frank Chang <[email protected]>
Reviewed-by: Max Chou <[email protected]>
Reviewed-by: Daniel Henrique Barboza <[email protected]>
Reviewed-by: Alistair Francis <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
(cherry picked from commit 613bb1949f)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-26 09:55:51 +03:00
Frank Chang fa2c8225a3 target/riscv: Update MISA.C for Zc* extensions
MISA.C is set if the following extensions are selected:
  * Zca and not F.
  * Zca, Zcf and F (but not D) is specified (RV32 only).
  * Zca, Zcf and Zcd if D is specified (RV32 only).
  * Zca, Zcd if D is specified (RV64 only).

Therefore, MISA.C must be set according to the Zc* extension rules.

Warn the user if RVC is explicitly disabled but MISA.C is required by
the rules above.

Signed-off-by: Frank Chang <[email protected]>
Reviewed-by: Max Chou <[email protected]>
Reviewed-by: Alistair Francis <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
(cherry picked from commit f0433a8bc4)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-26 09:55:51 +03:00
Daniel P. Berrangé b65de8cedb crypto: fix client side anonymous TLS credentials
The previous refactoring of credential creation failed to allocate
storage fo the anonymous TLS credentials on the client endpoint.

Fixes: 70f9fd8dbf
Reported-by: Maciej S. Szmigiero <[email protected]>
Signed-off-by: Daniel P. Berrangé <[email protected]>
(cherry picked from commit 27b127d734)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-25 20:19:43 +03:00
Michael Tokarev 6e9a825c1d Update version for 11.0.1 release
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-25 20:13:26 +03:00
Denis V. Lunev fddafa15a9 block/graph-lock: fix missed wakeup in bdrv_graph_co_rdunlock()
tests/qemu-iotests/tests/iothreads-create reproduces the hang on
master under `stress-ng --cpu $(nproc) --timeout 0`.  The iotest's
vm.run_job() times out and qemu stays permanently stuck in
ppoll(timeout=-1) inside bdrv_graph_wrlock_drained -> blk_remove_bs
during qemu_cleanup().  The timing window is narrow on modern
bare-metal hardware and much wider in a VM guest; downstream trees
that still use plain bdrv_graph_wrlock() in blk_remove_bs() hit it
on the first iteration under the same stress.

bdrv_graph_wrlock() zeroes has_writer around its AIO_WAIT_WHILE loop
so that callbacks dispatched by aio_poll() can still take the read
lock on the fast path.  The rdunlock side, however, only kicks a
waiting writer when has_writer is observed set; a reader that drops
its lock inside the polling window silently returns and nothing ever
wakes the writer:

  main thread                         iothread0 coroutine
  -----------                         -------------------
  bdrv_graph_wrlock:                  rdlock held, reader_count=1
    bdrv_drain_all_begin_nopoll
    has_writer = 0
    AIO_WAIT_WHILE_UNLOCKED(
        NULL, reader_count >= 1):
      num_waiters++
      smp_mb
      aio_poll(main_ctx, true)   -->  bdrv_graph_co_rdunlock:
        (ppoll, blocked)                reader_count-- -> 0
                                        smp_mb
                                        read has_writer = 0
                                        skip aio_wait_kick()
                                      return

reader_count is now 0 and num_waiters is still 1, but no BH, fd or
timer on the main AioContext will fire -- the only entity that could
kick just decided it did not have to.  Main stays in ppoll() holding
BQL, so RCU, VCPUs and any iothread path that needs BQL stall behind
it.  The hang is final; no timeout, no forward progress, no recovery
as there is no other source of wake up inside qemu_cleanup().

bdrv_drain_all_begin() does not close the race on its own: it
quiesces in-flight I/O, but graph readers also include non-I/O
coroutines (block-job cleanup, virtio-scsi polling) that drain does
not evict.  The bdrv_graph_wrlock_drained() wrapper narrows the
window but does not eliminate it; every plain bdrv_graph_wrlock()
site is exposed on the same basis.

Drop the has_writer check in bdrv_graph_co_rdunlock() and call
aio_wait_kick() unconditionally.  The helper itself loads num_waiters
atomically and only schedules a dummy BH when a waiter exists, so the
change is a no-op on the no-writer path and closes the missed-wakeup
on the writer path.

Signed-off-by: Denis V. Lunev <[email protected]>
Cc: Kevin Wolf <[email protected]>
Cc: Hanna Reitz <[email protected]>
Cc: Stefan Hajnoczi <[email protected]>
Cc: Fiona Ebner <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Kevin Wolf <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
(cherry picked from commit e3082ab3b3)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-25 20:10:14 +03:00
Kevin Wolf 438e152ad4 commit: Drain nodes across all of bdrv_commit()
The whole implementation of bdrv_commit() is only correct if no new
writes come in while it's running: It has only a single loop checking
the allocation status for each block and finally calls bdrv_make_empty()
without checking if that throws away any new changes.

We already have to drain while taking the graph write lock. Just extend
the drained section to all of bdrv_commit() to make sure that we don't
get any inconsistencies.

Signed-off-by: Kevin Wolf <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Denis V. Lunev <[email protected]>
Tested-by: Denis V. Lunev <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
(cherry picked from commit f0d9ccd46c)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-20 11:20:55 +03:00
Kevin Wolf a8efa05637 block: Add more defaults to DEFAULT_BLOCK_CONF
discard_granularity was missing from this, which means that SCSI disks
created with -drive if=scsi would default to 0 (i.e. disabling discards)
instead of -1, which makes scsi-hd automatically pick a granularity and
is the default of the corresponding qdev property for -device scsi-hd.

This was broken in QEMU 9.0 with commit 3089637.

Also set other fields whose default isn't an obvious 0. These are not
actual bug fixes because ON_OFF_AUTO_AUTO in fact happens to be 0, but
it's better not to rely on the order of enums.

Cc: [email protected]
Fixes: 3089637461 ('scsi: Don't ignore most usb-storage properties')
Reported-by: Lexi Winter <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
(cherry picked from commit f27aea1896)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-20 11:20:55 +03:00
Kevin Wolf 16db6a23fe block: Create DEFAULT_BLOCK_CONF macro
The property default values from include/hw/block/block.h were
duplicated in scsi_bus_legacy_handle_cmdline(), allowing them to go out
of sync easily. There doesn't seem a good way to avoid the duplication,
but moving them next to each other in the header file should help to
avoid this problem in the future.

Signed-off-by: Kevin Wolf <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
(cherry picked from commit a1310cc628)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-20 11:20:55 +03:00
Kevin Wolf a56f665743 ide-test: Test reset during TRIM
This is a regression test for the bug fixed in the previous commits, a
deadlock between the drain issued by an IDE reset and the TRIM state
machine.

Signed-off-by: Kevin Wolf <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
(cherry picked from commit 2fa24e9755)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-20 11:20:51 +03:00
Kevin Wolf ba4f1c1f87 ide-test: Factor out wait_dma_completion()
Signed-off-by: Kevin Wolf <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
(cherry picked from commit 92854c9c75)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-20 11:20:47 +03:00
Kevin Wolf 5044ebfad8 ide: Clean up ide_trim_co_entry() to be idiomatic coroutine code
The previous commit did a minimal conversion of the callback based state
machine for TRIM to a coroutine in order to fix a bug. Refactor it to
actually look like normal coroutine based code, which improves its
readability.

Signed-off-by: Kevin Wolf <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
(cherry picked from commit c1c71a7e16)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-20 11:20:43 +03:00
Kevin Wolf 6e5b03431b ide: Minimal fix for deadlock between TRIM and drain
The implementation of TRIM in IDE can chain multiple discard requests
and uses blk_inc/dec_in_flight() to make sure that the whole TRIM
operation has completed when the device needs to be quiescent (e.g. for
the drain when performing an IDE reset, it would be bad if an IDE
request like TRIM were still in flight).

The problem is that each drain request calls blk_wait_while_drained()
and when draining, it waits until the drained section ends. At the same
time, drain_begin can only return if the whole TRIM operation has
completed. This is a classic deadlock.

Use blk_co_start/end_request() and BDRV_REQ_NO_QUEUE to avoid the
problem. This requires moving the TRIM state machine to a coroutine.
This commit does the minimal conversion so that we do have a coroutine
that works for the fix, but it still looks much like a callback-based
implementation. This will be cleaned up in the next patch.

Cc: [email protected]
Fixes: 7e5cdb345f ('ide: Increment BB in-flight counter for TRIM BH')
Buglink: https://redhat.atlassian.net/browse/RHEL-121686
Signed-off-by: Kevin Wolf <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
(cherry picked from commit 095c08a7ba)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-20 11:19:44 +03:00
Kevin Wolf 854bf73918 block: Add flags parameter to blk_*_pdiscard()
All existing callers pass 0, but we need a way to pass BDRV_REQ_NO_QUEUE
for discard requests.

Signed-off-by: Kevin Wolf <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
(cherry picked from commit 53074ba033)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-20 11:19:44 +03:00
Kevin Wolf e25d83015b block: Add blk_co_start/end_request() and BDRV_REQ_NO_QUEUE
If a device uses blk_inc/dec_in_flight() in order to build macro
operations that involve multiple requests for the block layer and that
need to be completed as a unit before the BlockBackend can be considered
drained, it sets the stage for a deadlock: When a drain is requested,
the inner request at the BlockBackend level will be queued in
blk_wait_while_drained() and wait until the drained section ends, but at
the same time, drain_begin can only return if the whole macro operation
at the device level has completed.

Introduce a new interface to allow implementing the logic correctly:
Instead of queueing individual requests, blk_co_start_request() calls
blk_wait_while_drained() once at the beginning. The individual requests
must then set BDRV_REQ_NO_QUEUE to avoid being queued and running into
the deadlock; being wrapped in blk_co_start/end_request() makes sure
that drain_begin waits for them and they don't sneak in when the
BlockBackend is supposed to already be quiescent.

Signed-off-by: Kevin Wolf <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
(cherry picked from commit 34a6763776)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-20 11:19:44 +03:00
Kevin Wolf f44edf3d88 blkdebug: Add 'delay-ns' option
Sometimes reproducing a problem for debugging involves slow I/O, so
let's add something to blkdebug to make I/O slow when we need it. This
can be used either together with an error so that the request fails
after the delay, or with errno=0, which allows the request to succeed
after the delay.

Signed-off-by: Kevin Wolf <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
(cherry picked from commit d5e4090177)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-20 11:19:40 +03:00
Matt Turner 4a3684ef68 linux-user/sh4: Fix setup_sigtramp to match Linux kernel trampoline pattern
QEMU used MOVW(2) (0x9300), which loads the syscall number from PC+4,
instead of the kernel's MOVW(7) (0x9305), which loads from PC+14.  The
kernel uses five "or r0,r0" nop pads between TRAP_NOARG and the syscall
number word to reach that offset.  libunwind's unw_is_signal_frame checks
for the exact kernel byte pattern 0xc3109305 at the frame PC, so QEMU's
compact layout was not detected, breaking unwinding through signal frames.

Expand each trampoline from 6 to 16 bytes matching the kernel layout
defined in arch/sh/kernel/signal_32.c:

  #define MOVW(n)    (0x9300|((n)-2))  /* Move mem word at PC+n to R3 */
  #define TRAP_NOARG 0xc310            /* Syscall w/no args (NR in R3) */
  #define OR_R0_R0   0x200b            /* or r0,r0 (insert to avoid hardware bug) */

  __put_user(MOVW(7),          &frame->retcode[0]);  /* 0x9305 */
  __put_user(TRAP_NOARG,       &frame->retcode[1]);  /* 0xc310 */
  __put_user(OR_R0_R0,         &frame->retcode[2]);  /* 0x200b */
  __put_user(OR_R0_R0,         &frame->retcode[3]);  /* 0x200b */
  __put_user(OR_R0_R0,         &frame->retcode[4]);  /* 0x200b */
  __put_user(OR_R0_R0,         &frame->retcode[5]);  /* 0x200b */
  __put_user(OR_R0_R0,         &frame->retcode[6]);  /* 0x200b */
  __put_user((__NR_sigreturn), &frame->retcode[7]);

The first two halfwords (MOVW(7) || TRAP_NOARG = 0xc3109305) form the
32-bit value libunwind checks at the frame PC, followed by two
OR_R0_R0 halfwords (0x200b200b) at PC+4.  The same layout applies to
the rt_sigreturn trampoline (lines 366-373 of signal_32.c).

Neither this fix nor the companion tuc_link fix is independently
sufficient: this fix makes signal frames detectable but register reads
remain garbage without the correct ucontext layout; that fix corrects the
ucontext layout but libunwind still cannot detect the frame without the
correct trampoline pattern.  Together they fix the following libunwind
tests on a 64-bit host:
  Gtest-sig-context, Gtest-trace, Ltest-init-local-signal,
  Ltest-sig-context, Ltest-trace

Signed-off-by: Matt Turner <[email protected]>
Cc: [email protected]
Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Helge Deller <[email protected]>
(cherry picked from commit 9ac5aa7227)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-19 23:56:02 +03:00
Matt Turner 4b7971a1cb linux-user/sh4: Fix target_ucontext tuc_link field type
tuc_link is declared as 'struct target_ucontext *', which is a HOST
pointer.  On a 64-bit host running a 32-bit SH4 target, this is 8 bytes
instead of the 4 bytes the target expects, padding pushes tuc_mcontext
8 bytes past its correct offset.

When a signal handler receives ucontext_t *, every field accessed through
uc_mcontext (gregs[], pc, pr, ...) is read from the wrong address.  In
particular the saved PC comes back as a garbage stack value, which breaks
any code that initialises a libunwind cursor from the signal context.

Fix it by using abi_ulong, which is always sized to the target ABI (4
bytes for SH4), matching the layout the kernel and glibc agree on.  This
is the same pattern used by arm/signal.c.

Also remove the (unsigned long *) cast from the __put_user that zeros
tuc_link.  The cast was harmless when tuc_link was pointer-sized (8
bytes matching unsigned long on a 64-bit host), but after the type
change __put_user's sizeof dispatch would select stq_le_p (8-byte write)
for a now-4-byte field, silently overwriting the start of tuc_stack.

Neither this fix nor the companion setup_sigtramp fix is independently
sufficient: this fix corrects register values read from the signal context
but libunwind still cannot detect the frame without the correct trampoline
pattern; that fix makes the frame detectable but register reads remain
garbage without the correct ucontext layout.  Together they fix the
following libunwind tests on a 64-bit host:
  Gtest-sig-context, Gtest-trace, Ltest-init-local-signal,
  Ltest-sig-context, Ltest-trace

Signed-off-by: Matt Turner <[email protected]>
Cc: [email protected]
Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Helge Deller <[email protected]>
(cherry picked from commit c3176e6457)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-19 23:55:47 +03:00
Helge Deller ac7b9fabf2 linux-user: Fix AT_EXECFN in AUXV for symlinked programs
The AT_EXECFN entry in AUXV needs to keep the value which was used when
the program was started. Especially for symlinked programs qemu should
not try to resolve the realpath.

Here is a reproducer:
(arm64-chroot)root@p100:/# cd /usr/bin
(arm64-chroot)root@p100:/usr/bin# ln -s echo testprog
(arm64-chroot)root@p100:/usr/bin# LD_SHOW_AUXV=1 ./testprog | grep AT_EXECFN
AT_EXECFN:            ./testprog

In this example, "./testprog" is the correct output, and not "/usr/bin/echo".

This patch fixes parts of commit 258bec39 ("linux-user: Fix access to
/proc/self/exe").

Fixes: 258bec39 ("linux-user: Fix access to /proc/self/exe")
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3379
Signed-off-by: Helge Deller <[email protected]>
(cherry picked from commit 6b5aef7cac)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-19 23:53:28 +03:00
Klaus Jensen 4719d2b9cc hw/nvme: fix admin cq msix setup
If MSI-X is not enabled when the admin completion queue is created,
msix_vector_use() is not called. But, if MSI-X is subsequently enabled,
msix_notify() will fail to fire the interrupt because the use count for
the vector remains at 0.

msix_vector_use/unuse should be called if MSI-X is *present*, not
*enabled*. Fix this.

Cc: [email protected]
Reported-by: Andreas Hindborg <[email protected]>
Signed-off-by: Klaus Jensen <[email protected]>
(cherry picked from commit 2293d8b4bd)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-19 23:41:47 +03:00
Scott J. Goldman 3b98370b55 target/arm/hvf: Fix WFI halting to stop idle vCPU spinning
Commit b5f8f77271 ("accel/hvf: Implement WFI without using pselect()")
changed hvf_wfi() from blocking the vCPU thread with pselect() to
returning EXCP_HLT, intending QEMU's main event loop to handle the
idle wait. However, cpu->halted was never set, so cpu_thread_is_idle()
always returns false and the vCPU thread spins at 100% CPU per core
while the guest is idle.

Fix this by:

1. Setting cpu->halted = 1 in hvf_wfi() so the vCPU thread sleeps on
   halt_cond in qemu_process_cpu_events().

2. Arming a per-vCPU QEMU_CLOCK_VIRTUAL timer to fire when the guest's
   virtual timer (CNTV_CVAL_EL0) would expire. This is necessary
   because HVF only delivers HV_EXIT_REASON_VTIMER_ACTIVATED during
   hv_vcpu_run(), which is not called while the CPU is halted. The
   timer callback mirrors the VTIMER_ACTIVATED handler: it raises the
   vtimer IRQ through the GIC and marks vtimer_masked, causing the
   interrupt delivery chain to wake the vCPU via qemu_cpu_kick().

3. Clearing cpu->halted in hvf_arch_vcpu_exec() when cpu_has_work()
   indicates a pending interrupt, and cancelling the WFI timer.

4. Re-arming the WFI timer from hvf_vm_state_change() on the resume
   transition for any halted vCPU, since the QEMUTimer is per-instance
   state and is not migrated. After cpu_synchronize_all_states() the
   migrated vtimer state is mirrored in env, so we can read CNTV_CTL
   and CNTV_CVAL from there. If the vtimer has already expired by the
   time the destination resumes, hvf_wfi_timer_cb() is invoked
   directly so the halted vCPU is woken up.

All wfi_timer handling (allocation, arming, deletion, and the resume
re-arm) is gated on !hvf_irqchip_in_kernel(): with the Apple in-kernel
vGIC, HVF owns the vtimer and delivers wake-ups itself.

Note for stable backports: this commit won't apply to 11.0 as
it has changes to handle the hvf in-kernel irqchip support that
landed after the 11.0 release. The v3 version of this commit:
  https://patchew.org/QEMU/[email protected]/
should be suitable for 11.0 backporting (it is essentially
identical except that it doesn't make the changes conditional
on !hvf_irqchip_in_kernel()).

Cc: [email protected]
Fixes: b5f8f77271 ("accel/hvf: Implement WFI without using pselect()")
Signed-off-by: Scott J. Goldman <[email protected]>
Reviewed-by: Mohamed Mediouni <[email protected]>
[PMM: added note about stable backports to commit message]
Signed-off-by: Peter Maydell <[email protected]>
(cherry picked from commit a86024eb2d)
(Mjt: add hvf_irqchip_in_kernel() define)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-19 23:41:47 +03:00
Peter Maydell 420e10994e tests/functional/qemu_test/asset.py: Don't use setxattr when it doesn't exist
The Python os.setxattr() API is Linux-specific, so trying to use
it on other OSes triggers a failure:

  File "/Users/pm215/src/qemu/tests/functional/qemu_test/asset.py",
line 227, in fetch
    os.setxattr(str(tmp_cache_file), "user.qemu-asset-url",
    ^^^^^^^^^^^
AttributeError: module 'os' has no attribute 'setxattr'

Since we only set the attributes here for informational
purposes, skip them when os.setxattr() isn't available.

Cc: [email protected]
Fixes: 9903217a4e ("tests/functional: add a module for handling asset download & caching")
Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Daniel P. Berrangé <[email protected]>
Reviewed-by: Alex Bennée <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Message-id: [email protected]
(cherry picked from commit 039b057c09)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-19 23:41:47 +03:00
Peter Maydell c752106ad8 hw/remote/machine.c: Mark x-remote machine as OK for AArch64 and AArch32
When we updated Arm and AArch64 board types to mark them for the
target_machine_typename() filter, we forgot about the "x-remote"
machine type, which meant that it disappeared from the set of board
types exposed on the qemu-system-arm and qemu-system-aarch64
binaries.  We didn't notice this, because although we have a
functional test for it, it requires the KVM accelerator and we don't
run the functional tests on an AArch64 host in CI.

Mark the machine as being OK to expose in qemu-system-arm and
qemu-system-aarch64, in the same way we do for the "none" machine
type. This fixes a check-functional failure on aarch64 host, where
it would otherwise fail with:
   qemu-system-aarch64: unsupported machine type: "x-remote"

Cc: [email protected]
Fixes: eb796c5551 ("hw/core: Allow ARM/Aarch64 binaries to use the 'none' machine")
Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-id: [email protected]
(cherry picked from commit 4e8ac6857f)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-19 23:41:47 +03:00
Peter Maydell 157ffbec17 meson.build: Add -fzero-init-padding-bits=all
The C standard doesn't always guarantee that struct and union padding
bits are zero initialized, even if the code initializes a struct.
For QEMU, this is potentially problematic, because we often have
structs that match data structures in guest memory, where we
initialize them and then bulk copy them into the guest.  If the
compiler didn't zero init the whole of the memory containing the
struct, we could potentially leak random data from the host into the
guest via the padding bytes.

We already use -ftrivial-auto-var-init=zero, which will zero out
padding in many of these cases, but -fzero-init-padding-bits=all
closes some gaps, for example cases where we initialize a
variable with a struct initializer, and cases involving unions.

Follow the Linux kernel in using both options. Compare kernel
commit dce4aab8441 ("kbuild: Use -fzero-init-padding-bits=all").

This option exists in gcc-15 and above; it's not supported
by clang, but clang documents that it guarantees zero init
of these cases always:
https://clang.llvm.org/docs/LanguageExtensions.html#union-and-aggregate-initialization-in-c
Older gcc which don't have the option behave as if it were set.

(These options are passed through the cc.get_supported_arguments()
filter, so we don't need to do anything extra to avoid passing it to
a compiler that doesn't recognize it.)

Cc: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Daniel P. Berrangé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Message-id: [email protected]
(cherry picked from commit a163fc1f86)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-19 23:41:47 +03:00
Peter Maydell c4009746a0 tests/qtest/iommu-smmuv3-test: Skip if no TCG GICv3 device present
On a KVM-only (--disable-tcg) build, the iommu-smmuv3 qtest fails:

qemu-system-aarch64: QTest does not support GICv3 emulation
Broken pipe
../../tests/qtest/libqtest.c:201: kill_qemu() tried to terminate QEMU process but encountered exit status 1 (expected 0)

This is because the test runs the virt board with the qtest
accelerator and gic-version=3.  In the virt board this selects the
TCG (emulated) GICv3, but in a --disable-tcg build we don't compile
that device, only the KVM GICv3 (which isn't usable with qtest).

Add a check to the test so we skip it if the arm-gicv3 device isn't
in the QEMU binary.

Cc: [email protected]
Fixes: d8d19c31b2 ("tests/qtest: Add SMMUv3 bare-metal test using iommu-testdev")
Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Fabiano Rosas <[email protected]>
Reviewed-by: Eric Auger <[email protected]>
Signed-off-by: Fabiano Rosas <[email protected]>
(cherry picked from commit 0129c62650)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-19 23:41:47 +03:00
Chad Jablonski 1feb9d6a77 ati-vga: fix ati_set_dirty address calculation
This fixes three bugs with the ati_set_dirty address calculation.

First, vbe_start_addr is a word offset. All other values in the
calculation are byte offsets. It must be converted to bytes.

Second, when setting the dirty region with memory_region_set_dirty
the vbe_start_addr is used to calculate the start of the dirty region.
This is a problem because the vbe_start_addr is the offset at which scan out
begins. This puts it in the visible screen coordinate system. The dirty
region however is in the virtual screen coordinate system. This can cause both
overmarking and missed updates. This is removed from the calculation.

Third, when the start address of a blit is outside of the bounds check
the entire blit is missed and not set to dirty. This happens even if the
blit does partially overlap with the visible screen. The fix here is to
find the intersection of the visible screen and the blit and mark only
that region as dirty.

This does not attempt to apply clipping to the blit. So there will be
overmarking in some cases.

Signed-off-by: Chad Jablonski <[email protected]>
[balaton: drop excess parenthesis, use offsets instead of pointers]
Reviewed-by: BALATON Zoltan <[email protected]>
Tested-by: BALATON Zoltan <[email protected]>
Signed-off-by: BALATON Zoltan <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
(cherry picked from commit 6197c11dd5)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-19 23:41:47 +03:00
Peter Maydell b0138ca68c hw/i2c/microbit_i2c: Don't index off end of twi_read_sequence[]
If the guest tries to read more bytes from our fake stub I2C device
than we have provided, we incorrectly read one byte beyond the end of
this array. Avoid this, and instead keep reporting the RXD register
as containing the last byte of the "data transfer".

Cc: [email protected]
Fixes: 9d68bf564e ("arm: Stub out NRF51 TWI magnetometer/accelerometer detection")
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3408
Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
(cherry picked from commit a824f3531a)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-19 23:41:47 +03:00
Cédric Le Goater 8a1c8e6ac0 aspeed/hace: Prevent total_req_len overflow
In accumulate mode, total_req_len is incremented with plen (hwaddr)
for each hash request. Repeated additions can overflow total_req_len
(uint32_t) and potentially bypass validation checks in has_padding().

Add a helper function to detect overflow before incrementing
total_req_len and reject the request if overflow would occur.

Reported-by: Katherine Leaver <[email protected]>
Cc: [email protected]
Fixes: 5cd7d8564a ("aspeed/hace: Support AST2600 HACE")
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
(cherry picked from commit c6aa2d0ac1)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-19 23:41:47 +03:00
Cédric Le Goater ed260dcebc aspeed/hace: Fix out-of-bounds read in has_padding()
The has_padding() function reads the last 8 bytes of a DMA buffer
without validating req_len. req_len is guest-controlled (via
R_HASH_SRC_LEN register or scatter-gather entries) and values less
than 8 cause integer underflow. This can result in an out-of-bounds
read of QEMU process memory.

Add a check to ensure req_len >= 8 before accessing the buffer.

Reported-by: Katherine Leaver <[email protected]>
Cc: [email protected]
Fixes: 5cd7d8564a ("aspeed/hace: Support AST2600 HACE")
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
(cherry picked from commit 534a52755b)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-19 23:41:47 +03:00
Kane Chen 2f35979b2e hw/misc/aspeed_sbc: Add bounds checking for OTP write operations
There is a mismatch between the Aspeed OTP model and the Aspeed SBC
model in how the guest-provided address is handled.
aspeed_sbc_otp_prog() passes a word-indexed address directly
to address_space_write() without converting it to a byte offset,
whereas aspeed_otp_write() expects a byte offset and applies an
additional shift (otp_addr << 2). This double-shift confusion means
that an out-of-range word address can lead to a write beyond the
allocated storage.

Fix this by adding bounds checking on the word offset before
converting to byte offset and passing to address_space_write().
This matches the existing bounds check in aspeed_sbc_otp_read().

Cc: Kane-Chen-AS <[email protected]>
Cc: [email protected]
Fixes: 1a00754ccf15 ("hw/misc: Add Aspeed Secure Boot Controller model")
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3436
Reported-by: Peter Maydell <[email protected]>
Signed-off-by: Kane-Chen-AS <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
[ clg: Kept otp_addr in event logged in aspeed_sbc_otp_prog() ]
Signed-off-by: Cédric Le Goater <[email protected]>
(cherry picked from commit ff36712da5)
(Mjt: actual Fixes: tag is this one)
Fixes: 9f58dd0a8c ("hw/misc/aspeed_sbc: Connect ASPEED OTP memory device to SBC")
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-19 23:41:47 +03:00
Peter Maydell 5252f197ac hw/display/cirrus_vga: Fix packed-24 color-expansion transparent copies
For the "color expansion" subtype of raster operations, the source
pixel format is a monochrome bitmap, and the destination can be any
of 8, 16, 24 or 32bpp.

For these pattern operations, the GR2F register includes a field
which specifies how much to skip at the start of each scanline.  In
the 8, 16 and 32 bit cases, this field is 3 bits and is a count of
pixels to skip.  We get this case right.  However, for the 24 bit
case, the field is 5 bits and is a count of destination bytes to
skip.

In commit ad81218e40 ("depth=24 write mask fix (Volker Ruppert)")
in 2005, we updated the code to (attempt to) handle the 5-bit mask
case.  However, we don't do the right thing when the 5-bit mask
indicates that we need to skip more than 8 bits of the input bitmap:
we will right-shift the 0x80 constant completely off the right hand
side, and will be off-by-one for all the source bitmap loads.

Fix this by calculating the whole number of input bytes we need to
skip and the residual number of bits.  In the 8/16/32bpp case the
bytes to skip is always zero.

Cc: [email protected]
Fixes: ad81218e40 ("depth=24 write mask fix (Volker Ruppert)")
Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Junjie Cao <[email protected]>
Tested-by: Junjie Cao <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
(cherry picked from commit 27d14251b9)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-19 23:41:47 +03:00
Peter Maydell 7041b86a3c hw/display/cirrus_vga: Fix packed-24 color-expansion transparent pattern fills
The Cirrus Logic VGA card has "pattern fill" blit modes where it
repeatedly copies an 8x8 source pattern to the display.  For the
"color expansion" subtype of these, the source pixel format is an 8x8
monochrome bitmap, and the destination can be any of 8, 16, 24 or
32bpp.  We implemented these wrong for the 24bpp case, in a way that
results in a complaint from the undefined-behavior sanitizer about a
shift by a negative value.

For these pattern fills, the GR2F register includes a field which
specifies how much to skip at the start of each scanline.  In the 8,
16 and 32 bit cases, this field is 3 bits and is a count of pixels to
skip.  We get this case right.  However, for the 24 bit case, the
field is 5 bits and is a count of destination bytes to skip.  We
tried to add support for 24-bits in commit ad81218e40 ("depth=24
write mask fix (Volker Ruppert)") in 2005.  However we got this
wrong, because when we need to skip, for example, 30 bytes in the
destination, this is 10 input pixels but the whole pattern is only 8
pixels wide, and we ended up with a negative bitpos for the first bit
to use in the pattern.

Fix the bug by masking srcskipleft in the 24-bit case so that it
correctly gives the first pixel to use in the pattern even if we skip
so many pixels that we have wrapped around to what would have been
the second copy of the pattern to the destination.

This patch was produced based on the information in the CL-GD5446
Technical Reference Manual, specifically sections 5.8 "GR2F: BLT
Destination Left-Side Clipping" and 9.4.8 "Pattern Fills".

Cc: [email protected]
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3377
Fixes: ad81218e40 ("depth=24 write mask fix (Volker Ruppert)")
Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Junjie Cao <[email protected]>
Tested-by: Junjie Cao <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
(cherry picked from commit aefeecb413)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-19 23:41:47 +03:00
Jeuk Kim 9eae322cfe hw/ufs: Zero reserved bytes in REPORT LUNS response header
ufs_emulate_report_luns() writes the 4-byte LUN list length into
outbuf[0..3] via stl_be_p() but leaves outbuf[4..7], the reserved
field, uninitialized. Those bytes are then DMA'd to guest memory,
leaking uninitialized QEMU stack data.

Fixes: 7708e29818 ("hw/ufs/lu: skip automatic zero-init of large array")
Cc: [email protected]
Signed-off-by: Jeuk Kim <[email protected]>
(cherry picked from commit 042dbcff83)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-19 23:41:47 +03:00
Jeuk Kim ee06b266e0 hw/ufs: Keep MCQ SQs alive while requests are outstanding
MCQ requests are allocated with their SQ, but can remain in flight on the
CQ list or in the SCSI layer after leaving the SQ free list.

Reject runtime SQ deletion while any request is still outstanding, and
use separate teardown helpers so device exit can still release MCQ
queues after child devices have been unrealized.

Fixes: 5c079578d2 ("hw/ufs: Add support MCQ of UFSHCI 4.0")
Cc: [email protected]
Signed-off-by: Jeuk Kim <[email protected]>
(cherry picked from commit 619c2da19a)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-19 23:41:47 +03:00
Jeuk Kim 5afb510a90 hw/ufs: Reject zero-depth MCQ queues
Reject SQATTR.SIZE and CQATTR.SIZE values that produce zero-entry MCQ
queues. Such queues can later trigger a divide-by-zero while advancing
queue pointers.

Fixes: 5c079578d2 ("hw/ufs: Add support MCQ of UFSHCI 4.0")
Cc: [email protected]
Signed-off-by: Jeuk Kim <[email protected]>
(cherry picked from commit 4a909c00b9)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-19 23:41:47 +03:00
Jeuk Kim 5708138f82 hw/ufs: Guard MCQ CQ accesses against missing queues
A guest can ring an MCQ CQ doorbell before the completion queue exists.
The CQ head write path then dereferences a NULL CQ through
ufs_mcq_cq_full().

Ignore CQ head updates for missing CQs, and make ufs_mcq_cq_full()
handle a missing CQ defensively.

Fixes: f78762a3cc ("hw/ufs: Fix mcq completion queue wraparound")
Reported-by: Rayhan Ramdhany Hanaputra <[email protected]>
Cc: [email protected]
Signed-off-by: Jeuk Kim <[email protected]>
(cherry picked from commit 283d921e77)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-19 23:41:47 +03:00
Jeuk Kim 1abdb1cf4a hw/ufs: Validate MCQ SQ references before use
A guest can program an out-of-range SQATTR.CQID value, or ring an
MCQ SQ doorbell before the submission queue exists.

Reject SQ creation when the referenced CQ is invalid, and ignore SQ
doorbells for queues that have not been created. This prevents a
guest-triggerable out-of-bounds read and NULL pointer dereference.

Fixes: 5c079578d2 ("hw/ufs: Add support MCQ of UFSHCI 4.0")
Reported-by: Rayhan Ramdhany Hanaputra <[email protected]>
Cc: [email protected]
Signed-off-by: Jeuk Kim <[email protected]>
(cherry picked from commit 332ea29787)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-19 23:41:47 +03:00
Fabiano Rosas f7a6489b50 tests/functional: Make socat wait longer in migration exec test
The migration_with_exec test is failing sporadically for all
architectures due to a race when the destination socat process takes
too long to start listening while the source process is already
issuing connect().

The race is inherent because the exec: migration spawns the
to-be-exec'ed command asynchronously and returns from the
migrate-incoming command. The localhost-only testcase is not
representative of the majority of migrations. In a real scenario
between two different hosts that race wouldn't happen.

Fix the testcase by configuring the source socat command to wait
indefinitely while trying to connect.

Reviewed-by: Thomas Huth <[email protected]>
Reviewed-by: Peter Xu <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
(cherry picked from commit b4ec2e8dae)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-19 23:41:47 +03:00
Gerd Hoffmann 6a15005290 hw/uefi: check auth.hdr_length minimum size
auth.hdr_length maximum is already checked (against buffer size).  The
header has some fixed fields which are included in the header length, so
there also is a minimum size which must be verified.  Add a check for
that.  Fixes possible integer underflow.

While being at it replace the magic number '24' with sizeof calculations
for better code documentation.

Fixes: CVE-2026-8341
Fixes: f1488fac05 ("hw/uefi: add var-service-auth.c")
Reported-by: Feifan Qian <[email protected]>
Reviewed-by: Daniel P. Berrangé <[email protected]>
Signed-off-by: Gerd Hoffmann <[email protected]>
Message-ID: <[email protected]>
(cherry picked from commit b33fd8ab1c)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-19 23:41:47 +03:00
Gerd Hoffmann 4139cf452f hw/uefi: avoid possibly unaligned variable_auth_2 struct field access
Copy data to stack-allocated struct before accessing it
to make sure it is properly aligned.

Fixes: CVE-2026-41440
Fixes: f1488fac05 ("hw/uefi: add var-service-auth.c")
Reported-by: Katherine Leaver <[email protected]>
Signed-off-by: Gerd Hoffmann <[email protected]>
Message-ID: <[email protected]>
(cherry picked from commit b4680c02b8)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-11 20:10:10 +03:00
Gerd Hoffmann 02b593d4dc hw/uefi: verify data size before accessing it in wrap_pkcs7
Fixes: CVE-2026-41439
Fixes: 3e33af2cb3 ("hw/uefi: add var-service-pkcs7.c")
Reported-by: Katherine Leaver <[email protected]>
Signed-off-by: Gerd Hoffmann <[email protected]>
Message-ID: <[email protected]>
(cherry picked from commit 22b7b222d8)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-11 20:10:10 +03:00
Gerd Hoffmann 2c4c582f3f hw/uefi: add name_size check to uefi_vars_mm_lock_variable()
Make sure the total variable_policy_entry size stays below
64k so the (16-bit) size field can not wrap.

Fixes: CVE-2026-41438
Fixes: db1ecfb473 ("hw/uefi: add var-service-vars.c")
Reported-by: Katherine Leaver <[email protected]>
Signed-off-by: Gerd Hoffmann <[email protected]>
Message-ID: <[email protected]>
(cherry picked from commit c45b460d16)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-11 20:10:10 +03:00
Gerd Hoffmann 5c358eabe6 hw/uefi: fix ucs2 string helper functions
The length passed in is in bytes not characters.  Rename the
parameters to make that clear.  Calculate the number of chars
if needed.  Fix length checks to use the number of chars not
bytes to avoid OOB reads.

Fixes: CVE-2026-41437
Fixes: 1ebc319c8c ("hw/uefi: add var-service-utils.c")
Reported-by: Katherine Leaver <[email protected]>
Signed-off-by: Gerd Hoffmann <[email protected]>
Message-ID: <[email protected]>
(cherry picked from commit 5247b3034c)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-11 20:10:10 +03:00
Gerd Hoffmann 023f87ab68 hw/uefi: verify pio_xfer_offset before calculating buffer checksum
Without that it is possible to do trigger OOB reads by first
advancing offset, then making the buffer smaller, finally
asking for a checksum.

Fixes: CVE-2026-41436
Fixes: 90ca4e03c2 ("hw/uefi: add var-service-core.c")
Reported-by: Katherine Leaver <[email protected]>
Signed-off-by: Gerd Hoffmann <[email protected]>
Message-ID: <[email protected]>
(cherry picked from commit 94d9a8b2c9)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-11 20:10:10 +03:00
Gerd Hoffmann 4c6e8882e4 hw/uefi: fix buffer overruns
The buffer size checks do not consider the mm_header size, simliar to
CVE-2026-5744.  Factor out the repeated size check to a small helper
function, fix the check, update all places to use the new helper.

Fixes: CVE-2026-41435
Fixes: db1ecfb473 ("hw/uefi: add var-service-vars.c")
Reported-by: Katherine Leaver <[email protected]>
Signed-off-by: Gerd Hoffmann <[email protected]>
Message-ID: <[email protected]>
(cherry picked from commit f252769a23)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-11 20:10:10 +03:00
Peter Maydell 9baeca885a hw/misc/bcm2835_rng: Specify valid memory access sizes
The BCM2835 RNG has 32-bit registers only; specify this in
the MemoryRegionOps so wrong-sized accesses are rejected rather
than getting to the assertions in the read and write functions,
and for clarity add the matching .impl constraints.

Cc: [email protected]
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3394
Fixes: 54a5ba13a9 ("target-arm: Implement BCM2835 hardware RNG")
Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-id: [email protected]
(cherry picked from commit 18b664c900)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-11 20:09:32 +03:00
Peter Maydell a7a21ed905 target/arm: Report IL=0 for Thumb 16-bit BKPT insn
The Thumb BKPT insn is 16-bit, and the ESR_ELx syndrome register
definition requires that we set the IL bit to 0 for this, and 1 for
the 32-bit A32 and A64 BKPT/BRK.

We used to do this correctly, but accidentally lost it in the
conversion to decodetree, because we converted the A32 BKPT first,
and then when we converted the T16 BKPT we forgot that trans_BKPT()
was unconditionally setting IL=1.

Pass the right value for syn_aa32_bkpt()'s is_16bit argument.

Cc: [email protected]
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3474
Fixes: 43f7e42c7d ("target/arm: Convert T16, Miscellaneous 16-bit instructions")
Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Alex Bennée <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-id: [email protected]
(cherry picked from commit f443b68763)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-11 20:09:13 +03:00
Philippe Mathieu-Daudé 1d45337ad5 target/microblaze: Fix endianness used to disassemble
MicroBlaze CPU model has a "little-endian" property, pointing to
the @endi internal field. Commit c36ec3a965 ("hw/microblaze:
Explicit CPU endianness") took care of having all MicroBlaze
boards with an explicit default endianness (similarly with
commit 91fc6d8101 for linux-user binaries), so later commit
415aae543e ("target/microblaze: Consider endianness while
translating code") could infer the endianness at runtime from
the @endi field, and not a compile time via the TARGET_BIG_ENDIAN
definition. Doing so, we forgot to propagate that runtime change
to the disassemble_info structure. Do it now to display the
opcodes in correct endianness order.

Cc: [email protected]
Fixes: 415aae543e ("target/microblaze: Consider endianness while translating code")
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Message-Id: <[email protected]>
(cherry picked from commit 41c417290d)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-06 22:20:29 +03:00
Peter Xu 7e96799ae4 migration: Fix low possibility downtime violation
When QEMU queried the estimated version of pending data and thinks it's
ready to converge, it'll send another accurate query to make sure of it.
It is needed to make sure we collect the latest reports and that equation
still holds true.

However we missed one tiny little difference here on "<" v.s. "<=" when
comparing pending_size (A) to threshold_size (B)..

QEMU src only re-query if A<B, but will kickoff switchover if A<=B.

I think it means it is possible to happen if A (as an estimate only so far)
accidentally equals to B, then re-query won't happen and switchover will
proceed without considering new dirtied data.

It turns out it was an accident in my commit 7aaa1fc072 when refactoring
the code around.  Fix this by using the same equation in both places.

Fixes: 7aaa1fc072 ("migration: Rewrite the migration complete detect logic")
Cc: [email protected]
Reviewed-by: Juraj Marcin <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Peter Xu <[email protected]>
(cherry picked from commit 455a6167f2)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-06 22:14:03 +03:00
Fabiano Rosas ac0379ca04 migration: Use QAPI_CLONE_MEMBERS in migrate_params_test_apply
Use QAPI_CLONE_MEMBERS instead of making an assignment. The QAPI
method makes the handling of the TLS strings more intuitive because it
clones them as well.

This also fixes a segfault when a NULL TLS option is accessed as part
of a validation check for another option (e.g. in the zero-copy +
multifd compression case). Details follow:

Currently, after copying s->parameters to the temporary
MigrationParameters object before migrate_params_check(), the
references in temporary object to the TLS options are dropped, either
because:

a) the user set a new option, in which case that's fine as
   s->parameters still holds the reference to the old memory or,

b) the user did not set a new option, in which case keeping the
   references in the temporary object would later cause them to be
   freed along with it, leading to double-free when s->parameters is
   also freed later on.

In this second case, it was overlooked that the TLS options can be
accessed already during migrate_params_check() as part of validation
of another option. Those pointers should not have been cleared.

Using QAPI_CLONE_MEMBERS fixes the issue because the temporary object
is not stealing a reference from s->parameters anymore.

Cc: qemu-stable <[email protected]>
Fixes: aed97f0563 ("migration: Normalize tls arguments")
Reported-by: Maciej S. Szmigiero <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Reviewed-by: Peter Xu <[email protected]>
Signed-off-by: Fabiano Rosas <[email protected]>
Tested-by: Maciej S. Szmigiero <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Peter Xu <[email protected]>
(cherry picked from commit f77a7cec9f)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-06 22:13:20 +03:00
liugan1 09704f9ad0 hw/intc/arm_gicv3: Fix NS write to ICC_AP1Rn_EL1 when prebits < 7
The existing code uses a blanket `regno < 2` check to make
ICC_AP1R0_EL1 and ICC_AP1R1_EL1 writes from Non-secure code WI
(Write Ignore) when EL3 is present. This is intended to prevent
NS code from claiming active interrupts in the Secure priority
range, which could block Secure interrupt delivery.

However, that check assumes prebits=7 (4 APR registers), where the
NS priority range (128..255) maps entirely to AP1R2/AP1R3. Since
commit 39f29e5993 ("hw/intc/arm_gicv3: Use correct number of
priority bits for the CPU", first in 7.1), all QEMU AArch64 CPUs
are initialised with gic_pribits=5 (one APR register), so NS
priorities map to AP1R0 bits [16:31]. Blanket WI of the entire
AP1R0 register prevents NS code from clearing its own NS active
priority bits. Machines using hw_compat_7_0 (e.g. virt-7.0) still
force pribits=8 via force-8-bit-prio and are therefore unaffected.

A concrete consequence observed in virtualisation scenarios: when
a guest VM acknowledges an SPI interrupt but does not perform EOI,
is force-killed and restarted, the new guest's attempt to clear
the residual active state by writing ICC_AP1R0_EL1=0 is silently
ignored. The running priority (RPR) remains stuck at the old
interrupt's priority, preventing all equal-or-lower priority
interrupts (including timer interrupts) from being delivered, and
hanging the guest.

Fix this by computing the exact Secure/NS boundary within the APR
bank based on prebits. For registers entirely in the Secure range,
keep the WI behaviour. For the register that straddles the
boundary, preserve only the Secure bits while allowing NS bits to
be modified. For registers entirely in the NS range, allow full
write access.

The new logic produces identical behaviour to the old code when
prebits=7, preserving existing behaviour for machines that use
force-8-bit-prio.

Fixes: 39f29e5993 ("hw/intc/arm_gicv3: Use correct number of priority bits for the CPU")
Cc: [email protected]
Signed-off-by: liugan1 <[email protected]>
Message-id: [email protected]
Reviewed-by: Peter Maydell <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
(cherry picked from commit f35f0f1ca1)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-05 21:52:25 +03:00
宋文武 f6ea8ca7ff hw/net/allwinner-sun8i-emac: Flush queued packets when rx is enabled
The RX_CTL_0 register includes the RX_EN receive-enable bit,
which allwinner_sun8i_emac_can_receive() checks. That means that
if the guest sets it we need to call qemu_flush_queued_packets()
as we might now be able to handle them.

This fixes a bug where networking didn't work in u-boot on the
orangepi-pc machine.

Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3459
Signed-off-by: 宋文武 <[email protected]>
Message-id: [email protected]
Reviewed-by: Peter Maydell <[email protected]>
[PMM: expanded commit message, removed unneeded RX_EN test]
Signed-off-by: Peter Maydell <[email protected]>
(cherry picked from commit a7f27d6903)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-05 21:52:00 +03:00
Vivien LEGER d1b461131f 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 <[email protected]>
Reviewed-by: Bernhard Beschow <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
(cherry picked from commit 774e6f5c15)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-05 17:50:02 +03:00
kiki a1b948a640 hw/intc/xics: Add a check for an invalid server id
A malformed IVE value can result in an invalid server field being
passed to icp_irq(). The function assumes the server id is valid and
may access invalid state otherwise, potentially leading to a crash.

Fix this by validating the server id before using it and ignoring
invalid values.

Reported-by: Zexiang Zhang <[email protected]>
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3324
Signed-off-by: Zexiang Zhang <[email protected]>
Signed-off-by: Gautam Menghani <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Harsh Prateek Bora <[email protected]>
(cherry picked from commit 1aee8067fc)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-02 14:37:11 +03:00
Helge Deller ac0c2898d8 linux-user: Translate errno in IP_RECVERR and IPV6_RECVERR
Translate host error codes of IP_RECVERR and IPV6_RECVERR control messages to
target error codes before returning to the caller.
For example, this is important for architectures (e.g. hppa, alpha, sparc,
mips) on which the value of ECONNREFUSED is different to the value on a x86_64
host.

Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/602
Signed-off-by: Helge Deller <[email protected]>
(cherry picked from commit 9667bf3249)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-02 14:33:54 +03:00
Helge Deller 54ffa51e9e linux-user: Allow getsockopt() with NULL optval address
Some programs test availability of socket options by asking for the
value with an NULL optval address, which currenrly always trigger an
EFAULT in qemu.  Fix it by allowing a NULL address, in the same manner
as the Linux kernel on physical machines.

Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/2390
Signed-off-by: Helge Deller <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
(cherry picked from commit 08dc3e240f)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-02 14:33:54 +03:00
Helge Deller 855a3577eb linux-user: Flush errors by using exit() instead of _exit() in error path
Similiar to previous patch - ensure that we always flush I/O by using
exit() instead of _exit().

Reported by: Tobias Bergkvist <[email protected]>
Reviewed-by: Warner Losh <[email protected]>
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/2544
Signed-off-by: Helge Deller <[email protected]>
(cherry picked from commit 9fb681792d)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-02 14:33:18 +03:00
Helge Deller 95d1444532 linux-user: Add missing CDROM ioctls
Add the missing CDROM ioctls and bring them in same order as
documentation.

Signed-off-by: Helge Deller <[email protected]>
(cherry picked from commit dcb6e96257)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-02 14:33:18 +03:00
Alistair Francis 9623f7904d target/riscv: Use ELEN for Fractional LMUL check
The RISC-V spec states that

"""
For a given supported fractional LMUL setting, implementations
must support SEW settings between SEWMIN and LMUL * ELEN, inclusive.
"""

We were previously checking VLEN, instead of ELEN, so let's update to
check ELEN instead of VLEN for fractional scaling.

Cc: [email protected]
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3196
Signed-off-by: Alistair Francis <[email protected]>
Reviewed-by: Daniel Henrique Barboza <[email protected]>
Reviewed-by: LIU Zhiwei <[email protected]>
Reviewed-by: Chao Liu <[email protected]>
Reviewed-by: Max Chou <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
(cherry picked from commit 5dcc64828d)
(Mjt: context fixup)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-02 14:26:03 +03:00
Alistair Francis 936b32f639 target/riscv: Don't OR mip.SEIP when mvien is one
The RISC-V spec states that

"""
But when bit 9 of mvien is one, bit SEIP in mip is read-only and does
not include the value of bit 9 of mvip. Rather, the value of mip.SEIP
is simply the supervisor external interrupt signal from the hart’s
external interrupt controller (APLIC or IMSIC).
"""

As such let's mark the mip.SEIP in rmw_mip64().

Cc: [email protected]
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/2828
Signed-off-by: Alistair Francis <[email protected]>
Reviewed-by: Chao Liu <[email protected]>
Reviewed-by: Nutty Liu <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
(cherry picked from commit 175afdb0d1)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-02 14:26:03 +03:00
Alistair Francis cbe17d7158 target/riscv: Generate access fault if sc comparison fails
The RISC-V spec states:

"For the purposes of memory protection, a failed SC.W may be treated
like a store."

So if the comparison in sc.w fails we should still check for alignment
and do a probe access to check permissions.

Cc: [email protected]
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3323
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3136
Signed-off-by: Alistair Francis <[email protected]>
Reviewed-by: Daniel Henrique Barboza <[email protected]>
Reviewed-by: Chao Liu <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
(cherry picked from commit d107b74807)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-02 14:26:03 +03:00
Munkhbaatar Enkhbaatar 69051eae69 riscv_htif: reject invalid signature ranges (end <= begin)
Prevents huge allocations and crashes caused by malformed HTIF signature
addresses.

Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3205
Signed-off-by: Munkhbaatar Enkhbaatar <[email protected]>
Reviewed-by: Alistair Francis <[email protected]>
Message-ID: <[email protected]>
[ Squashed with following commit to fix build failures
    hw/char/riscv_htif: Fix format specifier for uint64_t

    Message-ID: <[email protected]>
    Signed-off-by: Chao Liu <[email protected]>
]
Tested-by: Tao Tang <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Chao Liu <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
(cherry picked from commit 14808578cc)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-02 14:26:03 +03:00
Sebastián Alba Vives 29e28b4845 hw/intc: fix heap OOB in ACLINT MTIMER multi-socket
The MMIO read/write handlers index timecmp[] with the absolute hartid
(hartid_base + offset) but the array is allocated with num_harts
elements. In multi-socket configurations with hartid_base > 0 this
causes heap OOB access in the QEMU process.

Fix by using the relative offset for array indexing.

Cc: [email protected]
Signed-off-by: Sebastián Alba Vives <[email protected]>
Reviewed-by: Alistair Francis <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
(cherry picked from commit d5b33fc180)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-02 14:26:03 +03:00
Sebastián Alba Vives 7c74dcaa74 target/riscv: fix stale ptshift and base on page walk restart
When the atomic compare-and-swap for updating A/D bits in the page
table entry fails due to a concurrent PTE modification by another
vCPU, get_physical_address() jumps to the 'restart' label to re-walk
the page table from the root.

However, neither 'ptshift' nor 'base' are re-initialized before the
restart. After the walk completes, ptshift has been decremented to
its final value and base has been overwritten with an inner PTE PPN.
On goto restart, the for loop resets i=0 but ptshift and base remain
stale, causing the restarted walk to compute incorrect PTE addresses.

In an SMP guest with MTTCG and Svadu active, this can result in
incorrect physical address mappings or guest crashes.

Fix by saving the root base address and re-initializing both ptshift
and base on each restart.

Fixes: 0c3e702aca ("RISC-V CPU Helpers")
Signed-off-by: Sebastián Alba Vives <[email protected]>
Reviewed-by: Alistair Francis <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
(cherry picked from commit b2e874bfec)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-02 14:26:03 +03:00
Yicong Yang 7f8e33765c hw/riscv/virt-acpi-build.c: Use kvm timer frequency when kvm enabled
The timer frequency is decided by the host(kvm) rather than a fixed
RISCV_ACLINT_DEFAULT_TIMEBASE_FREQ on kvm accelerated VM. So build
RCHT with KVM provided timer frequency if KVM is enabled, just like
how we build the timer node on DT based VM.

Fixes: ebfd392893 ("hw/riscv/virt: virt-acpi-build.c: Add RHCT Table")
Signed-off-by: Yicong Yang <[email protected]>
Reviewed-by: Andrew Jones <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
(cherry picked from commit 4cb2f91773)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-02 14:26:03 +03:00
Luc Michel 4d7eea2208 hw/core/register: add register_array_get_owner
Add the register_array_get_owner function to the register API. This
function can be used to retrieve the device owning the given
RegisterInfoArray.

This was previously done inline by some devices.
5c6367bc1c modified the way register
blocks are created and parented to the device. Since this is an
implementation detail of the register API, it makes sense to have a
function for this.

Use it in the Versal OSPI and Versal/ZynqMP eFuse models instead of
tinkering with the API internals.

Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3421
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3422
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3423
Signed-off-by: Luc Michel <[email protected]>
Tested-by: Thomas Huth <[email protected]>
Reviewed-by: Alistair Francis <[email protected]>
Fixes: 5c6367bc1c ("hw/core/register: add the REGISTER_ARRAY type")
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
(cherry picked from commit 57abf6b1d5)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-02 14:26:03 +03:00
Daniel P. Berrangé ad0a9ac68f util: fix use of pthread_get_name_np on OpenBSD
The pthread_get_name_np function is present on FreeBSD and OpenBSD
and has 'void' return not 'int'. We didn't notice this build problem
on FreeBSD since it also has pthread_getname_np which does return
int like Linux and we use the latter preferentially.

Fixes: 215235d365
Closes: https://gitlab.com/qemu-project/qemu/-/work_items/3399
Signed-off-by: Daniel P. Berrangé <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
(cherry picked from commit b8c2426157)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-02 14:26:03 +03:00
Helge Deller 152148d99f linux-user: Flush errors by using exit() instead of _exit() in error path
Qemu user mode does not properly flushes error messages related to bad
arguments when exiting (at least when the output is piped to a file
instead of running on a terminal).
Ensure that we always flush by using exit() instead of _exit().

Reported by: Tobias Bergkvist
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/2544
Signed-off-by: Helge Deller <[email protected]>
(cherry picked from commit 9e7734ead1)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-02 14:26:03 +03:00
Helge Deller 55cd56c340 linux-user: Use abi_int for imr_ifindex in ip_mreqn struct
Peter Hartley noticed, that in the qemu code the imr_ifindex member of
struct target_ip_mreq needs to be of type "int" instead of "long", which
is what the Linux kernel uses on all architectures.

Adjust the type accordingly, and add a QEMU_BUILD_BUG_ON() checker to
prevent such issues in the future.

This change should fix multicast issues when using hosts and guests with
different endianess or bit size.

Reported-by: Peter Hartley <[email protected]>
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/2553
Signed-off-by: Helge Deller <[email protected]>
(cherry picked from commit e2af3eadc0)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-02 14:26:03 +03:00
Helge Deller fb45f3fa70 linux-user: Fix CLONE_PARENT_SETTID when using fork-like clone
The CLONE_PARENT_SETTID option requires the implementation to store the
child thread ID at the location pointed to by parent_tid in the parent's
memory.

Fix our implementation and move the code from the client side (where
fork returned 0), to the parent side and store the return value from the
fork call (which is the client TID) in the parent_tid pointer.

Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3340
Signed-off-by: Helge Deller <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
(cherry picked from commit b03a6ac6fa)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-02 14:26:03 +03:00
Helge Deller 46c448b734 linux-user: Add getsockopt() for SO_RCVTIMEO_NEW and SO_SNDTIMEO_NEW
Add handlers for both sockopts which use 64-bit time_t from userspace.

Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/885
Signed-off-by: Helge Deller <[email protected]>
(cherry picked from commit 07c7decaa5)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-02 14:26:03 +03:00
Helge Deller 65632719e0 linux-user: Add setsockopt() for SO_RCVTIMEO_NEW and SO_SNDTIMEO_NEW
Add handlers for both sockopts which use 64-bit time_t from userspace.

Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/885
Signed-off-by: Helge Deller <[email protected]>
(cherry picked from commit edb4588309)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-02 14:26:03 +03:00
Helge Deller f814bacf30 linux-user: Define SO_TIMESTAMP*_NEW and SO_RCVTIMEIO_NEW
Define the entries which always use the 64-bit timestamps.

Signed-off-by: Helge Deller <[email protected]>
(cherry picked from commit 8b60ed8354)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-02 14:26:03 +03:00
James Hilliard c313116493 linux-user/mips: sync k0 TLS for EF_MIPS_MACH_OCTEON userlands
Cavium Octeon userspace is not following a generic MIPS Linux TLS
ABI rule here. Older Octeon glibc uses the k0 register as the fast
thread pointer, while newer Octeon2 and Octeon3 glibc variants use
the normal rdhwr $29 path.

linux-user already updates CP0_UserLocal for cpu_set_tls() and
TARGET_NR_set_thread_area, but it does not keep gpr[26]
synchronized. That leaves EF_MIPS_MACH_OCTEON userlands able to
complete set_thread_area() and still reach pthread startup or
pthread_self() with a stale k0 value.

Use the existing MIPS ELF machine flags from linux-user/elfload.c and
mirror CP0_UserLocal into gpr[26] only for EF_MIPS_MACH_OCTEON.

Signed-off-by: James Hilliard <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Helge Deller <[email protected]>
(cherry picked from commit 4c681ba3b8)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-02 14:26:03 +03:00
Alistair Francis ee343bd577 linux-user/strace: Use pointer type for read and write values
The stack pointer is being truncated as 32-bits for qemu-riscv64, so
let's use %p to print the syscall pointer argument.

Cc: [email protected]
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3238
Signed-off-by: Alistair Francis <[email protected]>
Reviewed-by: Nutty Liu <[email protected]>
Signed-off-by: Helge Deller <[email protected]>
(cherry picked from commit 1730e6f33f)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-02 14:26:03 +03:00
Richard Henderson 8bbc215d36 linux-user/arm/nwfpe: Use thread-local storage for qemufpa
Fix the thread safety of the emulation by not storing a
pointer in global storage.

Signed-off-by: Richard Henderson <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Helge Deller <[email protected]>
(cherry picked from commit 784f1dde90)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-02 14:26:03 +03:00
Richard Henderson 8094e5266f linux-user/arm/nwfpe: Replace user_registers with current_cpu
Use the thread-local variable current_cpu instead of
a global variable to access the general registers.
This also means we don't need to pass env to EmulateAll.

Signed-off-by: Richard Henderson <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Helge Deller <[email protected]>
(cherry picked from commit c8ea175900)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-02 14:26:03 +03:00
Gyorgy Tamasi e3c738c933 linux-user: Don't define target_stat64 struct for loongarch64
The kernel defines 'struct stat64' only if
__BITS_PER_LONG != 64 || defined(__ARCH_WANT_STAT64).
loongarch64 doesn't set __ARCH_WANT_STAT64, and it isn't 32-bit,
so it won't get this struct.

QEMU incorrectly does define a target_stat64 struct. However this
isn't causing any guest-visible problems, because defining the
target_stat64 struct and TARGET_HAS_STRUCT_STAT64 affects these
syscalls:
 TARGET_NR_stat64
 TARGET_NR_lstat64
 TARGET_NR_fstat64
 TARGET_NR_fstatat64
 TARGET_NR_newfstatat

For loongarch64 the only one of those we provide is newfstatat,
and that is actually a separate QEMU bug, because the kernel does
not provide that syscall for this architecture. No real guest
code will be using a syscall that doesn't exist in the ABI.

(Some of these syscalls are present in the loongarch64 "ABI1.0",
but that ABI was never accepted in the upstream kernel, and
QEMU does not model that ABI, only the "ABI2.0".)

Stop defining TARGET_HAS_STRUCT_STAT64 anyway, for consistency
with the kernel and to avoid confusion.

Note:
Commit message suggested by Peter Maydell <[email protected]>

Signed-off-by: Gyorgy Tamasi <[email protected]>
Tested-by: Gyorgy Tamasi <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Signed-off-by: Helge Deller <[email protected]>
(cherry picked from commit 93484c768f)
Signed-off-by: Michael Tokarev <[email protected]>
2026-05-02 14:26:03 +03:00
Yixin Wei 5666ae83e4 linux-user: fix off-by-one in host_to_target_for_each_rtattr()
host_to_target_for_each_rtattr() uses "len > sizeof(struct rtattr)"
as its loop condition. When the last rtattr in a netlink message has
exactly sizeof(struct rtattr) (4) bytes remaining, the loop exits
without byte-swapping its rta_len and rta_type. A big-endian guest
then reads rta_len in the wrong byte order and fails validation.

The companion function target_to_host_for_each_rtattr() correctly
uses ">=" (added in commit fa2229dbf8). The kernel's RTA_OK macro
also uses ">=". Fix the host_to_target direction to match.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2485
Signed-off-by: Yixin Wei <[email protected]>
Fixes: 6c5b5645ae ("linux-user: add rtnetlink(7) support")
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Helge Deller <[email protected]>
Cc: [email protected]
(cherry picked from commit 029f10e852)
Signed-off-by: Michael Tokarev <[email protected]>
2026-04-30 19:23:47 +03:00
Matt Turner 6a1a12f2fb linux-user/ppc: Fix ppc64 rt_sigframe stack offset
The kernel's 64-bit signal delivery (signal_64.c) uses:

    newsp = frame - __SIGNAL_FRAMESIZE

while the 32-bit path (signal_32.c) uses:

    newsp = frame - (__SIGNAL_FRAMESIZE + 16)

The extra 16 bytes in the 32-bit case is to place siginfo and ucontext
at the same offsets as older kernels (see the comment in signal_32.c).
The 64-bit rt_sigframe starts with ucontext directly and does not need
this adjustment.

QEMU's setup_rt_frame() unconditionally used (SIGNAL_FRAMESIZE + 16)
for both 32-bit and 64-bit, placing the handler's SP 16 bytes too low
on ppc64. Signal delivery and return still worked because do_rt_sigreturn
had the matching wrong offset, but the vDSO DWARF unwind info encodes
the correct kernel offset. This caused any DWARF unwinder (libunwind,
libgcc, etc.) to compute a CFA that is 16 bytes off, reading garbage
register values from the signal frame.

Define RT_SIGFRAME_ADJUST (0 on ppc64, 16 on ppc32) and use it in both
setup_rt_frame and do_rt_sigreturn to match the kernel.

This was verified by A/B testing with libunwind's test suite:

  ppc64le: Gtest-bt, Ltest-bt, Gtest-concurrent, Ltest-concurrent,
           and Ltest-sig-context all change from FAIL to PASS.
  ppc64be: Gtest-bt, Ltest-bt, and Ltest-sig-context all change
           from FAIL to PASS.

Signed-off-by: Matt Turner <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Signed-off-by: Helge Deller <[email protected]>
Cc: [email protected]
(cherry picked from commit 654dce6c52)
Signed-off-by: Michael Tokarev <[email protected]>
2026-04-30 19:23:02 +03:00
Thomas Huth 18577776c8 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 <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
(cherry picked from commit 3ab47a47d7)
Signed-off-by: Michael Tokarev <[email protected]>
2026-04-28 14:16:19 +03:00
Thomas Huth 4bf9eb3f09 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 <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
(cherry picked from commit c0306d2b8f)
Signed-off-by: Michael Tokarev <[email protected]>
2026-04-28 14:16:19 +03:00
Junjie Cao 08fd68d58f 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: [email protected]
Fixes: 2f1fbe6ee9 ("ati-vga: Make sure hardware cursor data is within vram")
Signed-off-by: Junjie Cao <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: BALATON Zoltan <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
(cherry picked from commit 0990cc8b28)
Signed-off-by: Michael Tokarev <[email protected]>
2026-04-28 14:16:19 +03:00
Vladimir Sementsov-Ogievskiy 5f9eb150ab migration: vmstate_save_state_v: fix double error_setg
We may call error_setg twice on same errp if inner
vmstate_save_state_v() or vmstate_save_state() call fails. Next we will
crash on assertion in error_setv().

Fixes: 848a050342 "migration: Update error description outside migration.c"
Signed-off-by: Vladimir Sementsov-Ogievskiy <[email protected]>
Reviewed-by: Fabiano Rosas <[email protected]>
Reviewed-by: Peter Xu <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
(cherry picked from commit d41ce10d0f)
Signed-off-by: Michael Tokarev <[email protected]>
2026-04-26 05:57:45 +03:00
Alex Bennée 0ed63c35e8 hw/display: don't accidentally autofree existing virgl resources
While sanity checking a create blob operation the use of the auto
freed res variable could lead to inadvertently freeing an existing
blob.

Avoid this by in-lining the virtio_gpu_virgl_find_resource() check as
the value is not needed anyway.

While at it add a comment to the end and use g_steal_pointer to make
it clearer the object lifetime exceeds the function bounds if we pass
all the checks.

Fixes: CVE-2026-6502
Fixes: 7c092f17cc (virtio-gpu: Handle resource blob commands)
Message-ID: [email protected]
Reviewed-by: Manos Pitsidianakis <[email protected]>
Cc: [email protected]
Message-ID: <[email protected]>
Signed-off-by: Alex Bennée <[email protected]>
Reviewed-by: Dmitry Osipenko <[email protected]>
(cherry picked from commit 30fad722ce)
Signed-off-by: Michael Tokarev <[email protected]>
2026-04-25 00:39:54 +03:00
Anthony Roberts 674221887f ui/sdl2: Fix assumption of EGL presence at runtime
The original commit had a section of code which worked on the assumption
that if OpenGL was enabled at build, it was present on the end user machine,
and calls could be made to it. This is not always the case (such as Windows
on Arm devices).

This line should have also included a runtime check.

This commit moves the relevant line to inside a runtime check for OpenGL.

Fixes: 52053b7e0a ("ui/sdl2: Implement dpy dmabuf functions")
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3347
Cc: [email protected]
Signed-off-by: Anthony Roberts <[email protected]>
Reviewed-by: Alex Bennée <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alex Bennée <[email protected]>
(cherry picked from commit 7077c83f71)
Signed-off-by: Michael Tokarev <[email protected]>
2026-04-25 00:38:29 +03:00
Stepan Popov e08ba49327 meson: add missing semicolon in pthread_condattr_setclock test
The test code was missing a semicolon after the pthread_condattr_t
variable declaration.

Signed-off-by: Stepan Popov <[email protected]>
Reviewed-by: Alex Bennée <[email protected]>
Fixes: 657ac98b58 ("thread-posix: use monotonic clock for QemuCond and QemuSemaphore", 2022-02-22)
Reviewed-by: Marc-André Lureau <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
(cherry picked from commit 79bc177186)
Signed-off-by: Michael Tokarev <[email protected]>
2026-04-25 00:36:56 +03:00
Paolo Bonzini 44cf0611b0 target/i386/tcg: fix decoding of MOVBE and CRC32 in 16-bit mode
Table A-4 of the SDM shows

                    F0                     F1
--------------------------------------------------------
     NP           MOVBE Gy,My           MOVBE My,Gy
     66           MOVBE Gw,Mw           MOVBW Mw,Gw
     F2           CRC32 Gd,Eb           CRC32 Gd,Ey
  66+F2           CRC32 Gd,Eb           CRC32 Gd,Ew

However, this is incorrect.  Both MOVBE and (for 0xF1) CRC32
take Gv, Ev or Mv operands.  In 16-bit mode therefore the
operand is of 16-bit size without prefix and 32-bit mode
with 0x66 (the data size override).

For example, with NASM you get:

                                 bits 16
   67 0F 38 F0 02                movbe ax, [edx]
   66 67 0F 38 F0 02             movbe eax, [edx]

   67 F2 0F 38 F1 02             crc32 ax, word [edx]
   66 67 F2 0F 38 F1 02          crc32 eax, dword [edx]

versus

                                 bits 32
   66 0F 38 F0 02                movbe ax, [edx]
   0F 38 F0 02                   movbe eax, [edx]

   66 F2 0F 38 F1 02             crc32 eax, word [edx]
   F2 0F 38 F1 02                crc32 eax, dword [edx]

The instruction is listed correctly in the APX documentation
as "SCALABLE" (which means it has v-size operands).

Cc: [email protected]
Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
(cherry picked from commit 76ad26dd17)
Signed-off-by: Michael Tokarev <[email protected]>
2026-04-25 00:36:13 +03:00
Magnus Kulke 80e8d7f683 target/i386/mshv: Fix segment regression in MMIO emu
When the segmentation code has been reworked, there is now an
unconditional call to emul_ops->read_segment_descriptor(). The MSHV impl
was delegating this to x86_read_segement_descriptor(), which read from
the GDT in guest memory. This fails for selector.idx == 0 and when no
GDT is set up (which is the case in real mode).

In the fix we change the MSHV impl to fill segment descriptor from
SegmentCache, that was populated from the hypervisor by mshv_load_regs()
before instruction emulation.

Fixes: 09442d98ab (target/i386: emulate: segmentation rework)

Signed-off-by: Magnus Kulke <[email protected]>
Reviewed-by: Mohamed Mediouni <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
(cherry picked from commit 7d6231dfb5)
Signed-off-by: Michael Tokarev <[email protected]>
2026-04-25 00:35:39 +03:00
rickgcn 03de9b1154 hw: i386: vapic: restore IRQ polling for non-kernel irqchip backends
69dfc078 extended vAPIC handling for WHPX with user-mode irqchip, but it
also changed vapic_write() case 4 in a way that excludes TCG from
apic_poll_irq().

Before that change, IRQ polling happened whenever no in-kernel irqchip
was active. After the change, it only happened for KVM or WHPX with a
user-mode irqchip. Under TCG, both kvm_enabled() and whpx_enabled() are
false, so the poll never happens.

This regresses 32-bit Windows XP guests on a Windows host with
-machine pc-i440fx-10.0,accel=tcg, causing a STOP 0x0000000A during boot.

Fix it by making the decision depend on whether KVM or WHPX is using an
in-kernel irqchip, instead of whether either accelerator is enabled.

Fixes: 69dfc078a6 ("hw: i386: vapic: enable on WHPX with user-mode irqchip")

Signed-off-by: rickgcn <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Cc: [email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
(cherry picked from commit c906c23370)
Signed-off-by: Michael Tokarev <[email protected]>
2026-04-25 00:32:47 +03:00
Simon Scherer 4052595a93 target/i386: fix missing PF_INSTR in SIGSEGV context
When running linux-user emulation, the SIGSEGV handler does not
correctly set the 4th bit (PF_INSTR) in the error_code variable of
the context argument (context->uc_mcontext.gregs[REG_ERR]).

Because this bit is never set, guest applications cannot distinguish
if a fault was due to missing executable permissions. This patch
ensures that when a page fault occurs during an instruction fetch,
the PF_INSTR flag is properly populated in the signal context.

Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3384
Signed-off-by: Simon Scherer <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Cc: [email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
(cherry picked from commit 3eae91a8b9)
Signed-off-by: Michael Tokarev <[email protected]>
2026-04-25 00:32:07 +03:00
Marc-André Lureau 0f82275c22 target/i386: fix strList leak in x86_cpu_get_unavailable_features
The result list built by x86_cpu_list_feature_names() was never freed
after being visited, causing a memory leak detected by ASan.
(the getter visitor is VISITOR_OUTPUT kind and doesn't own data)

Fixes: 506174bf82 ("i386: "unavailable-features" QOM property")
Signed-off-by: Marc-André Lureau <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Cc: [email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
(cherry picked from commit 87e1226e6f)
Signed-off-by: Michael Tokarev <[email protected]>
2026-04-25 00:31:42 +03:00
Pierrick Bouvier 7d78c44577 target/arm/tcg/translate.c: remove MO_TE usage
dc->be_data is already set just above in the same function:
```
    dc->be_data = EX_TBFLAG_ANY(tb_flags, BE_DATA) ? MO_BE : MO_LE;
```

Cc: [email protected]
Fixes: a729a46b05 ("target/arm: Add wrapper macros for accessing tbflags")
Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Pierrick Bouvier <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
(cherry picked from commit 027ad866bd)
Signed-off-by: Michael Tokarev <[email protected]>
2026-04-25 00:30:22 +03:00
Marc-André Lureau a7bd89ffdf ui/console-vc: fix off-by-one in CSI J 2 (clear entire screen)
The loop condition used `y <= s->height` instead of `y < s->height`,
causing vc_clear_xy() to be called with y == s->height. This clears
a row in the scrollback buffer beyond the visible screen.

Reviewed-by: Daniel P. Berrangé <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Marc-André Lureau <[email protected]>
(cherry picked from commit 181fdf8a7e)
Signed-off-by: Michael Tokarev <[email protected]>
2026-04-23 07:42:56 +03:00
GuoHan Zhao 67e82da858 ui/spice-app: detect runtime directory creation failures
spice_app_display_early_init() creates the per-VM runtime directory
with g_mkdir_with_parents() before setting up the Spice socket. The
code checks for "< -1", but g_mkdir_with_parents() returns -1 on
failure, so the error path is never taken.

This lets spice-app continue after a directory creation failure and
defers the problem to later setup steps.

Check for "< 0" instead so the failure is reported immediately and
spice-app exits before using an invalid runtime directory.

Fixes: d8aec9d9f1 ("display: add -display spice-app launching a Spice client")
Signed-off-by: GuoHan Zhao <[email protected]>
Reviewed-by: Marc-André Lureau <[email protected]>
Message-ID: <[email protected]>
(cherry picked from commit 52cf667ed2)
Signed-off-by: Michael Tokarev <[email protected]>
2026-04-23 07:38:28 +03:00
Werner de Carne 3e0ac2885e serial COM: windows serial COM PollingFunc don't sleep
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1802
Signed-off-by: Werner de Carne <[email protected]>
[ Marc-André - indentation fixes ]
Signed-off-by: Marc-André Lureau <[email protected]>
Message-ID: <[email protected]>
(cherry picked from commit 7437b3eab6)
Signed-off-by: Michael Tokarev <[email protected]>
2026-04-23 07:38:01 +03:00
Peter Maydell 98b060da3a Update version for v11.0.0 release
Signed-off-by: Peter Maydell <[email protected]>
2026-04-21 16:28:47 +01:00
Peter Maydell da6c4fe60f Update version for v11.0.0-rc4 release
Signed-off-by: Peter Maydell <[email protected]>
2026-04-14 20:22:00 +01:00
Chad Jablonski 985062e231 migration: Remove unnecessary zlib include from qemu-file.h
Commit 70eb5fde05 removed zlib from the libmigration dependencies but
missed removing the zlib include from the header file. zlib doesn't
appear to be used anywhere in qemu-file.h. This is fine in most
environments where zlib is nearly always in the default include path but
breaks the build when it isn't (NixOS for example).

Fixes: 70eb5fde05 ("migration: remove unnecessary zlib dependency")
Signed-off-by: Chad Jablonski <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
2026-04-14 15:57:46 +01:00
Peter Maydell 750c2d53ee docs: Deprecate Arm OABI and NWFPE support
Linux for 32-bit Arm has had two major ABIs: the original OABI and
the more modern EABI.  OABI support was marked as obsolete in GCC 4.7
and dropped in GCC 4.8.  In the Linux kernel, compatibility handling
for OABI (OABI_COMPAT) is not generally enabled by default and is not
compatible with building a Thumb2 kernel.  Distros dropped OABI
support fifteen years or more ago.

NWFPE floating-point emulation handles the ancient FPA11 coprocessor,
which is only needed/supported with OABI.  Our implementation is old,
untested and not thread-safe.

Mark OABI and NWFPE support as deprecated so we can remove it in a
future release.  Our main motivation here is to be able to drop the
2500+ lines of NWFPE emulation code.

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Mohamed Mediouni <[email protected]>
Reviewed-by: Alex Bennée <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-id: [email protected]
2026-04-14 15:52:48 +01:00
Bernhard Beschow f1b1db98cc util/cutils: Fix heap corruption under Windows
Under Windows, QEMU would only sporadically start successfully. In the
G_OS_WIN32 case, get_relocated_path() first determines a cursor
to the end of the "result" string and then increases its size with
g_string_set_size(). Since g_string_set_size() may reallocate, the
cursor may become dangling. Windows may detect this and crash the QEMU
process with the following message:

  HEAP: Free Heap block 000000000499B640 modified at 000000000499B684 after it was freed

Furthermore, QEMU crashes spontaneously, even long after the guest has
booted. For example, it presumably crashes due to the guest setting a
new cursor icon which may be a result of the heap corruption.

Fix this by determining the cursor on the resized string.

Fixes: cf60ccc330 ("cutils: Introduce bundle mechanism")
Cc: [email protected]
Signed-off-by: Bernhard Beschow <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-04-14 15:52:21 +01:00
Ani Sinha afa63fc0e3 accel/kvm: return early from kvm_irqchip_create if kvm does not support irqchip
During refactoring of kvm_irqchip_create(), the refactored code was returning
early from do_kvm_irqchip_create() function if the required essential
capabilities were not present in KVM. This was not translating to an early
return from kvm_irqchip_create() as was the case before refactoring.
This is because, do_kvm_irqchip_create() did not have a means to notify the
caller of the lack of required kvm capabilities. Fix this by making
do_notify_irqchip_create() return EOPNOTSUPP error when  capabilities
are absent and then the caller can check the return code and return early.

Due to this regression during refactoring, all KVM guests on ppc64le hang
immediately during startup and this completely breaks all functionality on
that platform.

Fixes: 98884e0cc1 ("accel/kvm: add changes required to support KVM VM file descriptor change")
Message-ID: <[email protected]>
Reported-by: Misbah Anjum N <[email protected]>
Reported-by: Gautam Menghani <[email protected]>
Tested-by: Misbah Anjum N <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Signed-off-by: Ani Sinha <[email protected]>
Message-id: [email protected]
Suggested-by: Fabiano Rosas <[email protected]>
Suggested-by: Harsh Prateek Bora <[email protected]>
Tested-by: Misbah Anjum N <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Signed-off-by: Ani Sinha <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
2026-04-14 15:51:57 +01:00
Peter Maydell 45cad8beca Merge tag 'block-pull-request' of https://gitlab.com/stefanha/qemu into staging
Pull request

virtio-blk zone report CVE DoS fix

# -----BEGIN PGP SIGNATURE-----
#
# iQEzBAABCgAdFiEEhpWov9P5fNqsNXdanKSrs4Grc8gFAmnc72sACgkQnKSrs4Gr
# c8h2CQf/TzMkfPv4bV0G3Z7JMOCllVejmlWUJpSh7lQdboNiIrWbtiCaC5n7CfTF
# +A8e8g4FYlTHhRj8nWMTd4vs6lmKEHTS7dbBlwB/ZkmAzHGtGizIXK7X7aAz6LZT
# KSRJYIm9Qj+c8kGZjPY/XmA6Y3uFS0jAZRd/1fFSshg0NyNxPIipj3YAv2P8mQf8
# y+v32O2WTezQQfTTBZR2moYmo3wBeSXum6NHOGq4DVswvaSQDJ1Eooc30xFswkIM
# vg+RqzUFCABsNj6vED61j1mE01vgFAvJKfCXNY1RFYkyeM2uzwlByktocbMTbs+b
# BJweRe9fO01GcQAunWT5Y6VmrJib7A==
# =m/MG
# -----END PGP SIGNATURE-----
# gpg: Signature made Mon Apr 13 14:28:11 2026 BST
# gpg:                using RSA key 8695A8BFD3F97CDAAC35775A9CA4ABB381AB73C8
# gpg: Good signature from "Stefan Hajnoczi <[email protected]>" [full]
# gpg:                 aka "Stefan Hajnoczi <[email protected]>" [full]
# Primary key fingerprint: 8695 A8BF D3F9 7CDA AC35  775A 9CA4 ABB3 81AB 73C8

* tag 'block-pull-request' of https://gitlab.com/stefanha/qemu:
  virtio-blk: fix zone report buffer out-of-memory (CVE-2026-5761)

Signed-off-by: Peter Maydell <[email protected]>
2026-04-13 15:13:01 +01:00
Stefan Hajnoczi 4913ae36f9 virtio-blk: fix zone report buffer out-of-memory (CVE-2026-5761)
An internal buffer is used when processing VIRTIO_BLK_T_ZONE_REPORT
requests. The buffer's size is controlled by the guest. A large value
can result in g_malloc() failure and the QEMU process aborts, resulting
in a Denial of Service (DoS) (most likely in cases where an untrusted
guest application or a nested guest with virtio-blk passthrough is able
to abort QEMU).

Modify the zone report implementation to work incrementally with a
bounded buffer size.

This is purely a QEMU implementation issue and no VIRTIO spec changes
are needed.

Mingyuan Luo found this bug and provided a reproducer which I haven't
put into tests/qtest/ because it requires a zoned storage device (e.g.
root and modprobe null_blk):

1) Prepare a zoned nullblk backend (/dev/nullb0):

sudo modprobe -r null_blk || true
sudo modprobe null_blk nr_devices=1 zoned=1
sudo chmod 0666 /dev/nullb0
cat /sys/block/nullb0/queue/zoned

2) Create qtest input:

cat >/tmp/vblk-zone-report-oom.qtest <<'EOF'
outl 0xcf8 0x80002004
outw 0xcfc 0x0007
outl 0xcf8 0x80002010
outl 0xcfc 0x0000c001
outb 0xc012 0x00
outb 0xc012 0x01
outb 0xc012 0x03
outl 0xc004 0x00000000
outw 0xc00e 0x0000
outl 0xc008 0x00000100
outb 0xc012 0x07
writel 0x00020000 0x00000010
writel 0x00020004 0x00000000
writeq 0x00020008 0x0000000000000000
writeq 0x00100000 0x0000000000020000
writel 0x00100008 0x00000010
writew 0x0010000c 0x0001
writew 0x0010000e 0x0001
EOF

for i in $(seq 1 1022); do
d=$((0x00100000 + i * 16))
n=$((i + 1))
printf 'writeq 0x%08x 0x0000000000200000\n' "$d" >> /tmp/vblk-zone-report-oom.qtest
printf 'writel 0x%08x 0x1fe00000\n' $((d + 8)) >> /tmp/vblk-zone-report-oom.qtest
printf 'writew 0x%08x 0x0003\n' $((d + 12)) >> /tmp/vblk-zone-report-oom.qtest
printf 'writew 0x%08x 0x%04x\n' $((d + 14)) "$n" >> /tmp/vblk-zone-report-oom.qtest
done

d=$((0x00100000 + 1023 * 16))
printf 'writeq 0x%08x 0x0000000000200000\n' "$d" >> /tmp/vblk-zone-report-oom.qtest
printf 'writel 0x%08x 0x1fe00000\n' $((d + 8)) >> /tmp/vblk-zone-report-oom.qtest
printf 'writew 0x%08x 0x0002\n' $((d + 12)) >> /tmp/vblk-zone-report-oom.qtest
printf 'writew 0x%08x 0x0000\n' $((d + 14)) >> /tmp/vblk-zone-report-oom.qtest
cat >> /tmp/vblk-zone-report-oom.qtest <<'EOF'
writew 0x00104000 0x0000
writew 0x00104002 0x0001
writew 0x00104004 0x0000
outw 0xc010 0x0000
EOF

3) Run the qtest input with ASAN build (compile qemu with --enable-asan):

build/qemu-system-x86_64 -display none \
-accel qtest -qtest stdio \
-machine pc -nodefaults -m 512M -monitor none -serial none \
-blockdev driver=host_device,node-name=disk0,filename=/dev/nullb0 \
-device virtio-blk-pci-transitional,drive=disk0,addr=04.0,queue-size=1024 \
< /tmp/vblk-zone-report-oom.qtest

Cc: Sam Li <[email protected]>
Cc: Damien Le Moal <[email protected]>
Cc: Dmitry Fomichev <[email protected]>
Fixes: CVE-2026-5761
Fixes: 4f7366506a ("virtio-blk: add zoned storage emulation for zoned devices")
Reported-by: Mingyuan Luo <[email protected]>
Reviewed-by: Damien Le Moal <[email protected]>
Signed-off-by: Stefan Hajnoczi <[email protected]>
2026-04-13 09:21:38 -04:00
Peter Maydell becd22fdc2 Update version for v11.0.0-rc3 release
Signed-off-by: Peter Maydell <[email protected]>
2026-04-09 21:18:56 +01:00
Peter Maydell 8969ee84d4 Merge tag 'hw-misc-20260409' of https://github.com/philmd/qemu into staging
Misc HW patches

Few hw/ fixes and a keymap one.

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCAAdFiEE+qvnXhKRciHc/Wuy4+MsLN6twN4FAmnXtasACgkQ4+MsLN6t
# wN6TYxAAkfAJ+bFx35zYD1BJXS9ozboprLFR6EtGzEzomOSNSio4W0Dh+X3G6R69
# CZ6AW11J+17JtIsvVp4UrZVT1Seq4nhEl+LVCvJtIgpKkDv4o1IZh+jyIpwRxlZ8
# JweahVgOgc3z9r+gEM8GTrZmux9P3fYjELPt+71tsrgiVWhXntOyO3MriRHD4+1m
# pYMKEh3FEd84VVacKVArnxf/ThUlgxd+nt+KjXMpPnW7oDlLnqaVahn5qqqDgYX8
# Kgva7g7Z30ZCrxuOa+9Fx2FsTof8EW6htGbSr8kfa8gzzveUYRmEFvRFpuTE7rX7
# 4LItAUaKKUsA65cbXPXPNB+3Ua2odtNgjhvbudTsRnpcKNfTW203ct7R9h9OnfIu
# WROnegR4qFi1uVRFaI0NUxS9pOWCtK4MotnmBtJPwTBB9xP6qch6i8pOLj7loNEo
# QC2AN1RB0N6u3mSXdMWUaWsbsCq7Mw2j7YIpj0N8Cg7/sCzzAXR1XEmHl1bPesbc
# D/f89ck2kBe8wFHphkTxkIu1USPMxP9nVYt/UU+dh3iusXu5wzp26a/TSMoCYCYl
# LTd/8mYPvAFK71icgZwaGvzhJagA9EYExL2RAWCQZ56K8GG5UvsHmriQovyNMBgX
# QRNlKU6X+fbnv5lHOUVVRtPcT4xz7xYycfm2I9bqLXt4aLDRkxs=
# =i6vx
# -----END PGP SIGNATURE-----
# gpg: Signature made Thu Apr  9 15:20:27 2026 BST
# gpg:                using RSA key FAABE75E12917221DCFD6BB2E3E32C2CDEADC0DE
# gpg: Good signature from "Philippe Mathieu-Daudé (F4BUG) <[email protected]>" [full]
# Primary key fingerprint: FAAB E75E 1291 7221 DCFD  6BB2 E3E3 2C2C DEAD C0DE

* tag 'hw-misc-20260409' of https://github.com/philmd/qemu:
  qemu-keymap: fix altgr modifier lookup for newer xkeyboard-config
  ati-vga: Fix check for overflowing vram
  hw/timer: ibex_timer: Update IRQs after writing CTRL
  ati-vga: Fix pitch and offset registers mask

Signed-off-by: Peter Maydell <[email protected]>
2026-04-09 15:54:41 +01:00
Dietmar Maurer 4e6fb62fb0 qemu-keymap: fix altgr modifier lookup for newer xkeyboard-config
xkeyboard-config 2.37 removed the "AltGr" virtual modifier in favor
of mapping upper groups directly to Mod5. Since then,
xkb_keymap_mod_get_index(map, "AltGr") returns XKB_MOD_INVALID, so
AltGr-based keysyms were never generated.

See: https://gitlab.freedesktop.org/xkeyboard-config/xkeyboard-config/-/commit/473f9bc32f9ba869829cc0d06a75cd1f2560aa60

Try "AltGr" first, and fall back to "Mod5" for compatibility with
both old and new xkeyboard-config versions.

Signed-off-by: Dietmar Maurer <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-04-09 15:44:58 +02:00
BALATON Zoltan a34f546c5f ati-vga: Fix check for overflowing vram
Take into account the bytes per pixels when checking for accessing
beyond end of vram area.

Signed-off-by: BALATON Zoltan <[email protected]>
Reviewed-by: Marc-André Lureau <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-04-09 15:44:53 +02:00
Alistair Francis c75b41f21f hw/timer: ibex_timer: Update IRQs after writing CTRL
When writing to rv_timer.CTRL after setting the compare values the timer
doesn't fire as we don't update the interrupts. Ensure we update the
interrupts after a write to the rv_timer.CTRL register.

Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/2796
Signed-off-by: Alistair Francis <[email protected]>
Reviewed-by: Chao Liu <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Daniel Henrique Barboza <[email protected]>
Reviewed-by: Nutty Liu <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-04-09 15:44:48 +02:00
BALATON Zoltan 1c3bc5ea56 ati-vga: Fix pitch and offset registers mask
Remove the Radeon specific masks for offset and pitch registers. While
the documentation is not clear about it I believe it is a copy&paste
error from the combined DST_PITCH_OFFSET register that has less bits
so more constrained than the individual registers which should not
have this mask.

Signed-off-by: BALATON Zoltan <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-04-09 15:44:37 +02:00
Peter Maydell 0175d6a4eb Merge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging
* virtio-scsi: fix cdb_size issue

# -----BEGIN PGP SIGNATURE-----
#
# iQFIBAABCgAyFiEE8TM4V0tmI4mGbHaCv/vSX3jHroMFAmnXhEYUHHBib256aW5p
# QHJlZGhhdC5jb20ACgkQv/vSX3jHroMx5ggAqWT2APURWbs4tz16RhC3GlIWdxxo
# zb+xEtwX9s/G1Pb18R6+ZJdOjW1EeKut84K/q+jkkQ514kfzXJFNlonqKnajvJ3i
# YcQ7TL8o2F7PDeAWlJ/vgQJuAAvXnTqk8ppuqz75W1cJnA6vLBCaCA0nUiUNMXR2
# fIMot1a5l2yH1V4IzspIJDkP1oNIfqhPG4/89sraJPhmKqhGw/gDfLsJ/oZ1C2LI
# sm9qmMSsHsyV6gW3TbOn3mCt1R7+16JwvF/E6HsSXaK8u/UJxLPzlfQGjaKBDtE3
# HpVNtKY4XJzSWR6zbWw10dqQbT2h7WwHEbHCnYhnCJs9RMDu+t2evpmMGw==
# =Z7CW
# -----END PGP SIGNATURE-----
# gpg: Signature made Thu Apr  9 11:49:42 2026 BST
# gpg:                using RSA key F13338574B662389866C7682BFFBD25F78C7AE83
# gpg:                issuer "[email protected]"
# gpg: Good signature from "Paolo Bonzini <[email protected]>" [full]
# gpg:                 aka "Paolo Bonzini <[email protected]>" [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:
  virtio-scsi: pass the same cdb_size to virtio_scsi_pop_req and virtio_scsi_handle_cmd_req_prepare

Signed-off-by: Peter Maydell <[email protected]>
2026-04-09 11:58:04 +01:00
Gerd Hoffmann af74c9e46b hw/uefi: fix heap overflow (CVE-2026-5744)
When copying the request response into the pio transfer buffer the code
skips the 'struct mm_header' but does not consider that when calculating
transfer size, so it will copy 24 (== sizeof(struct mm_header)) extra
bytes, which can overflow uv->pio_xfer_buffer.

Fix that by copying the complete buffer, including the header, which
also makes the pio code path consistent with the (unaffected) dma code
path.

Fixes: CVE-2026-5744
Fixes: 90ca4e03c2 ("hw/uefi: add var-service-core.c")
Reported-by: Yuma Kurogome <[email protected]>
Signed-off-by: Gerd Hoffmann <[email protected]>
Reviewed-by: Daniel P. Berrangé <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-04-09 11:57:59 +01:00
Paolo Bonzini 7997130293 virtio-scsi: pass the same cdb_size to virtio_scsi_pop_req and virtio_scsi_handle_cmd_req_prepare
Ensure that there is no allocation/usage mismatch when requests
are processed in virtio_scsi_handle_cmd_vq.  To do this,
retrieve the value once and pass it to both functions.

For other calls to virtio_scsi_pop_req the extra size
can be 0, because control and event requests fit
entirely in VirtIOSCSIReq.

Reported-by: Jihe Wang <[email protected]>
Tested-by: Jihe Wang <[email protected]>
Reviewed-by: Stefan Hajnoczi <[email protected]>
Fixes: CVE-2026-5763
Signed-off-by: Paolo Bonzini <[email protected]>
2026-04-09 12:49:30 +02:00
Peter Maydell a87e211600 Merge tag 'hw-misc-20260407' of https://github.com/philmd/qemu into staging
Misc HW patches

Few fixes, mostly for VGA display models.

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCAAdFiEE+qvnXhKRciHc/Wuy4+MsLN6twN4FAmnVffgACgkQ4+MsLN6t
# wN4vAw/+OpYUXgVIE82vn6eJQPewiFm/oq7Bi2iHWtB51JLGy+eckbVrahG5M74g
# dvr2x+1APsweNizhkHz6m00UdCDmhli8N+p9xOa2F61LjYCszZBteR7DhMdPVF33
# GuptAXnyZZkeN0lvD+hYfk2KBNCGGOz2r96XUsuSoOS6BwgTzqlpaZ3mL4YaQbLD
# KED9wsqqKHgUrgZa7yzH4IFx4iuQoRTEeXUfa/BOnYUMKs7zlf8+x8a/93GM2fqK
# HRHi27Dw52DI0wSKZ97i67a+pP291S5BbSBnLb37HZeOdS5AUa3hHuoXKNhdd1O1
# PbQT1Rs0cPBkQ/YEeJySfQbRNS6fk2W/fz1yKVUaUzgWgXZxRJuAIml0JyudfhMr
# g4/g882St0b8umQRqePgmCUHWeG/bpVvsRPZN+lm6jobpk69htbGtR0pYO/dRCkZ
# aZWTGulPqnPNLMQG/qkYCFCPX4NpJfrl1VWSwCXRLt8d4r1CrnqmwfqmgQCsMkRd
# UJtHqYeYPHT4ivW/Vbn3cEUY1c5kRLjlPjWO6mAZCKCwnPyK5p3f4hSStLJlra6k
# /bidMyIJXvYHPCgHRzTDWsx2tV1tL3iyGlxEae3BTcPlUiXOczxsoKEqvg487nh6
# tmzodtsOHpNXnuZQb3rFdiGdzKUhhpobex7mKzef7xEFOKA2adk=
# =7zMH
# -----END PGP SIGNATURE-----
# gpg: Signature made Tue Apr  7 22:58:16 2026 BST
# gpg:                using RSA key FAABE75E12917221DCFD6BB2E3E32C2CDEADC0DE
# gpg: Good signature from "Philippe Mathieu-Daudé (F4BUG) <[email protected]>" [full]
# Primary key fingerprint: FAAB E75E 1291 7221 DCFD  6BB2 E3E3 2C2C DEAD C0DE

* tag 'hw-misc-20260407' of https://github.com/philmd/qemu:
  ati-vga: Do not crash on 24 bits per pixel
  ati-vga: Update mode on CRTC_PITCH change
  ati-vga: Fix setting CRTC_OFFSET
  hw/arm/omap_sx1: map CS3 at the correct base
  cirrus-vga: Make frame buffer endianness little endian by default
  docs/about/removed-features: Replace 'since' -> 'removed in'

Signed-off-by: Peter Maydell <[email protected]>
2026-04-08 19:16:36 +01:00
Peter Maydell 6d3e9dddef Merge tag 'pull-trivial-patches' of https://gitlab.com/mjt0k/qemu into staging
trivial patches for 2026-04-08

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCgAdFiEEZKoqtTHVaQM2a/75gqpKJDselHgFAmnWM84ACgkQgqpKJDse
# lHgJMxAAuz4rJQh51cTA1vKa/Pte//BZ4ro9dVnCi2ogCVjmy/ZaD6r2B8ZJtpHo
# RMXbTrswGF1Hs6J5HxztcMHNHE9fO+2CGjhgjujCsvs72Msdp5j6TjQ61DzIG3UL
# jz3g7fGPxabOyiJcMi61QMIMwcOQlS4WSZhvcRtxixc6KpY6fx5uCXpvEKUIzumQ
# WSmTkHVah4C8D05jUWmD5jF2krAUvf0XjsGDIYidjXRwsnORnBSZdHGoukQ8rGl9
# 6OjvuWT9UZIM7nXv76lPkk3APVFL4q9FMNoc3GxcTzHMWyvYknOM5KI4tDFhncqh
# 0gvie5OalWCxrzq8inGy3o+3v0/ggsOG/mjyN9tR5nas6qsqzya6PHaPoXbLn/uq
# ibsV+LOtjo65w0uJUV1LRn1TwG6bBQBKO1pdYmx3SouaY8dF9UsNTsvhiyFOdBge
# 7ZnjzoMmD33USkSWbAL5icGHSAShsIvJkQfWd8lrsx46dzuePC/DwGp8S384sNA+
# j0Ecqd/ar0cBfGi9mToKHufrGZS4S4R4xdVU41k2eA5AmhaEQ4D3BkWaZC7ocx59
# Q5s2N/XMDK6CX7OEkIAEy6Oi8DyO8vl/hozEI/USpc6OqUM/eX74WH7dR2fKaDZa
# D+36iSHOKQK2wgPVHaeBrfjobgFXY+/MGFGPMlvk9Z4q4zQNZ2Y=
# =XP94
# -----END PGP SIGNATURE-----
# gpg: Signature made Wed Apr  8 11:54:06 2026 BST
# gpg:                using RSA key 64AA2AB531D56903366BFEF982AA4A243B1E9478
# gpg: Good signature from "Michael Tokarev <[email protected]>" [full]
# gpg:                 aka "Michael Tokarev <[email protected]>" [full]
# gpg:                 aka "Michael Tokarev <[email protected]>" [full]
# Primary key fingerprint: 9D8B E14E 3F2A 9DD7 9199  28F1 61AD 3D98 ECDF 2C8E
#      Subkey fingerprint: 64AA 2AB5 31D5 6903 366B  FEF9 82AA 4A24 3B1E 9478

* tag 'pull-trivial-patches' of https://gitlab.com/mjt0k/qemu:
  util: fix missing aio_wait sym in qemu guest agent only build
  Allow building qemu tools on 32-bit hosts
  util/meson.build: do not add cpuinfo-$arch to util_ss for 32bit CPUs

Signed-off-by: Peter Maydell <[email protected]>
2026-04-08 13:34:10 +01:00
Nguyen Dinh Phi 4e4832dd72 util/readline: Fix out-of-bounds access in readline_insert_char().
Currently, the readline_insert_char() function is guarded by the cursor
position (cmd_buf_index) rather than the actual buffer fill level(cmd_buf_size).
The current check is:
	if (rs->cmd_buf_index < READLINE_CMD_BUF_SIZE)

This logic is flawed because if the command buffer is full and a user moves the
cursor backward (e.g. by sending left arrow key), cmd_buf_index can be
decreased without descreasing of buffer size.
This allow subsequent insertions to increase cmd_buf_size past its maximum
limit of rs->cmd_buf.

Because in the ReadLineState struct, cmd_buf[READLINE_CMD_BUF_SIZE + 1] is
immediately followed by the cmd_buf_index integer, once the buffer size is
sufficiently inflated, the memmove() operation inside readline_insert_char()
can write past the end of cmd_buf[] and overwrites cmd_buf_index itself.

The subsequent line:
	rs->cmd_buf[rs->cmd_buf_index] = ch;

then writes the input character to an address determined by the now-corrupted
index.

By providing a specifically crafted input sequence via HMP, this flaw can be
used to redirect the write operation to overwrite any field within the
ReadLineState structure, which can lead to unpredictable behavior or
application crashes.

Fix this by adding the guard to check for buffer fullness.

Cc: [email protected]
Signed-off-by: Nguyen Dinh Phi <[email protected]>
Message-id: [email protected]
Reviewed-by: Marc-André Lureau <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
2026-04-08 13:33:25 +01:00
Daniel P. Berrangé 17fbf3e18c util: fix missing aio_wait sym in qemu guest agent only build
Configure QEMU with

 --disable-system --disable-user --disable-tools --enable-guest-agent

and the build with fail with

  FAILED: [code=1] qga/qemu-ga
  ld: libqemuutil.a.p/qapi_qmp-dispatch.c.o: in function `do_qmp_dispatch_bh':
  qapi/qmp-dispatch.c:140:(.text+0x5c): undefined reference to `aio_wait_kick'

This aio_kick() usage was recently introduced in qmp-dispatch.c
without updating the build logic.

Fixes commit fc1a2ec7da
Signed-off-by: Daniel P. Berrangé <[email protected]>
Cc: [email protected]
Reviewed-by: Michael Tokarev <[email protected]>
Signed-off-by: Michael Tokarev <[email protected]>
2026-04-08 13:48:50 +03:00
Helge Deller cf634dfcd8 Allow building qemu tools on 32-bit hosts
Qemu's tools like qemu-img are often needed on 32-bit platforms,
although the actual qemu emulators have been discontinued on 32-bit.

To allow building the tools on 32-bit this patch implements three small
changes:

a) The check in meson.build is changed to still error out if the user
tries to build qemu-system or qemu-user on a 32-bit platform, but allows
building tools (e.g. by "--enable-tools") alone.

b) The compile time check in atomic.h now checks against
sizeof(uint64_t) so that 32-bit environments can still build
successfully, while 128-bit atomic operations are prevented to sneak in.

c) Allow linking against libatomic as long as we don't build the
qemu-system and qemu-user binaries.

Sucessfully tested on the 32-bit big-endian powerpc architecture.

Signed-off-by: Helge Deller <[email protected]>
Suggested-by: Richard Henderson <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Reviewed-by: Michael Tokarev <[email protected]>
Signed-off-by: Michael Tokarev <[email protected]>
2026-04-08 13:48:50 +03:00
BALATON Zoltan 992e01e838 ati-vga: Do not crash on 24 bits per pixel
The stn_he_p function only supports power of two sizes so it will
assert if we call it with size 3 that happens with 24 bits per pixel.
It's not clear from the documentation if this should be supported or
not and drivers tested so far don't use it so refuse the parameters
that would crash QEMU for now.

Signed-off-by: BALATON Zoltan <[email protected]>
Reviewed-by: Chad Jablonski <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-04-07 22:40:29 +02:00
BALATON Zoltan f4813f444a ati-vga: Update mode on CRTC_PITCH change
When changing line length we need to update display parameters so call
mode change when changing CRTC_PITCH if the value has changed.

Signed-off-by: BALATON Zoltan <[email protected]>
Reviewed-by: Chad Jablonski <[email protected]>
Message-ID: <3f54ff54a873a8f8a0cc5f14660703b4025a69e2.1775228029.git.balaton@eik.bme.hu>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-04-07 22:40:29 +02:00
BALATON Zoltan 4bbe831f1e ati-vga: Fix setting CRTC_OFFSET
Offset (display start address) should also be updated when changing
the register value not only on mode change. Fix the register write
mask to hard code bits 0:2 to 0 as the chip docs say and update the
start address on register write. This fixes virtual screen panning for
screens larger than displayed resolution.

As this register allows values that cannot be handled by the VBE_DISPI
X and Y offsets (which is restricted by line length) we add a function
to set it directly not through the VBE offsets.

Signed-off-by: BALATON Zoltan <[email protected]>
Tested-by: Chad Jablonski <[email protected]>
Reviewed-by: Chad Jablonski <[email protected]>
Message-ID: <2b8af6022aba06aa98a249ae67922de29d82d86f.1775228029.git.balaton@eik.bme.hu>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-04-07 22:40:29 +02:00
GuoHan Zhao 9b3faf0d49 hw/arm/omap_sx1: map CS3 at the correct base
omap_sx1 wires the "sx1.cs3" region to OMAP_CS2_BASE instead of
OMAP_CS3_BASE.

That places both CS2 and CS3 at the same address and leaves the real
CS3 window unmapped. Point the CS3 region at OMAP_CS3_BASE so the
static chip-select layout matches the OMAP address definitions.

Signed-off-by: GuoHan Zhao <[email protected]>
Fixes: ba1580299d ("omap_sx1: convert to memory API")
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-04-07 22:40:29 +02:00
BALATON Zoltan 26f21f6e17 cirrus-vga: Make frame buffer endianness little endian by default
QEMU VGA defaults to target endianness but real Cirrus VGA is little
endian so set it explicitly in cirrus_init_common() to fix it on big
endian machines.

Signed-off-by: BALATON Zoltan <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-04-07 22:40:29 +02:00
Philippe Mathieu-Daudé 8108793f67 docs/about/removed-features: Replace 'since' -> 'removed in'
We use "deprecated since ..." and "removed in ...".
Replace "since" by "removed in" for removed features.

Fixes: 762c855439 ("vfio: Remove 'vfio-platform'")
Fixes: aeb1a50d4a ("vfio: Remove 'vfio-amd-xgbe' device")
Fixes: e50a021a45 ("hw/arm: Remove ast2700a0-evb machine")
Fixes: 4af2433a81 ("docs: Mention 32-bit PPC host as removed")
Fixes: 8ebc416ac1 ("vfio: Remove 'vfio-calxeda-xgmac' device")
Fixes: a80151c9da ("hw/sd/sdcard: Remove support for spec v1.10")
Fixes: 269ffaabc8 ("buildsys: Remove support for 32-bit MIPS hosts")
Fixes: fc37c122ff ("migration: Drop deprecated QMP migrate argument @detach")
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Message-Id: <[email protected]>
2026-04-07 22:39:59 +02:00
Peter Maydell e29302cbe6 Merge tag 'pull-target-arm-20260407' of https://gitlab.com/pm215/qemu into staging
target-arm queue:
 * docs/system: remove extraneous sentence
 * target/arm: fix fault_s1ns for stage 2 faults
 * target/arm: do_ats_write(): avoid assertion when ptw failed

# -----BEGIN PGP SIGNATURE-----
#
# iQJNBAABCAA3FiEE4aXFk81BneKOgxXPPCUl7RQ2DN4FAmnVRJIZHHBldGVyLm1h
# eWRlbGxAbGluYXJvLm9yZwAKCRA8JSXtFDYM3iy2EACmribMFgzcPttAFU9Tx3VG
# SZ6jvm3xexspyh0bQe/P47gV2oZgvTepEYzteM0b6b6hOfiDFHCFzXXjyfcTqhxU
# LkeDXysB54zKjnHThihTnD3065JndwSYQdIQx+P3hk1Lcq3uGvZNLHjMRT++N0xv
# Jtp9SLKD9LtJZcEAXtPEy3gxoZwA/3hXp03EooO9TpZHDEdhTFxTmP9DVLeaAU9T
# zH1CwIPvZv2g1ep82fKuVM2TNNazPC60RIy4jiyiMAKAFgWLdp2bpes8MfXu24Au
# mAFdZJirVI8/oBQn+WaM1o9zVcIPuXqpK1AfFa9KRxYJx35dS3fUEC80vhdcL7gO
# HQP0ZmnKqWxB2CN8b7sEAjLyLjScE5GMqWbbTUckfJoFdQF1jcmfxRpl8t5VI/p/
# /2lCIwFjSerRiRrqwbUMss1ue37IpwZ8dWUkpKPhwnlBUe/Ts41DMZeQ9Cf/HieZ
# 6RgfcXszTQWwUESOPooy593Smw2pwKfB3Gmpq7khwIPtu5WLMhDKiQhTA1t4r7YM
# /BmNXUCAoiTIN2S8IXxe23ORXcPlQ4EyFDDBh0h4gAeX0eQCgUAcfkmDlRZb7Rbj
# sIVuAFOd1YW8sz3AHoXXH4bq0oPeh5MeWZJwcp1djTV3j1Cdyz9L9I0eFF+OWtj/
# MNvSBK7/IIapbLenws8GHg==
# =eIR5
# -----END PGP SIGNATURE-----
# gpg: Signature made Tue Apr  7 18:53:22 2026 BST
# gpg:                using RSA key E1A5C593CD419DE28E8315CF3C2525ED14360CDE
# gpg:                issuer "[email protected]"
# gpg: Good signature from "Peter Maydell <[email protected]>" [ultimate]
# gpg:                 aka "Peter Maydell <[email protected]>" [ultimate]
# gpg:                 aka "Peter Maydell <[email protected]>" [ultimate]
# gpg:                 aka "Peter Maydell <[email protected]>" [ultimate]
# Primary key fingerprint: E1A5 C593 CD41 9DE2 8E83  15CF 3C25 25ED 1436 0CDE

* tag 'pull-target-arm-20260407' of https://gitlab.com/pm215/qemu:
  docs/system: remove extraneous sentence
  target/arm: fix fault_s1ns for stage 2 faults
  target/arm: do_ats_write(): avoid assertion when ptw failed

Signed-off-by: Peter Maydell <[email protected]>
2026-04-07 18:55:04 +01:00
Alex Bennée 8a9fa9ec99 docs/system: remove extraneous sentence
Lest we confuse the reader about something we are no longer showing in
the example.

Fixes: 132f8ec799 (target/arm: change default pauth algorithm to impdef)
Signed-off-by: Alex Bennée <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-04-07 16:03:54 +01:00
Alex Bennée 566594f108 target/arm: fix fault_s1ns for stage 2 faults
The computation of s1ns was simply wrong. For Stage 2 faults, it
should indicate whether the faulting IPA is in the Non-Secure IPA
space. Correct the logic to check for ARMSS_NonSecure and drop the
extraneous s2_mmu_idx test.

This is effectively a change in the intended semantics of the
ARMMMUFaultInfo::s1ns field, so that we no longer try to make it
exactly match HPFAR_EL2.NS but instead set it for any stage 2 fault
on an NS IPA, relying on users of the field to check whether the
fault is to be taken to Secure EL2 before propagating the field to
the HPFAR_EL2.NS bit.  Since the actual writing of HPFAR_EL2.NS is
already gated by arm_is_secure_below_el3(env), we only need to update
the comments to document this change of semantics.

Cc: [email protected]
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/2568
Signed-off-by: Alex Bennée <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-id: [email protected]
[PMM: also update comments about the s1ns field]
Reviewed-by: Peter Maydell <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
2026-04-07 12:38:59 +01:00
Michael Tokarev 276b060a74 util/meson.build: do not add cpuinfo-$arch to util_ss for 32bit CPUs
qemu dropped support for 32bit CPUs recently, so this change is an
additional clean-up on top.  But in theory it will allow building
qemu-guest-agent on a 32bit system.

Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Michael Tokarev <[email protected]>
2026-04-03 18:31:08 +03:00
Peter Maydell 84771c64a5 target/arm: do_ats_write(): avoid assertion when ptw failed
In do_ats_write() we try to assert that the cacheattrs from
get_phys_addr_for_at() are in the form we expect:

    /*
     * ATS operations only do S1 or S1+S2 translations, so we never
     * have to deal with the ARMCacheAttrs format for S2 only.
     */
    assert(!res.cacheattrs.is_s2_format);

However, the GetPhysAddrResult struct documents that its fields are
only valid when the page table walk succeeded.  For a two stage page
table walk which fails during stage two, we will return early from
get_phys_addr_twostage() and depending on the fault type the
res.cacheattrs may have been initialized with the stage 2 cache attr
information in stage 2 format.  In this case we will incorrectly
assert here.

Fix the assertion to not look at the res fields if the lookup failed.

Note for stable backports: the do_ats_write() function is in
target/arm/helper.c in older QEMU versions, but the change to the
assert line is the same.

Cc: [email protected]
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3328
Fixes: 9f225e607f ("target/arm: Postpone interpretation of stage 2 descriptor attribute bits")
Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-id: [email protected]
2026-04-01 20:52:14 +01:00
Peter Maydell b6a7d06213 Update version for v11.0.0-rc2 release
Signed-off-by: Peter Maydell <[email protected]>
2026-04-01 20:48:02 +01:00
Peter Maydell 2bf71cb2d8 Merge tag 'firmware-20260401-for-11.0-pull-request' of https://gitlab.com/kraxel/qemu into staging
igvm bugfixes

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCgAdFiEEoDKM/7k6F6eZAf59TLbY7tPocTgFAmnM6lEACgkQTLbY7tPo
# cTg9BhAA1WRZUp8e3G7wUwZPf8JGztEExXRC8ageNp6c4cmY8WB9BmqdteH4afo/
# ulKzwNk7aI8AdyG5OlIl+aI9MyfEMiOEstdL+Hu2nt8o0Ve5h5uXh9NmqTbcHxNU
# G3lwzTR1mjE5zm8/PZ0mQDMD7MMMbAPrpVCxbUSg13oWxQCG0Tl38w8n9G2RCTZe
# PE1XMRp/tzumzmraxTkCRwleD4Ctq298gS4DG7k8Zlits8Wwak5dDFvphwV7X/na
# Aix4DF0mtXgHHZ4szjX5HZGQq824JdY6keq8vq30kE87rA2/Qz9evhgRelYPPiLH
# /QFGUhHEwL4o5fMZkID852QXA85wRL9XulPIU08jF15jkkhOQZo6nYYQDJvTjtpz
# Lji++Pm8EFxvbDqO8TrSagXA0Y7DQ0GTzj5wuJ/5jIePA1trfV9dypjrT9vpOIg/
# iKM+kT8vb05Fid0v12thI0/7bAcnTMv+BNjtkiMYkQ8PIgSfEDbHYS6OBelXSHY0
# aw8I85UORuzqq5DDFRvY7WqpZ4Rd+vHDh9lBpnPEI6QheLFSV39zHpveNlB14z4Q
# r7CO9pQKvxU44qEpIiDQ36AJT8udBt4e9rBpBoRTbq77hbU0APKllpn89yb0YckQ
# uhoJnF8glP7kuu0aMz8OLHDFvZwmlSm/HuOFw4pbmE0WtLPnEcY=
# =rhi3
# -----END PGP SIGNATURE-----
# gpg: Signature made Wed Apr  1 10:50:09 2026 BST
# gpg:                using RSA key A0328CFFB93A17A79901FE7D4CB6D8EED3E87138
# gpg: Good signature from "Gerd Hoffmann (work) <[email protected]>" [full]
# gpg:                 aka "Gerd Hoffmann <[email protected]>" [full]
# gpg:                 aka "Gerd Hoffmann (private) <[email protected]>" [full]
# Primary key fingerprint: A032 8CFF B93A 17A7 9901  FE7D 4CB6 D8EE D3E8 7138

* tag 'firmware-20260401-for-11.0-pull-request' of https://gitlab.com/kraxel/qemu:
  igvm: fix parent object type in IgvmCfg struct
  igvm: fix memory leak on failed memory region init
  igvm: switch to PRIx64

Signed-off-by: Peter Maydell <[email protected]>
2026-04-01 16:47:41 +01:00
Peter Maydell 9e69071fc2 Merge tag 'pull-linux-user-20260401' of https://gitlab.com/pm215/qemu into staging
linux-user:
 * don't incorrectly sign extend guest addresses from mlock etc
 * fix name_to_handle_at when AT_HANDLE_MNT_ID_UNIQUE flag is set
 * update select timeout writeback
 * make openat2() use -L for absolute paths
 * correctly handle SIGSEGV generated when trying to deliver
   a synchronous signal

# -----BEGIN PGP SIGNATURE-----
#
# iQJNBAABCAA3FiEE4aXFk81BneKOgxXPPCUl7RQ2DN4FAmnM6b0ZHHBldGVyLm1h
# eWRlbGxAbGluYXJvLm9yZwAKCRA8JSXtFDYM3utoEACFpsqPLc4bTYZfIOy7Q8qW
# Kd9w/QT2Wyp5eZ52efxXopimpB7yKfIbHOB6MF1lHELfwkrDZ04CcD2q+JSR9Zce
# Zydl11nMdmhIzsWmfUju5qzrQQmx+F9pjC2nntt6QAqixMKqj6DLNEClK9QXp1WX
# q9XfJVju5JgciiUlC/Ne01GmKv1xGV3PkZy6BOzi1n3BVFyqb+wWP1G83KKIYoSN
# VCgs5IOh53qEwlPYMKzDJAUJhc3Ba2LvC4xQ2rAZlHTAoejcJHMtKjd/8ZNebGTo
# juO+7GpqxBhAQUFrmsaLidD7kiNcTMpWV5N25BDG+QFlD7pRdwk7hPrrtTHUCw7c
# H+HKKmCTUoTgoucNzkfokX58YTOOyG4Uh2eRnQ03SCd2bVX2Oesq2WYIkaJ6kY/D
# JukzaTGHLZHYzze7vmZe0dGdWWFox5MqbuNOuALan+sCq+VsznCOI2quXFovU/9m
# OCYRYwB5sAPmAd1yVvkwl53xfhyXvwCPJhzBTq9YfY6RAtqufgq1zfFPiMqvQNMi
# AZRTIcB+YXxk3fOa/xAMKF7GAzYujNbKCC/DTE2EnaqgpDHqUyQxQXSUJiAiR0os
# yI1XL/1I7dKEsV+ZdNJtQiWFdLJvi0f3C15jq1ICqzQViI2Dk27MVNAhYhda4ueo
# sr9PJ85vQk8bKu7+Ng2qYg==
# =jmT5
# -----END PGP SIGNATURE-----
# gpg: Signature made Wed Apr  1 10:47:41 2026 BST
# gpg:                using RSA key E1A5C593CD419DE28E8315CF3C2525ED14360CDE
# gpg:                issuer "[email protected]"
# gpg: Good signature from "Peter Maydell <[email protected]>" [ultimate]
# gpg:                 aka "Peter Maydell <[email protected]>" [ultimate]
# gpg:                 aka "Peter Maydell <[email protected]>" [ultimate]
# gpg:                 aka "Peter Maydell <[email protected]>" [ultimate]
# Primary key fingerprint: E1A5 C593 CD41 9DE2 8E83  15CF 3C25 25ED 1436 0CDE

* tag 'pull-linux-user-20260401' of https://gitlab.com/pm215/qemu:
  bsd-user, linux-user: signal: recursive signal delivery fix
  linux-user: Make openat2() use -L for absolute paths
  linux-user: update select timeout writeback
  linux-user: fix name_to_handle_at when AT_HANDLE_MNT_ID_UNIQUE flag is set
  include/user/guest-host.h: Provide g2h etc for both abi_ptr and vaddr
  include: Don't include guest-host.h in cpu-ldst.h

Signed-off-by: Peter Maydell <[email protected]>
2026-04-01 10:49:09 +01:00
Peter Maydell 7df28e4c41 Merge tag 'hppa-more-v11-fixes-pull-request' of https://github.com/hdeller/qemu-hppa into staging
HPPA patches for qemu-v11

A few late fixes for the HPPA architecture for QEMU v11:
- graphics support was broken for 64-bit machines. This series adds
  support for VGA graphics for Linux guests
- the various memory ranges were not correctly implemented
- TOC/NMI was not working on 64-bit machines
- minor 64-bit HP-UX boot fixes (but HP-UX 64-bit still crashes)

# -----BEGIN PGP SIGNATURE-----
#
# iHUEABYKAB0WIQS86RI+GtKfB8BJu973ErUQojoPXwUCacwXxAAKCRD3ErUQojoP
# X7NxAQCBszDUKsNX5KiB+cxW1AfT1Gyzo4q9T0NNULO5v2Fn7gD/YVzgtZ6F+crK
# 1eG1R0aVekPmx+NClsCLvy/dX1YmTww=
# =L+6i
# -----END PGP SIGNATURE-----
# gpg: Signature made Tue Mar 31 19:51:48 2026 BST
# gpg:                using EDDSA key BCE9123E1AD29F07C049BBDEF712B510A23A0F5F
# gpg: Good signature from "Helge Deller <[email protected]>" [unknown]
# gpg:                 aka "Helge Deller <[email protected]>" [unknown]
# gpg:                 aka "Helge Deller <[email protected]>" [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: 4544 8228 2CD9 10DB EF3D  25F8 3E5F 3D04 A7A2 4603
#      Subkey fingerprint: BCE9 123E 1AD2 9F07 C049  BBDE F712 B510 A23A 0F5F

* tag 'hppa-more-v11-fixes-pull-request' of https://github.com/hdeller/qemu-hppa:
  target/hppa: Update SeaBIOS-hppa to version 24
  hw/hppa: Implement memory ranges
  target/hppa: Fix TOC handler for 64-bit CPUs
  hw/pci-host/astro: Add GMMIO mapping
  hw/pci-host/astro: Fix LMMIO DIRECT mappings
  hw/pci-host/astro: Implement LMMIO registers
  hw/pci-host/astro: Fix initial addresses in IOC
  hw/pci-host/astro: Make astro address arrays accessible for other users

Signed-off-by: Peter Maydell <[email protected]>
2026-03-31 20:46:13 +01:00
Helge Deller bf758751aa target/hppa: Update SeaBIOS-hppa to version 24
New SeaBIOS-hppa v24 release with various fixes for qemu-v11:
- Initialize Astro chip with relevant LMMIO, GMMIO and others
- Disable Artist on 64-bit machines
- Fully implement parisc memory ranges
- Change inventory to list CPU first for HP-UX
- Allow 715 to boot from HP-UX 11iv1 CD-ROM
- Prepare for MULTICELL machines
- Initialize PCI_CACHE_LINE_SIZE PCI value
- Call TOC/HPMC handler code from OS if installed

Signed-off-by: Helge Deller <[email protected]>
2026-03-31 20:24:24 +02:00
Helge Deller 4a84032a26 hw/hppa: Implement memory ranges
All 64-bit PA-RISC machines split the memory into (up to 3) different
memory ranges, which are mapped at specific addresses.  This patch
mimics the mapping as it's done on physical machines, which includes the
3.75 GB split for C3700, and 1 GB split for newer 64-bit PAT machines
like the A400.

SeaBIOS-hppa needs to know how the memory split is done, so add a new
memsplit_addr variable which stores the specific split address and hand
this over to SeaBIOS-hppa via fwcfg.

Signed-off-by: Helge Deller <[email protected]>
2026-03-31 20:22:25 +02:00
Helge Deller afcb125165 target/hppa: Fix TOC handler for 64-bit CPUs
When the TOC handler is triggered, e.g. by using the "NMI" command
in the QEMU monitor, make sure to call the full 64-bit TOC handler
address in SeaBIOS-hppa firmware.
This fixes the TOC handler on 64-bit CPUs (and 64-bit SeaBIOS).

Signed-off-by: Helge Deller <[email protected]>
2026-03-31 20:22:25 +02:00
Helge Deller a45862947e hw/pci-host/astro: Add GMMIO mapping
Implement the GMMIO mapping.

Signed-off-by: Helge Deller <[email protected]>
2026-03-31 20:22:25 +02:00
Helge Deller 12cd2e5ec1 hw/pci-host/astro: Fix LMMIO DIRECT mappings
Fix the existing code which has the mask wrong.
Implement the direct mapping via overlapping subregion with priority 3
to make sure the direct mapping gets precedence over the LMMIO region.

Signed-off-by: Helge Deller <[email protected]>
2026-03-31 20:22:25 +02:00
Helge Deller 4f5367f0a2 hw/pci-host/astro: Implement LMMIO registers
Add code to adjust the memory mapping windows according to the LMMIO registers
in Astro.  This allows SeaBIOS-hppa to configure Astro depending on existing
PCI cards, and especially makes it possible to enable a VGA PCI card.

Signed-off-by: Helge Deller <[email protected]>
2026-03-31 20:22:25 +02:00
Helge Deller 64f676beea hw/pci-host/astro: Fix initial addresses in IOC
F-Extend the LMMIO and IOS distributed addresses.
Use the 44-bit address for the IOS distributed address.

Signed-off-by: Helge Deller <[email protected]>
2026-03-31 20:22:25 +02:00
Helge Deller a3210e056d hw/pci-host/astro: Make astro address arrays accessible for other users
Move the tables out of astro_realize(). This is needed because follow-up
patches will need those tables.

Signed-off-by: Helge Deller <[email protected]>
2026-03-31 20:22:25 +02:00
Nicholas Piggin 7e966ef38f bsd-user, linux-user: signal: recursive signal delivery fix
Synchronous signals must accommodate a synchronous signal being
raised during delivery, as asynchronous ones do. For example
badframe errors during delivery will cause SIGSEGV to be raised.

Without this fix, cpu_loop() runs process_pending_signals() which
delivers the first synchronous signal (e.g., SIGILL) which fails
to set the handler and forces SIGSEGV, but that is not picked up.
process_pending_signals() returns. Then cpu_loop() runs cpu_exec()
again, which attempts to execute the same instruction, another
SIGILL.

Signed-off-by: Nicholas Piggin <[email protected]>
Reviewed-by: Warner Losh <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-03-31 19:13:20 +01:00
Sun Haoyu fa6dfcc373 linux-user: Make openat2() use -L for absolute paths
openat2() ignored the -L prefix and opened host files directly.
For example, openat2("/tmp/file") opened /tmp/file on the host, not
QEMU_LD_PREFIX/tmp/file like openat() does.

Fix this by using path() to rewrite absolute paths. Skip this
when RESOLVE_BENEATH or RESOLVE_IN_ROOT is set:
- RESOLVE_BENEATH rejects absolute paths anyway
- RESOLVE_IN_ROOT resolves relative to dirfd

Now openat() and openat2() work in the same way.

Link: https://gitlab.com/qemu-project/qemu/-/work_items/3341

Signed-off-by: Sun Haoyu <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-03-31 19:13:20 +01:00
Sun Haoyu 9b7d64686b linux-user: update select timeout writeback
The Linux kernel writes back the remaining timeout for select-family
syscalls in poll_select_finish(). If that writeback fails, it keeps
the original return value.

However, QEMU only writes back the timeout on success. If the writeback
fails, QEMU returns -TARGET_EFAULT. This can lose the remaining
timeout and change the return value.

Update do_select(), do_pselect6(), and do_ppoll() to always write back
the timeout to match the Linux kernel's behavior. If the timeout
writeback fails, keep the original return value.

Tested with the issue reproducer.

Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3343
Signed-off-by: Sun Haoyu <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-03-31 19:13:20 +01:00
Clayton Craft 22966937f4 linux-user: fix name_to_handle_at when AT_HANDLE_MNT_ID_UNIQUE flag is set
Linux 6.12 added AT_HANDLE_MNT_ID_UNIQUE, which indicates that mount_id
is 64-bits. If name_to_handle_at is called with this flag set then qemu
passes a 4 byte int to the kernel, which then tries to store 8 bytes in
a 4 byte variable, causing a SIGSEGV[1][2].

This stores mount_id in a 64-bit var if the flag is set.

1. https://gitlab.postmarketos.org/postmarketOS/pmaports/-/work_items/4431
2. https://github.com/systemd/systemd/issues/41279

Signed-off-by: Clayton Craft <[email protected]>
Reviewed-by: Helge Deller <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-03-31 19:13:20 +01:00
Peter Maydell 8330da591e include/user/guest-host.h: Provide g2h etc for both abi_ptr and vaddr
In commit 7804c84a ("include/user: Use vaddr in guest-host.h") we
changed all the functions in guest-host.h that took or returned their
guest address argument in type abi_ptr to instead use vaddr.

This introduced regressions for the case of a 32-bit guest and an
address above 2GB for the common situation where the address is a
syscall argument stored in a variable of type 'abi_long'.  With
abi_ptr (which will be an unsigned 32-bit type for 32-bit guests),
the address is cast to unsigned 32-bit, and then zero-extended to
64-bits in g2h_untagged_vaddr().  With the switch to vaddr (which is
always a 64-bit unsigned type), the guest address will instead be
sign-extended to 64 bits, which gives the wrong answer.

Fix this by providing two versions of the affected functions: the
standard names (g2h(), g2h_untagged(), guest_addr_valid_untagged(),
guest_range_valid_untagged(), cpu_untagged_addr()) return to using
the logically-correct abi_ptr type; new versions with a _vaddr()
prefix use the vaddr type.

accel/tcg/user-exec.c must change to use the _vaddr() versions; this
is the only file that uses guest-host.h that we want to compile once.
All the other uses are in linux-user and bsd-user code that
inherently has to know the sizes of target-ABI types.

Cc: [email protected]
Fixes: 7804c84a ("include/user: Use vaddr in guest-host.h")
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3333
Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Laurent Vivier <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-id: [email protected]
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-31 19:13:03 +01:00
Peter Maydell 7a2dc48276 Merge tag 'for-upstream' of https://gitlab.com/kmwolf/qemu into staging
Block layer patches

- ide: Fix potential assertion failure on VM stop for PIO read error
- scsi: Don't consider LOGICAL UNIT NOT SUPPORTED guest recoverable
- vhost-user-blk-server: fix opt_io_size=1 causing severe Windows I/O degradation
- monitor: Fix deadlock in monitor_cleanup
- Fix filename references in comments

# -----BEGIN PGP SIGNATURE-----
#
# iQJFBAABCgAvFiEE3D3rFZqa+V09dFb+fwmycsiPL9YFAmnL4dURHGt3b2xmQHJl
# ZGhhdC5jb20ACgkQfwmycsiPL9aG/BAAiZ1XYu46Ct9+IdopoPYhEK+T7m7PuEUR
# KJPvdp0J6mVwVBehUjacmKvCtBQUbUF8x7PD6NMF3Q+7qkVqhmngbb4s5ks/zUQi
# MxZTJF1Yps9EZ6mI3bA6caV9PzegQSOA4p+RhOXaDt7lhXhBFt6lCVFVB5eCma+a
# 1dOxAbKD6geftaMvB1uQu5qYAtclATw1Gl4YSkdaO+UKGizce6YdKYOvFwU53EvO
# 4cRrrVzk7i5act61HcwT6xNSFJ+Fgmwcn+EiD0Uw/hOFzf8nXNS0DME7QJKjr6Ug
# Adv/439sUk5J1A//S3liSQ8D9SZBdi2yS7quMy4ggbwz9CqQvUi3ejenpOJtn8yG
# ylyhHmd4dnr8QC1Zf/3SbZ1hbLWn69y+rmV+e2uJF59bpWRMvqxeJX+D4DPe5LZp
# E8pckNmqkqkBfsPuM0nzW5qdPmkioZ+i2pEgAQ99tkUlcfFLvrlEaCr9AVKgDcZn
# B2HjaZPLrZtXEKMtKM4RXt7h8F33Zxnvy8chSdqW6J0BaWvPtFO7bJn2elAgibum
# ZBigvhfwkw9xxzlGmudTbNMz8Fnpc/KBue8bhzDkOe4AybcVwuefG3VIyI8tLkG9
# IoHxbeQM6+yHXjrvn3OLWLJ7HQ0EyBsRE9cpZN4p/3rSS5G7RWfNdAIuzwLamZQ3
# lmzdXf9++1E=
# =JiFt
# -----END PGP SIGNATURE-----
# gpg: Signature made Tue Mar 31 16:01:41 2026 BST
# gpg:                using RSA key DC3DEB159A9AF95D3D7456FE7F09B272C88F2FD6
# gpg:                issuer "[email protected]"
# gpg: Good signature from "Kevin Wolf <[email protected]>" [full]
# Primary key fingerprint: DC3D EB15 9A9A F95D 3D74  56FE 7F09 B272 C88F 2FD6

* tag 'for-upstream' of https://gitlab.com/kmwolf/qemu:
  block: Fix crash after setting latency historygram with single bin
  vhost-user-blk-server: fix opt_io_size=1 causing severe Windows I/O degradation
  monitor: Fix deadlock in monitor_cleanup
  block: Fix references in bdrv_bsc_*() function comments
  scsi: Don't consider LOGICAL UNIT NOT SUPPORTED guest recoverable
  ide: Fix potential assertion failure on VM stop for PIO read error

Signed-off-by: Peter Maydell <[email protected]>
2026-03-31 17:51:08 +01:00
Peter Maydell ad7a005d67 include: Don't include guest-host.h in cpu-ldst.h
We currently include user/guest-host.h from accel/tcg/cpu-ldst.h.
However that file doesn't need anything from guest-host.h, since we
removed the uses of g2h() in commit 9b74d403b3 ("accel/tcg: Move
user-only tlb_vaddr_to_host out of line").

Move the include of guest-host.h to where it's actually needed.

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Laurent Vivier <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-id: [email protected]
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-31 16:31:30 +01:00
Peter Maydell 9f6c969883 Merge tag 'hw-misc-20260331' of https://github.com/philmd/qemu into staging
Misc HW patches

Few fixes and MAINTAINERS updates.

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCAAdFiEE+qvnXhKRciHc/Wuy4+MsLN6twN4FAmnLyKIACgkQ4+MsLN6t
# wN5PNw/9ELCMUEt9V+K4NvfHYEeBAj3TvjxqJSoZ2NI8NrOP4edzWz690D4Hdqg/
# Ptt+OpgQicfxCpFrH3VNC7v69zaVRPB17BAlwMOJDF7x/2vRa4RsaPDpM3zYy3NA
# Rc+ujc/Umt8T3O0qVVcRExGx4XhHyo7ed55GPMXNcMFmG2ndmX2K/ZJfRCBWqSjd
# aMsqG/ZnT5WR7MgWL4jOC3oZsOg53FlNl4cVDV5HuVKzR8kK3M2u1nDFB2Oyi7Wa
# /9d6h5lwXRW5VrccNMM2wSoQqeYiChq7/ZcxBgmZrgbq9vlsSFQ/ea+3NloTLbx9
# 7SVwR7XHL2Bo8Civ6VjmyStt8bRCNOAYD4cg2br/EDhO9rnyVNpaCcYprAcK9I+H
# CKcwWBzKvgzkboCqU5rXrE1m5E+eZX9xiz3K0J7up+m72rGunhOIeou4gAY4wtFj
# d7F5dCzzC7wn+iIK45KtDpGTb9chlOoTTx0auwco9Av1C5ZqqoVa1+Dpf4wKnb2+
# 2Hzpz5L7R8UxYWTyYuL3ZDOqaVc5ZIpxrYwbzLI8VO1lHN0vPfzNLXfUaIPO4XNm
# JL0GDUV4CetFVAQJHFckUEpI+NAGkajvmY5bckwSA1CXWGDqGmRIuaL9ML9R79/V
# yZUZ0z/WHJQlH8Q953BE2SxQzhql/ZKDQeQSP/LVmVaJW2arBAw=
# =vddZ
# -----END PGP SIGNATURE-----
# gpg: Signature made Tue Mar 31 14:14:10 2026 BST
# gpg:                using RSA key FAABE75E12917221DCFD6BB2E3E32C2CDEADC0DE
# gpg: Good signature from "Philippe Mathieu-Daudé (F4BUG) <[email protected]>" [full]
# Primary key fingerprint: FAAB E75E 1291 7221 DCFD  6BB2 E3E3 2C2C DEAD C0DE

* tag 'hw-misc-20260331' of https://github.com/philmd/qemu:
  MAINTAINERS: fix OSUOSL typo
  hw/hppa: Disable Artist graphics card on 64-bit machines
  hw/pci-host/astro: Update copyright and documentation link
  ati-vga: Add upper limit to x-linear-aper-size property
  ati-vga: Silence warning about operator precedence
  target/i386: Treat qtest like TCG for supported-features
  target/i386/cpu.c: Correct minor grammar error in warning
  backends/igvm: switch to PRIx64
  target/mips: save CP0 timer in vmstate
  MAINTAINERS: Separate QDev section from QOM one
  ppc/pnv: generate dtb after machine initialization is complete

Signed-off-by: Peter Maydell <[email protected]>
2026-03-31 15:21:44 +01:00
Kevin Wolf a55402d5c3 block: Fix crash after setting latency historygram with single bin
Passing an empty list of boundaries to block-latency-histogram-set sets
up a state that leads to a NULL pointer dereference when the next
request should be accounted for. This is not a useful configuration, so
just error out if the user tries to set it.

The crash can easily be reproduced with the following script:

    qmp() {
    cat <<EOF
    {'execute':'qmp_capabilities'}
    {'execute':'block-latency-histogram-set',
     'arguments': {'id':'ide0','boundaries':[]}}
    {'execute':'cont'}
    EOF
    }

    qmp | ./qemu-system-x86_64 -S -qmp stdio \
        -drive if=none,format=raw,file=null-co:// \
        -device ide-hd,drive=none0,id=ide0

Signed-off-by: Kevin Wolf <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
2026-03-31 15:47:52 +02:00
Max Makarov 99bfc1c754 vhost-user-blk-server: fix opt_io_size=1 causing severe Windows I/O degradation
The QSD vhost-user-blk export sets opt_io_size=1 and min_io_size=1 in
the virtio config. These values are reported to the guest through the
VPD Block Limits page as OptimalTransferLength=1 block (512 bytes)
and OptimalTransferLengthGranularity=1 block.

Windows respects these hints and splits all I/O into ~512-byte
requests, causing ~100x sequential throughput degradation (150 MB/s
instead of 15+ GB/s). Linux is unaffected as its block layer ignores
these values.

Set both to 0 which means "not reported" per the SCSI Block Limits
VPD spec, allowing Windows to use its own optimal I/O size defaults.

Signed-off-by: Max Makarov <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Kevin Wolf <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
2026-03-31 15:45:32 +02:00
hongmianquan fc1a2ec7da monitor: Fix deadlock in monitor_cleanup
During qemu_cleanup, if a non-coroutine QMP command (e.g.,
query-commands) is concurrently received and processed by the
mon_iothread, it can lead to a deadlock in monitor_cleanup.

The root cause is a race condition between the main thread's shutdown
sequence and the coroutine's dispatching mechanism. When handling a
non-coroutine QMP command, qmp_dispatcher_co schedules the actual
command execution as a bottom half in iohandler_ctx and then yields. At
this suspended point, qmp_dispatcher_co_busy remains true.

Subsequently, the main thread in monitor_cleanup(), sets
qmp_dispatcher_co_shutdown, and calls qmp_dispatcher_co_wake(). Since
qmp_dispatcher_co_busy is already true, the aio_co_wake is skipped. The
main thread then enters the AIO_WAIT_WHILE_UNLOCKED loop, it executes
the scheduled BH (do_qmp_dispatch_bh) via aio_poll(iohandler_ctx,
false), which attempts to wake up the coroutine, aio_co_wake schedules a
new wake-up BH in iohandler_ctx. The main thread then blocks
indefinitely in aio_poll(qemu_aio_context, true), while the coroutine's
wake-up BH is starved in iohandler_ctx, qmp_dispatcher_co never reaches
termination, resulting in a deadlock.

The execution sequence is illustrated below:

 IO Thread                 Main Thread (qemu_aio_context)        qmp_dispatcher_co (iohandler_ctx)
    |                                 |                                        |
    |-- query-commands                |                                        |
    |-- qmp_dispatcher_co_wake()      |                                        |
    |    (sets busy = true)           |                                        |
    |                                 |   <-- Wakes up in iohandler_ctx -->    |
    |                                 |                                        |-- qmp_dispatch()
    |                                 |                                        |-- Schedules BH (do_qmp_dispatch_bh)
    |                                 |                                        |-- qemu_coroutine_yield()
    |                                 |                                            [State: Suspended, busy=true]
    |   [ quit triggered ]            |
    |                                 |-- monitor_cleanup()
    |                                 |-- qmp_dispatcher_co_shutdown = true
    |                                 |-- qmp_dispatcher_co_wake()
    |                                 |    -> Checks busy flag. It's TRUE!
    |                                 |    -> Skips aio_co_wake().
    |                                 |
    |                                 |-- AIO_WAIT_WHILE_UNLOCKED:
    |                                 |   |-- aio_poll(iohandler_ctx, false)
    |                                 |   |    -> Executes do_qmp_dispatch_bh
    |                                 |   |    -> Schedules 'co_schedule_bh' in iohandler_ctx
    |                                 |   |
    |                                 |   |-- aio_poll(qemu_aio_context, true)
    |                                 |   |    -> Blocks indefinitely! (Deadlock)
    |                                 |
    |                                 X (Main thread sleeping)                 X (Waiting for next iohandler_ctx poll)

To fix this, we add an explicit aio_wait_kick() in do_qmp_dispatch_bh()
to break the main loop out of its blocking poll, allowing it to evaluate
the loop condition and poll iohandler_ctx.

Suggested-by: Kevin Wolf <[email protected]>
Signed-off-by: hongmianquan <[email protected]>
Signed-off-by: wubo.bob <[email protected]>
Message-ID: <[email protected]>
Acked-by: Markus Armbruster <[email protected]>
Reviewed-by: Kevin Wolf <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
2026-03-31 15:35:19 +02:00
Alex Bennée a4d5cfe3ee MAINTAINERS: fix OSUOSL typo
It stands for Oregon State University Open Source Lab.

Signed-off-by: Alex Bennée <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-31 15:12:45 +02:00
Helge Deller 6a0e2db073 hw/hppa: Disable Artist graphics card on 64-bit machines
The original Artist graphics used the GSC bus, was often installed in old
32-bit machines (e.g. 715) and can not be used on 64-bit machines.
This is why this patch makes the artist driver dependend on the Lasi chip,
which was never used in a 64-bit machine.

Note that there exists a variant of Artist for the PCI-bus (Visualize-EG PCI).
It has quite some differences in the registers, and would require that we write
a PCI ROM for it, so that Linux and HP-UX would be able to use it.

Instead, for now, users can simply use a standard VGA or ATI PCI graphics card
on Linux.  This can be enabled on the command line with "-device ati-vga" or
"-device VGA".  If the "-nographic" option is omitted, a PCI OCHI controller
with USB keyboard and USB mouse will be added automatically.

This fixes graphics support on 64-bit hppa machines and allows us to boot up a
64-bit Linux installation with VGA graphics.

Signed-off-by: Helge Deller <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-31 15:12:45 +02:00
Helge Deller 508a870550 hw/pci-host/astro: Update copyright and documentation link
Update the link to the documentation, which was still pointing to the
Wiki page. In the meantime the PA-RISC wiki was converted to a
read-the-docs website.

Signed-off-by: Helge Deller <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Tested-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-31 15:12:45 +02:00
BALATON Zoltan 6af42f7c50 ati-vga: Add upper limit to x-linear-aper-size property
Coverity warns in CID 1645968 about possible integer overflow. This
should never happen but to ensure that, add an upper limit on the
x-linear-aper-size. This may not silence the warning but makes sure
users cannot cause an overflow.

Signed-off-by: BALATON Zoltan <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <541ffffdaa4c67b9dcbca6c2498e69b137bce95d.1774904832.git.balaton@eik.bme.hu>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-31 15:12:45 +02:00
BALATON Zoltan 3b4acaf9e6 ati-vga: Silence warning about operator precedence
Coverity in CID 1645969 warns about possible operator precendence
issue which is a false positive in this case but simplify the
expression to silence the warning.

Signed-off-by: BALATON Zoltan <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Message-ID: <24161ec41f118ad097387f8a84897dee7b4747b8.1774904832.git.balaton@eik.bme.hu>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-31 15:12:45 +02:00
Peter Maydell f2a8070d08 target/i386: Treat qtest like TCG for supported-features
In x86_cpu_get_supported_feature_word() we figure out the supported
features differently for each accelerator. The default case is
"set all feature bits"; however this triggers a warning because
it enables two features which conflict with each other:

$ ./build/x86/qemu-system-x86_64   -cpu max -accel qtest -S
qemu-system-x86_64: warning: this feature conflicts with APX: CPUID[eax=07h,ecx=00h].EBX.mpx [bit 14]
qemu-system-x86_64: warning: this feature conflicts with MPX: CPUID[eax=07h,ecx=01h].EDX.apxf [bit 21]

Treat qtest like TCG here, to avoid the complaint.

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Zhao Liu <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Zhao Liu <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-31 15:12:45 +02:00
Peter Maydell 1e0cf63987 target/i386/cpu.c: Correct minor grammar error in warning
Fix a minor error in the grammar of the warning messages
produced if both MPX and APX are enabled:

$ ./build/x86/qemu-system-x86_64   -cpu max -accel qtest -S
qemu-system-x86_64: warning: this feature conflicts with APX: CPUID[eax=07h,ecx=00h].EBX.mpx [bit 14]
qemu-system-x86_64: warning: this feature conflicts with MPX: CPUID[eax=07h,ecx=01h].EDX.apxf [bit 21]

Fixes: 91bc4d8107 ("i386/cpu: Add APX EGPRs into xsave area")
Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Zhao Liu <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-31 15:12:45 +02:00
Luigi Leonardi a85c5ed33f backends/igvm: switch to PRIx64
Use the PRIx64 format macro instead of %lX for uint64_t values.

This is to improve portability as %lX is not necessarily 64 bit long.

Signed-off-by: Luigi Leonardi <[email protected]>
Reviewed-by: Ani Sinha <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-31 15:12:45 +02:00
Trieu Huynh 07ec1a7235 target/mips: save CP0 timer in vmstate
The MIPS R4K CP0 timer (env->timer) is not included in vmstate_mips_cpu,
so after loadvm the QEMUTimer has no scheduled expiry. This causes
qemu_poll_ns() to block indefinitely and the guest to freeze until an
external I/O event (e.g. a keypress) wakes the main loop.

Fix by adding an optional vmstate subsection for the timer, following
the same pattern used by ARM (gt_timer), RISC-V (env.stimer), SPARC
(qtimer), and OpenRISC (timer).

The .needed callback returns false when env->timer is NULL (KVM mode),
keeping the subsection optional for backwards compatibility with
existing snapshots.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1987
Signed-off-by: Trieu Huynh <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-31 15:12:45 +02:00
Philippe Mathieu-Daudé 946e4d6506 MAINTAINERS: Separate QDev section from QOM one
QDev is about QEMU devices model API, while
QOM is about QEMU object model in plain C.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Michael Tokarev <[email protected]>
Message-Id: <[email protected]>
2026-03-31 15:12:45 +02:00
Shivang Upadhyay ba48bff09f ppc/pnv: generate dtb after machine initialization is complete
Currently, the machine dtb is generated in pnv_init(), before all devices
are fully initialized. This can result in an incomplete dtb for the system,
as seen in bug [1].

Fix this by deferring dtb generation until machine initialization is complete,
using the machine_init_done_notifier hook.

[1] https://lore.kernel.org/all/20260323231612.GA2637687@ax162/

Cc: Aditya Gupta <[email protected]>
Cc: Harsh Prateek Bora <[email protected]>
Cc: BALATON Zoltan <[email protected]>
Cc: [email protected]
Reported-by: Nathan Chancellor <[email protected]>
Suggested-by: Peter Maydell <[email protected]>
Fixes: a16d4c2f16 ("ppc/pnv: fix dumpdtb option")
Signed-off-by: Shivang Upadhyay <[email protected]>
Tested-by: Nathan Chancellor <[email protected]>
Reviewed-by: Aditya Gupta <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-31 15:12:45 +02:00
Yunjian Long 6bd32ce558 block: Fix references in bdrv_bsc_*() function comments
Some functions are defined in block_int-io.h, so the correct
annotation is block_int-io.h rather than block_int.h

Signed-off-by: Yunjian Long <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
2026-03-31 14:52:06 +02:00
Peter Maydell 6aeb397deb Merge tag 'for-11.0-rc-pull-request' of https://gitlab.com/marcandre.lureau/qemu into staging
Various UI & audio fixes for 11.0-rc

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCgAdFiEEh6m9kz+HxgbSdvYt2ujhCXWWnOUFAmnLmTsACgkQ2ujhCXWW
# nOUKig//Z6OlzPu5bmwwXulJpVsnwMHG5l+gftbYgs7p2XuMNFuejTQzHO6Ozns2
# chLJ3Of0xm9Z8NsQ2DZJThXjBUCanXCAOsuMYCAGy5PP2vTNBklwc6Sfm0a357cY
# um9E7GN21Kgc8CPizR/b5sv0enTZUT0JXPGapLZpuX2lOPrGpRXHA5thRtwcfaQP
# CHXJ6inWEgz3hXTTgxslvKIlwlTaH5EvjMWbjWgda//V/ZV2x8643o8n2qwO5spL
# ZY8j3TbPr10f4YnfwVcoRLfxnAswXeuk6LkJne0zv8WAQUOOkmi78H6oOmOCoJrt
# Lj08WXU+BJXZS6RKNN20eS1AmcHa2Z+59jXzwRDSRkskugeGACFlx/hbBMZwhbR9
# 0siL/dLJUdQhO/XiCYerN/HNwTy9j0lw4PWFNBBNPn66ykQQZWii4bzMWsVwt5IY
# yKhBQuAvHiN/wre0/NV914TuGWVHqwRYA37SPuLl7VfiR6hVJwTSUK7FscbswTLg
# WGjXB/uxn2XQJnYDXV9WaUHKAOIJ228HXBWLEB5vW55ZkJIl3xT5GL93kX8oFjSh
# 1vy3rVwrMO7UdS0UVhvXZC6E0tmI/fu67jcI8cQsENK6eqnXMdQEKY7otblW9LzM
# pesEUc7LKYFbYbxX8627MnbNU52HXan/XeV2otUJiX9ssUoIdag=
# =qtVg
# -----END PGP SIGNATURE-----
# gpg: Signature made Tue Mar 31 10:51:55 2026 BST
# gpg:                using RSA key 87A9BD933F87C606D276F62DDAE8E10975969CE5
# gpg: Good signature from "Marc-André Lureau <[email protected]>" [full]
# gpg:                 aka "Marc-André Lureau <[email protected]>" [full]
# Primary key fingerprint: 87A9 BD93 3F87 C606 D276  F62D DAE8 E109 7596 9CE5

* tag 'for-11.0-rc-pull-request' of https://gitlab.com/marcandre.lureau/qemu:
  tests: don't build audio tests when no audio drivers are enabled
  ui/vnc-jobs: clear source tag
  ui/vnc-jobs: fix VncRectEntry leak on job cleanup
  ui/dbus: tear down clipboard callbacks on display finalize
  ui/dbus: associate add_client completion with its request
  audio/mixeng: fix sw/hw mixup in audio_pcm_sw_init_

Signed-off-by: Peter Maydell <[email protected]>
2026-03-31 13:41:29 +01:00
Kevin Wolf ccc613f96c scsi: Don't consider LOGICAL UNIT NOT SUPPORTED guest recoverable
When commit bdf9613b introduced scsi_sense_buf_is_guest_recoverable(),
it included LOGICAL UNIT NOT SUPPORTED in the list of guest recoverable
sense codes. It doesn't really explain how the codes to be in the list
were selected.

As the LUN doesn't come from the guest, but from the block backend
(usually the SCSI device on the host that was opened with host_device,
but it could also be the iscsi block driver), there is really no way the
guest could influence this.

It seems that on some storage arrays, LOGICAL UNIT NOT SUPPORTED can
happen during failover operations. When combined with multipath, the
request should be retried on another path instead of being reported to
the guest, which would offline the filesystem in response.

Simply returning false in scsi_sense_buf_is_guest_recoverable() will
enable the retry logic in file-posix, and will also make sure that if
the error persists, the configured error policy is respected so that the
VM can be stopped.

Buglink: https://redhat.atlassian.net/browse/RHEL-158212
Fixes: bdf9613b7f ('scsi: explicitly list guest-recoverable sense codes')
Signed-off-by: Kevin Wolf <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Paolo Bonzini <[email protected]>
Reviewed-by: Stefan Hajnoczi <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
2026-03-31 14:27:28 +02:00
Kevin Wolf 59c1d31136 ide: Fix potential assertion failure on VM stop for PIO read error
ide_sector_read() as well as its callers neglect to call ide_set_retry()
before starting I/O. If the I/O fails, this means that the retry
information is stale. In particular, ide_handle_rw_error() has an
assertion that s->bus->retry_unit == s->unit, which can fail if either
there was no previous request or it came from another device on the bus.
If the assertion weren't there, a wrong request would be retried after
resuming the VM.

Fix this by adding a ide_set_retry() call to ide_sector_read().

This affects only reads because ide_transfer_start() does call
ide_set_retry(). For writes, the data transfer comes first and the I/O
is only started when the data has been read into s->io_buffer, so by
that time, ide_set_retry() has been called. For reads, however, the I/O
comes first and only then the data is transferred to the guest, so the
call in ide_transfer_start() is too late.

Buglink: https://redhat.atlassian.net/browse/RHEL-153537
Reported-by: Tingting Mao <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
2026-03-31 14:25:21 +02:00
Anton Kuchin 425f084fd2 tests: don't build audio tests when no audio drivers are enabled
When there are no audio drivers configure fails with "ERROR: Command
cannot have '@INPUT@', since no input files were specified".

Fixes: 3220b38a8d ("tests: start manual audio backend test")
Signed-off-by: Anton Kuchin <[email protected]>
Message-ID: <DB8P190MB07142E1BA8DEEA8B2E41D5B2DB57A@DB8P190MB0714.EURP190.PROD.OUTLOOK.COM>
[ Marc-André - use empty modinfo stub ]
Reviewed-by: Marc-André Lureau <[email protected]>
2026-03-31 13:48:42 +04:00
Peter Maydell 49ea010020 Merge tag 'migration-20260330-pull-request' of https://gitlab.com/farosas/qemu into staging
Migration pull request

- Fix dirty limit (-m thorough) test
- Fix a few error message strings

# -----BEGIN PGP SIGNATURE-----
#
# iQJEBAABCAAuFiEEqhtIsKIjJqWkw2TPx5jcdBvsMZ0FAmnKx94QHGZhcm9zYXNA
# c3VzZS5kZQAKCRDHmNx0G+wxnXp7EADLdY2S5gVgc8/R/b0uZRzj9f0A9vrkK2S8
# bcUHJxhY+PkJhUnNRr2l4PuyiwLCKefDWc0gnl9J0mFZ/gqVnkAPEZhVS+hOwjZm
# 6KyHWwEz9hBqU0RmIq/RmVsvKw+jRqAIZ2k43N4aOy38TbRK1o5PLrK8T4Zouycq
# grsg383xahcHUx/RZDGilGXWONeOnnv/Tg8v6rqL51eGa8BllOTZRxqMlXD/r53/
# EyLAdr3gmeawL9o7aLU6bodRwRREWGAPyvHMKB6VBautu28MsMmPjpdAbP+i3aYY
# JoKreKxO1mXvV8UL8xYOTVLbR52qACQ35Q+YKplrT4vO8yqVhN+nr8XVeQmQi2gF
# elLWi//ir6ZQggArkGSIfLdkzsyuLtNlHLtT7i35xudWUx1KcEDuT3i18OY6Qfd+
# faJr9JZPQ0I0QWMo7qRDjfUSzgYYOYoAdrfuG5xND+z2X3W4BK4E8dL4uJ5Eipad
# 8q/yRZf2KbY2vzR/VDRVUXOyVcirV0bg0v3Y7iAdaffIyia/htFvtJoZHNMhKhzU
# zoqa6VtipHJT5YLstei2Nzol9u0ghh7snWmzUKFnPjlbOfP8L11r7hNd6iYW0lFY
# GegIgZWyqwhccIAzAndqS14bwN/yRiDcH1FiZH8wYJaT4gcaTtgRzI5JGA08Ahhc
# SVKJrpsq7A==
# =ynIi
# -----END PGP SIGNATURE-----
# gpg: Signature made Mon Mar 30 19:58:38 2026 BST
# gpg:                using RSA key AA1B48B0A22326A5A4C364CFC798DC741BEC319D
# gpg:                issuer "[email protected]"
# gpg: Good signature from "Fabiano Rosas <[email protected]>" [unknown]
# gpg:                 aka "Fabiano Almeida Rosas <[email protected]>" [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: AA1B 48B0 A223 26A5 A4C3  64CF C798 DC74 1BEC 319D

* tag 'migration-20260330-pull-request' of https://gitlab.com/farosas/qemu:
  tests/qtest/migration: Fix slow test dirty_limit
  migration: Fix references to parameter names in error messages
  migration: Fix up error message for max-cpu-throttle

Signed-off-by: Peter Maydell <[email protected]>
2026-03-31 09:39:52 +01:00
Luigi Leonardi 9b4edc3eca igvm: fix parent object type in IgvmCfg struct
IgvmCfg is defined as an Object but, currently, its first member is an
ObjectClass.

Replace ObjectClass with Object.

Fixes: c1d466d267 ("backends/igvm: Add IGVM loader and configuration")
Signed-off-by: Luigi Leonardi <[email protected]>
Reviewed-by: Ani Sinha <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Gerd Hoffmann <[email protected]>
2026-03-31 08:53:47 +02:00
Luigi Leonardi 5df493476f igvm: fix memory leak on failed memory region init
When memory_region_init_* fail, `igvm_pages` is not freed causing a leak.

Free `igvm_pages` in the error path.

Fixes: c1d466d267 ("backends/igvm: Add IGVM loader and configuration")
Signed-off-by: Luigi Leonardi <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Gerd Hoffmann <[email protected]>
2026-03-31 08:53:47 +02:00
Luigi Leonardi f61ff065d3 igvm: switch to PRIx64
Use the PRIx64 format macro instead of %lX for uint64_t values.

This is to improve portability as %lX is not necessarily 64 bit long.

Signed-off-by: Luigi Leonardi <[email protected]>
Reviewed-by: Ani Sinha <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Gerd Hoffmann <[email protected]>
2026-03-31 08:53:47 +02:00
Peter Maydell d62e907c35 Merge tag 'pull-target-arm-20260330' of https://gitlab.com/pm215/qemu into staging
target-arm queue:
 * target/arm: Don't skip access flag fault for AccessType_AT
 * hw/net/rocker: Avoid double-free of l2_flood.group_ids
 * MAINTAINERS updates
 * hw/arm/xilinx_zynq: Use strcasecmp to parse boot-mode option values

# -----BEGIN PGP SIGNATURE-----
#
# iQJNBAABCAA3FiEE4aXFk81BneKOgxXPPCUl7RQ2DN4FAmnKxl0ZHHBldGVyLm1h
# eWRlbGxAbGluYXJvLm9yZwAKCRA8JSXtFDYM3i+bD/49nGG+lfkDEXxTl0CU+8Wp
# jQsZnKTox38hQA39Mdpi2yMnQLnOdjVlUloUiGp43jGnoqRRD60j3jrncytPRoPN
# ez4TZV0w/WHpGp1kj8UzKbe96XdMK6eQNSN+fnZHGsqz3F9mprQsX/qN461zIe8T
# AO4tg/Fk1omWpE7KqM6Y93T+00DcGjgjoQaVxkb97JPHsIEgZeqzZ8GZ5NgHPAWo
# +73bFW3jG3UbpCQwSycrVOduuyBMxeagnrXXlhPwrv5g7DLP5QA/F0RGj41VZD2U
# tYIGFBm3D+haQ0R6yLFHZQG3cnysroaGcw+pwSOf2M/iNV1D7h7zv3CaGsR3fgVq
# 6ZLYjCV0T0chDMCjeGAclTTYi8kLq2flMdu+RHmcN+pDP6rJjyBmRaha7jLLhRey
# bMQCYlYzZRsPn1F6wmy3mcX9Qpj4eBTFAu+fxoJ6JIOAZL6wAohfrTWPWpPI+yjK
# 9AFYEfizzonQYH/ItxWBHB5vYhq76CtsJZcwkAV5pyQsVdT87hlTjza5oNh/B6LP
# VCG6sdAdqFsgQ8ehzhnX3fNlfQe2nCcFstFnodD/6ee4rcU+Gq1op5bQW74rx+hC
# dm8EoM9iy5eJ1UTAPANlfmgUgsV/fYrCeS0vEMIvh5KEqoCARxTbPMn9iGQHgnjV
# dc8He30avuBBRh/LlOViJQ==
# =/KNp
# -----END PGP SIGNATURE-----
# gpg: Signature made Mon Mar 30 19:52:13 2026 BST
# gpg:                using RSA key E1A5C593CD419DE28E8315CF3C2525ED14360CDE
# gpg:                issuer "[email protected]"
# gpg: Good signature from "Peter Maydell <[email protected]>" [ultimate]
# gpg:                 aka "Peter Maydell <[email protected]>" [ultimate]
# gpg:                 aka "Peter Maydell <[email protected]>" [ultimate]
# gpg:                 aka "Peter Maydell <[email protected]>" [ultimate]
# Primary key fingerprint: E1A5 C593 CD41 9DE2 8E83  15CF 3C25 25ED 1436 0CDE

* tag 'pull-target-arm-20260330' of https://gitlab.com/pm215/qemu:
  hw/arm/xilinx_zynq: Use strcasecmp to parse boot-mode option values
  MAINTAINERS: Remove Igor Mitsyanko
  MAINTAINERS: Remove Riku Voipio
  hw/net/rocker: Avoid double-free of l2_flood.group_ids
  target/arm: Don't skip access flag fault for AccessType_AT

Signed-off-by: Peter Maydell <[email protected]>
2026-03-30 19:53:58 +01:00
Peter Maydell 36212b4e85 hw/arm/xilinx_zynq: Use strcasecmp to parse boot-mode option values
In zynq_set_boot_mode() where we parse the string the user has set
the boot-mode option to, we use strncasecmp(str, "qspi", 4) and so
on.  This is wrong, because it means that we will ignore any trailing
junk on the end of the option string, and handle
 -machine boot-mode=sdXYZZY
the same as
 -machine boot-mode=sd

In the documentation we say:
 Supported values are ``jtag``, ``sd``, ``qspi`` and ``nor``.
and that's obviously what we meant to implement.

The correct tool for this job is a simple strcasecmp operation.
Switch to that.

We use the g_ascii_strcasecmp() rather than plain strcasecmp()
because we're comparing ASCII strings here and don't want the
potentially locale-specific behaviour that strcasecmp() implies (and
we're trying to standardize on the glib function for this kind of
string comparison).

Fixes: 7df3747c92 ("hw/arm/xilinx_zynq: Add boot-mode property")
Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Alistair Francis <[email protected]>
Reviewed-by: Kostiantyn Kostiuk <[email protected]>
Reviewed-by: Paolo Bonzini <[email protected]>
Message-id: [email protected]
2026-03-30 16:18:07 +01:00
Peter Maydell 62ed99e8fe MAINTAINERS: Remove Igor Mitsyanko
Igor Mitsyanko doesn't wish to be listed in MAINTAINERS any more;
remove his email from the relevant sections.

Signed-off-by: Peter Maydell <[email protected]>
Message-id: [email protected]
2026-03-30 16:18:07 +01:00
Peter Maydell 4646224f2a MAINTAINERS: Remove Riku Voipio
Riku Voipio doesn't wish to be listed in MAINTAINERS any more;
remove his email from the relevant sections.

This moves the "overall usermode emulation" section to Orphan status.

Signed-off-by: Peter Maydell <[email protected]>
Message-id: [email protected]
2026-03-30 16:18:07 +01:00
Peter Maydell a0721c099b hw/net/rocker: Avoid double-free of l2_flood.group_ids
In of_dpa_cmd_add_l2_flood(), we allocate memory for the
group->l2_flood.group_ids array, freeing any previous array.
However, in the error-exit path we free the group_ids memory but do
not clear the pointer to NULL.  This means that if the guest causes
us to take the error-exit path and then later call the function
again, we will try again to free the memory we already freed.

Fix this by clearing the group_ids pointer in the error exit
path, so we maintain the invariant of "either it points at
allocated memory, or it is NULL" (both being valid to g_free()).

Cc: [email protected]
Fixes: dc488f8880 ("rocker: add new rocker switch device")
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3253
Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-id: [email protected]
2026-03-30 16:18:06 +01:00
Zenghui Yu 31b8d287b7 target/arm: Don't skip access flag fault for AccessType_AT
As per the pseudo code from DDI0487 M.a.a (on J1-16021) AArch64.S1Walk():

  // Check descriptor AF bit
  elsif (descriptor<10> == '0' && walkparams.ha == '0' &&
          (!accdesc.acctype IN {AccessType_DC, AccessType_IC} ||
           boolean IMPLEMENTATION_DEFINED "Generate access flag fault on IC/DC operations")) then
      fault.statuscode = Fault_AccessFlag;

an access flag fault should be generated for AccessType_AT, if the AF bit
is 0 and !param.ha.

Besides, we should continue to not raise the access flag fault for
in_debug = true which is what we've been doing previously (before commit
efebeec13d) for LPAE and is what intention of the debugger access
codepath is.

Cc: [email protected]
Fixes: efebeec13d ("target/arm: Skip AF and DB updates for AccessType_AT")
Signed-off-by: Zenghui Yu <[email protected]>
Message-id: [email protected]
Reviewed-by: Peter Maydell <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
2026-03-30 16:18:06 +01:00
Fabiano Rosas 6f33b6eebb tests/qtest/migration: Fix slow test dirty_limit
After the referenced commit, the incoming side doesn't exit
automatically after a failure. Tests that expect the destination to
fail should use -incoming defer, issue QMP migrate-incoming, wait for
the failure event and issue QMP quit.

Fix the dirty_limit test which wasn't updated properly.

Fixes: 4e8c4dda97 ("tests/qtest/migration: Force exit-on-error=false")
Reported-by: Thomas Huth <[email protected]>
Reviewed-by: Peter Xu <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-03-30 10:48:12 -03:00
Markus Armbruster 75ecd66028 migration: Fix references to parameter names in error messages
Migration parameter names separate words with hyphens.  A number of
error messages in migrate_params_check() use underscores instead.
Wrong since day one.  Fix them.

Signed-off-by: Markus Armbruster <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-03-30 10:46:57 -03:00
Markus Armbruster 95650cafc3 migration: Fix up error message for max-cpu-throttle
Fixes: 1a739d3012 (migration: Do away with usage of QERR_INVALID_PARAMETER_VALUE)
Signed-off-by: Markus Armbruster <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-03-30 10:46:18 -03:00
Peter Maydell dd3ee9c63d Merge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging
* more WHPX fixes and documentation
* hpet: fix bounds check for s->timer[]
* hpet: lower HPET_MAX_TIMERS to 24
* lsi53c895a: keep SCSIRequest alive during DMA
* lsi53c895a: keep device alive during SCRIPTS execution
* hw/acpi: fix save/restore for MIPS Malta machine

# -----BEGIN PGP SIGNATURE-----
#
# iQFIBAABCgAyFiEE8TM4V0tmI4mGbHaCv/vSX3jHroMFAmnKTQ0UHHBib256aW5p
# QHJlZGhhdC5jb20ACgkQv/vSX3jHroNDAQgAry87O2EtgZBK8084Rn41+8w7Hx4K
# HmKGGLRHunZgOPPbFtLFj8sjmZGqV6MuELf8zBIwheJiaWyp9SqPN2FtwldEwLsG
# C37MsUS02SbfPrJPuAMaDsfeFknHaV/pUWiZIYr5S5+dKckz8P9RUZghCVKBmwyL
# mapNE7/++A2HCX2FnABmAsMMo+kt425kCmkDFryJQ9R7j8vjYo2sHn+WpDRjOLYS
# 0K7a5HBCwE+TrdZC1Q3J17VMhX/sFL/Ms8ByIhwJa+WimZoF/roaDBiK/0iUfVlg
# 196U0rvejdymAMWqIU462fyHvVkeW50FCHjTccmqnrIbFEdL4CFZlnrNxQ==
# =JIqb
# -----END PGP SIGNATURE-----
# gpg: Signature made Mon Mar 30 11:14:37 2026 BST
# gpg:                using RSA key F13338574B662389866C7682BFFBD25F78C7AE83
# gpg:                issuer "[email protected]"
# gpg: Good signature from "Paolo Bonzini <[email protected]>" [full]
# gpg:                 aka "Paolo Bonzini <[email protected]>" [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:
  hw/acpi: Do not save/load cpuhp state unconditionally
  lsi53c895a: keep SCSIRequest alive during DMA
  lsi53c895a: keep lsi_request alive as long as the SCSIRequest
  lsi53c895a: keep lsi_request and SCSIRequest in local variables
  lsi53c895a: do not do anything else if a reset is requested by writing ISTAT0
  lsi53c895a: keep a reference to the device while SCRIPTS execute
  hpet: lower HPET_MAX_TIMERS to 24
  hpet: fix bounds check for s->timer[]
  target/i386: emulate: remove redundant logging for unmapped MMIO access
  whpx: i386: trace unsupported MSR accesses
  docs: add WHPX section with initial info
  meson.build: remove i386-softmmu WHPX support

Signed-off-by: Peter Maydell <[email protected]>
2026-03-30 13:54:56 +01:00
Peter Maydell fb66da4053 Merge tag 'pull-aspeed-20260330' of https://github.com/legoater/qemu into staging
aspeed queue:

* Complete lost interrupts fix in the Aspeed I2C model
* Fix a vlan tag insertion issue in the ftgmac100 model

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCAAdFiEEoPZlSPBIlev+awtgUaNDx8/77KEFAmnKYwYACgkQUaNDx8/7
# 7KHzlw/+OxlsY72otFxNbLWtQEOTQvWPDXvTbKsjlVtZalLM7BE/X+EqG6i9pDmj
# Reujd32F5pDX0pLzvFDqKgkQsFPW2F8jPpVMHDzZZkAjH0F5cckP/GO91WFC1F0x
# w7xlh9LKvw/LQcamR3Ptpb9+zuvG+p0O2tg+dmzUDzYwTt/Y7N25gnK9lUNup1qT
# T68Yy5Wa2YkW0J4/BGHOe9wxdM8tHz5izM69sTrb3nDnryiMWwNyMVIcDI1RyM53
# xMy2sMs/SpjxBYIl8+xfiGMGizjwVIyISb3aMC/OtLMMzxZ7PUaGSZLe63qB4kJF
# nBJ5LRxXTvsA74m9/rNk9S28lTtF4j14YVbMKj9hzt+YZzTumu20wfsTY63qja9K
# XWFqKoyD7Hrwt1grAYLWEl4mTNZNgby6091eNOWdYhv2Ogb3JWrTckCtDPWiJpeo
# c6Q9dewUSY0GDA5+2mOcVcDq4zcbZvVqdXqYH2EUasbmMLre/k/Q4zd7AOsC6U9V
# kPnd+cLPnIxMRBlzVKi/Sg2Non8QHsa/EgPyKYny9A4zGHgpGOAloSsRmv/xW3kH
# PFMpz/wIqudjpa0kJtsbE+v5iRixOTpr8oA8E8dPz8lrW9oVbRmqyQHKpIHOILq9
# M6WDnwxJDUqZS8w8Hk1hJMriQUpYPabYdwiWWdnPeyj9cWGuHFU=
# =ZxRl
# -----END PGP SIGNATURE-----
# gpg: Signature made Mon Mar 30 12:48:22 2026 BST
# gpg:                using RSA key A0F66548F04895EBFE6B0B6051A343C7CFFBECA1
# gpg: Good signature from "Cédric Le Goater <[email protected]>" [full]
# gpg:                 aka "Cédric Le Goater <[email protected]>" [full]
# Primary key fingerprint: A0F6 6548 F048 95EB FE6B  0B60 51A3 43C7 CFFB ECA1

* tag 'pull-aspeed-20260330' of https://github.com/legoater/qemu:
  net/ftgmac100: preserve full VLAN TCI in TX tag insertion
  hw/i2c/aspeed_i2c: reset and migrate pending_intr_sts

Signed-off-by: Peter Maydell <[email protected]>
2026-03-30 13:54:48 +01:00
Peter Maydell e389503e73 Merge tag 'pull-request-2026-03-30' of https://gitlab.com/thuth/qemu into staging
* Fix some warnings from pylint in the functional tests
* Fix migration of the isa-cirrus-vga device
* Remove obsolete linuxboot.bin prebuilt blob
* Fix migration functional test to check for socat instead of ncat now

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCgAdFiEEJ7iIR+7gJQEY8+q5LtnXdP5wLbUFAmnKT7YACgkQLtnXdP5w
# LbXqmA/8CUxZvJCxtODkw7jl8dX5yPRFs7HbYlY3RklhO8GhM4GHVo0ywxPAH3RG
# pkwXZwSp9I+ABY3fXwiFjMCYtM66iCR3UIateGonbREQgMn8A0EIeOQlCKF+rvaM
# HKucqanEk/lRAvuWJMEzo/3kPiUgblFieMZqUEdgTxH5YhJxi/IRq3HsESG5NKJn
# R+7u6KrgHJaZLhcLoBCRZ2FAf6wUTv+wpV58LoMsFXYQDRIsUU53u8uDWkUDy5yU
# TKMZOB0E5+Rb94apU2x3i7oAbQP8AX4fEGhzAiN00e8hjm8o5yRMHcK2aC1wpAlC
# VUnBwRPntiWGJKYMhaRS0Pe9gwTbUHvaO61GZpduK+Vip8mG8VRw1Ar71g703Zna
# AIqlJhqR4CS04I6SuF13qtJWmCOHw+sSzU8tMQe7MNGWF1rNuAk1GB5Lm5+nIm2e
# NVn6zGsI0v39ERGjUdCv2GZTZyfFdm+0+vB/nWvaCExsjVKErsaU1t/KNHL9ur2v
# 9x80CubNXy3bV8gnlgBzmgYkLxIyT6QpyPY3moKt9oHimy7XSEcMel80MiWEK8sL
# uPW2BKN+m0gUThuWG/3X9dkg/9nci81yoSpyuRvW8UBegqAFdLUjBfq/iCPNWtpI
# aX8aIgIQBoLfRGjUFBuButkWT2XQlxmp/TqT9FYkfvKAWobPNlU=
# =5aFN
# -----END PGP SIGNATURE-----
# gpg: Signature made Mon Mar 30 11:25:58 2026 BST
# gpg:                using RSA key 27B88847EEE0250118F3EAB92ED9D774FE702DB5
# gpg: Good signature from "Thomas Huth <[email protected]>" [full]
# gpg:                 aka "Thomas Huth <[email protected]>" [full]
# gpg:                 aka "Thomas Huth <[email protected]>" [full]
# gpg:                 aka "Thomas Huth <[email protected]>" [undefined]
# Primary key fingerprint: 27B8 8847 EEE0 2501 18F3  EAB9 2ED9 D774 FE70 2DB5

* tag 'pull-request-2026-03-30' of https://gitlab.com/thuth/qemu:
  tests/functional/migration.py: Skip migration_with_exec() if socat is not available
  pc-bios: remove obsolete linuxboot.bin prebuilt blob
  hw/display/cirrus_vga_isa: Disable global_vmstate by default for new machines
  hw/display/vga-isa: Fix migration of the isa-vga device
  tests/functional/qemu_test: Silence warnings from pylint in config.py
  tests/functional/qemu_test: Split huge fetch() function in asset.py
  tests/functional/qemu_test: Silence (most) warnings from pylint in asset.py

Signed-off-by: Peter Maydell <[email protected]>
2026-03-30 11:50:24 +01:00
Zhao Liu c0eaf14d93 tests/functional/migration.py: Skip migration_with_exec() if socat is not available
Commit 643a171f56 ("tests: Replace ncat with socat in migration test
and drop ncat from containers") replaced ncat with socat, but missed to
skip related test cases if socat is not available, which will cause test
errors on the system without socat.

Fix this by checking socat instead of the original ncat.

Fixes: 643a171f56 ("tests: Replace ncat with socat in migration test and drop ncat from containers")
Signed-off-by: Zhao Liu <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
2026-03-30 12:21:09 +02:00
Zhao Liu 0f254f70d4 hw/acpi: Do not save/load cpuhp state unconditionally
Commit 7aa563630b ("pc: Start with modern CPU hotplug interface
by default") removed the .needed callback (vmstate_test_use_cpuhp)
from vmstate_cpuhp_state in both piix4.c and ich9.c.

However, PIIX4 is also used by non-PC boards - MIPS Malta, which does
not select CONFIG_ACPI_CPU_HOTPLUG. For MIPS Malta, the linker resolves
vmstate_cpu_hotplug to the stub one in acpi-cpu-hotplug-stub.c, which is
a zero-initialized VMStateDescription with .fields == NULL.

Before commit 7aa563630b, .needed() of PIIX4's vmstate_cpuhp_state
returned false for MIPS Malta since PIIX4PMState always initialized the
field cpu_hotplug_legacy as true. Malta implicitly relies on this
initial value to bypass vmstate_cpuhp_state. However, this is unstable
because Malta itself does not support CPU hotplugging, whether via the
legacy way or the modern way.

Commit 7aa563630b removed .needed() check for vmstate_cpuhp_state,
this broke the existing dependency that Malta had relied on, forcing
Malta to save and load vmstate_cpuhp_state during the save/load process,
which in turn caused a segmentation fault due to NULL fields in the
stub-compiled code.

Fix this by bringing back the .needed = cpuhp_needed callback for
vmstate_cpuhp_state of PIIX4, that checks
MachineClass::has_hotpluggable_cpus. Boards that do not support CPU
hotplug (only MIPS Malta) will skip this subsection entirely, which
is both correct and consistent with the previous behavior.

At the same time, add a similar .needed() check to ICH9. Although no
boards with ICH9 are affected by this issue, this helps avoid potential
issues in the future.

Reproducer (MIPS Malta):
  $ qemu-img create -f qcow2 dummy.qcow2 32M
  $ qemu-system-mipsel -nographic \
      -drive if=none,format=qcow2,file=dummy.qcow2
  [Type "C-a c" to get the "(qemu)" monitor prompt)]
  (qemu) savevm foo    # segfault

Reported-by: Peter Maydell <[email protected]>
Fixes: 7aa563630b ("pc: Start with modern CPU hotplug interface by default")
Signed-off-by: Zhao Liu <[email protected]>
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3360
Tested-by: Peter Maydell <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-03-30 12:14:22 +02:00
Paolo Bonzini d459131ff5 lsi53c895a: keep SCSIRequest alive during DMA
Reentrant MMIO can cause the SCSIRequest to be completed, at which
point lsi_request_orphan would drop the last reference.  Anything
that happens afterwards would access freed data.  Keep a reference
to the SCSIRequest and, through req->hba_private, to the lsi_request*
for as long as DMA runs.

Reported-by: Jihe Wang <[email protected]>
Cc: [email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-03-30 12:14:22 +02:00
Paolo Bonzini 7c7aaaa342 lsi53c895a: keep lsi_request alive as long as the SCSIRequest
To protect against using the lsi_request after SCSIRequest has been freed,
keep the HBA-private data alive until the last reference to the SCSIRequest
is gone.  Because req->hba_private was used (even if just for an assertion)
to check that the request was still either current or queued, add a boolean
field that is set when the SCSIRequest is cancelled or completed, which
is when the lsi_request would have been unqueued.

Cc: [email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-03-30 12:14:22 +02:00
Paolo Bonzini 1ca38f84e1 lsi53c895a: keep lsi_request and SCSIRequest in local variables
Protect against changes from reentrant device MMIO during DMA, by always
operating on the same request.

Cc: [email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-03-30 12:14:22 +02:00
Paolo Bonzini 64807c84e8 lsi53c895a: do not do anything else if a reset is requested by writing ISTAT0
If the device is reset, anything that is done before will not really
be visible.  So do the reset and exit immediately if that is one
of the requests in the value written to ISTAT0.

Cc: [email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-03-30 12:14:17 +02:00
Marc-André Lureau eea54988fd ui/vnc-jobs: clear source tag
Avoid potentially removing a dangling source & simplify code.

Reviewed-by: Daniel P. Berrangé <[email protected]>
Signed-off-by: Marc-André Lureau <[email protected]>
2026-03-30 14:05:15 +04:00
Marc-André Lureau 3cae0b46be ui/vnc-jobs: fix VncRectEntry leak on job cleanup
When a VncJob is freed, its associated VncRectEntry list must also be
freed. Previously, vnc_job_push() and the disconnected path in
vnc_worker_thread_loop() called g_free(job) directly, leaking all
VncRectEntry allocations.

Introduce vnc_job_free() which iterates and frees the rectangle entries
before freeing the job itself, and use it in both paths.

Also add QLIST_REMOVE() in the worker loop before g_free(entry), so
that entries processed during normal operation are properly unlinked.
Without this, vnc_job_free() would iterate dangling pointers to
already-freed entries, causing use-after-free.

Fixes: bd023f953e ("vnc: threaded VNC server")
Reviewed-by: Daniel P. Berrangé <[email protected]>
Signed-off-by: Marc-André Lureau <[email protected]>
2026-03-30 14:05:10 +04:00
GuoHan Zhao e5ef268596 ui/dbus: tear down clipboard callbacks on display finalize
The clipboard D-Bus teardown path currently runs when the peer
disappears, but not when DBusDisplay itself is finalized.

That leaves pending clipboard requests and signal handlers associated
with the clipboard proxy active past display teardown.

Add an explicit clipboard fini hook and invoke it from
dbus_display_finalize() so the clipboard teardown also runs during
display destruction.

bixes: ff1a5810f6 ("ui/dbus: add clipboard interface")
Signed-off-by: GuoHan Zhao <[email protected]>
Message-ID: <[email protected]>
[ Marc-André - Move clipobard finalization to the function]
Reviewed-by: Marc-André Lureau <[email protected]>
2026-03-30 14:02:33 +04:00
GuoHan Zhao 2151a67eb6 ui/dbus: associate add_client completion with its request
Commit 99997823bb ("ui/dbus: add p2p=on/off option")
introduced an asynchronous D-Bus client setup path, with the completion
handler reaching back into the global dbus_display state.

This makes the callback effectively operate on whatever request is
current when it runs, rather than the one that created it. A completion
from an older request can therefore clear a newer
add_client_cancellable or install its connection after a replacement
request has already been issued. It also relies on the DBusDisplay
instance remaining alive until completion.

Fix this by passing the DBusDisplay and GCancellable as callback data,
taking references while the async setup is in flight, and only acting
on completion if it still matches the current request. Also drop the
previous cancellable before creating a new request.

Fixes: 99997823bb ("ui/dbus: add p2p=on/off option")
Signed-off-by: GuoHan Zhao <[email protected]>
Reviewed-by: Marc-André Lureau <[email protected]>
Message-ID: <[email protected]>
2026-03-30 14:02:32 +04:00
Marc-André Lureau 924b0be88d audio/mixeng: fix sw/hw mixup in audio_pcm_sw_init_
Commit 42061a1435 ("audio/mixeng: replace redundant pcm_info fields
with AudioFormat") accidentally changed the conv/clip function selection
in audio_pcm_sw_init_ to use hw->info.af (the hardware voice format)
instead of sw->info.af (the software voice format). This causes audio
distortion when the software and hardware voices use different formats,
as the wrong conversion functions are applied to the audio data.

Fix by using sw->info.af, restoring the original behavior.

Fixes: 42061a1435 ("audio/mixeng: replace redundant pcm_info fields with AudioFormat")
Reported-by: Dmitry Osipenko <[email protected]>
Reviewed-by: Christian Schoenebeck <[email protected]>
Signed-off-by: Marc-André Lureau <[email protected]>
2026-03-30 14:02:32 +04:00
Paolo Bonzini 4862d2c951 lsi53c895a: keep a reference to the device while SCRIPTS execute
SCRIPTS execution can trigger PCI device unplug and consequently
a use-after-free after the unplug returns.  Avoid this by keeping
the device alive.

Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3090
Cc: [email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-03-30 11:36:25 +02:00
Paolo Bonzini 7be175e65f hpet: lower HPET_MAX_TIMERS to 24
Each timer block occupies 32 bytes, but they only start at
offset 256 of the 1024-byte MMIO register space.  Therefore
the correct limit for HPET_MAX_TIMERS is 24, not 32.

Signed-off-by: Paolo Bonzini <[email protected]>
2026-03-30 11:36:25 +02:00
Paolo Bonzini 24b9ebd5f1 hpet: fix bounds check for s->timer[]
Fix an off-by-one issue in QEMU's HPET read and write MMIO handlers.
Both handlers check timer_id > s->num_timers instead of timer_id >=
s->num_timers, allowing a guest to access one timer beyond the valid
range.

The affected slot is initialized properly in hpet_realize, which goes
through all HPET_MAX_TIMERS elements of the array, so even though
it is not reset in hpet_reset() the bug does not cause any use of
uninitialized host memory.  Because of this, and also because (even
though HPET_MAX_TIMERS is 32) the HPET only has room for 24 timers in
its MMIO region, the bug has no security implications.

Commit 869b0afa4f ("rust/hpet: Drop BqlCell wrapper for num_timers",
2025-06-06) silently fixed the same bug in rust/hw/timer/hpet/src/device.rs.

Reported-by: Yuma Kurogome, Ricerca Security, Inc. <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
2026-03-30 11:36:25 +02:00
Mohamed Mediouni ee5b216c0e target/i386: emulate: remove redundant logging for unmapped MMIO access
ReactOS's install ISO does a bunch of 4-byte accesses
to 0xffdff124. This doesn't happen for the boot ISO.

It looks to be an access relative to the Windows KPCR
which is at 0xffdff000 but mistakenly done prior to
paging being on...

As this logging is redundant with -d invalid_mem,
remove it.

https://geoffchappell.com/studies/windows/km/ntoskrnl/inc/ntos/i386_x/kpcr.htm

Signed-off-by: Mohamed Mediouni <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-03-30 11:36:24 +02:00
Mohamed Mediouni 77a5deba0d whpx: i386: trace unsupported MSR accesses
Not actionable information for users, so stop
having it displayed unconditionally.

Signed-off-by: Mohamed Mediouni <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-03-30 11:36:24 +02:00
Mohamed Mediouni ea1169bca4 docs: add WHPX section with initial info
Signed-off-by: Mohamed Mediouni <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-03-30 11:36:24 +02:00
Mohamed Mediouni 1feb92de34 meson.build: remove i386-softmmu WHPX support
target/i386/emulate is pretty much incompatible
with i386-softmmu and fixing that doesn't look
worthwhile given the binary unification goals...

Signed-off-by: Mohamed Mediouni <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-03-30 11:36:24 +02:00
linhuang 9160305d92 net/ftgmac100: preserve full VLAN TCI in TX tag insertion
The VLAN tag insertion helper took vlan_tci as an 8-bit value, while
the descriptor provides a 16-bit VLAN TCI. This truncated egress tags
and caused VLAN ID corruption (for example, 4088/0x0ff8 became
248/0x00f8 at the receiver).

Change vlan_tci to uint16_t in the TX VLAN insertion path so the full
802.1Q TCI is preserved and transmitted correctly.

Fixes: c2ab73fcbe ("ftgmac100: Fix integer overflow in ftgmac100_do_tx()")
Signed-off-by: linhuang <[email protected]>
Link: https://lore.kernel.org/qemu-devel/1471e413d3589b6734819bda2b59b725b74f273a.d551129b.99fc.47f6.86dc.0759227268a2@feishu.cn
Reviewed-by: Cédric Le Goater <[email protected]>
Signed-off-by: Cédric Le Goater <[email protected]>
2026-03-30 07:36:25 +02:00
GuoHan Zhao 9c32999643 hw/i2c/aspeed_i2c: reset and migrate pending_intr_sts
Commit 7e82393ed0 ("hw/i2c/aspeed: fix lost interrupts on
back-to-back commands") introduced pending_intr_sts to preserve
interrupt bits that collide with already pending status bits.

That deferred interrupt state is consumed later when the guest clears
INTR_STS, but it is not reset in aspeed_i2c_bus_reset() and it is not
part of the bus migration state. A reset can therefore leave stale
deferred bits behind, and migration can silently drop them.

Clear pending_intr_sts on reset and include it in VMState while keeping
compatibility with older migration streams.

Fixes: 7e82393ed0 ("hw/i2c/aspeed: fix lost interrupts on back-to-back commands")
Signed-off-by: GuoHan Zhao <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Reviewed-by: Cédric Le Goater <[email protected]>
Reviewed-by: Jithu Joseph <[email protected]>
Signed-off-by: Cédric Le Goater <[email protected]>
2026-03-30 07:36:25 +02:00
Daniel P. Berrangé a2f0c836bd pc-bios: remove obsolete linuxboot.bin prebuilt blob
The corresponding source was removed in

  commit 88641f4df3
  Author: Philippe Mathieu-Daudé <[email protected]>
  Date:   Thu Jan 8 11:30:39 2026 +0800

    hw/i386: Remove linuxboot.bin

We must also remove the pre-built blob to avoid a GPL violation
from lack of complete & corresponding source.

Signed-off-by: Daniel P. Berrangé <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
2026-03-27 21:14:34 +01:00
Thomas Huth af4eea83d2 hw/display/cirrus_vga_isa: Disable global_vmstate by default for new machines
In the long run, we would like to get rid of the code that allows to
register migration state globally, so set global_vmstate to false when
using the isa-cirrus-vga device with new machines, and only enable it
for older machines to avoid breaking the migration there.

Reviewed-by: Fabiano Rosas <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
2026-03-27 21:14:34 +01:00
Thomas Huth d7189d4009 hw/display/vga-isa: Fix migration of the isa-vga device
QEMU currently crashes when migrating a guest that uses the
isa-vga device as display. This happens because vga_isa_class_initfn()
registers a vmsd for vmstate_vga_common that operates on VGACommonState.
But the isa-vga device is derived from ISADevice, not from VGACommonState,
so the migration code tries to fill in the data for VGACommonState to
the memory that is a ISADevice instead, which is of cause causing trouble.

We need an indirection here as it's also e.g. done in vga-pci.c, so
that the migration data gets filled into the right location.

While we're at it, also drop the "global_vmstate = true" here. Since
migration was broken for this device during the last 15 years (!) anyway,
we don't have to worry about maintaining backward compatibility with this
switch for older versions of QEMU anymore.

Fixes: 7435b791ca ("vga-isa: convert to qdev")
Reviewed-by: Fabiano Rosas <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
2026-03-27 21:14:34 +01:00
Thomas Huth de9698ead4 tests/functional/qemu_test: Silence warnings from pylint in config.py
Pylint complains here:

 config.py:1:0: C0114: Missing module docstring (missing-module-docstring)
 config.py:28:4: W0719: Raising too general exception: Exception (broad-exception-raised)

Add a module description and replace the general Exception to fix this.
And while we're at it, and since we've got a proper module description
string now, also replace the copy-n-pasted comment at the top of the file
with a proper SPDX identifier.

Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
2026-03-27 21:14:34 +01:00
Thomas Huth bfda4354ee tests/functional/qemu_test: Split huge fetch() function in asset.py
The fetch() function has become really huge and pylint complains about
that. Extract the internal retry-three-times-download loop into a
separate function to make it a little bit more readable and to make
pylint happy about this file again.

Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
2026-03-27 21:14:34 +01:00
Thomas Huth d22f790934 tests/functional/qemu_test: Silence (most) warnings from pylint in asset.py
Pylint currently complains:

 asset.py:1:0: C0114: Missing module docstring (missing-module-docstring)
 asset.py:21:0: C0115: Missing class docstring (missing-class-docstring)
 asset.py:28:15: C0209: Formatting a regular string which could be an f-string (consider-using-f-string)
 asset.py:34:0: C0115: Missing class docstring (missing-class-docstring)
 asset.py:49:15: C0209: Formatting a regular string which could be an f-string (consider-using-f-string)
 asset.py:73:4: C0116: Missing function or method docstring (missing-function-docstring)
 asset.py:80:4: C0116: Missing function or method docstring (missing-function-docstring)
 asset.py:83:4: C0116: Missing function or method docstring (missing-function-docstring)
 asset.py:125:4: C0116: Missing function or method docstring (missing-function-docstring)
 asset.py:181:43: C0209: Formatting a regular string which could be an f-string (consider-using-f-string)
 asset.py:190:39: C0209: Formatting a regular string which could be an f-string (consider-using-f-string)
 asset.py:201:39: C0209: Formatting a regular string which could be an f-string (consider-using-f-string)
 asset.py:213:15: W0718: Catching too general exception Exception (broad-exception-caught)
 asset.py:218:35: C0209: Formatting a regular string which could be an f-string (consider-using-f-string)
 asset.py:125:4: R0912: Too many branches (16/12) (too-many-branches)
 asset.py:125:4: R0915: Too many statements (64/50) (too-many-statements)
 asset.py:228:4: C0116: Missing function or method docstring (missing-function-docstring)
 asset.py:249:4: C0116: Missing function or method docstring (missing-function-docstring)
 asset.py:257:4: C0116: Missing function or method docstring (missing-function-docstring)

Fix all the warnings except for the R0912 and R0915 which will be tackled
in a later commit.
And while we're at it, also add a proper SPDX license identifier.

Signed-off-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
2026-03-27 21:14:34 +01:00
Peter Maydell 91f6a9cb1b Merge tag 'qga-pull-2026-03-27' of https://github.com/kostyanf14/qemu into staging
qga-pull-2026-03-27

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCgAdFiEEwsLBCepDxjwUI+uE711egWG6hOcFAmnGxwgACgkQ711egWG6
# hOdp2Q/+KEAF9+CNBJSwlfiNpC8U0SK0IzgP/PRGADUrZa422dWxmbwxyU3RkMY5
# HbFyupLCpnUn+CrmLwUyEDVXAWDox78SGPNt9L/E/GxnVKXgIi/caPayk2SSMrll
# gGlbvc4NMQc6bZwoPiqms58Fm9N0QlgA20TP8yg7doViuWOEhVK2cP8rR0TWWkQ1
# 69EJ7uEwNYhAVrC66ajPZMcH1JEmsLydNbHZK0AcsId32C+mbug71ewRTG5Uq9hS
# a1y3UaylDNuO+alLqpYj2Ej9ouTO0leSvnWOPrPGNdpONHhb5FXZ2whviiKbpAq/
# nGYi39slrxMsc67kkpnlztWwDrUW2XL2D1eF71WwAvSSGJdKd/4tJo1zvW3kMmTG
# NB4rJ7tud7ko63lsuMYnlocKgobeqDBjtY+OjDjn294gVJ5qkpWIdvbGn4pCePEZ
# EPgeRso3zoIYW0FQmOfxJ8pj3RkaINP3CvGbrbPoozYD6Q+Y3O5KEzwLCn1RofGc
# FwyaOlTAAFdTjGYveRhGfk/4TffI29MzJD2dSqdRDJNjDfhjJDK6E2MHwkEMgOXB
# 7dkZhEIssgQIGEVElVv8xb0sadAGkEWA8a0ytcdSqYGGjzgbEPWbz2Ywp5Mee+8T
# XNCam/GlzwnYSpU+Ar2VsicYK20nKeu0CO5RzuCzKJw/QZv2FF8=
# =8J6E
# -----END PGP SIGNATURE-----
# gpg: Signature made Fri Mar 27 18:06:00 2026 GMT
# gpg:                using RSA key C2C2C109EA43C63C1423EB84EF5D5E8161BA84E7
# gpg: Good signature from "Kostiantyn Kostiuk (Upstream PR sign) <[email protected]>" [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: C2C2 C109 EA43 C63C 1423  EB84 EF5D 5E81 61BA 84E7

* tag 'qga-pull-2026-03-27' of https://github.com/kostyanf14/qemu:
  scripts/qemu-guest-agent/fsfreeze-hook: Fix syslog-fallback logic
  scripts/qemu-guest-agent/fsfreeze-hook: Avoid use of PIPESTATUS
  scripts/qemu-guest-agent/fsfreeze-hook: Avoid bash-isms

Signed-off-by: Peter Maydell <[email protected]>
2026-03-27 18:41:05 +00:00
Peter Maydell bbaad5ee25 Merge tag 'pr-gh_rename-20260327' of https://gitlab.com/pbo-linaro/qemu into staging
Changes:
- [PATCH] docs and tests: assets moved after GitHub account renaming (Pierrick Bouvier <[email protected]>)
  Link: https://lore.kernel.org/qemu-devel/[email protected]

# -----BEGIN PGP SIGNATURE-----
#
# iQGzBAABCgAdFiEEZrmU7KFPfy5auggff5BUDQoc0A8FAmnGy6AACgkQf5BUDQoc
# 0A+Etgv9HpSzNWwdQ4kdKjlTH37zJzkIQ5iz4e1KefOkRGwolGc2ODF3ibiUP6hP
# 3OTBNHvOI6kkM0aYRqYlMTvyDxIXkEb8TCOfLHdO1vC8sYt9/0GqWoNrrCVPZy/a
# QH9dsNtRzHp7kKcSOPP4spe900mmGXnbEQ4mDhHp22an14MPXnnDIE1lrIBVRei6
# 06TFrhj1kVWhOqpSbMPT7YOZyDewqq+HNORnyuF7Z8w5aKZnGpmnb51x4tcwavjH
# vR+SRW6bXl0RuX9CA5XbA58OS9EINnDjCYA7Prj2fNwYZpt2dX+MRRW+SMTtbGxV
# jGWYmdygDLaj7EUSK8AJuguCS4Me3yOGyGad8PNFp0b900do/QHM/xaGxYmdIjyO
# 2IXe9bcuPa4S3WoV72VXnMtc7qEl9dPfBhLv9KExQA4MtQhF+cycf8+kTNnEaUck
# wX0oYuS4Lr/Q0b8mcMyhvr21ujc2HA6R/m/KRo0BgQ3BnzjxMR9TLMtxV6SqpVkC
# RnaBCozz
# =TSoR
# -----END PGP SIGNATURE-----
# gpg: Signature made Fri Mar 27 18:25:36 2026 GMT
# gpg:                using RSA key 66B994ECA14F7F2E5ABA081F7F90540D0A1CD00F
# gpg: Good signature from "Pierrick Bouvier <[email protected]>" [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: 66B9 94EC A14F 7F2E 5ABA  081F 7F90 540D 0A1C D00F

* tag 'pr-gh_rename-20260327' of https://gitlab.com/pbo-linaro/qemu:
  docs and tests: assets moved after GitHub account renaming

Signed-off-by: Peter Maydell <[email protected]>
2026-03-27 18:40:53 +00:00
Pierrick Bouvier d5a678c87c docs and tests: assets moved after GitHub account renaming
GitHub setup a permanent redirection for all repositories when accounts,
so the old links will keep on working also.

However, GitHub allow this username to be reused again. To ensure no one
can inject malicious content, I took ownership of the (newly free)
pbo-linaro account [1], so no one else can claim it.

[1] https://github.com/pbo-linaro

Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Pierrick Bouvier <[email protected]>
2026-03-27 11:25:02 -07:00
Peter Maydell 08497afcb2 scripts/qemu-guest-agent/fsfreeze-hook: Fix syslog-fallback logic
In the fsfreeze script we attempt to implement "log to a file if we
can, and fall back to syslog if we cannot".  We do this with:

  [ ! -w "$LOGFILE" ] && USE_SYSLOG=1
  touch "$LOGFILE" >/dev/null 2>&1 || USE_SYSLOG=1

This has a weird behaviour if it is run in a setup where we have
permissions that would allow us to write to $LOGFILE but it does not
currently exist.  On the first execution, the '-w' fails and so we
set USE_SYSLOG=1.  But since we also do the "touch $LOGFILE" step we
create an empty logfile.  Then on the second time the script is
executed, we see a writeable logfile and will use it.  The effect is
"log to syslog once, then to the logfile thereafter", which is not
likely to be what anybody wants.

Update the condition of the first check to only pick syslog if
the logfile exists but is not writable. This means that:
 * if the logfile doesn't exist but we are able to create it,
   we will create it and use it
 * if the logfile already exists and we can write to it,
   we will use it
 * if the logfile already exists but we can't write to it,
   we will fall back to syslog
 * if the logfile doesn't exist and we can't create it,
   we will fall back to syslog

Cc: [email protected]
Fixes: 85978dfb6b ("qemu-ga: Optimize freeze-hook script logic of logging error")
Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Kostiantyn Kostiuk <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Kostiantyn Kostiuk <[email protected]>
2026-03-27 19:55:01 +02:00
Peter Maydell 65b9f4791c scripts/qemu-guest-agent/fsfreeze-hook: Avoid use of PIPESTATUS
PIPESTATUS is a bash-specific construct, and this script is supposed
to be POSIX shell. We only use it in one place, to capture the exit
status of a command whose output we are piping to 'logger'.

Replace the PIPESTATUS usage with the trick described in
https://unix.stackexchange.com/questions/14270/get-exit-status-of-process-thats-piped-to-another/70675#70675
which uses a command-group to capture the status of the
first process in the pipeline.

Cc: [email protected]
Fixes: 85978dfb6b ("qemu-ga: Optimize freeze-hook script logic of logging error")
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3339
Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Kostiantyn Kostiuk <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Kostiantyn Kostiuk <[email protected]>
2026-03-27 19:55:01 +02:00
Peter Maydell b5abb655fa scripts/qemu-guest-agent/fsfreeze-hook: Avoid bash-isms
The fsfreeze-hook script starts with #!/bin/sh, but it uses
several bash-specific constructs, resulting in misbehaviour
on guest systems where /bin/sh is some other POSIX shell.

Fix the simple ones reported by shellcheck:

In scripts/qemu-guest-agent/fsfreeze-hook line 27:
touch "$LOGFILE" &>/dev/null || USE_SYSLOG=1
                 ^---------^ SC3020 (warning): In POSIX sh, &> is undefined.

In scripts/qemu-guest-agent/fsfreeze-hook line 31:
    local message="$1"
    ^-----------^ SC3043 (warning): In POSIX sh, 'local' is undefined.

In scripts/qemu-guest-agent/fsfreeze-hook line 46:
    log_message "Executing $file $@"
                                 ^-- SC2145 (error): Argument mixes string and array. Use * or separate argument.

In scripts/qemu-guest-agent/fsfreeze-hook line 55:
    if [ $STATUS -ne 0 ]; then
         ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

There is also a use of PIPESTATUS that is more complex to fix;
that will be dealt with in a separate commit.

Cc: [email protected]
Fixes: 85978dfb6b ("qemu-ga: Optimize freeze-hook script logic of logging error")
Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Kostiantyn Kostiuk <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Kostiantyn Kostiuk <[email protected]>
2026-03-27 19:55:01 +02:00
Peter Maydell 770f50c14f Merge tag 'pull-nvme-20260326' of https://gitlab.com/birkelund/qemu into staging
nvme queue

# -----BEGIN PGP SIGNATURE-----
#
# iQEzBAABCgAdFiEEUigzqnXi3OaiR2bATeGvMW1PDekFAmnE7OEACgkQTeGvMW1P
# Delfsgf/Z1L/MTif4pciPpSqvSo0D4NtaGCdqJDe+meA2/Z93SWokjDk21DoQ0qb
# A3ZdOE0jNGF3pjpWA82OWzVdk3Lur12tYvPq8HpnmoR76Ou3ZqQJlLXcLuT5jkHH
# hFJZRfu4gIGKS8Fks+MKsqwH+oB6bNpvXN87T6IpzF2U9aPqNM00wa678ALUDbjr
# rZBA7Zp0eyhCyKgB2IU+3X70tr4gQ0ZxkQrXAenzF2uWz1qsOCCvoSZvmFR8DDRV
# H5uG4fFvDXn+AceCbu/guvCtf6tiQ0cNr+SStb3DktxUU9BR3LaWXHtxlH4ic5sm
# xbc4dCE1tHo5sytu3nw/enWgSqqsYw==
# =Qmni
# -----END PGP SIGNATURE-----
# gpg: Signature made Thu Mar 26 08:22:57 2026 GMT
# gpg:                using RSA key 522833AA75E2DCE6A24766C04DE1AF316D4F0DE9
# gpg: Good signature from "Klaus Jensen <[email protected]>" [full]
# gpg:                 aka "Klaus Jensen <[email protected]>" [full]
# Primary key fingerprint: DDCA 4D9C 9EF9 31CC 3468  4272 63D5 6FC5 E55D A838
#      Subkey fingerprint: 5228 33AA 75E2 DCE6 A247  66C0 4DE1 AF31 6D4F 0DE9

* tag 'pull-nvme-20260326' of https://gitlab.com/birkelund/qemu:
  hw/nvme: fix heap-buffer-overflow in nvme_abort
  hw/nvme: re-enable wzds bit in namespace dlfeat

Signed-off-by: Peter Maydell <[email protected]>
2026-03-26 10:26:39 +00:00
Peter Maydell 0b4c378fbc Merge tag 'pr-plugins-20260325' of https://gitlab.com/pbo-linaro/qemu into staging
Changes:
- [PATCH 0/3] plugins: fix endianness for qemu_plugin_mem_get_value() (Pierrick Bouvier <[email protected]>)
   Link: https://lore.kernel.org/qemu-devel/[email protected]

# -----BEGIN PGP SIGNATURE-----
#
# iQGzBAABCgAdFiEEZrmU7KFPfy5auggff5BUDQoc0A8FAmnEWRAACgkQf5BUDQoc
# 0A/bnwv+M7tE/AxJBopnzMcAl2TAzYJXW2ZvipPutnPd83XNu5O/g1IBaQzGr06n
# 21SmDiNy7hUIW13bTPJXljycrykAgx320Fuj6R+E59Pa2D4sk7vJcwN7aJhMTgWy
# S0HhAeasHiNcPoEb8jPq6sGzS+wt4Xh+kmdjBa3CjIeerMMo/0bipUGn92Q01M81
# h+R9gDKmgtDci/fDx66Fvz8hE7P6jFTx6rHL1e1ksFBJ+FqYt9SQXQLqCcDLKzbo
# SW9k8wju1POxaKvf3Dg5vctejoogFzJCtKF7M/Fa4qo0DXzJP6eDMhlHcvzjfedJ
# xeVirOd5x3CO4AZ5KHCAoQWPu++UeGhirGhRCFc4s2MUopTwN8t4FGR0wpZxzGYC
# gNHB7/F3cm+pulMbr2MQZg3xVyy0q9+2ltNGjwo/vyjG4RxUIvNX6dsxu2sZ7Zpw
# lT1NqX0/4AlMsfeQCV3Rnx0V7+4HGarpbBZw5+Pgz2uhbP5g5ik5WBJY9rCzpwM/
# tFY4CTL4
# =NqGd
# -----END PGP SIGNATURE-----
# gpg: Signature made Wed Mar 25 21:52:16 2026 GMT
# gpg:                using RSA key 66B994ECA14F7F2E5ABA081F7F90540D0A1CD00F
# gpg: Good signature from "Pierrick Bouvier <[email protected]>" [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: 66B9 94EC A14F 7F2E 5ABA  081F 7F90 540D 0A1C D00F

* tag 'pr-plugins-20260325' of https://gitlab.com/pbo-linaro/qemu:
  tests/tcg/plugins/mem.c: fix endian swap in update_region_info
  include/plugins/qemu-plugin.h: add note about endianness of value returned by qemu_plugin_mem_get_value
  tcg: Pass host-endian values to plugin_gen_mem_callbacks_*

Signed-off-by: Peter Maydell <[email protected]>
2026-03-26 10:26:30 +00:00
Kaixuan Li eb5cc99aff hw/nvme: fix heap-buffer-overflow in nvme_abort
In nvme_abort(), the submission queue pointer is dereferenced from the
guest-controlled sqid before validating it with nvme_check_sqid():

    NvmeSQueue *sq = n->sq[sqid];

Since sqid is a 16-bit value (range 0-65535) taken directly from CDW10,
and n->sq[] is typically only max_ioqpairs+1 (65) entries, a malicious
guest can trigger an out-of-bounds heap read by sending an Abort command
with a large sqid.

ASan reports this as heap-buffer-overflow in nvme_abort.

Fix this by moving the array dereference to after the nvme_check_sqid()
bounds validation.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3348
Fixes: 75209c071a ("hw/nvme: actually implement abort")
Cc: [email protected]
Signed-off-by: Kaixuan Li <[email protected]>
Signed-off-by: Klaus Jensen <[email protected]>
2026-03-26 09:14:35 +01:00
Pankaj Raghav 55720ba97d hw/nvme: re-enable wzds bit in namespace dlfeat
dlfeat was changed from 0x9 to 0x1 when PI support was added.
It was removed because we can't rely on unmap and have to physically
clear it to get the checksums right but that doesnt mean that we do not
support the bit.

The spec says that if wzds is enabled, then the controller supports
deallocate (DEAC) on write zeroes. But DEAC bit in write zeroes command
is only a hint, the controller might choose to physically write zeroes in
those areas.

As we are sending write zeroes command with BDRV_REQ_MAY_UNMAP to the
underlying block device anyway (if the unmap operation is supported),
change the dlfeat value back to 0x9.

A new flag FALLOC_FL_WRITE_ZEROES has been introduced in linux for
fallocate which will use the wzds bit in dlfeat to quickly zeroout extents
using unmap operation whenever possible[1].

[1] https://lore.kernel.org/linux-fsdevel/[email protected]/

Fixes: 146f720c55 ("hw/block/nvme: end-to-end data protection")
Suggested-by: Klaus Jensen <[email protected]>
Signed-off-by: Pankaj Raghav <[email protected]>
Signed-off-by: Klaus Jensen <[email protected]>
2026-03-26 09:14:35 +01:00
Pierrick Bouvier e074c90947 tests/tcg/plugins/mem.c: fix endian swap in update_region_info
value returned by qemu_plugin_mem_get_value() is always in host-endian
order, so we need to convert TO target endianness and not FROM it.

Reviewed-by: Alex Bennée <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Pierrick Bouvier <[email protected]>
2026-03-25 14:51:15 -07:00
Pierrick Bouvier a08fff99be include/plugins/qemu-plugin.h: add note about endianness of value returned by qemu_plugin_mem_get_value
Reviewed-by: Pierrick Bouvier <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Pierrick Bouvier <[email protected]>
2026-03-25 14:51:15 -07:00
Richard Henderson 539421a428 tcg: Pass host-endian values to plugin_gen_mem_callbacks_*
If the host does not support swapped-endian loads and stores,
then we emulate those within the tcg expanders with explicit
bswap operations.

However, we were passing values to the plugin interface in
the middle of those bswap operations, which meant that we
would pass values of the wrong endianness to plugins when
running on hosts without swapped-endian loads and stores.

Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3351
Signed-off-by: Richard Henderson <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Tested-by: Pierrick Bouvier <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Pierrick Bouvier <[email protected]>
2026-03-25 14:51:15 -07:00
Peter Maydell 3c46691f16 Merge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging
* tests/functional: preserve PYTHONPATH entries
* target/i386: show GMET feature
* target/i386/emulate, whpx/i386: on-demand access to runtime state, MMU fixes
* tdx: fix use-after-free in tdx_fetch_cpuid
* treewide: replace qemu_hw_version() with QEMU_HW_VERSION
* sb16: detect invalid migration stream

# -----BEGIN PGP SIGNATURE-----
#
# iQFIBAABCgAyFiEE8TM4V0tmI4mGbHaCv/vSX3jHroMFAmnEGeAUHHBib256aW5p
# QHJlZGhhdC5jb20ACgkQv/vSX3jHroM8wgf/VuuB+yMlsgtDEG1jnAsQcg0gu+p6
# gIBb87RFyZKdrs6ZOtSfgyfo1XRBiHYr/UYoTIkz0PaOb+Scpq5QPKUDceGqUgAm
# g3GBtGxTN5tekQzcYFE4flIewsIFXNQh7Wgq4OWLMJqvBm3hoTEyaRMc6hS+F+S5
# Lyd81VWeV5zmer/+PdMH/gpG5+p4a+Me/NsEsd1xhnckakPbiaWJ/o76BxIt6GLo
# 3AwHuBr+l6wfg5OCv3WIz3y/HmeFuHnXYicvagoPVKgT1bH8zNeaRKeXVknl0rQn
# 6ficJOa0AyDlI9UcUBG4ivQrmdeiWMaiB+Hx2Yd+KW3DRgg8wRdp7tvlSw==
# =uGpa
# -----END PGP SIGNATURE-----
# gpg: Signature made Wed Mar 25 17:22:40 2026 GMT
# gpg:                using RSA key F13338574B662389866C7682BFFBD25F78C7AE83
# gpg:                issuer "[email protected]"
# gpg: Good signature from "Paolo Bonzini <[email protected]>" [full]
# gpg:                 aka "Paolo Bonzini <[email protected]>" [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:
  target/i386: emulate: follow priv_check_exempt
  target/i386: emulate: set PG_ERROR_W_MASK as expected
  target/i386: expose AMD GMET feature
  hw/audio/sb16: validate VMState fields in post_load
  whpx: i386: fast runtime state reads
  whpx: i386: fetch segments on-demand
  target/i386: emulate: segmentation rework
  whpx: i386: indirect access to CRs
  target/i386: emulate: indirect access to CRs
  whpx: i386: add implementation of new x86_emul_ops
  target/i386: emulate: add new callbacks
  whpx: i386: don't restore segment registers after MMIO handling
  whpx: i386: skip XCRs read for MMIO exits
  whpx: i386: skip TSC read for MMIO exits
  whpx: i386: enable exceptions VM exit only when needed
  whpx: i386: workaround for Windows 10 support
  treewide: replace qemu_hw_version() with QEMU_HW_VERSION
  tdx: fix use-after-free in tdx_fetch_cpuid
  tests/functional: preserve PYTHONPATH entries

Signed-off-by: Peter Maydell <[email protected]>
2026-03-25 19:36:04 +00:00
Mohamed Mediouni ba41e52541 target/i386: emulate: follow priv_check_exempt
Follow priv_check_exempt flag argument for
x86_write_mem_priv/x86_read_mem_priv.

Signed-off-by: Mohamed Mediouni <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-03-25 18:22:27 +01:00
Mohamed Mediouni a003cd280e target/i386: emulate: set PG_ERROR_W_MASK as expected
Make setting PG_ERROR_W_MASK no longer dependent on the access
being a priv violation.

Signed-off-by: Mohamed Mediouni <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-03-25 18:22:27 +01:00
Paolo Bonzini 746a823a17 target/i386: expose AMD GMET feature
This is implemented entirely by the hypervisor, so only the bit has to be
exposed.

Signed-off-by: Paolo Bonzini <[email protected]>
2026-03-25 18:22:27 +01:00
Jenny Guanni Qu cb1e8c18df hw/audio/sb16: validate VMState fields in post_load
The SB16 VMState loads in_index and out_data_len as raw INT32
values with no bounds validation. A crafted migration stream or
VM snapshot can set these to values exceeding their respective
buffer sizes (in2_data[10] and out_data[50]), causing heap OOB
write in dsp_write() and heap OOB read in dsp_read().

Add bounds checks in sb16_post_load() to reject invalid values
before they can be used as array indices.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3326
Reported-by: Jenny Guanni Qu <[email protected]>
Signed-off-by: Jenny Guanni Qu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Cc: [email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-03-25 18:22:27 +01:00
Mohamed Mediouni 378b1fdb1a whpx: i386: fast runtime state reads
Now that there's an on-demand interface for fetching CRs
and segments, only query GPRs and query everything else
on-demand for vmexits.

Signed-off-by: Mohamed Mediouni <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-03-25 18:22:27 +01:00
Mohamed Mediouni 9489224382 whpx: i386: fetch segments on-demand
Instead of save/restore, fetch segments dynamically.

Rely on the fetched state instead of loading from memory.

Or, if available, on the VM exit context.

Signed-off-by: Mohamed Mediouni <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-03-25 18:22:27 +01:00
Mohamed Mediouni 09442d98ab target/i386: emulate: segmentation rework
Make accesses to segments all go through read_segment_descriptor
to be able to fetch segment state on-demand.

Switch away from SegmentCache to the x86_segment_descriptor
that is already used by read_segment_descriptor.

Signed-off-by: Mohamed Mediouni <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-03-25 18:22:27 +01:00
Mohamed Mediouni 016dd86d89 whpx: i386: indirect access to CRs
Signed-off-by: Mohamed Mediouni <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-03-25 18:22:27 +01:00
Mohamed Mediouni 9548e5b2fe target/i386: emulate: indirect access to CRs
Prepare to have on-demand fetch of registers from the backend during
faults.

For x86_64 macOS, copy the function there too.

Signed-off-by: Mohamed Mediouni <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-03-25 18:22:27 +01:00
Mohamed Mediouni e2a11aea4e whpx: i386: add implementation of new x86_emul_ops
target/i386/emulate now has new ops for fetching whether the guest is in
protected mode, long mode or user mode without fetching control
registers.

Use those for faster vmexits.

Signed-off-by: Mohamed Mediouni <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-03-25 18:22:27 +01:00
Mohamed Mediouni 94ab400266 target/i386: emulate: add new callbacks
On Hyper-V fetching some guest registers is really expensive, so
add a way to query some state from information provided by Hyper-V
to save time on vmexits.

Signed-off-by: Mohamed Mediouni <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-03-25 18:22:27 +01:00
Mohamed Mediouni 40f1b4d61c whpx: i386: don't restore segment registers after MMIO handling
Signed-off-by: Mohamed Mediouni <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-03-25 18:22:27 +01:00
Mohamed Mediouni ccaa2fb7c2 whpx: i386: skip XCRs read for MMIO exits
The XCR0 value isn't currently needed for vmexit processing.

Signed-off-by: Mohamed Mediouni <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-03-25 18:22:27 +01:00
Mohamed Mediouni fe8c0a8b7d whpx: i386: skip TSC read for MMIO exits
The TSC value isn't needed for vmexit processing.

Signed-off-by: Mohamed Mediouni <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-03-25 18:22:27 +01:00
Mohamed Mediouni d2d6d91794 whpx: i386: enable exceptions VM exit only when needed
The exceptions VM exit was enabled with an empty bitmask
even when not used.

Signed-off-by: Mohamed Mediouni <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-03-25 18:22:27 +01:00
Mohamed Mediouni 68438cb3cb whpx: i386: workaround for Windows 10 support
Windows Server 2022 and later support
WHvCapabilityCodeProcessorPerfmonFeatures and
WHvPartitionPropertyCodeSyntheticProcessorFeaturesBanks.

Windows 10 supports neither of those.

As the QEMU executable doesn't have a manifest, OS version
queries do not return the actual Windows version but 6.2.9200
which corresponds to Windows 8. Windows Server 2022 and Windows
11 still use the 10.0 number, with distinction being the build
number.

As such, use the absence of perf monitoring feature query as
a cutoff to detect if a legacy OS is present.

Signed-off-by: Mohamed Mediouni <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-03-25 18:22:27 +01:00
Paolo Bonzini 3060e9b93b treewide: replace qemu_hw_version() with QEMU_HW_VERSION
The version is never set on 2.5+ machine types, so qemu_hw_version() and
qemu_set_hw_version() are not needed anymore.

Reviewed-by: Daniel P. Berrangé <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
2026-03-25 18:22:27 +01:00
Paolo Bonzini f093ee7ac3 tdx: fix use-after-free in tdx_fetch_cpuid
This is mostly harmless right now because the "if" is never
hit, but the code as written makes no sense.

Reported-by: Stefan Weil <[email protected]>
Cc: [email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-03-25 18:22:27 +01:00
Alyssa Ross 36578add66 tests/functional: preserve PYTHONPATH entries
Otherwise, it's not possible to use a packaged qemu.qmp.

Fixes: 1497377857 ("tests/functional: Prepare the meson build system for the functional tests")
Signed-off-by: Alyssa Ross <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-03-25 18:22:25 +01:00
Peter Maydell 007b29752e Merge tag 'for-upstream' of https://gitlab.com/kmwolf/qemu into staging
Block layer patches

- linux-aio/io-uring: Resubmit tails of short reads/writes
- curl: Fix memory leak

# -----BEGIN PGP SIGNATURE-----
#
# iQJFBAABCgAvFiEE3D3rFZqa+V09dFb+fwmycsiPL9YFAmnC3hgRHGt3b2xmQHJl
# ZGhhdC5jb20ACgkQfwmycsiPL9Ygxw//bxGIqnT2r9dSz8PzDfSGID21Ido7ypYP
# bUKUIPXtho85v6IbRCzKkgLXezmpoI/cbcsvnVmFbZW6Ab8ZSZxyEsZNCOQkxL34
# TwwWVI1pXtwXcfJFTb2EhE0HpHa2YQQ7N4Mg0RTcPqctywcjYs2Fz/O3cDstTEYx
# gkwpORdt4KJ4dbaRbm3UbDGzJyjWs8bZd+m7kXaJCCE1vZsmO3p1zbIkTGXt+PQJ
# Rmcg0O8kAEejTIEctOX0BYgyvCxYmhfOzDmmZwAVrlKmaeemsE8umRUCvmXAimu5
# JuKxgNJgag8xbVO41nykU0qwh0uerCOSiOwAXwh4U23MY/zBnPsbI0W985XbXCyB
# DAs2bs/GHb/z8kjhV/GzrBxpol9k2wdecy2Mgkihe4qEhffyxUsj4cz+XkN0CAZj
# /vZjCJO4FDN2zQqTQfwttU9A8pmkT9YLBdHOEMkTEWxvDjwIS8heBvB1EABW0F4J
# Bhy6z87jiWHILxdnMrmZ61UasN1GgP/fdbtFP5bhXN1LzOekfLYyfRb1B9Imwx67
# d1K3XsW2BD/ETQByUpiC/nouE6LWe5afJhKvTfg+y2L1CgAtw4jBBqpoQfALeYhv
# n2aCd69TJvarlAY9Rv2CjbQxUuouFxPzrjoS12AKW5on4iQCdCVHCywqlQIMTBbl
# kwzdLdUAEGw=
# =HiKg
# -----END PGP SIGNATURE-----
# gpg: Signature made Tue Mar 24 18:55:20 2026 GMT
# gpg:                using RSA key DC3DEB159A9AF95D3D7456FE7F09B272C88F2FD6
# gpg:                issuer "[email protected]"
# gpg: Good signature from "Kevin Wolf <[email protected]>" [full]
# Primary key fingerprint: DC3D EB15 9A9A F95D 3D74  56FE 7F09 B272 C88F 2FD6

* tag 'for-upstream' of https://gitlab.com/kmwolf/qemu:
  io-uring: Resubmit tails of short writes
  linux-aio: Resubmit tails of short reads/writes
  linux-aio: Put all parameters into qemu_laiocb
  block/curl: free s->password in cleanup paths

Signed-off-by: Peter Maydell <[email protected]>
2026-03-25 09:16:13 +00:00
Hanna Czenczek cf9cdaea6e io-uring: Resubmit tails of short writes
Short writes can happen, too, not just short reads.  The difference to
aio=native is that the kernel will actually retry the tail of short
requests internally already -- so it is harder to reproduce.  But if the
tail of a short request returns an error to the kernel, we will see it
in userspace still.  To reproduce this, apply the following patch on top
of the one shown in HEAD^ (again %s/escaped // to apply):

escaped diff --git a/block/export/fuse.c b/block/export/fuse.c
escaped index 67dc50a412..2b98489a32 100644
escaped --- a/block/export/fuse.c
escaped +++ b/block/export/fuse.c
@@ -1059,8 +1059,15 @@ fuse_co_read(FuseExport *exp, void **bufptr, uint64_t offset, uint32_t size)
     int64_t blk_len;
     void *buf;
     int ret;
+    static uint32_t error_size;

-    size = MIN(size, 4096);
+    if (error_size == size) {
+        error_size = 0;
+        return -EIO;
+    } else if (size > 4096) {
+        error_size = size - 4096;
+        size = 4096;
+    }

     /* Limited by max_read, should not happen */
     if (size > FUSE_MAX_READ_BYTES) {
@@ -1111,8 +1118,15 @@ fuse_co_write(FuseExport *exp, struct fuse_write_out *out,
 {
     int64_t blk_len;
     int ret;
+    static uint32_t error_size;

-    size = MIN(size, 4096);
+    if (error_size == size) {
+        error_size = 0;
+        return -EIO;
+    } else if (size > 4096) {
+        error_size = size - 4096;
+        size = 4096;
+    }

     QEMU_BUILD_BUG_ON(FUSE_MAX_WRITE_BYTES > BDRV_REQUEST_MAX_BYTES);
     /* Limited by max_write, should not happen */

I know this is a bit artificial because to produce this, there must be
an I/O error somewhere anyway, but if it does happen, qemu will
understand it to mean ENOSPC for short writes, which is incorrect.  So I
believe we need to resubmit the tail to maybe have it succeed now, or at
least get the correct error code.

Reproducer as before:
$ ./qemu-img create -f raw test.raw 8k
Formatting 'test.raw', fmt=raw size=8192
$ ./qemu-io -f raw -c 'write -P 42 0 8k' test.raw
wrote 8192/8192 bytes at offset 0
8 KiB, 1 ops; 00.00 sec (64.804 MiB/sec and 8294.9003 ops/sec)
$ hexdump -C test.raw
00000000  2a 2a 2a 2a 2a 2a 2a 2a  2a 2a 2a 2a 2a 2a 2a 2a  |****************|
*
00002000
$ storage-daemon/qemu-storage-daemon \
    --blockdev file,node-name=test,filename=test.raw \
    --export fuse,id=exp,node-name=test,mountpoint=test.raw,writable=true

$ ./qemu-io --image-opts -c 'read -P 23 0 8k' \
    driver=file,filename=test.raw,cache.direct=on,aio=io_uring
read 8192/8192 bytes at offset 0
8 KiB, 1 ops; 00.00 sec (58.481 MiB/sec and 7485.5342 ops/sec)
$ ./qemu-io --image-opts -c 'write -P 23 0 8k' \
    driver=file,filename=test.raw,cache.direct=on,aio=io_uring
write failed: No space left on device
$ hexdump -C test.raw
00000000  17 17 17 17 17 17 17 17  17 17 17 17 17 17 17 17  |................|
*
00001000  2a 2a 2a 2a 2a 2a 2a 2a  2a 2a 2a 2a 2a 2a 2a 2a  |****************|
*
00002000

So short reads already work (because there is code for that), but short
writes incorrectly produce ENOSPC.  This patch fixes that by
resubmitting not only the tail of short reads but short writes also.

(And this patch uses the opportunity to make it so qemu_iovec_destroy()
is called only if req->resubmit_qiov.iov is non-NULL.  Functionally a
non-op, but this is how the code generally checks whether the
resubmit_qiov has been set up or not.)

Reviewed-by: Kevin Wolf <[email protected]>
Signed-off-by: Hanna Czenczek <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
2026-03-24 19:55:09 +01:00
Peter Maydell 512b794b10 Update version for v11.0.0-rc1 release
Signed-off-by: Peter Maydell <[email protected]>
2026-03-24 18:37:34 +00:00
Hanna Czenczek 7eca3d4883 linux-aio: Resubmit tails of short reads/writes
Short reads/writes can happen.  One way to reproduce them is via our
FUSE export, with the following diff applied (%s/escaped // to apply --
if you put plain diffs in commit messages, git-am will apply them, and I
would rather avoid breaking FUSE accidentally via this patch):

escaped diff --git a/block/export/fuse.c b/block/export/fuse.c
escaped index a2a478d293..67dc50a412 100644
escaped --- a/block/export/fuse.c
escaped +++ b/block/export/fuse.c
@@ -828,7 +828,7 @@ static ssize_t coroutine_fn GRAPH_RDLOCK
 fuse_co_init(FuseExport *exp, struct fuse_init_out *out,
              const struct fuse_init_in_compat *in)
 {
-    const uint32_t supported_flags = FUSE_ASYNC_READ | FUSE_ASYNC_DIO;
+    const uint32_t supported_flags = FUSE_ASYNC_READ;

     if (in->major != 7) {
         error_report("FUSE major version mismatch: We have 7, but kernel has %"
@@ -1060,6 +1060,8 @@ fuse_co_read(FuseExport *exp, void **bufptr, uint64_t offset, uint32_t size)
     void *buf;
     int ret;

+    size = MIN(size, 4096);
+
     /* Limited by max_read, should not happen */
     if (size > FUSE_MAX_READ_BYTES) {
         return -EINVAL;
@@ -1110,6 +1112,8 @@ fuse_co_write(FuseExport *exp, struct fuse_write_out *out,
     int64_t blk_len;
     int ret;

+    size = MIN(size, 4096);
+
     QEMU_BUILD_BUG_ON(FUSE_MAX_WRITE_BYTES > BDRV_REQUEST_MAX_BYTES);
     /* Limited by max_write, should not happen */
     if (size > FUSE_MAX_WRITE_BYTES) {

Then:
$ ./qemu-img create -f raw test.raw 8k
Formatting 'test.raw', fmt=raw size=8192
$ ./qemu-io -f raw -c 'write -P 42 0 8k' test.raw
wrote 8192/8192 bytes at offset 0
8 KiB, 1 ops; 00.00 sec (64.804 MiB/sec and 8294.9003 ops/sec)
$ hexdump -C test.raw
00000000  2a 2a 2a 2a 2a 2a 2a 2a  2a 2a 2a 2a 2a 2a 2a 2a  |****************|
*
00002000

With aio=threads, short I/O works:
$ storage-daemon/qemu-storage-daemon \
    --blockdev file,node-name=test,filename=test.raw \
    --export fuse,id=exp,node-name=test,mountpoint=test.raw,writable=true

Other shell:
$ ./qemu-io --image-opts -c 'read -P 42 0 8k' \
    driver=file,filename=test.raw,cache.direct=on,aio=threads
read 8192/8192 bytes at offset 0
8 KiB, 1 ops; 00.00 sec (36.563 MiB/sec and 4680.0923 ops/sec)
$ ./qemu-io --image-opts -c 'write -P 23 0 8k' \
    driver=file,filename=test.raw,cache.direct=on,aio=threads
wrote 8192/8192 bytes at offset 0
8 KiB, 1 ops; 00.00 sec (35.995 MiB/sec and 4607.2970 ops/sec)
$ hexdump -C test.raw
00000000  17 17 17 17 17 17 17 17  17 17 17 17 17 17 17 17  |................|
*
00002000

But with aio=native, it does not:
$ ./qemu-io --image-opts -c 'read -P 23 0 8k' \
    driver=file,filename=test.raw,cache.direct=on,aio=native
Pattern verification failed at offset 0, 8192 bytes
read 8192/8192 bytes at offset 0
8 KiB, 1 ops; 00.00 sec (86.155 MiB/sec and 11027.7900 ops/sec)
$ ./qemu-io --image-opts -c 'write -P 42 0 8k' \
    driver=file,filename=test.raw,cache.direct=on,aio=native
write failed: No space left on device
$ hexdump -C test.raw
00000000  2a 2a 2a 2a 2a 2a 2a 2a  2a 2a 2a 2a 2a 2a 2a 2a  |****************|
*
00001000  17 17 17 17 17 17 17 17  17 17 17 17 17 17 17 17  |................|
*
00002000

This patch fixes that.

Reviewed-by: Kevin Wolf <[email protected]>
Signed-off-by: Hanna Czenczek <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
2026-03-24 17:34:49 +01:00
Hanna Czenczek cc03b62df4 linux-aio: Put all parameters into qemu_laiocb
Put all request parameters into the qemu_laiocb struct, which will allow
re-submitting the tail of short reads/writes.

Reviewed-by: Kevin Wolf <[email protected]>
Signed-off-by: Hanna Czenczek <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
2026-03-24 17:34:49 +01:00
GuoHan Zhao 51fc8443c1 block/curl: free s->password in cleanup paths
When password-secret is used, curl_open() resolves it with
qcrypto_secret_lookup_as_utf8() and stores the returned buffer in
s->password.

Unlike s->proxypassword, s->password is not freed either in the open
failure path or in curl_close(), so the resolved secret leaks once it
has been allocated.

Free s->password in both cleanup paths.

Fixes: 1bff960642 ('curl: add support for HTTP authentication parameters')
Signed-off-by: GuoHan Zhao <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Kevin Wolf <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
2026-03-24 17:34:49 +01:00
Peter Maydell 345e26093f Merge tag 'pull-target-arm-20260324' of https://gitlab.com/pm215/qemu into staging
target-arm queue:
 * linux-user/i386/signal.c: Correct definition of target_fpstate_32
 * hw/dma/pl080: Fix transfer logic in PL080
 * hw/arm/smmuv3-accel: Switch to OnOffAuto properties
 * qemu-options.hx: Document arm-smmuv3 device's accel properties

# -----BEGIN PGP SIGNATURE-----
#
# iQJNBAABCAA3FiEE4aXFk81BneKOgxXPPCUl7RQ2DN4FAmnCqXcZHHBldGVyLm1h
# eWRlbGxAbGluYXJvLm9yZwAKCRA8JSXtFDYM3iVhD/9SpxvYu22WidW7vO0g0Zct
# tEtSbEPO8BhXrJywEVlSMKUUQab8+eJLohftN+uLMIIEB81gWMqL6jZDA54Jk2dZ
# Pb1QiZ7CKLo52VYmZQLqgDCk/i8E71BxFGXadBQLVWIc0K8uNc0CY/1UgkyYyMSn
# eJcF4CuDjxs5cwYQwgLEQTweAH1Ki6LH+FQQWndp6LilpYXI9prFtvELtrMS7ow1
# xaUBf1FRKuJx3Dmi1QLvLGGK5c6gNu2Fbjb/l2xWeSSLG8dOx8NrmOaV3gLKlT7n
# uwZMGfWJ5HNQNfBdVmGaqu8ymYuxaEW6u9Iz8s8uLew4TJNTfuiQ5MOhS6bQULrG
# a21M13CYOjT3pSCZ647f9YI1roRonu2Q309B0ZJS8i5bG0pLpoUWLjcaF6yKYiXl
# Vifjfb2ffVnCu0XsVPDi4b/O9wJCsRNQ2L8GrCryXWmKOUbtBGw3A9Ybe6phiYkk
# 5pZYp97JPF8bwri8tnSoqjh6NseGhGSmG+qPP1I9RJ7vVPIEu+AaTT5o8byUOQPH
# xwyJYZSc1EdlgsMMwJIZ5lKW5y3RfKGVpeBnedItOC6vmrOP5kwlUZ5ZPe/PEYfR
# cG4xMKdBXq00ehGmnLsdOTnovwiDrvByoMJBXY9e6nA8tVuJlVHA5wHOsh+BvJzI
# NezPKYi5fY7KhkESB+3adQ==
# =lN4U
# -----END PGP SIGNATURE-----
# gpg: Signature made Tue Mar 24 15:10:47 2026 GMT
# gpg:                using RSA key E1A5C593CD419DE28E8315CF3C2525ED14360CDE
# gpg:                issuer "[email protected]"
# gpg: Good signature from "Peter Maydell <[email protected]>" [ultimate]
# gpg:                 aka "Peter Maydell <[email protected]>" [ultimate]
# gpg:                 aka "Peter Maydell <[email protected]>" [ultimate]
# gpg:                 aka "Peter Maydell <[email protected]>" [ultimate]
# Primary key fingerprint: E1A5 C593 CD41 9DE2 8E83  15CF 3C25 25ED 1436 0CDE

* tag 'pull-target-arm-20260324' of https://gitlab.com/pm215/qemu:
  qemu-options.hx: Document arm-smmuv3 device's accel properties
  hw/arm/smmuv3-accel: Change "oas" property type to OasMode
  qdev: Add an OasMode property type
  hw/arm/smmuv3-accel: Change "ssidsize" property type to SsidSizeMode
  qdev: Add a SsidSizeMode property type
  hw/arm/smmuv3-accel: Change "ril" property type to OnOffAuto
  hw/arm/smmuv3-accel: Change "ats" property type to OnOffAuto
  hw/arm/smmuv3-accel: Check ATS compatibility between host and guest
  hw/dma/pl080: Fix transfer logic in PL080
  linux-user/i386/signal.c: Correct definition of target_fpstate_32
  target/arm: fix s2prot not set for two-stage PMSA translations

Signed-off-by: Peter Maydell <[email protected]>
2026-03-24 15:14:12 +00:00
Peter Maydell d6037114ed Merge tag 'pull-aspeed-20260324' of https://github.com/legoater/qemu into staging
aspeed queue:

* Rework Aspeed SMC mem ops to improve error handling
* Fix race in Aspeed I2C model
* Disable kernel crypto self-tests in AST2700 boot tests

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCAAdFiEEoPZlSPBIlev+awtgUaNDx8/77KEFAmnChl4ACgkQUaNDx8/7
# 7KGAMg//Q/omDX+VVqLX9loRiM5uA3q7PIt58cED/h9zJK2OP7xLgGzGTfU2RQxW
# bqLA69PNueIdxJP4+0Y1VOvTs9cW1YJ73RX7kEH7PgQyQrWNCw7ZG7wlZiemljcN
# PqPwBm0UKfwlZnAKFiY/43/UnOxB06pFHreQSNtNK0D3EXpRQ7D7BjMI/yYN56hG
# 1RKvVV3WFk9NZP1W4ewf/5XevY2KRiY1NLokQmV8NCZntT6EVYpdwSW9P/l8kQrX
# TJf7VRwoToNjJ2yASJ5MvWFr0lucqtV8XHC2bXqFQJiIKe8dhNuo8gVr7bHvSNrd
# EWHdsW3cNnyUVhwtQAOEweag+S5K5r1+CNsxl4nJZK13dN+/ztfct7tnKqnV7Nsz
# LKTJ4dS7h3WzLtbSKk58uQJdRo66jX/1VmtlCGD8iUjRhGIjIlXqGrV2iEWR5oZI
# fsk83fIhBp5BF1IH7mrPicWFIy3oKVedbLK6eThaD3VsXcezitUaG5Se3ryzpBZE
# mJpm0NQD7YKwyon9koLwUbjAcY/FIx1i5VnYkvc0+8E10VONP5sI0UEaFr5zKhAJ
# UwF2T+odh3orRkEqcKQ0gc/TmKYkfqp9ecJrvFlu3o2w5hd+6DUpndfgvFIb/DEl
# i99acUCLcHhJfjVlAKls+5R1alV/4wqf9ERlcjgQKrD8lTXY0mA=
# =LI3x
# -----END PGP SIGNATURE-----
# gpg: Signature made Tue Mar 24 12:41:02 2026 GMT
# gpg:                using RSA key A0F66548F04895EBFE6B0B6051A343C7CFFBECA1
# gpg: Good signature from "Cédric Le Goater <[email protected]>" [full]
# gpg:                 aka "Cédric Le Goater <[email protected]>" [full]
# Primary key fingerprint: A0F6 6548 F048 95EB FE6B  0B60 51A3 43C7 CFFB ECA1

* tag 'pull-aspeed-20260324' of https://github.com/legoater/qemu:
  hw/i2c/aspeed_i2c: Remove assert
  hw/ssi/aspeed_smc: Convert mem ops to read/write_with_attrs for error handling
  tests/functional/aarch64/test_aspeed: Disable kernel crypto self-tests in AST2700 boot tests
  MAINTAINERS: Add Kane Chen as reviewer for Aspeed machines
  hw/i2c/aspeed: fix lost interrupts on back-to-back commands

Signed-off-by: Peter Maydell <[email protected]>
2026-03-24 15:14:04 +00:00
Peter Maydell 0a7bfc7a8d Merge tag 's390x-20260324' of https://gitlab.com/cohuck/qemu into staging
s390x maintainer and mailmap updates

# -----BEGIN PGP SIGNATURE-----
#
# iIgEABYKADAWIQRpo7U29cv8ZSCAJsHeiLtWQd5mwQUCacKAvBIcY29odWNrQHJl
# ZGhhdC5jb20ACgkQ3oi7VkHeZsE0xAEAmTo6hXLZS9uOsZ/fvKBPkmKFP4JptdLA
# JrIZp1BqOEMBAP6XoTzHg60UcimvnAtAquyMlw/GNAbJh/5pk1kC/2oJ
# =IX9E
# -----END PGP SIGNATURE-----
# gpg: Signature made Tue Mar 24 12:17:00 2026 GMT
# gpg:                using EDDSA key 69A3B536F5CBFC65208026C1DE88BB5641DE66C1
# gpg:                issuer "[email protected]"
# gpg: Good signature from "Cornelia Huck <[email protected]>" [marginal]
# gpg:                 aka "Cornelia Huck <[email protected]>" [full]
# gpg:                 aka "Cornelia Huck <[email protected]>" [full]
# gpg:                 aka "Cornelia Huck <[email protected]>" [marginal]
# gpg:                 aka "Cornelia Huck <[email protected]>" [marginal]
# gpg: WARNING: The key's User ID is not certified with sufficiently trusted signatures!
# gpg:          It is not certain that the signature belongs to the owner.
# Primary key fingerprint: C3D0 D66D C362 4FF6 A8C0  18CE DECF 6B93 C6F0 2FAF
#      Subkey fingerprint: 69A3 B536 F5CB FC65 2080  26C1 DE88 BB56 41DE 66C1

* tag 's390x-20260324' of https://gitlab.com/cohuck/qemu:
  mailmap: Update email for Nina Schoetterl-Glausch
  MAINTAINERS: S390 CPU topology: Change maintainer

Signed-off-by: Peter Maydell <[email protected]>
2026-03-24 15:13:52 +00:00
Nathan Chen af35bc0c14 qemu-options.hx: Document arm-smmuv3 device's accel properties
Document arm-smmuv3 properties for setting HW-acceleration,
Range Invalidation, and Address Translation Services support, as
well as setting Output Address size and Substream ID size.

Reviewed-by: Eric Auger <[email protected]>
Tested-by: Eric Auger <[email protected]>
Reviewed-by: Shameer Kolothum <[email protected]>
Tested-by: Shameer Kolothum <[email protected]>
Signed-off-by: Nathan Chen <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-03-24 14:02:30 +00:00
Nathan Chen c2ff1305cc hw/arm/smmuv3-accel: Change "oas" property type to OasMode
Change accel SMMUv3 OAS property from uint8_t to OasMode. The
'auto' value is not implemented, as this commit is meant to
set the property to the correct type and avoid breaking JSON/QMP
when the auto mode is introduced. A future patch will implement
resolution of 'auto' value to match the host SMMUv3 OAS value.

The conversion of the "oas" property type to OnOffAuto is an
incompatible change for JSON/QMP when a uint8_t value is expected for
"oas", but this property is new in 11.0 and this patch is
submitted as a fix to the property type.

Fixes: a015ac990f ("hw/arm/smmuv3-accel: Add property to specify OAS bits")
Tested-by: Eric Auger <[email protected]>
Reviewed-by: Shameer Kolothum <[email protected]>
Reviewed-by: Eric Auger <[email protected]>
Tested-by: Shameer Kolothum <[email protected]>
Acked-by: Markus Armbruster <[email protected]>
Signed-off-by: Nathan Chen <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-03-24 14:02:30 +00:00
Nathan Chen d3d2de3d22 qdev: Add an OasMode property type
Introduce a new enum type property allowing to set an Output Address
Size. Values are auto, 32, 36, 40, 42, 44, 48, 52, and 56, where a
value of N specifies an N-bit OAS.

Reviewed-by: Eric Auger <[email protected]>
Tested-by: Eric Auger <[email protected]>
Tested-by: Shameer Kolothum <[email protected]>
Acked-by: Markus Armbruster <[email protected]>
Signed-off-by: Nathan Chen <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-03-24 14:02:29 +00:00
Nathan Chen ffded86bdd hw/arm/smmuv3-accel: Change "ssidsize" property type to SsidSizeMode
Change accel SMMUv3 SSIDSIZE property from uint8_t to SsidSizeMode.
The 'auto' value is not implemented, as this commit is meant to set the
property to the correct type and avoid breaking JSON/QMP when the auto
mode is introduced. A future patch will implement resolution of 'auto'
value to match the host SMMUv3 SSIDSIZE value.

The conversion of the "ssidsize" property type to OnOffAuto is an
incompatible change for JSON/QMP when a uint8_t value is expected for
"ssidsize", but this property is new in 11.0 and this patch is
submitted as a fix to the property type.

Fixes: b8c6f8a69d ("hw/arm/smmuv3-accel: Make SubstreamID support configurable")
Tested-by: Eric Auger <[email protected]>
Reviewed-by: Shameer Kolothum <[email protected]>
Reviewed-by: Eric Auger <[email protected]>
Tested-by: Shameer Kolothum <[email protected]>
Acked-by: Markus Armbruster <[email protected]>
Signed-off-by: Nathan Chen <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-03-24 14:02:29 +00:00
Nathan Chen 3a3dd64e63 qdev: Add a SsidSizeMode property type
Introduce a new enum type property allowing to set a Substream ID size
for HW-accelerated smmuv3. Values are auto and 0..20. The auto value
allows SSID size property to be derived from host IOMMU capabilities.
A value of 0 disables SubstreamID, while non-zero values specify the
SSID size in bits.

Reviewed-by: Eric Auger <[email protected]>
Tested-by: Eric Auger <[email protected]>
Tested-by: Shameer Kolothum <[email protected]>
Acked-by: Markus Armbruster <[email protected]>
Signed-off-by: Nathan Chen <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-03-24 14:02:29 +00:00
Nathan Chen 1a76cc3933 hw/arm/smmuv3-accel: Change "ril" property type to OnOffAuto
Change accel SMMUv3 RIL property from bool to OnOffAuto. The 'auto'
value is not implemented, as this commit is meant to set the property
to the correct type and avoid breaking JSON/QMP when the auto mode is
introduced. A future patch will implement resolution of the 'auto'
value to match the host SMMUv3 RIL support.

The conversion of the RIL property type to OnOffAuto is an
incompatible change for JSON/QMP when a bool value is expected for
"ril", but the "ril" property is new in 11.0 and this patch is
submitted as a fix to the property type.

Fixes: bd715ff5bd ("hw/arm/smmuv3-accel: Add a property to specify RIL support")
Tested-by: Eric Auger <[email protected]>
Reviewed-by: Shameer Kolothum <[email protected]>
Tested-by: Shameer Kolothum <[email protected]>
Reviewed-by: Eric Auger <[email protected]>
Acked-by: Markus Armbruster <[email protected]>
Signed-off-by: Nathan Chen <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-03-24 14:02:29 +00:00
Nathan Chen 9f8a8e0f2c hw/arm/smmuv3-accel: Change "ats" property type to OnOffAuto
Change accel SMMUv3 ATS property from bool to OnOffAuto. The 'auto'
value is not implemented, as this commit is meant to set the property
to the correct type and avoid breaking JSON/QMP when the auto mode is
introduced. A future patch will implement resolution of the 'auto'
value to match the host SMMUv3 ATS support.

The conversion of the ATS property type to OnOffAuto is an
incompatible change for JSON/QMP when a bool value is expected for
"ats", but the "ats" property is new in 11.0 and this patch is
submitted as a fix to the property type.

Fixes: f7f5013a55 ("hw/arm/smmuv3-accel: Add support for ATS")
Tested-by: Eric Auger <[email protected]>
Reviewed-by: Shameer Kolothum <[email protected]>
Tested-by: Shameer Kolothum <[email protected]>
Reviewed-by: Eric Auger <[email protected]>
Acked-by: Markus Armbruster <[email protected]>
Signed-off-by: Nathan Chen <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-03-24 14:02:29 +00:00
Nathan Chen dc86d45232 hw/arm/smmuv3-accel: Check ATS compatibility between host and guest
Compare the host SMMUv3 ATS support bit with the guest SMMUv3 ATS support
bit in IDR0 and fail the compatibility check if ATS support is opted as
enabled on the guest SMMUv3 when it is not supported on host SMMUv3.

Fixes: f7f5013a55 ("hw/arm/smmuv3-accel: Add support for ATS")
Reviewed-by: Eric Auger <[email protected]>
Tested-by: Eric Auger <[email protected]>
Reviewed-by: Shameer Kolothum <[email protected]>
Tested-by: Shameer Kolothum <[email protected]>
Signed-off-by: Nathan Chen <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-03-24 14:02:29 +00:00
Tao Ding 5a2fa06b09 hw/dma/pl080: Fix transfer logic in PL080
The logic in the PL080 for transferring data has multiple bugs:

 * The TransferSize field in the channel control register counts
   in units of the source width; because our loop may do multiple
   source loads if the destination width is greater than the
   source width, we need to decrement it by (xsize / swidth),
   not by 1, each loop

 * It is documented in the TRM that it is a software error to program
   the source and destination width such that SWidth < DWidth and
   TransferSize * SWidth is not a multiple of DWidth. (This would
   mean that there isn't enough data to do a full final destination
   write.) We weren't doing anything sensible with this case.
   The TRM doesn't document what the hardware actually does (though
   it drops some hints that suggest that it probably over-reads
   from the source).

 * In the loop to write to the destination, each loop adds swidth
   to  ch->dest for each loop and also uses (ch->dest + n) as the
   destination address. This moves the destination address on
   further than we should each time round the loop, and also
   is incrementing ch->dest by swidth when it should be dwidth.

This patch fixes these problems:
 * decrement TransferSize by the correct amount
 * log and ignore the transfer size mismatch case
 * correct the loop logic for the destination writes

A repro case which exercises some of this is as follows.  It
configures swidth to 1 byte, dwidth to 4 bytes, and transfer size 4,
for a transfer from 0x00000000 to 0x000010000.  Examining the
destination memory in the QEMU monitor should show that the
source data 0x44332211 has all been copied, but before this
fix it is not:

    ./qemu-system-arm -M versatilepb -m 128M -nographic -S \
    -device loader,addr=0x00000000,data=0x44332211,data-len=4 \
    -device loader,addr=0x00001000,data=0x00000000,data-len=4 \
    -device loader,addr=0x10130030,data=0x00000001,data-len=4 \
    -device loader,addr=0x10130100,data=0x00000000,data-len=4 \
    -device loader,addr=0x10130104,data=0x00001000,data-len=4 \
    -device loader,addr=0x10130108,data=0x00000000,data-len=4 \
    -device loader,addr=0x1013010C,data=0x9e47f004,data-len=4 \
    -device loader,addr=0x10130110,data=0x0000c001,data-len=4

Without this patch the QEMU monitor shows:
    (qemu) xp /1wx 0x00001000
    00001000: 0x00002211

Correct result:
    (qemu) xp /1wx 0x00001000
    00001000: 0x44332211

Cc: [email protected]
Suggested-by: Peter Maydell <[email protected]>
Signed-off-by: Tao Ding <[email protected]>
[PMM: Wrote up what we are fixing in the commit message]
Reviewed-by: Peter Maydell <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
2026-03-24 14:02:29 +00:00
Peter Maydell 0376e9c2dd linux-user/i386/signal.c: Correct definition of target_fpstate_32
Our definition of the target_fpstate_32 struct doesn't match the
kernel's version.  We only use this struct definition in the
definition of 'struct sigframe', where it is used in a field that is
present only for legacy reasons to retain the offset of the following
'extramask' field.  So really all that matters is its length, and we
do get that right; but our previous definition using
X86LegacySaveArea implicitly added an extra alignment constraint
(because X86LegacySaveArea is tagged as 16-aligned) which the real
target_fpstate_32 does not have.  Because we allocate and use a
'struct sigframe' on the guest's stack with the guest's alignment
requirements, this resulted in the undefined-behaviour sanitizer
complaining during 'make check-tcg' for i386-linux-user:

../../linux-user/i386/signal.c:471:35: runtime error: member access within misaligned address 0x1000c07f75ec for type 'struct sigframe', which requires 16 byte alignment
0x1000c07f75ec: note: pointer points here
  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
              ^

../../linux-user/i386/signal.c:808:5: runtime error: member access within misaligned address 0x1000c07f75f4 for type 'struct target_sigcontext_32', which requires 8 byte alignment
0x1000c07f75f4: note: pointer points here
  0a 00 00 00 33 00 00 00  00 00 00 00 2b 00 00 00  2b 00 00 00 40 05 80 40  f4 7f 10 08 58 05 80 40
              ^

and various similar errors.

Replace the use of X86LegacyXSaveArea with a set of fields that match
the kernel _fpstate_32 struct, and assert that the length is correct.
We could equally have used
   uint8_t legacy_area[512];
but following the kernel is probably less confusing overall.

Since in target/i386/cpu.h we assert that X86LegacySaveArea is 512
bytes, and in linux-user/i386/signal.c we assert that
target_fregs_state is (32 + 80) bytes, the new assertion confirms
that we didn't change the size of target_fpstate_32 here, only its
alignment requirements.

Cc: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-id: [email protected]
2026-03-24 14:02:29 +00:00
Jose Martins 32ebd6c09c target/arm: fix s2prot not set for two-stage PMSA translations
Commit a811c5dafb ("target/arm: Implement get_S2prot_indirect")
changed get_phys_addr_twostage() to combine stage 1 and stage 2
permissions using the new s2prot field:

  result->f.prot = s1_prot & result->s2prot;

The LPAE stage 2 path sets result->s2prot explicitly, but the PMSA
stage 2 path (get_phys_addr_pmsav8) only sets result->f.prot, leaving
s2prot at zero. This causes the combined permission to be zero,
resulting in addr_read being set to -1 in the TLB entry and triggering
an assertion in atomic_mmu_lookup() when the guest executes an atomic
instruction on a two-stage PMSA platform (e.g. Cortex-R52 with EL2).

Set s2prot from f.prot after the PMSA stage 2 lookup, consistent with
what the LPAE path does.

Cc: [email protected]
Fixes: a811c5dafb ("target/arm: Implement get_S2prot_indirect")
Signed-off-by: Jose Martins <[email protected]>
[PMM: refer to the right commit in the commit message]
Reviewed-by: Peter Maydell <[email protected]>
Message-id: [email protected]
Reviewed-by: Gustavo Romero <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
2026-03-24 14:02:29 +00:00
Nina Schoetterl-Glausch 8a74949354 mailmap: Update email for Nina Schoetterl-Glausch
Update to my private email.

Signed-off-by: Nina Schoetterl-Glausch <[email protected]>
Reviewed-by: Matthew Rosato <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Cornelia Huck <[email protected]>
2026-03-24 11:52:11 +01:00
Gautam Gala 8ee23f993d MAINTAINERS: S390 CPU topology: Change maintainer
Replace Nina with me as the maintainer for s390 CPU topology.

Signed-off-by: Gautam Gala <[email protected]>
Reviewed-by: Eric Farman <[email protected]>
Reviewed-by: Matthew Rosato <[email protected]>
Acked-by: Nina Schoetterl-Glausch <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Cornelia Huck <[email protected]>
2026-03-24 11:52:11 +01:00
Peter Maydell fa4b2e31e6 Merge tag 'pull-trivial-patches' of https://gitlab.com/mjt0k/qemu into staging
trivial patches for 2026-03-23

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCgAdFiEEZKoqtTHVaQM2a/75gqpKJDselHgFAmnBcJwACgkQgqpKJDse
# lHhYoA//TDcPKICl5nSF7NJFOSABahHNDSXOYmPa6jX5+iViuLPHF5RFV3qUYxUQ
# cfE/jbz9eMWxJHXoCLx1/Y7rT77xQh6pFaKih/KIc1bT4vPXa9/qBAODl3SrW1JK
# 66DIzf9emkSIiJ88Xc0mA0zinSMqp0LmQmDrmPEcoW/bsDRf4QISO2DkGPLBXq7i
# MVodcISznSL5UCJSCPuIz675Hjzeb1WCOldU+OcRlZv1h9ixFWotBeuOzy02OgXZ
# F/i4VDSrwzaFpxDvo/RjCHaUWw47UTphElKdG3dikeMdHxwuomyyBSjRgTPPF7UU
# 77vMgvVwRm2/apP+qjGuU2PZ3ow6UAQ5NSaKOeyHr258i1UOtr2E/Ut0XP7vLTXf
# LkK3oqTw1+jTLq85mois8zWKgCZZ2bxV2GT5/QTxdHCC4lgpew+GAJC3G7+Tgu1j
# 4vCF3d9q9NGLwerwOQYY6dpoZFYwA/wxr5fl6eZXr1yvs9mk9wP0Xc4FSJTkU47G
# CULFn071njzjWUubT+Z3x132AuhJtfxN8Avxsw7Jqey82bMFHVoHqG9EQV8mSjSI
# 2CPKbv9z6EaHYcX8HE4ufQDrfP2WEY+I/4e11wWmpflPEg5efbPIDlJuvPlJ9XF0
# WKUjaTdoH6VE9niwHEHtf4uKId1VNfjVZjorqSJJMkse3VvGnVU=
# =TGAU
# -----END PGP SIGNATURE-----
# gpg: Signature made Mon Mar 23 16:55:56 2026 GMT
# gpg:                using RSA key 64AA2AB531D56903366BFEF982AA4A243B1E9478
# gpg: Good signature from "Michael Tokarev <[email protected]>" [full]
# gpg:                 aka "Michael Tokarev <[email protected]>" [full]
# gpg:                 aka "Michael Tokarev <[email protected]>" [full]
# Primary key fingerprint: 9D8B E14E 3F2A 9DD7 9199  28F1 61AD 3D98 ECDF 2C8E
#      Subkey fingerprint: 64AA 2AB5 31D5 6903 366B  FEF9 82AA 4A24 3B1E 9478

* tag 'pull-trivial-patches' of https://gitlab.com/mjt0k/qemu:
  Fix several typos in documentation (found by codespell)
  docs: Update GitHub URL of libu2f-emu
  Fix include statement for u2f-emu.h
  tests: fix typo in char unit test comment

Signed-off-by: Peter Maydell <[email protected]>
2026-03-24 10:41:21 +00:00
Cédric Le Goater 5fca367b89 hw/i2c/aspeed_i2c: Remove assert
According to the Aspeed datasheet, the RX_BUF_LEN_W1T and
TX_BUF_LEN_W1T bits of the A_I2CS_DMA_LEN (0x2c) register allow
firmware to program the TX and RX DMA length (TX_BUF_LEN and
RX_BUF_LEN fields of the same register) separately without the need to
read/modify/write the value.  If RX_BUF_LEN_W1T and TX_BUF_LEN_W1T
bits are 0, then both TX and RX DMA length will be written.

When setting the RX_BUF_LEN field, the TX_BUF_LEN field being set is
not an invalid condition. Remove the assert.

Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3315
Reviewed-by: Jamin Lin <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-03-24 11:19:40 +01:00
Cédric Le Goater 80c5be9458 hw/ssi/aspeed_smc: Convert mem ops to read/write_with_attrs for error handling
Error conditions (invalid flash mode, unwritable flash) now return
MEMTX_ERROR instead of silently succeeding or returning undefined
values.

This allows the memory subsystem to properly propagate transaction
errors to the guest, improving QEMU reliability.

Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3335
Reviewed-by: Jamin Lin <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-03-24 11:19:40 +01:00
Jamin Lin adbe612295 tests/functional/aarch64/test_aspeed: Disable kernel crypto self-tests in AST2700 boot tests
Disable the kernel crypto self-tests in the AST2700 functional tests by
appending "cryptomgr.notests=1" to the U-Boot bootargs before booting
the kernel.

The ASPEED SDK enables crypto self-tests during kernel startup to
validate the hardware crypto engine. However, the current QEMU
implementation of the AST2700 HACE/crypto engine is still incomplete.
As a result, the kernel crypto self-tests trigger multiple warnings
during boot when running under QEMU.

Typical examples observed in the kernel log include failures for
several cipher modes such as DES/TDES/AES in ECB/CBC/CTR modes:

alg: self-tests for ctr(des) using aspeed-ctr-des failed (rc=-22)
alg: self-tests for ecb(des3_ede) using aspeed-ecb-tdes failed (rc=-22)
alg: self-tests for cbc(aes) using aspeed-cbc-aes failed (rc=-22)
...

To reduce noise in the functional test logs, the tests now append
the following parameter to the kernel bootargs:

  cryptomgr.notests=1

This disables the kernel crypto self-tests when running the functional
tests under QEMU.

For validating the HACE implementation, we should instead rely on the
dedicated QEMU unit tests located in:

  tests/qtest/ast2700-hace-test.c

Once the QEMU implementation of the ASPEED HACE/crypto model has
progressed further and supports the missing crypto modes, we can
reassess whether enabling the kernel crypto self-tests again in the
functional tests is appropriate.

Signed-off-by: Jamin Lin <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-03-24 11:19:40 +01:00
Jamin Lin 24b5f58bee MAINTAINERS: Add Kane Chen as reviewer for Aspeed machines
Signed-off-by: Kane Chen <[email protected]>
Signed-off-by: Jamin Lin <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-03-24 11:19:40 +01:00
Jithu Joseph 7e82393ed0 hw/i2c/aspeed: fix lost interrupts on back-to-back commands
QEMU executes I2C commands synchronously inside the CMD register write
handler. On real hardware each command takes time on the bus, so the
ISR can clear the previous interrupt status before the next completion
arrives. In QEMU, when the guest ISR handles a TX_ACK and immediately
issues the next command by writing to CMD, that command completes
instantly — before the ISR returns to W1C-clear the first TX_ACK.
Since the bit is already set, setting it again is a no-op. The ISR
then clears it, wiping both completions at once. No interrupt fires
for the second command and the driver stalls.

This affects any multi-step I2C transaction: register reads, SMBus
word reads, and PMBus device probes all fail ("Error: Read failed"
from i2cget, -ETIMEDOUT from kernel drivers).

The issue is exposed when the guest kernel includes commit "i2c:
aspeed: Acknowledge Tx done with and without ACK irq late" [1] which
defers W1C acknowledgment of TX_ACK until after the ISR has issued
the next command. This means the old TX_ACK is still set when the
next command completes synchronously, and the subsequent W1C wipes
both completions at once.

The trace below shows `i2cget -y 15 0x50 0x00` (read EEPROM register
0x00) failing without the fix. The first START+TX sets TX_ACK. The
ISR handles it and issues a second TX to send the register address.
That TX completes synchronously while TX_ACK is still set:

  aspeed_i2c_bus_cmd cmd=0x3 start|tx| intr=0x0    # START+TX, clean
  aspeed_i2c_bus_raise_interrupt intr=0x1 ack|      # TX_ACK set
  aspeed_i2c_bus_read  0x10: 0x1                    # ISR reads TX_ACK
  aspeed_i2c_bus_write 0x14: 0x2                    # ISR issues TX cmd
  aspeed_i2c_bus_cmd cmd=0x400002 tx| intr=0x1      # TX runs, TX_ACK already set!
  aspeed_i2c_bus_raise_interrupt intr=0x1 ack|      # re-set is no-op
  aspeed_i2c_bus_write 0x10: 0x1                    # ISR W1C clears TX_ACK
  aspeed_i2c_bus_read  0x10: 0x0                    # LOST — both ACKs wiped

The driver sees INTR_STS=0 and never proceeds to the read phase.

Fix this by tracking interrupt bits that collide with already-pending
bits. Before calling aspeed_i2c_bus_handle_cmd(), save and clear
INTR_STS so that only freshly set bits are visible after the call.
Any overlap between the old and new bits is saved in pending_intr_sts.
When the ISR later W1C-clears the old bits, re-apply the saved
pending bits so the ISR sees them on its next loop iteration.

With the fix, the same operation completes successfully:

  aspeed_i2c_bus_cmd cmd=0x3 start|tx| intr=0x0    # START+TX, clean
  aspeed_i2c_bus_raise_interrupt intr=0x1 ack|      # TX_ACK set
  aspeed_i2c_bus_read  0x10: 0x1                    # ISR reads TX_ACK
  aspeed_i2c_bus_write 0x14: 0x2                    # ISR issues TX cmd
  aspeed_i2c_bus_cmd cmd=0x400002 tx| intr=0x0      # INTR_STS cleared first
  aspeed_i2c_bus_raise_interrupt intr=0x1 ack|      # TX_ACK freshly set
  aspeed_i2c_bus_write 0x10: 0x1                    # ISR W1C clears TX_ACK
  aspeed_i2c_bus_read  0x10: 0x1                    # RE-DELIVERED from pending
  aspeed_i2c_bus_write 0x14: 0x1b                   # ISR proceeds: START+RX
  aspeed_i2c_bus_cmd cmd=0x40001b start|tx|rx|last| # read phase completes
  i2c_recv recv(addr:0x50) data:0x00                # data received

[1] https://lore.kernel.org/all/[email protected]/

Signed-off-by: Jithu Joseph <[email protected]>
Fixes: 1602001195 ("i2c: add aspeed i2c controller")
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-03-24 11:19:40 +01:00
Peter Maydell 750ed363eb Merge tag 'hw-misc-20260323' of https://github.com/philmd/qemu into staging
Misc HW patches

- Fix guest-triggerable abort in FTGMAC100 Gigabit Ethernet
- Fix uninitialized value in DesignWare I3C controller
- Clear dangling GLib event source tag in virtio-console
- Mark RISC-V specific peripherals as little-endian
- Correct virtual address formatting in monitor
- Improve error handling path in core loader
- Improve error hints in IOMMU FD
- Prevent hang in USB OHCI
- ATI VGA, HyperV & CXL fixes

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCAAdFiEE+qvnXhKRciHc/Wuy4+MsLN6twN4FAmnBb5cACgkQ4+MsLN6t
# wN408A/8DQPa8l7uB/hJ397oWjPeRTvC18V5g7xa9DkC5m82GqqbNYj5RDCajD9T
# /o/SQUdOhxXfl6wkCirpZj9qsVdhPuXh4G+CziIju6XJIJFGYf8zxvz1Z3kNn3sU
# fsFuE+P6zQXUUNspowNOnQWa/eHbCqsTa+uhVvFccVcOYOeU0ptLjm6P1CptTyrS
# 7en27DO2/RqejvcI7fPThZCdplC0HPdy7UGM4AnvKOXUGNz4aNurMJrWw92ZHxLu
# EQ8cB3o4CUoFJbJGokhP/Xcc+YHXlzJKPw9SlSXGMCdp1e1s/Z1YaWM+6BnmcqDZ
# M+8/RZ57owr5yF77KpYpuN+weWwMBlvISXr0MNa14HHJi3sEoOPxPZ/8X5vhcPUi
# sXrwrLrDtIEPeloCKDbbafdLwrFI7nqvQyldbnVdnqncrX1v8WOFPQO4m2WuD5TL
# pY0zzfSqlCyUj0sycn19yVyTH0rjybmrhsJpjDut4Qvoy2Ng1geBsSq+WVIamDnN
# e2iLVMspgQX8Klr+fcae0INRHKXdpIEt0ITroxwx0rq88ITQQbijGXgn0N0T5rWF
# f1RDg6toyz5s6//dgjK8j/vCEhQ4YRxfNreqo8gH6V/8II9jzkGyfj2g/PaWKlDr
# CZXmHtSWG+adRQLdb0/xJjG3eej3qmivMP7+0v+utNcb2DoEUZw=
# =+5Iw
# -----END PGP SIGNATURE-----
# gpg: Signature made Mon Mar 23 16:51:35 2026 GMT
# gpg:                using RSA key FAABE75E12917221DCFD6BB2E3E32C2CDEADC0DE
# gpg: Good signature from "Philippe Mathieu-Daudé (F4BUG) <[email protected]>" [full]
# Primary key fingerprint: FAAB E75E 1291 7221 DCFD  6BB2 E3E3 2C2C DEAD C0DE

* tag 'hw-misc-20260323' of https://github.com/philmd/qemu: (27 commits)
  hw/hyperv: add QEMU_PACKED to uapi structs
  monitor: Correctly display virtual addresses while dumping memory
  hw/net/ftgmac100: Improve DMA error handling
  ati-vga: Make sure hardware cursor data is within vram
  ati-vga: Simplify pointer image handling
  ati-vga: Add work around for fuloong2e
  ati-vga: Fix display updates in non-32 bit modes
  ati-vga: Avoid warnings about sign extension
  ati-vga: Do not add crtc offset to src and dst data address
  ati-vga: Also switch mode on HW cursor enable bit change
  ati-vga: Fix colors when frame buffer endianness does not match host
  hw/usb/hcd-ohci: check for MPS=0 to avoid infinite loop
  hw/hyperv: Fix SynIC not initialized except on first vCPU
  hw/vfio/iommufd: report hint to user when vfio-dev/vfio*/dev is missing
  backends/iommufd: report error when /dev/iommu is not available
  hw/cxl: Exclude Discovery from Media Operation Discovery output
  hw/cxl: Respect Media Operation max ops discovery semantics
  hw/i386/hyperv: add stubs for synic enablement
  hw/i386/pc_sysfw: stub out x86_firmware_configure
  hw/pci/msix: fix error handling for msix_init callers
  ...

Signed-off-by: Peter Maydell <[email protected]>
2026-03-23 16:58:15 +00:00
Peter Maydell 88a338f9d1 Merge tag 'pull-11.0-testing-updates-230326-1' of https://gitlab.com/stsquad/qemu into staging
testing updates: tcg, functional, lcitool

  - add TCG_TEST_FILTER to filter check-tcg runs
  - use portable version of dirent64 in linux-test
  - add VBSA linux tests
  - drop python3-sqlite from deps
  - update openSUSE to version 16
  - replace ncat with socat for migration tests

# -----BEGIN PGP SIGNATURE-----
#
# iQEzBAABCgAdFiEEZoWumedRZ7yvyN81+9DbCVqeKkQFAmnBPPwACgkQ+9DbCVqe
# KkRwEQf+MGnOOKRVoRU4eRjp/OqcYEBzR5L3SU/lLVZ261tqGpes2ZlMdsam1cBS
# yk/Cv+M9vHPpD0qKo1opo6CB8pBn6cjcPHE09bUxvgcylok9ZfPTMp/z9RLllW0l
# 8WhVkQ+dzWJj4tWoAcOjWgadgGhf4sp6whUX/TC3wSSpGFRR/2MERlCQab9743dR
# dSh3+NUp43h9wgb2AixKwrefos8Wv3NH5/p6BZ3IHEvD7Apwuo4RkTEebloCfJFk
# 67GbxslbOYBYNTjkVRR0o3CATDXOmI7804T1TPKI/nc/KSumY0BcR2omDqc8JVqt
# 7OmlRxpWRJ1DN7omlaHVPbGJRcww1A==
# =1leB
# -----END PGP SIGNATURE-----
# gpg: Signature made Mon Mar 23 13:15:40 2026 GMT
# gpg:                using RSA key 6685AE99E75167BCAFC8DF35FBD0DB095A9E2A44
# gpg: Good signature from "Alex Bennée (Master Work Key) <[email protected]>" [full]
# Primary key fingerprint: 6685 AE99 E751 67BC AFC8  DF35 FBD0 DB09 5A9E 2A44

* tag 'pull-11.0-testing-updates-230326-1' of https://gitlab.com/stsquad/qemu:
  tests: Replace ncat with socat in migration test and drop ncat from containers
  tests/docker: Update the opensuse-leap container file to version 16
  tests/lcitool: Update openSUSE to version 16
  tests/lcitool: Remove python3-sqlite3 from the list of needed packages
  tests/functional: add VBSA linux tests
  tests/functional: allow tests to define decompression target
  tests/tcg/multiarch/linux-test: use portable alternative for dirent64
  tests/tcg: allow filtering of TCG tests

Signed-off-by: Peter Maydell <[email protected]>
2026-03-23 16:58:07 +00:00
Stefan Weil b7ae542de4 Fix several typos in documentation (found by codespell)
Signed-off-by: Stefan Weil <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
[Mjt: add 2 fixes suggested by Peter: "as a" and "deactivate"]
Reviewed-by: Michael Tokarev <[email protected]>
Signed-off-by: Michael Tokarev <[email protected]>
2026-03-23 19:55:24 +03:00
Stefan Weil bcf5e68cc9 docs: Update GitHub URL of libu2f-emu
This avoids a redirect from the old to the new URL.

Signed-off-by: Stefan Weil <[email protected]>
Reviewed-by: Michael Tokarev <[email protected]>
Signed-off-by: Michael Tokarev <[email protected]>
2026-03-23 19:55:20 +03:00
Stefan Weil 4ef8aca3d1 Fix include statement for u2f-emu.h
All examples on https://github.com/Agnoctopus/libu2f-emu/ don't
simply include u2f-emu.h without any added directory.

The additional include directory does not exist when libu2f
was built with meson.

It's up to pkgconfig to make sure that u2f-emu.h is found in any case.

Signed-off-by: Stefan Weil <[email protected]>
Reviewed-by: Michael Tokarev <[email protected]>
Signed-off-by: Michael Tokarev <[email protected]>
2026-03-23 19:55:16 +03:00
Magnus Kulke 070fc71025 hw/hyperv: add QEMU_PACKED to uapi structs
The uapi definitions are marked with __packed hints in the kernel
headers, since we want to keep the contract of the Microsoft Hypervisor
ABI explicit, we should also added them in our vendored files, with a
few notable exceptions where the attribute is a noop.

Signed-off-by: Magnus Kulke <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
[PMD: Do not include "qemu/compiler.h"]
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-23 17:50:50 +01:00
Philippe Mathieu-Daudé 083072dba0 monitor: Correctly display virtual addresses while dumping memory
While reworking the address format width in commit 6ad593a75a we
introduce a bug, leading to addresses being displayed with too many
zeroes:

  $ qemu-system-ppc -monitor stdio -S
  QEMU 10.2.90 monitor - type 'help' for more information
  (qemu) x/x 0
  0000000000000000000000000000000000000000000000000000000000000000: 0x00000000
  (qemu) x/x 0xfff00000
  00000000000000000000000000000000000000000000000000000000fff00000: 0x60000000

  $ qemu-system-ppc64 -monitor stdio -S
  QEMU 10.2.90 monitor - type 'help' for more information
  (qemu) x/x 0
  00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000: 0x00000000

Correct the format width to restore the previous behavior:

  $ qemu-system-ppc -monitor stdio -S
  QEMU 10.2.90 monitor - type 'help' for more information
  (qemu) x/x 0
  00000000: 0x00000000

  $ qemu-system-ppc64 -monitor stdio -S
  QEMU 10.2.90 monitor - type 'help' for more information
  (qemu) x/x 0
  0000000000000000: 0x00000000

Fixes: 6ad593a75a ("monitor/hmp: Use plain uint64_t @addr argument in memory_dump()")
Reported-by: BALATON Zoltan <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Message-Id: <[email protected]>
2026-03-23 17:50:50 +01:00
Cédric Le Goater fa4a759fc1 hw/net/ftgmac100: Improve DMA error handling
Currently, DMA memory operation errors in the ftgmac100 model are not
all tested and this can lead to a guest-triggerable denial of service
as described in https://gitlab.com/qemu-project/qemu/-/work_items/3335.

To fix this, check the return value of ftgmac100_write_bd() in the TX
path and exit the TX loop on error to prevent further processing. In
the event of a DMA error, also set FTGMAC100_INT_AHB_ERR interrupt
flag as appropriate.

The FTGMAC100_INT_AHB_ERR interrupt status bit only applies to the
AST2400 SoC; on newer Aspeed SoCs, it is a reserved bit.
Nevertheless, since it is supported by the Linux driver and it should
be safe to use in the QEMU implementation across all SoCs.

Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3335
Signed-off-by: Cédric Le Goater <[email protected]>
Reviewed-by: Jamin Lin <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-23 17:50:50 +01:00
BALATON Zoltan 2f1fbe6ee9 ati-vga: Make sure hardware cursor data is within vram
Add check to make sure we don't read past the end of vram when getting
mouse pointer image.

Signed-off-by: BALATON Zoltan <[email protected]>
Message-ID: <2ecf42bdeb96a4206b27dc39b3ff13cc8a6190d0.1774110169.git.balaton@eik.bme.hu>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-23 17:50:50 +01:00
BALATON Zoltan 28df2e5469 ati-vga: Simplify pointer image handling
Rewrite reading of mouse pointer image. I am not sure this is entirely
correct but appears to work at least on little endian host with PPC
guests using little or big endian frame buffer (MorphOS and MacOS) but
still produces broken pointer image with Linux where I am not sure if
it is a guest driver bug or still missing something.

Signed-off-by: BALATON Zoltan <[email protected]>
Message-ID: <b9de530074b954d661a0eb9b8b4ad82a66085456.1774110169.git.balaton@eik.bme.hu>
[PMD: Replaced BIT() -> BIT_ULL() in ati_cursor_draw_line()]
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-23 17:50:50 +01:00
BALATON Zoltan c1315534f3 ati-vga: Add work around for fuloong2e
With the linear aperture size fixed to match real card fuloong2e no
longer works due to running out of PCI memory because only one PCI bus
is emulated on that machine. Add a property to allow fuloong2e to set
a smaller linear aperture size to work around that problem until the
machine model is improved.

Signed-off-by: BALATON Zoltan <[email protected]>
Reviewed-by: Chad Jablonski <[email protected]>
Message-ID: <47cbdc7ad2291f22467f9fc86e7287eb8983c927.1774110169.git.balaton@eik.bme.hu>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-23 17:50:50 +01:00
BALATON Zoltan b7c0d01719 ati-vga: Fix display updates in non-32 bit modes
The memory_region_set_dirty used to mark changes should use stride
value in vram which is normally only the same as surface_stride in 32
bit modes. This caused missed updates in 8 and 16 bit modes.

Signed-off-by: BALATON Zoltan <[email protected]>
Reviewed-by: Chad Jablonski <[email protected]>
Message-ID: <6e1b83ef3fe7a1ebc246b474eb2b0c7cd05d5deb.1774110169.git.balaton@eik.bme.hu>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-23 17:50:50 +01:00
BALATON Zoltan 4588ef5176 ati-vga: Avoid warnings about sign extension
Coverity reports several possible sign extension errors (latest is CID
1645615). These cannot happen because the values are limited when
writing the registers and only 32 bits of the return value matter but
change type of the variable storing the return value to uint32_t to
avoid these warnings. Also change DEFAULT_SC_BOTTOM_RIGHT register
read to match what other similar registers do for consistency.

Signed-off-by: BALATON Zoltan <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Message-ID: <9a3263a06bc72aa5a56bafe0a11ad189d5f60528.1774110169.git.balaton@eik.bme.hu>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-23 17:50:50 +01:00
BALATON Zoltan eca8b4c99b ati-vga: Do not add crtc offset to src and dst data address
Drivers seem to program these registers with values that already
include the crtc offset so this is not needed. This fixes blit outside
of vram errors with non-0 crtc offset.

Signed-off-by: BALATON Zoltan <[email protected]>
Reviewed-by: Chad Jablonski <[email protected]>
Message-ID: <7d96c67f864845893d4903b988a4da7c7b010f66.1774110169.git.balaton@eik.bme.hu>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-23 17:50:50 +01:00
BALATON Zoltan 5c520d976a ati-vga: Also switch mode on HW cursor enable bit change
This does nothing for most drivers but works around issue and fixes
output with the Solaris R128 driver that only sets display parameters
after enabling CRT controller which we would miss otherwise.

Signed-off-by: BALATON Zoltan <[email protected]>
Tested-by: Chad Jablonski <[email protected]>
Reviewed-by: Chad Jablonski <[email protected]>
Message-ID: <ad3f415749178984c764f4ba810c663d1299ddfd.1774110169.git.balaton@eik.bme.hu>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-23 17:50:50 +01:00
BALATON Zoltan d0f1fdc37c ati-vga: Fix colors when frame buffer endianness does not match host
When writing pixels we have to take into account if the frame buffer
endianness matches the host endianness or we need to swap to correct
endianness. This caused wrong colors e.g. with PPC Linux guest that
uses big endian frame buffer when running on little endian host.

Signed-off-by: BALATON Zoltan <[email protected]>
Tested-by: Chad Jablonski <[email protected]>
Reviewed-by: Chad Jablonski <[email protected]>
Message-ID: <759ed5e3b019cce94e9a4ef003f1fc2e0cea2ec1.1774110169.git.balaton@eik.bme.hu>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-23 17:50:50 +01:00
Jenny Guanni Qu 129922c2bc hw/usb/hcd-ohci: check for MPS=0 to avoid infinite loop
When a guest sets MaxPacketSize to 0 in an OHCI Endpoint Descriptor,
ohci_service_td() transfers 0 bytes per iteration. The Transfer
Descriptor never completes because CBP never advances toward BE,
causing ohci_service_ed_list() to loop indefinitely and hang QEMU.

Add a check for MPS==0 after extracting the field from ED flags.
If MPS is zero, call ohci_die() to reset the controller and return
an error, preventing the infinite loop.

Fixes: CVE-2026-3890
Reported-by: Jenny Guanni Qu <[email protected]>
Signed-off-by: Jenny Guanni Qu <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-23 17:50:50 +01:00
Sourav Poddar 4f7a06ec25 hw/hyperv: Fix SynIC not initialized except on first vCPU
hyperv_is_synic_enabled() is a global flag that returns true after the
first CPU initializes SynIC. With -smp N, all subsequent CPUs skip
hyperv_x86_synic_add(), leaving them without a synic object. This causes
get_synic() to return NULL, making hyperv_sint_route_new() fail and
triggering an assertion crash in hyperv_testdev.

Fix by introducing hyperv_is_synic_present() which checks per-CPU
whether a synic object is already attached instead of using the global
flag.

Fixes: c4cf32fc63 ("kvm/hyperv: add synic feature to CPU only if its not enabled")
Reported-by: Xudong Hao <[email protected]>
Co-authored-by: Ani Sinha <[email protected]>
Signed-off-by: Sourav Poddar <[email protected]>
Tested-by: Xudong Hao <[email protected]>
Message-ID: <[email protected]>
[PMD: Reworded subject]
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-23 17:50:30 +01:00
Pierrick Bouvier 04249f0f94 hw/vfio/iommufd: report hint to user when vfio-dev/vfio*/dev is missing
Give a hint about missing kernel config CONFIG_VFIO_DEVICE_CDEV.

Reviewed-by: Yi Liu <[email protected]>
Reviewed-by: Zhenzhong Duan <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Pierrick Bouvier <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-23 17:48:06 +01:00
Pierrick Bouvier 45a0241365 backends/iommufd: report error when /dev/iommu is not available
In case current kernel does not support /dev/iommu, qemu will probably
fail first because /sys/bus/pci/devices/*/vfio-dev/ is not present,
since QEMU opens it before /dev/iommu.

Instead, report an error directly when completing an iommufd object, to
inform user that kernel does not support it, with a hint about missing
CONFIG_IOMMUFD. We can't do this from initialize as there is no way to
return an error, and we don't want to abort at this step.

Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Signed-off-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Zhenzhong Duan <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-23 17:48:06 +01:00
Davidlohr Bueso 20beec283b hw/cxl: Exclude Discovery from Media Operation Discovery output
Per CXL 4.0 Table 8-331, the Discovery operation "returns a list of
all Media Operations that the device supports, with the exception of
the Discovery operation (Class=0, Subclass=0)."

Filter out Discovery entries when building the output list and adjust
total_supported_operations accordingly.

Fixes: 77a8e9fe0e ("hw/cxl/cxl-mailbox-utils: Add support for Media operations discovery commands cxl r3.2 (8.2.10.9.5.3)")
Reviewed-by: Jonathan Cameron <[email protected]>
Signed-off-by: Davidlohr Bueso <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-23 17:48:06 +01:00
Davidlohr Bueso bc72b2996c hw/cxl: Respect Media Operation max ops discovery semantics
The Discovery rejects requests where start_index + num_ops
exceeds the total number of supported operations. Per CXL 4.0
Table 8-332, num_ops is the "Maximum number of Media Operation to
return" - a maximum, not an exact count. The device should return
up to that many entries, not reject the request.

Cap num_ops to the available entries from start_index instead of
erroring the command.

Fixes: 77a8e9fe0e ("hw/cxl/cxl-mailbox-utils: Add support for Media operations discovery commands cxl r3.2 (8.2.10.9.5.3)")
Reviewed-by: Jonathan Cameron <[email protected]>
Signed-off-by: Davidlohr Bueso <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-23 17:48:06 +01:00
Ani Sinha 6c21a067a7 hw/i386/hyperv: add stubs for synic enablement
Add a new call hyperv_enable_synic() that can be called whether or not
CONFIG_HYPERV is enabled. This way genetic code in i396/kvm.c can call this
function to enable synic for hyperv. For non-hyperv cases, the stub will
be a noop.

Reported-by: Michale Tokarev <[email protected]>
Signed-off-by: Ani Sinha <[email protected]>
Reviewed-by: Michael Tokarev <[email protected]>
Tested-by: Michael Tokarev <[email protected]>
Message-ID: <[email protected]>
Tested-by: Xudong Hao <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-23 17:27:29 +01:00
Ani Sinha c78bac1e67 hw/i386/pc_sysfw: stub out x86_firmware_configure
x86_firmware_configure requires ovmf support. Add a stub for this function call
for cases where OVMF is not supported.

Reported-by: Michael Tokarev <[email protected]>
Signed-off-by: Ani Sinha <[email protected]>
Reviewed-by: Michael Tokarev <[email protected]>
Tested-by: Michael Tokarev <[email protected]>
Message-ID: <[email protected]>
Tested-by: Xudong Hao <[email protected]>
[PMD: Remove "kvm/tdx.h" include line]
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-23 17:27:26 +01:00
Trieu Huynh 08324de90d hw/pci/msix: fix error handling for msix_init callers
Check return value of msix_init() and return early on
failure instead of continuing with invalid state.
- Use ret < 0 to handle negative return value.
- Use errp parameter to handle failure instead of NULL.
- No functional changes.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/413
Signed-off-by: Trieu Huynh <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-23 14:54:13 +01:00
Trieu Huynh 8953fd41e6 util/event_notifier: fix error handling for event_notifier_init callers
Check return value of event_notifier_init() and return early on
failure instead of continuing with invalid state.
- Use ret < 0 to handle negative return value.
- No functional changes.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/413
Signed-off-by: Trieu Huynh <[email protected]>
Acked-by: Anthony Krowiak <[email protected]>
Reviewed-by: Jagannathan Raman <[email protected]>
Reviewed-by: Maciej S. Szmigiero <[email protected]> # for the Hyper-V part
Reviewed-by: Matthew Rosato <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-23 14:54:13 +01:00
Trieu Huynh 5e69353ff1 hw/core/loader: fix error handling for get_image_size callers
Check the return value of get_image_size() and report failures
for non-mandatory file such as FRU image.

- Use ret < 0 to detect failures in getting image size.
- No functional changes.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/413
Signed-off-by: Trieu Huynh <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-23 14:54:13 +01:00
Trieu Huynh b06bb02721 hw/core/loader: fix error handling for load_image_targphys callers
Use QEMU's Error API to handle load_image_targphys() failures
consistently across callers.

- Use &error_fatal for callers that previously passed NULL, ensuring
the process exits early on failure instead of continuing in an invalid
state.
- No functional changes.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/413
Signed-off-by: Trieu Huynh <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-23 14:54:13 +01:00
Jamin Lin 56bd07a859 hw/i3c/dw-i3c: Fix uninitialized data use in short transfer
Coverity reports that dw_i3c_short_transfer() may pass an
uninitialized buffer to dw_i3c_send().

The immediate cause is the use of `data[len] += arg.byte0`, which
reads from an uninitialized element of the buffer. Replace this with
a simple assignment.

Additionally, avoid calling dw_i3c_send() when the constructed payload
length is zero. In that case the transfer has no data phase, so the
controller can transition to the idle state directly.

This resolves the Coverity UNINIT warning and clarifies the handling
of zero-length short transfers.

Resolves: Coverity CID 1645555
Signed-off-by: Jamin Lin <[email protected]>
Reviewed-by: Nabih Estefan <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-23 14:54:13 +01:00
Matthew Penney 34aad58901 hw/char/virtio-console: clear dangling GLib event source tag
Clear dangling GLib event source tag when virtio-console is
unrealized. This prevents a stale tag from being used, and
maintains consistency with the rest of virtio-console.

Signed-off-by: Matthew Penney <[email protected]>
Reviewed-by: Marc-André Lureau <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-23 14:54:13 +01:00
Alireza Sanaee ea24be6cdd hw/cxl: Use HPA in cxl_cfmws_find_device() rather than offset in window.
This function will shortly be used to help find if there is a route to a
device, serving an HPA, under a particular fixed memory window. Rather than
having that new use case subtract the base address in the caller, only to
add it again in cxl_cfmws_find_device(), push the responsibility for
calculating the HPA to the caller.

This also reduces the inconsistency in the meaning of the hwaddr addr
parameter between this function and the calls made within it that access
the HDM decoders that operating on HPA.

Reviewed-by: Li Zhijian <[email protected]>
Reviewed-by: Jonathan Cameron <[email protected]>
Reviewed-by: Gregory Price <[email protected]>
Tested-by: Gregory Price <[email protected]>
Signed-off-by: Alireza Sanaee <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-23 14:54:13 +01:00
Philippe Mathieu-Daudé cf430fa1f1 hw/riscv: Mark RISC-V specific peripherals as little-endian
These devices are only used by the RISC-V targets, which are
only built as little-endian. Therefore the DEVICE_NATIVE_ENDIAN
definition expand to DEVICE_LITTLE_ENDIAN (besides, the
DEVICE_BIG_ENDIAN case isn't tested). Simplify directly
using DEVICE_LITTLE_ENDIAN.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Alistair Francis <[email protected]>
Message-Id: <[email protected]>
2026-03-23 14:54:13 +01:00
Thomas Huth 643a171f56 tests: Replace ncat with socat in migration test and drop ncat from containers
nmap / ncat has a somewhat problematic license (e.g. saying claiming
that derived work is also considered for software that "is designed
specifically to execute Covered Software and parse the results", e.g.
by executing ncat from your own program, you might already fall into
this category) - so for example in openSUSE 16, you can only find it
in the "non-OSS" repository.

We are currently only using it in the migration functional test, and
that likely does not fall into this "derived work" category yet (since
it is also doing some other stuff), but still, to be safe, we should
move away from using it now.

Unfortunately, switching to one of the other flavors of netcat is
also not a real option (see commit f700abbbeb),
but socat should be a solid replacement here instead.

To avoid that someone else easily uses ncat again, let's also remove
it from our container files now.

Suggested-by: Daniel P. Berrangé <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
Acked-by: Peter Xu <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alex Bennée <[email protected]>
2026-03-23 13:13:07 +00:00
Thomas Huth b68e5bc1ed tests/docker: Update the opensuse-leap container file to version 16
Run "make lcitool-refresh" to update the container file to the latest
version of openSUSE.

Signed-off-by: Thomas Huth <[email protected]>
Reviewed-by: Alex Bennée <[email protected]>
Message-ID: <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alex Bennée <[email protected]>
2026-03-23 13:13:07 +00:00
Thomas Huth 5859803c77 tests/lcitool: Update openSUSE to version 16
The first version of openSUSE 15 has been released in 2018, and
according to our support policy, we "support the most recent major
version at all times for up to five years after its initial release."

Since openSUSE 16 has been released a while ago, and openSUSE is
clearly older than 5 years already, it's time to update to version 16
now.

Signed-off-by: Thomas Huth <[email protected]>
Reviewed-by: Alex Bennée <[email protected]>
Message-ID: <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alex Bennée <[email protected]>
2026-03-23 13:13:07 +00:00
Thomas Huth 31fb808acf tests/lcitool: Remove python3-sqlite3 from the list of needed packages
According to commit 7485508341 ("tests/docker: Add sqlite3 module to
openSUSE Leap container") that introduced this line, the sqlite3 package
was only required for Avocado. We don't use Avocado in QEMU anymore since
a while, so we can drop this package now from our list again.

Signed-off-by: Thomas Huth <[email protected]>
Reviewed-by: Alex Bennée <[email protected]>
Message-ID: <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alex Bennée <[email protected]>
2026-03-23 13:13:07 +00:00
Alex Bennée da10beeb8a tests/functional: add VBSA linux tests
This extends the VBSA test to run the linux tests. The sysarch-acs
test suite does provide some pre-built images which is good because
the tests require a patched kernel. However due to the structure of
the image we need to jump one or two hoops to get something useful:

  - download and double decompress (zip then xz) the image
  - navigate grub to launch the Linux Execution Environment
  - shutdown the system once tests are done
  - extract the logs from the MSDOS file system and parse them

It does make the code a bit ugly but it works for me at least. So far
the subset of tests run is limited but that might be solved by adding
some more devices to the PCIe bus to exercise the SMMU behaviour.

Reviewed-by: Pierrick Bouvier <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alex Bennée <[email protected]>
2026-03-23 13:13:07 +00:00
Alex Bennée 6ba3255d29 tests/functional: allow tests to define decompression target
When dealing with multi-stage decompression we want to specify the
target file name lest we just overload the cache name. It also allows
for something is little more friendly than the cache hash.

Reviewed-by: Pierrick Bouvier <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alex Bennée <[email protected]>
2026-03-23 13:13:07 +00:00
Matheus Tavares Bernardino e413f66f53 tests/tcg/multiarch/linux-test: use portable alternative for dirent64
dirent64 and readdir64 are glibc-specific and not portable to other
C libraries such as musl. Define _FILE_OFFSET_BITS=64 instead, which
portably instructs all libc implementations to use 64-bit file offsets,
making readdir() and struct dirent equivalent to their 64-bit variants.

Signed-off-by: Matheus Tavares Bernardino <[email protected]>
Reviewed-by: Brian Cain <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Message-ID: <af31d21c4d668cfb940ba4159f584fa6454c3d82.1772107448.git.matheus.bernardino@oss.qualcomm.com>
Message-ID: <[email protected]>
Signed-off-by: Alex Bennée <[email protected]>
2026-03-23 13:13:07 +00:00
Alex Bennée fb37a16694 tests/tcg: allow filtering of TCG tests
We have a lot of TCG tests now which can be fiddly if we just want to
check one particular test type across the targets. Introduce
TCG_TEST_FILTER to allow this:

  make check-tcg TCG_TEST_FILTER=gdb

to run all the gdb tests across the suites.

Reviewed-by: Pierrick Bouvier <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alex Bennée <[email protected]>
2026-03-23 13:13:07 +00:00
xieyi 317268a354 tests: fix typo in char unit test comment
Signed-off-by: xieyi <[email protected]>
Reviewed-by: Michael Tokarev <[email protected]>
Signed-off-by: Michael Tokarev <[email protected]>
2026-03-23 15:14:34 +03:00
Peter Maydell eb153d8fd3 Merge tag 'pull-target-arm-20260323' of https://gitlab.com/pm215/qemu into staging
target-arm queue:
 * tests/qtest/arm-cpu-features: Fix thinko in g_strdup_printf() call
 * configure: Remove unused variable default_cflags
 * whpx: arm: Various fixes, notably making '-cpu host' work
 * configs/targets: Restrict the legacy ldst_phys() API on ARM / Aarch64
 * hw/isa/piix: Embed i8259 irq in device state instead of allocating

# -----BEGIN PGP SIGNATURE-----
#
# iQJNBAABCAA3FiEE4aXFk81BneKOgxXPPCUl7RQ2DN4FAmnBG80ZHHBldGVyLm1h
# eWRlbGxAbGluYXJvLm9yZwAKCRA8JSXtFDYM3h5sEACn3SqYA+ejIyK9oZA4B7cV
# DGAvIjU8cmqn3iIEBBFxYYaGYOAhR+MrDZxk2myeEq2c9yzNTYm0jyE4zWyLZZ9o
# jH9XgtdhcLxdtGrs0OujxBjMOg2ORgLlPLyFAblhZ9dmIrko/TMJE8ZQojx4Ys7g
# I9KUJJhF3pK8M6io0QNzaFbDZTHFQjBUDMK6RdF+xLnreYUbNJQmzxQ310c4PsBj
# NVZT1Bx2PWqZrOE5sK+925y/dCbxl4yIEdbRq2hHG5CkHPD8nLV9khLq1B+/lHUZ
# PcpP4VbE8hyPw1lCQspzp4JaUMtj2Nj9+nzdGE81/f6uupfHwy8ZbYbE04bVBaLi
# CHT6TTiR18Zb2Hvo8adKhIeUR6UjMVWYe+RpQWLec41TIeAsGbaiAY8RAlFSt0AL
# Yg6oGgDCvMexqq68iAO6IuU6dZ587dmTAM++BpGt4776jNWjvMeSH5iLiW7vWs1s
# ONxIQmm3QqyZtoMbV9PPgs5YKiWP6dCWRun2s3/n8RogXXe0yvjMz8opb/mhJpBH
# OQ+BXy5XuhWq7/YIYpLUExZNz9OvwBngMZNoQLvNm05vkEZjedTpk1YLStS+HiZU
# 4NYVc7h6SKVs7fDayDnXqMR9xGLhaYnWNVIrx9pZ1PFz7J4QCXrGiKs3MqnrpjLj
# Nmb0/Ne4aOWIfv3YPqCipg==
# =n7nP
# -----END PGP SIGNATURE-----
# gpg: Signature made Mon Mar 23 10:54:05 2026 GMT
# gpg:                using RSA key E1A5C593CD419DE28E8315CF3C2525ED14360CDE
# gpg:                issuer "[email protected]"
# gpg: Good signature from "Peter Maydell <[email protected]>" [ultimate]
# gpg:                 aka "Peter Maydell <[email protected]>" [ultimate]
# gpg:                 aka "Peter Maydell <[email protected]>" [ultimate]
# gpg:                 aka "Peter Maydell <[email protected]>" [ultimate]
# Primary key fingerprint: E1A5 C593 CD41 9DE2 8E83  15CF 3C25 25ED 1436 0CDE

* tag 'pull-target-arm-20260323' of https://gitlab.com/pm215/qemu:
  hw/isa/piix: Embed i8259 irq in device state instead of allocating
  configs/targets: Restrict the legacy ldst_phys() API on ARM / Aarch64
  whpx: arm: fix ID_AA64MMFR3_EL1 host feature register index
  target/arm: cpu: alter error message for host CPU type
  whpx: arm: remove comment bit that is no longer accurate
  whpx: arm: enable more enlightenments
  whpx: arm: add EC_DATAABORT assert for WHvRunVpExitReasonGpaIntercept/UnmappedGpa
  whpx: arm: fix -cpu host
  configure: Remove unused variable default_cflags
  tests/qtest/arm-cpu-features: Fix thinko in g_strdup_printf() call

Signed-off-by: Peter Maydell <[email protected]>
2026-03-23 10:55:20 +00:00
Peter Maydell dec20f8f70 Merge tag 'pull-request-2026-03-23' of https://gitlab.com/thuth/qemu into staging
* Fix various crashes that can happen when running QEMU with -device xyz,help
* Improve detection of build directory in the functional patches

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCgAdFiEEJ7iIR+7gJQEY8+q5LtnXdP5wLbUFAmnBFYIACgkQLtnXdP5w
# LbVDShAAoV+WZlCG+nnVuXwjM4oQzLhMy/Geds9urnvohtMv0wmI0l8tm+1WYc6M
# uCazatR/FvPcmrHE09+zhbDbLeoCLES9LNCxwk4hov1AY+RL40PyoFJfmIXLJYz6
# 1Vp5PUnC/y5GnbGYy5jgQ/FtxApMQvvCWlLxcRrMVThMcPLYbnGGcaufK8oiltmU
# 96620XVUkGMpc1w5mCvbT3RJXuQkDb8OvIcm4/kZ2RxCEbrnCjvPpWN2bmi4D8nh
# 8TfMguB5c1Lgmw1y3d/hHoNxMuEijTtU1lVWycCW1ij1ZHLiYKlT9IjXbel8VqEQ
# GAEdsPwEtfcJZqRohZ5cOWn86jLYwlGB0xRrXHb5JI1r7XjMo3UEKB2M30S2SlkL
# Zvl92XJqOzhxL4o89UrVjTv/YcgkPYtfsnMZeuJpH8xwmBVd+7nSXAdQvfedVbPg
# W+BWUNWEL1/l6Rl7ge763rGu/I8nDisvhYpMWq83W8f0E8TSTmPTxdGlz4T5ObQd
# BAV6JwmiFXg9kHs28k5crk3oCNbuGETPhiBp5J3l/psDZQ3NkIM+KPRoiu3oVpei
# K2QFQiiHYTx9FdcyxASXyfbR3E2u+bEdT4gAnFjdIwIiYNtLLqqC0/BFgrHvII5e
# qaJH+qrV6BhBRfwooux6KjKDeb9d5BMfOCqk2ERdbHflIztFrrQ=
# =Y6fU
# -----END PGP SIGNATURE-----
# gpg: Signature made Mon Mar 23 10:27:14 2026 GMT
# gpg:                using RSA key 27B88847EEE0250118F3EAB92ED9D774FE702DB5
# gpg: Good signature from "Thomas Huth <[email protected]>" [full]
# gpg:                 aka "Thomas Huth <[email protected]>" [full]
# gpg:                 aka "Thomas Huth <[email protected]>" [full]
# gpg:                 aka "Thomas Huth <[email protected]>" [undefined]
# Primary key fingerprint: 27B8 8847 EEE0 2501 18F3  EAB9 2ED9 D774 FE70 2DB5

* tag 'pull-request-2026-03-23' of https://gitlab.com/thuth/qemu:
  tests/functional: remove heuristics for finding build dir
  tests/functional: fix log placement when run directly
  hw/sparc64/sun4u_iommu: Fix crash when introspecting sun4u-iommu from the CLI
  hw/sparc/sun4m_iommu: Fix crash when introspecting sun4m-iommu from the CLI
  hw/display/cg3: Fix crash when introspecting cgthree from the CLI
  hw/pci-host/raven: Fix crash when introspecting raven-pcihost from the CLI

Signed-off-by: Peter Maydell <[email protected]>
2026-03-23 10:55:07 +00:00
Peter Maydell 4ba98f4cb9 Merge tag 'pull-hex-20260320' of https://github.com/quic/qemu into staging
Fix for J2_jumptnew{,pt} pred-reg misbehavior

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCgAdFiEEPWaq5HRZSCTIjOD4GlSvuOVkbDIFAmm9Xi0ACgkQGlSvuOVk
# bDJFqQ/+NJfvsWAGDK/JV6dklKQ6f6GmRzuVBbPmEY+fCVdkaZPJFkoU70qNCths
# jD/3rsTtTb8NRs05z3BXcf2/hr7iU5f+u6hrz26xi4JpGJ+sNFIN+AHVinPuUeGl
# yM4Zd9gRlzdOOhKy6yV9FAclg+ldTUHDlgbmInxaDt1ADuDfTqcrphd4TmjsMsI3
# +HSn22lL7qn0IZWa2cOJ5k/fXagBP181lhRB4vtJrDPZdUww4FreBjTecKzdJuLO
# wxyew5ljNNn/V0MxGwrxPf/Y5VlqfkkffMh/d22DenAY6GXtiYMrNgZa4jt7gaPS
# +/42RxLr/rc1VXuPwDSE9+XEODWSpaNgOhuQYRtvvmd3vzpTIL4BKv0sFrVWkS/a
# OSAFUB+ufouwZs+DoaLaTU63PYTWQunJiaVyeoqiPjv/sOR3ykr+n304VBjSbQAF
# syvWE4qyQEos+8QVIuGA71NFzGrYCvw3iKnzcG+AeUrC5v0SI7o1jcNJ7G9z+5KX
# bIzC7voH2+1nrb/FJoMusS2foYmmJbCZ/cVJvb7df4rx6X0aPVDqB2MkrSHGcllI
# pUjhAGvMnN+bF0t28qtc4xKBa+yWSApR801BixIxlehfWk/7jgEx3RYA+iRCy966
# xPyxzvWdRBwn2CdppZKIMYPL8IYqhKVKOi7DKYWk02b7YWkFnGk=
# =MgZ9
# -----END PGP SIGNATURE-----
# gpg: Signature made Fri Mar 20 14:48:13 2026 GMT
# gpg:                using RSA key 3D66AAE474594824C88CE0F81A54AFB8E5646C32
# gpg: Good signature from "Brian Cain (OSS Qualcomm) <[email protected]>" [unknown]
# gpg:                 aka "Brian Cain <[email protected]>" [full]
# gpg:                 aka "Brian Cain (QuIC) <[email protected]>" [full]
# gpg:                 aka "Brian Cain (CAF) <[email protected]>" [full]
# gpg:                 aka "bcain" [full]
# gpg:                 aka "Brian Cain (QUIC) <[email protected]>" [unknown]
# Primary key fingerprint: 6350 20F9 67A7 7164 79EF  49E0 175C 464E 541B 6D47
#      Subkey fingerprint: 3D66 AAE4 7459 4824 C88C  E0F8 1A54 AFB8 E564 6C32

* tag 'pull-hex-20260320' of https://github.com/quic/qemu:
  tests/tcg/hexagon: add test for predicated .new branch LSB evaluation
  target/hexagon: use TCG_COND_TSTEQ/TSTNE for predicate branches
  target/hexagon: fix J2_jumptnew/pt predicate check to use LSB

Signed-off-by: Peter Maydell <[email protected]>
2026-03-23 10:54:45 +00:00
Peter Maydell b38859be76 hw/isa/piix: Embed i8259 irq in device state instead of allocating
The pci_piix_realize() function's use of qemu_allocate_irqs()
results in a memory leak:

Direct leak of 8 byte(s) in 1 object(s) allocated from:
    #0 0x61045c7a1a43 in malloc (/home/pm215/qemu/build/san/qemu-system-mips+0x16f8a43) (BuildId: aa43d3865e0f1991b1fc04422b5570fe522b6fa7)
    #1 0x724cc3095ac9 in g_malloc (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x62ac9) (BuildId: 116e142b9b52c8a4dfd403e759e71ab8f95d8bb3)
    #2 0x61045db72134 in qemu_extend_irqs /home/pm215/qemu/build/san/../../hw/core/irq.c:77:51
    #3 0x61045cd7bf49 in pci_piix_realize /home/pm215/qemu/build/san/../../hw/isa/piix.c:318:35
    #4 0x61045cf4533e in pci_qdev_realize /home/pm215/qemu/build/san/../../hw/pci/pci.c:2308:9
    #5 0x61045db6cbca in device_set_realized /home/pm215/qemu/build/san/../../hw/core/qdev.c:523:13
    #6 0x61045db86bd9 in property_set_bool /home/pm215/qemu/build/san/../../qom/object.c:2376:5
    #7 0x61045db81c5e in object_property_set /home/pm215/qemu/build/san/../../qom/object.c:1450:5
    #8 0x61045db8e2fc in object_property_set_qobject /home/pm215/qemu/build/san/../../qom/qom-qobject.c:28:10
    #9 0x61045db8258f in object_property_set_bool /home/pm215/qemu/build/san/../../qom/object.c:1520:15
    #10 0x61045db687aa in qdev_realize_and_unref /home/pm215/qemu/build/san/../../hw/core/qdev.c:283:11
    #11 0x61045d892e21 in mips_malta_init /home/pm215/qemu/build/san/../../hw/mips/malta.c:1239:5

(The i386 PC sets the has-pic property to 'false', so this only
affects the MIPS Malta board.)

Fix this by embedding the i8259 irq in the device state instead of
allocating it.  This is a similar fix to the one we used for vt82c686
in commit 2225dc562a, except that we use qemu_init_irq_child()
instead of qemu_init_irq().  The behaviour is identical except that
the _child() version avoids what would be a leak if we ever
unrealized the device.

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: BALATON Zoltan <[email protected]>
Reviewed-by: Bernhard Beschow <[email protected]>
Message-id: [email protected]
2026-03-23 09:51:01 +00:00
Philippe Mathieu-Daudé 8bee653122 configs/targets: Restrict the legacy ldst_phys() API on ARM / Aarch64
Commit d751921cff ("hw/arm/omap1: Remove omap_badwidth_*
implementations") removed the last use of the legacy ldst_phys()
API. Set the TARGET_NOT_USING_LEGACY_LDST_PHYS_API variable to
hide the legacy API to the ARM / Aarch64 binaries, avoiding further
API uses to creep in.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-id: [email protected]
Reviewed-by: Peter Maydell <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
2026-03-23 09:51:01 +00:00
Osama Abdelkader 045981037b whpx: arm: fix ID_AA64MMFR3_EL1 host feature register index
IdAa64Mmfr3El1 was stored in idregs[ID_AA64MMFR2_EL1_IDX], overwriting
MMFR2 and leaving MMFR3 never set. Use ID_AA64MMFR3_EL1_IDX so the host
MMFR3 value is stored in the correct slot.

Fixes: f7fa2b8808 ("whpx: arm64: implement -cpu host")
Signed-off-by: Osama Abdelkader <[email protected]>
Reviewed-by: Mohamed Mediouni <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-03-23 09:51:01 +00:00
Mohamed Mediouni 80cad8d0bd target/arm: cpu: alter error message for host CPU type
Make the error message for attempting to use 'host' on an
unsupported accelerator match the check we're doing.

Signed-off-by: Mohamed Mediouni <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-03-23 09:51:01 +00:00
Mohamed Mediouni dccf60b6ca whpx: arm: remove comment bit that is no longer accurate
As of Windows 11 version 26H1, SME support shipped.  However the
MIT-licensed headers aren't updated yet.

Signed-off-by: Mohamed Mediouni <[email protected]>
Message-id: [email protected]
Reviewed-by: Peter Maydell <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
2026-03-23 09:51:01 +00:00
Mohamed Mediouni f3364a1b04 whpx: arm: enable more enlightenments
Unconditionally enable some more enlightenments for whpx.  In
particular, linux uses AccessVpRegs without checking availability and
panics if it's not there, so it's important to expose it.

We also had a duplicate line where we set AccessHypercallRegs = 1
twice; remove the duplicate.

Microsoft’s VMM exposes SyncContext on arm64 and FastHypercallOutput
regardless of architecture unconditionally, so add those two to match
that configuration.

Signed-off-by: Mohamed Mediouni <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-03-23 09:51:01 +00:00
Mohamed Mediouni fc788ca5ed whpx: arm: add EC_DATAABORT assert for WHvRunVpExitReasonGpaIntercept/UnmappedGpa
If we get anything else from Hyper-V there's a problem, so enforce
this.

Signed-off-by: Mohamed Mediouni <[email protected]>
Message-id: [email protected]
Suggested-by: Alex Bennée <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
2026-03-23 09:51:01 +00:00
Mohamed Mediouni f4df1d60ac whpx: arm: fix -cpu host
"hw/arm/virt: Register valid CPU types dynamically" went under my
radar, so fix this for WHPX.

Signed-off-by: Mohamed Mediouni <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Stefan Weil <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-03-23 09:51:01 +00:00
Peter Maydell 6d5023fdc1 configure: Remove unused variable default_cflags
configure has a variable default_cflags, which was originally added
in commit bafe78ad3b ("contrib/plugins: use an independent
makefile") as part of it setting up the build environment for
contrib/plugins, which at the time used make.  However, we now build
the plugins with meson, and in commit 55c84a72ab ("contrib/plugins:
remove Makefile for contrib/plugins") we dropped the logic from
configure that does that makefile setup, leaving default_cflags
as an unused variable.

shellcheck helpfully reports this:
      default_cflags='-O0 -g'
      ^------------^ SC2034 (warning): default_cflags appears unused. Verify use (or export if used externally).

Remove the unused variable.

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-id: [email protected]
2026-03-23 09:51:01 +00:00
Peter Maydell b64a5f5351 tests/qtest/arm-cpu-features: Fix thinko in g_strdup_printf() call
In commit 62272f9f88 we changed some uses of fixed char arrays
to call g_strdup_printf() instead. In one place I made a silly
error where in changing
  sprintf(name, "fmt string", ...)
to
  name = g_strdup_printf("fmt string", ...)
I forgot to delete "name" from the argument list.

Luckily Coverity spotted this (as CID 1645771) because at this
point "name" is NULL and passing g_strdup_printf() a NULL first
argument is not valid.

We didn't notice the mistake in testing or CI because this bit of
code is only run if on an AArch64 host with KVM and SVE available.

Correct the error by removing the stray function argument.

Fixes: 62272f9f88 ("tests/qtest/arm-cpu-features: Use g_strdup_printf() instead of char arrays")
Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Message-id: [email protected]
2026-03-23 09:51:01 +00:00
Daniel P. Berrangé b86eff44ba tests/functional: remove heuristics for finding build dir
Currently some heuristics are used to locate the build dir, if the
MESON_BUILD_ROOT environment variable is not set. These are not
entirely accurate, however, especially if the developer is using
nested sub-dirs under $PWD/build/...

Since the introduction of the 'run' script, we can ensure any
direct execution of the tests will have MESON_BUILD_ROOT set.

Meanwhile when meson runs the test it will also have this env
set. The only gap is when running pre-caching, and that is easily
fixed to set MESON_BUILD_ROOT.

It can thus be assumed that MESON_BUILD_ROOT will always be set
in any supported execution scenario, which allows the heuristics
to be removed.

Signed-off-by: Daniel P. Berrangé <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
2026-03-23 08:16:07 +01:00
Daniel P. Berrangé dea076926b tests/functional: fix log placement when run directly
When running functional tests directly there are some heuristics
to figure out where the build directory lives, along with the
possibility to override the logic by setting the QEMU_BUILD_DIR
env variable. This env var is set as part of the test env when
run via Meson but not when run directly.

A particular flaw with the currently logic is that it silently
uses the wrong location when the build directory is a sub-dir
under "./build", which is a common usage scenario for some devs.

With the recent introduction of the 'run' script, we now have
the MESON_BUILD_ROOT env variable set unconditionally, so we
can rely on that from the functional tests to get the correct
location in all scenarios.

Reported-by: Peter Maydell <[email protected]>
Signed-off-by: Daniel P. Berrangé <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
2026-03-23 08:16:07 +01:00
Thomas Huth d319a3a899 hw/sparc64/sun4u_iommu: Fix crash when introspecting sun4u-iommu from the CLI
QEMU currently crashes when introspecting the sun4u-iommu device from the
command line interface:

 $ ./qemu-system-sparc64 -display none -device sun4u-iommu,help
 qemu-system-sparc64: ../../devel/qemu/system/physmem.c:1401:
  register_multipage: Assertion `num_pages' failed.
 Aborted (core dumped)

There does not seem to be a compelling reason for initializing the
memory regions from the instance_init function, so let's simply move
the code into a realize() function instead to fix this issue.

Reported-by: Markus Armbruster <[email protected]>
Tested-by: Markus Armbruster <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
2026-03-23 08:16:07 +01:00
Thomas Huth ead7c5b06f hw/sparc/sun4m_iommu: Fix crash when introspecting sun4m-iommu from the CLI
QEMU currently crashes when introspecting the sun4m-iommu device from the
command line interface:

 $ ./qemu-system-sparc -display none -device sun4m-iommu,help
 qemu-system-sparc: ../../devel/qemu/system/physmem.c:1401:
  register_multipage: Assertion `num_pages' failed.
 Aborted (core dumped)

There does not seem to be a compelling reason for initializing the
memory regions from the instance_init function, so let's simply move
the code into a realize() function instead to fix this issue.

Reported-by: Markus Armbruster <[email protected]>
Tested-by: Markus Armbruster <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
2026-03-23 08:16:07 +01:00
Thomas Huth 4ea7024ff6 hw/display/cg3: Fix crash when introspecting cgthree from the CLI
QEMU currently crashes when introspecting the cgthree device from the
command line interface:

 $ ./qemu-system-sparc -device cgthree,help
 Segmentation fault (core dumped)

This happens because the memory_region_init_rom() function internally
calls qemu_ram_alloc_internal() that needs the current_machine pointer
to be set up - which is not the case here since the machine has not
been created yet.

There does not seem to be a compelling reason for initializing the
memory regions from the instance_init function, so let's simply move
the code into the realize() function instead to fix this issue.

Tested-by: Markus Armbruster <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
2026-03-23 08:16:07 +01:00
Thomas Huth aee404fc7f hw/pci-host/raven: Fix crash when introspecting raven-pcihost from the CLI
QEMU currently crashes when introspecting raven-pcihost from the command
line interface:

 $ ./qemu-system-ppc -device raven-pcihost,help
 Segmentation fault (core dumped)

This happens because the raven_pcihost_initfn instance init function
calls get_system_memory(), but that is not available here yet.

There does not seem to be a compelling reason for initializing the
memory regions from the instance init function, so let's simply move
the code into the realize() function instead to fix this issue.

Tested-by: Markus Armbruster <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
2026-03-23 08:16:07 +01:00
Brian Cain 1adf67b3c4 tests/tcg/hexagon: add test for predicated .new branch LSB evaluation
Test for predicated .new branches with non-standard predicate values
(non-all-0, non-all-1).  Hexagon predicates are 8 bits wide but conditional
branches evaluate only the LSB.

Reviewed-by: Taylor Simpson <[email protected]>
Signed-off-by: Brian Cain <[email protected]>
2026-03-20 07:43:03 -07:00
Brian Cain dfa4c8810f target/hexagon: use TCG_COND_TSTEQ/TSTNE for predicate branches
Replace TCG_COND_EQ/NE comparisons against 0 with TCG_COND_TSTEQ/TSTNE
comparisons against 1 for all predicate-conditional branches. This tests
bit 0 of the predicate register directly, eliminating redundant andi
operations that previously extracted the LSB before the comparison.

For predicate-conditional jumps (jumpt, jumpf, jumptnew, etc.) and
jump-register variants (jumprt, jumprf, etc.), pass the raw predicate
value directly instead of going through fLSBOLD/fLSBNEW extraction.
For callers that produce a 0/1 result via setcond (compare-and-jump,
jumprz, etc.), the TSTEQ/TSTNE test on bit 0 is equivalent to the
previous EQ/NE test against 0.

Reviewed-by: Taylor Simpson <[email protected]>
Signed-off-by: Brian Cain <[email protected]>
2026-03-20 07:43:03 -07:00
Brian Cain e8743ca0ac target/hexagon: fix J2_jumptnew/pt predicate check to use LSB
J2_jumptnew and J2_jumptnewpt passed the raw predicate value to
gen_cond_jump(), checking if the full 8-bit value was non-zero.
Refer to PRM Section 6.1.2 "predicate-consuming instructions examine
only the least-significant bit".

This inconsistency caused if (p0.new) jumps and if (p0.new) loads
within the same packet to disagree when the predicate had values
other than the ones generated by predicate-generating instructions
(e.g. 0x80 or 0xAA where bit 0 is clear but the value is
non-zero): the jump would be taken while the loads were skipped.

Fix by routing both macros through fGEN_TCG_cond_jumpt(fLSBNEW(PuN)),
matching the pattern used by every other predicated jump.

Discovered-by: Alexey Karyakin <[email protected]>
Reviewed-by: Taylor Simpson <[email protected]>
Signed-off-by: Brian Cain <[email protected]>
2026-03-20 07:43:03 -07:00
Peter Maydell 8e711856d7 Merge tag 'hppa-fixes-for-v11-pull-request' of https://github.com/hdeller/qemu-hppa into staging
HPPA fixes for v11

Some late fixes for QEMU-v11

Various fixes in SeaBIOS-hppa and qemu code, most importantly
this fixes boot of the C3700, which broke while we added
support for CPUs with 40 and 44 bits physical address space.

# -----BEGIN PGP SIGNATURE-----
#
# iHUEABYKAB0WIQS86RI+GtKfB8BJu973ErUQojoPXwUCabxmmwAKCRD3ErUQojoP
# X5z0AP4h0hBe/jDlQ8VLs0LtdG4bBnyPSVl+4rahw10mmgkvZwD7B/wimiCUBOJZ
# Jj9nKpNWtgZRXwRIM4XOl/a6pYcbCw8=
# =MzWS
# -----END PGP SIGNATURE-----
# gpg: Signature made Thu Mar 19 21:11:55 2026 GMT
# gpg:                using EDDSA key BCE9123E1AD29F07C049BBDEF712B510A23A0F5F
# gpg: Good signature from "Helge Deller <[email protected]>" [unknown]
# gpg:                 aka "Helge Deller <[email protected]>" [unknown]
# gpg:                 aka "Helge Deller <[email protected]>" [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: 4544 8228 2CD9 10DB EF3D  25F8 3E5F 3D04 A7A2 4603
#      Subkey fingerprint: BCE9 123E 1AD2 9F07 C049  BBDE F712 B510 A23A 0F5F

* tag 'hppa-fixes-for-v11-pull-request' of https://github.com/hdeller/qemu-hppa:
  target/hppa: Update SeaBIOS-hppa to version 23
  hw/hppa: Fix crash of 64-bit HP-UX 11 while flushing caches
  hw/pci-host/astro: Use proper region names
  target/hppa: Always map 64-bit firmware at 0xfffffff0f0000000
  hw/hppa: Adjust physical addresses of Astro and Elroy
  hw/hppa: Fix description of the HP A400-44 server

Signed-off-by: Peter Maydell <[email protected]>
2026-03-20 10:04:48 +00:00
Peter Maydell 5f5875b0b5 Merge tag 'pull-riscv-to-apply-20260320' of https://github.com/alistair23/qemu into staging
RISC-V PR for 11.

* Fix integer overflow in cm_base calculation
* Fix null pointer dereference in cpu_set_exception_base
* Update Daniel Henrique Barboza's email
* Add Chao Liu as reviewer
* Set SiFive PDMA done bit upon completion
* Remove deprecated 'riscv, delegate' device-tree property
* Fix OCP FP8 E4M3 conversion issues
* Fix IOMMU instance_init allocations in instance_finalize
* Support Smpmpmt extension
* Fix SiFive UART spurious IRQ issue and misc updates
* Fix missing flags merge in probe_pages for cross-page accesses
* Fix page probe issues in vext_ldff
* Fix scountovf CSR behavior in VS-mode and M-mode

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCgAdFiEEaukCtqfKh31tZZKWr3yVEwxTgBMFAmm8ha4ACgkQr3yVEwxT
# gBMKOBAAsB6CwDSsi+DmuCD5r25kaLtvFg7hqc6iYpzjuwUE+uHu3LWMky19Div1
# mpMLZi1an/NbIKX8N9KS1G87hzteqvxY4wKVoMn1mF/3yQ5r6OJ2SfZoDiiJyAva
# UIhaiRUbmg78OX0YCBYCWaRbqN7rbV6XJnB8oGUyhVNwtfJ/pZppfCflsd5+E3KD
# U7sKMVaytfeQCQGXeNYgZBvYvDQ7/t21eLytLYGhUNy89N8mo7V5egFJEN45BE8O
# Zh+Oa7bN+lUOg0eUTj98zwXXXeOZMEKbn5I01XuUH1gn5aO+CeEvFEqDssF1fKle
# mq00WkK1Tk9kZOTLhMR4pdW2kXkom/mEmXI9jU0CInmF63+r8/SugimPS8LyLE3N
# qZodmmEeckOPsE+RnmBOHww2Y+g668+C/sTcSAuHsWUXJLDty+DyO0RU4d0ioRHa
# zyOf2cNoSVV8EWJ5uHk9Et2eimq0Q83n/tVpkKyq877rOGLQzoDIKJEwIO7nI59x
# NF437R7hWKOZ0JLE22wuLWNW8LohxaFkzYRGFDH2/qKlsEv7mSkutTU4y6g0XKok
# iTjBaibmwsaDeMrf5JYHTGMSvF/3lIXyeJiBCq6uQac3fFXKKeehttaU4F+KW0KE
# gO6oUdJWExp7Tt+9nx5KqFxlJPNd/JV3gDCKRjQskW3bT4H1cco=
# =chEj
# -----END PGP SIGNATURE-----
# gpg: Signature made Thu Mar 19 23:24:30 2026 GMT
# gpg:                using RSA key 6AE902B6A7CA877D6D659296AF7C95130C538013
# gpg: Good signature from "Alistair Francis <[email protected]>" [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: 6AE9 02B6 A7CA 877D 6D65  9296 AF7C 9513 0C53 8013

* tag 'pull-riscv-to-apply-20260320' of https://github.com/alistair23/qemu:
  target/riscv: Fix scountovf CSR behavior in VS-mode and M-mode
  target/riscv: rvv: Fix page probe issues in vext_ldff
  target/riscv: rvv: Fix missing flags merge in probe_pages for cross-page accesses
  hw/char: sifive_uart: Remove ip variable
  hw/char: sifive_uart: Update IRQ when rxctrl is written
  hw/char: sifive_uart: Sync txwm interrupt pending status after TX FIFO enqueue
  hw/char: sifive_uart: Implement txctrl.txen and rxctrl.rxen
  target/riscv: Support Smpmpmt extension
  hw/riscv/riscv-iommu: Free instance_init allocations in instance_finalize
  fpu: Fix unexpected exception flags when converting infinity to OCP E4M3
  fpu: Fix repacking issues in the uncanonical step for E4M3 overflow
  hw/riscv: Remove deprecated 'riscv, delegate' device-tree property
  hw/dma: sifive_pdma: Set done bit upon completion
  MAINTAINERS: Add myself as a reviewer for RISC-V TCG CPUs
  MAINTAINERS: update my email
  target/riscv: Fix null pointer dereference in cpu_set_exception_base
  hw/riscv: Fix integer overflow in cm_base calculation

Signed-off-by: Peter Maydell <[email protected]>
2026-03-20 10:04:40 +00:00
Peter Maydell 3e8d341ef1 Merge tag 'staging-pull-request' of https://gitlab.com/peterx/qemu into staging
mem pull for 11.0-rc1

Two fixes included:

- Xiaoyao's fix on recent coco guest boot failure
- BALATON's fix on recent sparce device-introspect-test failure

# -----BEGIN PGP SIGNATURE-----
#
# iIgEABYKADAWIQS5GE3CDMRX2s990ak7X8zN86vXBgUCabwC2xIccGV0ZXJ4QHJl
# ZGhhdC5jb20ACgkQO1/MzfOr1wYozgEAg32MCV/R9xs5krn9mSpBLLoVZCAIDp2C
# 4hLW7aEnf4UBALeUmJY/pLWEGwFc6LVzPe4kZ5BLl0j72jtcVP1BcmoG
# =Zd1r
# -----END PGP SIGNATURE-----
# gpg: Signature made Thu Mar 19 14:06:19 2026 GMT
# gpg:                using EDDSA key B9184DC20CC457DACF7DD1A93B5FCCCDF3ABD706
# gpg:                issuer "[email protected]"
# gpg: Good signature from "Peter Xu <[email protected]>" [marginal]
# gpg:                 aka "Peter Xu <[email protected]>" [marginal]
# gpg: WARNING: The key's User ID is not certified with sufficiently trusted signatures!
# gpg:          It is not certain that the signature belongs to the owner.
# Primary key fingerprint: B918 4DC2 0CC4 57DA CF7D  D1A9 3B5F CCCD F3AB D706

* tag 'staging-pull-request' of https://gitlab.com/peterx/qemu:
  hw/display/tcx: Init memory regions in realize
  memory: Set mr->ram before RAM Block allocation

Signed-off-by: Peter Maydell <[email protected]>
2026-03-20 10:04:21 +00:00
Jim Shu 38937473da target/riscv: Fix scountovf CSR behavior in VS-mode and M-mode
From Sscofpmf spec [1]:
- In M-mode, scountovf bit X is always readable.
- in VS mode, scountovf bit X is readable when mcounteren bit X and
  hcounteren bit X are both set, and otherwise reads as zero.

[1] https://github.com/riscv/riscv-isa-manual/blob/main/src/sscofpmf.adoc

Signed-off-by: Jim Shu <[email protected]>
Signed-off-by: Max Chou <[email protected]>
Reviewed-by: Alistair Francis <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
2026-03-20 08:41:15 +10:00
Max Chou 0e8ad6a846 target/riscv: rvv: Fix page probe issues in vext_ldff
Commit 17288e38be ("optimize the memory probing for vector
fault-only-first loads") introduced an optimization that moved from
per-element probing to a fast-path broad probe. Unfortunately it
introduced following bugs in cross-page handling:

- Wrong condition for second page probing: checked "env->vl > elems"
  instead of "env->vl > elems + env->vstart", failing to account for
  the vstart offset.

- Incorrect second page address calculation: used
  "addr + (elems << log2_esz)" instead of "addr + page_split".
  For segment loads (nf > 1), this would probe the wrong address,not
  at the page boundary.

- Wrong second page probe size: used "elems * msize" (the first page
  size) instead of calculating the remaining size as
  "(env->vl - env->vstart) * msize - page_split". This would probe
  too little memory and could miss faults.

This commit fixes these bugs by leveraging the probe_pages helper
which automatically handles cross-page memory accesses correctly.

Fixes: 17288e38be ("optimize the memory probing for vector fault-only-first loads.")

Signed-off-by: Max Chou <[email protected]>
Acked-by: Alistair Francis <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
2026-03-20 08:41:15 +10:00
Max Chou 5568177738 target/riscv: rvv: Fix missing flags merge in probe_pages for cross-page accesses
When probe_pages probes a memory region that spans two pages, it calls
probe_access_flags twice - once for each page. However, the flags from
the second page probe were overwriting the flags from the first page
instead of being merged together.

Signed-off-by: Max Chou <[email protected]>
Reviewed-by: Alistair Francis <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
2026-03-20 08:41:15 +10:00
Frank Chang f9f430b701 hw/char: sifive_uart: Remove ip variable
The ip variable is no longer used in the code. Remove it from the
codebase.

Signed-off-by: Frank Chang <[email protected]>
Reviewed-by: Alistair Francis <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
2026-03-20 08:41:15 +10:00
Frank Chang 558f14b26f hw/char: sifive_uart: Update IRQ when rxctrl is written
When rxctl is updated, we also need to check whether the IRQ should be
raised, as the user may activate the Rx channel or change the Rx FIFO
watermark level.

Signed-off-by: Frank Chang <[email protected]>
Reviewed-by: Alistair Francis <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
2026-03-20 08:41:15 +10:00
Frank Chang 7997b782f4 hw/char: sifive_uart: Sync txwm interrupt pending status after TX FIFO enqueue
Currently, the txwm interrupt pending status is only updated when the
asynchronous transmit handler runs. This can cause the txwm interrupt
state to become unsynchronized between the SiFive UART and the
interrupt controller.

For example, when a txwm interrupt is raised, the corresponding APLIC
pending bit is also set. However, if software later enqueues additional
characters into the TX FIFO exceeding the transmit watermark, the
APLIC pending bit may remain set because the txwm interrupt pending
status is not updated at enqueue time.

This issue has been observed on resource-constrained machines, where
Linux reports spurious IRQ errors. In these cases, the asynchronous
transmit handler is unable to drain the TX FIFO quickly enough to update
the txwm pending status before software reads the ip register, which
derives the txwm pending state directly from the actual number of
characters in the TX FIFO.

This commit fixes the issue by updating the txwm interrupt pending
status immediately after enqueuing data into the TX FIFO, ensuring that
the interrupt pending status between the SiFive UART and the interrupt
controller remains synchronized.

Signed-off-by: Frank Chang <[email protected]>
Reviewed-by: Alistair Francis <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
2026-03-20 08:41:14 +10:00
Frank Chang e6051fa61b hw/char: sifive_uart: Implement txctrl.txen and rxctrl.rxen
Implement txctrl.txen and rxctrl.rxen as follows:

* txctrl.txen
  The txen bit controls whether the Tx channel is active. When cleared,
  transmission of Tx FIFO contents is suppressed, and the txd pin is
  driven high.

* rxctrl.rxen:
  The rxen bit controls whether the Rx channel is active. When cleared,
  the state of the rxd pin is ignored, and no characters will be
  enqueued into the Rx FIFO.

Therefore, the Tx FIFO should not be dequeued when txctrl.txen is
cleared, and the Rx FIFO should not be enqueued when rxctrl.rxen is
cleared.

Signed-off-by: Frank Chang <[email protected]>
Reviewed-by: Alistair Francis <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
2026-03-20 08:41:14 +10:00
Helge Deller fa2d5d84e0 target/hppa: Update SeaBIOS-hppa to version 23
New SeaBIOS-hppa v23 release with various fixes for qemu-v11:
- Various fixes to support CPUs with 40 and 44 bits physical address
- Fix PAT_CPU call when asking for current CPU
- Add function to stop CPU in PDC_PROC
- Prevent execution of some functions when running as PAT firmware
- Tune cache parameters to speed up cache flushes in operating systems
- Revert resetting LSI SCSI with ODE on HP3000

Signed-off-by: Helge Deller <[email protected]>
Reviewed-by: Anton Johansson <[email protected]>
2026-03-19 22:06:49 +01:00
Helge Deller 3835a61341 hw/hppa: Fix crash of 64-bit HP-UX 11 while flushing caches
HP-UX 11 64-bit reads at bootup a word from address CPU_HPA + 0x500
while flushing the the cache of a T600.
Add a memory handler to avoid crashing while reading this word.

Signed-off-by: Helge Deller <[email protected]>
Reviewed-by: Anton Johansson <[email protected]>
2026-03-19 22:06:49 +01:00
Helge Deller 90c6cf342c hw/pci-host/astro: Use proper region names
All 64-bit hppa machines have at least 4 Elroy PCI busses in the system.
Make sure to use proper names in the qemu device tree, e.g. "elroy0" or
"elroy2-pci-mmio", to be able to distinguish between the various chips.

Signed-off-by: Helge Deller <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-19 22:06:49 +01:00
Helge Deller 0a3283513f target/hppa: Always map 64-bit firmware at 0xfffffff0f0000000
I checked on a physical A500, C3700 and C8000 machine and all load their
64-bit PDC (Firmware) at 0xfffffff0f0000000, independed if the CPU uses
40 or 44 physical address bits.
For qemu we will do the same and load the 64-bit SeaBIOS-hppa at the
same address for our emulated machines.

Signed-off-by: Helge Deller <[email protected]>
Reviewed-by: Anton Johansson <[email protected]>
2026-03-19 22:06:49 +01:00
Helge Deller 50bc19c0a5 hw/hppa: Adjust physical addresses of Astro and Elroy
Adjust the addresses of the Astro and Elroy PCI chips to a
44-bit physical address space when running a PA8700 CPU.

Signed-off-by: Helge Deller <[email protected]>
Reviewed-by: Anton Johansson <[email protected]>
2026-03-19 22:06:49 +01:00
Helge Deller cb991be5b1 hw/hppa: Fix description of the HP A400-44 server
The HP A400-44 machine has a height of 2U and is a noisy server machine
which was usually running in the datacenter.

Signed-off-by: Helge Deller <[email protected]>
Reviewed-by: Anton Johansson <[email protected]>
2026-03-19 22:06:49 +01:00
BALATON Zoltan 2a13e31073 hw/display/tcx: Init memory regions in realize
Thomas reported test failure:

  $ export QTEST_QEMU_BINARY=./qemu-system-sparc
  $ tests/qtest/device-introspect-test -m thorough
  ...
  # Testing device 'sun-tcx'
  RAMBlock "tcx.prom" already registered, abort!
  Broken pipe
  ../../devel/qemu/tests/qtest/libqtest.c:210: kill_qemu() detected QEMU
  death from signal 6 (Aborted) (core dumped)
  Aborted (core dumped)

Issue is the qom introspect test will create yet another sun-tcx device
causing double register of the memory region.

Fix it by removing the init method and move memory region creation in
realize.

Reported-by: Thomas Huth <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Fixes: 653c4fa5b0 hw/display/{cg3.tcx}: Do not use memory_region_init_rom_nomigrate
Signed-off-by: BALATON Zoltan <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
[peterx: amend commit message, fix tag, add link]
Signed-off-by: Peter Xu <[email protected]>
2026-03-19 10:05:18 -04:00
Xiaoyao Li 792cb90e84 memory: Set mr->ram before RAM Block allocation
Commit 2fb627ef2f ("memory: Factor out common ram region initialization")
introduced a helper function memory_region_set_ram_block(), which causes
mr->ram to be set to true after the RAM Block allocation by
qemu_ram_alloc_*().

It leads to the assertion

  g_assert(memory_region_is_ram(mr));

in memory_region_set_ram_discard_manager() being triggered when creating
RAM Block with the RAM_GUEST_MEMFD flag.

Fix this by restoring the original behavior of setting mr->ram before
RAM Block allocation.

Closes: https://gitlab.com/qemu-project/qemu/-/work_items/3330
Reported-by: Farrah Chen <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Reported-by: Kim Phillips <[email protected]>
Fixes: 2fb627ef2f ("memory: Factor out common ram region initialization")
Signed-off-by: Xiaoyao Li <[email protected]>
Tested-by: Kim Phillips <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Peter Xu <[email protected]>
2026-03-19 10:02:42 -04:00
Jay Chang 58cbdc780b target/riscv: Support Smpmpmt extension
The Smpmpmt extension provides a mechanism to control memory attributes
at the granularity of PMP (Physical Memory Protection) registers, similar
to how Svpbmt controls memory attributes at the page level.

Version 0.6
https://github.com/riscv/riscv-isa-manual/blob/smpmpmt/src/smpmpmt.adoc#svpbmt

Signed-off-by: Jay Chang <[email protected]>
Reviewed-by: Daniel Henrique Barboza <[email protected]>
Reviewed-by: Frank Chang <[email protected]>

Reviewed-by: Alistair Francis <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
2026-03-19 14:43:21 +10:00
Peter Maydell 3d39fd35f6 hw/riscv/riscv-iommu: Free instance_init allocations in instance_finalize
The riscv-iommu device makes various allocations in its
instance_init method. These will leak when QMP inits an
object of this type to introspect it, as can be seen if you
run 'make check' with the address sanitizer enabled:

Direct leak of 4096 byte(s) in 1 object(s) allocated from:
    #0 0x5d8415b6ed9d in calloc (/home/pm215/qemu/build/san/qemu-system-riscv32+0x1832d9d) (BuildId: fedcc313e48ba803d63837329c37fd609dd50849)
    #1 0x75c0502f1771 in g_malloc0 (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x63771) (BuildId: 116e142b9b52c8a4dfd403e759e71ab8f95d8bb3)
    #2 0x5d8416d09391 in riscv_iommu_instance_init /home/pm215/qemu/build/san/../../hw/riscv/riscv-iommu.c:2463:18
    #3 0x5d841710483f in object_initialize_with_type /home/pm215/qemu/build/san/../../qom/object.c:570:5
    #4 0x5d8417104ee9 in object_initialize /home/pm215/qemu/build/san/../../qom/object.c:578:5
    #5 0x5d8417104ee9 in object_initialize_child_with_propsv /home/pm215/qemu/build/san/../../qom/object.c:608:5
    #6 0x5d8417104db1 in object_initialize_child_with_props /home/pm215/qemu/build/san/../../qom/object.c:591:10
    #7 0x5d8417106506 in object_initialize_child_internal /home/pm215/qemu/build/san/../../qom/object.c:645:5
    #8 0x5d8416d16a12 in riscv_iommu_sys_init /home/pm215/qemu/build/san/../../hw/riscv/riscv-iommu-sys.c:199:5
    #9 0x5d841710483f in object_initialize_with_type /home/pm215/qemu/build/san/../../qom/object.c:570:5
    #10 0x5d841710661f in object_new_with_type /home/pm215/qemu/build/san/../../qom/object.c:774:5
    #11 0x5d841755d956 in qmp_device_list_properties /home/pm215/qemu/build/san/../../qom/qom-qmp-cmds.c:206:11

(and other similar backtraces).

Fix these by freeing the resources we allocate in instance_init in
instance_finalize.  In some cases we were freeing these in unrealize,
and in some cases not at all.

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Alistair Francis <[email protected]>
Reviewed-by: Chao Liu <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
2026-03-19 14:41:32 +10:00
Max Chou 9d090fe440 fpu: Fix unexpected exception flags when converting infinity to OCP E4M3
Infinity is a special case distinct from numeric overflow:
- Numeric overflow: finite value exceeds format's max normal
  -> overflow|inexact
- Infinity conversion: input is already infinite
  -> no flags

This commit fixes the unexpect exception flags by relocating the float
exception flag update flow to be outside the uncanon_e4m3_overflow.
And raising the overflow|inexact for numeric overflow in uncanon_normal.

Fixes: 27e989f99c ("fpu: Add conversion routines for OCP FP8 E4M3")
Reviewed-by: Chao Liu <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Max Chou <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
2026-03-19 14:39:55 +10:00
Max Chou 053e913aad fpu: Fix repacking issues in the uncanonical step for E4M3 overflow
In the uncanonical step, the input FloatParts will be repacked to the
target FloatFmt. This commit fixes following issues after calling
uncanon_e4m3_overflow in the uncanon/uncanon_normal functions.

- Add the local exp update after calling uncanon_e4m3_overflow in the
  parts_uncanon_normal function.
- Add the fraction shift after calling uncanon_e4m3_overflow in the
  parts_uncanon function.

Fixes: 27e989f99c ("fpu: Add conversion routines for OCP FP8 E4M3")
Reviewed-by: Richard Henderson <[email protected]>
Reviewed-by: Chao Liu <[email protected]>
Signed-off-by: Max Chou <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
2026-03-19 14:38:12 +10:00
Philippe Mathieu-Daudé f2af8f0d5d hw/riscv: Remove deprecated 'riscv, delegate' device-tree property
The "riscv,delegate" DT property was added in QEMU 7.0 as part of
the AIA APLIC support.  The property changed name during the
review process in Linux and the correct name ended up being
"riscv,delegation". The incorrect name was added as alias, and
deprecated in v9.1 (commit 38facfa843), so can be removed for
v11.0.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Alistair Francis <[email protected]>
Reviewed-by: Chao Liu <[email protected]>
Reviewed-by: Daniel Henrique Barboza <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
2026-03-19 14:36:29 +10:00
Jay Chang 9251858a65 hw/dma: sifive_pdma: Set done bit upon completion
Ensure that the 'done' bit is set upon transfer completion, even if
an error occurs, since all transfers are considered completed regardless
of success or failure.

Signed-off-by: Jay Chang <[email protected]>
Reviewed-by: Frank Chang <[email protected]>
Reviewed-by: Alistair Francis <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
2026-03-19 14:34:52 +10:00
Chao Liu cdb4c06292 MAINTAINERS: Add myself as a reviewer for RISC-V TCG CPUs
Add myself as a reviewer for RISC-V TCG CPU related code to better
participate in patch review.

Signed-off-by: Chao Liu <[email protected]>
Reviewed-by: Bin Meng <[email protected]>
Reviewed-by: Daniel Henrique Barboza <[email protected]>
Reviewed-by: LIU Zhiwei <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
2026-03-19 14:33:13 +10:00
Daniel Henrique Barboza c58ab7cf21 MAINTAINERS: update my email
Also add myself as a "RISC-V TCG target" reviewer.

Signed-off-by: Daniel Henrique Barboza <[email protected]>
Tested-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
2026-03-19 14:31:36 +10:00
Djordje Todorovic 519f0bdf4c target/riscv: Fix null pointer dereference in cpu_set_exception_base
Add missing return statement after logging the error when cs is NULL.
Without this, the function continues to dereference the null pointer.

Resolves: Coverity CID 1644077

Signed-off-by: Djordje Todorovic <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Alistair Francis <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
2026-03-19 14:29:58 +10:00
Djordje Todorovic 6802b477e1 hw/riscv: Fix integer overflow in cm_base calculation
Ensure 64-bit arithmetic is used when computing cm_base,
avoiding potential integer overflow.

Resolves: Coverity CID 1644076

Signed-off-by: Djordje Todorovic <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
2026-03-19 14:28:16 +10:00
Peter Maydell 5a68a3add6 Update version for v11.0.0-rc0 release
Signed-off-by: Peter Maydell <[email protected]>
2026-03-18 15:56:51 +00:00
Peter Maydell aed38fe520 Merge tag 'pr-plugins-20260317' of https://gitlab.com/pbo-linaro/qemu into staging
Changes:
- [PATCH v2 v2] plugins/api-system: Handle migrate_add_blocker() failure (Trieu Huynh <[email protected]>)
  Link: https://lore.kernel.org/qemu-devel/[email protected]

# -----BEGIN PGP SIGNATURE-----
#
# iQGzBAABCgAdFiEEZrmU7KFPfy5auggff5BUDQoc0A8FAmm5p+8ACgkQf5BUDQoc
# 0A9/RAv/TdNX7b8ah5TjRkmdh5HQDF9/bXCBCOiXndRM9wvgPfbZ+5Hm84jXWL3E
# U+NyznaPlpkUE0qomx11yVIV9kVuW5dZYCXUs2LaQqEg9ldT+r69Mt976AfM7yv4
# GkzszVFjfiQkSVllnqcM8McvTnkrS9h64ec5bv16ptyG4vrgmJ9ldsKZBz/1sXNL
# Yh16etRJTWqVOQXxRqOjS0klZh6RKQ2Tpy7T/nNHuI3ED6Gx1rBiXmRMsSkoAm5i
# GGoAoHtitu9DsnvY8XocE6C5F8es7W4gqmg37fSrbGO3AjVLwwW+sBD4a9gFE1GN
# mAJ3SvA/+ViwwzsBJZZJAHRSyJdtw3f998yC3yfZxsIWJmBb6EMIVZHn8J/UMj9D
# P68Ys4ulZgEvKjA6XMlONYYMLKTAo527qFW2qU3PX/mlqp0pw4xhxvTxu3QmutPs
# yijm1kzJ67ziOlwc/QCdf8t7nZaUIk/8HEPmwPCJ4CPhxmQxxsgHzdf4UiLNqQEy
# PlDR9z/Q
# =6Dj9
# -----END PGP SIGNATURE-----
# gpg: Signature made Tue Mar 17 19:13:51 2026 GMT
# gpg:                using RSA key 66B994ECA14F7F2E5ABA081F7F90540D0A1CD00F
# gpg: Good signature from "Pierrick Bouvier <[email protected]>" [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: 66B9 94EC A14F 7F2E 5ABA  081F 7F90 540D 0A1C D00F

* tag 'pr-plugins-20260317' of https://gitlab.com/pbo-linaro/qemu:
  plugins/api-system: Handle migrate_add_blocker() failure

Signed-off-by: Peter Maydell <[email protected]>
2026-03-18 10:12:59 +00:00
Peter Maydell 8844421b59 Merge tag 'single-binary-20260317' of https://github.com/philmd/qemu into staging
Few patches related to single binary effort:

- Build some stub files once
- Replace TARGET_PAGE_BITS by qemu_target_page_bits()

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCAAdFiEE+qvnXhKRciHc/Wuy4+MsLN6twN4FAmm6PhwACgkQ4+MsLN6t
# wN63yw//ddngvlvmeL1h3SlOqNYfgk/yb6f1kWj7NjeKws78Vflp0XimxI3Tm94k
# Df7kRgNr8gLFaDawiJRwb2jsd+2mAWq/v/50nc9t0k6U9dmNFVQHDSrSLSKozual
# /AZP1EtWUow44ad7QARj5ccFHwPKT8vjW1trUjKy5hOqgnnSu+VXYul7NFCskMfq
# j52yLL6sOtyjHbzuO3Ndfq67bnQnGmi+2Cu/LjLyIfPrbbm+pziXcwZk3ghJKGxo
# h33VtGewhaIOsRpv2rmxSSZQMlCKRiLBFF5K/oM/V+bZUlhEfmcrDpGx0JZvxjcc
# +XclP4wcAFLepkb+2BnogsXuU57uV+WAU/xqhn0OSqN9IAOza1b0EUBuMji7IFxY
# 3C5X7JkVC/lG1cOvchkIEkZ7bivCidyWbIMphnfoIxWDjtDKjIHT/b1GnjqEbo8n
# lI0bsNR3pDSqi4xqmE+H7yWQqTO2BFdHzRq/o3sWR8lN4lC+MoKLAXx2i824iUgA
# t9TkSLnocxiKZSip/ByWExAE3RgAxetBL16wFxlgJrLIyyGePkzMbSXprGf2El5C
# yIdULTHg0L/dFJu2EJKURLGb8RC/LCvN+oaH206lToDMAsNHqCSyhriLbJ1s+B+B
# bmppVVP3DP//Mp0Y1DJhwd+fsgXZypEzhJ/C+LIMtN0SZWkjwRc=
# =fwcr
# -----END PGP SIGNATURE-----
# gpg: Signature made Wed Mar 18 05:54:36 2026 GMT
# gpg:                using RSA key FAABE75E12917221DCFD6BB2E3E32C2CDEADC0DE
# gpg: Good signature from "Philippe Mathieu-Daudé (F4BUG) <[email protected]>" [full]
# Primary key fingerprint: FAAB E75E 1291 7221 DCFD  6BB2 E3E3 2C2C DEAD C0DE

* tag 'single-binary-20260317' of https://github.com/philmd/qemu:
  target/ppc: Replace TARGET_PAGE_BITS -> qemu_target_page_bits()
  hw/s390x/vfio: Replace TARGET_PAGE_BITS -> qemu_target_page_bits()
  hw/misc: Build 'mac_via' as common unit file
  hw/display: Build stubs once
  fsdev: Build stubs once

Signed-off-by: Peter Maydell <[email protected]>
2026-03-18 10:12:50 +00:00
Peter Maydell 0063f9a445 Merge tag 'migration-20260317-pull-request' of https://gitlab.com/farosas/qemu into staging
Migration/Qtest pull request

Various fixes

# -----BEGIN PGP SIGNATURE-----
#
# iQJEBAABCAAuFiEEqhtIsKIjJqWkw2TPx5jcdBvsMZ0FAmm5muIQHGZhcm9zYXNA
# c3VzZS5kZQAKCRDHmNx0G+wxnVpBEADQYBxOt+SzHpHfv/BqJ2dx0zrJK44+wjUd
# gL8iLA7cd0/Rri2gYV1GuVEiNarC10Fg8NSNf/td2HbucDHviwkg9G84GgbjdyXl
# CWs6pseTkCk0X1W+o/fEaXB4ve1ES4RyJwCpWL+QCN3XUNuaMA7YnFB+8ksW2AuA
# lsgNU6mvXHrR8agTl77/G0R5/mVZ5lu5p9gwz09PCXk0nrWyi5j2a7rA2zLneLuk
# jBfEa5b9yX7au/DL/55wMszkA8NRqft0CabJxTZRYO5YNPXvlsJS0L3gWHWDQ9DB
# I895zk2JnagARpiu/v/eHSf+b6nnmE+huAYxv8iXTw9aOet/2aLusJidS+S5IIV4
# 7Lkomis/ch8KqnDMB+SPnW/9TplfKHHa3Jv/3ZphbOwSM6SxjcHHTtUaIvAhQeAt
# DSLBdprDcMePYxi9ugoZLkIHgJGNiWnx+egOrEMa4ShyDXmIlxcjuV4/RtjI158V
# UXK4qPw2f60+Ic+d6gUMpByEX1O2BZziL97qHLAKWYtA9mktL+mX2x6sIEkIjrQJ
# F6dJcE1yvMY6Imhz+zRcS0Dck+vafHGA0DP8t1oxMYcBKeaGrCzuS9jCBQEp10hk
# L/P2jfdgvtlLRXhcoa22Ynn2qNkJDLEAy6+xHH8thkaaYeg52NGO5wGIYe5+F766
# Cekez3u3NA==
# =7Smy
# -----END PGP SIGNATURE-----
# gpg: Signature made Tue Mar 17 18:18:10 2026 GMT
# gpg:                using RSA key AA1B48B0A22326A5A4C364CFC798DC741BEC319D
# gpg:                issuer "[email protected]"
# gpg: Good signature from "Fabiano Rosas <[email protected]>" [unknown]
# gpg:                 aka "Fabiano Almeida Rosas <[email protected]>" [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: AA1B 48B0 A223 26A5 A4C3  64CF C798 DC74 1BEC 319D

* tag 'migration-20260317-pull-request' of https://gitlab.com/farosas/qemu:
  tests/qtest/test-hmp: Free machine options
  tests/qtest: Don't dup machine name in qtest_cb_for_every_machine callbacks
  migration: fix implicit integer division in migration_update_counters
  migration/options: Fix leaks in StrOrNull qdev accessors
  migration: assert that the same migration handler is not being added twice
  tests/qtest/migration: Force exit-on-error=false
  migration/multifd: Fix leaks of TLS error objects
  tests/qtest/migration: Fix leak in CPR exec test
  io: Fix TLS bye task leak
  tests/qtest/migration: Fix leak of migration tests data

Signed-off-by: Peter Maydell <[email protected]>
2026-03-18 10:12:39 +00:00
Peter Maydell f520fc4b04 Merge tag 'for-11.0-pull-request' of https://gitlab.com/marcandre.lureau/qemu into staging
Gather various audio/ui/dump patches for 11.0-rc

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCgAdFiEEh6m9kz+HxgbSdvYt2ujhCXWWnOUFAmm5jPYACgkQ2ujhCXWW
# nOWsxQ/+LOVsrCjxSQTI7Iygo8ICXBKwjBXOHA9g4PHMSZDD5B+WbCXLXRPfSwkj
# y+zjJpv13pqXXNFKw0MoEz6kIRKFWYq1XbHLgkXt538QIEJ5h5tff0V8YGtk9U0H
# D2ZwUBOWH7OW4VDCFg2BCYNrnC4y2wxFG7lSm5tbeJzkAogsLRDNPf5thvHgdS+U
# oYP2g8WdXx5ZgX8/f9tvDApTPXjfg1eATLy8veSZWkgqaCL8pO5E436sVT+cPRii
# aFQpiTPms6vutOtQpWLHv6Kvffvkk0A1zrdlRrvlEhhWT3v5sBvF5hVH/iEt+LIL
# ldChBtJnzc40ujsdKHSmUV+foCnKQYuWSwzgJaxSg2Rp81yrVZ+L8nz3f8W/raPp
# 5dWr+i6e80+2nUvDL3LA6HOJGz2JtQyaRXc4BgiwePEMKT6RfFW9V4mWRp4ItlRv
# 3mWhGFjPRLEU8kOefAcT77epe1gwLdlpUH3ZjCqECZYUWNu5FjNjPQUZ1kxD3o0K
# 7TyxLrZ6OH9b3mGhum17GBF0tAI3rkErriOxzjQF3UqMsFB9+OZlzQNfQRL/NnYw
# NjmV8JMXRe2+tjxS1bfqcUanmKpxYqiDJPJaoWG08VHuhuXBydfhiOhrG61H1u3N
# yoq5kb8XZ4LiSin+smSl5a9gCa7qZ17ceAAxuuCbItCXuHZ4nsk=
# =K+XO
# -----END PGP SIGNATURE-----
# gpg: Signature made Tue Mar 17 17:18:46 2026 GMT
# gpg:                using RSA key 87A9BD933F87C606D276F62DDAE8E10975969CE5
# gpg: Good signature from "Marc-André Lureau <[email protected]>" [full]
# gpg:                 aka "Marc-André Lureau <[email protected]>" [full]
# Primary key fingerprint: 87A9 BD93 3F87 C606 D276  F62D DAE8 E109 7596 9CE5

* tag 'for-11.0-pull-request' of https://gitlab.com/marcandre.lureau/qemu:
  coreaudio: Initialize the buffer for device change
  audio: Add functions to initialize buffers
  coreaudio: Commit the result of init in the end
  coreaudio: Improve naming
  ui/surface: Avoid including epoxy/gl.h in header files
  ui/console: Remove DisplaySurface::mem_obj
  ui/console: Unify pixman-OpenGL format mapping
  dump: enhance dump_state_prepare fd initialization
  ui/gtk-egl: Ensure EGL surface is available before drawing
  ui/dbus-listener: remove dbus_filter on connection close
  ui/dbus-listener: Fix FBO leak in dbus_cursor_dmabuf
  virtio-gpu: use computed rowstride instead of deriving it from hostmem
  virtio-gpu: fix overflow check when allocating 2d image
  ui/vdagent: add migration blocker when machine version < 10.1
  rutabaga: improve error handling, fix potential crash during init
  audio/mixeng: drop some needless checks

Signed-off-by: Peter Maydell <[email protected]>
2026-03-18 09:17:08 +00:00
Peter Maydell c9dbd923f7 Merge tag 'pull-ppc-for-11.0-hardfreeze-20260317' of https://gitlab.com/harshpb/qemu into staging
ppc queue for 11.0

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCAAdFiEEa4EM1tK+EPOIPSFCRUTplPnWj7sFAmm5bZ4ACgkQRUTplPnW
# j7vZvQ/9HlYrlHQD3eQSEyUlVoEkR4piSh/D8sdigOOOdYhPEQZ6spluHg3OLEml
# MvDv2Uz1t8GVKzGuZ19Y18H8wOW0zbjsOa9bfbtO7Mral7LIMbBFLej391czQVQC
# NQ64Wms2B2TwjKDam8msekMkME646m5SanzgT1hGkKmIAKKSCBLwA9Na1HfxdcwQ
# 1TcDpjHBLg0x3OOmkh7V1PYyb7RSIAFRcYEkPnvgEWvIOaGubTVpB7/syb2n+cdq
# ToPy0MvoIdlPID0wFd0t7t3tRPah/ubXD4ubrOEvWLDZ40BtLiB3p1Ou+MUU6lj1
# GfPx7gjW4QG4o5aV4MmsAKxEP6K3RfJcRVjJUa3tl8oJvggS9uwvewEqHT07XBWc
# NmxdEGzgkLCUXAVZLkKjqInz5VJlHROUWpsS8bq1edK09wju1o1CR0B0WDK//Cek
# oqfZtb/6XHvmFrNnJprJvPNOWuhash1XRbL+iyfYxJJwuqIZPkQWjABeD7Fu8/aZ
# Gpw3/2V+CiWJvThe9Z/vIEw/ksl1qigdNCtdVMeO9S8pQAtORZnUvNzWN5QKaVvL
# VjxsFXhiEEn6bdoycJE0V6mfuPGaKcvE/APTDA4dT1b4du8IaUiiqGvGvVY+F1vg
# p7ZpDlJmKd48jbkXnim8YiyXZO3sUUk7tw0N/xwPvCj+56nTv64=
# =OUEg
# -----END PGP SIGNATURE-----
# gpg: Signature made Tue Mar 17 15:05:02 2026 GMT
# gpg:                using RSA key 6B810CD6D2BE10F3883D21424544E994F9D68FBB
# gpg: Good signature from "Harsh Prateek Bora <[email protected]>" [full]
# gpg:                 aka "Harsh Prateek Bora <[email protected]>" [full]
# Primary key fingerprint: 6B81 0CD6 D2BE 10F3 883D  2142 4544 E994 F9D6 8FBB

* tag 'pull-ppc-for-11.0-hardfreeze-20260317' of https://gitlab.com/harshpb/qemu:
  ppc/pnv: fix dumpdtb option

Signed-off-by: Peter Maydell <[email protected]>
2026-03-18 09:16:58 +00:00
Peter Maydell 60ed428e5d Merge tag 'pull-block-2026-03-17' of https://gitlab.com/hreitz/qemu into staging
Block layer patches for rc0

- Fix race condition in throttle-group code triggering an assertion
  failure
- Fix assertion failure in mirror job when issuing job-complete twice

# -----BEGIN PGP SIGNATURE-----
#
# iQJGBAABCgAwFiEEy2LXoO44KeRfAE00ofpA0JgBnN8FAmm5SG8SHGhyZWl0ekBy
# ZWRoYXQuY29tAAoJEKH6QNCYAZzfMvMP/0IXpGtqMmG4cHvW6KS+VDrX4AOA7ZOg
# 8TP7KhpiFPKxnTzdlSiwlbNGAndUdxA8Ef7z5SUF0kslG9N+Ry3BCG6oB3b1zHAA
# 1Irz30FWny0zlESAvLjsK6KAetGEX/ZKKiEfWjlamZSfWzLI5RK5M8x59SxSene5
# oOe3+nxPV/I2VnXI1+svD3VtPjFxNjx2aA51sUfyuQRMP1II3XUdWCSv6DSb8wAh
# QVTFYWnFK9lHejXIXVOTHas5JG30cvC9fAsIBW8mK5J4rRWJP4zfqq5SQbgg9vtm
# pv0YZS8h0X/Vj3SSbPV6abP4MecVTLvvqCr/gRc+OtHbltK4HFMl3Y29VPDO5vTY
# XCPInFv6D84CliCESx2hGUJx9APScZqH047hxlmTTYdQGO2/RQSI6mr83CoVwKBh
# AmN23A5T2Bru+3zKea8HMwi/8NVtvZUWxJfq/NQRThXtLHILPTzKR6QP2VV8ZyD0
# d4Tqk1CqwE/yitbu9xjxpE5lC3O67q/X8DsH5SYiHJZVxSxQYs4b6LirHmlQrN4F
# aW3TQ7C18re4iqqPK3rlRsgR2q0pEdTbkBqSp5I7ZPU/QKLdklKgYnjI4ZefwjGy
# cMPy94rfP7HINH6SHX6R6AhIqFmPIxr1gPE3IjdOIWEqXV5r89DJ0ehrwWogasFv
# q1Qq7HRBIgwX
# =9y5H
# -----END PGP SIGNATURE-----
# gpg: Signature made Tue Mar 17 12:26:23 2026 GMT
# gpg:                using RSA key CB62D7A0EE3829E45F004D34A1FA40D098019CDF
# gpg:                issuer "[email protected]"
# gpg: Good signature from "Hanna Reitz <[email protected]>" [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: CB62 D7A0 EE38 29E4 5F00  4D34 A1FA 40D0 9801 9CDF

* tag 'pull-block-2026-03-17' of https://gitlab.com/hreitz/qemu:
  block/mirror: fix assertion failure upon duplicate complete for job using 'replaces'
  throttle-group: Fix race condition in throttle_group_restart_queue()

Signed-off-by: Peter Maydell <[email protected]>
2026-03-18 09:16:48 +00:00
Peter Maydell ceaa7da4c4 Merge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging
* runstate: handle return code of EOPNOTSUPP properly from rebuild_guest()
* meson: do not hardcode paths to generated files
* rust: fix build when --disable-rust and meson < 1.9
* rust: suggest passing --locked to "cargo install"

# -----BEGIN PGP SIGNATURE-----
#
# iQFIBAABCgAyFiEE8TM4V0tmI4mGbHaCv/vSX3jHroMFAmm6YIAUHHBib256aW5p
# QHJlZGhhdC5jb20ACgkQv/vSX3jHroMUCgf/W4sL/UM7+SWErMtpO5pHFu+bM15F
# 4wDq7DcGi0xD9CbjSfLy089+kDT5zhCU3/CFTWLRe78V4gEyNBAmRsb03M8NNyrw
# cw3iDoOMeHnMdhhJXIb2eZrohq9oavvvGAaOSMfH8FxMlhH+548MNQcgRLA4UgFS
# gcgYBoD7o+o4WLEgS7yCe904h3lX89wptv8ULMNLpBXxc7LFOXggwX6d1+An9pZO
# UAFW2qQnxg+OH0TIh7gH/GweGZLQsDMg39NMnJNpoRg4W91bZYZZAo1AoVMOIILE
# JPPQ73xNRAFSgao9s9+ObuLPdyxycxnSzrAZBlePvBqIbTgiCdQ1Xe7ysQ==
# =BEea
# -----END PGP SIGNATURE-----
# gpg: Signature made Wed Mar 18 08:21:20 2026 GMT
# gpg:                using RSA key F13338574B662389866C7682BFFBD25F78C7AE83
# gpg:                issuer "[email protected]"
# gpg: Good signature from "Paolo Bonzini <[email protected]>" [full]
# gpg:                 aka "Paolo Bonzini <[email protected]>" [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:
  rust: suggest passing --locked to "cargo install"
  rust: fix build when --disable-rust and meson < 1.9
  build-sys: use the "run" variable
  runstate: handle return code of EOPNOTSUPP properly from rebuild_guest()

Signed-off-by: Peter Maydell <[email protected]>
2026-03-18 09:16:26 +00:00
Paolo Bonzini 6257754bb9 rust: suggest passing --locked to "cargo install"
Without the option, cargo will try using the latest version of the
dependencies of bindgen-cli. While it will obviously respect the
constraints in Cargo.toml, old versions of Cargo do not have
version-constrained resolution and will choke on dependencies
that need Rust 2024.

Cc: Daniel P. Berrangé <[email protected]>
Cc: Peter Maydell <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
2026-03-18 09:20:57 +01:00
Philippe Mathieu-Daudé eca25ddb32 target/ppc: Replace TARGET_PAGE_BITS -> qemu_target_page_bits()
Get the target page bits at runtime.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Message-Id: <[email protected]>
2026-03-18 06:53:23 +01:00
Philippe Mathieu-Daudé 0d05d9365c hw/s390x/vfio: Replace TARGET_PAGE_BITS -> qemu_target_page_bits()
Get the target page bits at runtime.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Message-Id: <[email protected]>
2026-03-18 06:53:23 +01:00
Philippe Mathieu-Daudé 362d79e1a3 hw/misc: Build 'mac_via' as common unit file
Nothing there is target-specific anymore.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Message-Id: <[email protected]>
2026-03-18 06:53:23 +01:00
Philippe Mathieu-Daudé 988499515d hw/display: Build stubs once
Move stubs to the global stub_ss[] source set. These files
are now built once for all binaries, instead of one time
per system binary.

Add pixman to qemuutil library dependencies since pixman is
transitively included, which is needed to be able to include
prototypes for stubs we declared:

  In file included from include/ui/console.h:4,
  include/ui/qemu-pixman.h:10:10: fatal error: pixman.h: No such file or directory
     10 | #include <pixman.h>
        |          ^~~~~~~~~~

On OpenBSD, opengl headers are not available in default
include path, and thus we need to add opengl to list of
qemuutil dependencies, otherwise we get:

  In file included from ../hw/display/acpi-vga-stub.c:4:
  In file included from ../hw/display/vga_int.h:28:
  In file included from include/ui/console.h:9:
  include/ui/surface.h:11:11: fatal error: 'epoxy/gl.h' file not found
  # include <epoxy/gl.h>
            ^~~~~~~~~~~~
  1 error generated.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <[email protected]>
Co-developed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Pierrick Bouvier <[email protected]>
Message-Id: <[email protected]>
2026-03-18 06:52:14 +01:00
Trieu Huynh db52193355 plugins/api-system: Handle migrate_add_blocker() failure
migrate_add_blocker() can fail (e.g. if migration is already in
progress), in which case it returns a negative value and populates
its errp argument with the reason.

The previous code ignored the return value. Pass &error_fatal so
that on failure QEMU exits cleanly with an informative error message
rather than continuing in an inconsistent state.

Resolves: CID 1645470
Signed-off-by: Trieu Huynh <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Tested-by: Pierrick Bouvier <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Pierrick Bouvier <[email protected]>
2026-03-17 12:13:16 -07:00
Philippe Mathieu-Daudé 4a425e5f13 fsdev: Build stubs once
Move stubs to the global stub_ss[] source set. These files
are now built once for all binaries, instead of one time
per system binary.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <[email protected]>
2026-03-17 19:50:05 +01:00
Fabiano Rosas 8f627bf1be tests/qtest/test-hmp: Free machine options
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-03-17 14:58:09 -03:00
Fabiano Rosas b9b1ca5162 tests/qtest: Don't dup machine name in qtest_cb_for_every_machine callbacks
The qtest_get_machines function caches the list of machines in a
static variable. Dup'ing the machine->name string only serves to leak
that memory when a single test is executed.

Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-03-17 14:57:44 -03:00
Aadeshveer Singh b6a6d91b9e migration: fix implicit integer division in migration_update_counters
switchover_bw is a uint64_t, so switchover_bw / 1000 results in an
integer division. This value is then assigned to expected_bw_per_ms
which is of type double. This results in losing precision and is type
unsafe. Adding explicit cast ensures floating-point division.

Signed-off-by: Aadeshveer Singh <[email protected]>
Reviewed-by: Peter Xu <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-03-17 14:56:40 -03:00
Akihiko Odaki 461632f0b1 coreaudio: Initialize the buffer for device change
Reallocate buffers when the active device change as the required buffer
size may differ.

Signed-off-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Reviewed-by: Phil Dennis-Jordan <[email protected]>
Acked-by: Christian Schoenebeck <[email protected]>
Reviewed-by: Christian Schoenebeck <[email protected]>
Reviewed-by: Marc-André Lureau <[email protected]>
Message-Id: <[email protected].i.u-tokyo.ac.jp>
2026-03-17 21:15:10 +04:00
Akihiko Odaki c3492514c7 audio: Add functions to initialize buffers
These functions can be used to re-initialize buffers when hardware
parameters change due to device hotplug, for example.

Signed-off-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Reviewed-by: Phil Dennis-Jordan <[email protected]>
Reviewed-by: Christian Schoenebeck <[email protected]>
Reviewed-by: Marc-André Lureau <[email protected]>
Message-Id: <[email protected].i.u-tokyo.ac.jp>
2026-03-17 21:15:10 +04:00
Akihiko Odaki f47a5a3d47 coreaudio: Commit the result of init in the end
init_out_device may only commit some part of the result and leave the
state inconsistent when it encounters a fatal error or the device gets
unplugged during the operation, which is expressed by
kAudioHardwareBadObjectError or kAudioHardwareBadDeviceError. Commit the
result in the end of the function so that it commits the result iff it
sees no fatal error and the device remains plugged.

With this change, handle_voice_change can rely on core->outputDeviceID
to know whether the output device is initialized after calling
init_out_device.

Signed-off-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Acked-by: Marc-André Lureau <[email protected]>
Message-Id: <[email protected].i.u-tokyo.ac.jp>
2026-03-17 21:15:10 +04:00
Akihiko Odaki bba8a87001 coreaudio: Improve naming
coreaudio had names that are not conforming to QEMU codding style.
coreaudioVoiceOut also had some members that are prefixed with redundant
words like "output" or "audio".
Global names included "out" to tell they are specific to output devices,
but this rule was not completely enforced.
The frame size had three different names "frameSize", "bufferFrameSize",
and "frameCount".

Replace identifiers to fix these problems.

Signed-off-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Marc-André Lureau <[email protected]>
Message-Id: <[email protected].i.u-tokyo.ac.jp>
2026-03-17 21:15:10 +04:00
Akihiko Odaki cc47123440 ui/surface: Avoid including epoxy/gl.h in header files
include/ui/shader.h and include/ui/surface.h are included by files that
do not depend on Epoxy so they shouldn't include epoxy/gl.h. Otherwise,
compilations of these files can fail because the path to the directory
containing epoxy/gl.h may not be passed to the compiler.

Signed-off-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Reviewed-by: Marc-André Lureau <[email protected]>
Message-Id: <[email protected].i.u-tokyo.ac.jp>
2026-03-17 21:15:10 +04:00
Akihiko Odaki 633c529416 ui/console: Remove DisplaySurface::mem_obj
Only spice uses it so move it to spice.

Signed-off-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Reviewed-by: Marc-André Lureau <[email protected]>
Message-Id: <[email protected].i.u-tokyo.ac.jp>
2026-03-17 21:15:10 +04:00
Akihiko Odaki 9aa7be3a7d ui/console: Unify pixman-OpenGL format mapping
console_gl_check_format() was supposed to check if the pixman format is
supported by surface_gl_create_texture(), but it missed
PIXMAN_BE_x8r8g8b8 and PIXMAN_BE_a8r8g8b8, which are properly mapped to
OpenGL formats by surface_gl_create_texture().

Fix the discrepancy of the two functions by sharing the code to map
pixman formats to OpenGL ones.

Signed-off-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Reviewed-by: Marc-André Lureau <[email protected]>
Message-Id: <[email protected].i.u-tokyo.ac.jp>
2026-03-17 21:15:10 +04:00
Nikolai Barybin 8114cd44c8 dump: enhance dump_state_prepare fd initialization
Initializing descriptor with zero is unsafe: during cleanup we risk to
unconditional close of fd == 0 in case dump state wasn't fully
initialized. Thus, let's init fd with -1 value and check its value
before closing it.

Signed-off-by: Nikolai Barybin <[email protected]>
Reviewed-by: Daniel P. Berrangé <[email protected]>
Reviewed-by: Marc-André Lureau <[email protected]>
Message-Id: <[email protected]>
2026-03-17 21:15:10 +04:00
Dongwon Kim c141bcb6af ui/gtk-egl: Ensure EGL surface is available before drawing
The EGL surface and context are destroyed when a new GTK window is
created. We must ensure these are recreated and initialized before
any rendering happens in gd_egl_refresh.

Currently, the check for a pending draw is performed before the
surface initialization block. This can result in an attempt to
draw when the EGL surface (vc->gfx.esurface) is not yet available.

This patch moves the drawing check after the surface initialization
to ensure a valid surface exists before rendering in gd_egl_refresh.

Cc: Gerd Hoffmann <[email protected]>
Cc: Marc-André Lureau <[email protected]>
Signed-off-by: Vivek Kasireddy <[email protected]>
Signed-off-by: Dongwon Kim <[email protected]>
Acked-by: Marc-André Lureau <[email protected]>
Message-Id: <[email protected]>
2026-03-17 21:15:10 +04:00
Marc-André Lureau b6506de40f ui/dbus-listener: remove dbus_filter on connection close
The dbus filter holds a strong reference to the DBusDisplayListener
(via GDestroyNotify) to ensure the listener remains alive while the
filter may still be running in another thread. This creates a
reference cycle (ddl -> conn -> filter -> ddl) that prevents the
listener from being freed.

Break the cycle by connecting to the connection's "closed" signal
and removing the filter when the connection closes.

Fixes: commit fa88b85dea ("ui/dbus: filter out pending messages when scanout")
Signed-off-by: Marc-André Lureau <[email protected]>
2026-03-17 21:15:10 +04:00
Marc-André Lureau 0e9e50f9dd ui/dbus-listener: Fix FBO leak in dbus_cursor_dmabuf
cursor_fb is a local egl_fb that gets an FBO allocated via
egl_fb_setup_for_tex but is never destroyed, leaking the
framebuffer object on every cursor update.

Add egl_fb_destroy() after the cursor data has been read.

Fixes: commit 142ca628a7 ("ui: add a D-Bus display backend")
Signed-off-by: Marc-André Lureau <[email protected]>
2026-03-17 21:15:10 +04:00
Marc-André Lureau 2a886bda47 virtio-gpu: use computed rowstride instead of deriving it from hostmem
Since calc_image_hostmem() already computes the stride, return it and
use it directly. This is both simpler and more correct.

Signed-off-by: Marc-André Lureau <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Message-Id: <[email protected]>
2026-03-17 21:15:10 +04:00
Marc-André Lureau c035d5eadf virtio-gpu: fix overflow check when allocating 2d image
The calc_image_hostmem() comment says pixman_image_create_bits() checks
for overflow. However, this relied on the facts that "bits" was NULL and
it performed it when it was introduced. Since commit 9462ff4695, the
"bits" argument can be provided and the check is no longer applied.

Promotes the computation to uint64_t and adds an explicit overflow check
to avoid potential later OOB read/write on the image data.

Fixes: CVE-2026-3886
Fixes: ZDI-CAN-27578
Fixes: 9462ff4695 ("virtio-gpu/win32: allocate shareable 2d resources/images")
Reported-by: Zero Day Initiative <[email protected]>
Signed-off-by: Marc-André Lureau <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Message-Id: <[email protected]>
2026-03-17 21:15:10 +04:00
Fiona Ebner 6f23dde620 ui/vdagent: add migration blocker when machine version < 10.1
In QEMU 10.1, commit 5d56bff11e ("ui/vdagent: add migration support")
added migration support for the vdagent chardev and commit 42000e0013
("ui/vdagent: remove migration blocker") removed the migration
blocker. No compat for older machine versions was added, so migration
with pre-10.1 machine version, from a 10.1 binary to a pre-10.1 binary
will result in a failure when loading the VM state in the target
instance:

> Unknown savevm section or instance 'vdagent' 0. Make sure that your
> current VM setup matches your saved VM setup, including any
> hotplugged devices

Add a compat flag to block migration when the machine version is less
than 10.1 to avoid this.

Cc: [email protected]
Fixes: 42000e0013 ("ui/vdagent: remove migration blocker")
Signed-off-by: Fiona Ebner <[email protected]>
Reviewed-by: Fabiano Rosas <[email protected]>
Reviewed-by: Marc-André Lureau <[email protected]>
Message-Id: <[email protected]>
2026-03-17 21:15:10 +04:00
Marc-André Lureau 5322889f07 rutabaga: improve error handling, fix potential crash during init
When virtio_gpu_rutabaga_get_num_capsets() returns 0, virtio_init()
isn't called and the device later crashes during realize.
==72545==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x556ad6f7ba9e bp 0x7ffe6958f810 sp 0x7ffe6958f7e0 T0)
==72545==The signal is caused by a READ memory access.
==72545==Hint: address points to the zero page.
#0 0x556ad6f7ba9e in virtio_memory_listener_commit ../hw/virtio/virtio.c:4034
#1 0x556ad6a24c96 in listener_add_address_space ../system/memory.c:3128
#2 0x556ad6a25d15 in memory_listener_register ../system/memory.c:3216
#3 0x556ad6f7bf11 in virtio_device_realize ../hw/virtio/virtio.c:4075

Rework error handling of the function to set Error appropriately. 0
capset may be ok now.

Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Marc-André Lureau <[email protected]>
2026-03-17 21:15:10 +04:00
Marc-André Lureau 58e0580ab8 audio/mixeng: drop some needless checks
The NULL checks for be, name, callback_fn, and as in
audio_mixeng_backend_open_{in,out} are redundant: the callers
audio_be_open_{in,out} already assert that name, callback_fn, and as
are non-NULL, and dereference be unconditionally via
AUDIO_BACKEND_GET_CLASS(be) before the call.

Signed-off-by: Marc-André Lureau <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Message-Id: <[email protected]>
2026-03-17 21:15:09 +04:00
Fabiano Rosas 11d1b7da67 migration/options: Fix leaks in StrOrNull qdev accessors
Fix a couple of possible leaks detected by Coverity. Both are
currently harmless. This code is only used for the very specific
purpose of maintaining compatibility of a few migration options which
can be set via QEMU command line (-global migration.tls-*). The
command line interface is not supported and only used during
development and testing.

1) The setter function set_StrOrNull() is invoked whenever the -global
migration.tls-* command line options are set. The way it could leak is
that the temporary "StrOrNull *str_or_null" object is allocated before
calling the visitor, which could fail and cause an early return of the
function, leaving *ptr unset and str_or_null leaking.

2) The getter function get_StrOrNull() is unreachable code. It's only
there to provide a complete implementation of the property. Still, the
way it could leak is that the temporary "StrOrNull *str_or_null" might
be allocated and is simply never returned to the caller nor freed.

Fix the possible leaks:

1) at set_StrOrNull(): change the allocation of str_or_null to happen
only after the visit call has returned successfully.

2) at get_StrOrNull(): assert that the object is non-NULL, there is no
need for a temporary object.

The reason it should be non-NULL is that the property is initialized
by the default setter of the qdev property. The initialization is
unlikely to fail because the call to the setter is setup by qdev,
which has boilerplate ensuring the to-be-set object is allocated and
of the correct type. Moreover, passing NULL via command line to
-global migration.tls-* is not possible.

A programming error could result in an invalid call to the setter,
which would leave the object NULL and cause a crash in the getter, but
that's not a worthwhile scenario to protect against given the low
probability of this code being even reached.

While here, update the comment about why there's no QNULL in this
StrOrNull property to be more clear.

Fixes: CID 1643919
Fixes: CID 1643920
Cc: Markus Armbruster <[email protected]>
Reported-by: Peter Maydell <[email protected]>
Reviewed-by: Peter Xu <[email protected]>
Reviewed-by: Prasad Pandit <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-03-17 13:34:13 -03:00
Ani Sinha 22b0179639 migration: assert that the same migration handler is not being added twice
Currently the code that adds a migration blocker does not check if the same
blocker already exists. Assert that the migration handler being added has
not been added already.

CC: Markus Armbruster <[email protected]>
CC: Peter Xu <[email protected]>
CC: Prasad Pandit <[email protected]>
Reviewed-by: Peter Xu <[email protected]>
Signed-off-by: Ani Sinha <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-03-17 13:34:13 -03:00
Fabiano Rosas 4e8c4dda97 tests/qtest/migration: Force exit-on-error=false
Some tests can cause QEMU to exit(1) too early while the incoming
coroutine has not yielded for a first time yet. This trips ASAN
because resources related to dispatching the incoming process will
still be allocated in the io/channel.c layer without a
straight-forward way for the migration code to clean them up.

As an example of one such issue, the UUID validation happens early
enough that the temporary socket from qio_net_listener_channel_func()
still has an elevated refcount. If it fails, the listener dispatch
code never gets to free the resource:

Direct leak of 400 byte(s) in 1 object(s) allocated from:
    #0 0x55e668890a07 in malloc asan_malloc_linux.cpp:68:3
    #1 0x7f3c7e2b6648 in g_malloc ../glib/gmem.c:130
    #2 0x55e66a8ef05f in object_new_with_type ../qom/object.c:767:15
    #3 0x55e66a8ef178 in object_new ../qom/object.c:789:12
    #4 0x55e66a93bcc6 in qio_channel_socket_new ../io/channel-socket.c:70:31
    #5 0x55e66a93f34f in qio_channel_socket_accept ../io/channel-socket.c:401:12
    #6 0x55e66a96752a in qio_net_listener_channel_func ../io/net-listener.c:64:12
    #7 0x55e66a94bdac in qio_channel_fd_source_dispatch ../io/channel-watch.c:84:12
    #8 0x7f3c7e2adf4b in g_main_dispatch ../glib/gmain.c:3476
    #9 0x7f3c7e2adf4b in g_main_context_dispatch_unlocked ../glib/gmain.c:4284
    #10 0x7f3c7e2b00c8 in g_main_context_dispatch ../glib/gmain.c:4272

The exit(1) also requires some tests to setup qtest to expect a return
code of 1 from the QEMU process. Although we can check migration
status changes to be fairly certain where the failure happened, there
is always the possibility of QEMU exiting for another reason and the
test passing. This happens frequently with sanitizers enabled, but
also risks masking issues in the regular build.

Stop allowing the incoming migration to exit and instead require the
tests to wait for the FAILED state and end QEMU gracefully with
qtest_quit.

In practice this means setting exit-on-error=false for every incoming
migration, changing MIG_TEST_FAIL_DEST_QUIT_ERR to MIG_TEST_FAIL and
waiting for a change of state where necessary.

With this, the MIG_TEST_FAIL_DEST_QUIT_ERR error result is now unused,
remove it.

The affected tests are:
validate_uuid_error
multifd_tcp_cancel
dirty_limit
precopy_unix_tls_x509_default_host
precopy_tcp_tls_no_hostname
tcp_tls_x509_mismatch_host
dbus_vmstate_missing_src
dbus_vmstate_missing_dst

Also add a comment to QEMU source explaining that the incoming
coroutine might block for a while until it yields as this is the
actual root cause of the issue.

Reviewed-by: Peter Xu <[email protected]>
Reviewed-by: Prasad Pandit <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
[assert that key doesn't already exists]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-03-17 13:34:13 -03:00
Fabiano Rosas 56b9cfd5da migration/multifd: Fix leaks of TLS error objects
The code currently ignores errors from multifd threads that happen
after a first error has already been propagated. Make sure the
subsequent errors are freed appopriately.

This fixes a leak of the TLS session->werr when the certificate
validation fails after multifd threads are already running. The first
writes on the threads will fail deep into the gnutls stack.

No need to check if(err) because the callers are all under a similar
check.

Reviewed-by: Peter Xu <[email protected]>
Reviewed-by: Prasad Pandit <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-03-17 13:34:13 -03:00
Fabiano Rosas 47d71ee2e5 tests/qtest/migration: Fix leak in CPR exec test
The string was being dup'ed only to get around the const of the
qdict_get_str() return value.

Reviewed-by: Peter Xu <[email protected]>
Reviewed-by: Prasad Pandit <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-03-17 13:34:13 -03:00
Fabiano Rosas c20f143cc9 io: Fix TLS bye task leak
Recent fixes to TLS tasks memory handling have left the TLS bye task
uncovered. Fix by freeing the task in the same way the handshake task
is freed.

Direct leak of 704 byte(s) in 4 object(s) allocated from:
    #1 0x7f5909b1d6a0 in g_malloc0 ../glib/gmem.c:163
    #2 0x557650496d61 in qio_task_new ../io/task.c:58:12
    #3 0x557650475d7f in qio_channel_tls_bye ../io/channel-tls.c:352:12
    #4 0x55764f7a1bb4 in migration_tls_channel_end ../migration/tls.c:159:5
    #5 0x55764f709750 in migration_ioc_shutdown_gracefully ../migration/multifd.c:462:9
    #6 0x55764f6fcf53 in multifd_send_terminate_threads ../migration/multifd.c:493:13
    #7 0x55764f6fcafb in multifd_send_shutdown ../migration/multifd.c:580:5
    #8 0x55764f6e1b14 in migration_cleanup ../migration/migration.c:1323:9
    #9 0x55764f6f5bac in migration_cleanup_bh ../migration/migration.c:1350:5

Fixes: d39d0f3acd ("io: fix cleanup for TLS I/O source data on cancellation")
Reviewed-by: Daniel P. Berrangé <[email protected]>
Acked-by: Daniel P. Berrangé <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-03-17 13:34:12 -03:00
Fabiano Rosas 66e127d50c tests/qtest/migration: Fix leak of migration tests data
When the migration-test is invoked with the '-p' flag (to run a single
test), the glib code won't call the destroy function for the
not-executed tests, causing the MigrationTest wrapper data to leak.

This doesn't affect make check, but affects debugging use-cases where
having a leak pop up in ASAN output is extra annoying.

Fix by adding the tests data to a list and freeing them all at the end
of migration-test execution. Any tests actually dispatched by glib
will have the destroy function called as usual.

Note that migration_test_add_suffix() is altered to call
migration_test_add() so that there's only one place adding the data to
the list.

Performance is not an issue at the moment, we have < 100 tests.

Reviewed-by: Peter Xu <[email protected]>
Reviewed-by: Prasad Pandit <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-03-17 13:34:12 -03:00
Shivang Upadhyay a16d4c2f16 ppc/pnv: fix dumpdtb option
The '-machine dumpdtb' command line option stopped working on
PowerPC/pnv systems after recent design change [1].

Fixing this by generating fdt blob in `pnv_init`.

[1] https://lore.kernel.org/qemu-devel/[email protected]/

Cc: Aditya Gupta <[email protected]>
Cc: Harsh Prateek Bora <[email protected]>
Cc: Peter Maydell <[email protected]>
Cc: BALATON Zoltan <[email protected]>
Cc: [email protected]
Fixes: 8fd2518ef2 ("hw: Centralize handling of -machine dumpdtb option")
Signed-off-by: Shivang Upadhyay <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Reviewed-by: Aditya Gupta <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Harsh Prateek Bora <[email protected]>
2026-03-17 20:31:42 +05:30
Fiona Ebner 9ac85f4cc7 block/mirror: fix assertion failure upon duplicate complete for job using 'replaces'
If s->replace_blocker was already set by an earlier invocation of
mirror_complete(), then there will be an assertion failure when
error_setg() is called for it a second time. The bdrv_op_block_all()
and bdrv_ref() operations should only be done a single time too.

Signed-off-by: Fiona Ebner <[email protected]>
Message-Id: <[email protected]>
Reviewed-by: Hanna Czenczek <[email protected]>
Signed-off-by: Hanna Czenczek <[email protected]>
2026-03-17 12:31:54 +01:00
Paolo Bonzini e4ff2106da rust: fix build when --disable-rust and meson < 1.9
Commit e65030ed50 moved rust_std and build.rust_std from per-target
override_options into the project's default_options, in order to avoid
repetition.  However, default_options are validated unconditionally at
project initialization, even when Rust is disabled.  This breaks builds
with meson < 1.9.0 which does not know about "build.rust_std":

  meson.build:1:0: ERROR: Unknown option: "build.rust_std".

Make the options conditional on the meson version, since Rust only
supports new versions of Meson anyway.

Fixes: e65030ed50 ("rust: remove unnecessary repetitive options")
Reported-by: Marc-André Lureau <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
2026-03-17 12:04:26 +01:00
Marc-André Lureau 42949e4a9c build-sys: use the "run" variable
Avoid unused variables and hand-written path, this should also help meson
to figure out the relation between the commands.

Signed-off-by: Marc-André Lureau <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-03-17 12:03:55 +01:00
Peter Maydell 6667668e0c Merge tag 'pr-plugins-20260316' of https://gitlab.com/pbo-linaro/qemu into staging
Changes:
- [PATCH] contrib/plugins/uftrace.c: fix depth for exit events (Pierrick Bouvier <[email protected]>)
  Link: https://lore.kernel.org/qemu-devel/[email protected]

# -----BEGIN PGP SIGNATURE-----
#
# iQGzBAABCgAdFiEEZrmU7KFPfy5auggff5BUDQoc0A8FAmm4kCsACgkQf5BUDQoc
# 0A8gRQv+LZIiG75VL5cy+tpdD+kcwu+hsQ5Y6qGA6zs9TrdARxKtQ2Ozg9VjrMGE
# bTzhxo7ldwEjcki8bvi4yYN3uXtJzg/PODYcN7KWdqihunS97Iqr64Fd5aqkmNkV
# LNBbeLh+9qqtLY/k0YyR5yNJZ+9XuPatG+x/gG7WE0Ij3rMI2y1RIW7oq0MeBVuH
# gY9fsH80CL8wJC+LHkJDwpDXZyFLTh2+Q7kUGk51E3FYDQzHzV8Zewrmy3Vu+1RD
# 1+3EIBbC8e0fjYZEG6FFn0cBjx+TH11y2eN8JRvnmsMqoYRONSd2rUBQG5KFYcvO
# tJzDMCm7rfDWS+URs9SAb0a9mW0QNPBtZhhW5amHVFBQwIxpnznzC+xMCl51GUQe
# 1cNCzUCMhjSkFFUhvbWpB5IjQhDT6vKQ2y+telUDQ3VG1k914slEi2bIBECIEFeu
# u3X/4fCSU25rsXrjadbUKrnahRf9kGWmw1vZoZzGkb95HUpG3mgOXt7n8Ej9q1kt
# RBB/+NwN
# =q1H1
# -----END PGP SIGNATURE-----
# gpg: Signature made Mon Mar 16 23:20:11 2026 GMT
# gpg:                using RSA key 66B994ECA14F7F2E5ABA081F7F90540D0A1CD00F
# gpg: Good signature from "Pierrick Bouvier <[email protected]>" [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: 66B9 94EC A14F 7F2E 5ABA  081F 7F90 540D 0A1C D00F

* tag 'pr-plugins-20260316' of https://gitlab.com/pbo-linaro/qemu:
  contrib/plugins/uftrace.c: fix depth for exit events

Signed-off-by: Peter Maydell <[email protected]>
2026-03-17 10:20:30 +00:00
Pierrick Bouvier 48221e3716 contrib/plugins/uftrace.c: fix depth for exit events
Uftrace plugin was recording wrong depth for exit events, resulting in
incoherent traces, especially for partial ones.

Thanks to Honggyu Kim, one of the original author of uftrace, who
spotted the issue.
https://github.com/namhyung/uftrace/pull/2031#issuecomment-4051762627

Reviewed-by: Pierrick Bouvier <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Pierrick Bouvier <[email protected]>
2026-03-16 16:19:18 -07:00
Alberto Garcia 9c8430f5d6 throttle-group: Fix race condition in throttle_group_restart_queue()
When a timer is fired a pending I/O request is restarted and
tg->any_timer_armed is reset so other requests can be scheduled.

However we're resetting any_timer_armed first in timer_cb() before
the request is actually restarted, and there's a window between both
moments in which another thread can arm the same timer, hitting an
assertion in throttle_group_restart_queue().

This can be solved by deferring the reset of tg->any_timer_armed to
the moment when the queue is actually restarted, which is protected by
tg->lock, preventing other threads from arming the timer before that.

In addition to that, throttle_group_restart_tgm() is also updated to
hold tg->lock while the timer is being inspected. Here we consider
three different scenarios:

- If the tgm has a timer set, fire it immediately
- If another tgm has a timer set, restart the queue anyway
- If there is no timer set in this group then simulate a timer that
  fires immediately, by setting tg->any_timer_armed in order to
  prevent other threads from arming a timer in the meantime.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3194
Signed-off-by: Alberto Garcia <[email protected]>
Message-Id: <825598ef34ad384d936da19d634eda75598508f7.1773316842.git.berto@igalia.com>
Signed-off-by: Hanna Czenczek <[email protected]>
2026-03-16 16:55:18 +01:00
Peter Maydell 559919ce54 Merge tag 'pull-trivial-patches' of https://gitlab.com/mjt0k/qemu into staging
trivial patches for 2026-03-16

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCgAdFiEEZKoqtTHVaQM2a/75gqpKJDselHgFAmm34HIACgkQgqpKJDse
# lHjIwA/9G+XvpJHAXsK8QdPQAlrcCstV9GYJ/+wprclWM6rsWf+zQQ4RvQqxj4ue
# YzYmK37LVp2QyxNHACN5BYR/k7VUxjgdDZgu2bj3gw2A9XFkwnUHZuzvNaWPllit
# ugeeDP9dA+gM+YrUhPSwmDSX03KZrF1hipaQqPdFpCRaN1guvtNfnveqgGgE4eRm
# svwv40z0+kQW7pg/7cpPCp0ATdeYoLV84jOcEpR7gVdheektrIC2rQSUNl4Eqg1b
# VrvvoGZ+M4sJOyzz/jFEauWEYOjRT/3t0B1fy4jyUVOAKaDsPRBS1R3XvYGmgfEG
# OusGvluoLXdQ53xcdE448wTO9pQFnMjmrWsqtVyevyD3Rd0x1Rl2sQwZ4qoq5rgr
# Ck6ruvSnBM8tthSHktpYLdI1pcjAp3xS7LsVK+bQk9sJuIYiDczgDpsnkg/YgbtA
# Gqbbh1/2WIufpRd9HhhFo5yEzWfoHvGgSI1AytIkG4/VRKS5vXQ+sbGV2j4oVBte
# Wpx87zWaZytqdkA5i3EzOY/3JT63tpyEbzpZc35psGo6z/khUrdzqpLUwmt8MNNH
# oxadGK3B/r6rfaXOo9zN1ACCp1tY9D/OCow7MTPdnU5ySMkIzKO59akpw9SoShzC
# O8Ok0j/onHZbZwIt7rYAWODbeIN4zyoVsKbk1xFV2+CGoHWeOK8=
# =KGOq
# -----END PGP SIGNATURE-----
# gpg: Signature made Mon Mar 16 10:50:26 2026 GMT
# gpg:                using RSA key 64AA2AB531D56903366BFEF982AA4A243B1E9478
# gpg: Good signature from "Michael Tokarev <[email protected]>" [full]
# gpg:                 aka "Michael Tokarev <[email protected]>" [full]
# gpg:                 aka "Michael Tokarev <[email protected]>" [full]
# Primary key fingerprint: 9D8B E14E 3F2A 9DD7 9199  28F1 61AD 3D98 ECDF 2C8E
#      Subkey fingerprint: 64AA 2AB5 31D5 6903 366B  FEF9 82AA 4A24 3B1E 9478

* tag 'pull-trivial-patches' of https://gitlab.com/mjt0k/qemu:
  rename CONFIG_EPOLL_CREATE1 to CONFIG_EPOLL, and stop checking for epoll in meson.build
  meson.build: do not check for epoll.h (CONFIG_EPOLL)
  linux-user: assume epoll is always present
  meson.build: stop checking for inotify_init()
  linux-user: assume inotify sycalls are always present
  meson.build: stop checking for splice()
  linux-user/syscall.c: assume splice is always present
  docs: Move xbzrle.txt into the migration folder and convert to rst
  target/i386: fix NULL pointer dereference in legacy-cache=off handling
  hw/usb/core.c: reorder usage and assertion of p->ep
  system/physmem.c: remove useless assertion of block
  dump/dump.c: reorder usage and assertion of block
  migration/savevm.c: reorder usage and assertion of mis->from_src_file

Signed-off-by: Peter Maydell <[email protected]>
2026-03-16 13:07:33 +00:00
Peter Maydell bce666efa9 Merge tag 'pull-target-arm-20260316' of https://gitlab.com/pm215/qemu into staging
target-arm queue:
 * hw/net/rtl8319: Work around GCC sanitizer / -Wstringop-overflow bug
 * semihosting: Correctly byteswap data when CPU is in big-endian mode
 * hw/dma/pl080: Fix various minor bugs
 * MAINTAINERS: Remove some no-longer active maintainers
 * tests/qtest: Use g_strdup_printf() in various arm tests

# -----BEGIN PGP SIGNATURE-----
#
# iQJNBAABCAA3FiEE4aXFk81BneKOgxXPPCUl7RQ2DN4FAmm33l8ZHHBldGVyLm1h
# eWRlbGxAbGluYXJvLm9yZwAKCRA8JSXtFDYM3ssREACHRyPRM/BdgjxLcQ+mZDYl
# WLSJzytrgdBmUsALt1T6hKMAfAdtdNVbLO/4r9r1zSDhXWcHOd+hsiq0IF+F6CZd
# qKIB++aVrNDWA5v0tlz+j4kQNCeFOX/u53CB9nZtaV/dMrAZbiuOulxDzd9grKJi
# m3ZT7YfIAV6nNLp/J7Q7P8rvM5quN/1ohTGqKSmMgLAZgqa0ac8cV3NYqVpnd4Jc
# +pqoQQb54uKpMKRacAUX2OMk6XuxDI3szdciVQLLhhrglwMo3xoAwpX600lAcvYv
# 2D+8nb5A90u7pfIY4xGajIBqiBP5PQC2RiTUd0qRmOklnVx7gRHaI9N1LOA/DtX1
# YKCPuH3CZEuZ+s4bWH9+ahaHbu5eHmqhxlp+CdICWbf+MBa1bCig2gT6su26AeHs
# hEcLt9QQwKAfjegs4S9J90ph13LADau8VkSIP6WMfTuDmNesQY6/JlaGq8/qWrfL
# WfJF8i9fHpEX7OSy+/CwUS02HTDrn2MRTmAt2ihee5oYRuEdmSfYCjMvt5Nhbej3
# nzNWBw/BpgdNsdIPfJSoNWP/VQTTX6rYvUQh4+Z90SVqFyfGSCb9JOVg6Ab39Q8p
# gfjkIU2NwhZmDCjh4CqJLihKCPCUiFKlYrvOpAHkuDXcLqzLvF03A7WIHs4cA5+T
# PwUs4qJF8kpBsJOdshbQAQ==
# =V7Lm
# -----END PGP SIGNATURE-----
# gpg: Signature made Mon Mar 16 10:41:35 2026 GMT
# gpg:                using RSA key E1A5C593CD419DE28E8315CF3C2525ED14360CDE
# gpg:                issuer "[email protected]"
# gpg: Good signature from "Peter Maydell <[email protected]>" [ultimate]
# gpg:                 aka "Peter Maydell <[email protected]>" [ultimate]
# gpg:                 aka "Peter Maydell <[email protected]>" [ultimate]
# gpg:                 aka "Peter Maydell <[email protected]>" [ultimate]
# Primary key fingerprint: E1A5 C593 CD41 9DE2 8E83  15CF 3C25 25ED 1436 0CDE

* tag 'pull-target-arm-20260316' of https://gitlab.com/pm215/qemu:
  tests/qtest/aspeed_gpio-test: Use g_strdup_printf() instead of char arrays
  tests/qtest/ast2700-gpio-test: Use g_strdup_printf() instead of char arrays
  tests/qtest/arm-cpu-features: Use g_strdup_printf() instead of char arrays
  tests/qtest/ast2700-sgpio-test: Use g_strdup_printf() instead of char arrays
  MAINTAINERS: Remove Chris Browy
  MAINTAINERS: Remove Andrey Smirnov
  MAINTAINERS: Remove Radoslaw Biernacki
  MAINTAINERS: Remove Eduardo Habkost
  MAINTAINERS: Remove Cameron Esfahani
  MAINTAINERS: Remove Hannes Reinecke
  hw/dma/pl080: Ignore bottom 2 bits of LLI register
  hw/dma/pl080: Update interrupts after pl080_run()
  hw/dma/pl080: Handle bogus swidth and dwidth in transfers
  semihosting/uaccess: Use the cpu_internal_tswap() functions
  include/exec: Provide the cpu_internal_tswap() functions
  include/hw/core: Rename virtio_is_big_endian to internal_is_big_endian
  hw/net/rtl8319: Work around GCC sanitizer / -Wstringop-overflow bug

Signed-off-by: Peter Maydell <[email protected]>
2026-03-16 13:07:17 +00:00
Michael Tokarev 7cc61f922f rename CONFIG_EPOLL_CREATE1 to CONFIG_EPOLL, and stop checking for epoll in meson.build
Since CONFIG_EPOLL is now unused, it's okay to
perform this rename, to make it less ugly.

Since epoll is linux-specific and is always present on linux,
define CONFIG_EPOLL to 1 on linux, without compile-time test.

Signed-off-by: Michael Tokarev <[email protected]>
2026-03-16 13:50:18 +03:00
Michael Tokarev 18f1cf1cfc meson.build: do not check for epoll.h (CONFIG_EPOLL)
The only place where we used CONFIG_EPOLL was linux-user,
which now enables it unconditionally.

Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Michael Tokarev <[email protected]>
2026-03-16 13:50:17 +03:00
Michael Tokarev ecec2bd8f3 linux-user: assume epoll is always present
epoll is in linux since 2.6 (glibc 2.3.2).
epoll_init1 has been added in 2.6.27 (glibc 2.9).
There's no need to check for its presence, including all other
epoll-related syscalls.

Modern architectures don't have epoll_create(), only
epoll_create1(), so keep conditional around the former.

Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Michael Tokarev <[email protected]>
2026-03-16 13:50:17 +03:00
Michael Tokarev 7276d72802 meson.build: stop checking for inotify_init()
the only place in qemu which used the check for inotify_init()
was linux-user, which now assumes inotify_init() is always
present.  There's no need to check for this function anymore.

Signed-off-by: Michael Tokarev <[email protected]>
2026-03-16 13:50:17 +03:00
Michael Tokarev 11de247707 linux-user: assume inotify sycalls are always present
inotify_init() and other syscalls appeared in linux 2.6.13,
inotify_init1() - in linux 2.6.27.

There's no need to check their presence on linux anymore.

Keep condition on TARGET_NR_inotify_init because modern
architectures have only more generic inotify_init1().

Other, not linux-specific, places of the code checks for
inotify_init1() syscall only.

Signed-off-by: Michael Tokarev <[email protected]>
2026-03-16 13:50:17 +03:00
Michael Tokarev 44c49d9b0d meson.build: stop checking for splice()
CONFIG_SPLICE was only needed for linux-user/, where it is not
used anymore (assuming splice &Co is always present)

Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Michael Tokarev <[email protected]>
2026-03-16 13:50:17 +03:00
Michael Tokarev bf6ec283c5 linux-user/syscall.c: assume splice is always present
splice() &Co are defined since linux 2.6.17 (glibc 2.5).
Assume it is always present.

Reviewed-by: Peter Maydell <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Michael Tokarev <[email protected]>
2026-03-16 13:50:17 +03:00
Thomas Huth 271e2a38a2 docs: Move xbzrle.txt into the migration folder and convert to rst
xbzrle is a feature of migration and thus this file should go
into the docs/devel/migration/ folder. While we're at it, turn
it into proper .rst format, too.

Signed-off-by: Thomas Huth <[email protected]>
Reviewed-by: Peter Xu <[email protected]>
Reviewed-by: Michael Tokarev <[email protected]>
Signed-off-by: Michael Tokarev <[email protected]>
2026-03-16 13:50:17 +03:00
Sergei Heifetz 2741d2cc39 target/i386: fix NULL pointer dereference in legacy-cache=off handling
The check that xcc->model is not NULL occurs after it is dereferenced
inside x86_cpu_get_versioned_cache_info(), so something like
`-cpu host,legacy-cache=off` leads to a segfault rather than an error.
This patch fixes that.

Fixes: cca0a000d0 ("target/i386: allow versioned CPUs to specify new cache_info")
Signed-off-by: Sergei Heifetz <[email protected]>
Reviewed-by: Vladimir Sementsov-Ogievskiy <[email protected]>
Reviewed-by: Zhao Liu <[email protected]>
Reviewed-by: Michael Tokarev <[email protected]>
[Mjt: simplify the following condition too]
Signed-off-by: Michael Tokarev <[email protected]>
2026-03-16 13:50:17 +03:00
Sergei Heifetz e49f46d5c4 hw/usb/core.c: reorder usage and assertion of p->ep
Reorder the code so the assertion of p->ep occurs before it is
used in the subsequent lines.

Signed-off-by: Sergei Heifetz <[email protected]>
Reviewed-by: Laurent Vivier <[email protected]>
Reviewed-by: Peter Xu <[email protected]>
Reviewed-by: Michael Tokarev <[email protected]>
Signed-off-by: Michael Tokarev <[email protected]>
2026-03-16 13:50:17 +03:00
Sergei Heifetz 731abcf418 system/physmem.c: remove useless assertion of block
It is useless to assert that block is not NULL because it is
already dereferenced in the first line of the function.

The assertion is also unnecessary because the function is called
in only two places, and `block` can't be NULL in either of them:
- In `migration/ram.c`, we have already dereferenced `block` in
  the code just before the call.
- In `system/memory.c`, we assert `mr->ram_block` before passing
  it to the function.

(We could split the declaration and initialization of oldsize,
but then we would need to remove the const qualifier. As the
assertion is useless anyway, removing the const qualifier seems
worse.)

Signed-off-by: Sergei Heifetz <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Reviewed-by: Peter Xu <[email protected]>
Reviewed-by: Michael Tokarev <[email protected]>
Signed-off-by: Michael Tokarev <[email protected]>
2026-03-16 13:50:17 +03:00
Sergei Heifetz de49227611 dump/dump.c: reorder usage and assertion of block
Reorder the code so the assertion of block occurs before it is
used in the subsequent lines.

Signed-off-by: Sergei Heifetz <[email protected]>
Reviewed-by: Laurent Vivier <[email protected]>
Reviewed-by: Peter Xu <[email protected]>
Reviewed-by: Michael Tokarev <[email protected]>
Signed-off-by: Michael Tokarev <[email protected]>
2026-03-16 13:50:17 +03:00
Sergei Heifetz 455c908278 migration/savevm.c: reorder usage and assertion of mis->from_src_file
Reorder the code so the assertion of mis->from_src_file occurs before
the call to migration_ioc_unregister_yank_from_file, which dereferences
it in qemu_file_get_ioc.

Fixes: 39675ffffb ("migration: Move the yank unregister of channel_close out")
Signed-off-by: Sergei Heifetz <[email protected]>
Reviewed-by: Laurent Vivier <[email protected]>
Reviewed-by: Peter Xu <[email protected]>
Reviewed-by: Michael Tokarev <[email protected]>
Signed-off-by: Michael Tokarev <[email protected]>
2026-03-16 13:50:17 +03:00
Peter Maydell ac5ed6d278 Merge tag 'pull-request-2026-03-16' of https://gitlab.com/thuth/qemu into staging
* Fix various crashes that can occur when starting QEMU with -device xyz,help
* Update various sections in the MAINTAINERS file

# -----BEGIN PGP SIGNATURE-----
#
# iQIyBAABCgAdFiEEJ7iIR+7gJQEY8+q5LtnXdP5wLbUFAmm33eAACgkQLtnXdP5w
# LbUAnA/2NUNIRc18cIAmC5AABoLPeLd96ndPXoayMc78fdJXeM4GsFHqQ0Qqj56B
# nSZY9nHHzv8f9n+pVISoffuywP0ldR7+ThKVyps8rkmsXDuBsdNwZU829toq43lg
# V0+/UtyxrZLujV581TrmKlPf25sY5BV96YHWzXuUm2E5ikrSzqNcm+1ZNRRhWa5R
# gu0bhfAcILnmXxYYrIO/JWM38j7Kz2BHLGN2A8UepORhs5gUg5vk33RaTrzDfbwN
# rTxLKjLxYEPV2E9YTBsmMQqsiBomHjw66g5Rtq68KE26RodPeEdLsk9Yd7WbWfEf
# HGnZ/l2aZ8OoaricIvUdMQmkAVjxZE4b+a6AiZ38KsJ/3XEXQqbkvGRW3OCkAWOY
# kzRuxWJKoPIkvm4jfN39cZEtzHnXdrNgiVCwGuMn0BwqHOPIF/W+5XImOW1dqlTL
# CfR11yjUdpW33/hWmXtHkAYDlf5cP7/eL/KStrSv3DkG9/CNTAfwEvjkOyBq3C+K
# J/aiufIkbkUr8ZpfJ+eledbAkvvv1/d8/u5vlqyVa4sL7hdcaxQrUDxjojrE7EoM
# xB0eS4eFZNsRQn3YrvqyCMxwwO16HyeOOYSv/7Z2wixe/FCRQEjxl02/430ITVNS
# MB1/fKUWd4/SUY+BqtBHSo4qNPEbmxzOXKVEJHLS2bqqnDmEcg==
# =0ClG
# -----END PGP SIGNATURE-----
# gpg: Signature made Mon Mar 16 10:39:28 2026 GMT
# gpg:                using RSA key 27B88847EEE0250118F3EAB92ED9D774FE702DB5
# gpg: Good signature from "Thomas Huth <[email protected]>" [full]
# gpg:                 aka "Thomas Huth <[email protected]>" [full]
# gpg:                 aka "Thomas Huth <[email protected]>" [full]
# gpg:                 aka "Thomas Huth <[email protected]>" [undefined]
# Primary key fingerprint: 27B8 8847 EEE0 2501 18F3  EAB9 2ED9 D774 FE70 2DB5

* tag 'pull-request-2026-03-16' of https://gitlab.com/thuth/qemu:
  MAINTAINERS: Add another reviewer to s390x boot
  MAINTAINERS: Downgrade the functional testing section to "Odd Fixes"
  MAINTAINERS: Remove myself from various sections
  MAINTAINERS: Update the s390x maintainers
  MAINTAINERS: Update S390-ccw boot maintainers/reviewers
  hw/acpi: generic_event_device: Don't call qdev_get_machine in initfn
  hw/arm: fsl-imx6: Don't call qdev_get_machine in soc init
  hw/arm: fsl-imx8mp: Don't call qdev_get_machine in soc init
  hw/arm: fsl-imx7: Don't call qdev_get_machine in soc init
  hw/arm: xlnx-zynqmp: Don't call qdev_get_machine in soc init
  hw/riscv: microchip_pfsoc: Don't call qdev_get_machine in soc init
  hw/riscv: sifive_e: Don't call qdev_get_machine in soc init
  target/mips/cpu: Move initialization of memory region to realize function
  target/xtensa/cpu: Move initialization of memory region to realize function

Signed-off-by: Peter Maydell <[email protected]>
2026-03-16 10:43:15 +00:00
Peter Maydell 9378149187 Merge tag 'linux-user-for-v11-pull-request' of https://github.com/hdeller/qemu-hppa into staging
Two linux-user patches

Two linux-user patches from Razvan Ghiorghe.

# -----BEGIN PGP SIGNATURE-----
#
# iHUEABYKAB0WIQS86RI+GtKfB8BJu973ErUQojoPXwUCabRXkwAKCRD3ErUQojoP
# X8E4AQDtltuCmD+RnJ5yWNAh4Rx8kOU/tChL8kE44NjMz9HdxAEA37DKINiPHCOs
# G7kmfKqwUpJWVSXeMjUp0iaNOUydbAw=
# =ahOd
# -----END PGP SIGNATURE-----
# gpg: Signature made Fri Mar 13 18:29:39 2026 GMT
# gpg:                using EDDSA key BCE9123E1AD29F07C049BBDEF712B510A23A0F5F
# gpg: Good signature from "Helge Deller <[email protected]>" [unknown]
# gpg:                 aka "Helge Deller <[email protected]>" [unknown]
# gpg:                 aka "Helge Deller <[email protected]>" [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: 4544 8228 2CD9 10DB EF3D  25F8 3E5F 3D04 A7A2 4603
#      Subkey fingerprint: BCE9 123E 1AD2 9F07 C049  BBDE F712 B510 A23A 0F5F

* tag 'linux-user-for-v11-pull-request' of https://github.com/hdeller/qemu-hppa:
  linux-user: fix mremap with old_size=0 for shared mappings
  linux-user: Fix zero_bss for RX PT_LOAD segments

Signed-off-by: Peter Maydell <[email protected]>
2026-03-16 10:42:41 +00:00
Eric Farman bc4ee6025a MAINTAINERS: Add another reviewer to s390x boot
Jason offered to help review this area of code;
let's make sure he's notified of changes.

Signed-off-by: Eric Farman <[email protected]>
Message-ID: <[email protected]>
Acked-by: Jason J. Herne <[email protected]>
Acked-by: Matthew Rosato <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
2026-03-16 11:36:32 +01:00
Thomas Huth 3aaa367c15 MAINTAINERS: Downgrade the functional testing section to "Odd Fixes"
I won't have that much time for QEMU anymore in the future, so downgrade
the status of the "functional testing framework" section to "Odd Fixes"
to avoid wrong expectations. While we're at it, also switch to my other
e-mail address here that I'm already using for the other sections where
I am still listed as maintainer / reviewer.

Message-ID: <[email protected]>
Reviewed-by: Daniel P. Berrangé <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
2026-03-16 11:36:32 +01:00
Thomas Huth d217eebe15 MAINTAINERS: Remove myself from various sections
I likely won't have much time in the future for QEMU anymore, so
remove myself from various sections that have already enough other
maintainers / reviewers.

Message-ID: <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
2026-03-16 11:36:32 +01:00
Thomas Huth a76014b193 MAINTAINERS: Update the s390x maintainers
I'm going to move to another project next month, so I will not have
enough time to take care of s390x patches anymore. Fortunately,
Cornelia volunteered to take over the job of collecting s390x patches,
and Eric and Matthew offered help to back her up, so we can keep
the "S390 general architecture support" section in the "supported"
state. Thanks for your help, Cornelia, Eric and Matthew!

Message-ID: <[email protected]>
Reviewed-by: Cornelia Huck <[email protected]>
Acked-by: Eric Farman <[email protected]>
Acked-by: Matthew Rosato <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
2026-03-16 11:36:31 +01:00
Jared Rossi 7ae0f49287 MAINTAINERS: Update S390-ccw boot maintainers/reviewers
Christian Borntraeger is no longer active in this space.  Promote myself to
maintainer and demote Christian to reviewer.

Signed-off-by: Jared Rossi <[email protected]>
Acked-by: Eric Farman <[email protected]>
Acked-by: Christian Borntraeger <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
2026-03-16 11:36:31 +01:00
Alistair Francis 3b0f7a0834 hw/acpi: generic_event_device: Don't call qdev_get_machine in initfn
Calling qdev_get_machine() in the acpi_ged_initfn function would result
in the following assert

    ../hw/core/qdev.c:858: qdev_get_machine: Assertion `dev' failed.

when trying to run

    ./qemu-system-aarch64 -S -display none -M virt -device acpi-ged,help

as the machine wasn't created yet. We call qdev_get_machine() to obtain
the ram slots of the machine. So instead of initialising the GED in
the init let's instead do it in the realise where the machine
will exist.

Signed-off-by: Alistair Francis <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Tested-by: Markus Armbruster <[email protected]>
Message-ID: <[email protected]>
[thuth: Replaced soc_init with acpi_ged_initfn in the patch description]
Signed-off-by: Thomas Huth <[email protected]>
2026-03-16 11:36:31 +01:00
Alistair Francis 148dec4486 hw/arm: fsl-imx6: Don't call qdev_get_machine in soc init
Calling qdev_get_machine() in the soc_init function would result in
the following assert

    ../hw/core/qdev.c:858: qdev_get_machine: Assertion `dev' failed.

when trying to run

    ./qemu-system-aarch64 -S -display none -M virt -device fsl-imx6,help

as the machine wasn't created yet. We call qdev_get_machine() to obtain
the number of CPUs in the machine. So instead of initialising the CPUs in
the SoC init let's instead do it in the realise where the machine
will exist.

Signed-off-by: Alistair Francis <[email protected]>
Tested-by: Markus Armbruster <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
2026-03-16 11:36:31 +01:00
Alistair Francis b67d0bcdd4 hw/arm: fsl-imx8mp: Don't call qdev_get_machine in soc init
Calling qdev_get_machine() in the soc_init function would result in
the following assert

    ../hw/core/qdev.c:858: qdev_get_machine: Assertion `dev' failed.

when trying to run

    ./qemu-system-aarch64 -S -display none -M virt -device fsl-imx8mp,help

as the machine wasn't created yet. We call qdev_get_machine() to obtain
the number of CPUs in the machine. So instead of initialising the CPUs in
the SoC init let's instead do it in the realise where the machine
will exist.

Signed-off-by: Alistair Francis <[email protected]>
Tested-by: Markus Armbruster <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
2026-03-16 11:36:31 +01:00
Alistair Francis 99757d5574 hw/arm: fsl-imx7: Don't call qdev_get_machine in soc init
Calling qdev_get_machine() in the soc_init function would result in
the following assert

    ../hw/core/qdev.c:858: qdev_get_machine: Assertion `dev' failed.

when trying to run

    ./qemu-system-aarch64 -S -display none -M virt -device fsl-imx7,help

as the machine wasn't created yet. We call qdev_get_machine() to obtain
the number of CPUs in the machine. So instead of initialising the CPUs in
the SoC init let's instead do it in the realise where the machine
will exist.

Signed-off-by: Alistair Francis <[email protected]>
Tested-by: Markus Armbruster <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
2026-03-16 11:36:31 +01:00
Alistair Francis f70ee77f3c hw/arm: xlnx-zynqmp: Don't call qdev_get_machine in soc init
Calling qdev_get_machine() in the soc_init function would result in
the following assert

    ../hw/core/qdev.c:858: qdev_get_machine: Assertion `dev' failed.

when trying to run

    ./qemu-system-aarch64 -S -display none -M virt -device xlnx-zynqmp,help

as the machine wasn't created yet. We call qdev_get_machine() to obtain
the number of CPUs in the machine. So instead of initialising the CPUs in
the SoC init let's instead do it in the realise where the machine
will exist.

Signed-off-by: Alistair Francis <[email protected]>
Tested-by: Markus Armbruster <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
2026-03-16 11:36:31 +01:00
Alistair Francis aa12d98d02 hw/riscv: microchip_pfsoc: Don't call qdev_get_machine in soc init
Calling qdev_get_machine() in the soc_init function would result in
the following assert

    ../hw/core/qdev.c:858: qdev_get_machine: Assertion `dev' failed.

when trying to run

    ./qemu-system-riscv64 -S -display none -M virt -device microchip.pfsoc,help

as the machine wasn't created yet. We call qdev_get_machine() to obtain
the number of CPUs in the machine. So instead of setting the CPU
num-harts in the init function let's set it in realise where the machine
will exist.

Signed-off-by: Alistair Francis <[email protected]>
Tested-by: Markus Armbruster <[email protected]>
Message-ID: <[email protected]>
[thuth: Fix a complaint from checkpatch.pl with regards to multi-line comment]
Signed-off-by: Thomas Huth <[email protected]>
2026-03-16 11:36:19 +01:00
Alistair Francis b0c9d8c126 hw/riscv: sifive_e: Don't call qdev_get_machine in soc init
Calling qdev_get_machine() in the soc_init function would result in
the following assert

    ../hw/core/qdev.c:858: qdev_get_machine: Assertion `dev' failed.

when trying to run

    ./qemu-system-riscv64 -S -display none -M virt -device riscv.sifive.e.soc,help

as the machine wasn't created yet. We call qdev_get_machine() to obtain
the number of CPUs in the machine. So instead of setting the CPU
num-harts in the init function let's set it in realise where the machine
will exist.

Signed-off-by: Alistair Francis <[email protected]>
Tested-by: Markus Armbruster <[email protected]>
Message-ID: <[email protected]>
[thuth: Fix a complaint from checkpatch.pl with regards to multi-line comment]
Signed-off-by: Thomas Huth <[email protected]>
2026-03-16 11:35:45 +01:00
Thomas Huth 0dcaa42694 target/mips/cpu: Move initialization of memory region to realize function
When introspecting the Loongson-3A4000 CPUs from the command line, QEMU
currently crashes:

 $ ./qemu-system-mips64el -device Loongson-3A4000-mips64-cpu,help
 qemu-system-mips64el: ../../devel/qemu/system/physmem.c:1401:
  register_multipage: Assertion `num_pages' failed.
 Aborted (core dumped)

Move the initialization of the memory regions to the realize function
to fix this problem.

Reported-by: Markus Armbruster <[email protected]>
Message-ID: <[email protected]>
Tested-by: Markus Armbruster <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
2026-03-16 10:16:25 +01:00
Thomas Huth 7b743d01c3 target/xtensa/cpu: Move initialization of memory region to realize function
When introspecting the xtensa CPUs from the command line, QEMU currently
crashes:

 $ ./qemu-system-xtensa -device dc233c-xtensa-cpu,help
 qemu-system-xtensa: ../../devel/qemu/system/physmem.c:1401:
  register_multipage: Assertion `num_pages' failed.
 Aborted (core dumped)

Move the initialization of the memory regions to the realize function
to fix this problem.

Reported-by: Markus Armbruster <[email protected]>
Tested-by: Markus Armbruster <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
2026-03-16 10:16:25 +01:00
Ani Sinha 542a9ffb1c runstate: handle return code of EOPNOTSUPP properly from rebuild_guest()
If rebuild_guest() accelerator callback returns EOPNOTSUPP, this means that the
accelerator does not support rebuilding the guest state. Handle this case
properly and separately from other error return codes.

Fixes: 4003e5e65fe0("hw/accel: add a per-accelerator callback to change VM accelerator handle")
Reported-by: Harsh Prateek Bora <[email protected]>
Signed-off-by: Ani Sinha <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-03-14 08:48:20 +01:00
Peter Maydell ed44618b8e tests/qtest/aspeed_gpio-test: Use g_strdup_printf() instead of char arrays
Older versions of gcc with -Wformat-overflow=2 don't like the usage of
fixed size char arrays in this test; gcc 7.5.0 (SUSE Linux) says:

../tests/qtest/aspeed_gpio-test.c: In function ‘test_set_input_pins’:
../tests/qtest/aspeed_gpio-test.c:149:36: error: ‘sprintf’ may write a terminating nul past the end of the destination [-Werror=format-overflow=]
             sprintf(name, "gpio%c%d", c, i);
                                    ^
../tests/qtest/aspeed_gpio-test.c:149:13: note: ‘sprintf’ output between 7 and 17 bytes into a destination of size 16
             sprintf(name, "gpio%c%d", c, i);
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This can't actually happen because of the limited size of the values
being substituted in.  However rather than require readers to check
whether the arrays really have been declared large enough, we prefer
to use g_strdup_printf() for this kind of string work.

Reported-by: Fabiano Rosas <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
Tested-by: Fabiano Rosas <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-id: [email protected]
2026-03-13 13:27:57 +00:00
Peter Maydell 1d3926e271 tests/qtest/ast2700-gpio-test: Use g_strdup_printf() instead of char arrays
Older versions of gcc with -Wformat-overflow=2 don't like the usage of
fixed size char arrays in this test; gcc 7.5.0 (SUSE Linux) says:

../tests/qtest/ast2700-gpio-test.c: In function ‘test_input_pins’:
../tests/qtest/ast2700-gpio-test.c:54:36: error: ‘sprintf’ may write a terminating nul past the end of the destination [-Werror=format-overflow=]
             sprintf(name, "gpio%c%d", c, i);
                                    ^
../tests/qtest/ast2700-gpio-test.c:54:13: note: ‘sprintf’ output between 7 and 17 bytes into a destination of size 16
             sprintf(name, "gpio%c%d", c, i);
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This can't actually happen because of the limited size of the values
being substituted in.  However rather than require readers to check
whether the arrays really have been declared large enough, we prefer
to use g_strdup_printf() for this kind of string work.

Reported-by: Fabiano Rosas <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
Tested-by: Fabiano Rosas <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-id: [email protected]
2026-03-13 13:27:57 +00:00
Peter Maydell 62272f9f88 tests/qtest/arm-cpu-features: Use g_strdup_printf() instead of char arrays
Older versions of gcc with -Wformat-overflow=2 don't like the usage of
fixed size char arrays in this test; gcc 7.5.0 (SUSE Linux) says:

../tests/qtest/arm-cpu-features.c: In function ‘test_query_cpu_model_expansion_kvm’:
../tests/qtest/arm-cpu-features.c:578:35: error: ‘%u’ directive writing
between 1 and 10 bytes into a region of size 5
[-Werror=format-overflow=]

These can't actually happen because of the limited size of the values
being substituted in.  However rather than require readers to check
whether the arrays really have been declared large enough, we prefer
to use g_strdup_printf() for this kind of string work.

Reported-by: Fabiano Rosas <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
Tested-by: Fabiano Rosas <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-id: [email protected]
2026-03-13 13:27:50 +00:00
Peter Maydell 632d7bc0ec tests/qtest/ast2700-sgpio-test: Use g_strdup_printf() instead of char arrays
Older versions of gcc with -Wformat-overflow=2 don't like the usage of
fixed size char arrays in this test; gcc 7.5.0 (SUSE Linux) says:

../tests/qtest/ast2700-sgpio-test.c: In function ‘test_output_pins’:
../tests/qtest/ast2700-sgpio-test.c:27:33: error: ‘sprintf’ may write a
terminating nul past the end of the destination
[-Werror=format-overflow=]

../tests/qtest/ast2700-sgpio-test.c: In function ‘test_irq_level_high’:
../tests/qtest/ast2700-sgpio-test.c:85:33: error: ‘sprintf’ may write a
terminating nul past the end of the destination
[-Werror=format-overflow=]

These can't actually happen because of the limited size of the values
being substituted in.  However rather than require readers to check
whether the arrays really have been declared large enough, we prefer
to use g_strdup_printf() for this kind of string work.

Reported-by: Fabiano Rosas <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
Tested-by: Fabiano Rosas <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Message-id: [email protected]
2026-03-13 13:27:50 +00:00
Peter Maydell 4e188a1daa MAINTAINERS: Remove Chris Browy
Chris Browy's listed email address is undeliverable:

The recipient server did not accept our requests to connect; it
times out on attempts to connect by my sending mail server (gmail):
  [avery-design.com 99.83.249.127: timed out]
  [avery-design.com 75.2.78.167: timed out]

Remove his name from the file.

Signed-off-by: Peter Maydell <[email protected]>
Message-id: [email protected]
2026-03-13 13:26:21 +00:00
Peter Maydell 931f8e6457 MAINTAINERS: Remove Andrey Smirnov
Andrey Smirnov doesn't wish to be listed in MAINTAINERS any more;
remove his email from the relevant sections.

Signed-off-by: Peter Maydell <[email protected]>
Message-id: [email protected]
2026-03-13 13:26:21 +00:00
Peter Maydell c32149464f MAINTAINERS: Remove Radoslaw Biernacki
Radoslaw Biernacki doesn't wish to be listed in MAINTAINERS any more;
remove his email from the relevant sections.

Signed-off-by: Peter Maydell <[email protected]>
Message-id: [email protected]
2026-03-13 13:26:21 +00:00
Peter Maydell 838b10dab3 MAINTAINERS: Remove Eduardo Habkost
Eduardo Habkost doesn't wish to be listed in MAINTAINERS any more;
remove his email, and also the git trees he used to use.

Move the QOM boilerplate conversion script scripts/codeconverter
to "Orphan" status, as it no longer has any listed maintainers.

Signed-off-by: Peter Maydell <[email protected]>
Message-id: [email protected]
2026-03-13 13:26:21 +00:00
Peter Maydell acb2517441 MAINTAINERS: Remove Cameron Esfahani
Cameron Esfahani doesn't wish to be listed in MAINTAINERS any more;
remove his email from the relevant sections.

Signed-off-by: Peter Maydell <[email protected]>
Message-id: [email protected]
2026-03-13 13:26:21 +00:00
Peter Maydell fdb23230ee MAINTAINERS: Remove Hannes Reinecke
Hannes Reinecke doesn't wish to be listed in MAINTAINERS any more;
remove his email from the relevant sections.

As 'megasas' no longer has any listed maintainers, move it to
"Orphan" status.

Signed-off-by: Peter Maydell <[email protected]>
Message-id: [email protected]
2026-03-13 13:26:21 +00:00
Tao Ding f9b16f7915 hw/dma/pl080: Ignore bottom 2 bits of LLI register
The PL080 channel LLI (linked list item) register has bits [31:2] of
the address of the next LLI in bits [31:2], with bit [1] reserved
and bits [0] the AHB master select. We were incorrectly using the
whole register value as the address, which meant that if the guest
programmed something into the AHB master select bit we would use
an incorrect address, and read incorrect data from memory.

The following reproducer creates a setup which has bit 0 set in
an LLI value:

Configuration
    ../configure --target-list=arm-softmmu --enable-debug
Reproducer
    ./qemu-system-arm -M versatilepb -m 128M -nographic -S \
     -device loader,addr=0x00002000,data=0x00000004,data-len=4 \
     -device loader,addr=0x00002004,data=0x00001004,data-len=4 \
     -device loader,addr=0x00002008,data=0x00000000,data-len=4 \
     -device loader,addr=0x0000200c,data=0x9e4bf001,data-len=4 \
     -device loader,addr=0x00000000,data=0x44332211,data-len=4 \
     -device loader,addr=0x00000004,data=0x88776655,data-len=4 \
     -device loader,addr=0x00001000,data=0x00000000,data-len=4 \
     -device loader,addr=0x00001004,data=0x00000000,data-len=4 \
     -device loader,addr=0x10130030,data=0x00000001,data-len=4 \
     -device loader,addr=0x10130100,data=0x00000000,data-len=4 \
     -device loader,addr=0x10130104,data=0x00001000,data-len=4 \
     -device loader,addr=0x10130108,data=0x00002001,data-len=4 \
     -device loader,addr=0x1013010C,data=0x1e4bf001,data-len=4 \
     -device loader,addr=0x10130110,data=0x0000c001,data-len=4

The correct result with this bug fix:
    (qemu) xp /1wx 0x00001000
     00001000: 0x44332211
    (qemu) xp /1wx 0x00001004
     00001004: 0x88776655

Cc: [email protected]
Signed-off-by: Tao Ding <[email protected]>
[PMM: Adjusted commit message]
Reviewed-by: Peter Maydell <[email protected]>
Message-id: cb35c1b622674da7a2b70691402132f691933f2c.1773301927.git.dingtao0430@163.com
Signed-off-by: Peter Maydell <[email protected]>
2026-03-13 12:27:24 +00:00
Tao Ding b6e61d1cc3 hw/dma/pl080: Update interrupts after pl080_run()
In the codepath in pl080_write() where we run the DMA engine
after a change in the channel configuration register, we were
missing a pl080_update() call, which meant that we weren't
raising any interrupts generated by that DMA transfer.

A repro case for this is to program the PL080 and then
check the interrupt status by looking at the PL190 status
register, since the PL080 interrupt output is connected
to input 17 of the PL190. We look at the register value via
the QEMU monitor:

Reproducer
    ./qemu-system-arm -M versatilepb -m 128M -nographic -S \
    -device loader,addr=0x00000000,data=0x11223344,data-len=4 \
    -device loader,addr=0x00001000,data=0x00000000,data-len=4 \
    -device loader,addr=0x10130030,data=0x00000001,data-len=4 \
    -device loader,addr=0x10130100,data=0x00000000,data-len=4 \
    -device loader,addr=0x10130104,data=0x00001000,data-len=4 \
    -device loader,addr=0x10130108,data=0x00000000,data-len=4 \
    -device loader,addr=0x1013010C,data=0x9e4bf001,data-len=4 \
    -device loader,addr=0x10130110,data=0x0000c001,data-len=4

Qemu monitor
    (qemu) xp /1wx 0x10140008
    10140008: 0x00000000

The correct result after this fix:
    (qemu) xp /1wx 0x10140008
    10140008: 0x00020000

Cc: [email protected]
Signed-off-by: Tao Ding <[email protected]>
Message-id: 7584486ba62bc6d767c0d132dc843067f8c5efff.1773301927.git.dingtao0430@163.com
Reviewed-by: Peter Maydell <[email protected]>
[PMM: Adjusted commit message]
Signed-off-by: Peter Maydell <[email protected]>
2026-03-13 12:20:46 +00:00
Peter Maydell 37c9f6fce5 hw/dma/pl080: Handle bogus swidth and dwidth in transfers
The PL080 TRM states that the DWidth and SWidth fields of the channel
control registers can only validly specify widths up to 32 bits (i.e.
values from 0 to 2) and all other values are reserved.

Currently we don't check this, so if the guest specifies an invalid
value we will transfer more data into our local 'buff[]' array than
it can hold.

Check the widths; since the TRM doesn't clearly specify any behaviour
for what to do on invalid values, we choose to log them and then
ignore the channel for transfers.

Cc: [email protected]
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3203
Reviewed-by: Jim MacArthur <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
Message-id: [email protected]
2026-03-13 11:19:57 +00:00
Razvan Ghiorghe 5e5b278d2b linux-user: fix mremap with old_size=0 for shared mappings
When old_size is zero and old_address refers to a shareable mapping,
mremap() should create a new mapping of the same pages according to the
mremap(2) man page. The MREMAP_MAYMOVE flag must be specified in this case.

Previously, QEMU's target_mremap() rejected this valid case with EFAULT
during the initial validation, before checking for the special
old_size == 0 behaviour.

This patch adds proper handling for old_size == 0:
- Validates that MREMAP_MAYMOVE flag is set (required by man spec)
- Passes the call through to the host mremap()
- Creates a new mapping without invalidating the original, with both
  being valid and sharing the same physical memory frames.
- Ensures the new mapping address falls within the valid guest address
  region before returning it to the guest.

Tested with the reproducer from the issue on qemu-riscv64, qemu-hppa,
and qemu-aarch64.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3105
Signed-off-by: Razvan Ghiorghe <[email protected]>
Tested-by: Helge Deller <[email protected]>
Reviewed-by: Helge Deller <[email protected]>
Signed-off-by: Helge Deller <[email protected]>
2026-03-12 21:03:48 +01:00
Razvan Ghiorghe 2ff529c6f6 linux-user: Fix zero_bss for RX PT_LOAD segments
zero_bss() incorrectly assumed that any PT_LOAD containing .bss must be
writable, rejecting valid ELF binaries where .bss overlaps the tail of
an RX file-backed page.

Instead of failing, temporarily enable write access on the overlapping
page to zero the fractional bss range, then restore the original page
permissions once initialization is complete.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3179
Signed-off-by: Razvan Ghiorghe <[email protected]>
Reviewed-by: Helge Deller <[email protected]>
Signed-off-by: Helge Deller <[email protected]>
2026-03-12 21:03:48 +01:00
Martin Kröning c400bd4058 semihosting/uaccess: Use the cpu_internal_tswap() functions
The semihosting ABI [1] states:
> Multi-byte values in memory must be formatted as pure little-endian or pure
> big-endian to match the endianness mapping configuration of the processor.

This commits ensures that semihosting data is properly byte-swapped if
the guest's CPU is currently in a different runtime-configurable
endianness than the host's CPU.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3258
Buglink: https://github.com/taiki-e/semihosting/issues/18

[1]: https://github.com/ARM-software/abi-aa/blob/2025Q1/semihosting/semihosting.rst#the-semihosting-interface

Signed-off-by: Martin Kröning <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Message-id: 20260311-semihosting-cpu-tswap-v3-3-8e239575ec08@eonerc.rwth-aachen.de
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Tested-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
2026-03-12 19:24:24 +00:00
Martin Kröning c24e94fd15 include/exec: Provide the cpu_internal_tswap() functions
These functions are needed to support semihosting on CPUs that support
runtime-configurable endianness. They should not be used in other contexts.

Signed-off-by: Martin Kröning <[email protected]>
Message-id: 20260311-semihosting-cpu-tswap-v3-2-8e239575ec08@eonerc.rwth-aachen.de
Reviewed-by: Peter Maydell <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Tested-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
2026-03-12 19:24:18 +00:00
Martin Kröning 95b1f7cfd1 include/hw/core: Rename virtio_is_big_endian to internal_is_big_endian
These functions are needed to do semihosting on CPUs that support
runtime-configurable endiannes. This commit renames them and allows
using them for semihosting, but makes sure to signal that these
functions should not be used in other circumstances.

Signed-off-by: Martin Kröning <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Message-id: 20260311-semihosting-cpu-tswap-v3-1-8e239575ec08@eonerc.rwth-aachen.de
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Tested-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
2026-03-12 18:29:16 +00:00
Peter Maydell b83a42dc77 hw/net/rtl8319: Work around GCC sanitizer / -Wstringop-overflow bug
If you compile QEMU with GCC with -fsanitize=address and
-Wstringop-overflow, this causes GCC to produce a false-positive
warning which it does not produce when the sanitizer is not enabled
(and which makes compilation fail if you're using -Werror, as we do
by default for builds from git):

../../hw/net/rtl8139.c: In function ‘rtl8139_io_writeb’:
../../hw/net/rtl8139.c:2264:17: error: writing 8 bytes into a region of size 0 [-Werror=stringop-overflow=]
 2264 |                 memcpy(data_to_checksum, saved_ip_header + 12, 8);
      |                 ^
In file included from ../../hw/net/rtl8139.c:62:
/home/pm215/qemu/include/net/eth.h:50:14: note: at offset [8, 48] into destination object ‘ip_ver_len’ of size 1
   50 |     uint8_t  ip_ver_len;     /* version and header length */
      |              ^~~~~~~~~~
../../hw/net/rtl8139.c:2192:21: error: writing 8 bytes into a region of size 0 [-Werror=stringop-overflow=]
 2192 |                     memcpy(data_to_checksum, saved_ip_header + 12, 8);
      |                     ^
/home/pm215/qemu/include/net/eth.h:50:14: note: at offset [8, 48] into destination object ‘ip_ver_len’ of size 1
   50 |     uint8_t  ip_ver_len;     /* version and header length */
      |              ^~~~~~~~~~
../../hw/net/rtl8139.c:2192:21: error: writing 8 bytes into a region of size 0 [-Werror=stringop-overflow=]
 2192 |                     memcpy(data_to_checksum, saved_ip_header + 12, 8);
      |                     ^
/home/pm215/qemu/include/net/eth.h:50:14: note: at offset [8, 48] into destination object ‘ip_ver_len’ of size 1
   50 |     uint8_t  ip_ver_len;     /* version and header length */
      |              ^~~~~~~~~~
In file included from /home/pm215/qemu/include/system/memory.h:21,
                 from /home/pm215/qemu/include/hw/pci/pci.h:4,
                 from /home/pm215/qemu/include/hw/pci/pci_device.h:4,
                 from ../../hw/net/rtl8139.c:54:
In function ‘stl_he_p’,
    inlined from ‘stl_be_p’ at /home/pm215/qemu/include/qemu/bswap.h:371:5,
    inlined from ‘rtl8139_cplus_transmit_one’ at ../../hw/net/rtl8139.c:2244:21,
    inlined from ‘rtl8139_cplus_transmit’ at ../../hw/net/rtl8139.c:2345:28,
    inlined from ‘rtl8139_io_writeb’ at ../../hw/net/rtl8139.c:2728:17:
/home/pm215/qemu/include/qemu/bswap.h:284:5: error: writing 4 bytes into a region of size 0 [-Werror=stringop-overflow=]
  284 |     __builtin_memcpy(ptr, &v, sizeof(v));
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/pm215/qemu/include/net/eth.h: In function ‘rtl8139_io_writeb’:
/home/pm215/qemu/include/net/eth.h:50:14: note: at offset [24, 64] into destination object ‘ip_ver_len’ of size 1
   50 |     uint8_t  ip_ver_len;     /* version and header length */
      |              ^~~~~~~~~~

This has been triaged as a bug in GCC:
 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114494
 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99673
(the sanitizer pass rewrites the IR in a way that conflicts with its
use by the warning pass that runs afterwards).

Since this is the only place in our code where we hit this, work
around it by disabling the -Wstringop-overflow in the part of
the function that hits it. We do this only when using the
address sanitizer on GCC, so that we still get the benefit
of the warning in most compilation scenarios.

Cc: [email protected]
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3006
Suggested-by: Daniel P. Berrangé <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
Tested-by: Alex Bennée <[email protected]>
Tested-by: Yodel Eldar <[email protected]>
Reviewed-by: Alex Bennée <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Message-id: [email protected]
2026-03-12 18:28:00 +00:00
Peter Maydell fff352b9b6 Merge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging
* accel/kvm: fix typo in variable name
* system: fix coverity issues related to confidential guest reset
* target/i386: add compat for migrating error code
* docs fixes
* hyperv/syndbg: check length returned by cpu_physical_memory_map()
* typedefs: move QIgvm out of typedefs.h
* rust: Update Cargo.lock
* i386/cpu: cleanups for ClearwaterForest, AMX and more

# -----BEGIN PGP SIGNATURE-----
#
# iQFIBAABCgAyFiEE8TM4V0tmI4mGbHaCv/vSX3jHroMFAmmynZkUHHBib256aW5p
# QHJlZGhhdC5jb20ACgkQv/vSX3jHroP4mgf/bBnkf9xtT4M7+tIoHWCPKGCBuKpQ
# K0IXQ3QM9SJkQpKDbxwytFeGUo2+3jzbsOL+TSm95BmvM9lLj1eP3RALs1r+N1MV
# PISUVwtYyva69OaY/AoiVk5GXMvUqnLMdKm/wTfASH9iA8vd8G20dq0UUqqV+sK0
# e1RZIC9iAURbYnEJhHVgN+I6BXEhDntX087YRV4DR04HI7Ypr8IoOFEbSGIjSbvo
# oiSnBHHH/4L6GlrHtGx03JXlqYG2i2jq/9k5InHXSKHkK9WdVxi8G9WdieoV/Eur
# bsFDJnQs48Na2WKR8R+OIsONdiyU+4zcFOSn8pOM6mJmdD7Fk+/3IPq/2g==
# =IIgH
# -----END PGP SIGNATURE-----
# gpg: Signature made Thu Mar 12 11:03:53 2026 GMT
# gpg:                using RSA key F13338574B662389866C7682BFFBD25F78C7AE83
# gpg:                issuer "[email protected]"
# gpg: Good signature from "Paolo Bonzini <[email protected]>" [full]
# gpg:                 aka "Paolo Bonzini <[email protected]>" [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:
  typedefs: move QIgvm out of typedefs.h
  rust: Update Cargo.lock
  target/i386: add compat for migrating error code
  docs: mention that WHPX supports Arm too
  qemu-options.hx: document Hyper-V enlightenments accelerator option
  docs: remove 64-bit only mentions for accelerators
  accel/kvm: fix typo in variable name
  coverity: fix coverity issues related to confidential guest reset
  i386/cpu: Enable CPUID 0x1f & cache model for ClearwaterForest
  i386/cpu: Adjust the note for CPU models with its-no
  i386/cpu: Remove unnecessary cache_info fields from builtin CPU model
  i386/cpu: Rename AMX mirror feature words with -alias suffix
  i386/cpu: Rename AMX mirror cpuid macros with _ALIAS suffix
  hyperv/syndbg: check length returned by cpu_physical_memory_map()

Signed-off-by: Peter Maydell <[email protected]>
2026-03-12 15:21:06 +00:00
Paolo Bonzini c725a896c6 typedefs: move QIgvm out of typedefs.h
Typedefs.h should only be used for really core types; QIgvm is
just an opaque struct that is defined in system/igvm-internal.h,
and the typedef itself can be placed simply in system/igvm.h.

Signed-off-by: Paolo Bonzini <[email protected]>
2026-03-12 12:02:55 +01:00
Philippe Mathieu-Daudé 37f3410ba4 rust: Update Cargo.lock
Update Cargo.lock on top of commit  7ecd3f7107 ("Merge tag
'for-upstream' of https://gitlab.com/bonzini/qemu into staging").

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-03-12 12:02:55 +01:00
Fiona Ebner 1b80f1009d target/i386: add compat for migrating error code
If cpu->env.has_error_code is true, backwards migration of a VM from
a QEMU binary with commit 27535e9cca to a QEMU binary without commit
27535e9cca will fail:

> kvm: error while loading state for instance 0x0 of device 'cpu'

In practice, wrongly setting the error code to 0 on the target is
often unproblematic, so additionally checking error_code != 0 in
cpu_errcode_needed() is not enough to mitigate the issue. Instead, add
proper machine version compat handling.

Cc: [email protected]
Fixes: 27535e9cca ("target/i386: Add support for save/load of exception error code")
Signed-off-by: Fiona Ebner <[email protected]>
Reviewed-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-03-12 12:02:55 +01:00
Mohamed Mediouni f4107cbe80 docs: mention that WHPX supports Arm too
Signed-off-by: Mohamed Mediouni <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-03-12 12:02:55 +01:00
Mohamed Mediouni def5aec63b qemu-options.hx: document Hyper-V enlightenments accelerator option
This option is WHPX-specific and controls whether Hyper-V enlightenments are enabled.

Signed-off-by: Mohamed Mediouni <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-03-12 12:02:55 +01:00
Mohamed Mediouni 861f93e3f3 docs: remove 64-bit only mentions for accelerators
QEMU itself no longer supports 32-bit systems.

Signed-off-by: Mohamed Mediouni <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-03-12 12:02:55 +01:00
Alyssa Ross 1347b79b7a accel/kvm: fix typo in variable name
Fixes: 94a8d39afd ("kvm: Consolidate must-have capability checks")
Signed-off-by: Alyssa Ross <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-03-12 12:02:55 +01:00
Ani Sinha 6068592e56 coverity: fix coverity issues related to confidential guest reset
Fix issues reported by Peter.

Fixes: ec9bafd2ea ("i386/sev: add support for confidential guest reset")
Fixes: e76c30bb13 ("hw/machine: introduce machine specific option 'x-change-vmfd-on-reset'")
Reported-by: Peter Maydell <[email protected]>
Reviewed-by: Zhao Liu <[email protected]>
Signed-off-by: Ani Sinha <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-03-12 12:02:55 +01:00
Peter Maydell 582df3794e Merge tag 'qtest-20260311-pull-request' of https://gitlab.com/farosas/qemu into staging
Qtest pull request

- memory leak fixes

# -----BEGIN PGP SIGNATURE-----
#
# iQJEBAABCAAuFiEEqhtIsKIjJqWkw2TPx5jcdBvsMZ0FAmmx49sQHGZhcm9zYXNA
# c3VzZS5kZQAKCRDHmNx0G+wxnSVPEAC5YnD2OAn6MYYWolLtauIMI1VKL0Z2fKLg
# f/qymCek5w7ktfi455kQoQIfixBYV8yPT5CLC+qvgYuL+BRQykUYwzHYP+As+boC
# etdmjdwJUkUEQEuIDuoSBWomVNEB6f2plgFJpcyTCbHlXAmEQYhcSQruEhWGMmwg
# F5UgJPbHOIhm0wk6S3wLs43V3M+wZnEnxa+AxT7wkWdTI3ZCAymRpvL3coUA0ACZ
# SkImWuxdx1Y8LW970vCw/AbIdTYnaB8WiPShbvVAkbTe2Sk9WkWyJ5zB2bEdVg/Z
# 8AsP1+/nVZDb4PdCeSYlD/0G378NFGpm5lF1I0OSPeI9yRuSxo0rS/aZsfxajOrH
# XNM0s6daWmyRkqPz00EcuKjWQwd26tv0sz6rmTkIj/XMBvlW5H455Z0lUM5TQ6K3
# dbmkZ0fkwlxpcIJqBi0JzVakBNjNnRVv6NzyFoYJ6I5gvv/8h/SwGk36pRBb0BSi
# X0sle6qEmpF9IRb56FI9vVhUdldCrIu8I0lY0cSWqWleMKO+geVcMOFixdmCOKwk
# CR8ZhaqkC6qdhFqlGX4nIoy2bvhrj5ULtQjXSnpfSRZCZajpfMxG4VNhrNpDy/CE
# bFajU+mNO29wJ9ACqE43cx/YpvGzkv5qvAg8yR52gjPQ8+sx7HU4cSdm1VTLcU/Z
# /UnojkSTJg==
# =8Bwh
# -----END PGP SIGNATURE-----
# gpg: Signature made Wed Mar 11 21:51:23 2026 GMT
# gpg:                using RSA key AA1B48B0A22326A5A4C364CFC798DC741BEC319D
# gpg:                issuer "[email protected]"
# gpg: Good signature from "Fabiano Rosas <[email protected]>" [unknown]
# gpg:                 aka "Fabiano Almeida Rosas <[email protected]>" [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: AA1B 48B0 A223 26A5 A4C3  64CF C798 DC74 1BEC 319D

* tag 'qtest-20260311-pull-request' of https://gitlab.com/farosas/qemu:
  tests/qtest/test-x86-cpuid-compat: Switch test_feature_flag to data-driven
  tests/qtest/test-x86-cpuid-compat: Switch test_cpuid_prop to data-driven
  tests/qtest/vhost-user-test: Use g_timeout_add() to schedule connect

Signed-off-by: Peter Maydell <[email protected]>
2026-03-12 09:48:03 +00:00
Peter Maydell c4c27695a1 Merge tag 'pr-plugins-20260311' of https://gitlab.com/pbo-linaro/qemu into staging
Changes:
- [PATCH trivial v3] plugins: add missing docstrings to qemu-plugin.h (Florian Hofhammer <[email protected]>)
  Link: https://lore.kernel.org/qemu-devel/[email protected]

# -----BEGIN PGP SIGNATURE-----
#
# iQGzBAABCgAdFiEEZrmU7KFPfy5auggff5BUDQoc0A8FAmmxwvwACgkQf5BUDQoc
# 0A/PbAv+PTVXGMa32ZhrU/py+m82QEEyw9FzGaYgmdt3dCKnoQRf+AV5aICPh41L
# YA90mBSrzLaTL5ysPdAutT/kFNX4toT6rj/sMzkDvWp3404cA+09AGBeumoUxCod
# q5/GjCifWCFQLGUjVKRXVNKtshBJAJt9+E/LAr0Qf9V6jDTJtw1xENgU4FO8HGc4
# jnVv998zt8/YjjAuePO1gbBCS3OczsvdSCPRtGEKT/xrA7OoMwjPxdbXQVdXWtL3
# viRr0KKuduaKiosAgjxldnafFPnU76pImYaqH1dalJ5CJBQ36sF41bzMccSfcPcY
# g7XE7wCz2vQDUaLUjTDHf6e86E0U96d56rfF/MrRD1H1lNdpZRZPaw7MUjl07q9Z
# tY3BZtPU6FCCmwmHMmttCjw8pR6psxfD5Hzxei77HkfvmG4hUxWpQJaJV17u6Xm/
# ZxsBXuZodGxhWt922ssysdXum5FY3oE6imfQyjs5wfuu+WV3teMNNtC/uP10VQGo
# vioz2aoR
# =gkTu
# -----END PGP SIGNATURE-----
# gpg: Signature made Wed Mar 11 19:31:08 2026 GMT
# gpg:                using RSA key 66B994ECA14F7F2E5ABA081F7F90540D0A1CD00F
# gpg: Good signature from "Pierrick Bouvier <[email protected]>" [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: 66B9 94EC A14F 7F2E 5ABA  081F 7F90 540D 0A1C D00F

* tag 'pr-plugins-20260311' of https://gitlab.com/pbo-linaro/qemu:
  plugins: add missing docstrings to qemu-plugin.h

Signed-off-by: Peter Maydell <[email protected]>
2026-03-12 09:47:52 +00:00
Peter Maydell 6ba08f4ace tests/qtest/test-x86-cpuid-compat: Switch test_feature_flag to data-driven
As with add_cpuid_test(), the add_feature_test() function also
allocates memory that is leaked if the test case is not run.  Fix
this in the same way, by moving all the allocations into
test_feature_flag() and passing it a pointer to a struct with the
necessary parameters which is a compile-time constant.

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Fabiano Rosas <[email protected]>
Signed-off-by: Fabiano Rosas <[email protected]>
2026-03-11 18:43:20 -03:00
Peter Maydell a923b47f32 tests/qtest/test-x86-cpuid-compat: Switch test_cpuid_prop to data-driven
In test-x86-cpuid-compat, we allocate memory in add_cpuid_test()
which is then freed in the test function test_cpuid_prop().  This
means that this memory is leaked if the test is never run, which
happens in several cases:
 * user asks to list tests with -l option
 * user asks to run only some tests with -p or similar option
 * we are running a "subprocess" test and glib re-invokes the
   test binary telling it to run a specific single test

As noted in the commit message of commit 93ed7d3303, we cannot
deal with this by using g_test_add_data_func_full() and passing a
free-function, because glib doesn't call that if the test is not
executed.

Instead, move all the data allocations into test_cpuid_prop(),
and pass it a pointer to a struct with the necessary parameters
which is a compile-time constant.

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Fabiano Rosas <[email protected]>
Signed-off-by: Fabiano Rosas <[email protected]>
2026-03-11 18:43:20 -03:00
Peter Maydell d5444408c7 tests/qtest/vhost-user-test: Use g_timeout_add() to schedule connect
In vhost-user-test, we currently create a new g_thread to run the
connect_thread() function.  This function sleeps for 1 second, and
then calls test_server_create_chr() to create and configure a
chardev:

    chr = qemu_chr_new(server->chr_name, chr_path, server->context);
    g_assert(chr);

    qemu_chr_fe_init(&server->chr, chr, &error_abort);
    qemu_chr_fe_set_handlers(&server->chr, chr_can_read, chr_read,
                             chr_event, NULL, server, server->context, true);

This has a race condition, because when we set the
'reconnect-ms=1000' option on the chardev the socket chardev's
implementation handles the connect asynchronously, via a background
thread and a callback invoked in the main-loop thread.  This means
that that callback and the test_server_create_chr() call to
qemu_chr_fe_set_handlers() can both enter the char-socket code
simultaneously.  The result is random assertion failures and memory
leaks reported by the clang address-sanitizer.

Fix this by using g_timeout_source_new() to set up a GSource that
will run test_server_connect() on the main-loop thread.  This ensures
it can't execute in parallel with the callback that the socket
chardev sets up.  This is similar to how we already handle the
reconnect_cb() in test_reconnect().

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Fabiano Rosas <[email protected]>
Signed-off-by: Fabiano Rosas <[email protected]>
2026-03-11 18:43:20 -03:00
Florian Hofhammer 71b424ca76 plugins: add missing docstrings to qemu-plugin.h
This patch adds docstrings for typedefs and function declarations in
include/plugins/qemu-plugin.h that were previously missing. This
resolves inconsistencies in the docs, e.g., the description for
qemu_plugin_read_register() referring to qemu_plugin_register_flush_cb()
but code cache flush callbacks not being documented themselves.

Signed-off-by: Florian Hofhammer <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Pierrick Bouvier <[email protected]>
2026-03-11 12:30:17 -07:00
Zhao Liu acf74c1e8b i386/cpu: Enable CPUID 0x1f & cache model for ClearwaterForest
ClearwaterForest has CPUID 0x1f by default, so force enabling this leaf
for it (ClearwaterForect-v3).

And add the cache model to ClearwaterForest (v3) to better emulate its
environment.

The cache model is based on ClearwaterForest-AP (Advanced Performance):

      --- cache 0 ---
      cache type                         = data cache (1)
      cache level                        = 0x1 (1)
      self-initializing cache level      = true
      fully associative cache            = false
      maximum IDs for CPUs sharing cache = 0x0 (0)
      maximum IDs for cores in pkg       = 0x3f (63)
      system coherency line size         = 0x40 (64)
      physical line partitions           = 0x1 (1)
      ways of associativity              = 0x8 (8)
      number of sets                     = 0x40 (64)
      WBINVD/INVD acts on lower caches   = false
      inclusive to lower caches          = false
      complex cache indexing             = false
      number of sets (s)                 = 64
      (size synth)                       = 32768 (32 KB)
      --- cache 1 ---
      cache type                         = instruction cache (2)
      cache level                        = 0x1 (1)
      self-initializing cache level      = true
      fully associative cache            = false
      maximum IDs for CPUs sharing cache = 0x0 (0)
      maximum IDs for cores in pkg       = 0x3f (63)
      system coherency line size         = 0x40 (64)
      physical line partitions           = 0x1 (1)
      ways of associativity              = 0x8 (8)
      number of sets                     = 0x80 (128)
      WBINVD/INVD acts on lower caches   = false
      inclusive to lower caches          = false
      complex cache indexing             = false
      number of sets (s)                 = 128
      (size synth)                       = 65536 (64 KB)
      --- cache 2 ---
      cache type                         = unified cache (3)
      cache level                        = 0x2 (2)
      self-initializing cache level      = true
      fully associative cache            = false
      maximum IDs for CPUs sharing cache = 0x7 (7)
      maximum IDs for cores in pkg       = 0x3f (63)
      system coherency line size         = 0x40 (64)
      physical line partitions           = 0x1 (1)
      ways of associativity              = 0x10 (16)
      number of sets                     = 0x1000 (4096)
      WBINVD/INVD acts on lower caches   = false
      inclusive to lower caches          = false
      complex cache indexing             = false
      number of sets (s)                 = 4096
      (size synth)                       = 4194304 (4 MB)
      --- cache 3 ---
      cache type                         = unified cache (3)
      cache level                        = 0x3 (3)
      self-initializing cache level      = true
      fully associative cache            = false
      maximum IDs for CPUs sharing cache = 0x3ff (1023)
      maximum IDs for cores in pkg       = 0x3f (63)
      system coherency line size         = 0x40 (64)
      physical line partitions           = 0x1 (1)
      ways of associativity              = 0x10 (16)
      number of sets                     = 0x84000 (540672)
      WBINVD/INVD acts on lower caches   = false
      inclusive to lower caches          = false
      complex cache indexing             = true
      number of sets (s)                 = 540672
      (size synth)                       = 553648128 (528 MB)
      --- cache 4 ---
      cache type                         = no more caches (0)

Suggested-by: Zhijun Zeng <[email protected]>
Suggested-by: Chao Peng <[email protected]>
Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-03-11 17:02:00 +01:00
Zhao Liu 709ade3bbb i386/cpu: Adjust the note for CPU models with its-no
For new versioned CPU models with its-no enabled, since CET was already
enabled in previous versions, remove the related description from the
notes of its-no related CPU models.

Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-03-11 17:02:00 +01:00
Zhao Liu d8c0ef548c i386/cpu: Remove unnecessary cache_info fields from builtin CPU model
In x86_cpu_get_versioned_cache_info(), higher version CPU models will
inherit cache_info from lower versions if the cache_info field is not
specified, so there is no need to repeatedly set the same cache_info.

Therefore, remove the repeated cache models from SapphireRapids-v6
(SapphireRapids-v4 has set the cache model), GraniteRapids-v5
(GraniteRapids-v3 has set) and SierraForest-v5 (SierraForest-v3 has
set).

Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-03-11 17:02:00 +01:00
Zhao Liu 85dc6147e7 i386/cpu: Rename AMX mirror feature words with -alias suffix
The commit 956b8f0fc3 ("i386/cpu: Add CPUID.0x1E.0x1 subleaf for AMX
instructions") names amx-int8/amx-bf16/amx-complex-amx-fp16 in CPUID
0x1E.1.EAX with "-mirror" suffix.

To align with the naming style of corresponding macros, rename these
feature words with "-alias" suffix.

Since the commit 956b8f0fc3 is merged in v11.0 development cycle,
it's safe to modify the names of feature words (before v11.0 is
released).

Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-03-11 17:02:00 +01:00
Zhao Liu 1ad6644875 i386/cpu: Rename AMX mirror cpuid macros with _ALIAS suffix
For the similar case - CPUID_EXT2_AMD_ALIASES, the term "alias" has
already been used. Therefore, reintroducing the new term "mirror" is
likely to cause confusion.

Rename the relevant CPUID macros of AMX with _ALIAS suffix, aligning
with KVM's naming convention.

Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-03-11 17:02:00 +01:00
Paolo Bonzini 4f28b87fdd hyperv/syndbg: check length returned by cpu_physical_memory_map()
If cpu_physical_memory_map() returns a length shorter than the one
that was passed into the function, writing the full out_len bytes
causes an access beyond the memory allocated to the guest; or in
the case of the MMIO bounce buffer, an out-of-bounds access in a
heap-allocated object.

Add a check similar to the one already in handle_send_msg(),
and take the occasion to remove repeated computations of
recv_byte_count + UDP_PKT_HEADER_SIZE and clarify that the
code does not write past out_len bytes.

Reported-by: Oleh Konko <https://github.com/1seal>
Reviewed-by: Daniel P. Berrangé <[email protected]>
Fixes: CVE-2026-3842
Signed-off-by: Paolo Bonzini <[email protected]>
2026-03-11 17:01:30 +01:00
Peter Maydell 769a37d8bd Merge tag 'pr-gdbstub-20260310' of https://gitlab.com/pbo-linaro/qemu into staging
- [PATCH v4 00/16] gdbstub: Always infer base register index from GDB (=?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= <[email protected]>)
  Link: https://lore.kernel.org/qemu-devel/[email protected]

# -----BEGIN PGP SIGNATURE-----
#
# iQGzBAABCgAdFiEEZrmU7KFPfy5auggff5BUDQoc0A8FAmmwx5IACgkQf5BUDQoc
# 0A8L3Av/e0tWHqkofKIkvA1O1hWPM8pb1oa5HKdZXxzyto/gvDaborqwEIOBpfGu
# PBR+N6zbYeKu+/7WR6WJePcQSrx/cPZ8AwOCO0rkUVIVKbod4Gxoa9nv+1F7LgPe
# 8zW7DSCcILfOXnNWy6StCkOziqaeabEOEE/XNta7qBj5xYSJd9duBorkLIxFP31t
# guYBM6911uBA6XLro/OHk+ryrTMHjCj9Z3QH4aNfspz7alG0pN7Ibd4EM3C8cgB8
# WDQncSLWBeXSJemIJdPa2J0kXvsaVzHxXy1MYurwWh67fhy4yFRuazAgLxeFFMXO
# j2UDlGTxeJ3lTpVBT69xXmUUwQuu7KxkVF4hteRy2il8DfswUJ3ONCE+WMmd28lc
# Tx4tyRTeMrm9zL2Of6fAZ3LFbIMSiF8RK7qLOcgySFGanvqU5yL+4e0b+EHnbBxG
# Q5gYdziiDJ9bELZA/M5UAJZVcjZIp09kar7GF8ioFC+VSxzOh6dX/NvIOntHs9AM
# spnK+r0A
# =t241
# -----END PGP SIGNATURE-----
# gpg: Signature made Wed Mar 11 01:38:26 2026 GMT
# gpg:                using RSA key 66B994ECA14F7F2E5ABA081F7F90540D0A1CD00F
# gpg: Good signature from "Pierrick Bouvier <[email protected]>" [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: 66B9 94EC A14F 7F2E 5ABA  081F 7F90 540D 0A1C D00F

* tag 'pr-gdbstub-20260310' of https://gitlab.com/pbo-linaro/qemu:
  gdbstub: Generate a single gdbstub-xml.c / gdb_static_features[]
  gdbstub: Move gdb-xml/ within gdbstub/
  gdbstub: Remove 'gdb-xml/' directory prefix in TARGET_XML_FILES
  tests/tcg: Re-enable disabled multiarch tests for PPC targets
  gdbstub: Consider GDBFeature::base_reg in gdb_register_coprocessor()
  gdbstub: Emit base_register index in GDBFeature entries
  gdbstub: Remove @g_pos argument in gdb_register_coprocessor()
  gdbstub: Make base register explicit in m68k GDB XML files
  gdbstub: Have scripts/feature_to_c.py generate more verbose output
  gdbstub: Add trace events for around XML parsing / generation
  gdbstub: Simplify gdb_init_cpu() logic
  meson: Restrict gdbstub to user/system builds
  target/i386/gdbstub: Remove stale comment
  tests/docker: add gdb-multiarch to all-test-cross
  tests/tcg: Disable prot-none test on GitLab
  tests/tcg: Temporary disable multiarch tests for PPC targets

Signed-off-by: Peter Maydell <[email protected]>
2026-03-11 10:55:27 +00:00
Philippe Mathieu-Daudé 6511d4eed7 gdbstub: Generate a single gdbstub-xml.c / gdb_static_features[]
gdb_static_features[] does not depend on target-specific code.
Instead of generating one file per target, generate a single file
with a single gdb_static_features[] array.

Co-developed-by: Chao Liu <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Manos Pitsidianakis <[email protected]>
Reviewed-by: Chao Liu <[email protected]>
Acked-by: Alex Bennée <[email protected]>
Tested-by: Pierrick Bouvier <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Pierrick Bouvier <[email protected]>
2026-03-10 17:12:18 -07:00
Philippe Mathieu-Daudé 39fb349f74 gdbstub: Move gdb-xml/ within gdbstub/
gdb-xml/ files are only consumed by gdbstub API.
No need for a top-level entry, move them to gdbstub/.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Manos Pitsidianakis <[email protected]>
Reviewed-by: Alex Bennée <[email protected]>
Tested-by: Alex Bennée <[email protected]>
Acked-by: Alex Bennée <[email protected]>
Tested-by: Pierrick Bouvier <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Pierrick Bouvier <[email protected]>
2026-03-10 17:12:18 -07:00
Philippe Mathieu-Daudé 06531c79ee gdbstub: Remove 'gdb-xml/' directory prefix in TARGET_XML_FILES
All GDB XML files are in the gdb-xml/ directory. No need to be
so verbose in TARGET_XML_FILES, let meson prepend the directory.

Except meson.build lines, this is a mechanical change done running:

 $ sed -i -e s,gdb-xml/,,g $(git grep -l gdb-xml configs/targets/)

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Manos Pitsidianakis <[email protected]>
Reviewed-by: Warner Losh <[email protected]>
Reviewed-by: Alex Bennée <[email protected]>
Tested-by: Alex Bennée <[email protected]>
Acked-by: Alex Bennée <[email protected]>
Tested-by: Pierrick Bouvier <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Pierrick Bouvier <[email protected]>
2026-03-10 17:12:18 -07:00
Philippe Mathieu-Daudé 7b509a08b4 tests/tcg: Re-enable disabled multiarch tests for PPC targets
Previous patch fixed gdbstub / PPC, we can run the tests again.

Suggested-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Pierrick Bouvier <[email protected]>
2026-03-10 17:12:18 -07:00
Philippe Mathieu-Daudé b3e88abb20 gdbstub: Consider GDBFeature::base_reg in gdb_register_coprocessor()
When a feature XML file provides a "regnum=" tag to indicate
the registers base index, respect it, as it might not be the
same as our current number of registered entries, in particular
when there are gaps.

This fixes a bug with the "power-fpu.xml" file [*] which was
loaded at index 70 while the base register is 71. This latent
bug was exposed by commit 1ec0fbe2dd ("target/ppc: Fix
CPUClass::gdb_num_core_regs value").

[*] https://lore.kernel.org/qemu-devel/[email protected]/

Reported-by: Florian Hofhammer <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Tested-by: Pierrick Bouvier <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Pierrick Bouvier <[email protected]>
2026-03-10 17:12:18 -07:00
Philippe Mathieu-Daudé e0930f667a gdbstub: Emit base_register index in GDBFeature entries
Record the base register index in the generated C file.

Check at runtime that either @g_pos argument of
gdb_register_coprocessor() is zero, or it the base register
index.

This change pass 'make check-tcg' test suite, which runs the
tests/tcg/multiarch/gdbstub/registers.py test, itself calling
gdb_register_coprocessor() for each target tested.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Tested-by: Pierrick Bouvier <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Pierrick Bouvier <[email protected]>
2026-03-10 17:12:18 -07:00
Philippe Mathieu-Daudé aa6a508795 gdbstub: Remove @g_pos argument in gdb_register_coprocessor()
gdb_register_coprocessor()'s @g_pos argument is always '0',
meaning it is inferred from cpu->gdb_num_regs. Use instead
feature->base_reg.

Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Tested-by: Pierrick Bouvier <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Pierrick Bouvier <[email protected]>
2026-03-10 17:12:18 -07:00
Philippe Mathieu-Daudé 9aad3f83a5 gdbstub: Make base register explicit in m68k GDB XML files
Both gdb-xml/cf-fp.xml and gdb-xml/m68k-fp.xml aren't imported
from GDB repository. Presumably they are hand-written, and lack
the @regnum XML tag.

This might explain why gdb_register_coprocessor() have a @g_pos
argument, only used for these 2 m68k files.

Fixes: 56aebc8916 ("Add GDB XML register description support")
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Tested-by: Pierrick Bouvier <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Pierrick Bouvier <[email protected]>
2026-03-10 17:12:18 -07:00
Philippe Mathieu-Daudé 400b3633ff gdbstub: Have scripts/feature_to_c.py generate more verbose output
Make the structure field names explicit, so it is easier
to figure what is what when reviewing multiple entries.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Tested-by: Pierrick Bouvier <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Pierrick Bouvier <[email protected]>
2026-03-10 17:12:18 -07:00
Philippe Mathieu-Daudé 1e06ef47df gdbstub: Add trace events for around XML parsing / generation
Add trace events to help follow how the various files in
gdb-xml/ are parsed or generated at runtime.

Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Tested-by: Pierrick Bouvier <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Pierrick Bouvier <[email protected]>
2026-03-10 17:12:18 -07:00
Philippe Mathieu-Daudé 3b6cf87d42 gdbstub: Simplify gdb_init_cpu() logic
Ensure we either set gdb_num_core_regs or have a XML file.
We shouldn't modify CPUClass content, so mark it const.

Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Tested-by: Pierrick Bouvier <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Pierrick Bouvier <[email protected]>
2026-03-10 17:12:18 -07:00
Philippe Mathieu-Daudé 29e30df3f3 meson: Restrict gdbstub to user/system builds
Limited builds (tools, documentation) don't need to generate /
build gdbstub files. Only process the gdbstub/ folder when
user / system emulation / acceleration is built.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Manos Pitsidianakis <[email protected]>
Reviewed-by: Alex Bennée <[email protected]>
Tested-by: Alex Bennée <[email protected]>
Acked-by: Alex Bennée <[email protected]>
Tested-by: Pierrick Bouvier <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Pierrick Bouvier <[email protected]>
2026-03-10 17:12:18 -07:00
Philippe Mathieu-Daudé 541870763f target/i386/gdbstub: Remove stale comment
Since commit ecd6f6a882 ("gdbstub: Infer number of core
registers from XML") gdb_num_core_regs is inferred for
the x86 targets. Remove a stale comment.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Tested-by: Pierrick Bouvier <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Pierrick Bouvier <[email protected]>
2026-03-10 17:12:18 -07:00
Alex Bennée 5459318a25 tests/docker: add gdb-multiarch to all-test-cross
This allows the gdb integration tests to be run as well.

Signed-off-by: Alex Bennée <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Pierrick Bouvier <[email protected]>
2026-03-10 17:12:18 -07:00
Philippe Mathieu-Daudé c0ca86f510 tests/tcg: Disable prot-none test on GitLab
When adding gdb-multiarch on our container images, we
see the prot-none tests to pass on GitHub but fail on
GitLab. Disable and track:
https://gitlab.com/qemu-project/qemu/-/issues/3329

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Pierrick Bouvier <[email protected]>
2026-03-10 17:12:18 -07:00
Philippe Mathieu-Daudé c399ad4791 tests/tcg: Temporary disable multiarch tests for PPC targets
gdbstub is currently broken for the PPC targets [*]. We
didn't notice because our tests require gdb-multiarch which
isn't installed on our containers. Next patch will fix that,
but we need to temporary disable the PPC target test to keep
our CI green.

[*] https://lore.kernel.org/qemu-devel/[email protected]/

Suggested-by: Pierrick Bouvier <[email protected]>
Message-Id: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Pierrick Bouvier <[email protected]>
2026-03-10 17:12:18 -07:00
Peter Maydell 1fd5ff9d76 Merge tag 'for-upstream' of https://gitlab.com/kmwolf/qemu into staging
Block layer patches

- export/fuse: Use coroutines and multi-threading
- curl: Add force-range option
- nfs: add support for libnfs v6

# -----BEGIN PGP SIGNATURE-----
#
# iQJFBAABCgAvFiEE3D3rFZqa+V09dFb+fwmycsiPL9YFAmmwOl4RHGt3b2xmQHJl
# ZGhhdC5jb20ACgkQfwmycsiPL9b1dBAAikQXP9Pf9QMa2Z+DxlsZkTZW7y0mDKZW
# QKcHLPmeKvBFI/jPBM4Kh3X3cxXP74q9n4qHW/mCwttYvEK/ZT47MmlypAawFoVL
# NIp9LGDUi/ohh2eAM/v21kdjWClBXnX9T2DPIM8QYn4RcpSrcKVoCs8f5wlTg52/
# hpJdvksF53P6dUcGSVv6MmQGnHl4Y22+mWXtn6KMDYqm7CaaqWEfcANMEMHdxaxZ
# zCEbEFuiEsX7EiG+AooVkqZJoe17roBeYq5td91qZy1by5pBo8W86Q26303n+DII
# 45qtEhhxIaKxHtxop/c84khImNdETUZI1rObXDuNqVPX6YrqPixBDHZ8QxO6+t0z
# MfRz6AcEIJ0ImNagnAy7wG80gFhoInuy7G0pGSP4bkIV3A523sqrjkbJmbVXConC
# 98PoNoAIzG7NnxtFdu5JiaTHvCe9ZgH6P5GpgBZEGw0eGZBZuhsqsR7XqGWJRC/A
# XLGCG0UKKJvsMVWciHAseQuF/dme04EqpW27hZnh4IaqTQhEAYlh6gVJCI5h0HRj
# iRGBA9KsInO1DhI9roIxc1CFb6N6PmLCLxbzcizaPv0gtm3ADWXKe3k1ZbwkCs99
# erHEW8hWnNJb3cVheLcxr6wUsX2cd9sxwQ3+17Ou04UUvYPwojsLmr5JLAFHdvRN
# 3RyhPEyvyb0=
# =VJn6
# -----END PGP SIGNATURE-----
# gpg: Signature made Tue Mar 10 15:35:58 2026 GMT
# gpg:                using RSA key DC3DEB159A9AF95D3D7456FE7F09B272C88F2FD6
# gpg:                issuer "[email protected]"
# gpg: Good signature from "Kevin Wolf <[email protected]>" [full]
# Primary key fingerprint: DC3D EB15 9A9A F95D 3D74  56FE 7F09 B272 C88F 2FD6

* tag 'for-upstream' of https://gitlab.com/kmwolf/qemu: (28 commits)
  block/curl: add support for S3 presigned URLs
  qapi: block: Refactor HTTP(s) common arguments
  block/nfs: add support for libnfs v6
  iotests/308: Add multi-threading sanity test
  qapi/block-export: Document FUSE's multi-threading
  fuse: Implement multi-threading
  fuse: Make shared export state atomic
  iotests/307: Test multi-thread export interface
  block/export: Add multi-threading interface
  fuse: Process requests in coroutines
  fuse: Reduce max read size
  fuse: Manually process requests (without libfuse)
  fuse: Drop permission changes in fuse_do_truncate
  block: Move qemu_fcntl_addfl() into osdep.c
  fuse: Explicitly handle non-grow post-EOF accesses
  iotests/308: Use conv=notrunc to test growability
  fuse: fuse_{read,write}: Rename length to blk_len
  fuse: Add halted flag
  fuse: Introduce fuse_{inc,dec}_in_flight()
  fuse: Introduce fuse_{at,de}tach_handlers()
  ...

Signed-off-by: Peter Maydell <[email protected]>
2026-03-10 16:29:24 +00:00
Antoine Damhet 7b13fc97d7 block/curl: add support for S3 presigned URLs
S3 presigned URLs are signed for a specific HTTP method (typically GET
for our use cases). The curl block driver currently issues a HEAD
request to discover the web server features and the file size, which
fails with 'HTTP 403' (forbidden).

Add a 'force-range' option that skips the HEAD request and instead
issues a minimal GET request (querying 1 byte from the server) to
extract the file size from the 'Content-Range' response header. To
achieve this the 'curl_header_cb' is redesigned to generically parse
HTTP headers.

$ $QEMU -drive driver=https,\
             'url=https://s3.example.com/some.img?X-Amz-Security-Token=XXX',
             force-range=true

Enabling the 'force-range' option without the web server specified with
@url supporting it might cause the server to respond successfully with
'HTTP 200' and attempt to send the whole file body. With the
'CURLOPT_NOBODY' option set the libcurl will skip reading after the
headers and close the connection. QEMU still gracefully detects the
missing feature. This might waste a small number of TCP packets but is
otherwise transparent to the user.

Acked-by: Markus Armbruster <[email protected]>
Signed-off-by: Antoine Damhet <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Kevin Wolf <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
2026-03-10 15:48:48 +01:00
Antoine Damhet 15c719a142 qapi: block: Refactor HTTP(s) common arguments
The HTTPs curl block driver is a superset of the HTTP driver, reflect
that in the QAPI.

Suggested-by: Markus Armbruster <[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Signed-off-by: Antoine Damhet <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Kevin Wolf <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
2026-03-10 15:48:43 +01:00
Peter Lieven 37d10da587 block/nfs: add support for libnfs v6
libnfs v6 added a new api structure for read and write requests.

This effectively also adds zero copy read support for cases where
the qiov coming from the block layer has only one vector.

The .brdv_refresh_limits implementation is needed because libnfs v6
silently dropped support for splitting large read/write request into
chunks.

Signed-off-by: Ronnie Sahlberg <[email protected]>
Signed-off-by: Peter Lieven <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Kevin Wolf <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
2026-03-10 14:33:55 +01:00
Peter Maydell ae56950eac Merge tag 'firmware-20260310-pull-request' of https://gitlab.com/kraxel/qemu into staging
- firmware.json spec update for svsm.
- igvm bugfixes.

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCgAdFiEEoDKM/7k6F6eZAf59TLbY7tPocTgFAmmwGuAACgkQTLbY7tPo
# cTiOBQ//cln4/XTERNZqSiKGcjeX857L0KSw1JN2hHgXwvTMBTdCJHz0ZQw8mk5t
# ixcguZjmF2F9Xblljjwf8mQATtbZfnVtkkDXIGeezO3DRP38KK7OcHHPtHIJ2bdc
# cR1WOAPVn3465AFa6RqOhjK17U2aU9NQG7ecW2LbB6MuPCTwMdDQeZ4UEsVuBFf6
# b7vIUmDAQmOhMQEnaVdQUUFY7NyTv8i7KCXdf7c7Iz32VC7XJHJwQKrK7ixtuzVP
# /YWlcg//Qld/fhAWSb6N/mPxbrlpVbzeP93uoS0NF8RnF+5UpbNmNs2GSnI0Hu2+
# P1nvxOBDUGY6jZoha9mOQqMwj9C/rIC9mn72Wj0s8rukQV+bMZX/HjSF4HN1gbeV
# 2vqT3+I7khQxg89tlsGPCMMM+AtLCZA5dMKZ2EnAUdmZMbGEfjoR31spfIbUMsiI
# edDWLTetPHMHy+0Cyqbsg40RRmV9/QuysmFbMV5St2J+6oXxZBdF23m3VtDrYZRY
# e8qliIH8fdtnQWScELuAU33SY300ZXolurwHKsE86eWWDk2x6+u3funLWV3wcp3g
# ME0x3CycRooCEYV3ixy335YYMcE1pH6XjFLjMU6S5ABY3d/34P+0sF44ztvQ5Apj
# R+mEYe1gwyRzyTOUzBRz9+xJJvzOjpPTXvukKKofcF8eZNO+pTA=
# =taqn
# -----END PGP SIGNATURE-----
# gpg: Signature made Tue Mar 10 13:21:36 2026 GMT
# gpg:                using RSA key A0328CFFB93A17A79901FE7D4CB6D8EED3E87138
# gpg: Good signature from "Gerd Hoffmann (work) <[email protected]>" [full]
# gpg:                 aka "Gerd Hoffmann <[email protected]>" [full]
# gpg:                 aka "Gerd Hoffmann (private) <[email protected]>" [full]
# Primary key fingerprint: A032 8CFF B93A 17A7 9901  FE7D 4CB6 D8EE D3E8 7138

* tag 'firmware-20260310-pull-request' of https://gitlab.com/kraxel/qemu:
  i386/sev/igvm: do not reset guest policy if IGVM does not set it
  igvm: fix build when igvm is not installed in a well known path
  docs/interop: Add AMD SEV-SNP SVSM interface to firmware.json

Signed-off-by: Peter Maydell <[email protected]>
2026-03-10 13:32:30 +00:00
Peter Maydell 9745100afc Merge tag 'pull-loongarch-20260310' of https://github.com/gaosong715/qemu into staging
loongarch bug fix

# -----BEGIN PGP SIGNATURE-----
#
# iLMEAAEKAB0WIQTKRzxE1qCcGJoZP81FK5aFKyaCFgUCabAI8QAKCRBFK5aFKyaC
# FpRjA/sEr6qXd39gBPudz/qUJQ5b+4yJIk7KUknw0vR/Dxo97XwNBRoBYkKPQED5
# mcPJkjBrZdNQnWQmWZPK4LSMzfW7juhW+OeG59fX/hD5JgzXVM9MgRLG89VwiZbc
# 1oTEI0paFaCjImzamHuGxIxVQ5/niyo3X5/dLluKDdYX9uk1+g==
# =d2Zg
# -----END PGP SIGNATURE-----
# gpg: Signature made Tue Mar 10 12:05:05 2026 GMT
# gpg:                using RSA key CA473C44D6A09C189A193FCD452B96852B268216
# gpg: Good signature from "Song Gao <[email protected]>" [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: CA47 3C44 D6A0 9C18 9A19  3FCD 452B 9685 2B26 8216

* tag 'pull-loongarch-20260310' of https://github.com/gaosong715/qemu:
  target/loongarch: Avoid recursive PNX exception on CSR_BADI fetch
  target/loongarch: Preserve PTE permission bits in LDPTE

Signed-off-by: Peter Maydell <[email protected]>
2026-03-10 13:32:16 +00:00
Peter Maydell 89851dbcce Merge tag 'accel-tcg-20260310' of https://github.com/philmd/qemu into staging
Accelerators and TCG patches queue

- Improve TCG extract and deposit
- Build accelerator stub files once

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCAAdFiEE+qvnXhKRciHc/Wuy4+MsLN6twN4FAmmv9goACgkQ4+MsLN6t
# wN4NVQ//UsLGikzMHhQ52JqSePy3hJ00uBzeZ+6exKcgWfCHCEKLimTewCSuhdjM
# qic6DGSShUrl36EVT1qRdz261jntgvfn12TQfs0LdSvgZKBjdWFcZ+AiIp54jYTS
# Wi0Qsdqi0+oXg4ictiefmGlgqo65qJU8U8mnclzOa5GmLMZC4QbGhV3qvEcE0BNc
# 1tzLSSschLWOqAG+vaHUCyyhr28UgJGO7pqVSuVnw2fA1jXVyRH671ZIyhBf85o9
# eWlChqtuvwrauKojD2eIK4qMw3esDqlwRXckvLu6/Nq1McXYbdc5Mm61c6JW5Wza
# LXMms6bix2iS0CoR5qmkEFgttVe5aZtJwXkYW2FE/+p6wscZHOyhrs0YdxkYqjgp
# 9WYkyqK9oeLLDBHQ2XAa4f+zE/4nPaWzKElu/kqA+XrrxvnkQisD2uijxioXCi6X
# CUa+pJrXxiKZOrWRXRGwuPpdJT4CrX082ydhQnsnH0Pi7gedpXZj9eYIRjxSvndZ
# 06ONtE/4Ja++gKNF6sbu8HLY7eCrfIVCQGOex4h6BrQsyZKU/EYbw0LhcVfUooMw
# QsF3rMD2AyWpzPzcJ3Y0E7t7e5iKNJoKLlN3ziR9qz34HCjdoNmbIwvbR5oUkJpd
# dhvtPikIIgcRnQvVmuLdkiTg6he9z70lsCtSBCkkLQN8nb8j9cE=
# =ak2F
# -----END PGP SIGNATURE-----
# gpg: Signature made Tue Mar 10 10:44:26 2026 GMT
# gpg:                using RSA key FAABE75E12917221DCFD6BB2E3E32C2CDEADC0DE
# gpg: Good signature from "Philippe Mathieu-Daudé (F4BUG) <[email protected]>" [full]
# Primary key fingerprint: FAAB E75E 1291 7221 DCFD  6BB2 E3E3 2C2C DEAD C0DE

* tag 'accel-tcg-20260310' of https://github.com/philmd/qemu:
  accel/qtest: Build once as common object
  accel/xen: Build without target-specific knowledge
  accel/hvf: Build without target-specific knowledge
  accel/mshv: Build without target-specific knowledge
  accel/mshv: Forward-declare mshv_root_hvcall structure
  accel/stubs: Build stubs once
  accel/kvm: Make kvm_irqchip*notifier() declaration non target-specific
  accel/kvm: Include missing 'exec/cpu-common.h' header
  target/hppa: Expand tcg_global_mem_new() -> tcg_global_mem_new_i64()
  tcg/optimize: possibly expand deposit into zero with shifts
  tcg: target-dependent lowering of extract to shr/and
  tcg: Add tcg_op_imm_match
  tcg: Expand missing rotri with extract2
  tcg/optimize: Lower unsupported extract2 during optimize
  tcg/optimize: Lower unsupported deposit during optimize
  tcg: Drop extract+shl expansions in tcg_gen_deposit_z_*

Signed-off-by: Peter Maydell <[email protected]>
2026-03-10 13:32:04 +00:00
Ani Sinha 470ccb470b i386/sev/igvm: do not reset guest policy if IGVM does not set it
The guest policy is set either through command-line or through IGVM. If none of
the above applies, default guest policy applies. However, if IGVM does not set
the guest policy, currently the policy gets set to 0 regardless of whether it
was previously set to default value or command line. This change fixes this by
checking if IGVM indeed has set a policy value. If not, do not reset existing
value.

This avoids guest crashes such as the following during reset when the IGVM
has not explicitly set any guest policies:

qemu-system-x86_64: sev_snp_launch_start: SNP_LAUNCH_START ret=-22 fw_error=0 ''
qemu-system-x86_64: sev_common_kvm_init: failed to create encryption context
qemu-system-x86_64: unable to rebuild guest: Operation not permitted(-1)

Reported-by: Gerd Hoffmann <[email protected]>
Signed-off-by: Ani Sinha <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Gerd Hoffmann <[email protected]>
2026-03-10 14:20:41 +01:00
rail5 db2325f794 target/loongarch: Avoid recursive PNX exception on CSR_BADI fetch
loongarch_cpu_do_interrupt() updates CSR_BADI by fetching the faulting
instruction with cpu_ldl_code_mmu().

For a PNX exception (instruction fetch prohibited by NX), fetching the
instruction at env->pc will fault with PNX again. This can lead to an
infinite exception loop.

Treat PNX like other instruction-fetch exceptions (PIF/ADEF) and do not
update CSR_BADI for it.

Fixes: 410dfbf620 ("target/loongarch: Move TCG specified functions to tcg_cpu.c")
Cc: [email protected]
Signed-off-by: rail5 (Andrew S. Rightenburg) <[email protected]>
Reviewed-by: Bibo Mao <[email protected]>
Reviewed-by: Song Gao <[email protected]>
Signed-off-by: Song Gao <[email protected]>
2026-03-10 19:50:01 +08:00
rail5 2d877bc02a target/loongarch: Preserve PTE permission bits in LDPTE
The LDPTE helper loads a page table entry (or huge page entry) from guest
memory and currently applies the PALEN mask to the whole 64-bit value.

That mask is intended to constrain the physical address bits, but masking
the full entry also clears upper permission bits in the PTE, including NX
(bit 62). As a result, LoongArch TCG can incorrectly allow instruction
fetches from NX mappings when translation is driven through software
page-walk.

Fix this by masking only the PPN/address field with PALEN while preserving
permission bits, and by clearing any non-architectural (software) bits
using a hardware PTE mask. LDDIR is unchanged since it returns the base
address of the next page table level.

Reported at: https://gitlab.com/qemu-project/qemu/-/issues/3319

Fixes: 56599a705f ("target/loongarch: Introduce loongarch_palen_mask()")
Cc: [email protected]
Signed-off-by: rail5 (Andrew S. Rightenburg) <[email protected]>
Reviewed-by: Bibo Mao <[email protected]>
Reviewed-by: Song Gao <[email protected]>
Signed-off-by: Song Gao <[email protected]>
2026-03-10 19:49:54 +08:00
Peter Maydell 4680a6605e Merge tag 'pull-request-2026-03-10' of https://gitlab.com/thuth/qemu into staging
- Improve the s390-ccw bios to be able to boot from virtio-blk-pci devices
- Rework migration functional test to avoid a problem in the ppc64 test
- Disable functional memlock test for asan builds
- Some other minor tests improvements

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCgAdFiEEJ7iIR+7gJQEY8+q5LtnXdP5wLbUFAmmvsfEACgkQLtnXdP5w
# LbWozA/+NNi0PkYBvpubpAxoT9uRj9UiP+rcgzbWF93NxT5hLQINzwr4VvwbEdN0
# GM1vCUlGOcDhyDN7xcf82IYCLsOB1gU2+V6zEoGzsKdoXi9JIMh/EWowHuDh4HU2
# 1ghrevttQfRc97I4lh/w0s/zXwSu7ckflivo6TNzIxUdpP+NuSSCCGXygB54Ab0P
# bCt5lqKFAdn/HF1fIcNgMWEwPbmRtqkOlaxgTYghKdhau7SxZsRqlERlR2gA95bx
# u/n4pCMYTRoWYnROp+ChoZzhfmoHTuEb13GVOivbxsfXptoFeUCJlIQN2BNMK54E
# 6IxPzZ8F9d0KYlIc7sxEr9f3BvdBmbmbD4BV3bB6r0754EVQ2sJ5fXJOd4vE255O
# KJrnUWgHS3ipJrxn0CjkuVT8yN0T78oXR6pQUWCjMduMpAqXEqlAh1YEIfVWpnXv
# UXg/vte3MdnObowpVQwezBBtldqs2tP/Cu1gqL1AAJm1OJVfSjDnyR70w63ACqRh
# 2hogG5wKKmGBIzLnehUu0wB9nbhXzLzYljfNJnAu/I031eTjeqU0JLWbOK1XELZY
# Jv4HsNZz+bztN/XszfHo6U9WArUYslc8CYlywV+qQX7WZuNuxxHRlBlEME3lr6qL
# by8q5h0qQOygkYJ32oKDR1v60X10UlnudSI9Wlnsq6y24F3Koo0=
# =tk60
# -----END PGP SIGNATURE-----
# gpg: Signature made Tue Mar 10 05:53:53 2026 GMT
# gpg:                using RSA key 27B88847EEE0250118F3EAB92ED9D774FE702DB5
# gpg: Good signature from "Thomas Huth <[email protected]>" [full]
# gpg:                 aka "Thomas Huth <[email protected]>" [full]
# gpg:                 aka "Thomas Huth <[email protected]>" [full]
# gpg:                 aka "Thomas Huth <[email protected]>" [undefined]
# Primary key fingerprint: 27B8 8847 EEE0 2501 18F3  EAB9 2ED9 D774 FE70 2DB5

* tag 'pull-request-2026-03-10' of https://gitlab.com/thuth/qemu: (25 commits)
  pc-bios/s390-ccw.img: Update the s390 bios blog with the latest changes
  pc-bios/s390-ccw: Fix compiler warning when compiling with DEBUG enabled
  tests/qtest: Add s390x PCI boot test to cdrom-test.c
  hw: Add "loadparm" property to virtio block PCI devices booting on s390x
  s390x: Build IPLB for virtio-pci devices
  pc-bios/s390-ccw: Add support for virtio-blk-pci IPL
  pc-bios/s390-ccw: Introduce virtio-pci functions
  pc-bios/s390-ccw: Introduce PCI device
  s390x: Add definitions for PCI IPL type
  pc-bios/s390-ccw: Introduce CLP Architecture
  include/hw/s390x: Move CLP definitions for easier BIOS access
  pc-bios/s390-ccw: Split virtio-ccw and generic virtio
  pc-bios/s390-ccw: Store device type independent of sense data
  s390x: Remove duplicate definitions of IPL types
  pc-bios/s390-ccw: Always reset virtio device on failed boot attempt
  pc-bios/s390-ccw: Remove redundant vring schid attribute
  pc-bios/s390-ccw: Fix misattributed function prototypes
  tests/functional/ppc64/pseries: Remove custom migration routine
  tests/functional/migration: Use the migrate_vms helper
  tests/functional/migration: Add migrate_vms
  ...

Signed-off-by: Peter Maydell <[email protected]>
2026-03-10 11:39:08 +00:00
Peter Maydell 56fe2ca5b6 Merge tag 'staging-pull-request' of https://gitlab.com/peterx/qemu into staging
Memory pull for 11.0 softfreeze

- BALATON's memory cleanups on _nomigrate MRs and else
- Phil's small constify series and else
- Marc-André's initial cleanup patches around ram discard manager

# -----BEGIN PGP SIGNATURE-----
#
# iIgEABYKADAWIQS5GE3CDMRX2s990ak7X8zN86vXBgUCaa8v2xIccGV0ZXJ4QHJl
# ZGhhdC5jb20ACgkQO1/MzfOr1wbiNgD/ZLS5BtRGva5eUQNXKkE3oOiXfDBkLyQ1
# BowQ12zjPZMBAOxrVvyGbpgsI5SOcSjsvFSsWLs1GFfHjVUAyCNusl4D
# =+4wZ
# -----END PGP SIGNATURE-----
# gpg: Signature made Mon Mar  9 20:38:51 2026 GMT
# gpg:                using EDDSA key B9184DC20CC457DACF7DD1A93B5FCCCDF3ABD706
# gpg:                issuer "[email protected]"
# gpg: Good signature from "Peter Xu <[email protected]>" [marginal]
# gpg:                 aka "Peter Xu <[email protected]>" [marginal]
# gpg: WARNING: The key's User ID is not certified with sufficiently trusted signatures!
# gpg:          It is not certain that the signature belongs to the owner.
# Primary key fingerprint: B918 4DC2 0CC4 57DA CF7D  D1A9 3B5F CCCD F3AB D706

* tag 'staging-pull-request' of https://gitlab.com/peterx/qemu:
  system/memory: Have memory_region_type() correctly describe containers
  system/xen: Constify various MemoryRegion arguments
  system/memory: Constify various MemoryRegion arguments
  system/ramblock: Constify various RAMBlock arguments
  kvm: replace RamDicardManager by the RamBlockAttribute
  system/memory: minor doc fix
  virtio-mem: use warn_report_err_once()
  memory: drop RamDiscardListener::double_discard_supported
  system/rba: use DIV_ROUND_UP
  memory: Factor out common ram ptr initialization
  memory: Factor out common ram region initialization
  memory: Add internal memory_region_register_ram function
  memory: Shorten memory_region_init_ram_device_ptr and memory_region_init_rom_device
  memory: Remove memory_region_init_ram_nomigrate()
  hw/xtensa/xtfpga: Do not use memory_region_init_ram_nomigrate()
  sun4m,sun4u,tcx: Do not use memory_region_init_ram_nomigrate()
  memory: Remove memory_region_init_rom_nomigrate()
  hw/display/{cg3.tcx}: Do not use memory_region_init_rom_nomigrate()

Signed-off-by: Peter Maydell <[email protected]>
2026-03-10 11:38:58 +00:00
Hanna Czenczek 2224bff1ba iotests/308: Add multi-threading sanity test
Run qemu-img bench on a simple multi-threaded FUSE export to test that
it works.

Reviewed-by: Stefan Hajnoczi <[email protected]>
Signed-off-by: Hanna Czenczek <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Kevin Wolf <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
2026-03-10 12:12:05 +01:00
Hanna Czenczek 40ee2ff0ce qapi/block-export: Document FUSE's multi-threading
Document for users that FUSE's multi-threading implementation
distributes requests in a round-robin manner, regardless of where they
originate from.

As noted by Stefan, this will probably change with a FUSE-over-io_uring
implementation (which is supposed to have CPU affinity), but documenting
that is left for once that is done.

Suggested-by: Stefan Hajnoczi <[email protected]>
Acked-by: Markus Armbruster <[email protected]>
Signed-off-by: Hanna Czenczek <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Kevin Wolf <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
2026-03-10 12:12:04 +01:00
Hanna Czenczek b756692ce1 fuse: Implement multi-threading
FUSE allows creating multiple request queues by "cloning" /dev/fuse FDs
(via open("/dev/fuse") + ioctl(FUSE_DEV_IOC_CLONE)).

We can use this to implement multi-threading.

For configuration, we don't need any more information beyond the simple
array provided by the core block export interface: The FUSE kernel
driver feeds these FDs in a round-robin fashion, so all of them are
equivalent and we want to have exactly one per thread.

These are the benchmark results when using four threads (compared to a
single thread); note that fio still only uses a single job, but
performance can still be improved because of said round-robin usage for
the queues.  (Not in the sync case, though, in which case I guess it
just adds overhead.)

file:
  read:
    seq aio:   261.7k ±1.7k  (+168%)
    rand aio:  129.2k ±14.3k (+35%)
    seq sync:   36.6k ±0.6k  (+6%)
    rand sync:  10.1k ±0.1k  (+2%)
  write:
    seq aio:   235.7k ±2.8k  (+243%)
    rand aio:  232.0k ±6.7k  (+237%)
    seq sync:   31.7k ±0.6k  (+4%)
    rand sync:  31.8k ±0.5k  (+4%)
null:
  read:
    seq aio:   253.8k ±12.3k (+45%)
    rand aio:  248.2k ±12.0k (+45%)
    seq sync:   91.6k ±2.4k  (+12%)
    rand sync:  91.3k ±2.1k  (+17%)
  write:
    seq aio:   208.2k ±9.8k  (+6%)
    rand aio:  207.0k ±7.4k  (+8%)
    seq sync:   91.2k ±1.9k  (+9%)
    rand sync:  90.4k ±2.5k  (+14%)

So moderate improvements in most cases, but quite improved AIO
performance with an actual underlying file.

Here's results for numjobs=4:

"Before", i.e. without multithreading in QSD/FUSE (results compared to
numjobs=1):

file:
  read:
    seq aio:    85.5k ±0.4k (-13%)
    rand aio:   92.5k ±0.5k (-3%)
    seq sync:   54.5k ±9.1k (+58%)
    rand sync:  38.0k ±0.2k (+283%)
  write:
    seq aio:    67.3k ±0.3k (-2%)
    rand aio:   67.6k ±0.3k (-2%)
    seq sync:   69.3k ±0.5k (+126%)
    rand sync:  69.3k ±0.3k (+126%)
null:
  read:
    seq aio:   170.6k ±0.8k (-2%)
    rand aio:  170.9k ±0.9k (±0%)
    seq sync:  187.6k ±1.3k (+129%)
    rand sync: 188.9k ±0.9k (+142%)
  write:
    seq aio:   191.5k ±1.2k (-2%)
    rand aio:  193.8k ±1.4k (-1%)
    seq sync:  206.1k ±1.3k (+147%)
    rand sync: 206.1k ±1.2k (+159%)

As probably expected, little difference in the AIO case, but great
improvements in the sync cases because it kind of gives it an artificial
iodepth of 4.

"After", i.e. with four threads in QSD/FUSE (now results compared to the
above):

file:
  read:
    seq aio:   198.7k ±2.7k (+132%)
    rand aio:  317.3k ±0.6k (+243%)
    seq sync:   55.9k ±8.9k (+3%)
    rand sync:  39.1k ±0.0k (+3%)
  write:
    seq aio:   229.0k ±0.8k (+240%)
    rand aio:  227.0k ±1.3k (+235%)
    seq sync:  102.5k ±0.2k (+48%)
    rand sync: 101.7k ±0.2k (+47%)
null:
  read:
    seq aio:   584.0k ±1.5k (+242%)
    rand aio:  581.9k ±1.9k (+240%)
    seq sync:  270.6k ±0.9k (+44%)
    rand sync: 270.4k ±0.7k (+43%)
  write:
    seq aio:   598.4k ±2.0k (+212%)
    rand aio:  605.2k ±2.0k (+212%)
    seq sync:  274.0k ±0.8k (+33%)
    rand sync: 275.0k ±0.7k (+33%)

So this helps mainly for the AIO cases, but also in the null sync cases,
because null is always CPU-bound, so more threads help.

One unsolved mystery: When using a multithreaded export, running fio
with 1 job (benchmark at the top of this commit) yields better seqread
performance than doing so with 4 jobs.  Actually, with 4 jobs, it's
significantly than randread, which is quite strange.

Signed-off-by: Hanna Czenczek <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Kevin Wolf <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
2026-03-10 12:12:02 +01:00
Hanna Czenczek 7fe20a2fca fuse: Make shared export state atomic
The next commit is going to allow multi-threaded access to a FUSE
export.  In order to allow safe concurrent SETATTR operations that
can modify the shared st_mode, st_uid, and st_gid, make any access to
those fields atomic operations.

Signed-off-by: Hanna Czenczek <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Kevin Wolf <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
2026-03-10 12:12:01 +01:00
Hanna Czenczek 1a08957704 iotests/307: Test multi-thread export interface
Test the QAPI interface for multi-threaded exports.  None of our exports
currently support multi-threading, so it's always an error in the end,
but we can still test the specific errors.

Signed-off-by: Hanna Czenczek <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Kevin Wolf <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
2026-03-10 12:12:00 +01:00
Hanna Czenczek 277fc1ce18 block/export: Add multi-threading interface
Make BlockExportType.iothread an alternate between a single-thread
variant 'str' and a multi-threading variant '[str]'.

In contrast to the single-thread setting, the multi-threading setting
will not change the BDS's context (and so is incompatible with the
fixed-iothread setting), but instead just pass a list to the export
driver, with which it can do whatever it wants.

Currently no export driver supports multi-threading, so they all return
an error when receiving such a list.

Suggested-by: Kevin Wolf <[email protected]>
Acked-by: Markus Armbruster <[email protected]>
Reviewed-by: Stefan Hajnoczi <[email protected]>
Signed-off-by: Hanna Czenczek <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Kevin Wolf <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
2026-03-10 12:11:57 +01:00
Hanna Czenczek fb9427cc94 fuse: Process requests in coroutines
Make fuse_process_request() a coroutine_fn (fuse_co_process_request())
and have read_from_fuse_fd() launch it inside of a newly created
coroutine instead of running it synchronously.  This way, we can process
requests in parallel.

These are the benchmark results, compared to (a) the original results
with libfuse, and (b) the results after switching away from libfuse
(i.e. before this patch):

file:                (vs. libfuse / vs. no libfuse)
  read:
    seq aio:    97.8k ±1.5k (-2%  / -8%)
    rand aio:   95.8k ±3.4k (+90% / +98%)
    seq sync:   34.5k ±1.0k (-4%  / -3%)
    rand sync:   9.9k ±0.1k (-1%  / -1%)
  write:
    seq aio:    68.7k ±1.3k (-5%  / -10%)
    rand aio:   68.9k ±1.1k (-2%  / -10%)
    seq sync:   30.6k ±0.9k (±0%  / -3%)
    rand sync:  30.6k ±0.6k (+1%  / -1%)
null:
  read:
    seq aio:   174.5k ±6.8k (+11% / +8%)
    rand aio:  170.9k ±5.7k (+8%  / +3%)
    seq sync:   82.0k ±3.3k (+2%  / +2%)
    rand sync:  78.0k ±4.0k (+1%  / -1%)
  write:
    seq aio:   196.0k ±2.8k (+27% / +6%)
    rand aio:  191.2k ±7.9k (+24% / +2%)
    seq sync:   83.3k ±4.4k (+9%  / +1%)
    rand sync:  79.5k ±4.4k (+9%  / +1%)

So there is not much difference, especially when compared to how it was
with libfuse, except for the randread AIO case with an actual file.
That improves greatly.

Signed-off-by: Hanna Czenczek <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Kevin Wolf <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
2026-03-10 12:11:54 +01:00
Hanna Czenczek eae96caffc fuse: Reduce max read size
We are going to introduce parallel processing via coroutines, a maximum
read size of 64 MB may be problematic, allowing users of the export to
force us to allocate quite large amounts of memory with just a few
requests.

At least tone it down to 1 MB, which is still probably far more than
enough.  (Larger requests are split automatically by the FUSE kernel
driver anyway.)

(Yes, we inadvertently already had parallel request processing due to
nested polling before.  Better to fix this late than never.)

Reviewed-by: Stefan Hajnoczi <[email protected]>
Signed-off-by: Hanna Czenczek <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Kevin Wolf <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
2026-03-10 12:11:51 +01:00
Hanna Czenczek a94a1d7699 fuse: Manually process requests (without libfuse)
Manually read requests from the /dev/fuse FD and process them, without
using libfuse.  This allows us to safely add parallel request processing
in coroutines later, without having to worry about libfuse internals.
(Technically, we already have exactly that problem with
read_from_fuse_export()/read_from_fuse_fd() nesting.)

We will continue to use libfuse for mounting the filesystem; fusermount3
is a effectively a helper program of libfuse, so it should know best how
to interact with it.  (Doing it manually without libfuse, while doable,
is a bit of a pain, and it is not clear to me how stable the "protocol"
actually is.)

Take this opportunity of quite a major rewrite to update the Copyright
line with corrected information that has surfaced in the meantime.

Here are some benchmarks from before this patch (4k, iodepth=16, libaio;
except 'sync', which are iodepth=1 and pvsync2):

file:
  read:
    seq aio:    99.8k ±1.5k IOPS
    rand aio:   50.5k ±1.0k
    seq sync:   36.1k ±1.1k
    rand sync:  10.0k ±0.1k
  write:
    seq aio:    72.0k ±9.3k
    rand aio:   70.6k ±2.5k
    seq sync:   30.6k ±0.8k
    rand sync:  30.1k ±1.0k
null:
  read:
    seq aio:   157.9k ±4.7k
    rand aio:  158.7k ±4.8k
    seq sync:   80.2k ±2.8k
    rand sync:  77.5k ±3.8k
  write:
    seq aio:   154.3k ±3.6k
    rand aio:  154.3k ±4.2k
    seq sync:   76.1k ±5.2k
    rand sync:  72.9k ±4.0k

And with this patch applied:

file:
  read:
    seq aio:   106.8k ±1.9k (+7%)
    rand aio:   48.3k ±8.8k (-4%)
    seq sync:   35.5k ±1.4k (-2%)
    rand sync:  10.0k ±0.2k (±0%)
  write:
    seq aio:    76.3k ±6.6k (+6%)
    rand aio:   76.4k ±1.5k (+8%)
    seq sync:   31.6k ±0.6k (+3%)
    rand sync:  30.9k ±0.8k (+3%)
null:
  read:
    seq aio:   161.7k ±6.0k (+2%)
    rand aio:  165.6k ±7.1k (+4%)
    seq sync:   80.5k ±3.0k (±0%)
    rand sync:  78.5k ±3.1k (+1%)
  write:
    seq aio:   185.1k ±3.3k (+20%)
    rand aio:  186.7k ±4.8k (+21%)
    seq sync:   82.5k ±4.2k (+8%)
    rand sync:  78.7k ±3.2k (+8%)

So not much difference, aside from write AIO to a null-co export getting
a bit better.

Signed-off-by: Hanna Czenczek <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Kevin Wolf <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
2026-03-10 12:11:48 +01:00
Hanna Czenczek bea1163dec fuse: Drop permission changes in fuse_do_truncate
This function is always called with writable == true.  This makes
add_resize_perm always false, and thus we can drop the quite ugly
permission-changing code.

Signed-off-by: Hanna Czenczek <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Kevin Wolf <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
2026-03-10 12:11:45 +01:00
Hanna Czenczek 247fa896d5 block: Move qemu_fcntl_addfl() into osdep.c
Move file-posix's helper to add a flag (or a set of flags) to an FD's
existing set of flags into osdep.c for other places to use.

Suggested-by: Eric Blake <[email protected]>
Signed-off-by: Hanna Czenczek <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Kevin Wolf <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
2026-03-10 12:11:43 +01:00
Hanna Czenczek 4adf36d940 fuse: Explicitly handle non-grow post-EOF accesses
When reading to / writing from non-growable exports, we cap the I/O size
by `offset - blk_len`.  This will underflow for accesses that are
completely past the disk end.

Check and handle that case explicitly.

This is also enough to ensure that `offset + size` will not overflow;
blk_len is int64_t, offset is uint32_t, `offset < blk_len`, so from
`INT64_MAX + UINT32_MAX < UINT64_MAX` it follows that `offset + size`
cannot overflow.

Just one catch: We have to allow write accesses to growable exports past
the EOF, so then we cannot rely on `offset < blk_len`, but have to
verify explicitly that `offset + size` does not overflow.

The negative consequences of not having this commit are luckily limited
because blk_pread() and blk_pwrite() will reject post-EOF requests
anyway, so a `size` underflow post-EOF will just result in an I/O error.
So:
- Post-EOF reads will incorrectly result in I/O errors instead of just
  0-length reads.  We will also attempt to allocate a very large buffer,
  which is wrong and not good, but not terrible.
- Post-EOF writes on non-growable exports will result in I/O errors
  instead of 0-length writes (which generally indicate ENOSPC).
- Post-EOF writes on growable exports can theoretically overflow on EOF
  and truncate the export down to a much too small size, but in
  practice, FUSE will never send an offset greater than signed INT_MAX,
  preventing a uint64_t overflow.  (fuse_write_args_fill() in the kernel
  uses loff_t for the offset, which is signed.)

Signed-off-by: Hanna Czenczek <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Kevin Wolf <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
2026-03-10 12:11:42 +01:00
Hanna Czenczek e7b88252f3 iotests/308: Use conv=notrunc to test growability
Without conv=notrunc, dd will automatically truncate the output file to
the @seek value at least.  We want to test post-EOF I/O, not truncate,
so pass conv=notrunc.

(It does not make a difference in practice because we only seek to the
EOF, so the truncate effectively does nothing, but this is still
cleaner.)

Signed-off-by: Hanna Czenczek <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Kevin Wolf <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
2026-03-10 12:11:41 +01:00
Hanna Czenczek b22ff5ed6c fuse: fuse_{read,write}: Rename length to blk_len
The term "length" is ambiguous, use "blk_len" instead to be clear.

Signed-off-by: Hanna Czenczek <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Kevin Wolf <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
2026-03-10 12:11:39 +01:00
Hanna Czenczek 771b799bfb fuse: Add halted flag
This is a flag that we will want when processing FUSE requests
ourselves: When the kernel sends us e.g. a truncated request (i.e. we
receive less data than the request's indicated length), we cannot rely
on subsequent data to be valid.  Then, we are going to set this flag,
halting all FUSE request processing.

We plan to only use this flag in cases that would effectively be kernel
bugs.

While not necessary yet, access the flag atomically so that it will be
safe to use once we introduce multi-threading.

(Right now, the flag is unused because libfuse still does our request
processing.)

Signed-off-by: Hanna Czenczek <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Kevin Wolf <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
2026-03-10 12:11:38 +01:00
Hanna Czenczek 7e38c36558 fuse: Introduce fuse_{inc,dec}_in_flight()
This is how vduse-blk.c does it, and it does seem better to have
dedicated functions for it.

Reviewed-by: Stefan Hajnoczi <[email protected]>
Signed-off-by: Hanna Czenczek <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Kevin Wolf <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
2026-03-10 12:11:37 +01:00
Hanna Czenczek 4a8527e836 fuse: Introduce fuse_{at,de}tach_handlers()
Pull setting up and tearing down the AIO context handlers into two
dedicated functions.

Reviewed-by: Stefan Hajnoczi <[email protected]>
Signed-off-by: Hanna Czenczek <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Kevin Wolf <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
2026-03-10 12:11:36 +01:00
Hanna Czenczek 8599559580 fuse: Set direct_io and parallel_direct_writes
In fuse_open(), set these flags:
- direct_io: We probably actually don't want to have the host page cache
  be used for our exports.  QEMU block exports are supposed to represent
  the image as-is (and thus potentially changing).
  This causes a change in iotest 308's reference output.

- parallel_direct_writes: We can (now) cope with parallel writes, so we
  should set this flag.  For some reason, it doesn't seem to make an
  actual performance difference with libfuse, but it does make a
  difference without it, so let's set it.
  (See "fuse: Copy write buffer content before polling" for further
  discussion.)

Reviewed-by: Stefan Hajnoczi <[email protected]>
Signed-off-by: Hanna Czenczek <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Kevin Wolf <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
2026-03-10 12:11:35 +01:00
Hanna Czenczek c2959a8122 fuse: Fix mount options
Since I actually took a look into how mounting with libfuse works[1], I
now know that the FUSE mount options are not exactly standard mount
system call options.  Specifically:
- We should add "nosuid,nodev,noatime" because that is going to be
  translated into the respective MS_ mount flags; and those flags make
  sense for us.
- We can set rw/ro to make the mount writable or not.  It makes sense to
  set this flag to produce a better error message for read-only exports
  (EROFS instead of EACCES).
  This changes behavior as can be seen in iotest 308: It is no longer
  possible to modify metadata of read-only exports.
  Similarly, in fuse-allow-other, we must now make the export writable
  to use SETATTR.

In addition, in the comment, we can note that the FUSE mount() system
call actually expects some more parameters that we can omit because
fusermount3 (i.e. libfuse) will figure them out by itself:
- fd: /dev/fuse fd
- rootmode: Inode mode of the root node
- user_id/group_id: Mounter's UID/GID

[1] It invokes fusermount3, an SUID libfuse helper program, which parses
    and processes some mount options before actually invoking the
    mount() system call.

Reviewed-by: Stefan Hajnoczi <[email protected]>
Signed-off-by: Hanna Czenczek <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Kevin Wolf <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
2026-03-10 12:11:34 +01:00
Hanna Czenczek b8b054690c fuse: Destroy session on mount_fuse_export() fail
If mount_fuse_export() fails to mount the session, destroy it.
Depending on the allow_other configuration, fuse_export_create() may
retry this function on error, which may leak one session instance
otherwise.

Signed-off-by: Hanna Czenczek <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Kevin Wolf <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
2026-03-10 12:11:32 +01:00
Hanna Czenczek 52d50658c3 fuse: Change setup_... to mount_fuse_export()
There is no clear separation between what should go into
setup_fuse_export() and what should stay in fuse_export_create().

Make it clear that setup_fuse_export() is for mounting only.  Rename it,
and move everything that has nothing to do with mounting up into
fuse_export_create().

Reviewed-by: Stefan Hajnoczi <[email protected]>
Signed-off-by: Hanna Czenczek <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Kevin Wolf <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
2026-03-10 12:11:31 +01:00
Hanna Czenczek f4a0359e24 fuse: Explicitly set inode ID to 1
Setting .st_ino to the FUSE inode ID is kind of arbitrary.  While in
practice it is going to be fixed (to FUSE_ROOT_ID, which is 1) because
we only have the root inode, that is not obvious in fuse_getattr().

Just explicitly set it to 1 (i.e. no functional change).

Reviewed-by: Stefan Hajnoczi <[email protected]>
Signed-off-by: Hanna Czenczek <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Kevin Wolf <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
2026-03-10 12:11:30 +01:00
Hanna Czenczek 00945f6946 fuse: Remove superfluous empty line
Reviewed-by: Stefan Hajnoczi <[email protected]>
Signed-off-by: Hanna Czenczek <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Kevin Wolf <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
2026-03-10 12:11:29 +01:00
Hanna Czenczek 0cf42d8496 fuse: Ensure init clean-up even with error_fatal
When exports are created on the command line (with the storage daemon),
errp is going to point to error_fatal.  Without ERRP_GUARD, we would
exit immediately when *errp is set, i.e. skip the clean-up code under
the `fail` label.  Use ERRP_GUARD so we always run that code.

As far as I know, this has no actual impact right now[1], but it is
still better to make this right.

[1] Not cleaning up the mount point is the only thing I can imagine
    would be problematic, but that is the last thing we attempt, so if
    it fails, it will clean itself up.

Reviewed-by: Stefan Hajnoczi <[email protected]>
Signed-off-by: Hanna Czenczek <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Kevin Wolf <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
2026-03-10 12:11:26 +01:00
Hanna Czenczek a3fcbca0ef fuse: Copy write buffer content before polling
aio_poll() in I/O functions can lead to nested read_from_fuse_export()
calls, overwriting the request buffer's content.  The only function
affected by this is fuse_write(), which therefore must use a bounce
buffer or corruption may occur.

Note that in addition we do not know whether libfuse-internal structures
can cope with this nesting, and even if we did, we probably cannot rely
on it in the future.  This is the main reason why we want to remove
libfuse from the I/O path.

I do not have a good reproducer for this other than:

$ dd if=/dev/urandom of=image bs=1M count=4096
$ dd if=/dev/zero of=copy bs=1M count=4096
$ touch fuse-export
$ qemu-storage-daemon \
    --blockdev file,node-name=file,filename=copy \
    --export \
    fuse,id=exp,node-name=file,mountpoint=fuse-export,writable=true \
    &

Other shell:
$ qemu-img convert -p -n -f raw -O raw -t none image fuse-export
$ killall -SIGINT qemu-storage-daemon
$ qemu-img compare image copy
Content mismatch at offset 0!

(The -t none in qemu-img convert is important.)

I tried reproducing this with throttle and small aio_write requests from
another qemu-io instance, but for some reason all requests are perfectly
serialized then.

I think in theory we should get parallel writes only if we set
fi->parallel_direct_writes in fuse_open().  In fact, I can confirm that
if we do that, that throttle-based reproducer works (i.e. does get
parallel (nested) write requests).  I have no idea why we still get
parallel requests with qemu-img convert anyway.

Also, a later patch in this series will set fi->parallel_direct_writes
and note that it makes basically no difference when running fio on the
current libfuse-based version of our code.  It does make a difference
without libfuse.  So something quite fishy is going on.

I will try to investigate further what the root cause is, but I think
for now let's assume that calling blk_pwrite() can invalidate the buffer
contents through nested polling.

Cc: [email protected]
Reviewed-by: Kevin Wolf <[email protected]>
Signed-off-by: Hanna Czenczek <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Kevin Wolf <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
2026-03-10 12:11:16 +01:00
Philippe Mathieu-Daudé c574ff9245 accel/qtest: Build once as common object
No code within qtest.c uses target-specific knowledge:
build it once as target-agnostic common unit.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Message-Id: <[email protected]>
2026-03-10 11:36:21 +01:00
Philippe Mathieu-Daudé beaf63280a accel/xen: Build without target-specific knowledge
Code in accel/ aims to be target-agnostic. Enforce that
by moving the Xen file units to system_ss[], which is
target-agnostic.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Acked-by: Anthony PERARD <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <[email protected]>
2026-03-10 11:36:21 +01:00
Philippe Mathieu-Daudé 593063e4cb accel/hvf: Build without target-specific knowledge
Code in accel/ aims to be target-agnostic. Enforce that
by moving the HVF file units to system_ss[], which is
target-agnostic.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <[email protected]>
2026-03-10 11:36:21 +01:00
Philippe Mathieu-Daudé 35f797739b accel/mshv: Build without target-specific knowledge
Code in accel/ aims to be target-agnostic. Enforce that
by moving the MSHV file units to system_ss[], which is
target-agnostic.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <[email protected]>
2026-03-10 11:36:21 +01:00
Philippe Mathieu-Daudé 591357b68f accel/mshv: Forward-declare mshv_root_hvcall structure
Forward-declare the target-specific mshv_root_hvcall structure
in order to keep 'system/mshv_int.h' target-agnostic.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <[email protected]>
2026-03-10 11:36:21 +01:00
Philippe Mathieu-Daudé e78cc345db accel/stubs: Build stubs once
Move stubs to the global stub_ss[] source set. These files
are now built once for all binaries, instead of one time
per system binary.

Inspired-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <[email protected]>
2026-03-10 11:36:21 +01:00
Philippe Mathieu-Daudé 23e79ed4bf accel/kvm: Make kvm_irqchip*notifier() declaration non target-specific
Commit 3607715a30 ("kvm: Introduce KVM irqchip change notifier")
restricted the kvm_irqchip*notifier() declarations to target-specific
files, guarding them under the NEED_CPU_H (later renamed as
COMPILING_PER_TARGET) #ifdef check.

This however prohibit building the kvm-stub.c file once:

  ../accel/stubs/kvm-stub.c:70:6: error: no previous prototype for function 'kvm_irqchip_add_change_notifier' [-Werror,-Wmissing-prototypes]
     70 | void kvm_irqchip_add_change_notifier(Notifier *n)
        |      ^
  ../accel/stubs/kvm-stub.c:74:6: error: no previous prototype for function 'kvm_irqchip_remove_change_notifier' [-Werror,-Wmissing-prototypes]
     74 | void kvm_irqchip_remove_change_notifier(Notifier *n)
        |      ^
  ../accel/stubs/kvm-stub.c:78:6: error: no previous prototype for function 'kvm_irqchip_change_notify' [-Werror,-Wmissing-prototypes]
     78 | void kvm_irqchip_change_notify(void)
        |      ^

Since nothing in these prototype declarations is target specific,
move them around to be generically available, allowing to build
kvm-stub.c once for all targets in the next commit.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Message-Id: <[email protected]>
2026-03-10 11:36:21 +01:00
Philippe Mathieu-Daudé 43f507555d accel/kvm: Include missing 'exec/cpu-common.h' header
kvm-accel-ops.c uses EXCP_DEBUG, itself defined in
"exec/cpu-common.h". Include it explicitly, otherwise
we get when modifying unrelated headers:

  ../accel/kvm/kvm-accel-ops.c: In function ‘kvm_vcpu_thread_fn’:
  ../accel/kvm/kvm-accel-ops.c:54:22: error: ‘EXCP_DEBUG’ undeclared (first use in this function)
     54 |             if (r == EXCP_DEBUG) {
        |                      ^~~~~~~~~~

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <[email protected]>
2026-03-10 11:36:21 +01:00
Philippe Mathieu-Daudé 784d12cada target/hppa: Expand tcg_global_mem_new() -> tcg_global_mem_new_i64()
The HPPA target is a 64-bit one, so tcg_global_mem_new()
expands to tcg_global_mem_new_i64(). Use the latter which
is more explicit.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <[email protected]>
2026-03-10 11:36:21 +01:00
Richard Henderson 744eb39667 tcg/optimize: possibly expand deposit into zero with shifts
Use tcg_op_imm_match to choose between expanding with AND+SHL vs SHL+SHR.

Suggested-by: Paolo Bonzini <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-10 11:36:21 +01:00
Paolo Bonzini bfe9264835 tcg: target-dependent lowering of extract to shr/and
Instead of assuming only small immediates are available for AND,
consult the backend in order to decide between SHL/SHR and SHR/AND.

Reviewed-by: Jim MacArthur <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
[rth: Split from a larger patch]
Signed-off-by: Richard Henderson <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-10 11:36:21 +01:00
Paolo Bonzini bb5b6bbb10 tcg: Add tcg_op_imm_match
Create a function to test whether the second operand of a
binary operation allows a given immediate.

Reviewed-by: Jim MacArthur <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
[rth: Split out from a larger patch; keep the declaration internal.]
Signed-off-by: Richard Henderson <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-10 11:36:21 +01:00
Richard Henderson 6cced95c28 tcg: Expand missing rotri with extract2
Use extract2 to implement rotri.  To make this easier,
redefine rotli in terms of rotri, rather than the reverse.

Reviewed-by: Jim MacArthur <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-10 11:36:21 +01:00
Richard Henderson e4cebfc664 tcg/optimize: Lower unsupported extract2 during optimize
The expansions that we chose in tcg-op.c may be less than optimal.
Delay lowering until optimize, so that we have propagated constants
and have computed known zero/one masks.

Reviewed-by: Jim MacArthur <[email protected]>
Reviewed-by: Manos Pitsidianakis <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-10 11:36:21 +01:00
Richard Henderson 5f747705a4 tcg/optimize: Lower unsupported deposit during optimize
The expansions that we chose in tcg-op.c may be less than optimal.
Delay lowering until optimize, so that we have propagated constants
and have computed known zero/one masks.

Reviewed-by: Jim MacArthur <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-10 11:36:21 +01:00
Richard Henderson c1d5ef32e7 tcg: Drop extract+shl expansions in tcg_gen_deposit_z_*
The extract+shl expansion is handled in tcg_gen_andi_*
by preferring supported extract.

The shl+extract expansion is simply removed for now; it was
only present for slightly smaller code generation on x86.

Signed-off-by: Richard Henderson <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-10 11:36:21 +01:00
Peter Maydell 63ec1f7694 Merge tag 'python-pull-request' of https://gitlab.com/jsnow/qemu into staging
Python pullreq

Drop avocado, support Python3.14. Fixes optional check-python-tox GitLab
CI test.

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCgAdFiEE+ber27ys35W+dsvQfe+BBqr8OQ4FAmmvC+sACgkQfe+BBqr8
# OQ7jpA//X6N9Jql+GthF7H51lHvF5parKCP1rum16H9e0JSi+Q5fGjqk6QURGBup
# QkKEYG01gwMrH0RozufPRbSkcV8Tx0/qVZPG/cXr6sd2eNAZK6eWhf5ndMiU84+P
# XWiKxYx7EqEMpdHH8m47oI1ZW0l3KddRHDLDw/m7IeHp57yj3aFsvtCFzw1Gjzgr
# HKA2iSB1gQZj0Co3SqcYvNPcbiEhcDxjHl9FdhJVWn+t5vgNRmche5U3x5w41VXr
# RrWqEcvIj1DhEN6JQud7EJq1HfFb3woj6B1Rv8DXDOZJWsnZqXbh79v9a3riM+LN
# poYvjdGVnTLOCHy3mBLIf7Iimbk405qOq38ooq1eRbEYIg8J6khCFdPdTN6iCpuK
# NgaOTTtaXG1fNLLJlRQaTLe2vxKlTSR+X50z4TvSMB9IdJHmlQEE4NHzVBgGLJ9N
# rIS5TxB48mp12hzjDpp5l0vBXifNhkSwuqaCADAp5ei8m92sQlNpYsMWUNPzyLVt
# B24/axpbhn8b8QIf4Kraz2wFjUL5AZFWFYdncmG0FCsx/hbZfnMhmm0OvoBbrxtM
# +riMNiu1d6UZuOtailyDP4BIm1yzRlvFlSxNNKj7e3tTsQmxbJgc0Fbj8XQ1jvxs
# W0Sc9Gq+W4+Gj4hMdLrMfA/1Fqmv+/nSkmN4HRaDDNm4z4PwFgk=
# =D7N4
# -----END PGP SIGNATURE-----
# gpg: Signature made Mon Mar  9 18:05:31 2026 GMT
# gpg:                using RSA key F9B7ABDBBCACDF95BE76CBD07DEF8106AAFC390E
# gpg: Good signature from "John Snow (John Huston) <[email protected]>" [full]
# Primary key fingerprint: FAEB 9711 A12C F475 812F  18F2 88A9 064D 1835 61EB
#      Subkey fingerprint: F9B7 ABDB BCAC DF95 BE76  CBD0 7DEF 8106 AAFC 390E

* tag 'python-pull-request' of https://gitlab.com/jsnow/qemu:
  python: add formal python3.14 support and testing
  python: drop avocado
  python: replace avocado tests with pytest
  python: pin 'wheel' version in minreqs test

Signed-off-by: Peter Maydell <[email protected]>
2026-03-10 09:32:50 +00:00
Peter Maydell be7f1c297c Merge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging
* hvf/x86: compilation fixes
* whpx: fixes
* xen-block: fix possible NULL pointer dereference
* coroutine-lock: fix thinko

# -----BEGIN PGP SIGNATURE-----
#
# iQFIBAABCgAyFiEE8TM4V0tmI4mGbHaCv/vSX3jHroMFAmmugQwUHHBib256aW5p
# QHJlZGhhdC5jb20ACgkQv/vSX3jHroOOpQf/euE88TGF71S3kW4ckqCN4hLlvpl8
# 7wHjj83ggzufJikx5UI1lw31UuqyZYDX5ICQnvNeVEvBqCpi8oo9SJMBIwXJxn45
# 3oolIy+TJ7/k+QjZ1kMLPubnbH7p5h/iix+IkU01gFS0F0S12LgiJcLpBsSkKZHK
# 5AK53dKBAEikPP+IIT8Y4RrzNOZrydZzaXAtU4eCi3YVxf7/Ld1w9nRGvfG07Zd6
# Y0TptxjfMzbhxLuKetaHrAEI8EYYsmLAE3uJaDMSZ6heCXtfwQjkOaFjaqE/OYOK
# NhtIFArkq+tneI3sqDEoIdMngkL6SEowi1uDAOc5vKmtb2JcWzNo9PsXJw==
# =3X24
# -----END PGP SIGNATURE-----
# gpg: Signature made Mon Mar  9 08:13:00 2026 GMT
# gpg:                using RSA key F13338574B662389866C7682BFFBD25F78C7AE83
# gpg:                issuer "[email protected]"
# gpg: Good signature from "Paolo Bonzini <[email protected]>" [full]
# gpg:                 aka "Paolo Bonzini <[email protected]>" [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:
  whpx: i386: remove SIPI trapping
  whpx: arm64: enable enlightenments if asked for
  whpx: make Hyper-V enlightenments configurable
  whpx: i386: enable some more enlightenments
  target/i386: emulate: LA57 fix
  whpx: i386: do not enable nested virt when kernel-irqchip=off
  hvf: arm: unbreak the x86 build
  target/i386/hvf/hvf.c: fix compilation
  qemu-coroutine-lock: fix has_waiters()
  xen-block: remove NULL pointer dereference

Signed-off-by: Peter Maydell <[email protected]>
2026-03-10 09:32:17 +00:00
Luigi Leonardi 5c45204e34 igvm: fix build when igvm is not installed in a well known path
`stubs/igvm.c` includes `igvm-internal.h`, that in turn includes the igvm library.
This is required just for the QIgvm declaration and creates an
unnecessary dependency on the library.

Since igvm is not listed as a dependency of stubs, this results in build
failing when the library is not installed in a "well known" path of the
system.

Add a forward declaration for QIgvm and move the definition of
`qigvm_directive_madt` to `igvm.h` so that we can drop `igvm-internal.h` from
`stubs/igvm.c`.

Fixes: dea1f68a5c ("igvm: Fill MADT IGVM parameter field on x86_64")
Suggested-by: Stefano Garzarella <[email protected]>
Signed-off-by: Luigi Leonardi <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Gerd Hoffmann <[email protected]>
2026-03-10 08:57:05 +01:00
Oliver Steffen c221dd7746 docs/interop: Add AMD SEV-SNP SVSM interface to firmware.json
AMD SEV-SNP defines a guest to Secure VM Service Module (SVSM) firmware
[1] interface. Add a corresponding item to the FirmwareOSInterface
enum.

[1]
https://docs.amd.com/api/khub/documents/Al5Q~fSl~kWKkJ3zC0vk_g/content

Signed-off-by: Oliver Steffen <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Gerd Hoffmann <[email protected]>
2026-03-10 08:44:49 +01:00
Thomas Huth f2bd9693f2 pc-bios/s390-ccw.img: Update the s390 bios blog with the latest changes
- Make sure the reset virtio devices on failed boot attempts
- Add support for booting via virtio-blk-pci

Signed-off-by: Thomas Huth <[email protected]>
2026-03-10 06:46:45 +01:00
Thomas Huth 14c29f2906 pc-bios/s390-ccw: Fix compiler warning when compiling with DEBUG enabled
When compiling with DEBUG=1, there is currently a compiler warning:

 pc-bios/s390-ccw: Compiling main.o
 In file included from /home/thuth/devel/qemu/pc-bios/s390-ccw/main.c:14:
 In file included from /home/thuth/devel/qemu/pc-bios/s390-ccw/helper.h:16:
 /home/thuth/devel/qemu/pc-bios/s390-ccw/s390-ccw.h:122:31: warning: format specifies type
       'unsigned int' but the argument has type 'u64' (aka 'unsigned long long') [-Wformat]
   122 |     printf("%s 0x%X\n", desc, addr);
       |                  ~~           ^~~~
       |                  %llX
 1 warning generated.

Fix it by using the right format string here.

Message-ID: <[email protected]>
Reviewed-by: Farhan Ali<[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
2026-03-10 06:46:45 +01:00
Jared Rossi 98c93dfec1 tests/qtest: Add s390x PCI boot test to cdrom-test.c
Add a rudimentary test for s390x IPL to verify that a guest may boot using
virtio-blk-pci device.

Reviewed-by: Thomas Huth <[email protected]>
Signed-off-by: Jared Rossi <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
2026-03-10 06:46:45 +01:00
Jared Rossi c77da4c0d6 hw: Add "loadparm" property to virtio block PCI devices booting on s390x
The loadparm is required on s390x to pass the information to the boot loader
such as which kernel should be started or whether the boot menu should be shown.

Because PCI devices do not naturally allocate space for this, the property is
added on an architecture specific basis for supported device types.

Reviewed-by: Thomas Huth <[email protected]>
Signed-off-by: Jared Rossi <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
2026-03-10 06:46:45 +01:00
Jared Rossi 395116781d s390x: Build IPLB for virtio-pci devices
Search for a corresponding S390PCIBusDevice and build an IPLB if a device has
been indexed for boot but does not identify as a CCW device,

PCI devices are not yet included in boot probing (they must have a boot index).

Reviewed-by: Thomas Huth <[email protected]>
Reviewed-by: Eric Farman <[email protected]>
Signed-off-by: Jared Rossi <[email protected]>
Message-ID: <[email protected]>
[thuth: Fix endianness issue when running on a little endian host]
Signed-off-by: Thomas Huth <[email protected]>
2026-03-10 06:46:45 +01:00
Jared Rossi d72fb5e6b2 pc-bios/s390-ccw: Add support for virtio-blk-pci IPL
Add little-endian virt-queue configuration and support for virtio-blk-pci IPL
devices.

Reviewed-by: Eric Farman <[email protected]>
Signed-off-by: Jared Rossi <[email protected]>
Message-ID: <[email protected]>
[thuth: Fix coding style error & spelling warning reported by checkpatch.pl]
Signed-off-by: Thomas Huth <[email protected]>
2026-03-10 06:46:45 +01:00
Jared Rossi 40d80aedd5 pc-bios/s390-ccw: Introduce virtio-pci functions
Define common functionality for interacting with virtio-pci devices.

Signed-off-by: Jared Rossi <[email protected]>
Acked-by: Matthew Rosato <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Reviewed-by: Eric Farman <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
2026-03-10 06:46:45 +01:00
Jared Rossi 5ed17bb32a pc-bios/s390-ccw: Introduce PCI device
Define selected s390x PCI instructions.

Signed-off-by: Jared Rossi <[email protected]>
Reviewed-by: Matthew Rosato <[email protected]>
Acked-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Farhan Ali <[email protected]>
[thuth: Remove unused defines as suggested by Farhan]
Signed-off-by: Thomas Huth <[email protected]>
2026-03-10 06:46:45 +01:00
Jared Rossi 284a595c47 s390x: Add definitions for PCI IPL type
Define a new PBT code and IPLB layout in preparation for supporting PCI device
IPL on s390x.

Reviewed-by: Thomas Huth <[email protected]>
Reviewed-by: Eric Farman <[email protected]>
Signed-off-by: Jared Rossi <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
2026-03-10 06:46:45 +01:00
Jared Rossi d3da8afd1d pc-bios/s390-ccw: Introduce CLP Architecture
Call Logical Processor (CLP) Architecture is used for managing PCI functions on
s390x. Define and include the structures and routines needed to interact with
PCI devices during IPL.

Reviewed-by: Eric Farman <[email protected]>
Signed-off-by: Jared Rossi <[email protected]>
Reviewed-by: Matthew Rosato <[email protected]>
Reviewed-by: Farhan Ali <[email protected]>
Message-ID: <[email protected]>
[thuth: fix a typo in one of the comments]
Signed-off-by: Thomas Huth <[email protected]>
2026-03-10 06:46:11 +01:00
Jared Rossi fa8d22f628 include/hw/s390x: Move CLP definitions for easier BIOS access
Move the s390-pci-clp definitions into the "ipl" sub-directory, which is visible
to the s390-bios.  This allows the bios to reuse the architected definitions and
prevents code duplication.

Reviewed-by: Thomas Huth <[email protected]>
Reviewed-by: Eric Farman <[email protected]>
Reviewed-by: Matthew Rosato <[email protected]>
Signed-off-by: Jared Rossi <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
2026-03-10 06:36:01 +01:00
Jared Rossi 4ff1499ada pc-bios/s390-ccw: Split virtio-ccw and generic virtio
Separate the CCW specific virtio routines and create generic wrappers for easier
reuse of existing virtio functions with non-CCW devices.

Reviewed-by: Thomas Huth <[email protected]>
Reviewed-by: Eric Farman <[email protected]>
Signed-off-by: Jared Rossi <[email protected]>
Message-ID: <[email protected]>
[thuth: Use SPDX license identifier in virtio-ccw.c]
Signed-off-by: Thomas Huth <[email protected]>
2026-03-10 06:35:21 +01:00
Jared Rossi ada7a60056 pc-bios/s390-ccw: Store device type independent of sense data
Store the device type (e.g. block) directly as an attribute of the VDev rather
than assume all devices can be identified by accessing CCW specific sense data.

Reviewed-by: Thomas Huth <[email protected]>
Reviewed-by: Farhan Ali <[email protected]>
Signed-off-by: Jared Rossi <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
2026-03-10 06:18:53 +01:00
Jared Rossi 4228a92b2a s390x: Remove duplicate definitions of IPL types
Remove the duplicate definitions from hw/s390x/ipl.h and pc-bios/s390-ccw/iplb.h
and add a shared definition.  The new definition is an enum to enforce default
handling in switches.

Because the IPL type is determined by the IPLB, and because an IPLB is not
strictly necessary, the IPL type is set to a default value if not otherwise
specified.  A default IPL type is required so future functionality may add
IPL new bus and/or device types that dictate specific behavior during IPL.

Reviewed-by: Thomas Huth <[email protected]>
Signed-off-by: Jared Rossi <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
2026-03-10 06:18:53 +01:00
Jared Rossi dd8c8f16c0 pc-bios/s390-ccw: Always reset virtio device on failed boot attempt
The virtio spec necessitates that live virtqueues must not be altered.  Reset
the failed device so that the queues are not live before we attempt to boot any
fallback devices.

Reviewed-by: Thomas Huth <[email protected]>
Reviewed-by: Eric Farman <[email protected]>
Signed-off-by: Jared Rossi <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
2026-03-10 06:18:53 +01:00
Jared Rossi 5dbabcfee8 pc-bios/s390-ccw: Remove redundant vring schid attribute
The schid is already stored as an attribute of the VDev itself and any other
instances are copies of this same value.  To avoid CCW specific attributes in
the VRing let's just access the existing VDev schid attribute as needed.

Reviewed-by: Thomas Huth <[email protected]>
Reviewed-by: Eric Farman <[email protected]>
Reviewed-by: Farhan Ali <[email protected]>
Signed-off-by: Jared Rossi <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
2026-03-10 06:18:53 +01:00
Jared Rossi 1ef532cbcf pc-bios/s390-ccw: Fix misattributed function prototypes
The virtio-blkdev functions are incorrectly listed in s390-ccw.h as belonging to
virtio.c.  Additionally, virtio_load_direct() has an unused subchan_id argument.

Remove the unused argument and move the prototypes to virtio.h so that they are
independent from the CCW bus.

Reviewed-by: Thomas Huth <[email protected]>
Reviewed-by: Eric Farman <[email protected]>
Reviewed-by: Farhan Ali <[email protected]>
Signed-off-by: Jared Rossi <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
2026-03-10 06:18:53 +01:00
Fabiano Rosas 502357bbcb tests/functional/ppc64/pseries: Remove custom migration routine
Don't implement a custom migration routine at PpcMigrationTest and
instead reuse the generic one from MigrationTest.

This removes the dependency of PpcMigrationTest from
PseriesMachine. Having one test import another causes unittest code to
instantiate the imported test, resulting in the setup and teardown
methods being invoked for the imported test class, even if no test
from that class will be executed.

If run in parallel, the extra setup/teardown methods that result from
importing can race with the ones from the actual test being executed
and cause the following error:

File "<SRC_DIR>/tests/functional/qemu_test/testcase.py", line 238, in tearDown
shutil.rmtree(self.workdir)
...
FileNotFoundError: [Errno 2] No such file or directory:
'<SRC_DIR>/build/tests/functional/ppc64/.../test_migration_with_exec/scratch'

The PseriesMachine class is changed to inherit from MigrationTest so
both the migration routines and the class attributes of PseriesMachine
can be accessed without the need to instantiate another object.

Fixes: f4e34d0fd5 ("tests/functional: Add a OS level migration test for pseries")
Reported-by: Aditya Gupta <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Signed-off-by: Fabiano Rosas <[email protected]>
Reviewed-by: Peter Xu <[email protected]>
Tested-by: Aditya Gupta <[email protected]>
Message-ID: <[email protected]>
[thuth: Remove superfluous ";" as suggested by Aditya]
Signed-off-by: Thomas Huth <[email protected]>
2026-03-10 06:18:53 +01:00
Fabiano Rosas 4a2476634a tests/functional/migration: Use the migrate_vms helper
Change do_migrate() to call the migrate_vms() helper and provide it
with the two VMs already created. Rename do_migrate -> migrate and
adjust the callers.

While here, standardize on the "src" and "dst" names.

Reviewed-by: Thomas Huth <[email protected]>
Reviewed-by: Peter Xu <[email protected]>
Signed-off-by: Fabiano Rosas <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
2026-03-10 06:18:53 +01:00
Fabiano Rosas b47715e3ae tests/functional/migration: Add migrate_vms
Add a migration helper to MigrationTest that uses the migrate-incoming
QMP command and takes the already instantiated VMs. The -incoming
'defer' command line option is preferred way instead of the -incoming
URI syntax that's currently used.

Suggested-by: Peter Xu <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Reviewed-by: Peter Xu <[email protected]>
Signed-off-by: Fabiano Rosas <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
2026-03-10 06:18:42 +01:00
Fabiano Rosas 47d8d1e9c4 tests/functional/migration: Use socket_dir
Use QemuBaseTest.socket_dir instead of calling tempfile directly so
all tests have consistent directory prefixes.

Suggested-by: Daniel P. Berrangé <[email protected]>
Reviewed-by: Peter Xu <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Signed-off-by: Fabiano Rosas <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
2026-03-10 06:12:17 +01:00
Peter Maydell 558e1d7a15 tests/functional/x86_64: Disable memlock test for asan builds
The address-sanitizer intercepts mlock() and makes it a no-op,
because it interacts badly with the sanitizer's own use of large
amounts of memory.  This means that our 'memlock' test will always
fail, because it checks via /proc for whether the QEMU process really
locked some pages.  Don't add the test when QEMU is built with asan.

Suggested-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
2026-03-10 06:12:17 +01:00
Thomas Huth 5f9b7bbf3e tests/functional/ppc/test_40: Fix the URL of the NetBSD-7.1.2-prep.iso asset
We now need a slightly different URL to be able to download this asset.

Suggested-by: Reinoud Zandijk <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
2026-03-10 06:12:17 +01:00
Thomas Huth d904bd8ad0 tests/functional: Don't try to run functional tests on Windows
They just don't work there yet, so don't try to run them there
(these need some development work from a Windows wizard first).

Signed-off-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
2026-03-10 06:12:17 +01:00
Thomas Huth 545214fa64 tests/qemu-iotests: Mark 182 as Linux-only
Running test 182 on FreeBSD fails with this error message in the output:

 +warning: File lock requested but OFD locking syscall is unavailable, falling back to POSIX file locks
 +Due to the implementation, locks can be lost unexpectedly.

OFD locks seem to be only available on Linux, so let's mark this
test as Linux-only to silence the failure.

Reviewed-by: Daniel P. Berrangé <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
2026-03-10 06:12:17 +01:00
Philippe Mathieu-Daudé 40aa899d03 system/memory: Have memory_region_type() correctly describe containers
MemoryRegion containers are not I/O regions,
describe them as 'container'.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Peter Xu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Peter Xu <[email protected]>
2026-03-09 15:27:26 -04:00
Philippe Mathieu-Daudé 5eedbf49b9 system/xen: Constify various MemoryRegion arguments
Mark the MemoryRegion structure const when is only accessed read-only.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Peter Xu <[email protected]>
2026-03-09 15:27:26 -04:00
Philippe Mathieu-Daudé 5a525dcb4d system/memory: Constify various MemoryRegion arguments
Mark the MemoryRegion structure const when is only accessed read-only.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Peter Xu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Peter Xu <[email protected]>
2026-03-09 15:27:26 -04:00
Philippe Mathieu-Daudé f016021ff5 system/ramblock: Constify various RAMBlock arguments
Mark the RAMBlock structure const when is only accessed read-only.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Peter Xu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Peter Xu <[email protected]>
2026-03-09 15:27:25 -04:00
Marc-André Lureau 554671c1ec kvm: replace RamDicardManager by the RamBlockAttribute
No need to cast through the RamDiscardManager interface, use the
RamBlock already retrieved. Makes it more direct and readable, and allow
further refactoring to make RamDiscardManager an aggregator object in
the following patches.

Signed-off-by: Marc-André Lureau <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Reviewed-by: Chenyi Qiang <[email protected]>
Reviewed-by: Peter Xu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Peter Xu <[email protected]>
2026-03-09 14:06:30 -04:00
Marc-André Lureau 4264005cd4 system/memory: minor doc fix
Signed-off-by: Marc-André Lureau <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Reviewed-by: Peter Xu <[email protected]>
Reviewed-by: David Hildenbrand (Arm) <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Peter Xu <[email protected]>
2026-03-09 14:06:30 -04:00
Marc-André Lureau 07a965e6b7 virtio-mem: use warn_report_err_once()
Signed-off-by: Marc-André Lureau <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Reviewed-by: Peter Xu <[email protected]>
Acked-by: David Hildenbrand (Arm) <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Peter Xu <[email protected]>
2026-03-09 14:06:30 -04:00
Marc-André Lureau d3008f2e52 memory: drop RamDiscardListener::double_discard_supported
This was never turned off, effectively some dead code.

Signed-off-by: Marc-André Lureau <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Reviewed-by: Peter Xu <[email protected]>
Acked-by: David Hildenbrand (Arm) <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Peter Xu <[email protected]>
2026-03-09 14:06:30 -04:00
Marc-André Lureau 0a6830e68f system/rba: use DIV_ROUND_UP
Mostly for readability.

Signed-off-by: Marc-André Lureau <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Reviewed-by: Peter Xu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Peter Xu <[email protected]>
2026-03-09 14:06:30 -04:00
BALATON Zoltan 7f116e951d memory: Factor out common ram ptr initialization
Introduce internal helper function to remove duplicated code from
different memory_region_init_ram_*ptr functions.

Signed-off-by: BALATON Zoltan <[email protected]>
Link: https://lore.kernel.org/r/7c5a31fc2202e6927437ed57cb9ce08a224f2a50.1772924151.git.balaton@eik.bme.hu
Signed-off-by: Peter Xu <[email protected]>
2026-03-09 14:05:55 -04:00
BALATON Zoltan 2fb627ef2f memory: Factor out common ram region initialization
Introduce internal helper function to remove duplicated code from
different memory_region_init_*ram functions. Remove local err and
error_propagate and pass errp and check return value instead.
Also shorten some function prototypes while at it.

Signed-off-by: BALATON Zoltan <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Link: https://lore.kernel.org/r/d6db01c283149b46023ffeb9c5b368c67f6acc8d.1772924151.git.balaton@eik.bme.hu
Signed-off-by: Peter Xu <[email protected]>
2026-03-09 14:05:55 -04:00
BALATON Zoltan f0eca07fbd memory: Add internal memory_region_register_ram function
Factor out common operation from memory_region_init_{ram,rom}
functions to register the region for migration. This avoids
duplicating the long comment in several functions.

Signed-off-by: BALATON Zoltan <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Link: https://lore.kernel.org/r/1f0bcb38e59456aa910376df6a375d63c2f3f442.1772924151.git.balaton@eik.bme.hu
Signed-off-by: Peter Xu <[email protected]>
2026-03-09 14:05:55 -04:00
BALATON Zoltan 8fe668d0b4 memory: Shorten memory_region_init_ram_device_ptr and memory_region_init_rom_device
We can reuse memory_region_init_io in these functions.

Signed-off-by: BALATON Zoltan <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Link: https://lore.kernel.org/r/79ff00abd2eb5c304f1f00664c94784e1269d984.1772924151.git.balaton@eik.bme.hu
Signed-off-by: Peter Xu <[email protected]>
2026-03-09 14:05:55 -04:00
BALATON Zoltan 787495878f memory: Remove memory_region_init_ram_nomigrate()
Convert the last remaining use outside of memory.c in vga to use
memory_region_init_ram_flags_nomigrate() instead and inline and remove
the memory_region_init_ram_nomigrate() variant. This leaves
memory_region_init_ram_flags_nomigrate() as the only nomigrate variant
that is still needed at a few places.

Signed-off-by: BALATON Zoltan <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Link: https://lore.kernel.org/r/d913d0694b792bc3aed3fbb432e63d00c556de39.1772924151.git.balaton@eik.bme.hu
Signed-off-by: Peter Xu <[email protected]>
2026-03-09 14:05:55 -04:00
BALATON Zoltan ac042f93e3 hw/xtensa/xtfpga: Do not use memory_region_init_ram_nomigrate()
Convert to use memory_region_init_ram() instead. This breaks migration
but the machines using this device have no migration compatibility
guarantee.

Signed-off-by: BALATON Zoltan <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Link: https://lore.kernel.org/r/0a57625ac909c2b005302b9136920cb917427a8b.1772924151.git.balaton@eik.bme.hu
Signed-off-by: Peter Xu <[email protected]>
2026-03-09 14:05:55 -04:00
BALATON Zoltan 945f3573dd sun4m,sun4u,tcx: Do not use memory_region_init_ram_nomigrate()
Convert to use memory_region_init_{ram,rom} instead. This breaks
migration but these machines have no migration compatibility guarantee
and this removes most remaining usages of this nomigrate variant.

Signed-off-by: BALATON Zoltan <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Link: https://lore.kernel.org/r/1d0f04534af14598f5c6b8c6922e3f10d8bb18cf.1772924151.git.balaton@eik.bme.hu
Signed-off-by: Peter Xu <[email protected]>
2026-03-09 14:05:55 -04:00
BALATON Zoltan 0f32940510 memory: Remove memory_region_init_rom_nomigrate()
All users were converted so no longer needed.

Signed-off-by: BALATON Zoltan <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Link: https://lore.kernel.org/r/2665c92b578f5f6a602b34c7dde73451773e6148.1772924151.git.balaton@eik.bme.hu
Signed-off-by: Peter Xu <[email protected]>
2026-03-09 14:05:55 -04:00
BALATON Zoltan 653c4fa5b0 hw/display/{cg3.tcx}: Do not use memory_region_init_rom_nomigrate()
Use memory_region_init_rom() instead which is what other devices do.
This breaks migration but these devices are only used by sparc Sun
machines which have no migration compatibility guarantee.

Signed-off-by: BALATON Zoltan <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Link: https://lore.kernel.org/r/819df754e359b024bc9bf8f971ecd26816552559.1772924151.git.balaton@eik.bme.hu
Signed-off-by: Peter Xu <[email protected]>
2026-03-09 14:05:55 -04:00
John Snow 191d4ceb40 python: add formal python3.14 support and testing
Reviewed-by: Daniel P. Berrangé <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: John Snow <[email protected]>
2026-03-09 14:04:25 -04:00
John Snow d4ae1c7072 python: drop avocado
Avocado-framework is no longer used for anything, so it can be removed.

Reviewed-by: Daniel P. Berrangé <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: John Snow <[email protected]>
2026-03-09 14:04:19 -04:00
John Snow d5c6eef38e python: replace avocado tests with pytest
Following suit with the rest of this repository, drop avocado and
replace it with the Python standard "pytest" package.

Our ultimate goal is to merge these python tests with the meson test
suite, so the use of 'pytest' here is only a stop-gap solution to get
the GitLab CI 'check-python-tox' passing again following recent Python
packaging ecosystem changes.

Reviewed-by: Thomas Huth <[email protected]>
Reviewed-by: Daniel P. Berrangé <[email protected]>
Message-ID: <[email protected]>
[ran black autoformatter. --js]
Signed-off-by: John Snow <[email protected]>
2026-03-09 14:04:03 -04:00
John Snow 4c2c89630c python: pin 'wheel' version in minreqs test
With recent python packaging ecosystem updates, the latest 'wheel' is no
longer compatible with older packages - and was somehow still compatible
with our Python 3.9 environment. Pin wheel to an older version (Version
based on Debian 11's available wheel package) to remove warnings during
the minreqs test.

Reviewed-by: Daniel P. Berrangé <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: John Snow <[email protected]>
2026-03-09 14:03:36 -04:00
Peter Maydell 31ee190665 Merge tag 'hw-misc-20260309' of https://github.com/philmd/qemu into staging
Misc HW patches

- Remove versioned machines released in QEMU 3.1 and 4.0
- Enable X.Org text rendering on ATI VGA model
- Various memory leaks / overflows fixed
- Build using -Wformat-overflow=2 CPPFLAG

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCAAdFiEE+qvnXhKRciHc/Wuy4+MsLN6twN4FAmmu7BAACgkQ4+MsLN6t
# wN4P2RAA2m5XpiwqjyUaaidGQTZi1qNqj3DOl1nOh3XpFCzD4BGUtbJp+06i59iL
# Q8yxFr7jtsNDiRdWC2ow8rWp3aQhqzvsn1hpNFWZoVHWOBsPnHpOmgFINlw3nZA2
# d/boV8aKE/VXhLY8plL3T4oy9rUSiwd7S4rubYjVIr2BVOQaiMKEZvLYUS4ErP5Q
# rhhgj08Z6NhB6fE+kxmi/R1+C8i8mYnCtK2vO9kXoyfdiwFNBpfmaZ6xJ0eSI/v9
# 4GVkeEtTkBsvRjbo/S5OQIjUKYsB8y00UnaiO+VRPxVDHqks5eP2WtrZOjOKTs+C
# EaNkhqocMowGRt23JqM0XVaYktjzsXIYTGnRI33hmwL1qbyYK91wzxt5JqwYlpHo
# EGn6YqV4to/1QLSzPr25cETf089ZJ6gqoIPP/I8dwj4Ups+nDaAvRvOKAOTTnyez
# F8zZ+AYe6jhZKKN0iTwoaBUCFt1VgtJ6gSz/GChoALTrEcOGEzBxkfAbzTq9ir8/
# lmO62Rmdrzc8KZiclOyCQM1kOzNH4Jdzy3jEN9cyIQRhf+KVz1uQEqyR4Lb8xmHy
# S9Hts6CTP8yPXh/kL0xAlaY1IDRrkFwuTS52+XjwNyKTQFsOJX6VE2fJgA8ut7Jq
# gNc3sq0G1aCMRqB/1XHvawfSK1o6Olyk1P1i/FUAFzjIxGX0PMw=
# =zL9Q
# -----END PGP SIGNATURE-----
# gpg: Signature made Mon Mar  9 15:49:36 2026 GMT
# gpg:                using RSA key FAABE75E12917221DCFD6BB2E3E32C2CDEADC0DE
# gpg: Good signature from "Philippe Mathieu-Daudé (F4BUG) <[email protected]>" [full]
# Primary key fingerprint: FAAB E75E 1291 7221 DCFD  6BB2 E3E3 2C2C DEAD C0DE

* tag 'hw-misc-20260309' of https://github.com/philmd/qemu: (49 commits)
  hw/misc/riscv_cpc: Free CPU array in instance_finalize
  hw/misc/sifive_e_aon: Don't leak timer
  hw/i3c/dw-i3c: Fix memory leaks in error logging paths
  ati-vga: Do not access pixel outside the screen
  ati-vga: Simplify hw cursor drawing
  ati-vga: Implement HOST_DATA flush to VRAM
  ati-vga: Implement HOST_DATA register writes
  ati-vga: Implement scissor rectangle clipping for 2D operations
  ati-vga: Remove ATIVGAState param from ati_2d_do_blt
  ati-vga: Split ati_2d_do_blt from ati_2d_blt
  ati-vga: Extract setup_2d_blt_ctx from ati_2d_blt
  ati-vga: Introduce ATI2DCtx struct for 2D blit context
  ati-vga: Use local variables for register values in ati_2d_blt
  ati-vga: Remove src and dst stride mutation in ati_2d_blt
  hw: Make qdev_get_printable_name() consistently return freeable string
  hw/qdev: Document qdev_get_dev_path()
  hw/timer/slavio_timer: Free resources allocated in instance_init
  hw/sparc/sun4m: Use qdev GPIOs rather than qemu_allocate_irqs()
  hw/sparc/sun4m: Don't set up dummy cpu interrupts
  hw/net/npcm_gmac: Catch accesses off the end of the register array
  ...

Signed-off-by: Peter Maydell <[email protected]>
2026-03-09 17:19:26 +00:00
Peter Maydell caa5d82570 hw/misc/riscv_cpc: Free CPU array in instance_finalize
The TYPE_RISCV_CPC device allocates an array in its instance_init,
but does not free this, leading to leaks like this from QOM/QMP
introspection:

Direct leak of 512 byte in 1 object allocated from:
    #0  in calloc
    #1  in g_malloc0
    #2  in riscv_cpc_init /home/pm215/qemu/build/san/../../hw/misc/riscv_cpc.c:175:15
    #3  in object_initialize_with_type /home/pm215/qemu/build/san/../../qom/object.c:570:5
    #4  in object_new_with_type /home/pm215/qemu/build/san/../../qom/object.c:774:5
    #5  in qmp_device_list_properties /home/pm215/qemu/build/san/../../qom/qom-qmp-cmds.c:206:11
    #6  in qdev_device_help /home/pm215/qemu/build/san/../../system/qdev-monitor.c:313:17
    #7  in hmp_device_add /home/pm215/qemu/build/san/../../system/qdev-monitor.c:1005:9

Free the array in instance_finalize.

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-09 16:45:25 +01:00
Peter Maydell ac9dde499e hw/misc/sifive_e_aon: Don't leak timer
The sifive_e_aon watchdog creates a timer with timer_new_ns() in its
instance_init method, but does not free it in instance_finalize.
This means that QMP introspection of the device leaks it:

Direct leak of 48 byte in 1 object allocated from:
    #0  in calloc
    #1  in g_malloc0
    #2  in timer_new_full /home/pm215/qemu/include/qemu/timer.h:520:21
    #3  in timer_new /home/pm215/qemu/include/qemu/timer.h:543:12
    #4  in timer_new_ns /home/pm215/qemu/include/qemu/timer.h:563:12
    #5  in sifive_e_aon_init /home/pm215/qemu/build/san/../../hw/misc/sifive_e_aon.c:286:21
    #6  in object_initialize_with_type /home/pm215/qemu/build/san/../../qom/object.c:570:5
    #7  in object_initialize /home/pm215/qemu/build/san/../../qom/object.c:578:5
    #8  in object_initialize_child_with_propsv /home/pm215/qemu/build/san/../../qom/object.c:608:5
    #9  in object_initialize_child_with_props /home/pm215/qemu/build/san/../../qom/object.c:591:10
    #10  in object_initialize_child_internal /home/pm215/qemu/build/san/../../qom/object.c:645:5
    #11  in object_initialize_with_type /home/pm215/qemu/build/san/../../qom/object.c:570:5
    #12  in object_new_with_type /home/pm215/qemu/build/san/../../qom/object.c:774:5
    #13  in qmp_device_list_properties /home/pm215/qemu/build/san/../../qom/qom-qmp-cmds.c:206:11

Allocating a separate QEMUTimer with timer_new() is not the preferred
interface (per the comments in include/qemu/timer.h); switch to an
inline struct initialized with timer_init(), which we can clean up
with timer_del() in finalize.

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-09 16:45:25 +01:00
Cédric Le Goater 8a16a38f3d hw/i3c/dw-i3c: Fix memory leaks in error logging paths
object_get_canonical_path() returns an allocated string that must be
freed by the caller. Use g_autofree variables to ensure that memory is
not leaked.

Resolves: Coverity CID 1645550
Resolves: Coverity CID 1645553
Signed-off-by: Cédric Le Goater <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-09 16:45:25 +01:00
BALATON Zoltan e9fa0330a2 ati-vga: Do not access pixel outside the screen
We check end of screen before writing the pixel but before that
complement color also accesses screen pixel so we have to check before
that. This fixes a segmentation fault with guest_hwcursor when pointer
is partially out of screen at lower right corner.

Signed-off-by: BALATON Zoltan <[email protected]>
Reviewed-by: Chad Jablonski <[email protected]>
Message-ID: <26db0715a6b9f6504f394010513facc9a37882ad.1773009887.git.balaton@eik.bme.hu>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-09 16:45:25 +01:00
BALATON Zoltan 1c0f729127 ati-vga: Simplify hw cursor drawing
Avoid calculating index at every step when we can just count the
position.

Signed-off-by: BALATON Zoltan <[email protected]>
Reviewed-by: Chad Jablonski <[email protected]>
Message-ID: <90b49357b6bf80bcf8962331575ffd16a96b706a.1773009887.git.balaton@eik.bme.hu>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-09 16:45:25 +01:00
Chad Jablonski 2735701ec9 ati-vga: Implement HOST_DATA flush to VRAM
Implement flushing the 128-bit HOST_DATA accumulator to VRAM to enable
text rendering in X. Supports all datatypes (monochrome frgd/bkgd,
monochrome frgd, and color), however monochrome frgd support is
partial and does not properly handle transparency/leave-alone.

The flush is broken up into two steps. First, if necessary, expansion of the
monochrome bits to the destination color depth. Then the expanded pixels
are sent to the ati_2d_do_blt one scanline at a time. ati_2d_do_blt then
clips and performs the blit.

Signed-off-by: Chad Jablonski <[email protected]>
Reviewed-by: BALATON Zoltan <[email protected]>
[balaton: Fix build without pixman]
Signed-off-by: BALATON Zoltan <[email protected]>
Message-ID: <8d0d4b52a16f5564e37bbc88496d7ab8d41477ac.1773020351.git.balaton@eik.bme.hu>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-09 16:45:25 +01:00
Chad Jablonski 69051f7293 ati-vga: Implement HOST_DATA register writes
Writing to any of the HOST_DATA0-7 registers pushes the written data
into a 128-bit accumulator. When the accumulator is full a flush is
triggered to copy it to the framebuffer. A final write to HOST_DATA_LAST
will also initiate a flush. The flush itself is left for the next patch.

Unaligned HOST_DATA* writes result in, from what I can tell, undefined
behavior on real hardware. A well-behaved driver shouldn't be doing this
anyway. For that reason they are not handled here at all.

Signed-off-by: Chad Jablonski <[email protected]>
Reviewed-by: BALATON Zoltan <[email protected]>
Signed-off-by: BALATON Zoltan <[email protected]>
Message-ID: <235adb69787c818afd023e7f32286166cc70744c.1773020351.git.balaton@eik.bme.hu>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-09 16:45:25 +01:00
Chad Jablonski 527b07d2c5 ati-vga: Implement scissor rectangle clipping for 2D operations
Use scissor registers to clip blit operations. This is required
for text rendering in X using the r128 driver. Without it overly-wide
glyphs are drawn and create all sorts of chaos.

The visible destination rectangle (vis_dst) is the intersection of the
scissor rectangle and the destination rectangle (dst).

The src also needs to be offset if clipped on the top and/or
left sides to ensure that src data is read correctly and appears
clipped when drawn rather than shifted.

Signed-off-by: Chad Jablonski <[email protected]>
Reviewed-by: BALATON Zoltan <[email protected]>
[balaton: Fix build without pixman]
Signed-off-by: BALATON Zoltan <[email protected]>
Message-ID: <4752dfbe240102c2ffa1f2cdab4c9442d4f0dcfb.1773020351.git.balaton@eik.bme.hu>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-09 16:45:24 +01:00
Chad Jablonski ff3da02eaf ati-vga: Remove ATIVGAState param from ati_2d_do_blt
This completes the decoupling from the ATIVGAState struct.

Signed-off-by: Chad Jablonski <[email protected]>
Reviewed-by: BALATON Zoltan <[email protected]>
[balaton: Fix build without pixman]
Signed-off-by: BALATON Zoltan <[email protected]>
Message-ID: <6e3545dea9f4522e07e91f9db885a7d74dae781a.1773020351.git.balaton@eik.bme.hu>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-09 16:45:24 +01:00
Chad Jablonski 4066a2ff27 ati-vga: Split ati_2d_do_blt from ati_2d_blt
ati_2d_blt remains the public interface to the blitter but the bulk of
the implementation is moved down into ati_2d_do_blt which is passed an
ATI2DCtx.

ati_2d_do_blt returns a bool that is true when the blit succeeded, which
means that a screen region will need to be set dirty. Otherwise false is
returned.

Signed-off-by: Chad Jablonski <[email protected]>
Reviewed-by: BALATON Zoltan <[email protected]>
[balaton: Fix build without pixman]
Signed-off-by: BALATON Zoltan <[email protected]>
Message-ID: <367949c50ca140a2d18ae66234dafbbc586b553c.1773020351.git.balaton@eik.bme.hu>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-09 16:45:24 +01:00
Chad Jablonski b6740448a2 ati-vga: Extract setup_2d_blt_ctx from ati_2d_blt
setup_2d_blt_ctx is responsible for knowing how to retrieve the state
needed by ati_2d_blt from the registers and assigning it to the ATI2DCtx.
This will be useful in a future patch when HOST_DATA needs to make small
modifications to the ctx.

Signed-off-by: Chad Jablonski <[email protected]>
Reviewed-by: BALATON Zoltan <[email protected]>
[balaton: Fix build without pixman]
Signed-off-by: BALATON Zoltan <[email protected]>
Message-ID: <6e2dccba65d9b369e0db633c0149a77351827222.1773020351.git.balaton@eik.bme.hu>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-09 16:45:24 +01:00
Chad Jablonski 6df405b1cf ati-vga: Introduce ATI2DCtx struct for 2D blit context
Previously all state derived from registers was moved to locals. Now we
can mechanically replace those locals with fields on the new ATI2DCtx
struct.

Signed-off-by: Chad Jablonski <[email protected]>
Reviewed-by: BALATON Zoltan <[email protected]>
[balaton: Fix build without pixman]
Signed-off-by: BALATON Zoltan <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-09 16:45:24 +01:00
Chad Jablonski 67f074bf24 ati-vga: Use local variables for register values in ati_2d_blt
ati_2d_blt uses a mixture of locals and direct register access of needed
state. This assigns all values derived from register state to local
variables. It prepares the function for a larger refactor that removes
the dependency on the full device and direct register access entirely.

Signed-off-by: Chad Jablonski <[email protected]>
Reviewed-by: BALATON Zoltan <[email protected]>
[balaton: Fix build without pixman]
Signed-off-by: BALATON Zoltan <[email protected]>
Message-ID: <2c7f8fdc527e8c5bad237933a1c8a7a8e5068a3d.1773020351.git.balaton@eik.bme.hu>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-09 16:45:24 +01:00
Chad Jablonski 8239517393 ati-vga: Remove src and dst stride mutation in ati_2d_blt
Pixman requires stride in words. So over the course of the ati_2d_blt
function both src and dst stride were mutated before being passed to
pixman and then back afterwards.

This creates local variables holding src and dst stride in words
avoiding the potentially confusing mutation.

Signed-off-by: Chad Jablonski <[email protected]>
Reviewed-by: BALATON Zoltan <[email protected]>
[balaton: Fix build without pixman]
Signed-off-by: BALATON Zoltan <[email protected]>
Message-ID: <7ab2227b96b73a63cb4fc61d0e6921e01900a4ee.1773020351.git.balaton@eik.bme.hu>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-09 16:45:24 +01:00
Peter Maydell 1e3e1d51e2 hw: Make qdev_get_printable_name() consistently return freeable string
The current implementation of qdev_get_printable_name() sometimes
returns a string that must not be freed (vdev->id or the fixed
fallback string "<unknown device>" and sometimes returns a string
that must be freed (the return value of qdev_get_dev_path()). This
forces callers to leak the string in the "must be freed" case.

Make the function consistent that it always returns a string that
the caller must free, and make the three callsites free it.

This fixes leaks like this that show up when running "make check"
with the address sanitizer enabled:

Direct leak of 13 byte(s) in 1 object(s) allocated from:
    #0 0x5561de21f293 in malloc (/home/pm215/qemu/build/san/qemu-system-i386+0x1a2d293) (BuildId: 6d6fad7130fd5c8dbbc03401df554f68b8034936)
    #1 0x767ad7a82ac9 in g_malloc (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x62ac9) (BuildId: 116e142b9b52c8a4dfd403e759e71ab8f95d8bb3)
    #2 0x5561deaf34f2 in pcibus_get_dev_path /home/pm215/qemu/build/san/../../hw/pci/pci.c:2792:12
    #3 0x5561df9d8830 in qdev_get_printable_name /home/pm215/qemu/build/san/../../hw/core/qdev.c:431:24
    #4 0x5561deebdca2 in virtio_init_region_cache /home/pm215/qemu/build/san/../../hw/virtio/virtio.c:298:17
    #5 0x5561df05f842 in memory_region_write_accessor /home/pm215/qemu/build/san/../../system/memory.c:491:5
    #6 0x5561df05ed1b in access_with_adjusted_size /home/pm215/qemu/build/san/../../system/memory.c:567:18
    #7 0x5561df05e3fa in memory_region_dispatch_write /home/pm215/qemu/build/san/../../system/memory.c
    #8 0x5561df0aa805 in address_space_stm_internal /home/pm215/qemu/build/san/../../system/memory_ldst.c.inc:85:13
    #9 0x5561df0bcad3 in qtest_process_command /home/pm215/qemu/build/san/../../system/qtest.c:480:13

Cc: [email protected]
Fixes: e209d4d7a3 ("virtio: improve virtqueue mapping error messages")
Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-09 16:45:24 +01:00
Peter Maydell 7f2cef7f55 hw/qdev: Document qdev_get_dev_path()
We don't document qdev_get_dev_path() at all; in particular
we do not mention that it returns a string that the caller
must free.

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-09 16:45:24 +01:00
Peter Maydell c9949c096b hw/timer/slavio_timer: Free resources allocated in instance_init
The slavio_timer device's instance_init function allocates memory for
TimerContext structs and a ptimer, but it never frees this memory, so
we will leak it if the QMP interface does introspection of this
device type, as reported by the clang address sanitizer:

Indirect leak of 4896 byte(s) in 17 object(s) allocated from:
    #0 0x5f2948d9b14d in calloc (/home/pm215/qemu/build/san/qemu-system-sparc+0xe0c14d) (BuildId: 7210711bdf6f7fbd0b863bd2dfcc7c42c7175db1)
    #1 0x758584b11771 in g_malloc0 (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x63771) (BuildId: 116e142b9b52c8a4dfd403e759e71ab8f95d8bb3)
    #2 0x5f2949097b8a in slavio_timer_init /home/pm215/qemu/build/san/../../hw/timer/slavio_timer.c:403:14
    #3 0x5f29495d790f in object_initialize_with_type /home/pm215/qemu/build/san/../../qom/object.c:570:5
    #4 0x5f29495d96ef in object_new_with_type /home/pm215/qemu/build/san/../../qom/object.c:774:5
    #5 0x5f2949a30a26 in qmp_device_list_properties /home/pm215/qemu/build/san/../../qom/qom-qmp-cmds.c:206:11

Indirect leak of 1632 byte(s) in 17 object(s) allocated from:
    #0 0x5f2948d9b14d in calloc (/home/pm215/qemu/build/san/qemu-system-sparc+0xe0c14d) (BuildId: 7210711bdf6f7fbd0b863bd2dfcc7c42c7175db1)
    #1 0x758584b11771 in g_malloc0 (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x63771) (BuildId: 116e142b9b52c8a4dfd403e759e71ab8f95d8bb3)
    #2 0x5f2948f7c65a in ptimer_init /home/pm215/qemu/build/san/../../hw/core/ptimer.c:464:9
    #3 0x5f2949097c1f in slavio_timer_init /home/pm215/qemu/build/san/../../hw/timer/slavio_timer.c:407:32
    #4 0x5f29495d790f in object_initialize_with_type /home/pm215/qemu/build/san/../../qom/object.c:570:5
    #5 0x5f29495d96ef in object_new_with_type /home/pm215/qemu/build/san/../../qom/object.c:774:5
    #6 0x5f2949a30a26 in qmp_device_list_properties /home/pm215/qemu/build/san/../../qom/qom-qmp-cmds.c:206:11

Avoid the TimerContext leaks by making them an array inside the
SLAVIO_TimerState struct instead of allocating a compile-time-fixed
number of them each individually with g_new0() and then throwing away
the pointer.

Avoid the ptimer() leak by calling ptimer_free in
instance_finalize().

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Mark Cave-Ayland <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-09 16:45:24 +01:00
Peter Maydell fe00b8eba8 hw/sparc/sun4m: Use qdev GPIOs rather than qemu_allocate_irqs()
In the sun4m machine creation code, we currently use qemu_allocate_irqs()
to set up the IRQ lines that act as the inbound IRQ lines to the CPUs.
This results in a memory leak:

Direct leak of 128 byte(s) in 1 object(s) allocated from:
    #0 0x5a23c1281ec3 in malloc (/home/pm215/qemu/build/sparc-san/qemu-system-sparc+0xdf1ec3) (BuildId: e6aa10be01feb5524656dd083997bc82b85e3e93)
    #1 0x79e8f78f0ac9 in g_malloc (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x62ac9) (BuildId: 116e142b9b52c8a4dfd403e759e71ab8f95d8bb3)
    #2 0x5a23c1a94e54 in qemu_extend_irqs /home/pm215/qemu/build/sparc-san/../../hw/core/irq.c:77:51
    #3 0x5a23c1a39e03 in cpu_devinit /home/pm215/qemu/build/sparc-san/../../hw/sparc/sun4m.c:802:17
    #4 0x5a23c1a39e03 in sun4m_hw_init /home/pm215/qemu/build/sparc-san/../../hw/sparc/sun4m.c:838:9

The leak is unimportant as it is a "once at startup" leak, but
fixing it helps in getting a clean leak-sanitizer test run.

Switch the sun4m code to handle CPU interrupt lines in the same way
as the leon3 machine does: the machine init code uses
qdev_init_gpio_in to create GPIO lines on the CPU objects.  This is a
little bit odd as ideally the CPU would do that itself, but for these
32-bit SPARC machines the machine and the CPU are very closely
coupled already (the functions handling the IRQ lines modify data
fields inside the CPU).

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Mark Cave-Ayland <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-09 16:45:24 +01:00
Peter Maydell cbf8e38203 hw/sparc/sun4m: Don't set up dummy cpu interrupts
In the sun4m machine init, we set up the cpu_irqs[] array
with the real inbound IRQs for each CPU, followed by some
dummy IRQs for the remaining slots from smp_cpus up to
MAX_CPUS. These dummy IRQs do nothing when set/cleared
because the dummy_cpu_set_irq() function does nothing.

Instead of creating these "do nothing" qemu_irqs, instead
pass the number of CPUs to slavio_intctl_init() so that it
can only wire up the interrupt controller's interrupts
for the CPUs that actually exist. Calling qemu_set_irq()
on an irq that isn't connected does nothing, so this is
a simpler way to achieve the same result.

This cleanup fixes an unimportant memory leak reported by
the address sanitizer that happens because we allocate these
dummy IRQs with qemu_allocate_irqs():

Direct leak of 1920 byte(s) in 15 object(s) allocated from:
    #0 0x5cb7b120cf63 in malloc (/home/pm215/qemu/build/san/qemu-system-sparc+0xe0bf63) (BuildId: d27f9230a7cc82ebfaf0cf9e439dc215ddd7ac68)
    #1 0x743cd6dc5ac9 in g_malloc (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x62ac9) (BuildId: 116e142b9b52c8a4dfd403e759e71ab8f95d8bb3)
    #2 0x5cb7b1a42fb4 in qemu_extend_irqs /home/pm215/qemu/build/san/../../hw/core/irq.c:77:51
    #3 0x5cb7b19e7e72 in sun4m_hw_init /home/pm215/qemu/build/san/../../hw/sparc/sun4m.c:845:23
    #4 0x5cb7b141d3dd in machine_run_board_init /home/pm215/qemu/build/san/../../hw/core/machine.c:1709:5
    #5 0x5cb7b1542895 in qemu_init_board /home/pm215/qemu/build/san/../../system/vl.c:2717:5
    #6 0x5cb7b1542895 in qmp_x_exit_preconfig /home/pm215/qemu/build/san/../../system/vl.c:2811:5
    #7 0x5cb7b15493ac in qemu_init /home/pm215/qemu/build/san/../../system/vl.c:3849:9
    #8 0x5cb7b1f3f201 in main /home/pm215/qemu/build/san/../../system/main.c:71:5
    #9 0x743cd4a2a1c9 in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
    #10 0x743cd4a2a28a in __libc_start_main csu/../csu/libc-start.c:360:3
    #11 0x5cb7b1172114 in _start (/home/pm215/qemu/build/san/qemu-system-sparc+0xd71114) (BuildId: d27f9230a7cc82ebfaf0cf9e439dc215ddd7ac68)

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Mark Cave-Ayland <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-09 16:45:24 +01:00
Peter Maydell 550391c713 hw/net/npcm_gmac: Catch accesses off the end of the register array
In the npcm_gmac device, we create the iomem MemoryRegion with
a size of 8KB, but NPCM_GMAC_NR_REGS is only 0x1060 / 4. This
means there's a range of offsets that the guest can access
that don't have gmac->regs[] entries. We weren't catching this,
so the guest could get us to index off the end of the regs array.

Catch and log these invalid accesses.

Cc: [email protected]
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3316
Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-09 16:45:24 +01:00
Peter Foley d89f7c8194 net/passt: Don't try to read the pidfile if passt got a signal
g_subprocess_get_if_exited returns false if passt was killed by a signal, so we fall through to trying to read the pidfile.

Update the error when passt exits to include the exit code.

Reviewed-by: Laurent Vivier <[email protected]>
Signed-off-by: Peter Foley <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-09 16:45:24 +01:00
Peter Foley a1596cdc37 net/passt: Only kill passt if it wrote a pidfile
Avoid killing qemu if passt failed before writing a pidfile.

pid is initialized to 0, so calling pid in this scenario would kill the
entire process group.

Reviewed-by: Laurent Vivier <[email protected]>
Signed-off-by: Peter Foley <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-09 16:45:24 +01:00
Akihiko Odaki 4efd93949f meson: Add -Wformat-overflow=2
https://gcc.gnu.org/onlinedocs/gcc-15.2.0/gcc/Warning-Options.html
> Level 2 warns also about calls that might overflow the destination
> buffer given an argument of sufficient length or magnitude. At level
> 2, unknown numeric arguments are assumed to have the minimum
> representable value for signed types with a precision greater than 1,
> and the maximum representable value otherwise. Unknown string
> arguments whose length cannot be assumed to be bounded either by the
> directive’s precision, or by a finite set of string literals they may
> evaluate to, or the character array they may point to, are assumed to
> be 1 character long.

Signed-off-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Reviewed-by: Peter Maydell <[email protected]>
Message-ID: <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-09 16:45:24 +01:00
Akihiko Odaki 2a58162a1e tests: Clean up double comparisons to avoid compiler warning
To enable -Wformat-overflow=2, we need to clean up a couple of false
positives:

[2/5] Compiling C object tests/unit/test-qobject-output-visitor.p/test-qobject-output-visitor.c.o
../tests/unit/test-qobject-output-visitor.c: In function ‘test_visitor_out_list_struct’:
../tests/unit/test-qobject-output-visitor.c:577:28: error: ‘%.6f’ directive writing between 3 and 317 bytes into a region of size 32 [-Werror=format-overflow=]
  577 |         sprintf(expected, "%.6f", (double)i / 3);
      |                            ^~~~
../tests/unit/test-qobject-output-visitor.c:577:27: note: assuming directive output of 8 bytes
  577 |         sprintf(expected, "%.6f", (double)i / 3);
      |                           ^~~~~~
In file included from /usr/include/stdio.h:970,
                 from /home/me/q/var/qemu/include/qemu/osdep.h:114,
                 from ../tests/unit/test-qobject-output-visitor.c:13:
In function ‘sprintf’,
    inlined from ‘test_visitor_out_list_struct’ at ../tests/unit/test-qobject-output-visitor.c:577:9:
/usr/include/bits/stdio2.h:30:10: note: ‘__builtin___sprintf_chk’ output between 4 and 318 bytes into a destination of size 32
   30 |   return __builtin___sprintf_chk (__s, __USE_FORTIFY_LEVEL - 1,
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   31 |                                   __glibc_objsize (__s), __fmt,
      |                                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   32 |                                   __va_arg_pack ());
      |                                   ~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
FAILED: tests/unit/test-qobject-output-visitor.p/test-qobject-output-visitor.c.o

These buffers cannot actually overflow because the doubles are
between 0 and 31.0/3 inclusive.

However, formatting doubles just to compare them is silly.  Compare
them directly instead.  To avoid potential rounding trouble, change
the numbers tested to be representable exactly in double.

Signed-off-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Reviewed-by: Markus Armbruster <[email protected]>
Message-ID: <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-09 16:45:24 +01:00
Akihiko Odaki 1785bf9685 vfio/pci: Grow buffer in vfio_pci_host_match()
Each field of PCIHostDeviceAddress is an unsigned int, therefore
while a valid address is limited to 13 characters, an invalid
address could exceed the specified format, up to:

        ffffffff:ffffffff:ffffffff.ffffffff<NUL>

This requires 36 characters with the terminator.

Signed-off-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Reviewed-by: Alex Williamson <[email protected]>
Message-ID: <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-09 16:45:24 +01:00
Akihiko Odaki 2d23a97631 contrib/elf2dmp: Grow PDB URL buffer
The buffers used to construct a PDB URL overflow when the "age" property
is greater than 0xf, so grow it. This also simplifies the logic of the
URL construction to use one buffer instead of two to avoid the chore to
synchronize the sizes of two buffers.

Signed-off-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Reviewed-by: Peter Maydell <[email protected]>
Message-ID: <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-09 16:45:24 +01:00
Roman Kiryanov 248958526d virtio-snd: remove redundant fields
VirtIOSoundPCM does not need a pointer to
VirtIOSound because each VirtIOSoundPCMStream
already carries a pointer to it.

Signed-off-by: Roman Kiryanov <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-09 16:45:24 +01:00
Roman Kiryanov 2fd2f50e9b virtio-snd: remove a redundant memory allocation
This change also makes its lifetime explicit and
prevents NULL dereferences.

Signed-off-by: Roman Kiryanov <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-09 16:45:24 +01:00
Akihiko Odaki bac986a670 coreaudio: Remove extra whitespaces
Remove extra whitespaces around parentheses.

Signed-off-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Reviewed-by: Marc-André Lureau <[email protected]>
Message-ID: <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-09 16:45:24 +01:00
Akihiko Odaki 6151922f0e coreaudio: Remove unnecessary explicit casts
coreaudio had unnecessary explicit casts and they had extra whitespaces
around them so remove them.

Signed-off-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Reviewed-by: Marc-André Lureau <[email protected]>
Message-ID: <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-09 16:45:24 +01:00
Marc-André Lureau 639adeabb3 ui/dbus: fix pixman cleanup
Moved pixman_region32_fini() outside the WIN32 block so it's called on
all platforms.

Fixes: commit 7007e98c ("ui/dbus: implement damage regions for GL")
Signed-off-by: Marc-André Lureau <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-09 16:45:24 +01:00
Marc-André Lureau 4e86363a28 ui/dbus: fix Unix.Map proxy leak
Fixes: commit 48b7ef0f0 ("ui/dbus: implement Unix.Map")
Signed-off-by: Marc-André Lureau <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-09 16:45:24 +01:00
Marc-André Lureau 59bf093a64 ui/dbus: fix leak regression
For some reason, during refactoring, an extra reference leak was introduced.

Fixes: commit 7945576cf2 ("ui/dbus: factor out sending a scanout")
Signed-off-by: Marc-André Lureau <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-09 16:45:24 +01:00
Marc-André Lureau e96ff02669 tests: fix leaks in dbus-display-test
Close the connections and complete the method invocations.

Thanks ASAN for the report.

Signed-off-by: Marc-André Lureau <[email protected]>
Acked-by: Fabiano Rosas <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-09 16:45:24 +01:00
Philippe Mathieu-Daudé 59de9b6fa7 hw/rtc/pl031: : Remove PL031State::migrate_tick_offset field
The PL031State::migrate_tick_offset boolean was only set in
the hw_compat_4_0[] array, via the 'migrate-tick-offset=false'
property.  We removed all machines using that array, lets remove
that property, along with the pl031_properties[] array which is
now empty.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Message-Id: <[email protected]>
2026-03-09 16:45:24 +01:00
Philippe Mathieu-Daudé fb66dbbc4d hw/virtio: Remove VirtIOBalloon::qemu_4_0_config_size field
The VirtIOBalloon::qemu_4_0_config_size boolean was only set in
the hw_compat_4_0[] array, via the 'qemu-4-0-config-size=true'
property.  We removed all machines using that array, lets remove
that property.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Message-Id: <[email protected]>
2026-03-09 16:45:24 +01:00
Philippe Mathieu-Daudé f5c74c2a49 hw/core/machine: Remove the hw_compat_4_0[] array
The hw_compat_4_0[] array was only used by the pc-q35-4.0
and pc-i440fx-4.0 machines, which got removed. Remove it.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Message-Id: <[email protected]>
2026-03-09 16:45:24 +01:00
Philippe Mathieu-Daudé aa711b58e9 hw/i386/pc: Remove pc_compat_4_0[] array
The pc_compat_4_0[] array was only used by the pc-q35-4.0,
pc-q35-4.0.1 and pc-i440fx-4.0 machines, which got removed.
Remove it.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Message-Id: <[email protected]>
2026-03-09 16:45:24 +01:00
Philippe Mathieu-Daudé 75afdc1047 hw/i386/pc: Remove deprecated pc-q35-4.0[.1] and pc-i440fx-4.0 machines
These machines has been supported for a period of more than 6 years.
According to our versioned machine support policy (see commit
ce80c4fa6f "docs: document special exception for machine type
deprecation & removal") they can now be removed.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Message-Id: <[email protected]>
2026-03-09 16:45:24 +01:00
Philippe Mathieu-Daudé 0450e9d7bd hw/pci-bridge/pcie_rp: Remove PCIESlot::disable_acs field
The PCIESlot::disable_acs boolean was only set in the
hw_compat_3_1[] array, via the 'disable-acs=true' property.
We removed all machines using that array, lets remove that
property and all the code around it.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Message-Id: <[email protected]>
2026-03-09 16:45:24 +01:00
Philippe Mathieu-Daudé a861ffef23 hw/core/machine: Remove the hw_compat_3_1[] array
The hw_compat_3_1[] array was only used by the pc-q35-3.1
and pc-i440fx-3.1 machines, which got removed. Remove it.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Message-Id: <[email protected]>
2026-03-09 16:45:24 +01:00
Philippe Mathieu-Daudé b1173facb5 target/i386/cpu: Remove X86CPU::intel_pt_auto_level field
The X86CPU::intel_pt_auto_level boolean was only set in the
pc_compat_3_1[] array, via the 'x-intel-pt-auto-level=off'
property. We removed all machines using that array, let's
emove that property and all the code around it.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Message-Id: <[email protected]>
2026-03-09 16:45:24 +01:00
Philippe Mathieu-Daudé c935db70ee hw/i386/iommu: Remove IntelIOMMUState::dma_drain field
The IntelIOMMUState::dma_drain boolean was only set in
the pc_compat_3_1[] array, via the 'dma-drain=off' property.
We removed all machines using that array, lets remove that
property and all the code around it.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Message-Id: <[email protected]>
2026-03-09 16:45:24 +01:00
Philippe Mathieu-Daudé 14510958af hw/i386/pc: Remove pc_compat_3_1[] array
The pc_compat_3_1[] array was only used by the pc-q35-3.1
and pc-i440fx-3.1 machines, which got removed. Remove it.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Message-Id: <[email protected]>
2026-03-09 16:45:24 +01:00
Philippe Mathieu-Daudé 7d1e9bcfe9 hw/core/boards: Remove MachineClass::smbus_no_migration_support field
The MachineClass::smbus_no_migration_support boolean was only used
by the pc-q35-3.1 and pc-i440fx-3.1 machines, which got removed.
Remove it, along with pm_smbus_vmstate_needed().

Use the unconditional VMSTATE_BOOL() and VMSTATE_STRUCT() macros.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Acked-by: Corey Minyard <[email protected]>
Message-Id: <[email protected]>
2026-03-09 16:45:19 +01:00
Philippe Mathieu-Daudé b31f41d724 hw/i386/x86: Remove @pvh_enabled argument in x86_load_linux()
x86_load_linux()'s @pvh_enabled is now always %true: remove it.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Message-Id: <[email protected]>
2026-03-09 16:02:24 +01:00
Philippe Mathieu-Daudé 16d07e251c hw/i386/pc: Remove PCMachineClass::pvh_enabled field
The PCMachineClass::pvh_enabled boolean was only used by
the pc-q35-3.1 and pc-i440fx-3.1 machines, which got removed.
Remove it.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Message-Id: <[email protected]>
2026-03-09 16:02:24 +01:00
Philippe Mathieu-Daudé 7d2778dea3 hw/i386/pc: Remove deprecated pc-q35/pc-i440fx/xenfv 3.1 machines
These machines has been supported for a period of more than 6 years.
According to our versioned machine support policy (see commit
ce80c4fa6f "docs: document special exception for machine type
deprecation & removal") they can now be removed.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Message-Id: <[email protected]>
2026-03-09 16:02:24 +01:00
Philippe Mathieu-Daudé 85379af120 hw/timer/hpet: Remove HPETState::hpet_offset_saved field
The HPETState::hpet_offset_saved boolean was only set in the
hw_compat_2_11[] array, via the 'hpet-offset-saved=false'
property. We removed all machines using that array, let's remove
that property and all the code around it.

Message-ID: <[email protected]>
[thuth: Adapted the rust part to the current master branch]
Signed-off-by: Thomas Huth <[email protected]>
Reviewed-by: Zhao Liu <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
2026-03-09 16:02:24 +01:00
Peter Maydell de61484ec3 Merge tag 'linux-user-for-v11-pull-request' of https://github.com/hdeller/qemu-hppa into staging
linux-user patches for qemu v11

# -----BEGIN PGP SIGNATURE-----
#
# iHUEABYKAB0WIQS86RI+GtKfB8BJu973ErUQojoPXwUCaa7PQgAKCRD3ErUQojoP
# X1vmAP9xP/nu9TbgEn/75j6i/Id2vWAC3C5GGRVqFAIvtS7m0AEAor/4t50xQDvC
# yfrc2rGcV3cdoZe1jOlIPNbv6DvHIA4=
# =IkHG
# -----END PGP SIGNATURE-----
# gpg: Signature made Mon Mar  9 13:46:42 2026 GMT
# gpg:                using EDDSA key BCE9123E1AD29F07C049BBDEF712B510A23A0F5F
# gpg: Good signature from "Helge Deller <[email protected]>" [unknown]
# gpg:                 aka "Helge Deller <[email protected]>" [unknown]
# gpg:                 aka "Helge Deller <[email protected]>" [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: 4544 8228 2CD9 10DB EF3D  25F8 3E5F 3D04 A7A2 4603
#      Subkey fingerprint: BCE9 123E 1AD2 9F07 C049  BBDE F712 B510 A23A 0F5F

* tag 'linux-user-for-v11-pull-request' of https://github.com/hdeller/qemu-hppa:
  linux-user: Improve formatting for mremap()
  tests/tcg/multiarch/test-mmap: Check mmaps beyond reserved_va
  tests/tcg/multiarch/test-mmap: Print more details
  bsd-user: Deal with mmap where start > reserved_va
  linux-user: Deal with mmap where start > reserved_va
  linux-user: fix TIOCGSID ioctl
  linux-user: fix matching ioctl numbers in print_ioctl
  linux-user: Check if RESOLVE_CACHED flag is defined before using it
  linux-user: properly check flags in openat2
  linux-user/strace: fix printing of file offsets

Signed-off-by: Peter Maydell <[email protected]>
2026-03-09 14:53:42 +00:00
Peter Maydell 801797c249 Merge tag 'migration-20260309-pull-request' of https://gitlab.com/farosas/qemu into staging
Migration pull request

- Fix for races when migration starts again after a failure
- New maintainer for COLO: Lukas Straub
- COLO cleanups and bug fixes
- COLO multifd support

# -----BEGIN PGP SIGNATURE-----
#
# iQJEBAABCAAuFiEEqhtIsKIjJqWkw2TPx5jcdBvsMZ0FAmmuwz8QHGZhcm9zYXNA
# c3VzZS5kZQAKCRDHmNx0G+wxnaQ4D/9dq5niCFuJvP5xhaYTc0+VCErlaR9SFPkd
# OuJI3CWlld4EEfzgo0wAnt2CdF2oRqZwRrDzkcp0pXEaRS0US2yrzcnrXZmJwZ4j
# ZwTyMd/8N6Ej+qAzAkEFzT7pnwQDSWjtjLG+FZx8fidMqyYtEi2b4Ycp2x3VwZ+6
# BbR73sVK+4BNRR3OzI2FykmR6zlQgkWhznrHwpseYFJTmz28q/U3sIB0OA80lnuT
# DvZFlmwUSfJj+3hCrIcIm19SktOAG/8/jgkdMcWfb/EgBMieDBhLW0Q8S+EPVqNe
# HlcsZ3uYs8FFU/ae8j5TBeRHk4G41sUtFgunW6JD2Lgez+BAENejm3YbTtj8OyKA
# 95hYyCLa+GdYcTAHLBHU3xKhtrzcLQ7guDpeJqWPg36zKwBsZgBEDYqwQ/TTaMNR
# qLjRGZ3+h7HSrcIlDfE3HqZxAvsbGszQ8LlEeKxfrO+RklYSrQR1lEoeKZc9DYU3
# taAvWKYHkNGmOR6th6MQlT4eQGDkXxBv2oyLjlujS63102OrsSjFRwkuCwq0JNZk
# xcpw+EeUQAG6srOJHhe0HbjlhYSee26U0GuTrO3rlhqkKY+I10X81fCLhkUflnrA
# sjIjwRnI9uRUIOKuSx/XWVAvN1SW+/TYpDUPFon457RFjyQM7dirpyvxTcD5QTwj
# 1froPBPq8Q==
# =smC6
# -----END PGP SIGNATURE-----
# gpg: Signature made Mon Mar  9 12:55:27 2026 GMT
# gpg:                using RSA key AA1B48B0A22326A5A4C364CFC798DC741BEC319D
# gpg:                issuer "[email protected]"
# gpg: Good signature from "Fabiano Rosas <[email protected]>" [unknown]
# gpg:                 aka "Fabiano Almeida Rosas <[email protected]>" [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: AA1B 48B0 A223 26A5 A4C3  64CF C798 DC74 1BEC 319D

* tag 'migration-20260309-pull-request' of https://gitlab.com/farosas/qemu: (22 commits)
  colo: Reuse the return path from migration on primary and secondary side
  migration: Keep s->rp_state.from_dst_file open until migration ends
  colo: Use file lock in primary_vm_do_failover()
  multifd: Fix hang if send thread errors during sync
  qemu-colo.rst: Simplify the block replication setup
  qemu-colo.rst: Add my copyright
  qemu-colo.rst: Miscellaneous changes
  Convert colo main documentation to restructuredText
  migration-test: Add COLO migration unit test
  colo: Do not hold the BQL while receiving ram state.
  colo: Hold the BQL while sending ram state
  colo: Fix crash during device vmstate load
  Call colo_release_ram_cache() after multifd threads terminate
  multifd: Add COLO support
  multifd: Move ram state receive into multifd_ram_state_recv()
  ram: Remove colo special-casing
  colo: Remove ENABLE_COLO savevm command and mark it as deprecated
  colo: Replace migration_incoming_colo_enabled() with migrate_colo()
  colo: Setup ram cache in normal migration path
  MAINTAINERS: Remove Hailiang Zhang from COLO migration framework
  ...

Signed-off-by: Peter Maydell <[email protected]>
2026-03-09 14:53:34 +00:00
Helge Deller e6e8408506 linux-user: Improve formatting for mremap()
Improve slightly the strace output for mremap().
Print the old_address and new_address as hex values, old_size and
new_size as unsigned, and the flags as integer.

Signed-off-by: Helge Deller <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
2026-03-09 14:37:01 +01:00
Bingwu Zhang c865b6bce5 tests/tcg/multiarch/test-mmap: Check mmaps beyond reserved_va
Unfixed mmap calls where start > reserved_va or the max guest addr
should have a valid result.

Signed-off-by: Bingwu Zhang <[email protected]>
Signed-off-by: Helge Deller <[email protected]>
2026-03-09 14:37:01 +01:00
Bingwu Zhang 5ce072ea02 tests/tcg/multiarch/test-mmap: Print more details
Useful for debugging

Signed-off-by: Bingwu Zhang <[email protected]>
Signed-off-by: Helge Deller <[email protected]>
2026-03-09 14:37:01 +01:00
Bingwu Zhang e8e7d1f977 bsd-user: Deal with mmap where start > reserved_va
Fixes: f12294b5bd ("bsd-user: Use page_find_range_empty for mmap_find_vma_reserved")
Signed-off-by: Bingwu Zhang <[email protected]>
Reviewed-by: Helge Deller <[email protected]>
Reviewed-by: Warner Losh <[email protected]>
Signed-off-by: Helge Deller <[email protected]>
2026-03-09 14:37:01 +01:00
Bingwu Zhang f2813e13fe linux-user: Deal with mmap where start > reserved_va
Fixes: 4c13048e02 ("linux-user: Use page_find_range_empty for mmap_find_vma_reserved")
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3310
Signed-off-by: Bingwu Zhang <[email protected]>
Reviewed-by: Helge Deller <[email protected]>
Signed-off-by: Helge Deller <[email protected]>
2026-03-09 14:37:01 +01:00
Andreas Schwab 6a1221614f linux-user: fix TIOCGSID ioctl
TIOCGSID is IOC_R, not IOC_W.

Signed-off-by: Andreas Schwab <[email protected]>
Reviewed-by: Helge Deller <[email protected]>
Signed-off-by: Helge Deller <[email protected]>
2026-03-09 14:37:01 +01:00
Andreas Schwab e47b1ffff9 linux-user: fix matching ioctl numbers in print_ioctl
target_cmd in struct IOCTLEntry is a signed int.  Make sure the ioctl cmd
argument in the syscall is converted to int when matching, so that it
works correctly with an ioctl cmd that has bit 31 set.

Signed-off-by: Andreas Schwab <[email protected]>
Reviewed-by: Helge Deller <[email protected]>
Signed-off-by: Helge Deller <[email protected]>
2026-03-09 14:37:01 +01:00
Frank Chang 7ac4bded6a linux-user: Check if RESOLVE_CACHED flag is defined before using it
openat2.h was introduced in Linux kernel 5.6. However, RESOLVE_CACHED
flag was only added in kernel 5.12 and later. Therefore, we need to check
if RESOLVE_CACHED flag is defined before using it.

Signed-off-by: Frank Chang <[email protected]>
Reviewed-by: Helge Deller <[email protected]>
Signed-off-by: Helge Deller <[email protected]>
2026-03-09 14:37:01 +01:00
Andreas Schwab 2cf1cb3363 linux-user: properly check flags in openat2
target_to_host_bitmask truncates the bitmask to int.  Check that the upper
half of the flags do not have any bits set.

Signed-off-by: Andreas Schwab <[email protected]>
Reviewed-by: Helge Deller <[email protected]>
Signed-off-by: Helge Deller <[email protected]>
2026-03-09 14:37:01 +01:00
Jean-Christian CÎRSTEA cec27d2fa9 linux-user/strace: fix printing of file offsets
Previously, 64-bit file offsets (loff_t) were printed using `print_raw_param()`
function, which led to silent truncation of the upper part. This commit fixes
this issue by adding two helper functions:

1. print_file_offset32(): prints 32-bit file offsets (off_t)
2. print_file_offset64(): prints 64-bit file offsets (loff_t)

Changelog v2:

1. Make `print_file_offset32()` static.
2. Use `last` parameter in `print_file_offset32()`.
3. Rename `low` and `high` parameters of `print_file_offset64()` to `word0`,
`word1` respectively
4. Convert `last` to bool for `print_file_offset[32,64]()`
5. Use `PRId64` instead of `PRIu64` for `print_file_offset64()`
6. Fix `print__llseek()`

Signed-off-by: Jean-Christian CÎRSTEA <[email protected]>
Reviewed-by: Helge Deller <[email protected]>
Signed-off-by: Helge Deller <[email protected]>
2026-03-09 14:37:01 +01:00
Peter Maydell 7608a95d2e Merge tag 'pull-xen-20260309' of https://xenbits.xen.org/git-http/people/aperard/qemu-dm into staging
Xen queue:

- Bug fix handling framebuffer during migration
- Emit RTC_CHANGE event
- One build fix

# -----BEGIN PGP SIGNATURE-----
#
# iQEzBAABCgAdFiEE+AwAYwjiLP2KkueYDPVXL9f7Va8FAmmum+4ACgkQDPVXL9f7
# Va+LsggA9vh5IVYOMaiUDL/iktR8F2RudtL7wXoY0NbZ/GeYOPheX0E3x4nt7GWP
# Q41MOzlnSt6hL7ryKg78+sdbymSIF+b6mPr1w/eZWGjEs1cgjirrijWXDhbyhbwJ
# rbNEnJx4E+qC5yNqH3S4uDTnA7hz5f4YDOr+VXJ+r/R/p2u1ddZhmLQ06KwaE9jj
# rB7r5LblJnMuNqdNFh6Ybgp0hyyFWClhUb613uFgFe7OaP+C3UQ87t0Kkx7MdQ0c
# bNe2V5XNmWjo4hESKHJKBvWcnJpvlU3VGcDRDdu1tW9ZF4zFNNsh4KF85RRxjw70
# UscRuXTW9sNBET6dkBkYwdb924ReoA==
# =T3vF
# -----END PGP SIGNATURE-----
# gpg: Signature made Mon Mar  9 10:07:42 2026 GMT
# gpg:                using RSA key F80C006308E22CFD8A92E7980CF5572FD7FB55AF
# gpg: Good signature from "Anthony PERARD <[email protected]>" [marginal]
# gpg:                 aka "Anthony PERARD <[email protected]>" [marginal]
# gpg:                 aka "Anthony PERARD <[email protected]>" [unknown]
# gpg:                 aka "Anthony PERARD <[email protected]>" [unknown]
# gpg: WARNING: This key is not certified with sufficiently trusted signatures!
# gpg:          It is not certain that the signature belongs to the owner.
# Primary key fingerprint: 5379 2F71 024C 600F 778A  7161 D8D5 7199 DF83 42C8
#      Subkey fingerprint: F80C 0063 08E2 2CFD 8A92  E798 0CF5 572F D7FB 55AF

* tag 'pull-xen-20260309' of https://xenbits.xen.org/git-http/people/aperard/qemu-dm:
  xen-hvm: Emit RTC_CHANGE upon TIMEOFFSET ioreq
  xen-hvm: Handle framebuffer relocation
  hw/xen: Fix trace_xs_node_read() params

Signed-off-by: Peter Maydell <[email protected]>
2026-03-09 12:15:42 +00:00
Peter Maydell 8a39d34e65 Merge tag 'edgar/edgars-xen-queue-2026-02-09' of https://gitlab.com/edgar.iglesias/qemu into staging
Edgars Xen queue

# -----BEGIN PGP SIGNATURE-----
#
# iQEzBAABCgAdFiEErET+3BT38evtv0FRKcWWeA9ryoMFAmmuMroACgkQKcWWeA9r
# yoPuTQgAsnDiUDWD5H0eV9tQ4Ylb4anqUUP3chDjvCZ7/SdVjYEWOpeRq+IYPkmz
# EgqKZXkYCpBIQjySzMQQApqxB+3OhlnoenUtKY5tHfXuf3jtyuulDcT+ocOAlGMo
# yHv6X53r2o0o0cn9DlrhnyJ/s1RmOmtfjo5EmKo+IgPCE10HidhPzWJSoD6QhgBu
# +90s9AQGL5GmhL+Ns7/3bTh4VlSHynnBJgeJ0/AfDcgLhchAG3mDFCaunwmtwdd4
# z2O4yIYtgGzXsKzwUjaQRyCYjLYzN7wEOcK6qf3+nXLdnL3MsR5ry+KAySu40Fdg
# 7YmSK7RhA1EFdibCN/HAyeg64SnhOQ==
# =GhGY
# -----END PGP SIGNATURE-----
# gpg: Signature made Mon Mar  9 02:38:50 2026 GMT
# gpg:                using RSA key AC44FEDC14F7F1EBEDBF415129C596780F6BCA83
# gpg: Good signature from "Edgar E. Iglesias (Xilinx key) <[email protected]>" [unknown]
# gpg:                 aka "Edgar E. Iglesias <[email protected]>" [full]
# Primary key fingerprint: AC44 FEDC 14F7 F1EB EDBF  4151 29C5 9678 0F6B CA83

* tag 'edgar/edgars-xen-queue-2026-02-09' of https://gitlab.com/edgar.iglesias/qemu:
  hw/xen: xenpvh: Add prop to enable/disable the mapcache
  hw/xen-hvm: Add a mapcache arg to xen_register_ioreq()
  physmem: xen: Conditionalize use of the mapcache
  xen: mapcache: Add function to check if the mapcache is enabled
  xen: mapcache: Assert mapcache existance

Signed-off-by: Peter Maydell <[email protected]>
2026-03-09 12:15:31 +00:00
Peter Maydell a8ff516c2f Merge tag 'pr-plugins-20260307' of https://gitlab.com/pbo-linaro/qemu into staging
Changes:
- [PATCH] contrib/plugins/uftrace_symbols.py: ignore zero sized symbols (Pierrick Bouvier <[email protected]>)
  Link: https://lore.kernel.org/qemu-devel/[email protected]
- [PATCH] contrib/plugins/bbv.c: Check if file is NULL (Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>)
  Link: https://lore.kernel.org/qemu-devel/[email protected]

# -----BEGIN PGP SIGNATURE-----
#
# iQGzBAABCgAdFiEEZrmU7KFPfy5auggff5BUDQoc0A8FAmmskd8ACgkQf5BUDQoc
# 0A9+HQv/ZRaq8CEDIOXVOlS9d/j/tJRbp18rb+xcBWgFZAnL3NXOxvGvRm72elVz
# c1PwVqpw4itu3YIusXfUQUzqeY24oXSKDDBLYt5y4WvSCjixoUHjgrBa80rhgNxL
# Tybcpe3gyprSgTtRHki97sf1mfxp9+gTH4yCcC6/Onvbe/PoVyZZ/+LP5TDZf9oX
# UOTIhGD6bqMCrsFrr+zENl+3d+95MVSlHYd6AY/66j1SUn6PXdIDglHjcCdypNL/
# GIeUch9HtVWnVBES/LNZX4NxvpbvW2ZcJWg71MYj92kgnTitTrEacJiYbQF0BGzR
# prv6cfbWMrMz2GL5LGfzs8s5LRcxRn7FqVfTwujQwhZ+fYFVKIDD4J6aqesYnEco
# EEvTN0wHwUFJTDGOUcDJaXyBnO95opIQTxv7Dc3kGtD9x4zJUsoEqOdT5FfvBtjn
# WouF5j8LTndl5X7ofLlR67NAKARs8XVIH4VWadyJfPhrr1LjpI4SHgJfKW9G/LmA
# 0Zo/v3c6
# =faaJ
# -----END PGP SIGNATURE-----
# gpg: Signature made Sat Mar  7 21:00:15 2026 GMT
# gpg:                using RSA key 66B994ECA14F7F2E5ABA081F7F90540D0A1CD00F
# gpg: Good signature from "Pierrick Bouvier <[email protected]>" [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: 66B9 94EC A14F 7F2E 5ABA  081F 7F90 540D 0A1C D00F

* tag 'pr-plugins-20260307' of https://gitlab.com/pbo-linaro/qemu:
  contrib/plugins/bbv.c: Check if file is NULL
  contrib/plugins/uftrace_symbols.py: ignore zero sized symbols

Signed-off-by: Peter Maydell <[email protected]>
2026-03-09 12:15:12 +00:00
Lukas Straub 161e603975 colo: Reuse the return path from migration on primary and secondary side
Use the return-path capability with colo and reuse the opened return path
file on both primary and secondary side.

This fixes a crash in colo where migration_cancel() races with colo closing
s->rp_state.from_dst_file.

Signed-off-by: Lukas Straub <[email protected]>
Reviewed-by: Peter Xu <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-03-09 08:53:34 -03:00
Lukas Straub 64763e8ca6 migration: Keep s->rp_state.from_dst_file open until migration ends
This will be used in the next patch to allow COLO to reuse the return path.

Signed-off-by: Lukas Straub <[email protected]>
Reviewed-by: Peter Xu <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-03-09 08:53:34 -03:00
Lukas Straub b2cbd3d0f9 colo: Use file lock in primary_vm_do_failover()
Take the file lock since s->to_dst_file and s->rp_state.from_dst_file
may be changed in the migration thread.

Signed-off-by: Lukas Straub <[email protected]>
Reviewed-by: Peter Xu <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-03-09 08:53:34 -03:00
Lukas Straub 37c74b1dbb multifd: Fix hang if send thread errors during sync
When a send thread encounters an error (as is the case with yank),
it sets multifd_send_state->exiting and the other threads exit too.
This races with multifd_send_sync_main() which now hangs at
qemu_sem_wait(&p->sem_sync) in multifd_send_sync_main() line 647
as it waits for threads that have exited.

Fix this by kicking the semaphores when exiting the send threads.

I encountered this hang when stress testing the colo unit test,
though I was unable to write a migration test to reliably hit this.

Reviewed-by: Peter Xu <[email protected]>
Signed-off-by: Lukas Straub <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-03-09 08:53:34 -03:00
Lukas Straub 2a402535ba qemu-colo.rst: Simplify the block replication setup
On the primary side we don't actually need the replication
block driver, since it only passes trough all IO.
So simplify the setup and also use 'blockdev-add' instead of
'human-monitor-command'.

This is how my clients use colo in production.

Reviewed-by: Fabiano Rosas <[email protected]>
Signed-off-by: Lukas Straub <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-03-09 08:53:34 -03:00
Lukas Straub eb546b6137 qemu-colo.rst: Add my copyright
I have so far contributed 61 commits to the colo project, waranting
the addition of my copyright to this file.

Reviewed-by: Zhang Chen <[email protected]>
Reviewed-by: Fabiano Rosas <[email protected]>
Signed-off-by: Lukas Straub <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-03-09 08:53:33 -03:00
Lukas Straub 1d8f2e48ff qemu-colo.rst: Miscellaneous changes
Reviewed-by: Fabiano Rosas <[email protected]>
Reviewed-by: Zhang Chen <[email protected]>
Signed-off-by: Lukas Straub <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-03-09 08:53:33 -03:00
Lukas Straub f22952551e Convert colo main documentation to restructuredText
Reviewed-by: Fabiano Rosas <[email protected]>
Reviewed-by: Zhang Chen <[email protected]>
Signed-off-by: Lukas Straub <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
[replaced license boilerplate with SPDX line]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-03-09 08:53:33 -03:00
Lukas Straub c972c3bdb2 migration-test: Add COLO migration unit test
Add a COLO migration test for COLO migration and failover.

Reviewed-by: Fabiano Rosas <[email protected]>
Tested-by: Fabiano Rosas <[email protected]>
Reviewed-by: Peter Xu <[email protected]>
Signed-off-by: Lukas Straub <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
[remove license boilerplate]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-03-09 08:53:33 -03:00
Lukas Straub 9d13dd0a50 colo: Do not hold the BQL while receiving ram state.
We only receive ram into the colo cache here and don't touch anything
else, so the BQL is not needed here.

Move cpu_synchronize_all_states() downwards, before we apply the received
checkpoint. It turns out that qemu_system_reset() already calls it
for us.

Reviewed-by: Peter Xu <[email protected]>
Signed-off-by: Lukas Straub <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-03-09 08:53:33 -03:00
Lukas Straub 604492a991 colo: Hold the BQL while sending ram state
qemu_savevm_state_complete_precopy() requires that BQL is held.

This fixes a crash when running with TCG accel.

Reviewed-by: Peter Xu <[email protected]>
Signed-off-by: Lukas Straub <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-03-09 08:53:32 -03:00
Lukas Straub 32603ba372 colo: Fix crash during device vmstate load
With colo we load device vmstate during each checkpoint, on top of
a vm that was already running. Some devices expect a reset before
loading vmstate on such a previously running vm.

This fixes a crash when using COLO with Q35 machine.

The reset adds 10-20ms overhead to the checkpointing proces in my
testing.

Reviewed-by: Peter Xu <[email protected]>
Signed-off-by: Lukas Straub <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-03-09 08:53:32 -03:00
Lukas Straub 64df66fe8c Call colo_release_ram_cache() after multifd threads terminate
The multifd threads still may access the colo cache, so release it
only after they terminate.

Reviewed-by: Fabiano Rosas <[email protected]>
Reviewed-by: Peter Xu <[email protected]>
Signed-off-by: Lukas Straub <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-03-09 08:53:32 -03:00
Lukas Straub dd67c149e2 multifd: Add COLO support
Like in the normal ram_load() path, put the received pages into the
colo cache and mark the pages in the bitmap so that they will be
flushed to the guest later.

Multifd with COLO is useful to reduce the VM pause time during checkpointing
for latency sensitive workloads. In such workloads the worst-case latency
is especially important.

Also, this is already worth it for the precopy phase as it helps with
converging. Moreover, multifd migration is the preferred way to do migration
nowadays and this allows to use multifd compression with COLO.

Benchmark:
Cluster nodes
 - Intel Xenon E5-2630 v3
 - 48Gb RAM
 - 10G Ethernet
Guest
 - Windows Server 2016
 - 6Gb RAM
 - 4 cores
Workload
 - Upload a file to the guest with SMB to simulate moderate
   memory dirtying
 - Measure the memory transfer time portion of each checkpoint
 - 600ms COLO checkpoint interval

Results
Plain
 idle mean: 4.50ms 99per: 10.33ms
 load mean: 24.30ms 99per: 78.05ms
Multifd-4
 idle mean: 6.48ms 99per: 10.41ms
 load mean: 14.12ms 99per: 31.27ms

Evaluation
While multifd has slightly higher latency when the guest idles, it is
10ms faster under load and more importantly it's worst case latency is
less than 1/2 of plain under load as can be seen in the 99. Percentile.

Co-authored-by: Juan Quintela <[email protected]>
[farosas: changed SoB to coauthored as Juan doesn't own that email address anymore]
Reviewed-by: Fabiano Rosas <[email protected]>
Reviewed-by: Peter Xu <[email protected]>
Signed-off-by: Lukas Straub <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
[removed license boilerplate]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-03-09 08:53:32 -03:00
Lukas Straub 8bfb2f6d09 multifd: Move ram state receive into multifd_ram_state_recv()
This is in preparation for the next patch.

Reviewed-by: Peter Xu <[email protected]>
Reviewed-by: Fabiano Rosas <[email protected]>
Signed-off-by: Lukas Straub <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-03-09 08:53:32 -03:00
Lukas Straub 9489a40184 ram: Remove colo special-casing
We only enter colo state after the precopy migration is finished
so this if is always taken.

Reviewed-by: Fabiano Rosas <[email protected]>
Reviewed-by: Peter Xu <[email protected]>
Signed-off-by: Lukas Straub <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-03-09 08:53:31 -03:00
Lukas Straub af4cee59fa colo: Remove ENABLE_COLO savevm command and mark it as deprecated
No need for it anymore now that x-colo capability is required
on incoming side. There is also no need to send it for backwards
compatibility since we only support COLO with the same version on
both sides.

We mark the command code as deprecated and now error out if such
a unhandled command is encountered in loadvm_process_command().

Reviewed-by: Fabiano Rosas <[email protected]>
Reviewed-by: Peter Xu <[email protected]>
Signed-off-by: Lukas Straub <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-03-09 08:53:31 -03:00
Lukas Straub 3639d94e16 colo: Replace migration_incoming_colo_enabled() with migrate_colo()
Since
121ccedc2b migration: block incoming colo when capability is disabled

x-colo capability needs to be always enabled on the incoming side.
So migration_incoming_colo_enabled() and migrate_colo() are equivalent
with migrate_colo() being easier to reason about since it is always true
during the whole migration.

Reviewed-by: Fabiano Rosas <[email protected]>
Reviewed-by: Peter Xu <[email protected]>
Signed-off-by: Lukas Straub <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-03-09 08:53:31 -03:00
Lukas Straub 663692f0a3 colo: Setup ram cache in normal migration path
Since
121ccedc2b migration: block incoming colo when capability is disabled

x-colo capability needs to be always enabled on the incoming side.
So migration_incoming_colo_enabled() and migrate_colo() are equivalent
with migrate_colo() being easier to reason about since it is always true
during the whole migration.

Use migrate_colo() to initialize the ram cache in the normal migration path.

Reviewed-by: Fabiano Rosas <[email protected]>
Reviewed-by: Peter Xu <[email protected]>
Signed-off-by: Lukas Straub <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-03-09 08:53:31 -03:00
Lukas Straub 9a405226a6 MAINTAINERS: Remove Hailiang Zhang from COLO migration framework
His last email to the mailing list is from December 2021:
https://lore.kernel.org/qemu-devel/[email protected]/

Reviewed-by: Peter Xu <[email protected]>
Reviewed-by: Zhang Chen <[email protected]>
Signed-off-by: Lukas Straub <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-03-09 08:53:30 -03:00
Lukas Straub b543df7693 MAINTAINERS: Add myself as maintainer for COLO migration framework
I am ready to maintain it.

Reviewed-by: Peter Xu <[email protected]>
Reviewed-by: Zhang Chen <[email protected]>
Signed-off-by: Lukas Straub <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-03-09 08:53:30 -03:00
Prasad Pandit 93c8a97f99 migration: introduce MIGRATION_STATUS_FAILING
When migration connection is broken, the QEMU and libvirtd(8)
process on the source side receive TCP connection reset
notification. QEMU sets the migration status to FAILED and
proceeds to migration_cleanup(). Meanwhile, Libvirtd(8) sends
a QMP command to migrate_set_capabilities().

The migration_cleanup() and qmp_migrate_set_capabilities()
calls race with each other. When the latter is invoked first,
since the migration is not running (FAILED), migration
capabilities are reset to false, so during migration_cleanup()
the QEMU process crashes with assertion failure.

Introduce a new migration status FAILING and use it as an
interim status when an error occurs. Once migration_cleanup()
is done, it sets the migration status to FAILED. This helps
to avoid the above race condition and ensuing failure.

Interim status FAILING is set wherever the execution moves
towards migration_cleanup():
  - postcopy_start()
  - migration_thread()
  - migration_cleanup()
  - multifd_send_setup()
  - bg_migration_thread()
  - migration_completion()
  - migration_detect_error()
  - bg_migration_completion()
  - multifd_send_error_propagate()
  - migration_connect_error_propagate()

The migration status finally moves to FAILED and reports an
appropriate error to the user.

Interim status FAILING is _NOT_ set in the following routines
because they do not follow the migration_cleanup() path to the
FAILED state:
  - cpr_exec_cb()
  - qemu_savevm_state()
  - postcopy_listen_thread()
  - process_incoming_migration_co()
  - multifd_recv_terminate_threads()
  - migration_channel_process_incoming()

Reviewed-by: Peter Xu <[email protected]>
Signed-off-by: Prasad Pandit <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-03-09 08:53:30 -03:00
Ross Lagerwall 5a0b889086 xen-hvm: Emit RTC_CHANGE upon TIMEOFFSET ioreq
When the guest writes to the RTC, the write is intercepted and emulated
by Xen and the time difference is broadcasted as a TIMEOFFSET ioreq.
Emit an RTC_CHANGE QMP event when this happens rather than ignoring it
so that something can make use of the information (e.g. the toolstack
can persist it between VM starts).

Signed-off-by: Ross Lagerwall <[email protected]>
Message-ID: <[email protected]>
Acked-by: Anthony PERARD <[email protected]>
Signed-off-by: Anthony PERARD <[email protected]>
2026-03-09 10:48:33 +01:00
Ross Lagerwall 4022a1dcee xen-hvm: Handle framebuffer relocation
It is possible for a guest to relocate the linear framebuffer by writing
to the VGA device's BAR. This causes QEMU to report an error and if the
VM is migrated, the destination QEMU hits an assertion.
The problem is that updating the BAR causes the PCI core code to call
the del region callback followed by the add region callback but the
xen-hvm code ignores the del region call and therefore the subsequent
call to xen_relocate_memory() during the add region callback fails
because the source address is not correct.

Fix it by calling in to xen_remove_from_physmap() in response to a
del region callback for the linear framebuffer so that the subsequent
add region callback succeeds.

Signed-off-by: Ross Lagerwall <[email protected]>
Reviewed-by: Anthony PERARD <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Anthony PERARD <[email protected]>
2026-03-09 10:48:33 +01:00
Liam Merwick f6a6bc7350 hw/xen: Fix trace_xs_node_read() params
When the '--enable-trace-backends=syslog' build option is configured,
the following compilation error is encountered.

In file included from /usr/include/sys/syslog.h:207,
                 from /usr/include/syslog.h:1,
                 from ./trace/trace-hw_xen.h:224,
                 from ../hw/xen/trace.h:1,
                 from ../hw/xen/xen-bus-helper.c:13:
In function ‘syslog’,
    inlined from ‘_nocheck__trace_xs_node_read’ at ../hw/xen/trace-events:41:9,
    inlined from ‘trace_xs_node_read’ at trace/trace-hw_xen.h:903:9,
    inlined from ‘xs_node_read’ at ../hw/xen/xen-bus-helper.c:154:5:
/usr/include/bits/syslog.h:45:3: error: ‘%s’ directive argument is null [-Werror=format-overflow=]
   45 |   __syslog_chk (__pri, __USE_FORTIFY_LEVEL - 1, __fmt, __va_arg_pack ());
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Add a check that 'value' is not null before passing it to trace_xs_node_read().

Fixes: e6cdeee959 ("hw/xen: Add xs_node_read() helper function")
Signed-off-by: Liam Merwick <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Acked-by: Anthony PERARD <[email protected]>
Acked-by: David Woodhouse <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Anthony PERARD <[email protected]>
2026-03-09 10:48:33 +01:00
Peter Maydell 084a6c6e73 Merge tag 'hw-misc-20260308' of https://github.com/philmd/qemu into staging
Misc HW patches

- Remove versioned machines released in QEMU 3.0
- Build various stubs and ACPI objects once
- Pair of bug fixes in ATI VGA model
- Cleanups in 16550A UART model
- Clarify PA-RISC CPU models (adding the PA-8500)
- Various memory leaks / overflows fixed
- MAINTAINERS updates

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCAAdFiEE+qvnXhKRciHc/Wuy4+MsLN6twN4FAmmt+RQACgkQ4+MsLN6t
# wN6Xkg//bSmLBV1gZKx83GqYzebs+EwEau38XNQ7gl3yp13pU8di+Hfem+Lv8Lk+
# ZMMsFCLPQ5xPeggiefxpOu7bUG6YukIA85/XD4fwB8MWddu7qN2jJJuQHHFk8e1A
# T/kQZTIGvpItLQfBPqnXIgElGhmMSgzeHvjKUbXJXI8ZpQPlmBM1HJb363P/GbAy
# 8PIyOcQRfgTen3gQWqoGmft/dWi5XeUsQhB7PIAbB6X9Ix/EOgF+u7SYXnTO6UZY
# xJcjgsWpaVgMh1+gU4w/riZpcr8gJCcbN80lX3hzsBNKwgXCD+v3VMYldQYl5XwR
# R7tpt91gNvTWEnCbIHBFtkdGPD4TZ/kwH1ZrvofCWjx1ogaVrrt0oey713hfszVV
# e3moNlHvK3N4GeOXsV7JqMqFWAlyU6+6A1Dbe6+FV1pa9cxemIE9zyCuGQDjLjG8
# /3NK3S9ncNdw5hEfxz4kZWa4f3egrwULtTSBgpa8dIO3OW8CJUThccrjiKj+F9VT
# rog7XRvmqUFgkAzHqCnXCTk3gCcHbXaDRXQWP7gBwqaDanMgd7wHwofsr4bKWppd
# zFx8FoHRiYvOYe8eRwYtTwYtg/0JfsfOSq9/G6YIs5nqt1OWqHhXpzoIgGpDi1LD
# 8+u0rBpa4dgLPICu5iaaX05Hgyst2sbpnUXZZaV4HMi/qc1PydY=
# =s6PL
# -----END PGP SIGNATURE-----
# gpg: Signature made Sun Mar  8 22:32:52 2026 GMT
# gpg:                using RSA key FAABE75E12917221DCFD6BB2E3E32C2CDEADC0DE
# gpg: Good signature from "Philippe Mathieu-Daudé (F4BUG) <[email protected]>" [full]
# Primary key fingerprint: FAAB E75E 1291 7221 DCFD  6BB2 E3E3 2C2C DEAD C0DE

* tag 'hw-misc-20260308' of https://github.com/philmd/qemu: (49 commits)
  hw/char: Drop disable property of Diva GSP card
  hw/hppa: Avoid leaking a diva-gsp device
  audio/jack: Fix use of qemu_thread_set_name() on macOS
  hw/m68k/mcf_intc: Use qdev input gpios for input IRQs
  ati-vga: Allow setting EDID parameters directly
  hppa: Use 44 bit physical addresses for PA-8700
  hppa: Get physical address space bits from HPPACPUDef
  hppa: Introduce HPPACPUDef
  hw/char/serial: Avoid implicit conversion when tracing
  hw/char/serial: Remove redundant reset
  hw/char/serial: Add constants for Line Control Register
  hw/char/serial: Remove unhelpful comment
  hw/char/serial: Reuse fifo8_num_used()
  hw/char/serial: Prefer fifo8 methods over open-coding
  hw/char/serial: Remove explicit cast from void pointer
  util/fifo8: Make all read-only methods const-correct
  hw/arm/aspeed_ast27x0-{ssp, tsp}: Do not access SerialMM internals directly
  hw/char/{diva-gsp, serial-pci-multi}: Fix deinitialization order
  hw/arm/Kconfig: Fix serial selection for NPCM8XX
  MAINTAINERS: Update the maintainer for the CHRP NVRAM section
  ...

Signed-off-by: Peter Maydell <[email protected]>
2026-03-09 09:39:12 +00:00
Mohamed Mediouni 6ef6a0f04e whpx: i386: remove SIPI trapping
The implementation in Hyper-V works fine and the code
currently present doesn't handle x2APIC correctly anyway, so
remove it and use the implementation in Hyper-V.

Signed-off-by: Mohamed Mediouni <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-03-09 09:11:38 +01:00
Mohamed Mediouni bb7e0a3426 whpx: arm64: enable enlightenments if asked for
Signed-off-by: Mohamed Mediouni <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-03-09 09:11:37 +01:00
Mohamed Mediouni ae9dcd6f26 whpx: make Hyper-V enlightenments configurable
Have them be a machine option instead of a CPU one, to have something available, even if not ideal...

The existing Hyper-V enlightenments configuration mechanism is part of per-CPU configuration, which happens too late for this.

Signed-off-by: Mohamed Mediouni <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-03-09 09:11:37 +01:00
Mohamed Mediouni c3b1cce623 whpx: i386: enable some more enlightenments
Signed-off-by: Mohamed Mediouni <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-03-09 09:11:37 +01:00
Mohamed Mediouni cb02fc2284 target/i386: emulate: LA57 fix
Seen on a Sapphire Rapids box with LA57.

The top level of the pte array is taken for CR3, so there was
one entry too little for 5-level paging.

Signed-off-by: Mohamed Mediouni <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-03-09 09:11:37 +01:00
Mohamed Mediouni 89b624a9f7 whpx: i386: do not enable nested virt when kernel-irqchip=off
This combination is not allowed as of build 26300.7939 and results in:

qemu-system-x86_64.exe: WHPX: Failed to setup partition, hr=c0350005
qemu-system-x86_64.exe: failed to initialize whpx: Invalid argument

Signed-off-by: Mohamed Mediouni <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-03-09 09:11:37 +01:00
Mohamed Mediouni 336a4c6539 hvf: arm: unbreak the x86 build
We don't really have any great choices here, so use the __aarch64__ define to unbreak the x86 build.

Once the CI moves away from macOS 15.1 SDK to... 15.2 even we can get rid of these SME stubs horrible hacks.

Signed-off-by: Mohamed Mediouni <[email protected]
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-03-09 09:11:37 +01:00
Pierrick Bouvier 2d9b12962f target/i386/hvf/hvf.c: fix compilation
../target/i386/hvf/hvf.c:476:31: error: use of undeclared identifier 'cpu'
  476 |     X86CPU *x86_cpu = X86_CPU(cpu);
      |                               ^
../target/i386/hvf/hvf.c:479:24: error: use of undeclared identifier 'cpu'
  479 |     env->cr[0] = rvmcs(cpu->accel->fd, VMCS_GUEST_CR0);
      |                        ^
../target/i386/hvf/hvf.c:480:24: error: use of undeclared identifier 'cpu'
  480 |     env->cr[3] = rvmcs(cpu->accel->fd, VMCS_GUEST_CR3);
      |                        ^
../target/i386/hvf/hvf.c:481:23: error: use of undeclared identifier 'cpu'
  481 |     env->cr[2] = rreg(cpu->accel->fd, HV_X86_CR2);
      |                       ^
../target/i386/hvf/hvf.c:486:31: error: use of undeclared identifier 'cpu'
  486 |     X86CPU *x86_cpu = X86_CPU(cpu);
      |                               ^
../target/i386/hvf/hvf.c:489:11: error: use of undeclared identifier 'cpu'
  489 |     wvmcs(cpu->accel->fd, VMCS_GUEST_CR0, env->cr[0]);
      |           ^
../target/i386/hvf/hvf.c:490:11: error: use of undeclared identifier 'cpu'
  490 |     wvmcs(cpu->accel->fd, VMCS_GUEST_CR3, env->cr[3]);
      |           ^
7 errors generated.

Signed-off-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Mohamed Mediouni <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-03-09 09:03:45 +01:00
Paolo Bonzini 4878c3a43a qemu-coroutine-lock: fix has_waiters()
has_waiters() is testing a reversed condition.  The logic is that
has_waiters() must return true if a qemu_co_mutex_lock_slowpath()
happened:

  qemu_co_mutex_unlock            qemu_co_mutex_lock_slowpath
  -------------------------       -------------------------------
  set handoff                     push to from_push
  memory barrier                  memory barrier
  check has_waiters()             check handoff

which requires it to return true if from_push (or to_pop from a previous
call) are *not* empty.

This was unlikely to cause trouble because it can only happen when the
same CoMutex is used across multiple threads, but it is nevertheless
completely wrong.  The bug would show up as either a NULL-pointer
dereference inside qemu_co_mutex_lock_slowpath(), or a missed wait in
qemu_co_mutex_unlock().

Reported-by: Siteshwar Vashisht <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
2026-03-09 09:03:42 +01:00
Paolo Bonzini ef586b5ad5 xen-block: remove NULL pointer dereference
If params is NULL, xen_block_drive_create calls xen_block_drive_destroy
with drive == NULL.

Reported-by: Siteshwar Vashisht <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
2026-03-09 09:03:41 +01:00
Edgar E. Iglesias 83d1d9a49e hw/xen: xenpvh: Add prop to enable/disable the mapcache
Add a machine property to enable/disable the mapcache.
Default it to enabled for backwards compatibility.

Signed-off-by: Edgar E. Iglesias <[email protected]>
Reviewed-by: Stefano Stabellini <[email protected]>
2026-03-09 03:24:02 +01:00
Edgar E. Iglesias ad0c53fb5b hw/xen-hvm: Add a mapcache arg to xen_register_ioreq()
Add a mapcache argument to xen_register_ioreq() allowing
the caller to optionally disable the mapcache.

All callers still call it with mapcache = true so there's no
functional change yet.

Signed-off-by: Edgar E. Iglesias <[email protected]>
Reviewed-by: Stefano Stabellini <[email protected]>
2026-03-09 03:24:02 +01:00
Edgar E. Iglesias c1d78ba63c physmem: xen: Conditionalize use of the mapcache
Conditionalize use of the mapcache. This is in preparation
to optionally disable the mapcache at runtime.

Signed-off-by: Edgar E. Iglesias <[email protected]>
Acked-by: Peter Xu <[email protected]>
Reviewed-by: Stefano Stabellini <[email protected]>
2026-03-09 03:24:02 +01:00
Edgar E. Iglesias ded5f9a909 xen: mapcache: Add function to check if the mapcache is enabled
Add function to check if the mapcache is enabled.
No functional change.

Signed-off-by: Edgar E. Iglesias <[email protected]>
Reviewed-by: Stefano Stabellini <[email protected]>
2026-03-09 03:24:02 +01:00
Edgar E. Iglesias 3038c84daa xen: mapcache: Assert mapcache existance
Assert that the mapcache was created prior to being used.

Signed-off-by: Edgar E. Iglesias <[email protected]>
Reviewed-by: Stefano Stabellini <[email protected]>
2026-03-09 03:24:02 +01:00
Helge Deller 27c64fa59d hw/char: Drop disable property of Diva GSP card
The "disable" property is not used, so drop it.

Suggested-by: Peter Maydell <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Signed-off-by: Helge Deller <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-08 23:11:14 +01:00
Helge Deller 7624894549 hw/hppa: Avoid leaking a diva-gsp device
Create a Diva-gsp unconditionally on all 64-bit PCI machines.
The A400 usually comes with a Diva card. The C3700 has a built-in
SUPERIO chip, which we haven't implemented yet, so running with an
emulated Diva is the best we can do for now.

Signed-off-by: Helge Deller <[email protected]>
Suggested-by: Peter Maydell <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-08 23:11:14 +01:00
Philippe Mathieu-Daudé 60405776bf audio/jack: Fix use of qemu_thread_set_name() on macOS
Since commit 8f68a33ad4 we get on macOS:

  Audio backends
    CoreAudio support               : YES
    PipeWire support                : NO
    JACK support                    : YES 1.9.22

  ../audio/jackaudio.c:654:12: error: unused function 'qjack_thread_creator' [-Werror,-Wunused-function]
    654 | static int qjack_thread_creator(jack_native_thread_t *thread,
        |            ^~~~~~~~~~~~~~~~~~~~

This is simply due to a missing #ifdef'ry change. Update
so we can use the new qemu_thread_set_name() exposed by
commit 46255cc2be.

Fixes: 8f68a33ad4 ("audio: make jackaudio use qemu_thread_set_name")
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Christian Schoenebeck <[email protected]>
Message-Id: <[email protected]>
2026-03-08 23:11:14 +01:00
Peter Maydell 7134dbcc63 hw/m68k/mcf_intc: Use qdev input gpios for input IRQs
The m68k mcf_intc interrupt controller currently implements its
inbound IRQ lines by calling qemu_allocate_irqs() in mcf_intc_init().
This results in leaks like this:

Direct leak of 2944 byte(s) in 46 object(s) allocated from:
    #0 0x5cf95ec15323 in malloc (/home/pm215/qemu/build/san/qemu-system-m68k+0xf9e323) (BuildId: 18d55ef8ea9856e68ee30802078af5050b8b06c5)
    #1 0x7637c65c5ac9 in g_malloc (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x62ac9) (BuildId: 116e142b9b52c8a4dfd403e759e71ab8f95d8bb3)
    #2 0x5cf95f6b2f27 in object_new_with_type /home/pm215/qemu/build/san/../../qom/object.c:767:15
    #3 0x5cf95f6aa62e in qemu_allocate_irq /home/pm215/qemu/build/san/../../hw/core/irq.c:91:25
    #4 0x5cf95f6aa62e in qemu_extend_irqs /home/pm215/qemu/build/san/../../hw/core/irq.c:79:16
    #5 0x5cf95f5f6d99 in mcf5208evb_init /home/pm215/qemu/build/san/../../hw/m68k/mcf5208.c:310:11

This isn't an important leak, as it is memory we allocate once at
QEMU startup and that has to stay live for the lifetime of the
system.  However it does point at a code improvement.

Modernise this to have the device itself create inbound GPIOs with
qdev_init_gpio_in() that the board can then refer to and wire up
individually.

As the device is used in only a single board, we can update device
and board in a single patch rather than having to try to figure out
some way to change the API more piecemeal.

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-08 23:11:14 +01:00
BALATON Zoltan 1dacf5b9ab ati-vga: Allow setting EDID parameters directly
The EDID generation has some parameters that can be set via properties
but since ati-vga uses i2c-ddc it is only accessible with -global
option. Expose these properties so users can more easily set it via
e.g. -device ati-vga,xres=1024,yres=768.

Signed-off-by: BALATON Zoltan <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-08 23:11:14 +01:00
Anton Johansson 8fefb2fd60 hppa: Use 44 bit physical addresses for PA-8700
This is in line with the PA-8700 specification which demands 44 bits.

However, this change breaks the SeaBIOS functional tests as the firmware
assumes 40 bit physical addresses.  Therefore, change the functional
tests to instead run on an A400 which has the expected physical address
space size.

Reviewed-by: Helge Deller <[email protected]>
Signed-off-by: Anton Johansson <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-08 23:11:11 +01:00
Anton Johansson 1a80a03a40 hppa: Get physical address space bits from HPPACPUDef
Signed-off-by: Anton Johansson <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-08 23:11:08 +01:00
Anton Johansson dd6bee2707 hppa: Introduce HPPACPUDef
Restructures the CPU class heirarchy to clarify model names and allow
for per-model configuration options via HPPACPUDef. 32-bit HPPA is
assumed to run a PA-7300LC, and 64-bit assumed to run a PA-8700.
A new PA-8500 model is added, which will later be used by the A400
machine.  All CPU models are made into children of the now abstract
TYPE_HPPA_CPU base class.

Two fields are added to HPPACPUDef describing the size of the physical
address space, and whether or not the CPU uses the PA-RISC 2.0
architecture.  The latter was previously a field in CPUHPPAState.

phys_addr_bits is currently set but unused, and will be used in the
following commit.  Likewise, PA-8700 is moved to use 44 bit physical
addresses in a followup commit to not break bisection.

References to "hppa/hppa64" models in test cases are also updated.

Reviewed-by: Helge Deller <[email protected]>
Signed-off-by: Anton Johansson <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-08 23:11:04 +01:00
Bernhard Beschow 12ef587e2a hw/char/serial: Avoid implicit conversion when tracing
On 64 bit targets, the MemoryRegion API passes an address and a value as
uint64_t, so use that for tracing. Keep the uint8_t for reading since
this is what the device model produces. On targets with less than 64
bits, uint64_t is wide enough to avoid narrowing.

Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Bernhard Beschow <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-08 23:08:42 +01:00
Bernhard Beschow a8a77671b5 hw/char/serial: Remove redundant reset
There is no need to invoke the reset method in realize since the reset
framework will do so anyway before the machine starts.

Signed-off-by: Bernhard Beschow <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-08 23:08:42 +01:00
Bernhard Beschow 336af956e8 hw/char/serial: Add constants for Line Control Register
Substitute some magic numbers by named constants for slightly improved
readability.

Signed-off-by: Bernhard Beschow <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-08 23:08:42 +01:00
Bernhard Beschow 1a847b228b hw/char/serial: Remove unhelpful comment
There is no "is_load" flag and one can tell from the method name what
the method does. Remove this unhelpful comment.

Signed-off-by: Bernhard Beschow <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-08 23:08:42 +01:00
Bernhard Beschow 9f8caee699 hw/char/serial: Reuse fifo8_num_used()
Avoids accessing private fields of struct Fifo8. Now, TYPE_SERIAL only
accesses struct Fifo8 through its methods.

Signed-off-by: Bernhard Beschow <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-08 23:08:42 +01:00
Bernhard Beschow cbac82dbb7 hw/char/serial: Prefer fifo8 methods over open-coding
Use fifo8_is_empty() and fifo8_is_full() to improve readability of the
code.

Signed-off-by: Bernhard Beschow <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-08 23:08:42 +01:00
Bernhard Beschow 4b376e710e hw/char/serial: Remove explicit cast from void pointer
A void pointer asks for being casted, so C allows for omitting the
explicit cast. Take advantage of that.

Signed-off-by: Bernhard Beschow <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-08 23:08:42 +01:00
Bernhard Beschow 6cbfd6008d util/fifo8: Make all read-only methods const-correct
Allows these methods to be used in const contexts, i.e. where the parent
of the fifo itself is const. This is in particular useful for Rust code.

Signed-off-by: Bernhard Beschow <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-08 23:08:42 +01:00
Bernhard Beschow 79c0b57251 hw/arm/aspeed_ast27x0-{ssp, tsp}: Do not access SerialMM internals directly
SerialMM inherits from SysBusDevice and exposes the memory region by
means of sysbus_mmio_get_region(). Use that in order to avoid accessing
implementation details of SerialMM.

Reviewed-by: Jamin Lin <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Bernhard Beschow <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-08 23:08:42 +01:00
Bernhard Beschow 7e68ad18f5 hw/char/{diva-gsp, serial-pci-multi}: Fix deinitialization order
The memory region is owned by the device being unrealized, so must be
removed from the mapping before unrealizing.

Fixes: d66bbea4e0 ("serial: add 2x + 4x pci variant")
Fixes: 2740747084 ("hw/char: Add emulation of Diva GSP PCI management boards")
Reported-by: Peter Maydell <[email protected]>
Signed-off-by: Bernhard Beschow <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-08 23:08:42 +01:00
Bernhard Beschow ff0f5cefeb hw/arm/Kconfig: Fix serial selection for NPCM8XX
CONFIG_SERIAL selects the internal TYPE_SERIAL device which is akin to
an "IP block" that needs to be integrated with glue logic. In case of
NPCM8XX this glue logic is TYPE_SERIAL_MM which the code uses already.
Fix Kconfig to select CONFIG_SERIAL_MM which matches TYPE_SERIAL_MM.

Fixes: ae0c4d1a12 ("hw/arm: Add NPCM8XX SoC")
Signed-off-by: Bernhard Beschow <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-08 23:08:42 +01:00
Thomas Huth 85c0c6729d MAINTAINERS: Update the maintainer for the CHRP NVRAM section
I am not involved in the ppc machines anymore (the pseries machine was
the reason why I took over maintainership of the CHRP NVRAM code in the
past), so it does not make much sense that I'm still listed here as the
maintainer.
The CHRP NVRAM code is used by the mac99 / g3beige ppc machines and
some Sparc machines, too, where Mark is the maintainer, so I asked him
whether he would be interested in being listed as the maintainer here,
and fortunately, he agreed! Thanks, Mark!

Signed-off-by: Thomas Huth <[email protected]>
Acked-by: Mark Cave-Ayland <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-08 23:08:42 +01:00
Jim MacArthur 9e0de45d41 hw/net/xilinx_axienet: Prevent writes to PHY Identification registers
There are other registers in the PHY model which should be partially or
entirely read-only, but this solves the immediate issue.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3297

Signed-off-by: Jim MacArthur <[email protected]>
Reviewed-by: Edgar E. Iglesias <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-08 23:08:42 +01:00
Gerd Hoffmann b28c3ad1d6 hw/uefi: add variable digest to vmstate
Add digest to vmstate if needed.  Clear digest before
loading vmstate to make sure it is initialized.

Fixes: db1ecfb473 ("hw/uefi: add var-service-vars.c")
Signed-off-by: Gerd Hoffmann <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-08 23:08:42 +01:00
Akihiko Odaki a3b23b946c ui/cocoa: Do not automatically zoom for HiDPI
Cocoa automatically zooms for a HiDPI display like Retina and makes
the display blurry. Revert the automatic zooming.

Signed-off-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Acked-by: Marc-André Lureau <[email protected]>
Message-ID: <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-08 23:08:42 +01:00
Thomas Huth 0be66f6e77 MAINTAINERS: Replace @tuxfamily.org address
Tuxfamily.org has had many outages in the recent years and will likely
go away in the near future:

 https://forum.tuxfamily.org/post/3381/#p3381

Thus replace my @tuxfamily.org address with another one that is more
reliable and hopefully will survive longer.

Signed-off-by: Thomas Huth <[email protected]>
Reviewed-by: Gustavo Romero <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-08 23:08:42 +01:00
Peter Maydell 6595a8d5d1 hw/net/xilinx_ethlite: Check for oversized TX packets
The xilinx_ethlite network device wasn't checking that the TX packet
size set by the guest was within the size of its dual port RAM, with
the effect that the guest could get it to read off the end of the RAM
block.

Check the length.  There is no provision in this very simple device
for reporting errors, so as with various RX errors we just report via
tracepoint.

This lack of length check has been present since the device was first
introduced, though the code implementing the tx path has changed
somewhat since then.

Cc: [email protected]
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3317
Fixes: b43848a100 ("xilinx: Add ethlite emulation")
Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Alistair Francis <[email protected]>
Reviewed-by: Edgar E. Iglesias <[email protected]>
Message-ID: <[email protected]>
[PMD: renamed size -> tx_size to avoid shadow=compatible-local error]
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-08 23:08:42 +01:00
Chad Jablonski 1246965b3e ati-vga: Consolidate dirty region tracking in ati_2d_blt
Both supported ROPs follow the same memory set dirty logic.
This consolidates that logic to remove the duplication.

Signed-off-by: Chad Jablonski <[email protected]>
Reviewed-by: BALATON Zoltan <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-08 23:08:42 +01:00
Chad Jablonski 4df53270ae ati-vga: Remove dst_x/y updates after blit
The Mobility M6 register reference (DST_HEIGHT_WIDTH) states that dst_y is
updated after a blit but this appears to not be the case.

Hardware testing revealed that both the R128 and R100 do not update
dst_x or dst_y after a blit, regardless of the source. This removes
the update.

Signed-off-by: Chad Jablonski <[email protected]>
Reviewed-by: BALATON Zoltan <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-08 23:08:41 +01:00
Chad Jablonski 1b079e183d ati-vga: Add scissor clipping register support
Implement read and write operations on SC_TOP_LEFT, SC_BOTTOM_RIGHT,
and SRC_SC_BOTTOM_RIGHT registers. These registers are also updated
when the src and/or dst clipping fields on DP_GUI_MASTER_CNTL are set
to default clipping.

Scissor clipping is used when rendering text in X.org. The r128 driver
sends host data much wider than is necessary to draw a glyph and cuts it
down to size using clipping before rendering. The actual clipping
implementation follows in a future patch.

This also includes a very minor refactor of the combined
default_sc_bottom_right field in the registers struct to
default_sc_bottom and default_sc_right. This was done to
stay consistent with the other scissor registers and prevent repeated
masking and extraction.

Signed-off-by: Chad Jablonski <[email protected]>
Reviewed-by: BALATON Zoltan <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-08 23:08:41 +01:00
Chad Jablonski 18e2382172 ati-vga: Implement foreground and background color register writes
These are straightforward 32-bit register write handlers. They're
necessary for a future patch which will use them for color expansion
from monochrome host data transfers.

Signed-off-by: Chad Jablonski <[email protected]>
Reviewed-by: BALATON Zoltan <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-08 23:08:41 +01:00
Chad Jablonski 3ab35ff519 ati-vga: Latch src and dst pitch and offset on master_cntl default
Hardware testing on the Rage 128 confirms that (SRC/DST)_OFFSET,
and (SRC/DST)_PITCH are latched when (SRC/DST)_PITCH_OFFSET_CNTL bits
in DP_GUI_MASTER_CNTL are set to "default".

The earlier approach looked at the state of the (SRC/DST)_PITCH_OFFSET_CNTL
bits when offset and pitch registers were used. This meant that when
(SRC/DST)_PITCH_OFFSET_CNTL was reset to "leave alone" the old values
stored in the registers would return. This is not how the real hardware
works.

Signed-off-by: Chad Jablonski <[email protected]>
Reviewed-by: BALATON Zoltan <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-08 23:08:41 +01:00
Chad Jablonski 5c531f80f6 ati-vga: Read aliased values from DP_GUI_MASTER_CNTL
DP_GUI_MASTER_CNTL aliases several fields from DP_DATATYPE and DP_MIX.
These were being written correctly but not returned on a read of
DP_GUI_MASTER_CNTL.

Signed-off-by: Chad Jablonski <[email protected]>
Reviewed-by: BALATON Zoltan <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-08 23:08:41 +01:00
Chad Jablonski 12ea77b4c2 ati-vga: Fix DST_PITCH and SRC_PITCH reads
Reading DST_PITCH and SRC_PITCH on the Rage 128 is broken. The read
handlers attempt to construct the value from pitch and tile bits in
the register state but mistakenly AND them instead of ORing them. This
means the pitch is always zero on read.

Signed-off-by: Chad Jablonski <[email protected]>
Reviewed-by: BALATON Zoltan <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-08 23:08:41 +01:00
Chad Jablonski 601eb8f8ac ati-vga: Fix framebuffer mapping by using hardware-correct aperture sizes
Rage 128 cards always request 64MB for their linear (framebuffer)
aperture and R100 cards always request 128MB. This is regardless
of the amount of physical VRAM on the board. The following are results
from real hardware tests:

Card                              VRAM    PCI BAR0   CONFIG_MEMSIZE  CONFIG_APER_SIZE  AGP_APER_OFFSET
-----------------------           ----    --------   --------------  ----------------  ---------------
Rage 128 Pro Ultra TF             32MB     64MB       0x02000000      0x02000000        0x02000000
Rage 128 RF/SG AGP                16MB     64MB       0x01000000      0x02000000        0x02000000
Radeon R100 QD [Radeon 7200]      64MB    128MB       0x04000000      0x04000000        N/A
Radeon RV100 QY [Radeon 7000/VE]  32MB    128MB       0x02000000      0x04000000        N/A

Previously the linear aperture (BAR0) would match the VRAM size.
This discrepancy caused issues with the X.org and XFree86 r128 drivers.
These drivers apply a mask of 0xfc000000 (2^26 = 64MB) to the linear
aperture address. If that address is not on a 64MB boundary the
framebuffer points to an incorrect memory location.

Testing shows that the Radeon R100 also has a BAR0 larger than VRAM
(128MB in this case) and the X.org radeon driver also masks to 64MB.

For Rage 128, CONFIG_APER_SIZE also differs from the previous value and
the behavior stated in the documentation. The Rage 128 register guide
states that it should contain the size of the VRAM + AGP memory. The cards
tested above show that this isn't the case. These tests also included
enabling/disabling AGP with 8MB of memory. It didn't change the
contents of CONFIG_APER_SIZE.

For both Rage 128 and R100 the CONFIG_APER_SIZE is half of the PCI BAR0 size.

Signed-off-by: Chad Jablonski <[email protected]>
Reviewed-by: BALATON Zoltan <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-08 23:08:41 +01:00
Daniel P. Berrangé b1feb17eaa hw/i386: drop unused PC_CPU_MODEL_IDS macro
This is redundant since the 2.4 machine types were dropped.

Fixes: 4c82e7b34b
Signed-off-by: Daniel P. Berrangé <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-08 23:08:41 +01:00
David Hamilton 250d97681a hw/misc/ivshmem-pci: Handle error from kvm_irqchip_add_irqfd_notifier_gsi()
The return value of kvm_irqchip_add_irqfd_notifier_gsi() was being
ignored. Propagate the error to the caller via errp.

Also change setup_interrupt() to return bool to follow QEMU error
handling conventions, making error checks at call sites simpler.

Resolves the TODO comment at the call site.

Signed-off-by: David Hamilton <[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-08 23:08:41 +01:00
Philippe Mathieu-Daudé 566ca14890 hw/s390x/s390-pci-vfio: 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é <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Reviewed-by: Farhan Ali<[email protected]>
Message-Id: <[email protected]>
2026-03-08 23:08:41 +01:00
Philippe Mathieu-Daudé 8adc13d0c5 semihosting: Build stubs once
Move stubs to the global stub_ss[] source set. These files
are now built once for all binaries, instead of one time
per system binary.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <[email protected]>
2026-03-08 23:08:41 +01:00
Philippe Mathieu-Daudé 2fa22ab7fe hw/*: Build stubs once
Move stubs to the global stub_ss[] source set. These files
are now built once for all binaries, instead of one time
per system binary.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <[email protected]>
2026-03-08 23:08:41 +01:00
Philippe Mathieu-Daudé 8e5f6bc4e0 hw/net: Build stubs once
Move stubs to the global stub_ss[] source set. These files
are now built once for all binaries, instead of one time
per system binary.

qmp-norocker.c only contains stubs, rename it accordingly.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <[email protected]>
2026-03-08 23:08:41 +01:00
Philippe Mathieu-Daudé fb1d68d1d6 hw/acpi: Build stubs once
Move stubs to the global stub_ss[] source set. These files
are now built once for all binaries, instead of one time
per system binary.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Reviewed-by: Igor Mammedov <[email protected]>
Message-Id: <[email protected]>
2026-03-08 23:08:41 +01:00
Philippe Mathieu-Daudé 5752af7b58 hw/nvram: Build fw_cfg-acpi.c once
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Reviewed-by: Igor Mammedov <[email protected]>
Message-Id: <[email protected]>
2026-03-08 23:08:41 +01:00
Philippe Mathieu-Daudé 1c99c7d91e hw/acpi: Always link QOM interfaces with system binaries
Now that acpi_interface.c only contains QOM interfaces,
unconditionally link it with system binaries, regardless
of whether CONFIG_ACPI is set or not. It is now easier to
deselect hardware models depending on ACPI.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Reviewed-by: Igor Mammedov <[email protected]>
Message-Id: <[email protected]>
2026-03-08 23:08:41 +01:00
Philippe Mathieu-Daudé b5d09c11d1 hw/acpi: Move qbus_build_aml() function out of acpi_interface.c
acpi_interface.c should only register QOM interfaces. Move
the qbus_build_aml() function to aml-build.c with the other
AML build-related helpers.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Reviewed-by: Igor Mammedov <[email protected]>
Message-Id: <[email protected]>
2026-03-08 23:08:41 +01:00
Philippe Mathieu-Daudé 75e92ebbdf hw/acpi: Move acpi_send_event() function out of acpi_interface.c
acpi_interface.c should only register QOM interfaces. Move
the acpi_send_event() function to core.c with the other
event handlers, and its declaration in 'hw/acpi/acpi.h'.

Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Reviewed-by: Igor Mammedov <[email protected]>
Message-Id: <[email protected]>
2026-03-08 23:08:41 +01:00
Philippe Mathieu-Daudé 5b7814c0fc meson: Include various directories providing stubs before libqemuutil
Stubs are provided by libqemuutil. We want to use the generic meson
machinery to provide stubs once, instead of per sub-directories. Move
the 'subdir' calls earlier so when these directories are processed
they can add units to the global stub_ss[] source set.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <[email protected]>
2026-03-08 23:08:41 +01:00
Philippe Mathieu-Daudé 0a44e965e8 hw/core/machine: Remove the hw_compat_3_0[] array
The hw_compat_3_0[] array was only used by the pc-q35-3.0
and pc-i440fx-3.0 machines, which got removed. Remove it.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Message-Id: <[email protected]>
2026-03-08 23:08:41 +01:00
Philippe Mathieu-Daudé 804cca26dc target/i386/kvm: Remove X86CPU::hyperv_synic_kvm_only field
The X86CPU::hyperv_synic_kvm_only boolean (see commit 9b4cf107b0
"hyperv: only add SynIC in compatible configurations") was only set
in the pc_compat_3_0[] array, via the 'x-hv-synic-kvm-only=on'
property. We removed all machines using that array, lets remove that
property and all the code around it.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Message-Id: <[email protected]>
2026-03-08 23:08:41 +01:00
Philippe Mathieu-Daudé cc60846298 hw/i386/pc: Remove pc_compat_3_0[] array
The pc_compat_3_0[] array was only used by the pc-q35-3.0
and pc-i440fx-3.0 machines, which got removed. Remove it.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Message-Id: <[email protected]>
2026-03-08 23:08:41 +01:00
Philippe Mathieu-Daudé b2e0f64776 hw/i386/pc: Remove deprecated pc-q35-3.0 and pc-i440fx-3.0 machines
These machines has been supported for a period of more than 6 years.
According to our versioned machine support policy (see commit
ce80c4fa6f "docs: document special exception for machine type
deprecation & removal") they can now be removed.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Message-Id: <[email protected]>
2026-03-08 23:08:41 +01:00
Akihiko Odaki 1a1cfc0a32 contrib/plugins/bbv.c: Check if file is NULL
The file pointer can be NULL when e.g., opening the file failed.
vcpu_interval_exec() already implements a NULL-pointer check, but
plugin_exit() misses it. Handle the condition by adding the missing
check to plugin_exit().

Fixes: 0d279bec0f ("contrib/plugins: Add a plugin to generate basic block vectors")
Signed-off-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Pierrick Bouvier <[email protected]>
2026-03-07 12:59:36 -08:00
Pierrick Bouvier ca144c21dd contrib/plugins/uftrace_symbols.py: ignore zero sized symbols
When using llvm-addr2line in replacement of addr2line, it will output
zero sized symbols, which can shadow other binaries depending on where
their location is (happens with arm-trusted-firmware and its different
binaries). Thus, ignore those symbols.

Reviewed-by: Pierrick Bouvier <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Pierrick Bouvier <[email protected]>
2026-03-07 12:59:36 -08:00
Peter Maydell 1ae4271ab8 Merge tag 'pull-11.0-virtio-gpu-updates-060326-1' of https://gitlab.com/stsquad/qemu into staging
virtio-gpu updates (resolution, error handling, fences, native context)

  - support per-head resolution definitions
  - don't disable scanouts on sdl and gtk when display refreshed
  - take care not confuse virgl with switching contexts
  - use dmabuf to import textures when we can
  - keep virtio BH processing to main-loop
  - improve error handling for fence creation
  - support async fences
  - add support for DRM native context
  - update virtio-gpu docs
  - remove superfluous memory region enabling
  - validate mapping offsets
  - destroy vrigl resources on reset
  - support mapping hostmem blobs with map_fixed

# -----BEGIN PGP SIGNATURE-----
#
# iQEzBAABCgAdFiEEZoWumedRZ7yvyN81+9DbCVqeKkQFAmmrEysACgkQ+9DbCVqe
# KkQhugf/eab7ZSMfQzOArOjKcr+SSXiFE3wXg9HKRrbZx/yHRAiQ/Fv9Qx7uH8Q5
# Q7/A1l9WN/iwv2/jHWJv7gSOrYaRYIL0vXn/oriVNncZx779o56YhTIEYcSZ+zaF
# lHwLHpnzi2jcrmlhV49Mp1+tUH9U3OXwWzAUKTjhJxnLomoBwwcBaftbbBUj2cmS
# a3t1SMeIEq1hX7fCDnkBUfkUGAmPbk/vp/oXxF5SmBJIiyKB+O9jbx408hMQsNFo
# vulBmD2a5EOPwvBC0K6v+9aAbUicOFHwoQyeFvM8HTObMPj6+F40fvq+STNre22X
# Ln9a+tB/nq+7auX1D9VZSCkH7vzGRw==
# =x8lu
# -----END PGP SIGNATURE-----
# gpg: Signature made Fri Mar  6 17:47:23 2026 GMT
# gpg:                using RSA key 6685AE99E75167BCAFC8DF35FBD0DB095A9E2A44
# gpg: Good signature from "Alex Bennée (Master Work Key) <[email protected]>" [full]
# Primary key fingerprint: 6685 AE99 E751 67BC AFC8  DF35 FBD0 DB09 5A9E 2A44

* tag 'pull-11.0-virtio-gpu-updates-060326-1' of https://gitlab.com/stsquad/qemu:
  virtio-gpu: Support mapping hostmem blobs with map_fixed
  virtio-gpu: Destroy virgl resources on virtio-gpu reset
  virtio-gpu: Replace finish_unmapping with mapping_state
  virtio-gpu: Validate hostmem mapping offset
  virtio-gpu: Remove superfluous memory_region_set_enabled()
  docs/system: virtio-gpu: Document host/guest requirements
  docs/system: virtio-gpu: Update Venus link
  docs/system: virtio-gpu: Add link to Mesa VirGL doc
  virtio-gpu: Support DRM native context
  virtio-gpu: Support asynchronous fencing
  virtio-gpu: Handle virgl fence creation errors
  virtio-gpu: Ensure BHs are invoked only from main-loop thread
  ui/sdl2: Implement dpy dmabuf functions
  ui/sdl2: Restore original context after new context creation
  ui/gdk: Restore original context after new context creation
  ui/egl: Don't change bound GL context when creating new context
  ui/sdl2: Don't disable scanout when display is refreshed
  ui/gtk: Don't disable scanout when display is refreshed
  virtio-gpu: Fix scanout dmabuf cleanup during resource destruction
  Support per-head resolutions with virtio-gpu

Signed-off-by: Peter Maydell <[email protected]>
2026-03-07 11:22:16 +00:00
Peter Maydell d41b9b44ac Merge tag 'for-upstream' of https://gitlab.com/kmwolf/qemu into staging
Block layer patches

- Wire up 'flat' mode also for 'query-block'
- Never drop BLOCK_IO_ERROR with action=stop for rate limiting
- qcow2: Add keep_data_file command-line option
- vmdk: fix OOB read in vmdk_read_extent()
- curl: fix concurrent completion handling
- nfs: Fix deadlock
- mirror: Fix missed dirty bitmap writes during startup
- throttle-groups: fix deadlock with iolimits and muliple iothreads

# -----BEGIN PGP SIGNATURE-----
#
# iQJFBAABCgAvFiEE3D3rFZqa+V09dFb+fwmycsiPL9YFAmmrHbgRHGt3b2xmQHJl
# ZGhhdC5jb20ACgkQfwmycsiPL9b+ng/+P4B3q+Rrvb5WWrY8fro/3kzSqGAHjKeL
# QqEU8zywck5EorzK0H2f8BskxqXJ/LAe7ut4rFGqCA85l/eyWT7OhGm/DHnO/oI8
# /nU5r800/ZpvKn9HqK5+TSkswYQ6RmmMF9ZYIfYdB/JqPAmVmvbcjdqASVRT4PZ+
# v9QUKY309LDoaWm+vO/f0oPyxhog6yDHVh/rGhDkCOMyNExFyvfvAeLVuu+99Nzz
# GFxleM7JyHdVmIErbKRNp2Z/uVSQvlOg5uecI3IZnc2QUbACQWWc97PCP199JzZ+
# HaEq8tP+/TQZSsXEYKHmxYx4AyzCIu15qDmpnfhnoA9MC80P+eLrHJ5sXOsT6S32
# AyTLIE6KKLImtLyG6TZV05G127c7ekrMbY8OfY21ocACUstr4q6MY1J6ZCcLQRMZ
# E0BZR0CEOYtImrx0wr1XR0/q7SceiIaDcwFuPkHKz2akRS7bq9KH1RfxHYPpBJiX
# nkkLtilV4s/OlhrsoGJeq44C7jZA2MdrgouxNiPe+08CFeJra5wQybC7ZIYqknx6
# D/Eu4Y6KwMbyfnMd/4F0kbzHv9h8R+ri2hHUqfKEtl2pNTqe8JEpsPmn+yMpuRe4
# Cl66DFs0OzcONiUBNJVdGg0dm0jtIyCEo2am1MAJUgGkwYKxtgUQLsouSJS1d4EP
# iDe9pZmlytg=
# =kPKk
# -----END PGP SIGNATURE-----
# gpg: Signature made Fri Mar  6 18:32:24 2026 GMT
# gpg:                using RSA key DC3DEB159A9AF95D3D7456FE7F09B272C88F2FD6
# gpg:                issuer "[email protected]"
# gpg: Good signature from "Kevin Wolf <[email protected]>" [full]
# Primary key fingerprint: DC3D EB15 9A9A F95D 3D74  56FE 7F09 B272 C88F 2FD6

* tag 'for-upstream' of https://gitlab.com/kmwolf/qemu:
  iotests/244: Add test cases for keep_data_file
  iotests/common.filter: Sort keep_data_file
  qcow2: Simplify size round-up in co_create_opts
  qcow2: Add keep_data_file command-line option
  block/nfs: Do not enter coroutine from CB
  block: Never drop BLOCK_IO_ERROR with action=stop for rate limiting
  block/throttle-groups: fix deadlock with iolimits and muliple iothreads
  mirror: Fix missed dirty bitmap writes during startup
  block/curl: fix concurrent completion handling
  hmp_nbd_server_start: Don't ask for backing image data
  block: Wire up 'flat' mode also for 'query-block'
  block/vmdk: fix OOB read in vmdk_read_extent()

Signed-off-by: Peter Maydell <[email protected]>
2026-03-06 18:57:12 +00:00
Dmitry Osipenko 4eb0aace85 virtio-gpu: Support mapping hostmem blobs with map_fixed
Support mapping virgl blobs to a fixed location of a hostmem memory
region using new virglrenderer MAP_FIXED API.

This new feature closes multiple problems for virtio-gpu on QEMU:

- Having dedicated memory region for each mapped blob works notoriously
slow due to QEMU's memory region software design built around RCU that
isn't optimized for frequent removal of the regions

- KVM isn't optimized for a frequent slot changes too

- QEMU/KVM has a limit for a total number of created memory regions,
crashing QEMU when limit is reached

This patch makes virtio-gpu-gl to pre-create a single anonymous memory
region covering whole hostmem area to which blobs will be mapped using
the MAP_FIXED API.

Not all virgl resources will support mapping at a fixed memory address. For
them, we will continue to create individual nested memory sub-regions. In
particular, vrend resources may not have MAP_FIXED capability.

Venus and DRM native contexts will largely benefit from the MAP_FIXED
feature in terms of performance and stability improvement.

Tested-by: Yiwei Zhang <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected]>
Signed-off-by: Dmitry Osipenko <[email protected]>
Message-ID: <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alex Bennée <[email protected]>
2026-03-06 17:27:40 +00:00
Dmitry Osipenko bd9258917f virtio-gpu: Destroy virgl resources on virtio-gpu reset
Properly destroy virgl resources on virtio-gpu reset to not leak resources
on a hot reboot of a VM.

Suggested-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Reviewed-by: Akihiko Odaki <[email protected]>
Signed-off-by: Dmitry Osipenko <[email protected]>
Message-ID: <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alex Bennée <[email protected]>
2026-03-06 17:27:40 +00:00
Dmitry Osipenko 4611333538 virtio-gpu: Replace finish_unmapping with mapping_state
Allow virtio_gpu_virgl_unmap_resource_blob() to be invoked while async
unmapping is in progress. Do it in preparation to improvement of virtio-gpu
resetting that will require this change.

Suggested-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Reviewed-by: Akihiko Odaki <[email protected]>
Signed-off-by: Dmitry Osipenko <[email protected]>
Message-ID: <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alex Bennée <[email protected]>
2026-03-06 17:27:40 +00:00
Dmitry Osipenko d0803a90c8 virtio-gpu: Validate hostmem mapping offset
Check hostmem mapping boundaries originated from guest.

Suggested-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Reviewed-by: Akihiko Odaki <[email protected]>
Signed-off-by: Dmitry Osipenko <[email protected]>
Message-ID: <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alex Bennée <[email protected]>
2026-03-06 17:27:40 +00:00
Dmitry Osipenko 276a6c2919 virtio-gpu: Remove superfluous memory_region_set_enabled()
There is no need to explicitly enable/disable memory region when it's
added or deleted respectively. Remove superfluous set_enabled() calls
for consistency.

Suggested-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Reviewed-by: Alex Bennée <[email protected]>
Signed-off-by: Dmitry Osipenko <[email protected]>
Message-ID: <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alex Bennée <[email protected]>
2026-03-06 17:27:40 +00:00
Alex Bennée 13a97a1963 docs/system: virtio-gpu: Document host/guest requirements
This attempts to tidy up the VirtIO GPU documentation to make the list
of requirements clearer. There are still a lot of moving parts and the
distros have some catching up to do before this is all handled
automatically.

Cc: Sergio Lopez Pascual <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected]>
Acked-by: Pierre-Eric Pelloux-Prayer <[email protected]>
Reviewed-by: Yiwei Zhang <[email protected]>
Signed-off-by: Dmitry Osipenko <[email protected]>
[[email protected]: Extended and corrected doc]
Message-ID: <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alex Bennée <[email protected]>
2026-03-06 17:27:40 +00:00
Dmitry Osipenko c12998c2fd docs/system: virtio-gpu: Update Venus link
Change virtio-gpu Venus link, pointing it at the Mesa Venus
documentation instead of the protocol. The Mesa doc provides more
information and also has a link to the protocol.

Suggested-by: Akihiko Odaki <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected]>
Acked-by: Pierre-Eric Pelloux-Prayer <[email protected]>
Reviewed-by: Yiwei Zhang <[email protected]>
Signed-off-by: Dmitry Osipenko <[email protected]>
Message-ID: <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alex Bennée <[email protected]>
2026-03-06 17:27:40 +00:00
Dmitry Osipenko d847a5a53f docs/system: virtio-gpu: Add link to Mesa VirGL doc
Extend virtio-gpu documentation with a link to the Mesa VirGL
documentation.

Suggested-by: Akihiko Odaki <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected]>
Acked-by: Pierre-Eric Pelloux-Prayer <[email protected]>
Reviewed-by: Yiwei Zhang <[email protected]>
Signed-off-by: Dmitry Osipenko <[email protected]>
Message-ID: <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alex Bennée <[email protected]>
2026-03-06 17:27:40 +00:00
Dmitry Osipenko 893598209f virtio-gpu: Support DRM native context
Add support for DRM native contexts to VirtIO-GPU. DRM context is enabled
using a new virtio-gpu-gl device option "drm_native_context=on".

Unlike Virgl and Venus contexts that operate on application API level,
DRM native contexts work on a kernel UAPI level. This lower level results
in a lightweight context implementations that yield better performance.

Reviewed-by: Akihiko Odaki <[email protected]>
Acked-by: Michael S. Tsirkin <[email protected]>
Tested-by: Alex Bennée <[email protected]>
Acked-by: Pierre-Eric Pelloux-Prayer <[email protected]>
Reviewed-by: Yiwei Zhang <[email protected]>
Tested-by: Yiwei Zhang <[email protected]>
Signed-off-by: Dmitry Osipenko <[email protected]>
Message-ID: <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alex Bennée <[email protected]>
2026-03-06 17:27:40 +00:00
Dmitry Osipenko 6698eae8a1 virtio-gpu: Support asynchronous fencing
Support asynchronous fencing feature of virglrenderer. It allows Qemu to
handle fence as soon as it's signalled instead of periodically polling
the fence status. This feature is required for enabling DRM context
support in Qemu because legacy fencing mode isn't supported for DRM
contexts in virglrenderer.

Reviewed-by: Akihiko Odaki <[email protected]>
Acked-by: Michael S. Tsirkin <[email protected]>
Tested-by: Alex Bennée <[email protected]>
Reviewed-by: Alex Bennée <[email protected]>
Acked-by: Pierre-Eric Pelloux-Prayer <[email protected]>
Reviewed-by: Yiwei Zhang <[email protected]>
Tested-by: Yiwei Zhang <[email protected]>
Signed-off-by: Dmitry Osipenko <[email protected]>
Message-ID: <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alex Bennée <[email protected]>
2026-03-06 17:27:40 +00:00
Dmitry Osipenko 17bf86af36 virtio-gpu: Handle virgl fence creation errors
Print out error messages when virgl fence creation fails to aid debugging
of the fence-related bugs.

Reviewed-by: Akihiko Odaki <[email protected]>
Acked-by: Michael S. Tsirkin <[email protected]>
Tested-by: Alex Bennée <[email protected]>
Acked-by: Pierre-Eric Pelloux-Prayer <[email protected]>
Reviewed-by: Yiwei Zhang <[email protected]>
Tested-by: Yiwei Zhang <[email protected]>
Signed-off-by: Dmitry Osipenko <[email protected]>
Message-ID: <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alex Bennée <[email protected]>
2026-03-06 17:27:40 +00:00
Dmitry Osipenko 235f9b3638 virtio-gpu: Ensure BHs are invoked only from main-loop thread
QEMU's display GL core is tied to main-loop thread and virtio-gpu
interacts with display while processing GPU commands. Virtio-gpu BHs
work in generic AIO context that can be invoked on vCPU thread, while
GL and UI toolkits are bound to the main-loop thread.

Make virtio-gpu BHs use iohandler AIO context that is handled in a
main-loop thread only.

 0  SDL_GL_MakeCurrent() (libSDL3)
 1  SDL_GL_MakeCurrent_REAL() (libSDL2)
 2  sdl2_gl_make_context_current() (ui/sdl2-gl.c:201)
 3  make_current() (virglrenderer.c:639)
 4  vrend_finish_context_switch() (vrend_renderer.c:11630)
 5  vrend_hw_switch_context() (vrend_renderer.c:11613)
 6  vrend_renderer_force_ctx_0() (vrend_renderer.c:12986)
 7  virgl_renderer_force_ctx_0() (virglrenderer.c:460)
 8  virtio_gpu_virgl_process_cmd() (virtio-gpu-virgl.c:1013)
 9  virtio_gpu_process_cmdq() (virtio-gpu.c:1050)
 10 virtio_gpu_gl_handle_ctrl() (virtio-gpu-gl.c:86)
 11 aio_bh_poll() (util/async.c)
 12 aio_poll() (util/aio-posix.c)
 13 blk_pwrite() (block/block-gen.c:1985)
 14 pflash_update() (pflash_cfi01.c:396)
 15 pflash_write() (pflash_cfi01.c:541)
 16 memory_region_dispatch_write() (system/memory.c:1554)
 17 flatview_write() (system/physmem.c:3333)
 18 address_space_write() (system/physmem.c:3453)
 19 kvm_cpu_exec() (accel/kvm/kall-all.c:3248)
 20 kvm_vcpu_thread_fn() (accel/kvm/kaccel-ops.c:53)

Cc: [email protected]
Signed-off-by: Dmitry Osipenko <[email protected]>
Message-ID: <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alex Bennée <[email protected]>
2026-03-06 17:27:40 +00:00
Pierre-Eric Pelloux-Prayer 52053b7e0a ui/sdl2: Implement dpy dmabuf functions
If EGL is used, we can rely on dmabuf to import textures without
doing copies.

To get this working on X11, we use the existing SDL hint:
SDL_HINT_VIDEO_X11_FORCE_EGL (because dmabuf can't be used with GLX).

Reviewed-by: Akihiko Odaki <[email protected]>
Acked-by: Michael S. Tsirkin <[email protected]>
Tested-by: Alex Bennée <[email protected]>
Signed-off-by: Pierre-Eric Pelloux-Prayer <[email protected]>
Reviewed-by: Yiwei Zhang <[email protected]>
Signed-off-by: Dmitry Osipenko <[email protected]>
Message-ID: <[email protected]>
[AJB: ifdef CONFIG_OPENGL/CONFIG_GBM for non-linux hosts]
Message-ID: <[email protected]>
Signed-off-by: Alex Bennée <[email protected]>
2026-03-06 17:27:40 +00:00
Dmitry Osipenko 2b0e2edc83 ui/sdl2: Restore original context after new context creation
SDL API changes GL context to a newly created GL context, which differs
from other GL providers that don't switch context. Change SDL backend to
restore the original GL context. This allows Qemu's virtio-gpu to support
new virglrenderer async-fencing feature for Virgl contexts, otherwise
virglrenderer's vrend creates a fence-sync context on the Qemu's
main-loop thread that erroneously stays in-use by the main-loop after
creation, not allowing vrend's fence-sync thread switch to this new
context that belongs to it.

Reviewed-by: Akihiko Odaki <[email protected]>
Acked-by: Michael S. Tsirkin <[email protected]>
Tested-by: Alex Bennée <[email protected]>
Acked-by: Pierre-Eric Pelloux-Prayer <[email protected]>
Reviewed-by: Yiwei Zhang <[email protected]>
Signed-off-by: Dmitry Osipenko <[email protected]>
Message-ID: <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alex Bennée <[email protected]>
2026-03-06 17:27:40 +00:00
Dmitry Osipenko 47ab600668 ui/gdk: Restore original context after new context creation
Get currently bound GL context when creating new GL context and restore
it after the creation for consistency with behavior expected by virglrenderer
that assumes context-creation doesn't switch context.

Reviewed-by: Marc-André Lureau <[email protected]>
Signed-off-by: Dmitry Osipenko <[email protected]>
Message-ID: <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alex Bennée <[email protected]>
2026-03-06 17:27:40 +00:00
Dmitry Osipenko 3beb637032 ui/egl: Don't change bound GL context when creating new context
Don't change bound GL context when creating new GL context for consistency
with behavior expected by virglrenderer that assumes context-creation doesn't
switch context. eglCreateContext() doesn't require GL context to be bound
when it's invoked. Update qemu_egl_create_context() to spawn GL sub-contexts
from a given shared GL context instead of a currently-bound context.

Signed-off-by: Dmitry Osipenko <[email protected]>
Message-ID: <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alex Bennée <[email protected]>
2026-03-06 17:27:40 +00:00
Dmitry Osipenko 5bb16eb707 ui/sdl2: Don't disable scanout when display is refreshed
Display refreshment is invoked by a timer and it erroneously disables
the active scanout if it happens to be invoked after scanout has been
enabled. This offending scanout-disable race condition with a timer
can be easily hit when Qemu runs with a disabled vsync by using SDL or
GTK displays (with vblank_mode=0 for GTK). Refreshment of display's
content shouldn't disable the active display. Fix it by keeping the
scanout's state unchanged when display is redrawn.

Reviewed-by: Akihiko Odaki <[email protected]>
Acked-by: Michael S. Tsirkin <[email protected]>
Tested-by: Alex Bennée <[email protected]>
Acked-by: Pierre-Eric Pelloux-Prayer <[email protected]>
Reviewed-by: Yiwei Zhang <[email protected]>
Signed-off-by: Dmitry Osipenko <[email protected]>
Message-ID: <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alex Bennée <[email protected]>
2026-03-06 17:27:40 +00:00
Dmitry Osipenko 8acd000280 ui/gtk: Don't disable scanout when display is refreshed
Display refreshment is invoked by a timer and it erroneously disables
the active scanout if it happens to be invoked after scanout has been
enabled. This offending scanout-disable race condition with a timer
can be easily hit when Qemu runs with a disabled vsync by using SDL or
GTK displays (with vblank_mode=0 for GTK). Refreshment of display's
content shouldn't disable the active display. Fix it by keeping the
scanout's state unchanged when display is redrawn.

Reviewed-by: Akihiko Odaki <[email protected]>
Acked-by: Michael S. Tsirkin <[email protected]>
Tested-by: Alex Bennée <[email protected]>
Acked-by: Pierre-Eric Pelloux-Prayer <[email protected]>
Reviewed-by: Yiwei Zhang <[email protected]>
Signed-off-by: Dmitry Osipenko <[email protected]>
Message-ID: <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alex Bennée <[email protected]>
2026-03-06 17:27:40 +00:00
Dongwon Kim 48f12f521d virtio-gpu: Fix scanout dmabuf cleanup during resource destruction
When a virtio-gpu resource is destroyed, any associated udmabuf must be
properly torn down. Currently, the code may leave dangling references
to dmabuf file descriptors in the scanout primary buffers.

This patch updates virtio_gpu_fini_udmabuf to:
1. Iterate through all active scanouts.
2. Identify dmabufs that match the resource's file descriptor.
3. Close the dmabuf and invalidate the resource's FD reference to
   prevent use-after-free or double-close scenarios.
4. Finally, trigger the underlying udmabuf destruction.

This ensures that the display backend does not attempt to access
memory or FDs that have been released by the guest or the host.

Cc: Alex Bennée <[email protected]>
Cc: Gerd Hoffmann <[email protected]>
Cc: Marc-André Lureau <[email protected]>
Cc: Vivek Kasireddy <[email protected]>
Signed-off-by: Dongwon Kim <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alex Bennée <[email protected]>
2026-03-06 17:27:33 +00:00
Andrew Keesler d3a4969dc5 Support per-head resolutions with virtio-gpu
In 454f4b0f, we started down the path of supporting separate
configurations per display head (e.g., you have 2 heads - one with
EDID name "AAA" and the other with EDID name "BBB").

In this change, we add resolution to this configuration surface (e.g.,
you have 2 heads - one with resolution 111x222 and the other with
resolution 333x444).

  -display vnc=localhost:0,id=aaa,display=vga,head=0 \
  -display vnc=localhost:1,id=bbb,display=vga,head=1 \
  -device '{"driver":"virtio-vga",
            "max_outputs":2,
            "id":"vga",
            "outputs":[
              {
                 "name":"AAA",
                 "xres":111,
                 "yres":222
              },
              {
                 "name":"BBB",
                 "xres":333,
                 "yres":444
              }
            ]}'

Here is the behavior matrix of the current resolution configuration
surface (xres/yres) with the new resolution configuration surface
(outputs[i].xres/yres).

Note - we use "xres" and "yres" (instead of, say, "width" and "height")
to match analogous virtio_gpu_base_conf.xres/yres.

Case: !(xres || yres) && !(outputs[i].has_xres && outputs[i].has_yres)
Behavior: current behavior - outputs[0] enabled with default xres/yres

Case: (xres || yres) && !(outputs[i].has_xres && outputs[i].has_yres)
Behavior: current behavior - outputs[0] enabled with xres/yres

Case: outputs[i].has_xres && outputs[i].has_yres
Behavior: new behavior - outputs[i] enabled with outputs[i].xres/yres

Case: outputs[i].has_xres != outputs[i].has_yres
Behavior: error

Signed-off-by: Andrew Keesler <[email protected]>
Acked-by: Markus Armbruster <[email protected]>
Message-ID: <[email protected]>
[AJB: fix format strings for size_t in error_setg]
Message-ID: <[email protected]>
Signed-off-by: Alex Bennée <[email protected]>
2026-03-06 17:25:47 +00:00
Hanna Czenczek a844ad5da2 iotests/244: Add test cases for keep_data_file
Add various test cases around keep_data_file to the existing data_file
test suite 244.

Signed-off-by: Hanna Czenczek <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
[kwolf: Added prealloc=full to the test]
Reviewed-by: Kevin Wolf <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
2026-03-06 17:45:16 +01:00
Hanna Czenczek 21b4e03b7d iotests/common.filter: Sort keep_data_file
Sort the new keep_data_file creation option together with data_file and
data_file_raw.

Signed-off-by: Hanna Czenczek <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
Reviewed-by: Kevin Wolf <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
2026-03-06 17:45:16 +01:00
Hanna Czenczek 695d481a12 qcow2: Simplify size round-up in co_create_opts
Use the now-existing qcow2_opts pointer to simplify the size rounding up
code.

Signed-off-by: Hanna Czenczek <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
Reviewed-by: Kevin Wolf <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
2026-03-06 17:45:15 +01:00
Hanna Czenczek 910451bc5b qcow2: Add keep_data_file command-line option
Add a command-line-only option to prevent overwriting the file specified
as external data file.

This option is only available on the qemu-img create command line, not
via blockdev-create, as it makes no sense there: That interface
separates file creation and formatting, so where the external data file
attached to a newly formatted qcow2 node comes from is completely up to
the user.

Implementation detail: Enabling this option will not only not overwrite
the external data file, but also assume it already exists, for two
reasons:
- It is simpler than checking whether the file exists, and only skipping
  creating it when it does not.  It is therefore also less error-prone,
  i.e. we can never accidentally overwrite an existing file because we
  made some mistake in checking whether it exists.
- I think it makes sense from a user's perspective: You set this option
  when you want to use an existing data file, and you unset it when you
  want a new one.  Getting an error when you expect to use an existing
  data file seems to me a nice warning that something is not right.

Signed-off-by: Hanna Czenczek <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
[kwolf: Removed redundant has_data_file_raw check]
Reviewed-by: Kevin Wolf <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
2026-03-06 17:45:15 +01:00
Hanna Czenczek 1d6610099b block/nfs: Do not enter coroutine from CB
The reasoning I gave for why it would be safe to call aio_co_wake()
despite holding the mutex was wrong: It is true that the current request
will not re-acquire the mutex, but a subsequent request in the same
coroutine can.  Because the mutex is a non-coroutine mutex, this will
result in a deadlock.

Therefore, we must either not enter the coroutine here (only scheduling
it), or release the mutex around aio_co_wake().  I opt for the former,
as it is the behavior prior to the offending commit, and so seems safe
to do.

Fixes: deb35c129b
       ("nfs: Run co BH CB in the coroutine’s AioContext")
Buglink: https://gitlab.com/qemu-project/qemu/-/issues/2622#note_2965097035
Cc: [email protected]
Signed-off-by: Hanna Czenczek <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Kevin Wolf <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
2026-03-06 17:45:15 +01:00
Kevin Wolf 544ddbb637 block: Never drop BLOCK_IO_ERROR with action=stop for rate limiting
Commit 2155d2dd introduced rate limiting for BLOCK_IO_ERROR to emit an
event only once a second. This makes sense for cases in which the guest
keeps running and can submit more requests that would possibly also fail
because there is a problem with the backend.

However, if the error policy is configured so that the VM is stopped on
errors, this is both unnecessary because stopping the VM means that the
guest can't issue more requests and in fact harmful because stopping the
VM is an important state change that management tools need to keep track
of even if it happens more than once in a given second. If an event is
dropped, the management tool would see a VM randomly going to paused
state without an associated error, so it has a hard time deciding how to
handle the situation.

This patch disables rate limiting for action=stop by not relying on the
event type alone any more in monitor_qapi_event_queue_no_reenter(), but
checking action for BLOCK_IO_ERROR, too. If the error is reported to the
guest or ignored, the rate limiting stays in place.

Fixes: 2155d2dd7f ('block-backend: per-device throttling of BLOCK_IO_ERROR reports')
Signed-off-by: Kevin Wolf <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
2026-03-06 17:45:15 +01:00
Dmitry Guryanov d481617765 block/throttle-groups: fix deadlock with iolimits and muliple iothreads
Details: https://gitlab.com/qemu-project/qemu/-/issues/3144

The function schedule_next_request is called with tg->lock held and
it may call throttle_group_co_restart_queue, which takes
tgm->throttled_reqs_lock, qemu_co_mutex_lock may leave current
coroutine if other iothread has taken the lock. If the next
coroutine will call throttle_group_co_io_limits_intercept - it
will try to take the mutex tg->lock which will never be released.

Here is the backtrace of the iothread:
Thread 30 (Thread 0x7f8aad1fd6c0 (LWP 24240) "IO iothread2"):
 #0  futex_wait (futex_word=0x5611adb7d828, expected=2, private=0) at ../sysdeps/nptl/futex-internal.h:146
 #1  __GI___lll_lock_wait (futex=futex@entry=0x5611adb7d828, private=0) at lowlevellock.c:49
 #2  0x00007f8ab5a97501 in lll_mutex_lock_optimized (mutex=0x5611adb7d828) at pthread_mutex_lock.c:48
 #3  ___pthread_mutex_lock (mutex=0x5611adb7d828) at pthread_mutex_lock.c:93
 #4  0x00005611823f5482 in qemu_mutex_lock_impl (mutex=0x5611adb7d828, file=0x56118289daca "../block/throttle-groups.c", line=372) at ../util/qemu-thread-posix.c:94
 #5  0x00005611822b0b39 in throttle_group_co_io_limits_intercept (tgm=0x5611af1bb4d8, bytes=4096, direction=THROTTLE_READ) at ../block/throttle-groups.c:372
 #6  0x00005611822473b1 in blk_co_do_preadv_part (blk=0x5611af1bb490, offset=15972311040, bytes=4096, qiov=0x7f8aa4000f98, qiov_offset=0, flags=BDRV_REQ_REGISTERED_BUF) at ../block/block-backend.c:1354
 #7  0x0000561182247fa0 in blk_aio_read_entry (opaque=0x7f8aa4005910) at ../block/block-backend.c:1619
 #8  0x000056118241952e in coroutine_trampoline (i0=-1543497424, i1=32650) at ../util/coroutine-ucontext.c:175
 #9  0x00007f8ab5a56f70 in ?? () at ../sysdeps/unix/sysv/linux/x86_64/__start_context.S:66 from target:/lib64/libc.so.6
 #10 0x00007f8aad1ef190 in ?? ()
 #11 0x0000000000000000 in ?? ()

The lock is taken in line 386:
(gdb) p tg.lock
$1 = {lock = {__data = {__lock = 2, __count = 0, __owner = 24240, __nusers = 1, __kind = 0, __spins = 0, __elision = 0, __list = {__prev = 0x0, __next = 0x0}},
    __size = "\002\000\000\000\000\000\000\000\260^\000\000\001", '\000' <repeats 26 times>, __align = 2}, file = 0x56118289daca "../block/throttle-groups.c",
  line = 386, initialized = true}

The solution is to use tg->lock to protect both ThreadGroup fields and
ThrottleGroupMember.throttled_reqs. It doesn't seem to be possible
to use separate locks because we need to first manipulate ThrottleGroup
fields, then schedule next coroutine using throttled_reqs and after than
update token field from ThrottleGroup depending on the throttled_reqs
state.

Signed-off-by: Dmitry Guryanov <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Hanna Czenczek <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
2026-03-06 17:45:15 +01:00
Peter Maydell 900682c572 Merge tag 'pull-target-arm-20260306-2' of https://gitlab.com/pm215/qemu into staging
* Remove deprecated 'highbank' and 'midway' machines
 * hw/arm: Add missing dependencies for STM32F405 SoC
 * hw/arm/smmuv3-accel: Read and propagate host vIOMMU events
 * Minor MAINTAINERS updates
 * target/arm: Improve logging of migration errors due to system
   register mismatches between source and destination
 * hw/arm/aspeed_gpio: Don't leak string in aspeed_gpio_init()
 * tests/qtest/iommu-smmuv3-test: Free QPCIDevice
 * chardev: Fix various sanitizer detected leaks
 * tests/qtest/test-x86-cpuid-compat: Free allocated memory
 * tests/qtest/qos-test: Plug a couple of leaks
 * hw/arm/smmuv3: Fix various minor bugs
 * hvf/arm: expose FEAT_SME2 to guest if available
 * hvf/arm: drop unneeded includes

# -----BEGIN PGP SIGNATURE-----
#
# iQJNBAABCAA3FiEE4aXFk81BneKOgxXPPCUl7RQ2DN4FAmmq+VsZHHBldGVyLm1h
# eWRlbGxAbGluYXJvLm9yZwAKCRA8JSXtFDYM3lA0D/0YGr838hSBG1ugMp3WCgF6
# AjPUems5HMjuX1LBJwVF3cAekDTVrsXklqiSQHeOYnV9bq5wu87evRo7+uiOUZ3v
# i6nxFup8ncdbGBEUqDZHxafNDuBXfOwtcKvmE4eFy+QTDv63Mb58c4v3U2/Rq7/k
# EHaIzziHThU/pj4XLcsrY3DPVl87zw8q409J8UBcGTBicQli1bO1dxv8O3fbnarF
# /TKhdWwPmAHmMhGA7p9WOvWiXQGNUDo2M84yK3o5HxEysZB3FKcJgQauVjvvFLrt
# 9nJUtZlV09sYGX0PKavNhpxSy08hnwxrrPzlbWC2WB7nvRYl5IJsO8wjZgqEwSBt
# 2EZ0IznT8YyvL+KSIo+9TvbNqRBWTU/TUbTLnARDj76/kDXvImM/tRtQC9k+jZ6j
# afk2IdTPM+L5maTFIahiAf04xWPVPdRax6UCQ/WppOX6rRqZwRyf8JHx1Y0n3uoD
# r7kdRtCOkHtg4HC30oAnHF8A5FrCWrxDEahFSyH4MR0FOf+NLoixLmDbk05lb5V5
# jw9JMVQq1W2bOketJord7SqztVq64w1LVUR33WN4SF+m8HVBo7n4GOzVMVue0Zqy
# sjMWlv95M9ExlPMhwrvRSL5a1MkU1R2tVAYuuHwfKMETs5NzIeCQp4C7Fx6T7UMu
# 3LvSjYWJZ9X64XG+hyhO2A==
# =gP/m
# -----END PGP SIGNATURE-----
# gpg: Signature made Fri Mar  6 15:57:15 2026 GMT
# gpg:                using RSA key E1A5C593CD419DE28E8315CF3C2525ED14360CDE
# gpg:                issuer "[email protected]"
# gpg: Good signature from "Peter Maydell <[email protected]>" [ultimate]
# gpg:                 aka "Peter Maydell <[email protected]>" [ultimate]
# gpg:                 aka "Peter Maydell <[email protected]>" [ultimate]
# gpg:                 aka "Peter Maydell <[email protected]>" [ultimate]
# Primary key fingerprint: E1A5 C593 CD41 9DE2 8E83  15CF 3C25 25ED 1436 0CDE

* tag 'pull-target-arm-20260306-2' of https://gitlab.com/pm215/qemu: (36 commits)
  hvf: hvf-all: stop including hvf_arm.h
  hw/arm: virt: remove hvf_arm.h include
  hvf/arm: expose FEAT_SME2 to guest if available
  hvf/arm: handle FEAT_SME2 migration
  hw/arm/smmuv3: Fix CFGI_CD handling when stage-1 is unsupported
  hw/arm/smmuv3: Correct SMMUEN field name in CR0
  hw/arm/smmuv3-common: Fix incorrect reserved mask for SMMU CR0 register
  tests/qtest/qos-test: Plug a couple of leaks
  tests/qtest/test-x86-cpuid-compat: Free allocated memory
  chardev: Consolidate yank registration
  chardev: Don't attempt to unregister yank function more than once
  chardev: Fix QIOChannel refcount
  tests/qtest/iommu-smmuv3-test: Free QPCIDevice
  hw/arm/aspeed_gpio: Don't leak string in aspeed_gpio_init()
  scripts/lsan_suppressions.txt: Add more leaks
  scripts: Move lsan_suppressions.txt out of oss-fuzz subdir
  target/arm/machine: Fix detection of unknown incoming cpregs
  target/arm/machine: Trace all register mismatches
  target/arm/machine: Trace cpreg names which do not match on migration
  target/arm/kvm: Tweak print_register_name() for arm64 system register
  ...

Signed-off-by: Peter Maydell <[email protected]>
2026-03-06 15:58:24 +00:00
Mohamed Mediouni 7b6a3c3349 hvf: hvf-all: stop including hvf_arm.h
We don't need this target-specific header in this
target-agnostic source file.

Signed-off-by: Mohamed Mediouni <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-03-06 13:27:24 +00:00
Mohamed Mediouni 6df5285c52 hw/arm: virt: remove hvf_arm.h include
We don't need anything in this header, so drop the include.

Signed-off-by: Mohamed Mediouni <[email protected]>
[PMM: updated commit message]
Reviewed-by: Peter Maydell <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-03-06 13:26:44 +00:00
Manos Pitsidianakis 55cd59813f hvf/arm: expose FEAT_SME2 to guest if available
Starting from M4 cores and MacOS 15.2 SDK, HVF can virtualise FEAT_SME2.

Signed-off-by: Manos Pitsidianakis <[email protected]>
Reviewed-by: Mohamed Mediouni <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-03-06 13:08:09 +00:00
Manos Pitsidianakis 170de38560 hvf/arm: handle FEAT_SME2 migration
SME2 support adds the following state for HVF guests:

- Vector registers Z0, ... , Z31 (introduced by FEAT_SVE but HVF does
  not support it)
- Predicate registers P0, .., P15 (also FEAT_SVE)
- ZA register
- ZT0 register
- PSTATE.{SM,ZA} bits (SVCR pseudo-register)
- SMPRI_EL1 which handles the PE's priority in the SMCU
- TPIDR2_EL0 the thread local ID register for SME

Signed-off-by: Manos Pitsidianakis <[email protected]>
Reviewed-by: Mohamed Mediouni <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-03-06 13:08:09 +00:00
Peter Maydell 2940018747 Merge tag 'pr-hw_virtio_single_binary-20260305' of https://gitlab.com/pbo-linaro/qemu into staging
Changes:
- [PATCH v2 0/6] hw/virtio/virtio-access.h: remove target specific code (=?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= <[email protected]>)
  Link: https://lore.kernel.org/qemu-devel/[email protected]

# -----BEGIN PGP SIGNATURE-----
#
# iQGzBAABCgAdFiEEZrmU7KFPfy5auggff5BUDQoc0A8FAmmp8GkACgkQf5BUDQoc
# 0A/elwv+JgnJ1yLXP2ZTCB59tGT0TJuvTVf//h13YIxbeGdvfcoTLocCRyGix7pu
# rMbT5gaKBypF/BEqmeF5ST3dRTQ6h4P79eF4e3LILFhgs41kNltgLl6yXx9m1jtg
# g+b3bDX2Jlb9Qhvud72+pfGGUsIcQB68XBpkz9BS+R9Qy/kylvMAtr8MgUHFiwnU
# 5lq1W99DBZZ1kzR9H1jrJGge7s/OcDTA8/Lb6Qje3SYw3HR6yzWL4OXiDNh/UilV
# p4hVXGbDPDrpM7GUVPfU/A5vwVedeXnXdPsXxFqunvbKcCgiuLX8YMNikmBGqyL/
# VrRhQPKvd13o9uVLQH3hVKQA73A0xcyK/NvZVRQh9RoqGbHZKgaAAHl5way8w6ch
# /XPHhBzFxLYlnCGulDczio0vxHX7baxP6eOjD8vyb5v5DU0eoW1hoeQL5s0MPOKK
# ggd1XvJaygcYmxPPqQyg9OgTBxyFSMVd4oQvpo73+kYOvBYTMbspKNxgGegpErra
# fxOkl2Ue
# =EQ+o
# -----END PGP SIGNATURE-----
# gpg: Signature made Thu Mar  5 21:06:49 2026 GMT
# gpg:                using RSA key 66B994ECA14F7F2E5ABA081F7F90540D0A1CD00F
# gpg: Good signature from "Pierrick Bouvier <[email protected]>" [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: 66B9 94EC A14F 7F2E 5ABA  081F 7F90 540D 0A1C D00F

* tag 'pr-hw_virtio_single_binary-20260305' of https://gitlab.com/pbo-linaro/qemu:
  hw/virtio/: make all compilation units common
  hw/virtio/virtio-qmp: make compilation unit common
  hw/virtio/vhost-user: make compilation unit common
  hw/virtio: Inline virtio_access_is_big_endian()
  hw/virtio: Simplify virtio_access_is_big_endian()
  hw/virtio: Add virtio_vdev_is_legacy()

Signed-off-by: Peter Maydell <[email protected]>
2026-03-06 12:55:47 +00:00
Peter Maydell 2d3f78269a Merge tag 'pr-plugins-20260305' of https://gitlab.com/pbo-linaro/qemu into staging
Changes:
- [PATCH v7 0/8] Enable PC diversion via the plugin API (Florian Hofhammer <[email protected]>)
  Link: https://lore.kernel.org/qemu-devel/[email protected]
- [PATCH trivial] plugins: add missing callbacks to version history (Florian Hofhammer <[email protected]>)
  Link: https://lore.kernel.org/qemu-devel/[email protected]
- [PATCH 0/3] tests/tcg/plugins: Fix sanitizer issues (Peter Maydell <[email protected]>)
  Link: https://lore.kernel.org/qemu-devel/[email protected]

# -----BEGIN PGP SIGNATURE-----
#
# iQGzBAABCgAdFiEEZrmU7KFPfy5auggff5BUDQoc0A8FAmmp7N8ACgkQf5BUDQoc
# 0A8TfwwAiuLmdRmUIN8Gfd+3ELdamAMb60hXGIh3mV9OqztnYQ3AsmTCvdPqOeq/
# TZePhmDoiPOR7ZyKactGvcF3QmDrqmrcphQOggc8ufQsKM5nLfWIRT/jitVivD0/
# 9HRhEBTQm6QXQmQdkT+AcLJUhyB/WN2dDXajjBIWTjgHmTjPALHT76NmGdhNNhRE
# SPgvXWMucc441C9hbqQOKLBfAxH9v0an2ztgqeb3NlxKcVkBTOMvVcJOLTW7SBNK
# DGxXwc6z9kgp8BhPURKsoBQzDEZajWO6wm+6m11zuCEsuedU/zaH5RKEekjZn/xD
# 5aC7ZfuNpqtT2NGey0b59ehE6Ct6WKLR/dNfh9qgBg6/mmTixi8ozyOntGy700d3
# D2vvuetrPc1RO25Y5Yaa2KOzxq8IQMnxg5cflW+oMsA/Z13VdzC4BoIWOPnyVHOv
# pBLGpe9131iBjfneHDR9ls6WeOzo6ig2xiQ6s0iIUTI8MMnen/u+r6RBlN0IOGTz
# wV2d0/8X
# =pmiX
# -----END PGP SIGNATURE-----
# gpg: Signature made Thu Mar  5 20:51:43 2026 GMT
# gpg:                using RSA key 66B994ECA14F7F2E5ABA081F7F90540D0A1CD00F
# gpg: Good signature from "Pierrick Bouvier <[email protected]>" [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: 66B9 94EC A14F 7F2E 5ABA  081F 7F90 540D 0A1C D00F

* tag 'pr-plugins-20260305' of https://gitlab.com/pbo-linaro/qemu:
  tests/tcg/plugins/patch: Free read_data in patch_hwaddr()
  tests/tcg/plugins/mem: Correct hash iteration code in plugin_exit()
  tests/tcg/plugins/mem: Don't access unaligned memory
  plugins: add missing callbacks to version history
  tests/tcg/plugins: test register accesses
  plugins: prohibit writing to read-only registers
  plugins: add read-only property for registers
  tests/tcg: add tests for qemu_plugin_set_pc API
  plugins: add PC diversion API function
  linux-user: make syscall emulation interruptible
  plugins: add flag to specify whether PC is rw
  plugins/core: clamp syscall arguments if target is 32-bit

Signed-off-by: Peter Maydell <[email protected]>
2026-03-06 12:55:16 +00:00
Peter Maydell 7176f5d574 Merge tag 'pull-aspeed-20260305' of https://github.com/legoater/qemu into staging
aspeed queue:

* Add I3C support to QEMU, add an dummy I3C device and extend the
  Aspeed I3C controller
* Update test ASPEED OpenBMC SDK v11.01
* Fix DMA64 address handling in Aspeed I2C model (AST2700 SoC)

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCAAdFiEEoPZlSPBIlev+awtgUaNDx8/77KEFAmmpwnEACgkQUaNDx8/7
# 7KEPWw/9FAi0Mq+mxcUIv+rgsw26hGtBX9c/j0WKmUr0hFZiB9SC2kMZRASS19sX
# umGhp/0SrlG/Bp9wbEY/yH0SIwf+g/dGfndJ8YS7/XR2vcL5UEdhagJ6et9He16q
# RBMiTqATtkLJaZoCh6R7C/Nsv6f+MORsGJHox2jS1vsiewj/1aHDeRSJM3tgC5vc
# GLocWvIpowfb6bXCO383rm6b4M0qYDj5bqvpxiINDRbUqyMuVZukqeV9Bxb2NDk4
# Mq7KT9RbQy/Hr8m+ERzLRqJzB+0iqc/zmjosAt0BdG04uijfsc6v5WWqshLnoHY5
# 2rKIbRwP3HVLqeJNcrUWZDskPMk9OXD+xHSjMkRNIOlEqHhZ5j6nXFlJkHrA6j9U
# qI3dDQYGSHsjMDgollykvNIUkI+1hP8n4fuhVz4wkjHo4hJlyj+HixE2e0hpfidB
# DqLFrZL3EiLvVo/HXBWGHbIXM9LW7wKF3iYQslkALQtqf2wUhndgg0Zf4FXJrETh
# 8gSq0py2GYPohQpfsi8Q6K46FFdefRAYdJn644OJ1QO084VBs4U7Ue9qUiKIC8dp
# QWAO6uKCEc+gvhXik6zCrQ7a+C52Snb4iPrwl0uX8qdhMuvd0Vl3z5K/8tdQGwWZ
# 8K55a0/rFIusZ9whFVeih/k6Xv+TvNtjuEivp7vJ5b5ZQq/JXfM=
# =k1Jl
# -----END PGP SIGNATURE-----
# gpg: Signature made Thu Mar  5 17:50:41 2026 GMT
# gpg:                using RSA key A0F66548F04895EBFE6B0B6051A343C7CFFBECA1
# gpg: Good signature from "Cédric Le Goater <[email protected]>" [full]
# gpg:                 aka "Cédric Le Goater <[email protected]>" [full]
# Primary key fingerprint: A0F6 6548 F048 95EB FE6B  0B60 51A3 43C7 CFFB ECA1

* tag 'pull-aspeed-20260305' of https://github.com/legoater/qemu: (38 commits)
  tests/functional/aarch64/test_aspeed_ast2700fc: Update test ASPEED OpenBMC SDK v11.01
  tests/functional/aarch64/test_aspeed_ast2700a2: Update test ASPEED OpenBMC SDK v11.01
  tests/functional/aarch64/test_aspeed_ast2700a1: Update test ASPEED OpenBMC SDK v11.01
  tests/functional/arm/test_aspeed_ast2600_sdk_515: Update test ASPEED OpenBMC SDK v11.01
  tests/functional/arm/test_aspeed_ast2600_sdk_otp: Update test ASPEED OpenBMC SDK v11.01
  tests/functional/arm/test_aspeed_ast2600_sdk: Update test ASPEED OpenBMC SDK v11.01
  tests/functional/arm/test_aspeed_ast2500_sdk_515: Update test ASPEED OpenBMC SDK v11.01
  tests/functional/arm/test_aspeed_ast2500_sdk: Update test ASPEED OpenBMC SDK v11.01
  tests/functional/arm/test_aspeed_ast1060: Update test aspeed-zephyr-project v03.05
  tests/functional/arm/test_aspeed_ast1030: Update test ASPEED Zephyr SDK v03.06
  hw/i3c/mock-i3c-target: Simplify GETMRL byte extraction logic
  hw/i3c/core: Initialize num_sent in i3c_send_byte()
  hw/i3c/mock-i3c-target: Set num_sent in TX callback to fix trace reporting
  hw/i3c/dw-i3c: Use ROUND_UP() for RX buffer allocation alignment
  hw/i3c: Fix array bounds and storage in i3c_addr_is_rsvd()
  MAINTAINERS: Add I3C maintainers and reviewer
  tests/functional/arm/test_aspeed_ast2600_sdk: Add i3c functional test
  hw/i3c: Add hotplug support
  hw/arm/aspeed: Build with I3C_DEVICES
  hw/i3c: Add Mock target
  ...

Signed-off-by: Peter Maydell <[email protected]>
2026-03-06 09:50:07 +00:00
Tao Tang fb147007d1 hw/arm/smmuv3: Fix CFGI_CD handling when stage-1 is unsupported
Add a STAGE1_SUPPORTED check in the CMD_CFGI_CD and CMD_CFGI_CD_ALL path
and return CERROR_ILL when stage-1 translation is not implemented,
matching the architecture requirement (IHI 0070G.b, page 176).

Fixes: 32cfd7f39e ("hw/arm/smmuv3: Cache/invalidate config data")
Signed-off-by: Tao Tang <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Mostafa Saleh <[email protected]>
Reviewed-by: Eric Auger <[email protected]>
Message-id: [email protected]
Links: https://lore.kernel.org/qemu-devel/[email protected]/
Signed-off-by: Peter Maydell <[email protected]>
2026-03-06 09:43:19 +00:00
Tao Tang af15801a61 hw/arm/smmuv3: Correct SMMUEN field name in CR0
The FIELD macro for the SMMU enable bit in the CR0 register was
incorrectly named SMMU_ENABLE.

The ARM SMMUv3 Architecture Specification (both older IHI 0070.E.a and
newer IHI 0070.G.b) consistently refers to the SMMU enable bit as SMMUEN.

This change makes our implementation consistent with the manual.

Signed-off-by: Tao Tang <[email protected]>
Reviewed-by: Eric Auger <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Mostafa Saleh <[email protected]>
Message-id: [email protected]
Fixes: 10a83cb988 ("hw/arm/smmuv3: Skeleton")
Link: https://lists.nongnu.org/archive/html/qemu-arm/2025-09/msg01270.html
Signed-off-by: Peter Maydell <[email protected]>
2026-03-06 09:43:19 +00:00
Tao Tang 65152c2942 hw/arm/smmuv3-common: Fix incorrect reserved mask for SMMU CR0 register
The current definition of the SMMU_CR0_RESERVED mask is incorrect.
It mistakenly treats bit 10 (DPT_WALK_EN) as a reserved bit while
treating bit 9 (RES0) as an implemented bit.

According to the SMMU architecture specification, the layout for CR0 is:
| 31:11| RES0           |
| 10   | DPT_WALK_EN    |
| 9    | RES0           |
| 8:6  | VMW            |
| 5    | RES0           |
| 4    | ATSCHK         |
| 3    | CMDQEN         |
| 2    | EVENTQEN       |
| 1    | PRIQEN         |
| 0    | SMMUEN         |

Signed-off-by: Tao Tang <[email protected]>
Reviewed-by: Eric Auger <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Mostafa Saleh <[email protected]>
Message-id: [email protected]
Fixes: fae4be38b3 ("hw/arm/smmuv3: Implement MMIO write operations")
Link: https://lists.gnu.org/archive/html/qemu-arm/2025-06/msg00088.html
Signed-off-by: Peter Maydell <[email protected]>
2026-03-06 09:43:19 +00:00
Fabiano Rosas 93ed7d3303 tests/qtest/qos-test: Plug a couple of leaks
The walk_path() function of qos-test.c, which walks the graph and adds
tests to the test suite uses GLib's g_test_add_data_func_full()
function:

g_test_add_data_func_full (const char     *testpath,
                           gpointer        test_data,
                           GTestDataFunc   test_func,
                           GDestroyNotify  data_free_func)

Despite GLib's documentation stating that @data_free_func is a
destructor for @test_data, this is not the case. The destructor is
supposed to be paired with a constructor, which GLib only accepts via
g_test_create_case().

Providing externally allocated data plus a destructor function only
works if the test is guaranteed to execute, otherwise the test_data is
never deallocated.

Due to how subprocessess are implemented in qos-test, each test gets
added twice and an extra test gets added per subprocess. In a regular
run, the extra subprocess will not be executed and in a single test
run (-p), none of the other tests will be executed (+1 per
subprocess), leaking 'path_vec' and 'subprocess_path'.

Fix this by storing all the path vectors in a list and freeing them
all at the end of the program (including subprocess invocations) and
moving the allocation of 'subprocess_path' into run_one_subprocess().

While here add some documentation explaining why the graph needs to be
walked twice and tests re-added.

Signed-off-by: Fabiano Rosas <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Message-id: [email protected]
[PMM: rebased; rewrote the comment in main() a bit to account
 for the if (g_test_subprocess()) block it was previously inside
 no longer being present. ]
Reviewed-by: Peter Maydell <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
2026-03-06 09:43:19 +00:00
Fabiano Rosas 56603f5d12 tests/qtest/test-x86-cpuid-compat: Free allocated memory
Free the test arguments after test execution.

Signed-off-by: Fabiano Rosas <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
Message-id: [email protected]
2026-03-06 09:43:19 +00:00
Fabiano Rosas 5c102ac9f1 chardev: Consolidate yank registration
There's currently five places where the yank function is being
registered and they all come right before tcp_chr_new_client(). Fold
them into it.

Signed-off-by: Fabiano Rosas <[email protected]>
Reviewed-by: Daniel P. Berrangé <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
Message-id: [email protected]
[PMM: rebased]
Signed-off-by: Peter Maydell <[email protected]>
2026-03-06 09:43:19 +00:00
Fabiano Rosas 3f0170505e chardev: Don't attempt to unregister yank function more than once
tcp_chr_free_connection() can be called multiple times in succession,
in which case the yank function will get as argument a NULL s->sioc
that has been cleared by the previous tcp_chr_free_connection() call.

This leads to an abort() at yank_unregister_function().

 #0  __GI_raise (sig=6) at ../sysdeps/unix/sysv/linux/raise.c:51
 #1  __GI_abort () at abort.c:79
 #2  qtest_check_status (s=0x513000005600) at ../tests/qtest/libqtest.c:209
 #3  qtest_wait_qemu (s=0x513000005600) at ../tests/qtest/libqtest.c:273
 #4  qtest_kill_qemu (s=0x513000005600) at ../tests/qtest/libqtest.c:285
 #5  kill_qemu_hook_func (s=0x513000005600) at ../tests/qtest/libqtest.c:294
 #6  g_hook_list_invoke (hook_list=0x55ea9cc750c0 <abrt_hooks>, may_recurse=0) at ../glib/ghook.c:534
 #7  sigabrt_handler (signo=6) at ../tests/qtest/libqtest.c:299
 #8  <signal handler called>
 #9  __GI_raise (sig=6) at ../sysdeps/unix/sysv/linux/raise.c:51
 #10 __GI_abort () at abort.c:79
 #11 yank_unregister_function (instance=0x7fb26f2ea9a0,
     func=0x55ea9bcc0a10 <char_socket_yank_iochannel>, opaque=0x0) at
     ../util/yank.c:151
 #12 tcp_chr_free_connection (chr=0x51300000ffc0) at ../chardev/char-socket.c:385
 #13 tcp_chr_disconnect_locked (chr=0x51300000ffc0) at ../chardev/char-socket.c:477
 #14 tcp_chr_disconnect (chr=0x51300000ffc0) at ../chardev/char-socket.c:495
 #15 tcp_chr_hup (channel=0x514000000040, cond=G_IO_HUP, opaque=0x51300000ffc0) at ../chardev/char-socket.c:536
 #16 qio_channel_fd_source_dispatch (source=0x50c0000b5fc0, callback=0x55ea9bcd6770 <tcp_chr_hup>,
     user_data=0x51300000ffc0) at ../io/channel-watch.c:84
 #17 g_main_dispatch (context=0x50f000000040) at ../glib/gmain.c:3381
 #18 g_main_context_dispatch (context=context@entry=0x50f000000040) at ../glib/gmain.c:4099
 #19 g_main_context_iterate (context=0x50f000000040, block=block@entry=1, dispatch=dispatch@entry=1,
     self=<optimized out>) at ../glib/gmain.c:4175
 #20 g_main_loop_run (loop=0x502000055690) at ../glib/gmain.c:4373

Commit ebae6477dc ("chardev: check if the chardev is registered for
yanking") seems to have encountered a similar issue, but checking
s->registered_yank is not a complete solution because that flag
pertains to the yank instance, not to each individual function.

Skip the yank_unregister_function() in case s->sioc is already NULL,
which indicates the last yank function was already removed.

Signed-off-by: Fabiano Rosas <[email protected]>
Reviewed-by: Daniel P. Berrangé <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
Message-id: [email protected]
[PMM: rebased]
Signed-off-by: Peter Maydell <[email protected]>
2026-03-06 09:43:19 +00:00
Fabiano Rosas 1423c170b9 chardev: Fix QIOChannel refcount
The IOWatchPoll holds a reference to the iochannel while the "child"
source (iwp->src) is removed from the context and freed. Freeing the
source leads to the iochannel being also freed at
qio_channel_fd_source_finalize().

Later, io_watch_poll_prepare() tries to create another source with the
same iochannel and hits an use after free:

==8241==ERROR: AddressSanitizer: heap-use-after-free on address 0x514000000040
READ of size 8 at 0x514000000040 thread T2
    #0 0x561c2d272fcd in object_get_class  ../qom/object.c:1043:17
    #1 0x561c2d338f84 in QIO_CHANNEL_GET_CLASS  include/io/channel.h:29:1
    #2 0x561c2d33b26f in qio_channel_create_watch  ../io/channel.c:388:30
    #3 0x561c2d2f0993 in io_watch_poll_prepare  ../chardev/char-io.c:65:20
    ...

0x514000000040 is located 0 bytes inside of 392-byte region [0x514000000040,0x5140000001c8)
freed by thread T2 here:
    #0 0x561c2d2319a5 in free
    #1 0x7fb2c0926638 in g_free
    #2 0x561c2d276507 in object_finalize  ../qom/object.c:734:9
    #3 0x561c2d271d0d in object_unref  ../qom/object.c:1231:9
    #4 0x561c2d32ef1d in qio_channel_fd_source_finalize  ../io/channel-watch.c:95:5
    #5 0x7fb2c091d124 in g_source_unref_internal ../glib/gmain.c:2298
    #6 0x561c2d2f0b6c in io_watch_poll_prepare  ../chardev/char-io.c:71:9
    ...

previously allocated by thread T3 (connect) here:
    #0 0x561c2d231c69 in malloc
    #1 0x7fb2c0926518 in g_malloc
    #2 0x561c2d27246e in object_new_with_type  ../qom/object.c:767:15
    #3 0x561c2d272530 in object_new  ../qom/object.c:789:12
    #4 0x561c2d320193 in qio_channel_socket_new  ../io/channel-socket.c:64:31
    #5 0x561c2d308013 in tcp_chr_connect_client_async  ../chardev/char-socket.c:1181:12
    #6 0x561c2d3002e7 in qmp_chardev_open_socket_client  ../chardev/char-socket.c:1281:9
    ...

Fix the issue by incrementing the iochannel reference count when the
IOWatchPoll takes a reference and decrementing when it is finalized.

Signed-off-by: Fabiano Rosas <[email protected]>
Reviewed-by: Daniel P. Berrangé <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
Message-id: [email protected]
[PMM: rebased]
Signed-off-by: Peter Maydell <[email protected]>
2026-03-06 09:43:19 +00:00
Peter Maydell 7220c1a0ee tests/qtest/iommu-smmuv3-test: Free QPCIDevice
The QPCIDevice we get via qpci_device_foreach() is allocated
memory, and we need to g_free() it after use.

This fixes asan leaks like this:

Direct leak of 64 byte(s) in 1 object(s) allocated from:
    #0 0x622a5f16913d in calloc (/home/pm215/qemu/build/arm-clang/tests/qtest/iommu-smmuv3-test+0x1d413d) (BuildId: bc598be1f4ad6d1a9a600c55aeef36108bdb6a04)
    #1 0x73ee41c0f771 in g_malloc0 (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x63771) (BuildId: 116e142b9b52c8a4dfd403e759e71ab8f95d8bb3)
    #2 0x622a5f1d4cec in qpci_device_find /home/pm215/qemu/build/arm-clang/../../tests/qtest/libqos/pci.c:82:11
    #3 0x622a5f1d4cec in qpci_device_foreach /home/pm215/qemu/build/arm-clang/../../tests/qtest/libqos/pci.c:34:19
    #4 0x622a5f23cc73 in setup_qtest_pci_device /home/pm215/qemu/build/arm-clang/../../tests/qtest/iommu-smmuv3-test.c:45:5
    #5 0x622a5f23cc73 in run_smmuv3_translation /home/pm215/qemu/build/arm-clang/../../tests/qtest/iommu-smmuv3-test.c:74:11

Reviewed-by: Fabiano Rosas <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
Message-id: [email protected]
2026-03-06 09:43:19 +00:00
Peter Maydell cc177661ab hw/arm/aspeed_gpio: Don't leak string in aspeed_gpio_init()
We allocate the string for the GPIO property name, but never free it.
Use g_autofree to avoid this.

Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
Message-id: [email protected]
2026-03-06 09:43:19 +00:00
Peter Maydell 1373470577 scripts/lsan_suppressions.txt: Add more leaks
Running "make check" with the clang leak sanitizer reveals some
leak reports which are either not our problem or else not
a leak which is worth our time to fix. Add some suppressions
for these.

While we're touching the file, add the usual SPDX header
and a comment explaining how to use it.

Reviewed-by: Fabiano Rosas <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
Message-id: [email protected]
2026-03-06 09:43:18 +00:00
Peter Maydell e9f55f543f scripts: Move lsan_suppressions.txt out of oss-fuzz subdir
The oss-fuzz code uses an lsan_suppressions file to suppress certain
leak-sanitizer cases that are known issues or not our code's bug.
This is useful more widely than just for the fuzzer harness: if you
want to build QEMU with the leak sanitizer enabled and run 'make
check' then you will want to suppress some bogus leak reports.

Move the file up a directory.

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Reviewed-by: Yodel Eldar <[email protected]>
Message-id: [email protected]
2026-03-06 09:43:18 +00:00
Eric Auger dbfed8d808 target/arm/machine: Fix detection of unknown incoming cpregs
Currently the check of cpreg index matches fail to detect
a situation where the length of both arrays is same but
- destination has an extra register not found in the incoming stream (idx1)
- source has an extra register not found in the destination (idx2)
  where idx1 < = idx2
Normally this should fail but it does not.

Fix the logic to scan all indexes.

Fixes: 721fae1253 ("target-arm: Convert TCG to using (index,value) list for cp migration")
Signed-off-by: Eric Auger <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-03-06 09:43:18 +00:00
Eric Auger e25c63c3b3 target/arm/machine: Trace all register mismatches
At the moment, cpu_post_load() exits with error on the first
catch of unexpected register in the incoming stream. Let the code
go further and trace all the issues before exiting.

Signed-off-by: Eric Auger <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-03-06 09:43:18 +00:00
Eric Auger eac1e610f4 target/arm/machine: Trace cpreg names which do not match on migration
Whenever there is a mismatch between cpreg indexes in the incoming
stream and cpregs exposed by the destination output the name of
the register. We use a print_register_name() wrapper helper. At the
moment we are only able to do a nice decoding of the index for
KVM regs.

Without this patch, the error would be:
qemu-system-aarch64: load of migration failed: Operation not permitted:
error while loading state for instance 0x0 of device 'cpu': post load
hook failed for: cpu, version_id: 22, minimum_version: 22, ret: -1
which is not helpful for the end user to understand the actual
issue.

This patch adds the actual information about the probme:
qemu-system-aarch64: cpu_post_load: system register
op0:3 op1:0 crn:2 crm:0 op2:3 in the incoming stream but
unknown on the destination, fail migration

Signed-off-by: Eric Auger <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-03-06 09:43:18 +00:00
Eric Auger 3e0a3a8e91 target/arm/kvm: Tweak print_register_name() for arm64 system register
As opposed to other register types, arm64 system register decoding
is not introduced by any 'register' mention which can lead to
unfriendly user-facing traces.  Let's add "system register"

Signed-off-by: Eric Auger <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-03-06 09:43:18 +00:00
Eric Auger 5ae081fb49 target/arm/kvm: Export kvm_print_register_name()
We want to use kvm_print_register_name() in machine.c so
let's export the helper and implement a stub when kvm
is not enabled.

Signed-off-by: Eric Auger <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-03-06 09:43:18 +00:00
Eric Auger ab2ddc7b66 target/arm/machine: Use VMSTATE_VARRAY_INT32_ALLOC for cpreg arrays
This removes the need for explicitly allocating cpreg_vmstate arrays.
On post save we simply point to cpreg arrays and set the length
accordingly.

Remove VMSTATE_VARRAY_INT32 for cpreg_vmstate_array_len as now
the array is dynamically allocated.

Also add a trace point on post_load to trace potential mismatch
between the number of incoming cpregs versus current ones.

Signed-off-by: Eric Auger <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Message-id: [email protected]
Suggested-by: Peter Maydell <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
2026-03-06 09:43:18 +00:00
Eric Auger f555338df7 vmstate: Introduce VMSTATE_VARRAY_INT32_ALLOC
Already existing VMSTATE_VARRAY_INT32 requires an array to be
pre-allocated, however there are cases when the size is not known in
advance and there is no real need to enforce it.

Introduce VMSTATE_VARRAY_INT32_ALLOC as we currently have for UINT32
and UINT16.

The first user of this variant will be the target/arm/machine.c cpreg
indexes/values arrays.

Signed-off-by: Eric Auger <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Reviewed-by: Peter Xu <[email protected]>
Message-id: [email protected]
Suggested-by: Peter Maydell <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Reviewed-by: Peter Xu <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
2026-03-06 09:43:18 +00:00
Magnus Kulke fbf9bb0d79 MAINTAINERS: fix magnuskulke email-address
Consolidating email aliases.

Signed-off-by: Magnus Kulke <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
2026-03-06 09:43:18 +00:00
Peter Maydell d8e19f8042 hw/net/smc91c111: Don't allow negative-length packets
The smc91c111 data frame format in memory (figure 8-1 in the
datasheet) includes a "byte count" field which is intended to be the
total size of the data frame, including not just the packet data but
also the leading and trailing information like the status word and
the byte count field itself.  It is therefore possible for the guest
to set this to a value so small that the leading and trailing fields
won't fit and the packet has effectively a negative area.

We weren't checking for this, with the result that when we subtract 6
from the length to get the length of the packet proper we end up with
a negative length, which is then inconsistently handled in the
qemu_send_packet() code such that we can try to transmit a very large
amount of data and read off the end of the device's data array.

Treat excessively small length values the same way we do excessively
large values.  As with the oversized case, the datasheet does not
describe what happens for this software error case, and there is no
relevant tx error condition for this, so we just log and drop the
packet.

Cc: [email protected]
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3304
Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-id: [email protected]
2026-03-06 09:43:18 +00:00
Peter Maydell 2cae1adc42 system/qtest: Support comments in input commands
Allow the qtest input to include comment lines, which start with '#'.
This allows writing an input file for qtest which includes commentary,
like this:

  # set up TCR in bank 0
  write 0x1001000e 2 0
  # TCR TXEN
  write 0x10010000 2 1

which can make hand-writing or annotating reproduce cases a bit
more convenient.

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-id: [email protected]
2026-03-06 09:43:18 +00:00
CLEMENT MATHIEU--DRIF 76d126d0f6 MAINTAINERS: Update Clement Mathieu--Drif's email address
Switch to bull.com email address following a company split.
The previous eviden.com address will remain active for a few months.

Signed-off-by: Clement Mathieu--Drif <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-03-06 09:43:18 +00:00
Paul Durrant 7564492337 MAINTAINERS: remove myself as a Xen maintainer
I am no longer actively involved in the Xen Project.

Signed-off-by: Paul Durrant <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-03-06 09:43:18 +00:00
Shameer Kolothum c0c97fbc6c hw/arm/smmuv3-accel: Read and propagate host vIOMMU events
Install an event handler on the vEVENTQ fd to read and propagate host
generated vIOMMU events to the guest.

The handler runs in QEMU's main loop, using a non-blocking fd registered
via qemu_set_fd_handler().

Tested-by: Nicolin Chen <[email protected]>
Reviewed-by: Eric Auger <[email protected]>
Reviewed-by: Nicolin Chen <[email protected]>
Tested-by: Eric Auger <[email protected]>
Reviewed-by: Jonathan Cameron <[email protected]>
Signed-off-by: Shameer Kolothum <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-03-06 09:43:18 +00:00
Shameer Kolothum 43585524a7 hw/arm/smmuv3: Introduce a helper function for event propagation
Factor out the code that propagates event records to the guest into a
helper function. The accelerated SMMUv3 path can use this to propagate
host events in a subsequent patch.

Take the mutex inside the helper before accessing the Event Queue.
Today event propagation occurs only in the core SMMUv3 path and is
effectively serialized. A subsequent patch will also invoke this helper
from the accelerated event read path, which may run concurrently.
Therefore serialization is required here.

No functional change intended.

Reviewed-by: Nicolin Chen <[email protected]>
Reviewed-by: Eric Auger <[email protected]>
Tested-by: Nicolin Chen <[email protected]>
Tested-by: Eric Auger <[email protected]>
Reviewed-by: Jonathan Cameron <[email protected]>
Signed-off-by: Shameer Kolothum <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-03-06 09:43:18 +00:00
Nicolin Chen 46f0d48393 hw/arm/smmuv3-accel: Allocate vEVENTQ for accelerated SMMUv3 devices
When the guest enables the Event Queue and a vIOMMU is present, allocate a
vEVENTQ object so that host-side events related to the vIOMMU can be
received and propagated back to the guest.

Allocate a vEVENTQ only when both of the following conditions are met:

  1) The guest SMMUv3 driver has set EVENTQEN = 1 in SMMU_CR0.
  2) A vIOMMU exists (created when the first VFIO device is attached).

These two conditions may occur in any order.

In the cold-plug case, the vIOMMU already exists before the guest
driver probes. When the guest sets EVENTQEN = 1 during driver probe,
the vEVENTQ is allocated at that point.

With hot-plug, the VFIO device may be attached either before or after
the guest sets EVENTQEN. If the vIOMMU is created first, allocation is
deferred until EVENTQEN = 1. If EVENTQEN is already set, allocation
happens when the vIOMMU is created.

In all cases, allocation is triggered when the second required
condition becomes true.

Errors from command queue consumption and vEVENTQ allocation are reported
independently as the two operations are unrelated.

Event read and propagation will be added in a later patch.

Signed-off-by: Nicolin Chen <[email protected]>
Tested-by: Nicolin Chen <[email protected]>
Reviewed-by: Eric Auger <[email protected]>
Tested-by: Eric Auger <[email protected]>
Signed-off-by: Shameer Kolothum <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-03-06 09:43:18 +00:00
Shameer Kolothum 674d57bf6e hw/arm/smmuv3-accel: Add viommu free helper
Move viommu teardown into a helper function and use it from the
last device removal path.

This groups related cleanup logic in one place and improves readability.
It also makes it easier to extend the teardown in future, for example
when freeing related objects such as vEVENTQ.

No functional change.

Reviewed-by: Nicolin Chen <[email protected]>
Reviewed-by: Eric Auger <[email protected]>
Tested-by: Eric Auger <[email protected]>
Reviewed-by: Jonathan Cameron <[email protected]>
Signed-off-by: Shameer Kolothum <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-03-06 09:43:18 +00:00
Nicolin Chen 0885cd5504 backends/iommufd: Introduce iommufd_backend_alloc_veventq
Add a new helper for IOMMU_VEVENTQ_ALLOC ioctl to allocate a virtual event
queue (vEVENTQ) for a vIOMMU object.

Signed-off-by: Nicolin Chen <[email protected]>
Tested-by: Nicolin Chen <[email protected]>
Reviewed-by: Eric Auger <[email protected]>
Reviewed-by: Nicolin Chen <[email protected]>
Tested-by: Eric Auger <[email protected]>
Reviewed-by: Jonathan Cameron <[email protected]>
Signed-off-by: Shameer Kolothum <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-03-06 09:43:18 +00:00
Chisheng Chen 005b1d838b hw/arm: Add missing dependencies for STM32F405 SoC
The STM32F405 SoC relies on STM32F2xx peripherals (ADC, SPI, TIMER,
USART) and the unimplemented device (UNIMP). However, they are not
selected in Kconfig. This added these dependencies.

Signed-off-by: Chisheng Chen <[email protected]>
Message-id: [email protected]
Reviewed-by: Peter Maydell <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
2026-03-06 09:01:11 +00:00
Thomas Huth 072ddc8eb9 hw/net: Remove the xgmac device
The xgmac device was only used by the highbank machine that just
has been removed. Being a sysbus device that cannot be instantiated
by the user, this is dead code now and thus can be removed, too.

Signed-off-by: Thomas Huth <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
2026-03-06 09:01:11 +00:00
Thomas Huth 201245a654 hw/arm: Remove the deprecated "highbank" and "midway" machines
These machines have been marked as deprecated two releases ago,
and so far nobody complained that they are still useful, so it's
time to remove these now.

Signed-off-by: Thomas Huth <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-03-06 09:01:11 +00:00
Pierrick Bouvier 187adb4ac6 hw/virtio/: make all compilation units common
Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Pierrick Bouvier <[email protected]>
2026-03-05 11:11:01 -08:00
Pierrick Bouvier 4a0d0cd942 hw/virtio/virtio-qmp: make compilation unit common
All compile time conditionals have no impact at runtime, since they are
representing only possible features for devices present at runtime.

In case they are not present, associated features table will never be
used. In case they are present but some features are not, matching bits
will never be enabled, so those entries will be unused.

Thus, simply expose everything and call it a day.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Tested-by: Philippe Mathieu-Daudé <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Pierrick Bouvier <[email protected]>
2026-03-05 11:11:01 -08:00
Pierrick Bouvier c7c15bc178 hw/virtio/vhost-user: make compilation unit common
PPC architectures use a custom value for VHOST_USER_MAX_RAM_SLOTS (32
instead of 512).

vhost_user struct and several functions use VHOST_USER_MAX_RAM_SLOTS to
define stack allocated buffers. To avoid changing all functions to use
heap allocated buffers, we keep this max, and simply add a
target_base_ppc() conditional for the single place where size really
matters.

Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Tested-by: Philippe Mathieu-Daudé <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Pierrick Bouvier <[email protected]>
2026-03-05 11:11:01 -08:00
Pierrick Bouvier 93b32a8737 hw/virtio: Inline virtio_access_is_big_endian()
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Acked-by: Stefan Hajnoczi <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Pierrick Bouvier <[email protected]>
2026-03-05 11:11:01 -08:00
Pierrick Bouvier 38155b1f58 hw/virtio: Simplify virtio_access_is_big_endian()
Thanks to previous refactoring, we can see more easily it is strictly
equivalent to always call virtio_vdev_is_big_endian.

static inline bool virtio_vdev_is_big_endian(VirtIODevice *vdev)
{
    if (virtio_vdev_is_legacy(vdev)) {
        assert(vdev->device_endian != VIRTIO_DEVICE_ENDIAN_UNKNOWN);
        return vdev->device_endian == VIRTIO_DEVICE_ENDIAN_BIG;
    }
    /* Devices conforming to VIRTIO 1.0 or later are always LE. */
    return false;
}

The key is to understand that vdev->device_endian is initialized as
expected. It always contains cpu endianness, and not
device endianness, ignoring if device is legacy or not.

By default, it's initialized to vdev->device_endian =
virtio_default_endian(), which matches target default endianness.
Then, on virtio_reset, it will be initialized with current_cpu
endianness (if there is one current_cpu).

void virtio_reset() {
    ...
    if (current_cpu) {
        /* Guest initiated reset */
        vdev->device_endian = virtio_current_cpu_endian();
    } else {
        /* System reset */
        vdev->device_endian = virtio_default_endian();
    }

Now, we can see how existing virtio_access_is_big_endian is equivalent
to virtio_vdev_is_big_endian. Let's break the existing function in its 3
variants, and compare that to virtio_vdev_is_big_endian.

static inline bool virtio_access_is_big_endian(VirtIODevice *vdev)
- #if defined(LEGACY_VIRTIO_IS_BIENDIAN)
    return virtio_vdev_is_big_endian(vdev);
  This is the exact replacement we did, so equivalent.
- #elif TARGET_BIG_ENDIAN
    if (!virtio_vdev_is_legacy(vdev)) {
        return false;
    }
    return true;

  we know target_is_big_endian(), so
  vdev->device_endian == VIRTIO_DEVICE_ENDIAN_BIG.
  if (virtio_vdev_is_legacy(vdev)) {
      return VIRTIO_DEVICE_ENDIAN_BIG == VIRTIO_DEVICE_ENDIAN_BIG;
  }
  return false;
  It's written in opposite style compared to existing code (if legacy vs
  if modern), but it's strictly equivalent.
- #else
    return false;
  we know !target_is_big_endian(), so
  vdev->device_endian == VIRTIO_DEVICE_ENDIAN_LITTLE.
  if virtio_vdev_is_legacy(vdev) {
    return VIRTIO_DEVICE_ENDIAN_LITTLE == VIRTIO_DEVICE_ENDIAN_BIG;
  }
  return false;
  So it always return false, as expected.

Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Acked-by: Stefan Hajnoczi <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Pierrick Bouvier <[email protected]>
2026-03-05 11:11:01 -08:00
Pierrick Bouvier 64495d7cfe hw/virtio: Add virtio_vdev_is_legacy()
This simplifies code compared to having
virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1) or
!virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1).

Acked-by: Stefan Hajnoczi <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Pierrick Bouvier <[email protected]>
2026-03-05 11:11:01 -08:00
Peter Maydell aca77dfd90 tests/tcg/plugins/patch: Free read_data in patch_hwaddr()
In patch_hwaddr() we allocate a GByteArray for the data we read back
from the guest; however we forget to free it, and the leak sanitizer
complains:

Direct leak of 40 byte(s) in 1 object(s) allocated from:
    #0 0x56c00ad48293 in malloc (/home/pm215/qemu/build/x86-tgt-san/qemu-system-x86_64+0x1a9f293) (BuildId: 62e2a7dbe5ff146b2fa14d26e24e443f1967edd9)
    #1 0x7b3e4cc91ac9 in g_malloc (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x62ac9) (BuildId: 116e142b9b52c8a4dfd403e759e71ab8f95d8bb3)
    #2 0x7b3e4cc54c12 in g_array_sized_new (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x25c12) (BuildId: 116e142b9b52c8a4dfd403e759e71ab8f95d8bb3)
    #3 0x7b3e44b06b49 in patch_hwaddr /home/pm215/qemu/build/x86-tgt-san/../../tests/tcg/plugins/patch.c:68:29

Indirect leak of 16 byte(s) in 1 object(s) allocated from:
    #0 0x56c00ad486b0 in realloc (/home/pm215/qemu/build/x86-tgt-san/qemu-system-x86_64+0x1a9f6b0) (BuildId: 62e2a7dbe5ff146b2fa14d26e24e443f1967edd9)
    #1 0x7b3e4cc92819 in g_realloc (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x63819) (BuildId: 116e142b9b52c8a4dfd403e759e71ab8f95d8bb3)
    #2 0x7b3e4cc54b36  (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x25b36) (BuildId: 116e142b9b52c8a4dfd403e759e71ab8f95d8bb3)
    #3 0x7b3e4cc55276 in g_array_set_size (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x26276) (BuildId: 116e142b9b52c8a4dfd403e759e71ab8f95d8bb3)
    #4 0x7b3e4cc55574 in g_byte_array_set_size (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x26574) (BuildId: 116e142b9b52c8a4dfd403e759e71ab8f95d8bb3)
    #5 0x56c00be2ccc1 in qemu_plugin_read_memory_hwaddr /home/pm215/qemu/build/x86-tgt-san/../../plugins/api.c:524:5

Mark the variable as g_autoptr(), as we already do in the equivalent
code in patch_vaddr().

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Pierrick Bouvier <[email protected]>
2026-03-05 10:54:09 -08:00
Peter Maydell c9bfe4127d tests/tcg/plugins/mem: Correct hash iteration code in plugin_exit()
In plugin_exit() we call g_hash_table_get_values() to get a GList
which we look at to print some information. This code has
multiple issues:
 * it names the local variable for the GList "count", which
   shadows the "qemu_plugin_scoreboard *count". This isn't
   incorrect, but it is unnecessarily confusing
 * it doesn't free the list, and the leak sanitizer complains:

   Indirect leak of 2328 byte(s) in 97 object(s) allocated from:
    #0 0x5589b0b72293 in malloc (/home/pm215/qemu/build/x86-tgt-san/qemu-system-i386+0x1a2f293) (BuildId: 26964cad9e3f81d35fc144d7cc88b53adf6f60c7)
    #1 0x78fd8cfa1ac9 in g_malloc (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x62ac9) (BuildId: 116e142b9b52c8a4dfd403e759e71ab8f95d8bb3)
    #2 0x78fd8cf96e4a in g_list_prepend (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x57e4a) (BuildId: 116e142b9b52c8a4dfd403e759e71ab8f95d8bb3)
    #3 0x78fd8cf8b318 in g_hash_table_get_values (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x4c318) (BuildId: 116e142b9b52c8a4dfd403e759e71ab8f95d8bb3)
    #4 0x78fd84d1a90c in plugin_exit /home/pm215/qemu/build/x86-tgt-san/../../tests/tcg/plugins/mem.c:87:25
 * in iterating through the list it updates "count", so by the
   time we get to the end of the loop we no longer have a pointer
   to the head of the list that we could use to free it
 * it checks for the list being NULL twice (once in an if()
   and once in the for() loop's "while" condition), which is
   redundant
 * it skips the loop if g_list_next(counts) is NULL, which means
   it will wrongly skip the loop if the list has only one entry

Rewrite the iteration code to fix these problems.

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Pierrick Bouvier <[email protected]>
2026-03-05 10:54:09 -08:00
Peter Maydell 11b01d307b tests/tcg/plugins/mem: Don't access unaligned memory
In commit eb3f69cac6 we removed the dependency of this mem plugin
on the QEMU headers, but in doing that we introduced undefined
behaviour when the plugin accesses unaligned memory.  This shows up
if you build with the gcc or clang undefined behaviour sanitizer
(--enable-ubsan) and run 'make check-tcg', in numerous warnings like:

../../tests/tcg/plugins/mem.c:167:27: runtime error: load of misaligned address 0x7f1f300354b1 for type 'uint16_t' (aka 'unsigned short'), which requires 2 byte alignment
0x7f1f300354b1: note: pointer points here
 00 00 00  00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f  10 11 12 13 14 15 16 17  18 19 1a 1b 1c
              ^
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../../tests/tcg/plugins/mem.c:167:27

Fix this by rearranging the data reads and writes to use
memcpy() instead.

Fixes: eb3f69cac6 ("tests/tcg/plugins/mem.c: remove dependency on qemu headers")
Tested-by: Alex Bennée <[email protected]>
Reviewed-by: Alex Bennée <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Pierrick Bouvier <[email protected]>
2026-03-05 10:54:09 -08:00
Florian Hofhammer 0443c203c4 plugins: add missing callbacks to version history
The discontinuity and system call filter callbacks were not reflected in
the versioning comments before. The callbacks have been introduced in
aac73d85d2 and
5ed628d1d3, respectively.

Signed-off-by: Florian Hofhammer <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Pierrick Bouvier <[email protected]>
2026-03-05 10:54:09 -08:00
Florian Hofhammer 9fb1f82794 tests/tcg/plugins: test register accesses
The additional plugin tests register accesses, specifically both for
read-only and read-write registers. Writing to a read-only register is
currently not tested, as this would trigger an assertion and fail the
test.

Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Florian Hofhammer <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Pierrick Bouvier <[email protected]>
2026-03-05 10:54:09 -08:00
Florian Hofhammer 55327b85ce plugins: prohibit writing to read-only registers
The opaque register handle encodes whether a register is read-only in
the lowest bit and prevents writing to the register via the plugin API
in this case.

Reviewed-by: Alex Bennée <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Florian Hofhammer <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Pierrick Bouvier <[email protected]>
2026-03-05 10:54:09 -08:00
Florian Hofhammer 3ebd871cbd plugins: add read-only property for registers
Some registers should be marked as read-only from a plugin API
perspective, as writing to them via qemu_plugin_write_register has no
effect. This includes the program counter, and we expose this fact to
the plugins with this patch.

Reviewed-by: Alex Bennée <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Florian Hofhammer <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Pierrick Bouvier <[email protected]>
2026-03-05 10:54:09 -08:00
Florian Hofhammer 0b03c73c99 tests/tcg: add tests for qemu_plugin_set_pc API
The test plugin intercepts execution in different contexts. Without the
plugin, any of the implemented test functions would trigger an assert
and fail. With the plugin, control flow is redirected to skip the assert
and return cleanly via the qemu_plugin_set_pc() API.

Signed-off-by: Florian Hofhammer <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Pierrick Bouvier <[email protected]>
2026-03-05 10:54:09 -08:00
Florian Hofhammer 4f55cd7801 plugins: add PC diversion API function
This patch adds a plugin API function that allows diverting the program
counter during execution. A potential use case for this functionality is
to skip over parts of the code, e.g., by hooking into a specific
instruction and setting the PC to the next instruction in the callback.

Link: https://lists.nongnu.org/archive/html/qemu-devel/2025-08/msg00656.html
Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Florian Hofhammer <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Pierrick Bouvier <[email protected]>
2026-03-05 10:54:09 -08:00
Florian Hofhammer 9097087147 linux-user: make syscall emulation interruptible
The syscall emulation code previously wasn't interruptible via
cpu_loop_exit(), as this construct relies on a longjmp target that is not
live anymore in the syscall handling code. Consequently, longjmp() would
operate on a (potentially overwritten) stale jump buffer. This patch adds an additional
setjmp and the necessary handling around it to make longjmp() (and by
proxy cpu_loop_exit() safe to call even within a syscall context.

Reviewed-by: Warner Losh <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Alex Bennée <[email protected]>
Signed-off-by: Florian Hofhammer <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Pierrick Bouvier <[email protected]>
2026-03-05 10:54:09 -08:00
Florian Hofhammer d16ffa4244 plugins: add flag to specify whether PC is rw
In addition to the flags specifying whether general-purpose registers
are read-write (rw) during a plugin callback, we add an additional flag
explicitly stating whether the PC is writable. This is in preparation of
a patch that allows to explicitly set the PC to divert control flow from
within a plugin callback, which is currently not possible.

Reviewed-by: Alex Bennée <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Florian Hofhammer <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Pierrick Bouvier <[email protected]>
2026-03-05 10:54:09 -08:00
Pierrick Bouvier 2cc35f14ba plugins/core: clamp syscall arguments if target is 32-bit
Syscall arguments are abi_long in user code, and plugin syscall
interface works with uint64_t only.

According to C integer promotion rules, the value is sign extended
before becoming unsigned, thus setting high bits when only 32-bit lower
ones should have a significant value.

As a result, we need to clamp values we receive from user-code
accordingly.

Reviewed-by: Alex Bennée <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Pierrick Bouvier <[email protected]>
2026-03-05 10:54:09 -08:00
Peter Maydell 483cb5b74c Merge tag 'next-pr-pull-request' of https://gitlab.com/berrange/qemu into staging
* Increase pre-alloc max thread count to 32
* Fix checkpatch warning for new/removed files with --terse
* Detect more GPL boilerplate in checkpatch
* Fix lean of data in TLS/websock GSource cancellation
* Tweak CPU docs for DiamondRapids
* Unconditionally enable thread naming
* Fix race setting thread naming on Win32
* Add API docs for logging APIs
* Fix interleaved error/trace output
* Fix missing error prefixes with warn_report
* Add detailed error reporting for VNC passworrd changes
* Refactoring of error_vprintf & related funcs

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCAAdFiEE2vOm/bJrYpEtDo4/vobrtBUQT98FAmmpwaAACgkQvobrtBUQ
# T98nOg/8C+KQIoe02C6PkVIaH/maDuyAsWYMPkVySgL5Zt+lKR8hS+voyP56ON7S
# UltpZq+NHHQkrjh6O1jfJ7io1inEgXPKxbzKMi9SR0q6+Qva7Js2MJR8RSip8QTX
# lVGiRyCTGdgdDiXa+5t+N7zKwShdSVJ7lDh8G/Y/zWGeSzhOUs3BLTYCc8jVwvM/
# Frnvwk7XVX0SjZlI2xqIPYclzKNScM9QYwmAKDDvBgbxBPUq17NxprOyObSsR8Nc
# ajP6SckaZr2w8JgZ9wPRrGkEnts+MTk/6O/qTwuljbxj+GzaAuT7beJ6uVQMTAhj
# wvXC9ZCe+WnH4KBvOfb789M9wRD0VQLO3d4ejYm7z7dxjgpO/YTbMIFGcG/GO8Np
# /rS9EVpXlNX37x4pR4U7i/SkMtl/a5XyIdd8toSSfrmOODc7pzqmE+YM0F1nj+/U
# Hb/Zkl2A72OW7NRRZ0h2UL1qJ10NYc0WUb3YOE4/zLjSSt1LVDDH4a8qiRR/ooF4
# 7W3Xp9BZAhxO/fvWOdrv4oC73udJcxN38yRkSx8tO4oZiwMhAnNtZNMVNcib6XpL
# 1QQQDVEAvjnOElStYlFqbetaoknGkQ+QmIkr2SXDwpKaoFn1H6IWi0rvR5/2FjWV
# Ps7sLmGVtgZixLLNZYNp9F3CZ69UpXLE0jUxnA75VOfm8wKQJIU=
# =BVE/
# -----END PGP SIGNATURE-----
# gpg: Signature made Thu Mar  5 17:47:12 2026 GMT
# gpg:                using RSA key DAF3A6FDB26B62912D0E8E3FBE86EBB415104FDF
# gpg: Good signature from "Daniel P. Berrange <[email protected]>" [full]
# gpg:                 aka "Daniel P. Berrange <[email protected]>" [full]
# Primary key fingerprint: DAF3 A6FD B26B 6291 2D0E  8E3F BE86 EBB4 1510 4FDF

* tag 'next-pr-pull-request' of https://gitlab.com/berrange/qemu: (27 commits)
  util/oslib-posix: increase memprealloc thread count to 32
  scripts/checkpatch: Fix MAINTAINERS update warning with --terse
  util: fix interleaving of error prefixes
  util: don't skip error prefixes when QMP is active
  util: fix interleaving of error & trace output
  monitor: move error_vprintf back to error-report.c
  monitor: refactor error_vprintf()
  monitor: remove redundant error_[v]printf_unless_qmp
  ui: remove redundant use of error_printf_unless_qmp()
  ui: add proper error reporting for password changes
  util/log: add missing error reporting in qemu_log_trylock_with_err
  util: avoid repeated prefix on incremental qemu_log calls
  util: introduce some API docs for logging APIs
  util: add API to fetch the current thread name
  util: set the name for the 'main' thread on Windows
  audio: make jackaudio use qemu_thread_set_name
  util: expose qemu_thread_set_name
  util: fix race setting thread name on Win32
  system: unconditionally enable thread naming
  monitor: initialize global data from a constructor
  ...

Signed-off-by: Peter Maydell <[email protected]>
2026-03-05 17:49:14 +00:00
Jamin Lin ee357844b1 tests/functional/aarch64/test_aspeed_ast2700fc: Update test ASPEED OpenBMC SDK v11.01
Signed-off-by: Jamin Lin <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Tested-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-03-05 18:47:46 +01:00
Jamin Lin 01aa3f0dcb tests/functional/aarch64/test_aspeed_ast2700a2: Update test ASPEED OpenBMC SDK v11.01
Signed-off-by: Jamin Lin <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Tested-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-03-05 18:47:46 +01:00
Jamin Lin d15d893c8e tests/functional/aarch64/test_aspeed_ast2700a1: Update test ASPEED OpenBMC SDK v11.01
Signed-off-by: Jamin Lin <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Tested-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-03-05 18:47:46 +01:00
Jamin Lin c7d15f1a16 tests/functional/arm/test_aspeed_ast2600_sdk_515: Update test ASPEED OpenBMC SDK v11.01
Signed-off-by: Jamin Lin <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Tested-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-03-05 18:47:46 +01:00
Jamin Lin 81dfadfab1 tests/functional/arm/test_aspeed_ast2600_sdk_otp: Update test ASPEED OpenBMC SDK v11.01
Signed-off-by: Jamin Lin <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Tested-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-03-05 18:47:46 +01:00
Jamin Lin 226900a1ad tests/functional/arm/test_aspeed_ast2600_sdk: Update test ASPEED OpenBMC SDK v11.01
Signed-off-by: Jamin Lin <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Tested-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-03-05 18:47:46 +01:00
Jamin Lin ef78dc4a3a tests/functional/arm/test_aspeed_ast2500_sdk_515: Update test ASPEED OpenBMC SDK v11.01
Signed-off-by: Jamin Lin <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Tested-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-03-05 18:47:46 +01:00
Jamin Lin 7969ab0ca6 tests/functional/arm/test_aspeed_ast2500_sdk: Update test ASPEED OpenBMC SDK v11.01
Signed-off-by: Jamin Lin <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Tested-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-03-05 18:47:46 +01:00
Jamin Lin 60e0ba94a4 tests/functional/arm/test_aspeed_ast1060: Update test aspeed-zephyr-project v03.05
Signed-off-by: Jamin Lin <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Tested-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-03-05 18:47:46 +01:00
Jamin Lin e86a101419 tests/functional/arm/test_aspeed_ast1030: Update test ASPEED Zephyr SDK v03.06
Signed-off-by: Jamin Lin <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Tested-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-03-05 18:47:46 +01:00
Jamin Lin a39d7662cd hw/i3c/mock-i3c-target: Simplify GETMRL byte extraction logic
The GETMRL handling logic extracted MSB/LSB bytes from
s->cfg.buf_size using a mask-and-shift expression:

  (buf_size & (0xff00 >> (offset * 8))) >>
  (8 - (offset * 8))

While functionally correct, the expression is difficult to read
and obscures the intent, which is simply to return a 16-bit value
in MSB-first order.

Replace the mask/shift formula with explicit MSB/LSB extraction:

  offset == 0 -> buf_size >> 8
  offset == 1 -> buf_size & 0xff

This makes the code clearer and easier to review without altering
behavior or data ordering.

No functional change.

Signed-off-by: Jamin Lin <[email protected]>
Reviewed-by: Jithu Joseph <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-03-05 18:47:46 +01:00
Jamin Lin 5ed7dedf31 hw/i3c/core: Initialize num_sent in i3c_send_byte()
i3c_send_byte() declared num_sent without initializing it before
passing its address to i3c_send().

Although i3c_send_byte() itself ignores num_sent after the call,
i3c_send() forwards it to trace_i3c_send(). If the target send
callback does not set *num_sent, the trace may print an
uninitialized value, leading to misleading or garbage output.

Example concern from review:
  trace_i3c_send(*num_sent, num_to_send, ret == 0);

If *num_sent is not written by the callback, this trace can report
an incorrect number of transmitted bytes.

Initialize num_sent to 0 to ensure deterministic and predictable
trace output, even if the callback fails to update it.

Signed-off-by: Jamin Lin <[email protected]>
Reviewed-by: Jithu Joseph <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-03-05 18:47:46 +01:00
Jamin Lin f612757a3a hw/i3c/mock-i3c-target: Set num_sent in TX callback to fix trace reporting
mock_i3c_target_tx() did not update *num_sent before returning.

Although some callers may not directly use this value, i3c_send()
passes num_sent to trace_i3c_send(). If the target TX callback does
not initialize *num_sent, the trace output may report an incorrect
or uninitialized value, leading to confusing debugging information.

For example, the following trace was observed:

  mock_i3c_target_tx I3C mock target write 0x12
  i3c_send I3C send 0/1 bytes, ack=1    (expected 1/1 bytes)

This happens because *num_sent was never set by the TX callback.

Fix this by setting *num_sent in all return paths,
including the IBI magic handling case, to accurately reflect
the number of bytes consumed.

Signed-off-by: Jamin Lin <[email protected]>
Reviewed-by: Jithu Joseph <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-03-05 18:47:46 +01:00
Jamin Lin 713e9e951a hw/i3c/dw-i3c: Use ROUND_UP() for RX buffer allocation alignment
The RX temporary buffer allocation manually aligned the size using:

    num + (4 - (num & 0x03))

Replace this with ROUND_UP(num, 4) for better readability and
consistency with common QEMU coding style.

No functional change.

Signed-off-by: Jamin Lin <[email protected]>
Reviewed-by: Jithu Joseph <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-03-05 18:47:46 +01:00
Cédric Le Goater 4cb60ad650 hw/i3c: Fix array bounds and storage in i3c_addr_is_rsvd()
The size of the is_rsvd lookup table in i3c_addr_is_rsvd() is 255 but
should be 256 to cover all possible uint8_t address values and avoid
potential out-of-bounds access.

The array should be static too as it's a constant lookup table.

Reviewed-by: Jamin Lin <[email protected]>
Reviewed-by: Nabih Estefan <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-03-05 18:47:46 +01:00
Jamin Lin 5f682daa65 MAINTAINERS: Add I3C maintainers and reviewer
Add a new I3C section to the MAINTAINERS file.

List Joe Komlodi, Cédric Le Goater and Jamin Lin
as maintainers, and Nabih Estefan as the reviewer,
covering the I3C core and related files under hw/i3c/
and include/hw/i3c/.

Signed-off-by: Nabih Estefan <[email protected]>
Signed-off-by: Jamin Lin <[email protected]>
Tested-by: Jithu Joseph <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-03-05 18:47:46 +01:00
Jamin Lin b598a42fb1 tests/functional/arm/test_aspeed_ast2600_sdk: Add i3c functional test
Signed-off-by: Jamin Lin <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Tested-by: Jithu Joseph <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-03-05 18:47:46 +01:00
Jamin Lin 071d587645 hw/i3c: Add hotplug support
This adds support for hotplugging in I3C.
Conceptually this can be thought of as an I3C target being physically
socketed onto a board.
It is then the target's responsibility to go through the hot-join and
DAA process so it can participate on the bus.

Signed-off-by: Joe Komlodi <[email protected]>
Reviewed-by: Patrick Venture <[email protected]>
Signed-off-by: Jamin Lin <[email protected]>
Tested-by: Jithu Joseph <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-03-05 18:47:46 +01:00
Jamin Lin 82bf130eae hw/arm/aspeed: Build with I3C_DEVICES
Allows us to attach the mock I3C target

Signed-off-by: Joe Komlodi <[email protected]>
Reviewed-by: Jamin Lin <[email protected]>
Signed-off-by: Jamin Lin <[email protected]>
Tested-by: Jithu Joseph <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-03-05 18:47:46 +01:00
Jamin Lin 05158fadb3 hw/i3c: Add Mock target
Adds a simple i3c device to be used for testing in lieu of a real
device.

The mock target supports the following features:
- A buffer that users can read and write to.
- CCC support for commonly used CCCs when probing devices on an I3C bus.
- IBI sending upon receiving a user-defined byte.

Signed-off-by: Joe Komlodi <[email protected]>
Reviewed-by: Titus Rwantare <[email protected]>
Reviewed-by: Patrick Venture <[email protected]>
Reviewed-by: Jamin Lin <[email protected]>
Signed-off-by: Jamin Lin <[email protected]>
Reviewed-by: Jithu Joseph <[email protected]>
Tested-by: Jithu Joseph <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-03-05 18:47:46 +01:00
Jamin Lin 7ffc895802 hw/i3c/aspeed: Add I3C bus get function
To retrieve the I3C bus object normally, the order is Aspeed I3C -> DW
I3C[n] -> bus object, so make a nice wrapper for people to use.

Signed-off-by: Joe Komlodi <[email protected]>
Reviewed-by: Jamin Lin <[email protected]>
Signed-off-by: Jamin Lin <[email protected]>
Tested-by: Jithu Joseph <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-03-05 18:47:46 +01:00
Jamin Lin e5527d0e31 hw/i3c/dw-i3c: Add controller resets
Adds behavior to the device reset register.

Signed-off-by: Joe Komlodi <[email protected]>
Reviewed-by: Patrick Venture <[email protected]>
Reviewed-by: Stephen Longfield <[email protected]>
Reviewed-by: Jamin Lin <[email protected]>
Signed-off-by: Jamin Lin <[email protected]>
Tested-by: Jithu Joseph <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-03-05 18:47:46 +01:00
Jamin Lin 61c2a72bbc hw/i3c/dw-i3c: Add ctrl MMIO handling
Adds functionality to the CTRL register.

Signed-off-by: Joe Komlodi <[email protected]>
Reviewed-by: Titus Rwantare <[email protected]>
Reviewed-by: Patrick Venture <[email protected]>
Reviewed-by: Jamin Lin <[email protected]>
Signed-off-by: Jamin Lin <[email protected]>
Tested-by: Jithu Joseph <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-03-05 18:47:46 +01:00
Jamin Lin 4cbf835a87 hw/i3c/dw-i3c: Add IBI handling
Adds handling for different IBI events that the controller can receive.
This includes:
- Handling a hot-join from a target
- Handling a secondary controller on the bus requesting to be the
  primary bus controller
- Handling an interrupt request from a target.

When receiving an IBI, the controller sets an interrupt to notify
software about what happened.
When the IBI is finished being serviced, the controller pushes the
result of the IBI and any data received from the target into the IBI
queue.

Signed-off-by: Joe Komlodi <[email protected]>
Reviewed-by: Patrick Venture <[email protected]>
Reviewed-by: Stephen Longfield <[email protected]>
Signed-off-by: Jamin Lin <[email protected]>
Tested-by: Jithu Joseph <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-03-05 18:47:45 +01:00
Jamin Lin 208772a189 hw/i3c/dw-i3c: Add data TX and RX
This adds data and CCC transmission, reception, and the associated
queues required for data transmission and reception to happen.

The I3C controller transmits data by the user writing into a command
queue. When the queue has a command and an argument in it, the
controller starts executing the command.

The controller can execute 1 of 3 ways:
1. A larger data transfer that involves using the TX and RX queues. This
   is the most common way the controller does transactions.

2. A small data transfer that involves sending a couple bytes passed
   into the command queue argument.

3. An address assignment command. This is how the controller does
   ENTDAA. When ENTDAA succeeds in assigning an address to a target, it
   updates the controller's char table with the target's PID, BCR, and
   DCR.

The controller determines what addresses to send by looking at the index
in the device address table specified by the argument in the command
queue. ENTDAA also uses these addresses to assign to targets on the bus.

When the controller is done executing a command, it puts a response in
the response queue indicating how command execution went.

In order for the user to send and receive data to/from the controller,
the user reads/writes to a bidirectional TX/RX port.

Signed-off-by: Joe Komlodi <[email protected]>
Reviewed-by: Stephen Longfield <[email protected]>
Reviewed-by: Patrick Venture <[email protected]>
Signed-off-by: Jamin Lin <[email protected]>
Tested-by: Jithu Joseph <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-03-05 18:47:45 +01:00
Jamin Lin 1a7105014b hw/i3c/dw-i3c: Add IRQ MMIO behavior
Signed-off-by: Joe Komlodi <[email protected]>
Reviewed-by: Patrick Venture <[email protected]>
Reviewed-by: Hao Wu <[email protected]>
Reviewed-by: Jamin Lin <[email protected]>
Signed-off-by: Jamin Lin <[email protected]>
Tested-by: Jithu Joseph <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-03-05 18:47:45 +01:00
Jamin Lin 8141dc2945 hw/i3c/dw-i3c: Use 32 bits on MMIO writes
The registers are only 32 bits wide, so we should cast the 64-bit value
passed in to only be 32 bits wide.

Signed-off-by: Joe Komlodi <[email protected]>
Reviewed-by: Patrick Venture <[email protected]>
Reviewed-by: Titus Rwantare <[email protected]>
Reviewed-by: Jamin Lin <[email protected]>
Signed-off-by: Jamin Lin <[email protected]>
Tested-by: Jithu Joseph <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-03-05 18:47:45 +01:00
Jamin Lin ec449d0dce hw/i3c/dw-i3c: Treat more registers as read-as-zero
RESET_CTRL and INTR_FORCE are write-only.

Signed-off-by: Joe Komlodi <[email protected]>
Reviewed-by: Patrick Venture <[email protected]>
Reviewed-by: Jamin Lin <[email protected]>
Signed-off-by: Jamin Lin <[email protected]>
Tested-by: Jithu Joseph <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-03-05 18:47:45 +01:00
Jamin Lin ca56779a7a hw/i3c/dw-i3c: Add register RO field masks
Adds read-only register masks for the DwC I3C controller.

Signed-off-by: Joe Komlodi <[email protected]>
Reviewed-by: Patrick Venture <[email protected]>
Reviewed-by: Jamin Lin <[email protected]>
Signed-off-by: Jamin Lin <[email protected]>
Tested-by: Jithu Joseph <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-03-05 18:47:45 +01:00
Jamin Lin 84001254ec hw/i3c/aspeed_i3c: Add register RO field masks
Adds read-only register masks for the Aspeed I3C controller registers.

Signed-off-by: Joe Komlodi <[email protected]>
Reviewed-by: Patrick Venture <[email protected]>
Signed-off-by: Jamin Lin <[email protected]>
Tested-by: Jithu Joseph <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-03-05 18:47:45 +01:00
Jamin Lin e974c69575 hw/i3c/dw-i3c: Add more reset values
Adds reset values for the new registers added.

Signed-off-by: Joe Komlodi <[email protected]>
Reviewed-by: Patrick Venture <[email protected]>
Reviewed-by: Jamin Lin <[email protected]>
Signed-off-by: Jamin Lin <[email protected]>
Tested-by: Jithu Joseph <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-03-05 18:47:45 +01:00
Jamin Lin 3adafff6a5 hw/i3c/aspeed_i3c: Add more register fields
Adds the rest of the Aspeed I3C controller register fields.

Signed-off-by: Joe Komlodi <[email protected]>
Reviewed-by: Patrick Venture <[email protected]>
Reviewed-by: Jamin Lin <[email protected]>
Signed-off-by: Jamin Lin <[email protected]>
Tested-by: Jithu Joseph <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-03-05 18:47:45 +01:00
Jamin Lin d2b3d3b3a5 hw/i3c/dw-i3c: Add more register fields
Adds the rest of the Designware register fields.

Signed-off-by: Joe Komlodi <[email protected]>
Reviewed-by: Patrick Venture <[email protected]>
Signed-off-by: Jamin Lin <[email protected]>
Tested-by: Jithu Joseph <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-03-05 18:47:45 +01:00
Jamin Lin 9b3eb0e2db hw/i3c: Split DesignWare I3C out of Aspeed I3C
The Aspeed I3C IP block is technically an Aspeed IP block that manages
6 DW I3C controllers.

To help reflect this better and to make it easier for other SoCs to use
the DW I3C model, we'll split out the DW portion from the Aspeed
portion.

Signed-off-by: Joe Komlodi <[email protected]>
Reviewed-by: Jamin Lin <[email protected]>
Signed-off-by: Jamin Lin <[email protected]>
Tested-by: Jithu Joseph <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-03-05 18:47:45 +01:00
Jamin Lin 7810cfdb62 hw/i3c: Add bus support
Adds an I3C bus and a target class.
The bus supports:
- I3C data transmission and reception
- CCCs (including ENTDAA)
- IBIs
- legacy I2C transactions

General usage of the bus is similar to I2C. Users are expected to
initialize a bus via i3c_init_bus, and use the bus returned from the
init function to do transactions on the bus.

In order to handle IBIs, the controller provides callbacks to handle
receiving an IBI from a target, receiving (optional) additional IBI
bytes from a target, and handling when a target is done with its IBI.

Similarly, target creation is done via i3c_target_create_simple and
users use the provided I3CTarget to handle transactions.
The target has functions provided that it can use to invoke an IBI and
send additional bytes.

Along with the send, recv, and event callbacks that are expected of an
I3C target, which are similar to I2C, there is a separate callback for
CCC handling.
This is to help encapsulate CCC handling and keep it separate from
target-specific read/write functionality.

To avoid repition for required CCCs among I3C targets, there is some
class-level CCC handling added. The CCC is then passed to the target in
case it needs to handle it in some way.

Signed-off-by: Joe Komlodi <[email protected]>
Reviewed-by: Patrick Venture <[email protected]>
Reviewed-by: Titus Rwantare <[email protected]>
Reviewed-by: Jamin Lin <[email protected]>
Signed-off-by: Jamin Lin <[email protected]>
Reviewed-by: Jithu Joseph <[email protected]>
Tested-by: Jithu Joseph <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-03-05 18:47:45 +01:00
Jamin Lin cd0e477107 hw/i3c/aspeed_i3c: Switch to DEFINE_TYPES() and align parent_obj naming
Following review feedback, update the Aspeed I3C device to use the
DEFINE_TYPES() macro instead of an explicit type registration function.

DEFINE_TYPES() is the currently recommended approach in QEMU for
registering multiple TypeInfo entries and avoids boilerplate
type_init() code.

Additionally, rename embedded SysBusDevice fields from "parent" to
"parent_obj" to comply with the QEMU coding style guidelines for QOM
objects.

No functional change.

Signed-off-by: Jamin Lin <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Tested-by: Jithu Joseph <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-03-05 18:47:45 +01:00
Jamin Lin 4ef278c904 hw/misc/aspeed_i3c: Move to i3c directory
Moves the Aspeed I3C model and traces into hw/i3c and creates I3C build
files.

Signed-off-by: Joe Komlodi <[email protected]>
Reviewed-by: Patrick Venture <[email protected]>
Reviewed-by: Titus Rwantare <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Reviewed-by: Jamin Lin <[email protected]>
Signed-off-by: Jamin Lin <[email protected]>
Tested-by: Jithu Joseph <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-03-05 18:47:45 +01:00
Jamin Lin 402d5bf061 hw/i2c/aspeed_i2c: Fix DMA64 address handling
The current code updates the upper 32 bits of dma_dram_offset only when
aic->has_dma64 is false, which is incorrect.

If aic->has_dma64 is true, the controller supports 64-bit DMA addressing
and the upper 32-bit DMA address register must be used to update the
dma_dram_offset accordingly.

Fix the condition so that the upper 32 bits are updated only when
64-bit DMA is supported.

Fixes: efea7ddb46 ("hw/i2c/aspeed_i2c: Fix DMA moving data into incorrect address")
Signed-off-by: Jamin Lin <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-03-05 18:47:45 +01:00
Jon Kohler ca61f91ef9 util/oslib-posix: increase memprealloc thread count to 32
Increase MAX_MEM_PREALLOC_THREAD_COUNT from 16 to 32. This was last
touched in 2017 [1] and, since then, physical machine sizes and VMs
therein have continue to get even bigger, both on average and on the
extremes.

For very large VMs, using 16 threads to preallocate memory can be a
non-trivial bottleneck during VM start-up and migration. Increasing
this limit to 32 threads reduces the time taken for these operations.

Test results from quad socket Intel 8490H (4x 60 cores) show a fairly
linear gain of 50% with the 2x thread count increase.

---------------------------------------------
Idle Guest w/ 2M HugePages   | Start-up time
---------------------------------------------
240 vCPU, 7.5TB (16 threads) | 2m41.955s
---------------------------------------------
240 vCPU, 7.5TB (32 threads) | 1m19.404s
---------------------------------------------

Note: Going above 32 threads appears to have diminishing returns at
the point where the memory bandwidth and context switching costs
appear to be a limiting factor to linear scaling. For posterity, on
the same system as above:
- 32 threads: 1m19s
- 48 threads: 1m4s
- 64 threads: 59s
- 240 threads: 50s

Additional thread counts also get less interesting as the amount of
memory is to be preallocated is smaller. Putting that all together,
32 threads appears to be a sane number with a solid speedup on fairly
modern hardware. To go faster, we'd either need to improve the hardware
(CPU/memory) itself or improve clear_pages_*() on the kernel side to
be more efficient.

[1] 1e356fc14b ("mem-prealloc: reduce large guest start-up and migration time.")

Signed-off-by: Jon Kohler <[email protected]>
Reviewed-by: Daniel P. Berrangé <[email protected]>
Signed-off-by: Daniel P. Berrangé <[email protected]>
2026-03-05 17:40:24 +00:00
Markus Armbruster 33273219eb scripts/checkpatch: Fix MAINTAINERS update warning with --terse
We recently improved the MAINTAINERS update warning to show the files
that trigger it.  Example:

    WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
    #105:
    deleted file mode 100644

improved to

    WARNING: added, moved or deleted file(s):

      migration/threadinfo.h
      migration/threadinfo.c

    Does MAINTAINERS need updating?

Unfortunately, this made things worse with --terse, as only the first
line of each warning is shown then.

    WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?

became

    WARNING: added, moved or deleted file(s):

Adjust the warning text to

    WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
      migration/threadinfo.h
      migration/threadinfo.c

so we get the exact same warning as we used to with --terse.

Fixes: 1d745e6d96 (scripts/checkpatch: use new hook for MAINTAINERS update check)
Signed-off-by: Markus Armbruster <[email protected]>
Reviewed-by: Daniel P. Berrangé <[email protected]>
[DB: fix typo with missing string concat operator]
Signed-off-by: Daniel P. Berrangé <[email protected]>
2026-03-05 17:40:24 +00:00
Daniel P. Berrangé 13bedeb212 util: fix interleaving of error prefixes
The vreport() function will optionally emit an prefix for error
messages which is output to stderr incrementally. In the event
that two vreport() calls execute concurrently, there is a risk
that the prefix output will interleave. To address this it is
required to take a lock on 'stderr' when outputting errors.

Reported-by: Markus Armbruster <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Signed-off-by: Daniel P. Berrangé <[email protected]>
2026-03-05 17:40:24 +00:00
Daniel P. Berrangé 6365e97c84 util: don't skip error prefixes when QMP is active
The vreport() function will print to HMP if available, otherwise
to stderr. In the event that vreport() is called during execution
of a QMP command, it will print to stderr, but mistakenly omit the
message prefixes (timestamp, guest name, program name).

This new usage of monitor_is_cur_qmp() from vreport() requires that
we add a stub to satisfy linking of non-system emulator binaries.

Signed-off-by: Daniel P. Berrangé <[email protected]>
2026-03-05 17:40:24 +00:00
Daniel P. Berrangé 2eb00abcfe util: fix interleaving of error & trace output
The monitor_cur_hmp() function will acquire/release mutex locks, which
will trigger trace probes, which can in turn trigger qemu_log() calls.
vreport() calls monitor_cur() multiple times through its execution
both directly and indirectly via error_vprintf().

The result is that the prefix information printed by vreport() gets
interleaved with qemu_log() output, when run outside the context of
an HMP command dispatcher. This can be seen with:

 $ qemu-system-x86_64 \
     -msg timestamp=on,guest-name=on \
     -display none \
     -object tls-creds-x509,id=f,dir=fish \
     -name fish \
     -d trace:qemu_mutex*
   2025-09-10T16:30:42.514374Z qemu_mutex_unlock released mutex 0x560b0339b4c0 (/var/home/berrange/src/virt/qemu/include/qemu/lockable.h:56)
   2025-09-10T16:30:42.514400Z qemu_mutex_lock waiting on mutex 0x560b033983e0 (/var/home/berrange/src/virt/qemu/include/qemu/lockable.h:56)
   2025-09-10T16:30:42.514402Z qemu_mutex_locked taken mutex 0x560b033983e0 (/var/home/berrange/src/virt/qemu/include/qemu/lockable.h:56)
   2025-09-10T16:30:42.514404Z qemu_mutex_unlock released mutex 0x560b033983e0 (/var/home/berrange/src/virt/qemu/include/qemu/lockable.h:56)
   2025-09-10T16:30:42.516716Z qemu_mutex_lock waiting on mutex 0x560b03398560 (../monitor/monitor.c:91)
   2025-09-10T16:30:42.516723Z qemu_mutex_locked taken mutex 0x560b03398560 (../monitor/monitor.c:91)
   2025-09-10T16:30:42.516726Z qemu_mutex_unlock released mutex 0x560b03398560 (../monitor/monitor.c:96)
   2025-09-10T16:30:42.516728Z qemu_mutex_lock waiting on mutex 0x560b03398560 (../monitor/monitor.c:91)
   2025-09-10T16:31:04.842057Z qemu_mutex_locked taken mutex 0x564f5e401560 (../monitor/monitor.c:91)
   2025-09-10T16:31:04.842058Z qemu_mutex_unlock released mutex 0x564f5e401560 (../monitor/monitor.c:96)
   2025-09-10T16:31:04.842055Z 2025-09-10T16:31:04.842060Z qemu_mutex_lock waiting on mutex 0x564f5e401560 (../monitor/monitor.c:91)
   2025-09-10T16:31:04.842061Z qemu_mutex_locked taken mutex 0x564f5e401560 (../monitor/monitor.c:91)
   2025-09-10T16:31:04.842062Z qemu_mutex_unlock released mutex 0x564f5e401560 (../monitor/monitor.c:96)
   2025-09-10T16:31:04.842064Z qemu_mutex_lock waiting on mutex 0x564f5e401560 (../monitor/monitor.c:91)
   2025-09-10T16:31:04.842065Z qemu_mutex_locked taken mutex 0x564f5e401560 (../monitor/monitor.c:91)
   2025-09-10T16:31:04.842066Z qemu_mutex_unlock released mutex 0x564f5e401560 (../monitor/monitor.c:96)
   fish 2025-09-10T16:31:04.842068Z qemu_mutex_lock waiting on mutex 0x564f5e401560 (../monitor/monitor.c:91)
   2025-09-10T16:31:04.842069Z qemu_mutex_locked taken mutex 0x564f5e401560 (../monitor/monitor.c:91)
   2025-09-10T16:31:04.842070Z qemu_mutex_unlock released mutex 0x564f5e401560 (../monitor/monitor.c:96)
   2025-09-10T16:31:04.842072Z qemu_mutex_lock waiting on mutex 0x564f5e401560 (../monitor/monitor.c:91)
   2025-09-10T16:31:04.842097Z qemu_mutex_locked taken mutex 0x564f5e401560 (../monitor/monitor.c:91)
   2025-09-10T16:31:04.842099Z qemu_mutex_unlock released mutex 0x564f5e401560 (../monitor/monitor.c:96)
   qemu-system-x86_64:2025-09-10T16:31:04.842100Z qemu_mutex_lock waiting on mutex 0x564f5e401560 (../monitor/monitor.c:91)
   2025-09-10T16:31:04.842102Z qemu_mutex_locked taken mutex 0x564f5e401560 (../monitor/monitor.c:91)
   2025-09-10T16:31:04.842103Z qemu_mutex_unlock released mutex 0x564f5e401560 (../monitor/monitor.c:96)
    2025-09-10T16:31:04.842105Z qemu_mutex_lock waiting on mutex 0x564f5e401560 (../monitor/monitor.c:91)
   2025-09-10T16:31:04.842106Z qemu_mutex_locked taken mutex 0x564f5e401560 (../monitor/monitor.c:91)
   2025-09-10T16:31:04.842107Z qemu_mutex_unlock released mutex 0x564f5e401560 (../monitor/monitor.c:96)
   Unable to access credentials fish/ca-cert.pem: No such file or directory2025-09-10T16:31:04.842109Z qemu_mutex_lock waiting on mutex 0x564f5e401560 (../monitor/monitor.c:91)
   2025-09-10T16:31:04.842110Z qemu_mutex_locked taken mutex 0x564f5e401560 (../monitor/monitor.c:91)
   2025-09-10T16:31:04.842111Z qemu_mutex_unlock released mutex 0x564f5e401560 (../monitor/monitor.c:96)

To avoid this interleaving (as well as reduce the huge number of
mutex lock/unlock calls) we need to ensure that monitor_cur_is_hmp()
is only called once at the start of vreport(), and if no HMP is
present, no further monitor APIs can be called.

This implies error_[v]printf() cannot be called from vreport().
Instead we must introduce error_[v]printf_mon() which accept a
pre-acquired Monitor object. In some cases, however, fprintf
can be called directly as output will never be directed to the
monitor.

 $ qemu-system-x86_64 \
     -msg timestamp=on,guest-name=on \
     -display none \
     -object tls-creds-x509,id=f,dir=fish \
     -name fish \
     -d trace:qemu_mutex*
   2025-09-10T16:31:22.701691Z qemu_mutex_unlock released mutex 0x5626fd3b84c0 (/var/home/berrange/src/virt/qemu/include/qemu/lockable.h:56)
   2025-09-10T16:31:22.701728Z qemu_mutex_lock waiting on mutex 0x5626fd3b53e0 (/var/home/berrange/src/virt/qemu/include/qemu/lockable.h:56)
   2025-09-10T16:31:22.701730Z qemu_mutex_locked taken mutex 0x5626fd3b53e0 (/var/home/berrange/src/virt/qemu/include/qemu/lockable.h:56)
   2025-09-10T16:31:22.701732Z qemu_mutex_unlock released mutex 0x5626fd3b53e0 (/var/home/berrange/src/virt/qemu/include/qemu/lockable.h:56)
   2025-09-10T16:31:22.703989Z qemu_mutex_lock waiting on mutex 0x5626fd3b5560 (../monitor/monitor.c:91)
   2025-09-10T16:31:22.703996Z qemu_mutex_locked taken mutex 0x5626fd3b5560 (../monitor/monitor.c:91)
   2025-09-10T16:31:22.703999Z qemu_mutex_unlock released mutex 0x5626fd3b5560 (../monitor/monitor.c:96)
   2025-09-10T16:31:22.704000Z fish qemu-system-x86_64: Unable to access credentials fish/ca-cert.pem: No such file or directory

Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Daniel P. Berrangé <[email protected]>
2026-03-05 17:40:24 +00:00
Daniel P. Berrangé a582a5784e monitor: move error_vprintf back to error-report.c
The current unit tests rely on monitor.o not being linked, such
that the monitor stubs get linked instead. Since error_vprintf
is in monitor.o this allows a stub error_vprintf impl to be used
that calls g_test_message.

This takes a different approach, with error_vprintf moving
back to error-report.c such that it is always linked into the
tests. The monitor_vprintf() stub is then changed to use
g_test_message if QTEST_SILENT_ERRORS is set, otherwise it will
return -1 and trigger error_vprintf to call vfprintf.

The end result is functionally equivalent for the purposes of
the unit tests.

Reviewed-by: Richard Henderson <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Signed-off-by: Daniel P. Berrangé <[email protected]>
2026-03-05 17:40:24 +00:00
Daniel P. Berrangé cd670accb5 monitor: refactor error_vprintf()
The monitor_vprintf() code will return -1 if either the monitor
is NULL, or the monitor is QMP. The error_vprintf() code can
take advantage of this to avoid having to duplicate the same
checks, and instead simply look at the return value.

Reviewed-by: Richard Henderson <[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Signed-off-by: Daniel P. Berrangé <[email protected]>
2026-03-05 17:40:24 +00:00
Daniel P. Berrangé 7818c014ef monitor: remove redundant error_[v]printf_unless_qmp
The only callers of these functions have been removed. Adding any
new usage of them is highly undesirable, so they should be entirely
removed.

Reviewed-by: Richard Henderson <[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Daniel P. Berrangé <[email protected]>
2026-03-05 17:40:24 +00:00
Daniel P. Berrangé f917c060ee ui: remove redundant use of error_printf_unless_qmp()
The vnc_display_print_local_addr() method is intended to print the VNC
listening address on the console at startup, so the user can see the
auto-chosen port address when using the 'to=' flag. This is only called
by vnc_display_open() which is in the QEMU startup callpath. The check
for not being in QMP is thus redundant and can be removed.

Reviewed-by: Markus Armbruster <[email protected]>
Signed-off-by: Daniel P. Berrangé <[email protected]>
2026-03-05 17:40:24 +00:00
Daniel P. Berrangé 912f969e35 ui: add proper error reporting for password changes
Neither the VNC or SPICE code for password changes provides error
reporting at source, leading the callers to report a largely useless
generic error message.

Fixing this removes one of the two remaining needs for the undesirable
error_printf_unless_qmp() method.

While fixing this the error message hint is improved to recommend the
'password-secret' option which allows securely passing a password at
startup.

Reported-by: Markus Armbruster <[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Signed-off-by: Daniel P. Berrangé <[email protected]>
2026-03-05 17:40:24 +00:00
Daniel P. Berrangé 03eb6f411f util/log: add missing error reporting in qemu_log_trylock_with_err
One codepath that could return NULL failed to populate the errp
object.

Reported-by: Markus Armbruster <[email protected]>
Signed-off-by: Daniel P. Berrangé <[email protected]>
2026-03-05 17:40:24 +00:00
Daniel P. Berrangé 338f63e5f0 util: avoid repeated prefix on incremental qemu_log calls
There are three general patterns to QEMU log output

 1. Single complete message calls

      qemu_log("Some message\n");

 2. Direct use of fprintf

      FILE *f = qemu_log_trylock()
      fprintf(f, "...");
      fprintf(f, "...");
      fprintf(f, "...\n");
      qemu_log_unlock(f)

 3. Mixed use of qemu_log_trylock/qemu_log()

      FILE *f = qemu_log_trylock()
      qemu_log("....");
      qemu_log("....");
      qemu_log("....\n");
      qemu_log_unlock(f)

When message prefixes are enabled, the timestamp will be
unconditionally emitted for all qemu_log() calls. This
works fine in the 1st case, and has no effect in the 2nd
case. In the 3rd case, however, we get the timestamp
printed over & over in each fragment.

One can suggest that pattern (3) is pointless as it is
functionally identical to (2) but with extra indirection
and overhead. None the less we have a fair bit of code
that does this.

The qemu_log() call itself is nothing more than a wrapper
which does pattern (2) with a single fprintf() call.

One might question whether (2) should include the message
prefix in the same way that (1), but there are scenarios
where this could be inappropriate / unhelpful such as the
CPU register dumps or linux-user strace output.

This patch fixes the problem in pattern (3) by keeping
track of the call depth of qemu_log_trylock() and then
only emitting the the prefix when the starting depth
was zero. In doing this qemu_log_trylock_context() is
also introduced as a variant of qemu_log_trylock()
that emits the prefix. Callers doing to batch output
can thus choose whether a prefix is appropriate or
not.

Fixes: 012842c075 (log: make '-msg timestamp=on' apply to all qemu_log usage)
Reported-by: Richard Henderson <[email protected]>
Signed-off-by: Daniel P. Berrangé <[email protected]>
2026-03-05 17:40:24 +00:00
Daniel P. Berrangé e43c84813f util: introduce some API docs for logging APIs
There is a gotcha with qemu_log() usage in a threaded process.
If fragments of a log message are output via qemu_log() it is
possible for messages from two threads to get mixed up. To
prevent this qemu_log_trylock() should be used, along with
fprintf(f) calls.

This is a subtle problem that needs to be explained in the
API docs to ensure correct usage.

In the Rust code, the log_mask_ln method which is conceptually
equivalent to the C qemu_log() call will unconditionally append
a newline so must only ever be used for complete log messages.

Reported-by: Markus Armbruster <[email protected]>
Signed-off-by: Daniel P. Berrangé <[email protected]>
2026-03-05 17:40:24 +00:00
Daniel P. Berrangé 215235d365 util: add API to fetch the current thread name
This will be used to include the thread name in error reports
in a later patch. It returns a const string stored in a thread
local to avoid memory allocation when it is called repeatedly
in a single thread. The thread name should be set at the very
start of the thread execution, which is the case when using
qemu_thread_create.

This uses the official thread APIs for fetching thread names,
so that it captures  names of threads spawned by code in 3rd
party libraries, not merely QEMU spawned thrads.

This also addresses the gap from the previous patch for setting
the name of the main thread. A constructor is used to initialize
the 'namebuf' thread-local in the main thread only.

Signed-off-by: Daniel P. Berrangé <[email protected]>
2026-03-05 17:40:24 +00:00
Daniel P. Berrangé d74938d14c util: set the name for the 'main' thread on Windows
The default main thread name is undefined, so use a constructor to
explicitly set it to 'main'. This constructor is marked to run early
as the thread name is intended to be used in error reporting / logs
which may be triggered very early in QEMU execution.

This is only done on Windows platforms, because on Linux (and possibly
other POSIX platforms) changing the main thread name has a side effect
of changing the process name reported by tools like 'ps' which fetch
from the file /proc/self/task/tid/comm, expecting it to be the binary
name.

The subsequent patch will address POSIX platforms in a different way.

Reviewed-by: Richard Henderson <[email protected]>
Reviewed-by: Dr. David Alan Gilbert <[email protected]>
Signed-off-by: Daniel P. Berrangé <[email protected]>
2026-03-05 17:40:24 +00:00
Daniel P. Berrangé 8f68a33ad4 audio: make jackaudio use qemu_thread_set_name
This has greater portability than directly call pthread_setname_np,
which is only 1 out of 3 possible functions for pthreads that can
set the name.

The new API requires a trampoline function, since it can only set
the name of the current thread.

Reviewed-by: Christian Schoenebeck <[email protected]>
Signed-off-by: Daniel P. Berrangé <[email protected]>
2026-03-05 17:40:24 +00:00
Daniel P. Berrangé 46255cc2be util: expose qemu_thread_set_name
The ability to set the thread name needs to be used in a number
of places, so expose the current impls as public methods.

Reviewed-by: Richard Henderson <[email protected]>
Reviewed-by: Dr. David Alan Gilbert <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Signed-off-by: Daniel P. Berrangé <[email protected]>
2026-03-05 17:40:24 +00:00
Daniel P. Berrangé 71d81b320d util: fix race setting thread name on Win32
The call to set the thread name on Win32 platforms is done by the parent
thread, after _beginthreadex() returns. At this point the new child
thread is potentially already executing its start method. To ensure the
thread name is guaranteed to be set before any "interesting" code starts
executing, it must be done in the start method of the child thread itself.

Reviewed-by: Richard Henderson <[email protected]>
Reviewed-by: Dr. David Alan Gilbert <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Signed-off-by: Daniel P. Berrangé <[email protected]>
2026-03-05 17:40:24 +00:00
Daniel P. Berrangé 1b65aeed2a system: unconditionally enable thread naming
When thread naming was introduced years ago, it was disabled by
default and put behind a command line flag:

  commit 8f480de0c9
  Author: Dr. David Alan Gilbert <[email protected]>
  Date:   Thu Jan 30 10:20:31 2014 +0000

    Add 'debug-threads' suboption to --name

This was done based on a concern that something might depend
on the historical thread naming. Thread names, however, were
never promised to be part of QEMU's public API. The defaults
will vary across platforms, so no assumptions should ever be
made about naming.

An opt-in behaviour is also unfortunately incompatible with
RCU which creates its thread from an constructor function
which is run before command line args are parsed. Thus the
RCU thread lacks any name.

libvirt has unconditionally enabled debug-threads=yes on all
VMs it creates for 10 years. Interestingly this DID expose a
bug in libvirt, as it parsed /proc/$PID/stat and could not
cope with a space in the thread name. This was a latent
pre-existing bug in libvirt though, and not a part of QEMU's
API.

Having thread names always available, will allow thread names
to be included in error reports and log messags QEMU prints
by default, which will improve ability to triage QEMU bugs.

Reviewed-by: Dr. David Alan Gilbert <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Signed-off-by: Daniel P. Berrangé <[email protected]>
2026-03-05 17:40:24 +00:00
Daniel P. Berrangé 65c67540b7 monitor: initialize global data from a constructor
Some monitor functions, most notably, monitor_cur() rely on global
data being initialized by 'monitor_init_globals()'. The latter is
called relatively late in startup. If code triggers error_report()
before monitor_init_globals() is called, QEMU will abort when
accessing the uninitialized monitor mutex.

The critical monitor global data must be initialized from a
constructor function, to improve the guarantee that it is done
before any possible calls to monitor_cur(). Not only that, but
the constructor must be marked to run before the default
constructor in case any of them trigger error reporting.

Note in particular that the RCU constructor will spawn a background
thread so we might even have non-constructor QEMU code running
concurrently with other constructors.

As a general note, constructors should be extrememly careful
about what QEMU code they invoke, as it cannot be guaranteed that
the process is fully initialized and so not all normal QEMU API
rules apply.

Reviewed-by: Richard Henderson <[email protected]>
Reviewed-by: Dr. David Alan Gilbert <[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Fixes: e69ee454b5 (monitor: Make current monitor a per-coroutine property)
Signed-off-by: Daniel P. Berrangé <[email protected]>
2026-03-05 17:40:24 +00:00
Daniel P. Berrangé e3d9c2a0ce include: define constant for early constructor priority
Functions marked with __attribute__((__constructor__)) will be
invoked in linker order. In theory this is well defined, but
in practice, it is hard to determine what this order will be
with the layers of indirection through meson, ninja and the
static libraries QEMU builds.

Notably, the order currently appears different between Linux
and Windows (as tested with Wine on Linux). This can cause
problems when certain QEMU constructors have a dependancy on
other QEMU constructors.

To address this define a QEMU_CONSTRUCTOR_EARLY constant which
provides a priority value that will run before other default
constructors. This is to be used for QEMU constructors that
are themselves self-contained, but may be relied upon by other
constructors.

Reviewed-by: Richard Henderson <[email protected]>
Reviewed-by: Dr. David Alan Gilbert <[email protected]>
Signed-off-by: Daniel P. Berrangé <[email protected]>
2026-03-05 17:40:24 +00:00
Daniel P. Berrangé cbb724e0bd qemu-options: remove extraneous [] around arg values
There are quite a few inappropriate uses of [...] around argument
values. The [] are intended to indicate optionality, but in some
cases it is used to wrap a set of enum values. In other cases it
is being used to show the value is entirely optional, which was
common behaviour for boolean values in the past. QEMU has deprecated
short-form boolean options for quite a while though, and we should
thus not advertize this possibility in the docs.

Reviewed-by: Markus Armbruster <[email protected]>
Signed-off-by: Daniel P. Berrangé <[email protected]>
2026-03-05 17:40:24 +00:00
Daniel P. Berrangé 3275771e91 docs: simplify DiamondRapids CPU docs
This aligns the first line of the docs with the style used for previous
CPU models, and simplifies the text in the remaining docs.

Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Zhao Liu <[email protected]>
Signed-off-by: Daniel P. Berrangé <[email protected]>
2026-03-05 17:40:24 +00:00
Daniel P. Berrangé 9545c059f7 io: fix cleanup for websock I/O source data on cancellation
The websock code will create a GSource for tracking completion of the
handshake process, passing a QIOTask which is freed by the callback
when it completes, which means when a source is cancelled, nothing is
free'ing the task.

Switch to provide a data free callback to the GSource, which ensures
the QIOTask is always freed even when the main event callback never
fires.

Fixes: https://gitlab.com/qemu-project/qemu/-/issues/3114
Signed-off-by: Daniel P. Berrangé <[email protected]>
2026-03-05 17:40:24 +00:00
Daniel P. Berrangé d39d0f3acd io: fix cleanup for TLS I/O source data on cancellation
The TLS code will create a GSource for tracking completion of the
handshake process, passing a QIOChannelTLSData struct that contains
various data items. The data struct is freed by the callback when
it completes, which means when a source is cancelled, nothing is
free'ing the data struct or its contents.

Switch to provide a data free callback to the GSource, which ensures
the QIOChannelTLSData struct is always freed even when the main event
callback never fires.

Fixes: https://gitlab.com/qemu-project/qemu/-/issues/3114
Reviewed-by: Marc-André Lureau <[email protected]>
Signed-off-by: Daniel P. Berrangé <[email protected]>
2026-03-05 17:40:24 +00:00
Peter Maydell 314ff2e07d Merge tag 'pull-request-2026-03-05' of https://gitlab.com/thuth/qemu into staging
* Remove deprecated i440fx and q35 machine types -2.8 up to -2.12
* Remove the related hw_compat handling in various devices

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCgAdFiEEJ7iIR+7gJQEY8+q5LtnXdP5wLbUFAmmpWuMACgkQLtnXdP5w
# LbXSjhAAoJ/vG6HZeuyrUzE9jkVToOpUF7d72usWS8NP07KYgKNp0kVQ/5C/QQ2s
# PR7jdWSQT7Vl+iyzvNdSV+y64rdk3XcdCrbeDXA9N4+yqWNEbq2MYECYQAW18xBR
# i8g1e9+Y/yi4yXV7U76Jx7R89btVzRdbrENlypKS2wf5wXA5m8HUegxhl8NC59eg
# u3tjZgG+tr2Fkdhs8EPA1p8naDXd00fy3imgpzN4VhGzdXTzHtH/fa5UDMjBRJtc
# NheCC4Oe0EglhDQrj+uxVf8aklCXDhSXHRKqGOOTP65z41J4gBL0k2zATAReYp3G
# RhOMtEl66U+XOFeKYxh55zS3OAK6i/Yx9K7EQwZNbZks8DJhO23Ai3TZWg086mFg
# bxr2cSpo5JKdpiQeL28GQTYA/f0wNwcn9Q01QrerfO0VTXsW4pC3rc4HukJOwp/b
# KozT4se7VtxzlJVJ7oCAYYjqiw+DZc4z7tbf/fcvyNsnHAkJB3gHeb3lJB/PW0je
# eh2N2q4Qe20ewbJbl+l+BisQ3XTDUQRf46d8iw0flvvpeAgw1Raw7cpTS+tg52wU
# UzVl8slrQcDf8Mm+BMfbcmmO7W2Zhl7c7+7RXmDVrRiHdnR4jkRcGyk4HzEObqjs
# dyYW3h2Z519TVCDdxpF6MQNy+Za9UlOOBmR0WfhRueoNM4ebCuA=
# =QYGn
# -----END PGP SIGNATURE-----
# gpg: Signature made Thu Mar  5 10:28:51 2026 GMT
# gpg:                using RSA key 27B88847EEE0250118F3EAB92ED9D774FE702DB5
# gpg: Good signature from "Thomas Huth <[email protected]>" [full]
# gpg:                 aka "Thomas Huth <[email protected]>" [full]
# gpg:                 aka "Thomas Huth <[email protected]>" [full]
# gpg:                 aka "Thomas Huth <[email protected]>" [undefined]
# Primary key fingerprint: 27B8 8847 EEE0 2501 18F3  EAB9 2ED9 D774 FE70 2DB5

* tag 'pull-request-2026-03-05' of https://gitlab.com/thuth/qemu: (28 commits)
  hw/display/vga-pci: Do not expose the 'global-vmstate' property
  hw/audio/hda-codec: Remove HDAAudioState::use_timer field
  hw/core/machine: Remove hw_compat_2_12[] array
  hw/core/machine: Remove hw_compat_2_11[] array
  hw/input/virtio-input: Remove VirtIOInputHID::wheel_axis field
  hw/core/machine: Remove hw_compat_2_10[] array
  hw/i386/pc: Remove pc_compat_2_12[] array
  hw/i386/pc: Remove deprecated pc-q35-2.12 and pc-i440fx-2.12 machines
  hw/i386/pc: Remove pc_compat_2_11[] array
  hw/i386/pc: Remove deprecated pc-q35-2.11 and pc-i440fx-2.11 machines
  hw/i386/pc: Remove pc_compat_2_10[] array
  hw/i386/pc: Remove deprecated pc-q35-2.10 and pc-i440fx-2.10 machines
  tests/qtest/test-x86-cpuid-compat: Remove the test with the i440fx-2.9 machine
  hw/i386/x86-iommu: Remove X86IOMMUState::pt_supported field
  hw/pci-bridge/gen_pcie_rp: Remove GenPCIERootPort::migrate_msix field
  hw/net/virtio-net: Remove VirtIONet::mtu_bypass_backend field
  hw/core/machine: Remove hw_compat_2_9[] array
  hw/i386/pc: Remove pc_compat_2_9[] array
  hw/i386/pc: Remove deprecated pc-q35-2.9 and pc-i440fx-2.9 machines
  hw/virtio/virtio-pci: Remove VIRTIO_PCI_FLAG_INIT_PM definition
  ...

Signed-off-by: Peter Maydell <[email protected]>
2026-03-05 16:58:20 +00:00
Peter Maydell ae6e281633 Merge tag 'pull-loongarch-20260302' of https://github.com/gaosong715/qemu into staging
pull-loongarch-20260302

# -----BEGIN PGP SIGNATURE-----
#
# iLMEAAEKAB0WIQTKRzxE1qCcGJoZP81FK5aFKyaCFgUCaaVgvwAKCRBFK5aFKyaC
# FsyvA/oD4HhxbCjv6ukdYHkSj3rMxo0aTV9RzNSUGhdrC4v6LPnRf2JeEV9K65BU
# HEctYSMI64iasQBQx1FruFlVMJz+mYhHwv+FvE94TrZq1lTmbYdO1qOTChO+m+60
# B2qtT3pORejLLeawHighD9d8MkbNlXsysSMFRn4PwRYvFmYY9w==
# =CYNU
# -----END PGP SIGNATURE-----
# gpg: Signature made Mon Mar  2 10:04:47 2026 GMT
# gpg:                using RSA key CA473C44D6A09C189A193FCD452B96852B268216
# gpg: Good signature from "Song Gao <[email protected]>" [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: CA47 3C44 D6A0 9C18 9A19  3FCD 452B 9685 2B26 8216

* tag 'pull-loongarch-20260302' of https://github.com/gaosong715/qemu:
  target/loongarch: Add some CPUCFG bits with host CPU model
  target/loongarch: Add host CPU model in kvm mode
  target/loongarch: Add generic CPU model information
  target/loongarch: Add default cpucfg3 with LA464 CPU
  target/loongarch: Add detailed information with CPU Product ID
  target/loongarch: Add property set with query-cpu-model-expansion
  target/loongarch: Add full type support with query-cpu-model-expansion
  target/loongarch: Add missing vCPU features with QMP method

Signed-off-by: Peter Maydell <[email protected]>
2026-03-05 10:48:38 +00:00
Philippe Mathieu-Daudé 711de639d5 hw/display/vga-pci: Do not expose the 'global-vmstate' property
The "global-vmstate" property is 'false' by default, and was only
set to 'true' in the hw_compat_2_12[] array. We removed all machines
using that array. Stop exposing that property on the PCI devices.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
2026-03-05 10:33:25 +01:00
Philippe Mathieu-Daudé c2c8805742 hw/audio/hda-codec: Remove HDAAudioState::use_timer field
The HDAAudioState::use_timer boolean was only set in the
hw_compat_2_12[] array, via the 'use-timer=false' property.
We removed all machines using that array, lets remove that
property and all the code around it, like the compatibility
callbacks.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
[thuth: Rebased the patch to current master branch, fixed conflicts]
Signed-off-by: Thomas Huth <[email protected]>
2026-03-05 10:33:25 +01:00
Philippe Mathieu-Daudé f09613cf87 hw/core/machine: Remove hw_compat_2_12[] array
The hw_compat_2_12[] array was only used by the pc-q35-2.12,
pc-i440fx-2.12 and s390-ccw-virtio-2.12 machines, which got
removed. Remove it.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
2026-03-05 10:33:06 +01:00
Philippe Mathieu-Daudé 070b3287ab hw/core/machine: Remove hw_compat_2_11[] array
The hw_compat_2_11[] array was only used by the pc-q35-2.11,
pc-i440fx-2.11 and s390-ccw-virtio-2.11 machines, which got
removed. Remove it.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
2026-03-05 09:04:11 +01:00
Philippe Mathieu-Daudé bb8f84727f hw/input/virtio-input: Remove VirtIOInputHID::wheel_axis field
The VirtIOInputHID::wheel_axis boolean was only set in the
hw_compat_2_10[] array, via the 'wheel-axis=false' property.
We removed all machines using that array, lets remove that
property and all the code around it. There is only one
virtio_input_config[] version for each device, rename it
removing the '_v2' suffix.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
2026-03-05 09:04:07 +01:00
Philippe Mathieu-Daudé 67b0c007c6 hw/core/machine: Remove hw_compat_2_10[] array
The hw_compat_2_10[] array was only used by the pc-q35-2.10,
pc-i440fx-2.10 and s390-ccw-virtio-2.10 machines, which got
removed. Remove it.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
2026-03-05 09:03:40 +01:00
Philippe Mathieu-Daudé 4395ee372e hw/i386/pc: Remove pc_compat_2_12[] array
The pc_compat_2_12[] array was only used by the pc-q35-2.12
and pc-i440fx-2.12 machines, which got removed. Remove it.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Reviewed-by: Xiaoyao Li <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
2026-03-05 08:17:02 +01:00
Philippe Mathieu-Daudé 0313087adf hw/i386/pc: Remove deprecated pc-q35-2.12 and pc-i440fx-2.12 machines
These machines has been supported for a period of more than 6 years.
According to our versioned machine support policy (see commit
ce80c4fa6f "docs: document special exception for machine type
deprecation & removal") they can now be removed.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Reviewed-by: Xiaoyao Li <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
2026-03-05 08:16:54 +01:00
Philippe Mathieu-Daudé ce4ce7f43d hw/i386/pc: Remove pc_compat_2_11[] array
The pc_compat_2_11[] array was only used by the pc-q35-2.11
and pc-i440fx-2.11 machines, which got removed. Remove it.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Reviewed-by: Xiaoyao Li <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
2026-03-05 08:16:49 +01:00
Philippe Mathieu-Daudé 89d48b3f91 hw/i386/pc: Remove deprecated pc-q35-2.11 and pc-i440fx-2.11 machines
These machines has been supported for a period of more than 6 years.
According to our versioned machine support policy (see commit
ce80c4fa6f "docs: document special exception for machine type
deprecation & removal") they can now be removed.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Reviewed-by: Xiaoyao Li <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
2026-03-05 08:16:40 +01:00
Philippe Mathieu-Daudé 16dade7591 hw/i386/pc: Remove pc_compat_2_10[] array
The pc_compat_2_10[] array was only used by the pc-q35-2.10
and pc-i440fx-2.10 machines, which got removed. Remove it.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Reviewed-by: Xiaoyao Li <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
2026-03-05 08:16:29 +01:00
Philippe Mathieu-Daudé 89343afd04 hw/i386/pc: Remove deprecated pc-q35-2.10 and pc-i440fx-2.10 machines
These machines has been supported for a period of more than 6 years.
According to our versioned machine support policy (see commit
ce80c4fa6f "docs: document special exception for machine type
deprecation & removal") they can now be removed.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Reviewed-by: Xiaoyao Li <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
2026-03-05 08:15:12 +01:00
Thomas Huth 3d07240f81 tests/qtest/test-x86-cpuid-compat: Remove the test with the i440fx-2.9 machine
The machine has been removed, so the related test can now be removed, too.

Reviewed-by: Fabiano Rosas <[email protected]>
Reviewed-by: Igor Mammedov <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
2026-03-05 08:06:19 +01:00
Philippe Mathieu-Daudé c7b2e22bd9 hw/i386/x86-iommu: Remove X86IOMMUState::pt_supported field
The X86IOMMUState::pt_supported boolean was only set in
the hw_compat_2_9[] array, via the 'pt=off' property. We
removed all machines using that array, lets remove that
property and all the code around it, always setting the
VTD_ECAP_PT capability.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
[thuth: Dropped the hunks that were already merged via commit 31753d5a33]
Reviewed-by: Igor Mammedov <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
2026-03-05 08:06:19 +01:00
Philippe Mathieu-Daudé 8960a54939 hw/pci-bridge/gen_pcie_rp: Remove GenPCIERootPort::migrate_msix field
The GenPCIERootPort::migrate_msix boolean was only set in
the hw_compat_2_9[] array, via the 'x-migrate-msix=false'
property. We removed all machines using that array, lets
remove that property and all the code around it.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Igor Mammedov <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
2026-03-05 08:06:19 +01:00
Philippe Mathieu-Daudé 9b960bbc13 hw/net/virtio-net: Remove VirtIONet::mtu_bypass_backend field
The VirtIONet::mtu_bypass_backend boolean was only set in
the hw_compat_2_9[] array, via the 'x-mtu-bypass-backend=off'
property. We removed all machines using that array, lets remove
that property and all the code around it.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Igor Mammedov <[email protected]>
[thuth: Adjusted patch for latest changes in the master branch]
Signed-off-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
2026-03-05 08:06:19 +01:00
Philippe Mathieu-Daudé 6b5be4336a hw/core/machine: Remove hw_compat_2_9[] array
The hw_compat_2_9[] array was only used by the pc-q35-2.9 and
pc-i440fx-2.9 machines, which got removed. Remove it.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Igor Mammedov <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
2026-03-05 08:06:19 +01:00
Philippe Mathieu-Daudé 4fd30af5b5 hw/i386/pc: Remove pc_compat_2_9[] array
The pc_compat_2_9[] array was only used by the pc-q35-2.9
and pc-i440fx-2.9 machines, which got removed. Remove it.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Igor Mammedov <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
2026-03-05 08:06:19 +01:00
Philippe Mathieu-Daudé 1c6cef54a2 hw/i386/pc: Remove deprecated pc-q35-2.9 and pc-i440fx-2.9 machines
These machines has been supported for a period of more than 6 years.
According to our versioned machine support policy (see commit
ce80c4fa6f "docs: document special exception for machine type
deprecation & removal") they can now be removed.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Igor Mammedov <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
2026-03-05 08:06:19 +01:00
Philippe Mathieu-Daudé 92b25a9ac2 hw/virtio/virtio-pci: Remove VIRTIO_PCI_FLAG_INIT_PM definition
VIRTIO_PCI_FLAG_INIT_PM was only used by the hw_compat_2_8[]
array, via the 'x-pcie-pm-init=off' property. We removed all
machines using that array, lets remove all the code around
VIRTIO_PCI_FLAG_INIT_PM (see commit 9a4c0e220d for similar
VIRTIO_PCI_FLAG_* enum removal).

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Igor Mammedov <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
2026-03-05 08:06:19 +01:00
Philippe Mathieu-Daudé 05d13867d9 hw/virtio/virtio-pci: Remove VIRTIO_PCI_FLAG_INIT_LNKCTL definition
VIRTIO_PCI_FLAG_INIT_LNKCTL was only used by the hw_compat_2_8[]
array, via the 'x-pcie-lnkctl-init=off' property. We removed all
machines using that array, lets remove all the code around
VIRTIO_PCI_FLAG_INIT_LNKCTL (see commit 9a4c0e220d for similar
VIRTIO_PCI_FLAG_* enum removal).

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Igor Mammedov <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
2026-03-05 08:06:19 +01:00
Philippe Mathieu-Daudé f84a406f4d hw/virtio/virtio-pci: Remove VIRTIO_PCI_FLAG_INIT_DEVERR definition
VIRTIO_PCI_FLAG_INIT_DEVERR was only used by the hw_compat_2_8[]
array, via the 'x-pcie-deverr-init=off' property. We removed all
machines using that array, lets remove all the code around
VIRTIO_PCI_FLAG_INIT_DEVERR (see commit 9a4c0e220d for similar
VIRTIO_PCI_FLAG_* enum removal).

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Igor Mammedov <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
2026-03-05 08:06:19 +01:00
Philippe Mathieu-Daudé 51859dcf2b hw/pci/pcie: Remove QEMU_PCIE_EXTCAP_INIT definition
QEMU_PCIE_EXTCAP_INIT was only used by the hw_compat_2_8[]
array, via the 'x-pcie-extcap-init=off' property. We removed
all machines using that array, let's remove all the code around
QEMU_PCIE_EXTCAP_INIT.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
[thuth: Don't remove pci_set_long(), execute it always instead]
Signed-off-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
2026-03-05 08:06:19 +01:00
Philippe Mathieu-Daudé fd5c9c3da8 hw/block/pflash: Remove PFlashCFI01::old_multiple_chip_handling field
The PFlashCFI01::old_multiple_chip_handling boolean was only set
in the hw_compat_2_8[] array, via the 'old-multiple-chip-handling=on'
property. We removed all machines using that array, let's remove that
property and all the code around it.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Igor Mammedov <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
2026-03-05 08:06:19 +01:00
Philippe Mathieu-Daudé 37e0487210 hw/core/machine: Remove hw_compat_2_8[] array
The hw_compat_2_8[] array was only used by the pc-q35-2.8 and
pc-i440fx-2.8 machines, which got removed. Remove it.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Igor Mammedov <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
2026-03-05 08:06:19 +01:00
Philippe Mathieu-Daudé 8303ca1520 hw/i386/kvm: Remove KVMClockState::mach_use_reliable_get_clock field
The KVMClockState::mach_use_reliable_get_clock boolean was only
used by the pc-q35-2.8 and pc-i440fx-2.8 machines, which got removed.
Remove it, along with the 'x-mach-use-reliable-get-clock' property.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Igor Mammedov <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
2026-03-05 08:06:19 +01:00
Philippe Mathieu-Daudé 6eebc1220c hw/i386/pc: Remove pc_compat_2_8[] array
The pc_compat_2_8[] array was only used by the pc-q35-2.8
and pc-i440fx-2.8 machines, which got removed. Remove it.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Igor Mammedov <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
2026-03-05 08:06:19 +01:00
Philippe Mathieu-Daudé a4639584b4 hw/i386/pc: Remove deprecated pc-q35-2.8 and pc-i440fx-2.8 machines
These machines has been supported for a period of more than 6 years.
According to our versioned machine support policy (see commit
ce80c4fa6f "docs: document special exception for machine type
deprecation & removal") they can now be removed.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Igor Mammedov <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
2026-03-05 08:06:19 +01:00
Kevin Wolf 0f51f9c342 mirror: Fix missed dirty bitmap writes during startup
Currently, mirror disables the block layer's dirty bitmap before its own
replacement is working. This means that during startup, there is a
window in which the allocation status of blocks in the source has
already been checked, but new writes coming in aren't tracked yet,
resulting in a corrupted copy:

1. Dirty bitmap is disabled in mirror_start_job()
2. Some request are started in mirror_top_bs while s->job == NULL
3. mirror_dirty_init() -> bdrv_co_is_allocated_above() runs and because
   the request hasn't completed yet, the block isn't allocated
4. The request completes, still sees s->job == NULL and skips the
   bitmap, and nothing else will mark it dirty either

One ingredient is that mirror_top_opaque->job is only set after the
job is fully initialized. For the rationale, see commit 32125b1460
("mirror: Fix access of uninitialised fields during start").

Fix this by giving mirror_top_bs access to dirty_bitmap and enabling it
to track writes from the beginning. Disabling the block layer's tracking
and enabling the mirror_top_bs one happens in a drained section, so
there is no danger of races with in-flight requests any more. All of
this happens well before the block allocation status is checked, so we
can be sure that no writes will be missed.

Cc: [email protected]
Closes: https://gitlab.com/qemu-project/qemu/-/issues/3273
Fixes: 32125b1460 ('mirror: Fix access of uninitialised fields during start')
Signed-off-by: Kevin Wolf <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Fiona Ebner <[email protected]>
Tested-by: Jean-Louis Dupond <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
2026-03-04 11:47:44 +01:00
Antoine Damhet 6f7b0a23a6 block/curl: fix concurrent completion handling
curl_multi_check_completion would bail upon the first completed
transfer even if more completion messages were available thus leaving
some in flight IOs stuck.

Rework a bit the loop to make the iterations clearer and drop the breaks.

The original hang can be somewhat reproduced with the following command:

$ qemu-img convert -p -m 16 -O qcow2 -c --image-opts \
  'file.driver=https,file.url=https://scaleway.testdebit.info/10G.iso,file.readahead=1M' \
  /tmp/test.qcow2

Fixes: 1f2cead324 ("curl: Ensure all informationals are checked for completion")
Cc: [email protected]
Signed-off-by: Antoine Damhet <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
2026-03-04 11:47:44 +01:00
Peter Krempa b2e9401cc9 hmp_nbd_server_start: Don't ask for backing image data
'hmp_nbd_server_start' uses only the device name from the data returned
from 'qmp_query_block', thus no backing file information. Use the new
options to suppress asking for the unused parts to save on resources.

Signed-off-by: Peter Krempa <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
Message-ID: <df71ca72a96d870758695ac57772fcfb87dc8fa0.1770210044.git.pkrempa@redhat.com>
Reviewed-by: Kevin Wolf <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
2026-03-04 11:47:44 +01:00
Peter Krempa d57bdcae9a block: Wire up 'flat' mode also for 'query-block'
Some time ago (commit facda5443f) I've added 'flat' mode (which
omits 'backing-image' key in reply) to 'query-named-block-nodes' to
minimize the size of the returned JSON for deeper backing chains.

While 'query-block' behaved slightly better it turns out that in libvirt
we do call 'query-block' to figure out some information about the
block device (e.g. throttling info) but we don't look at the backing
chain itself.

Wire up 'flat' for 'query-block' so that libvirt can ask for an
abbreviated output. The implementation is much simpler as the internals
are shared with 'query-named-block-nodes'.

Signed-off-by: Peter Krempa <[email protected]>
Acked-by: Markus Armbruster <[email protected]>
Message-ID: <f4476e9f7e8fda74c02be3f806acaa9aa2df4d9a.1770210044.git.pkrempa@redhat.com>
Reviewed-by: Kevin Wolf <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
2026-03-04 11:47:44 +01:00
Halil Oktay (oblivionsage) cfda94eddb block/vmdk: fix OOB read in vmdk_read_extent()
Bounds check for marker.size doesn't account for the 12-byte marker
header, allowing zlib to read past the allocated buffer.

Move the check inside the has_marker block and subtract the marker size.

Fixes: CVE-2026-2243
Reported-by: Halil Oktay (oblivionsage) <[email protected]>
Signed-off-by: Halil Oktay (oblivionsage) <[email protected]>
Reviewed-by: Kevin Wolf <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
2026-03-03 14:45:01 +01:00
Daniel P. Berrangé 163cd0ae11 io: separate freeing of tasks from marking them as complete
The original design of QIOTask was intended to simplify lifecycle
management by automatically freeing it when the task was marked as
complete. This overlooked the fact that when a QIOTask is used in
combination with a GSource, there may be times when the source
callback is never invoked. This is typically when a GSource is
released before any I/O event arrives. In such cases it is not
desirable to mark a QIOTask as complete, but it still needs to be
freed. To satisfy this, the task must be released manually.

Reviewed-by: Marc-André Lureau <[email protected]>
Signed-off-by: Daniel P. Berrangé <[email protected]>
2026-03-03 10:22:46 +00:00
Daniel P. Berrangé 79773cd123 scripts: detect another GPL license boilerplate variant
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Daniel P. Berrangé <[email protected]>
2026-03-03 10:22:46 +00:00
Peter Maydell 3fb456e9a0 Merge tag 'pull-request-2026-03-02' of https://gitlab.com/thuth/qemu into staging
* Remove qemu-system-microblazeel (qemu-system-microblaze can be used instead)
* Improve detection of the docker/podman binary
* Prevent a null pointer dereference during zpci hot unplug

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCgAdFiEEJ7iIR+7gJQEY8+q5LtnXdP5wLbUFAmmlgwQACgkQLtnXdP5w
# LbW4jw//VMx6pHEu5L3Rzr3FZdgMJUhJ3UQKoV5PAImHz96QjIZi3kR311/D7Xjr
# nPf9VVgVZUEKzwyCfv7V06M9S79Jbw2cJesEIcu5LqbvGxKcevXVPMdVPpDG7P7T
# zuNW7eyIMpHYHRnMnxRNY/Hl8S1P9spEWJeQpNxfe9AKoWh2i4vEC8KLMAf59DAw
# MX0CZjonMeCBSWBqRqP0zOeUqiq9n49Lz1LQnCZb1R2TF+RGmwfe6+NaBeEZ9BSg
# FWGVIIq09OFxvtUuuut5X47DOrxk69q0RmiLy+wyrpH3VMxWM41n3oensoaNm0Xj
# dg0Eq1GzQwnLalaVgdqriGnymQWtvKXmlXHsIAwedLscOO6F5L+T12WZUSUjDZ92
# SGGKyi2TSkgEZO1naLxi+J0dMWSO51wOOln9GAgFHkT/PuF/12r0sVweXXiovucr
# 4CWKP8VGU5MVpGlZ9flLwXiq8uS1GOsMQbBj/eoVOxEuFnL0crX9dME8vlpoGYAg
# THmuLKOxtcVtC9BxBZQkMFj6IKdRYEfFnNuCl2gk33Ksdb9QYCyL54XSZ9vtvhhG
# +5ajjl+w+O8HgnQKdWSQy1PYrvQ6EXtY0ZOf0q0yPfz4oq4Ib81oLhfvK0AywM17
# DALYymGpGgOgGYIkKQKcn3id7OnaIiRe7ai4GeJ9AbFVgxR4l+w=
# =Sdy4
# -----END PGP SIGNATURE-----
# gpg: Signature made Mon Mar  2 12:31:00 2026 GMT
# gpg:                using RSA key 27B88847EEE0250118F3EAB92ED9D774FE702DB5
# gpg: Good signature from "Thomas Huth <[email protected]>" [full]
# gpg:                 aka "Thomas Huth <[email protected]>" [full]
# gpg:                 aka "Thomas Huth <[email protected]>" [full]
# gpg:                 aka "Thomas Huth <[email protected]>" [undefined]
# Primary key fingerprint: 27B8 8847 EEE0 2501 18F3  EAB9 2ED9 D774 FE70 2DB5

* tag 'pull-request-2026-03-02' of https://gitlab.com/thuth/qemu:
  gitlab: ensure docker output is always displayed in CI
  tests/docker: allow display of docker output
  tests/docker: add support for podman remote access
  tests/docker: improve handling of docker probes
  Remove the qemu-system-microblazeel target from the build
  gitlab-ci: Remove the microblazeel target from the CI jobs
  tests/qtest: Remove the microblazeel target from the qtests
  tests/functional: Remove the microblazeel test
  tests/functional: Make sure test case .py files are executable
  s390x/pci: prevent null pointer dereference during zpci hot unplug

Signed-off-by: Peter Maydell <[email protected]>
2026-03-02 14:01:46 +00:00
Peter Maydell 4577ac30d8 Merge tag 'bsd-user-2026q1-upstream-pull-request' of ssh://github.com/bsdimp/qemu into staging
git-publish --base upstream/master --pull --to [email protected] --no-check-url

bsd-user: Upstream for 11.0

This combines several batch streams that:
(1) Upstream the bsd-misc.c system calls:
    quoatctl, reboot, getdtablesize, uuidgen, semget, semop, semctl, msgctl
(2) common-user drop __linux__ ifdef
(3) Remove NetBSD and OpenBSD specific code for bsd-user (hasn't built in years)
(4) Fix inotify issues on FreeBSD 15
(5) Fix issues with gdb on aarch64

All of thse have been reviewed, and the only problems with the check patch line
length and about added files.

# -----BEGIN PGP SIGNATURE-----
# Comment: GPGTools - https://gpgtools.org
#
# iQIzBAABCgAdFiEEIDX4lLAKo898zeG3bBzRKH2wEQAFAmmlD6EACgkQbBzRKH2w
# EQANZw//edwiQF/H+07EBKdZNF/QJsBwsH5OwHh/rgyq6OPUHWtu00gxNDFd/e/D
# O+FisLvDbNa9v2es1RX0lDzdgXRwi2LRIc4tMW3ifEjK7Jj8np09tfWkghwc2u9Z
# RShNxlCHfg/lTFkkm5wbHEpl1W1sImcLhYSLdoXAdUhK8lQOoUiFYOtg9s6xq6LH
# 3NHH4roY+HQE2zpK6gY45BsD1Fi3qdg5VNwTHkvcducdC5jjXnJ1UikL48zM72An
# LK8EqQfGx06RVkPgPyxTeUjniJj9SyixZjBD8YzqlmhSCt3RD4e0V+5/wd8YlPpI
# dBaYqzLSfft+vtJEqUyds/SilMHqf2brvJ9e2chwIqBlghxPb9GpPjHASDqk1/t8
# +ckFaOtdtamw0H8JFp1ixzFn7WLvUp3jpQJbSzZxmKwC0hZCxl/aXFKcq+gDg3k5
# 1wt/su+1zfb1Qjp8M8tKHLWy2/aXT/yY7IeWAk2hpOel3e4L9pDU6bsgQMz4kOE8
# WO6GHDu2YA688EArVL8ErTkKw04+mGdTMmjqrF00O/MWnW8LNKNTHIHaxWtCfXVv
# mHSUyHt94CoDtScwCdLmyZslHiO0XgUFhnK+EPd+sHyaAPu2uH6ezfFMRF8F1vs8
# WXsOnZArDg+r02PnltEjbIEOJ8t+tYTZqZ/3IKn2Gecixqhqdmc=
# =yPBa
# -----END PGP SIGNATURE-----
# gpg: Signature made Mon Mar  2 04:18:41 2026 GMT
# gpg:                using RSA key 2035F894B00AA3CF7CCDE1B76C1CD1287DB01100
# gpg: Good signature from "Warner Losh <[email protected]>" [unknown]
# gpg:                 aka "Warner Losh <[email protected]>" [unknown]
# gpg:                 aka "Warner Losh <[email protected]>" [unknown]
# gpg:                 aka "Warner Losh <[email protected]>" [unknown]
# gpg:                 aka "Warner Losh <[email protected]>" [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: 2035 F894 B00A A3CF 7CCD  E1B7 6C1C D128 7DB0 1100

* tag 'bsd-user-2026q1-upstream-pull-request' of ssh://github.com/bsdimp/qemu: (27 commits)
  bsd-user: update aarch64-bsd-user.mak gdb XML list
  bsd-user: Add miscellaneous BSD syscall implementations
  bsd-user: Add System V message queue syscalls
  bsd-user: Implement System V semaphore calls
  bsd-user: Add bsd-misc.c to build
  bsd-user: Add message queue implementations
  bsd-user: Add do_bsd_msgctl implementation
  bsd-user: Add do_bsd___semctl implementation
  bsd-user: Add do_bsd_semop implementation
  bsd-user: Add do_bsd_semget implementation
  bsd-user: Add do_bsd_uuidgen implementation
  bsd-user: Add do_bsd_quotactl, do_bsd_reboot and do_bsd_getdtablesize
  bsd-user: Add semaphore operation constants and structures
  bsd-user: Add host_to_target_msqid_ds for msgctl(2)
  bsd-user: Add target_to_host_msqid_ds for msgctl(2)
  bsd-user: Add host_to_target_semid_ds for semctl(2)
  bsd-user: Add target_to_host_semid_ds for semctl(2)
  bsd-user: Add host_to_target_semarray for semaphore operations
  bsd-user: Add target_to_host_semarray for semaphore operations
  bsd-user: Add host_to_target_uuid for uuidgen(2)
  ...

Signed-off-by: Peter Maydell <[email protected]>
2026-03-02 14:01:31 +00:00
Bibo Mao 45e3ef638e target/loongarch: Add some CPUCFG bits with host CPU model
Some CPUCFG capability bits depend on KVM host hypervsior and they
are detected on QEMU. However some CPUCFG bits are irrelative with
hypervsior, here these bits are checked from host machine and set
for VM with host CPU model.

Signed-off-by: Bibo Mao <[email protected]>
Reviewed-by: Song Gao <[email protected]>
Signed-off-by: Song Gao <[email protected]>
2026-03-02 18:02:38 +08:00
Bibo Mao e7aab4856d target/loongarch: Add host CPU model in kvm mode
Host CPU model is basically the same with max CPU model, except Product
ID and CPU model name. With host CPU model, Product ID comes from
cpucfg0 and CPU model comes from /proc/cpuinfo.

Signed-off-by: Bibo Mao <[email protected]>
Reviewed-by: Song Gao <[email protected]>
Signed-off-by: Song Gao <[email protected]>
2026-03-02 18:01:55 +08:00
Bibo Mao 371c06fdff target/loongarch: Add generic CPU model information
On LoongArch system, CPU model name comes from IOCSR register
LOONGARCH_IOCSR_VENDOR and LOONGARCH_IOCSR_CPUNAME. Its value
can be initialized when CPU is created.

Signed-off-by: Bibo Mao <[email protected]>
Reviewed-by: Song Gao <[email protected]>
Signed-off-by: Song Gao <[email protected]>
2026-03-02 18:01:10 +08:00
Bibo Mao ce386d1313 target/loongarch: Add default cpucfg3 with LA464 CPU
The features shown in cpucfg3 mostly are relative with cache capability,
QEMU does not support cache emulation and discard these features.
However it will be better if it is the same with host machine.

Here add default cpucfg3 feature information with LA464 CPU.

Signed-off-by: Bibo Mao <[email protected]>
Reviewed-by: Song Gao <[email protected]>
Signed-off-by: Song Gao <[email protected]>
2026-03-02 18:00:18 +08:00
Bibo Mao d8684f3b21 target/loongarch: Add detailed information with CPU Product ID
CPUCFG0 is LoongArch CPU Product ID, it is a combination of Vendor ID,
Series ID and Product ID, here is the layout:
 +-------------+----------------+------------+----------------+
 | Reserved    | Vendor  ID     | Series ID  |  Product ID    |
 +-------------+----------------+------------+----------------+
  31         24 23            16 15        12 11              0

Here adds detailed information with CPUCFG0, it is convenient to add
such information with host or LA664 CPU type in future.

Signed-off-by: Bibo Mao <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Song Gao <[email protected]>
2026-03-02 17:59:23 +08:00
Bibo Mao 84fd24d691 target/loongarch: Add property set with query-cpu-model-expansion
On LoongArch with QMP command query-cpu-model-expansion, property
setting is not supported witch command such as:
  query-cpu-model-expansion type=static model={"name":"max","props":{"lasx":false}}

Here add property setting support with QMP command.

Signed-off-by: Bibo Mao <[email protected]>
Reviewed-by: Song Gao <[email protected]>
Signed-off-by: Song Gao <[email protected]>
2026-03-02 17:56:50 +08:00
Bibo Mao bedadea8a4 target/loongarch: Add full type support with query-cpu-model-expansion
On LoongArch with QMP command query-cpu-model-expansion, only static
type is supported, full type is not supported. Here add full type support
with QMP cpu model query command.

Signed-off-by: Bibo Mao <[email protected]>
Reviewed-by: Song Gao <[email protected]>
Signed-off-by: Song Gao <[email protected]>
2026-03-02 17:55:51 +08:00
Bibo Mao 42dbb60bce target/loongarch: Add missing vCPU features with QMP method
Feature msgint and ptw is missing with QMP method, such as:
  query-cpu-model-expansion type=static model={"name":"max"}

Here add missing features in cpu_model_advertised_features array.

Signed-off-by: Bibo Mao <[email protected]>
Reviewed-by: Song Gao <[email protected]>
Signed-off-by: Song Gao <[email protected]>
2026-03-02 17:52:45 +08:00
Peter Maydell 333aaa55f0 Merge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging
* target/alpha: Fix for record/replay issue
* accel/nitro: New Nitro Enclaves accelerator
* generic + kvm: add support for rebuilding VMs on reset
* audio requirements cleanup
* vmmouse: Fix hypercall clobbers
* rust: use checked_div to make clippy happy
* kvm: Don't clear pending #SMI in kvm_get_vcpu_events
* target/i386/emulate: rework MMU code, many fixes
* target/i386/whpx: replace winhvemulation with target/i386/emulate
* target/i386/whpx: x2apic support
* target/i386/whpx: vapic support
* kvm: support for the "ignore guest PAT" quirk
* target/i386: add ITS_NO bit for the arch-capabilities MSR
* target/i386: add MBEC bit for nested VMX

# -----BEGIN PGP SIGNATURE-----
#
# iQFIBAABCgAyFiEE8TM4V0tmI4mGbHaCv/vSX3jHroMFAmmkVTUUHHBib256aW5p
# QHJlZGhhdC5jb20ACgkQv/vSX3jHroOa8Qf+J16s57unw/DiM4Mw7wvnLGA86OSu
# bJwlHBgmgz3uT8LwPpg2F3+yTDzTGErm5Ex7JHYJqdLdhVuU0cC3d3/TndUovWZf
# lMwQi2QJNKECtOIIz3rqbqvuSoy577Q7qN7CIN4vR8JKFvToPnwABVfkl+VKedCT
# Tu/f3SiazXnNH8FejtXsyjDHMwJfMwhYg5HyAHeqxtrqMCnQ/pc46ZQoM4CJr8P+
# jDZu85RDlLVXkA0RtwkJ6QfvxSU3wUjEeDBz9ThGLk00PFCr1LAXj/oz+0Ayz3qu
# LkVpLLBxt0hfMCZPlYF0+17m1CJv7/micHVZEgblawpq/xXXk1iE8avGQQ==
# =mEuN
# -----END PGP SIGNATURE-----
# gpg: Signature made Sun Mar  1 15:03:17 2026 GMT
# gpg:                using RSA key F13338574B662389866C7682BFFBD25F78C7AE83
# gpg:                issuer "[email protected]"
# gpg: Good signature from "Paolo Bonzini <[email protected]>" [full]
# gpg:                 aka "Paolo Bonzini <[email protected]>" [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: (102 commits)
  target/i386: emulate: fix scas
  whpx: i386: expose HV_X64_MSR_APIC_FREQUENCY when kernel-irqchip=off
  whpx: i386: enable PMU
  target/i386: emulate: more 64-bit register handling
  whpx: i386: warn on unsupported MSR access instead of failing silently
  whpx: i386: enable synthetic processor features
  whpx: i386: enable all supported host features
  whpx: i386: move whpx_vcpu_kick_out_of_hlt() invocation to interrupt raise time
  target/i386: introduce ClearwaterForest-v3 to expose ITS_NO
  target/i386: introduce SierraForest-v5 to expose ITS_NO
  target/i386: introduce GraniteRapids-v5 to expose ITS_NO
  target/i386: introduce SapphireRapids-v6 to expose ITS_NO
  target/i386: Add MSR_IA32_ARCH_CAPABILITIES ITS_NO
  target/i386: Add VMX_SECONDARY_EXEC_MODE_BASED_EPT_EXEC
  Reapply "rcu: Unify force quiescent state"
  target/alpha: Reset CPU
  hw: i386: vapic: enable on WHPX with user-mode irqchip
  whpx: x86: kick out of HLT manually when using the kernel-irqchip
  whpx: x86: remove inaccurate comment
  KVM: i386: Default disable ignore guest PAT quirk
  ...

Signed-off-by: Peter Maydell <[email protected]>
2026-03-02 09:13:34 +00:00
Peter Maydell 0aac79bd79 Merge tag 'pull-ppc-for-11.0-20260302' of https://gitlab.com/harshpb/qemu into staging
ppc queue for 11.0

- Fix TCG debug assert translating CLRBWIBC
- Misc Power10 PowerVM bringup fixes
- MAINTAINERS: Add Glenn as PPC TCG Reviewer.

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCAAdFiEEa4EM1tK+EPOIPSFCRUTplPnWj7sFAmmlLJAACgkQRUTplPnW
# j7t5yg//S6Ch3ipR0gt13Q4/Hpseila6NADPaU+ASDcRNaWgJCjc+a6jW8xN6m5D
# myfms5vcbNdRLvDNdLYqNhtEjVqJgsbvb7jaFDK+Ny1vJDPRHZK4QIlsx5fWSteL
# fefWgfAu0ce70MQNY6zIsy/a6ORz6g+fTEv6XWsfZEdvlxow4BsClfnDcQw6vu5B
# YLi9FY50Kk7BxQ2gfFbAAPqCU9XSmjSObCANil9qiGl81lLG7VqIflSBEdQ6NWa1
# hJpUUoSEq+BzLtrVLTswb0/EnG2HATHyExRG5jy+oycuB8hKtZIV7g6zAdMBibrk
# EBAAU7MoH/dzcf5XDtrWEFzRm3yXHorMEIxejt51ss/7s6XaiDOciViOR2OEPOxY
# pzJ+8K8wRCxrM9tE2ZHZhmscz7Dns9nU0T5TrJ0NExUe8sB9A19nOQCSJsdNaWSl
# 4AXsevm0lqkoUCBgd+6ZHPgSSoheNW4DXuGr7dvaQiDY9xUw8lvAeG1WIVa2W0il
# GAGECZ4Da5e1bLlpSw8ALvINLL+/OjzpL8d//QQOTE7xoF/5SgGUAI/w7OJJXYtX
# vdvzAE9Dk2EMo0juRU9yLKiy7fjz+Ecp6wV74t9r18ZjzkD286+6nAOaXjvFH35i
# c3UMUPdVYRNRjVdFxKw8B/CJ22aWauz8z9X+fFwnqKYH7YLLUZ8=
# =AkZY
# -----END PGP SIGNATURE-----
# gpg: Signature made Mon Mar  2 06:22:08 2026 GMT
# gpg:                using RSA key 6B810CD6D2BE10F3883D21424544E994F9D68FBB
# gpg: Good signature from "Harsh Prateek Bora <[email protected]>" [full]
# gpg:                 aka "Harsh Prateek Bora <[email protected]>" [full]
# Primary key fingerprint: 6B81 0CD6 D2BE 10F3 883D  2142 4544 E994 F9D6 8FBB

* tag 'pull-ppc-for-11.0-20260302' of https://gitlab.com/harshpb/qemu:
  MAINTAINERS: Add self as reviewer for PowerPC TCG
  ppc/pnv: Add OCC FLAG registers
  ppc/pnv: Support for SECURITY_SWITCH XSCOM register access
  target/ppc/translate: Fix TCG debug assert translating CLRBWIBC

Signed-off-by: Peter Maydell <[email protected]>
2026-03-02 09:13:21 +00:00
Daniel P. Berrangé 424b4b82d5 gitlab: ensure docker output is always displayed in CI
Set the new $(DOCKER_V) variable from the previous commit, so that any
CI jobs invoking docker will show the full stdout content. This improves
the ability to diagnose any build failures in CI that involve docker.

For example, when a 'docker build' command fails, it lets us see which
command in the Dockerfile failed and why.

Reviewed-by: Thomas Huth <[email protected]>
Signed-off-by: Daniel P. Berrangé <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
2026-03-02 09:48:10 +01:00
Daniel P. Berrangé 2d3d5ae1ad tests/docker: allow display of docker output
The --quiet command is used with docker unless V=1 is passed to make,
and as a result stdout from docker is never visible by default, making
it hard to diagnose failures building / running containers.

Meanwhile passing V=1 is undesirable as that makes the entire build
system verbose.

Introduce a $(DOCKER_V) make variable which is initialized from $(V)

It is thus possible to display docker output without also enabling
make verbose output.

Signed-off-by: Daniel P. Berrangé <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
2026-03-02 09:48:10 +01:00
Daniel P. Berrangé c5ecd377a0 tests/docker: add support for podman remote access
When a developer's environment is already within a podman container it
is not possible to use 'podman' again to create containers. It will
usually result in wierd errors such as:

  Error: fatal error, invalid internal status, unable to create a new pause process: cannot re-exec process to join the existing user namespace. Try running "podman system migrate" and if that doesn't work reboot to recover

Podman offers the ability to talk to a daemon outside the container,
however, which could be leveraged by QEMU.

This can be used by invoking "podman --remote", or equivalently the
separate "podman-remote" binary:

  https://github.com/containers/podman/blob/main/docs/tutorials/remote_client.md

The current 'podman version' check is insufficient to detect the
inability to launch containers, so it is replaced with the stronger
'podman info' check.

Signed-off-by: Daniel P. Berrangé <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
2026-03-02 09:48:10 +01:00
Daniel P. Berrangé fbf4fa1091 tests/docker: improve handling of docker probes
The docker.py script has logic to guess the container command and
detects one of

  * docker
  * sudo -n docker
  * podman

but the "docker.py probe" command then throws away the detected argv
and prints a slightly different argv based solely on the detected
argv[0]. The result is that 'probe' will print

  * docker
  * sudo docker
  * podman

which means that if sudo was detected & the result of 'probe' were
used directly, it would end up prompting for password interaction
every time.

The 'configure' script, however, runs 'probe' and then throws away
the printed argv again, reporting only 'podman' or 'docker', which
is used to set the $(RUNC) variable for tests/docker/Makefile.include
which is in turn used to pass --engine to docker.py. So the docker.py
command will re-detect the need for 'sudo -n' and use it correctly

The problem with this is that some commands in Makefile.include do
not call docker.py at all, they invoke $(RUNC) directly. Since
configure threw away the 'sudo' command prefix Makefile.in won't
be adding either 'sudo' or 'sudo -n', it'll just run plain 'docker'
which is wrong.

This commit sanitizes things so that the 'docker.py probe' prints
out the exact detected ARGV, and configure fully preserves this
ARGV when setting $(RUNC). Since "$(RUNC)" is no longer just a bare
engine name, however, we must now also set the $(CONTAINER_ENGINE)
variable for Makefile.include so it can pass something sane to
the --engine arg for docker.py

Reviewed-by: Thomas Huth <[email protected]>
Signed-off-by: Daniel P. Berrangé <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
2026-03-02 09:48:10 +01:00
Thomas Huth 46a25ae3f0 Remove the qemu-system-microblazeel target from the build
It's been deprecated since two releases, so it should be fine to
remove this now. Users can use the qemu-system-microblaze binary
instead that can handle both endiannesses now.

Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
2026-03-02 09:48:10 +01:00
Thomas Huth 34faec9fe8 gitlab-ci: Remove the microblazeel target from the CI jobs
Since we're going to remove the qemu-system-microblazeel binary,
remove the related tests from the CI jobs now (or switch to "microblaze"
where it is appropriate).

Note: Since "build-system-ubuntu" does not have as many targets as
"build-system-fedora", we turn the "microblazeel-softmmu" into a
"microblaze-softmmu" in the ubuntu job, and remove the corresponding
target from the fedora job instead, so that the load is more balanced
now.

Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
2026-03-02 08:28:25 +01:00
Thomas Huth b63b340430 tests/qtest: Remove the microblazeel target from the qtests
The "petalogix-ml605" boot-serial-test can be run with the
"microblaze" target. The remaining tests can simply be dropped
now that we are going to remove the "microblazeel" target.

Reviewed-by: Fabiano Rosas <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
2026-03-02 08:28:24 +01:00
Thomas Huth 0e2c5647d9 tests/functional: Remove the microblazeel test
We are going to remove the microblazeel target, so the test is not
required anymore. The little endian mode is tested already via the
"microblaze" target, so we don't lose any test coverage here.

While we're at it, simplify the "microblaze" target test now (in the
file tests/functional/microblaze/test_s3adsp1800.py) since we don't
need the separate super-class here anymore.

Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
2026-03-02 08:28:24 +01:00
Peter Maydell d23e916926 tests/functional: Make sure test case .py files are executable
The top-level test python scripts in tests/functional are supposed to
be marked executable; "make check-functional" doesn't care about
this, but it allows them to be run as standalone executables to
exercise a single test, as docs/devel/testing/functional.rst
describes.

A couple of files have got into the tree without the executable
bit set: fix them.

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
2026-03-02 08:27:08 +01:00
Aby Sam Ross 78c25188e0 s390x/pci: prevent null pointer dereference during zpci hot unplug
vfio-pci hostdev realize during zpci hot plug fails (in `vfio_pci_realize()`)
if the vfio group file in `/dev/vfio/` lacks appropriate permissions and the
hostdev[/properties] addition doesn't reach the point where it could be
associated with previously added zpci device (in `s390_pcihost_plug()`).
As a result, zpci iommu pointer remains null. The zpci hot unplug following the
failed hostdev addition assumes zpci iommu pointer was assigned and tries to
make use of it to end the dma count resulting in a null pointer dereference.
In the non-hotplug scenario, `qdev_unplug()` for the zpci device is not called
after hostdev addition failure and this issue is not encountered.

All other uses of zpci iommu without null check happens after both the zpci and
hostdev(pci) devices are plugged and are safe from null dereference.

Fixes: 37fa32de70 ("s390x/pci: Honor DMA limits set by vfio")

Signed-off-by: Aby Sam Ross <[email protected]>
Acked-by: Eric Farman <[email protected]>
Reviewed-by: Matthew Rosato <[email protected]>
Reviewed-by: Farhan Ali <[email protected]>
Suggested-by: Halil Pasic <[email protected]>
Message-ID: <b45cefc3147c2c8446772dab0f53d030fb92406a.1770963150.git.abysamross@ibm.com>
Signed-off-by: Thomas Huth <[email protected]>
2026-03-02 08:24:09 +01:00
Glenn Miles 8dec25e04e MAINTAINERS: Add self as reviewer for PowerPC TCG
Added myself as a reviewer for PowerPC TCG

Signed-off-by: Glenn Miles <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Harsh Prateek Bora <[email protected]>
2026-03-02 11:17:34 +05:30
Caleb Schlossin 0b74dd1d80 ppc/pnv: Add OCC FLAG registers
OCCFLG are scratch registers that can be shared with OCC firmware.
Log reads and writes to the registers as a reminder when we run
into more OCC code.

Add RW, WO_CLEAR and WO_OR SCOM Type enums in pnv_occ.c

Reviewed-by: Chalapathi V <[email protected]>
Reviewed-by: Glenn Miles <[email protected]>
Reviewed-by: Aditya Gupta <[email protected]>
Signed-off-by: Chalapathi V <[email protected]>
Signed-off-by: Caleb Schlossin <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Harsh Prateek Bora <[email protected]>
2026-03-02 11:15:16 +05:30
Caleb Schlossin 2211bb484c ppc/pnv: Support for SECURITY_SWITCH XSCOM register access
Power Hypervisor code requires access to the SECURITY_SWITCH
XSCOM register at MMIO address 0x80028 (scom address 0x10005).
Adding basic read support for now so that is doesn't cause
error messages to be posted.

Reviewed-by: Chalapathi V <[email protected]>
Reviewed-by: Glenn Miles <[email protected]>
Reviewed-by: Aditya Gupta <[email protected]>
Signed-off-by: Glenn Miles <[email protected]>
Signed-off-by: Caleb Schlossin <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Harsh Prateek Bora <[email protected]>
2026-03-02 11:15:16 +05:30
Peter Maydell 78c6b6010c target/ppc/translate: Fix TCG debug assert translating CLRBWIBC
The test case in the ppe42 functional test triggers a TCG debug
assertion, which causes the test to fail in an --enable-debug
build or when the sanitizers are enabled:

#6  0x00007ffff4a3b517 in __assert_fail
    (assertion=0x5555562e7589 "!temp_readonly(ots)", file=0x5555562e5b23 "../../tcg/tcg.c", line=4928, function=0x5555562e8900 <__PRETTY_FUNCTION__.23> "tcg_reg_alloc_mov") at ./assert/assert.c:105
#7  0x0000555555cc2189 in tcg_reg_alloc_mov (s=0x7fff60000b70, op=0x7fff600126f8) at ../../tcg/tcg.c:4928
#8  0x0000555555cc74e0 in tcg_gen_code (s=0x7fff60000b70, tb=0x7fffa802f540, pc_start=4294446080) at ../../tcg/tcg.c:6667
#9  0x0000555555d02abe in setjmp_gen_code
    (env=0x555556cbe610, tb=0x7fffa802f540, pc=4294446080, host_pc=0x7fffeea00c00, max_insns=0x7fffee9f9d74, ti=0x7fffee9f9d90)
    at ../../accel/tcg/translate-all.c:257
#10 0x0000555555d02d75 in tb_gen_code (cpu=0x555556cba590, s=...) at ../../accel/tcg/translate-all.c:325
#11 0x0000555555cf5922 in cpu_exec_loop (cpu=0x555556cba590, sc=0x7fffee9f9ee0) at ../../accel/tcg/cpu-exec.c:970
#12 0x0000555555cf5aae in cpu_exec_setjmp (cpu=0x555556cba590, sc=0x7fffee9f9ee0) at ../../accel/tcg/cpu-exec.c:1016
#13 0x0000555555cf5b4b in cpu_exec (cpu=0x555556cba590) at ../../accel/tcg/cpu-exec.c:1042
#14 0x0000555555d1e7ab in tcg_cpu_exec (cpu=0x555556cba590) at ../../accel/tcg/tcg-accel-ops.c:82
#15 0x0000555555d1ff97 in rr_cpu_thread_fn (arg=0x555556cba590) at ../../accel/tcg/tcg-accel-ops-rr.c:285
#16 0x00005555561586c9 in qemu_thread_start (args=0x555556ee3c90) at ../../util/qemu-thread-posix.c:393
#17 0x00007ffff4a9caa4 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:447
#18 0x00007ffff4b29c6c in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78

This can be reproduced "by hand":

 ./build/clang/qemu-system-ppc -display none -vga none \
    -machine ppe42_machine -serial stdio \
    -device loader,file=$HOME/.cache/qemu/download/03c1ac0fb7f6c025102a02776a93b35101dae7c14b75e4eab36a337e39042ea8 \
    -device loader,addr=0xfff80040,cpu-num=0

(assuming you have the image file from the functional test
in your local cache).

This happens for this input:

IN:
0xfff80c00:  07436004  .byte    0x07, 0x43, 0x60, 0x04

which generates (among other things):

 not_i32 $0x80000,$0x80000

which the TCG optimization pass turns into:

 mov_i32 $0x80000,$0xfff7ffff             dead: 1  pref=0xffff

and where we then assert because we tried to write to a constant.

This happens for the CLRBWIBC instruction which ends up in
do_mask_branch() with rb_is_gpr false and invert true.  In this case
we will generate code that sets mask to a tcg_constant_tl() but then
uses it as the LHS in tcg_gen_not_tl().

Fix the assertion by doing the invert in the translate time C code
for the "mask is constant" case.

Cc: [email protected]
Fixes: f7ec91c239 ("target/ppc: Add IBM PPE42 special instructions")
Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Glenn Miles <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Harsh Prateek Bora <[email protected]>
2026-03-02 11:12:12 +05:30
Siva Mahadevan f0f6eae80f bsd-user: update aarch64-bsd-user.mak gdb XML list
Fixes unreachable code assert in qemu:smoke / bsd-user-smoke test.

Upstream commit: https://gitlab.com/qemu-project/qemu/-/commit/591e848aca7af3b4d25af03ed5bd266c479054bf

Pull-Request: https://github.com/qemu-bsd-user/qemu-bsd-user/pull/61
Signed-off-by: Siva Mahadevan <[email protected]>
Reviewed-by: Warner Losh <[email protected]>
Signed-off-by: Warner Losh <[email protected]>
2026-03-01 20:50:11 -07:00
Stacey Son b6f070a771 bsd-user: Add miscellaneous BSD syscall implementations
Wire up the remaining miscellaneous BSD syscalls:
- quotactl(2): Quota control (stub returning ENOSYS)
- reboot(2): Reboot system (stub returning ENOSYS)
- uuidgen(2): Generate UUIDs
- getdtablesize(2): Get descriptor table size

Signed-off-by: Stacey Son <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Warner Losh <[email protected]>
2026-03-01 20:49:40 -07:00
Stacey Son e3d86fb18f bsd-user: Add System V message queue syscalls
Connect the System V IPC message queue syscalls:
- msgctl(2): Message queue control
- msgget(2): Get message queue identifier
- msgsnd(2): Send message to queue
- msgrcv(2): Receive message from queue

Signed-off-by: Stacey Son <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Warner Losh <[email protected]>
2026-03-01 20:49:40 -07:00
Stacey Son 4019112cf1 bsd-user: Implement System V semaphore calls
Wire up semget(2) and semop(2) syscalls to get System V semaphore
implementation, as well the undocumented __semctl used to implement the
bits of the interface in libc.

Signed-off-by: Stacey Son <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Warner Losh <[email protected]>
2026-03-01 20:49:40 -07:00
Warner Losh edfff4f7a3 bsd-user: Add bsd-misc.c to build
Build bsd-misc.c for routines to support System V IPC, UUID, quotactl,
reboot and getdtablesize.

Signed-off-by: Stacey Son <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Warner Losh <[email protected]>
2026-03-01 20:49:40 -07:00
Stacey Son bc903963bf bsd-user: Add message queue implementations
Add implementations for:
- msgsnd(2): Send message to queue with size validation
- msgget(2): Get message queue identifier
- msgrcv(2): Receive message from queue with size validation

Signed-off-by: Stacey Son <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Warner Losh <[email protected]>
2026-03-01 20:49:40 -07:00
Stacey Son 1bbdc46d58 bsd-user: Add do_bsd_msgctl implementation
Add implementation of msgctl(2) syscall for System V message queue control
operations. Handles command translation and structure conversions for
IPC_STAT/IPC_SET/IPC_RMID operations.

Signed-off-by: Stacey Son <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Warner Losh <[email protected]>
2026-03-01 20:49:40 -07:00
Stacey Son 6cefbee70b bsd-user: Add do_bsd___semctl implementation
Add implementation of __semctl(2) syscall for System V semaphore control
operations. Handles command translation, endianness conversion for GETVAL/
SETVAL, and array/structure conversions for GETALL/SETALL/IPC_STAT/IPC_SET.

Signed-off-by: Stacey Son <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Warner Losh <[email protected]>
2026-03-01 20:49:40 -07:00
Stacey Son 441ddfb820 bsd-user: Add do_bsd_semop implementation
Add implementation of semop(2) syscall to perform System V semaphore
operations. Converts target sembuf array to host format and executes
operations.

Signed-off-by: Stacey Son <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Warner Losh <[email protected]>
2026-03-01 20:49:40 -07:00
Stacey Son 39fb6a5d09 bsd-user: Add do_bsd_semget implementation
Add implementation of semget(2) syscall to get System V semaphore set
identifier. Converts target IPC flags to host format.

Signed-off-by: Stacey Son <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Warner Losh <[email protected]>
2026-03-01 20:49:40 -07:00
Stacey Son 021fadcc8d bsd-user: Add do_bsd_uuidgen implementation
Add implementation of uuidgen(2) syscall that generates UUIDs and
converts them to target ABI format.

Signed-off-by: Stacey Son <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Warner Losh <[email protected]>
2026-03-01 20:49:40 -07:00
Stacey Son 75f6b9bcad bsd-user: Add do_bsd_quotactl, do_bsd_reboot and do_bsd_getdtablesize
Add some trivial misc system calls: stub implementations for quotactl(2)
and reboot(2) syscall; a trivial do_bsd_getdtablesize that calls
getdtablesize(2).

Signed-off-by: Stacey Son <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Warner Losh <[email protected]>
2026-03-01 20:49:40 -07:00
Warner Losh e9232a04ee bsd-user: Add semaphore operation constants and structures
Add System V semaphore operation constants (GETVAL, SETVAL, GETALL, etc.)
and the target_sembuf and target_semun structures needed for semop(2) and
semctl(2) syscall emulation.

Signed-off-by: Stacey Son <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Warner Losh <[email protected]>
2026-03-01 20:49:40 -07:00
Stacey Son e2ad4ba061 bsd-user: Add host_to_target_msqid_ds for msgctl(2)
Add host_to_target_msqid_ds() to convert host struct msqid_ds to target
format for msgctl(2) IPC_STAT operations.

Signed-off-by: Stacey Son <[email protected]>
Signed-off-by: Brooks Davis <[email protected]>
Signed-off-by: Sean Bruno <[email protected]>
Signed-off-by: Mikael Urankar <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Warner Losh <[email protected]>
2026-03-01 20:49:40 -07:00
Stacey Son ee032d237f bsd-user: Add target_to_host_msqid_ds for msgctl(2)
Add target_to_host_msqid_ds() to convert target struct msqid_ds to host
format for msgctl(2) IPC_SET operations. Uses memset to zero the struct
rather than directly accessing kernel-only members. Handles FreeBSD
64-bit time_t except on i386.

Signed-off-by: Stacey Son <[email protected]>
Signed-off-by: Brooks Davis <[email protected]>
Signed-off-by: Sean Bruno <[email protected]>
Signed-off-by: Mikael Urankar <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Warner Losh <[email protected]>
2026-03-01 20:49:40 -07:00
Stacey Son db17761920 bsd-user: Add host_to_target_semid_ds for semctl(2)
Add host_to_target_semid_ds() to convert host struct semid_ds to target
format for semctl(2) IPC_STAT operations.

Signed-off-by: Stacey Son <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Warner Losh <[email protected]>
2026-03-01 20:49:40 -07:00
Stacey Son b2ce1b6a8e bsd-user: Add target_to_host_semid_ds for semctl(2)
Add target_to_host_semid_ds() to convert target struct semid_ds to host
format for semctl(2) IPC_SET operations.

Signed-off-by: Stacey Son <[email protected]>
Signed-off-by: Mikael Urankar <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Warner Losh <[email protected]>
2026-03-01 20:49:40 -07:00
Stacey Son 685c763348 bsd-user: Add host_to_target_semarray for semaphore operations
Add host_to_target_semarray() to convert host semaphore array to target
format for semctl(2) GETALL operations.

Signed-off-by: Stacey Son <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Warner Losh <[email protected]>
2026-03-01 20:49:40 -07:00
Stacey Son ff1189f659 bsd-user: Add target_to_host_semarray for semaphore operations
Add target_to_host_semarray() to convert target semaphore array to host
format for semctl(2) SETALL operations.

Signed-off-by: Stacey Son <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Warner Losh <[email protected]>
2026-03-01 20:49:40 -07:00
Stacey Son 7cbe2f914c bsd-user: Add host_to_target_uuid for uuidgen(2)
Add host_to_target_uuid() to convert host struct uuid to target ABI
for the uuidgen(2) syscall.

Signed-off-by: Stacey Son <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Warner Losh <[email protected]>
2026-03-01 20:49:40 -07:00
Warner Losh 447121c344 bsd-user: Add function declarations for bsd-misc.c conversions
Add function declarations for BSD System V IPC and UUID conversion
routines that will be implemented in bsd-misc.c.

Signed-off-by: Stacey Son <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Warner Losh <[email protected]>
2026-03-01 20:49:40 -07:00
Warner Losh 4a75025b8a bsd-user: Add target_uuid structure for uuidgen syscall
Add the target ABI definition for struct uuid, needed for uuidgen(2)
syscall emulation.

Signed-off-by: Stacey Son <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Warner Losh <[email protected]>
2026-03-01 20:49:40 -07:00
Warner Losh e17d8c0044 bsd-user: Add target_semid_ds and target_msqid_ds structures
Add the target ABI definitions for System V semaphore and message queue
data structures, needed for semctl() and msgctl() syscall emulation.

Signed-off-by: Stacey Son <[email protected]>
Signed-off-by: Mikael Urankar <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Warner Losh <[email protected]>
2026-03-01 20:49:39 -07:00
Warner Losh e981b3133d common-user: Drop __linux__ around .note.GNU-stack
GNU-stack tagging is a toolchain issue, not an OS issue. All the
toolchains require this for ELF.

Signed-off-by: Warner Losh <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
2026-03-01 20:49:39 -07:00
Warner Losh 2c4cc8b61d bsd-user: Remove NetBSD-specific code
Remove the NetBSD specific code form bsd-user. It's not been maintained
in any meaningful way since it was introduced to the tree in 2008. It
hasn't been connected to the build since 2021, and last time (in 2023) I
tried to mock-up the meson support it needed, it failed to build. While
there were some out-of-tree work, I've not been able to connect with
that code.

Cc: Reinoud Zandijk <[email protected]>
Cc: Ryo ONODERA <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Warner Losh <[email protected]>
2026-03-01 20:49:39 -07:00
Warner Losh 90678cd379 bsd-user: Remove OpenBSD-specific code
Remove the OpenBSD specific code form bsd-user. It's not been maintained
in any meaningful way since it was introduced to the tree in 2008. It
hasn't been connected to the build since 2021, and last time (in 2023) I
tried to mock-up the meson support it needed, it failed to build. I
contacted the OpenBSD people in 2018, it appears, and even at that time
they tought this code was not at all useful to them.

Cc: Brad Smith <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Warner Losh <[email protected]>
2026-03-01 20:49:39 -07:00
Warner Losh bba2f724f1 freebsd: FreeBSD 15 has native inotify
Check to make sure that we have inotify in libc, before looking for it
in libinotify.

Cc: Paolo Bonzini <[email protected]>
Cc: Marc-André Lureau <[email protected]>
Cc: Daniel P. Berrange <[email protected]>
Cc: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Daniel P. Berrangé <[email protected]>
Signed-off-by: Warner Losh <[email protected]>
2026-03-01 20:49:39 -07:00
Mohamed Mediouni 5a0f9481b0 target/i386: emulate: fix scas
Signed-off-by: Mohamed Mediouni <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-03-01 16:02:54 +01:00
Mohamed Mediouni f2875e19d2 whpx: i386: expose HV_X64_MSR_APIC_FREQUENCY when kernel-irqchip=off
Now that we expose AccessFrequencyRegs, expose HV_X64_MSR_APIC_FREQUENCY as well for the case when the Hyper-V LAPIC is not used.

If the Hyper-V LAPIC is used, this will be handled by the hypervisor instead of the VMM, hence gating it on !whpx_irqchip_in_kernel().

Signed-off-by: Mohamed Mediouni <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-03-01 16:02:54 +01:00
Mohamed Mediouni eb3eaf882e whpx: i386: enable PMU
Also a partition property instead of a CPU one...

Signed-off-by: Mohamed Mediouni <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-03-01 16:02:54 +01:00
Mohamed Mediouni 7f7e797737 target/i386: emulate: more 64-bit register handling
Signed-off-by: Mohamed Mediouni <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-03-01 16:02:54 +01:00
Mohamed Mediouni 3f7e6348b0 whpx: i386: warn on unsupported MSR access instead of failing silently
Signed-off-by: Mohamed Mediouni <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-03-01 16:02:54 +01:00
Mohamed Mediouni 8022c62878 whpx: i386: enable synthetic processor features
At the point in time in which we setup the partition, the vCPUs
aren't available yet.

So enable them by default for now like what the MSHV backend does.

AccessFrequencyRegs is shared for both the LAPIC frequency reporting and the TSC frequency.

To still benefit from the fixed TSC frequency reporting when kernel-irqchip=off, still enable AccessFrequencyRegs anyway.

Signed-off-by: Mohamed Mediouni <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-03-01 16:02:54 +01:00
Mohamed Mediouni 8b87283ce4 whpx: i386: enable all supported host features
Signed-off-by: Mohamed Mediouni <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-03-01 16:02:54 +01:00
Mohamed Mediouni 3588d68bc8 whpx: i386: move whpx_vcpu_kick_out_of_hlt() invocation to interrupt raise time
This fixes the sti followed by hlt kvm_unit_tests.

Signed-off-by: Mohamed Mediouni <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-03-01 16:02:54 +01:00
Jon Kohler 364d7890c6 target/i386: introduce ClearwaterForest-v3 to expose ITS_NO
Expose ITS_NO by default, as users using Clearwater Forest and higher
CPU models would not be able to live migrate to lower CPU hosts due to
missing features. In that case, they would not be vulnerable to ITS.

its-no was originally added on [1], but needs to be exposed on the
individual CPU models for the guests to see by default.

Note: Version 1 already exposes ARCH_CAP_BHI_NO, which would already
mark the CPU as invulnerable to ITS (at least in Linux); however,
expose ITS_NO for completeness.

[1] 74978391b2 ("target/i386: Make ITS_NO available to guests")

Cc: Pawan Gupta <[email protected]>
Signed-off-by: Jon Kohler <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-03-01 16:02:54 +01:00
Jon Kohler c63bbb7a40 target/i386: introduce SierraForest-v5 to expose ITS_NO
Expose ITS_NO by default, as users using Sierra Forest and higher
CPU models would not be able to live migrate to lower CPU hosts due to
missing features. In that case, they would not be vulnerable to ITS.

its-no was originally added on [1], but needs to be exposed on the
individual CPU models for the guests to see by default.

Note: For SRF, version 2 already exposed BHI_CTRL, which would already
mark the CPU as invulnerable to ITS (at least in Linux); however,
expose ITS_NO for completeness.

[1] 74978391b2 ("target/i386: Make ITS_NO available to guests")

Cc: Pawan Gupta <[email protected]>
Signed-off-by: Jon Kohler <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-03-01 16:02:54 +01:00
Jon Kohler b40be41f37 target/i386: introduce GraniteRapids-v5 to expose ITS_NO
Expose ITS_NO by default, as users using Granite Rapids and higher
CPU models would not be able to live migrate to lower CPU hosts due to
missing features. In that case, they would not be vulnerable to ITS.

its-no was originally added on [1], but needs to be exposed on the
individual CPU models for the guests to see by default.

[1] 74978391b2 ("target/i386: Make ITS_NO available to guests")

Cc: Pawan Gupta <[email protected]>
Signed-off-by: Jon Kohler <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-03-01 16:02:45 +01:00
Jon Kohler 856cb7bd35 target/i386: introduce SapphireRapids-v6 to expose ITS_NO
Expose ITS_NO by default, as users using Sapphire Rapids and higher
CPU models would not be able to live migrate to lower CPU hosts due to
missing features. In that case, they would not be vulnerable to ITS.

its-no was originally added on [1], but needs to be exposed on the
individual CPU models for the guests to see by default.

[1] 74978391b2 ("target/i386: Make ITS_NO available to guests")

Cc: Pawan Gupta <[email protected]>
Signed-off-by: Jon Kohler <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-03-01 16:02:39 +01:00
Jon Kohler cf5dc5d019 target/i386: Add MSR_IA32_ARCH_CAPABILITIES ITS_NO
Add bit definition for Indirect Target Selection (ITS_NO) bit 62, to
allow ITS_NO to be added directly to a CPU model in the future.

Cc: Pawan Gupta <[email protected]>
Signed-off-by: Jon Kohler <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-03-01 15:17:29 +01:00
Jon KohlerandAditya Desai bfff4b2ae5 target/i386: Add VMX_SECONDARY_EXEC_MODE_BASED_EPT_EXEC
Enumerate ability to enable Intel Mode-Based Execute Control (MBEC)
on secondary execution control bit 22.

Intel MBEC is a hardware feature, introduced in the Kabylake
generation, that allows for more granular control over execution
permissions. MBEC enables the separation and tracking of execution
permissions for supervisor (kernel) and user-mode code. It is used as
an accelerator for Microsoft's Memory Integrity [1] (also known as
hypervisor-protected code integrity or HVCI).

[1] https://learn.microsoft.com/en-us/windows/security/hardware-security/enable-virtualization-based-protection-of-code-integrity

Code is mirrored here:
https://github.com/JonKohler/linux/tree/mbec-v1-6.18
https://github.com/JonKohler/kvm-unit-tests/tree/mbec-v1

LKML thread(s) are here:
Original RFC: https://lore.kernel.org/all/[email protected]/
V1 code: https://lore.kernel.org/all/[email protected]/
KVM unit test changes: https://lore.kernel.org/all/[email protected]/

Cc: Xiaoyao Li <[email protected]>
Cc: Zhao Liu <[email protected]>
Co-authored-by: Jon Kohler <[email protected]>
Co-authored-by: Aditya Desai <[email protected]>
Signed-off-by: Jon Kohler <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-03-01 15:16:42 +01:00
Peter Maydell ffcf1a7981 Merge tag 'pull-11.0-testing-updates-270226-2' of https://gitlab.com/stsquad/qemu into staging
testing updates (vm, docker, arm functional)

  - migrate non-lcitool Debian containers to Trixie (13)
  - remove legacy-test-cross hacks
  - fix some minor make vm- Makefile issues
  - bump OpenBSD to 7.8
  - add VBSA EFI functional test for Arm

# -----BEGIN PGP SIGNATURE-----
#
# iQEzBAABCgAdFiEEZoWumedRZ7yvyN81+9DbCVqeKkQFAmmhlHYACgkQ+9DbCVqe
# KkQVsQf+Mnow3ceQ4Tx9ovnn18SyS6+hXzBqUabd2aV4ybnkcwXAsY1XnArINdQP
# FuaJNgQalcaQYF9iCgZpSE0hcdk8Zt2lISZOPOAMvZ5zvia+fT2FoqKQYevIK/Oq
# 1A8g96yZW33EPi4SemEgnmXoKl8a0/HDqD7AT/L0JJuDWuldplRC2vJHoyT0tnC0
# qgTmENOGJsxbLJnpu9y2PyHpTgeRw7TdHwjN56c8Q0RjIptUFHotU47xYvMAbcdw
# E6mbeppnrOlF+0kNBy+jtAg1Fleh7JGIYbwyRh4QctRxIgTgvBJn/ej9BuljI230
# 8bCPaG6X5Ijrru66mTSQNyrsMAu4tA==
# =0Rb8
# -----END PGP SIGNATURE-----
# gpg: Signature made Fri Feb 27 12:56:22 2026 GMT
# gpg:                using RSA key 6685AE99E75167BCAFC8DF35FBD0DB095A9E2A44
# gpg: Good signature from "Alex Bennée (Master Work Key) <[email protected]>" [full]
# Primary key fingerprint: 6685 AE99 E751 67BC AFC8  DF35 FBD0 DB09 5A9E 2A44

* tag 'pull-11.0-testing-updates-270226-2' of https://gitlab.com/stsquad/qemu:
  tests/functional: add Arm VBSA uefi conformance test
  tests/vm: build openbsd from lcitool data
  tests/vm: fix interactive boot
  tests/vm: remove unused import
  tests/vm: bump OpenBSD to the current 7.8 release
  tests/docker: migrate legacy-test-cross compilers to trixie
  tests/docker: upgrade most non-lcitool debian tests to debian 13

Signed-off-by: Peter Maydell <[email protected]>
2026-02-28 14:30:23 +00:00
Peter Maydell 1dc84c612d Merge tag 'pull-9p-20260228' of https://github.com/cschoenebeck/qemu into staging
9pfs changes:

* Fix crash under unlink-heavy load in v9fs_mark_fids_unreclaim().

* Fix crash with the synth fs driver.

# -----BEGIN PGP SIGNATURE-----
#
# iQJLBAABCgA1FiEEltjREM96+AhPiFkBNMK1h2Wkc5UFAmmi7dIXHHFlbXVfb3Nz
# QGNydWRlYnl0ZS5jb20ACgkQNMK1h2Wkc5Uitw//SvhQlsjdtoJjsQYNpYN7gbkC
# PwU3b88xP1iPEhZ7ZWoQYdd0bJEdb4CmfG/iKlz8jwCvY2VnX4xkfU15GYLzEtOR
# PU13dBxXPLmhRFFO6TzLm8kFwa8LkZB/Hm8cGCwBshsGwIgQAE9RNoE/LyQb6C7B
# ocgdNFXkSvaqnWY6m3PjQb59IZ1Smg5P7GMvoIzqeiVYJ6PvsLvW9V/w3UrT5dhB
# hFqK8eUgYV5Wgx1qUeYqr8O9425tdGf9cO7w1eIl/YKTQkV3wbkvY8LlARYeLU6P
# bg2eVqj3c+dDVpO0+VSNUNutV5STHYP6Ub/WEZBP92MIOx8VIvus62/zKR2Hq2uY
# e0qpC3lCvKGxzxH54GGYzUfKonLi3uv5tLMfB/EPcLQd4bH0bf23a/F5gesYvzwZ
# N8WeHxV/cNpxxkM6lIDTdSIoxtj8HXLsZxkSJ8bOPpcXd7JPfIQATfYKVvVO7AzB
# JHsGSwHZ4xKw2KuDtN6xsalf48kVi8VZpcmgmCCgFN/m0ubQTcRiIXoZ3c8j9xp/
# UqrmcpBX5uU4t0CDEm0RBwyHVey7Gv0xFg8VKfIdWczdIcGNh/VCzp8rm+zcl6FB
# XFkA7O2q/qIPNpj0JNaBekKSLvDtqjgR0rOHh0iJhhzdQWIVkbKd0OvMtmpgKlbk
# vdAulpGAJftqpoe6/zo=
# =pZuI
# -----END PGP SIGNATURE-----
# gpg: Signature made Sat Feb 28 13:29:54 2026 GMT
# gpg:                using RSA key 96D8D110CF7AF8084F88590134C2B58765A47395
# gpg:                issuer "[email protected]"
# gpg: Good signature from "Christian Schoenebeck <[email protected]>" [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: ECAB 1A45 4014 1413 BA38  4926 30DB 47C3 A012 D5F4
#      Subkey fingerprint: 96D8 D110 CF7A F808 4F88  5901 34C2 B587 65A4 7395

* tag 'pull-9p-20260228' of https://github.com/cschoenebeck/qemu:
  hw/9pfs: fix missing EOPNOTSUPP on Twstat and Trenameat for fs synth driver
  hw/9pfs: fix data race in v9fs_mark_fids_unreclaim()

Signed-off-by: Peter Maydell <[email protected]>
2026-02-28 14:30:13 +00:00
Christian Schoenebeck b72d15f47c hw/9pfs: fix missing EOPNOTSUPP on Twstat and Trenameat for fs synth driver
Renaming files/dirs is only supported by path-based fs drivers. EOPNOTSUPP
should be returned on any renaming attempt for not path-based fs drivers.
This was already the case for 9p "Trename" request type. However for 9p
request types "Trenameat" and "Twstat" this was yet missing.

So fix this by checking in Twstat and Trenameat request handlers whether
the fs driver in use is really path based, if not return EOPNOTSUPP and
abort further handling of the request.

This fixes a crash with the 9p "synth" fs driver which is not path-based.

The crash happened because the synth driver stores and expects a raw
V9fsSynthNode pointer instead of a C-string on V9fsPath.data. So the
C-string delivered by 9p server to synth fs driver was incorrectly
casted to a V9fsSynthNode pointer, eventually causing a segfault.

Reported-by: Oliver Chang <[email protected]>
Fixes: https://issues.oss-fuzz.com/issues/477990727
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3298
Signed-off-by: Christian Schoenebeck <[email protected]>
Reviewed-by: Greg Kurz <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]/
2026-02-28 13:46:42 +01:00
Richie Buturla c96f6d2398 hw/9pfs: fix data race in v9fs_mark_fids_unreclaim()
A data race between v9fs_mark_fids_unreclaim() and v9fs_path_copy()
causes an inconsistent read of fidp->path. In v9fs_path_copy(), the
path size is set before the data pointer is allocated, creating a
window where size is non-zero but data is NULL.

v9fs_co_open2() holds a write lock during path modifications,
but v9fs_mark_fids_unreclaim() was not acquiring a read
lock, allowing it to race.

Fix by holding the path read lock during FID table iteration.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3300
Signed-off-by: Richie Buturla <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]/
Fixes: 7a46274529 ("hw/9pfs: Add file descriptor reclaim support")
Signed-off-by: Christian Schoenebeck <[email protected]>
2026-02-28 13:46:42 +01:00
Akihiko Odaki 649a78aa32 Reapply "rcu: Unify force quiescent state"
This reverts commit ddb4d9d174.

The commit says:
> This reverts commit 55d98e3ede.
>
> The commit introduced a regression in the replay functional test
> on alpha (tests/functional/alpha/test_replay.py), that causes CI
> failures regularly. Thus revert this change until someone has
> figured out what is going wrong here.

Reapply the change as alpha is fixed.

Signed-off-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-27 14:48:04 +01:00
Akihiko Odaki 284c01f76e target/alpha: Reset CPU
alpha_cpu_realizefn() did not properly call cpu_reset(), which
corrupted icount. Add the missing function call to fix icount.

Signed-off-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Tested-by: Thomas Huth <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-27 14:48:04 +01:00
Mohamed Mediouni 69dfc078a6 hw: i386: vapic: enable on WHPX with user-mode irqchip
Alleviate a performance bottleneck on legacy Windows guests.

In my test setup, this makes Windows XP boot times be 20x faster
than they're otherwise.

Signed-off-by: Mohamed Mediouni <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-27 14:48:04 +01:00
Mohamed Mediouni ca7a6add3b whpx: x86: kick out of HLT manually when using the kernel-irqchip
Otherwise, interrupts processed through the cancel vCPU and inject path will not cause the vCPU to go out of its halt state.

Signed-off-by: Mohamed Mediouni <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-27 14:48:04 +01:00
Mohamed Mediouni fc15a4c384 whpx: x86: remove inaccurate comment
WHvRunVpExitReasonX64Halt _is_ triggered on halt with kernel-irqchip=off as of Windows 11 version 25H2.

Signed-off-by: Mohamed Mediouni <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-27 14:48:04 +01:00
myrslint 5dacb3b8fa KVM: i386: Default disable ignore guest PAT quirk
Add a new accelerator option that allows the guest to adjust the PAT.
This is already the case for TDX guests and allows using virtio-gpu
Venus with RADV or NVIDIA drivers.

The quirk is disabled by default.  Since this caused problems with
Linux's Bochs video device driver, add a knob to leave it enabled,
and for now do ont enable it by default.

Signed-off-by: Myrsky Lintu <[email protected]>
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2943
Link: https://lore.kernel.org/r/[email protected]
[Add property; for now leave it off by default. - Paolo]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-27 14:48:04 +01:00
John Snow 062acfffe5 rust: use checked_div to make clippy happy
When upgrading from Fedora 41 to Fedora 43 for CI tests, clippy begins
complaining about not using checked_div instead of manually checking
divisors. Make clippy happy and use checked_div() instead.

Signed-off-by: John Snow <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-27 14:48:04 +01:00
Marc-André Lureau 1df5a9be65 ui: drop spice-protocol < 0.14.3 support
According to repology, all our supported distributions have 0.14.3.

Signed-off-by: Marc-André Lureau <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-27 14:48:04 +01:00
Marc-André Lureau 727451eadb audio: require spice >= 0.15
Spice server 0.15.0 was released on 2021-04-16. It is part of all our
supported distro (except CentOS 9, which doesn't include it).

It has all the new required audio APIs/interfaces.

Signed-off-by: Marc-André Lureau <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-27 14:48:04 +01:00
Marc-André Lureau 2168afd96c audio: require pulse >= 0.9.13
pulseaudio 0.9.13 was released on 2009-09-10. All our supported
distros have it.

PA_*_IS_GOOD are from 0.9.11.

Signed-off-by: Marc-André Lureau <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-27 14:48:04 +01:00
Marc-André Lureau f08abbae62 scripts/vendor.py: add pycotap
Related to commit 5ec1eec110 ("python:
Install pycotap in our venv if necessary")

Signed-off-by: Marc-André Lureau <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-27 14:48:04 +01:00
Marc-André Lureau 61fb8ca023 python/wheel: remove meson-1.9.0
Leftover from commit 8c04b6a48b.

Signed-off-by: Marc-André Lureau <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-27 14:48:04 +01:00
Marc-André Lureau 9b12aeda03 audio: fix nominal volume channel (cosmetic)
Signed-off-by: Marc-André Lureau <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-27 14:48:04 +01:00
Ani Sinha a9b3286111 qom: add 'confidential-guest-reset' property for x86 confidential vms
Through the new 'confidential-guest-reset' property, control plane should be
able to detect if the hypervisor supports x86 confidential guest resets. Older
hypervisors that do not support resets will not have this property populated.

Suggested-by: Daniel P. Berrangé <[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Reviewed-by: Daniel P. Berrangé <[email protected]>
Signed-off-by: Ani Sinha <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-27 14:48:04 +01:00
Ani Sinha da4ba40695 tests/functional/x86_64: add functional test to exercise vm fd change on reset
A new functional test is added that exercises the code changes related to
closing of the old KVM VM file descriptor and opening a new one upon VM reset.
This normally happens when confidential guests are reset but for
non-confidential guests, we use a special machine specific debug/test parameter
'x-change-vmfd-on-reset' to enable this behavior.
Only specific code changes related to re-initialisation of SEV-ES, SEV-SNP and
TDX platforms are not exercised in this test as they require hardware that
supports running confidential guests.

Signed-off-by: Ani Sinha <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-27 14:48:04 +01:00
Ani Sinha e76c30bb13 hw/machine: introduce machine specific option 'x-change-vmfd-on-reset'
A new machine specific option 'x-change-vmfd-on-reset' is introduced for
debugging and testing only (hence the 'x-' prefix). This option when enabled
will force KVM VM file descriptor to be changed upon guest reset like
in the case of confidential guests. This can be used to exercise the code
changes that are specific for confidential guests on non-confidential
guests as well (except changes that require hardware support for
confidential guests).
A new functional test has been added in the next patch that uses this new
parameter to test the VM file descriptor changes.

Signed-off-by: Ani Sinha <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-27 14:48:04 +01:00
Ani Sinha 18d55d0f66 kvm/clock: add support for confidential guest reset
Confidential guests change the KVM VM file descriptor upon reset and also create
new VCPU file descriptors against the new KVM VM file descriptor. We need to
save the clock state from kvm before KVM VM file descriptor changes and restore
it after. Also after VCPU file descriptors changed, we must call
KVM_KVMCLOCK_CTRL on the VCPU file descriptor to inform KVM that the VCPU is
in paused state.

Signed-off-by: Ani Sinha <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-27 14:48:04 +01:00
Ani Sinha 956200b180 kvm/vcpu: add notifiers to inform vcpu file descriptor change
When new vcpu file descriptors are created and bound to the new kvm file
descriptor as a part of the confidential guest reset mechanism, various
subsystems needs to know about it. This change adds notifiers so that various
subsystems can take appropriate actions when vcpu fds change by registering
their handlers to this notifier.
Subsequent changes will register specific handlers to this notifier.

Signed-off-by: Ani Sinha <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-27 14:48:04 +01:00
Ani Sinha c320bd40f7 ppc/openpic: create a new openpic device and reattach mem region on coco reset
For confidential guests during the reset process, the old KVM VM file
descriptor is closed and a new one is created. When a new file descriptor is
created, a new openpic device needs to be created against this new KVM VM file
descriptor as well. Additionally, existing memory region needs to be reattached
to this new openpic device and proper CPU attributes set associating new file
descriptor. This change makes this happen with the help of a callback handler
that gets called when the KVM VM file descriptor changes as a part of the
confidential guest reset process.

Reviewed-by: Bernhard Beschow <[email protected]>
Signed-off-by: Ani Sinha <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-27 14:48:04 +01:00
Ani Sinha 5e14320dac kvm/xen-emu: re-initialize capabilities during confidential guest reset
On confidential guests KVM virtual machine file descriptor changes as a
part of the guest reset process. Xen capabilities needs to be re-initialized in
KVM against the new file descriptor.

Signed-off-by: Ani Sinha <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-27 14:48:04 +01:00
Ani Sinha b6fde55342 hw/hyperv/vmbus: add support for confidential guest reset
On confidential guests when the KVM virtual machine file descriptor changes as
a part of the reset process, event file descriptors needs to be reassociated
with the new KVM VM file descriptor. This is achieved with the help of a
callback handler that gets called when KVM VM file descriptor changes during
the confidential guest reset process.

This patch is tested on non-confidential platform only.

Acked-by: Maciej S. Szmigiero <[email protected]>
Signed-off-by: Ani Sinha <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-27 14:48:04 +01:00
Ani Sinha c4cf32fc63 kvm/hyperv: add synic feature to CPU only if its not enabled
We need to make sure that synic CPU feature is not already enabled. If it is,
trying to enable it again will result in the following assertion:

Unexpected error in object_property_try_add() at ../qom/object.c:1268:
qemu-system-x86_64: attempt to add duplicate property 'synic' to object (type 'host-x86_64-cpu')

So enable synic only if its not enabled already.

Signed-off-by: Ani Sinha <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-27 14:48:03 +01:00
Ani Sinha 06fd6ae044 kvm/i8254: add support for confidential guest reset
A confidential guest reset involves closing the old virtual machine KVM file
descriptor and opening a new one. Since its a new KVM fd, PIT needs to be
re-initialized again. This is done with the help of a notifier which is invoked
upon KVM vm file descriptor change during the confidential guest reset process.

Signed-off-by: Ani Sinha <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-27 14:48:03 +01:00
Ani Sinha 815f0e916b kvm/i8254: refactor pit initialization into a helper
The initialization code will be used again by VM file descriptor change
notifier callback in a subsequent change. So refactor common code into a new
helper function.

Signed-off-by: Ani Sinha <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-27 14:48:03 +01:00
Ani Sinha 668c8abd8f hw/vfio: generate new file fd for pseudo device and rebind existing descriptors
Normally the vfio pseudo device file descriptor lives for the life of the VM.
However, when the kvm VM file descriptor changes, a new file descriptor
for the pseudo device needs to be generated against the new kvm VM descriptor.
Other existing vfio descriptors needs to be reattached to the new pseudo device
descriptor. This change performs the above steps.

Tested-by: Cédric Le Goater <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Signed-off-by: Ani Sinha <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-27 14:48:01 +01:00
Ani Sinha ec9bafd2ea i386/sev: add support for confidential guest reset
When the KVM VM file descriptor changes as a part of the confidential guest
reset mechanism, it necessary to create a new confidential guest context and
re-encrypt the VM memory. This happens for SEV-ES and SEV-SNP virtual machines
as a part of SEV_LAUNCH_FINISH, SEV_SNP_LAUNCH_FINISH operations.

A new resettable interface for SEV module has been added. A new reset callback
for the reset 'exit' state has been implemented to perform the above operations
when the VM file descriptor has changed during VM reset.

Tracepoints has been added also for tracing purpose.

Signed-off-by: Ani Sinha <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-27 14:22:08 +01:00
Ani Sinha 99d50e32c7 i386/sev: free existing launch update data and kernel hashes data on init
If there is existing launch update data and kernel hashes data, they need to be
freed when initialization code is executed. This is important for resettable
confidential guests where the initialization happens once every reset.

Signed-off-by: Ani Sinha <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-27 14:22:08 +01:00
Ani Sinha 1b4573f538 i386/sev: add notifiers only once
The various notifiers that are used needs to be installed only once not on
every initialization. This includes the vm state change notifier and others.
This change uses 'cgs->ready' flag to install the notifiers only one time,
the first time.

Signed-off-by: Ani Sinha <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-27 14:22:08 +01:00
Ani Sinha 13395029b5 i386/sev: add migration blockers only once
sev_launch_finish() and sev_snp_launch_finish() could be called multiple times
when the confidential guest is being reset/rebooted. The migration
blockers should not be added multiple times, once per invocation. This change
makes sure that the migration blockers are added only one time by adding the
migration blockers to the vm state change handler when the vm transitions to
the running state. Subsequent reboots do not change the state of the vm.

Reviewed-by: Prasad Pandit <[email protected]>
Signed-off-by: Ani Sinha <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-27 14:22:08 +01:00
Ani Sinha 154f1bcd64 i386/tdx: add a pre-vmfd change notifier to reset tdx state
During reset, when the VM file descriptor is changed, the TDX state needs to be
re-initialized. A notifier callback is implemented to reset the old
state and free memory before the new state is initialized post VM file
descriptor change.

Signed-off-by: Ani Sinha <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-27 14:22:08 +01:00
Ani Sinha 05caf2690e i386/tdx: finalize TDX guest state upon reset
When the confidential virtual machine KVM file descriptor changes due to the
guest reset, some TDX specific setup steps needs to be done again. This
includes finalizing the initial guest launch state again. This change
re-executes some parts of the TDX setup during the device reset phaze using a
resettable interface. This finalizes the guest launch state again and locks
it in. Machine done notifier which was previously used is no longer needed as
the same code is now executed as a part of VM reset.

Signed-off-by: Ani Sinha <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-27 14:22:08 +01:00
Ani Sinha b318bb6969 i386/tdx: refactor TDX firmware memory initialization code into a new function
A new helper function is introduced that refactors all firmware memory
initialization code into a separate function. No functional change.

Signed-off-by: Ani Sinha <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-27 14:22:08 +01:00
Ani Sinha 083ce77fc4 accel/kvm: rebind current VCPUs to the new KVM VM file descriptor upon reset
Confidential guests needs to generate a new KVM file descriptor upon virtual
machine reset. Existing VCPUs needs to be reattached to this new
KVM VM file descriptor. As a part of this, new VCPU file descriptors against
this new KVM VM file descriptor needs to be created and re-initialized.
Resources allocated against the old VCPU fds needs to be released. This change
makes this happen.

Signed-off-by: Ani Sinha <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-27 14:22:08 +01:00
Ani Sinha 7561c3247c kvm/i386: reload firmware for confidential guest reset
When IGVM is not being used by the confidential guest, the guest firmware has
to be reloaded explicitly again into memory. This is because, the memory into
which the firmware was loaded before reset was encrypted and is thus lost
upon reset. When IGVM is used, it is expected that the IGVM will contain the
guest firmware and the execution of the IGVM directives will set up the guest
firmware memory.

Signed-off-by: Ani Sinha <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-27 14:22:08 +01:00
Ani Sinha 40c015e969 hw/i386: export a new function x86_bios_rom_reload
Confidential guest smust reload their bios rom upon reset. This is because
bios memory is encrypted and upon reset, the contents of the old bios memory
is lost and cannot be re-used. To this end, export a new x86 function
x86_bios_rom_reload() to reload the bios again. This function will be used in
the subsequent patches.

Reviewed-by: Bernhard Beschow <[email protected]>
Signed-off-by: Ani Sinha <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-27 14:22:08 +01:00
Ani Sinha 473932c2eb hw/i386: refactor x86_bios_rom_init for reuse in confidential guest reset
For confidential guests, bios image must be reinitialized upon reset. This
is because bios memory is encrypted and hence once the old confidential
kvm context is destroyed, it cannot be decrypted. It needs to be reinitilized.
Towards that, this change refactors x86_bios_rom_init() code so that
parts of it can be called during confidential guest reset.
No functional chnage.

Acked-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Ani Sinha <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-27 14:22:08 +01:00
Ani Sinha 1842537960 i386/kvm: refactor xen init into a new function
Cosmetic - no new functionality added. Xen initialisation code is refactored
into its own function.

Signed-off-by: Ani Sinha <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-27 14:22:08 +01:00
Ani Sinha 9d7e732229 kvm/i386: implement architecture support for kvm file descriptor change
When the kvm file descriptor changes as a part of confidential guest reset,
some architecture specific setups including SEV/SEV-SNP/TDX specific setups
needs to be redone. These changes are implemented as a part of the
kvm_arch_on_vmfd_change() callback which was introduced previously.

Signed-off-by: Ani Sinha <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-27 14:22:08 +01:00
Ani Sinha 68457a8c2e i386/kvm: unregister smram listeners prior to vm file descriptor change
We will re-register smram listeners after the VM file descriptors has changed.
We need to unregister them first to make sure addresses and reference counters
work properly.

Signed-off-by: Ani Sinha <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-27 14:22:08 +01:00
Ani Sinha 0f53f021ad accel/kvm: notify when KVM VM file fd is about to be changed
Various subsystems might need to take some steps before the KVM file descriptor
for a virtual machine is changed. So a new boolean attribute is added to the
vmfd_notifier structure which is passed to the notifier callbacks.
vmfd_notifer.pre is true for pre-notification of vmfd change and false for
post notification. Notifier callback implementations can simply check
the boolean value for (vmfd_notifer*)->pre and can take actions for pre or
post vmfd change based on the value.

Subsequent patches will add callback implementations for specific components
that need this pre-notification.

Signed-off-by: Ani Sinha <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-27 14:22:08 +01:00
Ani Sinha 4dd184cb41 accel/kvm: add a notifier to indicate KVM VM file descriptor has changed
A notifier callback can be used by various subsystems to perform actions when
KVM file descriptor for a virtual machine changes as a part of confidential
guest reset process. This change adds this notifier mechanism. Subsequent
patches will add specific implementations for various notifier callbacks
corresponding to various subsystems that need to take action when KVM VM file
descriptor changed.

Signed-off-by: Ani Sinha <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-27 14:22:08 +01:00
Ani Sinha 9f0c2b3032 accel/kvm: mark guest state as unprotected after vm file descriptor change
When the KVM VM file descriptor has changed and a new one created, the guest
state is no longer in protected state. Mark it as such.
The guest state becomes protected again when TDX and SEV-ES and SEV-SNP mark
it as such.

Signed-off-by: Ani Sinha <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-27 14:22:08 +01:00
Ani Sinha 98884e0cc1 accel/kvm: add changes required to support KVM VM file descriptor change
This change adds common kvm specific support to handle KVM VM file descriptor
change. KVM VM file descriptor can change as a part of confidential guest reset
mechanism. A new function api kvm_arch_on_vmfd_change() per
architecture platform is added in order to implement architecture specific
changes required to support it. A subsequent patch will add x86 specific
implementation for kvm_arch_on_vmfd_change() as currently only x86 supports
confidential guest reset.

Signed-off-by: Ani Sinha <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-27 14:22:08 +01:00
Ani Sinha df8df3cb6b system/physmem: add helper to reattach existing memory after KVM VM fd change
After the guest KVM file descriptor has changed as a part of the process of
confidential guest reset mechanism, existing memory needs to be reattached to
the new file descriptor. This change adds a helper function ram_block_rebind()
for this purpose. The next patch will make use of this function.

Signed-off-by: Ani Sinha <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-27 14:22:07 +01:00
Ani Sinha 4003e5e65f hw/accel: add a per-accelerator callback to change VM accelerator handle
When a confidential virtual machine is reset, a new guest context in the
accelerator must be generated post reset. Therefore, the old accelerator guest
file handle must be closed and a new one created. To this end, a per-accelerator
callback, "rebuild_guest" is introduced that would get called when a confidential
guest is reset. Subsequent patches will introduce specific implementation of
this callback for KVM accelerator.

Signed-off-by: Ani Sinha <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-27 14:22:07 +01:00
Ani Sinha 2391125f13 accel/kvm: add confidential class member to indicate guest rebuild capability
As a part of the confidential guest reset process, the existing encrypted guest
state must be made mutable since it would be discarded after reset. A new
encrypted and locked guest state must be established after the reset. To this
end, a new boolean member per confidential guest support class
(eg, tdx or sev-snp) is added that will indicate whether its possible to
rebuild guest state:

bool can_rebuild_guest_state;

This is true if rebuilding guest state is possible, false otherwise.
A KVM based confidential guest reset is only possible when
the existing state is locked but its possible to rebuild guest state.
Otherwise, the guest is not resettable.

Signed-off-by: Ani Sinha <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-27 14:22:07 +01:00
Ani Sinha b3f0a55576 i386/kvm: avoid installing duplicate msr entries in msr_handlers
kvm_filter_msr() does not check if an msr entry is already present in the
msr_handlers table and installs a new handler unconditionally. If the function
is called again with the same MSR, it will result in duplicate entries in the
table and multiple such calls will fill up the table needlessly. Fix that.

Signed-off-by: Ani Sinha <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-27 14:22:07 +01:00
Alexander Graf 2855cee7c8 docs: Add Nitro Enclaves documentation
Now that all pieces are in place to spawn Nitro Enclaves using
a special purpose accelerator and machine model, document how
to use it.

Signed-off-by: Alexander Graf <[email protected]>

Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-27 14:22:07 +01:00
Alexander Graf f75e7baeaf hw/nitro: Enable direct kernel boot
Nitro Enclaves can only boot EIF files which are a combination of
kernel, initramfs and cmdline in a single file. When the kernel image is
not an EIF, treat it like a kernel image and assemble an EIF image on
the fly. This way, users can call QEMU with a direct
kernel/initrd/cmdline combination and everything "just works".

Signed-off-by: Alexander Graf <[email protected]>
Reviewed-by: Dorjoy Chowdhury <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-27 14:22:07 +01:00
Alexander Graf 73f84b622f hw/core/eif: Move definitions to header
In follow-up patches we need some EIF file definitions that are
currently in the eif.c file, but want to access them from a separate
device. Move them into the header instead.

Signed-off-by: Alexander Graf <[email protected]>
Reviewed-by: Dorjoy Chowdhury <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-27 14:22:07 +01:00
Alexander Graf 0e7f6f6359 hw/nitro: Add nitro machine
Add a machine model to spawn a Nitro Enclave. Unlike the existing -M
nitro-enclave, this machine model works exclusively with the -accel
nitro accelerator to drive real Nitro Enclave creation. It supports
memory allocation, number of CPU selection, both x86_64 as well as
aarch64, implements the Enclave heartbeat logic and debug serial
console.

To use it, create an EIF file and run

  $ qemu-system-x86_64 -accel nitro,debug-mode=on -M nitro -nographic \
                       -kernel test.eif

or

  $ qemu-system-aarch64 -accel nitro,debug-mode=on -M nitro -nographic \
                        -kernel test.eif

Signed-off-by: Alexander Graf <[email protected]>

Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-27 14:22:07 +01:00
Alex Bennée 49105fa010 tests/functional: add Arm VBSA uefi conformance test
The VBSA test is a subset of the wider Arm architecture compliance
suites (ACS) which validate machines meet particular minimum set of
requirements. The VBSA is for virtual machines so it makes sense we
should check the -M virt machine is compliant.

Fortunately there are prebuilt binaries published via github so all we
need to do is build an EFI partition and place things in the right
place.

There are some additional Linux based tests which are left for later.

Reviewed-by: Mohamed Mediouni <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alex Bennée <[email protected]>
2026-02-27 12:54:17 +00:00
Alex Bennée 1a1787ab6b tests/vm: build openbsd from lcitool data
For now only use the minimal decadency set until all the OpenBSD
mappings can be divined.

Reviewed-by: Pierrick Bouvier <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alex Bennée <[email protected]>
2026-02-27 12:13:53 +00:00
Alex Bennée 74a813a265 tests/vm: fix interactive boot
For reasons still not clear to me passing the single dashed
-interactive would confuse the argument parsing enough we tried to
pass "nterative" as a string to the launch command causing failure and
head scratching.

Reviewed-by: Pierrick Bouvier <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alex Bennée <[email protected]>
2026-02-27 12:11:26 +00:00
Alex Bennée 9bef09c906 tests/vm: remove unused import
Reviewed-by: Pierrick Bouvier <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alex Bennée <[email protected]>
2026-02-27 12:11:24 +00:00
Alex Bennée 506e6b6f5a tests/vm: bump OpenBSD to the current 7.8 release
Reviewed-by: Pierrick Bouvier <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alex Bennée <[email protected]>
2026-02-27 12:09:52 +00:00
Alex Bennée af4b64eb94 tests/docker: migrate legacy-test-cross compilers to trixie
The bugs have evidently been fixed in the latest release so we can
migrate the laggards into how all-test-cross container and remove the
legacy hacks. They are also packaged for the main architectures so we
don't need to jump through the amd64 hoops.

Suggested-by: John Snow <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alex Bennée <[email protected]>
2026-02-27 12:09:25 +00:00
John Snow e2d4646a02 tests/docker: upgrade most non-lcitool debian tests to debian 13
Debian 11 was EOL in 2024, and Debian 12 will be EOL this June. This
patch moves all but one of our tests, debian-legacy-test-cross, onto
Debian 13.

This patch does the bare minimum to upgrade these tests and doesn't make
any attempt at optimization or cleanup that may or may not be possible
with this upgrade.

Signed-off-by: John Snow <[email protected]>
Reviewed-by: Daniel P. Berrangé <[email protected]>
[AJB: tweak summary line]
Message-ID: <[email protected]>
Signed-off-by: Alex Bennée <[email protected]>
2026-02-27 12:09:25 +00:00
Alexander Graf 246f0f6727 target/arm/cpu64: Allow -host for nitro
The nitro accel does not actually make use of CPU emulation or details:
It always uses the host CPU regardless of configuration. Machines for
the nitro accel select the host CPU type as default to have a clear
statement of the above and to have a unified cpu type across all
supported architectures.

The arm64 logic on Linux currently only allows -cpu host for KVM based
virtual machines. Add a special case for nitro so that when the nitro
accel is active, it allows use of the host cpu type.

Signed-off-by: Alexander Graf <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-27 08:18:31 +01:00
Alexander Graf 9bdc612a18 hw/nitro: Introduce Nitro Enclave Heartbeat device
Nitro Enclaves expect the parent instance to host a vsock heartbeat listener
at port 9000. To host a Nitro Enclave with the nitro accel in QEMU, add
such a heartbeat listener as device model, so that the machine can
easily instantiate it.

Signed-off-by: Alexander Graf <[email protected]>

Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-27 08:18:31 +01:00
Alexander Graf 00c8360720 hw/nitro/nitro-serial-vsock: Nitro Enclaves vsock console
Nitro Enclaves support a special "debug" mode. When in debug mode, the
Nitro Hypervisor provides a vsock port that the parent can connect to to
receive serial console output of the Enclave. Add a new nitro-serial-vsock
driver that implements short-circuit logic to establish the vsock
connection to that port and feed its data into a chardev, so that a machine
model can use it as serial device.

Signed-off-by: Alexander Graf <[email protected]>

Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-27 08:18:31 +01:00
Alexander Graf 8155bca60d accel: Add Nitro Enclaves accelerator
Nitro Enclaves are a confidential compute technology which
allows a parent instance to carve out resources from itself
and spawn a confidential sibling VM next to itself. Similar
to other confidential compute solutions, this sibling is
controlled by an underlying vmm, but still has a higher level
vmm (QEMU) to implement some of its I/O functionality and
lifecycle.

Add an accelerator to drive this interface. In combination with
follow-on patches to enhance the Nitro Enclaves machine model, this
will allow users to run a Nitro Enclave using QEMU.

Signed-off-by: Alexander Graf <[email protected]>

Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-27 08:18:31 +01:00
Alexander Graf 4953bf187d hw/nitro: Add Nitro Vsock Bus
Add a dedicated bus for Nitro Enclave vsock devices. In Nitro Enclaves,
communication between parent and enclave/hypervisor happens almost
exclusively through vsock. The nitro-vsock-bus models this dependency
in QEMU, which allows devices in this bus to implement individual services
on top of vsock.

The nitro machine spawns this bus by creating the included
nitro-vsock-bridge sysbus device.

The nitro accel then advertises the Enclave's CID to the bus by calling
nitro_vsock_bridge_start_enclave() on the bridge device as soon as it
knows the CID.

Nitro vsock devices can listen to that event and learn the Enclave's CID
when it is available to perform actions, such as connect to the debug
serial vsock port.

Suggested-by: Paolo Bonzini <[email protected]>
Signed-off-by: Alexander Graf <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-27 08:18:31 +01:00
Alexander Graf ac46a82996 linux-headers: Add nitro_enclaves.h
QEMU is learning to drive the /dev/nitro_enclaves device node. Include
its UAPI header into our local copy of kernel headers so it has all
defines we need to drive it.

Signed-off-by: Alexander Graf <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-27 08:18:31 +01:00
Alexander Graf 2ae6d10c24 scripts/update-linux-headers: Add Nitro Enclaves header
We want to enable QEMU to drive the /dev/nitro_enclaves device node. Add
its UAPI header into our kernel sync so we have all defines we need to
drive it.

Signed-off-by: Alexander Graf <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-27 08:18:31 +01:00
Maxim Levitsky 777d9f78ff accel/kvm: Don't clear pending #SMI in kvm_get_vcpu_events
The kvm_get_vcpu_events propogates the state of the pending smi
from the kernel to the cpu->interrupt_request, with the intention
of having un up to date migration state.

Later the opposite is done, the kvm_put_vcpu_events restores the state
of the pending #SMI from the 'cs->interrupt_request'

The only problem is that kvm_get_vcpu_events also resets the SMI
in cpu->interrupt_request when there is no pending #SMI indicated by the kernel,
and that is wrong as the SMI might be still raised by qemu.

While at it, also fix a similar but more theoretical bug with regard to a
latched #INIT while in SMM.

A simple reproducer for this bug is to read an EFI variable in a loop
from within a guest, while at the same time run 'info registers' on
the qemu HMP monitor.

The reads will, once in a while, fail with an 'Invalid argument' error.

Signed-off-by: Maxim Levitsky <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-27 08:18:31 +01:00
Mohamed Mediouni f5b03da29f target/i386: emulate: propagate errors all the way and stop early
This ended up being a bigger patch than I thought it'd be...

Signed-off-by: Mohamed Mediouni <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-27 08:18:31 +01:00
Mohamed Mediouni 9533cc6d36 whpx: i386: ignore send_msi to interrupt vector 0
Signed-off-by: Mohamed Mediouni <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-27 08:18:31 +01:00
Mohamed Mediouni 5b4810a0ff whpx: i386: bump to x2apic
Signed-off-by: Mohamed Mediouni <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-27 08:18:31 +01:00
Mohamed Mediouni b5f7036a71 whpx: i386: inject exceptions
Signed-off-by: Mohamed Mediouni <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-27 08:18:31 +01:00
Mohamed Mediouni 192d377c98 target/i386: emulate: propagate memory errors on most reads/writes
Use that to not bump RIP for those cases.

Warn on read/write from/to unmapped MMIO, but not consider that as an exception.
For reads, return 0xFF(s) as the register value in that case.

Leaves a coverage gap for read_val_ext(), to be handled in a later commit.

Signed-off-by: Mohamed Mediouni <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-27 08:18:31 +01:00
Mohamed Mediouni fb45807fff target/i386: emulate: remove fetch_instruction helper too
Not used anymore.
Link: https://lore.kernel.org/r/[email protected]

Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-27 08:18:31 +01:00
Mohamed Mediouni a998be9926 target/i386: emulate: raise an exception on translation fault
Signed-off-by: Mohamed Mediouni <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-27 08:18:31 +01:00
Mohamed Mediouni a32e4ffc72 target/i386: emulate: get rid of write_val_to_mem() helper
Signed-off-by: Mohamed Mediouni <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-27 08:18:31 +01:00
Mohamed Mediouni 7e44b76644 hvf: i386: save/restore CR0/2/3
For symmetry, save/restore the same set of registers even when not needed.

CR2 save/restore needed as page faults injected to the guest imply modifying CR2.

Signed-off-by: Mohamed Mediouni <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-27 08:18:31 +01:00
Mohamed Mediouni 1c85a4a3d7 target/i386: emulate, hvf, mshv: rework MMU code
target/i386/emulate doesn't currently properly emulate instructions
which might cause a page fault during their execution. Notably, REP STOS/MOVS
from MMIO to an address which is unmapped until a page fault exception is raised
causes an abort() in vmx_write_mem.

Change the interface between the HW accel backend and target/i386/emulate as a first step towards addressing that.

Adapt the page table walker code to give actionable errors,
while leaving a possibility for backends to provide their own walker.

This removes the usage of the Hyper-V page walker in the mshv backend.

Signed-off-by: Mohamed Mediouni <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-27 08:18:31 +01:00
Mohamed Mediouni d1d985a34d target/i386: emulate: 5-level paging for the page table walker
Signed-off-by: Mohamed Mediouni <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-26 18:58:39 +01:00
Mohamed Mediouni 84d1d2b79d target/i386: mshv, emulate: move the generic x86 helpers to target/i386/emulate
HVF doesn't use them at this point, but move them to common code as that's what they are.

Signed-off-by: Mohamed Mediouni <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-26 18:58:39 +01:00
Mohamed Mediouni 2a9c0d0ac9 whpx: i386: saving/restoring less state for WHPX_LEVEL_FAST_RUNTIME_STATE
Optimise vmexits by save/restoring less state in those cases instead of the full state.

Signed-off-by: Mohamed Mediouni <[email protected]>
Reviewed-by: Bernhard Beschow <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-26 18:58:39 +01:00
Mohamed Mediouni 49f31a9671 whpx: common, i386, arm: rework state levels
Change state levels from a set of ifdefs to an enum.
Make register state loads use state levels too.

Signed-off-by: Mohamed Mediouni <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-26 18:58:39 +01:00
Mohamed Mediouni 2c08624db0 whpx: i386: remove CPUID trapping
Very partial in its current state and results in significantly inconsistent
CPUID data. Remove it until it's reimplemented later.

Signed-off-by: Mohamed Mediouni <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-26 18:58:39 +01:00
Mohamed Mediouni 40860e0c95 whpx: i386: remove messages
Remove some messages printed by the WHPX backend that don't
have an equivalent elsewhere and don't convey an error.

Signed-off-by: Mohamed Mediouni <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-26 18:58:39 +01:00
Mohamed Mediouni 9bd8a24a17 whpx: i386: remove remaining winhvemulation support code
After moving away to target/i386/emulate, this is no longer necessary.

Signed-off-by: Mohamed Mediouni <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-26 18:58:39 +01:00
Mohamed Mediouni a33a57f8d2 whpx: i386: flags conversion for target/i386/emulate internal state
Signed-off-by: Mohamed Mediouni <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-26 18:58:39 +01:00
Mohamed Mediouni ad17d24d18 whpx: i386: switch over from winhvemulation to target/i386/emulate
Using the mshv backend as a base, move away from winhvemulation
to using common QEMU code used by the HVF and mshv backends.

Signed-off-by: Mohamed Mediouni <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-26 18:58:39 +01:00
Mohamed Mediouni 9fdece1224 whpx: move whpx_get_reg/whpx_set_reg to generic code
These will be used in the next commit on the x86_64 backend too.
Also move flush_cpu_state as it's used by get_reg/set_reg and the arm64 code.

Signed-off-by: Mohamed Mediouni <[email protected]>
Reviewed-by: Bernhard Beschow <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-26 18:58:39 +01:00
Mohamed Mediouni 02dff8f72d whpx: refactor whpx_destroy_vcpu to arch-specific function
Avoid a TARGET_X86_64 define by moving platform-specific code
away from generic WHPX support.

Signed-off-by: Mohamed Mediouni <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-26 18:58:39 +01:00
Mohamed Mediouni 91a76b2c2d whpx: preparatory changes before switching over from winhvemulation
Signed-off-by: Mohamed Mediouni <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-26 18:58:39 +01:00
Mohamed Mediouni 19b48084f7 whpx: i386: re-enable guest debug support
Fix what got broken several years ago by adding ops->supports_guest_debug
support as an architecture-specific function.

arm64 WHP doesn't currently provide support needed for this.

Signed-off-by: Mohamed Mediouni <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-26 18:58:39 +01:00
Mohamed Mediouni 2c87eb5cad target/i386: emulate, hvf: move x86_mmu to common code
Signed-off-by: Mohamed Mediouni <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-26 18:58:39 +01:00
Mohamed Mediouni 03bd8515a3 target/i386/emulate: rework string_rep emulation
Signed-off-by: Mohamed Mediouni <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-26 18:58:39 +01:00
Bernhard Beschow 1b93832f55 target/i386/emulate/x86_decode: Actually use stream in decode_instruction_stream()
Compared to decode_instruction(), decode_instruction_stream() has an additional
stream parameter which avoids some guest memory accesses during instruction
decoding. Both functions defer the actual work to decode_opcode() which would
set the stream pointer to zero such that decode_instruction_stream() essentially
behaved like decode_instruction(). Given that all callers of
decode_instruction_stream() properly zero-initialize the decode parameter, the
memset() call can be moved into decode_instruction() which is the only other
user of decode_opcode(). This preserves the non-zero stream pointer which
avoids extra guest memory accesses.

Fixes: 1e25327b24 ("target/i386/emulate: Allow instruction decoding from stream")
cc: qemu-stable
Signed-off-by: Bernhard Beschow <[email protected]>
Reviewed-by: Mohamed Mediouni <[email protected]>
Reviewed-by: Wei Liu (Microsoft) <[email protected]>
Tested-by: Magnus Kulke <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-26 18:58:39 +01:00
Bernhard Beschow 529e5e7643 target/i386/hvf/x86_mmu: Fix compiler warning
When reusing the code in WHPX, GCC emits the following warning when compiling
for i386-softmmu under MSYS2:

  In file included from ../src/target/i386/emulate/x86_mmu.c:20:
  ../src/target/i386/emulate/x86_mmu.c: In function 'vmx_write_mem':
  ../src/target/i386/emulate/x86_mmu.c:251:25: error: format '%llx' expects argument of type 'long long unsigned int', but argument 3 has type 'target_ulong' {aka 'unsigned int'} [-Werror=format=]
    251 |             VM_PANIC_EX("%s: mmu_gva_to_gpa %llx failed\n", __func__, gva);
        |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~            ~~~
        |                                                                       |
        |                                                                       target_ulong {aka unsigned int}
  ../src/target/i386/emulate/panic.h:34:12: note: in definition of macro 'VM_PANIC_EX'
     34 |     printf(__VA_ARGS__); \
        |            ^~~~~~~~~~~
  ../src/target/i386/emulate/x86_mmu.c:251:48: note: format string is defined here
    251 |             VM_PANIC_EX("%s: mmu_gva_to_gpa %llx failed\n", __func__, gva);
        |                                             ~~~^
        |                                                |
        |                                                long long unsigned int
        |                                             %x

Fix the warning by reusing the target-specific macro TARGET_FMT_lx which exists
for this exact purpose.

Fixes: c97d6d2cdf ("i386: hvf: add code base from Google's QEMU repository")
cc: qemu-stable
Signed-off-by: Bernhard Beschow <[email protected]>
Reviewed-by: Mohamed Mediouni <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Wei Liu (Microsoft) <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-26 18:58:39 +01:00
Bernhard Beschow c86bca1671 target/i386/emulate/x86_decode: Fix compiler warning
When compiling for i386-softmmu under MSYS2, GCC emits the following warning:

  In function 'get_reg_val',
      inlined from 'calc_modrm_operand64' at ../src/target/i386/emulate/x86_decode.c:1796:15:
  ../src/target/i386/emulate/x86_decode.c:1703:5: error: 'memcpy' forming offset [4, 7] is out of the bounds [0, 4] of object 'val' with type 'target_ulong' {aka 'unsigned int'} [-Werror=array-bounds=]
   1703 |     memcpy(&val,
        |     ^~~~~~~~~~~~
   1704 |            get_reg_ref(env, reg, rex_present, is_extended, size),
        |            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   1705 |            size);
        |            ~~~~~
  ../src/target/i386/emulate/x86_decode.c: In function 'calc_modrm_operand64':
  ../src/target/i386/emulate/x86_decode.c:1702:18: note: 'val' declared here
   1702 |     target_ulong val = 0;
        |                  ^~~

In the calc_modrm_operand64() case the compiler sees size == 8 to be mem-copied
to a target_ulong variable which is only 4 bytes wide in case of i386-softmmu.
Note that when size != 1, get_reg_ref() always returns a pointer to an 8 byte
register, regardless of the target_ulong size. Fix the compiler warning by
always providing 8 bytes of storage by means of uint64_t.

Fixes: 77a2dba45c ("target/i386/emulate: stop overloading decode->op[N].ptr")
cc: qemu-stable
Signed-off-by: Bernhard Beschow <[email protected]>
Reviewed-by: Mohamed Mediouni <[email protected]>
Reviewed-by: Wei Liu (Microsoft) <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-26 18:58:39 +01:00
Josh Poimboeuf 48c8916aec hw/i386/vmmouse: Fix hypercall clobbers
Fedora QA reported the following kernel panic:

  BUG: unable to handle page fault for address: 0000000040003e54
  #PF: supervisor write access in kernel mode
  #PF: error_code(0x0002) - not-present page
  PGD 1082ec067 P4D 0
  Oops: Oops: 0002 [#1] SMP NOPTI
  CPU: 0 UID: 0 PID: 0 Comm: swapper/0 Not tainted 6.19.0-0.rc4.260108gf0b9d8eb98df.34.fc43.x86_64 #1 PREEMPT(lazy)
  Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS edk2-20251119-3.fc43 11/19/2025
  RIP: 0010:vmware_hypercall4.constprop.0+0x52/0x90
  Code: 48 83 c4 20 5b e9 69 f0 fc fe 8b 05 a0 c1 b2 01 85 c0 74 23 b8 68 58 4d 56 b9 27 00 00 00 31 d2 bb 04 00 00 00 66 ba 58 56 ed <89> 1f 89 0e 41 89 10 5b e9 3c f0 fc fe 6a 00 49 89 f9 45 31 c0 31
  RSP: 0018:ff5eeb3240003e40 EFLAGS: 00010046
  RAX: 0000000000000000 RBX: 000000000000ffca RCX: 000000000000ffac
  RDX: 0000000000000000 RSI: 0000000040003e58 RDI: 0000000040003e54
  RBP: ff1e05f3c1204800 R08: ff5eeb3240003e5c R09: 000000009d899c41
  R10: 000000000000003d R11: ff5eeb3240003ff8 R12: 0000000000000000
  R13: 00000000000000ff R14: ff1e05f3c02f9e00 R15: 000000000000000c
  FS:  0000000000000000(0000) GS:ff1e05f489e40000(0000) knlGS:0000000000000000
  CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
  CR2: 0000000040003e54 CR3: 000000010841d002 CR4: 0000000000771ef0
  PKRU: 55555554
  Call Trace:
   <IRQ>
   vmmouse_report_events+0x13e/0x1b0
   psmouse_handle_byte+0x15/0x60
   ps2_interrupt+0x8a/0xd0
   ...

It was triggered by dereferencing a bad pointer (RDI) immediately after
a VMware hypercall for VMWARE_CMD_ABSPOINTER_DATA in the vmmouse driver:

  ffffffff82135070 <vmware_hypercall4.constprop.0>:
  ...
  ffffffff821350ac:       b8 68 58 4d 56          mov    $0x564d5868,%eax
  ffffffff821350b1:       b9 27 00 00 00          mov    $0x27,%ecx
  ffffffff821350b6:       31 d2                   xor    %edx,%edx
  ffffffff821350b8:       bb 04 00 00 00          mov    $0x4,%ebx
  ffffffff821350bd:       66 ba 58 56             mov    $0x5658,%dx
  ffffffff821350c1:       ed                      in     (%dx),%eax	<-- hypercall
  ffffffff821350c2:       89 1f                   mov    %ebx,(%rdi)	<-- crash

Reading the kernel disassembly shows that RDI should contain the value
of a valid kernel stack address here (0xff5eeb3240003e54).  Instead it
contains 0x40003e54, suggesting the hypervisor cleared the upper 32
bits.

And indeed, Alexey discovered that QEMU's vmmouse_get_data() and
vmmouse_set_data() are only saving/restoring the lower 32 bits, while
clearing the upper 32.  Fix that by changing the type of the saved data
array from uint32_t to uint64_t.

Fixes: 548df2acc6 ("VMMouse Emulation, by Anthony Liguori.")
Reported-by: Justin Forbes <[email protected]>
Debugged-by: Alexey Makhalov <[email protected]>
Signed-off-by: Josh Poimboeuf <[email protected]>
Link: https://lore.kernel.org/r/c508fc1d4a4ccd8c9fb1e51b71df089e31115a53.1770309998.git.jpoimboe@kernel.org
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3293
Cc: [email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-26 18:58:38 +01:00
Peter Maydell d8a9d97317 Merge tag 'pull-target-arm-20260226' of https://gitlab.com/pm215/qemu into staging
target-arm queue:
 * target/arm: set the correct TI bits for WFIT traps
 * target/arm: Refactorings preparatory to KVM SME support
 * target/arm/kvm: Don't free migration-blocker reason on failure
 * target/arm/kvm: add kvm-psci-version vcpu property
 * Revert "target/arm/hvf: Sync CNTV_CTL_EL0 & CNTV_CVAL_EL0"
 * hw/arm/virt: Add virtio-mmio-transports property
 * hw/arm/virt: Update error message for bad gic-version option
 * hw/cpu: Build a15mpcore.c once as common object
 * hw/misc/allwinner-cpucfg: Remove use of ARM_CPU() cast macro
 * hw/ssi/xilinx_spips: Reset TX FIFO in reset
 * hw/char/pl011: Only log "data written to disabled UART" once
 * tests/functional: Make sure test case .py files are executable

# -----BEGIN PGP SIGNATURE-----
#
# iQJNBAABCAA3FiEE4aXFk81BneKOgxXPPCUl7RQ2DN4FAmmgbNoZHHBldGVyLm1h
# eWRlbGxAbGluYXJvLm9yZwAKCRA8JSXtFDYM3hzREACaWhS6mbqwKA0ao5GJFIex
# NFF3PqUf5MFx5J2wt6wNYBRvE2/laqJM84v5c2fVqQmxUPC0K7kiBu8JRliFMDvK
# zeykVX30e0a59M3dxeqs5A3D398g9v4STIosj8HydKcVYavVyJaFoi5Uw01h6GAp
# BRlRAcXMX1RnICyltuueKXYkuIqCZ4lOlpDZbSU/c97b01B2Um4m3MOuKXM0RBGo
# RroTPkNInuIX+SSNbKiSb53CNzvZFn6cP/NQnCtarx9UONxxESPvXSRufG1YjqMw
# YJnvJsR8ZkEZfQMhN3305N5yaQdM8T2ZIcd8JT/mCiwTP/31xquCS+M2SjriD54p
# TU8lZm4r4r3K6DKWxpfa/A6BGUjStAkXVytfHKWZHBAKN59GhKIl6uX4I8W402H3
# OEzNs10K0arrCYkW4hUGnayW0DSzqYJKk8Ejc0vOJkDm3RP6NjiZmYom/iR1Tpbk
# 1AKDJ+DuewuCSp9iFcXLbhzfZJl2in4lbJaFy8xRJn+M1CLbAsdKU5o7FJYjbKdS
# cBL/9STS+Puko+A9+WyLHh00drkFndjKruCPFTmXHnOyujIkegaBDrKN1OKebtgL
# XisfuivE6ipZqAMYZwEcnSZluKsLFDUo3rQXeQK4CQFuKvsSM9ilmBWQ9V5avxO3
# /goJymB/HYlVJhlEh33Bcg==
# =8ERD
# -----END PGP SIGNATURE-----
# gpg: Signature made Thu Feb 26 15:55:06 2026 GMT
# gpg:                using RSA key E1A5C593CD419DE28E8315CF3C2525ED14360CDE
# gpg:                issuer "[email protected]"
# gpg: Good signature from "Peter Maydell <[email protected]>" [ultimate]
# gpg:                 aka "Peter Maydell <[email protected]>" [ultimate]
# gpg:                 aka "Peter Maydell <[email protected]>" [ultimate]
# gpg:                 aka "Peter Maydell <[email protected]>" [ultimate]
# Primary key fingerprint: E1A5 C593 CD41 9DE2 8E83  15CF 3C25 25ED 1436 0CDE

* tag 'pull-target-arm-20260226' of https://gitlab.com/pm215/qemu:
  hw/char/pl011: Only log "data written to disabled UART" once
  target/arm/kvm: Don't free migration-blocker reason on failure
  target/arm: Add have_ffr argument to kvm_arch_{get, put}_sve
  target/arm: Add vq argument to kvm_arch_{get, put}_sve
  target/arm: Drop kvm_arm_pmu_supported
  target/arm: Remove kvm test in arm_set_pmu
  target/arm: Drop kvm_arm_sve_supported
  target/arm: Move kvm test out of cpu_arm_set_sve
  target/arm: Init sve_vq in kvm_arm_set_cpu_features_from_host
  target/arm: Move kvm_arm_sve_get_vls within kvm.c
  target/arm: Remove aarch64 test for kvm
  hw/misc/allwinner-cpucfg: Remove use of ARM_CPU() cast macro
  hw/cpu: Build a15mpcore.c once as common object
  Revert "target/arm/hvf: Sync CNTV_CTL_EL0 & CNTV_CVAL_EL0"
  target/arm/kvm: add kvm-psci-version vcpu property
  tests/functional: Make sure test case .py files are executable
  hw/arm/virt: Update error message for bad gic-version option
  hw/arm/virt: Add virtio-mmio-transports property
  target/arm: set the correct TI bits for WFIT traps
  hw/ssi/xilinx_spips: Reset TX FIFO in reset

Signed-off-by: Peter Maydell <[email protected]>
2026-02-26 16:00:07 +00:00
Peter Maydell 306ee5505f scripts/coverity: Drop --enable-libnfs from configure
The environment we do our coverity build in (amd64-fedora-container)
has just upgraded to Fedora 43.  This ships with libnfs version
16.2.0.  We can't currently build against that: in commit
e2d98f2571 we added a requirement to meson.build that libnfs be <
6.0.0, because of an upstream API change that we haven't yet updated
block/nfs.c to handle.

The result is that the coverity CI job currently fails in
configure:

Dependency libnfs found: NO. Found 16.2.0 but need: '<6.0.0' ;
matched: '>=1.9.3'
Run-time dependency libnfs found: NO
../meson.build:1150:11: ERROR: Dependency lookup for libnfs with
method 'pkgconfig' failed: Invalid version, need 'libnfs' ['<6.0.0']
found '16.2.0'.

Fix the coverity builds by dropping --enable-libnfs. This means we
will no longer have coverage of block/nfs.c until/unless we do
that update to handle the new libnfs API.

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Message-id: [email protected]
2026-02-26 15:59:45 +00:00
John Snow b7872ccbb9 configure: allow PyPI access for python 'tooling' dependencies
We actually do not allow our meson requirements to be fetched online
because we strictly prefer the vendored version. Move the tooling group
installation to a different invocation that does allow PyPI to be
accessed when configure is run without explicitly disabling PyPI access.

This will allow QEMU to download and install python3-wheel for you if
you don't have it in your host environment.

Reported-by: Kevin Wolf <[email protected]>
Reported-by: Thomas Huth <[email protected]>
Signed-off-by: John Snow <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Reviewed-by: Daniel P. Berrangé <[email protected]>
Tested-by: Thomas Huth <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-02-26 15:59:07 +00:00
Peter Maydell 907b8d5635 hw/char/pl011: Only log "data written to disabled UART" once
We log a GUEST_ERROR message "PL011 data written to disabled UART" if
the guest writes data to the TX FIFO when it has not set the enable
bit in the UART.  The idea is to note that the guest has done
something dubious but let it work anyway.  However, since we print
this message for every output character, it floods the logs when
running a guest that does this.

Keep a note of whether we've printed the log message or not, so we
only output it once.  If the guest actively disables the UART, we
re-arm the log message.

Notably, the Linux kernel does not bother to enable the UART if it is
used for earlycon, relying on the firmware having already done that.

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Mohamed Mediouni <[email protected]>
Message-id: [email protected]
2026-02-26 11:27:19 +00:00
Peter Maydell 534a96ab74 target/arm/kvm: Don't free migration-blocker reason on failure
The migrate_add_blocker() function documents that if it fails it will
free the Error it is passed via its reasonp argument and set reasonp
to NULL.  That means that in kvm_arm_enable_mte() we don't need to
call error_free(mte_migration_blocker) in the failure codepath.
Doing so is harmless because error_free(NULL) is permitted and does
nothing, but we can remove the unnecessary code.

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Message-id: [email protected]
2026-02-26 11:27:19 +00:00
Richard Henderson a59f5e8333 target/arm: Add have_ffr argument to kvm_arch_{get, put}_sve
Signed-off-by: Richard Henderson <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-02-26 11:27:19 +00:00
Richard Henderson ba738b9215 target/arm: Add vq argument to kvm_arch_{get, put}_sve
Signed-off-by: Richard Henderson <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-02-26 11:27:19 +00:00
Richard Henderson c23a2b303e target/arm: Drop kvm_arm_pmu_supported
This function has only one use, so inline it and drop the stubs.

Signed-off-by: Richard Henderson <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-02-26 11:27:18 +00:00
Richard Henderson 352051b1d2 target/arm: Remove kvm test in arm_set_pmu
In kvm_arm_get_host_cpu_features, we only set ARM_FEATURE_PMU if
kvm_arm_pmu_supported.  In arm_cpu_post_init we only register the
"pmu" property if ARM_FEATURE_PMU.  Therefore, if kvm is enabled,
we can only arrive in arm_set_pmu if kvm_arm_pmu_supported.

Signed-off-by: Richard Henderson <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-02-26 11:27:18 +00:00
Richard Henderson 4d08afde4b target/arm: Drop kvm_arm_sve_supported
This function has only one real use, so inline it and
drop the stubs.

Signed-off-by: Richard Henderson <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-02-26 11:27:18 +00:00
Richard Henderson d25293068b target/arm: Move kvm test out of cpu_arm_set_sve
Introduce a set of stub property callbacks for when we really
don't want to be able to enable SVE.  Register the real or stub
funtions in aarch64_add_sve_properties depending on whether or
not SVE is available.

Adjust aarch64_a64fx_initfn to initialize the set of supported
vector sizes before calling aarch64_add_sve_properties.

Signed-off-by: Richard Henderson <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-02-26 11:27:18 +00:00
Richard Henderson 5b3feb36ae target/arm: Init sve_vq in kvm_arm_set_cpu_features_from_host
Probe for SVE vector sizes with the same scratch vm that
we use for probing other features.  Remove a separate
initialization path in arm_cpu_sve_finalize.
Unexport kvm_arm_sve_get_vls.

Signed-off-by: Richard Henderson <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-02-26 11:27:18 +00:00
Richard Henderson 423b0ac34c target/arm: Move kvm_arm_sve_get_vls within kvm.c
Prepare to adjust the invocation point and visibility.

Signed-off-by: Richard Henderson <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-02-26 11:27:18 +00:00
Richard Henderson 5283e38fd1 target/arm: Remove aarch64 test for kvm
We no longer support kvm for aarch32, therefore the aarch64
test is trivially true.

Signed-off-by: Richard Henderson <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-02-26 11:27:18 +00:00
Philippe Mathieu-Daudé e0be954ff6 hw/misc/allwinner-cpucfg: Remove use of ARM_CPU() cast macro
allwinner_cpucfg_cpu_reset() doesn't access ARM CPU internal
fields: no need to cast, pass a generic CPU pointer along.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-02-26 11:27:18 +00:00
Philippe Mathieu-Daudé 8dbb04a68f hw/cpu: Build a15mpcore.c once as common object
a15mpcore.c doesn't need to include the target-specific 'kvm_arm.h'
header, it only lacks the qemu_get_cpu() declaration which comes
from 'hw/core/cpu.h'. Include the latter and build as common object.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-02-26 11:27:18 +00:00
Mohamed Mediouni 28b0ed32b3 Revert "target/arm/hvf: Sync CNTV_CTL_EL0 & CNTV_CVAL_EL0"
This reverts commit bfbea371ef.

This commit breaks VM save/restore:

Assertion failed: (b), function hvf_arch_get_registers, file hvf.c, line 667.
zsh: abort      ./qemu-system-aarch64 -m 8192 -M virt,accel=hvf -cdrom  -device virtio-gpu

Signed-off-by: Mohamed Mediouni <[email protected]>
Tested-by: Zenghui Yu <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
2026-02-26 11:27:18 +00:00
Sebastian Ott a99e32dbd4 target/arm/kvm: add kvm-psci-version vcpu property
Provide a kvm specific vcpu property to override the default
(as of kernel v6.13 that would be PSCI v1.3) PSCI version emulated
by kvm. Current valid values are: 0.1, 0.2, 1.0, 1.1, 1.2, and 1.3

Note: in order to support PSCI v0.1 we need to drop vcpu
initialization with KVM_CAP_ARM_PSCI_0_2 in that case.

Reviewed-by: Eric Auger <[email protected]>
Tested-by: Eric Auger <[email protected]>
Signed-off-by: Sebastian Ott <[email protected]>
Message-id: [email protected]
[PMM: adjust sscanf to not permit negative numbers]
Reviewed-by: Peter Maydell <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
2026-02-26 11:27:18 +00:00
Peter Maydell 7757ab56ab tests/functional: Make sure test case .py files are executable
The top-level test python scripts in tests/functional are supposed to
be marked executable; "make check-functional" doesn't care about
this, but it allows them to be run as standalone executables to
exercise a single test, as docs/devel/testing/functional.rst
describes.

A couple of files have got into the tree without the executable
bit set: fix them.

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Message-id: [email protected]
2026-02-26 11:27:18 +00:00
Peter Maydell f3ff5eb16f hw/arm/virt: Update error message for bad gic-version option
As we added different valid gic-version option settings,
we forgot to update the hint in the error message produced
when the user specifies an invalid value:

$ qemu-system-aarch64 -M virt,help | grep gic-version
  gic-version=<string>   - Set GIC version. Valid values are 2, 3, 4, host and max
$ qemu-system-aarch64 -M virt,gic-version=bang
qemu-system-aarch64: Invalid gic-version value
Valid values are 3, 2, host, max.

Update the error string to match the one we use in the help text
for the option.

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Mohamed Mediouni <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Alex Bennée <[email protected]>
Message-id: [email protected]
2026-02-26 11:27:18 +00:00
Mohammadfaiz Bawa ee4d1ff3af hw/arm/virt: Add virtio-mmio-transports property
Windows ARM64 guests detect virtio-mmio devices declared in ACPI
tables even when no backend is attached. This causes "Unknown
devices" (ACPI\LNRO0005) to appear in Device Manager.

Until Windows fixes that by supporting, add a new machine
property 'virtio-mmio-transports' to control the number of
virtio-mmio transports instantiated. The default remains
NUM_VIRTIO_TRANSPORTS (32) for backward compatibility.
Setting it to 0 allows users to disable virtio-mmio entirely.

Usage: -machine virt,virtio-mmio-transports=0

Signed-off-by: Mohammadfaiz Bawa <[email protected]>
Message-id: [email protected]
Reviewed-by: Peter Maydell <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
2026-02-26 11:27:18 +00:00
Alex Bennée 662fd548a0 target/arm: set the correct TI bits for WFIT traps
The WFIT trap should be reported as 0b10.

Cc: [email protected]
Signed-off-by: Alex Bennée <[email protected]>
Reviewed-by: Gustavo Romero <[email protected]>
Message-id: [email protected]
Reviewed-by: Peter Maydell <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
2026-02-26 11:27:18 +00:00
Weixie Cui 669683cf14 hw/ssi/xilinx_spips: Reset TX FIFO in reset
In xilinx_spips_reset() and xlnx_zynqmp_qspips_reset() a cut and
paste error meant we reset the RX FIFO twice and the TX FIFO not at
all.  Correct this to reset both FIFOs.

Cc: [email protected]
Signed-off-by: Weixie Cui <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Reviewed-by: Alistair Francis <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-id: [email protected]
[Rewrote commit message]
Signed-off-by: Peter Maydell <[email protected]>
2026-02-26 11:27:18 +00:00
Peter Maydell 7390b0825b Merge tag 'single-binary-20260226' of https://github.com/philmd/qemu into staging
Various patches related to single binary effort:

- Remove TARGET_PHYS_ADDR_SPACE_BITS definition
- Remove MonitorDef register entries already provided by gdbstub XML
- Remove gdbstub ldtul*() macros
- Build various gdbstub.c files once
- Make qemu_arch_available() and page-vary common code

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCAAdFiEE+qvnXhKRciHc/Wuy4+MsLN6twN4FAmmfgeYACgkQ4+MsLN6t
# wN6AUA/9E5LY2fWlQWHGXu4vDmzL4dqiIsitjd/2uo09Z7VQqJNOV+E1aj1cvk+y
# 0+CNafpwd3QkcdGFeAJla2qbTsSyQkEv5/ijZadprl1weAHSOM+0NNINL2fu1sZA
# VXLaUNXTEnrD82WPntF4ovbahcHzqPiimupZ0/RB1i6CAlcUv2fhN8hkmFwq1XaB
# DBNW0AG3+dL/qhYoJyloZCEn394QSTyVzexfqeQgbk1Zrwyx6b+EtobRIq9lEMTp
# 7OFQocPjOuXid+LR93MlRy/LSuw8ZAABIizFm924eMjuIe+JHRdOyRVl0N84kbcU
# TsaI7cB+qHM4uVrMrmaEpBBFATAWhMNxJMPTAYevrLOAN3whZj1a3ogKrZGroTPL
# aJG3M6to7TxKr1qDp+V75NkldUq/N4AG43aWLXODNuCewCZ9hV2QWMzAKuu9Ez4Q
# 6sEX2G8PlbiqnKqLkdFUg3Ny58v57IRXzyXJOrj9JG9v7NPCmHLT+xyyzVy3NVnF
# ZXbG0x/3/7jDGlYwPN5PKH7+NlEb44OwQ0qSyL7392mnhz+5DZ4IQr3LQriIFt31
# HT7fnlR1Kz01+vy7cezCHJOFdikK9cpJeKwljYkWhSOQvThRv5cELABiIrlXo423
# YVNZEirZWjiF8fS+nDJA91S3wj7pWGm0j3iSBGGPZ+9tG6OwHKU=
# =fOn0
# -----END PGP SIGNATURE-----
# gpg: Signature made Wed Feb 25 23:12:38 2026 GMT
# gpg:                using RSA key FAABE75E12917221DCFD6BB2E3E32C2CDEADC0DE
# gpg: Good signature from "Philippe Mathieu-Daudé (F4BUG) <[email protected]>" [full]
# Primary key fingerprint: FAAB E75E 1291 7221 DCFD  6BB2 E3E3 2C2C DEAD C0DE

* tag 'single-binary-20260226' of https://github.com/philmd/qemu: (70 commits)
  page-vary: Build migration_legacy_page_bits as common code
  page-vary: Build finalize_target_page_bits as common code
  page-vary: Build set_preferred_target_page_bits as common code
  target-info: Move TARGET_PAGE_BITS sanity check
  target-info: Add page_bits_{init,vary}
  page-vary: Expose TARGET_PAGE_BITS_MIN definition
  meson: don't access 'cxx' object without checking cpp lang
  system: Reduce 'arch_init.h' scope
  system: Make qemu_arch_available() common code
  hw/scsi/disk: Prefer target_s390x() over qemu_arch_available()
  qemu/target_info: Add target_s390x() helper
  qemu: Document qemu_arch_available() method
  target/m68k: clean-up includes in cpu.c
  target/tricore: Build 'gdbstub.c' once for system single binary
  target/s390x: Build 'gdbstub.c' once for system single binary
  target/rx: Build 'gdbstub.c' once for system single binary
  target/m68k: Build 'gdbstub.c' once for system single binary
  target/loongarch: Build 'gdbstub.c' once for system single binary
  target/avr: Build 'gdbstub.c' once for system single binary
  target/alpha: Build 'gdbstub.c' once for system single binary
  ...

Signed-off-by: Peter Maydell <[email protected]>
2026-02-26 09:33:12 +00:00
Richard Henderson c87bf20b07 page-vary: Build migration_legacy_page_bits as common code
Use target_info->page_bits_init to implement
migration_legacy_page_bits.  Because this is the last
function within the file, rename page-vary-target.c
to page-vary-system.c and build once for system mode.

Signed-off-by: Richard Henderson <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
[PMD: Update MAINTAINERS]
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-02-26 00:12:12 +01:00
Richard Henderson eb52c6d769 page-vary: Build finalize_target_page_bits as common code
Use target_info->page_bits_init to merge
finalize_target_page_bits_common into
finalize_target_page_bits in page-vary-common.c.

Signed-off-by: Richard Henderson <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-02-26 00:12:07 +01:00
Richard Henderson 79674d07d4 page-vary: Build set_preferred_target_page_bits as common code
Use target_info->page_bits_vary to merge
set_preferred_target_page_bits_common into
set_preferred_target_page_bits in page-vary-common.c.

Signed-off-by: Richard Henderson <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-02-26 00:11:30 +01:00
Richard Henderson bd2ecc733a target-info: Move TARGET_PAGE_BITS sanity check
Move the check from page-vary-target.c to target-info-stub.c,
in the process of removing page-vary-target.c entirely.

Signed-off-by: Richard Henderson <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-02-26 00:11:26 +01:00
Richard Henderson afb94ae333 target-info: Add page_bits_{init,vary}
Add two fields that will hold TARGET_PAGE_BITS,
TARGET_PAGE_BITS_VARY, TARGET_PAGE_BITS_LEGACY.

Signed-off-by: Richard Henderson <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-02-26 00:11:21 +01:00
Philippe Mathieu-Daudé 40a5b6745e page-vary: Expose TARGET_PAGE_BITS_MIN definition
We'll use TARGET_PAGE_BITS_MIN in page-vary-common.c,
so expose it via "exec/page-vary.h".

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-02-26 00:11:14 +01:00
Daniel P. Berrangé d2f198027b meson: don't access 'cxx' object without checking cpp lang
Signed-off-by: Daniel P. Berrangé <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Acked-by: Paolo Bonzini <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-02-26 00:02:14 +01:00
Philippe Mathieu-Daudé 747b494f12 system: Reduce 'arch_init.h' scope
Better to restrict qemu_arch_available() scope so it is only
used by generic system/ code to parse command line options.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Message-Id: <[email protected]>
2026-02-26 00:02:14 +01:00
Philippe Mathieu-Daudé 1bfbe1fc5a system: Make qemu_arch_available() common code
Remove the need of per-target QEMU_ARCH. Define the
QEMU_ARCH_* constants based on SYS_EMU_TARGET_* ones,
themselves already exposed via target_arch(), allowing
to check the current target is included in @arch_bitmask.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Message-Id: <[email protected]>
2026-02-26 00:02:14 +01:00
Philippe Mathieu-Daudé 1afc7da7db hw/scsi/disk: Prefer target_s390x() over qemu_arch_available()
qemu_arch_available() is used to check if a broadly available
feature should be exposed to a particular set of target
architectures. Here we only want to check something that is
specific to s390x: the target_s390x() helper is more adapted.
Besides, it will allow to reduce qemu_arch_available() scope.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Message-Id: <[email protected]>
2026-02-26 00:02:14 +01:00
Philippe Mathieu-Daudé 2dc8c9cf72 qemu/target_info: Add target_s390x() helper
Add a helper to distinct whether the binary is targetting
S390x or not.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Message-Id: <[email protected]>
2026-02-26 00:02:14 +01:00
Philippe Mathieu-Daudé 4b75d19e36 qemu: Document qemu_arch_available() method
qemu_arch_available() is used to check if a broadly available
feature should be exposed to a particular set of target
architectures.

Since its argument is a mask of bits, rename it as @arch_bitmask.

We have less than 32 target architectures so far, so restrict it
to the uint32_t type.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Message-Id: <[email protected]>
2026-02-26 00:02:14 +01:00
Alex Bennée 345179a72f target/m68k: clean-up includes in cpu.c
We don't need translation-block.h as the TB flags are local and the
only bits needed come from cpu-ops.h. The vmstate is a system only
concerns so we can guard against including it for linux-user.

Finally tidy up the order to keep things together with the local cpu.h
kept at the end.

Signed-off-by: Alex Bennée <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-02-26 00:02:14 +01:00
Philippe Mathieu-Daudé 936c783dab target/tricore: Build 'gdbstub.c' once for system single binary
There is a single qemu-system-tricore binary, but by moving
'gdbstub.c' in the target_common_system_arch[] source set
the resulting object can be linked into a single qemu-sytem
binary.

Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
2026-02-26 00:02:14 +01:00
Philippe Mathieu-Daudé cb543f4ac1 target/s390x: Build 'gdbstub.c' once for system single binary
There is a single qemu-system-s390x binary, but by moving
'gdbstub.c' in the target_common_system_arch[] source set
the resulting object can be linked into a single qemu-sytem
binary.

Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
2026-02-26 00:02:14 +01:00
Philippe Mathieu-Daudé dea007d310 target/rx: Build 'gdbstub.c' once for system single binary
There is a single qemu-system-rx binary, but by moving
'gdbstub.c' in the target_common_system_arch[] source set
the resulting object can be linked into a single qemu-sytem
binary.

Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
2026-02-26 00:02:14 +01:00
Philippe Mathieu-Daudé e9b39c7d72 target/m68k: Build 'gdbstub.c' once for system single binary
There is a single qemu-system-m68k binary, but by moving
'gdbstub.c' in the target_common_system_arch[] source set
the resulting object can be linked into a single qemu-sytem
binary.

Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
2026-02-26 00:02:14 +01:00
Philippe Mathieu-Daudé 9c6bed12f4 target/loongarch: Build 'gdbstub.c' once for system single binary
There is a single qemu-system-loongarch64 binary, but by
moving 'gdbstub.c' in the target_common_system_arch[] source
set the resulting object can be linked into a single qemu-sytem
binary.

Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
2026-02-26 00:02:14 +01:00
Philippe Mathieu-Daudé 7700b0106f target/avr: Build 'gdbstub.c' once for system single binary
There is a single qemu-system-avr binary, but by moving
'gdbstub.c' in the target_common_system_arch[] source set
the resulting object can be linked into a single qemu-sytem
binary.

Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
2026-02-26 00:02:14 +01:00
Philippe Mathieu-Daudé bbcab06e41 target/alpha: Build 'gdbstub.c' once for system single binary
There is a single qemu-system-alpha binary, but by moving
'gdbstub.c' in the target_common_system_arch[] source set
the resulting object can be linked into a single qemu-sytem
binary.

Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
2026-02-26 00:02:14 +01:00
Philippe Mathieu-Daudé ceffd13311 target/or1k: Build 'gdbstub.c' once for system single binary
There is a single qemu-system-or1k binary, but by moving
'gdbstub.c' in the target_common_system_arch[] source set
the resulting object can be linked into a single qemu-sytem
binary.

Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
2026-02-26 00:02:14 +01:00
Philippe Mathieu-Daudé eb908759ae target/or1k: Rename 'openrisc' -> 'or1k' in meson.build
Follow commit 62822fc7e0 ("target/or1k: Rename from openrisc").

Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
2026-02-26 00:02:14 +01:00
Philippe Mathieu-Daudé b7288c06fd target/sh4: Build 'gdbstub.c' once for system binaries
'gdbstub.c' can now be built once for all qemu-system-sh4*
binaries.

Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
2026-02-26 00:02:14 +01:00
Philippe Mathieu-Daudé 1c94da7a34 target/sh4: Build 'monitor.c' once for system binaries
'monitor.c' can be built once for all qemu-system-sh4* binaries.

Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
2026-02-26 00:02:14 +01:00
Philippe Mathieu-Daudé a056e7a3b8 target/microblaze: Build 'gdbstub.c' once for system binaries
'gdbstub.c' can now be built once for all qemu-system-microblaze*
binaries.

Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
2026-02-26 00:02:14 +01:00
Philippe Mathieu-Daudé 4ebb5ba551 gdbstub/helpers: Convert gdb_get_regl() macro to inlined helper
Rather than checking TARGET_LONG_BITS at build time,
check target_long_bits() at runtime.

Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
2026-02-26 00:02:14 +01:00
Philippe Mathieu-Daudé 2420b3fdfb target/sparc: Expand gdb_get_regl() in gdb_get_rega()
Convert the gdb_get_rega() macro to an inlined function,
expanding gdb_get_regl() via a TARGET_SPARC64 definition check.

Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
2026-02-26 00:02:14 +01:00
Philippe Mathieu-Daudé e1824a1042 target/sh4: Expand gdb_get_regl() -> gdb_get_reg32()
The SH4 targets are only built as 32-bit:

  $ git grep TARGET_LONG_BITS configs/targets/sh4*
  configs/targets/sh4-linux-user.mak:5:TARGET_LONG_BITS=32
  configs/targets/sh4-softmmu.mak:2:TARGET_LONG_BITS=32
  configs/targets/sh4eb-linux-user.mak:6:TARGET_LONG_BITS=32
  configs/targets/sh4eb-softmmu.mak:3:TARGET_LONG_BITS=32

Mechanically replace:

  gdb_get_regl() -> gdb_get_reg32()

Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
2026-02-26 00:02:14 +01:00
Philippe Mathieu-Daudé 14a39fc17b target/rx: Expand gdb_get_regl() -> gdb_get_reg32()
The Renesas RX target is only built as 32-bit:

  $ git grep TARGET_LONG_BITS configs/targets/rx*
  configs/targets/rx-softmmu.mak:5:TARGET_LONG_BITS=32

Mechanically replace:

  gdb_get_regl() -> gdb_get_reg32()

Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
2026-02-26 00:02:14 +01:00
Philippe Mathieu-Daudé 7831e5f48d target/hexagon: Expand gdb_get_regl() -> gdb_get_reg32()
The Hexagon target is only built as 32-bit:

  $ git grep TARGET_LONG_BITS configs/targets/hexagon*
  configs/targets/hexagon-linux-user.mak:5:TARGET_LONG_BITS=32

Mechanically replace:

  gdb_get_regl() -> gdb_get_reg32()

Reviewed-by: Brian Cain <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
2026-02-26 00:02:14 +01:00
Philippe Mathieu-Daudé 34fa8dbbf2 target/alpha: Expand gdb_get_regl() -> gdb_get_reg64()
The Alpha targets are only built as 64-bit:

  $ git grep TARGET_LONG_BITS configs/targets/alpha-*
  configs/targets/alpha-linux-user.mak:4:TARGET_LONG_BITS=64
  configs/targets/alpha-softmmu.mak:2:TARGET_LONG_BITS=64

Mechanically replace:

  gdb_get_regl() -> gdb_get_reg64()

Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
2026-02-26 00:02:14 +01:00
Philippe Mathieu-Daudé cebda82488 gdbstub: Remove ldtul*() macros
These macros aren't used anymore, remove them to avoid
further uses creeping back in.

Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
2026-02-26 00:02:14 +01:00
Philippe Mathieu-Daudé 62b7f6df56 target/i386: Expand 64-bit definitions when TARGET_LONG_BITS == 64
Where both gdb_read/write_register() functions check for
'TARGET_LONG_BITS == 64' we can expand the following definitions:

  ldtul_p() -> ldq_p()

  gdb_get_regl() -> gdb_get_reg64()

Do the same in i386_cpu_gdb_get_egprs(): check TARGET_LONG_BITS to
effectively inline gdb_get_regl().

Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
2026-02-26 00:02:14 +01:00
Philippe Mathieu-Daudé 7ca74dc98d target/i386: Replace ldtul_p() -> ldn_p()
Prefer ldn_p(target_long_bits) over target-specific ldtul_p().

Reviewed-by: Richard Henderson <[email protected]>
Reviewed-by: Zhao Liu <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Message-ID: <[email protected]>
2026-02-26 00:02:14 +01:00
Philippe Mathieu-Daudé de32a75647 target/riscv: Remove unnecessary target_ulong type uses
Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Daniel Henrique Barboza <[email protected]>
Reviewed-by: Chao Liu <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
2026-02-26 00:02:14 +01:00
Philippe Mathieu-Daudé 7170bddcd9 target/riscv: Replace ldtul_p() -> ldn_p()
Prefer ldn_p(riscv_cpu_is_32bit) over target-specific ldtul_p().

Reviewed-by: Richard Henderson <[email protected]>
Reviewed-by: Alistair Francis <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Daniel Henrique Barboza <[email protected]>
Reviewed-by: Chao Liu <[email protected]>
Message-ID: <[email protected]>
2026-02-26 00:02:14 +01:00
Philippe Mathieu-Daudé 2497a8a6e1 target/mips: Replace ldtul_p() -> ldn_p()
Prefer ldn_p(target_long_bits/8) over target-specific ldtul_p().

Use deposit64() in gdb_write_register(), allowing to remove
'target_ulong' type uses.

Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
2026-02-26 00:02:14 +01:00
Philippe Mathieu-Daudé 27385bc1ce target/ppc: Replace ldtul_p() -> ldn_p()
Prefer ldn_p(target_long_bits/8) over target-specific ldtul_p().

Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
2026-02-26 00:02:14 +01:00
Philippe Mathieu-Daudé 8ef71fe91c target/sparc: Factor sparc_cpu_gdb_write_register() out
Factor sparc_cpu_gdb_write_register() out.

Prefer ldn_p(target_long_bits/8) over target-specific ldtul_p().

Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
2026-02-26 00:02:14 +01:00
Philippe Mathieu-Daudé 6bd0ccc455 target/riscv: Remove empty target_monitor_defs() symbol
Prefer the stub target_monitor_defs() symbol introduced in commit
bf95728400 ("monitor: remove target-specific code from monitor.c").

Reviewed-by: Daniel Henrique Barboza <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Chao Liu <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
2026-02-26 00:02:14 +01:00
Philippe Mathieu-Daudé aa75a7c09b target/or1k: Use XML register definitions from GDB
Import gdb-xml/or1k-fpu.xml from mainstream binutils, tag
'binutils-2_46' [*]. Register as CPUClass::gdb_core_xml_file.

[*] https://sourceware.org/git/?p=binutils-gdb.git;a=blob_plain;f=gdb/features/or1k-core.xml;h=0d13f355f5296ae426794eb3003dcc18fbbd49d5;hb=refs/tags/binutils-2_46

Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
2026-02-26 00:02:14 +01:00
Philippe Mathieu-Daudé c91f3330cc target/ppc: Extract monitor-related code to monitor.c
Keep ppc-qmp-cmds.c for QMP, use monitor.c for HMP.

Since ppc-qmp-cmds.c was introduced using the MIT license
(see commit bf95728400 "monitor: remove target-specific
code from monitor.c") retain the same license for the new
monitor.c file.

Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
2026-02-26 00:02:14 +01:00
Philippe Mathieu-Daudé 53e6619ee0 target/ppc: Remove MonitorDef register entries available via gdbstub
All these registers are already provided by via gdbstub parsed XML
and handler by the gdb_get_register() helper in the monitor/hmp.c
file. Remove as now unreachable code.

Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
2026-02-26 00:02:14 +01:00
Philippe Mathieu-Daudé f7a46c64c8 target/m68k: Remove MonitorDef register entries available via gdbstub
All these registers are already provided by via gdbstub parsed XML
and handler by the gdb_get_register() helper in the monitor/hmp.c
file. Remove as now unreachable code.

Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
2026-02-26 00:02:14 +01:00
Philippe Mathieu-Daudé 3200552839 target/i386: Remove MonitorDef register entries available via gdbstub
All these registers are already provided by via gdbstub parsed XML
and handler by the gdb_get_register() helper in the monitor/hmp.c
file. Remove as now unreachable code.

Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
2026-02-26 00:02:14 +01:00
Philippe Mathieu-Daudé d1a4a7dfc7 target/sparc: Remove MonitorDef register entries available via gdbstub
All these registers are already provided by via gdbstub parsed XML
and handler by the gdb_get_register() helper in the monitor/hmp.c
file. Remove as now unreachable code.

Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
2026-02-26 00:02:14 +01:00
Philippe Mathieu-Daudé 42cc2028a4 monitor/hmp: Handle gdb-xml exposed registers via gdb_get_register()
Implement the gdb_get_register() helper and call it before the
regular get_monitor_def() one. Registers is exposed via the
GDB XML files will be directly handled, possibily allowing new
registers added to XML files to be automatically accessible in
QEMU monitor. All targets having GDB XML files can now be used
within the monitor.

For example with Loongarch, before:

  $ qemu-system-loongarch64 -M virt -S -monitor stdio
  QEMU 10.2.0 monitor - type 'help' for more information

  (qemu) info registers

  CPU#0
   PC=000000001c000000  FCSR0 0x00000000
   ...

  (qemu) p/x $pc
  unknown register
  Try "help p" for more information
  (qemu)

and after:

  $ ./qemu-system-loongarch64 -M virt -S -monitor stdio
  QEMU 10.2.50 monitor - type 'help' for more information
  (qemu) p/x $pc
  0x1c000000
  (qemu)

Similarly RISC-V:

  QEMU 10.2.0 monitor - type 'help' for more information
  (qemu) p/x $pc
  unknown register
  Try "help p" for more information

VS

  QEMU 10.2.50 monitor - type 'help' for more information
  (qemu) p/x $pc
  0x1000
  (qemu)

Reviewed-by: Dr. David Alan Gilbert <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
2026-02-26 00:02:14 +01:00
Philippe Mathieu-Daudé fe1958cdb6 target/sparc: Expose gdbstub registers to sparc32 targets
Import gdb-xml/sparc32-{cpu,fpu,cp0}.xml from mainstream binutils,
tag 'binutils-2_46', found in the gdb/features/sparc/folder [*].

Register them by setting the CPUClass::gdb_core_xml_file field and
calling gdb_register_coprocessor() in sparc_cpu_register_gdb_regs().

[*] https://sourceware.org/git/?p=binutils-gdb.git;a=tree;f=gdb/features/sparc;hb=refs/tags/binutils-2_46

Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
2026-02-26 00:02:14 +01:00
Philippe Mathieu-Daudé 0f0f47d8b8 target/sparc: Expose gdbstub registers to sparc32plus target
Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
2026-02-26 00:02:14 +01:00
Philippe Mathieu-Daudé 00c82c36b0 target/sparc: Restore 'gdb-xml/sparc64-cpu.xml'
Restore gdb-xml/sparc64-cpu.xml from mainstream binutils, tag
'binutils-2_46', found in the gdb/features/sparc/folder [*].

[*] https://sourceware.org/git/?p=binutils-gdb.git;a=tree;f=gdb/features/sparc;hb=refs/tags/binutils-2_46

Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
2026-02-26 00:02:14 +01:00
Philippe Mathieu-Daudé 85b4bcf3d5 target/sparc: Restore 'gdb-xml/sparc64-fpu.xml'
Restore gdb-xml/sparc64-fpu.xml from mainstream binutils, tag
'binutils-2_46', found in the gdb/features/sparc/folder [*].

Extract sparc_fpu_gdb_write_register() out of
sparc_cpu_gdb_read_register() and sparc_fpu_gdb_write_register()
out of sparc_cpu_gdb_write_register(), taking care to update the
register indexes in the switch cases.

Register these helpers with a call to gdb_register_coprocessor()
in sparc_cpu_register_gdb_regs().

[*] https://sourceware.org/git/?p=binutils-gdb.git;a=tree;f=gdb/features/sparc;hb=refs/tags/binutils-2_46

Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
2026-02-26 00:02:14 +01:00
Philippe Mathieu-Daudé 891601f2e4 target/sparc: Restore 'gdb-xml/sparc64-cp0.xml'
Restore gdb-xml/sparc64-cp0.xml from mainstream binutils, tag
'binutils-2_46', found in the gdb/features/sparc/folder [*].

Extract sparc_cp0_gdb_write_register() out of
sparc_cpu_gdb_read_register() and sparc_cp0_gdb_write_register()
out of sparc_cpu_gdb_write_register(), taking care to update the
register indexes in the switch cases.

Register these helpers with a call to gdb_register_coprocessor()
in sparc_cpu_register_gdb_regs().

[*] https://sourceware.org/git/?p=binutils-gdb.git;a=tree;f=gdb/features/sparc;hb=refs/tags/binutils-2_46

Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
2026-02-26 00:02:14 +01:00
Philippe Mathieu-Daudé 733c41f0aa target/sparc: Introduce sparc_cpu_register_gdb_regs() stub
Introduce sparc_cpu_register_gdb_regs() which we are going
to fill in the next commits.

Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
2026-02-25 23:46:04 +01:00
Philippe Mathieu-Daudé 7ddd3aca5f gdbstub: Always infer gdb_num_core_regs when using XML file
Rather correct inferred count over invalid manual one.

Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
2026-02-25 23:46:04 +01:00
Philippe Mathieu-Daudé 744bafc3f2 gdbstub: Make generated compound literal array size explicit
GDBFeature::num_regs holds the number of registers, but when using
the compound literal construction, if the last array entry is not
set, the array will be shorter. Prevent array overrun by making the
array length explicit,

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Message-Id: <[email protected]>
2026-02-25 23:46:04 +01:00
Philippe Mathieu-Daudé 429471c801 target/ppc: Remove dead code depending on USE_APPLE_GDB
We never defined USE_APPLE_GDB, so the code introduced in commit
b3cad3abf6 ("PPC: Add support for Apple gdb in gdbstub") is dead
since almost 12 years. Remove it.

Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
2026-02-25 23:46:04 +01:00
Philippe Mathieu-Daudé 1ec0fbe2dd target/ppc: Fix CPUClass::gdb_num_core_regs value
Only 70 registers are exposed from GDB XML file (for either
32 / 64-bit variants).

Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
2026-02-25 23:46:04 +01:00
Philippe Mathieu-Daudé c60750fe5e target/riscv: Extract monitor-related code to monitor.c
Keep riscv-qmp-cmds.c for QMP, use monitor.c for HMP.

Reviewed-by: Daniel Henrique Barboza <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
2026-02-25 23:46:04 +01:00
Philippe Mathieu-Daudé e4eff9dfaa target/alpha: Document gdbstub register indexes
Follow GDB XML comments. Re-order switch cases for clarity.

Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
2026-02-25 23:46:04 +01:00
Philippe Mathieu-Daudé bc1da6990f target/avr: Fix typo in gdb-xml feature name
While GDB doesn't provide an official XML for the gdbstub
protocol, it is still better to name it 'avr' instead of 'riscv'.

Fixes: 12b3540547 ("target/avr: CPU class: Add GDB support")
Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
2026-02-25 23:46:04 +01:00
Philippe Mathieu-Daudé e015ae3074 target/i386: Inline GDB_FORCE_64 definition
Directly checking TARGET_LONG_BITS allows to remove GDB_FORCE_64.

Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
2026-02-25 23:46:04 +01:00
Philippe Mathieu-Daudé 197c6071df target/ppc: Remove PPC_DEBUG_SPR left-over comment
The PPC_DEBUG_SPR definition was fully removed in commit
6113563982 ("target/ppc: Clean up _spr_register et al").

Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
2026-02-25 23:46:04 +01:00
Philippe Mathieu-Daudé 69fe6185ff target/ppc: Move user_only_helper.c to target_user_arch[] source set
Since commit 46369b50ee ("meson: Introduce meson_user_arch
source set for arch-specific user-mode") using target_user_arch[] is
preferred because clearer, and no need to filter on CONFIG_USER_ONLY.

Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
2026-02-25 23:46:04 +01:00
Anton Johansson cf884c075e exec: Drop TARGET_PHYS_ADDR_SPACE_BITS
The macro is no longer in use and can safely be dropped.

Reviewed-by: Richard Henderson <[email protected]>
Reviewed-by: Brian Cain <[email protected]>
Signed-off-by: Anton Johansson <[email protected]>
Message-ID: <[email protected]>
[PMD: Keep TARGET_PHYS_ADDR_SPACE_BITS poisoned]
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-02-25 23:46:04 +01:00
Anton Johansson 3a3cfcb29f hw/riscv: Set IOMMU PAS via property
Replaces the only remaining use of TARGET_PHYS_ADDR_SPACE_BITS for RISCV
with a property RISCVIOMMUState::pas_bits that gets written to the
capabilities field upon device realization.  This write needs to happen
at realize-time to ensure the property has been set.

For the virt machine and sysbus device, pas_bits is set by
virt_machine_init() to either 34 or 56 bits, retaining previous behaviour.
However, for the PCI device we do not have access to the CPU state, and
instead use the maximum riscv64 value of 56 bits.

Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Anton Johansson <[email protected]>
Reviewed-by: Chao Liu <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-02-25 23:46:04 +01:00
Anton Johansson 16d73d390c hw/loongarch: Use loongarch_palen_mask()
Replaces remaining uses of TARGET_PHYS_ADDR_SPACE_BITS with
runtime calls to loongarch_palen_mask() to fetch the physical
address mask from the cpucfg PALEN field.

Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Anton Johansson <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-02-25 23:46:04 +01:00
Anton Johansson 56599a705f target/loongarch: Introduce loongarch_palen_mask()
In preparation for dropping TARGET_PHYS_ADDR_SPACE_BITS, define a
runtime function to construct a mask from the PALEN cpucfg field.
The mask is then used when converting from virtual to physical
addresses.

Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Anton Johansson <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-02-25 23:46:04 +01:00
Anton Johansson ab7a864082 target/i386: Drop physical address range checks
Since TARGET_PHYS_ADDR_SPACE_BITS is now fixed to 64 bits for all
targets we can remove range checks on cpu->phys_bits and
TCG_PHYS_ADDR_BITS.

Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Anton Johansson <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-02-25 23:46:04 +01:00
Anton Johansson a92503e6e5 hw/hppa: Use hppa_abs_to_phys_pa1x()
Makes the physical address space conversion for 32 bit machines more
explicit, using the translation function defined in mem_helper.c.

Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Anton Johansson <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-02-25 23:46:04 +01:00
Anton Johansson 2b581da051 target/hppa: Define PA[20|1X] physical address space size
When converting virtual to physical addresses,
TARGET_PHYS_ADDR_SPACE_BITS is used under PA-RISC 2.0, and an explicit
cast to uint32_t is used under PA-RISC 1.X.  Replace the former with a
more specific macro limited to mem_helper.c, and make the latter
conversion explicit by defining the size of the physical address space
for PA-RISC 1.X.

Note: while 44 bits should be used for the 64-bit address space running
a C3700, 40 bits is still chosen as this is expected by the SeaBIOS
functional test.

Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Anton Johansson <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-02-25 23:46:04 +01:00
Peter Maydell 6593154e7d Merge tag 'python-pull-request' of https://gitlab.com/jsnow/qemu into staging
# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCgAdFiEE+ber27ys35W+dsvQfe+BBqr8OQ4FAmmd6oAACgkQfe+BBqr8
# OQ7iwhAAt7MYV/FV0HpzoMD8aKlft4EFjy3qU3zwRr33P8oH61nJfx1JX8wlZeph
# /lf8VX83phb/GjmqxzC4OFz+6yX2hERKAF0x5+BNAHt7upQhCitpbFD1HuE5kPcU
# TcUZKXd5s4w4iJq9unNtzNzT46eP/Kvloiff5piEfJTtqWDvsSNZl/bHEvKn7hpc
# eZ1x0PJ8QfZcXAKN6YKL5a91zkJwalmfw2OC6BI+YwZz3dzeci0hxScOGPk4qa0v
# VP21Z4su5EJhaKdQaJL3XNoJuEElbHkDRsPe3hBFKz/MhItOMLC0rhWvXlqTXi6n
# /maigfDMDoMXNfQo3S5KCDqOdCMIm6CoOHsXZZDF0Hdb7BfwB3bpUZ0K6WMxkcky
# CcIZkNfGMoZczQ9YHSuNQLLyGQYcUVgbNGyWahs9F6Ax7ojmackM5YDffcINjqs9
# lmdIWiizfqMFifdDosS4d1hjfAH7mdSL6bufuz4xSijKm2AbZLo/VTXOVlietLRj
# EI0GlAWXj+4UTQwuOOkf05+MgRRKn3pRm0hfxiJWlCkQ/I5xRRg9R3Jn3dlU0FCD
# U1tKQnNDDRFNYBKNsqi2LN0u1K3Bf/+Ghl+XFU9BSbBiXn/6MAA8qdbAykcsXXrX
# UmAG4u9r4F/SbQhmYONDzM8etjhiqaHKlynUNZxgeF7+vexoMkk=
# =ORRP
# -----END PGP SIGNATURE-----
# gpg: Signature made Tue Feb 24 18:14:24 2026 GMT
# gpg:                using RSA key F9B7ABDBBCACDF95BE76CBD07DEF8106AAFC390E
# gpg: Good signature from "John Snow (John Huston) <[email protected]>" [full]
# Primary key fingerprint: FAEB 9711 A12C F475 812F  18F2 88A9 064D 1835 61EB
#      Subkey fingerprint: F9B7 ABDB BCAC DF95 BE76  CBD0 7DEF 8106 AAFC 390E

* tag 'python-pull-request' of https://gitlab.com/jsnow/qemu:
  python: add setuptools and wheel dependencies
  python: update README.rst to reflect qemu.qmp's removal
  python: delete qemu.qmp
  scripts: nudge users to use 'run' script for scripts that import qemu.qmp
  tests: replace check-venv with vm-venv target
  configure: unconditionally install "tooling" group
  meson, mkvenv: add qemu.git/python/qemu package to pythondeps.toml
  meson, mkvenv: make functional tests depend on functests group
  python: add vendored qemu.qmp package
  tests/lcitool: add python3 wheel and setuptools deps for qemu
  tests/lcitool: update lcitool to latest version
  tests: use "run" script to execute device-crash-test
  iotests: tolerate being run outside of pyvenv
  tests: Use configured python to run GitLab iotests
  meson, mkvenv: add functests custom target
  python/mkvenv: add mechanism to install local package(s)
  python/mkvenv: add 'tooling' and 'functests' dependency groups
  python/mkvenv: bump 'qemu.qmp' dependency for testdeps
  python/mkvenv: create timestamp file for each group "ensured"

Signed-off-by: Peter Maydell <[email protected]>
2026-02-24 18:41:04 +00:00
John Snow 4e55bb4be5 python: add setuptools and wheel dependencies
Add setuptools and wheel packages to ease installation burden when
internet access is allowed. When internet access is not allowed, this
functions as a configure-time check ensuring that our environment has
the necessary minimum viable versions for these packaging tools
available.

For detailed information on Python ecosystem versions, please see
https://gitlab.com/jsnow/repology-dashboard#results-overview-as-of-2026-02-16

Suggested-by: Paolo Bonzini <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: John Snow <[email protected]>
2026-02-24 13:11:29 -05:00
John Snow c676f6cd78 python: update README.rst to reflect qemu.qmp's removal
It is no longer simply possible to just use this directory as if it were
an installed package now that it has dependencies, so update the README
to reflect this.

Reviewed-by: Thomas Huth <[email protected]>
Reviewed-by: Daniel P. Berrangé <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: John Snow <[email protected]>
2026-02-24 13:11:29 -05:00
John Snow e1e49b35b3 python: delete qemu.qmp
Start relying on the external python-qemu-qmp dependency instead, to
prevent desync between the internal and external libraries.

This library is now entirely independent; to contribute changes, see
https://gitlab.com/qemu-project/python-qemu-qmp/

Reviewed-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: John Snow <[email protected]>
2026-02-24 13:11:29 -05:00
John Snow b08e111b1e scripts: nudge users to use 'run' script for scripts that import qemu.qmp
Now that qmp has to be installed and isn't local, we can no longer offer
a simple forwarder for these scripts (nor path hacks) and hope that it
works. Encourage users to use the 'run' script to use these scripts
instead.

Reviewed-by: Daniel P. Berrangé <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: John Snow <[email protected]>
2026-02-24 13:11:29 -05:00
John Snow 5abfe61b40 tests: replace check-venv with vm-venv target
With the qemu.qmp and qemu.machine dependencies now installed by default
at configure time and additional dependencies required by functional
testing installed on demand, we do not need the explicit "check-venv" target.

...However, to facilitate running VM tests without running configure, we
move some of the former logic into tests/vm/Makefile.include to create a
new venv (vm-venv) on-demand when running VM tests from the source tree.

Reviewed-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: John Snow <[email protected]>
2026-02-24 13:11:29 -05:00
John Snow bb1f3a9594 configure: unconditionally install "tooling" group
Alongside meson, always ensure our in-tree tooling group and its
out-of-tree dependency, qemu.qmp, is always installed.

As a result, several "check-venv" invocations can be removed from
various testing scripts.

Reviewed-by: Thomas Huth <[email protected]>
Reviewed-by: Daniel P. Berrangé <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: John Snow <[email protected]>
2026-02-24 13:11:29 -05:00
John Snow 9e01686b28 meson, mkvenv: add qemu.git/python/qemu package to pythondeps.toml
Add the local python package group into pythondeps.toml for the tooling
group. This makes qemu.qmp, qemu.machine and qemu.utils packages
unconditionally available for tests and scripts.

Reviewed-by: Thomas Huth <[email protected]>
Reviewed-by: Daniel P. Berrangé <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: John Snow <[email protected]>
2026-02-24 13:11:29 -05:00
John Snow b5a21249cb meson, mkvenv: make functional tests depend on functests group
Note that only the thorough group requires the extra testing
dependencies; the quick group will run with just the "tooling" group,
which we intend to install by default at configure time in a forthcoming
commit.

Reviewed-by: Thomas Huth <[email protected]>
Reviewed-by: Daniel P. Berrangé <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: John Snow <[email protected]>
2026-02-24 13:11:29 -05:00
John Snow 93bf95964c python: add vendored qemu.qmp package
In anticipation of deleting the python/qemu/qmp source from the tree,
add a vendored version of the qemu.qmp package to ensure that "make
check" can be run in isolated build environments, offline.

Acked-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: John Snow <[email protected]>
2026-02-24 13:11:11 -05:00
Peter Maydell 82e9e30f43 Merge tag 'pull-fpu-20260224' of https://gitlab.com/rth7680/qemu into staging
- Reformat NaN classification to share code
- Fix pseudo-NaN handling in FPATAN/FYL2XP1/FYL2X helpers
- Add conversion routines for OCP FP8 and FP4 formats

# -----BEGIN PGP SIGNATURE-----
#
# iQFRBAABCgA7FiEEekgeeIaLTbaoWgXAZN846K9+IV8FAmmdOnYdHHJpY2hhcmQu
# aGVuZGVyc29uQGxpbmFyby5vcmcACgkQZN846K9+IV9RJwgAj4rs0Pj9rOMnrmGN
# 5EPq2p+Wvjeup59W8WeBJGUS6J8rC05i5fBtcThoRNEGf+w/+8ef8ZlERyv07FIJ
# O7RcLDeXWYotH7GMM/1EEi5FHJ4qmYkKjwX3ys6vxblYGa1gPtwUVyrySExqzWqe
# T59+ljzYGHka7hXEXx/0yL+ypJv3lidpdPk/a0Ylqi37zwLEuv/FycdlCNSnxNTj
# bR+GleqcxigkP7G1Mks5V9MpWWGd2tWloO1EwDieng6bMGom0c+4xNyZ5HCqt+Au
# cuGEZRgrfGcA6QpHKs9srVAwDkj4QWSky8ffjPSNbGvNLoGA+7gWE6VFmqlb0yib
# vd+Tqw==
# =Wpw9
# -----END PGP SIGNATURE-----
# gpg: Signature made Tue Feb 24 05:43:18 2026 GMT
# gpg:                using RSA key 7A481E78868B4DB6A85A05C064DF38E8AF7E215F
# gpg:                issuer "[email protected]"
# gpg: Good signature from "Richard Henderson <[email protected]>" [full]
# Primary key fingerprint: 7A48 1E78 868B 4DB6 A85A  05C0 64DF 38E8 AF7E 215F

* tag 'pull-fpu-20260224' of https://gitlab.com/rth7680/qemu:
  fpu: Add conversion routines for OCP FP4 E2M1
  fpu: Add conversion routines for OCP FP8 E4M3
  fpu: Add conversion routines for OCP FP8 E5M2
  fpu: Add saturate parameter to parts_uncanon
  fpu: Add overflow_raises_invalid to FloatFmt
  fpu: Introduce FloatFmtExpMaxKind
  target/i386: Fix pseudo-NaN handling in FPATAN/FYL2XP1/FYL2X helpers
  fpu/softfloat: Refactor floatx80 format NaN classification to share code
  fpu/softfloat: Refactor IEEE format NaN classification to share code

Signed-off-by: Peter Maydell <[email protected]>
2026-02-24 11:33:01 +00:00
Peter Maydell ba061eb352 Merge tag 'pr-plugins-20260223' of https://gitlab.com/pbo-linaro/qemu into staging
Changes:
- [PATCH] contrib/plugins/uftrace_symbols.py: filter out some addr2line (Pierrick Bouvier <[email protected]>)
  Link: https://lore.kernel.org/qemu-devel/[email protected]

# -----BEGIN PGP SIGNATURE-----
#
# iQGzBAABCgAdFiEEZrmU7KFPfy5auggff5BUDQoc0A8FAmmc//EACgkQf5BUDQoc
# 0A9SqAv/SXvI9t8NQAauRATFlcz7GQRAyrFdCMztNSPnP62w+J/PXD5NbAQX72Mo
# 3YBTjhU8nFXXUJGHoQMkH00Cp3/YyTaZut75jGctMn4FtrBAxn1ZVgMRdOQP7SzH
# foPDj/nhw/QccfyKhVKFDX45E7q5osg3whXmBAbdaA0ZJRXAFpT3/wAICPnfNrxW
# 7REApWH74KboB1D58Nz79DiiKaFMjHYi4tyDh8EmrMzW73i4y0IdTNyzWKjLWJc/
# R6VJlKQr051YVzJw3rVXgfHJdyFjeALxS/s5UAa4tX/P9pHISDfpvVuK+ePVTKW1
# i/U4ZQlf57QaWvzzbAst72WXaWgUrWfMox5svb95XxhX4VCrTWo0//0/IpG1tl3u
# wFNckTCV9iu089KDX3pm9aX+TXbgSnwzxPut9/Ea3mBifODaAo+9NszaoDR2ZTv4
# 0be4+l9jSaQL7VmpZFoMbUx5uaP7Z6pX1yuiTOzwgv7WsQuY0d18Wod2pyctEXtR
# BIe6szz6
# =+SgD
# -----END PGP SIGNATURE-----
# gpg: Signature made Tue Feb 24 01:33:37 2026 GMT
# gpg:                using RSA key 66B994ECA14F7F2E5ABA081F7F90540D0A1CD00F
# gpg: Good signature from "Pierrick Bouvier <[email protected]>" [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: 66B9 94EC A14F 7F2E 5ABA  081F 7F90 540D 0A1C D00F

* tag 'pr-plugins-20260223' of https://gitlab.com/pbo-linaro/qemu:
  contrib/plugins/uftrace_symbols.py: filter out some addr2line error messages

Signed-off-by: Peter Maydell <[email protected]>
2026-02-24 11:32:49 +00:00
Peter Maydell 2f9c4ba196 Merge tag 'block-pull-request' of https://gitlab.com/stefanha/qemu into staging
Pull request

Jens Axboe's fixes for fdmon-io_uring.

# -----BEGIN PGP SIGNATURE-----
#
# iQEzBAABCgAdFiEEhpWov9P5fNqsNXdanKSrs4Grc8gFAmmcYhEACgkQnKSrs4Gr
# c8i4BAgAgI7UlEbQs0iLV0N4qUJ7pc8p/bgRNP9/TkjFYtFIcmRZtNeRvlkIVdgD
# F2QAMJAP0KzP3T2mo3a9f5kcvKIqLFsOpwKmMiUa98aA4dDhkT6TNOqLjgKmaXmR
# muEv7TKjBPzZqNBWDyEMIcnIzxSGjnbATN1BdvEy+7awJJDqaYZEkxTT6u+Vv/2l
# MlaYwnNbfye7nFM/xCBt/wH07XLZMC3pezHQxJGq7CGGTG0JFFeXIhm0HrTjlAt/
# EBVf41zsAtYqBj9egl5Y570NXkTirBbY+Niv/rqtavknC/tAxN+PQTBoobHm2Wna
# yU7+L+lidtIcdwhbzeZar0KdoDhsEQ==
# =zdFX
# -----END PGP SIGNATURE-----
# gpg: Signature made Mon Feb 23 14:20:01 2026 GMT
# gpg:                using RSA key 8695A8BFD3F97CDAAC35775A9CA4ABB381AB73C8
# gpg: Good signature from "Stefan Hajnoczi <[email protected]>" [full]
# gpg:                 aka "Stefan Hajnoczi <[email protected]>" [full]
# Primary key fingerprint: 8695 A8BF D3F9 7CDA AC35  775A 9CA4 ABB3 81AB 73C8

* tag 'block-pull-request' of https://gitlab.com/stefanha/qemu:
  fdmon-io_uring: check CQ ring directly in gsource_check
  aio-posix: notify main loop when SQEs are queued

Signed-off-by: Peter Maydell <[email protected]>
2026-02-24 11:32:35 +00:00
Max Chou b5fee33bbf fpu: Add conversion routines for OCP FP4 E2M1
Reviewed-by: Chao Liu <[email protected]>
Signed-off-by: Max Chou <[email protected]>
[rth: Update for exp_max_kind]
Signed-off-by: Richard Henderson <[email protected]>
2026-02-24 16:21:18 +11:00
Max Chou 27e989f99c fpu: Add conversion routines for OCP FP8 E4M3
Reviewed-by: Chao Liu <[email protected]>
Signed-off-by: Max Chou <[email protected]>
[rth: Split out of a larger patch; adjust overflow detection.]
Signed-off-by: Richard Henderson <[email protected]>
2026-02-24 16:21:15 +11:00
Max Chou d8be495376 fpu: Add conversion routines for OCP FP8 E5M2
Reviewed-by: Chao Liu <[email protected]>
Signed-off-by: Max Chou <[email protected]>
[rth: Split out of a larger patch]
Signed-off-by: Richard Henderson <[email protected]>
2026-02-24 16:21:06 +11:00
Max Chou 0182fcd813 fpu: Add saturate parameter to parts_uncanon
The OCP FP8 conversion operations have a parameter to control
saturate vs overflow.  Add a parameter, currently always false.

Reviewed-by: Chao Liu <[email protected]>
Signed-off-by: Max Chou <[email protected]>
[rth: Split out of a larger patch]
Signed-off-by: Richard Henderson <[email protected]>
2026-02-24 16:20:34 +11:00
Max Chou 2c2e54428b fpu: Add overflow_raises_invalid to FloatFmt
ARM Alt HP raises different exceptions on overflow than is
standard for IEEE when saturating a value.  Add a flag to
control this effect.

Reviewed-by: Chao Liu <[email protected]>
Signed-off-by: Max Chou <[email protected]>
[rth: Split out of a larger patch]
Signed-off-by: Richard Henderson <[email protected]>
2026-02-24 16:20:28 +11:00
Richard Henderson a4aa765c9e fpu: Introduce FloatFmtExpMaxKind
Generalize arm_althp to indicate how exp==max should
be handled for the format.  Reorganize canonicalize
and uncanon_normal to use a switch statement, allowing
more cases to be added trivially.

Reviewed-by: Chao Liu <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
2026-02-24 16:19:57 +11:00
Max Chou cf10af6c70 target/i386: Fix pseudo-NaN handling in FPATAN/FYL2XP1/FYL2X helpers
According to Intel's x87 FPU specification (Table 8-10, Vol. 1), arithmetic
operations on operands in unsupported formats (including pseudo-NaNs) must
return the QNaN floating-point indefinite value.

The helper functions for FPATAN, FYL2XP1, and FYL2X incorrectly check for
signaling NaN before checking for invalid encodings. This causes pseudo-NaNs
to be treated as valid signaling NaNs and silenced, rather than being
rejected as unsupported formats.

Reorder the checks to test floatx80_invalid_encoding before
floatx80_is_signaling_nan, matching the correct behavior already
implemented in helper_fscale.

Signed-off-by: Max Chou <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Reviewed-by: Chao Liu <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-02-24 16:19:57 +11:00
Max Chou dddee8e1ba fpu/softfloat: Refactor floatx80 format NaN classification to share code
The floatx80_is_[quiet|signaling]_nan functions contain duplicated
logic that should be shared.
This commit introduces floatx80_nan_is_snan helper function that
determine if a NaN is signaling and change the return type of
floatx80_is_[signaling|quiet]_nan to bool.

Suggested-by: Richard Henderson <[email protected]>
Signed-off-by: Max Chou <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Reviewed-by: Chao Liu <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-02-24 16:19:57 +11:00
Max Chou 5146b68791 fpu/softfloat: Refactor IEEE format NaN classification to share code
The floatN_is_[quiet|signaling]_nan functions for following formats
(float16, bfloat16, float32, float64, float128) contain duplicated
logic that should be shared.
This commit introduces
[float16|bfloat16|float32|float64|float128]_nan_is_snan that determine
if a NaN is signaling.

Suggested-by: Richard Henderson <[email protected]>
Signed-off-by: Max Chou <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Reviewed-by: Chao Liu <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-02-24 16:19:57 +11:00
Pierrick Bouvier bd3d912b77 contrib/plugins/uftrace_symbols.py: filter out some addr2line error messages
This was found when tracing Hafnium and SLOF binaries, and it's probably
related to a bug in toolchain used. It's safe to ignore those entries,
and related symbols will still be present in output, whether they can be
found or not.

Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Pierrick Bouvier <[email protected]>
2026-02-23 17:32:40 -08:00
John Snow 047fa5b4d7 tests/lcitool: add python3 wheel and setuptools deps for qemu
Installing local dependencies while offline, without PyPI access,
requires the python3-setuptools and python3-wheel packages. Most
distributions have these available anyway for one reason or another, but
not all of them.

If you are asking yourself "Wait, aren't these packages guaranteed via
installation of pip, via the ensurepip module, which mkvenv takes
immense pains to provide for us?" - Well... since Python 3.13, "pip"
does not actually come with "setuptools" or "wheel" anymore, and so if
we want to build and install a python package, we actually need these
available in the host environment.

(Note that you don't need these packages just to install a pre-built
package, you only need them to *build* a package. With cutting edge
setuptools and pip, all locally installed packages, even in editable
mode, must be "built" first before being installed. Thus, these
dependencies are being added specifically to facilitate installing
qemu.git/python/qemu to the configure-time venv.)

Reviewed-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: John Snow <[email protected]>
2026-02-23 13:24:42 -05:00
John Snow 4510ff3a43 tests/lcitool: update lcitool to latest version
Update to latest lcitool master and refresh tests. Fedora is upgraded to
Fedora 43 and Alpine from 3.21 to 3.23 as a result.

This is being done in this series primarily to ensure that MacOS
installs python-setuptools, which is now separate from the core python
package, and which is needed for this series to work correctly.

Reviewed-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: John Snow <[email protected]>
2026-02-23 13:24:42 -05:00
John Snow 1150b6e4bf tests: use "run" script to execute device-crash-test
Instead of invoking python from the configure venv manually, instruct
developers to use the "run" script instead. Change the test invocation
to be a good example going forward.

Reviewed-by: Daniel P. Berrangé <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: John Snow <[email protected]>
2026-02-23 13:24:42 -05:00
John Snow 0e0bf74cdd iotests: tolerate being run outside of pyvenv
Modify the iotests environment preparation so that it can detect when it
is being run outside of the configure-time virtual environment and give
a warning to the user, suggesting the use of the meson run script
instead.

As a bonus, since the test executor itself does not actually rely on
anything in the configure-time venv in and of itself, it is possible to
just modify the python executable it uses for launching tests to be the
correct, configured venv that has access to qemu.qmp and other test
dependencies.

Reviewed-by: Thomas Huth <[email protected]>
Tested-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: John Snow <[email protected]>
2026-02-23 13:24:42 -05:00
John Snow ed2aad659a tests: Use configured python to run GitLab iotests
use the configured python (and the pyvenv) to run iotests instead of the
system default python3 interpreter. Use the new "run" script in the
build directory to execute the command inside the meson developer
environment, templated in qemu.git/run.in.

Reviewed-by: Daniel P. Berrangé <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: John Snow <[email protected]>
2026-02-23 13:24:42 -05:00
John Snow 1aa22ffee2 meson, mkvenv: add functests custom target
add the "pyvenv_functests_group" target to meson. This target will
invoke mkvenv.py to install the associated dependency group to the
build/pyvenv directory.

A "pyvenv_tooling_group" is not included here as it is the plan to
always install this group by default, so it will not need an on-demand
trigger.

Reviewed-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: John Snow <[email protected]>
2026-02-23 13:24:42 -05:00
John Snow b42ad8ef32 python/mkvenv: add mechanism to install local package(s)
Currently, we "implicitly" install the local 'qemu' python package for
'make check-venv' with some logic inside tests/Makefile.include. I would
like to make this installation explicit in pythondeps.toml instead.

This patch adds a path constraint that can be used in lieu of version
constraints to specify that a package should be installed from the
source tree instead of from PyPI or vendored packages. This is done to
allow us to install the python packages hosted inside of the tree while
also processing dependencies; i.e. so that our "qemu" package can
specify that it needs "qemu.qmp", which soon will not be included in
qemu.git.

This also has the benefit of being able to specify in a declarative
configuration file that our pyvenv environment *will* have our local
python packages installed and available without any PYTHONPATH hacks,
which should simplify iotests, device-crash-test and functional tests
without needing to manage local inclusion paths in environment
variables.

On the downsides, installing packages through mkvenv/ensuregroup means
that there are extra steps we need to take in order to install a local
package *offline*; namely we must disable build isolation (so we have
access to setuptools) and we must also include python3-wheel in QEMU's
build dependencies in order for "make check" to run successfully when in
an offline, isolated environment. These extra dependencies are handled
in a forthcoming commit; for now, nothing is utilizing this new pathway.

Reviewed-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: John Snow <[email protected]>
2026-02-23 13:24:42 -05:00
John Snow 5b798e6da6 python/mkvenv: add 'tooling' and 'functests' dependency groups
'tooling' contains depedencies required to run various tools (like
qmp-shell) as well as dependencies required to run "make check", and as
such, we promise that these dependencies can be sourced from the user's
distribution repository or from vendored packages so that "make check"
can be executed offline in an isolated build environment.

In contrast, pygdbmi is only needed for functional tests and not tests
in general; we do not make the same offline/isolated guarantees for
functional tests, and this dependency group is allowed to fetch
dependencies from PyPI at runtime.

For the time being, amend the "check-venv" target to install both
dependency groups, to avoid a duplicate dependency between them. By the
end of this series, however, "check-venv" will be eliminated in favor of
always installing "tooling" at configure time and allowing "functests"
to be installed on-demand as needed by meson/ninja.

Reviewed-by: Vladimir Sementsov-Ogievskiy <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Reviewed-by: Daniel P. Berrangé <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: John Snow <[email protected]>
2026-02-23 13:24:42 -05:00
John Snow 0d9d92d879 python/mkvenv: bump 'qemu.qmp' dependency for testdeps
First up, use the newest v0.0.5 instead of the older v0.0.3.

Secondly, the use of a period in the key name does not behave as
expected when installing and checking for dependencies, so quote this
string instead.

Reviewed-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: John Snow <[email protected]>
2026-02-23 13:24:42 -05:00
John Snow 6aadbb7e54 python/mkvenv: create timestamp file for each group "ensured"
Each group ensured by the mkvenv script will create an empty timestamp
file named {groupname}.group which can be used to conditionally trigger
dependency installation from various scripts and build machinery.

Reviewed-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: John Snow <[email protected]>
2026-02-23 13:24:42 -05:00
Peter Maydell afe653676d Merge tag 'audio-pull-request' of https://gitlab.com/marcandre.lureau/qemu into staging
audio cleanups

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCgAdFiEEh6m9kz+HxgbSdvYt2ujhCXWWnOUFAmmcWLAACgkQ2ujhCXWW
# nOUeIRAAlNCHKCBTTH+LmclTBfwI6UhkH7nsMdzQChnRpFqwUrB9HW9GXscXManq
# ZPzZ8A+atwH361CHNLcAkK4BR7JhXh4lhyDxUL9O4ZS8LCeatFkMefnU5NS0hhXg
# /CpUpni7mtXW9mJ2lzk3rrn/iI6akyATFvKpOEXqRAIZGFqDieWpxSO08hWkkRJl
# Csd6PZjk8Jo+k3C4V4M2MJGA6Y2GHiYanX5glJTvUSUkawZXjgZ9wul0gKvH3MLS
# Twk5/nGo7ghpSxvs6NRlqSfTfydMZaM6ps4erIGZk5tU6AofIv+6oiquL6JTd6ra
# rrQM6/+iesUx1Av/yBDmFNY4A6HajLDnOYb6NnCF1bH/9ddDBDJX+V55ntfChvQf
# ylw9L1LwboB29uyWokOGUegnMSozSblJ8GSgGs4CH5dLyoCHVFESf4UrZCH0M++Q
# vysJ+zKKzK3tP+x5IXY45IAbgJvuCJirgHwKnaNWVEiEUdCHuGA4MmnH2nVfjjDu
# ZtwTVuijjVtIxRFVBtUtBc/sFt9R3OI1LzPhH8Cj+qZzeegnO0YQExeKnTitBMTp
# pOS9R5NWykSTTAQHS1LPm+tPDp1KXf81hcCLX34Ve3rLjWpKRg/B/ZpUFqGF5beW
# 6uO6g7O1JH5/34eaYPOBf8H/Gz031lvbz1yWwDw7ekR2B9H2BV8=
# =lGb0
# -----END PGP SIGNATURE-----
# gpg: Signature made Mon Feb 23 13:40:00 2026 GMT
# gpg:                using RSA key 87A9BD933F87C606D276F62DDAE8E10975969CE5
# gpg: Good signature from "Marc-André Lureau <[email protected]>" [full]
# gpg:                 aka "Marc-André Lureau <[email protected]>" [full]
# Primary key fingerprint: 87A9 BD93 3F87 C606 D276  F62D DAE8 E109 7596 9CE5

* tag 'audio-pull-request' of https://gitlab.com/marcandre.lureau/qemu: (85 commits)
  audio: fix leak of audio capture name
  audio: remove AudioMixengBackendClass.name
  audio: remove AUD_log/ldebug
  audio: replace remaining dolog() and AUD_log
  audio: rework audio_bug()
  audio: rework invalid audsettings error
  tests/audio: add an invalid settings test
  audio: replace DEBUG_AUDIO with trace
  audio: replace DEBUG_OUT with traces
  audio: replace DEBUG_CAPTURE with traces
  audio: rework DEBUG_POLL
  audio: replace ldebug with trace events
  audio: replace int endianness with bool big_endian in audsettings
  audio/mixeng: replace redundant pcm_info fields with AudioFormat
  audio/wav: replace custom logging with error_report
  audio/spice: remove unused AUDIO_CAP macro
  audio/sndio: replace custom logging with error_report
  audio/sdl: replace custom logging with error_report
  audio/pw: replace custom logging with error_report
  audio/pa: replace custom logging with report & trace
  ...

Signed-off-by: Peter Maydell <[email protected]>
2026-02-23 14:03:50 +00:00
Jens Axboe 961fcc0f22 fdmon-io_uring: check CQ ring directly in gsource_check
gsource_check() only looks at the ppoll revents for the io_uring fd,
but CQEs can be posted during gsource_prepare()'s io_uring_submit()
call via kernel task_work processing on syscall exit. These completions
are already sitting in the CQ ring but the ring fd may not be signaled
yet, causing gsource_check() to return false.

Add a fallback io_uring_cq_ready() check so completions that arrive
during submission are dispatched immediately rather than waiting for
the next ppoll() cycle.

Signed-off-by: Jens Axboe <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Stefan Hajnoczi <[email protected]>
2026-02-23 08:50:04 -05:00
Jens Axboe 2ae361ef1d aio-posix: notify main loop when SQEs are queued
When a vCPU thread handles MMIO (holding BQL), aio_co_enter() runs the
block I/O coroutine inline on the vCPU thread because
qemu_get_current_aio_context() returns the main AioContext when BQL is
held. The coroutine calls luring_co_submit() which queues an SQE via
fdmon_io_uring_add_sqe(), but the actual io_uring_submit() only happens
in gsource_prepare() on the main loop thread.

Since the coroutine ran inline (not via aio_co_schedule()), no BH is
scheduled and aio_notify() is never called. The main loop remains asleep
in ppoll() with up to a 499ms timeout, leaving the SQE unsubmitted until
the next timer fires.

Fix this by calling aio_notify() after queuing the SQE. This wakes the
main loop via the eventfd so it can run gsource_prepare() and submit the
pending SQE promptly.

This is a generic fix that benefits all devices using aio=io_uring.
Without it, AHCI/SATA devices see MUCH worse I/O latency since they use
MMIO (not ioeventfd like virtio) and have no other mechanism to wake the
main loop after queuing block I/O.

This is usually a bit hard to detect, as it also relies on the ppoll
loop not waking up for other activity, and micro benchmarks tend not to
see it because they don't have any real processing time. With a
synthetic test case that has a few usleep() to simulate processing of
read data, it's very noticeable. The below example reads 128MB with
O_DIRECT in 128KB chunks in batches of 16, and has a 1ms delay before
each batch submit, and a 1ms delay after processing each completion.
Running it on /dev/sda yields:

time sudo ./iotest /dev/sda

________________________________________________________
Executed in   25.76 secs	  fish           external
   usr time    6.19 millis  783.00 micros    5.41 millis
   sys time   12.43 millis  642.00 micros   11.79 millis

while on a virtio-blk or NVMe device we get:

time sudo ./iotest /dev/vdb

________________________________________________________
Executed in    1.25 secs      fish           external
   usr time    1.40 millis    0.30 millis    1.10 millis
   sys time   17.61 millis    1.43 millis   16.18 millis

time sudo ./iotest /dev/nvme0n1

________________________________________________________
Executed in    1.26 secs      fish           external
   usr time    6.11 millis    0.52 millis    5.59 millis
   sys time   13.94 millis    1.50 millis   12.43 millis

where the latter are consistent. If we run the same test but keep the
socket for the ssh connection active by having activity there, then
the sda test looks as follows:

time sudo ./iotest /dev/sda

________________________________________________________
Executed in    1.23 secs      fish           external
   usr time    2.70 millis   39.00 micros    2.66 millis
   sys time    4.97 millis  977.00 micros    3.99 millis

as now the ppoll loop is woken all the time anyway.

After this fix, on an idle system:

time sudo ./iotest /dev/sda

________________________________________________________
Executed in    1.30 secs      fish           external
   usr time    2.14 millis    0.14 millis    2.00 millis
   sys time   16.93 millis    1.16 millis   15.76 millis

Signed-off-by: Jens Axboe <[email protected]>
Message-Id: <[email protected]>
Reviewed-by: Kevin Wolf <[email protected]>
[Generalize the comment since this applies to all vCPU thread activity,
not just coroutines, as suggested by Kevin Wolf <[email protected]>.
--Stefan]
Signed-off-by: Stefan Hajnoczi <[email protected]>
2026-02-23 08:49:51 -05:00
Marc-André Lureau d256efe6ed audio: fix leak of audio capture name
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Marc-André Lureau <[email protected]>
2026-02-23 14:38:22 +01:00
Marc-André Lureau 097409f57d audio: remove AudioMixengBackendClass.name
Simply use the class name instead.

Signed-off-by: Marc-André Lureau <[email protected]>
Reviewed-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
2026-02-23 14:38:22 +01:00
Marc-André Lureau a588f5a7c6 audio: remove AUD_log/ldebug
audio/ is now converted to use QEMU standard trace & error reporting.

Reviewed-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Marc-André Lureau <[email protected]>
2026-02-23 14:38:22 +01:00
Marc-André Lureau c6dfd07805 audio: replace remaining dolog() and AUD_log
Use warn_report/error_report and trace instead.

Reviewed-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Marc-André Lureau <[email protected]>
2026-02-23 14:38:22 +01:00
Marc-André Lureau ee5e1fca50 audio: rework audio_bug()
audio_bug() is a bit unconventional, it is meant to be used as a
condition expression, passing the actual condition as second argument
(and __func__ as first argument).

If the condition is true, it uses AUD_log() to print to stderr, and has
some dubious recommendations printed only once.

This change:
- clears the control flow, and make the condition directly visible in
  the 'if' statement.
- uses standard QEMU error_report()
- audio_bug() now captures __func__
- remove the "Save all your work and restart..." once hint

Reviewed-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Marc-André Lureau <[email protected]>
2026-02-23 14:38:22 +01:00
Marc-André Lureau 358b0519e7 audio: rework invalid audsettings error
Currently, when given invalid settings, QEMU will print to stderr:

A bug was just triggered in audio_mixeng_backend_open_out
Save all your work and restart without audio
I am sorry
Context:
audio: frequency=44100 nchannels=0 fmt=S16 endianness=little

Now it will use error_report() and simply report:
audio: Invalid audio settings: frequency=44100 nchannels=0 fmt=s16 endian=little

Reviewed-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Marc-André Lureau <[email protected]>
2026-02-23 14:38:22 +01:00
Marc-André Lureau ac8d4cf5f5 tests/audio: add an invalid settings test
As we are going to change the related code next.

Reviewed-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Marc-André Lureau <[email protected]>
2026-02-23 14:38:22 +01:00
Marc-André Lureau 5eafa1e1ba audio: replace DEBUG_AUDIO with trace
Reviewed-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Marc-André Lureau <[email protected]>
2026-02-23 14:38:22 +01:00
Marc-André Lureau c268bf4c7a audio: replace DEBUG_OUT with traces
Reviewed-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Marc-André Lureau <[email protected]>
2026-02-23 14:38:22 +01:00
Marc-André Lureau 28e90447bc audio: replace DEBUG_CAPTURE with traces
Reviewed-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Marc-André Lureau <[email protected]>
2026-02-23 14:38:22 +01:00
Marc-André Lureau e31b29f446 audio: rework DEBUG_POLL
Use more correct GTimer, specific for each backend, with a trace event.

Reviewed-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Marc-André Lureau <[email protected]>
2026-02-23 14:38:22 +01:00
Marc-André Lureau c661a2c448 audio: replace ldebug with trace events
Replace the ldebug macro calls with proper trace events:
- audio_get_avail: traces available samples in capture stream
- audio_open_out/audio_open_in: traces stream open parameters

This provides structured tracing that can be enabled at runtime
without requiring debug builds.

Reviewed-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Marc-André Lureau <[email protected]>
2026-02-23 14:38:22 +01:00
Marc-André Lureau eebba32fe5 audio: replace int endianness with bool big_endian in audsettings
The endianness field used an int to represent a boolean concept, with
0 meaning little-endian and 1 meaning big-endian. This required runtime
validation to reject invalid values and made the code less readable.

Replace with a bool big_endian field that is self-documenting and
type-safe. The compiler now enforces valid values, eliminating the
need for the validation check in audio_validate_settings().

Reviewed-by: Thomas Huth <[email protected]>
Reviewed-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Marc-André Lureau <[email protected]>
2026-02-23 14:38:22 +01:00
Marc-André Lureau 42061a1435 audio/mixeng: replace redundant pcm_info fields with AudioFormat
The audio_pcm_info structure stored three fields (bits, is_signed,
is_float) that were always derived from the AudioFormat enum. This
redundancy meant the same information was represented twice, with no
type-level guarantee that they stayed in sync.

Replace these fields with a single AudioFormat field, and add helper
functions to extract the derived properties when needed:
- audio_format_bits()
- audio_format_is_signed()
- audio_format_is_float()

This improves type safety by making AudioFormat the single source of
truth, eliminating the possibility of inconsistent state between the
format enum and its derived boolean/integer representations.

Signed-off-by: Marc-André Lureau <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Reviewed-by: Mark Cave-Ayland <[email protected]>
2026-02-23 14:38:22 +01:00
Marc-André Lureau 513d4d071e audio/wav: replace custom logging with error_report
Replace the custom audio logging infrastructure (dolog macro) with
standard QEMU error reporting (error_report).

Reviewed-by: Thomas Huth <[email protected]>
Reviewed-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Marc-André Lureau <[email protected]>
2026-02-23 14:38:22 +01:00
Marc-André Lureau 5b166de556 audio/spice: remove unused AUDIO_CAP macro
The AUDIO_CAP macro is no longer used.

Reviewed-by: Thomas Huth <[email protected]>
Reviewed-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Marc-André Lureau <[email protected]>
2026-02-23 14:38:22 +01:00
Marc-André Lureau dcd5915410 audio/sndio: replace custom logging with error_report
Replace the custom audio logging infrastructure (dolog macro) with
standard QEMU error reporting (error_report).

Reviewed-by: Thomas Huth <[email protected]>
Reviewed-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Marc-André Lureau <[email protected]>
2026-02-23 14:38:22 +01:00
Marc-André Lureau b4d6c29b84 audio/sdl: replace custom logging with error_report
Replace the custom audio logging infrastructure (dolog macro and
AUD_log/AUD_vlog) with standard QEMU error reporting (error_report,
error_printf, error_vprintf).

Note that we also dropped the abort() call in DEBUG_AUDIO, as it is not
usually compiled with, doesn't help much, and can easily be added back
when doing development as needed.

Reviewed-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Marc-André Lureau <[email protected]>
2026-02-23 14:38:22 +01:00
Marc-André Lureau a6d2b24bbf audio/pw: replace custom logging with error_report
Replace the custom audio logging infrastructure (dolog macro) with
standard QEMU error reporting (error_report).

Reviewed-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Marc-André Lureau <[email protected]>
2026-02-23 14:38:22 +01:00
Marc-André Lureau 4b6b4a7251 audio/pa: replace custom logging with report & trace
Replace the custom audio logging infrastructure with standard QEMU
error reporting and tracing.

qpa_conn_init() is called during audio_pa_realize() and already reports
an error through Error *.

Reviewed-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Marc-André Lureau <[email protected]>
2026-02-23 14:38:22 +01:00
Marc-André Lureau c60879085a audio/oss: replace custom logging with report & trace
Replace the custom audio logging infrastructure with standard QEMU
error reporting and tracing.

Note the patch drops DEBUG_MISMATCH condition, and now always trace
actual audio parameters.

Reviewed-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Marc-André Lureau <[email protected]>
2026-02-23 14:38:22 +01:00
Marc-André Lureau 8d99d51656 audio/noaudio: remove unused AUDIO_CAP macro
Reviewed-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Marc-André Lureau <[email protected]>
2026-02-23 14:38:22 +01:00
Marc-André Lureau 167af3829d audio/jack: replace custom logging with report & trace
Replace the custom audio logging infrastructure with standard QEMU
error reporting and tracing.

Reviewed-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Marc-André Lureau <[email protected]>
2026-02-23 14:38:22 +01:00
Marc-André Lureau 54f02d8551 audio/dsound: replace custom logging with error_report & trace
The DirectSound audio backend uses its own logging infrastructure
(AUD_log, AUD_vlog, dolog) and the AUDIO_CAP macro. This approach is
inconsistent with the rest of QEMU and makes the output harder to
filter and configure.

Replace the custom logging with standard QEMU error reporting.

Reviewed-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Marc-André Lureau <[email protected]>
2026-02-23 14:38:22 +01:00
Marc-André Lureau 1fa2223da1 audio/dbus: remove unused AUDIO_CAP macro
The DBus audio backend already uses error_report() for error logging.
Remove the unused AUDIO_CAP macro which was left over from the old
logging infrastructure.

Reviewed-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Marc-André Lureau <[email protected]>
2026-02-23 14:38:22 +01:00
Marc-André Lureau b701ae4c91 audio/coreaudio: replace custom logging with error_report
The CoreAudio backend uses its own logging infrastructure (AUD_log,
AUD_vlog, dolog) and the AUDIO_CAP macro. This approach is inconsistent
with the rest of QEMU and makes the output harder to filter and
configure.

Replace the custom logging with standard QEMU error reporting:
- Use error_report() / error_printf() for errors
- Use warn_report() for non-fatal warnings (buffer frame size
  adjustments)

Signed-off-by: Marc-André Lureau <[email protected]>
Reviewed-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
2026-02-23 14:38:22 +01:00
Marc-André Lureau da0625fc85 audio/alsa: replace custom logging with error_report and trace events
The ALSA audio backend uses its own logging infrastructure (AUD_log,
AUD_vlog, dolog, ldebug) and a custom alsa_dump_info() debug helper.
This approach is inconsistent with the rest of QEMU and makes the
output harder to filter and configure.

Replace the custom logging with standard QEMU error reporting:
- Use error_report() / error_printf() for errors
- Use warn_report() for non-fatal warnings (invalid formats,
  rejected parameters, unexpected states)
- Convert ldebug() calls and alsa_dump_info() to trace events

Remove DEBUG_ALSA and AUDIO_CAP macros which are no longer needed.

Reviewed-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Marc-André Lureau <[email protected]>
2026-02-23 14:38:22 +01:00
Marc-André Lureau 740578d483 audio: constify some add_capture() arguments
Reviewed-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Marc-André Lureau <[email protected]>
2026-02-23 14:38:22 +01:00
Marc-André Lureau 29a7f5da98 audio: move pcm_ops into AudioMixengBackendClass
Remove the separate audio_pcm_ops structure and move its function
pointers directly into AudioMixengBackendClass. This is a cleaner
QOM-style design where the PCM operations are part of the class
vtable rather than a separate indirection through hw->pcm_ops.

The HWVoiceOut and HWVoiceIn structures no longer need to store
a pcm_ops pointer, as the operations are now accessed through
the class with AUDIO_MIXENG_BACKEND_GET_CLASS().

Signed-off-by: Marc-André Lureau <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Reviewed-by: Mark Cave-Ayland <[email protected]>
2026-02-23 14:38:22 +01:00
Marc-André Lureau cc66d140a9 audio: remove audio_driver
Move all fields from audio_driver directly into AudioMixengBackendClass,
eliminating an unnecessary extra struct. Drivers now set class
fields directly in class_init instead of creating a static audio_driver
instance.

Signed-off-by: Marc-André Lureau <[email protected]>
Reviewed-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
2026-02-23 14:38:22 +01:00
Marc-André Lureau bc52c58c25 audio: remove audio_driver init/fini/next
They are no longer used after conversion to QOM.

Also removing the drv_opaque from a few of the pcm_ops methods.

Signed-off-by: Marc-André Lureau <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Reviewed-by: Mark Cave-Ayland <[email protected]>
2026-02-23 14:38:22 +01:00
Marc-André Lureau 58e9ca99db audio/dsound: convert to QOM lifecycle methods
Migrate the DirectSound audio backend from the legacy driver init/fini
callbacks to proper QOM realize and finalize methods.

The dsound struct fields are now embedded directly in the AudioDsound
QOM object instead of being allocated separately as drv_opaque. This
allows accessing the backend state through proper QOM type casting
with AUDIO_DSOUND() rather than casting drv_opaque pointers.

The DirectSound and DirectSoundCapture COM objects are now managed
through the QOM lifecycle, with initialization in realize and cleanup
in finalize.

Reviewed-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Marc-André Lureau <[email protected]>
2026-02-23 14:38:22 +01:00
Marc-André Lureau aaaf0f2fdc audio/coreaudio: convert to QOM lifecycle methods
Remove the legacy driver init/fini callbacks from the CoreAudio backend.

Both coreaudio_audio_init() and coreaudio_audio_fini() were no-ops that
performed no real initialization or cleanup work. Access to the
Audiodev is now through hw->s->dev instead of the drv_opaque pointer.

Signed-off-by: Marc-André Lureau <[email protected]>
Reviewed-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
2026-02-23 14:38:22 +01:00
Marc-André Lureau f895d598f2 audio/sndio: convert to QOM lifecycle methods
Remove the legacy driver init/fini callbacks from the sndio audio backend.

Both sndio_audio_init() and sndio_audio_fini() were no-ops that
performed no real initialization or cleanup work. Access to the
Audiodev is now through hw->s->dev instead of the drv_opaque pointer.

Reviewed-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Marc-André Lureau <[email protected]>
2026-02-23 14:38:22 +01:00
Marc-André Lureau 6222994d43 audio/jack: convert to QOM lifecycle methods
Remove the legacy driver init/fini callbacks from the JACK audio backend.

Both qjack_init() and qjack_fini() were no-ops that performed no real
initialization or cleanup work. Access to the Audiodev is now through
hw->s->dev instead of the drv_opaque pointer.

Reviewed-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Marc-André Lureau <[email protected]>
2026-02-23 14:38:22 +01:00
Marc-André Lureau cd5f9b9c02 audio/pw: convert to QOM lifecycle methods
Migrate the PipeWire audio backend from the legacy driver init/fini
callbacks to proper QOM realize and finalize methods.

The pwaudio struct fields are now embedded directly in the AudioPw
QOM object instead of being allocated separately as drv_opaque. This
allows accessing the backend state through proper QOM type casting
with AUDIO_PW() rather than casting drv_opaque pointers.

The PipeWire thread loop and context are now managed through the QOM
lifecycle, with initialization in realize and cleanup in finalize.

Reviewed-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Marc-André Lureau <[email protected]>
2026-02-23 14:38:22 +01:00
Marc-André Lureau 480e6bac92 audio/sdl: convert to QOM lifecycle methods
Migrate the SDL audio backend from the legacy driver init/fini
callbacks to proper QOM realize and finalize methods.

The sdl_audio_init() function is replaced with audio_sdl_realize(),
which initializes the SDL audio subsystem before delegating to the
parent class realize method. The sdl_audio_fini() is replaced with
audio_sdl_finalize() to properly clean up the SDL audio subsystem.

Access to the Audiodev is now through hw->s->dev instead of the
drv_opaque pointer.

Reviewed-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Marc-André Lureau <[email protected]>
2026-02-23 14:38:22 +01:00
Marc-André Lureau 5bb7016727 audio/pa: convert to QOM lifecycle methods
Migrate the PulseAudio backend from the legacy driver init/fini
callbacks to proper QOM realize and finalize methods.

The paaudio struct fields are now embedded directly in the AudioPa
QOM object instead of being allocated separately as drv_opaque. This
allows accessing the backend state through proper QOM type casting
with AUDIO_PA() rather than casting drv_opaque pointers.

The PulseAudio connection is now managed through the QOM lifecycle,
with the connection reference acquired in realize and released in
finalize.

Reviewed-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Marc-André Lureau <[email protected]>
2026-02-23 14:38:22 +01:00
Marc-André Lureau 8c24dd8a7e audio/oss: convert to QOM lifecycle methods
Migrate the OSS audio backend from the legacy driver init/fini
callbacks to proper QOM realize method.

The oss_audio_init() function is replaced with audio_oss_realize(),
which performs the same device accessibility check before delegating
to the parent class realize method. The empty oss_audio_fini() is
removed.

Access to the Audiodev is now through hw->s->dev instead of the
drv_opaque pointer.

Reviewed-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Marc-André Lureau <[email protected]>
2026-02-23 14:38:22 +01:00
Marc-André Lureau b4b511bd19 audio/alsa: convert to QOM lifecycle methods
Migrate the ALSA audio backend from the legacy driver init/fini
callbacks to proper QOM realize method.

The alsa_audio_init() function is replaced with audio_alsa_realize(),
which performs the same ALSA option initialization before delegating
to the parent class realize method. The empty alsa_audio_fini() is
removed.

The Audiodev pointer stored in ALSAVoiceOut and ALSAVoiceIn is removed
as it can now be accessed through hw->s->dev.

Reviewed-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Marc-André Lureau <[email protected]>
2026-02-23 14:38:22 +01:00
Marc-André Lureau f58d732795 audio/noaudio: convert to QOM lifecycle methods
Remove the legacy driver init/fini callbacks from the null audio backend.

Both no_audio_init() and no_audio_fini() were no-ops that performed
no real initialization or cleanup work.

Reviewed-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Marc-André Lureau <[email protected]>
2026-02-23 14:38:22 +01:00
Marc-André Lureau e70c55fee9 audio/wav: convert to QOM lifecycle methods
Remove the legacy driver init/fini callbacks from the WAV audio backend.

The wav_audio_init() just returned the Audiodev pointer and
wav_audio_fini() only logged a debug message. Access to the Audiodev
is now through hw->s->dev instead of the drv_opaque pointer.

Reviewed-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Marc-André Lureau <[email protected]>
2026-02-23 14:38:22 +01:00
Marc-André Lureau 7e4f621fa5 audio/spice: convert to QOM lifecycle methods
Migrate the SPICE audio backend from the legacy driver init/fini
callbacks to proper QOM realize method.

The spice_audio_init() function is replaced with spice_audio_realize(),
which validates that SPICE is enabled before delegating to the parent
class realize method. The empty spice_audio_fini() is removed as no
cleanup is needed.

Reviewed-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Marc-André Lureau <[email protected]>
2026-02-23 14:38:22 +01:00
Marc-André Lureau 06e1312b7d audio/dbus: convert to QOM lifecycle methods
Migrate the D-Bus audio backend from the legacy driver init/fini
callbacks to proper QOM realize and finalize methods.

The DBusAudio struct fields are now embedded directly in the AudioDbus
QOM object instead of being allocated separately as drv_opaque. This
allows accessing the backend state through proper QOM type casting
with AUDIO_DBUS() rather than casting drv_opaque pointers.

Reviewed-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Marc-André Lureau <[email protected]>
2026-02-23 14:38:22 +01:00
Marc-André Lureau 6c8b6f6a2b audio: make audio_driver init() & fini() optional
The next patches are going to remove usage of the driver callbacks in
favor of QOM realize/finalize.

Reviewed-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Marc-André Lureau <[email protected]>
2026-02-23 14:38:22 +01:00
Marc-André Lureau 2842da1dc0 audio: split AudioMixengBackend code in audio-mixeng-be.c
Allow to build the audio/ base classes without the
resampling/mixing/queuing code.

Reviewed-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Marc-André Lureau <[email protected]>
2026-02-23 14:38:22 +01:00
Marc-André Lureau b77fa6d559 audio-be: add some state trace for debugging
Reviewed-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Marc-André Lureau <[email protected]>
2026-02-23 14:38:22 +01:00
Marc-André Lureau 74bb6fb293 audio-be: add common pre-conditions
assert() on valid values, and handle acceptable NULL arguments
gracefully.

Note audio_driver_write() and audio_driver_read() used to return
size (with a "XXX: Consider options") when sw was NULL. Imho, it is more
correct to not pretend to have read/written anything by default in the
AudioBackend base abstract class.

Reviewed-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Marc-André Lureau <[email protected]>
2026-02-23 14:38:22 +01:00
Marc-André Lureau c70d79776b audio: AUD_ -> audio_be_
Use the associate AudioBackend prefix for readability.

Reviewed-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Marc-André Lureau <[email protected]>
2026-02-23 14:38:20 +01:00
Marc-André Lureau 25153b29f8 audio: split AudioBackend
Code clean-up, to allow building bare abstract class separately.

The original file is MIT-licensed.

Reviewed-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Marc-André Lureau <[email protected]>
2026-02-23 14:33:15 +01:00
Marc-André Lureau 909f04f417 audio: make AudioBackend truly abstract
Add virtual methods to be implemented by concrete classes, like
AudioMixengBackendClass.

Reviewed-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Marc-André Lureau <[email protected]>
2026-02-23 14:33:15 +01:00
Marc-André Lureau 61e95a0c60 audio: make all the backend-specific APIs take the be
This will allow to dispatch to different implementations next.

Reviewed-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Marc-André Lureau <[email protected]>
2026-02-23 14:33:09 +01:00
Marc-André Lureau 5ca6c931a7 replay: remove dependency on audio/
The replay infrastructure shouldn't depend on internals of audio/.
(st_sample is an internal implementation detail and could be different)

Let audio drive the audio samples recording/replaying.

Notice also we don't need to save & restore the internal ring "wpos",
all replay should care about is the number of samples and the samples.

Bump the replay version.

Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Marc-André Lureau <[email protected]>
2026-02-23 14:28:57 +01:00
Marc-André Lureau 45d5cf68bc audio: make create_pdos() private
Clean up.

Reviewed-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Marc-André Lureau <[email protected]>
2026-02-23 14:28:57 +01:00
Marc-André Lureau f7958dfd9f audio: make list type declaration private
No need to share in a common header.

Reviewed-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Marc-André Lureau <[email protected]>
2026-02-23 14:28:57 +01:00
Marc-André Lureau 1002fe3710 audio: keep a strong reference on the backend
Since we are going to convert audio_driver-based backends, we need to
properly handle reference counting to allow for a different order of
class finalization (for example, pulse class before base driver class).

Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Marc-André Lureau <[email protected]>
2026-02-23 14:28:57 +01:00
Marc-André Lureau b06d3bafbe audio: replace type_init() with DEFINE_TYPES
Use the convenience macro to register types.

Note that jack backend was using the type registration to initialize
some globals. Use a ctor function instead.

Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Marc-André Lureau <[email protected]>
2026-02-23 14:28:57 +01:00
Marc-André Lureau d8f9785fcc module: remove audio module support
It relies on dynamic object loading support instead.

Reviewed-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Marc-André Lureau <[email protected]>
2026-02-23 14:28:57 +01:00
Marc-André Lureau b16d03b5ba audio: drop audio driver registration
module_object_class_by_name() handles loading the module providing the
requested object.

Signed-off-by: Marc-André Lureau <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Reviewed-by: Mark Cave-Ayland <[email protected]>
2026-02-23 14:28:57 +01:00
Marc-André Lureau b47ed8a5c9 audio: lookup "audio-" object types, and realize them
Now "audio_driver" is a detail implementation of AudioMixengBackend and
not required to implement an AudioBackend.

Reviewed-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Marc-André Lureau <[email protected]>
2026-02-23 14:28:57 +01:00
Marc-André Lureau b95d55f77e audio: remove set_dbus_server from audio_driver
Use the QOM class vtable only instead.

Reviewed-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Marc-André Lureau <[email protected]>
2026-02-23 14:28:57 +01:00
Marc-André Lureau c2dfd949cb audio: add QOM module-objects for each backend
This will allow to use QOM and the dynamic object module loading.

The changes are done systematically, introducing an empty instance
structure that will later be filled by state with further refactoring.

Signed-off-by: Marc-André Lureau <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Reviewed-by: Mark Cave-Ayland <[email protected]>
2026-02-23 14:28:57 +01:00
Marc-André Lureau dacecaf681 audio: move object creation to audio_driver_init()
As we will allow other kind of AudioBackend objects to be instantiated,
move the object allocation to a audio_driver_init() and rename it
audio_be_new().

Reviewed-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Marc-André Lureau <[email protected]>
2026-02-23 14:28:57 +01:00
Marc-André Lureau 4879e3936c audio: simplify audio_init()
Factorize looking up the driver in audio_driver_init()

Reviewed-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Marc-André Lureau <[email protected]>
2026-02-23 14:28:57 +01:00
Marc-André Lureau 28df095452 audio: use DEFINE_TYPES
It's the "modern" way of registring the object TypeInfo.

Suggested-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Marc-André Lureau <[email protected]>
2026-02-23 14:28:57 +01:00
Marc-André Lureau 1618bea984 audio: introduce AudioMixengBackend
Introduce a sub-class for current "audio_driver" based implementations.
Future AudioBackend implementations can do without it.

Next cleanup will actually remove "audio_driver" struct altogether and
make the subclass proper QOM objects.

Public APIs still rely on backend being an AudioMixeng. They will
assert() if not. This will be addressed later to allow other backends.

Note that the initial naming proposed for this object was AudioDriver,
however the semantics for "driver" is already overloaded and leads to
confusion, in particular with the QAPI AudiodevDriver. The defining
characteristic is of using QEMU's software mixing engine, so
AudioMixengBackend.

Reviewed-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Marc-André Lureau <[email protected]>
2026-02-23 14:28:57 +01:00
Marc-André Lureau 1f11eb930e audio: constify audsettings argument
It shouldn't be modified by the audio functions.

Reviewed-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Marc-André Lureau <[email protected]>
2026-02-23 14:28:57 +01:00
Marc-André Lureau 3220b38a8d tests: start manual audio backend test
Start a simple test program that will exercise the QEMU audio APIs.

It is meant to run manually for now, as it accesses the sound system and
produces sound by default, and also runs for a few seconds. We may want
to make it silent or use the "none" (noaudio) backend by default though,
so it can run as part of the automated test suite.

Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Marc-André Lureau <[email protected]>
2026-02-23 14:28:57 +01:00
Marc-André Lureau ba63a9643a util: add some extra stubs for qemu modules initialization
Avoid extra ifdef-ery when optionally supporting modules, as done in
audio-test (and vl.c).

Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Marc-André Lureau <[email protected]>
2026-02-23 14:28:57 +01:00
Marc-André Lureau 492e422b6b scripts/modinfo: add --skip-missing-deps
Add --skip-missing-deps flag that prints warnings for missing
dependencies but continues without exiting with error code 1.

Acked-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Marc-André Lureau <[email protected]>
2026-02-23 14:28:57 +01:00
Marc-André Lureau fa13542f24 scripts/modinfo: make --devices optional
This will allow to use modinfo-generate in cases where devices aren't
relevant (tests etc)

Acked-by: Mark Cave-Ayland <[email protected]>w
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Marc-André Lureau <[email protected]>
2026-02-23 14:28:57 +01:00
Marc-André Lureau 915f990a96 scripts/modinfo: use argparse
This will allow to tweak argument handling more easily next.

Acked-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Marc-André Lureau <[email protected]>
2026-02-23 14:28:57 +01:00
Marc-André Lureau 53d7019663 scripts/modinfo: use f-strings
Reviewed-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Marc-André Lureau <[email protected]>
2026-02-23 14:28:57 +01:00
Marc-André Lureau 0fd2ed275a scripts/modinfo: use in instead of find()
Minor style improvement

Reviewed-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Marc-André Lureau <[email protected]>
2026-02-23 14:28:57 +01:00
Marc-André Lureau ac75ad2923 scripts/modinfo: remove trailing ;
Reviewed-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Marc-André Lureau <[email protected]>
2026-02-23 14:28:57 +01:00
Marc-André Lureau e7bd7f83b6 scripts/modinfo: add type annotations
Type annotations allow easier code reading, refactoring, checking etc.

Reviewed-by: Yodel Eldar <[email protected]>
Tested-by: Yodel Eldar <[email protected]>
Acked-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Marc-André Lureau <[email protected]>
2026-02-23 14:28:56 +01:00
Marc-André Lureau 915653082b build-sys: create a libaudio
This can help create tests, for example.

Reviewed-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Marc-André Lureau <[email protected]>
2026-02-23 14:28:56 +01:00
Marc-André Lureau 42679cb815 audio: list backends as modules
Windows doesn't support modules, atm, but we can treat it as a regular
audio unit regardless.

MacOs does support module, so this is fine.

Reviewed-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Marc-André Lureau <[email protected]>
2026-02-23 14:28:56 +01:00
Marc-André Lureau 67af2055d8 audio: replace vm_running with runstate_is_running()
AudioBackend had a vm_running field which was set in
audio_vm_change_state_handler().

The state change handler "bool running" argument is true when
vm_prepare_start() calls it, and the VM runstate is either SUSPENDED or
RUNNING.

Audio hw voices shouldn't be running when the VM is suspended, but only
when running. Thus replacing the vm_running field with a call to
runstate_is_running() is both simpler and more correct.

Reviewed-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Marc-André Lureau <[email protected]>
2026-02-23 14:28:56 +01:00
Marc-André Lureau fcd5cc9405 qemu-options.hx: document -audiodev dbus
Document the backend introduced in commit 739362d420 ("audio: add dbus
audio backend").

Reported-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Marc-André Lureau <[email protected]>
2026-02-23 14:28:56 +01:00
Marc-André Lureau 5ef9ae1fd5 qemu-options.hx: clarify default audio backend selection
Reviewed-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Marc-André Lureau <[email protected]>
2026-02-23 14:28:56 +01:00
Marc-André Lureau 7c3f1bab7e audio/dbus: make "dbus" the default backend when using -display dbus
Set "using_dbus_display" during early_dbus_init(), so that we can try to
create the "dbus" audio backend by default from audio_prio_list.

This makes dbus audio work by default when using an audio device,
without having to setup and wire up the -audiodev manually.

The added FIXME is addressed in the following commits.

Reviewed-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Marc-André Lureau <[email protected]>
2026-02-23 14:28:56 +01:00
Marc-André Lureau f5cd053a09 audio/adlib: drop ts_helper HWVoice field
Previous commits made this dead code.

Reviewed-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Marc-André Lureau <[email protected]>
2026-02-23 14:28:56 +01:00
Marc-André Lureau 3cb1c36ea2 adlib: remove dead code
Previous commit drop the need for this field.

Reviewed-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Marc-André Lureau <[email protected]>
2026-02-23 14:28:56 +01:00
Marc-André Lureau 52ef022ae8 audio: remove obsolete/obscure functions
AUD_init_time_stamp_{in,out} and AUD_get_elapsed_usec_{in,out} are only
used by the adlib device. The result isn't actually being used since
ADLIB_KILL_TIMERS was set some 20y ago. Let's drop this dead code now.

Drop QEMUAudioTimeStamp as well as reported by Akihiko Odaki.

Reviewed-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Marc-André Lureau <[email protected]>
2026-02-23 14:28:56 +01:00
Peter Maydell a6ec632dca Merge tag 'hw-misc-20260223' of https://github.com/philmd/qemu into staging
Misc HW & Net patches

- Fix trace event name in m68k system controller
- Constify and rename virtio_is_big_endian()
- Fix heap buffer overflow in virtio-serial-bus
- Set graphic display dimensions generically (removing system/globals-target.c)
- Mark eth_header, udp_header, tcp_header as packed structures
- Minor doc / header cleanups

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCAAdFiEE+qvnXhKRciHc/Wuy4+MsLN6twN4FAmmbj2wACgkQ4+MsLN6t
# wN7LqBAAq30ShByylpAJ7DvekgGOHCXeHSdVPZKB8eDC5aVULQfPKp8Ij0v7WpwD
# RzZZWL35nSAqLiMLxxpP/VSY1T+PopoaHtKuZfVc5J/J/mr6lvpbsMlo6jRe/lvT
# r2m5MYGyUnAPsm/t44nG7E53xIqvT5eFMMjMQSYQXgi1RztNGepE5acrOHk2RrWc
# X0NqORf6SeAvo6FX8lIQTQq9/4ePH9f3+DXiM48OaKNVDshARd8C7l3Q2aAC0UWi
# sP0oL7Re0mmCJ4820/tTqsKs9D+4U3Hu5lW0FPdXU6uLoNr70T2g29pRLE4o5mP5
# UV91+x6FdUm7o0oDJ6fxqa0Acdc14QObNeNKkFPIJetvWCOyLdk6tJA6sb6XfPnd
# t2JNvBDJonoUrSSaSp6ZiPP3pOzHyoa/NJUJ7HbRrTPzGHPf3ffwKtG53NkSqP4i
# Py1kFVJW3Ykyq1SUlQ/7UD/N5SPg1RLv8lTqdYXuY6cig7D1XDOPapUtvhKjb+H0
# GIouskPOF/nfB8vBiPDnM+LAC3RwFUi03U3IEEUfRPPvjSflwsNho7j6g+tU7IXk
# DfCwgfyMxvbTJAcalH0EufIDEsCrQ3HvH0oMnidP5Jz4VXCEocb/0zOrBTxbScKH
# Gk4UDN2eqqsbecnAeF7kOE9VOfSSZDrA7ZdvWGD6ofPL0b9wytk=
# =VJig
# -----END PGP SIGNATURE-----
# gpg: Signature made Sun Feb 22 23:21:16 2026 GMT
# gpg:                using RSA key FAABE75E12917221DCFD6BB2E3E32C2CDEADC0DE
# gpg: Good signature from "Philippe Mathieu-Daudé (F4BUG) <[email protected]>" [full]
# Primary key fingerprint: FAAB E75E 1291 7221 DCFD  6BB2 E3E3 2C2C DEAD C0DE

* tag 'hw-misc-20260223' of https://github.com/philmd/qemu: (21 commits)
  net: mark struct tcp_header as QEMU_PACKED
  net: mark struct udp_header as QEMU_PACKED
  net: mark struct eth_header as QEMU_PACKED
  hw/net/rocker: Don't assume h_proto is aligned in eth_strip_vlan_ex()
  hw/net/rocker: Don't keep pointer to h_proto as uint16_t* in OfDpaFlowPktFields
  hw/net/rtl8139: Remove ineffective parameter
  hw/core/cpu: expand cpu_reset function docs
  hw/alpha: remove unused includes
  hw/ppc/spapr: extract SPAPR_MAX_RAM_SLOTS in a new header
  system/globals: Build as common code
  hw/ppc: Set graphic display dimensions generically
  hw/sparc: Set graphic display dimensions generically
  hw/m68k: Set graphic display dimensions generically
  hw/m68k/q800: Set MACFB_DISPLAY_APPLE_21_COLOR within MacFrameBuffer
  hw/m68k/q800: Use MacFbMode fields in q800_machine_init()
  hw/display/macfb: Constify macfb_mode_table[] array
  hw/display/macfb: Constify macfb_sense_table[] array
  hw/char/virtio-serial-bus: Fix Heap-buffer-overflow in set_config()
  hw/virtio: rename virtio_is_big_endian to virtio_vdev_is_big_endian
  hw/virtio: Constify virtio_is_big_endian() argument
  ...

Signed-off-by: Peter Maydell <[email protected]>
2026-02-23 09:56:00 +00:00
Peter Maydell 7de8587b53 net: mark struct tcp_header as QEMU_PACKED
The eth_header is not actually guaranteed to be aligned.  We attempt
to deal with this in some places such as net_checksum_calculate() by
using lduw_be_p() and so on to access the fields, but this is not
sufficient to be correct, because even accessing a byte member within
a misaligned struct is undefined behaviour.  The clang sanitizer will
emit an error like this if you run the sifive_u_mmc functional test
with sanitizers enabled:

../../net/checksum.c:144:24: runtime error: member access within misaligned address 0x619a74c32033 for type 'tcp_header' (aka 'struct tcp_header'), which requires 4 byte alignment
0x619a74c32033: note: pointer points here
 0a  00 02 02 86 aa 00 16 52  c1 d3 70 00 00 00 00 a0  02 fa f0 00 00 00 00 02  04 05 b4 04 02 08 0a
              ^
    #0 0x619a6ba84794 in net_checksum_calculate /home/pm215/qemu/build/clang/../../net/checksum.c:144:24
    #1 0x619a6b5940da in gem_transmit /home/pm215/qemu/build/clang/../../hw/net/cadence_gem.c:1386:21
    #2 0x619a6b592141 in gem_write /home/pm215/qemu/build/clang/../../hw/net/cadence_gem.c:1650:13

Fix this by marking the tcp_header struct as QEMU_PACKED.

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-02-23 00:17:35 +01:00
Peter Maydell 2ca81b0eb3 net: mark struct udp_header as QEMU_PACKED
The eth_header is not actually guaranteed to be aligned.  We attempt
to deal with this in some places such as net_checksum_calculate() by
using lduw_be_p() and so on to access the fields, but this is not
sufficient to be correct, because even accessing a byte member within
a misaligned struct is undefined behaviour.  The clang sanitizer will
emit an error like this if you run the sifive_u_mmc functional test
with sanitizers enabled:

../../net/checksum.c:168:24: runtime error: member access within misaligned address 0x5b7a7f829033 for type 'udp_header' (aka 'struct udp_header'), which requires 2 byte alignment
0x5b7a7f829033: note: pointer points here
 ff  ff ff ff 00 44 00 43 01  34 58 54 01 01 06 00 85  95 80 60 00 00 00 00 00  00 00 00 00 00 00 00
              ^
    #0 0x5b7a71a5887e in net_checksum_calculate /home/pm215/qemu/build/clang/../../net/checksum.c:168:24
    #1 0x5b7a7156819a in gem_transmit /home/pm215/qemu/build/clang/../../hw/net/cadence_gem.c:1386:21
    #2 0x5b7a71566201 in gem_write /home/pm215/qemu/build/clang/../../hw/net/cadence_gem.c:1650:13

Fix this by marking the udp_header struct as QEMU_PACKED,
so that the compiler knows it might be unaligned and will
generate the right code for accessing fields.

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-02-23 00:17:35 +01:00
Peter Maydell 42ada5daf9 net: mark struct eth_header as QEMU_PACKED
The eth_header is not actually guaranteed to be aligned.  We attempt
to deal with this in some places such as net_checksum_calculate() by
using lduw_be_p() and so on to access the fields, but this is not
sufficient to be correct, because even accessing a byte member within
a misaligned struct is undefined behaviour.  The clang sanitizer will
emit an error like this if you run the sifive_u_mmc functional test
with sanitizers enabled:

../../net/checksum.c:78:47: runtime error: member access within misaligned address 0x561f52f35011 for type 'struct eth_header', which requires 2 byte alignment
0x561f52f35011: note: pointer points here
 00 00 00  00 33 33 00 00 00 16 52  54 00 12 34 56 86 dd 60  00 00 00 00 24 00 01 00  00 00 00 00 00
              ^
    #0 0x561f20608459 in net_checksum_calculate /home/pm215/qemu/build/clang/../../net/checksum.c:78:47
    #1 0x561f20117bfa in gem_transmit /home/pm215/qemu/build/clang/../../hw/net/cadence_gem.c:1386:21
    #2 0x561f20115c61 in gem_write /home/pm215/qemu/build/clang/../../hw/net/cadence_gem.c:1650:13

SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../../net/checksum.c:78:47

Fix this by marking the eth_header struct as QEMU_PACKED, so that the
compiler knows it might be unaligned and will generate the right code
for accessing fields.

This is similar to commit f8b94b4c52 ("net: mark struct ip_header as
QEMU_PACKED") where we fixed this for a different struct defined in
this file.

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-02-23 00:17:35 +01:00
Peter Maydell 3609630e79 hw/net/rocker: Don't assume h_proto is aligned in eth_strip_vlan_ex()
In eth_strip_vlan_ex() we take a pointer to the eth_header h_proto
field into a local uint16_t* variable, and then later in the function
we dereference that pointer.  This isn't safe, because the eth_header
struct may not be aligned, and if we mark the struct as QEMU_PACKED
then gcc will complain about taking the address of a field in a
packed struct.

Instead, make the local variable be a void* and use the appropriate
functions for accessing 16 bits of possibly unaligned data through
it.

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-02-23 00:17:35 +01:00
Peter Maydell 387ee5d2be hw/net/rocker: Don't keep pointer to h_proto as uint16_t* in OfDpaFlowPktFields
In rocker_of_dpa.c we assume that the h_proto field in an eth_header
struct is aligned, and we copy its address into a uint16_t* in the
OfDpaFlowPktFields struct which we then dereference later.  This
isn't a safe assumption; it will also result in compilation failures
with gcc if we mark the eth_header struct as QEMU_PACKED because gcc
will not let you take the address of an unaligned struct field.

Make the h_proto field in OfDpaFlowPktFields a void*, and make all
the places where we previously read through that pointer instead use
a new accessor function which allows for the possible lack of
alignment.

(Compare commit 5814c08467
"hw/net/virtio-net.c: Don't assume IP length field is aligned"
which fixed a similar problem elsewhere for an ip_header field.)

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-02-23 00:17:35 +01:00
BALATON Zoltan fa08447317 hw/net/rtl8139: Remove ineffective parameter
The do_interrupt parameter for rtl8139_do_receive was originally added
in commit 6cadb320c7 to avoid generating interrupt when receiving in
loopback mode. Later commit 5311fb805a changed this so that this
parameter became ineffective and now this parameter is unused and
always 1. If this turns out to be a problem maybe there's a better way
to fix this so remove the do_interrupt parameter for now to simplify
code.

Signed-off-by: BALATON Zoltan <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-02-23 00:17:35 +01:00
Alex Bennée 703bc80f55 hw/core/cpu: expand cpu_reset function docs
Add a hint to the developer that this should only be called from a
reset chain.

Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Alex Bennée <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-02-23 00:17:34 +01:00
Alex Bennée 029125efe4 hw/alpha: remove unused includes
Signed-off-by: Alex Bennée <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-02-23 00:17:34 +01:00
Pierrick Bouvier fe25b9213c hw/ppc/spapr: extract SPAPR_MAX_RAM_SLOTS in a new header
Allow to include it from common code (vhost-user, in next commit),
else it pulls ppc/cpu.h which has target specifics.

Signed-off-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Tested-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-02-23 00:17:34 +01:00
Philippe Mathieu-Daudé 32a38529c4 system/globals: Build as common code
Now that all targets have the graphic dimension variables
initialized the same way, we can move them to the common
file unit, having them built once. Remove the now empty
globals-target.c file. The command line '-g WxH[xD]' option
is not changed and behaves the same.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <[email protected]>
2026-02-23 00:17:34 +01:00
Philippe Mathieu-Daudé af2f0774cc hw/ppc: Set graphic display dimensions generically
If a dimension is not set, have the machine init code set
the default values.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <[email protected]>
2026-02-23 00:17:34 +01:00
Philippe Mathieu-Daudé 37ad735f6b hw/sparc: Set graphic display dimensions generically
If a dimension is not set, have the machine init code
set the default values.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Mark Cave-Ayland <[email protected]>
Message-Id: <[email protected]>
2026-02-23 00:17:34 +01:00
Philippe Mathieu-Daudé 7207a9c3a9 hw/m68k: Set graphic display dimensions generically
If a dimension is not set, have the machine init code
(q800_machine_init) set the default values.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Mark Cave-Ayland <[email protected]>
Message-Id: <[email protected]>
2026-02-23 00:17:34 +01:00
Philippe Mathieu-Daudé 6c72922fe5 hw/m68k/q800: Set MACFB_DISPLAY_APPLE_21_COLOR within MacFrameBuffer
The MACFB_DISPLAY_APPLE_21_COLOR mode is not specific to the Q800
machine. Check and set it once in the MacFB DeviceRealize handler.

No need to explicitly set the MACFB_DISPLAY_VGA mode since this is
the default value.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Mark Cave-Ayland <[email protected]>
Message-Id: <[email protected]>
2026-02-23 00:17:34 +01:00
Philippe Mathieu-Daudé 3445dd26ec hw/m68k/q800: Use MacFbMode fields in q800_machine_init()
Once the Mac Frame Buffer device is realized on the NuBus,
its MacFbMode might be different of the global graphic_depth
and graphic_width globals. Prefer the device MacFbMode fields
to initialize the BootInfo structure.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Mark Cave-Ayland <[email protected]>
Message-Id: <[email protected]>
2026-02-23 00:17:34 +01:00
Philippe Mathieu-Daudé ee56761607 hw/display/macfb: Constify macfb_mode_table[] array
macfb_mode_table[] is only read, never updated, so can be const.

Update the call sites accordingly.
Make the MacfbState::mode pointer to const.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <[email protected]>
2026-02-23 00:17:34 +01:00
Philippe Mathieu-Daudé 10b63551b6 hw/display/macfb: Constify macfb_sense_table[] array
macfb_sense_table[] is only read, never updated, so can be const.

Update the single call site, macfb_sense_read().

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <[email protected]>
2026-02-23 00:17:34 +01:00
Philippe Mathieu-Daudé 730d049c4b hw/char/virtio-serial-bus: Fix Heap-buffer-overflow in set_config()
When removing the 'emergency-write' property in commit d0660e5b7f
we neglected to remove the code reducing the virtio_console_config
structure size, allowing to access up to the unallocated 'emerg_wr'
field.

Can be reproduced running:

  $ cat << EOF | qemu-system-i386 -nodefaults \
                     -machine q35 -m 512M \
                     -device virtio-serial \
                     -display none \
                     -machine accel=qtest -qtest stdio
  outl 0xcf8 0x80000810
  outl 0xcfc 0xc000
  outl 0xcf8 0x80000804
  outw 0xcfc 0x01
  outl 0xc014 0x00
  EOF
  ==3210206==ERROR: AddressSanitizer: heap-buffer-overflow
      on address 0x502000090858 at pc 0x5638f1300a9b bp 0x7fff6b525b80 sp 0x7fff6b525b70
  READ of size 4 at 0x502000090858 thread T0
      #0 0x5638f1300a9a in set_config hw/char/virtio-serial-bus.c:590
      #1 0x5638f0bccdcf in virtio_config_writel hw/virtio/virtio-config-io.c:104
      #2 0x5638f0bd0c89 in virtio_pci_config_write hw/virtio/virtio-pci.c:637
      #3 0x5638f0cf90cf in memory_region_write_accessor system/memory.c:491
      #4 0x5638f0cf975b in access_with_adjusted_size system/memory.c:567
      #5 0x5638f0d01d3f in memory_region_dispatch_write system/memory.c:1547
      #6 0x5638f0d2fa1e in address_space_stm_internal system/memory_ldst.c.inc:85
      #7 0x5638f0d30013 in address_space_stl_le system/memory_ldst_endian.c.inc:53
      #8 0x5638f0ceb568 in cpu_outl system/ioport.c:79
      #9 0x5638f0d3c0f9 in qtest_process_command system/qtest.c:483

  0x502000090858 is located 0 bytes to the right of 8-byte region [0x502000090850,0x502000090858)
  allocated by thread T0 here:
      #0 0x7f0dc32cba57 in __interceptor_calloc src/libsanitizer/asan/asan_malloc_linux.cpp:154
      #1 0x7f0dc2382c50 in g_malloc0 (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x5ec50)
      #2 0x5638f1303c27 in virtio_serial_device_realize hw/char/virtio-serial-bus.c:1046
      #3 0x5638f1396a9c in virtio_device_realize hw/virtio/virtio.c:4053
      #4 0x5638f13ea370 in device_set_realized hw/core/qdev.c:523
      #5 0x5638f13fdaf6 in property_set_bool qom/object.c:2376
      #6 0x5638f13f9098 in object_property_set qom/object.c:1450
      #7 0x5638f140283c in object_property_set_qobject qom/qom-qobject.c:28
      #8 0x5638f13f9616 in object_property_set_bool qom/object.c:1520
      #9 0x5638f13e91cc in qdev_realize hw/core/qdev.c:276
      #10 0x5638f0c3d94b in virtio_serial_pci_realize hw/virtio/virtio-serial-pci.c:69
      #11 0x5638f0bda886 in virtio_pci_realize hw/virtio/virtio-pci.c:2351
      #12 0x5638f09bc2ae in pci_qdev_realize hw/pci/pci.c:2310
      #13 0x5638f0bdb2f2 in virtio_pci_dc_realize hw/virtio/virtio-pci.c:2473
      #14 0x5638f13ea370 in device_set_realized hw/core/qdev.c:523

    SUMMARY: AddressSanitizer: heap-buffer-overflow hw/char/virtio-serial-bus.c:590 in set_config

Fixes: d0660e5b7f ("hw/char/virtio-serial: Do not expose the 'emergency-write' property")
Reported-by: Alexander Bulekov <[email protected]>
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3303
Buglink: https://issues.oss-fuzz.com/issues/484647006
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Tested-by: Alexander Bulekov <[email protected]>
Message-Id: <[email protected]>
2026-02-23 00:17:34 +01:00
Pierrick Bouvier 6325407f67 hw/virtio: rename virtio_is_big_endian to virtio_vdev_is_big_endian
Renaming this function removes the confusion with
existing virtio_is_big_endian cpu ops.

Indeed, virtio_vdev_is_big_endian is *not* calling cpu
virtio_is_big_endian everytime.

Signed-off-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-02-22 22:52:29 +01:00
Philippe Mathieu-Daudé 2622a178b6 hw/virtio: Constify virtio_is_big_endian() argument
VirtIODevice argument is accessed read-only, make it const.

Signed-off-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
2026-02-22 22:52:29 +01:00
Kuan-Wei Chiu 8608ed356e hw/misc/virt_ctrl: Fix incorrect trace event in read operation
The virt_ctrl_read() function currently invokes trace_virt_ctrl_write()
instead of trace_virt_ctrl_read(). This results in read operations
appearing as write operations in the trace output, which is misleading
during debugging and analysis.

Replace the incorrect trace call with the proper read-specific trace
event to accurately reflect the hardware behavior.

Fixes: 0791bc02b8 ("m68k: add a system controller")
Signed-off-by: Kuan-Wei Chiu <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-02-22 22:52:29 +01:00
Peter Maydell 05de1b5309 Merge tag 'hppa-a400-pull-request' of https://github.com/hdeller/qemu-hppa into staging
hppa a400 machine support

Major enhancements to SeaBIOS-hppa to support an A400 server. This server
requires 64-bit PAT firmware, so SeaBIOS-hppa was extendend a lot. PAT firmware
is required as well to support 64-bit HP-UX 11i3 or MPE.

# -----BEGIN PGP SIGNATURE-----
#
# iHUEABYKAB0WIQS86RI+GtKfB8BJu973ErUQojoPXwUCaZcFewAKCRD3ErUQojoP
# X+DzAP92OFkgItNkG1Rv7z1Bk9J+6wzs2aYDyZud7Fc8/xB4IgD+Okm8B5LwXyQx
# BQIvYQiIo3e3Ix51tDQQXBvpLappTAw=
# =rCC8
# -----END PGP SIGNATURE-----
# gpg: Signature made Thu Feb 19 12:43:39 2026 GMT
# gpg:                using EDDSA key BCE9123E1AD29F07C049BBDEF712B510A23A0F5F
# gpg: Good signature from "Helge Deller <[email protected]>" [unknown]
# gpg:                 aka "Helge Deller <[email protected]>" [unknown]
# gpg:                 aka "Helge Deller <[email protected]>" [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: 4544 8228 2CD9 10DB EF3D  25F8 3E5F 3D04 A7A2 4603
#      Subkey fingerprint: BCE9 123E 1AD2 9F07 C049  BBDE F712 B510 A23A 0F5F

* tag 'hppa-a400-pull-request' of https://github.com/hdeller/qemu-hppa:
  hw/hppa: Add emulation for the 64-bit A400 server
  hw/hppa: Require SeaBIOS version 22 for A400 machine
  target/hppa: Update SeaBIOS-hppa to version 22
  hw/hppa: Add BMC on 64-bit machines only

Signed-off-by: Peter Maydell <[email protected]>
2026-02-22 18:58:36 +00:00
Peter Maydell 1d893e5069 Merge tag 'for_upstream' of https://git.kernel.org/pub/scm/virt/kvm/mst/qemu into staging
virtio,pc,pci: features, fixes

cxl:
    RAS features
    Back-Invalidate
    Flit mode
    r3.2 spec event updates
    FM-API Physical Switch Command Set support
vhost-vdpa: allow GSO for SVQ

misc fixes, cleanups in intel_iommu, vhost, virtio, acpi

Signed-off-by: Michael S. Tsirkin <[email protected]>

# -----BEGIN PGP SIGNATURE-----
#
# iQFDBAABCgAtFiEEXQn9CHHI+FuUyooNKB8NuNKNVGkFAmmYtvkPHG1zdEByZWRo
# YXQuY29tAAoJECgfDbjSjVRpiZ8IAKLpdkPW3mcYwlVgDLIBENu4S3ZzTAthEr+9
# 8qnk0H3eJ6f++OP9wMxwqZ0KcJbrfaB4iDSxd4d42bj6sVzdPhkaaIxnR45V7JiZ
# lQA1aOwhm8Z4vRS3nXBmNhkx6cngO0rzUabX5mzymUrYhtNNJ8HMuSKPU/V3vyW/
# lRXQc5toi2NQ4kbBy9kbPvx5ld5BXfnSmEEYbSsdBZ3Ifk/JCIZ0GWy53FxflbxZ
# FnffxNjy91uN7DVQvgWN0vNzp4r1txkZpoV8PkWqUB7BvtNESb6FXvv+skEG4cM8
# mNlhv0/LCLnyy4uMvSGUvI6IkFKA0WyVAm3O0i+yh1A6+c8VVxI=
# =iYn3
# -----END PGP SIGNATURE-----
# gpg: Signature made Fri Feb 20 19:33:13 2026 GMT
# gpg:                using RSA key 5D09FD0871C8F85B94CA8A0D281F0DB8D28D5469
# gpg:                issuer "[email protected]"
# gpg: Good signature from "Michael S. Tsirkin <[email protected]>" [full]
# gpg:                 aka "Michael S. Tsirkin <[email protected]>" [full]
# 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: (33 commits)
  vhost: fix vhost_inflight_buffer_pre_load
  virtio-snd: tighten read amount in in_cb
  virtio-snd: fix max_size bounds check in input cb
  virtio-snd: handle 5.14.6.2 for PCM_INFO properly
  virtio-snd: remove TODO comments
  MAINTAINERS: add me as maintainer to virtio-snd
  hw/cxl: Add Physical Port Control FMAPI Command (Opcode 5102h)
  hw/cxl: Get Physical Port State - update for PCIe flit mode
  hw/cxl: Physical Port Info FMAPI - update to current spec and add defines.
  virtio-gpu-virgl: Add virtio-gpu-virgl-hostmem-region type
  intel_iommu: Do not report recoverable faults to host
  net/vhost-vdpa: Whitelist virtio-net GSO for shadow virtqueue
  hw/cxl: Remove register special_ops->read()
  hw/cxl: Support type3 HDM-DB
  tests/acpi/cxl: Update CEDT.cxl to allow BI in CFWMS
  hw/cxl: Update CXL Fixed Memory Window ACPI description to include Back Invalidate support.
  tests/bios-tables-test: Excluded CEDT.cxl for BI restriction relaxation.
  hw/cxl: Refactor component register initialization
  hw/pcie: Support enabling flit mode
  hw/cxl: Add emulation for memory sparing control feature
  ...

Signed-off-by: Peter Maydell <[email protected]>
2026-02-22 18:58:23 +00:00
Peter Maydell 0954a96504 Merge tag 'pr-plugins-20260219' of https://gitlab.com/pbo-linaro/qemu into staging
Changes:
- [PATCH] contrib/plugins/cpp: use __has_include (Pierrick Bouvier <[email protected]>)
  Link: https://lore.kernel.org/qemu-devel/[email protected]

# -----BEGIN PGP SIGNATURE-----
#
# iQGzBAABCgAdFiEEZrmU7KFPfy5auggff5BUDQoc0A8FAmmXc/UACgkQf5BUDQoc
# 0A8IJgv/XGJdZg/LFbUrpZJRtlBNzFf1sRjFkYfm17T0zTIyJirAVQPozVImZGMs
# JKM/WBRKJ0GqUV8Gm2VTToWsdM3elByL2uEUpUZGFXbPGGQfa94orGj4TAz/PUc6
# z7GUSJ2Hg6nsJYjikdKmTp3v4+Z5fc+0YYo6vjjLMFi5rp/jsDcSTUnIvSH4WLZe
# Fbv1muZd5CZgdQa+swZzPeAXkZIlI6QMWTTaJSx7rNxiJSsAXJ4paWa3vqS++yV0
# bbTyxOI0AH/7A7In7lT2QS1lwmYRBbGrdH8IlTqrQCvD464KC2pq4jxzdt+kItns
# qk5XbLozvoFk0mhFQQXSNi54Wxs9muF4EgAxzyujl0kzR0mUKB92QE6gjy9MM1LA
# gcXePhtMsC6jIBJTEZPH3ZzLyYmc5bIExw/T8gfEB9XzAkd96IaCLQiCajF9MLOe
# nFlxrfLzjLhKncSsVQBHXrgaNN7+VPulstRJOG6K4l2IdgZYioOmKvO4+ys2gNCw
# nat4QWi6
# =wMeg
# -----END PGP SIGNATURE-----
# gpg: Signature made Thu Feb 19 20:35:01 2026 GMT
# gpg:                using RSA key 66B994ECA14F7F2E5ABA081F7F90540D0A1CD00F
# gpg: Good signature from "Pierrick Bouvier <[email protected]>" [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: 66B9 94EC A14F 7F2E 5ABA  081F 7F90 540D 0A1C D00F

* tag 'pr-plugins-20260219' of https://gitlab.com/pbo-linaro/qemu:
  contrib/plugins/cpp: use __has_include

Signed-off-by: Peter Maydell <[email protected]>
2026-02-22 18:58:09 +00:00
Alexandr Moshkov 72f663f575 vhost: fix vhost_inflight_buffer_pre_load
While I was rebasing my series about inflight migration, I missed a
small issue in vhost_inflight_buffer_preload:

* fix wrong return type in function
* fix error check

Signed-off-by: Alexandr Moshkov <[email protected]>
Fixes: tag pls?
Reviewed-by: Vladimir Sementsov-Ogievskiy <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Message-Id: <[email protected]>
2026-02-20 13:04:45 -05:00
Manos Pitsidianakis 7994203bb1 virtio-snd: tighten read amount in in_cb
The amount of bytes to read passed to AUD_read() should never surpass
the maximum available buffer length. Tighten the current amount by
MIN(<amount>, max_size - <existing size>).

Cc: [email protected]
Fixes: 98e77e3dd8 ("virtio-snd: add max size bounds check in input cb")
Reported-by: DARKNAVY <[email protected]>
Signed-off-by: Manos Pitsidianakis <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Message-Id: <[email protected]>
2026-02-20 13:04:45 -05:00
Manos Pitsidianakis bcb53328aa virtio-snd: fix max_size bounds check in input cb
In 98e77e3d we calculated the max size and checked that each buffer is smaller than it.

We neglected to subtract the size of the virtio_snd_pcm_status header
from the max size, and max_size was thus larger than the correct value,
leading to potential OOB writes.

If the buffer cannot fit the header or can fit only the header, return
the buffer immediately.

Cc: [email protected]
Fixes: 98e77e3dd8 ("virtio-snd: add max size bounds check in input cb")
Reported-by: DARKNAVY <[email protected]>
Signed-off-by: Manos Pitsidianakis <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Message-Id: <[email protected]>
2026-02-20 13:04:45 -05:00
Manos Pitsidianakis 61679d7dcf virtio-snd: handle 5.14.6.2 for PCM_INFO properly
The section 5.14.6.2 of the VIRTIO spec says:

  5.14.6.2 Driver Requirements: Item Information Request

  - The driver MUST NOT set start_id and count such that start_id +
    count is greater than the total number of particular items that is
    indicated in the device configuration space.

  - The driver MUST provide a buffer of sizeof(struct virtio_snd_hdr) +
    count * size bytes for the response.

While we performed some check for the second requirement, it failed to
check for integer overflow.

Add also a check for the first requirement, which should limit exposure
to any overflow, since realistically the number of streams will be low
enough in value such that overflow is improbable.

Cc: [email protected]
Reported-by: 罗铭源 <[email protected]>
Signed-off-by: Manos Pitsidianakis <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Message-Id: <[email protected]>
2026-02-20 13:04:45 -05:00
Manos Pitsidianakis 34238f078a virtio-snd: remove TODO comments
Replying with a VIRTIO_SND_S_BAD_MSG error does not warrant a device
reset. Instead, a device reset happens when the driver requests it from the
transport.

Signed-off-by: Manos Pitsidianakis <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Message-Id: <[email protected]>
2026-02-20 13:04:45 -05:00
Manos Pitsidianakis 5cf298a394 MAINTAINERS: add me as maintainer to virtio-snd
Cc: Michael S. Tsirkin <[email protected]>
Signed-off-by: Manos Pitsidianakis <[email protected]>
Reviewed-by: Alex Bennée <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Message-Id: <[email protected]>
2026-02-20 13:04:45 -05:00
Arpit Kumar 6e1410fdcf hw/cxl: Add Physical Port Control FMAPI Command (Opcode 5102h)
Added assert-deassert PERST implementation for physical ports (both USP
and DSP's).

Assert PERST involves bg operation for holding 100ms.
Reset PPB implementation for physical ports.

Signed-off-by: Arpit Kumar <[email protected]>
Co-developed-by: Jonathan Cameron <[email protected]>
Signed-off-by: Jonathan Cameron <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Message-Id: <[email protected]>
2026-02-20 13:04:45 -05:00
Jonathan Cameron be7ce15d35 hw/cxl: Get Physical Port State - update for PCIe flit mode
Recent support for 256B flits, was not accounted for in this FMAPI command
that should be retrieving the current status of Physical Switch Ports.

Note x-flit-mode control is via the downstream devices, so for USPs the
property must be checked to establish support, but for DSPs this mode is
always supported (control is with the next port downstream, typically the
end point.  All cases the linksta2 register may be queried to obtain
current status.  Note the PCI spec is a little confusing as it refers to
this bit only being non 0 if Device Readiness Status (DRS) is in particular
states (basically link trained) but Flit mode is a separate feature and DRS
may not be present. It is not yet emulated in QEMU. So assume that we
should reflect what states DRS would be reporting if it were actually
present.

One small thing to note is that the current link width for a port with
nothing connected reports the same as the capability. This is odd but valid
because the value under these circumstances is undefined (PCIe r6.2 table
7-26 Link Status Register - field Current Link Speed.)

Signed-off-by: Jonathan Cameron <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Message-Id: <[email protected]>
2026-02-20 13:04:45 -05:00
Arpit Kumar 7df839591c hw/cxl: Physical Port Info FMAPI - update to current spec and add defines.
Add a new cxl/cxl_ports.h header for field definitions related only to port
commands. Bring field naming up to date with spec as 'version' bitmasks
have been replaced with bitmasks of the specific features.

Fix a small issue where a reserved value for USP was set to 2 rather
than 0.

Signed-off-by: Arpit Kumar <[email protected]>
Co-developed-by: Jonathan Cameron <[email protected]>
Signed-off-by: Jonathan Cameron <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Message-Id: <[email protected]>
2026-02-20 13:04:45 -05:00
Akihiko Odaki b2a279094c virtio-gpu-virgl: Add virtio-gpu-virgl-hostmem-region type
Commit e27194e087 ("virtio-gpu-virgl: correct parent for blob memory
region") made the name member of MemoryRegion unset, causing a NULL
pointer dereference[1]:
> Thread 2 "qemu-system-x86" received signal SIGSEGV, Segmentation fault.
> (gdb) bt
> #0  0x00007ffff56565e2 in __strcmp_evex () at /lib64/libc.so.6
> #1  0x0000555555841bdb in find_fd (head=0x5555572337d0 <cpr_state>,
> name=0x0, id=0) at ../migration/cpr.c:68
> #2  cpr_delete_fd (name=name@entry=0x0, id=id@entry=0) at
> ../migration/cpr.c:77
> #3  0x000055555582290a in qemu_ram_free (block=0x7ff7e93aa7f0) at
> ../system/physmem.c:2615
> #4  0x000055555581ae02 in memory_region_finalize (obj=<optimized out>)
> at ../system/memory.c:1816
> #5  0x0000555555a70ab9 in object_deinit (obj=<optimized out>,
> type=<optimized out>) at ../qom/object.c:715
> #6  object_finalize (data=0x7ff7e936eff0) at ../qom/object.c:729
> #7  object_unref (objptr=0x7ff7e936eff0) at ../qom/object.c:1232
> #8  0x0000555555814fae in memory_region_unref (mr=<optimized out>) at
> ../system/memory.c:1848
> #9  flatview_destroy (view=0x555559ed6c40) at ../system/memory.c:301
> #10 0x0000555555bfc122 in call_rcu_thread (opaque=<optimized out>) at
> ../util/rcu.c:324
> #11 0x0000555555bf17a7 in qemu_thread_start (args=0x555557b99520) at
> ../util/qemu-thread-posix.c:393
> #12 0x00007ffff556f464 in start_thread () at /lib64/libc.so.6
> #13 0x00007ffff55f25ac in __clone3 () at /lib64/libc.so.6

The intention of the aforementioned commit is to prevent a MemoryRegion
from parenting itself while its references is counted indendependently
of the device. To achieve the same goal, add a type of QOM objects that
count references and parent MemoryRegions.

[1] https://lore.kernel.org/qemu-devel/[email protected]/

Cc: [email protected]
Fixes: e27194e087 ("virtio-gpu-virgl: correct parent for blob memory region")
Signed-off-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Tested-by: Dmitry Osipenko <[email protected]>
Tested-by: Joelle van Dyne <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Message-Id: <[email protected].i.u-tokyo.ac.jp>
2026-02-20 13:04:45 -05:00
Clement Mathieu--Drif a6e6a91c2a intel_iommu: Do not report recoverable faults to host
Signed-off-by: Clement Mathieu--Drif <[email protected]>
Reviewed-by: Zhenzhong Duan <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Message-Id: <[email protected]>
2026-02-20 13:04:45 -05:00
Eugenio Pérez 25730acda4 net/vhost-vdpa: Whitelist virtio-net GSO for shadow virtqueue
Even if it is deprecated by the VirtIO standard it does not affect the
layout of the queue, or introduces new operations. So Shadow Virtqueue
can handle it just fine.

Tested with OVS DPDK and VDUSE.

Signed-off-by: Eugenio Pérez <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Message-Id: <[email protected]>
2026-02-20 13:04:45 -05:00
Davidlohr Bueso defdfab32c hw/cxl: Remove register special_ops->read()
... this is unused, unlike its write counterpart.

Scope needs to be added to avoid _Static_assert() immediately
after a label. c23 makes this valid but before then it is compiler
dependent.

Suggested-by: [email protected]
Tested-by: Dongjoo Seo <[email protected]>
Signed-off-by: Davidlohr Bueso <[email protected]>
Signed-off-by: Jonathan Cameron <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Message-Id: <[email protected]>
2026-02-20 13:04:45 -05:00
Davidlohr Bueso 88ac457c88 hw/cxl: Support type3 HDM-DB
Add basic plumbing for memory expander devices that support Back
Invalidation. This introduces a 'hdm-db=on|off' parameter and
exposes the relevant BI RT/Decoder component cachemem registers.

Some noteworthy properties:
 - Devices require enabling Flit mode across the CXL topology.
 - Explicit BI-ID commit is required.
 - HDM decoder support both host and dev coherency models.

Tested-by: Dongjoo Seo <[email protected]>
Signed-off-by: Davidlohr Bueso <[email protected]>
Signed-off-by: Jonathan Cameron <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Message-Id: <[email protected]>
2026-02-20 13:04:45 -05:00
Jonathan Cameron 26cd3f8d96 tests/acpi/cxl: Update CEDT.cxl to allow BI in CFWMS
With the addition of back invalidate support in the CXL emulation relax
the restriction on the CXL Fixed Memory Window Structures so all
advertised ranges continue to support being used with all features that
QEMU emulates.

[064h 0100 001h]               Subtable Type : 01 [CXL Fixed Memory Window Structure]
[065h 0101 001h]                    Reserved : 00
[066h 0102 002h]                      Length : 0028
[068h 0104 004h]                    Reserved : 00000000
[06Ch 0108 008h]         Window base address : 0000000110000000
[074h 0116 008h]                 Window size : 0000000100000000
[07Ch 0124 001h]          Interleave Members : 00
[07Dh 0125 001h]       Interleave Arithmetic : 00
[07Eh 0126 002h]                    Reserved : 0000
[080h 0128 004h]                 Granularity : 00000005
[084h 0132 002h]                Restrictions : 002F # Changed from 000F
[086h 0134 002h]                       QtgId : 0000
[088h 0136 004h]                First Target : 0000000C

Signed-off-by: Jonathan Cameron <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Message-Id: <[email protected]>
2026-02-20 13:04:45 -05:00
Jonathan Cameron e6742e71c2 hw/cxl: Update CXL Fixed Memory Window ACPI description to include Back Invalidate support.
Defaults for these windows has always been to enable anything QEMU supports.
With the addition of back invalidate support it is necessary to specify that
host windows support this.

CXL emulation is currently only suitable for software stack verification.
The relaxation of the restrictions on this window to include BI have no
affect on the OS until BI capable devices are added and until now these
have not existed. As such no backwards compatibility impacts are expected
from this change.

Reviewed-by: Davidlohr Bueso <[email protected]>
Signed-off-by: Jonathan Cameron <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Message-Id: <[email protected]>
2026-02-20 13:04:45 -05:00
Jonathan Cameron de6eb44095 tests/bios-tables-test: Excluded CEDT.cxl for BI restriction relaxation.
The next patch will relax restrictions on the fixed memory window
to allow use with back invalidate capable devices.

Signed-off-by: Jonathan Cameron <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Message-Id: <[email protected]>
2026-02-20 13:04:45 -05:00
Ira Weiny 5729c01a60 hw/cxl: Refactor component register initialization
CXL 3.2 8.2.4 Table 8-22 defines which capabilities are mandatory, not
permitted, or optional for each type of device.

cxl_component_register_init_common() uses a rather odd 'fall through'
mechanism to define each component register set.  This assumes that any
device or capability being added builds on the previous devices
capabilities.  This is not true as there are mutually exclusive
capabilities defined.  For example, downstream ports can not have snoop
but it can have Back Invalidate capable decoders.

Refactor this code to make it easier to add individual capabilities as
defined by a device type.  Any capability which is not specified by the
type is left NULL'ed out which complies with the packed nature of the
register array.

Update all spec references to 3.2.

No functional changes should be seen with this patch.

Signed-off-by: Ira Weiny <[email protected]>
Tested-by: Dongjoo Seo <[email protected]>
[rebased, no RAS for HBs, r3.2 references]
Signed-off-by: Davidlohr Bueso <[email protected]>
Signed-off-by: Jonathan Cameron <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Message-Id: <[email protected]>
2026-02-20 13:04:45 -05:00
Davidlohr Bueso d29f3f5cdd hw/pcie: Support enabling flit mode
PCIe Flit Mode, introduced with the PCIe 6.0 specification, is a
fundamental change in how data is transmitted over the bus to
improve transfer rates. It shifts from variable-sized Transaction
Layer Packets (TLPs) to fixed 256-byte Flow Control Units (FLITs).

As with the link speed and width training, have ad-hoc property for
setting the flit mode and allow CXL components to make use of it.

For the CXL root port and dsp cases, always report flit mode but
the actual value after 'training' will depend on the downstream
device configuration.

Suggested-by: Jonathan Cameron <[email protected]>
Tested-by: Dongjoo Seo <[email protected]>
Signed-off-by: Davidlohr Bueso <[email protected]>
Signed-off-by: Jonathan Cameron <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Message-Id: <[email protected]>
2026-02-20 13:04:45 -05:00
Shiju Jose da5cafdc4d hw/cxl: Add emulation for memory sparing control feature
Memory sparing is defined as a repair function that replaces a portion of
memory with a portion of functional memory at that same DPA. The
subclasses for this operation vary in terms of the scope of the sparing
being performed. The Cacheline sparing subclass refers to a sparing
action that can replace a full cacheline. Row sparing is provided as an
alternative to PPR sparing functions and its scope is that of a single
DDR row. Bank sparing allows an entire bank to be replaced. Rank sparing
is defined as an operation in which an entire DDR rank is replaced.

Memory sparing maintenance operations may be supported by CXL devices
that implement CXL.mem protocol. A sparing maintenance operation requests
the CXL device to perform a repair operation on its media.
For example, a CXL device with DRAM components that support memory sparing
features may implement sparing Maintenance operations.

The host may issue a query command by setting Query Resources flag in the
Input Payload (CXL Spec 3.2 Table 8-120) to determine availability of
sparing resources for a given address. In response to a query request,
the device shall report the resource availability by producing the Memory
Sparing Event Record (CXL Spec 3.2 Table 8-60) in which the Channel, Rank,
Nibble Mask, Bank Group, Bank, Row, Column, Sub-Channel fields are a copy
of the values specified in the request.

During the execution of a sparing maintenance operation, a CXL memory
device:
- May or may not retain data
- May or may not be able to process CXL.mem requests correctly.
These CXL memory device capabilities are specified by restriction flags
in the memory sparing feature readable attributes.

When a CXL device identifies error on a memory component, the device
may inform the host about the need for a memory sparing maintenance
operation by using DRAM event record, where the 'maintenance needed' flag
may set. The event record contains some of the DPA, Channel, Rank,
Nibble Mask, Bank Group, Bank, Row, Column, Sub-Channel fields that
should be repaired. The userspace tool requests for maintenance operation
if the 'maintenance needed' flag set in the CXL DRAM error record.

CXL spec 3.2 section 8.2.10.7.2.3 describes the memory sparing feature
discovery and configuration.

CXL spec 3.2 section 8.2.10.7.1.4 describes the device's memory sparing
maintenance operation feature.

Add emulation for CXL memory device memory sparing control feature
and memory sparing maintenance operation command.

Signed-off-by: Shiju Jose <[email protected]>
Signed-off-by: Jonathan Cameron <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Message-Id: <[email protected]>
2026-02-20 13:04:45 -05:00
Davidlohr Bueso 5e5a86bab8 hw/cxl: Add support for Maintenance command and Post Package Repair (PPR)
This adds initial support for the Maintenance command, specifically
the soft and hard PPR operations on a dpa. The implementation allows
to be executed at runtime, therefore semantically, data is retained
and CXL.mem requests are correctly processed.

Keep track of the requests upon a general media or DRAM event.

Post Package Repair (PPR) maintenance operations may be supported by CXL
devices that implement CXL.mem protocol. A PPR maintenance operation
requests the CXL device to perform a repair operation on its media.
For example, a CXL device with DRAM components that support PPR features
may implement PPR Maintenance operations. DRAM components may support two
types of PPR, hard PPR (hPPR), for a permanent row repair, and Soft PPR
(sPPR), for a temporary row repair. Soft PPR is much faster than hPPR,
but the repair is lost with a power cycle.

CXL spec 3.2 section 8.2.10.7.1.2 describes the device's sPPR (soft PPR)
maintenance operation and section 8.2.10.7.1.3 describes the device's
hPPR (hard PPR) maintenance operation feature.

CXL spec 3.2 section 8.2.10.7.2.1 describes the sPPR feature discovery and
configuration.

CXL spec 3.2 section 8.2.10.7.2.2 describes the hPPR feature discovery and
configuration.

CXL spec 3.2 section 8.2.10.2.1.4 Table 8-60 describes the Memory Sparing
Event Record.

Signed-off-by: Davidlohr Bueso <[email protected]>
Co-developed-by: Shiju Jose <[email protected]>
Signed-off-by: Shiju Jose <[email protected]>
Signed-off-by: Jonathan Cameron <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Message-Id: <[email protected]>
2026-02-20 13:04:45 -05:00
Shiju Jose d2c428ecd4 hw/cxl/cxl-mailbox-utils: Move declaration of scrub and ECS feature attributes in cmd_features_set_feature()
Move the declaration of scrub and ECS feature attributes in
cmd_features_set_feature() to the local scope where they are used.

Signed-off-by: Shiju Jose <[email protected]>
Signed-off-by: Jonathan Cameron <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Message-Id: <[email protected]>
2026-02-20 13:04:45 -05:00
Shiju Jose 1fc57dd250 hw/cxl/events: Updates for rev3.2 memory module event record
CXL spec rev3.2 section 8.2.10.2.1.3 Table 8-59, memory module
event record has updated with following new fields.
1. Validity Flags
2. Component Identifier
3. Device Event Sub-Type

Add updates for the above spec changes in the CXL memory module
event reporting and QMP command to inject memory module event.

Updated all references for this command to the CXL r3.2
specification.

Signed-off-by: Shiju Jose <[email protected]>
Acked-by: Markus Armbruster <[email protected]>
Signed-off-by: Jonathan Cameron <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Message-Id: <[email protected]>
2026-02-20 13:04:45 -05:00
Shiju Jose 94976b8631 hw/cxl/events: Updates for rev3.2 DRAM event record
CXL spec rev3.2 section 8.2.10.2.1.2 Table 8-58, DRAM event record
has updated with following new fields.
1. Component Identifier
2. Sub-channel of the memory event location
3. Advanced Programmable Corrected Memory Error Threshold Event Flags
4. Corrected Volatile Memory Error Count at Event
5. Memory Event Sub-Type

Add updates for the above spec changes in the CXL DRAM event
reporting and QMP command to inject DRAM event.

In order to ensure consistency update all specification references
for this command to CXL r3.2.

Signed-off-by: Shiju Jose <[email protected]>
Acked-by: Markus Armbruster <[email protected]>
Signed-off-by: Jonathan Cameron <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Message-Id: <[email protected]>
2026-02-20 13:04:45 -05:00
Shiju Jose 1aa989a176 hw/cxl/events: Updates for rev3.2 general media event record
CXL spec rev3.2 section 8.2.10.2.1.1 Table 8-57, general media event
table has updated with following new fields.
1. Advanced Programmable Corrected Memory Error Threshold Event Flags
2. Corrected Memory Error Count at Event
3. Memory Event Sub-Type
4. Support for component ID in the PLDM format.

Add updates for the above spec changes in the CXL general media event
reporting and QMP command to inject general media event.

In order to have one consistent source of references, update all to
references for this command to CXL r3.2.

Signed-off-by: Shiju Jose <[email protected]>
Acked-by: Markus Armbruster <[email protected]>
Signed-off-by: Jonathan Cameron <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Message-Id: <[email protected]>
2026-02-20 13:04:45 -05:00
Shiju Jose e5b7d31243 hw/cxl/events: Update for rev3.2 common event record format
CXL spec 3.2 section 8.2.9.2.1 Table 8-55, Common Event Record
format has updated with optional Maintenance Operation Subclass,
LD ID and ID of the device head information.

Add updates for the above optional parameters in the related
CXL events reporting and in the QMP commands to inject CXL events.

Update all related specification references to CXL r3.2 to ensure
one consistent source.

Signed-off-by: Shiju Jose <[email protected]>
Acked-by: Markus Armbruster <[email protected]>
Reviewed-by: Ravi Jonnalagadda <[email protected]>
Signed-off-by: Jonathan Cameron <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Message-Id: <[email protected]>
2026-02-20 13:04:45 -05:00
Shiju Jose 2fc064e23e qapi: cxl: Refactor CXL event injection for common commands arguments
Refactor CXL event injection to use struct for common command
arguments.

Suggested-by: Markus Armbruster <[email protected]>
Signed-off-by: Shiju Jose <[email protected]>
Acked-by: Markus Armbruster <[email protected]>
Reviewed-by: Ravi Jonnalagadda <[email protected]>
Signed-off-by: Jonathan Cameron <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Message-Id: <[email protected]>
2026-02-20 13:04:45 -05:00
Philippe Mathieu-Daudé 843a97fa2c hw/virtio: Pass VirtIODevice* to virtio_reset()
virtio_reset() expects a VirtIODevice pointer, which
is what the single caller - virtio_bus_reset - passes.
Promote the opaque argument to a plain VirtIODevice.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Message-Id: <[email protected]>
2026-02-20 13:04:45 -05:00
Mohamed Mediouni 4d0830ea34 tests/data/acpi: disassemble-aml: rename and change interpreter line
/usr/bin/bash isn't guaranteed to be present. Switch
to /usr/bin/env bash.

Specifically, on Darwin/macOS:

$ which bash
/opt/homebrew/bin/bash

Rename disassemle to disassemble in the same commit (typo fix).

Adapt the correponding message in rebuild-expected-aml.

Signed-off-by: Mohamed Mediouni <[email protected]>
Reviewed-by: Ani Sinha <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Message-Id: <[email protected]>
2026-02-20 13:04:44 -05:00
Yanfeng Liu 27b3708292 audio/virtio-snd: fix latency calc
Media players needs meaningful latency_bytes update but it is
zero now most of the time. This adds stream-wise latency_bytes
calculation so that to improve the situation.

Signed-off-by: Yanfeng Liu <[email protected]>
Reviewed-by: Manos Pitsidianakis <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Message-Id: <[email protected]>
2026-02-20 13:04:44 -05:00
Yodel Eldar fa33e6815e contrib/vhost-user-bridge: Add UDP receive hexdump
vhost-user-bridge debug prints UDP TX hexdumps in its transmit handler,
but does not for receives, even though they are beneficial for testing.
Add an RX hexdump in the receive callback.

To delineate between transmits and receives, also add a debug print
indicating that the program is in the transmit handler.

Reviewed-by: Marc-André Lureau <[email protected]>
Signed-off-by: Yodel Eldar <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Message-Id: <[email protected]>
2026-02-20 13:04:44 -05:00
Yodel Eldar 051364b36b tests/functional/x86_64: Add vhost-user-bridge test
Introduce a functional test of vhost-user-bridge and enter it into
MAINTAINERS under the vhost section.

The test runs vhost-user-bridge as a subprocess, then launches a guest
with four backends: a unix domain socket for vhost-user, a UDP socket, a
user-mode net, and a hubport to hub the UDP and user backends; only the
vhost-user backend is exposed, the rest are deviceless. This
configuration mimics the testing setup described in the initial commit
of vhost-user-bridge in 3595e2eb0a.

The test creates a scratch file containing a hardcoded UUID on the host
and exposes it to the the guest via the tftp parameter of the user
netdev. After the guest invokes tftp to request the file, the test
verifies the transfer by hashsum.

Similarly, the test creates a file with another hardcoded UUID in the
guest. A call to check_http_download() serves the file to the host via
http, whereupon a check of the file hashsum occurs on the host.

Lastly, add the test to the thorough tests suite in meson.build.

Suggested-by: Cédric Le Goater <[email protected]>
Suggested-by: Marc-André Lureau <[email protected]>
Suggested-by: Michael S. Tsirkin <[email protected]>
Suggested-by: Thomas Huth <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Reviewed-by: Marc-André Lureau <[email protected]>
Signed-off-by: Yodel Eldar <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Message-Id: <[email protected]>
2026-02-20 13:04:44 -05:00
Yodel Eldar 42d2c1cc9e tests/vhost-user-bridge: Move to contrib/vhost-user-bridge/
After the introduction of vhost-user-bridge and libvhost-user, we
formed the convention of placing vhost-user daemons in eponymous subdirs
of contrib/. Follow this convention.

Create a contrib/vhost-user-bridge/ directory and move vhost-user-bridge
into it. Extract its build target definition from tests/meson.build into
the new directory, and include its subdir in the root-level meson.build.

Add a section about it in the "vhost-user daemons in contrib" document.

Reviewed-by: Marc-André Lureau <[email protected]>
Signed-off-by: Yodel Eldar <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Message-Id: <[email protected]>
2026-02-20 13:04:44 -05:00
Pierrick Bouvier 396d005e4b contrib/plugins/cpp: use __has_include
This make sure we can include all possible headers without breaking
build for environments missing them. It fixes compilation on openbsd.

We don't want to pollute configure script, as it's really a special case
here to make sure we don't have a compilation regression with
qemu-plugins header.

Tested-by: John Snow <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Pierrick Bouvier <[email protected]>
2026-02-19 12:34:11 -08:00
Helge Deller 9e59b112b6 hw/hppa: Add emulation for the 64-bit A400 server
The A400 machine is the very first 64-bit-only machines which uses the 64-bit
PAT firmware and doesn't support 32-bit PDC any longer.  Long-term goal is to
support the MPE and HP-UX 11iv3 operating systems, which both require a machine
with PAT firmware.

Signed-off-by: Helge Deller <[email protected]>
Reviewed-by: Anton Johansson <[email protected]>
2026-02-19 13:41:21 +01:00
Helge Deller 0a54ee20dd hw/hppa: Require SeaBIOS version 22 for A400 machine
Require at least SeaBIOS version 22 before adding the A400 machine.
This is required, because version 22 adds the A400 machine definition
and provides the necessary 64-bit PAT firmware. All other machines up to
now used only the 32- or 64-bit PDC firmware without the PAT extensions.

Signed-off-by: Helge Deller <[email protected]>
Reviewed-by: Anton Johansson <[email protected]>
2026-02-19 13:41:21 +01:00
Helge Deller 1546dc5204 target/hppa: Update SeaBIOS-hppa to version 22
The new firmware includes support for an A400-44 machine
with initial functional 64-bit PAT PDC support:
- Linux 64-bit kernel runs nicely.
- ODE 2006 works nicely on 715, B160L, and A400, but has problems on C3700.
- MPE and 64-bit HP-UX11 need more work, although HP-UX11 boot up to a crash
  where it reports where it had problems.

Signed-off-by: Helge Deller <[email protected]>
Reviewed-by: Anton Johansson <[email protected]>
2026-02-19 13:41:21 +01:00
Helge Deller 16786eb7bf hw/hppa: Add BMC on 64-bit machines only
Prevent adding the BMC with it's serial ports on 32-bit machines, even
if they have a PCI bus like the B160L. This fixes boot problems with
HP-UX on B160L.

Signed-off-by: Helge Deller <[email protected]>
Fixes: 557bc5260c ("hw/hppa: PCI devices depend on availability of PCI bus")
Cc: [email protected]
Reviewed-by: Anton Johansson <[email protected]>
2026-02-19 13:41:21 +01:00
Peter Maydell 07f97d5da0 Merge tag 'pull-target-arm-20260219' of https://gitlab.com/pm215/qemu into staging
target-arm queue:
 * Allow TCG to emulate CPUs with SME but not SVE
 * Refactorings for single-binary
 * whpx: minor fixes
 * hw/usb/hcd-ohci: Implement frame number overflow event

# -----BEGIN PGP SIGNATURE-----
#
# iQJNBAABCAA3FiEE4aXFk81BneKOgxXPPCUl7RQ2DN4FAmmW5pgZHHBldGVyLm1h
# eWRlbGxAbGluYXJvLm9yZwAKCRA8JSXtFDYM3uukD/9hu74EY24AYHuOog8Kb/xO
# 1WLGKFOa6rcSlSh+bvQ+mVqWXxsFp2sdEWddG7GD5i1ztOv2tcY+cKnvt9GBSaUf
# /SGepqoY8xgUWuDhRwk3tzfssemZC5IK6dSfljhlPlFpRU8ih7nWrsNjg1igK922
# UjYz2r/q+DT19liTOVzQhkl8VT7TvmFVOh3LxZcj0s4tB7E8S6DucWvhT/BYb/HF
# kxNcnsW/TkHuhgKSxqioLnY5WEb28EKVCZHO5GOBhc50l9P/adEQ9Osx/2uSsSir
# flnXbIc8JCOngNTyyF0RE00E14Fkh0EjTL/RB+kS5cqhcIN0NBI4E+JG7cjZ/+3H
# oDY1f+BS47s7Yrqi0yjXiOeM7i4Hcn7R9Kod8NUOalFHDOne0pPusWrK9kGQbnwO
# fnnJ2GCxTPcIG9tYVLqF0v4Wc8pAn5U1i2gK9HcRrUItgO0n7zvU/KBGZAAUW/Z/
# YMgpQaWuGC8mFlhojPQ9I4gCVjLUBt7TwkmdFrdeNmeYSuZfIRBer6uSbr4b+nvi
# VYyZgANiNazGIOZo+vchgHjqUMOkUN8L3bU0W8sFgISd2AEtWLVV1pAQs8XLWvxM
# NFVCBBPcYngMkxMxNB1yC6Mx1JcUwmYOnBEXF9koHIf89RIQhpcQQA6W7zoiME+o
# Do4a6MG6W4MekYVfsEJoJQ==
# =OMZn
# -----END PGP SIGNATURE-----
# gpg: Signature made Thu Feb 19 10:31:52 2026 GMT
# gpg:                using RSA key E1A5C593CD419DE28E8315CF3C2525ED14360CDE
# gpg:                issuer "[email protected]"
# gpg: Good signature from "Peter Maydell <[email protected]>" [ultimate]
# gpg:                 aka "Peter Maydell <[email protected]>" [ultimate]
# gpg:                 aka "Peter Maydell <[email protected]>" [ultimate]
# gpg:                 aka "Peter Maydell <[email protected]>" [ultimate]
# Primary key fingerprint: E1A5 C593 CD41 9DE2 8E83  15CF 3C25 25ED 1436 0CDE

* tag 'pull-target-arm-20260219' of https://gitlab.com/pm215/qemu: (32 commits)
  include/tcg/tcg-op.h: eradicate TARGET_INSN_START_EXTRA_WORDS
  target/arm/tcg/translate.h: replace target_long with int64_t
  target/arm/tcg/translate.h: replace target_ulong with vaddr
  target/arm/tcg/vec_helper.c: make compilation unit common
  target/arm/tcg/cpu-v7m.c: make compilation unit common
  target/arm/tcg/psci.c: make compilation unit common
  target/arm: move exec/helper-* plumbery to helper.h
  tcg: move tcg_use_softmmu to tcg/tcg-internal.h
  target/arm: extract helper-sme.h from helper.h
  target/arm: extract helper-sve.h from helper.h
  target/arm: extract helper-a64.h from helper.h
  target/arm: extract helper-mve.h from helper.h
  target/arm: Don't require helper prototypes in helper.c
  target/arm: Move TCG-specific code out of debug_helper.c
  whpx: fix FP register loop
  whpx: remove duplicate include
  hw/usb/hcd-ohci: Implement frame number overflow event
  target/arm: Permit configurations with SME but not SVE
  target/arm: Squash FEAT_SME_FA64 if FEAT_SVE is not present
  target/arm: Don't squash all ID_AA64ZFR0_EL1 fields for non-SVE
  ...

Signed-off-by: Peter Maydell <[email protected]>
2026-02-19 10:36:06 +00:00
Pierrick Bouvier 10059583c7 include/tcg/tcg-op.h: eradicate TARGET_INSN_START_EXTRA_WORDS
This commit removes TARGET_INSN_START_EXTRA_WORDS and force all arch to
call the same version of tcg_gen_insn_start, with additional 0 arguments
if needed. Since all arch have a single call site (in translate.c), this
is as good documentation as having a single define.

The notable exception is target/arm, which has two different translate
files for 32/64 bits. Since it's the only one, we accept to have two
call sites for this.

As well, we update parameter type to use uint64_t instead of
target_ulong, so it can be called from common code.

Signed-off-by: Pierrick Bouvier <[email protected]>
Message-id: [email protected]
Reviewed-by: Richard Henderson <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
2026-02-19 10:12:25 +00:00
Pierrick Bouvier 596081113b target/arm/tcg/translate.h: replace target_long with int64_t
target_long is used to represent a pc diff. Checked all call sites to
make sure we were already passing signed values, so extending works as
expected.

Use vaddr for pc_curr and pc_save.

Reviewed-by: Richard Henderson <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Pierrick Bouvier <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-02-19 10:12:25 +00:00
Pierrick Bouvier 15500df3b3 target/arm/tcg/translate.h: replace target_ulong with vaddr
Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Pierrick Bouvier <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-02-19 10:12:25 +00:00
Pierrick Bouvier 4ba9234f67 target/arm/tcg/vec_helper.c: make compilation unit common
We need to extract 64 bits helper in a new file (vec_helper64.c), and
extract some macro definition also, since they will be used in both
files.
As well, DO_3OP_PAIR was defined twice, so rename the second variant
to DO_3OP_PAIR_NO_STATUS to reflect what it does.

Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Pierrick Bouvier <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-02-19 10:12:25 +00:00
Pierrick Bouvier 3211199b00 target/arm/tcg/cpu-v7m.c: make compilation unit common
Reviewed-by: Richard Henderson <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Pierrick Bouvier <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-02-19 10:12:25 +00:00
Pierrick Bouvier 3580aa0354 target/arm/tcg/psci.c: make compilation unit common
Now that helper.h does not contain TARGET_AARCH64 identifier, we can
move forward with this file.

Reviewed-by: Richard Henderson <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Pierrick Bouvier <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-02-19 10:12:25 +00:00
Pierrick Bouvier bfc57f037d target/arm: move exec/helper-* plumbery to helper.h
Since we cleaned helper.h, we can continue further and remove
all exec/helper-* inclusion. This way, all helpers use the same pattern,
and helper include details are limited to those headers.

Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Pierrick Bouvier <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-02-19 10:12:25 +00:00
Pierrick Bouvier 9085154835 tcg: move tcg_use_softmmu to tcg/tcg-internal.h
In next commit, we'll apply same helper pattern for base helpers
remaining.

Our new helper pattern always include helper-*-common.h, which ends up
including include/tcg/tcg.h, which contains one occurrence of
CONFIG_USER_ONLY.
Thus, common files not being duplicated between system and target
relying on helpers will fail to compile. Existing occurrences are:
- target/arm/tcg/arith_helper.c
- target/arm/tcg/crypto_helper.c

This occurrence of CONFIG_USER_ONLY is for defining variable
tcg_use_softmmu, and we rely on dead code elimination with it in various
tcg-target.c.inc.

Thus, move its definition to tcg/tcg-internal.h, so helpers can be
included by common files. Also, change it to a define, as it has fixed
values for now.

Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Pierrick Bouvier <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-02-19 10:12:25 +00:00
Pierrick Bouvier 27031a759d target/arm: extract helper-sme.h from helper.h
Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Pierrick Bouvier <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-02-19 10:12:25 +00:00
Pierrick Bouvier af4ff26d4d target/arm: extract helper-sve.h from helper.h
Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Pierrick Bouvier <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-02-19 10:12:25 +00:00
Pierrick Bouvier 903a87216c target/arm: extract helper-a64.h from helper.h
Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Pierrick Bouvier <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-02-19 10:12:25 +00:00
Pierrick Bouvier 7811dd39a6 target/arm: extract helper-mve.h from helper.h
A few points to mention:
- We mix helper prototypes and gen_helper definitions in a single header
for convenience and to avoid headers boilerplate.
- We rename existing tcg/helper-mve.h to helper-mve-defs.h to avoid
conflict when including helper-mve.h.
- We move mve helper_info definitions to tcg/mve_helper.c

We'll repeat the same for other helpers.
This allow to get rid of TARGET_AARCH64 in target/arm/helper.h.

Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Pierrick Bouvier <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-02-19 10:12:25 +00:00
Peter Maydell fefb9baf11 target/arm: Don't require helper prototypes in helper.c
In arm_cpu_do_interrupt_aarch64() we call the TCG helper function
helper_rebuild_hflags_a64(), which requires helper.c to include the
TCG helper function prototypes even when this file is being compiled
with TCG disabled.

We don't actually need to do this -- because we have already written
the new EL into pstate and updated env->aarch64, we can call
aarch64_rebuild_hflags() to achieve the same effect. This is the
function we use everywhere else in this file to update hflags.

Switch to aarch64_rebuild_hflags() and drop the include of the
TCG helper headers.

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Pierrick Bouvier <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-02-19 10:12:25 +00:00
Peter Maydell 7bea97639e target/arm: Move TCG-specific code out of debug_helper.c
The target/arm/debug_helper.c file has some code which we need
for non-TCG accelerators, but quite a lot which is guarded by
a CONFIG_TCG ifdef. Move all this TCG-only code out to a
new file target/arm/tcg/debug.c.

In particular all the code requiring access to the TCG
helper function prototypes is in the moved code, so we can
drop the use of tcg/helper.h from debug_helper.c.

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Pierrick Bouvier <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-02-19 10:12:25 +00:00
Peter Maydell 53af6529b1 Merge tag 'pull-vfio-20260218' of https://github.com/legoater/qemu into staging
vfio queue:

* Improves VFIO region mmap alignment for hugepfnmap support on
  Grace-based systems (GB200)
* Documents vfio_device_get_region_info() API
* Adds a new VFIO_MIGRATION event notifying PRE_COPY_P2P transition

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCAAdFiEEoPZlSPBIlev+awtgUaNDx8/77KEFAmmVxcMACgkQUaNDx8/7
# 7KGOLw//XyKW5Xuyo6nqsTYbukHEa2LGkQ4IkdLiJm5lVdXl86G23e0N+PzA+Ukr
# hjSUysTHjrmEds53x57yYGfn+cLtGgxC7IWETDcMpBYtzs5hIgEpmkeTb0mTghc1
# U4U99xdDcN33ASt7kPfYrOXOBPKWcfZd+Ut/UW9H8qm+RPu8I63khh7t6OG7uMdf
# 7QJZ2cfaNTR9fSQb15/1YsMcHn4lyQG03fpbhueKA+tC08I+FHp6OCYIbZJrdk3E
# L+XRtZgeUow5o63cG8zBIZuhci4B9J8Di/tMmldZOOF6xq0rKL/0yzKt1ifuTiTx
# G25OeoVnXcBYGJd+f9wcSREslNjSqUrfnz8Z5+WUJLUZ9Jy2ugiyQUiS/d9eqrr3
# p7GDE+GfykvjNS2MD2vW34yg5AhrJSP97InrUpq+p/Ed4WWdfk0oED1I6NRJeEmo
# URPAHbSVPCSTh0GQMbop73+gQibee5PTd9Fg7CUoEPXYvt9nTWSuUycMfWPzLa/C
# +AdOXA42ocP6TZaS4/XGLmT4KeVxf/uYoBe/iWD0FJ8uvQ2fvZ71llsmMMk6ju17
# 3NiUHZqypWBhSpMkSDBY6fmtGaLy9NwzEwRy9XGMET8o4tyq/T4fr7/aHqsM6IN6
# EZx7hXffQ3rjY72P32esimVOa/FnXbc6JbDBkfP2iXf3FIIJZD8=
# =9FKA
# -----END PGP SIGNATURE-----
# gpg: Signature made Wed Feb 18 13:59:31 2026 GMT
# gpg:                using RSA key A0F66548F04895EBFE6B0B6051A343C7CFFBECA1
# gpg: Good signature from "Cédric Le Goater <[email protected]>" [full]
# gpg:                 aka "Cédric Le Goater <[email protected]>" [full]
# Primary key fingerprint: A0F6 6548 F048 95EB FE6B  0B60 51A3 43C7 CFFB ECA1

* tag 'pull-vfio-20260218' of https://github.com/legoater/qemu:
  vfio: Document vfio_device_get_region_info()
  hw/vfio: align mmap to power-of-2 of region size for hugepfnmap
  vfio: Add Error ** parameter to vfio_region_setup()
  hw/vfio: sort and validate sparse mmap regions by offset
  vfio/migration: Send VFIO_MIGRATION event before PRE_COPY_P2P transition

Signed-off-by: Peter Maydell <[email protected]>
2026-02-19 09:37:09 +00:00
Peter Maydell 021e68ea63 Merge tag 'qga-pull-2026-02-16-2' of https://github.com/kostyanf14/qemu into staging
qga-pull-2026-02-16-2

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCgAdFiEEwsLBCepDxjwUI+uE711egWG6hOcFAmmVjNEACgkQ711egWG6
# hOeDqQ/+L0jk9fXV8trbQ+J+b82AGrx+pMy9MWIppitO3xxqP0Z6RBh/F3iPLL0j
# 9vDzjL80R52gfH2o2n4jp0krBtUglieRr9Z+/Ttl6UiJvXHhCGYOf5ooifXsn1zH
# Le84BV9qtax9kHeYgqQ6FRUpZ+qThVGpbbnMwlRgeKF8mZBUiLFOOO8P9FZ9djBg
# Ysu8wpxr40YE7WhU9w1HCoegMLwdnb9TID9Oc6y0LHqdeW/5ap/RacbxKicXswQ3
# sJK8n+g0Z4Xo63NJye3ygHshLsQTQRcZOyVgdn9G9OZWjnBQ0Fzwcc9megTTcVAD
# Gd5avRvDj+iMSIb/dRzBcxSrKNwM/XC31awGgOna/UFsZlnz0oL3cFkdzCo3FHiM
# CV+z36tAJT5b2qepVMEnPuW1TtcYknzrqSRNK9TfTROdEmKqECRvweAbGfgDx6aK
# Fuiah2XoBCShy4SQF3Z4lEaAZyKMz90Mhmf9PrzG+QOZgPSJtuF4XQvV37BKr+8b
# 7V82DuIucdEoQvAedtiZueXH/8moN0L1MRrqxBjOk/g8AozOQD8Pykgg7cuRuA39
# dK/seTVIdP4YAPVGfcq/lwXuOAbx/0Hmwku5O59mSp6OC7UDWFeenbKzOq0U4cgr
# 1r4a4bGuSvusFGOfflKdWUMcDMlLWKOva9pDoywJsoRHdbfDrFU=
# =lIXl
# -----END PGP SIGNATURE-----
# gpg: Signature made Wed Feb 18 09:56:33 2026 GMT
# gpg:                using RSA key C2C2C109EA43C63C1423EB84EF5D5E8161BA84E7
# gpg: Good signature from "Kostiantyn Kostiuk (Upstream PR sign) <[email protected]>" [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: C2C2 C109 EA43 C63C 1423  EB84 EF5D 5E81 61BA 84E7

* tag 'qga-pull-2026-02-16-2' of https://github.com/kostyanf14/qemu:
  qga: Fix VSS provider GetSnapshotProperties return value
  qga: Move CoInitialize/CoInitializeSecurity to main process thread
  qga: implement guest-network-get-route for Windows

Signed-off-by: Peter Maydell <[email protected]>
2026-02-19 09:13:49 +00:00
Peter Maydell 71033fea46 Merge tag 'firmware-20260218-pull-request' of https://gitlab.com/kraxel/qemu into staging
- firmware json spec update
- igvm update

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCgAdFiEEoDKM/7k6F6eZAf59TLbY7tPocTgFAmmVf24ACgkQTLbY7tPo
# cTj4qQ//e2e0FIRPFMgEeXLxB3z/ITGFIfRc6UczVHc37mG2GvwOFIFpWnuDtsOR
# LBAmYjJ8daBP5QjtGn//L+TYDDBNpKoxT8asDqSMH898jJpUMI1PaJOS7e+b7uoC
# SuF81yCMQLUrq2medbeaNNar1gFskbMIGxdre/Rc+HGI7bxtYlTfOiFO6WC74HHV
# GHkcPrzeXlOBiy7rxL17viAaVncNw7r8UFExU+DvaLNrcjT8zNKb1CnMQ22hAv9c
# WEH1lyCKjBRqjcXZZSEXre0KKy6BM5/YmdPjI2/l26KnL8NKMXqDAwIYXdKkqbDI
# bBSr8mMmrYMDiBlCHnhr/5X3UaeyNCkyi492U/iAJX7OqnFQQMc11C/LTHg3YmFG
# eA3+KgMntA5esjjRHKa6LKIyW5Wl67iVVZYO6zzTV5NHaT87806Kltdjau/WjRQM
# j1GYxoRC2tP9Mlim9Qx+v5LY+HD3dNF4Bv+RvsEYWSFNlMdhqgfFQCwSx8XUlX9C
# Bw4HlO8+Y6cYbksn4b44e+Y7SLExyvGmA2Rh1JktSAb8wNf8iIsLbbwUwJvLmKpt
# ZX6PLWRe9mjjx2ElcyMeALRfbo84oWz3J5p6pUBroHF6YSbct3jsndMbk/yMHxbr
# 0jTAqdUABdZOFYPldw7pLi17kRqygXMV5ulF7ia210ZU7IrtUa4=
# =lACA
# -----END PGP SIGNATURE-----
# gpg: Signature made Wed Feb 18 08:59:26 2026 GMT
# gpg:                using RSA key A0328CFFB93A17A79901FE7D4CB6D8EED3E87138
# gpg: Good signature from "Gerd Hoffmann (work) <[email protected]>" [full]
# gpg:                 aka "Gerd Hoffmann <[email protected]>" [full]
# gpg:                 aka "Gerd Hoffmann (private) <[email protected]>" [full]
# Primary key fingerprint: A032 8CFF B93A 17A7 9901  FE7D 4CB6 D8EE D3E8 7138

* tag 'firmware-20260218-pull-request' of https://gitlab.com/kraxel/qemu:
  docs/interop/firmware: Add 'uefi-vars' member for FirmwareMappingMemory
  igvm: Add NULL checks for igvm_get_buffer()

Signed-off-by: Peter Maydell <[email protected]>
2026-02-19 09:13:38 +00:00
Osama Abdelkader 2755af839e whpx: fix FP register loop
In whpx_get_registers and whpx_set_registers the loops over FP registers
were using whpx_reg_match[i].reg instead of whpx_fpreg_match[i].reg

Signed-off-by: Osama Abdelkader <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Mohamed Mediouni <[email protected] <mailto:[email protected]>>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-02-18 18:42:59 +00:00
Osama Abdelkader 4a22c50d4a whpx: remove duplicate include
cpu.h is included twice

Signed-off-by: Osama Abdelkader <[email protected]>
Message-id: [email protected]
Reviewed-by: Peter Maydell <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
2026-02-18 18:41:49 +00:00
BALATON Zoltan 1b33ed1689 hw/usb/hcd-ohci: Implement frame number overflow event
According to the USB OHCI specification section 6.5.6
("FrameNumberOverflow Event"), when bit 15 of the frame count changes
(either from 1 to 0 or 0 to 1) a FrameNumberOverflow interrupt should
be generated.

This fixes usb-audio on mac99,via=pmu with MacOS 9.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3274
Signed-off-by: BALATON Zoltan <[email protected]>
Tested-by: Elisey Konstantinov <[email protected]>
Message-id: [email protected]
[PMM: added brief comment, tweaked commit message]
Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
2026-02-18 18:40:14 +00:00
Peter Maydell a0660e2b2d target/arm: Permit configurations with SME but not SVE
In commit f7767ca301 ("target/arm: Disable SME if SVE is disabled")
we added code that forces SME to be disabled if SVE is disabled.
This was something we did in the run-up to a release to avoid an
assertion failure in smcr_write() if the user disabled SVE on the
'max' CPU without disabling SME also.

Now that we have corrected the code so that it doesn't assert
in an SME-without-SVE setup, we can let users select it.

This effectively reverts f7767ca301.

Note that this now means that command lines like "-cpu max,sve=off"
which used to turn off SME and SVE will now give you a CPU with SME
but not SVE.  This is permitted by our loose "max can always give you
extra stuff" rules, but may be unexpected to users.  Mention this in
the CPU property documentation.

Reviewed-by: Richard Henderson <[email protected]>
Reviewed-by: Alex Bennée <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
Message-id: [email protected]
2026-02-18 18:40:14 +00:00
Peter Maydell c38e9dc3b6 target/arm: Squash FEAT_SME_FA64 if FEAT_SVE is not present
FEAT_SME_FA64 allows Streaming SVE code to access the whole
SVE instruction set; it requires FEAT_SVE to be present. If
we have a CPU with SME but not SVE, squash the FA64 bit in
arm_cpu_sme_finalize().

This doesn't have any effect at the moment because we don't
let the user create an SME-without-SVE CPU, but we are about
to lift that restriction.

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-id: [email protected]
2026-02-18 18:40:14 +00:00
Peter Maydell 8952556536 target/arm: Don't squash all ID_AA64ZFR0_EL1 fields for non-SVE
The ID register ID_AA64ZFR0_EL1's fields are not all for SVE
exclusive features; some are also used to describe SME on an
SME-only CPU:

SVE-only fields:
 * F64MM, F32MM, F16MM, SM4, B16B16, SVEVer

Fields used for SVE and SME (in some cases there is also a
field for SME in ID_AA64SMFR0_EL1, but it is just a "present
or absent" single bit flag and the ZFR0 field then tells you
what level of support is present):
 * I8MM, SHA3, BF16, BitPerm, EltPerm, AES

Currently we zero the whole ID_AA64ZFR0_EL1 register in
arm_cpu_sve_finalize() if SVE is not present, which wipes also the
fields we need for SME.  Only clear the fields which are SVE-specific
here, and clear the rest in arm_cpu_sme_finalize() if we
have neither SME nor SVE.

This requires us to update our ID_AA64ZFR0 field definitions
to match the rev M.a.a Arm ARM, as the F16MM SVE-only field
is not one we had a definition for previously.

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-id: [email protected]
2026-02-18 18:40:14 +00:00
Peter Maydell 3c10637790 target/arm/tcg: Correct SVE/SME BF16 checks
As with I8MM, the BF16 field of ID_AA64ZFR0_EL1 is set when the
CPU implements FEAT_BF16 and either FEAT_SVE or FEAT_SME, so
we need to have separate checks for "(SVE || SME) && BF16"
and "SVE && BF16". Follow the same pattern as with I8MM:

 * aa64_sve_sme_bf16 means (SVE || SME) && BF16
 * aa64_sve_bf16 means (SVE && BF16)

BFMMLA is the only SVE BF16 insn that isn't in SME.

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-id: [email protected]
2026-02-18 18:40:14 +00:00
Peter Maydell 5ca3420055 target/arm/tcg: Correct SVE/SME I8MM checks
The I8MM field of ID_AA64ZFR0_EL1 is set when the CPU implements
FEAT_I8MM and either FEAT_SVE or FEAT_SME. Currently we assume
that it is only set for FEAT_SVE. Update the feature checks:
 * we rename the existing feature check function to sve_sme_i8mm
   to indicate that it is true for either SVE or SME I8MM
 * we add a new check function for FEAT_SVE && FEAT_I8MM (giving
   it the sve_i8mm name that the old function used to have)
 * the instructions which are (SVE || SME) && I8MM need their
   checks updating to sve_sme_i8mm: these are SUDOT, USDOT
 * instructions which are SVE && I8MM (i.e. really SVE-only) stay
   unchanged with sve_i8mm: these are SMMLA, USMMLA, UMMLA

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-id: [email protected]
2026-02-18 18:40:14 +00:00
Peter Maydell 895d4367d6 target/arm/tcg: Use "or SME" feature checks where needed
Many SVE instructions should be provided where the CPU implements
either SVE or SME. Currently we largely check only for features
aa64_sve or aa64_sve2. This happens to work because we forbid
creation of a CPU with SME but not SVE. To allow users to create
SME-only CPUs we need to update the conditions to use the "or SME"
versions of the feature tests instead.

This commit was created by going through translate-sve.c from
top to bottom looking for aa64_sve feature tests and cross
checking those against the instruction descriptions in the Arm ARM,
which will say "(FEAT_SVE || FEAT_SME)" for instructions that
are provided for both features, and "(FEAT_SME)" for the rarer
instructions that are SME only.

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-id: [email protected]
2026-02-18 18:40:14 +00:00
Peter Maydell e69bddfc75 target/arm/tcg: Drop unnecessary aa64_sve check from do_trans_pmull()
Part of the logic inside do_trans_pmull() applies the aa64_sve
feature check for the non-128-bit-element versions of these insns
(PMULLB and PMULLT).  This is currently a redundant check because we
only invoke this function via the macro invocation
 TRANS_FEAT(..., aa64_sve2, do_trans_pmull, ...)
and it's actively wrong for an SME-only CPU, because these insns
are also available via SME. Remove the unnecessary logic.

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-id: [email protected]
2026-02-18 18:40:14 +00:00
Peter Maydell e868257fe6 target/arm: Add aa64_sme_or_sve, aa64_sme_or_sve2 features
With FEAT_SME, even a CPU which does not implement FEAT_SVE is
allowed to execute the subset of SVE instructions which are permitted
in streaming SVE mode.  We correctly handle this when the emulated
CPU has both FEAT_SVE and FEAT_SME, because sve_access_check()
includes the logic for this, matching the pseudocode
CheckSVEEnabled().  However if the emulated CPU only implement
FEAT_SME, it will fail the initial dc_isar_feature(aa64_sve, s)
feature check, because this doesn't match the check in the
per-instruction decode pseudocode, which is typically:

 !IsFeatureImplemented(FEAT_SVE) && !IsFeatureImplemented(FEAT_SME)

Add a new aa64_sme_or_sve feature function that we can use
to update the relevant uses of aa64_sve, and similarly
aa64_sme_or_sve2 for where we need to check FEAT_SVE2 || FEAT_SME.

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-id: [email protected]
2026-02-18 18:40:14 +00:00
Peter Maydell 5801dc1b3b target/arm: Handle SME-without-SVE on change of EL
aarch64_sve_change_el() currently assumes that SME implies
SVE, and will return without doing anything if SVE is not
implemented, skipping a possible requirement to change
the vector register state because the SME vector length
has changed. Update it to handle SME also.

Reviewed-by: Richard Henderson <[email protected]>
Reviewed-by: Alex Bennée <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-id: [email protected]
2026-02-18 18:40:14 +00:00
Peter Maydell 8a21e4e278 target/arm: Handle SME-only CPUs in sve_vqm1_for_el_sm()
In sve_vqm1_for_el_sm(), we implicitly assume that the CPU has SVE:
if called with sm == false for non-streaming mode, we try to return a
vector length from svq_vq.  This hits the "assert(sm)" at the bettom
of the function in an SME-only CPU where sve_vq.map is zero.

Add code to handle the "SME-only CPU not in streaming mode" case: we
report an effective VL of 128 bits, which is what the architecture
rule R_KXKNK says should be used when SVE instructions are disabled
or trapped but floating point instructions are enabled.

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Alex Bennée <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-id: [email protected]
2026-02-18 18:40:14 +00:00
Peter Maydell aeb3c147fc target/arm: Don't let 'sme=on' downgrade SME
In our handling of the boolean 'sme' CPU property, we write this 0/1
value directly to ID_AA64PFR1_EL1.SME.  This worked when the only
valid values in that field were 0 (for no SME) and 1 (for SME1).
However, with the addition of SME2 the SME field can now also read 2.
This means that "-cpu max,sme=on" will result in an inconsistent set
of ID registers, where ID_AA64PFR1_EL1.SME claims SME1 but
ID_AA64SMFR0_EL1.SMEver claims SME2p1.  This isn't a valid thing to
report, and confuses Linux into reporting SME2 to userspace but not
actually enabling userspace access for it.

Fix this bug by having arm_cpu_sme_finalize() fix up the
ID_AA64PFR1_EL1.SME field to match ID_AA64SMFR0.SMEver.  This means
the "sme" property's semantics are "off" for "no SME" and "on" for
"enable at whatever the default SME version this CPU provides is".

Update the documentation to clarify what 'sve=on' and 'sme=on' do.
(We don't have the equivalent bug for 'sve=on' because
ID_AA64PFR0_EL1.SVE only has 0 and 1 as valid values, but the
semantics of the property are the same.)

Cc: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Reviewed-by: Manos Pitsidianakis <[email protected]>
Message-id: [email protected]
2026-02-18 18:40:13 +00:00
Peter Maydell 433097a224 target/arm/tcg: Allow SVE RAX1 in SME2p1 streaming mode
The SVE RAX1 instruction is permitted in SME streaming mode starting
from SME2p1.  We forgot to allow this relaxation when we implemented
SME2p1.

Cc: [email protected]
Fixes: 7b1613a102 ("target/arm: Enable FEAT_SME2p1 on -cpu max")
Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-id: [email protected]
2026-02-18 18:40:13 +00:00
Peter Maydell ee5bf0962e target/arm: Fix feature check in DO_SVE2_RRX, DO_SVE2_RRX_TB
In the macros DO_SVE2_RRX and DO_SVE2_RRX_TB we use the
feature check aa64_sve, thus exposing this set of instructions
in SVE as well as SVE2. Use aa64_sve2 instead, so they UNDEF
on an SVE1-only CPU as they should.

Strictly, the condition here should be "SVE2 or SME"; but we
will correct that in a following commit with all the other
missing "or SME" checks.

Cc: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Reviewed-by: Manos Pitsidianakis <[email protected]>
Message-id: [email protected]
2026-02-18 18:40:13 +00:00
Peter Maydell 05f32d2584 target/arm: Report correct vector width in gdbstub when SME present
Our gdbstub implementation of the org.gnu.gdb.aarch64.sve feature
doesn't account for SME correctly.  We always report the Zn vector
registers with a width based on the maximum SVE vector register size,
even though SME's maximum size could be larger.

This is particularly bad in the case of a CPU with SME but not SVE,
because there the SVE vector width will be zero.  If we report the Zn
registers in the XML as having a zero width then gdb falls over with
an internal error:

 (gdb) target remote :1234
 Remote debugging using :1234
 /build/gdb-1WjiBe/gdb-15.0.50.20240403/gdb/aarch64-tdep.c:3066: internal-error: aarch64_pseudo_register_type: bad register number 160
 A problem internal to GDB has been detected,
 further debugging may prove unreliable.

Report the Zn registers with their correct size.  This matches how we
already handle the 'vg' pseudoregister in org.gnu.gdb.aarch64.sve: we
call sve_vqm1_for_el(), which returns the vector size accounting for
SME, not the pure SVE vector size.

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Alex Bennée <[email protected]>
Message-id: [email protected]
2026-02-18 18:40:13 +00:00
Peter Maydell 42eab40a12 target/arm: Account for SME in aarch64_sve_narrow_vq() assertion
In aarch64_sve_narrow_vq() we assert that the new VQ is within
the maximum supported range for the CPU. We forgot to update
this to account for SME, which might have a different maximum.

Update the assert to permit any VQ which is valid for either
SVE or SME.

Cc: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Alex Bennée <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-id: [email protected]
2026-02-18 18:40:13 +00:00
Vivek Kasireddy 9757da8951 vfio: Document vfio_device_get_region_info()
Add documentation for vfio_device_get_region_info() and clarify the
expectations around its usage.

Cc: Alex Williamson <[email protected]>
Cc: Cédric Le Goater <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Signed-off-by: Vivek Kasireddy <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-02-18 10:55:30 +01:00
Ankit Agrawal 3863e47828 hw/vfio: align mmap to power-of-2 of region size for hugepfnmap
On Grace-based systems such as GB200, device memory is exposed as a
BAR but the actual mappable size is not power-of-2 aligned. The
previous algorithm aligned each sparse mmap area based on its
individual size using ctz64() which prevented efficient huge page
usage by the kernel.

Adjust VFIO region mapping alignment to use the next power-of-2 of
the total region size and place the sparse subregions at their
appropriate offset. This provides better opportunities to get huge
alignment allowing the kernel to use larger page sizes for the VMA.

This enables the use of PMD-level huge pages which can significantly
improve memory access performance and reduce TLB pressure for large
device memory regions.

With this change:
- Create a single aligned base mapping for the entire region
- Change Alignment to be based on pow2ceil(region->size), capped at 1GiB
- Unmap gaps between sparse regions
- Use MAP_FIXED to overlay sparse mmap areas at their offsets

Example VMA for device memory of size 0x2F00F00000 on GB200:

Before (misaligned, no hugepfnmap):
ff88ff000000-ffb7fff00000 rw-s 400000000000 00:06 727                    /dev/vfio/devices/vfio1

After (aligned to 1GiB boundary, hugepfnmap enabled):
ff8ac0000000-ffb9c0f00000 rw-s 400000000000 00:06 727                    /dev/vfio/devices/vfio1

Requires sparse regions to be sorted by offset (done in previous
patch) to correctly identify and handle gaps.

cc: Alex Williamson <[email protected]>
Reviewed-by: Alex Williamson <[email protected]>
Reviewed-by: Shameer Kolothum <[email protected]>
Suggested-by: Jason Gunthorpe <[email protected]>
Signed-off-by: Ankit Agrawal <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-02-18 10:55:13 +01:00
Ankit Agrawal c42010197e vfio: Add Error ** parameter to vfio_region_setup()
Add an Error **errp parameter to vfio_region_setup() and
vfio_setup_region_sparse_mmaps to allow proper error handling
instead of just returning error codes.

The function sets errors via error_setg() when failure occur.

Suggested-by: Cedric Le Goater <[email protected]>
Signed-off-by: Ankit Agrawal <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-02-18 10:55:13 +01:00
Ankit Agrawal da02b21cc7 hw/vfio: sort and validate sparse mmap regions by offset
Sort sparse mmap regions by offset during region setup to ensure
predictable mapping order, avoid overlaps and a proper handling
of the gaps between sub-regions.

Add validation to detect overlapping sparse regions early during
setup before any mapping operations begin.

The sorting is performed on the subregions ranges during
vfio_setup_region_sparse_mmaps(). This also ensures that subsequent
mapping code can rely on subregions being in ascending offset order.

This is preparatory work for alignment adjustments needed to support
hugepfnmap on systems where device memory (e.g., Grace-based systems)
may have non-power-of-2 sizes.

cc: Alex Williamson <[email protected]>
Reviewed-by: Alex Williamson <[email protected]>
Reviewed-by: Shameer Kolothum <[email protected]>
Signed-off-by: Ankit Agrawal <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-02-18 10:55:13 +01:00
Avihai Horon 5ab3bce0f3 vfio/migration: Send VFIO_MIGRATION event before PRE_COPY_P2P transition
The VFIO_MIGRATION event notifies users when a VFIO device transitions
to a new state.

One use case for this event is to prevent timeouts for RDMA connections
to the migrated device. In this case, an external management application
(not libvirt) consumes the events and disables the RDMA timeout
mechanism when receiving the event for PRE_COPY_P2P state, which
indicates that the device is non-responsive.

This is essential because RDMA connections typically have very low
timeouts (tens of milliseconds), which can be far below migration
downtime.

However, under heavy resource utilization, the device transition to
PRE_COPY_P2P can take hundreds of milliseconds to complete. Since the
VFIO_MIGRATION event is currently sent only after the transition
completes, it arrives too late, after RDMA connections have already
timed out.

To address this, send an additional "prepare" event immediately before
initiating the PRE_COPY_P2P transition. This guarantees timely event
delivery regardless of how long the actual state transition takes.

Signed-off-by: Avihai Horon <[email protected]>
Acked-by: Markus Armbruster <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-02-18 10:54:57 +01:00
Elizabeth Ashurov 374f467678 qga: Fix VSS provider GetSnapshotProperties return value
GetSnapshotProperties() returned VSS_E_OBJECT_NOT_FOUND causing
"Snapshot id not found" errors during VSS operations.

Any error in this function causes a similar error in Windows VSS,
so we must return S_OK there.

Signed-off-by: Elizabeth Ashurov <[email protected]>
Reviewed-by: Kostiantyn Kostiuk <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Kostiantyn Kostiuk <[email protected]>
2026-02-18 11:27:57 +02:00
Elizabeth Ashurov 0257ec9905 qga: Move CoInitialize/CoInitializeSecurity to main process thread
Problem:
Two issues with COM initialization:

Issue #1: Incorrect call order
- requester_init() called CoInitializeSecurity first
- Per Microsoft documentation, CoInitialize() must be called BEFORE
  CoInitializeSecurity()

Issue #2: Incorrect call location
- CoInitializeSecurity was called from dll instead of the main process
- Per Microsoft documentation, CoInitializeSecurity() must be called exactly once per process from
  the main executable, not from a DLL

Reference:
https://learn.microsoft.com/en-us/windows/win32/api/combaseapi/nf-combaseapi-coinitializesecurity
https://learn.microsoft.com/en-us/windows/win32/api/objbase/nf-objbase-coinitialize

This caused incorrect COM initialization, preventing VSS Writers from
calling back via IVssWriterCallback (hr = 0x80070005, Access denied,
Event ID 8194).

Fix:
- Initialize COM in main.c for both service and CLI modes
- Call CoInitialize() followed by CoInitializeSecurity() in correct order
  in the main thread before any VSS operations
- Add proper CoUninitialize() cleanup

Result:
VSS Writers can now successfully call back to the agent. Event ID 8194
error is resolved.

Signed-off-by: Elizabeth Ashurov <[email protected]>
Reviewed-by: Kostiantyn Kostiuk <[email protected]>
Tested-by: Dehan Meng <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Kostiantyn Kostiuk <[email protected]>
2026-02-18 11:27:57 +02:00
Elizabeth Ashurov 595a77289d qga: implement guest-network-get-route for Windows
Add Windows implementation of guest-network-get-route command to provide
network routing information on Windows guests.

Features implemented:
- IPv4 and IPv6 route information retrieval using GetIpForwardTable2
- Human-readable interface names via GetAdaptersAddresses
- Proper route metrics combining route and interface metrics
- MTU information for network interfaces
- Support for destination, gateway, mask, and metric fields for IPv4
- Support for destination, nexthop, and desprefixlen fields for IPv6

Implementation uses modern Windows IP Helper API (GetIpForwardTable2,
GetIfEntry2).

Signed-off-by: Elizabeth Ashurov <[email protected]>
Reviewed-by: Kostiantyn Kostiuk <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Kostiantyn Kostiuk <[email protected]>
2026-02-18 11:27:55 +02:00
Peter Maydell 314f2d7fe6 Merge tag 'qtest-20260217-pull-request' of https://gitlab.com/farosas/qemu into staging
QTest pull request

- RISCV IOMMU test

# -----BEGIN PGP SIGNATURE-----
#
# iQJEBAABCAAuFiEEqhtIsKIjJqWkw2TPx5jcdBvsMZ0FAmmUlLMQHGZhcm9zYXNA
# c3VzZS5kZQAKCRDHmNx0G+wxnW3eEACAR/RJWKbxQM2O0M4QS5BKtryaI5y7CMb5
# VwovTOVwzs1WsV3eve5Q6y6vcGIjgp7Q53I5l9pvzLB4IcXG+RG5l9lP8AcEctvn
# KyY6dPD8FmXLmhYOrnyXDNkfS72g9ELfsccm8prJi3Xeo7yXVJf7e+sPE3YVPBPa
# 8YfIlgkVWDy2OfrM7kd4SaCoNevs2jMlhqdzXxg6KZNBx51wX2knDYGSenWFyL//
# 0YgRGnMSprLJgWHrddU4dQe+knpOZWHPqZuq9eSoAVO+k6i0+znwEoCqQNRssYhI
# Hgu5/A/NdAbOQiktEKGjjgMX8XDo5fq4BklLaGeziGwjgsflK9M1VSttgJUHgCOr
# aR216kclzi+dDxqNNS7hWack0OjhnHYErDcbAyYdTkm5kCE1h6Co2t0rZIVZZBW6
# sGiF1rMLjJvSC34v29hJCEmbDcW1w2fEAb14ntrbov+XKhsgwtE74H7sj81hLJzQ
# rfIqwn3cjTtGfMXuc0fK4vqSjmPfkZse4/b68fJAaduV9A7bof1HId+k82tMO69v
# ZtLhWsk8dSJmRNDM1gzeOPB2TDunX+i54AJboa7G0DMpPA8VGxvoVygdhC9GSfu0
# rXpPkywjcvX6sUIkoUi7KGAREjH+vH8pUbVVisbLI9kt3ovaj60R8S+dySQCEhBl
# ZKmy8EAeEg==
# =jkva
# -----END PGP SIGNATURE-----
# gpg: Signature made Tue Feb 17 16:17:55 2026 GMT
# gpg:                using RSA key AA1B48B0A22326A5A4C364CFC798DC741BEC319D
# gpg:                issuer "[email protected]"
# gpg: Good signature from "Fabiano Rosas <[email protected]>" [unknown]
# gpg:                 aka "Fabiano Almeida Rosas <[email protected]>" [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: AA1B 48B0 A223 26A5 A4C3  64CF C798 DC74 1BEC 319D

* tag 'qtest-20260217-pull-request' of https://gitlab.com/farosas/qemu:
  tests/qtest: Add RISC-V IOMMU bare-metal test
  tests/qtest/libqos: Add RISC-V IOMMU helper library

Signed-off-by: Peter Maydell <[email protected]>
2026-02-17 16:46:05 +00:00
Peter Maydell d823652366 Merge tag 'migration-20260217-pull-request' of https://gitlab.com/farosas/qemu into staging
Migration pull request

- Notifier changes: Remove duplicated events during postcopy. Emit
  MIG_EVENT_FAILED before the VM is started.

- Undefined behavior fix for tls-tests.

- Cleanups: COLO, savevm handlers, CPR/VFIOheaders.

# -----BEGIN PGP SIGNATURE-----
#
# iQJEBAABCAAuFiEEqhtIsKIjJqWkw2TPx5jcdBvsMZ0FAmmUkycQHGZhcm9zYXNA
# c3VzZS5kZQAKCRDHmNx0G+wxnRUQD/9tRGwSAmIY6T9X20eH+KFbPK+QquPGpyt7
# CPuTPAIx3fXCPZWq4syjJ1hKfoB3n8IHirTfKLmpW/0UKPZReOvsW7EDvZ5pati5
# Zsj/DtVYIEEwRDPRq2OL1kT//ofqhL8htjs2sTypEVgHTToIxYuT7kNGr1xVAKyB
# lUZWgQUJoihX4czNLkxKddxrG4BQx9hEYrq6kTgqmRdVUVo2xiQMSyHElE76L37g
# JZB2kOgf2Y6o8T4WTROiiEkn5CwWw181Nl/Iic1CNh44mFt/xSB7RQU91lU1Pu9b
# 4cqk6pf6WR35b0BS27b8jYfLGCf1GJJKMpoZLCEKbHPYs1rnGcD0gxoOx6NtscpR
# xNhaFm+iH4UtD2yX7Z3TlA7u/DfwsFpIMMtxc91bhYCnLX9AMm2MB+71T/v4HWvX
# f0dqXMSxlDpuzubuA+Ztw7h43+vidQCYXknFFtHVSv4SNAJbSqyzWiALpUibsT3I
# 2cQ+xm4mCT+7hYei59P2cnPOR9DW4/ONbvua2VAVeipgARwWnzn882B1zQrGYirJ
# gsQchT0/PTZEikkd3WWTUtSRO8r61AUnFgkTTIKkgZDF7rRAwm79gkM9yPFddIQQ
# GcssvGiuwdnWmSov0zW24285zRTOJendi1gMtd66jaEEWcvsONl285904RnrxQnm
# uypzwZgzaw==
# =5jYW
# -----END PGP SIGNATURE-----
# gpg: Signature made Tue Feb 17 16:11:19 2026 GMT
# gpg:                using RSA key AA1B48B0A22326A5A4C364CFC798DC741BEC319D
# gpg:                issuer "[email protected]"
# gpg: Good signature from "Fabiano Rosas <[email protected]>" [unknown]
# gpg:                 aka "Fabiano Almeida Rosas <[email protected]>" [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: AA1B 48B0 A223 26A5 A4C3  64CF C798 DC74 1BEC 319D

* tag 'migration-20260217-pull-request' of https://gitlab.com/farosas/qemu: (32 commits)
  tests/qtest/migration/tls-tests.c: Don't use tls_psk end hook for no_tls tests
  migration/cpr: Include vfio-cpr.h instead of vfio-device.h
  migration/colo/xen: Use generic helpers in qemu_save_device_state()
  migration: Simplify qemu_save_device_state()
  migration: Make qemu_savevm_state_non_iterable() take errp
  migration/bg-snapshot: Cleanup error paths
  migration: Introduce qemu_savevm_state_active()
  migration: Refactor qemu_savevm_state_setup()
  migration: Cleanup error propagates in qemu_savevm_state_setup()
  migration: qemu_savevm_state_complete_precopy() take MigrationState*
  migration: Split qemu_savevm_state_complete_precopy_non_iterable()
  migration: Provide helper for save vm description
  migration: Introduce qemu_savevm_state_end()
  migration/postcopy: Send device states without copying buffer
  migration/colo: Send device states without copying buffer
  migration: Drop qemu_file_set_error() when save non-iterable fails
  migration: Drop iterable_only in qemu_savevm_state_complete_precopy
  migration/colo: Document qemu_fflush(fb)
  migration/colo: Use the RAM iterable helper directly
  colo: Forbid VM resume during checkpointing
  ...

Signed-off-by: Peter Maydell <[email protected]>
2026-02-17 16:45:52 +00:00
Andrea Bolognani e8dcd2a0c2 docs/interop/firmware: Add 'uefi-vars' member for FirmwareMappingMemory
This allows describing firmwares that are loaded as ROMs but also
support a UEFI variable store. This is the case for edk2 builds
that are set up to use the uefi-vars QEMU device, and whose
descriptors would advertise the 'host-uefi-vars' feature.

Signed-off-by: Andrea Bolognani <[email protected]>
Reviewed-by: Daniel P. Berrangé <[email protected]>
Acked-by: Markus Armbruster <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Gerd Hoffmann <[email protected]>
2026-02-17 16:03:06 +01:00
Oliver Steffen 03025db6a0 igvm: Add NULL checks for igvm_get_buffer()
According to the documentation we are supposed to do a null-pointer
check on the buffers returned by igvm_get_buffer() (part of the IGVM C
library).
Add these checks in the IGVM backend.

Signed-off-by: Oliver Steffen <[email protected]>
Reviewed-by: Luigi Leonardi <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Gerd Hoffmann <[email protected]>
2026-02-17 16:02:57 +01:00
Peter Maydell fd5ecd187b tests/qtest/migration/tls-tests.c: Don't use tls_psk end hook for no_tls tests
If you run the TLS tests under a clang undefined-behaviour sanitizer build
it will fall over like this:

../../tests/unit/crypto-tls-psk-helpers.c:53:12: runtime error: null pointer passed as argument 1, which is declared to never be null
/usr/include/unistd.h:858:48: note: nonnull attribute specified here
    #0 0x62bd810762ee in test_tls_psk_cleanup /home/pm215/qemu/build/clang/../../tests/unit/crypto-tls-psk-helpers.c:53:5
    #1 0x62bd81073f89 in migrate_hook_end_tls_psk /home/pm215/qemu/build/clang/../../tests/qtest/migration/tls-tests.c:101:5
    #2 0x62bd81062ef0 in test_precopy_common /home/pm215/qemu/build/clang/../../tests/qtest/migration/framework.c:947:9

This happens because test_precopy_tcp_no_tls() uses a custom start_hook
that only sets a couple of parameters, but reuses the tsk_psk end_hook.
However, the end_hook runs cleanup that assumes that the data was set
up by migrate_hook_start_tls_psk_common(). In particular, it will
unconditionally call test_tls_psk_cleanup(data->pskfile), and
test_tls_psk_cleanup() will unconditionally unlink() the filename it
is passed, which is undefined behaviour if you pass it a NULL pointer.

Instead of creating a TestMigrateTLSPSKData struct which we never set
any fields in and requiring the migrate_hook_end_tls_psk() hook to
cope with that, don't allocate the struct in the start_hook. Then
there is nothing we need to clean up, and we can set the end_hook
to NULL (which the test framework will interpret as "don't call
any end_hook").

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Fabiano Rosas <[email protected]>
Reviewed-by: Peter Xu <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
[no need to copy stable]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-02-17 10:06:03 -03:00
Cédric Le Goater e8e8bb79dd migration/cpr: Include vfio-cpr.h instead of vfio-device.h
The file migration/cpr.c uses vmstate_cpr_vfio_devices which is
declared in hw/vfio/vfio-cpr.h, not in hw/vfio/vfio-device.h.

Replace the include with the correct header file to avoid pulling in
unnecessary VFIO device declarations.

Signed-off-by: Cédric Le Goater <[email protected]>
Reviewed-by: Peter Xu <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-02-17 10:05:24 -03:00
Peter Xu 32ed27e5b9 migration/colo/xen: Use generic helpers in qemu_save_device_state()
Use qemu_savevm_state_non_iterable*() helpers for saving device states,
rather than walking the vmstate handlers on its own.

Non-iterables can be either early_setup devices, or otherwise.

Note that QEMU only has one early_setup device currently, which is
virtio-mem, and I highly doubt if it is used in either COLO or Xen users..
However this step is still better needed to provide full coverage of all
non-iterable vmstates.

When at it, allow it to report errors.

Cc: David Woodhouse <[email protected]>
Cc: Paul Durrant <[email protected]>
Signed-off-by: Peter Xu <[email protected]>
Reviewed-by: Fabiano Rosas <[email protected]>
Tested-by: Lukas Straub <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-02-17 09:57:25 -03:00
Peter Xu 1580d7346b migration: Simplify qemu_save_device_state()
This function is used by both COLO and Xen.  Simplify it with two changes:

- Remove checks on qemu_savevm_se_iterable(): this is not needed as
  vmstate_save() also checks for "save_state() || vmsd" instead.  Here,
  save_setup() (or say, iterable states) should be mutual exclusive to
  "save_state() || vmsd" [*].

- Remove migrate_error_propagate(): both of the users are not using live
  migration framework, but raw vmstate operations.  Error propagation is
  only needed for query-migrate persistence.

[*] One tricky user is VFIO, who provided _both_ save_state() and
save_setup().  However VFIO mustn't have been used in these paths or it
means both COLO and Xen have ignored VFIO data instead (that is,
qemu_savevm_se_iterable() will return true for VFIO). Hence, this change is
safe.

Cc: David Woodhouse <[email protected]>
Cc: Paul Durrant <[email protected]>
Signed-off-by: Peter Xu <[email protected]>
Reviewed-by: Fabiano Rosas <[email protected]>
Tested-by: Lukas Straub <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
[commit msg: s/not needed for/only needed for]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-02-17 09:56:36 -03:00
Peter Xu 6b56e62de3 migration: Make qemu_savevm_state_non_iterable() take errp
Let the function report errors to upper layers.  Out of three current
users, two of them already process the errors, except one outlier,
qemu_savevm_state_complete_precopy(), where we do it manually for now with
a comment for TODO.

Signed-off-by: Peter Xu <[email protected]>
Tested-by: Lukas Straub <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
[add space in error_prepend string]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-02-17 09:55:30 -03:00
Peter Xu 7a6eeaf810 migration/bg-snapshot: Cleanup error paths
Cleanup bg_migration_thread() function on error handling.  First of all,
early_fail is almost only used to say if BQL is taken.  Since we already
have separate jumping labels, we don't really need it, hence removed.

Also, since local_err is around, making sure every failure path will set a
proper error string for the failure, then propagate to MigrationState.error.

Signed-off-by: Peter Xu <[email protected]>
Reviewed-by: Fabiano Rosas <[email protected]>
Tested-by: Lukas Straub <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-02-17 09:53:43 -03:00
Peter Xu ce0c20c68f migration: Introduce qemu_savevm_state_active()
Introduce this helper to detect if a SaveStateEntry is active.

Note that this helper can actually also be used in loadvm paths, but let's
stick with this name for now because we still use SaveStateEntry for the
shared structure that both savevm/loadvm uses, where this name still suites.

Signed-off-by: Peter Xu <[email protected]>
Reviewed-by: Fabiano Rosas <[email protected]>
Tested-by: Lukas Straub <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-02-17 09:53:42 -03:00
Peter Xu b1f774767f migration: Refactor qemu_savevm_state_setup()
Split it into two smaller chunks:

  - Dump of early_setup VMSDs
  - Dump of save_setup() sections

They're mutual exclusive, hence we can run two loops and do them
sequentially.  This will cause migration thread to loop one more time, but
it should be fine when migration just started and only do it once.  It's
needed because we will need to reuse the early_vmsd helper later to
deduplicate code elsewhere.

QEMU almost sticks with qemu_savevm_state_XXX() to represent the dump of
vmstates's section XXX.  With that in mind, this patch renamed the original
qemu_savevm_state_setup() to qemu_savevm_state_do_setup() instead.

So after this patch:

  - qemu_savevm_state_non_iterable_early() dumps early_vmsds only,
  - qemu_savevm_state_setup() dumps save_setup() sections only,
  - qemu_savevm_state_do_setup() does all things needed during setup
    phase (including migration SETUP notifies)

Signed-off-by: Peter Xu <[email protected]>
Reviewed-by: Fabiano Rosas <[email protected]>
Tested-by: Lukas Straub <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-02-17 09:53:42 -03:00
Peter Xu 9a2faa6a17 migration: Cleanup error propagates in qemu_savevm_state_setup()
We did two unnecessary error propagations in qemu_savevm_state_setup(), on
either propagate it to MigrationState*, or set qemufile with error.

Error propagation is not needed because:

  - Two live migration callers ([bg_]migration_thread) will propagate error
    if this function returned with an error.

  - Save snapshot (qemu_savevm_state) doesn't need to persist error; it got
    returned directly from save_snapshot().

QEMUFile set error is not needed because the callers always check for
errors explicitly.

Signed-off-by: Peter Xu <[email protected]>
Reviewed-by: Fabiano Rosas <[email protected]>
Tested-by: Lukas Straub <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-02-17 09:53:42 -03:00
Peter Xu 09108805d5 migration: qemu_savevm_state_complete_precopy() take MigrationState*
Make it pass in MigrationState* instead of s->to_dst_file, so as to drop
the internal migrate_get_current().

Signed-off-by: Peter Xu <[email protected]>
Reviewed-by: Fabiano Rosas <[email protected]>
Tested-by: Lukas Straub <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-02-17 09:53:42 -03:00
Peter Xu 4b5dc4d831 migration: Split qemu_savevm_state_complete_precopy_non_iterable()
Split the function, making itself to be the helper to dump all non-iterable
device states (early_vmsd excluded).  Move the precopy end logic out to the
two callers that need it.

With it, we can remove the in_postcopy parameter.  Meanwhile, renaming the
function to be qemu_savevm_state_non_iterable(): we don't need the keyword
"complete" because non-iterable doesn't iterate anyway, and we don't need
precopy because we moved precopy specialties out.

NOTE: this patch introduced one new migrate_get_current() user; will be
removed in follow up patch.

Signed-off-by: Peter Xu <[email protected]>
Reviewed-by: Fabiano Rosas <[email protected]>
Tested-by: Lukas Straub <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-02-17 09:53:42 -03:00
Peter Xu 56294bcd25 migration: Provide helper for save vm description
Provide two smaller helpers to dump the vm desc.  Preparing to move it out
and generalize device state dump.

Signed-off-by: Peter Xu <[email protected]>
Reviewed-by: Fabiano Rosas <[email protected]>
Tested-by: Lukas Straub <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-02-17 09:53:42 -03:00
Peter Xu c3bc01feb8 migration: Introduce qemu_savevm_state_end()
Introduce a helper to end a migration stream.

Signed-off-by: Peter Xu <[email protected]>
Reviewed-by: Fabiano Rosas <[email protected]>
Tested-by: Lukas Straub <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-02-17 09:53:42 -03:00
Peter Xu 7e188607fa migration/postcopy: Send device states without copying buffer
Put buffer can be async as long as the flush happens before the buffer will
be recycled / reused.  Do it for postcopy package data.  Quick measurement
shows a small VM the time to push / flush the package shrinks from 91us to
38us.

Signed-off-by: Peter Xu <[email protected]>
Reviewed-by: Fabiano Rosas <[email protected]>
Tested-by: Lukas Straub <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-02-17 09:53:42 -03:00
Peter Xu 2602618b3f migration/colo: Send device states without copying buffer
We can safely use the async version of put buffer here because the qemufile
will be flushed right away.

Suggested-by: Fabiano Rosas <[email protected]>
Signed-off-by: Peter Xu <[email protected]>
Reviewed-by: Fabiano Rosas <[email protected]>
Tested-by: Lukas Straub <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-02-17 09:53:41 -03:00
Peter Xu f2b2e6b42f migration: Drop qemu_file_set_error() when save non-iterable fails
All users of qemu_savevm_state_complete_precopy_non_iterable() process
return values.  There's no need to set error on qemufile (which we likely
should remove gradually across the tree).  Remove it for possible code
dedup to happen later.

Signed-off-by: Peter Xu <[email protected]>
Reviewed-by: Fabiano Rosas <[email protected]>
Tested-by: Lukas Straub <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-02-17 09:53:41 -03:00
Peter Xu 994f4b29ec migration: Drop iterable_only in qemu_savevm_state_complete_precopy
Now after removing the special case in COLO, we can drop this parameter.

Reviewed-by: Fabiano Rosas <[email protected]>
Signed-off-by: Peter Xu <[email protected]>
Tested-by: Lukas Straub <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-02-17 09:53:41 -03:00
Peter Xu 8c4d280054 migration/colo: Document qemu_fflush(fb)
COLO caches all device states in a buffer channel `fb'.  Add some comments
explaining the flush, that (1) it's the `fb' not the main channel, (2) on
what it updates.

Signed-off-by: Peter Xu <[email protected]>
Reviewed-by: Fabiano Rosas <[email protected]>
Tested-by: Lukas Straub <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-02-17 09:53:41 -03:00
Peter Xu 47377604dc migration/colo: Use the RAM iterable helper directly
qemu_savevm_state_complete_precopy() has a weird parameter called
"iterable_only".  It's needed because COLO saves device states in advance.

To make dropping that weird parameter easier, let COLO directly use the RAM
iterator helper instead, which should make the code easier to read too.

Reviewed-by: Fabiano Rosas <[email protected]>
Signed-off-by: Peter Xu <[email protected]>
Tested-by: Lukas Straub <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-02-17 09:53:41 -03:00
Peter Xu afbba26fd3 colo: Forbid VM resume during checkpointing
COLO will stop the VM during each checkpoint on either PVM or SVM.

Accidentally resuming the VM during the window might be fatal because it
may cause the RAM and devices state to misalign, corrupting the checkpoint.

Hence forbid VM resume during the process.

Reviewed-by: Fabiano Rosas <[email protected]>
Signed-off-by: Peter Xu <[email protected]>
Tested-by: Lukas Straub <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-02-17 09:53:41 -03:00
Peter Xu 93b974cbc1 migration: Remove call to send switchover start event in colo/savevm
COLO (in case of periodically checkpointing) already have switchover
happened before hand.  This switchover_start feature never applies to COLO.

Savevm for snapshot doesn't have switchover phase and VM is stopped for the
whole process.

Remove both.

Signed-off-by: Peter Xu <[email protected]>
Reviewed-by: Fabiano Rosas <[email protected]>
Tested-by: Lukas Straub <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-02-17 09:53:41 -03:00
Peter Xu ac4702a746 migration/colo: Unwrap qemu_savevm_live_state()
It's only used in COLO path and only contains two calls.  Unwrap the
function.  It paves way for further reduce special COLO paths on sync.

Reviewed-by: Fabiano Rosas <[email protected]>
Signed-off-by: Peter Xu <[email protected]>
Tested-by: Lukas Straub <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-02-17 09:53:41 -03:00
Peter Xu 8df42ed6e5 migration/savevm: Remove SaveStateEntry.is_ram
It's neither accurate nor necessary.  Use a proper helper to detect if it's
an iterable savevm state entry instead.

Reviewed-by: Fabiano Rosas <[email protected]>
Signed-off-by: Peter Xu <[email protected]>
Tested-by: Lukas Straub <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-02-17 09:53:41 -03:00
Peter Xu 4d82caab17 migration: Remove one migration_in_colo_state() occurance
Move the send header operation directly into Xen's QMP command, as COLO
doesn't need it.

Reviewed-by: Fabiano Rosas <[email protected]>
Signed-off-by: Peter Xu <[email protected]>
Tested-by: Lukas Straub <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-02-17 09:53:40 -03:00
Peter Xu 12f5921ff2 migration: Use qemu_savevm_send_header() in qemu_save_device_state()
Reduces duplication of the other path where we also send the same header.

Reviewed-by: Fabiano Rosas <[email protected]>
Signed-off-by: Peter Xu <[email protected]>
Tested-by: Lukas Straub <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-02-17 09:53:40 -03:00
Peter Xu fd5d166faf migration: Introduce qemu_savevm_send_* helpers
Split qemu_savevm_state_header() into two parts.   This paves way for a
reuse elsewhere.

Reviewed-by: Fabiano Rosas <[email protected]>
Signed-off-by: Peter Xu <[email protected]>
Tested-by: Lukas Straub <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-02-17 09:53:40 -03:00
Fabiano Rosas 3a4aa17821 migration: Update comments mentioning qmp_migrate_finish
The qmp_migrate_finish function was recently removed in commit
2379a04e60 ("migration: Remove qmp_migrate_finish"), update comments
that mention it.

Reviewed-by: Peter Xu <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-02-17 09:50:58 -03:00
Peter Xu a545fafccf migration: Rename MIG_EVENT_PRECOPY_* to MIG_EVENT_*
All three events are shared between precopy and postcopy, rather than
precopy specific.

For example, both precopy and postcopy will go through a SETUP process.

Meanwhile, both FAILED and DONE notifiers will be notified for either
precopy or postcopy on completions / failures.

Rename them to make them match what they do, and shorter.

Reviewed-by: Fabiano Rosas <[email protected]>
Acked-by: Stefan Hajnoczi <[email protected]>
Signed-off-by: Peter Xu <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
[fixed-up entry in scsi-disk.c that got merged first]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-02-17 09:43:09 -03:00
Peter Xu 7da1fba27e migration: Drop explicit block activation in postcopy fail path
Postcopy (in failure path) should share with precopy on disk reactivations.
Explicit activiation should used to be fine even if called twice, but after
26f65c01ed ("migration: Do not try to start VM if disk activation fails")
we may want to avoid it and always capture failure when reactivation
happens (even if we do not expect the failure to happen).  Remove this
redundant call.

Reviewed-by: Fabiano Rosas <[email protected]>
Acked-by: Stefan Hajnoczi <[email protected]>
Signed-off-by: Peter Xu <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-02-17 09:40:32 -03:00
Peter Xu 96dc397fe2 migration: Notify migration FAILED before starting VM
Devices may opt-in migration FAILED notifiers to be invoked when migration
fails.  Currently, the notifications happen in migration_cleanup().  It is
normally fine, but maybe not ideal if there's dependency of the fallback
v.s. VM starts.

This patch moves the FAILED notification earlier, so that if the failure
happened during switchover, it'll notify before VM restart.

After walking over all existing FAILED notifier users, I got the conclusion
that this should also be a cleaner approach at least from design POV.

We have these notifier users, where the first two do not need to trap
FAILED:

|----------------------------+-------------------------------------+---------------------|
| device                     | handler                             | events needed       |
|----------------------------+-------------------------------------+---------------------|
| gicv3                      | kvm_arm_gicv3_notifier              | DONE                |
| vfio_iommufd / vfio_legacy | vfio_cpr_reboot_notifier            | SETUP               |
| cpr-exec                   | cpr_exec_notifier                   | FAILED, DONE        |
| virtio-net                 | virtio_net_migration_state_notifier | SETUP, FAILED       |
| vfio                       | vfio_migration_state_notifier       | FAILED              |
| vdpa                       | vdpa_net_migration_state_notifier   | SETUP, FAILED       |
| spice [*]                  | migration_state_notifier            | SETUP, FAILED, DONE |
|----------------------------+-------------------------------------+---------------------|

For cpr-exec, it tries to cleanup some cpr-exec specific fd or env
variables.  This should be fine either way, as long as before
migration_cleanup().

For virtio-net, we need to re-plug the primary device back to guest in the
failover mode.  Likely benign.

VFIO needs to re-start the device if FAILED.  IIUC it should do it before
vm_start(), if the VFIO device can be put into a STOPed state due to
migration, we should logically make it running again before vCPUs run.

VDPA will disable SVQ when migration is FAILED.  Likely benign too, but
looks better if we can do it before resuming vCPUs.

For spice, we should rely on "spice_server_migrate_end(false)" to retake
the ownership.  Benign, but looks more reasonable if the spice client does
it before VM runs again.

Note that this change may introduce slightly more downtime, if the
migration failed exactly at the switchover phase.  But that's very rare,
and even if it happens, none of above expects a long delay, but a short
one, likely will be buried in the total downtime even if failed.

Cc: Cédric Le Goater <[email protected]>
Cc: Marc-André Lureau <[email protected]>
Acked-by: Stefan Hajnoczi <[email protected]>
Reviewed-by: Fabiano Rosas <[email protected]>
Signed-off-by: Peter Xu <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-02-17 09:40:32 -03:00
Peter Xu ff3a9e4e31 migration: Fix double notification of DONE/FAIL for postcopy
Migration notifiers will notify at any of three places: (1) SETUP
phase, (2) migration completes, (3) migration fails.

There's actually a special case for spice: one can refer to
b82fc321bf ("Postcopy+spice: Pass spice migration data earlier").  It
doesn't need another 4th event because in commit 9d9babf78d ("migration:
MigrationEvent for notifiers") we merged it together with the DONE event.

The merge makes some sense if we treat "switchover" of postcopy as "DONE",
however that also means for postcopy we'll notify DONE twice..  The other
one at the end of postcopy when migration_cleanup().

In reality, the current code base will also notify FAILED for postcopy
twice.  It's because an (maybe accidental) change in commit
4af667f87c ("migration: notifier error checking").

First of all, we still need that notification when switchover as stated in
Dave's commit, however that's only needed for spice.  To fix it, introduce
POSTCOPY_START event to differenciate it from DONE.  Use that instead in
postcopy_start().  Then spice will need to capture this event too.

Then we remove the extra FAILED notification in postcopy_start().

If one wonder if other DONE users should also monitor POSTCOPY_START
event.. We have two more DONE users:

  - kvm_arm_gicv3_notifier
  - cpr_exec_notifier

Both of them do not need a notification for POSTCOPY_START, but only when
migration completed.  Actually, both of them are used in CPR, which doesn't
support postcopy.

When at this, update the notifier transition graph in the comment, and move
it from migration_add_notifier() to be closer to where the enum is defined.

I didn't attach Fixes: because I am not aware of any real bug on such
double reporting.  I'm wildly guessing the 2nd notify might be silently
ignored in many cases.  However this is still worth fixing.

Cc: Marc-André Lureau <[email protected]>
Cc: Dr. David Alan Gilbert <[email protected]>
Signed-off-by: Peter Xu <[email protected]>
Reviewed-by: Fabiano Rosas <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-02-17 09:40:32 -03:00
Peter Xu 7e9608ebf5 migration: Add a tracepoint for invoking migration notifiers
Reviewed-by: Fabiano Rosas <[email protected]>
Acked-by: Stefan Hajnoczi <[email protected]>
Signed-off-by: Peter Xu <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-02-17 09:40:32 -03:00
Chao Liu a8f98ffd7b tests/qtest: Add RISC-V IOMMU bare-metal test
Add a qtest suite for the RISC-V IOMMU PCI device on the virt machine.
The test exercises bare, S-stage, G-stage, and nested translation paths
using iommu-testdev and the qos-riscv-iommu helpers.

The test validates:
- Device context (DC) configuration
- SV39 page table walks for S-stage translation
- SV39x4 page table walks for G-stage translation
- Nested translation combining both stages
- FCTL register constraints

This provides regression coverage for the RISC-V IOMMU implementation
without requiring a full guest OS boot.

Signed-off-by: Chao Liu <[email protected]>
Reviewed-by: Tao Tang <[email protected]>
Reviewed-by: Fabiano Rosas <[email protected]>
Reviewed-by: Daniel Henrique Barboza <[email protected]>
Link: https://lore.kernel.org/qemu-devel/35f046c8d21aa6d5f9a531258762e01be198d8cf.1770127918.git.chao.liu.zevorn@gmail.com
Signed-off-by: Fabiano Rosas <[email protected]>
2026-02-17 09:37:40 -03:00
Chao Liu 9d8ffbfc1d tests/qtest/libqos: Add RISC-V IOMMU helper library
Introduce a libqos helper module for RISC-V IOMMU testing with
iommu-testdev. The helper provides routines to:

- Build device contexts (DC) and 3-level page tables for SV39/SV39x4
- Program command queue (CQ), fault queue (FQ), and DDTP registers
  following the RISC-V IOMMU specification
- Execute DMA translations and verify results

The current implementation supports SV39 for S-stage and SV39x4 for
G-stage translation. Support for SV48/SV48x4/SV57/SV57x4 can be added
in future patches.

Signed-off-by: Chao Liu <[email protected]>
Reviewed-by: Tao Tang <[email protected]>
Reviewed-by: Fabiano Rosas <[email protected]>
Reviewed-by: Daniel Henrique Barboza <[email protected]>
Link: https://lore.kernel.org/qemu-devel/a2edf8c44f0bce26dccb91a7d13edb58be50c1a3.1770127918.git.chao.liu.zevorn@gmail.com
Signed-off-by: Fabiano Rosas <[email protected]>
2026-02-17 09:37:40 -03:00
Peter Maydell ece408818d Merge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging
* hw/i386: Remove deprecated PC 2.6 and 2.7 machines
* i386/cpu: Fix incorrect initializer in Diamond Rapids definition
* qom: Clean up property release
* target/i386/kvm: set KVM_PMU_CAP_DISABLE if "-pmu" is configured
* target/i386/kvm: reset AMD and perfmon-v2 PMU registers during VM reset
* mshv: Cleanup
* target/i386: convert SEV-ES termination requests to guest panic events

# -----BEGIN PGP SIGNATURE-----
#
# iQFIBAABCgAyFiEE8TM4V0tmI4mGbHaCv/vSX3jHroMFAmmO+kYUHHBib256aW5p
# QHJlZGhhdC5jb20ACgkQv/vSX3jHroPwIQf/XL4HXB7bYQH7LtTgsjmmxPpEqGuM
# 2QWvv1HurGf4pBCkBB7iFdzngSbJSzvtIM4D2KRuXVc99Ml8Do4kKGwDdtVfaM+I
# x+nsJfnSGA7tuNVQUUDEM1XWrnk3+O9oQxlk3elBWy8IBIjHFY1rv3FBdO9WkDpu
# AlaMITrX4R7u5gadCrxvAprbngNGlK220HZ+nxdxvf6mWkYMPqy1xtNzHIioG61V
# A94tdv/OZnUoQMd98c/yUvfST4/Gx6FeoEYfmyXGrnLM+Tc9es/xpN/mCYLdP3wA
# MDS170D2Z0zoZScLcpMfeqSn5cDYBMOSHBzqFpw2/FNVTO3td2qlSMLjzw==
# =AqB6
# -----END PGP SIGNATURE-----
# gpg: Signature made Fri Feb 13 10:17:42 2026 GMT
# gpg:                using RSA key F13338574B662389866C7682BFFBD25F78C7AE83
# gpg:                issuer "[email protected]"
# gpg: Good signature from "Paolo Bonzini <[email protected]>" [full]
# gpg:                 aka "Paolo Bonzini <[email protected]>" [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: (41 commits)
  target/i386/mshv: remove unused optimization of gva=>gpa translation
  accel/mshv: Remove remap overlapping mappings code
  tests: add /qdev/free-properties test
  qdev: make release_tpm() idempotent
  qdev: make release_drive() idempotent
  qdev: make release_string() idempotent
  qdev: Free property array on release
  target/i386/kvm: support perfmon-v2 for reset
  target/i386/kvm: reset AMD PMU registers during VM reset
  target/i386/kvm: rename architectural PMU variables
  target/i386/kvm: extract unrelated code out of kvm_x86_build_cpuid()
  target/i386/kvm: set KVM_PMU_CAP_DISABLE if "-pmu" is configured
  i386/cpu: Fix incorrect initializer in Diamond Rapids definition
  hw/char/virtio-serial: Do not expose the 'emergency-write' property
  hw/virtio/virtio-pci: Remove VirtIOPCIProxy::ignore_backend_features field
  hw/i386/intel_iommu: Remove IntelIOMMUState::buggy_eim field
  hw/core/machine: Remove hw_compat_2_7[] array
  hw/audio/pcspk: Remove PCSpkState::migrate field
  target/i386/cpu: Remove CPUX86State::full_cpuid_auto_level field
  hw/i386/pc: Remove pc_compat_2_7[] array
  ...

Signed-off-by: Peter Maydell <[email protected]>
2026-02-13 10:30:08 +00:00
Peter Maydell 4dd433550d Merge tag 'char-pull-request' of https://gitlab.com/marcandre.lureau/qemu into staging
chardev patches

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCgAdFiEEh6m9kz+HxgbSdvYt2ujhCXWWnOUFAmmO8tUACgkQ2ujhCXWW
# nOW1sg//bqvhuJeHHQoDzNM5qgPTwLoqKYOt5xx2MZkH5oRoG0L6RfjNKqs8DPVc
# rnWFNr6YYHP+AjtYSoOFZZZugQyYDggE6Defkb52ScMNgQF0MSYXfZz6gEllgbzw
# +xvSsS1MztwpfkcUGaV5GL6PatuhkmioX0v083w0AbyHhuCF5zjKPaW6tNb9iwdz
# A3pnPkZSdGQ876R53vRY0OhEDFD7aT/jiVPiN6rzjxaz7CL5nAGy3PQtXWnJptCd
# YPgl5CIKe0NsTBD+h4rq7GtU8z2dNGW+wocXuyBvBDxkfVgjWEi0yJ9C1tY3focG
# cZxuaC8GLpbowdNqBUdJzjOdj7GIn8pG/ASPrjYjA3igFspdr8vRfEiS01KnBNi7
# 9Jzg6A4uHJI25ydPEAGRjbWjPYuElrEoLO2WUG3NWlb2sAoj+WEhQyD6C9+Mp0KY
# 9aDAClzOLylqZLe4vLrMjR9MGHE7nAilvwFTVeD3CBEySmBvDgygzMzuDXq8D5NB
# nsZslPy+WXJAydTvCfB8eS3NGZWUz2MQmHsdLGBheSLnLoAKoC4p9BFx09XgMLAw
# hV0n0/0v9XtOLwvGILy7ejxt0sZXHFI3avy1df8gMSeP2VpX7DXnd745fZJQt3xB
# ppwYRg9MHHuIb1KoVvfck34WHJ6bhSHROEe2I/fdVFhCXg2eyms=
# =CYVg
# -----END PGP SIGNATURE-----
# gpg: Signature made Fri Feb 13 09:45:57 2026 GMT
# gpg:                using RSA key 87A9BD933F87C606D276F62DDAE8E10975969CE5
# gpg: Good signature from "Marc-André Lureau <[email protected]>" [full]
# gpg:                 aka "Marc-André Lureau <[email protected]>" [full]
# Primary key fingerprint: 87A9 BD93 3F87 C606 D276  F62D DAE8 E109 7596 9CE5

* tag 'char-pull-request' of https://gitlab.com/marcandre.lureau/qemu:
  baum: Add copy/paste bindings
  chardev: add logtimestamp option
  error-report: make real_time_iso8601() public
  char: qemu_chr_write_log() use qemu_write_full()
  chardev/char: qemu_char_open(): add return value
  chardev: rework filename handling
  chardev: introduce .chr_get_pty_name() handler
  chardev/char-pty: store pty_name into PtyChardev state
  chardev: .chr_open(): add boolean return value
  chardev: .chr_open(): drop be_opened parameter
  chardev: consistent naming for ChardevClass handlers implementations
  chardev: ChardevClass: consistent naming for handlers
  ui/spice: drop SPICE_HAS_ATTACHED_WORKER macro
  ui/spice: Require spice-server >= 0.15.0
  char-udp: Fix initial backend open status

Signed-off-by: Peter Maydell <[email protected]>
2026-02-13 10:29:55 +00:00
Magnus Kulke 7db36b8223 target/i386/mshv: remove unused optimization of gva=>gpa translation
The removed parameters are remnants of a prior attempt to optimize
gva=>gpa translation. Currently there is only one call site and it's
not using it. So we can remove it as dead code.

Signed-off-by: Magnus Kulke <[email protected]>
Reviewed-by: Wei Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-13 11:16:52 +01:00
Magnus Kulke 626e5dc999 accel/mshv: Remove remap overlapping mappings code
This change removes userland code that worked around a restriction
in the mshv driver in the 6.18 kernel: regions from userland
couldn't be mapped to multiple regions in the kernel. We maintained a
shadow mapping table in qemu and used a heuristic to swap in a requested
region in case of UNMAPPED_GPA exits.

However, this heuristic wasn't reliable in all cases, since HyperV
behaviour is not 100% reliable across versions. HyperV itself doesn't
prohibit to map regions at multiple places into the guest, so the
restriction has been removed in the mshv driver.

Hence we can remove the remapping code. Effectively this will mandate a
6.19 kernel, if the workload attempt to map e.g. BIOS to multiple
reagions. I still think it's the right call to remove this logic:

- The workaround only seems to work reliably with a certain revision
  of HyperV as a nested hypervisor.
- We expect Direct Virtualization (L1VH) to be the main platform for
  the mshv accelerator, which also requires a 6.19 kernel

This reverts commit efc4093358.

Signed-off-by: Magnus Kulke <[email protected]>
Acked-by: Wei Liu (Microsoft) <[email protected]>
Tested-by: Mohamed Mediouni <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-13 11:16:52 +01:00
Marc-André Lureau 69345f948a tests: add /qdev/free-properties test
Add a simple qdev test to check that allocated properties get freed with
the object. This test exhibited array leaks before the fixes.

Signed-off-by: Marc-André Lureau <[email protected]>
Reviewed-by: Stefan Berger <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Reviewed-by: Stefan Hajnoczi <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-13 11:16:52 +01:00
Marc-André Lureau 95d69539a4 qdev: make release_tpm() idempotent
So it can eventually be called multiple times safely.

Signed-off-by: Marc-André Lureau <[email protected]>
Reviewed-by: Stefan Berger <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Reviewed-by: Stefan Hajnoczi <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-13 11:16:52 +01:00
Marc-André Lureau b4579255d1 qdev: make release_drive() idempotent
So it can eventually be called multiple times safely.

Signed-off-by: Marc-André Lureau <[email protected]>
Reviewed-by: Stefan Berger <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Reviewed-by: Stefan Hajnoczi <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-13 11:16:52 +01:00
Marc-André Lureau 396b3fcecf qdev: make release_string() idempotent
So it can eventually be called multiple times safely.

Signed-off-by: Marc-André Lureau <[email protected]>
Reviewed-by: Stefan Berger <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Reviewed-by: Stefan Hajnoczi <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-13 11:16:52 +01:00
Chandan Somani 50bad63097 qdev: Free property array on release
Before this patch, users of the property array would free the
array themselves in their cleanup functions. This causes
inconsistencies where some users leak the array and some free them.

This patch makes it so that the property array's release function
frees the property array (instead of just its elements). It fixes any
leaks and requires less code.

DEFINE_PROP_ARRAY leakers that are fixed in this patch:
ebpf-rss_fds in hw/net/virtio-net.c
rnmi_irqvec, rnmi_excpvec in hw/riscv/riscv_hart.c
common.display_modes in hw/display/apple-gfx-mmio.m
common.display_modes in hw/display/apple-gfx-pci.m

Signed-off-by: Chandan Somani <[email protected]>
Reviewed-by: Stefan Hajnoczi <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-13 11:16:52 +01:00
Dongli Zhang e587632c22 target/i386/kvm: support perfmon-v2 for reset
Since perfmon-v2, the AMD PMU supports additional registers. This update
includes get/put functionality for these extra registers.

Similar to the implementation in KVM:

- MSR_CORE_PERF_GLOBAL_STATUS and MSR_AMD64_PERF_CNTR_GLOBAL_STATUS both
use env->msr_global_status.
- MSR_CORE_PERF_GLOBAL_CTRL and MSR_AMD64_PERF_CNTR_GLOBAL_CTL both use
env->msr_global_ctrl.
- MSR_CORE_PERF_GLOBAL_OVF_CTRL and MSR_AMD64_PERF_CNTR_GLOBAL_STATUS_CLR
both use env->msr_global_ovf_ctrl.

No changes are needed for vmstate_msr_architectural_pmu or
pmu_enable_needed().

Signed-off-by: Dongli Zhang <[email protected]>
Reviewed-by: Zhao Liu <[email protected]>
Reviewed-by: Sandipan Das <[email protected]>
Reviewed-by: Zide Chen <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-13 11:16:52 +01:00
Dongli Zhang 4c7f05232c target/i386/kvm: reset AMD PMU registers during VM reset
QEMU uses the kvm_get_msrs() function to save Intel PMU registers from KVM
and kvm_put_msrs() to restore them to KVM. However, there is no support for
AMD PMU registers. Currently, pmu_version and num_pmu_gp_counters are
initialized based on cpuid(0xa), which does not apply to AMD processors.
For AMD CPUs, prior to PerfMonV2, the number of general-purpose registers
is determined based on the CPU version.

To address this issue, we need to add support for AMD PMU registers.
Without this support, the following problems can arise:

1. If the VM is reset (e.g., via QEMU system_reset or VM kdump/kexec) while
running "perf top", the PMU registers are not disabled properly.

2. Despite x86_cpu_reset() resetting many registers to zero, kvm_put_msrs()
does not handle AMD PMU registers, causing some PMU events to remain
enabled in KVM.

3. The KVM kvm_pmc_speculative_in_use() function consistently returns true,
preventing the reclamation of these events. Consequently, the
kvm_pmc->perf_event remains active.

4. After a reboot, the VM kernel may report the following error:

[    0.092011] Performance Events: Fam17h+ core perfctr, Broken BIOS detected, complain to your hardware vendor.
[    0.092023] [Firmware Bug]: the BIOS has corrupted hw-PMU resources (MSR c0010200 is 530076)

5. In the worst case, the active kvm_pmc->perf_event may inject unknown
NMIs randomly into the VM kernel:

[...] Uhhuh. NMI received for unknown reason 30 on CPU 0.

To resolve these issues, we propose resetting AMD PMU registers during the
VM reset process.

Signed-off-by: Dongli Zhang <[email protected]>
Reviewed-by: Dapeng Mi <[email protected]>
Reviewed-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-13 11:16:52 +01:00
Dongli Zhang 4e041b2be1 target/i386/kvm: rename architectural PMU variables
AMD does not have what is commonly referred to as an architectural PMU.
Therefore, we need to rename the following variables to be applicable for
both Intel and AMD:

- has_architectural_pmu_version
- num_architectural_pmu_gp_counters
- num_architectural_pmu_fixed_counters

For Intel processors, the meaning of pmu_version remains unchanged.

For AMD processors:

pmu_version == 1 corresponds to versions before AMD PerfMonV2.
pmu_version == 2 corresponds to AMD PerfMonV2.

Signed-off-by: Dongli Zhang <[email protected]>
Reviewed-by: Dapeng Mi <[email protected]>
Reviewed-by: Zhao Liu <[email protected]>
Reviewed-by: Sandipan Das <[email protected]>
Reviewed-by: Zide Chen <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-13 11:16:52 +01:00
Dongli Zhang 7b5d709629 target/i386/kvm: extract unrelated code out of kvm_x86_build_cpuid()
The initialization of 'has_architectural_pmu_version',
'num_architectural_pmu_gp_counters', and
'num_architectural_pmu_fixed_counters' is unrelated to the process of
building the CPUID.

Extract them out of kvm_x86_build_cpuid().

In addition, use cpuid_find_entry() instead of cpu_x86_cpuid(), because
CPUID has already been filled at this stage.

Signed-off-by: Dongli Zhang <[email protected]>
Reviewed-by: Zhao Liu <[email protected]>
Reviewed-by: Dapeng Mi <[email protected]>
Reviewed-by: Zide Chen <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-13 11:16:52 +01:00
Dongli Zhang 3833744651 target/i386/kvm: set KVM_PMU_CAP_DISABLE if "-pmu" is configured
Although AMD PERFCORE and PerfMonV2 are removed when "-pmu" is configured,
there is no way to fully disable KVM AMD PMU virtualization. Neither
"-cpu host,-pmu" nor "-cpu EPYC" achieves this.

As a result, the following message still appears in the VM dmesg:

[    0.263615] Performance Events: AMD PMU driver.

However, the expected output should be:

[    0.596381] Performance Events: PMU not available due to virtualization, using software events only.
[    0.600972] NMI watchdog: Perf NMI watchdog permanently disabled

This occurs because AMD does not use any CPUID bit to indicate PMU
availability.

To address this, KVM_CAP_PMU_CAPABILITY is used to set KVM_PMU_CAP_DISABLE
when "-pmu" is configured.

Signed-off-by: Dongli Zhang <[email protected]>
Reviewed-by: Xiaoyao Li <[email protected]>
Reviewed-by: Zhao Liu <[email protected]>
Reviewed-by: Dapeng Mi <[email protected]>
Reviewed-by: Zide Chen <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-13 11:16:52 +01:00
Aidan Khoury 4f0dd09e61 i386/cpu: Fix incorrect initializer in Diamond Rapids definition
The new Diamond Rapids x86 cpu model definition that was added in 7a6dd8bde1
has an unexpected comma in the `.features[FEAT_VMX_EXIT_CTLS]` subobject
initializer, causing the prior initialization to be overridden.  For this
reason `VMX_VM_EXIT_SAVE_DEBUG_CONTROLS | VMX_VM_EXIT_HOST_ADDR_SPACE_SIZE`
is not included.

Fix this by replacing the comma with the missing bitwise OR to properly
combine all the flags into a single bitmask value.

Fixes: 7a6dd8bde1 ("i386/cpu: Add CPU model for Diamond Rapids")
Signed-off-by: Aidan Khoury <[email protected]>
2026-02-13 11:16:46 +01:00
Samuel Thibault 98ba0e4797 baum: Add copy/paste bindings
Brltty interprets

- TL1 (i.e. Display1) + routing as clip new
- TL2 (i.e. Display2) + routing as clip add
- TR1 (i.e. Display4) + routing as copy line
- TR2 (i.e. Display5) + routing as copy rect

https://github.com/brltty/brltty/blob/master/Tables/Input/bm/routing6.kti

- BAUM_TL1+BAUM_TL2+BAUM_TL3+BAUM_TR1 (i.e.
Display1+Display2+Display3+Display4) as paste

https://github.com/brltty/brltty/blob/master/Tables/Input/bm/d6.kti

Signed-off-by: Samuel Thibault <[email protected]>
[ Marc-André - style fixes ]
Signed-off-by: Marc-André Lureau <[email protected]>
Message-ID: <[email protected]>
2026-02-13 10:45:07 +01:00
Peter Maydell 4202b432a6 Merge tag 'pull-hex-20260212' of https://github.com/quic/qemu into staging
Fix how qemu-hexagon handles invalid encodings; cleanup

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCgAdFiEEPWaq5HRZSCTIjOD4GlSvuOVkbDIFAmmOkl8ACgkQGlSvuOVk
# bDJCTw/5AaixqoZzsCgLkLAy2zRMQdgqGZrppRAy3kYzm0kAvuCk/q+cdUa26pfS
# gvEHsgUoUqOQvS0n5er2QlU68qlYgzLH8VaRKvcsrxWnUKZORulm3nevuAJORNYR
# 40dDjvKG+eLPdc9cTxJGOZ/ydXMYszSGhdvhDKtKClA7vFt2cu+Q0FBH2FEhfdI1
# pu5113gOsixvL6AhP7SuqjXMHBMIR21mBDH4E+jxc8QzicbUx/sMhKArJw+8WXTp
# rz/KKZnxsD+2M2PZmuXqenW8Wc1WkFwUw3UoMu/jWeyzGYXehAo+ioeAJxV7PbPR
# KqF65/9ue2X74PgjnbH6xLRizz4wMsbzzyUHExWQGBVTDY767xHr+G3lCBLxXYwd
# tsqueLmVMHjTnFRjZtoVFNG+x2eqpMy9lmLe1sNVN1rmEhjts6oJHWoy9xqqqrwu
# RXeySg6M/qk9Ro8O7Hv2+FhFkt8hKOQxKukaSqpQ3VdAxhdrauh/Wog3RrLl04TH
# l38j8F0m+brOfTsTnnMCEQpVvvUnAyPye1Mb66CIyBzPr5akRgXh2v7Ls9W3kvnz
# R2CnNnXiHq71fwnRaGDZUBUwhOizJOdGEm65raXY332XkO13tKOdeZQI1XPxKwqF
# IsWhlAIyNuhfnKInICXFbaIPv9dBIkxHUYyOs9WMruEfpQ5ObLk=
# =lr3R
# -----END PGP SIGNATURE-----
# gpg: Signature made Fri Feb 13 02:54:23 2026 GMT
# gpg:                using RSA key 3D66AAE474594824C88CE0F81A54AFB8E5646C32
# gpg: Good signature from "Brian Cain (OSS Qualcomm) <[email protected]>" [unknown]
# gpg:                 aka "Brian Cain <[email protected]>" [full]
# gpg:                 aka "Brian Cain (QuIC) <[email protected]>" [full]
# gpg:                 aka "Brian Cain (CAF) <[email protected]>" [full]
# gpg:                 aka "bcain" [full]
# gpg:                 aka "Brian Cain (QUIC) <[email protected]>" [unknown]
# Primary key fingerprint: 6350 20F9 67A7 7164 79EF  49E0 175C 464E 541B 6D47
#      Subkey fingerprint: 3D66 AAE4 7459 4824 C88C  E0F8 1A54 AFB8 E564 6C32

* tag 'pull-hex-20260212' of https://github.com/quic/qemu:
  target/hexagon: Remove unused is_finite()
  target/hexagon: Remove unused EXT_IDX enum
  target/hexagon: Widen MemLog::width to 32 bits
  target/hexagon: Detect register write conflicts
  tests/tcg/hexagon: Handle SIGILL internally in invalid-slots test
  target/hexagon: Return decode failure for invalid non-duplex encodings
  target/hexagon: Fix invalid duplex decoding

Signed-off-by: Peter Maydell <[email protected]>
2026-02-13 09:33:57 +00:00
Peter Maydell 7d224fe8ca Merge tag 'pr-plugins-20260212' of https://gitlab.com/pbo-linaro/qemu into staging
Changes:
- contrib/plugins/uftrace: add riscv64 support (Pierrick Bouvier <[email protected]>)

# -----BEGIN PGP SIGNATURE-----
#
# iQGzBAABCgAdFiEEZrmU7KFPfy5auggff5BUDQoc0A8FAmmOc4AACgkQf5BUDQoc
# 0A89QAv/TgRSGaiYfOziVTAephxNlzCJTsiHOKETTaGnKUbWTe6eNGVCsNtsnXuk
# CETe/5vc5WAF3QYml2NJVl8YqmMOw6YbbCDJgVosmRvGTaYhi6Ner5se9cD2Io1Z
# FzOXgzLO9dXr24OQ404Gjlndos5EBp82LTA/wmh84Ucgzez7193gTKTBjd729Feb
# 5cz320yz9UkFhpTciZHK6X59Y2V5xp+ecJVlYORzzHSjI0Vpi2eDiF2suAAonIB9
# n+Ch/TCkt7ZSicX+IA2tp5hNMbF4PzVYr2fEDu005LHomN/TmwDrVBrWhat49Fkp
# iZ144Riy1LcpenZY50f4kr5vnFM40QG0w/DxemBrdHUQ91RvM//wrKG9QCYXe7hp
# SJJRwcZLZP7m6T9zvRSJIieX4I9ZgWRR3KvAqaX7Hd5H0k+thC4UgQ7rlwnoLJpA
# KPU/bgiZhsTEIWHoeOtqgdMTgK9k9FMR+t9u04J25bHXFcMUh7JpV96n/gFvBOPR
# n4POwZ+j
# =3a3y
# -----END PGP SIGNATURE-----
# gpg: Signature made Fri Feb 13 00:42:40 2026 GMT
# gpg:                using RSA key 66B994ECA14F7F2E5ABA081F7F90540D0A1CD00F
# gpg: Good signature from "Pierrick Bouvier <[email protected]>" [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: 66B9 94EC A14F 7F2E 5ABA  081F 7F90 540D 0A1C D00F

* tag 'pr-plugins-20260212' of https://gitlab.com/pbo-linaro/qemu:
  contrib/plugins/uftrace: add riscv64 support
  docs/about/emulation/uftrace: add info about automatic tracing
  contrib/plugins/uftrace: add ops for walking frame pointers chain
  contrib/plugins/uftrace: fix infinite stack unwind detection

Signed-off-by: Peter Maydell <[email protected]>
2026-02-13 09:33:49 +00:00
Peter Maydell 91eb10be2e Merge tag 'pull-aspeed-20260212' of https://github.com/legoater/qemu into staging
aspeed-next queue:

* Adds support for the AST2700 A2 SoC, including a new machine and
  a functional test
* Enhances AST2600 OTP functional test
* Restructures Aspeed ARM tests into separate files for better
  parallelism.
* Includes new SDK tests with Linux 5.15.
* Fixes Aspeed I2C models

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCAAdFiEEoPZlSPBIlev+awtgUaNDx8/77KEFAmmOSFgACgkQUaNDx8/7
# 7KEq0RAAyhY6FCrwU3hyeA0WPCWAIhoXjqVkuPIqbLEKpazuRK2A0XeN1QH38VUu
# rotcWx5O/eTqwDXm4uTPcHGjiFjL9YRkj3opBE33pfbnMWllezUrK6Soa3q4A9uk
# FnV2YN0sucaueUdXaKe4dJr12uxUWWTQ53Lr+yt0wmXJsjvBsUWaXBTJj+aGPWuS
# u46yxJFxKUK/3GkA8nnEOm91EEQYkETX5LeWZm8aqN/BHuvJNqWuhx19rj1kaa1K
# VXgv3lvvfTpKCpqz2BwFa03ZL4PNCRlS+fN1A9idcnh4yQzngw07jc/9r3Kx/8PS
# zYFgko7EU6Ja4WojToFU4yZK5NZN6BfCd6HAjIBN86EsysDWcNS9DXmqvPnMaPGl
# l+580YsGFO2F7sd8iSPAYT1Tl17jOLVMNIW4khNVOTUnJKIJWlfyA2u4J/1iYKcF
# UiASnvmtryNru9TahlCfTK1SLsFywKN3q6lgVFMba9GX2fzrtZCCDHrQYqHWnnGj
# IzpiUAX/GU8ST1p3RjA0hR2TdBHcA6QByOFhJYQoSmHw5gcuuVxXKNl+y1y9zj07
# YPJFm2V/29m/XcpV0NkAhpX+Gcg9ASrMEQplis2v0nvzSMd/Lcr7YNJLtX9/zkth
# wP8dRnSqisWrUDEUSYap8rxPdguRlUv/tAoxcJVlryN2fB8sOOc=
# =78p2
# -----END PGP SIGNATURE-----
# gpg: Signature made Thu Feb 12 21:38:32 2026 GMT
# gpg:                using RSA key A0F66548F04895EBFE6B0B6051A343C7CFFBECA1
# gpg: Good signature from "Cédric Le Goater <[email protected]>" [full]
# gpg:                 aka "Cédric Le Goater <[email protected]>" [full]
# Primary key fingerprint: A0F6 6548 F048 95EB FE6B  0B60 51A3 43C7 CFFB ECA1

* tag 'pull-aspeed-20260212' of https://github.com/legoater/qemu:
  tests/functional/aarch64/test_aspeed_ast2700fc: Use AST2700 A2 SDK image for FC tests
  hw/arm/aspeed_ast27x0-fc: Increase BMC DRAM size to 2GB for AST2700 A2
  hw/arm/aspeed_ast27x0-fc: Switch AST2700 FC machine to A2 SoC
  tests/functional/aarch64/test_aspeed_ast2700a2: Add AST2700 A2 EVB functional tests
  tests/functional/aarch64/test_aspeed_ast2700: Rename AST2700 A1 test to reduce test runtime
  tests/qtest/ast2700-hace-test: Use ast2700-evb alias for AST2700 HACE tests
  hw/arm/aspeed_ast27x0_evb: Move ast2700-evb alias to AST2700 A2 EVB
  hw/arm/aspeed_ast27x0_evb: Add AST2700 A2 EVB machine
  hw/arm/aspeed_ast27x0: Add AST2700 A2 SoC support
  hw/misc/aspeed_scu: Add AST2700 A2 silicon revisions
  hw/misc/aspeed_scu: Remove unused SoC silicon revision definitions
  tests/functional/arm/aspeed_ast2600: Enhance OTP test with functional validation
  hw/i2c/aspeed_i2c: Increase I2C device register size to 0xA0
  hw/i2c/aspeed_i2c: Fix out-of-bounds read in I2C MMIO handlers
  tests/functional: Add SDK tests with Linux 5.15
  tests/functional: Split Aspeed ARM tests into separate files

Signed-off-by: Peter Maydell <[email protected]>
2026-02-13 09:33:35 +00:00
Peter Maydell 05167ea35a Merge tag 'ipmi-add-fake-lan-config' of https://github.com/cminyard/qemu into staging
Add a fake LAN config operation for testing

Just add the commands, the proper data that can be set, and some tests.

Submitter ran migration test.

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCgAdFiEE/Q1c5nzg9ZpmiCaGYfOMkJGb/4EFAmmODfcACgkQYfOMkJGb
# /4EGEg/+NAygBBmU3gyBwrbSwS6Zch1Csq9M8sBGexEmbi/T9ICHI8Sfb3aX7JSr
# 3hZS/pPXn9Bb1vNQ5fQ2KCfDY0CjXtNBiSOvttgtYHiYu+Dz7+0WicusGKUoUywp
# jYwzsFaa8Nf//rhNGdXLXOOhNtMHD5ia3awhg5lPBgFTTrfGiKaz9CzTQCaFZtub
# Tt4nWjN+qBXPTBOsLTEZiIJ7qh9LhM56qT6e85wLwLjNSPgmctCTR+j1gg4nWSq2
# SOUQ6KeIY+DGk4G21i2HnHpjZK9BrUoISBElrSUECxRMokOAgPapMzAFZvErDI5n
# SiIuLjJqsOsPqjw60zrGhM81lawqJxSViQtVdHZ2vM4XABMOUs5msgE7doJMPGIH
# Hmnchv7WGZuWIwAsvF1T3fTyLvGES/8pv6UMKLjscdEIO7JMveUAvQHjUN1j06Ny
# p1VEB2EgkPz6YnvxZ2WN693SuWGhAuixRmjBHABwp+l43QvCYen+XMEnaBzcAnKl
# qrNMrU44OXDqofUrb5zaqj5o5Lmv8vjApGa3ouhKmYCinluboEEvPtP8szGVGat3
# k6cRPtz6FkngM1jtAUBCxH2pb0Rol3gFqfkoZRjqO3hyOl8q1ky5nSWcZqiJ5DPE
# fPIZW22ZF3yJPdVtSzwaiJ8klk9z3hgOoFlyZQkojaGuSeu2UOE=
# =QbzC
# -----END PGP SIGNATURE-----
# gpg: Signature made Thu Feb 12 17:29:27 2026 GMT
# gpg:                using RSA key FD0D5CE67CE0F59A6688268661F38C90919BFF81
# gpg: Good signature from "Corey Minyard <[email protected]>" [unknown]
# gpg:                 aka "Corey Minyard <[email protected]>" [unknown]
# gpg:                 aka "Corey Minyard <[email protected]>" [unknown]
# gpg:                 aka "Corey Minyard <[email protected]>" [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: FD0D 5CE6 7CE0 F59A 6688  2686 61F3 8C90 919B FF81

* tag 'ipmi-add-fake-lan-config' of https://github.com/cminyard/qemu:
  hw/ipmi/ipmi_bmc_sim: Support setting fake LAN channel config
  hw/ipmi/ipmi_bmc_sim: Support getting fake LAN channel config

Signed-off-by: Peter Maydell <[email protected]>
2026-02-13 09:33:24 +00:00
Vladimir Sementsov-Ogievskiy b108dcbebc chardev: add logtimestamp option
Add an option to inject timestamps into serial log file.
That simplifies debugging a lot, when you can simply compare
QEMU logs with guest console logs.

Signed-off-by: Vladimir Sementsov-Ogievskiy <[email protected]>
Acked-by: Markus Armbruster <[email protected]>
Reviewed-by: Marc-André Lureau <[email protected]>
Message-ID: <[email protected]>
2026-02-13 10:00:02 +01:00
Vladimir Sementsov-Ogievskiy 2eed5472ec error-report: make real_time_iso8601() public
To be reused in the following commit.

Signed-off-by: Vladimir Sementsov-Ogievskiy <[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Reviewed-by: Marc-André Lureau <[email protected]>
Message-ID: <[email protected]>
2026-02-13 10:00:02 +01:00
Vladimir Sementsov-Ogievskiy fa25379f76 char: qemu_chr_write_log() use qemu_write_full()
logfd is blocking, so we don't need to care about EAGAIN.
Let's simply use qemu_write_full().

Signed-off-by: Vladimir Sementsov-Ogievskiy <[email protected]>
Reviewed-by: Marc-André Lureau <[email protected]>
Message-ID: <[email protected]>
2026-02-13 10:00:02 +01:00
Vladimir Sementsov-Ogievskiy 518d1458bd chardev/char: qemu_char_open(): add return value
Accordingly with recommendations in include/qapi/error.h accompany
errp by boolean return value and get rid of error propagation.

Signed-off-by: Vladimir Sementsov-Ogievskiy <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Marc-André Lureau <[email protected]>
Message-Id: <[email protected]>
2026-02-13 10:00:02 +01:00
Vladimir Sementsov-Ogievskiy bc339129b6 chardev: rework filename handling
Instead of checking, did backend set the filename state or not, let's
be stateless: filename is needed rarely, so, let's just have a generic
function (with optional implementation by backends) to get it.

Signed-off-by: Vladimir Sementsov-Ogievskiy <[email protected]>
[ Marc-André - fix leak in ivshmem-pci.c ]
Signed-off-by: Marc-André Lureau <[email protected]>
Message-Id: <[email protected]>
2026-02-13 10:00:02 +01:00
Vladimir Sementsov-Ogievskiy e43eb54dc8 chardev: introduce .chr_get_pty_name() handler
Currently we do two wrong things:

1. Abuse s->filename to get pty_name from it

2. Violate layering with help of CHARDEV_IS_PTY()

Let's get rid of both, and introduce correct way to get pty name in
generic code, if available.

Signed-off-by: Vladimir Sementsov-Ogievskiy <[email protected]>
Reviewed-by: Marc-André Lureau <[email protected]>
Message-Id: <[email protected]>
2026-02-13 10:00:01 +01:00
Vladimir Sementsov-Ogievskiy 1116f5176e chardev/char-pty: store pty_name into PtyChardev state
We'll use it in following commit.

Note the bonus: stop use blind strcpy().

Signed-off-by: Vladimir Sementsov-Ogievskiy <[email protected]>
Reviewed-by: Marc-André Lureau <[email protected]>
Message-Id: <[email protected]>
2026-02-13 10:00:01 +01:00
Vladimir Sementsov-Ogievskiy 8c84f31ace chardev: .chr_open(): add boolean return value
Add boolean return value to follow common recommendations for functions
with errrp in include/qapi/error.h

Signed-off-by: Vladimir Sementsov-Ogievskiy <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Marc-André Lureau <[email protected]>
Message-Id: <[email protected]>
2026-02-13 10:00:01 +01:00
Vladimir Sementsov-Ogievskiy 0c5d04867a chardev: .chr_open(): drop be_opened parameter
The logic around the parameter is rather tricky. Let's instead
explicitly send CHR_EVENT_OPENED in all backends where needed.

Signed-off-by: Vladimir Sementsov-Ogievskiy <[email protected]>
[ Marc-André - add CHR_EVENT_OPENED in udp_chr_open() ]
Signed-off-by: Marc-André Lureau <[email protected]>
Message-Id: <[email protected]>
2026-02-13 10:00:01 +01:00
Vladimir Sementsov-Ogievskiy 0bc5c851f8 chardev: consistent naming for ChardevClass handlers implementations
Most handlers implementations has name like {unit_name}_{handler_name},
which is usual and well-recognized pattern. Convert the rest (especially
with useless qemu_ prefixes and misleading qmp_ prefixes) to the common
pattern.

Signed-off-by: Vladimir Sementsov-Ogievskiy <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Marc-André Lureau <[email protected]>
Message-Id: <[email protected]>
2026-02-13 10:00:01 +01:00
Vladimir Sementsov-Ogievskiy 6b4f8e7488 chardev: ChardevClass: consistent naming for handlers
Most handlers have name prefixed with "chr_". That's a good practice
which helps to grep them. Convert the rest: .parse, .open,
get/set_msgfds.

Signed-off-by: Vladimir Sementsov-Ogievskiy <[email protected]>
Reviewed-by: Marc-André Lureau <[email protected]>
Message-Id: <[email protected]>
2026-02-13 10:00:01 +01:00
Vladimir Sementsov-Ogievskiy 2a545fd851 ui/spice: drop SPICE_HAS_ATTACHED_WORKER macro
Since previous commit it is always 1. Let's just drop it.

Signed-off-by: Vladimir Sementsov-Ogievskiy <[email protected]>
Reviewed-by: Marc-André Lureau <[email protected]>
Message-Id: <[email protected]>
2026-02-13 10:00:01 +01:00
Vladimir Sementsov-Ogievskiy bd5058cf08 ui/spice: Require spice-server >= 0.15.0
For major distributions we have now:

    Debian 13: 0.15.2
    Ubuntu 22.04: 0.15.0
    RHEL-9/CentOS Stream 9: SPICE is removed
    Fedora 42: 0.15.1
    OpenSUSE Leap 15.4: 0.15.0

Time to update the dependancy in QEMU and drop almost all
SPICE_SERVER_VERSION checks.

Suggested-by: Marc-André Lureau <[email protected]>
Signed-off-by: Vladimir Sementsov-Ogievskiy <[email protected]>
Reviewed-by: Marc-André Lureau <[email protected]>
Message-Id: <[email protected]>
2026-02-13 10:00:01 +01:00
Eric K 45a6256830 char-udp: Fix initial backend open status
This patch removes the `*be_opened = false` override for the UDP chardev
backend. Since UDP is connectionless it never sends a `CHR_EVENT_OPENED`
so it is never marked open. This causes some frontends (e.g. virtio-serial)
to never perform any operations on the socket.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2993
Signed-off-by: Eric K <[email protected]>
Reviewed-by: Marc-André Lureau <[email protected]>
Message-Id: <[email protected]>
2026-02-13 10:00:01 +01:00
Marco Liebel 27e415963a target/hexagon: Remove unused is_finite()
is_finite() is defined but never called anywhere in the codebase.

Signed-off-by: Marco Liebel <[email protected]>
Reviewed-by: Taylor Simpson <[email protected]>
Reviewed-by: Brian Cain <[email protected]>
Signed-off-by: Brian Cain <[email protected]>
2026-02-12 18:39:51 -08:00
Marco Liebel 73aeeaf5e6 target/hexagon: Remove unused EXT_IDX enum
The EXT_IDX_noext, EXT_IDX_mmvec, and XX_LAST_EXT_IDX enum
constants are defined but never referenced anywhere in the
codebase.

Signed-off-by: Marco Liebel <[email protected]>
Reviewed-by: Taylor Simpson <[email protected]>
Reviewed-by: Brian Cain <[email protected]>
Signed-off-by: Brian Cain <[email protected]>
2026-02-12 18:39:51 -08:00
Anton Johansson d6eb20dbee target/hexagon: Widen MemLog::width to 32 bits
MemLog::width is a uint8_t value mapped to a TCGv (32 bit), the only
reason this currently works is because MemLog::width is padded to 32
bits.  Widen the field to uint32_t and fix the size of the TCGv
operations as well.  Use uint32_t when referencing and passing around
the field, as valid values are asserted in commit_store().

Reviewed-by: Brian Cain <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Anton Johansson <[email protected]>

--
Changes in v3:
- Added reviewed-by
Changes in v2:
- Removed truncation to uint8_t, valid values of 1,2,4,8 are checked in
  commit_store() already.

Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Brian Cain <[email protected]>
2026-02-12 18:39:43 -08:00
Brian Cain 20df4ef1c9 target/hexagon: Detect register write conflicts
A conflict exists when any GPR is written by multiple instructions and
at least one write is unconditional.  This catches (1) two unconditional
writes to the same GPR and (2) an unconditional write combined with a
predicated write.

Add HEX_CAUSE_REG_WRITE_CONFLICT and map it to SIGILL.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2696
Reviewed-by: Taylor Simpson <[email protected]>
Signed-off-by: Brian Cain <[email protected]>
2026-02-12 18:38:23 -08:00
Brian Cain 8772ff0085 tests/tcg/hexagon: Handle SIGILL internally in invalid-slots test
Rewrite invalid-slots.c to catch and verify SIGILL using a sigaction
handler that modifies the ucontext, matching the pattern used by
invalid-encoding.c.

Reviewed-by: Taylor Simpson <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Brian Cain <[email protected]>
2026-02-12 18:38:23 -08:00
Brian Cain b0129a14a4 target/hexagon: Return decode failure for invalid non-duplex encodings
When a non-duplex encoding (parse_bits != 0) fails both decode_normal()
and decode_hvx(), the decoder hit an unreachable.  Instead, handle
the decode failure and raise an exception.

Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Taylor Simpson <[email protected]>
Signed-off-by: Brian Cain <[email protected]>
2026-02-12 18:38:23 -08:00
Brian Cain f87873a134 target/hexagon: Fix invalid duplex decoding
When decoding a duplex instruction, if the slot0 sub-instruction fails
to decode after slot1 succeeds, QEMU was leaving the packet in a
partially-decoded state. This allowed invalid duplex encodings (where
one sub-instruction doesn't match any valid pattern) to be executed
incorrectly.

Fix by resetting the decoder state when slot0 fails, returning an empty
instruction that triggers an exception.

Add gen_exception_decode_fail() for raising exceptions when decode fails
before ctx->next_PC is initialized. This keeps gen_exception_end_tb()
semantics unchanged (it continues to use ctx->next_PC for the exception
PC after successful decode).

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3291
Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Taylor Simpson <[email protected]>
Signed-off-by: Brian Cain <[email protected]>
2026-02-12 18:38:19 -08:00
Pierrick Bouvier e82d8af3da contrib/plugins/uftrace: add riscv64 support
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Pierrick Bouvier <[email protected]>
2026-02-12 15:59:48 -08:00
Pierrick Bouvier 5f43899e76 docs/about/emulation/uftrace: add info about automatic tracing
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Pierrick Bouvier <[email protected]>
2026-02-12 15:59:48 -08:00
Pierrick Bouvier c3f8090605 contrib/plugins/uftrace: add ops for walking frame pointers chain
x86_64 and aarch64 use same stack layout. However, other architectures
might use different offset for return address and next frame pointer.

Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Pierrick Bouvier <[email protected]>
2026-02-12 15:59:48 -08:00
Pierrick Bouvier 0b356560e2 contrib/plugins/uftrace: fix infinite stack unwind detection
So far, we were detecting infinite stacks but not stopping unwinding
since break only exited inner loop.

Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Pierrick Bouvier <[email protected]>
2026-02-12 15:59:48 -08:00
Jamin Lin 1b66287951 tests/functional/aarch64/test_aspeed_ast2700fc: Use AST2700 A2 SDK image for FC tests
Update AST2700 FC functional tests to use the AST2700 A2 SDK v11.00 image.

Signed-off-by: Jamin Lin <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-02-12 16:06:55 +01:00
Jamin Lin b90ce0d78c hw/arm/aspeed_ast27x0-fc: Increase BMC DRAM size to 2GB for AST2700 A2
The AST2700 A1 EVB is equipped with 1GB of DRAM, while the AST2700 A2
EVB increases the DRAM size to 2GB.

The ast2700fc machine is updated to support the AST2700 A2. Increase
the BMC DRAM size to 2GB to match the hardware configuration of
AST2700 A2.

Signed-off-by: Jamin Lin <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-02-12 16:06:55 +01:00
Jamin Lin 90876d72c7 hw/arm/aspeed_ast27x0-fc: Switch AST2700 FC machine to A2 SoC
Update the AST2700 FC machine to use the AST2700 A2 SoC model instead of
the A1-specific variant.

This change removes A1-specific naming and definitions from the FC
machine and aligns it with the newer AST2700 A2 silicon.

Signed-off-by: Jamin Lin <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-02-12 16:06:55 +01:00
Jamin Lin 70ae73ac3f tests/functional/aarch64/test_aspeed_ast2700a2: Add AST2700 A2 EVB functional tests
Add functional coverage for the AST2700 A2 EVB machine by introducing
test cases that boot and validate an OpenBMC SDK v11.00 image on
"ast2700a2-evb".

Signed-off-by: Jamin Lin <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-02-12 16:06:55 +01:00
Jamin Lin 37a631db70 tests/functional/aarch64/test_aspeed_ast2700: Rename AST2700 A1 test to reduce test runtime
Adding additional test cases to test_aspeed_ast2700.py makes the test
suite significantly larger and increases the overall test runtime.

To keep testing efficient and better scoped, rename the existing test
to test_aspeed_ast2700a1.py and dedicate it to AST2700 A1 specific tests.

A new test_aspeed_ast2700.py will be introduced later to always cover
the latest revision of the AST2700 SoC.

No functional change.

Signed-off-by: Jamin Lin <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-02-12 16:06:55 +01:00
Jamin Lin 7c79c954aa tests/qtest/ast2700-hace-test: Use ast2700-evb alias for AST2700 HACE tests
Update AST2700 HACE qtests to use the "ast2700-evb" machine alias
instead of a specific silicon revision.

The AST2700 A1 and A2 revisions are compatible for the HACE model, so
the tests do not depend on a particular EVB revision. Using the
"ast2700-evb" alias ensures the tests always run the latest
supported AST2700 silicon revision.

Signed-off-by: Jamin Lin <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-02-12 16:06:55 +01:00
Jamin Lin bed8917d98 hw/arm/aspeed_ast27x0_evb: Move ast2700-evb alias to AST2700 A2 EVB
Make AST2700 A2 EVB the default ast2700-evb machine.

The "ast2700-evb" machine alias is moved from the AST2700 A1 EVB
to the AST2700 A2 EVB, making A2 the default evaluation board
for AST2700.

This ensures that users selecting "ast2700-evb" will run on the
latest AST2700 silicon revision. The AST2700 A1 EVB machine
remains available explicitly as "ast2700a1-evb".

Signed-off-by: Jamin Lin <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-02-12 16:06:55 +01:00
Jamin Lin ec270a67d3 hw/arm/aspeed_ast27x0_evb: Add AST2700 A2 EVB machine
Add a new AST2700 A2 EVB machine to model the newer A2 silicon.

The ast2700a2-evb machine is largely identical to ast2700a1-evb.
The only difference is the default DRAM size, which is increased
to 2 GB.

This change adds a dedicated ast2700a2-evb machine by copying the
existing ast2700a1-evb configuration and updating the DRAM size
accordingly.

Signed-off-by: Jamin Lin <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-02-12 16:06:55 +01:00
Jamin Lin ecfa7ae956 hw/arm/aspeed_ast27x0: Add AST2700 A2 SoC support
AST2700 A2 is functionally identical to AST2700 A1.
There are no changes to the IRQ layout, memory map, or peripheral
configuration. The only difference is the silicon revision.

This commit introduces a dedicated AST2700 A2 SoC type by reusing
the existing AST2700 A1 implementation and setting the A2 silicon
revision accordingly.

Signed-off-by: Jamin Lin <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Reviewed-by: Nabih Estefan <[email protected]>
Tested-by: Nabih Estefan <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-02-12 16:06:55 +01:00
Jamin Lin 6c5e1c5c73 hw/misc/aspeed_scu: Add AST2700 A2 silicon revisions
Add silicon revision definitions for AST2700 A2, and include
them in the list of supported Aspeed silicon revisions.

This allows newer AST27x0 A2 silicon to be correctly identified via
the SCU silicon revision register.

Signed-off-by: Jamin Lin <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-02-12 16:06:55 +01:00
Jamin Lin e202a765c6 hw/misc/aspeed_scu: Remove unused SoC silicon revision definitions
Several legacy Aspeed SoC silicon revision definitions are no longer
used by any machine models or runtime logic.

Remove unused silicon revision macros and corresponding entries from
the silicon revision table to reduce dead code and improve
maintainability.

No functional change intended.

Signed-off-by: Jamin Lin <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-02-12 16:06:55 +01:00
Kane Chen 2451fca14a tests/functional/arm/aspeed_ast2600: Enhance OTP test with functional validation
Improve the OTP test script by adding functional verification of OTP
strap registers. The test now validates that OTP modifications made
in U-Boot persist through the Linux boot process and survive a
subsequent reboot.

Key changes:
- Added interactive console commands for U-Boot and Linux.
- Implemented verification for OTP register 0x30 across reboots.

Signed-off-by: Kane-Chen-AS <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-02-12 16:06:55 +01:00
Jamin Lin 93a5fed3d9 hw/i2c/aspeed_i2c: Increase I2C device register size to 0xA0
According to the AST2700 A1 datasheet, the register space for each I2C
device instance has been expanded from 0x80 bytes to 0xA0 bytes.

Update the AST2700 I2C controller configuration to reflect the new
register layout by increasing the per-device register size to 0xA0
and adjusting the register gap size accordingly.

Signed-off-by: Jamin Lin <[email protected]>
Fixes: 4f53de2f10 ("hw/arm/aspeed_ast27x0: Remove ast2700-a0 SOC")
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-02-12 16:06:55 +01:00
Jamin Lin c2c5beec42 hw/i2c/aspeed_i2c: Fix out-of-bounds read in I2C MMIO handlers
The ASPEED I2C controller exposes a per-bus MMIO window of 0x80 bytes on
AST2600/AST1030/AST2700, but the backing regs[] array was sized for only
28 dwords (0x70 bytes). This allows guest reads in the range [0x70..0x7f]
to index past the end of regs[].

Fix this by:
- Sizing ASPEED_I2C_NEW_NUM_REG to match the 0x80-byte window
  (0x80 >> 2 = 32 dwords).
- Avoiding an unconditional pre-read from regs[] in the legacy/new read
  handlers. Initialize the return value to -1 and only read regs[] for
  offsets that are explicitly handled/valid, leaving invalid offsets to
  return -1 with a guest error log.

Signed-off-by: Jamin Lin <[email protected]>
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3290
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-02-12 16:06:55 +01:00
Cédric Le Goater 308eef22d9 tests/functional: Add SDK tests with Linux 5.15
Add functional tests for AST2500 and AST2600 machines using the
OpenBMC SDK v11.00 with Linux kernel 5.15. These tests complement the
existing SDK tests and verify that QEMU correctly boots older kernel
versions on these platforms.

Link: https://lore.kernel.org/qemu-devel/[email protected]
Reviewed-by: Kane Chen <[email protected]>
Signed-off-by: Cédric Le Goater <[email protected]>
2026-02-12 16:06:55 +01:00
Cédric Le Goater 6b1a1fc1d1 tests/functional: Split Aspeed ARM tests into separate files
Reorganize the monolithic Aspeed functional test files into separate
files based on firmware type (Buildroot vs SDK) and specific test
scenarios. This allows the test suite to run tests in parallel more
effectively and makes it easier to identify and run specific test
scenarios independently.

Link: https://lore.kernel.org/qemu-devel/[email protected]
Reviewed-by: Kane Chen <[email protected]>
Signed-off-by: Cédric Le Goater <[email protected]>
2026-02-12 16:06:55 +01:00
Peter Maydell 4ed6a7f2fd Merge tag 'pull-block-jobs-2026-02-12' of https://gitlab.com/vsementsov/qemu into staging
block: mirror: fix zero bitmap handling

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCgAdFiEEi5wmzbL9FHyIDoahVh8kwfGfefsFAmmNlVcACgkQVh8kwfGf
# eftwBA/8CzB05/OX8vOONCHYPeZI7i2vjw+3yeAm6iIqD5ICDlrmCl6lJP8TpVfa
# DHLAJVfi8DxIeLL72hORlFNEVNSt5qWYI3s+oJajnbX47gf0UNjqDG/NHeIWBDQU
# B+fBEWtRwvqVHjajfRqYwWx4goFSVRjICYbdQRY5R/1Gmw9DnvGsGj+XkAcoQ23a
# Azoqd8HGnRQbhXmvXi9hJDMlrZW0Yuoi6/Jygo3P4ks9c6BundZZFP87OEAbzzH7
# KNbtaWSjH4N8N39wRIF6qxJ5keaPDCY6hkzvXcbit+d6zoifg5sN4JCRcVJ1R8Se
# w2FIksUl0U2pjQ8/pQbZihH480Mhk2cENh8sSQAyYXc6LtCubR6FngFlf3d0Y9ho
# ky3YVnopm+v2++yJEJmqCKRa4Z3WQszO4eXejoheSiMa48FUs1Vh5QcPU7y/EBJf
# NuA5mN9PRs8eMSJ7HEtufY97LoGeJSQYtfhs9xxsdKmETtHgG7cro1Jl0CDDZToX
# cQdpP/sf/XZBb27/KX+x3GuOWp8MYZ78WsrjFQE1WO1ZG1Mn3Bx4WqwNIJG1W6OT
# ZyYt81OESTN1xBbeWnYUsuxIXzH6uGb3guJ6bTRubhlSMemBlun3u+UyyZqs0Dfj
# hnY1kigl9JRNEQ+SOzAqxBukj0wF5pHJYL/3urM0gmu3V6ypeXA=
# =uqha
# -----END PGP SIGNATURE-----
# gpg: Signature made Thu Feb 12 08:54:47 2026 GMT
# gpg:                using RSA key 8B9C26CDB2FD147C880E86A1561F24C1F19F79FB
# gpg: Good signature from "Vladimir Sementsov-Ogievskiy <[email protected]>" [unknown]
# gpg:                 aka "Vladimir Sementsov-Ogievskiy <[email protected]>" [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: 8B9C 26CD B2FD 147C 880E  86A1 561F 24C1 F19F 79FB

* tag 'pull-block-jobs-2026-02-12' of https://gitlab.com/vsementsov/qemu:
  iotests: test active mirror with unaligned, small write zeroes op
  block/mirror: check range when setting zero bitmap for sync write

Signed-off-by: Peter Maydell <[email protected]>
2026-02-12 14:35:18 +00:00
Peter Maydell 216264cb51 Merge tag 'pr-docs-20260211' of https://gitlab.com/pbo-linaro/qemu into staging
Changes:
- docs/devel: s/most/most recent/ ``probe_target_compiler`` call (Alex Bennée <[email protected]>)
- docs/devel: fix bash-ism warning for configure (Alex Bennée <[email protected]>)

# -----BEGIN PGP SIGNATURE-----
#
# iQGzBAABCgAdFiEEZrmU7KFPfy5auggff5BUDQoc0A8FAmmMuc8ACgkQf5BUDQoc
# 0A+p3AwAiMDjbx0oX9To6LhQhTxoLNtvqh7UxrnezA4G+JWwViKz7c7OslJS1Vnb
# PNpwy13ja9tZc9vdx8Yt7D526IM6NPaUa1bvR6NonxL6sQhBjG9TaoQU8vqJBTPe
# WDAFvfX6CMuR+IDXl5ZWguFlg2rFRQ/p/hFsZqHpObf5sIzBXIMQunERRab8tOiG
# 1SLpoliTv5G+/oEtfihT2WNAJy3+VdWn/mn2X1mnjnDia4ousPAhEs+qwhSAISbA
# 1IXtTnbws7hHF8UmTPopMwlh/SRL3kVvA1QwvW/lO1oR0oG7lKxTvgGKCUdDptEW
# EV7X6VwOrRXuH+F/VxIgE4/FLCxUeew1Mh2luaCX8+7oxtkVz4Vu1USwVxf2ECP5
# ZxNtqIB+XUsfGxtKBHlUUuur/EhRDOj/twmE41GuWZjAnCSPqrEwBqZbB4Xk05TM
# iuubgxCdRwYhwkZpiT130bA6M01gO4jcRE60A35MaNor/tUS1aINI3SPAzmIrf3+
# St9fk1jz
# =Dzwx
# -----END PGP SIGNATURE-----
# gpg: Signature made Wed Feb 11 17:18:07 2026 GMT
# gpg:                using RSA key 66B994ECA14F7F2E5ABA081F7F90540D0A1CD00F
# gpg: Good signature from "Pierrick Bouvier <[email protected]>" [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: 66B9 94EC A14F 7F2E 5ABA  081F 7F90 540D 0A1C D00F

* tag 'pr-docs-20260211' of https://gitlab.com/pbo-linaro/qemu:
  docs/devel: fix bash-ism warning for configure
  docs/devel: s/most/most recent/ ``probe_target_compiler`` call

Signed-off-by: Peter Maydell <[email protected]>
2026-02-12 14:35:05 +00:00
Peter Maydell c848bce261 Merge tag 'pr-plugins_llvm_dlltool-20260210' of https://gitlab.com/pbo-linaro/qemu into staging
plugins: fix cross-build using LLVM for Windows targets (Mohamed Mediouni <[email protected]>)

# -----BEGIN PGP SIGNATURE-----
#
# iQGzBAABCgAdFiEEZrmU7KFPfy5auggff5BUDQoc0A8FAmmLtlAACgkQf5BUDQoc
# 0A/Ljwv/Taze++KA6wxXQ1IFVqNHjiXxYl/IcPRvAEHGSm9AaBihpUWbCCxliiLg
# M4XtOJU6FVYQhYwe/HbazrWzgOQaA8+7NOhu4+NQydAWvHauDTulBXSgcsmO1mlS
# xOTNBhDJkg/jqw5O0AaBjE4U6tJ69+M5h9/zErhIwJYJqj1bC1hPNMPPs9iwB+b4
# z+WIR5wSBr16LW1M+c0vV8xCSSSE4U5cvQAZnwQv5Fl+VPMmwE2lEoBHBO7P+KBn
# /lcUtdMvB7yneNWQGCiOVBzLft2o95atY4Cfv0ON/EowehEwhfSG9T5DF3gCK95B
# qd0MHEyNkq3RXxvK7IimrBN2CSiS+4DCxttN/+8PuPFQZXk//1amg9EgK+s0OL1V
# RJfWE0PbocWhrEj/d6WPGY5xiTzA43kAgbsMvWjBLYQyrwZR0plBtSQUE6fkC45F
# SpqYQCn1BLCYnJ/L0OVpIzDFtwBGl7Rw0LB+i+Fji7OHAiI2g0hAysAi9pjhlHwi
# LxNOGjNY
# =uxQA
# -----END PGP SIGNATURE-----
# gpg: Signature made Tue Feb 10 22:50:56 2026 GMT
# gpg:                using RSA key 66B994ECA14F7F2E5ABA081F7F90540D0A1CD00F
# gpg: Good signature from "Pierrick Bouvier <[email protected]>" [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: 66B9 94EC A14F 7F2E 5ABA  081F 7F90 540D 0A1C D00F

* tag 'pr-plugins_llvm_dlltool-20260210' of https://gitlab.com/pbo-linaro/qemu:
  plugins: fix cross-build using LLVM for Windows targets

Signed-off-by: Peter Maydell <[email protected]>
2026-02-12 14:34:48 +00:00
Peter Maydell 039fae56bb Merge tag 'pull-request-2026-02-12v2' of https://gitlab.com/thuth/qemu into staging
* Updates to MAINTAINERS file
* Fix CI (broken pkg_resources in python, revert RCU change to fix alpha test)
* Fix endianness issue in PCI code on s390x
* Implement DIVIDE TO INTEGER instruction for s390x TCG emulation
* Bitesized documentation updates (run-tcg-tests target and fd-bootchk property)

# -----BEGIN PGP SIGNATURE-----
#
# iQJFBAABCgAvFiEEJ7iIR+7gJQEY8+q5LtnXdP5wLbUFAmmNu6ERHHRodXRoQHJl
# ZGhhdC5jb20ACgkQLtnXdP5wLbU+9Q//WVNddXAhre9g40SMvUULwFsoXIHtXASq
# 0WcL+GiZEenuON8YYvKVEUobNPEHtwm6GRKUwAeqCXQPXGEHamY3htMK5/HY9h2D
# dFG6XJr/0JozAFp381lhUt/Gu1b56uljqF3CzSf/AvidmFoxOH2Pi+IHcyzZZTkI
# DvsXbbIHim6dsMzxLpGBSDGj4+Jdz9t9HJF59Q7XO41EMgFKJzqBUDuVzL1ZZzg8
# rcV1yfrEJ1RmdK9+ZCweLTn1SnCjn1yywigzQUvMlguw2Tl9IWPFNmuhfs9u8KOv
# LEqteHnxJyslFZpBXTN5vxwM9FghWnACvGAKDln38N3kI56PbKRe6De6dZYh9Ihb
# ea3Uiaji2z8TI1xRHnWqGuT9gz9aRo1bMM6pCaX5rfxZ05xHmoP0qA1Ul20pr4I0
# +YPyhKG45JmrGkV+HKnQtq1k+8Xnl8Xon9gIgKM/f2r9fQ4wXjU0lIGWCxhSl9UV
# MntuoZtYeDs4S5WFnW2bhVYDIKsf+mbfoSBUYmAYAVqjbuqSX5tAsGPfYJ2l9+sR
# rwG0iuJcW/kYpkyNFV9xKKuhX7qh17N4TUgU7KkvIoVkRP++2quzwXuHOniDOiJ5
# Gl68R96GRSleWUusL1tKexVmOuQcZGST/SzGLol/L1Ob3iXawjfy0Y2C+rYsfOO7
# 5XX4X7alVew=
# =oaJh
# -----END PGP SIGNATURE-----
# gpg: Signature made Thu Feb 12 11:38:09 2026 GMT
# gpg:                using RSA key 27B88847EEE0250118F3EAB92ED9D774FE702DB5
# gpg:                issuer "[email protected]"
# gpg: Good signature from "Thomas Huth <[email protected]>" [full]
# gpg:                 aka "Thomas Huth <[email protected]>" [full]
# gpg:                 aka "Thomas Huth <[email protected]>" [full]
# gpg:                 aka "Thomas Huth <[email protected]>" [undefined]
# Primary key fingerprint: 27B8 8847 EEE0 2501 18F3  EAB9 2ED9 D774 FE70 2DB5

* tag 'pull-request-2026-02-12v2' of https://gitlab.com/thuth/qemu:
  python: drop uses of pkg_resources
  hw/i386/pc.c: add description for fd-bootchk option
  tests/Makefile.include: add run-tcg-tests-TARGET to check-help
  tests/tcg/s390x: Test DIVIDE TO INTEGER
  target/s390x: Implement DIVIDE TO INTEGER
  fpu: Restrict parts_round_to_int_normal to target precision
  target/s390x: Extract s390_get_bfp_rounding_mode()
  target/s390x: Dump Floating-Point-Control Register
  Revert "rcu: Unify force quiescent state"
  s390x/pci: Fix endianness for zPCI BAR values.
  virtio-ccw: virtio_ccw_set_guest_notifier(): fix failure path
  tests/.../reverse_debugging: Remove unsatisfiable condition
  MAINTAINERS: Replace backup for s390 PCI
  MAINTAINERS: Switch to my NVIDIA email

Signed-off-by: Peter Maydell <[email protected]>
2026-02-12 11:52:31 +00:00
John Snow e44a26ba94 python: drop uses of pkg_resources
pkg_resources has been fully dropped from modern pip/setuptools
distributions and we should phase out its use. This patch is enough to,
by itself, repair most GitLab CI tests upstream; with the exception of
tox tests which are still making use of avocado - which will be dropped
in a separate series to restore functionality there.

Signed-off-by: John Snow <[email protected]>
Suggested-by: Peter Maydell <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
2026-02-12 12:34:00 +01:00
Choon Keong e8cf82eb72 hw/i386/pc.c: add description for fd-bootchk option
The 'fd-bootchk' option for pc and q35 machines currently lacks of
description in the help output. This makes it difficult for users
to understand the purpose of the command.

This commit solve this issue by adding description using
object_class_property_set_description() in hw/i386/pc.c,
adding the the description message for the option 'fd-bootchk'.

Suggested-by: Peter Maydell <[email protected]>
Suggested-by: Thomas Huth <[email protected]>
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3193
Signed-off-by: Choon Keong <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
2026-02-12 12:05:10 +01:00
Choon Keong 76959197dd tests/Makefile.include: add run-tcg-tests-TARGET to check-help
User can execute TCG tests for a specific TARGET using the command:
$ make run-tcg-tests-TARGET-softmmu

However, this command is not showing in 'make check-help'
documentation, making it hard for new contributors to
discover.

This commit help to resolve this by adding the description
for the command, to the "check-tcg" section, as suggested
by Thomas, in tests/Makefile.include.

Additionally, reformat the alignment to accommodate
the length of the new command, ensuring the
consistency of the output.

Suggested-by: Thomas Huth <[email protected]>
Reported-by: Philippe Mathieu-Daudé <[email protected]>
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/228
Signed-off-by: ck <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
2026-02-12 12:05:10 +01:00
Ilya Leoshkevich a6364b292f tests/tcg/s390x: Test DIVIDE TO INTEGER
Add a test to prevent regressions. Data is generated using a
libFuzzer-based fuzzer and hopefully covers all the important corner
cases.

Acked-by: Alex Bennée <[email protected]>
Signed-off-by: Ilya Leoshkevich <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
2026-02-12 09:40:55 +01:00
Ilya Leoshkevich 8eb8c1bc59 target/s390x: Implement DIVIDE TO INTEGER
DIVIDE TO INTEGER computes floating point remainder and is used by
LuaJIT, so add it to QEMU.

Put the main logic into fpu/, because it is way more convenient to
operate on FloatParts than to convert floats back-and-forth.

Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Ilya Leoshkevich <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
2026-02-12 09:40:55 +01:00
Ilya Leoshkevich b4a85d8fe7 fpu: Restrict parts_round_to_int_normal to target precision
Currently parts_round_to_int_normal() assumes that its input has just
been unpacked and therefore doesn't expect non-zero fraction bits past
target precision.

The upcoming DIVIDE TO INTEGER use cases needs it to support
calculations on intermediate values that utilize all fraction bits,
while at the same time restricting the result's precision to frac_size.

Delete the "All integral" check, because even though really large
values are always integer, their low fraction bits still need to be
truncated. For the same reason, make sure rnd_mask covers at least
fraction bits past target precision.

Signed-off-by: Ilya Leoshkevich <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
2026-02-12 09:40:45 +01:00
Fiona Ebner 267d7ae99a iotests: test active mirror with unaligned, small write zeroes op
This tests the scenario fixed by "block/mirror: check range
when setting zero bitmap for sync write" [0].

[0] https://lore.kernel.org/qemu-devel/[email protected]/

Signed-off-by: Fiona Ebner <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Vladimir Sementsov-Ogievskiy <[email protected]>
Tested-by: Vladimir Sementsov-Ogievskiy <[email protected]>
Signed-off-by: Vladimir Sementsov-Ogievskiy <[email protected]>
2026-02-12 11:38:18 +03:00
Fiona Ebner 4a7b1bd18d block/mirror: check range when setting zero bitmap for sync write
Some Proxmox users reported an occasional assertion failure [0][1] in
busy VMs when using drive mirror with active mode. In particular, the
failure may occur for zero writes shorter than the job granularity:

> #0  0x00007b421154b507 in abort ()
> #1  0x00007b421154b420 in ?? ()
> #2  0x0000641c582e061f in bitmap_set (map=0x7b4204014e00, start=14, nr=-1)
> #3  0x0000641c58062824 in do_sync_target_write (job=0x641c7e73d1e0,
>       method=MIRROR_METHOD_ZERO, offset=852480, bytes=4096, qiov=0x0, flags=0)
> #4  0x0000641c58062250 in bdrv_mirror_top_do_write (bs=0x641c7e62e1f0,
        method=MIRROR_METHOD_ZERO, copy_to_target=true, offset=852480,
        bytes=4096, qiov=0x0, flags=0)
> #5  0x0000641c58061f31 in bdrv_mirror_top_pwrite_zeroes (bs=0x641c7e62e1f0,
        offset=852480, bytes=4096, flags=0)

The range for the dirty bitmap described by dirty_bitmap_offset and
dirty_bitmap_end is narrower than the original range and in fact,
dirty_bitmap_end might be smaller than dirty_bitmap_offset. There
already is a check for 'dirty_bitmap_offset < dirty_bitmap_end' before
resetting the dirty bitmap. Add such a check for setting the zero
bitmap too, which uses the same narrower range.

[0]: https://forum.proxmox.com/threads/177981/
[1]: https://bugzilla.proxmox.com/show_bug.cgi?id=7222

Cc: [email protected]
Fixes: 7e277545b9 ("mirror: Skip writing zeroes when target is already zero")
Signed-off-by: Fiona Ebner <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Vladimir Sementsov-Ogievskiy <[email protected]>
Signed-off-by: Vladimir Sementsov-Ogievskiy <[email protected]>
2026-02-12 11:38:17 +03:00
Ilya Leoshkevich f5682b9dee target/s390x: Extract s390_get_bfp_rounding_mode()
For DIVIDE TO INTEGER it will be helpful to pass final-quotient
rounding mode around explicitly rather than setting it in fpu_status
implicitly. To facilitate this, extract a function for converting the
mask to the rounding mode.

Reviewed-by: Richard Henderson <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Signed-off-by: Ilya Leoshkevich <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
2026-02-12 08:43:13 +01:00
Ilya Leoshkevich 5b251330e4 target/s390x: Dump Floating-Point-Control Register
Knowing the value of this register is very useful for debugging
floating-point code.

Reviewed-by: Alex Bennée <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Signed-off-by: Ilya Leoshkevich <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
2026-02-12 08:43:13 +01:00
Thomas Huth ddb4d9d174 Revert "rcu: Unify force quiescent state"
This reverts commit 55d98e3ede.

The commit introduced a regression in the replay functional test
on alpha (tests/functional/alpha/test_replay.py), that causes CI
failures regularly. Thus revert this change until someone has
figured out what is going wrong here.

Buglink: https://gitlab.com/qemu-project/qemu/-/issues/3197
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
2026-02-12 08:43:13 +01:00
Alex Bennée db61fb7a57 docs/devel: fix bash-ism warning for configure
Hopefully this makes the meaning clearer.

Signed-off-by: Alex Bennée <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Reviewed-by: Daniel P. Berrangé <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Pierrick Bouvier <[email protected]>
2026-02-11 09:15:35 -08:00
Alex Bennée 3e11c6dfa1 docs/devel: s/most/most recent/ `probe_target_compiler` call
Signed-off-by: Alex Bennée <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Reviewed-by: Daniel P. Berrangé <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Pierrick Bouvier <[email protected]>
2026-02-11 09:15:35 -08:00
Peter Maydell 44dba5a0c8 Merge tag 'pull-tpm-2026-02-10-1' of https://github.com/stefanberger/qemu-tpm into staging
Merge tpm 2026/02/10 v1

# -----BEGIN PGP SIGNATURE-----
#
# iQEzBAABCgAdFiEEuBi5yt+QicLVzsZrda1lgCoLQhEFAmmLUPwACgkQda1lgCoL
# QhH6Dwf/b2CqCmWwt4otJIYteKdhOGOuurL9jo2YWthJKj6hr3SuefRnflSweQTD
# 2Mij2tdfu089gWC7qmvLNeqCBKT0L9q80sV6YPD4RJBrybcVBQRYeO7aDM2HhYjq
# Q5AjHnToIdKgwr8rniccH0dOnGyCTMbe3jmamT8hr32Cev8Lu2++Hkxu0FEj/6Ur
# +yGIu0yNn5Es+IOX1Kd01n3LZb0TLpDRGglWScWZxh4jc99CHhzRNFn4IQfSqbAE
# A5rqN5bWY0p855h/+XNNdOiocx/hlrzyl47FWatzFJTaxvGka3N4WYVtrd6U0g1w
# ByP8ajaONqiQgo1tsV+52yWz7jj+vg==
# =quEE
# -----END PGP SIGNATURE-----
# gpg: Signature made Tue Feb 10 15:38:36 2026 GMT
# gpg:                using RSA key B818B9CADF9089C2D5CEC66B75AD65802A0B4211
# gpg: Good signature from "Stefan Berger <[email protected]>" [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: B818 B9CA DF90 89C2 D5CE  C66B 75AD 6580 2A0B 4211

* tag 'pull-tpm-2026-02-10-1' of https://github.com/stefanberger/qemu-tpm:
  tpm_emulator: tpm_emulator_set_state_blobs(): move to boolean return
  tpm_emulator: drop direct use of errno variable
  tpm_emulator: print error on error-ignore path

Signed-off-by: Peter Maydell <[email protected]>
2026-02-11 15:12:50 +00:00
Peter Maydell 2f0870fd6a Merge tag 'pull-target-arm-20260210' of https://gitlab.com/pm215/qemu into staging
target-arm queue:
 * Add whpx accelerator support for the virt board
 * Implement FEAT_E2H0
 * Implement WFE, SEV and SEVONPEND for Cortex-M

# -----BEGIN PGP SIGNATURE-----
#
# iQJNBAABCAA3FiEE4aXFk81BneKOgxXPPCUl7RQ2DN4FAmmLN9kZHHBldGVyLm1h
# eWRlbGxAbGluYXJvLm9yZwAKCRA8JSXtFDYM3jlTD/9RlOP4M+qJQ67v5/vzJkOC
# tml5W+iUINIuPrJyZn3+AtLZoyS5GHH+lkBLwuRkdIpx9LjEApfr/4/T45quRqj1
# T0ziJXPQpSC6+3eVyJcfAg4ROtQSZq1+JUGQdCGocxyrwHxTKKI3LHyQezLhe56G
# +U/z1cI+DZPuYIdzz3LneIrNopsxEdmlWLlcR3e9HaSp15rcYrYwjOn08eTTk8HV
# e5pCu/1kq8LHlf8lwqwDwHL9odfW9W5570hPcuFZcjy1cUzzOJty3AW644Jlj4aw
# MEnyvvqCXKPSgOQ9N+W9TT2veU60h7aWov3N5S+HmYix3ZsFgbI8w/9SdDjeJlkH
# RFb/apdK8xcEktbsGaToEZOp1Wz1vxOMoGVCGayfYZ4byBhTAjOp5YLH2+26JDze
# I7o4q2PYENNP4r0ayOIbPcayBzlkp53VROZKILyQfQfwfChnoaFlkBeqVvF/PUxt
# CNsei6qDY2jsArhUieZ8CkHbOSlCeg22+7HjNTjp6b1h4lr3p4/tnFobJAYJrtRB
# 5v6EGaWnejEvsbcKV0aZhtVITygcny7tENZUkKlKoPeNr4k0R6dyFNKDcShLhv75
# 42ms95D7T/j4weJt6G3E9t1kqFCMl3KM8qwMT7nDJ1xiSVOw329sMtCcazAssDQ/
# 5ecCq9cGSaGUROwlnoUDpQ==
# =pzkY
# -----END PGP SIGNATURE-----
# gpg: Signature made Tue Feb 10 13:51:21 2026 GMT
# gpg:                using RSA key E1A5C593CD419DE28E8315CF3C2525ED14360CDE
# gpg:                issuer "[email protected]"
# gpg: Good signature from "Peter Maydell <[email protected]>" [ultimate]
# gpg:                 aka "Peter Maydell <[email protected]>" [ultimate]
# gpg:                 aka "Peter Maydell <[email protected]>" [ultimate]
# gpg:                 aka "Peter Maydell <[email protected]>" [ultimate]
# Primary key fingerprint: E1A5 C593 CD41 9DE2 8E83  15CF 3C25 25ED 1436 0CDE

* tag 'pull-target-arm-20260210' of https://gitlab.com/pm215/qemu: (26 commits)
  target/arm: implement FEAT_E2H0
  target/arm: Implement WFE, SEV and SEVONPEND for Cortex-M
  target/arm: Remove entry for "any" from cpu32 arm_tcg_cpus[] list
  hw/arm/virt: Rename arm_virt_compat into arm_virt_compat_defaults
  whpx: arm64: add partition-wide reset on the reboot path
  whpx: enable arm64 builds
  target/arm: whpx: instantiate GIC early
  whpx: arm64: implement -cpu host
  hw/arm, accel/hvf, whpx: unify get_physical_address_range between WHPX and HVF
  whpx: arm64: clamp down IPA size
  target/arm: cpu: mark WHPX as supporting PSCI 1.3
  whpx: change memory management logic
  whpx: add arm64 support
  hw, target, accel: whpx: change apic_in_platform to kernel_irqchip
  whpx: common: add WHPX_INTERCEPT_DEBUG_TRAPS define
  whpx: ifdef out winhvemulation on non-x86_64
  whpx: reshuffle common code
  whpx: Move around files before introducing AArch64 support
  docs: arm: update virt machine model description
  qtest: hw/arm: virt: add new test case for GICv3 + GICv2m
  ...

Signed-off-by: Peter Maydell <[email protected]>
2026-02-11 15:12:42 +00:00
Jaehoon Kim 00ebc44514 s390x/pci: Fix endianness for zPCI BAR values.
During zPCI scan, BAR configuration data retrieved via CLP Query was
misinterpreted due to an endianness mismatch between QEMU and the guest
kernel.

The guest kernel's clp_store_query_pci_fn() expects BAR values in
little-endian format and converts them with le32_to_cpu(). However, QEMU
was incorrectly sending them in big-endian format, not following the
architecture specification. This caused incorrect bit-swapping in the
kernel, leading zpci_setup_bus_resources() to perform registration checks
against invalid flags, making the process ineffective.

Observation values for zPCI device (NVMe passthrough):
LPAR from real CLP:
[    0.865595] Resource: PCI Bus 0000:00 -> zdev->bar[0].val: 0x4
[    0.865597]  start: 0x4000000000000000
[    0.865598]  end:   0x4000000000003fff
[    0.865600]  flags: 0x100200

QEMU before fix (wrong):
[    0.601083] Resource: PCI Bus 0001:00 -> zdev->bar[0].val: 0x4000000
[    0.601085]  start: 0x4003000000000000
[    0.601086]  end:   0x4003000000003fff
[    0.601087]  flags: 0x200

QEMU after fix (correct):
[    0.601116] Resource: PCI Bus 0001:00 -> zdev->bar[0].val: 0x4
[    0.601117]  start: 0x4003000000000000
[    0.601118]  end:   0x4003000000003fff
[    0.601119]  flags: 0x100200

Signed-off-by: Jaehoon Kim <[email protected]>
Reviewed-by: Matthew Rosato <[email protected]>
Reviewed-by: Farhan Ali <[email protected]>
Reviewed-by: Eric Farman <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
2026-02-11 08:36:09 +01:00
Mohamed Mediouni b0353beebb plugins: fix cross-build using LLVM for Windows targets
llvm-dlltool assumes that it's by default targeting the host architecture
it's running on. That assumption doesn't hold true when cross-compiling.

Signed-off-by: Mohamed Mediouni <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Tested-by: Pierrick Bouvier <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Pierrick Bouvier <[email protected]>
2026-02-10 12:58:31 -08:00
Vladimir Sementsov-Ogievskiy 46565a8db1 tpm_emulator: tpm_emulator_set_state_blobs(): move to boolean return
The returned error is only used to check for success, so no reason
to use specific errno values.

Also, this is the only function with -errno contract in the file,
so converting it simplifies the whole file from three types of
contract (0/-1, 0/-errno, true/false) to only two (0/-1, true/false).

Signed-off-by: Vladimir Sementsov-Ogievskiy <[email protected]>
Reviewed-by: Stefan Berger <[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Signed-off-by: Stefan Berger <[email protected]>
2026-02-10 10:35:55 -05:00
Vladimir Sementsov-Ogievskiy 18264ce6d6 tpm_emulator: drop direct use of errno variable
The code tends to include errno into error messages after
tpm_util_test_tpmdev() and tpm_emulator_ctrlcmd() calls.

Both has error paths, where errno is not set, examples:

tpm_emulator_ctrlcmd()
  qemu_chr_fe_write_all()
    qemu_chr_write()
      replay_char_write_event_load()
        ...
        *res = replay_get_dword();
        ...

tpm_util_test_tpmdev()
  tpm_util_test()
    tpm_util_request()
      ...
      if (n != requestlen) {
          return -EFAULT;
      }
      ...

Both doesn't document that they set errno.

Let's drop these explicit usage of errno. If we need this information,
it should be added to errp deeper in the stack.

Signed-off-by: Vladimir Sementsov-Ogievskiy <[email protected]>
Reviewed-by: Stefan Berger <[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Signed-off-by: Stefan Berger <[email protected]>
2026-02-10 10:35:49 -05:00
Vladimir Sementsov-Ogievskiy e4244f84b3 tpm_emulator: print error on error-ignore path
Commit 3469a56fa3 introduced errp passthrough for many
errors in the file. But in this specific case in
tpm_emulator_get_buffer_size(), it simply used errp=NULL, so we lose
printed error. Let's bring it back

Note also, that 3469a56fa3 was fixing another commit,
42e556fa3f "backends/tpm: Propagate vTPM error on migration failure"
and didn't mention it.

Fixes: 3469a56fa3 "tmp_emulator: improve and fix use of errp"
Signed-off-by: Vladimir Sementsov-Ogievskiy <[email protected]>
Reviewed-by: Stefan Berger <[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Signed-off-by: Stefan Berger <[email protected]>
2026-02-10 10:35:26 -05:00
Alex Bennée a2834b853d target/arm: implement FEAT_E2H0
FEAT_E2H0 is a formalisation of the existing behaviour of HCR_EL2.E2H
being programmable to switch between EL2 host mode and the
"traditional" nVHE EL2 mode. This implies at some point we might want
to model CPUs without FEAT_E2H0 which will always have EL2 host mode
enabled.

There are two values to represent no E2H0 systems of which 0b1110 will
make HCR_EL2.NV1 RES0 for FEAT_NV systems. For FEAT_NV2 the NV1 bit is
always valid.

Message-ID: <[email protected]>
Signed-off-by: Alex Bennée <[email protected]>
Reviewed-by: Mohamed Mediouni <[email protected]>
Message-id: [email protected]

Reviewed-by: Peter Maydell <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
2026-02-10 12:52:39 +00:00
Ashish Anand d238858bff target/arm: Implement WFE, SEV and SEVONPEND for Cortex-M
Currently, QEMU implements the 'Wait For Event' (WFE) instruction as a
simple yield. This causes high host CPU usage because guest
RTOS idle loops effectively become busy-wait loops.

To improve efficiency, this patch transitions WFE to use the architectural
'Halt' state (EXCP_HLT) for M-profile CPUs. This allows the host thread
to sleep when the guest is idle.

To support this transition, we implement the full architectural behavior
required for WFE, specifically the 'Event Register', 'SEVONPEND' logic,
and 'R_BPBR' exception handling requirements defined in the ARM
Architecture Reference Manual.

This patch enables resource-efficient idle emulation for Cortex-M.

Signed-off-by: Ashish Anand <[email protected]>
Message-id: [email protected]
Reviewed-by: Peter Maydell <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
2026-02-10 11:39:33 +00:00
Philippe Mathieu-Daudé bc3d2e7067 target/arm: Remove entry for "any" from cpu32 arm_tcg_cpus[] list
Since commit a0032cc542 ("target/arm: Make 'any' CPU just an alias
for 'max'") the 'any' CPU QOM type is never used, because we change
"any" to "max" before creating the object.  The array entry means we
have an unnecessary type in the system, and the only user-visible
effect is that "any" is listed in the "-cpu help" output for
qemu-arm.  (System emulation already doesn't include this array
entry.)

Since qemu-aarch64 already doesn't include "any" in its "-cpu help"
output, we can reasonably drop it for qemu-arm also; remove the
not-very-useful array entry.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Message-id: [email protected]
[PMM: update commit message to note effect on help output.]
Signed-off-by: Peter Maydell <[email protected]>
2026-02-10 11:34:49 +00:00
Eric Auger 5484e94cd4 hw/arm/virt: Rename arm_virt_compat into arm_virt_compat_defaults
Renaming arm_virt_compat into arm_virt_compat_defaults
makes more obvious that those compats apply to all machine
types by default, if not overriden for specific ones. This also
matches the terminology used for pc-q35.

Suggested-by: Igor Mammedov <[email protected]>
Signed-off-by: Eric Auger <[email protected]>
Reviewed-by: Sebastian Ott <[email protected]>
Reviewed-by: Cornelia Huck <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
2026-02-10 11:34:49 +00:00
Mohamed Mediouni ac4af772ad whpx: arm64: add partition-wide reset on the reboot path
This resets non-architectural state to allow for reboots to succeed.

Signed-off-by: Mohamed Mediouni <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Peter Maydell <[email protected]>
2026-02-10 11:34:49 +00:00
Mohamed Mediouni b21fa1218d whpx: enable arm64 builds
Signed-off-by: Mohamed Mediouni <[email protected]>

Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Peter Maydell <[email protected]>
2026-02-10 11:34:49 +00:00
Mohamed Mediouni 515bf55441 target/arm: whpx: instantiate GIC early
While figuring out a better spot for it, put it in whpx_accel_init.

Needs to be done before WHvSetupPartition.

Signed-off-by: Mohamed Mediouni <[email protected]>

Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Peter Maydell <[email protected]>
2026-02-10 11:34:49 +00:00
Mohamed Mediouni f7fa2b8808 whpx: arm64: implement -cpu host
Logic to fetch MIDR_EL1 for cpu 0 adapted from:
https://github.com/FEX-Emu/FEX/blob/e6de17e72ef03aa88ba14fa0ec13163061608c74/Source/Windows/Common/CPUFeatures.cpp#L62

Signed-off-by: Mohamed Mediouni <[email protected]>

Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Peter Maydell <[email protected]>
2026-02-10 11:34:49 +00:00
Mohamed Mediouni 293984563e hw/arm, accel/hvf, whpx: unify get_physical_address_range between WHPX and HVF
Signed-off-by: Mohamed Mediouni <[email protected]>

Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
2026-02-10 11:34:49 +00:00
Mohamed Mediouni ea475a5ebb whpx: arm64: clamp down IPA size
Code taken from HVF and adapted for WHPX use. Note that WHPX doesn't
have a default vs maximum IPA distinction.

Signed-off-by: Mohamed Mediouni <[email protected]>

Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
2026-02-10 11:34:49 +00:00
Mohamed Mediouni 5ae1609f00 target/arm: cpu: mark WHPX as supporting PSCI 1.3
Hyper-V supports PSCI 1.3, and that implementation is exposed through
WHPX.

Signed-off-by: Mohamed Mediouni <[email protected]>

Reviewed-by: Richard Henderson <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Peter Maydell <[email protected]>
2026-02-10 11:34:49 +00:00
Mohamed Mediouni bf36e65bda whpx: change memory management logic
This allows edk2 to work on Arm, although u-boot is still not functional.

Signed-off-by: Mohamed Mediouni <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Peter Maydell <[email protected]>
2026-02-10 11:34:49 +00:00
Mohamed Mediouni 59432082ce whpx: add arm64 support
Signed-off-by: Mohamed Mediouni <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
2026-02-10 11:34:49 +00:00
Mohamed Mediouni e4c95f78a4 hw, target, accel: whpx: change apic_in_platform to kernel_irqchip
Change terminology to match the KVM one, as APIC is x86-specific.

And move out whpx_irqchip_in_kernel() to make it usable from common
code even when not compiling with WHPX support.

Signed-off-by: Mohamed Mediouni <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Peter Maydell <[email protected]>
2026-02-10 11:34:49 +00:00
Mohamed Mediouni 7573977b4e whpx: common: add WHPX_INTERCEPT_DEBUG_TRAPS define
As of why: WHPX on arm64 doesn't have debug trap support as of today.

Keep the exception bitmap interface for now - despite that being entirely unavailable on arm64 too.

Signed-off-by: Mohamed Mediouni <[email protected]>

Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Peter Maydell <[email protected]>
2026-02-10 11:34:49 +00:00
Mohamed Mediouni 69ac30ea1b whpx: ifdef out winhvemulation on non-x86_64
winhvemulation is x86_64 only.

In the future, we might want to get rid of winhvemulation usage
entirely.

Signed-off-by: Mohamed Mediouni <[email protected]>

Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
2026-02-10 11:34:49 +00:00
Mohamed Mediouni 4610fee324 whpx: reshuffle common code
Some code can be shared between x86_64 and arm64 WHPX. Do so as much as reasonable.

Signed-off-by: Mohamed Mediouni <[email protected]>

Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Peter Maydell <[email protected]>
2026-02-10 11:34:49 +00:00
Mohamed Mediouni 1f1f9fd88c whpx: Move around files before introducing AArch64 support
Switch to a design where we can share whpx code between x86 and AArch64 when it makes sense to do so.

Signed-off-by: Mohamed Mediouni <[email protected]>

Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Peter Maydell <[email protected]>
2026-02-10 11:34:49 +00:00
Mohamed Mediouni 5bc283d705 docs: arm: update virt machine model description
Update the documentation to match current QEMU.

Remove the mention of pre-2.7 machine models as those aren't provided
anymore.

Signed-off-by: Mohamed Mediouni <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
2026-02-10 11:34:49 +00:00
Mohamed Mediouni 72a231af4c qtest: hw/arm: virt: add new test case for GICv3 + GICv2m
Signed-off-by: Mohamed Mediouni <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
2026-02-10 11:34:48 +00:00
Mohamed Mediouni 5f52ba1f34 qtest: hw/arm: virt: add ACPI tables for new GICv3 + GICv2m test case
Signed-off-by: Mohamed Mediouni <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
2026-02-10 11:34:48 +00:00
Mohamed Mediouni 2e1bb23b44 tests: data: update AArch64 ACPI tables
After the previous commit introducing GICv3 + GICv2m configurations,
update the AArch64 ACPI tables for the GICv2 case.

Changes to the ACPI tables:

tests/data/acpi/aarch64/virt/IORT.dsl:

@@ -11,68 +11,49 @@
  */

 [000h 0000 004h]                   Signature : "IORT"    [IO Remapping Table]
-[004h 0004 004h]                Table Length : 00000080
+[004h 0004 004h]                Table Length : 00000054
 [008h 0008 001h]                    Revision : 05
-[009h 0009 001h]                    Checksum : B1
+[009h 0009 001h]                    Checksum : 3C
 [00Ah 0010 006h]                      Oem ID : "BOCHS "
 [010h 0016 008h]                Oem Table ID : "BXPC    "
 [018h 0024 004h]                Oem Revision : 00000001
 [01Ch 0028 004h]             Asl Compiler ID : "BXPC"
 [020h 0032 004h]       Asl Compiler Revision : 00000001

-[024h 0036 004h]                  Node Count : 00000002
+[024h 0036 004h]                  Node Count : 00000001
 [028h 0040 004h]                 Node Offset : 00000030
 [02Ch 0044 004h]                    Reserved : 00000000

-[030h 0048 001h]                        Type : 00
-[031h 0049 002h]                      Length : 0018
-[033h 0051 001h]                    Revision : 01
+[030h 0048 001h]                        Type : 02
+[031h 0049 002h]                      Length : 0024
+[033h 0051 001h]                    Revision : 03
 [034h 0052 004h]                  Identifier : 00000000
 [038h 0056 004h]               Mapping Count : 00000000
-[03Ch 0060 004h]              Mapping Offset : 00000000
+[03Ch 0060 004h]              Mapping Offset : 00000024

-[040h 0064 004h]                    ItsCount : 00000001
-[044h 0068 004h]                 Identifiers : 00000000
-
-[048h 0072 001h]                        Type : 02
-[049h 0073 002h]                      Length : 0038
-[04Bh 0075 001h]                    Revision : 03
-[04Ch 0076 004h]                  Identifier : 00000001
-[050h 0080 004h]               Mapping Count : 00000001
-[054h 0084 004h]              Mapping Offset : 00000024
-
-[058h 0088 008h]           Memory Properties : [IORT Memory Access Properties]
-[058h 0088 004h]             Cache Coherency : 00000001
-[05Ch 0092 001h]       Hints (decoded below) : 00
+[040h 0064 008h]           Memory Properties : [IORT Memory Access Properties]
+[040h 0064 004h]             Cache Coherency : 00000001
+[044h 0068 001h]       Hints (decoded below) : 00
                                    Transient : 0
                               Write Allocate : 0
                                Read Allocate : 0
                                     Override : 0
-[05Dh 0093 002h]                    Reserved : 0000
-[05Fh 0095 001h] Memory Flags (decoded below) : 03
+[045h 0069 002h]                    Reserved : 0000
+[047h 0071 001h] Memory Flags (decoded below) : 03
                                    Coherency : 1
                             Device Attribute : 1
                Ensured Coherency of Accesses : 0
-[060h 0096 004h]               ATS Attribute : 00000000
-[064h 0100 004h]          PCI Segment Number : 00000000
-[068h 0104 001h]           Memory Size Limit : 40
-[069h 0105 002h]          PASID Capabilities : 0000
-[06Bh 0107 001h]                    Reserved : 00
+[048h 0072 004h]               ATS Attribute : 00000000
+[04Ch 0076 004h]          PCI Segment Number : 00000000
+[050h 0080 001h]           Memory Size Limit : 40
+[051h 0081 002h]          PASID Capabilities : 0000
+[053h 0083 001h]                    Reserved : 00

-[06Ch 0108 004h]                  Input base : 00000000
-[070h 0112 004h]                    ID Count : 0000FFFF
-[074h 0116 004h]                 Output Base : 00000000
-[078h 0120 004h]            Output Reference : 00000030
-[07Ch 0124 004h]       Flags (decoded below) : 00000000
-                              Single Mapping : 0
+Raw Table Data: Length 84 (0x54)

-Raw Table Data: Length 128 (0x80)
-
-    0000: 49 4F 52 54 80 00 00 00 05 B1 42 4F 43 48 53 20  // IORT......BOCHS
+    0000: 49 4F 52 54 54 00 00 00 05 3C 42 4F 43 48 53 20  // IORTT....<BOCHS
     0010: 42 58 50 43 20 20 20 20 01 00 00 00 42 58 50 43  // BXPC    ....BXPC
-    0020: 01 00 00 00 02 00 00 00 30 00 00 00 00 00 00 00  // ........0.......
-    0030: 00 18 00 01 00 00 00 00 00 00 00 00 00 00 00 00  // ................
-    0040: 01 00 00 00 00 00 00 00 02 38 00 03 01 00 00 00  // .........8......
-    0050: 01 00 00 00 24 00 00 00 01 00 00 00 00 00 00 03  // ....$...........
-    0060: 00 00 00 00 00 00 00 00 40 00 00 00 00 00 00 00  // ........@.......
-    0070: FF FF 00 00 00 00 00 00 30 00 00 00 00 00 00 00  // ........0.......
+    0020: 01 00 00 00 01 00 00 00 30 00 00 00 00 00 00 00  // ........0.......
+    0030: 02 24 00 03 00 00 00 00 00 00 00 00 24 00 00 00  // .$..........$...
+    0040: 01 00 00 00 00 00 00 03 00 00 00 00 00 00 00 00  // ................
+    0050: 40 00 00 00                                      // @...

tests/data/acpi/aarch64/virt/IORT.smmuv3-dev.dsl:

@@ -11,164 +11,120 @@
  */

 [000h 0000 004h]                   Signature : "IORT"    [IO Remapping Table]
-[004h 0004 004h]                Table Length : 0000016C
+[004h 0004 004h]                Table Length : 00000104
 [008h 0008 001h]                    Revision : 05
-[009h 0009 001h]                    Checksum : C8
+[009h 0009 001h]                    Checksum : 49
 [00Ah 0010 006h]                      Oem ID : "BOCHS "
 [010h 0016 008h]                Oem Table ID : "BXPC    "
 [018h 0024 004h]                Oem Revision : 00000001
 [01Ch 0028 004h]             Asl Compiler ID : "BXPC"
 [020h 0032 004h]       Asl Compiler Revision : 00000001

-[024h 0036 004h]                  Node Count : 00000004
+[024h 0036 004h]                  Node Count : 00000003
 [028h 0040 004h]                 Node Offset : 00000030
 [02Ch 0044 004h]                    Reserved : 00000000

-[030h 0048 001h]                        Type : 00
-[031h 0049 002h]                      Length : 0018
-[033h 0051 001h]                    Revision : 01
+[030h 0048 001h]                        Type : 04
+[031h 0049 002h]                      Length : 0044
+[033h 0051 001h]                    Revision : 04
 [034h 0052 004h]                  Identifier : 00000000
 [038h 0056 004h]               Mapping Count : 00000000
 [03Ch 0060 004h]              Mapping Offset : 00000000

-[040h 0064 004h]                    ItsCount : 00000001
-[044h 0068 004h]                 Identifiers : 00000000
-
-[048h 0072 001h]                        Type : 04
-[049h 0073 002h]                      Length : 0058
-[04Bh 0075 001h]                    Revision : 04
-[04Ch 0076 004h]                  Identifier : 00000001
-[050h 0080 004h]               Mapping Count : 00000001
-[054h 0084 004h]              Mapping Offset : 00000044
-
-[058h 0088 008h]                Base Address : 000000000C000000
-[060h 0096 004h]       Flags (decoded below) : 00000001
+[040h 0064 008h]                Base Address : 000000000C000000
+[048h 0072 004h]       Flags (decoded below) : 00000001
                              COHACC Override : 1
                                HTTU Override : 0
                       Proximity Domain Valid : 0
                               DeviceID Valid : 0
-[064h 0100 004h]                    Reserved : 00000000
-[068h 0104 008h]               VATOS Address : 0000000000000000
-[070h 0112 004h]                       Model : 00000000
-[074h 0116 004h]                  Event GSIV : 00000090
-[078h 0120 004h]                    PRI GSIV : 00000091
-[07Ch 0124 004h]                   GERR GSIV : 00000093
-[080h 0128 004h]                   Sync GSIV : 00000092
-[084h 0132 004h]            Proximity Domain : 00000000
-[088h 0136 004h]     Device ID Mapping Index : 00000000
+[04Ch 0076 004h]                    Reserved : 00000000
+[050h 0080 008h]               VATOS Address : 0000000000000000
+[058h 0088 004h]                       Model : 00000000
+[05Ch 0092 004h]                  Event GSIV : 00000090
+[060h 0096 004h]                    PRI GSIV : 00000091
+[064h 0100 004h]                   GERR GSIV : 00000093
+[068h 0104 004h]                   Sync GSIV : 00000092
+[06Ch 0108 004h]            Proximity Domain : 00000000
+[070h 0112 004h]     Device ID Mapping Index : 00000000

-[08Ch 0140 004h]                  Input base : 00000000
-[090h 0144 004h]                    ID Count : 0000FFFF
-[094h 0148 004h]                 Output Base : 00000000
-[098h 0152 004h]            Output Reference : 00000030
-[09Ch 0156 004h]       Flags (decoded below) : 00000000
-                              Single Mapping : 0
+[074h 0116 001h]                        Type : 04
+[075h 0117 002h]                      Length : 0044
+[077h 0119 001h]                    Revision : 04
+[078h 0120 004h]                  Identifier : 00000001
+[07Ch 0124 004h]               Mapping Count : 00000000
+[080h 0128 004h]              Mapping Offset : 00000000

-[0A0h 0160 001h]                        Type : 04
-[0A1h 0161 002h]                      Length : 0058
-[0A3h 0163 001h]                    Revision : 04
-[0A4h 0164 004h]                  Identifier : 00000002
-[0A8h 0168 004h]               Mapping Count : 00000001
-[0ACh 0172 004h]              Mapping Offset : 00000044
-
-[0B0h 0176 008h]                Base Address : 000000000C020000
-[0B8h 0184 004h]       Flags (decoded below) : 00000001
+[084h 0132 008h]                Base Address : 000000000C020000
+[08Ch 0140 004h]       Flags (decoded below) : 00000001
                              COHACC Override : 1
                                HTTU Override : 0
                       Proximity Domain Valid : 0
                               DeviceID Valid : 0
-[0BCh 0188 004h]                    Reserved : 00000000
-[0C0h 0192 008h]               VATOS Address : 0000000000000000
-[0C8h 0200 004h]                       Model : 00000000
-[0CCh 0204 004h]                  Event GSIV : 00000094
-[0D0h 0208 004h]                    PRI GSIV : 00000095
-[0D4h 0212 004h]                   GERR GSIV : 00000097
-[0D8h 0216 004h]                   Sync GSIV : 00000096
-[0DCh 0220 004h]            Proximity Domain : 00000000
-[0E0h 0224 004h]     Device ID Mapping Index : 00000000
+[090h 0144 004h]                    Reserved : 00000000
+[094h 0148 008h]               VATOS Address : 0000000000000000
+[09Ch 0156 004h]                       Model : 00000000
+[0A0h 0160 004h]                  Event GSIV : 00000094
+[0A4h 0164 004h]                    PRI GSIV : 00000095
+[0A8h 0168 004h]                   GERR GSIV : 00000097
+[0ACh 0172 004h]                   Sync GSIV : 00000096
+[0B0h 0176 004h]            Proximity Domain : 00000000
+[0B4h 0180 004h]     Device ID Mapping Index : 00000000

-[0E4h 0228 004h]                  Input base : 00000000
-[0E8h 0232 004h]                    ID Count : 0000FFFF
-[0ECh 0236 004h]                 Output Base : 00000000
-[0F0h 0240 004h]            Output Reference : 00000030
-[0F4h 0244 004h]       Flags (decoded below) : 00000000
-                              Single Mapping : 0
+[0B8h 0184 001h]                        Type : 02
+[0B9h 0185 002h]                      Length : 004C
+[0BBh 0187 001h]                    Revision : 03
+[0BCh 0188 004h]                  Identifier : 00000002
+[0C0h 0192 004h]               Mapping Count : 00000002
+[0C4h 0196 004h]              Mapping Offset : 00000024

-[0F8h 0248 001h]                        Type : 02
-[0F9h 0249 002h]                      Length : 0074
-[0FBh 0251 001h]                    Revision : 03
-[0FCh 0252 004h]                  Identifier : 00000003
-[100h 0256 004h]               Mapping Count : 00000004
-[104h 0260 004h]              Mapping Offset : 00000024
-
-[108h 0264 008h]           Memory Properties : [IORT Memory Access Properties]
-[108h 0264 004h]             Cache Coherency : 00000001
-[10Ch 0268 001h]       Hints (decoded below) : 00
+[0C8h 0200 008h]           Memory Properties : [IORT Memory Access Properties]
+[0C8h 0200 004h]             Cache Coherency : 00000001
+[0CCh 0204 001h]       Hints (decoded below) : 00
                                    Transient : 0
                               Write Allocate : 0
                                Read Allocate : 0
                                     Override : 0
-[10Dh 0269 002h]                    Reserved : 0000
-[10Fh 0271 001h] Memory Flags (decoded below) : 03
+[0CDh 0205 002h]                    Reserved : 0000
+[0CFh 0207 001h] Memory Flags (decoded below) : 03
                                    Coherency : 1
                             Device Attribute : 1
                Ensured Coherency of Accesses : 0
-[110h 0272 004h]               ATS Attribute : 00000000
-[114h 0276 004h]          PCI Segment Number : 00000000
-[118h 0280 001h]           Memory Size Limit : 40
-[119h 0281 002h]          PASID Capabilities : 0000
-[11Bh 0283 001h]                    Reserved : 00
+[0D0h 0208 004h]               ATS Attribute : 00000000
+[0D4h 0212 004h]          PCI Segment Number : 00000000
+[0D8h 0216 001h]           Memory Size Limit : 40
+[0D9h 0217 002h]          PASID Capabilities : 0000
+[0DBh 0219 001h]                    Reserved : 00

-[11Ch 0284 004h]                  Input base : 00000000
-[120h 0288 004h]                    ID Count : 000001FF
-[124h 0292 004h]                 Output Base : 00000000
-[128h 0296 004h]            Output Reference : 00000048
-[12Ch 0300 004h]       Flags (decoded below) : 00000000
+[0DCh 0220 004h]                  Input base : 00000000
+[0E0h 0224 004h]                    ID Count : 000001FF
+[0E4h 0228 004h]                 Output Base : 00000000
+[0E8h 0232 004h]            Output Reference : 00000030
+[0ECh 0236 004h]       Flags (decoded below) : 00000000
                               Single Mapping : 0

-[130h 0304 004h]                  Input base : 00001000
-[134h 0308 004h]                    ID Count : 000000FF
-[138h 0312 004h]                 Output Base : 00001000
-[13Ch 0316 004h]            Output Reference : 000000A0
-[140h 0320 004h]       Flags (decoded below) : 00000000
+[0F0h 0240 004h]                  Input base : 00001000
+[0F4h 0244 004h]                    ID Count : 000000FF
+[0F8h 0248 004h]                 Output Base : 00001000
+[0FCh 0252 004h]            Output Reference : 00000074
+[100h 0256 004h]       Flags (decoded below) : 00000000
                               Single Mapping : 0

-[144h 0324 004h]                  Input base : 00000200
-[148h 0328 004h]                    ID Count : 00000DFF
-[14Ch 0332 004h]                 Output Base : 00000200
-[150h 0336 004h]            Output Reference : 00000030
-[154h 0340 004h]       Flags (decoded below) : 00000000
-                              Single Mapping : 0
+Raw Table Data: Length 260 (0x104)

-[158h 0344 004h]                  Input base : 00001100
-[15Ch 0348 004h]                    ID Count : 0000EEFF
-[160h 0352 004h]                 Output Base : 00001100
-[164h 0356 004h]            Output Reference : 00000030
-[168h 0360 004h]       Flags (decoded below) : 00000000
-                              Single Mapping : 0
-
-Raw Table Data: Length 364 (0x16C)
-
-    0000: 49 4F 52 54 6C 01 00 00 05 C8 42 4F 43 48 53 20  // IORTl.....BOCHS
+    0000: 49 4F 52 54 04 01 00 00 05 49 42 4F 43 48 53 20  // IORT.....IBOCHS
     0010: 42 58 50 43 20 20 20 20 01 00 00 00 42 58 50 43  // BXPC    ....BXPC
-    0020: 01 00 00 00 04 00 00 00 30 00 00 00 00 00 00 00  // ........0.......
-    0030: 00 18 00 01 00 00 00 00 00 00 00 00 00 00 00 00  // ................
-    0040: 01 00 00 00 00 00 00 00 04 58 00 04 01 00 00 00  // .........X......
-    0050: 01 00 00 00 44 00 00 00 00 00 00 0C 00 00 00 00  // ....D...........
-    0060: 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  // ................
-    0070: 00 00 00 00 90 00 00 00 91 00 00 00 93 00 00 00  // ................
-    0080: 92 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  // ................
-    0090: FF FF 00 00 00 00 00 00 30 00 00 00 00 00 00 00  // ........0.......
-    00A0: 04 58 00 04 02 00 00 00 01 00 00 00 44 00 00 00  // .X..........D...
-    00B0: 00 00 02 0C 00 00 00 00 01 00 00 00 00 00 00 00  // ................
-    00C0: 00 00 00 00 00 00 00 00 00 00 00 00 94 00 00 00  // ................
-    00D0: 95 00 00 00 97 00 00 00 96 00 00 00 00 00 00 00  // ................
-    00E0: 00 00 00 00 00 00 00 00 FF FF 00 00 00 00 00 00  // ................
-    00F0: 30 00 00 00 00 00 00 00 02 74 00 03 03 00 00 00  // 0........t......
-    0100: 04 00 00 00 24 00 00 00 01 00 00 00 00 00 00 03  // ....$...........
-    0110: 00 00 00 00 00 00 00 00 40 00 00 00 00 00 00 00  // ........@.......
-    0120: FF 01 00 00 00 00 00 00 48 00 00 00 00 00 00 00  // ........H.......
-    0130: 00 10 00 00 FF 00 00 00 00 10 00 00 A0 00 00 00  // ................
-    0140: 00 00 00 00 00 02 00 00 FF 0D 00 00 00 02 00 00  // ................
-    0150: 30 00 00 00 00 00 00 00 00 11 00 00 FF EE 00 00  // 0...............
-    0160: 00 11 00 00 30 00 00 00 00 00 00 00              // ....0.......
+    0020: 01 00 00 00 03 00 00 00 30 00 00 00 00 00 00 00  // ........0.......
+    0030: 04 44 00 04 00 00 00 00 00 00 00 00 00 00 00 00  // .D..............
+    0040: 00 00 00 0C 00 00 00 00 01 00 00 00 00 00 00 00  // ................
+    0050: 00 00 00 00 00 00 00 00 00 00 00 00 90 00 00 00  // ................
+    0060: 91 00 00 00 93 00 00 00 92 00 00 00 00 00 00 00  // ................
+    0070: 00 00 00 00 04 44 00 04 01 00 00 00 00 00 00 00  // .....D..........
+    0080: 00 00 00 00 00 00 02 0C 00 00 00 00 01 00 00 00  // ................
+    0090: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  // ................
+    00A0: 94 00 00 00 95 00 00 00 97 00 00 00 96 00 00 00  // ................
+    00B0: 00 00 00 00 00 00 00 00 02 4C 00 03 02 00 00 00  // .........L......
+    00C0: 02 00 00 00 24 00 00 00 01 00 00 00 00 00 00 03  // ....$...........
+    00D0: 00 00 00 00 00 00 00 00 40 00 00 00 00 00 00 00  // ........@.......
+    00E0: FF 01 00 00 00 00 00 00 30 00 00 00 00 00 00 00  // ........0.......
+    00F0: 00 10 00 00 FF 00 00 00 00 10 00 00 74 00 00 00  // ............t...
+    0100: 00 00 00 00                                      // ....

tests/data/acpi/aarch64/virt/IORT.smmuv3-legacy.dsl:

@@ -11,129 +11,92 @@
  */

 [000h 0000 004h]                   Signature : "IORT"    [IO Remapping Table]
-[004h 0004 004h]                Table Length : 00000114
+[004h 0004 004h]                Table Length : 000000C0
 [008h 0008 001h]                    Revision : 05
-[009h 0009 001h]                    Checksum : 4A
+[009h 0009 001h]                    Checksum : 1C
 [00Ah 0010 006h]                      Oem ID : "BOCHS "
 [010h 0016 008h]                Oem Table ID : "BXPC    "
 [018h 0024 004h]                Oem Revision : 00000001
 [01Ch 0028 004h]             Asl Compiler ID : "BXPC"
 [020h 0032 004h]       Asl Compiler Revision : 00000001

-[024h 0036 004h]                  Node Count : 00000003
+[024h 0036 004h]                  Node Count : 00000002
 [028h 0040 004h]                 Node Offset : 00000030
 [02Ch 0044 004h]                    Reserved : 00000000

-[030h 0048 001h]                        Type : 00
-[031h 0049 002h]                      Length : 0018
-[033h 0051 001h]                    Revision : 01
+[030h 0048 001h]                        Type : 04
+[031h 0049 002h]                      Length : 0044
+[033h 0051 001h]                    Revision : 04
 [034h 0052 004h]                  Identifier : 00000000
 [038h 0056 004h]               Mapping Count : 00000000
 [03Ch 0060 004h]              Mapping Offset : 00000000

-[040h 0064 004h]                    ItsCount : 00000001
-[044h 0068 004h]                 Identifiers : 00000000
-
-[048h 0072 001h]                        Type : 04
-[049h 0073 002h]                      Length : 0058
-[04Bh 0075 001h]                    Revision : 04
-[04Ch 0076 004h]                  Identifier : 00000001
-[050h 0080 004h]               Mapping Count : 00000001
-[054h 0084 004h]              Mapping Offset : 00000044
-
-[058h 0088 008h]                Base Address : 0000000009050000
-[060h 0096 004h]       Flags (decoded below) : 00000001
+[040h 0064 008h]                Base Address : 0000000009050000
+[048h 0072 004h]       Flags (decoded below) : 00000001
                              COHACC Override : 1
                                HTTU Override : 0
                       Proximity Domain Valid : 0
                               DeviceID Valid : 0
-[064h 0100 004h]                    Reserved : 00000000
-[068h 0104 008h]               VATOS Address : 0000000000000000
-[070h 0112 004h]                       Model : 00000000
-[074h 0116 004h]                  Event GSIV : 0000006A
-[078h 0120 004h]                    PRI GSIV : 0000006B
-[07Ch 0124 004h]                   GERR GSIV : 0000006D
-[080h 0128 004h]                   Sync GSIV : 0000006C
-[084h 0132 004h]            Proximity Domain : 00000000
-[088h 0136 004h]     Device ID Mapping Index : 00000000
+[04Ch 0076 004h]                    Reserved : 00000000
+[050h 0080 008h]               VATOS Address : 0000000000000000
+[058h 0088 004h]                       Model : 00000000
+[05Ch 0092 004h]                  Event GSIV : 0000006A
+[060h 0096 004h]                    PRI GSIV : 0000006B
+[064h 0100 004h]                   GERR GSIV : 0000006D
+[068h 0104 004h]                   Sync GSIV : 0000006C
+[06Ch 0108 004h]            Proximity Domain : 00000000
+[070h 0112 004h]     Device ID Mapping Index : 00000000

-[08Ch 0140 004h]                  Input base : 00000000
-[090h 0144 004h]                    ID Count : 0000FFFF
-[094h 0148 004h]                 Output Base : 00000000
-[098h 0152 004h]            Output Reference : 00000030
-[09Ch 0156 004h]       Flags (decoded below) : 00000000
-                              Single Mapping : 0
+[074h 0116 001h]                        Type : 02
+[075h 0117 002h]                      Length : 004C
+[077h 0119 001h]                    Revision : 03
+[078h 0120 004h]                  Identifier : 00000001
+[07Ch 0124 004h]               Mapping Count : 00000002
+[080h 0128 004h]              Mapping Offset : 00000024

-[0A0h 0160 001h]                        Type : 02
-[0A1h 0161 002h]                      Length : 0074
-[0A3h 0163 001h]                    Revision : 03
-[0A4h 0164 004h]                  Identifier : 00000002
-[0A8h 0168 004h]               Mapping Count : 00000004
-[0ACh 0172 004h]              Mapping Offset : 00000024
-
-[0B0h 0176 008h]           Memory Properties : [IORT Memory Access Properties]
-[0B0h 0176 004h]             Cache Coherency : 00000001
-[0B4h 0180 001h]       Hints (decoded below) : 00
+[084h 0132 008h]           Memory Properties : [IORT Memory Access Properties]
+[084h 0132 004h]             Cache Coherency : 00000001
+[088h 0136 001h]       Hints (decoded below) : 00
                                    Transient : 0
                               Write Allocate : 0
                                Read Allocate : 0
                                     Override : 0
-[0B5h 0181 002h]                    Reserved : 0000
-[0B7h 0183 001h] Memory Flags (decoded below) : 03
+[089h 0137 002h]                    Reserved : 0000
+[08Bh 0139 001h] Memory Flags (decoded below) : 03
                                    Coherency : 1
                             Device Attribute : 1
                Ensured Coherency of Accesses : 0
-[0B8h 0184 004h]               ATS Attribute : 00000000
-[0BCh 0188 004h]          PCI Segment Number : 00000000
-[0C0h 0192 001h]           Memory Size Limit : 40
-[0C1h 0193 002h]          PASID Capabilities : 0000
-[0C3h 0195 001h]                    Reserved : 00
+[08Ch 0140 004h]               ATS Attribute : 00000000
+[090h 0144 004h]          PCI Segment Number : 00000000
+[094h 0148 001h]           Memory Size Limit : 40
+[095h 0149 002h]          PASID Capabilities : 0000
+[097h 0151 001h]                    Reserved : 00

-[0C4h 0196 004h]                  Input base : 00000000
-[0C8h 0200 004h]                    ID Count : 000001FF
-[0CCh 0204 004h]                 Output Base : 00000000
-[0D0h 0208 004h]            Output Reference : 00000048
-[0D4h 0212 004h]       Flags (decoded below) : 00000000
+[098h 0152 004h]                  Input base : 00000000
+[09Ch 0156 004h]                    ID Count : 000001FF
+[0A0h 0160 004h]                 Output Base : 00000000
+[0A4h 0164 004h]            Output Reference : 00000030
+[0A8h 0168 004h]       Flags (decoded below) : 00000000
                               Single Mapping : 0

-[0D8h 0216 004h]                  Input base : 00001000
-[0DCh 0220 004h]                    ID Count : 000000FF
-[0E0h 0224 004h]                 Output Base : 00001000
-[0E4h 0228 004h]            Output Reference : 00000048
-[0E8h 0232 004h]       Flags (decoded below) : 00000000
+[0ACh 0172 004h]                  Input base : 00001000
+[0B0h 0176 004h]                    ID Count : 000000FF
+[0B4h 0180 004h]                 Output Base : 00001000
+[0B8h 0184 004h]            Output Reference : 00000030
+[0BCh 0188 004h]       Flags (decoded below) : 00000000
                               Single Mapping : 0

-[0ECh 0236 004h]                  Input base : 00000200
-[0F0h 0240 004h]                    ID Count : 00000DFF
-[0F4h 0244 004h]                 Output Base : 00000200
-[0F8h 0248 004h]            Output Reference : 00000030
-[0FCh 0252 004h]       Flags (decoded below) : 00000000
-                              Single Mapping : 0
+Raw Table Data: Length 192 (0xC0)

-[100h 0256 004h]                  Input base : 00001100
-[104h 0260 004h]                    ID Count : 0000EEFF
-[108h 0264 004h]                 Output Base : 00001100
-[10Ch 0268 004h]            Output Reference : 00000030
-[110h 0272 004h]       Flags (decoded below) : 00000000
-                              Single Mapping : 0
-
-Raw Table Data: Length 276 (0x114)
-
-    0000: 49 4F 52 54 14 01 00 00 05 4A 42 4F 43 48 53 20  // IORT.....JBOCHS
+    0000: 49 4F 52 54 C0 00 00 00 05 1C 42 4F 43 48 53 20  // IORT......BOCHS
     0010: 42 58 50 43 20 20 20 20 01 00 00 00 42 58 50 43  // BXPC    ....BXPC
-    0020: 01 00 00 00 03 00 00 00 30 00 00 00 00 00 00 00  // ........0.......
-    0030: 00 18 00 01 00 00 00 00 00 00 00 00 00 00 00 00  // ................
-    0040: 01 00 00 00 00 00 00 00 04 58 00 04 01 00 00 00  // .........X......
-    0050: 01 00 00 00 44 00 00 00 00 00 05 09 00 00 00 00  // ....D...........
-    0060: 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  // ................
-    0070: 00 00 00 00 6A 00 00 00 6B 00 00 00 6D 00 00 00  // ....j...k...m...
-    0080: 6C 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  // l...............
-    0090: FF FF 00 00 00 00 00 00 30 00 00 00 00 00 00 00  // ........0.......
-    00A0: 02 74 00 03 02 00 00 00 04 00 00 00 24 00 00 00  // .t..........$...
-    00B0: 01 00 00 00 00 00 00 03 00 00 00 00 00 00 00 00  // ................
-    00C0: 40 00 00 00 00 00 00 00 FF 01 00 00 00 00 00 00  // @...............
-    00D0: 48 00 00 00 00 00 00 00 00 10 00 00 FF 00 00 00  // H...............
-    00E0: 00 10 00 00 48 00 00 00 00 00 00 00 00 02 00 00  // ....H...........
-    00F0: FF 0D 00 00 00 02 00 00 30 00 00 00 00 00 00 00  // ........0.......
-    0100: 00 11 00 00 FF EE 00 00 00 11 00 00 30 00 00 00  // ............0...
-    0110: 00 00 00 00                                      // ....
+    0020: 01 00 00 00 02 00 00 00 30 00 00 00 00 00 00 00  // ........0.......
+    0030: 04 44 00 04 00 00 00 00 00 00 00 00 00 00 00 00  // .D..............
+    0040: 00 00 05 09 00 00 00 00 01 00 00 00 00 00 00 00  // ................
+    0050: 00 00 00 00 00 00 00 00 00 00 00 00 6A 00 00 00  // ............j...
+    0060: 6B 00 00 00 6D 00 00 00 6C 00 00 00 00 00 00 00  // k...m...l.......
+    0070: 00 00 00 00 02 4C 00 03 01 00 00 00 02 00 00 00  // .....L..........
+    0080: 24 00 00 00 01 00 00 00 00 00 00 03 00 00 00 00  // $...............
+    0090: 00 00 00 00 40 00 00 00 00 00 00 00 FF 01 00 00  // ....@...........
+    00A0: 00 00 00 00 30 00 00 00 00 00 00 00 00 10 00 00  // ....0...........
+    00B0: FF 00 00 00 00 10 00 00 30 00 00 00 00 00 00 00  // ........0.......

Signed-off-by: Mohamed Mediouni <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
2026-02-10 11:34:48 +00:00
Mohamed Mediouni 5f834ccdcf hw: arm: virt: rework MSI-X configuration
Introduce a -M msi= argument to be able to control MSI-X support independently
from ITS, as part of supporting GICv3 + GICv2m platforms.

Remove vms->its as it's no longer needed after that change.

Signed-off-by: Mohamed Mediouni <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
2026-02-10 11:34:48 +00:00
Mohamed Mediouni eb1c60997c qtest: hw/arm: virt: skip ACPI test for IORT with GICv2
Signed-off-by: Mohamed Mediouni <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
2026-02-10 11:34:48 +00:00
Philippe Mathieu-Daudé 7ca22ae3e6 accel/system: Introduce hwaccel_enabled() helper
hwaccel_enabled() return whether any hardware accelerator
is enabled.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Peter Maydell <[email protected]>
2026-02-10 11:34:48 +00:00
Sebastian Ott d30b420c9c target/arm/kvm: add constants for new PSCI versions
Add constants for PSCI version 1_2 and 1_3.

Signed-off-by: Sebastian Ott <[email protected]>

Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
2026-02-10 11:34:48 +00:00
Vladimir Sementsov-Ogievskiy 391c230f71 virtio-ccw: virtio_ccw_set_guest_notifier(): fix failure path
We leak notifier initialization on that failure path. Let's
cleanup it.

Signed-off-by: Vladimir Sementsov-Ogievskiy <[email protected]>
Reviewed-by: Halil Pasic <[email protected]>
Reviewed-by: Eric Farman <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
2026-02-10 10:52:48 +01:00
Yodel Eldar a3e0783a87 tests/.../reverse_debugging: Remove unsatisfiable condition
get_qemu_img() already skips the test if qemu-img is not found and does
not return None. Eliminate the check for None on its result, and the
unreachable skipTest() gated by it.

Signed-off-by: Yodel Eldar <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
2026-02-10 10:52:48 +01:00
Eric Farman c14c0d0844 MAINTAINERS: Replace backup for s390 PCI
Farhan has been doing a masterful job coming on in the
s390 PCI space, and my own attention has been lacking.
Let's make MAINTAINERS reflect reality.

Signed-off-by: Eric Farman <[email protected]>
Acked-by: Farhan Ali <[email protected]>
Acked-by: Hendrik Brueckner <[email protected]>
Acked-by: Matthew Rosato <[email protected]>
Acked-by: Christian Borntraeger <[email protected]>
Acked-by: Alex Williamson <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
2026-02-10 10:52:48 +01:00
Raphael Norwitz ca2e794eea MAINTAINERS: Switch to my NVIDIA email
Signed-off-by: Raphael Norwitz <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
2026-02-10 10:52:48 +01:00
Peter Maydell 0b91040d23 Merge tag 'pull-loongarch-20260210' of https://github.com/gaosong715/qemu into staging
pull-loongarch-2026-02-10

# -----BEGIN PGP SIGNATURE-----
#
# iLMEAAEKAB0WIQTKRzxE1qCcGJoZP81FK5aFKyaCFgUCaYqcuAAKCRBFK5aFKyaC
# FkgeA/9G0mHfS7GOrna5V3mUkTmCZt0vDRyhoUvQYhq5xOxiw6xTwUHSnUGhrW1X
# Rl5I7TcRiv/Bl6pmDB3c0lZ4+V70MQBufxpwURA3XzKT1C2RSjVHEr7p2WzRiXPF
# 0Zgam8cG2xugT3Al9gdsrba1br/OLXtJHj1+n/L6tgAI8V2Beg==
# =WO9M
# -----END PGP SIGNATURE-----
# gpg: Signature made Tue Feb 10 02:49:28 2026 GMT
# gpg:                using RSA key CA473C44D6A09C189A193FCD452B96852B268216
# gpg: Good signature from "Song Gao <[email protected]>" [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: CA47 3C44 D6A0 9C18 9A19  3FCD 452B 9685 2B26 8216

* tag 'pull-loongarch-20260210' of https://github.com/gaosong715/qemu:
  target/loongarch: Add LA v1.1 instructions to max cpu
  target/loongarch: Add sc.q instructions
  target/loongarch: Add llacq/screl instructions
  target/loongarch: Add estimated reciprocal instructions
  target/loongarch: Add amcas[_db].{b/h/w/d}
  target/loongarch: Add am{swap/add}[_db].{b/h}
  target/loongarch: Require atomics to be aligned

Signed-off-by: Peter Maydell <[email protected]>
2026-02-10 09:12:38 +00:00
Peter Maydell 37daf4ec82 Merge tag 'single-binary-20260206' of https://github.com/philmd/qemu into staging
Various patches related to single binary effort:

- Reduce RISC-V Boston tests
- Prohibit target_ulong / TARGET_PAGE_SIZE uses on s390x target
- Build target/arm/arm-qmp-cmds once
- Forbid legacy native endianness & ld/st_phys APIs on SPARC targets
- Forbid legacy ld/st_phys APIs on x86 targets
- Rename OpenRISC -> or1k
- Avoid QAPI parsing in target_arch()

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCAAdFiEE+qvnXhKRciHc/Wuy4+MsLN6twN4FAmmKO5wACgkQ4+MsLN6t
# wN5EchAAxWVK1eWW5cO7R3+PxWFFzAMcyTzVUftNIyMLZQcXg5C6P2MSt8gsU8KC
# oOwl9S85u5dYh/PlAJtQYC+wtNUxawaJk26vUm3k+uOY2XgqCLtFKts+id15F3Hb
# RueLTEM095jbFgl5OzDwFVRAXP/z727vRsSN2ULXdphHpSVnrROGLz++Uqn7wAmd
# S9u8q35VVRkHl5TRQBDCYNddvGkW6PY0lSdDPhPMYFDH0Pln1Ao3fEn1zfa1c2gP
# HQ1d4MdHi8XX041o2TPFZf74tEs0EeSaxBtfyFEMByOs2kVe8oiX5oaM37vbejLa
# WAfwkG1imw9LcMo0VyjMGgQMb0tkdCVJWzp47eEAEhxSHBsfX5w7+jG0pBng3BBJ
# 6BrcfzVcWeqScUJPdXbM+mY+uBW09JHsTH37aM1NCsRlJI3gys2TfY/oIyVb7aqM
# C17DPKwxv+LVC5BI8LPAkh/nM2/sh5jtC+DjqaAFfAlo3JPLIUOcEIpFikiGbbzU
# MFH1k6YRAee3e7fW1Sw26R17Sf+VTYO9EhYiyWdyAIaBPZ5r7V/fVZWNNrBvh3Zd
# +ETHyRr/mwxbPx3fiNRg880jsP6mVhpLqykRJN1ttW0eQPaA96aqLmDrez/NFF4D
# NisJI8nlJNSEnF84cKgpV74mbIM5lmwMQi684rnI/Ty31X1hLxU=
# =dY6o
# -----END PGP SIGNATURE-----
# gpg: Signature made Mon Feb  9 19:55:08 2026 GMT
# gpg:                using RSA key FAABE75E12917221DCFD6BB2E3E32C2CDEADC0DE
# gpg: Good signature from "Philippe Mathieu-Daudé (F4BUG) <[email protected]>" [full]
# Primary key fingerprint: FAAB E75E 1291 7221 DCFD  6BB2 E3E3 2C2C DEAD C0DE

* tag 'single-binary-20260206' of https://github.com/philmd/qemu: (30 commits)
  target-info: Statically initialize target_arch
  meson: Add TARGET_ARCH to config_target_data
  qapi: Add hexagon to SysEmuTarget
  hw/or1k: Rename or1k-sim.c from openrisc_sim.c
  docs/system/or1k: Rename from openrisc
  tests/tcg/or1k: Rename from openrisc
  hw/or1k: Rename from openrisc
  include/hw/or1k: Rename from openrisc
  target/or1k: Rename from openrisc
  configs/targets: Restrict the legacy ldst_phys() API on x86 targets
  hw/intc/ioapic: Replace legacy st_phys() -> address_space_st()
  hw/intc: Mark x86-specific [IO]APIC peripherals as little-endian
  target/i386: Use explicit little-endian LD/ST API
  configs/targets: Restrict legacy ldst_phys() API on 32-bit SPARC target
  target/sparc: Replace legacy st_phys() -> address_space_st()
  configs/targets: Forbid SPARC to use legacy native endianness APIs
  target/sparc: Replace MO_TE -> MO_BE
  target/sparc: Remove dubious swapping in LD_code() helper
  target/arm/arm-qmp-cmds.c: make compilation unit common
  target/s390x: Expand tcg_global_mem_new() -> tcg_global_mem_new_i64()
  ...

Signed-off-by: Peter Maydell <[email protected]>
2026-02-10 09:11:16 +00:00
Jiajie Chen 59c8adc283 target/loongarch: Add LA v1.1 instructions to max cpu
Add LA v1.1 new instructinos to max cpu by enabling new features in
CPUCFG2.

Signed-off-by: Jiajie Chen <[email protected]>
Reviewed-by: Song Gao <[email protected]>
Signed-off-by: Song Gao <[email protected]>
2026-02-10 10:48:20 +08:00
Jiajie Chen 424227ff54 target/loongarch: Add sc.q instructions
Add the sc.q instruction in LoongArch v1.1, guarded by CPUCFG2.SCQ. It
is implemented by reading 128bit data (llval + llval_high) in ll.d when
aligned to 16B boundary, and cmpxchg 128bit in sc.q. If ld.d
matches the higher part of the 128bit, its data is taken from
llval_high.

Expected assembly sequence:

ll.d lo, base, 0
ld.d hi, base, 8
sc.q lo, hi, base

Signed-off-by: Jiajie Chen <[email protected]>
Reviewed-by: Song Gao <[email protected]>
Signed-off-by: Song Gao <[email protected]>
2026-02-10 10:48:20 +08:00
Jiajie Chen 6e533aca52 target/loongarch: Add llacq/screl instructions
Add the following instructions in LoongArch v1.1:

- llacq.w
- screl.w
- llacq.d
- screl.d

They are guarded by CPUCFG2.LLACQ_SCREL.

Signed-off-by: Jiajie Chen <[email protected]>
Co-developed-by: Richard Henderson <[email protected]>
Reviewed-by: Song Gao <[email protected]>
Signed-off-by: Song Gao <[email protected]>
2026-02-10 10:48:20 +08:00
Jiajie Chen ebe521ad93 target/loongarch: Add estimated reciprocal instructions
Add the following new instructions in LoongArch v1.1:

- frecipe.s
- frecipe.d
- frsqrte.s
- frsqrte.d
- vfrecipe.s
- vfrecipe.d
- vfrsqrte.s
- vfrsqrte.d
- xvfrecipe.s
- xvfrecipe.d
- xvfrsqrte.s
- xvfrsqrte.d

They are guarded by CPUCFG2.FRECIPE. Altought the instructions allow
implementation to improve performance by reducing precision, we use the
existing softfloat implementation.

Signed-off-by: Jiajie Chen <[email protected]>
Acked-by: Richard Henderson <[email protected]>
Reviewed-by: Song Gao <[email protected]>
Signed-off-by: Song Gao <[email protected]>
2026-02-10 10:48:20 +08:00
Jiajie Chen c1db8eb023 target/loongarch: Add amcas[_db].{b/h/w/d}
The new instructions are introduced in LoongArch v1.1:

- amcas.b
- amcas.h
- amcas.w
- amcas.d
- amcas_db.b
- amcas_db.h
- amcas_db.w
- amcas_db.d

The new instructions are gated by CPUCFG2.LAMCAS.

Signed-off-by: Jiajie Chen <[email protected]>
Reviewed-by: Song Gao <[email protected]>
Signed-off-by: Song Gao <[email protected]>
2026-02-10 10:48:20 +08:00
Jiajie Chen 2276261a01 target/loongarch: Add am{swap/add}[_db].{b/h}
The new instructions are introduced in LoongArch v1.1:

- amswap.b
- amswap.h
- amadd.b
- amadd.h
- amswap_db.b
- amswap_db.h
- amadd_db.b
- amadd_db.h

The instructions are gated by CPUCFG2.LAM_BH.

Signed-off-by: Jiajie Chen <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Reviewed-by: Song Gao <[email protected]>
Signed-off-by: Song Gao <[email protected]>
2026-02-10 10:48:20 +08:00
Jiajie Chen 5cf9a035aa target/loongarch: Require atomics to be aligned
Currently, all atomic instructions in LoongArch require the address to
be aligned.

Signed-off-by: Jiajie Chen <[email protected]>
Reviewed-by: Song Gao <[email protected]>
Signed-off-by: Song Gao <[email protected]>
2026-02-10 10:48:20 +08:00
Richard Henderson e934c624f3 target-info: Statically initialize target_arch
Use TARGET_ARCH and token pasting to initialize
target_arch from SYS_EMU_TARGET_*.

Signed-off-by: Richard Henderson <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-02-09 20:51:52 +01:00
Richard Henderson f87f7e145d meson: Add TARGET_ARCH to config_target_data
Signed-off-by: Richard Henderson <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-02-09 20:51:52 +01:00
Richard Henderson 3fdc58a30b qapi: Add hexagon to SysEmuTarget
Signed-off-by: Richard Henderson <[email protected]>
Reviewed-by: Brian Cain <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-02-09 20:51:52 +01:00
Richard Henderson afc63fb067 hw/or1k: Rename or1k-sim.c from openrisc_sim.c
Match the filename to the machine type: or1k-sim.

Signed-off-by: Richard Henderson <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Acked-by: Stafford Horne <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-02-09 20:51:52 +01:00
Richard Henderson 322963969e docs/system/or1k: Rename from openrisc
Also rename docs/system/target-or1k.rst from target-openrisc.rst,
and update all toctree entries to match.

Signed-off-by: Richard Henderson <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Acked-by: Stafford Horne <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-02-09 20:51:52 +01:00
Richard Henderson e4dad5f55f tests/tcg/or1k: Rename from openrisc
Signed-off-by: Richard Henderson <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Acked-by: Stafford Horne <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-02-09 20:51:52 +01:00
Richard Henderson 44967f9422 hw/or1k: Rename from openrisc
Signed-off-by: Richard Henderson <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-02-09 20:51:52 +01:00
Richard Henderson 8cbc31d341 include/hw/or1k: Rename from openrisc
Signed-off-by: Richard Henderson <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Acked-by: Stafford Horne <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-02-09 20:51:52 +01:00
Richard Henderson 62822fc7e0 target/or1k: Rename from openrisc
This is the minimal change beginning with TARGET_ARCH in
configs/targets/or1k-* from openrisc to or1k, then adjust
TARGET_OR1K, QEMU_ARCH_OR1K, directory names,
and meson.build to match.

Signed-off-by: Richard Henderson <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-02-09 20:51:52 +01:00
Philippe Mathieu-Daudé a8b5e57635 configs/targets: Restrict the legacy ldst_phys() API on x86 targets
The x86 targets don't use the legacy ldst_phys() API anymore.
Set the TARGET_NOT_USING_LEGACY_LDST_PHYS_API variable to hide
the legacy API to the x86 binaries, avoiding further API uses
to creep in.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <[email protected]>
2026-02-09 20:51:52 +01:00
Philippe Mathieu-Daudé 33f79f636f hw/intc/ioapic: Replace legacy st_phys() -> address_space_st()
Prefer the address_space_ld/st API over the legacy ld_phys()
because it allow checking for bus access fault. However the
IOAPIC datasheet (82093AA Order Number: 290566-001) doesn't
mention any fault occuring when the system bus (ISA bus) is
accessed. The ISA bus neither offer a way to signal recoverable
access faults. Therefore just inline the stl_le_phys() call,
not specifying any memory transaction attribute nor expecting
transation result, per the definition in
"system/memory_ldst_phys_endian.h.inc":

  42 static inline void ST_PHYS(l)(ARG1_DECL, hwaddr addr, uint32_t val)
  43 {
  44     ADDRESS_SPACE_ST(l)(ARG1, addr, val, MEMTXATTRS_UNSPECIFIED, NULL);
  45 }

No logical change intended.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <[email protected]>
2026-02-09 20:51:52 +01:00
Philippe Mathieu-Daudé 3f19262008 hw/intc: Mark x86-specific [IO]APIC peripherals as little-endian
These devices are only used by the x86 targets, which are
only built as little-endian. Therefore the DEVICE_NATIVE_ENDIAN
definition expand to DEVICE_LITTLE_ENDIAN (besides, the
DEVICE_BIG_ENDIAN case isn't tested). Simplify directly
using DEVICE_LITTLE_ENDIAN.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <[email protected]>
2026-02-09 20:51:52 +01:00
Philippe Mathieu-Daudé c2e7579505 target/i386: Use explicit little-endian LD/ST API
The x86 architecture uses little endianness. Directly use
the little-endian LD/ST API.

Mechanical change running:

  $ for a in uw w l q; do \
      sed -i -e "s/ld${a}_p(/ld${a}_le_p(/" \
        $(git grep -wlE '(ld|st)u?[wlq]_p' target/i386/);
    done

Coding style adapted manually.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <[email protected]>
2026-02-09 20:51:52 +01:00
Philippe Mathieu-Daudé 6172a4257e configs/targets: Restrict legacy ldst_phys() API on 32-bit SPARC target
Since we removed the last legacy uses of the legacy ldst_phys()
API, set the TARGET_NOT_USING_LEGACY_LDST_PHYS_API variable to
hide the legacy API to the qemu-system-sparc binary, avoiding
further API uses to creep in.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <[email protected]>
2026-02-09 20:51:52 +01:00
Philippe Mathieu-Daudé 11eb2f873b target/sparc: Replace legacy st_phys() -> address_space_st()
Prefer the address_space_ld/st API over the legacy ld_phys()
because it allow checking for bus access fault.

get_physical_address() already accessed the PTE stored at
%pde_ptr and is going to update it. Assume the address space
is also writeable there. The SPARC v8 manual only mentions
faults (with error condition bits updated) in the READ path
but not on the WRITE (update) one.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <[email protected]>
2026-02-09 20:51:52 +01:00
Philippe Mathieu-Daudé 3563f60931 configs/targets: Forbid SPARC to use legacy native endianness APIs
All SPARC-related binaries are buildable without a single
use of the legacy "native endian" API. Set the transitional
TARGET_NOT_USING_LEGACY_NATIVE_ENDIAN_API definition to forbid
further uses of the legacy API.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Manos Pitsidianakis <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <[email protected]>
2026-02-09 20:51:52 +01:00
Philippe Mathieu-Daudé 136b115809 target/sparc: Replace MO_TE -> MO_BE
We only build the SPARC targets using big endianness order,
therefore the MO_TE definitions expand to the big endian
one. Use the latter which is more explicit.

Mechanical change running:

  $ sed -i -e s/MO_TE/MO_BE/ \
        $(git grep -wl MO_TE target/sparc/)

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Manos Pitsidianakis <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <[email protected]>
2026-02-09 20:51:52 +01:00
Philippe Mathieu-Daudé f811e8ba6c target/sparc: Remove dubious swapping in LD_code() helper
Since the endianness is contained in %oi, cpu_ld*_code_mmu() has
already honored it. Swapping again makes no sense. Remove the
bswap() calls.

Fixes: 2786a3f8d3 ("Use GET_ASI_CODE for ASI_KERNELTXT / ASI_USERTXT")
Reported-by: Richard Henderson <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <[email protected]>
2026-02-09 20:51:52 +01:00
Pierrick Bouvier 3ca2cadd39 target/arm/arm-qmp-cmds.c: make compilation unit common
Move gic_cap_kvm_probe to target/arm/kvm.c to remove #ifdef CONFIG_KVM.

Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Pierrick Bouvier <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-02-09 20:51:52 +01:00
Philippe Mathieu-Daudé e9c3aafb5f target/s390x: Expand tcg_global_mem_new() -> tcg_global_mem_new_i64()
The s390x target is a 64-bit one, so tcg_global_mem_new()
expands to tcg_global_mem_new_i64(). Use the latter which
is more explicit.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Message-Id: <[email protected]>
2026-02-09 20:51:52 +01:00
Philippe Mathieu-Daudé b29c1d33a2 target/s390x: Expand tcg_gen_qemu_ld/st_tl() as 64-bit target
The s390x target is a 64-bit one, so we have these expansions
in the "tcg/tcg-op.h" header:

 . tcg_gen_qemu_ld_tl() -> tcg_gen_qemu_ld_i64()
 . tcg_gen_qemu_st_tl() -> tcg_gen_qemu_st_i64()

Use the expanded form which is more explicit when a target
isn't built for different words size.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Message-Id: <[email protected]>
2026-02-09 20:51:52 +01:00
Philippe Mathieu-Daudé ad429e3a38 target/s390x: Expand TCGv type as 64-bit target
The s390x target is a 64-bit one, so TCGv expands to TCGv_i64.
Use the latter which is already used about a hundred times in
this file, and is also more explicit.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Message-Id: <[email protected]>
2026-02-09 20:51:52 +01:00
Philippe Mathieu-Daudé dacb7a6510 target/s390x: Build system units in common source set
Except the ioinst.c file which uses the TARGET_PAGE_SIZE
definition in the ioinst_handle_chsc() method, all other
files in meson's s390x_system_ss[] source set don't use
any target-specific code. Moving them in the other
s390x_common_system_ss[] set to build as common objects
ensures these files won't use any target-specific API
such target_ulong / TARGET_PAGE_SIZE, thus forcing to use
the appropriate types instead (such vaddr, hwaddr, uint64_t,
...).

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Message-Id: <[email protected]>
2026-02-09 20:51:52 +01:00
Philippe Mathieu-Daudé 8d2fd86965 target/s390x: Add more unreachable KVM stubs
Next patch will move s390x system objects from the target
specific source set to the common one. Unfortunately the
kvm_enabled() macro won't be evaluable at built-time
anymore. Add stubs for KVM symbols unreachable at runtime.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Acked-by: Thomas Huth <[email protected]>
Reviewed-by: Eric Farman <[email protected]>
Message-Id: <[email protected]>
2026-02-09 20:51:52 +01:00
Philippe Mathieu-Daudé e0abd3de76 target/s390x: Un-inline KVM Protected Virtualization stubs
By removing the target-specific 'CONFIG_KVM' definition this
header can be used by files in meson common_ss[].

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Reviewed-by: Eric Farman <[email protected]>
Message-Id: <[email protected]>
2026-02-09 20:51:52 +01:00
Philippe Mathieu-Daudé 4a41b5ecc5 target/s390x: Replace %target_ulong -> %hwaddr where appropriate
Use the %hwaddr type for physical addresses.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Message-Id: <[email protected]>
2026-02-09 20:51:52 +01:00
Philippe Mathieu-Daudé 1ba04414cc target/s390x: Replace %target_ulong -> %vaddr where appropriate
Use the %vaddr type for virtual addresses.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Message-Id: <[email protected]>
2026-02-09 20:51:52 +01:00
Philippe Mathieu-Daudé 8a2286cd40 target/s390x: Rename get_phys_page_debug() @vaddr argument as @v_addr
In order to use the %vaddr type in s390_cpu_get_phys_page_debug()
in the next commit, rename the argument @vaddr -> @v_addr.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Message-Id: <[email protected]>
2026-02-09 20:51:52 +01:00
Philippe Mathieu-Daudé 4d784c9120 target/s390x: Use address_space_ldq_be() in read_table_entry()
address_space_read/write() is meant for accessing random
amount of memory blobs.  When the access size is known,
use the address_space_ld/st() API which can directly swap
endianness.

Reviewed-by: Thomas Huth <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Eric Farman <[email protected]>
Message-Id: <[email protected]>
2026-02-09 20:51:42 +01:00
Daniel Henrique Barboza 03f1049bc5 riscv64/test_boston.py: fix intermitent test timeout
The recently added Boston MIPS board selftest times out consistently in a
machine running 'make check-functional' with -j 16:

18/18 func-thorough+func-riscv64-thorough+thorough - qemu:func-riscv64-boston
      TIMEOUT        120.09s   killed by signal 15 SIGTERM

The reason is quite boring: it is testing too much stuff.

Note that functional tests aren't supposed to be used as stress tests,
e.g. it doesn't have to test every single corner case that might hit the
board. It is supposed to catch most common user ooopsies. A timeout, in
this context, is most likely to be considered something abnormal slowing
down the emulation, not a lack of CPU horsepower to run all the tests
before timeout.

Some of the tests claim to test odd CPU SMP numbers to either "ensures
proper core distribution across clusters" or "validating proper handling
of larger asymmetric SMP configurations". But there's no SMP/NUMA check
made anywhere after boot, so in the end we're just testing whether the
board is able to boot with 7/35 CPUs. As far as these tests are concerned
we could have a completely broken, but bootable, SMP topology with 7/35
CPUS, and we're oblivious about it.

Remove the 7 and 35 SMP tests, keeping the minimal CPUs (2) and maximum
(64) tests. With these changes we're now able to run the test with a
good TIMEOUT margin:

17/18 func-thorough+func-riscv64-thorough+thorough - qemu:func-riscv64-boston
      OK              61.28s   3 subtests passed

Fixes: e71111e26b ("test/functional: Add test for boston-aia board")
Signed-off-by: Daniel Henrique Barboza <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Djordje Todorovic <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-02-09 20:51:24 +01:00
Peter Maydell b3abdfa486 Merge tag 'block-pull-request' of https://gitlab.com/stefanha/qemu into staging
Pull request

Andrey Drobyshev's qemugdb script improvements and my --device
scsi-block,migrate-pr=on|off live migration support for SCSI Persistent
Reservations.

# -----BEGIN PGP SIGNATURE-----
#
# iQEzBAABCgAdFiEEhpWov9P5fNqsNXdanKSrs4Grc8gFAmmJ8t0ACgkQnKSrs4Gr
# c8goXggAgx8Fehp5q1e1xUulb/WwnHw14lfl2+O4Or3FxK9TDWSUjT0Htk0+QwAf
# W+7Q7MTnSzLTDYKbsPj+4RxZ+Pth/ra2rhIS3YWMQLNAjFKAIWKvQdD0krOlJ8t+
# i3DkERhaw/ke2ImR7GSr7SZjJjhHaxTaC+R/DEPWVxgK1j4mLt/pwAhigWxlvVLT
# SInnZAvfy7+OspFu3AcBtwDEe0MvIQKdTgxZS7wSf/tWS/9WZqsM8pSL/1+ozPGg
# hWjHevhGI6LS4QfRqdF6+dq/XaGT81hFNosCL2o9YWbLuipk/9TyUSX7uevo1IFz
# SpXwxFltCyPicaGJcufX4MjASJqjrg==
# =DKtL
# -----END PGP SIGNATURE-----
# gpg: Signature made Mon Feb  9 14:44:45 2026 GMT
# gpg:                using RSA key 8695A8BFD3F97CDAAC35775A9CA4ABB381AB73C8
# gpg: Good signature from "Stefan Hajnoczi <[email protected]>" [full]
# gpg:                 aka "Stefan Hajnoczi <[email protected]>" [full]
# Primary key fingerprint: 8695 A8BF D3F9 7CDA AC35  775A 9CA4 ABB3 81AB 73C8

* tag 'block-pull-request' of https://gitlab.com/stefanha/qemu:
  docs: add SCSI migrate-pr documentation
  scsi: save/load SCSI reservation state
  scsi: track SCSI reservation state for live migration
  scsi: add error reporting to scsi_SG_IO()
  scsi: generalize scsi_SG_IO_FROM_DEV() to scsi_SG_IO()
  scripts/qemugdb: coroutine: Add option for obtaining detailed trace in coredump
  scripts/qemugdb: timers: Improve 'qemu timers' command readability
  scripts/qemugdb: timers: Fix KeyError in 'qemu timers' command
  scripts/qemugdb: mtree: Fix OverflowError in mtree with 128-bit addresses

Signed-off-by: Peter Maydell <[email protected]>
2026-02-09 14:50:45 +00:00
Peter Maydell 51e36e86d9 Merge tag 'pull-tcg-20260206' of https://gitlab.com/rth7680/qemu into staging
linux-user/syscall.c: Prevent acquiring clone_lock while fork()
accel/tcg: Remove a redundant argument attrs in io_prepare()
accel/tcg: Fix uninitialized hostp in get_page_addr_code_hostp
Revert "tcg/user: do not set exit_request gratuitously"

# -----BEGIN PGP SIGNATURE-----
#
# iQFRBAABCgA7FiEEekgeeIaLTbaoWgXAZN846K9+IV8FAmmFkJ0dHHJpY2hhcmQu
# aGVuZGVyc29uQGxpbmFyby5vcmcACgkQZN846K9+IV9aLQgAjOLW3deluyYPggdi
# YXDAS8YfCFbtXJ36jAeMZnRisXnIXcXkWZr/dseVyVoghz3WUbbRAJrbPuIFrTMq
# b+IX2Gjh7uXgh65EhmwYrinH2jygOdIK5SdJV7x2DtukA1MdRbDHeM8k1gvFNOdn
# Y4nNbTFzI6wuNfti6rvat2SaPm+b7QgMckxB3R8cTAb3o4zvzeUqJ1HMbYil9VG8
# EHQOGJyq2fViTtBm6ZBQ98BylHxqXOsVclchqwARYTlWrvxeVrJ7LopjbD6BfAUr
# 3qasEKoM9Gu1J+i2HXC14qHofScqVYIO3zFl4jbMSwBSsABGZY1OQBxynfOw3cJ9
# 15BiXQ==
# =1ALE
# -----END PGP SIGNATURE-----
# gpg: Signature made Fri Feb  6 06:56:29 2026 GMT
# gpg:                using RSA key 7A481E78868B4DB6A85A05C064DF38E8AF7E215F
# gpg:                issuer "[email protected]"
# gpg: Good signature from "Richard Henderson <[email protected]>" [full]
# Primary key fingerprint: 7A48 1E78 868B 4DB6 A85A  05C0 64DF 38E8 AF7E 215F

* tag 'pull-tcg-20260206' of https://gitlab.com/rth7680/qemu:
  accel/tcg: Remove a redundant argument attrs in io_prepare()
  Revert "tcg/user: do not set exit_request gratuitously"
  linux-user/syscall.c: Prevent acquiring clone_lock while fork()
  accel/tcg: Fix uninitialized hostp in get_page_addr_code_hostp
  accel/tcg: Don't pass NULL to get_page_addr_code_hostp

Signed-off-by: Peter Maydell <[email protected]>
2026-02-09 14:50:30 +00:00
Stefan Hajnoczi a67819adb2 docs: add SCSI migrate-pr documentation
Suggested-by: Paolo Bonzini <[email protected]>
Signed-off-by: Stefan Hajnoczi <[email protected]>
Reviewed-by: Paolo Bonzini <[email protected]>
Message-id: [email protected]
Signed-off-by: Stefan Hajnoczi <[email protected]>
2026-02-09 09:27:30 -05:00
Stefan Hajnoczi ab57b51f13 scsi: save/load SCSI reservation state
Add a vmstate subsection to SCSIDiskState so that scsi-block devices can
transfer their reservation state during live migration. Upon loading the
subsection, the destination QEMU invokes the PERSISTENT RESERVE OUT
command's PREEMPT service action to atomically move the reservation from
the source I_T nexus to the destination I_T nexus. This results in
transparent live migration of SCSI reservations.

This approach is incomplete since SCSI reservations are cooperative and
other hosts could interfere. Neither the source QEMU nor the destination
QEMU are aware of changes made by other hosts. The assumption is that
reservation is not taken over by a third host without cooperation from
the source host.

I considered adding the vmstate subsection to SCSIDevice instead of
SCSIDiskState, since reservations are part of the SCSI Primary Commands
that other devices apart from disks could support. However, due to
fragility of migrating reservations, we will probably limit support to
scsi-block and maybe scsi-disk in the future. In the end, I think it
makes sense to place this within scsi-disk.c.

Signed-off-by: Stefan Hajnoczi <[email protected]>
Reviewed-by: Paolo Bonzini <[email protected]>
Message-id: [email protected]
Signed-off-by: Stefan Hajnoczi <[email protected]>
2026-02-09 09:27:30 -05:00
Stefan Hajnoczi 70f0e0cedb scsi: track SCSI reservation state for live migration
SCSI Persistent Reservations are stateful and external to the guest. In
order to transparently move reservations to the destination host during
live migration, it is necessary to track the state built up on the
source host before migration. Only then can the destination host ensure
an equivalent state is restored upon migration.

Snoop on successful PERSISTENT RESERVE OUT commands and save the
reservation key and reservation type. This will allow registered keys
and reservations to be migrated.

Also patch PERSISTENT RESERVE IN replies with the REPORT CAPABILITIES
service action since features that involve the physical SCSI bus target
ports must not be exposed to the guest (it sees a virtual SCSI bus).

Usually this plays out as follows:
1. The guest invokes the REGISTER service action to register a
   reservation key on its I_T nexus.
2. The guest invokes the RESERVE service action to create a reservation
   using the previously-registered key.

This commit implements the snooping and stores the reservation key and
type (if any) for each LUN. The snooped PR state and the migrate_pr flag
to enable PR migration will be used in later commits.

Signed-off-by: Stefan Hajnoczi <[email protected]>
Reviewed-by: Paolo Bonzini <[email protected]>
Message-id: [email protected]
Signed-off-by: Stefan Hajnoczi <[email protected]>
2026-02-09 09:27:30 -05:00
Stefan Hajnoczi 6302598fe5 scsi: add error reporting to scsi_SG_IO()
Report the details of the SG_IO ioctl failure if an Error pointer is
provided. This information aids troubleshooting and will be used by the
SCSI Persistent Reservations migration code.

Signed-off-by: Stefan Hajnoczi <[email protected]>
Reviewed-by: Paolo Bonzini <[email protected]>
Message-id: [email protected]
Signed-off-by: Stefan Hajnoczi <[email protected]>
2026-02-09 09:27:30 -05:00
Stefan Hajnoczi 03396b9afc scsi: generalize scsi_SG_IO_FROM_DEV() to scsi_SG_IO()
Add a direction argument so that scsi_SG_IO() can be used for
SG_DXFER_FROM_DEV and SG_DXFER_TO_DEV transfers.

Signed-off-by: Stefan Hajnoczi <[email protected]>
Reviewed-by: Paolo Bonzini <[email protected]>
Message-id: [email protected]
Signed-off-by: Stefan Hajnoczi <[email protected]>
2026-02-09 09:27:30 -05:00
Andrey Drobyshev 42f3c143c3 scripts/qemugdb: coroutine: Add option for obtaining detailed trace in coredump
Commit 772f86839f ("scripts/qemu-gdb: Support coroutine dumps in
coredumps") introduced coroutine traces in coredumps using raw stack
unwinding.  While this works, this approach does not allow to view the
function arguments in the corresponding stack frames.

As an alternative, we can obtain saved registers from the coroutine's
jmpbuf, patch them into the coredump's struct elf_prstatus in place, and
execute another gdb subprocess to get backtrace from the patched temporary
coredump.

While providing more detailed info, this alternative approach, however, is
more invasive as it might potentially corrupt the coredump file. We do take
precautions by saving the original registers values into a separate binary
blob /path/to/coredump.ptregs, so that it can be restores in the next
GDB session.  Still, instead of making it a new deault, let's keep raw unwind
the default behaviour, but add the '--detailed' option for 'qemu bt' and
'qemu coroutine' command which would enforce the new behaviour.

That's how this looks:

  (gdb) qemu coroutine 0x7fda9335a508
  #0  0x5602bdb41c26 in qemu_coroutine_switch<+214> () at ../util/coroutine-ucontext.c:321
  #1  0x5602bdb3e8fe in qemu_aio_coroutine_enter<+493> () at ../util/qemu-coroutine.c:293
  #2  0x5602bdb3c4eb in co_schedule_bh_cb<+538> () at ../util/async.c:547
  #3  0x5602bdb3b518 in aio_bh_call<+119> () at ../util/async.c:172
  #4  0x5602bdb3b79a in aio_bh_poll<+457> () at ../util/async.c:219
  #5  0x5602bdb10f22 in aio_poll<+1201> () at ../util/aio-posix.c:719
  #6  0x5602bd8fb1ac in iothread_run<+123> () at ../iothread.c:63
  #7  0x5602bdb18a24 in qemu_thread_start<+355> () at ../util/qemu-thread-posix.c:393

  (gdb) qemu coroutine 0x7fda9335a508 --detailed
  patching core file /tmp/tmpq4hmk2qc
  found "CORE" at 0x10c48
  assume pt_regs at 0x10cbc
  write r15 at 0x10cbc
  write r14 at 0x10cc4
  write r13 at 0x10ccc
  write r12 at 0x10cd4
  write rbp at 0x10cdc
  write rbx at 0x10ce4
  write rip at 0x10d3c
  write rsp at 0x10d54

  #0  0x00005602bdb41c26 in qemu_coroutine_switch (from_=0x7fda9335a508, to_=0x7fda8400c280, action=COROUTINE_ENTER) at ../util/coroutine-ucontext.c:321
  #1  0x00005602bdb3e8fe in qemu_aio_coroutine_enter (ctx=0x5602bf7147c0, co=0x7fda8400c280) at ../util/qemu-coroutine.c:293
  #2  0x00005602bdb3c4eb in co_schedule_bh_cb (opaque=0x5602bf7147c0) at ../util/async.c:547
  #3  0x00005602bdb3b518 in aio_bh_call (bh=0x5602bf714a40) at ../util/async.c:172
  #4  0x00005602bdb3b79a in aio_bh_poll (ctx=0x5602bf7147c0) at ../util/async.c:219
  #5  0x00005602bdb10f22 in aio_poll (ctx=0x5602bf7147c0, blocking=true) at ../util/aio-posix.c:719
  #6  0x00005602bd8fb1ac in iothread_run (opaque=0x5602bf42b100) at ../iothread.c:63
  #7  0x00005602bdb18a24 in qemu_thread_start (args=0x5602bf7164a0) at ../util/qemu-thread-posix.c:393
  #8  0x00007fda9e89f7f2 in start_thread (arg=<optimized out>) at pthread_create.c:443
  #9  0x00007fda9e83f450 in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81

CC: Vladimir Sementsov-Ogievskiy <[email protected]>
CC: Peter Xu <[email protected]>
Originally-by: Vladimir Sementsov-Ogievskiy <[email protected]>
Signed-off-by: Andrey Drobyshev <[email protected]>
Reviewed-by: Stefan Hajnoczi <[email protected]>
Message-id: [email protected]
Signed-off-by: Stefan Hajnoczi <[email protected]>
2026-02-09 09:24:49 -05:00
Andrey Drobyshev 03a37ce754 scripts/qemugdb: timers: Improve 'qemu timers' command readability
* Add the 'attributes' field from QEMUTimer;
* Stringify the field's value in accordance with macros from
  include/qemu/timer.h;
* Make timer expiration times human-readable by converting from nanoseconds
  to appropriate units (ms/s/min/hrs/days) and showing the scale factor
  (ns/us/ms/s).

Signed-off-by: Andrey Drobyshev <[email protected]>
Reviewed-by: Stefan Hajnoczi <[email protected]>
Message-id: [email protected]
Signed-off-by: Stefan Hajnoczi <[email protected]>
2026-02-09 09:24:49 -05:00
Andrey Drobyshev 80c97930a9 scripts/qemugdb: timers: Fix KeyError in 'qemu timers' command
Currently invoking 'qemu timers' command results into: "gdb.error: There
is no member named last".  Let's remove the legacy 'last' field from
QEMUClock, as it was removed in v4.2.0 by the commit 3c2d4c8aa6
("timer: last, remove last bits of last").

Signed-off-by: Andrey Drobyshev <[email protected]>
Reviewed-by: Stefan Hajnoczi <[email protected]>
Message-id: [email protected]
Signed-off-by: Stefan Hajnoczi <[email protected]>
2026-02-09 09:24:49 -05:00
Andrey Drobyshev 33a0e3c755 scripts/qemugdb: mtree: Fix OverflowError in mtree with 128-bit addresses
The 'qemu mtree' command fails with "OverflowError: int too big to
convert" when memory regions have 128-bit addresses.

Fix by changing conversion base from 16 to 0 (automatic detection based
on string prefix).  This works more reliably in GDB's embedded
Python.

Signed-off-by: Andrey Drobyshev <[email protected]>
Reviewed-by: Stefan Hajnoczi <[email protected]>
Message-id: [email protected]
Signed-off-by: Stefan Hajnoczi <[email protected]>
2026-02-09 09:24:49 -05:00
Peter Maydell c4a9d49c7b Merge tag 'pull-9p-20260207' of https://github.com/cschoenebeck/qemu into staging
9pfs changes:

* security-model=mapped: add fallback for reading native symlink
  (if no mapped symlink present).

# -----BEGIN PGP SIGNATURE-----
#
# iQJLBAABCgA1FiEEltjREM96+AhPiFkBNMK1h2Wkc5UFAmmHOzsXHHFlbXVfb3Nz
# QGNydWRlYnl0ZS5jb20ACgkQNMK1h2Wkc5UFig//cFlQBGHpcCfTIowY2y3I8WeW
# gZgNyiZ2IWsiZBg7/PsG/QltKa0MlTCxL5XgxmLZhn+3CDex7Sv+BxWvaZvgjuot
# g7vqt4floCXS5WiNY1Ce0ZOGM2AaMoTf2JPcY2FavFwYz0x2NoODlvEaEnOu9SA8
# v6vrRvC18SaCed6erd9dqRNba1uY5pEJKpV4+t8FcpddYewiKCUYYwGrdFu03w7m
# fZM0TDvoXZV+V8qLXgo4C8R6ZFkt84MeFmWK4ERKTlmt8FT+TdWsXJdLYKG8OpTU
# q702X+4bwZhr0/Rj2PjmrS8Bs9/Vyjv65flkLsWX037r+vrpkfy8du1HPaif+L/W
# nATZk8V4YUexS6UI1XdThJKNJGJYhAJ+jjH1H6ddLpExEcXkxL6A75SKDMDyp/PF
# 1vMXSzWW4MlyCcAvKyDYCL2lU1QpgCdZrBddYnmd0h/jMwenw496284pWdsen2xY
# 1UQnUBmeHx5X437pFOvqNiPeu7PbwdkJl012BND0DiVfFlJSHJU/H/J/z0cuhKUc
# pvagZ+jH6hWB4gEjdsVA853gJpNee/7W4mNkgHYioQFEghUYqHj9V2g+hXr/n7AL
# MQpgkd7857n7VgpJhPWR6Lq7D60Q3gegNZX5o8XqXty+8ABRF8QKFxFqKgljGtnL
# LUk8TTTstEgUCcXb6uI=
# =ossu
# -----END PGP SIGNATURE-----
# gpg: Signature made Sat Feb  7 13:16:43 2026 GMT
# gpg:                using RSA key 96D8D110CF7AF8084F88590134C2B58765A47395
# gpg:                issuer "[email protected]"
# gpg: Good signature from "Christian Schoenebeck <[email protected]>" [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: ECAB 1A45 4014 1413 BA38  4926 30DB 47C3 A012 D5F4
#      Subkey fingerprint: 96D8 D110 CF7A F808 4F88  5901 34C2 B587 65A4 7395

* tag 'pull-9p-20260207' of https://github.com/cschoenebeck/qemu:
  9pfs: local: read native symlinks when security-model=mapped

Signed-off-by: Peter Maydell <[email protected]>
2026-02-07 17:46:15 +00:00
Peter Maydell 046e59f191 Merge tag 'pull-11.0-gdbstub-updates-060226-1' of https://gitlab.com/stsquad/qemu into staging
gdbstub updates:

  - don't duplicate gdb help text in configure
  - re-build meson-buildoptions.sh if the python updated
  - re-factor stop packet handling
  - add EIO and ENOSYS errno defines
  - move host_to_gdb_errno into common gdbstub code
  - return GDB errno values for F packets
  - bool-ify user's running_state state

# -----BEGIN PGP SIGNATURE-----
#
# iQEzBAABCgAdFiEEZoWumedRZ7yvyN81+9DbCVqeKkQFAmmF/+0ACgkQ+9DbCVqe
# KkSWYggAmLldicMTpigrwkGQGpJwh32W+E687171JcbsptpDlxq7O2B6wbaWNPGN
# kRsB5q5qsPTt9IhX1Rr68aTO+kmVDokqKwOAVaqHgcKfxRjU3PjyvVh9qD4VTAtN
# cyUxV1TkzFBTS97OaNdJ6g/UzId1sSNJW/f1p896ooa0dQ0wXv3+jAlGgu8k74wq
# /qG/cyHv6WxHR91JCqL/p40uiEO9wHEgZs2/ayB0EQMsq97plPMRLhq21bI1FZjr
# rJ4W+ILiGx/LLI9q/ixcM1w4ZLrmdgYVHbqLJHy5sZ2O+gBPB1+OCws7VGCWEp7N
# c0400qjskV8txkp64QYwxf7RP4neOw==
# =h80P
# -----END PGP SIGNATURE-----
# gpg: Signature made Fri Feb  6 14:51:25 2026 GMT
# gpg:                using RSA key 6685AE99E75167BCAFC8DF35FBD0DB095A9E2A44
# gpg: Good signature from "Alex Bennée (Master Work Key) <[email protected]>" [full]
# Primary key fingerprint: 6685 AE99 E751 67BC AFC8  DF35 FBD0 DB09 5A9E 2A44

* tag 'pull-11.0-gdbstub-updates-060226-1' of https://gitlab.com/stsquad/qemu:
  gdbstub/user: rename and use bool for running_state
  include/gdbstub: tweak language
  gdbstub/user-target: Convert host errno to GDB File-I/O errno
  gdbstub: Export host_to_gdb_errno File-I/O helper function
  include/gdbstub/syscalls: Add EIO and ENOSYS GDB File-I/O errno values
  gdbstub/user: localise variables for reading gdb socket
  gdbstub: extract stop reply message construction
  gdbstub: remove the need for goto cleanup
  Makefile: add python script dependency for meson-buildoptions.sh
  meson-buildoptions: Remove duplicated entry of --gdb in the help text

Signed-off-by: Peter Maydell <[email protected]>
2026-02-07 17:46:07 +00:00
Philippe Mathieu-Daudé d0660e5b7f hw/char/virtio-serial: Do not expose the 'emergency-write' property
The VIRTIO_CONSOLE_F_EMERG_WRITE feature bit was only set
in the hw_compat_2_7[] array, via the 'emergency-write=off'
property. We removed all machines using that array, lets remove
that property. All instances have this feature bit set and
it can not be disabled. VirtIOSerial::host_features mask is
now unused, remove it.

Reviewed-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Zhao Liu <[email protected]>
Reviewed-by: Igor Mammedov <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-07 14:37:53 +01:00
Philippe Mathieu-Daudé da5c0274ea hw/virtio/virtio-pci: Remove VirtIOPCIProxy::ignore_backend_features field
The VirtIOPCIProxy::ignore_backend_features boolean was only set
in the hw_compat_2_7[] array, via the 'x-ignore-backend-features=on'
property. We removed all machines using that array, lets remove
that property, simplify by only using the default version.

Reviewed-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Igor Mammedov <[email protected]>
Reviewed-by: Zhao Liu <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-07 14:37:53 +01:00
Philippe Mathieu-Daudé 79ecb998a4 hw/i386/intel_iommu: Remove IntelIOMMUState::buggy_eim field
The IntelIOMMUState::buggy_eim boolean was only set in
the hw_compat_2_7[] array, via the 'x-buggy-eim=true'
property. We removed all machines using that array, lets
remove that property, simplifying vtd_decide_config().

Reviewed-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Igor Mammedov <[email protected]>
Reviewed-by: Zhao Liu <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-07 14:37:53 +01:00
Philippe Mathieu-Daudé d99dcf1668 hw/core/machine: Remove hw_compat_2_7[] array
The hw_compat_2_7[] array was only used by the pc-q35-2.7 and
pc-i440fx-2.7 machines, which got removed. Remove it.

Reviewed-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Zhao Liu <[email protected]>
Reviewed-by: Igor Mammedov <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-07 14:37:53 +01:00
Philippe Mathieu-Daudé 7d20a7c6ab hw/audio/pcspk: Remove PCSpkState::migrate field
The PCSpkState::migrate boolean was only set in the
pc_compat_2_7[] array, via the 'migrate=off' property.
We removed all machines using that array, lets remove
that property, simplifying vmstate_spk[].

Reviewed-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Reviewed-by: Igor Mammedov <[email protected]>
Reviewed-by: Zhao Liu <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-07 14:37:52 +01:00
Philippe Mathieu-Daudé d8acb44572 target/i386/cpu: Remove CPUX86State::full_cpuid_auto_level field
The CPUX86State::full_cpuid_auto_level boolean was only
disabled for the pc-q35-2.7 and pc-i440fx-2.7 machines,
which got removed. Being now always %true, we can remove
it and simplify x86_cpu_expand_features().

Reviewed-by: Zhao Liu <[email protected]>
Reviewed-by: Igor Mammedov <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-07 14:37:52 +01:00
Philippe Mathieu-Daudé af704c0e25 hw/i386/pc: Remove pc_compat_2_7[] array
The pc_compat_2_7[] array was only used by the pc-q35-2.7
and pc-i440fx-2.7 machines, which got removed. Remove it.

Reviewed-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Zhao Liu <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Reviewed-by: Igor Mammedov <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-07 14:37:52 +01:00
Philippe Mathieu-Daudé 6fcfe360dc hw/i386/pc: Remove deprecated pc-q35-2.7 and pc-i440fx-2.7 machines
These machines has been supported for a period of more than 6 years.
According to our versioned machine support policy (see commit
ce80c4fa6f "docs: document special exception for machine type
deprecation & removal") they can now be removed.  Remove the qtest
in test-x86-cpuid-compat.c file.

Reviewed-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Reviewed-by: Zhao Liu <[email protected]>
Reviewed-by: Igor Mammedov <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-07 14:37:52 +01:00
Philippe Mathieu-Daudé 5964220631 hw/virtio/virtio-mmio: Remove VirtIOMMIOProxy::format_transport_address field
The VirtIOMMIOProxy::format_transport_address boolean was only set
in the hw_compat_2_6[] array, via the 'format_transport_address=off'
property. We removed all machines using that array, lets remove
that property, simplifying virtio_mmio_bus_get_dev_path().

Reviewed-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Reviewed-by: Zhao Liu <[email protected]>
Reviewed-by: Igor Mammedov <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-07 14:37:52 +01:00
Philippe Mathieu-Daudé 7de77b0f5d hw/core/machine: Remove hw_compat_2_6[] array
The hw_compat_2_6[] array was only used by the pc-q35-2.6 and
pc-i440fx-2.6 machines, which got removed. Remove it.

Reviewed-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Reviewed-by: Zhao Liu <[email protected]>
Reviewed-by: Igor Mammedov <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-07 14:37:52 +01:00
Philippe Mathieu-Daudé 5b10d689ec hw/intc/apic: Remove APICCommonState::legacy_instance_id field
The APICCommonState::legacy_instance_id boolean was only set
in the pc_compat_2_6[] array, via the 'legacy-instance-id=on'
property. We removed all machines using that array, lets remove
that property, simplifying apic_common_realize().

Because instance_id is initialized as initial_apic_id, we can
not register vmstate_apic_common directly via dc->vmsd.

Reviewed-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Reviewed-by: Igor Mammedov <[email protected]>
Reviewed-by: Zhao Liu <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-07 14:37:52 +01:00
Philippe Mathieu-Daudé 1f7e4333e5 hw/i386/pc: Remove pc_compat_2_6[] array
The pc_compat_2_6[] array was only used by the pc-q35-2.6
and pc-i440fx-2.6 machines, which got removed. Remove it.

Reviewed-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Reviewed-by: Zhao Liu <[email protected]>
Reviewed-by: Igor Mammedov <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-07 14:37:52 +01:00
Philippe Mathieu-Daudé 88641f4df3 hw/i386: Remove linuxboot.bin
All machines now use the linuxboot_dma.bin binary, so it's safe to
remove the non-DMA version (linuxboot.bin).

Suggested-by: Thomas Huth <[email protected]>
Reviewed-by: Zhao Liu <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Zhao Liu <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-07 14:37:52 +01:00
Philippe Mathieu-Daudé 04ddbb137d hw/i386: Assume fw_cfg DMA is always enabled
Now all calls of x86 machines to fw_cfg_init_io_dma() pass DMA
arguments, so the FWCfgState (FWCfgIoState) created by x86 machines
enables DMA by default.

Although other callers of fw_cfg_init_io_dma() besides x86 also pass
DMA arguments to create DMA-enabled FwCfgIoState, the "dma_enabled"
property of FwCfgIoState cannot yet be removed, because Sun4u and Sun4v
still create DMA-disabled FwCfgIoState (bypass fw_cfg_init_io_dma()) in
sun4uv_init() (hw/sparc64/sun4u.c).

Maybe reusing fw_cfg_init_io_dma() for them would be a better choice, or
adding fw_cfg_init_io_nodma(). However, before that, first simplify the
handling of FwCfgState in x86.

Considering that FwCfgIoState in x86 enables DMA by default, remove the
handling for DMA-disabled cases and replace DMA checks with assertions
to ensure that the default DMA-enabled setting is not broken.

Then 'linuxboot.bin' isn't used anymore, and it will be removed in the
next commit.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Zhao Liu <[email protected]>
Acked-by: Igor Mammedov <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-07 14:37:52 +01:00
Philippe Mathieu-Daudé e818b4b109 hw/i386/pc: Remove multiboot.bin
All PC machines now use the multiboot_dma.bin binary,
we can remove the non-DMA version (multiboot.bin).

This doesn't change multiboot_dma binary file.

Suggested-by: Thomas Huth <[email protected]>
Reviewed-by: Zhao Liu <[email protected]>
Reviewed-by: Igor Mammedov <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-07 14:37:52 +01:00
Philippe Mathieu-Daudé a5d6b65861 hw/i386/x86: Remove X86MachineClass::fwcfg_dma_enabled field
The X86MachineClass::fwcfg_dma_enabled boolean was only used
by the pc-q35-2.6 and pc-i440fx-2.6 machines, which got
removed. Remove it and simplify.

'multiboot.bin' isn't used anymore, we'll remove it in the
next commit.

Reviewed-by: Zhao Liu <[email protected]>
Reviewed-by: Igor Mammedov <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-07 14:37:52 +01:00
Philippe Mathieu-Daudé 99d1b03365 hw/nvram/fw_cfg: Rename fw_cfg_init_mem_wide() -> fw_cfg_init_mem_dma()
"wide" in fw_cfg_init_mem_wide() means "DMA support".
Rename for clarity.

Suggested-by: Zhao Liu <[email protected]>
Reviewed-by: Xiaoyao Li <[email protected]>
Reviewed-by: Zhao Liu <[email protected]>
Reviewed-by: Igor Mammedov <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-07 14:37:52 +01:00
Philippe Mathieu-Daudé b8f5ff7778 hw/nvram/fw_cfg: Factor fw_cfg_init_mem_internal() out
Factor fw_cfg_init_mem_internal() out of fw_cfg_init_mem_wide().
In fw_cfg_init_mem_wide(), assert DMA arguments are provided.
Callers without DMA have to use the fw_cfg_init_mem() helper.

Reviewed-by: Igor Mammedov <[email protected]>
Reviewed-by: Zhao Liu <[email protected]>
Reviewed-by: Xiaoyao Li <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-07 14:37:52 +01:00
Philippe Mathieu-Daudé c47d27f592 hw/mips/loongson3_virt: Prefer using fw_cfg_init_mem_nodma()
fw_cfg_init_mem_wide() is prefered to initialize fw_cfg
with DMA support. Without DMA, use fw_cfg_init_mem_nodma().

Reviewed-by: Xiaoyao Li <[email protected]>
Reviewed-by: Igor Mammedov <[email protected]>
Reviewed-by: Zhao Liu <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-07 14:37:52 +01:00
Philippe Mathieu-Daudé 5e6868c519 hw/nvram/fw_cfg: Rename fw_cfg_init_mem() with '_nodma' suffix
Rename fw_cfg_init_mem() as fw_cfg_init_mem_nodma()
to distinct with the DMA version (currently named
fw_cfg_init_mem_wide).

Suggested-by: Zhao Liu <[email protected]>
Reviewed-by: Igor Mammedov <[email protected]>
Reviewed-by: Zhao Liu <[email protected]>
Reviewed-by: Xiaoyao Li <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-07 14:37:52 +01:00
Zhao Liu 9b65a1dbc1 tests/acpi: Update DSDT tables for pc & q35 machines
Now the legacy cpu hotplug way has gone away, and there's no _INIT
method in DSDT table for modern cpu hotplug support.

Update DSDT tables for pc machine, and_INIT methods are removed from
DSDT tables:

  -            Method (_INI, 0, Serialized)  // _INI: Initialize
  -            {
  -                CSEL = Zero
  -            }

Signed-off-by: Zhao Liu <[email protected]>
Acked-by: Igor Mammedov <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-07 14:37:52 +01:00
Zhao Liu cd531feb36 docs/specs/acpi_cpu_hotplug: Remove legacy cpu hotplug descriptions
Legacy cpu hotplug has been removed totally and machines start with
modern cpu hotplug interface directly.

Therefore, update the documentation to describe current QEMU cpu hotplug
logic.

Reviewed-by: Igor Mammedov <[email protected]>
Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-07 14:37:52 +01:00
Zhao Liu 067ab16cf7 acpi: Remove legacy cpu hotplug utilities
The cpu_hotplug.h and cpu_hotplug.c contain legacy cpu hotplug
utilities. Now there's no use case of legacy cpu hotplug, so it's safe
to drop legacy cpu hotplug support totally.

Signed-off-by: Igor Mammedov <[email protected]>
Signed-off-by: Zhao Liu <[email protected]>
Acked-by: Igor Mammedov <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-07 14:37:52 +01:00
Philippe Mathieu-Daudé 67d6012d85 hw/i386/pc: Remove PCMachineClass::legacy_cpu_hotplug field
Now all PC & Q35 machiens are using modern hotplug from the beginning,
and all legacy_cpu_hotplug flags keep false during runtime.

So it's safe to remove legacy_cpu_hotplug flags and related properties,
with unused gpe_cpu field.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Igor Mammedov <[email protected]>
Signed-off-by: Zhao Liu <[email protected]>
Acked-by: Igor Mammedov <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-07 14:37:52 +01:00
Zhao Liu 7aa563630b pc: Start with modern CPU hotplug interface by default
For compatibility reasons PC/Q35 will start with legacy CPU hotplug
interface by default but with new CPU hotplug AML code since 2.7
machine type (in commit 679dd1a957 ("pc: use new CPU hotplug interface
since 2.7 machine type")). In that way, legacy firmware that doesn't use
QEMU generated ACPI tables was able to continue using legacy CPU hotplug
interface.

While later machine types, with firmware supporting QEMU provided ACPI
tables, generate new CPU hotplug AML, which will switch to new CPU
hotplug interface when guest OS executes its _INI method on ACPI tables
loading.

Since 2.6 machine type is now gone, and consider that the legacy BIOS
(based on QEMU ACPI prior to v2.7) should be no longer in use, previous
compatibility requirements are no longer necessary. So initialize
'modern' hotplug directly from the very beginning for PC/Q35 machines
with cpu_hotplug_hw_init(), and drop _INIT method.

Additionally, remove the checks and settings around cpu_hotplug_legacy
in cpuhp VMState (for piix4 & ich9), to eliminate the risk of
segmentation faults, as gpe_cpu no longer has the opportunity to be
initialized. This is safe because all hotplug now start with the modern
way, and it's impossible to switch to legacy way at runtime (even the
"cpu-hotplug-legacy" properties does not allow it either).

Signed-off-by: Igor Mammedov <[email protected]>
Signed-off-by: Zhao Liu <[email protected]>
Acked-by: Igor Mammedov <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-07 14:37:52 +01:00
Igor Mammedov 0a07b71f20 tests/acpi: Allow DSDT table change for x86 machines
Before dropping legacy CPU hotplug code, mark and allow the affected
ACPI tables, to avoid breaking ACPI table testing.

Signed-off-by: Igor Mammedov <[email protected]>
Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-07 14:37:52 +01:00
Philippe Mathieu-Daudé 52d8e35bd1 hw/i386/pc: Remove deprecated pc-q35-2.6 and pc-i440fx-2.6 machines
These machines has been supported for a period of more than 6 years.
According to our versioned machine support policy (see commit
ce80c4fa6f "docs: document special exception for machine type
deprecation & removal") they can now be removed.

Reviewed-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Reviewed-by: Zhao Liu <[email protected]>
Reviewed-by: Igor Mammedov <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-07 14:37:52 +01:00
Paolo Bonzini 56d89db2cf target/i386: convert SEV-ES termination requests to guest panic events
This produces a good error message instead of:

KVM: unknown exit reason 24
EAX=00000000 EBX=00000000 ECX=00000000 EDX=00a00f11
ESI=00000000 EDI=00000000 EBP=00000000 ESP=00000000
EIP=0000b004 EFL=00000002 [-------] CPL=0 II=0 A20=1 SMM=0 HLT=1
ES =0000 00000000 0000ffff 00009300
CS =f000 00800000 0000ffff 00009b00
SS =0000 00000000 0000ffff 00009300
DS =0000 00000000 0000ffff 00009300
FS =0000 00000000 0000ffff 00009300
GS =0000 00000000 0000ffff 00009300
LDT=0000 00000000 0000ffff 00008200
TR =0000 00000000 0000ffff 00008b00
GDT=     00000000 0000ffff
IDT=     00000000 0000ffff
CR0=60000010 CR2=00000000 CR3=00000000 CR4=00000000
DR0=0000000000000000 DR1=0000000000000000 DR2=0000000000000000 DR3=0000000000000000
DR6=00000000ffff0ff0 DR7=0000000000000400
EFER=0000000000000000
Code=00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <00> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

Reported-by: Jin Liu <[email protected]>
Cc: Michael Roth <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
2026-02-07 14:31:38 +01:00
Andrey Erokhin 22296f2db9 9pfs: local: read native symlinks when security-model=mapped
Directories attached using virtfs with security-model=mapped
may contain native symlinks

This can happen e.g. when booting from a rootfs directory tree
(usually with a writable overlay set up on the host side)

Currently, when security-model=mapped[-xattr|-file],
QEMU assumes that host-side "symlinks" are in the mapped format,
i.e. are regular files storing the linked path,
so it tries to open with O_NOFOLLOW
and fails with ELOOP on native symlinks

This patch introduces a fallback for such cases:
reuse security-model=[none|passthrough] else if branch logic
where readlink will be called for the path basename

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/173
Signed-off-by: Andrey Erokhin <[email protected]>
Reviewed-by: Greg Kurz <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Christian Schoenebeck <[email protected]>
2026-02-07 13:38:56 +01:00
Alex Bennée db13b4e262 gdbstub/user: rename and use bool for running_state
This is just a clean-up to document what we using the running variable
for in user-mode.

Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alex Bennée <[email protected]>
2026-02-06 12:43:07 +00:00
Alex Bennée 501214a1dd include/gdbstub: tweak language
While "iff" means "if and only if" it might look like a typo to those
not familiar with this mathematical abbreviation. A plain "if" is
clear enough.

Message-ID: <[email protected]>
Signed-off-by: Alex Bennée <[email protected]>
2026-02-06 12:43:07 +00:00
Yodel Eldar 62e2d445c2 gdbstub/user-target: Convert host errno to GDB File-I/O errno
Use host_to_gdb_errno to convert host-supplied errnos to their GDB
File-I/O remote protocol values, and use them in F reply packets.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2751
Reported-by: Dominik 'Disconnect3d' Czarnota <[email protected]>
Signed-off-by: Yodel Eldar <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alex Bennée <[email protected]>
2026-02-06 12:43:07 +00:00
Yodel Eldar c3fbf1a5f0 gdbstub: Export host_to_gdb_errno File-I/O helper function
Move host_to_gdb_errno from target/m68k/m68k-semi.c to
gdbstub/syscalls.c. Declare it in include/gdbstub/syscalls.h.

Add both newly added GDB File-I/O supported errno values, EIO and
ENOSYS, to the mapping.

Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Yodel Eldar <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alex Bennée <[email protected]>
2026-02-06 12:43:07 +00:00
Yodel Eldar 6a64470216 include/gdbstub/syscalls: Add EIO and ENOSYS GDB File-I/O errno values
This patch adds the EIO and ENOSYS errno values that were missing from
the GDB Manual [1] when the other errno values were defined.

[1] https://sourceware.org/gdb/current/onlinedocs/gdb.html/Errno-Values.html

Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Yodel Eldar <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alex Bennée <[email protected]>
2026-02-06 12:43:06 +00:00
Alex Bennée dcec2bd048 gdbstub/user: localise variables for reading gdb socket
Keep things tidy by moving the declarations to the block where they
are used.

Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alex Bennée <[email protected]>
2026-02-06 12:43:06 +00:00
Alex Bennée 7b17fef592 gdbstub: extract stop reply message construction
The stop reply message we send can include a lot of extra information
and a bunch is mode dependant. Extract the construction into a helper
and add specialised versions for system and user mode.

The correct response for system mode should be of the form:

  T05core:N;

Where N is the core ID. We pass GString to gdb_build_stop_packet as
other functions we are going to clean-up work variously with their own
dynamically allocated GStrings or with the common shared buffer.

Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alex Bennée <[email protected]>
2026-02-06 12:43:02 +00:00
Alex Bennée 916991fee2 gdbstub: remove the need for goto cleanup
We already set a default error reply which we can only overwrite if we
successfully follow the chain of checks. Initialise the variables as
NULL and use that to gate the construction of the filled out
stop/reply packet.

Message-ID: <[email protected]>
Signed-off-by: Alex Bennée <[email protected]>
2026-02-06 12:41:51 +00:00
Alex Bennée 912536ff7c Makefile: add python script dependency for meson-buildoptions.sh
If we update the script we should also make sure we regenerate the
help text.

Reviewed-by: Paolo Bonzini <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alex Bennée <[email protected]>
2026-02-06 12:02:56 +00:00
Alex Bennée 11e89ad034 meson-buildoptions: Remove duplicated entry of --gdb in the help text
Since --gdb has recently been added to meson_options.txt, the help
text shows up twice in the output of "./configure --help":

 $ ./configure --help | grep gdb
   --gdb=GDB-path           gdb to use for gdbstub tests [/usr/bin/gdb]
   --gdb=VALUE              Path to GDB

As the probed value is of interest we want to keep the configure text
so make meson-buildoptions able to handle deferring to configure.

Fixes: b46b3818cf ("tests/functional: Provide GDB to the functional tests")
Acked-by: Paolo Bonzini <[email protected]>
Reviewed-by: Gustavo Romero <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Tested-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alex Bennée <[email protected]>
2026-02-06 12:02:56 +00:00
Jim Shu 973b0b0e3a accel/tcg: Remove a redundant argument attrs in io_prepare()
attrs is already in CPUTLBEntryFull, so this argument is redundant.
Just remove it.

Clean up commit 94c6e9cf04

Signed-off-by: Jim Shu <[email protected]>
Reviewed-by: Gustavo Romero <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-02-06 16:51:09 +10:00
Paolo Bonzini 251a3d4ca3 Revert "tcg/user: do not set exit_request gratuitously"
This reverts commit b422a7bff6.

The reporter says "The commit breaks go; if you run go build in a loop,
it eventually hangs uninterruptible (except -9) with a couple of zombie
children left over".

Reported-by: Andreas Schwab <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-02-06 16:51:09 +10:00
Aleksandr Sergeev d22e9aec57 linux-user/syscall.c: Prevent acquiring clone_lock while fork()
By the spec, fork() copies only the thread which executes it.
So it may happen, what while one thread is doing a fork,
another thread is holding `clone_lock` mutex
(e.g. doing a `fork()` or `exit()`).
So the child process is born with the mutex being held,
and there are nobody to release it.

As the thread executing do_syscall() is not considered running,
start_exclusive() does not protect us from the case.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3226
Signed-off-by: Aleksandr Sergeev <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-02-06 16:51:09 +10:00
Richard Henderson 0039e5fd22 accel/tcg: Fix uninitialized hostp in get_page_addr_code_hostp
This uninitialized value violates the contract in the
documentation comment, and may lead to a SEGV during
translaton with -d in_asm.

Change the documentation to disallow hostp NULL.
Pass hostp to probe_access_internal directly.

Reported-by: Panda Jiang <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
2026-02-06 16:51:09 +10:00
Richard Henderson 813dbe869f accel/tcg: Don't pass NULL to get_page_addr_code_hostp
Pass a dummy variable instead to let the value be discarded,
in preparation for making the argument mandatory.

Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
2026-02-06 16:51:09 +10:00
Peter Maydell cd5a79dc98 Merge tag 'for_upstream' of https://git.kernel.org/pub/scm/virt/kvm/mst/qemu into staging
virtio,pci,pc: features, fixes

intel_iommu:
    SVM support
vhost:
    support for indirect descriptors in shadow virtqueue
vhost-user:
    vhost-user-spi support
    vhost-user-blk inflight migration support
    vhost-user-blk inflight migration support

misc fixes in pci, vhost, virtio, acpi, cxl
cleanups in acpi/ghes

Signed-off-by: Michael S. Tsirkin <[email protected]>

# -----BEGIN PGP SIGNATURE-----
#
# iQFDBAABCgAtFiEEXQn9CHHI+FuUyooNKB8NuNKNVGkFAmmEa9APHG1zdEByZWRo
# YXQuY29tAAoJECgfDbjSjVRpqj8H/iBqAHZSTmAdBJgoLnmgoTLB01J9aUTrQU2H
# BHKyrd+G3m54pwjgUNN5ieZARtlXscigf6fr0Gq2wrc8/kV/O5G5jViw9+1Bo8nW
# OkLDW45nDzZGhap4oUedV+PJ3fCuW2fC8Jyb1n8OGlkadbhq0NU6GtqiEx6/7QIh
# hk5WUDE/3LH4cTp8qNtr0/nYfM4FZk2sjq7aRyg4cz/uC7rIAFRq7BCZ/dfRqMh/
# T+rLnizSSAg9PFMd8slWqoxOGF9NzT9LIoDSkAlso1L9lUekUSNoUblhlWDrRlLn
# DEEqqGCVounfBzA95WrTRmvWs6JodppjjAjI0M4isrMKGXXg8dg=
# =HdgY
# -----END PGP SIGNATURE-----
# gpg: Signature made Thu Feb  5 10:07:12 2026 GMT
# gpg:                using RSA key 5D09FD0871C8F85B94CA8A0D281F0DB8D28D5469
# gpg:                issuer "[email protected]"
# gpg: Good signature from "Michael S. Tsirkin <[email protected]>" [full]
# gpg:                 aka "Michael S. Tsirkin <[email protected]>" [full]
# 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: (38 commits)
  hw/cxl: Take into account how many media operations are requested for param check
  hw/cxl: Check for overflow on santize media as both base and offset 64bit.
  vhost-user-blk: support inter-host inflight migration
  vhost: add vmstate for inflight region with inner buffer
  vmstate: introduce VMSTATE_VBUFFER_UINT64
  vhost-user: introduce protocol feature for skip drain on GET_VRING_BASE
  vhost-user.rst: specify vhost-user back-end action on GET_VRING_BASE
  virtio-gpu: use consistent error checking for virtio_gpu_create_mapping_iov
  virtio-gpu: fix error handling in virgl_cmd_resource_create_blob
  virtio-pmem: ignore empty queue notifications
  virtio-gpu-virgl: correct parent for blob memory region
  MAINTAINERS: Update VIOT maintainer
  cryptodev-builtin: Limit the maximum size
  hw/virtio/virtio-crypto: verify asym request size
  virtio-spi: Add vhost-user-spi device support
  standard-headers: Update virtio_spi.h from Linux v6.18-rc3
  q35: Fix migration of SMRAM state
  pcie_sriov: Fix PCI_SRIOV_* accesses in pcie_sriov_pf_exit()
  virtio: Fix crash when sriov-pf is set for non-PCI-Express device
  virtio-dmabuf: Ensure UUID persistence for hash table insertion
  ...

Signed-off-by: Peter Maydell <[email protected]>
2026-02-05 13:54:50 +00:00
Jonathan Cameron 25465c0e1f hw/cxl: Take into account how many media operations are requested for param check
Whilst the spec doesn't speak to it directly my assumption is that
a request for more operations than exist should result in an invalid
input error return.

Fixes: 77a8e9fe0e ("hw/cxl/cxl-mailbox-utils: Add support for Media operations discovery commands cxl r3.2 (8.2.10.9.5.3)")
Closes: https://lore.kernel.org/qemu-devel/CAFEAcA-p5wZkNxK7wNVq_3PAzEE-muOd1Def-0O-FSpck4DrBQ@mail.gmail.com/
Reported-by: Peter Maydell <[email protected]>
Signed-off-by: Jonathan Cameron <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Message-Id: <[email protected]>
2026-02-05 05:06:46 -05:00
Jonathan Cameron 87f8e5a71d hw/cxl: Check for overflow on santize media as both base and offset 64bit.
The both the size and base of a media sanitize operation are both provided
by the VM, an overflow is possible which may result in checks on valid
range passing when they should not.  Close that by checking for overflow
on the addition.

Fixes: 40ab4ed107 ("hw/cxl/cxl-mailbox-utils: Media operations Sanitize and Write Zeros commands CXL r3.2(8.2.10.9.5.3)")
Closes: https://lore.kernel.org/qemu-devel/CAFEAcA8Rqop+ju0fuxN+0T57NBG+bep80z45f6pY0ci2fz_G3A@mail.gmail.com/
Reported-by: Peter Maydell <[email protected]>
Signed-off-by: Jonathan Cameron <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Message-Id: <[email protected]>
2026-02-05 05:06:46 -05:00
Alexandr Moshkov 3dfd711ea9 vhost-user-blk: support inter-host inflight migration
During inter-host migration, waiting for disk requests to be drained
in the vhost-user backend can incur significant downtime.

This can be avoided if QEMU migrates the inflight region in
vhost-user-blk.
Thus, during the qemu migration, with feature flag the vhost-user
back-end can immediately stop vrings, so all in-flight requests will be
migrated to another host.

Signed-off-by: Alexandr Moshkov <[email protected]>
Reviewed-by: Stefan Hajnoczi <[email protected]>
Reviewed-by: Raphael Norwitz <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Message-Id: <[email protected]>
2026-02-05 05:06:46 -05:00
Alexandr Moshkov 3a80ff0721 vhost: add vmstate for inflight region with inner buffer
Prepare for future inflight region migration for vhost-user-blk.
We need to migrate size, queue_size, and inner buffer.

So firstly it migrate size and queue_size fields, then allocate memory
for buffer with
migrated size, then migrate inner buffer itself.

Signed-off-by: Alexandr Moshkov <[email protected]>
Reviewed-by: Stefan Hajnoczi <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Message-Id: <[email protected]>
2026-02-05 05:06:46 -05:00
Alexandr Moshkov f6fdd8b2bd vmstate: introduce VMSTATE_VBUFFER_UINT64
This is an analog of VMSTATE_VBUFFER_UINT32 macro, but for uint64 type.

Signed-off-by: Alexandr Moshkov <[email protected]>
Acked-by: Peter Xu <[email protected]>
Reviewed-by: Stefan Hajnoczi <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Message-Id: <[email protected]>
2026-02-05 05:06:46 -05:00
Alexandr Moshkov e0822e6085 vhost-user: introduce protocol feature for skip drain on GET_VRING_BASE
Add vhost-user protocol feature
VHOST_USER_PROTOCOL_F_GET_VRING_BASE_INFLIGHT

Now on GET_VRING_BASE this feature can control whether to wait for
in-flight requests to complete or not.
Also we have to validate that this feature will be enabled only when
qemu and back-end supports in-flight buffer and in-flight migration

It will be helpfull in future for in-flight requests migration in
vhost-user devices.

Update docs, add ref to label for inflight-io-tracking

Signed-off-by: Alexandr Moshkov <[email protected]>
Reviewed-by: Stefan Hajnoczi <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Message-Id: <[email protected]>
2026-02-05 05:06:46 -05:00
Alexandr Moshkov e7985b6a56 vhost-user.rst: specify vhost-user back-end action on GET_VRING_BASE
By default, we assume that server need to wait all inflight IO on
GET_VRING_BASE. However, this fact is not recorded anywhere in the
documentation.
So, add this info in rst.

Signed-off-by: Alexandr Moshkov <[email protected]>
Reviewed-by: Stefan Hajnoczi <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Message-Id: <[email protected]>
2026-02-05 05:06:46 -05:00
Honglei Huang 12a2d5ca45 virtio-gpu: use consistent error checking for virtio_gpu_create_mapping_iov
Unify error checking style for virtio_gpu_create_mapping_iov() across the
codebase to improve consistency and readability.

virtio_gpu_create_mapping_iov() returns 0 on success and negative values
on error. The original code used inconsistent patterns for checking errors:
- Some used 'if (ret != 0)' in virtio-gpu-virgl.c and virtio-gpu.c
- Some used 'CHECK(!ret, cmd)' in virtio-gpu-rutabaga.c

For if-statement checks, change to 'if (ret < 0)' which is the preferred
QEMU coding convention for functions that return 0 on success and negative
on error. This makes the return value convention immediately clear to code
readers.

For CHECK macro usage in virtio-gpu-rutabaga.c, keep the original
'CHECK(!ret, cmd)' pattern as it is more concise and consistent with other
error checks in the same file.

Updated locations:
- hw/display/virtio-gpu-virgl.c: virgl_resource_attach_backing()
- hw/display/virtio-gpu-virgl.c: virgl_cmd_resource_create_blob()
- hw/display/virtio-gpu.c: virtio_gpu_resource_create_blob()
- hw/display/virtio-gpu.c: virtio_gpu_resource_attach_backing()

Signed-off-by: Honglei Huang <[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Reviewed-by: Dmitry Osipenko <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Message-Id: <[email protected]>
2026-02-05 05:06:46 -05:00
Honglei Huang 3560b51979 virtio-gpu: fix error handling in virgl_cmd_resource_create_blob
Fix inverted error check in virgl_cmd_resource_create_blob() that causes
the function to return error when virtio_gpu_create_mapping_iov() succeeds.

virtio_gpu_create_mapping_iov() returns 0 on success and negative values
on error. The check 'if (!ret)' incorrectly treats success (ret=0) as an
error condition, causing the function to fail when it should succeed.

Change the condition to 'if (ret != 0)' to properly detect errors.

Fixes: 7c092f17cc ("virtio-gpu: Handle resource blob commands")
Signed-off-by: Honglei Huang <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Reviewed-by: Dmitry Osipenko <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Message-Id: <[email protected]>
2026-02-05 05:06:46 -05:00
Li Chen efd581a8cd virtio-pmem: ignore empty queue notifications
virtio_pmem_flush() treats a NULL return from virtqueue_pop() as a fatal
error and calls virtio_error(), which puts the device into NEEDS_RESET.

However, virtqueue handlers can be invoked when no element is available,
so an empty queue should be handled as a benign no-op.

With a Linux guest this avoids spurious NEEDS_RESET and the resulting
-EIO propagation (e.g. EXT4 journal abort and remount-ro).

Signed-off-by: Li Chen <[email protected]>
Acked-by: Michael S. Tsirkin <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Message-Id: <[email protected]>
2026-02-05 05:06:46 -05:00
Joelle van Dyne e27194e087 virtio-gpu-virgl: correct parent for blob memory region
When `owner` == `mr`, `object_unparent` will crash:

object_unparent(mr) ->
object_property_del_child(mr, mr) ->
object_finalize_child_property(mr, name, mr) ->
object_unref(mr) ->
object_finalize(mr) ->
object_property_del_all(mr) ->
object_finalize_child_property(mr, name, mr) ->
object_unref(mr) ->
fail on g_assert(obj->ref > 0)

However, passing a different `owner` to `memory_region_init` does not
work. `memory_region_ref` has an optimization where it takes a ref
only on the owner. That means when flatviews are created, it does not
take a ref on the region and you can get a UAF from `flatview_destroy`
called from RCU.

The correct fix therefore is to use `NULL` as the name which will set
the `owner` but not the `parent` (which is still NULL). This allows us
to use `memory_region_ref` on itself while not having to rely on unparent
for cleanup.

Signed-off-by: Joelle van Dyne <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Message-Id: <[email protected]>
2026-02-05 05:06:46 -05:00
Jean-Philippe Brucker f0754cd386 MAINTAINERS: Update VIOT maintainer
Unfortunately I can't contribute to QEMU for the time being, but Eric
has offered to take on maintainership of the ACPI VIOT. Thank you!

Signed-off-by: Jean-Philippe Brucker <[email protected]>
Reviewed-by: Eric Auger <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Message-Id: <[email protected]>
2026-02-05 05:06:46 -05:00
zhenwei pi 7b913094c7 cryptodev-builtin: Limit the maximum size
This backend driver is used for demonstration purposes only, unlimited
size leads QEMU OOM.

Fixes: CVE-2025-14876
Fixes: 1653a5f3fc ("cryptodev: introduce a new cryptodev backend")
Reported-by: 이재영 <[email protected]>
Signed-off-by: zhenwei pi <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Message-Id: <[email protected]>
2026-02-05 05:06:46 -05:00
zhenwei pi 91c6438caf hw/virtio/virtio-crypto: verify asym request size
The total lenght of request is limited by cryptodev config, verify it
to avoid unexpected request from guest.

Fixes: CVE-2025-14876
Fixes: 0e660a6f90 ("crypto: Introduce RSA algorithm")
Reported-by: 이재영 <[email protected]>
Signed-off-by: zhenwei pi <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Message-Id: <[email protected]>
2026-02-05 05:06:46 -05:00
Haixu Cui 6ab7b84fc2 virtio-spi: Add vhost-user-spi device support
This patch introduces support for vhost-user-spi and vhost-user-spi-pci
devices in QEMU, enabling virtio-based SPI communication via the vhost-user
protocol.

The implementation follows the virtio-spi specification and leverages
the upstream virtio-spi driver in Linux. Relevant references:

- Virtio SPI specification:
  https://github.com/oasis-tcs/virtio-spec/tree/master/device-types/spi
- Linux virtio-spi driver:
  https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/spi/spi-virtio.c?h=v6.18-rc3
- vhost-user-spi daemon:
  https://github.com/rust-vmm/vhost-device/tree/main/vhost-device-spi

Example usage with rust-vmm vhost-user-spi daemon:

Start the vhost-user-spi daemon:
    vhost-device-spi --socket-path=vspi.sock --socket-count=1 \
        --device "/dev/spidev0.0"

Launch QEMU with:
    qemu-system-aarch64 -m 1G \
        -chardev socket,path=/home/root/vspi.sock0,id=vspi \
        -device vhost-user-spi-device,chardev=vspi,id=spi \
        -object memory-backend-file,id=mem,size=1G,mem-path=/dev/shm,share=on \
        -numa node,memdev=mem

Signed-off-by: Haixu Cui <[email protected]>
Reviewed-by: Manos Pitsidianakis <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Message-Id: <[email protected]>
2026-02-05 05:06:46 -05:00
Haixu Cui f4cc404c82 standard-headers: Update virtio_spi.h from Linux v6.18-rc3
Synced virtio_spi.h from upstream Linux kernelusing
scripts/update-linux-headers.sh.

Source:
- Linux commit dcb6fa37fd7bc9c3d2b066329b0d27dedf8becaa (v6.18-rc3)
- Author: Linus Torvalds <[email protected]>
- Date:   Sun Oct 26 15:59:49 2025 -0700

This update ensures QEMU's standard headers are consistent with the latest
virtio SPI definitions from Linux v6.18-rc3.

Signed-off-by: Haixu Cui <[email protected]>
Reviewed-by: Manos Pitsidianakis <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Message-Id: <[email protected]>
2026-02-05 05:06:46 -05:00
Igor Mammedov 66cf169e29 q35: Fix migration of SMRAM state
When migrating, dst QEMU by default has SMRAM unlocked,
and since wmask is not migrated, the migrated value of
MCH_HOST_BRIDGE_F_SMBASE in config space fall to prey of

  mch_update_smbase_smram()
    ...
    if (pd->wmask[MCH_HOST_BRIDGE_F_SMBASE] == 0xff) {
        *reg = 0x00;

and is getting cleared and leads to unlocked smram
on dst even if on source it's been locked.

As Andrey has pointed out [1], we should derive wmask
from config and not other way around.

Drop offending chunk and resync wmask based on MCH_HOST_BRIDGE_F_SMBASE
register value. That would preserve the register during
migration and set smram regions into corresponding state.

What that changes is:
that it would let guest write junk values in register
(with no apparent effect) until it's stumbles upon
reserved 0x1 [|] 0x2 values, at which point it
would be only possible to lock register and trigger
switch to SMRAM blackhole in CPU AS.

While at it, fix up test by removing junk discard before negotiation hunk.

PS2:
Instead of adding a dedicated post_load handler for it,
reuse mch_update->mch_update_smbase_smram call chain
that is called on write/reset/post_load to be consistent
with how we handle mch registers.

PS3:
for prosterity here is erro message Andrey got due to this bug:
    qemu: vfio_container_dma_map(0x..., 0x0, 0xa0000, 0x....) = -22 (Invalid argument)
    qemu: hardware error: vfio: DMA mapping failed, unable to continue

1) https://patchew.org/QEMU/[email protected]/

Fixes: f404220e27 ("q35: implement 128K SMRAM at default SMBASE address")
Reported-by: Andrey Ryabinin <[email protected]>
Signed-off-by: Igor Mammedov <[email protected]>
Reviewed-by: Andrey Ryabinin <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Message-Id: <[email protected]>
2026-02-05 05:06:46 -05:00
Kevin Wolf f73e5ed9bc pcie_sriov: Fix PCI_SRIOV_* accesses in pcie_sriov_pf_exit()
PCI_SRIOV_* are offsets into the SR-IOV capability, not into the PCI
config space. pcie_sriov_pf_exit() erroneously takes them as the latter,
which makes it read PCI_HEADER_TYPE and PCI_BIST when it tries to read
PCI_SRIOV_TOTAL_VF.

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

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

Cc: [email protected]
Fixes: 19e55471d4 ('pcie_sriov: Allow user to create SR-IOV device')
Signed-off-by: Kevin Wolf <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Message-Id: <[email protected]>
2026-02-05 05:06:46 -05:00
Kevin Wolf 623db85647 virtio: Fix crash when sriov-pf is set for non-PCI-Express device
Setting the sriov-pf property on devices that aren't PCI Express causes
an assertion failure:

    $ qemu-system-x86_64 \
        -blockdev null-co,node-name=null \
        -blockdev null-co,node-name=null2 \
        -device virtio-blk,drive=null,id=pf \
        -device virtio-blk,sriov-pf=pf,drive=null2
    qemu-system-x86_64: ../hw/pci/pcie.c:1062: void pcie_add_capability(PCIDevice *, uint16_t, uint8_t, uint16_t, uint16_t): Assertion `offset >= PCI_CONFIG_SPACE_SIZE' failed.

This is because proxy->last_pcie_cap_offset is only initialised to a
non-zero value in virtio_pci_realize() if it's a PCI Express device, and
then virtio_pci_device_plugged() still tries to use it.

To fix this, just skip the SR-IOV code for !pci_is_express(). Then the
next thing pci_qdev_realize() does is call pcie_sriov_register_device(),
which returns the appropriate error.

Cc: [email protected]
Fixes: d0c280d3fa ('pcie_sriov: Make a PCI device with user-created VF ARI-capable')
Signed-off-by: Kevin Wolf <[email protected]>
Reviewed-by: Stefan Hajnoczi <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Message-Id: <[email protected]>
2026-02-05 05:06:46 -05:00
Dorinda Bassey fff77cfb84 virtio-dmabuf: Ensure UUID persistence for hash table insertion
In `virtio_add_resource` function, the UUID used as a key for
`g_hash_table_insert` was temporary, which could lead to
invalid lookups when accessed later. This patch ensures that
the UUID remains valid by duplicating it into a newly allocated
memory space. The value is then inserted into the hash table
with this persistent UUID key to ensure that the key stored in
the hash table remains valid as long as the hash table entry
exists.

Fixes: faefdba847 ("hw/display: introduce virtio-dmabuf")
Signed-off-by: Dorinda Bassey <[email protected]>
Reviewed-by: Stefano Garzarella <[email protected]>
Reviewed-by: Albert Esteve <[email protected]>
Reviewed-by: Marc-André Lureau <[email protected]>
Reviewed-by: Jim MacArthur <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Message-Id: <[email protected]>
2026-02-05 05:06:45 -05:00
Eugenio Pérez 459cfb80a7 vhost: accept indirect descriptors in shadow virtqueue
The device is not able to generate indirect descriptors by itself, only
the driver can do it.  And SVQ is already able to handle them by reusing
VirtQueue struct.

Shadow VirtQueue just transform the indirect descriptors to chained
buffers.  This way we don't need to map a new buffer for the indirect
table and handle its exhaustion etc.  As they are only used in control
plane and HW devices don't like indirect, we should not see significant
downsides with these.

Signed-off-by: Eugenio Pérez <[email protected]>
--

Tested functionally by forwarding the CVQ descriptors.

Acked-by: Jason Wang <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Message-Id: <[email protected]>
2026-02-05 05:06:45 -05:00
Gavin Shan 0771574c2f acpi/ghes: Use error_fatal in acpi_ghes_memory_errors()
Use error_fatal in acpi_ghes_memory_errors() so that the caller needn't
explicitly call exit(). The return value of acpi_ghes_memory_errors()
and ghes_record_cper_errors() is changed to 'bool' indicating an error
has been raised, to be compatible with what's documented in error.h.

Suggested-by: Igor Mammedov <[email protected]>
Suggested-by: Markus Armbruster <[email protected]>
Signed-off-by: Gavin Shan <[email protected]>
Reviewed-by: Jonathan Cameron <[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Reviewed-by: Igor Mammedov <[email protected]>
Reviewed-by: Mauro Carvalho Chehab <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Message-Id: <[email protected]>
2026-02-05 05:06:45 -05:00
Gavin Shan b2782920e0 acpi/ghes: Bail early on error from get_ghes_source_offsets()
In ghes_record_cper_errors(), get_ghes_source_offsets() can return
a error initialized by error_setg(). Without bailing on this error,
it can call into the second error_setg() due to the unexpected value
returned from the read acknowledgement register. The second error_setg()
can trigger assert(*errp == NULL) in its callee error_setv(), which
isn't expected.

Bail early in ghes_record_cper_errors() when error is received from
get_ghes_source_offsets() to avoid the unexpected behavior.

Signed-off-by: Gavin Shan <[email protected]>
Reviewed-by: Jonathan Cameron <[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Reviewed-by: Igor Mammedov <[email protected]>
Reviewed-by: Mauro Carvalho Chehab <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Message-Id: <[email protected]>
2026-02-05 05:06:45 -05:00
Gavin Shan 0352e85fe5 target/arm/kvm: Exit on error from acpi_ghes_memory_errors()
A core dump is no sense as there isn't programming bugs related to
errors from acpi_ghes_memory_errors().

Exit instead of abort when the function returns errors, and the
excessive error message is also dropped.

Suggested-by: Igor Mammedov <[email protected]>
Suggested-by: Markus Armbruster <[email protected]>
Signed-off-by: Gavin Shan <[email protected]>
Reviewed-by: Igor Mammedov <[email protected]>
Reviewed-by: Mauro Carvalho Chehab <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Message-Id: <[email protected]>
2026-02-05 05:06:45 -05:00
Gavin Shan 27814d0e63 acpi/ghes: Abort in acpi_ghes_memory_errors() if necessary
The function hw/acpi/ghes-stub.c::acpi_ghes_memory_errors() shouldn't
be called by any one. Take g_assert_not_reached() as a clearer indication.

Suggested-by: Markus Armbruster <[email protected]>
Signed-off-by: Gavin Shan <[email protected]>
Reviewed-by: Igor Mammedov <[email protected]>
Reviewed-by: Mauro Carvalho Chehab <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Message-Id: <[email protected]>
2026-02-05 05:06:45 -05:00
Gavin Shan 1ab76ad760 acpi/ghes: Automate data block cleanup in acpi_ghes_memory_errors()
Use g_auto_ptr() to automate data block cleanup in the function so
that it won't be a burden to us.

Suggested-by: Markus Armbruster <[email protected]>
Signed-off-by: Gavin Shan <[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Reviewed-by: Igor Mammedov <[email protected]>
Reviewed-by: Mauro Carvalho Chehab <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Message-Id: <[email protected]>
2026-02-05 05:06:45 -05:00
Wafer Xie fd3a2c601a vdpa: fix vhost-vdpa suspended state not be shared
When stopping a vhost-vdpa device, only the first queue pair is marked as suspended,
while the remaining queues are not updated to the suspended state.
As a result, when stopping a multi-queue vhost-vdpa device,
the following error message will be printed.

qemu-system-x86_64:vhost VQ 2 ring restore failed: -1: Operation not permitted (1)

qemu-system-x86_64:vhost VQ 3 ring restore failed: -1: Operation not permitted (1)

So move v->suspended to v->shared, and then all the vhost_vdpa devices cannot
have different suspended states.

Fixes: 0bb302a996 ("vdpa: add vhost_vdpa_suspend")
Suggested-by: Eugenio Pérez <[email protected]>
Acked-by: Eugenio Pérez <[email protected]>
Acked-by: Jason Wang <[email protected]>
Signed-off-by: Wafer Xie <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Acked-by: Jason Wang <[email protected]>
Message-Id: <[email protected]>
2026-02-05 05:06:45 -05:00
Daniil Tatianin 23a4edb6db virtio/vhost: don't consider non-MAP_SHARED regions public
Just having a file descriptor is not enough to consider a memory region
public. If QEMU didn't map it as MAP_SHARED (in case of share=off), guest
writes to this region won't be visible to the vhost-user backend, thus
causing it to read all zeroes or garbage. Make sure we don't pass such
regions and include that to our definition of what a private region is.

Signed-off-by: Daniil Tatianin <[email protected]>
Fixes: 552b25229c ("vhost: Rework memslot filtering and fix "used_memslot" tracking")
Acked-by: Stefano Garzarella <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Message-Id: <[email protected]>
2026-02-05 05:06:45 -05:00
Peter Maydell 739ae3df7b Merge tag 'pull-aspeed-20260204' of https://github.com/legoater/qemu into staging
aspeed queue:

* Added support for the new AST1700 IO expander, including several
  device models (LTPI, PWM, I2C, GPIO, etc.).
* Updated the AST2700 SoC with LTPI support, EHCI IRQ fixes, and other
  improvements.
* Updated test images and test cases for various Aspeed platforms.
* Fixed issues in the Aspeed I2C and ADC models.
* Added support for pca9535 GPIO expander.
* Updated documentation for Aspeed boards.

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCAAdFiEEoPZlSPBIlev+awtgUaNDx8/77KEFAmmDH8EACgkQUaNDx8/7
# 7KEJShAAulFE612LVWb+FAnuqf4StOA8qHbK3zDVG8ki7IC9vfOdS5guRwJgy5bU
# rbCYxSudRe50uRct+3c2mxPEsUpFUwfthA8w36BGZoSxxugLSoBzJto3Om1UH/rQ
# ZMZerg6Aze0oab2Df98TTceSi4el76owKRAabnOAOS7n24BKxTgn4dN2weRyWT0d
# 7AemIMqjtRhT27JBoB8vHsmdNlSDzI+eR2nyHJqvd0u3DHKBVxk0UH/DyTnJ5/4i
# A7d4Oxi28rEG+VJVG5vLfJi+is1sggoGxfX3SQmWKronODn3aNkWk93dR+kljMGo
# pXyqMQn8JJZZtRRSGAMflIdYvYLmpQkyUGR6kufdMn4EshALwLa5bObx6qb7RLyG
# CfS0gIR1O9zTS6w7kzifF4N2/iYlIReoIs8IiYFCcef8kmu/UToipQtUIllZN3q5
# pNTlruoylqbctyaqrtwHV2tiPxO4N+Y7voX68YtXWIVzLChQiAwz6osdP+JO1txq
# ePi3R0nAI9wks3NR206LRO45OFKP4IPgfAbMMq5aeDEpIbxU/qAEtTglwUUPby9o
# E8D15vukcYWuobvVqnKX7IzWGoGzJX5QU0wbO5pfDUc8BtQtdL9nOaSTDX3o+chK
# KNcuG91mQLlGe86OpysoK6N+PNwLvnWy8Su5x3HF0wNQ0PTASkw=
# =APEm
# -----END PGP SIGNATURE-----
# gpg: Signature made Wed Feb  4 10:30:25 2026 GMT
# gpg:                using RSA key A0F66548F04895EBFE6B0B6051A343C7CFFBECA1
# gpg: Good signature from "Cédric Le Goater <[email protected]>" [full]
# gpg:                 aka "Cédric Le Goater <[email protected]>" [full]
# Primary key fingerprint: A0F6 6548 F048 95EB FE6B  0B60 51A3 43C7 CFFB ECA1

* tag 'pull-aspeed-20260204' of https://github.com/legoater/qemu: (45 commits)
  tests/functional/aarch64: Add I2C test for AST1700 IO expanders
  tests/functional/aarch64: Parameterize PCIe2 initialization in AST2700
  tests/functional/aarch64: Parameterize I2C bus ID in AST2700 test
  hw/arm/aspeed: Enable AST1700 IO expander support
  hw/arm/aspeed: Model AST1700 I3C block as unimplemented device
  hw/arm/aspeed: Attach SGPIOM device to AST1700 model
  hw/arm/aspeed: Attach PWM device to AST1700 model
  hw/arm/aspeed: Attach WDT device to AST1700 model
  hw/arm/aspeed: attach I2C device to AST1700 model
  hw/arm/aspeed: Attach GPIO device to AST1700 model
  hw/arm/aspeed: Attach SCU device to AST1700 model
  hw/arm/aspeed: Attach ADC device to AST1700 model
  hw/arm/aspeed: Attach SPI device to AST1700 model
  hw/arm/aspeed: Attach SRAM device to AST1700 model
  hw/arm/aspeed: Attach UART device to AST1700 model
  hw/arm/aspeed: Attach LTPI controller to AST1700 model
  hw/arm/aspeed: Integrate interrupt controller for AST1700
  hw/arm/aspeed: Integrate AST1700 device into AST27X0
  hw/arm/aspeed: Add AST1700 LTPI expander device model
  hw/misc: Add basic Aspeed PWM model
  ...

Signed-off-by: Peter Maydell <[email protected]>
2026-02-05 09:50:33 +00:00
CLEMENT MATHIEU--DRIF 952e1a6e90 intel_iommu: Add a CLI option to enable SVM
Signed-off-by: Clement Mathieu--Drif <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Message-Id: <[email protected]>
2026-02-05 03:18:40 -05:00
CLEMENT MATHIEU--DRIF 0acb2b193b intel_iommu: Minimal handling of privileged ATS request
The purpose of this commit is not to support privileged requests but
to prevent devices from doing things they wouldn't be able to do
with real hardware.

We simply block privileged requests when the SRS ecap is not set
and abort when the ecap is present.

For now, its not worth implementing support for privileged requests
because the kernel does not support it.
(https://lore.kernel.org/linux-iommu/[email protected]/)
However, we may consider working on it depending on how the development
goes in the kernel.

Signed-off-by: Clement Mathieu--Drif <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Message-Id: <[email protected]>
2026-02-05 03:18:40 -05:00
CLEMENT MATHIEU--DRIF e08a72d217 intel_iommu: Handle insufficient permissions during translation requests
ATS translations should not fail when the write permission is not set.

Signed-off-by: Clement Mathieu--Drif <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Message-Id: <[email protected]>
2026-02-05 03:18:40 -05:00
CLEMENT MATHIEU--DRIF ccd162e5be pci: Block ATS requests when privileged mode is disabled
Signed-off-by: Clement Mathieu--Drif <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Message-Id: <[email protected]>
2026-02-05 03:18:40 -05:00
CLEMENT MATHIEU--DRIF b7e31028a3 pcie: Add a function to check if pasid privileged mode is enabled
Signed-off-by: Clement Mathieu--Drif <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Message-Id: <[email protected]>
2026-02-05 03:18:40 -05:00
CLEMENT MATHIEU--DRIF 05f858cb67 intel_iommu: Support memory operations with pre-translated addresses
Signed-off-by: Clement Mathieu--Drif <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Message-Id: <[email protected]>
2026-02-05 03:18:40 -05:00
CLEMENT MATHIEU--DRIF cabeac1246 intel_iommu: Add an IOMMU index for pre-translated addresses
Signed-off-by: Clement Mathieu--Drif <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Message-Id: <[email protected]>
2026-02-05 03:18:39 -05:00
Philippe Mathieu-Daudé c6caeed118 hw/pci-host: Set DEVICE_CATEGORY_BRIDGE once in parent class_init()
No need to set DEVICE_CATEGORY_BRIDGE for each device
implementing TYPE_PCI_HOST_BRIDGE: set it once in the
parent.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Marc-André Lureau <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Message-Id: <[email protected]>
2026-02-05 03:18:39 -05:00
Akihiko Odaki 6d8dd5ec08 pci/shpc: Do not unparent in instance_finalize()
Children are automatically unparented so manually unparenting is
unnecessary.

Worse, automatic unparenting happens before the instance_finalize()
callback of the parent gets called, so object_unparent() calls in
the callback will refer to objects that are already unparented, which
is semantically incorrect.

Signed-off-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Message-ID: <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Message-Id: <[email protected].i.u-tokyo.ac.jp>
2026-02-05 03:18:39 -05:00
Kane Chen e56e45d5bd tests/functional/aarch64: Add I2C test for AST1700 IO expanders
Extend the AST2700 test suite to verify I2C connectivity on AST1700
IO expanders using the DCSCM image. This validates the new bus-label
naming scheme by testing communication on both primary and
expander-attached I2C buses.

Signed-off-by: Kane-Chen-AS <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-02-04 10:10:57 +01:00
Kane Chen 3e792a6a44 tests/functional/aarch64: Parameterize PCIe2 initialization in AST2700
The current AST2700 functional test forces PCIe2 enablement by manually
manipulating U-Boot env and FDT via the console. This sequence
interferes with test cases that rely on the default boot flow of the
image.

Introduce a 'enable_pcie' parameter (defaulting to True) to both
'verify_openbmc_boot_start' and 'verify_openbmc_boot_and_login' methods.
This allow test cases to toggle the PCIe2 initialization sequence based
on their specific requirements without breaking standard boot tests.

Signed-off-by: Kane-Chen-AS <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-02-04 10:10:57 +01:00
Kane Chen 0fa5a11210 tests/functional/aarch64: Parameterize I2C bus ID in AST2700 test
The current Aspeed AST2700 functional test case strictly uses I2C bus
1 for its sensor tests. This hard-coded approach prevents the test
logic from being reused for other machine types or configurations
where I2C bus 1 might be disabled or where a different bus needs to
be verified (e.g., I2C expanders).

This refactoring allows the same I2C verification logic to be shared
across different test scenarios by simply passing the target bus
number.

Signed-off-by: Kane-Chen-AS <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-02-04 10:10:57 +01:00
Kane Chen fb7325aac1 hw/arm/aspeed: Enable AST1700 IO expander support
Set ioexp_num to 2 to enable AST1700 IO expander support.

Signed-off-by: Kane-Chen-AS <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Reviewed-by: Nabih Estefan <[email protected]>
Tested-by: Nabih Estefan <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-02-04 10:10:57 +01:00
Kane Chen 551fe2c376 hw/arm/aspeed: Model AST1700 I3C block as unimplemented device
AST1700 exposes more I3C buses than the current dummy I3C model
provides. When Linux probes the I3C devices on AST1700 this mismatch
can trigger a kernel panic. Model the I3C block as an unimplemented
device to make the missing functionality explicit and avoid unexpected
side effects.

This wires up the I3C interrupt lines for the IO expanders and adds the
corresponding device entries for the AST1700 model.

No functional I3C emulation is provided yet; this only prevents crashes and
documents the missing piece.

Signed-off-by: Kane-Chen-AS <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Reviewed-by: Nabih Estefan <[email protected]>
Tested-by: Nabih Estefan <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-02-04 10:10:57 +01:00
Kane Chen 8cb4865429 hw/arm/aspeed: Attach SGPIOM device to AST1700 model
Connect the SGPIOM device to AST1700 model.

Signed-off-by: Kane-Chen-AS <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Reviewed-by: Nabih Estefan <[email protected]>
Tested-by: Nabih Estefan <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-02-04 10:10:57 +01:00
Kane Chen 7e70b59776 hw/arm/aspeed: Attach PWM device to AST1700 model
Connect the PWM device to AST1700 model.

Signed-off-by: Kane-Chen-AS <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Reviewed-by: Nabih Estefan <[email protected]>
Tested-by: Nabih Estefan <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-02-04 10:10:57 +01:00
Kane Chen 7caf444957 hw/arm/aspeed: Attach WDT device to AST1700 model
Connect the WDT device to AST1700 model.

Signed-off-by: Kane-Chen-AS <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Reviewed-by: Nabih Estefan <[email protected]>
Tested-by: Nabih Estefan <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-02-04 10:10:57 +01:00
Kane Chen a8b43ac5b6 hw/arm/aspeed: attach I2C device to AST1700 model
Connect the I2C controller to the AST1700 model by mapping its MMIO
region and wiring its interrupt line.

Signed-off-by: Kane-Chen-AS <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-02-04 10:10:57 +01:00
Kane Chen 1ab5e44df7 hw/arm/aspeed: Attach GPIO device to AST1700 model
Connect the GPIO controller to the AST1700 model by mapping its MMIO
region and wiring its interrupt line.

Signed-off-by: Kane-Chen-AS <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Reviewed-by: Nabih Estefan <[email protected]>
Tested-by: Nabih Estefan <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-02-04 10:10:57 +01:00
Kane Chen b500ab0055 hw/arm/aspeed: Attach SCU device to AST1700 model
Connect the SCU device to AST1700 model.

Signed-off-by: Kane-Chen-AS <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Reviewed-by: Nabih Estefan <[email protected]>
Tested-by: Nabih Estefan <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-02-04 10:10:57 +01:00
Kane Chen 5d04074cb7 hw/arm/aspeed: Attach ADC device to AST1700 model
Connect the ADC device to AST1700 model.

Signed-off-by: Kane-Chen-AS <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Reviewed-by: Nabih Estefan <[email protected]>
Tested-by: Nabih Estefan <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-02-04 10:10:57 +01:00
Kane Chen 79856931e3 hw/arm/aspeed: Attach SPI device to AST1700 model
Connect the SPI device to AST1700 model.

Signed-off-by: Kane-Chen-AS <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-02-04 10:10:57 +01:00
Kane Chen 7ba5fd213d hw/arm/aspeed: Attach SRAM device to AST1700 model
Map the SRAM device to AST1700 model

Signed-off-by: Kane-Chen-AS <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Reviewed-by: Nabih Estefan <[email protected]>
Tested-by: Nabih Estefan <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-02-04 10:10:57 +01:00
Kane Chen d75f9e5aca hw/arm/aspeed: Attach UART device to AST1700 model
Connect the UART controller to the AST1700 model by mapping its MMIO
region.

Signed-off-by: Kane-Chen-AS <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Reviewed-by: Nabih Estefan <[email protected]>
Tested-by: Nabih Estefan <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-02-04 10:10:57 +01:00
Kane Chen 5f37bf0127 hw/arm/aspeed: Attach LTPI controller to AST1700 model
Connect the LTPI controller to the AST1700 model by mapping its MMIO
region.

Signed-off-by: Kane-Chen-AS <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Reviewed-by: Nabih Estefan <[email protected]>
Tested-by: Nabih Estefan <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-02-04 10:10:57 +01:00
Kane Chen a844b88044 hw/arm/aspeed: Integrate interrupt controller for AST1700
Connect the AST1700 interrupt lines to the GIC in AST27X0, enabling
the propagation of AST1700-originated interrupts to the host SoC.

This patch does not implement interrupt sources in AST1700 itself,
only the wiring into AST27X0.

Signed-off-by: Kane-Chen-AS <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-02-04 10:10:57 +01:00
Kane Chen b6fb986047 hw/arm/aspeed: Integrate AST1700 device into AST27X0
Connect the AST1700 device as a child of the AST27X0 model to reflect
its role in DC-SCM 2.0 LTPI-based architectures. This patch wires
the AST1700 device into the platform without introducing functional
peripherals.

This forms the base for LTPI expander emulation in QEMU using
AST27X0 as the host controller.

Note: ioexp_num is set to 0 at this stage. Once all related devices
and interrupts are fully implemented, ioexp_num will be updated to
its expected value. This ensures the machine remains functional at
every commit and avoids potential compiler or build issues.

Signed-off-by: Kane-Chen-AS <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Reviewed-by: Nabih Estefan <[email protected]>
Tested-by: Nabih Estefan <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-02-04 10:10:57 +01:00
Kane Chen fc381d5b03 hw/arm/aspeed: Add AST1700 LTPI expander device model
Introduce a minimal QEMU device model for the ASPEED AST1700, an
MCU-less I/O expander used in the LTPI topology defined by the
DC-SCM 2.0 specification (see figure 2):
https://www.opencompute.org/documents/ocp-dc-scm-2-0-ltpi-ver-1-0-pdf

This initial implementation includes:

* Definition of aspeed.ast1700 as a SysBusDevice

* Setup of a basic memory region to reserve I/O space for future
  peripheral modeling

This stub establishes the foundation for LTPI-related device emulation,
without implementing any functional peripherals at this stage.

Signed-off-by: Kane-Chen-AS <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Reviewed-by: Nabih Estefan <[email protected]>
Tested-by: Nabih Estefan <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-02-04 10:10:57 +01:00
Kane Chen b935def0f8 hw/misc: Add basic Aspeed PWM model
Add an initial PWM model for Aspeed SoCs, including device state,
register definitions, and basic initialization as a sysbus device.

Signed-off-by: Cédric Le Goater <[email protected]>
Signed-off-by: Kane-Chen-AS <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-02-04 10:10:57 +01:00
Kane Chen 8ed21f4ba6 hw/arm/aspeed: Attach LTPI controller to AST27X0 platform
Connect the LTPI controller device (representing the AST1700 I/O
expander) to the AST27X0 SoC model. This patch sets up the memory
mapping and device registration according to the AST2700 SoC design,
where the LTPI controller is exposed at fixed MMIO regions.

This change only handles device instantiation and integration,
without implementing the controller's internal logic.

Signed-off-by: Kane-Chen-AS <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Reviewed-by: Nabih Estefan <[email protected]>
Tested-by: Nabih Estefan <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-02-04 10:10:57 +01:00
Kane Chen b75d9bef4a hw/misc: Add LTPI controller
LTPI (LVDS Tunneling Protocol & Interface) is defined in the OCP DC-SCM
2.0 specification:
https://www.opencompute.org/documents/ocp-dc-scm-2-0-ltpi-ver-1-0-pdf

LTPI is a protocol and physical interface for tunneling various low-speed
signals between the HPM and SCM. As shown in Figure 2, the AST27x0 (left)
integrates two LTPI controllers, allowing it to connect to up to two
extended boards.

This commit introduces a simple device model for the ASPEED LTPI
controller in QEMU.

The model includes basic MMIO read/write operations and sets default
register values during reset to emulate a link-up state.

Implements register space with read/write callbacks.

Signed-off-by: Kane-Chen-AS <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Reviewed-by: Nabih Estefan <[email protected]>
Tested-by: Nabih Estefan <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-02-04 10:10:57 +01:00
Jamin Lin 1a45e9d90d docs/system/arm/aspeed: Load raw U-Boot image in AST2700 boot example
Recent SDK versions no longer provide a U-Boot FIT image, and U-Boot is
now built as a single raw binary. Update the documentation to load the
raw u-boot.bin image directly.

Signed-off-by: Jamin Lin <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-02-04 08:24:29 +01:00
Jamin Lin b2bbf8452d tests/functional/aarch64/test_aspeed_ast2700fc: Update test ASPEED SDK v11.00 for A1
Signed-off-by: Jamin Lin <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-02-04 08:24:29 +01:00
Jamin Lin e0da69cc7e tests/functional/aarch64/test_aspeed_ast2700: Update test ASPEED SDK v11.00 for A1
Signed-off-by: Jamin Lin <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-02-04 08:24:29 +01:00
Jamin Lin 03073201da tests/functional/aarch64/test_aspeed_ast2700: Enable PCIe2 DTS status for AST2700 tests
PCIe2 is disabled by default starting from SDK v10.00.

Add a helper function to stop U-Boot autoboot and update the device
tree at runtime, setting the PCIe2 node status to "okay" before
booting Linux. This allows the AST2700 functional test to verify
the PCIe2 root complex behavior correctly.

Signed-off-by: Jamin Lin <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-02-04 08:24:29 +01:00
Jamin Lin efea7ddb46 hw/i2c/aspeed_i2c: Fix DMA moving data into incorrect address
In the previous design, the I2C model updated dma_dram_offset only when
firmware programmed the RX/TX DMA buffer address registers. The firmware
used to rewrite these registers before issuing each DMA command.

The firmware driver behavior has changed to program the DMA address
registers only once during I2C initialization. As a result, the I2C model
no longer refreshes dma_dram_offset, causing DMA to move data into an
incorrect DRAM address.

Fix this by introducing helper functions to update dma_dram_offset from
the DMA address registers, and invoke them right before handling TX/RX
DMA operations. This guarantees DMA always uses the correct buffer
address even if the registers are programmed only once.

Signed-off-by: Jamin Lin <[email protected]>
Fixes: c400c38854 ("hw/i2c/aspeed: Introduce a new dma_dram_offset attribute in AspeedI2Cbus")
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-02-04 08:24:29 +01:00
Jamin Lin a9a70ac692 hw/arm/aspeed_ast27x0: Sort SSP and TSP IRQ maps
Sort the SSP and TSP IRQ map tables to improve readability and make the
definitions easier to maintain.

No functional change.

Signed-off-by: Jamin Lin <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-02-04 08:24:29 +01:00
Jamin Lin 5259109164 hw/arm/aspeed_ast27x0: Sort SSP and TSP memmap tables by address
Sort the SSP and TSP memmap tables to improve readability and
make the definitions easier to maintain.

No functional change.

Signed-off-by: Jamin Lin <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-02-04 08:24:29 +01:00
Jamin Lin 7d64f04863 hw/arm/aspeed_ast27x0: Fix EHCI3/4 IRQ routing to GIC
EHCI3 and EHCI4 were missing entries in aspeed_soc_ast2700a1_irqmap,
so their source IRQs were never routed through the INTC OR-gates.

As a result, EHCI3/4 interrupts were not propagated to the GIC,
causing incorrect interrupt behavior for these controllers.

Add EHCI3 and EHCI4 to the IRQ map and route them to the same INTC
group as other shared peripherals, ensuring their interrupts are
properly connected to the GIC.

Signed-off-by: Jamin Lin <[email protected]>
Fixes: ba27ba302a ("hw/arm: ast27x0: Wire up EHCI controllers")
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-02-04 08:24:29 +01:00
Jamin Lin 05d8525957 tests/functional/arm/test_aspeed_ast1030: Update test ASPEED Zephyr SDK v03.05
Signed-off-by: Jamin Lin <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-02-04 08:24:29 +01:00
Jamin Lin d512b03be7 tests/functional/arm/test_aspeed_ast1060: Update test aspeed-zephyr-project v03.04
Signed-off-by: Jamin Lin <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-02-04 08:24:29 +01:00
Jamin Lin 787222fb46 tests/functional/arm/test_aspeed_ast2600_sdk: Update test ASPEED SDK v11.00
Drop root device and set root bus number to 0.

Signed-off-by: Jamin Lin <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-02-04 08:24:29 +01:00
Jamin Lin 2455271901 hw/arm/aspeed_ast2600: Expand RC_H PCIe MMIO window to 0x60000000 - 0x80000000
Historically, the ASPEED PCIe driver supported both RC_L and RC_H, with RC_L
using MMIO window 0x60000000 - 0x70000000 and RC_H using 0x70000000 - 0x80000000.

Mainline Linux has dropped RC_L support and now supports RC_H only, updating
RC_H to use a single combined MMIO window 0x60000000 - 0x80000000.

Update the AST2600 QEMU model accordingly by moving PCIE_MMIO1 base to
0x60000000 and increasing the aliased MMIO size to 0x20000000.

Signed-off-by: Jamin Lin <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-02-04 08:24:29 +01:00
Jamin Lin 6b7f0908dc hw/pci-host/aspeed_pcie: Drop AST2600 RC_H root-bus remap and bus-nr property
The original AST2600 PCIe design supported both RC_L and RC_H, using root bus
number 0 for RC_L and 0x80 for RC_H. In that model, the root port appeared as
80:08.0 and QEMU carried a "bus-nr" property plus a config-space bus remap to
translate bus 0x80 to bus 0x00 for PCI enumeration.

Linux mainline has since dropped RC_L support and updated the RC_H root bus
number to start at 0. The root port is now enumerated as 00:08.0, matching the
default QEMU PCIe subsystem root bus numbering.

Remove the bus number setting and the AST2600 bus remap logic, and drop the
corresponding "bus-nr"/rc_bus_nr fields and property plumbing. QEMU now relies
on the default root bus 0 behavior.

Signed-off-by: Jamin Lin <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-02-04 08:24:29 +01:00
Jamin Lin 8f5e28530f hw/pci-host/aspeed_pcie: Drop AST2600 PCIe root device
AST2600 PCIe previously exposed a root bus at 0x80 with both a
root device at 80:00.0 and a root port at 80:08.0.

Recent ASPEED SDK PCIe driver updates decided to remove the root
device and keep only a single root port. This behavior has already
been accepted by the upstream Linux kernel.

Update the QEMU PCIe model accordingly by dropping the root device
implementation and related properties. AST2600 now matches the
AST2700 PCIe topology and no longer supports the legacy RC_L
layout.

Signed-off-by: Jamin Lin <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-02-04 08:24:29 +01:00
Jamin Lin 6772ffa4dc tests/functional/arm/test_aspeed_ast2500: Update test ASPEED SDK v10.00
Signed-off-by: Jamin Lin <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-02-04 08:24:29 +01:00
Cédric Le Goater 4c6521296d hw/adc: Fix out-of-bounds write in Aspeed ADC model
The 'regs' array has ASPEED_ADC_NR_REGS (52) elements, while the
memory region covers offsets 0x00-0xFC. The aspeed_adc_engine_write()
function has an out-of-bounds write vulnerability when accessing
unimplemented registers.

Fix this by using 'return' instead of 'break' in the default case,
which prevents execution from reaching the s->regs[reg] assignment for
unimplemented registers.

Reported-by: Elhrj Saad <[email protected]>
Fixes: 5857974d5d ("hw/adc: Add basic Aspeed ADC model")
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-02-04 08:24:29 +01:00
Patrick Williams 6353cdce2d hw/arm/aspeed: catalina: use pca9535
A few entries in the catalina model were using the PCA9552 chip
because it was "close enough" in function.  Since there is a PCA9535
model now, switch to use it.

Signed-off-by: Patrick Williams <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-02-04 08:24:29 +01:00
Patrick Williams f139033e58 hw/gpio/pca9552: add pca9535 support
Extend the 16-bit PCA9552 model to support non-LED devices such as
the PCA9535[1].

[1]: https://www.ti.com/lit/ds/symlink/pca9535.pdf

Signed-off-by: Patrick Williams <[email protected]>
Reviewed-by: Glenn Miles <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-02-04 08:24:29 +01:00
Nabih Estefan 0a1d477067 hw/i2c/aspeed_i2c.c: Add a check for dma_read
If aspeed_i2c_dma_read fails in aspeed_i2c_bus_send currently, we get
stuck in an infinite retry loop. Add a check for the return value of
aspeed_i2c_dma_read that will break us out of said loop.

Signed-off-by: Nabih Estefan <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Fixes: 545d6bef70 ("aspeed/i2c: Add support for DMA transfers")
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-02-04 08:24:29 +01:00
Jamin Lin fa6455ac1c MAINTAINERS: Update ASPEED entry
Signed-off-by: Jamin Lin <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-02-04 08:24:29 +01:00
Kane-Chen-AS 2835794bcd hw/i2c/aspeed: Introduce 'bus-label' to customize bus naming
On some Aspeed-based machines, multiple I2C controllers may exist
across different components, such as the primary SoC and an external
IO expander or co-processor (e.g., AST1700). Using the current static
naming convention results in object name conflicts when multiple
controllers attempt to instantiate buses with the same ID.

This patch introduces a 'bus-label' property for the Aspeed I2C
controller. This allows higher-level layers, such as the SoC realize
function, to provide a unique identifier for the buses. The I2C bus
object name is then constructed using this label (e.g., "ioexp0.0"
instead of the default "aspeed.i2c.bus.0").

This enhancement ensures unique bus identifiers across the system and
resolves naming conflicts in multi-controller configurations.

Signed-off-by: Kane-Chen-AS <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Tested-by: Nabih Estefan <[email protected]>
Reviewed-by: Nabih Estefan <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-02-04 08:24:29 +01:00
Cédric Le Goater 7a477dd174 tests/functional/arm/aspeed: Update buildroot images to 2025.11
The main changes compared to upstream 2025.11 buildroot are

  - Linux v6.18
  - latest OpenBMC U-Boot
  - extra packages (ssh, etc.)

See

  https://github.com/legoater/buildroot/commits/aspeed-2025.11

Acked-by: Jamin Lin <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-02-04 08:24:29 +01:00
Cédric Le Goater c289b82934 Merge tag 'pull-vbootrom-20260116-v3' into aspeed-next
vbootrom update pull request v3

* tag 'pull-vbootrom-20260116-v3':
  pc-bios: Update vbootrom image to commit 1c8e9510b22c

Signed-off-by: Cédric Le Goater <[email protected]>
2026-02-04 08:24:03 +01:00
Richard Henderson 28a6ca268c Merge tag 'single-binary-20260203' of https://github.com/philmd/qemu into staging
Various patches related to single binary effort:

- Endianness cleanups on various targets (PPC in particular)
- Few cleanups around target_ulong type on Alpha
- Have CPUClass::disas_set_info() take a const CPUState

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCAAdFiEE+qvnXhKRciHc/Wuy4+MsLN6twN4FAmmCDTkACgkQ4+MsLN6t
# wN7vHQ/+LCAYESbTy7cXeKGgAslwPbX1Q2zYGk0rhGMgrbBtQThbgQSkNsAwYmzg
# 6vx5crw9vYA/kLq0jyJQPTRIAKzXH9BzdEfTsEt5AIpZv6Cc4im6JBZdrxUa6S0O
# AMGb4pn9bpkcwHOv2ufotJbl0fa+id4WgQgXyLDEgwgNVvY18fVWfn5OwAon2bWo
# nb6zqRfwgdyAB+liwmlPNI+M4hZ3vDdct7whUP8t37FjTL0lNrsyG/Epr0xJB5ru
# CRsjubBkXAq8HlmwHZp8JSM/Lriitp8Z2ubD8VBqYbMYI25XUnRlBWWxTnQKkaDD
# Vgbq67UqS/k/X6vV5cfJaeS2qOdgF98V0VmrOqlNXTwMU56lzMn0ThgLqUXznRos
# IUfTUvmjfGu63aAWG2l+HBrehK5JEAGYzK6ZTiTA6abpvfHUjehslsQlAlMgcSnL
# TnMsM7mxS+XNbf6bsew0azTt2p/V81JDVrQuQgmAJS9ZOpALMFGep5YAYKvN/kLf
# cSbl+hQRsxqxQPoc6y0NrnCcfT33U1+I+IXpMIR/VyC0RgseW9HeRdJWuNyKBW/4
# VUBnQnYNhZM9hDHKp5PzU2KhoeudAlK3gws8zvtWfLCFyAvfmEYX0Gt5r23JkoxT
# IO340Jz5XRwfXMWENc6Bm8lqr7HilQi28HFNXWdy897YfNS83Ow=
# =J0gm
# -----END PGP SIGNATURE-----
# gpg: Signature made Wed 04 Feb 2026 12:59:05 AM AEST
# gpg:                using RSA key FAABE75E12917221DCFD6BB2E3E32C2CDEADC0DE
# gpg: Good signature from "Philippe Mathieu-Daudé (F4BUG) <[email protected]>" [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: FAAB E75E 1291 7221 DCFD  6BB2 E3E3 2C2C DEAD C0DE

* tag 'single-binary-20260203' of https://github.com/philmd/qemu: (30 commits)
  disas: Have disas_set_info() take a const CPUState
  disas: Make disassemble_info::target_info field const
  disas/riscv: Make rv_decode::cfg const
  target/arm: Have arm_sctlr_b() take a const @env argument
  target/arm: Have is_64() take a const @env argument
  target/arm: Have cpu_isar_feature() use a const ARMCPU object
  target/arm: Have arm_feature() take a const @env argument
  target/alpha: Expand TCGv type for 64-bit target
  target/alpha: Remove target_ulong uses in get_physical_address()
  target/alpha: Do not use target_ulong for page table entries / indexes
  target/alpha: Do not use target_ulong for trap arguments
  target/alpha: Replace target_ulong -> uint64_t in gdb_write_register()
  target/alpha: Build system units in common source set
  target/alpha: Avoid target-specific migration headers in machine.c
  target/m68k: Inline translator_ld[uw,l,q]() calls
  target/i386: Inline translator_ld[uw,l,q]() calls
  target/riscv: Inline translator_ld[uw,l,q]() calls
  target/riscv: Inline cpu_ld[lq]_code() calls
  target/ppc: Inline cpu_ldl_code() call in ppc_ldl_code()
  target/ppc: Check endianness at runtime in ppc_data_endian_env()
  ...

Signed-off-by: Richard Henderson <[email protected]>
2026-02-04 01:57:26 +10:00
Richard Henderson cab0422bfe Merge tag 'firmware-20260203-pull-request' of https://gitlab.com/kraxel/qemu into staging
firmware updates for 11.0
- igvm: rework reset handling.
- igvm: add MADT parameter support.
- uefi: variable store fixes.

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCgAdFiEEoDKM/7k6F6eZAf59TLbY7tPocTgFAmmB5AYACgkQTLbY7tPo
# cThR7Q//d5Z9cIQEOn7hqAgsqyz4llvyLpZk+pWuyQmJ7iBtF7geP0p61iICi5vP
# +jyKJChHtPQzAQLqKwgHLWAuYSW82EZPh74YvL4MBNe7WX8LouHvCoTsOE28Nxqx
# EWDtucSwwwQpx/r1iSSHEHqjlV2MudlGFMaOb0+by57j2ZsAGEe/0J+yF07hhXLQ
# OxQY1l8gHC+PK6BnRLnwIlBVBe+o2E9hJeV0GA/zd1UufTxsan/r06T1JRsdNhPe
# vkBFedwPz+4+jKbOVWBp2pY5FSxmIEe+sOqRdhFvyvz+KBziAyisCNtv/eABrd9h
# Jk/yfvrDIZEJk7GtwMAC/un+zz/iQfu9BK3EAtT5OnUCEbj7HNaEjuStB2AnfBnw
# 4clhjPA+qwej1771zAuKC5HOc+2mMxbON/roD4nGcEY3WKq7JvjUrIopesJcgCCu
# TjV1UXAxyG6CRvsiUc3uesdleumAqt3I4+OryfnPY5SloYjlg+bEW8fpKvXmI82l
# uZsI1SL3yqXJMVQEh0cS7awquKKkjzNR0CGR+a9KBMl3kCiuAPPkevEhERpd1J6V
# W6zZrNI9IHczBKrZEJ42apXutGmADDZUdREjktc4gUBvTzC317bfSTGk/tvQQe7N
# lRr9KV+56bSVrnLiqcCzfVj8U2YTecsvO98Xp28W3nwwvIls3mQ=
# =npQG
# -----END PGP SIGNATURE-----
# gpg: Signature made Tue 03 Feb 2026 10:03:18 PM AEST
# gpg:                using RSA key A0328CFFB93A17A79901FE7D4CB6D8EED3E87138
# gpg: Good signature from "Gerd Hoffmann (work) <[email protected]>" [unknown]
# gpg:                 aka "Gerd Hoffmann <[email protected]>" [unknown]
# gpg:                 aka "Gerd Hoffmann (private) <[email protected]>" [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: A032 8CFF B93A 17A7 9901  FE7D 4CB6 D8EE D3E8 7138

* tag 'firmware-20260203-pull-request' of https://gitlab.com/kraxel/qemu:
  igvm: Fill MADT IGVM parameter field on x86_64
  igvm: Only build stubs if igvm is enabled
  igvm: Pass machine state to IGVM file processing
  igvm: Refactor qigvm_parameter_insert
  igvm: Add common function for finding parameter entries
  igvm: Move structs to internal header
  hw/acpi: Add standalone function to build MADT
  hw/acpi: Make BIOS linker optional
  hw/acpi: Make acpi_checksum() public
  igvm: move igvm file processing to reset callbacks
  igvm: add trace points for igvm file loading and processing
  igvm: move file load to complete callback
  igvm: make igvm-cfg object resettable
  igvm: reorganize headers
  hw/uefi: fix size negotiation
  hw/uefi: skip time check for append-write updates.
  docs/system/igvm.rst: Update external links

Signed-off-by: Richard Henderson <[email protected]>
2026-02-04 01:56:55 +10:00
Philippe Mathieu-Daudé a63b90ca6c disas: Have disas_set_info() take a const CPUState
The CPUClass::disas_set_info() handler is meant to initialize
the %disassemble_info structure; it shoudn't alter the CPU state.
Enforce the CPUState can not be modified by having the handler
take a const pointer.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
2026-02-03 14:57:34 +01:00
Philippe Mathieu-Daudé b10b43176d disas: Make disassemble_info::target_info field const
Disassemblers shouldn't need writeable context, so make the
disassemble_info::target_info field const.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-02-03 14:57:34 +01:00
Philippe Mathieu-Daudé 8a00198ab4 disas/riscv: Make rv_decode::cfg const
Disassembler is not expected to alter the CPU config.
Besides, all other RISC-V methods takes a const RISCVCPUConfig.
Make the @cfg field of the rv_decode structure const, passing
a const pointer to disasm_inst().

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-02-03 14:57:34 +01:00
Philippe Mathieu-Daudé c87ef9d18a target/arm: Have arm_sctlr_b() take a const @env argument
arm_sctlr_b() only access @env read-only, make it const.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-02-03 14:57:34 +01:00
Philippe Mathieu-Daudé 655309dc4c target/arm: Have is_64() take a const @env argument
is_64() only access @env read-only, make it const.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-02-03 14:57:34 +01:00
Philippe Mathieu-Daudé 8a91d97085 target/arm: Have cpu_isar_feature() use a const ARMCPU object
The @cpu_ variable is only accessed read-only, make it const.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-02-03 14:57:34 +01:00
Philippe Mathieu-Daudé fd37919778 target/arm: Have arm_feature() take a const @env argument
arm_feature() only access @env read-only, make it const.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-02-03 14:57:34 +01:00
Philippe Mathieu-Daudé d8f0217284 target/alpha: Expand TCGv type for 64-bit target
The Alpha targets are only built as 64-bit:

  $ git grep TARGET_LONG_BITS configs/targets/alpha-*
  configs/targets/alpha-linux-user.mak:4:TARGET_LONG_BITS=64
  configs/targets/alpha-softmmu.mak:2:TARGET_LONG_BITS=64

Replace:

  TCGv -> TCGv_i64
  tcg_temp_new -> tcg_temp_new_i64

This is a mechanical replacement, adapting style to pass
the checkpatch.pl script.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-02-03 14:57:34 +01:00
Philippe Mathieu-Daudé 2be3650d62 target/alpha: Remove target_ulong uses in get_physical_address()
%addr is a virtual address, so use the 'vaddr' type.
%pphys is a pointer to a physical address, so use the 'hwaddr' type.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-02-03 14:57:34 +01:00
Philippe Mathieu-Daudé c3ba74e21a target/alpha: Do not use target_ulong for page table entries / indexes
%L[123]pte are loaded calling ldq_le_phys() which returns
a uint64_t. %pt is loaded with @ptbr, declared as uint64_t
in target/alpha/cpu.h:

  236    uint64_t ptbr;

%index is at most 1024 so can fit in uint16_t.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-02-03 14:57:34 +01:00
Philippe Mathieu-Daudé 29a45d20a0 target/alpha: Do not use target_ulong for trap arguments
%mmcsr and %cause are filled with @trap_arg1 / @trap_arg2,
both declared as uint64_t in target/alpha/cpu.h:

    229     uint64_t trap_arg1;
    230     uint64_t trap_arg2;
    ...

Use uint64_t instead of target_ulong.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-02-03 14:57:34 +01:00
Philippe Mathieu-Daudé f5d00b3b3a target/alpha: Replace target_ulong -> uint64_t in gdb_write_register()
On Alpha, the target_ulong type expands to uint64_t.
Besides, ldq_be_p() returns a uint64_t type, and all
field / values accessed are uint64_t, see target/alpha/cpu.h:

  200 typedef struct CPUArchState {
  201     uint64_t ir[31];
  202     float64 fir[31];
  203     uint64_t pc;
  204     uint64_t unique;
  ...
  443 void cpu_alpha_store_fpcr (CPUAlphaState *env, uint64_t val);
  445 void cpu_alpha_store_gr(CPUAlphaState *env, unsigned reg, uint64_t val);

Use uint64_t instead of target_ulong.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-02-03 14:57:34 +01:00
Philippe Mathieu-Daudé 63004cd8c4 target/alpha: Build system units in common source set
Since commits bb5de52524 ("target: Widen pc/cs_base in
cpu_get_tb_cpu_state") and 32f0c394bb ("target: Use vaddr
in gen_intermediate_code") we remove all uses of the target_ulong
type in target/alpha/. Use the meson target_common_system_arch[]
source set to prevent further uses of target-specific types.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-02-03 14:57:34 +01:00
Philippe Mathieu-Daudé 5d9e60294c target/alpha: Avoid target-specific migration headers in machine.c
machine.c doesn't use any target-specific macro defined by
the "migration/cpu.h" header. Use the minimum header required:
"migration/qemu-file-types.h" and "migration/vmstate.h", which
are not target-specific.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-02-03 14:57:34 +01:00
Philippe Mathieu-Daudé 18cae273a1 target/m68k: Inline translator_ld[uw,l,q]() calls
In preparation of removing the translator_ld[uw,l,q]() methods,
inline them for the m68k target, expanding MO_TE -> MO_BE since
this architecture is only available in big endianness.

Mechanical change using the following Coccinelle 'spatch' script:

    @@
    expression env, db, pc, do_swap;
    @@
    (
    - translator_lduw(env, db, pc)
    + translator_lduw_end(env, db, pc, MO_BE)
    |
    - translator_ldl(env, db, pc)
    + translator_ldl_end(env, db, pc, MO_BE)
    |
    - translator_ldq(env, db, pc)
    + translator_ldq_end(env, db, pc, MO_BE)
    )

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Reviewed-by: Laurent Vivier <[email protected]>
Message-ID: <[email protected]>
2026-02-03 14:57:34 +01:00
Philippe Mathieu-Daudé 39520c9eaa target/i386: Inline translator_ld[uw,l,q]() calls
In preparation of removing the translator_ld[uw,l,q]() methods,
inline them for the x86 targets, expanding MO_TE -> MO_LE since
the architecture uses little endian order.

Mechanical change using the following Coccinelle 'spatch' script:

    @@
    expression env, db, pc, do_swap;
    @@
    (
    - translator_lduw(env, db, pc)
    + translator_lduw_end(env, db, pc, MO_LE)
    |
    - translator_ldl(env, db, pc)
    + translator_ldl_end(env, db, pc, MO_LE)
    |
    - translator_ldq(env, db, pc)
    + translator_ldq_end(env, db, pc, MO_LE)
    )

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-02-03 14:57:33 +01:00
Philippe Mathieu-Daudé a31f16bdd4 target/riscv: Inline translator_ld[uw,l,q]() calls
In preparation of removing the translator_ld[uw,l,q]() methods,
inline them for the RISC-V targets, using mo_endian(ctx) -- which
we introduced in commit 504f7f304f -- instead of MO_TE.

Mechanical change using the following Coccinelle 'spatch' script:

    @@
    expression env, db, pc, do_swap;
    @@
    (
    - translator_lduw(env, db, pc)
    + translator_lduw_end(env, db, pc, mo_endian(ctx))
    |
    - translator_ldl(env, db, pc)
    + translator_ldl_end(env, db, pc, mo_endian(ctx))
    |
    - translator_ldq(env, db, pc)
    + translator_ldq_end(env, db, pc, mo_endian(ctx))
    )

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-02-03 14:57:33 +01:00
Philippe Mathieu-Daudé f7f4cd501c target/riscv: Inline cpu_ld[lq]_code() calls
In preparation of removing the cpu_ldl_code() and cpu_ldq_code()
wrappers, inline them.

Since RISC-V instructions are always stored in little-endian order
(see "Volume I: RISC-V Unprivileged ISA" document, chapter
'Instruction Encoding Spaces and Prefixes': "instruction fetch
in RISC-V is little-endian"), replace MO_TE -> MO_LE.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-02-03 14:57:33 +01:00
Philippe Mathieu-Daudé b9789d2993 target/ppc: Inline cpu_ldl_code() call in ppc_ldl_code()
In preparation of removing the cpu_ldl_code wrapper, inline it.

Get the runtime endianness with ppc_data_endian_env(), passing it
to cpu_ldl_code_mmu(). No need to swap versus qemu-system binary
anymore.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Anton Johansson <[email protected]>
Message-Id: <[email protected]>
2026-02-03 14:57:33 +01:00
Philippe Mathieu-Daudé 7ef4fee1a6 target/ppc: Check endianness at runtime in ppc_data_endian_env()
Rather a runtime endianness check via env MSR over
a build-time one.

Now CPU can change endianness at runtime.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Anton Johansson <[email protected]>
Message-Id: <[email protected]>
2026-02-03 14:57:33 +01:00
Philippe Mathieu-Daudé cf7719d302 target/ppc: Introduce ppc_env_is_little_endian() helper
Centralize endianness check on MSR via a common helper.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Anton Johansson <[email protected]>
Message-Id: <[email protected]>
2026-02-03 14:57:33 +01:00
Philippe Mathieu-Daudé 3d072f029f target/ppc: Check endianness via env in ppc_disas_set_info()
disas_set_info() shouldn't bother with env->hflags,
access env->msr directly.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Anton Johansson <[email protected]>
Message-Id: <[email protected]>
2026-02-03 14:57:33 +01:00
Philippe Mathieu-Daudé 3531dc3dd9 target/ppc: Inline need_byteswap() and replace translator_ldl_swap()
Rather than using a boolean with translator_ldl_swap(),
get the MemOp endianness with ppc_code_endian() and pass
it to translator_ldl_end().

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Anton Johansson <[email protected]>
Message-Id: <[email protected]>
2026-02-03 14:57:33 +01:00
Philippe Mathieu-Daudé 858a54e44d target/ppc: Introduce ppc_code_endian_dc() helper
Introduce the ppc_code_endian_dc() helper which returns the
MemOp endianness for the CODE path.

Use it in need_byteswap(), removing one TARGET_BIG_ENDIAN.

Note, the target MemOp endianness can be evaluated as (see
commit 5c43a750b6 "accel/tcg: Implement translator_ld*_end"):

    MO_TE ^ (do_swap * MO_BSWAP)

For PPC we use the DisasContext::le_mode field to swap the
default (big-endian) order, so to get the PPC MemOp endianness
we can directly use:

    MO_BE ^ (ctx->le_mode * MO_BSWAP)

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Anton Johansson <[email protected]>
Message-ID: <[email protected]>
2026-02-03 14:57:33 +01:00
Philippe Mathieu-Daudé 043c4e1715 target/ppc: Introduce ppc_data_endian_env() helper
Introduce ppc_data_endian_env() which returns the endian MemOp
of the data path from the vCPU env pointer. Keep it hardcoded
as MO_TE, the target built-time endianness.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Anton Johansson <[email protected]>
Message-ID: <[email protected]>
2026-02-03 14:57:33 +01:00
Philippe Mathieu-Daudé 3b24453f85 target/ppc: Expect page translation hash addresses to be aligned
The page translation hash addresses are aligned:
remove the misleading MO_UNALN flag.

Reported-by: Richard Henderson <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Anton Johansson <[email protected]>
Message-Id: <[email protected]>
2026-02-03 14:57:33 +01:00
Philippe Mathieu-Daudé 50d114e04f target/ppc: Inline cpu_ld/st_data_ra() calls in do_hash()
In preparation of removing the cpu_ld*_data_ra() and
cpu_st*_data_ra() calls, inline them. No logical change
intended.

We note the page translation hash address is expected to
be aligned, so the MO_UNALN flag is misleading. Next commit
will remove it.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Anton Johansson <[email protected]>
Message-Id: <[email protected]>
2026-02-03 14:57:33 +01:00
Philippe Mathieu-Daudé cd4b54a030 target/ppc: Inline cpu_ld/st_mmuidx_ra() calls in memory helpers
In preparation of removing the cpu_ld*_mmuidx_ra() and
cpu_st*_mmuidx_ra() calls, inline them.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Anton Johansson <[email protected]>
Message-Id: <[email protected]>
2026-02-03 14:57:33 +01:00
Philippe Mathieu-Daudé f09e80011b target/ppc: Inline cpu_ldl_data_ra() calls in ICBI helpers
Inline the cpu_ldl_data_ra() call in preparation of
removing it. Since the returned value is discarded,
don't bother to set the access endianness.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Anton Johansson <[email protected]>
Message-Id: <[email protected]>
2026-02-03 14:57:33 +01:00
Pierrick Bouvier f2ac221cc5 target-info: add target_base_ppc, target_ppc and target_ppc64
Signed-off-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Tested-by: Philippe Mathieu-Daudé <[email protected]>
Message-Id: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-02-03 14:57:33 +01:00
Michael S. Tsirkin 196ac25441 vhost-user: ancilliary -> ancillary
My dictionary says the former spelling is incorrect.

Message-ID: <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Gustavo Romero <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
2026-02-03 07:16:44 -05:00
Oliver Steffen dea1f68a5c igvm: Fill MADT IGVM parameter field on x86_64
Use the new acpi_build_madt_standalone() function to fill the MADT
parameter field.

The IGVM parameter can be consumed by Coconut SVSM [1], instead of
relying on the fw_cfg interface, which has caused problems before due to
unexpected access [2,3]. Using IGVM parameters is the default way for
Coconut SVSM across hypervisors; switching over would allow removing
specialized code paths for QEMU in Coconut.

Coconut SVSM needs to know the SMP configuration, but does not look at
any other ACPI data, nor does it interact with the PCI bus settings.
Since the MADT is static and not linked with other ACPI tables, it can
be supplied stand-alone like this.

Generating the MADT twice (during ACPI table building and IGVM processing)
seems acceptable, since there is no infrastructure to obtain the MADT
out of the ACPI table memory area.

In any case OVMF, which runs after SVSM has already been initialized,
will continue reading all ACPI tables via fw_cfg and provide fixed up
ACPI data to the OS as before without any changes.

The IGVM parameter handler is implemented for the i386 machine target
and stubbed for all others.

[1] https://github.com/coconut-svsm/svsm/pull/858
[2] https://gitlab.com/qemu-project/qemu/-/issues/2882
[3] https://github.com/coconut-svsm/svsm/issues/646

Signed-off-by: Oliver Steffen <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Gerd Hoffmann <[email protected]>
2026-02-03 08:32:33 +01:00
Oliver Steffen 81553078a1 igvm: Only build stubs if igvm is enabled
Change meson script to only include the IGVM stubs file if the IGVM
feature is enabled. It is used to handle architecture specific
differences within the IGVM backend, not to provide stubs of the backend
itself.

Signed-off-by: Oliver Steffen <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Gerd Hoffmann <[email protected]>
2026-02-03 08:32:33 +01:00
Oliver Steffen 8effe94499 igvm: Pass machine state to IGVM file processing
Pass the full MachineState to the IGVM backend during file processing,
instead of just the ConfidentialGuestSupport struct (which is a member
of the MachineState).
This replaces the cgs parameter of qigvm_process_file() with the machine
state to make it available in the IGVM processing context.

We will use it later to generate MADT data there to pass to the guest
as IGVM parameter.

Reviewed-by: Luigi Leonardi <[email protected]>
Signed-off-by: Oliver Steffen <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Gerd Hoffmann <[email protected]>
2026-02-03 08:32:33 +01:00
Oliver Steffen 5dd11338f6 igvm: Refactor qigvm_parameter_insert
Use qigvm_find_param_entry() also in qigvm_parameter_insert().
This changes behavior: Processing now stops after the first parameter
entry found. That is OK, because we expect only one matching entry
anyway.

Reviewed-by: Luigi Leonardi <[email protected]>
Signed-off-by: Oliver Steffen <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Gerd Hoffmann <[email protected]>
2026-02-03 08:32:33 +01:00
Oliver Steffen 4113ac8c41 igvm: Add common function for finding parameter entries
Move repeating code for finding the parameter entries in the IGVM
backend out of the parameter handlers into a common function.

A warning message is emitted in case a no parameter entry can be found
for a given index.

Reviewed-by: Luigi Leonardi <[email protected]>
Signed-off-by: Oliver Steffen <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Gerd Hoffmann <[email protected]>
2026-02-03 08:32:33 +01:00
Oliver Steffen 2b0cb58451 igvm: Move structs to internal header
Move QIgvm and QIgvmParameter struct definitions from the source file
into an IGVM internal header file to allow implementing architecture
specific IGVM code in other places, for example target/i386/igvm.c.

Signed-off-by: Oliver Steffen <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Gerd Hoffmann <[email protected]>
2026-02-03 08:32:33 +01:00
Oliver Steffen 403b7db067 hw/acpi: Add standalone function to build MADT
Add a function called `acpi_build_madt_standalone()` that builds a MADT
without the rest of the ACPI table structure.

Signed-off-by: Oliver Steffen <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Gerd Hoffmann <[email protected]>
2026-02-03 08:32:33 +01:00
Oliver Steffen ef7a0dee80 hw/acpi: Make BIOS linker optional
Make the BIOS linker optional in acpi_table_end() and calculate the ACPI
table checksum directly if no linker is provided.

This makes it possible to call for example
acpi_build_madt() from outside the ACPI table builder context.

Signed-off-by: Oliver Steffen <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Gerd Hoffmann <[email protected]>
2026-02-03 08:32:33 +01:00
Oliver Steffen 8e862b7246 hw/acpi: Make acpi_checksum() public
Make the ACPI table checksum calculation function (in core.c) public so
it can be reused in other parts of the ACPI code.

Signed-off-by: Oliver Steffen <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Gerd Hoffmann <[email protected]>
2026-02-03 08:32:33 +01:00
Gerd Hoffmann d5266c4740 igvm: move igvm file processing to reset callbacks
Move igvm file processing from machine init to reset callbacks.  With
that the igvm file is properly re-loaded on reset.  Also the loading
happens later in the init process now.  This will simplify future
support for some IGVM parameters which depend on initialization steps
which happen after machine init.

Reviewed-by: Ani Sinha <[email protected]>
Reviewed-by: Stefano Garzarella <[email protected]>
Signed-off-by: Gerd Hoffmann <[email protected]>
Message-ID: <[email protected]>
2026-02-03 08:32:33 +01:00
Gerd Hoffmann 9d0880cf39 igvm: add trace points for igvm file loading and processing
Reviewed-by: Ani Sinha <[email protected]>
Reviewed-by: Stefano Garzarella <[email protected]>
Reviewed-by: Luigi Leonardi <[email protected]>
Signed-off-by: Gerd Hoffmann <[email protected]>
Message-ID: <[email protected]>
2026-02-03 08:32:33 +01:00
Gerd Hoffmann 74d800a098 igvm: move file load to complete callback
Add UserCreatableClass->complete callback function for igvm-cfg object.

Move file loading and parsing of the igvm file from the process function
to the new complete() callback function.  Keep the igvm file loaded
after processing, release it in finalize() instead, so we parse it only
once.

Reviewed-by: Ani Sinha <[email protected]>
Reviewed-by: Stefano Garzarella <[email protected]>
Signed-off-by: Gerd Hoffmann <[email protected]>
Message-ID: <[email protected]>
2026-02-03 08:32:33 +01:00
Gerd Hoffmann 0a158a4148 igvm: make igvm-cfg object resettable
Add TYPE_RESETTABLE_INTERFACE to interfaces.  Register callbacks for the
reset phases.  Add trace points for logging and debugging.  No
functional change, that will come in followup patches.

Reviewed-by: Ani Sinha <[email protected]>
Reviewed-by: Stefano Garzarella <[email protected]>
Signed-off-by: Gerd Hoffmann <[email protected]>
Message-ID: <[email protected]>
2026-02-03 08:32:33 +01:00
Gerd Hoffmann acd47d9928 igvm: reorganize headers
Add a new igvm-internal.h header file.  Structs and declarations which
depend on the igvm library header go into that file.

Also declare IgvmCfg in typedefs.h, so the type can be used without
including igvm header files.

Reviewed-by: Stefano Garzarella <[email protected]>
Signed-off-by: Gerd Hoffmann <[email protected]>
Message-ID: <[email protected]>
2026-02-03 08:32:33 +01:00
Gerd Hoffmann 46dee71a94 hw/uefi: fix size negotiation
Payload size is the variable request size, not the total buffer size.
Take that into account and subtract header sizes.

Fixes: db1ecfb473 ("hw/uefi: add var-service-vars.c")
Signed-off-by: Gerd Hoffmann <[email protected]>
Message-ID: <[email protected]>
2026-02-03 08:32:33 +01:00
Gerd Hoffmann 9317274c01 hw/uefi: skip time check for append-write updates.
Only execute the time time check if the EFI_VARIABLE_APPEND_WRITE bit is
clear.  For append-write updates the timestamp verification is not
needed.

See uefi spec, section "8.2.6 Using the EFI_VARIABLE_AUTHENTICATION_2
descriptor"

Fixes: db1ecfb473 ("hw/uefi: add var-service-vars.c")
Signed-off-by: Gerd Hoffmann <[email protected]>
Message-ID: <[email protected]>
2026-02-03 08:32:33 +01:00
Jim MacArthur 60cb02a5aa docs/system/igvm.rst: Update external links
* Fixes link to AMD64 Architecture Programmer's
Manual and bumps version to 3.43.
* Updates link to buildigvm to new home on GitLab.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3247
Signed-off-by: Jim MacArthur <[email protected]>
Reviewed-by: Luigi Leonardi <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Gerd Hoffmann <[email protected]>
2026-02-03 08:32:33 +01:00
Richard Henderson b377abc220 Merge tag 'hw-misc-20260202' of https://github.com/philmd/qemu into staging
Misc HW & memory API patches

- Add unit test for qemu_hexdump()
- Remove legacy native endianness API uses on the Alpha target
- Remove unused memory_region_init_rom_device_nomigrate()
- Fix use-after-free in NvmeNamespace "bootindex" suffix
- Correct documentation of SCSI Rotation Rate field
- Make iotlb_to_section() work with non-CPU AddressSpaces
- Reduce few monitor target-specific methods

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCAAdFiEE+qvnXhKRciHc/Wuy4+MsLN6twN4FAmmBFLoACgkQ4+MsLN6t
# wN4jrhAAjSb6hqXTTGWqVdyovdjCWmUOa3b8CZvTVycI2xTRA2HDqawnZSZrYwJS
# Wz20vyfylaoVI9OUibQOYBrpuZw1TBI4G7IeLBgdtzVW6oygIiHO1IlhtEENJtm7
# IXOMoU59ToQ85JWUZN6dwd6mbhBkR5roPJzJseyh/D5gf3t7/BE+jMXyAPNgls2A
# jnrgxw/1f1/DnIfAwbKaQfPuTVGerFmuicLhZsIrE9KFW2z8+acEPckAQKugsUqO
# vRrNz4m5ekNIijQfQwgU5XMhLDmiOfh0lRruecWOmCham3IKUaQ4YngGiArM8Q/p
# I9zcejrISWqlEYteu65OvB0ZOStEDGuCCu+sCDdvvFLTTfzkAEyyAKf4+rLdYS3L
# AWk1pm5YRQUb62VdNnFYXNVatDODixOSj2icoj4ojud2J9BsdHgvf7qPJ9IMgp2a
# eGnLj/F/38OUKRkj6kzzIUf5t/g9ZmC+JsdLcW1EleQLGiv4+yXqiH7c7swalXK5
# dZCjIrr92/iiemx9/kIi6oxkjlibzhDm9fF0NLoHhMOs9YGarbJx+J1YjRfQSnvh
# MehsqLV/D8KQvhy4VLsrEIPEx53g38SnXeHKBmyBXvZKeD2aqvzfaSilgHbrmFpu
# F6fD8FASkS+QVK0Fo+zOU7Zq3wuMebiDD7ioiE1JO8yg3KFS8jQ=
# =djFg
# -----END PGP SIGNATURE-----
# gpg: Signature made Tue 03 Feb 2026 07:18:50 AM AEST
# gpg:                using RSA key FAABE75E12917221DCFD6BB2E3E32C2CDEADC0DE
# gpg: Good signature from "Philippe Mathieu-Daudé (F4BUG) <[email protected]>" [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: FAAB E75E 1291 7221 DCFD  6BB2 E3E3 2C2C DEAD C0DE

* tag 'hw-misc-20260202' of https://github.com/philmd/qemu:
  monitor: Reduce target-specific methods
  monitor: Add hmp_cmds_for_target() helper
  monitor: Reduce target-specific declarations
  target/i386: Include missing 'svm.h' header in 'sev.h'
  system/physmem: Remove the assertion of page-aligned section number
  accel/tcg: Fix iotlb_to_section() for different AddressSpace
  accel/tcg: Send the CPUTLBEntryFull struct into io_prepare()
  hw/ide, scsi-disk: Fix typo on the rotation_rate documentation
  hw/nvme: Fix bootindex suffix use-after-free
  memory: Add internal memory_region_set_ops helper function
  memory: Remove memory_region_init_rom_device_nomigrate()
  target/alpha: Replace legacy ld_phys() -> address_space_ld()
  configs/targets: Forbid Alpha to use legacy native endianness APIs
  target/alpha: Inline translator_ldl()
  target/alpha: Use explicit little-endian LD/ST API
  tests/unit: add unit test for qemu_hexdump()

Signed-off-by: Richard Henderson <[email protected]>
2026-02-03 07:52:04 +10:00
Philippe Mathieu-Daudé d8316b64df monitor: Reduce target-specific methods
The following methods don't use target-specific code anymore:
- hmp_compare_cmd()
- monitor_register_hmp()
- monitor_register_hmp_info_hrt()
Move them to hmp.c which is target-agnostic, being built once.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Dr. David Alan Gilbert <[email protected]>
Message-Id: <[email protected]>
2026-02-02 22:14:51 +01:00
Philippe Mathieu-Daudé f863b32569 monitor: Add hmp_cmds_for_target() helper
HMPCommand arrays are filled with target-specific
commands, so defined in a target-specific unit.
Introduce the hmp_cmds_for_target() to allow
target-agnostic code to access the arrays.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Dr. David Alan Gilbert <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Message-Id: <[email protected]>
2026-02-02 22:14:51 +01:00
Philippe Mathieu-Daudé a9edda7250 monitor: Reduce target-specific declarations
Some declarations do not depend on target-specific types,
move them out of "monitor/hmp-target.h" to "monitor/hmp.h".

Commit 409e9f7131 ("mos6522: add "info via" HMP command
for debugging") declared hmp_info_via() is declared twice.
Remove the one in "hw/misc/mos6522.h" otherwise we get:

  In file included from ../hw/misc/mos6522.c:33:
  include/monitor/hmp.h:43:6: error: redundant redeclaration of 'hmp_info_via' [-Werror=redundant-decls]
     43 | void hmp_info_via(Monitor *mon, const QDict *qdict);
        |      ^~~~~~~~~~~~
  In file included from ../hw/misc/mos6522.c:29:
  include/hw/misc/mos6522.h:175:6: note: previous declaration of 'hmp_info_via' with type 'void(Monitor *, const QDict *)'
    175 | void hmp_info_via(Monitor *mon, const QDict *qdict);
        |      ^~~~~~~~~~~~

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-Id: <[email protected]>
2026-02-02 22:14:51 +01:00
Philippe Mathieu-Daudé a91b167cea target/i386: Include missing 'svm.h' header in 'sev.h'
"target/i386/sev.h" uses the vmcb_seg structure type, which
is defined in "target/i386/svm.h". Current builds succeed
because the files including "target/i386/sev.h" also include
"monitor/hmp-target.h", itself including "cpu.h" and finally
"target/i386/svm.h".

Include the latter, otherwise removing "cpu.h" from
"monitor/hmp-target.h" triggers:

  ../target/i386/sev.h:62:21: error: field has incomplete type 'struct vmcb_seg'
     62 |     struct vmcb_seg es;
        |                     ^

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Zhao Liu <[email protected]>
Message-Id: <[email protected]>
2026-02-02 22:14:51 +01:00
Jim Shu 6e3ec10610 system/physmem: Remove the assertion of page-aligned section number
We don't need to OR the physical section number anymore since we now
directly have a pointer on the memory section.

Signed-off-by: Jim Shu <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Message-ID: <[email protected]>
[PMD: Reworded description per Pierrick's comment]
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-02-02 22:11:49 +01:00
Jim Shu 854cd16e31 accel/tcg: Fix iotlb_to_section() for different AddressSpace
'CPUTLBEntryFull.xlat_section' stores section_index in last 12 bits to
find the correct section when CPU access the IO region over the IOTLB.
However, section_index is only unique inside single AddressSpace. If
address space translation is over IOMMUMemoryRegion, it could return
section from other AddressSpace. 'iotlb_to_section()' API only finds the
sections from CPU's AddressSpace so that it couldn't find section in
other AddressSpace. Thus, using 'iotlb_to_section()' API will find the
wrong section and QEMU will have wrong load/store access.

To fix this bug of iotlb_to_section(), store complete MemoryRegionSection
pointer in CPUTLBEntryFull to replace the section_index in xlat_section.
Rename 'xlat_section' to 'xlat' as we remove last 12 bits section_index
inside. Also, since we directly use section pointer in the
CPUTLBEntryFull (full->section), we can remove the unused functions:
iotlb_to_section(), memory_region_section_get_iotlb().

This bug occurs only when
(1) IOMMUMemoryRegion is in the path of CPU access.
(2) IOMMUMemoryRegion returns different target_as and the section is in
the IO region.

Common IOMMU devices don't have this issue since they are only in the
path of DMA access. Currently, the bug only occurs when ARM MPC device
(hw/misc/tz-mpc.c) returns 'blocked_io_as' to emulate blocked access
handling. Upcoming RISC-V wgChecker [1] and IOPMP [2] devices are also
affected by this bug.

[1] RISC-V WG:
https://patchew.org/QEMU/[email protected]/
[2] RISC-V IOPMP:
https://patchew.org/QEMU/[email protected]/

Signed-off-by: Jim Shu <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Tested-by: Mark Burton <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-02-02 16:43:38 +01:00
Jim Shu 94c6e9cf04 accel/tcg: Send the CPUTLBEntryFull struct into io_prepare()
To let io_prepare() function use the multiple members in
CPUTLBEntryFull struct, send the full struct instead of 'xlat_section'
member as the argument.

It is the preliminary patch of next commit.

Signed-off-by: Jim Shu <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Tested-by: Mark Burton <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-02-02 16:43:38 +01:00
Alberto Garcia 7652e5556f hw/ide, scsi-disk: Fix typo on the rotation_rate documentation
Correct values according to the Medium Rotation Rate field from the
Block Device Characteristics VPD page (B1h) of the SCSI specification.

Signed-off-by: Alberto Garcia <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-02-02 16:43:38 +01:00
Akihiko Odaki eda9baa17a hw/nvme: Fix bootindex suffix use-after-free
The bootindex suffix can be used as long as the property is alive.

Signed-off-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-02-02 16:43:38 +01:00
BALATON Zoltan 5cb466d7ca memory: Add internal memory_region_set_ops helper function
This is a common operation used at multiple places, add a helper
function for it.

Signed-off-by: BALATON Zoltan <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <25045c95c083e31c6773521ecfe41900738b7bb5.1770042013.git.balaton@eik.bme.hu>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-02-02 16:43:38 +01:00
BALATON Zoltan 5cf3908f70 memory: Remove memory_region_init_rom_device_nomigrate()
This function is not used outside of memory_region_init_rom_device()
which is its only caller. Inline it there and remove it.

Signed-off-by: BALATON Zoltan <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <e6f973ff3c243fe1780bf01c3e67c9e019b08fa9.1770042013.git.balaton@eik.bme.hu>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-02-02 16:43:38 +01:00
Philippe Mathieu-Daudé 59ac89211b target/alpha: Replace legacy ld_phys() -> address_space_ld()
Prefer the address_space_ld/st API over the legacy ld_phys()
because it allow checking for bus access fault.

Since we removed the last legacy uses of the legacy ldst_phys()
API, set the TARGET_NOT_USING_LEGACY_LDST_PHYS_API variable to
hide the legacy API to alpha binaries, avoiding further API uses
to creep in.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <[email protected]>
2026-02-02 12:34:14 +01:00
Philippe Mathieu-Daudé fd2b312050 configs/targets: Forbid Alpha to use legacy native endianness APIs
All Alpha-related binaries are buildable without a single use
of the legacy "native endian" API. Unset the transitional
TARGET_USE_LEGACY_NATIVE_ENDIAN_API definition to forbid
further uses of the legacy API.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <[email protected]>
2026-02-02 12:34:14 +01:00
Philippe Mathieu-Daudé fd8e27d2dc target/alpha: Inline translator_ldl()
translator_ldl() is defined in "exec/translator.h" as:

  198 static inline uint32_t
  199 translator_ldl(CPUArchState *env, DisasContextBase *db, vaddr pc)
  200 {
  201     return translator_ldl_end(env, db, pc, MO_TE);
  202 }

Directly use the inlined form, expanding MO_TE -> MO_LE
since Alpha use little-endian order.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <[email protected]>
2026-02-02 12:34:14 +01:00
Philippe Mathieu-Daudé 954072d255 target/alpha: Use explicit little-endian LD/ST API
The Alpha architecture uses little endianness. Directly
use the little-endian LD/ST API.

Mechanical change running:

  $ for a in uw w l q; do \
      sed -i -e "s/ld${a}_p(/ld${a}_le_p(/" \
        $(git grep -wlE '(ld|st)u?[wlq]_p' target/alpha/);
    done

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Manos Pitsidianakis <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <[email protected]>
2026-02-02 12:34:14 +01:00
Vladimir Sementsov-Ogievskiy 7404d6852d tests/unit: add unit test for qemu_hexdump()
Test that the fix in commit 20aa05edc2 ("util/hexdump: fix
QEMU_HEXDUMP_LINE_WIDTH logic") make sense.

To not break compilation when we build without 'block', move
hexdump.c out of "if have_block" in meson.build.

Signed-off-by: Vladimir Sementsov-Ogievskiy <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-Id: <[email protected]>
2026-02-02 12:34:14 +01:00
John Snow 587f4a1805 python: fix msys64 wheel directory specification
In python3.14, fixes were made to the file URI parsing [1] such that
file URIs that used to work but were technically out of spec are now
broken.

As a result, our msys2 GitLab CI tests began failing.

Stop using "file://" URI links in favor of simple paths (Thanks pbo) to
fix parsing errors under Python 3.14 and fix the msys2 GitLab CI tests.

[1] https://docs.python.org/3/whatsnew/3.14.html#urllib

Reported-by: Pierrick Bouvier <[email protected]>
Suggested-by: Pierrick Bouvier <[email protected]>
Signed-off-by: John Snow <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Tested-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-02-02 16:46:40 +10:00
Richard Henderson 4bf4976e8e Merge tag 'pull-ufs-20260202' of https://gitlab.com/jeuk20.kim/qemu into staging
UFS MCQ fixes and tests series.

Changes in v2:
- Fix additional endianness-related bugs.

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCgAdFiEEUBfYMVl8eKPZB+73EuIgTA5dtgIFAmmAOCkACgkQEuIgTA5d
# tgIcMA/+OLU4Cq1AWpucFOZskYjvMfxubUUt+gl+TYsBQZTk+0T4UN4Is5vZo1Th
# xi4csP3lCP8Q/Y8TXJ+sBQxjiWX/xkYee7mvqh68wXouLYtkPs2ll9ICqKnBQXtl
# vxo+ea4XLNxSfCd6Qw8grxTgWtdNKdh0Rk2F8Tdga1WHIz55LQR0WqpYAeodVumq
# LELB6ViFdrXF/4kUkN/iKSUZMBUBIubzVqzT2dP2ydP2V6+DZIl8iif++cPCD2LB
# +IG+FEfweiBUUstZC3bUc9H+Fbo0qlsQbmlmNJJRPtR1LW7oYIhBg+KEB8hyEjPd
# IhX27UJP1fxYE72Kp/Z+WPkwOCih8bh5ad6+to6t8bQySWrTDaFaQa4tMruP6kC8
# eCgatct8TfykCKGbcgPqZX9UC41IreoeoJu8/8O0tNmAdQtET8ZEO0H8TkHMBFSS
# AQ+1ape930go1bilqYB47ayEO43H5EdupV7xECyhAHYrzzHepxSJ++E+cS/b+Rg4
# in/72wVATORz6xHlWqUbKGRgBTC2rLQFjcSeEYXXWK8Vucfh480CBUfcDcXgSyBQ
# 7u7J1600q4N3k6gLBYVfQeFcZ2/iEOco3qB+Cnf8QKLed6AGaVxrOx4acRgp0Ekd
# zZtdRxwZh4K55QZ4vu53hFCOBh1rvJoDAn8krjBLdOI8Z354Xk4=
# =dXrP
# -----END PGP SIGNATURE-----
# gpg: Signature made Mon 02 Feb 2026 03:37:45 PM AEST
# gpg:                using RSA key 5017D831597C78A3D907EEF712E2204C0E5DB602
# gpg: Good signature from "Jeuk Kim <[email protected]>" [unknown]
# gpg:                 aka "Jeuk Kim <[email protected]>" [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: 5017 D831 597C 78A3 D907  EEF7 12E2 204C 0E5D B602

* tag 'pull-ufs-20260202' of https://gitlab.com/jeuk20.kim/qemu:
  tests/qtest/ufs-test: Add test for mcq completion queue wraparound
  hw/ufs: Fix mcq completion queue wraparound
  hw/ufs: fix CQE endianness and UPIU length
  hw/ufs: Ensure DBC of PRDT uses only lower 18 bits

Signed-off-by: Richard Henderson <[email protected]>
2026-02-02 16:46:19 +10:00
Ilia Levi 94e72135d4 tests/qtest/ufs-test: Add test for mcq completion queue wraparound
Added a test that sends 32 NOP Out commands asynchronously. Since the CQ
has 31 entries by default, this tests the scenario where CQ processing
needs to wait for space to become available.

Additionally, added two minor fixes to existing tests:
* advance CQ head after reading from CQ
* initialize command descriptor slots bitmap in ufs_init()

Signed-off-by: Ilia Levi <[email protected]>
Acked-by: Fabiano Rosas <[email protected]>
Reviewed-by: Jeuk Kim <[email protected]>
Signed-off-by: Jeuk Kim <[email protected]>
2026-02-02 14:33:46 +09:00
Ilia Levi f78762a3cc hw/ufs: Fix mcq completion queue wraparound
Currently, ufs_mcq_process_cq() writes to the CQ without checking whether
there is available space. This can cause CQ entries to be discarded and
overwritten. The solution is to stop writing when CQ is full and exert
backpressure on the affected SQs. This is similar to how NVMe CQs operate.

Signed-off-by: Ilia Levi <[email protected]>
Reviewed-by: Jeuk Kim <[email protected]>
Signed-off-by: Jeuk Kim <[email protected]>
2026-02-02 14:33:46 +09:00
Jeuk Kim ed621cc8e2 hw/ufs: fix CQE endianness and UPIU length
Round-trip UTRD fields through cpu_to_le/ le_to_cpu when building MCQ CQEs to
keep BE hosts correct. Also avoid double BE conversion of response
data_segment_length and document the LE round-trip.

Signed-off-by: Jeuk Kim <[email protected]>
2026-02-02 14:33:46 +09:00
Jeuk Kim 289e6a3edf hw/ufs: Ensure DBC of PRDT uses only lower 18 bits
The UFS spec defines the PRDT data byte count as an 18-bit field. This
commit masks the value to the lower 18 bits to prevent incorrect
transfer lengths and ensure compliance.

Signed-off-by: Jeuk Kim <[email protected]>
2026-02-02 14:33:46 +09:00
Richard Henderson d21a442a5a Merge tag 'pull-target-arm-20260129' of https://gitlab.com/pm215/qemu into staging
target-arm queue:
 * Support SMMUv3 acceleration
 * A few other minor cleanups and fixes

# -----BEGIN PGP SIGNATURE-----
#
# iQJNBAABCAA3FiEE4aXFk81BneKOgxXPPCUl7RQ2DN4FAml7hesZHHBldGVyLm1h
# eWRlbGxAbGluYXJvLm9yZwAKCRA8JSXtFDYM3mFyEACUDY0XTLaqkCLQyeJc1OAg
# +oH6sRblPCJpBT3Y8eFUiDjH/2amSdxADxNmE7B/+ltD2InXJ6lHfPsA+F7QiaXD
# 7D0vKQ9LlQiv2KXwH75xEqTkG1W0m/9OLhnuyygiBIA+hjvCU5wuCmJ3AIAZOdV1
# haiW5Dg4++nxjyFNJOdC7IVCb8xIMO7rlITG4aAFhl8VOT9Orx/kJYvBCnk2flFP
# +X8JQuI3kn5ew4iTahsvAnsxTSn403u/A7j1PT8I4cODnRoV7rNF4L+LmtROHkIs
# Fkqz5LI7yN8IQeh8/kDxXr25tZnwsQ2xrBLcZsyMelVDN4fXj2+HDn+ohCNV+xIh
# 65mlQkPZ+uos4PBLgXRmuRHfvt4EBYBwAx/iRk4D+NPmHbNGlznKBRiy/7/HpFsr
# JH3XYJBW6iqmqbvfCfGJ83aiSfTkRYE/k/w8JPBO9ko8nmuqMwlCysHfBfmr/zU3
# 2MHzx+CcQ6kWEh7bi3R1r/r0LPtzT9Y4xsZKKhGyjKmwmA7eNbVCbpzbTmxWICcP
# donH/9ecAX+il7/hZOZliG7050HeSPuZC+pM7BkJlLuiKDpfwn/hBeIPJu4JGna7
# N4qRls6rO3IOchzQk9eFewie1575xUV/BDUlNsXE2ZdN0n8XgSHd9lBXzlLeOoV+
# cjg2O1Iwi+53Nb4G5Ap74Q==
# =JEwH
# -----END PGP SIGNATURE-----
# gpg: Signature made Fri 30 Jan 2026 03:08:11 AM AEDT
# gpg:                using RSA key E1A5C593CD419DE28E8315CF3C2525ED14360CDE
# gpg:                issuer "[email protected]"
# gpg: Good signature from "Peter Maydell <[email protected]>" [unknown]
# gpg:                 aka "Peter Maydell <[email protected]>" [unknown]
# gpg:                 aka "Peter Maydell <[email protected]>" [unknown]
# gpg:                 aka "Peter Maydell <[email protected]>" [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: E1A5 C593 CD41 9DE2 8E83  15CF 3C25 25ED 1436 0CDE

* tag 'pull-target-arm-20260129' of https://gitlab.com/pm215/qemu: (43 commits)
  arm: add DCZID_EL0 to idregs array
  arm: add {get,set}_dczid_bs helpers
  docs/system: update FEAT_BBML[12] references
  MAINTAINERS: add emulation.rst to ARM TCG CPUs
  target/arm/hvf: Sync CNTV_CTL_EL0 & CNTV_CVAL_EL0
  target/arm/hvf: Move hvf_sysreg_[read, write]_cp() functions around
  hw/arm/smmuv3-accel: Make SubstreamID support configurable
  hw/vfio/pci: Synthesize PASID capability for vfio-pci devices
  hw/pci: Factor out common PASID capability initialization
  hw/pci: Add helper to insert PCIe extended capability at a fixed offset
  backends/iommufd: Add get_pasid_info() callback
  backends/iommufd: Retrieve PASID width from iommufd_backend_get_device_info()
  hw/arm/smmuv3-accel: Add property to specify OAS bits
  hw/arm/smmuv3-accel: Add support for ATS
  hw/arm/smmuv3-accel: Add a property to specify RIL support
  hw/arm/smmuv3: Add accel property for SMMUv3 device
  hw/arm/smmuv3: Block migration when accel is enabled
  tests/qtest/bios-tables-test: Update IORT blobs after revision upgrade
  hw/arm/virt-acpi-build: Add IORT RMR regions to handle MSI nested binding
  tests/qtest/bios-tables-test: Prepare for IORT revison upgrade
  ...

Signed-off-by: Richard Henderson <[email protected]>
2026-02-02 15:04:44 +11:00
Richard Henderson b6bba79e97 Merge tag 'pull-11.0-testing-fixes-300126-1' of https://gitlab.com/stsquad/qemu into staging
testing updates (sbsa-ref, docker)

  - restore weekly container job
  - move assets for sbsa-ref tests

# -----BEGIN PGP SIGNATURE-----
#
# iQEzBAABCgAdFiEEZoWumedRZ7yvyN81+9DbCVqeKkQFAml8t/AACgkQ+9DbCVqe
# KkS5qAf/QBhD/1MDM9Ecry3IuWf6xFaxQIndwPD0C+32ijmTLjpve6w2/zDx7HRY
# a1Eu2+kOziWUvNrRHNwWOQjPZP5kJnXzs9KK7EEQiBaPJJgJpLTTAmmw6bafS2Pu
# Xxxxr5sm0ePFNBLvURYvS7HPq9BQe0QCBxyAmtVyDsDMgfVjp0+PfX/rAop5C9r/
# 9KHwj4PdCB1GmrOA9WUIHm+slQsmdr8fEBCfEwQSEoPRz4vCg0knterz/tu845U1
# 3/EqNPgEo8KQkcR3GhLx6EQsvNYciQo3iEXVaz8A8PkyPSzQUNal+lSrSqAuHN3Z
# Dvss2hDCtJlhdAZHo4X2sXFHHQmCuQ==
# =Grpn
# -----END PGP SIGNATURE-----
# gpg: Signature made Sat 31 Jan 2026 12:53:52 AM AEDT
# gpg:                using RSA key 6685AE99E75167BCAFC8DF35FBD0DB095A9E2A44
# gpg: Good signature from "Alex Bennée (Master Work Key) <[email protected]>" [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.0-testing-fixes-300126-1' of https://gitlab.com/stsquad/qemu:
  tests/functional: migrate sbsa_ref test images
  tests/docker: rename wasm cross container

Signed-off-by: Richard Henderson <[email protected]>
2026-02-02 15:04:18 +11:00
Alex Bennée d9ca273f8f tests/functional: migrate sbsa_ref test images
As the builds in codelinaro.org are going away migrate the binaries to
share.linaro.org. As the hotlinks don't encode the filename we need to
explicitly tell uncompress how to handle the files.

Tested-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alex Bennée <[email protected]>
2026-01-30 13:52:59 +00:00
Alex Bennée 792d94406a tests/docker: rename wasm cross container
Now we are 64 bit only there is no need to keep the generic name. This
also fixes a check failure in the weekly container build which was
checking containers based on the expansion of DOCKER_IMAGES which is
based of the dockerfile names.

Remove the DOCKERFILE bits that were added to handle multiple
containers from the same dockerfile.

Fixes: 4203ea0247 (gitlab-ci: Add build tests for wasm64)
Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Daniel P. Berrangé <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alex Bennée <[email protected]>
2026-01-30 13:52:48 +00:00
Richard Henderson a8e6997ef8 Merge tag 'pr-plugins-20260129' of https://gitlab.com/pbo-linaro/qemu into staging
Changes:
- contrib/plugins/hotblocks: Minor bug fixes and add limit argument (Alex Bradbury <[email protected]>)
- linux-user: introduce syscall-filter plugin API (Ziyang Zhang <[email protected]>)
- plugins: return bool from register r/w API (Florian Hofhammer <[email protected]>)
- plugins: enable C++ plugins (Pierrick Bouvier <[email protected]>)
- plugins: reduce source conflicts in plugins list (Pierrick Bouvier <[email protected]>)

# -----BEGIN PGP SIGNATURE-----
#
# iQGzBAABCgAdFiEEZrmU7KFPfy5auggff5BUDQoc0A8FAml7mhoACgkQf5BUDQoc
# 0A/L+gv/VGFWxKwZHu2S6rmIc8BXlShTDj9drJDJjcaRuLi+mXe6fjhEXL7UjIKf
# 4Zq+VtoBRdakuefhw4xcrCSGNScRdG64h/qz9z2mCzZVtlTJDlhoL7QV8TXxciLV
# 1MAQbiY7AXD66Geu9XrXQ1EOV3McdjMaf6DiJ0LcUUxIn9PYxSpuhpfBa89kyGVH
# qDVlel2rvj6DUtdciHAisy1sElDO1Lc3T4EoM74k3zX6XJLs3anZ3PlV1Gg2UL9e
# ORzh2dgckXXxFbFcrRUaS6baDVzAWddMfNWhMljIqdypI4VxWJfkYnEO4RPhqXBO
# saglpNjlZeFXfymBV4ZgjKjoAB0CRWDZs8CZ5i74jvO5NuoDyrMn8kOD2NlMTUi5
# g4QOyXXfRhETqMLeeuhJFcWAredBl23LNxKIRJeYaFnWBszx1QnYTKB2qxxIW0RC
# /H861Wn4scDh2hA0FT+78mpDNKBZf24oUdazMDb2qZUkpOKlf17jibfewACOBR13
# nNProazp
# =qS+z
# -----END PGP SIGNATURE-----
# gpg: Signature made Fri 30 Jan 2026 04:34:18 AM AEDT
# gpg:                using RSA key 66B994ECA14F7F2E5ABA081F7F90540D0A1CD00F
# gpg: Good signature from "Pierrick Bouvier <[email protected]>" [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: 66B9 94EC A14F 7F2E 5ABA  081F 7F90 540D 0A1C D00F

* tag 'pr-plugins-20260129' of https://gitlab.com/pbo-linaro/qemu: (21 commits)
  plugins: reduce source conflicts in plugins list
  contrib/plugins: add empty cpp plugin
  meson: update C++ standard to C++23
  qga/vss-win32: fix clang warning with C++20
  meson: enable cpp (optionally) for plugins
  meson: fix supported compiler arguments in other languages than C
  plugins: move qemu-plugin.h to include/plugins/
  tests/tcg/plugins/mem.c: remove dependency on qemu headers
  plugins: define plugin API symbols as extern "C" when compiling in C++
  plugins: use complete filename for defining plugins sources
  plugins: factorize plugin dependencies and library details
  plugins: move win32_linker.c file to plugins directory
  plugins: return bool from register r/w API
  tcg tests: add a test to verify the syscall filter plugin API
  linux-user: add plugin API to filter syscalls
  linux-user: move user/syscall-trace.h to linux-user/syscall.c
  contrib/plugins/hotblocks: Allow limit to be set as a command line argument
  docs/about/emulation: Add documentation for hotblocks plugin arguments
  contrib/plugins/hotblocks: Print uint64_t with PRIu64 rather than PRId64
  contrib/plugins/hotblocks: Fix off by one error in iteration of sorted blocks
  ...

Signed-off-by: Richard Henderson <[email protected]>
2026-01-30 08:03:22 +11:00
Pierrick Bouvier bed25f00d3 plugins: reduce source conflicts in plugins list
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Pierrick Bouvier <[email protected]>
2026-01-29 09:34:14 -08:00
Pierrick Bouvier 20fc9c3f8b contrib/plugins: add empty cpp plugin
This plugin makes sure we can compile in C++ while including qemu-plugin
header. It includes all C++ standard headers, up to C++23 standard,
minus the ones that are missing in the oldest environments we need to
build for.

Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Manos Pitsidianakis <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Pierrick Bouvier <[email protected]>
2026-01-29 09:34:14 -08:00
Pierrick Bouvier a6abd84425 meson: update C++ standard to C++23
C++ is evolving faster than C, so it's useful to enable new standards,
especially for standard library.
Update to most recent standard available in our build environments.

Reviewed-by: Manos Pitsidianakis <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Pierrick Bouvier <[email protected]>
2026-01-29 09:34:14 -08:00
Pierrick Bouvier 79762f55ef qga/vss-win32: fix clang warning with C++20
C++20 deprecated such constructs.

../qga/vss-win32/requester.cpp:380:32: error: bitwise operation between different enumeration types ('_VSS_SNAPSHOT_CONTEXT' and '_VSS_VOLUME_SNAPSHOT_ATTRIBUTES') is deprecated [-Werror,-Wdeprecated-enum-enum-conversion]
  380 |     ctx = VSS_CTX_APP_ROLLBACK | VSS_VOLSNAP_ATTR_TRANSPORTABLE |

This is a false positive, since VSS_CTX_APP_ROLLBACK is not a value
defined in _VSS_VOLUME_SNAPSHOT_ATTRIBUTES enum.

Reviewed-by: Manos Pitsidianakis <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Pierrick Bouvier <[email protected]>
2026-01-29 09:34:14 -08:00
Pierrick Bouvier f3b3bfbe3f meson: enable cpp (optionally) for plugins
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Manos Pitsidianakis <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Pierrick Bouvier <[email protected]>
2026-01-29 09:34:14 -08:00
Pierrick Bouvier 329803c111 meson: fix supported compiler arguments in other languages than C
qemu_common_flags are only checked for c compiler, even though they
are applied to c++ and objc. This is a problem when C compiler is gcc,
and C++ compiler is clang, creating a possible mismatch.

One concrete example is option -fzero-call-used-regs=used-gpr with
ubuntu2204 container, which is supported by gcc, but not by clang, thus
leading to a failure when compiling a C++ TCG plugin.

Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Manos Pitsidianakis <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Pierrick Bouvier <[email protected]>
2026-01-29 09:34:14 -08:00
Pierrick Bouvier cab15547f1 plugins: move qemu-plugin.h to include/plugins/
This change has two benefits:
- ensure plugins can't include anything else from QEMU than plugins API
- when compiling a C++ module, solves the header conflict with iostream
  header that includes transitively the wrong ctype.h, which already
  exists in include/qemu.

By Hyrum's law, there was already one usage of other headers with mem
plugin, which has been eliminated in previous commit.

Reviewed-by: Richard Henderson <[email protected]>
Reviewed-by: Manos Pitsidianakis <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Pierrick Bouvier <[email protected]>
2026-01-29 09:34:14 -08:00
Pierrick Bouvier eb3f69cac6 tests/tcg/plugins/mem.c: remove dependency on qemu headers
This plugin uses endianness conversion primitives from QEMU headers. As
next commit will strongly isolate plugins code from those headers, those
primitives can't be used anymore.

glib.h provides such primitives:
https://docs.gtk.org/glib/conversion-macros.html#byte-order-conversion

Reviewed-by: Manos Pitsidianakis <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Pierrick Bouvier <[email protected]>
2026-01-29 09:34:14 -08:00
Pierrick Bouvier 1f2c0bd2ff plugins: define plugin API symbols as extern "C" when compiling in C++
Reviewed-by: Richard Henderson <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Pierrick Bouvier <[email protected]>
2026-01-29 09:34:14 -08:00
Pierrick Bouvier ec48ee7866 plugins: use complete filename for defining plugins sources
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Manos Pitsidianakis <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Pierrick Bouvier <[email protected]>
2026-01-29 09:34:14 -08:00
Pierrick Bouvier e115d55110 plugins: factorize plugin dependencies and library details
Reviewed-by: Daniel P. Berrangé <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Pierrick Bouvier <[email protected]>
2026-01-29 09:34:14 -08:00
Pierrick Bouvier 3b781315cc plugins: move win32_linker.c file to plugins directory
Reviewed-by: Richard Henderson <[email protected]>
Reviewed-by: Manos Pitsidianakis <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Pierrick Bouvier <[email protected]>
2026-01-29 09:34:14 -08:00
Florian Hofhammer c22ea55b3b plugins: return bool from register r/w API
The qemu_plugin_{read,write} register API previously was inconsistent
with regard to its docstring (where a return value of both -1 and 0
would indicate an error) and to the memory read/write APIs, which
already return a boolean value to indicate success or failure.
Returning the number of bytes read or written is superfluous, as the
GByteArray* passed to the API functions already encodes the length.
See the linked thread for more details.

This patch moves from returning an int (number of bytes read/written) to
returning a bool from the register read/write API, bumps the plugin API
version, and adjusts plugins and tests accordingly.

Signed-off-by: Florian Hofhammer <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Pierrick Bouvier <[email protected]>
2026-01-29 09:34:14 -08:00
Ziyang Zhang 948ffdd79b tcg tests: add a test to verify the syscall filter plugin API
Register a syscall filter callback in tests/tcg/plugins/sycall.c,
returns a specific value for a magic system call number, and check
it in tests/tcg/multiarch/test-plugin-syscall-filter.c.

Signed-off-by: Ziyang Zhang <[email protected]>
Co-authored-by: Mingyuan Xia <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
[Pierrick - Changed syscall number to 4096 to make it work with mips32]
[Pierrick - Skip test when compiling without plugins enabled]
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Pierrick Bouvier <[email protected]>
2026-01-29 09:34:14 -08:00
Ziyang Zhang 5ed628d1d3 linux-user: add plugin API to filter syscalls
This commit adds a syscall filter API to the TCG plugin API set.
Plugins can register a filter callback to QEMU to decide whether
to intercept a syscall, process it and bypass the QEMU syscall
handler.

Signed-off-by: Ziyang Zhang <[email protected]>
Co-authored-by: Mingyuan Xia <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
[Pierrick - move send_through_syscall_filters to linux-user/syscall.c]
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Pierrick Bouvier <[email protected]>
2026-01-29 09:34:14 -08:00
Pierrick Bouvier d37ce14f98 linux-user: move user/syscall-trace.h to linux-user/syscall.c
For now, only linux-user supports plugin syscall API, so restrict the
scope of these functions to linux-user/syscall.c

Reviewed-by: Richard Henderson <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Pierrick Bouvier <[email protected]>
2026-01-29 09:34:14 -08:00
Alex Bradbury 0a9754525c contrib/plugins/hotblocks: Allow limit to be set as a command line argument
Also add documentation for this argument. This allows the default of 20
to be overridden, and is helpful for using the hotblocks plugin for
analysis scripts that require collecting data on a larger number of
blocks (e.g. setting limit=0 to dump information on all blocks).

Signed-off-by: Alex Bradbury <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Link: https://lore.kernel.org/qemu-devel/58281d6e54bcad1802e8d3dc8d8501d54c2a971e.1753857212.git.asb@igalia.com
Signed-off-by: Pierrick Bouvier <[email protected]>
2026-01-29 09:34:14 -08:00
Alex Bradbury e4ed74c9ae docs/about/emulation: Add documentation for hotblocks plugin arguments
Currently just 'inline'.

Signed-off-by: Alex Bradbury <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Link: https://lore.kernel.org/qemu-devel/35128cc5a86a0c18418f9d3150fb8771c54ef7d8.1753857212.git.asb@igalia.com
Signed-off-by: Pierrick Bouvier <[email protected]>
2026-01-29 09:34:14 -08:00
Alex Bradbury e777f6ab91 contrib/plugins/hotblocks: Print uint64_t with PRIu64 rather than PRId64
qemu_plugin_u64_sum returns a uint64_t, so PRIu64 is the correct format
specifier.

Signed-off-by: Alex Bradbury <[email protected]>
Reviewed-by: Manos Pitsidianakis <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Link: https://lore.kernel.org/qemu-devel/5d26c9d99ee87ac4a4034ff64e3d8881253eedf3.1753857212.git.asb@igalia.com
Signed-off-by: Pierrick Bouvier <[email protected]>
2026-01-29 09:34:14 -08:00
Alex Bradbury 1c1e45fcd6 contrib/plugins/hotblocks: Fix off by one error in iteration of sorted blocks
The logic to iterate over the hottest blocks will never reach the last
item in the list, as it checks `it->next != NULL` before entering the
loop. It's hard to trigger this off-by-one error with the default
limit=20, but it is a bug and is problematic if that default is changed
to something larger.

Signed-off-by: Alex Bradbury <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Link: https://lore.kernel.org/qemu-devel/f1ba2e57c6126472c0c8310774009f2455efc370.1753857212.git.asb@igalia.com
Signed-off-by: Pierrick Bouvier <[email protected]>
2026-01-29 09:34:14 -08:00
Alex Bradbury 90fabd5dda contrib/plugins/hotblocks: Correctly free sorted counts list
g_list_free should be passed the head of the list.

Signed-off-by: Alex Bradbury <[email protected]>
Reviewed-by: Manos Pitsidianakis <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Link: https://lore.kernel.org/qemu-devel/cf5a00136738b981a12270b76572e8d502daf208.1753857212.git.asb@igalia.com
Signed-off-by: Pierrick Bouvier <[email protected]>
2026-01-29 09:34:14 -08:00
Cornelia Huck 5252c07746 arm: add DCZID_EL0 to idregs array
Continue moving ID registers to the idregs array, so that we
eventually can switch to an autogenerated cpu-sysregs.h.inc.

This requires a bit of care, since we still have to handle the EL
specific part (DCZID_EL0.DZP). The value previously saved in
cpu->dcz_blocksize is now kept in DCZID_EL.BS (transparent to
callers using the wrappers.)

KVM currently does not support DCZID_EL0 via ONE_REG, assert that
we're not trying to do anything with it until it does.

Signed-off-by: Cornelia Huck <[email protected]>
Reviewed-by: Sebastian Ott <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-01-29 13:45:39 +00:00
Cornelia Huck 7d2e2d0941 arm: add {get,set}_dczid_bs helpers
Most accesses to cpu->dcz_blocksize really care about
DCZID_EL0.BS (i.e. the part of the register that does not change at
different EL.) Wean them off directly dealing with cpu->dcz_blocksize
so that we can switch to handling DCZID_EL0 differently in a followup
patch.

Signed-off-by: Cornelia Huck <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Reviewed-by: Sebastian Ott <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-01-29 13:45:39 +00:00
Alex Bennée 8a0d94ab4a docs/system: update FEAT_BBML[12] references
It looks like the features were renamed to include the levels at some
point. To make it easier to match features up to the Arm ARM update to
use the full name.

Signed-off-by: Alex Bennée <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-01-29 13:42:29 +00:00
Alex Bennée 591b9b94ce MAINTAINERS: add emulation.rst to ARM TCG CPUs
This is updated as Arm architectural features are added so we should
catch changes to the docs as well.

Signed-off-by: Alex Bennée <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-01-29 13:41:53 +00:00
Philippe Mathieu-Daudé bfbea371ef target/arm/hvf: Sync CNTV_CTL_EL0 & CNTV_CVAL_EL0
Keep CNTV_CTL_EL0 and CNTV_CVAL_EL0 synchronized with the
host hardware accelerator.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-01-29 13:32:05 +00:00
Philippe Mathieu-Daudé c0f2a78e2c target/arm/hvf: Move hvf_sysreg_[read, write]_cp() functions around
Next commit will use these functions prototype earlier. Rather
than forward-declaring them, move them around.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-01-29 13:32:05 +00:00
Shameer Kolothum b8c6f8a69d hw/arm/smmuv3-accel: Make SubstreamID support configurable
QEMU SMMUv3 currently reports no SubstreamID support, forcing SSID to
zero. This prevents accelerated use cases such as Shared Virtual
Addressing (SVA), which require multiple Stage-1 context descriptors
indexed by SubstreamID.

Add a new "ssidsize" property to explicitly configure the number of bits
used for SubstreamIDs. A value greater than zero enables SubstreamID
support and advertises PASID capability to the vIOMMU.

The requested SSIDSIZE is validated against host SMMUv3 capabilities and
is only supported when accel=on.

Reviewed-by: Jonathan Cameron <[email protected]>
Reviewed-by: Eric Auger <[email protected]>
Reviewed-by: Nicolin Chen <[email protected]>
Tested-by: Eric Auger <[email protected]>
Tested-by: Zhangfei Gao <[email protected]>
Signed-off-by: Shameer Kolothum <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-01-29 13:32:05 +00:00
Shameer Kolothum 06b38473cd hw/vfio/pci: Synthesize PASID capability for vfio-pci devices
Add support for synthesizing a PCIe PASID extended capability for
vfio-pci devices when PASID is enabled via a vIOMMU and supported by
the host IOMMU backend.

PASID capability parameters are retrieved via IOMMUFD APIs and the
capability is inserted into the PCIe extended capability list using
the insertion helper. A new x-vpasid-cap-offset property allows
explicit control over the placement; by default the capability is
placed at the end of the PCIe extended configuration space.

If the kernel does not expose PASID information or insertion fails,
the device continues without PASID support.

Reviewed-by: Jonathan Cameron <[email protected]>
Tested-by: Eric Auger <[email protected]>
Tested-by: Zhangfei Gao <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Signed-off-by: Shameer Kolothum <[email protected]>
Reviewed-by: Yi Liu <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-01-29 13:32:05 +00:00
Shameer Kolothum 7d59fa2059 hw/pci: Factor out common PASID capability initialization
Refactor PCIe PASID capability initialization by moving the common
register init into a new helper, pcie_pasid_common_init().

Subsequent patch to synthesize a vPASID will make use of this
helper.

No functional change intended.

Cc: Michael S. Tsirkin <[email protected]>
Reviewed-by: Jonathan Cameron <[email protected]>
Reviewed-by: Eric Auger <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Tested-by: Eric Auger <[email protected]>
Tested-by: Zhangfei Gao <[email protected]>
Signed-off-by: Shameer Kolothum <[email protected]>
Reviewed-by: Yi Liu <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-01-29 13:32:05 +00:00
Shameer Kolothum 49a2bed19b hw/pci: Add helper to insert PCIe extended capability at a fixed offset
Add pcie_insert_capability(), a helper to insert a PCIe extended
capability into an existing extended capability list at a caller
specified offset.

Unlike pcie_add_capability(), which always appends a capability to the
end of the list, this helper preserves the existing list ordering while
allowing insertion at an arbitrary offset.

The helper only validates that the insertion does not overwrite an
existing PCIe extended capability header, since corrupting a header
would break the extended capability linked list. Validation of overlaps
with other configuration space registers or capability-specific
register blocks is left to the caller.

Reviewed-by: Michael S. Tsirkin <[email protected]>
Reviewed-by: Eric Auger <[email protected]>
Tested-by: Eric Auger <[email protected]>
Tested-by: Zhangfei Gao <[email protected]>
Reviewed-by: Jonathan Cameron <[email protected]>
Signed-off-by: Shameer Kolothum <[email protected]>
Reviewed-by: Yi Liu <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-01-29 13:32:05 +00:00
Shameer Kolothum 22afd9d865 backends/iommufd: Add get_pasid_info() callback
The get_pasid_info callback retrieves PASID capability information
when the HostIOMMUDevice backend supports it. Currently, only the
Linux IOMMUFD backend provides this information.

This will be used by a subsequent patch to synthesize a PASID
capability for vfio-pci devices behind a vIOMMU that supports PASID.

Reviewed-by: Jonathan Cameron <[email protected]>
Reviewed-by: Eric Auger <[email protected]>
Tested-by: Eric Auger <[email protected]>
Tested-by: Zhangfei Gao <[email protected]>
Reviewed-by: Nicolin Chen <[email protected]>
Signed-off-by: Shameer Kolothum <[email protected]>
Reviewed-by: Yi Liu <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-01-29 13:32:05 +00:00
Shameer Kolothum 550beca3d7 backends/iommufd: Retrieve PASID width from iommufd_backend_get_device_info()
Retrieve PASID width from iommufd_backend_get_device_info() and store it
in HostIOMMUDeviceCaps for later use.

Reviewed-by: Jonathan Cameron <[email protected]>
Reviewed-by: Eric Auger <[email protected]>
Tested-by: Zhangfei Gao <[email protected]>
Reviewed-by: Nicolin Chen <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Tested-by: Eric Auger <[email protected]>
Signed-off-by: Shameer Kolothum <[email protected]>
Reviewed-by: Yi Liu <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-01-29 13:32:05 +00:00
Shameer Kolothum a015ac990f hw/arm/smmuv3-accel: Add property to specify OAS bits
QEMU SMMUv3 currently sets the output address size (OAS) to 44 bits.
With accelerator mode enabled, a device may use SVA, where CPU page tables
are shared with the SMMU, requiring an OAS at least as large as the
CPU’s output address size. A user option is added to configure this.

However, the OAS value advertised by the virtual SMMU must remain
compatible with the capabilities of the host SMMUv3. In accelerated
mode, the host SMMU performs stage-2 translation and must be able to
consume the intermediate physical addresses (IPA) produced by stage-1.

The OAS exposed by the virtual SMMU defines the maximum IPA width that
stage-1 translations may generate. For AArch64 implementations, the
maximum usable IPA size on the host SMMU is determined by its own OAS.
Check that the configured OAS does not exceed what the host SMMU
can safely support.

Tested-by: Zhangfei Gao <[email protected]>
Reviewed-by: Nicolin Chen <[email protected]>
Reviewed-by: Eric Auger <[email protected]>
Reviewed-by: Jonathan Cameron <[email protected]>
Tested-by: Eric Auger <[email protected]>
Signed-off-by: Shameer Kolothum <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-01-29 13:32:05 +00:00
Shameer Kolothum f7f5013a55 hw/arm/smmuv3-accel: Add support for ATS
QEMU SMMUv3 does not enable ATS (Address Translation Services) by default.
When accelerated mode is enabled and the host SMMUv3 supports ATS, it can
be useful to report ATS capability to the guest so it can take advantage
of it if the device also supports ATS.

Note: ATS support cannot be reliably detected from the host SMMUv3 IDR
registers alone, as firmware ACPI IORT tables may override them. The
user must therefore ensure the support before enabling it.

The ATS support enabled here is only relevant for vfio-pci endpoints,
as SMMUv3 accelerated mode does not support emulated endpoint devices.
QEMU’s SMMUv3 implementation still lacks support for handling ATS
translation requests, which would be required for emulated endpoints.

Reviewed-by: Jonathan Cameron <[email protected]>
Tested-by: Zhangfei Gao <[email protected]>
Reviewed-by: Nicolin Chen <[email protected]>
Reviewed-by: Eric Auger <[email protected]>
Tested-by: Eric Auger <[email protected]>
Signed-off-by: Shameer Kolothum <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-01-29 13:32:05 +00:00
Shameer Kolothum bd715ff5bd hw/arm/smmuv3-accel: Add a property to specify RIL support
Currently QEMU SMMUv3 has RIL support by default. But if accelerated mode
is enabled, RIL has to be compatible with host SMMUv3 support.

Add a property so that the user can specify this.

Reviewed-by: Jonathan Cameron <[email protected]>
Tested-by: Zhangfei Gao <[email protected]>
Reviewed-by: Eric Auger <[email protected]>
Reviewed-by: Nicolin Chen <[email protected]>
Tested-by: Eric Auger <[email protected]>
Signed-off-by: Shameer Kolothum <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-01-29 13:32:05 +00:00
Shameer Kolothum 6cc3a621c6 hw/arm/smmuv3: Add accel property for SMMUv3 device
Add an "accel" property to enable SMMUv3 accelerator mode.

Accelerator mode relies on IORT RMR entries for MSI support and is
therefore not supported when booting with a device tree.

In this mode, the host SMMUv3 operates in nested translation
(Stage-1 + Stage-2), with the guest owning the Stage-1 page tables.
Expose only Stage-1 to the guest to ensure it uses the correct page
table format

Reviewed-by: Nicolin Chen <[email protected]>
Reviewed-by: Eric Auger <[email protected]>
Tested-by: Zhangfei Gao <[email protected]>
Reviewed-by: Jonathan Cameron <[email protected]>
Tested-by: Eric Auger <[email protected]>
Signed-off-by: Shameer Kolothum <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-01-29 13:32:05 +00:00
Shameer Kolothum be0cf3c8f1 hw/arm/smmuv3: Block migration when accel is enabled
Live migration is not supported when the SMMUv3 accelerator mode is
enabled. Add a migration blocker to prevent migration in this
configuration.

Reviewed-by: Nicolin Chen <[email protected]>
Reviewed-by: Eric Auger <[email protected]>
Tested-by: Zhangfei Gao <[email protected]>
Reviewed-by: Jonathan Cameron <[email protected]>
Tested-by: Eric Auger <[email protected]>
Signed-off-by: Shameer Kolothum <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-01-29 13:32:05 +00:00
Shameer Kolothum f48bddafa2 tests/qtest/bios-tables-test: Update IORT blobs after revision upgrade
Update the reference IORT blobs after revision upgrade for RMR node
support. This affects the aarch64 'virt' IORT tests.

IORT diff is the same for all the tests:

 /*
  * Intel ACPI Component Architecture
  * AML/ASL+ Disassembler version 20230628 (64-bit version)
  * Copyright (c) 2000 - 2023 Intel Corporation
  *
- * Disassembly of tests/data/acpi/aarch64/virt/IORT, Mon Oct 20 14:42:41 2025
+ * Disassembly of /tmp/aml-B4ZRE3, Mon Oct 20 14:42:41 2025
  *
  * ACPI Data Table [IORT]
  *
  * Format: [HexOffset DecimalOffset ByteLength]  FieldName : FieldValue (in hex)
  */

 [000h 0000 004h]                   Signature : "IORT"    [IO Remapping Table]
 [004h 0004 004h]                Table Length : 00000080
-[008h 0008 001h]                    Revision : 03
-[009h 0009 001h]                    Checksum : B3
+[008h 0008 001h]                    Revision : 05
+[009h 0009 001h]                    Checksum : B1
 [00Ah 0010 006h]                      Oem ID : "BOCHS "
 [010h 0016 008h]                Oem Table ID : "BXPC    "
 [018h 0024 004h]                Oem Revision : 00000001
 [01Ch 0028 004h]             Asl Compiler ID : "BXPC"
 [020h 0032 004h]       Asl Compiler Revision : 00000001
 ...

Reviewed-by: Jonathan Cameron <[email protected]>
Reviewed-by: Eric Auger <[email protected]>
Tested-by: Eric Auger <[email protected]>
Tested-by: Zhangfei Gao <[email protected]>
Signed-off-by: Shameer Kolothum <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-01-29 13:32:05 +00:00
Eric Auger 06c0c8fde7 hw/arm/virt-acpi-build: Add IORT RMR regions to handle MSI nested binding
To handle SMMUv3 accel=on mode(which configures the host SMMUv3 in nested
mode), it is practical to expose the guest with reserved memory regions
(RMRs) covering the IOVAs used by the host kernel to map physical MSI
doorbells.

Those IOVAs belong to [0x8000000, 0x8100000] matching MSI_IOVA_BASE and
MSI_IOVA_LENGTH definitions in kernel arm-smmu-v3 driver. This is the
window used to allocate IOVAs matching physical MSI doorbells.

With those RMRs, the guest is forced to use a flat mapping for this range.
Hence the assigned device is programmed with one IOVA from this range.
Stage 1, owned by the guest has a flat mapping for this IOVA. Stage2,
owned by the VMM then enforces a mapping from this IOVA to the physical
MSI doorbell.

The creation of those RMR nodes is only relevant if nested stage SMMU is
in use, along with VFIO. As VFIO devices can be hotplugged, all RMRs need
to be created in advance.

Initialise AcpiIortSMMUv3Dev structures to avoid using uninitialised
state when building the IORT, as legacy and device SMMUv3 paths
populate different fields now(e.g. accel).

Signed-off-by: Eric Auger <[email protected]>
Signed-off-by: Shameer Kolothum <[email protected]>
Signed-off-by: Nicolin Chen <[email protected]>
Signed-off-by: Shameer Kolothum <[email protected]>
Tested-by: Zhangfei Gao <[email protected]>
Tested-by: Eric Auger <[email protected]>
Reviewed-by: Jonathan Cameron <[email protected]>
Message-id: [email protected]
Suggested-by: Jean-Philippe Brucker <[email protected]>
Signed-off-by: Nicolin Chen <[email protected]>
Signed-off-by: Shameer Kolothum <[email protected]>
Tested-by: Zhangfei Gao <[email protected]>
Reviewed-by: Jonathan Cameron <[email protected]>
Tested-by: Eric Auger <[email protected]>
Signed-off-by: Shameer Kolothum <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
2026-01-29 13:32:05 +00:00
Shameer Kolothum b8e196a746 tests/qtest/bios-tables-test: Prepare for IORT revison upgrade
Subsequent patch will upgrade IORT revision to 5 to add support
for IORT RMR nodes.

Add the affected IORT blobs to allowed-diff list for bios-table
tests.

Reviewed-by: Jonathan Cameron <[email protected]>
Reviewed-by: Eric Auger <[email protected]>
Tested-by: Eric Auger <[email protected]>
Tested-by: Zhangfei Gao <[email protected]>
Signed-off-by: Shameer Kolothum <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-01-29 13:32:05 +00:00
Shameer Kolothum 45c57eaefd hw/arm/virt: Set PCI preserve_config for accel SMMUv3
Introduce a new pci_preserve_config field in virt machine state which
allows the generation of DSM #5. This field is only set if accel SMMU
is instantiated.

In a subsequent patch, SMMUv3 accel mode will make use of IORT RMR nodes
to enable nested translation of MSI doorbell addresses. IORT RMR requires
_DSM #5 to be set for the PCI host bridge so that the Guest kernel
preserves the PCI boot configuration.

Reviewed-by: Jonathan Cameron <[email protected]>
Tested-by: Zhangfei Gao <[email protected]>
Reviewed-by: Eric Auger <[email protected]>
Tested-by: Eric Auger <[email protected]>
Signed-off-by: Shameer Kolothum <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-01-29 13:32:05 +00:00
Eric Auger 59a5c80623 hw/pci-host/gpex: Allow to generate preserve boot config DSM #5
Add a 'preserve_config' field in struct GPEXConfig and, if set, generate
the _DSM function #5 for preserving PCI boot configurations.

This will be used for SMMUv3 accel=on support in subsequent patch. When
SMMUv3 acceleration (accel=on) is enabled, QEMU exposes IORT Reserved
Memory Region (RMR) nodes to support MSI doorbell translations. As per
the Arm IORT specification, using IORT RMRs mandates the presence of
_DSM function #5 so that the OS retains the firmware-assigned PCI
configuration. Hence, this patch adds conditional support for generating
_DSM #5.

According to the ACPI Specification, Revision 6.6, Section 9.1.1 -
“_DSM (Device Specific Method)”,

"
If Function Index is zero, the return is a buffer containing one bit for
each function index, starting with zero. Bit 0 indicates whether there
is support for any functions other than function 0 for the specified
UUID and Revision ID. If set to zero, no functions are supported (other
than function zero) for the specified UUID and Revision ID. If set to
one, at least one additional function is supported. For all other bits
in the buffer, a bit is set to zero to indicate if that function index
is not supported for the specific UUID and Revision ID. (For example,
bit 1 set to 0 indicates that function index 1 is not supported for the
specific UUID and Revision ID.)
"

Please refer PCI Firmware Specification, Revision 3.3, Section 4.6.5 —
"_DSM for Preserving PCI Boot Configurations" for Function 5 of _DSM
method.

Also, while at it, move the byte_list declaration to the top of the
function for clarity.

At the moment, DSM generation is not yet enabled.

The resulting AML when preserve_config=true is:

    Method (_DSM, 4, NotSerialized)
        {
            If ((Arg0 == ToUUID ("e5c937d0-3553-4d7a-9117-ea4d19c3434d")))
                {
                    If ((Arg2 == Zero))
                    {
                        Return (Buffer (One)
                        {
                             0x21
                        })
                    }

                    If ((Arg2 == 0x05))
                    {
                        Return (Zero)
                    }
                }
         ...
      }

Cc: Michael S. Tsirkin <[email protected]>
Signed-off-by: Eric Auger <[email protected]>
Signed-off-by: Shameer Kolothum <[email protected]>
Signed-off-by: Shameer Kolothum <[email protected]>
Tested-by: Zhangfei Gao <[email protected]>
Tested-by: Eric Auger <[email protected]>
Reviewed-by: Jonathan Cameron <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Message-id: [email protected]
[Shameer: Removed possible duplicate _DSM creations]
Signed-off-by: Shameer Kolothum <[email protected]>
Tested-by: Zhangfei Gao <[email protected]>
Reviewed-by: Jonathan Cameron <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Tested-by: Eric Auger <[email protected]>
Signed-off-by: Shameer Kolothum <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
2026-01-29 13:32:05 +00:00
Shameer Kolothum ad32238ad2 hw/arm/smmuv3-accel: Get host SMMUv3 hw info and validate
Just before the device gets attached to the SMMUv3, make sure QEMU SMMUv3
features are compatible with the host SMMUv3.

Not all fields in the host SMMUv3 IDR registers are meaningful for userspace.
Only the following fields can be used:

  - IDR0: ST_LEVEL, TERM_MODEL, STALL_MODEL, TTENDIAN, CD2L, ASID16, TTF
  - IDR1: SIDSIZE, SSIDSIZE
  - IDR3: BBML, RIL
  - IDR5: VAX, GRAN64K, GRAN16K, GRAN4K

For now, the check is to make sure the features are in sync to enable
basic accelerated SMMUv3 support. AIDR is not checked, as hardware
implementations often provide a mix of architecture features regardless
of the revision reported in AIDR.

Note that SSIDSIZE check will be added later when support for PASID is
introduced.

Reviewed-by: Nicolin Chen <[email protected]>
Reviewed-by: Jonathan Cameron <[email protected]>
Reviewed-by: Eric Auger <[email protected]>
Tested-by: Eric Auger <[email protected]>
Tested-by: Zhangfei Gao <[email protected]>
Signed-off-by: Shameer Kolothum <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-01-29 13:32:05 +00:00
Shameer Kolothum f577dcdb5c hw/arm/smmuv3: Initialize ID registers early during realize()
Factor out ID register init into smmuv3_init_id_regs() and call it from
realize(). This ensures ID registers are initialized early for use in the
accelerated SMMUv3 path and will be utilized in subsequent patch.

Other registers remain initialized in smmuv3_reset().

Reviewed-by: Nicolin Chen <[email protected]>
Reviewed-by: Jonathan Cameron <[email protected]>
Reviewed-by: Eric Auger <[email protected]>
Tested-by: Eric Auger <[email protected]>
Tested-by: Zhangfei Gao <[email protected]>
Signed-off-by: Shameer Kolothum <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-01-29 13:32:05 +00:00
Shameer Kolothum 58a789c389 hw/arm/smmuv3-accel: Add support to issue invalidation cmd to host
Provide a helper and use that to issue the invalidation cmd to host SMMUv3.
We only issue one cmd at a time for now.

Support for batching of commands will be added later after analysing the
impact.

Reviewed-by: Jonathan Cameron <[email protected]>
Tested-by: Zhangfei Gao <[email protected]>
Reviewed-by: Nicolin Chen <[email protected]>
Reviewed-by: Eric Auger <[email protected]>
Tested-by: Eric Auger <[email protected]>
Signed-off-by: Shameer Kolothum <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-01-29 13:32:05 +00:00
Shameer Kolothum 5ec2700dcb hw/arm/virt: Set msi-gpa property
Set the MSI doorbell GPA property for accelerated SMMUv3 devices for use
by KVM MSI setup. Also, since any meaningful use of vfio-pci devices with
an accelerated SMMUv3 requires both KVM and a kernel irqchip, ensure
those are specified when accel=on is selected.

Reviewed-by: Nicolin Chen <[email protected]>
Tested-by: Eric Auger <[email protected]>
Tested-by: Zhangfei Gao <[email protected]>
Reviewed-by: Jonathan Cameron <[email protected]>
Signed-off-by: Shameer Kolothum <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-01-29 13:32:05 +00:00
Shameer Kolothum 3558c85392 hw/arm/smmuv3-accel: Implement get_msi_direct_gpa callback
Accelerated SMMUv3 instances rely on the physical SMMUv3 for nested
translation (guest Stage-1, host Stage-2). In this mode, the guest Stage-1
tables are programmed directly into hardware, and QEMU must not attempt to
walk them for translation, as doing so is not reliably safe. For vfio-pci
endpoints behind such a vSMMU, the only translation QEMU needs to perform
is for the MSI doorbell used during KVM MSI setup.

Implement the callback so that kvm_arch_fixup_msi_route() can retrieve the
MSI doorbell GPA directly, instead of attempting a software walk of the
guest translation tables.

Also introduce an SMMUv3 device property to carry the MSI doorbell GPA.
This property will be set by the virt machine in a subsequent patch.

Reviewed-by: Nicolin Chen <[email protected]>
Reviewed-by: Eric Auger <[email protected]>
Tested-by: Eric Auger <[email protected]>
Tested-by: Zhangfei Gao <[email protected]>
Reviewed-by: Jonathan Cameron <[email protected]>
Signed-off-by: Shameer Kolothum <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-01-29 13:32:05 +00:00
Shameer Kolothum 5c921b29c9 hw/pci/pci: Introduce a callback to retrieve the MSI doorbell GPA directly
For certain vIOMMU implementations, such as SMMUv3 in accelerated mode,
the translation tables are programmed directly into the physical SMMUv3
in a nested configuration. While QEMU knows where the guest tables live,
safely walking them in software would require trapping and ordering all
guest invalidations on every command queue. Without this, QEMU could race
with guest updates and walk stale or freed page tables.

This constraint is fundamental to the design of HW-accelerated vSMMU when
used with downstream vfio-pci endpoint devices, where QEMU must never walk
guest translation tables and must rely on the physical SMMU for
translation. Future accelerated vSMMU features, such as virtual CMDQ, will
also prevent trapping invalidations, reinforcing this restriction.

For vfio-pci endpoints behind such a vSMMU, the only translation QEMU
needs is for the MSI doorbell used when setting up KVM MSI route tables.
Instead of attempting a software walk, introduce an optional vIOMMU
callback that returns the MSI doorbell GPA directly.

kvm_arch_fixup_msi_route() uses this callback when available and ignores
the guest provided IOVA in that case.

If the vIOMMU does not implement the callback, we fall back to the
existing IOMMU based address space translation path.

This ensures correct MSI routing for accelerated SMMUv3 + VFIO passthrough
while avoiding unsafe software walks of guest translation tables.

As a related change, replace RCU_READ_LOCK_GUARD() with explicit
rcu_read_lock()/rcu_read_unlock(). The introduction of an early goto
(set_doorbell) path means the RCU read side critical section can no longer
be safely scoped using RCU_READ_LOCK_GUARD().

Cc: Michael S. Tsirkin <[email protected]>
Reviewed-by: Nicolin Chen <[email protected]>
Reviewed-by: Eric Auger <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Tested-by: Eric Auger <[email protected]>
Tested-by: Zhangfei Gao <[email protected]>
Reviewed-by: Jonathan Cameron <[email protected]>
Signed-off-by: Shameer Kolothum <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-01-29 13:32:04 +00:00
Shameer Kolothum b6b867b9c1 hw/arm/smmuv3-accel: Install SMMUv3 GBPA based hwpt
On guest reboot or on GBPA update, attach a nested HWPT based on the
GPBA.ABORT bit which either aborts all incoming transactions or bypasses
them.

Reviewed-by: Eric Auger <[email protected]>
Reviewed-by: Nicolin Chen <[email protected]>
Tested-by: Eric Auger <[email protected]>
Tested-by: Zhangfei Gao <[email protected]>
Reviewed-by: Jonathan Cameron <[email protected]>
Signed-off-by: Shameer Kolothum <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-01-29 13:32:04 +00:00
Nicolin Chen 2da17a988c hw/arm/smmuv3-accel: Add nested vSTE install/uninstall support
A device placed behind a vSMMU instance must have corresponding vSTEs
(bypass, abort, or translate) installed. The bypass and abort proxy nested
HWPTs are pre-allocated.

For translat HWPT, a vDEVICE object is allocated and associated with the
vIOMMU for each guest device. This allows the host kernel to establish a
virtual SID to physical SID mapping, which is required for handling
invalidations and event reporting.

An translate HWPT is allocated based on the guest STE configuration and
attached to the device when the guest issues SMMU_CMD_CFGI_STE or
SMMU_CMD_CFGI_STE_RANGE, provided the STE enables S1 translation.

If the guest STE is invalid or S1 translation is disabled, the device is
attached to one of the pre-allocated ABORT or BYPASS HWPTs instead.

While at it, export smmu_find_ste() for use here.

Signed-off-by: Nicolin Chen <[email protected]>
Signed-off-by: Shameer Kolothum <[email protected]>
Reviewed-by: Jonathan Cameron <[email protected]>
Reviewed-by: Eric Auger <[email protected]>
Tested-by: Eric Auger <[email protected]>
Tested-by: Zhangfei Gao <[email protected]>
Signed-off-by: Shameer Kolothum <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-01-29 13:32:04 +00:00
Shameer Kolothum 95d855167a hw/arm/smmuv3: propagate smmuv3_cmdq_consume() errors to caller
smmuv3_cmdq_consume() is updated to return detailed errors via errp.

Although this is currently a no-op, it prepares the ground for accel
SMMUv3 specific command handling where proper error reporting will be
useful.

Reviewed-by: Nicolin Chen <[email protected]>
Reviewed-by: Eric Auger <[email protected]>
Tested-by: Eric Auger <[email protected]>
Tested-by: Zhangfei Gao <[email protected]>
Reviewed-by: Jonathan Cameron <[email protected]>
Signed-off-by: Shameer Kolothum <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-01-29 13:32:04 +00:00
Nicolin Chen 703b7b91db hw/arm/smmuv3-accel: Add set/unset_iommu_device callback
Implement the VFIO/PCI callbacks to attach and detach a HostIOMMUDevice
to a vSMMUv3 when accel=on,

 - set_iommu_device(): attach a HostIOMMUDevice to a vIOMMU
 - unset_iommu_device(): detach and release associated resources

In SMMUv3 accel=on mode, the guest SMMUv3 is backed by the host SMMUv3 via
IOMMUFD. A vIOMMU object (created via IOMMU_VIOMMU_ALLOC) provides a per-VM,
security-isolated handle to the physical SMMUv3. Without a vIOMMU, the
vSMMUv3 cannot relay guest operations to the host hardware nor maintain
isolation across VMs or devices. Therefore, set_iommu_device() allocates
a vIOMMU object if one does not already exist.

There are two main points to consider in this implementation:

1) VFIO core allocates and attaches a S2 HWPT that acts as the nesting
   parent for nested HWPTs(IOMMU_DOMAIN_NESTED). This parent HWPT will
   be shared across multiple vSMMU instances within a VM.

2) A device cannot attach directly to a vIOMMU. Instead, it attaches
   through a proxy nested HWPT (IOMMU_DOMAIN_NESTED). Based on the STE
   configuration,there are three types of nested HWPTs: bypass, abort,
   and translate.
    -The bypass and abort proxy HWPTs are pre-allocated. When SMMUv3
     operates in global abort or bypass modes, as controlled by the GBPA
     register, or issues a vSTE for bypass or abort we attach these
     pre-allocated nested HWPTs.
    -The translate HWPT requires a vDEVICE to be allocated first, since
     invalidations and events depend on a valid vSID.
    -The vDEVICE allocation and attach operations for vSTE based HWPTs
     are implemented in subsequent patches.

In summary, a device placed behind a vSMMU instance must have a vSID for
translate vSTE. The bypass and abort vSTEs are pre-allocated as proxy
nested HWPTs and is attached based on GBPA register. The core-managed
nesting parent S2 HWPT is used as parent S2 HWPT for all the nested
HWPTs and is intended to be shared across vSMMU instances within the
same VM.

set_iommu_device():
  - Reuse an existing vIOMMU for the same physical SMMU if available.
    If not, allocate a new one using the nesting parent S2 HWPT.
  - Pre-allocate two proxy nested HWPTs (bypass and abort) under the
    vIOMMU and install one based on GBPA.ABORT value.
  - Add the device to the vIOMMU’s device list.

unset_iommu_device():
  - Re-attach device to the nesting parent S2 HWPT.
  - Remove the device from the vIOMMU’s device list.
  - If the list is empty, free the proxy HWPTs (bypass and abort)
    and release the vIOMMU object.

Introduce struct SMMUv3AccelState, representing an accelerated SMMUv3
instance backed by an iommufd vIOMMU object, and storing the bypass and
abort proxy HWPT IDs.

Signed-off-by: Nicolin Chen <[email protected]>
Signed-off-by: Shameer Kolothum <[email protected]
Reviewed-by: Jonathan Cameron <[email protected]>
Tested-by: Zhangfei Gao <[email protected]>
Reviewed-by: Eric Auger <[email protected]>
Tested-by: Eric Auger <[email protected]>
Signed-off-by: Shameer Kolothum <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-01-29 13:32:04 +00:00
Shameer Kolothum fc6dafb98c hw/arm/smmuv3: Implement get_viommu_cap() callback
For accelerated SMMUv3, we need nested parent domain creation. Add the
callback support so that VFIO can create a nested parent.

Reviewed-by: Nicolin Chen <[email protected]>
Reviewed-by: Jonathan Cameron <[email protected]>
Signed-off-by: Shameer Kolothum <[email protected]>
Tested-by: Zhangfei Gao <[email protected]>
Reviewed-by: Eric Auger <[email protected]>
Tested-by: Eric Auger <[email protected]>
Signed-off-by: Shameer Kolothum <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-01-29 13:32:04 +00:00
Shameer Kolothum c7ecb4cf2e hw/arm/smmuv3-accel: Restrict accelerated SMMUv3 to vfio-pci endpoints with iommufd
Accelerated SMMUv3 is only meaningful when a device can leverage the host
SMMUv3 in nested mode (S1+S2 translation). To keep the model consistent
and correct, this mode is restricted to vfio-pci endpoint devices using
the iommufd backend.

Non-endpoint emulated devices such as PCIe root ports and bridges are also
permitted so that vfio-pci devices can be attached downstream. All other
device types are unsupported in accelerated mode.

Implement supports_address_space() callback to reject all such unsupported
devices.

This restriction also avoids complications with IOTLB invalidations. Some
TLBI commands (e.g. CMD_TLBI_NH_ASID) lack an associated SID, making it
difficult to trace the originating device. Allowing emulated endpoints
would require invalidating both QEMU’s software IOTLB and the host’s
hardware IOTLB, which can significantly degrade performance.

A key design choice is the address space returned for accelerated vfio-pci
endpoints. VFIO core has a container that manages an HWPT. By default, it
allocates a stage-1 normal HWPT, unless vIOMMU requests for a nesting
parent HWPT for accelerated cases.

VFIO core adds a listener for that HWPT and sets up a handler
vfio_container_region_add() where it checks the memory region.

 -If the region is a non-IOMMU translated one (system address space), VFIO
  treats it as RAM and handles all stage-2 mappings for the core allocated
  nesting parent HWPT.

 -If the region is an IOMMU address space, VFIO instead enables IOTLB
  notifier handling and translation replay, skipping the RAM listener and
  therefore not installing stage-2 mappings.

For accelerated SMMUv3, correct operation requires the S1+S2 nesting
model, and therefore VFIO must take the "system address space" path so
that stage-2 mappings are properly built. Returning an alias of the
system address space ensures this happens. Returning the IOMMU address
space would omit stage-2 mapping and break nested translation.

Another option considered was forcing a pre-registration path using
vfio_prereg_listener() to set up stage-2 mappings, but this requires
changes in VFIO core and was not adopted. Returning an alias of the
system address space keeps the design aligned with existing VFIO/iommufd
nesting flows and avoids the need for cross-subsystem changes.

In summary:
 - vfio-pci devices(with iommufd as backend) return an address space
   aliased to system address space.
 - bridges and root ports return the IOMMU address space.

Reviewed-by: Jonathan Cameron <[email protected]>
Reviewed-by: Nicolin Chen <[email protected]>
Reviewed-by: Eric Auger <[email protected]>
Tested-by: Eric Auger <[email protected]>
Tested-by: Zhangfei Gao <[email protected]>
Signed-off-by: Shameer Kolothum <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-01-29 13:32:04 +00:00
Shameer Kolothum d1c585db8b hw/pci-bridge/pci_expander_bridge: Move TYPE_PXB_PCIE_DEV to header
Move the TYPE_PXB_PCIE_DEV definition to header so that it can be
referenced by other code in subsequent patch.

Reviewed-by: Jonathan Cameron <[email protected]>
Reviewed-by: Eric Auger <[email protected]>
Reviewed-by: Nicolin Chen <[email protected]>
Tested-by: Eric Auger <[email protected]>
Tested-by: Zhangfei Gao <[email protected]>
Signed-off-by: Shameer Kolothum <[email protected]>
Reviewed-by: Yi Liu <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-01-29 13:32:04 +00:00
Shameer Kolothum 84ce97290c hw/pci/pci: Add optional supports_address_space() callback
Introduce an optional supports_address_space() callback in PCIIOMMUOps to
allow a vIOMMU implementation to reject devices that should not be attached
to it.

Currently, get_address_space() is the first and mandatory callback into the
vIOMMU layer, which always returns an address space. For certain setups, such
as hardware accelerated vIOMMUs (e.g. ARM SMMUv3 with accel=on), attaching
emulated endpoint devices is undesirable as it may impact the behavior or
performance of VFIO passthrough devices, for example, by triggering
unnecessary invalidations on the host IOMMU.

The new callback allows a vIOMMU to check and reject unsupported devices
early during PCI device registration.

Cc: Michael S. Tsirkin <[email protected]>
Reviewed-by: Jonathan Cameron <[email protected]>
Reviewed-by: Eric Auger <[email protected]>
Reviewed-by: Nicolin Chen <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Tested-by: Eric Auger <[email protected]>
Tested-by: Zhangfei Gao <[email protected]>
Signed-off-by: Shameer Kolothum <[email protected]>
Reviewed-by: Yi Liu <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-01-29 13:32:04 +00:00
Shameer Kolothum e4eab7d4a1 hw/pci/pci: Move pci_init_bus_master() after adding device to bus
During PCI hotplug, in do_pci_register_device(), pci_init_bus_master()
is called before storing the pci_dev pointer in bus->devices[devfn].

This causes a problem if pci_init_bus_master() (via its
get_address_space() callback) attempts to retrieve the device using
pci_find_device(), since the PCI device is not yet visible on the bus.

Fix this by moving the pci_init_bus_master() call to after the device
has been added to bus->devices[devfn].

This prepares for a subsequent patch where the accel SMMUv3
get_address_space() callback retrieves the pci_dev to identify the
attached device type.

No functional change intended.

Cc: Michael S. Tsirkin <[email protected]>
Reviewed-by: Jonathan Cameron <[email protected]>
Reviewed-by: Eric Auger <[email protected]>
Reviewed-by: Nicolin Chen <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Tested-by: Eric Auger <[email protected]>
Tested-by: Zhangfei Gao <[email protected]>
Signed-off-by: Shameer Kolothum <[email protected]>
Reviewed-by: Yi Liu <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-01-29 13:32:04 +00:00
Shameer Kolothum 7d7931257d hw/arm/smmuv3-accel: Initialize shared system address space
To support accelerated SMMUv3 instances, introduce a shared system-wide
AddressSpace (shared_as_sysmem) that aliases the global system memory.
This shared AddressSpace will be used in a subsequent patch for all
vfio-pci devices behind all accelerated SMMUv3 instances within a VM.

Sharing a single system AddressSpace ensures that all devices behind
accelerated SMMUv3s use the same system address space pointer. This
allows VFIO/iommufd to reuse a single IOAS ID in iommufd_cdev_attach(),
enabling the Stage-2 page tables to be shared within the VM rather than
duplicated for each SMMUv3 instance.

Reviewed-by: Nicolin Chen <[email protected]>
Reviewed-by: Jonathan Cameron <[email protected]>
Reviewed-by: Eric Auger <[email protected]>
Tested-by: Zhangfei Gao <[email protected]>
Tested-by: Eric Auger <[email protected]>
Signed-off-by: Shameer Kolothum <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-01-29 13:32:04 +00:00
Shameer Kolothum 79fcbec80a hw/arm/smmuv3-accel: Introduce smmuv3 accel device
Set up dedicated PCIIOMMUOps for the accel SMMUv3, since it will need
different callback handling in upcoming patches. This also adds a
CONFIG_ARM_SMMUV3_ACCEL build option so the feature can be disabled
at compile time. Because we now include CONFIG_DEVICES in the header to
check for ARM_SMMUV3_ACCEL, the meson file entry for smmuv3.c needs to
be changed to arm_ss.add.

The “accel” property isn’t user visible yet and it will be introduced in
a later patch once all the supporting pieces are ready.

Signed-off-by: Shameer Kolothum <[email protected]>
Reviewed-by: Nicolin Chen <[email protected]>
Reviewed-by: Jonathan Cameron <[email protected]>
Reviewed-by: Eric Auger <[email protected]>
Tested-by: Zhangfei Gao <[email protected]>
Tested-by: Eric Auger <[email protected]>
Signed-off-by: Shameer Kolothum <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-01-29 13:32:04 +00:00
Shameer Kolothum 797fffedac hw/arm/smmu-common: Make iommu ops part of SMMUState
Make iommu ops part of SMMUState and set to the current default smmu_ops.
No functional change intended. This will allow SMMUv3 accel implementation
to set a different iommu ops later.

Reviewed-by: Jonathan Cameron <[email protected]>
Reviewed-by: Nicolin Chen <[email protected]>
Reviewed-by: Eric Auger <[email protected]>
Tested-by: Zhangfei Gao <[email protected]>
Tested-by: Eric Auger <[email protected]>
Signed-off-by: Shameer Kolothum <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-01-29 13:32:04 +00:00
Shameer Kolothum 8d9633f1ed hw/arm/smmu-common: Factor out common helper functions and export
Factor out common helper functions and export. Subsequent patches for
smmuv3 accel support will make use of this.

Signed-off-by: Nicolin Chen <[email protected]>
Reviewed-by: Eric Auger <[email protected]>
Signed-off-by: Shameer Kolothum <[email protected]>
Reviewed-by: Jonathan Cameron <[email protected]>
Tested-by: Zhangfei Gao <[email protected]>
Tested-by: Eric Auger <[email protected]>
Signed-off-by: Shameer Kolothum <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-01-29 13:32:04 +00:00
Nicolin Chen cd438bf9bd backends/iommufd: Introduce iommufd_backend_alloc_vdev
Add a helper to allocate an iommufd device's virtual device (in the user
space) per a viommu instance.

While at it, introduce a struct IOMMUFDVdev for later use by vendor
IOMMU implementations.

Signed-off-by: Nicolin Chen <[email protected]>
Reviewed-by: Eric Auger <[email protected]>
Signed-off-by: Shameer Kolothum <[email protected]>
Reviewed-by: Jonathan Cameron <[email protected]>
Tested-by: Zhangfei Gao <[email protected]>
Tested-by: Eric Auger <[email protected]>
Signed-off-by: Shameer Kolothum <[email protected]>
Reviewed-by: Yi Liu <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-01-29 13:32:04 +00:00
Nicolin Chen f2d31df0d9 backends/iommufd: Introduce iommufd_backend_alloc_viommu
Add a helper to allocate a viommu object.

Also introduce a struct IOMMUFDViommu that can be used later by vendor
IOMMU implementations.

Signed-off-by: Nicolin Chen <[email protected]>
Reviewed-by: Eric Auger <[email protected]>
Reviewed-by: Jonathan Cameron <[email protected]>
Signed-off-by: Shameer Kolothum <[email protected]>
Tested-by: Zhangfei Gao <[email protected]>
Tested-by: Eric Auger <[email protected]>
Signed-off-by: Shameer Kolothum <[email protected]>
Reviewed-by: Yi Liu <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-01-29 13:32:04 +00:00
Richard Henderson 65fb9de488 Merge tag 'pr-build_fix-20260128' of https://gitlab.com/pbo-linaro/qemu into staging
Fix build with --enable-modules

# -----BEGIN PGP SIGNATURE-----
#
# iQGzBAABCgAdFiEEZrmU7KFPfy5auggff5BUDQoc0A8FAml6uYIACgkQf5BUDQoc
# 0A+1fgv/VBYR4Svtjbpq9GmAzXYSdqI5WhbDTPMH0mC9dFoFHdpZL0hOiZnXkoXs
# fXLBJkB8zJPTE+f7q9FQS6LTTJVkazSE+EmuqnewQbL4mueEgK1ZZelg2aRmIBCg
# nyQFh+X+p3z6Kt7aErLX4W1tH4OySLrGEu+QCHoSiRBpEPuK9Qeb5chvS9GmEq5o
# 7UGE4eiJ9y3Q7uXx32xo36zaLSwEkUHURp8FVUVxg44z0xDH7JyiJetUQrdxHtWT
# DoAdJR+l1hIqCP60qyd9JZFNNm1QgGBI3D7b0A7GArc/Soa96ikWTpoPid3OK0qd
# l1FxnfacoFOmNKa9kbEtupDGBzs6n3lkjzJ13EgF3pmAvTYKk/efCZ58Or1GdsK8
# IJVPzVx979XrXEIzpNs3KxVvR21TiRQvpF4dOa3GBcHYw+EgFKGoo4sKboYV21CC
# wZDUM7w2iFZKNGr73VzLI+PZUqBSFdCmXGTVddgKFcibnjxizzTJgjz+C1urew9M
# 7E7R/XrT
# =wFh0
# -----END PGP SIGNATURE-----
# gpg: Signature made Thu 29 Jan 2026 12:36:02 PM AEDT
# gpg:                using RSA key 66B994ECA14F7F2E5ABA081F7F90540D0A1CD00F
# gpg: Good signature from "Pierrick Bouvier <[email protected]>" [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: 66B9 94EC A14F 7F2E 5ABA  081F 7F90 540D 0A1C D00F

* tag 'pr-build_fix-20260128' of https://gitlab.com/pbo-linaro/qemu:
  meson: fix build of qemu-system-microblaze with --enable-modules

Signed-off-by: Richard Henderson <[email protected]>
2026-01-29 13:29:33 +11:00
Pierrick Bouvier 8eff45dfe9 meson: fix build of qemu-system-microblaze with --enable-modules
A previous commit wrongly skipped including the generated modinfo in
case hw_arch dictionary ends up being empty.
Fix that by adding an empty source set in dictionary in this case.

Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3280
Fixes: e8efe5ff4 (meson: Do not try to build module for empty per-target hw/ directory)
Signed-off-by: Pierrick Bouvier <[email protected]>
2026-01-28 17:35:52 -08:00
Richard Henderson 9ad7f544c6 Merge tag 'pull-request-2026-01-27' of https://gitlab.com/thuth/qemu into staging
* gitlab: preserve base rules for container template
* Fix some issues to make QEMU compilable on non-mainstream distros again
* Enforce sha256 as hashsum algorithm for all functional tests

# -----BEGIN PGP SIGNATURE-----
#
# iQJFBAABCgAvFiEEJ7iIR+7gJQEY8+q5LtnXdP5wLbUFAml4ytMRHHRodXRoQHJl
# ZGhhdC5jb20ACgkQLtnXdP5wLbX8LQ//dceTUIF2Ynakhce4MZjsHzM9YZz86knw
# 3MK8172k05Vcb/e4vlsqLv/gJYAu1XlZRGsEjSfFBi11FSQMORV3c3QLm0MkSIzR
# 7L3Zt9YnwBMEdMjJ/3moLPegRvE1kE/Kaa5t/wWP/eh34jgsubcnALktw9K5vkBP
# B/gYMKP5ZgYM+3UyNvy3FmtNGz4+U8IeURzqmgYvZ87BkCfT4DAR8WWBgjasGRSZ
# MjOYsJwtVLnm1eSzZRiJKAwzLgsQMJOp3UJFvGSTYFgalM+YP/MoV4aia3ZyKr5H
# iZQfqTdvRnp2KIJKsOJIYop3do/xUylKDYCXxESF61QyFugrA9igZ9i4tTtLBTJf
# M6ZDqdJIZj2auU4Pps6DXDjcpZcOpnhTI3exg4aCLDdUZt9DsZrdjGYnM6rf0TeK
# g7Cr+TXHEt8nMTymH3NXZLPCOyzpBbOH7a6ZbblLkOhV/KSZaazBBzpoC3FHKdfu
# l61+wbre3JCNSLUyNRh2eH112N2JR/J3Yg/8CLcAgQjsJfko701nfnb+kC8eoVtP
# YTCZmPPrbaSzzNrEamDC3YafyX3/92Y9NLiS6oEeoOog2Fy69V5tF4HzOkA4riBx
# LVk6aLkScJYYM/MI4vUYhYnK3yu9u9ioDDQJfPYgPOj5ariON7AA6ftU/WZkW7xL
# EP7xytLZBUE=
# =vTKP
# -----END PGP SIGNATURE-----
# gpg: Signature made Wed 28 Jan 2026 01:25:23 AM AEDT
# gpg:                using RSA key 27B88847EEE0250118F3EAB92ED9D774FE702DB5
# gpg:                issuer "[email protected]"
# gpg: Good signature from "Thomas Huth <[email protected]>" [unknown]
# gpg:                 aka "Thomas Huth <[email protected]>" [unknown]
# gpg:                 aka "Thomas Huth <[email protected]>" [unknown]
# gpg:                 aka "Thomas Huth <[email protected]>" [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: 27B8 8847 EEE0 2501 18F3  EAB9 2ED9 D774 FE70 2DB5

* tag 'pull-request-2026-01-27' of https://gitlab.com/thuth/qemu:
  tests/functional: Enforce sha256 as hashsum algorithm for all tests
  tests/vm: Make the haiku VM usable again
  tests/vm: Update netbsd VM to version 10.1
  pc-bios/optionrom: Use 32-bit linker emulation for the optionroms
  tests/tracetool: Honor the Python interpreter that "configure" detected
  tests/functional/x86_64: Use the right Python interpreter & fix format string
  tests/functional/x86_64: Limit the memlock test to Linux hosts
  tests/functional/riscv64: Silence warnings from Pylint in the boston test
  gitlab: preserve base rules for container template

Signed-off-by: Richard Henderson <[email protected]>
2026-01-28 10:04:17 +11:00
Richard Henderson ea603cbe0b Merge tag 'pull-11.0-maintainer-updates-270126-1' of https://gitlab.com/stsquad/qemu into staging
MAINTAINER updates

  - fix some malformed entries (names, lists, status)
  - drop Mads from HVF and Tracing reviews
  - add Pierrick for overall docs catcher
  - add Pierrick as a linux-user reviewer
  - add Pierrick as a co-maintainer for plugins
  - set linux-user to Odd Fixes
  - update core Arm to "Supported"

# -----BEGIN PGP SIGNATURE-----
#
# iQEzBAABCgAdFiEEZoWumedRZ7yvyN81+9DbCVqeKkQFAml4pGcACgkQ+9DbCVqe
# KkQA6wgAkkXh8ZfPmtqYurG75nAPT37t70OUyFxxf0/MmbvERzIuBrnl7AOxsKWt
# NGo0CnP/jD3hiC9f8ciUgp7XqS8xUMdbflkt7h/opoiD+72I6G1K7Z8IS6vIF++o
# xhGj6fOVQlVfib/wMFFSGbJ+W+Uii1zuX4N1dTT1xVMFs833aj6dQ3x2qHKXBO1S
# K2Hlj6kfcIOW0l85LK6SmpNnSlmK3seolXDcceQ6cqZtofjmrApLqIGuM4lyA6uG
# qNjKH3J2omFI7eUAvxu+xa/UT1zKJQFmH9f7qUKcXhHd5z7unIj/RrUEMRu/moge
# 3F7r7LCOJ5tJxZ86DdO52b2yf1nMEA==
# =CyCY
# -----END PGP SIGNATURE-----
# gpg: Signature made Tue 27 Jan 2026 10:41:27 PM AEDT
# gpg:                using RSA key 6685AE99E75167BCAFC8DF35FBD0DB095A9E2A44
# gpg: Good signature from "Alex Bennée (Master Work Key) <[email protected]>" [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.0-maintainer-updates-270126-1' of https://gitlab.com/stsquad/qemu:
  MAINTAINERS: add co-maintainer for TCG Plugins
  MAINTAINERS: be realistic about *-user
  MAINTAINERS: add reviewer for linux-user
  MAINTAINERS: update Arm to Supported status
  MAINTAINERS: add maintainer for docs/
  MAINTAINERS: remove myself as reviewer
  MAINTAINERS: regularise the status fields
  MAINTAINERS: fix libvirt entry
  MAINTAINERS: fix missing names

Signed-off-by: Richard Henderson <[email protected]>
2026-01-28 10:03:57 +11:00
Richard Henderson 7ecd3f7107 Merge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging
* rust: move binding generation to bindings/
* rust: fixes for Windows
* target/i386/tcg: fix a few instructions that do not support VEX.L=1
* target/i386/tcg: various cleanups

# -----BEGIN PGP SIGNATURE-----
#
# iQFIBAABCgAyFiEE8TM4V0tmI4mGbHaCv/vSX3jHroMFAml4h1QUHHBib256aW5p
# QHJlZGhhdC5jb20ACgkQv/vSX3jHroP56Qf/cqjdwUO8GUNP5Og2s/D2wjiTeSTq
# 9oer3Jq2OUyh5zqt6oVXLjWIV6GOjaak9aSa8b23Ej4jC+Zjc0RRN9s6qXkCfvM7
# yrfQWnbIkkSmCWIp5stsqtXtE11wMWh25gjVNzj0tuPxNEzgYG8lyZT3/vgZ3B/o
# OO6s8HxNdgGrP5zeIMNeaF0OkdyF/JADv5NrKH57HYRyYE0ZMmn0G/RPxecyS7se
# W0KW7H6F6RqFPNf7W0Y9+uQjDttrinQ9Ni2+IIgZ9GaoIRloqslclmof9fxMizK9
# aqxuC8XmJkgF13V/9mLy+iZKO9fhlaCJ0CsxZqscmrzPNs7QWlJ3L9nDng==
# =4pTP
# -----END PGP SIGNATURE-----
# gpg: Signature made Tue 27 Jan 2026 08:37:24 PM AEDT
# gpg:                using RSA key F13338574B662389866C7682BFFBD25F78C7AE83
# gpg:                issuer "[email protected]"
# gpg: Good signature from "Paolo Bonzini <[email protected]>" [unknown]
# gpg:                 aka "Paolo Bonzini <[email protected]>" [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: 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:
  rust/hpet: remove stale TODO comment
  target/i386/tcg: cleanup #ifdef TARGET_X86_64
  target/i386/tcg: replace havesib variable with the SIB byte itself
  target/i386/tcg: merge decode_modrm and decode_modrm_address split
  target/i386/tcg: remove dead constants
  target/i386/tcg: fix typo in dpps/dppd instructions
  target/i386/tcg: fix a few instructions that do not support VEX.L=1
  qdev: add hw/core/gpio.c to libhwcore
  rust: move hwcore::sysbus to system crate
  rust: move binding generation to bindings/
  rust: move class_init to an extension trait
  rust: hwcore: add chardev symbols to integration tests
  rust: trace: libc does not have syslog on windows

Signed-off-by: Richard Henderson <[email protected]>
2026-01-28 10:03:37 +11:00
Thomas Huth 161ea5a634 tests/functional: Enforce sha256 as hashsum algorithm for all tests
The functional testing framework currently supports both, sha256
and sha512 as hashsums for the assets. However, all but one test
currently only use sha256, which should also be sufficient according
to the current security standards. Having two algorithms around already
caused some confusion (e.g. the clean_functional_cache.py script only
supports sha256 right now), so standardize now on enforcing sha256
before more tests use a mix of the two algorithms.

Reviewed-by: Daniel P. Berrangé <[email protected]>
Reviewed-by: Aditya Gupta <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
2026-01-27 15:20:43 +01:00
Thomas Huth f2981f9901 tests/vm: Make the haiku VM usable again
The haiku VM bitrotted in the course of time. Make sure to use the
latest version of the repositories here and install missing pieces
like "pip" and "tomli" now.

Since we nowadays also install our own version of meson in our venv,
this also requires a change to our configure script: On Haiku, the
meson binary shows up as pyvenv/non-packaged/bin/meson here, and not
in the expected location pyvenv/bin/meson. Adjust the "meson" variable
to point to that Haiku-specific location to fix this issue. See also:
https://github.com/haiku/haiku/blob/r1beta5/docs/user/storage/storageintro.dox

And finally, with the new toolchain from the beta 5, we also have to
compile with "-pie", otherwise the linker complains about bad relocations
in the object files, so allow compiling with PIE in the configure script
now.

Reviewed-by: Prasad Pandit <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
2026-01-27 15:20:43 +01:00
Thomas Huth 6f028a17a9 tests/vm: Update netbsd VM to version 10.1
NetBSD 10.1 has been released since more than a year, so it's time to
update our VM to that version.
Apart from the usual changes in the installation process, we also have
to disable the installation of the "jpeg" package now, otherwise the
package installation fails with an error message like this:

 pkg_add: jpeg-9fnb1: conflicts with `libjpeg-turbo-[0-9]*', and
 `libjpeg-turbo-3.1.3' is installed.

We also have to drop the executable bits from scripts/qemu-plugin-symbols.py
to force meson to use the detected Python interpreter instead of executing
the file directly (which tries to use the Python interpreter from the file's
shebang line).

Signed-off-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
2026-01-27 15:20:43 +01:00
Thomas Huth e4f1a9b1da pc-bios/optionrom: Use 32-bit linker emulation for the optionroms
Without this linker flag, the linking fails on NetBSD v10.1 with:

 ld: i386 architecture of input file `multiboot.o' is incompatible with i386:x86-64 output
 ld: i386 architecture of input file `multiboot_dma.o' is incompatible with i386:x86-64 output

Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
2026-01-27 15:20:43 +01:00
Thomas Huth 661a47ff1e tests/tracetool: Honor the Python interpreter that "configure" detected
The tracetool tests currently fail if the host installation does not
have a "python3" binary (and you compiled QEMU by selecting a different
one during the "configure" step). This happens because tracetool-test.py
executes scripts/tracetool.py directly, so that this script is run via
its shebang line. To fix the issue, use the same Python interpreter to
run scripts/tracetool.py as we are using to run the tracetool-test.py
script.

Suggested-by: Paolo Bonzini <[email protected]>
Reviewed-by: Daniel P. Berrangé <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
2026-01-27 15:20:43 +01:00
Thomas Huth b6c2c05a87 tests/functional/x86_64: Use the right Python interpreter & fix format string
The bad_vmstate test currently fails if the host does not have a "python3"
binary in $PATH because the vmstate-static-checker.py script is executed
directly, so that it gets run via its shebang line. Use the right Python
interpreter from sys.executable to fix this problem.

Additionally, there was another bug with the formatting of the error
message in case of failures: The "+" operator can only concatenate strings,
but not strings with integers. Use a proper format string here instead.

Reviewed-by: Daniel P. Berrangé <[email protected]>
Acked-by: Fabiano Rosas <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
2026-01-27 15:20:43 +01:00
Thomas Huth ef325d0c87 tests/functional/x86_64: Limit the memlock test to Linux hosts
The memlock test analyzes /proc/*/status files and expects the layout
from Linux in there. However, these files also exist on NetBSD hosts
with a completely different layout, causing this test to fail. Thus
limit the test to Linux hosts now. We already have a decorator to
skip a test if it is running on a certain host system, but in this
case, we rather want to skip if we are not running on a specific
host system, so introduce a new @skipUnlessOperatingSystem decorator
for this job.

Reviewed-by: Daniel P. Berrangé <[email protected]>
Reviewed-by: Zhao Liu <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
2026-01-27 15:20:43 +01:00
Thomas Huth b9a4553e29 tests/functional/riscv64: Silence warnings from Pylint in the boston test
Pylint complains:

 tests/functional/riscv64/test_boston.py:1:0: C0114:
  Missing module docstring (missing-module-docstring)
 tests/functional/riscv64/test_boston.py:95:8: C0415:
  Import outside toplevel (subprocess.run, subprocess.PIPE) (import-outside-toplevel)
 tests/functional/riscv64/test_boston.py:112:17: W1510:
  'subprocess.run' used without explicitly defining the value for 'check'. (subprocess-run-check)
 tests/functional/riscv64/test_boston.py:95:8: W0611:
  Unused PIPE imported from subprocess (unused-import)

Rework the code a little bit to make the linter happy.

Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Tested-by: Chao Liu <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
2026-01-27 15:20:43 +01:00
Daniel P. Berrangé 815567b4ea gitlab: preserve base rules for container template
When extending the container template to allow scheduled pipelines in
upstream context, we must ensure that all the existing rules defined
by .base_job_template are preserved.

Fortunately since the new rule for scheduled pipelines can come at
the head of all other rules, not in the middle, we can just the obscure
'!reference' syntax to pull in all the pre-existing rules as a single
block.

This fixes

 * stable branches using the wrong tag name in container images
 * pushes to forks unconditionally running container builds

Fixes: 8bec7b9874
Signed-off-by: Daniel P. Berrangé <[email protected]>
Tested-by: Michael Tokarev <[email protected]>
Fixes: 8bec7b9874 ("gitlab: add a weekly container building job")
Message-ID: <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
2026-01-27 15:20:35 +01:00
Pierrick Bouvier 74be6f8bc9 MAINTAINERS: add co-maintainer for TCG Plugins
I would like to help Alex to maintain TCG Plugins. We talked about it
and he will keep the priority for merging series, but I can occasionally
merge some of them when there is a special interest.

Signed-off-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alex Bennée <[email protected]>
2026-01-27 11:37:35 +00:00
Alex Bennée e813d3be36 MAINTAINERS: be realistic about *-user
Looking at the merges for the last year:

  $ git shortlog --merges --since "last year" *-user/ accel/tcg/user-exec* hw/core/cpu-user.c include/user/ scripts/qemu-binfmt-conf.sh scripts/update-syscalltbl.sh scripts/update-mips-syscall-args.sh tests/functional/arm/test_bflt.py tests/vm/*bsd

  Richard Henderson (4):
        Merge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging
        Merge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging
        Merge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging
        Merge tag 'pull-tcg-20251019' of https://gitlab.com/rth7680/qemu into staging

  Stefan Hajnoczi (12):
        Merge tag 'linux-user-fix-gupnp-pull-request' of https://github.com/hdeller/qemu-hppa into staging
        Merge tag 'pull-10.0-testing-and-gdstub-updates-100225-1' of https://gitlab.com/stsquad/qemu into staging
        Merge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging
        Merge tag 'pull-loongarch-20250424' of https://github.com/gaosong715/qemu into staging
        Merge tag 'pull-misc-2025-04-24' of https://repo.or.cz/qemu/armbru into staging
        Merge tag 'pull-trivial-patches' of https://gitlab.com/mjt0k/qemu into staging
        Merge tag 'hppa-fpe-fixup-pull-request' of https://github.com/hdeller/qemu-hppa into staging
        Merge tag 'pull-target-arm-20250704' of https://gitlab.com/pm215/qemu into staging
        Merge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging
        Merge tag 'pull-10.1-rc0-maintainer-140725-1' of https://gitlab.com/stsquad/qemu into staging
        Merge tag 'for_upstream' of https://git.kernel.org/pub/scm/virt/kvm/mst/qemu into staging
        Merge tag 'accel-20250715' of https://github.com/philmd/qemu into staging

None of the pull requests have come through the maintainers and while
there are a fair number of commits overall they have been mostly bug
fixes, re-factoring clean-ups and the occasional new syscall/ioctl
handling.

We should reflect the current status so users don't have unrealistic
expectations of how quickly things can get reviewed and merged.

Reviewed-by: Warner Losh <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alex Bennée <[email protected]>
2026-01-27 11:37:35 +00:00
Pierrick Bouvier ca25f18b5c MAINTAINERS: add reviewer for linux-user
I had interest in this area for some time, and would like to help
reviewing it.

Signed-off-by: Pierrick Bouvier <[email protected]>
Acked-by: Laurent Vivier <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Tested-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alex Bennée <[email protected]>
2026-01-27 11:37:33 +00:00
Alex Bennée 8e61c618f4 MAINTAINERS: update Arm to Supported status
We are involved in lots of areas of the QEMU code base but as I'm sure
most developers will realise we are actively funded to support the Arm
ecosystem for both emulation and virtualisation use-cases. Lets make
that clear in MAINTAINERS to keep parity with the other Supported
architectures.

Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alex Bennée <[email protected]>
2026-01-27 11:37:33 +00:00
Pierrick Bouvier 3889460440 MAINTAINERS: add maintainer for docs/
I would like to help maintaining qemu documentation and I've been
invited by Alex to apply as maintainer.

Files in docs/ that are already maintained will continue to be under
their respective maintainer. The goal here is to have someone that can
help on all other files that don't have an official maintainer.

Signed-off-by: Pierrick Bouvier <[email protected]>
Acked-by: Daniel P. Berrangé <[email protected]>
Acked-by: Thomas Huth <[email protected]>
Acked-by: Alex Bennée <[email protected]>
Acked-by: Markus Armbruster <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Tested-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alex Bennée <[email protected]>
2026-01-27 11:37:30 +00:00
Mads Ynddal 2430b05fbe MAINTAINERS: remove myself as reviewer
My work has changed focus, and I do not have the time to continue.

Signed-off-by: Mads Ynddal <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alex Bennée <[email protected]>
2026-01-27 11:35:38 +00:00
Alex Bennée a986231df0 MAINTAINERS: regularise the status fields
Orphaned isn't a state, Orphan is. Likewise all the other "Odd Fixes"
are capitalised so fix the ones that are not.

Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alex Bennée <[email protected]>
2026-01-27 11:35:38 +00:00
Alex Bennée aca1cc9973 MAINTAINERS: fix libvirt entry
We have a particular tag for lists so lets use it.

Signed-off-by: Markus Armbruster <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Reviewed-by: Cornelia Huck <[email protected]>
Reviewed-by: Daniel P. Berrangé <[email protected]>
Reviewed-by: Ján Tomko <[email protected]>
Message-Id: <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alex Bennée <[email protected]>
2026-01-27 11:35:38 +00:00
Alex Bennée 2106da94dc MAINTAINERS: fix missing names
The form is Name <email> so lets fix that up before we enforce it.

Reviewed-by: Pierrick Bouvier <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alex Bennée <[email protected]>
2026-01-27 11:35:38 +00:00
Mohd Kashif Khan df8dfc3b60 rust/hpet: remove stale TODO comment
The irq binding is already implemented in the following line, so the TODO comment is obsolete.

Signed-off-by: Mohd Kashif Khan <[email protected]>
Reviewed-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-01-27 10:37:11 +01:00
Paolo Bonzini 2a52067b06 target/i386/tcg: cleanup #ifdef TARGET_X86_64
32-bit TCG opcodes produced for the i386 target usually looks the same
as 64-bit TCG opcodes produced for the x86_64.  The special one that
needs extensions is 32-bit TCG opcodes produced for the x86_64 target.
Make all #ifdefs look the same, like this:

    case MO_32:
  #ifdef TARGET_X86_64
      /* code using 32-bit opcodes */

    case MO_64:
  #endif
      /* code using target_long opcodes */

  default:
    g_assert_not_reached();

Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
2026-01-27 08:57:52 +01:00
Paolo Bonzini 5585d072c6 target/i386/tcg: replace havesib variable with the SIB byte itself
Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
2026-01-27 08:57:52 +01:00
Paolo Bonzini a1356c5677 target/i386/tcg: merge decode_modrm and decode_modrm_address split
Unlike the older code in translate.c, mod=11b *is* filtered out earlier
by decode_modrm, and it would have returned bogus code.  Since the register
case is so simple, just inline decode_modrm_address into its caller instead
of removing the "if".

Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
2026-01-27 08:57:52 +01:00
Paolo Bonzini 30ebb65f83 target/i386/tcg: remove dead constants
NB_OP_SIZES has been dead since the conversion to TCG, REG_L_OFFSET
since 2015, the others somewhere in the middle.

Reviewed-by: Richard Henderson <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
2026-01-27 08:57:52 +01:00
Paolo Bonzini d66532600f target/i386/tcg: fix typo in dpps/dppd instructions
Their gen_* functions were incorrectly named gen_VDDPS and gen_VDDPD.

Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
2026-01-27 08:57:52 +01:00
Paolo Bonzini 2eb8d97343 target/i386/tcg: fix a few instructions that do not support VEX.L=1
Match the contents of table 2-17 ("#UD Exception and VEX.L Field Encoding")
in the SDM, for instruction in exception class 5.  They were incorrectly
accepting 256-bit versions that do not exist.

Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
2026-01-27 08:57:52 +01:00
Paolo Bonzini fe367cbe39 qdev: add hw/core/gpio.c to libhwcore
While GPIO functionality is not used by user-mode emulation, it is
conceptually part of qdev - GPIO pins are included in DeviceState
independent of whether this is system or user-mode emulation.

For the Rust bindings, having GPIO functionality in system_ss causes
a problem because, for simplicity, all methods of DeviceState are
included in the Rust hwcore crate.  On Windows, rustc is not able
to do dead code elimination as well as on other OSes and this causes
an undefined symbol error, because gpio.c is not linked into the
rust/hw/core/rust-hwcore-rs-integration test binary.

To fix it, move gpio.c out of system_ss and into libhwcore.
Alternatively, it would be possible to define some DeviceState
methods also in the system crate, using for example a separate trace
SystemDeviceMethods.  For now, keep all the methods in one crate and
link 200 unused lines of code into user-mode emulators.

Signed-off-by: Paolo Bonzini <[email protected]>
2026-01-27 08:57:52 +01:00
Paolo Bonzini 1713498c0d rust: move hwcore::sysbus to system crate
This inverts the dependency from hwcore to system, replacing it with
a dependency from system to hwcore.  It also matches how hw/core/sysbus.h
is part of the system-sys crate, and hw/core/sysbus.c is part of system_ss
on the C side.

This fixes a linker error in hwcore integration tests on msys2.

Signed-off-by: Paolo Bonzini <[email protected]>
2026-01-27 08:57:52 +01:00
Marc-André Lureau c899071b5a rust: move binding generation to bindings/
Move raw FFI bindings generation to separate crates.  This makes it
possible to reuse bindgen declarations for a header file in its
dependencies (this was not the case before this change), while keeping
multiple -sys crates to avoid rebuilding all the code whenever
something changes.

Because the -sys crates are generated in dependency order, this also
enforces that the crates are organized in something that resembles
the dependencies between C headers.

The meson.build for rust-safe crates becomes simpler, and it should be
possible in the future to let Meson's cargo support handle most of it.

Signed-off-by: Marc-André Lureau <[email protected]>
[General cleanup and Python script. - Paolo]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-01-27 08:57:52 +01:00
Paolo Bonzini f9bbbde1ed rust: move class_init to an extension trait
Prepare for having ObjectClass, DeviceClass and SysbusDeviceClass
defined outside the hwcore and qom crates.  It then becomes
impossible to add a method to them.

Extracted from a patch by Marc-André Lureau.

Signed-off-by: Paolo Bonzini <[email protected]>
2026-01-27 08:57:52 +01:00
Paolo Bonzini e079272604 rust: hwcore: add chardev symbols to integration tests
Even though they are not used, rustc does not elide its symbols on msys2.
This causes a linker error.

Signed-off-by: Paolo Bonzini <[email protected]>
2026-01-27 08:57:52 +01:00
Paolo Bonzini a05b986d74 rust: trace: libc does not have syslog on windows
Reported-by: Thomas Huth <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
2026-01-27 08:57:51 +01:00
Richard Henderson f26976b9d3 Merge tag 'pull-vfio-20260126' of https://github.com/legoater/qemu into staging
vfio queue:

* Fixes for vfio-user and CPR
* Fixes issues detected by Coverity
* Updates linux-headers to Linux v6.19-rc1
* Adds support for the creation of dma-buf objects for PCI BARs. This
  allows safe P2P DMA operations when using iommufd host backend.

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCAAdFiEEoPZlSPBIlev+awtgUaNDx8/77KEFAml3MhsACgkQUaNDx8/7
# 7KH5dg/+PKQIuokpJOgbxBjQNvrw4qAehsuv799+tmCJ621utRWplSqnLls2x8+R
# jIu1v8T830Cxl7C+KcaSthxH+dcCvvVtV1YgQUbpjJJU/M/D5yq/Nc6N4KRGHE7t
# zTs1nUx4kTZ70HTbpoDgnDbZpTpbhfk3a6yNk+e/JSgJV3rf58z7ZsqaGMtRxp10
# eK9xSXzFS2MOwHPWsE33BL6aju8N1BeHmqW+j3Thsoh/aGxoTOT5wUSuJ0n1UmWx
# X53Cc62XS0ToGFCYqwbe06kZtn+n+xP3DakLoaj6xqdjuGtNn2CFE3XWSTRJKFqJ
# B3ODyBhOuZkyJhluQ3dBqd+CzE5DCiNPxvPAEAHZjNoAD2FRiGT/ZEHY5+49yIMq
# sMRm1qluNYFU17PvN3BjkQHcxDEpGu+f9NHp6/USMtdY4N9LgH8WkMjP/WAr/dXp
# hh/f8xJlzSAt8YfFgCWNEsWao1aaeOf6Lmn6A4MxV0TfBpas4s9eD+35Qrlt3GsI
# FhD1h8M8+vK/mn51JyQDWKCl9vjKvN8RIrHLS32T0PE0OVmT+d1w1/ZWlxmJeLld
# KVM1ex68zIX1xMdIK6Ygwv2KEMJpIe5JzOZSDeha1X+IgfjdM6ou2m5dVQ6sJp2d
# hJnEqtVOl7Pwn+DyEEmLVSIU2djqUHd2KESjt29u0T39WY95KGI=
# =R7jr
# -----END PGP SIGNATURE-----
# gpg: Signature made Mon 26 Jan 2026 08:21:31 PM AEDT
# gpg:                using RSA key A0F66548F04895EBFE6B0B6051A343C7CFFBECA1
# gpg: Good signature from "Cédric Le Goater <[email protected]>" [full]
# gpg:                 aka "Cédric Le Goater <[email protected]>" [full]

* tag 'pull-vfio-20260126' of https://github.com/legoater/qemu:
  vfio-user: update VFIOProxy flag constants to use the BIT() macro
  vfio-user: fix VFIO_PROXY_USE_MULTI constant value
  hw/vfio/region: Create dmabuf for PCI BAR per region
  hw/vfio: Add helper to retrieve device feature
  linux-headers: Update to Linux v6.19-rc1
  hw/vfio: cpr-iommufd: Fix wrong usage of migrate_add_blocker_modes
  vfio/migration: Fix page size calculation

Signed-off-by: Richard Henderson <[email protected]>
2026-01-27 07:14:11 +11:00
Mark Cave-Ayland 4c5e5d66f9 vfio-user: update VFIOProxy flag constants to use the BIT() macro
This should help avoid incorrect constant values being used in future. At
the same time we can remove the gap left for BIT(1) which was originally
intended for the VFIO_PROXY_NO_MMAP feature which was removed from later
versions of the vfio-user series.

Suggested-by: John Levon <[email protected]>
Signed-off-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: John Levon <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-01-26 08:30:04 +01:00
Mark Cave-Ayland 6a66c9f752 vfio-user: fix VFIO_PROXY_USE_MULTI constant value
The constant value should represent the next bit in the VFIOProxy flags which
is 0x10 and not 0x16.

Signed-off-by: Mark Cave-Ayland <[email protected]>
Fixes: 1a0c32a9da ("vfio-user: add coalesced posted writes")
Reviewed-by: John Levon <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-01-26 08:30:04 +01:00
Nicolin Chen 8cfaf22668 hw/vfio/region: Create dmabuf for PCI BAR per region
Linux now provides a VFIO dmabuf exporter to expose PCI BAR memory for P2P
use cases. Create a dmabuf for each mapped BAR region after the mmap is set
up, and store the returned fd in the region’s RAMBlock. This allows QEMU to
pass the fd to dma_map_file(), enabling iommufd to import the dmabuf and map
the BAR correctly in the host IOMMU page table.

If the kernel lacks support or dmabuf setup fails, QEMU skips the setup
and continues with normal mmap handling.

Tested-by: Nicolin Chen <[email protected]>
Reviewed-by: Zhenzhong Duan <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Signed-off-by: Nicolin Chen <[email protected]>
Signed-off-by: Shameer Kolothum <[email protected]>
Reviewed-by: Eric Auger <[email protected]>
Tested-by: Eric Auger <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-01-26 08:30:04 +01:00
Shameer Kolothum de36da106d hw/vfio: Add helper to retrieve device feature
Add vfio_device_get_feature() as a common helper to retrieve
VFIO device features.

No functional change intended.

Reviewed-by: Cédric Le Goater <[email protected]>
Signed-off-by: Shameer Kolothum <[email protected]>
Reviewed-by: Eric Auger <[email protected]>
Tested-by: Eric Auger <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-01-26 08:30:04 +01:00
Shameer Kolothum 49f6b93d07 linux-headers: Update to Linux v6.19-rc1
Mainly for adding support for VFIO DMABUF. While at it, update all
headers.

The header update breaks virtio-net due to virtio_net_hdr_v1_hash
changes. Include the virtio-net changes to avoid build and bisect
failures.

Cc: Michael S. Tsirkin <[email protected]>
Cc: Jason Wang <[email protected]>
Tested-by: Nicolin Chen <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Signed-off-by: Shameer Kolothum <[email protected]>
Reviewed-by: Eric Auger <[email protected]>
Tested-by: Eric Auger <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-01-26 08:30:04 +01:00
Jim Shu 0e387bd1df hw/vfio: cpr-iommufd: Fix wrong usage of migrate_add_blocker_modes
The return value of API is 0 for success and negative error code for
failure. We'll check if the return value equals to 0.
Also, the MIG_MODE should be CPR_TRANSFER and CPR_EXEC instead
of 2 same bits.

The API usage is aligned with 'hw/vfio/cpr-legacy.c' after these 2
changes.

Fixes: 3ca0a0ab05 ("migration: Use bitset of MigMode instead of variable arguments")
Signed-off-by: Jim Shu <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-01-26 08:30:04 +01:00
Zhenzhong Duan e3c659fee0 vfio/migration: Fix page size calculation
Coverity detected an issue of left shifting int by more than 31 bits leading
to undefined behavior.

In practice bcontainer->dirty_pgsizes always have some common page sizes
when dirty tracking is supported.

Resolves: Coverity CID 1644186
Resolves: Coverity CID 1644187
Resolves: Coverity CID 1644188
Fixes: 46c7633114 ("vfio/migration: Add migration blocker if VM memory is too large to cause unmap_bitmap failure").
Suggested-by: Cédric Le Goater <[email protected]>
Signed-off-by: Zhenzhong Duan <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-01-26 08:30:04 +01:00
Richard Henderson fea2d7a784 Merge tag 'linux-user-for-v11-pull-request' of https://github.com/hdeller/qemu-hppa into staging
linux-user: statx() syscall, termios2 support and futext() syscall fixes

v2:
Fix build error in which CentOS9 is lacking the definition of MADV_COLLAPSE

# -----BEGIN PGP SIGNATURE-----
#
# iHUEABYKAB0WIQS86RI+GtKfB8BJu973ErUQojoPXwUCaXSIawAKCRD3ErUQojoP
# X1HtAQDmDfFPKNNL9+tRr+6d2mzfc2mM4B8prJhh1LdUaDy6SwEAmf/M080jpH5W
# ljtBSN41MIOfS4s3qFs2O9uL096YgQE=
# =WcLZ
# -----END PGP SIGNATURE-----
# gpg: Signature made Sat 24 Jan 2026 07:52:59 PM AEDT
# gpg:                using EDDSA key BCE9123E1AD29F07C049BBDEF712B510A23A0F5F
# gpg: Good signature from "Helge Deller <[email protected]>" [unknown]
# gpg:                 aka "Helge Deller <[email protected]>" [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: 4544 8228 2CD9 10DB EF3D  25F8 3E5F 3D04 A7A2 4603
#      Subkey fingerprint: BCE9 123E 1AD2 9F07 C049  BBDE F712 B510 A23A 0F5F

* tag 'linux-user-for-v11-pull-request' of https://github.com/hdeller/qemu-hppa:
  linux-user: Fix MADV_XXX constants on hppa target
  linux-user: strace: Fix 5th argument of futex syscall
  linux-user: fixup termios2 related things on PowerPC
  linux-user: Add missing termios baud rates
  linux-user: Add termios2 support to sparc target
  linux-user: Add termios2 support to sh4 target
  linux-user: Add termios2 support to mips target
  linux-user: Add termios2 support to hppa target
  linux-user: Add termios2 support to alpha target
  linux-user: Add termios2 support
  linux-user: update statx emulation

Signed-off-by: Richard Henderson <[email protected]>
2026-01-24 21:31:17 +11:00
Helge Deller 5db961f92b linux-user: Fix MADV_XXX constants on hppa target
Older hppa binaries may still use the old MADV_XXX constants for the
madivise() syscall. Fix it up in the same manner as it's done in the
Linux kernel in the parisc_madvise() function.

Signed-off-by: Helge Deller <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
2026-01-24 09:47:00 +01:00
Richard Henderson 363a069b31 Merge tag 'migration-20260123-pull-request' of https://gitlab.com/farosas/qemu into staging
Migration pull request

- Removal of deprecated query-migrationthreads command
- Removal of deprecated QMP migrate argument 'detach'
- Removal of deprecated zero-blocks capability
- Removal of deprecated migration to file using fd: URI
- Improvements to fd handling in QEMUFile
- Cleanups to postcopy tests
- Cleanup of migration channel connection code

# -----BEGIN PGP SIGNATURE-----
#
# iQJEBAABCAAuFiEEqhtIsKIjJqWkw2TPx5jcdBvsMZ0FAmlz0PIQHGZhcm9zYXNA
# c3VzZS5kZQAKCRDHmNx0G+wxnS1hEADSUFCynktz0MwmPbun9rHI/DSTmkk2SFIj
# 4WI66Wgez805uD/Xa/r7qpqpjkTTFd+mgbfUlkcmiatrrPMFsYFP4cyrtFfLOl16
# ODmYZO+VQ+cFpzgXDsS1IrHSwaJ1zU7sFkYLXGJdwwhkDWDDxHpO/1OADG7HotkH
# GFaZaMFim4fAHuDp688uzbUsljNjaKNlqbZQFVeg2S+ewEFtp1/tTY2oRTuKA0Es
# BPeENU6xQxR26YPn8lZub61D12ZNw4BCKTNANGvnDGjTmC9Ijw3iAjEo5O4TWhca
# q7UPkFS9uuxIxtAeRul92XzAclASnZ52Lk1oTfP083GcXIepsFwNKKmZtulOjGm2
# bz8exu46WUSO0wxlWcM/DGfmkapKbXteP/nIBjpeRrYxxz4dBJ4MHHCNv487Si3Y
# Um8dar3wUNP6UZEt/ZGidJRvcigMwM01aDVXyn05qqHQ8Qfj93ozi9hz1ttHBeDP
# QuX6LlJ4wiU4z9QZqNaDe7pwSi/VdROkp3U0/0SVySudqE/vTC0YtUxq2miH7RLl
# VJsYPF9nZOEgKXCqMdzM4G9kr/jJ0Ou7z8hm/J6l19joBn79pf7FrRG935LCM7at
# 0xkF1D+D/O4+C/mnYemVXNwY35MhQR9OihS6DjVxYeySf4QIwUtuzBQ6W1pz9vJt
# EyLedtJXpg==
# =7sEk
# -----END PGP SIGNATURE-----
# gpg: Signature made Sat 24 Jan 2026 06:50:10 AM AEDT
# gpg:                using RSA key AA1B48B0A22326A5A4C364CFC798DC741BEC319D
# gpg:                issuer "[email protected]"
# gpg: Good signature from "Fabiano Rosas <[email protected]>" [unknown]
# gpg:                 aka "Fabiano Almeida Rosas <[email protected]>" [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: AA1B 48B0 A223 26A5 A4C3  64CF C798 DC74 1BEC 319D

* tag 'migration-20260123-pull-request' of https://gitlab.com/farosas/qemu: (36 commits)
  migration/channel: Centralize calling migration_channel_connect_outgoing
  migration: Remove qmp_migrate_finish
  migration: Move CPR HUP watch to cpr-transfer.c
  migration: Free cpr-transfer MigrationAddress along with gsource
  migration: Move URI parsing to channel.c
  migration: Move channel parsing to channel.c
  migration: Move transport connection code into channel.c
  migration: Move channel code to channel.c
  migration: Rename instances of start
  migration/channel: Rename migration_channel_connect
  migration: Start incoming from channel.c
  migration/rdma: Use common connection paths
  migration: Move setting of QEMUFile into migration_outgoing|incoming_setup
  migration: Handle error in the early async paths
  migration: Fold migration_cleanup() into migration_connect_error_propagate()
  migration: yank: Move register instance earlier
  migration: Expand migration_connect_error_propagate to cover cancelling
  migration: Move error reporting out of migration_cleanup
  migration: Free the error earlier in the resume case
  migration: Use migrate_mode() to query for cpr-transfer
  ...

Signed-off-by: Richard Henderson <[email protected]>
2026-01-24 10:08:23 +11:00
Richard Henderson 9c4c090d27 Merge tag 'pull-target-arm-20260123' of https://gitlab.com/pm215/qemu into staging
target-arm queue:
 * hw/arm/imx8mp-evk: Provide some defaults matching real hardware
 * hw/intc: endianness fixes
 * various: Clean up includes
 * kernel-doc.py: sync with upstream Kernel v6.19-rc4
 * scripts/clean-includes: Minor improvements; exclude list update
 * docs/system/arm/imx8mp-evk: Avoid suggesting redundant CLI parameters
 * docs/system/arm/xlnx-zynq.rst: Improve docs rendering
 * docs: Be consistent about capitalization of 'Arm' (again)
 * docs: Avoid unintended mailto: hyperlinks
 * qemu-options.hx: Drop uses of @var
 * qemu-options.hx: Improve formatting in colo-compare docs

# -----BEGIN PGP SIGNATURE-----
#
# iQJNBAABCAA3FiEE4aXFk81BneKOgxXPPCUl7RQ2DN4FAmlzju4ZHHBldGVyLm1h
# eWRlbGxAbGluYXJvLm9yZwAKCRA8JSXtFDYM3uU/D/9IHpo57UIHAF7vU9gsWm5k
# TxLl9PBw3ev2Uv6zWWza0wYZQF2ZcvqwMiU/AlBFuyJFyXTLocL3iN6Rsw+8kcjh
# jaq2hCtzSNJWj41CEU22l7iUfJ5PdOVdRYhhwlrQqxXDJj8Oj3plliRc6AL1EZYD
# mxAJ+YQ8pfJ/2ibO66sqwGMLjPsjCmmgfloTm/qFzk7QccQkPZKzDrC9CGGRmmRA
# tcdBGMtu+DOqpCRKIRul0S8ed2qaTecIK3+fUID0+qEzb10VWgFs/AAQiwLPkwyi
# RvMmIbC9lYVCnP+YC4HlvYMfd61V3lpzsUXgMIbdRZYsN/IlTVfetJUOVmn3LTQ/
# gGU0b+t6D/OZAt1L6toBngKVh89VPqbpGXEx4UMHCNIcvfI1Xo+HRT9ZV5WCw6b8
# sVKOZUwKs9ZbFAcrgBgskXp/5KWZAb92IFjwbfwxxl/2NRK3B3y7CDHBoOM/zQ9a
# rZ7rfJHhQVGR2+1QonNbpG0IFwbgs0zPQwBjPreGh6TWf2UiXvx1ku94Wxe2lA+5
# CPeju+swbFKRNjwSas6NZjJWazacohYG3nhmhF7HtcgX279BzIV0d+ZIl786Juls
# 4Vt4dPUxU/kHHZHjE52AZUS/opIy+UHAj0FKPAPpTrc7UfuHlY3gqoI7UfVpciau
# q3DqM7PlF2X91kw4xJ6JCA==
# =bE6w
# -----END PGP SIGNATURE-----
# gpg: Signature made Sat 24 Jan 2026 02:08:30 AM AEDT
# gpg:                using RSA key E1A5C593CD419DE28E8315CF3C2525ED14360CDE
# gpg:                issuer "[email protected]"
# gpg: Good signature from "Peter Maydell <[email protected]>" [unknown]
# gpg:                 aka "Peter Maydell <[email protected]>" [unknown]
# gpg:                 aka "Peter Maydell <[email protected]>" [unknown]
# gpg:                 aka "Peter Maydell <[email protected]>" [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: E1A5 C593 CD41 9DE2 8E83  15CF 3C25 25ED 1436 0CDE

* tag 'pull-target-arm-20260123' of https://gitlab.com/pm215/qemu: (22 commits)
  qemu-options.hx: Improve formatting in colo-compare docs
  qemu-options.hx: Drop uses of @var
  docs: avoid unintended mailto: hyperlinks
  docs/system/arm/xlnx-zynq.rst: Improve docs rendering
  hw/intc: avoid byte swap fiddling in gicv3 its path
  hw/intc: declare GICv3 regions as little endian
  hw/intc: declare GIC regions as little endian
  hw/intc: declare NVIC regions as little endian
  all: Clean up includes
  misc: Clean up includes
  bsd-user: Clean up includes
  mshv: Clean up includes
  scripts/clean-includes: Update exclude list
  scripts/clean-includes: Give the args in git commit messages
  scripts/clean-includes: Do all our exclusions with REGEXFILE
  scripts/clean-includes: Make ignore-regexes one per line
  scripts/clean-includes: Remove outdated comment
  scripts/clean-includes: Allow directories on command line
  docs: Be consistent about capitalization of 'Arm' (again)
  kernel-doc.py: sync with upstream Kernel v6.19-rc4
  ...

Signed-off-by: Richard Henderson <[email protected]>
2026-01-24 07:59:34 +11:00
Richard Henderson 092009a55c Merge tag 'net-pull-request' of https://github.com/jasowang/qemu into staging
# -----BEGIN PGP SIGNATURE-----
#
# iQEzBAABCAAdFiEEIV1G9IJGaJ7HfzVi7wSWWzmNYhEFAmlzZqsACgkQ7wSWWzmN
# YhGITAf+I46cGYha4dE7Gepbqnk+/eHxURNhToX2yZwWsRBkn4LEWHxavWzYGhTk
# acaVL7zPiHG7S33xSUT7Ie3yrLvbpATAlBsa5xbEKS26KAVIzVtsmMJA6jHyKXUX
# RKBoX2zUkveMZCDtU0XSPjf/wzf7LyeFEDk/o9Agl5zzqfU3mfe58Zk+9MkpFJ9Y
# HEGgocbW4Kuu65RJzesejbrBw0f3PMq8cfktUJ8rj0o5v5MX58hrijBAbE5JLrxG
# Z2u1GvMFR4ZA3e+Mmgu5zg2/AZ4/ZrN9c8moxB9DWLVX8Psz4fJwyYm2Hx0ldhf4
# 4ETQ326nrAZ5REiUTea1FPACBSK7dw==
# =TV7k
# -----END PGP SIGNATURE-----
# gpg: Signature made Fri 23 Jan 2026 11:16:43 PM AEDT
# gpg:                using RSA key 215D46F48246689EC77F3562EF04965B398D6211
# gpg: Good signature from "Jason Wang (Jason Wang on RedHat) <[email protected]>" [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: 215D 46F4 8246 689E C77F  3562 EF04 965B 398D 6211

* tag 'net-pull-request' of https://github.com/jasowang/qemu:
  tests/qtest: Add test for filter-redirector rx event opened
  qtest: add a test to test redirector status change
  net/filter-redirector: add support for dynamic status on/off switching
  tests/qtest: add test for filter-buffer interval change
  net/filter-buffer: make interval change take effect immediately
  net/tap: rework tap_set_sndbuf()
  net/tap: tap_set_sndbuf(): add return value
  net/tap: setup exit notifier only when needed
  net/tap: rework scripts handling
  net/tap: pass NULL to net_init_tap_one() in cases when scripts are NULL
  net/tap: net_init_tap_one(): move parameter checking earlier
  net/tap: net_init_tap_one(): drop extra error propagation
  net/tap-linux.c: avoid abort when setting invalid fd

Signed-off-by: Richard Henderson <[email protected]>
2026-01-24 07:58:52 +11:00
Helge Deller 160b9347c7 linux-user: strace: Fix 5th argument of futex syscall
The 5th argument isn't printed, but instead the 4th argument is shown twice.
Fix this, and print the FUTEX_BITSET_MATCH_ANY string constant instead of -1
if the op is FUTEX_WAIT_BITSET or FUTEX_WAKE_BITSET.

Signed-off-by: Helge Deller <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
2026-01-23 20:40:15 +01:00
Icenowy Zheng d68f0e2e90 linux-user: fixup termios2 related things on PowerPC
The termios things on PowerPC equal to termios2 things otherwhere.

Use some simple #define's to allow both termios and termios2 to map to
termios on PowerPC.

Signed-off-by: Icenowy Zheng <[email protected]>
Link: https://github.com/AOSC-Dev/aosc-os-abbs/blob/8d77eeaa76e9b159c3f35adaf73c875751aa7d17/app-virtualization/qemu/01-shared/patches/0005-AOSCOS-linux-user-fixup-termios2-related-things-on-P.patch
Link: https://lore.kernel.org/qemu-devel/[email protected]
Reviewed-by: Helge Deller <[email protected]>
2026-01-23 20:40:15 +01:00
Vivian Wang 4f22fcb5c6 linux-user: Add missing termios baud rates
Add several missing baud rates and inputs baud rates in cflag_tbl.

Add these missing definitions in termbits.h:

- TARGET_BOTHER for alpha, hppa, ppc, sh4, sparc
- TARGET_IBSHIFT for hppa, mips, ppc, sh4, sparc
- Missing standard baud rates for hppa

These are required for the glibc test tst-termios-linux.

Link: https://lore.kernel.org/qemu-devel/20251203-linux-user-higher-baud-rates-v2-1-e45b35224437@iscas.ac.cn
Signed-off-by: Vivian Wang <[email protected]>
Reviewed-by: Helge Deller <[email protected]>
2026-01-23 20:40:15 +01:00
Luca Bonissi 947b971cad linux-user: Add termios2 support to sparc target
Signed-off-by: Luca Bonissi <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Reviewed-by: Helge Deller <[email protected]>
2026-01-23 20:40:15 +01:00
Luca Bonissi afbe0ff81c linux-user: Add termios2 support to sh4 target
Signed-off-by: Luca Bonissi <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Reviewed-by: Helge Deller <[email protected]>
2026-01-23 20:40:15 +01:00
Luca Bonissi edf9184f4f linux-user: Add termios2 support to mips target
Signed-off-by: Luca Bonissi <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Reviewed-by: Helge Deller <[email protected]>
2026-01-23 20:40:15 +01:00
Luca Bonissi edc741710a linux-user: Add termios2 support to hppa target
Signed-off-by: Luca Bonissi <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Reviewed-by: Helge Deller <[email protected]>
2026-01-23 20:40:15 +01:00
Luca Bonissi 8d8c6aeee8 linux-user: Add termios2 support to alpha target
Signed-off-by: Luca Bonissi <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Reviewed-by: Helge Deller <[email protected]>
2026-01-23 20:40:15 +01:00
Luca Bonissi e9a8a10e84 linux-user: Add termios2 support
Signed-off-by: Luca Bonissi <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Reviewed-by: Helge Deller <[email protected]>
Tested-by: Heinrich Schuchardt <[email protected]>
2026-01-23 20:40:15 +01:00
Andreas Schwab 344640b479 linux-user: update statx emulation
Signed-off-by: Andreas Schwab <[email protected]>
Reviewed-by: Laurent Vivier <[email protected]>
Signed-off-by: Helge Deller <[email protected]>
2026-01-23 20:40:15 +01:00
Fabiano Rosas 03a680c978 migration/channel: Centralize calling migration_channel_connect_outgoing
Make the synchronous calls evident by not hiding the call to
migration_channel_connect_outgoing() in the transport code. Have those
functions return and call the function at the upper level.

This helps with navigation: the transport code returns the ioc,
there's no need to look into them when browsing the code.

It also allows RDMA in the source side to use the same path as the
rest of the transports.

While here, document the async calls which are the exception.

Reviewed-by: Peter Xu <[email protected]>
Reviewed-by: Prasad Pandit <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-01-23 11:34:25 -03:00
Fabiano Rosas 2379a04e60 migration: Remove qmp_migrate_finish
After cleanups, the qmp_migrate_finish function is now just a call to
migration_connect_outgoing(). Remove qmp_migrate_finish() and rename
the qmp_migrate_finish_cb callback.

This also allows the function's error handling to be removed as it now
receives &local_err like the rest of the callees of qmp_migrate().

Reviewed-by: Peter Xu <[email protected]>
Reviewed-by: Prasad Pandit <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-01-23 11:32:19 -03:00
Fabiano Rosas f523e5aa5f migration: Move CPR HUP watch to cpr-transfer.c
Move this CPR-specific code into a cpr file. While here, give the
functions more significant names.

This makes the new idea (after cpr-transfer) of having two parts to
qmp_migrate slightly more obvious: either wait for the hangup or
continue directly.

Reviewed-by: Peter Xu <[email protected]>
Reviewed-by: Prasad Pandit <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-01-23 11:32:19 -03:00
Fabiano Rosas 6a887119ce migration: Free cpr-transfer MigrationAddress along with gsource
When setting a callback on a Glib source and giving it a data pointer,
it's natural to also provide the destructor for the data in question.

Since migrate_hup_add() already needs to clone the MigrationAddress
when setting the qmp_migrate_finish_cb callback, also pass the
qapi_free_MigrationAddress as the GDestroyNotify callback.

With this the address doesn't need to be freed at the callback body,
making the management of that memory slightly simpler.

Cc: Mark Kanda <[email protected]>
Cc: Ben Chaney <[email protected]>
Reviewed-by: Peter Xu <[email protected]>
Reviewed-by: Prasad Pandit <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-01-23 11:32:18 -03:00
Fabiano Rosas 0c26f7f8e9 migration: Move URI parsing to channel.c
The migrate_uri_parse function is responsible for converting the URI
string into a MigrationChannel for consumption by the rest of the
code. Move it to channel.c and add a wrapper that calls both URI and
channels parsing.

Reviewed-by: Peter Xu <[email protected]>
Reviewed-by: Prasad Pandit <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-01-23 11:32:18 -03:00
Fabiano Rosas b16e0dae8e migration: Move channel parsing to channel.c
Encapsulate the MigrationChannelList parsing in a new
migrate_channels_parse() located at channel.c.

This also makes the memory management of the MigrationAddress more
uniform. Previously, half the parsing code (uri parsing) would
allocate memory for the address while the other half (channel parsing)
would instead pass the original QAPI object along. After this patch,
the MigrationAddress is always QAPI_CLONEd, so the callers can use
g_autoptr(MigrationAddress) in all cases.

Reviewed-by: Peter Xu <[email protected]>
Reviewed-by: Prasad Pandit <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-01-23 11:32:18 -03:00
Fabiano Rosas 468bd4ba1c migration: Move transport connection code into channel.c
Move the <transport>_connect_incoming|outgoing functions to channel.c.
It leaves migration.c to deal with the established connection only.

While here, sort the includes.

Reviewed-by: Peter Xu <[email protected]>
Reviewed-by: Prasad Pandit <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-01-23 11:32:18 -03:00
Fabiano Rosas 7d7bf3e60e migration: Move channel code to channel.c
Move the code responsible for the various channels connection into
channel.c. This is all executed before the migration_thread and
process_incoming_migration_co are running, so it helps the reasoning
to have them out of migration.c.

migration_ioc_process_incoming becomes migration_channel_identify
which is more in line with what the function does.

Reviewed-by: Peter Xu <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-01-23 11:32:18 -03:00
Fabiano Rosas 86a0ceb1ce migration: Rename instances of start
To make it easier to follow the code, rename the functions that start
the migration thread and migration coroutine to contain the word
"start".

This will give new contributors the chance of seeing the word start
and reaching the actual migration code, instead of twists and turns of
qio_channel_add_watch and qio_task_run_in_thread.

Remove all other instances of "start" and use wording more suitable to
what the current migration stage is. The transport code such as
fd_start_migration_outgoing becomes fd_connect_outgoing, the early
setup code such as qemu_start_incoming_migration becomes
qemu_setup_incoming_migration and so on.

Reviewed-by: Peter Xu <[email protected]>
Reviewed-by: Prasad Pandit <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-01-23 11:32:18 -03:00
Fabiano Rosas 9fdca27637 migration/channel: Rename migration_channel_connect
Rename migration_channel_connect to indicate this is the source
side. Future patches will do similar changes to the incoming side and
this will avoid inconsistencies in naming.

Reviewed-by: Peter Xu <[email protected]>
Reviewed-by: Prasad Pandit <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-01-23 11:32:18 -03:00
Fabiano Rosas 9834b6de61 migration: Start incoming from channel.c
Leave migration_ioc_process_incoming to do only the channel
identification process and move the migration start into
channel.c. Both routines will be renamed in the next patches to better
reflect their usage.

Reviewed-by: Peter Xu <[email protected]>
Reviewed-by: Prasad Pandit <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-01-23 11:32:17 -03:00
Fabiano Rosas 52f3b05d54 migration/rdma: Use common connection paths
Use the common connection paths for the incoming and outgoing sides of
rdma migration. This removes one usage of QEMUFile from rdma.c. It
also allows further unification of the connection code in next
patches.

Move the channels enum to channel.h so rdma.c can access it. The RDMA
channel is considered a CH_MAIN channel.

Reviewed-by: Peter Xu <[email protected]>
Reviewed-by: Prasad Pandit <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-01-23 11:32:17 -03:00
Fabiano Rosas 5bc9c7995c migration: Move setting of QEMUFile into migration_outgoing|incoming_setup
Centralize, on both sides of migration, the setting of the to_src_file
and from_dst_file QEMUFiles. This will clean up the interface with
channel.c and rdma.c, allowing those files to stop dealing with
QEMUFile themselves.

(multifd_recv_new_channel was changed to return bool+errp for
convenience)

Reviewed-by: Peter Xu <[email protected]>
Reviewed-by: Prasad Pandit <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-01-23 11:32:17 -03:00
Fabiano Rosas b6ef92ddbd migration: Handle error in the early async paths
Simplify migration_channel_connect() and migration_connect() to not
take an error as input. Move the error handling into the paths that
generate the error.

To achieve this, call migration_connect_error_propagate() from
socket.c and tls.c, which are the async paths.

For the sync paths, the handling is done as normal by returning all
the way to qmp_migrate_finish(), except that now the sync paths don't
pass the error forward into migration_connect() anymore.

Reviewed-by: Peter Xu <[email protected]>
Reviewed-by: Prasad Pandit <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-01-23 11:32:17 -03:00
Fabiano Rosas 6b587af5ec migration: Fold migration_cleanup() into migration_connect_error_propagate()
Whenever an error occurs between migrate_init() and the start of
migration_thread, do cleanup immediately.

This allows the special casing for resume to be removed from
migration_connect(), that check is now done at
migration_connect_error_propagate() which already had a case for
resume.

The cleanup at qmp_migrate_finish_cb can also be removed because it
will always be reached either via the error path at
qmp_migrate_finish->migration_connect_error_propagate or via the
migrate_cleanup_bh.

The yank_unregister_instance at qmp_migrate() is now replaced by the
one at migration_cleanup().

Reviewed-by: Peter Xu <[email protected]>
Reviewed-by: Prasad Pandit <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-01-23 11:32:17 -03:00
Fabiano Rosas 7e71439243 migration: yank: Move register instance earlier
Move the register_instance call to migrate_prepare() so it can be
paired with the unregister_instance at migration_cleanup(). Otherwise,
the cleanup cannot be run when cpr_state_save() fails because the
instance is registered only after it.

When resuming from a paused postcopy migration, migrate_prepare()
returns early, but migration_cleanup() doesn't run, so the yank will
remain paired.

Reviewed-by: Peter Xu <[email protected]>
Reviewed-by: Prasad Pandit <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-01-23 11:32:17 -03:00
Fabiano Rosas 2f8ccc5d58 migration: Expand migration_connect_error_propagate to cover cancelling
Cover the CANCELLING state in migration_connect_error_propagate() and
use it to funnel errors from migrate_prepare() until the end of
migration_connect().

Reviewed-by: Peter Xu <[email protected]>
Reviewed-by: Prasad Pandit <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-01-23 11:32:17 -03:00
Fabiano Rosas f7be51a690 migration: Move error reporting out of migration_cleanup
In the next patches migration_cleanup() will be used in qmp_migrate(),
which currently does not show an error message. Move the error
reporting out of migration_cleanup() to avoid duplicate messages.

Reviewed-by: Peter Xu <[email protected]>
Reviewed-by: Prasad Pandit <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-01-23 11:32:16 -03:00
Fabiano Rosas 318cb7906e migration: Free the error earlier in the resume case
Freeing the error at migration_connect() is redundant in the normal
migration case. The freeing already happened at migrate_init():

qmp_migrate()
-> migrate_prepare()
   -> migrate_init()
-> qmp_migrate_finish()
   -> *_start_outgoing_migration()
   -> migration_channel_connect()
      -> migration_connect()

For the resume case, migrate_prepare() returns early and doesn't reach
migrate_init(). Move the extra migrate_error_free() call to
migrate_prepare() along with the resume check.

Also change migrate_init() to use migrate_error_free(), so it's easier
to see where are the places the error gets freed.

Reviewed-by: Peter Xu <[email protected]>
Reviewed-by: Prasad Pandit <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-01-23 11:32:16 -03:00
Fabiano Rosas 5dafed3235 migration: Use migrate_mode() to query for cpr-transfer
cpr_set_incoming_mode() is only called on the target side, so
migrate_mode() on the source side is the same as s->parameters.mode.

Use the function to reduce explicit access to s->parameters, we have
options.c for that.

Cc: Mark Kanda <[email protected]>
Cc: Ben Chaney <[email protected]>
Reviewed-by: Peter Xu <[email protected]>
Reviewed-by: Prasad Pandit <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-01-23 11:32:16 -03:00
Fabiano Rosas a57209371b migration: Move postcopy_try_recover into migration_incoming_process
The postcopy_try_recover() call doesn't need to be duplicated, move it
into migration_incoming_process().

This removes code from migration_fd_process_incoming() so it can be
removed in the near future.

Reviewed-by: Peter Xu <[email protected]>
Reviewed-by: Prasad Pandit <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-01-23 11:32:16 -03:00
Fabiano Rosas 5a26b76b4a migration: Cleanup TLS handshake hostname passing
The TLS hostname is doing a tour around the world just to be cached
into s->hostname. We're already abusing MigrationState by doing that,
so incorporate the s->hostname into migration_tls_hostname() and stop
passing the string around.

The old route was roughly:

 -transport code (socket.c, fd.c, etc):
    if (SOCKET_ADDRESS_TYPE_INET)
        hostname = saddr->u.inet.host
    else
        hostname = NULL
    migration_channel_connect(..., hostname)
      s->hostname = hostname;
      migration_tls_client_create(..., hostname)
        if (migrate_tls_hostname())
            qio_channel_tls_new_client(migrate_tls_hostname())
        else
            qio_channel_tls_new_client(hostname)

 -postcopy_preempt_setup:
    postcopy_preempt_send_channel_new
      migration_tls_client_create(..., s->hostname)

New route is:

 -socket.c only:
   if SOCKET_ADDRESS_TYPE_INET
       s->hostname = saddr->u.inet.host
   migration_channel_connect()
     migration_tls_client_create()
       qio_channel_tls_new_client(migrate_tls_hostname())

 -postcopy_preempt_setup:
    postcopy_preempt_send_channel_new
      migration_tls_client_create()
        qio_channel_tls_new_client(migrate_tls_hostname())

Reviewed-by: Peter Xu <[email protected]>
Reviewed-by: Prasad Pandit <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-01-23 11:32:16 -03:00
Fabiano Rosas 13b50cc7ea migration/tls: Remove unused parameter
The MigrationState parameter is not used at
migration_tls_channel_process_incoming().

The last usage was removed by commit 3f461a0c0b ("migration: Drop
unused parameter for migration_tls_get_creds()")

Reviewed-by: Peter Xu <[email protected]>
Reviewed-by: Prasad Pandit <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-01-23 11:32:16 -03:00
Fabiano Rosas 44fe18201c migration: Fix state change at migration_channel_process_incoming
When the incoming migration fails during the channel connection phase,
the state transition to FAILED is currently being done in the
MigrationState->state, but the MigrationIncomingState->state is the
one that should be used.

Reviewed-by: Peter Xu <[email protected]>
Reviewed-by: Prasad Pandit <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-01-23 11:32:16 -03:00
Fabiano Rosas 41982a06d1 migration: Remove redundant state change
If local_err is set, migration_connect_error_propagate() will be
called and that function already has a state transition from SETUP to
FAILED.

Reviewed-by: Peter Xu <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-01-23 11:32:16 -03:00
Peter Xu f1fcc1c101 migration: Remove fd: support on files
This feature was deprecated in 9.1.  Remove it in this release (11.0).

We also need to remove one unit test (/migration/precopy/fd/file) that
covers the fd: file migration, because it'll stop working now.

Reviewed-by: Prasad Pandit <[email protected]>
Reviewed-by: Fabiano Rosas <[email protected]>
Signed-off-by: Peter Xu <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-01-23 11:24:19 -03:00
Peter Xu aa575660d0 migration: Remove zero-blocks capability
It was declared deprecated since 9.2.

Reviewed-by: Fabiano Rosas <[email protected]>
Signed-off-by: Peter Xu <[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-01-23 11:24:19 -03:00
Peter Xu 3346b16aa2 tests/migration-test: Remove postcopy_recovery_fail_stage from MigrateCommon
The parameter can be instead passed into the function to avoid polluting
the global address space of MigrateCommon.

Reviewed-by: Prasad Pandit <[email protected]>
Signed-off-by: Peter Xu <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-01-23 11:24:19 -03:00
Peter Xu 86571f5121 tests/migration-test: Remove postcopy_data from MigrateCommon
Now postcopy is not the only user of start_hook / end_hook that will pass
in a opaque pointer.  It doesn't need to be defined in MigrateCommon as
part of the framework, as all other hook users can pass hook_data around.
Do it too for postcopy.

Reviewed-by: Prasad Pandit <[email protected]>
Signed-off-by: Peter Xu <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-01-23 11:24:18 -03:00
Vladimir Sementsov-Ogievskiy f43a45ba09 qemu-file: qemu_file_get_fd(): improve interface
Make it symmetrical with qemu_file_put_fd() and simplify callers.

Signed-off-by: Vladimir Sementsov-Ogievskiy <[email protected]>
Reviewed-by: Fabiano Rosas <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-01-23 11:24:18 -03:00
Vladimir Sementsov-Ogievskiy 20125d93af qemu-file: qemu_file_get_fd(): check service byte itself
We can check it, so, why not.

Signed-off-by: Vladimir Sementsov-Ogievskiy <[email protected]>
Reviewed-by: Fabiano Rosas <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-01-23 11:24:18 -03:00
Vladimir Sementsov-Ogievskiy ace0ad87ae qemu-file: qemu_file_get_fd(): get byte in one shot
No reason to split into peek + get.

Signed-off-by: Vladimir Sementsov-Ogievskiy <[email protected]>
Reviewed-by: Fabiano Rosas <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-01-23 11:24:18 -03:00
Vladimir Sementsov-Ogievskiy 030baed787 qemu-file: qemu_file_get_fd(): fail if no expected fd come
In _put() we don't actually allow send a service byte
without fd. So on _get() it's unexpected. Let's be strict.

Signed-off-by: Vladimir Sementsov-Ogievskiy <[email protected]>
Reviewed-by: Fabiano Rosas <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-01-23 11:24:17 -03:00
Vladimir Sementsov-Ogievskiy 0369fac6c8 vmstate-types: get_fd(): handle qemu_file_get_fd() failure
qemu_file_get_fd() may fail, and return -1 in this case.
We don't support passing "invalid" file descriptors (like -1),
so we should not interpret error here like invalid descriptor.

Signed-off-by: Vladimir Sementsov-Ogievskiy <[email protected]>
Reviewed-by: Fabiano Rosas <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-01-23 11:24:17 -03:00
Markus Armbruster fc37c122ff migration: Drop deprecated QMP migrate argument @detach
Deprecated in commit c2fb6eaeb9 (qapi/migration: Deprecate migrate
argument @detach), v10.1.0.

Signed-off-by: Markus Armbruster <[email protected]>
Reviewed-by: Fabiano Rosas <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-01-23 11:24:16 -03:00
Markus Armbruster 7686f2c5d7 migration: Drop deprecated QMP command query-migrationthreads
Deprecated in commit 228529d1fe (migration: Deprecate
query-migrationthreads command), v9.2.0.

Signed-off-by: Markus Armbruster <[email protected]>
Reviewed-by: Fabiano Rosas <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
[fixed title underline length]
Signed-off-by: Fabiano Rosas <[email protected]>
2026-01-23 11:24:16 -03:00
Peter Maydell 62580edc02 qemu-options.hx: Improve formatting in colo-compare docs
The colo-compare option documentation has some formatting issues: it
uses a "@var{...}" syntax which is not used elsewhere and which is
rendered literally into the HTML documentation.  The bare "@" sign
also results in an unintended 'mailto:' hyperlink.

Rewrite this into the style we seem to use most in the rest of
the command line options, where an option which takes an argument
is written as "my-option=<thing>".

We take the opportunity to make the documentation a little clearer
by splitting up the long paragraph and using preformatted-text
markup for the names of the suboptions.

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Alex Bennée <[email protected]>
Reviewed-by: Zhang Chen <[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-id: [email protected]
2026-01-23 14:08:57 +00:00
Peter Maydell b755c5e7ec qemu-options.hx: Drop uses of @var
A few entries in qemu-options.hx use the syntax "my-option=@var{name}"
(or @var{} with no name specified) when documenting an option that takes
an argument. This syntax isn't consistently used, and the documentation
generation has no support for it: it just appears literally in the
HTML output.

Switch these uses to the more common "my-option=<name>". This also
doesn't have any particular support in the documentation generation
and so appears literally in the output, but it is a little less odd
looking to the end-user.

The other common pattern we have is "my-option=name" with no marking
at all that the right hand side of the '=' is not literal text;
using <> seems preferable to me, as it makes it more distinct from
cases where the right hand side is documenting that only certain
values are permitted, as in "my-option=on|off". This patch doesn't
do anything about existing uses of this pattern (except in one case
which was so confused as to use "my-option=@var{}" in the --help
output and "my-option=" in the RST output, where we change both
for consistency), but prefers not to add more of them.

We don't change the uses of @var in the colo-compare documentation,
as that part deserves a slightly more wide-ranging overhaul that
is better in its own commit.

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Alex Bennée <[email protected]>
Reviewed-by: Zhang Chen <[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-id: [email protected]
2026-01-23 14:08:57 +00:00
Peter Maydell eac712a44b docs: avoid unintended mailto: hyperlinks
In rST documents, an '@' character in normal text or a parsed-literal is
assumed to be an email address and will result in a 'mailto:' hyperlink in
the generated HTML.  In several places we have mailto: hyperlinks that are
unintended nonsense; correct these by either escaping the @ character or
making the text use ``...`` preformatted rendering.

This commit covers only the simple cases which can be trivially fixed
with escaping or ``..``; the remaining cases will be handled in
separate commits.

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Alex Bennée <[email protected]>
Reviewed-by: Zhang Chen <[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-id: [email protected]
2026-01-23 14:08:57 +00:00
Peter Maydell 5b9a1d5b4f docs/system/arm/xlnx-zynq.rst: Improve docs rendering
Make some minor improvements to the rendering of the docs for
the xlnx-zynq-a9 board:

 * use a proper hyperlink rather than a bare URL for the
   link to the reference manual
 * drop the hex address of the SMC SRAM: the bare '@' is
   rendered as bogus mailto: hyperlink, and the information
   is not very interesting to the user anyway
 * expand out the abbreviations in the list of Cortex-A9
   per-CPU devices
 * correct the bullet-point list markup so it doesn't render
   with odd highlighted lines
 * capitalize 'Arm' correctly

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Alex Bennée <[email protected]>
Reviewed-by: Zhang Chen <[email protected]>
Message-id: [email protected]
2026-01-23 14:08:57 +00:00
Richard Henderson 619c0234c4 Merge tag 'memory-api-20260122' of https://github.com/philmd/qemu into staging
Memory API patches

- Use explicit endianness for cpu_ld/st_data*() on some targets
- Reduce 'qemu/bswap.h' uses
- Introduce ldm_p/stm_p (MemOp) load/store helpers
- Allow restricting the legacy 'native-endian' APIs
- Forbid various targets to use legacy native endianness APIs
- Simplify cpu_address_space_init() API

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCAAdFiEE+qvnXhKRciHc/Wuy4+MsLN6twN4FAmlyBsIACgkQ4+MsLN6t
# wN7sIxAAz/2e04lfoX9bbnQeI7SNEEpLwSrmwvLCCcmzSTDc32RSOJHzs6MOYHkm
# ubib6sRW5XFrW+lg0jLTPxKX7LMAgT2QkRw7Du9yQGFfPMhPHqMUqW8w6zYg6EQi
# IkOrvMLN91KR9rvk4Cy68dyE0ypD3224mhSHjza7Y30F9uVglyjCauXo/ifSbGIj
# pRE5VEMcrDEaXaNLZxbiBiGRYV+8fVoGAZikV80EadQnOxqM4frXpemHfncamuKf
# F6jIa9ggclQv9ebgBv06sCWd+KpF54oEtYiiRK1GC2SEFOrnca4Z/e2BXEmR/jTE
# xAkkpBcxLhB+4m9XauoPCPPRJUK3lHSCIVnYgrigzi2p/Xje7dkha+lZUPUHu5Hd
# MlUJ57qs8tPz0IS+wR3q7i6diLZq7YQoy2GS01A/5P/25etDM8TqZ66ft5rZwz4f
# +3USRA9bKOCy9yKef/o9Pfua3ApC8jm/Kjhufmb70n4N+TMaUYgbl0jeKfAnpLTT
# DJ/a1P85CmZojd5jWr0IiT2Nx9eva2Fx2MISJGWI4EfMHE/0JFIcwYHropJuEyGN
# G2X0wrRS2ypjq0hFXSd+vbVTlvuiYj3/lf4l9437iZOz+8Zi5Fp5kDIEtbjVibvf
# ShsDFuDIgMzMGyq2vmn8KWsR3baVMfEI53jaYI1qoXqzK4QGqnQ=
# =98VE
# -----END PGP SIGNATURE-----
# gpg: Signature made Thu 22 Jan 2026 10:15:14 PM AEDT
# gpg:                using RSA key FAABE75E12917221DCFD6BB2E3E32C2CDEADC0DE
# gpg: Good signature from "Philippe Mathieu-Daudé (F4BUG) <[email protected]>" [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: FAAB E75E 1291 7221 DCFD  6BB2 E3E3 2C2C DEAD C0DE

* tag 'memory-api-20260122' of https://github.com/philmd/qemu: (37 commits)
  cpus: Allocate maximum number of ASes supported by the arch
  target/arm: Add a _MAX sentinel to ARMASIdx enum
  target/i386: Add a _MAX sentinel to X86ASIdx enum
  target/arm: Initialize AS 0 first
  dump: Build stubs once for non-x86 targets
  dump: Abort in create_win_dump() on non-x86 guests
  configs/targets: Forbid s390x to use legacy native endianness APIs
  configs/targets: Forbid Renesas RX to use legacy native endianness API
  configs/targets: Forbid TriCore to use legacy native endianness API
  configs/targets: Forbid OpenRISC to use legacy native endianness APIs
  configs/targets: Forbid LoongArch to use legacy native endianness APIs
  configs/targets: Forbid HPPA to use legacy native endianness APIs
  configs/targets: Forbid Hexagon to use legacy native endianness API
  system: Allow restricting the legacy DEVICE_NATIVE_ENDIAN definition
  system: Allow restricting the legacy MO_TE* 'native-endian' definitions
  system: Allow restricting the legacy tswap() 'native-endian' API
  system: Allow restricting the legacy translator_ld() 'native-endian' API
  system: Allow restricting the legacy cpu_ld/st() 'native-endian' API
  system: Allow restricting legacy address_space_ldst() native-endian API
  system: Allow restricting the legacy ld/st_phys() 'native-endian' API
  ...

Signed-off-by: Richard Henderson <[email protected]>
2026-01-23 20:17:25 +11:00
Jason Wang 014c06435f tests/qtest: Add test for filter-redirector rx event opened
Add a new test case 'test_redirector_rx_event_opened' to verify the
handling of the CHR_EVENT_OPENED event in filter-redirector.

The test simulates a scenario where the backend character device (socket)
is disconnected and then reconnected. It works by:
1. Connecting to the redirector's socket (triggers CHR_EVENT_OPENED).
2. Sending a packet to verify initial connectivity.
3. Disconnecting (triggers CHR_EVENT_CLOSED).
4. Reconnecting (triggers CHR_EVENT_OPENED again).
5. Sending another packet to verify that the redirector correctly
   re-registers its handlers and resumes passing traffic.

This ensures that the filter-redirector can recover and function correctly
after a backend reconnection.

Reviewed-by: Zhang Chen <[email protected]>
Signed-off-by: Jason Wang <[email protected]>
2026-01-23 14:47:24 +08:00
Jason Wang 414af49791 qtest: add a test to test redirector status change
This patch adds a qtest to test the status change of
filter-redirector. Two subtests were added:

- test_redirector_status: tests dynamic on/off switching at runtime
  using qom-set QMP command

- test_redirector_init_status_off: tests creating filter-redirector
  with status=off from the start via command line

Both tests verify that:

1. When status is off, data from indev chardev is not received
2. When status is switched to on, data is received correctly

Reviewed-by: Zhang Chen <[email protected]>
Signed-off-by: Jason Wang <[email protected]>
2026-01-23 14:46:47 +08:00
Jason Wang 5193528b9f net/filter-redirector: add support for dynamic status on/off switching
Currently, filter-redirector does not implement the status_changed
callback, which means the 'status' property cannot be used to
dynamically enable/disable the filter at runtime. When status is
set to 'off' via QMP/HMP, the filter still receives data from the
indev chardev because the chardev handlers remain registered.

This patch adds proper support for the 'status' property:

1. Implement filter_redirector_status_changed() callback:
   - When status changes to 'off': remove chardev read handlers
   - When status changes to 'on': re-register chardev handlers
     (only if chardev is already open)

2. Update filter_redirector_setup() to respect initial status:
   - If filter is created with status=off, do not register handlers
   - This allows creating disabled filters via command line or QMP

3. Handle chardev OPENED/CLOSED events to re-arm handlers on reconnect:
   - Keep the chr_event callback installed on CLOSE so a later OPENED
     can re-register the read handlers when nf->on
   - Use qemu_chr_fe_set_handlers_full(..., set_open=false, sync_state=false)
     instead of qemu_chr_fe_set_handlers() because the latter forces
     sync_state=true and may emit CHR_EVENT_OPENED for an already-open
     backend. Doing that from inside the chr_event callback would cause
     recursive/re-entrant OPENED handling.

Signed-off-by: Jason Wang <[email protected]>
2026-01-23 14:46:22 +08:00
Jason Wang 50f6d44850 tests/qtest: add test for filter-buffer interval change
Add test_change_interval_timer to verify that modifying the 'interval'
property of filter-buffer at runtime takes effect immediately.

The test uses socket backend and filter-redirector to verify timer behavior:
- Creates filter-buffer with a very long interval (1000 seconds)
- Sends a packet which gets buffered
- Advances virtual clock by 1 second, verifies packet is still buffered
- Changes interval to 1ms via qom-set (timer should be rescheduled)
- Advances virtual clock by 2ms, verifies packet is now released
- This proves the timer was rescheduled immediately when interval changed

The test uses filter-redirector to observe when packets are released
by filter-buffer, providing end-to-end verification of the timer
rescheduling behavior.

Reviewed-by: Zhang Chen <[email protected]>
Reviewed-by: Fabiano Rosas <[email protected]>
Signed-off-by: Jason Wang <[email protected]>
2026-01-23 14:44:17 +08:00
Jason Wang 60a8b9b75a net/filter-buffer: make interval change take effect immediately
Previously, when the 'interval' property was modified at runtime via
QMP, the new value would only take effect after the current timer
period elapsed. This could lead to unexpected behavior when users
expect immediate changes.

Fix this by checking if the timer is already running when setting
the interval property. If so, reschedule the timer with the new
interval value immediately.

Reviewed-by: Zhang Chen <[email protected]>
Signed-off-by: Jason Wang <[email protected]>
2026-01-23 14:43:57 +08:00
Vladimir Sementsov-Ogievskiy 3183bd395a net/tap: rework tap_set_sndbuf()
Keep NetdevTapOptions related logic in tap.c, and make tap_set_sndbuf a
simple system call wrapper, more like other functions in tap-linux.c

Signed-off-by: Vladimir Sementsov-Ogievskiy <[email protected]>
Reviewed-by: Maksim Davydov <[email protected]>
Signed-off-by: Jason Wang <[email protected]>
2026-01-23 14:41:26 +08:00
Vladimir Sementsov-Ogievskiy 638a302b1b net/tap: tap_set_sndbuf(): add return value
Follow common recommendations in include/qapi/error.h of having
a return value together with errp. This allows to avoid error propagation.

Signed-off-by: Vladimir Sementsov-Ogievskiy <[email protected]>
Reviewed-by: Maksim Davydov <[email protected]>
Signed-off-by: Jason Wang <[email protected]>
2026-01-23 14:41:26 +08:00
Vladimir Sementsov-Ogievskiy 0b72ea1ff5 net/tap: setup exit notifier only when needed
No reason to setup notifier on each queue of multique tap,
when we actually want to run downscript only once.
As well, let's not setup notifier, when downscript is
not enabled (downsciprt="no").

Signed-off-by: Vladimir Sementsov-Ogievskiy <[email protected]>
Reviewed-by: Maksim Davydov <[email protected]>
Signed-off-by: Jason Wang <[email protected]>
2026-01-23 14:41:26 +08:00
Vladimir Sementsov-Ogievskiy fcc56cd23e net/tap: rework scripts handling
Simplify handling scripts: parse all these "no" and '\0' once, and
then keep simpler logic for net_tap_open() and net_init_tap_one(): NULL
means no script to run, otherwise run script.

Signed-off-by: Vladimir Sementsov-Ogievskiy <[email protected]>
Reviewed-by: Maksim Davydov <[email protected]>
Signed-off-by: Jason Wang <[email protected]>
2026-01-23 14:41:26 +08:00
Vladimir Sementsov-Ogievskiy dd6709b851 net/tap: pass NULL to net_init_tap_one() in cases when scripts are NULL
Directly pass NULL in cases where we report an error if script or
downscript are set.

Signed-off-by: Vladimir Sementsov-Ogievskiy <[email protected]>
Reviewed-by: Maksim Davydov <[email protected]>
Signed-off-by: Jason Wang <[email protected]>
2026-01-23 14:41:26 +08:00
Vladimir Sementsov-Ogievskiy fec61d48d1 net/tap: net_init_tap_one(): move parameter checking earlier
Let's keep all similar argument checking in net_init_tap() function.

Signed-off-by: Vladimir Sementsov-Ogievskiy <[email protected]>
Reviewed-by: Maksim Davydov <[email protected]>
Signed-off-by: Jason Wang <[email protected]>
2026-01-23 14:41:26 +08:00
Vladimir Sementsov-Ogievskiy f96f34d132 net/tap: net_init_tap_one(): drop extra error propagation
Signed-off-by: Vladimir Sementsov-Ogievskiy <[email protected]>
Reviewed-by: Maksim Davydov <[email protected]>
Signed-off-by: Jason Wang <[email protected]>
2026-01-23 14:41:26 +08:00
Houqi (Nick) Zuo a1708203b5 net/tap-linux.c: avoid abort when setting invalid fd
This patch removes abort() call in the tap_fd_set_vnet_hdr_len()
function. If the fd is found to be in a bad state (e.g., EBADFD
 or ENODEV), the function will print an error message.

When QEMU creates a tap device automatically and the tap device is
manually removed from the host while the guest is running, the tap
device file descriptor becomes invalid. Later, when the guest executes
shutdown, the tap_fd_set_vnet_hdr_len() function may be called and
abort QEMU with a core dump when attempting to use the invalid fd.
The expected behavior for this negative test case is that QEMU should
report an error but continue running rather than aborting.

Testing:
- Start QEMU with automatically created tap device
- Manually remove the tap device on the host
- Execute shutdown in the guest
- Verify QEMU reports an error but does not abort

Fixes: 0caed25cd1 ("virtio: Call set_features during reset")
Signed-off-by: Houqi (Nick) Zuo <[email protected]>
Signed-off-by: Jason Wang <[email protected]>
2026-01-23 14:32:54 +08:00
Alex Bennée cf10273aff hw/intc: avoid byte swap fiddling in gicv3 its path
This allows us to keep the MSI data in plain host order all the way
from the MemoryRegionOps write method to the final KVM_SIGNAL_MSI
ioctl. This fixes a theoretical bug on big-endian hosts because we
were using different size byte swaps which would have truncated the data.

Signed-off-by: Alex Bennée <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Message-id: [email protected]
Cc: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-01-22 11:25:26 +00:00
Alex Bennée a051f78714 hw/intc: declare GICv3 regions as little endian
The GIC should always be a little-endian device as big-endian
behaviour is a function of the current CPU configuration not the
system as a whole. This should have no functional effect as the GIC
cannot be instantiated on a BE system but will help the single binary
efforts.

Signed-off-by: Alex Bennée <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-01-22 11:25:26 +00:00
Alex Bennée 62b688d7eb hw/intc: declare GIC regions as little endian
The GIC should always be a little-endian device as big-endian
behaviour is a function of the current CPU configuration not the
system as a whole. This should have no functional effect as the GIC
cannot be instantiated on a BE system but will help the single binary
efforts.

Signed-off-by: Alex Bennée <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-01-22 11:25:26 +00:00
Alex Bennée 41dd8982f9 hw/intc: declare NVIC regions as little endian
The NVIC should always be a little-endian device as big-endian
behaviour is a function of the current CPU configuration not the
system as a whole. Indeed the Armv8-M architecture reference manual
declares:

  All accesses to the Private Peripheral Bus (PPB) are always
  little-endian, which means that the PE assumes a little-endian
  arrangement of the PPB registers.

This should have no functional effect as the NVIC cannot be
instantiated on a BE system but will help the single binary efforts.

Signed-off-by: Alex Bennée <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-01-22 11:25:26 +00:00
Peter Maydell 75f48413bb all: Clean up includes
This commit was created with scripts/clean-includes:
 ./scripts/clean-includes '--git' 'all' '--all'

and manually edited to remove one change to hw/virtio/cbor-helpers.c.
All these changes are header files that include osdep.h or some
system header that osdep.h pulls in; they don't need to do this.

All .c should include qemu/osdep.h first.  The script performs three
related cleanups:

* Ensure .c files include qemu/osdep.h first.
* Including it in a .h is redundant, since the .c  already includes
  it.  Drop such inclusions.
* Likewise, including headers qemu/osdep.h includes is redundant.
  Drop these, too.

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-id: [email protected]
2026-01-22 11:23:31 +00:00
Peter Maydell dc249aaf57 misc: Clean up includes
This commit deals with various .c files that included system
headers that are already pulled in by osdep.h, where the .c
file includes osdep.h already itself.

This commit was created with scripts/clean-includes:
 ./scripts/clean-includes '--git' 'misc' 'hw/core' 'semihosting' 'target/arm' 'target/i386/kvm/kvm.c' 'target/loongarch' 'target/riscv' 'tools' 'util'

All .c should include qemu/osdep.h first.  The script performs three
related cleanups:

* Ensure .c files include qemu/osdep.h first.
* Including it in a .h is redundant, since the .c  already includes
  it.  Drop such inclusions.
* Likewise, including headers qemu/osdep.h includes is redundant.
  Drop these, too.

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-id: [email protected]
2026-01-22 11:23:31 +00:00
Peter Maydell 6b0d081e60 bsd-user: Clean up includes
This commit was created with scripts/clean-includes:
 ./scripts/clean-includes '--git' 'bsd-user' 'bsd-user'

All .c should include qemu/osdep.h first.  The script performs three
related cleanups:

* Ensure .c files include qemu/osdep.h first.
* Including it in a .h is redundant, since the .c  already includes
  it.  Drop such inclusions.
* Likewise, including headers qemu/osdep.h includes is redundant.
  Drop these, too.

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Warner Losh <[email protected]>
Message-id: [email protected]
2026-01-22 11:23:31 +00:00
Peter Maydell 2be48b31b4 mshv: Clean up includes
This commit was created with scripts/clean-includes:
 ./scripts/clean-includes '--git' 'mshv' 'accel/mshv' 'target/i386/mshv' 'include/system/mshv.h'

All .c should include qemu/osdep.h first.  The script performs three
related cleanups:

* Ensure .c files include qemu/osdep.h first.
* Including it in a .h is redundant, since the .c  already includes
  it.  Drop such inclusions.
* Likewise, including headers qemu/osdep.h includes is redundant.
  Drop these, too.

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-id: [email protected]
2026-01-22 11:23:31 +00:00
Peter Maydell bb442dfe37 scripts/clean-includes: Update exclude list
Remove from the exclude list:
 * tests/plugin, which is a non-existent directory. This was
   probably intended to exclude tests/tcg/plugins/, which is caught
   by the tests/tcg exclude pattern anyway
Add to the exclude list:
 * rust/ -- the headers in here are purely for input to bindgen
 * target/hexagon has some standalone tools used at build time
 * linux-user/gen-vsdo.c -- another standalone tool
 * linux-user/mips64/elfload.c just includes mips/elfload.c
 * scripts/xen-detect.c is feature-detection code used by meson.build
 * tests/tracetool/simple.c is autogenerated
 * tests/unit/ has some "C file just includes another one" files
 * include/system/os-wasm.h is like os-posix.h and os-win32.h and
   shouldn't be adjusted

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-id: [email protected]
2026-01-22 11:23:31 +00:00
Peter Maydell 84ba328353 scripts/clean-includes: Give the args in git commit messages
If clean-includes is creating a git commit for its changes,
currently it says only "created with scripts/clean-includes".
Add the command line arguments the user passed us, as useful
extra information.

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Message-id: [email protected]
2026-01-22 11:23:31 +00:00
Peter Maydell 3398e2a23f scripts/clean-includes: Do all our exclusions with REGEXFILE
We currently have two mechanisms for excluding files:
 * the REGEXFILE which excludes by regex
 * special cases in the "loop over each file" which make
   us skip the file

Roll all the "skip this" cases into REGEXFILE, so we use
a single mechanism for identifying which files to exclude.

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-id: [email protected]
2026-01-22 11:23:31 +00:00
Peter Maydell 8a4a5c68c4 scripts/clean-includes: Make ignore-regexes one per line
Currently we have a single extended regular expression defining
files that clean-includes should ignore. This is now very long
and awkward to read and edit.

Switch to having a list of newline-separated EREs that we write
to a file for grep's -f option, so we can express them more
legibly in the shell script. We allow for comments in the
regex list, which lets us document why we have put the
exclusions in.

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-id: [email protected]
2026-01-22 11:23:31 +00:00
Peter Maydell 490d685588 scripts/clean-includes: Remove outdated comment
Remove an old comment suggesting a manual shell line to use to find
files to run the script on. The script's exclude-list and its
support for directory names make this irrelevant.

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-id: [email protected]
2026-01-22 11:23:31 +00:00
Peter Maydell cc349b568c scripts/clean-includes: Allow directories on command line
Currently clean-includes supports two ways of specifying files to check:
 * --all to run on everything
 * specific files
There's no way to say "check everything in target/arm".

Add support for handling directory names, by always running
the arguments through git ls-files.

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-id: [email protected]
2026-01-22 11:23:31 +00:00
Peter Maydell d154001f5a docs: Be consistent about capitalization of 'Arm' (again)
The company 'Arm' went through a rebranding many years back
involving a recapitalization from 'ARM' to 'Arm'. As a result
our documentation is a bit inconsistent between the two forms.
It's not worth trying to update everywhere in QEMU, but it's
easy enough to make docs/ consistent.

We last did this in commit 6fe6d6c9a in 2020, but a few new
uses of the wrong capitalization have crept back in since.

As before, "ARMv8" and similar architecture names, and
older CPU names like "ARM926" still retain all-caps.

In a few places we make minor grammar fixups as we touch
the sentences we're fixing.

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-id: [email protected]
2026-01-22 11:23:31 +00:00
Mauro Carvalho Chehab d9aa110bf1 kernel-doc.py: sync with upstream Kernel v6.19-rc4
The changes here are aligned up to this Linux changeset:
	f64c7e113dc9 ("scripts: docs: kdoc_files.py: don't consider symlinks as directories")

On other words, everything that it is there, except for the
patch moving the library to tools/lib/python.

Signed-off-by: Mauro Carvalho Chehab <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Message-id: 54dec248994abf37c4b5b9e48d5ab8f0f8df6f2d.1767716928.git.mchehab+huawei@kernel.org
Acked-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
2026-01-22 11:23:31 +00:00
Bernhard Beschow 43f9287d3a docs/system/arm/imx8mp-evk: Avoid suggesting redundant CLI parameters
Commit 094fd7d36f ("hw/arm/imx8mp-evk: Add KVM support") introduced KVM
support for the imx8mp-evk machine. KVM only works with the "host" CPU type
such that it has been made the default CPU type for KVM. No need to repeat
that on the command line.

Fixes: 094fd7d36f ("hw/arm/imx8mp-evk: Add KVM support")
Signed-off-by: Bernhard Beschow <[email protected]>
Message-id: [email protected]
Reviewed-by: Peter Maydell <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
2026-01-22 11:23:31 +00:00
Bernhard Beschow 582a8f30ea hw/arm/imx8mp-evk: Provide some defaults matching real hardware
Having four CPUs and 6 GiB of RAM matches real hardware. Fix the machine
defaults to make its use more ergonomic and less error-prone.

Signed-off-by: Bernhard Beschow <[email protected]>
Message-id: [email protected]
Reviewed-by: Peter Maydell <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
2026-01-22 11:23:30 +00:00
Philippe Mathieu-Daudé 1280ec826e cpus: Allocate maximum number of ASes supported by the arch
Instead of computing the number of address spaces used for a given
architecture, machine, and CPU configuration, simplify the code by
always allocating the maximum number of CPUAddressSpaces supported
by the architecture.

Signed-off-by: Gustavo Romero <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
2026-01-22 10:48:46 +01:00
Gustavo Romero 1d60038fc8 target/arm: Add a _MAX sentinel to ARMASIdx enum
Add a sentinel to the ARMASIdx enum so it can be used to compute the
total number of address spaces supported by the arch.

Signed-off-by: Gustavo Romero <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-01-22 10:48:46 +01:00
Gustavo Romero 500bf3dfcf target/i386: Add a _MAX sentinel to X86ASIdx enum
Add a sentinel to the X86ASIdx enum so it can be used to compute the
total number of address spaces supported by the arch.

Signed-off-by: Gustavo Romero <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-01-22 10:48:46 +01:00
Gustavo Romero d6f174f61d target/arm: Initialize AS 0 first
Move the initialization of AS of index 0 (ARMASIdx_NS) so it happens
before the initialization of the other address spaces. This is purely a
code organization change with no effect on behavior.

Signed-off-by: Gustavo Romero <[email protected]>
Suggested-by: Alex Bennée <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-01-22 10:48:46 +01:00
Philippe Mathieu-Daudé a2290fa210 dump: Build stubs once for non-x86 targets
Rather than compiling the same content for all targets (unused
most of the time, i.e. qemu-system-avr ...), extract the non
x86 specific parts to a stub file and build it once for all
non-x86 targets.

Add a Kconfig symbol to only select the target-specific file
with the x86 target (rename this file with '-x86' suffix).

Since Kconfig symbols aren't evaluated for user emulation,
the file unit is only built for system emulation.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Marc-André Lureau <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <[email protected]>
2026-01-22 10:48:46 +01:00
Philippe Mathieu-Daudé 40b51dd9b4 dump: Abort in create_win_dump() on non-x86 guests
qmp_dump_guest_memory() checks win_dump_available()
before calling create_win_dump(). On non-x86 targets
calling it would be a programming error, so abort.

Reviewed-by: Marc-André Lureau <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <[email protected]>
2026-01-22 10:48:45 +01:00
Philippe Mathieu-Daudé da38740554 configs/targets: Forbid s390x to use legacy native endianness APIs
All s390x-related binaries are buildable without a single
use of the legacy "native endian" API. Set the transitional
TARGET_NOT_USING_LEGACY_NATIVE_ENDIAN_API definition to forbid
further uses of the legacy API.

Preliminary commits allowing this final change:

 . f0853c2586 target/s390x: Inline translator_lduw() and translator_ldl()
 . ee4dae6a33 target/s390x: Use big-endian variant of cpu_ld/st_data*()
 . 381a1fda5b target/s390x: Inline cpu_ld{uw, l}_code() calls in EX opcode helper
 . 69da23130f target/s390x: Replace MO_TE -> MO_BE
 . 0fb6ad781c target/s390x: Replace gdb_get_regl() -> gdb_get_reg64()
 . 409cbb1a61 target/s390x: Use explicit big-endian LD/ST API
 . 6d9dad7126 target/s390x: Replace HOST_BIG_ENDIAN #ifdef with if() check

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Manos Pitsidianakis <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <[email protected]>
2026-01-22 10:48:45 +01:00
Philippe Mathieu-Daudé a68b332fc8 configs/targets: Forbid Renesas RX to use legacy native endianness API
The qemu-system-rx binary is buildable without a single
use of the legacy "native endian" API. Set the transitional
TARGET_NOT_USING_LEGACY_NATIVE_ENDIAN_API definition to forbid
further uses of the legacy API.

Preliminary commits allowing this final change:

 . b0afb81271 target/rx: Inline translator_lduw() and translator_ldl()
 . 41a1b46c3b target/rx: Use explicit little-endian LD/ST API
 . de1f3d628e target/rx: Use little-endian variant of cpu_ld/st_data*()
 . 0f4af4e267 target/rx: Use MemOp type in gen_ld[u]() and gen_st()
 . 2062fa663c target/rx: Propagate DisasContext to generated helpers
 . 8b71fd6ffe target/rx: Propagate DisasContext to push() / pop()
 . 363fff6d1b target/rx: Propagate DisasContext to gen_ld[u]() and gen_st()
 . cb8e4556d5 target/rx: Factor mo_endian() helper out
 . f9903a8a23 target/rx: Replace MO_TE -> MO_LE

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Manos Pitsidianakis <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-01-22 10:48:45 +01:00
Philippe Mathieu-Daudé 8790da3161 configs/targets: Forbid TriCore to use legacy native endianness API
The qemu-system-tricore binary is buildable without a single
use of the legacy "native endian" API. Set the transitional
TARGET_NOT_USING_LEGACY_NATIVE_ENDIAN_API definition to forbid
further uses of the legacy API.

Preliminary commits allowing this final change:

 . 8075a0a547 target/tricore: Inline translator_lduw()
 . 4a4b272ae8 target/tricore: Use little-endian variant of cpu_ld/st_data*()
 . cd08bcaa36 target/tricore: Expand TCGv type for 32-bit target
 . 8a2235dd07 target/tricore: Un-inline various helpers
 . e843ef2bba target/tricore: Pass DisasContext as first argument
 . 4f08815467 target/tricore: Expand TCG helpers for 32-bit target
 . f30c8aa229 target/tricore: Inline tcg_gen_ld32u_tl()
 . 6b2e4fcb83 target/tricore: Declare registers as TCGv_i32
 . c558aa9421 target/tricore: Replace target_ulong -> uint32_t in op_helper.c
 . 30257dcd2b target/tricore: Remove unnecessary cast to target_ulong
 . 44e2b68d27 target/tricore: Remove target_ulong use in gen_addi_d()
 . a15e899626 target/tricore: Remove target_ulong use in translate_insn() handler
 . 0d5f954256 target/tricore: Replace target_ulong -> vaddr with tlb_fill() callees
 . 809b460f30 target/tricore: Remove target_ulong use in gen_goto_tb()

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Manos Pitsidianakis <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-01-22 10:48:45 +01:00
Philippe Mathieu-Daudé f2a334c5f5 configs/targets: Forbid OpenRISC to use legacy native endianness APIs
All OpenRISC-related binaries are buildable without a single
use of the legacy "native endian" API. Set the transitional
TARGET_NOT_USING_LEGACY_NATIVE_ENDIAN_API definition to forbid
further uses of the legacy API.

Preliminary commits allowing this final change:

 . 52392f95e6 target/openrisc: Inline translator_ldl()
 . 16c0efb5a7 target/openrisc: Use explicit big-endian LD/ST API
 . 5b67dbf1dc target/openrisc: Replace target_ulong -> uint32_t
 . 500708331e target/openrisc: Inline tcg_gen_trunc_i64_tl()
 . 4f6c60683f target/openrisc: Replace MO_TE -> MO_BE
 . 73cd283e58 target/openrisc: Introduce mo_endian() helper
 . 2f737e19a4 target/openrisc: Conceal MO_TE within do_store()
 . 22c36c0a20 target/openrisc: Conceal MO_TE within do_load()
 . ef797ac002 target/openrisc: Explode MO_TExx -> MO_TE | MO_xx
 . 81e2fb236b target/openrisc: Remove 'TARGET_LONG_BITS != 32' dead code
 . 9dc4862dc4 target/openrisc: Use vaddr type for $pc jumps
 . 2367c94cbb target/openrisc: Remove target_ulong use in raise_mmu_exception()
 . 1843e89bec target/openrisc: Remove unused cpu_openrisc_map_address_*() handlers
 . a3c4facd39 target/openrisc: Do not use target_ulong for @mr in MTSPR helper
 . 2795bc52af target/openrisc: Replace VMSTATE_UINTTL() -> VMSTATE_UINT32()

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Manos Pitsidianakis <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-01-22 10:48:45 +01:00
Philippe Mathieu-Daudé c6056f9812 configs/targets: Forbid LoongArch to use legacy native endianness APIs
All LoongArch-related binaries are buildable without a single
use of the legacy "native endian" API. Set the transitional
TARGET_NOT_USING_LEGACY_NATIVE_ENDIAN_API definition to forbid
further uses of the legacy API.

Preliminary commits allowing this final change:

 . 6b4c30465c target/loongarch: Inline translator_ldl()
 . f9a03787c7 target/loongarch: Use explicit little-endian LD/ST API
 . 91312a6d04 target/loongarch: Inline cpu_ldl_code() call in cpu_do_interrupt()
 . 492b2799c6 target/loongarch: Replace MO_TE -> MO_LE

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Bibo Mao <[email protected]>
Message-Id: <[email protected]>
2026-01-22 10:48:45 +01:00
Philippe Mathieu-Daudé 403959d0f6 configs/targets: Forbid HPPA to use legacy native endianness APIs
All HPPA-related binaries are buildable without a single use
of the legacy "native endian" API. Set the transitional
TARGET_NOT_USING_LEGACY_NATIVE_ENDIAN_API definition to
forbid further uses of the legacy API.

Preliminary commits allowing this final change:

 . c77d0e9009 target/hppa: Use big-endian variant of cpu_ld/st_data*()
 . 75498b3f7b target/hppa: Use explicit big-endian LD/ST API
 . bcf5e5d3e3 target/hppa: Inline translator_ldl()
 . 7307ff9558 target/hppa: Replace MO_TE -> MO_BE
 . 6c1c734f78 target/hppa: Introduce mo_endian() helper
 . 64d1c17851 target/hppa: Conceal MO_TE within do_store_32/64()
 . 0807994a0c target/hppa: Conceal MO_TE within do_store()
 . e3da436711 target/hppa: Conceal MO_TE within do_load_32/64()
 . 4eef4dab50 target/hppa: Conceal MO_TE within do_load()
 . 714dd08fed target/hppa: Explode MO_TExx -> MO_TE | MO_xx

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Manos Pitsidianakis <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-01-22 10:48:45 +01:00
Philippe Mathieu-Daudé d78a07fb21 configs/targets: Forbid Hexagon to use legacy native endianness API
The qemu-hexagon binary is buildable without a single use
of the legacy "native endian" API. Set the transitional
TARGET_NOT_USING_LEGACY_NATIVE_ENDIAN_API definition to
forbid further uses of the legacy API.

Preliminary commits allowing this final change:

 . dffb3938aa target/hexagon: Use little-endian variant of cpu_ld/st_data*()
 . 989b25c73b target/hexagon: Inline translator_ldl()
 . beb38fda0f target/hexagon: Replace MO_TE -> MO_LE
 . fdcb7483ae target/hexagon: Explode MO_TExx -> MO_TE | MO_xx

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Manos Pitsidianakis <[email protected]>
Message-ID: <[email protected]>
2026-01-22 10:48:45 +01:00
Philippe Mathieu-Daudé 8b2f859063 system: Allow restricting the legacy DEVICE_NATIVE_ENDIAN definition
Guard the native endian definition we want to remove by surrounding
it with TARGET_NOT_USING_LEGACY_NATIVE_ENDIAN_API #ifdef'ry.
Assign values to the enumerators so they stay unchanged.

Once a target gets cleaned we'll set the definition in the target
config, then the target won't be able to use the legacy API anymore.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-01-22 10:48:45 +01:00
Philippe Mathieu-Daudé a9c39c7083 system: Allow restricting the legacy MO_TE* 'native-endian' definitions
Guard the native endian definitions we want to remove by surrounding
them with TARGET_NOT_USING_LEGACY_NATIVE_ENDIAN_API #ifdef'ry.

Once a target gets cleaned we'll set the definition in the
target config, then the target won't be able to use the legacy
API anymore.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-01-22 10:48:45 +01:00
Philippe Mathieu-Daudé f9e68a2c82 system: Allow restricting the legacy tswap() 'native-endian' API
Guard the native endian APIs we want to remove by surrounding
them with TARGET_NOT_USING_LEGACY_NATIVE_ENDIAN_API #ifdef'ry.

Once a target gets cleaned we'll set the definition in the
target config, then the target won't be able to use the legacy
API anymore.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-01-22 10:48:45 +01:00
Philippe Mathieu-Daudé 0fca27a4d5 system: Allow restricting the legacy translator_ld() 'native-endian' API
Guard the native endian APIs we want to remove by surrounding
them with TARGET_NOT_USING_LEGACY_NATIVE_ENDIAN_API #ifdef'ry.

Once a target gets cleaned we'll set the definition in the
target config, then the target won't be able to use the legacy
API anymore.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-01-22 10:48:45 +01:00
Philippe Mathieu-Daudé 2c9429d213 system: Allow restricting the legacy cpu_ld/st() 'native-endian' API
Guard the native endian APIs we want to remove by surrounding
them with TARGET_NOT_USING_LEGACY_NATIVE_ENDIAN_API #ifdef'ry.

Once a target gets cleaned we'll set the definition in the
target config, then the target won't be able to use the legacy
API anymore.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-01-22 10:48:45 +01:00
Philippe Mathieu-Daudé 5d267f5b85 system: Allow restricting legacy address_space_ldst() native-endian API
Guard the native endian APIs we want to remove by surrounding
them with TARGET_NOT_USING_LEGACY_NATIVE_ENDIAN_API #ifdef'ry.

Once a target gets cleaned we'll set the definition in the
target config, then the target won't be able to use the legacy
API anymore.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-01-22 10:48:45 +01:00
Philippe Mathieu-Daudé 23b34de6df system: Allow restricting the legacy ld/st_phys() 'native-endian' API
Guard the native endian APIs we want to remove by surrounding
them with TARGET_NOT_USING_LEGACY_NATIVE_ENDIAN_API #ifdef'ry.

Since all targets can check the definition, do not poison it.

Once a target gets cleaned we'll set the definition in the
target config, then the target won't be able to use the legacy
API anymore.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Manos Pitsidianakis <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-01-22 10:48:45 +01:00
Philippe Mathieu-Daudé d5461ff4eb system/memory: Directly call address_space_ldst[M]_internal() helper
Inline internal address_space_ld/st[L,D,Q] helpers,
directly calling address_space_ldst[M]_internal().

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-01-22 10:48:45 +01:00
Philippe Mathieu-Daudé dd1b3aaa05 system/memory: Use ldm_p() and stm_p() helpers
address_space_{ld,st}m_internal() take a MemOp argument
so can directly use the {ld,st}m_p() helpers.

Suggested-by: Paolo Bonzini <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-01-22 10:48:45 +01:00
Philippe Mathieu-Daudé c790e17de2 system/memory: Pass device_endian argument as MemOp bit
Use the MemOp argument to hold both the access size and
its endianness.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-01-22 10:48:45 +01:00
Philippe Mathieu-Daudé 9c2ed58b6d system/memory: Factor address_space_ldst[M]_internal() helper out
All the LD/ST[W,L,Q] variants use the same template, only
modifying the access size used. Unify as a single pair of
LD/ST methods taking a MemOp argument. Thus use the 'm'
suffix for MemOp.

Keep the pre-existing "warning: addr must be aligned" comment.

We leave the wonder about why we aren't asserting alignment
for later.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-01-22 10:48:45 +01:00
Philippe Mathieu-Daudé 99989213a2 system/memory: Define address_space_ldst[Q] endian variants via template
Define address_space_ldst[Q] endian variants via template.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-01-22 10:48:45 +01:00
Philippe Mathieu-Daudé 2cdca569bd system/memory: Define address_space_ldst[L] endian variants via template
Define address_space_ldst[L] endian variants via template.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-01-22 10:48:45 +01:00
Philippe Mathieu-Daudé 08bcb64bce system/memory: Define address_space_ldst[W] endian variants via template
Like we do for other LD/ST APIs, use one template to declare and
define all endianness variants of the address_space_ldst[W] methods.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-01-22 10:48:45 +01:00
Philippe Mathieu-Daudé cfb88b2ce3 system/memory: Introduce ldm_p() and stm_p() load/store helpers
Introduce load/store helpers which take a MemOp argument.

Inspired-by: Paolo Bonzini <[email protected]>
Suggested-by: Richard Henderson <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <[email protected]>
2026-01-22 10:48:45 +01:00
Philippe Mathieu-Daudé e3bf323f53 bswap: Remove unnecessary 'qemu/bswap.h'
"qemu/host-utils.h" and "qemu/int128.h" are included a lot in
the tree, and don't use any definition from "qemu/bswap.h"...
Since it contains a lot of inlined functions, remove it to
reduce pointless compilation cycles.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-01-22 10:48:45 +01:00
Philippe Mathieu-Daudé e44dc42f3a bswap: Use 'qemu/bswap.h' instead of 'qemu/host-utils.h'
These files only require "qemu/bswap.h", not "qemu/host-utils.h".

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-01-22 10:48:45 +01:00
Philippe Mathieu-Daudé 3115691855 bswap: Include missing 'qemu/bswap.h' header
All these files indirectly include the "qemu/bswap.h" header.
Make this inclusion explicit to avoid build errors when
refactoring unrelated headers.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-01-22 10:48:45 +01:00
Philippe Mathieu-Daudé 81c389fd6f target/ppc: Simplify endianness handling in Altivec opcodes
Access the memory in big-endian order,
swap bytes when MSR.LE is set.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <[email protected]>
2026-01-22 10:46:36 +01:00
Philippe Mathieu-Daudé ff9359fca2 target/sh4: Replace cpu_stl_data() call in OCBI helper
In preparation of removing the cpu_stl_data() call,
inline it. Set the return address argument.

See commit 852d481faf ("SH: Improve movca.l/ocbi
emulation") for more context on this code.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <[email protected]>
2026-01-22 10:42:19 +01:00
Philippe Mathieu-Daudé 4cc30fe59f target/sparc: Use big-endian variant of cpu_ld/st_data*()
We only build the SPARC targets using big endianness order,
therefore the cpu_ld/st_data*() definitions expand to the big
endian declarations. Use the explicit big-endian variants.

Mechanical change running:

  $ tgt=sparc; \
    end=be; \
    for op in data mmuidx_ra; do \
      for ac in uw sw l q; do \
        sed -i -e "s/cpu_ld${ac}_${op}/cpu_ld${ac}_${end}_${op}/" \
                  $(git grep -l cpu_ target/${tgt}/); \
      done;
      for ac in w l q; do \
        sed -i -e "s/cpu_st${ac}_${op}/cpu_st${ac}_${end}_${op}/" \
                  $(git grep -l cpu_ target/${tgt}/); \
      done;
    done

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <[email protected]>
2026-01-22 10:42:05 +01:00
Philippe Mathieu-Daudé 9668079d8b target/m68k: Use big-endian variant of cpu_ld/st_data*()
We only build the M68k target using big endianness order,
therefore the cpu_ld/st_data*() definitions expand to the
big endian declarations. Use the explicit big-endian variants.

Mechanical change running:

  $ tgt=m68k; \
    end=be; \
    for op in data mmuidx_ra; do \
      for ac in uw sw l q; do \
        sed -i -e "s/cpu_ld${ac}_${op}/cpu_ld${ac}_${end}_${op}/" \
                  $(git grep -l cpu_ target/${tgt}/); \
      done;
      for ac in w l q; do \
        sed -i -e "s/cpu_st${ac}_${op}/cpu_st${ac}_${end}_${op}/" \
                  $(git grep -l cpu_ target/${tgt}/); \
      done;
    done

Then adapting indentation in do_stack_frame() to pass checkpatch.pl.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <[email protected]>
2026-01-22 10:41:49 +01:00
Philippe Mathieu-Daudé b7f18d2980 target/riscv: Use little-endian variant of cpu_ld/st_data*() for vector
RISC-V vector "elements are simply packed in order from
the least-signicant to most-signicant bits of the vector
register" [*] which is little endianness, therefore the
cpu_ld/st_data*() definitions expand to the little endian
declarations. Use the explicit little-endian variants.

[*] RISC-V "V" Vector Extension v1.0

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Daniel Henrique Barboza <[email protected]>
Message-Id: <[email protected]>
2026-01-22 10:41:37 +01:00
Philippe Mathieu-Daudé 3c8f525e93 target/i386: Use little-endian variant of cpu_ld/st_data*()
We only build the X86 targets using little endianness order,
therefore the cpu_ld/st_data*() definitions expand to the little
endian declarations. Use the explicit little-endian variants.

Mechanical change running:

  $ tgt=i386; \
    end=le; \
    for op in data mmuidx_ra; do \
      for ac in uw sw l q; do \
        sed -i -e "s/cpu_ld${ac}_${op}/cpu_ld${ac}_${end}_${op}/" \
                  $(git grep -l cpu_ target/${tgt}/); \
      done;
      for ac in w l q; do \
        sed -i -e "s/cpu_st${ac}_${op}/cpu_st${ac}_${end}_${op}/" \
                  $(git grep -l cpu_ target/${tgt}/); \
      done;
    done

Then adapting indentation in helper_vmload() to pass checkpatch.pl.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <[email protected]>
2026-01-22 10:41:18 +01:00
Richard Henderson 2339d0a1cf Merge tag 'hw-misc-20260120' of https://github.com/philmd/qemu into staging
Misc HW patches

- Generalized IOMMU test framework
- Fix Freescale SDHCI endianness issues
- Support for zboot images compressed with Zstd
- Pcap support to analyze UEFI firmware traffic

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCAAdFiEE+qvnXhKRciHc/Wuy4+MsLN6twN4FAmlvzsUACgkQ4+MsLN6t
# wN5G4BAAzpNnhYe09TMrn/pUBMbXqmYGXTpOXxkkes922X1Xt/qpo1LGSgcMnW8j
# p1ju7rWa3r3TIqkPPzHlyxaZrcMMUBTEdJ/u5tOeD19aNzQHQTTWKErqIucZOLZl
# /DElbpNGakEDHyqX4BMZW+zfIkjIou0ZWh95hyHPnDPK7aJrbLvWrz2tcaOsqfDI
# WYNf8BrCEwbKTvnBis7/IYOGH2sK8ZUgMwXShLbhnAIdFoVLwlBwGbosH/wR/qW0
# Ql/hPEovXfBN7J1w9cYM8gfSOanZ5Hs1fC9K/FXHA9/TDkF3xYOwp9ky85y6fJO3
# lbD9wzAsNIdzOgj8s90AihTr5FFa+XK1SUTHR5xcTyou5zR73N4cGjmwJT6xvu0W
# Noy89Jsg+DhFXYWBcnNr0XxUgNnPe0zRV1YZJNEwJm+ODiY9o/St7cKtcM1wYPKZ
# y1vgRT7nxbI41F7cAJH/sEFigNWDkDdP3QSqHCwWpJG2urPtT/7iaFH4k4VoNUab
# YfplDcoXGTljGEHI0l4hqauSelo5VyDcMCajXfqkgXawSdMTWxFxhpr68zRoY2//
# KaIu4czG82iSAN4hFj8KySzwHT5dQizCGa98CrMHhf4JLwYkd7g80KRjNvFxWNhk
# JJ6ciqpN+M7pZUihLd222Oz5/Jjf/qXpkRPIYO/kaDvzZ2uL7/c=
# =uody
# -----END PGP SIGNATURE-----
# gpg: Signature made Wed 21 Jan 2026 05:51:49 AM AEDT
# gpg:                using RSA key FAABE75E12917221DCFD6BB2E3E32C2CDEADC0DE
# gpg: Good signature from "Philippe Mathieu-Daudé (F4BUG) <[email protected]>" [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: FAAB E75E 1291 7221 DCFD  6BB2 E3E3 2C2C DEAD C0DE

* tag 'hw-misc-20260120' of https://github.com/philmd/qemu: (29 commits)
  meson: Do not try to build module for empty per-target hw/ directory
  hw/virtio-nsm: include qemu/osdep.h
  hw/uefi: add pcap support
  hw: move pcap structs to header file
  hw/loader: Add support for zboot images compressed with zstd
  hw/loader: Use g_autofree in unpack_efi_zboot_image()
  hw/loader: Rename UBOOT_MAX _GUNZIP_BYTES to _DECOMPRESSED_BYTES
  hw/loader: Rename LOAD_IMAGE_MAX _GUNZIP_BYTES to _DECOMPRESSED_BYTES
  hw/sd/trace-events: Remove redundant "SWITCH " command name
  hw/sd/sdhci: Remove vendor property
  hw/sd/sdhci: Remove endianness property
  hw/arm/fsl-imx25: Extract TYPE_FSL_ESDHC_LE
  hw/ppc/e500: Use TYPE_FSL_ESDHC_BE
  hw/sd/sdhci: Add TYPE_FSL_ESDHC_BE
  hw/sd/sdhci: Rename usdhc_ functions
  hw/sd/sdhci: Consolidate eSDHC constants
  Revert "hw/sd/sdhci: Rename ESDHC_* defines to USDHC_*"
  hw/arm/fsl-imx25: Apply missing reset quirk
  hw/arm/fsl-imx6: Fix naming of SDHCI related constants and attributes
  hw/arm/fsl-imx6: Remove now redundant setting of "sd-spec-version" property
  ...

Signed-off-by: Richard Henderson <[email protected]>
2026-01-21 07:39:57 +11:00
Richard Henderson 464f49bf90 Merge tag 'pull-trivial-patches' of https://gitlab.com/mjt0k/qemu into staging
trivial patches for 2026-01-20

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCgAdFiEEZKoqtTHVaQM2a/75gqpKJDselHgFAmlvdRoACgkQgqpKJDse
# lHilOw//fdYjk7Ls+M2F0zgIKHbtQj/ACeIXtYr9mLwgUHCVnYByMbaqVVvyuCfZ
# 6n7unTRC6UyhmAgVz5F9RElUBxrRucqgXHXo9QcbvIBBZoWsnWAXjNWmV6kqBF4s
# L8cDniWRLwwkRaGTf1jjOEHJz8ilVwpXfvbQRkU9KJNelFkoh1rprxj3hkw1hF9C
# TpGda15ho7EaplRdfpN+qjOlHpShgbF2qMPUz1zZAWcpomZK8U5/xiHcuE9Y19/L
# tLC6lEkt1nR+xW/5JRptCAke8jLgLlYUHGsXdZuahpXwfK++ITCtM95X2Ra44gMR
# M3xC8hmcpaO5aF/2JoMkLS7LnuenJ093oBIwyhC9LM+MYt/NWIwLIItu22V25qRj
# bEuD2avDSiR0tWDikzxezj5J7riYsDQCt004Ycw7roBZeEI7yngXD2YTkkurSDjb
# wPvzg+qW8WM9n5K9Mxi66F0C7dFU0lru817nJO3dj4ayPJ7B6Elr47n5NpcfAEpP
# dn7j4+nj2puvAyXcfGwLQyU/o/ayJxkEvAZja1Q5sONwMqf0GHIZ9fDu63njkClQ
# rvzKyIKhRv3inmr65nO8RvnZe/j4ONhJ07IwMEBFjUMqW7aXu0GYPx0no7rtWZvQ
# NXypCGE+ag+PYetcOu2tHjaOLQG5/43eBEWSFCgns5UJcrB6vJ4=
# =u20D
# -----END PGP SIGNATURE-----
# gpg: Signature made Tue 20 Jan 2026 11:29:14 PM AEDT
# gpg:                using RSA key 64AA2AB531D56903366BFEF982AA4A243B1E9478
# gpg: Good signature from "Michael Tokarev <[email protected]>" [unknown]
# gpg:                 aka "Michael Tokarev <[email protected]>" [unknown]
# gpg:                 aka "Michael Tokarev <[email protected]>" [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: 9D8B E14E 3F2A 9DD7 9199  28F1 61AD 3D98 ECDF 2C8E
#      Subkey fingerprint: 64AA 2AB5 31D5 6903 366B  FEF9 82AA 4A24 3B1E 9478

* tag 'pull-trivial-patches' of https://gitlab.com/mjt0k/qemu:
  bsd-user/syscall_defs.h: define STAT_TIME_T_EXT only for 32 bits
  linux-user/aarch64/target_fcntl.h: add missing TARGET_O_LARGEFILE definition
  configure: add ppc target back to container tests
  MAINTAINERS: Add docs/system/i386/ to the general x86 architecture section
  tests/qemu-iotests: Use "gsed" for expressions that require GNU sed
  configure: Set $PYTHON in the configuration of the optionroms
  tests: fix comment declaring runtime in rv64 interruptedmemory test
  qemu-options.hx: use KiB, MiB, GiB for power-of-2 units
  gdbstub: unlink the unix socket before bind()
  Revert "gdbstub: Try unlinking the unix socket before binding"

Signed-off-by: Richard Henderson <[email protected]>
2026-01-21 07:38:12 +11:00
Philippe Mathieu-Daudé e8efe5ff4a meson: Do not try to build module for empty per-target hw/ directory
In commit 83d5db95d3 ("meson: Allow system binaries to not
have target-specific units") we allowed targets with empty
target_system_arch[] source set, but missed hw_arch[] could
also be empty when building modules.

Skip such case, otherwise due to commit a1ced48754
("hw/microblaze: Build files once"), building with
--enable-modules triggers:

  ../meson.build:4034:14: ERROR: Key microblaze is not in the dictionary.

Fixes: a1ced48754 ("hw/microblaze: Build files once")
Reported-by: Frederic Bezies <[email protected]>
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3272
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Message-Id: <[email protected]>
2026-01-20 19:51:36 +01:00
Paolo Bonzini b248ca4670 hw/virtio-nsm: include qemu/osdep.h
The file hw/virtio/cbor-helpers.c does not include our standard
qemu/osdep.h header, add it.

Reported-by: Peter Maydell <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Dorjoy Chowdhury <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-01-20 19:51:36 +01:00
Gerd Hoffmann 41e047ad66 hw/uefi: add pcap support
Add pcapfile property to uevi-vars-* devices, allowing to write out a
capture of the communication traffic between uefi firmware and qemu.

Signed-off-by: Gerd Hoffmann <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
[PMD: Wrap long line to avoid checkpatch.pl warning]
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-01-20 19:51:36 +01:00
Gerd Hoffmann 9aac42720c hw: move pcap structs to header file
Allow reusing them elsewhere in qemu.

Signed-off-by: Gerd Hoffmann <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-01-20 19:51:36 +01:00
Daan De Meyer 3a18e8a259 hw/loader: Add support for zboot images compressed with zstd
Reviewed-by: Daniel P. Berrangé <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Tested-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Daan De Meyer <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-01-20 19:51:36 +01:00
Daan De Meyer 3fd0734cb3 hw/loader: Use g_autofree in unpack_efi_zboot_image()
Reviewed-by: Daniel P. Berrangé <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Tested-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Daan De Meyer <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-01-20 19:51:36 +01:00
Daan De Meyer f9e1dcb7d3 hw/loader: Rename UBOOT_MAX _GUNZIP_BYTES to _DECOMPRESSED_BYTES
For consistency with LOAD_IMAGE_MAX_DECOMPRESSED_BYTES.

Signed-off-by: Daan De Meyer <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Tested-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-01-20 19:51:36 +01:00
Daan De Meyer 0d0ba24909 hw/loader: Rename LOAD_IMAGE_MAX _GUNZIP_BYTES to _DECOMPRESSED_BYTES
Preparation for adding support for zstd compressed efi zboot kernel
images.

Reviewed-by: Daniel P. Berrangé <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Tested-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Daan De Meyer <[email protected]>
Message-ID: <[email protected]>
[PMD: Wrap long line to avoid checkpatch.pl warning]
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-01-20 19:51:36 +01:00
Bernhard Beschow 4395c14a45 hw/sd/trace-events: Remove redundant "SWITCH " command name
"switch" is already part of the function name. No need to repeat it.

Signed-off-by: Bernhard Beschow <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Tested-by: BALATON Zoltan <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-01-20 19:51:36 +01:00
Bernhard Beschow 7980909d65 hw/sd/sdhci: Remove vendor property
Now that there are dedicated eSDHC device models it is possible to replace
the "vendor" property (which is really a device-specific property) with a
dynamic cast, "fishing" out only the device models which shall have the
quirk applied.

Signed-off-by: Bernhard Beschow <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Tested-by: BALATON Zoltan <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-01-20 19:51:36 +01:00
Bernhard Beschow ab49b0ac04 hw/sd/sdhci: Remove endianness property
The endianness property was only explicitly set in the e500 machine which
now instantiates TYPE_FSL_ESDHC_BE. The property could also not be used
meaningfully in a hypothetical, common TYPE_FSL_ESDHC device model since
sdhci_common_realize() would fail in that case or it would need to know
all MMIO implementations upfront. Remove the property in favor of dedicated
device models.

Signed-off-by: Bernhard Beschow <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Tested-by: BALATON Zoltan <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-01-20 19:51:36 +01:00
Bernhard Beschow ca35f8cc4d hw/arm/fsl-imx25: Extract TYPE_FSL_ESDHC_LE
Extract an eSDHC (little endian) device model since the uSDHC device model
will get an uSDHC-specific MMIO quirk.

Signed-off-by: Bernhard Beschow <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Tested-by: BALATON Zoltan <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-01-20 19:51:36 +01:00
Bernhard Beschow 3b8ea2c193 hw/ppc/e500: Use TYPE_FSL_ESDHC_BE
TYPE_FSL_ESDHC_BE maches real hardware more closely by reusing code of
TYPE_IMX_USDHC. For example, it fixes Linux to flood the guest console with
"mmc0: Internal clock never stabilised" messages in the QEMU advent calendar
2018 day 19 image.

Reported-by: Thomas Huth <[email protected]>
Signed-off-by: Bernhard Beschow <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Tested-by: BALATON Zoltan <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-01-20 19:51:36 +01:00
Bernhard Beschow 75e98bc4f8 hw/sd/sdhci: Add TYPE_FSL_ESDHC_BE
For now, TYPE_FSL_ESDHC_BE is basically a big-endian variant of
TYPE_IMX_USDHC. It will be used in the e500 machines in the next step which
prevents Linux to flood the console with "mmc0: Internal clock never
stabilised" messages.

Signed-off-by: Bernhard Beschow <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Tested-by: BALATON Zoltan <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-01-20 19:51:36 +01:00
Bernhard Beschow f8f1f5917c hw/sd/sdhci: Rename usdhc_ functions
The next patches will introduce eSDHC device models (big and little endian).
Prepare for that by renaming the functions. Also, this makes the code have
similar conventions as in Linux and U-Boot.

Signed-off-by: Bernhard Beschow <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Tested-by: BALATON Zoltan <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-01-20 19:51:36 +01:00
Bernhard Beschow c12125d26f hw/sd/sdhci: Consolidate eSDHC constants
Drop the "IMX_" part of the names since these are actually {E,U}SDHC
specific and apply for PowerPC-based SoCs as well. While at it
consolidate all ESDHC constants into the ESDHC section.

Signed-off-by: Bernhard Beschow <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Tested-by: BALATON Zoltan <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-01-20 19:51:36 +01:00
Bernhard Beschow 94f3a4d190 Revert "hw/sd/sdhci: Rename ESDHC_* defines to USDHC_*"
This reverts commit 1e76667f7a.

Unaware that the constants were named after Linux and U-Boot code,
commit 1e76667f7a ("hw/sd/sdhci: Rename ESDHC_* defines to USDHC_*")
changed the naming to be consistent with the function names. Fix the
constant naming to be consistent with Linux and U-Boot again. In the
next step, the function names will be renamed according to Linux and
U-Boot code as well.

Signed-off-by: Bernhard Beschow <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Tested-by: BALATON Zoltan <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-01-20 19:51:36 +01:00
Bernhard Beschow 37d65400b9 hw/arm/fsl-imx25: Apply missing reset quirk
Just like the Freescale MPC8569E SoC the i.MX25 features an eSDHC but
as little-endian variant. According to the datasheet TYPE_FSL_IMX25 requires
the same reset quirk as the e500 machines. The quirk was introduced in
d060b2789f ("hw/sd/sdhci: Set reset value of interrupt registers") for the
e500 machines, so reuse it now in TYPE_FSL_IMX25.

Signed-off-by: Bernhard Beschow <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Tested-by: BALATON Zoltan <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-01-20 19:51:36 +01:00
Bernhard Beschow c8145636be hw/arm/fsl-imx6: Fix naming of SDHCI related constants and attributes
The i.MX 6 SoC features uSDHC controllers which are the successors of eSDHC.
Fix the naming to make this clear.

Fixes: ec46eaa83a ("i.MX: Add i.MX6 SOC implementation.")
Signed-off-by: Bernhard Beschow <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Tested-by: BALATON Zoltan <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-01-20 19:51:36 +01:00
Bernhard Beschow 0c135c2f05 hw/arm/fsl-imx6: Remove now redundant setting of "sd-spec-version" property
Now that TYPE_IMX_USDHC sets this property internally it is not needed
on the SoC level any longer.

Signed-off-by: Bernhard Beschow <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Tested-by: BALATON Zoltan <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-01-20 19:51:36 +01:00
Bernhard Beschow 214f79fdfb hw/sd/sdhci: Fix TYPE_IMX_USDHC to implement sd-spec-version 3 by default
Fixes TYPE_FSL_IMX6UL, TYPE_FSL_IMX7, and TYPE_FSL_IMX8MP to implement
version 3 of the SD specification.

Note that TYPE_FSL_IMX6 already had "sd-spec-version" set accordingly and
that TYPE_FSL_IMX25 correctly sets the same property to version 2 since the
real hardware is an eSDHC which is the uSDHC's predecessor.

Fixes: fd1e5c8179 ("sdhci: Add i.MX specific subtype of SDHCI")
cc: qemu-stable
Signed-off-by: Bernhard Beschow <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Tested-by: BALATON Zoltan <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-01-20 19:51:36 +01:00
Tao Tang d8d19c31b2 tests/qtest: Add SMMUv3 bare-metal test using iommu-testdev
Add a qtest suite that validates ARM SMMUv3 translation without guest
firmware or OS. The tests leverage iommu-testdev to trigger DMA
operations and the qos-smmuv3 library to configure IOMMU translation
structures.

This test suite targets the virt machine and covers:
- Stage 1 only translation (VA -> PA via CD page tables)
- Stage 2 only translation (IPA -> PA via STE S2 tables)
- Nested translation (VA -> IPA -> PA, Stage 1 + Stage 2)
- Design to extended to support multiple security spaces
    (Non-Secure, Secure, Root, Realm)

Each test case follows this sequence:
1. Initialize SMMUv3 with appropriate command/event queues
2. Build translation tables (STE/CD/PTE) for the target scenario
3. Configure iommu-testdev with IOVA and DMA attributes via MMIO
4. Trigger DMA and validate successful translation
5. Verify data integrity through a deterministic write-read pattern

This bare-metal approach provides deterministic IOMMU testing with
minimal dependencies, making failures directly attributable to the SMMU
translation path.

Signed-off-by: Tao Tang <[email protected]>
Tested-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Message-ID: <[email protected]>
[PMD: Cover tests/qtest/iommu-smmuv3-test.c in MAINTAINERS]
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-01-20 19:51:36 +01:00
Tao Tang 489812e32d tests/qtest/libqos: Add SMMUv3 helper library
Introduce qos-smmuv3, a reusable library for SMMUv3-related qtest
operations. This module encapsulates common tasks like:

- SMMUv3 initialization (enabling, configuring command/event queues)
- Stream Table Entry (STE) and Context Descriptor (CD) setup
- Multi-level page table construction (L0-L3 for 4KB granules)
- Support for Stage 1, Stage 2, and nested translation modes
- Could be easily extended to support multi-space testing infrastructure
    (Non-Secure, Secure, Root, Realm)

The library provides high-level abstractions that allow test code to
focus on IOMMU behavior validation rather than low-level register
manipulation and page table encoding. Key features include:

- Provide memory allocation for translation structures with proper
    alignment
- Helper functions to build valid STEs/CDs for different translation
    scenarios
- Page table walkers that handle address offset calculations per
    security space

This infrastructure is designed to be used by iommu-testdev-based tests
and future SMMUv3 test suites, reducing code duplication and improving
test maintainability.

Signed-off-by: Tao Tang <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Fabiano Rosas <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-01-20 19:51:36 +01:00
Tao Tang a68650098a tests/qtest: Add libqos iommu-testdev helpers
Introduce a libqos helper module for the iommu-testdev
device used by qtests. This module provides some common functions to
all IOMMU test cases using iommu-testdev.

Wire the new sources into tests/qtest/libqos/meson.build so
they are built as part of the qtest support library.

Signed-off-by: Tao Tang <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-01-20 19:51:36 +01:00
Tao Tang 59a6b74aeb hw/arm/smmuv3-common: Add STE/CD set helpers for repeated field setup
This change introduces STE_SET_* and CD_SET_* helpers to centralize and
simplify repeated field setting logic.

Signed-off-by: Tao Tang <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Eric Auger <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-01-20 19:51:36 +01:00
Tao Tang ee1c84ded1 hw/arm/smmuv3-common: Add NSCFG bit definition for CD
Add NSCFG bit definition for CD structure. This allows proper
configuration of non-secure access settings in CD.

Signed-off-by: Tao Tang <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Eric Auger <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-01-20 19:51:36 +01:00
Tao Tang 6ce361b02c hw/misc: Introduce iommu-testdev for bare-metal IOMMU testing
Add a minimal PCI test device designed to exercise IOMMU translation
(such as ARM SMMUv3) without requiring guest firmware or OS. The device
provides MMIO registers to configure and trigger DMA operations with
controllable attributes (security state, address space), enabling
deterministic IOMMU testing.

Key features:
- Bare-metal IOMMU testing via simple MMIO interface
- Configurable DMA attributes for security states and address spaces
- Write-then-read verification pattern with automatic result checking

The device performs a deterministic DMA test pattern: write a known
value (0x12345678) to a configured GVA, read it back, and verify data
integrity. Results are reported through a dedicated result register,
eliminating the need for complex interrupt handling or driver
infrastructure in tests.

This is purely a test device and not intended for production use or
machine realism. It complements existing test infrastructure like
pci-testdev but focuses specifically on IOMMU translation path
validation.

Signed-off-by: Tao Tang <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Clément Mathieu--Drif <[email protected]>
Reviewed-by: Fabiano Rosas <[email protected]>
Message-ID: <[email protected]>
[PMD: Add SPDX-License-Identifier: GPL-2.0-or-later tag]
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-01-20 19:51:36 +01:00
Tao Tang 0a50d06fa1 hw/arm/smmuv3-common: Define STE/CD fields via registerfields
Switch STE/CD bitfield definitions and accessors to the
'registerfields.h' REG/FIELD API.

Signed-off-by: Tao Tang <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Eric Auger <[email protected]>
Message-ID: <[email protected]>
[PMD: Updated STE::CTXPTR_HI, STE::S2TTB_HI and CD:TTBx_HI lengths]
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-01-20 19:50:28 +01:00
Tao Tang 81ee3206f0 hw/arm/smmuv3: Extract common definitions to smmuv3-common.h
Move register definitions, command enums, and Stream Table Entry (STE) /
Context Descriptor (CD) structure definitions from the internal header
hw/arm/smmuv3-internal.h to a new common header
include/hw/arm/smmuv3-common.h.

This allows other components, such as generic SMMUv3 tests or test devices,
to utilize these definitions without including the specific SMMUv3 device
internal state.

Signed-off-by: Tao Tang <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Eric Auger <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-01-20 18:23:05 +01:00
Pierrick Bouvier f0de58ccf6 bsd-user/syscall_defs.h: define STAT_TIME_T_EXT only for 32 bits
Commit 369c1ba2b changed the wrong conditional "#if defined(__i386__)" to
"#if defined(TARGET_I386)".
However, TARGET_I386 is defined for target x86_64 also.

This commit fixes it by identifying correctly 32 bits target.

Found with:
$ ./build/qemu-x86_64 \
  -plugin ./build/contrib/plugins/libstoptrigger,icount=1000000 \
  -plugin ./build/tests/tcg/plugins/libinsn \
  -d plugin \
  ./build/qemu-system-x86_64 --version
ld-elf.so.1: /lib/libz.so.6: invalid file format
cpu 0 insns: 59746
total insns: 59746

Fixes: 369c1ba2b ("Fix __i386__ test for TARGET_HAS_STAT_TIME_T_EXT")
Signed-off-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Warner Losh <[email protected]>
Reviewed-by: Michael Tokarev <[email protected]>
Signed-off-by: Michael Tokarev <[email protected]>
2026-01-20 15:28:21 +03:00
Pierrick Bouvier 83017c4aaa linux-user/aarch64/target_fcntl.h: add missing TARGET_O_LARGEFILE definition
This caused a failure with program using openat2, where O_LARGEFILE was
replaced by O_NOFOLLOW.
This issue is only visible when QEMU is compiled with musl libc, where
O_LARGEFILE is different from 0 (vs glibc).

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3262
Cc: [email protected]
Signed-off-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Michael Tokarev <[email protected]>
Signed-off-by: Michael Tokarev <[email protected]>
2026-01-20 15:21:08 +03:00
Florian Hofhammer 0f825b502f configure: add ppc target back to container tests
Commit 2ff8c9a298 removed support for 32-bit PPC hosts from the build
system. Unfortunately, the patch also removed the 32-bit PPC target for
containerized tests, which leads to an error when trying to run tests,
e.g., with "make check-tcg":
"make[1]: *** No rule to make target 'docker-image-debian-ppc-cross',
needed by 'build-tcg-tests-ppc-linux-user'.  Stop."

This patch adds the PPC target back for containerized tests.

Fixes: 2ff8c9a298 ("buildsys: Remove support for 32-bit PPC hosts")
Signed-off-by: Florian Hofhammer <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Michael Tokarev <[email protected]>
[Mjt: specify commit subject in Fixes tag)
Signed-off-by: Michael Tokarev <[email protected]>
2026-01-20 14:26:33 +03:00
Thomas Huth 64dfb49535 MAINTAINERS: Add docs/system/i386/ to the general x86 architecture section
We've got a section for generic x86 architecture support in our
MAINTAINERS file - this should cover the docs/system/i386/ folder, too.

Signed-off-by: Thomas Huth <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Zhao Liu <[email protected]>
Reviewed-by: Michael Tokarev <[email protected]>
Signed-off-by: Michael Tokarev <[email protected]>
2026-01-20 14:25:17 +03:00
Thomas Huth 28e8b25f7d tests/qemu-iotests: Use "gsed" for expressions that require GNU sed
A bunch of tests are currently failing e.g. on FreeBSD like this:

 082   fail       [13:38:58] [13:38:59]   0.5s                 output
  mismatch (see .../build/tests/qemu-iotests/scratch/qcow2-file-082/082.out.bad)
 --- .../src/tests/qemu-iotests/082.out
 +++ .../build/tests/qemu-iotests/scratch/qcow2-file-082/082.out.bad
 @@ -17,7 +17,7 @@
  cluster_size: 4096
  Format specific information:
      compat: 1.1
 -    compression type: COMPRESSION_TYPE
 +    compression type: zlib
      lazy refcounts: true
      refcount bits: 16
      corrupt: false

This happens because the sed statements require GNU sed. Let's use
gsed in these spots to get it fixed.

Signed-off-by: Thomas Huth <[email protected]>
Reviewed-by: Daniel P. Berrangé <[email protected]>
Reviewed-by: Michael Tokarev <[email protected]>
Signed-off-by: Michael Tokarev <[email protected]>
2026-01-20 14:23:16 +03:00
Thomas Huth 47f43690fb configure: Set $PYTHON in the configuration of the optionroms
pc-bios/optionrom/Makefile uses $(PYTHON) for running a Python script,
but this variable is never initialized here. So the script gets run
via its shebang line - which fails if the "python3" binary is not
available on the system. To fix this, write the PYTHON configuration
to the config.mak file of the optionroms.

Signed-off-by: Thomas Huth <[email protected]>
Reviewed-by: Daniel P. Berrangé <[email protected]>
Reviewed-by: Michael Tokarev <[email protected]>
Signed-off-by: Michael Tokarev <[email protected]>
2026-01-20 14:21:42 +03:00
Julian Ganz f0cd0c7c7e tests: fix comment declaring runtime in rv64 interruptedmemory test
The test attempts to trigger a regression for arount 30s. However, a
comment just before the computation of the target wall clock time falsly
declares the run time to be around 60s.

This was the case already when we introduced the test in

    5241645c47
    (tests: add test with interrupted memory accesses on rv64)

Signed-off-by: Julian Ganz <[email protected]>
Reviewed-by: Daniel Henrique Barboza <[email protected]>
Signed-off-by: Michael Tokarev <[email protected]>
2026-01-20 14:21:07 +03:00
Michael Tokarev 9ae46975cf qemu-options.hx: use KiB, MiB, GiB for power-of-2 units
Use MiB &Co instead of MB &Co when the talk is about
power-of-two-based sizes, in qemu-options.hx.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3222
Signed-off-by: Michael Tokarev <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
2026-01-20 14:21:06 +03:00
Michael Tokarev e916f8b3b6 gdbstub: unlink the unix socket before bind()
This is another variant of doing what v9.2.0-1561-gfccb744f41c6
"gdbstub: Try unlinking the unix socket before binding" did, but
that commit introduced dependency on qemu-sockets.c which is
more problematic for statically-linked qemu-user binaries.

Reviewed-by: Ilya Leoshkevich <[email protected]>
Signed-off-by: Michael Tokarev <[email protected]>
2026-01-20 14:21:06 +03:00
Michael Tokarev a2b429b114 Revert "gdbstub: Try unlinking the unix socket before binding"
This reverts commit fccb744f41.

This commit introduced dependency of linux-user on qemu-sockets.c.
The latter includes handling of various socket types, while gdbstub
only needs unix sockets.  Including different kinds of sockets
makes it more problematic to build linux-user statically.

The original issue - the need to unlink unix socket before binding -
will be addressed in the next change.

Reviewed-by: Ilya Leoshkevich <[email protected]>
Signed-off-by: Michael Tokarev <[email protected]>
2026-01-20 14:21:06 +03:00
Richard Henderson 38879a667f Merge tag 'pull-tcg-20260119' of https://gitlab.com/rth7680/qemu into staging
Remove support for 32-bit hosts.

# -----BEGIN PGP SIGNATURE-----
#
# iQFRBAABCgA7FiEEekgeeIaLTbaoWgXAZN846K9+IV8FAmltWH8dHHJpY2hhcmQu
# aGVuZGVyc29uQGxpbmFyby5vcmcACgkQZN846K9+IV/ERwgAjYEp0OOEGoHQG0Tj
# MWymeQXRgtslspQtkhlIC5IiC8vWOeJVXVvb+sWV4fckkv/v4BK2R903IuHrRiYu
# MeJSDMI6tCWDRzP2U2jbeFlxQ0BGAQUjpi7oRkJEZv9qgWxodek6o+2HLM0iqcDM
# 7NciQwWwlMpkizx45qD+rpulvictLWjYczSpQPrkXEvqVT7dut20MKP/06FvqGsa
# E+1WoZAq0UfkT8xbqcLXgX5QyVPFpC0ZIcHBzXiUip6G4rY5rVnBeuiYCKojl2CI
# M0l9UEwG1KP9aaP6Lx2lg0qnXKT6ITukoPIzlEUDoNorGDwdXklYjd/ChmknQv3K
# fG0zWg==
# =LRWj
# -----END PGP SIGNATURE-----
# gpg: Signature made Mon 19 Jan 2026 09:02:39 AM AEDT
# gpg:                using RSA key 7A481E78868B4DB6A85A05C064DF38E8AF7E215F
# gpg:                issuer "[email protected]"
# gpg: Good signature from "Richard Henderson <[email protected]>" [ultimate]

* tag 'pull-tcg-20260119' of https://gitlab.com/rth7680/qemu: (54 commits)
  include/qemu/atomic: Drop aligned_{u}int64_t
  meson: Remove CONFIG_ATOMIC64
  include/qemu/atomic: Drop qatomic_{read,set}_[iu]64
  util: Remove stats64
  block: Drop use of Stat64
  migration: Drop use of Stat64
  target/s390x: Simplify atomicity check in do_csst
  target/s390x: Drop CONFIG_ATOMIC64 tests
  target/m68k: Drop CONFIG_ATOMIC64 tests
  target/hppa: Drop CONFIG_ATOMIC64 test
  target/arm: Drop CONFIG_ATOMIC64 tests
  linux-user/hppa: Drop CONFIG_ATOMIC64 test
  linux-user/arm: Drop CONFIG_ATOMIC64 test
  accel/tcg: Drop CONFIG_ATOMIC64 test from translator.c
  accel/tcg: Drop CONFIG_ATOMIC64 checks from ldst_atomicicy.c.inc
  tcg: Unconditionally define atomic64 helpers
  accel/tcg/runtime: Remove helper_nonatomic_cmpxchgo
  accel/tcg/runtime: Remove 64-bit shift helpers
  target/riscv: Drop TCG_TARGET_REG_BITS test
  target/i386/tcg: Drop TCG_TARGET_REG_BITS test
  ...

Signed-off-by: Richard Henderson <[email protected]>
2026-01-19 09:04:31 +11:00
Richard Henderson 239b9d0488 include/qemu/atomic: Drop aligned_{u}int64_t
As we no longer support i386 as a host architecture,
this abstraction is no longer required.

Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
2026-01-17 10:46:51 +11:00
Richard Henderson 997d86a9bb meson: Remove CONFIG_ATOMIC64
This config is no longer used.

Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
2026-01-17 10:46:51 +11:00
Richard Henderson 71adccb6f7 include/qemu/atomic: Drop qatomic_{read,set}_[iu]64
Replace all uses with the normal qatomic_{read,set}.

Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
2026-01-17 10:46:51 +11:00
Richard Henderson 90e2e8ada7 util: Remove stats64
This API is no longer used.

Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
2026-01-17 10:46:42 +11:00
Richard Henderson d9fe147955 block: Drop use of Stat64
The Stat64 structure is an aid for 32-bit hosts, and
is no longer required.  Use plain 64-bit types.

Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
2026-01-17 10:46:42 +11:00
Richard Henderson a2bd1e766c migration: Drop use of Stat64
The Stat64 structure is an aid for 32-bit hosts, and
is no longer required.  Use plain 64-bit types.

Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
2026-01-17 10:46:31 +11:00
Richard Henderson 56763352e7 target/s390x: Simplify atomicity check in do_csst
We should have used MO_{32,64} from the start, rather than
raw integer constants.  However, now that the CONFIG_ATOMIC64
test has been removed, we can remove the 'max' variable and
simplify the two blocks.

Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
2026-01-17 10:46:19 +11:00
Richard Henderson 51c5d7b63b target/s390x: Drop CONFIG_ATOMIC64 tests
Reviewed-by: Thomas Huth <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
2026-01-17 10:46:19 +11:00
Richard Henderson e415f147b3 target/m68k: Drop CONFIG_ATOMIC64 tests
Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
2026-01-17 10:46:19 +11:00
Richard Henderson a6de0794d1 target/hppa: Drop CONFIG_ATOMIC64 test
Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
2026-01-17 10:46:19 +11:00
Richard Henderson 3f2589c30a target/arm: Drop CONFIG_ATOMIC64 tests
Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
2026-01-17 10:46:19 +11:00
Richard Henderson a1de2343b2 linux-user/hppa: Drop CONFIG_ATOMIC64 test
Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
2026-01-17 10:46:19 +11:00
Richard Henderson 1e8b4763e0 linux-user/arm: Drop CONFIG_ATOMIC64 test
Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
2026-01-17 10:46:19 +11:00
Richard Henderson 5efc6083de accel/tcg: Drop CONFIG_ATOMIC64 test from translator.c
Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
2026-01-17 10:46:19 +11:00
Richard Henderson adcf06ec44 accel/tcg: Drop CONFIG_ATOMIC64 checks from ldst_atomicicy.c.inc
CONFIG_ATOMIC64 is a configuration knob for 32-bit hosts.

This allows removal of functions like load_atomic8_or_exit
and simplification of load_atom_extract_al8_or_exit to
load_atom_extract_al8.

Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
2026-01-17 10:46:18 +11:00
Richard Henderson c8d5ce7d5b tcg: Unconditionally define atomic64 helpers
CONFIG_ATOMIC64 is a configuration knob for 32-bit hosts.

Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
2026-01-17 10:46:18 +11:00
Richard Henderson 15d8cb32c5 accel/tcg/runtime: Remove helper_nonatomic_cmpxchgo
This were only required for some 32-bit hosts.

Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
2026-01-17 10:46:18 +11:00
Richard Henderson cf1bc1dead accel/tcg/runtime: Remove 64-bit shift helpers
These were only required for some 32-bit hosts.

Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
2026-01-17 10:46:18 +11:00
Richard Henderson 21f0c37ee0 target/riscv: Drop TCG_TARGET_REG_BITS test
Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
2026-01-17 10:46:18 +11:00
Richard Henderson fe15a2d5a6 target/i386/tcg: Drop TCG_TARGET_REG_BITS test
Reviewed-by: Thomas Huth <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
2026-01-17 10:46:18 +11:00
Richard Henderson 6af4efcdc3 include/tcg: Drop TCG_TARGET_REG_BITS tests
Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
2026-01-17 10:46:18 +11:00
Richard Henderson e77c07592c tcg: Drop TCG_TARGET_REG_BITS test in tcg-has.h
Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
2026-01-17 10:46:18 +11:00
Richard Henderson f2a618dff3 tcg: Drop TCG_TARGET_REG_BITS tests in tcg-internal.h
Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
2026-01-17 10:46:18 +11:00
Richard Henderson c39f15aeda tcg: Drop TCG_TARGET_REG_BITS tests in tcg.c
Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
2026-01-17 10:46:18 +11:00
Richard Henderson 1c9df1abbd tcg: Drop TCG_TARGET_REG_BITS tests in tcg-op-ldst.c
Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
2026-01-17 10:46:18 +11:00
Richard Henderson f8fb0bcd9a tcg: Drop TCG_TARGET_REG_BITS tests in tcg-op-gvec.c
Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
2026-01-17 10:46:18 +11:00
Richard Henderson 25b6f7ae53 tcg: Drop TCG_TARGET_REG_BITS tests in tcg-op.c
Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
2026-01-17 10:46:18 +11:00
Richard Henderson ffef4d5dd2 tcg: Drop TCG_TARGET_REG_BITS test in region.c
Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
2026-01-17 10:46:18 +11:00
Richard Henderson 220ef471a2 tcg/tci: Remove glue TCG_TARGET_REG_BITS renames
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
2026-01-17 10:46:18 +11:00
Richard Henderson 245223f64d tcg/tci: Drop TCG_TARGET_REG_BITS tests
Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
2026-01-17 10:46:18 +11:00
Richard Henderson 6e7b13936d tcg: Remove INDEX_op_dup2_vec
This opcode was exclusively for 32-bit hosts.

Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
2026-01-17 10:46:18 +11:00
Richard Henderson 2f4bf8148f tcg: Remove INDEX_op_setcond2_i32
This opcode was exclusively for 32-bit hosts.

Reviewed-by: Thomas Huth <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
2026-01-17 10:46:18 +11:00
Richard Henderson e3601d2cfc tcg: Remove INDEX_op_brcond2_i32
This opcode was exclusively for 32-bit hosts.

Reviewed-by: Thomas Huth <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
2026-01-17 10:46:18 +11:00
Richard Henderson 1c3e1b41ca *: Drop TCG_TARGET_REG_BITS test for prefer_i64
Mechanically via sed -i.

Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
2026-01-17 10:46:18 +11:00
Richard Henderson 186993f23d tcg: Replace TCG_TARGET_REG_BITS / 8
Use sizeof(tcg_target_long) instead of division.

Reviewed-by: Thomas Huth <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
2026-01-17 10:46:18 +11:00
Richard Henderson 9cc902d0bc tcg: Make TCG_TARGET_REG_BITS common
Since we only support 64-bit hosts, there's no real need
to parameterize TCG_TARGET_REG_BITS.  It seems worth holding
on to the identifier though, for documentation purposes.

Move one tcg/*/tcg-target-reg-bits.h to tcg/target-reg-bits.h
and remove the others.

Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
2026-01-17 10:46:18 +11:00
Richard Henderson 35caceb700 meson: Remove cpu == riscv32 tests
The 32-bit riscv host is no longer supported.

Reviewed-by: Thomas Huth <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
2026-01-17 10:46:07 +11:00
Richard Henderson 264ae24c36 meson: Drop host_arch rename for riscv64
This requires renaming several directories:
tcg/riscv, linux-user/include/host/riscv, and
common-user/host/riscv.

Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
2026-01-17 10:46:07 +11:00
Richard Henderson e06980adea meson: Drop host_arch rename for mips64
This requires renaming several directories:
tcg/mips, linux-user/include/host/mips, and
common-user/host/mips.

Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
2026-01-17 10:46:07 +11:00
Richard Henderson 904702f464 tcg/ppc64: Rename from ppc
Emphasize that we're generating 64-bit code.
Drop the explicit rename from meson's cpu.

Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
2026-01-17 10:46:07 +11:00
Richard Henderson 02a2449fbe tcg/x86_64: Rename from i386
Emphasize that we're generating 64-bit code.
Drop the explicit rename from meson's cpu.

Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
2026-01-17 10:46:07 +11:00
Richard Henderson 54a1ecd6d6 tcg/i386: Remove TCG_TARGET_REG_BITS tests
We now only support 64-bit code generation.

Reviewed-by: Thomas Huth <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
2026-01-17 10:45:40 +11:00
Richard Henderson e23d76d896 *: Remove ppc host support
Move the files from host/include/ppc to host/include/ppc64,
replacing the stub headers that redirected to ppc.

Remove linux-user/include/host/ppc.
Remove common-user/host/ppc.
Remove cpu == ppc tests from meson.

Reviewed-by: Thomas Huth <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
2026-01-17 10:45:40 +11:00
Richard Henderson c1997d85cb meson: Remove cpu == x86 tests
The 32-bit x86 host is no longer supported.

Reviewed-by: Thomas Huth <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
2026-01-17 10:45:39 +11:00
Richard Henderson b83f9f99aa host/include/x86_64/bufferiszero: Remove no SSE2 fallback
Since x86_64 always has SSE2, we can remove the fallback
that was present for i686.

Reviewed-by: Thomas Huth <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
2026-01-17 10:45:39 +11:00
Richard Henderson a2d76779d6 *: Remove i386 host support
Move the files from host/include/i386 to host/include/x86_64,
replacing the stub headers that redirected to i386.

Remove linux-user/include/host/i386.
Remove common-user/host/i386.

Reviewed-by: Thomas Huth <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
2026-01-17 10:45:39 +11:00
Richard Henderson 25512d6865 *: Remove __i386__ tests
Remove instances of __i386__, except from tests and imported headers.

Drop a block containing sanity check and fprintf error message for
i386-on-i386 or x86_64-on-x86_64 emulation.  If we really want
something like this, we would do it via some form of compile-time check.

Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
2026-01-17 10:45:39 +11:00
Richard Henderson 369c1ba2b7 bsd-user: Fix __i386__ test for TARGET_HAS_STAT_TIME_T_EXT
The target test is TARGET_I386, not __i386__.

Cc: Kyle Evans <[email protected]>
Reviewed-by: Warner Losh <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
2026-01-17 10:45:14 +11:00
Richard Henderson 581b722144 *: Remove arm host support
Remove tcg/arm.
Remove instances of __arm__, except from tests and imported headers.
Remove arm from supported_cpus.
Remove linux-user/include/host/arm.
Remove common-user/host/arm.

Reviewed-by: Thomas Huth <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
2026-01-17 10:44:40 +11:00
Richard Henderson 212d309af1 meson: Drop cpu == wasm32 tests
The 32-bit wasm32 host is no longer supported.

Reviewed-by: Kohei Tokunaga <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
2026-01-17 10:44:29 +11:00
Richard Henderson 372ec46b9f meson: Reject 32-bit hosts
32-bit hosts have been deprecated since 10.0.
As the first step, disable any such at configuration time.
Further patches will remove the dead code.

Reviewed-by: Thomas Huth <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
2026-01-17 10:44:20 +11:00
Richard Henderson 0d1137550b gitlab: Remove 32-bit host testing
These deprecated builds will be disabled.
Remove testing of armhf and i686.

Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
2026-01-17 10:44:09 +11:00
Richard Henderson f1f55e9886 tests/docker/dockerfiles: Drop wasm32 from emsdk-wasm-cross.docker
We will no longer build wasm32, so drop the docker config.
Streamline the dockerfile to hardcode TARGET_CPU as wasm64.

Reviewed-by: Kohei Tokunaga <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
2026-01-17 10:34:31 +11:00
Richard Henderson 5053e0a65d gitlab-ci: Drop build-wasm32-32bit
Drop the wasm32 build and container jobs.

Reviewed-by: Kohei Tokunaga <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
2026-01-17 10:34:03 +11:00
Richard Henderson 42a5675aa9 Merge tag 'accel-20260116' of https://github.com/philmd/qemu into staging
Accelerators patches queue

- Enable 64bit WebAssembly guests (TCI)
- Fix migration on HVF
- Remove a signal race with WFI on HVF (Aarch64)
- Correct HVF guest timer frequency (Aarch64)
- Fix NVMM build (x86)

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCAAdFiEE+qvnXhKRciHc/Wuy4+MsLN6twN4FAmlqHhcACgkQ4+MsLN6t
# wN7NEA//cZvw4AdTKgUxenEQL2r+Y8KVT+Wm+F7WqznTm9dqGgb+YHgmDoPA9b6y
# qxenzIwVA1R2ZkgAs7m99z9k9YcZLXHdoKelWYqxoWZd1DFVQJ7by5iRoQbvdtRJ
# LSxQXkdcXCGBIWQ080k0WJP5e7Sw/1+LdSm3jn2naRTD1JF3jn4LwUZMFQSwuhH0
# 0uXFrb207AlFz4itNnZXIjcvugMi6hIKNhHX8ol0JLSlfkS0lVR4y1X21J11ipg3
# VYucsUfA9fzfqcTDkPxGuEAV5mivaP1wy8kHRh5p8vgq7dbLivdIpjYIZynzb1LF
# 10WaeJaYHHYeWqLSKcZPUd66eKc2ZOeGn+zcE8oM8Zsm2NQUJ+rIkWw7/O978PfS
# RsXmIYTkM8gXfx7gUtW95/JmX5FH4xsvrwRjv1FdOPwYNe3kMtc1xslq9dkqsXMG
# P79n+NVXRr62ph93lSjLdLgqFW6eEXo0nVO4maD+9pBolK9S8TIrzLxRwXyHY/lx
# FD9nRHP/U1QjrrwpCcFT3PmTfJ/CsMlP0biUG9+uf6XKkxlOIyNoMSDdTC5xjUTx
# iCC71XluRIBKAIpwIN9QHtTTrKvm2wMFlTHpQxMD/kldc+0whHBtfU/24vemCCMQ
# dpnJxr0lVng942YHhT/n2Y6CZbzURF022I89p7EJ6d/1Els0j/c=
# =khzj
# -----END PGP SIGNATURE-----
# gpg: Signature made Fri 16 Jan 2026 10:16:39 PM AEDT
# gpg:                using RSA key FAABE75E12917221DCFD6BB2E3E32C2CDEADC0DE
# gpg: Good signature from "Philippe Mathieu-Daudé (F4BUG) <[email protected]>" [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: FAAB E75E 1291 7221 DCFD  6BB2 E3E3 2C2C DEAD C0DE

* tag 'accel-20260116' of https://github.com/philmd/qemu: (30 commits)
  tests/functional: Require TCG to run reverse debugging tests
  target/i386/nvmm: Include missing ramlist.h header
  accel/nvmm: Fix 'cpu' typo in nvmm_init_vcpu()
  hmp-commands-info.hx: Move definition of "info accel"
  target/arm: Only allow disabling NEON when using TCG
  target/arm/hvf: Really set Generic Timer counter frequency
  target/arm: Create GTimers *after* features finalized / accel realized
  accel/hvf: Add hvf_arch_cpu_realize() stubs
  accel: Introduce AccelOpsClass::cpu_target_realize() hook
  accel/hvf: Have PSCI CPU_SUSPEND halt the vCPU
  accel/hvf: Implement WFI without using pselect()
  accel/hvf: Skip WFI if CPU has work to do
  target/arm/hvf: Implement dirty page tracking
  accel/hvf: Remove mac_slots
  accel/hvf: Drop hvf_slot and hvf_find_overlap_slot
  accel/hvf: Simplify hvf_set_phys_mem
  accel/hvf: Move hvf_log_sync to hvf_log_clear
  accel/hvf: Simplify hvf_log_*
  target/i386/hvf: Use address_space_translate in ept_emulation_fault
  target/i386/hvf: Use hvf_unprotect_dirty_range
  ...

Signed-off-by: Richard Henderson <[email protected]>
2026-01-16 22:26:36 +11:00
Philippe Mathieu-Daudé 7b87e00c25 tests/functional: Require TCG to run reverse debugging tests
Record/replay is specific to TCG. Require it to avoid failure
when using a HVF-only build on Darwin:

  qemu-system-aarch64: -icount shift=7,rr=record,rrfile=/scratch/replay.bin,rrsnapshot=init: cannot configure icount, TCG support not available

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Daniel P. Berrangé <[email protected]>
Reviewed-by: Alex Bennée <[email protected]>
Message-ID: <[email protected]>
2026-01-16 11:17:28 +01:00
Thomas Huth 9535803a9e target/i386/nvmm: Include missing ramlist.h header
Compiling on NetBSD currently fails with:

 ../src/target/i386/nvmm/nvmm-all.c:1136:22: error: unknown type name 'RAMBlockNotifier'
  1136 | nvmm_ram_block_added(RAMBlockNotifier *n, void *host, size_t size,
       |                      ^~~~~~~~~~~~~~~~
 ../src/target/i386/nvmm/nvmm-all.c:1152:15: error: variable 'nvmm_ram_notifier' has initializer but incomplete type
  1152 | static struct RAMBlockNotifier nvmm_ram_notifier = {
       |               ^~~~~~~~~~~~~~~~
 ../src/target/i386/nvmm/nvmm-all.c:1153:6: error: 'struct RAMBlockNotifier' has no member named 'ram_block_added'
  1153 |     .ram_block_added = nvmm_ram_block_added
       |      ^~~~~~~~~~~~~~~
 ../src/target/i386/nvmm/nvmm-all.c:1153:24: error: 'nvmm_ram_block_added' undeclared here (not in a function)
  1153 |     .ram_block_added = nvmm_ram_block_added
       |                        ^~~~~~~~~~~~~~~~~~~~

Include the right header to get this fixed.

Signed-off-by: Thomas Huth <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Tested-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Acked-by: Paolo Bonzini <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-01-16 11:17:28 +01:00
Philippe Mathieu-Daudé 7be4256281 accel/nvmm: Fix 'cpu' typo in nvmm_init_vcpu()
Fix typo to avoid the following build failure:

  target/i386/nvmm/nvmm-all.c: In function 'nvmm_init_vcpu':
  target/i386/nvmm/nvmm-all.c:988:9: error: 'AccelCPUState' has no member named 'vcpu_dirty'
    988 |     qcpu->vcpu_dirty = true;
        |         ^~

Cc: [email protected]
Reported-by: Thomas Huth <[email protected]>
Fixes: 2098164a6b ("accel/nvmm: Replace @dirty field by generic CPUState::vcpu_dirty field")
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Tested-by: Thomas Huth <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Tested-by: Pierrick Bouvier <[email protected]>
Message-ID: <[email protected]>
2026-01-16 11:17:28 +01:00
Markus Armbruster 688f20dbde hmp-commands-info.hx: Move definition of "info accel"
Commit c10eb74010 (accel/system: Add 'info accel' on human monitor)
inserted "info accel" in the middle of "info sync-profile".  Move it
behind "info sync-profile".

Signed-off-by: Markus Armbruster <[email protected]>
Reviewed-by: Daniel P. Berrangé <[email protected]>
Reviewed-by: Dr. David Alan Gilbert <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-01-16 11:17:28 +01:00
Philippe Mathieu-Daudé f46f05b6d8 target/arm: Only allow disabling NEON when using TCG
Only allow disabling NEON when using TCG.

This avoids confusing user experience:

  $ qemu-system-aarch64 -M virt -accel hvf \
                        -cpu host,neon=off,vfp=off,vfp-d32=off
  qemu-system-aarch64: AArch64 CPUs must have both VFP and Neon or neither

  $ qemu-system-aarch64 -M virt -accel hvf \
                        -cpu host,neon=off,vfp=off,vfp-d32=off
  qemu-system-aarch64: ARM CPUs must have both VFP-D32 and Neon or neither

  $ qemu-system-aarch64 -M virt -accel hvf \
                        -cpu host,neon=off,vfp=off,vfp-d32=off
  qemu-system-aarch64: can't apply global host-arm-cpu.vfp-d32=off: Property 'host-arm-cpu.vfp-d32' not found

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Message-ID: <[email protected]>
2026-01-16 11:17:28 +01:00
Philippe Mathieu-Daudé 7f359375fc target/arm/hvf: Really set Generic Timer counter frequency
Setting ARMCPU::gt_cntfrq_hz in hvf_arch_init_vcpu() is
not correct because the timers have already be initialized
with the default frequency.

Set it earlier in the AccelOpsClass::cpu_target_realize()
handler instead, and assert the value is correct when
reaching hvf_arch_init_vcpu().

Fixes: a1477da3dd ("hvf: Add Apple Silicon support")
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Message-ID: <[email protected]>
2026-01-16 11:17:28 +01:00
Philippe Mathieu-Daudé 6e18afcd31 target/arm: Create GTimers *after* features finalized / accel realized
Call generic (including accelerator) cpu_realize() handlers
*before* setting @gt_cntfrq_hz default

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Message-ID: <[email protected]>
2026-01-16 11:17:28 +01:00
Philippe Mathieu-Daudé b2d57718a9 accel/hvf: Add hvf_arch_cpu_realize() stubs
Implement HVF AccelOpsClass::cpu_target_realize() hook as
empty stubs. Target implementations will come separately.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Message-ID: <[email protected]>
2026-01-16 11:17:28 +01:00
Philippe Mathieu-Daudé e4f6a02d86 accel: Introduce AccelOpsClass::cpu_target_realize() hook
Allow accelerators to set vCPU properties before its realization.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Message-ID: <[email protected]>
2026-01-16 11:17:28 +01:00
Philippe Mathieu-Daudé 6ca499b791 accel/hvf: Have PSCI CPU_SUSPEND halt the vCPU
Return EXCP_HLT to the main loop.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Message-ID: <[email protected]>
2026-01-16 11:17:28 +01:00
Philippe Mathieu-Daudé b5f8f77271 accel/hvf: Implement WFI without using pselect()
Return to the main loop where we'll be waken again.
This avoid a tricky race with signals introduced in
commit 219c101fa7 ("Add HVF WFI handler").

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Message-ID: <[email protected]>
2026-01-16 11:17:28 +01:00
Philippe Mathieu-Daudé a14afa985e accel/hvf: Skip WFI if CPU has work to do
Avoid sleeping vCPU thread for any pending work, not just IRQs.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Alex Bennée <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Message-ID: <[email protected]>
2026-01-16 11:17:28 +01:00
Richard Henderson 58bc47fd1c target/arm/hvf: Implement dirty page tracking
Notice writes to pages which are being monitored.  Mark the page dirty,
re-enable writes, and retry the instruction without emulation.

Assert the fault is not from a stage1 page table walk.

Signed-off-by: Richard Henderson <[email protected]>
Tested-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Message-ID: <[email protected]>
2026-01-16 11:17:28 +01:00
Richard Henderson 7d7654a643 accel/hvf: Remove mac_slots
This data structure is no longer used.

Signed-off-by: Richard Henderson <[email protected]>
Tested-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Message-ID: <[email protected]>
2026-01-16 11:17:28 +01:00
Richard Henderson 6bf331164c accel/hvf: Drop hvf_slot and hvf_find_overlap_slot
These are now unused.

Signed-off-by: Richard Henderson <[email protected]>
Tested-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Message-ID: <[email protected]>
2026-01-16 11:17:28 +01:00
Richard Henderson d1f4ba9d94 accel/hvf: Simplify hvf_set_phys_mem
All of the complicated parts of updating the address space
are handled by address_space_update_topology_pass.
Do not create or use hvf_slot structures.

Signed-off-by: Richard Henderson <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Message-ID: <[email protected]>
2026-01-16 11:17:28 +01:00
Richard Henderson 1b6261bfc0 accel/hvf: Move hvf_log_sync to hvf_log_clear
Right idea, wrong hook.  log_sync is called before using
dirty bit data (which for hvf is already up-to-date),
whereas log_clear is called before cleaning the range.

Signed-off-by: Richard Henderson <[email protected]>
Tested-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Message-ID: <[email protected]>
2026-01-16 11:17:28 +01:00
Richard Henderson 6d0a5a4456 accel/hvf: Simplify hvf_log_*
Rely on the AddressSpace and MemoryRegion structures
rather than hvf_slot.

Signed-off-by: Richard Henderson <[email protected]>
Tested-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Message-ID: <[email protected]>
2026-01-16 11:17:28 +01:00
Richard Henderson ef878343e8 target/i386/hvf: Use address_space_translate in ept_emulation_fault
The hvf_slot structure is a poor replacement for properly
looking up a memory region in the address space.
Use memory_region_get_dirty_log_mask instead of HVF_SLOT_LOG.

Signed-off-by: Richard Henderson <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Message-ID: <[email protected]>
2026-01-16 11:17:28 +01:00
Jamin Lin b1a40e6063 pc-bios: Update vbootrom image to commit 1c8e9510b22c
Full changelog since last update (183c9ff8056b) :

Joe Komlodi (1):
    npcm8xx: Fix u-boot copy size

Jamin Lin (3):
    ast27x0: refactor FIT boot loader into fmc_image.c for future Caliptra Manifest support
    ast27x0: Add Caliptra Manifest boot support and MCU runtime loader framework
    ast27x0: Fix compilation issues on Ubuntu 22.04

Compiled with gcc version 13.3.0

Signed-off-by: Jamin Lin <[email protected]>
Reviewed-by: Nabih Estefan <[email protected]>
2026-01-16 17:21:27 +08:00
Richard Henderson 36d5b5caaa target/i386/hvf: Use hvf_unprotect_dirty_range
Signed-off-by: Richard Henderson <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Message-ID: <[email protected]>
2026-01-16 09:22:16 +01:00
Philippe Mathieu-Daudé 0b36673c27 accel/hvf: Enforce host alignment in hv_vm_protect()
hv_vm_protect() arguments must be aligned to host page.

Suggested-by: Richard Henderson <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Message-ID: <[email protected]>
2026-01-16 09:22:16 +01:00
Philippe Mathieu-Daudé f1c59f59bd target/i386/hvf: Use host page alignment in ept_emulation_fault()
While on x86 the host page size is fixed to 4KB, it is
better to call qemu_real_host_page_size() for consistency.

Reviewed-by: Peter Maydell <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Message-ID: <[email protected]>
2026-01-16 09:22:16 +01:00
Richard Henderson 43e97e2c1a accel/hvf: Create hvf_protect_clean_range, hvf_unprotect_dirty_range
Signed-off-by: Richard Henderson <[email protected]>
Tested-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Message-ID: <[email protected]>
2026-01-16 09:22:16 +01:00
Kohei Tokunaga 4203ea0247 gitlab-ci: Add build tests for wasm64
The wasm builds are tested for 3 targets: wasm32, wasm64(-sMEMORY64=1) and
wasm64(-sMEMORY64=2). The CI builds the containers using the same Dockerfile
(emsdk-wasm-cross.docker) with different build args.

Signed-off-by: Kohei Tokunaga <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
Message-ID: <ee30d4956a485fd46b4735028486d3fb7b22fe60.1768308374.git.ktokunaga.mail@gmail.com>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-01-16 09:22:16 +01:00
Kohei Tokunaga 3ef255fbd6 dockerfiles: Add support for wasm64 to the wasm Dockerfile
This commit fixes Dockerfile of the wasm build to support both of wasm32 and
wasm64 build. Dockerfile takes the following build argument and use it for
building dependencies.

- TARGET_CPU: target wasm arch (wasm32 or wasm64)

Signed-off-by: Kohei Tokunaga <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
Message-ID: <3f21342f50e0412a32143fe21ecc0d8db95b3f37.1768308374.git.ktokunaga.mail@gmail.com>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-01-16 09:22:16 +01:00
Kohei Tokunaga c6f975df5b configure: Enable to propagate -sMEMORY64 flag to Emscripten
Currently there are some engines that don't support wasm64 (e.g. unsupported
on Safari[1]). To mitigate this issue, the configure script allows the user
to use Emscripten's compatibility feature, "-sMEMORY64=2" flag[2].

Emscripten's "-sMEMORY64=2" flag still enables 64bit pointers in C code. But
this flag lowers the output binary into wasm32, with limiting the maximum
memory size to 4GB. So QEMU can run on wasm32 engines.

[1] https://webassembly.org/features/
[2] https://emscripten.org/docs/tools_reference/settings_reference.html#memory64

Signed-off-by: Kohei Tokunaga <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
Message-ID: <a2f068c7884a629fe3e4b297368d70b0956ab048.1768308374.git.ktokunaga.mail@gmail.com>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-01-16 09:22:16 +01:00
Kohei Tokunaga 5aefc06403 meson: Add wasm64 support to the --cpu flag
wasm64 target enables 64bit pointers using Emscripten's -sMEMORY64=1
flag[1]. This enables QEMU to run 64bit guests.

Although the configure script uses "uname -m" as the fallback value when
"cpu" is empty, this can't be used for Emscripten which targets to Wasm.
So, in wasm build, this commit fixes configure to require --cpu flag to be
explicitly specified by the user.

[1] https://emscripten.org/docs/tools_reference/settings_reference.html#memory64

Signed-off-by: Kohei Tokunaga <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
Message-ID: <91f16f0e9ae6b36fbf0c2caac510dcf855120400.1768308374.git.ktokunaga.mail@gmail.com>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-01-16 09:22:16 +01:00
Philippe Mathieu-Daudé a49cb762eb tests/qtest/migration: Add MigrationTestEnv::has_hvf field
Allow tests to tune their parameters when running on HVF.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Fabiano Rosas <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-01-16 07:05:09 +01:00
Philippe Mathieu-Daudé 851fc792d5 tests/qtest/migration: Make 'has_dirty_ring' generic
Keep accelerator knowledge limited within MigrationTestEnv,
expose a generic %has_dirty_ring value, only checking for
KVM when initializing it in migration_get_env().

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Fabiano Rosas <[email protected]>
Message-ID: <[email protected]>
2026-01-16 07:05:09 +01:00
Philippe Mathieu-Daudé c60c1077a7 migration/dirtyrate: Do not unlock cpu_list lock twice
&qemu_cpu_list_lock is locked within the WITH_QEMU_LOCK_GUARD()
context, then unlocked. No need to manually unlock it.

Fixes: 370ed60029 ("cpu: expose qemu_cpu_list_lock for lock-guard use")
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Fabiano Rosas <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-01-16 07:05:09 +01:00
Richard Henderson c1c58cee16 Merge tag 'pull-target-arm-20260115' of https://gitlab.com/pm215/qemu into staging
target-arm queue:
 * hw/arm/raspi: remove duplicate include
 * target/arm: Enable FEAT_ASID2 emulation
 * hw/char/cmsdk-apb-uart.c: log guest_errors for r/w to disabled uart
 * hw/arm: Re-enable the MAX78000FTHR machine in qemu-system-arm/aarch64
 * target/arm/ptw: make granule_protection_check usable without a cpu
 * hw/arm/omap: Remove omap_badwidth_* functions
 * hw/arm/smmu: add memory regions as property for an SMMU instance
 * docs/system/generic-loader: clarify
 * tests/functional: migrate aspeed_rainier image
 * target/arm: Correctly handle HCR.TID1 and TID3 traps on v7A CPUs

# -----BEGIN PGP SIGNATURE-----
#
# iQJNBAABCAA3FiEE4aXFk81BneKOgxXPPCUl7RQ2DN4FAmlpN5EZHHBldGVyLm1h
# eWRlbGxAbGluYXJvLm9yZwAKCRA8JSXtFDYM3j/QD/9G1AV5Sd59zoO//cS6m7OO
# dB0/1MaX7ChTK4zHaQwA2TammwKTxUDV1nj8LJBd4/d1SV1SC3OrYl88bQdjKhLD
# +o4z9snfV+TmVm6WlmKvDkOhV0UdhrA31exvXFOXytmVSq6BxvHv/yy2j4eo8KVu
# UtWf8A2RHnfR1QNIvBGtDQ7NWhd9XHV8mKtGMIiTTQtQ72/9MLig9Kbv97yavbRT
# ZY8AdvDZJrR8P7euRc//qmGuWb6ix2GiFRWQ0FXQu/qU63MR+Css12nzkXFFGeU2
# KEtZ2PTwd8i/NRYtJmqVw3ZsQHAqXplGle/VzK7orTLWKHbjiLOc9FdnSVplkBNM
# AWhQGVqrwXYHnEI34RiTQuxzhNepPwOgS6/0gXw2mHzHQ5g6ndZnfJuPTw/70ZNY
# Yd0nAU1ajvgW/1/i9zVs4aQ5wy/SFRd+OoHqujVIcKWB9iPWvNZUGgrnySQO8lq+
# 6GOMZauK+8kU4WJO/wHCW9ktIUPWjwYmmTLwElTj/VUEjShy2t8mETZEvzJl+eVl
# WZpzfJEvbraJiCe+e2QRcRA0goTlBdNneUQ31ePoVOpXS6UXIXuqd3Qisli9y4sB
# 9NrJseIQ7RclIYfpHxkrlejXGOFlwtxaDoxSupn7IblKCCFFf6TS3LwiJRXpcf2k
# kpMq6Mcnt/HCrpvmN5gNUA==
# =yMo2
# -----END PGP SIGNATURE-----
# gpg: Signature made Fri 16 Jan 2026 05:53:05 AM AEDT
# gpg:                using RSA key E1A5C593CD419DE28E8315CF3C2525ED14360CDE
# gpg:                issuer "[email protected]"
# gpg: Good signature from "Peter Maydell <[email protected]>" [unknown]
# gpg:                 aka "Peter Maydell <[email protected]>" [unknown]
# gpg:                 aka "Peter Maydell <[email protected]>" [unknown]
# gpg:                 aka "Peter Maydell <[email protected]>" [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: E1A5 C593 CD41 9DE2 8E83  15CF 3C25 25ED 1436 0CDE

* tag 'pull-target-arm-20260115' of https://gitlab.com/pm215/qemu: (25 commits)
  target/arm: Rename access_aa64_tid5() to access_tid5()
  target/arm: Correctly trap HCR.TID1 registers in v7A
  target/arm: Correctly honour HCR.TID3 for v7A cores
  target/arm: Don't specify ID_PFR1 accessfn twice
  tests/functional: migrate aspeed_rainier image
  docs/system/generic-loader: move TODO to source code
  docs/system/generic-loader: Don't mention QemuOpts implementation detail
  docs/system/generic-loader: Clarify behaviour of cpu-num
  hw/arm/smmu: add memory regions as property for an SMMU instance
  hw/arm/omap1: Remove omap_badwidth_* implementations
  hw/arm/omap1: Remove omap_badwidth_write* calls
  hw/arm/omap1: Remove omap_badwidth_read* calls
  hw/dma/omap_dma: Remove omap_badwidth_* calls
  hw/gpio/omap_gpio: Remove omap_badwidth_* calls
  hw/i2c/omap_i2c: Remove omap_badwidth_* calls
  hw/sd/omap_mmc: Remove omap_badwidth_* calls
  target/arm/ptw: make granule_protection_check usable without a cpu
  target/arm: Move ARMSecuritySpace to a common header
  hw/arm: Re-enable the MAX78000FTHR machine in qemu-system-arm/aarch64
  hw/char/cmsdk-apb-uart.c: log guest_errors for r/w to disabled uart
  ...

Signed-off-by: Richard Henderson <[email protected]>
2026-01-16 09:33:20 +11:00
Richard Henderson beaeffb57c Merge tag 'pull-loongarch-20260115' of https://github.com/bibo-mao/qemu into staging
loongarch queue

# -----BEGIN PGP SIGNATURE-----
#
# iHUEABYKAB0WIQQNhkKjomWfgLCz0aQfewwSUazn0QUCaWiLIAAKCRAfewwSUazn
# 0cGHAQCVjRn2wPtniAIS6HQ/edTPXQt8Nr83Bv6SHkcOskbexwEA/OmUd4MiftSV
# GJFfJ66Z3i9TCRZJdLqsUZBk9p9W9AQ=
# =Aiem
# -----END PGP SIGNATURE-----
# gpg: Signature made Thu 15 Jan 2026 05:37:20 PM AEDT
# gpg:                using EDDSA key 0D8642A3A2659F80B0B3D1A41F7B0C1251ACE7D1
# gpg: Good signature from "bibo mao <[email protected]>" [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: 7044 3A00 19C0 E97A 31C7  13C4 8E86 8FB7 A176 9D4C
#      Subkey fingerprint: 0D86 42A3 A265 9F80 B0B3  D1A4 1F7B 0C12 51AC E7D1

* tag 'pull-loongarch-20260115' of https://github.com/bibo-mao/qemu:
  hw/loongarch/virt: Don't abort on access to unimplemented IOCSR
  target/loongarch: Fix exception ADEF/ADEM missing to update CSR_BADV
  target/loongarch: Fix exception BCE missing to update CSR_BADV
  target/loongach: Fix some exceptions failure in updating CSR_BADV
  hw/loongarch/virt: Fix irq allocation failure with pci device from fdt
  hw/loongarch/virt: Modify the interrupt trigger type in fdt table

Signed-off-by: Richard Henderson <[email protected]>
2026-01-16 09:32:38 +11:00
Peter Maydell 4efed64ffc target/arm: Rename access_aa64_tid5() to access_tid5()
There is no equivalent access_aa32_tid5() (HCR_EL2.TID5 only exists
starting from v8); rename access_aa64_tid5() to access_tid5() to line
up with the naming we now have for the TID1 and TID3 check functions.

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Alex Bennée <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-id: [email protected]
2026-01-15 15:30:16 +00:00
Peter Maydell b67a35622f target/arm: Correctly trap HCR.TID1 registers in v7A
In v7A HCR.TID1 is defined to trap for TCMTR, TLBTR, REVIDR and AIDR.
We incorrectly use an accessfn for REVIDR and AIDR that only traps on
v8A cores.  Fix this by collapsing access_aa64_tid1() and
access_aa32_tid1() together and never doing a check for v8 vs v7.

The accessfn is also used for SMIDR_EL1, which is fine as this
register is AArch64 only.

Cc: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Alex Bennée <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-id: [email protected]
2026-01-15 15:30:16 +00:00
Peter Maydell 205ca535ab target/arm: Correctly honour HCR.TID3 for v7A cores
The HCR.TID3 bit defines that we should trap to the hypervisor for
reads to a collection of ID registers. Different architecture versions
have defined this differently:

 * v7A has a set of ID regs that definitely must trap:
    - ID_PFR{0,1}, ID_DFR0, ID_AFR0, ID_MMFR{0,1,2,3},
      ID_ISAR{0,1,2,3,4,5}, MVFR{0,1}
   and somewhat vaguely says that "there is no requirement"
   to trap for registers that are reserved in the ID reg space
   (i.e. which RAZ and might be used for new ID regs in future)
 * v8A adds to this list:
    - ID_PFR2 and MVFR2 must trap
    - ID_MMFR4, ID_MMFR5, ID_ISAR6, ID_DFR1 and reserved registers
      in the ID reg space must trap if FEAT_FGT is implemented,
      and it is IMPDEF if they trap if FEAT_FGT is not implemented

In QEMU we seem to have attempted to implement this distinction
(taking the "we do trap" IMPDEF choice if no FEAT_FGT), with
access_aa64_tid3() always trapping on TID3 and access_aa32_tid3()
trapping only if ARM_FEATURE_V8 is set.  However, we didn't apply
these to the right set of registers: we use access_aa32_tid3() on all
the 32-bit ID registers *except* ID_PFR2, ID_DFR1, ID_MMFR5 and the
RES0 space, which means that for a v7 CPU we don't trap on a lot of
registers that we should trap on, and we do trap on various things
that the v7A Arm ARM says there is "no requirement" to trap on.

Straighten this out by naming the access functions more clearly for
their purpose, and documenting this: access_v7_tid3() is only for the
fixed set of ID registers that v7A traps on HCR.TID3, and
access_tid3() is for any others, including the reserved encoding
spaces and any new registers we add in future.

AArch32 MVFR2 access is handled differently, in check_hcr_el2_trap;
there we already do not trap on TID3 on v7A cores (where MVFR2
doesn't exist), because we in the code-generation function we UNDEF
if ARM_FEATURE_V8 is not set, without generating code to call
check_hcr_el2_trap.

This bug was causing a problem for Xen which (after a recent change
to Xen) expects to be able to trap ID_PFR0 on a Cortex-A15.

The result of these changes is that our v8A behaviour remains
the same, and on v7A we now trap the registers the Arm ARM definitely
requires us to trap, and don't trap the reserved space that "there is
no requirement" to trap.

Cc: [email protected]
Fixes: 6a4ef4e5d1 ("target/arm: Honor HCR_EL2.TID3 trapping requirements")
Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Alex Bennée <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-id: [email protected]
2026-01-15 15:28:35 +00:00
Peter Maydell 8da52b8401 target/arm: Don't specify ID_PFR1 accessfn twice
In the definition of ID_PFR1 we have an ifdef block; we specify the
accessfn once in the common part of the ifdef and once in the
not-user-only part, which is redundant but harmless.

The accessfn will always return success in user-only mode (because
we won't trap to EL2), so specify it only in the not-user-only
half of the ifdef, as was probably the intention.

This is only cc'd to stable to avoid a textual conflict with
the following patch, which is a bug fix.

Cc: [email protected]
Fixes: 0f150c8499 ("target/arm: Constify ID_PFR1 on user emulation")
Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Alex Bennée <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-id: [email protected]
2026-01-15 15:27:34 +00:00
Alex Bennée 7cf096d609 tests/functional: migrate aspeed_rainier image
Cedric has a host for the file which allows us to keep the name.

Cc: [email protected]
Signed-off-by: Alex Bennée <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Message-id: [email protected]
Cc: Cédric Le Goater <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
2026-01-15 15:26:31 +00:00
Peter Maydell 6b65590f4a docs/system/generic-loader: move TODO to source code
Currently we have a "Restrictions and ToDos" section at the bottom of
the document which notes that there's no way to specify a CPU to load
a file through that doesn't also set that CPU's PC.  This is written
as a developer-facing note.  Move this to a TODO comment in the
source code, and provide a shorter user-facing statement of the
current restriction under the specific sub-option that it applies to.

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Alex Bennée <[email protected]>
2026-01-15 15:26:30 +00:00
Peter Maydell 5f8d933407 docs/system/generic-loader: Don't mention QemuOpts implementation detail
We currently say "All values are parsed using the standard QemuOpts
parsing".  This doesn't tell the user anything useful because we
don't mention QemuOpts anywhere else in the docs.  What we're really
trying to tell the user is what we mention afterwards: that the
values are decimal, and you need an 0x prefix for hex.  How we
achieve it is an implementation detail the user doesn't need to know.

Drop the explicit mention of QemuOpts; this in passing removes a typo
"QemuOps" that we made in one place. Put the informative note
more closely associated with the <addr> suboption which is the
one that users might most reasonably assume to default to hex.

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Alex Bennée <[email protected]>
2026-01-15 15:26:30 +00:00
Peter Maydell 1e812f8eb1 docs/system/generic-loader: Clarify behaviour of cpu-num
The cpu-num suboption to the generic loader has two effects when
it is used with -device loader,file=<file>:
 * it specifies which CPU to load the data through
 * it specifies which CPU gets its PC set to the file's entry point

Our documentation is not very clear about what happens if you don't
pass this suboption.  The default is that we pick the first CPU to
load the data, but we don't set the PC for any CPU, so the "If not
specified, the default is CPU 0" is confusing: it applies for loading
but not for the PC setting.

Clarify the text to make it clearer that the option has two effects
and the default behaviour is different for the two effects.

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Alex Bennée <[email protected]>
2026-01-15 15:26:30 +00:00
Pierrick Bouvier 53b54a8252 hw/arm/smmu: add memory regions as property for an SMMU instance
This will be used to access non-secure and secure memory. Secure support
and Granule Protection Check (for RME) for SMMU need to access secure
memory.

As well, it allows to remove usage of global address_space_memory,
allowing different SMMU instances to have a specific view of memory.

User creatable SMMU are handled as well for virt machine,
by setting the memory properties when device is plugged in.

Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Eric Auger <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
2026-01-15 15:26:30 +00:00
Peter Maydell d751921cff hw/arm/omap1: Remove omap_badwidth_* implementations
Now there are no callsites for the omap_badwidth_* family
of functions we can remove their implementations.

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
2026-01-15 15:26:30 +00:00
Peter Maydell 7c1a339bbf hw/arm/omap1: Remove omap_badwidth_write* calls
Complete the conversion started in the previous commit by
changing all the omap_badwidth_write* calls to open-coded
log-and-ignore behaviour.

We can delete a FIXME comment about an infinite loop, because that
only looped infinitely back before 2011 when the device was still
using absolute physical addresses.  Now that we are simply logging
the error we can clearly see that there's no loop.

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
2026-01-15 15:26:30 +00:00
Peter Maydell 21d3cac1ab hw/arm/omap1: Remove omap_badwidth_read* calls
The omap_badwidth_read* and omap_badwidth_write* functions are
used by various OMAP devices when the guest makes an access
to registers with an invalid width; they do two things:
 - log a GUEST_ERROR for the access
 - call cpu_physical_memory_read() or cpu_physical_memory_write()
   with the offset they are passed in

The first of these produces an unhelpful log message because the
function name that is printed is that of the omap-badwidth_*
function, not that of the read or write function of the device that
called it; this means you can't tell what device is involved.

The second is wrong because the offset is an offset into the device
but we use it as an absolute physical address, so we will access
whatever is at low memory.  That happens to be the boot ROM, so we
will ignore a write and return random garbage on a read.  This bug
has been present since 2011, when we did the conversions to the
MemoryRegion APIs, which involved changing all devices from working
with absolute physical addresses to working with offsets within their
MemoryRegions.  We must have missed updating these functions.

Replace the uses of the omap_badwidth_read* functions in omap1.c with
an open-coded call to qemu_log_mask() and RAZ/WI behaviour.
We do just the reads here because there are a lot of callsites in
omap1.c; the writes will be done in the next commit.

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
2026-01-15 15:26:30 +00:00
Peter Maydell 0dbc2392d8 hw/dma/omap_dma: Remove omap_badwidth_* calls
The omap_badwidth_read* and omap_badwidth_write* functions are
used by various OMAP devices when the guest makes an access
to registers with an invalid width; they do two things:
 - log a GUEST_ERROR for the access
 - call cpu_physical_memory_read() or cpu_physical_memory_write()
   with the offset they are passed in

The first of these produces an unhelpful log message because the
function name that is printed is that of the omap-badwidth_*
function, not that of the read or write function of the device that
called it; this means you can't tell what device is involved.

The second is wrong because the offset is an offset into the device
but we use it as an absolute physical address, so we will access
whatever is at low memory.  That happens to be the boot ROM, so we
will ignore a write and return random garbage on a read.  This bug
has been present since 2011, when we did the conversions to the
MemoryRegion APIs, which involved changing all devices from working
with absolute physical addresses to working with offsets within their
MemoryRegions.  We must have missed updating these functions.

Replace the uses of these functions in omap_dma.c with an
open-coded call to qemu_log_mask() and RAZ/WI behaviour.

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
2026-01-15 15:26:30 +00:00
Peter Maydell cf8552eb4c hw/gpio/omap_gpio: Remove omap_badwidth_* calls
The omap_badwidth_read* and omap_badwidth_write* functions are
used by various OMAP devices when the guest makes an access
to registers with an invalid width; they do two things:
 - log a GUEST_ERROR for the access
 - call cpu_physical_memory_read() or cpu_physical_memory_write()
   with the offset they are passed in

The first of these produces an unhelpful log message because the
function name that is printed is that of the omap-badwidth_*
function, not that of the read or write function of the device that
called it; this means you can't tell what device is involved.

The second is wrong because the offset is an offset into the device
but we use it as an absolute physical address, so we will access
whatever is at low memory.  That happens to be the boot ROM, so we
will ignore a write and return random garbage on a read.  This bug
has been present since 2011, when we did the conversions to the
MemoryRegion APIs, which involved changing all devices from working
with absolute physical addresses to working with offsets within their
MemoryRegions.  We must have missed updating these functions.

Replace the uses of these functions in omap_gpio.c with an
open-coded call to qemu_log_mask() and RAZ/WI behaviour.

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
2026-01-15 15:26:30 +00:00
Peter Maydell f2368e9d67 hw/i2c/omap_i2c: Remove omap_badwidth_* calls
The omap_badwidth_read* and omap_badwidth_write* functions are
used by various OMAP devices when the guest makes an access
to registers with an invalid width; they do two things:
 - log a GUEST_ERROR for the access
 - call cpu_physical_memory_read() or cpu_physical_memory_write()
   with the offset they are passed in

The first of these produces an unhelpful log message because the
function name that is printed is that of the omap-badwidth_*
function, not that of the read or write function of the device that
called it; this means you can't tell what device is involved.

The second is wrong because the offset is an offset into the device
but we use it as an absolute physical address, so we will access
whatever is at low memory.  That happens to be the boot ROM, so we
will ignore a write and return random garbage on a read.  This bug
has been present since 2011, when we did the conversions to the
MemoryRegion APIs, which involved changing all devices from working
with absolute physical addresses to working with offsets within their
MemoryRegions.  We must have missed updating these functions.

Replace the uses of these functions in omap_i2c.c with an
open-coded call to qemu_log_mask() and RAZ/WI behaviour.

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
2026-01-15 15:26:30 +00:00
Peter Maydell 4d353e1228 hw/sd/omap_mmc: Remove omap_badwidth_* calls
The omap_badwidth_read* and omap_badwidth_write* functions are
used by various OMAP devices when the guest makes an access
to registers with an invalid width; they do two things:
 - log a GUEST_ERROR for the access
 - call cpu_physical_memory_read() or cpu_physical_memory_write()
   with the offset they are passed in

The first of these produces an unhelpful log message because the
function name that is printed is that of the omap-badwidth_*
function, not that of the read or write function of the device that
called it; this means you can't tell what device is involved.

The second is wrong because the offset is an offset into the device
but we use it as an absolute physical address, so we will access
whatever is at low memory.  That happens to be the boot ROM, so we
will ignore a write and return random garbage on a read.  This bug
has been present since 2011, when we did the conversions to the
MemoryRegion APIs, which involved changing all devices from working
with absolute physical addresses to working with offsets within their
MemoryRegions.  We must have missed updating these functions.

Replace the uses of these functions in omap_mmc.c with an
open-coded call to qemu_log_mask() and RAZ/WI behaviour.

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
2026-01-15 15:26:30 +00:00
Pierrick Bouvier df2f43555c target/arm/ptw: make granule_protection_check usable without a cpu
By removing cpu details and use a config struct, we can use the
same granule_protection_check with other devices, like SMMU.

Signed-off-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-id: [email protected]
[PMM: avoid local vars in middle of block]
Signed-off-by: Peter Maydell <[email protected]>
2026-01-15 15:26:30 +00:00
Tao Tang a14503827d target/arm: Move ARMSecuritySpace to a common header
The ARMSecuritySpace enum and its related helpers were defined in the
target-specific header target/arm/cpu.h. This prevented common,
target-agnostic code like the SMMU model from using these definitions
without triggering "cpu.h included from common code" errors.

To resolve this, this commit introduces a new, lightweight header,
include/hw/arm/arm-security.h, which is safe for inclusion by common
code.

The following change was made:

- The ARMSecuritySpace enum and the arm_space_is_secure() and
arm_secure_to_space() helpers have been moved from target/arm/cpu.h
to the new hw/arm/arm-security.h header.

This refactoring decouples the security state definitions from the core
CPU implementation, allowing common hardware models to correctly handle
security states without pulling in heavyweight, target-specific headers.

Signed-off-by: Tao Tang <[email protected]>
Reviewed-by: Eric Auger <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-id: [email protected]
Link: https://lists.nongnu.org/archive/html/qemu-arm/2025-09/msg01288.html
Signed-off-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
2026-01-15 15:26:29 +00:00
Philippe Mathieu-Daudé c5712ad83f hw/arm: Re-enable the MAX78000FTHR machine in qemu-system-arm/aarch64
Unfortunately while rebasing the series registering the
ARM/Aarch64 machine interfaces and getting it merged as
commit 38c5ab4003 ("hw/arm: Filter machine types for
qemu-system-arm/aarch64 binaries") we missed the recent
addition of the MAX78000FTHR machine in commit 51eb283dd0.
Correct that.

The effect is that the machine was accidentally disabled.

Cc: [email protected]
Reported-by: Thomas Huth <[email protected]>
Tested-by: Thomas Huth <[email protected]>
Tested-by: Markus Armbruster <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-id: [email protected]
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3248
Fixes: 38c5ab4003 ("hw/arm: Filter machine types for single binary")
Signed-off-by: Peter Maydell <[email protected]>
2026-01-15 15:26:29 +00:00
julia 9111971f33 hw/char/cmsdk-apb-uart.c: log guest_errors for r/w to disabled uart
I don't want to admit how many hours I spent trying to figure out why
nothing was being printed (as the enable-ing code hadn't yet run,
even thought it existed).

Signed-off-by: julia <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-id: 20251217-cmsdk-uart-disabled-warning2-v1-1-847de48840bc@trainwit.ch
Signed-off-by: Peter Maydell <[email protected]>
2026-01-15 15:26:29 +00:00
Jim MacArthur bb5ce7dc56 tests: Add test for ASID2 and write/read of feature bits
Test for presence of ASID2; if it is, check FNG1, FNG0, and A2 are
writable, and read value shows the update. If not present, check these
read as RES0.

Reviewed-by: Alex Bennée <[email protected]>
Signed-off-by: Jim MacArthur <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
2026-01-15 15:26:29 +00:00
Jim MacArthur 672a1dd1ed target/arm/tcg/cpu64.c: Enable ASID2 for cpu_max
docs/system/arm/emulation.rst: Add ASID2

Reviewed-by: Gustavo Romero <[email protected]>
Signed-off-by: Jim MacArthur <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
2026-01-15 15:26:29 +00:00
Jim MacArthur 42f13215fe target/arm: Allow writes to FNG1, FNG0, A2
This just allows read/write of three feature bits. ASID is still
ignored. Any writes to TTBR0_EL0 and TTBR1_EL0, including changing
the ASID, will still cause a complete flush of the TLB.

Signed-off-by: Jim MacArthur <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
2026-01-15 15:26:29 +00:00
Jim MacArthur 153a15e9f5 target/arm: Enable ID_AA64MMFR4_EL1 register
Reviewed-by: Richard Henderson <[email protected]>
Reviewed-by: Alex Bennée <[email protected]>
Reviewed-by: Gustavo Romero <[email protected]>
Signed-off-by: Jim MacArthur <[email protected]>
[PMM: add entry to v8_user_idregs[] list also]
Signed-off-by: Peter Maydell <[email protected]>
2026-01-15 15:26:29 +00:00
Osama Abdelkader 0900f43715 hw/arm/raspi: remove duplicate include
hw/arm/boot.h is included twice

Signed-off-by: Osama Abdelkader <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
2026-01-15 15:26:29 +00:00
Yao Zi 49ee001a5b hw/loongarch/virt: Don't abort on access to unimplemented IOCSR
Since commit f2e61edb29 ("hw/loongarch/virt: Use MemTxAttrs interface
for misc ops") which adds a call to g_assert_not_reached() in the path
of handling unimplemented IOCSRs, QEMU would abort when the guest
accesses unimplemented IOCSRs.

This is too serious since there's nothing fatal happening in QEMU
itself, and the guest could probably continue running if we give zero as
result for these reads, which also matches the behavior observed on
3A5000M real machine.

Replace the assertion with qemu_log_mask(LOG_UNIMP, ...), it's still
possible to examine unimplemented IOCSR access through "-d unimp"
command line arguments.

Fixes: f2e61edb29 ("hw/loongarch/virt: Use MemTxAttrs interface for misc ops")
Signed-off-by: Yao Zi <[email protected]>
Signed-off-by: Bibo Mao <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Bibo Mao <[email protected]>
2026-01-15 14:36:11 +08:00
Song Gao a7be2e0a3f target/loongarch: Fix exception ADEF/ADEM missing to update CSR_BADV
Exception ADEM/ADEF need update CSR_BADV, the value from the virtual
address.

Signed-off-by: Song Gao <[email protected]>
Signed-off-by: Bibo Mao <[email protected]>
Reviewed-by: Bibo Mao <[email protected]>
2026-01-15 14:35:52 +08:00
Song Gao e4f0ef58d5 target/loongarch: Fix exception BCE missing to update CSR_BADV
Exception BCE need update CSR_BADV, and the value is env->pc.

Signed-off-by: Song Gao <[email protected]>
Signed-off-by: Bibo Mao <[email protected]>
Reviewed-by: Bibo Mao <[email protected]>
2026-01-15 14:35:35 +08:00
Song Gao 70cf9b7bf7 target/loongach: Fix some exceptions failure in updating CSR_BADV
According to Volume 1 Manual 7.4.8 ,exception,SYS,BRK,INE,IPE,PPD
FPE,SXD,ASXD are need't update CSR_BADV, this patch correct it.

Signed-off-by: Song Gao <[email protected]>
Signed-off-by: Bibo Mao <[email protected]>
Reviewed-by: Bibo Mao <[email protected]>
2026-01-15 14:35:20 +08:00
Xianglai Li ff54394eed hw/loongarch/virt: Fix irq allocation failure with pci device from fdt
When we use the -kernel parameter to start an elf format kernel relying on
fdt, we get the following error:

pcieport 0000:00:01.0: of_irq_parse_pci: failed with rc=-22
pcieport 0000:00:01.0: enabling device (0000 -> 0003)
pcieport 0000:00:01.0: PME: Signaling with IRQ 19
pcieport 0000:00:01.0: AER: enabled with IRQ 19
pcieport 0000:00:01.1: of_irq_parse_pci: failed with rc=-22
pcieport 0000:00:01.1: enabling device (0000 -> 0003)
pcieport 0000:00:01.1: PME: Signaling with IRQ 20
pcieport 0000:00:01.1: AER: enabled with IRQ 20
pcieport 0000:00:01.2: of_irq_parse_pci: failed with rc=-22
pcieport 0000:00:01.2: enabling device (0000 -> 0003)
pcieport 0000:00:01.2: PME: Signaling with IRQ 21
pcieport 0000:00:01.2: AER: enabled with IRQ 21
pcieport 0000:00:01.3: of_irq_parse_pci: failed with rc=-22
pcieport 0000:00:01.3: enabling device (0000 -> 0003)
pcieport 0000:00:01.3: PME: Signaling with IRQ 22
pcieport 0000:00:01.3: AER: enabled with IRQ 22
pcieport 0000:00:01.4: of_irq_parse_pci: failed with rc=-22

This is because  the description of interrupt-cell is missing in the pcie
irq map.  And there is a lack of a description of the interrupt trigger
type.  Now it is corrected and the correct interrupt-cell is added in the
pcie irq map.

Refer to the implementation in arm and add some comments.

Signed-off-by: Xianglai Li <[email protected]>
Signed-off-by: Bibo Mao <[email protected]>
Reviewed-by: Bibo Mao <[email protected]>
2026-01-15 14:34:58 +08:00
Xianglai Li 47de28a0b7 hw/loongarch/virt: Modify the interrupt trigger type in fdt table
In the loongarch virt fdt file, the interrupt trigger type directly
uses magic numbers. Now, refer to the definitions in the linux kernel and
use macro definitions.

Signed-off-by: Xianglai Li <[email protected]>
Signed-off-by: Bibo Mao <[email protected]>
Reviewed-by: Bibo Mao <[email protected]>
2026-01-15 14:34:48 +08:00
Richard Henderson 4cfa1ce036 Merge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging
* target/i386/tcg fixes
* hw/i386/kvm: fix PIRQ bounds check in xen_physdev_map_pirq()

# -----BEGIN PGP SIGNATURE-----
#
# iQFIBAABCgAyFiEE8TM4V0tmI4mGbHaCv/vSX3jHroMFAmlmFmIUHHBib256aW5p
# QHJlZGhhdC5jb20ACgkQv/vSX3jHroOyDAgAiDTglXIUzvbM1AGRcufyjKMzFeaH
# /aI1UrVno0XT0BsxGqOyR2d8EhtDiBXZe0nS0WBc0KtdUFjVDbnzPT4YF9PPDYwY
# 6KOp7dbfCLuK9gmvSPji3rlEsRrGkawy/WwI7HSzpMT2r/yMUBN/mWUqK359NgUI
# mHZkHyyf78wqSYiSsuKs8SRLfEXa2p3u9kH6F7yZ/CWSUO9o8yanu83nVvF2b12K
# m87SBKGJutuJrp266Id5DyArkbn+vIfpT1wTgsRIAWpRSAZFm/t2xSX/6UTQhmtg
# 5kAL7OCkKh/iHePx5JxtVrkFGGffhZeoSToo8amroyZ1SEXCnk/U1Ksiyg==
# =0p8Y
# -----END PGP SIGNATURE-----
# gpg: Signature made Tue 13 Jan 2026 08:54:42 PM AEDT
# gpg:                using RSA key F13338574B662389866C7682BFFBD25F78C7AE83
# gpg:                issuer "[email protected]"
# gpg: Good signature from "Paolo Bonzini <[email protected]>" [unknown]
# gpg:                 aka "Paolo Bonzini <[email protected]>" [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: 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:
  rust: Update Cargo.lock
  hw/i386/kvm: fix PIRQ bounds check in xen_physdev_map_pirq()
  target/i386/tcg: allow VEX in 16-bit protected mode
  target/i386/tcg: mask addresses for VSIB
  target/i386/tcg: do not mark all SSE instructions as unaligned
  target/i386/tcg: remove dead code
  target/i386/tcg: do not leave non-arithmetic flags in CC_SRC after PUSHF

Signed-off-by: Richard Henderson <[email protected]>
2026-01-15 11:29:21 +11:00
Richard Henderson 9ac1aa8b79 Merge tag 'm68k-for-11.0-pull-request' of https://github.com/vivier/qemu-m68k into staging
Pull request for M68K emulation (20250113)

# -----BEGIN PGP SIGNATURE-----
#
# iQJGBAABCgAwFiEEzS913cjjpNwuT1Fz8ww4vT8vvjwFAmlmGEASHGxhdXJlbnRA
# dml2aWVyLmV1AAoJEPMMOL0/L748b/QP/19OY8lzZtUazK5RVTNCZVXkRrr2vQBV
# Geey+OywZiCkREbgS5CniQ8mNUMgajY0RCyrDO5Eb7xLffBdXxGBRBpocnAbsQtj
# HJbgPS7Fg8GJKCecgzwHOhkyb6Yy9A9sleijXGq9CUoJaJAwDQGGO1MPm4jUsMVt
# GVjJG8vm3KbVNXCzgLUfHh72wSoE4S8Fn94DNJxCAEb2FC0C5T24+Yf80JA55hgT
# FRnTIbEbrJyOTVvxwZim3Ye3o2/hk3oQcaFd3ugSKXdJh58/DQi1FSAPyVM26DQu
# qXFK5Zaj9VCMpXG8vjd0SUhJWauJ9WXIRGh+S8HHcWBIxqhRxULBCvjTrPzAN2eJ
# VftrYHQe2ruqocSxWMKAIaX8RY/Og58bMwqWDkWj9r9GT3gttFRLISYdry5KS/mS
# NAlEeLNNazatCgldOrdpfvSm7rMLausuqdNgDLG6tRHwxCDR5SQMnj1hHNE+sn2O
# /Ek7gQ+JfzR5nKw1oBlWyv8ZG9DXJXLgjxX/bxR4FC+xp/QOo+ono59Ma9SjHt/2
# zpWXoIm2YgrfzRJbm7NUHnKkbd8titA1EYO9JZ0/EzPAL+pCwx6WQx+/GnxMKjA8
# 42vaRmi9lGcukXQ3gQeHR+wt/s0SOYNGTgK8tcMuDt28yn9iODijmcQSDyLLAVx4
# FNkp9jL4U+fc
# =LQA5
# -----END PGP SIGNATURE-----
# gpg: Signature made Tue 13 Jan 2026 09:02:40 PM AEDT
# gpg:                using RSA key CD2F75DDC8E3A4DC2E4F5173F30C38BD3F2FBE3C
# gpg:                issuer "[email protected]"
# gpg: Good signature from "Laurent Vivier <[email protected]>" [unknown]
# gpg:                 aka "Laurent Vivier <[email protected]>" [unknown]
# gpg:                 aka "Laurent Vivier (Red Hat) <[email protected]>" [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: CD2F 75DD C8E3 A4DC 2E4F  5173 F30C 38BD 3F2F BE3C

* tag 'm68k-for-11.0-pull-request' of https://github.com/vivier/qemu-m68k:
  target/m68k: Improve CHK and CHK2; implement CMP2
  m68k: link.l is only available with 68020+
  m68k: fix CAS2 writeback when Dc1==Dc2

Signed-off-by: Richard Henderson <[email protected]>
2026-01-15 11:28:36 +11:00
Richard Henderson d03c3e522e Merge tag 'pull-vfio-20260113' of https://github.com/legoater/qemu into staging
vfio queue:

* Resolves build errors with gcc 16
* Adjusts the Linux headers for s390x and mshv
* Fixes endianness issue in the VFIO helper functions
* Adds support for live migration with vIOMMU when using IOMMU
  dirty tracking
* Implements a migration blocker to prevent failures when VM
  memory is too large
* Corrects an unmap_bitmap failure in the legacy VFIO backend
* Addresses a workaround for an Intel IOMMU errata.
* Implements Intel IOMMU first stage translation for passthrough
  device. Also a prerequisite work for vSVA.
* Updates documentation

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCAAdFiEEoPZlSPBIlev+awtgUaNDx8/77KEFAmlmEgQACgkQUaNDx8/7
# 7KFm2w/+JwlyiY5jWjzvCBCEEgBdBrb8XzMoSFr2xWNQrNHvE23veeQJcT+5LwQI
# DV74Y3wmWYeAVGGKHVoALVEIJYtjVDOPU5TIyhr4nTMO8/A2j1ylBhsP6ZnWYYkO
# uFe92O3wTHViFY5h9dgm1JsA3Bok52mteAHAE5gsxCNYk6h+ps1a5UZM8wxjtNA2
# yVIvAZvaubnA/0yN02pz5bCOhPpaGpkV69l7nJSHwk2RPuspUR6dWo11P2yjxVDQ
# 7pv7DbLl9qm+xdmOp0ANVPKp9fqBJnBa/ta1Dn1VrQ2iJXnwezy+IdNC1In/HKKy
# ZHe+V/p2JA09xjjmB2fu53DQQIjh/qeCWi0b2vkDZZVvl0hJ+0y9P1GRxhwBhtgK
# /vwvgKGwC3OwXcdrxXNvD4Yy4NJLUtCoN8vmyI41ohLeMfr7/XrmTrf0J4ciPc4T
# 1bAHY2SWkFL59ylN+gt1khlV8zqPYP9S1i08A2wJjvLOwqRJ/LN2tNEh9pWvGmFg
# p5WGTNeZLsfD+ZT10bm083EMAc1va7RTQNjAzb55pxq0ASPl7ZIVAKqazaG9QsaK
# apPxGGYevuWzJVaNYWAqj7y37WDP/w6rKmyRmIBMV+x9+Dv+DGPbGb8oAOjZ0Av5
# 489mHYIONxp//2SvaUSfGpQHACCgEKTHlstdlyw79C84xPzHujE=
# =o9aW
# -----END PGP SIGNATURE-----
# gpg: Signature made Tue 13 Jan 2026 08:36:04 PM AEDT
# gpg:                using RSA key A0F66548F04895EBFE6B0B6051A343C7CFFBECA1
# gpg: Good signature from "Cédric Le Goater <[email protected]>" [full]
# gpg:                 aka "Cédric Le Goater <[email protected]>" [full]

* tag 'pull-vfio-20260113' of https://github.com/legoater/qemu: (41 commits)
  tests/rcutorture: Fix build error
  tests/qtest: Fix build error
  target/riscv: Fix build errors
  ppc/vof: Fix build error
  update-linux-headers: Remove "asm-s390/unistd_32.h"
  include/hw/hyperv: Remove unused 'struct mshv_vp_registers' definition
  util/vfio-helper: Fix endianness in PCI config read/write functions
  Workaround for ERRATA_772415_SPR17
  vfio/listener: Bypass readonly region for dirty tracking
  intel_iommu_accel: Implement get_host_iommu_quirks() callback
  hw/pci: Introduce pci_device_get_host_iommu_quirks()
  vfio/migration: Allow live migration with vIOMMU without VFs using device dirty tracking
  vfio/migration: Add migration blocker if VM memory is too large to cause unmap_bitmap failure
  vfio/listener: Add missing dirty tracking in region_del
  intel_iommu: Fix unmap_bitmap failure with legacy VFIO backend
  vfio/iommufd: Add IOMMU_HWPT_GET_DIRTY_BITMAP_NO_CLEAR flag support
  vfio: Add a backend_flag parameter to vfio_container_query_dirty_bitmap()
  vfio/container-legacy: rename vfio_dma_unmap_bitmap() to vfio_legacy_dma_unmap_get_dirty_bitmap()
  vfio/iommufd: Query dirty bitmap before DMA unmap
  vfio/iommufd: Add framework code to support getting dirty bitmap before unmap
  ...

Signed-off-by: Richard Henderson <[email protected]>
2026-01-14 02:37:13 +11:00
Zhao Liu a24f045228 rust: Update Cargo.lock
`cargo +nightly build` updates Cargo.lock file.

Reported-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-01-13 10:54:28 +01:00
Vulnerability Report c7504ba2a5 hw/i386/kvm: fix PIRQ bounds check in xen_physdev_map_pirq()
Reject pirq == s->nr_pirqs in xen_physdev_map_pirq().

Fixes: aa98ee38a5 ("hw/xen: Implement emulated PIRQ hypercall support")
Fixes: CVE-2026-0665
Reported-by: DARKNAVY (@DarkNavyOrg) <[email protected]>
Reviewed-by: David Woodhouse <[email protected]>
Signed-off-by: Vulnerability Report <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2026-01-13 10:54:28 +01:00
Paolo Bonzini ed88bdcfbd target/i386/tcg: allow VEX in 16-bit protected mode
VEX is only forbidden in real and vm86 mode; 16-bit protected mode supports
it for some unfathomable reason.

Cc: [email protected]
Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
2026-01-13 10:54:28 +01:00
Paolo Bonzini 5e3572ef2e target/i386/tcg: mask addresses for VSIB
VSIB can have either 32-bit or 64-bit addresses, pass a constant mask to
the helper and apply it before the load.

Cc: [email protected]
Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
2026-01-13 10:54:28 +01:00
Paolo Bonzini 73dd6e4a36 target/i386/tcg: do not mark all SSE instructions as unaligned
If the vex_special field was not initialized, it was considered to be
X86_VEX_SSEUnaligned (whose value was zero).  Add a new value to
fix that.

Cc: [email protected]
Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
2026-01-13 10:54:28 +01:00
Paolo Bonzini df5c2ef7cd target/i386/tcg: remove dead code
Remove dead code; it arose when I noticed that, because 0x3? opcodes do
have a pop, case 0x32 works just fine as fcomp (even though 0x?2 is fcom):
there is no need to hack the op to 0x03.

Reported by Coverity as CID 1643922.

Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
2026-01-13 10:54:28 +01:00
Paolo Bonzini fe12f7c8a8 target/i386/tcg: do not leave non-arithmetic flags in CC_SRC after PUSHF
The value that is pushed by PUSHF is the full EFLAGS, while CC_OP_EFLAGS
only wants arithmetic flags in CC_SRC.  To avoid this, follow what other
helpers do and set CC_SRC/CC_OP directly in helper_read_eflags.  This
is basically free and fixes an issue booting Windows 3.11.

Reported-by: Mark Cave-Ayland <[email protected]>
Fixes: e661e2d7a3 ("target/i386/tcg: update cc_op after PUSHF", 2025-12-27)
Signed-off-by: Paolo Bonzini <[email protected]>
2026-01-13 10:54:28 +01:00
Cédric Le Goater 7a05be8c70 tests/rcutorture: Fix build error
Newer gcc compiler (version 16.0.0 20260103 (Red Hat 16.0.0-0) (GCC))
detects an unused variable error:

  ../tests/unit/rcutorture.c: In function ‘rcu_read_stress_test’:
  ../tests/unit/rcutorture.c:251:18: error: variable ‘garbage’ set but not used [-Werror=unused-but-set-variable=]
    251 |     volatile int garbage = 0;
        |                  ^~~~~~~

Since the 'garbage' variable is used to generate memory reads from the
CPU while holding the RCU lock, it can not be removed. Tag it as
((unused)) instead to silence the compiler warnings/errors.

Reviewed-by: Richard Henderson <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-01-13 08:29:59 +01:00
Cédric Le Goater aef386e0b1 tests/qtest: Fix build error
Newer gcc compiler (version 16.0.0 20260103 (Red Hat 16.0.0-0) (GCC))
detects an unused variable error:

  ../tests/qtest/libqtest.c: In function ‘qtest_qom_has_concrete_type’:
  ../tests/qtest/libqtest.c:1044:9: error: variable ‘idx’ set but not used [-Werror=unused-but-set-variable=]

Remove idx.

Cc: Fabiano Rosas <[email protected]>
Cc: Laurent Vivier <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-01-13 08:29:59 +01:00
Cédric Le Goater 228f72b90f target/riscv: Fix build errors
Newer gcc compiler (version 16.0.0 20260103 (Red Hat 16.0.0-0) (GCC))
detects a truncation error:

  ../target/riscv/cpu.c: In function ‘riscv_isa_write_fdt’:
  ../target/riscv/cpu.c:2916:35: error: ‘%d’ directive output may be truncated writing between 1 and 11 bytes into a region of size 5 [-Werror=format-truncation=]
   2916 |     snprintf(isa_base, maxlen, "rv%di", xlen);
        |                                   ^~
  ../target/riscv/cpu.c:2916:32: note: directive argument in the range [-2147483648, 2147483632]
   2916 |     snprintf(isa_base, maxlen, "rv%di", xlen);
        |                                ^~~~~~~

Since the xlen variable represents the register width (32, 64, 128) in
the RISC-V base ISA name, mask its value with a 8-bit bitmask to
satisfy the size constraints on the snprintf output.

Cc: Palmer Dabbelt <[email protected]>
Cc: Alistair Francis <[email protected]>
Cc: Weiwei Li <[email protected]>
Cc: Daniel Henrique Barboza <[email protected]>
Cc: Liu Zhiwei <[email protected]>
Reviewed-by: Daniel Henrique Barboza <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-01-13 08:29:59 +01:00
Cédric Le Goater 4f543cc8c7 ppc/vof: Fix build error
Newer gcc compiler (version 16.0.0 20260103 (Red Hat 16.0.0-0) (GCC))
detects an unused variable error:

../hw/ppc/vof.c: In function ‘vof_dt_memory_available’:
../hw/ppc/vof.c:642:12: error: variable ‘n’ set but not used [-Werror=unused-but-set-variable=]

Remove 'n'.

Cc: Alexey Kardashevskiy <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-01-13 08:29:59 +01:00
Cédric Le Goater 9cac339345 update-linux-headers: Remove "asm-s390/unistd_32.h"
The "asm/unistd_32.h" file was generated for the 31-bit compatibility
mode on the s390 architecture and support was removed in v6.19-rc1,
commit 4ac286c4a8d9 ("s390/syscalls: Switch to generic system call
table generation")

unistd_32.h is no longer generated when running make header_install.
Remove it.

Reported-by: Shameer Kolothum <[email protected]>
Cc: Thomas Huth <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Reviewed-by: Cornelia Huck <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-01-13 08:29:59 +01:00
Cédric Le Goater ec7109999a include/hw/hyperv: Remove unused 'struct mshv_vp_registers' definition
The 'struct mshv_vp_registers' definition in hvgdk_mini.h is unused in
QEMU and conflicts with the canonical definition in
linux-headers/linux/mshv.h.

Remove the duplicate definition to avoid build conflicts when the Linux
headers are updated.

Cc: Magnus Kulke <[email protected]>
Reviewed-by: Magnus Kulke <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-01-13 08:29:59 +01:00
Farhan Ali 0ffc8f3625 util/vfio-helper: Fix endianness in PCI config read/write functions
The VFIO pread/pwrite functions use little-endian data format. Currently, the
qemu_vfio_pci_read_config() and qemu_vfio_pci_write_config() don't correctly
convert from CPU native endian format to little-endian (and vice versa) when
using the pread/pwrite functions. Fix this by limiting read/write to 32 bits
and handling endian conversion in qemu_vfio_pci_read_config() and
qemu_vfio_pci_write_config().

Signed-off-by: Farhan Ali <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
[ clg: Fixed typo in subject ]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-01-13 08:29:59 +01:00
Zhenzhong Duan 68d3a2a24d Workaround for ERRATA_772415_SPR17
On a system influenced by ERRATA_772415, IOMMU_HW_INFO_VTD_ERRATA_772415_SPR17
is repored by IOMMU_DEVICE_GET_HW_INFO. Due to this errata, even the readonly
range mapped on second stage page table could still be written.

Reference from 4th Gen Intel Xeon Processor Scalable Family Specification
Update, Errata Details, SPR17.
Link https://edc.intel.com/content/www/us/en/design/products-and-solutions/processors-and-chipsets/eagle-stream/sapphire-rapids-specification-update/
Backup https://cdrdv2.intel.com/v1/dl/getContent/772415

Also copied the SPR17 details from above link:
"Problem: When remapping hardware is configured by system software in
scalable mode as Nested (PGTT=011b) and with PWSNP field Set in the
PASID-table-entry, it may Set Accessed bit and Dirty bit (and Extended
Access bit if enabled) in first-stage page-table entries even when
second-stage mappings indicate that corresponding first-stage page-table
is Read-Only.

Implication: Due to this erratum, pages mapped as Read-only in second-stage
page-tables may be modified by remapping hardware Access/Dirty bit updates.

Workaround: None identified. System software enabling nested translations
for a VM should ensure that there are no read-only pages in the
corresponding second-stage mappings."

Introduce a helper vfio_device_get_host_iommu_quirk_bypass_ro to check if
readonly mappings should be bypassed.

Signed-off-by: Zhenzhong Duan <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-01-13 08:29:59 +01:00
Zhenzhong Duan 5c9da3d65d vfio/listener: Bypass readonly region for dirty tracking
When doing dirty tracking or calculating dirty tracking range, readonly
regions can be bypassed, because corresponding DMA mappings are readonly
and never become dirty.

This can optimize dirty tracking a bit for passthrough device.

Signed-off-by: Zhenzhong Duan <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-01-13 08:29:59 +01:00
Zhenzhong Duan 554a719e05 intel_iommu_accel: Implement get_host_iommu_quirks() callback
Implement get_host_iommu_quirks() callback to retrieve the vendor specific
hardware information data and convert it into bitmaps defined with enum
host_iommu_quirks. It will be used by VFIO in subsequent patch.

Suggested-by: Eric Auger <[email protected]>
Suggested-by: Nicolin Chen <[email protected]>
Signed-off-by: Zhenzhong Duan <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-01-13 08:29:59 +01:00
Zhenzhong Duan cd4d7fb721 hw/pci: Introduce pci_device_get_host_iommu_quirks()
In VFIO core, we call iommufd_backend_get_device_info() to return vendor
specific hardware information data, but it's not good to retrieve this raw
data in VFIO core.

Introduce a new PCIIOMMUOps optional callback, get_host_iommu_quirk() which
allows to retrieve the vendor specific hardware information data and convert
it into bitmaps defined with enum host_iommu_quirks.

pci_device_get_host_iommu_quirks() is a wrapper that can be called on a PCI
device potentially protected by a vIOMMU.

Suggested-by: Eric Auger <[email protected]>
Suggested-by: Nicolin Chen <[email protected]>
Signed-off-by: Zhenzhong Duan <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-01-13 08:29:59 +01:00
Zhenzhong Duan 0e3c1e2b2b vfio/migration: Allow live migration with vIOMMU without VFs using device dirty tracking
Commit e46883204c ("vfio/migration: Block migration with vIOMMU")
introduces a migration blocker when vIOMMU is enabled, because we need
to calculate the IOVA ranges for device dirty tracking. But this is
unnecessary for iommu dirty tracking.

Limit the vfio_viommu_preset() check to those devices which use device
dirty tracking. This allows live migration with VFIO devices which use
iommu dirty tracking.

Suggested-by: Jason Zeng <[email protected]>
Co-developed-by: Joao Martins <[email protected]>
Signed-off-by: Joao Martins <[email protected]>
Signed-off-by: Zhenzhong Duan <[email protected]>
Reviewed-by: Yi Liu <[email protected]>
Tested-by: Xudong Hao <[email protected]>
Tested-by: Giovannio Cabiddu <[email protected]>
Tested-by: Rohith S R <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-01-13 08:29:59 +01:00
Zhenzhong Duan 46c7633114 vfio/migration: Add migration blocker if VM memory is too large to cause unmap_bitmap failure
With default config, kernel VFIO IOMMU type1 driver limits dirty bitmap to
256MB for unmap_bitmap ioctl so the maximum guest memory region is no more
than 8TB size for the ioctl to succeed.

Be conservative here to limit total guest memory to max value supported
by unmap_bitmap ioctl or else add a migration blocker. IOMMUFD backend
doesn't have such limit, one can use it if there is a need to migrate such
large VM.

Suggested-by: Yi Liu <[email protected]>
Signed-off-by: Zhenzhong Duan <[email protected]>
Reviewed-by: Yi Liu <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-01-13 08:29:59 +01:00
Zhenzhong Duan 6e360c0617 vfio/listener: Add missing dirty tracking in region_del
If a VFIO device in guest switches from passthrough(PT) domain to block
domain, the whole memory address space is unmapped, but we passed a NULL
iotlb entry to unmap_bitmap, then bitmap query didn't happen and we lost
dirty pages.

By constructing an iotlb entry with iova = gpa for unmap_bitmap, it can
set dirty bits correctly.

For IOMMU address space, we still send NULL iotlb because VFIO don't know
the actual mappings in guest. It's vIOMMU's responsibility to send actual
unmapping notifications, e.g., vtd_address_space_unmap_in_dirty_tracking().

Signed-off-by: Zhenzhong Duan <[email protected]>
Tested-by: Giovannio Cabiddu <[email protected]>
Reviewed-by: Yi Liu <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-01-13 08:29:59 +01:00
Zhenzhong Duan cac33cb553 intel_iommu: Fix unmap_bitmap failure with legacy VFIO backend
If a VFIO device in guest switches from IOMMU domain to block domain,
vtd_address_space_unmap() is called to unmap whole address space.

If that happens during migration, migration fails with legacy VFIO
backend as below:

Status: failed (vfio_container_dma_unmap(0x561bbbd92d90, 0x100000000000, 0x100000000000) = -7 (Argument list too long))

Because legacy VFIO limits maximum bitmap size to 256MB which maps to 8TB on
4K page system, when 16TB sized UNMAP notification is sent, unmap_bitmap
ioctl fails. Normally such large UNMAP notification come from IOVA range
rather than system memory.

Apart from that, vtd_address_space_unmap() sends UNMAP notification with
translated_addr = 0, because there is no valid translated_addr for unmapping
a whole iommu memory region. This breaks dirty tracking no matter which VFIO
backend is used.

Fix them all by iterating over DMAMap list to unmap each range with active
mapping when global_dirty_tracking is active. global_dirty_tracking is
protected by BQL, so it's safe to reference it directly. If it's not active,
unmapping the whole address space in one go is optimal.

Signed-off-by: Zhenzhong Duan <[email protected]>
Reviewed-by: Yi Liu <[email protected]>
Tested-by: Giovannio Cabiddu <[email protected]>
Tested-by: Rohith S R <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-01-13 08:29:59 +01:00
Zhenzhong Duan e98a1c7049 vfio/iommufd: Add IOMMU_HWPT_GET_DIRTY_BITMAP_NO_CLEAR flag support
Pass IOMMU_HWPT_GET_DIRTY_BITMAP_NO_CLEAR when doing the last dirty
bitmap query right before unmap, no PTEs flushes. This accelerates the
query without issue because unmap will tear down the mapping anyway.

Co-developed-by: Joao Martins <[email protected]>
Signed-off-by: Joao Martins <[email protected]>
Signed-off-by: Zhenzhong Duan <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Reviewed-by: Yi Liu <[email protected]>
Tested-by: Xudong Hao <[email protected]>
Tested-by: Giovannio Cabiddu <[email protected]>
Tested-by: Rohith S R <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-01-13 08:29:59 +01:00
Joao Martins 374e28d876 vfio: Add a backend_flag parameter to vfio_container_query_dirty_bitmap()
This new parameter will be used in following patch, currently 0 is passed.

Signed-off-by: Joao Martins <[email protected]>
Signed-off-by: Zhenzhong Duan <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Reviewed-by: Yi Liu <[email protected]>
Tested-by: Giovannio Cabiddu <[email protected]>
Tested-by: Rohith S R <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
[ clg: Fixed subject typo ]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-01-13 08:29:59 +01:00
Zhenzhong Duan e79bc265ef vfio/container-legacy: rename vfio_dma_unmap_bitmap() to vfio_legacy_dma_unmap_get_dirty_bitmap()
This is to follow naming style in container-legacy.c to have low level functions
with vfio_legacy_ prefix.

No functional changes.

Suggested-by: Cédric Le Goater <[email protected]>
Signed-off-by: Zhenzhong Duan <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Reviewed-by: Yi Liu <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-01-13 08:29:59 +01:00
Zhenzhong Duan f051dbeb91 vfio/iommufd: Query dirty bitmap before DMA unmap
When an existing mapping is unmapped, there could already be dirty bits
which need to be recorded before unmap.

If query dirty bitmap fails, we still need to do unmapping or else there
is stale mapping and it's risky to guest.

Co-developed-by: Joao Martins <[email protected]>
Signed-off-by: Joao Martins <[email protected]>
Signed-off-by: Zhenzhong Duan <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Reviewed-by: Yi Liu <[email protected]>
Tested-by: Xudong Hao <[email protected]>
Tested-by: Giovannio Cabiddu <[email protected]>
Tested-by: Rohith S R <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-01-13 08:29:59 +01:00
Zhenzhong Duan 31ec4aadd0 vfio/iommufd: Add framework code to support getting dirty bitmap before unmap
Currently we support device and iommu dirty tracking, device dirty tracking
is preferred.

Add the framework code in iommufd_cdev_unmap() to choose either device or
iommu dirty tracking, just like vfio_legacy_dma_unmap_one().

Signed-off-by: Zhenzhong Duan <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Reviewed-by: Yi Liu <[email protected]>
Tested-by: Xudong Hao <[email protected]>
Tested-by: Giovannio Cabiddu <[email protected]>
Tested-by: Rohith S R <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-01-13 08:29:59 +01:00
Zhenzhong Duan ce1e871680 docs/devel: Add IOMMUFD nesting documentation
Add documentation about using IOMMUFD backed VFIO device with intel_iommu with
x-flts=on.

Suggested-by: Yi Liu <[email protected]>
Signed-off-by: Zhenzhong Duan <[email protected]>
Reviewed-by: Eric Auger <[email protected]>
Reviewed-by: Yi Liu <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-01-13 08:29:59 +01:00
Zhenzhong Duan b0163f4319 intel_iommu: Enable host device when x-flts=on in scalable mode
Now that all infrastructures of supporting passthrough device running
with first stage translation are there, enable it now.

Signed-off-by: Zhenzhong Duan <[email protected]>
Reviewed-by: Eric Auger <[email protected]>
Reviewed-by: Yi Liu <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-01-13 08:29:59 +01:00
Zhenzhong Duan cba6f4a9b5 intel_iommu: Add migration support with x-flts=on
When x-flts=on, we set up bindings to nested HWPT in host, after
migration, VFIO device binds to nesting parent HWPT by default.
We need to re-establish the bindings to nested HWPT, or else device
DMA will break.

Signed-off-by: Zhenzhong Duan <[email protected]>
Reviewed-by: Eric Auger <[email protected]>
Reviewed-by: Yi Liu <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-01-13 08:29:59 +01:00
Yi Liu cfb5139b1d intel_iommu: Replay pasid bindings after context cache invalidation
This replays guest pasid bindings after context cache invalidation.
Actually, programmer should issue pasid cache invalidation with proper
granularity after issuing context cache invalidation.

We see old linux such as 6.7.0-rc2 not following the spec, it sends
pasid cache invalidation before context cache invalidation, then QEMU
depends on context cache invalidation to get pasid entry and setup
binding.

Signed-off-by: Yi Liu <[email protected]>
Signed-off-by: Zhenzhong Duan <[email protected]>
Reviewed-by: Eric Auger <[email protected]>
Reviewed-by: Yi Liu <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-01-13 08:29:59 +01:00
Yi Liu 851d6b2c8c intel_iommu: Replay all pasid bindings when either SRTP or TE bit is changed
When either 'Set Root Table Pointer' or 'Translation Enable' bit is changed,
all pasid bindings on host side become stale and need to be updated.

Introduce a helper function vtd_replay_pasid_bindings_all() to go through all
pasid entries in all passthrough devices to update host side bindings.

Signed-off-by: Yi Liu <[email protected]>
Signed-off-by: Zhenzhong Duan <[email protected]>
Reviewed-by: Eric Auger <[email protected]>
Reviewed-by: Yi Liu <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-01-13 08:29:59 +01:00
Yi Liu f9e7fbbc0e intel_iommu_accel: Propagate PASID-based iotlb invalidation to host
This traps the guest PASID-based iotlb invalidation request and propagate it
to host.

Intel VT-d 3.0 supports nested translation in PASID granularity. Guest SVA
support could be implemented by configuring nested translation on specific
pasid. This is also known as dual stage DMA translation.

Under such configuration, guest owns the GVA->GPA translation which is
configured as first stage page table on host side for a specific pasid, and
host owns GPA->HPA translation. As guest owns first stage translation table,
piotlb invalidation should be propagated to host since host IOMMU will cache
first level page table related mappings during DMA address translation.

Signed-off-by: Yi Liu <[email protected]>
Signed-off-by: Yi Sun <[email protected]>
Signed-off-by: Zhenzhong Duan <[email protected]>
Reviewed-by: Eric Auger <[email protected]>
Reviewed-by: Yi Liu <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-01-13 08:29:58 +01:00
Zhenzhong DuanandYi Liu 0686ac68e1 intel_iommu_accel: Bind/unbind guest page table to host
This captures the guest PASID table entry modifications and propagates
the changes to host to attach a hwpt with type determined per guest IOMMU
PGTT configuration.

When PGTT=PT, attach PASID_0 to a second stage HWPT(GPA->HPA).
When PGTT=FST, attach PASID_0 to nested HWPT with nesting parent HWPT
coming from VFIO.

Co-Authored-by: Yi Liu <[email protected]>
Signed-off-by: Yi Liu <[email protected]>
Signed-off-by: Yi Sun <[email protected]>
Signed-off-by: Zhenzhong Duan <[email protected]>
Reviewed-by: Eric Auger <[email protected]>
Reviewed-by: Yi Liu <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-01-13 08:29:58 +01:00
Zhenzhong Duan df644b6981 intel_iommu: Add some macros and inline functions
Add some macros and inline functions that will be used by following patch.

This patch also make a cleanup to change below macros to use extract64()
just like what smmu does, because they are either used in following patches
or used indirectly by new introduced inline functions.

  VTD_INV_DESC_PIOTLB_IH
  VTD_SM_PASID_ENTRY_PGTT
  VTD_SM_PASID_ENTRY_DID
  VTD_SM_PASID_ENTRY_FSPM
  VTD_SM_PASID_ENTRY_FSPTPTR

But we doesn't aim to change the huge amount of bit mask style macro
definitions in this patch, that should be in a separate patch.

Suggested-by: Eric Auger <[email protected]>
Signed-off-by: Zhenzhong Duan <[email protected]>
Reviewed-by: Yi Liu <[email protected]>
Reviewed-by: Eric Auger <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-01-13 08:29:58 +01:00
Zhenzhong Duan f910f1f9b0 intel_iommu_accel: Stick to system MR for IOMMUFD backed host device when x-flts=on
When guest enables scalable mode and setup first stage page table, we don't
want to use IOMMU MR but rather continue using the system MR for IOMMUFD
backed host device.

Then default HWPT in VFIO contains GPA->HPA mappings which could be reused
as nesting parent HWPT to construct nested HWPT in vIOMMU.

Move vtd_as_key into intel_iommu_internal.h as it's also used by accel code.

Suggested-by: Yi Liu <[email protected]>
Signed-off-by: Zhenzhong Duan <[email protected]>
Reviewed-by: Eric Auger <[email protected]>
Reviewed-by: Yi Liu <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-01-13 08:29:58 +01:00
Zhenzhong Duan 42fa8991b5 intel_iommu_accel: Fail passthrough device under PCI bridge if x-flts=on
Currently we don't support nested translation for passthrough device with
emulated device under same PCI bridge, because they require different address
space when x-flts=on.

In theory, we do support if devices under same PCI bridge are all passthrough
devices. But emulated device can be hotplugged under same bridge. To simplify,
just forbid passthrough device under PCI bridge no matter if there is, or will
be emulated devices under same bridge. This is acceptable because PCIE bridge
is more popular than PCI bridge now.

Suggested-by: Yi Liu <[email protected]>
Signed-off-by: Zhenzhong Duan <[email protected]>
Reviewed-by: Eric Auger <[email protected]>
Reviewed-by: Yi Liu <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-01-13 08:29:58 +01:00
Zhenzhong Duan cca621c782 intel_iommu_accel: Check for compatibility with IOMMUFD backed device when x-flts=on
When vIOMMU is configured x-flts=on in scalable mode, first stage page table
is passed to host to construct nested page table for passthrough devices.

We need to check compatibility of some critical IOMMU capabilities between
vIOMMU and host IOMMU to ensure guest first stage page table could be used by
host.

For instance, vIOMMU supports first stage 1GB large page mapping, but host does
not, then this IOMMUFD backed device should fail.

Even of the checks pass, for now we willingly reject the association because
all the bits are not there yet, it will be relaxed in the end of this series.

Note vIOMMU has exposed VIOMMU_FLAG_WANT_NESTING_PARENT flag to force
VFIO core to create nesting parent HWPT, if host doesn't support nested
translation, the creation will fail. So no need to check nested
capability here.

Signed-off-by: Zhenzhong Duan <[email protected]>
Reviewed-by: Eric Auger <[email protected]>
Reviewed-by: Yi Liu <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
[ clg: - hw/i386/intel_iommu_accel.[hc]: Changed Copyright date 2025 -> 2026
       - in commit log :
       	 IOMMU_HWPT_ALLOC_NEST_PARENT -> VIOMMU_FLAG_WANT_NESTING_PARENT  ]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-01-13 08:29:58 +01:00
Zhenzhong Duan c3459c6bfa vfio/iommufd: Force creating nesting parent HWPT
Call pci_device_get_viommu_flags() to get if vIOMMU supports
VIOMMU_FLAG_WANT_NESTING_PARENT.

If yes, create a nesting parent HWPT and add it to the container's hwpt_list,
letting this parent HWPT cover the entire second stage mappings (GPA=>HPA).

This allows a VFIO passthrough device to directly attach to this default HWPT
and then to use the system address space and its listener.

Introduce a vfio_device_get_viommu_flags_want_nesting() helper to facilitate
this implementation.

It is safe to do so because a vIOMMU will be able to fail in set_iommu_device()
call, if something else related to the VFIO device or vIOMMU isn't compatible.

Suggested-by: Nicolin Chen <[email protected]>
Suggested-by: Yi Liu <[email protected]>
Signed-off-by: Zhenzhong Duan <[email protected]>
Reviewed-by: Nicolin Chen <[email protected]>
Reviewed-by: Eric Auger <[email protected]>
Reviewed-by: Yi Liu <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-01-13 08:29:58 +01:00
Zhenzhong Duan a3379c14c2 intel_iommu: Introduce a new structure VTDHostIOMMUDevice
Introduce a new structure VTDHostIOMMUDevice which replaces
HostIOMMUDevice to be stored in hash table.

It includes a reference to HostIOMMUDevice and IntelIOMMUState,
also includes BDF information which will be used in future
patches.

Signed-off-by: Zhenzhong Duan <[email protected]>
Reviewed-by: Eric Auger <[email protected]>
Reviewed-by: Nicolin Chen <[email protected]>
Reviewed-by: Yi Liu <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-01-13 08:29:58 +01:00
Zhenzhong Duan ecacfc145f intel_iommu: Implement get_viommu_flags() callback
Implement get_viommu_flags() callback and expose a request for nesting
parent HWPT for now.

VFIO uses it to create nesting parent HWPT which is further used to create
nested HWPT in vIOMMU. All these will be implemented in following patches.

Suggested-by: Yi Liu <[email protected]>
Signed-off-by: Zhenzhong Duan <[email protected]>
Reviewed-by: Eric Auger <[email protected]>
Reviewed-by: Nicolin Chen <[email protected]>
Reviewed-by: Yi Liu <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-01-13 08:29:58 +01:00
Zhenzhong Duan 844302bd59 hw/pci: Introduce pci_device_get_viommu_flags()
Introduce a new PCIIOMMUOps optional callback, get_viommu_flags() which
allows to retrieve flags exposed by a vIOMMU. The first planned vIOMMU
device flag is VIOMMU_FLAG_WANT_NESTING_PARENT that advertises the
support of HW nested stage translation scheme and wants other sub-system
like VFIO's cooperation to create nesting parent HWPT.

pci_device_get_viommu_flags() is a wrapper that can be called on a PCI
device potentially protected by a vIOMMU.

get_viommu_flags() is designed to return 64bit bitmap of purely vIOMMU
flags which are only determined by user's configuration, no host
capabilities involved. Reasons are:

1. host may has heterogeneous IOMMUs, each with different capabilities
2. this is migration friendly, return value is consistent between source
   and target.

Note that this op will be invoked at the attach_device() stage, at which
point host IOMMU capabilities are not yet forwarded to the vIOMMU through
the set_iommu_device() callback that will be after the attach_device().

See below sequence:

  vfio_device_attach():
      iommufd_cdev_attach():
          pci_device_get_viommu_flags() for HW nesting cap
          create a nesting parent HWPT
          attach device to the HWPT
          vfio_device_hiod_create_and_realize() creating hiod
  ...
  pci_device_set_iommu_device(hiod)

Suggested-by: Yi Liu <[email protected]>
Signed-off-by: Zhenzhong Duan <[email protected]>
Reviewed-by: Nicolin Chen <[email protected]>
Reviewed-by: Eric Auger <[email protected]>
Reviewed-by: Yi Liu <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
[ clg: include/hw/core/iommu.h: Changed Copyright date 2025 -> 2026 ]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-01-13 08:29:58 +01:00
Zhenzhong Duan d58230d875 hw/pci: Export pci_device_get_iommu_bus_devfn() and return bool
Returns true if PCI device is aliased or false otherwise. This will be
used in following patch to determine if a PCI device is under a PCI
bridge.

Signed-off-by: Zhenzhong Duan <[email protected]>
Reviewed-by: Eric Auger <[email protected]>
Reviewed-by: Nicolin Chen <[email protected]>
Reviewed-by: Yi Liu <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-01-13 08:29:58 +01:00
Zhenzhong Duan 4fda086f76 intel_iommu: Update terminology to match VTD spec
VTD spec revision 3.4 released in December 2021 renamed "First-level" to
"First-stage" and "Second-level" to "Second-stage".

Do the same in intel_iommu code to match spec, change all existing
"fl/sl/FL/SL/first level/second level/stage-1/stage-2" terminology to
"fs/ss/FS/SS/first stage/second stage".

Opportunistically fix a error print of "flts=on" with "x-flts=on".

No functional changes intended.

Suggested-by: Yi Liu <[email protected]>
Suggested-by: Eric Auger <[email protected]>
Signed-off-by: Zhenzhong Duan <[email protected]>
Reviewed-by: Eric Auger <[email protected]>
Reviewed-by: Yi Liu <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-01-13 08:29:58 +01:00
Zhenzhong Duan c629b030a2 intel_iommu: Delete RPS capability related supporting code
RID-PASID Support(RPS) is not set in vIOMMU ECAP register, the supporting
code is there but never takes effect.

Meanwhile, according to VTD spec section 3.4.3:
"Implementations not supporting RID_PASID capability (ECAP_REG.RPS is 0b),
use a PASID value of 0 to perform address translation for requests without
PASID."

We should delete the supporting code which fetches RID_PASID field from
scalable context entry and use 0 as RID_PASID directly, because RID_PASID
field is ignored if no RPS support according to spec.

This simplifies the code and doesn't bring any penalty.

Suggested-by: Yi Liu <[email protected]>
Signed-off-by: Zhenzhong Duan <[email protected]>
Reviewed-by: Eric Auger <[email protected]>
Reviewed-by: Yi Liu <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-01-13 08:29:58 +01:00
Zhenzhong Duan ecd0ff2d2e intel_iommu: Rename vtd_ce_get_rid2pasid_entry to vtd_ce_get_pasid_entry
In early days vtd_ce_get_rid2pasid_entry() was used to get pasid entry
of rid2pasid, then it was extended to get any pasid entry. So a new name
vtd_ce_get_pasid_entry is better to match what it actually does.

No functional change intended.

Signed-off-by: Zhenzhong Duan <[email protected]>
Reviewed-by: Clément Mathieu--Drif <[email protected]>
Reviewed-by: Yi Liu <[email protected]>
Reviewed-by: Eric Auger <[email protected]>
Reviewed-by: Nicolin Chen <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-01-13 08:29:58 +01:00
Zhenzhong Duan 8e49988ce0 docs/devel: Remove stale comments related to iommufd dirty tracking
IOMMUFD dirty tracking support had be merged in merge commit dd4bc5f1cf,
the stale comments could be dropped.

Signed-off-by: Zhenzhong Duan <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-01-13 08:29:58 +01:00
Philippe Mathieu-Daudé 78e630fcc4 hw/vfio/migration: Check base architecture at runtime
Inline vfio_arch_wants_loading_config_after_iter() and
replace the compile time check of the TARGET_ARM definition
by a runtime call to target_base_arm().

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Acked-by: Maciej S. Szmigiero <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-01-13 08:29:58 +01:00
Richard Henderson cf3e71d8fc Merge tag 'single-binary-20260112' of https://github.com/philmd/qemu into staging
Various patches related to single binary effort:

- Endianness cleanups in memory core subsystem and for various targets
- Few cleanups around target_ulong type
- Build various compilation units as common

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCAAdFiEE+qvnXhKRciHc/Wuy4+MsLN6twN4FAmlleisACgkQ4+MsLN6t
# wN40yw/+NYK6Q+v8YHclH0g6YkPsXYsCVOLWhYaUQ9Smc3Vk8js02LRMxomGiyjc
# lRhatftrH4dCuiWavyhlK/z+tu3b2WOgjjcIocg7ztZEwzyvDPEKidBNM4Wrv27d
# 6WNdtCn1rOOYQBcCs/MEHnrxIl3qfl5Kqt4hzejcK4E1DFa1m5ashAEVJwMlqYWp
# qkBT3fw0jfHojM+eTAbvKI1fi27GVMXbQXSM3V3vG3njxmx4JQT0p9QjyDYWZwgh
# xAJvy5neoNv3T7TBELCfqSWzGA5WHrW/eAkuRuO0JVa69IOn/mh2aGKboJMT7KQF
# ufyxceHMj8TLJr6c9BrvaWX7+p7xyvbX3ud+qXOV9P2FBVm+hf2lHnw0pJJ6A51g
# qv3u8zUVwhmx6oF95ibQtaWKdLNhGCKtVKJu59Xxj/7Bp00BS1Jnj6E/g34To8Vm
# 18g3cPJ+CEhdTFSkcHusiVI4GdHb8JEGUd5kyWza3gEgYb/J1Ps/a807n6C6NQcq
# MRkt2zNKS+sJeZzvl+BGH8WewMVGWm1f8IoP28ZvgyxFVutkgFcj+UQZp3J7mkpV
# ja0B7+1NMK9oMeq/+YM4gUgEF0ydThlqa+qTzxVYu8qpzWT9+cqqWeQHAteE3g/v
# rqqu/sBUSbh5xi+82zRbgwd7Hj31ST5XkepQN0vUTT4P3zCijy8=
# =P+9/
# -----END PGP SIGNATURE-----
# gpg: Signature made Tue 13 Jan 2026 09:48:11 AM AEDT
# gpg:                using RSA key FAABE75E12917221DCFD6BB2E3E32C2CDEADC0DE
# gpg: Good signature from "Philippe Mathieu-Daudé (F4BUG) <[email protected]>" [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: FAAB E75E 1291 7221 DCFD  6BB2 E3E3 2C2C DEAD C0DE

* tag 'single-binary-20260112' of https://github.com/philmd/qemu: (61 commits)
  target/arm/gdbstub: make compilation unit common
  target/arm/gdbstub: extract aarch64_cpu_register_gdb_regs_for_features
  gdbstub/helpers.h: allow header to be called from common code
  accel/tcg: Un-inline WatchPoint API user-emulation stubs
  target/tricore: Build system units in common source set
  target/tricore: Inline translator_lduw()
  target/tricore: Use little-endian variant of cpu_ld/st_data*()
  target/sparc: Inline cpu_ldl_code() call in cpu_do_interrupt()
  target/sparc: Inline translator_ldl()
  target/sparc: Use explicit big-endian LD/ST API
  hw/sparc: Use explicit big-endian LD/ST API
  hw/sparc: Mark SPARC-specific peripherals as big-endian
  target/sh4: drop cpu_reset from realizefn
  target/sh4: Build system units in common source set
  target/rx: Build system units in common source set
  target/rx: Inline translator_lduw() and translator_ldl()
  target/rx: Use explicit little-endian LD/ST API
  target/rx: Use little-endian variant of cpu_ld/st_data*()
  target/openrisc: Build system units in common source set
  target/openrisc: Avoid target-specific migration headers in machine.c
  ...

Signed-off-by: Richard Henderson <[email protected]>
2026-01-13 11:51:18 +11:00
Pierrick Bouvier f445b4a4b6 target/arm/gdbstub: make compilation unit common
Expose and stubs aarch64 functions. All call sites are under a
"is_aarch64" check.

Signed-off-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-01-12 23:47:57 +01:00
Pierrick Bouvier 7e274980f2 target/arm/gdbstub: extract aarch64_cpu_register_gdb_regs_for_features
Signed-off-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-01-12 23:47:57 +01:00
Pierrick Bouvier e5bb3f7715 gdbstub/helpers.h: allow header to be called from common code
Target specific variants can't be used in common code, thus limit their
definition to COMPILING_PER_TARGET.

Signed-off-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-01-12 23:47:57 +01:00
Philippe Mathieu-Daudé ec77d52cc5 accel/tcg: Un-inline WatchPoint API user-emulation stubs
Currently we can not build files including "exec/watchpoint.h"
as meson common objects because the CONFIG_USER_ONLY definition
is poisoned. We can easily fix that by un-inlining the
user-emulation stubs.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Message-ID: <[email protected]>
2026-01-12 23:47:57 +01:00
Philippe Mathieu-Daudé 6338bb09db target/tricore: Build system units in common source set
Since commit range 809b460f305..cd08bcaa36b we remove all
uses of the target_ulong type in target/rx/. Use the meson
target_common_system_arch[] source set to prevent further
uses of target-specific types.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-01-12 23:47:57 +01:00
Philippe Mathieu-Daudé 8075a0a547 target/tricore: Inline translator_lduw()
translator_lduw() is defined in "exec/translator.h" as:

 192 static inline uint16_t
 193 translator_lduw(CPUArchState *env, DisasContextBase *db, vaddr pc)
 194 {
 195     return translator_lduw_end(env, db, pc, MO_TE);
 196 }

Directly use the inlined form, expanding MO_TE -> MO_LE
since we only build the TriCore target as little-endian.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Manos Pitsidianakis <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-01-12 23:47:57 +01:00
Philippe Mathieu-Daudé 4a4b272ae8 target/tricore: Use little-endian variant of cpu_ld/st_data*()
We only build the TriCore target using little endianness order,
therefore the cpu_ld/st_data*() definitions expand to the little
endian declarations. Use the explicit little-endian variants.

Mechanical change running:

  $ tgt=tricore; \
    end=le; \
    for op in data mmuidx_ra; do \
      for ac in uw sw l q; do \
        sed -i -e "s/cpu_ld${ac}_${op}/cpu_ld${ac}_${end}_${op}/" \
                  $(git grep -l cpu_ target/${tgt}/); \
      done;
      for ac in w l q; do \
        sed -i -e "s/cpu_st${ac}_${op}/cpu_st${ac}_${end}_${op}/" \
                  $(git grep -l cpu_ target/${tgt}/); \
      done;
    done

Then adapting spaces style manually to pass checkpatch.pl.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Reviewed-by: Manos Pitsidianakis <[email protected]>
Message-ID: <[email protected]>
2026-01-12 23:47:57 +01:00
Philippe Mathieu-Daudé a8f70781d7 target/sparc: Inline cpu_ldl_code() call in cpu_do_interrupt()
In preparation of removing the cpu_ldl_code wrapper, inline it.

Since SPARC instructions are always stored in big-endian order,
replace MO_TE -> MO_BE.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Manos Pitsidianakis <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-01-12 23:47:57 +01:00
Philippe Mathieu-Daudé f7a00f64fa target/sparc: Inline translator_ldl()
translator_ldl() is defined in "exec/translator.h" as:

  198 static inline uint32_t
  199 translator_ldl(CPUArchState *env, DisasContextBase *db, vaddr pc)
  200 {
  201     return translator_ldl_end(env, db, pc, MO_TE);
  202 }

Directly use the inlined form, expanding MO_TE -> MO_BE
since we only build the SPARC targets as big-endian.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Manos Pitsidianakis <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-01-12 23:47:57 +01:00
Philippe Mathieu-Daudé 18a91deb41 target/sparc: Use explicit big-endian LD/ST API
The SPARC architecture uses big endianness. Directly use
the big-endian LD/ST API.

Mechanical change running:

  $ for a in uw w l q; do \
      sed -i -e "s/ld${a}_p(/ld${a}_be_p(/" \
        $(git grep -wlE '(ld|st)u?[wlq]_p' target/sparc/);
    done

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Manos Pitsidianakis <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-01-12 23:47:57 +01:00
Philippe Mathieu-Daudé 3b3033a0bf hw/sparc: Use explicit big-endian LD/ST API
The SPARC architecture uses big endianness. Directly use
the big-endian LD/ST API.

Mechanical change running:

  $ for a in uw w l q; do \
      sed -i -e "s/ld${a}_p(/ld${a}_be_p(/" \
        $(git grep -wlE '(ld|st)u?[wlq]_p' hw/sparc*/);
    done

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Mark Cave-Ayland <[email protected]>
Reviewed-by: Chigot Clément <[email protected]>
Reviewed-by: Manos Pitsidianakis <[email protected]>
Message-ID: <[email protected]>
2026-01-12 23:47:57 +01:00
Philippe Mathieu-Daudé 21932912a0 hw/sparc: Mark SPARC-specific peripherals as big-endian
These devices are only used by the SPARC target, which is
only built as big-endian. Therefore the DEVICE_NATIVE_ENDIAN
definition expand to DEVICE_BIG_ENDIAN (besides, the
DEVICE_LITTLE_ENDIAN case isn't tested). Simplify directly
using DEVICE_BIG_ENDIAN.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Manos Pitsidianakis <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-01-12 23:47:57 +01:00
Alex Bennée be9fe81e29 target/sh4: drop cpu_reset from realizefn
Shuffle things around to ensure that gdb register creation was
done after dependant peripherals had created their cpu interfaces.

Signed-off-by: Alex Bennée <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-01-12 23:47:57 +01:00
Philippe Mathieu-Daudé 678805a7ef target/sh4: Build system units in common source set
Since commit range 42c90609b8f..82a1e739010 we remove all
uses of the target_ulong type in target/rx/. Use the meson
target_common_system_arch[] source set to prevent further
uses of target-specific types.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-01-12 23:47:57 +01:00
Philippe Mathieu-Daudé 90d14b8d0d target/rx: Build system units in common source set
Since commit range 2982b948a9f..86114e43ffd we remove all
uses of the target_ulong type in target/rx/. Use the meson
target_common_system_arch[] source set to prevent further
uses of target-specific types.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-01-12 23:47:57 +01:00
Philippe Mathieu-Daudé b0afb81271 target/rx: Inline translator_lduw() and translator_ldl()
translator_lduw() and translator_ldl() are defined in
"exec/translator.h" as:

  192 static inline uint16_t
  193 translator_lduw(CPUArchState *env, DisasContextBase *db, vaddr pc)
  194 {
  195     return translator_lduw_end(env, db, pc, MO_TE);
  196 }

  198 static inline uint32_t
  199 translator_ldl(CPUArchState *env, DisasContextBase *db, vaddr pc)
  200 {
  201     return translator_ldl_end(env, db, pc, MO_TE);
  202 }

Directly use the inlined form, expanding MO_TE -> mo_endian().

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Manos Pitsidianakis <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-01-12 23:47:57 +01:00
Philippe Mathieu-Daudé 41a1b46c3b target/rx: Use explicit little-endian LD/ST API
The RX architecture uses little endianness. Directly use
the little-endian LD/ST API.

Mechanical change using:

  $ end=le; \
    for acc in uw w l q tul; do \
      sed -i -e "s/ld${acc}_p(/ld${acc}_${end}_p(/" \
             -e "s/st${acc}_p(/st${acc}_${end}_p(/" \
        $(git grep -wlE '(ld|st)t?u?[wlq]_p' target/rx/); \
    done

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Manos Pitsidianakis <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-01-12 23:47:57 +01:00
Philippe Mathieu-Daudé de1f3d628e target/rx: Use little-endian variant of cpu_ld/st_data*()
We only build the RX target using little endianness order,
therefore the cpu_ld/st_data*() definitions expand to the little
endian declarations. Use the explicit little-endian variants.

Mechanical change running:

  $ tgt=rx; \
    end=le; \
    for op in data mmuidx_ra; do \
      for ac in uw sw l q; do \
        sed -i -e "s/cpu_ld${ac}_${op}/cpu_ld${ac}_${end}_${op}/" \
                  $(git grep -l cpu_ target/${tgt}/); \
      done;
      for ac in w l q; do \
        sed -i -e "s/cpu_st${ac}_${op}/cpu_st${ac}_${end}_${op}/" \
                  $(git grep -l cpu_ target/${tgt}/); \
      done;
    done

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Reviewed-by: Manos Pitsidianakis <[email protected]>
Message-ID: <[email protected]>
2026-01-12 23:47:57 +01:00
Philippe Mathieu-Daudé 5059b259dd target/openrisc: Build system units in common source set
Since previous 2 commits and range 2795bc52af4..5b67dbf1dc3 we
remove all uses of the target_ulong type in target/rx/. Use the
meson target_common_system_arch[] source set to prevent further
uses of target-specific types.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-01-12 23:47:57 +01:00
Philippe Mathieu-Daudé 6238fc2f65 target/openrisc: Avoid target-specific migration headers in machine.c
machine.c doesn't use any target-specific macro defined by
the "migration/cpu.h" header. Use the minimum header required:
"migration/qemu-file-types.h" and "migration/vmstate.h", which
are not target-specific.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Prasad Pandit <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-01-12 23:47:57 +01:00
Philippe Mathieu-Daudé 4685aa3e51 target/openrisc: Remove unused 'gdbstub/helpers.h' header in helper.c
"gdbstub/helpers.h" uses target-specific symbols, but we don't
need it, so remove it.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-01-12 23:47:57 +01:00
Philippe Mathieu-Daudé 52392f95e6 target/openrisc: Inline translator_ldl()
translator_ldl() is defined in "exec/translator.h" as:

  198 static inline uint32_t
  199 translator_ldl(CPUArchState *env, DisasContextBase *db, vaddr pc)
  200 {
  201     return translator_ldl_end(env, db, pc, MO_TE);
  202 }

Directly use the inlined form, expanding MO_TE -> mo_endian().

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Manos Pitsidianakis <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-01-12 23:47:57 +01:00
Philippe Mathieu-Daudé 16c0efb5a7 target/openrisc: Use explicit big-endian LD/ST API
The OpenRISC architecture uses big endianness. Directly
use the big-endian LD/ST API.

Mechanical change running:

  $ for a in uw w l q; do \
      sed -i -e "s/ld${a}_p(/ld${a}_be_p(/" \
        $(git grep -wlE '(ld|st)u?[wlq]_p' target/openrisc/);
    done

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Manos Pitsidianakis <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-01-12 23:47:57 +01:00
Philippe Mathieu-Daudé 32d4256839 hw/intc: Mark OpenRISC-specific peripheral as big-endian
The Open Multi-Processor Interrupt Controller (ompic) is only
used by the OpenRISC target, which is only built as big-endian.
Therefore the DEVICE_NATIVE_ENDIAN definition expand to
DEVICE_BIG_ENDIAN (besides, the DEVICE_LITTLE_ENDIAN case isn't
tested). Simplify directly using DEVICE_BIG_ENDIAN.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Manos Pitsidianakis <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-01-12 23:47:57 +01:00
Philippe Mathieu-Daudé a1ced48754 hw/microblaze: Build files once
Previous commit removed the last target-specific use in
hw model units, we can now build them once.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Message-ID: <[email protected]>
2026-01-12 23:47:57 +01:00
Philippe Mathieu-Daudé 1346a81123 hw/microblaze: Replace TARGET_BIG_ENDIAN -> target_big_endian()
Check endianness at runtime to remove the target-specific
TARGET_BIG_ENDIAN definition.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Message-ID: <[email protected]>
2026-01-12 23:47:57 +01:00
Philippe Mathieu-Daudé 195060d9c8 target/microblaze: Build system files once
Previous commit removed the last target-specific use in
system units, we can now build them once.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Message-ID: <[email protected]>
2026-01-12 23:47:57 +01:00
Philippe Mathieu-Daudé f2cd7f507e target/microblaze: Avoid target-specific migration headers in machine.c
machine.c doesn't use any target-specific macro defined by
the "migration/cpu.h" header. Use the minimum header requiered:
"migration/qemu-file-types.h" and "migration/vmstate.h", which
are not target-specific.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Message-ID: <[email protected]>
2026-01-12 23:47:57 +01:00
Philippe Mathieu-Daudé 9281c68dec target/microblaze: Directly check endianness via CPUConfig::endi flag
The MicroBlazeCPUConfig::endi flag reports whether the CPU is
configure in little endianness. Directly use this knowledge
instead of evaluating MemOp from mo_endian().

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Message-ID: <[email protected]>
2026-01-12 23:47:57 +01:00
Philippe Mathieu-Daudé 10c5799fac target/m68k: Replace MD_TLONG -> MD_I32 in monitor.c
m68k's monitor_defs[] array implicitly uses type=MD_TLONG for
all its entries. Since we only build this target as 32-bit,
use the explicit MD_I32 type to avoid an indirect target_long
use.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-01-12 23:47:57 +01:00
Philippe Mathieu-Daudé 6b4c30465c target/loongarch: Inline translator_ldl()
translator_ldl() is defined in "exec/translator.h" as:

  198 static inline uint32_t
  199 translator_ldl(CPUArchState *env, DisasContextBase *db, vaddr pc)
  200 {
  201     return translator_ldl_end(env, db, pc, MO_TE);
  202 }

Directly use the inlined form, expanding MO_TE -> MO_LE
since LoongArch use little-endian order.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Bibo Mao <[email protected]>
Message-ID: <[email protected]>
2026-01-12 23:47:57 +01:00
Philippe Mathieu-Daudé f9a03787c7 target/loongarch: Use explicit little-endian LD/ST API
The LoongArch architecture uses little endianness. Directly
use the little-endian LD/ST API.

Mechanical change using:

  $ end=le; \
    for acc in uw w l q tul; do \
      sed -i -e "s/ld${acc}_p(/ld${acc}_${end}_p(/" \
             -e "s/st${acc}_p(/st${acc}_${end}_p(/" \
        $(git grep -wlE '(ld|st)t?u?[wlq]_p' target/loongarch/); \
    done

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Bibo Mao <[email protected]>
Message-ID: <[email protected]>
2026-01-12 23:47:57 +01:00
Philippe Mathieu-Daudé 91312a6d04 target/loongarch: Inline cpu_ldl_code() call in cpu_do_interrupt()
In preparation of removing the cpu_ldl_code wrapper, inline it.

Since LoongArch instructions are always stored in little-endian
order, replace MO_TE -> MO_LE.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Bibo Mao <[email protected]>
Message-Id: <[email protected]>
2026-01-12 23:47:57 +01:00
Philippe Mathieu-Daudé 492b2799c6 target/loongarch: Replace MO_TE -> MO_LE
We only build the LoongArch target using little endianness
order, therefore the MO_TE definitions expand to the little
endian one. Use the latter which is more explicit.

Mechanical change running:

  $ sed -i -e s/MO_TE/MO_LE/ \
        $(git grep -wl MO_TE target/loongarch/)

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Bibo Mao <[email protected]>
Message-ID: <[email protected]>
2026-01-12 23:47:56 +01:00
Philippe Mathieu-Daudé dfb8034a9a target/loongarch: Use hwaddr type for physical addresses
Replace variables used with get_physical_address(), which
expect a physical addresses, by the 'hwaddr' type, instead
of the 'target_ulong' one.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Bibo Mao <[email protected]>
Message-ID: <[email protected]>
2026-01-12 23:47:56 +01:00
Philippe Mathieu-Daudé 99d8a33fe6 target/loongarch: Replace target_ulong -> uint64_t for DMW and TLBRBADV
The Direct Mapping Configuration Window and Bad Virtual
Address CSR registers are declared as uint64_t since their
introduction in commit 398cecb9c3 ("target/loongarch: Add
CSRs definition"):

 296 typedef struct CPUArchState {
 ...
 345     uint64_t CSR_TLBRBADV;
 ...
 359     uint64_t CSR_DMW[4];
 ...
 385 } CPULoongArchState;

Use the proper uint64_t type instead of target_ulong
(which would otherwise be truncated on 32-bit builds).

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Bibo Mao <[email protected]>
Message-Id: <[email protected]>
2026-01-12 23:47:56 +01:00
Philippe Mathieu-Daudé 2d3c00965a hw/loongarch: Use explicit little-endian LD/ST API
The LoongArch architecture uses little endianness. Directly
use the little-endian LD/ST API.

Mechanical change using:

  $ end=le; \
    for acc in uw w l q tul; do \
      sed -i -e "s/ld${acc}_p(/ld${acc}_${end}_p(/" \
             -e "s/st${acc}_p(/st${acc}_${end}_p(/" \
        $(git grep -wlE '(ld|st)t?u?[wlq]_p' hw/loongarch/); \
    done

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Bibo Mao <[email protected]>
Message-ID: <[email protected]>
2026-01-12 23:47:56 +01:00
Philippe Mathieu-Daudé 10a860dd5d target/hppa: Remove target_ulong use in disas_log() handler
Since commit 85c19af63e ("include/exec: Use vaddr in DisasContextBase
virtual addresses") the DisasContextBase::pc_first field is a vaddr
type.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-01-12 23:47:56 +01:00
Philippe Mathieu-Daudé 253b483940 target/hppa: Avoid target-specific migration headers in machine.c
machine.c doesn't use any target-specific macro defined by
the "migration/cpu.h" header. Use the minimum header required:
"migration/qemu-file-types.h" and "migration/vmstate.h", which
are not target-specific.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Prasad Pandit <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-01-12 23:47:56 +01:00
Philippe Mathieu-Daudé bcf5e5d3e3 target/hppa: Inline translator_ldl()
translator_ldl() is defined in "exec/translator.h" as:

  198 static inline uint32_t
  199 translator_ldl(CPUArchState *env, DisasContextBase *db, vaddr pc)
  200 {
  201     return translator_ldl_end(env, db, pc, MO_TE);
  202 }

Directly use the inlined form, expanding MO_TE -> mo_endian().

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Manos Pitsidianakis <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-01-12 23:47:56 +01:00
Philippe Mathieu-Daudé 75498b3f7b target/hppa: Use explicit big-endian LD/ST API
The HPPA architecture uses big endianness. Directly use
the big-endian LD/ST API.

Mechanical change using:

  $ end=be; \
    for acc in uw w l q tul; do \
      sed -i -e "s/ld${acc}_p(/ld${acc}_${end}_p(/" \
             -e "s/st${acc}_p(/st${acc}_${end}_p(/" \
        $(git grep -wlE '(ld|st)t?u?[wlq]_p' target/hppa/); \
    done

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Manos Pitsidianakis <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-01-12 23:47:56 +01:00
Philippe Mathieu-Daudé c53afb5ed5 target/hppa: Remove unnecessary @cpu variable by using cpu_env()
Partly revert changes introduced by commit b2c2d00f48 ("target/hppa:
add 64 bit support to gdbstub"), restoring the cpu_env() call and
removing the unused @cpu argument.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Manos Pitsidianakis <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-01-12 23:47:56 +01:00
Philippe Mathieu-Daudé c77d0e9009 target/hppa: Use big-endian variant of cpu_ld/st_data*()
We only build the HPPA target using big endianness order,
therefore the cpu_ld/st_data*() definitions expand to the big
endian declarations. Use the explicit big-endian variants.

Mechanical change running:

  $ tgt=hppa; \
    end=be; \
    for op in data mmuidx_ra; do \
      for ac in uw sw l q; do \
        sed -i -e "s/cpu_ld${ac}_${op}/cpu_ld${ac}_${end}_${op}/" \
                  $(git grep -l cpu_ target/${tgt}/); \
      done;
      for ac in w l q; do \
        sed -i -e "s/cpu_st${ac}_${op}/cpu_st${ac}_${end}_${op}/" \
                  $(git grep -l cpu_ target/${tgt}/); \
      done;
    done

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-01-12 23:47:56 +01:00
Philippe Mathieu-Daudé dffb3938aa target/hexagon: Use little-endian variant of cpu_ld/st_data*()
We only build the Hexagon target using little endianness order,
therefore the cpu_ld/st_data*() definitions expand to the little
endian declarations. Use the explicit little-endian variants.

Mechanical change running:

  $ tgt=hexagon; \
    end=le; \
    for op in data mmuidx_ra; do \
      for ac in uw sw l q; do \
        sed -i -e "s/cpu_ld${ac}_${op}/cpu_ld${ac}_${end}_${op}/" \
                  $(git grep -l cpu_ target/${tgt}/); \
      done;
      for ac in w l q; do \
        sed -i -e "s/cpu_st${ac}_${op}/cpu_st${ac}_${end}_${op}/" \
                  $(git grep -l cpu_ target/${tgt}/); \
      done;
    done

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Brian Cain <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-01-12 23:47:56 +01:00
Philippe Mathieu-Daudé 989b25c73b target/hexagon: Inline translator_ldl()
translator_ldl() is defined in "exec/translator.h" as:

  198 static inline uint32_t
  199 translator_ldl(CPUArchState *env, DisasContextBase *db, vaddr pc)
  200 {
  201     return translator_ldl_end(env, db, pc, MO_TE);
  202 }

Directly use the inlined form, expanding MO_TE -> MO_LE
since Hexagon use little-endian order.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Manos Pitsidianakis <[email protected]>
Message-ID: <[email protected]>
2026-01-12 23:47:56 +01:00
Philippe Mathieu-Daudé 8d9a3353bc target/avr: Inline translator_lduw()
translator_lduw() is defined in "exec/translator.h" as:

 192 static inline uint16_t
 193 translator_lduw(CPUArchState *env, DisasContextBase *db, vaddr pc)
 194 {
 195     return translator_lduw_end(env, db, pc, MO_TE);
 196 }

Directly use the inlined form, expanding MO_TE -> MO_LE
since AVR only exists in little-endian.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Manos Pitsidianakis <[email protected]>
Message-ID: <[email protected]>
2026-01-12 23:47:56 +01:00
Anton Johansson f5fa259b50 target/alpha: Introduce alpha_phys_addr_space_bits()
In preparation for dropping TARGET_PHYS_ADDR_SPACE_BITS, add a
a runtime function to correctly represent the size of the physical
address space for EV4-6 based on the current CPU version.

Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Anton Johansson <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2026-01-12 23:47:56 +01:00
Philippe Mathieu-Daudé 62e8edfe1b target/alpha: Inline translator_ldl()
translator_ldl() is defined in "exec/translator.h" as:

  198 static inline uint32_t
  199 translator_ldl(CPUArchState *env, DisasContextBase *db, vaddr pc)
  200 {
  201     return translator_ldl_end(env, db, pc, MO_TE);
  202 }

Directly use the inlined form.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-01-12 23:47:56 +01:00
Philippe Mathieu-Daudé 076bcbd7e2 target/alpha: Inline cpu_ldl_code() call in do_unaligned_access()
In preparation of removing the cpu_ldl_code wrapper, inline it.
Use the return address argument.

Since Alpha instructions are always stored in little-endian
order, replace MO_TE -> MO_LE.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-01-12 23:47:56 +01:00
Philippe Mathieu-Daudé bd595bfa2d hw/alpha: Use explicit little-endian LD/ST API
The Alpha architecture uses little endianness. Directly
use the little-endian LD/ST API.

Mechanical change running:

  $ for a in uw w l q; do \
      sed -i -e "s/ld${a}_p(/ld${a}_le_p(/" \
        $(git grep -wlE '(ld|st)u?[wlq]_p' hw/alpha/);
    done

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Manos Pitsidianakis <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-01-12 23:47:56 +01:00
Philippe Mathieu-Daudé 83d5db95d3 meson: Allow system binaries to not have target-specific units
As we are moving toward a single binary, targets might end
without any target-specific objects (all objects being in
the 'common' source set). Allow this by checking the
target_system_arch[] dictionary contains the target key
before using it.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Message-ID: <[email protected]>
2026-01-12 23:47:56 +01:00
Philippe Mathieu-Daudé 5a17a542ac system/ioport: Do not open-code address_space_ld/st_le() methods
When a variable size is known, prefer the address_space_ld/st()
API. Keep address_space_read/write() for blobs.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-01-12 23:47:56 +01:00
Philippe Mathieu-Daudé 35ddb78b65 system/ioport: Declare x86-specific I/O port in little-endian order
X86 in/out port (related to ISA bus) uses little endianness:
- enforce little endianness in x86 cpu_in/out() accessors,
- serialize QTest in/out port accesses as little-endian.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Fabiano Rosas <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-01-12 23:47:56 +01:00
Philippe Mathieu-Daudé d78e91a311 system/memory: Inline address_space_stq_internal()
As its name suggests, address_space_stq_internal() is an
internal method which can be inlined like all the other
ones in this file.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-01-12 23:47:56 +01:00
Philippe Mathieu-Daudé 00531d0567 system/memory: Split MemoryRegionCache API to 'memory_cached.h'
We have 115 direct inclusions of "system/memory.h", and 91 headers
in include/ use it: hundreds of files have to process it.
However only one single header really uses the MemoryRegionCache
API: "hw/virtio/virtio-access.h". Split it out to a new header,
avoiding processing unused inlined functions hundreds of times.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-01-12 23:47:56 +01:00
Philippe Mathieu-Daudé f0d1d7f379 system/physmem: Convert DEBUG_SUBPAGE printf() to trace events
Defining DEBUG_SUBPAGE allows to use raw printf() statements to
print information about some events; convert these to tracepoints.

Suggested-by: Richard Henderson <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Manos Pitsidianakis <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-01-12 23:47:56 +01:00
Philippe Mathieu-Daudé 31ec610992 system/physmem: Inline and remove leul_to_cpu()
leul_to_cpu() is only used within physmem.c: inline it
and remove.
Since @bitmap is of 'unsigned long' type, use its size
with ldn_le_p() instead of using HOST_LONG_BITS.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-01-12 23:47:56 +01:00
Philippe Mathieu-Daudé 8afde4364d tests/qtest: Remove unnecessary 'qemu/bswap.h' include
None of these files use API declared in "qemu/bswap.h",
remove the unnecessary inclusion.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Reviewed-by: Manos Pitsidianakis <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-01-12 23:47:56 +01:00
Philippe Mathieu-Daudé f44866719f bswap: Consistently use builtin bswap() functions
Since these headers use some __builtin_bswap*(), use it
consistently in all the cases, allowing to remove the
"qemu/bswap.h" inclusion (which only defines bswap* to
the builtin equivalent).

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-01-12 23:47:56 +01:00
Philippe Mathieu-Daudé c8c3955424 docs/devel/loads-stores: Fix ld/stn_*_p() regexp
Fixes: afa4f6653d ("bswap: Add stn_*_p() and ldn_*_p() functions")
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-01-12 23:47:56 +01:00
Philippe Mathieu-Daudé 6af7da930a MAINTAINERS: Cover 'system/memory_ldst*.h.inc' files
Missed in commit c611228c0e ("include: move memory_ldst*
to include/system").

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Manos Pitsidianakis <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-01-12 23:47:56 +01:00
Paolo Bonzini 894c8bd56f configs: use default prefix for Windows compilation
The update to Python 3.13 causes meson configuration to fail, see e.g.:

   https://gitlab.com/qemu-project/qemu/-/jobs/12672816538#L397

   meson.build:1:0: ERROR: prefix value '/qemu' must be an absolute path

This is https://github.com/mesonbuild/meson/issues/14303.  Remove the
prefix='/qemu' line in configs/meson/windows.txt, since commit d17f305a26
("configure: use a platform-neutral prefix", 2020-09-30) says that the
NSIS installer doesn't care.

Cc: [email protected]
Cc: Thomas Huth <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-01-13 09:44:41 +11:00
Richard Henderson 07d73947d0 Merge tag 'pull-request-2026-01-12' of https://gitlab.com/thuth/qemu into staging
* Check functional tests with pylint
* update copyright year to 2026
* Some more universal-binary work for the s390x code done by Philippe
* Fix reverse debugging for s390x and add a functional test for it

# -----BEGIN PGP SIGNATURE-----
#
# iQJFBAABCgAvFiEEJ7iIR+7gJQEY8+q5LtnXdP5wLbUFAmlk81cRHHRodXRoQHJl
# ZGhhdC5jb20ACgkQLtnXdP5wLbWxhxAAlvaTwC7trSsFY3sTMwenG0GHfg0M840H
# vYXHm69uHigT4IyC2pXOjCN0Yq9zujCymtUIWOKY8l+Hx/x5tgi5fKhOXqqZBhJP
# KyBKZqJx3cVZC54qlNWF0vxSYCi32wi6xQmVlMYtbBZPfbMfY1Vi55PAknpXCWjv
# YfBB72LQhS3uPBLOi2Dg3mkGq9+cqHoAVCDVguOBx0N4SdkotvbKrG4XOhFfzjVu
# VrLgwF2LBLQzlU2JZ/b2u1IOSju67c0qW29dx86p5n6JZdLqNhsOjQ81ToHpQML2
# S/X2Nv0uyZTSzjdriBvkyOnM6L35wpZ2qyPrRekfnwzUNKEyHN9b+WTqAZdvCrm1
# eKrs87HQ7u3XUu3lR43fFCVlAgpstsF2I9UyyiMMEqGlKAjllDzgy7U3SYaP04Zm
# pgv7cLt1jgh5GoLB7TC/XRdy1P7Ya1cZ76tL2Uj93CF4w7E2vtHtVzCA6YQk9kVJ
# jn9pxjYXw/qsoQgM2Ze7UI/d5MYqVHVPK83T5natq1sXf9ardmf2OGQWLrp1JaUl
# O8xeVpMR08tElxPlcEL+3zd5YAw4QrNJ9D7GhfJQWKOgnOkT/4Kslcyqp8wLP4/D
# oeNVrv/aEXA8Lf+ozHyIEejmmWJnmgHlAnfL+wi9KV1JzWAsskg5ClR8G3ZzAa69
# CUnS7mOSnsw=
# =N/we
# -----END PGP SIGNATURE-----
# gpg: Signature made Tue 13 Jan 2026 12:12:55 AM AEDT
# gpg:                using RSA key 27B88847EEE0250118F3EAB92ED9D774FE702DB5
# gpg:                issuer "[email protected]"
# gpg: Good signature from "Thomas Huth <[email protected]>" [unknown]
# gpg:                 aka "Thomas Huth <[email protected]>" [unknown]
# gpg:                 aka "Thomas Huth <[email protected]>" [unknown]
# gpg:                 aka "Thomas Huth <[email protected]>" [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: 27B8 8847 EEE0 2501 18F3  EAB9 2ED9 D774 FE70 2DB5

* tag 'pull-request-2026-01-12' of https://gitlab.com/thuth/qemu:
  tests/functional/s390x: Add reverse debugging test for s390x
  target/s390x: Fix infinite loop during replay
  target/s390x: Un-inline s390_is_pv()
  target/s390x: Simplify S390_ADAPTER_SUPPRESSIBLE definition
  target/s390x: Remove unused 'gdbstub/helpers.h' header in helper.c
  target/s390x: Replace target_ulong -> uint64_t in gdb_write_register()
  target/s390x: Use vaddr for $pc in get_next_pc()
  target/s390x: Restrict WatchPoint API to TCG
  docs: update copyright year to 2026
  tests/functional: Add a generic test that checks the files with pylint
  tests/functional/aarch64/test_smmu: Silence warning from pylint
  tests/functional/aarch64/test_virt_gpu: Fix style issues
  tests/functional/ppc64/test_hv: Silence warnings reported by pylint
  tests/functional/mips/test_malta: Silence warnings reported by pylint
  tests/functional: Add a pylintrc file

Signed-off-by: Richard Henderson <[email protected]>
2026-01-13 09:44:00 +11:00
Richard Henderson 32b41c59f3 Merge tag 'pull-ppc-for-11.0-20260112' of https://gitlab.com/harshpb/qemu into staging
First PPC PR for 11.0

- Snapshot support for several ppc devices
- Migration fix and OS level migration test for pseries
- Minor code cleanups

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCAAdFiEEa4EM1tK+EPOIPSFCRUTplPnWj7sFAmlky2YACgkQRUTplPnW
# j7vXUg/8Dx/nsygeDspmhlmvqEWjyXm3fjIGnyCtSZWSkDkhh1x+uc0khFLuG8in
# 1Ep2D4qkGDBrdv079WzDKJDhgH21gTApA92xUsJFof2LLgN+MZOgi2Im6wR+Prtr
# EddB7jJ062fDDyMQWBdg+9jkl0+xuj+JE5JXPbXV0Fqu+t3rVJvn7c1b3uRXRrC9
# hgiss0xgTpXdVGnVjsQYLr3+iJ5Qcd7+6UhtRzTgv7S02IJRjpVoHSayBnKmzG9r
# eLqQMykyqU8drmQUruTk1nM2PRbaGTuRO+Swcld7SgqxOxxYIXD72f89B94kZKqM
# qZKv/C03EP30wS7/zJMwWsIEuXKM/oUwXl4i5C5eRUIa637VjcFEhuj0fCd8qxmz
# mUp6tVTYaGESpWUJA9TLZOkvLO9c4gumbTWa5valYeRWCLdXFQZgDg0wrwu7SL5M
# vdzKdnTMozkkKIY0W2Gk5j6E6aHpcGvNxREGrtI1BEUGKtGVzPjMHZmYDormSLIz
# lvgZj7JEncjkGv6uIYKMv1tT7Cbo2YxoGRWbx59PWpK9Ekl8307BMi2OtPYqZm7N
# CKS0lK+OM8CUP7Ao4nwxzH+T6X+C88Ivjt31sS25ixdUK6+Wy8tCEK2XCwA8gxjH
# QuBMDYMoAWgZ+mQITNy+HrqM1TBI8a4PiF9DjX2xj3sdyBd67F8=
# =2zBL
# -----END PGP SIGNATURE-----
# gpg: Signature made Mon 12 Jan 2026 09:22:30 PM AEDT
# gpg:                using RSA key 6B810CD6D2BE10F3883D21424544E994F9D68FBB
# gpg: Good signature from "Harsh Prateek Bora <[email protected]>" [undefined]
# gpg:                 aka "Harsh Prateek Bora <[email protected]>" [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.0-20260112' of https://gitlab.com/harshpb/qemu:
  tests/functional: Add a OS level migration test for pseries
  target/ppc: Fix env->quiesced migration
  hw/ppc: Add VMSTATE information to PnvPsi
  hw/ppc: pnv_chiptod.c add vmstate support
  hw/ppc: pnv_core.c add vmstate support
  hw/ppc: pnv_adu.c added vmstate support
  hw/ppc: Add pnv_i2c vmstate support
  hw/ppc: Add pnv_spi vmstate support
  hw/ppc: Add VMSTATE information for LPC model
  target/ppc/kvm : Use macro names instead of hardcoded constants as return values

Signed-off-by: Richard Henderson <[email protected]>
2026-01-13 09:43:39 +11:00
Richard Henderson 81f1fc471c Merge tag 'pull-loongarch-20260112' of https://github.com/bibo-mao/qemu into staging
loongarch queue

# -----BEGIN PGP SIGNATURE-----
#
# iHUEABYKAB0WIQQNhkKjomWfgLCz0aQfewwSUazn0QUCaWSdwgAKCRAfewwSUazn
# 0cwwAQC4xgK0x98Z10yoMfuIz5FfDq1onrFC7rd5k0K7pLgsywEA1NrLtW/lSy6Z
# xlgaus/3reiDz+zEOeBQPLibVIVQSA0=
# =8ksY
# -----END PGP SIGNATURE-----
# gpg: Signature made Mon 12 Jan 2026 06:07:46 PM AEDT
# gpg:                using EDDSA key 0D8642A3A2659F80B0B3D1A41F7B0C1251ACE7D1
# gpg: Good signature from "bibo mao <[email protected]>" [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: 7044 3A00 19C0 E97A 31C7  13C4 8E86 8FB7 A176 9D4C
#      Subkey fingerprint: 0D86 42A3 A265 9F80 B0B3  D1A4 1F7B 0C12 51AC E7D1

* tag 'pull-loongarch-20260112' of https://github.com/bibo-mao/qemu:
  hw/loongarch/virt: Add property highmem-mmio-size with virt machine
  hw/loongarch/virt: Add high MMIO support with GPEX host
  hw/loongarch/virt: Add property highmem_mmio with virt machine
  hw/loongarch/virt: Get PCI info from gpex config info
  hw/loongarch/virt: Get irq number from gpex config info
  hw/loongarch/virt: Add field gpex in LoongArchVirtMachineState
  hw/loongarch/virt: Add field ram_end in LoongArchVirtMachineState
  target/loongarch: Add PMU register dump support in KVM
  target/loongarch: Call function loongarch_la464_init_csr() after realized
  target/loongarch: Add PMU migration support in KVM mode

Signed-off-by: Richard Henderson <[email protected]>
2026-01-13 08:23:10 +11:00
William Hooper cad529260a target/m68k: Improve CHK and CHK2; implement CMP2
Some CHK2 (Check Register Against Bounds) instructions, such as opcode
02FA, cause spurious illegal instruction exceptions, despite being valid
on Motorola MC68020 and later processors and used in existing software.

With this patch, QEMU:

- Translates CHK2 and CMP2 (Compare Register Against Bounds)
  instructions [1] having any valid size or effective address. CHK2 and
  CMP2 use the same opcodes but differ in bit 11 of the extension word.
  (BITREV or BYTEREV instructions for ColdFire family processors [2],
  which use similar opcodes, are not captured, however.)

- Implements CMP2, which "is identical to CHK2 except that it sets
  condition codes rather than taking an exception" [1].

- Populates the correct "logical address of the instruction following
  the instruction that caused the trap" [3] in the exception stack frame
  for CHK and CHK2 exceptions, according to the number of words in the
  instruction, including extension words, rather than default lengths.

An existing test for CHK2 is enabled, and tests are added for CHK, CHK2,
and CMP2.

References:
[1] Motorola M68000 Family Programmer's Reference Manual (M68000PM/AD),
    Rev. 1, 1992, pages 4-72 to 4-73 and 4-82 to 4-83.
[2] Freescale Semiconductor, ColdFire Family Programmer's Reference Manual
    (CFPRM), Rev. 3, 2005, pages 4-19 and 4-26.
[3] Motorola M68040 User's Manual (M68040UM/AD), 1993, page 8-8.

Signed-off-by: William Hooper <[email protected]>
Reviewed-by: Laurent Vivier <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Laurent Vivier <[email protected]>
2026-01-12 16:26:48 +01:00
Laurent Vivier c8f7fdd122 m68k: link.l is only available with 68020+
Base 68000 only supports word size.

Signed-off-by: Laurent Vivier <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Reviewed-by: William Hooper <[email protected]>
Message-ID: <[email protected]>
2026-01-12 16:24:53 +01:00
Laurent Vivier 11dac41f2e m68k: fix CAS2 writeback when Dc1==Dc2
According to Programmer's Reference Manual, if Dc1 and Dc2 specify the
same data register and the comparison fails, memory operand 1 is stored
in the data register.

The current helpers wrote Dc1 then Dc2, leaving operand 2 in the shared
register.

Swap the writeback order for cas2w/cas2l so memory operand 1 wins.

Signed-off-by: Laurent Vivier <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-01-12 16:24:29 +01:00
Thomas Huth f397b7652d tests/functional/s390x: Add reverse debugging test for s390x
We just have to make sure that we can set the endianness to big endian,
then we can also run this test on s390x.

Reviewed-by: Ilya Leoshkevich <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
2026-01-12 13:56:28 +01:00
Ilya Leoshkevich f098c32db4 target/s390x: Fix infinite loop during replay
Replaying even trivial s390x kernels hangs, because:

- cpu_post_load() fires the TOD timer immediately.

- s390_tod_load() schedules work for firing the TOD timer.

- If rr loop sees work and then timer, we get one timer expiration.

- If rr loop sees timer and then work, we get two timer expirations.

- Record and replay may diverge due to this race.

- In this particular case divergence makes replay loop spin: it sees that
  TOD timer has expired, but cannot invoke its callback, because there
  is no recorded CHECKPOINT_CLOCK_VIRTUAL.

- The order in which rr loop sees work and timer depends on whether
  and when rr loop wakes up during load_snapshot().

- rr loop may wake up after the main thread kicks the CPU and drops
  the BQL, which may happen if it calls, e.g., qemu_cond_wait_bql().

Firing TOD timer twice is duplicate work, but it was introduced
intentionally in commit 7c12f710ba ("s390x/tcg: rearm the CKC timer
during migration") in order to avoid dependency on migration order.

The key culprits here are timers that are armed ready expired. They
break the ordering between timers and CPU work, because they are not
constrained by instruction execution, thus introducing non-determinism
and record-replay divergence.

Fix by converting such timer callbacks to CPU work. Also add TOD clock
updates to the save path, mirroring the load path, in order to have the
same CHECKPOINT_CLOCK_VIRTUAL during recording and replaying.

Link: https://lore.kernel.org/qemu-devel/[email protected]/
Signed-off-by: Ilya Leoshkevich <[email protected]>
Tested-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
[thuth: Add SPDX license identifiers to the new stubs files]
Signed-off-by: Thomas Huth <[email protected]>
2026-01-12 13:56:28 +01:00
Philippe Mathieu-Daudé c4a009cbdc target/s390x: Un-inline s390_is_pv()
Inlining a method which use a static variable is really a
bad idea, as it totally defeats the point of both concepts.

Currently we have 12 + 4 = 16 static 'ccw' variables...:

  $ git grep -wl target/s390x/kvm/pv.h | fgrep .h
  hw/s390x/ipl.h
  $ git grep -wl target/s390x/kvm/pv.h | fgrep .c | wc -l
        12
  $ git grep -wl hw/s390x/ipl.h | fgrep .c | wc -l
         4

Fixes: c3347ed0d2 ("s390x: protvirt: Support unpack facility")
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
2026-01-12 13:56:28 +01:00
Philippe Mathieu-Daudé 901e2eb325 target/s390x: Simplify S390_ADAPTER_SUPPRESSIBLE definition
Commit 1497c16066 ("s390x: add flags field for registering I/O
adapter") defined S390_ADAPTER_SUPPRESSIBLE twice, one when
KVM is available and another when it isn't. However both
definitions expand to the same value. Unify them, adding an
extra safety check in KVM-specific file.

This allows removing the target-specific 'CONFIG_KVM'
definition in "cpu.h".

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
2026-01-12 13:56:28 +01:00
Philippe Mathieu-Daudé 11d65ecf6e target/s390x: Remove unused 'gdbstub/helpers.h' header in helper.c
"gdbstub/helpers.h" uses target-specific symbols, but we don't
need it, so remove it.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Tested-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
2026-01-12 13:56:28 +01:00
Philippe Mathieu-Daudé 0cdf2c9af2 target/s390x: Replace target_ulong -> uint64_t in gdb_write_register()
On s390x target_ulong expands to uint64_t. Besides,
ldq_be_p() returns a uint64_t type. Use that instead.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
2026-01-12 13:56:28 +01:00
Philippe Mathieu-Daudé 3254cca0f8 target/s390x: Use vaddr for $pc in get_next_pc()
DisasContextBase::pc_next is of vaddr type.
Since translator_lduw_end() returns a uint16_t,
also use that type for clarity.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
2026-01-12 13:56:28 +01:00
Philippe Mathieu-Daudé 053c14ae37 target/s390x: Restrict WatchPoint API to TCG
By inverting the 'tcg_enabled()' check in s390_cpu_set_psw()
we can let the compiler elide the s390_cpu_recompute_watchpoints()
call when TCG is not available. Move this function -- along with
s390x_cpu_debug_excp_handler() which was introduced in the same
commit 311918b979 ("target-s390x: PER storage-alteration event
support") -- to a TCG specific file to avoid compiling dead code
on KVM. This restricts the WatchPoint API calls to TCG.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
2026-01-12 13:56:28 +01:00
Ani Sinha 900e9a3adc docs: update copyright year to 2026
We are already in 2026. Update docs to update copyright info to year 2026.

Cc: [email protected]
Cc: [email protected]
Signed-off-by: Ani Sinha <[email protected]>
Reviewed-by: Alex Bennée <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
2026-01-12 13:53:32 +01:00
Thomas Huth 58cb0a35fb tests/functional: Add a generic test that checks the files with pylint
To avoid that new pylint-related warnings get committed, let's check
the files with pylint during each run (similar to what we are doing
for the iotests already).

Message-Id: <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
2026-01-12 13:53:32 +01:00
Thomas Huth 973800eaf2 tests/functional/aarch64/test_smmu: Silence warning from pylint
Pylint thinks that the accel variable might be used here without
being set first, since it does not know that skipTest() never
returns. Thus initialize "accel = None" here to make it happy.

Message-Id: <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
2026-01-12 13:53:32 +01:00
Thomas Huth d68c74dd1a tests/functional/aarch64/test_virt_gpu: Fix style issues
Reshuffle the import statements according to the suggestions from pylint,
use lowercase letters for variable names, and drop some spaces that flake8
did not like.

Message-Id: <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
2026-01-12 13:53:32 +01:00
Thomas Huth 28994ed156 tests/functional/ppc64/test_hv: Silence warnings reported by pylint
To make pylint happy here, remove unused variables, switch to f-string,
use "check=True" when calling subprocess.run() and split a line that was
too long.

Message-Id: <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
2026-01-12 13:53:32 +01:00
Thomas Huth 7aec77200b tests/functional/mips/test_malta: Silence warnings reported by pylint
Pylint complains about too many positional arguments for the
mips_check_wheezy() function. Add a "*" to enforce that the later
ones are passed with an argument name (all calling sites are doing
this already).

Also turn some old-school format strings into proper f-strings now.

Message-Id: <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
2026-01-12 13:53:32 +01:00
Thomas Huth 4e53727537 tests/functional: Add a pylintrc file
Add a pylintrc file that can be used for checking the python code of
the functional tests. For the beginning, we use some rather lax settings.
We still can refine them later if we think that there's a need for it.

Message-Id: <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
2026-01-12 13:53:32 +01:00
Fabiano Rosas f4e34d0fd5 tests/functional: Add a OS level migration test for pseries
There's currently no OS level test for ppc64le. Add one such test by
reusing the boot level tests that are already present.

The test boots the source machine, waits for it to reach a mid-boot
message, migrates and checks that the destination has reached the
final boot message (VFS error due to no disk).

Reviewed-by: Thomas Huth <[email protected]>
Signed-off-by: Fabiano Rosas <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Harsh Prateek Bora <[email protected]>
2026-01-12 15:34:04 +05:30
Fabiano Rosas 628bda1ab7 target/ppc: Fix env->quiesced migration
The commit referenced (from QEMU 10.0) has changed the way the pseries
machine marks a cpu as quiesced. Previously, the cpu->halted value
from QEMU common cpu code was (incorrectly) used. With the fix, the
env->quiesced variable starts being used, which improves on the
original situation, but also causes a side effect after migration:

The env->quiesced is set at reset and never migrated, which causes the
destination QEMU to stop delivering interrupts and hang the machine.

To fix the issue from this point on, start migrating the env->quiesced
value.

For QEMU versions < 10.0, sending the new element on the stream would
cause migration to be aborted, so add the appropriate compatibility
property to omit the new subsection.

Independently of this patch, all migrations from QEMU versions < 10.0
would result in a hang since the older QEMU never migrates
env->quiesced. This is bad because it leaves machines already running
on the old QEMU without a migration path into newer versions.

As a workaround, use a few heuristics to infer the new value of
env->quiesced based on cpu->halted, LPCR and PSSCR bits that are
usually set/cleared along with quiesced.

Note that this was tested with -cpu power9 and -machine ic-mode=xive
due to another bug affecting migration of XICS guests. Tested both
forward and backward migration and savevm/loadvm from 9.2 and 10.0.

Also tested loadvm of a savevm image that contains a mix of cpus both
halted and not halted.

Reported-by: Fabian Vogt <[email protected]>
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3079
Fixes: fb802acdc8 ("ppc/spapr: Fix RTAS stopped state")
Acked-by: Chinmay Rath <[email protected]>
Reviewed-by: Harsh Prateek Bora <[email protected]>
Signed-off-by: Fabiano Rosas <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Harsh Prateek Bora <[email protected]>
2026-01-12 15:33:07 +05:30
Bibo Mao 1a8d5e95d7 hw/loongarch/virt: Add property highmem-mmio-size with virt machine
The default high mmio size of GPEX PCIE host controller is 64G bytes on
virt machine. If it does not meet requirements with some pass-throught HW
devices in future, it can be adjust dynamically, here adds property
highmem-mmio-size to set high mmio size.

Signed-off-by: Bibo Mao <[email protected]>
Reviewed-by: Song Gao <[email protected]>
2026-01-12 14:58:01 +08:00
Bibo Mao d2ebf3570a hw/loongarch/virt: Add high MMIO support with GPEX host
With high MMIO supported, its base address comes from high end of
physical address space. Also add high MMIO support with GPEX host bridge.

Signed-off-by: Bibo Mao <[email protected]>
Reviewed-by: Song Gao <[email protected]>
2026-01-12 14:55:32 +08:00
Bibo Mao 2cb067f50f hw/loongarch/virt: Add property highmem_mmio with virt machine
On LoongArch Virt Machine, MMIO region with GPEX host bridge is
0x40000000 -- 0x7FFFFFFF. The total size is 1G bytes and it is enough
for emulated virtio devices basically.

However on some conditions such as hostmem is added with virtio-gpu
device, the command line is -device virtio-gpu-gl,hostmem=4G. The
PCIE MMIO region is not enough, 64-bit high MMIO region is required.

Here add property highmem_mmio with virt machine, however it brings
out incompatible issue. Here the default value is false.

Signed-off-by: Bibo Mao <[email protected]>
Reviewed-by: Song Gao <[email protected]>
2026-01-12 14:54:18 +08:00
Bibo Mao ecfd5c0bfc hw/loongarch/virt: Get PCI info from gpex config info
PCIE host bridge configuration information such as MMIO/Conf/IO base
and size can come from gpex config info.

Signed-off-by: Bibo Mao <[email protected]>
Reviewed-by: Song Gao <[email protected]>
2026-01-12 14:53:34 +08:00
Bibo Mao ecdd3751ad hw/loongarch/virt: Get irq number from gpex config info
The base irq number of GPEX PCIE host bridge can comes from gpex::irq.

Signed-off-by: Bibo Mao <[email protected]>
Reviewed-by: Song Gao <[email protected]>
2026-01-12 14:52:28 +08:00
Bibo Mao efee88883a hw/loongarch/virt: Add field gpex in LoongArchVirtMachineState
Add field gpex in structure LoongArchVirtMachineState, type of field gpex
is structure GPEXConfig and it is to record configuration information
about GPEX host bridge. And remove field pci_bus in structure
LoongArchVirtMachineState since the information is in field gpex already.

Signed-off-by: Bibo Mao <[email protected]>
Reviewed-by: Song Gao <[email protected]>
2026-01-12 14:51:30 +08:00
Bibo Mao 4150801bfd hw/loongarch/virt: Add field ram_end in LoongArchVirtMachineState
DRAM region is dynamically set and the last valid physical address region
with LoongArch Virt Machine. To record the last valid physical address,
field ram_end is added in structure LoongArchVirtMachineState. In future
end address of DRAM cannot exceed base addres of PCIE 64-bit MMIO region.

Signed-off-by: Bibo Mao <[email protected]>
Reviewed-by: Song Gao <[email protected]>
2026-01-12 14:49:21 +08:00
Bibo Mao f9870fe1ec target/loongarch: Add PMU register dump support in KVM
PMU is supported in KVM mode. With info registers command, PMU CSR
registers should be dumped also. And it is not necessary in TCG mode.

Signed-off-by: Bibo Mao <[email protected]>
Reviewed-by: Song Gao <[email protected]>
2026-01-12 14:44:38 +08:00
Bibo Mao 411b9496ca target/loongarch: Call function loongarch_la464_init_csr() after realized
When CPU is realized, it will check capability of host and set guest
features, such as PMU CSR register number used by VM etc. Here move
function call with loongarch_la464_init_csr() after CPU is realized.

Signed-off-by: Bibo Mao <[email protected]>
Reviewed-by: Song Gao <[email protected]>
2026-01-12 14:43:54 +08:00
Bibo Mao 7f93bcf696 target/loongarch: Add PMU migration support in KVM mode
PMU is supported in KVM mode. When VM is migrated, PMU register should
be migrated also, otherwise PMU will be disabled after migration.

Here add PMU register save and restore interface and PMU register
state migration is added also.

Signed-off-by: Bibo Mao <[email protected]>
Reviewed-by: Song Gao <[email protected]>
2026-01-12 14:43:06 +08:00
Caleb Schlossin 7edb81861d hw/ppc: Add VMSTATE information to PnvPsi
PnvPsi needs to be able to save/load snapshots.  Add VMSTATE information
to the device class and a post_load() method to restore dynamic data items and
memory region mappings.

Signed-off-by: Michael Kowal <[email protected]>
Reviewed-by: Michael Kowal <[email protected]>
Reviewed-by: Aditya Gupta <[email protected]>
Reviewed-by: Chalapathi V <[email protected]>
Signed-off-by: Caleb Schlossin <[email protected]>
Reviewed-by: Glenn Miles <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Harsh Prateek Bora <[email protected]>
2026-01-12 12:11:56 +05:30
Caleb Schlossin 3415bd5863 hw/ppc: pnv_chiptod.c add vmstate support
- Added pre_save and post_load methods to handle slave_pc_target and tod_state

Signed-off-by: Angelo Jaramillo <[email protected]>
Reviewed-by: Michael Kowal <[email protected]>
Reviewed-by: Aditya Gupta <[email protected]>
Reviewed-by: Chalapathi V <[email protected]>
Signed-off-by: Caleb Schlossin <[email protected]>
Reviewed-by: Glenn Miles <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Harsh Prateek Bora <[email protected]>
2026-01-12 12:11:47 +05:30
Caleb Schlossin abcc2aaa8f hw/ppc: pnv_core.c add vmstate support
- Add vmstate support PnvCore and PnvQuad capturing scratch
registers and special wakeup registers

Signed-off-by: Angelo Jaramillo <[email protected]>
Reviewed-by: Glenn Miles <[email protected]>
Reviewed-by: Aditya Gupta <[email protected]>
Reviewed-by: Chalapathi V <[email protected]>
Signed-off-by: Caleb Schlossin <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Harsh Prateek Bora <[email protected]>
2026-01-12 12:11:40 +05:30
Caleb Schlossin d1d37ce851 hw/ppc: pnv_adu.c added vmstate support
- Added vmstate support for ADU model

Signed-off-by: Angelo Jaramillo <[email protected]>
Reviewed-by: Michael Kowal <[email protected]>
Reviewed-by: Aditya Gupta <[email protected]>
Reviewed-by: Chalapathi V <[email protected]>
Signed-off-by: Caleb Schlossin <[email protected]>
Reviewed-by: Glenn Miles <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Harsh Prateek Bora <[email protected]>
2026-01-12 12:11:28 +05:30
Caleb Schlossin 39af40b3f4 hw/ppc: Add pnv_i2c vmstate support
- Add vmstate support for i2c registers

Reviewed-by: Michael Kowal <[email protected]>
Reviewed-by: Aditya Gupta <[email protected]>
Reviewed-by: Chalapathi V <[email protected]>
Signed-off-by: Caleb Schlossin <[email protected]>
Reviewed-by: Glenn Miles <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Harsh Prateek Bora <[email protected]>
2026-01-12 12:11:10 +05:30
Caleb Schlossin 555fd783ef hw/ppc: Add pnv_spi vmstate support
- Add support for needed PnvSpi structure variables

Reviewed-by: Michael Kowal <[email protected]>
Reviewed-by: Aditya Gupta <[email protected]>
Reviewed-by: Chalapathi V <[email protected]>
Signed-off-by: Caleb Schlossin <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Harsh Prateek Bora <[email protected]>
2026-01-12 12:11:02 +05:30
Caleb Schlossin ffc83d0ffd hw/ppc: Add VMSTATE information for LPC model
The PNV LPC model needs snapshot/migration support.  Added a VMSTATE
descriptor to save model data and an associated post_load() method.
Snapshot support added for Power8, Power9, and Power10.

Signed-off-by: Michael Kowal <[email protected]>
Reviewed-by: Michael Kowal <[email protected]>
Reviewed-by: Aditya Gupta <[email protected]>
Reviewed-by: Chalapathi V <[email protected]>
Signed-off-by: Caleb Schlossin <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Harsh Prateek Bora <[email protected]>
2026-01-12 12:10:34 +05:30
Gautam Menghani e3c062a4b9 target/ppc/kvm : Use macro names instead of hardcoded constants as return values
In the parse_* functions used to parse the return values of
KVM_PPC_GET_CPU_CHAR ioctl, the return values are hardcoded as numbers.
Use the macro names for better readability. No functional change
intended.

Signed-off-by: Gautam Menghani <[email protected]>
Reviewed-by: Chinmay Rath <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Harsh Prateek Bora <[email protected]>
2026-01-12 11:58:51 +05:30
Richard Henderson 18c38476de Merge tag 'pull-tcg-20260112' of https://gitlab.com/rth7680/qemu into staging
tcg/riscv: Fix TCG_REG_TMP0 clobber in tcg_gen_dup{m,i}
tcg/optimize: Fixes for o_mask and a_mask
linux-user: Correction to HWCAP2 accessor
linux-user: Fixes for mremap
linux-user: Implement epoll_pwait2 syscall
meson: disable libatomic with GCC >= 16

# -----BEGIN PGP SIGNATURE-----
#
# iQFRBAABCgA7FiEEekgeeIaLTbaoWgXAZN846K9+IV8FAmlkHJQdHHJpY2hhcmQu
# aGVuZGVyc29uQGxpbmFyby5vcmcACgkQZN846K9+IV8i0gf8C/MTPjEqPDij3WDA
# skE6cNyWaGF1xw8WDrGfC9GkKndBtWKZ/bZi8JmngcqfOkOzkZa5X8D25W0/esOs
# cnjqsGX3blW1YUTXgs/Go/EZguZnO23I/4/2sFdba6lo2zYmwab8HzJjYLhzRZB2
# fFyLVvVDgkCfbpomkuZM7nHlnqP1UXgxkYtdD9hhs/08Mdv/H5BwwZN/xkC+YSwt
# zLfB9fb2/5rf3u+TlUoQsHkDV7hHcAiCwUpL9W89AGTVtuwAd2K+LObebaxk8ExM
# WDSXl5CJsavdGZ7sYUqBlJBnHYdSUqMu3DvghQdn5mC1QuRVelLWJhYkNuWVLMsD
# DyH4GQ==
# =yWGs
# -----END PGP SIGNATURE-----
# gpg: Signature made Mon 12 Jan 2026 08:56:36 AM AEDT
# gpg:                using RSA key 7A481E78868B4DB6A85A05C064DF38E8AF7E215F
# gpg:                issuer "[email protected]"
# gpg: Good signature from "Richard Henderson <[email protected]>" [ultimate]

* tag 'pull-tcg-20260112' of https://gitlab.com/rth7680/qemu:
  meson: disable libatomic with GCC >= 16
  linux-user: implement epoll_pwait2 syscall
  linux-user: cleanup epoll_pwait ifdeff'ery
  tests: add tcg coverage for fixed mremap bugs
  linux-user: fix reserved_va page leak in do_munmap
  linux-user: fix mremap errors for invalid ranges
  linux-user: fix mremap unmapping adjacent region
  linux-user/elfload.c: Correction to HWCAP2 accessor
  linux-user: allow null `pathname` for statx()/fstatat()
  tcg/riscv: Fix TCG_REG_TMP0 clobber in tcg_gen_dup{m,i}
  tcg/optimize: Do use affected bits
  tcg/optimize: Fix a_mask computation for orc
  tcg/optimize: Save o_mask in fold_masks_zosa_int

Signed-off-by: Richard Henderson <[email protected]>
2026-01-12 09:00:22 +11:00
Daniel P. Berrangé 365a2248ae meson: disable libatomic with GCC >= 16
Historically it was required to ask for libatomic explicitly with
-latomic, but with GCC >= 16 apps will get linked to libatomic
whether they ask for it or not.

This invalidates QEMU's check for atomic op support for int128
which explicitly does NOT want to use the libatomic impl. As a
result with GCC >= 16, QEMU is now getting linked to libatomic
and is activating CONFIG_ATOMIC128. This in turn exposes a bug
in GCC's libatomic.a static buld which is incompatible with the
use of -static-pie leading to build failures like:

    /usr/bin/ld: /usr/lib/gcc/x86_64-redhat-linux/16/libatomic.a(cas_16_.o): relocation R_X86_64_32 against hidden symbol `libat_compare_exchange_16_i1' can not be used when making a PIE object
    /usr/bin/ld: failed to set dynamic section sizes: bad value
collect2: error: ld returned 1 exit status

The newly introduced -fno-link-libatomic flag can be used to
disable the new automatic linking of libatomic. Setting this in
qemu_isa_flags early on ensures that the check for CONFIG_ATOMIC128
still works correctly.

Signed-off-by: Daniel P. Berrangé <[email protected]>
Acked-by: Paolo Bonzini <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-01-12 08:49:33 +11:00
Michael Tokarev a19fe4d377 linux-user: implement epoll_pwait2 syscall
epoll_pwait2 is the same as epoll_pwait but with timeout being
(a pointer to) struct timespec instead of an integer.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3210
Signed-off-by: Michael Tokarev <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-01-12 08:49:33 +11:00
Michael Tokarev 429bc03a8e linux-user: cleanup epoll_pwait ifdeff'ery
All linux targets these days have epoll_pwait system call
(while some miss epoll_wait, which is less generic).  And
all linux targets definitely has one or another epoll_*wait*
system call - so whole code block dealing with this system
call should always be present.

Remove the now-unneeded ifdef'fery.

Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Michael Tokarev <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-01-12 08:49:33 +11:00
Matthew Lugg 9290c10ae9 tests: add tcg coverage for fixed mremap bugs
These tests cover the first two fixes in this patch series. The final
patch is not covered because the bug it fixes is not easily observable
by the guest.

Signed-off-by: Matthew Lugg <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-01-12 08:49:33 +11:00
Matthew Lugg 81ceab3049 linux-user: fix reserved_va page leak in do_munmap
The old logic had an off-by-one bug. For instance, assuming 4k pages on
host and guest, if 'len' is '4097' (indicating to unmap 2 pages), then
'last = start + 4096', so 'real_last = start + 4095', so ultimately
'real_len = 4096'. I do not believe this could cause any observable bugs
in guests, because `target_munmap` page-aligns the length it passes in.
However, calls to this function in `target_mremap` do not page-align the
length, so those calls could "drop" pages, leading to a part of the
reserved region becoming unmapped. At worst, a host allocation could get
mapped into that hole, then clobbered by a new guest mapping.

Signed-off-by: Matthew Lugg <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-01-12 08:49:33 +11:00
Matthew Lugg 2422884ec5 linux-user: fix mremap errors for invalid ranges
If an address range given to `mremap` is invalid (exceeds addressing
bounds on the guest), we were previously returning `ENOMEM`, which is
not correct. The manpage and the Linux kernel implementation both agree
that if `old_addr`/`old_size` refer to an invalid address, `EFAULT` is
returned, and if `new_addr`/`new_size` refer to an invalid address,
`EINVAL` is returned.

Signed-off-by: Matthew Lugg <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-01-12 08:49:33 +11:00
Matthew Lugg aaed9ca179 linux-user: fix mremap unmapping adjacent region
This typo meant that calls to `mremap` which shrink a mapping by some N
bytes would, when the virtual address space was pre-reserved (e.g.
32-bit guest on 64-bit host), unmap the N bytes following the *original*
mapping.

Signed-off-by: Matthew Lugg <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-01-12 08:49:33 +11:00
Jim MacArthur c333f9c4ee linux-user/elfload.c: Correction to HWCAP2 accessor
get_elf_hwcap was used when get_elf_hwcap2 should have been.

Cc: [email protected]
Fixes: fcac98d0ba ("linux-user: Remove ELF_HWCAP2")
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3259
Signed-off-by: Jim MacArthur <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-01-12 08:49:33 +11:00
Jean-Christian CÎRSTEA 82ae60c8b5 linux-user: allow null pathname for statx()/fstatat()
Since Linux 6.11, the path argument may be NULL.

Before this patch, qemu-*-linux-user failed with EFAULT when `pathname` was
specified as NULL, even for Linux kernel hosts > 6.10. This patch fixes this
issue by checking whether `arg2` is 0. If so, don't return EFAULT, but instead
perform the appropiate syscall and let the host's kernel handle null `pathname`.

Cc: [email protected]
Signed-off-by: Jean-Christian CÎRSTEA <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-01-12 08:49:33 +11:00
Richard Henderson af6db3b713 tcg/riscv: Fix TCG_REG_TMP0 clobber in tcg_gen_dup{m,i}
TCG_REG_TMP0 may be used by set_vtype* to load the vtype
parameter, so delay any other use of TCG_REG_TMP0 until
the correct vtype has been installed.

Cc: [email protected]
Fixes: d4be6ee111 ("tcg/riscv: Implement vector mov/dup{m/i}")
Reported-by: Zhijin Zeng <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
2026-01-12 08:49:33 +11:00
Paolo Bonzini 23b53ec3a8 tcg/optimize: Do use affected bits
We inadvertently disabled affected bits optimizations on operations
that use fold_masks_zosa.  These happen relatively often in x86 code
for extract/sextract; for example given the following:

   mov %esi, %ebp
   xor $0x1, %ebp

the optimizer is able to simplify the "extract_i64 rbp,tmp0,$0x0,$0x20"
produced by the second instruction to a move.

Cc: [email protected]
Fixes: 932522a9dd ("tcg/optimize: Fold and to extract during optimize")
Signed-off-by: Paolo Bonzini <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
2026-01-12 08:49:33 +11:00
Richard Henderson 08b12bfb8f tcg/optimize: Fix a_mask computation for orc
In computing a_mask, for or, we remove the bits from t1->o_mask
which are known to be zero.  For orc, the bits known to be zero
are the inverse of those known to be one.

Cc: [email protected]
Fixes: cc4033ee47 ("tcg/optimize: Build and use zero, one and affected bits in fold_orc")
Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
2026-01-12 08:49:21 +11:00
Richard Henderson 7d2d577de0 tcg/optimize: Save o_mask in fold_masks_zosa_int
When adding o_mask to this function, we used it in a
couple of places but failed to save it for future use.
Also, update a related comment.

Cc: [email protected]
Fixes: 56f15f67ea ("tcg/optimize: Add one's mask to TempOptInfo")
Reported-by: Manos Pitsidianakis <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
2026-01-11 17:31:34 +11:00
Richard Henderson b254e48624 Merge tag 'pull-riscv-to-apply-20260109' of https://github.com/alistair23/qemu into staging
First RISC-V PR for 11.

* Remove unused import statement from sifive_u test
* Free allocated memory in core/loader
* Add all available CSRs to 'info registers'
* Add 'riscv-aia' accel prop info to documentation
* Fix IOMMU MemoryRegion owner
* Make riscv cpu.h target partially independent
* Expand AIA target[i] source handling and refactor related code
* Don't look up DDT cache in Off and Bare modes
* Add Zilsd and Zclsd extension support
* Add RISCV ZALASR extension
* Add support for MIPS P8700 CPU

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCgAdFiEEaukCtqfKh31tZZKWr3yVEwxTgBMFAmlgmt8ACgkQr3yVEwxT
# gBMxsRAAsdrRs8jrvjJqA60vt6Q/YZRCZFTeRfGlq92zVV4cmkUIkZdCESQsbToV
# lGmbdLXXeC8huxh27zjQuoO9JZzPlg6tBzxCpuNXnrTQB57UKjLJoQ4rKJ9F6wT+
# iakZ3ky6iN9N64p1lDRwfph7hjxodb6Vxgi/iBTsWdj1p4OsJgL2kOPSVBZLdkoL
# fTngoy0bmnV83o2eXIBx09YMxCaT3zjrhIf5lZ3zIeML8wJiq9RKUTs9pDlVO5Z1
# UEeBC8SHNj6siZ5EkCk3IQf7hIq77UITR4wHMQmNLqXY25pSexzqgAKiQt5bbU38
# VyUcXZglXKyvWDPLR36kKQeSSQFaToyVYmw2pr4oZXtEwAUrh8KqprlL+o/V1kFk
# 726i03xtqpPn/HN49kzvfOatlq5qUkeLPWI5RN/q9jjE4RdNxPeSBeyy47yNoR6t
# i9jPV+Z9XhNk7OpTmFKyEEBrf2cyGBubddpDgjDlzBohaICk24pIZgUpHs5WyIkF
# 8/mz9nruUHNXYwasQ5zjHoEaNfoCAgmAMY8klNK6t7Ty5AhT5x0c/5c5WxJ4L0BC
# z0WMZrK4r3uoFeXxRqQZnaWxx0ySCQkPyCuRNGqCx8J/bFhx9VUz5xgR1fZpkfNG
# NdDCueZI3mtdULz2JFe+wwan5XPapEKArFW0RQdR4QYBHiZTrpE=
# =gVkC
# -----END PGP SIGNATURE-----
# gpg: Signature made Fri 09 Jan 2026 05:06:23 PM AEDT
# gpg:                using RSA key 6AE902B6A7CA877D6D659296AF7C95130C538013
# gpg: Good signature from "Alistair Francis <[email protected]>" [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: 6AE9 02B6 A7CA 877D 6D65  9296 AF7C 9513 0C53 8013

* tag 'pull-riscv-to-apply-20260109' of https://github.com/alistair23/qemu: (34 commits)
  test/functional: Add test for boston-aia board
  riscv/boston-aia: Add an e1000e NIC in slot 0 func 1
  hw/riscv: Add support for MIPS Boston-aia board mode
  hw/riscv: Add support for RISCV CPS
  hw/misc: Add RISC-V CPC device implementation
  hw/misc: Add RISC-V CMGCR device implementation
  target/riscv: Add Xmipslsp instructions
  target/riscv: Add mips.pref instruction
  target/riscv: Add mips.ccmov instruction
  target/riscv: Add MIPS P8700 CSRs
  target/riscv: Add MIPS P8700 CPU
  target/riscv: Add cpu_set_exception_base
  Add RISCV ZALASR extension
  target/riscv: Add Zilsd and Zclsd extension support
  hw/riscv: riscv-iommu: Don't look up DDT cache in Off and Bare modes
  hw/intc/riscv_aplic: Factor out source_active() and remove duplicate checks
  hw/intc/riscv_aplic: Expand inactive source handling for AIA target[i]
  target/riscv: Remove upper_half from riscv_pmu_ctr_get_fixed_counters_val
  target/riscv: Combine mhpmcounter and mhpmcounterh
  target/riscv: Combine minstretcfg and minstretcfgh
  ...

Signed-off-by: Richard Henderson <[email protected]>
2026-01-10 10:31:57 +11:00
Djordje Todorovic e71111e26b test/functional: Add test for boston-aia board
Add functional test for Boston AIA board. The P8700 RISC-V based
CPU by MIPS supports it at the moment.

Signed-off-by: Chao-ying Fu <[email protected]>
Signed-off-by: Djordje Todorovic <[email protected]>
Acked-by: Alistair Francis <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
2026-01-09 15:14:58 +10:00
Djordje Todorovic 94081c10af riscv/boston-aia: Add an e1000e NIC in slot 0 func 1
The Boston AIA board needs a basic GbE NIC.  There is no PCH GbE
device emulation, so use an `e1000e` instead.  We place it in
**slot 0, function 1** in order not to conflict with the existing
AHCI device in slot 0 func 0.

Signed-off-by: Chao-ying Fu <[email protected]>
Signed-off-by: Djordje Todorovic <[email protected]>
Reviewed-by: Daniel Henrique Barboza <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
2026-01-09 15:13:55 +10:00
Djordje Todorovic 2264f637da hw/riscv: Add support for MIPS Boston-aia board mode
The board model supports up to 64 harts with MIPS CPS, MIPS GCR,
MIPS CPC, AIA plic, and AIA clint devices. The model can create
boot code, if there is no -bios parameter. We can specify -smp x,
cores=y,thread=z.
Ex: Use 4 cores and 2 threads with each core to
have 8 smp cpus as follows.
  qemu-system-riscv64 -cpu mips-p8700 \
  -m 2G -M boston-aia \
  -smp 8,cores=4,threads=2 -kernel fw_payload.bin \
  -drive file=rootfs.ext2,format=raw -serial stdio

Signed-off-by: Chao-ying Fu <[email protected]>
Signed-off-by: Djordje Todorovic <[email protected]>
Acked-by: Daniel Henrique Barboza <[email protected]>
Acked-by: Alistair Francis <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
2026-01-09 15:13:53 +10:00
Djordje Todorovic 12eda1a6aa hw/riscv: Add support for RISCV CPS
Add support for the Coherent Processing System for RISC-V.
This enables SMP support for RISC-V boards that require
cache-coherent multiprocessor systems.

Signed-off-by: Chao-ying Fu <[email protected]>
Signed-off-by: Djordje Todorovic <[email protected]>
Acked-by: Daniel Henrique Barboza <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
2026-01-09 15:13:20 +10:00
Djordje Todorovic 0cf4a87966 hw/misc: Add RISC-V CPC device implementation
Add RISC-V implementation of the Cluster Power Controller (CPC) device.
It is based on the existing MIPS CPC implementations but adapted for
RISC-V systems.

The CPC device manages power control for CPU clusters in RISC-V
systems.

This is needed for the MIPS BOSTON AIA board.

Signed-off-by: Chao-ying Fu <[email protected]>
Signed-off-by: Djordje Todorovic <[email protected]>
Reviewed-by: Daniel Henrique Barboza <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
2026-01-09 15:12:48 +10:00
Djordje Todorovic 290a1f174e hw/misc: Add RISC-V CMGCR device implementation
Add RISC-V implementation of the Coherent Manager Global Control
Register (CMGCR) device. It is based on the existing MIPS CMGCR
implementation but adapted for RISC-V systems.

The CMGCR device provides global system control for multi-core
configurations in RISC-V systems.

This is needed for the MIPS BOSTON AIA board.

Signed-off-by: Chao-ying Fu <[email protected]>
Signed-off-by: Djordje Todorovic <[email protected]>
Reviewed-by: Daniel Henrique Barboza <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
2026-01-09 15:12:15 +10:00
Djordje Todorovic 84635b9396 target/riscv: Add Xmipslsp instructions
Add MIPS P8700 ldp, lwp, sdp, swp instructions.

Signed-off-by: Chao-ying Fu <[email protected]>
Signed-off-by: Djordje Todorovic <[email protected]>
Acked-by: Daniel Henrique Barboza <[email protected]>
Acked-by: Alistair Francis <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
2026-01-09 15:11:43 +10:00
Djordje Todorovic 0bc1d40977 target/riscv: Add mips.pref instruction
Add MIPS P8700 prefetch instruction defined by Xmipscbop.

Signed-off-by: Chao-ying Fu <[email protected]>
Signed-off-by: Djordje Todorovic <[email protected]>
Reviewed-by: Daniel Henrique Barboza <[email protected]>
Acked-by: Alistair Francis <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
2026-01-09 15:11:28 +10:00
Djordje Todorovic 2d9f941085 target/riscv: Add mips.ccmov instruction
Add mips.ccmov defined by Xmipscmov.

Signed-off-by: Chao-ying Fu <[email protected]>
Signed-off-by: Djordje Todorovic <[email protected]>
Acked-by: Daniel Henrique Barboza <[email protected]>
Acked-by: Alistair Francis <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
2026-01-09 15:11:13 +10:00
Djordje Todorovic dfe2b6fa76 target/riscv: Add MIPS P8700 CSRs
Define MIPS CSRs used for P8700 CPU.

Signed-off-by: Chao-ying Fu <[email protected]>
Signed-off-by: Djordje Todorovic <[email protected]>
Reviewed-by: Daniel Henrique Barboza <[email protected]>
Reviewed-by: Alistair Francis <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
2026-01-09 15:10:46 +10:00
Djordje Todorovic 38e63ea61a target/riscv: Add MIPS P8700 CPU
Introduce P8700 CPU by MIPS.

Signed-off-by: Chao-ying Fu <[email protected]>
Signed-off-by: Djordje Todorovic <[email protected]>
Reviewed-by: Daniel Henrique Barboza <[email protected]>
Reviewed-by: Alistair Francis <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
2026-01-09 15:10:19 +10:00
Djordje Todorovic 209c2c9af6 target/riscv: Add cpu_set_exception_base
Add a new function, so we can change reset vector from platforms
during runtime.

Signed-off-by: Chao-ying Fu <[email protected]>
Signed-off-by: Djordje Todorovic <[email protected]>
Reviewed-by: Daniel Henrique Barboza <[email protected]>
Reviewed-by: Alistair Francis <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
2026-01-09 15:10:04 +10:00
Roan Richmond 26154585c6 Add RISCV ZALASR extension
This is based on version v0.9 of the ZALASR specification [1].
The specification is listed as in Ratified state [2].

[1]: https://github.com/riscv/riscv-zalasr/tree/v0.9
[2]: https://lf-riscv.atlassian.net/wiki/spaces/HOME/pages/16154882/All+RISC-V+Specifications+Under+Active+Development

Reviewed-by: Alistair Francis <[email protected]>
Signed-off-by: Roan Richmond <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
2026-01-09 15:09:49 +10:00
lxx 4975960510 target/riscv: Add Zilsd and Zclsd extension support
This patch adds support for the Zilsd and Zclsd extension,
which is documented at https://github.com/riscv/riscv-zilsd/releases/tag/v1.0

Signed-off-by: LIU Xu <[email protected]>
Co-developed-by: SUN Dongya <[email protected]>
Co-developed-by: ZHAO Fujin <[email protected]>
Reviewed-by: Alistair Francis <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
2026-01-09 15:01:10 +10:00
Frank Chang 15406cc593 hw/riscv: riscv-iommu: Don't look up DDT cache in Off and Bare modes
According to the RISC-V IOMMU specification:

* When ddtp.iommu_mode is set to Off, there is no DDT look-up, and an "All
  inbound transactions disallowed" fault (cause = 256) is reported for any
  inbound transaction.

* When ddtp.iommu_mode is set to Bare, there is no DDT look-up, and the
  translated address is the same as the IOVA, unless the transaction type
  is disallowed (cause = 260).

In the current implementation, the DDT cache is incorrectly looked up
even when ddtp.iommu_mode is set to Off or Bare. This may result in
unintended cache hits.

Therefore, the DDT cache must not be looked up when ddtp.iommu_mode is
set to Off or Bare. For other modes, software is required to issue cache
invalidation commands before any inbound transactions.

Signed-off-by: Frank Chang <[email protected]>
Acked-by: Alistair Francis <[email protected]>
Reviewed-by: Daniel Henrique Barboza <[email protected]>
Reviewed-by: Jim Shu <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
2026-01-09 15:01:10 +10:00
Nikita Novikov b88df15592 hw/intc/riscv_aplic: Factor out source_active() and remove duplicate checks
Refactor the APLIC code to consolidate repeated conditions checking
whether an interrupt source is valid, delegated, or inactive.

Signed-off-by: Nikita Novikov <[email protected]>
Reviewed-by: Alistair Francis <[email protected]>
Reviewed-by: Daniel Henrique Barboza <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
2026-01-09 15:01:10 +10:00
Nikita Novikov 7c96dbdda8 hw/intc/riscv_aplic: Expand inactive source handling for AIA target[i]
According to the RISC-V AIA v1.0, section 4.5.2 ("Source configurations"),
register target[i] shall be read-only zero when interrupt source i is inactive
in this domain. A source is inactive if it is delegated to a child domain or
its source mode is INACTIVE.

The previous implementation only checked SM == INACTIVE. This patch adds
full compliance:
- Return zero on read if D == 1 or SM == INACTIVE
- Ignore writes in both cases

Fixes: b6f1244678 ("intc/riscv_aplic: Fix target register read when source is inactive")
Signed-off-by: Nikita Novikov <[email protected]>
Acked-by: Alistair Francis <[email protected]>
Reviewed-by: Daniel Henrique Barboza <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
2026-01-09 15:01:10 +10:00
Alistair Francis cfc96df65e target/riscv: Remove upper_half from riscv_pmu_ctr_get_fixed_counters_val
Now that mhpmcounter is always a 64-bit value we can remove the
upper_half argument from riscv_pmu_ctr_get_fixed_counters_val() and
always return a 64-bit value.

Signed-off-by: Alistair Francis <[email protected]>
Reviewed-by: Anton Johansson <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
2026-01-09 15:01:10 +10:00
Anton Johansson 4fe8ae0906 target/riscv: Combine mhpmcounter and mhpmcounterh
According to version 20250508 of the privileged specification,
mhpmconter is a 64-bit register and mhpmcounterh refers to the top
32 bits of this register when XLEN == 32.  No real advantage is
gained by keeping them separate, and combining allows for slight
simplification.

Note, the cpu/pmu VMSTATE version is bumped breaking migration from
older versions.

Signed-off-by: Anton Johansson <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Alistair Francis <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
2026-01-09 15:01:10 +10:00
Anton Johansson bb951e47f9 target/riscv: Combine minstretcfg and minstretcfgh
According to version 20250508 of the privileged specification,
minstretcfg is a 64-bit register and minstretcfgh refers to the top
32 bits of this register when XLEN == 32.  No real advantage is
gained by keeping them separate, and combining them allows for slight
simplification.

Signed-off-by: Anton Johansson <[email protected]>
Reviewed-by: Alistair Francis <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
2026-01-09 15:01:09 +10:00
Anton Johansson 6c07ca842b target/riscv: Combine mcyclecfg and mcyclecfgh
According to version 20250508 of the privileged specification, mcyclecfg
is a 64-bit register and mcyclecfgh refers to the top 32 bits of this
register when XLEN == 32.  No real advantage is gained by keeping
them separate, and combining them allows for slight simplification.

Signed-off-by: Anton Johansson <[email protected]>
Reviewed-by: Alistair Francis <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
2026-01-09 15:01:09 +10:00
Anton Johansson c9efdb7b63 target/riscv: Combine mhpmevent and mhpmeventh
According to version 20250508 of the privileged specification,
mhpmeventn is 64 bits in size and mhpmeventnh is only ever used
when XLEN == 32 and accesses the top 32 bits of the 64-bit
mhpmeventn registers. Combine the two arrays of target_ulong
mhpmeventh[] and mhpmevent[] to a single array of uint64_t.

This also allows for some minor code simplification where branches
handling either mhpmeventh[] or mhpmevent[] could be combined.

Signed-off-by: Anton Johansson <[email protected]>
Reviewed-by: Alistair Francis <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
2026-01-09 15:01:09 +10:00
Anton Johansson d9fa41e101 target/riscv: Bugfix make bit 62 read-only 0 for sireg* cfg CSR read
According to version 20250508 of the privileged specification, a read of
cyclecfg or instretcfg through sireg* should make the MINH bit
read-only 0, currently bit 30 is zeroed.

Signed-off-by: Anton Johansson <[email protected]>
Reviewed-by: Alistair Francis <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
2026-01-09 15:01:09 +10:00
Anton Johansson bd008558d2 target/riscv: Fix size of mhartid
and update formatting in log.

Signed-off-by: Anton Johansson <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Alistair Francis <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
2026-01-09 15:01:09 +10:00
Anton Johansson 740021e278 target/riscv: Fix size of trivial CPUArchState fields
This commits groups together all CPUArchState fields whose behaviour can
be retained by simply changing the size of the field.

Note, senvcfg is defined to be SXLEN bits wide, but is widened to 64
bits to match henvcfg and menvcfg.  Next, [m|h]edeleg are changed to
64 bits as defined privileged specification, and hvictl is fixed to 32
bits which holds all relevant values, see HVICTL_VALID_MASK.  The
remaining fields touched in the commit are widened from [H|S|M]XLEN
to 64-bit.

Note, the cpu/hyper, cpu/envcfg, cpu/jvt, and cpu VMSTATE versions are
bumped, breaking migration from older versions.

References to the privileged/unprivileged RISCV specification refer to
version 20250508.

Signed-off-by: Anton Johansson <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Alistair Francis <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
2026-01-09 15:01:09 +10:00
Akihiko Odaki c497ef6739 hw/riscv/riscv-iommu: Fix MemoryRegion owner
as points to the MemoryRegion itself. s is the device that owns the
MemoryRegion.

Signed-off-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Reviewed-by: Daniel Henrique Barboza <[email protected]>
Reviewed-by: Nutty Liu <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected].i.u-tokyo.ac.jp>
Signed-off-by: Alistair Francis <[email protected]>
2026-01-09 15:01:09 +10:00
Daniel Henrique Barboza 7e89ab5eab docs/specs/riscv-aia.rst: add 'riscv-aia' accel prop info
Add a small section talking about the 'riscv-aia' KVM setting we
implement and how it affects the provisioning of the IMSIC s-mode
in-kernel controller.

While we're at it, fix the formatting of the AIA bullet list.

Signed-off-by: Daniel Henrique Barboza <[email protected]>
Acked-by: Alistair Francis <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
2026-01-09 15:01:09 +10:00
Daniel Henrique Barboza 354c16c69f target/riscv: print all available CSRs in riscv_cpu_dump_state()
At this moment we're printing a small selection of CSRs. There's no
particular reason to not print all of them.

We're ignoring the note about CSR_SSTATUS being ommited because it can
be read via CSR_MSTATUS. There's a huge list of CSRs that would fall in
this category and it would be an extra burden to manage them, not
mentioning having to document "we're not listing X because it's the same
value as Y" to users.

Remove 'dump_csrs' and use the existing 'csr_ops' array to print all
available CSRs. Create two helpers in csr.c to identify FPU and VPU CSRs
and skip them - they'll be printed in the FPU/VPU blocks later.

Signed-off-by: Daniel Henrique Barboza <[email protected]>
Reviewed-by: Alistair Francis <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
2026-01-09 15:01:09 +10:00
Daniel Henrique Barboza 8e35971a56 target/riscv/cpu: print all FPU CSRs in riscv_cpu_dump_state()
We're missing fflags and frm.

Signed-off-by: Daniel Henrique Barboza <[email protected]>
Reviewed-by: Alistair Francis <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
2026-01-09 15:01:09 +10:00
Daniel Henrique Barboza c10187b12d target/riscv/cpu: add riscv_dump_csr() helper
riscv_cpu_dump_state() is using the same pattern to print a CSR given
its number. Add a helper to avoid code repetition.

While we're at it fix the identation of the 'flags & CPU_DUMP_VPU'
block.

Signed-off-by: Daniel Henrique Barboza <[email protected]>
Reviewed-by: Alistair Francis <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
2026-01-09 15:01:09 +10:00
Alistair Francis de0a5b1fbd hw/core/loader: Free the allocated string from size_to_str()
The string needs be be freed with g_free() according to the functions
documentation.

Coverity: CID 1642762
Fixes: f62226f7dc ("hw/core/loader: improve error handling in image loading functions")
Signed-off-by: Alistair Francis <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
2026-01-09 15:01:09 +10:00
Alistair Francis 98d3546f01 hw/core/loader: Free the image file descriptor on error
Coverity: CID 1642764
Fixes: f62226f7dc ("hw/core/loader: improve error handling in image loading functions")
Signed-off-by: Alistair Francis <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Vishal Chourasia <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
2026-01-09 15:01:09 +10:00
Alistair Francis 044bc505b1 hw/core/loader: Fixup whitespace for get_image_size()
Signed-off-by: Alistair Francis <[email protected]>
Reviewed-by:Vishal Chourasia <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
2026-01-09 15:01:09 +10:00
Thomas Huth b619c41593 tests/functional/riscv64/test_sifive_u: Remove unused import statement
skipIfMissingCommands is not used here, remove the import to silence
a pylint warning for this file.

Signed-off-by: Thomas Huth <[email protected]>
Reviewed-by: Alistair Francis <[email protected]>
Reviewed-by: Daniel Henrique Barboza <[email protected]>
Reviewed-by: Nutty Liu <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
2026-01-09 15:01:09 +10:00
Richard Henderson 146dcea03e Merge tag 'pull-maintainers-2026-01-08' of https://repo.or.cz/qemu/armbru into staging
MAINTAINERS patches for 2026-01-08

# -----BEGIN PGP SIGNATURE-----
#
# iQJGBAABCgAwFiEENUvIs9frKmtoZ05fOHC0AOuRhlMFAmlfcIUSHGFybWJydUBy
# ZWRoYXQuY29tAAoJEDhwtADrkYZTv3YQAJGXEh1vqIZsEIRfPlOFPQWSfXUCbchX
# aiHYiWieMLJsNdP9jj+vxAz0agCURqbipqIAOJF21FfrSi8sC1T0g6bW7Bo8DFhn
# SP+LWHv+dqUds1Tb+GKk2qiU/g+giXCJ01paj2VuNzo3e5Aitj/l5uxVdXnCLZGy
# FwdchNPJBl2H9IO6J+OF1D7u4SKlIZncRyyyosaRGxVdKlF5hhIz8PypW/xw2kf2
# aCgHVldcij2ZXZSRuxGhyUsKtldGHNTEZFE/pQf30xhg30PlPA4crZuS3I/dlaQ4
# Nhx62ahQaZsG/D/jLvqUtOHKM7zFToLMSdvV5VKioxkgcf16VJ2RNf9OWgkWjUHz
# uBQgJJUFEF3gjE5DV1bEAQYDtp7xv0vOyUphkE6EJf7eAiIF4+vy6HvFpK7v1fpQ
# Bkd36FkL2uuFpDNk7fxFhcKbxEOreGjQOQoowhByLoCY/MuSro6NFvEh8Jtcid8L
# 2ju5+yCcLiZv3UXRTQ5uffi4CKzsjAGVSq2odqz7Xo6N0RGCQGp/NfrmumJEqM0k
# JSn/hxsn9kpKsi9WvwM5kpsDt7d45vjVF3VfiI5pZpoyOQPjud+1jdUR30BmuyGy
# CJ1Z+v6afnwTAh1KdYb8d7RNo1JOBnNWOFenmAzhevL3+sYthlS5LsK5iblMJr1e
# 3oiFTiACHbiO
# =kYKn
# -----END PGP SIGNATURE-----
# gpg: Signature made Thu 08 Jan 2026 07:53:25 PM AEDT
# gpg:                using RSA key 354BC8B3D7EB2A6B68674E5F3870B400EB918653
# gpg:                issuer "[email protected]"
# gpg: Good signature from "Markus Armbruster <[email protected]>" [unknown]
# gpg:                 aka "Markus Armbruster <[email protected]>" [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: 354B C8B3 D7EB 2A6B 6867  4E5F 3870 B400 EB91 8653

* tag 'pull-maintainers-2026-01-08' of https://repo.or.cz/qemu/armbru:
  MAINTAINERS: Add MAX78000FTHR section as orphan
  MAINTAINERS: Add EEPROM 93xx section
  MAINTAINERS: Fix coverage of meson.build in tests/functional
  MAINTAINERS: Fix coverage of tests/functional/acpi-bits/

Signed-off-by: Richard Henderson <[email protected]>
2026-01-08 21:18:22 +11:00
Richard Henderson fa59d71d57 Merge tag 'pull-error-2026-01-07-v2' of https://repo.or.cz/qemu/armbru into staging
Error reporting patches for 2026-01-07

# -----BEGIN PGP SIGNATURE-----
#
# iQJGBAABCgAwFiEENUvIs9frKmtoZ05fOHC0AOuRhlMFAmlfU/wSHGFybWJydUBy
# ZWRoYXQuY29tAAoJEDhwtADrkYZToiUP/RW1I1wFyescGOpUxBjlXqbkgZvrdRbL
# BxtTcoCW0q/cc1Fv3CSYZMm+vvwWJyAysnYONDu6ldDl9ojKfGT/gi1Tgp/99/r4
# bgLbAvExRbbyPOkPBtoXCYeobmgaDP9pMHHlVcdFQrW9hmQiEl4QSWPImmNrKEk2
# gV9SZJ737k9n5dq4XLbqlHXKspn4lWiUE9hbHIUrKWZDn0LDdr5z2wkjhZCmuCR2
# mRSgJhc68Lnb1LdBdRo/5PlG6Hw3jvLat4+q+42teN/aI6zJbD9yKocgaGtubVv1
# h4ntJPMvDKD7DRZF06k8crpLMXJjZFztVr30XBE/e7wG+xY34+3tho3iCQN1vTFe
# RBJne0FaRPGSNYpF8Tj7lPIr0kduqk3/lOQ9HPobTroIPTrCcRXbdOeQ/Ed/Cjrk
# suh8t4OGmy0ThcsUsAajSjPDw2aFlitCS4pWNaSctTvR7V+2trol+WS2QO4My0MX
# 4Z3BnOHBnhE/xo+22T4FW3NvNcFKsQ5Tlq6mjjAgFJ/guaJ2TbMFe/Pm9TtzcPHj
# 7mhBBvKStNWFrQz66z7+hxJhOuOEmON8i4coADDPTUWmcICCyjtJW5m5f+PoYYHr
# LpFwIFHWuKtSAwWQKReOAmA2p0gx1FNZX9eGCl/4IQ54/tLP2zJ07t6LwAl6fn6t
# mKXChdbC9L7p
# =CY68
# -----END PGP SIGNATURE-----
# gpg: Signature made Thu 08 Jan 2026 05:51:40 PM AEDT
# gpg:                using RSA key 354BC8B3D7EB2A6B68674E5F3870B400EB918653
# gpg:                issuer "[email protected]"
# gpg: Good signature from "Markus Armbruster <[email protected]>" [unknown]
# gpg:                 aka "Markus Armbruster <[email protected]>" [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: 354B C8B3 D7EB 2A6B 6867  4E5F 3870 B400 EB91 8653

* tag 'pull-error-2026-01-07-v2' of https://repo.or.cz/qemu/armbru:
  block/file-win32: Improve an error message
  qga/commands-win32: Use error_setg_win32() for better error messages
  error: Use error_setg_errno() for simplicity and consistency
  error: Use error_setg_errno() to improve error messages
  net/slirp: Improve file open error message
  error: Use error_setg_file_open() for simplicity and consistency
  blkdebug: Use error_setg_file_open() for a better error message
  net/tap: Use error_setg_file_open() for a better error message
  qga: Use error_setg_file_open() for better error messages
  tap-solaris: Use error_setg_file_open() for better error messages
  ui: Convert to qemu_create() for simplicity and consistency
  error: Strip trailing '\n' from error string arguments (again)
  error: Consistently name Error * objects err, and not errp
  error: error_free(NULL) is safe, drop unnecessary conditionals
  nbd/client-connection: Replace error_propagate() by assignment
  hw/nvram/xlnx-bbram: More idiomatic and simpler error reporting
  hw/core/loader: Make load_elf_hdr() return bool, simplify caller

Signed-off-by: Richard Henderson <[email protected]>
2026-01-08 21:17:46 +11:00
Markus Armbruster bfb8ab8370 MAINTAINERS: Add MAX78000FTHR section as orphan
This machine was contributed by Jackson Donaldson a couple of months
ago.  Its RISC-V core is not implemented.  Unfortunately, Jackson
isn't able to serve as maintainer at this time, so add it as orphan.

Cc: Jackson Donaldson <[email protected]>
Cc: [email protected]
Signed-off-by: Markus Armbruster <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
2026-01-08 09:53:09 +01:00
Markus Armbruster 2c52c35eb2 MAINTAINERS: Add EEPROM 93xx section
Stefan Weil volunteered to serve as maintainer.  Thanks!

Cc: Stefan Weil <[email protected]>
Signed-off-by: Markus Armbruster <[email protected]>
Signed-off-by: Stefan Weil <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
2026-01-08 09:53:09 +01:00
Markus Armbruster 7e3bfed7ac MAINTAINERS: Fix coverage of meson.build in tests/functional
Of the 29 meson.build wihin tests/functional, only 8 are covered.  Add
the architecture-independent ones to "Functional testing framework",
and the remainder to "$arcg general architecture support" when
available, else to "$arch TCG CPUs".

Signed-off-by: Markus Armbruster <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
2026-01-08 09:53:09 +01:00
Markus Armbruster e0422713b5 MAINTAINERS: Fix coverage of tests/functional/acpi-bits/
The pattern tests/functional/acpi-bits/* covers files in
acpi-bits/ (there are none), but not the files in its
subdirectories (there are five).  Drop the *.

Signed-off-by: Markus Armbruster <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
2026-01-08 09:53:09 +01:00
Markus Armbruster 1f674a2b7a block/file-win32: Improve an error message
Two out of three calls of CreateFile() use error_setg_win32() to
report errors.  The third uses error_setg_errno(), mapping
ERROR_ACCESS_DENIED to EACCES, and everything else to EINVAL, throwing
away detail.  Switch it to error_setg_win32().

Signed-off-by: Markus Armbruster <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
2026-01-08 07:50:32 +01:00
Markus Armbruster 3ec3397098 qga/commands-win32: Use error_setg_win32() for better error messages
We include numeric GetLastError() codes in error messages in a few
places, like this:

    error_setg(errp, "GRIPE: %d", (int)GetLastError());

Show text instead, like this:

    error_setg_win32(errp, GetLastError(), "GRIPE");

Signed-off-by: Markus Armbruster <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Kostiantyn Kostiuk <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
2026-01-08 07:50:32 +01:00
Markus Armbruster 0223e79287 error: Use error_setg_errno() for simplicity and consistency
Use error_setg_errno() instead of passing the value of strerror() or
g_strerror() to error_setg().

The separator between the error message proper and the value of
strerror() changes from " : ", "", " - ", "- " to ": " in places.

Signed-off-by: Markus Armbruster <[email protected]>
Message-ID: <[email protected]>
Acked-by: Jagannathan Raman <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
2026-01-08 07:50:32 +01:00
Markus Armbruster b351b49275 error: Use error_setg_errno() to improve error messages
A few error messages show numeric errno codes.  Use error_setg_errno()
to show human-readable text instead.

Signed-off-by: Markus Armbruster <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
[Trivial fixup to riscv_kvm_cpu_finalize_features()]
2026-01-08 07:49:23 +01:00
Richard Henderson 3b5fe75e2c Merge tag 'pull-monitor-2026-01-07' of https://repo.or.cz/qemu/armbru into staging
Monitor patches for 2026-01-07

# -----BEGIN PGP SIGNATURE-----
#
# iQJGBAABCgAwFiEENUvIs9frKmtoZ05fOHC0AOuRhlMFAmlehMoSHGFybWJydUBy
# ZWRoYXQuY29tAAoJEDhwtADrkYZTuPgP/2rHOlK4GKLJH6QHzK8RJKSyuSH2aPj8
# 7Mz22qnwxmlckinstF5AHpIdtzJtvpm9GpHQpvqzjaIObHNSqbopNUcC+C7SVYmB
# LomxyyBfNOGtqF7lCsWGwJIEDthMELN8BrrahADVxJRdEnVBJ3u8N21JaQegYJeE
# A+oywBUTdfNBkXwpwk/EzgXQSH9mSZxQI9QAfvqwd6alleRdSdlWQ1tt++x9TNXr
# 4I/leZpk5Olh99HtFonxMs03crVoNDaxEkqRzZaxa9WivFUjt6RZwOjfLnam7dFM
# fKz05/KeK8bgaJU0oaP8yrIZqcKeEM2kF+uYyBEsDsu8BWghv6a9mQ/7KrbU+idN
# lmr0el4Uk1kGmubpxEtWvse3yP2v4C4Y2/0r4nx00ebW3A09iBcfYQ9DjCvAhZ+O
# Ml7ECzZ63ubJ6Sj4w6sjjiUK6kcrbqxBP+DzLMzUY9YrGofSTLx6YUtyvEFyUm8J
# NPLl3u6vCI5zKnc9nHZoXsmLsPFKGe3at3TOJahNyM68TFc27xcvYlm3ZnKit6Un
# V2EvMxEjdZk2ZU6rWqEnIsVREQoC3Uje8zSkS9UFZEWWCj0WDhv552WXHlHRf4Uo
# ssP0T2wIG6N97LIdtKZSOg32Ff/EFU6ZI7J0pN8j4jz8is+7qdBuCkobq4kZ3vqN
# rfPt/lIY6dpc
# =RlpK
# -----END PGP SIGNATURE-----
# gpg: Signature made Thu 08 Jan 2026 03:07:38 AM AEDT
# gpg:                using RSA key 354BC8B3D7EB2A6B68674E5F3870B400EB918653
# gpg:                issuer "[email protected]"
# gpg: Good signature from "Markus Armbruster <[email protected]>" [unknown]
# gpg:                 aka "Markus Armbruster <[email protected]>" [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: 354B C8B3 D7EB 2A6B 6867  4E5F 3870 B400 EB91 8653

* tag 'pull-monitor-2026-01-07' of https://repo.or.cz/qemu/armbru:
  monitor/qmp: cleanup SocketChardev listener sources early to avoid fd handling race
  scripts/device-crash-test: ERROR_RULE_LIST garbage collection
  qdev: Legacy properties are now unused internally, drop
  qdev: Fix "info qtree" to show links

Signed-off-by: Richard Henderson <[email protected]>
2026-01-08 17:45:15 +11:00
Richard Henderson 63a88166ab Merge tag 'pull-request-2026-01-07' of https://gitlab.com/thuth/qemu into staging
* Compat machines for 11.0
* Add some more files to the MAINTAINERS file
* Use explicit big-endian API calls in the s390x code
* Add the possibility to run sub-tests manually in the functional test suite

# -----BEGIN PGP SIGNATURE-----
#
# iQJFBAABCgAvFiEEJ7iIR+7gJQEY8+q5LtnXdP5wLbUFAmleSkMRHHRodXRoQHJl
# ZGhhdC5jb20ACgkQLtnXdP5wLbVegA//R8zGTnW++Rcb3xFlRGQye08eKNWda4K8
# hqgHg4nEf3zj8dYm91lop8v3CMwVJtlBLiKtv+8GAo5ma/yItM9N/F3AgsUXt6po
# dpAAJISucDyIkHLDEMtlPTfQsEvoegEIaXoM7m1AOktArRaLzynmu430f8oAV8BE
# H3pPGUxaNgjtGlF+6yeUJ/FzrRpI2PXR6o8vtoG8+II5lQZvajOcmix6Znh+u0xj
# QKzYchYeN1u1YCvykQSp7dTUPygaGOgXHKpUvzUFNWyiq9d0eRW75NMLQJ4LSG2q
# nqmmHlSxsay5E0H+AWzDRGAsGNrXDtsxkXuAVE0GitKLcc3a1U5m4RQAl2bCW7Px
# +tx5xjxzg5d38wyKo7mif5WKKIdJs0ljuFlMMMn+FR8MEblCorW/CVCB4qVBdJ2v
# GMSD7hvHoRba2SpT6y0s+pIOZRsXdWW9FhAAVk9gURkm494UxBJZZL37gQEKwC0t
# HMxq8WMFLqZAC4TaoxSMdIRW9CZD5qKjGa4y2N9JU1HO2YDHsItce9DWb/09ep91
# LQg+adtqOFsYs5oGAZ1I17AIl9+ZYUatCeOGxwyYV4Bso5VZ45YH0z2puhA+FSp6
# zT+4trfasVDPQTFOFzBOZXOzhSFBqeVBPeBZAPG3CsTfHBdqu/YNOQuYtWWize94
# 0qmfMrevMxs=
# =oVgR
# -----END PGP SIGNATURE-----
# gpg: Signature made Wed 07 Jan 2026 10:57:55 PM AEDT
# gpg:                using RSA key 27B88847EEE0250118F3EAB92ED9D774FE702DB5
# gpg:                issuer "[email protected]"
# gpg: Good signature from "Thomas Huth <[email protected]>" [unknown]
# gpg:                 aka "Thomas Huth <[email protected]>" [unknown]
# gpg:                 aka "Thomas Huth <[email protected]>" [unknown]
# gpg:                 aka "Thomas Huth <[email protected]>" [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: 27B8 8847 EEE0 2501 18F3  EAB9 2ED9 D774 FE70 2DB5

* tag 'pull-request-2026-01-07' of https://gitlab.com/thuth/qemu:
  tests/functional/qemu_test/testcase: Fix mismatched quotations
  tests/functional: Allow tests to be run individually
  target/s390x: Inline translator_lduw() and translator_ldl()
  target/s390x: Use big-endian variant of cpu_ld/st_data*()
  target/s390x: Inline cpu_ld{uw, l}_code() calls in EX opcode helper
  target/s390x: Replace MO_TE -> MO_BE
  target/s390x: Replace gdb_get_regl() -> gdb_get_reg64()
  target/s390x: Use explicit big-endian LD/ST API
  hw/s390x: Use explicit big-endian LD/ST API
  MAINTAINERS: Add configs/targets/s390x-softmmu.mak to the S390 general section
  MAINTAINERS: Add util/s390x_pci_mmio.c to the S390 PCI section
  hw/s390x: Un-inline the s390_do_cpu_*() functions
  hw: add compat machines for 11.0
  hw/s390x/ccw: Remove deprecated s390-ccw-virtio-5.0 machine

Signed-off-by: Richard Henderson <[email protected]>
2026-01-08 07:24:44 +11:00
Jie Song e714f1a3d4 monitor/qmp: cleanup SocketChardev listener sources early to avoid fd handling race
When starting a dummy QEMU process with virsh version, monitor_init_qmp()
enables IOThread monitoring of the QMP fd by default. However, a race
condition exists during the initialization phase: the IOThread only removes
the main thread's fd watch when it reaches qio_net_listener_set_client_func_full(),
which may be delayed under high system load.

This creates a window between monitor_qmp_setup_handlers_bh() and
qio_net_listener_set_client_func_full() where both the main thread and
IOThread are simultaneously monitoring the same fd and processing events.
This race can cause either the main thread or the IOThread to hang and
become unresponsive.

Fix this by proactively cleaning up the listener's IO sources in
monitor_init_qmp() before the IOThread initializes QMP monitoring,
ensuring exclusive fd ownership and eliminating the race condition.

Signed-off-by: Jie Song <[email protected]>
Reviewed-by: Marc-André Lureau <[email protected]>
Message-ID: <[email protected]>
2026-01-07 17:05:25 +01:00
Markus Armbruster d968d29df0 scripts/device-crash-test: ERROR_RULE_LIST garbage collection
Device 'nand' was dropped in commit commit e86c1f967a.

Device 'vfio-amd-xgbe' was dropped in commit aeb1a50d4a.

Device 'vfio-calxeda-xgmac' was dropped in commit 8ebc416ac1.

The last error messages matching r"images* must be given with the
'pflash' parameter" was dropped in commit a2ccff4d2b.

The error message matching r"Option '-device [\w.,-]+' cannot be
handled by this machine" was dropped in commit commit db78a60559.

The error message matching r"Ignoring smp_cpus value" ceased to match
in commit f2ad5140fa, and was then dropped in commit 7264961934.

The error message matching r"rom check and register reset failed" was
lost in merge commit af3f37319c.

Signed-off-by: Markus Armbruster <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
2026-01-07 14:30:36 +01:00
Markus Armbruster a61383f7ab qdev: Legacy properties are now unused internally, drop
Legacy properties are an accidental and undocumented external
interface.  qom-set doesn't work for them (no .set() method).  qom-get
and qom-list-get work only when the underlying qdev property has a
.print() method, i.e. the PCI address properties, as explained in the
previous commit.  Here's one that works:

    (qemu) qom-get /machine/unattached/device[3]/pm addr
    11
    (qemu) qom-get /machine/unattached/device[3]/pm legacy-addr
    "01.3"

And here's one that doesn't:

    (qemu) qom-get /machine/unattached/device[3]/pm bus
    "/machine/i440fx/pci.0"
    (qemu) qom-get /machine/unattached/device[3]/pm legacy-bus
    Error: Property 'PIIX4_PM.legacy-bus' is not readable

Actual use of this undocumented interface seems quite unlikely.  A
deprecation period seems unnecessary.  Drop it.

Signed-off-by: Markus Armbruster <[email protected]>
Message-ID: <[email protected]>
Acked-by: Marc-André Lureau <[email protected]>
[Commit message improved]
2026-01-07 14:30:36 +01:00
Markus Armbruster d10176ddf7 qdev: Fix "info qtree" to show links
qdev_print_props() retrieves a property's value from its legacy
property if it exists.  A legacy property is created by
qdev_class_add_legacy_property() when the property has a print()
method or does not have a get() method.

If it has a print() method, the legacy property's value is obtained
from the property's print() method.  This is used to format PCI
addresses nicely, i.e. like 01.3 instead of 11.

Else, if doesn't have a get() method, the legacy property is
unreadable.  "info qtree" silently skips unreadable properties.

Link properties don't have a get() method, and are therefore skipped.
This is wrong, because the underlying QOM property *is* readable.

Change qdev_print_props() to simply use a print() method directly if
it exists, else get the value via QOM.

"info qtree" now shows links fine.  For instance, machine "pc" onboard
device "PIIX4_PM" property "bus" is now visible.

Signed-off-by: Markus Armbruster <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Marc-André Lureau <[email protected]>
2026-01-07 14:30:36 +01:00
Markus Armbruster 42cfc68b0e net/slirp: Improve file open error message
This error reports failure to create a temporary file, and
error_setg_file_open() would probably be too terse, so merely switch
to error_setg_errno() to add errno information.

Signed-off-by: Markus Armbruster <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
2026-01-07 13:25:01 +01:00
Markus Armbruster d84870f2b8 error: Use error_setg_file_open() for simplicity and consistency
Replace

    error_setg_errno(errp, errno, MSG, FNAME);

by

    error_setg_file_open(errp, errno, FNAME);

where MSG is "Could not open '%s'" or similar.

Also replace equivalent uses of error_setg().

A few messages lose prefixes ("net dump: ", "SEV: ", __func__ ": ").
We could put them back with error_prepend().  Not worth the bother.

Signed-off-by: Markus Armbruster <[email protected]>
Reviewed-by: Dr. David Alan Gilbert <[email protected]>
Message-ID: <[email protected]>
[Conflict with commit 26b4a6ffe7 (monitor/hmp: Merge
hmp-cmds-target.c within hmp-cmds.c) resolved]
2026-01-07 13:24:41 +01:00
Markus Armbruster 9c3a66f5c4 blkdebug: Use error_setg_file_open() for a better error message
The error message changes from

    Could not read blkdebug config file: REASON

to

    Could not open 'FNAME': REASON

I think the exact file name is more useful to know than the file's
purpose.

Signed-off-by: Markus Armbruster <[email protected]>
Message-ID: <[email protected]>
2026-01-07 11:26:57 +01:00
Markus Armbruster aca7194284 net/tap: Use error_setg_file_open() for a better error message
The error message changes from

    tap: open vhost char device failed

to

    Could not open '/dev/vhost-net': REASON

I think the exact file name is more useful to know than the file's
purpose.

We could put back the "tap: " prefix with error_prepend().  Not
worth the bother.

Signed-off-by: Markus Armbruster <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
2026-01-07 11:26:57 +01:00
Markus Armbruster 578988e684 qga: Use error_setg_file_open() for better error messages
Error messages change from

    open("FNAME"): REASON

to

    Could not open 'FNAME': REASON

Signed-off-by: Markus Armbruster <[email protected]>
Reviewed-by: Dr. David Alan Gilbert <[email protected]>
Reviewed-by: Kostiantyn Kostiuk <[email protected]>
Message-ID: <[email protected]>
2026-01-07 11:26:57 +01:00
Markus Armbruster 7a6665350b tap-solaris: Use error_setg_file_open() for better error messages
Error messages change from

    Can't open /dev/ip (actually /dev/udp)
    Can't open /dev/tap
    Can't open /dev/tap (2)

to

    Could not open '/dev/udp': REASON
    Could not open '/dev/tap': REASON

where REASON is the value of strerror(errno).

Signed-off-by: Markus Armbruster <[email protected]>
Reviewed-by: Dr. David Alan Gilbert <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
2026-01-07 11:26:57 +01:00
Markus Armbruster 5657d9b60a ui: Convert to qemu_create() for simplicity and consistency
The error message changes from

    failed to open file 'FILENAME': REASON

to

    Could not create 'FILENAME': REASON

Signed-off-by: Markus Armbruster <[email protected]>
Message-ID: <[email protected]>
2026-01-07 11:26:57 +01:00
Markus Armbruster 13837193fa error: Strip trailing '\n' from error string arguments (again)
Tracked down with scripts/coccinelle/err-bad-newline.cocci.

Signed-off-by: Markus Armbruster <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
2026-01-07 11:26:57 +01:00
Markus Armbruster 19552884e4 error: Consistently name Error * objects err, and not errp
This touches code in xen_enable_tpm() that is obviously wrong.  Since
I don't know how to fix it properly, I'm adding a FIXME there.

Signed-off-by: Markus Armbruster <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Zhao Liu <[email protected]>
2026-01-07 11:26:57 +01:00
Markus Armbruster a4cda04107 error: error_free(NULL) is safe, drop unnecessary conditionals
Signed-off-by: Markus Armbruster <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Reviewed-by: Vladimir Sementsov-Ogievskiy <[email protected]>
Reviewed-by: Peter Xu <[email protected]>
Reviewed-by: Zhao Liu <[email protected]>
2026-01-07 11:26:56 +01:00
Markus Armbruster cfd5d4eafb nbd/client-connection: Replace error_propagate() by assignment
connect_thread_func() sets a variable to null, then error_propagate()s
an Error * to it.  This is a roundabout way to assign the Error * to
it, so replace it by just that.

Signed-off-by: Markus Armbruster <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Vladimir Sementsov-Ogievskiy <[email protected]>
Reviewed-by: Peter Xu <[email protected]>
Reviewed-by: Zhao Liu <[email protected]>
2026-01-07 11:26:56 +01:00
Markus Armbruster 51cd475682 hw/nvram/xlnx-bbram: More idiomatic and simpler error reporting
bbram_bdrv_error() interpolates a "detail" string into a template with
error_setg_errno(), then reports the result with error_report().
Produces error messages with an unwanted '.':

    BLK-NAME: BBRAM backstore DETAIL failed.: STERROR

Replace both calls of bbram_bdrv_error() by straightforward
error_report(), and drop the function.  This is less code, easier to
read, and the error message is more greppable.

Also delete the unwanted '.'.

Signed-off-by: Markus Armbruster <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Vladimir Sementsov-Ogievskiy <[email protected]>
Reviewed-by: Peter Xu <[email protected]>
Reviewed-by: Luc Michel <[email protected]>
Reviewed-by: Zhao Liu <[email protected]>
2026-01-07 11:26:56 +01:00
Markus Armbruster 7bfd6c0e09 hw/core/loader: Make load_elf_hdr() return bool, simplify caller
Signed-off-by: Markus Armbruster <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Reviewed-by: Vladimir Sementsov-Ogievskiy <[email protected]>
Reviewed-by: Peter Xu <[email protected]>
Reviewed-by: Daniel Henrique Barboza <[email protected]>
Reviewed-by: Zhao Liu <[email protected]>
2026-01-07 11:26:56 +01:00
Yodel Eldar 8080227881 tests/functional/qemu_test/testcase: Fix mismatched quotations
A debug string incorrectly mixes single-quotes with double-quotes,
causing the variable within to be treated as a literal. Fix it.

Signed-off-by: Yodel Eldar <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Alex Bennée <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
2026-01-07 10:41:40 +01:00
Fabiano Rosas 11d99e98fe tests/functional: Allow tests to be run individually
The functional tests currently don't allow a single test to be
selected for execution by dotted name, e.g:

./build/run tests/functional/ppc64/test_pseries.py PseriesMachine.test_ppc64_linux_boot
                                          ^
The issue is that the testcase.py main function passes the test
module's name as the second argument to unittest.main(), which makes
it ignore all other positional arguments (presumably because the
module is already the superset of all tests).

After commit cac08383f0 ("tests/functional: expose sys.argv to
unittest.main"), the situation improves by passing the rest of the
argv from the command line invocation into unittest.main(), but it
still doesn't fix the issue. The short form options are now accepted,
so the -k option could be used to filter for a pattern, which is
useful, but not the same as listing the test names.

Fix this by passing the test module name via the "module" argument to
unittest.main() and stop touching argv. The ways of invoking tests are
now as per unittests documentation (-k still works):

  Examples:
    test_pseries.py                           - run default set of tests
    test_pseries.py MyTestSuite               - run suite 'MyTestSuite'
    test_pseries.py MyTestCase.testSomething  - run MyTestCase.testSomething
    test_pseries.py MyTestCase                - run all 'test*' test methods in MyTestCase

Note that ever since we've been programatically passing the module
name to unittest.main(), the usage 'test_pseries.py test_pseries' was
never valid. It used to "work" just the same as 'test_pseries.py
foobar' would. After this patch, that usage results in an error.

Also note that testcase.py:main() pertains to running the test module
that invoked it via QemuSystemTest.main(), i.e. module == __main__. So
the 'discover' usage of unittest doesn't apply here, the module is
already discovered because that's where this code was called from to
begin with. This patch could just as well call unittest.main() instead
of unittest.main(test_module), but the latter provides nicer error
messages prefixed with the module name.

Tested-by: Thomas Huth <[email protected]>
Signed-off-by: Fabiano Rosas <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
2026-01-07 09:55:37 +01:00
Philippe Mathieu-Daudé f0853c2586 target/s390x: Inline translator_lduw() and translator_ldl()
translator_lduw() and translator_ldl() are defined in
"exec/translator.h" as:

  192 static inline uint16_t
  193 translator_lduw(CPUArchState *env, DisasContextBase *db, vaddr pc)
  194 {
  195     return translator_lduw_end(env, db, pc, MO_TE);
  196 }

  198 static inline uint32_t
  199 translator_ldl(CPUArchState *env, DisasContextBase *db, vaddr pc)
  200 {
  201     return translator_ldl_end(env, db, pc, MO_TE);
  202 }

Directly use the inlined form, expanding MO_TE -> MO_BE
since we only build the S390x target as big-endian.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Manos Pitsidianakis <[email protected]>
Reviewed-by: Eric Farman <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
2026-01-07 09:55:37 +01:00
Philippe Mathieu-Daudé ee4dae6a33 target/s390x: Use big-endian variant of cpu_ld/st_data*()
We only build the S390x target using big endianness order,
therefore the cpu_ld/st_data*() definitions expand to the
big endian declarations. Use the explicit big-endian variants.

Mechanical change running:

  $ tgt=s390x; \
    end=be; \
    for op in data mmuidx_ra; do \
      for ac in uw sw l q; do \
        sed -i -e "s/cpu_ld${ac}_${op}/cpu_ld${ac}_${end}_${op}/" \
                  $(git grep -l cpu_ target/${tgt}/); \
      done;
      for ac in w l q; do \
        sed -i -e "s/cpu_st${ac}_${op}/cpu_st${ac}_${end}_${op}/" \
                  $(git grep -l cpu_ target/${tgt}/); \
      done;
    done

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Reviewed-by: Manos Pitsidianakis <[email protected]>
Reviewed-by: Eric Farman <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
2026-01-07 09:55:37 +01:00
Philippe Mathieu-Daudé 381a1fda5b target/s390x: Inline cpu_ld{uw, l}_code() calls in EX opcode helper
In preparation of removing the cpu_lduw_code() and cpu_ldl_code()
wrappers, inline them.

Since S390x instructions are always stored in big-endian order,
replace MO_TE -> MO_BE.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Manos Pitsidianakis <[email protected]>
Reviewed-by: Eric Farman <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
2026-01-07 09:55:37 +01:00
Philippe Mathieu-Daudé 69da23130f target/s390x: Replace MO_TE -> MO_BE
We only build the S390x target using big endianness order,
therefore the MO_TE definitions expand to the big endian
one. Use the latter which is more explicit.

Mechanical change running:

  $ sed -i -e s/MO_TE/MO_BE/ \
        $(git grep -wl MO_TE target/s390x/)

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Manos Pitsidianakis <[email protected]>
Reviewed-by: Eric Farman <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
2026-01-07 09:55:37 +01:00
Philippe Mathieu-Daudé 0fb6ad781c target/s390x: Replace gdb_get_regl() -> gdb_get_reg64()
We only build s390x targets as 64-bit:

  $ git grep BIT configs/targets/s390x-*
  configs/targets/s390x-linux-user.mak:6:TARGET_LONG_BITS=64
  configs/targets/s390x-softmmu.mak:5:TARGET_LONG_BITS=64

Therefore gdb_get_regl() expands to gdb_get_reg64(). Use
the latter which is more explicit.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Manos Pitsidianakis <[email protected]>
Reviewed-by: Eric Farman <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
2026-01-07 09:55:37 +01:00
Philippe Mathieu-Daudé 409cbb1a61 target/s390x: Use explicit big-endian LD/ST API
The S390x architecture uses big endianness. Directly use
the big-endian LD/ST API.

Mechanical change running:

  $ for a in uw w l q; do \
      sed -i -e "s/ld${a}_p(/ld${a}_be_p(/" \
        $(git grep -wlE '(ld|st)u?[wlq]_p' target/s390x/);
    done

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Manos Pitsidianakis <[email protected]>
Reviewed-by: Eric Farman <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
2026-01-07 09:55:37 +01:00
Philippe Mathieu-Daudé eb3d793d35 hw/s390x: Use explicit big-endian LD/ST API
The S390x architecture uses big endianness. Directly use
the big-endian LD/ST API.

Mechanical change running:

  $ for a in uw w l q; do \
      sed -i -e "s/ld${a}_p(/ld${a}_be_p(/" \
        $(git grep -wlE '(ld|st)u?[wlq]_p' hw/s390x/);
    done

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Manos Pitsidianakis <[email protected]>
Reviewed-by: Halil Pasic <[email protected]>
Reviewed-by: Eric Farman <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
2026-01-07 09:55:37 +01:00
Thomas Huth f0391eef7f MAINTAINERS: Add configs/targets/s390x-softmmu.mak to the S390 general section
Make sure that configs/targets/s390x-softmmu.mak is covered by
MAINTAINERS - the "S390 general architecture support" section seems
to be a good place for this.

Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
2026-01-07 06:13:17 +01:00
Thomas Huth 8930b09a49 MAINTAINERS: Add util/s390x_pci_mmio.c to the S390 PCI section
s390x_pci_mmio.c currently shows up as unmaintained. Add it to
the S390 PCI section to make the right people aware of changes
to this file.

Reviewed-by: Matthew Rosato <[email protected]>
Reviewed-by: Farhan Ali <[email protected]>
Reviewed-by: Eric Farman <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
2026-01-07 06:13:17 +01:00
Thomas Huth 0dcbba66de hw/s390x: Un-inline the s390_do_cpu_*() functions
These functions are only called via their function pointer by using
the run_on_cpu() function, so it does not make sense to declare these
as "inline" functions. Move the functions from cpu.h to either cpu.c
(when they are still used in multiple places), or to s390-virtio-ccw.c
(when they are only called from that file).

Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Eric Farman <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
2026-01-07 06:13:17 +01:00
Cornelia Huck 231b4a035b hw: add compat machines for 11.0
Add 11.0 machine types for arm/i440fx/m68k/q35/s390x/spapr.

Signed-off-by: Cornelia Huck <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
2026-01-07 06:13:17 +01:00
Philippe Mathieu-Daudé 868e210ace hw/s390x/ccw: Remove deprecated s390-ccw-virtio-5.0 machine
This machine has been supported for a period of more than 6 years.
According to our versioned machine support policy (see commit
ce80c4fa6f "docs: document special exception for machine type
deprecation & removal") it can now be removed.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
2026-01-07 06:13:17 +01:00
Richard Henderson 0fc482b73d Merge tag 'pull-aspeed-20260105' of https://github.com/legoater/qemu into staging
aspeed queue:

* Removed the ast2700-a0 SoC and ast2700a0-evb machine.
* Added SGPIO support to the ast2700 SoC, including unit tests.
* Added several FRU EEPROMs to the Catalina board.
* Added support for the new AST1060 SoC and ast1060-evb machine,
  including functional tests.
* Fixed the silicon revision ID register for AST2600 and AST1030 SoCs.
* Added an SFDP table for a Winbond flash chip.
* Updated documentation for Aspeed boards.

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCAAdFiEEoPZlSPBIlev+awtgUaNDx8/77KEFAmlbtGMACgkQUaNDx8/7
# 7KGtVBAAgiCDME1oXrc+ZVmYn8RtRsx/lakp4prbqRbs6A8qoITk3ao6WjNd2k3P
# kOkvB/xQCqRDSSJIpp8BQhUzDet80b8KUz16iTw1m7KubMIqapmOxVkGJqSc9kGT
# PfLVjB60rHqiCkInNaaMXxMQuY0iAFKS+SDM8mCGaay0MXdvsEIi+XIcxv2TX0Jo
# tnHMaJxtSKfzY3QiM7yeB+WryzOlzQ7IMqRkai9tCN1y3XyDy8PodelZFCIGXw/N
# tw04Z3q/LhmxT6kjvYLmeTETne+1k69gfME+7JhB1hPSrIgdIqM9qyXCROb0U8/W
# 5mJDkm84blHc4QWITdewiyhIGps9ITxqlIelCExPL1GpEubSg5BVkqFbIjMv+6HJ
# 2XcBbP+rG6IdEpxeT+PcHw5HvOfLjMY6kGrawpK4s2id5jI9GSSyNY5k576tqRzg
# P10GfeKUDNDj1nYhUfOmzL6qXb9TqIyQtOVJVGcHkaASnXIqFvL6rYQHcttFej08
# YepKqvYBBSwsb2TdSb1t6VKTgCublFUD4jdhph3iqVmfQRl3ei8WJHFKCt8aQ235
# HqXzcmBDoTFYqJ97SAg1bvydhVL+rDpd//gcPqVw2cwMnTa2S3zvgI6xj1oBTEf8
# YiRPtFYJ03Y9baNZRdGdYAErxIdiliZh+OYfaEFNNn5Zuqp6tYQ=
# =64bG
# -----END PGP SIGNATURE-----
# gpg: Signature made Mon 05 Jan 2026 11:53:55 PM AEDT
# gpg:                using RSA key A0F66548F04895EBFE6B0B6051A343C7CFFBECA1
# gpg: Good signature from "Cédric Le Goater <[email protected]>" [full]
# gpg:                 aka "Cédric Le Goater <[email protected]>" [full]

* tag 'pull-aspeed-20260105' of https://github.com/legoater/qemu: (36 commits)
  hw/i2c/aspeed: Fix wrong I2CC_DMA_LEN when I2CM_DMA_TX/RX_ADDR set first
  hw/intc/aspeed: Remove TSP 128 - 138
  hw/intc/aspeed: Remove SSP 128 - 138
  docs/specs/aspeed-intc: Remove GIC 128 - 136
  hw/intc/aspeed: Remove GIC 128 - 136
  hw/arm/aspeed_ast27x0: Remove ast2700-a0 SOC
  hw/arm: Remove ast2700a0-evb machine
  tests/functional: Fix URL of gb200nvl-bmc image
  test/qtest: Add Unit test for Aspeed SGPIO
  hw/arm/aspeed_ast27x0: Wire SGPIO controller to AST2700 SoC
  hw/arm/aspeed_soc: Update Aspeed SoC to support two SGPIO controllers
  hw/gpio/aspeed_sgpio: Implement SGPIO interrupt handling
  hw/gpio/aspeed_sgpio: Add QOM property accessors for SGPIO pins
  hw/gpio/aspeed_sgpio: Add basic device model for Aspeed SGPIO
  hw/arm/aspeed: catalina: add Cable Cartridge FRU EEPROM
  hw/arm/aspeed: catalina: add NIC FRU EEPROM
  hw/arm/aspeed: catalina: add HMC FRU EEPROM
  hw/arm/aspeed: catalina: add GB200-IO FRU EEPROM
  hw/arm/aspeed: catalina: add GB200 FRU EEPROM
  hw/arm/aspeed: catalina: add HDD FRU EEPROM
  ...

Signed-off-by: Richard Henderson <[email protected]>
2026-01-06 06:52:47 +11:00
Yunpeng Yang 75c15651af hw/ipmi/ipmi_bmc_sim: Support setting fake LAN channel config
The "Set LAN Configuration Parameters" IPMI command is added to the
`ipmi_bmc_sim` device to support dynamically setting fake LAN channel
configurations. With the fake LAN channel enabled, inside the guest OS,
tools such as `ipmitool` can be used to modify the configurations.

Signed-off-by: Yunpeng Yang <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Corey Minyard <[email protected]>
2026-01-05 13:07:23 -06:00
Yunpeng Yang fb7e4f7968 hw/ipmi/ipmi_bmc_sim: Support getting fake LAN channel config
The following IPMI commands are added or modified to support getting
fake LAN channel configurations from the `ipmi_bmc_sim` device:
* Get Channel Access;
* Get Channel Info Command;
* Get LAN Configuration Parameters.

The fake LAN channel configurations can be specified from QEMU
commandline options for device `ipmi_bmc_sim`. Inside the guest OS, the
configurations can be retrieved from the device using some IPMI tools,
e.g., `ipmitool lan print`.
Note, there is not a real LAN channel. The fake LAN channel is suitable
for testing purposes.

Signed-off-by: Yunpeng Yang <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Corey Minyard <[email protected]>
2026-01-05 13:07:23 -06:00
Jamin Lin 9cbd8ee7f6 hw/i2c/aspeed: Fix wrong I2CC_DMA_LEN when I2CM_DMA_TX/RX_ADDR set first
In the previous design, the I2C model would update I2CC_DMA_LEN (0x54) based on
the value of I2CM_DMA_LEN (0x1C) when the firmware set either I2CM_DMA_TX_ADDR
(0x30) or I2CM_DMA_RX_ADDR (0x34). However, this only worked correctly if the
firmware set I2CM_DMA_LEN before setting I2CM_DMA_TX_ADDR or I2CM_DMA_RX_ADDR.

If the firmware instead set I2CM_DMA_TX_ADDR or I2CM_DMA_RX_ADDR before setting
I2CM_DMA_LEN, the value written to I2CC_DMA_LEN would be incorrect.

To fix this issue, the model should be updated to set I2CC_DMA_LEN when the
firmware writes to the I2CM_DMA_LEN register, rather than when it writes to the
I2CM_DMA_RX_ADDR and I2CM_DMA_TX_ADDR registers.

Signed-off-by: Jamin Lin <[email protected]>
Fixes: ba2cccd64e ("aspeed: i2c: Add new mode support")
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-01-05 10:38:02 +01:00
Jamin Lin d1736a2ae2 hw/intc/aspeed: Remove TSP 128 - 138
The SSP interrupts 128 - 138 were only used by the AST2700 A0 SoC.
Since the AST2700 A0 has been deprecated, these interrupt
definitions are no longer needed. This commit removes them to
clean up the codebase.

Signed-off-by: Jamin Lin <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-01-05 10:38:02 +01:00
Jamin Lin 61fa20dc50 hw/intc/aspeed: Remove SSP 128 - 138
The SSP interrupts 128 - 138 were only used by the AST2700 A0 SoC.
Since the AST2700 A0 has been deprecated, these interrupt
definitions are no longer needed. This commit removes them to
clean up the codebase.

Signed-off-by: Jamin Lin <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-01-05 10:38:02 +01:00
Jamin Lin 798c442df7 docs/specs/aspeed-intc: Remove GIC 128 - 136
The GIC interrupts 128 - 136 were only used by the AST2700 A0 SoC.
Since the AST2700 A0 has been deprecated, these interrupt
definitions are no longer needed. This commit removes them to
clean up the codebase.

Signed-off-by: Jamin Lin <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-01-05 10:38:02 +01:00
Jamin Lin 14ecbe9fb2 hw/intc/aspeed: Remove GIC 128 - 136
The GIC interrupts 128 - 136 were only used by the AST2700 A0 SoC.
Since the AST2700 A0 has been deprecated, these interrupt
definitions are no longer needed. This commit removes them to
clean up the codebase.

Signed-off-by: Jamin Lin <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-01-05 10:38:02 +01:00
Jamin Lin 4f53de2f10 hw/arm/aspeed_ast27x0: Remove ast2700-a0 SOC
The ast2700-a1 SOC represented the first revision of the AST2700 and
was intended as an early engineering sample rather than a production
platform. A newer revision, A1, is now supported, and the ast2700-a1
SOC should replace the older A0 version.

Signed-off-by: Jamin Lin <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-01-05 10:38:02 +01:00
Jamin Lin e50a021a45 hw/arm: Remove ast2700a0-evb machine
The ast2700a0-evb machine represents the first revision of the AST2700 and
serves as the initial engineering sample rather than a production version.
A newer revision, A1, is now supported, and the ast2700a1-evb should replace
the older A0 version.

Signed-off-by: Jamin Lin <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
[ clg: Updated docs/about/removed-features.rst ]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-01-05 10:38:02 +01:00
Cédric Le Goater 75bcfb98a1 tests/functional: Fix URL of gb200nvl-bmc image
Commit [1] moved the FW image of the gb200nvl-bmc machine and broke
the associated functional test. Fix that.

[1] https://github.com/legoater/qemu-aspeed-boot/commit/52451b2472eeb40aa97e131aeea327e9d4a8a78a

Cc: Ed Tanous <[email protected]>
Cc: Patrick Williams <[email protected]>
Tested-by: Philippe Mathieu-Daudé <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-01-05 10:38:02 +01:00
Yubin Zou eb5f781add test/qtest: Add Unit test for Aspeed SGPIO
This commit introduces a new qtest for the Aspeed SGPIO controller
The test covers the following:
  - Setting and clearing SGPIO output pins and verifying the pin state.
  - Setting and clearing SGPIO input pins and verifying the pin state.
  - Verifying that level-high interrupts are correctly triggered and cleared.

Signed-off-by: Yubin Zou <[email protected]>
Reviewed-by: Kane Chen <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-01-05 10:38:02 +01:00
Yubin Zou 508e8630de hw/arm/aspeed_ast27x0: Wire SGPIO controller to AST2700 SoC
This commit integrates the Aspeed SGPIO controller into the AST2700

Signed-off-by: Yubin Zou <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-01-05 10:38:02 +01:00
Yubin Zou 46ad43a031 hw/arm/aspeed_soc: Update Aspeed SoC to support two SGPIO controllers
This commit updates the Aspeed SoC model to support two SGPIO
controllers, reflecting the hardware capabilities of the AST2700

The memory map and interrupt map are updated to include entries for
two SGPIO controllers (SGPIOM0 and SGPIOM1). This change is a
prerequisite for the full implementation of the SGPIO device model.

Signed-off-by: Yubin Zou <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-01-05 10:38:02 +01:00
Yubin Zou 362d551dee hw/gpio/aspeed_sgpio: Implement SGPIO interrupt handling
The SGPIO controller can generate interrupts based on various pin state
changes, such as rising/falling edges or high/low levels. This change
adds the necessary logic to detect these events, update the interrupt
status registers, and signal the interrupt to the SoC.

Signed-off-by: Yubin Zou <[email protected]>
Reviewed-by: Kane Chen <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-01-05 10:38:02 +01:00
Yubin Zou 8b0265db27 hw/gpio/aspeed_sgpio: Add QOM property accessors for SGPIO pins
The `aspeed_sgpio_get_pin` and `aspeed_sgpio_set_pin` functions are
implemented to get and set the level of individual SGPIO pins. These
are then exposed as boolean properties on the SGPIO device object.

Signed-off-by: Yubin Zou <[email protected]>
Reviewed-by: Kane Chen <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-01-05 10:38:02 +01:00
Yubin Zou 5fbe0fc35a hw/gpio/aspeed_sgpio: Add basic device model for Aspeed SGPIO
This initial implementation includes the basic device structure,
memory-mapped register definitions, and read/write handlers for the
SGPIO control registers.

Signed-off-by: Yubin Zou <[email protected]>
Reviewed-by: Kane Chen <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-01-05 10:38:02 +01:00
Patrick Williams d8e135369a hw/arm/aspeed: catalina: add Cable Cartridge FRU EEPROM
Use ipmitool/frugen tool to generate a Cable Cart image based on a
sanitized set of data from a real device EEPROM.  The EEPROM
bus/address did not match device tree for one of the EEPROMs so move
it from bus 13 / 55 to bus 12 / 54.

Signed-off-by: Patrick Williams <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-01-05 10:38:02 +01:00
Patrick Williams b32fc2f907 hw/arm/aspeed: catalina: add NIC FRU EEPROM
Use ipmitool/frugen tool to generate a CX-7 NIC image based on a
sanitized set of data from a real device EEPROM.

Signed-off-by: Patrick Williams <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-01-05 10:38:02 +01:00
Patrick Williams 6b160e218a hw/arm/aspeed: catalina: add HMC FRU EEPROM
Use ipmitool/frugen tool to generate a HMC image based on a
sanitized set of data from a real device EEPROM.

Signed-off-by: Patrick Williams <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-01-05 10:38:02 +01:00
Patrick Williams 3836f5a4db hw/arm/aspeed: catalina: add GB200-IO FRU EEPROM
Use ipmitool/frugen tool to generate a GB200-IO image based on a
sanitized set of data from a real device EEPROM.

Signed-off-by: Patrick Williams <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-01-05 10:38:02 +01:00
Patrick Williams 121181ca6e hw/arm/aspeed: catalina: add GB200 FRU EEPROM
Use ipmitool/frugen tool to generate a GB200 image based on a
sanitized set of data from a real device EEPROM.

Signed-off-by: Patrick Williams <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-01-05 10:38:02 +01:00
Patrick Williams 5a49b57cd5 hw/arm/aspeed: catalina: add HDD FRU EEPROM
Use ipmitool/frugen tool to generate a HDD image based on a
sanitized set of data from a real device EEPROM.

Signed-off-by: Patrick Williams <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-01-05 10:38:02 +01:00
Patrick Williams dbf93cb83d hw/arm/aspeed: catalina: add FIO FRU EEPROM
Use ipmitool/frugen tool to generate an FIO image based on a
sanitized set of data from a real device EEPROM.

Signed-off-by: Patrick Williams <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-01-05 10:38:02 +01:00
Patrick Williams b7016ea66f hw/arm/aspeed: catalina: add OSFP FRU EEPROM
Use ipmitool/frugen tool to generate an OSFP image based on a
sanitized set of data from a real device EEPROM.

Signed-off-by: Patrick Williams <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-01-05 10:38:02 +01:00
Patrick Williams 171dc46524 hw/arm/aspeed: catalina: add PDB FRU EEPROM
Use ipmitool/frugen tool to generate a PDB image based on a
sanitized set of data from a real device EEPROM.

Signed-off-by: Patrick Williams <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-01-05 10:38:02 +01:00
Patrick Williams d684236c6d hw/arm/aspeed: catalina: add DC-SCM FRU EEPROM
Use ipmitool/frugen tool to generate a DC-SCM image based on a
sanitized set of data from a real device EEPROM.

Signed-off-by: Patrick Williams <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-01-05 10:38:02 +01:00
Patrick Williams 3c16b8ea29 hw/arm/aspeed: catalina: add BSM FRU EEPROM
Use ipmitool/frugen tool to generate a BSM image based on a
sanitized set of data from a real device EEPROM.

Signed-off-by: Patrick Williams <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-01-05 10:38:01 +01:00
Jamin Lin 641455f526 docs/system/arm/aspeed: Update Aspeed MiniBMC section to include AST1060 processor
Added details describing AST1060 as a Platform Root of Trust processor board alongside
AST1030 MiniBMC, and extended the list of missing devices to include
SMBus Filter and QSPI Monitor controllers.

Signed-off-by: Jamin Lin <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-01-05 10:38:01 +01:00
Jamin Lin ec348addb9 docs/system/arm/aspeed: Update Aspeed and 2700 family boards list
Remove the ast2700-evb entry from the Aspeed family boards list in
the documentation. The AST2700 platform now belongs to the new Aspeed
2700 family group, which has its own dedicated documentation section
and board definitions.

Update the Aspeed 2700 family boards list in the documentation to include
the new ast2700fc board entry.

Signed-off-by: Jamin Lin <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-01-05 10:38:01 +01:00
Jamin Lin 2510e00f2c tests/functional/arm/test_aspeed_ast1060: Add functional tests for Aspeed AST1060 SoC
Add functional tests for the Aspeed AST1060 SoC and its evaluation board.
The new test test_aspeed_ast1060.py validates booting the AST1060 EVB
machine using the Zephyr OS and ASPEED PROT application (ast1060_prot_v03.02.tgz)
and ensures basic console functionality.

Signed-off-by: Jamin Lin <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-01-05 10:38:01 +01:00
Jamin Lin 097957b555 hw/arm/aspeed_ast10x0_evb: Add AST1060 EVB machine support
Add a new machine definition ast1060-evb to support the Aspeed AST1060
evaluation board. The new EVB reuses the same MiniBMC framework used by
AST1030, as both SoCs share the same core peripherals and controller
designs.

The AST1060 EVB machine initializes the ast1060-a2 SoC and sets the
FMC and SPI flash models (w25q80bl and w25q02jvm) for simulation.
This enables QEMU to boot and emulate firmware images for AST1060-based
platforms.

Signed-off-by: Jamin Lin <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-01-05 10:38:01 +01:00
Jamin Lin 6a8ef87e6b hw/arm/aspeed_ast10x0: Add AST1060 SoC support
Add initial support for the Aspeed AST1060 SoC. The AST1060 reuses most
of the AST1030 peripheral device models, as the two SoCs share nearly
the same controllers including WDT, SCU, TIMER, HACE, ADC, I2C, FMC,
and SPI.

A new common initialization and realization framework (ast10x0_init
and ast10x0_realize) is leveraged so AST1060 can instantiate the
existing AST1030 models without redefining duplicate device types.

Signed-off-by: Jamin Lin <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-01-05 10:38:01 +01:00
Jamin Lin 1df0dbdfbb hw/arm/aspeed_ast10x0: Pass SoC name to common init for AST10x0 family reuse
Refactor the AST10x0 common initialization to accept a socname
parameter.

The AST1030 model can be reused by AST1060 since they share most of the
same controllers. This approach allows AST1060 to leverage the existing
AST1030 initialization flow while keeping separate SoC-specific init
functions for components that differ.

This prepares the framework for AST1060 support, allowing it to reuse
AST1030 device models and initialization flow without code duplication.

No functional changes.

Signed-off-by: Jamin Lin <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-01-05 10:38:01 +01:00
Jamin Lin 689e04592d hw/arm/aspeed_ast10x0: Add common realize function for AST10x0 SoCs
Introduce a new common realize function aspeed_soc_ast10x0_realize()
for AST10x0 series SoCs. The shared initialization and realization logic
is now placed in this common function to improve code reuse and reduce
duplication between different SoCs in the same family.

The AST1030 realization function aspeed_soc_ast1030_realize() is
updated to call the new common routine and then perform realization of
its own specific devices such as LPC and PECI, which are not present on
future SoCs like AST1060.

This refactor simplifies maintenance and prepares the framework for
adding AST1060 support.

No functional changes.

Signed-off-by: Jamin Lin <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-01-05 10:38:01 +01:00
Jamin Lin 8b8cc90cd4 hw/arm/aspeed_ast10x0: Add common init function for AST10x0 SoCs
Introduce a new common initialization function
aspeed_soc_ast10x0_init() for AST10x0 series SoCs. This separates the
shared initialization logic from the AST1030-specific part, allowing
reuse by future SoCs such as AST1060.

The AST1060 does not include the LPC and PECI models, so the common
initializer is used for all shared modules, while
aspeed_soc_ast1030_init() adds initialization of LPC and PECI, which
are unique to AST1030.

This refactor improves code reuse and prepares the codebase for
supporting the AST1060 platform.

No functional changes.

Signed-off-by: Jamin Lin <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-01-05 10:38:01 +01:00
Jamin Lin af0a260a04 hhw/misc/aspeed_scu: Add AST1060 A2 silicon revision definition
Add a new silicon revision constant AST1060_A2_SILICON_REV for the
AST1060 SoC. This allows the SCU model and related SoC layers to
identify and handle AST1060 A2 revision properly in the same way as
other Aspeed SoC families.

Signed-off-by: Jamin Lin <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-01-05 10:38:01 +01:00
Jamin Lin 0d9e824944 hw/misc/aspeed_scu: Fix the revision ID cannot be set in the SOC layer for AST2600 and AST1030
According to the design of the AST2600, it has a Silicon Revision ID
Register, specifically SCU004 and SCU014, to set the Revision ID for the
AST2600. For the AST2600 A3, SCU004 is set to 0x05030303 and SCU014 is
set to 0x05030303.

In the "aspeed_ast2600_scu_reset" function, the hardcoded value
"AST2600_A3_SILICON_REV" was used for SCU004, while "s->silicon_rev" was
used for SCU014. The value of "s->silicon_rev" is set by the SoC layer
via the "silicon-rev" property. This patch aligns both SCU004 and SCU014
to use "s->silicon_rev" for consistency and flexibility.

Similarly, the "aspeed_ast1030_scu_reset" function also used a fixed
revision constant ("AST1030_A1_SILICON_REV"). This change updates it to
use the same "s->silicon_rev" property, ensuring that both SoCs follow
a consistent and configurable revision handling mechanism.

Signed-off-by: Jamin Lin <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-01-05 10:38:01 +01:00
Jamin Lin 72347b162c hw/block/m25p80: Add SFDP table for Winbond W25Q02JVM flash
Add the SFDP data table for Winbond W25Q02JVM flash device. The table
was generated under Linux kernel by dumping the SFDP content using
the following command:

```
hexdump -v -e '8/1 "0x%02x, " "\n"' \
    /sys/bus/spi/devices/spi0.0/spi-nor/sfdp
```

Signed-off-by: Jamin Lin <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
2026-01-05 10:38:01 +01:00
Richard Henderson 159107e390 Merge tag 'pull-hex-20260102' of https://github.com/quic/qemu into staging
Bypass packet commit for implicit usr write; cleanup

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCgAdFiEEPWaq5HRZSCTIjOD4GlSvuOVkbDIFAmlYJAgACgkQGlSvuOVk
# bDIQOg//TmXIRWGHuwL8jwtDDktyj0w5FVh3yA+i7Yx7fuoui/h1cwKc0LkSmx71
# m4JLvgDCqYsxh0DKmR3qadUnt4dNKUkMIdvpyqN/uBVzxyepfgTAOBXn6LAISHtr
# P5ObIbB72E0G/L3qwvEJuawcY/eCgpEU5laiBmfGyka8h8bvc0zD9M3VLzSOm28e
# XUAhR1WOd7IY0AAwYrHzCH0x+OjqY8xi8q5t5UDr1TA2ZL8mqwJuuUfO4QdTNPio
# QTump+kqN3PcmWHnKzqs/IJVQOi9vi7JN/8S6JsiLwpL3/PhKk7y8b9a5NWO6mHs
# 4W9SRa0Wy+lxkhNXSjUkVD7NqMre8fAYvl0jYWpj09Z7sm71Y3A+aIWllm70/vzK
# NnZutZp+DXGbqZalwRK3ON7csCfBehPLfr4ru2Kwo1GNZbQx5KR+TMc/CuVihCYl
# owFR0aG94xyfhpBrUXLcyqmjRb2MmMt0LrFbjOXOhy+fmFhw/NrxMsmTDXBEuAB1
# HpqjizcLNobRwIxI+vvp8cTdP0uL3oKrn0CcppI689n+Qvp4TnC6WTzAqA7UJaCJ
# WPWCSGmPBNDo1IsnoYBuPEH1po6tuesmJdsNWQPdfO14JA0NAAWsH7W+Ow14jQaf
# WG1WMvMph/m2wc7JbeZe5cujUxQ2Jj+CvjnjAaMRR8X6ndzk33k=
# =GJil
# -----END PGP SIGNATURE-----
# gpg: Signature made Sat 03 Jan 2026 07:01:12 AM AEDT
# gpg:                using RSA key 3D66AAE474594824C88CE0F81A54AFB8E5646C32
# gpg: Good signature from "Brian Cain (QUIC) <[email protected]>" [unknown]
# gpg:                 aka "Brian Cain <[email protected]>" [unknown]
# gpg:                 aka "Brian Cain (QuIC) <[email protected]>" [unknown]
# gpg:                 aka "Brian Cain (CAF) <[email protected]>" [unknown]
# gpg:                 aka "bcain" [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: 6350 20F9 67A7 7164 79EF  49E0 175C 464E 541B 6D47
#      Subkey fingerprint: 3D66 AAE4 7459 4824 C88C  E0F8 1A54 AFB8 E564 6C32

* tag 'pull-hex-20260102' of https://github.com/quic/qemu:
  Hexagon (target/hexagon) s/log_write/gen_write
  Hexagon (target/hexagon) s/gen_log_vreg_write/gen_vreg_write
  Hexagon (target/hexagon) s/gen_log_pred_write/gen_pred_write
  Hexagon (target/hexagon) Remove gen_log_reg_write
  Hexagon (target/hexagon) analyze all reads before writes
  Hexagon (tests/tcg/hexagon) Add test for USR changes in packet
  Hexagon (target/hexagon) Implicit writes to USR don't force packet commit
  Hexagon (target/hexagon) Add pkt_need_commit argument to arch_fpop_end
  Hexagon (target/hexagon) Remove gen_tcg_func_table.py

Signed-off-by: Richard Henderson <[email protected]>
2026-01-05 07:35:40 +11:00
Taylor Simpson 15722c774a Hexagon (target/hexagon) s/log_write/gen_write
These functions don't "log" anything, they just generate the write

Signed-off-by: Taylor Simpson <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Brian Cain <[email protected]>
Signed-off-by: Brian Cain <[email protected]>
2025-12-31 22:57:44 -06:00
Taylor Simpson 19366c95f0 Hexagon (target/hexagon) s/gen_log_vreg_write/gen_vreg_write
Note there are two functions impacted
    gen_log_vreg_write          -> gen_vreg_write
    gen_log_vreg_write_pair     -> gen_vreg_write_pair
These functions don't "log" anything, they just generate the write

Signed-off-by: Taylor Simpson <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Brian Cain <[email protected]>
Signed-off-by: Brian Cain <[email protected]>
2025-12-31 22:57:44 -06:00
Taylor Simpson b68bcbf6ea Hexagon (target/hexagon) s/gen_log_pred_write/gen_pred_write
The function doesn't "log" anything, it just generates the write

Signed-off-by: Taylor Simpson <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Brian Cain <[email protected]>
Signed-off-by: Brian Cain <[email protected]>
2025-12-31 22:57:44 -06:00
Taylor Simpson c3d9f1b84b Hexagon (target/hexagon) Remove gen_log_reg_write
The gen_log_reg_write function is a memnant of the original Hexagon
target design.  With the addition of gen_analyze_funcs.py and the
ability to short-circuit a packet commit, this function can be
removed.

Note that the implementation of gen_log_reg_write contains a check
of the register mutability mask.  This is only needed for control
registers, so we move it to gen_write_ctrl_reg.

We do need the gen_log_reg_write_pair function, but the name is
now misleading, so we change the name go gen_write_reg_pair.

Signed-off-by: Taylor Simpson <[email protected]>
Reviewed-by: Brian Cain <[email protected]>
Signed-off-by: Brian Cain <[email protected]>
2025-12-31 22:57:44 -06:00
Taylor Simpson e70fcf1c3e Hexagon (target/hexagon) analyze all reads before writes
I noticed that analyze_packet is marking the implicit pred reads after
marking all the writes.  However, the semantics of the instrucion and
packet are to do all the reads, then do the operation, then do all the
writes.

Here is the old code
static void analyze_packet(DisasContext *ctx)
{
    Packet *pkt = ctx->pkt;
    ctx->read_after_write = false;
    ctx->has_hvx_overlap = false;
    for (int i = 0; i < pkt->num_insns; i++) {
        Insn *insn = &pkt->insn[i];
        ctx->insn = insn;
        if (opcode_analyze[insn->opcode]) {
            opcode_analyze[insn->opcode](ctx);
        }
        mark_implicit_reg_writes(ctx);
        mark_implicit_pred_writes(ctx);
        mark_implicit_pred_reads(ctx);
    }

    ctx->need_commit = need_commit(ctx);
}

Recall that opcode_analyze[insn->opcode](ctx) will mark all the
explicit reads then all the explicit writes.

To properly handle the semantics, we'll create two new functions
    mark_implicit_reads
    mark_implicit_writes
Then we change gen_analyze_funcs.py to add a call to the former
after all the explicit reads and a call to the latter after all
the explicit_writes.

The reason this is an RFC patch is I can't find any instructions
where this distinction makes a difference in ctx->need_commit which
determines if the packet commit can be short-circuited.  However, this
could change in the future if the architecture introduces an
instruction with an implicit read of a register that is also written
(either implicit or explicit).  Then, anlayze_packet would detect
a read-after-write, and the packet would not short-circuit.  The
execution would be correct, but the performance would not be optimal.

Signed-off-by: Taylor Simpson <[email protected]>
Reviewed-by: Brian Cain <[email protected]>
Tested-by: Brian Cain <[email protected]>
Message-Id: <[email protected]>
Signed-off-by: Brian Cain <[email protected]>
2025-12-31 22:57:44 -06:00
Taylor Simpson fb7aceaf13 Hexagon (tests/tcg/hexagon) Add test for USR changes in packet
Signed-off-by: Taylor Simpson <[email protected]>
Reviewed-by: Brian Cain <[email protected]>
Signed-off-by: Brian Cain <[email protected]>
2025-12-31 22:57:44 -06:00
Taylor Simpson 3e98496691 Hexagon (target/hexagon) Implicit writes to USR don't force packet commit
Implicit writes to USR are only to specific fields of USR to indicate
side effects (e.g., saturation overflow, floating point status).
In these cases, we don't force a packet commit. This will allow more
packets to be short-circuited (avoid writing the results to temporaries).

When there is a packet commit with an implicit write to USR, we initialize
new_value_usr during gen_start_packet and write to USR in gen_reg_writes.

Reviewed-by: Brian Cain <[email protected]>
Signed-off-by: Taylor Simpson <[email protected]>
Signed-off-by: Brian Cain <[email protected]>
2025-12-31 22:57:44 -06:00
Taylor Simpson c2f724cfb7 Hexagon (target/hexagon) Add pkt_need_commit argument to arch_fpop_end
The arch_fpop_end function converts the softfloat fp_status flags to
bits set in Hexagon USR.  It is hard-coded that the packet must need
a commit.  We add an argument to the function and update all the helper
call sites.

In a subsequent commit, we will change the code that forces a commit
when the packet contains an floating point instruction.

Reviewed-by: Brian Cain <[email protected]>
Signed-off-by: Taylor Simpson <[email protected]>
Signed-off-by: Brian Cain <[email protected]>
2025-12-31 22:57:43 -06:00
Taylor Simpson c072bfd536 Hexagon (target/hexagon) Remove gen_tcg_func_table.py
This can easily be done in C with opcodes_def_generated.h.inc

Note that gen_tcg_func_table.py has some logic to skip instructions.
However, there aren't any instructions currently in the code that would
be skipped by this logic.  So, it is safe to base the table on the
complete opcodes table.

Signed-off-by: Taylor Simpson <[email protected]>
Reviewed-by: Brian Cain <[email protected]>
Tested-by: Brian Cain <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Brian Cain <[email protected]>
2025-12-31 22:57:43 -06:00
Richard Henderson 667e1fff87 Merge tag 'hw-misc-20251230' of https://github.com/philmd/qemu into staging
Misc HW patches

- Remove few target_ulong uses
- Make human monitor non-target specific
- Better name for TrustZone Peripheral Protection Controller memory regions
- Do not expose DEVICE_NATIVE_ENDIAN on Rust
- Remove address_space_stl_notdirty() and stl_phys_notdirty()
- Allow to restrict targets to legacy ldst_phys() API
- Fix MinGW-w64 link failure due to ConvertStringToBSTR()
- Header cleanups
- MAINTAINERS updates

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCAAdFiEE+qvnXhKRciHc/Wuy4+MsLN6twN4FAmlUPtEACgkQ4+MsLN6t
# wN5eVQ//cMeeYMl48XFmMlA1v0Ml8lbP/wzmgxyLM1DNHSVDGqBKArug+BdAPh2Q
# BiyWGj73FiQUi97m8Rfa8eR+LeBIOF/19uxVvJAGU61PHUCvvxzDUwRyuo3OjNjk
# JgnAmnf0iq9RRZas26fll2EV4CIibs97fR/FoKw9lKCvY1WY35O195fMChMRYzFo
# nUsPocatjr9RB8ZjCWlaP9sbqiI15r+WqhstfFC3uKBu0NlBfih1yRcSqYwW9jZl
# QoKERwGfrNvqvz/43wer0oGyidrDvgXFtAtGe/UWaj6EvqVikzZs2s6kMnIb+YC6
# 0k4hD/7/389ILYb3IqFknMZmXPN8xw/XfmQW8t4C/gJc/pkd0LYESE/Hs/R6lEOk
# MqgG8PeqdUtqSywnX3Hdayd+9p2n2mnlmiNqJFXZVRYTu0b/mM8jCPIJeID9PyNI
# rK6qGiBmznOs+iTaA/UMIKz0hj6KAmeibnTzby6k4SvdzK3QjesDSajeA8XLMhyL
# gayOxMhwNwW/zIwvCZ6MblI9kQaPf3oUtjjAsRPDOUgj2S44zR1VU3akynCa8RbA
# nEu5lA6umeIsIWFxf53aDZlEGXSReS6Zqk7QPLee1XW24hhdinX7Jb3dV8SPULDQ
# /A3WLY72KgtpN4Ap1MYWSerCKzyIqVwz4wwSHEOSEqXUnV/GMAU=
# =9ATS
# -----END PGP SIGNATURE-----
# gpg: Signature made Wed 31 Dec 2025 08:06:25 AM AEDT
# gpg:                using RSA key FAABE75E12917221DCFD6BB2E3E32C2CDEADC0DE
# gpg: Good signature from "Philippe Mathieu-Daudé (F4BUG) <[email protected]>" [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: FAAB E75E 1291 7221 DCFD  6BB2 E3E3 2C2C DEAD C0DE

* tag 'hw-misc-20251230' of https://github.com/philmd/qemu: (34 commits)
  MAINTAINERS: Change email and status of TriCore
  MAINTAINERS: remove old email for Bandan Das
  meson: Optimize summary_info about directories
  hw/i2c/imx: Fix trace func name error
  util: Move qemu_ftruncate64 from block/file-win32.c to oslib-win32.c
  qga/vss-win32: Fix ConvertStringToBSTR redefinition with newer MinGW
  configs/targets: Mark targets not using legacy ldst_phys() API
  hw/virtio: Reduce virtio_lduw/stw_phys_cached() scope
  hw/virtio: Remove unused ldst_phys() helpers
  configs/targets: Mark targets not using legacy ldst_phys() API
  system/memory: Allow restricting legacy ldst_phys() API usage
  system/memory: Remove address_space_stl_notdirty and stl_phys_notdirty
  hw/arm: Avoid address_space_stl_notdirty() when generating bootloader
  target/sparc: Update MMU page table using stl_phys()
  target/i386: Remove x86_stl_phys_notdirty() leftover
  target/hexagon: Include missing 'cpu.h' header in 'internal.h'
  rust/system: Stop exposing bogus DEVICE_NATIVE_ENDIAN symbol
  hw/char/pl011: Mark implementation as being little-endian
  hw/timer/hpet: Mark implementation as being little-endian
  hw/misc/pvpanic: Expose MMIO interface as little-endian
  ...

Signed-off-by: Richard Henderson <[email protected]>
2025-12-31 16:44:17 +11:00
Bastian Koppelmann 4bd2b65e52 MAINTAINERS: Change email and status of TriCore
I'm no longer employed at the university of Paderborn. This also means
my time available for QEMU has reduced significantly. Thus, I'm dropping
the status to odd fixes.

Signed-off-by: Bastian Koppelmann <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2025-12-30 20:38:41 +01:00
Stefan Hajnoczi 0057d7fac9 MAINTAINERS: remove old email for Bandan Das
Bandan recently left Red Hat and emails to his old address now result in
bounce messages. I contacted Bandan and he asked me to remove his old
address on his behalf.

Reported-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Stefan Hajnoczi <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2025-12-30 20:38:41 +01:00
Bin Guo 981a5a5c88 meson: Optimize summary_info about directories
Clear summary_info first, otherwise there will be redundant output
about build environment.

Signed-off-by: Bin Guo <[email protected]>
Tested-by: Alex Bennée <[email protected]>
Reviewed-by: Alex Bennée <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2025-12-30 20:38:41 +01:00
Alano Song 3fbadbb392 hw/i2c/imx: Fix trace func name error
Signed-off-by: Alano Song <[email protected]>
Fixes: e589c0ea9c ("hw/i2c/imx_i2c: Convert DPRINTF() to trace events")
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2025-12-30 20:38:41 +01:00
Nguyen Dinh Phi 0c9f429ec8 util: Move qemu_ftruncate64 from block/file-win32.c to oslib-win32.c
qemu_ftruncate64() is a general-purpose utility function that may be
used outside of the block layer. Move it to util/oslib-win32.c where
other Windows-specific utility functions reside.

Signed-off-by: Nguyen Dinh Phi <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2025-12-30 20:38:41 +01:00
Nguyen Dinh Phi c1df49269a qga/vss-win32: Fix ConvertStringToBSTR redefinition with newer MinGW
Newer versions of MinGW-w64 provide ConvertStringToBSTR() in the
_com_util namespace via <comutil.h>. This causes a redefinition
error when building qemu-ga on Windows with these toolchains.

Add a meson check to detect whether ConvertStringToBSTR is already
available, and conditionally compile our fallback implementation
only when the system does not provide one.

Signed-off-by: Nguyen Dinh Phi <[email protected]>
Suggested-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Kostiantyn Kostiuk <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2025-12-30 20:38:41 +01:00
Philippe Mathieu-Daudé 0f9150b250 configs/targets: Mark targets not using legacy ldst_phys() API
These targets were only using the legacy ldst_phys() API
via the virtio load/store helpers, which got cleaned up.

Mark them not using the legacy ldst_phys() API to avoid
further use, allowing to eventually remove it.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Manos Pitsidianakis <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <[email protected]>
2025-12-30 20:38:41 +01:00
Philippe Mathieu-Daudé 383112976b hw/virtio: Reduce virtio_lduw/stw_phys_cached() scope
virtio_lduw_phys_cached() and virtio_stw_phys_cached() are
only used within hw/virtio/virtio.c: reduce their scope by
moving their definitions there.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Manos Pitsidianakis <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <[email protected]>
2025-12-30 20:38:41 +01:00
Philippe Mathieu-Daudé dacddc5304 hw/virtio: Remove unused ldst_phys() helpers
None of the following virtio ldst_phys() inlined helpers are used:

 - virtio_lduw_phys()
 - virtio_ldl_phys[_cached]()
 - virtio_ldq_phys[_cached]()
 - virtio_stw_phys()
 - virtio_stl_phys[_cached]()

Just remove them.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Manos Pitsidianakis <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <[email protected]>
2025-12-30 20:38:41 +01:00
Philippe Mathieu-Daudé 0b223b17fe configs/targets: Mark targets not using legacy ldst_phys() API
Luckily these targets don't use the legacy ldst_phys() API at
all. Set the TARGET_NOT_USING_LEGACY_LDST_PHYS_API variable to
hide the API to them, avoiding further API uses to creep in.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Manos Pitsidianakis <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <[email protected]>
2025-12-30 20:38:41 +01:00
Philippe Mathieu-Daudé f4ea95c9ad system/memory: Allow restricting legacy ldst_phys() API usage
Commit 500131154d ("exec.c: Add new address_space_ld*/st*
functions") added a new API to fix a shortcoming of the
ld/st*_phys() API, which does blind bus access, not reporting
failure (and it also allow to provide transaction attributes).

Later commit 42874d3a8c ("Switch non-CPU callers from ld/st*_phys
to address_space_ld/st*") automatically converted the legacy uses
to the new API, not precising transaction attributes
(MEMTXATTRS_UNSPECIFIED) and ignoring the transation result (passing
NULL pointer as MemTxResult).

While this is a faithful replacement, without any logical change,
we later realized better is to not use MEMTXATTRS_UNSPECIFIED or
NULL MemTxResult, and adapt each call site on a pair basis, looking
at the device model datasheet to do the correct behavior (which is
unlikely to ignore transaction failures).

Since this is quite some work, we defer that to device model
maintainers. Meanwhile we introduce a definition, to allow a
target which removed all legacy API call to prohibit further
legacy API uses, named "TARGET_NOT_USING_LEGACY_LDST_PHYS_API".

Since all targets should be able to check this definition, we
take care to not poison it.

Suggested-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Manos Pitsidianakis <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <[email protected]>
2025-12-30 20:38:41 +01:00
Philippe Mathieu-Daudé f717405be6 system/memory: Remove address_space_stl_notdirty and stl_phys_notdirty
stl_phys_notdirty() was added in commit 8df1cd076c ("physical memory
access functions") as a (premature?) optimisation for the CODE path.
Meanwhile 20 years passed, we might never have understood / used it
properly; the code evolved and now the recommended way to access the
CODE path is via the cpu_ld/st_mmu*() API.

Remove both address_space_stl_notdirty() and stl_phys_notdirty()
leftovers.

Suggested-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <[email protected]>
2025-12-30 20:38:41 +01:00
Philippe Mathieu-Daudé 3800f80624 hw/arm: Avoid address_space_stl_notdirty() when generating bootloader
When using the '-kernel' command line option, a bootloader is
emitted, calling address_space_stl_notdirty().

The _notdirty() variant is supposed to /not/ mark the updated
CODE page as dirty, to not re-translate it. However this code
is only used with the '-kernel' CLI option after the machine
is created and /before/ the vCPUs run, and *only* during the
first (cold) reset; not during following (hot) resets. The
optimisation is totally not justified, since we haven't
translated any guest code yet.
Replace by the normal address_space_stl() helper.

Suggested-by: Richard Henderson <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <[email protected]>
2025-12-30 20:38:41 +01:00
Philippe Mathieu-Daudé a58ced9649 target/sparc: Update MMU page table using stl_phys()
stl_phys_notdirty() is supposed to do an optimized CODE
path store. Here we update the page table via the DATA
path, so can use the normal stl_phys() helper.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <[email protected]>
2025-12-30 20:38:41 +01:00
Philippe Mathieu-Daudé a24151dec6 target/i386: Remove x86_stl_phys_notdirty() leftover
Last use of x86_stl_phys_notdirty() was removed in commit 4a1e9d4d11
("target/i386: Use atomic operations for pte updates"), let's remove.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Reviewed-by: Zhao Liu <[email protected]>
Message-Id: <[email protected]>
2025-12-30 20:38:41 +01:00
Philippe Mathieu-Daudé 3f76eeb4b4 target/hexagon: Include missing 'cpu.h' header in 'internal.h'
Both CPUHexagonState and TOTAL_PER_THREAD_REGS are defined
in "cpu.h" which is luckily indirectly included. However when
refactoring unrelated files we get:

  In file included from target/hexagon/helper.h:18,
                   from include/exec/helper-proto.h.inc:56,
                   from include/exec/helper-proto.h:13,
                   from target/hexagon/op_helper.c:22:
  target/hexagon/internal.h: At top level:
  target/hexagon/internal.h:29:25: error: unknown type name ‘CPUHexagonState’; did you mean ‘CPUPluginState’?
     29 | void hexagon_debug_vreg(CPUHexagonState *env, int regnum);
        |                         ^~~~~~~~~~~~~~~
        |                         CPUPluginState
  target/hexagon/internal.h:30:25: error: unknown type name ‘CPUHexagonState’; did you mean ‘CPUPluginState’?
     30 | void hexagon_debug_qreg(CPUHexagonState *env, int regnum);
        |                         ^~~~~~~~~~~~~~~
        |                         CPUPluginState
  target/hexagon/internal.h:31:20: error: unknown type name ‘CPUHexagonState’; did you mean ‘CPUPluginState’?
     31 | void hexagon_debug(CPUHexagonState *env);
        |                    ^~~~~~~~~~~~~~~
        |                    CPUPluginState
  target/hexagon/internal.h:33:44: error: ‘TOTAL_PER_THREAD_REGS’ undeclared here (not in a function)
     33 | extern const char * const hexagon_regnames[TOTAL_PER_THREAD_REGS];
        |                                            ^~~~~~~~~~~~~~~~~~~~~

Fix that by including the missing header.

We don't need the "qemu/log.h" since commit 0cb73cb5a0 ("target/hexagon:
Remove HEX_DEBUG/HEX_DEBUG_LOG"): remove it.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Acked-by: Matheus Tavares Bernardino <[email protected]>
Reviewed-by: Brian Cain <[email protected]>
Message-Id: <[email protected]>
2025-12-30 20:38:41 +01:00
Philippe Mathieu-Daudé d97c8037bf rust/system: Stop exposing bogus DEVICE_NATIVE_ENDIAN symbol
We want to remove the bogus DEVICE_NATIVE_ENDIAN definition
(by only having it explicit, either big or little one). Stop
exposing it to rust devices to avoid it spreading further.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Reviewed-by: Manos Pitsidianakis <[email protected]>
Reviewed-by: Zhao Liu <[email protected]>
Message-Id: <[email protected]>
2025-12-30 20:38:40 +01:00
Philippe Mathieu-Daudé c715efe284 hw/char/pl011: Mark implementation as being little-endian
The PL011 component is only built / used by ARM targets, which
are only built in little endianness. Thus we only ever built
as little endian, never testing the big-endian possibility of
the DEVICE_NATIVE_ENDIAN definition. Simplify by only keeping
the little endian variant.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Reviewed-by: Manos Pitsidianakis <[email protected]>
Reviewed-by: Zhao Liu <[email protected]>
Message-Id: <[email protected]>
2025-12-30 20:38:40 +01:00
Philippe Mathieu-Daudé 56f7e42c47 hw/timer/hpet: Mark implementation as being little-endian
The HPET component is only built / used by X86 targets, which
are only built in little endianness. Thus we only ever built
as little endian, never testing the big-endian possibility of
the DEVICE_NATIVE_ENDIAN definition. Simplify by only keeping
the little endian variant.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Reviewed-by: Zhao Liu <[email protected]>
Message-Id: <[email protected]>
2025-12-30 20:38:40 +01:00
Philippe Mathieu-Daudé 5742fdb263 hw/misc/pvpanic: Expose MMIO interface as little-endian
Make the PVPanic MMIO interface behave like the ISA and PCI
variants: access it using little endianness.

Fixes: a89607c4d0 ("hw/misc/pvpanic: Add MMIO interface")
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Manos Pitsidianakis <[email protected]>
Message-Id: <[email protected]>
2025-12-30 20:38:40 +01:00
Philippe Mathieu-Daudé 56ae448867 hw/char/serial: Let compiler pick serial_mm_ops[] array length
No need to enforce the MemoryRegionOps array length.
We index by device_endian enum, the compiler will easily
pick the correct length. Besides, this allow further
adjustments in the device_endian enum itself.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <[email protected]>
2025-12-30 20:38:40 +01:00
Philippe Mathieu-Daudé ea85af3e87 hw/net/opencores: Clarify MMIO read/write handlers expect 32-bit access
The read/write handlers access array of 32-bit register by index:

 277 struct OpenEthState {
  ..
 287     uint32_t regs[REG_MAX];
  ..
 291 };

 546 static uint64_t open_eth_reg_read(void *opaque,
 547                                   hwaddr addr, unsigned int size)
 548 {
  ..
 551     OpenEthState *s = opaque;
 552     unsigned idx = addr / 4;
  ..
 559             v = s->regs[idx];
  ..
 563     return v;
 564 }

This is a 32-bit implementation. Make that explicit in the
MemoryRegionOps structure (this doesn't change the maximum
access size, which -- being unset -- is 64-bit).

Move the structure just after the handlers to ease code review.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <[email protected]>
2025-12-30 20:38:40 +01:00
Philippe Mathieu-Daudé bdae76b71f hw/arm/Kconfig: Have FSL_IMX6UL SoC select IMX_USBPHY
Since commit 17372bd812, the SoC used by the mcimx6ul-evk
machine requires the IMX USB PHY component.
As this component is only used by 2 machines, do not select
it by default (it will be automatically  selected when
necessary).

Fixes: 17372bd812 ("hw/arm/fsl-imx6ul: Wire up USB controllers")
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <[email protected]>
2025-12-30 20:38:40 +01:00
Philippe Mathieu-Daudé 26b4a6ffe7 monitor/hmp: Merge hmp-cmds-target.c within hmp-cmds.c
hmp-cmds-target.c is no more target specific, move its code
in hmp-cmds.c, which is built once for all system binaries.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Manos Pitsidianakis <[email protected]>
Message-Id: <[email protected]>
2025-12-30 20:38:40 +01:00
Philippe Mathieu-Daudé 8289e2528a monitor/hmp: Fix coding style in hmp-cmds-target.c
Previous to moving code contained in hmp-cmds-target.c,
fix the coding style. Otherwise the checkpatch.pl script
would report:

  ERROR: space required before the open parenthesis '('
  #134: FILE: monitor/hmp-cmds-target.c:152:
  +    switch(format) {

  ERROR: braces {} are necessary for all arms of this statement
  #154: FILE: monitor/hmp-cmds-target.c:172:
  +        if (l > line_size)
  [...]

  ERROR: space required before the open parenthesis '('
  #172: FILE: monitor/hmp-cmds-target.c:190:
  +            switch(wsize) {

  ERROR: space required before the open parenthesis '('
  #188: FILE: monitor/hmp-cmds-target.c:206:
  +            switch(format) {

  ERROR: Don't use '#' flag of printf format ('%#') in format strings, use '0x' prefix instead
  #190: FILE: monitor/hmp-cmds-target.c:208:
  +                monitor_printf(mon, "%#*" PRIo64, max_digits, v);

  WARNING: line over 80 characters
  #240: FILE: monitor/hmp-cmds-target.c:258:
  +        error_setg(errp, "No memory is mapped at address 0x%" HWADDR_PRIx, addr);

  WARNING: line over 80 characters
  #245: FILE: monitor/hmp-cmds-target.c:263:
  +        error_setg(errp, "Memory at address 0x%" HWADDR_PRIx " is not RAM", addr);

  ERROR: Don't use '#' flag of printf format ('%#') in format strings, use '0x' prefix instead
  #297: FILE: monitor/hmp-cmds-target.c:315:
  +        monitor_printf(mon, "gpa: %#" HWADDR_PRIx "\n",

  WARNING: line over 80 characters
  #329: FILE: monitor/hmp-cmds-target.c:347:
  +    ret = ((pinfo & 0x007fffffffffffffull) * pagesize) | (addr & (pagesize - 1));

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Manos Pitsidianakis <[email protected]>
Reviewed-by: Dr. David Alan Gilbert <[email protected]>
Message-Id: <[email protected]>
2025-12-30 20:38:40 +01:00
Philippe Mathieu-Daudé 540be542d1 monitor/hmp: Inline ld[uw,l,q]_p() calls in memory_dump()
Remove the last target-specificity in this file.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Manos Pitsidianakis <[email protected]>
Message-Id: <[email protected]>
2025-12-30 20:38:40 +01:00
Philippe Mathieu-Daudé c029aa1024 monitor/hmp: Remove target_long uses in memory_dump()
Pass a plain vaddr type to express virtual address.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Manos Pitsidianakis <[email protected]>
Message-Id: <[email protected]>
2025-12-30 20:38:40 +01:00
Philippe Mathieu-Daudé 6ad593a75a monitor/hmp: Use plain uint64_t @addr argument in memory_dump()
memory_dump() takes either hwaddr or vaddr type, depending
on the @is_physical argument. Simply use uint64_t type which
is common to both.
Pad address using field width formatting, removing the need
for the target_ulong type.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Manos Pitsidianakis <[email protected]>
Reviewed-by: Dr. David Alan Gilbert <[email protected]>
Message-Id: <[email protected]>
2025-12-30 20:38:40 +01:00
Philippe Mathieu-Daudé c46a13c505 monitor/hmp: Make memory_dump() @is_physical argument a boolean
Suggested-by: Dr. David Alan Gilbert <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Dr. David Alan Gilbert <[email protected]>
Reviewed-by: Manos Pitsidianakis <[email protected]>
Message-Id: <[email protected]>
2025-12-30 20:38:40 +01:00
Philippe Mathieu-Daudé d6db93d8e1 monitor/hmp: Replace target_ulong -> vaddr in hmp_gva2gpa()
cpu_get_phys_page_debug() takes a vaddr type since commit
00b941e581 ("cpu: Turn cpu_get_phys_page_debug() into a CPUClass
hook").

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Manos Pitsidianakis <[email protected]>
Reviewed-by: Dr. David Alan Gilbert <[email protected]>
Message-Id: <[email protected]>
2025-12-30 20:38:40 +01:00
Alex Bennée d0c84808ae hw/misc: make the tz-ppc-port names more useful
The TrustZone peripheral protection controller (tz-ppc) sits between
peripherals and the main system. However this results in "info mtree"
looking at bit confusing, especially as the sequence numbers can
overlap and miss steps:

      0000000000000000-ffffffffffffffff (prio -2, i/o): system
        0000000000000000-00000000003fffff (prio 0, i/o): tz-mpc-upstream
        0000000000400000-00000000007fffff (prio 0, i/o): alias ssram-0-alias @tz-mpc-upstream 0000000000000000-00000000003fffff
        0000000028000000-00000000281fffff (prio 0, i/o): tz-mpc-upstream
        0000000028200000-00000000283fffff (prio 0, i/o): tz-mpc-upstream
        0000000040080000-0000000040080fff (prio 0, i/o): iotkit-secctl-ns-regs
        0000000040100000-0000000040100fff (prio 0, i/o): tz-ppc-port[1]
        0000000040101000-0000000040101fff (prio 0, i/o): tz-ppc-port[2]
        0000000040102000-0000000040102fff (prio 0, i/o): tz-ppc-port[3]
        0000000040103000-0000000040103fff (prio 0, i/o): tz-ppc-port[4]
        0000000040110000-0000000040110fff (prio 0, i/o): tz-ppc-port[0]
        0000000040111000-0000000040111fff (prio 0, i/o): tz-ppc-port[1]
        0000000040112000-0000000040112fff (prio 0, i/o): tz-ppc-port[2]
        0000000040113000-0000000040113fff (prio 0, i/o): tz-ppc-port[3]
        0000000040200000-0000000040200fff (prio 0, i/o): tz-ppc-port[5]
        0000000040201000-0000000040201fff (prio 0, i/o): tz-ppc-port[6]
        0000000040202000-0000000040202fff (prio 0, i/o): tz-ppc-port[7]
        0000000040203000-0000000040203fff (prio 0, i/o): tz-ppc-port[8]
        0000000040204000-0000000040204fff (prio 0, i/o): tz-ppc-port[9]
        0000000040205000-0000000040205fff (prio 0, i/o): tz-ppc-port[0]
        0000000040206000-0000000040206fff (prio 0, i/o): tz-ppc-port[1]
        0000000040207000-0000000040207fff (prio 0, i/o): tz-ppc-port[10]
        0000000040208000-0000000040208fff (prio 0, i/o): tz-ppc-port[11]
        0000000040209000-0000000040209fff (prio 0, i/o): tz-ppc-port[2]
        000000004020a000-000000004020afff (prio 0, i/o): tz-ppc-port[3]
        000000004020b000-000000004020bfff (prio 0, i/o): tz-ppc-port[4]
        000000004020c000-000000004020cfff (prio 0, i/o): tz-ppc-port[12]
        000000004020d000-000000004020dfff (prio 0, i/o): tz-ppc-port[13]
        0000000040300000-0000000040300fff (prio 0, i/o): tz-ppc-port[0]
        0000000040301000-0000000040301fff (prio 0, i/o): tz-ppc-port[1]
        0000000040302000-0000000040302fff (prio 0, i/o): tz-ppc-port[2]
        0000000041000000-000000004113ffff (prio 0, i/o): tz-ppc-port[0]
        0000000042000000-00000000420000ff (prio 0, i/o): tz-ppc-port[5]
        0000000048007000-0000000048007fff (prio -1000, i/o): FPGA NS PC
        0000000050080000-0000000050080fff (prio 0, i/o): iotkit-secctl-s-regs
        0000000058007000-0000000058007fff (prio 0, i/o): tz-ppc-port[0]
        0000000058008000-0000000058008fff (prio 0, i/o): tz-ppc-port[1]
        0000000058009000-0000000058009fff (prio 0, i/o): tz-ppc-port[2]
        0000000080000000-0000000080ffffff (prio 0, ram): mps.ram

So as a quality of life feature lets expose the name of the underlying
region so we get something more useful:

    0000000000000000-ffffffffffffffff (prio -2, i/o): system
      0000000000000000-00000000003fffff (prio 0, i/o): tz-mpc-upstream
      0000000000400000-00000000007fffff (prio 0, i/o): alias ssram-0-alias @tz-mpc-upstream 0000000000000000-00000000003fffff
      0000000028000000-00000000281fffff (prio 0, i/o): tz-mpc-upstream
      0000000028200000-00000000283fffff (prio 0, i/o): tz-mpc-upstream
      0000000040080000-0000000040080fff (prio 0, i/o): iotkit-secctl-ns-regs
      0000000040100000-0000000040100fff (prio 0, i/o): tz-ppc-port[gpio0]
      0000000040101000-0000000040101fff (prio 0, i/o): tz-ppc-port[gpio1]
      0000000040102000-0000000040102fff (prio 0, i/o): tz-ppc-port[gpio2]
      0000000040103000-0000000040103fff (prio 0, i/o): tz-ppc-port[gpio3]
      0000000040110000-0000000040110fff (prio 0, i/o): tz-ppc-port[pl080]
      0000000040111000-0000000040111fff (prio 0, i/o): tz-ppc-port[pl080]
      0000000040112000-0000000040112fff (prio 0, i/o): tz-ppc-port[pl080]
      0000000040113000-0000000040113fff (prio 0, i/o): tz-ppc-port[pl080]
      0000000040200000-0000000040200fff (prio 0, i/o): tz-ppc-port[uart]
      0000000040201000-0000000040201fff (prio 0, i/o): tz-ppc-port[uart]
      0000000040202000-0000000040202fff (prio 0, i/o): tz-ppc-port[uart]
      0000000040203000-0000000040203fff (prio 0, i/o): tz-ppc-port[uart]
      0000000040204000-0000000040204fff (prio 0, i/o): tz-ppc-port[uart]
      0000000040205000-0000000040205fff (prio 0, i/o): tz-ppc-port[pl022]
      0000000040206000-0000000040206fff (prio 0, i/o): tz-ppc-port[pl022]
      0000000040207000-0000000040207fff (prio 0, i/o): tz-ppc-port[arm_sbcon_i2c]
      0000000040208000-0000000040208fff (prio 0, i/o): tz-ppc-port[arm_sbcon_i2c]
      0000000040209000-0000000040209fff (prio 0, i/o): tz-ppc-port[pl022]
      000000004020a000-000000004020afff (prio 0, i/o): tz-ppc-port[pl022]
      000000004020b000-000000004020bfff (prio 0, i/o): tz-ppc-port[pl022]
      000000004020c000-000000004020cfff (prio 0, i/o): tz-ppc-port[arm_sbcon_i2c]
      000000004020d000-000000004020dfff (prio 0, i/o): tz-ppc-port[arm_sbcon_i2c]
      0000000040300000-0000000040300fff (prio 0, i/o): tz-ppc-port[mps2-scc]
      0000000040301000-0000000040301fff (prio 0, i/o): tz-ppc-port[i2s-audio]
      0000000040302000-0000000040302fff (prio 0, i/o): tz-ppc-port[mps2-fpgaio]
      0000000041000000-000000004113ffff (prio 0, i/o): tz-ppc-port[gfx]
      0000000042000000-00000000420000ff (prio 0, i/o): tz-ppc-port[lan9118-mmio]
      0000000048007000-0000000048007fff (prio -1000, i/o): FPGA NS PC
      0000000050080000-0000000050080fff (prio 0, i/o): iotkit-secctl-s-regs
      0000000058007000-0000000058007fff (prio 0, i/o): tz-ppc-port[tz-mpc-regs]
      0000000058008000-0000000058008fff (prio 0, i/o): tz-ppc-port[tz-mpc-regs]
      0000000058009000-0000000058009fff (prio 0, i/o): tz-ppc-port[tz-mpc-regs]
      0000000080000000-0000000080ffffff (prio 0, ram): mps.ram

Signed-off-by: Alex Bennée <[email protected]>
Cc: Jim MacArthur <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
[PMD: Wrap long line to avoid checkpatch.pl warning]
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2025-12-30 20:38:40 +01:00
Anton Johansson ceaaeb2ad9 hw/riscv: Treat kernel_start_addr as vaddr
Changes kernel_start_addr from target_ulong to vaddr. Logically, the
argument represents a virtual address at which to load the kernel image,
which gets treated as a hwaddr as a fallback if elf and uimage loading
fails.

Suggested-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Anton Johansson <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2025-12-30 20:38:40 +01:00
Osama Abdelkader 70c0198ef3 hw/core: remove duplicate include
qemu/target-info.h is included twice.

Signed-off-by: Osama Abdelkader <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2025-12-30 20:38:40 +01:00
Bin Meng 426ca94938 hw/sd: Remove unused header includes in ssi-sd.c
Remove these header files which are not used by ssi-sd.c

Signed-off-by: Bin Meng <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
2025-12-30 20:38:40 +01:00
Richard Henderson 942b0d378a Merge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging
* cleanup include/hw headers
* cleanup memory headers
* rust: preludes
* rust: support for dtrace
* rust/hpet: first part of reorganization
* meson: small cleanups
* target/i386: Diamond Rapids CPU model including CET, APX, AVX10.2

# -----BEGIN PGP SIGNATURE-----
#
# iQFIBAABCgAyFiEE8TM4V0tmI4mGbHaCv/vSX3jHroMFAmlPov8UHHBib256aW5p
# QHJlZGhhdC5jb20ACgkQv/vSX3jHroPN1wf9HCceQ1273g7HbNeamay2bSaqypyM
# sEUBk4ipwO0dp7AYaaX5MeJ8NxeYcK82oFgm35WLY1tMOv0BZG5ez02dLoh5C4fb
# Bmy3kV1aY9cxF0IwTyD4dIADlZoaMnGgMElUKFY2/EixjxOUMLe90b1MO2KczqFa
# jvC4gmjx5PC1r+BHycSEdKm2Rbunueb/5eSkKeyTX7rjxQ/Eij0uGjrWrZkMWtgs
# ERJ2xo+D6a38w/uJ88KuqUV1BqYxNNwKmvOwVBU2xFB9o9bm20TNOJZ3+D+Ki8Aj
# idv+rU0XY1bWseo4USuozsqxfkjLJ5lj2YYUkSVO/I1wJmuO7Bq6xzrCxg==
# =/nIt
# -----END PGP SIGNATURE-----
# gpg: Signature made Sat 27 Dec 2025 08:12:31 PM AEDT
# gpg:                using RSA key F13338574B662389866C7682BFFBD25F78C7AE83
# gpg:                issuer "[email protected]"
# gpg: Good signature from "Paolo Bonzini <[email protected]>" [unknown]
# gpg:                 aka "Paolo Bonzini <[email protected]>" [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: 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: (152 commits)
  block: rename block/aio-wait.h to qemu/aio-wait.h
  block: rename block/aio.h to qemu/aio.h
  block: reduce files included by block/aio.h
  block: extract include/qemu/aiocb.h out of include/block/aio.h
  hw: add missing includes hidden by block/aio.h
  qmp: Fix thread race
  thread-pool: Fix thread race
  dosc/cpu-models-x86: Add documentation for DiamondRapids
  i386/cpu: Add CPU model for Diamond Rapids
  i386/cpu: Define dependency for VMX_VM_ENTRY_LOAD_IA32_FRED
  i386/cpu: Add an option in X86CPUDefinition to control CPUID 0x1f
  i386/cpu: Allow cache to be shared at thread level
  i386/cpu: Allow unsupported avx10_version with x-force-features
  i386/cpu: Add a helper to get host avx10 version
  i386/cpu: Support AVX10.2 with AVX10 feature models
  i386/cpu: Add support for AVX10_VNNI_INT in CPUID enumeration
  i386/cpu: Add CPUID.0x1E.0x1 subleaf for AMX instructions
  i386/cpu: Add support for MOVRS in CPUID enumeration
  run: introduce a script for running devel commands
  gitlab-ci: enable rust for msys2-64bit
  ...

Signed-off-by: Richard Henderson <[email protected]>
2025-12-29 09:10:40 +11:00
Paolo Bonzini 12e50722e4 block: rename block/aio-wait.h to qemu/aio-wait.h
AIO_WAIT_WHILE is used even outside the block layer; move the header file
out of block/ just like the implementation is in util/.

Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:12 +01:00
Paolo Bonzini ba773aded3 block: rename block/aio.h to qemu/aio.h
AioContexts are used as a generic event loop even outside the block
layer; move the header file out of block/ just like the implementation
is in util/.

Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:12 +01:00
Paolo Bonzini 238449947d block: reduce files included by block/aio.h
Avoid including all of qdev everywhere (the hw/core/qdev.h header in fact
brings in a lot more headers too), instead declare a couple structs for
which only a pointer type is needed.

Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:12 +01:00
Paolo Bonzini ddab0ef124 block: extract include/qemu/aiocb.h out of include/block/aio.h
Create a new header corresponding to functions defined in
util/aiocb.c, and include it whenever AIOCBs are used but
AioContext is not.

Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:12 +01:00
Paolo Bonzini e47deb1de5 hw: add missing includes hidden by block/aio.h
hw/qdev/core.h being included by core headers means that it was quite
easy to forget including it, or anything that hw/qdev/core.h included.
Add the missing inclusions.

Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:12 +01:00
Marc Morcos f3375b3945 qmp: Fix thread race
This fixes a thread race involving the monitor in monitor_qmp_event and monitor_qapi_event_emit .

Signed-off-by: Marc Morcos <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
[Use QEMU_LOCK_GUARD and "continue". - Paolo]
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:12 +01:00
Marc Morcos e77508292c thread-pool: Fix thread race
Fix a data race occurred between `worker_thread()` writing and
`thread_pool_completion_bh()` reading shared data in `util/thread-pool.c`.

Signed-off-by: Marc Morcos <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
[Use qatomic_set for writes to ret->ret. - Paolo]
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:12 +01:00
Zhao Liu b3104e721b dosc/cpu-models-x86: Add documentation for DiamondRapids
Current DiamondRapids hasn't supported cache model. Instead, document
its special CPU & cache topology to allow user emulate with "-smp" &
"-machine smp-cache".

Reviewed-by: Yu Chen <[email protected]>
Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:12 +01:00
Zhao Liu 7a6dd8bde1 i386/cpu: Add CPU model for Diamond Rapids
According to table 1-2 in Intel Architecture Instruction Set Extensions
and Future Features (rev 059), Diamond Rapids has the following new
features which have already been supported for guest:
 * SM4 (EVEX)
 * Intel Advanced Vector Extensions 10 Version 2 (Intel AVX10.2)
 * MOVRS and the PREFETCHRST2 instruction
 * AMX-MOVRS, AMX-AVX512, AMX-FP8, AMX-TF32
 * Intel Advanced Performance Extensions

And FRED - Flexible Return and Event Delivery (FRED) and the LKGS
instruction (introduced since Clearwater Forest & Diamond Rapids) - is
included in Diamond Rapids CPU model.

In addition, the following features are added into Diamond Rapids CPU
model:
 * CET: Control-flow Enforcement Technology (introduced since Sapphire
   Rapids & Sierra Forest).

Tested-by: Xudong Hao <[email protected]>
Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:12 +01:00
Zhao Liu 2580c66147 i386/cpu: Define dependency for VMX_VM_ENTRY_LOAD_IA32_FRED
VMX_VM_ENTRY_LOAD_IA32_FRED depends on FRED. Define this dependency
relationship.

Tested-by: Xudong Hao <[email protected]>
Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:12 +01:00
Zhao Liu 3d497826c3 i386/cpu: Add an option in X86CPUDefinition to control CPUID 0x1f
Many Intel CPUs enable CPUID 0x1f by default to encode CPU topology
information.

Add the "cpuid_0x1f" option to X86CPUDefinition to allow named CPU
models to configure CPUID 0x1f from the start, thereby forcing 0x1f
to be present for guest.

With this option, there's no need to explicitly add v1 model to an
unversioned CPU model for explicitly enabling the x-force-cpuid-0x1f
property.

Tested-by: Xudong Hao <[email protected]>
Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:12 +01:00
Zhao Liu 87ae7ab84f i386/cpu: Allow cache to be shared at thread level
In CPUID 0x4 leaf, it's possible to make the cache privated at thread
level when there's no HT within the core. In this case, while cache per
thread and cache per core are essentially identical, their topology
information differs in CPUID 0x4.

Diamond Rapids assigns the L1 i/d cache at the thread level. To allow
accurate emulation of DMR cache topology, remove the cache-per-thread
restriction in max_thread_ids_for_cache(), which enables CPUID 0x4 to
support cache per thread topology.

Given that after adding thread-level support, the topology offset
information required by max_thread_ids_for_cache() can be sufficiently
provided by apicid_offset_by_topo_level(), so it's straightforward to
re-implement max_thread_ids_for_cache() based on
apicid_offset_by_topo_level() to reduce redundant duplicate codes.

Tested-by: Xudong Hao <[email protected]>
Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:12 +01:00
Zhao Liu 86efa9340f i386/cpu: Allow unsupported avx10_version with x-force-features
The "force_features" ("x-force-features" property) forces setting
feature even if host doesn't support, but also reports the warning.

Given its function, it's useful for debug, so even if the AVX10
version is unsupported by host, force to set this AVX10 version if
x-force-features=on.

Tested-by: Xudong Hao <[email protected]>
Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:12 +01:00
Zhao Liu 61181166d0 i386/cpu: Add a helper to get host avx10 version
Factor out a helper to get host avx10 version, to reduce duplicate
codes.

Tested-by: Xudong Hao <[email protected]>
Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:12 +01:00
Zhao Liu 7c90fa647b i386/cpu: Support AVX10.2 with AVX10 feature models
Intel AVX10 Version 2 (Intel AVX10.2) includes a suite of new
instructions delivering new AI features and performance, accelerated
media processing, expanded Web Assembly, and Cryptography support, along
with enhancements to existing legacy instructions for completeness and
efficiency, and it is enumerated as version 2 in CPUID 0x24.0x0.EBX[bits
0-7] [*].

Considerring "Intel CPUs which support Intel AVX10.2 will include an
enumeration for AVX10_VNNI_INT (CPUID.24H.01H:ECX.AVX10_VNNI_INT[2])"
[*] and EVEX VPDP* instructions for INT8/INT16 (AVX10_VNNI_INT) are
detected by either AVX10.2 OR AVX10_VNNI_INT, AVX10_VNNI_INT is part of
AVX10.2, so any Intel AVX10.2 implementation lacking the AVX10_VNNI_INT
enumeration should be considered buggy hardware.

Therefore, it's necessary to set AVX10_VNNI_INT enumeration for Guest
when the user specifies AVX10 version 2. For this, introduce AVX10
models to explicitly define the feature bits included in different AVX10
versions.

[*]: Intel Advanced Vector Extensions 10.2 Architecture Specification
     (rev 5.0).

Tested-by: Xudong Hao <[email protected]>
Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:12 +01:00
Zhao Liu 24a9bc1088 i386/cpu: Add support for AVX10_VNNI_INT in CPUID enumeration
AVX10_VNNI_INT (0x24.0x1.ECX[bit 2]) is a discrete feature bit
introduced on Intel Diamond Rapids, which enumerates the support for
EVEX VPDP* instructions for INT8/INT16 [*].

Although Intel AVX10.2 has already included new VPDP* INT8/INT16 VNNI
instructions, a bit - AVX10_VNNI_INT - is still be separated. Relevant
new instructions can be checked by either CPUID AVX10.2 OR
AVX10_VNNI_INT (e.g., VPDPBSSD).

Support CPUID 0x24.0x1 subleaf with AVX10_VNNI_INT enumeration for
Guest.

[*]: Intel Advanced Vector Extensions 10.2 Architecture Specification
     (rev 5.0).

Tested-by: Xudong Hao <[email protected]>
Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:12 +01:00
Zhao Liu 956b8f0fc3 i386/cpu: Add CPUID.0x1E.0x1 subleaf for AMX instructions
Intel Diamond Rapids adds new AMX instructions to support new formats
and memory operations [*]. And it introduces the CPUID subleaf 0x1E.0x1
to centralize the discrete AMX feature bits within EAX.

For new feature bits (CPUID 0x1E.0x1.EAX[bits 4,6-8]), it's
straightforward to add their enurmeration support.

In addition to the new features, CPUID 0x1E.0x1.EAX[bits 0-3] are
mirrored positions of existing AMX feature bits distributing across
the 0x7 leaves. It's not flexible to make these mirror bits have the
same names as existing ones, because QEMU would try to set both original
bit and mirror bit which would cause warning if host doesn't support
0x1E.0x1 subleaf. Thus, name these mirror bits with "*-mirror" suffix.

[*]: Intel Architecture Instruction Set Extensions and Future Features
     (rev.059).

Tested-by: Xudong Hao <[email protected]>
Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:12 +01:00
Zhao Liu f8e830300c i386/cpu: Add support for MOVRS in CPUID enumeration
MOVRS is a new set of instructions introduced in the Intel platform
Diamond Rapids, to load instructions that carry a read-shared hint.

Functionally, MOVRS family is equivalent to existing load instructions,
but its read-shared hint indicates the source memory location is likely
to become read-shared by multiple processors, i.e., read in the future
by at least one other processor before it is written (assuming it is
ever written in the future). It could optimize the behavior of the
caches, especially shared caches, for this data for future reads by
multiple processors. Additionally, MOVRS family also includes a software
prefetch instruction, PREFETCHRST2, that carries the same read-shared
hint. [*]

MOVRS family is enumerated by CPUID single-bit (0x7.0x1.EAX[bit 31]).
Add its enumeration support.

[*]: Intel Architecture Instruction Set Extensions and Future Features
     (rev.059).

Tested-by: Xudong Hao <[email protected]>
Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:12 +01:00
Daniel P. Berrangé 757a9c91a6 run: introduce a script for running devel commands
Various aspects of the development workflow are complicated by the need
to set env variables ahead of time, or use specific paths. Meson
provides a 'devenv' command that can be used to launch a command with a
number of appropriate project specific environment variables preset.

By default it will modify $PATH to point to any build directory that
contains a binary built by the project.

This further augments that to replicate the venv 'activate' script:

 * Add $BUILD_DIR/pyvenv/bin to $PATH
 * Set VIRTUAL_ENV to $BUILD_DIR/pyvenv

And then makes functional tests more easily executable

 * Add $SRC_DIR/tests/functional and $SRC_DIR/python to $PYTHONPATH

To see the benefits of this consider this command:

  $ source ./build/pyvenv/bin/activate
  $ ./scripts/qmp/qmp-shell-wrap ./build/qemu-system-x86_64

which is now simplified to

  $ ./build/run ./scripts/qmp/qmp-shell-wrap qemu-system-x86_64 [args..]

This avoids the need repeat './build' several times and avoids polluting
the current terminal's environment and/or avoids errors from forgetting
to source the venv settings.

As another example running functional tests

  $ export PYTHONPATH=./python:./tests/functional
  $ export QEMU_TEST_QEMU_BINARY=./build/qemu-system-x86_64
  $ build/pyvenv/bin/python3 ./tests/functional/x86_64/test_virtio_version.py

which is now simplified to

  $ export QEMU_TEST_QEMU_BINARY=qemu-system-x86_64
  $ ./build/run ./tests/functional/x86_64/test_virtio_version.py

This usefulness of this will be further enhanced with the pending
removal of the QEMU python APIs from git, as that will require the use
of the python venv in even more scenarios that today.

The 'run' script does not let 'meson devenv' directly launch the command
to be run because it always requires $BUILD_DIR as the current working
directory. It is desired that 'run' script always honour the current
working directory of the terminal that invokes is. Thus the '--dump'
flag is used to export the devenv variables into the 'run' script's
shell.

This takes the liberty to assign 'run.in' to the "Build system" section
in the MAINTAINERS file, given that it leverages meson's 'devenv'
feature.

Signed-off-by: Daniel P. Berrangé <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:12 +01:00
Marc-André Lureau 1a69483616 gitlab-ci: enable rust for msys2-64bit
Signed-off-by: Marc-André Lureau <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:12 +01:00
Paolo Bonzini 1dc162f5a3 rust: skip compilation if there are no system emulators
Otherwise, the Rust crates require the corresponding C code
(e.g. migration/ for rust/migration/) but the dependencies of
that C code, for example the trace files, have not been built.

Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:12 +01:00
Paolo Bonzini e12799fc61 target/i386/tcg: commonize code to compute SF/ZF/PF
PF/ZF/SF are computed the same way for almost all CC_OP values (depending
only on the operand size in the case of ZF and SF).  The only exception is
PF for CC_OP_BLSI* and CC_OP_BMILG*; but AMD documents that PF should
be computed normally (rather than being undefined) so that is a kind of
bug fix.

Put the common code at the end of helper_cc_compute_all, shaving
another kB from its text.

Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:12 +01:00
Paolo Bonzini 7e7d54fc60 target/i386/tcg: move fetch code out of translate.c
Let translate.c only concern itself with TCG code generation.  Move everything
that uses CPUX86State*, as well as gen_lea_modrm_0 now that it is only used
to fill decode->mem, to decode-new.c.inc.

While at it also rename gen_lea_modrm_0.

Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:12 +01:00
Paolo Bonzini 14b0bc53a1 target/i386/tcg: add a CCOp for SBB x,x
This is more efficient both when generating code and when testing
flags.

Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:12 +01:00
Paolo Bonzini bffe7ed95f target/i386/tcg: kill tmp2_i32
Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:12 +01:00
Paolo Bonzini b4e9c687f3 target/i386/tcg: kill tmp1_i64
Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:12 +01:00
Paolo Bonzini fb2efb0667 target/i386/tcg: unify more pop/no-pop x87 instructions
Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:12 +01:00
Paolo Bonzini dcc2b436c1 target/i386/tcg: reuse gen_helper_fp_arith_ST0_FT0 for undocumented fcom/fcomp variants
For 0x32 hack the op to be fcomp; for the others there isn't even anything special
to do.

Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:12 +01:00
Paolo Bonzini 2326789c91 target/i386/tcg: reuse gen_helper_fp_arith_ST0_FT0 for fcom STn and fcomp STn
Treat specially the undocumented ops, instead of treating specially the
two d8/0 opcodes that have undocumented variants: just call
gen_helper_fp_arith_ST0_FT0 for all opcodes in the d8/0 encoding.

Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:12 +01:00
Paolo Bonzini 7a1ec17e3f target/i386/tcg: move fcom/fcomp differentiation to gen_helper_fp_arith_ST0_FT0
There is only one call site for gen_helper_fp_arith_ST0_FT0(), therefore
there is no need to check the op1 == 3 in the caller.  Once this is done,
eliminate the goto to that call site.

Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:12 +01:00
Paolo Bonzini e8a1d23f24 target/i386/tcg: unnest switch statements in disas_insn_x87
Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:12 +01:00
Paolo Bonzini 55a15eb350 target/i386/tcg: simplify effective address calculation
Split gen_lea_v_seg_dest into three simple phases (extend from
16 bits, add, final extend), with optimization for known-zero bases
to avoid back-to-back extensions.

Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:12 +01:00
Paolo Bonzini 2b230c4989 target/i386/tcg: move and expand misplaced comment
Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:12 +01:00
Paolo Bonzini 73c2d62079 target/i386/tcg: remove do_decode_0F
It is not needed anymore since all prefixes are handled by the
new decoder.

Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:11 +01:00
Paolo Bonzini da7649c6ae target/i386/tcg: do not compute all flags for SAHF
Only OF is needed, the others are overwritten.

Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:11 +01:00
Paolo Bonzini a71706fc11 target/i386/tcg: mark more instructions that are invalid in 64-bit mode
Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:11 +01:00
Paolo Bonzini e661e2d7a3 target/i386/tcg: update cc_op after PUSHF
PUSHF already needs to compute the full eflags; set the cc_op to
CC_OP_EFLAGS to avoid duplicate computation in subsequent code.

Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:11 +01:00
Paolo Bonzini 0db1b556e4 target/i386/tcg: ignore V3 in 32-bit mode
From the manual: "In 64-bit mode all 4 bits may be used. [...]
In 32-bit and 16-bit modes bit 6 must be 1 (if bit 6 is not 1, the
2-byte VEX version will generate LDS instruction and the 3-byte VEX
version will ignore this bit)."

Cc: [email protected]
Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:11 +01:00
Andrew Cooper 60efba3c1b target/i386: Fix #GP error code for INT instructions
While the (intno << shift) expression is correct for indexing the IDT based on
whether Long Mode is active, the error code itself was unchanged with AMD64,
and is still the index with 3 bits of metadata in the bottom.

Found when running a Xen unit test, all under QEMU.  The unit test objected to
being told there was an error with IDT index 256 when INT $0x80 (128) was the
problem instruction:

  ...
  Error: Unexpected fault 0x800d0802, #GP[IDT[256]]
  ...

Fixes: d2fd1af767 ("x86_64 linux user emulation")
Signed-off-by: Andrew Cooper <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Cc: [email protected]
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3160
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:11 +01:00
Zhao Liu 5839e9a1cc i386/cpu: Drop incorrect comment for CPUID 0x1E
The information (tmul_maxk and tmul_maxn) in CPUID 0x1E.0x0.EBX is
defined for architecture, not for SPR.

This is to say, these "hardcoded" values won't change in future. If
the TMUL component needs to be extended for new palettes, there'll
likely be the new TMUL instructions, or new types of AMX instructions
that are _parallel_ to TMUL that operate in particular palettes,
instead of changing current tmul_maxk and tmul_maxn fields in CPUID
0x1E.0x0.EBX.

Furthermore, the previous attempt [*] to make the 0x1E.0x0.EBX fields
user-configurable is incorrect and unnecessary.

Therefore, drop the incorrect and misleading comment.

[*]: https://lore.kernel.org/qemu-devel/[email protected]/

Signed-off-by: Zhao Liu <[email protected]>
Reviewed-by: Xiaoyao Li <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:11 +01:00
Zhao Liu 2bc19a5449 i386/cpu: Drop incorrect comment for CPUID 0x1D
The information in CPUID 0x1D.0x1 is for tile palette 1, and is not
SPR-specific.

This is to say, these "hardcoded" values won't change in future. If
the palette needs to be extended, a new tile palette (maybe in a new
subleaf) will be introduced instead of changing current information of
tile palette 1.

Furthermore, the previous attempt [*] to make the 0x1D.0x1 fields
user-configurable is incorrect and unnecessary.

Therefore, drop the incorrect and misleading comment.

[*]: https://lore.kernel.org/qemu-devel/[email protected]/

Signed-off-by: Zhao Liu <[email protected]>
Reviewed-by: Xiaoyao Li <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:11 +01:00
Paolo Bonzini e8bb12c350 meson: let Meson handle mixed-language linking of Rust and C objects
With the bump to Meson 1.10.0, C objects can be passed to rust targets.
This way, the Rust libstd will be added by rustc itself in its final
linker invocation.  Use that to eliminate the staticlib and allow
dynamic linking with libstd (also introduced by Meson 1.9.0, but not
for staticlib crates due to lack of support in rustc).

The main() function is still provided by C, which is possible by
declaring the main source file of the Rust executable (which is
still created by scripts/rust/rust_root_crate.sh) as #![no_main].

Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:11 +01:00
Paolo Bonzini e12d608b59 rust: Meson now adds -Cdefault-linker-libraries
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:11 +01:00
Marc-André Lureau dce5471366 cirrus/macos: enable Rust
Signed-off-by: Marc-André Lureau <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:11 +01:00
Paolo Bonzini d8779cb5d6 lcitool: enable Rust for Windows cross targets
The issue that is mentioned in the comment has been fixed.

Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:11 +01:00
Paolo Bonzini 4d06424c3d rust: only link the Rust part of the code into devices
Do not include libqemuutil in the device crates for the same
reason as in the previous commit.  Static libraries like qemuutil
are sensitive to their position on the command line and rustc does not
always get it right.

If rustc places the library too early on the command line, the stubs
are included in the final link product, which results in duplicate
symbols.

Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:11 +01:00
Martin Kletzander 9be6962015 rust: Do not link qemuutil into Rust rlibs
Commit de037ab8d83d removed qemuutil dependency from chardev and util
rust crates.  However it stayed in the _util_rs static library.  The
dependency is also defined as `link_with`, which is fine for C targets,
where the resulting archive gets linked as another parameter on the
command line when it is a static library.

However, when a C library is linked into a Rust rlib, rustc remembers
the dependency into the metadata and adds the library to the linker
command line.

Unfortunately, static libraries are sensitive to their
position on the command line and rustc does not always get it right.
Fortunately, simply removing it from dependencies of any rust libraries
and instead adding them into the dependencies of executables and
doctests fixes the behaviour.

Without this patch the error I get is:

  FAILED: [code=1] rust/tests/rust-integration
  ...
  = note: rust-lld: error: unable to find library -l:libqemuutil.a
          rust-lld: error: unable to find library -l:libvhost-user-glib.a
          rust-lld: error: unable to find library -l:libvhost-user.a
          rust-lld: error: unable to find library -l:libqemuutil.a
          rust-lld: error: unable to find library -l:libvhost-user-glib.a
          rust-lld: error: unable to find library -l:libvhost-user.a
          rust-lld: error: unable to find library -l:libqemuutil.a
          rust-lld: error: unable to find library -l:libvhost-user-glib.a
          rust-lld: error: unable to find library -l:libvhost-user.a
          rust-lld: error: unable to find library -l:libqemuutil.a
          rust-lld: error: unable to find library -l:libvhost-user-glib.a
          rust-lld: error: unable to find library -l:libvhost-user.a
          rust-lld: error: unable to find library -l:libqemuutil.a
          rust-lld: error: unable to find library -l:libvhost-user-glib.a
          rust-lld: error: unable to find library -l:libvhost-user.a
          rust-lld: error: unable to find library -l:libqemuutil.a
          rust-lld: error: unable to find library -l:libvhost-user-glib.a
          rust-lld: error: unable to find library -l:libvhost-user.a
          collect2: error: ld returned 1 exit status

Meson could work around it itself by never adding these static libraries
to the rlibs (after all, Meson tracks the transitive dependencies already
and knows how to add them to dependents of those rlibs); at least for now,
do it in QEMU: never link C libraries into Rust rlibs, and add them to the
final build products only.

Signed-off-by: Martin Kletzander <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:11 +01:00
Paolo Bonzini 8c04b6a48b bump meson wheel to 1.10.0
This version includes several improvements and bugfixes for Rust.

Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:11 +01:00
Paolo Bonzini a7ab886b6e tests/meson: do not reuse migration_files variable
The variable is defined in migration/meson.build, reusing it is confusing.

Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:11 +01:00
Paolo Bonzini 9103b40f4f build: do not include @block.syms/@qemu.sys with modules disabled
Including specific symbols used by modules is not necessary for
monolithic executables.  This avoids a failure where emcc does not
support @file syntax inside a response file---which in turn breaks
the WebAssembly build if the command line is long enough that meson
decides to use a response file.

Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:11 +01:00
Zhao Liu 016dddf240 i386/cpu: Mark APX xstate as migratable
APX xstate is user xstate. The related registers are cached in
X86CPUState. And there's a vmsd "vmstate_apx" to migrate these
registers.

Thus, it's safe to mark it as migratable.

Tested-by: Xudong Hao <[email protected]>
Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:11 +01:00
Zhao Liu 60caf14339 i386/cpu: Support APX CPUIDs
APX is enumerated by CPUID.(EAX=0x7, ECX=1).EDX[21]. And this feature
bit also indicates the existence of dedicated CPUID leaf 0x29, called
the Intel APX Advanced Performance Extensions Leaf.

This new CPUID leaf now is populated with enumerations for a select
set of Intel APX sub-features.

CPUID.(EAX=0x29, ECX=0)
 - EAX
   * Maximum Subleaf CPUID.(EAX=0x29, ECX=0).EAX[31:0] = 0
 - EBX
   * Reserved CPUID.(EAX=0x29, ECX=0).EBX[31:1] = 0
   * APX_NCI_NDD_NF CPUID.(EAX=0x29, ECX=0).EBX[0:0] = 1, which
     enumerates the presence of New Conditional Instructions (NCIs),
     explicit New Data Destination (NDD) controls, and explicit Flags
     Suppression (NF) controls for select sets of EVEX-encoded Intel
     APX instructions (present in EVEX map=4, and EVEX map=2 0x0F38).
 - ECX
   * Reserved CPUID.(EAX=0x29, ECX=0).ECX[31:0] = 0
 - EDX
   * Reserved CPUID.(EAX=0x29, ECX=0).EDX[31:0] = 0

Note, APX_NCI_NDD_NF is documented as always enabled for Intel
processors since APX spec (revision v7.0). Now any Intel processor
that enumerates support for APX_F (CPUID.(EAX=0x7, ECX=1).EDX[21])
will also enumerate support for APX_NCI_NDD_NF.

Tested-by: Xudong Hao <[email protected]>
Co-developed-by: Zide Chen <[email protected]>
Signed-off-by: Zide Chen <[email protected]>
Co-developed-by: Peter Fang <[email protected]>
Signed-off-by: Peter Fang <[email protected]>
Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:11 +01:00
Zide Chen e105745d20 i386/cpu: Add APX migration support
Add a VMStateDescription to migrate APX EGPRs.

Tested-by: Xudong Hao <[email protected]>
Signed-off-by: Zide Chen <[email protected]>
Co-developed-by: Zhao Liu <[email protected]>
Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:11 +01:00
Zhao Liu 103b49bc64 i386/monitor: Support EGPRs in hmp_print
Add EGPRs in monitor_defs[] to allow HMP to access EGPRs.

For example,

(qemu) print $r16

Since monitor_defs[] is used for read-only case, no need to consider
xstate synchronization issues that might be caused by modifying EGPRs
(like what gdbstub did).

Suggested-by: Paolo Bonzini <[email protected]>
Tested-by: Xudong Hao <[email protected]>
Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:11 +01:00
Zhao Liu 1d5d97583d i386/cpu-dump: Dump entended GPRs for APX supported guest
Dump EGPRs when guest supports APX.

Suggested-by: Paolo Bonzini <[email protected]>
Tested-by: Xudong Hao <[email protected]>
Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:11 +01:00
Zhao Liu f46e5073a8 i386/gdbstub: Add APX support for gdbstub
Add i386-64bit-apx.xml from gdb to allow QEMU gdbstub parse APX EGPRs,
and implement the callbacks to allow gdbstub access EGPRs of guest.

Suggested-by: Paolo Bonzini <[email protected]>
Tested-by: Xudong Hao <[email protected]>
Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:11 +01:00
Zide Chen 1b1cf88937 i386/cpu: Cache EGPRs in CPUX86State
Expend general registers array "regs" of CPUX86State to cache entended
GPRs.

Tested-by: Xudong Hao <[email protected]>
Signed-off-by: Zide Chen <[email protected]>
Co-developed-by: Zhao Liu <[email protected]>
Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:11 +01:00
Zhao Liu bb9f99e9ba i386/machine: Use VMSTATE_UINTTL_SUB_ARRAY for vmstate of CPUX86State.regs
Before expanding the number of elements in the CPUX86State.regs array,
first use VMSTATE_UINTTL_SUB_ARRAY for the regs' vmstate to avoid the
type_check_array failure.

VMSTATE_UINTTL_SUB_ARRAY will also be used for subsequently added elements
in regs array.

Tested-by: Xudong Hao <[email protected]>
Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:11 +01:00
Zide Chen 91bc4d8107 i386/cpu: Add APX EGPRs into xsave area
APX feature bit is in CPUID_7_1_EDX[21], and APX has EGPR component with
index 19 in xstate area, EGPR component has 16 64bit regs. Add EGRP
component into xstate area.

Note, APX re-uses the 128-byte XSAVE area that had been previously
allocated by MPX which has been deprecated on Intel processors, so check
whether APX and MPX are set at the same for Guest, if this case happens,
mask off them both to avoid conflict for xsave area.

Tested-by: Xudong Hao <[email protected]>
Signed-off-by: Zide Chen <[email protected]>
Co-developed-by: Zhao Liu <[email protected]>
Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:11 +01:00
Chenyi Qiang 12ef9d4ed3 i386/tdx: Add CET SHSTK/IBT into the supported CPUID by XFAM
So that it can be configured in TD guest.

And considerring CET_U and CET_S bits are always same in supported
XFAM reported by TDX module, i.e., either 00 or 11. So, only need to
choose one of them.

Tested-by: Farrah Chen <[email protected]>
Reviewed-by: Xiaoyao Li <[email protected]>
Signed-off-by: Chenyi Qiang <[email protected]>
Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:11 +01:00
Zhao Liu 133e89cca3 i386/tdx: Fix missing spaces in tdx_xfam_deps[]
The checkpatch.pl always complains: "ERROR: space required after that
close brace '}'".

Fix this issue.

Tested-by: Farrah Chen <[email protected]>
Reviewed-by: Xiaoyao Li <[email protected]>
Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:11 +01:00
Zhao Liu 5cb89cad7f i386/cpu: Enable cet-ss & cet-ibt for supported CPU models
Add new versioned CPU models for Sapphire Rapids, Sierra Forest, Granite
Rapids and Clearwater Forest, to enable shadow stack and indirect branch
tracking.

Tested-by: Farrah Chen <[email protected]>
Reviewed-by: Xiaoyao Li <[email protected]>
Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:11 +01:00
Yang Weijiang 2f25476ae7 i386/cpu: Advertise CET related flags in feature words
Add SHSTK and IBT flags in feature words with entry/exit
control flags.

CET SHSTK and IBT feature are enumerated via CPUID(EAX=7,ECX=0)
ECX[bit 7] and EDX[bit 20]. CET states load/restore at vmentry/
vmexit are controlled by VMX_ENTRY_CTLS[bit 20] and VMX_EXIT_CTLS[bit 28].
Enable these flags so that KVM can enumerate the features properly.

Tested-by: Farrah Chen <[email protected]>
Reviewed-by: Xiaoyao Li <[email protected]>
Signed-off-by: Yang Weijiang <[email protected]>
Co-developed-by: Chao Gao <[email protected]>
Signed-off-by: Chao Gao <[email protected]>
Co-developed-by: Zhao Liu <[email protected]>
Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:11 +01:00
Zhao Liu 54db912495 i386/cpu: Mark cet-u & cet-s xstates as migratable
Cet-u and cet-s are supervisor xstates. Their states are saved/loaded by
saving/loading related CET MSRs. And there're the "vmstate_cet" and
"vmstate_pl0_ssp" to migrate these MSRs.

Thus, it's safe to mark them as migratable.

Tested-by: Farrah Chen <[email protected]>
Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:11 +01:00
Yang Weijiang 93608c99bd i386/machine: Add vmstate for cet-shstk and cet-ibt
Add vmstates for cet-shstk and cet-ibt

Tested-by: Farrah Chen <[email protected]>
Signed-off-by: Yang Weijiang <[email protected]>
Co-developed-by: Chao Gao <[email protected]>
Signed-off-by: Chao Gao <[email protected]>
Co-developed-by: Zhao Liu <[email protected]>
Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:11 +01:00
Xin Li (Intel) a5b163fa22 i386/cpu: Migrate MSR_IA32_PL0_SSP for FRED and CET-SHSTK
Both FRED and CET-SHSTK need MSR_IA32_PL0_SSP, so add the vmstate for
this MSR.

When CET-SHSTK is not supported, MSR_IA32_PL0_SSP keeps accessible, but
its value doesn't take effect. Therefore, treat this vmstate as a
subsection rather than a fix for the previous FRED vmstate.

Tested-by: Farrah Chen <[email protected]>
Signed-off-by: Xin Li (Intel) <[email protected]>
Co-developed-by: Zhao Liu <[email protected]>
Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:11 +01:00
Yang Weijiang b775eff300 i386/kvm: Add save/restore support for KVM_REG_GUEST_SSP
CET provides a new architectural register, shadow stack pointer (SSP),
which cannot be directly encoded as a source, destination or memory
operand in instructions. But Intel VMCS & VMCB provide fields to
save/load guest & host's ssp.

It's necessary to save & restore Guest's ssp before & after migration.
To support this, KVM implements Guest's SSP as a special KVM internal
register - KVM_REG_GUEST_SSP, and allows QEMU to save & load it via
KVM_GET_ONE_REG/KVM_SET_ONE_REG.

Cache KVM_REG_GUEST_SSP in X86CPUState.

Tested-by: Farrah Chen <[email protected]>
Reviewed-by: Xiaoyao Li <[email protected]>
Signed-off-by: Yang Weijiang <[email protected]>
Co-developed-by: Chao Gao <[email protected]>
Signed-off-by: Chao Gao <[email protected]>
Co-developed-by: Zhao Liu <[email protected]>
Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:11 +01:00
Yang Weijiang b6f85c5e45 i386/kvm: Add save/restore support for CET MSRs
CET (architectural) MSRs include:
MSR_IA32_U_CET - user mode CET control bits.
MSR_IA32_S_CET - supervisor mode CET control bits.
MSR_IA32_PL{0,1,2,3}_SSP - linear addresses of SSPs for user/kernel modes.
MSR_IA32_INT_SSP_TAB - linear address of interrupt SSP table

Since FRED also needs to save/restore MSR_IA32_PL0_SSP, to avoid duplicate
operations, make FRED only save/restore MSR_IA32_PL0_SSP when CET-SHSTK
is not enumerated.

And considerring MSR_IA32_SSP_TBL_ADDR is only presented on 64 bit
processor, wrap it with TARGET_X86_64 macro.

For other MSRs, add save/restore support directly.

Tested-by: Farrah Chen <[email protected]>
Suggested-by: Xin Li (Intel) <[email protected]>
Signed-off-by: Yang Weijiang <[email protected]>
Co-developed-by: Chao Gao <[email protected]>
Signed-off-by: Chao Gao <[email protected]>
Co-developed-by: Zhao Liu <[email protected]>
Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:10 +01:00
Xin Li (Intel) 0fa1025904 i386/cpu: Save/restore SSP0 MSR for FRED
Both FRED and CET shadow stack define the MSR MSR_IA32_PL0_SSP (aka
MSR_IA32_FRED_SSP0 in FRED spec).

MSR_IA32_PL0_SSP is a FRED SSP MSR, so that if a processor doesn't
support CET shadow stack, FRED transitions won't use MSR_IA32_PL0_SSP,
but this MSR would still be accessible using MSR-access instructions
(e.g., RDMSR, WRMSR).

Therefore, save/restore SSP0 MSR for FRED.

Tested-by: Farrah Chen <[email protected]>
Signed-off-by: Xin Li (Intel) <[email protected]>
Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:10 +01:00
Zhao Liu ad88fb1bd5 i386/cpu: Add CET support in CR4
CR4.CET bit (bit 23) is as master enable for CET.
Check and adjust CR4.CET bit based on CET CPUIDs.

Tested-by: Farrah Chen <[email protected]>
Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:10 +01:00
Yang Weijiang e46dcef1d0 i386/cpu: Enable xsave support for CET states
Add CET_U/S bits in xstate area and report support in xstate
feature mask.
MSR_XSS[bit 11] corresponds to CET user mode states.
MSR_XSS[bit 12] corresponds to CET supervisor mode states.

CET Shadow Stack(SHSTK) and Indirect Branch Tracking(IBT) features
are enumerated via CPUID.(EAX=07H,ECX=0H):ECX[7] and EDX[20]
respectively, two features share the same state bits in XSS, so
if either of the features is enabled, set CET_U and CET_S bits
together.

Tested-by: Farrah Chen <[email protected]>
Reviewed-by: Xiaoyao Li <[email protected]>
Signed-off-by: Yang Weijiang <[email protected]>
Co-developed-by: Chao Gao <[email protected]>
Signed-off-by: Chao Gao <[email protected]>
Co-developed-by: Zhao Liu <[email protected]>
Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:10 +01:00
Zhao Liu 54fed32ec1 i386/cpu: Add missing migratable xsave features
Xtile-cfg & xtile-data are both user xstates. Their xstates are cached
in X86CPUState, and there's a related vmsd "vmstate_amx_xtile", so that
it's safe to mark them as migratable.

Arch lbr xstate is a supervisor xstate, and it is save & load by saving
& loading related arch lbr MSRs, which are cached in X86CPUState, and
there's a related vmsd "vmstate_arch_lbr". So it should be migratable.

PT is still unmigratable since KVM disabled it and there's no vmsd and
no other emulation/simulation support.

Note, though the migratable_flags get fixed,
x86_cpu_enable_xsave_components() still overrides supported xstates
bitmaps regardless the masking of migratable_flags. This is another
issue, and would be fixed in follow-up refactoring.

Tested-by: Farrah Chen <[email protected]>
Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:10 +01:00
Chao Gao 95a945c61d i386/cpu: Fix supervisor xstate initialization
Arch lbr is a supervisor xstate, but its area is not covered in
x86_cpu_init_xsave().

Fix it by checking supported xss bitmap.

In addition, drop the (uint64_t) type casts for supported_xcr0 since
x86_cpu_get_supported_feature_word() returns uint64_t so that the cast
is not needed. Then ensure line length is within 90 characters.

Tested-by: Farrah Chen <[email protected]>
Reviewed-by: Xiaoyao Li <[email protected]>
Signed-off-by: Chao Gao <[email protected]>
Co-developed-by: Zhao Liu <[email protected]>
Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:10 +01:00
Zhao Liu 6f2f0f76d0 i386/cpu: Drop pmu check in CPUID 0x1C encoding
Since CPUID_7_0_EDX_ARCH_LBR will be masked off if pmu is disabled,
there's no need to check CPUID_7_0_EDX_ARCH_LBR feature with pmu.

Tested-by: Farrah Chen <[email protected]>
Reviewed-by: Zide Chen <[email protected]>
Reviewed-by: Xiaoyao Li <[email protected]>
Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:10 +01:00
Zhao Liu 7fa4830317 i386/cpu: Reorganize dependency check for arch lbr state
The arch lbr state has 2 dependencies:
 * Arch lbr feature bit (CPUID 0x7.0x0:EDX[bit 19]):

   This bit also depends on pmu property. Mask it off if pmu is disabled
   in x86_cpu_expand_features(), so that it is not needed to repeatedly
   check whether this bit is set as well as pmu is enabled.

   Note this doesn't need compat option, since even KVM hasn't support
   arch lbr yet.

   The supported xstate is constructed based such dependency in
   cpuid_has_xsave_feature(), so if pmu is disabled and arch lbr bit is
   masked off, then arch lbr state won't be included in supported
   xstates.

   Thus it's safe to drop the check on arch lbr bit in CPUID 0xD
   encoding.

 * XSAVES feature bit (CPUID 0xD.0x1.EAX[bit 3]):

   Arch lbr state is a supervisor state, which requires the XSAVES
   feature support. Enumerate supported supervisor state based on XSAVES
   feature bit in x86_cpu_enable_xsave_components().

   Then it's safe to drop the check on XSAVES feature support during
   CPUID 0XD encoding.

Suggested-by: Zide Chen <[email protected]>
Tested-by: Farrah Chen <[email protected]>
Reviewed-by: Zide Chen <[email protected]>
Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:10 +01:00
Zhao Liu d88caf0954 i386/cpu: Use x86_ext_save_areas[] for CPUID.0XD subleaves
The x86_ext_save_areas[] is expected to be well initialized by
accelerators and its xstate detail information cannot be changed by
user. So use x86_ext_save_areas[] to encode CPUID.0XD subleaves directly
without other hardcoding & masking.

And for arch LBR, KVM fills its xstate in x86_ext_save_areas[] via
host_cpuid(). The info obtained this way matches what would be retrieved
from x86_cpu_get_supported_cpuid() (since KVM just fills CPUID with the
host xstate info directly anyway). So just use the initialized
x86_ext_save_areas[] instead of calling x86_cpu_get_supported_cpuid().

Tested-by: Farrah Chen <[email protected]>
Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:10 +01:00
Zhao Liu 9a15846f56 i386/cpu: Add avx10 dependency for Opmask/ZMM_Hi256/Hi16_ZMM
With feature array in ExtSaveArea, add avx10 as the second dependency
for Opmask/ZMM_Hi256/Hi16_ZMM xsave components, and drop the special
check in cpuid_has_xsave_feature().

Tested-by: Farrah Chen <[email protected]>
Reviewed-by: Xiaoyao Li <[email protected]>
Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:10 +01:00
Zhao Liu bf9a8bdbc1 i386/cpu: Make ExtSaveArea store an array of dependencies
Some XSAVE components depend on multiple features. For example, Opmask/
ZMM_Hi256/Hi16_ZMM depend on avx512f OR avx10, and for CET (which will
be supported later), cet_u/cet_s will depend on shstk OR ibt.

Although previously there's the special check for the dependencies of
AVX512F OR AVX10 on their respective XSAVE components (in
cpuid_has_xsave_feature()), to make the code more general and avoid
adding more special cases, make ExtSaveArea store a features array
instead of a single feature, so that it can describe multiple
dependencies.

Tested-by: Farrah Chen <[email protected]>
Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:10 +01:00
Zhao Liu d625b216a6 i386/cpu: Reorganize arch lbr structure definitions
- Move ARCH_LBR_NR_ENTRIES macro and LBREntry definition before XSAVE
  areas definitions.
- Reorder XSavesArchLBR (area 15) between XSavePKRU (area 9) and
  XSaveXTILECFG (area 17), and reorder the related QEMU_BUILD_BUG_ON
  check to keep the same ordering.

This makes xsave structures to be organized together and makes them
clearer.

Tested-by: Farrah Chen <[email protected]>
Reviewed-by: Zide Chen <[email protected]>
Reviewed-by: Xiaoyao Li <[email protected]>
Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:10 +01:00
Zhao Liu 44d536df3f i386/cpu: Clean up arch lbr xsave struct and comment
Arch LBR state is area 15, not 19. Fix this comment. And considerring
other areas don't mention user or supervisor state, for consistent
style, remove "Supervisor mode" from its comment.

Moreover, rename XSavesArchLBR to XSaveArchLBR since there's no need to
emphasize XSAVES in naming; the XSAVE related structure is mainly
used to represent memory layout.

In addition, arch lbr specifies its offset of xsave component as 0. But
this cannot help on anything. The offset of ExtSaveArea is initialized
by accelerators (e.g., hvf_cpu_xsave_init(), kvm_cpu_xsave_init() and
x86_tcg_cpu_xsave_init()), so explicitly setting the offset doesn't
work and CPUID 0xD encoding has already ensure supervisor states won't
have non-zero offsets. Drop the offset initialization and its comment
from the xsave area of arch lbr.

Tested-by: Farrah Chen <[email protected]>
Reviewed-by: Zide Chen <[email protected]>
Reviewed-by: Xiaoyao Li <[email protected]>
Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:10 +01:00
Zhao Liu d14e7ab950 i386/cpu: Clean up indent style of x86_ext_save_areas[]
The indentation style in `x86_ext_save_areas[]` is extremely
inconsistent. Clean it up to ensure a uniform style.

Tested-by: Farrah Chen <[email protected]>
Reviewed-by: Xiaoyao Li <[email protected]>
Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:10 +01:00
Dr. David Alan Gilbert 806108519c qemu-options.hx: Document -M as -machine alias
-M is used heavily in documentation and scripts, but isn't actually
documented anywhere.

Document it as equivalent to -machine, also moving to -machine the sole
suboption that was documented under -M.

Reported-by: Julian Andres Klode <[email protected]>
Signed-off-by: Dr. David Alan Gilbert <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:10 +01:00
Paolo Bonzini 3d508e096b tracetool: add Rust DTrace/SystemTap SDT support
Implement DTrace/SystemTap SDT by emitting the following:
- The probe crate's probe!() macro is used to emit a DTrace/SystemTap
  SDT probe.
- Every trace event gets a corresponding trace_<name>_enabled() -> bool
  generated function that Rust code can use to avoid expensive
  computation when a trace event is disabled. This API works for other
  trace backends too.

`#[allow(dead_code)]` additions are necessary for QEMU's dstate in
generated trace-<dir>.rs files since they are unused by the dtrace
backend. `./configure --enable-trace-backends=` can enable multiple
backends, so keep it simple and just silence the warning instead of
trying to detect the condition when generating the dstate code can be
skipped.

The tracetool tests are updated. Take a look at
tests/tracetool/dtrace.rs to see what the new generated code looks like.

Signed-off-by: Stefan Hajnoczi <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:10 +01:00
Stefan Hajnoczi cd9fe9265c subprojects: add probe crate
The probe crate (https://crates.io/crates/probe) provides a probe!()
macro that defines SystemTap SDT probes on Linux hosts or does nothing
on other host OSes.

This crate will be used to implement DTrace support for Rust.

Signed-off-by: Stefan Hajnoczi <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:10 +01:00
Paolo Bonzini 4536693a72 rust/hpet: change wrap_flag to a bool
This is more precise, and makes it possible to use bool::then_some().

Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:10 +01:00
Zhao Liu 0448840adb rust/hpet: Apply Migratable<> wrapper and ToMigrationState
Before using Mutex<> to protect HPETRegisters, it's necessary to apply
Migratable<> wrapper and ToMigrationState first since there's no
pre-defined VMState for Mutex<>.

In addition, this allows to move data from HPETRegisters' vmstate
to HPETTimer's, so as to preserve the original migration format of the C
implementation.  To do that, HPETTimer is wrapped with Migratable<>
as well but the implementation of ToMigrationStateShared is
hand-written.

Note that even though the HPETRegistersMigration struct is
generated by ToMigrationState macro, its VMState still needs to be
implemented by hand.

Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
[Added HPETTimer implementation and restored compatible migration format. - Paolo]
Reviewed-by: Zhao Liu <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:10 +01:00
Paolo Bonzini 9947bf9351 rust: migration: implement ToMigrationState for Timer
Timer is a complex struct, allow adding it to a struct that
uses #[derive(ToMigrationState)]; similar to vmstate_timer, only
the expiration time has to be preserved.

In fact, because it is thread-safe, ToMigrationStateShared can
also be implemented without needing a cell or mutex that wraps
the timer.

Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:10 +01:00
Paolo Bonzini 709beed426 rust: timer: add bindings to timer_mod_ns and timer_expire_time_ns
These are needed to implement ToMigrationStateShared for timers,
and thus allow including them in Migratable<> structs.

Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:10 +01:00
Paolo Bonzini 6660b5a1a8 rust/hpet: move hpet_offset to HPETRegisters
Likewise, do not separate hpet_offset from the other registers.
However, because it is migrated in a subsection it is necessary
to copy it out of HPETRegisters and into a BqlCell<>.

Reviewed-by: Zhao Liu <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:10 +01:00
Paolo Bonzini 56dbc824a2 rust/hpet: remove BqlRefCell around HPETTimer
HPETTimer now has all of its state stored in HPETRegisters, so it does not
need its own BqlRefCell anymore.

Reviewed-by: Zhao Liu <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:10 +01:00
Paolo Bonzini ef43216317 rust/hpet: move hidden registers to HPETTimerRegisters
Do not separate visible and hidden state; both of them are used in the
same circumstances and it's easiest to place both of them under the
same BqlRefCell.

Reviewed-by: Zhao Liu <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:10 +01:00
Zhao Liu aef4e4637d rust/hpet: Borrow BqlRefCell<HPETRegisters> at top level
Lockless IO requires to lock the registers during MMIO access. So it's
necessary to get (or borrow) registers data at top level, and not to
borrow again in child function calls.

Change the argument types from BqlRefCell<HPETRegisters> to
&HPETRegisters/&mut HPETRegisters in child methods, and do borrow the
data once at top level.

This allows BqlRefCell<HPETRegisters> to be directly replaced with
Mutex<HPETRegisters> in subsequent steps without causing lock reentrancy
issues.

Note, passing reference instead of BqlRef/BqlRefMut because BqlRefMut
cannot be re-borrowed as BqlRef, though BqlRef/BqlRefMut themselves play
as the "guard". Passing reference is directly and the extra
bql::is_locked check could help to consolidate safety guarantee.

Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:10 +01:00
Zhao Liu 4e6223c727 rust/hpet: Maintain HPETTimerRegisters in HPETRegisters
Lockless IO requires holding a single lock during MMIO access, so that
it's necessary to maintain timer N's registers (HPETTimerRegisters) with
global register in one place.

Therefore, move HPETTimerRegisters to HPETRegisters from HPETTimer, and
access timer registers from HPETRegisters struct for the whole HPET
code.

This changes HPETTimer and HPETRegisters, and the layout of VMState has
changed, which makes it incompatible to migrate with previous versions.
Thus, bump up the version IDs in VMStates of HPETState and HPETTimer.

The VMState version IDs of HPETRegisters doesn't need to change since
it's a newly added struct and its version IDs doesn't affect the
compatibility of HPETState's VMState.

Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:10 +01:00
Zhao Liu d25964880f rust/hpet: Pass &BqlRefCell<HPETRegisters> as argument during MMIO access
Currently in HPETTimer context, the global registers are accessed by
dereferring a HPETState raw pointer stored in NonNull<>, and then
borrowing the BqlRefCel<>.

This blocks borrowing HPETRegisters once during MMIO access, and
furthermore prevents replacing BqlRefCell<> with Mutex<>.

Therefore, do not access global registers through NonNull<HPETState>
and instead passing &BqlRefCell<HPETRegisters> as argument in
function calls within MMIO access.

But there's one special case that is timer handler, which still needs
to access HPETRegistsers through NonNull<HPETState>. It's okay for now
since this case doesn't have any repeated borrow() or lock reentrancy
issues.

Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:10 +01:00
Zhao Liu b7d1deefc3 rust/hpet: Explicitly initialize complex fields in init()
Explicitly initialize more fields which are complex structures.

For simple types (bool/u32/usize), they can be omitted since C has
already initialized memory to all zeros and this is the valid
initialization for those simple types.

Previously such complex fields (InterruptSource/BqlCell/BqlRefCell) were
not explicitly initialized in init() and it's fine, because simply
setting all memory to zero aligns with their default initialization
behavior. However, this behavior is not robust. When adding new complex
struct or modifying the initial values of existing structs, this default
behavior can easily be broken.

Thus, do explicit initialization for HPET to become a good example.

Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:10 +01:00
Zhao Liu e3b5a1190a rust/hpet: Borrow HPETState.regs once in HPETState::post_load()
Timers in post_load() access the same HPETState, which is the "self"
HPETState.

So there's no need to access HPETState from child HPETTimer again and
again. Instead, just cache and borrow HPETState.regs at the beginning,
and this could save some CPU cycles and reduce borrow() calls.

It's safe, because post_load() is called with BQL protection, so that
there's no other chance to modify the regs.

Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:10 +01:00
Zhao Liu 2abee243d6 rust/hpet: Make global register accessors as methods of HPETRegisters
Implement helper accessors as methods of HPETRegisters. Then
HPETRegisters can be accessed without going through HPETState.

In subsequent refactoring, coarser-grained BQL lock protection will be
implemented. Specifically, BqlRefCell<HPETRegisters> will be borrowed
only once during MMIO accesses, and the scope of borrowed `regs` will
be extended to cover the entire MMIO access. Consequently, repeated
borrow() attempts within function calls will no longer be allowed.

Therefore, refactor the accessors of HPETRegisters to bypass HPETState,
which help to reduce borrow() in deep function calls.

Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:10 +01:00
Zhao Liu 8375fbaf48 rust/hpet: Abstract HPETRegisters struct
Place all HPET (global) timer block registers in a HPETRegisters struct,
and wrap the whole register struct with a BqlRefCell<>.

This allows to elevate the Bql check from individual register access to
register structure access, making the Bql check more coarse-grained. But
in current step, just treat BqlRefCell as BqlCell while maintaining
fine-grained BQL protection. This approach helps to use HPETRegisters
struct clearly without introducing the "already borrowed" around
BqlRefCell.

HPETRegisters struct makes it possible to take a Mutex<> to replace
BqlRefCell<>, like C side did.

Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:10 +01:00
Zhao Liu 9259f47dc9 rust/hpet: Make timer register accessors as methods of HPETTimerRegisters
Implement helper accessors as methods of HPETTimerRegisters. Then
HPETTimerRegisters can be accessed without going through HPETTimer or
HPETState.

In subsequent refactoring, HPETTimerRegisters will be maintained at the
HPETState level. However, accessing it through HPETState requires the
lock (lock BQL or mutex), which would cause troublesome nested locks or
reentrancy issues.

Therefore, refactor the accessors of HPETTimerRegisters to bypass
HPETTimer or HPETState.

Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:10 +01:00
Zhao Liu 349b931e61 rust/hpet: Abstract HPETTimerRegisters struct
Place all timer N's registers in a HPETTimerRegisters struct.

This allows all Timer N registers to be grouped together with global
registers and managed using a single lock (BqlRefCell or Mutex) in
future. And this makes it easier to apply ToMigrationState macro.

Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:10 +01:00
Zhao Liu 335395270f rust/hpet: Rename decoded "reg" enumeration to "target"
HPETAddrDecode has a `reg` field so that there're many variables named
"reg" in MMIO read/write/decode functions.

In the future, there'll be other HPETRegisters/HPETTimerRegisters
structs containing values of HPET registers, and related variables or
arguments will be named as "regs".

To avoid potential confusion between many "reg" and "regs", rename
HPETAddrDecode::reg to HPETAddrDecode::target, and rename decoding
related variables from "reg" to "target".

"target" is picked as the name since this clearly reflects the field or
variable is the target decoded register.

Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:10 +01:00
Zhao Liu 4a104f9451 rust/hpet: Rename HPETRegister to DecodedRegister
HPETRegister represents the layout of register spaces of HPET timer
block and timer N, and is used to decode register address into register
enumeration.

To avoid confusion with the subsequently introduced HPETRegisters (that
is used to maintain values of HPET registers), rename HPETRegister to
DecodedRegister.

Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:10 +01:00
Zhao Liu f5839d2774 rust/hpet: Reduce unnecessary mutable self argument
Methods of Timer and InterruptSource have been made as safe, so make the
related methods of HPETTimer to accept immutable self reference.

Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:10 +01:00
Zhao Liu 0118c2d7e8 rust/bql: Ensure BQL locked early at BqlRefCell borrowing
At present, BqlRefCell checks whether BQL is locked when it blocks BQL
unlock (in bql_block_unlock).

But the such check should be done earlier - at the beginning of
BqlRefCell borrowing.

So convert BqlRefCell::borrow field from Cell<> to BqlCell<>, to
guarantee BQL is locked from the beginning when someone is trying to
borrow BqlRefCell.

Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:10 +01:00
Zhao Liu febdab3d5d rust/migration: Check name field in VMStateDescriptionBuilder
The name field is necessary for VMStateDescription, so that it's
necessary to check if it is set when build VMStateDescription.

Since is_null()/as_ref() become rustc v1.84 and pointer cannot cast to
integer in const, use Option<> to check name with a new field in
VMStateDescriptionBuilder instead.

This can be simplified in future when QEMU bumps up rustc version.

Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:10 +01:00
Zhao Liu bb6e3e743a rust/migration: Fix missing name in the VMSD of Migratable<>
The VMStateDescription of Migratable<T> missed the name field, and this
casused segmentation fault in vmstate_save_state_v() when it tries to
write name field by json_writer_str().

Due to the limitation of const, a custom name based on type would be
more difficult. Instead, a straightforward and simple approach is to
have all Migratable<T> instances use the same VMSD name -
"migratable-wrapper".

This is availiable because Migratable<T> is always a field within a
VMSD, and its parent VMSD should have a distinct name.

Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:10 +01:00
Zhao Liu 4ace4aa133 rust/migration: Add Sync implementation for Migratable<>
It's common to define MemoryRegionOps<T> and VMStateDescription<T> as
static variables, and this requires T to implement Sync.

Migratable<T> is usually embedded in device state, so it's necessary to
implement Sync for Migratable<T>.

Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:10 +01:00
Stefan Hajnoczi 751535943e rust/hpet: add trace events
Implement the same trace events as the C implementation.

Notes:
- Keep order of hpet_ram_write_invalid_tn_cmp and hpet_ram_write_tn_cmp
  the same as the C implementation.
- Put hpet_ram_write_timer_id in HPETTimer::write() instead of
  HPETState::decode() so that reads can be excluded.

Signed-off-by: Stefan Hajnoczi <[email protected]>
Reviewed-by: Manos Pitsidianakis <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:10 +01:00
Stefan Hajnoczi da5eacf9d1 hpet: remove unused trace events
Signed-off-by: Stefan Hajnoczi <[email protected]>
Reviewed-by: Manos Pitsidianakis <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:10 +01:00
Paolo Bonzini 8218c7a704 qom: add more to the prelude
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:10 +01:00
Paolo Bonzini c0eb26603d system: add prelude
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:10 +01:00
Paolo Bonzini 2ff035b7c7 bql: add prelude
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:10 +01:00
Paolo Bonzini cd6e5449da chardev: add prelude
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:09 +01:00
Paolo Bonzini e560f257b2 migration: add prelude
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:09 +01:00
Paolo Bonzini ea9a5074b1 hwcore: add prelude
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:09 +01:00
Paolo Bonzini d30bb44c57 common: add prelude
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:09 +01:00
Paolo Bonzini 6b4a0683af util: add prelude
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:09 +01:00
Paolo Bonzini f0768791b5 rust: move strict lints handling to meson.build
Simplify rustc_args.py, and align its code with what Meson's own Cargo.toml
translator does in v1.10.

Bump unknown_lints to "forbid", so that it will certainly override Cargo.toml's
"allow" level.

Reviewed-by: Zhao Liu <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:09 +01:00
Paolo Bonzini 34f66fdfd2 rust: hide panicking default associated constants from rustdoc
Work around rustdoc issue that panics while trying to evaluate
the constants.

Reviewed-by: Zhao Liu <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:09 +01:00
Paolo Bonzini 966eee573a rust: fix reference to MemoryRegion
Use the wrapper struct, not the C one.

Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:09 +01:00
Paolo Bonzini ebf3fb9a53 rust: do not copy the SysBusDevice
Reviewed-by: Zhao Liu <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:09 +01:00
Paolo Bonzini e65030ed50 rust: remove unnecessary repetitive options
Reviewed-by: Zhao Liu <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:09 +01:00
Paolo Bonzini 06556a6b2b rust: remove unused --cfg arguments
Reviewed-by: Zhao Liu <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:09 +01:00
Marc-André Lureau cef5629f83 rust: remove leftover bindings/
Reviewed-by: Zhao Liu <[email protected]>
Signed-off-by: Marc-André Lureau <[email protected]>
2025-12-27 10:11:09 +01:00
Paolo Bonzini 7f548b8f23 include: reorganize memory API headers
Move RAMBlock functions out of ram_addr.h and cpu-common.h;
move memory API headers out of include/exec and into include/system.

Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:09 +01:00
Paolo Bonzini 048a23851c include: move hw/hw.h to hw/core/, rename
Call it include/hw/core/hw-error.h since that is the only
thing it contains.

Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:09 +01:00
Paolo Bonzini 9f6b0553eb include: move hw/vmstate-if.h to hw/core/
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:08 +01:00
Paolo Bonzini c755f3b959 include: move hw/sysbus.h to hw/core/
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:08 +01:00
Paolo Bonzini 5d39d7d1e9 include: move hw/stream.h to hw/core/
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:08 +01:00
Paolo Bonzini 4b64d23a7e include: move hw/resettable.h to hw/core/
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:08 +01:00
Paolo Bonzini 8c7d406c88 include: move hw/register.h to hw/core/
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:08 +01:00
Paolo Bonzini 3e7316044d include: move hw/registerfields.h to hw/core/
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:08 +01:00
Paolo Bonzini e1e9a72500 include: move hw/qdev-properties-system.h to hw/core/
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:08 +01:00
Paolo Bonzini 78d45220b4 include: move hw/qdev-properties.h to hw/core/
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:07 +01:00
Paolo Bonzini f7889f86bd include: move hw/qdev-dma.h to hw/core/
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:07 +01:00
Paolo Bonzini d1000ecae2 include: move hw/qdev-core.h to hw/core/, rename
Call it hw/core/qdev.h to avoid the duplication in the name.

Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:07 +01:00
Paolo Bonzini 3775d19906 include: move hw/qdev-clock.h to hw/core/
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:07 +01:00
Paolo Bonzini a5d7e646f6 include: move hw/ptimer.h to hw/core/
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:07 +01:00
Paolo Bonzini c094dd45b7 include: move hw/platform-bus.h to hw/core/
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:07 +01:00
Paolo Bonzini 23bde89a92 include: move hw/or-irq.h to hw/core/
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:07 +01:00
Paolo Bonzini ca07b6a94b include: move hw/nmi.h to hw/core/
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:07 +01:00
Paolo Bonzini fc9ba01724 include: move hw/loader.h to hw/core/
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:07 +01:00
Paolo Bonzini da0fad21f4 include: move hw/loader-fit.h to hw/core/
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:07 +01:00
Paolo Bonzini 32222dc3bb include: move hw/irq.h to hw/core/
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:06 +01:00
Paolo Bonzini 02b7f04702 include: move hw/hotplug.h to hw/core/
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:06 +01:00
Paolo Bonzini d1526663f2 include: move hw/fw-path-provider.h to hw/core/
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:06 +01:00
Paolo Bonzini 838861a1f9 include: move hw/clock.h to hw/core/
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:06 +01:00
Paolo Bonzini 1942b61b74 include: move hw/boards.h to hw/core/
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:06 +01:00
Paolo Bonzini 78476202e4 include: move hw/usb.h to hw/usb/
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:06 +01:00
Paolo Bonzini c611228c0e include: move memory_ldst* to include/system
These partial headers are only included via system/memory.h, so keep them in
the same directory.

Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:06 +01:00
Paolo Bonzini e4e1105949 include: name the MemReentrancyGuard struct
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:05 +01:00
Nicholas Mosier 5304f36748 i386/tcg/svm: fix comma operator typo
A comma operator inappropriately terminates an expression
in svm_helper.c. Replace it with a semicolon.

Signed-off-by: Nicholas Mosier <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
2025-12-27 10:11:05 +01:00
Richard Henderson 5887cb3e2b Merge tag 'qtest-20251226-pull-request' of https://gitlab.com/farosas/qemu into staging
Qtest pull request

- Fix tests using deprecated machine versions

# -----BEGIN PGP SIGNATURE-----
#
# iQJEBAABCAAuFiEEqhtIsKIjJqWkw2TPx5jcdBvsMZ0FAmlOxGMQHGZhcm9zYXNA
# c3VzZS5kZQAKCRDHmNx0G+wxnQ8jEACKyE525JVTSBqa7UTVpU1WMmViHGYoQY1S
# bbGHTnWuMMXHFw0ptF1nMRQbKSZvtOJ7BDYDs/lYhNzKCJJ47/WkHyv9npUH1ttl
# jSbbZz0iN5RrIkRvVv3paiJ+uh3pCOSnThh86eUCf8W+7lwpulYVM5AUTg7cc7Lh
# sTCDbVp6im/tB5ePySUTp7edSc+tEXe1NufmKxOfw7znvn0Aqj+31F5KV39GvyQb
# CpaoPxVI6l6F489EcDiwzLXGoOTG6pmIx0fvDiHiC+u41lwLL/dDsWfXS03EdQmu
# GXD0SKSp7ta0QhxvhSlmasM/YqNIeXGGdNeAEVvoZdV9jm3KIFZViOqa7ObPxlGO
# h8ZBM3mwkDzLcszp1F1UF5a0HoBUv7F788W1Ocn3QEumFS2UmOG1xJ6vWhBCWOyC
# n6XrA9ollxuqpBL+wkZF1fKeFWQp0+umsaosQoC1l3+dw0MIgwf0wwncMD0XNMhO
# L3pRkH/kgNo0C6U4CwujpXtel3Q0C51+6kSzpKFUgpt/5Igd30jdDEszbrv1HKFB
# ZrTOuTFPOPIH9+BVZYbId4deyUUcs0zUNUO+xpizBuq4kNg1npxGLJO77kNYOSdJ
# TurJcyAkwQp9Wd0kcMzXOVA0qKJvmsWtX36GCBhrecaW+sWLq8b8uYv8LBdFvaRh
# 3Z5depSLQQ==
# =n+cs
# -----END PGP SIGNATURE-----
# gpg: Signature made Sat 27 Dec 2025 04:22:43 AM AEDT
# gpg:                using RSA key AA1B48B0A22326A5A4C364CFC798DC741BEC319D
# gpg:                issuer "[email protected]"
# gpg: Good signature from "Fabiano Rosas <[email protected]>" [unknown]
# gpg:                 aka "Fabiano Almeida Rosas <[email protected]>" [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: AA1B 48B0 A223 26A5 A4C3  64CF C798 DC74 1BEC 319D

* tag 'qtest-20251226-pull-request' of https://gitlab.com/farosas/qemu:
  tests/qtest: Do not use versioned pc-q35-5.0 machine anymore

Signed-off-by: Richard Henderson <[email protected]>
2025-12-27 08:44:15 +11:00
Richard Henderson 83202ca722 Merge tag 'hppa-updates-qemu-v11-pull-request' of https://github.com/hdeller/qemu-hppa into staging
Please pull fixes and updates for the parisc architecture:

- New SeaBIOS-hppa v21 mit fixes for 715 machine
- ncr710 fixes for NetBSD and HP-UX on 715 machine
- 64-bit gdb support

Thanks!
Helge

# -----BEGIN PGP SIGNATURE-----
#
# iHUEABYKAB0WIQS86RI+GtKfB8BJu973ErUQojoPXwUCaUq53gAKCRD3ErUQojoP
# X0fqAP4wmQIDeyknz4uSZlfaNS7L6HElMrz1jiyyh0avKA/TjwD/UkSvVJJ5Ww7W
# DRx9W5Lg7if93+hQl00QnJGTzgQZQQo=
# =zro8
# -----END PGP SIGNATURE-----
# gpg: Signature made Wed 24 Dec 2025 02:48:46 AM AEDT
# gpg:                using EDDSA key BCE9123E1AD29F07C049BBDEF712B510A23A0F5F
# gpg: Good signature from "Helge Deller <[email protected]>" [unknown]
# gpg:                 aka "Helge Deller <[email protected]>" [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: 4544 8228 2CD9 10DB EF3D  25F8 3E5F 3D04 A7A2 4603
#      Subkey fingerprint: BCE9 123E 1AD2 9F07 C049  BBDE F712 B510 A23A 0F5F

* tag 'hppa-updates-qemu-v11-pull-request' of https://github.com/hdeller/qemu-hppa:
  target/hppa: add 64 bit support to gdbstub
  scsi: ncr710: Fix CTEST FIFO status
  scsi: ncr710: Fix DSA register
  scsi: ncr710: Simplify disconnect handling
  scsi: ncr710: Add LUN scanning
  scsi: ncr710: Mark command complete in status phase and fix disconnect
  scsi: ncr710: Fix table indirect addressing endianness
  scsi: ncr710: Fix DMA State machine and flow control
  scsi: ncr710: Fix interrupt related register handing
  scsi: ncr710: Fix use after free in command_complete
  scsi: ncr710: Add null pointer checks
  target/hppa: Update SeaBIOS-hppa to version 21

Signed-off-by: Richard Henderson <[email protected]>
2025-12-27 08:43:24 +11:00
Richard Henderson f96d2014dd Merge tag 'next-pull-request' of https://gitlab.com/peterx/qemu into staging
memory + migration pull

- Pawel's misc fixes to mapped-ram when x-ignore-share is enabled
- Peter's series to cleanup migration error reporting
- Peter's added debug property for x-ignore-shared
- Part of Fabiano's series on unify capabilities and parameters
- Chuang's log_clear optimization on unaligned ramblocks
- Maintainer file update from Ben (CPR++) and David (MemoryAPI-)

# -----BEGIN PGP SIGNATURE-----
#
# iIgEABYKADAWIQS5GE3CDMRX2s990ak7X8zN86vXBgUCaUqnKhIccGV0ZXJ4QHJl
# ZGhhdC5jb20ACgkQO1/MzfOr1wbOSgD/b62g/6CnM3WtvzsGhOodjO1vixaYOxXk
# BO5k8x0mea8A/ibOOI4MreDfJ7cx6KtI+Pn2ooyJBPAtMJLYiPvaDmUF
# =KmkA
# -----END PGP SIGNATURE-----
# gpg: Signature made Wed 24 Dec 2025 01:28:58 AM AEDT
# gpg:                using EDDSA key B9184DC20CC457DACF7DD1A93B5FCCCDF3ABD706
# gpg:                issuer "[email protected]"
# gpg: Good signature from "Peter Xu <[email protected]>" [unknown]
# gpg:                 aka "Peter Xu <[email protected]>" [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: B918 4DC2 0CC4 57DA CF7D  D1A9 3B5F CCCD F3AB D706

* tag 'next-pull-request' of https://gitlab.com/peterx/qemu: (31 commits)
  MAINTAINERS: remove David from "Memory API" section
  migration: merge fragmented clear_dirty ioctls
  tests/qtest/migration: Pass MigrateStart into cancel tests
  tests/qtest/migration: Pass MigrateCommon into test functions
  migration: Use QAPI_CLONE_MEMBERS in query_migrate_parameters
  migration: Extract code to mark all parameters as present
  migration: Do away with usage of QERR_INVALID_PARAMETER_VALUE
  migration: Remove checks for s->parameters has_* fields
  migration: Add a flag to track block-bitmap-mapping input
  migration: Run a post update routine after setting parameters
  qapi/migration: Don't document MigrationParameter
  migration: Remove MigrateSetParameters
  migration: Normalize tls arguments
  tests/qtest/migration: Add a NULL parameters test for TLS
  migration: Add a qdev property for StrOrNull
  migration: Fix leak of cpr_exec_command
  migration: Fix leak of block_bitmap_mapping
  MAINTAINERS: Update reviewers for CPR
  migration/options: Add x-ignore-shared
  migration: Use error_propagate() in migrate_error_propagate()
  ...

Signed-off-by: Richard Henderson <[email protected]>
2025-12-27 08:42:37 +11:00
Philippe Mathieu-Daudé 9eef3854d3 tests/qtest: Do not use versioned pc-q35-5.0 machine anymore
As of QEMU v10.2.0, the v5.0.0 machines are not usable anymore.

Use the latest x86 q35 machine instead, otherwise we get:

  $ qemu-system-x86_64 -M pc-q35-5.0
  qemu-system-x86_64: unsupported machine type: "pc-q35-5.0"
  Use -machine help to list supported machines

See commit a35f8577a0 ("include/hw: add macros for deprecation
& removal of versioned machines") and f59ee04406 ("include/hw/boards:
cope with dev/rc versions in deprecation checks") for explanation
on automatically removed versioned machines.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Fabiano Rosas <[email protected]>
Reviewed-by: Akihiko Odaki <[email protected].i.u-tokyo.ac.jp>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
2025-12-26 12:06:46 -03:00
Sven Schnelle b2c2d00f48 target/hppa: add 64 bit support to gdbstub
Signed-off-by: Sven Schnelle <[email protected]>
Reviewed-by: Helge Deller <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Helge Deller <[email protected]>
2025-12-23 16:41:56 +01:00
Soumyajyotii Ssarkar 2410c0332a scsi: ncr710: Fix CTEST FIFO status
Update CTEST1 FIFO status when CTEST8 is written, setting to 0xFF when
FIFO is flushed, otherwise clear to 0x00.

Signed-off-by: Soumyajyotii Ssarkar <[email protected]>
Tested-by: Helge Deller <[email protected]>
Signed-off-by: Helge Deller <[email protected]>
2025-12-23 16:41:49 +01:00
Soumyajyotii Ssarkar 9a9c2915c4 scsi: ncr710: Fix DSA register
Implement bytewise write handling for DSA register instead of using
the macro, as NetBSD driver accesses it byte by byte.

Signed-off-by: Soumyajyotii Ssarkar <[email protected]>
Tested-by: Helge Deller <[email protected]>
Signed-off-by: Helge Deller <[email protected]>
2025-12-23 16:41:42 +01:00
Soumyajyotii Ssarkar 3fb0e0d841 scsi: ncr710: Simplify disconnect handling
Simplify disconnect instruction by unconditionally clearing waiting
statements when command completes.

Signed-off-by: Soumyajyotii Ssarkar <[email protected]>
Tested-by: Helge Deller <[email protected]>
Signed-off-by: Helge Deller <[email protected]>
2025-12-23 16:41:32 +01:00
Soumyajyotii Ssarkar 3be0f8f7fe scsi: ncr710: Add LUN scanning
Add multi LUN support by scanning all 8 LUNs when ANT bit is set.

Signed-off-by: Soumyajyotii Ssarkar <[email protected]>
Tested-by: Helge Deller <[email protected]>
Signed-off-by: Helge Deller <[email protected]>
2025-12-23 16:41:24 +01:00
Soumyajyotii Ssarkar 0cbcd0612b scsi: ncr710: Mark command complete in status phase and fix disconnect
Set command_complete flag after status_phase and use_phase_clearing,
instead of full disconnect during message processing.

Signed-off-by: Soumyajyotii Ssarkar <[email protected]>
Reviewed-by: Helge Deller <[email protected]>
Tested-by: Helge Deller <[email protected]>
Signed-off-by: Helge Deller <[email protected]>
2025-12-23 16:41:16 +01:00
Soumyajyotii Ssarkar eb7a22dc2e scsi: ncr710: Fix table indirect addressing endianness
Correct the endianness conversion for table indirect addressing and
use be32_to_cpu() instead of cpu_to_le32().

This fix descriptor table parsing when using indirect addressing modes
in SCRIPTS.

Signed-off-by: Soumyajyotii Ssarkar <[email protected]>
Reviewed-by: Helge Deller <[email protected]>
Signed-off-by: Helge Deller <[email protected]>
2025-12-23 16:41:06 +01:00
Soumyajyotii Ssarkar 22f10208d7 scsi: ncr710: Fix DMA State machine and flow control
Set waiting state and return after scsi_req_continue() to prevent
re entrancy when DMA transfer completes.

Signed-off-by: Soumyajyotii Ssarkar <[email protected]>
Reviewed-by: Helge Deller <[email protected]>
Signed-off-by: Helge Deller <[email protected]>
2025-12-23 16:40:58 +01:00
Soumyajyotii Ssarkar e17f1e9f0b scsi: ncr710: Fix interrupt related register handing
These fixes ensure proper interrupt signaling and status
register behavior during SCSI operations:
- Mask DFE bit in ncr710_update_irq()
- Remove manual ISTAT_DIP clearing, let ncr710_update_irq()
  handle it consistently
- Fix SSTAT0 read to clear unconditionally when non zero
- Fix SSTAT2 read was returning DSTAT instead
- Preserve DFE status bit when clearing DSTAT

Signed-off-by: Soumyajyotii Ssarkar <[email protected]>
Tested-by: Helge Deller <[email protected]>
Signed-off-by: Helge Deller <[email protected]>
2025-12-23 16:40:50 +01:00
Soumyajyotii Ssarkar 177364fa43 scsi: ncr710: Fix use after free in command_complete
Add proper hba_private pointer cleanup in ncr710_command_complete.
This prevents use after free errors from occuring.

This was causing memory corruption in NetBSD device initialization
when commands complete and the request structures were freed while
still being referenced.

Signed-off-by: Soumyajyotii Ssarkar <[email protected]>
Reviewed-by: Helge Deller <[email protected]>
Signed-off-by: Helge Deller <[email protected]>
2025-12-23 16:40:41 +01:00
Soumyajyotii Ssarkar a8df524c8f scsi: ncr710: Add null pointer checks
Add nullpointer safety checks in ncr710_request_free() and
ncr710_request_cancelled() to prevent crashed while handing invalid req
structures.

Added to preventing memory corruption, which occured during device
initialization.

Signed-off-by: Soumyajyotii Ssarkar <[email protected]>
Reviewed-by: Helge Deller <[email protected]>
Signed-off-by: Helge Deller <[email protected]>
2025-12-23 16:40:33 +01:00
Helge Deller bdab1f0c24 target/hppa: Update SeaBIOS-hppa to version 21
Some small bugfixes for the 715/64 machine:
- fix CPU detection of 715 in HP-UX and NetBSD
- minor cleanups regarding LASI_SCSI for 715

Signed-off-by: Helge Deller <[email protected]>
2025-12-23 16:40:25 +01:00
David Hildenbrand (Red Hat) bcb411a005 MAINTAINERS: remove David from "Memory API" section
I don't have a lot of capacity to do any maintanance (or even review) of
"Memory API" lately, so remove myself. Fortunately we still do have two
other maintainers and one reviewer :)

Cc: Paolo Bonzini <[email protected]>
Cc: Peter Xu <[email protected]>
Cc: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: David Hildenbrand (Red Hat) <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Peter Xu <[email protected]>
2025-12-23 09:27:02 -05:00
Chuang Xu e8a6d158db migration: merge fragmented clear_dirty ioctls
In our long-term experience in Bytedance, we've found that under
the same load, live migration of larger VMs with more devices is
often more difficult to converge (requiring a larger downtime limit).

Through some testing and calculations, we conclude that bitmap sync time
affects the calculation of live migration bandwidth.

When the addresses processed are not aligned, a large number of
clear_dirty ioctl occur (e.g. a 4MB misaligned memory can generate
2048 clear_dirty ioctls from two different memory_listener),
which increases the time required for bitmap_sync and makes it
more difficult for dirty pages to converge.

For a 64C256G vm with 8 vhost-user-net(32 queue per nic) and
16 vhost-user-blk(4 queue per blk), the sync time is as high as *73ms*
(tested with 10GBps dirty rate, the sync time increases as the dirty
page rate increases), Here are each part of the sync time:

- sync from kvm to ram_list: 2.5ms
- vhost_log_sync:3ms
- sync aligned memory from ram_list to RAMBlock: 5ms
- sync misaligned memory from ram_list to RAMBlock: 61ms

Attempt to merge those fragmented clear_dirty ioctls, then syncing
misaligned memory from ram_list to RAMBlock takes only about 1ms,
and the total sync time is only *12ms*.

Signed-off-by: Chuang Xu <[email protected]>
Reviewed-by: Fabiano Rosas <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
[peterx: drop var "offset" in physical_memory_sync_dirty_bitmap]
Signed-off-by: Peter Xu <[email protected]>
2025-12-23 09:24:34 -05:00
Fabiano Rosas 11e06ae0b5 tests/qtest/migration: Pass MigrateStart into cancel tests
Pass the "args" parameter to the cancel tests so they can access the
config object which will be part of this struct.

Signed-off-by: Fabiano Rosas <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Peter Xu <[email protected]>
2025-12-23 09:24:34 -05:00
Fabiano Rosas 6fea394aa6 tests/qtest/migration: Pass MigrateCommon into test functions
With the upcoming addition of the config QDict, the tests will need a
better way of managing the memory of the test data than putting the
test arguments on the stack of the test functions. The config QDict
will need to be merged into the arguments of migrate_qmp* functions,
which causes a refcount increment, so the test functions would need to
allocate and deref the config QDict themselves.

A better approach is to already pass the arguments into the test
functions and do the memory management in the existing wrapper. There
is already migration_test_destroy(), which is called for every test.

Do the following:

- merge the two existing wrappers, migration_test_wrapper() and
  migration_test_wrapper_full(). The latter was pioneer in passing
  data into the tests, but now all tests will receive data, so we
  don't need it anymore.

  The usage of migration_test_wrapper_full() was in passing a slightly
  different test name string into the cancel tests, so still keep the
  migration_test_add_suffix() function.

- add (char *name, MigrateCommon *args) to the signature of all test
  functions.

- alter any code to stop allocating args on the stack and instead use
  the object that came as parameter.

- pass args around as needed.

- while here, order args (MigrateCommon) before args->start
  (MigrateStart) and put a blank like in between.

No functional change.

Signed-off-by: Fabiano Rosas <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
[peterx: fix a conflict with newly added mapped-ram+ignore-share test]
Signed-off-by: Peter Xu <[email protected]>
2025-12-23 09:24:34 -05:00
Fabiano Rosas 058f71402f migration: Use QAPI_CLONE_MEMBERS in query_migrate_parameters
QAPI_CLONE_MEMBERS is a better option than copying parameters one by
one because it operates on the entire struct and follows pointers. It
also avoids the need to alter this function every time a new parameter
is added.

For this to work, the has_* fields of s->parameters need to be already
set beforehand, so move migrate_mark_all_params_present() to the init
routine.

Reviewed-by: Peter Xu <[email protected]>
Signed-off-by: Fabiano Rosas <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Peter Xu <[email protected]>
2025-12-23 09:24:34 -05:00
Fabiano Rosas f55f4ef632 migration: Extract code to mark all parameters as present
MigrationParameters needs to have all of its has_* fields marked as
true when used as the return of query_migrate_parameters because the
corresponding QMP command has all of its members non-optional by
design, despite them being marked as optional in migration.json.

Extract this code into a function and make it assert if any field is
missing. With this we ensure future changes will not inadvertently
leave any parameters missing.

Note that the block-bitmap-mapping is a special case because the empty
list is considered a valid value, so it has historically not been
present in the command's output if it has never been set.

CC: Kevin Wolf <[email protected]>
Signed-off-by: Fabiano Rosas <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Peter Xu <[email protected]>
2025-12-23 09:24:34 -05:00
Fabiano Rosas 1a739d3012 migration: Do away with usage of QERR_INVALID_PARAMETER_VALUE
The QERR_INVALID_PARAMETER_VALUE macro is documented as not to be used
in new code. Remove the usage from migration/options.c.

Reviewed-by: Peter Xu <[email protected]>
Signed-off-by: Fabiano Rosas <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Peter Xu <[email protected]>
2025-12-23 09:24:34 -05:00
Fabiano Rosas 03049e0221 migration: Remove checks for s->parameters has_* fields
The migration parameters validation produces a temporary structure
which is the merge of the current parameter values (s->parameters,
MigrationParameters) with the new parameters set by the user
(former MigrateSetParameters).

When copying the values from s->parameters into the temporary
structure, the has_* fields are copied along, but when merging the
user-input values they are not.

During migrate_params_check(), only the parameters that have the
corresponding has_* field will be checked, so only the parameters that
were initialized in migrate_params_init() will be validated.

This causes (almost) all of the migration parameters to be validated
every time a parameter is set, regardless of which fields the user
touched, but it also skips validation of any values that are not set
in migrate_params_init().

It's not clear what was the intention of the original code, whether to
validate all fields always, or only validate what the user input
changed. Since the current situation is closer to the former option,
make the choice of validating all parameters by removing the checks
for the has_* fields when validating.

Note that bringing the user input into the temporary structure for
validation still needs to look at the has_* fields, otherwise any
parameters not set by the user (i.e. 0) would override the
corresponding value in s->parameters.

The empty migrate_params_init() will be kept because subsequent
patches will add code to it.

Signed-off-by: Fabiano Rosas <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Peter Xu <[email protected]>
2025-12-23 09:24:34 -05:00
Fabiano Rosas 47979fce03 migration: Add a flag to track block-bitmap-mapping input
The QAPI converts an empty list on the block-bitmap-mapping input into
a NULL BitmapMigrationNodeAliasList. The empty list is a valid input
for the block-bitmap-mapping option, so commit 3cba22c9ad ("migration:
Fix block_bitmap_mapping migration") started using the
s->parameters.has_block_bitmap_mapping field to tell when the user has
passed in an empty list vs. when no list has been passed at all.

Using s->parameters.has_block_bitmap_mapping field is only possible
because MigrationParameters has had its members made optional due to
historical reasons.

In order to make improvements to the way configuration options are set
for a migration, we'd like to reduce the open-coded usage of the has_*
fields of the global configuration object (s->parameters).

Add a separate boolean to track the status of the block_bitmap_mapping
option.

No functional change intended.

(this was verified to not regress iotest 300, which is the test that
3cba22c9ad refers to)

CC: Kevin Wolf <[email protected]>
Acked-by: Peter Xu <[email protected]>
Signed-off-by: Fabiano Rosas <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Peter Xu <[email protected]>
2025-12-23 09:24:34 -05:00
Fabiano Rosas 6ab968d5e9 migration: Run a post update routine after setting parameters
Some migration parameters are updated immediately once they are set
via migrate-set-parameters. Move that work outside of
migrate_params_apply() and leave that function with the single
responsibility of setting s->parameters and not doing any
side-effects.

Reviewed-by: Peter Xu <[email protected]>
Signed-off-by: Fabiano Rosas <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Peter Xu <[email protected]>
2025-12-23 09:24:34 -05:00
Fabiano Rosas 2220c2b9ef qapi/migration: Don't document MigrationParameter
The MigrationParameter (singular) enumeration is not part of the
migration QMP API, it's only used for nicely converting HMP strings
into MigrationParameters (plural) members and for providing readline
completion.

Documenting this enum only serves to duplicate documentation between
MigrationParameter and MigrationParameters.

Add an exception to QAPIs pragma.json and stop documenting it.

The generated "QEMU QMP Reference Manual" now lists the enum members
as "Not documented."  Tolerable.

Acked-by: Markus Armbruster <[email protected]>
Acked-by: Peter Xu <[email protected]>
Signed-off-by: Fabiano Rosas <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Peter Xu <[email protected]>
2025-12-23 09:24:34 -05:00
Fabiano Rosas 691a836572 migration: Remove MigrateSetParameters
Now that the TLS options have been made the same between
migrate-set-parameters and query-migrate-parameters, a single type can
be used. Remove MigrateSetParameters.

The TLS options documentation from MigrationParameters were replaced
with the ones from MigrateSetParameters which was more complete.

Acked-by: Markus Armbruster <[email protected]>
Acked-by: Peter Xu <[email protected]>
Signed-off-by: Fabiano Rosas <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Peter Xu <[email protected]>
2025-12-23 09:24:34 -05:00
Fabiano Rosas aed97f0563 migration: Normalize tls arguments
The migration parameters tls_creds, tls_authz and tls_hostname
currently have a non-uniform handling. When used as arguments to
migrate-set-parameters, their type is StrOrNull and when used as
return value from query-migrate-parameters their type is a plain
string.

Not only having to convert between the types is cumbersome, but it
also creates the issue of requiring two different QAPI types to be
used, one for each command. MigrateSetParameters is used for
migrate-set-parameters with the TLS arguments as StrOrNull while
MigrationParameters is used for query-migrate-parameters with the TLS
arguments as str.

Since StrOrNull could be considered a superset of str, change the type
of the TLS arguments in MigrationParameters to StrOrNull. Also ensure
that QTYPE_QNULL is never used.

1) migrate-set-parameters will always write QTYPE_QSTRING to
  s->parameters, either an empty or non-empty string.

2) query-migrate-parameters will always return a QTYPE_QSTRING, either
  empty or non-empty.

3) the migrate_tls_* helpers will always return a non-empty string or
  NULL, for the internal migration code's consumption.

Points (1) and (2) above help simplify the parameters validation and
the query command handling because s->parameters is already kept in
the format that query-migrate-parameters (and info migrate_paramters)
expect. Point (3) is so people don't need to care about StrOrNull in
migration code.

This will allow the type duplication to be removed in the next
patches.

Note that the type of @tls_creds, @tls-hostname, @tls-authz changes
from str to StrOrNull in introspection of the query-migrate-parameters
command. We accept this imprecision to enable de-duplication.

There's no need to free the TLS options in
migration_instance_finalize() because they're freed by the qdev
properties .release method.

Temporary in this patch:
migrate_params_test_apply() copies s->parameters into a temporary
structure, so it's necessary to drop the references to the TLS options
if they were not set by the user to avoid double-free. This is fixed
in the next patches.

Acked-by: Markus Armbruster <[email protected]>
Signed-off-by: Fabiano Rosas <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
[peterx: in hmp_info_migrate_parameters(), remove an extra dump of
 max_postcopy_bandwidth, introduced likely by accident]
Signed-off-by: Peter Xu <[email protected]>
2025-12-23 09:24:34 -05:00
Fabiano Rosas df9c38b19a tests/qtest/migration: Add a NULL parameters test for TLS
Make sure the TLS options handling is working correctly with a NULL
parameter. This is relevant due to the usage of StrOrNull for the
tls-creds, tls-authz and tls-hostname options.

With this, all manners of passing TLS options are somehow covered by
the tests, we should not need to do manual testing when touching TLS
options code.

Signed-off-by: Fabiano Rosas <[email protected]>
Reviewed-by: Peter Xu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Peter Xu <[email protected]>
2025-12-23 09:24:34 -05:00
Fabiano Rosas be346eb667 migration: Add a qdev property for StrOrNull
The MigrationState is a QOM object with TYPE_DEVICE as a parent. This
was done about eight years ago so the migration code could make use of
qdev properties to define the defaults for the migration parameters
and to be able to expose migration knobs for debugging via the
'-global migration' command line option.

Due to unrelated historical reasons, three of the migration parameters
(TLS options) received different types when used via the
query-migrate-parameters QMP command than with the
migrate-set-parameters command. This has created a lot of duplication
in the migration code and in the QAPI documentation because the whole
of MigrationParameters had to be duplicated as well.

The migration code is now being fixed to remove the duplication and
for that to happen the offending fields need to be reconciled into a
single type. The StrOrNull type is going to be used.

To keep the command line compatibility, the parameters need to
continue being exposed via qdev properties accessible from the command
line. Introduce a qdev property StrOrNull just for that.

Note that this code is being kept in migration/options.c as this
version of StrOrNull doesn't need to handle QNULL because it was never
a valid option in the previous command line, which took a string.

Signed-off-by: Fabiano Rosas <[email protected]>
Acked-by: Peter Xu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Peter Xu <[email protected]>
2025-12-23 09:24:34 -05:00
Fabiano Rosas 881536e2a5 migration: Fix leak of cpr_exec_command
Signed-off-by: Fabiano Rosas <[email protected]>
Reviewed-by: Peter Xu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Peter Xu <[email protected]>
2025-12-23 09:24:34 -05:00
Fabiano Rosas 16de4ac52e migration: Fix leak of block_bitmap_mapping
Caught by inspection, but ASAN also reports:

Direct leak of 16 byte(s) in 1 object(s) allocated from:
 #0 in malloc
 #1 in g_malloc
 #2 in g_memdup
 #3 in qapi_clone_start_struct ../qapi/qapi-clone-visitor.c:40:12
 #4 in qapi_clone_start_list ../qapi/qapi-clone-visitor.c:59:12
 #5 in visit_start_list ../qapi/qapi-visit-core.c:80:10
 #6 in visit_type_BitmapMigrationNodeAliasList qapi/qapi-visit-migration.c:639:10
 #7 in migrate_params_apply ../migration/options.c:1407:13
 #8 in qmp_migrate_set_parameters ../migration/options.c:1463:5
 #9 in qmp_marshal_migrate_set_parameters qapi/qapi-commands-migration.c:214:5
 #10 in do_qmp_dispatch_bh ../qapi/qmp-dispatch.c:128:5

Note that this is entirely harmless because the migration object which
contains the MigrationParameters structure is kept until the QEMU
process exits.

Reviewed-by: Markus Armbruster <[email protected]>
Reviewed-by: Peter Xu <[email protected]>
Signed-off-by: Fabiano Rosas <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Peter Xu <[email protected]>
2025-12-23 09:24:34 -05:00
Ben Chaney 1b67d95352 MAINTAINERS: Update reviewers for CPR
Signed-off-by: Ben Chaney <[email protected]>
Reviewed-by: Fabiano Rosas <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Peter Xu <[email protected]>
2025-12-23 09:24:34 -05:00
Peter Xu e39dd4e5d5 migration/options: Add x-ignore-shared
This aids scriptings only.

Reviewed-by: Fabiano Rosas <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
[peterx: make the property x-ignore-shared to match, per cedric]
[peterx: fix over-80 line]
Signed-off-by: Peter Xu <[email protected]>
2025-12-23 09:24:34 -05:00
Peter Xu a85fb03ee4 migration: Use error_propagate() in migrate_error_propagate()
It improves readability, as suggested by Markus.

Suggested-by: Markus Armbruster <[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Peter Xu <[email protected]>
2025-12-23 09:24:34 -05:00
Peter Xu d4fd83c9b5 migration: Replace migrate_set_error() with migrate_error_propagate()
migrate_set_error() currently doesn't take ownership of the error being
passed in.  It's not aligned with the error API and meanwhile it also
makes most of the caller free the error explicitly.

Change the API to take the ownership of the Error object instead.  This
should save a lot of error_copy() invocations.

Reviewed-by: Markus Armbruster <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
[peterx: break line for qemu_savevm_send_packaged, per markus]
Signed-off-by: Peter Xu <[email protected]>
2025-12-23 09:24:34 -05:00
Peter Xu 2f904a384d migration: Make multifd_recv_terminate_threads() own the error
Make multifd_recv_terminate_threads() take ownership of the error always.
Paving way for making migrate_set_error() to take ownership.

Reviewed-by: Markus Armbruster <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Peter Xu <[email protected]>
2025-12-23 09:24:34 -05:00
Peter Xu bc85583079 migration: Make multifd_send_set_error() own the error
Make multifd_send_set_error() take ownership of the error always.  Paving
way for making migrate_set_error() to take ownership.

When at it, rename it to multifd_send_error_propagate() to imply the
ownership transition following Error API's naming style.

Reviewed-by: Markus Armbruster <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Peter Xu <[email protected]>
2025-12-23 09:24:34 -05:00
Peter Xu 77c82edadb migration: Make migration_connect_set_error() own the error
Make migration_connect_set_error() take ownership of the error always.
Paving way for making migrate_set_error() to take ownership.

When at it, renaming it to migration_connect_error_propagate(), following
Error API, to imply the Error object ownership transition.

NOTE: this patch also makes migration_connect() to take ownership of the
Error passed in.

Reviewed-by: Markus Armbruster <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Peter Xu <[email protected]>
2025-12-23 09:24:34 -05:00
Markus Armbruster b4898faabe error: Poison g_autoptr(Error) to prevent its use
The previous commit reverted support for g_autoptr(Error).  This one
should stop it from coming back.

Suggested-by: Peter Maydell <[email protected]>
Signed-off-by: Markus Armbruster <[email protected]>
Tested-by: Cédric Le Goater <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Peter Xu <[email protected]>
2025-12-23 09:24:34 -05:00
Peter Xu aa0b2ec50b Revert "error: define g_autoptr() cleanup function for the Error type"
This reverts commit 18eb55546a.

Due to the nature of how Error should be used (normally ownership will be
passed over to Error APIs, like error_report_err), auto-free functions may
be error prone on its own.  The auto cleanup function was merged without
proper review as pointed out by Dan and Markus:

https://lore.kernel.org/r/[email protected]

Cc: Cédric Le Goater <[email protected]>
Acked-by: Maciej S. Szmigiero <[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Acked-by: Maciej S. Szmigiero <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Peter Xu <[email protected]>
2025-12-23 09:24:34 -05:00
Peter Xu 856ac0ccd8 migration: Use explicit error_free() instead of g_autoptr
There're only two use cases of g_autoptr to free Error objects in migration
code paths.

Due to the nature of how Error should be used (normally ownership will be
passed over to Error APIs, like error_report_err), auto-free functions may
be error prone on its own.  The auto cleanup function was merged without
proper review, as pointed out by Dan and Markus:

https://lore.kernel.org/r/[email protected]

Remove the two use cases so that we can remove the auto cleanup function,
hence suggest to not use auto frees for Errors.

Suggested-by: Markus Armbruster <[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Peter Xu <[email protected]>
2025-12-23 09:24:34 -05:00
Pawel Zmarzly 0002b0db13 scripts/analyze-migration: Support mapped-ram snapshot format
The script has not been updated to read mapped-ram snapshots and is currently
crashing when trying to read such a file.

With this commit, it can now read a snapshot created with:

    (qemu) migrate_set_capability x-ignore-shared on
    (qemu) migrate_set_capability mapped-ram on
    (qemu) migrate -d file:vm.state

Signed-off-by: Pawel Zmarzly <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
[peterx: space fixes, introduce parseMappedRamBlob(), add comments, etc.]
Signed-off-by: Peter Xu <[email protected]>
2025-12-23 09:24:34 -05:00
Pawel Zmarzly e476d36ef7 scripts/analyze-migration: Rename RAM_SAVE_FLAG_COMPRESS to RAM_SAVE_FLAG_ZERO
It has been renamed on the C side a few years ago. In modern QEMU versions,
fill_byte must be zero. Updating the Python script to make grepping and
understanding the code easier.

Signed-off-by: Pawel Zmarzly <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
[peterx: fix over-long line]
Signed-off-by: Peter Xu <[email protected]>
2025-12-23 09:24:34 -05:00
Pawel Zmarzly 0b510b51b6 migration: Fix writing mapped_ram + ignore_shared snapshots
Currently if you set these flags and have any shared memory object, saving
a snapshot will fail with:

    Failed to write bitmap to file: Unable to write to file: Bad address

We need to skip writing RAMBlocks that are backed by shared objects.

Also, we should mark these RAMBlocks as skipped, so the snapshot format stays
readable to tools that later don't know QEMU's command line (for example
scripts/analyze-migration.py). I used bitmap_offset=0 pages_offset=0 for this.

This minor change to snapshot format should be safe, as offset=0 should not
have ever been possible.

Signed-off-by: Pawel Zmarzly <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Peter Xu <[email protected]>
2025-12-23 09:24:34 -05:00
Pawel Zmarzly b043f6df27 migration: fix parsing snapshots with x-ignore-shared flag
Snapshots made with mapped-ram and x-ignore-shared flags are
not parsed properly.

The ignore-shared feature adds and extra field in the stream, which
needs to be consumed on the destination side. Even though mapped-ram has
a fixed header format, the ignore-shared is part of the "generic" stream
infomation so the mapped-ram code is currently skipping that be64 read
which incorrectly offsets every subsequent read from the stream.

The current ignore-shared handling can simply be moved earlier in the code
to encompass mapped-ram as well since the ignore-shared doubleword is the
first one read when parsing the ramblock section of the stream.

Co-authored-by: Peter Xu <[email protected]>
Signed-off-by: Pawel Zmarzly <[email protected]>
Reviewed-by: Fabiano Rosas <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
[peterx: enhance commit log per fabiano]
Signed-off-by: Peter Xu <[email protected]>
2025-12-23 09:24:34 -05:00
Richard Henderson 8dd5bceb2f Open 11.0 development tree
Signed-off-by: Richard Henderson <[email protected]>
2025-12-23 14:45:38 +11:00
3784 changed files with 78945 additions and 54192 deletions

No files matched your search

+3 -4
View File
@@ -28,6 +28,9 @@ variables:
# we don't need. The --filter options avoid blobs and tree references we aren't going to use
# and we also avoid fetching tags.
GIT_FETCH_EXTRA_FLAGS: --filter=blob:none --filter=tree:0 --no-tags --prune --quiet
# Ensure docker.py / tests/docker/Makefile.include always displays stdout
# from any docker commands to aid debugging of failures
DOCKER_V: 1
interruptible: true
@@ -49,10 +52,6 @@ variables:
- if: '$CI_PIPELINE_SOURCE == "schedule"'
when: never
# Cirrus jobs can't run unless the creds / target repo are set
- if: '$QEMU_JOB_CIRRUS && ($CIRRUS_GITHUB_REPO == null || $CIRRUS_API_TOKEN == null)'
when: never
# Publishing jobs should only run on the default branch in upstream
- if: '$QEMU_JOB_PUBLISH == "1" && $CI_PROJECT_NAMESPACE == $QEMU_CI_UPSTREAM && $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH'
when: never
+29 -34
View File
@@ -40,7 +40,7 @@ build-system-ubuntu:
variables:
IMAGE: ubuntu2204
CONFIGURE_ARGS: --enable-docs --enable-rust
TARGETS: alpha-softmmu microblazeel-softmmu mips64el-softmmu
TARGETS: alpha-softmmu microblaze-softmmu mips64el-softmmu
MAKE_CHECK_ARGS: check-build
check-system-ubuntu:
@@ -101,8 +101,7 @@ crash-test-debian:
IMAGE: debian
script:
- cd build
- make NINJA=":" check-venv
- pyvenv/bin/python3 scripts/device-crash-test -q --tcg-only ./qemu-system-i386
- ./run scripts/device-crash-test -q --tcg-only ./qemu-system-i386
build-system-fedora:
extends:
@@ -113,7 +112,7 @@ build-system-fedora:
variables:
IMAGE: fedora
CONFIGURE_ARGS: --disable-gcrypt --enable-nettle --enable-docs --enable-crypto-afalg --enable-rust
TARGETS: microblaze-softmmu mips-softmmu
TARGETS: mips-softmmu
xtensa-softmmu m68k-softmmu riscv32-softmmu ppc-softmmu sparc64-softmmu
MAKE_CHECK_ARGS: check-build check-doc
@@ -158,9 +157,8 @@ crash-test-fedora:
IMAGE: fedora
script:
- cd build
- make NINJA=":" check-venv
- pyvenv/bin/python3 scripts/device-crash-test -q ./qemu-system-ppc
- pyvenv/bin/python3 scripts/device-crash-test -q ./qemu-system-riscv32
- ./run scripts/device-crash-test -q ./qemu-system-ppc
- ./run scripts/device-crash-test -q ./qemu-system-riscv32
build-system-centos:
extends:
@@ -350,15 +348,15 @@ build-tcg-disabled:
- make -j"$JOBS"
- make check-unit
- make check-qapi-schema
- cd tests/qemu-iotests/
- ./check -raw 001 002 003 004 005 008 009 010 011 012 021 025 032 033 048
052 063 077 086 101 104 106 113 148 150 151 152 157 159 160 163
170 171 184 192 194 208 221 226 227 236 253 277 image-fleecing
- ./check -qcow2 028 051 056 057 058 065 068 082 085 091 095 096 102 122
124 132 139 142 144 145 151 152 155 157 165 194 196 200 202
208 209 216 218 227 234 246 247 248 250 254 255 257 258
260 261 262 263 264 270 272 273 277 279 image-fleecing
- cd ../..
- ./run tests/qemu-iotests/check -raw 001 002 003 004 005 008 009
010 011 012 021 025 032 033 048 052 063 077 086 101 104 106
113 148 150 151 152 157 159 160 163 170 171 184 192 194 208
221 226 227 236 253 277 image-fleecing
- ./run tests/qemu-iotests/check -qcow2 028 051 056 057 058 065 068
082 085 091 095 096 102 122 124 132 139 142 144 145 151 152
155 157 165 194 196 200 202 208 209 216 218 227 234 246 247
248 250 254 255 257 258 260 261 262 263 264 270 272 273 277
279 image-fleecing
- make distclean
build-user:
@@ -378,18 +376,6 @@ build-user-static:
variables:
IMAGE: debian-all-test-cross
CONFIGURE_ARGS: --disable-tools --disable-system --static
--target-list-exclude=alpha-linux-user,sh4-linux-user
MAKE_CHECK_ARGS: check-tcg
# targets stuck on older compilers
build-legacy:
extends: .native_build_job_template
needs:
- job: amd64-debian-legacy-cross-container
variables:
IMAGE: debian-legacy-test-cross
TARGETS: alpha-linux-user alpha-softmmu sh4-linux-user
CONFIGURE_ARGS: --disable-tools
MAKE_CHECK_ARGS: check-tcg
build-user-hexagon:
@@ -628,7 +614,7 @@ build-oss-fuzz:
IMAGE: fedora
script:
- mkdir build-oss-fuzz
- export LSAN_OPTIONS=suppressions=scripts/oss-fuzz/lsan_suppressions.txt
- export LSAN_OPTIONS=suppressions=scripts/lsan_suppressions.txt
- CC="clang" CXX="clang++" CFLAGS="-fsanitize=address"
./scripts/oss-fuzz/build.sh
- export ASAN_OPTIONS="fast_unwind_on_malloc=0"
@@ -678,7 +664,7 @@ build-without-defaults:
--disable-pie
--disable-qom-cast-debug
--disable-strip
--target-list-exclude=aarch64-softmmu,microblaze-softmmu,mips64-softmmu,mipsel-softmmu,ppc64-softmmu,sh4el-softmmu,xtensa-softmmu,x86_64-softmmu
--target-list-exclude=aarch64-softmmu,mips64-softmmu,mipsel-softmmu,ppc64-softmmu,sh4el-softmmu,xtensa-softmmu,x86_64-softmmu
MAKE_CHECK_ARGS: check
build-libvhost-user:
@@ -785,11 +771,20 @@ coverity:
# Always manual on forks even if $QEMU_CI == "2"
- when: manual
build-wasm:
build-wasm64-64bit:
extends: .wasm_build_job_template
timeout: 2h
needs:
- job: wasm-emsdk-cross-container
- job: wasm64-emsdk-cross-container
variables:
IMAGE: emsdk-wasm32-cross
CONFIGURE_ARGS: --static --disable-tools --enable-debug --enable-tcg-interpreter
IMAGE: emsdk-wasm64-cross
CONFIGURE_ARGS: --static --cpu=wasm64 --disable-tools --enable-debug --enable-tcg-interpreter
build-wasm64-32bit:
extends: .wasm_build_job_template
timeout: 2h
needs:
- job: wasm64-emsdk-cross-container
variables:
IMAGE: emsdk-wasm64-cross
CONFIGURE_ARGS: --static --cpu=wasm64 --wasm64-32bit-address-limit --disable-tools --enable-debug --enable-tcg-interpreter
-60
View File
@@ -1,60 +0,0 @@
# Jobs that we delegate to Cirrus CI because they require an operating
# system other than Linux. These jobs will only run if the required
# setup has been performed on the GitLab account.
#
# The Cirrus CI configuration is generated by replacing target-specific
# variables in a generic template: some of these variables are provided
# when the GitLab CI job is defined, others are taken from a shell
# snippet generated using lcitool.
#
# Note that the $PATH environment variable has to be treated with
# special care, because we can't just override it at the GitLab CI job
# definition level or we risk breaking it completely.
.cirrus_build_job:
extends: .base_job_template
stage: build
image: registry.gitlab.com/libvirt/libvirt-ci/cirrus-run:latest
needs: []
allow_failure:
exit_codes: 3
# 20 mins larger than "timeout_in" in cirrus/build.yml
# as there's often a 5-10 minute delay before Cirrus CI
# actually starts the task
timeout: 80m
script:
- set -o allexport
- source .gitlab-ci.d/cirrus/$NAME.vars
- set +o allexport
- cirrus-vars <.gitlab-ci.d/cirrus/build.yml >.gitlab-ci.d/cirrus/$NAME.yml
- cat .gitlab-ci.d/cirrus/$NAME.yml
- cirrus-run -v --show-build-log always .gitlab-ci.d/cirrus/$NAME.yml
variables:
QEMU_JOB_CIRRUS: 1
x64-freebsd-14-build:
extends: .cirrus_build_job
variables:
NAME: freebsd-14
CIRRUS_VM_INSTANCE_TYPE: freebsd_instance
CIRRUS_VM_IMAGE_SELECTOR: image_family
CIRRUS_VM_IMAGE_NAME: freebsd-14-3
CIRRUS_VM_CPUS: 8
CIRRUS_VM_RAM: 8G
UPDATE_COMMAND: pkg update; pkg upgrade -y
INSTALL_COMMAND: pkg install -y
CONFIGURE_ARGS: --target-list-exclude=arm-softmmu,i386-softmmu,microblaze-softmmu,mips64el-softmmu,mipsel-softmmu,mips-softmmu,ppc-softmmu,sh4eb-softmmu,xtensa-softmmu --enable-rust
TEST_TARGETS: check
aarch64-macos-build:
extends: .cirrus_build_job
variables:
NAME: macos-14
CIRRUS_VM_INSTANCE_TYPE: macos_instance
CIRRUS_VM_IMAGE_SELECTOR: image
CIRRUS_VM_IMAGE_NAME: ghcr.io/cirruslabs/macos-runner:sonoma
UPDATE_COMMAND: brew update
INSTALL_COMMAND: brew install
PATH_EXTRA: /opt/homebrew/ccache/libexec:/opt/homebrew/gettext/bin
PKG_CONFIG_PATH: /opt/homebrew/curl/lib/pkgconfig:/opt/homebrew/ncurses/lib/pkgconfig:/opt/homebrew/readline/lib/pkgconfig
CONFIGURE_ARGS: --target-list-exclude=arm-softmmu,i386-softmmu,microblazeel-softmmu,mips64-softmmu,mipsel-softmmu,mips-softmmu,ppc-softmmu,sh4-softmmu,xtensaeb-softmmu
TEST_TARGETS: check-unit check-block check-qapi-schema check-softfloat check-qtest-x86_64
-54
View File
@@ -1,54 +0,0 @@
Cirrus CI integration
=====================
GitLab CI shared runners only provide a docker environment running on Linux.
While it is possible to provide private runners for non-Linux platforms this
is not something most contributors/maintainers will wish to do.
To work around this limitation, we take advantage of `Cirrus CI`_'s free
offering: more specifically, we use the `cirrus-run`_ script to trigger Cirrus
CI jobs from GitLab CI jobs so that Cirrus CI job output is integrated into
the main GitLab CI pipeline dashboard.
There is, however, some one-time setup required. If you want FreeBSD and macOS
builds to happen when you push to your GitLab repository, you need to
* set up a GitHub repository for the project, eg. ``yourusername/qemu``.
This repository needs to exist for cirrus-run to work, but it doesn't need to
be kept up to date, so you can create it and then forget about it;
* enable the `Cirrus CI GitHub app`_ for your GitHub account;
* sign up for Cirrus CI. It's enough to log into the website using your GitHub
account;
* grab an API token from the `Cirrus CI settings`_ page;
* it may be necessary to push an empty ``.cirrus.yml`` file to your github fork
for Cirrus CI to properly recognize the project. You can check whether
Cirrus CI knows about your project by navigating to:
``https://cirrus-ci.com/yourusername/qemu``
* in the *CI/CD / Variables* section of the settings page for your GitLab
repository, create two new variables:
* ``CIRRUS_GITHUB_REPO``, containing the name of the GitHub repository
created earlier, eg. ``yourusername/qemu``;
* ``CIRRUS_API_TOKEN``, containing the Cirrus CI API token generated earlier.
This variable **must** be marked as *Masked*, because anyone with knowledge
of it can impersonate you as far as Cirrus CI is concerned.
Neither of these variables should be marked as *Protected*, because in
general you'll want to be able to trigger Cirrus CI builds from non-protected
branches.
Once this one-time setup is complete, you can just keep pushing to your GitLab
repository as usual and you'll automatically get the additional CI coverage.
.. _Cirrus CI GitHub app: https://github.com/marketplace/cirrus-ci
.. _Cirrus CI settings: https://cirrus-ci.com/settings/profile/
.. _Cirrus CI: https://cirrus-ci.com/
.. _cirrus-run: https://github.com/sio/cirrus-run/
-42
View File
@@ -1,42 +0,0 @@
@CIRRUS_VM_INSTANCE_TYPE@:
@CIRRUS_VM_IMAGE_SELECTOR@: @CIRRUS_VM_IMAGE_NAME@
cpu: @CIRRUS_VM_CPUS@
memory: @CIRRUS_VM_RAM@
env:
CIRRUS_CLONE_DEPTH: 1
CI_REPOSITORY_URL: "@CI_REPOSITORY_URL@"
CI_COMMIT_REF_NAME: "@CI_COMMIT_REF_NAME@"
CI_COMMIT_SHA: "@CI_COMMIT_SHA@"
PATH: "@PATH_EXTRA@:$PATH"
PKG_CONFIG_PATH: "@PKG_CONFIG_PATH@"
PYTHON: "@PYTHON@"
MAKE: "@MAKE@"
CONFIGURE_ARGS: "@CONFIGURE_ARGS@"
TEST_TARGETS: "@TEST_TARGETS@"
build_task:
# A little shorter than GitLab timeout in ../cirrus.yml
timeout_in: 60m
install_script:
- @UPDATE_COMMAND@
- @INSTALL_COMMAND@ @PKGS@
- if test -n "@PYPI_PKGS@" ; then PYLIB=$(@PYTHON@ -c 'import sysconfig; print(sysconfig.get_path("stdlib"))'); rm -f $PYLIB/EXTERNALLY-MANAGED; @PIP3@ install @PYPI_PKGS@ ; fi
clone_script:
- git clone --depth 100 "$CI_REPOSITORY_URL" .
- git fetch origin "$CI_COMMIT_REF_NAME"
- git reset --hard "$CI_COMMIT_SHA"
step_script:
- mkdir build
- cd build
- ../configure --enable-werror $CONFIGURE_ARGS
|| { cat config.log meson-logs/meson-log.txt; exit 1; }
- $MAKE -j$(sysctl -n hw.ncpu)
- for TARGET in $TEST_TARGETS ;
do
$MAKE -j$(sysctl -n hw.ncpu) $TARGET V=1 ;
done
always:
build_result_artifacts:
path: build/meson-logs/*log.txt
type: text/plain
-16
View File
@@ -1,16 +0,0 @@
# THIS FILE WAS AUTO-GENERATED
#
# $ lcitool variables freebsd-14 qemu
#
# https://gitlab.com/libvirt/libvirt-ci
CCACHE='/usr/local/bin/ccache'
CPAN_PKGS=''
CROSS_PKGS=''
MAKE='/usr/local/bin/gmake'
NINJA='/usr/local/bin/ninja'
PACKAGING_COMMAND='pkg'
PIP3='/usr/local/bin/pip'
PKGS='alsa-lib bash bison bzip2 ca_root_nss capstone4 ccache4 cmocka coreutils ctags curl cyrus-sasl dbus diffutils dtc flex fusefs-libs3 gettext git glib gmake gnutls gsed gtk-vnc gtk3 json-c libepoxy libffi libgcrypt libjpeg-turbo libnfs libslirp libspice-server libssh libtasn1 llvm lzo2 meson mtools ncurses nettle ninja opencv pixman pkgconf png py311-numpy py311-pillow py311-pip py311-pyyaml py311-sphinx py311-sphinx_rtd_theme py311-tomli python3 rpm2cpio rust rust-bindgen-cli sdl2 sdl2_image snappy sndio socat spice-protocol tesseract usbredir virglrenderer vte3 vulkan-tools xorriso zstd'
PYPI_PKGS=''
PYTHON='/usr/local/bin/python3'
+2 -20
View File
@@ -10,24 +10,12 @@ amd64-debian-user-cross-container:
variables:
NAME: debian-all-test-cross
amd64-debian-legacy-cross-container:
extends: .container_job_template
stage: containers
variables:
NAME: debian-legacy-test-cross
arm64-debian-cross-container:
extends: .container_job_template
stage: containers
variables:
NAME: debian-arm64-cross
armhf-debian-cross-container:
extends: .container_job_template
stage: containers
variables:
NAME: debian-armhf-cross
hexagon-cross-container:
extends: .container_job_template
stage: containers
@@ -40,12 +28,6 @@ loongarch-debian-cross-container:
variables:
NAME: debian-loongarch-cross
i686-debian-cross-container:
extends: .container_job_template
stage: containers
variables:
NAME: debian-i686-cross
mips64el-debian-cross-container:
extends: .container_job_template
stage: containers
@@ -86,7 +68,7 @@ win64-fedora-cross-container:
variables:
NAME: fedora-win64-cross
wasm-emsdk-cross-container:
wasm64-emsdk-cross-container:
extends: .container_job_template
variables:
NAME: emsdk-wasm32-cross
NAME: emsdk-wasm64-cross
+2 -3
View File
@@ -21,6 +21,5 @@
- docker logout
rules:
# because we want to enable this for scheduled runs we also have to replicate the normal rules
- if: '$CI_PIPELINE_SOURCE == "schedule"'
- if: '$CI_PROJECT_NAMESPACE == $QEMU_CI_UPSTREAM && $CI_COMMIT_BRANCH =~ /^staging/'
- if: '$QEMU_CI && $CI_PROJECT_NAMESPACE != $QEMU_CI_UPSTREAM'
- if: '$CI_PIPELINE_SOURCE == "schedule" && $CI_PROJECT_NAMESPACE == $QEMU_CI_UPSTREAM'
- !reference [.base_job_template, rules]
+1 -4
View File
@@ -45,12 +45,9 @@ weekly-container-builds:
# cross
- amd64-debian-cross-container
- amd64-debian-user-cross-container
- amd64-debian-legacy-cross-container
- arm64-debian-cross-container
- armhf-debian-cross-container
- hexagon-cross-container
- loongarch-debian-cross-container
- i686-debian-cross-container
- mips64el-debian-cross-container
- ppc64el-debian-cross-container
- riscv64-debian-cross-container
@@ -58,7 +55,7 @@ weekly-container-builds:
- tricore-debian-cross-container
- xtensa-debian-cross-container
- win64-fedora-cross-container
- wasm-emsdk-cross-container
- wasm64-emsdk-cross-container
# containers
- amd64-alpine-container
- amd64-debian-container
+1 -46
View File
@@ -1,13 +1,6 @@
include:
- local: '/.gitlab-ci.d/crossbuild-template.yml'
cross-armhf-user:
extends: .cross_user_build_job
needs:
- job: armhf-debian-cross-container
variables:
IMAGE: debian-armhf-cross
cross-arm64-system:
extends: .cross_system_build_job
needs:
@@ -30,44 +23,6 @@ cross-arm64-kvm-only:
IMAGE: debian-arm64-cross
EXTRA_CONFIGURE_OPTS: --disable-tcg --without-default-features
cross-i686-system:
extends:
- .cross_system_build_job
- .cross_test_artifacts
needs:
- job: i686-debian-cross-container
variables:
IMAGE: debian-i686-cross
EXTRA_CONFIGURE_OPTS: --disable-kvm
MAKE_CHECK_ARGS: check-qtest
cross-i686-user:
extends:
- .cross_user_build_job
- .cross_test_artifacts
needs:
- job: i686-debian-cross-container
variables:
IMAGE: debian-i686-cross
MAKE_CHECK_ARGS: check
cross-i686-tci:
extends:
- .cross_accel_build_job
- .cross_test_artifacts
timeout: 60m
needs:
- job: i686-debian-cross-container
variables:
IMAGE: debian-i686-cross
ACCEL: tcg-interpreter
EXTRA_CONFIGURE_OPTS: --target-list=i386-softmmu,i386-linux-user,arm-softmmu,arm-linux-user,ppc-softmmu,ppc-linux-user --disable-plugins --disable-kvm
# Force tests to run with reduced parallelism, to see whether this
# reduces the flakiness of this CI job. The CI
# environment by default shows us 8 CPUs and so we
# would otherwise be using a parallelism of 9.
MAKE_CHECK_ARGS: check check-tcg -j2
cross-mips64el-system:
extends: .cross_system_build_job
needs:
@@ -156,7 +111,7 @@ cross-win64-system:
IMAGE: fedora-win64-cross
EXTRA_CONFIGURE_OPTS: --enable-fdt=internal --disable-plugins
CROSS_SKIP_TARGETS: alpha-softmmu avr-softmmu hppa-softmmu
m68k-softmmu microblazeel-softmmu
m68k-softmmu microblaze-softmmu
or1k-softmmu rx-softmmu sh4eb-softmmu sparc64-softmmu
tricore-softmmu xtensaeb-softmmu
artifacts:
@@ -11,6 +11,6 @@ MAKE='/opt/homebrew/bin/gmake'
NINJA='/opt/homebrew/bin/ninja'
PACKAGING_COMMAND='brew'
PIP3='/opt/homebrew/bin/pip3'
PKGS='bash bc bindgen bison bzip2 capstone ccache cmocka coreutils ctags curl dbus diffutils dtc flex gcovr gettext git glib gnu-sed gnutls gtk+3 gtk-vnc jemalloc jpeg-turbo json-c libcbor libepoxy libffi libgcrypt libiscsi libnfs libpng libslirp libssh libtasn1 libusb llvm lzo make meson mtools ncurses nettle ninja pixman pkg-config python3 rpm2cpio rust sdl2 sdl2_image snappy socat sparse spice-protocol swtpm tesseract usbredir vde vte3 vulkan-tools xorriso zlib zstd'
PKGS='bash bc bindgen bison bzip2 capstone ccache cmocka coreutils ctags curl dbus diffutils dtc flex gcovr gettext git glib gnu-sed gnutls gtk+3 gtk-vnc jemalloc jpeg-turbo json-c libcbor libepoxy libffi libgcrypt libiscsi libnfs libpng libslirp libssh libtasn1 libusb llvm lzo make meson mtools ncurses nettle ninja pixman pkg-config python-setuptools python3 rpm2cpio rust sdl2 sdl2_image snappy socat sparse spice-protocol swtpm tesseract usbredir vde vte3 vulkan-tools xorriso zlib zstd'
PYPI_PKGS='PyYAML numpy pillow sphinx sphinx-rtd-theme tomli'
PYTHON='/opt/homebrew/bin/python3'
+47
View File
@@ -0,0 +1,47 @@
.macos_job_template:
extends: .base_job_template
stage: build
tags:
- saas-macos-large-m2pro
needs: []
timeout: 80m
artifacts:
name: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"
expire_in: 7 days
paths:
- build/meson-logs/
- build/tests/tcg/
reports:
junit: build/meson-logs/*.junit.xml
when: always
before_script:
- set -o allexport
- source .gitlab-ci.d/macos-14.vars
- set +o allexport
- export PATH="$PATH_EXTRA:$PATH"
- export PKG_CONFIG_PATH="$PKG_CONFIG_PATH"
- brew update
- brew install $PKGS
- brew install gdb aarch64-elf-gcc i686-elf-gcc x86_64-elf-gcc
- if test -n "$PYPI_PKGS" ; then PYLIB=$($PYTHON -c 'import sysconfig; print(sysconfig.get_path("stdlib"))'); rm -f $PYLIB/EXTERNALLY-MANAGED; $PIP3 install --break-system-packages $PYPI_PKGS ; fi
script:
- mkdir build
- cd build
- ../configure --enable-werror $CONFIGURE_ARGS || { cat config.log meson-logs/meson-log.txt; exit 1; }
- $MAKE -j$(sysctl -n hw.ncpu)
- for TARGET in $TEST_TARGETS ; do $MAKE $TARGET ; done
aarch64-macos-15-build:
extends: .macos_job_template
image: macos-15-xcode-16
variables:
NAME: macos-15
PATH_EXTRA: /opt/homebrew/gettext/bin
PKG_CONFIG_PATH: /opt/homebrew/curl/lib/pkgconfig:/opt/homebrew/ncurses/lib/pkgconfig:/opt/homebrew/readline/lib/pkgconfig
CONFIGURE_ARGS:
--target-list=aarch64-softmmu,i386-softmmu,x86_64-softmmu
--cross-prefix-aarch64=aarch64-elf-
--cross-prefix-i386=i686-elf-
--cross-prefix-x86_64=x86_64-elf-
--disable-plugins
TEST_TARGETS: check-unit run-tcg-tests-aarch64-softmmu run-tcg-tests-i386-softmmu run-tcg-tests-x86_64-softmmu
+1 -1
View File
@@ -17,5 +17,5 @@ include:
- local: '/.gitlab-ci.d/buildtest.yml'
- local: '/.gitlab-ci.d/static_checks.yml'
- local: '/.gitlab-ci.d/custom-runners.yml'
- local: '/.gitlab-ci.d/cirrus.yml'
- local: '/.gitlab-ci.d/windows.yml'
- local: '/.gitlab-ci.d/macos.yml'
+8 -1
View File
@@ -17,7 +17,7 @@ msys2-64bit:
# This feature doesn't (currently) work with PowerShell, it stops
# the echo'ing of commands being run and doesn't show any timing
FF_SCRIPT_SECTIONS: 0
CONFIGURE_ARGS: --disable-system --enable-tools -Ddebug=false -Doptimization=0
CONFIGURE_ARGS: --disable-system --enable-tools -Ddebug=false -Doptimization=0 --enable-rust
# The Windows git is a bit older so override the default
GIT_FETCH_EXTRA_FLAGS: --no-tags --prune --quiet
artifacts:
@@ -77,6 +77,7 @@ msys2-64bit:
bison diffutils flex
git grep make sed
mingw-w64-x86_64-binutils
mingw-w64-x86_64-ca-certificates
mingw-w64-x86_64-ccache
mingw-w64-x86_64-curl-winssl
mingw-w64-x86_64-gcc
@@ -87,6 +88,11 @@ msys2-64bit:
mingw-w64-x86_64-pixman
mingw-w64-x86_64-pkgconf
mingw-w64-x86_64-python
mingw-w64-x86_64-python-certifi
mingw-w64-x86_64-python-setuptools
mingw-w64-x86_64-python-wheel
mingw-w64-x86_64-rust
mingw-w64-x86_64-rust-bindgen
mingw-w64-x86_64-zstd"
- .\msys64\usr\bin\bash -lc "pacman -Sc --noconfirm"
- Write-Output "Running build at $(Get-Date -Format u)"
@@ -98,6 +104,7 @@ msys2-64bit:
- $env:CCACHE_MAXSIZE = "180M"
- $env:CCACHE_DEPEND = 1 # cache misses are too expensive with preprocessor mode
- $env:CC = "ccache gcc"
- $env:LIBCLANG_PATH = Join-Path -Path $PWD.Path -ChildPath "msys64/mingw64/bin"
- mkdir build
- cd build
- ..\msys64\usr\bin\bash -lc "ccache --zero-stats"
+1
View File
+1
View File
@@ -1,6 +1,7 @@
source Kconfig.host
source backends/Kconfig
source accel/Kconfig
source dump/Kconfig
source target/Kconfig
source hw/Kconfig
source semihosting/Kconfig
+216 -126
View File
File diff suppressed because it is too large. Load diff
+1 -1
View File
@@ -130,7 +130,7 @@ Makefile.mtest: build.ninja scripts/mtest2make.py
.PHONY: update-buildoptions
all update-buildoptions: $(SRC_PATH)/scripts/meson-buildoptions.sh
$(SRC_PATH)/scripts/meson-buildoptions.sh: $(SRC_PATH)/meson_options.txt
$(SRC_PATH)/scripts/meson-buildoptions.sh: $(SRC_PATH)/meson_options.txt $(SRC_PATH)/scripts/meson-buildoptions.py
$(MESON) introspect --buildoptions $(SRC_PATH)/meson.build | $(PYTHON) \
scripts/meson-buildoptions.py > $@.tmp && mv $@.tmp $@
endif
+1 -1
View File
@@ -1 +1 @@
10.2.0
11.0.2
+3
View File
@@ -16,6 +16,9 @@ config KVM
config MSHV
bool
config NITRO
bool
config XEN
bool
select FSDEV_9P if VIRTFS
+5
View File
@@ -106,6 +106,11 @@ bool accel_cpu_common_realize(CPUState *cpu, Error **errp)
if (acc->cpu_common_realize && !acc->cpu_common_realize(cpu, errp)) {
return false;
}
if (acc->ops
&& acc->ops->cpu_target_realize
&& !acc->ops->cpu_target_realize(cpu, errp)) {
return false;
}
return true;
}
+1 -1
View File
@@ -27,7 +27,7 @@
#include "qemu/accel.h"
#include "qapi/qapi-commands-accelerator.h"
#include "monitor/monitor.h"
#include "hw/boards.h"
#include "hw/core/boards.h"
#include "hw/core/cpu.h"
#include "accel/accel-ops.h"
#include "accel/accel-cpu-ops.h"
+2 -16
View File
@@ -64,20 +64,6 @@ HVFState *hvf_state;
/* Memory slots */
hvf_slot *hvf_find_overlap_slot(uint64_t start, uint64_t size)
{
hvf_slot *slot;
int x;
for (x = 0; x < hvf_state->num_slots; ++x) {
slot = &hvf_state->slots[x];
if (slot->size && start < (slot->start + slot->size) &&
(start + size) > slot->start) {
return slot;
}
}
return NULL;
}
static void do_hvf_cpu_synchronize_state(CPUState *cpu, run_on_cpu_data arg)
{
if (!cpu->vcpu_dirty) {
@@ -149,8 +135,6 @@ static int hvf_init_vcpu(CPUState *cpu)
sigaction(SIG_IPI, &sigact, NULL);
#ifdef __aarch64__
pthread_sigmask(SIG_BLOCK, NULL, &cpu->accel->unblock_ipi_mask);
sigdelset(&cpu->accel->unblock_ipi_mask, SIG_IPI);
cpu->accel->guest_debug_enabled = false;
r = hv_vcpu_create(&cpu->accel->fd,
@@ -372,6 +356,8 @@ static void hvf_accel_ops_class_init(ObjectClass *oc, const void *data)
{
AccelOpsClass *ops = ACCEL_OPS_CLASS(oc);
ops->cpu_target_realize = hvf_arch_cpu_realize;
ops->create_vcpu_thread = hvf_start_vcpu_thread;
ops->kick_vcpu_thread = hvf_kick_vcpu_thread;
ops->handle_interrupt = generic_handle_interrupt;
+60 -134
View File
@@ -11,25 +11,17 @@
#include "qemu/osdep.h"
#include "qemu/error-report.h"
#include "accel/accel-ops.h"
#include "exec/cpu-common.h"
#include "system/address-spaces.h"
#include "system/memory.h"
#include "system/hvf.h"
#include "system/hvf_int.h"
#include "hw/core/cpu.h"
#include "hw/boards.h"
#include "hw/core/boards.h"
#include "trace.h"
bool hvf_allowed;
struct mac_slot {
int present;
uint64_t size;
uint64_t gpa_start;
uint64_t gva;
};
struct mac_slot mac_slots[32];
const char *hvf_return_string(hv_return_t ret)
{
switch (ret) {
@@ -58,45 +50,44 @@ void assert_hvf_ok_impl(hv_return_t ret, const char *file, unsigned int line,
abort();
}
static int do_hvf_set_memory(hvf_slot *slot, hv_memory_flags_t flags)
static void do_hv_vm_protect(hwaddr start, size_t size,
hv_memory_flags_t flags)
{
struct mac_slot *macslot;
intptr_t page_mask = qemu_real_host_page_mask();
hv_return_t ret;
macslot = &mac_slots[slot->slot_id];
trace_hvf_vm_protect(start, size, flags,
flags & HV_MEMORY_READ ? 'R' : '-',
flags & HV_MEMORY_WRITE ? 'W' : '-',
flags & HV_MEMORY_EXEC ? 'X' : '-');
g_assert(!((uintptr_t)start & ~page_mask));
g_assert(!(size & ~page_mask));
if (macslot->present) {
if (macslot->size != slot->size) {
macslot->present = 0;
trace_hvf_vm_unmap(macslot->gpa_start, macslot->size);
ret = hv_vm_unmap(macslot->gpa_start, macslot->size);
assert_hvf_ok(ret);
}
}
if (!slot->size) {
return 0;
}
macslot->present = 1;
macslot->gpa_start = slot->start;
macslot->size = slot->size;
trace_hvf_vm_map(slot->start, slot->size, slot->mem, flags,
flags & HV_MEMORY_READ ? 'R' : '-',
flags & HV_MEMORY_WRITE ? 'W' : '-',
flags & HV_MEMORY_EXEC ? 'X' : '-');
ret = hv_vm_map(slot->mem, slot->start, slot->size, flags);
ret = hv_vm_protect(start, size, flags);
assert_hvf_ok(ret);
return 0;
}
void hvf_protect_clean_range(hwaddr addr, size_t size)
{
do_hv_vm_protect(addr, size, HV_MEMORY_READ | HV_MEMORY_EXEC);
}
void hvf_unprotect_dirty_range(hwaddr addr, size_t size)
{
do_hv_vm_protect(addr, size,
HV_MEMORY_READ | HV_MEMORY_WRITE | HV_MEMORY_EXEC);
}
static void hvf_set_phys_mem(MemoryRegionSection *section, bool add)
{
hvf_slot *mem;
MemoryRegion *area = section->mr;
bool writable = !area->readonly && !area->rom_device;
hv_memory_flags_t flags;
uint64_t page_size = qemu_real_host_page_size();
uint64_t gpa = section->offset_within_address_space;
uint64_t size = int128_get64(section->size);
hv_return_t ret;
void *mem;
if (!memory_region_is_ram(area)) {
if (writable) {
@@ -110,120 +101,60 @@ static void hvf_set_phys_mem(MemoryRegionSection *section, bool add)
}
}
if (!QEMU_IS_ALIGNED(int128_get64(section->size), page_size) ||
!QEMU_IS_ALIGNED(section->offset_within_address_space, page_size)) {
if (!QEMU_IS_ALIGNED(size, page_size) ||
!QEMU_IS_ALIGNED(gpa, page_size)) {
/* Not page aligned, so we can not map as RAM */
add = false;
}
mem = hvf_find_overlap_slot(
section->offset_within_address_space,
int128_get64(section->size));
if (mem && add) {
if (mem->size == int128_get64(section->size) &&
mem->start == section->offset_within_address_space &&
mem->mem == (memory_region_get_ram_ptr(area) +
section->offset_within_region)) {
return; /* Same region was attempted to register, go away. */
}
}
/* Region needs to be reset. set the size to 0 and remap it. */
if (mem) {
mem->size = 0;
if (do_hvf_set_memory(mem, 0)) {
error_report("Failed to reset overlapping slot");
abort();
}
}
if (!add) {
trace_hvf_vm_unmap(gpa, size);
ret = hv_vm_unmap(gpa, size);
assert_hvf_ok(ret);
return;
}
if (area->readonly ||
(!memory_region_is_ram(area) && memory_region_is_romd(area))) {
flags = HV_MEMORY_READ | HV_MEMORY_EXEC;
} else {
flags = HV_MEMORY_READ | HV_MEMORY_WRITE | HV_MEMORY_EXEC;
}
flags = HV_MEMORY_READ | HV_MEMORY_EXEC | (writable ? HV_MEMORY_WRITE : 0);
mem = memory_region_get_ram_ptr(area) + section->offset_within_region;
/* Now make a new slot. */
int x;
for (x = 0; x < hvf_state->num_slots; ++x) {
mem = &hvf_state->slots[x];
if (!mem->size) {
break;
}
}
if (x == hvf_state->num_slots) {
error_report("No free slots");
abort();
}
mem->size = int128_get64(section->size);
mem->mem = memory_region_get_ram_ptr(area) + section->offset_within_region;
mem->start = section->offset_within_address_space;
mem->region = area;
if (do_hvf_set_memory(mem, flags)) {
error_report("Error registering new memory slot");
abort();
}
}
static void hvf_set_dirty_tracking(MemoryRegionSection *section, bool on)
{
hvf_slot *slot;
slot = hvf_find_overlap_slot(
section->offset_within_address_space,
int128_get64(section->size));
/* protect region against writes; begin tracking it */
if (on) {
slot->flags |= HVF_SLOT_LOG;
hv_vm_protect((uintptr_t)slot->start, (size_t)slot->size,
HV_MEMORY_READ | HV_MEMORY_EXEC);
/* stop tracking region*/
} else {
slot->flags &= ~HVF_SLOT_LOG;
hv_vm_protect((uintptr_t)slot->start, (size_t)slot->size,
HV_MEMORY_READ | HV_MEMORY_WRITE | HV_MEMORY_EXEC);
}
trace_hvf_vm_map(gpa, size, mem, flags,
flags & HV_MEMORY_READ ? 'R' : '-',
flags & HV_MEMORY_WRITE ? 'W' : '-',
flags & HV_MEMORY_EXEC ? 'X' : '-');
ret = hv_vm_map(mem, gpa, size, flags);
assert_hvf_ok(ret);
}
static void hvf_log_start(MemoryListener *listener,
MemoryRegionSection *section, int old, int new)
{
if (old != 0) {
return;
assert(new != 0);
if (old == 0) {
hvf_protect_clean_range(section->offset_within_address_space,
int128_get64(section->size));
}
hvf_set_dirty_tracking(section, 1);
}
static void hvf_log_stop(MemoryListener *listener,
MemoryRegionSection *section, int old, int new)
{
if (new != 0) {
return;
assert(old != 0);
if (new == 0) {
hvf_unprotect_dirty_range(section->offset_within_address_space,
int128_get64(section->size));
}
hvf_set_dirty_tracking(section, 0);
}
static void hvf_log_sync(MemoryListener *listener,
MemoryRegionSection *section)
static void hvf_log_clear(MemoryListener *listener,
MemoryRegionSection *section)
{
/*
* sync of dirty pages is handled elsewhere; just make sure we keep
* tracking the region.
* The dirty page bits within section are being cleared.
* Some number of those pages may have been dirtied and
* the write permission enabled. Reset the range read-only.
*/
hvf_set_dirty_tracking(section, 1);
hvf_protect_clean_range(section->offset_within_address_space,
int128_get64(section->size));
}
static void hvf_region_add(MemoryListener *listener,
@@ -245,19 +176,20 @@ static MemoryListener hvf_memory_listener = {
.region_del = hvf_region_del,
.log_start = hvf_log_start,
.log_stop = hvf_log_stop,
.log_sync = hvf_log_sync,
.log_clear = hvf_log_clear,
};
static int hvf_accel_init(AccelState *as, MachineState *ms)
{
int x;
hv_return_t ret;
HVFState *s = HVF_STATE(as);
int pa_range = 36;
MachineClass *mc = MACHINE_GET_CLASS(ms);
if (mc->hvf_get_physical_address_range) {
pa_range = mc->hvf_get_physical_address_range(ms);
if (mc->get_physical_address_range) {
pa_range = mc->get_physical_address_range(ms,
hvf_arch_get_default_ipa_bit_size(), hvf_arch_get_max_ipa_bit_size());
if (pa_range < 0) {
return -EINVAL;
}
@@ -271,12 +203,6 @@ static int hvf_accel_init(AccelState *as, MachineState *ms)
}
assert_hvf_ok(ret);
s->num_slots = ARRAY_SIZE(s->slots);
for (x = 0; x < s->num_slots; ++x) {
s->slots[x].size = 0;
s->slots[x].slot_id = x;
}
QTAILQ_INIT(&s->hvf_sw_breakpoints);
hvf_state = s;
+1 -4
View File
@@ -1,7 +1,4 @@
hvf_ss = ss.source_set()
hvf_ss.add(files(
system_ss.add(when: 'CONFIG_HVF', if_true: files(
'hvf-all.c',
'hvf-accel-ops.c',
))
specific_ss.add_all(when: 'CONFIG_HVF', if_true: hvf_ss)
+1
View File
@@ -5,3 +5,4 @@
# hvf-accel-ops.c
hvf_vm_map(uint64_t paddr, uint64_t size, void *vaddr, uint8_t flags, const char r, const char w, const char e) "paddr:0x%016"PRIx64" size:0x%08"PRIx64" vaddr:%p flags:0x%02x/%c%c%c"
hvf_vm_unmap(uint64_t paddr, uint64_t size) "paddr:0x%016"PRIx64" size:0x%08"PRIx64
hvf_vm_protect(uint64_t paddr, size_t size, uint8_t flags, const char r, const char w, const char e) "paddr:0x%016"PRIx64" size:0x%08zx flags:0x%02x/%c%c%c"
+1
View File
@@ -16,6 +16,7 @@
#include "qemu/osdep.h"
#include "qemu/error-report.h"
#include "qemu/main-loop.h"
#include "exec/cpu-common.h"
#include "accel/accel-cpu-ops.h"
#include "system/kvm.h"
#include "system/kvm_int.h"
+340 -52
View File
@@ -42,7 +42,7 @@
#include "qemu/event_notifier.h"
#include "qemu/main-loop.h"
#include "trace.h"
#include "hw/irq.h"
#include "hw/core/irq.h"
#include "qapi/visitor.h"
#include "qapi/qapi-types-common.h"
#include "qapi/qapi-visit-common.h"
@@ -53,7 +53,7 @@
#include "system/dirtylimit.h"
#include "qemu/range.h"
#include "hw/boards.h"
#include "hw/core/boards.h"
#include "system/stats.h"
/* This check must be after config-host.h is included */
@@ -61,7 +61,7 @@
#include <sys/eventfd.h>
#endif
#if defined(__i386__) || defined(__x86_64__) || defined(__aarch64__)
#if defined(__x86_64__) || defined(__aarch64__)
# define KVM_HAVE_MCE_INJECTION 1
#endif
@@ -90,6 +90,7 @@ struct KVMParkedVcpu {
};
KVMState *kvm_state;
VmfdChangeNotifier vmfd_notifier;
bool kvm_kernel_irqchip;
bool kvm_split_irqchip;
bool kvm_async_interrupts_allowed;
@@ -110,7 +111,7 @@ static uint64_t kvm_supported_memory_attributes;
static bool kvm_guest_memfd_supported;
static hwaddr kvm_max_slot_size = ~0;
static const KVMCapabilityInfo kvm_required_capabilites[] = {
static const KVMCapabilityInfo kvm_required_capabilities[] = {
KVM_CAP_INFO(USER_MEMORY),
KVM_CAP_INFO(DESTROY_MEMORY_REGION_WORKS),
KVM_CAP_INFO(JOIN_MEMORY_REGIONS_WORKS),
@@ -123,6 +124,16 @@ static const KVMCapabilityInfo kvm_required_capabilites[] = {
static NotifierList kvm_irqchip_change_notifiers =
NOTIFIER_LIST_INITIALIZER(kvm_irqchip_change_notifiers);
static NotifierWithReturnList register_vmfd_changed_notifiers =
NOTIFIER_WITH_RETURN_LIST_INITIALIZER(register_vmfd_changed_notifiers);
static NotifierWithReturnList register_vcpufd_changed_notifiers =
NOTIFIER_WITH_RETURN_LIST_INITIALIZER(register_vcpufd_changed_notifiers);
static int map_kvm_run(KVMState *s, CPUState *cpu, Error **errp);
static int map_kvm_dirty_gfns(KVMState *s, CPUState *cpu, Error **errp);
static int vcpu_unmap_regions(KVMState *s, CPUState *cpu);
struct KVMResampleFd {
int gsi;
EventNotifier *resample_event;
@@ -416,6 +427,90 @@ err:
return ret;
}
static void kvm_create_vcpu_internal(CPUState *cpu, KVMState *s, int kvm_fd)
{
cpu->kvm_fd = kvm_fd;
cpu->kvm_state = s;
if (!s->guest_state_protected) {
cpu->vcpu_dirty = true;
}
cpu->dirty_pages = 0;
cpu->throttle_us_per_full = 0;
return;
}
static int kvm_rebind_vcpus(Error **errp)
{
CPUState *cpu;
unsigned long vcpu_id;
KVMState *s = kvm_state;
int kvm_fd, ret = 0;
CPU_FOREACH(cpu) {
vcpu_id = kvm_arch_vcpu_id(cpu);
if (cpu->kvm_fd) {
close(cpu->kvm_fd);
}
ret = kvm_arch_destroy_vcpu(cpu);
if (ret < 0) {
goto err;
}
if (s->coalesced_mmio_ring == (void *)cpu->kvm_run + PAGE_SIZE) {
s->coalesced_mmio_ring = NULL;
}
ret = vcpu_unmap_regions(s, cpu);
if (ret < 0) {
goto err;
}
ret = kvm_arch_pre_create_vcpu(cpu, errp);
if (ret < 0) {
goto err;
}
kvm_fd = kvm_vm_ioctl(s, KVM_CREATE_VCPU, vcpu_id);
if (kvm_fd < 0) {
error_report("KVM_CREATE_VCPU IOCTL failed for vCPU %lu (%s)",
vcpu_id, strerror(kvm_fd));
return kvm_fd;
}
kvm_create_vcpu_internal(cpu, s, kvm_fd);
ret = map_kvm_run(s, cpu, errp);
if (ret < 0) {
goto err;
}
if (s->kvm_dirty_ring_size) {
ret = map_kvm_dirty_gfns(s, cpu, errp);
if (ret < 0) {
goto err;
}
}
ret = kvm_arch_init_vcpu(cpu);
if (ret < 0) {
error_setg_errno(errp, -ret,
"kvm_init_vcpu: kvm_arch_init_vcpu failed (%lu)",
vcpu_id);
}
close(cpu->kvm_vcpu_stats_fd);
cpu->kvm_vcpu_stats_fd = kvm_vcpu_ioctl(cpu, KVM_GET_STATS_FD, NULL);
kvm_init_cpu_signals(cpu);
}
trace_kvm_rebind_vcpus();
err:
return ret;
}
static void kvm_park_vcpu(CPUState *cpu)
{
struct KVMParkedVcpu *vcpu;
@@ -479,13 +574,7 @@ static int kvm_create_vcpu(CPUState *cpu)
}
}
cpu->kvm_fd = kvm_fd;
cpu->kvm_state = s;
if (!s->guest_state_protected) {
cpu->vcpu_dirty = true;
}
cpu->dirty_pages = 0;
cpu->throttle_us_per_full = 0;
kvm_create_vcpu_internal(cpu, s, kvm_fd);
trace_kvm_create_vcpu(cpu->cpu_index, vcpu_id, kvm_fd);
@@ -504,19 +593,11 @@ int kvm_create_and_park_vcpu(CPUState *cpu)
return ret;
}
static int do_kvm_destroy_vcpu(CPUState *cpu)
static int vcpu_unmap_regions(KVMState *s, CPUState *cpu)
{
KVMState *s = kvm_state;
int mmap_size;
int ret = 0;
trace_kvm_destroy_vcpu(cpu->cpu_index, kvm_arch_vcpu_id(cpu));
ret = kvm_arch_destroy_vcpu(cpu);
if (ret < 0) {
goto err;
}
mmap_size = kvm_ioctl(s, KVM_GET_VCPU_MMAP_SIZE, 0);
if (mmap_size < 0) {
ret = mmap_size;
@@ -544,6 +625,31 @@ static int do_kvm_destroy_vcpu(CPUState *cpu)
cpu->kvm_dirty_gfns = NULL;
}
err:
return ret;
}
static int do_kvm_destroy_vcpu(CPUState *cpu)
{
KVMState *s = kvm_state;
int ret = 0;
trace_kvm_destroy_vcpu(cpu->cpu_index, kvm_arch_vcpu_id(cpu));
ret = kvm_arch_destroy_vcpu(cpu);
if (ret < 0) {
goto err;
}
/* If I am the CPU that created coalesced_mmio_ring, then discard it */
if (s->coalesced_mmio_ring == (void *)cpu->kvm_run + PAGE_SIZE) {
s->coalesced_mmio_ring = NULL;
}
ret = vcpu_unmap_regions(s, cpu);
if (ret < 0) {
goto err;
}
kvm_park_vcpu(cpu);
err:
return ret;
@@ -557,26 +663,9 @@ void kvm_destroy_vcpu(CPUState *cpu)
}
}
int kvm_init_vcpu(CPUState *cpu, Error **errp)
static int map_kvm_run(KVMState *s, CPUState *cpu, Error **errp)
{
KVMState *s = kvm_state;
int mmap_size;
int ret;
trace_kvm_init_vcpu(cpu->cpu_index, kvm_arch_vcpu_id(cpu));
ret = kvm_arch_pre_create_vcpu(cpu, errp);
if (ret < 0) {
goto err;
}
ret = kvm_create_vcpu(cpu);
if (ret < 0) {
error_setg_errno(errp, -ret,
"kvm_init_vcpu: kvm_create_vcpu failed (%lu)",
kvm_arch_vcpu_id(cpu));
goto err;
}
int mmap_size, ret = 0;
mmap_size = kvm_ioctl(s, KVM_GET_VCPU_MMAP_SIZE, 0);
if (mmap_size < 0) {
@@ -601,14 +690,53 @@ int kvm_init_vcpu(CPUState *cpu, Error **errp)
(void *)cpu->kvm_run + s->coalesced_mmio * PAGE_SIZE;
}
err:
return ret;
}
static int map_kvm_dirty_gfns(KVMState *s, CPUState *cpu, Error **errp)
{
int ret = 0;
/* Use MAP_SHARED to share pages with the kernel */
cpu->kvm_dirty_gfns = mmap(NULL, s->kvm_dirty_ring_bytes,
PROT_READ | PROT_WRITE, MAP_SHARED,
cpu->kvm_fd,
PAGE_SIZE * KVM_DIRTY_LOG_PAGE_OFFSET);
if (cpu->kvm_dirty_gfns == MAP_FAILED) {
ret = -errno;
}
return ret;
}
int kvm_init_vcpu(CPUState *cpu, Error **errp)
{
KVMState *s = kvm_state;
int ret;
trace_kvm_init_vcpu(cpu->cpu_index, kvm_arch_vcpu_id(cpu));
ret = kvm_arch_pre_create_vcpu(cpu, errp);
if (ret < 0) {
goto err;
}
ret = kvm_create_vcpu(cpu);
if (ret < 0) {
error_setg_errno(errp, -ret,
"kvm_init_vcpu: kvm_create_vcpu failed (%lu)",
kvm_arch_vcpu_id(cpu));
goto err;
}
ret = map_kvm_run(s, cpu, errp);
if (ret < 0) {
goto err;
}
if (s->kvm_dirty_ring_size) {
/* Use MAP_SHARED to share pages with the kernel */
cpu->kvm_dirty_gfns = mmap(NULL, s->kvm_dirty_ring_bytes,
PROT_READ | PROT_WRITE, MAP_SHARED,
cpu->kvm_fd,
PAGE_SIZE * KVM_DIRTY_LOG_PAGE_OFFSET);
if (cpu->kvm_dirty_gfns == MAP_FAILED) {
ret = -errno;
ret = map_kvm_dirty_gfns(s, cpu, errp);
if (ret < 0) {
goto err;
}
}
@@ -2173,6 +2301,38 @@ void kvm_irqchip_change_notify(void)
notifier_list_notify(&kvm_irqchip_change_notifiers, NULL);
}
void kvm_vmfd_add_change_notifier(NotifierWithReturn *n)
{
notifier_with_return_list_add(&register_vmfd_changed_notifiers, n);
}
void kvm_vmfd_remove_change_notifier(NotifierWithReturn *n)
{
notifier_with_return_remove(n);
}
static int kvm_vmfd_change_notify(Error **errp)
{
return notifier_with_return_list_notify(&register_vmfd_changed_notifiers,
&vmfd_notifier, errp);
}
void kvm_vcpufd_add_change_notifier(NotifierWithReturn *n)
{
notifier_with_return_list_add(&register_vcpufd_changed_notifiers, n);
}
void kvm_vcpufd_remove_change_notifier(NotifierWithReturn *n)
{
notifier_with_return_remove(n);
}
static int kvm_vcpufd_change_notify(Error **errp)
{
return notifier_with_return_list_notify(&register_vcpufd_changed_notifiers,
&vmfd_notifier, errp);
}
int kvm_irqchip_get_virq(KVMState *s)
{
int next_virq;
@@ -2415,11 +2575,9 @@ void kvm_irqchip_set_qemuirq_gsi(KVMState *s, qemu_irq irq, int gsi)
g_hash_table_insert(s->gsimap, irq, GINT_TO_POINTER(gsi));
}
static void kvm_irqchip_create(KVMState *s)
static int do_kvm_irqchip_create(KVMState *s)
{
int ret;
assert(s->kernel_irqchip_split != ON_OFF_AUTO_AUTO);
if (kvm_check_extension(s, KVM_CAP_IRQCHIP)) {
;
} else if (kvm_check_extension(s, KVM_CAP_S390_IRQCHIP)) {
@@ -2429,7 +2587,7 @@ static void kvm_irqchip_create(KVMState *s)
exit(1);
}
} else {
return;
return -EOPNOTSUPP;
}
if (kvm_check_extension(s, KVM_CAP_IRQFD) <= 0) {
@@ -2453,6 +2611,16 @@ static void kvm_irqchip_create(KVMState *s)
exit(1);
}
return 0;
}
static void kvm_irqchip_create(KVMState *s)
{
assert(s->kernel_irqchip_split != ON_OFF_AUTO_AUTO);
if (do_kvm_irqchip_create(s) < 0) {
return;
}
kvm_kernel_irqchip = true;
/* If we have an in-kernel IRQ chip then we must have asynchronous
* interrupt delivery (though the reverse is not necessarily true)
@@ -2607,6 +2775,123 @@ static int kvm_setup_dirty_ring(KVMState *s)
return 0;
}
static int kvm_reset_vmfd(MachineState *ms)
{
KVMState *s;
KVMMemoryListener *kml;
int ret = 0, type;
Error *err = NULL;
/*
* bail if the current architecture does not support VM file
* descriptor change.
*/
if (!kvm_arch_supports_vmfd_change()) {
error_report("This target architecture does not support KVM VM "
"file descriptor change.");
return -EOPNOTSUPP;
}
s = KVM_STATE(ms->accelerator);
kml = &s->memory_listener;
memory_listener_unregister(&kml->listener);
memory_listener_unregister(&kvm_io_listener);
vmfd_notifier.pre = true;
ret = kvm_vmfd_change_notify(&err);
if (ret < 0) {
return ret;
}
assert(!err);
if (s->vmfd >= 0) {
close(s->vmfd);
}
type = find_kvm_machine_type(ms);
if (type < 0) {
return -EINVAL;
}
ret = do_kvm_create_vm(s, type);
if (ret < 0) {
return ret;
}
s->vmfd = ret;
/* guest state is now unprotected again */
kvm_state->guest_state_protected = false;
kvm_setup_dirty_ring(s);
/* rebind memory to new vm fd */
ret = ram_block_rebind(&err);
if (ret < 0) {
return ret;
}
assert(!err);
ret = kvm_arch_on_vmfd_change(ms, s);
if (ret < 0) {
return ret;
}
if (s->kernel_irqchip_allowed) {
/* ignore return from this function */
do_kvm_irqchip_create(s);
}
/*
* notify everyone that vmfd has changed.
*/
vmfd_notifier.vmfd = s->vmfd;
vmfd_notifier.pre = false;
ret = kvm_vmfd_change_notify(&err);
if (ret < 0) {
return ret;
}
assert(!err);
/*
* rebind new vcpu fds with the new kvm fds
* These can only be called after kvm_arch_on_vmfd_change()
*/
ret = kvm_rebind_vcpus(&err);
if (ret < 0) {
return ret;
}
assert(!err);
/* notify everyone that vcpu fd has changed. */
ret = kvm_vcpufd_change_notify(&err);
if (ret < 0) {
return ret;
}
assert(!err);
/* these can be only called after ram_block_rebind() */
memory_listener_register(&kml->listener, &address_space_memory);
memory_listener_register(&kvm_io_listener, &address_space_io);
/*
* kvm fd has changed. Commit the irq routes to KVM once more.
*/
kvm_irqchip_commit_routes(s);
/*
* for confidential guest, this is the last possible place where we
* can call synchronize_all_post_init() to sync all vcpu states to
* kvm.
*/
if (ms->cgs) {
cpu_synchronize_all_post_init();
}
trace_kvm_reset_vmfd();
return ret;
}
static int kvm_init(AccelState *as, MachineState *ms)
{
MachineClass *mc = MACHINE_GET_CLASS(ms);
@@ -2712,7 +2997,7 @@ static int kvm_init(AccelState *as, MachineState *ms)
nc++;
}
missing_cap = kvm_check_extension_list(s, kvm_required_capabilites);
missing_cap = kvm_check_extension_list(s, kvm_required_capabilities);
if (!missing_cap) {
missing_cap =
kvm_check_extension_list(s, kvm_arch_required_capabilities);
@@ -3124,7 +3409,7 @@ int kvm_convert_memory(hwaddr start, hwaddr size, bool to_private)
addr = memory_region_get_ram_ptr(mr) + section.offset_within_region;
rb = qemu_ram_block_from_host(addr, false, &offset);
ret = ram_block_attributes_state_change(RAM_BLOCK_ATTRIBUTES(mr->rdm),
ret = ram_block_attributes_state_change(rb->attributes,
offset, size, to_private);
if (ret) {
error_report("Failed to notify the listener the state change of "
@@ -3300,6 +3585,7 @@ int kvm_cpu_exec(CPUState *cpu)
qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
ret = EXCP_INTERRUPT;
break;
case KVM_SYSTEM_EVENT_SEV_TERM:
case KVM_SYSTEM_EVENT_CRASH:
kvm_cpu_synchronize_state(cpu);
bql_lock();
@@ -3996,6 +4282,7 @@ static void kvm_accel_instance_init(Object *obj)
s->xen_evtchn_max_pirq = 256;
s->device = NULL;
s->msr_energy.enable = false;
s->honor_guest_pat = ON_OFF_AUTO_OFF;
}
/**
@@ -4014,6 +4301,7 @@ static void kvm_accel_class_init(ObjectClass *oc, const void *data)
AccelClass *ac = ACCEL_CLASS(oc);
ac->name = "KVM";
ac->init_machine = kvm_init;
ac->rebuild_guest = kvm_reset_vmfd;
ac->has_memory = kvm_accel_has_memory;
ac->allowed = &kvm_allowed;
ac->gdbstub_supported_sstep_flags = kvm_gdbstub_sstep_flags;
+2
View File
@@ -14,6 +14,8 @@ kvm_destroy_vcpu(int cpu_index, unsigned long arch_cpu_id) "index: %d id: %lu"
kvm_park_vcpu(int cpu_index, unsigned long arch_cpu_id) "index: %d id: %lu"
kvm_unpark_vcpu(unsigned long arch_cpu_id, const char *msg) "id: %lu %s"
kvm_irqchip_commit_routes(void) ""
kvm_reset_vmfd(void) ""
kvm_rebind_vcpus(void) ""
kvm_irqchip_add_msi_route(char *name, int vector, int virq) "dev %s vector %d virq %d"
kvm_irqchip_update_msi_route(int virq) "Updating MSI route virq=%d"
kvm_irqchip_release_virq(int virq) "virq %d"
+2
View File
@@ -6,11 +6,13 @@ user_ss.add(files('accel-user.c'))
subdir('tcg')
if have_system
subdir('hvf')
subdir('whpx')
subdir('qtest')
subdir('kvm')
subdir('xen')
subdir('stubs')
subdir('mshv')
subdir('nitro')
endif
# qtest
+1 -2
View File
@@ -10,8 +10,8 @@
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "linux/mshv.h"
#include "qemu/osdep.h"
#include "linux/mshv.h"
#include "qemu/error-report.h"
#include "hw/hyperv/hvhdk_mini.h"
#include "hw/hyperv/hvgdk_mini.h"
@@ -20,7 +20,6 @@
#include "system/mshv.h"
#include "system/mshv_int.h"
#include "trace.h"
#include <stdint.h>
#include <sys/ioctl.h>
#define MSHV_IRQFD_RESAMPLE_FLAG (1 << MSHV_IRQFD_BIT_RESAMPLE)
+28 -378
View File
@@ -11,9 +11,7 @@
*/
#include "qemu/osdep.h"
#include "qemu/lockable.h"
#include "qemu/error-report.h"
#include "qemu/rcu.h"
#include "linux/mshv.h"
#include "system/address-spaces.h"
#include "system/mshv.h"
@@ -22,137 +20,6 @@
#include <sys/ioctl.h>
#include "trace.h"
typedef struct SlotsRCUReclaim {
struct rcu_head rcu;
GList *old_head;
MshvMemorySlot *removed_slot;
} SlotsRCUReclaim;
static void rcu_reclaim_slotlist(struct rcu_head *rcu)
{
SlotsRCUReclaim *r = container_of(rcu, SlotsRCUReclaim, rcu);
g_list_free(r->old_head);
g_free(r->removed_slot);
g_free(r);
}
static void publish_slots(GList *new_head, GList *old_head,
MshvMemorySlot *removed_slot)
{
MshvMemorySlotManager *manager = &mshv_state->msm;
assert(manager);
qatomic_store_release(&manager->slots, new_head);
SlotsRCUReclaim *r = g_new(SlotsRCUReclaim, 1);
r->old_head = old_head;
r->removed_slot = removed_slot;
call_rcu1(&r->rcu, rcu_reclaim_slotlist);
}
/* Needs to be called with mshv_state->msm.mutex held */
static int remove_slot(MshvMemorySlot *slot)
{
GList *old_head, *new_head;
MshvMemorySlotManager *manager = &mshv_state->msm;
assert(manager);
old_head = qatomic_load_acquire(&manager->slots);
if (!g_list_find(old_head, slot)) {
error_report("slot requested for removal not found");
return -1;
}
new_head = g_list_copy(old_head);
new_head = g_list_remove(new_head, slot);
manager->n_slots--;
publish_slots(new_head, old_head, slot);
return 0;
}
/* Needs to be called with mshv_state->msm.mutex held */
static MshvMemorySlot *append_slot(uint64_t gpa, uint64_t userspace_addr,
uint64_t size, bool readonly)
{
GList *old_head, *new_head;
MshvMemorySlot *slot;
MshvMemorySlotManager *manager = &mshv_state->msm;
assert(manager);
old_head = qatomic_load_acquire(&manager->slots);
if (manager->n_slots >= MSHV_MAX_MEM_SLOTS) {
error_report("no free memory slots available");
return NULL;
}
slot = g_new0(MshvMemorySlot, 1);
slot->guest_phys_addr = gpa;
slot->userspace_addr = userspace_addr;
slot->memory_size = size;
slot->readonly = readonly;
new_head = g_list_copy(old_head);
new_head = g_list_append(new_head, slot);
manager->n_slots++;
publish_slots(new_head, old_head, NULL);
return slot;
}
static int slot_overlaps(const MshvMemorySlot *slot1,
const MshvMemorySlot *slot2)
{
uint64_t start_1 = slot1->userspace_addr,
start_2 = slot2->userspace_addr;
size_t len_1 = slot1->memory_size,
len_2 = slot2->memory_size;
if (slot1 == slot2) {
return -1;
}
return ranges_overlap(start_1, len_1, start_2, len_2) ? 0 : -1;
}
static bool is_mapped(MshvMemorySlot *slot)
{
/* Subsequent reads of mapped field see a fully-initialized slot */
return qatomic_load_acquire(&slot->mapped);
}
/*
* Find slot that is:
* - overlapping in userspace
* - currently mapped in the guest
*
* Needs to be called with mshv_state->msm.mutex or RCU read lock held.
*/
static MshvMemorySlot *find_overlap_mem_slot(GList *head, MshvMemorySlot *slot)
{
GList *found;
MshvMemorySlot *overlap_slot;
found = g_list_find_custom(head, slot, (GCompareFunc) slot_overlaps);
if (!found) {
return NULL;
}
overlap_slot = found->data;
if (!overlap_slot || !is_mapped(overlap_slot)) {
return NULL;
}
return overlap_slot;
}
static int set_guest_memory(int vm_fd,
const struct mshv_user_mem_region *region)
{
@@ -160,169 +27,38 @@ static int set_guest_memory(int vm_fd,
ret = ioctl(vm_fd, MSHV_SET_GUEST_MEMORY, region);
if (ret < 0) {
error_report("failed to set guest memory: %s", strerror(errno));
return -1;
error_report("failed to set guest memory");
return -errno;
}
return 0;
}
static int map_or_unmap(int vm_fd, const MshvMemorySlot *slot, bool map)
static int map_or_unmap(int vm_fd, const MshvMemoryRegion *mr, bool map)
{
struct mshv_user_mem_region region = {0};
region.guest_pfn = slot->guest_phys_addr >> MSHV_PAGE_SHIFT;
region.size = slot->memory_size;
region.userspace_addr = slot->userspace_addr;
region.guest_pfn = mr->guest_phys_addr >> MSHV_PAGE_SHIFT;
region.size = mr->memory_size;
region.userspace_addr = mr->userspace_addr;
if (!map) {
region.flags |= (1 << MSHV_SET_MEM_BIT_UNMAP);
trace_mshv_unmap_memory(slot->userspace_addr, slot->guest_phys_addr,
slot->memory_size);
trace_mshv_unmap_memory(mr->userspace_addr, mr->guest_phys_addr,
mr->memory_size);
return set_guest_memory(vm_fd, &region);
}
region.flags = BIT(MSHV_SET_MEM_BIT_EXECUTABLE);
if (!slot->readonly) {
if (!mr->readonly) {
region.flags |= BIT(MSHV_SET_MEM_BIT_WRITABLE);
}
trace_mshv_map_memory(slot->userspace_addr, slot->guest_phys_addr,
slot->memory_size);
trace_mshv_map_memory(mr->userspace_addr, mr->guest_phys_addr,
mr->memory_size);
return set_guest_memory(vm_fd, &region);
}
static int slot_matches_region(const MshvMemorySlot *slot1,
const MshvMemorySlot *slot2)
{
return (slot1->guest_phys_addr == slot2->guest_phys_addr &&
slot1->userspace_addr == slot2->userspace_addr &&
slot1->memory_size == slot2->memory_size) ? 0 : -1;
}
/* Needs to be called with mshv_state->msm.mutex held */
static MshvMemorySlot *find_mem_slot_by_region(uint64_t gpa, uint64_t size,
uint64_t userspace_addr)
{
MshvMemorySlot ref_slot = {
.guest_phys_addr = gpa,
.userspace_addr = userspace_addr,
.memory_size = size,
};
GList *found;
MshvMemorySlotManager *manager = &mshv_state->msm;
assert(manager);
found = g_list_find_custom(manager->slots, &ref_slot,
(GCompareFunc) slot_matches_region);
return found ? found->data : NULL;
}
static int slot_covers_gpa(const MshvMemorySlot *slot, uint64_t *gpa_p)
{
uint64_t gpa_offset, gpa = *gpa_p;
gpa_offset = gpa - slot->guest_phys_addr;
return (slot->guest_phys_addr <= gpa && gpa_offset < slot->memory_size)
? 0 : -1;
}
/* Needs to be called with mshv_state->msm.mutex or RCU read lock held */
static MshvMemorySlot *find_mem_slot_by_gpa(GList *head, uint64_t gpa)
{
GList *found;
MshvMemorySlot *slot;
trace_mshv_find_slot_by_gpa(gpa);
found = g_list_find_custom(head, &gpa, (GCompareFunc) slot_covers_gpa);
if (found) {
slot = found->data;
trace_mshv_found_slot(slot->userspace_addr, slot->guest_phys_addr,
slot->memory_size);
return slot;
}
return NULL;
}
/* Needs to be called with mshv_state->msm.mutex held */
static void set_mapped(MshvMemorySlot *slot, bool mapped)
{
/* prior writes to mapped field becomes visible before readers see slot */
qatomic_store_release(&slot->mapped, mapped);
}
MshvRemapResult mshv_remap_overlap_region(int vm_fd, uint64_t gpa)
{
MshvMemorySlot *gpa_slot, *overlap_slot;
GList *head;
int ret;
MshvMemorySlotManager *manager = &mshv_state->msm;
/* fast path, called often by unmapped_gpa vm exit */
WITH_RCU_READ_LOCK_GUARD() {
assert(manager);
head = qatomic_load_acquire(&manager->slots);
/* return early if no slot is found */
gpa_slot = find_mem_slot_by_gpa(head, gpa);
if (gpa_slot == NULL) {
return MshvRemapNoMapping;
}
/* return early if no overlapping slot is found */
overlap_slot = find_overlap_mem_slot(head, gpa_slot);
if (overlap_slot == NULL) {
return MshvRemapNoOverlap;
}
}
/*
* We'll modify the mapping list, so we need to upgrade to mutex and
* recheck.
*/
assert(manager);
QEMU_LOCK_GUARD(&manager->mutex);
/* return early if no slot is found */
gpa_slot = find_mem_slot_by_gpa(manager->slots, gpa);
if (gpa_slot == NULL) {
return MshvRemapNoMapping;
}
/* return early if no overlapping slot is found */
overlap_slot = find_overlap_mem_slot(manager->slots, gpa_slot);
if (overlap_slot == NULL) {
return MshvRemapNoOverlap;
}
/* unmap overlapping slot */
ret = map_or_unmap(vm_fd, overlap_slot, false);
if (ret < 0) {
error_report("failed to unmap overlap region");
abort();
}
set_mapped(overlap_slot, false);
warn_report("mapped out userspace_addr=0x%016lx gpa=0x%010lx size=0x%lx",
overlap_slot->userspace_addr,
overlap_slot->guest_phys_addr,
overlap_slot->memory_size);
/* map region for gpa */
ret = map_or_unmap(vm_fd, gpa_slot, true);
if (ret < 0) {
error_report("failed to map new region");
abort();
}
set_mapped(gpa_slot, true);
warn_report("mapped in userspace_addr=0x%016lx gpa=0x%010lx size=0x%lx",
gpa_slot->userspace_addr, gpa_slot->guest_phys_addr,
gpa_slot->memory_size);
return MshvRemapOk;
}
static int handle_unmapped_mmio_region_read(uint64_t gpa, uint64_t size,
uint8_t *data)
{
@@ -388,97 +124,20 @@ int mshv_guest_mem_write(uint64_t gpa, const uint8_t *data, uintptr_t size,
return -1;
}
static int tracked_unmap(int vm_fd, uint64_t gpa, uint64_t size,
uint64_t userspace_addr)
static int set_memory(const MshvMemoryRegion *mshv_mr, bool add)
{
int ret;
MshvMemorySlot *slot;
MshvMemorySlotManager *manager = &mshv_state->msm;
int ret = 0;
assert(manager);
QEMU_LOCK_GUARD(&manager->mutex);
slot = find_mem_slot_by_region(gpa, size, userspace_addr);
if (!slot) {
trace_mshv_skip_unset_mem(userspace_addr, gpa, size);
/* no work to do */
return 0;
}
if (!is_mapped(slot)) {
/* remove slot, no need to unmap */
return remove_slot(slot);
}
ret = map_or_unmap(vm_fd, slot, false);
if (ret < 0) {
error_report("failed to unmap memory region");
return ret;
}
return remove_slot(slot);
}
static int tracked_map(int vm_fd, uint64_t gpa, uint64_t size, bool readonly,
uint64_t userspace_addr)
{
MshvMemorySlot *slot, *overlap_slot;
int ret;
MshvMemorySlotManager *manager = &mshv_state->msm;
assert(manager);
QEMU_LOCK_GUARD(&manager->mutex);
slot = find_mem_slot_by_region(gpa, size, userspace_addr);
if (slot) {
error_report("memory region already mapped at gpa=0x%lx, "
"userspace_addr=0x%lx, size=0x%lx",
slot->guest_phys_addr, slot->userspace_addr,
slot->memory_size);
if (!mshv_mr) {
error_report("Invalid mshv_mr");
return -1;
}
slot = append_slot(gpa, userspace_addr, size, readonly);
overlap_slot = find_overlap_mem_slot(manager->slots, slot);
if (overlap_slot) {
trace_mshv_remap_attempt(slot->userspace_addr,
slot->guest_phys_addr,
slot->memory_size);
warn_report("attempt to map region [0x%lx-0x%lx], while "
"[0x%lx-0x%lx] is already mapped in the guest",
userspace_addr, userspace_addr + size - 1,
overlap_slot->userspace_addr,
overlap_slot->userspace_addr +
overlap_slot->memory_size - 1);
/* do not register mem slot in hv, but record for later swap-in */
set_mapped(slot, false);
return 0;
}
ret = map_or_unmap(vm_fd, slot, true);
if (ret < 0) {
error_report("failed to map memory region");
return -1;
}
set_mapped(slot, true);
return 0;
}
static int set_memory(uint64_t gpa, uint64_t size, bool readonly,
uint64_t userspace_addr, bool add)
{
int vm_fd = mshv_state->vm;
if (add) {
return tracked_map(vm_fd, gpa, size, readonly, userspace_addr);
}
return tracked_unmap(vm_fd, gpa, size, userspace_addr);
trace_mshv_set_memory(add, mshv_mr->guest_phys_addr,
mshv_mr->memory_size,
mshv_mr->userspace_addr, mshv_mr->readonly,
ret);
return map_or_unmap(mshv_state->vm, mshv_mr, add);
}
/*
@@ -514,9 +173,7 @@ void mshv_set_phys_mem(MshvMemoryListener *mml, MemoryRegionSection *section,
bool writable = !area->readonly && !area->rom_device;
hwaddr start_addr, mr_offset, size;
void *ram;
size = align_section(section, &start_addr);
trace_mshv_set_phys_mem(add, section->mr->name, start_addr);
MshvMemoryRegion mshv_mr = {0};
size = align_section(section, &start_addr);
trace_mshv_set_phys_mem(add, section->mr->name, start_addr);
@@ -543,21 +200,14 @@ void mshv_set_phys_mem(MshvMemoryListener *mml, MemoryRegionSection *section,
ram = memory_region_get_ram_ptr(area) + mr_offset;
ret = set_memory(start_addr, size, !writable, (uint64_t)ram, add);
mshv_mr.guest_phys_addr = start_addr;
mshv_mr.memory_size = size;
mshv_mr.readonly = !writable;
mshv_mr.userspace_addr = (uint64_t)ram;
ret = set_memory(&mshv_mr, add);
if (ret < 0) {
error_report("failed to set memory region");
error_report("Failed to set memory region");
abort();
}
}
void mshv_init_memory_slot_manager(MshvState *mshv_state)
{
MshvMemorySlotManager *manager;
assert(mshv_state);
manager = &mshv_state->msm;
manager->n_slots = 0;
manager->slots = NULL;
qemu_mutex_init(&manager->mutex);
}
+1 -4
View File
@@ -1,9 +1,6 @@
mshv_ss = ss.source_set()
mshv_ss.add(if_true: files(
system_ss.add(when: 'CONFIG_MSHV', if_true: files(
'irq.c',
'mem.c',
'msr.c',
'mshv-all.c'
))
specific_ss.add_all(when: 'CONFIG_MSHV', if_true: mshv_ss)
+3 -5
View File
@@ -19,7 +19,7 @@
#include "qemu/event_notifier.h"
#include "qemu/module.h"
#include "qemu/main-loop.h"
#include "hw/boards.h"
#include "hw/core/boards.h"
#include "hw/hyperv/hvhdk.h"
#include "hw/hyperv/hvhdk_mini.h"
@@ -31,6 +31,7 @@
#include "qemu/guest-random.h"
#include "accel/accel-ops.h"
#include "accel/accel-cpu-ops.h"
#include "exec/cpu-common.h"
#include "system/cpus.h"
#include "system/runstate.h"
#include "system/accel-blocker.h"
@@ -40,7 +41,6 @@
#include "system/reset.h"
#include "trace.h"
#include <err.h>
#include <stdint.h>
#include <sys/ioctl.h>
#define TYPE_MSHV_ACCEL ACCEL_CLASS_NAME("mshv")
@@ -381,7 +381,7 @@ static void register_mshv_memory_listener(MshvState *s, MshvMemoryListener *mml,
}
}
int mshv_hvcall(int fd, const struct mshv_root_hvcall *args)
int mshv_hvcall(int fd, const mshv_root_hvcall *args)
{
int ret = 0;
@@ -437,8 +437,6 @@ static int mshv_init(AccelState *as, MachineState *ms)
mshv_init_msicontrol();
mshv_init_memory_slot_manager(s);
ret = create_vm(mshv_fd, &vm_fd);
if (ret < 0) {
close(mshv_fd);
-5
View File
@@ -26,8 +26,3 @@ mshv_map_memory(uint64_t userspace_addr, uint64_t gpa, uint64_t size) "\tu_a=0x%
mshv_unmap_memory(uint64_t userspace_addr, uint64_t gpa, uint64_t size) "\tu_a=0x%" PRIx64 " gpa=0x%010" PRIx64 " size=0x%08" PRIx64
mshv_set_phys_mem(bool add, const char *name, uint64_t gpa) "\tadd=%d name=%s gpa=0x%010" PRIx64
mshv_handle_mmio(uint64_t gva, uint64_t gpa, uint64_t size, uint8_t access_type) "\tgva=0x%" PRIx64 " gpa=0x%010" PRIx64 " size=0x%" PRIx64 " access_type=%d"
mshv_found_slot(uint64_t userspace_addr, uint64_t gpa, uint64_t size) "\tu_a=0x%" PRIx64 " gpa=0x%010" PRIx64 " size=0x%08" PRIx64
mshv_skip_unset_mem(uint64_t userspace_addr, uint64_t gpa, uint64_t size) "\tu_a=0x%" PRIx64 " gpa=0x%010" PRIx64 " size=0x%08" PRIx64
mshv_remap_attempt(uint64_t userspace_addr, uint64_t gpa, uint64_t size) "\tu_a=0x%" PRIx64 " gpa=0x%010" PRIx64 " size=0x%08" PRIx64
mshv_find_slot_by_gpa(uint64_t gpa) "\tgpa=0x%010" PRIx64
+3
View File
@@ -0,0 +1,3 @@
nitro_ss = ss.source_set()
nitro_ss.add(files('nitro-accel.c'))
system_ss.add_all(when: 'CONFIG_NITRO', if_true: nitro_ss)
+284
View File
@@ -0,0 +1,284 @@
/*
* Nitro Enclaves accelerator
*
* Copyright © 2026 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Authors:
* Alexander Graf <[email protected]>
*
* Nitro Enclaves are a confidential compute technology which
* allows a parent instance to carve out resources from itself
* and spawn a confidential sibling VM next to itself. Similar
* to other confidential compute solutions, this sibling is
* controlled by an underlying vmm, but still has a higher level
* vmm (QEMU) to implement some of its I/O functionality and
* lifecycle.
*
* This accelerator drives /dev/nitro_enclaves to spawn a Nitro
* Enclave. It works in tandem with the nitro_enclaves machine
* which ensures the correct backend devices are available and
* that the initial seed (an EIF file) is loaded at the correct
* offset in memory.
*
* The accel starts the enclave when the machine starts, after
* all device setup is finished.
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "qemu/osdep.h"
#include "qemu/error-report.h"
#include "qapi/error.h"
#include "qapi/visitor.h"
#include "qemu/module.h"
#include "qemu/rcu.h"
#include "qemu/accel.h"
#include "qemu/guest-random.h"
#include "qemu/main-loop.h"
#include "accel/accel-ops.h"
#include "accel/accel-cpu-ops.h"
#include "accel/dummy-cpus.h"
#include "system/cpus.h"
#include "hw/core/cpu.h"
#include "hw/core/boards.h"
#include "hw/nitro/nitro-vsock-bus.h"
#include "system/ramblock.h"
#include "system/nitro-accel.h"
#include "trace.h"
#include <sys/ioctl.h>
#include "standard-headers/linux/nitro_enclaves.h"
bool nitro_allowed;
typedef struct NitroAccelState {
AccelState parent_obj;
int ne_fd;
int enclave_fd;
uint64_t slot_uid;
uint64_t enclave_cid;
bool debug_mode;
} NitroAccelState;
static int nitro_init_machine(AccelState *as, MachineState *ms)
{
NitroAccelState *s = NITRO_ACCEL(as);
uint64_t slot_uid = 0;
int ret;
s->ne_fd = open("/dev/nitro_enclaves", O_RDWR | O_CLOEXEC);
if (s->ne_fd < 0) {
error_report("nitro: failed to open /dev/nitro_enclaves: %s",
strerror(errno));
return -errno;
}
ret = ioctl(s->ne_fd, NE_CREATE_VM, &slot_uid);
if (ret < 0) {
error_report("nitro: NE_CREATE_VM failed: %s", strerror(errno));
close(s->ne_fd);
return -errno;
}
s->enclave_fd = ret;
s->slot_uid = slot_uid;
return 0;
}
static int nitro_donate_ram_block(RAMBlock *rb, void *opaque)
{
NitroAccelState *s = opaque;
struct ne_user_memory_region region = {
.flags = 0,
.memory_size = rb->used_length,
.userspace_addr = (uint64_t)(uintptr_t)rb->host,
};
if (!rb->used_length) {
return 0;
}
if (ioctl(s->enclave_fd, NE_SET_USER_MEMORY_REGION, &region) < 0) {
error_report("nitro: NE_SET_USER_MEMORY_REGION failed for %s "
"(%" PRIu64 " bytes): %s", rb->idstr, rb->used_length,
strerror(errno));
return -errno;
}
return 0;
}
/*
* Start the Enclave. At this point memory is set up and the EIF is loaded.
* This function donates memory, adds vCPUs, and starts the enclave.
*/
static void nitro_setup_post(AccelState *as)
{
MachineState *ms = MACHINE(qdev_get_machine());
NitroAccelState *s = NITRO_ACCEL(as);
int nr_cpus = ms->smp.cpus;
int i, ret;
struct ne_enclave_start_info start_info = {
.flags = s->debug_mode ? NE_ENCLAVE_DEBUG_MODE : 0,
.enclave_cid = s->enclave_cid,
};
ret = qemu_ram_foreach_block(nitro_donate_ram_block, s);
if (ret < 0) {
error_report("nitro: failed to donate memory");
exit(1);
}
for (i = 0; i < nr_cpus; i++) {
uint32_t cpu_id = 0;
if (ioctl(s->enclave_fd, NE_ADD_VCPU, &cpu_id) < 0) {
error_report("nitro: NE_ADD_VCPU failed: %s", strerror(errno));
exit(1);
}
}
ret = ioctl(s->enclave_fd, NE_START_ENCLAVE, &start_info);
if (ret < 0) {
switch (errno) {
case NE_ERR_NO_MEM_REGIONS_ADDED:
error_report("nitro: no memory regions added");
break;
case NE_ERR_NO_VCPUS_ADDED:
error_report("nitro: no vCPUs added");
break;
case NE_ERR_ENCLAVE_MEM_MIN_SIZE:
error_report("nitro: memory is below the minimum "
"required size. Try increasing -m");
break;
case NE_ERR_FULL_CORES_NOT_USED:
error_report("nitro: requires full CPU cores. "
"Try increasing -smp to a multiple of threads "
"per core on this host (e.g. -smp 2)");
break;
case NE_ERR_NOT_IN_INIT_STATE:
error_report("nitro: not in init state");
break;
case NE_ERR_INVALID_FLAG_VALUE:
error_report("nitro: invalid flag value for NE_START_ENCLAVE");
break;
case NE_ERR_INVALID_ENCLAVE_CID:
error_report("nitro: invalid enclave CID");
break;
default:
error_report("nitro: NE_START_ENCLAVE failed: %s (errno %d)",
strerror(errno), errno);
break;
}
exit(1);
}
s->enclave_cid = start_info.enclave_cid;
trace_nitro_enclave_started(s->enclave_cid);
/*
* Notify all Nitro vsock bus devices that the enclave has started
* and provide them with the CID for vsock connections.
*/
{
NitroVsockBridge *bridge = nitro_vsock_bridge_find();
Error *err = NULL;
if (bridge) {
nitro_vsock_bridge_start_enclave(bridge,
(uint32_t)s->enclave_cid, &err);
if (err) {
error_report_err(err);
exit(1);
}
}
}
}
/* QOM properties */
static bool nitro_get_debug_mode(Object *obj, Error **errp)
{
return NITRO_ACCEL(obj)->debug_mode;
}
static void nitro_set_debug_mode(Object *obj, bool value, Error **errp)
{
NITRO_ACCEL(obj)->debug_mode = value;
}
static void nitro_get_enclave_cid(Object *obj, Visitor *v,
const char *name, void *opaque,
Error **errp)
{
uint64_t val = NITRO_ACCEL(obj)->enclave_cid;
visit_type_uint64(v, name, &val, errp);
}
static void nitro_set_enclave_cid(Object *obj, Visitor *v,
const char *name, void *opaque,
Error **errp)
{
uint64_t val;
if (visit_type_uint64(v, name, &val, errp)) {
NITRO_ACCEL(obj)->enclave_cid = val;
}
}
static void nitro_accel_class_init(ObjectClass *oc, const void *data)
{
AccelClass *ac = ACCEL_CLASS(oc);
ac->name = "Nitro";
ac->init_machine = nitro_init_machine;
ac->setup_post = nitro_setup_post;
ac->allowed = &nitro_allowed;
object_class_property_add_bool(oc, "debug-mode",
nitro_get_debug_mode,
nitro_set_debug_mode);
object_class_property_set_description(oc, "debug-mode",
"Start enclave in debug mode (enables console output)");
object_class_property_add(oc, "enclave-cid", "uint64",
nitro_get_enclave_cid,
nitro_set_enclave_cid,
NULL, NULL);
object_class_property_set_description(oc, "enclave-cid",
"Enclave CID (0 = auto-assigned by Nitro)");
}
static const TypeInfo nitro_accel_type = {
.name = TYPE_NITRO_ACCEL,
.parent = TYPE_ACCEL,
.instance_size = sizeof(NitroAccelState),
.class_init = nitro_accel_class_init,
};
module_obj(TYPE_NITRO_ACCEL);
static bool nitro_cpus_are_resettable(void)
{
return false;
}
static void nitro_accel_ops_class_init(ObjectClass *oc, const void *data)
{
AccelOpsClass *ops = ACCEL_OPS_CLASS(oc);
ops->create_vcpu_thread = dummy_start_vcpu_thread;
ops->handle_interrupt = generic_handle_interrupt;
ops->cpus_are_resettable = nitro_cpus_are_resettable;
}
static const TypeInfo nitro_accel_ops_type = {
.name = ACCEL_OPS_NAME("nitro"),
.parent = TYPE_ACCEL_OPS,
.class_init = nitro_accel_ops_class_init,
.abstract = true,
};
module_obj(ACCEL_OPS_NAME("nitro"));
static void nitro_type_init(void)
{
type_register_static(&nitro_accel_type);
type_register_static(&nitro_accel_ops_type);
}
type_init(nitro_type_init);
+6
View File
@@ -0,0 +1,6 @@
# SPDX-License-Identifier: GPL-2.0-or-later
#
# See docs/devel/tracing.rst for syntax documentation.
# nitro-accel.c
nitro_enclave_started(uint64_t cid) "nitro: enclave started, CID=%"PRIu64
+2
View File
@@ -0,0 +1,2 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */
#include "trace/trace-accel_nitro.h"
+4 -1
View File
@@ -1 +1,4 @@
qtest_module_ss.add(when: ['CONFIG_SYSTEM_ONLY'], if_true: files('qtest.c'))
qtest_module_ss = ss.source_set()
qtest_module_ss.add(files('qtest.c'))
modules += {'accel': {'qtest': qtest_module_ss}}
+2 -2
View File
@@ -31,12 +31,12 @@ static int64_t qtest_clock_counter;
static int64_t qtest_get_virtual_clock(void)
{
return qatomic_read_i64(&qtest_clock_counter);
return qatomic_read(&qtest_clock_counter);
}
static void qtest_set_virtual_clock(int64_t count)
{
qatomic_set_i64(&qtest_clock_counter, count);
qatomic_set(&qtest_clock_counter, count);
}
static int qtest_init_accel(AccelState *as, MachineState *ms)
+18
View File
@@ -79,6 +79,24 @@ void kvm_irqchip_change_notify(void)
{
}
void kvm_vmfd_add_change_notifier(NotifierWithReturn *n)
{
}
void kvm_vmfd_remove_change_notifier(NotifierWithReturn *n)
{
}
void kvm_vcpufd_add_change_notifier(NotifierWithReturn *n)
{
return;
}
void kvm_vcpufd_remove_change_notifier(NotifierWithReturn *n)
{
return;
}
int kvm_irqchip_add_irqfd_notifier_gsi(KVMState *s, EventNotifier *n,
EventNotifier *rn, int virq)
{
+10 -10
View File
@@ -1,10 +1,10 @@
system_stubs_ss = ss.source_set()
system_stubs_ss.add(when: 'CONFIG_XEN', if_false: files('xen-stub.c'))
system_stubs_ss.add(when: 'CONFIG_KVM', if_false: files('kvm-stub.c'))
system_stubs_ss.add(when: 'CONFIG_TCG', if_false: files('tcg-stub.c'))
system_stubs_ss.add(when: 'CONFIG_HVF', if_false: files('hvf-stub.c'))
system_stubs_ss.add(when: 'CONFIG_NVMM', if_false: files('nvmm-stub.c'))
system_stubs_ss.add(when: 'CONFIG_WHPX', if_false: files('whpx-stub.c'))
system_stubs_ss.add(when: 'CONFIG_MSHV', if_false: files('mshv-stub.c'))
specific_ss.add_all(when: ['CONFIG_SYSTEM_ONLY'], if_true: system_stubs_ss)
stub_ss.add(files(
'hvf-stub.c',
'kvm-stub.c',
'nitro-stub.c',
'mshv-stub.c',
'nvmm-stub.c',
'tcg-stub.c',
'whpx-stub.c',
'xen-stub.c',
))
+11
View File
@@ -0,0 +1,11 @@
/*
* Nitro accel stubs for QEMU
*
* Copyright © 2026 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "qemu/osdep.h"
bool nitro_allowed;
+1
View File
@@ -10,3 +10,4 @@
#include "system/whpx.h"
bool whpx_allowed;
bool whpx_irqchip_in_kernel;
-32
View File
@@ -46,11 +46,8 @@ CMPXCHG_HELPER(cmpxchgw_be, uint32_t)
CMPXCHG_HELPER(cmpxchgw_le, uint32_t)
CMPXCHG_HELPER(cmpxchgl_be, uint32_t)
CMPXCHG_HELPER(cmpxchgl_le, uint32_t)
#ifdef CONFIG_ATOMIC64
CMPXCHG_HELPER(cmpxchgq_be, uint64_t)
CMPXCHG_HELPER(cmpxchgq_le, uint64_t)
#endif
#if HAVE_CMPXCHG128
CMPXCHG_HELPER(cmpxchgo_be, Int128)
@@ -59,32 +56,11 @@ CMPXCHG_HELPER(cmpxchgo_le, Int128)
#undef CMPXCHG_HELPER
Int128 HELPER(nonatomic_cmpxchgo)(CPUArchState *env, uint64_t addr,
Int128 cmpv, Int128 newv, uint32_t oi)
{
#if TCG_TARGET_REG_BITS == 32
uintptr_t ra = GETPC();
Int128 oldv;
oldv = cpu_ld16_mmu(env, addr, oi, ra);
if (int128_eq(oldv, cmpv)) {
cpu_st16_mmu(env, addr, newv, oi, ra);
} else {
/* Even with comparison failure, still need a write cycle. */
probe_write(env, addr, 16, get_mmuidx(oi), ra);
}
return oldv;
#else
g_assert_not_reached();
#endif
}
#define ATOMIC_HELPER(OP, TYPE) \
TYPE HELPER(glue(atomic_,OP))(CPUArchState *env, uint64_t addr, \
TYPE val, uint32_t oi) \
{ return glue(glue(cpu_atomic_,OP),_mmu)(env, addr, val, oi, GETPC()); }
#ifdef CONFIG_ATOMIC64
#define GEN_ATOMIC_HELPERS(OP) \
ATOMIC_HELPER(glue(OP,b), uint32_t) \
ATOMIC_HELPER(glue(OP,w_be), uint32_t) \
@@ -93,14 +69,6 @@ Int128 HELPER(nonatomic_cmpxchgo)(CPUArchState *env, uint64_t addr,
ATOMIC_HELPER(glue(OP,l_le), uint32_t) \
ATOMIC_HELPER(glue(OP,q_be), uint64_t) \
ATOMIC_HELPER(glue(OP,q_le), uint64_t)
#else
#define GEN_ATOMIC_HELPERS(OP) \
ATOMIC_HELPER(glue(OP,b), uint32_t) \
ATOMIC_HELPER(glue(OP,w_be), uint32_t) \
ATOMIC_HELPER(glue(OP,w_le), uint32_t) \
ATOMIC_HELPER(glue(OP,l_be), uint32_t) \
ATOMIC_HELPER(glue(OP,l_le), uint32_t)
#endif
GEN_ATOMIC_HELPERS(fetch_add)
GEN_ATOMIC_HELPERS(fetch_and)
+2 -2
View File
@@ -27,8 +27,8 @@
# define SHIFT 4
#elif DATA_SIZE == 8
# define SUFFIX q
# define DATA_TYPE aligned_uint64_t
# define SDATA_TYPE aligned_int64_t
# define DATA_TYPE uint64_t
# define SDATA_TYPE int64_t
# define BSWAP bswap64
# define SHIFT 3
#elif DATA_SIZE == 4
-2
View File
@@ -751,7 +751,6 @@ static inline bool cpu_handle_exception(CPUState *cpu, int *ret)
void tcg_kick_vcpu_thread(CPUState *cpu)
{
#ifndef CONFIG_USER_ONLY
/*
* Ensure cpu_exec will see the reason why the exit request was set.
* FIXME: this is not always needed. Other accelerators instead
@@ -759,7 +758,6 @@ void tcg_kick_vcpu_thread(CPUState *cpu)
* CPU thread; see kvm_arch_pre_run() for example.
*/
qatomic_store_release(&cpu->exit_request, true);
#endif
/* Ensure cpu_exec will see the exit request after TCG has exited. */
qatomic_store_release(&cpu->neg.icount_decr.u16.high, -1);
+27 -67
View File
@@ -30,7 +30,7 @@
#include "accel/tcg/cpu-mmu-index.h"
#include "exec/cputlb.h"
#include "exec/tb-flush.h"
#include "system/ram_addr.h"
#include "system/ramblock.h"
#include "exec/mmu-access-type.h"
#include "exec/tlb-common.h"
#include "exec/vaddr.h"
@@ -857,8 +857,9 @@ void tlb_flush_page_bits_by_mmuidx_all_cpus_synced(CPUState *src_cpu,
void tlb_protect_code(ram_addr_t ram_addr)
{
physical_memory_test_and_clear_dirty(ram_addr & TARGET_PAGE_MASK,
TARGET_PAGE_SIZE,
DIRTY_MEMORY_CODE);
TARGET_PAGE_SIZE,
DIRTY_MEMORY_CODE,
NULL);
}
/* update the TLB so that writes in physical page 'phys_addr' are no longer
@@ -1089,7 +1090,7 @@ void tlb_set_page_full(CPUState *cpu, int mmu_idx,
}
} else {
/* I/O or ROMD */
iotlb = memory_region_section_get_iotlb(cpu, section) + xlat;
iotlb = xlat;
/*
* Writes to romd devices must go through MMIO to enable write.
* Reads to romd devices go through the ram_ptr found above,
@@ -1140,10 +1141,9 @@ void tlb_set_page_full(CPUState *cpu, int mmu_idx,
/*
* When memory region is ram, iotlb contains a TARGET_PAGE_BITS
* aligned ram_addr_t of the page base of the target RAM.
* Otherwise, iotlb contains
* - a physical section number in the lower TARGET_PAGE_BITS
* - the offset within section->mr of the page base (I/O, ROMD) with the
* TARGET_PAGE_BITS masked off.
* Otherwise, iotlb contains a TARGET_PAGE_BITS aligned
* offset within section->mr of the page base (I/O, ROMD)
*
* We subtract addr_page (which is page aligned and thus won't
* disturb the low bits) to give an offset which can be added to the
* (non-page-aligned) vaddr of the eventual memory access to get
@@ -1153,7 +1153,8 @@ void tlb_set_page_full(CPUState *cpu, int mmu_idx,
*/
desc->fulltlb[index] = *full;
full = &desc->fulltlb[index];
full->xlat_section = iotlb - addr_page;
full->xlat_offset = iotlb - addr_page;
full->section = section;
full->phys_addr = paddr_page;
/* Now calculate the new entry */
@@ -1269,14 +1270,14 @@ static inline void cpu_unaligned_access(CPUState *cpu, vaddr addr,
}
static MemoryRegionSection *
io_prepare(hwaddr *out_offset, CPUState *cpu, hwaddr xlat,
MemTxAttrs attrs, vaddr addr, uintptr_t retaddr)
io_prepare(hwaddr *out_offset, CPUState *cpu, CPUTLBEntryFull *full,
vaddr addr, uintptr_t retaddr)
{
MemoryRegionSection *section;
hwaddr mr_offset;
section = iotlb_to_section(cpu, xlat, attrs);
mr_offset = (xlat & TARGET_PAGE_MASK) + addr;
section = full->section;
mr_offset = full->xlat_offset + addr;
cpu->mem_io_pc = retaddr;
if (!cpu->neg.can_do_io) {
cpu_io_recompile(cpu, retaddr);
@@ -1335,7 +1336,7 @@ static bool victim_tlb_hit(CPUState *cpu, size_t mmu_idx, size_t index,
static void notdirty_write(CPUState *cpu, vaddr mem_vaddr, unsigned size,
CPUTLBEntryFull *full, uintptr_t retaddr)
{
ram_addr_t ram_addr = mem_vaddr + full->xlat_section;
ram_addr_t ram_addr = mem_vaddr + full->xlat_offset;
trace_memory_notdirty_write_access(mem_vaddr, ram_addr, size);
@@ -1544,18 +1545,18 @@ tb_page_addr_t get_page_addr_code_hostp(CPUArchState *env, vaddr addr,
(void)probe_access_internal(env_cpu(env), addr, 1, MMU_INST_FETCH,
cpu_mmu_index(env_cpu(env), true), false,
&p, &full, 0, false);
hostp, &full, 0, false);
p = *hostp;
if (p == NULL) {
return -1;
}
if (full->lg_page_size < TARGET_PAGE_BITS) {
*hostp = NULL;
return -1;
}
if (hostp) {
*hostp = p;
}
return qemu_ram_addr_from_host_nofail(p);
}
@@ -1592,9 +1593,7 @@ bool tlb_plugin_lookup(CPUState *cpu, vaddr addr, int mmu_idx,
/* We must have an iotlb entry for MMIO */
if (tlb_addr & TLB_MMIO) {
MemoryRegionSection *section =
iotlb_to_section(cpu, full->xlat_section & ~TARGET_PAGE_MASK,
full->attrs);
MemoryRegionSection *section = full->section;
data->is_io = true;
data->mr = section->mr;
} else {
@@ -1975,12 +1974,10 @@ static uint64_t do_ld_mmio_beN(CPUState *cpu, CPUTLBEntryFull *full,
MemoryRegionSection *section;
MemoryRegion *mr;
hwaddr mr_offset;
MemTxAttrs attrs;
tcg_debug_assert(size > 0 && size <= 8);
attrs = full->attrs;
section = io_prepare(&mr_offset, cpu, full->xlat_section, attrs, addr, ra);
section = io_prepare(&mr_offset, cpu, full, addr, ra);
mr = section->mr;
BQL_LOCK_GUARD();
@@ -1995,13 +1992,11 @@ static Int128 do_ld16_mmio_beN(CPUState *cpu, CPUTLBEntryFull *full,
MemoryRegionSection *section;
MemoryRegion *mr;
hwaddr mr_offset;
MemTxAttrs attrs;
uint64_t a, b;
tcg_debug_assert(size > 8 && size <= 16);
attrs = full->attrs;
section = io_prepare(&mr_offset, cpu, full->xlat_section, attrs, addr, ra);
section = io_prepare(&mr_offset, cpu, full, addr, ra);
mr = section->mr;
BQL_LOCK_GUARD();
@@ -2079,25 +2074,6 @@ static uint64_t do_ld_parts_beN(MMULookupPageData *p, uint64_t ret_be)
return ret_be;
}
/**
* do_ld_parts_be4
* @p: translation parameters
* @ret_be: accumulated data
*
* As do_ld_bytes_beN, but with one atomic load.
* Four aligned bytes are guaranteed to cover the load.
*/
static uint64_t do_ld_whole_be4(MMULookupPageData *p, uint64_t ret_be)
{
int o = p->addr & 3;
uint32_t x = load_atomic4(p->haddr - o);
x = cpu_to_be32(x);
x <<= o * 8;
x >>= (4 - p->size) * 8;
return (ret_be << (p->size * 8)) | x;
}
/**
* do_ld_parts_be8
* @p: translation parameters
@@ -2110,7 +2086,7 @@ static uint64_t do_ld_whole_be8(CPUState *cpu, uintptr_t ra,
MMULookupPageData *p, uint64_t ret_be)
{
int o = p->addr & 7;
uint64_t x = load_atomic8_or_exit(cpu, ra, p->haddr - o);
uint64_t x = load_atomic8(p->haddr - o);
x = cpu_to_be64(x);
x <<= o * 8;
@@ -2175,11 +2151,7 @@ static uint64_t do_ld_beN(CPUState *cpu, MMULookupPageData *p,
if (atom == MO_ATOM_IFALIGN_PAIR
? p->size == half_size
: p->size >= half_size) {
if (!HAVE_al8_fast && p->size < 4) {
return do_ld_whole_be4(p, ret_be);
} else {
return do_ld_whole_be8(cpu, ra, p, ret_be);
}
return do_ld_whole_be8(cpu, ra, p, ret_be);
}
/* fall through */
@@ -2516,12 +2488,10 @@ static uint64_t do_st_mmio_leN(CPUState *cpu, CPUTLBEntryFull *full,
MemoryRegionSection *section;
hwaddr mr_offset;
MemoryRegion *mr;
MemTxAttrs attrs;
tcg_debug_assert(size > 0 && size <= 8);
attrs = full->attrs;
section = io_prepare(&mr_offset, cpu, full->xlat_section, attrs, addr, ra);
section = io_prepare(&mr_offset, cpu, full, addr, ra);
mr = section->mr;
BQL_LOCK_GUARD();
@@ -2536,12 +2506,10 @@ static uint64_t do_st16_mmio_leN(CPUState *cpu, CPUTLBEntryFull *full,
MemoryRegionSection *section;
MemoryRegion *mr;
hwaddr mr_offset;
MemTxAttrs attrs;
tcg_debug_assert(size > 8 && size <= 16);
attrs = full->attrs;
section = io_prepare(&mr_offset, cpu, full->xlat_section, attrs, addr, ra);
section = io_prepare(&mr_offset, cpu, full, addr, ra);
mr = section->mr;
BQL_LOCK_GUARD();
@@ -2585,13 +2553,7 @@ static uint64_t do_st_leN(CPUState *cpu, MMULookupPageData *p,
if (atom == MO_ATOM_IFALIGN_PAIR
? p->size == half_size
: p->size >= half_size) {
if (!HAVE_al8_fast && p->size <= 4) {
return store_whole_le4(p->haddr, p->size, val_le);
} else if (HAVE_al8) {
return store_whole_le8(p->haddr, p->size, val_le);
} else {
cpu_loop_exit_atomic(cpu, ra);
}
return store_whole_le8(p->haddr, p->size, val_le);
}
/* fall through */
@@ -2885,10 +2847,8 @@ static void do_st16_mmu(CPUState *cpu, vaddr addr, Int128 val,
#define DATA_SIZE 4
#include "atomic_template.h"
#ifdef CONFIG_ATOMIC64
#define DATA_SIZE 8
#include "atomic_template.h"
#endif
#if defined(CONFIG_ATOMIC128) || HAVE_CMPXCHG128
#define DATA_SIZE 16
+12 -13
View File
@@ -86,8 +86,8 @@ static void icount_update_locked(CPUState *cpu)
int64_t executed = icount_get_executed(cpu);
cpu->icount_budget -= executed;
qatomic_set_i64(&timers_state.qemu_icount,
timers_state.qemu_icount + executed);
qatomic_set(&timers_state.qemu_icount,
timers_state.qemu_icount + executed);
}
/*
@@ -116,15 +116,14 @@ static int64_t icount_get_raw_locked(void)
/* Take into account what has run */
icount_update_locked(cpu);
}
/* The read is protected by the seqlock, but needs atomic64 to avoid UB */
return qatomic_read_i64(&timers_state.qemu_icount);
/* The read is protected by the seqlock, but needs atomic to avoid UB */
return qatomic_read(&timers_state.qemu_icount);
}
static int64_t icount_get_locked(void)
{
int64_t icount = icount_get_raw_locked();
return qatomic_read_i64(&timers_state.qemu_icount_bias) +
icount_to_ns(icount);
return qatomic_read(&timers_state.qemu_icount_bias) + icount_to_ns(icount);
}
int64_t icount_get_raw(void)
@@ -201,9 +200,9 @@ static void icount_adjust(void)
timers_state.icount_time_shift + 1);
}
timers_state.last_delta = delta;
qatomic_set_i64(&timers_state.qemu_icount_bias,
cur_icount - (timers_state.qemu_icount
<< timers_state.icount_time_shift));
qatomic_set(&timers_state.qemu_icount_bias,
cur_icount - (timers_state.qemu_icount
<< timers_state.icount_time_shift));
seqlock_write_unlock(&timers_state.vm_clock_seqlock,
&timers_state.vm_clock_lock);
}
@@ -269,8 +268,8 @@ static void icount_warp_rt(void)
}
warp_delta = MIN(warp_delta, delta);
}
qatomic_set_i64(&timers_state.qemu_icount_bias,
timers_state.qemu_icount_bias + warp_delta);
qatomic_set(&timers_state.qemu_icount_bias,
timers_state.qemu_icount_bias + warp_delta);
}
timers_state.vm_clock_warp_start = -1;
seqlock_write_unlock(&timers_state.vm_clock_seqlock,
@@ -361,8 +360,8 @@ void icount_start_warp_timer(void)
*/
seqlock_write_lock(&timers_state.vm_clock_seqlock,
&timers_state.vm_clock_lock);
qatomic_set_i64(&timers_state.qemu_icount_bias,
timers_state.qemu_icount_bias + deadline);
qatomic_set(&timers_state.qemu_icount_bias,
timers_state.qemu_icount_bias + deadline);
seqlock_write_unlock(&timers_state.vm_clock_seqlock,
&timers_state.vm_clock_lock);
qemu_clock_notify(QEMU_CLOCK_VIRTUAL);
+3 -2
View File
@@ -82,7 +82,7 @@ void tb_check_watchpoint(CPUState *cpu, uintptr_t retaddr);
* See get_page_addr_code() (full-system version) for documentation on the
* return value.
*
* Sets *@hostp (when @hostp is non-NULL) as follows.
* Sets *@hostp as follows.
* If the return value is -1, sets *@hostp to NULL. Otherwise, sets *@hostp
* to the host address where @addr's content is kept.
*
@@ -105,7 +105,8 @@ tb_page_addr_t get_page_addr_code_hostp(CPUArchState *env, vaddr addr,
static inline tb_page_addr_t get_page_addr_code(CPUArchState *env,
vaddr addr)
{
return get_page_addr_code_hostp(env, addr, NULL);
void *discard;
return get_page_addr_code_hostp(env, addr, &discard);
}
/*
+21 -128
View File
@@ -12,13 +12,6 @@
#include "host/load-extract-al16-al8.h.inc"
#include "host/store-insert-al16.h.inc"
#ifdef CONFIG_ATOMIC64
# define HAVE_al8 true
#else
# define HAVE_al8 false
#endif
#define HAVE_al8_fast (ATOMIC_REG_SIZE >= 8)
/**
* required_atomicity:
*
@@ -132,44 +125,7 @@ static inline uint32_t load_atomic4(void *pv)
static inline uint64_t load_atomic8(void *pv)
{
uint64_t *p = __builtin_assume_aligned(pv, 8);
qemu_build_assert(HAVE_al8);
return qatomic_read__nocheck(p);
}
/**
* load_atomic8_or_exit:
* @cpu: generic cpu state
* @ra: host unwind address
* @pv: host address
*
* Atomically load 8 aligned bytes from @pv.
* If this is not possible, longjmp out to restart serially.
*/
static uint64_t load_atomic8_or_exit(CPUState *cpu, uintptr_t ra, void *pv)
{
if (HAVE_al8) {
return load_atomic8(pv);
}
#ifdef CONFIG_USER_ONLY
/*
* If the page is not writable, then assume the value is immutable
* and requires no locking. This ignores the case of MAP_SHARED with
* another process, because the fallback start_exclusive solution
* provides no protection across processes.
*/
WITH_MMAP_LOCK_GUARD() {
if (!page_check_range(h2g(pv), 8, PAGE_WRITE_ORG)) {
uint64_t *p = __builtin_assume_aligned(pv, 8);
return *p;
}
}
#endif
/* Ultimate fallback: re-execute in serial context. */
trace_load_atom8_or_exit_fallback(ra);
cpu_loop_exit_atomic(cpu, ra);
return qatomic_read(p);
}
/**
@@ -264,9 +220,7 @@ static uint64_t load_atom_extract_al8x2(void *pv)
}
/**
* load_atom_extract_al8_or_exit:
* @cpu: generic cpu state
* @ra: host unwind address
* load_atom_extract_al8
* @pv: host address
* @s: object size in bytes, @s <= 4.
*
@@ -275,15 +229,14 @@ static uint64_t load_atom_extract_al8x2(void *pv)
* 8-byte load and extract.
* The value is returned in the low bits of a uint32_t.
*/
static uint32_t load_atom_extract_al8_or_exit(CPUState *cpu, uintptr_t ra,
void *pv, int s)
static uint32_t load_atom_extract_al8(void *pv, int s)
{
uintptr_t pi = (uintptr_t)pv;
int o = pi & 7;
int shr = (HOST_BIG_ENDIAN ? 8 - s - o : o) * 8;
pv = (void *)(pi & ~7);
return load_atomic8_or_exit(cpu, ra, pv) >> shr;
return load_atomic8(pv) >> shr;
}
/**
@@ -297,7 +250,7 @@ static uint32_t load_atom_extract_al8_or_exit(CPUState *cpu, uintptr_t ra,
* and p % 16 + s > 8. I.e. does not cross a 16-byte
* boundary, but *does* cross an 8-byte boundary.
* This is the slow version, so we must have eliminated
* any faster load_atom_extract_al8_or_exit case.
* any faster load_atom_extract_al8 case.
*
* If this is not possible, longjmp out to restart serially.
*/
@@ -374,21 +327,6 @@ static inline uint64_t load_atom_8_by_4(void *pv)
}
}
/**
* load_atom_8_by_8_or_4:
* @pv: host address
*
* Load 8 bytes from aligned @pv, with at least 4-byte atomicity.
*/
static inline uint64_t load_atom_8_by_8_or_4(void *pv)
{
if (HAVE_al8_fast) {
return load_atomic8(pv);
} else {
return load_atom_8_by_4(pv);
}
}
/**
* load_atom_2:
* @p: host address
@@ -418,12 +356,8 @@ static uint16_t load_atom_2(CPUState *cpu, uintptr_t ra,
return lduw_he_p(pv);
case MO_16:
/* The only case remaining is MO_ATOM_WITHIN16. */
if (!HAVE_al8_fast && (pi & 3) == 1) {
/* Big or little endian, we want the middle two bytes. */
return load_atomic4(pv - 1) >> 8;
}
if ((pi & 15) != 7) {
return load_atom_extract_al8_or_exit(cpu, ra, pv, 2);
return load_atom_extract_al8(pv, 2);
}
return load_atom_extract_al16_or_exit(cpu, ra, pv, 2);
default:
@@ -468,7 +402,7 @@ static uint32_t load_atom_4(CPUState *cpu, uintptr_t ra,
return load_atom_extract_al4x2(pv);
case MO_32:
if (!(pi & 4)) {
return load_atom_extract_al8_or_exit(cpu, ra, pv, 4);
return load_atom_extract_al8(pv, 4);
}
return load_atom_extract_al16_or_exit(cpu, ra, pv, 4);
default:
@@ -493,7 +427,7 @@ static uint64_t load_atom_8(CPUState *cpu, uintptr_t ra,
* If the host does not support 8-byte atomics, wait until we have
* examined the atomicity parameters below.
*/
if (HAVE_al8 && likely((pi & 7) == 0)) {
if (likely((pi & 7) == 0)) {
return load_atomic8(pv);
}
if (HAVE_ATOMIC128_RO) {
@@ -502,30 +436,9 @@ static uint64_t load_atom_8(CPUState *cpu, uintptr_t ra,
atmax = required_atomicity(cpu, pi, memop);
if (atmax == MO_64) {
if (!HAVE_al8 && (pi & 7) == 0) {
load_atomic8_or_exit(cpu, ra, pv);
}
return load_atom_extract_al16_or_exit(cpu, ra, pv, 8);
}
if (HAVE_al8_fast) {
return load_atom_extract_al8x2(pv);
}
switch (atmax) {
case MO_8:
return ldq_he_p(pv);
case MO_16:
return load_atom_8_by_2(pv);
case MO_32:
return load_atom_8_by_4(pv);
case -MO_32:
if (HAVE_al8) {
return load_atom_extract_al8x2(pv);
}
trace_load_atom8_fallback(memop, ra);
cpu_loop_exit_atomic(cpu, ra);
default:
g_assert_not_reached();
}
return load_atom_extract_al8x2(pv);
}
/**
@@ -565,18 +478,10 @@ static Int128 load_atom_16(CPUState *cpu, uintptr_t ra,
b = load_atom_8_by_4(pv + 8);
break;
case MO_64:
if (!HAVE_al8) {
trace_load_atom16_fallback(memop, ra);
cpu_loop_exit_atomic(cpu, ra);
}
a = load_atomic8(pv);
b = load_atomic8(pv + 8);
break;
case -MO_64:
if (!HAVE_al8) {
trace_load_atom16_fallback(memop, ra);
cpu_loop_exit_atomic(cpu, ra);
}
a = load_atom_extract_al8x2(pv);
b = load_atom_extract_al8x2(pv + 8);
break;
@@ -624,9 +529,7 @@ static inline void store_atomic4(void *pv, uint32_t val)
static inline void store_atomic8(void *pv, uint64_t val)
{
uint64_t *p = __builtin_assume_aligned(pv, 8);
qemu_build_assert(HAVE_al8);
qatomic_set__nocheck(p, val);
qatomic_set(p, val);
}
/**
@@ -688,9 +591,8 @@ static void store_atom_insert_al8(uint64_t *p, uint64_t val, uint64_t msk)
{
uint64_t old, new;
qemu_build_assert(HAVE_al8);
p = __builtin_assume_aligned(p, 8);
old = qatomic_read__nocheck(p);
old = qatomic_read(p);
do {
new = (old & ~msk) | val;
} while (!__atomic_compare_exchange_n(p, &old, new, true,
@@ -802,7 +704,6 @@ static uint64_t store_whole_le8(void *pv, int size, uint64_t val_le)
uint64_t m = MAKE_64BIT_MASK(0, sz);
uint64_t v;
qemu_build_assert(HAVE_al8);
if (HOST_BIG_ENDIAN) {
v = bswap64(val_le) >> sh;
m = bswap64(m) >> sh;
@@ -887,10 +788,8 @@ static void store_atom_2(CPUState *cpu, uintptr_t ra,
store_atom_insert_al4(pv - 1, (uint32_t)val << 8, MAKE_64BIT_MASK(8, 16));
return;
} else if ((pi & 7) == 3) {
if (HAVE_al8) {
store_atom_insert_al8(pv - 3, (uint64_t)val << 24, MAKE_64BIT_MASK(24, 16));
return;
}
store_atom_insert_al8(pv - 3, (uint64_t)val << 24, MAKE_64BIT_MASK(24, 16));
return;
} else if ((pi & 15) == 7) {
if (HAVE_CMPXCHG128) {
Int128 v = int128_lshift(int128_make64(val), 56);
@@ -957,10 +856,8 @@ static void store_atom_4(CPUState *cpu, uintptr_t ra,
return;
case MO_32:
if ((pi & 7) < 4) {
if (HAVE_al8) {
store_whole_le8(pv, 4, cpu_to_le32(val));
return;
}
store_whole_le8(pv, 4, cpu_to_le32(val));
return;
} else {
if (HAVE_CMPXCHG128) {
store_whole_le16(pv, 4, int128_make64(cpu_to_le32(val)));
@@ -988,7 +885,7 @@ static void store_atom_8(CPUState *cpu, uintptr_t ra,
uintptr_t pi = (uintptr_t)pv;
int atmax;
if (HAVE_al8 && likely((pi & 7) == 0)) {
if (likely((pi & 7) == 0)) {
store_atomic8(pv, val);
return;
}
@@ -1005,7 +902,7 @@ static void store_atom_8(CPUState *cpu, uintptr_t ra,
store_atom_8_by_4(pv, val);
return;
case -MO_32:
if (HAVE_al8) {
{
uint64_t val_le = cpu_to_le64(val);
int s2 = pi & 7;
int s1 = 8 - s2;
@@ -1024,9 +921,8 @@ static void store_atom_8(CPUState *cpu, uintptr_t ra,
default:
g_assert_not_reached();
}
return;
}
break;
return;
case MO_64:
if (HAVE_CMPXCHG128) {
store_whole_le16(pv, 8, int128_make64(cpu_to_le64(val)));
@@ -1077,12 +973,9 @@ static void store_atom_16(CPUState *cpu, uintptr_t ra,
store_atom_8_by_4(pv + 8, b);
return;
case MO_64:
if (HAVE_al8) {
store_atomic8(pv, a);
store_atomic8(pv + 8, b);
return;
}
break;
store_atomic8(pv, a);
store_atomic8(pv + 8, b);
return;
case -MO_64:
if (HAVE_CMPXCHG128) {
uint64_t val_le;
+2 -1
View File
@@ -24,13 +24,14 @@
*/
#include "qemu/osdep.h"
#include "exec/cpu-common.h"
#include "system/tcg.h"
#include "system/replay.h"
#include "exec/icount.h"
#include "qemu/main-loop.h"
#include "qemu/notify.h"
#include "qemu/guest-random.h"
#include "hw/boards.h"
#include "hw/core/boards.h"
#include "tcg/startup.h"
#include "tcg-accel-ops.h"
#include "tcg-accel-ops-mttcg.h"
+1 -1
View File
@@ -37,7 +37,7 @@
#include "qemu/units.h"
#include "qemu/target-info.h"
#ifndef CONFIG_USER_ONLY
#include "hw/boards.h"
#include "hw/core/boards.h"
#include "exec/tb-flush.h"
#include "system/runstate.h"
#endif
-15
View File
@@ -55,21 +55,6 @@ uint32_t HELPER(remu_i32)(uint32_t arg1, uint32_t arg2)
/* 64-bit helpers */
uint64_t HELPER(shl_i64)(uint64_t arg1, uint64_t arg2)
{
return arg1 << arg2;
}
uint64_t HELPER(shr_i64)(uint64_t arg1, uint64_t arg2)
{
return arg1 >> arg2;
}
int64_t HELPER(sar_i64)(int64_t arg1, int64_t arg2)
{
return arg1 >> arg2;
}
int64_t HELPER(div_i64)(int64_t arg1, int64_t arg2)
{
return arg1 / arg2;
-23
View File
@@ -8,10 +8,6 @@ DEF_HELPER_FLAGS_2(rem_i64, TCG_CALL_NO_RWG_SE, s64, s64, s64)
DEF_HELPER_FLAGS_2(divu_i64, TCG_CALL_NO_RWG_SE, i64, i64, i64)
DEF_HELPER_FLAGS_2(remu_i64, TCG_CALL_NO_RWG_SE, i64, i64, i64)
DEF_HELPER_FLAGS_2(shl_i64, TCG_CALL_NO_RWG_SE, i64, i64, i64)
DEF_HELPER_FLAGS_2(shr_i64, TCG_CALL_NO_RWG_SE, i64, i64, i64)
DEF_HELPER_FLAGS_2(sar_i64, TCG_CALL_NO_RWG_SE, s64, s64, s64)
DEF_HELPER_FLAGS_2(mulsh_i64, TCG_CALL_NO_RWG_SE, s64, s64, s64)
DEF_HELPER_FLAGS_2(muluh_i64, TCG_CALL_NO_RWG_SE, i64, i64, i64)
@@ -52,12 +48,10 @@ DEF_HELPER_FLAGS_5(atomic_cmpxchgl_be, TCG_CALL_NO_WG,
i32, env, i64, i32, i32, i32)
DEF_HELPER_FLAGS_5(atomic_cmpxchgl_le, TCG_CALL_NO_WG,
i32, env, i64, i32, i32, i32)
#ifdef CONFIG_ATOMIC64
DEF_HELPER_FLAGS_5(atomic_cmpxchgq_be, TCG_CALL_NO_WG,
i64, env, i64, i64, i64, i32)
DEF_HELPER_FLAGS_5(atomic_cmpxchgq_le, TCG_CALL_NO_WG,
i64, env, i64, i64, i64, i32)
#endif
#if HAVE_CMPXCHG128
DEF_HELPER_FLAGS_5(atomic_cmpxchgo_be, TCG_CALL_NO_WG,
i128, env, i64, i128, i128, i32)
@@ -77,10 +71,6 @@ DEF_HELPER_FLAGS_4(atomic_fetch_oro_le, TCG_CALL_NO_WG,
i128, env, i64, i128, i32)
#endif
DEF_HELPER_FLAGS_5(nonatomic_cmpxchgo, TCG_CALL_NO_WG,
i128, env, i64, i128, i128, i32)
#ifdef CONFIG_ATOMIC64
#define GEN_ATOMIC_HELPERS(NAME) \
DEF_HELPER_FLAGS_4(glue(glue(atomic_, NAME), b), \
TCG_CALL_NO_WG, i32, env, i64, i32, i32) \
@@ -96,19 +86,6 @@ DEF_HELPER_FLAGS_5(nonatomic_cmpxchgo, TCG_CALL_NO_WG,
TCG_CALL_NO_WG, i64, env, i64, i64, i32) \
DEF_HELPER_FLAGS_4(glue(glue(atomic_, NAME), q_be), \
TCG_CALL_NO_WG, i64, env, i64, i64, i32)
#else
#define GEN_ATOMIC_HELPERS(NAME) \
DEF_HELPER_FLAGS_4(glue(glue(atomic_, NAME), b), \
TCG_CALL_NO_WG, i32, env, i64, i32, i32) \
DEF_HELPER_FLAGS_4(glue(glue(atomic_, NAME), w_le), \
TCG_CALL_NO_WG, i32, env, i64, i32, i32) \
DEF_HELPER_FLAGS_4(glue(glue(atomic_, NAME), w_be), \
TCG_CALL_NO_WG, i32, env, i64, i32, i32) \
DEF_HELPER_FLAGS_4(glue(glue(atomic_, NAME), l_le), \
TCG_CALL_NO_WG, i32, env, i64, i32, i32) \
DEF_HELPER_FLAGS_4(glue(glue(atomic_, NAME), l_be), \
TCG_CALL_NO_WG, i32, env, i64, i32, i32)
#endif /* CONFIG_ATOMIC64 */
GEN_ATOMIC_HELPERS(fetch_add)
GEN_ATOMIC_HELPERS(fetch_and)
+1 -3
View File
@@ -352,15 +352,13 @@ static bool translator_ld(CPUArchState *env, DisasContextBase *db,
return true;
}
break;
#ifdef CONFIG_ATOMIC64
case 8:
if (QEMU_IS_ALIGNED(pc, 8)) {
uint64_t t = qatomic_read__nocheck((uint64_t *)host);
uint64_t t = qatomic_read((uint64_t *)host);
stq_he_p(dest, t);
return true;
}
break;
#endif
}
/* Unaligned or partial read from the second page is not atomic. */
memcpy(dest, host, len);
+33
View File
@@ -1,6 +1,8 @@
#include "qemu/osdep.h"
#include "hw/core/cpu.h"
#include "accel/tcg/cpu-ops.h"
#include "exec/replay-core.h"
#include "exec/watchpoint.h"
#include "internal-common.h"
void cpu_resume(CPUState *cpu)
@@ -19,6 +21,37 @@ void cpu_exec_reset_hold(CPUState *cpu)
{
}
int cpu_watchpoint_insert(CPUState *cpu, vaddr addr, vaddr len,
int flags, CPUWatchpoint **watchpoint)
{
return -ENOSYS;
}
int cpu_watchpoint_remove(CPUState *cpu, vaddr addr,
vaddr len, int flags)
{
return -ENOSYS;
}
void cpu_watchpoint_remove_by_ref(CPUState *cpu, CPUWatchpoint *wp)
{
}
void cpu_watchpoint_remove_all(CPUState *cpu, int mask)
{
}
int cpu_watchpoint_address_matches(CPUState *cpu, vaddr addr, vaddr len)
{
return 0;
}
void cpu_check_watchpoint(CPUState *cpu, vaddr addr, vaddr len,
MemTxAttrs atr, int fl, uintptr_t ra)
{
}
/* User mode emulation does not support softmmu yet. */
void tlb_init(CPUState *cpu)
+13 -17
View File
@@ -647,7 +647,7 @@ void tb_lock_page0(tb_page_addr_t address)
if (prot & PAGE_WRITE) {
pageflags_set_clear(start, last, 0, PAGE_WRITE);
mprotect(g2h_untagged(start), last - start + 1,
mprotect(g2h_untagged_vaddr(start), last - start + 1,
prot & (PAGE_READ | PAGE_EXEC) ? PROT_READ : PROT_NONE);
}
}
@@ -734,7 +734,7 @@ int page_unprotect(CPUState *cpu, tb_page_addr_t address, uintptr_t pc)
if (prot & PAGE_EXEC) {
prot = (prot & ~PAGE_EXEC) | PAGE_READ;
}
mprotect((void *)g2h_untagged(start), len, prot & PAGE_RWX);
mprotect((void *)g2h_untagged_vaddr(start), len, prot & PAGE_RWX);
}
mmap_unlock();
@@ -763,7 +763,7 @@ static int probe_access_internal(CPUArchState *env, vaddr addr,
g_assert_not_reached();
}
if (guest_addr_valid_untagged(addr)) {
if (guest_addr_valid_untagged_vaddr(addr)) {
int page_flags = page_get_flags(addr);
if (page_flags & acc_flag) {
if (access_type != MMU_INST_FETCH
@@ -792,7 +792,7 @@ int probe_access_flags(CPUArchState *env, vaddr addr, int size,
g_assert(-(addr | TARGET_PAGE_MASK) >= size);
flags = probe_access_internal(env, addr, size, access_type, nonfault, ra);
*phost = (flags & TLB_INVALID_MASK) ? NULL : g2h(env_cpu(env), addr);
*phost = (flags & TLB_INVALID_MASK) ? NULL : g2h_vaddr(env_cpu(env), addr);
return flags;
}
@@ -805,13 +805,13 @@ void *probe_access(CPUArchState *env, vaddr addr, int size,
flags = probe_access_internal(env, addr, size, access_type, false, ra);
g_assert((flags & ~TLB_MMIO) == 0);
return size ? g2h(env_cpu(env), addr) : NULL;
return size ? g2h_vaddr(env_cpu(env), addr) : NULL;
}
void *tlb_vaddr_to_host(CPUArchState *env, vaddr addr,
MMUAccessType access_type, int mmu_idx)
{
return g2h(env_cpu(env), addr);
return g2h_vaddr(env_cpu(env), addr);
}
tb_page_addr_t get_page_addr_code_hostp(CPUArchState *env, vaddr addr,
@@ -822,9 +822,7 @@ tb_page_addr_t get_page_addr_code_hostp(CPUArchState *env, vaddr addr,
flags = probe_access_internal(env, addr, 1, MMU_INST_FETCH, false, 0);
g_assert(flags == 0);
if (hostp) {
*hostp = g2h_untagged(addr);
}
*hostp = g2h_untagged_vaddr(addr);
return addr;
}
@@ -940,7 +938,7 @@ static void *cpu_mmu_lookup(CPUState *cpu, vaddr addr,
cpu_loop_exit_sigbus(cpu, addr, type, ra);
}
ret = g2h(cpu, addr);
ret = g2h_vaddr(cpu, addr);
set_helper_retaddr(ra);
return ret;
}
@@ -970,7 +968,7 @@ int cpu_memory_rw_debug(CPUState *cpu, vaddr addr,
}
if (is_write) {
if (flags & PAGE_WRITE) {
memcpy(g2h(cpu, addr), buf, l);
memcpy(g2h_vaddr(cpu, addr), buf, l);
} else {
/* Bypass the host page protection using ptrace. */
if (fd == -1) {
@@ -989,13 +987,13 @@ int cpu_memory_rw_debug(CPUState *cpu, vaddr addr,
*/
tb_invalidate_phys_range(NULL, addr, addr + l - 1);
written = pwrite(fd, buf, l,
(off_t)(uintptr_t)g2h_untagged(addr));
(off_t)(uintptr_t)g2h_untagged_vaddr(addr));
if (written != l) {
goto out_close;
}
}
} else if (flags & PAGE_READ) {
memcpy(buf, g2h(cpu, addr), l);
memcpy(buf, g2h_vaddr(cpu, addr), l);
} else {
/* Bypass the host page protection using ptrace. */
if (fd == -1) {
@@ -1005,7 +1003,7 @@ int cpu_memory_rw_debug(CPUState *cpu, vaddr addr,
}
}
if (pread(fd, buf, l,
(off_t)(uintptr_t)g2h_untagged(addr)) != l) {
(off_t)(uintptr_t)g2h_untagged_vaddr(addr)) != l) {
goto out_close;
}
}
@@ -1233,7 +1231,7 @@ static void *atomic_mmu_lookup(CPUState *cpu, vaddr addr, MemOpIdx oi,
cpu_loop_exit_atomic(cpu, retaddr);
}
ret = g2h(cpu, addr);
ret = g2h_vaddr(cpu, addr);
set_helper_retaddr(retaddr);
return ret;
}
@@ -1258,10 +1256,8 @@ static void *atomic_mmu_lookup(CPUState *cpu, vaddr addr, MemOpIdx oi,
#define DATA_SIZE 4
#include "atomic_template.h"
#ifdef CONFIG_ATOMIC64
#define DATA_SIZE 8
#include "atomic_template.h"
#endif
#if defined(CONFIG_ATOMIC128) || HAVE_CMPXCHG128
#define DATA_SIZE 16
+7
View File
@@ -0,0 +1,7 @@
whpx_ss = ss.source_set()
whpx_ss.add(files(
'whpx-accel-ops.c',
'whpx-common.c'
))
specific_ss.add_all(when: 'CONFIG_WHPX', if_true: whpx_ss)
@@ -16,8 +16,9 @@
#include "qemu/guest-random.h"
#include "system/whpx.h"
#include "whpx-internal.h"
#include "whpx-accel-ops.h"
#include "system/whpx-internal.h"
#include "system/whpx-all.h"
#include "system/whpx-accel-ops.h"
static void *whpx_cpu_thread_fn(void *arg)
{
@@ -78,9 +79,15 @@ static void whpx_kick_vcpu_thread(CPUState *cpu)
static bool whpx_vcpu_thread_is_idle(CPUState *cpu)
{
return !whpx_apic_in_platform();
return !whpx_irqchip_in_kernel();
}
static bool whpx_supports_guest_debug(void)
{
return whpx_arch_supports_guest_debug();
}
static void whpx_accel_ops_class_init(ObjectClass *oc, const void *data)
{
AccelOpsClass *ops = ACCEL_OPS_CLASS(oc);
@@ -89,6 +96,7 @@ static void whpx_accel_ops_class_init(ObjectClass *oc, const void *data)
ops->kick_vcpu_thread = whpx_kick_vcpu_thread;
ops->cpu_thread_is_idle = whpx_vcpu_thread_is_idle;
ops->handle_interrupt = generic_handle_interrupt;
ops->supports_guest_debug = whpx_supports_guest_debug;
ops->synchronize_post_reset = whpx_cpu_synchronize_post_reset;
ops->synchronize_post_init = whpx_cpu_synchronize_post_init;
+589
View File
@@ -0,0 +1,589 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
* QEMU Windows Hypervisor Platform accelerator (WHPX)
*
* Copyright Microsoft Corp. 2017
*/
#include "qemu/osdep.h"
#include "cpu.h"
#include "system/address-spaces.h"
#include "system/ioport.h"
#include "gdbstub/helpers.h"
#include "qemu/accel.h"
#include "accel/accel-ops.h"
#include "system/memory.h"
#include "system/whpx.h"
#include "system/cpus.h"
#include "system/runstate.h"
#include "qemu/main-loop.h"
#include "hw/core/boards.h"
#include "hw/intc/ioapic.h"
#include "qemu/error-report.h"
#include "qapi/error.h"
#include "qapi/qapi-types-common.h"
#include "qapi/qapi-visit-common.h"
#include "migration/blocker.h"
#include "accel/accel-cpu-target.h"
#include <winerror.h>
#include "system/whpx-internal.h"
#include "system/whpx-accel-ops.h"
#include "system/whpx-common.h"
#include "system/whpx-all.h"
#include <winhvplatform.h>
#include <winhvplatformdefs.h>
bool whpx_allowed;
bool whpx_irqchip_in_kernel;
static bool whp_dispatch_initialized;
static HMODULE hWinHvPlatform;
struct whpx_state whpx_global;
struct WHPDispatch whp_dispatch;
void whpx_flush_cpu_state(CPUState *cpu)
{
if (cpu->vcpu_dirty) {
whpx_set_registers(cpu, WHPX_LEVEL_RUNTIME_STATE);
cpu->vcpu_dirty = false;
}
}
void whpx_get_reg(CPUState *cpu, WHV_REGISTER_NAME reg, WHV_REGISTER_VALUE* val)
{
struct whpx_state *whpx = &whpx_global;
HRESULT hr;
whpx_flush_cpu_state(cpu);
hr = whp_dispatch.WHvGetVirtualProcessorRegisters(whpx->partition, cpu->cpu_index,
&reg, 1, val);
if (FAILED(hr)) {
error_report("WHPX: Failed to get register %08x, hr=%08lx", reg, hr);
}
}
void whpx_set_reg(CPUState *cpu, WHV_REGISTER_NAME reg, WHV_REGISTER_VALUE val)
{
struct whpx_state *whpx = &whpx_global;
HRESULT hr;
hr = whp_dispatch.WHvSetVirtualProcessorRegisters(whpx->partition, cpu->cpu_index,
&reg, 1, &val);
if (FAILED(hr)) {
error_report("WHPX: Failed to set register %08x, hr=%08lx", reg, hr);
}
}
/* Tries to find a breakpoint at the specified address. */
struct whpx_breakpoint *whpx_lookup_breakpoint_by_addr(uint64_t address)
{
struct whpx_state *whpx = &whpx_global;
int i;
if (whpx->breakpoints.breakpoints) {
for (i = 0; i < whpx->breakpoints.breakpoints->used; i++) {
if (address == whpx->breakpoints.breakpoints->data[i].address) {
return &whpx->breakpoints.breakpoints->data[i];
}
}
}
return NULL;
}
/*
* This function is called when the a VCPU is about to start and no other
* VCPUs have been started so far. Since the VCPU start order could be
* arbitrary, it doesn't have to be VCPU#0.
*
* It is used to commit the breakpoints into memory, and configure WHPX
* to intercept debug exceptions.
*
* Note that whpx_set_exception_exit_bitmap() cannot be called if one or
* more VCPUs are already running, so this is the best place to do it.
*/
int whpx_first_vcpu_starting(CPUState *cpu)
{
struct whpx_state *whpx = &whpx_global;
g_assert(bql_locked());
if (!QTAILQ_EMPTY(&cpu->breakpoints) ||
(whpx->breakpoints.breakpoints &&
whpx->breakpoints.breakpoints->used)) {
CPUBreakpoint *bp;
int i = 0;
bool update_pending = false;
QTAILQ_FOREACH(bp, &cpu->breakpoints, entry) {
if (i >= whpx->breakpoints.original_address_count ||
bp->pc != whpx->breakpoints.original_addresses[i]) {
update_pending = true;
}
i++;
}
if (i != whpx->breakpoints.original_address_count) {
update_pending = true;
}
if (update_pending) {
/*
* The CPU breakpoints have changed since the last call to
* whpx_translate_cpu_breakpoints(). WHPX breakpoints must
* now be recomputed.
*/
whpx_translate_cpu_breakpoints(&whpx->breakpoints, cpu, i);
}
/* Actually insert the breakpoints into the memory. */
whpx_apply_breakpoints(whpx->breakpoints.breakpoints, cpu, true);
}
HRESULT hr;
uint64_t exception_mask;
if (whpx->step_pending ||
(whpx->breakpoints.breakpoints &&
whpx->breakpoints.breakpoints->used)) {
/*
* We are either attempting to single-step one or more CPUs, or
* have one or more breakpoints enabled. Both require intercepting
* the WHvX64ExceptionTypeBreakpointTrap exception.
*/
exception_mask = 1UL << WHPX_INTERCEPT_DEBUG_TRAPS;
} else {
/* Let the guest handle all exceptions. */
exception_mask = 0;
}
hr = whpx_set_exception_exit_bitmap(exception_mask);
if (!SUCCEEDED(hr)) {
error_report("WHPX: Failed to update exception exit mask,"
"hr=%08lx.", hr);
return 1;
}
return 0;
}
/*
* This function is called when the last VCPU has finished running.
* It is used to remove any previously set breakpoints from memory.
*/
int whpx_last_vcpu_stopping(CPUState *cpu)
{
whpx_apply_breakpoints(whpx_global.breakpoints.breakpoints, cpu, false);
return 0;
}
static void do_whpx_cpu_synchronize_state(CPUState *cpu, run_on_cpu_data arg)
{
if (!cpu->vcpu_dirty) {
whpx_get_registers(cpu, WHPX_LEVEL_FULL_STATE);
cpu->vcpu_dirty = true;
}
}
static void do_whpx_cpu_synchronize_post_reset(CPUState *cpu,
run_on_cpu_data arg)
{
whpx_set_registers(cpu, WHPX_LEVEL_RESET_STATE);
cpu->vcpu_dirty = false;
}
static void do_whpx_cpu_synchronize_post_init(CPUState *cpu,
run_on_cpu_data arg)
{
whpx_set_registers(cpu, WHPX_LEVEL_FULL_STATE);
cpu->vcpu_dirty = false;
}
static void do_whpx_cpu_synchronize_pre_loadvm(CPUState *cpu,
run_on_cpu_data arg)
{
cpu->vcpu_dirty = true;
}
/*
* CPU support.
*/
void whpx_cpu_synchronize_state(CPUState *cpu)
{
if (!cpu->vcpu_dirty) {
run_on_cpu(cpu, do_whpx_cpu_synchronize_state, RUN_ON_CPU_NULL);
}
}
void whpx_cpu_synchronize_post_reset(CPUState *cpu)
{
run_on_cpu(cpu, do_whpx_cpu_synchronize_post_reset, RUN_ON_CPU_NULL);
}
void whpx_cpu_synchronize_post_init(CPUState *cpu)
{
run_on_cpu(cpu, do_whpx_cpu_synchronize_post_init, RUN_ON_CPU_NULL);
}
void whpx_cpu_synchronize_pre_loadvm(CPUState *cpu)
{
run_on_cpu(cpu, do_whpx_cpu_synchronize_pre_loadvm, RUN_ON_CPU_NULL);
}
static void whpx_pre_resume_vm(AccelState *as, bool step_pending)
{
whpx_global.step_pending = step_pending;
}
/*
* Vcpu support.
*/
int whpx_vcpu_exec(CPUState *cpu)
{
int ret;
int fatal;
for (;;) {
if (cpu->exception_index >= EXCP_INTERRUPT) {
ret = cpu->exception_index;
cpu->exception_index = -1;
break;
}
fatal = whpx_vcpu_run(cpu);
if (fatal) {
error_report("WHPX: Failed to exec a virtual processor");
abort();
}
}
return ret;
}
void whpx_destroy_vcpu(CPUState *cpu)
{
struct whpx_state *whpx = &whpx_global;
whp_dispatch.WHvDeleteVirtualProcessor(whpx->partition, cpu->cpu_index);
whpx_arch_destroy_vcpu(cpu);
g_free(cpu->accel);
}
void whpx_vcpu_kick(CPUState *cpu)
{
struct whpx_state *whpx = &whpx_global;
whp_dispatch.WHvCancelRunVirtualProcessor(
whpx->partition, cpu->cpu_index, 0);
}
/*
* Memory support.
*/
static void whpx_set_phys_mem(MemoryRegionSection *section, bool add)
{
struct whpx_state *whpx = &whpx_global;
MemoryRegion *area = section->mr;
bool writable = !area->readonly && !area->rom_device;
WHV_MAP_GPA_RANGE_FLAGS flags;
uint64_t page_size = qemu_real_host_page_size();
uint64_t gva = section->offset_within_address_space;
uint64_t size = int128_get64(section->size);
HRESULT hr;
void *mem;
if (!memory_region_is_ram(area)) {
if (writable) {
return;
} else if (!memory_region_is_romd(area)) {
add = false;
}
}
if (!QEMU_IS_ALIGNED(size, page_size) ||
!QEMU_IS_ALIGNED(gva, page_size)) {
/* Not page aligned, so we can not map as RAM */
add = false;
}
if (!add) {
hr = whp_dispatch.WHvUnmapGpaRange(whpx->partition,
gva, size);
if (FAILED(hr)) {
error_report("WHPX: failed to unmap GPA range");
abort();
}
return;
}
flags = WHvMapGpaRangeFlagRead | WHvMapGpaRangeFlagExecute
| (writable ? WHvMapGpaRangeFlagWrite : 0);
mem = memory_region_get_ram_ptr(area) + section->offset_within_region;
hr = whp_dispatch.WHvMapGpaRange(whpx->partition,
mem, gva, size, flags);
if (FAILED(hr)) {
error_report("WHPX: failed to map GPA range");
abort();
}
}
static void whpx_region_add(MemoryListener *listener,
MemoryRegionSection *section)
{
whpx_set_phys_mem(section, true);
}
static void whpx_region_del(MemoryListener *listener,
MemoryRegionSection *section)
{
whpx_set_phys_mem(section, false);
}
static void whpx_transaction_begin(MemoryListener *listener)
{
}
static void whpx_transaction_commit(MemoryListener *listener)
{
}
static void whpx_log_sync(MemoryListener *listener,
MemoryRegionSection *section)
{
MemoryRegion *mr = section->mr;
if (!memory_region_is_ram(mr)) {
return;
}
memory_region_set_dirty(mr, 0, int128_get64(section->size));
}
static MemoryListener whpx_memory_listener = {
.name = "whpx",
.begin = whpx_transaction_begin,
.commit = whpx_transaction_commit,
.region_add = whpx_region_add,
.region_del = whpx_region_del,
.log_sync = whpx_log_sync,
.priority = MEMORY_LISTENER_PRIORITY_ACCEL,
};
void whpx_memory_init(void)
{
memory_listener_register(&whpx_memory_listener, &address_space_memory);
}
/*
* Load the functions from the given library, using the given handle. If a
* handle is provided, it is used, otherwise the library is opened. The
* handle will be updated on return with the opened one.
*/
static bool load_whp_dispatch_fns(HMODULE *handle,
WHPFunctionList function_list)
{
HMODULE hLib = *handle;
#define WINHV_PLATFORM_DLL "WinHvPlatform.dll"
#define WHP_LOAD_FIELD_OPTIONAL(return_type, function_name, signature) \
whp_dispatch.function_name = \
(function_name ## _t)GetProcAddress(hLib, #function_name); \
#define WHP_LOAD_FIELD(return_type, function_name, signature) \
whp_dispatch.function_name = \
(function_name ## _t)GetProcAddress(hLib, #function_name); \
if (!whp_dispatch.function_name) { \
error_report("Could not load function %s", #function_name); \
goto error; \
} \
#define WHP_LOAD_LIB(lib_name, handle_lib) \
if (!handle_lib) { \
handle_lib = LoadLibrary(lib_name); \
if (!handle_lib) { \
error_report("Could not load library %s.", lib_name); \
goto error; \
} \
} \
switch (function_list) {
case WINHV_PLATFORM_FNS_DEFAULT:
WHP_LOAD_LIB(WINHV_PLATFORM_DLL, hLib)
LIST_WINHVPLATFORM_FUNCTIONS(WHP_LOAD_FIELD)
break;
case WINHV_PLATFORM_FNS_SUPPLEMENTAL:
WHP_LOAD_LIB(WINHV_PLATFORM_DLL, hLib)
LIST_WINHVPLATFORM_FUNCTIONS_SUPPLEMENTAL(WHP_LOAD_FIELD_OPTIONAL)
break;
}
*handle = hLib;
return true;
error:
if (hLib) {
FreeLibrary(hLib);
}
return false;
}
static void whpx_set_kernel_irqchip(Object *obj, Visitor *v,
const char *name, void *opaque,
Error **errp)
{
struct whpx_state *whpx = &whpx_global;
OnOffSplit mode;
if (!visit_type_OnOffSplit(v, name, &mode, errp)) {
return;
}
switch (mode) {
case ON_OFF_SPLIT_ON:
whpx->kernel_irqchip_allowed = true;
whpx->kernel_irqchip_required = true;
break;
case ON_OFF_SPLIT_OFF:
whpx->kernel_irqchip_allowed = false;
whpx->kernel_irqchip_required = false;
break;
case ON_OFF_SPLIT_SPLIT:
error_setg(errp, "WHPX: split irqchip currently not supported");
error_append_hint(errp,
"Try without kernel-irqchip or with kernel-irqchip=on|off");
break;
default:
/*
* The value was checked in visit_type_OnOffSplit() above. If
* we get here, then something is wrong in QEMU.
*/
abort();
}
}
static void whpx_set_hyperv(Object *obj, Visitor *v,
const char *name, void *opaque,
Error **errp)
{
struct whpx_state *whpx = &whpx_global;
OnOffAuto mode;
if (!visit_type_OnOffAuto(v, name, &mode, errp)) {
return;
}
switch (mode) {
case ON_OFF_AUTO_ON:
whpx->hyperv_enlightenments_allowed = true;
whpx->hyperv_enlightenments_required = true;
break;
case ON_OFF_AUTO_OFF:
whpx->hyperv_enlightenments_allowed = false;
whpx->hyperv_enlightenments_required = false;
break;
case ON_OFF_AUTO_AUTO:
whpx->hyperv_enlightenments_allowed = true;
whpx->hyperv_enlightenments_required = false;
break;
default:
/*
* The value was checked in visit_type_OnOffAuto() above. If
* we get here, then something is wrong in QEMU.
*/
abort();
}
}
static void whpx_cpu_accel_class_init(ObjectClass *oc, const void *data)
{
AccelCPUClass *acc = ACCEL_CPU_CLASS(oc);
acc->cpu_instance_init = whpx_cpu_instance_init;
}
static const TypeInfo whpx_cpu_accel_type = {
.name = ACCEL_CPU_NAME("whpx"),
.parent = TYPE_ACCEL_CPU,
.class_init = whpx_cpu_accel_class_init,
.abstract = true,
};
static void whpx_accel_class_init(ObjectClass *oc, const void *data)
{
AccelClass *ac = ACCEL_CLASS(oc);
ac->name = "WHPX";
ac->init_machine = whpx_accel_init;
ac->pre_resume_vm = whpx_pre_resume_vm;
ac->allowed = &whpx_allowed;
object_class_property_add(oc, "kernel-irqchip", "on|off|split",
NULL, whpx_set_kernel_irqchip,
NULL, NULL);
object_class_property_set_description(oc, "kernel-irqchip",
"Configure WHPX in-kernel irqchip");
object_class_property_add(oc, "hyperv", "OnOffAuto",
NULL, whpx_set_hyperv,
NULL, NULL);
object_class_property_set_description(oc, "hyperv",
"Configure Hyper-V enlightenments");
}
static void whpx_accel_instance_init(Object *obj)
{
struct whpx_state *whpx = &whpx_global;
memset(whpx, 0, sizeof(struct whpx_state));
/* Turn on kernel-irqchip, by default */
whpx->kernel_irqchip_allowed = true;
whpx->hyperv_enlightenments_allowed = true;
whpx->hyperv_enlightenments_required = false;
}
static const TypeInfo whpx_accel_type = {
.name = ACCEL_CLASS_NAME("whpx"),
.parent = TYPE_ACCEL,
.instance_init = whpx_accel_instance_init,
.class_init = whpx_accel_class_init,
};
static void whpx_type_init(void)
{
type_register_static(&whpx_accel_type);
type_register_static(&whpx_cpu_accel_type);
}
bool init_whp_dispatch(void)
{
if (whp_dispatch_initialized) {
return true;
}
if (!load_whp_dispatch_fns(&hWinHvPlatform, WINHV_PLATFORM_FNS_DEFAULT)) {
goto error;
}
assert(load_whp_dispatch_fns(&hWinHvPlatform,
WINHV_PLATFORM_FNS_SUPPLEMENTAL));
whp_dispatch_initialized = true;
return true;
error:
if (hWinHvPlatform) {
FreeLibrary(hWinHvPlatform);
}
return false;
}
type_init(whpx_type_init);
+1 -1
View File
@@ -1 +1 @@
specific_ss.add(when: 'CONFIG_XEN', if_true: files('xen-all.c'))
system_ss.add(when: 'CONFIG_XEN', if_true: files('xen-all.c'))
+1 -1
View File
@@ -26,7 +26,7 @@
#include "system/runstate.h"
#include "migration/misc.h"
#include "migration/global_state.h"
#include "hw/boards.h"
#include "hw/core/boards.h"
bool xen_allowed;
+124 -149
View File
@@ -26,36 +26,43 @@
#include <alsa/asoundlib.h>
#include "qemu/main-loop.h"
#include "qemu/module.h"
#include "qemu/error-report.h"
#include "qemu/audio.h"
#include "qom/object.h"
#include "trace.h"
#pragma GCC diagnostic ignored "-Waddress"
#define AUDIO_CAP "alsa"
#include "audio_int.h"
#define DEBUG_ALSA 0
#define TYPE_AUDIO_ALSA "audio-alsa"
OBJECT_DECLARE_SIMPLE_TYPE(AudioALSA, AUDIO_ALSA)
static AudioBackendClass *audio_alsa_parent_class;
struct AudioALSA {
AudioMixengBackend parent_obj;
};
struct pollhlp {
snd_pcm_t *handle;
struct pollfd *pfds;
int count;
int mask;
AudioBackend *s;
AudioMixengBackend *s;
};
typedef struct ALSAVoiceOut {
HWVoiceOut hw;
snd_pcm_t *handle;
struct pollhlp pollhlp;
Audiodev *dev;
} ALSAVoiceOut;
typedef struct ALSAVoiceIn {
HWVoiceIn hw;
snd_pcm_t *handle;
struct pollhlp pollhlp;
Audiodev *dev;
} ALSAVoiceIn;
struct alsa_params_req {
@@ -72,33 +79,29 @@ struct alsa_params_obt {
snd_pcm_uframes_t samples;
};
static void G_GNUC_PRINTF (2, 3) alsa_logerr (int err, const char *fmt, ...)
static void G_GNUC_PRINTF(2, 3) alsa_logerr(int err, const char *fmt, ...)
{
va_list ap;
va_start (ap, fmt);
AUD_vlog (AUDIO_CAP, fmt, ap);
va_end (ap);
AUD_log (AUDIO_CAP, "Reason: %s\n", snd_strerror (err));
error_printf("alsa: ");
va_start(ap, fmt);
error_vprintf(fmt, ap);
va_end(ap);
error_printf(" Reason: %s", snd_strerror(err));
error_printf("\n");
}
static void G_GNUC_PRINTF (3, 4) alsa_logerr2 (
int err,
const char *typ,
const char *fmt,
...
)
static void G_GNUC_PRINTF(3, 4) alsa_logerr2(int err, const char *typ,
const char *fmt, ...)
{
va_list ap;
AUD_log (AUDIO_CAP, "Could not initialize %s\n", typ);
va_start (ap, fmt);
AUD_vlog (AUDIO_CAP, fmt, ap);
va_end (ap);
AUD_log (AUDIO_CAP, "Reason: %s\n", snd_strerror (err));
error_printf("alsa: Could not initialize %s:", typ);
va_start(ap, fmt);
error_vprintf(fmt, ap);
va_end(ap);
error_printf(" Reason: %s", snd_strerror(err));
error_printf("\n");
}
static void alsa_fini_poll (struct pollhlp *hlp)
@@ -121,7 +124,7 @@ static void alsa_anal_close1 (snd_pcm_t **handlep)
{
int err = snd_pcm_close (*handlep);
if (err) {
alsa_logerr (err, "Failed to close PCM handle %p\n", *handlep);
alsa_logerr(err, "Failed to close PCM handle %p", *handlep);
}
*handlep = NULL;
}
@@ -136,7 +139,7 @@ static int alsa_recover (snd_pcm_t *handle)
{
int err = snd_pcm_prepare (handle);
if (err < 0) {
alsa_logerr (err, "Failed to prepare handle %p\n", handle);
alsa_logerr(err, "Failed to prepare handle %p", handle);
return -1;
}
return 0;
@@ -146,7 +149,7 @@ static int alsa_resume (snd_pcm_t *handle)
{
int err = snd_pcm_resume (handle);
if (err < 0) {
alsa_logerr (err, "Failed to resume handle %p\n", handle);
alsa_logerr(err, "Failed to resume handle %p", handle);
return -1;
}
return 0;
@@ -161,7 +164,7 @@ static void alsa_poll_handler (void *opaque)
count = poll (hlp->pfds, hlp->count, 0);
if (count < 0) {
dolog ("alsa_poll_handler: poll %s\n", strerror (errno));
warn_report("alsa_poll_handler: poll %s", strerror(errno));
return;
}
@@ -174,7 +177,7 @@ static void alsa_poll_handler (void *opaque)
err = snd_pcm_poll_descriptors_revents (hlp->handle, hlp->pfds,
hlp->count, &revents);
if (err < 0) {
alsa_logerr (err, "snd_pcm_poll_descriptors_revents");
alsa_logerr(err, "snd_pcm_poll_descriptors_revents");
return;
}
@@ -206,7 +209,7 @@ static void alsa_poll_handler (void *opaque)
break;
default:
dolog ("Unexpected state %d\n", state);
warn_report("alsa: Unexpected state %d", state);
}
}
@@ -217,8 +220,8 @@ static int alsa_poll_helper (snd_pcm_t *handle, struct pollhlp *hlp, int mask)
count = snd_pcm_poll_descriptors_count (handle);
if (count <= 0) {
dolog ("Could not initialize poll mode\n"
"Invalid number of poll descriptors %d\n", count);
warn_report("alsa: Could not initialize poll mode: "
"Invalid number of poll descriptors %d", count);
return -1;
}
@@ -226,8 +229,7 @@ static int alsa_poll_helper (snd_pcm_t *handle, struct pollhlp *hlp, int mask)
err = snd_pcm_poll_descriptors (handle, pfds, count);
if (err < 0) {
alsa_logerr (err, "Could not initialize poll mode\n"
"Could not obtain poll descriptors\n");
alsa_logerr(err, "Could not initialize poll mode: Could not obtain poll descriptors");
g_free (pfds);
return -1;
}
@@ -289,10 +291,7 @@ static snd_pcm_format_t aud_to_alsafmt(AudioFormat fmt, bool big_endian)
return big_endian ? SND_PCM_FORMAT_FLOAT_BE : SND_PCM_FORMAT_FLOAT_LE;
default:
dolog ("Internal logic error: Bad audio format %d\n", fmt);
#ifdef DEBUG_AUDIO
abort ();
#endif
warn_report("alsa: Internal logic error: Bad audio format %d", fmt);
return SND_PCM_FORMAT_U8;
}
}
@@ -362,29 +361,13 @@ static int alsa_to_audfmt (snd_pcm_format_t alsafmt, AudioFormat *fmt,
break;
default:
dolog ("Unrecognized audio format %d\n", alsafmt);
warn_report("alsa: Unrecognized audio format %d", alsafmt);
return -1;
}
return 0;
}
static void alsa_dump_info (struct alsa_params_req *req,
struct alsa_params_obt *obt,
snd_pcm_format_t obtfmt,
AudiodevAlsaPerDirectionOptions *apdo)
{
dolog("parameter | requested value | obtained value\n");
dolog("format | %10d | %10d\n", req->fmt, obtfmt);
dolog("channels | %10d | %10d\n",
req->nchannels, obt->nchannels);
dolog("frequency | %10d | %10d\n", req->freq, obt->freq);
dolog("============================================\n");
dolog("requested: buffer len %" PRId32 " period len %" PRId32 "\n",
apdo->buffer_length, apdo->period_length);
dolog("obtained: samples %ld\n", obt->samples);
}
static void alsa_set_threshold (snd_pcm_t *handle, snd_pcm_uframes_t threshold)
{
int err;
@@ -394,23 +377,22 @@ static void alsa_set_threshold (snd_pcm_t *handle, snd_pcm_uframes_t threshold)
err = snd_pcm_sw_params_current (handle, sw_params);
if (err < 0) {
dolog ("Could not fully initialize DAC\n");
alsa_logerr (err, "Failed to get current software parameters\n");
error_report("alsa: Could not fully initialize DAC");
alsa_logerr(err, "Failed to get current software parameters");
return;
}
err = snd_pcm_sw_params_set_start_threshold (handle, sw_params, threshold);
if (err < 0) {
dolog ("Could not fully initialize DAC\n");
alsa_logerr (err, "Failed to set software threshold to %ld\n",
threshold);
error_report("alsa: Could not fully initialize DAC");
alsa_logerr(err, "Failed to set software threshold to %ld", threshold);
return;
}
err = snd_pcm_sw_params (handle, sw_params);
if (err < 0) {
dolog ("Could not fully initialize DAC\n");
alsa_logerr (err, "Failed to set software parameters\n");
error_report("alsa: Could not fully initialize DAC");
alsa_logerr(err, "Failed to set software parameters");
return;
}
}
@@ -442,13 +424,13 @@ static int alsa_open(bool in, struct alsa_params_req *req,
SND_PCM_NONBLOCK
);
if (err < 0) {
alsa_logerr2 (err, typ, "Failed to open `%s':\n", pcm_name);
alsa_logerr2(err, typ, "Failed to open `%s'", pcm_name);
return -1;
}
err = snd_pcm_hw_params_any (handle, hw_params);
if (err < 0) {
alsa_logerr2 (err, typ, "Failed to initialize hardware parameters\n");
alsa_logerr2(err, typ, "Failed to initialize hardware parameters");
goto err;
}
@@ -458,18 +440,18 @@ static int alsa_open(bool in, struct alsa_params_req *req,
SND_PCM_ACCESS_RW_INTERLEAVED
);
if (err < 0) {
alsa_logerr2 (err, typ, "Failed to set access type\n");
alsa_logerr2(err, typ, "Failed to set access type");
goto err;
}
err = snd_pcm_hw_params_set_format (handle, hw_params, req->fmt);
if (err < 0) {
alsa_logerr2 (err, typ, "Failed to set format %d\n", req->fmt);
alsa_logerr2(err, typ, "Failed to set format %d", req->fmt);
}
err = snd_pcm_hw_params_set_rate_near (handle, hw_params, &freq, 0);
if (err < 0) {
alsa_logerr2 (err, typ, "Failed to set frequency %d\n", req->freq);
alsa_logerr2(err, typ, "Failed to set frequency %d", req->freq);
goto err;
}
@@ -479,8 +461,7 @@ static int alsa_open(bool in, struct alsa_params_req *req,
&nchannels
);
if (err < 0) {
alsa_logerr2 (err, typ, "Failed to set number of channels %d\n",
req->nchannels);
alsa_logerr2(err, typ, "Failed to set number of channels %d", req->nchannels);
goto err;
}
@@ -492,14 +473,14 @@ static int alsa_open(bool in, struct alsa_params_req *req,
handle, hw_params, &btime, &dir);
if (err < 0) {
alsa_logerr2(err, typ, "Failed to set buffer time to %" PRId32 "\n",
alsa_logerr2(err, typ, "Failed to set buffer time to %" PRId32,
apdo->buffer_length);
goto err;
}
if (apdo->has_buffer_length && btime != apdo->buffer_length) {
dolog("Requested buffer time %" PRId32
" was rejected, using %u\n", apdo->buffer_length, btime);
warn_report("alsa: Requested buffer time %" PRId32 " was rejected, using %u",
apdo->buffer_length, btime);
}
}
@@ -511,43 +492,43 @@ static int alsa_open(bool in, struct alsa_params_req *req,
&dir);
if (err < 0) {
alsa_logerr2(err, typ, "Failed to set period time to %" PRId32 "\n",
alsa_logerr2(err, typ, "Failed to set period time to %" PRId32,
apdo->period_length);
goto err;
}
if (apdo->has_period_length && ptime != apdo->period_length) {
dolog("Requested period time %" PRId32 " was rejected, using %d\n",
apdo->period_length, ptime);
warn_report("alsa: Requested period time %" PRId32 " was rejected, using %d",
apdo->period_length, ptime);
}
}
err = snd_pcm_hw_params (handle, hw_params);
if (err < 0) {
alsa_logerr2 (err, typ, "Failed to apply audio parameters\n");
alsa_logerr2(err, typ, "Failed to apply audio parameters");
goto err;
}
err = snd_pcm_hw_params_get_buffer_size (hw_params, &obt_buffer_size);
if (err < 0) {
alsa_logerr2 (err, typ, "Failed to get buffer size\n");
alsa_logerr2(err, typ, "Failed to get buffer size");
goto err;
}
err = snd_pcm_hw_params_get_format (hw_params, &obtfmt);
if (err < 0) {
alsa_logerr2 (err, typ, "Failed to get format\n");
alsa_logerr2(err, typ, "Failed to get format");
goto err;
}
if (alsa_to_audfmt (obtfmt, &obt->fmt, &obt->endianness)) {
dolog ("Invalid format was returned %d\n", obtfmt);
error_report("alsa: Invalid format was returned %d", obtfmt);
goto err;
}
err = snd_pcm_prepare (handle);
if (err < 0) {
alsa_logerr2 (err, typ, "Could not prepare handle %p\n", handle);
alsa_logerr2(err, typ, "Could not prepare handle %p", handle);
goto err;
}
@@ -565,11 +546,9 @@ static int alsa_open(bool in, struct alsa_params_req *req,
*handlep = handle;
if (DEBUG_ALSA || obtfmt != req->fmt ||
obt->nchannels != req->nchannels || obt->freq != req->freq) {
dolog ("Audio parameters for %s\n", typ);
alsa_dump_info(req, obt, obtfmt, apdo);
}
trace_alsa_info_params(req->fmt, obtfmt, req->nchannels, obt->nchannels,
req->freq, obt->freq);
trace_alsa_info_samples(apdo->buffer_length, apdo->period_length, obt->samples);
return 0;
@@ -592,8 +571,7 @@ static size_t alsa_buffer_get_free(HWVoiceOut *hw)
}
}
if (avail < 0) {
alsa_logerr(avail,
"Could not obtain number of available frames\n");
alsa_logerr(avail, "Could not obtain number of available frames");
avail = 0;
}
}
@@ -634,8 +612,7 @@ static size_t alsa_write(HWVoiceOut *hw, void *buf, size_t len)
case -EPIPE:
if (alsa_recover(alsa->handle)) {
alsa_logerr(written, "Failed to write %zu frames\n",
len_frames);
alsa_logerr(written, "Failed to write %zu frames", len_frames);
return pos;
}
trace_alsa_xrun_out();
@@ -647,8 +624,7 @@ static size_t alsa_write(HWVoiceOut *hw, void *buf, size_t len)
* recovery
*/
if (alsa_resume(alsa->handle)) {
alsa_logerr(written, "Failed to write %zu frames\n",
len_frames);
alsa_logerr(written, "Failed to write %zu frames", len_frames);
return pos;
}
trace_alsa_resume_out();
@@ -658,8 +634,7 @@ static size_t alsa_write(HWVoiceOut *hw, void *buf, size_t len)
return pos;
default:
alsa_logerr(written, "Failed to write %zu frames from %p\n",
len, src);
alsa_logerr(written, "Failed to write %zu frames from %p", len_frames, src);
return pos;
}
}
@@ -678,21 +653,20 @@ static void alsa_fini_out (HWVoiceOut *hw)
{
ALSAVoiceOut *alsa = (ALSAVoiceOut *) hw;
ldebug ("alsa_fini\n");
trace_alsa_fini_out();
alsa_anal_close (&alsa->handle, &alsa->pollhlp);
}
static int alsa_init_out(HWVoiceOut *hw, struct audsettings *as,
void *drv_opaque)
static int alsa_init_out(HWVoiceOut *hw, struct audsettings *as)
{
ALSAVoiceOut *alsa = (ALSAVoiceOut *) hw;
struct alsa_params_req req;
struct alsa_params_obt obt;
snd_pcm_t *handle;
struct audsettings obt_as;
Audiodev *dev = drv_opaque;
Audiodev *dev = hw->s->dev;
req.fmt = aud_to_alsafmt (as->fmt, as->endianness);
req.fmt = aud_to_alsafmt (as->fmt, as->big_endian);
req.freq = as->freq;
req.nchannels = as->nchannels;
@@ -703,14 +677,13 @@ static int alsa_init_out(HWVoiceOut *hw, struct audsettings *as,
obt_as.freq = obt.freq;
obt_as.nchannels = obt.nchannels;
obt_as.fmt = obt.fmt;
obt_as.endianness = obt.endianness;
obt_as.big_endian = obt.endianness;
audio_pcm_init_info (&hw->info, &obt_as);
hw->samples = obt.samples;
alsa->pollhlp.s = hw->s;
alsa->handle = handle;
alsa->dev = dev;
return 0;
}
@@ -725,19 +698,19 @@ static int alsa_voice_ctl (snd_pcm_t *handle, const char *typ, int ctl)
if (ctl == VOICE_CTL_PAUSE) {
err = snd_pcm_drop (handle);
if (err < 0) {
alsa_logerr (err, "Could not stop %s\n", typ);
alsa_logerr(err, "Could not stop %s", typ);
return -1;
}
} else {
err = snd_pcm_prepare (handle);
if (err < 0) {
alsa_logerr (err, "Could not prepare handle for %s\n", typ);
alsa_logerr(err, "Could not prepare handle for %s", typ);
return -1;
}
if (ctl == VOICE_CTL_START) {
err = snd_pcm_start(handle);
if (err < 0) {
alsa_logerr (err, "Could not start handle for %s\n", typ);
alsa_logerr(err, "Could not start handle for %s", typ);
return -1;
}
}
@@ -749,19 +722,19 @@ static int alsa_voice_ctl (snd_pcm_t *handle, const char *typ, int ctl)
static void alsa_enable_out(HWVoiceOut *hw, bool enable)
{
ALSAVoiceOut *alsa = (ALSAVoiceOut *) hw;
AudiodevAlsaPerDirectionOptions *apdo = alsa->dev->u.alsa.out;
AudiodevAlsaPerDirectionOptions *apdo = hw->s->dev->u.alsa.out;
trace_alsa_enable_out(enable);
if (enable) {
bool poll_mode = apdo->try_poll;
ldebug("enabling voice\n");
if (poll_mode && alsa_poll_out(hw)) {
poll_mode = 0;
}
hw->poll_mode = poll_mode;
alsa_voice_ctl(alsa->handle, "playback", VOICE_CTL_PREPARE);
} else {
ldebug("disabling voice\n");
if (hw->poll_mode) {
hw->poll_mode = 0;
alsa_fini_poll(&alsa->pollhlp);
@@ -770,16 +743,16 @@ static void alsa_enable_out(HWVoiceOut *hw, bool enable)
}
}
static int alsa_init_in(HWVoiceIn *hw, struct audsettings *as, void *drv_opaque)
static int alsa_init_in(HWVoiceIn *hw, struct audsettings *as)
{
ALSAVoiceIn *alsa = (ALSAVoiceIn *) hw;
struct alsa_params_req req;
struct alsa_params_obt obt;
snd_pcm_t *handle;
struct audsettings obt_as;
Audiodev *dev = drv_opaque;
Audiodev *dev = hw->s->dev;
req.fmt = aud_to_alsafmt (as->fmt, as->endianness);
req.fmt = aud_to_alsafmt (as->fmt, as->big_endian);
req.freq = as->freq;
req.nchannels = as->nchannels;
@@ -790,14 +763,13 @@ static int alsa_init_in(HWVoiceIn *hw, struct audsettings *as, void *drv_opaque)
obt_as.freq = obt.freq;
obt_as.nchannels = obt.nchannels;
obt_as.fmt = obt.fmt;
obt_as.endianness = obt.endianness;
obt_as.big_endian = obt.endianness;
audio_pcm_init_info (&hw->info, &obt_as);
hw->samples = obt.samples;
alsa->pollhlp.s = hw->s;
alsa->handle = handle;
alsa->dev = dev;
return 0;
}
@@ -828,7 +800,7 @@ static size_t alsa_read(HWVoiceIn *hw, void *buf, size_t len)
case -EPIPE:
if (alsa_recover(alsa->handle)) {
alsa_logerr(nread, "Failed to read %zu frames\n", len);
alsa_logerr(nread, "Failed to read %zu frames", len);
return pos;
}
trace_alsa_xrun_in();
@@ -838,8 +810,7 @@ static size_t alsa_read(HWVoiceIn *hw, void *buf, size_t len)
return pos;
default:
alsa_logerr(nread, "Failed to read %zu frames to %p\n",
len, dst);
alsa_logerr(nread, "Failed to read %zu frames to %p", len, dst);
return pos;
}
}
@@ -854,12 +825,13 @@ static size_t alsa_read(HWVoiceIn *hw, void *buf, size_t len)
static void alsa_enable_in(HWVoiceIn *hw, bool enable)
{
ALSAVoiceIn *alsa = (ALSAVoiceIn *) hw;
AudiodevAlsaPerDirectionOptions *apdo = alsa->dev->u.alsa.in;
AudiodevAlsaPerDirectionOptions *apdo = hw->s->dev->u.alsa.in;
trace_alsa_enable_in(enable);
if (enable) {
bool poll_mode = apdo->try_poll;
ldebug("enabling voice\n");
if (poll_mode && alsa_poll_in(hw)) {
poll_mode = 0;
}
@@ -867,7 +839,6 @@ static void alsa_enable_in(HWVoiceIn *hw, bool enable)
alsa_voice_ctl(alsa->handle, "capture", VOICE_CTL_START);
} else {
ldebug ("disabling voice\n");
if (hw->poll_mode) {
hw->poll_mode = 0;
alsa_fini_poll(&alsa->pollhlp);
@@ -884,7 +855,8 @@ static void alsa_init_per_direction(AudiodevAlsaPerDirectionOptions *apdo)
}
}
static void *alsa_audio_init(Audiodev *dev, Error **errp)
static bool
audio_alsa_realize(AudioBackend *abe, Audiodev *dev, Error **errp)
{
AudiodevAlsaOptions *aopts;
assert(dev->driver == AUDIODEV_DRIVER_ALSA);
@@ -912,41 +884,44 @@ static void *alsa_audio_init(Audiodev *dev, Error **errp)
dev->u.alsa.in->buffer_length = 92880;
}
return dev;
return audio_alsa_parent_class->realize(abe, dev, errp);
}
static void alsa_audio_fini (void *opaque)
static void audio_alsa_class_init(ObjectClass *klass, const void *data)
{
AudioBackendClass *b = AUDIO_BACKEND_CLASS(klass);
AudioMixengBackendClass *k = AUDIO_MIXENG_BACKEND_CLASS(klass);
audio_alsa_parent_class = AUDIO_BACKEND_CLASS(object_class_get_parent(klass));
b->realize = audio_alsa_realize;
k->max_voices_out = INT_MAX;
k->max_voices_in = INT_MAX;
k->voice_size_out = sizeof(ALSAVoiceOut);
k->voice_size_in = sizeof(ALSAVoiceIn);
k->init_out = alsa_init_out;
k->fini_out = alsa_fini_out;
k->write = alsa_write;
k->buffer_get_free = alsa_buffer_get_free;
k->run_buffer_out = audio_generic_run_buffer_out;
k->enable_out = alsa_enable_out;
k->init_in = alsa_init_in;
k->fini_in = alsa_fini_in;
k->read = alsa_read;
k->run_buffer_in = audio_generic_run_buffer_in;
k->enable_in = alsa_enable_in;
}
static struct audio_pcm_ops alsa_pcm_ops = {
.init_out = alsa_init_out,
.fini_out = alsa_fini_out,
.write = alsa_write,
.buffer_get_free = alsa_buffer_get_free,
.run_buffer_out = audio_generic_run_buffer_out,
.enable_out = alsa_enable_out,
.init_in = alsa_init_in,
.fini_in = alsa_fini_in,
.read = alsa_read,
.run_buffer_in = audio_generic_run_buffer_in,
.enable_in = alsa_enable_in,
static const TypeInfo audio_types[] = {
{
.name = TYPE_AUDIO_ALSA,
.parent = TYPE_AUDIO_MIXENG_BACKEND,
.instance_size = sizeof(AudioALSA),
.class_init = audio_alsa_class_init,
},
};
static struct audio_driver alsa_audio_driver = {
.name = "alsa",
.init = alsa_audio_init,
.fini = alsa_audio_fini,
.pcm_ops = &alsa_pcm_ops,
.max_voices_out = INT_MAX,
.max_voices_in = INT_MAX,
.voice_size_out = sizeof (ALSAVoiceOut),
.voice_size_in = sizeof (ALSAVoiceIn)
};
static void register_audio_alsa(void)
{
audio_driver_register(&alsa_audio_driver);
}
type_init(register_audio_alsa);
DEFINE_TYPES(audio_types)
module_obj(TYPE_AUDIO_ALSA);
+274
View File
@@ -0,0 +1,274 @@
/* SPDX-License-Identifier: MIT */
#include "qemu/osdep.h"
#include "qemu/audio.h"
#include "qemu/audio-capture.h"
#include "qapi/error.h"
#include "trace.h"
#include "qapi-types-audio.h"
bool audio_be_check(AudioBackend **be, Error **errp)
{
assert(be != NULL);
if (!*be) {
*be = audio_get_default_audio_be(errp);
if (!*be) {
return false;
}
}
return true;
}
SWVoiceIn *audio_be_open_in(
AudioBackend *be,
SWVoiceIn *sw,
const char *name,
void *callback_opaque,
audio_callback_fn callback_fn,
const struct audsettings *as)
{
AudioBackendClass *klass = AUDIO_BACKEND_GET_CLASS(be);
assert(name != NULL);
assert(callback_fn != NULL);
assert(as != NULL);
return klass->open_in(be, sw, name, callback_opaque, callback_fn, as);
}
SWVoiceOut *audio_be_open_out(
AudioBackend *be,
SWVoiceOut *sw,
const char *name,
void *callback_opaque,
audio_callback_fn callback_fn,
const struct audsettings *as)
{
AudioBackendClass *klass = AUDIO_BACKEND_GET_CLASS(be);
assert(name != NULL);
assert(callback_fn != NULL);
assert(as != NULL);
return klass->open_out(be, sw, name, callback_opaque, callback_fn, as);
}
void audio_be_close_out(AudioBackend *be, SWVoiceOut *sw)
{
AudioBackendClass *klass = AUDIO_BACKEND_GET_CLASS(be);
if (!sw) {
return;
}
return klass->close_out(be, sw);
}
void audio_be_close_in(AudioBackend *be, SWVoiceIn *sw)
{
AudioBackendClass *klass = AUDIO_BACKEND_GET_CLASS(be);
if (!sw) {
return;
}
return klass->close_in(be, sw);
}
bool audio_be_is_active_out(AudioBackend *be, SWVoiceOut *sw)
{
AudioBackendClass *klass = AUDIO_BACKEND_GET_CLASS(be);
if (!sw) {
return false;
}
return klass->is_active_out(be, sw);
}
bool audio_be_is_active_in(AudioBackend *be, SWVoiceIn *sw)
{
AudioBackendClass *klass = AUDIO_BACKEND_GET_CLASS(be);
if (!sw) {
return false;
}
return klass->is_active_in(be, sw);
}
size_t audio_be_write(AudioBackend *be, SWVoiceOut *sw, void *buf, size_t size)
{
AudioBackendClass *klass = AUDIO_BACKEND_GET_CLASS(be);
if (!sw) {
return 0;
}
return klass->write(be, sw, buf, size);
}
size_t audio_be_read(AudioBackend *be, SWVoiceIn *sw, void *buf, size_t size)
{
AudioBackendClass *klass = AUDIO_BACKEND_GET_CLASS(be);
if (!sw) {
return 0;
}
return klass->read(be, sw, buf, size);
}
int audio_be_get_buffer_size_out(AudioBackend *be, SWVoiceOut *sw)
{
AudioBackendClass *klass = AUDIO_BACKEND_GET_CLASS(be);
if (!sw) {
return 0;
}
return klass->get_buffer_size_out(be, sw);
}
void audio_be_set_active_out(AudioBackend *be, SWVoiceOut *sw, bool on)
{
AudioBackendClass *klass = AUDIO_BACKEND_GET_CLASS(be);
trace_audio_be_set_active_out(sw, on);
if (!sw) {
return;
}
return klass->set_active_out(be, sw, on);
}
void audio_be_set_active_in(AudioBackend *be, SWVoiceIn *sw, bool on)
{
AudioBackendClass *klass = AUDIO_BACKEND_GET_CLASS(be);
trace_audio_be_set_active_in(sw, on);
if (!sw) {
return;
}
return klass->set_active_in(be, sw, on);
}
void audio_be_set_volume_out(AudioBackend *be, SWVoiceOut *sw, Volume *vol)
{
AudioBackendClass *klass = AUDIO_BACKEND_GET_CLASS(be);
if (!sw) {
return;
}
klass->set_volume_out(be, sw, vol);
}
void audio_be_set_volume_in(AudioBackend *be, SWVoiceIn *sw, Volume *vol)
{
AudioBackendClass *klass = AUDIO_BACKEND_GET_CLASS(be);
if (!sw) {
return;
}
klass->set_volume_in(be, sw, vol);
}
CaptureVoiceOut *audio_be_add_capture(
AudioBackend *be,
const struct audsettings *as,
const struct audio_capture_ops *ops,
void *cb_opaque)
{
AudioBackendClass *klass = AUDIO_BACKEND_GET_CLASS(be);
assert(as != NULL);
assert(ops != NULL);
return klass->add_capture(be, as, ops, cb_opaque);
}
void audio_be_del_capture(AudioBackend *be, CaptureVoiceOut *cap, void *cb_opaque)
{
AudioBackendClass *klass = AUDIO_BACKEND_GET_CLASS(be);
if (!cap) {
return;
}
klass->del_capture(be, cap, cb_opaque);
}
#ifdef CONFIG_GIO
bool audio_be_can_set_dbus_server(AudioBackend *be)
{
AudioBackendClass *klass = AUDIO_BACKEND_GET_CLASS(be);
return klass->set_dbus_server != NULL;
}
bool audio_be_set_dbus_server(AudioBackend *be,
GDBusObjectManagerServer *server,
bool p2p,
Error **errp)
{
AudioBackendClass *klass = AUDIO_BACKEND_GET_CLASS(be);
assert(server != NULL);
if (!audio_be_can_set_dbus_server(be)) {
error_setg(errp, "Audiodev '%s' is not compatible with DBus",
audio_be_get_id(be));
return false;
}
return klass->set_dbus_server(be, server, p2p, errp);
}
#endif
const char *audio_be_get_id(AudioBackend *be)
{
if (be) {
return AUDIO_BACKEND_GET_CLASS(be)->get_id(be);
} else {
return "";
}
}
AudioBackend *audio_be_new(Audiodev *dev, Error **errp)
{
const char *drvname = AudiodevDriver_str(dev->driver);
g_autofree char *type = g_strconcat("audio-", drvname, NULL);
AudioBackend *be = AUDIO_BACKEND(object_new(type));
if (!be) {
error_setg(errp, "Unknown audio driver `%s'", drvname);
qapi_free_Audiodev(dev);
return NULL;
}
if (!AUDIO_BACKEND_GET_CLASS(be)->realize(be, dev, errp)) {
object_unref(OBJECT(be));
return NULL;
}
return be;
}
static const TypeInfo audio_types[] = {
{
.name = TYPE_AUDIO_BACKEND,
.parent = TYPE_OBJECT,
.instance_size = sizeof(AudioBackend),
.abstract = true,
.class_size = sizeof(AudioBackendClass),
},
};
DEFINE_TYPES(audio_types)
File diff suppressed because it is too large. Load diff
+171 -2032
View File
File diff suppressed because it is too large. Load diff
+63 -107
View File
@@ -33,27 +33,13 @@
#include "qemu/audio-capture.h"
#include "mixeng.h"
#ifdef CONFIG_GIO
#include <gio/gio.h>
#endif
void G_GNUC_PRINTF(2, 0)
AUD_vlog(const char *cap, const char *fmt, va_list ap);
void G_GNUC_PRINTF(2, 3)
AUD_log(const char *cap, const char *fmt, ...);
struct audio_pcm_ops;
struct audio_callback {
void *opaque;
audio_callback_fn fn;
};
struct audio_pcm_info {
int bits;
bool is_signed;
bool is_float;
AudioFormat af;
int freq;
int nchannels;
int bytes_per_frame;
@@ -61,7 +47,7 @@ struct audio_pcm_info {
int swap_endianness;
};
typedef struct AudioBackend AudioBackend;
typedef struct AudioMixengBackend AudioMixengBackend;
typedef struct SWVoiceCap SWVoiceCap;
typedef struct STSampleBuffer {
@@ -70,14 +56,13 @@ typedef struct STSampleBuffer {
} STSampleBuffer;
typedef struct HWVoiceOut {
AudioBackend *s;
AudioMixengBackend *s;
bool enabled;
int poll_mode;
bool pending_disable;
struct audio_pcm_info info;
f_sample *clip;
uint64_t ts_helper;
STSampleBuffer mix_buf;
void *buf_emul;
@@ -86,12 +71,11 @@ typedef struct HWVoiceOut {
size_t samples;
QLIST_HEAD (sw_out_listhead, SWVoiceOut) sw_head;
QLIST_HEAD (sw_cap_listhead, SWVoiceCap) cap_head;
struct audio_pcm_ops *pcm_ops;
QLIST_ENTRY (HWVoiceOut) entries;
} HWVoiceOut;
typedef struct HWVoiceIn {
AudioBackend *s;
AudioMixengBackend *s;
bool enabled;
int poll_mode;
struct audio_pcm_info info;
@@ -99,7 +83,6 @@ typedef struct HWVoiceIn {
t_sample *conv;
size_t total_samples_captured;
uint64_t ts_helper;
STSampleBuffer conv_buf;
void *buf_emul;
@@ -107,12 +90,11 @@ typedef struct HWVoiceIn {
size_t samples;
QLIST_HEAD (sw_in_listhead, SWVoiceIn) sw_head;
struct audio_pcm_ops *pcm_ops;
QLIST_ENTRY (HWVoiceIn) entries;
} HWVoiceIn;
struct SWVoiceOut {
AudioBackend *s;
AudioMixengBackend *s;
struct audio_pcm_info info;
t_sample *conv;
STSampleBuffer resample_buf;
@@ -128,7 +110,7 @@ struct SWVoiceOut {
};
struct SWVoiceIn {
AudioBackend *s;
AudioMixengBackend *s;
bool active;
struct audio_pcm_info info;
void *rate;
@@ -142,59 +124,6 @@ struct SWVoiceIn {
QLIST_ENTRY (SWVoiceIn) entries;
};
typedef struct audio_driver audio_driver;
struct audio_driver {
const char *name;
void *(*init) (Audiodev *, Error **);
void (*fini) (void *);
#ifdef CONFIG_GIO
bool (*set_dbus_server)(AudioBackend *be,
GDBusObjectManagerServer *manager,
bool p2p,
Error **errp);
#endif
struct audio_pcm_ops *pcm_ops;
int max_voices_out;
int max_voices_in;
size_t voice_size_out;
size_t voice_size_in;
QLIST_ENTRY(audio_driver) next;
};
struct audio_pcm_ops {
int (*init_out)(HWVoiceOut *hw, audsettings *as, void *drv_opaque);
void (*fini_out)(HWVoiceOut *hw);
size_t (*write) (HWVoiceOut *hw, void *buf, size_t size);
void (*run_buffer_out)(HWVoiceOut *hw);
/*
* Get the free output buffer size. This is an upper limit. The size
* returned by function get_buffer_out may be smaller.
*/
size_t (*buffer_get_free)(HWVoiceOut *hw);
/*
* get a buffer that after later can be passed to put_buffer_out; optional
* returns the buffer, and writes it's size to size (in bytes)
*/
void *(*get_buffer_out)(HWVoiceOut *hw, size_t *size);
/*
* put back the buffer returned by get_buffer_out; optional
* buf must be equal the pointer returned by get_buffer_out,
* size may be smaller
*/
size_t (*put_buffer_out)(HWVoiceOut *hw, void *buf, size_t size);
void (*enable_out)(HWVoiceOut *hw, bool enable);
void (*volume_out)(HWVoiceOut *hw, Volume *vol);
int (*init_in) (HWVoiceIn *hw, audsettings *as, void *drv_opaque);
void (*fini_in) (HWVoiceIn *hw);
size_t (*read) (HWVoiceIn *hw, void *buf, size_t size);
void (*run_buffer_in)(HWVoiceIn *hw);
void *(*get_buffer_in)(HWVoiceIn *hw, size_t *size);
void (*put_buffer_in)(HWVoiceIn *hw, void *buf, size_t size);
void (*enable_in)(HWVoiceIn *hw, bool enable);
void (*volume_in)(HWVoiceIn *hw, Volume *vol);
};
audsettings audiodev_to_audsettings(AudiodevPerDirectionOptions *pdo);
int audioformat_bytes_per_sample(AudioFormat fmt);
int audio_buffer_frames(AudiodevPerDirectionOptions *pdo,
@@ -212,9 +141,11 @@ static inline void *advance(void *p, size_t incr)
int wav_start_capture(AudioBackend *state, CaptureState *s, const char *path,
int freq, int bits, int nchannels);
void audio_generic_initialize_buffer_in(HWVoiceIn *hw);
void audio_generic_run_buffer_in(HWVoiceIn *hw);
void *audio_generic_get_buffer_in(HWVoiceIn *hw, size_t *size);
void audio_generic_put_buffer_in(HWVoiceIn *hw, void *buf, size_t size);
void audio_generic_initialize_buffer_out(HWVoiceOut *hw);
void audio_generic_run_buffer_out(HWVoiceOut *hw);
size_t audio_generic_buffer_get_free(HWVoiceOut *hw);
void *audio_generic_get_buffer_out(HWVoiceOut *hw, size_t *size);
@@ -241,41 +172,74 @@ struct SWVoiceCap {
QLIST_ENTRY (SWVoiceCap) entries;
};
typedef struct AudioBackend {
Object parent;
struct AudioMixengBackendClass {
AudioBackendClass parent_class;
int max_voices_out;
int max_voices_in;
size_t voice_size_out;
size_t voice_size_in;
int (*init_out)(HWVoiceOut *hw, audsettings *as);
void (*fini_out)(HWVoiceOut *hw);
size_t (*write) (HWVoiceOut *hw, void *buf, size_t size);
void (*run_buffer_out)(HWVoiceOut *hw);
/*
* Get the free output buffer size. This is an upper limit. The size
* returned by function get_buffer_out may be smaller.
*/
size_t (*buffer_get_free)(HWVoiceOut *hw);
/*
* get a buffer that after later can be passed to put_buffer_out; optional
* returns the buffer, and writes it's size to size (in bytes)
*/
void *(*get_buffer_out)(HWVoiceOut *hw, size_t *size);
/*
* put back the buffer returned by get_buffer_out; optional
* buf must be equal the pointer returned by get_buffer_out,
* size may be smaller
*/
size_t (*put_buffer_out)(HWVoiceOut *hw, void *buf, size_t size);
void (*enable_out)(HWVoiceOut *hw, bool enable);
void (*volume_out)(HWVoiceOut *hw, Volume *vol);
int (*init_in) (HWVoiceIn *hw, audsettings *as);
void (*fini_in) (HWVoiceIn *hw);
size_t (*read) (HWVoiceIn *hw, void *buf, size_t size);
void (*run_buffer_in)(HWVoiceIn *hw);
void *(*get_buffer_in)(HWVoiceIn *hw, size_t *size);
void (*put_buffer_in)(HWVoiceIn *hw, void *buf, size_t size);
void (*enable_in)(HWVoiceIn *hw, bool enable);
void (*volume_in)(HWVoiceIn *hw, Volume *vol);
};
struct AudioMixengBackend {
AudioBackend parent_obj;
struct audio_driver *drv;
Audiodev *dev;
void *drv_opaque;
QEMUTimer *ts;
GTimer *run_timer;
QLIST_HEAD (hw_in_listhead, HWVoiceIn) hw_head_in;
QLIST_HEAD (hw_out_listhead, HWVoiceOut) hw_head_out;
QLIST_HEAD (cap_listhead, CaptureVoiceOut) cap_head;
int nb_hw_voices_out;
int nb_hw_voices_in;
int vm_running;
int64_t period_ticks;
bool timer_running;
uint64_t timer_last;
VMChangeStateEntry *vmse;
} AudioBackend;
};
extern const struct mixeng_volume nominal_volume;
extern const char *audio_prio_list[];
void audio_driver_register(audio_driver *drv);
void audio_pcm_init_info (struct audio_pcm_info *info, struct audsettings *as);
void audio_pcm_init_info (struct audio_pcm_info *info, const struct audsettings *as);
void audio_pcm_info_clear_buf (struct audio_pcm_info *info, void *buf, int len);
int audio_bug (const char *funcname, int cond);
void audio_run(AudioBackend *s, const char *msg);
const char *audio_application_name(void);
void audio_run(AudioMixengBackend *s, const char *msg);
typedef struct RateCtl {
int64_t start_ticks;
@@ -307,23 +271,15 @@ static inline size_t audio_ring_posb(size_t pos, size_t dist, size_t len)
return pos >= dist ? pos - dist : len - dist + pos;
}
#define dolog(fmt, ...) AUD_log(AUDIO_CAP, fmt, ## __VA_ARGS__)
#ifdef DEBUG
#define ldebug(fmt, ...) AUD_log(AUDIO_CAP, fmt, ## __VA_ARGS__)
#else
#define ldebug(fmt, ...) (void)0
#endif
typedef struct AudiodevListEntry {
Audiodev *dev;
QSIMPLEQ_ENTRY(AudiodevListEntry) next;
} AudiodevListEntry;
typedef QSIMPLEQ_HEAD(, AudiodevListEntry) AudiodevListHead;
void audio_create_pdos(Audiodev *dev);
AudiodevPerDirectionOptions *audio_get_pdo_in(Audiodev *dev);
AudiodevPerDirectionOptions *audio_get_pdo_out(Audiodev *dev);
void audio_sample_to_uint64(const st_sample *sample, int pos,
uint64_t *left, uint64_t *right);
void audio_sample_from_uint64(st_sample *sample, int pos,
uint64_t left, uint64_t right);
#define TYPE_AUDIO_MIXENG_BACKEND "audio-mixeng-backend"
OBJECT_DECLARE_TYPE(AudioMixengBackend, AudioMixengBackendClass, AUDIO_MIXENG_BACKEND)
#endif /* QEMU_AUDIO_INT_H */
+88 -124
View File
@@ -36,42 +36,42 @@
#define HWBUF hw->conv_buf
#endif
static void glue(audio_init_nb_voices_, TYPE)(AudioBackend *s,
struct audio_driver *drv, int min_voices)
static void glue(audio_init_nb_voices_, TYPE)(AudioMixengBackend *s,
AudioMixengBackendClass *k,
int min_voices)
{
int max_voices = glue (drv->max_voices_, TYPE);
size_t voice_size = glue(drv->voice_size_, TYPE);
const char *be_name = object_class_get_name(OBJECT_CLASS(k));
int max_voices = glue(k->max_voices_, TYPE);
size_t voice_size = glue(k->voice_size_, TYPE);
glue (s->nb_hw_voices_, TYPE) = glue(audio_get_pdo_, TYPE)(s->dev)->voices;
if (glue (s->nb_hw_voices_, TYPE) > max_voices) {
glue(s->nb_hw_voices_, TYPE) = glue(audio_get_pdo_, TYPE)(s->dev)->voices;
if (glue(s->nb_hw_voices_, TYPE) > max_voices) {
if (!max_voices) {
#ifdef DAC
dolog ("Driver `%s' does not support " NAME "\n", drv->name);
warn_report("audio: '%s' backend does not support " NAME, be_name);
#endif
} else {
dolog ("Driver `%s' does not support %d " NAME " voices, max %d\n",
drv->name,
glue (s->nb_hw_voices_, TYPE),
max_voices);
warn_report("audio: '%s' backend does not support %d " NAME " voices, max %d",
be_name, glue(s->nb_hw_voices_, TYPE), max_voices);
}
glue (s->nb_hw_voices_, TYPE) = max_voices;
glue(s->nb_hw_voices_, TYPE) = max_voices;
}
if (glue (s->nb_hw_voices_, TYPE) < min_voices) {
dolog ("Bogus number of " NAME " voices %d, setting to %d\n",
glue (s->nb_hw_voices_, TYPE),
min_voices);
if (glue(s->nb_hw_voices_, TYPE) < min_voices) {
warn_report("audio: Bogus number of " NAME " voices %d, setting to %d",
glue(s->nb_hw_voices_, TYPE),
min_voices);
}
if (audio_bug(__func__, !voice_size && max_voices)) {
dolog ("drv=`%s' voice_size=0 max_voices=%d\n",
drv->name, max_voices);
glue (s->nb_hw_voices_, TYPE) = 0;
if (!voice_size && max_voices) {
audio_bug("backend=`%s' voice_size=0 max_voices=%d",
be_name, max_voices);
glue(s->nb_hw_voices_, TYPE) = 0;
}
if (audio_bug(__func__, voice_size && !max_voices)) {
dolog("drv=`%s' voice_size=%zu max_voices=0\n",
drv->name, voice_size);
if (voice_size && !max_voices) {
audio_bug("backend=`%s' voice_size=%zu max_voices=0",
be_name, voice_size);
}
}
@@ -87,8 +87,8 @@ static void glue(audio_pcm_hw_alloc_resources_, TYPE)(HW *hw)
{
if (glue(audio_get_pdo_, TYPE)(hw->s->dev)->mixing_engine) {
size_t samples = hw->samples;
if (audio_bug(__func__, samples == 0)) {
dolog("Attempted to allocate empty buffer\n");
if (samples == 0) {
audio_bug("Attempted to allocate empty buffer");
}
HWBUF.buffer = g_new0(st_sample, samples);
@@ -129,7 +129,7 @@ static int glue (audio_pcm_sw_alloc_resources_, TYPE) (SW *sw)
/* f_fe_min = ceil(1 [frames] * f_be [Hz] / size_be [frames]) */
f_fe_min = (f_be + HWBUF.size - 1) / HWBUF.size;
qemu_log_mask(LOG_UNIMP,
AUDIO_CAP ": The guest selected a " NAME " sample rate"
"audio: The guest selected a " NAME " sample rate"
" of %d Hz for %s. Only sample rates >= %" PRIu64 " Hz"
" are supported.\n",
sw->info.freq, sw->name, f_fe_min);
@@ -159,7 +159,7 @@ static int glue (audio_pcm_sw_init_, TYPE) (
SW *sw,
HW *hw,
const char *name,
struct audsettings *as
const struct audsettings *as
)
{
int err;
@@ -172,7 +172,7 @@ static int glue (audio_pcm_sw_init_, TYPE) (
sw->empty = true;
#endif
if (sw->info.is_float) {
if (audio_format_is_float(sw->info.af)) {
#ifdef DAC
sw->conv = mixeng_conv_float[sw->info.nchannels == 2]
[sw->info.swap_endianness];
@@ -187,9 +187,9 @@ static int glue (audio_pcm_sw_init_, TYPE) (
sw->clip = mixeng_clip
#endif
[sw->info.nchannels == 2]
[sw->info.is_signed]
[audio_format_is_signed(sw->info.af)]
[sw->info.swap_endianness]
[audio_bits_to_index(sw->info.bits)];
[audio_format_to_index(sw->info.af)];
}
sw->name = g_strdup (name);
@@ -221,27 +221,29 @@ static void glue (audio_pcm_hw_del_sw_, TYPE) (SW *sw)
static void glue (audio_pcm_hw_gc_, TYPE) (HW **hwp)
{
HW *hw = *hwp;
AudioBackend *s = hw->s;
AudioMixengBackend *s = hw->s;
AudioMixengBackendClass *k = AUDIO_MIXENG_BACKEND_GET_CLASS(s);
if (!hw->sw_head.lh_first) {
#ifdef DAC
audio_detach_capture(hw);
#endif
QLIST_REMOVE(hw, entries);
glue(hw->pcm_ops->fini_, TYPE) (hw);
glue(k->fini_, TYPE)(hw);
glue(s->nb_hw_voices_, TYPE) += 1;
glue(audio_pcm_hw_free_resources_ , TYPE) (hw);
object_unref(hw->s);
g_free(hw);
*hwp = NULL;
}
}
static HW *glue(audio_pcm_hw_find_any_, TYPE)(AudioBackend *s, HW *hw)
static HW *glue(audio_pcm_hw_find_any_, TYPE)(AudioMixengBackend *s, HW *hw)
{
return hw ? hw->entries.le_next : glue (s->hw_head_, TYPE).lh_first;
}
static HW *glue(audio_pcm_hw_find_any_enabled_, TYPE)(AudioBackend *s, HW *hw)
static HW *glue(audio_pcm_hw_find_any_enabled_, TYPE)(AudioMixengBackend *s, HW *hw)
{
while ((hw = glue(audio_pcm_hw_find_any_, TYPE)(s, hw))) {
if (hw->enabled) {
@@ -251,7 +253,7 @@ static HW *glue(audio_pcm_hw_find_any_enabled_, TYPE)(AudioBackend *s, HW *hw)
return NULL;
}
static HW *glue(audio_pcm_hw_find_specific_, TYPE)(AudioBackend *s, HW *hw,
static HW *glue(audio_pcm_hw_find_specific_, TYPE)(AudioMixengBackend *s, HW *hw,
struct audsettings *as)
{
while ((hw = glue(audio_pcm_hw_find_any_, TYPE)(s, hw))) {
@@ -262,48 +264,42 @@ static HW *glue(audio_pcm_hw_find_specific_, TYPE)(AudioBackend *s, HW *hw,
return NULL;
}
static HW *glue(audio_pcm_hw_add_new_, TYPE)(AudioBackend *s,
static HW *glue(audio_pcm_hw_add_new_, TYPE)(AudioMixengBackend *s,
struct audsettings *as)
{
HW *hw;
struct audio_driver *drv = s->drv;
AudioMixengBackendClass *k = AUDIO_MIXENG_BACKEND_GET_CLASS(s);
if (!glue (s->nb_hw_voices_, TYPE)) {
if (!glue(s->nb_hw_voices_, TYPE)) {
return NULL;
}
if (audio_bug(__func__, !drv)) {
dolog ("No host audio driver\n");
return NULL;
}
if (audio_bug(__func__, !drv->pcm_ops)) {
dolog ("Host audio driver without pcm_ops\n");
if (!glue(k->init_, TYPE)) {
audio_bug("No host audio driver or missing init_%s", NAME);
return NULL;
}
/*
* Since glue(s->nb_hw_voices_, TYPE) is != 0, glue(drv->voice_size_, TYPE)
* Since glue(s->nb_hw_voices_, TYPE) is != 0, glue(k->voice_size_, TYPE)
* is guaranteed to be != 0. See the audio_init_nb_voices_* functions.
*/
hw = g_malloc0(glue(drv->voice_size_, TYPE));
hw->s = s;
hw->pcm_ops = drv->pcm_ops;
hw = g_malloc0(glue(k->voice_size_, TYPE));
hw->s = AUDIO_MIXENG_BACKEND(object_ref(s));
QLIST_INIT (&hw->sw_head);
#ifdef DAC
QLIST_INIT (&hw->cap_head);
#endif
if (glue (hw->pcm_ops->init_, TYPE) (hw, as, s->drv_opaque)) {
if (glue(k->init_, TYPE)(hw, as)) {
goto err0;
}
if (audio_bug(__func__, hw->samples <= 0)) {
dolog("hw->samples=%zd\n", hw->samples);
if (hw->samples <= 0) {
audio_bug("hw->samples=%zd", hw->samples);
goto err1;
}
if (hw->info.is_float) {
if (audio_format_is_float(hw->info.af)) {
#ifdef DAC
hw->clip = mixeng_clip_float[hw->info.nchannels == 2]
[hw->info.swap_endianness];
@@ -318,9 +314,9 @@ static HW *glue(audio_pcm_hw_add_new_, TYPE)(AudioBackend *s,
hw->conv = mixeng_conv
#endif
[hw->info.nchannels == 2]
[hw->info.is_signed]
[audio_format_is_signed(hw->info.af)]
[hw->info.swap_endianness]
[audio_bits_to_index(hw->info.bits)];
[audio_format_to_index(hw->info.af)];
}
glue(audio_pcm_hw_alloc_resources_, TYPE)(hw);
@@ -333,8 +329,9 @@ static HW *glue(audio_pcm_hw_add_new_, TYPE)(AudioBackend *s,
return hw;
err1:
glue (hw->pcm_ops->fini_, TYPE) (hw);
glue(k->fini_, TYPE)(hw);
err0:
object_unref(hw->s);
g_free (hw);
return NULL;
}
@@ -398,7 +395,7 @@ AudiodevPerDirectionOptions *glue(audio_get_pdo_, TYPE)(Audiodev *dev)
abort();
}
static HW *glue(audio_pcm_hw_add_, TYPE)(AudioBackend *s, struct audsettings *as)
static HW *glue(audio_pcm_hw_add_, TYPE)(AudioMixengBackend *s, struct audsettings *as)
{
HW *hw;
AudiodevPerDirectionOptions *pdo = glue(audio_get_pdo_, TYPE)(s->dev);
@@ -424,9 +421,9 @@ static HW *glue(audio_pcm_hw_add_, TYPE)(AudioBackend *s, struct audsettings *as
}
static SW *glue(audio_pcm_create_voice_pair_, TYPE)(
AudioBackend *s,
AudioMixengBackend *s,
const char *sw_name,
struct audsettings *as
const struct audsettings *as
)
{
SW *sw;
@@ -441,11 +438,11 @@ static SW *glue(audio_pcm_create_voice_pair_, TYPE)(
}
sw = g_new0(SW, 1);
sw->s = s;
sw->s = AUDIO_MIXENG_BACKEND(object_ref(s));
hw = glue(audio_pcm_hw_add_, TYPE)(s, &hw_as);
if (!hw) {
dolog("Could not create a backend for voice `%s'\n", sw_name);
error_report("audio: Could not create a backend for voice '%s'", sw_name);
goto err1;
}
@@ -461,6 +458,7 @@ err2:
glue (audio_pcm_hw_del_sw_, TYPE) (sw);
glue (audio_pcm_hw_gc_, TYPE) (&hw);
err1:
object_unref(sw->s);
g_free(sw);
return NULL;
}
@@ -470,14 +468,16 @@ static void glue (audio_close_, TYPE) (SW *sw)
glue (audio_pcm_sw_fini_, TYPE) (sw);
glue (audio_pcm_hw_del_sw_, TYPE) (sw);
glue (audio_pcm_hw_gc_, TYPE) (&sw->hw);
object_unref(sw->s);
g_free (sw);
}
void glue(AUD_close_, TYPE)(AudioBackend *be, SW *sw)
static void glue(audio_mixeng_backend_close_, TYPE)(AudioBackend *be, SW *sw)
{
if (sw) {
if (audio_bug(__func__, !be)) {
dolog("backend=%p\n", be);
if (!be) {
audio_bug("backend=%p", be);
return;
}
@@ -485,36 +485,35 @@ void glue(AUD_close_, TYPE)(AudioBackend *be, SW *sw)
}
}
SW *glue (AUD_open_, TYPE) (
static SW *glue(audio_mixeng_backend_open_, TYPE) (
AudioBackend *be,
SW *sw,
const char *name,
void *callback_opaque ,
audio_callback_fn callback_fn,
struct audsettings *as
)
const struct audsettings *as)
{
AudioBackend *s = be;
AudioMixengBackend *s = AUDIO_MIXENG_BACKEND(be);
AudioMixengBackendClass *k;
AudiodevPerDirectionOptions *pdo;
if (audio_bug(__func__, !be || !name || !callback_fn || !as)) {
dolog("backend=%p name=%p callback_fn=%p as=%p\n",
be, name, callback_fn, as);
goto fail;
}
k = AUDIO_MIXENG_BACKEND_GET_CLASS(s);
pdo = glue(audio_get_pdo_, TYPE)(s->dev);
ldebug ("open %s, freq %d, nchannels %d, fmt %d\n",
name, as->freq, as->nchannels, as->fmt);
#ifdef DAC
trace_audio_open_out(name, as->freq, as->nchannels, as->fmt);
#else
trace_audio_open_in(name, as->freq, as->nchannels, as->fmt);
#endif
if (audio_bug(__func__, audio_validate_settings(as))) {
audio_print_settings (as);
if (audio_validate_settings(as)) {
g_autofree char *str = audsettings_to_string(as);
error_report("audio: Invalid audio settings: %s", str);
goto fail;
}
if (audio_bug(__func__, !s->drv)) {
dolog ("Can not open `%s' (no host audio driver)\n", name);
if (!glue(k->init_, TYPE)) {
error_report("audio: Can not open `%s' (no host audio driver)", name);
goto fail;
}
@@ -523,7 +522,7 @@ SW *glue (AUD_open_, TYPE) (
}
if (!pdo->fixed_settings && sw) {
glue(AUD_close_, TYPE)(be, sw);
glue(audio_be_close_, TYPE)(be, sw);
sw = NULL;
}
@@ -531,8 +530,7 @@ SW *glue (AUD_open_, TYPE) (
HW *hw = sw->hw;
if (!hw) {
dolog("Internal logic error: voice `%s' has no backend\n",
SW_NAME(sw));
audio_bug("Internal logic error: voice '%s' has no backend", SW_NAME(sw));
goto fail;
}
@@ -551,58 +549,24 @@ SW *glue (AUD_open_, TYPE) (
sw->callback.fn = callback_fn;
sw->callback.opaque = callback_opaque;
#ifdef DEBUG_AUDIO
dolog ("%s\n", name);
audio_pcm_print_info ("hw", &sw->hw->info);
audio_pcm_print_info ("sw", &sw->info);
#endif
trace_audio_voice_pair(G_STRINGIFY(TYPE), name,
AudioFormat_str(sw->hw->info.af),
sw->hw->info.freq, sw->hw->info.nchannels,
AudioFormat_str(sw->info.af),
sw->info.freq, sw->info.nchannels);
return sw;
fail:
glue(AUD_close_, TYPE)(be, sw);
glue(audio_be_close_, TYPE)(be, sw);
return NULL;
}
bool glue(AUD_is_active_, TYPE)(SW *sw)
static bool glue(audio_mixeng_backend_is_active_, TYPE)(AudioBackend *be, SW *sw)
{
return sw ? sw->active : 0;
}
void glue (AUD_init_time_stamp_, TYPE) (SW *sw, QEMUAudioTimeStamp *ts)
{
if (!sw) {
return;
}
ts->old_ts = sw->hw->ts_helper;
}
uint64_t glue (AUD_get_elapsed_usec_, TYPE) (SW *sw, QEMUAudioTimeStamp *ts)
{
uint64_t delta, cur_ts, old_ts;
if (!sw) {
return 0;
}
cur_ts = sw->hw->ts_helper;
old_ts = ts->old_ts;
/* dolog ("cur %" PRId64 " old %" PRId64 "\n", cur_ts, old_ts); */
if (cur_ts >= old_ts) {
delta = cur_ts - old_ts;
} else {
delta = UINT64_MAX - old_ts + cur_ts;
}
if (!delta) {
return 0;
}
return muldiv64 (delta, sw->hw->info.freq, 1000000);
}
#undef TYPE
#undef HW
#undef SW
+15 -16
View File
@@ -2,12 +2,12 @@
#include "qemu/osdep.h"
#define AUDIO_CAP "win-int"
#include <windows.h>
#include <mmreg.h>
#include <mmsystem.h>
#include "qemu/audio.h"
#include "qemu/error-report.h"
#include "audio_int.h"
#include "audio_win_int.h"
@@ -53,7 +53,7 @@ int waveformat_from_audio_settings (WAVEFORMATEX *wfx,
break;
default:
dolog("Internal logic error: Bad audio format %d\n", as->fmt);
error_report("dsound: Internal logic error: Bad audio format %d", as->fmt);
return -1;
}
@@ -64,7 +64,7 @@ int waveformat_to_audio_settings (WAVEFORMATEX *wfx,
struct audsettings *as)
{
if (!wfx->nSamplesPerSec) {
dolog ("Invalid wave format, frequency is zero\n");
error_report("dsound: Invalid wave format, frequency is zero");
return -1;
}
as->freq = wfx->nSamplesPerSec;
@@ -79,10 +79,9 @@ int waveformat_to_audio_settings (WAVEFORMATEX *wfx,
break;
default:
dolog (
"Invalid wave format, number of channels is not 1 or 2, but %d\n",
wfx->nChannels
);
error_report("dsound: Invalid wave format, "
"number of channels is not 1 or 2, but %d",
wfx->nChannels);
return -1;
}
@@ -101,9 +100,9 @@ int waveformat_to_audio_settings (WAVEFORMATEX *wfx,
break;
default:
dolog("Invalid PCM wave format, bits per sample is not "
"8, 16 or 32, but %d\n",
wfx->wBitsPerSample);
error_report("dsound: Invalid PCM wave format, bits per sample is not "
"8, 16 or 32, but %d",
wfx->wBitsPerSample);
return -1;
}
} else if (wfx->wFormatTag == WAVE_FORMAT_IEEE_FLOAT) {
@@ -113,15 +112,15 @@ int waveformat_to_audio_settings (WAVEFORMATEX *wfx,
break;
default:
dolog("Invalid IEEE_FLOAT wave format, bits per sample is not "
"32, but %d\n",
wfx->wBitsPerSample);
error_report("dsound: Invalid IEEE_FLOAT wave format, "
"bits per sample is not 32, but %d",
wfx->wBitsPerSample);
return -1;
}
} else {
dolog("Invalid wave format, tag is not PCM and not IEEE_FLOAT, "
"but %d\n",
wfx->wFormatTag);
error_report("dsound: Invalid wave format, "
"tag is not PCM and not IEEE_FLOAT, but %d",
wfx->wFormatTag);
return -1;
}
+199 -194
View File
@@ -28,42 +28,49 @@
#include "qemu/main-loop.h"
#include "qemu/module.h"
#include "qemu/error-report.h"
#include "qemu/audio.h"
#define AUDIO_CAP "coreaudio"
#include "qom/object.h"
#include "audio_int.h"
#define TYPE_AUDIO_COREAUDIO "audio-coreaudio"
OBJECT_DECLARE_SIMPLE_TYPE(AudioCoreaudio, AUDIO_COREAUDIO)
struct AudioCoreaudio {
AudioMixengBackend parent_obj;
};
typedef struct coreaudioVoiceOut {
HWVoiceOut hw;
pthread_mutex_t buf_mutex;
AudioDeviceID outputDeviceID;
int frameSizeSetting;
uint32_t bufferCount;
UInt32 audioDevicePropertyBufferFrameSize;
AudioDeviceID device_id;
int frame_size_setting;
uint32_t buffer_count;
UInt32 device_frame_size;
AudioDeviceIOProcID ioprocid;
bool enabled;
} coreaudioVoiceOut;
} CoreaudioVoiceOut;
static const AudioObjectPropertyAddress voice_addr = {
static const AudioObjectPropertyAddress voice_out_addr = {
kAudioHardwarePropertyDefaultOutputDevice,
kAudioObjectPropertyScopeGlobal,
kAudioObjectPropertyElementMain
};
static OSStatus coreaudio_get_voice(AudioDeviceID *id)
static OSStatus coreaudio_get_voice_out(AudioDeviceID *id)
{
UInt32 size = sizeof(*id);
return AudioObjectGetPropertyData(kAudioObjectSystemObject,
&voice_addr,
&voice_out_addr,
0,
NULL,
&size,
id);
}
static OSStatus coreaudio_get_framesizerange(AudioDeviceID id,
AudioValueRange *framerange)
static OSStatus coreaudio_get_out_framesizerange(AudioDeviceID id,
AudioValueRange *framerange)
{
UInt32 size = sizeof(*framerange);
AudioObjectPropertyAddress addr = {
@@ -80,7 +87,7 @@ static OSStatus coreaudio_get_framesizerange(AudioDeviceID id,
framerange);
}
static OSStatus coreaudio_get_framesize(AudioDeviceID id, UInt32 *framesize)
static OSStatus coreaudio_get_out_framesize(AudioDeviceID id, UInt32 *framesize)
{
UInt32 size = sizeof(*framesize);
AudioObjectPropertyAddress addr = {
@@ -97,7 +104,7 @@ static OSStatus coreaudio_get_framesize(AudioDeviceID id, UInt32 *framesize)
framesize);
}
static OSStatus coreaudio_set_framesize(AudioDeviceID id, UInt32 *framesize)
static OSStatus coreaudio_set_out_framesize(AudioDeviceID id, UInt32 *framesize)
{
UInt32 size = sizeof(*framesize);
AudioObjectPropertyAddress addr = {
@@ -114,8 +121,8 @@ static OSStatus coreaudio_set_framesize(AudioDeviceID id, UInt32 *framesize)
framesize);
}
static OSStatus coreaudio_set_streamformat(AudioDeviceID id,
AudioStreamBasicDescription *d)
static OSStatus coreaudio_set_out_streamformat(AudioDeviceID id,
AudioStreamBasicDescription *d)
{
UInt32 size = sizeof(*d);
AudioObjectPropertyAddress addr = {
@@ -132,7 +139,7 @@ static OSStatus coreaudio_set_streamformat(AudioDeviceID id,
d);
}
static OSStatus coreaudio_get_isrunning(AudioDeviceID id, UInt32 *result)
static OSStatus coreaudio_get_out_isrunning(AudioDeviceID id, UInt32 *result)
{
UInt32 size = sizeof(*result);
AudioObjectPropertyAddress addr = {
@@ -149,7 +156,7 @@ static OSStatus coreaudio_get_isrunning(AudioDeviceID id, UInt32 *result)
result);
}
static void coreaudio_logstatus (OSStatus status)
static void coreaudio_logstatus(OSStatus status)
{
const char *str = "BUG";
@@ -199,89 +206,85 @@ static void coreaudio_logstatus (OSStatus status)
break;
default:
AUD_log (AUDIO_CAP, "Reason: status code %" PRId32 "\n", (int32_t)status);
error_printf(" Reason: status code %" PRId32, (int32_t)status);
return;
}
AUD_log (AUDIO_CAP, "Reason: %s\n", str);
error_printf(" Reason: %s", str);
}
static void G_GNUC_PRINTF (2, 3) coreaudio_logerr (
OSStatus status,
const char *fmt,
...
)
static void G_GNUC_PRINTF(2, 3) coreaudio_logerr(OSStatus status,
const char *fmt, ...)
{
va_list ap;
va_start (ap, fmt);
AUD_log (AUDIO_CAP, fmt, ap);
va_end (ap);
coreaudio_logstatus (status);
error_printf("coreaudio: ");
va_start(ap, fmt);
error_vprintf(fmt, ap);
va_end(ap);
coreaudio_logstatus(status);
error_printf("\n");
}
static void G_GNUC_PRINTF (3, 4) coreaudio_logerr2 (
OSStatus status,
const char *typ,
const char *fmt,
...
)
static void G_GNUC_PRINTF(3, 4) coreaudio_logerr2(OSStatus status,
const char *typ,
const char *fmt, ...)
{
va_list ap;
AUD_log (AUDIO_CAP, "Could not initialize %s\n", typ);
va_start (ap, fmt);
AUD_vlog (AUDIO_CAP, fmt, ap);
va_end (ap);
coreaudio_logstatus (status);
error_printf("coreaudio: Could not initialize %s: ", typ);
va_start(ap, fmt);
error_vprintf(fmt, ap);
va_end(ap);
coreaudio_logstatus(status);
error_printf("\n");
}
#define coreaudio_playback_logerr(status, ...) \
coreaudio_logerr2(status, "playback", __VA_ARGS__)
static int coreaudio_buf_lock (coreaudioVoiceOut *core, const char *fn_name)
static int coreaudio_voice_out_buf_lock(CoreaudioVoiceOut *core,
const char *fn_name)
{
int err;
err = pthread_mutex_lock (&core->buf_mutex);
err = pthread_mutex_lock(&core->buf_mutex);
if (err) {
dolog ("Could not lock voice for %s\nReason: %s\n",
fn_name, strerror (err));
error_report("coreaudio: Could not lock voice for %s: %s",
fn_name, strerror(err));
return -1;
}
return 0;
}
static int coreaudio_buf_unlock (coreaudioVoiceOut *core, const char *fn_name)
static int coreaudio_voice_out_buf_unlock(CoreaudioVoiceOut *core,
const char *fn_name)
{
int err;
err = pthread_mutex_unlock (&core->buf_mutex);
err = pthread_mutex_unlock(&core->buf_mutex);
if (err) {
dolog ("Could not unlock voice for %s\nReason: %s\n",
fn_name, strerror (err));
error_report("coreaudio: Could not unlock voice for %s: %s",
fn_name, strerror(err));
return -1;
}
return 0;
}
#define COREAUDIO_WRAPPER_FUNC(name, ret_type, args_decl, args) \
static ret_type glue(coreaudio_, name)args_decl \
{ \
coreaudioVoiceOut *core = (coreaudioVoiceOut *) hw; \
ret_type ret; \
\
if (coreaudio_buf_lock(core, "coreaudio_" #name)) { \
return 0; \
} \
\
ret = glue(audio_generic_, name)args; \
\
coreaudio_buf_unlock(core, "coreaudio_" #name); \
return ret; \
#define COREAUDIO_WRAPPER_FUNC(name, ret_type, args_decl, args) \
static ret_type glue(coreaudio_, name)args_decl \
{ \
CoreaudioVoiceOut *core = (CoreaudioVoiceOut *)hw; \
ret_type ret; \
\
if (coreaudio_voice_out_buf_lock(core, "coreaudio_" #name)) { \
return 0; \
} \
\
ret = glue(audio_generic_, name)args; \
\
coreaudio_voice_out_buf_unlock(core, "coreaudio_" #name); \
return ret; \
}
COREAUDIO_WRAPPER_FUNC(buffer_get_free, size_t, (HWVoiceOut *hw), (hw))
COREAUDIO_WRAPPER_FUNC(get_buffer_out, void *, (HWVoiceOut *hw, size_t *size),
@@ -297,7 +300,7 @@ COREAUDIO_WRAPPER_FUNC(write, size_t, (HWVoiceOut *hw, void *buf, size_t size),
* callback to feed audiooutput buffer. called without BQL.
* allowed to lock "buf_mutex", but disallowed to have any other locks.
*/
static OSStatus audioDeviceIOProc(
static OSStatus out_device_ioproc(
AudioDeviceID inDevice,
const AudioTimeStamp *inNow,
const AudioBufferList *inInputData,
@@ -306,33 +309,33 @@ static OSStatus audioDeviceIOProc(
const AudioTimeStamp *inOutputTime,
void *hwptr)
{
UInt32 frameCount, pending_frames;
UInt32 frame_size, pending_frames;
void *out = outOutputData->mBuffers[0].mData;
HWVoiceOut *hw = hwptr;
coreaudioVoiceOut *core = (coreaudioVoiceOut *) hwptr;
CoreaudioVoiceOut *core = hwptr;
size_t len;
if (coreaudio_buf_lock (core, "audioDeviceIOProc")) {
if (coreaudio_voice_out_buf_lock(core, "out_device_ioproc")) {
inInputTime = 0;
return 0;
}
if (inDevice != core->outputDeviceID) {
coreaudio_buf_unlock (core, "audioDeviceIOProc(old device)");
if (inDevice != core->device_id) {
coreaudio_voice_out_buf_unlock(core, "out_device_ioproc(old device)");
return 0;
}
frameCount = core->audioDevicePropertyBufferFrameSize;
frame_size = core->device_frame_size;
pending_frames = hw->pending_emul / hw->info.bytes_per_frame;
/* if there are not enough samples, set signal and return */
if (pending_frames < frameCount) {
if (pending_frames < frame_size) {
inInputTime = 0;
coreaudio_buf_unlock (core, "audioDeviceIOProc(empty)");
coreaudio_voice_out_buf_unlock(core, "out_device_ioproc(empty)");
return 0;
}
len = frameCount * hw->info.bytes_per_frame;
len = frame_size * hw->info.bytes_per_frame;
while (len) {
size_t write_len, start;
@@ -348,17 +351,20 @@ static OSStatus audioDeviceIOProc(
out += write_len;
}
coreaudio_buf_unlock (core, "audioDeviceIOProc");
coreaudio_voice_out_buf_unlock(core, "out_device_ioproc");
return 0;
}
static OSStatus init_out_device(coreaudioVoiceOut *core)
static OSStatus init_out_device(CoreaudioVoiceOut *core)
{
AudioDeviceID device_id;
AudioDeviceIOProcID ioprocid;
AudioValueRange value_range;
OSStatus status;
AudioValueRange frameRange;
UInt32 device_frame_size;
AudioStreamBasicDescription streamBasicDescription = {
.mBitsPerChannel = core->hw.info.bits,
AudioStreamBasicDescription stream_basic_description = {
.mBitsPerChannel = audio_format_bits(core->hw.info.af),
.mBytesPerFrame = core->hw.info.bytes_per_frame,
.mBytesPerPacket = core->hw.info.bytes_per_frame,
.mChannelsPerFrame = core->hw.info.nchannels,
@@ -368,76 +374,74 @@ static OSStatus init_out_device(coreaudioVoiceOut *core)
.mSampleRate = core->hw.info.freq
};
status = coreaudio_get_voice(&core->outputDeviceID);
status = coreaudio_get_voice_out(&device_id);
if (status != kAudioHardwareNoError) {
coreaudio_playback_logerr (status,
"Could not get default output Device\n");
coreaudio_playback_logerr(status,
"Could not get default output device");
return status;
}
if (core->outputDeviceID == kAudioDeviceUnknown) {
dolog ("Could not initialize playback - Unknown Audiodevice\n");
if (device_id == kAudioDeviceUnknown) {
error_report("coreaudio: Could not initialize playback: "
"Unknown audio device");
return status;
}
/* get minimum and maximum buffer frame sizes */
status = coreaudio_get_framesizerange(core->outputDeviceID,
&frameRange);
status = coreaudio_get_out_framesizerange(device_id, &value_range);
if (status == kAudioHardwareBadObjectError) {
return 0;
}
if (status != kAudioHardwareNoError) {
coreaudio_playback_logerr (status,
"Could not get device buffer frame range\n");
coreaudio_playback_logerr(status,
"Could not get device buffer frame range");
return status;
}
if (frameRange.mMinimum > core->frameSizeSetting) {
core->audioDevicePropertyBufferFrameSize = (UInt32) frameRange.mMinimum;
dolog ("warning: Upsizing Buffer Frames to %f\n", frameRange.mMinimum);
} else if (frameRange.mMaximum < core->frameSizeSetting) {
core->audioDevicePropertyBufferFrameSize = (UInt32) frameRange.mMaximum;
dolog ("warning: Downsizing Buffer Frames to %f\n", frameRange.mMaximum);
if (value_range.mMinimum > core->frame_size_setting) {
device_frame_size = value_range.mMinimum;
warn_report("coreaudio: Upsizing buffer frames to %f",
value_range.mMinimum);
} else if (value_range.mMaximum < core->frame_size_setting) {
device_frame_size = value_range.mMaximum;
warn_report("coreaudio: Downsizing buffer frames to %f",
value_range.mMaximum);
} else {
core->audioDevicePropertyBufferFrameSize = core->frameSizeSetting;
device_frame_size = core->frame_size_setting;
}
/* set Buffer Frame Size */
status = coreaudio_set_framesize(core->outputDeviceID,
&core->audioDevicePropertyBufferFrameSize);
status = coreaudio_set_out_framesize(device_id, &device_frame_size);
if (status == kAudioHardwareBadObjectError) {
return 0;
}
if (status != kAudioHardwareNoError) {
coreaudio_playback_logerr (status,
"Could not set device buffer frame size %" PRIu32 "\n",
(uint32_t)core->audioDevicePropertyBufferFrameSize);
coreaudio_playback_logerr(status,
"Could not set device buffer frame size %" PRIu32,
(uint32_t)device_frame_size);
return status;
}
/* get Buffer Frame Size */
status = coreaudio_get_framesize(core->outputDeviceID,
&core->audioDevicePropertyBufferFrameSize);
status = coreaudio_get_out_framesize(device_id, &device_frame_size);
if (status == kAudioHardwareBadObjectError) {
return 0;
}
if (status != kAudioHardwareNoError) {
coreaudio_playback_logerr (status,
"Could not get device buffer frame size\n");
coreaudio_playback_logerr(status,
"Could not get device buffer frame size");
return status;
}
core->hw.samples = core->bufferCount * core->audioDevicePropertyBufferFrameSize;
/* set Samplerate */
status = coreaudio_set_streamformat(core->outputDeviceID,
&streamBasicDescription);
status = coreaudio_set_out_streamformat(device_id,
&stream_basic_description);
if (status == kAudioHardwareBadObjectError) {
return 0;
}
if (status != kAudioHardwareNoError) {
coreaudio_playback_logerr (status,
"Could not set samplerate %lf\n",
streamBasicDescription.mSampleRate);
core->outputDeviceID = kAudioDeviceUnknown;
coreaudio_playback_logerr(status,
"Could not set samplerate %lf",
stream_basic_description.mSampleRate);
return status;
}
@@ -451,63 +455,68 @@ static OSStatus init_out_device(coreaudioVoiceOut *core)
* Therefore, the specified callback must be designed to avoid a deadlock
* with the callers of AudioObjectGetPropertyData.
*/
core->ioprocid = NULL;
status = AudioDeviceCreateIOProcID(core->outputDeviceID,
audioDeviceIOProc,
ioprocid = NULL;
status = AudioDeviceCreateIOProcID(device_id,
out_device_ioproc,
&core->hw,
&core->ioprocid);
&ioprocid);
if (status == kAudioHardwareBadDeviceError) {
return 0;
}
if (status != kAudioHardwareNoError || core->ioprocid == NULL) {
coreaudio_playback_logerr (status, "Could not set IOProc\n");
core->outputDeviceID = kAudioDeviceUnknown;
if (status != kAudioHardwareNoError || ioprocid == NULL) {
coreaudio_playback_logerr(status, "Could not set IOProc");
return status;
}
core->device_id = device_id;
core->device_frame_size = device_frame_size;
core->hw.samples = core->buffer_count * core->device_frame_size;
audio_generic_initialize_buffer_out(&core->hw);
core->ioprocid = ioprocid;
return 0;
}
static void fini_out_device(coreaudioVoiceOut *core)
static void fini_out_device(CoreaudioVoiceOut *core)
{
OSStatus status;
UInt32 isrunning;
/* stop playback */
status = coreaudio_get_isrunning(core->outputDeviceID, &isrunning);
status = coreaudio_get_out_isrunning(core->device_id, &isrunning);
if (status != kAudioHardwareBadObjectError) {
if (status != kAudioHardwareNoError) {
coreaudio_logerr(status,
"Could not determine whether Device is playing\n");
"Could not determine whether device is playing");
}
if (isrunning) {
status = AudioDeviceStop(core->outputDeviceID, core->ioprocid);
status = AudioDeviceStop(core->device_id, core->ioprocid);
if (status != kAudioHardwareBadDeviceError && status != kAudioHardwareNoError) {
coreaudio_logerr(status, "Could not stop playback\n");
coreaudio_logerr(status, "Could not stop playback");
}
}
}
/* remove callback */
status = AudioDeviceDestroyIOProcID(core->outputDeviceID,
status = AudioDeviceDestroyIOProcID(core->device_id,
core->ioprocid);
if (status != kAudioHardwareBadDeviceError && status != kAudioHardwareNoError) {
coreaudio_logerr(status, "Could not remove IOProc\n");
coreaudio_logerr(status, "Could not remove IOProc");
}
core->outputDeviceID = kAudioDeviceUnknown;
core->device_id = kAudioDeviceUnknown;
}
static void update_device_playback_state(coreaudioVoiceOut *core)
static void update_out_device_playback_state(CoreaudioVoiceOut *core)
{
OSStatus status;
UInt32 isrunning;
status = coreaudio_get_isrunning(core->outputDeviceID, &isrunning);
status = coreaudio_get_out_isrunning(core->device_id, &isrunning);
if (status != kAudioHardwareNoError) {
if (status != kAudioHardwareBadObjectError) {
coreaudio_logerr(status,
"Could not determine whether Device is playing\n");
"Could not determine whether device is playing");
}
return;
@@ -516,90 +525,92 @@ static void update_device_playback_state(coreaudioVoiceOut *core)
if (core->enabled) {
/* start playback */
if (!isrunning) {
status = AudioDeviceStart(core->outputDeviceID, core->ioprocid);
status = AudioDeviceStart(core->device_id, core->ioprocid);
if (status != kAudioHardwareBadDeviceError && status != kAudioHardwareNoError) {
coreaudio_logerr (status, "Could not resume playback\n");
coreaudio_logerr(status, "Could not resume playback");
}
}
} else {
/* stop playback */
if (isrunning) {
status = AudioDeviceStop(core->outputDeviceID,
status = AudioDeviceStop(core->device_id,
core->ioprocid);
if (status != kAudioHardwareBadDeviceError && status != kAudioHardwareNoError) {
coreaudio_logerr(status, "Could not pause playback\n");
coreaudio_logerr(status, "Could not pause playback");
}
}
}
}
/* called without BQL. */
static OSStatus handle_voice_change(
static OSStatus handle_voice_out_change(
AudioObjectID in_object_id,
UInt32 in_number_addresses,
const AudioObjectPropertyAddress *in_addresses,
void *in_client_data)
{
coreaudioVoiceOut *core = in_client_data;
CoreaudioVoiceOut *core = in_client_data;
bql_lock();
if (core->outputDeviceID) {
if (core->device_id) {
fini_out_device(core);
}
if (!init_out_device(core)) {
update_device_playback_state(core);
init_out_device(core);
if (core->device_id) {
update_out_device_playback_state(core);
}
bql_unlock();
return 0;
}
static int coreaudio_init_out(HWVoiceOut *hw, struct audsettings *as,
void *drv_opaque)
static int coreaudio_init_out(HWVoiceOut *hw, struct audsettings *as)
{
OSStatus status;
coreaudioVoiceOut *core = (coreaudioVoiceOut *) hw;
CoreaudioVoiceOut *core = (CoreaudioVoiceOut *)hw;
int err;
Audiodev *dev = drv_opaque;
Audiodev *dev = hw->s->dev;
AudiodevCoreaudioPerDirectionOptions *cpdo = dev->u.coreaudio.out;
struct audsettings obt_as;
/* create mutex */
err = pthread_mutex_init(&core->buf_mutex, NULL);
if (err) {
dolog("Could not create mutex\nReason: %s\n", strerror (err));
error_report("coreaudio: Could not create mutex: %s", strerror(err));
return -1;
}
obt_as = *as;
as = &obt_as;
as->fmt = AUDIO_FORMAT_F32;
audio_pcm_init_info (&hw->info, as);
audio_pcm_init_info(&hw->info, as);
core->frameSizeSetting = audio_buffer_frames(
core->frame_size_setting = audio_buffer_frames(
qapi_AudiodevCoreaudioPerDirectionOptions_base(cpdo), as, 11610);
core->bufferCount = cpdo->has_buffer_count ? cpdo->buffer_count : 4;
core->buffer_count = cpdo->has_buffer_count ? cpdo->buffer_count : 4;
status = AudioObjectAddPropertyListener(kAudioObjectSystemObject,
&voice_addr, handle_voice_change,
&voice_out_addr,
handle_voice_out_change,
core);
if (status != kAudioHardwareNoError) {
coreaudio_playback_logerr (status,
"Could not listen to voice property change\n");
coreaudio_playback_logerr(status,
"Could not listen to voice property change");
return -1;
}
if (init_out_device(core)) {
status = AudioObjectRemovePropertyListener(kAudioObjectSystemObject,
&voice_addr,
handle_voice_change,
&voice_out_addr,
handle_voice_out_change,
core);
if (status != kAudioHardwareNoError) {
coreaudio_playback_logerr(status,
"Could not remove voice property change listener\n");
"Could not remove voice property change listener");
}
return -1;
@@ -612,14 +623,14 @@ static void coreaudio_fini_out (HWVoiceOut *hw)
{
OSStatus status;
int err;
coreaudioVoiceOut *core = (coreaudioVoiceOut *) hw;
CoreaudioVoiceOut *core = (CoreaudioVoiceOut *)hw;
status = AudioObjectRemovePropertyListener(kAudioObjectSystemObject,
&voice_addr,
handle_voice_change,
&voice_out_addr,
handle_voice_out_change,
core);
if (status != kAudioHardwareNoError) {
coreaudio_logerr(status, "Could not remove voice property change listener\n");
coreaudio_logerr(status, "Could not remove voice property change listener");
}
fini_out_device(core);
@@ -627,54 +638,48 @@ static void coreaudio_fini_out (HWVoiceOut *hw)
/* destroy mutex */
err = pthread_mutex_destroy(&core->buf_mutex);
if (err) {
dolog("Could not destroy mutex\nReason: %s\n", strerror (err));
error_report("coreaudio: Could not destroy mutex: %s", strerror(err));
}
}
static void coreaudio_enable_out(HWVoiceOut *hw, bool enable)
{
coreaudioVoiceOut *core = (coreaudioVoiceOut *) hw;
CoreaudioVoiceOut *core = (CoreaudioVoiceOut *)hw;
core->enabled = enable;
update_device_playback_state(core);
update_out_device_playback_state(core);
}
static void *coreaudio_audio_init(Audiodev *dev, Error **errp)
static void audio_coreaudio_class_init(ObjectClass *klass, const void *data)
{
return dev;
AudioMixengBackendClass *k = AUDIO_MIXENG_BACKEND_CLASS(klass);
k->max_voices_out = 1;
k->max_voices_in = 0;
k->voice_size_out = sizeof(CoreaudioVoiceOut);
k->voice_size_in = 0;
k->init_out = coreaudio_init_out;
k->fini_out = coreaudio_fini_out;
/* wrapper for audio_generic_write */
k->write = coreaudio_write;
/* wrapper for audio_generic_buffer_get_free */
k->buffer_get_free = coreaudio_buffer_get_free;
/* wrapper for audio_generic_get_buffer_out */
k->get_buffer_out = coreaudio_get_buffer_out;
/* wrapper for audio_generic_put_buffer_out */
k->put_buffer_out = coreaudio_put_buffer_out;
k->enable_out = coreaudio_enable_out;
}
static void coreaudio_audio_fini (void *opaque)
{
}
static struct audio_pcm_ops coreaudio_pcm_ops = {
.init_out = coreaudio_init_out,
.fini_out = coreaudio_fini_out,
/* wrapper for audio_generic_write */
.write = coreaudio_write,
/* wrapper for audio_generic_buffer_get_free */
.buffer_get_free = coreaudio_buffer_get_free,
/* wrapper for audio_generic_get_buffer_out */
.get_buffer_out = coreaudio_get_buffer_out,
/* wrapper for audio_generic_put_buffer_out */
.put_buffer_out = coreaudio_put_buffer_out,
.enable_out = coreaudio_enable_out
static const TypeInfo audio_types[] = {
{
.name = TYPE_AUDIO_COREAUDIO,
.parent = TYPE_AUDIO_MIXENG_BACKEND,
.instance_size = sizeof(AudioCoreaudio),
.class_init = audio_coreaudio_class_init,
},
};
static struct audio_driver coreaudio_audio_driver = {
.name = "coreaudio",
.init = coreaudio_audio_init,
.fini = coreaudio_audio_fini,
.pcm_ops = &coreaudio_pcm_ops,
.max_voices_out = 1,
.max_voices_in = 0,
.voice_size_out = sizeof (coreaudioVoiceOut),
.voice_size_in = 0
};
static void register_audio_coreaudio(void)
{
audio_driver_register(&coreaudio_audio_driver);
}
type_init(register_audio_coreaudio);
DEFINE_TYPES(audio_types)
module_obj(TYPE_AUDIO_COREAUDIO);
+96 -74
View File
@@ -26,15 +26,16 @@
#include "qemu/error-report.h"
#include "qemu/module.h"
#include "qemu/dbus.h"
#include "qom/object.h"
#ifdef G_OS_UNIX
#include <gio/gunixfdlist.h>
#endif
#include "ui/dbus.h"
#include "ui/dbus-display.h"
#include "ui/dbus-display1.h"
#define AUDIO_CAP "dbus"
#include "qemu/audio.h"
#include "audio_int.h"
#include "trace.h"
@@ -43,15 +44,22 @@
#define DBUS_DEFAULT_AUDIO_NSAMPLES 480
typedef struct DBusAudio {
Audiodev *dev;
#define TYPE_AUDIO_DBUS "audio-dbus"
OBJECT_DECLARE_SIMPLE_TYPE(AudioDbus, AUDIO_DBUS)
static AudioBackendClass *audio_dbus_parent_class;
struct AudioDbus {
AudioMixengBackend parent_obj;
GDBusObjectManagerServer *server;
bool p2p;
GDBusObjectSkeleton *audio;
QemuDBusDisplay1Audio *iface;
GHashTable *out_listeners;
GHashTable *in_listeners;
} DBusAudio;
};
typedef struct DBusVoiceOut {
HWVoiceOut hw;
@@ -94,7 +102,7 @@ static void *dbus_get_buffer_out(HWVoiceOut *hw, size_t *size)
static size_t dbus_put_buffer_out(HWVoiceOut *hw, void *buf, size_t size)
{
DBusAudio *da = (DBusAudio *)hw->s->drv_opaque;
AudioDbus *da = AUDIO_DBUS(hw->s);
DBusVoiceOut *vo = container_of(hw, DBusVoiceOut, hw);
GHashTableIter iter;
QemuDBusDisplay1AudioOutListener *listener = NULL;
@@ -139,9 +147,9 @@ dbus_init_out_listener(QemuDBusDisplay1AudioOutListener *listener,
qemu_dbus_display1_audio_out_listener_call_init(
listener,
(uintptr_t)hw,
hw->info.bits,
hw->info.is_signed,
hw->info.is_float,
audio_format_bits(hw->info.af),
audio_format_is_signed(hw->info.af),
audio_format_is_float(hw->info.af),
hw->info.freq,
hw->info.nchannels,
hw->info.bytes_per_frame,
@@ -151,9 +159,9 @@ dbus_init_out_listener(QemuDBusDisplay1AudioOutListener *listener,
}
static guint
dbus_audio_get_nsamples(DBusAudio *da)
dbus_audio_get_nsamples(AudioDbus *da)
{
AudiodevDBusOptions *opts = &da->dev->u.dbus;
AudiodevDBusOptions *opts = &AUDIO_MIXENG_BACKEND(da)->dev->u.dbus;
if (opts->has_nsamples && opts->nsamples) {
return opts->nsamples;
@@ -163,9 +171,9 @@ dbus_audio_get_nsamples(DBusAudio *da)
}
static int
dbus_init_out(HWVoiceOut *hw, struct audsettings *as, void *drv_opaque)
dbus_init_out(HWVoiceOut *hw, struct audsettings *as)
{
DBusAudio *da = (DBusAudio *)hw->s->drv_opaque;
AudioDbus *da = AUDIO_DBUS(hw->s);
DBusVoiceOut *vo = container_of(hw, DBusVoiceOut, hw);
GHashTableIter iter;
QemuDBusDisplay1AudioOutListener *listener = NULL;
@@ -184,7 +192,7 @@ dbus_init_out(HWVoiceOut *hw, struct audsettings *as, void *drv_opaque)
static void
dbus_fini_out(HWVoiceOut *hw)
{
DBusAudio *da = (DBusAudio *)hw->s->drv_opaque;
AudioDbus *da = AUDIO_DBUS(hw->s);
DBusVoiceOut *vo = container_of(hw, DBusVoiceOut, hw);
GHashTableIter iter;
QemuDBusDisplay1AudioOutListener *listener = NULL;
@@ -203,7 +211,7 @@ dbus_fini_out(HWVoiceOut *hw)
static void
dbus_enable_out(HWVoiceOut *hw, bool enable)
{
DBusAudio *da = (DBusAudio *)hw->s->drv_opaque;
AudioDbus *da = AUDIO_DBUS(hw->s);
DBusVoiceOut *vo = container_of(hw, DBusVoiceOut, hw);
GHashTableIter iter;
QemuDBusDisplay1AudioOutListener *listener = NULL;
@@ -245,7 +253,7 @@ dbus_volume_out_listener(HWVoiceOut *hw,
static void
dbus_volume_out(HWVoiceOut *hw, Volume *vol)
{
DBusAudio *da = (DBusAudio *)hw->s->drv_opaque;
AudioDbus *da = AUDIO_DBUS(hw->s);
DBusVoiceOut *vo = container_of(hw, DBusVoiceOut, hw);
GHashTableIter iter;
QemuDBusDisplay1AudioOutListener *listener = NULL;
@@ -265,9 +273,9 @@ dbus_init_in_listener(QemuDBusDisplay1AudioInListener *listener, HWVoiceIn *hw)
qemu_dbus_display1_audio_in_listener_call_init(
listener,
(uintptr_t)hw,
hw->info.bits,
hw->info.is_signed,
hw->info.is_float,
audio_format_bits(hw->info.af),
audio_format_is_signed(hw->info.af),
audio_format_is_float(hw->info.af),
hw->info.freq,
hw->info.nchannels,
hw->info.bytes_per_frame,
@@ -277,9 +285,9 @@ dbus_init_in_listener(QemuDBusDisplay1AudioInListener *listener, HWVoiceIn *hw)
}
static int
dbus_init_in(HWVoiceIn *hw, struct audsettings *as, void *drv_opaque)
dbus_init_in(HWVoiceIn *hw, struct audsettings *as)
{
DBusAudio *da = (DBusAudio *)hw->s->drv_opaque;
AudioDbus *da = AUDIO_DBUS(hw->s);
DBusVoiceIn *vo = container_of(hw, DBusVoiceIn, hw);
GHashTableIter iter;
QemuDBusDisplay1AudioInListener *listener = NULL;
@@ -298,7 +306,7 @@ dbus_init_in(HWVoiceIn *hw, struct audsettings *as, void *drv_opaque)
static void
dbus_fini_in(HWVoiceIn *hw)
{
DBusAudio *da = (DBusAudio *)hw->s->drv_opaque;
AudioDbus *da = AUDIO_DBUS(hw->s);
GHashTableIter iter;
QemuDBusDisplay1AudioInListener *listener = NULL;
@@ -335,7 +343,7 @@ dbus_volume_in_listener(HWVoiceIn *hw,
static void
dbus_volume_in(HWVoiceIn *hw, Volume *vol)
{
DBusAudio *da = (DBusAudio *)hw->s->drv_opaque;
AudioDbus *da = AUDIO_DBUS(hw->s);
DBusVoiceIn *vo = container_of(hw, DBusVoiceIn, hw);
GHashTableIter iter;
QemuDBusDisplay1AudioInListener *listener = NULL;
@@ -352,7 +360,7 @@ dbus_volume_in(HWVoiceIn *hw, Volume *vol)
static size_t
dbus_read(HWVoiceIn *hw, void *buf, size_t size)
{
DBusAudio *da = (DBusAudio *)hw->s->drv_opaque;
AudioDbus *da = AUDIO_DBUS(hw->s);
/* DBusVoiceIn *vo = container_of(hw, DBusVoiceIn, hw); */
GHashTableIter iter;
QemuDBusDisplay1AudioInListener *listener = NULL;
@@ -387,7 +395,7 @@ dbus_read(HWVoiceIn *hw, void *buf, size_t size)
static void
dbus_enable_in(HWVoiceIn *hw, bool enable)
{
DBusAudio *da = (DBusAudio *)hw->s->drv_opaque;
AudioDbus *da = AUDIO_DBUS(hw->s);
DBusVoiceIn *vo = container_of(hw, DBusVoiceIn, hw);
GHashTableIter iter;
QemuDBusDisplay1AudioInListener *listener = NULL;
@@ -405,23 +413,31 @@ dbus_enable_in(HWVoiceIn *hw, bool enable)
}
}
static void *
dbus_audio_init(Audiodev *dev, Error **errp)
static bool
audio_dbus_realize(AudioBackend *abe, Audiodev *dev, Error **errp)
{
DBusAudio *da = g_new0(DBusAudio, 1);
AudioDbus *da = AUDIO_DBUS(abe);
if (!qemu_using_dbus_display(errp)) {
qapi_free_Audiodev(dev);
return false;
}
if (!audio_dbus_parent_class->realize(abe, dev, errp)) {
return false;
}
da->dev = dev;
da->out_listeners = g_hash_table_new_full(g_str_hash, g_str_equal,
g_free, g_object_unref);
g_free, g_object_unref);
da->in_listeners = g_hash_table_new_full(g_str_hash, g_str_equal,
g_free, g_object_unref);
return da;
g_free, g_object_unref);
return true;
}
static void
dbus_audio_fini(void *opaque)
audio_dbus_finalize(Object *obj)
{
DBusAudio *da = opaque;
AudioDbus *da = AUDIO_DBUS(obj);
if (da->server) {
g_dbus_object_manager_server_unexport(da->server,
@@ -432,14 +448,13 @@ dbus_audio_fini(void *opaque)
g_clear_pointer(&da->in_listeners, g_hash_table_unref);
g_clear_pointer(&da->out_listeners, g_hash_table_unref);
g_clear_object(&da->server);
g_free(da);
}
static void
listener_out_vanished_cb(GDBusConnection *connection,
gboolean remote_peer_vanished,
GError *error,
DBusAudio *da)
AudioDbus *da)
{
char *name = g_object_get_data(G_OBJECT(connection), "name");
@@ -450,7 +465,7 @@ static void
listener_in_vanished_cb(GDBusConnection *connection,
gboolean remote_peer_vanished,
GError *error,
DBusAudio *da)
AudioDbus *da)
{
char *name = g_object_get_data(G_OBJECT(connection), "name");
@@ -458,7 +473,7 @@ listener_in_vanished_cb(GDBusConnection *connection,
}
static gboolean
dbus_audio_register_listener(AudioBackend *s,
dbus_audio_register_listener(AudioMixengBackend *s,
GDBusMethodInvocation *invocation,
#ifdef G_OS_UNIX
GUnixFDList *fd_list,
@@ -466,7 +481,7 @@ dbus_audio_register_listener(AudioBackend *s,
GVariant *arg_listener,
bool out)
{
DBusAudio *da = s->drv_opaque;
AudioDbus *da = AUDIO_DBUS(s);
const char *sender =
da->p2p ? "p2p" : g_dbus_method_invocation_get_sender(invocation);
g_autoptr(GDBusConnection) listener_conn = NULL;
@@ -615,7 +630,7 @@ dbus_audio_register_listener(AudioBackend *s,
}
static gboolean
dbus_audio_register_out_listener(AudioBackend *s,
dbus_audio_register_out_listener(AudioMixengBackend *s,
GDBusMethodInvocation *invocation,
#ifdef G_OS_UNIX
GUnixFDList *fd_list,
@@ -631,7 +646,7 @@ dbus_audio_register_out_listener(AudioBackend *s,
}
static gboolean
dbus_audio_register_in_listener(AudioBackend *s,
dbus_audio_register_in_listener(AudioMixengBackend *s,
GDBusMethodInvocation *invocation,
#ifdef G_OS_UNIX
GUnixFDList *fd_list,
@@ -651,9 +666,8 @@ dbus_audio_set_server(AudioBackend *s,
bool p2p,
Error **errp)
{
DBusAudio *da = s->drv_opaque;
AudioDbus *da = AUDIO_DBUS(s);
g_assert(da);
g_assert(!da->server);
da->server = g_object_ref(server);
@@ -676,39 +690,47 @@ dbus_audio_set_server(AudioBackend *s,
return true;
}
static struct audio_pcm_ops dbus_pcm_ops = {
.init_out = dbus_init_out,
.fini_out = dbus_fini_out,
.write = audio_generic_write,
.get_buffer_out = dbus_get_buffer_out,
.put_buffer_out = dbus_put_buffer_out,
.enable_out = dbus_enable_out,
.volume_out = dbus_volume_out,
.init_in = dbus_init_in,
.fini_in = dbus_fini_in,
.read = dbus_read,
.run_buffer_in = audio_generic_run_buffer_in,
.enable_in = dbus_enable_in,
.volume_in = dbus_volume_in,
};
static struct audio_driver dbus_audio_driver = {
.name = "dbus",
.init = dbus_audio_init,
.fini = dbus_audio_fini,
.set_dbus_server = dbus_audio_set_server,
.pcm_ops = &dbus_pcm_ops,
.max_voices_out = INT_MAX,
.max_voices_in = INT_MAX,
.voice_size_out = sizeof(DBusVoiceOut),
.voice_size_in = sizeof(DBusVoiceIn)
};
static void register_audio_dbus(void)
static void audio_dbus_class_init(ObjectClass *klass, const void *data)
{
audio_driver_register(&dbus_audio_driver);
AudioBackendClass *b = AUDIO_BACKEND_CLASS(klass);
AudioMixengBackendClass *k = AUDIO_MIXENG_BACKEND_CLASS(klass);
audio_dbus_parent_class = AUDIO_BACKEND_CLASS(object_class_get_parent(klass));
b->realize = audio_dbus_realize;
b->set_dbus_server = dbus_audio_set_server;
k->max_voices_out = INT_MAX;
k->max_voices_in = INT_MAX;
k->voice_size_out = sizeof(DBusVoiceOut);
k->voice_size_in = sizeof(DBusVoiceIn);
k->init_out = dbus_init_out;
k->fini_out = dbus_fini_out;
k->write = audio_generic_write;
k->get_buffer_out = dbus_get_buffer_out;
k->put_buffer_out = dbus_put_buffer_out;
k->enable_out = dbus_enable_out;
k->volume_out = dbus_volume_out;
k->init_in = dbus_init_in;
k->fini_in = dbus_fini_in;
k->read = dbus_read;
k->run_buffer_in = audio_generic_run_buffer_in;
k->enable_in = dbus_enable_in;
k->volume_in = dbus_volume_in;
}
type_init(register_audio_dbus);
static const TypeInfo audio_types[] = {
{
.name = TYPE_AUDIO_DBUS,
.parent = TYPE_AUDIO_MIXENG_BACKEND,
.instance_size = sizeof(AudioDbus),
.instance_finalize = audio_dbus_finalize,
.class_init = audio_dbus_class_init,
},
};
DEFINE_TYPES(audio_types)
module_dep("ui-dbus")
module_obj(TYPE_AUDIO_DBUS)
+41 -48
View File
@@ -53,9 +53,9 @@ static int glue (dsound_unlock_, TYPE) (
{
HRESULT hr;
hr = glue (IFACE, _Unlock) (buf, p1, blen1, p2, blen2);
if (FAILED (hr)) {
dsound_logerr (hr, "Could not unlock " NAME "\n");
hr = glue(IFACE, _Unlock)(buf, p1, blen1, p2, blen2);
if (FAILED(hr)) {
dsound_logerr(hr, "Could not unlock " NAME);
return -1;
}
@@ -72,7 +72,7 @@ static int glue (dsound_lock_, TYPE) (
DWORD *blen1p,
DWORD *blen2p,
int entire,
dsound *s
AudioDsound *s
)
{
HRESULT hr;
@@ -85,35 +85,35 @@ static int glue (dsound_lock_, TYPE) (
#endif
hr = glue(IFACE, _Lock)(buf, pos, len, p1p, blen1p, p2p, blen2p, flag);
if (FAILED (hr)) {
if (FAILED(hr)) {
#ifndef DSBTYPE_IN
if (hr == DSERR_BUFFERLOST) {
if (glue (dsound_restore_, TYPE) (buf, s)) {
dsound_logerr (hr, "Could not lock " NAME "\n");
if (glue(dsound_restore_, TYPE)(buf, s)) {
dsound_logerr(hr, "Could not lock " NAME);
}
goto fail;
}
#endif
dsound_logerr (hr, "Could not lock " NAME "\n");
dsound_logerr(hr, "Could not lock " NAME);
goto fail;
}
if ((p1p && *p1p && (*blen1p % info->bytes_per_frame)) ||
(p2p && *p2p && (*blen2p % info->bytes_per_frame))) {
dolog("DirectSound returned misaligned buffer %ld %ld\n",
*blen1p, *blen2p);
error_report("dsound: returned misaligned buffer %ld %ld",
*blen1p, *blen2p);
glue(dsound_unlock_, TYPE)(buf, *p1p, p2p ? *p2p : NULL, *blen1p,
blen2p ? *blen2p : 0);
goto fail;
}
if (p1p && !*p1p && *blen1p) {
dolog("warning: !p1 && blen1=%ld\n", *blen1p);
warn_report("dsound: !p1 && blen1=%ld", *blen1p);
*blen1p = 0;
}
if (p2p && !*p2p && *blen2p) {
dolog("warning: !p2 && blen2=%ld\n", *blen2p);
warn_report("dsound: !p2 && blen2=%ld", *blen2p);
*blen2p = 0;
}
@@ -143,30 +143,28 @@ static void dsound_fini_out (HWVoiceOut *hw)
#endif
if (ds->FIELD) {
hr = glue (IFACE, _Stop) (ds->FIELD);
if (FAILED (hr)) {
dsound_logerr (hr, "Could not stop " NAME "\n");
hr = glue(IFACE, _Stop)(ds->FIELD);
if (FAILED(hr)) {
dsound_logerr(hr, "Could not stop " NAME);
}
hr = glue (IFACE, _Release) (ds->FIELD);
if (FAILED (hr)) {
dsound_logerr (hr, "Could not release " NAME "\n");
hr = glue(IFACE, _Release)(ds->FIELD);
if (FAILED(hr)) {
dsound_logerr(hr, "Could not release " NAME);
}
ds->FIELD = NULL;
}
}
#ifdef DSBTYPE_IN
static int dsound_init_in(HWVoiceIn *hw, struct audsettings *as,
void *drv_opaque)
static int dsound_init_in(HWVoiceIn *hw, struct audsettings *as)
#else
static int dsound_init_out(HWVoiceOut *hw, struct audsettings *as,
void *drv_opaque)
static int dsound_init_out(HWVoiceOut *hw, struct audsettings *as)
#endif
{
int err;
HRESULT hr;
dsound *s = drv_opaque;
AudioDsound *s = AUDIO_DSOUND(hw->s);
WAVEFORMATEX wfx;
struct audsettings obt_as;
#ifdef DSBTYPE_IN
@@ -174,17 +172,18 @@ static int dsound_init_out(HWVoiceOut *hw, struct audsettings *as,
DSoundVoiceIn *ds = (DSoundVoiceIn *) hw;
DSCBUFFERDESC bd;
DSCBCAPS bc;
AudiodevPerDirectionOptions *pdo = s->dev->u.dsound.in;
AudiodevPerDirectionOptions *pdo = hw->s->dev->u.dsound.in;
#else
const char *typ = "DAC";
DSoundVoiceOut *ds = (DSoundVoiceOut *) hw;
DSBUFFERDESC bd;
DSBCAPS bc;
AudiodevPerDirectionOptions *pdo = s->dev->u.dsound.out;
AudiodevPerDirectionOptions *pdo = hw->s->dev->u.dsound.out;
#endif
if (!s->FIELD2) {
dolog ("Attempt to initialize voice without " NAME2 " object\n");
error_report("dsound: Attempt to initialize voice without "
NAME2 " object");
return -1;
}
@@ -214,28 +213,28 @@ static int dsound_init_out(HWVoiceOut *hw, struct audsettings *as,
);
#endif
if (FAILED (hr)) {
dsound_logerr2 (hr, typ, "Could not create " NAME "\n");
if (FAILED(hr)) {
dsound_logerr2(hr, typ, "Could not create " NAME);
return -1;
}
hr = glue (IFACE, _GetFormat) (ds->FIELD, &wfx, sizeof (wfx), NULL);
if (FAILED (hr)) {
dsound_logerr2 (hr, typ, "Could not get " NAME " format\n");
hr = glue(IFACE, _GetFormat)(ds->FIELD, &wfx, sizeof(wfx), NULL);
if (FAILED(hr)) {
dsound_logerr2(hr, typ, "Could not get " NAME " format");
goto fail0;
}
#ifdef DEBUG_DSOUND
dolog (NAME "\n");
print_wave_format (&wfx);
#endif
trace_dsound_wave_format(
wfx.wFormatTag, wfx.nChannels,
wfx.nSamplesPerSec, wfx.nAvgBytesPerSec,
wfx.nBlockAlign, wfx.wBitsPerSample, wfx.cbSize);
memset (&bc, 0, sizeof (bc));
bc.dwSize = sizeof (bc);
hr = glue (IFACE, _GetCaps) (ds->FIELD, &bc);
if (FAILED (hr)) {
dsound_logerr2 (hr, typ, "Could not get " NAME " format\n");
hr = glue(IFACE, _GetCaps)(ds->FIELD, &bc);
if (FAILED(hr)) {
dsound_logerr2(hr, typ, "Could not get " NAME " caps");
goto fail0;
}
@@ -245,23 +244,17 @@ static int dsound_init_out(HWVoiceOut *hw, struct audsettings *as,
}
ds->first_time = true;
obt_as.endianness = 0;
obt_as.big_endian = false;
audio_pcm_init_info (&hw->info, &obt_as);
if (bc.dwBufferBytes % hw->info.bytes_per_frame) {
dolog (
"GetCaps returned misaligned buffer size %ld, alignment %d\n",
bc.dwBufferBytes, hw->info.bytes_per_frame
);
warn_report("dsound: GetCaps returned misaligned buffer size %ld, "
"alignment %d", bc.dwBufferBytes, hw->info.bytes_per_frame);
}
hw->size_emul = bc.dwBufferBytes;
hw->samples = bc.dwBufferBytes / hw->info.bytes_per_frame;
ds->s = s;
#ifdef DEBUG_DSOUND
dolog ("caps %ld, desc %ld\n",
bc.dwBufferBytes, bd.dwBufferBytes);
#endif
trace_dsound_buffer_bytes(bc.dwBufferBytes, bd.dwBufferBytes);
return 0;
fail0:
+125 -142
View File
@@ -28,40 +28,43 @@
#include "qemu/osdep.h"
#include "qemu/audio.h"
#define AUDIO_CAP "dsound"
#include "qemu/error-report.h"
#include "audio_int.h"
#include "qemu/module.h"
#include "qapi/error.h"
#include "qom/object.h"
#include <windows.h>
#include <mmsystem.h>
#include <objbase.h>
#include <dsound.h>
#include "trace.h"
#include "audio_win_int.h"
/* #define DEBUG_DSOUND */
#define TYPE_AUDIO_DSOUND "audio-dsound"
OBJECT_DECLARE_SIMPLE_TYPE(AudioDsound, AUDIO_DSOUND)
static AudioBackendClass *audio_dsound_parent_class;
struct AudioDsound {
AudioMixengBackend parent_obj;
typedef struct {
LPDIRECTSOUND dsound;
LPDIRECTSOUNDCAPTURE dsound_capture;
struct audsettings settings;
Audiodev *dev;
} dsound;
};
typedef struct {
HWVoiceOut hw;
LPDIRECTSOUNDBUFFER dsound_buffer;
bool first_time;
dsound *s;
} DSoundVoiceOut;
typedef struct {
HWVoiceIn hw;
LPDIRECTSOUNDCAPTUREBUFFER dsound_capture_buffer;
bool first_time;
dsound *s;
} DSoundVoiceIn;
static const char *dserror(HRESULT hr)
@@ -208,65 +211,46 @@ static void dsound_log_hresult(HRESULT hr)
const char *str = dserror(hr);
if (str) {
AUD_log (AUDIO_CAP, "Reason: %s\n", str);
error_printf(" Reason: %s", str);
} else {
AUD_log (AUDIO_CAP, "Reason: Unknown (HRESULT: 0x%lx)\n", hr);
error_printf(" Reason: Unknown (HRESULT: 0x%lx)", hr);
}
}
static void G_GNUC_PRINTF (2, 3) dsound_logerr (
HRESULT hr,
const char *fmt,
...
)
static void G_GNUC_PRINTF(2, 3) dsound_logerr(HRESULT hr, const char *fmt, ...)
{
va_list ap;
va_start (ap, fmt);
AUD_vlog (AUDIO_CAP, fmt, ap);
va_end (ap);
dsound_log_hresult (hr);
error_printf("dsound: ");
va_start(ap, fmt);
error_vprintf(fmt, ap);
va_end(ap);
dsound_log_hresult(hr);
error_printf("\n");
}
static void G_GNUC_PRINTF (3, 4) dsound_logerr2 (
HRESULT hr,
const char *typ,
const char *fmt,
...
)
static void G_GNUC_PRINTF(3, 4) dsound_logerr2(HRESULT hr, const char *typ,
const char *fmt, ...)
{
va_list ap;
AUD_log (AUDIO_CAP, "Could not initialize %s\n", typ);
va_start (ap, fmt);
AUD_vlog (AUDIO_CAP, fmt, ap);
va_end (ap);
dsound_log_hresult (hr);
error_printf("dsound: Could not initialize %s: ", typ);
va_start(ap, fmt);
error_vprintf(fmt, ap);
va_end(ap);
dsound_log_hresult(hr);
error_printf("\n");
}
#ifdef DEBUG_DSOUND
static void print_wave_format (WAVEFORMATEX *wfx)
{
dolog ("tag = %d\n", wfx->wFormatTag);
dolog ("nChannels = %d\n", wfx->nChannels);
dolog ("nSamplesPerSec = %ld\n", wfx->nSamplesPerSec);
dolog ("nAvgBytesPerSec = %ld\n", wfx->nAvgBytesPerSec);
dolog ("nBlockAlign = %d\n", wfx->nBlockAlign);
dolog ("wBitsPerSample = %d\n", wfx->wBitsPerSample);
dolog ("cbSize = %d\n", wfx->cbSize);
}
#endif
static int dsound_restore_out (LPDIRECTSOUNDBUFFER dsb, dsound *s)
static int dsound_restore_out (LPDIRECTSOUNDBUFFER dsb, AudioDsound *s)
{
HRESULT hr;
hr = IDirectSoundBuffer_Restore (dsb);
if (hr != DS_OK) {
dsound_logerr (hr, "Could not restore playback buffer\n");
dsound_logerr(hr, "Could not restore playback buffer");
return -1;
}
return 0;
@@ -278,13 +262,13 @@ static int dsound_restore_out (LPDIRECTSOUNDBUFFER dsb, dsound *s)
#undef DSBTYPE_IN
static int dsound_get_status_out (LPDIRECTSOUNDBUFFER dsb, DWORD *statusp,
dsound *s)
AudioDsound *s)
{
HRESULT hr;
hr = IDirectSoundBuffer_GetStatus (dsb, statusp);
if (FAILED (hr)) {
dsound_logerr (hr, "Could not get playback buffer status\n");
dsound_logerr(hr, "Could not get playback buffer status");
return -1;
}
@@ -303,7 +287,7 @@ static int dsound_get_status_in (LPDIRECTSOUNDCAPTUREBUFFER dscb,
hr = IDirectSoundCaptureBuffer_GetStatus (dscb, statusp);
if (FAILED (hr)) {
dsound_logerr (hr, "Could not get capture buffer status\n");
dsound_logerr(hr, "Could not get capture buffer status");
return -1;
}
@@ -311,7 +295,7 @@ static int dsound_get_status_in (LPDIRECTSOUNDCAPTUREBUFFER dscb,
}
static void dsound_clear_sample (HWVoiceOut *hw, LPDIRECTSOUNDBUFFER dsb,
dsound *s)
AudioDsound *s)
{
int err;
LPVOID p1, p2;
@@ -334,11 +318,7 @@ static void dsound_clear_sample (HWVoiceOut *hw, LPDIRECTSOUNDBUFFER dsb,
len1 = blen1 / hw->info.bytes_per_frame;
len2 = blen2 / hw->info.bytes_per_frame;
#ifdef DEBUG_DSOUND
dolog ("clear %p,%ld,%ld %p,%ld,%ld\n",
p1, blen1, len1,
p2, blen2, len2);
#endif
trace_dsound_clear_sample(p1, blen1, len1, p2, blen2, len2);
if (p1 && len1) {
audio_pcm_info_clear_buf (&hw->info, p1, len1);
@@ -355,45 +335,45 @@ static void dsound_enable_out(HWVoiceOut *hw, bool enable)
{
HRESULT hr;
DWORD status;
AudioDsound *s = AUDIO_DSOUND(hw->s);
DSoundVoiceOut *ds = (DSoundVoiceOut *) hw;
LPDIRECTSOUNDBUFFER dsb = ds->dsound_buffer;
dsound *s = ds->s;
if (!dsb) {
dolog ("Attempt to control voice without a buffer\n");
error_report("dsound: Attempt to control voice without a buffer");
return;
}
if (enable) {
if (dsound_get_status_out (dsb, &status, s)) {
if (dsound_get_status_out(dsb, &status, s)) {
return;
}
if (status & DSBSTATUS_PLAYING) {
dolog ("warning: Voice is already playing\n");
warn_report("dsound: Voice is already playing");
return;
}
dsound_clear_sample (hw, dsb, s);
dsound_clear_sample(hw, dsb, s);
hr = IDirectSoundBuffer_Play (dsb, 0, 0, DSBPLAY_LOOPING);
if (FAILED (hr)) {
dsound_logerr (hr, "Could not start playing buffer\n");
hr = IDirectSoundBuffer_Play(dsb, 0, 0, DSBPLAY_LOOPING);
if (FAILED(hr)) {
dsound_logerr(hr, "Could not start playing buffer");
return;
}
} else {
if (dsound_get_status_out (dsb, &status, s)) {
if (dsound_get_status_out(dsb, &status, s)) {
return;
}
if (status & DSBSTATUS_PLAYING) {
hr = IDirectSoundBuffer_Stop (dsb);
if (FAILED (hr)) {
dsound_logerr (hr, "Could not stop playing buffer\n");
hr = IDirectSoundBuffer_Stop(dsb);
if (FAILED(hr)) {
dsound_logerr(hr, "Could not stop playing buffer");
return;
}
} else {
dolog ("warning: Voice is not playing\n");
warn_report("dsound: Voice is not playing");
}
}
}
@@ -408,7 +388,7 @@ static size_t dsound_buffer_get_free(HWVoiceOut *hw)
hr = IDirectSoundBuffer_GetCurrentPosition(
dsb, &ppos, ds->first_time ? &wpos : NULL);
if (FAILED(hr)) {
dsound_logerr(hr, "Could not get playback buffer position\n");
dsound_logerr(hr, "Could not get playback buffer position");
return 0;
}
@@ -433,9 +413,9 @@ static void *dsound_get_buffer_out(HWVoiceOut *hw, size_t *size)
assert(req_size > 0);
err = dsound_lock_out(dsb, &hw->info, hw->pos_emul, req_size, &ret, NULL,
&act_size, NULL, false, ds->s);
&act_size, NULL, false, AUDIO_DSOUND(hw->s));
if (err) {
dolog("Failed to lock buffer\n");
error_report("dsound: Failed to lock buffer");
*size = 0;
return NULL;
}
@@ -451,7 +431,7 @@ static size_t dsound_put_buffer_out(HWVoiceOut *hw, void *buf, size_t len)
int err = dsound_unlock_out(dsb, buf, NULL, len, 0);
if (err) {
dolog("Failed to unlock buffer!!\n");
error_report("dsound: Failed to unlock buffer");
return 0;
}
hw->pos_emul = (hw->pos_emul + len) % hw->size_emul;
@@ -467,40 +447,40 @@ static void dsound_enable_in(HWVoiceIn *hw, bool enable)
LPDIRECTSOUNDCAPTUREBUFFER dscb = ds->dsound_capture_buffer;
if (!dscb) {
dolog ("Attempt to control capture voice without a buffer\n");
error_report("dsound: Attempt to control capture voice without a buffer");
return;
}
if (enable) {
if (dsound_get_status_in (dscb, &status)) {
if (dsound_get_status_in(dscb, &status)) {
return;
}
if (status & DSCBSTATUS_CAPTURING) {
dolog ("warning: Voice is already capturing\n");
warn_report("dsound: Voice is already capturing");
return;
}
/* clear ?? */
hr = IDirectSoundCaptureBuffer_Start (dscb, DSCBSTART_LOOPING);
if (FAILED (hr)) {
dsound_logerr (hr, "Could not start capturing\n");
hr = IDirectSoundCaptureBuffer_Start(dscb, DSCBSTART_LOOPING);
if (FAILED(hr)) {
dsound_logerr(hr, "Could not start capturing");
return;
}
} else {
if (dsound_get_status_in (dscb, &status)) {
if (dsound_get_status_in(dscb, &status)) {
return;
}
if (status & DSCBSTATUS_CAPTURING) {
hr = IDirectSoundCaptureBuffer_Stop (dscb);
if (FAILED (hr)) {
dsound_logerr (hr, "Could not stop capturing\n");
hr = IDirectSoundCaptureBuffer_Stop(dscb);
if (FAILED(hr)) {
dsound_logerr(hr, "Could not stop capturing");
return;
}
} else {
dolog ("warning: Voice is not capturing\n");
warn_report("dsound: Voice is not capturing");
}
}
}
@@ -517,7 +497,7 @@ static void *dsound_get_buffer_in(HWVoiceIn *hw, size_t *size)
hr = IDirectSoundCaptureBuffer_GetCurrentPosition(dscb, NULL, &rpos);
if (FAILED(hr)) {
dsound_logerr(hr, "Could not get capture buffer position\n");
dsound_logerr(hr, "Could not get capture buffer position");
*size = 0;
return NULL;
}
@@ -536,9 +516,9 @@ static void *dsound_get_buffer_in(HWVoiceIn *hw, size_t *size)
}
err = dsound_lock_in(dscb, &hw->info, hw->pos_emul, req_size, &ret, NULL,
&act_size, NULL, false, ds->s);
&act_size, NULL, false, AUDIO_DSOUND(hw->s));
if (err) {
dolog("Failed to lock buffer\n");
error_report("dsound: Failed to lock buffer");
*size = 0;
return NULL;
}
@@ -554,50 +534,51 @@ static void dsound_put_buffer_in(HWVoiceIn *hw, void *buf, size_t len)
int err = dsound_unlock_in(dscb, buf, NULL, len, 0);
if (err) {
dolog("Failed to unlock buffer!!\n");
error_report("dsound: Failed to unlock buffer");
return;
}
hw->pos_emul = (hw->pos_emul + len) % hw->size_emul;
}
static void dsound_audio_fini (void *opaque)
static void audio_dsound_finalize(Object *obj)
{
AudioDsound *s = AUDIO_DSOUND(obj);
HRESULT hr;
dsound *s = opaque;
if (!s->dsound) {
g_free(s);
return;
}
hr = IDirectSound_Release (s->dsound);
if (FAILED (hr)) {
dsound_logerr (hr, "Could not release DirectSound\n");
dsound_logerr(hr, "Could not release DirectSound");
}
s->dsound = NULL;
if (!s->dsound_capture) {
g_free(s);
return;
}
hr = IDirectSoundCapture_Release (s->dsound_capture);
if (FAILED (hr)) {
dsound_logerr (hr, "Could not release DirectSoundCapture\n");
dsound_logerr(hr, "Could not release DirectSoundCapture");
}
s->dsound_capture = NULL;
g_free(s);
}
static void *dsound_audio_init(Audiodev *dev, Error **errp)
static bool
audio_dsound_realize(AudioBackend *abe, Audiodev *dev, Error **errp)
{
AudioDsound *s = AUDIO_DSOUND(abe);
HRESULT hr;
dsound *s = g_new0(dsound, 1);
AudiodevDsoundOptions *dso;
assert(dev->driver == AUDIODEV_DRIVER_DSOUND);
s->dev = dev;
if (!audio_dsound_parent_class->realize(abe, dev, errp)) {
return false;
}
dso = &dev->u.dsound;
if (!dso->has_latency) {
@@ -608,8 +589,7 @@ static void *dsound_audio_init(Audiodev *dev, Error **errp)
hr = CoInitialize (NULL);
if (FAILED (hr)) {
dserror_set(errp, hr, "Could not initialize COM");
dsound_audio_fini(s);
return NULL;
return false;
}
hr = CoCreateInstance (
@@ -621,15 +601,13 @@ static void *dsound_audio_init(Audiodev *dev, Error **errp)
);
if (FAILED (hr)) {
dserror_set(errp, hr, "Could not create DirectSound instance");
dsound_audio_fini(s);
return NULL;
return false;
}
hr = IDirectSound_Initialize (s->dsound, NULL);
if (FAILED (hr)) {
dserror_set(errp, hr, "Could not initialize DirectSound");
dsound_audio_fini(s);
return NULL;
return false;
}
hr = CoCreateInstance (
@@ -641,15 +619,13 @@ static void *dsound_audio_init(Audiodev *dev, Error **errp)
);
if (FAILED (hr)) {
dserror_set(errp, hr, "Could not create DirectSoundCapture instance");
dsound_audio_fini(s);
return NULL;
return false;
}
hr = IDirectSoundCapture_Initialize (s->dsound_capture, NULL);
if (FAILED(hr)) {
dserror_set(errp, hr, "Could not initialize DirectSoundCapture");
dsound_audio_fini(s);
return NULL;
return false;
}
hr = IDirectSound_SetCooperativeLevel (
@@ -659,43 +635,50 @@ static void *dsound_audio_init(Audiodev *dev, Error **errp)
);
if (FAILED(hr)) {
dserror_set(errp, hr, "Could not set cooperative level");
dsound_audio_fini(s);
return NULL;
return false;
}
return s;
return true;
}
static struct audio_pcm_ops dsound_pcm_ops = {
.init_out = dsound_init_out,
.fini_out = dsound_fini_out,
.write = audio_generic_write,
.buffer_get_free = dsound_buffer_get_free,
.get_buffer_out = dsound_get_buffer_out,
.put_buffer_out = dsound_put_buffer_out,
.enable_out = dsound_enable_out,
.init_in = dsound_init_in,
.fini_in = dsound_fini_in,
.read = audio_generic_read,
.get_buffer_in = dsound_get_buffer_in,
.put_buffer_in = dsound_put_buffer_in,
.enable_in = dsound_enable_in,
};
static struct audio_driver dsound_audio_driver = {
.name = "dsound",
.init = dsound_audio_init,
.fini = dsound_audio_fini,
.pcm_ops = &dsound_pcm_ops,
.max_voices_out = INT_MAX,
.max_voices_in = 1,
.voice_size_out = sizeof (DSoundVoiceOut),
.voice_size_in = sizeof (DSoundVoiceIn)
};
static void register_audio_dsound(void)
static void audio_dsound_class_init(ObjectClass *klass, const void *data)
{
audio_driver_register(&dsound_audio_driver);
AudioBackendClass *b = AUDIO_BACKEND_CLASS(klass);
AudioMixengBackendClass *k = AUDIO_MIXENG_BACKEND_CLASS(klass);
audio_dsound_parent_class = AUDIO_BACKEND_CLASS(object_class_get_parent(klass));
b->realize = audio_dsound_realize;
k->max_voices_out = INT_MAX;
k->max_voices_in = 1;
k->voice_size_out = sizeof(DSoundVoiceOut);
k->voice_size_in = sizeof(DSoundVoiceIn);
k->init_out = dsound_init_out;
k->fini_out = dsound_fini_out;
k->write = audio_generic_write;
k->buffer_get_free = dsound_buffer_get_free;
k->get_buffer_out = dsound_get_buffer_out;
k->put_buffer_out = dsound_put_buffer_out;
k->enable_out = dsound_enable_out;
k->init_in = dsound_init_in;
k->fini_in = dsound_fini_in;
k->read = audio_generic_read;
k->get_buffer_in = dsound_get_buffer_in;
k->put_buffer_in = dsound_put_buffer_in;
k->enable_in = dsound_enable_in;
}
type_init(register_audio_dsound);
static const TypeInfo audio_types[] = {
{
.name = TYPE_AUDIO_DSOUND,
.parent = TYPE_AUDIO_MIXENG_BACKEND,
.instance_size = sizeof(AudioDsound),
.class_init = audio_dsound_class_init,
.instance_finalize = audio_dsound_finalize,
},
};
DEFINE_TYPES(audio_types)
module_obj(TYPE_AUDIO_DSOUND);
+88 -69
View File
@@ -26,14 +26,23 @@
#include "qemu/module.h"
#include "qemu/atomic.h"
#include "qemu/main-loop.h"
#include "qemu/error-report.h"
#include "qemu/audio.h"
#define AUDIO_CAP "jack"
#include "qom/object.h"
#include "audio_int.h"
#include "trace.h"
#include <jack/jack.h>
#include <jack/thread.h>
#define TYPE_AUDIO_JACK "audio-jack"
OBJECT_DECLARE_SIMPLE_TYPE(AudioJack, AUDIO_JACK)
struct AudioJack {
AudioMixengBackend parent_obj;
};
struct QJack;
typedef enum QJackState {
@@ -334,7 +343,7 @@ static void qjack_client_recover(QJackClient *c)
/* if enabled then attempt to recover */
if (c->enabled) {
dolog("attempting to reconnect to server\n");
trace_jack_client_recover();
qjack_client_init(c);
}
}
@@ -390,10 +399,10 @@ static void qjack_client_connect_ports(QJackClient *c)
}
if (c->out) {
dolog("connect %s -> %s\n", p, ports[i]);
trace_jack_connect(p, ports[i]);
jack_connect(c->client, p, ports[i]);
} else {
dolog("connect %s -> %s\n", ports[i], p);
trace_jack_connect(ports[i], p);
jack_connect(c->client, ports[i], p);
}
}
@@ -432,9 +441,9 @@ static int qjack_client_init(QJackClient *c)
c->opt->server_name);
if (c->client == NULL) {
dolog("jack_client_open failed: status = 0x%2.0x\n", status);
error_report("jack: jack_client_open failed: status = 0x%2.0x", status);
if (status & JackServerFailed) {
dolog("unable to connect to JACK server\n");
error_report("jack: unable to connect to JACK server");
}
return -1;
}
@@ -442,12 +451,11 @@ static int qjack_client_init(QJackClient *c)
c->freq = jack_get_sample_rate(c->client);
if (status & JackServerStarted) {
dolog("JACK server started\n");
trace_jack_server_started();
}
if (status & JackNameNotUnique) {
dolog("JACK unique name assigned %s\n",
jack_get_client_name(c->client));
trace_jack_unique_name(jack_get_client_name(c->client));
}
/* Allocate working buffer for process callback */
@@ -497,11 +505,10 @@ static int qjack_client_init(QJackClient *c)
return 0;
}
static int qjack_init_out(HWVoiceOut *hw, struct audsettings *as,
void *drv_opaque)
static int qjack_init_out(HWVoiceOut *hw, struct audsettings *as)
{
QJackOut *jo = (QJackOut *)hw;
Audiodev *dev = (Audiodev *)drv_opaque;
Audiodev *dev = hw->s->dev;
jo->c.out = true;
jo->c.enabled = false;
@@ -524,21 +531,19 @@ static int qjack_init_out(HWVoiceOut *hw, struct audsettings *as,
.freq = jo->c.freq,
.nchannels = jo->c.nchannels,
.fmt = AUDIO_FORMAT_F32,
.endianness = 0
.big_endian = false
};
audio_pcm_init_info(&hw->info, &os);
dolog("JACK output configured for %dHz (%d samples)\n",
jo->c.freq, jo->c.buffersize);
trace_jack_out_init(jo->c.freq, jo->c.buffersize);
return 0;
}
static int qjack_init_in(HWVoiceIn *hw, struct audsettings *as,
void *drv_opaque)
static int qjack_init_in(HWVoiceIn *hw, struct audsettings *as)
{
QJackIn *ji = (QJackIn *)hw;
Audiodev *dev = (Audiodev *)drv_opaque;
Audiodev *dev = hw->s->dev;
ji->c.out = false;
ji->c.enabled = false;
@@ -561,12 +566,11 @@ static int qjack_init_in(HWVoiceIn *hw, struct audsettings *as,
.freq = ji->c.freq,
.nchannels = ji->c.nchannels,
.fmt = AUDIO_FORMAT_F32,
.endianness = 0
.big_endian = false
};
audio_pcm_init_info(&hw->info, &is);
dolog("JACK input configured for %dHz (%d samples)\n",
ji->c.freq, ji->c.buffersize);
trace_jack_in_init(ji->c.freq, ji->c.buffersize);
return 0;
}
@@ -629,76 +633,91 @@ static void qjack_enable_in(HWVoiceIn *hw, bool enable)
ji->c.enabled = enable;
}
#if !defined(WIN32) && defined(CONFIG_PTHREAD_SETNAME_NP_W_TID)
#if !defined(WIN32)
struct QJackThreadData {
void *(*function)(void *);
void *arg;
};
static void *qjack_thread_trampoline(void *targ)
{
struct QJackThreadData *data = targ;
void *(*function)(void *) = data->function;
void *arg = data->arg;
g_free(data);
qemu_thread_set_name("jack-client");
return function(arg);
}
static int qjack_thread_creator(jack_native_thread_t *thread,
const pthread_attr_t *attr, void *(*function)(void *), void *arg)
{
int ret = pthread_create(thread, attr, function, arg);
struct QJackThreadData *data = g_new0(struct QJackThreadData, 1);
data->function = function;
data->arg = arg;
int ret = pthread_create(thread, attr, qjack_thread_trampoline, data);
if (ret != 0) {
g_free(data);
return ret;
}
/* set the name of the thread */
pthread_setname_np(*thread, "jack-client");
return ret;
}
#endif
static void *qjack_init(Audiodev *dev, Error **errp)
{
assert(dev->driver == AUDIODEV_DRIVER_JACK);
return dev;
}
static void qjack_fini(void *opaque)
{
}
static struct audio_pcm_ops jack_pcm_ops = {
.init_out = qjack_init_out,
.fini_out = qjack_fini_out,
.write = qjack_write,
.buffer_get_free = audio_generic_buffer_get_free,
.run_buffer_out = audio_generic_run_buffer_out,
.enable_out = qjack_enable_out,
.init_in = qjack_init_in,
.fini_in = qjack_fini_in,
.read = qjack_read,
.run_buffer_in = audio_generic_run_buffer_in,
.enable_in = qjack_enable_in
};
static struct audio_driver jack_driver = {
.name = "jack",
.init = qjack_init,
.fini = qjack_fini,
.pcm_ops = &jack_pcm_ops,
.max_voices_out = INT_MAX,
.max_voices_in = INT_MAX,
.voice_size_out = sizeof(QJackOut),
.voice_size_in = sizeof(QJackIn)
};
static void qjack_error(const char *msg)
{
dolog("E: %s\n", msg);
error_report("jack: %s", msg);
}
static void qjack_info(const char *msg)
{
dolog("I: %s\n", msg);
trace_jack_info(msg);
}
static void register_audio_jack(void)
static void audio_jack_class_init(ObjectClass *klass, const void *data)
{
AudioMixengBackendClass *k = AUDIO_MIXENG_BACKEND_CLASS(klass);
k->max_voices_out = INT_MAX;
k->max_voices_in = INT_MAX;
k->voice_size_out = sizeof(QJackOut);
k->voice_size_in = sizeof(QJackIn);
k->init_out = qjack_init_out;
k->fini_out = qjack_fini_out;
k->write = qjack_write;
k->buffer_get_free = audio_generic_buffer_get_free;
k->run_buffer_out = audio_generic_run_buffer_out;
k->enable_out = qjack_enable_out;
k->init_in = qjack_init_in;
k->fini_in = qjack_fini_in;
k->read = qjack_read;
k->run_buffer_in = audio_generic_run_buffer_in;
k->enable_in = qjack_enable_in;
}
static const TypeInfo audio_types[] = {
{
.name = TYPE_AUDIO_JACK,
.parent = TYPE_AUDIO_MIXENG_BACKEND,
.instance_size = sizeof(AudioJack),
.class_init = audio_jack_class_init,
},
};
static void __attribute__((__constructor__)) audio_jack_init(void)
{
qemu_mutex_init(&qjack_shutdown_lock);
audio_driver_register(&jack_driver);
#if !defined(WIN32) && defined(CONFIG_PTHREAD_SETNAME_NP_W_TID)
#if !defined(WIN32)
jack_set_thread_creator(qjack_thread_creator);
#endif
jack_set_error_function(qjack_error);
jack_set_info_function(qjack_info);
}
type_init(register_audio_jack);
DEFINE_TYPES(audio_types)
module_obj(TYPE_AUDIO_JACK);
+7 -5
View File
@@ -1,5 +1,8 @@
system_ss.add(files(
audio_ss = ss.source_set()
audio_ss.add(files(
'audio.c',
'audio-be.c',
'audio-mixeng-be.c',
'mixeng.c',
'noaudio.c',
'wavaudio.c',
@@ -8,12 +11,11 @@ system_ss.add(files(
# deprecated since v10.2, to be removed
system_ss.add(files('audio-hmp-cmds.c', 'wavcapture.c'))
system_ss.add(when: coreaudio, if_true: files('coreaudio.m'))
system_ss.add(when: dsound, if_true: files('dsoundaudio.c', 'audio_win_int.c'))
audio_modules = {}
foreach m : [
['alsa', alsa, files('alsaaudio.c')],
['coreaudio', coreaudio, files('coreaudio.m')],
['dsound', dsound, files('dsoundaudio.c', 'audio_win_int.c')],
['oss', oss, files('ossaudio.c')],
['pa', pulse, files('paaudio.c')],
['sdl', sdl, files('sdlaudio.c')],
@@ -32,7 +34,7 @@ endforeach
if dbus_display
module_ss = ss.source_set()
module_ss.add(when: [gio, pixman],
if_true: [dbus_display1, files('dbusaudio.c')])
if_true: [dbus_display1_h, files('dbusaudio.c')])
audio_modules += {'dbus': module_ss}
endif
-1
View File
@@ -26,7 +26,6 @@
#include "qemu/bswap.h"
#include "qemu/audio.h"
#define AUDIO_CAP "mixeng"
#include "audio_int.h"
#ifdef FLOAT_MIXENG
#include "qemu/error-report.h"
+39 -39
View File
@@ -25,10 +25,17 @@
#include "qemu/osdep.h"
#include "qemu/module.h"
#include "qemu/audio.h"
#include "qom/object.h"
#define AUDIO_CAP "noaudio"
#include "audio_int.h"
#define TYPE_AUDIO_NONE "audio-none"
OBJECT_DECLARE_SIMPLE_TYPE(AudioNone, AUDIO_NONE)
struct AudioNone {
AudioMixengBackend parent_obj;
};
typedef struct NoVoiceOut {
HWVoiceOut hw;
RateCtl rate;
@@ -45,7 +52,7 @@ static size_t no_write(HWVoiceOut *hw, void *buf, size_t len)
return audio_rate_get_bytes(&no->rate, &hw->info, len);
}
static int no_init_out(HWVoiceOut *hw, struct audsettings *as, void *drv_opaque)
static int no_init_out(HWVoiceOut *hw, struct audsettings *as)
{
NoVoiceOut *no = (NoVoiceOut *) hw;
@@ -69,7 +76,7 @@ static void no_enable_out(HWVoiceOut *hw, bool enable)
}
}
static int no_init_in(HWVoiceIn *hw, struct audsettings *as, void *drv_opaque)
static int no_init_in(HWVoiceIn *hw, struct audsettings *as)
{
NoVoiceIn *no = (NoVoiceIn *) hw;
@@ -102,44 +109,37 @@ static void no_enable_in(HWVoiceIn *hw, bool enable)
}
}
static void *no_audio_init(Audiodev *dev, Error **errp)
static void audio_none_class_init(ObjectClass *klass, const void *data)
{
return &no_audio_init;
AudioMixengBackendClass *k = AUDIO_MIXENG_BACKEND_CLASS(klass);
k->max_voices_out = INT_MAX;
k->max_voices_in = INT_MAX;
k->voice_size_out = sizeof(NoVoiceOut);
k->voice_size_in = sizeof(NoVoiceIn);
k->init_out = no_init_out;
k->fini_out = no_fini_out;
k->write = no_write;
k->buffer_get_free = audio_generic_buffer_get_free;
k->run_buffer_out = audio_generic_run_buffer_out;
k->enable_out = no_enable_out;
k->init_in = no_init_in;
k->fini_in = no_fini_in;
k->read = no_read;
k->run_buffer_in = audio_generic_run_buffer_in;
k->enable_in = no_enable_in;
}
static void no_audio_fini (void *opaque)
{
(void) opaque;
}
static struct audio_pcm_ops no_pcm_ops = {
.init_out = no_init_out,
.fini_out = no_fini_out,
.write = no_write,
.buffer_get_free = audio_generic_buffer_get_free,
.run_buffer_out = audio_generic_run_buffer_out,
.enable_out = no_enable_out,
.init_in = no_init_in,
.fini_in = no_fini_in,
.read = no_read,
.run_buffer_in = audio_generic_run_buffer_in,
.enable_in = no_enable_in
static const TypeInfo audio_types[] = {
{
.name = TYPE_AUDIO_NONE,
.parent = TYPE_AUDIO_MIXENG_BACKEND,
.instance_size = sizeof(AudioNone),
.class_init = audio_none_class_init,
},
};
static struct audio_driver no_audio_driver = {
.name = "none",
.init = no_audio_init,
.fini = no_audio_fini,
.pcm_ops = &no_pcm_ops,
.max_voices_out = INT_MAX,
.max_voices_in = INT_MAX,
.voice_size_out = sizeof (NoVoiceOut),
.voice_size_in = sizeof (NoVoiceIn)
};
static void register_audio_none(void)
{
audio_driver_register(&no_audio_driver);
}
type_init(register_audio_none);
DEFINE_TYPES(audio_types)
module_obj(TYPE_AUDIO_NONE);
+147 -153
View File
@@ -23,6 +23,7 @@
*/
#include "qemu/osdep.h"
#include "qapi-types-audio.h"
#include <sys/ioctl.h>
#include <sys/soundcard.h>
#include "qemu/main-loop.h"
@@ -30,10 +31,20 @@
#include "qemu/host-utils.h"
#include "qapi/error.h"
#include "qemu/audio.h"
#include "qemu/error-report.h"
#include "qom/object.h"
#include "audio_int.h"
#include "trace.h"
#define AUDIO_CAP "oss"
#include "audio_int.h"
#define TYPE_AUDIO_OSS "audio-oss"
OBJECT_DECLARE_SIMPLE_TYPE(AudioOss, AUDIO_OSS)
static AudioBackendClass *audio_oss_parent_class;
struct AudioOss {
AudioMixengBackend parent_obj;
};
#if defined OSS_GETVERSION && defined SNDCTL_DSP_POLICY
#define USE_DSP_POLICY
@@ -64,56 +75,53 @@ struct oss_params {
int fragsize;
};
static void G_GNUC_PRINTF (2, 3) oss_logerr (int err, const char *fmt, ...)
static void G_GNUC_PRINTF(2, 3) oss_logerr(int err, const char *fmt, ...)
{
va_list ap;
va_start (ap, fmt);
AUD_vlog (AUDIO_CAP, fmt, ap);
va_end (ap);
error_printf("oss: ");
va_start(ap, fmt);
error_vprintf(fmt, ap);
va_end(ap);
AUD_log (AUDIO_CAP, "Reason: %s\n", strerror (err));
error_printf(" Reason: %s\n", strerror(err));
}
static void G_GNUC_PRINTF (3, 4) oss_logerr2 (
int err,
const char *typ,
const char *fmt,
...
)
static void G_GNUC_PRINTF(3, 4) oss_logerr2(int err, const char *typ,
const char *fmt, ...)
{
va_list ap;
AUD_log (AUDIO_CAP, "Could not initialize %s\n", typ);
error_printf("oss: Could not initialize %s: ", typ);
va_start (ap, fmt);
AUD_vlog (AUDIO_CAP, fmt, ap);
va_end (ap);
va_start(ap, fmt);
error_vprintf(fmt, ap);
va_end(ap);
AUD_log (AUDIO_CAP, "Reason: %s\n", strerror (err));
error_printf(" Reason: %s\n", strerror(err));
}
static void oss_anal_close (int *fdp)
static void oss_anal_close(int *fdp)
{
int err;
qemu_set_fd_handler (*fdp, NULL, NULL, NULL);
err = close (*fdp);
qemu_set_fd_handler(*fdp, NULL, NULL, NULL);
err = close(*fdp);
if (err) {
oss_logerr (errno, "Failed to close file(fd=%d)\n", *fdp);
oss_logerr(errno, "Failed to close file(fd=%d)", *fdp);
}
*fdp = -1;
}
static void oss_helper_poll_out (void *opaque)
{
AudioBackend *s = opaque;
AudioMixengBackend *s = opaque;
audio_run(s, "oss_poll_out");
}
static void oss_helper_poll_in (void *opaque)
{
AudioBackend *s = opaque;
AudioMixengBackend *s = opaque;
audio_run(s, "oss_poll_in");
}
@@ -147,69 +155,52 @@ static int aud_to_ossfmt(AudioFormat fmt, bool big_endian)
return big_endian ? AFMT_U16_BE : AFMT_U16_LE;
default:
dolog ("Internal logic error: Bad audio format %d\n", fmt);
#ifdef DEBUG_AUDIO
abort ();
#endif
error_report("oss: Internal logic error: Bad audio format %d", fmt);
return AFMT_U8;
}
}
static int oss_to_audfmt (int ossfmt, AudioFormat *fmt, int *endianness)
static int oss_to_audfmt (int ossfmt, AudioFormat *fmt, bool *big_endian)
{
switch (ossfmt) {
case AFMT_S8:
*endianness = 0;
*big_endian = false;
*fmt = AUDIO_FORMAT_S8;
break;
case AFMT_U8:
*endianness = 0;
*big_endian = false;
*fmt = AUDIO_FORMAT_U8;
break;
case AFMT_S16_LE:
*endianness = 0;
*big_endian = false;
*fmt = AUDIO_FORMAT_S16;
break;
case AFMT_U16_LE:
*endianness = 0;
*big_endian = false;
*fmt = AUDIO_FORMAT_U16;
break;
case AFMT_S16_BE:
*endianness = 1;
*big_endian = true;
*fmt = AUDIO_FORMAT_S16;
break;
case AFMT_U16_BE:
*endianness = 1;
*big_endian = true;
*fmt = AUDIO_FORMAT_U16;
break;
default:
dolog ("Unrecognized audio format %d\n", ossfmt);
error_report("oss: Unrecognized audio format %d", ossfmt);
return -1;
}
return 0;
}
#if defined DEBUG_MISMATCHES || defined DEBUG
static void oss_dump_info (struct oss_params *req, struct oss_params *obt)
{
dolog ("parameter | requested value | obtained value\n");
dolog ("format | %10d | %10d\n", req->fmt, obt->fmt);
dolog ("channels | %10d | %10d\n",
req->nchannels, obt->nchannels);
dolog ("frequency | %10d | %10d\n", req->freq, obt->freq);
dolog ("nfrags | %10d | %10d\n", req->nfrags, obt->nfrags);
dolog ("fragsize | %10d | %10d\n",
req->fragsize, obt->fragsize);
}
#endif
#ifdef USE_DSP_POLICY
static int oss_get_version (int fd, int *version, const char *typ)
{
@@ -228,7 +219,7 @@ static int oss_get_version (int fd, int *version, const char *typ)
return 0;
}
#endif
oss_logerr2 (errno, typ, "Failed to get OSS version\n");
oss_logerr2(errno, typ, "Failed to get OSS version");
return -1;
}
return 0;
@@ -257,7 +248,7 @@ static int oss_open(int in, struct oss_params *req, audsettings *as,
fd = open (dspname, oflags | O_NONBLOCK);
if (-1 == fd) {
oss_logerr2 (errno, typ, "Failed to open `%s'\n", dspname);
oss_logerr2(errno, typ, "Failed to open '%s'", dspname);
return -1;
}
@@ -269,23 +260,23 @@ static int oss_open(int in, struct oss_params *req, audsettings *as,
qapi_AudiodevOssPerDirectionOptions_base(opdo), as, 23220);
if (ioctl (fd, SNDCTL_DSP_SAMPLESIZE, &fmt)) {
oss_logerr2 (errno, typ, "Failed to set sample size %d\n", req->fmt);
oss_logerr2(errno, typ, "Failed to set sample size %d", req->fmt);
goto err;
}
if (ioctl (fd, SNDCTL_DSP_CHANNELS, &nchannels)) {
oss_logerr2 (errno, typ, "Failed to set number of channels %d\n",
req->nchannels);
oss_logerr2(errno, typ, "Failed to set number of channels %d",
req->nchannels);
goto err;
}
if (ioctl (fd, SNDCTL_DSP_SPEED, &freq)) {
oss_logerr2 (errno, typ, "Failed to set frequency %d\n", req->freq);
oss_logerr2(errno, typ, "Failed to set frequency %d", req->freq);
goto err;
}
if (ioctl (fd, SNDCTL_DSP_NONBLOCK, NULL)) {
oss_logerr2 (errno, typ, "Failed to set non-blocking mode\n");
oss_logerr2(errno, typ, "Failed to set non-blocking mode");
goto err;
}
@@ -299,9 +290,9 @@ static int oss_open(int in, struct oss_params *req, audsettings *as,
if (version >= 0x040000) {
int policy2 = policy;
if (ioctl(fd, SNDCTL_DSP_POLICY, &policy2)) {
oss_logerr2 (errno, typ,
"Failed to set timing policy to %d\n",
policy);
oss_logerr2(errno, typ,
"Failed to set timing policy to %d",
policy);
goto err;
}
setfragment = 0;
@@ -313,20 +304,20 @@ static int oss_open(int in, struct oss_params *req, audsettings *as,
if (setfragment) {
int mmmmssss = (req->nfrags << 16) | ctz32 (req->fragsize);
if (ioctl (fd, SNDCTL_DSP_SETFRAGMENT, &mmmmssss)) {
oss_logerr2 (errno, typ, "Failed to set buffer length (%d, %d)\n",
req->nfrags, req->fragsize);
oss_logerr2(errno, typ, "Failed to set buffer length (%d, %d)",
req->nfrags, req->fragsize);
goto err;
}
}
if (ioctl (fd, in ? SNDCTL_DSP_GETISPACE : SNDCTL_DSP_GETOSPACE, &abinfo)) {
oss_logerr2 (errno, typ, "Failed to get buffer length\n");
oss_logerr2(errno, typ, "Failed to get buffer length");
goto err;
}
if (!abinfo.fragstotal || !abinfo.fragsize) {
AUD_log (AUDIO_CAP, "Returned bogus buffer information(%d, %d) for %s\n",
abinfo.fragstotal, abinfo.fragsize, typ);
error_report("oss: Returned bogus buffer information(%d, %d) for %s",
abinfo.fragstotal, abinfo.fragsize, typ);
goto err;
}
@@ -337,20 +328,13 @@ static int oss_open(int in, struct oss_params *req, audsettings *as,
obt->fragsize = abinfo.fragsize;
*pfd = fd;
#ifdef DEBUG_MISMATCHES
if ((req->fmt != obt->fmt) ||
(req->nchannels != obt->nchannels) ||
(req->freq != obt->freq) ||
(req->fragsize != obt->fragsize) ||
(req->nfrags != obt->nfrags)) {
dolog ("Audio parameters mismatch\n");
oss_dump_info (req, obt);
}
#endif
trace_oss_out_params(
req->fmt, obt->fmt,
req->nchannels, obt->nchannels,
req->freq, obt->freq,
req->nfrags, obt->nfrags,
req->fragsize, obt->fragsize);
#ifdef DEBUG
oss_dump_info (req, obt);
#endif
return 0;
err:
@@ -366,7 +350,7 @@ static size_t oss_get_available_bytes(OSSVoiceOut *oss)
err = ioctl(oss->fd, SNDCTL_DSP_GETOPTR, &cntinfo);
if (err < 0) {
oss_logerr(errno, "SNDCTL_DSP_GETOPTR failed\n");
oss_logerr(errno, "SNDCTL_DSP_GETOPTR failed");
return 0;
}
@@ -447,8 +431,7 @@ static size_t oss_write(HWVoiceOut *hw, void *buf, size_t len)
bytes_written = write(oss->fd, pcm, len);
if (bytes_written < 0) {
if (errno != EAGAIN) {
oss_logerr(errno, "failed to write %zu bytes\n",
len);
oss_logerr(errno, "failed to write %zu bytes", len);
}
return pos;
}
@@ -462,38 +445,37 @@ static size_t oss_write(HWVoiceOut *hw, void *buf, size_t len)
return pos;
}
static void oss_fini_out (HWVoiceOut *hw)
static void oss_fini_out(HWVoiceOut *hw)
{
int err;
OSSVoiceOut *oss = (OSSVoiceOut *) hw;
OSSVoiceOut *oss = (OSSVoiceOut *)hw;
ldebug ("oss_fini\n");
oss_anal_close (&oss->fd);
trace_oss_fini_out();
oss_anal_close(&oss->fd);
if (oss->mmapped && hw->buf_emul) {
err = munmap(hw->buf_emul, hw->size_emul);
if (err) {
oss_logerr(errno, "Failed to unmap buffer %p, size %zu\n",
oss_logerr(errno, "Failed to unmap buffer %p, size %zu",
hw->buf_emul, hw->size_emul);
}
hw->buf_emul = NULL;
}
}
static int oss_init_out(HWVoiceOut *hw, struct audsettings *as,
void *drv_opaque)
static int oss_init_out(HWVoiceOut *hw, struct audsettings *as)
{
OSSVoiceOut *oss = (OSSVoiceOut *) hw;
struct oss_params req, obt;
int err;
int fd;
struct audsettings obt_as;
Audiodev *dev = drv_opaque;
Audiodev *dev = hw->s->dev;
AudiodevOssOptions *oopts = &dev->u.oss;
oss->fd = -1;
req.fmt = aud_to_ossfmt (as->fmt, as->endianness);
req.fmt = aud_to_ossfmt (as->fmt, as->big_endian);
req.freq = as->freq;
req.nchannels = as->nchannels;
@@ -501,7 +483,7 @@ static int oss_init_out(HWVoiceOut *hw, struct audsettings *as,
return -1;
}
err = oss_to_audfmt(obt.fmt, &obt_as.fmt, &obt_as.endianness);
err = oss_to_audfmt(obt.fmt, &obt_as.fmt, &obt_as.big_endian);
if (err) {
oss_anal_close (&fd);
return -1;
@@ -515,8 +497,8 @@ static int oss_init_out(HWVoiceOut *hw, struct audsettings *as,
oss->fragsize = obt.fragsize;
if (obt.nfrags * obt.fragsize % hw->info.bytes_per_frame) {
dolog ("warning: Misaligned DAC buffer, size %d, alignment %d\n",
obt.nfrags * obt.fragsize, hw->info.bytes_per_frame);
warn_report("oss: Misaligned DAC buffer, size %d, alignment %d",
obt.nfrags * obt.fragsize, hw->info.bytes_per_frame);
}
hw->samples = (obt.nfrags * obt.fragsize) / hw->info.bytes_per_frame;
@@ -533,20 +515,16 @@ static int oss_init_out(HWVoiceOut *hw, struct audsettings *as,
0
);
if (hw->buf_emul == MAP_FAILED) {
oss_logerr(errno, "Failed to map %zu bytes of DAC\n",
hw->size_emul);
oss_logerr(errno, "Failed to map %zu bytes of DAC", hw->size_emul);
hw->buf_emul = NULL;
} else {
int trig = 0;
if (ioctl (fd, SNDCTL_DSP_SETTRIGGER, &trig) < 0) {
oss_logerr (errno, "SNDCTL_DSP_SETTRIGGER 0 failed\n");
oss_logerr(errno, "SNDCTL_DSP_SETTRIGGER 0 failed");
} else {
trig = PCM_ENABLE_OUTPUT;
if (ioctl (fd, SNDCTL_DSP_SETTRIGGER, &trig) < 0) {
oss_logerr (
errno,
"SNDCTL_DSP_SETTRIGGER PCM_ENABLE_OUTPUT failed\n"
);
if (ioctl(fd, SNDCTL_DSP_SETTRIGGER, &trig) < 0) {
oss_logerr(errno, "SNDCTL_DSP_SETTRIGGER PCM_ENABLE_OUTPUT failed");
} else {
oss->mmapped = 1;
}
@@ -555,7 +533,7 @@ static int oss_init_out(HWVoiceOut *hw, struct audsettings *as,
if (!oss->mmapped) {
err = munmap(hw->buf_emul, hw->size_emul);
if (err) {
oss_logerr(errno, "Failed to unmap buffer %p size %zu\n",
oss_logerr(errno, "Failed to unmap buffer %p size %zu",
hw->buf_emul, hw->size_emul);
}
hw->buf_emul = NULL;
@@ -571,13 +549,14 @@ static int oss_init_out(HWVoiceOut *hw, struct audsettings *as,
static void oss_enable_out(HWVoiceOut *hw, bool enable)
{
int trig;
OSSVoiceOut *oss = (OSSVoiceOut *) hw;
OSSVoiceOut *oss = (OSSVoiceOut *)hw;
AudiodevOssPerDirectionOptions *opdo = oss->dev->u.oss.out;
trace_oss_enable_out(enable);
if (enable) {
hw->poll_mode = opdo->try_poll;
ldebug("enabling voice\n");
if (hw->poll_mode) {
oss_poll_out(hw);
}
@@ -590,12 +569,12 @@ static void oss_enable_out(HWVoiceOut *hw, bool enable)
trig = PCM_ENABLE_OUTPUT;
if (ioctl(oss->fd, SNDCTL_DSP_SETTRIGGER, &trig) < 0) {
oss_logerr(errno,
"SNDCTL_DSP_SETTRIGGER PCM_ENABLE_OUTPUT failed\n");
"SNDCTL_DSP_SETTRIGGER PCM_ENABLE_OUTPUT failed");
return;
}
} else {
if (hw->poll_mode) {
qemu_set_fd_handler (oss->fd, NULL, NULL, NULL);
qemu_set_fd_handler(oss->fd, NULL, NULL, NULL);
hw->poll_mode = 0;
}
@@ -603,34 +582,33 @@ static void oss_enable_out(HWVoiceOut *hw, bool enable)
return;
}
ldebug ("disabling voice\n");
trig = 0;
if (ioctl (oss->fd, SNDCTL_DSP_SETTRIGGER, &trig) < 0) {
oss_logerr (errno, "SNDCTL_DSP_SETTRIGGER 0 failed\n");
if (ioctl(oss->fd, SNDCTL_DSP_SETTRIGGER, &trig) < 0) {
oss_logerr(errno, "SNDCTL_DSP_SETTRIGGER 0 failed");
return;
}
}
}
static int oss_init_in(HWVoiceIn *hw, struct audsettings *as, void *drv_opaque)
static int oss_init_in(HWVoiceIn *hw, struct audsettings *as)
{
OSSVoiceIn *oss = (OSSVoiceIn *) hw;
struct oss_params req, obt;
int err;
int fd;
struct audsettings obt_as;
Audiodev *dev = drv_opaque;
Audiodev *dev = hw->s->dev;
oss->fd = -1;
req.fmt = aud_to_ossfmt (as->fmt, as->endianness);
req.fmt = aud_to_ossfmt (as->fmt, as->big_endian);
req.freq = as->freq;
req.nchannels = as->nchannels;
if (oss_open(1, &req, as, &obt, &fd, dev)) {
return -1;
}
err = oss_to_audfmt(obt.fmt, &obt_as.fmt, &obt_as.endianness);
err = oss_to_audfmt(obt.fmt, &obt_as.fmt, &obt_as.big_endian);
if (err) {
oss_anal_close (&fd);
return -1;
@@ -643,9 +621,16 @@ static int oss_init_in(HWVoiceIn *hw, struct audsettings *as, void *drv_opaque)
oss->nfrags = obt.nfrags;
oss->fragsize = obt.fragsize;
trace_oss_in_params(
req.fmt, obt.fmt,
req.nchannels, obt.nchannels,
req.freq, obt.freq,
req.nfrags, obt.nfrags,
req.fragsize, obt.fragsize);
if (obt.nfrags * obt.fragsize % hw->info.bytes_per_frame) {
dolog ("warning: Misaligned ADC buffer, size %d, alignment %d\n",
obt.nfrags * obt.fragsize, hw->info.bytes_per_frame);
warn_report("oss: Misaligned ADC buffer, size %d, alignment %d",
obt.nfrags * obt.fragsize, hw->info.bytes_per_frame);
}
hw->samples = (obt.nfrags * obt.fragsize) / hw->info.bytes_per_frame;
@@ -679,7 +664,7 @@ static size_t oss_read(HWVoiceIn *hw, void *buf, size_t len)
case EAGAIN:
break;
default:
oss_logerr(errno, "Failed to read %zu bytes of audio (to %p)\n",
oss_logerr(errno, "Failed to read %zu bytes of audio (to %p)",
len, dst);
break;
}
@@ -695,9 +680,11 @@ static size_t oss_read(HWVoiceIn *hw, void *buf, size_t len)
static void oss_enable_in(HWVoiceIn *hw, bool enable)
{
OSSVoiceIn *oss = (OSSVoiceIn *) hw;
OSSVoiceIn *oss = (OSSVoiceIn *)hw;
AudiodevOssPerDirectionOptions *opdo = oss->dev->u.oss.out;
trace_oss_enable_in(enable);
if (enable) {
hw->poll_mode = opdo->try_poll;
@@ -720,7 +707,8 @@ static void oss_init_per_direction(AudiodevOssPerDirectionOptions *opdo)
}
}
static void *oss_audio_init(Audiodev *dev, Error **errp)
static bool
audio_oss_realize(AudioBackend *abe, Audiodev *dev, Error **errp)
{
AudiodevOssOptions *oopts;
assert(dev->driver == AUDIODEV_DRIVER_OSS);
@@ -731,49 +719,55 @@ static void *oss_audio_init(Audiodev *dev, Error **errp)
if (access(oopts->in->dev ?: "/dev/dsp", R_OK | W_OK) < 0) {
error_setg_errno(errp, errno, "%s not accessible", oopts->in->dev ?: "/dev/dsp");
return NULL;
qapi_free_Audiodev(dev);
return false;
}
if (access(oopts->out->dev ?: "/dev/dsp", R_OK | W_OK) < 0) {
error_setg_errno(errp, errno, "%s not accessible", oopts->out->dev ?: "/dev/dsp");
return NULL;
qapi_free_Audiodev(dev);
return false;
}
return dev;
return audio_oss_parent_class->realize(abe, dev, errp);
}
static void oss_audio_fini (void *opaque)
static void audio_oss_class_init(ObjectClass *klass, const void *data)
{
AudioBackendClass *b = AUDIO_BACKEND_CLASS(klass);
AudioMixengBackendClass *k = AUDIO_MIXENG_BACKEND_CLASS(klass);
audio_oss_parent_class = AUDIO_BACKEND_CLASS(object_class_get_parent(klass));
b->realize = audio_oss_realize;
k->max_voices_out = INT_MAX;
k->max_voices_in = INT_MAX;
k->voice_size_out = sizeof(OSSVoiceOut);
k->voice_size_in = sizeof(OSSVoiceIn);
k->init_out = oss_init_out;
k->fini_out = oss_fini_out;
k->write = oss_write;
k->buffer_get_free = oss_buffer_get_free;
k->run_buffer_out = oss_run_buffer_out;
k->get_buffer_out = oss_get_buffer_out;
k->put_buffer_out = oss_put_buffer_out;
k->enable_out = oss_enable_out;
k->init_in = oss_init_in;
k->fini_in = oss_fini_in;
k->read = oss_read;
k->run_buffer_in = audio_generic_run_buffer_in;
k->enable_in = oss_enable_in;
}
static struct audio_pcm_ops oss_pcm_ops = {
.init_out = oss_init_out,
.fini_out = oss_fini_out,
.write = oss_write,
.buffer_get_free = oss_buffer_get_free,
.run_buffer_out = oss_run_buffer_out,
.get_buffer_out = oss_get_buffer_out,
.put_buffer_out = oss_put_buffer_out,
.enable_out = oss_enable_out,
.init_in = oss_init_in,
.fini_in = oss_fini_in,
.read = oss_read,
.run_buffer_in = audio_generic_run_buffer_in,
.enable_in = oss_enable_in
static const TypeInfo audio_types[] = {
{
.name = TYPE_AUDIO_OSS,
.parent = TYPE_AUDIO_MIXENG_BACKEND,
.instance_size = sizeof(AudioOss),
.class_init = audio_oss_class_init,
},
};
static struct audio_driver oss_audio_driver = {
.name = "oss",
.init = oss_audio_init,
.fini = oss_audio_fini,
.pcm_ops = &oss_pcm_ops,
.max_voices_out = INT_MAX,
.max_voices_in = INT_MAX,
.voice_size_out = sizeof (OSSVoiceOut),
.voice_size_in = sizeof (OSSVoiceIn)
};
static void register_audio_oss(void)
{
audio_driver_register(&oss_audio_driver);
}
type_init(register_audio_oss);
DEFINE_TYPES(audio_types)
module_obj(TYPE_AUDIO_OSS);
+142 -149
View File
@@ -3,12 +3,18 @@
#include "qemu/osdep.h"
#include "qemu/module.h"
#include "qemu/audio.h"
#include "qemu/error-report.h"
#include "qapi/error.h"
#include "qom/object.h"
#include "audio_int.h"
#include <pulse/pulseaudio.h>
#define AUDIO_CAP "pulseaudio"
#include "audio_int.h"
#define TYPE_AUDIO_PA "audio-pa"
OBJECT_DECLARE_SIMPLE_TYPE(AudioPa, AUDIO_PA)
static AudioBackendClass *audio_pa_parent_class;
typedef struct PAConnection {
char *server;
@@ -19,18 +25,19 @@ typedef struct PAConnection {
pa_context *context;
} PAConnection;
struct AudioPa {
AudioMixengBackend parent_obj;
PAConnection *conn;
};
static QTAILQ_HEAD(PAConnectionHead, PAConnection) pa_conns =
QTAILQ_HEAD_INITIALIZER(pa_conns);
typedef struct {
Audiodev *dev;
PAConnection *conn;
} paaudio;
typedef struct {
HWVoiceOut hw;
pa_stream *stream;
paaudio *g;
AudioPa *g;
} PAVoiceOut;
typedef struct {
@@ -38,42 +45,23 @@ typedef struct {
pa_stream *stream;
const void *read_data;
size_t read_length;
paaudio *g;
AudioPa *g;
} PAVoiceIn;
static void qpa_conn_fini(PAConnection *c);
static void G_GNUC_PRINTF (2, 3) qpa_logerr (int err, const char *fmt, ...)
static void G_GNUC_PRINTF(2, 3) qpa_logerr(int err, const char *fmt, ...)
{
va_list ap;
va_start (ap, fmt);
AUD_vlog (AUDIO_CAP, fmt, ap);
va_end (ap);
error_printf("pulseaudio: ");
va_start(ap, fmt);
error_vprintf(fmt, ap);
va_end(ap);
AUD_log (AUDIO_CAP, "Reason: %s\n", pa_strerror (err));
error_printf(" Reason: %s\n", pa_strerror(err));
}
#ifndef PA_CONTEXT_IS_GOOD
static inline int PA_CONTEXT_IS_GOOD(pa_context_state_t x)
{
return
x == PA_CONTEXT_CONNECTING ||
x == PA_CONTEXT_AUTHORIZING ||
x == PA_CONTEXT_SETTING_NAME ||
x == PA_CONTEXT_READY;
}
#endif
#ifndef PA_STREAM_IS_GOOD
static inline int PA_STREAM_IS_GOOD(pa_stream_state_t x)
{
return
x == PA_STREAM_CREATING ||
x == PA_STREAM_READY;
}
#endif
#define CHECK_SUCCESS_GOTO(c, expression, label, msg) \
do { \
if (!(expression)) { \
@@ -105,12 +93,12 @@ static void *qpa_get_buffer_in(HWVoiceIn *hw, size_t *size)
pa_threaded_mainloop_lock(c->mainloop);
CHECK_DEAD_GOTO(c, p->stream, unlock_and_fail,
"pa_threaded_mainloop_lock failed\n");
"pa_threaded_mainloop_lock failed");
if (!p->read_length) {
r = pa_stream_peek(p->stream, &p->read_data, &p->read_length);
CHECK_SUCCESS_GOTO(c, r == 0, unlock_and_fail,
"pa_stream_peek failed\n");
"pa_stream_peek failed");
}
*size = MIN(p->read_length, *size);
@@ -133,7 +121,7 @@ static void qpa_put_buffer_in(HWVoiceIn *hw, void *buf, size_t size)
pa_threaded_mainloop_lock(c->mainloop);
CHECK_DEAD_GOTO(c, p->stream, unlock,
"pa_threaded_mainloop_lock failed\n");
"pa_threaded_mainloop_lock failed");
assert(buf == p->read_data && size <= p->read_length);
@@ -142,7 +130,7 @@ static void qpa_put_buffer_in(HWVoiceIn *hw, void *buf, size_t size)
if (size && !p->read_length) {
r = pa_stream_drop(p->stream);
CHECK_SUCCESS_GOTO(c, r == 0, unlock, "pa_stream_drop failed\n");
CHECK_SUCCESS_GOTO(c, r == 0, unlock, "pa_stream_drop failed");
}
unlock:
@@ -158,7 +146,7 @@ static size_t qpa_read(HWVoiceIn *hw, void *data, size_t length)
pa_threaded_mainloop_lock(c->mainloop);
CHECK_DEAD_GOTO(c, p->stream, unlock_and_fail,
"pa_threaded_mainloop_lock failed\n");
"pa_threaded_mainloop_lock failed");
if (pa_stream_get_state(p->stream) != PA_STREAM_READY) {
/* wait for stream to become ready */
goto unlock;
@@ -171,7 +159,7 @@ static size_t qpa_read(HWVoiceIn *hw, void *data, size_t length)
if (!p->read_length) {
r = pa_stream_peek(p->stream, &p->read_data, &p->read_length);
CHECK_SUCCESS_GOTO(c, r == 0, unlock_and_fail,
"pa_stream_peek failed\n");
"pa_stream_peek failed");
if (!p->read_length) {
/* buffer is empty */
break;
@@ -188,7 +176,7 @@ static size_t qpa_read(HWVoiceIn *hw, void *data, size_t length)
if (!p->read_length) {
r = pa_stream_drop(p->stream);
CHECK_SUCCESS_GOTO(c, r == 0, unlock_and_fail,
"pa_stream_drop failed\n");
"pa_stream_drop failed");
}
}
@@ -210,7 +198,7 @@ static size_t qpa_buffer_get_free(HWVoiceOut *hw)
pa_threaded_mainloop_lock(c->mainloop);
CHECK_DEAD_GOTO(c, p->stream, unlock_and_fail,
"pa_threaded_mainloop_lock failed\n");
"pa_threaded_mainloop_lock failed");
if (pa_stream_get_state(p->stream) != PA_STREAM_READY) {
/* wait for stream to become ready */
l = 0;
@@ -219,7 +207,7 @@ static size_t qpa_buffer_get_free(HWVoiceOut *hw)
l = pa_stream_writable_size(p->stream);
CHECK_SUCCESS_GOTO(c, l != (size_t) -1, unlock_and_fail,
"pa_stream_writable_size failed\n");
"pa_stream_writable_size failed");
unlock:
pa_threaded_mainloop_unlock(c->mainloop);
@@ -240,12 +228,12 @@ static void *qpa_get_buffer_out(HWVoiceOut *hw, size_t *size)
pa_threaded_mainloop_lock(c->mainloop);
CHECK_DEAD_GOTO(c, p->stream, unlock_and_fail,
"pa_threaded_mainloop_lock failed\n");
"pa_threaded_mainloop_lock failed");
*size = -1;
r = pa_stream_begin_write(p->stream, &ret, size);
CHECK_SUCCESS_GOTO(c, r >= 0, unlock_and_fail,
"pa_stream_begin_write failed\n");
"pa_stream_begin_write failed");
pa_threaded_mainloop_unlock(c->mainloop);
return ret;
@@ -265,10 +253,10 @@ static size_t qpa_put_buffer_out(HWVoiceOut *hw, void *data, size_t length)
pa_threaded_mainloop_lock(c->mainloop);
CHECK_DEAD_GOTO(c, p->stream, unlock_and_fail,
"pa_threaded_mainloop_lock failed\n");
"pa_threaded_mainloop_lock failed");
r = pa_stream_write(p->stream, data, length, NULL, 0LL, PA_SEEK_RELATIVE);
CHECK_SUCCESS_GOTO(c, r >= 0, unlock_and_fail, "pa_stream_write failed\n");
CHECK_SUCCESS_GOTO(c, r >= 0, unlock_and_fail, "pa_stream_write failed");
pa_threaded_mainloop_unlock(c->mainloop);
return length;
@@ -288,7 +276,7 @@ static size_t qpa_write(HWVoiceOut *hw, void *data, size_t length)
pa_threaded_mainloop_lock(c->mainloop);
CHECK_DEAD_GOTO(c, p->stream, unlock_and_fail,
"pa_threaded_mainloop_lock failed\n");
"pa_threaded_mainloop_lock failed");
if (pa_stream_get_state(p->stream) != PA_STREAM_READY) {
/* wait for stream to become ready */
l = 0;
@@ -298,14 +286,14 @@ static size_t qpa_write(HWVoiceOut *hw, void *data, size_t length)
l = pa_stream_writable_size(p->stream);
CHECK_SUCCESS_GOTO(c, l != (size_t) -1, unlock_and_fail,
"pa_stream_writable_size failed\n");
"pa_stream_writable_size failed");
if (l > length) {
l = length;
}
r = pa_stream_write(p->stream, data, l, NULL, 0LL, PA_SEEK_RELATIVE);
CHECK_SUCCESS_GOTO(c, r >= 0, unlock_and_fail, "pa_stream_write failed\n");
CHECK_SUCCESS_GOTO(c, r >= 0, unlock_and_fail, "pa_stream_write failed");
unlock:
pa_threaded_mainloop_unlock(c->mainloop);
@@ -337,43 +325,43 @@ static pa_sample_format_t audfmt_to_pa(AudioFormat afmt, bool big_endian)
format = big_endian ? PA_SAMPLE_FLOAT32BE : PA_SAMPLE_FLOAT32LE;
break;
default:
dolog ("Internal logic error: Bad audio format %d\n", afmt);
error_report("pulseaudio: Internal logic error: Bad audio format %d", afmt);
format = PA_SAMPLE_U8;
break;
}
return format;
}
static AudioFormat pa_to_audfmt (pa_sample_format_t fmt, int *endianness)
static AudioFormat pa_to_audfmt (pa_sample_format_t fmt, bool *big_endian)
{
switch (fmt) {
case PA_SAMPLE_U8:
return AUDIO_FORMAT_U8;
case PA_SAMPLE_S16BE:
*endianness = 1;
*big_endian = true;
return AUDIO_FORMAT_S16;
case PA_SAMPLE_S16LE:
*endianness = 0;
*big_endian = false;
return AUDIO_FORMAT_S16;
case PA_SAMPLE_S32BE:
*endianness = 1;
*big_endian = true;
return AUDIO_FORMAT_S32;
case PA_SAMPLE_S32LE:
*endianness = 0;
*big_endian = false;
return AUDIO_FORMAT_S32;
case PA_SAMPLE_FLOAT32BE:
*endianness = 1;
*big_endian = true;
return AUDIO_FORMAT_F32;
case PA_SAMPLE_FLOAT32LE:
*endianness = 0;
*big_endian = false;
return AUDIO_FORMAT_F32;
default:
dolog ("Internal logic error: Bad pa_sample_format %d\n", fmt);
error_report("pulseaudio: Internal logic error: Bad pa_sample_format %d", fmt);
return AUDIO_FORMAT_U8;
}
}
static void context_state_cb (pa_context *c, void *userdata)
static void context_state_cb(pa_context *c, void *userdata)
{
PAConnection *conn = userdata;
@@ -465,7 +453,7 @@ static pa_stream *qpa_simple_new (
break;
default:
dolog("Internal error: unsupported channel count %d\n", ss->channels);
error_report("pulseaudio: unsupported channel count %d", ss->channels);
goto fail;
}
@@ -509,34 +497,35 @@ fail:
return NULL;
}
static int qpa_init_out(HWVoiceOut *hw, struct audsettings *as,
void *drv_opaque)
static int qpa_init_out(HWVoiceOut *hw, struct audsettings *as)
{
AudioMixengBackend *amb = hw->s;
AudioPa *apa = AUDIO_PA(amb);
int error;
pa_sample_spec ss;
pa_buffer_attr ba;
struct audsettings obt_as = *as;
PAVoiceOut *pa = (PAVoiceOut *) hw;
paaudio *g = pa->g = drv_opaque;
AudiodevPaOptions *popts = &g->dev->u.pa;
AudiodevPaOptions *popts = &amb->dev->u.pa;
AudiodevPaPerDirectionOptions *ppdo = popts->out;
PAConnection *c = g->conn;
PAConnection *c = apa->conn;
ss.format = audfmt_to_pa (as->fmt, as->endianness);
pa->g = apa;
ss.format = audfmt_to_pa (as->fmt, as->big_endian);
ss.channels = as->nchannels;
ss.rate = as->freq;
ba.tlength = pa_usec_to_bytes(ppdo->latency, &ss);
ba.minreq = pa_usec_to_bytes(MIN(ppdo->latency >> 2,
(g->dev->timer_period >> 2) * 3), &ss);
(amb->dev->timer_period >> 2) * 3), &ss);
ba.maxlength = -1;
ba.prebuf = -1;
obt_as.fmt = pa_to_audfmt (ss.format, &obt_as.endianness);
obt_as.fmt = pa_to_audfmt (ss.format, &obt_as.big_endian);
pa->stream = qpa_simple_new (
c,
ppdo->stream_name ?: g->dev->id,
ppdo->stream_name ?: amb->dev->id,
PA_STREAM_PLAYBACK,
ppdo->name,
&ss,
@@ -544,7 +533,7 @@ static int qpa_init_out(HWVoiceOut *hw, struct audsettings *as,
&error
);
if (!pa->stream) {
qpa_logerr (error, "pa_simple_new for playback failed\n");
qpa_logerr(error, "pa_simple_new for playback failed");
goto fail1;
}
@@ -559,33 +548,35 @@ static int qpa_init_out(HWVoiceOut *hw, struct audsettings *as,
return -1;
}
static int qpa_init_in(HWVoiceIn *hw, struct audsettings *as, void *drv_opaque)
static int qpa_init_in(HWVoiceIn *hw, struct audsettings *as)
{
AudioMixengBackend *amb = hw->s;
AudioPa *apa = AUDIO_PA(amb);
int error;
pa_sample_spec ss;
pa_buffer_attr ba;
struct audsettings obt_as = *as;
PAVoiceIn *pa = (PAVoiceIn *) hw;
paaudio *g = pa->g = drv_opaque;
AudiodevPaOptions *popts = &g->dev->u.pa;
AudiodevPaOptions *popts = &amb->dev->u.pa;
AudiodevPaPerDirectionOptions *ppdo = popts->in;
PAConnection *c = g->conn;
PAConnection *c = apa->conn;
ss.format = audfmt_to_pa (as->fmt, as->endianness);
pa->g = apa;
ss.format = audfmt_to_pa (as->fmt, as->big_endian);
ss.channels = as->nchannels;
ss.rate = as->freq;
ba.fragsize = pa_usec_to_bytes((g->dev->timer_period >> 1) * 3, &ss);
ba.fragsize = pa_usec_to_bytes((amb->dev->timer_period >> 1) * 3, &ss);
ba.maxlength = pa_usec_to_bytes(
MAX(ppdo->latency, g->dev->timer_period * 3), &ss);
MAX(ppdo->latency, amb->dev->timer_period * 3), &ss);
ba.minreq = -1;
ba.prebuf = -1;
obt_as.fmt = pa_to_audfmt (ss.format, &obt_as.endianness);
obt_as.fmt = pa_to_audfmt (ss.format, &obt_as.big_endian);
pa->stream = qpa_simple_new (
c,
ppdo->stream_name ?: g->dev->id,
ppdo->stream_name ?: amb->dev->id,
PA_STREAM_RECORD,
ppdo->name,
&ss,
@@ -593,7 +584,7 @@ static int qpa_init_in(HWVoiceIn *hw, struct audsettings *as, void *drv_opaque)
&error
);
if (!pa->stream) {
qpa_logerr (error, "pa_simple_new for capture failed\n");
qpa_logerr(error, "pa_simple_new for capture failed");
goto fail1;
}
@@ -622,7 +613,7 @@ static void qpa_simple_disconnect(PAConnection *c, pa_stream *stream)
err = pa_stream_disconnect(stream);
if (err != 0) {
dolog("Failed to disconnect! err=%d\n", err);
error_report("pulseaudio: Failed to disconnect! err=%d", err);
}
pa_stream_unref(stream);
}
@@ -653,7 +644,7 @@ static void qpa_fini_in (HWVoiceIn *hw)
int r = pa_stream_drop(pa->stream);
if (r) {
qpa_logerr(pa_context_errno(c->context),
"pa_stream_drop failed\n");
"pa_stream_drop failed");
}
pa->read_length = 0;
}
@@ -671,9 +662,7 @@ static void qpa_volume_out(HWVoiceOut *hw, Volume *vol)
PAConnection *c = pa->g->conn;
int i;
#ifdef PA_CHECK_VERSION /* macro is present in 0.9.16+ */
pa_cvolume_init (&v); /* function is present in 0.9.13+ */
#endif
pa_cvolume_init(&v);
v.channels = vol->channels;
for (i = 0; i < vol->channels; ++i) {
@@ -687,7 +676,7 @@ static void qpa_volume_out(HWVoiceOut *hw, Volume *vol)
&v, NULL, NULL);
if (!op) {
qpa_logerr(pa_context_errno(c->context),
"set_sink_input_volume() failed\n");
"set_sink_input_volume() failed");
} else {
pa_operation_unref(op);
}
@@ -697,7 +686,7 @@ static void qpa_volume_out(HWVoiceOut *hw, Volume *vol)
vol->mute, NULL, NULL);
if (!op) {
qpa_logerr(pa_context_errno(c->context),
"set_sink_input_mute() failed\n");
"set_sink_input_mute() failed");
} else {
pa_operation_unref(op);
}
@@ -713,9 +702,7 @@ static void qpa_volume_in(HWVoiceIn *hw, Volume *vol)
PAConnection *c = pa->g->conn;
int i;
#ifdef PA_CHECK_VERSION
pa_cvolume_init (&v);
#endif
pa_cvolume_init(&v);
v.channels = vol->channels;
for (i = 0; i < vol->channels; ++i) {
@@ -729,7 +716,7 @@ static void qpa_volume_in(HWVoiceIn *hw, Volume *vol)
&v, NULL, NULL);
if (!op) {
qpa_logerr(pa_context_errno(c->context),
"set_source_output_volume() failed\n");
"set_source_output_volume() failed");
} else {
pa_operation_unref(op);
}
@@ -739,7 +726,7 @@ static void qpa_volume_in(HWVoiceIn *hw, Volume *vol)
vol->mute, NULL, NULL);
if (!op) {
qpa_logerr(pa_context_errno(c->context),
"set_source_output_mute() failed\n");
"set_source_output_mute() failed");
} else {
pa_operation_unref(op);
}
@@ -777,7 +764,7 @@ static void *qpa_conn_init(const char *server)
if (pa_context_connect(c->context, server, 0, NULL) < 0) {
qpa_logerr(pa_context_errno(c->context),
"pa_context_connect() failed\n");
"pa_context_connect() failed");
goto fail;
}
@@ -798,7 +785,7 @@ static void *qpa_conn_init(const char *server)
if (!PA_CONTEXT_IS_GOOD(state)) {
qpa_logerr(pa_context_errno(c->context),
"Wrong context state\n");
"Wrong context state");
goto unlock_and_fail;
}
@@ -812,20 +799,24 @@ static void *qpa_conn_init(const char *server)
unlock_and_fail:
pa_threaded_mainloop_unlock(c->mainloop);
fail:
AUD_log (AUDIO_CAP, "Failed to initialize PA context");
qpa_conn_fini(c);
return NULL;
}
static void *qpa_audio_init(Audiodev *dev, Error **errp)
static bool
audio_pa_realize(AudioBackend *abe, Audiodev *dev, Error **errp)
{
paaudio *g;
AudioPa *apa = AUDIO_PA(abe);
AudiodevPaOptions *popts = &dev->u.pa;
const char *server;
PAConnection *c;
assert(dev->driver == AUDIODEV_DRIVER_PA);
if (!audio_pa_parent_class->realize(abe, dev, errp)) {
return false;
}
if (!popts->server) {
char pidfile[64];
char *runtime;
@@ -834,42 +825,38 @@ static void *qpa_audio_init(Audiodev *dev, Error **errp)
runtime = getenv("XDG_RUNTIME_DIR");
if (!runtime) {
error_setg(errp, "XDG_RUNTIME_DIR not set");
return NULL;
return false;
}
snprintf(pidfile, sizeof(pidfile), "%s/pulse/pid", runtime);
if (stat(pidfile, &st) != 0) {
error_setg_errno(errp, errno, "could not stat pidfile %s", pidfile);
return NULL;
return false;
}
}
qpa_validate_per_direction_opts(dev, popts->in);
qpa_validate_per_direction_opts(dev, popts->out);
g = g_new0(paaudio, 1);
server = popts->server;
g->dev = dev;
QTAILQ_FOREACH(c, &pa_conns, list) {
if (server == NULL || c->server == NULL ?
server == c->server :
strcmp(server, c->server) == 0) {
g->conn = c;
apa->conn = c;
break;
}
}
if (!g->conn) {
g->conn = qpa_conn_init(server);
if (!apa->conn) {
apa->conn = qpa_conn_init(server);
}
if (!g->conn) {
g_free(g);
if (!apa->conn) {
error_setg(errp, "could not connect to PulseAudio server");
return NULL;
return false;
}
++g->conn->refcount;
return g;
++apa->conn->refcount;
return true;
}
static void qpa_conn_fini(PAConnection *c)
@@ -891,48 +878,54 @@ static void qpa_conn_fini(PAConnection *c)
g_free(c);
}
static void qpa_audio_fini (void *opaque)
static void audio_pa_finalize(Object *obj)
{
paaudio *g = opaque;
PAConnection *c = g->conn;
AudioPa *apa = AUDIO_PA(obj);
PAConnection *c = apa->conn;
if (--c->refcount == 0) {
if (c && --c->refcount == 0) {
qpa_conn_fini(c);
}
g_free(g);
}
static struct audio_pcm_ops qpa_pcm_ops = {
.init_out = qpa_init_out,
.fini_out = qpa_fini_out,
.write = qpa_write,
.buffer_get_free = qpa_buffer_get_free,
.get_buffer_out = qpa_get_buffer_out,
.put_buffer_out = qpa_put_buffer_out,
.volume_out = qpa_volume_out,
.init_in = qpa_init_in,
.fini_in = qpa_fini_in,
.read = qpa_read,
.get_buffer_in = qpa_get_buffer_in,
.put_buffer_in = qpa_put_buffer_in,
.volume_in = qpa_volume_in
};
static struct audio_driver pa_audio_driver = {
.name = "pa",
.init = qpa_audio_init,
.fini = qpa_audio_fini,
.pcm_ops = &qpa_pcm_ops,
.max_voices_out = INT_MAX,
.max_voices_in = INT_MAX,
.voice_size_out = sizeof (PAVoiceOut),
.voice_size_in = sizeof (PAVoiceIn),
};
static void register_audio_pa(void)
static void audio_pa_class_init(ObjectClass *klass, const void *data)
{
audio_driver_register(&pa_audio_driver);
AudioBackendClass *b = AUDIO_BACKEND_CLASS(klass);
AudioMixengBackendClass *k = AUDIO_MIXENG_BACKEND_CLASS(klass);
audio_pa_parent_class = AUDIO_BACKEND_CLASS(object_class_get_parent(klass));
b->realize = audio_pa_realize;
k->max_voices_out = INT_MAX;
k->max_voices_in = INT_MAX;
k->voice_size_out = sizeof(PAVoiceOut);
k->voice_size_in = sizeof(PAVoiceIn);
k->init_out = qpa_init_out;
k->fini_out = qpa_fini_out;
k->write = qpa_write;
k->buffer_get_free = qpa_buffer_get_free;
k->get_buffer_out = qpa_get_buffer_out;
k->put_buffer_out = qpa_put_buffer_out;
k->volume_out = qpa_volume_out;
k->init_in = qpa_init_in;
k->fini_in = qpa_fini_in;
k->read = qpa_read;
k->get_buffer_in = qpa_get_buffer_in;
k->put_buffer_in = qpa_put_buffer_in;
k->volume_in = qpa_volume_in;
}
type_init(register_audio_pa);
static const TypeInfo audio_types[] = {
{
.name = TYPE_AUDIO_PA,
.parent = TYPE_AUDIO_MIXENG_BACKEND,
.instance_size = sizeof(AudioPa),
.class_init = audio_pa_class_init,
.instance_finalize = audio_pa_finalize,
},
};
DEFINE_TYPES(audio_types)
module_obj(TYPE_AUDIO_PA);
+111 -103
View File
@@ -13,37 +13,43 @@
#include "qemu/audio.h"
#include "qemu/error-report.h"
#include "qapi/error.h"
#include "qom/object.h"
#include <spa/param/audio/format-utils.h>
#include <spa/utils/ringbuffer.h>
#include <spa/utils/result.h>
#include <spa/param/props.h>
#include <pipewire/pipewire.h>
#include "audio_int.h"
#include "trace.h"
#define AUDIO_CAP "pipewire"
#define RINGBUFFER_SIZE (1u << 22)
#define RINGBUFFER_MASK (RINGBUFFER_SIZE - 1)
#include "audio_int.h"
#define TYPE_AUDIO_PW "audio-pipewire"
OBJECT_DECLARE_SIMPLE_TYPE(AudioPw, AUDIO_PW)
typedef struct pwvolume {
uint32_t channels;
float values[SPA_AUDIO_MAX_CHANNELS];
} pwvolume;
static AudioBackendClass *audio_pw_parent_class;
struct AudioPw {
AudioMixengBackend parent_obj;
typedef struct pwaudio {
Audiodev *dev;
struct pw_thread_loop *thread_loop;
struct pw_context *context;
struct pw_core *core;
struct spa_hook core_listener;
int last_seq, pending_seq, error;
} pwaudio;
};
typedef struct pwvolume {
uint32_t channels;
float values[SPA_AUDIO_MAX_CHANNELS];
} pwvolume;
typedef struct PWVoice {
pwaudio *g;
struct pw_stream *stream;
struct spa_hook stream_listener;
struct spa_audio_info_raw info;
@@ -219,9 +225,9 @@ static const struct pw_stream_events playback_stream_events = {
static size_t
qpw_read(HWVoiceIn *hw, void *data, size_t len)
{
AudioPw *c = AUDIO_PW(hw->s);
PWVoiceIn *pw = (PWVoiceIn *) hw;
PWVoice *v = &pw->v;
pwaudio *c = v->g;
const char *error = NULL;
size_t l;
int32_t avail;
@@ -256,9 +262,9 @@ done_unlock:
static size_t qpw_buffer_get_free(HWVoiceOut *hw)
{
AudioPw *c = AUDIO_PW(hw->s);
PWVoiceOut *pw = (PWVoiceOut *)hw;
PWVoice *v = &pw->v;
pwaudio *c = v->g;
const char *error = NULL;
int32_t filled, avail;
uint32_t index;
@@ -281,9 +287,9 @@ done_unlock:
static size_t
qpw_write(HWVoiceOut *hw, void *data, size_t len)
{
AudioPw *c = AUDIO_PW(hw->s);
PWVoiceOut *pw = (PWVoiceOut *) hw;
PWVoice *v = &pw->v;
pwaudio *c = v->g;
const char *error = NULL;
int32_t filled, avail;
uint32_t index;
@@ -351,7 +357,7 @@ audfmt_to_pw(AudioFormat fmt, bool big_endian)
format = big_endian ? SPA_AUDIO_FORMAT_F32_BE : SPA_AUDIO_FORMAT_F32_LE;
break;
default:
dolog("Internal logic error: Bad audio format %d\n", fmt);
error_report("pipewire: internal logic error: bad audio format %d", fmt);
format = SPA_AUDIO_FORMAT_U8;
break;
}
@@ -359,7 +365,7 @@ audfmt_to_pw(AudioFormat fmt, bool big_endian)
}
static AudioFormat
pw_to_audfmt(enum spa_audio_format fmt, int *endianness,
pw_to_audfmt(enum spa_audio_format fmt, bool *big_endian,
uint32_t *sample_size)
{
switch (fmt) {
@@ -371,53 +377,53 @@ pw_to_audfmt(enum spa_audio_format fmt, int *endianness,
return AUDIO_FORMAT_U8;
case SPA_AUDIO_FORMAT_S16_BE:
*sample_size = 2;
*endianness = 1;
*big_endian = true;
return AUDIO_FORMAT_S16;
case SPA_AUDIO_FORMAT_S16_LE:
*sample_size = 2;
*endianness = 0;
*big_endian = false;
return AUDIO_FORMAT_S16;
case SPA_AUDIO_FORMAT_U16_BE:
*sample_size = 2;
*endianness = 1;
*big_endian = true;
return AUDIO_FORMAT_U16;
case SPA_AUDIO_FORMAT_U16_LE:
*sample_size = 2;
*endianness = 0;
*big_endian = false;
return AUDIO_FORMAT_U16;
case SPA_AUDIO_FORMAT_S32_BE:
*sample_size = 4;
*endianness = 1;
*big_endian = true;
return AUDIO_FORMAT_S32;
case SPA_AUDIO_FORMAT_S32_LE:
*sample_size = 4;
*endianness = 0;
*big_endian = false;
return AUDIO_FORMAT_S32;
case SPA_AUDIO_FORMAT_U32_BE:
*sample_size = 4;
*endianness = 1;
*big_endian = true;
return AUDIO_FORMAT_U32;
case SPA_AUDIO_FORMAT_U32_LE:
*sample_size = 4;
*endianness = 0;
*big_endian = false;
return AUDIO_FORMAT_U32;
case SPA_AUDIO_FORMAT_F32_BE:
*sample_size = 4;
*endianness = 1;
*big_endian = true;
return AUDIO_FORMAT_F32;
case SPA_AUDIO_FORMAT_F32_LE:
*sample_size = 4;
*endianness = 0;
*big_endian = false;
return AUDIO_FORMAT_F32;
default:
*sample_size = 1;
dolog("Internal logic error: Bad spa_audio_format %d\n", fmt);
error_report("pipewire: internal logic error: bad spa_audio_format %d", fmt);
return AUDIO_FORMAT_U8;
}
}
static int
qpw_stream_new(pwaudio *c, PWVoice *v, const char *stream_name,
qpw_stream_new(AudioPw *c, PWVoice *v, const char *stream_name,
const char *name, enum spa_direction dir)
{
int res;
@@ -435,8 +441,8 @@ qpw_stream_new(pwaudio *c, PWVoice *v, const char *stream_name,
}
/* 75% of the timer period for faster updates */
buf_samples = (uint64_t)v->g->dev->timer_period * v->info.rate
* 3 / 4 / 1000000;
buf_samples = (uint64_t)AUDIO_MIXENG_BACKEND(c)->dev->timer_period
* v->info.rate * 3 / 4 / 1000000;
pw_properties_setf(props, PW_KEY_NODE_LATENCY, "%" PRIu64 "/%u",
buf_samples, v->info.rate);
@@ -511,37 +517,37 @@ qpw_set_position(uint32_t channels, uint32_t position[SPA_AUDIO_MAX_CHANNELS])
position[0] = SPA_AUDIO_CHANNEL_MONO;
break;
default:
dolog("Internal error: unsupported channel count %d\n", channels);
error_report("pipewire: unsupported channel count %d", channels);
}
}
static int
qpw_init_out(HWVoiceOut *hw, struct audsettings *as, void *drv_opaque)
qpw_init_out(HWVoiceOut *hw, struct audsettings *as)
{
AudioPw *c = AUDIO_PW(hw->s);
PWVoiceOut *pw = (PWVoiceOut *) hw;
PWVoice *v = &pw->v;
struct audsettings obt_as = *as;
pwaudio *c = v->g = drv_opaque;
AudiodevPipewireOptions *popts = &c->dev->u.pipewire;
AudiodevPipewireOptions *popts = &AUDIO_MIXENG_BACKEND(c)->dev->u.pipewire;
AudiodevPipewirePerDirectionOptions *ppdo = popts->out;
int r;
pw_thread_loop_lock(c->thread_loop);
v->info.format = audfmt_to_pw(as->fmt, as->endianness);
v->info.format = audfmt_to_pw(as->fmt, as->big_endian);
v->info.channels = as->nchannels;
qpw_set_position(as->nchannels, v->info.position);
v->info.rate = as->freq;
obt_as.fmt =
pw_to_audfmt(v->info.format, &obt_as.endianness, &v->frame_size);
pw_to_audfmt(v->info.format, &obt_as.big_endian, &v->frame_size);
v->frame_size *= as->nchannels;
v->req = (uint64_t)c->dev->timer_period * v->info.rate
v->req = (uint64_t)AUDIO_MIXENG_BACKEND(c)->dev->timer_period * v->info.rate
* 1 / 2 / 1000000 * v->frame_size;
/* call the function that creates a new stream for playback */
r = qpw_stream_new(c, v, ppdo->stream_name ? : c->dev->id,
r = qpw_stream_new(c, v, ppdo->stream_name ?: AUDIO_MIXENG_BACKEND(c)->dev->id,
ppdo->name, SPA_DIRECTION_OUTPUT);
if (r < 0) {
pw_thread_loop_unlock(c->thread_loop);
@@ -563,29 +569,29 @@ qpw_init_out(HWVoiceOut *hw, struct audsettings *as, void *drv_opaque)
}
static int
qpw_init_in(HWVoiceIn *hw, struct audsettings *as, void *drv_opaque)
qpw_init_in(HWVoiceIn *hw, struct audsettings *as)
{
AudioPw *c = AUDIO_PW(hw->s);
PWVoiceIn *pw = (PWVoiceIn *) hw;
PWVoice *v = &pw->v;
struct audsettings obt_as = *as;
pwaudio *c = v->g = drv_opaque;
AudiodevPipewireOptions *popts = &c->dev->u.pipewire;
AudiodevPipewireOptions *popts = &AUDIO_MIXENG_BACKEND(c)->dev->u.pipewire;
AudiodevPipewirePerDirectionOptions *ppdo = popts->in;
int r;
pw_thread_loop_lock(c->thread_loop);
v->info.format = audfmt_to_pw(as->fmt, as->endianness);
v->info.format = audfmt_to_pw(as->fmt, as->big_endian);
v->info.channels = as->nchannels;
qpw_set_position(as->nchannels, v->info.position);
v->info.rate = as->freq;
obt_as.fmt =
pw_to_audfmt(v->info.format, &obt_as.endianness, &v->frame_size);
pw_to_audfmt(v->info.format, &obt_as.big_endian, &v->frame_size);
v->frame_size *= as->nchannels;
/* call the function that creates a new stream for recording */
r = qpw_stream_new(c, v, ppdo->stream_name ? : c->dev->id,
r = qpw_stream_new(c, v, ppdo->stream_name ? : AUDIO_MIXENG_BACKEND(c)->dev->id,
ppdo->name, SPA_DIRECTION_INPUT);
if (r < 0) {
pw_thread_loop_unlock(c->thread_loop);
@@ -604,10 +610,8 @@ qpw_init_in(HWVoiceIn *hw, struct audsettings *as, void *drv_opaque)
}
static void
qpw_voice_fini(PWVoice *v)
qpw_voice_fini(AudioPw *c, PWVoice *v)
{
pwaudio *c = v->g;
if (!v->stream) {
return;
}
@@ -620,19 +624,18 @@ qpw_voice_fini(PWVoice *v)
static void
qpw_fini_out(HWVoiceOut *hw)
{
qpw_voice_fini(&PW_VOICE_OUT(hw)->v);
qpw_voice_fini(AUDIO_PW(hw->s), &PW_VOICE_OUT(hw)->v);
}
static void
qpw_fini_in(HWVoiceIn *hw)
{
qpw_voice_fini(&PW_VOICE_IN(hw)->v);
qpw_voice_fini(AUDIO_PW(hw->s), &PW_VOICE_IN(hw)->v);
}
static void
qpw_voice_set_enabled(PWVoice *v, bool enable)
qpw_voice_set_enabled(AudioPw *c, PWVoice *v, bool enable)
{
pwaudio *c = v->g;
pw_thread_loop_lock(c->thread_loop);
pw_stream_set_active(v->stream, enable);
pw_thread_loop_unlock(c->thread_loop);
@@ -641,19 +644,18 @@ qpw_voice_set_enabled(PWVoice *v, bool enable)
static void
qpw_enable_out(HWVoiceOut *hw, bool enable)
{
qpw_voice_set_enabled(&PW_VOICE_OUT(hw)->v, enable);
qpw_voice_set_enabled(AUDIO_PW(hw->s), &PW_VOICE_OUT(hw)->v, enable);
}
static void
qpw_enable_in(HWVoiceIn *hw, bool enable)
{
qpw_voice_set_enabled(&PW_VOICE_IN(hw)->v, enable);
qpw_voice_set_enabled(AUDIO_PW(hw->s), &PW_VOICE_IN(hw)->v, enable);
}
static void
qpw_voice_set_volume(PWVoice *v, Volume *vol)
qpw_voice_set_volume(AudioPw *c, PWVoice *v, Volume *vol)
{
pwaudio *c = v->g;
int i, ret;
pw_thread_loop_lock(c->thread_loop);
@@ -676,16 +678,16 @@ qpw_voice_set_volume(PWVoice *v, Volume *vol)
static void
qpw_volume_out(HWVoiceOut *hw, Volume *vol)
{
qpw_voice_set_volume(&PW_VOICE_OUT(hw)->v, vol);
qpw_voice_set_volume(AUDIO_PW(hw->s), &PW_VOICE_OUT(hw)->v, vol);
}
static void
qpw_volume_in(HWVoiceIn *hw, Volume *vol)
{
qpw_voice_set_volume(&PW_VOICE_IN(hw)->v, vol);
qpw_voice_set_volume(AUDIO_PW(hw->s), &PW_VOICE_IN(hw)->v, vol);
}
static int wait_resync(pwaudio *pw)
static int wait_resync(AudioPw *pw)
{
int res;
pw->pending_seq = pw_core_sync(pw->core, PW_ID_CORE, pw->pending_seq);
@@ -708,7 +710,7 @@ static int wait_resync(pwaudio *pw)
static void
on_core_error(void *data, uint32_t id, int seq, int res, const char *message)
{
pwaudio *pw = data;
AudioPw *pw = data;
error_report("error id:%u seq:%d res:%d (%s): %s",
id, seq, res, spa_strerror(res), message);
@@ -720,7 +722,7 @@ on_core_error(void *data, uint32_t id, int seq, int res, const char *message)
static void
on_core_done(void *data, uint32_t id, int seq)
{
pwaudio *pw = data;
AudioPw *pw = data;
assert(id == PW_ID_CORE);
pw->last_seq = seq;
if (pw->pending_seq == seq) {
@@ -735,17 +737,20 @@ static const struct pw_core_events core_events = {
.error = on_core_error,
};
static void *
qpw_audio_init(Audiodev *dev, Error **errp)
static bool
audio_pw_realize(AudioBackend *abe, Audiodev *dev, Error **errp)
{
g_autofree pwaudio *pw = g_new0(pwaudio, 1);
AudioPw *pw = AUDIO_PW(abe);
assert(dev->driver == AUDIODEV_DRIVER_PIPEWIRE);
trace_pw_audio_init();
if (!audio_pw_parent_class->realize(abe, dev, errp)) {
return false;
}
pw_init(NULL, NULL);
pw->dev = dev;
pw->thread_loop = pw_thread_loop_new("PipeWire thread loop", NULL);
if (pw->thread_loop == NULL) {
error_setg_errno(errp, errno, "Could not create PipeWire loop");
@@ -784,8 +789,7 @@ qpw_audio_init(Audiodev *dev, Error **errp)
}
pw_thread_loop_unlock(pw->thread_loop);
return g_steal_pointer(&pw);
return true;
fail:
if (pw->thread_loop) {
@@ -793,13 +797,13 @@ fail:
}
g_clear_pointer(&pw->context, pw_context_destroy);
g_clear_pointer(&pw->thread_loop, pw_thread_loop_destroy);
return NULL;
return false;
}
static void
qpw_audio_fini(void *opaque)
audio_pw_finalize(Object *obj)
{
pwaudio *pw = opaque;
AudioPw *pw = AUDIO_PW(obj);
if (pw->thread_loop) {
pw_thread_loop_stop(pw->thread_loop);
@@ -814,43 +818,47 @@ qpw_audio_fini(void *opaque)
if (pw->context) {
pw_context_destroy(pw->context);
}
pw_thread_loop_destroy(pw->thread_loop);
g_free(pw);
g_clear_pointer(&pw->thread_loop, pw_thread_loop_destroy);
}
static struct audio_pcm_ops qpw_pcm_ops = {
.init_out = qpw_init_out,
.fini_out = qpw_fini_out,
.write = qpw_write,
.buffer_get_free = qpw_buffer_get_free,
.run_buffer_out = audio_generic_run_buffer_out,
.enable_out = qpw_enable_out,
.volume_out = qpw_volume_out,
.volume_in = qpw_volume_in,
.init_in = qpw_init_in,
.fini_in = qpw_fini_in,
.read = qpw_read,
.run_buffer_in = audio_generic_run_buffer_in,
.enable_in = qpw_enable_in
};
static struct audio_driver pw_audio_driver = {
.name = "pipewire",
.init = qpw_audio_init,
.fini = qpw_audio_fini,
.pcm_ops = &qpw_pcm_ops,
.max_voices_out = INT_MAX,
.max_voices_in = INT_MAX,
.voice_size_out = sizeof(PWVoiceOut),
.voice_size_in = sizeof(PWVoiceIn),
};
static void
register_audio_pw(void)
static void audio_pw_class_init(ObjectClass *klass, const void *data)
{
audio_driver_register(&pw_audio_driver);
AudioBackendClass *b = AUDIO_BACKEND_CLASS(klass);
AudioMixengBackendClass *k = AUDIO_MIXENG_BACKEND_CLASS(klass);
audio_pw_parent_class = AUDIO_BACKEND_CLASS(object_class_get_parent(klass));
b->realize = audio_pw_realize;
k->max_voices_out = INT_MAX;
k->max_voices_in = INT_MAX;
k->voice_size_out = sizeof(PWVoiceOut);
k->voice_size_in = sizeof(PWVoiceIn);
k->init_out = qpw_init_out;
k->fini_out = qpw_fini_out;
k->write = qpw_write;
k->buffer_get_free = qpw_buffer_get_free;
k->run_buffer_out = audio_generic_run_buffer_out;
k->enable_out = qpw_enable_out;
k->volume_out = qpw_volume_out;
k->init_in = qpw_init_in;
k->fini_in = qpw_fini_in;
k->read = qpw_read;
k->run_buffer_in = audio_generic_run_buffer_in;
k->enable_in = qpw_enable_in;
k->volume_in = qpw_volume_in;
}
type_init(register_audio_pw);
static const TypeInfo audio_types[] = {
{
.name = TYPE_AUDIO_PW,
.parent = TYPE_AUDIO_MIXENG_BACKEND,
.instance_size = sizeof(AudioPw),
.class_init = audio_pw_class_init,
.instance_finalize = audio_pw_finalize,
},
};
DEFINE_TYPES(audio_types)
module_obj(TYPE_AUDIO_PW);
+90 -88
View File
@@ -26,8 +26,10 @@
#include <SDL.h>
#include <SDL_thread.h>
#include "qemu/module.h"
#include "qemu/error-report.h"
#include "qapi/error.h"
#include "qemu/audio.h"
#include "qom/object.h"
#ifndef _WIN32
#ifdef __sun__
@@ -37,9 +39,18 @@
#endif
#endif
#define AUDIO_CAP "sdl"
#include "audio_int.h"
#define TYPE_AUDIO_SDL "audio-sdl"
OBJECT_DECLARE_SIMPLE_TYPE(AudioSdl, AUDIO_SDL)
static AudioBackendClass *audio_sdl_parent_class;
struct AudioSdl {
AudioMixengBackend parent_obj;
};
typedef struct SDLVoiceOut {
HWVoiceOut hw;
int exit;
@@ -56,17 +67,6 @@ typedef struct SDLVoiceIn {
SDL_AudioDeviceID devid;
} SDLVoiceIn;
static void G_GNUC_PRINTF (1, 2) sdl_logerr (const char *fmt, ...)
{
va_list ap;
va_start (ap, fmt);
AUD_vlog (AUDIO_CAP, fmt, ap);
va_end (ap);
AUD_log (AUDIO_CAP, "Reason: %s\n", SDL_GetError ());
}
static int aud_to_sdlfmt (AudioFormat fmt)
{
switch (fmt) {
@@ -91,69 +91,66 @@ static int aud_to_sdlfmt (AudioFormat fmt)
return AUDIO_F32LSB;
default:
dolog ("Internal logic error: Bad audio format %d\n", fmt);
#ifdef DEBUG_AUDIO
abort ();
#endif
error_report("sdl: internal logic error: bad audio format %d", fmt);
return AUDIO_U8;
}
}
static int sdl_to_audfmt(int sdlfmt, AudioFormat *fmt, int *endianness)
static int sdl_to_audfmt(int sdlfmt, AudioFormat *fmt, bool *big_endian)
{
switch (sdlfmt) {
case AUDIO_S8:
*endianness = 0;
*big_endian = false;
*fmt = AUDIO_FORMAT_S8;
break;
case AUDIO_U8:
*endianness = 0;
*big_endian = false;
*fmt = AUDIO_FORMAT_U8;
break;
case AUDIO_S16LSB:
*endianness = 0;
*big_endian = false;
*fmt = AUDIO_FORMAT_S16;
break;
case AUDIO_U16LSB:
*endianness = 0;
*big_endian = false;
*fmt = AUDIO_FORMAT_U16;
break;
case AUDIO_S16MSB:
*endianness = 1;
*big_endian = true;
*fmt = AUDIO_FORMAT_S16;
break;
case AUDIO_U16MSB:
*endianness = 1;
*big_endian = true;
*fmt = AUDIO_FORMAT_U16;
break;
case AUDIO_S32LSB:
*endianness = 0;
*big_endian = false;
*fmt = AUDIO_FORMAT_S32;
break;
case AUDIO_S32MSB:
*endianness = 1;
*big_endian = true;
*fmt = AUDIO_FORMAT_S32;
break;
case AUDIO_F32LSB:
*endianness = 0;
*big_endian = false;
*fmt = AUDIO_FORMAT_F32;
break;
case AUDIO_F32MSB:
*endianness = 1;
*big_endian = true;
*fmt = AUDIO_FORMAT_F32;
break;
default:
dolog ("Unrecognized SDL audio format %d\n", sdlfmt);
error_report("sdl: unrecognized audio format %d", sdlfmt);
return -1;
}
@@ -171,27 +168,27 @@ static SDL_AudioDeviceID sdl_open(SDL_AudioSpec *req, SDL_AudioSpec *obt,
/* Make sure potential threads created by SDL don't hog signals. */
err = sigfillset (&new);
if (err) {
dolog ("sdl_open: sigfillset failed: %s\n", strerror (errno));
error_report("sdl: sigfillset failed: %s", strerror (errno));
return 0;
}
err = pthread_sigmask (SIG_BLOCK, &new, &old);
if (err) {
dolog ("sdl_open: pthread_sigmask failed: %s\n", strerror (err));
error_report("sdl: pthread_sigmask failed: %s", strerror (err));
return 0;
}
#endif
devid = SDL_OpenAudioDevice(NULL, rec, req, obt, 0);
if (!devid) {
sdl_logerr("SDL_OpenAudioDevice for %s failed\n",
rec ? "recording" : "playback");
error_report("SDL_OpenAudioDevice for %s failed: %s",
rec ? "recording" : "playback", SDL_GetError());
}
#ifndef _WIN32
err = pthread_sigmask (SIG_SETMASK, &old, NULL);
if (err) {
dolog ("sdl_open: pthread_sigmask (restore) failed: %s\n",
strerror (errno));
error_report("sdl: pthread_sigmask (restore) failed: %s",
strerror (errno));
/* We have failed to restore original signal mask, all bets are off,
so exit the process */
exit (EXIT_FAILURE);
@@ -222,8 +219,6 @@ static void sdl_callback_out(void *opaque, Uint8 *buf, int len)
if (!sdl->exit) {
/* dolog("callback_out: len=%d avail=%zu\n", len, hw->pending_emul); */
while (hw->pending_emul && len) {
size_t write_len, start;
@@ -272,8 +267,6 @@ static void sdl_callback_in(void *opaque, Uint8 *buf, int len)
return;
}
/* dolog("callback_in: len=%d pending=%zu\n", len, hw->pending_emul); */
while (hw->pending_emul < hw->size_emul && len) {
size_t read_len = MIN(len, MIN(hw->size_emul - hw->pos_emul,
hw->size_emul - hw->pending_emul));
@@ -333,13 +326,12 @@ static void sdl_fini_out(HWVoiceOut *hw)
sdl_close_out(sdl);
}
static int sdl_init_out(HWVoiceOut *hw, struct audsettings *as,
void *drv_opaque)
static int sdl_init_out(HWVoiceOut *hw, struct audsettings *as)
{
SDLVoiceOut *sdl = (SDLVoiceOut *)hw;
SDL_AudioSpec req, obt;
int err;
Audiodev *dev = drv_opaque;
Audiodev *dev = hw->s->dev;
AudiodevSdlPerDirectionOptions *spdo = dev->u.sdl.out;
struct audsettings obt_as;
@@ -358,7 +350,7 @@ static int sdl_init_out(HWVoiceOut *hw, struct audsettings *as,
return -1;
}
err = sdl_to_audfmt(obt.format, &obt_as.fmt, &obt_as.endianness);
err = sdl_to_audfmt(obt.format, &obt_as.fmt, &obt_as.big_endian);
if (err) {
sdl_close_out(sdl);
return -1;
@@ -390,12 +382,12 @@ static void sdl_fini_in(HWVoiceIn *hw)
sdl_close_in(sdl);
}
static int sdl_init_in(HWVoiceIn *hw, audsettings *as, void *drv_opaque)
static int sdl_init_in(HWVoiceIn *hw, audsettings *as)
{
SDLVoiceIn *sdl = (SDLVoiceIn *)hw;
SDL_AudioSpec req, obt;
int err;
Audiodev *dev = drv_opaque;
Audiodev *dev = hw->s->dev;
AudiodevSdlPerDirectionOptions *spdo = dev->u.sdl.in;
struct audsettings obt_as;
@@ -414,7 +406,7 @@ static int sdl_init_in(HWVoiceIn *hw, audsettings *as, void *drv_opaque)
return -1;
}
err = sdl_to_audfmt(obt.format, &obt_as.fmt, &obt_as.endianness);
err = sdl_to_audfmt(obt.format, &obt_as.fmt, &obt_as.big_endian);
if (err) {
sdl_close_in(sdl);
return -1;
@@ -442,57 +434,67 @@ static void sdl_enable_in(HWVoiceIn *hw, bool enable)
SDL_PauseAudioDevice(sdl->devid, !enable);
}
static void *sdl_audio_init(Audiodev *dev, Error **errp)
static bool audio_sdl_realize(AudioBackend *abe, Audiodev *dev, Error **errp)
{
if (SDL_InitSubSystem (SDL_INIT_AUDIO)) {
if (SDL_InitSubSystem(SDL_INIT_AUDIO)) {
error_setg(errp, "SDL failed to initialize audio subsystem");
return NULL;
qapi_free_Audiodev(dev);
return false;
}
return dev;
return audio_sdl_parent_class->realize(abe, dev, errp);
}
static void sdl_audio_fini (void *opaque)
static void audio_sdl_finalize(Object *obj)
{
SDL_QuitSubSystem (SDL_INIT_AUDIO);
SDL_QuitSubSystem(SDL_INIT_AUDIO);
}
static struct audio_pcm_ops sdl_pcm_ops = {
.init_out = sdl_init_out,
.fini_out = sdl_fini_out,
/* wrapper for audio_generic_write */
.write = sdl_write,
/* wrapper for audio_generic_buffer_get_free */
.buffer_get_free = sdl_buffer_get_free,
/* wrapper for audio_generic_get_buffer_out */
.get_buffer_out = sdl_get_buffer_out,
/* wrapper for audio_generic_put_buffer_out */
.put_buffer_out = sdl_put_buffer_out,
.enable_out = sdl_enable_out,
.init_in = sdl_init_in,
.fini_in = sdl_fini_in,
/* wrapper for audio_generic_read */
.read = sdl_read,
/* wrapper for audio_generic_get_buffer_in */
.get_buffer_in = sdl_get_buffer_in,
/* wrapper for audio_generic_put_buffer_in */
.put_buffer_in = sdl_put_buffer_in,
.enable_in = sdl_enable_in,
static void audio_sdl_class_init(ObjectClass *klass, const void *data)
{
AudioBackendClass *b = AUDIO_BACKEND_CLASS(klass);
AudioMixengBackendClass *k = AUDIO_MIXENG_BACKEND_CLASS(klass);
audio_sdl_parent_class = AUDIO_BACKEND_CLASS(object_class_get_parent(klass));
b->realize = audio_sdl_realize;
k->max_voices_out = INT_MAX;
k->max_voices_in = INT_MAX;
k->voice_size_out = sizeof(SDLVoiceOut);
k->voice_size_in = sizeof(SDLVoiceIn);
k->init_out = sdl_init_out;
k->fini_out = sdl_fini_out;
/* wrapper for audio_generic_write */
k->write = sdl_write;
/* wrapper for audio_generic_buffer_get_free */
k->buffer_get_free = sdl_buffer_get_free;
/* wrapper for audio_generic_get_buffer_out */
k->get_buffer_out = sdl_get_buffer_out;
/* wrapper for audio_generic_put_buffer_out */
k->put_buffer_out = sdl_put_buffer_out;
k->enable_out = sdl_enable_out;
k->init_in = sdl_init_in;
k->fini_in = sdl_fini_in;
/* wrapper for audio_generic_read */
k->read = sdl_read;
/* wrapper for audio_generic_get_buffer_in */
k->get_buffer_in = sdl_get_buffer_in;
/* wrapper for audio_generic_put_buffer_in */
k->put_buffer_in = sdl_put_buffer_in;
k->enable_in = sdl_enable_in;
}
static const TypeInfo audio_types[] = {
{
.name = TYPE_AUDIO_SDL,
.parent = TYPE_AUDIO_MIXENG_BACKEND,
.instance_size = sizeof(AudioSdl),
.class_init = audio_sdl_class_init,
.instance_finalize = audio_sdl_finalize,
},
};
static struct audio_driver sdl_audio_driver = {
.name = "sdl",
.init = sdl_audio_init,
.fini = sdl_audio_fini,
.pcm_ops = &sdl_pcm_ops,
.max_voices_out = INT_MAX,
.max_voices_in = INT_MAX,
.voice_size_out = sizeof(SDLVoiceOut),
.voice_size_in = sizeof(SDLVoiceIn),
};
static void register_audio_sdl(void)
{
audio_driver_register(&sdl_audio_driver);
}
type_init(register_audio_sdl);
DEFINE_TYPES(audio_types)
module_obj(TYPE_AUDIO_SDL);
+55 -53
View File
@@ -18,11 +18,20 @@
#include <poll.h>
#include <sndio.h>
#include "qemu/main-loop.h"
#include "qemu/error-report.h"
#include "qemu/audio.h"
#include "qom/object.h"
#include "audio_int.h"
#include "trace.h"
#define AUDIO_CAP "sndio"
#include "audio_int.h"
#define TYPE_AUDIO_SNDIO "audio-sndio"
OBJECT_DECLARE_SIMPLE_TYPE(AudioSndio, AUDIO_SNDIO)
struct AudioSndio {
AudioMixengBackend parent_obj;
};
/* default latency in microseconds if no option is set */
#define SNDIO_LATENCY_US 50000
@@ -339,7 +348,7 @@ static int sndio_init(SndioVoice *self,
/* open the device in non-blocking mode */
self->hdl = sio_open(dev_name, mode, 1);
if (self->hdl == NULL) {
dolog("failed to open device\n");
error_report("sndio: failed to open device");
return -1;
}
@@ -373,12 +382,12 @@ static int sndio_init(SndioVoice *self,
req.sig = 0;
break;
default:
dolog("unknown audio sample format\n");
error_report("sndio: unknown audio sample format");
return -1;
}
if (req.bits > 8) {
req.le = as->endianness ? 0 : 1;
req.le = !as->big_endian;
}
req.rate = as->freq;
@@ -392,12 +401,12 @@ static int sndio_init(SndioVoice *self,
req.appbufsz = req.rate * latency / 1000000;
if (!sio_setpar(self->hdl, &req)) {
dolog("failed set audio params\n");
error_report("sndio: failed to set audio params");
goto fail;
}
if (!sio_getpar(self->hdl, &self->par)) {
dolog("failed get audio params\n");
error_report("sndio: failed to get audio params");
goto fail;
}
@@ -410,7 +419,7 @@ static int sndio_init(SndioVoice *self,
if (self->par.bits != req.bits || self->par.bps != req.bits / 8 ||
self->par.sig != req.sig || (req.bits > 8 && self->par.le != req.le) ||
self->par.rate != as->freq || nch != as->nchannels) {
dolog("unsupported audio params\n");
error_report("sndio: unsupported audio params");
goto fail;
}
@@ -422,7 +431,7 @@ static int sndio_init(SndioVoice *self,
self->buf = g_malloc(self->buf_size);
if (self->buf == NULL) {
dolog("failed to allocate audio buffer\n");
error_report("sndio: failed to allocate audio buffer");
goto fail;
}
@@ -430,13 +439,13 @@ static int sndio_init(SndioVoice *self,
self->pfds = g_malloc_n(nfds, sizeof(struct pollfd));
if (self->pfds == NULL) {
dolog("failed to allocate pollfd structures\n");
error_report("sndio: failed to allocate pollfd structures");
goto fail;
}
self->pindexes = g_malloc_n(nfds, sizeof(struct pollindex));
if (self->pindexes == NULL) {
dolog("failed to allocate pollindex structures\n");
error_report("sndio: failed to allocate pollindex structures");
goto fail;
}
@@ -478,11 +487,11 @@ static void sndio_enable_in(HWVoiceIn *hw, bool enable)
sndio_enable(self, enable);
}
static int sndio_init_out(HWVoiceOut *hw, struct audsettings *as, void *opaque)
static int sndio_init_out(HWVoiceOut *hw, struct audsettings *as)
{
SndioVoice *self = (SndioVoice *) hw;
if (sndio_init(self, as, SIO_PLAY, opaque) == -1) {
if (sndio_init(self, as, SIO_PLAY, hw->s->dev) == -1) {
return -1;
}
@@ -491,11 +500,11 @@ static int sndio_init_out(HWVoiceOut *hw, struct audsettings *as, void *opaque)
return 0;
}
static int sndio_init_in(HWVoiceIn *hw, struct audsettings *as, void *opaque)
static int sndio_init_in(HWVoiceIn *hw, struct audsettings *as)
{
SndioVoice *self = (SndioVoice *) hw;
if (sndio_init(self, as, SIO_REC, opaque) == -1) {
if (sndio_init(self, as, SIO_REC, hw->s->dev) == -1) {
return -1;
}
@@ -518,46 +527,39 @@ static void sndio_fini_in(HWVoiceIn *hw)
sndio_fini(self);
}
static void *sndio_audio_init(Audiodev *dev, Error **errp)
static void audio_sndio_class_init(ObjectClass *klass, const void *data)
{
assert(dev->driver == AUDIODEV_DRIVER_SNDIO);
return dev;
AudioMixengBackendClass *k = AUDIO_MIXENG_BACKEND_CLASS(klass);
k->max_voices_out = INT_MAX;
k->max_voices_in = INT_MAX;
k->voice_size_out = sizeof(SndioVoice);
k->voice_size_in = sizeof(SndioVoice);
k->init_out = sndio_init_out;
k->fini_out = sndio_fini_out;
k->write = audio_generic_write;
k->buffer_get_free = sndio_buffer_get_free;
k->get_buffer_out = sndio_get_buffer_out;
k->put_buffer_out = sndio_put_buffer_out;
k->enable_out = sndio_enable_out;
k->init_in = sndio_init_in;
k->fini_in = sndio_fini_in;
k->read = audio_generic_read;
k->get_buffer_in = sndio_get_buffer_in;
k->put_buffer_in = sndio_put_buffer_in;
k->enable_in = sndio_enable_in;
}
static void sndio_audio_fini(void *opaque)
{
}
static struct audio_pcm_ops sndio_pcm_ops = {
.init_out = sndio_init_out,
.fini_out = sndio_fini_out,
.enable_out = sndio_enable_out,
.write = audio_generic_write,
.buffer_get_free = sndio_buffer_get_free,
.get_buffer_out = sndio_get_buffer_out,
.put_buffer_out = sndio_put_buffer_out,
.init_in = sndio_init_in,
.fini_in = sndio_fini_in,
.read = audio_generic_read,
.enable_in = sndio_enable_in,
.get_buffer_in = sndio_get_buffer_in,
.put_buffer_in = sndio_put_buffer_in,
static const TypeInfo audio_types[] = {
{
.name = TYPE_AUDIO_SNDIO,
.parent = TYPE_AUDIO_MIXENG_BACKEND,
.instance_size = sizeof(AudioSndio),
.class_init = audio_sndio_class_init,
},
};
static struct audio_driver sndio_audio_driver = {
.name = "sndio",
.init = sndio_audio_init,
.fini = sndio_audio_fini,
.pcm_ops = &sndio_pcm_ops,
.max_voices_out = INT_MAX,
.max_voices_in = INT_MAX,
.voice_size_out = sizeof(SndioVoice),
.voice_size_in = sizeof(SndioVoice)
};
static void register_audio_sndio(void)
{
audio_driver_register(&sndio_audio_driver);
}
type_init(register_audio_sndio);
DEFINE_TYPES(audio_types)
module_obj(TYPE_AUDIO_SNDIO);
+64 -83
View File
@@ -24,22 +24,33 @@
#include "qemu/timer.h"
#include "qapi/error.h"
#include "ui/qemu-spice.h"
#include "qom/object.h"
#define AUDIO_CAP "spice"
#include "qemu/audio.h"
#include "audio_int.h"
#if SPICE_INTERFACE_PLAYBACK_MAJOR > 1 || SPICE_INTERFACE_PLAYBACK_MINOR >= 3
#define LINE_OUT_SAMPLES (480 * 4)
#else
#define LINE_OUT_SAMPLES (256 * 4)
#endif
#define TYPE_AUDIO_SPICE "audio-spice"
OBJECT_DECLARE_SIMPLE_TYPE(AudioSpice, AUDIO_SPICE)
#if SPICE_INTERFACE_RECORD_MAJOR > 2 || SPICE_INTERFACE_RECORD_MINOR >= 3
static AudioBackendClass *audio_spice_parent_class;
struct AudioSpice {
AudioMixengBackend parent_obj;
};
static bool spice_audio_realize(AudioBackend *abe, Audiodev *dev, Error **errp)
{
if (!using_spice) {
error_setg(errp, "Cannot use spice audio without -spice");
qapi_free_Audiodev(dev);
return false;
}
return audio_spice_parent_class->realize(abe, dev, errp);
}
#define LINE_OUT_SAMPLES (480 * 4)
#define LINE_IN_SAMPLES (480 * 4)
#else
#define LINE_IN_SAMPLES (256 * 4)
#endif
typedef struct SpiceVoiceOut {
HWVoiceOut hw;
@@ -72,37 +83,17 @@ static const SpiceRecordInterface record_sif = {
.base.minor_version = SPICE_INTERFACE_RECORD_MINOR,
};
static void *spice_audio_init(Audiodev *dev, Error **errp)
{
if (!using_spice) {
error_setg(errp, "Cannot use spice audio without -spice");
return NULL;
}
return &spice_audio_init;
}
static void spice_audio_fini (void *opaque)
{
/* nothing */
}
/* playback */
static int line_out_init(HWVoiceOut *hw, struct audsettings *as,
void *drv_opaque)
static int line_out_init(HWVoiceOut *hw, struct audsettings *as)
{
SpiceVoiceOut *out = container_of (hw, SpiceVoiceOut, hw);
struct audsettings settings;
#if SPICE_INTERFACE_PLAYBACK_MAJOR > 1 || SPICE_INTERFACE_PLAYBACK_MINOR >= 3
settings.freq = spice_server_get_best_playback_rate(NULL);
#else
settings.freq = SPICE_INTERFACE_PLAYBACK_FREQ;
#endif
settings.nchannels = SPICE_INTERFACE_PLAYBACK_CHAN;
settings.fmt = AUDIO_FORMAT_S16;
settings.endianness = HOST_BIG_ENDIAN;
settings.big_endian = HOST_BIG_ENDIAN;
audio_pcm_init_info (&hw->info, &settings);
hw->samples = LINE_OUT_SAMPLES;
@@ -110,9 +101,7 @@ static int line_out_init(HWVoiceOut *hw, struct audsettings *as,
out->sin.base.sif = &playback_sif.base;
qemu_spice.add_interface(&out->sin.base);
#if SPICE_INTERFACE_PLAYBACK_MAJOR > 1 || SPICE_INTERFACE_PLAYBACK_MINOR >= 3
spice_server_set_playback_rate(&out->sin, settings.freq);
#endif
return 0;
}
@@ -190,7 +179,6 @@ static void line_out_enable(HWVoiceOut *hw, bool enable)
}
}
#if ((SPICE_INTERFACE_PLAYBACK_MAJOR >= 1) && (SPICE_INTERFACE_PLAYBACK_MINOR >= 2))
static void line_out_volume(HWVoiceOut *hw, Volume *vol)
{
SpiceVoiceOut *out = container_of(hw, SpiceVoiceOut, hw);
@@ -202,23 +190,18 @@ static void line_out_volume(HWVoiceOut *hw, Volume *vol)
spice_server_playback_set_volume(&out->sin, 2, svol);
spice_server_playback_set_mute(&out->sin, vol->mute);
}
#endif
/* record */
static int line_in_init(HWVoiceIn *hw, struct audsettings *as, void *drv_opaque)
static int line_in_init(HWVoiceIn *hw, struct audsettings *as)
{
SpiceVoiceIn *in = container_of (hw, SpiceVoiceIn, hw);
struct audsettings settings;
#if SPICE_INTERFACE_RECORD_MAJOR > 2 || SPICE_INTERFACE_RECORD_MINOR >= 3
settings.freq = spice_server_get_best_record_rate(NULL);
#else
settings.freq = SPICE_INTERFACE_RECORD_FREQ;
#endif
settings.nchannels = SPICE_INTERFACE_RECORD_CHAN;
settings.fmt = AUDIO_FORMAT_S16;
settings.endianness = HOST_BIG_ENDIAN;
settings.big_endian = HOST_BIG_ENDIAN;
audio_pcm_init_info (&hw->info, &settings);
hw->samples = LINE_IN_SAMPLES;
@@ -226,9 +209,7 @@ static int line_in_init(HWVoiceIn *hw, struct audsettings *as, void *drv_opaque)
in->sin.base.sif = &record_sif.base;
qemu_spice.add_interface(&in->sin.base);
#if SPICE_INTERFACE_RECORD_MAJOR > 2 || SPICE_INTERFACE_RECORD_MINOR >= 3
spice_server_set_record_rate(&in->sin, settings.freq);
#endif
return 0;
}
@@ -277,7 +258,6 @@ static void line_in_enable(HWVoiceIn *hw, bool enable)
}
}
#if ((SPICE_INTERFACE_RECORD_MAJOR >= 2) && (SPICE_INTERFACE_RECORD_MINOR >= 2))
static void line_in_volume(HWVoiceIn *hw, Volume *vol)
{
SpiceVoiceIn *in = container_of(hw, SpiceVoiceIn, hw);
@@ -289,46 +269,47 @@ static void line_in_volume(HWVoiceIn *hw, Volume *vol)
spice_server_record_set_volume(&in->sin, 2, svol);
spice_server_record_set_mute(&in->sin, vol->mute);
}
#endif
static struct audio_pcm_ops audio_callbacks = {
.init_out = line_out_init,
.fini_out = line_out_fini,
.write = audio_generic_write,
.buffer_get_free = line_out_get_free,
.get_buffer_out = line_out_get_buffer,
.put_buffer_out = line_out_put_buffer,
.enable_out = line_out_enable,
#if (SPICE_INTERFACE_PLAYBACK_MAJOR >= 1) && \
(SPICE_INTERFACE_PLAYBACK_MINOR >= 2)
.volume_out = line_out_volume,
#endif
.init_in = line_in_init,
.fini_in = line_in_fini,
.read = line_in_read,
.run_buffer_in = audio_generic_run_buffer_in,
.enable_in = line_in_enable,
#if ((SPICE_INTERFACE_RECORD_MAJOR >= 2) && (SPICE_INTERFACE_RECORD_MINOR >= 2))
.volume_in = line_in_volume,
#endif
};
static struct audio_driver spice_audio_driver = {
.name = "spice",
.init = spice_audio_init,
.fini = spice_audio_fini,
.pcm_ops = &audio_callbacks,
.max_voices_out = 1,
.max_voices_in = 1,
.voice_size_out = sizeof (SpiceVoiceOut),
.voice_size_in = sizeof (SpiceVoiceIn),
};
static void register_audio_spice(void)
static void audio_spice_class_init(ObjectClass *klass, const void *data)
{
audio_driver_register(&spice_audio_driver);
AudioBackendClass *b = AUDIO_BACKEND_CLASS(klass);
AudioMixengBackendClass *k = AUDIO_MIXENG_BACKEND_CLASS(klass);
audio_spice_parent_class = AUDIO_BACKEND_CLASS(object_class_get_parent(klass));
b->realize = spice_audio_realize;
k->max_voices_out = 1;
k->max_voices_in = 1;
k->voice_size_out = sizeof(SpiceVoiceOut);
k->voice_size_in = sizeof(SpiceVoiceIn);
k->init_out = line_out_init;
k->fini_out = line_out_fini;
k->write = audio_generic_write;
k->buffer_get_free = line_out_get_free;
k->get_buffer_out = line_out_get_buffer;
k->put_buffer_out = line_out_put_buffer;
k->enable_out = line_out_enable;
k->volume_out = line_out_volume;
k->init_in = line_in_init;
k->fini_in = line_in_fini;
k->read = line_in_read;
k->run_buffer_in = audio_generic_run_buffer_in;
k->enable_in = line_in_enable;
k->volume_in = line_in_volume;
}
type_init(register_audio_spice);
static const TypeInfo audio_types[] = {
{
.name = TYPE_AUDIO_SPICE,
.parent = TYPE_AUDIO_MIXENG_BACKEND,
.instance_size = sizeof(AudioSpice),
.class_init = audio_spice_class_init,
},
};
DEFINE_TYPES(audio_types)
module_obj(TYPE_AUDIO_SPICE);
module_dep("ui-spice-core");
+46
View File
@@ -9,15 +9,39 @@ alsa_read_zero(long len) "Failed to read %ld frames (read zero)"
alsa_xrun_out(void) "Recovering from playback xrun"
alsa_xrun_in(void) "Recovering from capture xrun"
alsa_resume_out(void) "Resuming suspended output stream"
alsa_info_params(int req_fmt, int obt_fmt, int req_channels, int obt_channels, int req_freq, int obt_freq) "format %d->%d, channels %d->%d, frequency %d->%d"
alsa_info_samples(int buffer_length, int period_length, long samples) "requested: buffer len %d, period len %d; obtained: %ld samples"
alsa_fini_out(void) ""
alsa_enable_out(bool enable) "enable=%d"
alsa_enable_in(bool enable) "enable=%d"
# ossaudio.c
oss_version(int version) "OSS version = 0x%x"
oss_out_params(int req_fmt, int obt_fmt, int req_channels, int obt_channels, int req_freq, int obt_freq, int req_nfrags, int obt_nfrags, int req_fragsize, int obt_fragsize) "fmt=%d->%d, channels %d->%d, freq=%d->%d, nfrags=%d->%d, fragsize=%d->%d"
oss_in_params(int req_fmt, int obt_fmt, int req_channels, int obt_channels, int req_freq, int obt_freq, int req_nfrags, int obt_nfrags, int req_fragsize, int obt_fragsize) "fmt=%d->%d, channels %d->%d, freq=%d->%d, nfrags=%d->%d, fragsize=%d->%d"
oss_fini_out(void) ""
oss_enable_out(bool enable) "enable=%d"
oss_enable_in(bool enable) "enable=%d"
# dbusaudio.c
dbus_audio_register(const char *s, const char *dir) "sender = %s, dir = %s"
dbus_audio_put_buffer_out(size_t pos, size_t size) "buf_pos = %zu, buf_size = %zu"
dbus_audio_read(size_t len) "len = %zu"
# dsoundaudio.c
dsound_clear_sample(void *p1, uint32_t blen1, uint32_t len1, void *p2, uint32_t blen2, uint32_t len2) "p1=%p, blen1=%u, len1=%u, p2=%p, blen2=%u, len2=%u"
dsound_wave_format(uint16_t wFormatTag, uint16_t nChannels, uint32_t nSamplesPerSec, uint32_t nAvgBytesPerSec, uint16_t nBlockAlign, uint16_t wBitsPerSample, uint16_t cbSize) "wFormatTag=%u, nChannels=%u, nSamplesPerSec=%u, nAvgBytesPerSec=%u, nBlockAlign=%u, wBitsPerSample=%u, cbSize=%u"
dsound_buffer_bytes(uint32_t caps_bytes, uint32_t desc_bytes) "caps_bytes=%u, desc_bytes=%u"
# jackaudio.c
jack_client_recover(void) "attempting to reconnect to server"
jack_connect(const char *src, const char *dst) "connect %s -> %s"
jack_server_started(void) "server started"
jack_unique_name(const char *name) "unique name assigned %s"
jack_out_init(uint32_t freq, int buffersize) "output configured for %uHz (%d samples)"
jack_in_init(uint32_t freq, int buffersize) "input configured for %uHz (%d samples)"
jack_info(const char *msg) "%s"
# pwaudio.c
pw_state_changed(int nodeid, const char *s) "node id: %d stream state: %s"
pw_read(int32_t avail, uint32_t index, size_t len) "avail=%d index=%u len=%zu"
@@ -26,7 +50,29 @@ pw_vol(const char *ret) "set volume: %s"
pw_period(uint64_t quantum, uint32_t rate) "period =%" PRIu64 "/%u"
pw_audio_init(void) "Initialize PipeWire context"
# audio-be.c
audio_be_set_active_in(void *sw, bool on) "sw=%p, on=%d"
audio_be_set_active_out(void *sw, bool on) "sw=%p, on=%d"
# audio.c
audio_timer_start(int interval) "interval %d ms"
audio_timer_stop(void) ""
audio_timer_delayed(int interval) "interval %d ms"
audio_notify_capture(int cmd) "notification %d sent"
audio_capture_attach(const char *name, bool active) "capture %s active=%d"
# audio-mixeng-be.c
audio_get_avail(const char *name, size_t live, uint32_t frontend_frames) "%s: get_avail live %zu frontend frames %u"
audio_run_poll(const char *msg, int64_t elapsed_us) "Elapsed since last %s: %" PRId64 " us"
audio_capture_free_sw(const char *name) "freeing %s"
audio_out_full(const char *name, size_t live) "%s is full %zu"
audio_sw_write(const char *name, size_t size, size_t written, size_t total_mixed) "%s: write size %zu written %zu total mixed %zu"
audio_get_free(const char *name, size_t live, size_t dead, uint32_t frontend_frames) "%s: get_free live %zu dead %zu frontend frames %u"
audio_out_disable(void) "Disabling voice"
audio_out_played(size_t played) "played=%zu"
audio_rate_reset(int64_t frames) "Resetting rate control (%" PRId64 " frames)"
# audio_template.h
audio_open_out(const char *name, int freq, int nchannels, int fmt) "open %s, freq %d, nchannels %d, fmt %d"
audio_open_in(const char *name, int freq, int nchannels, int fmt) "open %s, freq %d, nchannels %d, fmt %d"
audio_voice_pair(const char *type, const char *name, const char *hw_fmt, int hw_freq, int hw_nchannels, const char *sw_fmt, int sw_freq, int sw_nchannels) "%s: name=%s hw=%s/%d/%d sw=%s/%d/%d"
+47 -54
View File
@@ -24,11 +24,19 @@
#include "qemu/osdep.h"
#include "qemu/module.h"
#include "qemu/error-report.h"
#include "qemu/audio.h"
#include "qom/object.h"
#define AUDIO_CAP "wav"
#include "audio_int.h"
#define TYPE_AUDIO_WAV "audio-wav"
OBJECT_DECLARE_SIMPLE_TYPE(AudioWav, AUDIO_WAV)
struct AudioWav {
AudioMixengBackend parent_obj;
};
typedef struct WAVVoiceOut {
HWVoiceOut hw;
FILE *f;
@@ -43,8 +51,8 @@ static size_t wav_write_out(HWVoiceOut *hw, void *buf, size_t len)
assert(bytes % hw->info.bytes_per_frame == 0);
if (bytes && fwrite(buf, bytes, 1, wav->f) != 1) {
dolog("wav_write_out: fwrite of %" PRId64 " bytes failed\nReason: %s\n",
bytes, strerror(errno));
error_report("wav: fwrite of %" PRId64 " bytes failed: %s",
bytes, strerror(errno));
}
wav->total_samples += bytes / hw->info.bytes_per_frame;
@@ -61,8 +69,7 @@ static void le_store (uint8_t *buf, uint32_t val, int len)
}
}
static int wav_init_out(HWVoiceOut *hw, struct audsettings *as,
void *drv_opaque)
static int wav_init_out(HWVoiceOut *hw, struct audsettings *as)
{
WAVVoiceOut *wav = (WAVVoiceOut *) hw;
int bits16 = 0, stereo = 0;
@@ -72,7 +79,7 @@ static int wav_init_out(HWVoiceOut *hw, struct audsettings *as,
0x02, 0x00, 0x44, 0xac, 0x00, 0x00, 0x10, 0xb1, 0x02, 0x00, 0x04,
0x00, 0x10, 0x00, 0x64, 0x61, 0x74, 0x61, 0x00, 0x00, 0x00, 0x00
};
Audiodev *dev = drv_opaque;
Audiodev *dev = hw->s->dev;
AudiodevWavOptions *wopts = &dev->u.wav;
struct audsettings wav_as = audiodev_to_audsettings(dev->u.wav.out);
const char *wav_path = wopts->path ?: "qemu.wav";
@@ -91,11 +98,11 @@ static int wav_init_out(HWVoiceOut *hw, struct audsettings *as,
case AUDIO_FORMAT_S32:
case AUDIO_FORMAT_U32:
dolog ("WAVE files can not handle 32bit formats\n");
error_report("wav: WAVE files cannot handle 32-bit formats");
return -1;
case AUDIO_FORMAT_F32:
dolog("WAVE files can not handle float formats\n");
error_report("wav: WAVE files cannot handle float formats");
return -1;
default:
@@ -104,7 +111,7 @@ static int wav_init_out(HWVoiceOut *hw, struct audsettings *as,
hdr[34] = bits16 ? 0x10 : 0x08;
wav_as.endianness = 0;
wav_as.big_endian = false;
audio_pcm_init_info (&hw->info, &wav_as);
hw->samples = 1024;
@@ -115,14 +122,13 @@ static int wav_init_out(HWVoiceOut *hw, struct audsettings *as,
wav->f = fopen(wav_path, "wb");
if (!wav->f) {
dolog ("Failed to open wave file `%s'\nReason: %s\n",
wav_path, strerror(errno));
error_report("wav: failed to open wave file '%s': %s",
wav_path, strerror(errno));
return -1;
}
if (fwrite (hdr, sizeof (hdr), 1, wav->f) != 1) {
dolog ("wav_init_out: failed to write header\nReason: %s\n",
strerror(errno));
error_report("wav: failed to write header: %s", strerror(errno));
return -1;
}
@@ -146,30 +152,25 @@ static void wav_fini_out (HWVoiceOut *hw)
le_store (dlen, datalen, 4);
if (fseek (wav->f, 4, SEEK_SET)) {
dolog ("wav_fini_out: fseek to rlen failed\nReason: %s\n",
strerror(errno));
error_report("wav: fseek to rlen failed: %s", strerror(errno));
goto doclose;
}
if (fwrite (rlen, 4, 1, wav->f) != 1) {
dolog ("wav_fini_out: failed to write rlen\nReason: %s\n",
strerror (errno));
error_report("wav: failed to write rlen: %s", strerror(errno));
goto doclose;
}
if (fseek (wav->f, 32, SEEK_CUR)) {
dolog ("wav_fini_out: fseek to dlen failed\nReason: %s\n",
strerror (errno));
error_report("wav: fseek to dlen failed: %s", strerror(errno));
goto doclose;
}
if (fwrite (dlen, 4, 1, wav->f) != 1) {
dolog ("wav_fini_out: failed to write dlen\nReaons: %s\n",
strerror (errno));
error_report("wav: failed to write dlen: %s", strerror(errno));
goto doclose;
}
doclose:
if (fclose (wav->f)) {
dolog ("wav_fini_out: fclose %p failed\nReason: %s\n",
wav->f, strerror (errno));
error_report("wav: fclose failed: %s", strerror(errno));
}
wav->f = NULL;
}
@@ -183,39 +184,31 @@ static void wav_enable_out(HWVoiceOut *hw, bool enable)
}
}
static void *wav_audio_init(Audiodev *dev, Error **errp)
static void audio_wav_class_init(ObjectClass *klass, const void *data)
{
assert(dev->driver == AUDIODEV_DRIVER_WAV);
return dev;
AudioMixengBackendClass *k = AUDIO_MIXENG_BACKEND_CLASS(klass);
k->max_voices_out = 1;
k->max_voices_in = 0;
k->voice_size_out = sizeof(WAVVoiceOut);
k->voice_size_in = 0;
k->init_out = wav_init_out;
k->fini_out = wav_fini_out;
k->write = wav_write_out;
k->buffer_get_free = audio_generic_buffer_get_free;
k->run_buffer_out = audio_generic_run_buffer_out;
k->enable_out = wav_enable_out;
}
static void wav_audio_fini (void *opaque)
{
ldebug ("wav_fini");
}
static struct audio_pcm_ops wav_pcm_ops = {
.init_out = wav_init_out,
.fini_out = wav_fini_out,
.write = wav_write_out,
.buffer_get_free = audio_generic_buffer_get_free,
.run_buffer_out = audio_generic_run_buffer_out,
.enable_out = wav_enable_out,
static const TypeInfo audio_types[] = {
{
.name = TYPE_AUDIO_WAV,
.parent = TYPE_AUDIO_MIXENG_BACKEND,
.instance_size = sizeof(AudioWav),
.class_init = audio_wav_class_init,
}
};
static struct audio_driver wav_audio_driver = {
.name = "wav",
.init = wav_audio_init,
.fini = wav_audio_fini,
.pcm_ops = &wav_pcm_ops,
.max_voices_out = 1,
.max_voices_in = 0,
.voice_size_out = sizeof (WAVVoiceOut),
.voice_size_in = 0
};
static void register_audio_wav(void)
{
audio_driver_register(&wav_audio_driver);
}
type_init(register_audio_wav);
DEFINE_TYPES(audio_types)
module_obj(TYPE_AUDIO_WAV);
+6 -3
View File
@@ -1,4 +1,5 @@
#include "qemu/osdep.h"
#include "qemu/audio.h"
#include "qemu/qemu-print.h"
#include "qemu/error-report.h"
#include "audio_int.h"
@@ -10,6 +11,7 @@ typedef struct {
int freq;
int bits;
int nchannels;
AudioBackend *audio_be;
CaptureVoiceOut *cap;
} WAVState;
@@ -84,7 +86,7 @@ static void wav_capture_destroy (void *opaque)
{
WAVState *wav = opaque;
AUD_del_capture (wav->cap, wav);
audio_be_del_capture(wav->audio_be, wav->cap, wav);
g_free (wav);
}
@@ -135,7 +137,7 @@ int wav_start_capture(AudioBackend *state, CaptureState *s, const char *path,
as.freq = freq;
as.nchannels = 1 << stereo;
as.fmt = bits16 ? AUDIO_FORMAT_S16 : AUDIO_FORMAT_U8;
as.endianness = 0;
as.big_endian = false;
ops.notify = wav_notify;
ops.capture = wav_capture;
@@ -159,6 +161,7 @@ int wav_start_capture(AudioBackend *state, CaptureState *s, const char *path,
return -1;
}
wav->audio_be = state;
wav->path = g_strdup (path);
wav->bits = bits;
wav->nchannels = nchannels;
@@ -169,7 +172,7 @@ int wav_start_capture(AudioBackend *state, CaptureState *s, const char *path,
goto error_free;
}
cap = AUD_add_capture(state, &as, &ops, wav);
cap = audio_be_add_capture(wav->audio_be, &as, &ops, wav);
if (!cap) {
error_report("Failed to add audio capture");
goto error_free;
+3 -6
View File
@@ -53,6 +53,8 @@ typedef struct CryptoDevBackendBuiltinSession {
#define CRYPTODEV_BUITLIN_MAX_AUTH_KEY_LEN 512
#define CRYPTODEV_BUITLIN_MAX_CIPHER_KEY_LEN 64
/* demonstration purposes only, use a limited size to avoid QEMU OOM */
#define CRYPTODEV_BUITLIN_MAX_REQUEST_SIZE (1024 * 1024)
struct CryptoDevBackendBuiltin {
CryptoDevBackend parent_obj;
@@ -98,12 +100,7 @@ static void cryptodev_builtin_init(
1u << QCRYPTODEV_BACKEND_SERVICE_TYPE_MAC;
backend->conf.cipher_algo_l = 1u << VIRTIO_CRYPTO_CIPHER_AES_CBC;
backend->conf.hash_algo = 1u << VIRTIO_CRYPTO_HASH_SHA1;
/*
* Set the Maximum length of crypto request.
* Why this value? Just avoid to overflow when
* memory allocation for each crypto request.
*/
backend->conf.max_size = LONG_MAX - sizeof(CryptoDevBackendOpInfo);
backend->conf.max_size = CRYPTODEV_BUITLIN_MAX_REQUEST_SIZE;
backend->conf.max_cipher_key_len = CRYPTODEV_BUITLIN_MAX_CIPHER_KEY_LEN;
backend->conf.max_auth_key_len = CRYPTODEV_BUITLIN_MAX_AUTH_KEY_LEN;
cryptodev_builtin_init_akcipher(backend);
+1 -1
View File
@@ -218,7 +218,7 @@ static void cryptodev_lkcf_init(CryptoDevBackend *backend, Error **errp)
}
lkcf->eventfd = eventfd(0, 0);
if (lkcf->eventfd < 0) {
error_setg(errp, "Failed to create eventfd: %d", errno);
error_setg_errno(errp, errno, "Failed to create eventfd");
return;
}
+3 -2
View File
@@ -12,7 +12,8 @@
#include "qemu/osdep.h"
#include "system/hostmem.h"
#include "hw/boards.h"
#include "system/ramblock.h"
#include "hw/core/boards.h"
#include "qapi/error.h"
#include "qapi/qapi-builtin-visit.h"
#include "qapi/visitor.h"
@@ -21,7 +22,7 @@
#include "qemu/mmap-alloc.h"
#include "qemu/madvise.h"
#include "qemu/cutils.h"
#include "hw/qdev-core.h"
#include "hw/core/qdev.h"
#ifdef CONFIG_NUMA
#include <numaif.h>
+62 -2
View File
@@ -11,9 +11,15 @@
#include "qemu/osdep.h"
#include "system/igvm-cfg.h"
#include "system/igvm.h"
#include "system/igvm-cfg.h"
#include "system/igvm-internal.h"
#include "system/reset.h"
#include "qom/object_interfaces.h"
#include "hw/core/qdev.h"
#include "hw/core/boards.h"
#include "trace.h"
static char *get_igvm(Object *obj, Error **errp)
{
@@ -28,24 +34,78 @@ static void set_igvm(Object *obj, const char *value, Error **errp)
igvm->filename = g_strdup(value);
}
static ResettableState *igvm_reset_state(Object *obj)
{
IgvmCfg *igvm = IGVM_CFG(obj);
return &igvm->reset_state;
}
static void igvm_reset_enter(Object *obj, ResetType type)
{
trace_igvm_reset_enter(type);
}
static void igvm_reset_hold(Object *obj, ResetType type)
{
MachineState *ms = MACHINE(qdev_get_machine());
IgvmCfg *igvm = IGVM_CFG(obj);
trace_igvm_reset_hold(type);
qigvm_process_file(igvm, ms, false, &error_fatal);
}
static void igvm_reset_exit(Object *obj, ResetType type)
{
trace_igvm_reset_exit(type);
}
static void igvm_complete(UserCreatable *uc, Error **errp)
{
IgvmCfg *igvm = IGVM_CFG(uc);
igvm->file = qigvm_file_init(igvm->filename, errp);
}
OBJECT_DEFINE_TYPE_WITH_INTERFACES(IgvmCfg, igvm_cfg, IGVM_CFG, OBJECT,
{ TYPE_USER_CREATABLE }, { NULL })
{ TYPE_USER_CREATABLE },
{ TYPE_RESETTABLE_INTERFACE },
{ NULL })
static void igvm_cfg_class_init(ObjectClass *oc, const void *data)
{
IgvmCfgClass *igvmc = IGVM_CFG_CLASS(oc);
ResettableClass *rc = RESETTABLE_CLASS(oc);
UserCreatableClass *uc = USER_CREATABLE_CLASS(oc);
object_class_property_add_str(oc, "file", get_igvm, set_igvm);
object_class_property_set_description(oc, "file",
"Set the IGVM filename to use");
igvmc->process = qigvm_process_file;
rc->get_state = igvm_reset_state;
rc->phases.enter = igvm_reset_enter;
rc->phases.hold = igvm_reset_hold;
rc->phases.exit = igvm_reset_exit;
uc->complete = igvm_complete;
}
static void igvm_cfg_init(Object *obj)
{
IgvmCfg *igvm = IGVM_CFG(obj);
igvm->file = -1;
qemu_register_resettable(obj);
}
static void igvm_cfg_finalize(Object *obj)
{
IgvmCfg *igvm = IGVM_CFG(obj);
qemu_unregister_resettable(obj);
if (igvm->file >= 0) {
igvm_free(igvm->file);
}
}
+162 -149
View File
@@ -12,21 +12,20 @@
#include "qemu/osdep.h"
#include "qapi/error.h"
#include "qemu/error-report.h"
#include "qemu/target-info-qapi.h"
#include "system/igvm.h"
#include "system/igvm-cfg.h"
#include "system/igvm-internal.h"
#include "system/memory.h"
#include "system/address-spaces.h"
#include "hw/core/cpu.h"
#include "trace.h"
#include <igvm/igvm.h>
#include <igvm/igvm_defs.h>
typedef struct QIgvmParameterData {
QTAILQ_ENTRY(QIgvmParameterData) next;
uint8_t *data;
uint32_t size;
uint32_t index;
} QIgvmParameterData;
/*
* Some directives are specific to particular confidential computing platforms.
@@ -62,36 +61,19 @@ struct QEMU_PACKED sev_id_authentication {
#define IGVM_SEV_ID_BLOCK_VERSION 1
/*
* QIgvm contains the information required during processing
* of a single IGVM file.
*/
typedef struct QIgvm {
IgvmHandle file;
ConfidentialGuestSupport *cgs;
ConfidentialGuestSupportClass *cgsc;
uint32_t compatibility_mask;
unsigned current_header_index;
QTAILQ_HEAD(, QIgvmParameterData) parameter_data;
IgvmPlatformType platform_type;
/*
* SEV-SNP platforms can contain an ID block and authentication
* that should be verified by the guest.
*/
struct sev_id_block *id_block;
struct sev_id_authentication *id_auth;
/* Define the guest policy for SEV guests */
uint64_t sev_policy;
/* These variables keep track of contiguous page regions */
IGVM_VHS_PAGE_DATA region_prev_page_data;
uint64_t region_start;
unsigned region_start_index;
unsigned region_last_index;
unsigned region_page_count;
} QIgvm;
QIgvmParameterData*
qigvm_find_param_entry(QIgvm *igvm, uint32_t parameter_area_index)
{
QIgvmParameterData *param_entry;
QTAILQ_FOREACH(param_entry, &igvm->parameter_data, next)
{
if (param_entry->index == parameter_area_index) {
return param_entry;
}
}
warn_report("IGVM: No parameter area for index %u", parameter_area_index);
return NULL;
}
static int qigvm_directive_page_data(QIgvm *ctx, const uint8_t *header_data,
Error **errp);
@@ -146,6 +128,8 @@ static struct QIGVMHandler handlers[] = {
qigvm_directive_snp_id_block },
{ IGVM_VHT_GUEST_POLICY, IGVM_HEADER_SECTION_INITIALIZATION,
qigvm_initialization_guest_policy },
{ IGVM_VHT_MADT, IGVM_HEADER_SECTION_DIRECTIVE,
qigvm_directive_madt },
};
static int qigvm_handler(QIgvm *ctx, uint32_t type, Error **errp)
@@ -168,9 +152,17 @@ static int qigvm_handler(QIgvm *ctx, uint32_t type, Error **errp)
(int)header_handle);
return -1;
}
header_data = igvm_get_buffer(ctx->file, header_handle) +
sizeof(IGVM_VHS_VARIABLE_HEADER);
result = handlers[handler].handler(ctx, header_data, errp);
header_data = igvm_get_buffer(ctx->file, header_handle);
if (header_data != NULL) {
header_data += sizeof(IGVM_VHS_VARIABLE_HEADER);
result = handlers[handler].handler(ctx, header_data, errp);
} else {
error_setg(errp,
"IGVM: No buffer for handle %d: "
"(type 0x%X)",
header_handle, type);
result = -1;
}
igvm_free_buffer(ctx->file, header_handle);
return result;
}
@@ -195,7 +187,7 @@ static void *qigvm_prepare_memory(QIgvm *ctx, uint64_t addr, uint64_t size,
error_setg(
errp,
"Processing of IGVM file failed: Could not prepare memory "
"at address 0x%lX due to existing non-RAM region",
"at address 0x%" PRIx64 " due to existing non-RAM region",
addr);
return NULL;
}
@@ -206,7 +198,7 @@ static void *qigvm_prepare_memory(QIgvm *ctx, uint64_t addr, uint64_t size,
error_setg(
errp,
"Processing of IGVM file failed: Could not prepare memory "
"at address 0x%lX: region size exceeded",
"at address 0x%" PRIx64 ": region size exceeded",
addr);
return NULL;
}
@@ -220,14 +212,17 @@ static void *qigvm_prepare_memory(QIgvm *ctx, uint64_t addr, uint64_t size,
g_autofree char *region_name =
g_strdup_printf("igvm.%X", region_identifier);
igvm_pages = g_new0(MemoryRegion, 1);
if (ctx->cgs && ctx->cgs->require_guest_memfd) {
if (ctx->machine_state->cgs &&
ctx->machine_state->cgs->require_guest_memfd) {
if (!memory_region_init_ram_guest_memfd(igvm_pages, NULL,
region_name, size, errp)) {
g_free(igvm_pages);
return NULL;
}
} else {
if (!memory_region_init_ram(igvm_pages, NULL, region_name, size,
errp)) {
g_free(igvm_pages);
return NULL;
}
}
@@ -331,6 +326,11 @@ static int qigvm_process_mem_region(QIgvm *ctx, unsigned start_index,
return -1;
}
data = igvm_get_buffer(ctx->file, data_handle);
if (data == NULL) {
error_setg(errp, "IGVM: No buffer for handle %d", data_handle);
igvm_free_buffer(ctx->file, data_handle);
return -1;
}
memcpy(&region[page_index * page_size], data, data_size);
igvm_free_buffer(ctx->file, data_handle);
}
@@ -340,7 +340,7 @@ static int qigvm_process_mem_region(QIgvm *ctx, unsigned start_index,
* If a confidential guest support object is provided then use it to set the
* guest state.
*/
if (ctx->cgs) {
if (ctx->machine_state->cgs) {
cgs_page_type =
qigvm_type_to_cgs_type(page_type, flags->unmeasured, zero);
if (cgs_page_type < 0) {
@@ -441,8 +441,13 @@ static int qigvm_directive_vp_context(QIgvm *ctx, const uint8_t *header_data,
}
data = (uint8_t *)igvm_get_buffer(ctx->file, data_handle);
if (data == NULL) {
error_setg(errp, "IGVM: No buffer for handle %d", data_handle);
result = -1;
goto exit;
}
if (ctx->cgs) {
if (ctx->machine_state->cgs) {
result = ctx->cgsc->set_guest_state(
vp_context->gpa, data, igvm_get_buffer_size(ctx->file, data_handle),
CGS_PAGE_TYPE_VMSA, vp_context->vp_index, errp);
@@ -456,6 +461,7 @@ static int qigvm_directive_vp_context(QIgvm *ctx, const uint8_t *header_data,
result = -1;
}
exit:
igvm_free_buffer(ctx->file, data_handle);
if (result < 0) {
return result;
@@ -494,31 +500,31 @@ static int qigvm_directive_parameter_insert(QIgvm *ctx,
return 0;
}
QTAILQ_FOREACH(param_entry, &ctx->parameter_data, next)
{
if (param_entry->index == param->parameter_area_index) {
region = qigvm_prepare_memory(ctx, param->gpa, param_entry->size,
ctx->current_header_index, errp);
if (!region) {
return -1;
}
memcpy(region, param_entry->data, param_entry->size);
g_free(param_entry->data);
param_entry->data = NULL;
param_entry = qigvm_find_param_entry(ctx, param->parameter_area_index);
if (param_entry == NULL) {
return 0;
}
/*
* If a confidential guest support object is provided then use it to
* set the guest state.
*/
if (ctx->cgs) {
result = ctx->cgsc->set_guest_state(param->gpa, region,
param_entry->size,
CGS_PAGE_TYPE_UNMEASURED, 0,
errp);
if (result < 0) {
return -1;
}
}
region = qigvm_prepare_memory(ctx, param->gpa, param_entry->size,
ctx->current_header_index, errp);
if (!region) {
return -1;
}
memcpy(region, param_entry->data, param_entry->size);
g_free(param_entry->data);
param_entry->data = NULL;
/*
* If a confidential guest support object is provided then use it to
* set the guest state.
*/
if (ctx->machine_state->cgs) {
result = ctx->cgsc->set_guest_state(param->gpa, region,
param_entry->size,
CGS_PAGE_TYPE_UNMEASURED, 0,
errp);
if (result < 0) {
return -1;
}
}
return 0;
@@ -553,7 +559,7 @@ static int qigvm_directive_memory_map(QIgvm *ctx, const uint8_t *header_data,
ConfidentialGuestMemoryMapEntry cgmm_entry;
int retval = 0;
if (ctx->cgs && ctx->cgsc->get_mem_map_entry) {
if (ctx->machine_state->cgs && ctx->cgsc->get_mem_map_entry) {
get_mem_map_entry = ctx->cgsc->get_mem_map_entry;
} else if (target_arch() == SYS_EMU_TARGET_X86_64) {
@@ -567,58 +573,54 @@ static int qigvm_directive_memory_map(QIgvm *ctx, const uint8_t *header_data,
}
/* Find the parameter area that should hold the memory map */
QTAILQ_FOREACH(param_entry, &ctx->parameter_data, next)
{
if (param_entry->index == param->parameter_area_index) {
max_entry_count =
param_entry->size / sizeof(IGVM_VHS_MEMORY_MAP_ENTRY);
mm_entry = (IGVM_VHS_MEMORY_MAP_ENTRY *)param_entry->data;
param_entry = qigvm_find_param_entry(ctx, param->parameter_area_index);
if (param_entry == NULL) {
return 0;
}
retval = get_mem_map_entry(entry, &cgmm_entry, errp);
while (retval == 0) {
if (entry >= max_entry_count) {
error_setg(
errp,
"IGVM: guest memory map size exceeds parameter area defined in IGVM file");
return -1;
}
mm_entry[entry].starting_gpa_page_number = cgmm_entry.gpa >> 12;
mm_entry[entry].number_of_pages = cgmm_entry.size >> 12;
max_entry_count = param_entry->size / sizeof(IGVM_VHS_MEMORY_MAP_ENTRY);
mm_entry = (IGVM_VHS_MEMORY_MAP_ENTRY *)param_entry->data;
switch (cgmm_entry.type) {
case CGS_MEM_RAM:
mm_entry[entry].entry_type =
IGVM_MEMORY_MAP_ENTRY_TYPE_MEMORY;
break;
case CGS_MEM_RESERVED:
mm_entry[entry].entry_type =
IGVM_MEMORY_MAP_ENTRY_TYPE_PLATFORM_RESERVED;
break;
case CGS_MEM_ACPI:
mm_entry[entry].entry_type =
IGVM_MEMORY_MAP_ENTRY_TYPE_PLATFORM_RESERVED;
break;
case CGS_MEM_NVS:
mm_entry[entry].entry_type =
IGVM_MEMORY_MAP_ENTRY_TYPE_PERSISTENT;
break;
case CGS_MEM_UNUSABLE:
mm_entry[entry].entry_type =
IGVM_MEMORY_MAP_ENTRY_TYPE_PLATFORM_RESERVED;
break;
}
retval = get_mem_map_entry(++entry, &cgmm_entry, errp);
}
if (retval < 0) {
return retval;
}
/* The entries need to be sorted */
qsort(mm_entry, entry, sizeof(IGVM_VHS_MEMORY_MAP_ENTRY),
qigvm_cmp_mm_entry);
retval = get_mem_map_entry(entry, &cgmm_entry, errp);
while (retval == 0) {
if (entry >= max_entry_count) {
error_setg(
errp,
"IGVM: guest memory map size exceeds parameter area defined "
"in IGVM file");
return -1;
}
mm_entry[entry].starting_gpa_page_number = cgmm_entry.gpa >> 12;
mm_entry[entry].number_of_pages = cgmm_entry.size >> 12;
switch (cgmm_entry.type) {
case CGS_MEM_RAM:
mm_entry[entry].entry_type = IGVM_MEMORY_MAP_ENTRY_TYPE_MEMORY;
break;
case CGS_MEM_RESERVED:
mm_entry[entry].entry_type =
IGVM_MEMORY_MAP_ENTRY_TYPE_PLATFORM_RESERVED;
break;
case CGS_MEM_ACPI:
mm_entry[entry].entry_type =
IGVM_MEMORY_MAP_ENTRY_TYPE_PLATFORM_RESERVED;
break;
case CGS_MEM_NVS:
mm_entry[entry].entry_type = IGVM_MEMORY_MAP_ENTRY_TYPE_PERSISTENT;
break;
case CGS_MEM_UNUSABLE:
mm_entry[entry].entry_type =
IGVM_MEMORY_MAP_ENTRY_TYPE_PLATFORM_RESERVED;
break;
}
retval = get_mem_map_entry(++entry, &cgmm_entry, errp);
}
if (retval < 0) {
return retval;
}
/* The entries need to be sorted */
qsort(mm_entry, entry, sizeof(IGVM_VHS_MEMORY_MAP_ENTRY),
qigvm_cmp_mm_entry);
return 0;
}
@@ -630,18 +632,18 @@ static int qigvm_directive_vp_count(QIgvm *ctx, const uint8_t *header_data,
uint32_t *vp_count;
CPUState *cpu;
QTAILQ_FOREACH(param_entry, &ctx->parameter_data, next)
{
if (param_entry->index == param->parameter_area_index) {
vp_count = (uint32_t *)(param_entry->data + param->byte_offset);
*vp_count = 0;
CPU_FOREACH(cpu)
{
(*vp_count)++;
}
break;
}
param_entry = qigvm_find_param_entry(ctx, param->parameter_area_index);
if (param_entry == NULL) {
return 0;
}
vp_count = (uint32_t *)(param_entry->data + param->byte_offset);
*vp_count = 0;
CPU_FOREACH(cpu)
{
(*vp_count)++;
}
return 0;
}
@@ -653,15 +655,15 @@ static int qigvm_directive_environment_info(QIgvm *ctx,
QIgvmParameterData *param_entry;
IgvmEnvironmentInfo *environmental_state;
QTAILQ_FOREACH(param_entry, &ctx->parameter_data, next)
{
if (param_entry->index == param->parameter_area_index) {
environmental_state =
(IgvmEnvironmentInfo *)(param_entry->data + param->byte_offset);
environmental_state->memory_is_shared = 1;
break;
}
param_entry = qigvm_find_param_entry(ctx, param->parameter_area_index);
if (param_entry == NULL) {
return 0;
}
environmental_state =
(IgvmEnvironmentInfo *)(param_entry->data + param->byte_offset);
environmental_state->memory_is_shared = 1;
return 0;
}
@@ -683,7 +685,7 @@ static int qigvm_directive_required_memory(QIgvm *ctx,
if (!region) {
return -1;
}
if (ctx->cgs) {
if (ctx->machine_state->cgs) {
result =
ctx->cgsc->set_guest_state(mem->gpa, region, mem->number_of_bytes,
CGS_PAGE_TYPE_REQUIRED_MEMORY, 0, errp);
@@ -797,18 +799,24 @@ static int qigvm_supported_platform_compat_mask(QIgvm *ctx, Error **errp)
}
platform =
(IGVM_VHS_SUPPORTED_PLATFORM *)(igvm_get_buffer(ctx->file,
header_handle) +
sizeof(
IGVM_VHS_VARIABLE_HEADER));
header_handle));
if (platform == NULL) {
error_setg(errp, "IGVM: No buffer for handle %d", header_handle);
igvm_free_buffer(ctx->file, header_handle);
return -1;
}
platform = (IGVM_VHS_SUPPORTED_PLATFORM *)((void *)platform
+ sizeof(IGVM_VHS_VARIABLE_HEADER));
if ((platform->platform_type == IGVM_PLATFORM_TYPE_SEV_ES) &&
ctx->cgs) {
ctx->machine_state->cgs) {
if (ctx->cgsc->check_support(
CGS_PLATFORM_SEV_ES, platform->platform_version,
platform->highest_vtl, platform->shared_gpa_boundary)) {
compatibility_mask_sev_es = platform->compatibility_mask;
}
} else if ((platform->platform_type == IGVM_PLATFORM_TYPE_SEV) &&
ctx->cgs) {
ctx->machine_state->cgs) {
if (ctx->cgsc->check_support(
CGS_PLATFORM_SEV, platform->platform_version,
platform->highest_vtl, platform->shared_gpa_boundary)) {
@@ -816,7 +824,7 @@ static int qigvm_supported_platform_compat_mask(QIgvm *ctx, Error **errp)
}
} else if ((platform->platform_type ==
IGVM_PLATFORM_TYPE_SEV_SNP) &&
ctx->cgs) {
ctx->machine_state->cgs) {
if (ctx->cgsc->check_support(
CGS_PLATFORM_SEV_SNP, platform->platform_version,
platform->highest_vtl, platform->shared_gpa_boundary)) {
@@ -867,7 +875,7 @@ static int qigvm_handle_policy(QIgvm *ctx, Error **errp)
return 0;
}
static IgvmHandle qigvm_file_init(char *filename, Error **errp)
IgvmHandle qigvm_file_init(char *filename, Error **errp)
{
IgvmHandle igvm;
g_autofree uint8_t *buf = NULL;
@@ -884,10 +892,12 @@ static IgvmHandle qigvm_file_init(char *filename, Error **errp)
error_setg(errp, "Unable to parse IGVM file %s: %d", filename, igvm);
return -1;
}
trace_igvm_file_loaded(filename, igvm);
return igvm;
}
int qigvm_process_file(IgvmCfg *cfg, ConfidentialGuestSupport *cgs,
int qigvm_process_file(IgvmCfg *cfg, MachineState *machine_state,
bool onlyVpContext, Error **errp)
{
int32_t header_count;
@@ -896,18 +906,23 @@ int qigvm_process_file(IgvmCfg *cfg, ConfidentialGuestSupport *cgs,
QIgvm ctx;
memset(&ctx, 0, sizeof(ctx));
ctx.file = qigvm_file_init(cfg->filename, errp);
if (ctx.file < 0) {
if (cfg->file < 0) {
error_setg(errp, "No IGVM file loaded.");
return -1;
}
ctx.file = cfg->file;
trace_igvm_process_file(cfg->file, onlyVpContext);
ctx.machine_state = machine_state;
/*
* The ConfidentialGuestSupport object is optional and allows a confidential
* guest platform to perform extra processing, such as page measurement, on
* IGVM directives.
*/
ctx.cgs = cgs;
ctx.cgsc = cgs ? CONFIDENTIAL_GUEST_SUPPORT_GET_CLASS(cgs) : NULL;
ctx.cgsc = machine_state->cgs ?
CONFIDENTIAL_GUEST_SUPPORT_GET_CLASS(machine_state->cgs) :
NULL;
/*
* Check that the IGVM file provides configuration for the current
@@ -990,7 +1005,5 @@ cleanup_parameters:
g_free(ctx.id_auth);
cleanup:
igvm_free(ctx.file);
return retval;
}
+112 -3
View File
@@ -82,6 +82,9 @@ static void iommufd_backend_complete(UserCreatable *uc, Error **errp)
} else {
cpr_save_fd(name, 0, be->fd);
}
} else if (!g_file_test("/dev/iommu", G_FILE_TEST_EXISTS)) {
error_setg(errp, "/dev/iommu does not exist"
" (is your kernel config missing CONFIG_IOMMUFD?)");
}
}
@@ -361,7 +364,7 @@ bool iommufd_backend_get_dirty_bitmap(IOMMUFDBackend *be,
uint32_t hwpt_id,
uint64_t iova, ram_addr_t size,
uint64_t page_size, uint64_t *data,
Error **errp)
uint64_t flags, Error **errp)
{
int ret;
struct iommu_hwpt_get_dirty_bitmap get_dirty_bitmap = {
@@ -371,11 +374,12 @@ bool iommufd_backend_get_dirty_bitmap(IOMMUFDBackend *be,
.length = size,
.page_size = page_size,
.data = (uintptr_t)data,
.flags = flags,
};
ret = ioctl(be->fd, IOMMU_HWPT_GET_DIRTY_BITMAP, &get_dirty_bitmap);
trace_iommufd_backend_get_dirty_bitmap(be->fd, hwpt_id, iova, size,
page_size, ret ? errno : 0);
flags, page_size, ret ? errno : 0);
if (ret) {
error_setg_errno(errp, errno,
"IOMMU_HWPT_GET_DIRTY_BITMAP (iova: 0x%"HWADDR_PRIx
@@ -388,7 +392,8 @@ bool iommufd_backend_get_dirty_bitmap(IOMMUFDBackend *be,
bool iommufd_backend_get_device_info(IOMMUFDBackend *be, uint32_t devid,
uint32_t *type, void *data, uint32_t len,
uint64_t *caps, Error **errp)
uint64_t *caps, uint8_t *max_pasid_log2,
Error **errp)
{
struct iommu_hw_info info = {
.size = sizeof(info),
@@ -407,6 +412,9 @@ bool iommufd_backend_get_device_info(IOMMUFDBackend *be, uint32_t devid,
g_assert(caps);
*caps = info.out_capabilities;
if (max_pasid_log2) {
*max_pasid_log2 = info.out_max_pasid_log2;
}
return true;
}
@@ -446,6 +454,90 @@ bool iommufd_backend_invalidate_cache(IOMMUFDBackend *be, uint32_t id,
return !ret;
}
bool iommufd_backend_alloc_viommu(IOMMUFDBackend *be, uint32_t dev_id,
uint32_t viommu_type, uint32_t hwpt_id,
uint32_t *out_viommu_id, Error **errp)
{
int ret;
struct iommu_viommu_alloc alloc_viommu = {
.size = sizeof(alloc_viommu),
.type = viommu_type,
.dev_id = dev_id,
.hwpt_id = hwpt_id,
};
ret = ioctl(be->fd, IOMMU_VIOMMU_ALLOC, &alloc_viommu);
trace_iommufd_backend_alloc_viommu(be->fd, dev_id, viommu_type, hwpt_id,
alloc_viommu.out_viommu_id, ret);
if (ret) {
error_setg_errno(errp, errno, "IOMMU_VIOMMU_ALLOC failed");
return false;
}
g_assert(out_viommu_id);
*out_viommu_id = alloc_viommu.out_viommu_id;
return true;
}
bool iommufd_backend_alloc_vdev(IOMMUFDBackend *be, uint32_t dev_id,
uint32_t viommu_id, uint64_t virt_id,
uint32_t *out_vdev_id, Error **errp)
{
int ret;
struct iommu_vdevice_alloc alloc_vdev = {
.size = sizeof(alloc_vdev),
.viommu_id = viommu_id,
.dev_id = dev_id,
.virt_id = virt_id,
};
ret = ioctl(be->fd, IOMMU_VDEVICE_ALLOC, &alloc_vdev);
trace_iommufd_backend_alloc_vdev(be->fd, dev_id, viommu_id, virt_id,
alloc_vdev.out_vdevice_id, ret);
if (ret) {
error_setg_errno(errp, errno, "IOMMU_VDEVICE_ALLOC failed");
return false;
}
g_assert(out_vdev_id);
*out_vdev_id = alloc_vdev.out_vdevice_id;
return true;
}
bool iommufd_backend_alloc_veventq(IOMMUFDBackend *be, uint32_t viommu_id,
uint32_t type, uint32_t depth,
uint32_t *out_veventq_id,
uint32_t *out_veventq_fd, Error **errp)
{
int ret;
struct iommu_veventq_alloc alloc_veventq = {
.size = sizeof(alloc_veventq),
.flags = 0,
.type = type,
.veventq_depth = depth,
.viommu_id = viommu_id,
};
ret = ioctl(be->fd, IOMMU_VEVENTQ_ALLOC, &alloc_veventq);
trace_iommufd_viommu_alloc_eventq(be->fd, viommu_id, type,
alloc_veventq.out_veventq_id,
alloc_veventq.out_veventq_fd, ret);
if (ret) {
error_setg_errno(errp, errno, "IOMMU_VEVENTQ_ALLOC failed");
return false;
}
g_assert(out_veventq_id);
g_assert(out_veventq_fd);
*out_veventq_id = alloc_veventq.out_veventq_id;
*out_veventq_fd = alloc_veventq.out_veventq_fd;
return true;
}
bool host_iommu_device_iommufd_attach_hwpt(HostIOMMUDeviceIOMMUFD *idev,
uint32_t hwpt_id, Error **errp)
{
@@ -481,11 +573,28 @@ static int hiod_iommufd_get_cap(HostIOMMUDevice *hiod, int cap, Error **errp)
}
}
static bool hiod_iommufd_get_pasid_info(HostIOMMUDevice *hiod,
PasidInfo *pasid_info)
{
HostIOMMUDeviceCaps *caps = &hiod->caps;
if (!caps->max_pasid_log2) {
return false;
}
g_assert(pasid_info);
pasid_info->exec_perm = (caps->hw_caps & IOMMU_HW_CAP_PCI_PASID_EXEC);
pasid_info->priv_mod = (caps->hw_caps & IOMMU_HW_CAP_PCI_PASID_PRIV);
pasid_info->max_pasid_log2 = caps->max_pasid_log2;
return true;
}
static void hiod_iommufd_class_init(ObjectClass *oc, const void *data)
{
HostIOMMUDeviceClass *hioc = HOST_IOMMU_DEVICE_CLASS(oc);
hioc->get_cap = hiod_iommufd_get_cap;
hioc->get_pasid_info = hiod_iommufd_get_pasid_info;
};
static const TypeInfo types[] = {
+4 -4
View File
@@ -13,8 +13,8 @@
#include "qemu/osdep.h"
#include "system/spdm-socket.h"
#include "qapi/error.h"
#include "hw/qdev-properties.h"
#include "hw/qdev-properties-system.h"
#include "hw/core/qdev-properties.h"
#include "hw/core/qdev-properties-system.h"
#include "hw/core/qdev-prop-internal.h"
static bool read_bytes(const int socket, uint8_t *buffer,
@@ -167,7 +167,7 @@ int spdm_socket_connect(uint16_t port, Error **errp)
client_socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (client_socket < 0) {
error_setg(errp, "cannot create socket: %s", strerror(errno));
error_setg_errno(errp, errno, "cannot create socket");
return -1;
}
@@ -179,7 +179,7 @@ int spdm_socket_connect(uint16_t port, Error **errp)
if (connect(client_socket, (struct sockaddr *)&server_addr,
sizeof(server_addr)) < 0) {
error_setg(errp, "cannot connect: %s", strerror(errno));
error_setg_errno(errp, errno, "cannot connect");
close(client_socket);
return -1;
}
+24 -38
View File
@@ -225,8 +225,7 @@ static int tpm_emulator_set_locality(TPMEmulator *tpm_emu, uint8_t locty_number,
if (tpm_emulator_ctrlcmd(tpm_emu, CMD_SET_LOCALITY, &loc,
sizeof(loc), sizeof(loc.u.resp.tpm_result),
sizeof(loc)) < 0) {
error_setg(errp, "tpm-emulator: could not set locality : %s",
strerror(errno));
error_setg(errp, "tpm-emulator: could not set locality");
return -1;
}
@@ -264,7 +263,7 @@ static int tpm_emulator_probe_caps(TPMEmulator *tpm_emu)
if (tpm_emulator_ctrlcmd(tpm_emu, CMD_GET_CAPABILITY, &cap_n, 0,
sizeof(cap_n.u.resp.tpm_result),
sizeof(cap_n)) < 0) {
error_report("tpm-emulator: probing failed : %s", strerror(errno));
error_report("tpm-emulator: probing failed");
return -1;
}
@@ -315,8 +314,7 @@ static int tpm_emulator_stop_tpm(TPMBackend *tb, Error **errp)
if (tpm_emulator_ctrlcmd(tpm_emu, CMD_STOP, &res, 0,
sizeof(ptm_res), sizeof(res)) < 0) {
error_setg(errp, "tpm-emulator: Could not stop TPM: %s",
strerror(errno));
error_setg(errp, "tpm-emulator: Could not stop TPM");
return -1;
}
@@ -344,8 +342,7 @@ static int tpm_emulator_lock_storage(TPMEmulator *tpm_emu)
if (tpm_emulator_ctrlcmd(tpm_emu, CMD_LOCK_STORAGE, &pls, sizeof(pls.u.req),
sizeof(pls.u.resp.tpm_result),
sizeof(pls.u.resp)) < 0) {
error_report("tpm-emulator: Could not lock storage within 3 seconds: "
"%s", strerror(errno));
error_report("tpm-emulator: Could not lock storage within 3 seconds");
return -1;
}
@@ -377,8 +374,7 @@ static int tpm_emulator_set_buffer_size(TPMBackend *tb,
if (tpm_emulator_ctrlcmd(tpm_emu, CMD_SET_BUFFERSIZE, &psbs,
sizeof(psbs.u.req), sizeof(psbs.u.resp.tpm_result),
sizeof(psbs.u.resp)) < 0) {
error_setg(errp, "tpm-emulator: Could not set buffer size: %s",
strerror(errno));
error_setg(errp, "tpm-emulator: Could not set buffer size");
return -1;
}
@@ -426,8 +422,7 @@ static int tpm_emulator_startup_tpm_resume(TPMBackend *tb, size_t buffersize,
if (tpm_emulator_ctrlcmd(tpm_emu, CMD_INIT, &init, sizeof(init),
sizeof(init.u.resp.tpm_result),
sizeof(init)) < 0) {
error_setg(errp, "tpm-emulator: could not send INIT: %s",
strerror(errno));
error_setg(errp, "tpm-emulator: could not send INIT");
goto err_exit;
}
@@ -482,8 +477,7 @@ static bool tpm_emulator_get_tpm_established_flag(TPMBackend *tb)
if (tpm_emulator_ctrlcmd(tpm_emu, CMD_GET_TPMESTABLISHED, &est, 0,
sizeof(est) /* always returns resp.bit */,
sizeof(est)) < 0) {
error_report("tpm-emulator: Could not get the TPM established flag: %s",
strerror(errno));
error_report("tpm-emulator: Could not get the TPM established flag");
return false;
}
trace_tpm_emulator_get_tpm_established_flag(est.u.resp.bit);
@@ -511,8 +505,7 @@ static int tpm_emulator_reset_tpm_established_flag(TPMBackend *tb,
&reset_est, sizeof(reset_est),
sizeof(reset_est.u.resp.tpm_result),
sizeof(reset_est)) < 0) {
error_report("tpm-emulator: Could not reset the establishment bit: %s",
strerror(errno));
error_report("tpm-emulator: Could not reset the establishment bit");
return -1;
}
@@ -542,8 +535,7 @@ static void tpm_emulator_cancel_cmd(TPMBackend *tb)
/* FIXME: make the function non-blocking, or it may block a VCPU */
if (tpm_emulator_ctrlcmd(tpm_emu, CMD_CANCEL_TPM_CMD, &res, 0,
sizeof(ptm_res), sizeof(res)) < 0) {
error_report("tpm-emulator: Could not cancel command: %s",
strerror(errno));
error_report("tpm-emulator: Could not cancel command");
} else if (res != 0) {
error_report("tpm-emulator: Failed to cancel TPM: 0x%x",
be32_to_cpu(res));
@@ -560,8 +552,10 @@ static TPMVersion tpm_emulator_get_tpm_version(TPMBackend *tb)
static size_t tpm_emulator_get_buffer_size(TPMBackend *tb)
{
size_t actual_size;
Error *local_err = NULL;
if (tpm_emulator_set_buffer_size(tb, 0, &actual_size, NULL) < 0) {
if (tpm_emulator_set_buffer_size(tb, 0, &actual_size, &local_err) < 0) {
error_report_err(local_err);
return 4096;
}
@@ -602,8 +596,7 @@ static int tpm_emulator_prepare_data_fd(TPMEmulator *tpm_emu)
if (tpm_emulator_ctrlcmd(tpm_emu, CMD_SET_DATAFD, &res, 0,
sizeof(ptm_res), sizeof(res)) < 0 || res != 0) {
error_report("tpm-emulator: Failed to send CMD_SET_DATAFD: %s",
strerror(errno));
error_report("tpm-emulator: Failed to send CMD_SET_DATAFD");
goto err_exit;
}
@@ -660,8 +653,8 @@ static int tpm_emulator_handle_device_opts(TPMEmulator *tpm_emu, QemuOpts *opts)
*/
if (tpm_util_test_tpmdev(QIO_CHANNEL_SOCKET(tpm_emu->data_ioc)->fd,
&tpm_emu->tpm_version)) {
error_report("'%s' is not emulating TPM device. Error: %s",
tpm_emu->options->chardev, strerror(errno));
error_report("'%s' is not emulating TPM device.",
tpm_emu->options->chardev);
goto err;
}
@@ -751,8 +744,7 @@ static int tpm_emulator_get_state_blob(TPMEmulator *tpm_emu,
/* always returns up to resp.data */
offsetof(ptm_getstate, u.resp.data),
offsetof(ptm_getstate, u.resp.data)) < 0) {
error_report("tpm-emulator: could not get state blob type %d : %s",
type, strerror(errno));
error_report("tpm-emulator: could not get state blob type %d", type);
return -1;
}
@@ -854,9 +846,8 @@ static int tpm_emulator_set_state_blob(TPMEmulator *tpm_emu,
/* write the header only */
if (tpm_emulator_ctrlcmd(tpm_emu, CMD_SET_STATEBLOB, &pss,
offsetof(ptm_setstate, u.req.data), 0, 0) < 0) {
error_setg_errno(errp, errno,
"tpm-emulator: could not set state blob type %d",
type);
error_setg(errp, "tpm-emulator: could not set state blob type %d",
type);
return -1;
}
@@ -894,10 +885,8 @@ static int tpm_emulator_set_state_blob(TPMEmulator *tpm_emu,
/*
* Set all the TPM state blobs.
*
* Returns a negative errno code in case of error.
*/
static int tpm_emulator_set_state_blobs(TPMBackend *tb, Error **errp)
static bool tpm_emulator_set_state_blobs(TPMBackend *tb, Error **errp)
{
TPMEmulator *tpm_emu = TPM_EMULATOR(tb);
TPMBlobBuffers *state_blobs = &tpm_emu->state_blobs;
@@ -906,7 +895,7 @@ static int tpm_emulator_set_state_blobs(TPMBackend *tb, Error **errp)
if (tpm_emulator_stop_tpm(tb, errp) < 0) {
trace_tpm_emulator_set_state_blobs_error("Could not stop TPM");
return -EIO;
return false;
}
if (tpm_emulator_set_state_blob(tpm_emu, PTM_BLOB_TYPE_PERMANENT,
@@ -918,12 +907,12 @@ static int tpm_emulator_set_state_blobs(TPMBackend *tb, Error **errp)
tpm_emulator_set_state_blob(tpm_emu, PTM_BLOB_TYPE_SAVESTATE,
&state_blobs->savestate,
state_blobs->savestate_flags, errp) < 0) {
return -EIO;
return false;
}
trace_tpm_emulator_set_state_blobs_done();
return 0;
return true;
}
static int tpm_emulator_pre_save(void *opaque)
@@ -966,10 +955,8 @@ static void tpm_emulator_vm_state_change(void *opaque, bool running,
static bool tpm_emulator_post_load(void *opaque, int version_id, Error **errp)
{
TPMBackend *tb = opaque;
int ret;
ret = tpm_emulator_set_state_blobs(tb, errp);
if (ret < 0) {
if (!tpm_emulator_set_state_blobs(tb, errp)) {
return false;
}
@@ -1038,8 +1025,7 @@ static void tpm_emulator_shutdown(TPMEmulator *tpm_emu)
if (tpm_emulator_ctrlcmd(tpm_emu, CMD_SHUTDOWN, &res, 0,
sizeof(ptm_res), sizeof(res)) < 0) {
error_report("tpm-emulator: Could not cleanly shutdown the TPM: %s",
strerror(errno));
error_report("tpm-emulator: Could not cleanly shutdown the TPM");
} else if (res != 0) {
error_report("tpm-emulator: TPM result for shutdown: 0x%x %s",
be32_to_cpu(res), tpm_emulator_strerror(be32_to_cpu(res)));
+2 -1
View File
@@ -26,7 +26,7 @@
#include "qapi/visitor.h"
#include "tpm_int.h"
#include "system/memory.h"
#include "hw/qdev-properties.h"
#include "hw/core/qdev-properties.h"
#include "system/tpm_backend.h"
#include "system/tpm_util.h"
#include "trace.h"
@@ -72,6 +72,7 @@ static void release_tpm(Object *obj, const char *name, void *opaque)
if (*be) {
tpm_backend_reset(*be);
*be = NULL;
}
}
+11 -1
View File
@@ -19,5 +19,15 @@ iommufd_backend_alloc_ioas(int iommufd, uint32_t ioas) " iommufd=%d ioas=%d"
iommufd_backend_alloc_hwpt(int iommufd, uint32_t dev_id, uint32_t pt_id, uint32_t flags, uint32_t hwpt_type, uint32_t len, uint64_t data_ptr, uint32_t out_hwpt_id, int ret) " iommufd=%d dev_id=%u pt_id=%u flags=0x%x hwpt_type=%u len=%u data_ptr=0x%"PRIx64" out_hwpt=%u (%d)"
iommufd_backend_free_id(int iommufd, uint32_t id, int ret) " iommufd=%d id=%d (%d)"
iommufd_backend_set_dirty(int iommufd, uint32_t hwpt_id, bool start, int ret) " iommufd=%d hwpt=%u enable=%d (%d)"
iommufd_backend_get_dirty_bitmap(int iommufd, uint32_t hwpt_id, uint64_t iova, uint64_t size, uint64_t page_size, int ret) " iommufd=%d hwpt=%u iova=0x%"PRIx64" size=0x%"PRIx64" page_size=0x%"PRIx64" (%d)"
iommufd_backend_get_dirty_bitmap(int iommufd, uint32_t hwpt_id, uint64_t iova, uint64_t size, uint64_t flags, uint64_t page_size, int ret) " iommufd=%d hwpt=%u iova=0x%"PRIx64" size=0x%"PRIx64" flags=0x%"PRIx64" page_size=0x%"PRIx64" (%d)"
iommufd_backend_invalidate_cache(int iommufd, uint32_t id, uint32_t data_type, uint32_t entry_len, uint32_t entry_num, uint32_t done_num, uint64_t data_ptr, int ret) " iommufd=%d id=%u data_type=%u entry_len=%u entry_num=%u done_num=%u data_ptr=0x%"PRIx64" (%d)"
iommufd_backend_alloc_viommu(int iommufd, uint32_t dev_id, uint32_t type, uint32_t hwpt_id, uint32_t viommu_id, int ret) " iommufd=%d type=%u dev_id=%u hwpt_id=%u viommu_id=%u (%d)"
iommufd_backend_alloc_vdev(int iommufd, uint32_t dev_id, uint32_t viommu_id, uint64_t virt_id, uint32_t vdev_id, int ret) " iommufd=%d dev_id=%u viommu_id=%u virt_id=0x%"PRIx64" vdev_id=%u (%d)"
iommufd_viommu_alloc_eventq(int iommufd, uint32_t viommu_id, uint32_t type, uint32_t veventq_id, uint32_t veventq_fd, int ret) " iommufd=%d viommu_id=%u type=%u veventq_id=%u veventq_fd=%u (%d)"
# igvm-cfg.c
igvm_reset_enter(int type) "type=%u"
igvm_reset_hold(int type) "type=%u"
igvm_reset_exit(int type) "type=%u"
igvm_file_loaded(const char *fn, int32_t handle) "fn=%s, handle=0x%x"
igvm_process_file(int32_t handle, bool context_only) "handle=0x%x context-only=%d"
+3 -3
View File
@@ -8477,7 +8477,7 @@ static bool bdrv_bsc_range_overlaps_locked(BlockDriverState *bs,
}
/**
* See block_int.h for this function's documentation.
* See block_int-io.h for this function's documentation.
*/
bool bdrv_bsc_is_data(BlockDriverState *bs, int64_t offset, int64_t *pnum)
{
@@ -8487,7 +8487,7 @@ bool bdrv_bsc_is_data(BlockDriverState *bs, int64_t offset, int64_t *pnum)
}
/**
* See block_int.h for this function's documentation.
* See block_int-io.h for this function's documentation.
*/
void bdrv_bsc_invalidate_range(BlockDriverState *bs,
int64_t offset, int64_t bytes)
@@ -8501,7 +8501,7 @@ void bdrv_bsc_invalidate_range(BlockDriverState *bs,
}
/**
* See block_int.h for this function's documentation.
* See block_int-io.h for this function's documentation.
*/
void bdrv_bsc_fill(BlockDriverState *bs, int64_t offset, int64_t bytes)
{
+9 -1
View File
@@ -73,7 +73,6 @@ bool block_acct_setup(BlockAcctStats *stats, enum OnOffAuto account_invalid,
}
block_acct_add_interval(stats, stats_intervals[i]);
}
g_free(stats_intervals);
}
return true;
}
@@ -186,6 +185,15 @@ int block_latency_histogram_set(BlockAcctStats *stats, enum BlockAcctType type,
prev = entry->value;
}
/*
* block_latency_histogram_account() assumes that it can always access
* hist->boundaries[0], so require at least one boundary. A histogram with
* a single bin is useless anyway.
*/
if (new_nbins <= 1) {
return -EINVAL;
}
hist->nbins = new_nbins;
g_free(hist->boundaries);
hist->boundaries = g_new(uint64_t, hist->nbins - 1);
Loaded 100 of 3784 files, more files were not shown because too many files have changed in this diff. Show more