Patch Round-up for stable 6.0.1, freeze on 2021-10-26
Subsystems (3)
cover Patch Round-up for stable 6.0.1, freeze on 2021-10-26
Hi everyone,
The following new patches are queued for QEMU stable v6.0.1:
https://gitlab.com/qemu-project/qemu/-/commits/stable-6.0-staging/
Patch freeze is 2021-10-26, and the release is planned for 2021-10-28:
https://wiki.qemu.org/Planning/6.0
Please respond here or CC [email protected] on any additional patches you think should (or shouldn't) be included in the release.
Thanks!
----------------------------------------------------------------
David Hildenbrand (2):
virtio-balloon: don't start free page hinting if postcopy is possible
virtio-mem-pci: Fix memory leak when creating MEMORY_DEVICE_SIZE_CHANGE event
Dr. David Alan Gilbert (1):
audio: Never send migration section
Gerd Hoffmann (3):
uas: add stream number sanity checks. usb/redir: avoid dynamic stack allocation (CVE-2021-3527)
usb: limit combined packets to 1 MiB (CVE-2021-3527)
Giuseppe Musacchio (1):
target/ppc: Fix load endianness for lxvwsx/lxvdsx
Gollu Appalanaidu (1):
hw/block/nvme: align with existing style
Greg Kurz (1):
docs/system: Document the removal of "compat" property for POWER CPUs
Igor Mammedov (3):
tests: acpi: prepare for changing DSDT tables
acpi: pc: revert back to v5.2 PCI slot enumeration
tests: acpi: pc: update expected DSDT blobs
Jason Wang (2):
vhost-vdpa: don't initialize backend_features
virtio-net: fix use after unmap/free for sg
Kevin Wolf (1):
hmp: Fix loadvm to resume the VM on success instead of failure
Klaus Jensen (2):
hw/nvme: fix missing check for PMR capability hw/nvme: fix pin-based interrupt behavior (again)
Kunkun Jiang (1):
vfio: Fix unregister SaveVMHandler in vfio_migration_finalize
Leonardo Bras (1):
yank: Unregister function when using TLS migration
Li Qiang (7):
vhost-user-gpu: fix memory disclosure in virgl_cmd_get_capset_info (CVE-2021-3545)
vhost-user-gpu: fix resource leak in 'vg_resource_create_2d' (CVE-2021-3544)
vhost-user-gpu: fix memory leak in vg_resource_attach_backing (CVE-2021-3544)
vhost-user-gpu: fix memory leak while calling 'vg_resource_unref' (CVE-2021-3544)
vhost-user-gpu: fix memory leak in 'virgl_cmd_resource_unref' (CVE-2021-3544)
vhost-user-gpu: fix memory leak in 'virgl_resource_attach_backing' (CVE-2021-3544)
vhost-user-gpu: fix OOB write in 'virgl_cmd_get_capset' (CVE-2021-3546)
Li Zhijian (1):
migration/rdma: Fix cm_event used before being initialized
Marcel Apfelbaum (3):
hw/rdma: Fix possible mremap overflow in the pvrdma device (CVE-2021-3582)
pvrdma: Ensure correct input on ring init (CVE-2021-3607)
pvrdma: Fix the ring init error flow (CVE-2021-3608)
Mark Cave-Ayland (2):
esp: only assert INTR_DC interrupt flag if selection fails
esp: only set ESP_RSEQ at the start of the select sequence
Markus Armbruster (1):
hmp: Unbreak "change vnc"
Max Filippov (1):
target/xtensa: fix access ring in l32ex
Nir Soffer (1):
qemu-nbd: Change default cache mode to writeback
Paolo Bonzini (7):
vl: allow not specifying size in -m when using -M memory-backend
qemu-option: support accept-any QemuOptsList in qemu_opts_absorb_qdict
qemu-config: load modules when instantiating option groups
qemu-config: parse configuration files to a QDict
vl: plumb keyval-based options into -readconfig
vl: plug -object back into -readconfig
configure: fix detection of gdbus-codegen
Pavel Pisa (1):
hw/net/can: sja1000 fix buff2frame_bas and buff2frame_pel when dlc is out of std CAN 8 bytes
Peng Liang (1):
runstate: Initialize Error * to NULL
Peter Maydell (1):
target/arm: Don't skip M-profile reset entirely in user mode
Philippe Mathieu-Daudé (11):
hw/pci-host/q35: Ignore write of reserved PCIEXBAR LENGTH field block/nvme: Fix VFIO_MAP_DMA failed: No space left on device crypto/tlscreds: Introduce qcrypto_tls_creds_check_endpoint() helper block/nbd: Use qcrypto_tls_creds_check_endpoint()
qemu-nbd: Use qcrypto_tls_creds_check_endpoint() chardev/socket: Use qcrypto_tls_creds_check_endpoint() migration/tls: Use qcrypto_tls_creds_check_endpoint() ui/vnc: Use qcrypto_tls_creds_check_endpoint()
crypto: Make QCryptoTLSCreds* structures private hw/sd/sdcard: Document out-of-range addresses for SEND_WRITE_PROT hw/sd/sdcard: Fix assertion accessing out-of-range addresses with CMD30
Richard Henderson (4):
linux-user/aarch64: Enable hwcap for RND, BTI, and MTE target/i386: Exit tb after wrmsr
tcg/sparc: Fix temp_allocate_frame vs sparc stack bias
tcg: Allocate sufficient storage in temp_allocate_frame
Stefan Hajnoczi (1):
sockets: update SOCKET_ADDRESS_TYPE_FD listen(2) backlog
Stefan Reiter (1):
monitor/qmp: fix race on CHR_EVENT_CLOSED without OOB
Zenghui Yu (1):
multi-process: Initialize variables declared with g_auto*
Zhenzhong Duan (1):
vl: Fix an assert failure in error path
audio/audio.c | 10 +++ block/nbd.c | 6 +- block/nvme.c | 22 ++++++ blockdev-nbd.c | 6 +- chardev/char-socket.c | 18 ++--- configure | 4 +- contrib/vhost-user-gpu/vhost-user-gpu.c | 7 ++ contrib/vhost-user-gpu/virgl.c | 17 ++++- crypto/tls-cipher-suites.c | 7 ++ crypto/tlscreds.c | 12 +++ crypto/tlscredsanon.c | 2 + crypto/tlscredspriv.h | 45 +++++++++++ crypto/tlscredspsk.c | 2 + crypto/tlscredsx509.c | 1 + crypto/tlssession.c | 1 + docs/system/removed-features.rst | 6 ++ docs/tools/qemu-nbd.rst | 6 +- hw/block/nvme-ns.c | 2 +- hw/block/nvme.c | 89 ++++++++++++++-------- hw/block/nvme.h | 1 + hw/i386/acpi-build.c | 9 ++- hw/net/can/can_sja1000.c | 8 ++ hw/net/virtio-net.c | 39 ++++++++-- hw/pci-host/q35.c | 3 + hw/rdma/vmw/pvrdma_cmd.c | 7 ++ hw/rdma/vmw/pvrdma_dev_ring.c | 2 +- hw/rdma/vmw/pvrdma_main.c | 5 ++ hw/remote/memory.c | 5 +- hw/remote/proxy.c | 3 +- hw/scsi/esp.c | 13 +++- hw/sd/sd.c | 9 ++- hw/usb/combined-packet.c | 4 +- hw/usb/dev-uas.c | 11 +++ hw/usb/redirect.c | 6 +- hw/vfio/migration.c | 1 + hw/virtio/vhost-vdpa.c | 3 - hw/virtio/virtio-balloon.c | 13 ++++ hw/virtio/virtio-mem-pci.c | 7 +- include/block/nvme.h | 10 +-- include/block/qdict.h | 2 - include/crypto/tls-cipher-suites.h | 6 -- include/crypto/tlscreds.h | 30 ++++---- include/crypto/tlscredsanon.h | 12 --- include/crypto/tlscredspsk.h | 12 --- include/crypto/tlscredsx509.h | 10 --- include/qapi/qmp/qdict.h | 3 + include/qemu/config-file.h | 7 +- linux-user/elfload.c | 13 ++++ migration/channel.c | 26 ++++--- migration/multifd.c | 3 +- migration/qemu-file-channel.c | 4 +- migration/rdma.c | 1 - migration/tls.c | 6 +- monitor/hmp-cmds.c | 4 +- monitor/qmp.c | 40 +++++----- qemu-nbd.c | 25 +++--- softmmu/runstate.c | 2 +- softmmu/vl.c | 130 +++++++++++++++++++++++--------- stubs/meson.build | 1 + stubs/module-opts.c | 6 ++ target/arm/cpu.c | 19 +++++ target/i386/tcg/translate.c | 2 + target/ppc/translate/vsx-impl.c.inc | 4 +- target/xtensa/translate.c | 2 +- tcg/sparc/tcg-target.c.inc | 16 ++-- tcg/tcg.c | 40 +++++++--- tests/data/acpi/pc/DSDT | Bin 6002 -> 6002 bytes tests/data/acpi/pc/DSDT.acpihmat | Bin 7327 -> 7327 bytes tests/data/acpi/pc/DSDT.bridge | Bin 8668 -> 8668 bytes tests/data/acpi/pc/DSDT.cphp | Bin 6466 -> 6466 bytes tests/data/acpi/pc/DSDT.dimmpxm | Bin 7656 -> 7656 bytes tests/data/acpi/pc/DSDT.hpbridge | Bin 5969 -> 5969 bytes tests/data/acpi/pc/DSDT.ipmikcs | Bin 6074 -> 6074 bytes tests/data/acpi/pc/DSDT.memhp | Bin 7361 -> 7361 bytes tests/data/acpi/pc/DSDT.nohpet | Bin 5860 -> 5860 bytes tests/data/acpi/pc/DSDT.numamem | Bin 6008 -> 6008 bytes ui/vnc.c | 7 +- util/qemu-config.c | 99 ++++++++++++++++-------- util/qemu-option.c | 3 +- util/qemu-sockets.c | 29 +++++-- 80 files changed, 685 insertions(+), 301 deletions(-) create mode 100644 stubs/module-opts.c
PATCH 1/64 multi-process: Initialize variables declared with g_auto*
From: Zenghui Yu <[email protected]>
Quote docs/devel/style.rst (section "Automatic memory deallocation"):
* Variables declared with g_auto* MUST always be initialized, otherwise the cleanup function will use uninitialized stack memory
Initialize @name properly to get rid of the compilation error (using gcc-7.3.0 on CentOS):
../hw/remote/proxy.c: In function 'pci_proxy_dev_realize':/usr/include/glib-2.0/glib/glib-autocleanups.h:28:3: error: 'name' may be used uninitialized in this function [-Werror=maybe-uninitialized]
g_free (*pp);
^~~~~~~~~~~~../hw/remote/proxy.c:350:30: note: 'name' was declared here
g_autofree char *name;
^~~~Message-id: [email protected]
--- hw/remote/memory.c | 5 ++--- hw/remote/proxy.c | 3 +-- 2 files changed, 3 insertions(+), 5 deletions(-)
hw/remote/memory.c +2 -3
@@ -42,10 +42,9 @@ void remote_sysmem_reconfig(MPQemuMsg *msg, Error **errp)remote_sysmem_reset (); -for (region =0 ; region < msg->num_fds; region++) { - g_autofree char *name; +for (region =0 ; region < msg->num_fds; region++, suffix++) { + g_autofree char *name = g_strdup_printf("remote-mem-%u", suffix); subregion =g_new (MemoryRegion,1 ); - name =g_strdup_printf ("remote-mem-%u" , suffix++); memory_region_init_ram_from_fd(subregion, NULL, name, sysmem_info->sizes[region], true, msg->fds[region],
hw/remote/proxy.c +1 -2
@@ -347,13 +347,12 @@ static void probe_pci_info(PCIDevice *dev, Error **errp) PCI_BASE_ADDRESS_SPACE_IO :PCI_BASE_ADDRESS_SPACE_MEMORY ;if (size) { - g_autofree char *name; + g_autofree char *name = g_strdup_printf("bar-region-%d", i); pdev->region[i].dev = pdev; pdev->region[i].present = true;if (type ==PCI_BASE_ADDRESS_SPACE_MEMORY ) { pdev->region[i].memory = true; } - name =g_strdup_printf ("bar-region-%d" , i);memory_region_init_io (&pdev->region[i].mr,OBJECT (pdev), &proxy_mr_ops, &pdev->region[i], name, size);
Signature · 1 line
2.25.1
PATCH 2/64 linux-user/aarch64: Enable hwcap for RND, BTI, and MTE
In reply to Michael RothFrom: Richard Henderson <[email protected]>
These three features are already enabled by TCG, but are missing their hwcap bits. Update HWCAP2 from linux v5.12.
Message-id: [email protected]
--- linux-user/elfload.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
linux-user/elfload.c +13 -0
@@ -586,6 +586,16 @@ enum {ARM_HWCAP2_A64_SVESM4 =1 <<6 ,ARM_HWCAP2_A64_FLAGM2 =1 <<7 ,ARM_HWCAP2_A64_FRINT =1 <<8 , +ARM_HWCAP2_A64_SVEI8MM =1 <<9 , +ARM_HWCAP2_A64_SVEF32MM =1 <<10 , +ARM_HWCAP2_A64_SVEF64MM =1 <<11 , +ARM_HWCAP2_A64_SVEBF16 =1 <<12 , +ARM_HWCAP2_A64_I8MM =1 <<13 , +ARM_HWCAP2_A64_BF16 =1 <<14 , +ARM_HWCAP2_A64_DGH =1 <<15 , +ARM_HWCAP2_A64_RNG =1 <<16 , +ARM_HWCAP2_A64_BTI =1 <<17 , + ARM_HWCAP2_A64_MTE = 1 << 18, };#define ELF_HWCAP get_elf_hwcap()
@@ -640,6 +650,9 @@ static uint32_t get_elf_hwcap2(void)GET_FEATURE_ID (aa64_dcpodp,ARM_HWCAP2_A64_DCPODP );GET_FEATURE_ID (aa64_condm_5,ARM_HWCAP2_A64_FLAGM2 );GET_FEATURE_ID (aa64_frint,ARM_HWCAP2_A64_FRINT ); +GET_FEATURE_ID (aa64_rndr,ARM_HWCAP2_A64_RNG ); +GET_FEATURE_ID (aa64_bti,ARM_HWCAP2_A64_BTI ); +GET_FEATURE_ID (aa64_mte,ARM_HWCAP2_A64_MTE );return hwcaps; }
Signature · 1 line
2.25.1
PATCH 3/64 docs/system: Document the removal of "compat" property for POWER CPUs
In reply to Michael RothFrom: Greg Kurz <[email protected]>
This is just an oversight.
Message-Id: <[email protected]>
--- docs/system/removed-features.rst | 6 ++++++ 1 file changed, 6 insertions(+)
docs/system/removed-features.rst +6 -0
@@ -285,6 +285,12 @@ The RISC-V no MMU cpus have been removed. The two CPUs: ``rv32imacu-nommu`` and ``rv64imacu-nommu`` can no longer be used. Instead the MMU status can be specified via the CPU ``mmu`` option when using the ``rv32`` or ``rv64`` CPUs. +``compat`` property of server class POWER CPUs (removed in 6.0) +''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + +The ``max-cpu-compat`` property of the ``pseries`` machine type should be used +instead. + System emulator machines ------------------------
Signature · 1 line
2.25.1
PATCH 4/64 monitor/qmp: fix race on CHR_EVENT_CLOSED without OOB
In reply to Michael RothFrom: Stefan Reiter <[email protected]>
The QMP dispatcher coroutine holds the qmp_queue_lock over a yield point, where it expects to be rescheduled from the main context. If a CHR_EVENT_CLOSED event is received just then, it can race and block the main thread on the mutex in monitor_qmp_cleanup_queue_and_resume.
monitor_resume does not need to be called from main context, so we can call it immediately after popping a request from the queue, which allows us to drop the qmp_queue_lock mutex before yielding.
Message-Id: <[email protected]>
--- monitor/qmp.c | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-)
monitor/qmp.c +22 -18
@@ -257,24 +257,6 @@ void coroutine_fn monitor_qmp_dispatcher_co(void *data)trace_monitor_qmp_in_band_dequeue (req_obj, req_obj->mon->qmp_requests->length); -if (qatomic_xchg (&qmp_dispatcher_co_busy, true) == true) { -/* -* Someone rescheduled us (probably because a new requests -* came in), but we didn't actually yield. Do that now, -* only to be immediately reentered and removed from the -* list of scheduled coroutines. -*/ -qemu_coroutine_yield (); - } - -/* -* Move the coroutine from iohandler_ctx to qemu_aio_context for -* executing the command handler so that it can make progress if it -* involves an AIO_WAIT_WHILE(). -*/ -aio_co_schedule (qemu_get_aio_context (), qmp_dispatcher_co); -qemu_coroutine_yield (); -/* * @req_obj has a request, we hold req_obj->mon->qmp_queue_lock */
@@ -298,8 +280,30 @@ void coroutine_fn monitor_qmp_dispatcher_co(void *data)monitor_resume (&mon->common); } +/* +* Drop the queue mutex now, before yielding, otherwise we might +* deadlock if the main thread tries to lock it. +*/ qemu_mutex_unlock (&mon->qmp_queue_lock); +if (qatomic_xchg (&qmp_dispatcher_co_busy, true) == true) { +/* +* Someone rescheduled us (probably because a new requests +* came in), but we didn't actually yield. Do that now, +* only to be immediately reentered and removed from the +* list of scheduled coroutines. +*/ +qemu_coroutine_yield (); + } + +/* +* Move the coroutine from iohandler_ctx to qemu_aio_context for +* executing the command handler so that it can make progress if it +* involves an AIO_WAIT_WHILE(). +*/ +aio_co_schedule (qemu_get_aio_context (), qmp_dispatcher_co); +qemu_coroutine_yield (); +/* Process request */ if (req_obj->req) {if (trace_event_get_state (TRACE_MONITOR_QMP_CMD_IN_BAND )) {
Signature · 1 line
2.25.1
PATCH 5/64 migration/rdma: Fix cm_event used before being initialized
In reply to Michael RothFrom: Li Zhijian <[email protected]>
A segmentation fault was triggered when i try to abort a postcopy + rdma migration.
since rdma_ack_cm_event releases a uninitialized cm_event in these case.
like below:
2496 ret = rdma_get_cm_event(rdma->channel, &cm_event);
2497 if (ret) {
2498 perror("rdma_get_cm_event after rdma_connect");
2499 ERROR(errp, "connecting to destination!");
2500 rdma_ack_cm_event(cm_event); <<<< cause segmentation fault
2501 goto err_rdma_source_connect;2502 }
Refer to the rdma_get_cm_event() code, cm_event will be updated/changed only if rdma_get_cm_event() returns 0. So it's okey to remove the ack in error patch.
Message-Id: <[email protected]>
--- migration/rdma.c | 1 - 1 file changed, 1 deletion(-)
migration/rdma.c +0 -1
@@ -2497,7 +2497,6 @@ static int qemu_rdma_connect(RDMAContext *rdma, Error **errp)if (ret) {perror ("rdma_get_cm_event after rdma_connect" );ERROR (errp,"connecting to destination!" ); -rdma_ack_cm_event (cm_event); goto err_rdma_source_connect; }
Signature · 1 line
2.25.1
PATCH 6/64 target/i386: Exit tb after wrmsr
In reply to Michael RothFrom: Richard Henderson <[email protected]>
At minimum, wrmsr can change efer, which affects HF_LMA.
Message-Id: <[email protected]>
--- target/i386/tcg/translate.c | 2 ++ 1 file changed, 2 insertions(+)
target/i386/tcg/translate.c +2 -0
@@ -7198,6 +7198,8 @@ static target_ulong disas_insn(DisasContext *s, CPUState *cpu)gen_helper_rdmsr (cpu_env); }else {gen_helper_wrmsr (cpu_env); +gen_jmp_im (s, s->pc - s->cs_base); +gen_eob (s); } }break ;
Signature · 1 line
2.25.1
PATCH 7/64 target/ppc: Fix load endianness for lxvwsx/lxvdsx
In reply to Michael RothFrom: Giuseppe Musacchio <[email protected]>
TARGET_WORDS_BIGENDIAN may not match the machine endianness if that's a runtime-configurable parameter.
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/212
Message-Id: <[email protected]>
--- target/ppc/translate/vsx-impl.c.inc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
target/ppc/translate/vsx-impl.c.inc +2 -2
@@ -139,7 +139,7 @@ static void gen_lxvwsx(DisasContext *ctx) gen_addr_reg_index(ctx, EA); data = tcg_temp_new_i32(); - tcg_gen_qemu_ld_i32(data, EA, ctx->mem_idx, MO_TEUL); + tcg_gen_qemu_ld_i32(data, EA, ctx->mem_idx, DEF_MEMOP(MO_UL)); tcg_gen_gvec_dup_i32(MO_UL, vsr_full_offset(xT(ctx->opcode)), 16, 16, data); tcg_temp_free(EA);
@@ -162,7 +162,7 @@ static void gen_lxvdsx(DisasContext *ctx) gen_addr_reg_index(ctx, EA); data = tcg_temp_new_i64(); - tcg_gen_qemu_ld_i64(data, EA, ctx->mem_idx, MO_TEQ); + tcg_gen_qemu_ld_i64(data, EA, ctx->mem_idx, DEF_MEMOP(MO_Q)); tcg_gen_gvec_dup_i64(MO_Q, vsr_full_offset(xT(ctx->opcode)), 16, 16, data); tcg_temp_free(EA);
Signature · 1 line
2.25.1
PATCH 8/64 vl: allow not specifying size in -m when using -M memory-backend
In reply to Michael RothFrom: Paolo Bonzini <[email protected]>
Starting in QEMU 6.0's commit f5c9fcb82d ("vl: separate qemu_create_machine", 2020-12-10), a function have_custom_ram_size() replaced the return value of set_memory_options().
The purpose of the return value was to record the presence of "-m size", and if it was not there, change the default RAM size to the size of the memory backend passed with "-M memory-backend".
With that commit, however, have_custom_ram_size() is now queried only after set_memory_options has stored the fixed-up RAM size in QemuOpts for "future use". This was actually the only future use of the fixed-up RAM size, so remove that code and fix the bug.
--- softmmu/vl.c | 2 -- 1 file changed, 2 deletions(-)
softmmu/vl.c +0 -2
@@ -2025,8 +2025,6 @@ static void set_memory_options(MachineClass *mc)exit (EXIT_FAILURE ); } -/* store value for the future use */ -qemu_opt_set_number (opts,"size" , ram_size, &error_abort); maxram_size = ram_size;if (qemu_opt_get (opts,"maxmem" )) {
Signature · 1 line
2.25.1
PATCH 9/64 target/xtensa: fix access ring in l32ex
In reply to Michael RothFrom: Max Filippov <[email protected]>
l32ex does memory access as all regular load/store operations at CRING level. Fix apparent pasto from l32e that caused it to use RING instead.
This is a correctness issue, not a security issue, because in the worst case the privilege level of memory access may be lowered, resulting in an exception when the correct implementation would've succeeded. In no case it would allow memory access that would've raised an exception in the correct implementation.
--- target/xtensa/translate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/xtensa/translate.c +1 -1
@@ -1817,7 +1817,7 @@ static void translate_l32ex(DisasContext *dc, const OpcodeArg arg[],tcg_gen_mov_i32 (addr, arg[1 ].in);gen_load_store_alignment (dc,2 , addr, true);gen_check_exclusive (dc, addr, false); -tcg_gen_qemu_ld_i32 (arg[0 ].out, addr, dc->ring,MO_TEUL ); +tcg_gen_qemu_ld_i32 (arg[0 ].out, addr, dc->cring,MO_TEUL );tcg_gen_mov_i32 (cpu_exclusive_addr, addr);tcg_gen_mov_i32 (cpu_exclusive_val, arg[0 ].out);tcg_temp_free (addr);
Signature · 1 line
2.25.1
PATCH 10/64 qemu-option: support accept-any QemuOptsList in qemu_opts_absorb_qdict
In reply to Michael RothFrom: Paolo Bonzini <[email protected]>
--- util/qemu-option.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
util/qemu-option.c +2 -1
@@ -1056,7 +1056,8 @@ bool qemu_opts_absorb_qdict(QemuOpts *opts, QDict *qdict, Error **errp)while (entry !=NULL ) { next =qdict_next (qdict, entry); -if (find_desc_by_name (opts->list->desc, entry->key)) { +if (opts_accepts_any (opts->list) || +find_desc_by_name (opts->list->desc, entry->key)) {if (!qemu_opts_from_qdict_entry (opts, entry, errp)) {return false; }
Signature · 1 line
2.25.1
PATCH 11/64 qemu-config: load modules when instantiating option groups
In reply to Michael RothFrom: Paolo Bonzini <[email protected]>
Right now the SPICE module is special cased to be loaded when processing of the -spice command line option. However, the spice option group can also be brought in via -readconfig, in which case the module is not loaded.
Add a generic hook to load modules that provide a QemuOpts group, and use it for the "spice" and "iscsi" groups.
--- include/qemu/config-file.h | 2 +- softmmu/vl.c | 21 +++++++++++++++++---- stubs/meson.build | 1 + stubs/module-opts.c | 6 ++++++ util/qemu-config.c | 1 + 5 files changed, 26 insertions(+), 5 deletions(-) create mode 100644 stubs/module-opts.c
include/qemu/config-file.h +1 -1
@@ -1,7 +1,7 @@#ifndef QEMU_CONFIG_FILE_H #define QEMU_CONFIG_FILE_H - +void qemu_load_module_for_opts (const char *group);QemuOptsList *qemu_find_opts (const char *group);QemuOptsList *qemu_find_opts_err (const char *group,Error **errp);QemuOpts *qemu_find_opts_singleton (const char *group);
softmmu/vl.c +17 -4
@@ -2613,6 +2613,23 @@ void qmp_x_exit_preconfig(Error **errp) } } +#ifdef CONFIG_MODULES +void qemu_load_module_for_opts (const char *group) +{ +static bool spice_tried; +if (g_str_equal (group,"spice" ) && !spice_tried) { +ui_module_load_one ("spice-core" ); + spice_tried = true; + } + +static bool iscsi_tried; +if (g_str_equal (group,"iscsi" ) && !iscsi_tried) { +block_module_load_one ("iscsi" ); + iscsi_tried = true; + } +} +#endif +void qemu_init (int argc,char **argv,char **envp) {QemuOpts *opts;
@@ -3372,10 +3389,6 @@ void qemu_init(int argc, char **argv, char **envp)break ;case QEMU_OPTION_spice: olist =qemu_find_opts_err ("spice" ,NULL ); -if (!olist) { -ui_module_load_one ("spice-core" ); - olist =qemu_find_opts ("spice" ); - }if (!olist) {error_report ("spice support is disabled" );exit (1 );
stubs/meson.build +1 -0
@@ -22,6 +22,7 @@ stub_ss.add(files('isa-bus.c')) stub_ss.add(files('is-daemonized.c')) stub_ss.add(when: 'CONFIG_LINUX_AIO', if_true: files('linux-aio.c')) stub_ss.add(files('migr-blocker.c')) +stub_ss.add(files('module-opts.c')) stub_ss.add(files('monitor.c')) stub_ss.add(files('monitor-core.c')) stub_ss.add(files('pci-bus.c'))
stubs/module-opts.c new file +6 -0
@@ -0,0 +1,6 @@ +#include "qemu/osdep.h" +#include "qemu/config-file.h" + +void qemu_load_module_for_opts (const char *group) +{ +}
util/qemu-config.c +1 -0
@@ -16,6 +16,7 @@ static QemuOptsList *find_list(QemuOptsList **lists, const char *group, {int i; +qemu_load_module_for_opts (group);for (i =0 ; lists[i] !=NULL ; i++) {if (strcmp (lists[i]->name, group) ==0 )break ;
Signature · 1 line
2.25.1
PATCH 12/64 qemu-config: parse configuration files to a QDict
In reply to Michael RothFrom: Paolo Bonzini <[email protected]>
Change the parser to put the values into a QDict and pass them to a callback. qemu_config_parse's QemuOpts creation is itself turned into a callback function.
This is useful for -readconfig to support keyval-based options; getting a QDict from the parser removes a roundtrip from QDict to QemuOpts and then back to QDict.
Unfortunately there is a disadvantage in that semantic errors will point to the last line of the group, because the entries of the QDict do not have a location attached.
Message-Id: <[email protected]>
--- include/qemu/config-file.h | 7 ++- softmmu/vl.c | 4 +- util/qemu-config.c | 98 ++++++++++++++++++++++++++------------ 3 files changed, 76 insertions(+), 33 deletions(-)
include/qemu/config-file.h +6 -1
@@ -1,6 +1,8 @@#ifndef QEMU_CONFIG_FILE_H #define QEMU_CONFIG_FILE_H +typedef void QEMUConfigCB (const char *group,QDict *qdict,void *opaque,Error **errp); +void qemu_load_module_for_opts (const char *group);QemuOptsList *qemu_find_opts (const char *group);QemuOptsList *qemu_find_opts_err (const char *group,Error **errp);
@@ -14,7 +16,10 @@ void qemu_config_write(FILE *fp);int qemu_config_parse (FILE *fp,QemuOptsList **lists,const char *fname,Error **errp); -int qemu_read_config_file (const char *filename,Error **errp); +/* A default callback for qemu_read_config_file(). */ +void qemu_config_do_parse (const char *group,QDict *qdict,void *opaque,Error **errp); + +int qemu_read_config_file (const char *filename,QEMUConfigCB *f,Error **errp);/* Parse QDict options as a replacement for a config file (allowing multiple enumerated (0..(n-1)) configuration "sections") */
softmmu/vl.c +2 -2
@@ -2119,7 +2119,7 @@ static void qemu_read_default_config_file(Error **errp)int ret; g_autofree char *file = get_relocated_path(CONFIG_QEMU_CONFDIR "/qemu.conf"); - ret =qemu_read_config_file (file, errp); + ret =qemu_read_config_file (file, qemu_config_do_parse, errp);if (ret <0 ) {if (ret == -ENOENT ) {error_free (*errp);
@@ -3385,7 +3385,7 @@ void qemu_init(int argc, char **argv, char **envp)qemu_plugin_opt_parse (optarg, &plugin_list);break ;case QEMU_OPTION_readconfig: -qemu_read_config_file (optarg, &error_fatal); +qemu_read_config_file (optarg, qemu_config_do_parse, &error_fatal);break ;case QEMU_OPTION_spice: olist =qemu_find_opts_err ("spice" ,NULL );
util/qemu-config.c +68 -30
150 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH 13/64 vl: plumb keyval-based options into -readconfig
In reply to Michael RothFrom: Paolo Bonzini <[email protected]>
Let -readconfig support parsing command line options into QDict or QemuOpts. This will be used to add back support for objects in -readconfig.
Message-Id: <[email protected]>
--- include/block/qdict.h | 2 - include/qapi/qmp/qdict.h | 3 ++ softmmu/vl.c | 83 ++++++++++++++++++++++++++++------------ 3 files changed, 62 insertions(+), 26 deletions(-)
include/block/qdict.h +0 -2
@@ -20,8 +20,6 @@ void qdict_join(QDict *dest, QDict *src, bool overwrite);void qdict_extract_subqdict (QDict *src,QDict **dst,const char *start);void qdict_array_split (QDict *src,QList **dst);int qdict_array_entries (QDict *src,const char *subqdict); -QObject *qdict_crumple (const QDict *src,Error **errp); -void qdict_flatten (QDict *qdict); typedef struct QDictRenames { const char *from;
include/qapi/qmp/qdict.h +3 -0
@@ -64,4 +64,7 @@ const char *qdict_get_try_str(const QDict *qdict, const char *key);QDict *qdict_clone_shallow (const QDict *src); +QObject *qdict_crumple (const QDict *src,Error **errp); +void qdict_flatten (QDict *qdict); +#endif /* QDICT_H */
softmmu/vl.c +59 -24
129 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH 14/64 vl: plug -object back into -readconfig
In reply to Michael RothFrom: Paolo Bonzini <[email protected]>
Commit bc2f4fcb1d ("qom: move user_creatable_add_opts logic to vl.c and QAPIfy it", 2021-03-19) switched the creation of objects from qemu_opts_foreach to a bespoke QTAILQ in preparation for supporting JSON syntax in -object.
Unfortunately in doing so it lost support for [object] stanzas in configuration files and also for "-set object.ID.KEY=VAL". The latter is hard to re-establish and probably best solved by deprecating -set. This patch uses the infrastructure introduced by the previous two patches in order to parse QOM objects correctly from configuration files.
Message-Id: <[email protected]>
--- softmmu/vl.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-)
softmmu/vl.c +18 -6
@@ -1709,9 +1709,15 @@ static void object_option_foreach_add(bool (*type_opt_predicate)(const char *)) } } +static void object_option_add_visitor (Visitor *v) +{ +ObjectOption *opt =g_new0 (ObjectOption,1 ); +visit_type_ObjectOptions (v,NULL , &opt->opts, &error_fatal); +QTAILQ_INSERT_TAIL (&object_opts, opt, next); +} +static void object_option_parse (const char *optarg) { -ObjectOption *opt;QemuOpts *opts;const char *type;Visitor *v;
@@ -1739,11 +1745,8 @@ static void object_option_parse(const char *optarg) v =opts_visitor_new (opts); } - opt =g_new0 (ObjectOption,1 ); -visit_type_ObjectOptions (v,NULL , &opt->opts, &error_fatal); +object_option_add_visitor (v);visit_free (v); - -QTAILQ_INSERT_TAIL (&object_opts, opt, next); }/*
@@ -2120,13 +2123,22 @@ static int global_init_func(void *opaque, QemuOpts *opts, Error **errp)*/ static bool is_qemuopts_group (const char *group) { +if (g_str_equal (group,"object" )) { +return false; + }return true; }static void qemu_record_config_group (const char *group,QDict *dict,bool from_json,Error **errp) { -abort (); +if (g_str_equal (group,"object" )) { +Visitor *v =qobject_input_visitor_new_keyval (QOBJECT (dict)); +object_option_add_visitor (v); +visit_free (v); + }else { +abort (); + } }/*
Signature · 1 line
2.25.1
PATCH 15/64 sockets: update SOCKET_ADDRESS_TYPE_FD listen(2) backlog
In reply to Michael RothFrom: Stefan Hajnoczi <[email protected]>
socket_get_fd() fails with the error "socket_get_fd: too many connections" if the given listen backlog value is not 1.
Not all callers set the backlog to 1. For example, commit 582d4210eb2f2ab5baac328fe4b479cd86da1647 ("qemu-nbd: Use SOMAXCONN for socket listen() backlog") uses SOMAXCONN. This will always fail with in socket_get_fd().
This patch calls listen(2) on the fd to update the backlog value. The socket may already be in the listen state. I have tested that this works on Linux 5.10 and macOS Catalina.
As a bonus this allows us to detect when the fd cannot listen. Now we'll be able to catch unbound or connected fds in socket_listen().
Drop the num argument from socket_get_fd() since this function is also called by socket_connect() where a listen backlog value does not make sense.
Message-Id: <[email protected]>
--- util/qemu-sockets.c | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-)
util/qemu-sockets.c +22 -7
@@ -1116,14 +1116,10 @@ fail:return NULL ; } -static int socket_get_fd (const char *fdstr,int num,Error **errp) +static int socket_get_fd (const char *fdstr,Error **errp) {Monitor *cur_mon =monitor_cur ();int fd; -if (num !=1 ) { -error_setg_errno (errp,EINVAL ,"socket_get_fd: too many connections" ); -return -1 ; - }if (cur_mon) { fd =monitor_get_fd (cur_mon, fdstr, errp);if (fd <0 ) {
@@ -1159,7 +1155,7 @@ int socket_connect(SocketAddress *addr, Error **errp)break ;case SOCKET_ADDRESS_TYPE_FD : - fd =socket_get_fd (addr->u.fd.str,1 , errp); + fd =socket_get_fd (addr->u.fd.str, errp);break ;case SOCKET_ADDRESS_TYPE_VSOCK :
@@ -1187,7 +1183,26 @@ int socket_listen(SocketAddress *addr, int num, Error **errp)break ;case SOCKET_ADDRESS_TYPE_FD : - fd =socket_get_fd (addr->u.fd.str, num, errp); + fd =socket_get_fd (addr->u.fd.str, errp); +if (fd <0 ) { +return -1 ; + } + +/* +* If the socket is not yet in the listen state, then transition it to +* the listen state now. +* +* If it's already listening then this updates the backlog value as +* requested. +* +* If this socket cannot listen because it's already in another state +* (e.g. unbound or connected) then we'll catch the error here. +*/ +if (listen (fd, num) !=0 ) { +error_setg_errno (errp, errno,"Failed to listen on fd socket" ); +closesocket (fd); +return -1 ; + }break ;case SOCKET_ADDRESS_TYPE_VSOCK :
Signature · 1 line
2.25.1
PATCH 16/64 hmp: Fix loadvm to resume the VM on success instead of failure
In reply to Michael RothFrom: Kevin Wolf <[email protected]>
Commit f61fe11aa6f broke hmp_loadvm() by adding an incorrect negation when converting from 0/-errno return values to a bool value. The result is that loadvm resumes the VM now if it failed and keeps it stopped if it failed. Fix it to restore the old behaviour and do it the other way around.
Message-Id: <[email protected]>
--- monitor/hmp-cmds.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
monitor/hmp-cmds.c +1 -1
@@ -1133,7 +1133,7 @@ void hmp_loadvm(Monitor *mon, const QDict *qdict)vm_stop (RUN_STATE_RESTORE_VM ); -if (!load_snapshot (name,NULL , false,NULL , &err) && saved_vm_running) { +if (load_snapshot (name,NULL , false,NULL , &err) && saved_vm_running) {vm_start (); }hmp_handle_error (mon, err);
Signature · 1 line
2.25.1
PATCH 17/64 configure: fix detection of gdbus-codegen
In reply to Michael RothFrom: Paolo Bonzini <[email protected]>
"pkg-config --variable=gdbus_codegen gio-2.0" returns "gdbus-codegen", and it does not pass test -x (which does not walk the path).
Meson 0.58.0 notices that something is iffy, as the dbus_vmstate1 assignment in tests/qtest/meson.build uses an empty string as the command, and fails very eloquently:
../tests/qtest/meson.build:92:2: ERROR: No program name specified.
Use the "has" function instead of test -x, and fix the generation of config-host.mak since meson.build expects that GDBUS_CODEGEN is absent, rather than empty, if the tool is unavailable.
--- configure | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
configure +3 -1
@@ -3331,7 +3331,7 @@ if ! test "$gio" = "no"; then gio_cflags=$($pkg_config --cflags gio-2.0) gio_libs=$($pkg_config --libs gio-2.0) gdbus_codegen=$($pkg_config --variable=gdbus_codegen gio-2.0) - if [ ! -x "$gdbus_codegen" ]; then + if ! has "$gdbus_codegen"; then gdbus_codegen= fi # Check that the libraries actually work -- Ubuntu 18.04 ships
@@ -5678,6 +5678,8 @@ if test "$gio" = "yes" ; then echo "CONFIG_GIO=y" >> $config_host_mak echo "GIO_CFLAGS=$gio_cflags" >> $config_host_mak echo "GIO_LIBS=$gio_libs" >> $config_host_mak +fi +if test "$gdbus_codegen" != "" ; then echo "GDBUS_CODEGEN=$gdbus_codegen" >> $config_host_mak fi echo "CONFIG_TLS_PRIORITY=\"$tls_priority\"" >> $config_host_mak
Signature · 1 line
2.25.1
PATCH 18/64 vhost-vdpa: don't initialize backend_features
In reply to Michael RothFrom: Jason Wang <[email protected]>
We used to initialize backend_features during vhost_vdpa_init() regardless whether or not it was supported by vhost. This will lead the unsupported features like VIRTIO_F_IN_ORDER to be included and set to the vhost-vdpa during vhost_dev_start. Because the VIRTIO_F_IN_ORDER is not supported by vhost-vdpa so it won't be advertised to guest which will break the datapath.
Fix this by not initializing the backend_features, so the acked_features could be built only from guest features via vhost_net_ack_features().
--- hw/virtio/vhost-vdpa.c | 3 --- 1 file changed, 3 deletions(-)
hw/virtio/vhost-vdpa.c +0 -3
@@ -275,15 +275,12 @@ static void vhost_vdpa_add_status(struct vhost_dev *dev, uint8_t status)static int vhost_vdpa_init (struct vhost_dev *dev,void *opaque) {struct vhost_vdpa *v; -uint64_t features;assert (dev->vhost_ops->backend_type ==VHOST_BACKEND_TYPE_VDPA );trace_vhost_vdpa_init (dev, opaque); v = opaque; v->dev = dev; dev->opaque = opaque ; -vhost_vdpa_call (dev,VHOST_GET_FEATURES , &features); - dev->backend_features = features; v->listener = vhost_vdpa_memory_listener; v->msg_type =VHOST_IOTLB_MSG_V2 ;
Signature · 1 line
2.25.1
PATCH 19/64 esp: only assert INTR_DC interrupt flag if selection fails
In reply to Michael RothFrom: Mark Cave-Ayland <[email protected]>
The datasheet sequence tables confirm that when a target selection fails, only the INTR_DC interrupt flag should be asserted.
Message-Id: <[email protected]>
--- hw/scsi/esp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/scsi/esp.c +1 -1
@@ -213,7 +213,7 @@ static int esp_select(ESPState *s)if (!s->current_dev) {/* No such drive */ s->rregs[ESP_RSTAT ] =0 ; - s->rregs[ESP_RINTR ] |=INTR_DC ; + s->rregs[ESP_RINTR ] =INTR_DC ; s->rregs[ESP_RSEQ ] =SEQ_0 ;esp_raise_irq (s);return -1 ;
Signature · 1 line
2.25.1
PATCH 20/64 esp: only set ESP_RSEQ at the start of the select sequence
In reply to Michael RothFrom: Mark Cave-Ayland <[email protected]>
When processing a command to select a target and send a CDB, the ESP device maintains a sequence step register so that if an error occurs the host can determine which part of the selection/CDB submission sequence failed.
The old Linux 2.6 driver is really pedantic here: it checks the sequence step register even if a command succeeds and complains loudly on the console if the sequence step register doesn't match the expected bus phase and interrupt flags.
This reason this mismatch occurs is because the ESP emulation currently doesn't update the bus phase until the next TI (Transfer Information) command and so the cleared sequence step register is considered invalid for the stale bus phase.
Normally this isn't an issue as the host only checks the sequence step register if an error occurs but the old Linux 2.6 driver does this in several places causing a large stream of "esp0: STEP_ASEL for tgt 0" messages to appear on the console during the boot process.
Fix this by not clearing the sequence step register when reading the interrupt register and clearing the DMA status, so the guest sees a valid sequence step and bus phase combination at the end of the command phase. No other change is required since the sequence step register is correctly updated throughout the selection/CDB submission sequence once one of the select commands is issued.
Message-Id: <[email protected]>
--- hw/scsi/esp.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
hw/scsi/esp.c +9 -2
@@ -481,7 +481,6 @@ static void esp_dma_done(ESPState *s) { s->rregs[ESP_RSTAT ] |=STAT_TC ; s->rregs[ESP_RINTR ] |=INTR_BS ; - s->rregs[ESP_RSEQ ] =0 ; s->rregs[ESP_RFLAGS ] =0 ;esp_set_tc (s,0 );esp_raise_irq (s);
@@ -917,7 +916,15 @@ uint64_t esp_reg_read(ESPState *s, uint32_t saddr) val = s->rregs[ESP_RINTR ]; s->rregs[ESP_RINTR ] =0 ; s->rregs[ESP_RSTAT ] &= ~STAT_TC ; - s->rregs[ESP_RSEQ ] =SEQ_0 ; +/* +* According to the datasheet ESP_RSEQ should be cleared, but as the +* emulation currently defers information transfers to the next TI +* command leave it for now so that pedantic guests such as the old +* Linux 2.6 driver see the correct flags before the next SCSI phase +* transition. +* +* s->rregs[ESP_RSEQ] = SEQ_0; +*/ esp_lower_irq (s);break ;case ESP_TCHI :
Signature · 1 line
2.25.1
PATCH 21/64 runstate: Initialize Error * to NULL
In reply to Michael RothFrom: Peng Liang <[email protected]>
Based on the description of error_setg(), the local variable err in qemu_init_subsystems() should be initialized to NULL.
Message-Id: <[email protected]>
--- softmmu/runstate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
softmmu/runstate.c +1 -1
@@ -746,7 +746,7 @@ static void qemu_run_exit_notifiers(void)void qemu_init_subsystems (void ) { -Error *err; +Error *err =NULL ;os_set_line_buffering ();
Signature · 1 line
2.25.1
PATCH 22/64 vfio: Fix unregister SaveVMHandler in vfio_migration_finalize
In reply to Michael RothFrom: Kunkun Jiang <[email protected]>
In the vfio_migration_init(), the SaveVMHandler is registered for VFIO device. But it lacks the operation of 'unregister'. It will lead to 'Segmentation fault (core dumped)' in qemu_savevm_state_setup(), if performing live migration after a VFIO device is hot deleted.
Message-Id: <[email protected]> Reviewed by: Kirti Wankhede <[email protected]>
--- hw/vfio/migration.c | 1 + 1 file changed, 1 insertion(+)
hw/vfio/migration.c +1 -0
@@ -893,6 +893,7 @@ void vfio_migration_finalize(VFIODevice *vbasedev)remove_migration_state_change_notifier (&migration->migration_state);qemu_del_vm_change_state_handler (migration->vm_state); +unregister_savevm (VMSTATE_IF (vbasedev->dev),"vfio" , vbasedev);vfio_migration_exit (vbasedev); }
Signature · 1 line
2.25.1
PATCH 23/64 vl: Fix an assert failure in error path
In reply to Michael RothFrom: Zhenzhong Duan <[email protected]>
Based on the description of error_setg(), the local variable err in qemu_maybe_daemonize() should be initialized to NULL.
Without fix, the uninitialized *errp triggers assert failure which doesn't show much valuable information.
Before the fix:
qemu-system-x86_64: ../util/error.c:59: error_setv: Assertion `*errp == NULL' failed.
After fix:
qemu-system-x86_64: cannot create PID file: Cannot open pid file: Permission denied
Message-Id: <[email protected]>
--- softmmu/vl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
softmmu/vl.c +1 -1
@@ -2508,7 +2508,7 @@ static void qemu_process_help_options(void)static void qemu_maybe_daemonize (const char *pid_file) { -Error *err; +Error *err =NULL ;os_daemonize ();rcu_disable_atfork ();
Signature · 1 line
2.25.1
PATCH 24/64 tcg/sparc: Fix temp_allocate_frame vs sparc stack bias
In reply to Michael RothFrom: Richard Henderson <[email protected]>
We should not be aligning the offset in temp_allocate_frame, because the odd offset produces an aligned address in the end. Instead, pass the logical offset into tcg_set_frame and add the stack bias last.
--- tcg/sparc/tcg-target.c.inc | 16 ++++++++++------ tcg/tcg.c | 9 +++------ 2 files changed, 13 insertions(+), 12 deletions(-)
tcg/sparc/tcg-target.c.inc +10 -6
@@ -987,14 +987,18 @@ static void tcg_target_qemu_prologue(TCGContext *s) { int tmp_buf_size, frame_size; - /* The TCG temp buffer is at the top of the frame, immediately - below the frame pointer. */ + /* + * The TCG temp buffer is at the top of the frame, immediately + * below the frame pointer. Use the logical (aligned) offset here; + * the stack bias is applied in temp_allocate_frame(). + */ tmp_buf_size = CPU_TEMP_BUF_NLONGS * (int)sizeof(long); - tcg_set_frame(s, TCG_REG_I6, TCG_TARGET_STACK_BIAS - tmp_buf_size, - tmp_buf_size); + tcg_set_frame(s, TCG_REG_I6, -tmp_buf_size, tmp_buf_size); - /* TCG_TARGET_CALL_STACK_OFFSET includes the stack bias, but is - otherwise the minimal frame usable by callees. */ + /* + * TCG_TARGET_CALL_STACK_OFFSET includes the stack bias, but is + * otherwise the minimal frame usable by callees. + */ frame_size = TCG_TARGET_CALL_STACK_OFFSET - TCG_TARGET_STACK_BIAS; frame_size += TCG_STATIC_CALL_ARGS_SIZE + tmp_buf_size; frame_size += TCG_TARGET_STACK_ALIGN - 1;
tcg/tcg.c +3 -6
@@ -3489,17 +3489,14 @@ static void check_regs(TCGContext *s)static void temp_allocate_frame (TCGContext *s,TCGTemp *ts) { -#if !(defined(__sparc__) &&TCG_TARGET_REG_BITS ==64 ) -/* Sparc64 stack is accessed with offset of 2047 */ - s->current_frame_offset = (s->current_frame_offset + - (tcg_target_long )sizeof (tcg_target_long) -1 ) & - ~(sizeof (tcg_target_long) -1 ); -#endif if (s->current_frame_offset + (tcg_target_long )sizeof (tcg_target_long) > s->frame_end) {tcg_abort (); } ts->mem_offset = s->current_frame_offset; +#if defined(__sparc__) + ts->mem_offset +=TCG_TARGET_STACK_BIAS ; +#endif ts->mem_base = s->frame_temp; ts->mem_allocated =1 ; s->current_frame_offset +=sizeof (tcg_target_long);
Signature · 1 line
2.25.1
PATCH 25/64 tcg: Allocate sufficient storage in temp_allocate_frame
In reply to Michael RothFrom: Richard Henderson <[email protected]>
This function should have been updated for vector types when they were introduced.
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/367
--- tcg/tcg.c | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-)
tcg/tcg.c +26 -5
@@ -3489,17 +3489,38 @@ static void check_regs(TCGContext *s)static void temp_allocate_frame (TCGContext *s,TCGTemp *ts) { -if (s->current_frame_offset + (tcg_target_long )sizeof (tcg_target_long) > - s->frame_end) { -tcg_abort (); +intptr_t off, size, align; + +switch (ts->type) { +case TCG_TYPE_I32 : + size = align =4 ; +break ; +case TCG_TYPE_I64 : +case TCG_TYPE_V64 : + size = align =8 ; +break ; +case TCG_TYPE_V128 : + size = align =16 ; +break ; +case TCG_TYPE_V256 : +/* Note that we do not require aligned storage for V256. */ + size =32 , align =16 ; +break ; +default : +g_assert_not_reached (); } - ts->mem_offset = s->current_frame_offset; + +assert (align <=TCG_TARGET_STACK_ALIGN ); + off =ROUND_UP (s->current_frame_offset, align); +assert (off + size <= s->frame_end); + s->current_frame_offset = off + size; + + ts->mem_offset = off;#if defined(__sparc__) ts->mem_offset +=TCG_TARGET_STACK_BIAS ;#endif ts->mem_base = s->frame_temp; ts->mem_allocated =1 ; - s->current_frame_offset +=sizeof (tcg_target_long); }static void temp_load (TCGContext *,TCGTemp *,TCGRegSet ,TCGRegSet ,TCGRegSet );
Signature · 1 line
2.25.1
PATCH 26/64 hw/pci-host/q35: Ignore write of reserved PCIEXBAR LENGTH field
In reply to Michael RothFrom: Philippe Mathieu-Daudé <[email protected]>
libFuzzer triggered the following assertion:
cat << EOF | qemu-system-i386 -M pc-q35-5.0 \
-nographic -monitor none -serial none \
-qtest stdio -d guest_errors -trace pci\*
outl 0xcf8 0xf2000060
outl 0xcfc 0x8400056e
EOF
pci_cfg_write mch 00:0 @0x60 <- 0x8400056e
Aborted (core dumped)This is because guest wrote MCH_HOST_BRIDGE_PCIEXBAR_LENGTH_RVD (reserved value) to the PCIE XBAR register.
There is no indication on the datasheet about what occurs when this value is written. Simply ignore it on QEMU (and report an guest error):
pci_cfg_write mch 00:0 @0x60 <- 0x8400056e
Q35: Reserved PCIEXBAR LENGTH
pci_cfg_read mch 00:0 @0x0 -> 0x8086
pci_cfg_read mch 00:0 @0x0 -> 0x29c08086
...
Message-Id: <[email protected]>
--- hw/pci-host/q35.c | 3 +++ 1 file changed, 3 insertions(+)
hw/pci-host/q35.c +3 -0
@@ -29,6 +29,7 @@*/ #include "qemu/osdep.h" +#include "qemu/log.h" #include "hw/i386/pc.h" #include "hw/pci-host/q35.h" #include "hw/qdev-properties.h"
@@ -318,6 +319,8 @@ static void mch_update_pciexbar(MCHPCIState *mch) addr_mask |=MCH_HOST_BRIDGE_PCIEXBAR_64ADMSK ;break ;case MCH_HOST_BRIDGE_PCIEXBAR_LENGTH_RVD : +qemu_log_mask (LOG_GUEST_ERROR ,"Q35: Reserved PCIEXBAR LENGTH\n" ); +return ;default :abort (); }
Signature · 1 line
2.25.1
PATCH 27/64 block/nvme: Fix VFIO_MAP_DMA failed: No space left on device
In reply to Michael RothFrom: Philippe Mathieu-Daudé <[email protected]>
When the NVMe block driver was introduced (see commit bdd6a90a9e5, January 2018), Linux VFIO_IOMMU_MAP_DMA ioctl was only returning -ENOMEM in case of error. The driver was correctly handling the error path to recycle its volatile IOVA mappings.
To fix CVE-2019-3882, Linux commit 492855939bdb ("vfio/type1: Limit DMA mappings per container", April 2019) added the -ENOSPC error to signal the user exhausted the DMA mappings available for a container.
The block driver started to mis-behave:
qemu-system-x86_64: VFIO_MAP_DMA failed: No space left on device (qemu)
(qemu) info status
VM status: paused (io-error)
(qemu) c
VFIO_MAP_DMA failed: No space left on device
(qemu) c
VFIO_MAP_DMA failed: No space left on device
(The VM is not resumable from here, hence stuck.)
Fix by handling the new -ENOSPC error (when DMA mappings are exhausted) without any distinction to the current -ENOMEM error, so we don't change the behavior on old kernels where the CVE-2019-3882 fix is not present.
An easy way to reproduce this bug is to restrict the DMA mapping limit (65535 by default) when loading the VFIO IOMMU module:
# modprobe vfio_iommu_type1 dma_entry_limit=666
Message-id: [email protected]
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/65
--- block/nvme.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
block/nvme.c +22 -0
@@ -1030,7 +1030,29 @@ try_map: r =qemu_vfio_dma_map (s->vfio, qiov->iov[i].iov_base, len, true, &iova); +if (r == -ENOSPC ) { +/* +* In addition to the -ENOMEM error, the VFIO_IOMMU_MAP_DMA +* ioctl returns -ENOSPC to signal the user exhausted the DMA +* mappings available for a container since Linux kernel commit +* 492855939bdb ("vfio/type1: Limit DMA mappings per container", +* April 2019, see CVE-2019-3882). +* +* This block driver already handles this error path by checking +* for the -ENOMEM error, so we directly replace -ENOSPC by +* -ENOMEM. Beside, -ENOSPC has a specific meaning for blockdev +* coroutines: it triggers BLOCKDEV_ON_ERROR_ENOSPC and +* BLOCK_ERROR_ACTION_STOP which stops the VM, asking the operator +* to add more storage to the blockdev. Not something we can do +* easily with an IOMMU :) +*/ + r = -ENOMEM ; + }if (r == -ENOMEM && retry) { +/* +* We exhausted the DMA mappings available for our container: +* recycle the volatile IOVA mappings. +*/ retry = false;trace_nvme_dma_flush_queue_wait (s);if (s->dma_map_count) {
Signature · 1 line
2.25.1
PATCH 28/64 crypto/tlscreds: Introduce qcrypto_tls_creds_check_endpoint() helper
In reply to Michael RothFrom: Philippe Mathieu-Daudé <[email protected]>
Introduce the qcrypto_tls_creds_check_endpoint() helper to access QCryptoTLSCreds internal 'endpoint' field.
--- crypto/tlscreds.c | 12 ++++++++++++ include/crypto/tlscreds.h | 14 ++++++++++++++ 2 files changed, 26 insertions(+)
crypto/tlscreds.c +12 -0
@@ -20,6 +20,7 @@#include "qemu/osdep.h" #include "qapi/error.h" +#include "qapi-types-crypto.h" #include "qemu/module.h" #include "tlscredspriv.h" #include "trace.h"
@@ -259,6 +260,17 @@ qcrypto_tls_creds_finalize(Object *obj)g_free (creds->priority); } +bool qcrypto_tls_creds_check_endpoint (QCryptoTLSCreds *creds, +QCryptoTLSCredsEndpoint endpoint, +Error **errp) +{ +if (creds->endpoint != endpoint) { +error_setg (errp,"Expected TLS credentials for a %s endpoint" , +QCryptoTLSCredsEndpoint_str (endpoint)); +return false; + } +return true; +}static const TypeInfo qcrypto_tls_creds_info = { .parent =TYPE_OBJECT ,
include/crypto/tlscreds.h +14 -0
@@ -65,5 +65,19 @@ struct QCryptoTLSCredsClass { CryptoTLSCredsReload reload; }; +/** +* qcrypto_tls_creds_check_endpoint: +* @creds: pointer to a TLS credentials object +* @endpoint: type of network endpoint that will be using the credentials +* @errp: pointer to a NULL-initialized error object +* +* Check whether the credentials is setup according to +* the type of @endpoint argument. +* +* Returns true if the credentials is setup for the endpoint, false otherwise +*/ +bool qcrypto_tls_creds_check_endpoint (QCryptoTLSCreds *creds, +QCryptoTLSCredsEndpoint endpoint, +Error **errp);#endif /* QCRYPTO_TLSCREDS_H */
Signature · 1 line
2.25.1
PATCH 29/64 block/nbd: Use qcrypto_tls_creds_check_endpoint()
In reply to Michael RothFrom: Philippe Mathieu-Daudé <[email protected]>
Avoid accessing QCryptoTLSCreds internals by using the qcrypto_tls_creds_check_endpoint() helper.
--- block/nbd.c | 6 +++--- blockdev-nbd.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-)
block/nbd.c +3 -3
@@ -2163,9 +2163,9 @@ static QCryptoTLSCreds *nbd_get_tls_creds(const char *id, Error **errp)return NULL ; } -if (creds->endpoint !=QCRYPTO_TLS_CREDS_ENDPOINT_CLIENT ) { -error_setg (errp, -"Expecting TLS credentials with a client endpoint" ); +if (!qcrypto_tls_creds_check_endpoint (creds, +QCRYPTO_TLS_CREDS_ENDPOINT_CLIENT , + errp)) {return NULL ; }object_ref (obj);
blockdev-nbd.c +3 -3
@@ -108,9 +108,9 @@ static QCryptoTLSCreds *nbd_get_tls_creds(const char *id, Error **errp)return NULL ; } -if (creds->endpoint !=QCRYPTO_TLS_CREDS_ENDPOINT_SERVER ) { -error_setg (errp, -"Expecting TLS credentials with a server endpoint" ); +if (!qcrypto_tls_creds_check_endpoint (creds, +QCRYPTO_TLS_CREDS_ENDPOINT_SERVER , + errp)) {return NULL ; }object_ref (obj);
Signature · 1 line
2.25.1
PATCH 30/64 qemu-nbd: Use qcrypto_tls_creds_check_endpoint()
In reply to Michael RothFrom: Philippe Mathieu-Daudé <[email protected]>
Avoid accessing QCryptoTLSCreds internals by using the qcrypto_tls_creds_check_endpoint() helper.
--- qemu-nbd.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-)
qemu-nbd.c +7 -12
@@ -43,6 +43,7 @@#include "io/channel-socket.h" #include "io/net-listener.h" #include "crypto/init.h" +#include "crypto/tlscreds.h" #include "trace/control.h" #include "qemu-version.h"
@@ -422,18 +423,12 @@ static QCryptoTLSCreds *nbd_get_tls_creds(const char *id, bool list,return NULL ; } -if (list) { -if (creds->endpoint !=QCRYPTO_TLS_CREDS_ENDPOINT_CLIENT ) { -error_setg (errp, -"Expecting TLS credentials with a client endpoint" ); -return NULL ; - } - }else { -if (creds->endpoint !=QCRYPTO_TLS_CREDS_ENDPOINT_SERVER ) { -error_setg (errp, -"Expecting TLS credentials with a server endpoint" ); -return NULL ; - } +if (!qcrypto_tls_creds_check_endpoint (creds, + list + ?QCRYPTO_TLS_CREDS_ENDPOINT_CLIENT + :QCRYPTO_TLS_CREDS_ENDPOINT_SERVER , + errp)) { +return NULL ; }object_ref (obj);return creds;
Signature · 1 line
2.25.1
PATCH 31/64 chardev/socket: Use qcrypto_tls_creds_check_endpoint()
In reply to Michael RothFrom: Philippe Mathieu-Daudé <[email protected]>
Avoid accessing QCryptoTLSCreds internals by using the qcrypto_tls_creds_check_endpoint() helper.
--- chardev/char-socket.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-)
chardev/char-socket.c +6 -12
@@ -1402,18 +1402,12 @@ static void qmp_chardev_open_socket(Chardev *chr,return ; }object_ref (OBJECT (s->tls_creds)); -if (is_listen) { -if (s->tls_creds->endpoint !=QCRYPTO_TLS_CREDS_ENDPOINT_SERVER ) { -error_setg (errp,"%s" , -"Expected TLS credentials for server endpoint" ); -return ; - } - }else { -if (s->tls_creds->endpoint !=QCRYPTO_TLS_CREDS_ENDPOINT_CLIENT ) { -error_setg (errp,"%s" , -"Expected TLS credentials for client endpoint" ); -return ; - } +if (!qcrypto_tls_creds_check_endpoint (s->tls_creds, + is_listen + ?QCRYPTO_TLS_CREDS_ENDPOINT_SERVER + :QCRYPTO_TLS_CREDS_ENDPOINT_CLIENT , + errp)) { +return ; } } s->tls_authz =g_strdup (sock->tls_authz);
Signature · 1 line
2.25.1
PATCH 32/64 migration/tls: Use qcrypto_tls_creds_check_endpoint()
In reply to Michael RothFrom: Philippe Mathieu-Daudé <[email protected]>
Avoid accessing QCryptoTLSCreds internals by using the qcrypto_tls_creds_check_endpoint() helper.
--- migration/tls.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
migration/tls.c +1 -5
@@ -49,11 +49,7 @@ migration_tls_get_creds(MigrationState *s, s->parameters.tls_creds);return NULL ; } -if (ret->endpoint != endpoint) { -error_setg (errp, -"Expected TLS credentials for a %s endpoint" , - endpoint ==QCRYPTO_TLS_CREDS_ENDPOINT_CLIENT ? -"client" :"server" ); +if (!qcrypto_tls_creds_check_endpoint (ret, endpoint, errp)) {return NULL ; }
Signature · 1 line
2.25.1
PATCH 33/64 ui/vnc: Use qcrypto_tls_creds_check_endpoint()
In reply to Michael RothFrom: Philippe Mathieu-Daudé <[email protected]>
Avoid accessing QCryptoTLSCreds internals by using the qcrypto_tls_creds_check_endpoint() helper.
--- ui/vnc.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
ui/vnc.c +4 -3
@@ -45,6 +45,7 @@#include "qapi/qapi-commands-ui.h" #include "ui/input.h" #include "crypto/hash.h" +#include "crypto/tlscreds.h" #include "crypto/tlscredsanon.h" #include "crypto/tlscredsx509.h" #include "crypto/random.h"
@@ -4071,9 +4072,9 @@ void vnc_display_open(const char *id, Error **errp) }object_ref (OBJECT (vd->tlscreds)); -if (vd->tlscreds->endpoint !=QCRYPTO_TLS_CREDS_ENDPOINT_SERVER ) { -error_setg (errp, -"Expecting TLS credentials with a server endpoint" ); +if (!qcrypto_tls_creds_check_endpoint (vd->tlscreds, +QCRYPTO_TLS_CREDS_ENDPOINT_SERVER , + errp)) { goto fail; } }
Signature · 1 line
2.25.1
PATCH 34/64 crypto: Make QCryptoTLSCreds* structures private
In reply to Michael RothFrom: Philippe Mathieu-Daudé <[email protected]>
Code consuming the "crypto/tlscreds*.h" APIs doesn't need to access its internals. Move the structure definitions to the "tlscredspriv.h" private header (only accessible by implementations). The public headers (in include/) still forward-declare the structures typedef.
Note, tlscreds.c and 3 of the 5 modified source files already include "tlscredspriv.h", so only add it to tls-cipher-suites.c and tlssession.c.
Removing the internals from the public header solves a bug introduced by commit 7de2e856533 ("yank: Unregister function when using TLS migration") which made migration/qemu-file-channel.c include "io/channel-tls.h", itself sometime depends on GNUTLS, leading to a build failure on OSX:
[2/35] Compiling C object libmigration.fa.p/migration_qemu-file-channel.c.o
FAILED: libmigration.fa.p/migration_qemu-file-channel.c.o
cc -Ilibmigration.fa.p -I. -I.. -Iqapi [ ... ] -o libmigration.fa.p/migration_qemu-file-channel.c.o -c ../migration/qemu-file-channel.c In file included from ../migration/qemu-file-channel.c:29:
In file included from include/io/channel-tls.h:26:
In file included from include/crypto/tlssession.h:24:
include/crypto/tlscreds.h:28:10: fatal error: 'gnutls/gnutls.h' file not found
#include <gnutls/gnutls.h>
^~~~~~~~~~~~~~~~~1 error generated.
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/407
--- crypto/tls-cipher-suites.c | 7 +++++ crypto/tlscredsanon.c | 2 ++ crypto/tlscredspriv.h | 45 ++++++++++++++++++++++++++++++ crypto/tlscredspsk.c | 2 ++ crypto/tlscredsx509.c | 1 + crypto/tlssession.c | 1 + include/crypto/tls-cipher-suites.h | 6 ---- include/crypto/tlscreds.h | 16 ----------- include/crypto/tlscredsanon.h | 12 -------- include/crypto/tlscredspsk.h | 12 -------- include/crypto/tlscredsx509.h | 10 ------- 11 files changed, 58 insertions(+), 56 deletions(-)
crypto/tls-cipher-suites.c +7 -0
@@ -14,8 +14,15 @@#include "crypto/tlscreds.h" #include "crypto/tls-cipher-suites.h" #include "hw/nvram/fw_cfg.h" +#include "tlscredspriv.h" #include "trace.h" +struct QCryptoTLSCipherSuites { +/* <private> */ +QCryptoTLSCreds parent_obj; +/* <public> */ +}; +/* * IANA registered TLS ciphers: * https://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml#tls-parameters-4
crypto/tlscredsanon.c +2 -0
@@ -29,6 +29,8 @@#ifdef CONFIG_GNUTLS +#include <gnutls/gnutls.h> + static int qcrypto_tls_creds_anon_load(QCryptoTLSCredsAnon *creds,
crypto/tlscredspriv.h +45 -0
51 lines not on this page · raw message
crypto/tlscredspsk.c +2 -0
@@ -29,6 +29,8 @@#ifdef CONFIG_GNUTLS +#include <gnutls/gnutls.h> +static int lookup_key (const char *pskfile,const char *username,gnutls_datum_t *key,Error **errp)
crypto/tlscredsx509.c +1 -0
@@ -30,6 +30,7 @@#ifdef CONFIG_GNUTLS +#include <gnutls/gnutls.h> #include <gnutls/x509.h>
crypto/tlssession.c +1 -0
@@ -25,6 +25,7 @@#include "crypto/tlscredsx509.h" #include "qapi/error.h" #include "authz/base.h" +#include "tlscredspriv.h" #include "trace.h" #ifdef CONFIG_GNUTLS
include/crypto/tls-cipher-suites.h +0 -6
@@ -19,12 +19,6 @@ typedef struct QCryptoTLSCipherSuites QCryptoTLSCipherSuites;DECLARE_INSTANCE_CHECKER (QCryptoTLSCipherSuites,QCRYPTO_TLS_CIPHER_SUITES ,TYPE_QCRYPTO_TLS_CIPHER_SUITES ) -struct QCryptoTLSCipherSuites { -/* <private> */ -QCryptoTLSCreds parent_obj; -/* <public> */ -}; -/** * qcrypto_tls_cipher_suites_get_data: * @obj: pointer to a TLS cipher suites object
include/crypto/tlscreds.h +0 -16
@@ -24,10 +24,6 @@#include "qapi/qapi-types-crypto.h" #include "qom/object.h" -#ifdef CONFIG_GNUTLS -#include <gnutls/gnutls.h> -#endif -#define TYPE_QCRYPTO_TLS_CREDS "tls-creds"typedef struct QCryptoTLSCreds QCryptoTLSCreds ;typedef struct QCryptoTLSCredsClass QCryptoTLSCredsClass ;
@@ -48,18 +44,6 @@ typedef bool (*CryptoTLSCredsReload)(QCryptoTLSCreds *, Error **);* certificate credentials. */ -struct QCryptoTLSCreds { -Object parent_obj; -char *dir; -QCryptoTLSCredsEndpoint endpoint; -#ifdef CONFIG_GNUTLS -gnutls_dh_params_t dh_params; -#endif -bool verifyPeer; -char *priority; -}; - -struct QCryptoTLSCredsClass {ObjectClass parent_class;CryptoTLSCredsReload reload;
include/crypto/tlscredsanon.h +0 -12
@@ -92,18 +92,6 @@ typedef struct QCryptoTLSCredsAnonClass QCryptoTLSCredsAnonClass;* */ - -struct QCryptoTLSCredsAnon { -QCryptoTLSCreds parent_obj; -#ifdef CONFIG_GNUTLS -union { -gnutls_anon_server_credentials_t server; -gnutls_anon_client_credentials_t client; - } data; -#endif -}; - -struct QCryptoTLSCredsAnonClass {QCryptoTLSCredsClass parent_class; };
include/crypto/tlscredspsk.h +0 -12
@@ -87,18 +87,6 @@ typedef struct QCryptoTLSCredsPSKClass QCryptoTLSCredsPSKClass;* The PSK file can be created and managed using psktool. */ -struct QCryptoTLSCredsPSK { -QCryptoTLSCreds parent_obj; -char *username; -#ifdef CONFIG_GNUTLS -union { -gnutls_psk_server_credentials_t server; -gnutls_psk_client_credentials_t client; - } data; -#endif -}; - -struct QCryptoTLSCredsPSKClass {QCryptoTLSCredsClass parent_class; };
include/crypto/tlscredsx509.h +0 -10
@@ -96,16 +96,6 @@ typedef struct QCryptoTLSCredsX509Class QCryptoTLSCredsX509Class;* */ -struct QCryptoTLSCredsX509 { -QCryptoTLSCreds parent_obj; -#ifdef CONFIG_GNUTLS -gnutls_certificate_credentials_t data; -#endif -bool sanityCheck; -char *passwordid; -}; - -struct QCryptoTLSCredsX509Class {QCryptoTLSCredsClass parent_class; };
Signature · 1 line
2.25.1
PATCH 35/64 yank: Unregister function when using TLS migration
In reply to Michael RothFrom: Leonardo Bras <[email protected]>
After yank feature was introduced in migration, whenever migration is started using TLS, the following error happens in both source and destination hosts:
(qemu) qemu-kvm: ../util/yank.c:107: yank_unregister_instance:
Assertion `QLIST_EMPTY(&entry->yankfns)' failed.
This happens because of a missing yank_unregister_function() when using qio-channel-tls.
Fix this by also allowing TYPE_QIO_CHANNEL_TLS object type to perform yank_unregister_function() in channel_close() and multifd_load_cleanup().
Also, inside migration_channel_connect() and migration_channel_process_incoming() move yank_register_function() so it only runs once on a TLS migration.
--
Changes since v2:
- Dropped all references to ioc->master
- yank_register_function() and yank_unregister_function() now only run once in a TLS migration.
Changes since v1:
- Cast p->c to QIOChannelTLS into multifd_load_cleanup()
Message-Id: <[email protected]>
--- migration/channel.c | 26 ++++++++++++++------------ migration/multifd.c | 3 ++- migration/qemu-file-channel.c | 4 +++- 3 files changed, 19 insertions(+), 14 deletions(-)
migration/channel.c +14 -12
@@ -38,18 +38,19 @@ void migration_channel_process_incoming(QIOChannel *ioc)trace_migration_set_incoming_channel ( ioc,object_get_typename (OBJECT (ioc))); -if (object_dynamic_cast (OBJECT (ioc),TYPE_QIO_CHANNEL_SOCKET )) { -yank_register_function (MIGRATION_YANK_INSTANCE , - migration_yank_iochannel, -QIO_CHANNEL (ioc)); - } -if (s->parameters.tls_creds && *s->parameters.tls_creds && !object_dynamic_cast (OBJECT (ioc),TYPE_QIO_CHANNEL_TLS )) {migration_tls_channel_process_incoming (s, ioc, &local_err); }else { +if (object_dynamic_cast (OBJECT (ioc),TYPE_QIO_CHANNEL_SOCKET ) || +object_dynamic_cast (OBJECT (ioc),TYPE_QIO_CHANNEL_TLS )) { +yank_register_function (MIGRATION_YANK_INSTANCE , + migration_yank_iochannel, +QIO_CHANNEL (ioc)); + } +migration_ioc_process_incoming (ioc, &local_err); }
@@ -76,12 +77,6 @@ void migration_channel_connect(MigrationState *s, ioc, object_get_typename(OBJECT(ioc)), hostname, error); if (!error) { - if (object_dynamic_cast(OBJECT(ioc), TYPE_QIO_CHANNEL_SOCKET)) { - yank_register_function(MIGRATION_YANK_INSTANCE, - migration_yank_iochannel, - QIO_CHANNEL(ioc)); - } - if (s->parameters.tls_creds && *s->parameters.tls_creds && !object_dynamic_cast(OBJECT(ioc),
@@ -99,6 +94,13 @@ void migration_channel_connect(MigrationState *s, }else {QEMUFile *f =qemu_fopen_channel_output (ioc); +if (object_dynamic_cast (OBJECT (ioc),TYPE_QIO_CHANNEL_SOCKET ) || +object_dynamic_cast (OBJECT (ioc),TYPE_QIO_CHANNEL_TLS )) { +yank_register_function (MIGRATION_YANK_INSTANCE , + migration_yank_iochannel, +QIO_CHANNEL (ioc)); + } +qemu_mutex_lock (&s->qemu_file_lock); s->to_dst_file = f;qemu_mutex_unlock (&s->qemu_file_lock);
migration/multifd.c +2 -1
@@ -987,7 +987,8 @@ int multifd_load_cleanup(Error **errp)for (i =0 ; i <migrate_multifd_channels (); i++) {MultiFDRecvParams *p = &multifd_recv_state->params[i]; -if (object_dynamic_cast (OBJECT (p->c),TYPE_QIO_CHANNEL_SOCKET ) +if ((object_dynamic_cast (OBJECT (p->c),TYPE_QIO_CHANNEL_SOCKET ) || +object_dynamic_cast (OBJECT (p->c),TYPE_QIO_CHANNEL_TLS )) &&OBJECT (p->c)->ref ==1 ) { yank_unregister_function(MIGRATION_YANK_INSTANCE, migration_yank_iochannel,
migration/qemu-file-channel.c +3 -1
@@ -26,6 +26,7 @@#include "qemu-file-channel.h" #include "qemu-file.h" #include "io/channel-socket.h" +#include "io/channel-tls.h" #include "qemu/iov.h" #include "qemu/yank.h" #include "yank_functions.h"
@@ -106,7 +107,8 @@ static int channel_close(void *opaque, Error **errp)int ret;QIOChannel *ioc =QIO_CHANNEL (opaque); ret =qio_channel_close (ioc, errp); -if (object_dynamic_cast (OBJECT (ioc),TYPE_QIO_CHANNEL_SOCKET ) +if ((object_dynamic_cast (OBJECT (ioc),TYPE_QIO_CHANNEL_SOCKET ) || +object_dynamic_cast (OBJECT (ioc),TYPE_QIO_CHANNEL_TLS )) &&OBJECT (ioc)->ref ==1 ) { yank_unregister_function(MIGRATION_YANK_INSTANCE, migration_yank_iochannel,
Signature · 1 line
2.25.1
PATCH 36/64 tests: acpi: prepare for changing DSDT tables
In reply to Michael RothFrom: Igor Mammedov <[email protected]>
Message-Id: <[email protected]>
--- tests/qtest/bios-tables-test-allowed-diff.h | 10 ++++++++++ 1 file changed, 10 insertions(+)
tests/qtest/bios-tables-test-allowed-diff.h +10 -0
@@ -1 +1,11 @@/* List of comma-separated changed AML files to ignore */ +"tests/data/acpi/pc/DSDT" , +"tests/data/acpi/pc/DSDT.bridge" , +"tests/data/acpi/pc/DSDT.ipmikcs" , +"tests/data/acpi/pc/DSDT.cphp" , +"tests/data/acpi/pc/DSDT.memhp" , +"tests/data/acpi/pc/DSDT.numamem" , +"tests/data/acpi/pc/DSDT.nohpet" , +"tests/data/acpi/pc/DSDT.dimmpxm" , +"tests/data/acpi/pc/DSDT.acpihmat" , +"tests/data/acpi/pc/DSDT.hpbridge",
Signature · 1 line
2.25.1
PATCH 37/64 acpi: pc: revert back to v5.2 PCI slot enumeration
In reply to Michael RothFrom: Igor Mammedov <[email protected]>
Commit [1] moved _SUN variable from only hot-pluggable to all devices. This made linux kernel enumerate extra slots that weren't present before. If extra slot happens to be be enumerated first and there is a device in th same slot but on other bridge, linux kernel will add -N suffix to slot name of the later, thus changing NIC name compared to QEMU 5.2. This in some case confuses systemd, if it is using SLOT NIC naming scheme and interface name becomes not the same as it was under QEMU-5.2.
Reproducer QEMU CLI:
-M pc-i440fx-5.2 -nodefaults \
-device pci-bridge,chassis_nr=1,id=pci.1,bus=pci.0,addr=0x3 \
-device virtio-net-pci,id=nic1,bus=pci.1,addr=0x1 \
-device virtio-net-pci,id=nic2,bus=pci.1,addr=0x2 \
-device virtio-net-pci,id=nic3,bus=pci.1,addr=0x3
with RHEL8 guest produces following results:
v5.2:
kernel: virtio_net virtio0 ens1: renamed from eth0
kernel: virtio_net virtio2 ens3: renamed from eth2
kernel: virtio_net virtio1 enp1s2: renamed from eth1
(slot 2 is assigned to empty bus 0 slot and virtio1
is assigned to 2-2 slot, and renaming falls back, for some reason, to path based naming scheme)
v6.0:
kernel: virtio_net virtio0 ens1: renamed from eth0
kernel: virtio_net virtio2 ens3: renamed from eth2
systemd-udevd[299]: Error changing net interface name 'eth1' to 'ens3': File exists systemd-udevd[299]: could not rename interface '3' from 'eth1' to 'ens3': File exists
(with commit [1] kernel assigns virtio2 to 3-2 slot
since bridge advertises _SUN=0x3 and kernel assigns
slot 3 to bridge. Still it manages to rename virtio2
correctly to ens3, however systemd gets confused with virtio1
where slot allocation exactly the same (2-2) as in 5.2 case
and tries to rename it to ens3 which is rightfully taken by
virtio2)
I'm not sure what breaks in systemd interface renaming (it probably should be investigated), but on QEMU side we can safely revert _SUN to 5.2 behavior (i.e. avoid cold-plugged bridges and non hot-pluggable device classes), without breaking acpi-index, which uses slot numbers but it doesn't have to use _SUN, it could use an arbitrary variable name that has the same slot value).
It will help existing VMs to keep networking with non trivial configs in working order since systemd will do its interface renaming magic as it used to do.
1)
Message-Id: <[email protected]>
--- hw/i386/acpi-build.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
hw/i386/acpi-build.c +7 -2
@@ -432,11 +432,15 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,aml_append (dev,aml_name_decl ("_ADR" ,aml_int (slot <<16 )));if (bsel) { -aml_append (dev,aml_name_decl ("_SUN" ,aml_int (slot))); +/* +* Can't declare _SUN here for every device as it changes 'slot' +* enumeration order in linux kernel, so use another variable for it +*/ +aml_append (dev,aml_name_decl ("ASUN" ,aml_int (slot))); method =aml_method ("_DSM" ,4 ,AML_SERIALIZED );aml_append (method,aml_return (aml_call6 ("PDSM" ,aml_arg (0 ),aml_arg (1 ),aml_arg (2 ), -aml_arg (3 ),aml_name ("BSEL" ),aml_name ("_SUN" )) +aml_arg (3 ),aml_name ("BSEL" ),aml_name ("ASUN" )) ));aml_append (dev, method); }
@@ -463,6 +467,7 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,aml_append (method,aml_return (aml_int (s3d)));aml_append (dev, method); }else if (hotplug_enabled_dev) { +aml_append (dev,aml_name_decl ("_SUN" ,aml_int (slot)));/* add _EJ0 to make slot hotpluggable */ method =aml_method ("_EJ0" ,1 ,AML_NOTSERIALIZED ); aml_append(method,
Signature · 1 line
2.25.1
PATCH 38/64 tests: acpi: pc: update expected DSDT blobs
In reply to Michael RothFrom: Igor Mammedov <[email protected]>
@@ -930,20 +930,20 @@ DefinitionBlock ("", "DSDT", 1, "BOCHS ", "BXPC ", 0x00000001)
Device (S00)
{
Name (_ADR, Zero) // _ADR: Address- Name (_SUN, Zero) // _SUN: Slot User Number
+ Name (ASUN, Zero)
Method (_DSM, 4, Serialized) // _DSM: Device-Specific Method {
- Return (PDSM (Arg0, Arg1, Arg2, Arg3, BSEL, _SUN))
+ Return (PDSM (Arg0, Arg1, Arg2, Arg3, BSEL, ASUN))
}
}
Device (S10)
{
Name (_ADR, 0x00020000) // _ADR: Address- Name (_SUN, 0x02) // _SUN: Slot User Number
+ Name (ASUN, 0x02)
Method (_DSM, 4, Serialized) // _DSM: Device-Specific Method {
- Return (PDSM (Arg0, Arg1, Arg2, Arg3, BSEL, _SUN))
+ Return (PDSM (Arg0, Arg1, Arg2, Arg3, BSEL, ASUN))
}
Method (_S1D, 0, NotSerialized) // _S1D: S1 Device State
with a hank per bridge:
@@ -965,10 +965,10 @@ DefinitionBlock ("", "DSDT", 1, "BOCHS ", "BXPC ", 0x00000001)
Device (S18)
{
Name (_ADR, 0x00030000) // _ADR: Address- Name (_SUN, 0x03) // _SUN: Slot User Number
+ Name (ASUN, 0x03)
Method (_DSM, 4, Serialized) // _DSM: Device-Specific Method {
- Return (PDSM (Arg0, Arg1, Arg2, Arg3, BSEL, _SUN))
+ Return (PDSM (Arg0, Arg1, Arg2, Arg3, BSEL, ASUN))
}
}Message-Id: <[email protected]>
--- tests/data/acpi/pc/DSDT | Bin 6002 -> 6002 bytes tests/data/acpi/pc/DSDT.acpihmat | Bin 7327 -> 7327 bytes tests/data/acpi/pc/DSDT.bridge | Bin 8668 -> 8668 bytes tests/data/acpi/pc/DSDT.cphp | Bin 6466 -> 6466 bytes tests/data/acpi/pc/DSDT.dimmpxm | Bin 7656 -> 7656 bytes tests/data/acpi/pc/DSDT.hpbridge | Bin 5969 -> 5969 bytes tests/data/acpi/pc/DSDT.ipmikcs | Bin 6074 -> 6074 bytes tests/data/acpi/pc/DSDT.memhp | Bin 7361 -> 7361 bytes tests/data/acpi/pc/DSDT.nohpet | Bin 5860 -> 5860 bytes tests/data/acpi/pc/DSDT.numamem | Bin 6008 -> 6008 bytes tests/qtest/bios-tables-test-allowed-diff.h | 10 ---------- 11 files changed, 10 deletions(-)
tests/data/acpi/pc/DSDT binary +0 -0
tests/data/acpi/pc/DSDT.acpihmat binary +0 -0
tests/data/acpi/pc/DSDT.bridge binary +0 -0
tests/data/acpi/pc/DSDT.cphp binary +0 -0
tests/data/acpi/pc/DSDT.dimmpxm binary +0 -0
tests/data/acpi/pc/DSDT.hpbridge binary +0 -0
tests/data/acpi/pc/DSDT.ipmikcs binary +0 -0
tests/data/acpi/pc/DSDT.memhp binary +0 -0
tests/data/acpi/pc/DSDT.nohpet binary +0 -0
tests/data/acpi/pc/DSDT.numamem binary +0 -0
tests/qtest/bios-tables-test-allowed-diff.h +0 -10
@@ -1,11 +1 @@/* List of comma-separated changed AML files to ignore */ -"tests/data/acpi/pc/DSDT" , -"tests/data/acpi/pc/DSDT.bridge" , -"tests/data/acpi/pc/DSDT.ipmikcs" , -"tests/data/acpi/pc/DSDT.cphp" , -"tests/data/acpi/pc/DSDT.memhp" , -"tests/data/acpi/pc/DSDT.numamem" , -"tests/data/acpi/pc/DSDT.nohpet" , -"tests/data/acpi/pc/DSDT.dimmpxm" , -"tests/data/acpi/pc/DSDT.acpihmat" , -"tests/data/acpi/pc/DSDT.hpbridge",
Signature · 1 line
2.25.1
PATCH 39/64 hw/block/nvme: align with existing style
In reply to Michael RothFrom: Gollu Appalanaidu <[email protected]>
While QEMU coding style prefers lowercase hexadecimals in constants, the NVMe subsystem uses the format from the NVMe specifications in comments, i.e. 'h' suffix instead of '0x' prefix.
Fix this up across the code base.
*context dependency for 2b02aabc9d
--- hw/block/nvme-ns.c | 2 +- hw/block/nvme.c | 67 +++++++++++++++++++++++++------------------- include/block/nvme.h | 10 +++---- 3 files changed, 44 insertions(+), 35 deletions(-)
hw/block/nvme-ns.c +1 -1
@@ -303,7 +303,7 @@ static void nvme_ns_init_zoned(NvmeNamespace *ns) id_ns_z =g_malloc0 (sizeof (NvmeIdNsZoned)); -/* MAR/MOR are zeroes-based, 0xffffffff means no limit */ +/* MAR/MOR are zeroes-based, FFFFFFFFFh means no limit */ id_ns_z->mar =cpu_to_le32 (ns->params.max_active_zones -1 ); id_ns_z->mor =cpu_to_le32 (ns->params.max_open_zones -1 ); id_ns_z->zoc =0 ;
hw/block/nvme.c +38 -29
174 lines not on this page · raw message
include/block/nvme.h +5 -5
@@ -848,8 +848,8 @@ enum NvmeStatusCodes {NVME_FW_REQ_SUSYSTEM_RESET =0x0110 ,NVME_NS_ALREADY_ATTACHED =0x0118 ,NVME_NS_PRIVATE =0x0119 , -NVME_NS_NOT_ATTACHED =0x011A , -NVME_NS_CTRL_LIST_INVALID =0x011C , +NVME_NS_NOT_ATTACHED =0x011a , +NVME_NS_CTRL_LIST_INVALID =0x011c ,NVME_CONFLICTING_ATTRS =0x0180 ,NVME_INVALID_PROT_INFO =0x0181 , NVME_WRITE_TO_RO = 0x0182,
@@ -1409,9 +1409,9 @@ typedef enum NvmeZoneState {NVME_ZONE_STATE_IMPLICITLY_OPEN =0x02 ,NVME_ZONE_STATE_EXPLICITLY_OPEN =0x03 ,NVME_ZONE_STATE_CLOSED =0x04 , -NVME_ZONE_STATE_READ_ONLY =0x0D , -NVME_ZONE_STATE_FULL =0x0E , -NVME_ZONE_STATE_OFFLINE =0x0F , +NVME_ZONE_STATE_READ_ONLY =0x0d , +NVME_ZONE_STATE_FULL =0x0e , +NVME_ZONE_STATE_OFFLINE =0x0f , } NvmeZoneState;static inline void _nvme_check_size (void )
Signature · 1 line
2.25.1
PATCH 40/64 hw/nvme: fix missing check for PMR capability
In reply to Michael RothFrom: Klaus Jensen <[email protected]>
Qiang Liu reported that an access on an unknown address is triggered in memory_region_set_enabled because a check on CAP.PMRS is missing for the PMRCTL register write when no PMR is configured.
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/362
--- hw/block/nvme.c | 4 ++++ 1 file changed, 4 insertions(+)
hw/block/nvme.c +4 -0
@@ -5589,6 +5589,10 @@ static void nvme_write_bar(NvmeCtrl *n, hwaddr offset, uint64_t data, "invalid write to PMRCAP register, ignored");return ;case 0xe04 :/* PMRCTL */ +if (!NVME_CAP_PMRS (n->bar.cap)) { +return ; + } + n->bar.pmrctl = data;if (NVME_PMRCTL_EN (data)) {memory_region_set_enabled (&n->pmr.dev->mr, true);
Signature · 1 line
2.25.1
PATCH 41/64 hw/nvme: fix pin-based interrupt behavior (again)
In reply to Michael RothFrom: Klaus Jensen <[email protected]>
Jakub noticed[1] that, when using pin-based interrupts, the device will unconditionally deasssert when any CQEs are acknowledged. However, the pin should not be deasserted if other completion queues still holds unacknowledged CQEs.
The bug is an artifact of commit ca247d35098d ("hw/block/nvme: fix pin-based interrupt behavior") which fixed one bug but introduced another. This is the third time someone tries to fix pin-based interrupts (see commit 5e9aa92eb1a5 ("hw/block: Fix pin-based interrupt behaviour of NVMe"))...
Third time's the charm, so fix it, again, by keeping track of how many CQs have unacknowledged CQEs and only deassert when all are cleared.
[1]: <[email protected]>
*avoid dependency on 88eea45c ("hw/nvme: move nvme emulation out of hw/block")
--- hw/block/nvme.c | 18 +++++++++++++++++- hw/block/nvme.h | 1 + 2 files changed, 18 insertions(+), 1 deletion(-)
hw/block/nvme.c +17 -1
@@ -469,7 +469,9 @@ static void nvme_irq_deassert(NvmeCtrl *n, NvmeCQueue *cq)return ; }else {assert (cq->vector <32 ); - n->irq_status &= ~(1 << cq->vector); +if (!n->cq_pending) { + n->irq_status &= ~(1 << cq->vector); + }nvme_irq_check (n); } }
@@ -1262,6 +1264,7 @@ static void nvme_post_cqes(void *opaque)NvmeCQueue *cq = opaque;NvmeCtrl *n = cq->ctrl;NvmeRequest *req, *next; +bool pending = cq->head != cq->tail;int ret; QTAILQ_FOREACH_SAFE(req, &cq->req_list, entry, next) {
@@ -1291,6 +1294,10 @@ static void nvme_post_cqes(void *opaque)QTAILQ_INSERT_TAIL (&sq->req_list, req, entry); }if (cq->tail != cq->head) { +if (cq->irq_enabled && !pending) { + n->cq_pending++; + } +nvme_irq_assert (n, cq); } }
@@ -4091,6 +4098,11 @@ static uint16_t nvme_del_cq(NvmeCtrl *n, NvmeRequest *req)trace_pci_nvme_err_invalid_del_cq_notempty (qid);return NVME_INVALID_QUEUE_DEL ; } + +if (cq->irq_enabled && cq->tail != cq->head) { + n->cq_pending--; + } +nvme_irq_deassert (n, cq);trace_pci_nvme_del_cq (qid);nvme_free_cq (cq, n);
@@ -5768,6 +5780,10 @@ static void nvme_process_db(NvmeCtrl *n, hwaddr addr, int val) }if (cq->tail == cq->head) { +if (cq->irq_enabled) { + n->cq_pending--; + } +nvme_irq_deassert (n, cq); } }else {
hw/block/nvme.h +1 -0
@@ -171,6 +171,7 @@ typedef struct NvmeCtrl {uint32_t max_q_ents;uint8_t outstanding_aers;uint32_t irq_status; +int cq_pending;uint64_t host_timestamp;/* Timestamp sent by the host */ uint64_t timestamp_set_qemu_clock_ms;/* QEMU clock time */ uint64_t starttime_ms;
Signature · 1 line
2.25.1
PATCH 42/64 virtio-balloon: don't start free page hinting if postcopy is possible
In reply to Michael RothFrom: David Hildenbrand <[email protected]>
Postcopy never worked properly with 'free-page-hint=on', as there are at least two issues:
1) With postcopy, the guest will never receive a VIRTIO_BALLOON_CMD_ID_DONE and consequently won't release free pages back to the OS once migration finishes.
The issue is that for postcopy, we won't do a final bitmap sync while the guest is stopped on the source and virtio_balloon_free_page_hint_notify() will only call virtio_balloon_free_page_done() on the source during PRECOPY_NOTIFY_CLEANUP, after the VM state was already migrated to the destination.
2) Once the VM touches a page on the destination that has been excluded from migration on the source via qemu_guest_free_page_hint() while postcopy is active, that thread will stall until postcopy finishes and all threads are woken up. (with older Linux kernels that won't retry faults when woken up via userfaultfd, we might actually get a SEGFAULT)
The issue is that the source will refuse to migrate any pages that are not marked as dirty in the dirty bmap -- for example, because the page might just have been sent. Consequently, the faulting thread will stall, waiting for the page to be migrated -- which could take quite a while and result in guest OS issues.
While we could fix 1) comparatively easily, 2) is harder to get right and might require more involved RAM migration changes on source and destination [1].
As it never worked properly, let's not start free page hinting in the precopy notifier if the postcopy migration capability was enabled to fix it easily. Capabilities cannot be enabled once migration is already running.
Note 1: in the future we might either adjust migration code on the source
to track pages that have actually been sent or adjust migration code on source and destination to eventually send pages multiple times from the source and and deal with pages that are sent multiple times on the destination.
Note 2: virtio-mem has similar issues, however, access to "unplugged"
memory by the guest is very rare and we would have to be very lucky for it to happen during migration. The spec states "The driver SHOULD NOT read from unplugged memory blocks ..." and "The driver MUST NOT write to unplugged memory blocks". virtio-mem will move away from virtio_balloon_free_page_done() soon and handle this case explicitly on the destination.
[1] https://lkml.kernel.org/r/[email protected]
Message-Id: <[email protected]>
--- hw/virtio/virtio-balloon.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
hw/virtio/virtio-balloon.c +13 -0
@@ -30,6 +30,7 @@#include "trace.h" #include "qemu/error-report.h" #include "migration/misc.h" +#include "migration/migration.h" #include "hw/virtio/virtio-bus.h" #include "hw/virtio/virtio-access.h"
@@ -662,6 +663,18 @@ virtio_balloon_free_page_hint_notify(NotifierWithReturn *n, void *data)return 0 ; } +/* +* Pages hinted via qemu_guest_free_page_hint() are cleared from the dirty +* bitmap and will not get migrated, especially also not when the postcopy +* destination starts using them and requests migration from the source; the +* faulting thread will stall until postcopy migration finishes and +* all threads are woken up. Let's not start free page hinting if postcopy +* is possible. +*/ +if (migrate_postcopy_ram ()) { +return 0 ; + } +switch (pnd->reason) {case PRECOPY_NOTIFY_SETUP :precopy_enable_free_page_optimization ();
Signature · 1 line
2.25.1
PATCH 43/64 hw/net/can: sja1000 fix buff2frame_bas and buff2frame_pel when dlc is out of std CAN 8 bytes
In reply to Michael RothFrom: Pavel Pisa <[email protected]>
Problem reported by openEuler fuzz-sig group.
The buff2frame_bas function (hw\net\can\can_sja1000.c) infoleak(qemu5.x~qemu6.x) or stack-overflow(qemu 4.x).
--- hw/net/can/can_sja1000.c | 8 ++++++++ 1 file changed, 8 insertions(+)
hw/net/can/can_sja1000.c +8 -0
@@ -275,6 +275,10 @@ static void buff2frame_pel(const uint8_t *buff, qemu_can_frame *frame) } frame->can_dlc = buff[0 ] &0x0f ; +if (frame->can_dlc >8 ) { + frame->can_dlc =8 ; + } +if (buff[0 ] &0x80 ) {/* Extended */ frame->can_id |=QEMU_CAN_EFF_FLAG ; frame->can_id |= buff[1 ] <<21 ;/* ID.28~ID.21 */
@@ -311,6 +315,10 @@ static void buff2frame_bas(const uint8_t *buff, qemu_can_frame *frame) } frame->can_dlc = buff[1 ] &0x0f ; +if (frame->can_dlc >8 ) { + frame->can_dlc =8 ; + } +for (i =0 ; i < frame->can_dlc; i++) { frame->data[i] = buff[2 + i]; }
Signature · 1 line
2.25.1
PATCH 44/64 hw/sd/sdcard: Document out-of-range addresses for SEND_WRITE_PROT
In reply to Michael RothFrom: Philippe Mathieu-Daudé <[email protected]>
Per the 'Physical Layer Simplified Specification Version 3.01', Table 4-22: 'Block Oriented Write Protection Commands'
SEND_WRITE_PROT (CMD30)
If the card provides write protection features, this command asks the card to send the status of the write protection bits [1].
[1] 32 write protection bits (representing 32 write protect groups starting at the specified address) [...]
The last (least significant) bit of the protection bits corresponds to the first addressed group. If the addresses of the last groups are outside the valid range, then the corresponding write protection bits shall be set to 0.
Split the if() statement (without changing the behaviour of the code) to better position the description comment.
Message-Id: <[email protected]>
*context dependency for 4ac0b72bae ("hw/sd/sdcard: Fix assertion accessing out-of-range addresses with CMD30")
--- hw/sd/sd.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
hw/sd/sd.c +8 -1
@@ -822,7 +822,14 @@ static uint32_t sd_wpbits(SDState *sd, uint64_t addr)for (i =0 ; i <32 ; i++, wpnum++, addr +=WPGROUP_SIZE ) {assert (wpnum < sd->wpgrps_size); -if (addr < sd->size &&test_bit (wpnum, sd->wp_groups)) { +if (addr >= sd->size) { +/* +* If the addresses of the last groups are outside the valid range, +* then the corresponding write protection bits shall be set to 0. +*/ +continue ; + } +if (test_bit (wpnum, sd->wp_groups)) { ret |= (1 << i); } }
Signature · 1 line
2.25.1
PATCH 45/64 hw/sd/sdcard: Fix assertion accessing out-of-range addresses with CMD30
In reply to Michael RothFrom: Philippe Mathieu-Daudé <[email protected]>
OSS-Fuzz found sending illegal addresses when querying the write protection bits triggers the assertion added in commit 84816fb63e5 ("hw/sd/sdcard: Assert if accessing an illegal group"):
qemu-fuzz-i386-target-generic-fuzz-sdhci-v3: ../hw/sd/sd.c:824: uint32_t sd_wpbits(SDState *, uint64_t):
Assertion `wpnum < sd->wpgrps_size' failed.
#3 0x7f62a8b22c91 in __assert_fail
#4 0x5569adcec405 in sd_wpbits hw/sd/sd.c:824:9
#5 0x5569adce5f6d in sd_normal_command hw/sd/sd.c:1389:38
#6 0x5569adce3870 in sd_do_command hw/sd/sd.c:1737:17
#7 0x5569adcf1566 in sdbus_do_command hw/sd/core.c:100:16
#8 0x5569adcfc192 in sdhci_send_command hw/sd/sdhci.c:337:12
#9 0x5569adcfa3a3 in sdhci_write hw/sd/sdhci.c:1186:9
#10 0x5569adfb3447 in memory_region_write_accessor softmmu/memory.c:492:5
It is legal for the CMD30 to query for out-of-range addresses. Such invalid addresses are simply ignored in the response (write protection bits set to 0).
In commit 84816fb63e5 ("hw/sd/sdcard: Assert if accessing an illegal group") we misplaced the assertion *before* we test the address is in range. Move it *after*.
Include the qtest reproducer provided by Alexander Bulekov:
$ make check-qtest-i386 ... Running test qtest-i386/fuzz-sdcard-test qemu-system-i386: ../hw/sd/sd.c:824: sd_wpbits: Assertion `wpnum < sd->wpgrps_size' failed.
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/495
Message-Id: <[email protected]>
*drop fuzz test additions, since sdcard fuzz test has functional
dependency on guest-visible change not flagged for stable:
59b63d78 ("hw/sd/sdcard: Check for valid address range in SEND_WRITE_PROT (CMD30)")
--- hw/sd/sd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/sd/sd.c +1 -1
@@ -821,7 +821,6 @@ static uint32_t sd_wpbits(SDState *sd, uint64_t addr) wpnum =sd_addr_to_wpnum (addr);for (i =0 ; i <32 ; i++, wpnum++, addr +=WPGROUP_SIZE ) { -assert (wpnum < sd->wpgrps_size);if (addr >= sd->size) {/* * If the addresses of the last groups are outside the valid range,
@@ -829,6 +828,7 @@ static uint32_t sd_wpbits(SDState *sd, uint64_t addr)*/ continue ; } +assert (wpnum < sd->wpgrps_size);if (test_bit (wpnum, sd->wp_groups)) { ret |= (1 << i); }
Signature · 1 line
2.25.1
PATCH 46/64 audio: Never send migration section
In reply to Michael RothFrom: "Dr. David Alan Gilbert" <[email protected]>
The audio migration vmstate is empty, and always has been; we can't just remove it though because an old qemu might send it us. Changes with -audiodev now mean it's sometimes created when it didn't used to be, and can confuse migration to old qemu.
Change it so that vmstate_audio is never sent; if it's received it should still be accepted, and old qemu's shouldn't be too upset if it's missing.
Message-Id: <[email protected]>
--- audio/audio.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
audio/audio.c +10 -0
@@ -1621,10 +1621,20 @@ void audio_cleanup(void) } } +static bool vmstate_audio_needed (void *opaque) +{ +/* +* Never needed, this vmstate only exists in case +* an old qemu sends it to us. +*/ +return false; +} +static const VMStateDescription vmstate_audio = { .name ="audio" , .version_id =1 , .minimum_version_id =1 , + .needed = vmstate_audio_needed, .fields = (VMStateField []) {VMSTATE_END_OF_LIST () }
Signature · 1 line
2.25.1
PATCH 47/64 target/arm: Don't skip M-profile reset entirely in user mode
In reply to Michael RothFrom: Peter Maydell <[email protected]>
Currently all of the M-profile specific code in arm_cpu_reset() is inside a !defined(CONFIG_USER_ONLY) ifdef block. This is
unintentional: it happened because originally the only M-profile-specific handling was the setup of the initial SP and PC from the vector table, which is system-emulation only. But then we added a lot of other M-profile setup to the same "if (ARM_FEATURE_M)" code block without noticing that it was all inside a not-user-mode ifdef. This has generally been harmless, but with the addition of v8.1M low-overhead-loop support we ran into a problem: the reset of FPSCR.LTPSIZE to 4 was only being done for system emulation mode, so if a user-mode guest tried to execute the LE instruction it would incorrectly take a UsageFault.
Adjust the ifdefs so only the really system-emulation specific parts are covered. Because this means we now run some reset code that sets up initial values in the FPCCR and similar FPU related registers, explicitly set up the registers controlling FPU context handling in user-emulation mode so that the FPU works by design and not by chance.
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/613
Message-id: [email protected]
--- target/arm/cpu.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
target/arm/cpu.c +19 -0
@@ -265,12 +265,15 @@ static void arm_cpu_reset(DeviceState *dev) env->uncached_cpsr = ARM_CPU_MODE_SVC; } env->daif =PSTATE_D |PSTATE_A |PSTATE_I |PSTATE_F ; +#endif if (arm_feature (env,ARM_FEATURE_M )) { +#ifndef CONFIG_USER_ONLY uint32_t initial_msp;/* Loaded from 0x0 */ uint32_t initial_pc;/* Loaded from 0x4 */ uint8_t *rom;uint32_t vecbase; +#endif if (cpu_isar_feature (aa32_lob, cpu)) {/*
@@ -324,6 +327,8 @@ static void arm_cpu_reset(DeviceState *dev) env->v7m.fpccr[M_REG_S ] =R_V7M_FPCCR_ASPEN_MASK |R_V7M_FPCCR_LSPEN_MASK |R_V7M_FPCCR_S_MASK ; } + +#ifndef CONFIG_USER_ONLY /* Unlike A/R profile, M profile defines the reset LR value */ env->regs[14 ] =0xffffffff ;
@@ -351,8 +356,22 @@ static void arm_cpu_reset(DeviceState *dev) env->regs[13 ] = initial_msp &0xFFFFFFFC ; env->regs[15 ] = initial_pc & ~1 ; env->thumb = initial_pc &1 ; +#else +/* +* For user mode we run non-secure and with access to the FPU. +* The FPU context is active (ie does not need further setup) +* and is owned by non-secure. +*/ + env->v7m.secure = false; + env->v7m.nsacr =0xcff ; + env->v7m.cpacr[M_REG_NS ] =0xf0ffff ; + env->v7m.fpccr[M_REG_S ] &= + ~(R_V7M_FPCCR_LSPEN_MASK |R_V7M_FPCCR_S_MASK ); + env->v7m.control[M_REG_S ] |=R_V7M_CONTROL_FPCA_MASK ; +#endif } +#ifndef CONFIG_USER_ONLY /* AArch32 has a hard highvec setting of 0xFFFF0000. If we are currently * executing as AArch32 then check if highvecs are enabled and * adjust the PC accordingly.
Signature · 1 line
2.25.1
PATCH 48/64 virtio-net: fix use after unmap/free for sg
In reply to Michael RothFrom: Jason Wang <[email protected]>
When mergeable buffer is enabled, we try to set the num_buffers after the virtqueue elem has been unmapped. This will lead several issues, E.g a use after free when the descriptor has an address which belongs to the non direct access region. In this case we use bounce buffer that is allocated during address_space_map() and freed during address_space_unmap().
Fixing this by storing the elems temporarily in an array and delay the unmap after we set the the num_buffers.
This addresses CVE-2021-3748.
--- hw/net/virtio-net.c | 39 ++++++++++++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 7 deletions(-)
hw/net/virtio-net.c +32 -7
@@ -1659,10 +1659,13 @@ static ssize_t virtio_net_receive_rcu(NetClientState *nc, const uint8_t *buf,VirtIONet *n =qemu_get_nic_opaque (nc);VirtIONetQueue *q =virtio_net_get_subqueue (nc);VirtIODevice *vdev =VIRTIO_DEVICE (n); +VirtQueueElement *elems[VIRTQUEUE_MAX_SIZE ]; +size_t lens[VIRTQUEUE_MAX_SIZE ];struct iovec mhdr_sg[VIRTQUEUE_MAX_SIZE ];struct virtio_net_hdr_mrg_rxbuf mhdr;unsigned mhdr_cnt =0 ; -size_t offset, i, guest_offset; +size_t offset, i, guest_offset, j; +ssize_t err;if (!virtio_net_can_receive (nc)) {return -1 ;
@@ -1693,6 +1696,12 @@ static ssize_t virtio_net_receive_rcu(NetClientState *nc, const uint8_t *buf, total =0 ; +if (i ==VIRTQUEUE_MAX_SIZE ) { +virtio_error (vdev,"virtio-net unexpected long buffer chain" ); + err = size; + goto err; + } + elem =virtqueue_pop (q->rx_vq,sizeof (VirtQueueElement));if (!elem) {if (i) {
@@ -1704,7 +1713,8 @@ static ssize_t virtio_net_receive_rcu(NetClientState *nc, const uint8_t *buf, n->guest_hdr_len, n->host_hdr_len, vdev->guest_features); } -return -1 ; + err =-1 ; + goto err; }if (elem->in_num <1 ) {
@@ -1712,7 +1722,8 @@ static ssize_t virtio_net_receive_rcu(NetClientState *nc, const uint8_t *buf, "virtio-net receive queue contains no in buffers");virtqueue_detach_element (q->rx_vq, elem,0 );g_free (elem); -return -1 ; + err =-1 ; + goto err; } sg = elem->in_sg;
@@ -1749,12 +1760,13 @@ static ssize_t virtio_net_receive_rcu(NetClientState *nc, const uint8_t *buf,if (!n->mergeable_rx_bufs && offset < size) {virtqueue_unpop (q->rx_vq, elem, total);g_free (elem); -return size; + err = size; + goto err; } -/* signal other side */ -virtqueue_fill (q->rx_vq, elem, total, i++); -g_free (elem); + elems[i] = elem; + lens[i] = total; + i++; }if (mhdr_cnt) {
@@ -1764,10 +1776,23 @@ static ssize_t virtio_net_receive_rcu(NetClientState *nc, const uint8_t *buf, &mhdr.num_buffers, sizeof mhdr.num_buffers); } +for (j =0 ; j < i; j++) { +/* signal other side */ +virtqueue_fill (q->rx_vq, elems[j], lens[j], j); +g_free (elems[j]); + } +virtqueue_flush (q->rx_vq, i);virtio_notify (vdev, q->rx_vq);return size; + +err: +for (j =0 ; j < i; j++) { +g_free (elems[j]); + } + +return err; } static ssize_t virtio_net_do_receive(NetClientState *nc, const uint8_t *buf,
Signature · 1 line
2.25.1
PATCH 49/64 qemu-nbd: Change default cache mode to writeback
In reply to Michael RothFrom: Nir Soffer <[email protected]>
Both qemu and qemu-img use writeback cache mode by default, which is already documented in qemu(1). qemu-nbd uses writethrough cache mode by default, and the default cache mode is not documented.
According to the qemu-nbd(8):
--cache=CACHE
The cache mode to be used with the file. See the documentation of the emulator's -drive cache=... option for allowed values.
qemu(1) says:
The default mode is cache=writeback.
So users have no reason to assume that qemu-nbd is using writethough cache mode. The only hint is the painfully slow writing when using the defaults.
Looking in git history, it seems that qemu used writethrough in the past to support broken guests that did not flush data properly, or could not flush due to limitations in qemu. But qemu-nbd clients can use NBD_CMD_FLUSH to flush data, so using writethrough does not help anyone.
Change the default cache mode to writback, and document the default and available values properly in the online help and manual.
With this change converting image via qemu-nbd is 3.5 times faster.
$ qemu-img create dst.img 50g
$ qemu-nbd -t -f raw -k /tmp/nbd.sock dst.imgBefore this change:
$ hyperfine -r3 "./qemu-img convert -p -f raw -O raw -T none -W fedora34.img nbd+unix:///?socket=/tmp/nbd.sock"
Benchmark #1: ./qemu-img convert -p -f raw -O raw -T none -W fedora34.img nbd+unix:///?socket=/tmp/nbd.sock
Time (mean ± σ): 83.639 s ± 5.970 s [User: 2.733 s, System: 6.112 s]
Range (min … max): 76.749 s … 87.245 s 3 runsAfter this change:
$ hyperfine -r3 "./qemu-img convert -p -f raw -O raw -T none -W fedora34.img nbd+unix:///?socket=/tmp/nbd.sock"
Benchmark #1: ./qemu-img convert -p -f raw -O raw -T none -W fedora34.img nbd+unix:///?socket=/tmp/nbd.sock
Time (mean ± σ): 23.522 s ± 0.433 s [User: 2.083 s, System: 5.475 s]
Range (min … max): 23.234 s … 24.019 s 3 runsUsers can avoid the issue by using --cache=writeback[1] but the defaults should give good performance for the common use case.
[1] https://bugzilla.redhat.com/1990656
Message-Id: <[email protected]>
--- docs/tools/qemu-nbd.rst | 6 ++++-- qemu-nbd.c | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-)
docs/tools/qemu-nbd.rst +4 -2
@@ -98,8 +98,10 @@ driver options if ``--image-opts`` is specified. .. option:: --cache=CACHE - The cache mode to be used with the file. See the documentation of - the emulator's ``-drive cache=...`` option for allowed values. + The cache mode to be used with the file. Valid values are: + ``none``, ``writeback`` (the default), ``writethrough``, + ``directsync`` and ``unsafe``. See the documentation of + the emulator's ``-drive cache=...`` option for more info. .. option:: -n, --nocache
qemu-nbd.c +4 -2
@@ -135,7 +135,9 @@ static void usage(const char *name)" 'snapshot.id=[ID],snapshot.name=[NAME]', or\n" " '[ID_OR_NAME]'\n" " -n, --nocache disable host cache\n" -" --cache=MODE set cache mode (none, writeback, ...)\n" +" --cache=MODE set cache mode used to access the disk image, the\n" +" valid options are: 'none', 'writeback' (default),\n" +" 'writethrough', 'directsync' and 'unsafe'\n" " --aio=MODE set AIO mode (native, io_uring or threads)\n" " --discard=MODE set discard mode (ignore, unmap)\n" " --detect-zeroes=MODE set detect-zeroes mode (off, on, unmap)\n"
@@ -552,7 +554,7 @@ int main(int argc, char **argv)bool alloc_depth = false;const char *tlscredsid =NULL ;bool imageOpts = false; -bool writethrough = true; +bool writethrough = false;/* Client will flush as needed. */ bool fork_process = false;bool list = false;int old_stderr =-1 ;
Signature · 1 line
2.25.1
PATCH 50/64 hmp: Unbreak "change vnc"
In reply to Michael RothFrom: Markus Armbruster <[email protected]>
HMP command "change vnc" can take the password as argument, or prompt for it:
(qemu) change vnc password 123
(qemu) change vnc password
Password: ***
(qemu)
This regressed in commit cfb5387a1d "hmp: remove "change vnc TARGET" command", v6.0.0.
(qemu) change vnc passwd 123
Password: ***
(qemu) change vnc passwd
(qemu)
The latter passes NULL to qmp_change_vnc_password(), which is a no-no. Looks like it puts the display into "password required, but none set" state.
The logic error is easy to miss in review, but testing should've caught it.
Fix the obvious way.
Message-Id: <[email protected]>
--- monitor/hmp-cmds.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
monitor/hmp-cmds.c +1 -1
@@ -1492,7 +1492,7 @@ void hmp_change(Monitor *mon, const QDict *qdict) }if (strcmp (target,"passwd" ) ==0 ||strcmp (target,"password" ) ==0 ) { -if (arg) { +if (!arg) {MonitorHMP *hmp_mon =container_of (mon, MonitorHMP, common);monitor_read_password (hmp_mon, hmp_change_read_arg,NULL );return ;
Signature · 1 line
2.25.1
PATCH 51/64 virtio-mem-pci: Fix memory leak when creating MEMORY_DEVICE_SIZE_CHANGE event
In reply to Michael RothFrom: David Hildenbrand <[email protected]>
Apparently, we don't have to duplicate the string.
Message-Id: <[email protected]>
--- hw/virtio/virtio-mem-pci.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
hw/virtio/virtio-mem-pci.c +1 -6
@@ -88,13 +88,8 @@ static void virtio_mem_pci_size_change_notify(Notifier *notifier, void *data) size_change_notifier);DeviceState *dev =DEVICE (pci_mem);const uint64_t *const size_p = data; -const char *id =NULL ; -if (dev->id) { - id =g_strdup (dev->id); - } - -qapi_event_send_memory_device_size_change (!!id, id, *size_p); +qapi_event_send_memory_device_size_change (!!dev->id, dev->id, *size_p); }static void virtio_mem_pci_class_init (ObjectClass *klass,void *data)
Signature · 1 line
2.25.1
PATCH 52/64 uas: add stream number sanity checks.
In reply to Michael RothFrom: Gerd Hoffmann <[email protected]>
The device uses the guest-supplied stream number unchecked, which can lead to guest-triggered out-of-band access to the UASDevice->data3 and UASDevice->status3 fields. Add the missing checks.
Message-Id: <[email protected]>
--- hw/usb/dev-uas.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
hw/usb/dev-uas.c +11 -0
@@ -840,6 +840,9 @@ static void usb_uas_handle_data(USBDevice *dev, USBPacket *p) }break ;case UAS_PIPE_ID_STATUS : +if (p->stream >UAS_MAX_STREAMS ) { + goto err_stream; + }if (p->stream) { QTAILQ_FOREACH(st, &uas->results, next) {if (st->stream == p->stream) {
@@ -867,6 +870,9 @@ static void usb_uas_handle_data(USBDevice *dev, USBPacket *p)break ;case UAS_PIPE_ID_DATA_IN :case UAS_PIPE_ID_DATA_OUT : +if (p->stream >UAS_MAX_STREAMS ) { + goto err_stream; + }if (p->stream) { req =usb_uas_find_request (uas, p->stream); }else {
@@ -902,6 +908,11 @@ static void usb_uas_handle_data(USBDevice *dev, USBPacket *p) p->status =USB_RET_STALL ;break ; } + +err_stream: +error_report ("%s: invalid stream %d" , __func__, p->stream); + p->status =USB_RET_STALL ; +return ; }static void usb_uas_unrealize (USBDevice *dev)
Signature · 1 line
2.25.1
PATCH 53/64 usb/redir: avoid dynamic stack allocation (CVE-2021-3527)
In reply to Michael RothFrom: Gerd Hoffmann <[email protected]>
Use autofree heap allocation instead.
Message-Id: <[email protected]>
--- hw/usb/redirect.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
hw/usb/redirect.c +3 -3
@@ -620,7 +620,7 @@ static void usbredir_handle_iso_data(USBRedirDevice *dev, USBPacket *p, .endpoint = ep, .length = p->iov.size }; -uint8_t buf[p->iov.size]; + g_autofree uint8_t *buf = g_malloc(p->iov.size);/* No id, we look at the ep when receiving a status back */ usb_packet_copy (p, buf, p->iov.size); usbredirparser_send_iso_packet(dev->parser, 0, &iso_packet,
@@ -818,7 +818,7 @@ static void usbredir_handle_bulk_data(USBRedirDevice *dev, USBPacket *p,usbredirparser_send_bulk_packet (dev->parser, p->id, &bulk_packet,NULL ,0 ); }else { -uint8_t buf[size]; + g_autofree uint8_t *buf = g_malloc(size);usb_packet_copy (p, buf, size);usbredir_log_data (dev,"bulk data out:" , buf, size); usbredirparser_send_bulk_packet(dev->parser, p->id,
@@ -923,7 +923,7 @@ static void usbredir_handle_interrupt_out_data(USBRedirDevice *dev, USBPacket *p, uint8_t ep) {struct usb_redir_interrupt_packet_header interrupt_packet; -uint8_t buf[p->iov.size]; + g_autofree uint8_t *buf = g_malloc(p->iov.size);DPRINTF ("interrupt-out ep %02X len %zd id %" PRIu64"\n" , ep, p->iov.size, p->id);
Signature · 1 line
2.25.1
PATCH 54/64 usb: limit combined packets to 1 MiB (CVE-2021-3527)
In reply to Michael RothFrom: Gerd Hoffmann <[email protected]>
usb-host and usb-redirect try to batch bulk transfers by combining many small usb packets into a single, large transfer request, to reduce the overhead and improve performance.
This patch adds a size limit of 1 MiB for those combined packets to restrict the host resources the guest can bind that way.
Message-Id: <[email protected]>
--- hw/usb/combined-packet.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
hw/usb/combined-packet.c +3 -1
@@ -171,7 +171,9 @@ void usb_ep_combine_input_packets(USBEndpoint *ep)if ((p->iov.size % ep->max_packet_size) !=0 || !p->short_not_ok || next ==NULL ||/* Work around for Linux usbfs bulk splitting + migration */ - (totalsize == (16 * KiB -36 ) && p->int_req)) { + (totalsize == (16 * KiB -36 ) && p->int_req) || +/* Next package may grow combined package over 1MiB */ + totalsize >1 * MiB - ep->max_packet_size) {usb_device_handle_data (ep->dev, first);assert (first->status ==USB_RET_ASYNC );if (first->combined) {
Signature · 1 line
2.25.1
Quoted 4 lines · Michael Roth
Hi everyone,
The following new patches are queued for QEMU stable v6.0.1:
Quoted 8 lines
https://gitlab.com/qemu-project/qemu/-/commits/stable-6.0-staging/
Patch freeze is 2021-10-26, and the release is planned for 2021-10-28:
https://wiki.qemu.org/Planning/6.0
Please respond here or CC [email protected] on any additional patches you think should (or shouldn't) be included in the release.
I believe we should also include this patch:
https://lore.kernel.org/qemu-devel/[email protected]/T/
It is also CC'd to qemu-stable@ but the patch itself was not tagged so (my apologies for that).
Quoted 212 lines
Thanks!
----------------------------------------------------------------
David Hildenbrand (2):
virtio-balloon: don't start free page hinting if postcopy is possible
virtio-mem-pci: Fix memory leak when creatingMEMORY_DEVICE_SIZE_CHANGEeventDr. David Alan Gilbert (1):
audio: Never send migration sectionGerd Hoffmann (3):
uas: add stream number sanity checks. usb/redir: avoid dynamic stack allocation (CVE-2021-3527)
usb: limit combined packets to 1 MiB (CVE-2021-3527)Giuseppe Musacchio (1):
target/ppc: Fix load endianness for lxvwsx/lxvdsxGollu Appalanaidu (1):
hw/block/nvme: align with existing styleGreg Kurz (1):
docs/system: Document the removal of "compat" property for POWER CPUsIgor Mammedov (3):
tests: acpi: prepare for changing DSDT tables
acpi: pc: revert back to v5.2 PCI slot enumeration
tests: acpi: pc: update expected DSDT blobsJason Wang (2):
vhost-vdpa: don't initializebackend_features
virtio-net: fix use after unmap/free for sgKevin Wolf (1):
hmp: Fix loadvm to resume the VM on success instead of failureKlaus Jensen (2):
hw/nvme: fix missing check for PMR capability hw/nvme: fix pin-based interrupt behavior (again)Kunkun Jiang (1):
vfio: Fix unregister SaveVMHandler invfio_migration_finalizeLeonardo Bras (1):
yank: Unregister function when using TLS migrationLi Qiang (7):
vhost-user-gpu: fix memory disclosure invirgl_cmd_get_capset_info(CVE-2021-3545)
vhost-user-gpu: fix resource leak in 'vg_resource_create_2d' (CVE-2021-3544)
vhost-user-gpu: fix memory leak invg_resource_attach_backing(CVE-2021-3544)
vhost-user-gpu: fix memory leak while calling 'vg_resource_unref' (CVE-2021-3544)
vhost-user-gpu: fix memory leak in 'virgl_cmd_resource_unref' (CVE-2021-3544)
vhost-user-gpu: fix memory leak in 'virgl_resource_attach_backing' (CVE-2021-3544)
vhost-user-gpu: fix OOB write in 'virgl_cmd_get_capset' (CVE-2021-3546)Li Zhijian (1):
migration/rdma: Fixcm_eventused before being initializedMarcel Apfelbaum (3):
hw/rdma: Fix possible mremap overflow in the pvrdma device (CVE-2021-3582)
pvrdma: Ensure correct input on ring init (CVE-2021-3607)
pvrdma: Fix the ring init error flow (CVE-2021-3608)Mark Cave-Ayland (2):
esp: only assertINTR_DCinterrupt flag if selection fails
esp: only setESP_RSEQat the start of the select sequenceMarkus Armbruster (1):
hmp: Unbreak "change vnc"Max Filippov (1):
target/xtensa: fix access ring in l32exNir Soffer (1):
qemu-nbd: Change default cache mode to writebackPaolo Bonzini (7):
vl: allow not specifying size in -m when using -M memory-backend
qemu-option: support accept-any QemuOptsList inqemu_opts_absorb_qdict
qemu-config: load modules when instantiating option groups
qemu-config: parse configuration files to a QDict
vl: plumb keyval-based options into -readconfig
vl: plug -object back into -readconfig
configure: fix detection of gdbus-codegenPavel Pisa (1):
hw/net/can: sja1000 fixbuff2frame_basandbuff2frame_pelwhen dlc is out of std CAN 8 bytesPeng Liang (1):
runstate: Initialize Error * to NULLPeter Maydell (1):
target/arm: Don't skip M-profile reset entirely in user modePhilippe Mathieu-Daudé (11):
hw/pci-host/q35: Ignore write of reserved PCIEXBAR LENGTH field block/nvme: FixVFIO_MAP_DMAfailed: No space left on devicecrypto/tlscreds: Introduceqcrypto_tls_creds_check_endpoint()helper block/nbd: Useqcrypto_tls_creds_check_endpoint()
qemu-nbd: Useqcrypto_tls_creds_check_endpoint()chardev/socket: Useqcrypto_tls_creds_check_endpoint()migration/tls: Useqcrypto_tls_creds_check_endpoint()ui/vnc: Useqcrypto_tls_creds_check_endpoint()
crypto: Make QCryptoTLSCreds* structures private hw/sd/sdcard: Document out-of-range addresses forSEND_WRITE_PROThw/sd/sdcard: Fix assertion accessing out-of-range addresses with CMD30Richard Henderson (4):
linux-user/aarch64: Enable hwcap for RND, BTI, and MTE target/i386: Exit tb after wrmsr
tcg/sparc: Fixtemp_allocate_framevs sparc stack bias
tcg: Allocate sufficient storage intemp_allocate_frameStefan Hajnoczi (1):
sockets: updateSOCKET_ADDRESS_TYPE_FDlisten(2) backlogStefan Reiter (1):
monitor/qmp: fix race onCHR_EVENT_CLOSEDwithout OOBZenghui Yu (1):
multi-process: Initialize variables declared with g_auto*Zhenzhong Duan (1):
vl: Fix an assert failure in error pathaudio/audio.c | 10 +++ block/nbd.c | 6 +- block/nvme.c | 22 ++++++ blockdev-nbd.c | 6 +- chardev/char-socket.c | 18 ++--- configure | 4 +- contrib/vhost-user-gpu/vhost-user-gpu.c | 7 ++ contrib/vhost-user-gpu/virgl.c | 17 ++++- crypto/tls-cipher-suites.c | 7 ++ crypto/tlscreds.c | 12 +++ crypto/tlscredsanon.c | 2 + crypto/tlscredspriv.h | 45 +++++++++++ crypto/tlscredspsk.c | 2 + crypto/tlscredsx509.c | 1 + crypto/tlssession.c | 1 + docs/system/removed-features.rst | 6 ++ docs/tools/qemu-nbd.rst | 6 +- hw/block/nvme-ns.c | 2 +- hw/block/nvme.c | 89 ++++++++++++++-------- hw/block/nvme.h | 1 + hw/i386/acpi-build.c | 9 ++- hw/net/can/can_sja1000.c | 8 ++ hw/net/virtio-net.c | 39 ++++++++-- hw/pci-host/q35.c | 3 + hw/rdma/vmw/pvrdma_cmd.c | 7 ++ hw/rdma/vmw/pvrdma_dev_ring.c | 2 +- hw/rdma/vmw/pvrdma_main.c | 5 ++ hw/remote/memory.c | 5 +- hw/remote/proxy.c | 3 +- hw/scsi/esp.c | 13 +++- hw/sd/sd.c | 9 ++- hw/usb/combined-packet.c | 4 +- hw/usb/dev-uas.c | 11 +++ hw/usb/redirect.c | 6 +- hw/vfio/migration.c | 1 + hw/virtio/vhost-vdpa.c | 3 - hw/virtio/virtio-balloon.c | 13 ++++ hw/virtio/virtio-mem-pci.c | 7 +- include/block/nvme.h | 10 +-- include/block/qdict.h | 2 - include/crypto/tls-cipher-suites.h | 6 -- include/crypto/tlscreds.h | 30 ++++---- include/crypto/tlscredsanon.h | 12 --- include/crypto/tlscredspsk.h | 12 --- include/crypto/tlscredsx509.h | 10 --- include/qapi/qmp/qdict.h | 3 + include/qemu/config-file.h | 7 +- linux-user/elfload.c | 13 ++++ migration/channel.c | 26 ++++--- migration/multifd.c | 3 +- migration/qemu-file-channel.c | 4 +- migration/rdma.c | 1 - migration/tls.c | 6 +- monitor/hmp-cmds.c | 4 +- monitor/qmp.c | 40 +++++----- qemu-nbd.c | 25 +++--- softmmu/runstate.c | 2 +- softmmu/vl.c | 130 +++++++++++++++++++++++--------- stubs/meson.build | 1 + stubs/module-opts.c | 6 ++ target/arm/cpu.c | 19 +++++ target/i386/tcg/translate.c | 2 + target/ppc/translate/vsx-impl.c.inc | 4 +- target/xtensa/translate.c | 2 +- tcg/sparc/tcg-target.c.inc | 16 ++-- tcg/tcg.c | 40 +++++++--- tests/data/acpi/pc/DSDT | Bin 6002 -> 6002 bytes tests/data/acpi/pc/DSDT.acpihmat | Bin 7327 -> 7327 bytes tests/data/acpi/pc/DSDT.bridge | Bin 8668 -> 8668 bytes tests/data/acpi/pc/DSDT.cphp | Bin 6466 -> 6466 bytes tests/data/acpi/pc/DSDT.dimmpxm | Bin 7656 -> 7656 bytes tests/data/acpi/pc/DSDT.hpbridge | Bin 5969 -> 5969 bytes tests/data/acpi/pc/DSDT.ipmikcs | Bin 6074 -> 6074 bytes tests/data/acpi/pc/DSDT.memhp | Bin 7361 -> 7361 bytes tests/data/acpi/pc/DSDT.nohpet | Bin 5860 -> 5860 bytes tests/data/acpi/pc/DSDT.numamem | Bin 6008 -> 6008 bytes ui/vnc.c | 7 +- util/qemu-config.c | 99 ++++++++++++++++-------- util/qemu-option.c | 3 +- util/qemu-sockets.c | 29 +++++-- 80 files changed, 685 insertions(+), 301 deletions(-) create mode 100644 stubs/module-opts.c
Quoted 14 lines · Ani Sinha
Quoted 10 lines · Michael Roth
Hi everyone,
The following new patches are queued for QEMU stable v6.0.1:
https://gitlab.com/qemu-project/qemu/-/commits/stable-6.0-staging/
Patch freeze is 2021-10-26, and the release is planned for 2021-10-28:
Quoted 8 lines
Quoted 2 lines
Please respond here or CC [email protected] on any additional patches you think should (or shouldn't) be included in the release.
I believe we should also include this patch:
https://lore.kernel.org/qemu-devel/[email protected]/T/It is also CC'd to qemu-stable@ but the patch itself was not tagged so (my apologies for that).
I concur.
Quoted 214 lines
Quoted 214 lines
Thanks!
----------------------------------------------------------------
David Hildenbrand (2):
virtio-balloon: don't start free page hinting if postcopy is possible
virtio-mem-pci: Fix memory leak when creatingMEMORY_DEVICE_SIZE_CHANGEeventDr. David Alan Gilbert (1):
audio: Never send migration sectionGerd Hoffmann (3):
uas: add stream number sanity checks. usb/redir: avoid dynamic stack allocation (CVE-2021-3527)
usb: limit combined packets to 1 MiB (CVE-2021-3527)Giuseppe Musacchio (1):
target/ppc: Fix load endianness for lxvwsx/lxvdsxGollu Appalanaidu (1):
hw/block/nvme: align with existing styleGreg Kurz (1):
docs/system: Document the removal of "compat" property for POWER CPUsIgor Mammedov (3):
tests: acpi: prepare for changing DSDT tables
acpi: pc: revert back to v5.2 PCI slot enumeration
tests: acpi: pc: update expected DSDT blobsJason Wang (2):
vhost-vdpa: don't initializebackend_features
virtio-net: fix use after unmap/free for sgKevin Wolf (1):
hmp: Fix loadvm to resume the VM on success instead of failureKlaus Jensen (2):
hw/nvme: fix missing check for PMR capability hw/nvme: fix pin-based interrupt behavior (again)Kunkun Jiang (1):
vfio: Fix unregister SaveVMHandler invfio_migration_finalizeLeonardo Bras (1):
yank: Unregister function when using TLS migrationLi Qiang (7):
vhost-user-gpu: fix memory disclosure invirgl_cmd_get_capset_info(CVE-2021-3545)
vhost-user-gpu: fix resource leak in 'vg_resource_create_2d' (CVE-2021-3544)
vhost-user-gpu: fix memory leak invg_resource_attach_backing(CVE-2021-3544)
vhost-user-gpu: fix memory leak while calling 'vg_resource_unref' (CVE-2021-3544)
vhost-user-gpu: fix memory leak in 'virgl_cmd_resource_unref' (CVE-2021-3544)
vhost-user-gpu: fix memory leak in 'virgl_resource_attach_backing' (CVE-2021-3544)
vhost-user-gpu: fix OOB write in 'virgl_cmd_get_capset' (CVE-2021-3546)Li Zhijian (1):
migration/rdma: Fixcm_eventused before being initializedMarcel Apfelbaum (3):
hw/rdma: Fix possible mremap overflow in the pvrdma device (CVE-2021-3582)
pvrdma: Ensure correct input on ring init (CVE-2021-3607)
pvrdma: Fix the ring init error flow (CVE-2021-3608)Mark Cave-Ayland (2):
esp: only assertINTR_DCinterrupt flag if selection fails
esp: only setESP_RSEQat the start of the select sequenceMarkus Armbruster (1):
hmp: Unbreak "change vnc"Max Filippov (1):
target/xtensa: fix access ring in l32exNir Soffer (1):
qemu-nbd: Change default cache mode to writebackPaolo Bonzini (7):
vl: allow not specifying size in -m when using -M memory-backend
qemu-option: support accept-any QemuOptsList inqemu_opts_absorb_qdict
qemu-config: load modules when instantiating option groups
qemu-config: parse configuration files to a QDict
vl: plumb keyval-based options into -readconfig
vl: plug -object back into -readconfig
configure: fix detection of gdbus-codegenPavel Pisa (1):
hw/net/can: sja1000 fixbuff2frame_basandbuff2frame_pelwhen dlc is out of std CAN 8 bytesPeng Liang (1):
runstate: Initialize Error * to NULLPeter Maydell (1):
target/arm: Don't skip M-profile reset entirely in user modePhilippe Mathieu-Daudé (11):
hw/pci-host/q35: Ignore write of reserved PCIEXBAR LENGTH field block/nvme: FixVFIO_MAP_DMAfailed: No space left on devicecrypto/tlscreds: Introduceqcrypto_tls_creds_check_endpoint()helper block/nbd: Useqcrypto_tls_creds_check_endpoint()
qemu-nbd: Useqcrypto_tls_creds_check_endpoint()chardev/socket: Useqcrypto_tls_creds_check_endpoint()migration/tls: Useqcrypto_tls_creds_check_endpoint()ui/vnc: Useqcrypto_tls_creds_check_endpoint()
crypto: Make QCryptoTLSCreds* structures private hw/sd/sdcard: Document out-of-range addresses forSEND_WRITE_PROThw/sd/sdcard: Fix assertion accessing out-of-range addresses with CMD30Richard Henderson (4):
linux-user/aarch64: Enable hwcap for RND, BTI, and MTE target/i386: Exit tb after wrmsr
tcg/sparc: Fixtemp_allocate_framevs sparc stack bias
tcg: Allocate sufficient storage intemp_allocate_frameStefan Hajnoczi (1):
sockets: updateSOCKET_ADDRESS_TYPE_FDlisten(2) backlogStefan Reiter (1):
monitor/qmp: fix race onCHR_EVENT_CLOSEDwithout OOBZenghui Yu (1):
multi-process: Initialize variables declared with g_auto*Zhenzhong Duan (1):
vl: Fix an assert failure in error pathaudio/audio.c | 10 +++ block/nbd.c | 6 +- block/nvme.c | 22 ++++++ blockdev-nbd.c | 6 +- chardev/char-socket.c | 18 ++--- configure | 4 +- contrib/vhost-user-gpu/vhost-user-gpu.c | 7 ++ contrib/vhost-user-gpu/virgl.c | 17 ++++- crypto/tls-cipher-suites.c | 7 ++ crypto/tlscreds.c | 12 +++ crypto/tlscredsanon.c | 2 + crypto/tlscredspriv.h | 45 +++++++++++ crypto/tlscredspsk.c | 2 + crypto/tlscredsx509.c | 1 + crypto/tlssession.c | 1 + docs/system/removed-features.rst | 6 ++ docs/tools/qemu-nbd.rst | 6 +- hw/block/nvme-ns.c | 2 +- hw/block/nvme.c | 89 ++++++++++++++-------- hw/block/nvme.h | 1 + hw/i386/acpi-build.c | 9 ++- hw/net/can/can_sja1000.c | 8 ++ hw/net/virtio-net.c | 39 ++++++++-- hw/pci-host/q35.c | 3 + hw/rdma/vmw/pvrdma_cmd.c | 7 ++ hw/rdma/vmw/pvrdma_dev_ring.c | 2 +- hw/rdma/vmw/pvrdma_main.c | 5 ++ hw/remote/memory.c | 5 +- hw/remote/proxy.c | 3 +- hw/scsi/esp.c | 13 +++- hw/sd/sd.c | 9 ++- hw/usb/combined-packet.c | 4 +- hw/usb/dev-uas.c | 11 +++ hw/usb/redirect.c | 6 +- hw/vfio/migration.c | 1 + hw/virtio/vhost-vdpa.c | 3 - hw/virtio/virtio-balloon.c | 13 ++++ hw/virtio/virtio-mem-pci.c | 7 +- include/block/nvme.h | 10 +-- include/block/qdict.h | 2 - include/crypto/tls-cipher-suites.h | 6 -- include/crypto/tlscreds.h | 30 ++++---- include/crypto/tlscredsanon.h | 12 --- include/crypto/tlscredspsk.h | 12 --- include/crypto/tlscredsx509.h | 10 --- include/qapi/qmp/qdict.h | 3 + include/qemu/config-file.h | 7 +- linux-user/elfload.c | 13 ++++ migration/channel.c | 26 ++++--- migration/multifd.c | 3 +- migration/qemu-file-channel.c | 4 +- migration/rdma.c | 1 - migration/tls.c | 6 +- monitor/hmp-cmds.c | 4 +- monitor/qmp.c | 40 +++++----- qemu-nbd.c | 25 +++--- softmmu/runstate.c | 2 +- softmmu/vl.c | 130 +++++++++++++++++++++++--------- stubs/meson.build | 1 + stubs/module-opts.c | 6 ++ target/arm/cpu.c | 19 +++++ target/i386/tcg/translate.c | 2 + target/ppc/translate/vsx-impl.c.inc | 4 +- target/xtensa/translate.c | 2 +- tcg/sparc/tcg-target.c.inc | 16 ++-- tcg/tcg.c | 40 +++++++--- tests/data/acpi/pc/DSDT | Bin 6002 -> 6002 bytes tests/data/acpi/pc/DSDT.acpihmat | Bin 7327 -> 7327 bytes tests/data/acpi/pc/DSDT.bridge | Bin 8668 -> 8668 bytes tests/data/acpi/pc/DSDT.cphp | Bin 6466 -> 6466 bytes tests/data/acpi/pc/DSDT.dimmpxm | Bin 7656 -> 7656 bytes tests/data/acpi/pc/DSDT.hpbridge | Bin 5969 -> 5969 bytes tests/data/acpi/pc/DSDT.ipmikcs | Bin 6074 -> 6074 bytes tests/data/acpi/pc/DSDT.memhp | Bin 7361 -> 7361 bytes tests/data/acpi/pc/DSDT.nohpet | Bin 5860 -> 5860 bytes tests/data/acpi/pc/DSDT.numamem | Bin 6008 -> 6008 bytes ui/vnc.c | 7 +- util/qemu-config.c | 99 ++++++++++++++++-------- util/qemu-option.c | 3 +- util/qemu-sockets.c | 29 +++++-- 80 files changed, 685 insertions(+), 301 deletions(-) create mode 100644 stubs/module-opts.c
Quoting Ani Sinha (2021-10-19 09:43:52)
Quoted 14 lines · Michael Roth
Quoted 11 lines
Hi everyone,
The following new patches are queued for QEMU stable v6.0.1:
https://gitlab.com/qemu-project/qemu/-/commits/stable-6.0-staging/
Patch freeze is 2021-10-26, and the release is planned for 2021-10-28:
Quoted 8 lines
Quoted 2 lines
Please respond here or CC [email protected] on any additional patches you think should (or shouldn't) be included in the release.
I believe we should also include this patch:
https://lore.kernel.org/qemu-devel/[email protected]/T/It is also CC'd to qemu-stable@ but the patch itself was not tagged so (my apologies for that).
It looks like this patch is a fix for:
commit caf108bc587908f7608729f39639dccdfa53010b
Author: Julia Suvorova <[email protected]>
Date: Tue Jul 13 02:42:00 2021 +0200
hw/i386/acpi-build: Add ACPI PCI hot-plug methods to Q35
which is in 6.1.0, but not 6.0.0, so it didn't seem like it was needed for 6.0.1. Let me know if that's incorrect.
Will definitely pull it in for 6.1.1 though.
Quoted 33 lines · On Tue, Oct 19, 2021 at 23:53 Michael Roth <[email protected]> wrote:
Quoting Ani Sinha (2021-10-19 09:43:52)
Quoted 8 lines · Michael Roth
Quoted 5 lines
Hi everyone,
The following new patches are queued for QEMU stable v6.0.1:
Quoted 7 lines
Quoted 7 lines
https://gitlab.com/qemu-project/qemu/-/commits/stable-6.0-staging/
Patch freeze is 2021-10-26, and the release is planned for 2021-10-28:
https://wiki.qemu.org/Planning/6.0
Please respond here or CC [email protected] on any additional
patches
Quoted 4 lines
Quoted 1 line
you think should (or shouldn't) be included in the release.
I believe we should also include this patch:
https://lore.kernel.org/qemu-devel/[email protected]/T/
Quoted 2 lines
It is also CC'd to qemu-stable@ but the patch itself was not tagged so
(my
Quoted 1 line
apologies for that).
It looks like this patch is a fix for:
commit
caf108bc587908f7608729f39639dccdfa53010b
Author: Julia Suvorova <[email protected]>
Date: Tue Jul 13 02:42:00 2021 +0200
Quoted 6 lines
hw/i386/acpi-build: Add ACPI PCI hot-plug methods to Q35
which is in 6.1.0, but not 6.0.0, so it didn't seem like it was needed for 6.0.1. Let me know if that's incorrect.
Will definitely pull it in for 6.1.1 though.
Yes you are correct. This should be pulled in for 6.1.1 and not 6.0.1. In fact for 6.0.1 there will likely be a conflict and the patch won’t apply. Apologies for the noise.
Quoted 2 lines
PATCH 55/64 vhost-user-gpu: fix memory disclosure in virgl_cmd_get_capset_info (CVE-2021-3545)
In reply to Michael RothFrom: Li Qiang <[email protected]>
Otherwise some of the 'resp' will be leaked to guest.
virtio-gpu fix: 42a8dadc74 ("virtio-gpu: fix information leak in getting capset info dispatch")
Message-Id: <[email protected]>
--- contrib/vhost-user-gpu/virgl.c | 1 + 1 file changed, 1 insertion(+)
contrib/vhost-user-gpu/virgl.c +1 -0
@@ -128,6 +128,7 @@ virgl_cmd_get_capset_info(VuGpu *g,VUGPU_FILL_CMD (info); +memset (&resp,0 ,sizeof (resp));if (info.capset_index ==0 ) { resp.capset_id =VIRTIO_GPU_CAPSET_VIRGL ; virgl_renderer_get_cap_set(resp.capset_id,
Signature · 1 line
2.25.1
PATCH 56/64 vhost-user-gpu: fix resource leak in 'vg_resource_create_2d' (CVE-2021-3544)
In reply to Michael RothFrom: Li Qiang <[email protected]>
Call 'vugbm_buffer_destroy' in error path to avoid resource leak.
Message-Id: <[email protected]>
--- contrib/vhost-user-gpu/vhost-user-gpu.c | 1 + 1 file changed, 1 insertion(+)
contrib/vhost-user-gpu/vhost-user-gpu.c +1 -0
@@ -349,6 +349,7 @@ vg_resource_create_2d(VuGpu *g,g_critical ("%s: resource creation failed %d %d %d" , __func__, c2d.resource_id, c2d.width, c2d.height);g_free (res); +vugbm_buffer_destroy (&res->buffer); cmd->error =VIRTIO_GPU_RESP_ERR_OUT_OF_MEMORY ;return ; }
Signature · 1 line
2.25.1
PATCH 57/64 vhost-user-gpu: fix memory leak in vg_resource_attach_backing (CVE-2021-3544)
In reply to Michael RothFrom: Li Qiang <[email protected]>
Check whether the 'res' has already been attach_backing to avoid memory leak.
virtio-gpu fix: 204f01b309 ("virtio-gpu: fix memory leak in resource attach backing")
Message-Id: <[email protected]>
--- contrib/vhost-user-gpu/vhost-user-gpu.c | 5 +++++ 1 file changed, 5 insertions(+)
contrib/vhost-user-gpu/vhost-user-gpu.c +5 -0
@@ -489,6 +489,11 @@ vg_resource_attach_backing(VuGpu *g,return ; } +if (res->iov) { + cmd->error =VIRTIO_GPU_RESP_ERR_UNSPEC ; +return ; + } + ret =vg_create_mapping_iov (g, &ab, cmd, &res->iov);if (ret !=0 ) { cmd->error =VIRTIO_GPU_RESP_ERR_UNSPEC ;
Signature · 1 line
2.25.1
PATCH 58/64 vhost-user-gpu: fix memory leak while calling 'vg_resource_unref' (CVE-2021-3544)
In reply to Michael RothFrom: Li Qiang <[email protected]>
If the guest trigger following sequences, the attach_backing will be leaked:
vg_resource_create_2d
vg_resource_attach_backing
vg_resource_unref
This patch fix this by freeing 'res->iov' in vg_resource_destroy.
virtio-gpu fix: 5e8e3c4c75 ("virtio-gpu: fix resource leak in virgl_cmd_resource_unref")
Message-Id: <[email protected]>
--- contrib/vhost-user-gpu/vhost-user-gpu.c | 1 + 1 file changed, 1 insertion(+)
contrib/vhost-user-gpu/vhost-user-gpu.c +1 -0
@@ -400,6 +400,7 @@ vg_resource_destroy(VuGpu *g, }vugbm_buffer_destroy (&res->buffer); +g_free (res->iov);pixman_image_unref (res->image);QTAILQ_REMOVE (&g->reslist, res, next);g_free (res);
Signature · 1 line
2.25.1
PATCH 59/64 vhost-user-gpu: fix memory leak in 'virgl_cmd_resource_unref' (CVE-2021-3544)
In reply to Michael RothFrom: Li Qiang <[email protected]>
The 'res->iov' will be leaked if the guest trigger following sequences:
virgl_cmd_create_resource_2d
virgl_resource_attach_backing
virgl_cmd_resource_unref
This patch fixes this.
virtio-gpu fix: 5e8e3c4c75 ("virtio-gpu: fix resource leak in virgl_cmd_resource_unref"
Message-Id: <[email protected]>
--- contrib/vhost-user-gpu/virgl.c | 7 +++++++ 1 file changed, 7 insertions(+)
contrib/vhost-user-gpu/virgl.c +7 -0
@@ -108,9 +108,16 @@ virgl_cmd_resource_unref(VuGpu *g, struct virtio_gpu_ctrl_command *cmd) {struct virtio_gpu_resource_unref unref; +struct iovec *res_iovs =NULL ; +int num_iovs =0 ;VUGPU_FILL_CMD (unref); +virgl_renderer_resource_detach_iov (unref.resource_id, + &res_iovs, + &num_iovs); +g_free (res_iovs); +virgl_renderer_resource_unref (unref.resource_id); }
Signature · 1 line
2.25.1
PATCH 60/64 vhost-user-gpu: fix memory leak in 'virgl_resource_attach_backing' (CVE-2021-3544)
In reply to Michael RothFrom: Li Qiang <[email protected]>
If 'virgl_renderer_resource_attach_iov' failed, the 'res_iovs' will be leaked.
virtio-gpu fix: 33243031da ("virtio-gpu-3d: fix memory leak in resource attach backing")
Message-Id: <[email protected]>
--- contrib/vhost-user-gpu/virgl.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
contrib/vhost-user-gpu/virgl.c +4 -1
@@ -287,8 +287,11 @@ virgl_resource_attach_backing(VuGpu *g,return ; } -virgl_renderer_resource_attach_iov (att_rb.resource_id, + ret =virgl_renderer_resource_attach_iov (att_rb.resource_id, res_iovs, att_rb.nr_entries); +if (ret !=0 ) { +g_free (res_iovs); + } } static void
Signature · 1 line
2.25.1
PATCH 61/64 vhost-user-gpu: fix OOB write in 'virgl_cmd_get_capset' (CVE-2021-3546)
In reply to Michael RothFrom: Li Qiang <[email protected]>
If 'virgl_cmd_get_capset' set 'max_size' to 0,
the 'virgl_renderer_fill_caps' will write the data after the 'resp'. This patch avoid this by checking the returned 'max_size'.
virtio-gpu fix: abd7f08b23 ("display: virtio-gpu-3d: check virgl capabilities max_size")
Message-Id: <[email protected]>
--- contrib/vhost-user-gpu/virgl.c | 4 ++++ 1 file changed, 4 insertions(+)
contrib/vhost-user-gpu/virgl.c +4 -0
@@ -177,6 +177,10 @@ virgl_cmd_get_capset(VuGpu *g,virgl_renderer_get_cap_set (gc.capset_id, &max_ver, &max_size); +if (!max_size) { + cmd->error =VIRTIO_GPU_RESP_ERR_INVALID_PARAMETER ; +return ; + } resp =g_malloc0 (sizeof (*resp) + max_size); resp->hdr.type =VIRTIO_GPU_RESP_OK_CAPSET ;
Signature · 1 line
2.25.1
PATCH 62/64 hw/rdma: Fix possible mremap overflow in the pvrdma device (CVE-2021-3582)
In reply to Michael RothFrom: Marcel Apfelbaum <[email protected]>
Ensure mremap boundaries not trusting the guest kernel to pass the correct buffer length.
Message-Id: <[email protected]>
--- hw/rdma/vmw/pvrdma_cmd.c | 7 +++++++ 1 file changed, 7 insertions(+)
hw/rdma/vmw/pvrdma_cmd.c +7 -0
@@ -38,6 +38,13 @@ static void *pvrdma_map_to_pdir(PCIDevice *pdev, uint64_t pdir_dma,return NULL ; } + length =ROUND_UP (length,TARGET_PAGE_SIZE ); +if (nchunks *TARGET_PAGE_SIZE != length) { +rdma_error_report ("Invalid nchunks/length (%u, %lu)" , nchunks, + (unsigned long )length); +return NULL ; + } + dir =rdma_pci_dma_map (pdev, pdir_dma,TARGET_PAGE_SIZE );if (!dir) {rdma_error_report ("Failed to map to page directory" );
Signature · 1 line
2.25.1
PATCH 63/64 pvrdma: Ensure correct input on ring init (CVE-2021-3607)
In reply to Michael RothFrom: Marcel Apfelbaum <[email protected]>
Check the guest passed a non zero page count
for pvrdma device ring buffers.
Message-Id: <[email protected]>
--- hw/rdma/vmw/pvrdma_main.c | 5 +++++ 1 file changed, 5 insertions(+)
hw/rdma/vmw/pvrdma_main.c +5 -0
@@ -92,6 +92,11 @@ static int init_dev_ring(PvrdmaRing *ring, PvrdmaRingState **ring_state,uint64_t *dir, *tbl;int rc =0 ; +if (!num_pages) { +rdma_error_report ("Ring pages count must be strictly positive" ); +return -EINVAL ; + } + dir =rdma_pci_dma_map (pci_dev, dir_addr,TARGET_PAGE_SIZE );if (!dir) {rdma_error_report ("Failed to map to page directory (ring %s)" , name);
Signature · 1 line
2.25.1
Quoted 6 lines · On Dienstag, 19. Oktober 2021 16:08:40 CEST Michael Roth wrote:
Hi everyone,
The following new patches are queued for QEMU stable v6.0.1:
https://gitlab.com/qemu-project/qemu/-/commits/stable-6.0-staging/
Quoted 8 lines
Patch freeze is 2021-10-26, and the release is planned for 2021-10-28:
https://wiki.qemu.org/Planning/6.0
Please respond here or CC [email protected] on any additional patches you think should (or shouldn't) be included in the release.
Thanks!
Hi Micheal,
I think the following 9p fix is yet missing:
f83df00900816476cca41bb536e4d532b297d76e 9pfs: fix crash in v9fs_walk()
Best regards,
Christian Schoenebeck
Quoted 14 lines · On Tue, 19 Oct 2021 16:52:37 +0200 Christian Schoenebeck…
Quoted 13 lines · On Dienstag, 19. Oktober 2021 16:08:40 CEST Michael Roth wrote:
Hi everyone,
The following new patches are queued for QEMU stable v6.0.1:
https://gitlab.com/qemu-project/qemu/-/commits/stable-6.0-staging/
Patch freeze is 2021-10-26, and the release is planned for 2021-10-28:
https://wiki.qemu.org/Planning/6.0
Please respond here or CC [email protected] on any additional patches you think should (or shouldn't) be included in the release.
Quoted 8 lines
Quoted 1 line
Thanks!
Hi Micheal,
I think the following 9p fix is yet missing:
f83df00900816476cca41bb536e4d532b297d76e9pfs: fix crash inv9fs_walk()
No, this commit fixes 8d6cb100731c ("9pfs: reduce latency of Twalk") which was merged in QEMU 6.1. This is a good candidate for the upcoming QEMU 6.1.1 though :-)
Quoted 4 lines
Best regards,
Christian Schoenebeck
Quoted 20 lines · On Dienstag, 19. Oktober 2021 17:26:38 CEST Greg Kurz wrote:
On Tue, 19 Oct 2021 16:52:37 +0200
Quoted 17 lines · Christian Schoenebeck
Quoted 5 lines · On Dienstag, 19. Oktober 2021 16:08:40 CEST Michael Roth wrote:
Hi everyone,
The following new patches are queued for QEMU stable v6.0.1:
https://gitlab.com/qemu-project/qemu/-/commits/stable-6.0-staging/Quoted 8 lines
Patch freeze is 2021-10-26, and the release is planned for 2021-10-28:
https://wiki.qemu.org/Planning/6.0Please respond here or CC [email protected] on any additional patches
you think should (or shouldn't) be included in the release.Thanks!
Hi Micheal,
Quoted 7 lines
Quoted 3 lines
I think the following 9p fix is yet missing:
f83df00900816476cca41bb536e4d532b297d76e9pfs: fix crash inv9fs_walk()No, this commit fixes
8d6cb100731c("9pfs: reduce latency of Twalk") which was merged in QEMU 6.1. This is a good candidate for the upcoming QEMU 6.1.1 though :-)
Aah, right! Yeah, sorry for the noise! :)
Best regards,
Christian Schoenebeck
PATCH 64/64 pvrdma: Fix the ring init error flow (CVE-2021-3608)
In reply to Michael RothFrom: Marcel Apfelbaum <[email protected]>
Do not unmap uninitialized dma addresses.
Message-Id: <[email protected]>
--- hw/rdma/vmw/pvrdma_dev_ring.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/rdma/vmw/pvrdma_dev_ring.c +1 -1
@@ -41,7 +41,7 @@ int pvrdma_ring_init(PvrdmaRing *ring, const char *name, PCIDevice *dev,qatomic_set(&ring->ring_state->cons_head, 0); */ ring->npages = npages; - ring->pages =g_malloc (npages *sizeof (void *)); + ring->pages =g_malloc0 (npages *sizeof (void *));for (i =0 ; i < npages; i++) {if (!tbl[i]) {
Signature · 1 line
2.25.1