Currently we check the name of the NamedGPIOList when doing
irq_intercept_out, but not for irq_intercept_in. Even though we
don't currently support irq_intercept_in on named GPIO lines, we
still need to check the name, because otherwise we will install the
observer on every set of GPIO inputs the device has, rather than only
for the unnamed GPIO inputs.
This doesn't currently affect any test cases, because of all the
tests which use irq_intercept_in only tests/qtest-l2vic-test.c uses
it on a device that creates named GPIO inputs. That device has both
unnamed GPIO inputs and a named GPIO input "reset". The effect is
that a change in the "reset" line state looks like a change in
interrupt input line 0; but since the test doesn't cause "reset" to
change this doesn't happen and there are no observable effects of the
bug.
Check the ngl->name against the specified one for both input
and output interception. (Currently this will be equivalent to
a check against NULL for input intercepts.) As we're now checking
for an exact name match unconditionally, we can break out of the
loop as soon as we've found it.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Fabiano Rosas <farosas@suse.de>
Signed-off-by: Fabiano Rosas <farosas@suse.de>
The current implementation of the irq_intercept_out and
irq_intercept_in commands uses a fixed-size static irq_levels[] array
to track the state of the intercepted IRQ lines. This is sized at
MAX_IRQ == 256, which is smaller than some real device models use
(for instance the GICv2 on the virt board has 384 inputs). A test
that tried to intercept the inputs to such a device and then assert
an interrupt over 255 would overrun the array.
Reimplement the IRQ interception so that it allocates an array
of the required size rather than using a static one.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Fabiano Rosas <farosas@suse.de>
Signed-off-by: Fabiano Rosas <farosas@suse.de>
pci, vhost, virtio, iommu, acpi: features, fixes
multiboot can again load 64 bit images
vdpa-dev now implements guest_notifier_mask/pending
pci bridge can now configure the negotiated bandwidth
tap can now auto-detect host mtu and expose to guest
amd iommu can now attach on non system bus
vhost-user spec now has its own mailing list
Fixes, cleanups all over the place.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
# -----BEGIN PGP SIGNATURE-----
#
# iQFDBAABCgAtFiEEXQn9CHHI+FuUyooNKB8NuNKNVGkFAmrjkJ0PHG1zdEByZWRo
# YXQuY29tAAoJECgfDbjSjVRpY1YH/0r+PhxgcRVVrroGkIxaTaPfOpTj1UkGPmND
# OcjcVCKPXBJF+rve1ZOE4HF8VvbEU1fD1tJ6w+Hto78tjmaVEDvE7gVbhX3YRHv9
# LubC75aTJBYixn/wcS/LUyLAf50+3DD3T+yy83obaJmxHwFyO3CJh2CIMSQxTbSe
# zGPA0noriSSMKEnfbTtikj6NHvFIhdnYipkUaWjGefEbdzXumBhcAF2C7eee9H5m
# 1Nz1Zvjx7BMoArviiZ6EWpGwWPBp0fKwTa7Idcv9K5v6YfWhgVp/gPploCCvulEA
# SMYRqQbbQ41801jR8kY9mV5w5ZFUeNENqplbOR3y6dYtr2w+H2k=
# =JvkM
# -----END PGP SIGNATURE-----
# gpg: Signature made Thu 29 Oct 2026 01:29:49 PM CDT
# gpg: using RSA key 5D09FD0871C8F85B94CA8A0D281F0DB8D28D5469
# gpg: issuer "mst@redhat.com"
# gpg: Good signature from "Michael S. Tsirkin <mst@kernel.org>" [unknown]
# gpg: aka "Michael S. Tsirkin <mst@redhat.com>" [unknown]
# gpg: WARNING: The key's User ID is not certified with a trusted signature!
# gpg: There is no indication that the signature belongs to the owner.
# Primary key fingerprint: 0270 606B 6F3C DF3D 0B17 0970 C350 3912 AFBE 8E67
# Subkey fingerprint: 5D09 FD08 71C8 F85B 94CA 8A0D 281F 0DB8 D28D 5469
* tag 'for_upstream' of https://git.kernel.org/pub/scm/virt/kvm/mst/qemu: (77 commits)
virtio-net: add mtu-from-tap property for automatic MTU detection
net: add generic get_mtu NetClientInfo callback
net/tap: add tap_fd_get_mtu() to query host tap MTU
hw/virtio/virtio-mem: Fix error message on invalid NUMA node
intel_iommu_accel: Teardown FAULTQ resources in bottom half
intel_iommu_accel: Accept PRQ response for passthrough device
intel_iommu_accel: Add PRQ injection for passthrough device
backends/iommufd: Extend iommufd_backend_alloc_hwpt() with fault_id
backends/iommufd: Introduce iommufd_backend_alloc_faultq
intel_iommu_accel: Guard VTDAccelPASIDCacheEntry definition
amd_iommu: Allow IOMMU to attachment on non-system (pcie.0) bus
acpi-build: Create PCI topology using amd iommu root bus
amd_iommu: Introduce root bus
i386/kvm: Use x86_iommu_device_get() for per-device IOMMU lookup
intel_iommu: Add support for get_x86_iommu callback
amd_iommu: Add support for get_x86_iommu callback
x86-iommu: Introduce x86_iommu_device_get() for x86-iommu retrieval
amd_iommu: Assign ioapic_as only when interrupt remapping is supported.
vhost-user: add dedicated mailing list
virtio-snd: don't use virtio_snd_pcm_get_stream() in virtio_snd_post_load()
...
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
In its current form, the mechanism for saving CPR FDs into hash table
has flaws.
The CPR fd hash table uses the same CprFd for both key and value, and
is created with a key destroy function. Inserting a second element
with the same (name, id) key leads to a use after free. According to
GLib docs [1], g_hash_table_insert() keeps the old key, replaces the
value with the new element, and destroys the new key. Thus when
inserting 2 CprFd elements fd1 and fd2 with equal keys we get:
g_hash_table_insert(table, fd1, fd1); /* table has fd1 -> fd1 */
g_hash_table_insert(table, fd2, fd2); /* table has fd1 -> fd2, fd2 freed */
Any subsequent cpr_find_fd() for that key then returns freed memory.
This is reachable whenever two CPR-aware objects register fds under the
same name, and it happens long before an actual CPR, since cpr_save_fd()
is typically called from .realize(), i.e. at boot time.
Apart from the UAF itself, when the user decides to perform CPR migration,
on CPR target we'd get corrupted FD from the hash table and fail somewhere
in .realize() for affected devices.
As a solution, let's altogether prohibit adding CprFds with duplicate
keys. Since FDs are being registered for a subsequent CPR right at the
startup in .realize(), that'll allow us to error out and exit QEMU (or
fail a device hotplug op) gracefully instead of delaying potential
problems for later. To do so, let's make cpr_save_fd() return 'bool'
instead of 'void' and provide an 'errp' argument to it. That way caller
becomes responsible for checking the return value and propagating the
error.
Also update all the callers to use the adjusted interface to keep things
compilable and bisectable.
[1] https://docs.gtk.org/glib/type_func.HashTable.insert.html
Fixes: a181df93bb ("migration/cpr: use hashtable for cpr fds")
Reviewed-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Signed-off-by: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Message-ID: <20261012-up-vsock-vhost-v5-v16-1-36c38bd15ffc@virtuozzo.com>
We have seccomp matches for clone() which mandate the presence of
several flags, in order to permit pthreads_create:
REQUIRE_CLONE_FLAG(CLONE_VM);
REQUIRE_CLONE_FLAG(CLONE_FS);
...
Given those mandatory matches, it is impossible for flags == 0 to
pass the filter. This is fortunate, since the explicit match on
flags == 0 is in fact broken, as it has a silent size extension
from 32-bits to 64-bits.
This results in seccomp generating pseudo code of:
if ($arch == 3221225534)
# filter for syscall "clone" (56) [priority: 65531]
if ($syscall == 56)
if ($a0.hi32 & 0xffffffff == 0)
if ($a0.lo32 & 0xffffff00 == 0)
action ERRNO(1);
# default action
action ALLOW;
# invalid architecture action
action KILL;
Since the clone() flag is passed as a 32-bit value in the syscall,
the high 32-bits are liable to be undefined/uninitialized garbage
The desired match for flags == 0 was
if ($arch == 3221225534)
# filter for syscall "clone" (56) [priority: 65532]
if ($syscall == 56)
if ($a0.hi32 & 0x00000000 == 0)
if ($a0.lo32 & 0xffffff00 == 0)
action ERRNO(1);
# default action
action ALLOW;
# invalid architecture action
action KILL;
That is redundant, however, as can be seen if we look at the
(fixed) program with the CLONE_THREAD rule also present:
if ($arch == 3221225534)
# filter for syscall "clone" (56) [priority: 65532]
if ($syscall == 56)
if ($a0.hi32 & 0x00000000 == 0)
if ($a0.lo32 & 0xffffff00 == 0)
action ERRNO(1);
if ($a0.lo32 & 0x00010000 == 0)
action ERRNO(1);
# default action
action ALLOW;
# invalid architecture action
action KILL;
That "($a0.lo32 & 0x00010000 == 0)" match will catch the case
of flags == 0 and do the right thing.
Reported-by: Ricardo Branco (https://gitlab.com/ricardobranco777)
Related: https://gitlab.com/qemu-project/qemu/-/work_items/4671
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
* target/i386/tcg: fix EFLAGS reads in TCG plugin callbacks
* target/i386/tcg: raise #GP(0) on null SS load with RPL != CPL
* target/i386/tcg: Don't clear C1 for FCOMI/FCOMIP/FUCOMI/FUCOMIP
* target/i386/tcg: implement APX
* target/i386: Migrate error code only with an exception
* agents: Add a skill for finding your way around QEMU
* tdx: fix buffer overflow in tdx_parse_panic_message
* accel/kvm: fixes
# -----BEGIN PGP SIGNATURE-----
#
# iQFIBAABCgAyFiEE8TM4V0tmI4mGbHaCv/vSX3jHroMFAmrDtEEUHHBib256aW5p
# QHJlZGhhdC5jb20ACgkQv/vSX3jHroN54Qf/WWX2G/Jh3WsKI7/9ahX+aqaOsGqP
# hdz8c6VurrGFwD4a6W8M73962XvrSlR0cNixXxjEo5lZ5UEuLXoCNuNHOW7TTHgF
# tGbfmX8hDMsU/VepRXjIVq5CQuJx6GJtYGf0bWROt3FkM3mn9xYevKu6bg9szNEX
# 3P71MtHIH/CMqP6/oI6VdHeGmNhGamiAoSLqly5t303CbtCULZiTZlqf3xMxjvVO
# M+hFMaW44kvXmpKWo8XLkWhcEasBuULJdKgq7cRIIrE1VNM+f9tItaEbxmozxlfT
# ae5+y1M/H5LAwjYLqTgUy2mvCcZ/btcdjU+wrWzYeSuAcOu4IRC1jQ4ozw==
# =d5mw
# -----END PGP SIGNATURE-----
# gpg: Signature made Mon 05 Oct 2026 04:29:21 PM CEST
# gpg: using RSA key F13338574B662389866C7682BFFBD25F78C7AE83
# gpg: issuer "pbonzini@redhat.com"
# gpg: Good signature from "Paolo Bonzini <bonzini@gnu.org>" [unknown]
# gpg: aka "Paolo Bonzini <pbonzini@redhat.com>" [unknown]
# gpg: WARNING: The key's User ID is not certified with a trusted signature!
# gpg: There is no indication that the signature belongs to the owner.
# Primary key fingerprint: 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: (32 commits)
agents: Add a skill for finding your way around QEMU
target/i386/tcg: mark APX as supported
target/i386: extract computation of no-autoenable features
target/i386/tcg: optimize CCMP
target/i386/tcg: decode APX instructions
target/i386/tcg: implement CCMP/CTEST
target/i386/tcg: add decode functionality for APX
target/i386/tcg: decode EVEX prefix
target/i386/tcg: extend VEX.vvvv parsing for APX
target/i386/tcg: implement JMPABS instruction
target/i386/tcg: decode REX2 prefix
target/i386/tcg: treat 0x0F as a prefix
target/i386/tcg: mark XSAVE* as not allowing REX2
target/i386/tcg: add definition for REX2 prefix
target/i386/tcg: add APX support to XSAVE/XRSTOR
target/i386/tcg: unify MOVBE and BSWAP generators
target/i386/tcg: use zextT1 for CMPXCHG
target/i386/tcg: use standard operand order for BSF and BSR
target/i386/tcg: generalize zero- and sign-extension
accel/kvm: coalesced mmio: check lenght of the MMIO write entry
...
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Merge USB, I/O and seccomp fixes
* Fix seccomp to use errno action for setns/execveat/unshare
instead of killing the thread
* Improve TLS performance and avoid test suite timeouts by
corking TLS writes to increase packet size
* Fix websocket server unbounded read of client data
CVE-2026-101291
* Avoid use-after-free in MTP device during object delete
# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCAAdFiEEOSEivHoFu8YQee2OpU5XPKwd8GwFAmrEslEACgkQpU5XPKwd
# 8GzKxA//fWvTM+u6OVK3vC2ieh87B9EHLMIxQ86jyCW9CReoX/8GQBrGpoWOW3oy
# 7P2TsLTS6HvxKWITcuAAdXR0iWZheOUcj8vcEozSMJuZ4ozQKpC1TPV+ViXv2bfB
# CASqTs/G+MaJETsiAM2Q4p8Glwh9MV55GnYwzAkvrCM+y7Jpl6PgxzcFFkVxw5DC
# drCuuNXKUKwf/eoCzcIWtYTicMb/5OA6Bs3NwDQSKCyAwBWyRWti4pzGftfZzNvd
# 1Dyy4fD0mQUO637EsnNu/k53s0Eu7Mt5UxQSU+hCJVMgOjZfcTdDV6wAXGVkNPN+
# jlBSJ2Jj38CJ3bgk6o7XJvFJgbZycRynC60LCLrW5O2X9acOQcgYY1XSpqC9l+QG
# WlK72oK3XI+mqubdBrUFMntEJr8JMD9dNN+eG7Zs33spQcmjmfBYDRX2lpe+HIfP
# ePpQA6pe5hKjhKeqXPZJhjvRSUwA7lHbfLs0NYblRLNGe1O3zvsX89M4xQ9G/f0x
# 5uAOdGi4IWfkNlgfHZRdSVI0t/UWHevyTvTNXSNPkLgFRAD9d4TRt3d/6WvXOZgr
# miFWbwWpdNVwbpEI9gIvPYns6skDy1doypLsF7TQz4byPpwl5BROdED/M1fGnLyA
# Ie+pXhEjk2Ah8/kmJTiyxZVLvx9K/itOJNca439IJZSIwMAhLf0=
# =VJrG
# -----END PGP SIGNATURE-----
# gpg: Signature made Tue 06 Oct 2026 10:33:21 AM CEST
# gpg: using RSA key 392122BC7A05BBC61079ED8EA54E573CAC1DF06C
# gpg: Good signature from "Daniel P. Berrange <dan@berrange.com>" [unknown]
# gpg: aka "Daniel P. Berrange <berrange@redhat.com>" [unknown]
# gpg: WARNING: This key is not certified with a trusted signature!
# gpg: There is no indication that the signature belongs to the owner.
# Primary key fingerprint: DAF3 A6FD B26B 6291 2D0E 8E3F BE86 EBB4 1510 4FDF
# Subkey fingerprint: 3921 22BC 7A05 BBC6 1079 ED8E A54E 573C AC1D F06C
* tag 'misc-fixes-pull-request' of https://gitlab.com/berrange/qemu:
seccomp: fix blocking of setns/execveat/unshare
io: cork TLS writes to avoid small TLS records
io: prevent unbounded read of websocket data from client
hw/usb: Fix USB MTP Use-After-Free in usb_mtp_deletefn List Iteration
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
The initializer for these syscalls missed the seccomp action
field, so it got the default action which was to kill the calling
thread, instead of returning an errno value, which the other
equivalent syscalls use.
Since we don't ever intend to use a seccomp filter without a
defined action, use an assert to validate that action is always
set to non-zero.
Reported-by: Igor Santos-Grueiro (gitlab:@igorsantosgrueiro)
Fixes: https://gitlab.com/qemu-project/qemu/-/work_items/4600
Fixes: 4638057110 (seccomp: block setns, unshare and execveat syscalls)
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This name is too generic, and can conflict with support for using
guest-memfd for shared memory. Add a _PRIVATE suffix to show what it
really means: it is using guest_memfd specifically for private memory;
whether or not guest_memfd is being used for shared memory is something
to be configured/determined separately.
This also paves way for in-place guest-memfd, which means we can have a
ramblock that allocates pages completely from guest-memfd (private or
shared).
Reviewed-by: Xiaoyao Li <xiaoyao.li@intel.com>
Reviewed-by: Michael Roth <michael.roth@amd.com>
Reviewed-by: David Hildenbrand <david@kernel.org>
Signed-off-by: Michael Roth <michael.roth@amd.com>
Link: https://lore.kernel.org/r/20260929235109.1398509-6-michael.roth@amd.com
Signed-off-by: Peter Xu <peterx@redhat.com>
With the mmap support of guest memfd, KVM allows userspace to create
guest memfd serving as normal non-private memory for X86 DEFAULT VM.
However, KVM doesn't support private memory attribute for X86 DEFAULT
VM.
Make kvm_guest_memfd_supported not rely on KVM_MEMORY_ATTRIBUTE_PRIVATE
and check KVM_MEMORY_ATTRIBUTE_PRIVATE separately when the machine
requires guest_memfd to serve as private memory.
This allows QEMU to create guest memfd with mmap to serve as the memory
backend for X86 DEFAULT VM.
Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com>
Reviewed-by: Fabiano Rosas <farosas@suse.de>
Reviewed-by: Michael Roth <michael.roth@amd.com>
Reviewed-by: David Hildenbrand <david@kernel.org>
Signed-off-by: Michael Roth <michael.roth@amd.com>
Link: https://lore.kernel.org/r/20260929235109.1398509-2-michael.roth@amd.com
Signed-off-by: Peter Xu <peterx@redhat.com>
curr_cflags() is called once per TB dispatch, from helper_lookup_tb_ptr()
and from the cpu_exec() loop. It recomputes the same value every time:
uint32_t cflags = cpu->tcg_cflags;
if (unlikely(cpu_single_stepping(cpu))) { ... }
else if (qatomic_read(&one_insn_per_tb)) { ... }
else if (qemu_loglevel_mask(CPU_LOG_TB_NOCHAIN)) { ... }
That is three loads and three branches on the hottest path in the
interpreter, for state that changes only when gdb enables single-step,
when one-insn-per-tb is toggled, or when the log mask changes.
None of the three has to be sampled at dispatch time. Fold each into
CPUState::tcg_cflags where it changes and curr_cflags() becomes a single
load of a field that TB lookup has to read anyway.
The derived bits -- CF_COUNT_MASK, CF_NO_GOTO_TB, CF_NO_GOTO_PTR and
CF_SINGLE_STEP -- are never set by tcg_cflags_set(), so tcg_update_cflags()
can recompute them in place without disturbing the rest, and conversely
tcg_cflags_set() ORs in its bits without disturbing them.
There are three places to call it:
- tcg_exec_realizefn(), so that a CPU created after the command line has
been parsed starts out with the right value. This covers user-only,
where tcg_cpu_init_cflags() is not reached. linux-user's cpu_copy()
copies tcg_cflags wholesale, so a cloned thread inherits it.
- cpu_single_step(), which changes one CPU. gdb is the only caller that
matters; in system mode it runs with the vCPUs stopped, and in user mode
gdb_continue_partial() can reach a thread that is still running, because
gdb_handlesig() stops only the thread that trapped. That is exactly the
plain cross-thread store to another CPU's CPUState that
cpu->singlestep_flags already was, read back by that CPU through
cpu_single_stepping() in curr_cflags(). This patch changes which field
carries it, not who writes it or how.
- hmp_one_insn_per_tb() and hmp_log(), which change every CPU while the
vCPUs are running, so the update is queued with async_run_on_cpu() and
each CPU writes its own cflags from its own thread. The command line
spellings of those two settings need nothing: they are parsed before
any CPU is realized, so tcg_exec_realizefn() picks them up.
Measured with qemu-alpha running an emulated alpha gcc 16.2.0 compiling
the SQLite 3.45.1 amalgamation (255k lines, -O2) on an x86-64 host, in a
build configured with --enable-lto:
before: 1,646,994,254,249 instructions
after: 1,562,204,796,597 instructions -5.15%
That workload issues 8.4 billion dispatches, so the per-call saving is
small but the aggregate is not. The emulated compiler produces
byte-identical output before and after.
Wall clock does not move: 133.19s to 132.58s, a 0.46% difference against a
run-to-run spread larger than that. The removed work is a few predictable
loads and branches that the host executes largely in parallel with the
surrounding dispatch, so this patch is worth taking for the instruction
count and for what it enables, not for a time saving that can be measured
on its own.
v4: Update the cflags from the HMP handlers for 'log' and 'one-insn-per-tb'
rather than from qemu_set_log_internal() and the accelerator property
setter. Those are the paths that reach a running vCPU, and the monitor
is the only thing that does. Suggested by Richard Henderson.
v4: Queue the per-CPU update with async_run_on_cpu() rather than
async_safe_run_on_cpu(). Halting the other vCPUs buys nothing: the
queued work already runs on the owning CPU's own thread. Suggested by
Alex Bennee, who also asked whether there are cross-vCPU updates of
tcg_cflags at all. With this change the monitor path has none: the
only remaining writer from another thread is cpu_single_step(), above,
which is neither new nor made worse here.
v4: Move the stub to accel/stubs/, which is where the other accelerator
stubs live.
Signed-off-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-ID: <20260901034808.3524945-2-mattst88@gmail.com>
Mem api pull
- Peter's patchset to drop some dead code for 32bit hosts
- Phil/Bin's patch to enhance error message for mem allocations
- Cam's fix to virtio-mem crash in multi-source work
# -----BEGIN PGP SIGNATURE-----
#
# iIgEABYKADAWIQS5GE3CDMRX2s990ak7X8zN86vXBgUCaq0ivhIccGV0ZXJ4QHJl
# ZGhhdC5jb20ACgkQO1/MzfOr1wbtGQD/djQyYM2zWEh5SyDDhbT4cj7iPIkvFtCM
# MVQNJPFkZLUBANMM8sWaoEaIsehh+tLq+6zvqyAB5U9yF8ecuYgR6iEH
# =n5bF
# -----END PGP SIGNATURE-----
# gpg: Signature made Fri 18 Sep 2026 01:38:38 AM HST
# gpg: using EDDSA key B9184DC20CC457DACF7DD1A93B5FCCCDF3ABD706
# gpg: issuer "peterx@redhat.com"
# gpg: Good signature from "Peter Xu <xzpeter@gmail.com>" [unknown]
# gpg: aka "Peter Xu <peterx@redhat.com>" [unknown]
# gpg: WARNING: The key's User ID is not certified with a trusted signature!
# gpg: There is no indication that the signature belongs to the owner.
# Primary key fingerprint: B918 4DC2 0CC4 57DA CF7D D1A9 3B5F CCCD F3AB D706
* tag 'next-pull-request' of https://gitlab.com/peterx/qemu:
system/ram-discard-manager: fix offset_within_address_space in replay_by_populated_state()
system/physmem: Improve guest memory allocation failure error message
machine: Remove 32bit limitation on ram size
hw/arm/raspi4b: Drop board_rev for 32bit hosts
arm/aspeed: Drop ASPEED_RAM_SIZE
linux-user: Remove 32bit host support in thunk_convert|print()
bsd-user: Remove 32bit host support in thunk_convert|print()
xen-mapcache: Remove 32bit support
arm/mps: Remove 32bit define for MPS3_DDR_SIZE
hw/vexpress.c: Remove forced cast to u64
system: Define ram_addr_t to be always uint64_t
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Fix bug inside replay_by_populated_state() that forgets to initialize
MemoryRegionSection field offset_within_address_space. Follow the
established pattern of calling memory_region_section_intersect_range()
to accomplish this task.
Prior to commit cc9c77f4dd ("system/memory: implement
RamDiscardManager multi-source aggregation"),
replay_by_populated_state() had called
memory_region_section_intersect_range() in order to initialize
interdependent fields offset_within_address_space, offset_within_region,
and size together, as shown below.
s->offset_within_address_space += start - s->offset_within_region;
s->offset_within_region = start;
s->size = int128_sub(end, int128_make64(start));
cc9c77f4dd reimplements replay_by_populated_state() initializing the
fields of the given MemoryRegionSection instance by hand instead of via
memory_region_section_intersect_range(). In doing so, it leaves
offset_within_address_space uninitialized for some reason, as you can
see below.
MemoryRegionSection subsection = {
.mr = section->mr,
.offset_within_region = offset,
.size = int128_make64(MIN(granularity, end_offset - offset)),
};
Consequently offset_within_address_space defaults to GPA 0x0, which is
incorrect. For example, on s390x, base RAM begins at GPA 0x0 and it is
problematic to report that a virtio-iommu MR section lives there
instead.
cc9c77f4dd deliberately calls memory_region_section_intersect_range()
from other related code paths inside the same file, namely
replay_source_by_state() and rdl_populate_cb()/rdl_discard_cb(). It is
unclear why the new replay_by_populated_state() implementation does not
conform to this same pattern.
The effects of the bug include qemu crashes on multiple architectures.
The following assertion failure occurs when driving the
guest_phys_blocks_append() code path, for guests with virtio-mem device
that has some memory plugged.
DBG: guest_phys_block_add_section: predecessor->target_end=280000000 target_start=0
**
ERROR:../system/memory_mapping.c:222:guest_phys_block_add_section: assertion failed: (predecessor->target_end <= target_start)
Bail out! ERROR:../system/memory_mapping.c:222:guest_phys_block_add_section: assertion failed: (predecessor->target_end <= target_start)
2026-09-11 16:03:57.405+0000: shutting down, reason=crashed
This crash can be triggered on x86 via the dump-guest-memory QMP
command. The same crash can be triggered on s390x by restoring VM State
that has been migrated to a local file. (I used libvirt to manage this
migration restore operation, namely command virsh managedsave then virsh
start.) Applying the fix resolved the crash on both platforms.
Cc: qemu-stable <qemu-stable@nongnu.org>
Fixes: cc9c77f4dd ("system/memory: implement RamDiscardManager multi-source aggregation")
Reported-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Signed-off-by: Cam Miller <cam@linux.ibm.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Link: https://lore.kernel.org/r/20260914-vmem_fix-v1-1-f69ef04a07b0@linux.ibm.com
Signed-off-by: Peter Xu <peterx@redhat.com>
This wires up the accelerator creation code to apply the compat policy
security check. When multiple -accel options are given, normal fallback
logic applies. IOW, if one is rejected by the security check, it will
carry on to try the next accelerator until one passes the security
check.
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
HotplugHandler value returned from qdev_get_hotplug_handler()
points to the handler of and object implementing the
TYPE_HOTPLUG_HANDLER interface. That handler mostly points to
read-only section which shouldn't not be updated. Better
protect it with the const qualifier.
Mechanical change using 'sed' then manually adapted coding style.
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Message-ID: <20260903230245.65601-5-philmd@oss.qualcomm.com>
Replace the hand-rolled container property with
object_property_add_link().
With check=NULL the link has no setter (read-only), matching the
existing behaviour. The built-in link getter and resolver are
functionally identical to the removed memory_region_get_container() and
memory_region_resolve_container(). The non-STRONG flag avoids refcount
interference: mr->container is managed externally by
memory_region_add/del_subregion().
Reviewed-by: Peter Xu <peterx@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Add #ifdef CONFIG_HMP around all hmp_* function implementations and
their HMP-only helpers across subsystems.
This covers monitor_register_hmp* callers, hmp_info_* handlers, and
HMP-only helper functions like slirp_lookup.
To link succesfully, use empty cmds tables in hmp-cmds.c (to be removed
once meson build-sys is updated with !hmp support later in the series)
Reviewed-by: Jason J. Herne <jjherne@linux.ibm.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-ID: <20260828-qemu-no-hmp-v5-41-9227de146347@redhat.com>
Rename monitor_printf->monitor_hmp_printf, monitor_vprintf->
monitor_hmp_vprintf, and monitor_printc->monitor_hmp_printc, changing
the first parameter from Monitor * to MonitorHMP * to enforce type
safety. The implementation is also simplified: monitor_hmp_vprintf now
directly calls g_strdup_vprintf + monitor_puts, removing the virtual
dispatch via moncls->vprintf.
The dev_print() callbacks are temporarily using the MONITOR_HMP(mon)
cast, they are fixed in the following commits.
Early return in qemu_vprintf() if "hmp" is NULL, relying on
monitor_hmp_vprintf() handling NULL case is a bit uncommon.
Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-ID: <20260828-qemu-no-hmp-v5-37-9227de146347@redhat.com>
HMP commands are specific to the HMP monitor, so make the cmd function
pointer in HMPCommand take MonitorHMP * instead of Monitor *. This
strengthens type safety and makes the HMP-specific nature of these
handlers explicit.
Handler functions are renamed to take MonitorHMP *hmp, with a local
Monitor *mon = MONITOR(hmp) added where the body needs the base type.
Following patches will drop it, since most functions are HMP specific.
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Jason J. Herne <jjherne@linux.ibm.com>
Reviewed-by: Dr. David Alan Gilbert <dave@treblig.org>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-ID: <20260828-qemu-no-hmp-v5-31-9227de146347@redhat.com>
- disable default monitor when HMP is not available
- hide 'readline' from -mon help text
- error out on mux chardev monitor when no HMP
- skip HMP monitor terminal for gdb, return E01 for 'qRcmd' remote
commands
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-ID: <20260828-qemu-no-hmp-v5-28-9227de146347@redhat.com>
Add a "qemu-io" command to the qtest protocol so that tests can issue
block layer I/O commands without going through the HMP monitor's
"human-monitor-command" QMP, or use QMP at all.
Unfortunately, many tests will prefer to use QMP as they also monitor
and log other events. It's easier if it is pipelined in the same stream.
Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-ID: <20260828-qemu-no-hmp-v5-23-9227de146347@redhat.com>
Keep cpus.c focused on vCPUs handling, move code related to
VM state to runstate.c where similar code lives.
Fix few checkpatch.pl warnings:
WARNING: Block comments use a leading /* on a separate line
WARNING: Block comments use * on subsequent lines
#327: FILE: system/runstate.c:541:
+/* does a state transition even if the VM is already stopped,
+ current state is forgotten forever */
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20260812211708.92824-17-philmd@oss.qualcomm.com>
Keep cpus.c related to vCPU scheduling, move the QMP handlers
related to dumping physical memory to file to their own unit.
Fix a pair of checkpatch.pl errors doing so:
ERROR: braces {} are necessary for all arms of this statement
#185: FILE: system/physmem-qmp-cmds.c:51:
+ if (l > size)
[...]
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20260812211708.92824-16-philmd@oss.qualcomm.com>