Skip to contentSkip to conversation

Patch Round-up for stable 6.1.1, freeze on 2021-12-21

PATCH In review Michael Roth 3 participants 51 messages Dec 15, 2021 – Dec 20, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover Patch Round-up for stable 6.1.1, freeze on 2021-12-21

Hi everyone,

The following new patches are queued for QEMU stable v6.1.1:

https://gitlab.com/qemu-project/qemu/-/commits/stable-6.1-staging/

Patch freeze is 2021-12-21, and the release is planned for 2021-12-23:

https://wiki.qemu.org/Planning/6.1

Please respond here or CC [email protected] on any additional patches you think should (or shouldn't) be included in the release.

Thanks!

----------------------------------------------------------------
Ani Sinha (6):
bios-tables-test: allow changes in DSDT ACPI tables for q35 hw/i386/acpi: fix conflicting IO address range for acpi pci hotplug in q35
bios-tables-test: Update ACPI DSDT table golden blobs for q35 tests/acpi/bios-tables-test: add and allow changes to a new q35 DSDT table blob tests/acpi/pcihp: add unit tests for hotplug on multifunction bridges for q35 tests/acpi/bios-tables-test: update DSDT blob for multifunction bridge test

Ari Sundholm (1):
block/file-posix: Fix return value translation for AIO discards

Christian Schoenebeck (1):
9pfs: fix crash in v9fs_walk()

Daniil Tatianin (1):
chardev/wctable: don't free the instance in wctablet_chr_finalize

David Hildenbrand (3):
virtio-balloon: don't start free page hinting if postcopy is possible
virtio-mem-pci: Fix memory leak when creating MEMORY_DEVICE_SIZE_CHANGE event
libvhost-user: fix VHOST_USER_REM_MEM_REG skipping mmap_addr

Eric Blake (1):
nbd/server: Don't complain on certain client disconnects

Gerd Hoffmann (1):
uas: add stream number sanity checks.

Greg Kurz (2):
rcu: Introduce force_rcu notifier
accel/tcg: Register a force_rcu notifier

Helge Deller (1):
hw/display/artist: Fix bug in coordinate extraction in artist_vram_read() and artist_vram_write()

Igor Mammedov (1):
pcie: rename 'native-hotplug' to 'x-native-hotplug'

Jason Wang (3):
virtio-net: fix use after unmap/free for sg
virtio: use virtio accessor to access packed descriptor flags
virtio: use virtio accessor to access packed event

Jean-Philippe Brucker (2):
hw/arm/virt: Rename default_bus_bypass_iommu hw/i386: Rename default_bus_bypass_iommu

Jessica Clarke (1):
Partially revert "build: -no-pie is no functional linker flag"

Jon Maloy (1):
e1000: fix tx re-entrancy problem

Klaus Jensen (1):
hw/nvme: fix buffer overrun in nvme_changed_nslist (CVE-2021-3947)

Laurent Vivier (1):
hw: m68k: virt: Add compat machine for 6.1

Mahmoud Mandour (1):
plugins/execlog: removed unintended "s" at the end of log lines.

Mark Mielke (1):
virtio-blk: Fix clean up of host notifiers for single MR transaction.

Markus Armbruster (1):
hmp: Unbreak "change vnc"

Mauro Matteo Cascella (1):
hw/scsi/scsi-disk: MODE_PAGE_ALLS not allowed in MODE SELECT commands

Michael S. Tsirkin (1):
pci: fix PCI resource reserve capability on BE

Michael Tokarev (1):
qemu-sockets: fix unix socket path copy (again)

Nir Soffer (1):
qemu-nbd: Change default cache mode to writeback

Paolo Bonzini (4):
plugins: do not limit exported symbols if modules are active
block: introduce max_hw_iov for use in scsi-generic
target-i386: mmu: use pg_mode instead of HF_LMA_MASK
target-i386: mmu: fix handling of noncanonical virtual addresses

Peng Liang (1):
vfio: Fix memory leak of hostwin

Peter Maydell (1):
target/arm: Don't skip M-profile reset entirely in user mode

Philippe Mathieu-Daudé (3):
hw/block/fdc: Extract blk_create_empty_drive() hw/block/fdc: Kludge missing floppy drive to fix CVE-2021-20196 tests/qtest/fdc-test: Add a regression test for CVE-2021-20196

Prasad J Pandit (1):
net: vmxnet3: validate configuration values during activate (CVE-2021-20203)

Stefano Garzarella (1):
vhost-vsock: fix migration issue when seqpacket is supported

Xueming Li (1):
vhost-user: fix duplicated notifier MR init

Yang Zhong (1):
i386/cpu: Remove AVX_VNNI feature from Cooperlake cpu model

 accel/tcg/tcg-accel-ops-mttcg.c           |  26 ++++++++++++++++++++
 accel/tcg/tcg-accel-ops-rr.c              |  10 ++++++++
 block/block-backend.c                     |   6 +++++
 block/file-posix.c                        |   6 ++---
 block/io.c                                |   1 +
 chardev/wctablet.c                        |   1 -
 configure                                 |  10 +++++---
 contrib/plugins/execlog.c                 |   2 +-
 docs/tools/qemu-nbd.rst                   |   6 +++--
 hw/9pfs/coth.h                            |   4 ++-
 hw/arm/virt.c                             |   4 +--
 hw/block/dataplane/virtio-blk.c           |   2 +-
 hw/block/fdc.c                            |  23 +++++++++++++++---
 hw/core/machine.c                         |   1 +
 hw/display/artist.c                       |   8 +++---
 hw/i386/pc.c                              |   2 +-
 hw/i386/pc_q35.c                          |   2 +-
 hw/m68k/virt.c                            |   9 ++++++-
 hw/net/e1000.c                            |   7 ++++++
 hw/net/virtio-net.c                       |  39 ++++++++++++++++++++++++------
 hw/net/vmxnet3.c                          |  13 ++++++++++
 hw/nvme/ctrl.c                            |   5 ++++
 hw/pci/pci_bridge.c                       |  10 ++++----
 hw/pci/pcie_port.c                        |   2 +-
 hw/scsi/scsi-disk.c                       |   6 +++++
 hw/scsi/scsi-generic.c                    |   2 +-
 hw/usb/dev-uas.c                          |  11 +++++++++
 hw/vfio/common.c                          |   8 ++++++
 hw/virtio/vhost-user.c                    |   5 ++--
 hw/virtio/vhost-vsock.c                   |  19 ++++++++++++---
 hw/virtio/virtio-balloon.c                |  13 ++++++++++
 hw/virtio/virtio-mem-pci.c                |   7 +-----
 hw/virtio/virtio.c                        |  24 ++++++------------
 include/block/block_int.h                 |   7 ++++++
 include/hw/acpi/ich9.h                    |   2 +-
 include/hw/virtio/vhost-vsock.h           |   3 +++
 include/qemu/rcu.h                        |  15 ++++++++++++
 include/sysemu/block-backend.h            |   1 +
 monitor/hmp-cmds.c                        |   2 +-
 nbd/server.c                              |   3 +++
 plugins/meson.build                       |  14 ++++++-----
 qemu-nbd.c                                |   6 +++--
 subprojects/libvhost-user/libvhost-user.c |   1 +
 target/arm/cpu.c                          |  19 +++++++++++++++
 target/i386/cpu.c                         |   2 +-
 target/i386/tcg/sysemu/excp_helper.c      |  25 ++++++++++---------
 tests/data/acpi/q35/DSDT                  | Bin 8289 -> 8289 bytes
 tests/data/acpi/q35/DSDT.acpihmat         | Bin 9614 -> 9614 bytes
 tests/data/acpi/q35/DSDT.bridge           | Bin 11003 -> 11003 bytes
 tests/data/acpi/q35/DSDT.cphp             | Bin 8753 -> 8753 bytes
 tests/data/acpi/q35/DSDT.dimmpxm          | Bin 9943 -> 9943 bytes
 tests/data/acpi/q35/DSDT.ipmibt           | Bin 8364 -> 8364 bytes
 tests/data/acpi/q35/DSDT.memhp            | Bin 9648 -> 9648 bytes
 tests/data/acpi/q35/DSDT.mmio64           | Bin 9419 -> 9419 bytes
 tests/data/acpi/q35/DSDT.multi-bridge     | Bin 0 -> 8583 bytes
 tests/data/acpi/q35/DSDT.nohpet           | Bin 8147 -> 8147 bytes
 tests/data/acpi/q35/DSDT.numamem          | Bin 8295 -> 8295 bytes
 tests/data/acpi/q35/DSDT.tis              | Bin 8894 -> 8894 bytes
 tests/qtest/bios-tables-test.c            |  18 ++++++++++++++
 tests/qtest/fdc-test.c                    |  38 +++++++++++++++++++++++++++++
 util/qemu-sockets.c                       |  13 ++++------
 util/rcu.c                                |  19 +++++++++++++++
 62 files changed, 386 insertions(+), 96 deletions(-)
 create mode 100644 tests/data/acpi/q35/DSDT.multi-bridge
#1 lore raw

PATCH 1/47 virtio-balloon: don't start free page hinting if postcopy is possible

From: David Hildenbrand <[email protected]>

Postcopy never worked properly with 'free-page-hint=on', as there are at least two issues:

1) With postcopy, the guest will never receive a VIRTIO_BALLOON_CMD_ID_DONE and consequently won't release free pages back to the OS once migration finishes.

The issue is that for postcopy, we won't do a final bitmap sync while the guest is stopped on the source and virtio_balloon_free_page_hint_notify() will only call virtio_balloon_free_page_done() on the source during PRECOPY_NOTIFY_CLEANUP, after the VM state was already migrated to the destination.

2) Once the VM touches a page on the destination that has been excluded from migration on the source via qemu_guest_free_page_hint() while postcopy is active, that thread will stall until postcopy finishes and all threads are woken up. (with older Linux kernels that won't retry faults when woken up via userfaultfd, we might actually get a SEGFAULT)

The issue is that the source will refuse to migrate any pages that are not marked as dirty in the dirty bmap -- for example, because the page might just have been sent. Consequently, the faulting thread will stall, waiting for the page to be migrated -- which could take quite a while and result in guest OS issues.

While we could fix 1) comparatively easily, 2) is harder to get right and might require more involved RAM migration changes on source and destination [1].

As it never worked properly, let's not start free page hinting in the precopy notifier if the postcopy migration capability was enabled to fix it easily. Capabilities cannot be enabled once migration is already running.

Note 1: in the future we might either adjust migration code on the source
to track pages that have actually been sent or adjust migration code on source and destination to eventually send pages multiple times from the source and and deal with pages that are sent multiple times on the destination.

Note 2: virtio-mem has similar issues, however, access to "unplugged"
memory by the guest is very rare and we would have to be very lucky for it to happen during migration. The spec states "The driver SHOULD NOT read from unplugged memory blocks ..." and "The driver MUST NOT write to unplugged memory blocks". virtio-mem will move away from virtio_balloon_free_page_done() soon and handle this case explicitly on the destination.

[1] https://lkml.kernel.org/r/[email protected]

Fixes c13c4153f76d ("virtio-balloon: VIRTIO_BALLOON_F_FREE_PAGE_HINT")
Cc Wei Wang <[email protected]>
Cc Michael S. Tsirkin <[email protected]>
Cc Philippe Mathieu-Daudé <[email protected]>
Cc Alexander Duyck <[email protected]>
Cc Juan Quintela <[email protected]>
Cc "Dr. David Alan Gilbert" <[email protected]>
Cc Peter Xu <[email protected]>

Message-Id: <[email protected]>

(cherry picked from commit fd51e54fa10221e5a8add894c38cc1cf199f4bc4)
---
 hw/virtio/virtio-balloon.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
hw/virtio/virtio-balloon.c +13 -0
index 4b5d9e5e50..ae7867a8db 100644
@@ -30,6 +30,7 @@
 #include "trace.h"
 #include "qemu/error-report.h"
 #include "migration/misc.h"
+#include "migration/migration.h"
 
 #include "hw/virtio/virtio-bus.h"
 #include "hw/virtio/virtio-access.h"
@@ -662,6 +663,18 @@ virtio_balloon_free_page_hint_notify(NotifierWithReturn *n, void *data)
         return 0;
     }
 
+    /*
+     * Pages hinted via qemu_guest_free_page_hint() are cleared from the dirty
+     * bitmap and will not get migrated, especially also not when the postcopy
+     * destination starts using them and requests migration from the source; the
+     * faulting thread will stall until postcopy migration finishes and
+     * all threads are woken up. Let's not start free page hinting if postcopy
+     * is possible.
+     */
+    if (migrate_postcopy_ram()) {
+        return 0;
+    }
+
     switch (pnd->reason) {
     case PRECOPY_NOTIFY_BEFORE_BITMAP_SYNC:
         virtio_balloon_free_page_stop(dev);
Signature · 1 line
2.25.1
#2 lore raw

PATCH 2/47 target/arm: Don't skip M-profile reset entirely in user mode

In reply to Michael Roth

From: Peter Maydell <[email protected]>

Currently all of the M-profile specific code in arm_cpu_reset() is inside a !defined(CONFIG_USER_ONLY) ifdef block. This is
unintentional: it happened because originally the only M-profile-specific handling was the setup of the initial SP and PC from the vector table, which is system-emulation only. But then we added a lot of other M-profile setup to the same "if (ARM_FEATURE_M)" code block without noticing that it was all inside a not-user-mode ifdef. This has generally been harmless, but with the addition of v8.1M low-overhead-loop support we ran into a problem: the reset of FPSCR.LTPSIZE to 4 was only being done for system emulation mode, so if a user-mode guest tried to execute the LE instruction it would incorrectly take a UsageFault.

Adjust the ifdefs so only the really system-emulation specific parts are covered. Because this means we now run some reset code that sets up initial values in the FPCCR and similar FPU related registers, explicitly set up the registers controlling FPU context handling in user-emulation mode so that the FPU works by design and not by chance.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/613

Message-id: [email protected]

(cherry picked from commit b62ceeaf8096fdbbbfdc6087da0028bc4a4dd77e)
---
 target/arm/cpu.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
target/arm/cpu.c +19 -0
index 2866dd7658..af60c07ca1 100644
@@ -265,12 +265,15 @@ static void arm_cpu_reset(DeviceState *dev)
         env->uncached_cpsr = ARM_CPU_MODE_SVC;
     }
     env->daif = PSTATE_D | PSTATE_A | PSTATE_I | PSTATE_F;
+#endif
 
     if (arm_feature(env, ARM_FEATURE_M)) {
+#ifndef CONFIG_USER_ONLY
         uint32_t initial_msp; /* Loaded from 0x0 */
         uint32_t initial_pc; /* Loaded from 0x4 */
         uint8_t *rom;
         uint32_t vecbase;
+#endif
 
         if (cpu_isar_feature(aa32_lob, cpu)) {
             /*
@@ -324,6 +327,8 @@ static void arm_cpu_reset(DeviceState *dev)
             env->v7m.fpccr[M_REG_S] = R_V7M_FPCCR_ASPEN_MASK |
                 R_V7M_FPCCR_LSPEN_MASK | R_V7M_FPCCR_S_MASK;
         }
+
+#ifndef CONFIG_USER_ONLY
         /* Unlike A/R profile, M profile defines the reset LR value */
         env->regs[14] = 0xffffffff;
 
@@ -352,8 +357,22 @@ static void arm_cpu_reset(DeviceState *dev)
         env->regs[13] = initial_msp & 0xFFFFFFFC;
         env->regs[15] = initial_pc & ~1;
         env->thumb = initial_pc & 1;
+#else
+        /*
+         * For user mode we run non-secure and with access to the FPU.
+         * The FPU context is active (ie does not need further setup)
+         * and is owned by non-secure.
+         */
+        env->v7m.secure = false;
+        env->v7m.nsacr = 0xcff;
+        env->v7m.cpacr[M_REG_NS] = 0xf0ffff;
+        env->v7m.fpccr[M_REG_S] &=
+            ~(R_V7M_FPCCR_LSPEN_MASK | R_V7M_FPCCR_S_MASK);
+        env->v7m.control[M_REG_S] |= R_V7M_CONTROL_FPCA_MASK;
+#endif
     }
 
+#ifndef CONFIG_USER_ONLY
     /* AArch32 has a hard highvec setting of 0xFFFF0000.  If we are currently
      * executing as AArch32 then check if highvecs are enabled and
      * adjust the PC accordingly.
Signature · 1 line
2.25.1
#3 lore raw

PATCH 3/47 virtio-net: fix use after unmap/free for sg

In reply to Michael Roth

From: Jason Wang <[email protected]>

When mergeable buffer is enabled, we try to set the num_buffers after the virtqueue elem has been unmapped. This will lead several issues, E.g a use after free when the descriptor has an address which belongs to the non direct access region. In this case we use bounce buffer that is allocated during address_space_map() and freed during address_space_unmap().

Fixing this by storing the elems temporarily in an array and delay the unmap after we set the the num_buffers.

This addresses CVE-2021-3748.

Fixes fbe78f4f55c6 ("virtio-net support")
(cherry picked from commit bedd7e93d01961fcb16a97ae45d93acf357e11f6)
---
 hw/net/virtio-net.c | 39 ++++++++++++++++++++++++++++++++-------
 1 file changed, 32 insertions(+), 7 deletions(-)
hw/net/virtio-net.c +32 -7
index 16d20cdee5..f205331dcf 100644
@@ -1746,10 +1746,13 @@ static ssize_t virtio_net_receive_rcu(NetClientState *nc, const uint8_t *buf,
     VirtIONet *n = qemu_get_nic_opaque(nc);
     VirtIONetQueue *q = virtio_net_get_subqueue(nc);
     VirtIODevice *vdev = VIRTIO_DEVICE(n);
+    VirtQueueElement *elems[VIRTQUEUE_MAX_SIZE];
+    size_t lens[VIRTQUEUE_MAX_SIZE];
     struct iovec mhdr_sg[VIRTQUEUE_MAX_SIZE];
     struct virtio_net_hdr_mrg_rxbuf mhdr;
     unsigned mhdr_cnt = 0;
-    size_t offset, i, guest_offset;
+    size_t offset, i, guest_offset, j;
+    ssize_t err;
 
     if (!virtio_net_can_receive(nc)) {
         return -1;
@@ -1780,6 +1783,12 @@ static ssize_t virtio_net_receive_rcu(NetClientState *nc, const uint8_t *buf,
 
         total = 0;
 
+        if (i == VIRTQUEUE_MAX_SIZE) {
+            virtio_error(vdev, "virtio-net unexpected long buffer chain");
+            err = size;
+            goto err;
+        }
+
         elem = virtqueue_pop(q->rx_vq, sizeof(VirtQueueElement));
         if (!elem) {
             if (i) {
@@ -1791,7 +1800,8 @@ static ssize_t virtio_net_receive_rcu(NetClientState *nc, const uint8_t *buf,
                              n->guest_hdr_len, n->host_hdr_len,
                              vdev->guest_features);
             }
-            return -1;
+            err = -1;
+            goto err;
         }
 
         if (elem->in_num < 1) {
@@ -1799,7 +1809,8 @@ static ssize_t virtio_net_receive_rcu(NetClientState *nc, const uint8_t *buf,
                          "virtio-net receive queue contains no in buffers");
             virtqueue_detach_element(q->rx_vq, elem, 0);
             g_free(elem);
-            return -1;
+            err = -1;
+            goto err;
         }
 
         sg = elem->in_sg;
@@ -1836,12 +1847,13 @@ static ssize_t virtio_net_receive_rcu(NetClientState *nc, const uint8_t *buf,
         if (!n->mergeable_rx_bufs && offset < size) {
             virtqueue_unpop(q->rx_vq, elem, total);
             g_free(elem);
-            return size;
+            err = size;
+            goto err;
         }
 
-        /* signal other side */
-        virtqueue_fill(q->rx_vq, elem, total, i++);
-        g_free(elem);
+        elems[i] = elem;
+        lens[i] = total;
+        i++;
     }
 
     if (mhdr_cnt) {
@@ -1851,10 +1863,23 @@ static ssize_t virtio_net_receive_rcu(NetClientState *nc, const uint8_t *buf,
                      &mhdr.num_buffers, sizeof mhdr.num_buffers);
     }
 
+    for (j = 0; j < i; j++) {
+        /* signal other side */
+        virtqueue_fill(q->rx_vq, elems[j], lens[j], j);
+        g_free(elems[j]);
+    }
+
     virtqueue_flush(q->rx_vq, i);
     virtio_notify(vdev, q->rx_vq);
 
     return size;
+
+err:
+    for (j = 0; j < i; j++) {
+        g_free(elems[j]);
+    }
+
+    return err;
 }
 
 static ssize_t virtio_net_do_receive(NetClientState *nc, const uint8_t *buf,
Signature · 1 line
2.25.1
#4 lore raw

PATCH 4/47 qemu-nbd: Change default cache mode to writeback

In reply to Michael Roth

From: Nir Soffer <[email protected]>

Both qemu and qemu-img use writeback cache mode by default, which is already documented in qemu(1). qemu-nbd uses writethrough cache mode by default, and the default cache mode is not documented.

According to the qemu-nbd(8):

--cache=CACHE
The cache mode to be used with the file. See the documentation of the emulator's -drive cache=... option for allowed values.

qemu(1) says:

The default mode is cache=writeback.

So users have no reason to assume that qemu-nbd is using writethough cache mode. The only hint is the painfully slow writing when using the defaults.

Looking in git history, it seems that qemu used writethrough in the past to support broken guests that did not flush data properly, or could not flush due to limitations in qemu. But qemu-nbd clients can use NBD_CMD_FLUSH to flush data, so using writethrough does not help anyone.

Change the default cache mode to writback, and document the default and available values properly in the online help and manual.

With this change converting image via qemu-nbd is 3.5 times faster.

    $ qemu-img create dst.img 50g
    $ qemu-nbd -t -f raw -k /tmp/nbd.sock dst.img

Before this change:

    $ hyperfine -r3 "./qemu-img convert -p -f raw -O raw -T none -W fedora34.img nbd+unix:///?socket=/tmp/nbd.sock"
    Benchmark #1: ./qemu-img convert -p -f raw -O raw -T none -W fedora34.img nbd+unix:///?socket=/tmp/nbd.sock
      Time (mean ± σ):     83.639 s ±  5.970 s    [User: 2.733 s, System: 6.112 s]
      Range (min … max):   76.749 s … 87.245 s    3 runs

After this change:

    $ hyperfine -r3 "./qemu-img convert -p -f raw -O raw -T none -W fedora34.img nbd+unix:///?socket=/tmp/nbd.sock"
    Benchmark #1: ./qemu-img convert -p -f raw -O raw -T none -W fedora34.img nbd+unix:///?socket=/tmp/nbd.sock
      Time (mean ± σ):     23.522 s ±  0.433 s    [User: 2.083 s, System: 5.475 s]
      Range (min … max):   23.234 s … 24.019 s    3 runs

Users can avoid the issue by using --cache=writeback[1] but the defaults should give good performance for the common use case.

[1] https://bugzilla.redhat.com/1990656

Message-Id: <[email protected]>

(cherry picked from commit 09615257058a0ae87b837bb041f56f7312d9ead8)
---
 docs/tools/qemu-nbd.rst | 6 ++++--
 qemu-nbd.c              | 6 ++++--
 2 files changed, 8 insertions(+), 4 deletions(-)
docs/tools/qemu-nbd.rst +4 -2
index ee862fa0bc..5643da26e9 100644
@@ -98,8 +98,10 @@ driver options if ``--image-opts`` is specified.
 
 .. option:: --cache=CACHE
 
-  The cache mode to be used with the file.  See the documentation of
-  the emulator's ``-drive cache=...`` option for allowed values.
+  The cache mode to be used with the file. Valid values are:
+  ``none``, ``writeback`` (the default), ``writethrough``,
+  ``directsync`` and ``unsafe``. See the documentation of
+  the emulator's ``-drive cache=...`` option for more info.
 
 .. option:: -n, --nocache
 
qemu-nbd.c +4 -2
index 26ffbf15af..6c18fcd19a 100644
@@ -135,7 +135,9 @@ static void usage(const char *name)
 "                            'snapshot.id=[ID],snapshot.name=[NAME]', or\n"
 "                            '[ID_OR_NAME]'\n"
 "  -n, --nocache             disable host cache\n"
-"      --cache=MODE          set cache mode (none, writeback, ...)\n"
+"      --cache=MODE          set cache mode used to access the disk image, the\n"
+"                            valid options are: 'none', 'writeback' (default),\n"
+"                            'writethrough', 'directsync' and 'unsafe'\n"
 "      --aio=MODE            set AIO mode (native, io_uring or threads)\n"
 "      --discard=MODE        set discard mode (ignore, unmap)\n"
 "      --detect-zeroes=MODE  set detect-zeroes mode (off, on, unmap)\n"
@@ -552,7 +554,7 @@ int main(int argc, char **argv)
     bool alloc_depth = false;
     const char *tlscredsid = NULL;
     bool imageOpts = false;
-    bool writethrough = true;
+    bool writethrough = false; /* Client will flush as needed. */
     bool fork_process = false;
     bool list = false;
     int old_stderr = -1;
Signature · 1 line
2.25.1
#5 lore raw

PATCH 5/47 hmp: Unbreak "change vnc"

In reply to Michael Roth

From: Markus Armbruster <[email protected]>

HMP command "change vnc" can take the password as argument, or prompt for it:

(qemu) change vnc password 123
(qemu) change vnc password
Password: ***
(qemu)

This regressed in commit cfb5387a1d "hmp: remove "change vnc TARGET" command", v6.0.0.

(qemu) change vnc passwd 123
Password: ***
(qemu) change vnc passwd
(qemu)

The latter passes NULL to qmp_change_vnc_password(), which is a no-no. Looks like it puts the display into "password required, but none set" state.

The logic error is easy to miss in review, but testing should've caught it.

Fix the obvious way.

Fixes cfb5387a1de2acda23fb5c97d2378b9e7ddf8025

Message-Id: <[email protected]>

(cherry picked from commit 6193344f9337f8b76cd44ce94a32c9900d907d35)
---
 monitor/hmp-cmds.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
monitor/hmp-cmds.c +1 -1
index e00255f7ee..a7e197a90b 100644
@@ -1496,7 +1496,7 @@ void hmp_change(Monitor *mon, const QDict *qdict)
         }
         if (strcmp(target, "passwd") == 0 ||
             strcmp(target, "password") == 0) {
-            if (arg) {
+            if (!arg) {
                 MonitorHMP *hmp_mon = container_of(mon, MonitorHMP, common);
                 monitor_read_password(hmp_mon, hmp_change_read_arg, NULL);
                 return;
Signature · 1 line
2.25.1
#6 lore raw

PATCH 6/47 virtio-mem-pci: Fix memory leak when creating MEMORY_DEVICE_SIZE_CHANGE event

In reply to Michael Roth

From: David Hildenbrand <[email protected]>

Apparently, we don't have to duplicate the string.

Fixes 722a3c783ef4 ("virtio-pci: Send qapi events when the virtio-mem size changes")

Message-Id: <[email protected]>

(cherry picked from commit 75b98cb9f6456ccf194211beffcbf93b0a995fa4)
---
 hw/virtio/virtio-mem-pci.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
hw/virtio/virtio-mem-pci.c +1 -6
index fa5395cd88..7e384b7397 100644
@@ -88,13 +88,8 @@ static void virtio_mem_pci_size_change_notify(Notifier *notifier, void *data)
                                          size_change_notifier);
     DeviceState *dev = DEVICE(pci_mem);
     const uint64_t * const size_p = data;
-    const char *id = NULL;
 
-    if (dev->id) {
-        id = g_strdup(dev->id);
-    }
-
-    qapi_event_send_memory_device_size_change(!!id, id, *size_p);
+    qapi_event_send_memory_device_size_change(!!dev->id, dev->id, *size_p);
 }
 
 static void virtio_mem_pci_class_init(ObjectClass *klass, void *data)
Signature · 1 line
2.25.1
#7 lore raw

PATCH 7/47 uas: add stream number sanity checks.

In reply to Michael Roth

From: Gerd Hoffmann <[email protected]>

The device uses the guest-supplied stream number unchecked, which can lead to guest-triggered out-of-band access to the UASDevice->data3 and UASDevice->status3 fields. Add the missing checks.

Message-Id: <[email protected]>

(cherry picked from commit 13b250b12ad3c59114a6a17d59caf073ce45b33a)
---
 hw/usb/dev-uas.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
hw/usb/dev-uas.c +11 -0
index 263056231c..f6309a5ebf 100644
@@ -840,6 +840,9 @@ static void usb_uas_handle_data(USBDevice *dev, USBPacket *p)
         }
         break;
     case UAS_PIPE_ID_STATUS:
+        if (p->stream > UAS_MAX_STREAMS) {
+            goto err_stream;
+        }
         if (p->stream) {
             QTAILQ_FOREACH(st, &uas->results, next) {
                 if (st->stream == p->stream) {
@@ -867,6 +870,9 @@ static void usb_uas_handle_data(USBDevice *dev, USBPacket *p)
         break;
     case UAS_PIPE_ID_DATA_IN:
     case UAS_PIPE_ID_DATA_OUT:
+        if (p->stream > UAS_MAX_STREAMS) {
+            goto err_stream;
+        }
         if (p->stream) {
             req = usb_uas_find_request(uas, p->stream);
         } else {
@@ -902,6 +908,11 @@ static void usb_uas_handle_data(USBDevice *dev, USBPacket *p)
         p->status = USB_RET_STALL;
         break;
     }
+
+err_stream:
+    error_report("%s: invalid stream %d", __func__, p->stream);
+    p->status = USB_RET_STALL;
+    return;
 }
 
 static void usb_uas_unrealize(USBDevice *dev)
Signature · 1 line
2.25.1
#8 lore raw

PATCH 8/47 vhost-user: fix duplicated notifier MR init

In reply to Michael Roth

From: Xueming Li <[email protected]>

In case of device resume after suspend, VQ notifier MR still valid. Duplicated registrations explode memory block list and slow down device resume.

Fixes 44866521bd6e ("vhost-user: support registering external host notifiers")
Cc Yuwei Zhang <[email protected]>

Message-Id: <[email protected]>

(cherry picked from commit a1ed9ef1de87c3e86ff68589604298ec90875a14)
---
 hw/virtio/vhost-user.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
hw/virtio/vhost-user.c +3 -2
index aec6cc1990..7b35c5d71d 100644
@@ -1469,8 +1469,9 @@ static int vhost_user_slave_handle_vring_host_notifier(struct vhost_dev *dev,
 
     name = g_strdup_printf("vhost-user/host-notifier@%p mmaps[%d]",
                            user, queue_idx);
-    memory_region_init_ram_device_ptr(&n->mr, OBJECT(vdev), name,
-                                      page_size, addr);
+    if (!n->mr.ram) /* Don't init again after suspend. */
+        memory_region_init_ram_device_ptr(&n->mr, OBJECT(vdev), name,
+                                          page_size, addr);
     g_free(name);
 
     if (virtio_queue_set_host_notifier_mr(vdev, queue_idx, &n->mr, true)) {
Signature · 1 line
2.25.1
#9 lore raw

PATCH 9/47 libvhost-user: fix VHOST_USER_REM_MEM_REG skipping mmap_addr

In reply to Michael Roth

From: David Hildenbrand <[email protected]>

We end up not copying the mmap_addr of all existing regions, resulting in a SEGFAULT once we actually try to map/access anything within our memory regions.

Fixes 875b9fd97b34 ("Support individual region unmap in libvhost-user")
Cc Michael S. Tsirkin <[email protected]>
Cc Raphael Norwitz <[email protected]>
Cc "Marc-André Lureau" <[email protected]>
Cc Stefan Hajnoczi <[email protected]>
Cc Paolo Bonzini <[email protected]>
Cc Coiby Xu <[email protected]>

Message-Id: <[email protected]>

(cherry picked from commit 6889eb2d431ae962e3e083b57bff47cd573cb1c4)
---
 subprojects/libvhost-user/libvhost-user.c | 1 +
 1 file changed, 1 insertion(+)
subprojects/libvhost-user/libvhost-user.c +1 -0
index bf09693255..787f4d2d4f 100644
@@ -816,6 +816,7 @@ vu_rem_mem_reg(VuDev *dev, VhostUserMsg *vmsg) {
             shadow_regions[j].gpa = dev->regions[i].gpa;
             shadow_regions[j].size = dev->regions[i].size;
             shadow_regions[j].qva = dev->regions[i].qva;
+            shadow_regions[j].mmap_addr = dev->regions[i].mmap_addr;
             shadow_regions[j].mmap_offset = dev->regions[i].mmap_offset;
             j++;
         } else {
Signature · 1 line
2.25.1
#10 lore raw

PATCH 10/47 hw/display/artist: Fix bug in coordinate extraction in artist_vram_read() and artist_vram_write()

In reply to Michael Roth

From: Helge Deller <[email protected]>

The CDE desktop on HP-UX 10 shows wrongly rendered pixels when the local screen menu is closed. This bug was introduced by commit c7050f3f167b ("hw/display/artist: Refactor x/y coordination extraction") which converted the coordinate extraction in artist_vram_read() and artist_vram_write() to use the ADDR_TO_X and ADDR_TO_Y macros, but forgot to right-shift the address by 2 as it was done before.

Fixes c7050f3f167b ("hw/display/artist: Refactor x/y coordination extraction")
Cc Philippe Mathieu-Daudé <[email protected]>
Cc Richard Henderson <[email protected]>
Cc Sven Schnelle <[email protected]>

Message-Id: <YK1aPb8keur9W7h2@ls3530>

(cherry picked from commit 01f750f5fef1afd8f6abc0548910f87d473e26d5)
---
 hw/display/artist.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
hw/display/artist.c +4 -4
index aa7bd594aa..21b7fd1b44 100644
@@ -1170,8 +1170,8 @@ static void artist_vram_write(void *opaque, hwaddr addr, uint64_t val,
     }
 
     buf = vram_write_buffer(s);
-    posy = ADDR_TO_Y(addr);
-    posx = ADDR_TO_X(addr);
+    posy = ADDR_TO_Y(addr >> 2);
+    posx = ADDR_TO_X(addr >> 2);
 
     if (!buf->size) {
         return;
@@ -1232,8 +1232,8 @@ static uint64_t artist_vram_read(void *opaque, hwaddr addr, unsigned size)
         return 0;
     }
 
-    posy = ADDR_TO_Y(addr);
-    posx = ADDR_TO_X(addr);
+    posy = ADDR_TO_Y(addr >> 2);
+    posx = ADDR_TO_X(addr >> 2);
 
     if (posy > buf->height || posx > buf->width) {
         return 0;
Signature · 1 line
2.25.1
#11 lore raw

PATCH 11/47 i386/cpu: Remove AVX_VNNI feature from Cooperlake cpu model

In reply to Michael Roth

From: Yang Zhong <[email protected]>

The AVX_VNNI feature is not in Cooperlake platform, remove it from cpu model.

Message-Id: <[email protected]>

Fixes c1826ea6a052 ("i386/cpu: Expose AVX_VNNI instruction to guest")
(cherry picked from commit f429dbf8fc526a9cacf531176b28d0c65701475a)
---
 target/i386/cpu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target/i386/cpu.c +1 -1
index 34a7ce865b..24ddc5b926 100644
@@ -3102,7 +3102,7 @@ static const X86CPUDefinition builtin_x86_defs[] = {
             MSR_ARCH_CAP_SKIP_L1DFL_VMENTRY | MSR_ARCH_CAP_MDS_NO |
             MSR_ARCH_CAP_PSCHANGE_MC_NO | MSR_ARCH_CAP_TAA_NO,
         .features[FEAT_7_1_EAX] =
-            CPUID_7_1_EAX_AVX_VNNI | CPUID_7_1_EAX_AVX512_BF16,
+            CPUID_7_1_EAX_AVX512_BF16,
         /* XSAVES is added in version 2 */
         .features[FEAT_XSAVE] =
             CPUID_XSAVE_XSAVEOPT | CPUID_XSAVE_XSAVEC |
Signature · 1 line
2.25.1
#12 lore raw

PATCH 12/47 9pfs: fix crash in v9fs_walk()

In reply to Michael Roth

From: Christian Schoenebeck <[email protected]>

v9fs_walk() utilizes the v9fs_co_run_in_worker({...}) macro to run the supplied fs driver code block on a background worker thread.

When either the 'Twalk' client request was interrupted or if the client requested fid for that 'Twalk' request caused a stat error then that fs driver code block was left by 'break' keyword, with the intention to return from worker thread back to main thread as well:

    v9fs_co_run_in_worker({
        if (v9fs_request_cancelled(pdu)) {
            err = -EINTR;
            break;
        }
        err = s->ops->lstat(&s->ctx, &dpath, &fidst);
        if (err < 0) {
            err = -errno;
            break;
        }
        ...
    });

However that 'break;' statement also skipped the v9fs_co_run_in_worker() macro's final and mandatory

    /* re-enter back to qemu thread */
    qemu_coroutine_yield();

call and thus caused the rest of v9fs_walk() to be continued being executed on the worker thread instead of main thread, eventually leading to a crash in the transport virtio transport driver.

To fix this issue and to prevent the same error from happening again by other users of v9fs_co_run_in_worker() in future, auto wrap the supplied code block into its own

    do { } while (0);

loop inside the 'v9fs_co_run_in_worker' macro definition.

Full discussion and backtrace:
https://lists.gnu.org/archive/html/qemu-devel/2021-08/msg05209.html
https://lists.gnu.org/archive/html/qemu-devel/2021-09/msg00174.html

Fixes 8d6cb100731c4d28535adbf2a3c2d1f29be3fef4

Message-Id: <[email protected]>

(cherry picked from commit f83df00900816476cca41bb536e4d532b297d76e)
---
 hw/9pfs/coth.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
hw/9pfs/coth.h +3 -1
index c51289903d..f83c7dda7b 100644
@@ -51,7 +51,9 @@
          */                                                             \
         qemu_coroutine_yield();                                         \
         qemu_bh_delete(co_bh);                                          \
-        code_block;                                                     \
+        do {                                                            \
+            code_block;                                                 \
+        } while (0);                                                    \
         /* re-enter back to qemu thread */                              \
         qemu_coroutine_yield();                                         \
     } while (0)
Signature · 1 line
2.25.1
#13 lore raw

PATCH 13/47 plugins/execlog: removed unintended "s" at the end of log lines.

In reply to Michael Roth

From: Mahmoud Mandour <[email protected]>

Message-Id: <[email protected]>
Message-Id: <[email protected]>

(cherry picked from commit b40310616d2bd550279dd22b05483c3c613a00ff)
---
 contrib/plugins/execlog.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
contrib/plugins/execlog.c +1 -1
index 2de9f0d7d4..a5275dcc15 100644
@@ -67,7 +67,7 @@ static void vcpu_insn_exec(unsigned int cpu_index, void *udata)
     /* Print previous instruction in cache */
     if (s->len) {
         qemu_plugin_outs(s->str);
-        qemu_plugin_outs("s\n");
+        qemu_plugin_outs("\n");
     }
 
     /* Store new instruction in cache */
Signature · 1 line
2.25.1
#14 lore raw

PATCH 14/47 plugins: do not limit exported symbols if modules are active

In reply to Michael Roth

From: Paolo Bonzini <[email protected]>

On Mac --enable-modules and --enable-plugins are currently incompatible, because the Apple -Wl,-exported_symbols_list command line options prevents the export of any symbols needed by the modules. On x86 -Wl,--dynamic-list does not have this effect, but only because the -Wl,--export-dynamic option provided by gmodule-2.0.pc overrides it. On Apple there is no -Wl,--export-dynamic, because it is the default, and thus no override.

Either way, when modules are active there is no reason to include the plugin_ldflags. While at it, avoid the useless -Wl,--export-dynamic when --enable-plugins is specified but --enable-modules is not; this way, the GNU and Apple configurations are more similar.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/516

[AJB: fix noexport to no-export]

Message-Id: <[email protected]>

(cherry picked from commit b906acace2d4f68b6ff8de73739a773cc4851436)
---
 configure           |  5 ++---
 plugins/meson.build | 14 ++++++++------
 2 files changed, 10 insertions(+), 9 deletions(-)
configure +2 -3
index 9a79a004d7..7659870810 100755
@@ -3187,9 +3187,8 @@ glib_req_ver=2.56
 glib_modules=gthread-2.0
 if test "$modules" = yes; then
     glib_modules="$glib_modules gmodule-export-2.0"
-fi
-if test "$plugins" = "yes"; then
-    glib_modules="$glib_modules gmodule-2.0"
+elif test "$plugins" = "yes"; then
+    glib_modules="$glib_modules gmodule-no-export-2.0"
 fi
 
 for i in $glib_modules; do
plugins/meson.build +8 -6
index e77723010e..bfd5c9822a 100644
@@ -1,9 +1,11 @@
-if 'CONFIG_HAS_LD_DYNAMIC_LIST' in config_host
-  plugin_ldflags = ['-Wl,--dynamic-list=' + (meson.build_root() / 'qemu-plugins-ld.symbols')]
-elif 'CONFIG_HAS_LD_EXPORTED_SYMBOLS_LIST' in config_host
-  plugin_ldflags = ['-Wl,-exported_symbols_list,' + (meson.build_root() / 'qemu-plugins-ld64.symbols')]
-else
-  plugin_ldflags = []
+plugin_ldflags = []
+# Modules need more symbols than just those in plugins/qemu-plugins.symbols
+if not enable_modules
+  if 'CONFIG_HAS_LD_DYNAMIC_LIST' in config_host
+    plugin_ldflags = ['-Wl,--dynamic-list=' + (meson.build_root() / 'qemu-plugins-ld.symbols')]
+  elif 'CONFIG_HAS_LD_EXPORTED_SYMBOLS_LIST' in config_host
+    plugin_ldflags = ['-Wl,-exported_symbols_list,' + (meson.build_root() / 'qemu-plugins-ld64.symbols')]
+  endif
 endif
 
 specific_ss.add(when: 'CONFIG_PLUGIN', if_true: [files(
Signature · 1 line
2.25.1
#15 lore raw

PATCH 15/47 qemu-sockets: fix unix socket path copy (again)

In reply to Michael Roth

From: Michael Tokarev <[email protected]>

Commit 4cfd970ec188558daa6214f26203fe553fb1e01f added an assert which ensures the path within an address of a unix socket returned from the kernel is at least one byte and does not exceed sun_path buffer. Both of this constraints are wrong:

A unix socket can be unnamed, in this case the path is completely empty (not even \0)

And some implementations (notable linux) can add extra trailing byte (\0) _after_ the sun_path buffer if we passed buffer larger than it (and we do).

So remove the assertion (since it causes real-life breakage) but at the same time fix the usage of sun_path. Namely, we should not access sun_path[0] if kernel did not return it at all (this is the case for unnamed sockets), and use the returned salen when copyig actual path as an upper constraint for the amount of bytes to copy - this will ensure we wont exceed the information provided by the kernel, regardless whenever there is a trailing \0 or not. This also helps with unnamed sockets.

Note the case of abstract socket, the sun_path is actually a blob and can contain \0 characters, - it should not be passed to g_strndup and the like, it should be accessed by memcpy-like functions.

Fixes 4cfd970ec188558daa6214f26203fe553fb1e01f
(cherry picked from commit 118d527f2e4baec5fe8060b22a6212468b8e4d3f)
---
 util/qemu-sockets.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)
util/qemu-sockets.c +5 -8
index f2f3676d1f..c5043999e9 100644
@@ -1345,25 +1345,22 @@ socket_sockaddr_to_address_unix(struct sockaddr_storage *sa,
     SocketAddress *addr;
     struct sockaddr_un *su = (struct sockaddr_un *)sa;
 
-    assert(salen >= sizeof(su->sun_family) + 1 &&
-           salen <= sizeof(struct sockaddr_un));
-
     addr = g_new0(SocketAddress, 1);
     addr->type = SOCKET_ADDRESS_TYPE_UNIX;
+    salen -= offsetof(struct sockaddr_un, sun_path);
 #ifdef CONFIG_LINUX
-    if (!su->sun_path[0]) {
+    if (salen > 0 && !su->sun_path[0]) {
         /* Linux abstract socket */
-        addr->u.q_unix.path = g_strndup(su->sun_path + 1,
-                                        salen - sizeof(su->sun_family) - 1);
+        addr->u.q_unix.path = g_strndup(su->sun_path + 1, salen - 1);
         addr->u.q_unix.has_abstract = true;
         addr->u.q_unix.abstract = true;
         addr->u.q_unix.has_tight = true;
-        addr->u.q_unix.tight = salen < sizeof(*su);
+        addr->u.q_unix.tight = salen < sizeof(su->sun_path);
         return addr;
     }
 #endif
 
-    addr->u.q_unix.path = g_strndup(su->sun_path, sizeof(su->sun_path));
+    addr->u.q_unix.path = g_strndup(su->sun_path, salen);
     return addr;
 }
 #endif /* WIN32 */
Signature · 1 line
2.25.1
#16 lore raw

PATCH 16/47 vhost-vsock: fix migration issue when seqpacket is supported

In reply to Michael Roth

From: Stefano Garzarella <[email protected]>

Commit 1e08fd0a46 ("vhost-vsock: SOCK_SEQPACKET feature bit support") enabled the SEQPACKET feature bit.
This commit is released with QEMU 6.1, so if we try to migrate a VM where the host kernel supports SEQPACKET but machine type version is less than 6.1, we get the following errors:

Features 0x130000002 unsupported. Allowed features: 0x179000000
Failed to load virtio-vhost_vsock:virtio
error while loading state for instance 0x0 of device '0000:00:05.0/virtio-vhost_vsock' load of migration failed: Operation not permitted

Let's disable the feature bit for machine types < 6.1.
We add a new OnOffAuto property for this, called seqpacket. When it is auto (default), QEMU behaves as before, trying to enable the feature, when it is on QEMU will fail if the backend (vhost-vsock kernel module) doesn't support it.

Fixes 1e08fd0a46 ("vhost-vsock: SOCK_SEQPACKET feature bit support")

Message-Id: <[email protected]>

(cherry picked from commit d6a9378f47515c6d70dbff4912c5740c98709880)
---
 hw/core/machine.c               |  1 +
 hw/virtio/vhost-vsock.c         | 19 ++++++++++++++++---
 include/hw/virtio/vhost-vsock.h |  3 +++
 3 files changed, 20 insertions(+), 3 deletions(-)
hw/core/machine.c +1 -0
index 54e040587d..2cf2f321f9 100644
@@ -43,6 +43,7 @@ GlobalProperty hw_compat_6_0[] = {
     { "nvme-ns", "eui64-default", "off"},
     { "e1000", "init-vet", "off" },
     { "e1000e", "init-vet", "off" },
+    { "vhost-vsock-device", "seqpacket", "off" },
 };
 const size_t hw_compat_6_0_len = G_N_ELEMENTS(hw_compat_6_0);
 
hw/virtio/vhost-vsock.c +16 -3
index 1b1a5c70ed..dade0da031 100644
@@ -114,10 +114,21 @@ static uint64_t vhost_vsock_get_features(VirtIODevice *vdev,
                                          Error **errp)
 {
     VHostVSockCommon *vvc = VHOST_VSOCK_COMMON(vdev);
+    VHostVSock *vsock = VHOST_VSOCK(vdev);
+
+    if (vsock->seqpacket != ON_OFF_AUTO_OFF) {
+        virtio_add_feature(&requested_features, VIRTIO_VSOCK_F_SEQPACKET);
+    }
+
+    requested_features = vhost_get_features(&vvc->vhost_dev, feature_bits,
+                                            requested_features);
+
+    if (vsock->seqpacket == ON_OFF_AUTO_ON &&
+        !virtio_has_feature(requested_features, VIRTIO_VSOCK_F_SEQPACKET)) {
+        error_setg(errp, "vhost-vsock backend doesn't support seqpacket");
+    }
 
-    virtio_add_feature(&requested_features, VIRTIO_VSOCK_F_SEQPACKET);
-    return vhost_get_features(&vvc->vhost_dev, feature_bits,
-                                requested_features);
+    return requested_features;
 }
 
 static const VMStateDescription vmstate_virtio_vhost_vsock = {
@@ -218,6 +229,8 @@ static void vhost_vsock_device_unrealize(DeviceState *dev)
 static Property vhost_vsock_properties[] = {
     DEFINE_PROP_UINT64("guest-cid", VHostVSock, conf.guest_cid, 0),
     DEFINE_PROP_STRING("vhostfd", VHostVSock, conf.vhostfd),
+    DEFINE_PROP_ON_OFF_AUTO("seqpacket", VHostVSock, seqpacket,
+                            ON_OFF_AUTO_AUTO),
     DEFINE_PROP_END_OF_LIST(),
 };
 
include/hw/virtio/vhost-vsock.h +3 -0
index 84f4e727c7..3f121a624f 100644
@@ -30,6 +30,9 @@ struct VHostVSock {
     VHostVSockCommon parent;
     VHostVSockConf conf;
 
+    /* features */
+    OnOffAuto seqpacket;
+
     /*< public >*/
 };
 
Signature · 1 line
2.25.1
#17 lore raw

PATCH 17/47 hw/arm/virt: Rename default_bus_bypass_iommu

In reply to Michael Roth

From: Jean-Philippe Brucker <[email protected]>

Since commit d8fb7d0969d5 ("vl: switch -M parsing to keyval"), machine parameter definitions cannot use underscores, because keyval_dashify() transforms them to dashes and the parser doesn't find the parameter.

This affects option default_bus_bypass_iommu which was introduced in the same release:

$ qemu-system-aarch64 -M virt,default_bus_bypass_iommu=on
qemu-system-aarch64: Property 'virt-6.1-machine.default-bus-bypass-iommu' not found

Rename the parameter to "default-bus-bypass-iommu". Passing "default_bus_bypass_iommu" is still valid since the underscore are transformed automatically.

Fixes 6d7a85483a06 ("hw/arm/virt: Add default_bus_bypass_iommu machine option")

Message-Id: <[email protected]>

(cherry picked from commit 9dad363a223df8269175d218413aa8cd265e078e)
---
 hw/arm/virt.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/arm/virt.c +2 -2
index 81eda46b0b..106be60fd4 100644
@@ -2677,10 +2677,10 @@ static void virt_machine_class_init(ObjectClass *oc, void *data)
                                           "Set the IOMMU type. "
                                           "Valid values are none and smmuv3");
 
-    object_class_property_add_bool(oc, "default_bus_bypass_iommu",
+    object_class_property_add_bool(oc, "default-bus-bypass-iommu",
                                    virt_get_default_bus_bypass_iommu,
                                    virt_set_default_bus_bypass_iommu);
-    object_class_property_set_description(oc, "default_bus_bypass_iommu",
+    object_class_property_set_description(oc, "default-bus-bypass-iommu",
                                           "Set on/off to enable/disable "
                                           "bypass_iommu for default root bus");
 
Signature · 1 line
2.25.1
#18 lore raw

PATCH 18/47 hw/i386: Rename default_bus_bypass_iommu

In reply to Michael Roth

From: Jean-Philippe Brucker <[email protected]>

Since commit d8fb7d0969d5 ("vl: switch -M parsing to keyval"), machine parameter definitions cannot use underscores, because keyval_dashify() transforms them to dashes and the parser doesn't find the parameter.

This affects option default_bus_bypass_iommu which was introduced in the same release:

$ qemu-system-x86_64 -M q35,default_bus_bypass_iommu=on
qemu-system-x86_64: Property 'pc-q35-6.1-machine.default-bus-bypass-iommu' not found

Rename the parameter to "default-bus-bypass-iommu". Passing "default_bus_bypass_iommu" is still valid since the underscore are transformed automatically.

Fixes c9e96b04fc19 ("hw/i386: Add a default_bus_bypass_iommu pc machine option")

Message-Id: <[email protected]>

(cherry picked from commit 739b38630c45585cd9d372d44537f69c0b2b4346)
---
 hw/i386/pc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/i386/pc.c +1 -1
index c2b9d62a35..1d421ae2f8 100644
@@ -1763,7 +1763,7 @@ static void pc_machine_class_init(ObjectClass *oc, void *data)
     object_class_property_add_bool(oc, "hpet",
         pc_machine_get_hpet, pc_machine_set_hpet);
 
-    object_class_property_add_bool(oc, "default_bus_bypass_iommu",
+    object_class_property_add_bool(oc, "default-bus-bypass-iommu",
         pc_machine_get_default_bus_bypass_iommu,
         pc_machine_set_default_bus_bypass_iommu);
 
Signature · 1 line
2.25.1
#19 lore raw

PATCH 19/47 bios-tables-test: allow changes in DSDT ACPI tables for q35

In reply to Michael Roth

From: Ani Sinha <[email protected]>

We are going to commit a change to fix IO address range allocated for acpi pci hotplug in q35. This affects DSDT tables. This change allows DSDT table modification so that unit tests are not broken.

Message-Id: <[email protected]>

(cherry picked from commit 9f29e872d5b3973003701401cf659cfb71c95013)
---
 tests/qtest/bios-tables-test-allowed-diff.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)
tests/qtest/bios-tables-test-allowed-diff.h +12 -0
index dfb8523c8b..c06da38af3 100644
@@ -1 +1,13 @@
 /* List of comma-separated changed AML files to ignore */
+"tests/data/acpi/q35/DSDT",
+"tests/data/acpi/q35/DSDT.tis.tpm12",
+"tests/data/acpi/q35/DSDT.tis.tpm2",
+"tests/data/acpi/q35/DSDT.bridge",
+"tests/data/acpi/q35/DSDT.mmio64",
+"tests/data/acpi/q35/DSDT.ipmibt",
+"tests/data/acpi/q35/DSDT.cphp",
+"tests/data/acpi/q35/DSDT.memhp",
+"tests/data/acpi/q35/DSDT.numamem",
+"tests/data/acpi/q35/DSDT.nohpet",
+"tests/data/acpi/q35/DSDT.dimmpxm",
+"tests/data/acpi/q35/DSDT.acpihmat",
Signature · 1 line
2.25.1
#20 lore raw

PATCH 20/47 hw/i386/acpi: fix conflicting IO address range for acpi pci hotplug in q35

In reply to Michael Roth

From: Ani Sinha <[email protected]>

Change caf108bc58790 ("hw/i386/acpi-build: Add ACPI PCI hot-plug methods to Q35") selects an IO address range for acpi based PCI hotplug for q35 arbitrarily. It starts at address 0x0cc4 and ends at 0x0cdb. At the time when the patch was written but the final version of the patch was not yet pushed upstream, this address range was free and did not conflict with any other IO address ranges. However, with the following change, this address range was no
longer conflict free as in this change, the IO address range
(value of ACPI_PCIHP_SIZE) was incremented by four bytes:

b32bd763a1ca92 ("pci: introduce acpi-index property for PCI device")

This can be seen from the output of QMP command 'info mtree' :

0000000000000600-0000000000000603 (prio 0, i/o): acpi-evt 0000000000000604-0000000000000605 (prio 0, i/o): acpi-cnt 0000000000000608-000000000000060b (prio 0, i/o): acpi-tmr 0000000000000620-000000000000062f (prio 0, i/o): acpi-gpe0 0000000000000630-0000000000000637 (prio 0, i/o): acpi-smi 0000000000000cc4-0000000000000cdb (prio 0, i/o): acpi-pci-hotplug 0000000000000cd8-0000000000000ce3 (prio 0, i/o): acpi-cpu-hotplug

It shows that there is a region of conflict between IO regions of acpi pci hotplug and acpi cpu hotplug.

Unfortunately, the change caf108bc58790 did not update the IO address range appropriately before it was pushed upstream to accommodate the increased length of the IO address space introduced in change b32bd763a1ca92.

Due to this bug, windows guests complain 'This device cannot find enough free resources it can use' in the device manager panel for extended IO buses. This issue also breaks the correct functioning of pci hotplug as the following shows that the IO space for pci hotplug has been truncated:

(qemu) info mtree -f
FlatView #0
AS "I/O", root: io
Root memory region: io
0000000000000cc4-0000000000000cd7 (prio 0, i/o): acpi-pci-hotplug 0000000000000cd8-0000000000000cf7 (prio 0, i/o): acpi-cpu-hotplug

Therefore, in this fix, we adjust the IO address range for the acpi pci hotplug so that it does not conflict with cpu hotplug and there is no truncation of IO spaces. The starting IO address of PCI hotplug region has been decremented by four bytes in order to accommodate four byte increment in the IO address space introduced by change b32bd763a1ca92 ("pci: introduce acpi-index property for PCI device")

After fixing, the following are the corrected IO ranges:

0000000000000600-0000000000000603 (prio 0, i/o): acpi-evt 0000000000000604-0000000000000605 (prio 0, i/o): acpi-cnt 0000000000000608-000000000000060b (prio 0, i/o): acpi-tmr 0000000000000620-000000000000062f (prio 0, i/o): acpi-gpe0 0000000000000630-0000000000000637 (prio 0, i/o): acpi-smi 0000000000000cc0-0000000000000cd7 (prio 0, i/o): acpi-pci-hotplug 0000000000000cd8-0000000000000ce3 (prio 0, i/o): acpi-cpu-hotplug

This change has been tested using a Windows Server 2019 guest VM. Windows no longer complains after this change.

Fixes caf108bc58790 ("hw/i386/acpi-build: Add ACPI PCI hot-plug methods to Q35")

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/561

Message-Id: <[email protected]>

(cherry picked from commit 0e780da76a6fe283a20283856718bca3986c104f)
---
 include/hw/acpi/ich9.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/hw/acpi/ich9.h +1 -1
index a329ce43ab..f04f1791bd 100644
@@ -29,7 +29,7 @@
 #include "hw/acpi/acpi_dev_interface.h"
 #include "hw/acpi/tco.h"
 
-#define ACPI_PCIHP_ADDR_ICH9 0x0cc4
+#define ACPI_PCIHP_ADDR_ICH9 0x0cc0
 
 typedef struct ICH9LPCPMRegs {
     /*
Signature · 1 line
2.25.1
#21 lore raw

PATCH 21/47 bios-tables-test: Update ACPI DSDT table golden blobs for q35

In reply to Michael Roth

From: Ani Sinha <[email protected]>

We have modified the IO address range for ACPI pci hotplug in q35. See change:

5adcc9e39e6a5 ("hw/i386/acpi: fix conflicting IO address range for acpi pci hotplug in q35")

The ACPI DSDT table golden blobs must be regenrated in order to make the unit tests pass. This change updates the golden ACPI DSDT table blobs.

Following is the ASL diff between the blobs:

@@ -1,30 +1,30 @@
/*
* Intel ACPI Component Architecture
* AML/ASL+ Disassembler version 20190509 (64-bit version)
* Copyright (c) 2000 - 2019 Intel Corporation
*
* Disassembling to symbolic ASL+ operators
*
- * Disassembly of tests/data/acpi/q35/DSDT, Tue Sep 14 09:04:06 2021
+ * Disassembly of /tmp/aml-52DP90, Tue Sep 14 09:04:06 2021 *
* Original Table Header:

  *     Signature        "DSDT"
  *     Length           0x00002061 (8289)
  *     Revision         0x01 **** 32-bit table (V1), no 64-bit math support
- *     Checksum         0xE5
+ *     Checksum         0xF9
  *     OEM ID           "BOCHS "
  *     OEM Table ID     "BXPC    "
  *     OEM Revision     0x00000001 (1)
  *     Compiler ID      "BXPC"
  *     Compiler Version 0x00000001 (1)
  */
 DefinitionBlock ("", "DSDT", 1, "BOCHS ", "BXPC    ", 0x00000001)
 {
     Scope (\)
     {
         OperationRegion (DBG, SystemIO, 0x0402, One)
         Field (DBG, ByteAcc, NoLock, Preserve)
         {
             DBGB,   8
         }

@@ -226,46 +226,46 @@

             Name (_CRS, ResourceTemplate ()  // _CRS: Current Resource Settings
             {
                 IO (Decode16,
                     0x0070,             // Range Minimum
                     0x0070,             // Range Maximum
                     0x01,               // Alignment
                     0x08,               // Length
                     )
                 IRQNoFlags ()
                     {8}
             })
         }
     }

     Scope (_SB.PCI0)
     {
-        OperationRegion (PCST, SystemIO, 0x0CC4, 0x08)
+        OperationRegion (PCST, SystemIO, 0x0CC0, 0x08)
         Field (PCST, DWordAcc, NoLock, WriteAsZeros)
         {
             PCIU,   32,
             PCID,   32
         }

- OperationRegion (SEJ, SystemIO, 0x0CCC, 0x04)
+ OperationRegion (SEJ, SystemIO, 0x0CC8, 0x04)

         Field (SEJ, DWordAcc, NoLock, WriteAsZeros)
         {
             B0EJ,   32
         }

- OperationRegion (BNMR, SystemIO, 0x0CD4, 0x08)
+ OperationRegion (BNMR, SystemIO, 0x0CD0, 0x08)

         Field (BNMR, DWordAcc, NoLock, WriteAsZeros)
         {
             BNUM,   32,
             PIDX,   32
         }

         Mutex (BLCK, 0x00)
         Method (PCEJ, 2, NotSerialized)
         {
             Acquire (BLCK, 0xFFFF)
             BNUM = Arg0
             B0EJ = (One << Arg1)
             Release (BLCK)
             Return (Zero)
         }

@@ -3185,34 +3185,34 @@

                     0x0620,             // Range Minimum
                     0x0620,             // Range Maximum
                     0x01,               // Alignment
                     0x10,               // Length
                     )
             })
         }

         Device (PHPR)
         {
             Name (_HID, "PNP0A06" /* Generic Container Device */)  // _HID: Hardware ID
             Name (_UID, "PCI Hotplug resources")  // _UID: Unique ID
             Name (_STA, 0x0B)  // _STA: Status
             Name (_CRS, ResourceTemplate ()  // _CRS: Current Resource Settings
             {
                 IO (Decode16,
-                    0x0CC4,             // Range Minimum
-                    0x0CC4,             // Range Maximum
+                    0x0CC0,             // Range Minimum
+                    0x0CC0,             // Range Maximum
                     0x01,               // Alignment
                     0x18,               // Length
                     )
             })
         }
     }

     Scope (\)
     {
         Name (_S3, Package (0x04)  // _S3_: S3 System State
         {
             One,
             One,
             Zero,
             Zero
         })

Message-Id: <[email protected]>

(cherry picked from commit 500eb21cff08dfb0478db9b34f2fdba69eb31496)

*drop dependency on 75539b886a ("tests: acpi: tpm1.2: Add expected TPM 1.2 ACPI blobs")

---
 tests/data/acpi/q35/DSDT                    | Bin 8289 -> 8289 bytes
 tests/data/acpi/q35/DSDT.acpihmat           | Bin 9614 -> 9614 bytes
 tests/data/acpi/q35/DSDT.bridge             | Bin 11003 -> 11003 bytes
 tests/data/acpi/q35/DSDT.cphp               | Bin 8753 -> 8753 bytes
 tests/data/acpi/q35/DSDT.dimmpxm            | Bin 9943 -> 9943 bytes
 tests/data/acpi/q35/DSDT.ipmibt             | Bin 8364 -> 8364 bytes
 tests/data/acpi/q35/DSDT.memhp              | Bin 9648 -> 9648 bytes
 tests/data/acpi/q35/DSDT.mmio64             | Bin 9419 -> 9419 bytes
 tests/data/acpi/q35/DSDT.nohpet             | Bin 8147 -> 8147 bytes
 tests/data/acpi/q35/DSDT.numamem            | Bin 8295 -> 8295 bytes
 tests/data/acpi/q35/DSDT.tis                | Bin 8894 -> 8894 bytes
 tests/qtest/bios-tables-test-allowed-diff.h |  12 ------------
 12 files changed, 12 deletions(-)
tests/data/acpi/q35/DSDT binary +0 -0
index 842533f53e6db40935c3cdecd1d182edba6c17d4..281fc82c03b2562d2e6b7caec0d817b034a47138 100644
GIT binary patch
tests/data/acpi/q35/DSDT.acpihmat binary +0 -0
index 8d00f2ea0dd78f962e136273d68cb0c568e43c27..8c1e05a11a328ec1cc6f86e36e52c28f41f9744e 100644
GIT binary patch
tests/data/acpi/q35/DSDT.bridge binary +0 -0
index 55ad4bd7ab4759d68031b2f1d0307355a7332fe7..6f1464b6c712d7f33cb4b891b7ce76fe228f44c9 100644
GIT binary patch
tests/data/acpi/q35/DSDT.cphp binary +0 -0
index ccde2add9f87db0c0eaf0cc155717d5744e4ef40..f8337ff5191a37a47dcf7c09a6c39c4e704a15bf 100644
GIT binary patch
tests/data/acpi/q35/DSDT.dimmpxm binary +0 -0
index b062e30117f955c7a2ac9629a0512324bbd28bf2..fe5820d93d057ef09a001662369b15afbc5b87e2 100644
GIT binary patch
tests/data/acpi/q35/DSDT.ipmibt binary +0 -0
index 1c5737692f56fc678e685a4ad0bb1df38d487a14..631741065860fd5036aa303904dabd1d2839f9c6 100644
GIT binary patch
tests/data/acpi/q35/DSDT.memhp binary +0 -0
index 7b6f6487b229cac3424a5215c8f1755c0c85310c..9bc11518fc57687ca789dc70793b48b29a0d74ed 100644
GIT binary patch
tests/data/acpi/q35/DSDT.mmio64 binary +0 -0
index 2e0a772a85275c9c3b4c9317d98cc7c3d27417f3..713288a12ef2b70a20b4e8836c036ba4db3a57a8 100644
GIT binary patch
tests/data/acpi/q35/DSDT.nohpet binary +0 -0
index ceb61f4115c2ccf4bcbb0d529551236933ecee15..e8202e6ddfbe96071f32f1ec05758f650569943e 100644
GIT binary patch
tests/data/acpi/q35/DSDT.numamem binary +0 -0
index a3f846df541a70ce0730d0351954b78818bbcdd0..151e7cf42953f3f5fe61ff0140ab7b976fe9e5b8 100644
GIT binary patch
tests/data/acpi/q35/DSDT.tis binary +0 -0
index d1433e3c14570bbd17b029a9aec6bc53134c3b7d..c92d4d29c79352a60974ea9f665d0b9a410a4bac 100644
GIT binary patch
tests/qtest/bios-tables-test-allowed-diff.h +0 -12
index c06da38af3..dfb8523c8b 100644
@@ -1,13 +1 @@
 /* List of comma-separated changed AML files to ignore */
-"tests/data/acpi/q35/DSDT",
-"tests/data/acpi/q35/DSDT.tis.tpm12",
-"tests/data/acpi/q35/DSDT.tis.tpm2",
-"tests/data/acpi/q35/DSDT.bridge",
-"tests/data/acpi/q35/DSDT.mmio64",
-"tests/data/acpi/q35/DSDT.ipmibt",
-"tests/data/acpi/q35/DSDT.cphp",
-"tests/data/acpi/q35/DSDT.memhp",
-"tests/data/acpi/q35/DSDT.numamem",
-"tests/data/acpi/q35/DSDT.nohpet",
-"tests/data/acpi/q35/DSDT.dimmpxm",
-"tests/data/acpi/q35/DSDT.acpihmat",
Signature · 1 line
2.25.1
#22 lore raw

PATCH 22/47 block: introduce max_hw_iov for use in scsi-generic

In reply to Michael Roth

From: Paolo Bonzini <[email protected]>

Linux limits the size of iovecs to 1024 (UIO_MAXIOV in the kernel sources, IOV_MAX in POSIX). Because of this, on some host adapters requests with many iovecs are rejected with -EINVAL by the io_submit() or readv()/writev() system calls.

In fact, the same limit applies to SG_IO as well. To fix both the EINVAL and the possible performance issues from using fewer iovecs than allowed by Linux (some HBAs have max_segments as low as 128), introduce a separate entry in BlockLimits to hold the max_segments value from sysfs. This new limit is used only for SG_IO and clamped to bs->bl.max_iov anyway, just like max_hw_transfer is clamped to bs->bl.max_transfer.

Cc Hanna Reitz <[email protected]>
Cc Kevin Wolf <[email protected]>
Fixes 18473467d5 ("file-posix: try BLKSECTGET on block devices too, do not round to power of 2", 2021-06-25)

Message-Id: <[email protected]>

(cherry picked from commit cc071629539dc1f303175a7e2d4ab854c0a8b20f)
---
 block/block-backend.c          | 6 ++++++
 block/file-posix.c             | 2 +-
 block/io.c                     | 1 +
 hw/scsi/scsi-generic.c         | 2 +-
 include/block/block_int.h      | 7 +++++++
 include/sysemu/block-backend.h | 1 +
 6 files changed, 17 insertions(+), 2 deletions(-)
block/block-backend.c +6 -0
index deb55c272e..6320752aa2 100644
@@ -1978,6 +1978,12 @@ uint32_t blk_get_max_transfer(BlockBackend *blk)
     return ROUND_DOWN(max, blk_get_request_alignment(blk));
 }
 
+int blk_get_max_hw_iov(BlockBackend *blk)
+{
+    return MIN_NON_ZERO(blk->root->bs->bl.max_hw_iov,
+                        blk->root->bs->bl.max_iov);
+}
+
 int blk_get_max_iov(BlockBackend *blk)
 {
     return blk->root->bs->bl.max_iov;
block/file-posix.c +1 -1
index cb9bffe047..1567edb3d5 100644
@@ -1273,7 +1273,7 @@ static void raw_refresh_limits(BlockDriverState *bs, Error **errp)
 
         ret = hdev_get_max_segments(s->fd, &st);
         if (ret > 0) {
-            bs->bl.max_iov = ret;
+            bs->bl.max_hw_iov = ret;
         }
     }
 }
block/io.c +1 -0
index a19942718b..f38e7f81d8 100644
@@ -136,6 +136,7 @@ static void bdrv_merge_limits(BlockLimits *dst, const BlockLimits *src)
     dst->min_mem_alignment = MAX(dst->min_mem_alignment,
                                  src->min_mem_alignment);
     dst->max_iov = MIN_NON_ZERO(dst->max_iov, src->max_iov);
+    dst->max_hw_iov = MIN_NON_ZERO(dst->max_hw_iov, src->max_hw_iov);
 }
 
 typedef struct BdrvRefreshLimitsState {
hw/scsi/scsi-generic.c +1 -1
index 665baf900e..0306ccc7b1 100644
@@ -180,7 +180,7 @@ static int scsi_handle_inquiry_reply(SCSIGenericReq *r, SCSIDevice *s, int len)
         page = r->req.cmd.buf[2];
         if (page == 0xb0) {
             uint64_t max_transfer = blk_get_max_hw_transfer(s->conf.blk);
-            uint32_t max_iov = blk_get_max_iov(s->conf.blk);
+            uint32_t max_iov = blk_get_max_hw_iov(s->conf.blk);
 
             assert(max_transfer);
             max_transfer = MIN_NON_ZERO(max_transfer, max_iov * qemu_real_host_page_size)
include/block/block_int.h +7 -0
index f1a54db0f8..c31cbd034a 100644
@@ -702,6 +702,13 @@ typedef struct BlockLimits {
      */
     uint64_t max_hw_transfer;
 
+    /* Maximal number of scatter/gather elements allowed by the hardware.
+     * Applies whenever transfers to the device bypass the kernel I/O
+     * scheduler, for example with SG_IO.  If larger than max_iov
+     * or if zero, blk_get_max_hw_iov will fall back to max_iov.
+     */
+    int max_hw_iov;
+
     /* memory alignment, in bytes so that no bounce buffer is needed */
     size_t min_mem_alignment;
 
include/sysemu/block-backend.h +1 -0
index 9ac5f7bbd3..5daec61f6e 100644
@@ -210,6 +210,7 @@ uint32_t blk_get_request_alignment(BlockBackend *blk);
 uint32_t blk_get_max_transfer(BlockBackend *blk);
 uint64_t blk_get_max_hw_transfer(BlockBackend *blk);
 int blk_get_max_iov(BlockBackend *blk);
+int blk_get_max_hw_iov(BlockBackend *blk);
 void blk_set_guest_block_size(BlockBackend *blk, int align);
 void *blk_try_blockalign(BlockBackend *blk, size_t size);
 void *blk_blockalign(BlockBackend *blk, size_t size);
Signature · 1 line
2.25.1
#23 lore raw

PATCH 23/47 pci: fix PCI resource reserve capability on BE

In reply to Michael Roth

From: "Michael S. Tsirkin" <[email protected]>

PCI resource reserve capability should use LE format as all other PCI things. If we don't then seabios won't boot:

=== PCI new allocation pass #1 ===
PCI: check devices
PCI: QEMU resource reserve cap: size 10000000000000 type io
PCI: secondary bus 1 size 10000000000000 type io
PCI: secondary bus 1 size 00200000 type mem
PCI: secondary bus 1 size 00200000 type prefmem === PCI new allocation pass #2 ===
PCI: out of I/O address space

This became more important since we started reserving IO by default, previously no one noticed.

Fixes e2a6290aab ("hw/pcie-root-port: Fix hotplug for PCI devices requiring IO")
Fixes 226263fb5c ("hw/pci: add QEMU-specific PCI capability to the Generic PCI Express Root Port")
Fixes 6755e618d0 ("hw/pci: add PCI resource reserve capability to legacy PCI bridge")
(cherry picked from commit 0e464f7d993113119f0fd17b890831440734ce15)
---
 hw/pci/pci_bridge.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
hw/pci/pci_bridge.c +5 -5
index 3789c17edc..6a1e8e433c 100644
@@ -448,11 +448,11 @@ int pci_bridge_qemu_reserve_cap_init(PCIDevice *dev, int cap_offset,
     PCIBridgeQemuCap cap = {
             .len = cap_len,
             .type = REDHAT_PCI_CAP_RESOURCE_RESERVE,
-            .bus_res = res_reserve.bus,
-            .io = res_reserve.io,
-            .mem = res_reserve.mem_non_pref,
-            .mem_pref_32 = res_reserve.mem_pref_32,
-            .mem_pref_64 = res_reserve.mem_pref_64
+            .bus_res = cpu_to_le32(res_reserve.bus),
+            .io = cpu_to_le64(res_reserve.io),
+            .mem = cpu_to_le32(res_reserve.mem_non_pref),
+            .mem_pref_32 = cpu_to_le32(res_reserve.mem_pref_32),
+            .mem_pref_64 = cpu_to_le64(res_reserve.mem_pref_64)
     };
 
     int offset = pci_add_capability(dev, PCI_CAP_ID_VNDR,
Signature · 1 line
2.25.1
#24 lore raw

PATCH 24/47 tests/acpi/bios-tables-test: add and allow changes to a new q35 DSDT table blob

In reply to Michael Roth

From: Ani Sinha <[email protected]>

We are adding a new unit test to cover the acpi hotplug support in q35 for multi-function bridges. This test uses a new table DSDT.multi-bridge. We need to allow changes in DSDT acpi table for addition of this new unit test.

Message-Id: <[email protected]>

(cherry picked from commit 6dcb1cc9512c6b4cd8f85abc537abaf6f6c0738b)
---
 tests/data/acpi/q35/DSDT.multi-bridge       | 0
 tests/qtest/bios-tables-test-allowed-diff.h | 1 +
 2 files changed, 1 insertion(+)
 create mode 100644 tests/data/acpi/q35/DSDT.multi-bridge
tests/data/acpi/q35/DSDT.multi-bridge new file +0 -0
new file mode 100644
index 0000000000..e69de29bb2
tests/qtest/bios-tables-test-allowed-diff.h +1 -0
index dfb8523c8b..dabc024f53 100644
@@ -1 +1,2 @@
 /* List of comma-separated changed AML files to ignore */
+"tests/data/acpi/q35/DSDT.multi-bridge",
Signature · 1 line
2.25.1
#25 lore raw

PATCH 25/47 tests/acpi/pcihp: add unit tests for hotplug on multifunction bridges for q35

In reply to Michael Roth

From: Ani Sinha <[email protected]>

commit d7346e614f4ec ("acpi: x86: pcihp: add support hotplug on multifunction bridges") added ACPI hotplug descriptions for cold plugged bridges for functions other than 0. For all other devices, the ACPI hotplug descriptions are limited to function 0 only. This change adds unit tests for this feature.

This test adds the following devices to qemu and then checks the changes introduced in the DSDT table due to the addition of the following devices:

(a) a multifunction bridge device
(b) a bridge device with function 1
(c) a non-bridge device with function 2

In the DSDT table, we should see AML hotplug descriptions for (a) and (b). For (a) we should find a hotplug AML description for function 0.

The following diff compares the DSDT table AML with the new unit test before and after the change d7346e614f4ec is introduced. In other words, this diff reflects the changes that occurs in the DSDT table due to the change d7346e614f4ec .

@@ -1,60 +1,38 @@
/*
* Intel ACPI Component Architecture
* AML/ASL+ Disassembler version 20190509 (64-bit version)
* Copyright (c) 2000 - 2019 Intel Corporation
*
* Disassembling to symbolic ASL+ operators
*
- * Disassembly of tests/data/acpi/q35/DSDT.multi-bridge, Thu Oct 7 18:56:05 2021
+ * Disassembly of /tmp/aml-AN0DA1, Thu Oct 7 18:56:05 2021
*
* Original Table Header:

  *     Signature        "DSDT"
- *     Length           0x000020FE (8446)
+ *     Length           0x00002187 (8583)
  *     Revision         0x01 **** 32-bit table (V1), no 64-bit math support
- *     Checksum         0xDE
+ *     Checksum         0x8D
  *     OEM ID           "BOCHS "
  *     OEM Table ID     "BXPC    "
  *     OEM Revision     0x00000001 (1)
  *     Compiler ID      "BXPC"
  *     Compiler Version 0x00000001 (1)

*/
DefinitionBlock ("", "DSDT", 1, "BOCHS ", "BXPC ", 0x00000001)
{
- /*

-     * iASL Warning: There was 1 external control method found during
-     * disassembly, but only 0 were resolved (1 unresolved). Additional
-     * ACPI tables may be required to properly disassemble the code. This
-     * resulting disassembler output file may not compile because the
-     * disassembler did not know how many arguments to assign to the
-     * unresolved methods. Note: SSDTs can be dynamically loaded at
-     * runtime and may or may not be available via the host OS.
-     *
-     * In addition, the -fe option can be used to specify a file containing
-     * control method external declarations with the associated method
-     * argument counts. Each line of the file must be of the form:
-     *     External (<method pathname>, MethodObj, <argument count>)
-     * Invocation:
-     *     iasl -fe refs.txt -d dsdt.aml
-     *
-     * The following methods were unresolved and many not compile properly
-     * because the disassembler had to guess at the number of arguments
-     * required for each:
-     */
-    External (_SB_.PCI0.S19_.PCNT, MethodObj)    // Warning: Unknown method, guessing 1 arguments
-
     Scope (\)
     {
         OperationRegion (DBG, SystemIO, 0x0402, One)
         Field (DBG, ByteAcc, NoLock, Preserve)
         {
             DBGB,   8
         }

         Method (DBUG, 1, NotSerialized)
         {
             ToHexString (Arg0, Local0)
             ToBuffer (Local0, Local0)
             Local1 = (SizeOf (Local0) - One)
             Local2 = Zero
             While ((Local2 < Local1))
             {
@@ -3322,24 +3300,60 @@
                 Method (DVNT, 2, NotSerialized)
                 {
                     If ((Arg0 & One))
                     {
                         Notify (S00, Arg1)
                     }
                 }

                 Method (PCNT, 0, NotSerialized)
                 {
                     BNUM = One
                     DVNT (PCIU, One)
                     DVNT (PCID, 0x03)
                 }
             }

+ Device (S19)
+ {

+                Name (_ADR, 0x00030001)  // _ADR: Address
+                Name (BSEL, Zero)
+                Device (S00)
+                {
+                    Name (_SUN, Zero)  // _SUN: Slot User Number
+                    Name (_ADR, Zero)  // _ADR: Address
+                    Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device, x=0-9
+                    {

+ PCEJ (BSEL, _SUN)
+ }
+
+ Method (_DSM, 4, Serialized) // _DSM: Device-Specific Method
+ {
+ Return (PDSM (Arg0, Arg1, Arg2, Arg3, BSEL, _SUN))
+ }
+ }
+
+ Method (DVNT, 2, NotSerialized)
+ {
+ If ((Arg0 & One))
+ {
+ Notify (S00, Arg1)
+ }
+ }
+
+ Method (PCNT, 0, NotSerialized)
+ {

+                    BNUM = Zero
+                    DVNT (PCIU, One)
+                    DVNT (PCID, 0x03)

+ }
+ }
+
Method (PCNT, 0, NotSerialized)
{

-                ^S19.PCNT (^S10.PCNT ())
+                ^S19.PCNT ()
+                ^S10.PCNT ()
             }
         }
     }

}

Message-Id: <[email protected]>

(cherry picked from commit 04dd78b9e85720226a148eef54b45cb02b463034)
---
 tests/qtest/bios-tables-test.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
tests/qtest/bios-tables-test.c +18 -0
index 51d3a4e239..921f676e4c 100644
@@ -859,6 +859,23 @@ static void test_acpi_q35_tcg_bridge(void)
     free_test_data(&data);
 }
 
+static void test_acpi_q35_multif_bridge(void)
+{
+    test_data data = {
+        .machine = MACHINE_Q35,
+        .variant = ".multi-bridge",
+    };
+    test_acpi_one("-device pcie-root-port,id=pcie-root-port-0,"
+                  "multifunction=on,"
+                  "port=0x0,chassis=1,addr=0x2,bus=pcie.0 "
+                  "-device pcie-root-port,id=pcie-root-port-1,"
+                  "port=0x1,chassis=2,addr=0x3.0x1,bus=pcie.0 "
+                  "-device virtio-balloon,id=balloon0,"
+                  "bus=pcie.0,addr=0x4.0x2",
+                  &data);
+    free_test_data(&data);
+}
+
 static void test_acpi_q35_tcg_mmio64(void)
 {
     test_data data = {
@@ -1528,6 +1545,7 @@ int main(int argc, char *argv[])
                        test_acpi_piix4_no_acpi_pci_hotplug);
         qtest_add_func("acpi/q35", test_acpi_q35_tcg);
         qtest_add_func("acpi/q35/bridge", test_acpi_q35_tcg_bridge);
+        qtest_add_func("acpi/q35/multif-bridge", test_acpi_q35_multif_bridge);
         qtest_add_func("acpi/q35/mmio64", test_acpi_q35_tcg_mmio64);
         qtest_add_func("acpi/piix4/ipmi", test_acpi_piix4_tcg_ipmi);
         qtest_add_func("acpi/q35/ipmi", test_acpi_q35_tcg_ipmi);
Signature · 1 line
2.25.1
#26 lore raw

PATCH 26/47 tests/acpi/bios-tables-test: update DSDT blob for multifunction bridge test

In reply to Michael Roth

From: Ani Sinha <[email protected]>

We added a new unit test for testing acpi hotplug on multifunction bridges in q35 machines. Here, we update the DSDT table gloden master blob for this unit test.

The test adds the following devices to qemu and then checks the changes introduced in the DSDT table due to the addition of the following devices:

(a) a multifunction bridge device
(b) a bridge device with function 1
(c) a non-bridge device with function 2

In the DSDT table, we should see AML hotplug descriptions for (a) and (b). For (a) we should find a hotplug AML description for function 0.

Following is the ASL diff between the original DSDT table and the modified DSDT table due to the unit test. We see that multifunction bridge on bus 2 and single function bridge on bus 3 function 1 are described, not the non-bridge balloon device on bus 4, function 2.

@@ -1,30 +1,30 @@
/*
* Intel ACPI Component Architecture
* AML/ASL+ Disassembler version 20190509 (64-bit version)
* Copyright (c) 2000 - 2019 Intel Corporation
*
* Disassembling to symbolic ASL+ operators
*
- * Disassembly of tests/data/acpi/q35/DSDT, Thu Oct 7 18:29:19 2021
+ * Disassembly of /tmp/aml-C7JCA1, Thu Oct 7 18:29:19 2021 *
* Original Table Header:

  *     Signature        "DSDT"
- *     Length           0x00002061 (8289)
+ *     Length           0x00002187 (8583)
  *     Revision         0x01 **** 32-bit table (V1), no 64-bit math support
- *     Checksum         0xF9
+ *     Checksum         0x8D
  *     OEM ID           "BOCHS "
  *     OEM Table ID     "BXPC    "
  *     OEM Revision     0x00000001 (1)
  *     Compiler ID      "BXPC"
  *     Compiler Version 0x00000001 (1)
  */
 DefinitionBlock ("", "DSDT", 1, "BOCHS ", "BXPC    ", 0x00000001)
 {
     Scope (\)
     {
         OperationRegion (DBG, SystemIO, 0x0402, One)
         Field (DBG, ByteAcc, NoLock, Preserve)
         {
             DBGB,   8
         }

@@ -3265,23 +3265,95 @@

                 Method (_S1D, 0, NotSerialized)  // _S1D: S1 Device State
                 {
                     Return (Zero)
                 }

                 Method (_S2D, 0, NotSerialized)  // _S2D: S2 Device State
                 {
                     Return (Zero)
                 }

                 Method (_S3D, 0, NotSerialized)  // _S3D: S3 Device State
                 {
                     Return (Zero)
                 }
             }

+ Device (S10)
+ {

+                Name (_ADR, 0x00020000)  // _ADR: Address
+                Name (BSEL, One)
+                Device (S00)
+                {
+                    Name (_SUN, Zero)  // _SUN: Slot User Number
+                    Name (_ADR, Zero)  // _ADR: Address
+                    Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device, x=0-9
+                    {

+ PCEJ (BSEL, _SUN)
+ }
+
+ Method (_DSM, 4, Serialized) // _DSM: Device-Specific Method
+ {
+ Return (PDSM (Arg0, Arg1, Arg2, Arg3, BSEL, _SUN))
+ }
+ }
+
+ Method (DVNT, 2, NotSerialized)
+ {
+ If ((Arg0 & One))
+ {
+ Notify (S00, Arg1)
+ }
+ }
+
+ Method (PCNT, 0, NotSerialized)
+ {

+                    BNUM = One
+                    DVNT (PCIU, One)
+                    DVNT (PCID, 0x03)

+ }
+ }
+
+ Device (S19)
+ {

+                Name (_ADR, 0x00030001)  // _ADR: Address
+                Name (BSEL, Zero)
+                Device (S00)
+                {
+                    Name (_SUN, Zero)  // _SUN: Slot User Number
+                    Name (_ADR, Zero)  // _ADR: Address
+                    Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device, x=0-9
+                    {

+ PCEJ (BSEL, _SUN)
+ }
+
+ Method (_DSM, 4, Serialized) // _DSM: Device-Specific Method
+ {
+ Return (PDSM (Arg0, Arg1, Arg2, Arg3, BSEL, _SUN))
+ }
+ }
+
+ Method (DVNT, 2, NotSerialized)
+ {
+ If ((Arg0 & One))
+ {
+ Notify (S00, Arg1)
+ }
+ }
+
+ Method (PCNT, 0, NotSerialized)
+ {

+                    BNUM = Zero
+                    DVNT (PCIU, One)
+                    DVNT (PCID, 0x03)

+ }
+ }
+
Method (PCNT, 0, NotSerialized)
{
+ ^S19.PCNT ()
+ ^S10.PCNT ()

             }
         }
     }

}

Message-Id: <[email protected]>

(cherry picked from commit a8339e07f94a47f99560baef59d65a9e039aaf45)
---
 tests/data/acpi/q35/DSDT.multi-bridge       | Bin 0 -> 8583 bytes
 tests/qtest/bios-tables-test-allowed-diff.h |   1 -
 2 files changed, 1 deletion(-)
tests/data/acpi/q35/DSDT.multi-bridge binary +0 -0
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..a24c713d22102a1a1583b5c902edffe1694e5cfe 100644
GIT binary patch
tests/qtest/bios-tables-test-allowed-diff.h +0 -1
index dabc024f53..dfb8523c8b 100644
@@ -1,2 +1 @@
 /* List of comma-separated changed AML files to ignore */
-"tests/data/acpi/q35/DSDT.multi-bridge",
Signature · 1 line
2.25.1
#27 lore raw

PATCH 27/47 block/file-posix: Fix return value translation for AIO discards

In reply to Michael Roth

From: Ari Sundholm <[email protected]>

AIO discards regressed as a result of the following commit:
0dfc7af2 block/file-posix: Optimize for macOS

When trying to run blkdiscard within a Linux guest, the request would fail, with some errors in dmesg:

---- [ snip ] ----

[    4.010070] sd 2:0:0:0: [sda] tag#0 FAILED Result: hostbyte=DID_OK
driverbyte=DRIVER_SENSE
[    4.011061] sd 2:0:0:0: [sda] tag#0 Sense Key : Aborted Command
[current]
[    4.011061] sd 2:0:0:0: [sda] tag#0 Add. Sense: I/O process
terminated
[    4.011061] sd 2:0:0:0: [sda] tag#0 CDB: Unmap/Read sub-channel 42
00 00 00 00 00 00 00 18 00
[    4.011061] blk_update_request: I/O error, dev sda, sector 0

---- [ snip ] ----

This turns out to be a result of a flaw in changes to the error value translation logic in handle_aiocb_discard(). The default return value may be left untranslated in some configurations, and the wrong variable is used in one translation.

Fix both issues.

Fixes 0dfc7af2b28 ("block/file-posix: Optimize for macOS")

Message-Id: <[email protected]>

(cherry picked from commit 13a028336f2c05e7ff47dfdaf30dfac7f4883e80)
---
 block/file-posix.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
block/file-posix.c +2 -2
index 1567edb3d5..dd295cfc6d 100644
@@ -1807,7 +1807,7 @@ static int handle_aiocb_copy_range(void *opaque)
 static int handle_aiocb_discard(void *opaque)
 {
     RawPosixAIOData *aiocb = opaque;
-    int ret = -EOPNOTSUPP;
+    int ret = -ENOTSUP;
     BDRVRawState *s = aiocb->bs->opaque;
 
     if (!s->has_discard) {
@@ -1829,7 +1829,7 @@ static int handle_aiocb_discard(void *opaque)
 #ifdef CONFIG_FALLOCATE_PUNCH_HOLE
         ret = do_fallocate(s->fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE,
                            aiocb->aio_offset, aiocb->aio_nbytes);
-        ret = translate_err(-errno);
+        ret = translate_err(ret);
 #elif defined(__APPLE__) && (__MACH__)
         fpunchhole_t fpunchhole;
         fpunchhole.fp_flags = 0;
Signature · 1 line
2.25.1
#28 lore raw

PATCH 28/47 Partially revert "build: -no-pie is no functional linker flag"

In reply to Michael Roth

From: Jessica Clarke <[email protected]>

This partially reverts commit bbd2d5a8120771ec59b86a80a1f51884e0a26e53.

This commit was misguided and broke using --disable-pie on any distro that enables PIE by default in their compiler driver, including Debian and its derivatives. Whilst -no-pie is not a linker flag, it is a compiler driver flag that ensures -pie is not automatically passed by it to the linker. Without it, all compile_prog checks will fail as any code built with the explicit -fno-pie will fail to link with the implicit default -pie due to trying to use position-dependent relocations. The only bug that needed fixing was LDFLAGS_NOPIE being used as a flag for the linker itself in pc-bios/optionrom/Makefile.

Note this does not reinstate exporting LDFLAGS_NOPIE, as it is unused, since the only previous use was the one that should not have existed. I have also updated the comment for the -fno-pie and -no-pie checks to reflect what they're actually needed for.

Fixes bbd2d5a8120771ec59b86a80a1f51884e0a26e53
Cc Christian Ehrhardt <[email protected]>
Cc Paolo Bonzini <[email protected]>

Message-Id: <[email protected]>

(cherry picked from commit ffd205ef2901bd65fcfbd09a98c0ff7cfcec5e4d)
---
 configure | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
configure +4 -1
index 7659870810..6e308ed77f 100755
@@ -2246,9 +2246,11 @@ static THREAD int tls_var;
 int main(void) { return tls_var; }
 EOF
 
-# Check we support --no-pie first; we will need this for building ROMs.
+# Check we support -fno-pie and -no-pie first; we will need the former for
+# building ROMs, and both for everything if --disable-pie is passed.
 if compile_prog "-Werror -fno-pie" "-no-pie"; then
   CFLAGS_NOPIE="-fno-pie"
+  LDFLAGS_NOPIE="-no-pie"
 fi
 
 if test "$static" = "yes"; then
@@ -2264,6 +2266,7 @@ if test "$static" = "yes"; then
   fi
 elif test "$pie" = "no"; then
   CONFIGURE_CFLAGS="$CFLAGS_NOPIE $CONFIGURE_CFLAGS"
+  CONFIGURE_LDFLAGS="$LDFLAGS_NOPIE $CONFIGURE_LDFLAGS"
 elif compile_prog "-Werror -fPIE -DPIE" "-pie"; then
   CONFIGURE_CFLAGS="-fPIE -DPIE $CONFIGURE_CFLAGS"
   CONFIGURE_LDFLAGS="-pie $CONFIGURE_LDFLAGS"
Signature · 1 line
2.25.1
#29 lore raw

PATCH 29/47 target-i386: mmu: use pg_mode instead of HF_LMA_MASK

In reply to Michael Roth

From: Paolo Bonzini <[email protected]>

Correctly look up the paging mode of the hypervisor when it is using 64-bit mode but the guest is not.

Fixes 68746930ae ("target/i386: use mmu_translate for NPT walk", 2021-05-11)
(cherry picked from commit 93eae3583256896dd91a4c2ca38dcbb8d4051cff)
---
 target/i386/tcg/sysemu/excp_helper.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
target/i386/tcg/sysemu/excp_helper.c +2 -2
index b6d940e04e..2dea4a248e 100644
@@ -90,7 +90,7 @@ static int mmu_translate(CPUState *cs, hwaddr addr, MMUTranslateFunc get_hphys_f
         target_ulong pdpe_addr;
 
 #ifdef TARGET_X86_64
-        if (env->hflags & HF_LMA_MASK) {
+        if (pg_mode & PG_MODE_LMA) {
             bool la57 = pg_mode & PG_MODE_LA57;
             uint64_t pml5e_addr, pml5e;
             uint64_t pml4e_addr, pml4e;
@@ -287,7 +287,7 @@ do_check_protect_pse36:
         *prot |= PAGE_EXEC;
     }
 
-    if (!(env->hflags & HF_LMA_MASK)) {
+    if (!(pg_mode & PG_MODE_LMA)) {
         pkr = 0;
     } else if (ptep & PG_USER_MASK) {
         pkr = pg_mode & PG_MODE_PKE ? env->pkru : 0;
Signature · 1 line
2.25.1
#30 lore raw

PATCH 30/47 target-i386: mmu: fix handling of noncanonical virtual addresses

In reply to Michael Roth

From: Paolo Bonzini <[email protected]>

mmu_translate is supposed to return an error code for page faults; it is not able to handle other exceptions. The #GP case for noncanonical virtual addresses is not handled correctly, and incorrectly raised as a page fault with error code 1. Since it cannot happen for nested page tables, move it directly to handle_mmu_fault, even before the invocation of mmu_translate.

Fixes #676
Fixes 661ff4879e ("target/i386: extract mmu_translate", 2021-05-11)
(cherry picked from commit b04dc92e013d55c9ac8082caefff45dcfb1310e7)
---
 target/i386/tcg/sysemu/excp_helper.c | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)
target/i386/tcg/sysemu/excp_helper.c +12 -9
index 2dea4a248e..9fb59058ef 100644
@@ -94,15 +94,6 @@ static int mmu_translate(CPUState *cs, hwaddr addr, MMUTranslateFunc get_hphys_f
             bool la57 = pg_mode & PG_MODE_LA57;
             uint64_t pml5e_addr, pml5e;
             uint64_t pml4e_addr, pml4e;
-            int32_t sext;
-
-            /* test virtual address sign extension */
-            sext = la57 ? (int64_t)addr >> 56 : (int64_t)addr >> 47;
-            if (get_hphys_func && sext != 0 && sext != -1) {
-                env->error_code = 0;
-                cs->exception_index = EXCP0D_GPF;
-                return 1;
-            }
 
             if (la57) {
                 pml5e_addr = ((cr3 & ~0xfff) +
@@ -423,6 +414,18 @@ static int handle_mmu_fault(CPUState *cs, vaddr addr, int size,
         page_size = 4096;
     } else {
         pg_mode = get_pg_mode(env);
+        if (pg_mode & PG_MODE_LMA) {
+            int32_t sext;
+
+            /* test virtual address sign extension */
+            sext = (int64_t)addr >> (pg_mode & PG_MODE_LA57 ? 56 : 47);
+            if (sext != 0 && sext != -1) {
+                env->error_code = 0;
+                cs->exception_index = EXCP0D_GPF;
+                return 1;
+            }
+        }
+
         error_code = mmu_translate(cs, addr, get_hphys, env->cr[3], is_write1,
                                    mmu_idx, pg_mode,
                                    &paddr, &page_size, &prot);
Signature · 1 line
2.25.1
#31 lore raw

PATCH 31/47 hw/scsi/scsi-disk: MODE_PAGE_ALLS not allowed in MODE SELECT commands

In reply to Michael Roth

From: Mauro Matteo Cascella <[email protected]>

This avoids an off-by-one read of 'mode_sense_valid' buffer in hw/scsi/scsi-disk.c:mode_sense_page().

Fixes CVE-2021-3930
Fixes a8f4bbe2900 ("scsi-disk: store valid mode pages in a table")
Fixes #546
(cherry picked from commit b3af7fdf9cc537f8f0dd3e2423d83f5c99a457e8)
---
 hw/scsi/scsi-disk.c | 6 ++++++
 1 file changed, 6 insertions(+)
hw/scsi/scsi-disk.c +6 -0
index e8a547dbb7..d4914178ea 100644
@@ -1087,6 +1087,7 @@ static int mode_sense_page(SCSIDiskState *s, int page, uint8_t **p_outbuf,
     uint8_t *p = *p_outbuf + 2;
     int length;
 
+    assert(page < ARRAY_SIZE(mode_sense_valid));
     if ((mode_sense_valid[page] & (1 << s->qdev.type)) == 0) {
         return -1;
     }
@@ -1428,6 +1429,11 @@ static int scsi_disk_check_mode_select(SCSIDiskState *s, int page,
         return -1;
     }
 
+    /* MODE_PAGE_ALLS is only valid for MODE SENSE commands */
+    if (page == MODE_PAGE_ALLS) {
+        return -1;
+    }
+
     p = mode_current;
     memset(mode_current, 0, inlen + 2);
     len = mode_sense_page(s, page, &p, 0);
Signature · 1 line
2.25.1
#32 lore raw

PATCH 32/47 hw: m68k: virt: Add compat machine for 6.1

In reply to Michael Roth

From: Laurent Vivier <[email protected]>

Add the missing machine type for m68k/virt

Message-Id: <[email protected]>

(cherry picked from commit 6837f299762679429924242a63f16490862578e3)
---
 hw/m68k/virt.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
hw/m68k/virt.c +8 -1
index 4e8bce5aa6..0d9e3f83c1 100644
@@ -304,7 +304,14 @@ type_init(virt_machine_register_types)
     } \
     type_init(machvirt_machine_##major##_##minor##_init);
 
+static void virt_machine_6_1_options(MachineClass *mc)
+{
+}
+DEFINE_VIRT_MACHINE(6, 1, true)
+
 static void virt_machine_6_0_options(MachineClass *mc)
 {
+    virt_machine_6_1_options(mc);
+    compat_props_add(mc->compat_props, hw_compat_6_0, hw_compat_6_0_len);
 }
-DEFINE_VIRT_MACHINE(6, 0, true)
+DEFINE_VIRT_MACHINE(6, 0, false)
Signature · 1 line
2.25.1
#33 lore raw

PATCH 33/47 rcu: Introduce force_rcu notifier

In reply to Michael Roth

From: Greg Kurz <[email protected]>

The drain_rcu_call() function can be blocked as long as an RCU reader stays in a read-side critical section. This is typically what happens when a TCG vCPU is executing a busy loop. It can deadlock the QEMU monitor as reported in https://gitlab.com/qemu-project/qemu/-/issues/650 .

This can be avoided by allowing drain_rcu_call() to enforce an RCU grace period. Since each reader might need to do specific actions to end a read-side critical section, do it with notifiers.

Prepare ground for this by adding a notifier list to the RCU reader struct and use it in wait_for_readers() if drain_rcu_call() is in progress. An API is added for readers to register their notifiers.

This is largely based on a draft from Paolo Bonzini.

Message-Id: <[email protected]>

(cherry picked from commit ef149763a8fcce70b85dfda27cc1222ecf765750)
---
 include/qemu/rcu.h | 15 +++++++++++++++
 util/rcu.c         | 19 +++++++++++++++++++
 2 files changed, 34 insertions(+)
include/qemu/rcu.h +15 -0
index 515d327cf1..e69efbd47f 100644
@@ -27,6 +27,7 @@
 #include "qemu/thread.h"
 #include "qemu/queue.h"
 #include "qemu/atomic.h"
+#include "qemu/notify.h"
 #include "qemu/sys_membarrier.h"
 
 #ifdef __cplusplus
@@ -66,6 +67,13 @@ struct rcu_reader_data {
 
     /* Data used for registry, protected by rcu_registry_lock */
     QLIST_ENTRY(rcu_reader_data) node;
+
+    /*
+     * NotifierList used to force an RCU grace period.  Accessed under
+     * rcu_registry_lock.  Note that the notifier is called _outside_
+     * the thread!
+     */
+    NotifierList force_rcu;
 };
 
 extern __thread struct rcu_reader_data rcu_reader;
@@ -180,6 +188,13 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC(RCUReadAuto, rcu_read_auto_unlock)
 #define RCU_READ_LOCK_GUARD() \
     g_autoptr(RCUReadAuto) _rcu_read_auto __attribute__((unused)) = rcu_read_auto_lock()
 
+/*
+ * Force-RCU notifiers tell readers that they should exit their
+ * read-side critical section.
+ */
+void rcu_add_force_rcu_notifier(Notifier *n);
+void rcu_remove_force_rcu_notifier(Notifier *n);
+
 #ifdef __cplusplus
 }
 #endif
util/rcu.c +19 -0
index 13ac0f75cb..c91da9f137 100644
@@ -46,6 +46,7 @@
 unsigned long rcu_gp_ctr = RCU_GP_LOCKED;
 
 QemuEvent rcu_gp_event;
+static int in_drain_call_rcu;
 static QemuMutex rcu_registry_lock;
 static QemuMutex rcu_sync_lock;
 
@@ -107,6 +108,8 @@ static void wait_for_readers(void)
                  * get some extra futex wakeups.
                  */
                 qatomic_set(&index->waiting, false);
+            } else if (qatomic_read(&in_drain_call_rcu)) {
+                notifier_list_notify(&index->force_rcu, NULL);
             }
         }
 
@@ -339,8 +342,10 @@ void drain_call_rcu(void)
      * assumed.
      */
 
+    qatomic_inc(&in_drain_call_rcu);
     call_rcu1(&rcu_drain.rcu, drain_rcu_callback);
     qemu_event_wait(&rcu_drain.drain_complete_event);
+    qatomic_dec(&in_drain_call_rcu);
 
     if (locked) {
         qemu_mutex_lock_iothread();
@@ -363,6 +368,20 @@ void rcu_unregister_thread(void)
     qemu_mutex_unlock(&rcu_registry_lock);
 }
 
+void rcu_add_force_rcu_notifier(Notifier *n)
+{
+    qemu_mutex_lock(&rcu_registry_lock);
+    notifier_list_add(&rcu_reader.force_rcu, n);
+    qemu_mutex_unlock(&rcu_registry_lock);
+}
+
+void rcu_remove_force_rcu_notifier(Notifier *n)
+{
+    qemu_mutex_lock(&rcu_registry_lock);
+    notifier_remove(n);
+    qemu_mutex_unlock(&rcu_registry_lock);
+}
+
 static void rcu_init_complete(void)
 {
     QemuThread thread;
Signature · 1 line
2.25.1
#34 lore raw

PATCH 34/47 accel/tcg: Register a force_rcu notifier

In reply to Michael Roth

From: Greg Kurz <[email protected]>

A TCG vCPU doing a busy loop systematicaly hangs the QEMU monitor if the user passes 'device_add' without argument. This is because drain_cpu_all() which is called from qmp_device_add() cannot return if readers don't exit read-side critical sections. That is typically what busy-looping TCG vCPUs do:

int cpu_exec(CPUState *cpu)
{
[...]

    rcu_read_lock();
[...]
    while (!cpu_handle_exception(cpu, &ret)) {
        // Busy loop keeps vCPU here
    }
[...]
    rcu_read_unlock();

    return ret;
}

For MTTCG, have all vCPU threads register a force_rcu notifier that will kick them out of the loop using async_run_on_cpu(). The notifier is called with the rcu_registry_lock mutex held, using async_run_on_cpu() ensures there are no deadlocks.

For RR, a single thread runs all vCPUs. Just register a single notifier that kicks the current vCPU to the next one.

For MTTCG:

For RR:

Fixes 7bed89958bfb ("device_core: use drain_call_rcu in in qmp_device_add")

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/650

Message-Id: <[email protected]>

(cherry picked from commit dd47a8f654d84f666b235ce8891e17ee76f9be8b)
---
 accel/tcg/tcg-accel-ops-mttcg.c | 26 ++++++++++++++++++++++++++
 accel/tcg/tcg-accel-ops-rr.c    | 10 ++++++++++
 2 files changed, 36 insertions(+)
accel/tcg/tcg-accel-ops-mttcg.c +26 -0
index 847d2079d2..29632bd4c0 100644
@@ -28,6 +28,7 @@
 #include "sysemu/tcg.h"
 #include "sysemu/replay.h"
 #include "qemu/main-loop.h"
+#include "qemu/notify.h"
 #include "qemu/guest-random.h"
 #include "exec/exec-all.h"
 #include "hw/boards.h"
@@ -35,6 +36,26 @@
 #include "tcg-accel-ops.h"
 #include "tcg-accel-ops-mttcg.h"
 
+typedef struct MttcgForceRcuNotifier {
+    Notifier notifier;
+    CPUState *cpu;
+} MttcgForceRcuNotifier;
+
+static void do_nothing(CPUState *cpu, run_on_cpu_data d)
+{
+}
+
+static void mttcg_force_rcu(Notifier *notify, void *data)
+{
+    CPUState *cpu = container_of(notify, MttcgForceRcuNotifier, notifier)->cpu;
+
+    /*
+     * Called with rcu_registry_lock held, using async_run_on_cpu() ensures
+     * that there are no deadlocks.
+     */
+    async_run_on_cpu(cpu, do_nothing, RUN_ON_CPU_NULL);
+}
+
 /*
  * In the multi-threaded case each vCPU has its own thread. The TLS
  * variable current_cpu can be used deep in the code to find the
@@ -43,12 +64,16 @@
 
 static void *mttcg_cpu_thread_fn(void *arg)
 {
+    MttcgForceRcuNotifier force_rcu;
     CPUState *cpu = arg;
 
     assert(tcg_enabled());
     g_assert(!icount_enabled());
 
     rcu_register_thread();
+    force_rcu.notifier.notify = mttcg_force_rcu;
+    force_rcu.cpu = cpu;
+    rcu_add_force_rcu_notifier(&force_rcu.notifier);
     tcg_register_thread();
 
     qemu_mutex_lock_iothread();
@@ -100,6 +125,7 @@ static void *mttcg_cpu_thread_fn(void *arg)
 
     tcg_cpus_destroy(cpu);
     qemu_mutex_unlock_iothread();
+    rcu_remove_force_rcu_notifier(&force_rcu.notifier);
     rcu_unregister_thread();
     return NULL;
 }
accel/tcg/tcg-accel-ops-rr.c +10 -0
index c02c061ecb..aa5b4ac247 100644
@@ -28,6 +28,7 @@
 #include "sysemu/tcg.h"
 #include "sysemu/replay.h"
 #include "qemu/main-loop.h"
+#include "qemu/notify.h"
 #include "qemu/guest-random.h"
 #include "exec/exec-all.h"
 
@@ -135,6 +136,11 @@ static void rr_deal_with_unplugged_cpus(void)
     }
 }
 
+static void rr_force_rcu(Notifier *notify, void *data)
+{
+    rr_kick_next_cpu();
+}
+
 /*
  * In the single-threaded case each vCPU is simulated in turn. If
  * there is more than a single vCPU we create a simple timer to kick
@@ -145,10 +151,13 @@ static void rr_deal_with_unplugged_cpus(void)
 
 static void *rr_cpu_thread_fn(void *arg)
 {
+    Notifier force_rcu;
     CPUState *cpu = arg;
 
     assert(tcg_enabled());
     rcu_register_thread();
+    force_rcu.notify = rr_force_rcu;
+    rcu_add_force_rcu_notifier(&force_rcu);
     tcg_register_thread();
 
     qemu_mutex_lock_iothread();
@@ -257,6 +266,7 @@ static void *rr_cpu_thread_fn(void *arg)
         rr_deal_with_unplugged_cpus();
     }
 
+    rcu_remove_force_rcu_notifier(&force_rcu);
     rcu_unregister_thread();
     return NULL;
 }
Signature · 1 line
2.25.1
#35 lore raw

PATCH 35/47 pcie: rename 'native-hotplug' to 'x-native-hotplug'

In reply to Michael Roth

From: Igor Mammedov <[email protected]>

Mark property as experimental/internal adding 'x-' prefix.

Property was introduced in 6.1 and it should have provided ability to turn on native PCIE hotplug on port even when ACPI PCI hotplug is in use is user explicitly sets property on CLI. However that never worked since slot is wired to ACPI hotplug controller.
Another non-intended usecase: disable native hotplug on slot when APCI based hotplug is disabled, which works but slot has 'hotplug' property for this taks.

It should be relatively safe to rename it to experimental as no users should exist for it and given that the property is broken we don't really want to leave it around for much longer lest users start using it.

Message-Id: <[email protected]>

(cherry picked from commit 2aa1842d6d79dcd1b84c58eeb44591a99a9e56df)
---
 hw/i386/pc_q35.c   | 2 +-
 hw/pci/pcie_port.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
hw/i386/pc_q35.c +1 -1
index 04b4a4788d..9070544a90 100644
@@ -243,7 +243,7 @@ static void pc_q35_init(MachineState *machine)
                                           NULL);
 
     if (acpi_pcihp) {
-        object_register_sugar_prop(TYPE_PCIE_SLOT, "native-hotplug",
+        object_register_sugar_prop(TYPE_PCIE_SLOT, "x-native-hotplug",
                                    "false", true);
     }
 
hw/pci/pcie_port.c +1 -1
index da850e8dde..e95c1e5519 100644
@@ -148,7 +148,7 @@ static Property pcie_slot_props[] = {
     DEFINE_PROP_UINT8("chassis", PCIESlot, chassis, 0),
     DEFINE_PROP_UINT16("slot", PCIESlot, slot, 0),
     DEFINE_PROP_BOOL("hotplug", PCIESlot, hotplug, true),
-    DEFINE_PROP_BOOL("native-hotplug", PCIESlot, native_hotplug, true),
+    DEFINE_PROP_BOOL("x-native-hotplug", PCIESlot, native_hotplug, true),
     DEFINE_PROP_END_OF_LIST()
 };
 
Signature · 1 line
2.25.1
#36 lore raw

PATCH 36/47 virtio: use virtio accessor to access packed descriptor flags

In reply to Michael Roth

From: Jason Wang <[email protected]>

We used to access packed descriptor flags via address_space_{write|read}_cached(). When we hit the cache, memcpy() is used which is not an atomic operation which may lead a wrong value is read or wrote.

So this patch switches to use virito_{stw|lduw}_phys_cached() to make sure the aceess is atomic.

Fixes 86044b24e865f ("virtio: basic packed virtqueue support")

Message-Id: <[email protected]>

(cherry picked from commit f463e761a41ee71e59892121e1c74d9c25c985d2)
---
 hw/virtio/virtio.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)
hw/virtio/virtio.c +4 -7
index 874377f37a..2dbccb6b3f 100644
@@ -509,11 +509,9 @@ static void vring_packed_desc_read_flags(VirtIODevice *vdev,
                                          MemoryRegionCache *cache,
                                          int i)
 {
-    address_space_read_cached(cache,
-                              i * sizeof(VRingPackedDesc) +
-                              offsetof(VRingPackedDesc, flags),
-                              flags, sizeof(*flags));
-    virtio_tswap16s(vdev, flags);
+    hwaddr off = i * sizeof(VRingPackedDesc) + offsetof(VRingPackedDesc, flags);
+
+    *flags = virtio_lduw_phys_cached(vdev, cache, off);
 }
 
 static void vring_packed_desc_read(VirtIODevice *vdev,
@@ -566,8 +564,7 @@ static void vring_packed_desc_write_flags(VirtIODevice *vdev,
 {
     hwaddr off = i * sizeof(VRingPackedDesc) + offsetof(VRingPackedDesc, flags);
 
-    virtio_tswap16s(vdev, &desc->flags);
-    address_space_write_cached(cache, off, &desc->flags, sizeof(desc->flags));
+    virtio_stw_phys_cached(vdev, cache, off, desc->flags);
     address_space_cache_invalidate(cache, off, sizeof(desc->flags));
 }
 
Signature · 1 line
2.25.1
#37 lore raw

PATCH 37/47 virtio: use virtio accessor to access packed event

In reply to Michael Roth

From: Jason Wang <[email protected]>

We used to access packed descriptor event and off_wrap via address_space_{write|read}_cached(). When we hit the cache, memcpy() is used which is not atomic which may lead a wrong value to be read or wrote.

This patch fixes this by switching to use virito_{stw|lduw}_phys_cached() to make sure the access is atomic.

Fixes 683f7665679c1 ("virtio: event suppression support for packed ring")

Message-Id: <[email protected]>

(cherry picked from commit d152cdd6f6fad381e804c8185f0ba938030ccac9)
---
 hw/virtio/virtio.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)
hw/virtio/virtio.c +4 -9
index 2dbccb6b3f..c9567f09ed 100644
@@ -249,13 +249,10 @@ static void vring_packed_event_read(VirtIODevice *vdev,
     hwaddr off_off = offsetof(VRingPackedDescEvent, off_wrap);
     hwaddr off_flags = offsetof(VRingPackedDescEvent, flags);
 
-    address_space_read_cached(cache, off_flags, &e->flags,
-                              sizeof(e->flags));
+    e->flags = virtio_lduw_phys_cached(vdev, cache, off_flags);
     /* Make sure flags is seen before off_wrap */
     smp_rmb();
-    address_space_read_cached(cache, off_off, &e->off_wrap,
-                              sizeof(e->off_wrap));
-    virtio_tswap16s(vdev, &e->off_wrap);
+    e->off_wrap = virtio_lduw_phys_cached(vdev, cache, off_off);
     virtio_tswap16s(vdev, &e->flags);
 }
 
@@ -265,8 +262,7 @@ static void vring_packed_off_wrap_write(VirtIODevice *vdev,
 {
     hwaddr off = offsetof(VRingPackedDescEvent, off_wrap);
 
-    virtio_tswap16s(vdev, &off_wrap);
-    address_space_write_cached(cache, off, &off_wrap, sizeof(off_wrap));
+    virtio_stw_phys_cached(vdev, cache, off, off_wrap);
     address_space_cache_invalidate(cache, off, sizeof(off_wrap));
 }
 
@@ -275,8 +271,7 @@ static void vring_packed_flags_write(VirtIODevice *vdev,
 {
     hwaddr off = offsetof(VRingPackedDescEvent, flags);
 
-    virtio_tswap16s(vdev, &flags);
-    address_space_write_cached(cache, off, &flags, sizeof(flags));
+    virtio_stw_phys_cached(vdev, cache, off, flags);
     address_space_cache_invalidate(cache, off, sizeof(flags));
 }
 
Signature · 1 line
2.25.1
#38 lore raw

PATCH 38/47 vfio: Fix memory leak of hostwin

In reply to Michael Roth

From: Peng Liang <[email protected]>

hostwin is allocated and added to hostwin_list in vfio_host_win_add, but it is only deleted from hostwin_list in vfio_host_win_del, which causes a memory leak. Also, freeing all elements in hostwin_list is missing in vfio_disconnect_container.

Fix: 2e4109de8e58 ("vfio/spapr: Create DMA window dynamically (SPAPR IOMMU v2)")

(cherry picked from commit f3bc3a73c908df15966e66f88d5a633bd42fd029)
---
 hw/vfio/common.c | 8 ++++++++
 1 file changed, 8 insertions(+)
hw/vfio/common.c +8 -0
index 8728d4d5c2..af37346aca 100644
@@ -551,6 +551,7 @@ static int vfio_host_win_del(VFIOContainer *container, hwaddr min_iova,
     QLIST_FOREACH(hostwin, &container->hostwin_list, hostwin_next) {
         if (hostwin->min_iova == min_iova && hostwin->max_iova == max_iova) {
             QLIST_REMOVE(hostwin, hostwin_next);
+            g_free(hostwin);
             return 0;
         }
     }
@@ -2230,6 +2231,7 @@ static void vfio_disconnect_container(VFIOGroup *group)
     if (QLIST_EMPTY(&container->group_list)) {
         VFIOAddressSpace *space = container->space;
         VFIOGuestIOMMU *giommu, *tmp;
+        VFIOHostDMAWindow *hostwin, *next;
 
         QLIST_REMOVE(container, next);
 
@@ -2240,6 +2242,12 @@ static void vfio_disconnect_container(VFIOGroup *group)
             g_free(giommu);
         }
 
+        QLIST_FOREACH_SAFE(hostwin, &container->hostwin_list, hostwin_next,
+                           next) {
+            QLIST_REMOVE(hostwin, hostwin_next);
+            g_free(hostwin);
+        }
+
         trace_vfio_disconnect_container(container->fd);
         close(container->fd);
         g_free(container);
Signature · 1 line
2.25.1
#39 lore raw

PATCH 39/47 nbd/server: Don't complain on certain client disconnects

In reply to Michael Roth

From: Eric Blake <[email protected]>

When a client disconnects abruptly, but did not have any pending requests (for example, when using nbdsh without calling h.shutdown), we used to output the following message:

$ qemu-nbd -f raw file
$ nbdsh -u 'nbd://localhost:10809' -c 'h.trim(1,0)'
qemu-nbd: Disconnect client, due to: Failed to read request: Unexpected end-of-file before all bytes were read

Then in commit f148ae7, we refactored nbd_receive_request() to use nbd_read_eof(); when this returns 0, we regressed into tracing uninitialized memory (if tracing is enabled) and reporting a less-specific:

qemu-nbd: Disconnect client, due to: Request handling failed in intermediate state

Note that with Unix sockets, we have yet another error message, unchanged by the 6.0 regression:

$ qemu-nbd -k /tmp/sock -f raw file
$ nbdsh -u 'nbd+unix:///?socket=/tmp/sock' -c 'h.trim(1,0)'
qemu-nbd: Disconnect client, due to: Failed to send reply: Unable to write to socket: Broken pipe

But in all cases, the error message goes away if the client performs a soft shutdown by using NBD_CMD_DISC, rather than a hard shutdown by abrupt disconnect:

$ nbdsh -u 'nbd://localhost:10809' -c 'h.trim(1,0)' -c 'h.shutdown()'

This patch fixes things to avoid uninitialized memory, and in general avoids warning about a client that does a hard shutdown when not in the middle of a packet. A client that aborts mid-request, or which does not read the full server's reply, can still result in warnings, but those are indeed much more unusual situations.

Fixes f148ae7d36 ("nbd/server: Quiesce coroutines on context switch", v6.0.0)
[eblake: defer unrelated typo fixes to later patch]

Message-Id: <[email protected]>

(cherry picked from commit 1644cccea5c71b02b9cf8f78b780e7069a29b189)
---
 nbd/server.c | 3 +++
 1 file changed, 3 insertions(+)
nbd/server.c +3 -0
index 3927f7789d..83aeed51c7 100644
@@ -1413,6 +1413,9 @@ static int nbd_receive_request(NBDClient *client, NBDRequest *request,
     if (ret < 0) {
         return ret;
     }
+    if (ret == 0) {
+        return -EIO;
+    }
 
     /* Request
        [ 0 ..  3]   magic   (NBD_REQUEST_MAGIC)
Signature · 1 line
2.25.1
#40 lore raw

PATCH 40/47 hw/nvme: fix buffer overrun in nvme_changed_nslist (CVE-2021-3947)

In reply to Michael Roth

From: Klaus Jensen <[email protected]>

Fix missing offset verification.

Cc Philippe Mathieu-Daudé <[email protected]>
Fixes f432fdfa121 ("support changed namespace asynchronous event")
(cherry picked from commit e2c57529c9306e4c9aac75d9879f6e7699584a22)
---
 hw/nvme/ctrl.c | 5 +++++
 1 file changed, 5 insertions(+)
hw/nvme/ctrl.c +5 -0
index 6baf9e0420..27dddb87bd 100644
@@ -4164,6 +4164,11 @@ static uint16_t nvme_changed_nslist(NvmeCtrl *n, uint8_t rae, uint32_t buf_len,
     int i = 0;
     uint32_t nsid;
 
+    if (off >= sizeof(nslist)) {
+        trace_pci_nvme_err_invalid_log_page_offset(off, sizeof(nslist));
+        return NVME_INVALID_FIELD | NVME_DNR;
+    }
+
     memset(nslist, 0x0, sizeof(nslist));
     trans_len = MIN(sizeof(nslist) - off, buf_len);
 
Signature · 1 line
2.25.1
#41 lore raw

PATCH 41/47 chardev/wctable: don't free the instance in wctablet_chr_finalize

In reply to Michael Roth

From: Daniil Tatianin <[email protected]>

Object is supposed to be freed by invoking obj->free, and not obj->instance_finalize. This would lead to use-after-free followed by double free in object_unref/object_finalize.

Message-Id: <[email protected]>

(cherry picked from commit fdc6e168181d06391711171b7c409b34f2981ced)
---
 chardev/wctablet.c | 1 -
 1 file changed, 1 deletion(-)
chardev/wctablet.c +0 -1
index 95e005f5a5..e8b292c43c 100644
@@ -320,7 +320,6 @@ static void wctablet_chr_finalize(Object *obj)
     TabletChardev *tablet = WCTABLET_CHARDEV(obj);
 
     qemu_input_handler_unregister(tablet->hs);
-    g_free(tablet);
 }
 
 static void wctablet_chr_open(Chardev *chr,
Signature · 1 line
2.25.1
#42 lore raw

PATCH 42/47 hw/block/fdc: Extract blk_create_empty_drive()

In reply to Michael Roth

From: Philippe Mathieu-Daudé <[email protected]>

We are going to re-use this code in the next commit, so extract it as a new blk_create_empty_drive() function.

Message-id: [email protected]

(cherry picked from commit b154791e7b6d4ca5cdcd54443484d97360bd7ad2)
---
 hw/block/fdc.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
hw/block/fdc.c +7 -2
index 9014cd30b3..c3e09973ca 100644
@@ -61,6 +61,12 @@
     } while (0)
 
 
+/* Anonymous BlockBackend for empty drive */
+static BlockBackend *blk_create_empty_drive(void)
+{
+    return blk_new(qemu_get_aio_context(), 0, BLK_PERM_ALL);
+}
+
 /********************************************************/
 /* qdev floppy bus                                      */
 
@@ -486,8 +492,7 @@ static void floppy_drive_realize(DeviceState *qdev, Error **errp)
     }
 
     if (!dev->conf.blk) {
-        /* Anonymous BlockBackend for an empty drive */
-        dev->conf.blk = blk_new(qemu_get_aio_context(), 0, BLK_PERM_ALL);
+        dev->conf.blk = blk_create_empty_drive();
         ret = blk_attach_dev(dev->conf.blk, qdev);
         assert(ret == 0);
 
Signature · 1 line
2.25.1
#43 lore raw

PATCH 43/47 hw/block/fdc: Kludge missing floppy drive to fix CVE-2021-20196

In reply to Michael Roth

From: Philippe Mathieu-Daudé <[email protected]>

Guest might select another drive on the bus by setting the DRIVE_SEL bit of the DIGITAL OUTPUT REGISTER (DOR). The current controller model doesn't expect a BlockBackend to be NULL. A simple way to fix CVE-2021-20196 is to create an empty BlockBackend when it is missing. All further accesses will be safely handled, and the controller state machines keep behaving correctly.

Message-id: [email protected]

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/338

(cherry picked from commit 1ab95af033a419e7a64e2d58e67dd96b20af5233)
---
 hw/block/fdc.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
hw/block/fdc.c +13 -1
index c3e09973ca..af398c1116 100644
@@ -1166,7 +1166,19 @@ static FDrive *get_drv(FDCtrl *fdctrl, int unit)
 
 static FDrive *get_cur_drv(FDCtrl *fdctrl)
 {
-    return get_drv(fdctrl, fdctrl->cur_drv);
+    FDrive *cur_drv = get_drv(fdctrl, fdctrl->cur_drv);
+
+    if (!cur_drv->blk) {
+        /*
+         * Kludge: empty drive line selected. Create an anonymous
+         * BlockBackend to avoid NULL deref with various BlockBackend
+         * API calls within this model (CVE-2021-20196).
+         * Due to the controller QOM model limitations, we don't
+         * attach the created to the controller device.
+         */
+        cur_drv->blk = blk_create_empty_drive();
+    }
+    return cur_drv;
 }
 
 /* Status A register : 0x00 (read-only) */
Signature · 1 line
2.25.1
#44 lore raw

PATCH 44/47 tests/qtest/fdc-test: Add a regression test for CVE-2021-20196

In reply to Michael Roth

From: Philippe Mathieu-Daudé <[email protected]>

Without the previous commit, when running 'make check-qtest-i386' with QEMU configured with '--enable-sanitizers' we get:

AddressSanitizer:DEADLYSIGNAL
=================================================================
==287878==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000344 ==287878==The signal is caused by a WRITE memory access. ==287878==Hint: address points to the zero page.

      #0 0x564b2e5bac27 in blk_inc_in_flight block/block-backend.c:1346:5
      #1 0x564b2e5bb228 in blk_pwritev_part block/block-backend.c:1317:5
      #2 0x564b2e5bcd57 in blk_pwrite block/block-backend.c:1498:11
      #3 0x564b2ca1cdd3 in fdctrl_write_data hw/block/fdc.c:2221:17
      #4 0x564b2ca1b2f7 in fdctrl_write hw/block/fdc.c:829:9
      #5 0x564b2dc49503 in portio_write softmmu/ioport.c:201:9

Add the reproducer for CVE-2021-20196.

Message-id: [email protected]

(cherry picked from commit cc20926e9b8077bff6813efc8dcdeae90d1a3b10)
---
 tests/qtest/fdc-test.c | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)
tests/qtest/fdc-test.c +38 -0
index 26b69f7c5c..8f6eee84a4 100644
@@ -32,6 +32,9 @@
 /* TODO actually test the results and get rid of this */
 #define qmp_discard_response(...) qobject_unref(qmp(__VA_ARGS__))
 
+#define DRIVE_FLOPPY_BLANK \
+    "-drive if=floppy,file=null-co://,file.read-zeroes=on,format=raw,size=1440k"
+
 #define TEST_IMAGE_SIZE 1440 * 1024
 
 #define FLOPPY_BASE 0x3f0
@@ -546,6 +549,40 @@ static void fuzz_registers(void)
     }
 }
 
+static bool qtest_check_clang_sanitizer(void)
+{
+#if defined(__SANITIZE_ADDRESS__) || __has_feature(address_sanitizer)
+    return true;
+#else
+    g_test_skip("QEMU not configured using --enable-sanitizers");
+    return false;
+#endif
+}
+static void test_cve_2021_20196(void)
+{
+    QTestState *s;
+
+    if (!qtest_check_clang_sanitizer()) {
+        return;
+    }
+
+    s = qtest_initf("-nographic -m 32M -nodefaults " DRIVE_FLOPPY_BLANK);
+
+    qtest_outw(s, 0x3f4, 0x0500);
+    qtest_outb(s, 0x3f5, 0x00);
+    qtest_outb(s, 0x3f5, 0x00);
+    qtest_outw(s, 0x3f4, 0x0000);
+    qtest_outb(s, 0x3f5, 0x00);
+    qtest_outw(s, 0x3f1, 0x0400);
+    qtest_outw(s, 0x3f4, 0x0000);
+    qtest_outw(s, 0x3f4, 0x0000);
+    qtest_outb(s, 0x3f5, 0x00);
+    qtest_outb(s, 0x3f5, 0x01);
+    qtest_outw(s, 0x3f1, 0x0500);
+    qtest_outb(s, 0x3f5, 0x00);
+    qtest_quit(s);
+}
+
 int main(int argc, char **argv)
 {
     int fd;
@@ -576,6 +613,7 @@ int main(int argc, char **argv)
     qtest_add_func("/fdc/read_no_dma_18", test_read_no_dma_18);
     qtest_add_func("/fdc/read_no_dma_19", test_read_no_dma_19);
     qtest_add_func("/fdc/fuzz-registers", fuzz_registers);
+    qtest_add_func("/fdc/fuzz/cve_2021_20196", test_cve_2021_20196);
 
     ret = g_test_run();
 
Signature · 1 line
2.25.1
#45 lore raw

PATCH 45/47 virtio-blk: Fix clean up of host notifiers for single MR transaction.

In reply to Michael Roth

From: Mark Mielke <[email protected]>

The code that introduced "virtio-blk: Configure all host notifiers in a single MR transaction" introduced a second loop variable to perform cleanup in second loop, but mistakenly still refers to the first loop variable within the second loop body.

Fixes d0267da61489 ("virtio-blk: Configure all host notifiers in a single MR transaction")

Message-id: CALm7yL08qarOu0dnQkTN+pa=BSRC92g31YpQQNDeAiT4yLZWQQ@mail.gmail.com

(cherry picked from commit 5b807181c27a940a3a7ad1f221a2e76a132cbdc0)
---
 hw/block/dataplane/virtio-blk.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/block/dataplane/virtio-blk.c +1 -1
index 252c3a7a23..ee5a5352dc 100644
@@ -222,7 +222,7 @@ int virtio_blk_data_plane_start(VirtIODevice *vdev)
             memory_region_transaction_commit();
 
             while (j--) {
-                virtio_bus_cleanup_host_notifier(VIRTIO_BUS(qbus), i);
+                virtio_bus_cleanup_host_notifier(VIRTIO_BUS(qbus), j);
             }
             goto fail_host_notifiers;
         }
Signature · 1 line
2.25.1
#46 lore raw

PATCH 46/47 net: vmxnet3: validate configuration values during activate (CVE-2021-20203)

In reply to Michael Roth

From: Prasad J Pandit <[email protected]>

While activating device in vmxnet3_acticate_device(), it does not validate guest supplied configuration values against predefined minimum - maximum limits. This may lead to integer overflow or OOB access issues. Add checks to avoid it.

Fixes CVE-2021-20203
(cherry picked from commit d05dcd94aee88728facafb993c7280547eb4d645)
---
 hw/net/vmxnet3.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
hw/net/vmxnet3.c +13 -0
index 41f796a247..f65af4e9ef 100644
@@ -1441,6 +1441,7 @@ static void vmxnet3_activate_device(VMXNET3State *s)
     vmxnet3_setup_rx_filtering(s);
     /* Cache fields from shared memory */
     s->mtu = VMXNET3_READ_DRV_SHARED32(d, s->drv_shmem, devRead.misc.mtu);
+    assert(VMXNET3_MIN_MTU <= s->mtu && s->mtu < VMXNET3_MAX_MTU);
     VMW_CFPRN("MTU is %u", s->mtu);
 
     s->max_rx_frags =
@@ -1486,6 +1487,9 @@ static void vmxnet3_activate_device(VMXNET3State *s)
         /* Read rings memory locations for TX queues */
         pa = VMXNET3_READ_TX_QUEUE_DESCR64(d, qdescr_pa, conf.txRingBasePA);
         size = VMXNET3_READ_TX_QUEUE_DESCR32(d, qdescr_pa, conf.txRingSize);
+        if (size > VMXNET3_TX_RING_MAX_SIZE) {
+            size = VMXNET3_TX_RING_MAX_SIZE;
+        }
 
         vmxnet3_ring_init(d, &s->txq_descr[i].tx_ring, pa, size,
                           sizeof(struct Vmxnet3_TxDesc), false);
@@ -1496,6 +1500,9 @@ static void vmxnet3_activate_device(VMXNET3State *s)
         /* TXC ring */
         pa = VMXNET3_READ_TX_QUEUE_DESCR64(d, qdescr_pa, conf.compRingBasePA);
         size = VMXNET3_READ_TX_QUEUE_DESCR32(d, qdescr_pa, conf.compRingSize);
+        if (size > VMXNET3_TC_RING_MAX_SIZE) {
+            size = VMXNET3_TC_RING_MAX_SIZE;
+        }
         vmxnet3_ring_init(d, &s->txq_descr[i].comp_ring, pa, size,
                           sizeof(struct Vmxnet3_TxCompDesc), true);
         VMXNET3_RING_DUMP(VMW_CFPRN, "TXC", i, &s->txq_descr[i].comp_ring);
@@ -1537,6 +1544,9 @@ static void vmxnet3_activate_device(VMXNET3State *s)
             /* RX rings */
             pa = VMXNET3_READ_RX_QUEUE_DESCR64(d, qd_pa, conf.rxRingBasePA[j]);
             size = VMXNET3_READ_RX_QUEUE_DESCR32(d, qd_pa, conf.rxRingSize[j]);
+            if (size > VMXNET3_RX_RING_MAX_SIZE) {
+                size = VMXNET3_RX_RING_MAX_SIZE;
+            }
             vmxnet3_ring_init(d, &s->rxq_descr[i].rx_ring[j], pa, size,
                               sizeof(struct Vmxnet3_RxDesc), false);
             VMW_CFPRN("RX queue %d:%d: Base: %" PRIx64 ", Size: %d",
@@ -1546,6 +1556,9 @@ static void vmxnet3_activate_device(VMXNET3State *s)
         /* RXC ring */
         pa = VMXNET3_READ_RX_QUEUE_DESCR64(d, qd_pa, conf.compRingBasePA);
         size = VMXNET3_READ_RX_QUEUE_DESCR32(d, qd_pa, conf.compRingSize);
+        if (size > VMXNET3_RC_RING_MAX_SIZE) {
+            size = VMXNET3_RC_RING_MAX_SIZE;
+        }
         vmxnet3_ring_init(d, &s->rxq_descr[i].comp_ring, pa, size,
                           sizeof(struct Vmxnet3_RxCompDesc), true);
         VMW_CFPRN("RXC queue %d: Base: %" PRIx64 ", Size: %d", i, pa, size);
Signature · 1 line
2.25.1
#47 lore raw

PATCH 47/47 e1000: fix tx re-entrancy problem

In reply to Michael Roth

From: Jon Maloy <[email protected]>

The fact that the MMIO handler is not re-entrant causes an infinite loop under certain conditions:

Guest write to TDT -> Loopback -> RX (DMA to TDT) -> TX

We now eliminate the effect of this problem locally in e1000, by adding a boolean in struct E1000State indicating when the TX side is busy. This will cause any entering new call to return early instead of interfering with the ongoing work, and eliminates any risk of looping.

This is intended to address CVE-2021-20257.

(cherry picked from commit 25ddb946e6301f42cff3094ea1c25fb78813e7e9)
---
 hw/net/e1000.c | 7 +++++++
 1 file changed, 7 insertions(+)
hw/net/e1000.c +7 -0
index a30546c5d5..f5bc81296d 100644
@@ -107,6 +107,7 @@ struct E1000State_st {
         e1000x_txd_props props;
         e1000x_txd_props tso_props;
         uint16_t tso_frames;
+        bool busy;
     } tx;
 
     struct {
@@ -763,6 +764,11 @@ start_xmit(E1000State *s)
         return;
     }
 
+    if (s->tx.busy) {
+        return;
+    }
+    s->tx.busy = true;
+
     while (s->mac_reg[TDH] != s->mac_reg[TDT]) {
         base = tx_desc_base(s) +
                sizeof(struct e1000_tx_desc) * s->mac_reg[TDH];
@@ -789,6 +795,7 @@ start_xmit(E1000State *s)
             break;
         }
     }
+    s->tx.busy = false;
     set_ics(s, 0, cause);
 }
 
Signature · 1 line
2.25.1
#48 lore raw
In reply to Michael Roth
Quoted 5 lines · Michael Roth

Hi everyone,

The following new patches are queued for QEMU stable v6.1.1:

https://gitlab.com/qemu-project/qemu/-/commits/stable-6.1-staging/

FYI, this branch doesn't appear to have been pushed.

Quoted 6 lines

Patch freeze is 2021-12-21, and the release is planned for 2021-12-23:

https://wiki.qemu.org/Planning/6.1

Please respond here or CC [email protected] on any additional patches you think should (or shouldn't) be included in the release.

Based on critical fixes Fedora users hit in 6.1 we pulled in the following fixes that you've not queued yet:

eb94846280df3f1e2a91b6179fc05f9890b7e384 qxl: fix pre-save logic

69e3895f9d37ca39536775b13ce63e8c291427ba target/i386: add missing bits to CR4_RESERVED_MASK

b9537d5904f6e3df896264a6144883ab07db9608 tcg/arm: Reduce vector alignment requirement for NEON

8e751e9c38e324737fd3d3aa0562f886313bba3c tests: tcg: Fix PVH test with binutils 2.36+

Quoted 166 lines

----------------------------------------------------------------
Ani Sinha (6):
bios-tables-test: allow changes in DSDT ACPI tables for q35 hw/i386/acpi: fix conflicting IO address range for acpi pci hotplug in q35
bios-tables-test: Update ACPI DSDT table golden blobs for q35 tests/acpi/bios-tables-test: add and allow changes to a new q35 DSDT table blob tests/acpi/pcihp: add unit tests for hotplug on multifunction bridges for q35 tests/acpi/bios-tables-test: update DSDT blob for multifunction bridge test

Ari Sundholm (1):
block/file-posix: Fix return value translation for AIO discards

Christian Schoenebeck (1):
9pfs: fix crash in v9fs_walk()

Daniil Tatianin (1):
chardev/wctable: don't free the instance in wctablet_chr_finalize

David Hildenbrand (3):
virtio-balloon: don't start free page hinting if postcopy is possible
virtio-mem-pci: Fix memory leak when creating MEMORY_DEVICE_SIZE_CHANGE event
libvhost-user: fix VHOST_USER_REM_MEM_REG skipping mmap_addr

Eric Blake (1):
nbd/server: Don't complain on certain client disconnects

Gerd Hoffmann (1):
uas: add stream number sanity checks.

Greg Kurz (2):
rcu: Introduce force_rcu notifier
accel/tcg: Register a force_rcu notifier

Helge Deller (1):
hw/display/artist: Fix bug in coordinate extraction in artist_vram_read() and artist_vram_write()

Igor Mammedov (1):
pcie: rename 'native-hotplug' to 'x-native-hotplug'

Jason Wang (3):
virtio-net: fix use after unmap/free for sg
virtio: use virtio accessor to access packed descriptor flags
virtio: use virtio accessor to access packed event

Jean-Philippe Brucker (2):
hw/arm/virt: Rename default_bus_bypass_iommu hw/i386: Rename default_bus_bypass_iommu

Jessica Clarke (1):
Partially revert "build: -no-pie is no functional linker flag"

Jon Maloy (1):
e1000: fix tx re-entrancy problem

Klaus Jensen (1):
hw/nvme: fix buffer overrun in nvme_changed_nslist (CVE-2021-3947)

Laurent Vivier (1):
hw: m68k: virt: Add compat machine for 6.1

Mahmoud Mandour (1):
plugins/execlog: removed unintended "s" at the end of log lines.

Mark Mielke (1):
virtio-blk: Fix clean up of host notifiers for single MR transaction.

Markus Armbruster (1):
hmp: Unbreak "change vnc"

Mauro Matteo Cascella (1):
hw/scsi/scsi-disk: MODE_PAGE_ALLS not allowed in MODE SELECT commands

Michael S. Tsirkin (1):
pci: fix PCI resource reserve capability on BE

Michael Tokarev (1):
qemu-sockets: fix unix socket path copy (again)

Nir Soffer (1):
qemu-nbd: Change default cache mode to writeback

Paolo Bonzini (4):
plugins: do not limit exported symbols if modules are active
block: introduce max_hw_iov for use in scsi-generic
target-i386: mmu: use pg_mode instead of HF_LMA_MASK
target-i386: mmu: fix handling of noncanonical virtual addresses

Peng Liang (1):
vfio: Fix memory leak of hostwin

Peter Maydell (1):
target/arm: Don't skip M-profile reset entirely in user mode

Philippe Mathieu-Daudé (3):
hw/block/fdc: Extract blk_create_empty_drive() hw/block/fdc: Kludge missing floppy drive to fix CVE-2021-20196 tests/qtest/fdc-test: Add a regression test for CVE-2021-20196

Prasad J Pandit (1):
net: vmxnet3: validate configuration values during activate (CVE-2021-20203)

Stefano Garzarella (1):
vhost-vsock: fix migration issue when seqpacket is supported

Xueming Li (1):
vhost-user: fix duplicated notifier MR init

Yang Zhong (1):
i386/cpu: Remove AVX_VNNI feature from Cooperlake cpu model

 accel/tcg/tcg-accel-ops-mttcg.c           |  26 ++++++++++++++++++++
 accel/tcg/tcg-accel-ops-rr.c              |  10 ++++++++
 block/block-backend.c                     |   6 +++++
 block/file-posix.c                        |   6 ++---
 block/io.c                                |   1 +
 chardev/wctablet.c                        |   1 -
 configure                                 |  10 +++++---
 contrib/plugins/execlog.c                 |   2 +-
 docs/tools/qemu-nbd.rst                   |   6 +++--
 hw/9pfs/coth.h                            |   4 ++-
 hw/arm/virt.c                             |   4 +--
 hw/block/dataplane/virtio-blk.c           |   2 +-
 hw/block/fdc.c                            |  23 +++++++++++++++---
 hw/core/machine.c                         |   1 +
 hw/display/artist.c                       |   8 +++---
 hw/i386/pc.c                              |   2 +-
 hw/i386/pc_q35.c                          |   2 +-
 hw/m68k/virt.c                            |   9 ++++++-
 hw/net/e1000.c                            |   7 ++++++
 hw/net/virtio-net.c                       |  39 ++++++++++++++++++++++++------
 hw/net/vmxnet3.c                          |  13 ++++++++++
 hw/nvme/ctrl.c                            |   5 ++++
 hw/pci/pci_bridge.c                       |  10 ++++----
 hw/pci/pcie_port.c                        |   2 +-
 hw/scsi/scsi-disk.c                       |   6 +++++
 hw/scsi/scsi-generic.c                    |   2 +-
 hw/usb/dev-uas.c                          |  11 +++++++++
 hw/vfio/common.c                          |   8 ++++++
 hw/virtio/vhost-user.c                    |   5 ++--
 hw/virtio/vhost-vsock.c                   |  19 ++++++++++++---
 hw/virtio/virtio-balloon.c                |  13 ++++++++++
 hw/virtio/virtio-mem-pci.c                |   7 +-----
 hw/virtio/virtio.c                        |  24 ++++++------------
 include/block/block_int.h                 |   7 ++++++
 include/hw/acpi/ich9.h                    |   2 +-
 include/hw/virtio/vhost-vsock.h           |   3 +++
 include/qemu/rcu.h                        |  15 ++++++++++++
 include/sysemu/block-backend.h            |   1 +
 monitor/hmp-cmds.c                        |   2 +-
 nbd/server.c                              |   3 +++
 plugins/meson.build                       |  14 ++++++-----
 qemu-nbd.c                                |   6 +++--
 subprojects/libvhost-user/libvhost-user.c |   1 +
 target/arm/cpu.c                          |  19 +++++++++++++++
 target/i386/cpu.c                         |   2 +-
 target/i386/tcg/sysemu/excp_helper.c      |  25 ++++++++++---------
 tests/data/acpi/q35/DSDT                  | Bin 8289 -> 8289 bytes
 tests/data/acpi/q35/DSDT.acpihmat         | Bin 9614 -> 9614 bytes
 tests/data/acpi/q35/DSDT.bridge           | Bin 11003 -> 11003 bytes
 tests/data/acpi/q35/DSDT.cphp             | Bin 8753 -> 8753 bytes
 tests/data/acpi/q35/DSDT.dimmpxm          | Bin 9943 -> 9943 bytes
 tests/data/acpi/q35/DSDT.ipmibt           | Bin 8364 -> 8364 bytes
 tests/data/acpi/q35/DSDT.memhp            | Bin 9648 -> 9648 bytes
 tests/data/acpi/q35/DSDT.mmio64           | Bin 9419 -> 9419 bytes
 tests/data/acpi/q35/DSDT.multi-bridge     | Bin 0 -> 8583 bytes
 tests/data/acpi/q35/DSDT.nohpet           | Bin 8147 -> 8147 bytes
Quoted 11 lines
 tests/data/acpi/q35/DSDT.numamem          | Bin 8295 -> 8295 bytes
 tests/data/acpi/q35/DSDT.tis              | Bin 8894 -> 8894 bytes
 tests/qtest/bios-tables-test.c            |  18 ++++++++++++++
 tests/qtest/fdc-test.c                    |  38 +++++++++++++++++++++++++++++
 util/qemu-sockets.c                       |  13 ++++------
 util/rcu.c                                |  19 +++++++++++++++
 62 files changed, 386 insertions(+), 96 deletions(-)
 create mode 100644 tests/data/acpi/q35/DSDT.multi-bridge

Regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
#49 lore raw
Quoted 8 lines · Daniel P. Berrangé
Quoted 5 lines · Michael Roth

Hi everyone,

The following new patches are queued for QEMU stable v6.1.1:

https://gitlab.com/qemu-project/qemu/-/commits/stable-6.1-staging/

FYI, this branch doesn't appear to have been pushed.

Argh, sorry, outdated link format in my email template, the correct URL is:

https://gitlab.com/mdroth/qemu/-/commits/stable-6.1-staging/

Quoted 11 lines
Quoted 7 lines

Patch freeze is 2021-12-21, and the release is planned for 2021-12-23:

https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwiki.qemu.org%2FPlanning%2F6.1&amp;data=04%7C01%7Cmichael.roth%40amd.com%7Cc2deb18e48d7428bcd7a08d9bfac34df%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637751568618799581%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=yyM%2FWVt9UcJocOhBwRVXRN5MJmhttQ022gRhB1XlRcg%3D&amp;reserved=0

Please respond here or CC [email protected] on any additional patches you think should (or shouldn't) be included in the release.

Based on critical fixes Fedora users hit in 6.1 we pulled in the following fixes that you've not queued yet:

Quoted 7 lines

eb94846280df3f1e2a91b6179fc05f9890b7e384 qxl: fix pre-save logic

69e3895f9d37ca39536775b13ce63e8c291427ba target/i386: add missing bits to CR4_RESERVED_MASK

b9537d5904f6e3df896264a6144883ab07db9608 tcg/arm: Reduce vector alignment requirement for NEON

8e751e9c38e324737fd3d3aa0562f886313bba3c tests: tcg: Fix PVH test with binutils 2.36+

Will get these applied. Thanks!

#50 lore raw
In reply to Michael Roth
Quoted 4 lines · Michael Roth

Hi everyone,

The following new patches are queued for QEMU stable v6.1.1:

Quoted 8 lines

https://gitlab.com/qemu-project/qemu/-/commits/stable-6.1-staging/

Patch freeze is 2021-12-21, and the release is planned for 2021-12-23:

https://wiki.qemu.org/Planning/6.1

Please respond here or CC [email protected] on any additional patches you think should (or shouldn't) be included in the release.

Thank you for the suggestions so far. The following additional patches have been pushed to the staging tree:

fddd169de5 tests: tcg: Fix PVH test with binutils 2.36+ 711bd602cc tcg/arm: Reduce vector alignment requirement for NEON e88636b4d4 target/i386: add missing bits to CR4_RESERVED_MASK 34833f361b qxl: fix pre-save logic

https://gitlab.com/mdroth/qemu/-/commits/stable-6.1-staging/

Patch freeze is 2021-21-21 EOD.

-Mike

Quoted 180 lines

Thanks!

----------------------------------------------------------------
Ani Sinha (6):
bios-tables-test: allow changes in DSDT ACPI tables for q35 hw/i386/acpi: fix conflicting IO address range for acpi pci hotplug in q35
bios-tables-test: Update ACPI DSDT table golden blobs for q35 tests/acpi/bios-tables-test: add and allow changes to a new q35 DSDT table blob tests/acpi/pcihp: add unit tests for hotplug on multifunction bridges for q35 tests/acpi/bios-tables-test: update DSDT blob for multifunction bridge test

Ari Sundholm (1):
block/file-posix: Fix return value translation for AIO discards

Christian Schoenebeck (1):
9pfs: fix crash in v9fs_walk()

Daniil Tatianin (1):
chardev/wctable: don't free the instance in wctablet_chr_finalize

David Hildenbrand (3):
virtio-balloon: don't start free page hinting if postcopy is possible
virtio-mem-pci: Fix memory leak when creating MEMORY_DEVICE_SIZE_CHANGE event
libvhost-user: fix VHOST_USER_REM_MEM_REG skipping mmap_addr

Eric Blake (1):
nbd/server: Don't complain on certain client disconnects

Gerd Hoffmann (1):
uas: add stream number sanity checks.

Greg Kurz (2):
rcu: Introduce force_rcu notifier
accel/tcg: Register a force_rcu notifier

Helge Deller (1):
hw/display/artist: Fix bug in coordinate extraction in artist_vram_read() and artist_vram_write()

Igor Mammedov (1):
pcie: rename 'native-hotplug' to 'x-native-hotplug'

Jason Wang (3):
virtio-net: fix use after unmap/free for sg
virtio: use virtio accessor to access packed descriptor flags
virtio: use virtio accessor to access packed event

Jean-Philippe Brucker (2):
hw/arm/virt: Rename default_bus_bypass_iommu hw/i386: Rename default_bus_bypass_iommu

Jessica Clarke (1):
Partially revert "build: -no-pie is no functional linker flag"

Jon Maloy (1):
e1000: fix tx re-entrancy problem

Klaus Jensen (1):
hw/nvme: fix buffer overrun in nvme_changed_nslist (CVE-2021-3947)

Laurent Vivier (1):
hw: m68k: virt: Add compat machine for 6.1

Mahmoud Mandour (1):
plugins/execlog: removed unintended "s" at the end of log lines.

Mark Mielke (1):
virtio-blk: Fix clean up of host notifiers for single MR transaction.

Markus Armbruster (1):
hmp: Unbreak "change vnc"

Mauro Matteo Cascella (1):
hw/scsi/scsi-disk: MODE_PAGE_ALLS not allowed in MODE SELECT commands

Michael S. Tsirkin (1):
pci: fix PCI resource reserve capability on BE

Michael Tokarev (1):
qemu-sockets: fix unix socket path copy (again)

Nir Soffer (1):
qemu-nbd: Change default cache mode to writeback

Paolo Bonzini (4):
plugins: do not limit exported symbols if modules are active
block: introduce max_hw_iov for use in scsi-generic
target-i386: mmu: use pg_mode instead of HF_LMA_MASK
target-i386: mmu: fix handling of noncanonical virtual addresses

Peng Liang (1):
vfio: Fix memory leak of hostwin

Peter Maydell (1):
target/arm: Don't skip M-profile reset entirely in user mode

Philippe Mathieu-Daudé (3):
hw/block/fdc: Extract blk_create_empty_drive() hw/block/fdc: Kludge missing floppy drive to fix CVE-2021-20196 tests/qtest/fdc-test: Add a regression test for CVE-2021-20196

Prasad J Pandit (1):
net: vmxnet3: validate configuration values during activate (CVE-2021-20203)

Stefano Garzarella (1):
vhost-vsock: fix migration issue when seqpacket is supported

Xueming Li (1):
vhost-user: fix duplicated notifier MR init

Yang Zhong (1):
i386/cpu: Remove AVX_VNNI feature from Cooperlake cpu model

 accel/tcg/tcg-accel-ops-mttcg.c           |  26 ++++++++++++++++++++
 accel/tcg/tcg-accel-ops-rr.c              |  10 ++++++++
 block/block-backend.c                     |   6 +++++
 block/file-posix.c                        |   6 ++---
 block/io.c                                |   1 +
 chardev/wctablet.c                        |   1 -
 configure                                 |  10 +++++---
 contrib/plugins/execlog.c                 |   2 +-
 docs/tools/qemu-nbd.rst                   |   6 +++--
 hw/9pfs/coth.h                            |   4 ++-
 hw/arm/virt.c                             |   4 +--
 hw/block/dataplane/virtio-blk.c           |   2 +-
 hw/block/fdc.c                            |  23 +++++++++++++++---
 hw/core/machine.c                         |   1 +
 hw/display/artist.c                       |   8 +++---
 hw/i386/pc.c                              |   2 +-
 hw/i386/pc_q35.c                          |   2 +-
 hw/m68k/virt.c                            |   9 ++++++-
 hw/net/e1000.c                            |   7 ++++++
 hw/net/virtio-net.c                       |  39 ++++++++++++++++++++++++------
 hw/net/vmxnet3.c                          |  13 ++++++++++
 hw/nvme/ctrl.c                            |   5 ++++
 hw/pci/pci_bridge.c                       |  10 ++++----
 hw/pci/pcie_port.c                        |   2 +-
 hw/scsi/scsi-disk.c                       |   6 +++++
 hw/scsi/scsi-generic.c                    |   2 +-
 hw/usb/dev-uas.c                          |  11 +++++++++
 hw/vfio/common.c                          |   8 ++++++
 hw/virtio/vhost-user.c                    |   5 ++--
 hw/virtio/vhost-vsock.c                   |  19 ++++++++++++---
 hw/virtio/virtio-balloon.c                |  13 ++++++++++
 hw/virtio/virtio-mem-pci.c                |   7 +-----
 hw/virtio/virtio.c                        |  24 ++++++------------
 include/block/block_int.h                 |   7 ++++++
 include/hw/acpi/ich9.h                    |   2 +-
 include/hw/virtio/vhost-vsock.h           |   3 +++
 include/qemu/rcu.h                        |  15 ++++++++++++
 include/sysemu/block-backend.h            |   1 +
 monitor/hmp-cmds.c                        |   2 +-
 nbd/server.c                              |   3 +++
 plugins/meson.build                       |  14 ++++++-----
 qemu-nbd.c                                |   6 +++--
 subprojects/libvhost-user/libvhost-user.c |   1 +
 target/arm/cpu.c                          |  19 +++++++++++++++
 target/i386/cpu.c                         |   2 +-
 target/i386/tcg/sysemu/excp_helper.c      |  25 ++++++++++---------
 tests/data/acpi/q35/DSDT                  | Bin 8289 -> 8289 bytes
 tests/data/acpi/q35/DSDT.acpihmat         | Bin 9614 -> 9614 bytes
 tests/data/acpi/q35/DSDT.bridge           | Bin 11003 -> 11003 bytes
 tests/data/acpi/q35/DSDT.cphp             | Bin 8753 -> 8753 bytes
 tests/data/acpi/q35/DSDT.dimmpxm          | Bin 9943 -> 9943 bytes
 tests/data/acpi/q35/DSDT.ipmibt           | Bin 8364 -> 8364 bytes
 tests/data/acpi/q35/DSDT.memhp            | Bin 9648 -> 9648 bytes
 tests/data/acpi/q35/DSDT.mmio64           | Bin 9419 -> 9419 bytes
 tests/data/acpi/q35/DSDT.multi-bridge     | Bin 0 -> 8583 bytes
 tests/data/acpi/q35/DSDT.nohpet           | Bin 8147 -> 8147 bytes
 tests/data/acpi/q35/DSDT.numamem          | Bin 8295 -> 8295 bytes
 tests/data/acpi/q35/DSDT.tis              | Bin 8894 -> 8894 bytes
 tests/qtest/bios-tables-test.c            |  18 ++++++++++++++
 tests/qtest/fdc-test.c                    |  38 +++++++++++++++++++++++++++++
 util/qemu-sockets.c                       |  13 ++++------
 util/rcu.c                                |  19 +++++++++++++++
 62 files changed, 386 insertions(+), 96 deletions(-)
 create mode 100644 tests/data/acpi/q35/DSDT.multi-bridge