135452 Commits
Author SHA1 Message Date
千川白浪 21bda5437d ci: reduce upstream sync to daily and remove upstream QEMU lockdown workflow 2026-12-05 00:29:10 -07:00
YXC0915 a7a727a739 build: Update maintenance branch references [ci skip]
Keep automation and documentation aligned with the renamed branch.
The source pins and build steps stay the same.
2026-12-02 19:27:52 +08:00
Xiaochi You 0b057da401 🆕 Automate merging upstream updates into the maintenance branch 2026-12-01 23:47:03 +08:00
Richard Henderson e9fa1f66f0 Merge tag 'pull-nbd-2026-11-10-v2' of https://gitlab.com/ebblake/qemu into staging
NBD patches through 2026-11-10

A few bug fixes:
- Eric Blake: fix two low-severity CVEs with non-compliant NBD clients

# -----BEGIN PGP SIGNATURE-----
#
# iQEzBAABCAAdFiEEccLMIrHEYCkn0vOqp6FrSiUnQ2oFAmr3HqAACgkQp6FrSiUn
# Q2oOugf/cw/KQ3ZCv2SIs313JHhWR8fRO0k4FG/t9r9JA0vBMgDPrKv6vfJWhFtg
# in5Nvy6KOkb/nq18MwuDzwmTgAyPYd1XACxHB8iR7g/MRbs9ODytQB12DUJVADEl
# Ww0Ht/VV0oXDPdpEEreQt5LvcErVVwfohzQXTCIVgMlhLjWvKg1hi0abTRzujZnm
# iyMdaN/hNz68yJbssOEnlXTVZ2jcRjkencRfBQMCQ7KI7/6Tod4MfSjPwqXLIeDc
# sES8yiAnn4N44q18iF7o1nKt9+rBXMZYRVs7Retxr/qsPuriEfhNBsiqx8XSeUnA
# Plmm9bOKu5rl9tDnjxAqrNd9mYjrwg==
# =Qmp0
# -----END PGP SIGNATURE-----
# gpg: Signature made Fri 13 Nov 2026 07:28:48 AM MST
# gpg:                using RSA key 71C2CC22B1C4602927D2F3AAA7A16B4A2527436A
# gpg: Good signature from "Eric Blake <eblake@redhat.com>" [unknown]
# gpg:                 aka "Eric Blake (Free Software Programmer) <ebb9@byu.net>" [unknown]
# gpg:                 aka "[jpeg image of size 6874]" [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: 71C2 CC22 B1C4 6029 27D2  F3AA A7A1 6B4A 2527 436A

* tag 'pull-nbd-2026-11-10-v2' of https://gitlab.com/ebblake/qemu:
  iotests: Add another nbd-robustness test
  nbd/server: Reject rather than assert on non-compliant NBD_OPT_SET_META_CONTEXT
  iotests: Add new nbd-robustness test
  nbd/server: Reject rather than assert on non-compliant BLOCK_STATUS
  iotests: Refactor python NBD server setup
  docs: Mention security considerations for NBD

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2026-11-13 08:44:16 -07:00
Eric Blake e682c0e570 iotests: Add another nbd-robustness test
Convert the proof of concept test by TonySD into another case of the
iotest. This is yet another instance where a hard-coded exchange is
easier than forcing libnbd into producing an exchange that violates
the protocol.  Swapping the order with the previous patch shows the
assertion failure that was previously reachable.

Based-on: https://gitlab.com/qemu-project/qemu/-/work_items/4843
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-ID: <20261110155356.1520433-12-eblake@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
2026-11-13 08:02:09 -06:00
Eric Blake 325b8b75d5 nbd/server: Reject rather than assert on non-compliant NBD_OPT_SET_META_CONTEXT
The NBD protocol says that NBD_OPT_{LIST,SET}_META_CONTEXT sends
several lengths that must be consistent: an overall option reply
length, then a series of smaller lengths/data pairs representing the
export name and zero or more context names. If the smaller lengths
within the payload do not add up to the larger value, the client has
sent garbage bytes that will trigger the server's parse of the
client's next option to be out of sync.  However, QEMU was dying with
an assertion failure rather than diagnosing the issue, which a
malicious client can then exploit to mount a denial-of-service attack
against QEMU as the NBD server.

As with several other recent NBD protocol violations, the likelihood
of this attack can be reduced by using TLS and x509 certs to reject
unwanted clients (a "trusted" client can still trigger the problem,
but you first have to compromise the trusted client into sending
arbitrary traffic).

Fixes: CVE-2026-125683
Fixes: e7b1948d51 ("nbd: BLOCK_STATUS for standard get_block_status function: server part", v2.12.0)
Reported-by: TonySD via https://gitlab.com/qemu-project/qemu/-/work_items/4843
CC: qemu-stable@nongnu.org
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-ID: <20261110155356.1520433-11-eblake@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
2026-11-13 08:02:09 -06:00
Eric Blake 3e6759157e iotests: Add new nbd-robustness test
Convert the proof of concept test by Sunday Jiang into an iotest. I
tried to get libnbd to trigger the situation, but forcing a block
status command when no status has been initiated is not something that
libnbd is willing to do. So this results in a hard-coded sequence of
bytes sent over a raw socket.  Swapping the order with the previous
patch shows the assertion failure that was previously reachable.

Based-on: https://gitlab.com/qemu-project/qemu/-/work_items/4091
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-ID: <20261110155356.1520433-10-eblake@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
2026-11-13 08:02:09 -06:00
Eric Blake 3ec7bb1935 nbd/server: Reject rather than assert on non-compliant BLOCK_STATUS
The NBD spec is clear that a client must not send NBD_BLOCK_STATUS
requests to a server if it did not negotiate any metacontexts with
NBD_OPT_SET_META_CONTEXT for the current export.  However, if the
non-compliant client uses NBD_OPT_EXTENDED_HEADERS and then passes in
the relatively new NBD_CMD_FLAG_PAYLOAD_LEN flag alongside an
inappropriate block status request, this was enough to trigger an
assertion in qemu.  The assertion can also be tripped by initially
requesting the context for one export, then using NBD_OPT_GO on a
different export (nbd_check_meta_export() sets contexts.count to 0,
but did not wipe contexts.exp). Forcing the client command to be
rejected if contexts.count is 0 solves both triggers, and allows the
assertion to still operate cleanly at a later location.

If you do not use recommended practice to prevent unwanted clients
from connecting to QEMU's NBD server, then any client can cause a
denial of service with minimal effort.  However, with TLS and x509
certs in place, an attacker must first chain in an attack to convince
the client to send unwanted traffic, which is a factor in declaring
this a lower-risk denial of service.

Fixes: CVE-2026-124559
Fixes: 2dcbb11b ("nbd/server: Add FLAG_PAYLOAD support to CMD_BLOCK_STATUS", v8.2.0)
Reported-by: Feifan Qian <bea1e@proton.me>
Reported-by: https://gitlab.com/qemu-project/qemu/-/work_items/3796
CC: Haotian Jiang <jianghaotian.sunday@gmail.com>
CC: qemu-stable@nongnu.org
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-ID: <20261110155356.1520433-9-eblake@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
2026-11-13 08:02:09 -06:00
Eric Blake 9bc9e737a3 iotests: Refactor python NBD server setup
Extract code from nbd-multiconn that I plan to use in another upcoming
unit test.

Signed-off-by: Eric Blake <eblake@redhat.com>
Message-ID: <20261110155356.1520433-8-eblake@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
2026-11-13 08:02:09 -06:00
Eric Blake fd2cee4c2e docs: Mention security considerations for NBD
Document a policy that NBD connections should strongly consider using
TLS and x509 certificates to filter out unwanted clients.  If a
malicious server or client can trigger a QEMU assertion failure on a
plaintext connection, but can trivially have risk mitigated by
enabling TLS to weed out unknown partners (so that a full-on attack of
QEMU would first require chaining some other attack to convince a
"trusted" client to break protocol in the first place), then that
reduces the CVSS-BE score of the QEMU bug. In turn, our policy already
states that low severity scores can be fixed without an embargo.

Signed-off-by: Eric Blake <eblake@redhat.com>
Message-ID: <20261110155356.1520433-7-eblake@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
2026-11-13 08:02:09 -06:00
Richard Henderson 4bcd55a1f4 Merge tag 'pull-trivial-patches' of https://gitlab.com/mjt0k/qemu into staging
trivial patches for 2026-11-12

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCgAdFiEEZKoqtTHVaQM2a/75gqpKJDselHgFAmr2DyMACgkQgqpKJDse
# lHjSWw//c3kywmPZOONmmZoswENDa2te9nOAsQAD4E15dnny5GqiaUVGQwxu7arg
# 7jODnHdCAHQIzvltT9GH1oSgq1gYNVo99h0bRsy2sEEPOHkxNDUY3BgBEF0P3R/d
# nd9nE72WDQfLBNN0oMKIiSM+pKIV14/PPlMznSmo7jsiUk1rwynFmDLXClVOeG00
# 46oSHju2YPw2r12uDTw0PqUsyqpOvoaIC9HA885I1whQQQM7aNgFnjeExHYarvAl
# puhfdQTUGXdtSNR4FtrgPX1AnNrwAd+q1BblJwGkgIrV/cGSmxqFgRaSnynGQd3L
# t9wodCf2xOAQ5iXHgYui+YLqGUvHjl8tPowM6eqVij/Ur9EpELIgJz4G4d2dh0YV
# BMo7p8uZCEotB80i7Q7TW22UJBfV5LHrC1ImE52YtG76RkuvTudKraRwIXeRXt8t
# xpmwGKpFLWTWXwUIRXe5zjN5Uwu4rz9uRPED51BBKVAeFu2CAFe/LO7ZLaSmZkwh
# F2kw0ZmpLLX8cwE77c0xqf75KgZFUTwbHbYRz2vY0bhzBLesAlzAmiHOi4OAFAbC
# C6Jl21WXB1l9B6Nz8JaafEkktmUYLWicuGHCVOGyOXVY4bzZV3gp3veJGz8Zly4J
# 8vbn0r+q+fzH0pWtKuK6E4tG4mKLD8BvkAO9SBmrCi2ofiMWF1A=
# =EmRm
# -----END PGP SIGNATURE-----
# gpg: Signature made Thu 12 Nov 2026 12:10:27 PM MST
# gpg:                using RSA key 64AA2AB531D56903366BFEF982AA4A243B1E9478
# gpg: Good signature from "Michael Tokarev <mjt@debian.org>" [unknown]
# gpg:                 aka "Michael Tokarev <mjt@corpit.ru>" [unknown]
# gpg:                 aka "Michael Tokarev <mjt@tls.msk.ru>" [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:
  hw/audio/intel-hda: Belatedly update comment for removal of -soundhw
  MAINTAINERS: fix typo in Gerd's name
  docs: fix a few typos
  hw/audio/fmopl.c: Convert malloc, free to g_malloc0, g_new and g_free
  io: avoid potential double close of qio_channel_file's fd

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2026-11-12 21:14:41 -07:00
Richard Henderson 4955956780 Merge tag 'mkulke-pull-20261111' of https://github.com/mkulke/qemu into staging
mshv fixes for 2026-11-11

# -----BEGIN PGP SIGNATURE-----
#
# iHUEABYIAB0WIQSIMd1XyYFq56tSq9Pd9deQOCwLigUCavTJGwAKCRDd9deQOCwL
# ijvWAQDJcT9mhQYuyW2dp5pboZg/dtJV8D5g16Y7EvP9YqrkIgD/bCJ98xNkgN06
# /lmiliI0P4YXo1Tqr6TSUt9PbYeWfwI=
# =KhYw
# -----END PGP SIGNATURE-----
# gpg: Signature made Wed 11 Nov 2026 12:59:23 PM MST
# gpg:                using EDDSA key 8831DD57C9816AE7AB52ABD3DDF5D790382C0B8A
# gpg: Good signature from "Magnus Kulke (QEMU) <magnuskulke@linux.microsoft.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: 5255 B617 7982 9168 7022  31CA 68D9 BB56 DD17 8417
#      Subkey fingerprint: 8831 DD57 C981 6AE7 AB52  ABD3 DDF5 D790 382C 0B8A

* tag 'mkulke-pull-20261111' of https://github.com/mkulke/qemu:
  target/i386/mshv: add MshvPutState for vcpu writes
  accel/mshv: freeze time during TSC MSR write
  target/i386/mshv: fix vCPU run result contract
  accel/mshv: skip double unmap of mem regions

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2026-11-12 13:45:30 -07:00
Richard Henderson 9d7d057a55 Merge tag 'virtio-snd-fixes-pr1' of https://gitlab.com/epilys/qemu into staging
virtio-snd-fixes-pr1

# -----BEGIN PGP SIGNATURE-----
#
# iQJPBAABCgA5FiEEzFwbTkSgVvOHcB0QdynHcH9+CdAFAmr0VikbFIAAAAAABAAO
# bWFudTIsMi41KzEuMTIsMCwzAAoJEHcpx3B/fgnQqiIP/RwyAXlUupo/L8Lgetbx
# bjOwtNBPZBKlZk6F3A4WNpqXZRLFlnH6GQSH7l0Xporokm8qiVytH50mHJcBFgpi
# PoICtqNooN5ud9YeK8UWQFXqGLSb4G1V2x6NQyLd1zGOrZkrnNaxRIRu0vN5s8RO
# R2dcrpYJ5S9IChbkWM/vLo6p9HAeGcD3F+zT1HhRpm7iKCKXZsyCCDGXu4RR6eUM
# d4Oxviglg1krjxqWy0ZNiohO1I3FOhYrrJiNTwv9jbbv+FXCAs45a5Ve1XauYgRn
# +8yPocxfFiuX9sobAXirNy084Xmv8kJCYThAucvho19dgEItDUamNhYg/fbsQHDv
# QZKb0JNtQm5B8xXmIK3zKGSGGdSUw1hn1YmQSgAy4clUpxhRgqCmFw/6I8Eo9Yt0
# IOgimj1hYQ9Fq55VNDdEEr16PH8O0b7D/ztToD3pw0ejW50kNIkBz9RrebCNfLTW
# rShv67h+yhJOUGF4OH1DBDXPFIw9zAMH4ep+tR6CGNi5dK4s7kALZD1noN++NGGl
# bLYCJXqdAL1o1jkiVG5Qteen4FtX1a5YI88zsnu5AMu2GyxhVmX8XWaPh2+T/vT3
# hgaMb0VsNH3pixhDMAU9IFwbP7QT+vugNI+B7QtwHvOXB3f2CrsxghmmZInSoKTn
# acOa8TNrie14G7F3jEdtqXHk
# =j9s7
# -----END PGP SIGNATURE-----
# gpg: Signature made Wed 11 Nov 2026 04:48:57 AM MST
# gpg:                using RSA key CC5C1B4E44A056F387701D107729C7707F7E09D0
# gpg: Good signature from "Manos Pitsidianakis <manos@pitsidianak.is>" [full]
# gpg:                 aka "Manos Pitsidianakis <el13635@mail.ntua.gr>" [full]
# gpg:                 aka "Manos Pitsidianakis <manos.pitsidianakis@linaro.com>" [full]
# gpg:                 aka "Manos Pitsidianakis <manos.pitsidianakis@linaro.org>" [full]
# gpg: Signature notation: manu=2,2.5+1.12,0,3

* tag 'virtio-snd-fixes-pr1' of https://gitlab.com/epilys/qemu:
  virtio-snd: period_bytes divides buffer_bytes
  virtio-snd: cap maximum buffer_bytes to half a GiB
  virtio-snd: don't allocate pcm_info zero-count buf
  virtio-snd: reject invalid feats in set_pcm_params
  virtio-snd: add pcm_state_to_str()
  virtio-snd: convert virtio_error to error_report

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2026-11-12 11:16:50 -07:00
Markus Armbruster 84d6ea1499 hw/audio/intel-hda: Belatedly update comment for removal of -soundhw
Comment is stale since commit 039a68373c (introduce -audio as a
replacement for -soundhw).

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2026-11-12 13:30:40 +03:00
Alex Bennée a308817bf3 MAINTAINERS: fix typo in Gerd's name
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Gustavo Romero <gromero@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2026-11-12 13:30:40 +03:00
Filip Hejsek 7412a6a275 docs: fix a few typos
Signed-off-by: Filip Hejsek <filip.hejsek@gmail.com>
Reviewed-by: John Snow <jsnow@redhat.com>
Reviewed-by: Michael Tokarev <mjt@tls.msk.ru>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2026-11-12 13:30:40 +03:00
Lucas Cardoso ba58329c5e hw/audio/fmopl.c: Convert malloc, free to g_malloc0, g_new and g_free
In accordance with QEMU's coding style guidelines, replace raw memory
allocation functions (malloc/free) with their GLib equivalents
(g_new/g_malloc0/g_free/g_clear_pointer).

Also removes the old generic error-handling code from
OPLOpenTable(), since the Glib functions abort the program automatically
if memory is exhausted.

Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/1798
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Lucas Cardoso <luc.fast2004@gmail.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Michael Tokarev <mjt@tls.msk.ru>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2026-11-12 13:30:40 +03:00
Filip Hejsek e5f54bcd1e io: avoid potential double close of qio_channel_file's fd
Make qio_channel_file_close() set fd to -1 even if qemu_close() returns
an error so that qio_channel_file_finalize() doesn't call close again.

On Linux, close() always closes the fd, even when it returns an error.
Because the fd can be reused after it is closed, the close must not
be retried.

Signed-off-by: Filip Hejsek <filip.hejsek@gmail.com>
Reviewed-by: Michael Tokarev <mjt@tls.msk.ru>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2026-11-12 13:30:13 +03:00
Magnus Kulke fcc504b770 target/i386/mshv: add MshvPutState for vcpu writes
Currently QEMU marks a vcpu state as dirty also on merely inspectional
reads, e.g. via "info registers", which triggers a writeback to the
hypervisor. For MSRs that cause a side-effect when written to this is
undesired.

We introduce an MshvPutState flag into the writeback logic to differentiate
"runtime" from "full" and "reset" writebacks that should occur e.g. after
a migration or startup.

Discrete side-effectful MSRs are excluded in runtime writebacks. So far
we only mark one MSR as not runtime-safe, but probably more will be
added eventually.

Signed-off-by: Magnus Kulke <magnuskulke@linux.microsoft.com>
Reviewed-by: Wei Liu <wei.liu@kernel.org>
Reviewed-by: Mohamed Mediouni <mohamed@unpredictable.fr>
2026-11-11 20:51:04 +01:00
Magnus Kulke faf92218ec accel/mshv: freeze time during TSC MSR write
A regression was introduced when the HV_X64_REGISTER_TSC MSR state is
being written to the hypervisor as part of the migration framework. If
the MSR is written without the time being frozen, the tsc_page (a
hyper-v enlightenment) is zeroed out and cannot be used by a guest,
which results in a performance regression, because the guest falls back
to costly reads of HV_X64_MSR_TIME_REF_COUNT.

An implementation of pre_resume_vm hook was added to handle the clock
lifecycle, relying on the dirty_vcpu state to avoid redundant state
writes.

Fixes: d540dcc5e2 ("target/i386/mshv: migrate MSRs")

Signed-off-by: Magnus Kulke <magnuskulke@linux.microsoft.com>
Reviewed-by: Doru Blânzeanu <dblanzeanu@linux.microsoft.com>
2026-11-11 20:51:04 +01:00
Magnus Kulke cc47cd339a target/i386/mshv: fix vCPU run result contract
Currently the return semantics of mshv_run_vcpu() are broken. They
return a mix of int and exit_reason, ignoring the out param *exit.

This change propagates errno's to the call site and sets the *exit value
accordingly. We also consider the case when an ioctl has return due to a
qemu-requested interruption of the call, this is a legitimate condition
that should not produce an error.

Fixes: 6dec60528c ("target/i386/mshv: Implement mshv_vcpu_run()")
Signed-off-by: Magnus Kulke <magnuskulke@linux.microsoft.com>
Reviewed-by: Doru Blânzeanu <dblanzeanu@linux.microsoft.com>
2026-11-11 20:51:04 +01:00
Magnus Kulke 3b9e70ba6c accel/mshv: skip double unmap of mem regions
This change addresses a regression that was introduced when the dynamic
mapping handler was removed, from the MSHV controller, breaking OVMF
support.

We introduce a small uaddr-indexed table to track mapped regions. The
current logic turns an add into a remove op if a rom-device region is
currently not in romd_mode.

We could ignore both map + unmap for this condition, but this misses a
the case of a region transitioning from romd_mode=true => false. In this
case we still do want to unmap a region.

Fixes: 626e5dc999 ("accel/mshv: Remove remap overlapping mappings code")

Signed-off-by: Magnus Kulke <magnuskulke@linux.microsoft.com>
Reviewed-by: Doru Blânzeanu <dblanzeanu@linux.microsoft.com>
2026-11-11 20:50:57 +01:00
Manos Pitsidianakis 9a0f03f815 virtio-snd: period_bytes divides buffer_bytes
Add a check for the VIRTIO spec statement:

  5.14.6.6.3.2 Driver Requirements: Stream Parameters

      period_bytes MUST be a divider buffer_bytes, i.e. buffer_bytes % period_bytes == 0.

Reviewed-by: Jim MacArthur <jim.macarthur@linaro.org>
Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
2026-11-11 13:46:50 +02:00
Manos Pitsidianakis 259b58e68e virtio-snd: cap maximum buffer_bytes to half a GiB
A faulty/malicious guest can try to exhaust host memory. Cap the buffer
size to 500 MiB.

Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3587
Reviewed-by: Jim MacArthur <jim.macarthur@linaro.org>
Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
2026-11-11 13:46:44 +02:00
Manos Pitsidianakis 0d9843799c virtio-snd: don't allocate pcm_info zero-count buf
g_new0() might return NULL, which is UB if passed to a memcpy
implementation that does not expect it (not in the usual case).

Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3778
Reviewed-by: Jim MacArthur <jim.macarthur@linaro.org>
Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
2026-11-11 13:46:36 +02:00
Manos Pitsidianakis c50c39370c virtio-snd: reject invalid feats in set_pcm_params
Do not blindly accept features for a stream, check them against what we
had reported to the guest with pcm_info.

Reviewed-by: Jim MacArthur <jim.macarthur@linaro.org>
Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
2026-11-11 13:46:26 +02:00
Manos Pitsidianakis 3d9c8c41d0 virtio-snd: add pcm_state_to_str()
Add macro to print the stream state in a human-understandable state,
since this is an internal enum and one would have to inspect the source
code to understand what a e.g. "2" state means in an error message.

Reviewed-by: Jim MacArthur <jim.macarthur@linaro.org>
Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
2026-11-11 13:46:16 +02:00
Manos Pitsidianakis 21f87695e6 virtio-snd: convert virtio_error to error_report
virtio_error() also signals a RESET, which is not what we want: we want
the guest driver to read the VIRTIO_SND_S_BAD_MSG response.

If a guest sends an invalid command and we do virtio_error() and reply
with a BAD_MSG response, the guest needs to detect the device reset
otherwise it hangs forever waiting for the response.

Reviewed-by: Jim MacArthur <jim.macarthur@linaro.org>
Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
2026-11-11 13:46:04 +02:00
Richard Henderson 29760efaf9 Update version for v11.2.0-rc0 release
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2026-11-10 14:47:54 -08:00
Richard Henderson 415a0605ef Merge tag 'pull-hex-20261109' of https://github.com/qualcomm/qemu into staging
Hexagon: fix virt, mttcg, docs

Fixes for:
* doc updates for 11.2
* virt machine -bios, FDT
* vmrte, guest BADVA
* TLB locking

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCgAdFiEEPWaq5HRZSCTIjOD4GlSvuOVkbDIFAmryhhEACgkQGlSvuOVk
# bDK63xAAgtt7UyEIhe1+v8ZxORBd9R4xBygXWl4E0gu6gW8lrzlMYXFVaFReEotM
# mrvixIZGKHxmsDPGey+5yhpgavjBySLuqiGrhjwAv6TYoCsg3WpPqsoTZNsUTAOt
# 7PZEEh4QLflM0rIhBzyPzFGuulRWP1F5eyAu6ffhwzEI8Y/B5oL//0MLdCRbe736
# aaS2Nv1p33A8wpu6ip2eJC+5e5ooFKAoFl2kcqispumENCoLHFWq6CdmjJax1dKJ
# zZDXz+90PCg8ZgWp2KUNRRveIlCC3qMH2C5Pgdw7B0MUj4gyHR1Ki/p7Q4CObQQJ
# wJoZedrHhM1oZAr8MmB3bG3r6DOzyO5PY3gf9ejcAhBPBZeyMrpsxhnzSj4MjRJU
# dLqRlsS5QKpgc1WjMdZP83+1bu3XVczTtc2yAntbeDWhYpjsLnwU5+//Izb2c9Cl
# zqISzL7xzKRB9O089EvNEcNueMyR8uDOZBg9+syOI9LB/X2XGyLySRWkBmGfvhFc
# ykAA09IBRNPM2nk9fBWi3dhUPTKdSr7uMwqiQtV8dka/zLwaa/GtZpwO9SeAt5Sl
# T91rWDyW0pYbPygjztuS1PIe10a/TDj5ufLFnNyfBHfJ6jfldYM2sFQCDw32eIMx
# jIrsAldZc0H8xbsCc/gG1huODn50hz0msNek3KI4nrAyjUcfzWI=
# =tPgM
# -----END PGP SIGNATURE-----
# gpg: Signature made Mon 09 Nov 2026 06:48:49 PM PST
# gpg:                using RSA key 3D66AAE474594824C88CE0F81A54AFB8E5646C32
# gpg: Good signature from "Brian Cain (OSS Qualcomm) <brian.cain@oss.qualcomm.com>" [unknown]
# gpg:                 aka "Brian Cain (QUIC) <quic_bcain@quicinc.com>" [unknown]
# gpg:                 aka "Brian Cain <bcain@kernel.org>" [unknown]
# gpg:                 aka "Brian Cain (QuIC) <bcain@quicinc.com>" [unknown]
# gpg:                 aka "Brian Cain (CAF) <bcain@codeaurora.org>" [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-20261109' of https://github.com/qualcomm/qemu:
  hw/hexagon: fix FDT address and size cells
  hw/hexagon/virt: fix firmware boot
  hw/hexagon: share the Hexagon VM guest boot code
  docs/system/hexagon: describe integrated firmware OS boot paths
  docs/system/hexagon: document SDK semihosting workloads
  docs/system/hexagon: document boot interfaces
  docs/system/hexagon: update the overview and emulation limits
  docs/system/hexagon: describe machine models and memory maps
  target/hexagon: leave stack exchange to virtual SPSWAP
  target/hexagon: serialize TLB invalidation and IMASK access
  target/hexagon: preserve guest event fault and CFI state

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2026-11-10 07:32:53 -08:00
Brian Cain a38ea91cad hw/hexagon: fix FDT address and size cells
Hexagon MMUs support 64-bit physical addresses.  Describe the root and
/soc buses with two address cells and two size cells so their child reg
properties can represent the full address and size range.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
2026-11-09 18:45:32 -08:00
Brian Cain 3461642bdb hw/hexagon/virt: fix firmware boot
-bios on virt only loaded a raw image of at most 64 KiB at address
zero.  This is insufficient for H2 firmware, which is usually hundreds of
KiB.

Boot a kernel given with -kernel through the firmware given with -bios.
Load both ELFs at their declared physical addresses, place the device tree
and initrd after the kernel, and enter the firmware through a boot stub
that passes the device tree in r1:r0.

Fixes: 88a8bc7f43 ("hw/hexagon: Define hexagon "virt" machine")
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
2026-11-09 18:45:32 -08:00
Brian Cain d32e78c5c6 hw/hexagon: share the Hexagon VM guest boot code
The DSP subsystem machines boot a guest kernel through the hypervisor
firmware.  Move that code, the DT nodes, guest timer, into hex-board so that
it can be used by virt.

No functional change, this will be used by a subsequent commit.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
2026-11-09 18:45:32 -08:00
Brian Cain 48faa0883a docs/system/hexagon: describe integrated firmware OS boot paths
Show how to boot a Linux guest with the hexagon_loadlinux firmware, and
hexagon_booter for running h2 user programs.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
2026-11-09 18:45:32 -08:00
Brian Cain d47bf86352 docs/system/hexagon: document SDK semihosting workloads
Show how to run standalone SDK programs and the QuRT loader chain with
an explicit v68 machine.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
2026-11-09 18:45:32 -08:00
Brian Cain 13991a855a docs/system/hexagon: document boot interfaces
Describe ELF and raw-image loading, reset state, the DTB handoff to VM
host firmware, and initial thread state. Explain UART and semihosting
console routing.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
2026-11-09 18:45:32 -08:00
Brian Cain 4dac5445ab docs/system/hexagon: update the overview and emulation limits
Describe the devices that the machines instantiate, ELF boot
path.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
2026-11-09 18:45:32 -08:00
Brian Cain 70ff19cb8c docs/system/hexagon: describe machine models and memory maps
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
2026-11-09 18:45:32 -08:00
Marco Liebel d8d24f5360 target/hexagon: leave stack exchange to virtual SPSWAP
Virtual RTE must restore status and branch to GELR without swapping
SP and GOSP. An implicit swap undoes the explicit exit SPSWAP and
resumes guest user code on the kernel stack.

Signed-off-by: Marco Liebel <marco.liebel@oss.qualcomm.com>
Reviewed-by: Brian Cain <brian.cain@oss.qualcomm.com>
Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
2026-11-09 18:45:32 -08:00
Marco Liebel d372cbc1c8 target/hexagon: serialize TLB invalidation and IMASK access
Hold the shared TLB mutex during ASID invalidation so it cannot
overwrite a concurrent entry replacement.

Route local IMASK reads and writes through BQL-protected helpers
to serialize them with cross-thread interrupt assignment. Apply
the pre-V81 writable-bit mask under the same lock.

Signed-off-by: Marco Liebel <marco.liebel@oss.qualcomm.com>
Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
2026-11-09 18:45:32 -08:00
Marco Liebel 80cccdb055 target/hexagon: preserve guest event fault and CFI state
Guest event entry must select BADVA0 or BADVA1 through SSR.BVS
instead of copying the stale BADVA array slot. It must also save
SSR.CFI into GSR.CFI so guest return can restore the interrupted
CFI state.

Signed-off-by: Marco Liebel <marco.liebel@oss.qualcomm.com>
Reviewed-by: Brian Cain <brian.cain@oss.qualcomm.com>
Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
2026-11-09 18:45:32 -08:00
Richard Henderson 723622bedb Merge tag 'for-upstream' of https://repo.or.cz/qemu/kevin into staging
Block layer patches

- qcow2: fix snapshot data corruption with discard-no-unref=on
- vmdk: Fix various bugs in handling malicious image files
- vhdx: Prevent out-of-bounds BAT accesses with malicious vhdx files
- iotests: add --quiet arg to hide env variable dump

# -----BEGIN PGP SIGNATURE-----
#
# iQJFBAABCgAvFiEE3D3rFZqa+V09dFb+fwmycsiPL9YFAmrx+EwRHGt3b2xmQHJl
# ZGhhdC5jb20ACgkQfwmycsiPL9Ziiw/+ORADnC0XFs85sEko+V831yp2NO99Gu+U
# GJ/C91rPaNpywIaCDajuPFcJN6xrVgKoMrRimsbTHoZnGN3J9Nd+k4ZMgefih3eD
# pA87hw7yvsngQVDtsmP4hT4vYocHBNTQBbLK9h6FmOaiBMMUn213bOFpbsq+wQ1S
# Yo64AUX6u3tbQP2ls+PV5IxtYYbnSWX9taD2UnA+HCdV24cIEfwrRhuBDspqjsVP
# DTkQwacXIDU9KZyW2tdXOH7l+JwhJL1JYOZJRODfv5xqhvxsetwxn50MKsBX/vXQ
# r2mIw+73FSw05tlrmomMIxE0ssWuMpxgf94L6FftVr8Wg5wgkxPw4Q13IDIyuPck
# gsoQ4sbsSS74AaJgwLuXmYU1M1q90Wviu3WN+MNdfdFIqjqwJCS/2JMu/KV0lkLA
# r2HA6oM/9M8GOcd40IVNcx1jW94OIQDyeP6uv8iPk7riXY76K2AAcYxgFGRqumwG
# 8aW0QiIyNc4dVY1sedL12xRHzPeaEMyZ9+L+tg3ibCjtM/CgzcR2vwFfkkthoGyc
# +bqByp1TX9f4H78IzqBv0c89pFn5mPBpoJzRrlBPE91FycLL76tx9o9MhVWjZpmS
# v5W0ZQwvQo/qhYSZ/AnZQOHW8tfkJv0jn7yLwf6JZbh9OuacY7H50nxMlBoBLMfG
# rDNsmuVL7BE=
# =gMMb
# -----END PGP SIGNATURE-----
# gpg: Signature made Mon 09 Nov 2026 08:43:56 AM PST
# gpg:                using RSA key DC3DEB159A9AF95D3D7456FE7F09B272C88F2FD6
# gpg:                issuer "kwolf@redhat.com"
# gpg: Good signature from "Kevin Wolf <kwolf@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: DC3D EB15 9A9A F95D 3D74  56FE 7F09 B272 C88F 2FD6

* tag 'for-upstream' of https://repo.or.cz/qemu/kevin:
  block/vhdx: Prevent out-of-bounds BAT accesses with malicious vhdx files
  iotests/290: add 'discard' and 'write -z -u' case with a snapshot
  qcow2: fix snapshot data corruption with discard-no-unref=on
  iotests/290: add test case to check 'discard-no-unref' option behavior
  block: add missing coroutine_fn annotations
  block/vmdk: Avoid overflowing multiplication in vmdk_open_vmdk4()
  block/vmdk: Reject a zero cluster_sectors parameter
  block/vmdk: Use larger types for byte counts in vmdk_read_extent()
  block/vmdk: Avoid reading off the end of descriptor memory
  block/vmdk: Avoid assertion if image file has no extents
  iotests: add --quiet arg to hide env variable dump

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2026-11-09 11:58:07 -08:00
Richard Henderson 95dda33f38 Merge tag 's390x-20261109' of https://gitlab.com/efarman/qemu into staging
Fix vhost on s390x

# -----BEGIN PGP SIGNATURE-----
#
# iIsEABYKADMWIQQB3Dhbwk4ZE3uUN6KmTx4R4Fx3tAUCavHWwhUcZmFybWFuQGxp
# bnV4LmlibS5jb20ACgkQpk8eEeBcd7RABwEAmJd9ZeqdsXd1RdXBMEjMmMCIVogn
# xpCpzLKR/OBBsToA/jji9kFeGAtQ8b7vppxiH5pRvnWSAxAHit5zOgMr6H0M
# =SjK7
# -----END PGP SIGNATURE-----
# gpg: Signature made Mon 09 Nov 2026 06:20:50 AM PST
# gpg:                using EDDSA key 01DC385BC24E19137B9437A2A64F1E11E05C77B4
# gpg:                issuer "farman@linux.ibm.com"
# gpg: Good signature from "Eric Farman <farman@linux.ibm.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: D2C6 0504 C9E8 F568 CFE5  87B5 3827 B212 71BF 9562
#      Subkey fingerprint: 01DC 385B C24E 1913 7B94  37A2 A64F 1E11 E05C 77B4

* tag 's390x-20261109' of https://gitlab.com/efarman/qemu:
  vhost: only use config notifier when exists/initialized

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2026-11-09 09:37:33 -08:00
Richard Henderson 0d91bdd6dd Merge tag 'pull-target-arm-20261109' of https://gitlab.com/pm215/qemu into staging
target-arm queue:
 * target/arm/ptw: check XN for ARMv6 in get_S1prot()
 * hw/net/bcm2838_genet: various bugfixes
 * arm/cpu: fix GIC v3 flag for a64fx
 * hw/intc/arm_gic: do not hardcode GICv2 minimum binary point
 * target/arm: Clear the local monitor on AArch32 (v8) exception returns
 * hw/intc/hex-l2vic: avoid shift into sign bit

# -----BEGIN PGP SIGNATURE-----
#
# iQJNBAABCAA3FiEE4aXFk81BneKOgxXPPCUl7RQ2DN4FAmrx0v8ZHHBldGVyLm1h
# eWRlbGxAbGluYXJvLm9yZwAKCRA8JSXtFDYM3sQpD/9bO2J7p/Us50EJzpeEO15z
# 9r1hDTz9x1VvMjCuPOHcM6ByrzaZC0UOBnBNr/NgmSw26UEf/5KR4eukhVemKSkD
# tXnGbktuijzyMCVg4c1jTZXKnsLFi9kNKWM69GO2s8G4/LXiFE/uSXQi40BwIqyc
# aG21bTDplWbuH1DESAN6fge+P9F961Y7W5Qyw8LfTUWTE8XRB41WT6v3J+qEPWpN
# mJ3nyaD4dmh9m57UZQsYt91H9NWvPtkSxepdOXC1H4nhwFE+ZBcZ2dclITO2zPh1
# fWZ6mn5b8UbGwFKqMRNKUNAA54ktN0r1zzzRtCQ2+cMcHbmXRlRP0oCVFlKSN4zd
# cepYMneByqicjfuxaJcKO86TxuFUR5/bY3fTgwLFTQ+ydGAl9Ahv772eQdd4/bT1
# PVD6ebjSEEioS9+OpTuHyoLUuCPIEmFDDtsI/yhUd/k9dLBJGTPCEL2b7mErA+ig
# h6xTqAaIq/pepgAdiKqYLATIn1IStFNIMO5bxuDtJEGC1wyz8vcHQdw3mouVbP3w
# kNqU84veRlwv/4Pqm6MU1H0Drf6pIzRM1QdINq++wV+n0RQU9OsON2iJVZH2Zb+2
# DpeV6/U1P0YdJpPscQwLCp9CO43FbKBkqpl3qsCoyGtqa9vYpg4L5vxFPuvrheBJ
# AFQyJ1L9P3/O6WcVIE4XlQ==
# =9eMU
# -----END PGP SIGNATURE-----
# gpg: Signature made Mon 09 Nov 2026 06:04:47 AM PST
# gpg:                using RSA key E1A5C593CD419DE28E8315CF3C2525ED14360CDE
# gpg:                issuer "peter.maydell@linaro.org"
# gpg: Good signature from "Peter Maydell <peter.maydell@linaro.org>" [unknown]
# gpg:                 aka "Peter Maydell <pmaydell@gmail.com>" [unknown]
# gpg:                 aka "Peter Maydell <pmaydell@chiark.greenend.org.uk>" [unknown]
# gpg:                 aka "Peter Maydell <peter@archaic.org.uk>" [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-20261109' of https://gitlab.com/pm215/qemu:
  hw/intc/hex-l2vic: avoid shift into sign bit
  target/arm: Clear the local monitor on AArch32 (v8) exception returns
  hw/intc/arm_gic: do not hardcode GICv2 minimum binary point
  hw/intc/arm_gic: move num-priority-bits check
  arm/cpu: fix GIC v3 flag for a64fx
  hw/net/bcm2838_genet: fit the RX frame within the guest's buffer
  hw/net/bcm2838_genet: hold RX frames while the ring is full
  hw/net/bcm2838_genet: wrap the TX consumer index at 16 bits
  target/arm/ptw: check XN for ARMv6 in get_S1prot()

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2026-11-09 09:36:54 -08:00
Richard Henderson 144393da8d Merge tag 'whpx-fix-0-pull-request' of https://github.com/mediouni-m/qemu into staging
whpx: QEMU 11.2 pull request

This is a cut-down version of the "whpx: i386: updates for QEMU 11.2" patchset
with fixes for QEMU 11.2.

These include:

- fixing reset
- CPUID fixes (leaf 0xd)
- handle systems where nested virt is advertised but not working
- xsave fixes

v1 -> v2:
- Adding Signed-off-by to all commits
- Rewording

# -----BEGIN PGP SIGNATURE-----
#
# iJEEABYKADkWIQQcss1Irh5YnrL54hsUIDoXkgPV/AUCavHKIBsUgAAAAAAEAA5t
# YW51MiwyLjUrMS4xMiwwLDMACgkQFCA6F5ID1fxmYwEAufhyj6bCQadi9Uwe7ibv
# IPjjMaHbJCNdN/04+SETImYBAOlRkkl5zldlOdCTTxBObgupIDqxPAR2f27cuIX1
# IUwA
# =ErmZ
# -----END PGP SIGNATURE-----
# gpg: Signature made Mon 09 Nov 2026 05:26:56 AM PST
# gpg:                using EDDSA key 1CB2CD48AE1E589EB2F9E21B14203A179203D5FC
# gpg: Good signature from "Mohamed Mediouni <mohamed@unpredictable.fr>" [unknown]
# gpg: Signature notation: manu=2,2.5+1.12,0,3
# gpg: WARNING: This key is not certified with a trusted signature!
# gpg:          There is no indication that the signature belongs to the owner.
# Primary key fingerprint: 1CB2 CD48 AE1E 589E B2F9  E21B 1420 3A17 9203 D5FC

* tag 'whpx-fix-0-pull-request' of https://github.com/mediouni-m/qemu:
  whpx: i386: fall back to xAPIC when the MSR exit bitmap is unavailable
  whpx: i386: do not require ProcessorFeaturesBanks on legacy Windows
  whpx: i386: forward the dynamic EBX of CPUID[0xD] sub-leaves 0 and 1, not 1 and 2
  target/i386/whpx: handle processor reset
  whpx: i386: avoid updating hflags for vmexits
  target/i386/whpx: whpx_get_xsave_state error handling
  target/i386/whpx: fix VMX capability MSR values

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2026-11-09 07:59:32 -08:00
Thomas Huth 67198583a1 block/vhdx: Prevent out-of-bounds BAT accesses with malicious vhdx files
virtual_disk_size is read directly from a VHDX image's metadata region
and never checked for sane sizes.  The 64 TiB limit (VHDX_MAX_IMAGE_SIZE)
is only enforced in vhdx_co_create(), so it limits images QEMU creates
but never images QEMU opens.

Without the bound, vhdx_calc_bat_entries() computes the block count
into a uint32_t, so a huge image size gets truncated and the BAT is
undersized relative to total_sectors.
vhdx_block_translate() then converts sector numbers into BAT indices
with no bounds check, allowing out-of-bounds access on the BAT array
from both the read and write paths.

To fix the problem, add a VHDX_MAX_IMAGE_SIZE check to vhdx_parse_metadata()
so images opened for reading are subject to the same limit as images
created by QEMU.
With this limit, the calculation in vhdx_calc_bat_entries() cannot get
truncated anymore (block_size is at least 1 MiB):

 VHDX_MAX_IMAGE_SIZE / block_size = 64 TiB / 1 MiB = 64 MiB

... and 64 MiB fit nicely into 32 bits.

To be really on the safe side, let's also add an assertion in
vhdx_block_translate() to catch accesses that exceeds the allocated
entry count.

Buglink: https://gitlab.com/qemu-project/qemu/-/work_items/3762
Reported-by: Daniel Wade <danjwade95@gmail.com>
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4470
Reported-by: Mayank Jangid (OpenSec)
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4487
Reported-by: Ken Hsu, Royce Lu, and Bo Qu of Palo Alto Networks
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4638
Reported-by: Thai Duong (Calif.io)
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4733
Reported-by: Xiang Chen
Signed-off-by: Thomas Huth <thuth@redhat.com>
Message-ID: <20261023130023.539252-1-thuth@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2026-11-09 16:32:35 +01:00
Andrey Drobyshev 8f23f50082 iotests/290: add 'discard' and 'write -z -u' case with a snapshot
Before the previous commit, issuing 'discard' and 'write -z -u'
operations with discard-no-unref=on option enabled led to data
corruption.  Add a test to cover this case.

Signed-off-by: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
Reviewed-by: Denis V. Lunev <den@openvz.org>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Message-ID: <20261105161515.794213-4-andrey.drobyshev@virtuozzo.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2026-11-09 16:32:35 +01:00
Andrey Drobyshev 3fe45543bf qcow2: fix snapshot data corruption with discard-no-unref=on
Whenever option discard-no-unref=on is enabled, we bypass refcount
machinery and unconditionally punch hole in the data on 'discard' and
'write -z -u' paths.  However, when this same cluster is also referenced
by an internal snapshot, such operations lead to problems.  The active L2
table is copied before it is changed, so the snapshot metadata stays
correct, but the host range under it is punched out and the snapshot reads
zeroes there afterwards. qemu-img check finds nothing wrong.

Fix this by guarding the 'keep_reference' flag by the presence of the
QCOW_OFLAG_COPIED bit.  I.e. only proceed with unconditional data
punching if we own this cluster exclusively.

Cc: qemu-stable@nongnu.org
Fixes: 42a2890a76 ("qcow2: add discard-no-unref option")
Signed-off-by: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
Reviewed-by: Denis V. Lunev <den@openvz.org>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Message-ID: <20261105161515.794213-3-andrey.drobyshev@virtuozzo.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2026-11-09 16:32:35 +01:00
Andrey Drobyshev 26aae51023 iotests/290: add test case to check 'discard-no-unref' option behavior
We basically fill 2 images with identical data and perform discard
operations with and without 'discard-no-unref' enabled.  Then we check
that images still read identically, that their disk usage is the same
(i.e. fallocate(FALLOC_FL_PUNCH_HOLE|FALLOC_FL_KEEP_SIZE) is called for
both) and that with the option enabled cluster is still marked as
allocated in "qemu-img map" output.  We also check that the option
doesn't work with qcow2 v2 images.

Signed-off-by: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
Message-ID: <20261105161515.794213-2-andrey.drobyshev@virtuozzo.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2026-11-09 16:32:35 +01:00
Marc-André Lureau ae8aacb25f block: add missing coroutine_fn annotations
The functions call coroutine functions or are called by coroutine.

Add an assert() in qcow2_do_close() code path which calls a
no_coroutine_fn bdrv_graph_wrlock_drained().

Add an assert() in qcow2_update_options_commit() in the coroutine
path.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-ID: <20260730171027.1023696-1-marcandre.lureau@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2026-11-09 16:32:35 +01:00