Patch Round-up for stable 4.2.1, freeze on 2020-06-22
Subsystems (3)
cover Patch Round-up for stable 4.2.1, freeze on 2020-06-22
Hi everyone,
The following new patches are queued for QEMU stable v4.2.1:
https://github.com/mdroth/qemu/commits/stable-4.2-staging
The release is planned for 2020-06-25:
https://wiki.qemu.org/Planning/4.2
Due to delays on my part this release is going out beyond the normal ~4 month support window. v5.0.1 is scheduled to be released as normal.
Please respond here or CC [email protected] on any additional patches you think should be included in the release.
Thanks!
----------------------------------------------------------------
Alex Bennée (2):
target/arm: ensure we use current exception state after SCR update
tcg: save vaddr temp for plugin usage
Alexander Popov (2):
tests/ide-test: Create a single unit-test covering more PRDT cases
ide: Fix incorrect handling of some PRDTs in ide_dma_cb()
Anthony PERARD (1):
xen-block: Fix double qlist remove and request leak
Basil Salman (2):
qga: Installer: Wait for installation to finish
qga-win: prevent crash when executing guest-file-read with large count
Christian Borntraeger (1):
s390/sclp: improve special wait psw logic
Christophe de Dinechin (1):
scsi/qemu-pr-helper: Fix out-of-bounds access to trnptid_list[]
Cornelia Huck (1):
compat: disable edid on correct virtio-gpu device
Daniel P. Berrangé (1):
qapi: better document NVMe blockdev @device parameter
David Hildenbrand (3):
virtio-balloon: fix free page hinting without an iothread
virtio-balloon: fix free page hinting check on unrealize
virtio-balloon: unref the iothread when unrealizing
Denis Plotnikov (1):
virtio-mmio: update queue size on guest write
Eduardo Habkost (1):
i386: Resolve CPU models to v1 by default
Emilio G. Cota (1):
plugins/core: add missing break in cb_to_tcg_flags
Eric Blake (3):
qga: Fix undefined C behavior
nbd/server: Avoid long error message assertions CVE-2020-10761
block: Call attention to truncation of long NBD exports
Finn Thain (14):
dp8393x: Mask EOL bit from descriptor addresses
dp8393x: Always use 32-bit accesses
dp8393x: Clean up endianness hacks
dp8393x: Have dp8393x_receive() return the packet size
dp8393x: Update LLFA and CRDA registers from rx descriptor
dp8393x: Clear RRRA command register bit only when appropriate
dp8393x: Implement packet size limit and RBAE interrupt
dp8393x: Don't clobber packet checksum
dp8393x: Use long-word-aligned RRA pointers in 32-bit mode
dp8393x: Pad frames to word or long word boundary
dp8393x: Clear descriptor in_use field to release packet
dp8393x: Always update RRA pointers and sequence numbers
dp8393x: Don't reset Silicon Revision register
dp8393x: Don't stop reception upon RBE interrupt assertion
Greg Kurz (1):
9p: Lock directory streams with a CoMutex
Igor Mammedov (3):
numa: remove not needed check
numa: properly check if numa is supported
hostmem: don't use mbind() if host-nodes is empty
Kevin Wolf (4):
block: Activate recursively even for already active nodes
qcow2: update_refcount(): Reset old_table_index after qcow2_cache_put()
qcow2: Fix qcow2_alloc_cluster_abort() for external data file
iotests: Test copy offloading with external data file
Li Hangjing (1):
virtio-blk: fix out-of-bounds access to bitmap in notify_guest_bh
Liu Yi L (2):
intel_iommu: a fix to vtd_find_as_from_bus_num()
intel_iommu: add present bit check for pasid table entries
Max Reitz (4):
backup-top: Begin drain earlier
qcow2: Fix alloc_cluster_abort() for pre-existing clusters iotests/026: Test EIO on preallocated zero cluster iotests/026: Test EIO on allocation in a data-file
Michael S. Tsirkin (3):
virtio: update queue size on guest write
virtio: add ability to delete vq through a pointer
virtio: make virtio_delete_queue idempotent
Nicholas Piggin (1):
target/ppc: Fix mtmsr(d) L=1 variant that loses interrupts
Niek Linnenbank (2):
arm/arm-powerctl: set NSACR.{CP11, CP10} bits in arm_set_cpu_on() arm/arm-powerctl: rebuild hflags after setting CP15 bits in arm_set_cpu_on()
Pan Nengyuan (2):
block/nbd: extract the common cleanup code
block/nbd: fix memory leak in nbd_open()
Peter Maydell (2):
hw/i386/amd_iommu.c: Fix corruption of log events passed to guest
dump: Fix writing of ELF section
Peter Wu (1):
hw/i386/pc: fix regression in parsing vga cmdline parameter
Peter Xu (1):
vfio/pci: Don't remove irqchip notifier if not registered
Philippe Mathieu-Daudé (1):
vhost-user-gpu: Release memory returned by vu_queue_pop() with free()
Raphael Pour (1):
qemu-nbd: Close inherited stderr
Richard Henderson (3):
target/arm: Set ISSIs16Bit in make_issinfo tcg/i386: Fix INDEX_op_dup2_vec
target/arm: Clear tail in gvec_fmul_idx_*, gvec_fmla_idx_*
Sameeh Jubran (1):
qga-win: Handle VSS_E_PROVIDER_ALREADY_REGISTERED error
Stefan Hajnoczi (2):
virtio: gracefully handle invalid region caches
qemu-ga: document vsock-listen in the man page
Thomas Huth (1):
net: Do not include a newline in the id of -nic devices
Vitaly Chikunov (1):
target/ppc: Fix rlwinm on ppc64
Vladimir Sementsov-Ogievskiy (5):
qcow2-bitmaps: fix qcow2_can_store_new_dirty_bitmap block/qcow2-threads: fix qcow2_decompress
job: refactor progress to separate object block/block-copy: fix progress calculation block/io: fix bdrv_co_do_copy_on_readv
Yuri Benditovich (2):
virtio: reset region cache when on queue deletion
virtio-net: delete also control queue when TX/RX deleted
backends/hostmem.c | 6 +- block.c | 57 +++++------ block/backup-top.c | 4 +- block/backup.c | 13 +-- block/block-copy.c | 16 ++- block/io.c | 2 +- block/nbd.c | 48 +++++---- block/qcow2-bitmap.c | 41 ++++---- block/qcow2-cluster.c | 7 +- block/qcow2-refcount.c | 1 + block/qcow2-threads.c | 12 ++- blockjob.c | 16 +-- contrib/vhost-user-gpu/main.c | 4 +- contrib/vhost-user-gpu/virgl.c | 2 +- docs/interop/qemu-ga.rst | 5 +- dump/dump.c | 2 +- hw/9pfs/9p.h | 8 +- hw/arm/sbsa-ref.c | 1 - hw/block/dataplane/virtio-blk.c | 2 +- hw/block/dataplane/xen-block.c | 48 +++------ hw/core/machine.c | 6 +- hw/core/numa.c | 7 +- hw/i386/amd_iommu.c | 2 +- hw/i386/intel_iommu.c | 93 +++++++++++++---- hw/i386/intel_iommu_internal.h | 1 + hw/i386/x86.c | 8 +- hw/ide/core.c | 30 ++++-- hw/net/dp8393x.c | 200 ++++++++++++++++++++++++------------- hw/net/virtio-net.c | 3 +- hw/vfio/pci.c | 4 +- hw/virtio/virtio-balloon.c | 36 +++---- hw/virtio/virtio-mmio.c | 3 +- hw/virtio/virtio-pci.c | 2 + hw/virtio/virtio.c | 116 ++++++++++++++++++--- include/block/block-copy.h | 15 +-- include/hw/virtio/virtio.h | 2 + include/qemu/job.h | 11 +- include/qemu/progress_meter.h | 58 +++++++++++ job-qmp.c | 4 +- job.c | 6 +- nbd/server.c | 23 ++++- net/net.c | 2 +- plugins/core.c | 1 + qapi/block-core.json | 6 +- qemu-deprecated.texi | 8 ++ qemu-img.c | 6 +- qemu-nbd.c | 6 +- qga/commands-win32.c | 8 +- qga/commands.c | 9 +- qga/installer/qemu-ga.wxs | 2 +- qga/main.c | 4 +- qga/vss-win32/install.cpp | 11 ++ scsi/qemu-pr-helper.c | 17 ++-- target/arm/arm-powerctl.c | 6 ++ target/arm/cpu.h | 8 +- target/arm/helper.c | 14 ++- target/arm/helper.h | 1 + target/arm/translate.c | 9 +- target/arm/vec_helper.c | 2 + target/i386/cpu.c | 8 +- target/ppc/translate.c | 66 ++++++------ target/s390x/helper.c | 2 +- tcg/i386/tcg-target.inc.c | 10 +- tcg/tcg-op.c | 23 ++++- tests/ide-test.c | 174 ++++++++++++++------------------ tests/qemu-iotests/026 | 53 ++++++++++ tests/qemu-iotests/026.out | 16 +++ tests/qemu-iotests/026.out.nocache | 16 +++ tests/qemu-iotests/143 | 4 + tests/qemu-iotests/143.out | 2 + tests/qemu-iotests/244 | 14 +++ tests/qemu-iotests/244.out | 6 ++ 72 files changed, 963 insertions(+), 476 deletions(-) create mode 100644 include/qemu/progress_meter.h
PATCH 1/78 block/nbd: extract the common cleanup code
From: Pan Nengyuan <[email protected]>
The BDRVNBDState cleanup code is common in two places, add nbd_clear_bdrvstate() function to do these cleanups.
Message-Id: <[email protected]>
--- block/nbd.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-)
block/nbd.c +15 -11
@@ -94,6 +94,19 @@ typedef struct BDRVNBDState {static int nbd_client_connect (BlockDriverState *bs,Error **errp); +static void nbd_clear_bdrvstate (BDRVNBDState *s) +{ +object_unref (OBJECT (s->tlscreds)); +qapi_free_SocketAddress (s->saddr); + s->saddr =NULL ; +g_free (s->export); + s->export =NULL ; +g_free (s->tlscredsid); + s->tlscredsid =NULL ; +g_free (s->x_dirty_bitmap); + s->x_dirty_bitmap =NULL ; +} +static void nbd_channel_error (BDRVNBDState *s,int ret) {if (ret == -EIO ) {
@@ -1864,11 +1877,7 @@ static int nbd_process_options(BlockDriverState *bs, QDict *options, error:if (ret <0 ) { -object_unref (OBJECT (s->tlscreds)); -qapi_free_SocketAddress (s->saddr); -g_free (s->export); -g_free (s->tlscredsid); -g_free (s->x_dirty_bitmap); +nbd_clear_bdrvstate (s); }qemu_opts_del (opts);return ret;
@@ -1947,12 +1956,7 @@ static void nbd_close(BlockDriverState *bs)BDRVNBDState *s = bs->opaque;nbd_client_close (bs); - -object_unref (OBJECT (s->tlscreds)); -qapi_free_SocketAddress (s->saddr); -g_free (s->export); -g_free (s->tlscredsid); -g_free (s->x_dirty_bitmap); +nbd_clear_bdrvstate (s); }static int64_t nbd_getlength (BlockDriverState *bs)
Signature · 1 line
2.17.1
PATCH 2/78 block/nbd: fix memory leak in nbd_open()
In reply to Michael RothFrom: Pan Nengyuan <[email protected]>
In currently implementation there will be a memory leak when nbd_client_connect() returns error status. Here is an easy way to reproduce:
1. run qemu-iotests as follow and check the result with asan:
./check -raw 143
Following is the asan output backtrack:
Direct leak of 40 byte(s) in 1 object(s) allocated from:
#0 0x7f629688a560 in calloc (/usr/lib64/libasan.so.3+0xc7560)
#1 0x7f6295e7e015 in g_malloc0 (/usr/lib64/libglib-2.0.so.0+0x50015)
#2 0x56281dab4642 in qobject_input_start_struct /mnt/sdb/qemu-4.2.0-rc0/qapi/qobject-input-visitor.c:295
#3 0x56281dab1a04 in visit_start_struct /mnt/sdb/qemu-4.2.0-rc0/qapi/qapi-visit-core.c:49
#4 0x56281dad1827 in visit_type_SocketAddress qapi/qapi-visit-sockets.c:386
#5 0x56281da8062f in nbd_config /mnt/sdb/qemu-4.2.0-rc0/block/nbd.c:1716
#6 0x56281da8062f in nbd_process_options /mnt/sdb/qemu-4.2.0-rc0/block/nbd.c:1829
#7 0x56281da8062f in nbd_open /mnt/sdb/qemu-4.2.0-rc0/block/nbd.c:1873Direct leak of 15 byte(s) in 1 object(s) allocated from:
#0 0x7f629688a3a0 in malloc (/usr/lib64/libasan.so.3+0xc73a0)
#1 0x7f6295e7dfbd in g_malloc (/usr/lib64/libglib-2.0.so.0+0x4ffbd)
#2 0x7f6295e96ace in g_strdup (/usr/lib64/libglib-2.0.so.0+0x68ace)
#3 0x56281da804ac in nbd_process_options /mnt/sdb/qemu-4.2.0-rc0/block/nbd.c:1834
#4 0x56281da804ac in nbd_open /mnt/sdb/qemu-4.2.0-rc0/block/nbd.c:1873Indirect leak of 24 byte(s) in 1 object(s) allocated from:
#0 0x7f629688a3a0 in malloc (/usr/lib64/libasan.so.3+0xc73a0)
#1 0x7f6295e7dfbd in g_malloc (/usr/lib64/libglib-2.0.so.0+0x4ffbd)
#2 0x7f6295e96ace in g_strdup (/usr/lib64/libglib-2.0.so.0+0x68ace)
#3 0x56281dab41a3 in qobject_input_type_str_keyval /mnt/sdb/qemu-4.2.0-rc0/qapi/qobject-input-visitor.c:536
#4 0x56281dab2ee9 in visit_type_str /mnt/sdb/qemu-4.2.0-rc0/qapi/qapi-visit-core.c:297
#5 0x56281dad0fa1 in visit_type_UnixSocketAddress_members qapi/qapi-visit-sockets.c:141
#6 0x56281dad17b6 in visit_type_SocketAddress_members qapi/qapi-visit-sockets.c:366
#7 0x56281dad186a in visit_type_SocketAddress qapi/qapi-visit-sockets.c:393
#8 0x56281da8062f in nbd_config /mnt/sdb/qemu-4.2.0-rc0/block/nbd.c:1716
#9 0x56281da8062f in nbd_process_options /mnt/sdb/qemu-4.2.0-rc0/block/nbd.c:1829
#10 0x56281da8062f in nbd_open /mnt/sdb/qemu-4.2.0-rc0/block/nbd.c:1873Message-Id: <[email protected]>
--- block/nbd.c | 1 + 1 file changed, 1 insertion(+)
block/nbd.c +1 -0
@@ -1900,6 +1900,7 @@ static int nbd_open(BlockDriverState *bs, QDict *options, int flags, ret =nbd_client_connect (bs, errp);if (ret <0 ) { +nbd_clear_bdrvstate (s);return ret; }/* successfully connected */
Signature · 1 line
2.17.1
PATCH 3/78 i386: Resolve CPU models to v1 by default
In reply to Michael RothFrom: Eduardo Habkost <[email protected]>
When using query-cpu-definitions using -machine none, QEMU is resolving all CPU models to their latest versions. The actual CPU model version being used by another machine type (e.g. pc-q35-4.0) might be different.
In theory, this was OK because the correct CPU model version is returned when using the correct -machine argument.
Except that in practice, this breaks libvirt expectations:
libvirt always use -machine none when checking if a CPU model is runnable, because runnability is not expected to be affected when the machine type is changed.
For example, when running on a Haswell host without TSX, Haswell-v4 is runnable, but Haswell-v1 is not. On those hosts, query-cpu-definitions says Haswell is runnable if using -machine none, but Haswell is actually not runnable using any of the pc-* machine types (because they resolve Haswell to Haswell-v1). In other words, we're breaking the "runnability guarantee" we promised to not break for a few releases (see qemu-deprecated.texi).
To address this issue, change the default CPU model version to v1 on all machine types, so we make query-cpu-definitions output when using -machine none match the results when using pc-*. This will change in the future (the plan is to always return the latest CPU model version if using -machine none), but only after giving libvirt the opportunity to adapt.
Message-Id: <[email protected]>
--- qemu-deprecated.texi | 8 ++++++++ target/i386/cpu.c | 8 +++++++- 2 files changed, 15 insertions(+), 1 deletion(-)
qemu-deprecated.texi +8 -0
@@ -374,6 +374,14 @@ guarantees must resolve the CPU model aliases using te ``alias-of'' field returned by the ``query-cpu-definitions'' QMP command. +While those guarantees are kept, the return value of +``query-cpu-definitions'' will have existing CPU model aliases +point to a version that doesn't break runnability guarantees +(specifically, version 1 of those CPU models). In future QEMU +versions, aliases will point to newer CPU model versions +depending on the machine type, so management software must +resolve CPU model aliases before starting a virtual machine. + @node Recently removed features @appendix Recently removed features
target/i386/cpu.c +7 -1
@@ -3924,7 +3924,13 @@ static PropValue tcg_default_props[] = { }; -X86CPUVersion default_cpu_version =CPU_VERSION_LATEST ; +/* +* We resolve CPU model aliases using -v1 when using "-machine +* none", but this is just for compatibility while libvirt isn't +* adapted to resolve CPU model versions before creating VMs. +* See "Runnability guarantee of CPU models" at * qemu-deprecated.texi. +*/ +X86CPUVersion default_cpu_version =1 ;void x86_cpu_set_default_version (X86CPUVersion version) {
Signature · 1 line
2.17.1
PATCH 4/78 qapi: better document NVMe blockdev @device parameter
In reply to Michael RothFrom: Daniel P. Berrangé <[email protected]>
Mention that this is a PCI device address & give the format it is expected in. Also mention that it must be first unbound from any host kernel driver.
--- qapi/block-core.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
qapi/block-core.json +5 -1
@@ -2963,9 +2963,13 @@ # # Driver specific block device options for the NVMe backend. # -# @device: controller address of the NVMe device. +# @device: PCI controller address of the NVMe device in +# format hhhh:bb:ss.f (host:bus:slot.function) # @namespace: namespace number of the device, starting from 1. # +# Note that the PCI @device must have been unbound from any host +# kernel driver before instructing QEMU to add the blockdev. +# # Since: 2.12 ## { 'struct': 'BlockdevOptionsNVMe',
Signature · 1 line
2.17.1
PATCH 5/78 target/arm: ensure we use current exception state after SCR update
In reply to Michael RothFrom: Alex Bennée <[email protected]>
A write to the SCR can change the effective EL by droppping the system from secure to non-secure mode. However if we use a cached current_el from before the change we'll rebuild the flags incorrectly. To fix this we introduce the ARM_CP_NEWEL CP flag to indicate the new EL should be used when recomputing the flags.
Message-id: [email protected]
Cc: Richard Henderson <[email protected]>
Message-Id: <[email protected]>
--- target/arm/cpu.h | 8 ++++++-- target/arm/helper.c | 14 +++++++++++++- target/arm/helper.h | 1 + target/arm/translate.c | 6 +++++- 4 files changed, 25 insertions(+), 4 deletions(-)
target/arm/cpu.h +6 -2
@@ -2238,6 +2238,9 @@ static inline uint64_t cpreg_to_kvm_id(uint32_t cpregid)* RAISES_EXC is for when the read or write hook might raise an exception; * the generated code will synchronize the CPU state before calling the hook * so that it is safe for the hook to call raise_exception(). +* NEWEL is for writes to registers that might change the exception +* level - typically on older ARM chips. For those cases we need to +* re-read the new el when recomputing the translation flags. */ #define ARM_CP_SPECIAL 0x0001#define ARM_CP_CONST 0x0002
@@ -2257,10 +2260,11 @@ static inline uint64_t cpreg_to_kvm_id(uint32_t cpregid)#define ARM_CP_SVE 0x2000#define ARM_CP_NO_GDB 0x4000#define ARM_CP_RAISES_EXC 0x8000 +#define ARM_CP_NEWEL 0x10000/* Used only as a terminator for ARMCPRegInfo lists */ -#define ARM_CP_SENTINEL 0xffff +#define ARM_CP_SENTINEL 0xfffff/* Mask of only the flag bits in a type field */ -#define ARM_CP_FLAG_MASK 0xf0ff +#define ARM_CP_FLAG_MASK 0x1f0ff/* Valid values for ARMCPRegInfo state field, indicating which of * the AArch32 and AArch64 execution states this register is visible in.
target/arm/helper.c +13 -1
@@ -5096,7 +5096,7 @@ static const ARMCPRegInfo el3_cp_reginfo[] = { .opc0 = 3, .opc1 = 6, .crn = 1, .crm = 1, .opc2 = 0, .access = PL3_RW, .fieldoffset = offsetof(CPUARMState, cp15.scr_el3), .resetvalue = 0, .writefn = scr_write }, - { .name = "SCR", .type = ARM_CP_ALIAS, + { .name = "SCR", .type = ARM_CP_ALIAS | ARM_CP_NEWEL, .cp = 15, .opc1 = 0, .crn = 1, .crm = 1, .opc2 = 0, .access = PL1_RW, .accessfn = access_trap_aa32s_el1, .fieldoffset = offsetoflow32(CPUARMState, cp15.scr_el3),
@@ -11332,6 +11332,18 @@ void HELPER(rebuild_hflags_m32)(CPUARMState *env, int el) env->hflags =rebuild_hflags_m32 (env, fp_el, mmu_idx); } +/* +* If we have triggered a EL state change we can't rely on the +* translator having passed it too us, we need to recompute. +*/ +void HELPER (rebuild_hflags_a32_newel )(CPUARMState *env) +{ +int el =arm_current_el (env); +int fp_el =fp_exception_el (env, el); +ARMMMUIdx mmu_idx =arm_mmu_idx_el (env, el); + env->hflags =rebuild_hflags_a32 (env, fp_el, mmu_idx); +} +void HELPER (rebuild_hflags_a32 )(CPUARMState *env,int el) {int fp_el =fp_exception_el (env, el);
target/arm/helper.h +1 -0
@@ -91,6 +91,7 @@ DEF_HELPER_2(get_user_reg, i32, env, i32) DEF_HELPER_3(set_user_reg, void, env, i32, i32) DEF_HELPER_FLAGS_2(rebuild_hflags_m32, TCG_CALL_NO_RWG, void, env, int) +DEF_HELPER_FLAGS_1(rebuild_hflags_a32_newel, TCG_CALL_NO_RWG, void, env) DEF_HELPER_FLAGS_2(rebuild_hflags_a32, TCG_CALL_NO_RWG, void, env, int)DEF_HELPER_FLAGS_2 (rebuild_hflags_a64,TCG_CALL_NO_RWG , void, env, int)
target/arm/translate.c +5 -1
@@ -7083,7 +7083,11 @@ static int disas_coproc_insn(DisasContext *s, uint32_t insn)if (arm_dc_feature (s,ARM_FEATURE_M )) {gen_helper_rebuild_hflags_m32 (cpu_env, tcg_el); }else { -gen_helper_rebuild_hflags_a32 (cpu_env, tcg_el); +if (ri->type &ARM_CP_NEWEL ) { +gen_helper_rebuild_hflags_a32_newel (cpu_env); + }else { +gen_helper_rebuild_hflags_a32 (cpu_env, tcg_el); + } }tcg_temp_free_i32 (tcg_el);/*
Signature · 1 line
2.17.1
PATCH 6/78 block: Activate recursively even for already active nodes
In reply to Michael RothFrom: Kevin Wolf <[email protected]>
bdrv_invalidate_cache_all() assumes that all nodes in a given subtree are either active or inactive when it starts. Therefore, as soon as it arrives at an already active node, it stops.
However, this assumption is wrong. For example, it's possible to take a snapshot of an inactive node, which results in an active overlay over an inactive backing file. The active overlay is probably also the root node of an inactive BlockBackend (blk->disable_perm == true).
In this case, bdrv_invalidate_cache_all() does not need to do anything to activate the overlay node, but it still needs to recurse into the children and the parents to make sure that after returning success, really everything is activated.
--- block.c | 50 ++++++++++++++++++++++++-------------------------- 1 file changed, 24 insertions(+), 26 deletions(-)
block.c +24 -26
@@ -5335,10 +5335,6 @@ static void coroutine_fn bdrv_co_invalidate_cache(BlockDriverState *bs,return ; } -if (!(bs->open_flags &BDRV_O_INACTIVE )) { -return ; - } - QLIST_FOREACH(child, &bs->children, next) {bdrv_co_invalidate_cache (child->bs, &local_err);if (local_err) {
@@ -5360,34 +5356,36 @@ static void coroutine_fn bdrv_co_invalidate_cache(BlockDriverState *bs,* just keep the extended permissions for the next time that an activation * of the image is tried. */ - bs->open_flags &= ~BDRV_O_INACTIVE ; -bdrv_get_cumulative_perm (bs, &perm, &shared_perm); - ret =bdrv_check_perm (bs,NULL , perm, shared_perm,NULL ,NULL , &local_err); -if (ret <0 ) { - bs->open_flags |=BDRV_O_INACTIVE ; -error_propagate (errp, local_err); -return ; - } -bdrv_set_perm (bs, perm, shared_perm); - -if (bs->drv->bdrv_co_invalidate_cache) { - bs->drv->bdrv_co_invalidate_cache (bs, &local_err); -if (local_err) { +if (bs->open_flags &BDRV_O_INACTIVE ) { + bs->open_flags &= ~BDRV_O_INACTIVE ; +bdrv_get_cumulative_perm (bs, &perm, &shared_perm); + ret =bdrv_check_perm (bs,NULL , perm, shared_perm,NULL ,NULL , &local_err); +if (ret <0 ) { bs->open_flags |=BDRV_O_INACTIVE ;error_propagate (errp, local_err);return ; } - } +bdrv_set_perm (bs, perm, shared_perm); - FOR_EACH_DIRTY_BITMAP(bs, bm) { -bdrv_dirty_bitmap_skip_store (bm, false); - } +if (bs->drv->bdrv_co_invalidate_cache) { + bs->drv->bdrv_co_invalidate_cache (bs, &local_err); +if (local_err) { + bs->open_flags |=BDRV_O_INACTIVE ; +error_propagate (errp, local_err); +return ; + } + } - ret =refresh_total_sectors (bs, bs->total_sectors); -if (ret <0 ) { - bs->open_flags |=BDRV_O_INACTIVE ; -error_setg_errno (errp, -ret,"Could not refresh total sector count" ); -return ; + FOR_EACH_DIRTY_BITMAP(bs, bm) { +bdrv_dirty_bitmap_skip_store (bm, false); + } + + ret =refresh_total_sectors (bs, bs->total_sectors); +if (ret <0 ) { + bs->open_flags |=BDRV_O_INACTIVE ; +error_setg_errno (errp, -ret,"Could not refresh total sector count" ); +return ; + } } QLIST_FOREACH(parent, &bs->parents, next_parent) {
Signature · 1 line
2.17.1
PATCH 7/78 virtio-blk: fix out-of-bounds access to bitmap in notify_guest_bh
In reply to Michael RothFrom: Li Hangjing <[email protected]>
When the number of a virtio-blk device's virtqueues is larger than BITS_PER_LONG, the out-of-bounds access to bitmap[ ] will occur.
Message-id: [email protected]
Message-Id: <[email protected]>
--- hw/block/dataplane/virtio-blk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/block/dataplane/virtio-blk.c +1 -1
@@ -67,7 +67,7 @@ static void notify_guest_bh(void *opaque)memset (s->batch_notify_vqs,0 ,sizeof (bitmap));for (j =0 ; j < nvqs; j +=BITS_PER_LONG ) { -unsigned long bits = bitmap[j]; +unsigned long bits = bitmap[j /BITS_PER_LONG ];while (bits !=0 ) {unsigned i = j +ctzl (bits);
Signature · 1 line
2.17.1
PATCH 8/78 numa: remove not needed check
In reply to Michael RothFrom: Igor Mammedov <[email protected]>
Currently parse_numa_node() is always called from already numa enabled context.
Drop unnecessary check if numa is supported.
Message-Id: <[email protected]>
--- hw/core/numa.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
hw/core/numa.c +1 -6
@@ -83,10 +83,6 @@ static void parse_numa_node(MachineState *ms, NumaNodeOptions *node,return ; } -if (!mc->cpu_index_to_instance_props || !mc->get_default_cpu_node_id) { -error_setg (errp,"NUMA is not supported by this machine-type" ); -return ; - }for (cpus = node->cpus; cpus; cpus = cpus->next) {CpuInstanceProperties props;if (cpus->value >= max_cpus) {
@@ -178,9 +174,8 @@ void parse_numa_distance(MachineState *ms, NumaDistOptions *dist, Error **errp)void set_numa_options (MachineState *ms,NumaOptions *object,Error **errp) {Error *err =NULL ; -MachineClass *mc =MACHINE_GET_CLASS (ms); -if (!mc->numa_mem_supported) { +if (!ms->numa_state) {error_setg (errp,"NUMA is not supported by this machine-type" ); goto end; }
Signature · 1 line
2.17.1
PATCH 9/78 numa: properly check if numa is supported
In reply to Michael RothFrom: Igor Mammedov <[email protected]>
Commit aa57020774b, by mistake used MachineClass::numa_mem_supported to check if NUMA is supported by machine and also as unrelated change set it to true for sbsa-ref board.
Luckily change didn't break machines that support NUMA, as the field is set to true for them.
But the field is not intended for checking if NUMA is supported and will be flipped to false within this release for new machine types.
Fix it:
- by using previously used condition
!mc->cpu_index_to_instance_props || !mc->get_default_cpu_node_id
the first time and then use MachineState::numa_state down the road to check if NUMA is supported
- dropping stray sbsa-ref chunk
Message-Id: <[email protected]>
--- hw/arm/sbsa-ref.c | 1 - hw/core/machine.c | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-)
hw/arm/sbsa-ref.c +0 -1
@@ -791,7 +791,6 @@ static void sbsa_ref_class_init(ObjectClass *oc, void *data) mc->possible_cpu_arch_ids = sbsa_ref_possible_cpu_arch_ids; mc->cpu_index_to_instance_props = sbsa_ref_cpu_index_to_props; mc->get_default_cpu_node_id = sbsa_ref_get_default_cpu_node_id; - mc->numa_mem_supported = true; }static const TypeInfo sbsa_ref_info = {
hw/core/machine.c +2 -2
@@ -958,7 +958,7 @@ static void machine_initfn(Object *obj) NULL); } -if (mc->numa_mem_supported) { +if (mc->cpu_index_to_instance_props && mc->get_default_cpu_node_id) { ms->numa_state =g_new0 (NumaState,1 ); }
@@ -1102,7 +1102,7 @@ void machine_run_board_init(MachineState *machine) {MachineClass *machine_class =MACHINE_GET_CLASS (machine); -if (machine_class->numa_mem_supported) { +if (machine->numa_state) {numa_complete_configuration (machine);if (machine->numa_state->num_nodes) {machine_numa_finish_cpu_init (machine);
Signature · 1 line
2.17.1
PATCH 10/78 backup-top: Begin drain earlier
In reply to Michael RothFrom: Max Reitz <[email protected]>
When dropping backup-top, we need to drain the node before freeing the BlockCopyState. Otherwise, requests may still be in flight and then the assertion in shres_destroy() will fail.
(This becomes visible in intermittent failure of 056.)
Message-id: [email protected]
--- block/backup-top.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
block/backup-top.c +2 -2
@@ -257,12 +257,12 @@ void bdrv_backup_top_drop(BlockDriverState *bs)BDRVBackupTopState *s = bs->opaque;AioContext *aio_context =bdrv_get_aio_context (bs); -block_copy_state_free (s->bcs); -aio_context_acquire (aio_context);bdrv_drained_begin (bs); +block_copy_state_free (s->bcs); + s->active = false;bdrv_child_refresh_perms (bs, bs->backing, &error_abort);bdrv_replace_node (bs,backing_bs (bs), &error_abort);
Signature · 1 line
2.17.1
PATCH 11/78 arm/arm-powerctl: set NSACR.{CP11, CP10} bits in arm_set_cpu_on()
In reply to Michael RothFrom: Niek Linnenbank <[email protected]>
This change ensures that the FPU can be accessed in Non-Secure mode when the CPU core is reset using the arm_set_cpu_on() function call. The NSACR.{CP11,CP10} bits define the exception level required to access the FPU in Non-Secure mode. Without these bits set, the CPU will give an undefined exception trap on the first FPU access for the secondary cores under Linux.
This is necessary because in this power-control codepath QEMU is effectively emulating a bit of EL3 firmware, and has to set the CPU up as the EL3 firmware would.
--- target/arm/arm-powerctl.c | 3 +++ 1 file changed, 3 insertions(+)
target/arm/arm-powerctl.c +3 -0
@@ -104,6 +104,9 @@ static void arm_set_cpu_on_async_work(CPUState *target_cpu_state,/* Processor is not in secure mode */ target_cpu->env.cp15.scr_el3 |=SCR_NS ; +/* Set NSACR.{CP11,CP10} so NS can access the FPU */ + target_cpu->env.cp15.nsacr |=3 <<10 ; +/* * If QEMU is providing the equivalent of EL3 firmware, then we need * to make sure a CPU targeting EL2 comes out of reset with a
Signature · 1 line
2.17.1
PATCH 12/78 arm/arm-powerctl: rebuild hflags after setting CP15 bits in arm_set_cpu_on()
In reply to Michael RothFrom: Niek Linnenbank <[email protected]>
After setting CP15 bits in arm_set_cpu_on() the cached hflags must be rebuild to reflect the changed processor state. Without rebuilding, the cached hflags would be inconsistent until the next call to arm_rebuild_hflags(). When QEMU is compiled with debugging enabled (--enable-debug), this problem is captured shortly after the first call to arm_set_cpu_on() for CPUs running in ARM 32-bit non-secure mode:
qemu-system-arm: target/arm/helper.c:11359: cpu_get_tb_cpu_state:
Assertion `flags == rebuild_hflags_internal(env)' failed. Aborted (core dumped)
--- target/arm/arm-powerctl.c | 3 +++ 1 file changed, 3 insertions(+)
target/arm/arm-powerctl.c +3 -0
@@ -127,6 +127,9 @@ static void arm_set_cpu_on_async_work(CPUState *target_cpu_state, target_cpu->env.regs[0 ] = info->context_id; } +/* CP15 update requires rebuilding hflags */ +arm_rebuild_hflags (&target_cpu->env); +/* Start the new CPU at the requested address */ cpu_set_pc (target_cpu_state, info->entry);
Signature · 1 line
2.17.1
PATCH 13/78 hw/i386/pc: fix regression in parsing vga cmdline parameter
In reply to Michael RothFrom: Peter Wu <[email protected]>
When the 'vga=' parameter is succeeded by another parameter, QEMU 4.2.0 would refuse to start with a rather cryptic message:
$ qemu-system-x86_64 -kernel /boot/vmlinuz-linux -append 'vga=792 quiet'
qemu: can't parse 'vga' parameter: Invalid argumentIt was not clear whether this applied to the '-vga std' parameter or the '-append' one. Fix the parsing regression and clarify the error.
Message-Id: <[email protected]>
--- hw/i386/x86.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
hw/i386/x86.c +4 -4
@@ -508,6 +508,7 @@ void x86_load_linux(X86MachineState *x86ms, vmode =strstr (kernel_cmdline,"vga=" );if (vmode) {unsigned int video_mode; +const char *end;int ret;/* skip "vga=" */ vmode +=4 ;
@@ -518,10 +519,9 @@ void x86_load_linux(X86MachineState *x86ms, }else if (!strncmp (vmode,"ask" ,3 )) { video_mode =0xfffd ; }else { - ret =qemu_strtoui (vmode,NULL ,0 , &video_mode); -if (ret !=0 ) { -fprintf (stderr,"qemu: can't parse 'vga' parameter: %s\n" , -strerror (-ret)); + ret =qemu_strtoui (vmode, &end,0 , &video_mode); +if (ret !=0 || (*end && *end !=' ' )) { +fprintf (stderr,"qemu: invalid 'vga=' kernel parameter.\n" );exit (1 ); } }
Signature · 1 line
2.17.1
PATCH 14/78 tests/ide-test: Create a single unit-test covering more PRDT cases
In reply to Michael RothFrom: Alexander Popov <[email protected]>
Fuzzing the Linux kernel with syzkaller allowed to find how to crash qemu using a special SCSI_IOCTL_SEND_COMMAND. It hits the assertion in ide_dma_cb() introduced in the commit a718978ed58a in July 2015. Currently this bug is not reproduced by the unit tests.
Let's improve the ide-test to cover more PRDT cases including one that causes this particular qemu crash.
The test is developed according to the Programming Interface for Bus Master IDE Controller (Revision 1.0 5/16/94).
Message-id: [email protected]
--- tests/ide-test.c | 174 ++++++++++++++++++++--------------------------- 1 file changed, 74 insertions(+), 100 deletions(-)
tests/ide-test.c +74 -100
@@ -445,104 +445,81 @@ static void test_bmdma_trim(void)test_bmdma_teardown (qts); } -static void test_bmdma_short_prdt (void ) -{ -QTestState *qts; -QPCIDevice *dev; -QPCIBar bmdma_bar, ide_bar; -uint8_t status; - -PrdtEntry prdt[] = { - { - .addr =0 , - .size =cpu_to_le32 (0x10 |PRDT_EOT ), - }, - }; - - qts =test_bmdma_setup (); - - dev =get_pci_device (qts, &bmdma_bar, &ide_bar); - -/* Normal request */ - status =send_dma_request (qts,CMD_READ_DMA ,0 ,1 , - prdt,ARRAY_SIZE (prdt),NULL ); - g_assert_cmphex(status, ==, 0); -assert_bit_clear (qpci_io_readb (dev, ide_bar, reg_status),DF |ERR ); - -/* Abort the request before it completes */ - status =send_dma_request (qts,CMD_READ_DMA |CMDF_ABORT ,0 ,1 , - prdt,ARRAY_SIZE (prdt),NULL ); - g_assert_cmphex(status, ==, 0); -assert_bit_clear (qpci_io_readb (dev, ide_bar, reg_status),DF |ERR ); -free_pci_device (dev); -test_bmdma_teardown (qts); -} - -static void test_bmdma_one_sector_short_prdt (void ) -{ -QTestState *qts; -QPCIDevice *dev; -QPCIBar bmdma_bar, ide_bar; -uint8_t status; - -/* Read 2 sectors but only give 1 sector in PRDT */ -PrdtEntry prdt[] = { - { - .addr =0 , - .size =cpu_to_le32 (0x200 |PRDT_EOT ), - }, - }; - - qts =test_bmdma_setup (); - - dev =get_pci_device (qts, &bmdma_bar, &ide_bar); - -/* Normal request */ - status =send_dma_request (qts,CMD_READ_DMA ,0 ,2 , - prdt,ARRAY_SIZE (prdt),NULL ); - g_assert_cmphex(status, ==, 0); -assert_bit_clear (qpci_io_readb (dev, ide_bar, reg_status),DF |ERR ); - -/* Abort the request before it completes */ - status =send_dma_request (qts,CMD_READ_DMA |CMDF_ABORT ,0 ,2 , - prdt,ARRAY_SIZE (prdt),NULL ); - g_assert_cmphex(status, ==, 0); -assert_bit_clear (qpci_io_readb (dev, ide_bar, reg_status),DF |ERR ); -free_pci_device (dev); -test_bmdma_teardown (qts); -} - -static void test_bmdma_long_prdt (void ) +/* +* This test is developed according to the Programming Interface for +* Bus Master IDE Controller (Revision 1.0 5/16/94) +*/ +static void test_bmdma_various_prdts (void ) { -QTestState *qts; -QPCIDevice *dev; -QPCIBar bmdma_bar, ide_bar; -uint8_t status; - -PrdtEntry prdt[] = { - { - .addr =0 , - .size =cpu_to_le32 (0x1000 |PRDT_EOT ), - }, - }; - - qts =test_bmdma_setup (); - - dev =get_pci_device (qts, &bmdma_bar, &ide_bar); - -/* Normal request */ - status =send_dma_request (qts,CMD_READ_DMA ,0 ,1 , - prdt,ARRAY_SIZE (prdt),NULL ); - g_assert_cmphex(status, ==, BM_STS_ACTIVE | BM_STS_INTR); -assert_bit_clear (qpci_io_readb (dev, ide_bar, reg_status),DF |ERR ); +int sectors =0 ; +uint32_t size =0 ; + +for (sectors =1 ; sectors <=256 ; sectors *=2 ) { +QTestState *qts =NULL ; +QPCIDevice *dev =NULL ; +QPCIBar bmdma_bar, ide_bar; + + qts =test_bmdma_setup (); + dev =get_pci_device (qts, &bmdma_bar, &ide_bar); + +for (size =0 ; size <65536 ; size +=256 ) { +uint32_t req_size = sectors *512 ; +uint32_t prd_size = size &0xfffe ;/* bit 0 is always set to 0 */ +uint8_t ret =0 ; +uint8_t req_status =0 ; +uint8_t abort_req_status =0 ; +PrdtEntry prdt[] = { + { + .addr =0 , + .size =cpu_to_le32 (size |PRDT_EOT ), + }, + }; + +/* A value of zero in PRD size indicates 64K */ +if (prd_size ==0 ) { + prd_size =65536 ; + } + +/* +* 1. If PRDs specified a smaller size than the IDE transfer +* size, then the Interrupt and Active bits in the Controller +* status register are not set (Error Condition). +* +* 2. If the size of the physical memory regions was equal to +* the IDE device transfer size, the Interrupt bit in the +* Controller status register is set to 1, Active bit is set to 0. +* +* 3. If PRDs specified a larger size than the IDE transfer size, +* the Interrupt and Active bits in the Controller status register +* are both set to 1. +*/ +if (prd_size < req_size) { + req_status =0 ; + abort_req_status =0 ; + }else if (prd_size == req_size) { + req_status =BM_STS_INTR ; + abort_req_status =BM_STS_INTR ; + }else { + req_status =BM_STS_ACTIVE |BM_STS_INTR ; + abort_req_status =BM_STS_INTR ; + } + +/* Test the request */ + ret =send_dma_request (qts,CMD_READ_DMA ,0 , sectors, + prdt,ARRAY_SIZE (prdt),NULL ); + g_assert_cmphex(ret, ==, req_status); +assert_bit_clear (qpci_io_readb (dev, ide_bar, reg_status),DF |ERR ); + +/* Now test aborting the same request */ + ret =send_dma_request (qts,CMD_READ_DMA |CMDF_ABORT ,0 , + sectors, prdt,ARRAY_SIZE (prdt),NULL ); + g_assert_cmphex(ret, ==, abort_req_status); +assert_bit_clear (qpci_io_readb (dev, ide_bar, reg_status),DF |ERR ); + } -/* Abort the request before it completes */ - status =send_dma_request (qts,CMD_READ_DMA |CMDF_ABORT ,0 ,1 , - prdt,ARRAY_SIZE (prdt),NULL ); - g_assert_cmphex(status, ==, BM_STS_INTR); -assert_bit_clear (qpci_io_readb (dev, ide_bar, reg_status),DF |ERR ); -free_pci_device (dev); -test_bmdma_teardown (qts); +free_pci_device (dev); +test_bmdma_teardown (qts); + } }static void test_bmdma_no_busmaster (void )
@@ -1066,10 +1043,7 @@ int main(int argc, char **argv)qtest_add_func ("/ide/bmdma/simple_rw" , test_bmdma_simple_rw);qtest_add_func ("/ide/bmdma/trim" , test_bmdma_trim); -qtest_add_func ("/ide/bmdma/short_prdt" , test_bmdma_short_prdt); -qtest_add_func ("/ide/bmdma/one_sector_short_prdt" , - test_bmdma_one_sector_short_prdt); -qtest_add_func ("/ide/bmdma/long_prdt" , test_bmdma_long_prdt); +qtest_add_func ("/ide/bmdma/various_prdts" , test_bmdma_various_prdts);qtest_add_func ("/ide/bmdma/no_busmaster" , test_bmdma_no_busmaster);qtest_add_func ("/ide/flush" , test_flush);
Signature · 1 line
2.17.1
PATCH 15/78 ide: Fix incorrect handling of some PRDTs in ide_dma_cb()
In reply to Michael RothFrom: Alexander Popov <[email protected]>
The commit a718978ed58a from July 2015 introduced the assertion which implies that the size of successful DMA transfers handled in ide_dma_cb() should be multiple of 512 (the size of a sector). But guest systems can initiate DMA transfers that don't fit this requirement.
For fixing that let's check the number of bytes prepared for the transfer by the prepare_buf() handler. The code in ide_dma_cb() must behave according to the Programming Interface for Bus Master IDE Controller (Revision 1.0 5/16/94):
1. If PRDs specified a smaller size than the IDE transfer size, then the Interrupt and Active bits in the Controller status register are not set (Error Condition).
2. If the size of the physical memory regions was equal to the IDE device transfer size, the Interrupt bit in the Controller status register is set to 1, Active bit is set to 0.
3. If PRDs specified a larger size than the IDE transfer size, the Interrupt and Active bits in the Controller status register are both set to 1.
Message-id: [email protected]
--- hw/ide/core.c | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-)
hw/ide/core.c +22 -8
@@ -849,6 +849,7 @@ static void ide_dma_cb(void *opaque, int ret)int64_t sector_num;uint64_t offset;bool stay_active = false; +int32_t prep_size =0 ;if (ret == -EINVAL ) {ide_dma_error (s);
@@ -863,13 +864,15 @@ static void ide_dma_cb(void *opaque, int ret) } } - n = s->io_buffer_size >>9 ; -if (n > s->nsector) { -/* The PRDs were longer than needed for this request. Shorten them so -* we don't get a negative remainder. The Active bit must remain set -* after the request completes. */ +if (s->io_buffer_size > s->nsector *512 ) { +/* +* The PRDs were longer than needed for this request. +* The Active bit must remain set after the request completes. +*/ n = s->nsector; stay_active = true; + }else { + n = s->io_buffer_size >>9 ; } sector_num =ide_get_sector (s);
@@ -892,9 +895,20 @@ static void ide_dma_cb(void *opaque, int ret) n = s->nsector; s->io_buffer_index =0 ; s->io_buffer_size = n *512 ; -if (s->bus->dma->ops->prepare_buf (s->bus->dma, s->io_buffer_size) <512 ) { -/* The PRDs were too short. Reset the Active bit, but don't raise an -* interrupt. */ + prep_size = s->bus->dma->ops->prepare_buf (s->bus->dma, s->io_buffer_size); +/* prepare_buf() must succeed and respect the limit */ +assert (prep_size >=0 && prep_size <= n *512 ); + +/* +* Now prep_size stores the number of bytes in the sglist, and +* s->io_buffer_size stores the number of bytes described by the PRDs. +*/ + +if (prep_size < n *512 ) { +/* +* The PRDs are too short for this request. Error condition! +* Reset the Active bit and don't raise the interrupt. +*/ s->status =READY_STAT |SEEK_STAT ;dma_buf_commit (s,0 ); goto eot;
Signature · 1 line
2.17.1
PATCH 16/78 target/arm: Set ISSIs16Bit in make_issinfo
In reply to Michael RothFrom: Richard Henderson <[email protected]>
During the conversion to decodetree, the setting of ISSIs16Bit got lost. This causes the guest os to incorrectly adjust trapping memory operations.
Message-id: [email protected]
--- target/arm/translate.c | 3 +++ 1 file changed, 3 insertions(+)
target/arm/translate.c +3 -0
@@ -8556,6 +8556,9 @@ static ISSInfo make_issinfo(DisasContext *s, int rd, bool p, bool w)/* ISS not valid if writeback */ if (p && !w) { ret = rd; +if (s->base.pc_next - s->pc_curr ==2 ) { + ret |= ISSIs16Bit; + } }else { ret = ISSInvalid; }
Signature · 1 line
2.17.1
PATCH 17/78 virtio: update queue size on guest write
In reply to Michael RothFrom: "Michael S. Tsirkin" <[email protected]>
Some guests read back queue size after writing it. Update the size immediatly upon write otherwise they get confused.
In particular this is the case for seabios.
--- hw/virtio/virtio-pci.c | 2 ++ 1 file changed, 2 insertions(+)
hw/virtio/virtio-pci.c +2 -0
@@ -1256,6 +1256,8 @@ static void virtio_pci_common_write(void *opaque, hwaddr addr,break ;case VIRTIO_PCI_COMMON_Q_SIZE : proxy->vqs[vdev->queue_sel].num = val; +virtio_queue_set_num (vdev, vdev->queue_sel, + proxy->vqs[vdev->queue_sel].num);break ;case VIRTIO_PCI_COMMON_Q_MSIX : msix_vector_unuse(&proxy->pci_dev,
Signature · 1 line
2.17.1
PATCH 18/78 virtio-mmio: update queue size on guest write
In reply to Michael RothFrom: Denis Plotnikov <[email protected]>
Some guests read back queue size after writing it. Always update the on size write otherwise they might be confused.
Message-Id: <[email protected]>
--- hw/virtio/virtio-mmio.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
hw/virtio/virtio-mmio.c +2 -1
@@ -295,8 +295,9 @@ static void virtio_mmio_write(void *opaque, hwaddr offset, uint64_t value,break ;case VIRTIO_MMIO_QUEUE_NUM :trace_virtio_mmio_queue_write (value,VIRTQUEUE_MAX_SIZE ); +virtio_queue_set_num (vdev, vdev->queue_sel, value); +if (proxy->legacy) { -virtio_queue_set_num (vdev, vdev->queue_sel, value);virtio_queue_update_rings (vdev, vdev->queue_sel); }else { proxy->vqs[vdev->queue_sel].num = value;
Signature · 1 line
2.17.1
PATCH 19/78 virtio: add ability to delete vq through a pointer
In reply to Michael RothFrom: "Michael S. Tsirkin" <[email protected]>
Devices tend to maintain vq pointers, allow deleting them trough a vq pointer.
*prereq for 421afd2fe8
--- hw/virtio/virtio.c | 15 ++++++++++----- include/hw/virtio/virtio.h | 2 ++ 2 files changed, 12 insertions(+), 5 deletions(-)
hw/virtio/virtio.c +10 -5
@@ -2330,17 +2330,22 @@ VirtQueue *virtio_add_queue(VirtIODevice *vdev, int queue_size,return &vdev->vq[i]; } +void virtio_delete_queue (VirtQueue *vq) +{ + vq->vring.num =0 ; + vq->vring.num_default =0 ; + vq->handle_output =NULL ; + vq->handle_aio_output =NULL ; +g_free (vq->used_elems); +} +void virtio_del_queue (VirtIODevice *vdev,int n) {if (n <0 || n >=VIRTIO_QUEUE_MAX ) {abort (); } - vdev->vq[n].vring.num =0 ; - vdev->vq[n].vring.num_default =0 ; - vdev->vq[n].handle_output =NULL ; - vdev->vq[n].handle_aio_output =NULL ; -g_free (vdev->vq[n].used_elems); +virtio_delete_queue (&vdev->vq[n]); }static void virtio_set_isr (VirtIODevice *vdev,int value)
include/hw/virtio/virtio.h +2 -0
@@ -183,6 +183,8 @@ VirtQueue *virtio_add_queue(VirtIODevice *vdev, int queue_size,void virtio_del_queue (VirtIODevice *vdev,int n); +void virtio_delete_queue (VirtQueue *vq); +void virtqueue_push (VirtQueue *vq,const VirtQueueElement *elem,unsigned int len);void virtqueue_flush (VirtQueue *vq,unsigned int count);
Signature · 1 line
2.17.1
PATCH 20/78 virtio: make virtio_delete_queue idempotent
In reply to Michael RothFrom: "Michael S. Tsirkin" <[email protected]>
Let's make sure calling this twice is harmless - no known instances, but seems safer.
*prereq for 421afd2fe8
--- hw/virtio/virtio.c | 1 + 1 file changed, 1 insertion(+)
hw/virtio/virtio.c +1 -0
@@ -2337,6 +2337,7 @@ void virtio_delete_queue(VirtQueue *vq) vq->handle_output =NULL ; vq->handle_aio_output =NULL ;g_free (vq->used_elems); + vq->used_elems =NULL ; }void virtio_del_queue (VirtIODevice *vdev,int n)
Signature · 1 line
2.17.1
PATCH 21/78 virtio: reset region cache when on queue deletion
In reply to Michael RothFrom: Yuri Benditovich <[email protected]>
https://bugzilla.redhat.com/show_bug.cgi?id=1708480
Fix leak of region reference that prevents complete device deletion on hot unplug.
Message-Id: <[email protected]>
--- hw/virtio/virtio.c | 1 + 1 file changed, 1 insertion(+)
hw/virtio/virtio.c +1 -0
@@ -2338,6 +2338,7 @@ void virtio_delete_queue(VirtQueue *vq) vq->handle_aio_output =NULL ;g_free (vq->used_elems); vq->used_elems =NULL ; +virtio_virtqueue_reset_region_cache (vq); }void virtio_del_queue (VirtIODevice *vdev,int n)
Signature · 1 line
2.17.1
PATCH 22/78 virtio-net: delete also control queue when TX/RX deleted
In reply to Michael RothFrom: Yuri Benditovich <[email protected]>
https://bugzilla.redhat.com/show_bug.cgi?id=1708480
If the control queue is not deleted together with TX/RX, it later will be ignored in freeing cache resources and hot unplug will not be completed.
Message-Id: <[email protected]>
--- hw/net/virtio-net.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
hw/net/virtio-net.c +2 -1
@@ -3101,7 +3101,8 @@ static void virtio_net_device_unrealize(DeviceState *dev, Error **errp)for (i =0 ; i < max_queues; i++) {virtio_net_del_queue (n, i); } - +/* delete also control vq */ +virtio_del_queue (vdev, max_queues *2 );qemu_announce_timer_del (&n->announce_timer, false);g_free (n->vqs);qemu_del_nic (n->nic);
Signature · 1 line
2.17.1
PATCH 23/78 intel_iommu: a fix to vtd_find_as_from_bus_num()
In reply to Michael RothFrom: Liu Yi L <[email protected]>
Ensure the return value of vtd_find_as_from_bus_num() is NULL by enforcing vtd_bus=NULL. This would help caller of vtd_find_as_from_bus_num() to decide if any further operation on the returned vtd_bus.
Message-Id: <[email protected]>
--- hw/i386/intel_iommu.c | 1 + 1 file changed, 1 insertion(+)
hw/i386/intel_iommu.c +1 -0
@@ -948,6 +948,7 @@ static VTDBus *vtd_find_as_from_bus_num(IntelIOMMUState *s, uint8_t bus_num)return vtd_bus; } } + vtd_bus =NULL ; }return vtd_bus; }
Signature · 1 line
2.17.1
PATCH 24/78 intel_iommu: add present bit check for pasid table entries
In reply to Michael RothFrom: Liu Yi L <[email protected]>
The present bit check for pasid entry (pe) and pasid directory entry (pdire) were missed in previous commits as fpd bit check doesn't require present bit as "Set". This patch adds the present bit check for callers which wants to get a valid pe/pdire.
Message-Id: <[email protected]>
--- hw/i386/intel_iommu.c | 92 +++++++++++++++++++++++++++------- hw/i386/intel_iommu_internal.h | 1 + 2 files changed, 74 insertions(+), 19 deletions(-)
hw/i386/intel_iommu.c +73 -19
@@ -686,9 +686,18 @@ static inline bool vtd_pe_type_check(X86IOMMUState *x86_iommu,return true; } -static int vtd_get_pasid_dire (dma_addr_t pasid_dir_base, -uint32_t pasid, -VTDPASIDDirEntry *pdire) +static inline bool vtd_pdire_present (VTDPASIDDirEntry *pdire) +{ +return pdire->val &1 ; +} + +/** +* Caller of this function should check present bit if wants +* to use pdir entry for futher usage except for fpd bit check. +*/ +static int vtd_get_pdire_from_pdir_table (dma_addr_t pasid_dir_base, +uint32_t pasid, +VTDPASIDDirEntry *pdire) {uint32_t index;dma_addr_t addr, entry_size;
@@ -703,18 +712,22 @@ static int vtd_get_pasid_dire(dma_addr_t pasid_dir_base,return 0 ; } -static int vtd_get_pasid_entry (IntelIOMMUState *s, -uint32_t pasid, -VTDPASIDDirEntry *pdire, -VTDPASIDEntry *pe) +static inline bool vtd_pe_present (VTDPASIDEntry *pe) +{ +return pe->val[0 ] &VTD_PASID_ENTRY_P ; +} + +static int vtd_get_pe_in_pasid_leaf_table (IntelIOMMUState *s, +uint32_t pasid, +dma_addr_t addr, +VTDPASIDEntry *pe) {uint32_t index; -dma_addr_t addr, entry_size; +dma_addr_t entry_size;X86IOMMUState *x86_iommu =X86_IOMMU_DEVICE (s); index =VTD_PASID_TABLE_INDEX (pasid); entry_size =VTD_PASID_ENTRY_SIZE ; - addr = pdire->val &VTD_PASID_TABLE_BASE_ADDR_MASK ; addr = addr + index * entry_size;if (dma_memory_read (&address_space_memory, addr, pe, entry_size)) {return -VTD_FR_PASID_TABLE_INV ;
@@ -732,25 +745,54 @@ static int vtd_get_pasid_entry(IntelIOMMUState *s,return 0 ; } -static int vtd_get_pasid_entry_from_pasid (IntelIOMMUState *s, -dma_addr_t pasid_dir_base, -uint32_t pasid, -VTDPASIDEntry *pe) +/** +* Caller of this function should check present bit if wants +* to use pasid entry for futher usage except for fpd bit check. +*/ +static int vtd_get_pe_from_pdire (IntelIOMMUState *s, +uint32_t pasid, +VTDPASIDDirEntry *pdire, +VTDPASIDEntry *pe) +{ +dma_addr_t addr = pdire->val &VTD_PASID_TABLE_BASE_ADDR_MASK ; + +return vtd_get_pe_in_pasid_leaf_table (s, pasid, addr, pe); +} + +/** +* This function gets a pasid entry from a specified pasid +* table (includes dir and leaf table) with a specified pasid. +* Sanity check should be done to ensure return a present +* pasid entry to caller. +*/ +static int vtd_get_pe_from_pasid_table (IntelIOMMUState *s, +dma_addr_t pasid_dir_base, +uint32_t pasid, +VTDPASIDEntry *pe) {int ret;VTDPASIDDirEntry pdire; - ret =vtd_get_pasid_dire (pasid_dir_base, pasid, &pdire); + ret =vtd_get_pdire_from_pdir_table (pasid_dir_base, + pasid, &pdire);if (ret) {return ret; } - ret =vtd_get_pasid_entry (s, pasid, &pdire, pe); +if (!vtd_pdire_present (&pdire)) { +return -VTD_FR_PASID_TABLE_INV ; + } + + ret =vtd_get_pe_from_pdire (s, pasid, &pdire, pe);if (ret) {return ret; } -return ret; +if (!vtd_pe_present (pe)) { +return -VTD_FR_PASID_TABLE_INV ; + } + +return 0 ; } static int vtd_ce_get_rid2pasid_entry(IntelIOMMUState *s,
@@ -763,7 +805,7 @@ static int vtd_ce_get_rid2pasid_entry(IntelIOMMUState *s, pasid =VTD_CE_GET_RID2PASID (ce); pasid_dir_base =VTD_CE_GET_PASID_DIR_TABLE (ce); - ret =vtd_get_pasid_entry_from_pasid (s, pasid_dir_base, pasid, pe); + ret =vtd_get_pe_from_pasid_table (s, pasid_dir_base, pasid, pe);return ret; }
@@ -781,7 +823,11 @@ static int vtd_ce_get_pasid_fpd(IntelIOMMUState *s, pasid =VTD_CE_GET_RID2PASID (ce); pasid_dir_base =VTD_CE_GET_PASID_DIR_TABLE (ce); - ret =vtd_get_pasid_dire (pasid_dir_base, pasid, &pdire); +/* +* No present bit check since fpd is meaningful even +* if the present bit is clear. +*/ + ret =vtd_get_pdire_from_pdir_table (pasid_dir_base, pasid, &pdire);if (ret) {return ret; }
@@ -791,7 +837,15 @@ static int vtd_ce_get_pasid_fpd(IntelIOMMUState *s,return 0 ; } - ret =vtd_get_pasid_entry (s, pasid, &pdire, &pe); +if (!vtd_pdire_present (&pdire)) { +return -VTD_FR_PASID_TABLE_INV ; + } + +/* +* No present bit check since fpd is meaningful even +* if the present bit is clear. +*/ + ret =vtd_get_pe_from_pdire (s, pasid, &pdire, &pe);if (ret) {return ret; }
hw/i386/intel_iommu_internal.h +1 -0
@@ -479,6 +479,7 @@ typedef struct VTDRootEntry VTDRootEntry;#define VTD_PASID_ENTRY_FPD (1ULL << 1)/* Fault Processing Disable */ /* PASID Granular Translation Type Mask */ +#define VTD_PASID_ENTRY_P 1ULL#define VTD_SM_PASID_ENTRY_PGTT (7ULL << 6)#define VTD_SM_PASID_ENTRY_FLT (1ULL << 6)#define VTD_SM_PASID_ENTRY_SLT (2ULL << 6)
Signature · 1 line
2.17.1
PATCH 25/78 vfio/pci: Don't remove irqchip notifier if not registered
In reply to Michael RothFrom: Peter Xu <[email protected]>
The kvm irqchip notifier is only registered if the device supports INTx, however it's unconditionally removed. If the assigned device does not support INTx, this will cause QEMU to crash when unplugging the device from the system. Change it to conditionally remove the notifier only if the notify hook is setup.
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1782678
--- hw/vfio/pci.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
hw/vfio/pci.c +3 -1
@@ -3076,7 +3076,9 @@ static void vfio_exitfn(PCIDevice *pdev)vfio_unregister_req_notifier (vdev);vfio_unregister_err_notifier (vdev);pci_device_set_intx_routing_notifier (&vdev->pdev,NULL ); -kvm_irqchip_remove_change_notifier (&vdev->irqchip_change_notifier); +if (vdev->irqchip_change_notifier.notify) { +kvm_irqchip_remove_change_notifier (&vdev->irqchip_change_notifier); + }vfio_disable_interrupts (vdev);if (vdev->intx.mmap_timer) {timer_free (vdev->intx.mmap_timer);
Signature · 1 line
2.17.1
PATCH 26/78 qcow2-bitmaps: fix qcow2_can_store_new_dirty_bitmap
In reply to Michael RothFrom: Vladimir Sementsov-Ogievskiy <[email protected]>
qcow2_can_store_new_dirty_bitmap works wrong, as it considers only bitmaps already stored in the qcow2 image and ignores persistent BdrvDirtyBitmap objects.
So, let's instead count persistent BdrvDirtyBitmaps. We load all qcow2 bitmaps on open, so there should not be any bitmap in the image for which we don't have BdrvDirtyBitmaps version. If it is - it's a kind of corruption, and no reason to check for corruptions here (open() and close() are better places for it).
Message-id: [email protected]
--- block/qcow2-bitmap.c | 41 ++++++++++++++++++----------------------- 1 file changed, 18 insertions(+), 23 deletions(-)
block/qcow2-bitmap.c +18 -23
@@ -1703,8 +1703,14 @@ bool coroutine_fn qcow2_co_can_store_new_dirty_bitmap(BlockDriverState *bs, Error **errp) {BDRVQcow2State *s = bs->opaque; -bool found; -Qcow2BitmapList *bm_list; +BdrvDirtyBitmap *bitmap; +uint64_t bitmap_directory_size =0 ; +uint32_t nb_bitmaps =0 ; + +if (bdrv_find_dirty_bitmap (bs, name)) { +error_setg (errp,"Bitmap already exists: %s" , name); +return false; + }if (s->qcow_version <3 ) {/* Without autoclear_features, we would always have to assume
@@ -1720,38 +1726,27 @@ bool coroutine_fn qcow2_co_can_store_new_dirty_bitmap(BlockDriverState *bs, goto fail; } -if (s->nb_bitmaps ==0 ) { -return true; + FOR_EACH_DIRTY_BITMAP(bs, bitmap) { +if (bdrv_dirty_bitmap_get_persistence (bitmap)) { + nb_bitmaps++; + bitmap_directory_size += +calc_dir_entry_size (strlen (bdrv_dirty_bitmap_name (bitmap)),0 ); + } } + nb_bitmaps++; + bitmap_directory_size +=calc_dir_entry_size (strlen (name),0 ); -if (s->nb_bitmaps >=QCOW2_MAX_BITMAPS ) { +if (nb_bitmaps >QCOW2_MAX_BITMAPS ) {error_setg (errp,"Maximum number of persistent bitmaps is already reached" ); goto fail; } -if (s->bitmap_directory_size +calc_dir_entry_size (strlen (name),0 ) > -QCOW2_MAX_BITMAP_DIRECTORY_SIZE ) - { +if (bitmap_directory_size >QCOW2_MAX_BITMAP_DIRECTORY_SIZE ) {error_setg (errp,"Not enough space in the bitmap directory" ); goto fail; } -qemu_co_mutex_lock (&s->lock); - bm_list =bitmap_list_load (bs, s->bitmap_directory_offset, - s->bitmap_directory_size, errp); -qemu_co_mutex_unlock (&s->lock); -if (bm_list ==NULL ) { - goto fail; - } - - found =find_bitmap_by_name (bm_list, name); -bitmap_list_free (bm_list); -if (found) { -error_setg (errp,"Bitmap with the same name is already stored" ); - goto fail; - } -return true; fail:
Signature · 1 line
2.17.1
PATCH 27/78 dp8393x: Mask EOL bit from descriptor addresses
In reply to Michael RothFrom: Finn Thain <[email protected]>
The Least Significant bit of a descriptor address register is used as an EOL flag. It has to be masked when the register value is to be used as an actual address for copying memory around. But when the registers are to be updated the EOL bit should not be masked.
Conflicts:
hw/net/dp8393x.c
*drop context dep. on 19f70347731
--- hw/net/dp8393x.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)
hw/net/dp8393x.c +11 -6
@@ -145,6 +145,9 @@ do { printf("sonic ERROR: %s: " fmt, __func__ , ## __VA_ARGS__); } while (0)#define SONIC_ISR_PINT 0x0800#define SONIC_ISR_LCD 0x1000 +#define SONIC_DESC_EOL 0x0001 +#define SONIC_DESC_ADDR 0xFFFE +#define TYPE_DP8393X "dp8393x"#define DP8393X (obj) OBJECT_CHECK(dp8393xState, (obj), TYPE_DP8393X)
@@ -197,7 +200,8 @@ static uint32_t dp8393x_crba(dp8393xState *s)static uint32_t dp8393x_crda (dp8393xState *s) { -return (s->regs[SONIC_URDA ] <<16 ) | s->regs[SONIC_CRDA ]; +return (s->regs[SONIC_URDA ] <<16 ) | + (s->regs[SONIC_CRDA ] &SONIC_DESC_ADDR ); }static uint32_t dp8393x_rbwc (dp8393xState *s)
@@ -217,7 +221,8 @@ static uint32_t dp8393x_tsa(dp8393xState *s)static uint32_t dp8393x_ttda (dp8393xState *s) { -return (s->regs[SONIC_UTDA ] <<16 ) | s->regs[SONIC_TTDA ]; +return (s->regs[SONIC_UTDA ] <<16 ) | + (s->regs[SONIC_TTDA ] &SONIC_DESC_ADDR ); }static uint32_t dp8393x_wt (dp8393xState *s)
@@ -507,7 +512,7 @@ static void dp8393x_do_transmit_packets(dp8393xState *s) (4 +3 * s->regs[SONIC_TFC ]) * width, MEMTXATTRS_UNSPECIFIED, (uint8_t *)s->data, size, 0); s->regs[SONIC_CTDA ] =dp8393x_get (s, width,0 ) & ~0x1 ; -if (dp8393x_get (s, width,0 ) &0x1 ) { +if (dp8393x_get (s, width,0 ) &SONIC_DESC_EOL ) {/* EOL detected */ break ; }
@@ -763,13 +768,13 @@ static ssize_t dp8393x_receive(NetClientState *nc, const uint8_t * buf,/* XXX: Check byte ordering */ /* Check for EOL */ -if (s->regs[SONIC_LLFA ] &0x1 ) { +if (s->regs[SONIC_LLFA ] &SONIC_DESC_EOL ) {/* Are we still in resource exhaustion? */ size =sizeof (uint16_t ) *1 * width; address =dp8393x_crda (s) +sizeof (uint16_t ) *5 * width;address_space_rw (&s->as, address,MEMTXATTRS_UNSPECIFIED , (uint8_t *)s->data, size,0 ); -if (dp8393x_get (s, width,0 ) &0x1 ) { +if (dp8393x_get (s, width,0 ) &SONIC_DESC_EOL ) {/* Still EOL ; stop reception */ return -1 ; }else {
@@ -827,7 +832,7 @@ static ssize_t dp8393x_receive(NetClientState *nc, const uint8_t * buf,address_space_rw (&s->as,dp8393x_crda (s) +sizeof (uint16_t ) *5 * width,MEMTXATTRS_UNSPECIFIED , (uint8_t *)s->data, size,0 ); s->regs[SONIC_LLFA ] =dp8393x_get (s, width,0 ); -if (s->regs[SONIC_LLFA ] &0x1 ) { +if (s->regs[SONIC_LLFA ] &SONIC_DESC_EOL ) {/* EOL detected */ s->regs[SONIC_ISR ] |=SONIC_ISR_RDE ; }else {
Signature · 1 line
2.17.1
PATCH 28/78 dp8393x: Always use 32-bit accesses
In reply to Michael RothFrom: Finn Thain <[email protected]>
The DP83932 and DP83934 have 32 data lines. The datasheet says,
Data Bus: These bidirectional lines are used to transfer data on the system bus. When the SONIC is a bus master, 16-bit data is transferred on D15-D0 and 32-bit data is transferred on D31-D0. When the SONIC is accessed as a slave, register data is driven onto lines D15-D0. D31-D16 are held TRI-STATE if SONIC is in 16-bit mode. If SONIC is in 32-bit mode, they are driven, but invalid.
Always use 32-bit accesses both as bus master and bus slave.
Force the MSW to zero in bus master mode.
This gets the Linux 'jazzsonic' driver working, and avoids the need for prior hacks to make the NetBSD 'sn' driver work.
--- hw/net/dp8393x.c | 47 +++++++++++++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 18 deletions(-)
hw/net/dp8393x.c +29 -18
@@ -246,9 +246,19 @@ static void dp8393x_put(dp8393xState *s, int width, int offset, uint16_t val) {if (s->big_endian) { - s->data[offset * width + width -1 ] =cpu_to_be16 (val); +if (width ==2 ) { + s->data[offset *2 ] =0 ; + s->data[offset *2 +1 ] =cpu_to_be16 (val); + }else { + s->data[offset] =cpu_to_be16 (val); + } }else { - s->data[offset * width] =cpu_to_le16 (val); +if (width ==2 ) { + s->data[offset *2 ] =cpu_to_le16 (val); + s->data[offset *2 +1 ] =0 ; + }else { + s->data[offset] =cpu_to_le16 (val); + } } }
@@ -588,7 +598,7 @@ static uint64_t dp8393x_read(void *opaque, hwaddr addr, unsigned int size)DPRINTF ("read 0x%04x from reg %s\n" , val, reg_names[reg]); -return val; +return s->big_endian ? val <<16 : val; } static void dp8393x_write(void *opaque, hwaddr addr, uint64_t data,
@@ -596,13 +606,14 @@ static void dp8393x_write(void *opaque, hwaddr addr, uint64_t data, {dp8393xState *s = opaque;int reg = addr >> s->it_shift; +uint32_t val = s->big_endian ? data >>16 : data; -DPRINTF ("write 0x%04x to reg %s\n" , (uint16_t )data, reg_names[reg]); +DPRINTF ("write 0x%04x to reg %s\n" , (uint16_t )val, reg_names[reg]);switch (reg) {/* Command register */ case SONIC_CR : -dp8393x_do_command (s, data); +dp8393x_do_command (s, val);break ;/* Prevent write to read-only registers */ case SONIC_CAP2 :
@@ -615,36 +626,36 @@ static void dp8393x_write(void *opaque, hwaddr addr, uint64_t data,/* Accept write to some registers only when in reset mode */ case SONIC_DCR :if (s->regs[SONIC_CR ] &SONIC_CR_RST ) { - s->regs[reg] = data &0xbfff ; + s->regs[reg] = val &0xbfff ; }else {DPRINTF ("writing to DCR invalid\n" ); }break ;case SONIC_DCR2 :if (s->regs[SONIC_CR ] &SONIC_CR_RST ) { - s->regs[reg] = data &0xf017 ; + s->regs[reg] = val &0xf017 ; }else {DPRINTF ("writing to DCR2 invalid\n" ); }break ;/* 12 lower bytes are Read Only */ case SONIC_TCR : - s->regs[reg] = data &0xf000 ; + s->regs[reg] = val &0xf000 ;break ;/* 9 lower bytes are Read Only */ case SONIC_RCR : - s->regs[reg] = data &0xffe0 ; + s->regs[reg] = val &0xffe0 ;break ;/* Ignore most significant bit */ case SONIC_IMR : - s->regs[reg] = data &0x7fff ; + s->regs[reg] = val &0x7fff ;dp8393x_update_irq (s);break ;/* Clear bits by writing 1 to them */ case SONIC_ISR : - data &= s->regs[reg]; - s->regs[reg] &= ~data; -if (data &SONIC_ISR_RBE ) { + val &= s->regs[reg]; + s->regs[reg] &= ~val; +if (val &SONIC_ISR_RBE ) {dp8393x_do_read_rra (s); }dp8393x_update_irq (s);
@@ -657,17 +668,17 @@ static void dp8393x_write(void *opaque, hwaddr addr, uint64_t data,case SONIC_REA :case SONIC_RRP :case SONIC_RWP : - s->regs[reg] = data &0xfffe ; + s->regs[reg] = val &0xfffe ;break ;/* Invert written value for some registers */ case SONIC_CRCT :case SONIC_FAET :case SONIC_MPT : - s->regs[reg] = data ^0xffff ; + s->regs[reg] = val ^0xffff ;break ;/* All other registers have no special contrainst */ default : - s->regs[reg] = data; + s->regs[reg] = val; }if (reg ==SONIC_WT0 || reg ==SONIC_WT1 ) {
@@ -678,8 +689,8 @@ static void dp8393x_write(void *opaque, hwaddr addr, uint64_t data,static const MemoryRegionOps dp8393x_ops = { .read = dp8393x_read, .write = dp8393x_write, - .impl.min_access_size =2 , - .impl.max_access_size =2 , + .impl.min_access_size =4 , + .impl.max_access_size =4 , .endianness =DEVICE_NATIVE_ENDIAN , };
Signature · 1 line
2.17.1
PATCH 29/78 dp8393x: Clean up endianness hacks
In reply to Michael RothFrom: Finn Thain <[email protected]>
According to the datasheet, section 3.4.4, "in 32-bit mode ... the SONIC always writes long words".
Therefore, use the same technique for the 'in_use' field that is used everywhere else, and write the full long word.
Conflicts:
hw/net/dp8393x.c
*roll in local dependencies on b7cbebf2b9d
*drop functional dep. on 19f70347731
--- hw/net/dp8393x.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-)
hw/net/dp8393x.c +6 -11
@@ -776,8 +776,6 @@ static ssize_t dp8393x_receive(NetClientState *nc, const uint8_t * buf,return -1 ; } -/* XXX: Check byte ordering */ -/* Check for EOL */ if (s->regs[SONIC_LLFA ] &SONIC_DESC_EOL ) {/* Are we still in resource exhaustion? */
@@ -847,15 +845,12 @@ static ssize_t dp8393x_receive(NetClientState *nc, const uint8_t * buf,/* EOL detected */ s->regs[SONIC_ISR ] |=SONIC_ISR_RDE ; }else { -/* Clear in_use, but it is always 16bit wide */ -int offset =dp8393x_crda (s) +sizeof (uint16_t ) *6 * width; -if (s->big_endian && width ==2 ) { -/* we need to adjust the offset of the 16bit field */ - offset +=sizeof (uint16_t ); - } - s->data[0 ] =0 ; -address_space_rw (&s->as, offset,MEMTXATTRS_UNSPECIFIED , - (uint8_t *)s->data,sizeof (uint16_t ),1 ); +/* Clear in_use */ + size =sizeof (uint16_t ) * width; + address =dp8393x_crda (s) +sizeof (uint16_t ) *6 * width; +dp8393x_put (s, width,0 ,0 ); +address_space_rw (&s->as, address,MEMTXATTRS_UNSPECIFIED , + (uint8_t *)s->data, size, true); s->regs[SONIC_CRDA ] = s->regs[SONIC_LLFA ]; s->regs[SONIC_ISR ] |=SONIC_ISR_PKTRX ; s->regs[SONIC_RSC ] = (s->regs[SONIC_RSC ] &0xff00 ) | (((s->regs[SONIC_RSC ] &0x00ff ) +1 ) &0x00ff );
Signature · 1 line
2.17.1
PATCH 30/78 dp8393x: Have dp8393x_receive() return the packet size
In reply to Michael RothFrom: Finn Thain <[email protected]>
This function re-uses its 'size' argument as a scratch variable. Instead, declare a local 'size' variable for that purpose so that the function result doesn't get messed up.
--- hw/net/dp8393x.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
hw/net/dp8393x.c +5 -4
@@ -757,20 +757,21 @@ static int dp8393x_receive_filter(dp8393xState *s, const uint8_t * buf, }static ssize_t dp8393x_receive (NetClientState *nc,const uint8_t * buf, -size_t size) +size_t pkt_size) {dp8393xState *s =qemu_get_nic_opaque (nc);int packet_type;uint32_t available, address; -int width, rx_len = size; +int width, rx_len = pkt_size;uint32_t checksum; +int size; width = (s->regs[SONIC_DCR ] &SONIC_DCR_DW ) ?2 :1 ; s->regs[SONIC_RCR ] &= ~(SONIC_RCR_PRX |SONIC_RCR_LBK |SONIC_RCR_FAER |SONIC_RCR_CRCR |SONIC_RCR_LPKT |SONIC_RCR_BC |SONIC_RCR_MC ); - packet_type =dp8393x_receive_filter (s, buf, size); + packet_type =dp8393x_receive_filter (s, buf, pkt_size);if (packet_type <0 ) {DPRINTF ("packet not for netcard\n" );return -1 ;
@@ -864,7 +865,7 @@ static ssize_t dp8393x_receive(NetClientState *nc, const uint8_t * buf,/* Done */ dp8393x_update_irq (s); -return size; +return pkt_size; }static void dp8393x_reset (DeviceState *dev)
Signature · 1 line
2.17.1
PATCH 31/78 dp8393x: Update LLFA and CRDA registers from rx descriptor
In reply to Michael RothFrom: Finn Thain <[email protected]>
Follow the algorithm given in the National Semiconductor DP83932C datasheet in section 3.4.7:
At the next reception, the SONIC re-reads the last RXpkt.link field, and updates its CRDA register to point to the next descriptor.
The chip is designed to allow the host to provide a new list of descriptors in this way.
*drop context dep on 19f70347731
--- hw/net/dp8393x.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
hw/net/dp8393x.c +7 -4
@@ -784,12 +784,13 @@ static ssize_t dp8393x_receive(NetClientState *nc, const uint8_t * buf, address =dp8393x_crda (s) +sizeof (uint16_t ) *5 * width;address_space_rw (&s->as, address,MEMTXATTRS_UNSPECIFIED , (uint8_t *)s->data, size,0 ); -if (dp8393x_get (s, width,0 ) &SONIC_DESC_EOL ) { + s->regs[SONIC_LLFA ] =dp8393x_get (s, width,0 ); +if (s->regs[SONIC_LLFA ] &SONIC_DESC_EOL ) {/* Still EOL ; stop reception */ return -1 ; - }else { - s->regs[SONIC_CRDA ] = s->regs[SONIC_LLFA ]; } +/* Link has been updated by host */ + s->regs[SONIC_CRDA ] = s->regs[SONIC_LLFA ]; }/* Save current position */
@@ -837,7 +838,7 @@ static ssize_t dp8393x_receive(NetClientState *nc, const uint8_t * buf,address_space_rw (&s->as,dp8393x_crda (s),MEMTXATTRS_UNSPECIFIED , (uint8_t *)s->data, size,1 ); -/* Move to next descriptor */ +/* Check link field */ size =sizeof (uint16_t ) * width;address_space_rw (&s->as,dp8393x_crda (s) +sizeof (uint16_t ) *5 * width,MEMTXATTRS_UNSPECIFIED , (uint8_t *)s->data, size,0 );
@@ -852,6 +853,8 @@ static ssize_t dp8393x_receive(NetClientState *nc, const uint8_t * buf,dp8393x_put (s, width,0 ,0 );address_space_rw (&s->as, address,MEMTXATTRS_UNSPECIFIED , (uint8_t *)s->data, size, true); + +/* Move to next descriptor */ s->regs[SONIC_CRDA ] = s->regs[SONIC_LLFA ]; s->regs[SONIC_ISR ] |=SONIC_ISR_PKTRX ; s->regs[SONIC_RSC ] = (s->regs[SONIC_RSC ] &0xff00 ) | (((s->regs[SONIC_RSC ] &0x00ff ) +1 ) &0x00ff );
Signature · 1 line
2.17.1
PATCH 32/78 dp8393x: Clear RRRA command register bit only when appropriate
In reply to Michael RothFrom: Finn Thain <[email protected]>
It doesn't make sense to clear the command register bit unless the command was actually issued.
--- hw/net/dp8393x.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
hw/net/dp8393x.c +3 -4
@@ -352,9 +352,6 @@ static void dp8393x_do_read_rra(dp8393xState *s) s->regs[SONIC_ISR ] |=SONIC_ISR_RBE ;dp8393x_update_irq (s); } - -/* Done */ - s->regs[SONIC_CR ] &= ~SONIC_CR_RRRA ; }static void dp8393x_do_software_reset (dp8393xState *s)
@@ -563,8 +560,10 @@ static void dp8393x_do_command(dp8393xState *s, uint16_t command)dp8393x_do_start_timer (s);if (command &SONIC_CR_RST )dp8393x_do_software_reset (s); -if (command &SONIC_CR_RRRA ) +if (command &SONIC_CR_RRRA ) {dp8393x_do_read_rra (s); + s->regs[SONIC_CR ] &= ~SONIC_CR_RRRA ; + }if (command &SONIC_CR_LCAM )dp8393x_do_load_cam (s); }
Signature · 1 line
2.17.1
PATCH 33/78 dp8393x: Implement packet size limit and RBAE interrupt
In reply to Michael RothFrom: Finn Thain <[email protected]>
Add a bounds check to prevent a large packet from causing a buffer overflow. This is defensive programming -- I haven't actually tried sending an oversized packet or a jumbo ethernet frame.
The SONIC handles packets that are too big for the buffer by raising the RBAE interrupt and dropping them. Linux uses that interrupt to count dropped packets.
--- hw/net/dp8393x.c | 9 +++++++++ 1 file changed, 9 insertions(+)
hw/net/dp8393x.c +9 -0
@@ -137,6 +137,7 @@ do { printf("sonic ERROR: %s: " fmt, __func__ , ## __VA_ARGS__); } while (0)#define SONIC_TCR_CRCI 0x2000#define SONIC_TCR_PINT 0x8000 +#define SONIC_ISR_RBAE 0x0010#define SONIC_ISR_RBE 0x0020#define SONIC_ISR_RDE 0x0040#define SONIC_ISR_TC 0x0080
@@ -770,6 +771,14 @@ static ssize_t dp8393x_receive(NetClientState *nc, const uint8_t * buf, s->regs[SONIC_RCR ] &= ~(SONIC_RCR_PRX |SONIC_RCR_LBK |SONIC_RCR_FAER |SONIC_RCR_CRCR |SONIC_RCR_LPKT |SONIC_RCR_BC |SONIC_RCR_MC ); +if (pkt_size +4 >dp8393x_rbwc (s) *2 ) { +DPRINTF ("oversize packet, pkt_size is %d\n" , pkt_size); + s->regs[SONIC_ISR ] |=SONIC_ISR_RBAE ; +dp8393x_update_irq (s); +dp8393x_do_read_rra (s); +return pkt_size; + } + packet_type =dp8393x_receive_filter (s, buf, pkt_size);if (packet_type <0 ) {DPRINTF ("packet not for netcard\n" );
Signature · 1 line
2.17.1
PATCH 34/78 dp8393x: Don't clobber packet checksum
In reply to Michael RothFrom: Finn Thain <[email protected]>
A received packet consumes pkt_size bytes in the buffer and the frame checksum that's appended to it consumes another 4 bytes. The Receive Buffer Address register takes the former quantity into account but not the latter. So the next packet written to the buffer overwrites the frame checksum. Fix this.
*drop context dep. on 19f70347731
--- hw/net/dp8393x.c | 1 + 1 file changed, 1 insertion(+)
hw/net/dp8393x.c +1 -0
@@ -816,6 +816,7 @@ static ssize_t dp8393x_receive(NetClientState *nc, const uint8_t * buf, address += rx_len;address_space_rw (&s->as, address,MEMTXATTRS_UNSPECIFIED , (uint8_t *)&checksum,4 ,1 ); + address +=4 ; rx_len +=4 ; s->regs[SONIC_CRBA1 ] = address >>16 ; s->regs[SONIC_CRBA0 ] = address &0xffff ;
Signature · 1 line
2.17.1
PATCH 35/78 dp8393x: Use long-word-aligned RRA pointers in 32-bit mode
In reply to Michael RothFrom: Finn Thain <[email protected]>
Section 3.4.1 of the datasheet says,
The alignment of the RRA is confined to either word or long word boundaries, depending upon the data width mode. In 16-bit mode, the RRA must be aligned to a word boundary (A0 is always zero) and in 32-bit mode, the RRA is aligned to a long word boundary (A0 and A1 are always zero).
This constraint has been implemented for 16-bit mode; implement it for 32-bit mode too.
--- hw/net/dp8393x.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
hw/net/dp8393x.c +6 -2
@@ -663,12 +663,16 @@ static void dp8393x_write(void *opaque, hwaddr addr, uint64_t data,qemu_flush_queued_packets (qemu_get_queue (s->nic)); }break ; -/* Ignore least significant bit */ +/* The guest is required to store aligned pointers here */ case SONIC_RSA :case SONIC_REA :case SONIC_RRP :case SONIC_RWP : - s->regs[reg] = val &0xfffe ; +if (s->regs[SONIC_DCR ] &SONIC_DCR_DW ) { + s->regs[reg] = val &0xfffc ; + }else { + s->regs[reg] = val &0xfffe ; + }break ;/* Invert written value for some registers */ case SONIC_CRCT :
Signature · 1 line
2.17.1
PATCH 36/78 dp8393x: Pad frames to word or long word boundary
In reply to Michael RothFrom: Finn Thain <[email protected]>
The existing code has a bug where the Remaining Buffer Word Count (RBWC) is calculated with a truncating division, which gives the wrong result for odd-sized packets.
Section 1.4.1 of the datasheet says,
Once the end of the packet has been reached, the serializer will fill out the last word (16-bit mode) or long word (32-bit mode) if the last byte did not end on a word or long word boundary respectively. The fill byte will be 0FFh.
Implement buffer padding so that buffer limits are correctly enforced.
*drop context dependencies from b7cbebf2b9d, 1ccda935d4f, and
19f70347731
--- hw/net/dp8393x.c | 39 ++++++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 11 deletions(-)
hw/net/dp8393x.c +28 -11
@@ -766,16 +766,23 @@ static ssize_t dp8393x_receive(NetClientState *nc, const uint8_t * buf,dp8393xState *s =qemu_get_nic_opaque (nc);int packet_type;uint32_t available, address; -int width, rx_len = pkt_size; +int width, rx_len, padded_len;uint32_t checksum;int size; - width = (s->regs[SONIC_DCR ] &SONIC_DCR_DW ) ?2 :1 ; - s->regs[SONIC_RCR ] &= ~(SONIC_RCR_PRX |SONIC_RCR_LBK |SONIC_RCR_FAER |SONIC_RCR_CRCR |SONIC_RCR_LPKT |SONIC_RCR_BC |SONIC_RCR_MC ); -if (pkt_size +4 >dp8393x_rbwc (s) *2 ) { + rx_len = pkt_size +sizeof (checksum); +if (s->regs[SONIC_DCR ] &SONIC_DCR_DW ) { + width =2 ; + padded_len = ((rx_len -1 ) |3 ) +1 ; + }else { + width =1 ; + padded_len = ((rx_len -1 ) |1 ) +1 ; + } + +if (padded_len >dp8393x_rbwc (s) *2 ) {DPRINTF ("oversize packet, pkt_size is %d\n" , pkt_size); s->regs[SONIC_ISR ] |=SONIC_ISR_RBAE ;dp8393x_update_irq (s);
@@ -810,22 +817,32 @@ static ssize_t dp8393x_receive(NetClientState *nc, const uint8_t * buf, s->regs[SONIC_TRBA0 ] = s->regs[SONIC_CRBA0 ];/* Calculate the ethernet checksum */ - checksum =cpu_to_le32 (crc32 (0 , buf, rx_len)); + checksum =cpu_to_le32 (crc32 (0 , buf, pkt_size));/* Put packet into RBA */ DPRINTF ("Receive packet at %08x\n" ,dp8393x_crba (s)); address =dp8393x_crba (s);address_space_rw (&s->as, address, -MEMTXATTRS_UNSPECIFIED , (uint8_t *)buf, rx_len,1 ); - address += rx_len; +MEMTXATTRS_UNSPECIFIED , (uint8_t *)buf, pkt_size,1 ); + address += pkt_size; + +/* Put frame checksum into RBA */ address_space_rw (&s->as, address, -MEMTXATTRS_UNSPECIFIED , (uint8_t *)&checksum,4 ,1 ); - address +=4 ; - rx_len +=4 ; +MEMTXATTRS_UNSPECIFIED , (uint8_t *)&checksum,sizeof (checksum),1 ); + address +=sizeof (checksum); + +/* Pad short packets to keep pointers aligned */ +if (rx_len < padded_len) { + size = padded_len - rx_len; +address_space_rw (&s->as, address,MEMTXATTRS_UNSPECIFIED , + (uint8_t *)"\xFF\xFF\xFF" , size,1 ); + address += size; + } + s->regs[SONIC_CRBA1 ] = address >>16 ; s->regs[SONIC_CRBA0 ] = address &0xffff ; available =dp8393x_rbwc (s); - available -= rx_len /2 ; + available -= padded_len >>1 ; s->regs[SONIC_RBWC1 ] = available >>16 ; s->regs[SONIC_RBWC0 ] = available &0xffff ;
Signature · 1 line
2.17.1
PATCH 37/78 dp8393x: Clear descriptor in_use field to release packet
In reply to Michael RothFrom: Finn Thain <[email protected]>
When the SONIC receives a packet into the last available descriptor, it retains ownership of that descriptor for as long as necessary.
Section 3.4.7 of the datasheet says,
When the system appends more descriptors, the SONIC releases ownership of the descriptor after writing 0000h to the RXpkt.in_use field.
The packet can now be processed by the host, so raise a PKTRX interrupt, just like the normal case.
--- hw/net/dp8393x.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
hw/net/dp8393x.c +10 -0
@@ -809,7 +809,17 @@ static ssize_t dp8393x_receive(NetClientState *nc, const uint8_t * buf,return -1 ; }/* Link has been updated by host */ + +/* Clear in_use */ + size =sizeof (uint16_t ) * width; + address =dp8393x_crda (s) +sizeof (uint16_t ) *6 * width; +dp8393x_put (s, width,0 ,0 ); +address_space_rw (&s->as, address,MEMTXATTRS_UNSPECIFIED , + (uint8_t *)s->data, size,1 ); + +/* Move to next descriptor */ s->regs[SONIC_CRDA ] = s->regs[SONIC_LLFA ]; + s->regs[SONIC_ISR ] |=SONIC_ISR_PKTRX ; }/* Save current position */
Signature · 1 line
2.17.1
PATCH 38/78 dp8393x: Always update RRA pointers and sequence numbers
In reply to Michael RothFrom: Finn Thain <[email protected]>
These operations need to take place regardless of whether or not rx descriptors have been used up (that is, EOL flag was observed).
The algorithm is now the same for a packet that was withheld as for a packet that was not.
--- hw/net/dp8393x.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
hw/net/dp8393x.c +7 -5
@@ -897,12 +897,14 @@ static ssize_t dp8393x_receive(NetClientState *nc, const uint8_t * buf,/* Move to next descriptor */ s->regs[SONIC_CRDA ] = s->regs[SONIC_LLFA ]; s->regs[SONIC_ISR ] |=SONIC_ISR_PKTRX ; - s->regs[SONIC_RSC ] = (s->regs[SONIC_RSC ] &0xff00 ) | (((s->regs[SONIC_RSC ] &0x00ff ) +1 ) &0x00ff ); + } -if (s->regs[SONIC_RCR ] &SONIC_RCR_LPKT ) { -/* Read next RRA */ -dp8393x_do_read_rra (s); - } + s->regs[SONIC_RSC ] = (s->regs[SONIC_RSC ] &0xff00 ) | + ((s->regs[SONIC_RSC ] +1 ) &0x00ff ); + +if (s->regs[SONIC_RCR ] &SONIC_RCR_LPKT ) { +/* Read next RRA */ +dp8393x_do_read_rra (s); }/* Done */
Signature · 1 line
2.17.1
PATCH 39/78 dp8393x: Don't reset Silicon Revision register
In reply to Michael RothFrom: Finn Thain <[email protected]>
The jazzsonic driver in Linux uses the Silicon Revision register value to probe the chip. The driver fails unless the SR register contains 4. Unfortunately, reading this register in QEMU usually returns 0 because the s->regs[] array gets wiped after a software reset.
--- hw/net/dp8393x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/net/dp8393x.c +1 -1
@@ -919,6 +919,7 @@ static void dp8393x_reset(DeviceState *dev)timer_del (s->watchdog);memset (s->regs,0 ,sizeof (s->regs)); + s->regs[SONIC_SR ] =0x0004 ;/* only revision recognized by Linux/mips */ s->regs[SONIC_CR ] =SONIC_CR_RST |SONIC_CR_STP |SONIC_CR_RXDIS ; s->regs[SONIC_DCR ] &= ~(SONIC_DCR_EXBUS |SONIC_DCR_LBR ); s->regs[SONIC_RCR ] &= ~(SONIC_RCR_LB0 |SONIC_RCR_LB1 |SONIC_RCR_BRD |SONIC_RCR_RNT );
@@ -971,7 +972,6 @@ static void dp8393x_realize(DeviceState *dev, Error **errp)qemu_format_nic_info_str (qemu_get_queue (s->nic), s->conf.macaddr.a); s->watchdog =timer_new_ns (QEMU_CLOCK_VIRTUAL , dp8393x_watchdog, s); - s->regs[SONIC_SR ] =0x0004 ;/* only revision recognized by Linux */ memory_region_init_ram (&s->prom,OBJECT (dev),"dp8393x-prom" ,SONIC_PROM_SIZE , &local_err);
Signature · 1 line
2.17.1
PATCH 40/78 dp8393x: Don't stop reception upon RBE interrupt assertion
In reply to Michael RothFrom: Finn Thain <[email protected]>
Section 3.4.7 of the datasheet explains that,
The RBE bit in the Interrupt Status register is set when the SONIC finishes using the second to last receive buffer and reads the last RRA descriptor. Actually, the SONIC is not truly out of resources, but gives the system an early warning of an impending out of resources condition.
RBE does not mean actual receive buffer exhaustion, and reception should not be stopped. This is important because Linux will not check and clear the RBE interrupt until it receives another packet. But that won't happen if can_receive returns false. This bug causes the SONIC to become deaf (until reset).
Fix this with a new flag to indicate actual receive buffer exhaustion.
--- hw/net/dp8393x.c | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-)
hw/net/dp8393x.c +22 -13
@@ -158,6 +158,7 @@ typedef struct dp8393xState {/* Hardware */ uint8_t it_shift;bool big_endian; +bool last_rba_is_full;qemu_irq irq;#ifdef DEBUG_SONIC int irq_level;
@@ -347,12 +348,15 @@ static void dp8393x_do_read_rra(dp8393xState *s) s->regs[SONIC_RRP ] = s->regs[SONIC_RSA ]; } -/* Check resource exhaustion */ +/* Warn the host if CRBA now has the last available resource */ if (s->regs[SONIC_RRP ] == s->regs[SONIC_RWP ]) { s->regs[SONIC_ISR ] |=SONIC_ISR_RBE ;dp8393x_update_irq (s); } + +/* Allow packet reception */ + s->last_rba_is_full = false; }static void dp8393x_do_software_reset (dp8393xState *s)
@@ -659,9 +663,6 @@ static void dp8393x_write(void *opaque, hwaddr addr, uint64_t data,dp8393x_do_read_rra (s); }dp8393x_update_irq (s); -if (dp8393x_can_receive (s->nic->ncs)) { -qemu_flush_queued_packets (qemu_get_queue (s->nic)); - }break ;/* The guest is required to store aligned pointers here */ case SONIC_RSA :
@@ -721,8 +722,6 @@ static int dp8393x_can_receive(NetClientState *nc)if (!(s->regs[SONIC_CR ] &SONIC_CR_RXEN ))return 0 ; -if (s->regs[SONIC_ISR ] &SONIC_ISR_RBE ) -return 0 ;return 1 ; }
@@ -773,6 +772,10 @@ static ssize_t dp8393x_receive(NetClientState *nc, const uint8_t * buf, s->regs[SONIC_RCR ] &= ~(SONIC_RCR_PRX |SONIC_RCR_LBK |SONIC_RCR_FAER |SONIC_RCR_CRCR |SONIC_RCR_LPKT |SONIC_RCR_BC |SONIC_RCR_MC ); +if (s->last_rba_is_full) { +return pkt_size; + } + rx_len = pkt_size +sizeof (checksum);if (s->regs[SONIC_DCR ] &SONIC_DCR_DW ) { width =2 ;
@@ -786,8 +789,8 @@ static ssize_t dp8393x_receive(NetClientState *nc, const uint8_t * buf,DPRINTF ("oversize packet, pkt_size is %d\n" , pkt_size); s->regs[SONIC_ISR ] |=SONIC_ISR_RBAE ;dp8393x_update_irq (s); -dp8393x_do_read_rra (s); -return pkt_size; + s->regs[SONIC_RCR ] |=SONIC_RCR_LPKT ; + goto done; } packet_type =dp8393x_receive_filter (s, buf, pkt_size);
@@ -899,17 +902,23 @@ static ssize_t dp8393x_receive(NetClientState *nc, const uint8_t * buf, s->regs[SONIC_ISR ] |=SONIC_ISR_PKTRX ; } +dp8393x_update_irq (s); + s->regs[SONIC_RSC ] = (s->regs[SONIC_RSC ] &0xff00 ) | ((s->regs[SONIC_RSC ] +1 ) &0x00ff ); +done: +if (s->regs[SONIC_RCR ] &SONIC_RCR_LPKT ) { -/* Read next RRA */ -dp8393x_do_read_rra (s); +if (s->regs[SONIC_RRP ] == s->regs[SONIC_RWP ]) { +/* Stop packet reception */ + s->last_rba_is_full = true; + }else { +/* Read next resource */ +dp8393x_do_read_rra (s); + } } -/* Done */ -dp8393x_update_irq (s); -return pkt_size; }
Signature · 1 line
2.17.1
PATCH 41/78 s390/sclp: improve special wait psw logic
In reply to Michael RothFrom: Christian Borntraeger <[email protected]>
There is a special quiesce PSW that we check for "shutdown". Otherwise disabled wait is detected as "crashed". Architecturally we must only check PSW bits 116-127. Fix this.
Message-Id: <[email protected]>
--- target/s390x/helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/s390x/helper.c +1 -1
@@ -89,7 +89,7 @@ hwaddr s390_cpu_get_phys_addr_debug(CPUState *cs, vaddr vaddr)static inline bool is_special_wait_psw (uint64_t psw_addr) {/* signal quiesce */ -return psw_addr ==0xfffUL ; +return (psw_addr &0xfffUL ) ==0xfffUL ; }void s390_handle_wait (S390CPU *cpu)
Signature · 1 line
2.17.1
PATCH 42/78 plugins/core: add missing break in cb_to_tcg_flags
In reply to Michael RothFrom: "Emilio G. Cota" <[email protected]>
Message-Id: <[email protected]>
Cc: [email protected]
Message-Id: <[email protected]>
--- plugins/core.c | 1 + 1 file changed, 1 insertion(+)
plugins/core.c +1 -0
@@ -286,6 +286,7 @@ static inline uint32_t cb_to_tcg_flags(enum qemu_plugin_cb_flags flags)switch (flags) {case QEMU_PLUGIN_CB_RW_REGS : ret =0 ; +break ;case QEMU_PLUGIN_CB_R_REGS : ret =TCG_CALL_NO_WG ;break ;
Signature · 1 line
2.17.1
PATCH 43/78 tcg: save vaddr temp for plugin usage
In reply to Michael RothFrom: Alex Bennée <[email protected]>
While do_gen_mem_cb does copy (via extu_tl_i64) vaddr into a new temp this won't help if the vaddr temp gets clobbered by the actual load/store op. To avoid this clobbering we explicitly copy vaddr before the op to ensure it is live my the time we do the instrumentation.
Message-Id: <[email protected]>
--- tcg/tcg-op.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-)
tcg/tcg-op.c +20 -3
@@ -2794,13 +2794,26 @@ static void tcg_gen_req_mo(TCGBar type) } } +static inline TCGv plugin_prep_mem_callbacks (TCGv vaddr) +{ +#ifdef CONFIG_PLUGIN +if (tcg_ctx->plugin_insn !=NULL ) { +/* Save a copy of the vaddr for use after a load. */ +TCGv temp =tcg_temp_new (); +tcg_gen_mov_tl (temp, vaddr); +return temp; + } +#endif +return vaddr; +} +static inline void plugin_gen_mem_callbacks (TCGv vaddr,uint16_t info) {#ifdef CONFIG_PLUGIN -if (tcg_ctx->plugin_insn ==NULL ) { -return ; +if (tcg_ctx->plugin_insn !=NULL ) { +plugin_gen_empty_mem_callback (vaddr, info); +tcg_temp_free (vaddr); } -plugin_gen_empty_mem_callback (vaddr, info);#endif }
@@ -2822,6 +2835,7 @@ void tcg_gen_qemu_ld_i32(TCGv_i32 val, TCGv addr, TCGArg idx, MemOp memop) } } + addr =plugin_prep_mem_callbacks (addr);gen_ldst_i32 (INDEX_op_qemu_ld_i32, val, addr, memop, idx);plugin_gen_mem_callbacks (addr, info);
@@ -2868,6 +2882,7 @@ void tcg_gen_qemu_st_i32(TCGv_i32 val, TCGv addr, TCGArg idx, MemOp memop) memop &= ~MO_BSWAP ; } + addr =plugin_prep_mem_callbacks (addr);gen_ldst_i32 (INDEX_op_qemu_st_i32, val, addr, memop, idx);plugin_gen_mem_callbacks (addr, info);
@@ -2905,6 +2920,7 @@ void tcg_gen_qemu_ld_i64(TCGv_i64 val, TCGv addr, TCGArg idx, MemOp memop) } } + addr =plugin_prep_mem_callbacks (addr);gen_ldst_i64 (INDEX_op_qemu_ld_i64, val, addr, memop, idx);plugin_gen_mem_callbacks (addr, info);
@@ -2967,6 +2983,7 @@ void tcg_gen_qemu_st_i64(TCGv_i64 val, TCGv addr, TCGArg idx, MemOp memop) memop &= ~MO_BSWAP ; } + addr =plugin_prep_mem_callbacks (addr);gen_ldst_i64 (INDEX_op_qemu_st_i64, val, addr, memop, idx);plugin_gen_mem_callbacks (addr, info);
Signature · 1 line
2.17.1
PATCH 44/78 qcow2: update_refcount(): Reset old_table_index after qcow2_cache_put()
In reply to Michael RothFrom: Kevin Wolf <[email protected]>
In the case that update_refcount() frees a refcount block, it evicts it from the metadata cache. Before doing so, however, it returns the currently used refcount block to the cache because it might be the same. Returning the refcount block early means that we need to reset old_table_index so that we reload the refcount block in the next iteration if it is actually still in use.
Message-Id: <[email protected]>
--- block/qcow2-refcount.c | 1 + 1 file changed, 1 insertion(+)
block/qcow2-refcount.c +1 -0
@@ -889,6 +889,7 @@ static int QEMU_WARN_UNUSED_RESULT update_refcount(BlockDriverState *bs, offset);if (table !=NULL ) {qcow2_cache_put (s->refcount_block_cache, &refcount_block); + old_table_index =-1 ;qcow2_cache_discard (s->refcount_block_cache, table); }
Signature · 1 line
2.17.1
PATCH 45/78 qcow2: Fix qcow2_alloc_cluster_abort() for external data file
In reply to Michael RothFrom: Kevin Wolf <[email protected]>
For external data file, cluster allocations return an offset in the data file and are not refcounted. In this case, there is nothing to do for qcow2_alloc_cluster_abort(). Freeing the same offset in the qcow2 file is wrong and causes crashes in the better case or image corruption in the worse case.
Message-Id: <[email protected]>
--- block/qcow2-cluster.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
block/qcow2-cluster.c +5 -2
@@ -1015,8 +1015,11 @@ err:void qcow2_alloc_cluster_abort (BlockDriverState *bs,QCowL2Meta *m) {BDRVQcow2State *s = bs->opaque; -qcow2_free_clusters (bs, m->alloc_offset, m->nb_clusters << s->cluster_bits, -QCOW2_DISCARD_NEVER ); +if (!has_data_file (bs)) { +qcow2_free_clusters (bs, m->alloc_offset, + m->nb_clusters << s->cluster_bits, +QCOW2_DISCARD_NEVER ); + } }/*
Signature · 1 line
2.17.1
PATCH 46/78 iotests: Test copy offloading with external data file
In reply to Michael RothFrom: Kevin Wolf <[email protected]>
This adds a test for 'qemu-img convert' with copy offloading where the target image has an external data file. If the test hosts supports it, it tests both the case where copy offloading is supported and the case where it isn't (otherwise we just test unsupported twice).
More specifically, the case with unsupported copy offloading tests qcow2_alloc_cluster_abort() with external data files.
Message-Id: <[email protected]>
--- tests/qemu-iotests/244 | 14 ++++++++++++++ tests/qemu-iotests/244.out | 6 ++++++ 2 files changed, 20 insertions(+)
tests/qemu-iotests/244 +14 -0
@@ -194,6 +194,20 @@ $QEMU_IO -c 'read -P 0x11 0 1M' -f $IMGFMT "$TEST_IMG" | _filter_qemu_io $QEMU_IMG map --output=human "$TEST_IMG" | _filter_testdir $QEMU_IMG map --output=json "$TEST_IMG" +echo +echo "=== Copy offloading ===" +echo + +# Make use of copy offloading if the test host can provide it +_make_test_img -o "data_file=$TEST_IMG.data" 64M +$QEMU_IMG convert -f $IMGFMT -O $IMGFMT -n -C "$TEST_IMG.src" "$TEST_IMG" +$QEMU_IMG compare -f $IMGFMT -F $IMGFMT "$TEST_IMG.src" "$TEST_IMG" + +# blkdebug doesn't support copy offloading, so this tests the error path +$QEMU_IMG amend -f $IMGFMT -o "data_file=blkdebug::$TEST_IMG.data" "$TEST_IMG" +$QEMU_IMG convert -f $IMGFMT -O $IMGFMT -n -C "$TEST_IMG.src" "$TEST_IMG" +$QEMU_IMG compare -f $IMGFMT -F $IMGFMT "$TEST_IMG.src" "$TEST_IMG" + # success, all done echo "*** done" rm -f $seq.full
tests/qemu-iotests/244.out +6 -0
@@ -122,4 +122,10 @@ Offset Length Mapped to File 0 0x100000 0 TEST_DIR/t.qcow2.data [{ "start": 0, "length": 1048576, "depth": 0, "zero": false, "data": true, "offset": 0}, { "start": 1048576, "length": 66060288, "depth": 0, "zero": true, "data": false}] + +=== Copy offloading === + +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 data_file=TEST_DIR/t.IMGFMT.data +Images are identical. +Images are identical. *** done
Signature · 1 line
2.17.1
PATCH 47/78 qcow2: Fix alloc_cluster_abort() for pre-existing clusters
In reply to Michael RothFrom: Max Reitz <[email protected]>
handle_alloc() reuses preallocated zero clusters. If anything goes wrong during the data write, we do not change their L2 entry, so we must not let qcow2_alloc_cluster_abort() free them.
Message-Id: <[email protected]>
--- block/qcow2-cluster.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
block/qcow2-cluster.c +1 -1
@@ -1015,7 +1015,7 @@ err:void qcow2_alloc_cluster_abort (BlockDriverState *bs,QCowL2Meta *m) {BDRVQcow2State *s = bs->opaque; -if (!has_data_file (bs)) { +if (!has_data_file (bs) && !m->keep_old_clusters) {qcow2_free_clusters (bs, m->alloc_offset, m->nb_clusters << s->cluster_bits,QCOW2_DISCARD_NEVER );
Signature · 1 line
2.17.1
PATCH 48/78 iotests/026: Test EIO on preallocated zero cluster
In reply to Michael RothFrom: Max Reitz <[email protected]>
Test what happens when writing data to a preallocated zero cluster, but the data write fails.
Message-Id: <[email protected]>
--- tests/qemu-iotests/026 | 21 +++++++++++++++++++++ tests/qemu-iotests/026.out | 10 ++++++++++ tests/qemu-iotests/026.out.nocache | 10 ++++++++++ 3 files changed, 41 insertions(+)
tests/qemu-iotests/026 +21 -0
@@ -215,6 +215,27 @@ _make_test_img 64M $QEMU_IO -c "write 0 1M" -c "write 0 1M" "$BLKDBG_TEST_IMG" | _filter_qemu_io _check_test_img +echo +echo === Avoid freeing preallocated zero clusters on failure === +echo + +cat > "$TEST_DIR/blkdebug.conf" <<EOF +[inject-error] +event = "write_aio" +errno = "5" +once = "on" +EOF + +_make_test_img $CLUSTER_SIZE +# Create a preallocated zero cluster +$QEMU_IO -c "write 0 $CLUSTER_SIZE" -c "write -z 0 $CLUSTER_SIZE" "$TEST_IMG" \ + | _filter_qemu_io +# Try to overwrite it (prompting an I/O error from blkdebug), thus +# triggering the alloc abort code +$QEMU_IO -c "write 0 $CLUSTER_SIZE" "$BLKDBG_TEST_IMG" | _filter_qemu_io + +_check_test_img + # success, all done echo "*** done" rm -f $seq.full
tests/qemu-iotests/026.out +10 -0
@@ -643,4 +643,14 @@ write failed: Input/output error wrote 1048576/1048576 bytes at offset 0 1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) No errors were found on the image. + +=== Avoid freeing preallocated zero clusters on failure === + +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1024 +wrote 1024/1024 bytes at offset 0 +1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 1024/1024 bytes at offset 0 +1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +write failed: Input/output error +No errors were found on the image. *** done
tests/qemu-iotests/026.out.nocache +10 -0
@@ -651,4 +651,14 @@ write failed: Input/output error wrote 1048576/1048576 bytes at offset 0 1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) No errors were found on the image. + +=== Avoid freeing preallocated zero clusters on failure === + +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1024 +wrote 1024/1024 bytes at offset 0 +1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 1024/1024 bytes at offset 0 +1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +write failed: Input/output error +No errors were found on the image. *** done
Signature · 1 line
2.17.1
PATCH 49/78 iotests/026: Test EIO on allocation in a data-file
In reply to Michael RothFrom: Max Reitz <[email protected]>
Test what happens when writing data to an external data file, where the write requires an L2 entry to be allocated, but the data write fails.
Message-Id: <[email protected]>
--- tests/qemu-iotests/026 | 32 ++++++++++++++++++++++++++++++ tests/qemu-iotests/026.out | 6 ++++++ tests/qemu-iotests/026.out.nocache | 6 ++++++ 3 files changed, 44 insertions(+)
tests/qemu-iotests/026 +32 -0
@@ -30,6 +30,7 @@ _cleanup() { _cleanup_test_img rm "$TEST_DIR/blkdebug.conf" + rm -f "$TEST_IMG.data_file" } trap "_cleanup; exit \$status" 0 1 2 3 15
@@ -236,6 +237,37 @@ $QEMU_IO -c "write 0 $CLUSTER_SIZE" "$BLKDBG_TEST_IMG" | _filter_qemu_io _check_test_img +echo +echo === Avoid freeing external data clusters on failure === +echo + +# Similar test as the last one, except we test what happens when there +# is an error when writing to an external data file instead of when +# writing to a preallocated zero cluster +_make_test_img -o "data_file=$TEST_IMG.data_file" $CLUSTER_SIZE + +# Put blkdebug above the data-file, and a raw node on top of that so +# that blkdebug will see a write_aio event and emit an error +$QEMU_IO -c "write 0 $CLUSTER_SIZE" \ + "json:{ + 'driver': 'qcow2', + 'file': { 'driver': 'file', 'filename': '$TEST_IMG' }, + 'data-file': { + 'driver': 'raw', + 'file': { + 'driver': 'blkdebug', + 'config': '$TEST_DIR/blkdebug.conf', + 'image': { + 'driver': 'file', + 'filename': '$TEST_IMG.data_file' + } + } + } + }" \ + | _filter_qemu_io + +_check_test_img + # success, all done echo "*** done" rm -f $seq.full
tests/qemu-iotests/026.out +6 -0
@@ -653,4 +653,10 @@ wrote 1024/1024 bytes at offset 0 1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) write failed: Input/output error No errors were found on the image. + +=== Avoid freeing external data clusters on failure === + +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1024 data_file=TEST_DIR/t.IMGFMT.data_file +write failed: Input/output error +No errors were found on the image. *** done
tests/qemu-iotests/026.out.nocache +6 -0
@@ -661,4 +661,10 @@ wrote 1024/1024 bytes at offset 0 1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) write failed: Input/output error No errors were found on the image. + +=== Avoid freeing external data clusters on failure === + +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1024 data_file=TEST_DIR/t.IMGFMT.data_file +write failed: Input/output error +No errors were found on the image. *** done
Signature · 1 line
2.17.1
PATCH 50/78 virtio: gracefully handle invalid region caches
In reply to Michael RothFrom: Stefan Hajnoczi <[email protected]>
The virtqueue code sets up MemoryRegionCaches to access the virtqueue guest RAM data structures. The code currently assumes that VRingMemoryRegionCaches is initialized before device emulation code accesses the virtqueue. An assertion will fail in vring_get_region_caches() when this is not true. Device fuzzing found a case where this assumption is false (see below).
Virtqueue guest RAM addresses can also be changed from a vCPU thread while an IOThread is accessing the virtqueue. This breaks the same assumption but this time the caches could become invalid partway through the virtqueue code. The code fetches the caches RCU pointer multiple times so we will need to validate the pointer every time it is fetched.
Add checks each time we call vring_get_region_caches() and treat invalid caches as a nop: memory stores are ignored and memory reads return 0.
The fuzz test failure is as follows:
$ qemu -M pc -device virtio-blk-pci,id=drv0,drive=drive0,addr=4.0 \
-drive if=none,id=drive0,file=null-co://,format=raw,auto-read-only=off \
-drive if=none,id=drive1,file=null-co://,file.read-zeroes=on,format=raw \
-display none \
-qtest stdio
endianness
outl 0xcf8 0x80002020
outl 0xcfc 0xe0000000
outl 0xcf8 0x80002004
outw 0xcfc 0x7
write 0xe0000000 0x24 0x00ffffffabffffffabffffffabffffffabffffffabffffffabffffffabffffffabffffffabffffffabffffffabffffffabffffffabffffffab5cffffffabffffffabffffffabffffffabffffffabffffffabffffffabffffffabffffffabffffffabffffffabffffffabffffffabffffffabffffffab0000000001
inb 0x4
writew 0xe000001c 0x1
write 0xe0000014 0x1 0x0dThe following error message is produced:
qemu-system-x86_64: /home/stefanha/qemu/hw/virtio/virtio.c:286: vring_get_region_caches: Assertion `caches != NULL' failed.
The backtrace looks like this:
#0 0x00007ffff5520625 in raise () at /lib64/libc.so.6 #1 0x00007ffff55098d9 in abort () at /lib64/libc.so.6 #2 0x00007ffff55097a9 in _nl_load_domain.cold () at /lib64/libc.so.6 #3 0x00007ffff5518a66 in annobin_assert.c_end () at /lib64/libc.so.6 #4 0x00005555559073da in vring_get_region_caches (vq=<optimized out>) at qemu/hw/virtio/virtio.c:286 #5 vring_get_region_caches (vq=<optimized out>) at qemu/hw/virtio/virtio.c:283 #6 0x000055555590818d in vring_used_flags_set_bit (mask=1, vq=0x5555575ceea0) at qemu/hw/virtio/virtio.c:398 #7 virtio_queue_split_set_notification (enable=0, vq=0x5555575ceea0) at qemu/hw/virtio/virtio.c:398 #8 virtio_queue_set_notification (vq=vq@entry=0x5555575ceea0, enable=enable@entry=0) at qemu/hw/virtio/virtio.c:451 #9 0x0000555555908512 in virtio_queue_set_notification (vq=vq@entry=0x5555575ceea0, enable=enable@entry=0) at qemu/hw/virtio/virtio.c:444
#10 0x00005555558c697a in virtio_blk_handle_vq (s=0x5555575c57e0, vq=0x5555575ceea0) at qemu/hw/block/virtio-blk.c:775 #11 0x0000555555907836 in virtio_queue_notify_aio_vq (vq=0x5555575ceea0) at qemu/hw/virtio/virtio.c:2244
#12 0x0000555555cb5dd7 in aio_dispatch_handlers (ctx=ctx@entry=0x55555671a420) at util/aio-posix.c:429
#13 0x0000555555cb67a8 in aio_dispatch (ctx=0x55555671a420) at util/aio-posix.c:460
#14 0x0000555555cb307e in aio_ctx_dispatch (source=<optimized out>, callback=<optimized out>, user_data=<optimized out>) at util/async.c:260 #15 0x00007ffff7bbc510 in g_main_context_dispatch () at /lib64/libglib-2.0.so.0
#16 0x0000555555cb5848 in glib_pollfds_poll () at util/main-loop.c:219
#17 os_host_main_loop_wait (timeout=<optimized out>) at util/main-loop.c:242
#18 main_loop_wait (nonblocking=<optimized out>) at util/main-loop.c:518
#19 0x00005555559b20c9 in main_loop () at vl.c:1683
#20 0x0000555555838115 in main (argc=<optimized out>, argv=<optimized out>, envp=<optimized out>) at vl.c:4441
Message-Id: <[email protected]>
--- hw/virtio/virtio.c | 99 ++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 91 insertions(+), 8 deletions(-)
hw/virtio/virtio.c +91 -8
@@ -282,15 +282,19 @@ static void vring_packed_flags_write(VirtIODevice *vdev,/* Called within rcu_read_lock(). */ static VRingMemoryRegionCaches *vring_get_region_caches (struct VirtQueue *vq) { -VRingMemoryRegionCaches *caches =atomic_rcu_read (&vq->vring.caches); -assert (caches !=NULL ); -return caches; +return atomic_rcu_read (&vq->vring.caches); } +/* Called within rcu_read_lock(). */ static inline uint16_t vring_avail_flags (VirtQueue *vq) {VRingMemoryRegionCaches *caches =vring_get_region_caches (vq);hwaddr pa = offsetof(VRingAvail , flags); + +if (!caches) { +return 0 ; + } +return virtio_lduw_phys_cached (vq->vdev, &caches->avail, pa); }
@@ -299,6 +303,11 @@ static inline uint16_t vring_avail_idx(VirtQueue *vq) {VRingMemoryRegionCaches *caches =vring_get_region_caches (vq);hwaddr pa = offsetof(VRingAvail , idx); + +if (!caches) { +return 0 ; + } + vq->shadow_avail_idx =virtio_lduw_phys_cached (vq->vdev, &caches->avail, pa);return vq->shadow_avail_idx; }
@@ -308,6 +317,11 @@ static inline uint16_t vring_avail_ring(VirtQueue *vq, int i) {VRingMemoryRegionCaches *caches =vring_get_region_caches (vq); hwaddr pa = offsetof(VRingAvail, ring[i]); + +if (!caches) { +return 0 ; + } +return virtio_lduw_phys_cached (vq->vdev, &caches->avail, pa); }
@@ -323,6 +337,11 @@ static inline void vring_used_write(VirtQueue *vq, VRingUsedElem *uelem, {VRingMemoryRegionCaches *caches =vring_get_region_caches (vq); hwaddr pa = offsetof(VRingUsed, ring[i]); + +if (!caches) { +return ; + } +virtio_tswap32s (vq->vdev, &uelem->id);virtio_tswap32s (vq->vdev, &uelem->len);address_space_write_cached (&caches->used, pa, uelem,sizeof (VRingUsedElem));
@@ -334,6 +353,11 @@ static uint16_t vring_used_idx(VirtQueue *vq) {VRingMemoryRegionCaches *caches =vring_get_region_caches (vq);hwaddr pa = offsetof(VRingUsed , idx); + +if (!caches) { +return 0 ; + } +return virtio_lduw_phys_cached (vq->vdev, &caches->used, pa); }
@@ -342,8 +366,12 @@ static inline void vring_used_idx_set(VirtQueue *vq, uint16_t val) {VRingMemoryRegionCaches *caches =vring_get_region_caches (vq);hwaddr pa = offsetof(VRingUsed , idx); -virtio_stw_phys_cached (vq->vdev, &caches->used, pa, val); -address_space_cache_invalidate (&caches->used, pa,sizeof (val)); + +if (caches) { +virtio_stw_phys_cached (vq->vdev, &caches->used, pa, val); +address_space_cache_invalidate (&caches->used, pa,sizeof (val)); + } + vq->used_idx = val; }
@@ -353,8 +381,13 @@ static inline void vring_used_flags_set_bit(VirtQueue *vq, int mask)VRingMemoryRegionCaches *caches =vring_get_region_caches (vq);VirtIODevice *vdev = vq->vdev;hwaddr pa = offsetof(VRingUsed , flags); -uint16_t flags =virtio_lduw_phys_cached (vq->vdev, &caches->used, pa); +uint16_t flags; +if (!caches) { +return ; + } + + flags =virtio_lduw_phys_cached (vq->vdev, &caches->used, pa);virtio_stw_phys_cached (vdev, &caches->used, pa, flags | mask);address_space_cache_invalidate (&caches->used, pa,sizeof (flags)); }
@@ -365,8 +398,13 @@ static inline void vring_used_flags_unset_bit(VirtQueue *vq, int mask)VRingMemoryRegionCaches *caches =vring_get_region_caches (vq);VirtIODevice *vdev = vq->vdev;hwaddr pa = offsetof(VRingUsed , flags); -uint16_t flags =virtio_lduw_phys_cached (vq->vdev, &caches->used, pa); +uint16_t flags; +if (!caches) { +return ; + } + + flags =virtio_lduw_phys_cached (vq->vdev, &caches->used, pa);virtio_stw_phys_cached (vdev, &caches->used, pa, flags & ~mask);address_space_cache_invalidate (&caches->used, pa,sizeof (flags)); }
@@ -381,6 +419,10 @@ static inline void vring_set_avail_event(VirtQueue *vq, uint16_t val) } caches =vring_get_region_caches (vq); +if (!caches) { +return ; + } + pa = offsetof(VRingUsed, ring[vq->vring.num]);virtio_stw_phys_cached (vq->vdev, &caches->used, pa, val);address_space_cache_invalidate (&caches->used, pa,sizeof (val));
@@ -410,7 +452,11 @@ static void virtio_queue_packed_set_notification(VirtQueue *vq, int enable)VRingMemoryRegionCaches *caches;RCU_READ_LOCK_GUARD (); - caches =vring_get_region_caches (vq); + caches =vring_get_region_caches (vq); +if (!caches) { +return ; + } +vring_packed_event_read (vq->vdev, &caches->used, &e);if (!enable) {
@@ -592,6 +638,10 @@ static int virtio_queue_packed_empty_rcu(VirtQueue *vq) } cache =vring_get_region_caches (vq); +if (!cache) { +return 1 ; + } +vring_packed_desc_read_flags (vq->vdev, &desc.flags, &cache->desc, vq->last_avail_idx);
@@ -772,6 +822,10 @@ static void virtqueue_packed_fill_desc(VirtQueue *vq, } caches =vring_get_region_caches (vq); +if (!caches) { +return ; + } +vring_packed_desc_write (vq->vdev, &desc, &caches->desc, head, strict_order); }
@@ -944,6 +998,10 @@ static void virtqueue_split_get_avail_bytes(VirtQueue *vq, max = vq->vring.num; caches =vring_get_region_caches (vq); +if (!caches) { + goto err; + } +while ((rc =virtqueue_num_heads (vq, idx)) >0 ) {MemoryRegionCache *desc_cache = &caches->desc;unsigned int num_bufs;
@@ -1084,6 +1142,9 @@ static void virtqueue_packed_get_avail_bytes(VirtQueue *vq, max = vq->vring.num; caches =vring_get_region_caches (vq); +if (!caches) { + goto err; + }for (;;) {unsigned int num_bufs = total_bufs;
@@ -1189,6 +1250,10 @@ void virtqueue_get_avail_bytes(VirtQueue *vq, unsigned int *in_bytes, } caches =vring_get_region_caches (vq); +if (!caches) { + goto err; + } + desc_size =virtio_vdev_has_feature (vq->vdev,VIRTIO_F_RING_PACKED ) ?sizeof (VRingPackedDesc) :sizeof (VRingDesc);if (caches->desc.len < vq->vring.num * desc_size) {
@@ -1382,6 +1447,11 @@ static void *virtqueue_split_pop(VirtQueue *vq, size_t sz) i = head; caches =vring_get_region_caches (vq); +if (!caches) { +virtio_error (vdev,"Region caches not initialized" ); + goto done; + } +if (caches->desc.len < max *sizeof (VRingDesc)) {virtio_error (vdev,"Cannot map descriptor ring" ); goto done;
@@ -1504,6 +1574,11 @@ static void *virtqueue_packed_pop(VirtQueue *vq, size_t sz) i = vq->last_avail_idx; caches =vring_get_region_caches (vq); +if (!caches) { +virtio_error (vdev,"Region caches not initialized" ); + goto done; + } +if (caches->desc.len < max *sizeof (VRingDesc)) {virtio_error (vdev,"Cannot map descriptor ring" ); goto done;
@@ -1623,6 +1698,10 @@ static unsigned int virtqueue_packed_drop_all(VirtQueue *vq)VRingPackedDesc desc; caches =vring_get_region_caches (vq); +if (!caches) { +return 0 ; + } + desc_cache = &caches->desc;virtio_queue_set_notification (vq,0 );
@@ -2406,6 +2485,10 @@ static bool virtio_packed_should_notify(VirtIODevice *vdev, VirtQueue *vq)VRingMemoryRegionCaches *caches; caches =vring_get_region_caches (vq); +if (!caches) { +return false; + } +vring_packed_event_read (vdev, &caches->avail, &e); old = vq->signalled_used;
Signature · 1 line
2.17.1
PATCH 51/78 scsi/qemu-pr-helper: Fix out-of-bounds access to trnptid_list[]
In reply to Michael RothFrom: Christophe de Dinechin <[email protected]>
Compile error reported by gcc 10.0.1:
scsi/qemu-pr-helper.c: In function ‘multipath_pr_out’:scsi/qemu-pr-helper.c:523:32: error: array subscript <unknown> is outside array bounds of ‘struct transportid *[0]’ [-Werror=array-bounds]
523 | paramp.trnptid_list[paramp.num_transportid++] = id;
| ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from scsi/qemu-pr-helper.c:36:
/usr/include/mpath_persist.h:168:22: note: while referencing ‘trnptid_list’
168 | struct transportid *trnptid_list[];
| ^~~~~~~~~~~~scsi/qemu-pr-helper.c:424:35: note: defined here ‘paramp’
424 | struct prout_param_descriptor paramp;
| ^~~~~~
This highlights an actual implementation issue in function multipath_pr_out. The variable paramp is declared with type struct prout_param_descriptor, which is a struct terminated by an empty array in mpath_persist.h:
struct transportid *trnptid_list[];
That empty array was filled with code that looked like that:
trnptid_list[paramp.descr.num_transportid++] = id;
This is an actual out-of-bounds access.
The fix is to malloc paramp.
--- scsi/qemu-pr-helper.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-)
scsi/qemu-pr-helper.c +10 -7
@@ -421,10 +421,13 @@ static int multipath_pr_out(int fd, const uint8_t *cdb, uint8_t *sense,int rq_servact = cdb[1 ];int rq_scope = cdb[2 ] >>4 ;int rq_type = cdb[2 ] &0xf ; -struct prout_param_descriptor paramp; + g_autofree struct prout_param_descriptor *paramp = NULL;char transportids[PR_HELPER_DATA_SIZE ];int r; + paramp =g_malloc0 (sizeof (struct prout_param_descriptor ) + +sizeof (struct transportid *) *MPATH_MX_TIDS ); +if (sz <PR_OUT_FIXED_PARAM_SIZE ) {/* Illegal request, Parameter list length error. This isn't fatal; * we have read the data, send an error without closing the socket.
@@ -454,10 +457,9 @@ static int multipath_pr_out(int fd, const uint8_t *cdb, uint8_t *sense,* used by libmpathpersist (which, of course, will immediately * do the opposite). */ -memset (¶mp,0 ,sizeof (paramp)); -memcpy (¶mp.key, ¶m[0 ],8 ); -memcpy (¶mp.sa_key, ¶m[8 ],8 ); - paramp.sa_flags = param[20 ]; +memcpy (¶mp->key, ¶m[0 ],8 ); +memcpy (¶mp->sa_key, ¶m[8 ],8 ); + paramp->sa_flags = param[20 ];if (sz >PR_OUT_FIXED_PARAM_SIZE ) {size_t transportid_len;int i, j;
@@ -520,12 +522,13 @@ static int multipath_pr_out(int fd, const uint8_t *cdb, uint8_t *sense, return CHECK_CONDITION; } - paramp.trnptid_list[paramp.num_transportid++] = id; +assert (paramp->num_transportid <MPATH_MX_TIDS ); + paramp->trnptid_list[paramp->num_transportid++] = id; } } r =mpath_persistent_reserve_out (fd, rq_servact, rq_scope, rq_type, - ¶mp, noisy, verbose); + paramp, noisy, verbose);return mpath_reconstruct_sense (fd, r, sense); }#endif
Signature · 1 line
2.17.1
PATCH 52/78 block/qcow2-threads: fix qcow2_decompress
In reply to Michael RothFrom: Vladimir Sementsov-Ogievskiy <[email protected]>
On success path we return what inflate() returns instead of 0. And it most probably works for Z_STREAM_END as it is positive, but is definitely broken for Z_BUF_ERROR.
While being here, switch to errno return code, to be closer to qcow2_compress API (and usual expectations).
Revert condition in if to be more positive. Drop dead initialization of ret.
Message-Id: <[email protected]>
--- block/qcow2-threads.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
block/qcow2-threads.c +7 -5
@@ -128,12 +128,12 @@ static ssize_t qcow2_compress(void *dest, size_t dest_size,* @src - source buffer, @src_size bytes * * Returns: 0 on success -* -1 on fail +* -EIO on fail */ static ssize_t qcow2_decompress (void *dest,size_t dest_size,const void *src,size_t src_size) { -int ret =0 ; +int ret;z_stream strm;memset (&strm,0 ,sizeof (strm));
@@ -144,17 +144,19 @@ static ssize_t qcow2_decompress(void *dest, size_t dest_size, ret =inflateInit2 (&strm,-12 );if (ret !=Z_OK ) { -return -1 ; +return -EIO ; } ret =inflate (&strm,Z_FINISH ); -if ((ret !=Z_STREAM_END && ret !=Z_BUF_ERROR ) || strm.avail_out !=0 ) { +if ((ret ==Z_STREAM_END || ret ==Z_BUF_ERROR ) && strm.avail_out ==0 ) {/* * We approve Z_BUF_ERROR because we need @dest buffer to be filled, but * @src buffer may be processed partly (because in qcow2 we know size of * compressed data with precision of one sector) */ - ret =-1 ; + ret =0 ; + }else { + ret = -EIO ; }inflateEnd (&strm);
Signature · 1 line
2.17.1
PATCH 53/78 job: refactor progress to separate object
In reply to Michael RothFrom: Vladimir Sementsov-Ogievskiy <[email protected]>
We need it in separate to pass to the block-copy object in the next commit.
Message-Id: <[email protected]>
--- blockjob.c | 16 +++++----- include/qemu/job.h | 11 ++----- include/qemu/progress_meter.h | 58 +++++++++++++++++++++++++++++++++++ job-qmp.c | 4 +-- job.c | 6 ++-- qemu-img.c | 6 ++-- 6 files changed, 76 insertions(+), 25 deletions(-) create mode 100644 include/qemu/progress_meter.h
blockjob.c +8 -8
@@ -298,8 +298,8 @@ BlockJobInfo *block_job_query(BlockJob *job, Error **errp) info->device =g_strdup (job->job.id); info->busy =atomic_read (&job->job.busy); info->paused = job->job.pause_count >0 ; - info->offset = job->job.progress_current; - info->len = job->job.progress_total; + info->offset = job->job.progress.current; + info->len = job->job.progress.total; info->speed = job->speed; info->io_status = job->iostatus; info->ready = job_is_ready(&job->job),
@@ -329,8 +329,8 @@ static void block_job_event_cancelled(Notifier *n, void *opaque)qapi_event_send_block_job_cancelled (job_type (&job->job), job->job.id, - job->job.progress_total, - job->job.progress_current, + job->job.progress.total, + job->job.progress.current, job->speed); }
@@ -349,8 +349,8 @@ static void block_job_event_completed(Notifier *n, void *opaque)qapi_event_send_block_job_completed (job_type (&job->job), job->job.id, - job->job.progress_total, - job->job.progress_current, + job->job.progress.total, + job->job.progress.current, job->speed, !!msg, msg);
@@ -378,8 +378,8 @@ static void block_job_event_ready(Notifier *n, void *opaque)qapi_event_send_block_job_ready (job_type (&job->job), job->job.id, - job->job.progress_total, - job->job.progress_current, + job->job.progress.total, + job->job.progress.current, job->speed); }
include/qemu/job.h +2 -9
@@ -28,6 +28,7 @@#include "qapi/qapi-types-job.h" #include "qemu/queue.h" +#include "qemu/progress_meter.h" #include "qemu/coroutine.h" #include "block/aio.h"
@@ -117,15 +118,7 @@ typedef struct Job {/** True if this job should automatically dismiss itself */ bool auto_dismiss; -/** -* Current progress. The unit is arbitrary as long as the ratio between -* progress_current and progress_total represents the estimated percentage -* of work already done. -*/ -int64_t progress_current; - -/** Estimated progress_current value at the completion of the job */ -int64_t progress_total; +ProgressMeter progress;/** * Return code from @run and/or @prepare callback(s).
include/qemu/progress_meter.h new file +58 -0
58 lines not on this page · raw message
job-qmp.c +2 -2
@@ -143,8 +143,8 @@ static JobInfo *job_query_single(Job *job, Error **errp) .id = g_strdup(job->id), .type = job_type(job), .status = job->status, - .current_progress = job->progress_current, - .total_progress = job->progress_total, + .current_progress = job->progress.current, + .total_progress = job->progress.total, .has_error = !!job->err, .error = job->err ? \ g_strdup(error_get_pretty(job->err)) : NULL,
job.c +3 -3
@@ -369,17 +369,17 @@ void job_unref(Job *job)void job_progress_update (Job *job,uint64_t done) { - job->progress_current += done; +progress_work_done (&job->progress, done); }void job_progress_set_remaining (Job *job,uint64_t remaining) { - job->progress_total = job->progress_current + remaining; +progress_set_remaining (&job->progress, remaining); }void job_progress_increase_remaining (Job *job,uint64_t delta) { - job->progress_total += delta; +progress_increase_remaining (&job->progress, delta); }void job_event_cancelled (Job *job)
qemu-img.c +3 -3
@@ -881,9 +881,9 @@ static void run_block_job(BlockJob *job, Error **errp)do {float progress =0.0f ;aio_poll (aio_context, true); -if (job->job.progress_total) { - progress = (float )job->job.progress_current / - job->job.progress_total *100.f ; +if (job->job.progress.total) { + progress = (float )job->job.progress.current / + job->job.progress.total *100.f ; }qemu_progress_print (progress,0 ); }while (!job_is_ready (&job->job) && !job_is_completed (&job->job));
Signature · 1 line
2.17.1
PATCH 54/78 block/block-copy: fix progress calculation
In reply to Michael RothFrom: Vladimir Sementsov-Ogievskiy <[email protected]>
Assume we have two regions, A and B, and region B is in-flight now, region A is not yet touched, but it is unallocated and should be skipped.
Correspondingly, as progress we have
total = A + B
current = 0
If we reset unallocated region A and call progress_reset_callback, it will calculate 0 bytes dirty in the bitmap and call job_progress_set_remaining, which will set
total = current + 0 = 0 + 0 = 0
So, B bytes are actually removed from total accounting. When job finishes we'll have
total = 0
current = B
, which doesn't sound good.
This is because we didn't considered in-flight bytes, actually when calculating remaining, we should have set (in_flight + dirty_bytes) as remaining, not only dirty_bytes.
To fix it, let's refactor progress calculation, moving it to block-copy itself instead of fixing callback. And, of course, track in_flight bytes count.
We still have to keep one callback, to maintain backup job bytes_read calculation, but it will go on soon, when we turn the whole backup process into one block_copy call.
Message-Id: <[email protected]>
--- block/backup.c | 13 ++----------- block/block-copy.c | 16 ++++++++++++---- include/block/block-copy.h | 15 +++++---------- 3 files changed, 19 insertions(+), 25 deletions(-)
block/backup.c +2 -11
@@ -57,15 +57,6 @@ static void backup_progress_bytes_callback(int64_t bytes, void *opaque)BackupBlockJob *s = opaque; s->bytes_read += bytes; -job_progress_update (&s->common.job, bytes); -} - -static void backup_progress_reset_callback (void *opaque) -{ -BackupBlockJob *s = opaque; -uint64_t estimate =bdrv_get_dirty_count (s->bcs->copy_bitmap); - -job_progress_set_remaining (&s->common.job, estimate); } static int coroutine_fn backup_do_cow(BackupBlockJob *job,
@@ -461,8 +452,8 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs, job->cluster_size = cluster_size; job->len = len; -block_copy_set_callbacks (bcs, backup_progress_bytes_callback, - backup_progress_reset_callback, job); +block_copy_set_progress_callback (bcs, backup_progress_bytes_callback, job); +block_copy_set_progress_meter (bcs, &job->common.job.progress);/* Required permissions are already taken by backup-top target */ block_job_add_bdrv(&job->common, "target", target, 0, BLK_PERM_ALL,
block/block-copy.c +12 -4
@@ -127,17 +127,20 @@ BlockCopyState *block_copy_state_new(BdrvChild *source, BdrvChild *target,return s; } -void block_copy_set_callbacks ( +void block_copy_set_progress_callback (BlockCopyState *s,ProgressBytesCallbackFunc progress_bytes_callback, -ProgressResetCallbackFunc progress_reset_callback,void *progress_opaque) { s->progress_bytes_callback = progress_bytes_callback; - s->progress_reset_callback = progress_reset_callback; s->progress_opaque = progress_opaque; } +void block_copy_set_progress_meter (BlockCopyState *s,ProgressMeter *pm) +{ + s->progress = pm; +} +/* * block_copy_do_copy *
@@ -269,7 +272,9 @@ int64_t block_copy_reset_unallocated(BlockCopyState *s,if (!ret) {bdrv_reset_dirty_bitmap (s->copy_bitmap, offset, bytes); - s->progress_reset_callback (s->progress_opaque); +progress_set_remaining (s->progress, +bdrv_get_dirty_count (s->copy_bitmap) + + s->in_flight_bytes); } *count = bytes;
@@ -331,15 +336,18 @@ int coroutine_fn block_copy(BlockCopyState *s,trace_block_copy_process (s, start);bdrv_reset_dirty_bitmap (s->copy_bitmap, start, chunk_end - start); + s->in_flight_bytes += chunk_end - start;co_get_from_shres (s->mem, chunk_end - start); ret =block_copy_do_copy (s, start, chunk_end, error_is_read);co_put_to_shres (s->mem, chunk_end - start); + s->in_flight_bytes -= chunk_end - start;if (ret <0 ) {bdrv_set_dirty_bitmap (s->copy_bitmap, start, chunk_end - start);break ; } +progress_work_done (s->progress, chunk_end - start); s->progress_bytes_callback (chunk_end - start, s->progress_opaque); start = chunk_end; ret =0 ;
include/block/block-copy.h +5 -10
@@ -26,7 +26,6 @@ typedef struct BlockCopyInFlightReq { } BlockCopyInFlightReq;typedef void (*ProgressBytesCallbackFunc )(int64_t bytes,void *opaque); -typedef void (*ProgressResetCallbackFunc )(void *opaque); typedef struct BlockCopyState { /* * BdrvChild objects are not owned or managed by block-copy. They are
@@ -36,6 +35,7 @@ typedef struct BlockCopyState {BdrvChild *source;BdrvChild *target;BdrvDirtyBitmap *copy_bitmap; +int64_t in_flight_bytes;int64_t cluster_size;bool use_copy_range;int64_t copy_size;
@@ -60,15 +60,9 @@ typedef struct BlockCopyState {*/ bool skip_unallocated; +ProgressMeter *progress;/* progress_bytes_callback: called when some copying progress is done. */ ProgressBytesCallbackFunc progress_bytes_callback; - -/* -* progress_reset_callback: called when some bytes reset from copy_bitmap -* (see @skip_unallocated above). The callee is assumed to recalculate how -* many bytes remain based on the dirty bit count of copy_bitmap. -*/ -ProgressResetCallbackFunc progress_reset_callback;void *progress_opaque;SharedResource *mem;
@@ -79,12 +73,13 @@ BlockCopyState *block_copy_state_new(BdrvChild *source, BdrvChild *target,BdrvRequestFlags write_flags, Error **errp); -void block_copy_set_callbacks ( +void block_copy_set_progress_callback (BlockCopyState *s,ProgressBytesCallbackFunc progress_bytes_callback, -ProgressResetCallbackFunc progress_reset_callback,void *progress_opaque); +void block_copy_set_progress_meter (BlockCopyState *s,ProgressMeter *pm); +void block_copy_state_free (BlockCopyState *s); int64_t block_copy_reset_unallocated(BlockCopyState *s,
Signature · 1 line
2.17.1
PATCH 55/78 target/ppc: Fix rlwinm on ppc64
In reply to Michael RothFrom: Vitaly Chikunov <[email protected]>
rlwinm cannot just AND with Mask if shift value is zero on ppc64 when Mask Begin is greater than Mask End and high bits are set to 1.
Note that PowerISA 3.0B says that for `rlwinm' ROTL32 is used, and ROTL32 is defined (in 3.3.14) so that rotated value should have two copies of lower word of the source value.
This seems to be another incarnation of the fix from 820724d170 ("target-ppc: Fix rlwimi, rlwinm, rlwnm again"), except I leave optimization when Mask value is less than 32 bits.
Message-Id: <[email protected]>
--- target/ppc/translate.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-)
target/ppc/translate.c +11 -9
@@ -1938,15 +1938,17 @@ static void gen_rlwinm(DisasContext *ctx) me +=32 ;#endif mask =MASK (mb, me); -if (sh ==0 ) { -tcg_gen_andi_tl (t_ra, t_rs, mask); - }else if (mask <=0xffffffffu ) { -TCGv_i32 t0 =tcg_temp_new_i32 (); -tcg_gen_trunc_tl_i32 (t0, t_rs); -tcg_gen_rotli_i32 (t0, t0, sh); -tcg_gen_andi_i32 (t0, t0, mask); -tcg_gen_extu_i32_tl (t_ra, t0); -tcg_temp_free_i32 (t0); +if (mask <=0xffffffffu ) { +if (sh ==0 ) { +tcg_gen_andi_tl (t_ra, t_rs, mask); + }else { +TCGv_i32 t0 =tcg_temp_new_i32 (); +tcg_gen_trunc_tl_i32 (t0, t_rs); +tcg_gen_rotli_i32 (t0, t0, sh); +tcg_gen_andi_i32 (t0, t0, mask); +tcg_gen_extu_i32_tl (t_ra, t0); +tcg_temp_free_i32 (t0); + } }else {#if defined(TARGET_PPC64 )tcg_gen_deposit_i64 (t_ra, t_rs, t_rs,32 ,32 );
Signature · 1 line
2.17.1
PATCH 56/78 block/io: fix bdrv_co_do_copy_on_readv
In reply to Michael RothFrom: Vladimir Sementsov-Ogievskiy <[email protected]>
Prior to 1143ec5ebf4 it was OK to qemu_iovec_from_buf() from aligned-up buffer to original qiov, as qemu_iovec_from_buf() will stop at qiov end anyway.
But after 1143ec5ebf4 we assume that bdrv_co_do_copy_on_readv works on part of original qiov, defined by qiov_offset and bytes. So we must not touch qiov behind qiov_offset+bytes bound. Fix it.
Message-id: [email protected]
--- block/io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
block/io.c +1 -1
@@ -1395,7 +1395,7 @@ static int coroutine_fn bdrv_co_do_copy_on_readv(BdrvChild *child,if (!(flags &BDRV_REQ_PREFETCH )) {qemu_iovec_from_buf (qiov, qiov_offset + progress, bounce_buffer + skip_bytes, - pnum - skip_bytes); +MIN (pnum - skip_bytes, bytes - progress)); } }else if (!(flags &BDRV_REQ_PREFETCH )) {/* Read directly into the destination */
Signature · 1 line
2.17.1
PATCH 57/78 compat: disable edid on correct virtio-gpu device
In reply to Michael RothFrom: Cornelia Huck <[email protected]>
Commit bb15791166c1 ("compat: disable edid on virtio-gpu base device") tried to disable 'edid' on the virtio-gpu base device. However, that device is not 'virtio-gpu', but 'virtio-gpu-device'. Fix it.
Message-id: [email protected]
--- hw/core/machine.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/core/machine.c +1 -1
@@ -37,7 +37,7 @@ GlobalProperty hw_compat_4_0[] = { { "secondary-vga", "edid", "false" }, { "bochs-display", "edid", "false" }, { "virtio-vga", "edid", "false" }, - { "virtio-gpu", "edid", "false" }, + { "virtio-gpu-device", "edid", "false" }, { "virtio-device", "use-started", "false" }, { "virtio-balloon-device", "qemu-4-0-config-size", "true" }, { "pl031", "migrate-tick-offset", "false" },
Signature · 1 line
2.17.1
PATCH 58/78 qga: Installer: Wait for installation to finish
In reply to Michael RothFrom: Basil Salman <[email protected]>
Installation might fail if we don't wait for the provider unregisteration process to finish.
--- qga/installer/qemu-ga.wxs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
qga/installer/qemu-ga.wxs +1 -1
@@ -81,7 +81,7 @@ Arguments="-d --retry-path" > </ServiceInstall> - <ServiceControl Id="StartService" Start="install" Stop="both" Remove="uninstall" Name="QEMU-GA" Wait="no" /> + <ServiceControl Id="StartService" Start="install" Stop="both" Remove="uninstall" Name="QEMU-GA" Wait="yes" /> </Component> <?ifdef var.InstallVss?> <Component Id="qga_vss_dll" Guid="{CB19C453-FABB-4BB1-ABAB-6B74F687BFBB}">
Signature · 1 line
2.17.1
PATCH 59/78 qga-win: Handle VSS_E_PROVIDER_ALREADY_REGISTERED error
In reply to Michael RothFrom: Sameeh Jubran <[email protected]>
This patch handles the case where VSS Provider is already registered, where in such case qga uninstalls the provider and registers it again.
--- qga/vss-win32/install.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+)
qga/vss-win32/install.cpp +11 -0
@@ -443,6 +443,17 @@ STDAPI DllRegisterServer(void) VSS_PROV_SOFTWARE, const_cast<WCHAR*>(QGA_PROVIDER_VERSION), g_gProviderVersion); + if (hr == (long int) VSS_E_PROVIDER_ALREADY_REGISTERED) { + DllUnregisterServer(); + hr = pVssAdmin->RegisterProvider(g_gProviderId, CLSID_QGAVSSProvider, + const_cast<WCHAR * > + (QGA_PROVIDER_LNAME), + VSS_PROV_SOFTWARE, + const_cast<WCHAR * > + (QGA_PROVIDER_VERSION), + g_gProviderVersion); + } + if (FAILED(hr)) { errmsg_dialog(hr, "RegisterProvider failed"); }
Signature · 1 line
2.17.1
PATCH 60/78 qga-win: prevent crash when executing guest-file-read with large count
In reply to Michael RothFrom: Basil Salman <[email protected]>
guest-file-read command is currently implemented to read from a
file handle count number of bytes. when executed with a very large count number qemu-ga crashes.
after some digging turns out that qemu-ga crashes after trying to allocate a buffer large enough to save the data read in it, the buffer was allocated using g_malloc0 which is not fail safe, and results a crash in case of failure. g_malloc0 was replaced with g_try_malloc0() which returns NULL on failure, A check was added for that case in order to prevent qemu-ga from crashing and to send a response to the qemu-ga client accordingly.
--- qga/commands-win32.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
qga/commands-win32.c +7 -1
@@ -342,7 +342,13 @@ GuestFileRead *qmp_guest_file_read(int64_t handle, bool has_count, } fh = gfh->fh; - buf =g_malloc0 (count+1 ); + buf =g_try_malloc0 (count +1 ); +if (!buf) { +error_setg (errp, +"failed to allocate sufficient memory " +"to complete the requested service" ); +return NULL ; + } is_ok =ReadFile (fh, buf, count, &read_count,NULL );if (!is_ok) {error_setg_win32 (errp,GetLastError (),"failed to read file" );
Signature · 1 line
2.17.1
PATCH 61/78 qga: Fix undefined C behavior
In reply to Michael RothFrom: Eric Blake <[email protected]>
The QAPI struct GuestFileWhence has a comment about how we are exploiting equivalent values between two different integer types shared in a union. But C says behavior is undefined on assignments to overlapping storage when the two types are not the same width, and indeed, 'int64_t value' and 'enum QGASeek name' are very likely to be different in width. Utilize a temporary variable to fix things.
--- qga/commands.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
qga/commands.c +7 -2
@@ -482,10 +482,15 @@ done:* the guest's SEEK_ constants. */ int ga_parse_whence (GuestFileWhence *whence,Error **errp) { -/* Exploit the fact that we picked values to match QGA_SEEK_*. */ +/* +* Exploit the fact that we picked values to match QGA_SEEK_*; +* however, we have to use a temporary variable since the union +* members may have different size. +*/ if (whence->type ==QTYPE_QSTRING ) { +int value = whence->u.name; whence->type =QTYPE_QNUM ; - whence->u.value = whence->u.name; + whence->u.value = value; }switch (whence->u.value) {case QGA_SEEK_SET :
Signature · 1 line
2.17.1
PATCH 62/78 qemu-ga: document vsock-listen in the man page
In reply to Michael RothFrom: Stefan Hajnoczi <[email protected]>
Although qemu-ga has supported vsock since 2016 it was not documented on the man page.
Also add the socket address representation to the qga --help output.
("qga: add vsock-listen method")
--- docs/interop/qemu-ga.rst | 5 +++-- qga/main.c | 4 +++- 2 files changed, 6 insertions(+), 3 deletions(-)
docs/interop/qemu-ga.rst +3 -2
@@ -36,13 +36,14 @@ Options .. option:: -m, --method=METHOD Transport method: one of ``unix-listen``, ``virtio-serial``, or - ``isa-serial`` (``virtio-serial`` is the default). + ``isa-serial``, or ``vsock-listen`` (``virtio-serial`` is the default). .. option:: -p, --path=PATH Device/socket path (the default for virtio-serial is ``/dev/virtio-ports/org.qemu.guest_agent.0``, - the default for isa-serial is ``/dev/ttyS0``) + the default for isa-serial is ``/dev/ttyS0``). Socket addresses for + vsock-listen are written as ``<cid>:<port>``. .. option:: -l, --logfile=PATH
qga/main.c +3 -1
@@ -234,7 +234,9 @@ QEMU_COPYRIGHT "\n"" -p, --path device/socket path (the default for virtio-serial is:\n" " %s,\n" " the default for isa-serial is:\n" -" %s)\n" +" %s).\n" +" Socket addresses for vsock-listen are written as\n" +" <cid>:<port>.\n" " -l, --logfile set logfile path, logs to stderr by default\n" " -f, --pidfile specify pidfile (default is %s)\n" #ifdef CONFIG_FSFREEZE
Signature · 1 line
2.17.1
PATCH 63/78 hw/i386/amd_iommu.c: Fix corruption of log events passed to guest
In reply to Michael RothFrom: Peter Maydell <[email protected]>
In the function amdvi_log_event(), we write an event log buffer entry into guest ram, whose contents are passed to the function via the "uint64_t *evt" argument. Unfortunately, a spurious '&' in the call to dma_memory_write() meant that instead of writing the event to the guest we would write the literal value of the pointer, plus whatever was in the following 8 bytes on the stack. This error was spotted by Coverity.
Fix the bug by removing the '&'.
Message-Id: <[email protected]>
--- hw/i386/amd_iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/i386/amd_iommu.c +1 -1
@@ -181,7 +181,7 @@ static void amdvi_log_event(AMDVIState *s, uint64_t *evt) }if (dma_memory_write (&address_space_memory, s->evtlog + s->evtlog_tail, - &evt,AMDVI_EVENT_LEN )) { + evt,AMDVI_EVENT_LEN )) {trace_amdvi_evntlog_fail (s->evtlog, s->evtlog_tail); }
Signature · 1 line
2.17.1
PATCH 64/78 tcg/i386: Fix INDEX_op_dup2_vec
In reply to Michael RothFrom: Richard Henderson <[email protected]>
We were only constructing the 64-bit element, and not replicating the 64-bit element across the rest of the vector.
--- tcg/i386/tcg-target.inc.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
tcg/i386/tcg-target.inc.c +7 -3
@@ -2855,9 +2855,13 @@ static void tcg_out_vec_op(TCGContext *s, TCGOpcode opc, goto gen_simd;#if TCG_TARGET_REG_BITS ==32 case INDEX_op_dup2_vec: -/* Constraints have already placed both 32-bit inputs in xmm regs. */ - insn =OPC_PUNPCKLDQ ; - goto gen_simd; +/* First merge the two 32-bit inputs to a single 64-bit element. */ +tcg_out_vex_modrm (s,OPC_PUNPCKLDQ , a0, a1, a2); +/* Then replicate the 64-bit elements across the rest of the vector. */ +if (type !=TCG_TYPE_V64 ) { +tcg_out_dup_vec (s, type,MO_64 , a0, a0); + } +break ;#endif case INDEX_op_abs_vec: insn = abs_insn[vece];
Signature · 1 line
2.17.1
PATCH 65/78 dump: Fix writing of ELF section
In reply to Michael RothFrom: Peter Maydell <[email protected]>
In write_elf_section() we set the 'shdr' pointer to point to local structures shdr32 or shdr64, which we fill in to be written out to the ELF dump. Unfortunately the address we pass to fd_write_vmcore() has a spurious '&' operator, so instead of writing out the section header we write out the literal pointer value followed by whatever is on the stack after the 'shdr' local variable.
Pass the correct address into fd_write_vmcore().
Spotted by Coverity: CID 1421970.
Message-id: [email protected]
--- dump/dump.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
dump/dump.c +1 -1
@@ -364,7 +364,7 @@ static void write_elf_section(DumpState *s, int type, Error **errp) shdr = &shdr64; } - ret =fd_write_vmcore (&shdr, shdr_size, s); + ret =fd_write_vmcore (shdr, shdr_size, s);if (ret <0 ) {error_setg_errno (errp, -ret,"dump: failed to write section header table" );
Signature · 1 line
2.17.1
PATCH 66/78 xen-block: Fix double qlist remove and request leak
In reply to Michael RothFrom: Anthony PERARD <[email protected]>
Commit a31ca6801c02 ("qemu/queue.h: clear linked list pointers on remove") revealed that a request was removed twice from a list, once in xen_block_finish_request() and a second time in xen_block_release_request() when both function are called from xen_block_complete_aio(). But also, the `requests_inflight' counter is decreased twice, and thus became negative.
This is a bug that was introduced in bfd0d6366043 ("xen-block: improve response latency"), where a `finished' list was removed.
That commit also introduced a leak of request in xen_block_do_aio(). That function calls xen_block_finish_request() but the request is never released after that.
To fix both issue, we do two changes:
- we squash finish_request() and release_request() together as we want to remove a request from 'inflight' list to add it to 'freelist'.
- before releasing a request, we need to let the other end know the result, thus we should call xen_block_send_response() before releasing a request.
The first change fixes the double QLIST_REMOVE() as we remove the extra call. The second change makes the leak go away because if we want to call finish_request(), we need to call a function that does all of finish, send response, and release.
Message-Id: <[email protected]>
--- hw/block/dataplane/xen-block.c | 48 ++++++++++++---------------------- 1 file changed, 16 insertions(+), 32 deletions(-)
hw/block/dataplane/xen-block.c +16 -32
@@ -64,6 +64,8 @@ struct XenBlockDataPlane {AioContext *ctx; }; +static int xen_block_send_response (XenBlockRequest *request); +static void reset_request (XenBlockRequest *request) {memset (&request->req,0 ,sizeof (request->req));
@@ -115,23 +117,26 @@ out:return request; } -static void xen_block_finish_request (XenBlockRequest *request) +static void xen_block_complete_request (XenBlockRequest *request) {XenBlockDataPlane *dataplane = request->dataplane; -QLIST_REMOVE (request, list); - dataplane->requests_inflight--; -} +if (xen_block_send_response (request)) { +Error *local_err =NULL ; -static void xen_block_release_request (XenBlockRequest *request) -{ -XenBlockDataPlane *dataplane = request->dataplane; +xen_device_notify_event_channel (dataplane->xendev, + dataplane->event_channel, + &local_err); +if (local_err) { +error_report_err (local_err); + } + }QLIST_REMOVE (request, list); + dataplane->requests_inflight--;reset_request (request); request->dataplane = dataplane;QLIST_INSERT_HEAD (&dataplane->freelist, request, list); - dataplane->requests_inflight--; }/*
@@ -246,7 +251,6 @@ static int xen_block_copy_request(XenBlockRequest *request) }static int xen_block_do_aio (XenBlockRequest *request); -static int xen_block_send_response (XenBlockRequest *request);static void xen_block_complete_aio (void *opaque,int ret) {
@@ -286,7 +290,6 @@ static void xen_block_complete_aio(void *opaque, int ret) } request->status = request->aio_errors ?BLKIF_RSP_ERROR :BLKIF_RSP_OKAY ; -xen_block_finish_request (request);switch (request->req.operation) {case BLKIF_OP_WRITE :
@@ -306,17 +309,8 @@ static void xen_block_complete_aio(void *opaque, int ret)default :break ; } -if (xen_block_send_response (request)) { -Error *local_err =NULL ; -xen_device_notify_event_channel (dataplane->xendev, - dataplane->event_channel, - &local_err); -if (local_err) { -error_report_err (local_err); - } - } -xen_block_release_request (request); +xen_block_complete_request (request);if (dataplane->more_work) {qemu_bh_schedule (dataplane->bh);
@@ -420,8 +414,8 @@ static int xen_block_do_aio(XenBlockRequest *request)return 0 ; err: -xen_block_finish_request (request); request->status =BLKIF_RSP_ERROR ; +xen_block_complete_request (request);return -1 ; }
@@ -575,17 +569,7 @@ static bool xen_block_handle_requests(XenBlockDataPlane *dataplane)break ; }; -if (xen_block_send_response (request)) { -Error *local_err =NULL ; - -xen_device_notify_event_channel (dataplane->xendev, - dataplane->event_channel, - &local_err); -if (local_err) { -error_report_err (local_err); - } - } -xen_block_release_request (request); +xen_block_complete_request (request);continue ; }
Signature · 1 line
2.17.1
PATCH 67/78 vhost-user-gpu: Release memory returned by vu_queue_pop() with free()
In reply to Michael RothFrom: Philippe Mathieu-Daudé <[email protected]>
vu_queue_pop() returns memory that must be freed with free().
--- contrib/vhost-user-gpu/main.c | 4 ++-- contrib/vhost-user-gpu/virgl.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
contrib/vhost-user-gpu/main.c +2 -2
@@ -848,7 +848,7 @@ vg_handle_ctrl(VuDev *dev, int qidx)QTAILQ_INSERT_TAIL (&vg->fenceq, cmd, next); vg->inflight++; }else { -g_free (cmd); +free (cmd); } } }
@@ -939,7 +939,7 @@ vg_handle_cursor(VuDev *dev, int qidx) }vu_queue_push (dev, vq, elem,0 );vu_queue_notify (dev, vq); -g_free (elem); +free (elem); } }
contrib/vhost-user-gpu/virgl.c +1 -1
@@ -519,7 +519,7 @@ virgl_write_fence(void *opaque, uint32_t fence)g_debug ("FENCE %" PRIu64, cmd->cmd_hdr.fence_id);vg_ctrl_response_nodata (g, cmd,VIRTIO_GPU_RESP_OK_NODATA );QTAILQ_REMOVE (&g->fenceq, cmd, next); -g_free (cmd); +free (cmd); g->inflight--; } }
Signature · 1 line
2.17.1
PATCH 68/78 target/ppc: Fix mtmsr(d) L=1 variant that loses interrupts
In reply to Michael RothFrom: Nicholas Piggin <[email protected]>
If mtmsr L=1 sets MSR[EE] while there is a maskable exception pending, it does not cause an interrupt. This causes the test case to hang:
https://lists.gnu.org/archive/html/qemu-ppc/2019-10/msg00826.html
More recently, Linux reduced the occurance of operations (e.g., rfi) which stop translation and allow pending interrupts to be processed. This started causing hangs in Linux boot in long-running kernel tests, running with '-d int' shows the decrementer stops firing despite DEC wrapping and MSR[EE]=1.
https://lists.ozlabs.org/pipermail/linuxppc-dev/2020-April/208301.html
The cause is the broken mtmsr L=1 behaviour, which is contrary to the architecture. From Power ISA v3.0B, p.977, Move To Machine State Register, Programming Note states:
If MSR[EE]=0 and an External, Decrementer, or Performance Monitor exception is pending, executing an mtmsrd instruction that sets MSR[EE] to 1 will cause the interrupt to occur before the next instruction is executed, if no higher priority exception exists
Fix this by handling L=1 exactly the same way as L=0, modulo the MSR bits altered.
The confusion arises from L=0 being "context synchronizing" whereas L=1 is "execution synchronizing", which is a weaker semantic. However this is not a relaxation of the requirement that these exceptions cause interrupts when MSR[EE]=1 (e.g., when mtmsr executes to completion as TCG is doing here), rather it specifies how a pipelined processor can have multiple instructions in flight where one may influence how another behaves.
Message-Id: <[email protected]>
--- target/ppc/translate.c | 46 +++++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 19 deletions(-)
target/ppc/translate.c +27 -19
@@ -4361,30 +4361,34 @@ static void gen_mtmsrd(DisasContext *ctx)CHK_SV ;#if !defined(CONFIG_USER_ONLY ) +if (tb_cflags (ctx->base.tb) &CF_USE_ICOUNT ) { +gen_io_start (); + }if (ctx->opcode &0x00010000 ) { -/* Special form that does not need any synchronisation */ +/* L=1 form only updates EE and RI */ TCGv t0 =tcg_temp_new (); +TCGv t1 =tcg_temp_new ();tcg_gen_andi_tl (t0, cpu_gpr[rS (ctx->opcode)], (1 <<MSR_RI ) | (1 <<MSR_EE )); -tcg_gen_andi_tl (cpu_msr, cpu_msr, +tcg_gen_andi_tl (t1, cpu_msr, ~(target_ulong)((1 <<MSR_RI ) | (1 <<MSR_EE ))); -tcg_gen_or_tl (cpu_msr, cpu_msr, t0); +tcg_gen_or_tl (t1, t1, t0); + +gen_helper_store_msr (cpu_env, t1);tcg_temp_free (t0); +tcg_temp_free (t1); + }else {/* * XXX: we need to update nip before the store if we enter * power saving mode, we will exit the loop directly from * ppc_store_msr */ -if (tb_cflags (ctx->base.tb) &CF_USE_ICOUNT ) { -gen_io_start (); - }gen_update_nip (ctx, ctx->base.pc_next);gen_helper_store_msr (cpu_env, cpu_gpr[rS (ctx->opcode)]); -/* Must stop the translation as machine state (may have) changed */ -/* Note that mtmsr is not always defined as context-synchronizing */ -gen_stop_exception (ctx); } +/* Must stop the translation as machine state (may have) changed */ +gen_stop_exception (ctx); #endif /* !defined(CONFIG_USER_ONLY) */ }#endif /* defined(TARGET_PPC64) */
@@ -4394,15 +4398,23 @@ static void gen_mtmsr(DisasContext *ctx)CHK_SV ;#if !defined(CONFIG_USER_ONLY ) -if (ctx->opcode &0x00010000 ) { -/* Special form that does not need any synchronisation */ +if (tb_cflags (ctx->base.tb) &CF_USE_ICOUNT ) { +gen_io_start (); + } +if (ctx->opcode &0x00010000 ) { +/* L=1 form only updates EE and RI */ TCGv t0 =tcg_temp_new (); +TCGv t1 =tcg_temp_new ();tcg_gen_andi_tl (t0, cpu_gpr[rS (ctx->opcode)], (1 <<MSR_RI ) | (1 <<MSR_EE )); -tcg_gen_andi_tl (cpu_msr, cpu_msr, +tcg_gen_andi_tl (t1, cpu_msr, ~(target_ulong)((1 <<MSR_RI ) | (1 <<MSR_EE ))); -tcg_gen_or_tl (cpu_msr, cpu_msr, t0); +tcg_gen_or_tl (t1, t1, t0); + +gen_helper_store_msr (cpu_env, t1);tcg_temp_free (t0); +tcg_temp_free (t1); + }else {TCGv msr =tcg_temp_new ();
@@ -4411,9 +4423,6 @@ static void gen_mtmsr(DisasContext *ctx)* power saving mode, we will exit the loop directly from * ppc_store_msr */ -if (tb_cflags (ctx->base.tb) &CF_USE_ICOUNT ) { -gen_io_start (); - }gen_update_nip (ctx, ctx->base.pc_next);#if defined(TARGET_PPC64 )tcg_gen_deposit_tl (msr, cpu_msr, cpu_gpr[rS (ctx->opcode)],0 ,32 );
@@ -4422,10 +4431,9 @@ static void gen_mtmsr(DisasContext *ctx)#endif gen_helper_store_msr (cpu_env, msr); tcg_temp_free(msr); -/* Must stop the translation as machine state (may have) changed */ -/* Note that mtmsr is not always defined as context-synchronizing */ - gen_stop_exception(ctx); } +/* Must stop the translation as machine state (may have) changed */ +gen_stop_exception (ctx);#endif }
Signature · 1 line
2.17.1
PATCH 69/78 hostmem: don't use mbind() if host-nodes is empty
In reply to Michael RothFrom: Igor Mammedov <[email protected]>
Since 5.0 QEMU uses hostmem backend for allocating main guest RAM. The backend however calls mbind() which is typically NOP in case of default policy/absent host-nodes bitmap. However when runing in container with black-listed mbind() syscall, QEMU fails to start with error
"cannot bind memory to host NUMA nodes: Operation not permitted"
even when user hasn't provided host-nodes to pin to explictly (which is the case with -m option)
To fix issue, call mbind() only in case when user has provided host-nodes explicitly (i.e. host_nodes bitmap is not empty). That should allow to run QEMU in containers with black-listed mbind() without memory pinning. If QEMU provided memory-pinning is required user still has to white-list mbind() in container configuration.
Message-Id: <[email protected]>
--- backends/hostmem.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
backends/hostmem.c +4 -2
@@ -363,8 +363,10 @@ host_memory_backend_memory_complete(UserCreatable *uc, Error **errp)assert (sizeof (backend->host_nodes) >=BITS_TO_LONGS (MAX_NODES +1 ) *sizeof (unsigned long ));assert (maxnode <=MAX_NODES ); -if (mbind (ptr, sz, backend->policy, - maxnode ? backend->host_nodes :NULL , maxnode +1 , flags)) { + +if (maxnode && +mbind (ptr, sz, backend->policy, backend->host_nodes, maxnode +1 , + flags)) {if (backend->policy !=MPOL_DEFAULT || errno !=ENOSYS ) {error_setg_errno (errp, errno,"cannot bind memory to host NUMA nodes" );
Signature · 1 line
2.17.1
PATCH 70/78 target/arm: Clear tail in gvec_fmul_idx_*, gvec_fmla_idx_*
In reply to Michael RothFrom: Richard Henderson <[email protected]>
Must clear the tail for AdvSIMD when SVE is enabled.
Message-id: [email protected]
--- target/arm/vec_helper.c | 2 ++ 1 file changed, 2 insertions(+)
target/arm/vec_helper.c +2 -0
@@ -737,6 +737,7 @@ void HELPER(NAME)(void *vd, void *vn, void *vm, void *stat, uint32_t desc) \ d[i + j] = TYPE##_mul(n[i + j], mm, stat); \ } \ } \ +clear_tail (d, oprsz,simd_maxsz (desc)); \ }DO_MUL_IDX (gvec_fmul_idx_h, float16,H2 )
@@ -761,6 +762,7 @@ void HELPER(NAME)(void *vd, void *vn, void *vm, void *va, \ mm, a[i + j], 0, stat); \ } \ } \ +clear_tail (d, oprsz,simd_maxsz (desc)); \ }DO_FMLA_IDX (gvec_fmla_idx_h, float16,H2 )
Signature · 1 line
2.17.1
PATCH 71/78 qemu-nbd: Close inherited stderr
In reply to Michael RothFrom: Raphael Pour <[email protected]>
Close inherited stderr of the parent if fork_process is false. Otherwise no one will close it. (introduced by e6df58a5)
This only affected 'qemu-nbd -c /dev/nbd0'.
Message-Id: <[email protected]>
--- qemu-nbd.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
qemu-nbd.c +5 -1
@@ -1022,7 +1022,11 @@ int main(int argc, char **argv) }else if (pid ==0 ) {close (stderr_fd[0 ]); - old_stderr =dup (STDERR_FILENO ); +/* Remember parent's stderr if we will be restoring it. */ +if (fork_process) { + old_stderr =dup (STDERR_FILENO ); + } + ret =qemu_daemon (1 ,0 );/* Temporarily redirect stderr to the parent's pipe... */
Signature · 1 line
2.17.1
PATCH 72/78 9p: Lock directory streams with a CoMutex
In reply to Michael RothFrom: Greg Kurz <[email protected]>
Locking was introduced in QEMU 2.7 to address the deprecation of readdir_r(3) in glibc 2.24. It turns out that the frontend code is the worst place to handle a critical section with a pthread mutex:
the code runs in a coroutine on behalf of the QEMU mainloop and then yields control, waiting for the fsdev backend to process the request in a worker thread. If the client resends another readdir request for the same fid before the previous one finally unlocked the mutex, we're deadlocked.
This never bit us because the linux client serializes readdir requests for the same fid, but it is quite easy to demonstrate with a custom client.
A good solution could be to narrow the critical section in the worker thread code and to return a copy of the dirent to the frontend, but this causes quite some changes in both 9p.c and codir.c. So, instead of that, in order for people to easily backport the fix to older QEMU versions, let's simply use a CoMutex since all the users for this sit in coroutines.
Message-Id: <[email protected]>
--- hw/9pfs/9p.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
hw/9pfs/9p.h +4 -4
@@ -186,22 +186,22 @@ typedef struct V9fsXattrtypedef struct V9fsDir {DIR *stream; -QemuMutex readdir_mutex; +CoMutex readdir_mutex; }V9fsDir ;static inline void v9fs_readdir_lock (V9fsDir *dir) { -qemu_mutex_lock (&dir->readdir_mutex); +qemu_co_mutex_lock (&dir->readdir_mutex); }static inline void v9fs_readdir_unlock (V9fsDir *dir) { -qemu_mutex_unlock (&dir->readdir_mutex); +qemu_co_mutex_unlock (&dir->readdir_mutex); }static inline void v9fs_readdir_init (V9fsDir *dir) { -qemu_mutex_init (&dir->readdir_mutex); +qemu_co_mutex_init (&dir->readdir_mutex); }/*
Signature · 1 line
2.17.1
Re: [PATCH 72/78] 9p: Lock directory streams with a CoMutex
Cc'ing co-maintainer Christian Schoenebeck.
Christian,
If there are some more commits you think are worth being cherry picked for QEMU 4.2.1, please inform Michael before freeze on 2020-06-22.
Cheers,
--
Greg
Quoted 63 lines · On Tue, 16 Jun 2020 09:15:41 -0500 Michael Roth <[email protected]>…
From: Greg Kurz <[email protected]>
Locking was introduced in QEMU 2.7 to address the deprecation of
readdir_r(3)in glibc 2.24. It turns out that the frontend code is the worst place to handle a critical section with a pthread mutex:
the code runs in a coroutine on behalf of the QEMU mainloop and then yields control, waiting for the fsdev backend to process the request in a worker thread. If the client resends another readdir request for the same fid before the previous one finally unlocked the mutex, we're deadlocked.This never bit us because the linux client serializes readdir requests for the same fid, but it is quite easy to demonstrate with a custom client.
A good solution could be to narrow the critical section in the worker thread code and to return a copy of the dirent to the frontend, but this causes quite some changes in both
9p.candcodir.c. So, instead of that, in order for people to easily backport the fix to older QEMU versions, let's simply use a CoMutex since all the users for this sit in coroutines.Fixes 7cde47d4a89d ("9p: add locking to V9fsDir")Reviewed-by Christian Schoenebeck <[email protected]>Message-Id: <[email protected]>
Signed-off-by Greg Kurz <[email protected]>(cherry picked from commit ed463454efd0ac3042ff772bfe1b1d846dc281a5)Signed-off-by Michael Roth <[email protected]>--- hw/9pfs/9p.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)hw/9pfs/9p.h +4
-4@@ -186,22 +186,22 @@ typedef struct V9fsXattrtypedef struct V9fsDir {DIR *stream; -QemuMutex readdir_mutex; +CoMutex readdir_mutex; }V9fsDir ;static inline void v9fs_readdir_lock (V9fsDir *dir) { -qemu_mutex_lock (&dir->readdir_mutex); +qemu_co_mutex_lock (&dir->readdir_mutex); }static inline void v9fs_readdir_unlock (V9fsDir *dir) { -qemu_mutex_unlock (&dir->readdir_mutex); +qemu_co_mutex_unlock (&dir->readdir_mutex); }static inline void v9fs_readdir_init (V9fsDir *dir) { -qemu_mutex_init (&dir->readdir_mutex); +qemu_co_mutex_init (&dir->readdir_mutex); }/*
Re: [PATCH 72/78] 9p: Lock directory streams with a CoMutex
Quoted 6 lines · On Dienstag, 16. Juni 2020 17:14:40 CEST Greg Kurz wrote:
Cc'ing co-maintainer Christian Schoenebeck.
Christian,
If there are some more commits you think are worth being cherry picked for QEMU 4.2.1, please inform Michael before freeze on 2020-06-22.
Indeed, for that particular stable branch I would see the following 9p fixes as additional candidates (chronologically top down):
841b8d099c [trivial] 9pfs: local: Fix possible memory leak in local_link() 846cf408a4 [maybe] 9p: local: always return -1 on error in local_unlinkat_common 9580d60e66 [maybe] virtio-9p-device: fix memleak in virtio_9p_device_unrealize 659f195328 [trivial] 9p/proxy: Fix export_flagsa5804fcf7b [maybe] 9pfs: local: ignore O_NOATIME if we don't have permissions 03556ea920 [trivial] 9pfs: include linux/limits.h for XATTR_SIZE_MAX a4c4d46272 [recommended] xen/9pfs: yield when there isn't enough room on the ring
What do you think Greg?
What's the recommended way for me to keep track of imminent stable picks/ freezes in future?
Best regards,
Christian Schoenebeck
Re: [PATCH 72/78] 9p: Lock directory streams with a CoMutex
Quoted 19 lines · On Tue, 16 Jun 2020 18:09:04 +0200 Christian Schoenebeck…
Quoted 6 lines · On Dienstag, 16. Juni 2020 17:14:40 CEST Greg Kurz wrote:
Cc'ing co-maintainer Christian Schoenebeck.
Christian,
If there are some more commits you think are worth being cherry picked for QEMU 4.2.1, please inform Michael before freeze on 2020-06-22.
Indeed, for that particular stable branch I would see the following 9p fixes as additional candidates (chronologically top down):
841b8d099c[trivial] 9pfs: local: Fix possible memory leak inlocal_link()846cf408a4[maybe] 9p: local: always return -1 on error inlocal_unlinkat_common9580d60e66[maybe] virtio-9p-device: fix memleak invirtio_9p_device_unrealize659f195328[trivial] 9p/proxy: Fixexport_flagsa5804fcf7b[maybe] 9pfs: local: ignoreO_NOATIMEif we don't have permissions03556ea920[trivial] 9pfs: includelinux/limits.hforXATTR_SIZE_MAXa4c4d46272[recommended] xen/9pfs: yield when there isn't enough room on the ring
Quoted 2 lines
What do you think Greg?
AFAIK, only regressions and fixes to severe bugs (QEMU crashes, hangs, CVEs) go to stable QEMU releases. It doesn't seem to be the case for any of the commits listed above but I had only a quick look.
Quoted 3 lines
What's the recommended way for me to keep track of imminent stable picks/ freezes in future?
Hmm good question. I'm usually notified when Michael posts the patch round-up and a 9p patch is already in the list, like for the present patch. Other than that I watch qemu-stable from time to time or the planning pages in the wiki.
Michael, anything better to suggest to Christian ?
Quoted 4 lines
Best regards,
Christian Schoenebeck
Re: [PATCH 72/78] 9p: Lock directory streams with a CoMutex
Quoting Greg Kurz (2020-06-16 11:41:36)
Quoted 22 lines
Quoted 19 lines · On Tue, 16 Jun 2020 18:09:04 +0200 Christian Schoenebeck…
Quoted 6 lines · On Dienstag, 16. Juni 2020 17:14:40 CEST Greg Kurz wrote:
Cc'ing co-maintainer Christian Schoenebeck.
Christian,
If there are some more commits you think are worth being cherry picked for QEMU 4.2.1, please inform Michael before freeze on 2020-06-22.
Indeed, for that particular stable branch I would see the following 9p fixes as additional candidates (chronologically top down):
841b8d099c[trivial] 9pfs: local: Fix possible memory leak inlocal_link()846cf408a4[maybe] 9p: local: always return -1 on error inlocal_unlinkat_common9580d60e66[maybe] virtio-9p-device: fix memleak invirtio_9p_device_unrealize659f195328[trivial] 9p/proxy: Fixexport_flagsa5804fcf7b[maybe] 9pfs: local: ignoreO_NOATIMEif we don't have permissions03556ea920[trivial] 9pfs: includelinux/limits.hforXATTR_SIZE_MAXa4c4d46272[recommended] xen/9pfs: yield when there isn't enough room on the ring
Quoted 6 lines
Quoted 2 lines
What do you think Greg?
AFAIK, only regressions and fixes to severe bugs (QEMU crashes, hangs, CVEs) go to stable QEMU releases. It doesn't seem to be the case for any of the commits listed above but I had only a quick look.
That's the main focus, but if memory leaks and other minor fixes get tagged for stable I'll generally pull those in as well if the backport is fairly straightforward. As that was the case with the patches above I went ahead and pull those in.
Quoted 10 lines
Quoted 4 lines
What's the recommended way for me to keep track of imminent stable picks/ freezes in future?
Hmm good question. I'm usually notified when Michael posts the patch round-up and a 9p patch is already in the list, like for the present patch. Other than that I watch qemu-stable from time to time or the planning pages in the wiki.
Michael, anything better to suggest to Christian ?
I think that about covers it. You can also subscribe to the planning pages, e.g. https://wiki.qemu.org/Planning/5.0 (by clicking the star/"add to watchlist" icon), then you'll get notifications when additional release/freeze dates are added. Generally it will be updated shortly before the patch round-up gets posted to qemu-stable.
Quoted 6 lines
Quoted 5 lines
Best regards,
Christian Schoenebeck
Re: [PATCH 72/78] 9p: Lock directory streams with a CoMutex
Quoted 34 lines · On Mittwoch, 17. Juni 2020 00:46:26 CEST Michael Roth wrote:
Quoted 14 lines
Quoted 14 lines
Indeed, for that particular stable branch I would see the following 9p fixes as additional candidates (chronologically top down):
841b8d099c[trivial] 9pfs: local: Fix possible memory leak inlocal_link()846cf408a4[maybe] 9p: local: always return -1 on error inlocal_unlinkat_common9580d60e66[maybe] virtio-9p-device: fix memleak invirtio_9p_device_unrealize659f195328[trivial] 9p/proxy: Fixexport_flagsa5804fcf7b[maybe] 9pfs: local: ignoreO_NOATIMEif we don't have permissions03556ea920[trivial] 9pfs: includelinux/limits.hforXATTR_SIZE_MAXa4c4d46272[recommended] xen/9pfs: yield when there isn't enough room on the ringQuoted 5 lines
Quoted 1 line
What do you think Greg?
AFAIK, only regressions and fixes to severe bugs (QEMU crashes, hangs, CVEs) go to stable QEMU releases. It doesn't seem to be the case for any of the commits listed above but I had only a quick look.
That's the main focus, but if memory leaks and other minor fixes get tagged for stable I'll generally pull those in as well if the backport is fairly straightforward. As that was the case with the patches above I went ahead and pull those in.
Quoted 9 lines
Quoted 3 lines
What's the recommended way for me to keep track of imminent stable picks/
freezes in future?Hmm good question. I'm usually notified when Michael posts the patch round-up and a 9p patch is already in the list, like for the present patch. Other than that I watch qemu-stable from time to time or the planning pages in the wiki.
Quoted 7 lines
Quoted 1 line
Michael, anything better to suggest to Christian ?
I think that about covers it. You can also subscribe to the planning pages, e.g. https://wiki.qemu.org/Planning/5.0 (by clicking the star/"add to watchlist" icon), then you'll get notifications when additional release/freeze dates are added. Generally it will be updated shortly before the patch round-up gets posted to qemu-stable.
Good idea! Will do that.
Thanks Michael!
Best regards,
Christian Schoenebeck
PATCH 73/78 net: Do not include a newline in the id of -nic devices
In reply to Michael RothFrom: Thomas Huth <[email protected]>
The '\n' sneaked in by accident here, an "id" string should really not contain a newline character at the end.
Message-Id: <[email protected]>
--- net/net.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/net.c +1 -1
@@ -1524,7 +1524,7 @@ static int net_param_nic(void *dummy, QemuOpts *opts, Error **errp)/* Create an ID if the user did not specify one */ nd_id =g_strdup (qemu_opts_id (opts));if (!nd_id) { - nd_id =g_strdup_printf ("__org.qemu.nic%i\n" , idx); + nd_id =g_strdup_printf ("__org.qemu.nic%i" , idx);qemu_opts_set_id (opts, nd_id); }
Signature · 1 line
2.17.1
PATCH 74/78 nbd/server: Avoid long error message assertions CVE-2020-10761
In reply to Michael RothFrom: Eric Blake <[email protected]>
Ever since commit 36683283 (v2.8), the server code asserts that error strings sent to the client are well-formed per the protocol by not exceeding the maximum string length of 4096. At the time the server first started sending error messages, the assertion could not be triggered, because messages were completely under our control. However, over the years, we have added latent scenarios where a client could trigger the server to attempt an error message that would include the client's information if it passed other checks first:
- requesting NBD_OPT_INFO/GO on an export name that is not present (commit 0cfae925 in v2.12 echoes the name)
- requesting NBD_OPT_LIST/SET_META_CONTEXT on an export name that is not present (commit e7b1948d in v2.12 echoes the name)
At the time, those were still safe because we flagged names larger than 256 bytes with a different message; but that changed in commit 93676c88 (v4.2) when we raised the name limit to 4096 to match the NBD string limit. (That commit also failed to change the magic number 4096 in nbd_negotiate_send_rep_err to the just-introduced named constant.) So with that commit, long client names appended to server text can now trigger the assertion, and thus be used as a denial of service attack against a server. As a mitigating factor, if the server requires TLS, the client cannot trigger the problematic paths unless it first supplies TLS credentials, and such trusted clients are less likely to try to intentionally crash the server.
We may later want to further sanitize the user-supplied strings we place into our error messages, such as scrubbing out control characters, but that is less important to the CVE fix, so it can be a later patch to the new nbd_sanitize_name.
Consideration was given to changing the assertion in nbd_negotiate_send_rep_verr to instead merely log a server error and truncate the message, to avoid leaving a latent path that could trigger a future CVE DoS on any new error message. However, this merely complicates the code for something that is already (correctly) flagging coding errors, and now that we are aware of the long message pitfall, we are less likely to introduce such errors in the future, which would make such error handling dead code.
Message-Id: <[email protected]>
--- nbd/server.c | 23 ++++++++++++++++++++--- tests/qemu-iotests/143 | 4 ++++ tests/qemu-iotests/143.out | 2 ++ 3 files changed, 26 insertions(+), 3 deletions(-)
nbd/server.c +20 -3
@@ -217,7 +217,7 @@ nbd_negotiate_send_rep_verr(NBDClient *client, uint32_t type, msg =g_strdup_vprintf (fmt, va); len =strlen (msg); -assert (len <4096 ); +assert (len <NBD_MAX_STRING_SIZE );trace_nbd_negotiate_send_rep_err (msg); ret =nbd_negotiate_send_rep_len (client, type, len, errp);if (ret <0 ) {
@@ -231,6 +231,19 @@ nbd_negotiate_send_rep_verr(NBDClient *client, uint32_t type,return 0 ; } +/* +* Return a malloc'd copy of @name suitable for use in an error reply. +*/ +static char * +nbd_sanitize_name (const char *name) +{ +if (strnlen (name,80 ) <80 ) { +return g_strdup (name); + } +/* XXX Should we also try to sanitize any control characters? */ +return g_strdup_printf ("%.80s..." , name); +} +/* Send an error reply. * Return -errno on error, 0 on success. */ static int GCC_FMT_ATTR(4, 5)
@@ -595,9 +608,11 @@ static int nbd_negotiate_handle_info(NBDClient *client, Error **errp) exp =nbd_export_find (name);if (!exp) { + g_autofree char *sane_name = nbd_sanitize_name(name); +return nbd_negotiate_send_rep_err (client,NBD_REP_ERR_UNKNOWN , errp,"export '%s' not present" , - name); + sane_name); }/* Don't bother sending NBD_INFO_NAME unless client requested it */
@@ -995,8 +1010,10 @@ static int nbd_negotiate_meta_queries(NBDClient *client, meta->exp =nbd_export_find (export_name);if (meta->exp ==NULL ) { + g_autofree char *sane_name = nbd_sanitize_name(export_name); +return nbd_opt_drop (client,NBD_REP_ERR_UNKNOWN , errp, -"export '%s' not present" , export_name); +"export '%s' not present" , sane_name); } ret =nbd_opt_read (client, &nb_queries,sizeof (nb_queries), errp);
tests/qemu-iotests/143 +4 -0
@@ -58,6 +58,10 @@ _send_qemu_cmd $QEMU_HANDLE \ $QEMU_IO_PROG -f raw -c quit \ "nbd+unix:///no_such_export?socket=$SOCK_DIR/nbd" 2>&1 \ | _filter_qemu_io | _filter_nbd +# Likewise, with longest possible name permitted in NBD protocol +$QEMU_IO_PROG -f raw -c quit \ + "nbd+unix:///$(printf %4096d 1 | tr ' ' a)?socket=$SOCK_DIR/nbd" 2>&1 \ + | _filter_qemu_io | _filter_nbd | sed 's/aaaa*aa/aa--aa/' _send_qemu_cmd $QEMU_HANDLE \ "{ 'execute': 'quit' }" \
tests/qemu-iotests/143.out +2 -0
@@ -5,6 +5,8 @@ QA output created by 143 {"return": {}} qemu-io: can't open device nbd+unix:///no_such_export?socket=SOCK_DIR/nbd: Requested export not available server reported: export 'no_such_export' not present +qemu-io: can't open device nbd+unix:///aa--aa1?socket=SOCK_DIR/nbd: Requested export not available +server reported: export 'aa--aa...' not present { 'execute': 'quit' } {"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}}
Signature · 1 line
2.17.1
PATCH 75/78 virtio-balloon: fix free page hinting without an iothread
In reply to Michael RothFrom: David Hildenbrand <[email protected]>
In case we don't have an iothread, we mark the feature as abscent but still add the queue. 'free_page_bh' remains set to NULL.
qemu-system-i386 \
-M microvm \
-nographic \
-device virtio-balloon-device,free-page-hint=true \
-nographic \
-display none \
-monitor none \
-serial none \
-qtest stdioDoing a "write 0xc0000e30 0x24 0x030000000300000003000000030000000300000003000000030000000300000003000000"
We will trigger a SEGFAULT. Let's move the check and bail out.
While at it, move the static initializations to instance_init(). free_page_report_status and block_iothread are implicitly set to the right values (0/false) already, so drop the initialization.
Message-Id: <[email protected]>
--- hw/virtio/virtio-balloon.c | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-)
hw/virtio/virtio-balloon.c +16 -17
@@ -789,6 +789,13 @@ static void virtio_balloon_device_realize(DeviceState *dev, Error **errp)return ; } +if (virtio_has_feature (s->host_features,VIRTIO_BALLOON_F_FREE_PAGE_HINT ) && + !s->iothread) { +error_setg (errp,"'free-page-hint' requires 'iothread' to be set" ); +virtio_cleanup (vdev); +return ; + } + s->ivq =virtio_add_queue (vdev,128 , virtio_balloon_handle_output); s->dvq =virtio_add_queue (vdev,128 , virtio_balloon_handle_output); s->svq =virtio_add_queue (vdev,128 , virtio_balloon_receive_stats);
@@ -797,24 +804,11 @@ static void virtio_balloon_device_realize(DeviceState *dev, Error **errp) VIRTIO_BALLOON_F_FREE_PAGE_HINT)) { s->free_page_vq =virtio_add_queue (vdev,VIRTQUEUE_MAX_SIZE , virtio_balloon_handle_free_page_vq); - s->free_page_report_status =FREE_PAGE_REPORT_S_STOP ; - s->free_page_report_cmd_id = -VIRTIO_BALLOON_FREE_PAGE_REPORT_CMD_ID_MIN ; - s->free_page_report_notify.notify = - virtio_balloon_free_page_report_notify;precopy_add_notifier (&s->free_page_report_notify); -if (s->iothread) { -object_ref (OBJECT (s->iothread)); - s->free_page_bh =aio_bh_new (iothread_get_aio_context (s->iothread), - virtio_ballloon_get_free_page_hints, s); -qemu_mutex_init (&s->free_page_lock); -qemu_cond_init (&s->free_page_cond); - s->block_iothread = false; - }else { -/* Simply disable this feature if the iothread wasn't created. */ - s->host_features &= ~(1 <<VIRTIO_BALLOON_F_FREE_PAGE_HINT ); -virtio_error (vdev,"iothread is missing" ); - } + +object_ref (OBJECT (s->iothread)); + s->free_page_bh =aio_bh_new (iothread_get_aio_context (s->iothread), + virtio_ballloon_get_free_page_hints, s); }reset_stats (s); }
@@ -885,6 +879,11 @@ static void virtio_balloon_instance_init(Object *obj) {VirtIOBalloon *s =VIRTIO_BALLOON (obj); +qemu_mutex_init (&s->free_page_lock); +qemu_cond_init (&s->free_page_cond); + s->free_page_report_cmd_id =VIRTIO_BALLOON_FREE_PAGE_REPORT_CMD_ID_MIN ; + s->free_page_report_notify.notify = virtio_balloon_free_page_report_notify; +object_property_add (obj,"guest-stats" ,"guest statistics" , balloon_stats_get_all,NULL ,NULL , s,NULL );
Signature · 1 line
2.17.1
PATCH 76/78 virtio-balloon: fix free page hinting check on unrealize
In reply to Michael RothFrom: David Hildenbrand <[email protected]>
Checking against guest features is wrong. We allocated data structures based on host features. We can rely on "free_page_bh" as an indicator whether to un-do stuff instead.
Message-Id: <[email protected]>
--- hw/virtio/virtio-balloon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/virtio/virtio-balloon.c +1 -1
@@ -818,7 +818,7 @@ static void virtio_balloon_device_unrealize(DeviceState *dev, Error **errp)VirtIODevice *vdev =VIRTIO_DEVICE (dev);VirtIOBalloon *s =VIRTIO_BALLOON (dev); -if (virtio_balloon_free_page_support (s)) { +if (s->free_page_bh) {qemu_bh_delete (s->free_page_bh);virtio_balloon_free_page_stop (s);precopy_remove_notifier (&s->free_page_report_notify);
Signature · 1 line
2.17.1
PATCH 77/78 virtio-balloon: unref the iothread when unrealizing
In reply to Michael RothFrom: David Hildenbrand <[email protected]>
We took a reference when realizing, so let's drop that reference when unrealizing.
Message-Id: <[email protected]>
--- hw/virtio/virtio-balloon.c | 1 + 1 file changed, 1 insertion(+)
hw/virtio/virtio-balloon.c +1 -0
@@ -820,6 +820,7 @@ static void virtio_balloon_device_unrealize(DeviceState *dev, Error **errp)if (s->free_page_bh) {qemu_bh_delete (s->free_page_bh); +object_unref (OBJECT (s->iothread));virtio_balloon_free_page_stop (s);precopy_remove_notifier (&s->free_page_report_notify); }
Signature · 1 line
2.17.1
PATCH 78/78 block: Call attention to truncation of long NBD exports
In reply to Michael RothFrom: Eric Blake <[email protected]>
Commit 93676c88 relaxed our NBD client code to request export names up to the NBD protocol maximum of 4096 bytes without NUL terminator, even though the block layer can't store anything longer than 4096 bytes including NUL terminator for display to the user. Since this means there are some export names where we have to truncate things, we can at least try to make the truncation a bit more obvious for the user. Note that in spite of the truncated display name, we can still communicate with an NBD server using such a long export name; this was deemed nicer than refusing to even connect to such a server (since the server may not be under our control, and since determining our actual length limits gets tricky when nbd://host:port/export and nbd+unix:///export?socket=/path are themselves variable-length expansions beyond the export name but count towards the block layer name length).
Message-Id: <[email protected]>
--- block.c | 7 +++++-- block/nbd.c | 21 +++++++++++++-------- 2 files changed, 18 insertions(+), 10 deletions(-)
block.c +5 -2
@@ -6486,8 +6486,11 @@ void bdrv_refresh_filename(BlockDriverState *bs)pstrcpy (bs->filename,sizeof (bs->filename), bs->exact_filename); }else {QString *json =qobject_to_json (QOBJECT (bs->full_open_options)); -snprintf (bs->filename,sizeof (bs->filename),"json:%s" , -qstring_get_str (json)); +if (snprintf (bs->filename,sizeof (bs->filename),"json:%s" , +qstring_get_str (json)) >=sizeof (bs->filename)) { +/* Give user a hint if we truncated things. */ +strcpy (bs->filename +sizeof (bs->filename) -4 ,"..." ); + }qobject_unref (json); } }
block/nbd.c +13 -8
@@ -1971,6 +1971,7 @@ static void nbd_refresh_filename(BlockDriverState *bs) {BDRVNBDState *s = bs->opaque;const char *host =NULL , *port =NULL , *path =NULL ; +size_t len =0 ;if (s->saddr->type ==SOCKET_ADDRESS_TYPE_INET ) {const InetSocketAddress *inet = &s->saddr->u.inet;
@@ -1983,17 +1984,21 @@ static void nbd_refresh_filename(BlockDriverState *bs) }/* else can't represent as pseudo-filename */ if (path && s->export) { -snprintf (bs->exact_filename,sizeof (bs->exact_filename), -"nbd+unix:///%s?socket=%s" , s->export, path); + len =snprintf (bs->exact_filename,sizeof (bs->exact_filename), +"nbd+unix:///%s?socket=%s" , s->export, path); }else if (path && !s->export) { -snprintf (bs->exact_filename,sizeof (bs->exact_filename), -"nbd+unix://?socket=%s" , path); + len =snprintf (bs->exact_filename,sizeof (bs->exact_filename), +"nbd+unix://?socket=%s" , path); }else if (host && s->export) { -snprintf (bs->exact_filename,sizeof (bs->exact_filename), -"nbd://%s:%s/%s" , host, port, s->export); + len =snprintf (bs->exact_filename,sizeof (bs->exact_filename), +"nbd://%s:%s/%s" , host, port, s->export); }else if (host && !s->export) { -snprintf (bs->exact_filename,sizeof (bs->exact_filename), -"nbd://%s:%s" , host, port); + len =snprintf (bs->exact_filename,sizeof (bs->exact_filename), +"nbd://%s:%s" , host, port); + } +if (len >sizeof (bs->exact_filename)) { +/* Name is too long to represent exactly, so leave it empty. */ + bs->exact_filename[0 ] ='\0' ; } }
Signature · 1 line
2.17.1
Quoted 10 lines · Michael Roth
Hi everyone,
The following new patches are queued for QEMU stable v4.2.1:
https://github.com/mdroth/qemu/commits/stable-4.2-staging
The release is planned for 2020-06-25:
Quoted 7 lines
Due to delays on my part this release is going out beyond the normal ~4 month support window. v5.0.1 is scheduled to be released as normal.
Please respond here or CC [email protected] on any additional patches you think should be included in the release.
Thanks!
A few bug fixes we are carrying in Fedora 32:
commit eca3a945234a5f0a499860dd11df64b5f1a2e0a5
Author: Cole Robinson <[email protected]> Date: Wed Nov 13 16:09:35 2019 -0500
tests: fix modules-test 'duplicate test case' error
commit 8deb8019d696c75e6ecaee7545026b62aba2f1bb
Author: David Gibson <[email protected]> Date: Fri Oct 18 15:19:31 2019 +1100
spapr: Don't trigger a CAS reboot for XICS/XIVE mode changeover
commit bb8136df698bd565ee4f6c18d26c50dee320bfe4
Author: Pan Nengyuan <[email protected]> Date: Tue Dec 10 15:14:37 2019 +0800
riscv/sifive_u: fix a memory leak in soc_realize()
commit a37f21c27d3e2342c2080aafd4cfe7e949612428
Author: Yiting Wang <[email protected]> Date: Fri Jan 3 11:53:42 2020 +0800
riscv: Set xPIE to 1 after xRET
commit 613fa160e19abe8e1fe44423fcfa8ec73d3d48e5
Author: ShihPo Hung <[email protected]> Date: Tue Jan 14 22:17:31 2020 -0800
target/riscv: Fix tb->flags FS status
commit a59796eb6d59bbd74ce28ddbddb1b83e60674e96
Author: ShihPo Hung <[email protected]> Date: Tue Jan 14 22:17:32 2020 -0800
target/riscv: fsd/fsw doesn't dirty FP state
commit 82f014671cf057de51c4a577c9e2ad637dcec6f9
Author: ShihPo Hung <[email protected]> Date: Tue Jan 14 22:17:33 2020 -0800
target/riscv: update mstatus.SD when FS is set dirty
Thanks,
Cole
Quoted 8 lines · Michael Roth
Hi everyone,
The following new patches are queued for QEMU stable v4.2.1:
https://github.com/mdroth/qemu/commits/stable-4.2-staging
The release is planned for 2020-06-25:
Quoted 7 lines
https://wiki.qemu.org/Planning/4.2Due to delays on my part this release is going out beyond the normal ~4 month support window. v5.0.1 is scheduled to be released as normal.
Please respond here or CC [email protected] on any additional patches you think should be included in the release.
Does this need to be picked up too?
4a910e1f6ab4 ("target/i386: do not set unsupported VMX secondary execution controls")
(which fixes https://bugzilla.redhat.com/show_bug.cgi?id=1822682)
Regards,
Liam
Quoted 230 lines
----------------------------------------------------------------
Alex Bennée (2):
target/arm: ensure we use current exception state after SCR update
tcg: save vaddr temp for plugin usageAlexander Popov (2):
tests/ide-test: Create a single unit-test covering more PRDT cases
ide: Fix incorrect handling of some PRDTs inide_dma_cb()Anthony PERARD (1):
xen-block: Fix double qlist remove and request leakBasil Salman (2):
qga: Installer: Wait for installation to finish
qga-win: prevent crash when executing guest-file-read with large countChristian Borntraeger (1):
s390/sclp: improve special wait psw logicChristophe de Dinechin (1):
scsi/qemu-pr-helper: Fix out-of-bounds access to trnptid_list[]Cornelia Huck (1):
compat: disable edid on correct virtio-gpu deviceDaniel P. Berrangé (1):
qapi: better document NVMe blockdev @device parameterDavid Hildenbrand (3):
virtio-balloon: fix free page hinting without an iothread
virtio-balloon: fix free page hinting check on unrealize
virtio-balloon: unref the iothread when unrealizingDenis Plotnikov (1):
virtio-mmio: update queue size on guest writeEduardo Habkost (1):
i386: Resolve CPU models to v1 by defaultEmilio G. Cota (1):
plugins/core: add missing break incb_to_tcg_flagsEric Blake (3):
qga: Fix undefined C behavior
nbd/server: Avoid long error message assertions CVE-2020-10761
block: Call attention to truncation of long NBD exportsFinn Thain (14):
dp8393x: Mask EOL bit from descriptor addresses
dp8393x: Always use 32-bit accesses
dp8393x: Clean up endianness hacks
dp8393x: Havedp8393x_receive()return the packet size
dp8393x: Update LLFA and CRDA registers from rx descriptor
dp8393x: Clear RRRA command register bit only when appropriate
dp8393x: Implement packet size limit and RBAE interrupt
dp8393x: Don't clobber packet checksum
dp8393x: Use long-word-aligned RRA pointers in 32-bit mode
dp8393x: Pad frames to word or long word boundary
dp8393x: Clear descriptorin_usefield to release packet
dp8393x: Always update RRA pointers and sequence numbers
dp8393x: Don't reset Silicon Revision register
dp8393x: Don't stop reception upon RBE interrupt assertionGreg Kurz (1):
9p: Lock directory streams with a CoMutexIgor Mammedov (3):
numa: remove not needed check
numa: properly check if numa is supported
hostmem: don't usembind()if host-nodes is emptyKevin Wolf (4):
block: Activate recursively even for already active nodes
qcow2:update_refcount(): Resetold_table_indexafterqcow2_cache_put()
qcow2: Fixqcow2_alloc_cluster_abort()for external data file
iotests: Test copy offloading with external data fileLi Hangjing (1):
virtio-blk: fix out-of-bounds access to bitmap innotify_guest_bhLiu Yi L (2):
intel_iommu: a fix tovtd_find_as_from_bus_num()
intel_iommu: add present bit check for pasid table entriesMax Reitz (4):
backup-top: Begin drain earlier
qcow2: Fixalloc_cluster_abort()for pre-existing clusters iotests/026: Test EIO on preallocated zero cluster iotests/026: Test EIO on allocation in a data-fileMichael S. Tsirkin (3):
virtio: update queue size on guest write
virtio: add ability to delete vq through a pointer
virtio: makevirtio_delete_queueidempotentNicholas Piggin (1):
target/ppc: Fix mtmsr(d) L=1 variant that loses interruptsNiek Linnenbank (2):
arm/arm-powerctl: set NSACR.{CP11, CP10} bits inarm_set_cpu_on()arm/arm-powerctl: rebuild hflags after setting CP15 bits inarm_set_cpu_on()Pan Nengyuan (2):
block/nbd: extract the common cleanup code
block/nbd: fix memory leak innbd_open()Peter Maydell (2):
hw/i386/amd_iommu.c: Fix corruption of log events passed to guest
dump: Fix writing of ELF sectionPeter Wu (1):
hw/i386/pc: fix regression in parsing vga cmdline parameterPeter Xu (1):
vfio/pci: Don't remove irqchip notifier if not registeredPhilippe Mathieu-Daudé (1):
vhost-user-gpu: Release memory returned byvu_queue_pop()withfree()Raphael Pour (1):
qemu-nbd: Close inherited stderrRichard Henderson (3):
target/arm: Set ISSIs16Bit inmake_issinfotcg/i386: FixINDEX_op_dup2_vec
target/arm: Clear tail in gvec_fmul_idx_*, gvec_fmla_idx_*Sameeh Jubran (1):
qga-win: HandleVSS_E_PROVIDER_ALREADY_REGISTEREDerrorStefan Hajnoczi (2):
virtio: gracefully handle invalid region caches
qemu-ga: document vsock-listen in the man pageThomas Huth (1):
net: Do not include a newline in the id of -nic devicesVitaly Chikunov (1):
target/ppc: Fix rlwinm on ppc64Vladimir Sementsov-Ogievskiy (5):
qcow2-bitmaps: fixqcow2_can_store_new_dirty_bitmapblock/qcow2-threads: fixqcow2_decompress
job: refactor progress to separate objectblock/block-copy: fix progress calculation block/io: fixbdrv_co_do_copy_on_readvYuri Benditovich (2):
virtio: reset region cache when on queue deletion
virtio-net: delete also control queue when TX/RX deletedbackends/hostmem.c | 6 +- block.c | 57 +++++------ block/backup-top.c | 4 +- block/backup.c | 13 +-- block/block-copy.c | 16 ++- block/io.c | 2 +- block/nbd.c | 48 +++++---- block/qcow2-bitmap.c | 41 ++++---- block/qcow2-cluster.c | 7 +- block/qcow2-refcount.c | 1 + block/qcow2-threads.c | 12 ++- blockjob.c | 16 +-- contrib/vhost-user-gpu/main.c | 4 +- contrib/vhost-user-gpu/virgl.c | 2 +- docs/interop/qemu-ga.rst | 5 +- dump/dump.c | 2 +- hw/9pfs/9p.h | 8 +- hw/arm/sbsa-ref.c | 1 - hw/block/dataplane/virtio-blk.c | 2 +- hw/block/dataplane/xen-block.c | 48 +++------ hw/core/machine.c | 6 +- hw/core/numa.c | 7 +- hw/i386/amd_iommu.c | 2 +- hw/i386/intel_iommu.c | 93 +++++++++++++---- hw/i386/intel_iommu_internal.h | 1 + hw/i386/x86.c | 8 +- hw/ide/core.c | 30 ++++-- hw/net/dp8393x.c | 200 ++++++++++++++++++++++++------------- hw/net/virtio-net.c | 3 +- hw/vfio/pci.c | 4 +- hw/virtio/virtio-balloon.c | 36 +++---- hw/virtio/virtio-mmio.c | 3 +- hw/virtio/virtio-pci.c | 2 + hw/virtio/virtio.c | 116 ++++++++++++++++++--- include/block/block-copy.h | 15 +-- include/hw/virtio/virtio.h | 2 + include/qemu/job.h | 11 +- include/qemu/progress_meter.h | 58 +++++++++++ job-qmp.c | 4 +- job.c | 6 +- nbd/server.c | 23 ++++- net/net.c | 2 +- plugins/core.c | 1 + qapi/block-core.json | 6 +- qemu-deprecated.texi | 8 ++ qemu-img.c | 6 +- qemu-nbd.c | 6 +- qga/commands-win32.c | 8 +- qga/commands.c | 9 +- qga/installer/qemu-ga.wxs | 2 +- qga/main.c | 4 +- qga/vss-win32/install.cpp | 11 ++ scsi/qemu-pr-helper.c | 17 ++-- target/arm/arm-powerctl.c | 6 ++ target/arm/cpu.h | 8 +- target/arm/helper.c | 14 ++- target/arm/helper.h | 1 + target/arm/translate.c | 9 +- target/arm/vec_helper.c | 2 + target/i386/cpu.c | 8 +- target/ppc/translate.c | 66 ++++++------ target/s390x/helper.c | 2 +- tcg/i386/tcg-target.inc.c | 10 +- tcg/tcg-op.c | 23 ++++- tests/ide-test.c | 174 ++++++++++++++------------------ tests/qemu-iotests/026 | 53 ++++++++++ tests/qemu-iotests/026.out | 16 +++ tests/qemu-iotests/026.out.nocache | 16 +++ tests/qemu-iotests/143 | 4 + tests/qemu-iotests/143.out | 2 + tests/qemu-iotests/244 | 14 +++ tests/qemu-iotests/244.out | 6 ++ 72 files changed, 963 insertions(+), 476 deletions(-)create mode 100644
include/qemu/progress_meter.h
Quoted 8 lines · Michael Roth
Hi everyone,
The following new patches are queued for QEMU stable v4.2.1:
https://github.com/mdroth/qemu/commits/stable-4.2-staging
The release is planned for 2020-06-25:
Quoted 7 lines
https://wiki.qemu.org/Planning/4.2
Due to delays on my part this release is going out beyond the normal ~4 month support window. v5.0.1 is scheduled to be released as normal.
Please respond here or CC [email protected] on any additional patches you think should be included in the release.
CVE related commits:
* 693fd2acdf14 ("iscsi: Cap block count from GET LBA STATUS (CVE-2020-1711)")
* ac2071c3791b ("ati-vga: Fix checks in ati_2d_blt() to avoid crash") to fix CVE-2020-11869
* a98610c429d5 ("ati-vga: check mm_index before recursive call (CVE-2020-13800)")
* 369ff955a849 ("es1370: check total frame count against current frame") to fix CVE-2020-13361
* Advance the slirp submodule to commit 2faae0f778f8 ("Fix use-afte-free in ip_reass()") to fix CVE-2019-15890, CVE-2020-8608, and CVE-2020-1983
Fix for a crash:
* 9b3a31c745b6 ("kvm: Reallocate dirty_bmap when we change a slot")
Thank you,
Karl
Quoted 240 lines
Thanks!
----------------------------------------------------------------
Alex Bennée (2):
target/arm: ensure we use current exception state after SCR
update
tcg: save vaddr temp for plugin usageAlexander Popov (2):
tests/ide-test: Create a single unit-test covering more PRDT
cases
ide: Fix incorrect handling of some PRDTs inide_dma_cb()Anthony PERARD (1):
xen-block: Fix double qlist remove and request leakBasil Salman (2):
qga: Installer: Wait for installation to finish
qga-win: prevent crash when executing guest-file-read with large
countChristian Borntraeger (1):
s390/sclp: improve special wait psw logicChristophe de Dinechin (1):
scsi/qemu-pr-helper: Fix out-of-bounds access to trnptid_list[]Cornelia Huck (1):
compat: disable edid on correct virtio-gpu deviceDaniel P. Berrangé (1):
qapi: better document NVMe blockdev @device parameterDavid Hildenbrand (3):
virtio-balloon: fix free page hinting without an iothread
virtio-balloon: fix free page hinting check on unrealize
virtio-balloon: unref the iothread when unrealizingDenis Plotnikov (1):
virtio-mmio: update queue size on guest writeEduardo Habkost (1):
i386: Resolve CPU models to v1 by defaultEmilio G. Cota (1):
plugins/core: add missing break incb_to_tcg_flagsEric Blake (3):
qga: Fix undefined C behavior
nbd/server: Avoid long error message assertions CVE-2020-10761
block: Call attention to truncation of long NBD exportsFinn Thain (14):
dp8393x: Mask EOL bit from descriptor addresses
dp8393x: Always use 32-bit accesses
dp8393x: Clean up endianness hacks
dp8393x: Havedp8393x_receive()return the packet size
dp8393x: Update LLFA and CRDA registers from rx descriptor
dp8393x: Clear RRRA command register bit only when appropriate
dp8393x: Implement packet size limit and RBAE interrupt
dp8393x: Don't clobber packet checksum
dp8393x: Use long-word-aligned RRA pointers in 32-bit mode
dp8393x: Pad frames to word or long word boundary
dp8393x: Clear descriptorin_usefield to release packet
dp8393x: Always update RRA pointers and sequence numbers
dp8393x: Don't reset Silicon Revision register
dp8393x: Don't stop reception upon RBE interrupt assertionGreg Kurz (1):
9p: Lock directory streams with a CoMutexIgor Mammedov (3):
numa: remove not needed check
numa: properly check if numa is supported
hostmem: don't usembind()if host-nodes is emptyKevin Wolf (4):
block: Activate recursively even for already active nodes
qcow2:update_refcount(): Resetold_table_indexafterqcow2_cache_put()
qcow2: Fixqcow2_alloc_cluster_abort()for external data file
iotests: Test copy offloading with external data fileLi Hangjing (1):
virtio-blk: fix out-of-bounds access to bitmap innotify_guest_bhLiu Yi L (2):
intel_iommu: a fix tovtd_find_as_from_bus_num()
intel_iommu: add present bit check for pasid table entriesMax Reitz (4):
backup-top: Begin drain earlier
qcow2: Fixalloc_cluster_abort()for pre-existing clusters iotests/026: Test EIO on preallocated zero cluster iotests/026: Test EIO on allocation in a data-fileMichael S. Tsirkin (3):
virtio: update queue size on guest write
virtio: add ability to delete vq through a pointer
virtio: makevirtio_delete_queueidempotentNicholas Piggin (1):
target/ppc: Fix mtmsr(d) L=1 variant that loses interruptsNiek Linnenbank (2):
arm/arm-powerctl: set NSACR.{CP11, CP10} bits inarm_set_cpu_on()
arm/arm-powerctl: rebuild hflags after setting CP15 bits inarm_set_cpu_on()Pan Nengyuan (2):
block/nbd: extract the common cleanup code
block/nbd: fix memory leak innbd_open()Peter Maydell (2):
hw/i386/amd_iommu.c: Fix corruption of log events passed to
guest
dump: Fix writing of ELF sectionPeter Wu (1):
hw/i386/pc: fix regression in parsing vga cmdline parameterPeter Xu (1):
vfio/pci: Don't remove irqchip notifier if not registeredPhilippe Mathieu-Daudé (1):
vhost-user-gpu: Release memory returned byvu_queue_pop()withfree()Raphael Pour (1):
qemu-nbd: Close inherited stderrRichard Henderson (3):
target/arm: Set ISSIs16Bit inmake_issinfotcg/i386: FixINDEX_op_dup2_vec
target/arm: Clear tail in gvec_fmul_idx_*, gvec_fmla_idx_*Sameeh Jubran (1):
qga-win: HandleVSS_E_PROVIDER_ALREADY_REGISTEREDerrorStefan Hajnoczi (2):
virtio: gracefully handle invalid region caches
qemu-ga: document vsock-listen in the man pageThomas Huth (1):
net: Do not include a newline in the id of -nic devicesVitaly Chikunov (1):
target/ppc: Fix rlwinm on ppc64Vladimir Sementsov-Ogievskiy (5):
qcow2-bitmaps: fixqcow2_can_store_new_dirty_bitmapblock/qcow2-threads: fixqcow2_decompress
job: refactor progress to separate objectblock/block-copy: fix progress calculation block/io: fixbdrv_co_do_copy_on_readvYuri Benditovich (2):
virtio: reset region cache when on queue deletion
virtio-net: delete also control queue when TX/RX deletedbackends/hostmem.c | 6 +- block.c | 57 +++++------ block/backup-top.c | 4 +- block/backup.c | 13 +-- block/block-copy.c | 16 ++- block/io.c | 2 +- block/nbd.c | 48 +++++---- block/qcow2-bitmap.c | 41 ++++---- block/qcow2-cluster.c | 7 +- block/qcow2-refcount.c | 1 + block/qcow2-threads.c | 12 ++- blockjob.c | 16 +-- contrib/vhost-user-gpu/main.c | 4 +- contrib/vhost-user-gpu/virgl.c | 2 +- docs/interop/qemu-ga.rst | 5 +- dump/dump.c | 2 +- hw/9pfs/9p.h | 8 +- hw/arm/sbsa-ref.c | 1 - hw/block/dataplane/virtio-blk.c | 2 +- hw/block/dataplane/xen-block.c | 48 +++------ hw/core/machine.c | 6 +- hw/core/numa.c | 7 +- hw/i386/amd_iommu.c | 2 +- hw/i386/intel_iommu.c | 93 +++++++++++++---- hw/i386/intel_iommu_internal.h | 1 + hw/i386/x86.c | 8 +- hw/ide/core.c | 30 ++++-- hw/net/dp8393x.c | 200 ++++++++++++++++++++++++------------- hw/net/virtio-net.c | 3 +- hw/vfio/pci.c | 4 +- hw/virtio/virtio-balloon.c | 36 +++---- hw/virtio/virtio-mmio.c | 3 +- hw/virtio/virtio-pci.c | 2 + hw/virtio/virtio.c | 116 ++++++++++++++++++--- include/block/block-copy.h | 15 +-- include/hw/virtio/virtio.h | 2 + include/qemu/job.h | 11 +- include/qemu/progress_meter.h | 58 +++++++++++ job-qmp.c | 4 +- job.c | 6 +- nbd/server.c | 23 ++++- net/net.c | 2 +- plugins/core.c | 1 + qapi/block-core.json | 6 +- qemu-deprecated.texi | 8 ++ qemu-img.c | 6 +- qemu-nbd.c | 6 +- qga/commands-win32.c | 8 +- qga/commands.c | 9 +- qga/installer/qemu-ga.wxs | 2 +- qga/main.c | 4 +- qga/vss-win32/install.cpp | 11 ++ scsi/qemu-pr-helper.c | 17 ++-- target/arm/arm-powerctl.c | 6 ++ target/arm/cpu.h | 8 +- target/arm/helper.c | 14 ++- target/arm/helper.h | 1 + target/arm/translate.c | 9 +- target/arm/vec_helper.c | 2 + target/i386/cpu.c | 8 +- target/ppc/translate.c | 66 ++++++------ target/s390x/helper.c | 2 +- tcg/i386/tcg-target.inc.c | 10 +- tcg/tcg-op.c | 23 ++++- tests/ide-test.c | 174 ++++++++++++++------------------ tests/qemu-iotests/026 | 53 ++++++++++ tests/qemu-iotests/026.out | 16 +++ tests/qemu-iotests/026.out.nocache | 16 +++ tests/qemu-iotests/143 | 4 + tests/qemu-iotests/143.out | 2 + tests/qemu-iotests/244 | 14 +++ tests/qemu-iotests/244.out | 6 ++ 72 files changed, 963 insertions(+), 476 deletions(-) create mode 100644 include/qemu/progress_meter.h
Hi Michael,
Quoted 17 lines · Michael Roth
Finn Thain (14):
dp8393x: Mask EOL bit from descriptor addresses
dp8393x: Always use 32-bit accesses
dp8393x: Clean up endianness hacks
dp8393x: Havedp8393x_receive()return the packet size
dp8393x: Update LLFA and CRDA registers from rx descriptor
dp8393x: Clear RRRA command register bit only when appropriate
dp8393x: Implement packet size limit and RBAE interrupt
dp8393x: Don't clobber packet checksum
dp8393x: Use long-word-aligned RRA pointers in 32-bit mode
dp8393x: Pad frames to word or long word boundary
dp8393x: Clear descriptorin_usefield to release packet
dp8393x: Always update RRA pointers and sequence numbers
dp8393x: Don't reset Silicon Revision register
dp8393x: Don't stop reception upon RBE interrupt assertion
Thanks for picking these fixes. When the maintainer originally merged this series of patches, the first patch got slightly damaged. This was remedied in a subsequent patch[1]. That is, mainline commit a0cf4297d6 ("dp8393x:
Mask EOL bit from descriptor addresses, take 2"). Would you also pick that commit for v4.2.1 please?
Quoted 10 lines · Finn Thain
Thanks for picking these fixes. When the maintainer originally merged this series of patches, the first patch got slightly damaged. This was remedied in a subsequent patch[1]. That is, mainline commit
a0cf4297d6("dp8393x:
Mask EOL bit from descriptor addresses, take 2"). Would you also pick that commit for v4.2.1 please?
While we're on the subject of cherry-picking fixes for fixes, you may also want to consider c264e5d2f9f5d73977eac8e5d084f727b3d07ea9. I didn't find any fixes for fixes for fixes. That search probably needs to be automated...
Quoting Finn Thain (2020-06-19 22:39:41)
Quoted 9 lines · Finn Thain
Quoted 8 lines
Thanks for picking these fixes. When the maintainer originally merged this series of patches, the first patch got slightly damaged. This was remedied in a subsequent patch[1]. That is, mainline commit
a0cf4297d6("dp8393x:
Mask EOL bit from descriptor addresses, take 2"). Would you also pick that commit for v4.2.1 please?
Quoted 8 lines
Quoted 3 lines
While we're on the subject of cherry-picking fixes for fixes, you may also want to consider
c264e5d2f9f5d73977eac8e5d084f727b3d07ea9. I didn't find any fixes for fixes for fixes. That search probably needs to be automated...
Thanks for the catch/suggestion. I've added a script to the process to help find follow-up fixes, but it still needs to be run manually. Some sort of git integration would probably be a good next step.
Hi Michael,
Our upcoming SLE15-SP2 and Leap 15.2 releases have a qemu package which is based on v4.2.0. In addition to some of the patches already mentioned, here is a list of others we have backported as being stable material. I threw a little wider net this time than usual, so feel free to give it a more critical eye.
commit 8937a39da22e5d5689c516a2d4ce4f2bb6a378fc
Author: Han Han <[email protected]>
Revert "qemu-options.hx: Update for reboot-timeout parameter"
commit 0f516ca4767042aec8716369d6d62436fa10593a
Author: Robert Foley <[email protected]>
Fix double free issue in qemu_set_log_filename().
commit eb4ea9aaa0051054b3c148ad8631be7510851681
Author: Max Reitz <[email protected]>
iotests: Fix IMGOPTSSYNTAX for nbd
commit fcd3f2cc124600385dba46c69a80626985c15b50
Author: Igor Mammedov <[email protected]>
numa: properly check if numa is supported
commit ca26b032e5a0e8a190c763ce828a8740d24b9b65
Author: Cole Robinson <[email protected]>
vhost-user-gpu: Drop trailing json comma
commit 0d82411d0e38a0de7829f97d04406765c8d2210d
Author: Cameron Esfahani <[email protected]>
display/bochs-display: fix memory leak
commit 3d44c60500785f18bb469c9de0aeba7415c0f28f
Author: Simon Veith <[email protected]>
hw/arm/smmuv3: Apply address mask to linear strtab base address
commit 3293b9f514a413e019b7dbc9d543458075b4849e
Author: Simon Veith <[email protected]>
hw/arm/smmuv3: Correct SMMU_BASE_ADDR_MASK value
commit 05ff2fb80ce4ca85d8a39d48ff8156de739b4f51
Author: Simon Veith <[email protected]>
hw/arm/smmuv3: Check stream IDs against actual table LOG2SIZE
commit 41678c33aac61261522b74f08595ccf2221a430a
Author: Simon Veith <[email protected]>
hw/arm/smmuv3: Align stream table base address to table size
commit a7f65ceb851af5a5b639c6e30801076d848db2c2
Author: Simon Veith <[email protected]>
hw/arm/smmuv3: Use correct bit positions in EVT_SET_ADDR2 macro
commit b255cafb59578d16716186ed955717bc8f87bdb7
Author: Simon Veith <[email protected]>
hw/arm/smmuv3: Report F_STE_FETCH fault address in correct word position
commit 7b1d9c4df0603fbc526226a9c5ef91118aa6c957
Author: Max Reitz <[email protected]>
block: Add bdrv_qapi_perm_to_blk_perm()
commit 69c6449ff10fe4e3219e960549307096d5366bd0
Author: Max Reitz <[email protected]>
blkdebug: Allow taking/unsharing permissions
commit 16c5c6928ff53bd95e6504301ef6c285501531e7
Author: Laurent Vivier <[email protected]>
migration-test: ppc64: fix FORTH test program
commit 30d544839e278dc76017b9a42990c41e84a34377
Author: Jeff Kubascik <[email protected]>
target/arm: Return correct IL bit in merge_syn_data_abort
commit ddad81bd28de665475a87693a93e6cf5d6fd8bab
Author: Laurent Vivier <[email protected]>
runstate: ignore finishmigrate -> prelaunch transition
commit 97e1e06780e70f6e98a0d2df881e0c0927d3aeb6
Author: Dr. David Alan Gilbert <[email protected]>
migration: Rate limit inside host pages
commit 0780ec7be82dd4781e9fd216b5d99a125882ff5a
Author: Gerd Hoffmann <[email protected]>
Revert "vnc: allow fall back to RAW encoding"
commit 557ba0e57200014bd4f453f6516f02b61bdfc782
Author: Cameron Esfahani <[email protected]>
vnc: prioritize ZRLE compression over ZLIB
commit 322f244aaa80a5208090d41481c1c09c6face66b
Author: Laurent Vivier <[email protected]>
m68k: Fix regression causing Single-Step via GDB/RSP to not single step
commit de0b1bae6461f67243282555475f88b2384a1eb9
Author: Vincent Dehors <[email protected]>
target/arm: Fix PAuth sbox functions
commit 420ae1fc51c99abfd03b1c590f55617edd2a2bed
Author: Paolo Bonzini <[email protected]>
target/i386: kvm: initialize feature MSRs very early
commit 3c5fd8074335c67777d9391b84f97070c35d9c63
Author: Cornelia Huck <[email protected]>
s390x: adapter routes error handling
commit fb574de81bfdd71fdb0315105a3a7761efb68395
Author: Eiichi Tsukata <[email protected]>
block/backup: fix memory leak in bdrv_backup_top_append()
commit 71e415c8a75c130875f14d6b2136825789feb297
Author: Marc-André Lureau <[email protected]>
tpm-ppi: page-align PPI RAM
commit 618bacabd3c8c3360be795cd8763bacdf5bec101
Author: Zenghui Yu <[email protected]>
hw/intc/arm_gicv3_kvm: Stop wrongly programming GICR_PENDBASER.PTZ bit
commit 7a4ede0047a8613b0e3b72c9d351038f013dd357
Author: Gerd Hoffmann <[email protected]>
audio/oss: fix buffer pos calculation
commit aeab8e5eb220cc5ff84b0b68b9afccc611bf0fcd
Author: Alex Bennée <[email protected]>
target/arm: fix TCG leak for fcvt half->double
commit cb8956144ccaccf23d5cc4167677e2c84fa5a9f8
Author: Pan Nengyuan <[email protected]>
block: fix memleaks in bdrv_refresh_filename
commit 0df62f45c1de6c020f1e6fba4eeafd248209b003
Author: Vladimir Sementsov-Ogievskiy <[email protected]>
block/backup-top: fix failure path
commit a541fcc27c98b96da187c7d4573f3270f3ddd283
Author: Vladimir Sementsov-Ogievskiy <[email protected]>
iotests: add test for backup-top failure on permission activation
commit 0999a4ba8718aa96105b978d3567fc7e90244c7e
Author: Liang Yan <[email protected]>
target/arm/monitor: query-cpu-model-expansion crashed qemu when using machine type none
commit ac9d00bf7b47acae6b0e42910d9ed55fef3af5b8
Author: Vladimir Sementsov-Ogievskiy <[email protected]>
block: fix crash on zero-length unaligned write and read
commit 804359b8b90f76d9d8fbe8d85a6544b68f107f10
Author: Max Reitz <[email protected]>
block: Fix VM size field width in snapshot dump
commit a1ed04dd79aabb9dbeeb5fa7d49f1a3de0357553
Author: Peter Maydell <[email protected]>
target/arm: Correct definition of PMCRDP
commit 9861546e1dae05c5152de7d3bd14e341ecadc972
Author: Pan Nengyuan <[email protected]>
virtio-pmem: do delete rq_vq in virtio_pmem_unrealize
commit d56e1c8256cb37e68f9b5d98c6cc4e6ca463f1fd
Author: Pan Nengyuan <[email protected]>
virtio-crypto: do delete ctrl_vq in virtio_crypto_device_unrealize
commit 13e5468127111bf44c5dc314d1dd2ec5a65dfec4
Author: Pan Nengyuan <[email protected]>
vhost-user-blk: delete virtioqueues in unrealize to fix memleaks
commit 2104df2a1fbf44b2564427aa72fd58d66ce290a7
Author: Niek Linnenbank <[email protected]>
hw/arm/cubieboard: use ARM Cortex-A8 as the default CPU in machine definition
commit 9bfc04f9ef6802fff0fc77130ff345a541783363
Author: Janosch Frank <[email protected]>
pc-bios: s390x: Save iplb location in lowcore
commit 69135eb30b9c3fca583737a96df015174dc8e6dd
Author: Eric Blake <[email protected]>
iotests: Fix nonportable use of od --endian
commit 1583794b9b36911df116cc726750dadbeeac506a
Author: Philippe Mathieu-Daudé <[email protected]>
ppc/ppc405_boards: Remove unnecessary NULL check
commit 71eaec2e8c7c8d266137b5c5f42da0bd6d6b5eb7
Author: Eric Blake <[email protected]>
block: Avoid memleak on qcow2 image info failure
commit 6e57963a77df1e275a73dab4c6a7ec9a9d3468d4
Author: Vladimir Sementsov-Ogievskiy <[email protected]>
block: bdrv_set_backing_bs: fix use-after-free
commit d4ff109373ce871928c7e9ef648973eba642b484
Author: Dr. David Alan Gilbert <[email protected]>
hmp/vnc: Fix info vnc list leak
commit 27d07fcfa70c3afa0664288cbce5334ed9595a3a
Author: Vladimir Sementsov-Ogievskiy <[email protected]>
migration/colo: fix use after free of local_err
commit b4a1733c5e6827c72b0dcfa295e07ef7b1ebccff
Author: Vladimir Sementsov-Ogievskiy <[email protected]>
migration/ram: fix use after free of local_err
commit bb40ebce2cb0bd4bf37968074d43d5a864fb6dee
Author: Eric Blake <[email protected]>
qcow2: List autoclear bit names in header
commit ed049910637be991c88cc25c864115bc5b1e4dab
Author: Eric Blake <[email protected]>
sheepdog: Consistently set bdrv_has_zero_init_truncate
commit 8ffb7265af64ec81748335ec8f20e7ab542c3850
Author: Prasad J Pandit <[email protected]>
net: tulip: check frame size and r/w data length
commit 7aab5899764887f6b0512cb2e5c11bdc2a5d3644
Author: David Gibson <[email protected]>
spapr: Fix failure path for attempting to hot unplug PCI bridges
commit 3f6de653b946fe849330208becf79d6af7e876cb
Author: Kevin Wolf <[email protected]>
vpc: Don't round up already aligned BAT sizes
commit 1a03362b14affa4d8ddede55df6e21d7a07b87c2
Author: Max Filippov <[email protected]>
target/xtensa: fix pasto in pfwait.r opcode name
commit a4e57084c16d5b0eff3651693fba04f26b30b551
- Bruce
________________________________________
From: Qemu-devel <[email protected]> on behalf of Michael Roth <[email protected]>
Sent: Tuesday, June 16, 2020 8:14 AM
To: [email protected]
Cc: [email protected]
Subject: [PATCH 00/78] Patch Round-up for stable 4.2.1, freeze on 2020-06-22
Hi everyone,
The following new patches are queued for QEMU stable v4.2.1:
https://github.com/mdroth/qemu/commits/stable-4.2-staging
The release is planned for 2020-06-25:
https://wiki.qemu.org/Planning/4.2
Due to delays on my part this release is going out beyond the normal ~4 month support window. v5.0.1 is scheduled to be released as normal.
Please respond here or CC [email protected] on any additional patches you think should be included in the release.
Thanks!
----------------------------------------------------------------
Alex Bennée (2):
target/arm: ensure we use current exception state after SCR update
tcg: save vaddr temp for plugin usage
Alexander Popov (2):
tests/ide-test: Create a single unit-test covering more PRDT cases
ide: Fix incorrect handling of some PRDTs in ide_dma_cb()
Anthony PERARD (1):
xen-block: Fix double qlist remove and request leak
Basil Salman (2):
qga: Installer: Wait for installation to finish
qga-win: prevent crash when executing guest-file-read with large count
Christian Borntraeger (1):
s390/sclp: improve special wait psw logic
Christophe de Dinechin (1):
scsi/qemu-pr-helper: Fix out-of-bounds access to trnptid_list[]
Cornelia Huck (1):
compat: disable edid on correct virtio-gpu device
Daniel P. Berrangé (1):
qapi: better document NVMe blockdev @device parameter
David Hildenbrand (3):
virtio-balloon: fix free page hinting without an iothread
virtio-balloon: fix free page hinting check on unrealize
virtio-balloon: unref the iothread when unrealizing
Denis Plotnikov (1):
virtio-mmio: update queue size on guest write
Eduardo Habkost (1):
i386: Resolve CPU models to v1 by default
Emilio G. Cota (1):
plugins/core: add missing break in cb_to_tcg_flags
Eric Blake (3):
qga: Fix undefined C behavior
nbd/server: Avoid long error message assertions CVE-2020-10761
block: Call attention to truncation of long NBD exports
Finn Thain (14):
dp8393x: Mask EOL bit from descriptor addresses
dp8393x: Always use 32-bit accesses
dp8393x: Clean up endianness hacks
dp8393x: Have dp8393x_receive() return the packet size
dp8393x: Update LLFA and CRDA registers from rx descriptor
dp8393x: Clear RRRA command register bit only when appropriate
dp8393x: Implement packet size limit and RBAE interrupt
dp8393x: Don't clobber packet checksum
dp8393x: Use long-word-aligned RRA pointers in 32-bit mode
dp8393x: Pad frames to word or long word boundary
dp8393x: Clear descriptor in_use field to release packet
dp8393x: Always update RRA pointers and sequence numbers
dp8393x: Don't reset Silicon Revision register
dp8393x: Don't stop reception upon RBE interrupt assertion
Greg Kurz (1):
9p: Lock directory streams with a CoMutex
Igor Mammedov (3):
numa: remove not needed check
numa: properly check if numa is supported
hostmem: don't use mbind() if host-nodes is empty
Kevin Wolf (4):
block: Activate recursively even for already active nodes
qcow2: update_refcount(): Reset old_table_index after qcow2_cache_put()
qcow2: Fix qcow2_alloc_cluster_abort() for external data file
iotests: Test copy offloading with external data file
Li Hangjing (1):
virtio-blk: fix out-of-bounds access to bitmap in notify_guest_bh
Liu Yi L (2):
intel_iommu: a fix to vtd_find_as_from_bus_num()
intel_iommu: add present bit check for pasid table entries
Max Reitz (4):
backup-top: Begin drain earlier
qcow2: Fix alloc_cluster_abort() for pre-existing clusters iotests/026: Test EIO on preallocated zero cluster iotests/026: Test EIO on allocation in a data-file
Michael S. Tsirkin (3):
virtio: update queue size on guest write
virtio: add ability to delete vq through a pointer
virtio: make virtio_delete_queue idempotent
Nicholas Piggin (1):
target/ppc: Fix mtmsr(d) L=1 variant that loses interrupts
Niek Linnenbank (2):
arm/arm-powerctl: set NSACR.{CP11, CP10} bits in arm_set_cpu_on() arm/arm-powerctl: rebuild hflags after setting CP15 bits in arm_set_cpu_on()
Pan Nengyuan (2):
block/nbd: extract the common cleanup code
block/nbd: fix memory leak in nbd_open()
Peter Maydell (2):
hw/i386/amd_iommu.c: Fix corruption of log events passed to guest
dump: Fix writing of ELF section
Peter Wu (1):
hw/i386/pc: fix regression in parsing vga cmdline parameter
Peter Xu (1):
vfio/pci: Don't remove irqchip notifier if not registered
Philippe Mathieu-Daudé (1):
vhost-user-gpu: Release memory returned by vu_queue_pop() with free()
Raphael Pour (1):
qemu-nbd: Close inherited stderr
Richard Henderson (3):
target/arm: Set ISSIs16Bit in make_issinfo tcg/i386: Fix INDEX_op_dup2_vec
target/arm: Clear tail in gvec_fmul_idx_*, gvec_fmla_idx_*
Sameeh Jubran (1):
qga-win: Handle VSS_E_PROVIDER_ALREADY_REGISTERED error
Stefan Hajnoczi (2):
virtio: gracefully handle invalid region caches
qemu-ga: document vsock-listen in the man page
Thomas Huth (1):
net: Do not include a newline in the id of -nic devices
Vitaly Chikunov (1):
target/ppc: Fix rlwinm on ppc64
Vladimir Sementsov-Ogievskiy (5):
qcow2-bitmaps: fix qcow2_can_store_new_dirty_bitmap block/qcow2-threads: fix qcow2_decompress
job: refactor progress to separate object block/block-copy: fix progress calculation block/io: fix bdrv_co_do_copy_on_readv
Yuri Benditovich (2):
virtio: reset region cache when on queue deletion
virtio-net: delete also control queue when TX/RX deleted
backends/hostmem.c | 6 +- block.c | 57 +++++------ block/backup-top.c | 4 +- block/backup.c | 13 +-- block/block-copy.c | 16 ++- block/io.c | 2 +- block/nbd.c | 48 +++++---- block/qcow2-bitmap.c | 41 ++++---- block/qcow2-cluster.c | 7 +- block/qcow2-refcount.c | 1 + block/qcow2-threads.c | 12 ++- blockjob.c | 16 +-- contrib/vhost-user-gpu/main.c | 4 +- contrib/vhost-user-gpu/virgl.c | 2 +- docs/interop/qemu-ga.rst | 5 +- dump/dump.c | 2 +- hw/9pfs/9p.h | 8 +- hw/arm/sbsa-ref.c | 1 - hw/block/dataplane/virtio-blk.c | 2 +- hw/block/dataplane/xen-block.c | 48 +++------ hw/core/machine.c | 6 +- hw/core/numa.c | 7 +- hw/i386/amd_iommu.c | 2 +- hw/i386/intel_iommu.c | 93 +++++++++++++---- hw/i386/intel_iommu_internal.h | 1 + hw/i386/x86.c | 8 +- hw/ide/core.c | 30 ++++-- hw/net/dp8393x.c | 200 ++++++++++++++++++++++++------------- hw/net/virtio-net.c | 3 +- hw/vfio/pci.c | 4 +- hw/virtio/virtio-balloon.c | 36 +++---- hw/virtio/virtio-mmio.c | 3 +- hw/virtio/virtio-pci.c | 2 + hw/virtio/virtio.c | 116 ++++++++++++++++++--- include/block/block-copy.h | 15 +-- include/hw/virtio/virtio.h | 2 + include/qemu/job.h | 11 +- include/qemu/progress_meter.h | 58 +++++++++++ job-qmp.c | 4 +- job.c | 6 +- nbd/server.c | 23 ++++- net/net.c | 2 +- plugins/core.c | 1 + qapi/block-core.json | 6 +- qemu-deprecated.texi | 8 ++ qemu-img.c | 6 +- qemu-nbd.c | 6 +- qga/commands-win32.c | 8 +- qga/commands.c | 9 +- qga/installer/qemu-ga.wxs | 2 +- qga/main.c | 4 +- qga/vss-win32/install.cpp | 11 ++ scsi/qemu-pr-helper.c | 17 ++-- target/arm/arm-powerctl.c | 6 ++ target/arm/cpu.h | 8 +- target/arm/helper.c | 14 ++- target/arm/helper.h | 1 + target/arm/translate.c | 9 +- target/arm/vec_helper.c | 2 + target/i386/cpu.c | 8 +- target/ppc/translate.c | 66 ++++++------ target/s390x/helper.c | 2 +- tcg/i386/tcg-target.inc.c | 10 +- tcg/tcg-op.c | 23 ++++- tests/ide-test.c | 174 ++++++++++++++------------------ tests/qemu-iotests/026 | 53 ++++++++++ tests/qemu-iotests/026.out | 16 +++ tests/qemu-iotests/026.out.nocache | 16 +++ tests/qemu-iotests/143 | 4 + tests/qemu-iotests/143.out | 2 + tests/qemu-iotests/244 | 14 +++ tests/qemu-iotests/244.out | 6 ++ 72 files changed, 963 insertions(+), 476 deletions(-) create mode 100644 include/qemu/progress_meter.h
Quoting Michael Roth (2020-06-16 09:14:29)
Quoted 8 lines
Hi everyone,
The following new patches are queued for QEMU stable v4.2.1:
https://github.com/mdroth/qemu/commits/stable-4.2-staging
The release is planned for 2020-06-25:
Quoted 7 lines
https://wiki.qemu.org/Planning/4.2
Due to delays on my part this release is going out beyond the normal ~4 month support window. v5.0.1 is scheduled to be released as normal.
Please respond here or CC [email protected] on any additional patches you think should be included in the release.
The following additional patches have been added to the staging tree:
iotests/283: Use consistent size for source and target
Fix tulip breakage
tcg/mips: mips sync* encode error
target/xtensa: fix pasto in pfwait.r opcode name
vpc: Don't round up already aligned BAT sizes
spapr: Fix failure path for attempting to hot unplug PCI bridges
net: tulip: check frame size and r/w data length
sheepdog: Consistently set bdrv_has_zero_init_truncate
qcow2: List autoclear bit names in header
migration/ram: fix use after free of local_err
migration/colo: fix use after free of local_err
hmp/vnc: Fix info vnc list leak
block: bdrv_set_backing_bs: fix use-after-free
block: Avoid memleak on qcow2 image info failure
ppc/ppc405_boards: Remove unnecessary NULL check
iotests: Fix nonportable use of od --endian
pc-bios: s390x: Save iplb location in lowcore
hw/arm/cubieboard: use ARM Cortex-A8 as the default CPU in machine definition
vhost-user-blk: delete virtioqueues in unrealize to fix memleaks
virtio-crypto: do delete ctrl_vq in virtio_crypto_device_unrealize
virtio-pmem: do delete rq_vq in virtio_pmem_unrealize
target/arm: Correct definition of PMCRDP
block: Fix VM size field width in snapshot dump
block: fix crash on zero-length unaligned write and read target/arm/monitor: query-cpu-model-expansion crashed qemu when using machine type none
iotests: add test for backup-top failure on permission activation block/backup-top: fix failure path
block: fix memleaks in bdrv_refresh_filename
target/arm: fix TCG leak for fcvt half->double
audio/oss: fix buffer pos calculation
hw/intc/arm_gicv3_kvm: Stop wrongly programming GICR_PENDBASER.PTZ bit
tpm-ppi: page-align PPI RAM
block/backup: fix memory leak in bdrv_backup_top_append()
s390x: adapter routes error handling
target/i386: kvm: initialize feature MSRs very early
target/arm: Fix PAuth sbox functions
m68k: Fix regression causing Single-Step via GDB/RSP to not single step Revert "vnc: allow fall back to RAW encoding"
migration: Rate limit inside host pages
runstate: ignore finishmigrate -> prelaunch transition
target/arm: Return correct IL bit in merge_syn_data_abort
migration-test: ppc64: fix FORTH test program
blkdebug: Allow taking/unsharing permissions
block: Add bdrv_qapi_perm_to_blk_perm()
hw/arm/smmuv3: Report F_STE_FETCH fault address in correct word position hw/arm/smmuv3: Use correct bit positions in EVT_SET_ADDR2 macro hw/arm/smmuv3: Align stream table base address to table size hw/arm/smmuv3: Check stream IDs against actual table LOG2SIZE hw/arm/smmuv3: Correct SMMU_BASE_ADDR_MASK value
hw/arm/smmuv3: Apply address mask to linear strtab base address display/bochs-display: fix memory leak
vhost-user-gpu: Drop trailing json comma
iotests: Fix IMGOPTSSYNTAX for nbd
Fix double free issue in qemu_set_log_filename().
Revert "qemu-options.hx: Update for reboot-timeout parameter" iotests/026: Move v3-exclusive test to new file
dp8393x: Mask EOL bit from descriptor addresses, take 2
slirp: update to fix CVE-2020-1983
kvm: Reallocate dirty_bmap when we change a slot
es1370: check total frame count against current frame
ati-vga: check mm_index before recursive call (CVE-2020-13800)
ati-vga: Fix checks in ati_2d_blt() to avoid crash
iscsi: Cap block count from GET LBA STATUS (CVE-2020-1711)
target/i386: do not set unsupported VMX secondary execution controls target/riscv: update mstatus.SD when FS is set dirty
target/riscv: fsd/fsw doesn't dirty FP state
target/riscv: Fix tb->flags FS status
riscv: Set xPIE to 1 after xRET
riscv/sifive_u: fix a memory leak in soc_realize()
tests: fix modules-test 'duplicate test case' error
Thanks everyone for the suggestions.
Quoted 231 lines
Thanks!
----------------------------------------------------------------
Alex Bennée (2):
target/arm: ensure we use current exception state after SCR update
tcg: save vaddr temp for plugin usageAlexander Popov (2):
tests/ide-test: Create a single unit-test covering more PRDT cases
ide: Fix incorrect handling of some PRDTs inide_dma_cb()Anthony PERARD (1):
xen-block: Fix double qlist remove and request leakBasil Salman (2):
qga: Installer: Wait for installation to finish
qga-win: prevent crash when executing guest-file-read with large countChristian Borntraeger (1):
s390/sclp: improve special wait psw logicChristophe de Dinechin (1):
scsi/qemu-pr-helper: Fix out-of-bounds access to trnptid_list[]Cornelia Huck (1):
compat: disable edid on correct virtio-gpu deviceDaniel P. Berrangé (1):
qapi: better document NVMe blockdev @device parameterDavid Hildenbrand (3):
virtio-balloon: fix free page hinting without an iothread
virtio-balloon: fix free page hinting check on unrealize
virtio-balloon: unref the iothread when unrealizingDenis Plotnikov (1):
virtio-mmio: update queue size on guest writeEduardo Habkost (1):
i386: Resolve CPU models to v1 by defaultEmilio G. Cota (1):
plugins/core: add missing break incb_to_tcg_flagsEric Blake (3):
qga: Fix undefined C behavior
nbd/server: Avoid long error message assertions CVE-2020-10761
block: Call attention to truncation of long NBD exportsFinn Thain (14):
dp8393x: Mask EOL bit from descriptor addresses
dp8393x: Always use 32-bit accesses
dp8393x: Clean up endianness hacks
dp8393x: Havedp8393x_receive()return the packet size
dp8393x: Update LLFA and CRDA registers from rx descriptor
dp8393x: Clear RRRA command register bit only when appropriate
dp8393x: Implement packet size limit and RBAE interrupt
dp8393x: Don't clobber packet checksum
dp8393x: Use long-word-aligned RRA pointers in 32-bit mode
dp8393x: Pad frames to word or long word boundary
dp8393x: Clear descriptorin_usefield to release packet
dp8393x: Always update RRA pointers and sequence numbers
dp8393x: Don't reset Silicon Revision register
dp8393x: Don't stop reception upon RBE interrupt assertionGreg Kurz (1):
9p: Lock directory streams with a CoMutexIgor Mammedov (3):
numa: remove not needed check
numa: properly check if numa is supported
hostmem: don't usembind()if host-nodes is emptyKevin Wolf (4):
block: Activate recursively even for already active nodes
qcow2:update_refcount(): Resetold_table_indexafterqcow2_cache_put()
qcow2: Fixqcow2_alloc_cluster_abort()for external data file
iotests: Test copy offloading with external data fileLi Hangjing (1):
virtio-blk: fix out-of-bounds access to bitmap innotify_guest_bhLiu Yi L (2):
intel_iommu: a fix tovtd_find_as_from_bus_num()
intel_iommu: add present bit check for pasid table entriesMax Reitz (4):
backup-top: Begin drain earlier
qcow2: Fixalloc_cluster_abort()for pre-existing clusters iotests/026: Test EIO on preallocated zero cluster iotests/026: Test EIO on allocation in a data-fileMichael S. Tsirkin (3):
virtio: update queue size on guest write
virtio: add ability to delete vq through a pointer
virtio: makevirtio_delete_queueidempotentNicholas Piggin (1):
target/ppc: Fix mtmsr(d) L=1 variant that loses interruptsNiek Linnenbank (2):
arm/arm-powerctl: set NSACR.{CP11, CP10} bits inarm_set_cpu_on()arm/arm-powerctl: rebuild hflags after setting CP15 bits inarm_set_cpu_on()Pan Nengyuan (2):
block/nbd: extract the common cleanup code
block/nbd: fix memory leak innbd_open()Peter Maydell (2):
hw/i386/amd_iommu.c: Fix corruption of log events passed to guest
dump: Fix writing of ELF sectionPeter Wu (1):
hw/i386/pc: fix regression in parsing vga cmdline parameterPeter Xu (1):
vfio/pci: Don't remove irqchip notifier if not registeredPhilippe Mathieu-Daudé (1):
vhost-user-gpu: Release memory returned byvu_queue_pop()withfree()Raphael Pour (1):
qemu-nbd: Close inherited stderrRichard Henderson (3):
target/arm: Set ISSIs16Bit inmake_issinfotcg/i386: FixINDEX_op_dup2_vec
target/arm: Clear tail in gvec_fmul_idx_*, gvec_fmla_idx_*Sameeh Jubran (1):
qga-win: HandleVSS_E_PROVIDER_ALREADY_REGISTEREDerrorStefan Hajnoczi (2):
virtio: gracefully handle invalid region caches
qemu-ga: document vsock-listen in the man pageThomas Huth (1):
net: Do not include a newline in the id of -nic devicesVitaly Chikunov (1):
target/ppc: Fix rlwinm on ppc64Vladimir Sementsov-Ogievskiy (5):
qcow2-bitmaps: fixqcow2_can_store_new_dirty_bitmapblock/qcow2-threads: fixqcow2_decompress
job: refactor progress to separate objectblock/block-copy: fix progress calculation block/io: fixbdrv_co_do_copy_on_readvYuri Benditovich (2):
virtio: reset region cache when on queue deletion
virtio-net: delete also control queue when TX/RX deletedbackends/hostmem.c | 6 +- block.c | 57 +++++------ block/backup-top.c | 4 +- block/backup.c | 13 +-- block/block-copy.c | 16 ++- block/io.c | 2 +- block/nbd.c | 48 +++++---- block/qcow2-bitmap.c | 41 ++++---- block/qcow2-cluster.c | 7 +- block/qcow2-refcount.c | 1 + block/qcow2-threads.c | 12 ++- blockjob.c | 16 +-- contrib/vhost-user-gpu/main.c | 4 +- contrib/vhost-user-gpu/virgl.c | 2 +- docs/interop/qemu-ga.rst | 5 +- dump/dump.c | 2 +- hw/9pfs/9p.h | 8 +- hw/arm/sbsa-ref.c | 1 - hw/block/dataplane/virtio-blk.c | 2 +- hw/block/dataplane/xen-block.c | 48 +++------ hw/core/machine.c | 6 +- hw/core/numa.c | 7 +- hw/i386/amd_iommu.c | 2 +- hw/i386/intel_iommu.c | 93 +++++++++++++---- hw/i386/intel_iommu_internal.h | 1 + hw/i386/x86.c | 8 +- hw/ide/core.c | 30 ++++-- hw/net/dp8393x.c | 200 ++++++++++++++++++++++++------------- hw/net/virtio-net.c | 3 +- hw/vfio/pci.c | 4 +- hw/virtio/virtio-balloon.c | 36 +++---- hw/virtio/virtio-mmio.c | 3 +- hw/virtio/virtio-pci.c | 2 + hw/virtio/virtio.c | 116 ++++++++++++++++++--- include/block/block-copy.h | 15 +-- include/hw/virtio/virtio.h | 2 + include/qemu/job.h | 11 +- include/qemu/progress_meter.h | 58 +++++++++++ job-qmp.c | 4 +- job.c | 6 +- nbd/server.c | 23 ++++- net/net.c | 2 +- plugins/core.c | 1 + qapi/block-core.json | 6 +- qemu-deprecated.texi | 8 ++ qemu-img.c | 6 +- qemu-nbd.c | 6 +- qga/commands-win32.c | 8 +- qga/commands.c | 9 +- qga/installer/qemu-ga.wxs | 2 +- qga/main.c | 4 +- qga/vss-win32/install.cpp | 11 ++ scsi/qemu-pr-helper.c | 17 ++-- target/arm/arm-powerctl.c | 6 ++ target/arm/cpu.h | 8 +- target/arm/helper.c | 14 ++- target/arm/helper.h | 1 + target/arm/translate.c | 9 +- target/arm/vec_helper.c | 2 + target/i386/cpu.c | 8 +- target/ppc/translate.c | 66 ++++++------ target/s390x/helper.c | 2 +- tcg/i386/tcg-target.inc.c | 10 +- tcg/tcg-op.c | 23 ++++- tests/ide-test.c | 174 ++++++++++++++------------------ tests/qemu-iotests/026 | 53 ++++++++++ tests/qemu-iotests/026.out | 16 +++ tests/qemu-iotests/026.out.nocache | 16 +++ tests/qemu-iotests/143 | 4 + tests/qemu-iotests/143.out | 2 + tests/qemu-iotests/244 | 14 +++ tests/qemu-iotests/244.out | 6 ++ 72 files changed, 963 insertions(+), 476 deletions(-) create mode 100644 include/qemu/progress_meter.h