qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH 00/47] Patch Round-up for stable 7.2.1
@ 2023-03-08 16:57 Michael Tokarev
  2023-03-08 16:57 ` [PATCH 01/47] target/sh4: Mask restore of env->flags from tb->flags Michael Tokarev
                   ` (47 more replies)
  0 siblings, 48 replies; 50+ messages in thread
From: Michael Tokarev @ 2023-03-08 16:57 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-stable, Michael Tokarev

Hello!

This is my first attempt to perform a stable qemu release.
Doing it in a way similar to how Michael Roth did it before :)
But since this is my first attempt, this is an RFC for now.

The following new patches are queued for QEMU stable v7.2.1:

  https://gitlab.com/mjt0k/qemu/-/commits/stable-7.2-staging/

Please respond here or CC qemu-stable@nongnu.org on any additional patches
you think should (or shouldn't) be included in the release.

About some of the patches.

I picked up a few more than minimally necessary so that some of the CI
tests are fixed. These are the curl forward compat change, two changes
for tests/, and also "build-sys: fix crlf-ending C code" (fixes build
failure on msys-win32). The same failures exists on 7.2.0 now, while
the proposed 7.2.1 passes all tests I've tried so far (will try avocado
tests too once additional hdd will arrive).

Two patches ("vdpa: stop all svq on device deletion" and "Revert "hw/i386:
pass RNG seed via setup_data entry"") required conflict resolution when
cherry-picking.

2 virtio-rng-pci migration fixes makes certain v7.2.0 VMs non-migratable
to v7.2.1.

-----------------------------------------------------------------------

Akihiko Odaki (4):
  vhost-user-gpio: Configure vhost_dev when connecting
  vhost-user-i2c: Back up vqs before cleaning up vhost_dev
  vhost-user-rng: Back up vqs before cleaning up vhost_dev
  hw/timer/hpet: Fix expiration time overflow

Alex Bennée (2):
  target/arm: fix handling of HLT semihosting in system mode
  tests/tcg: fix unused variable in linux-test

Anton Johansson (1):
  block: Handle curl 7.55.0, 7.85.0 version changes

Carlos López (2):
  vhost: avoid a potential use of an uninitialized variable in
    vhost_svq_poll()
  libvhost-user: check for NULL when allocating a virtqueue element

Chenyi Qiang (2):
  virtio-mem: Fix the bitmap index of the section offset
  virtio-mem: Fix the iterator variable in a vmem->rdl_list loop

David Hildenbrand (2):
  migration/ram: Fix error handling in ram_write_tracking_start()
  migration/ram: Fix populate_read_range()

Dr. David Alan Gilbert (2):
  virtio-rng-pci: fix migration compat for vectors
  virtio-rng-pci: fix transitional migration compat for vectors

Eugenio Pérez (1):
  vdpa: stop all svq on device deletion

Evgeny Iakovlev (1):
  target/arm: allow writes to SCR_EL3.HXEn bit when FEAT_HCX is enabled

Guenter Roeck (1):
  target/sh4: Mask restore of env->flags from tb->flags

Jason Wang (3):
  vhost: fix vq dirty bitmap syncing when vIOMMU is enabled
  intel-iommu: fail MAP notifier without caching mode
  intel-iommu: fail DEVIOTLB_UNMAP without dt mode

Julia Suvorova (1):
  hw/smbios: fix field corruption in type 4 table

Kevin Wolf (1):
  qcow2: Fix theoretical corruption in store_bitmap() error path

Klaus Jensen (2):
  hw/nvme: fix missing endian conversions for doorbell buffers
  hw/nvme: fix missing cq eventidx update

Laszlo Ersek (1):
  acpi: cpuhp: fix guest-visible maximum access size to the legacy reg
    block

Marc-André Lureau (1):
  build-sys: fix crlf-ending C code

Michael S. Tsirkin (6):
  Revert "x86: do not re-randomize RNG seed on snapshot load"
  Revert "x86: re-initialize RNG seed when selecting kernel"
  Revert "x86: reinitialize RNG seed on system reboot"
  Revert "x86: use typedef for SetupData struct"
  Revert "x86: return modified setup_data only if read as memory, not as
    file"
  Revert "hw/i386: pass RNG seed via setup_data entry"

Paolo Bonzini (4):
  meson: accept relative symlinks in "meson introspect --installed" data
  configure: fix GLIB_VERSION for cross-compilation
  target/i386: fix ADOX followed by ADCX
  block/iscsi: fix double-free on BUSY or similar statuses

Richard Henderson (8):
  target/riscv: Set pc_succ_insn for !rvc illegal insn
  target/arm: Fix sve_probe_page
  target/arm: Fix in_debug path in S1_ptw_translate
  target/arm: Fix physical address resolution for Stage2
  tests/tcg/i386: Introduce and use reg_t consistently
  target/i386: Fix BEXTR instruction
  target/i386: Fix C flag for BLSI, BLSMSK, BLSR
  target/i386: Fix BZHI instruction

Stefan Hajnoczi (1):
  block: fix detect-zeroes= with BDRV_REQ_REGISTERED_BUF

Yajun Wu (1):
  chardev/char-socket: set s->listener = NULL in char_socket_finalize

 block/curl.c                              |  44 ++++-
 block/io.c                                |   3 +
 block/iscsi.c                             |   1 +
 block/qcow2-bitmap.c                      |   5 +-
 chardev/char-socket.c                     |   1 +
 configure                                 |   2 +-
 hw/acpi/cpu_hotplug.c                     |   3 +
 hw/core/machine.c                         |   3 +
 hw/i386/intel_iommu.c                     |  15 ++
 hw/i386/microvm.c                         |   2 +-
 hw/i386/pc.c                              |   4 +-
 hw/i386/pc_piix.c                         |   2 -
 hw/i386/pc_q35.c                          |   2 -
 hw/i386/x86.c                             |  88 ++--------
 hw/nvme/ctrl.c                            |  32 +++-
 hw/nvram/fw_cfg.c                         |  12 +-
 hw/smbios/smbios.c                        |   8 +-
 hw/timer/hpet.c                           |  19 ++-
 hw/virtio/vhost-shadow-virtqueue.c        |   2 +-
 hw/virtio/vhost-user-gpio.c               |  10 +-
 hw/virtio/vhost-user-i2c.c                |   5 +-
 hw/virtio/vhost-user-rng.c                |   5 +-
 hw/virtio/vhost-vdpa.c                    |  17 +-
 hw/virtio/vhost.c                         |  84 ++++++---
 hw/virtio/virtio-mem.c                    |   6 +-
 include/hw/i386/pc.h                      |   3 -
 include/hw/i386/x86.h                     |   3 +-
 include/hw/nvram/fw_cfg.h                 |  22 ---
 include/hw/virtio/vhost-user-gpio.h       |   2 +-
 meson.build                               |   2 +-
 migration/ram.c                           |   9 +-
 scripts/shaderinclude.pl                  |  16 --
 scripts/shaderinclude.py                  |  26 +++
 scripts/symlink-install-tree.py           |   1 -
 subprojects/libvhost-user/libvhost-user.c |   7 +
 target/arm/helper.c                       |   3 +
 target/arm/ptw.c                          |   6 +-
 target/arm/sve_helper.c                   |  14 +-
 target/arm/translate.c                    |   2 +-
 target/i386/tcg/emit.c.inc                |  59 ++++---
 target/riscv/translate.c                  |  12 +-
 target/sh4/cpu.c                          |   2 +-
 tests/tcg/Makefile.target                 |   2 +
 tests/tcg/i386/Makefile.target            |   6 +-
 tests/tcg/i386/test-i386-adcox.c          |  75 ++++++++
 tests/tcg/i386/test-i386-bmi2.c           | 197 ++++++++++++----------
 tests/tcg/multiarch/linux/linux-test.c    |   6 +-
 tests/tcg/riscv64/Makefile.target         |   6 +
 tests/tcg/riscv64/test-noc.S              |  32 ++++
 49 files changed, 547 insertions(+), 341 deletions(-)
 delete mode 100644 scripts/shaderinclude.pl
 create mode 100644 scripts/shaderinclude.py
 create mode 100644 tests/tcg/i386/test-i386-adcox.c
 create mode 100644 tests/tcg/riscv64/test-noc.S

-- 
2.30.2



^ permalink raw reply	[flat|nested] 50+ messages in thread

* [PATCH 01/47] target/sh4: Mask restore of env->flags from tb->flags
  2023-03-08 16:57 [RFC PATCH 00/47] Patch Round-up for stable 7.2.1 Michael Tokarev
@ 2023-03-08 16:57 ` Michael Tokarev
  2023-03-08 16:57 ` [PATCH 02/47] vhost: fix vq dirty bitmap syncing when vIOMMU is enabled Michael Tokarev
                   ` (46 subsequent siblings)
  47 siblings, 0 replies; 50+ messages in thread
From: Michael Tokarev @ 2023-03-08 16:57 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-stable, Guenter Roeck, Richard Henderson, Michael Tokarev

From: Guenter Roeck <linux@roeck-us.net>

The values in env->flags are a subset of tb->flags.
Restore only the bits that belong.

Cc: qemu-stable@nongnu.org
Fixes: ab419fd8a035 ("target/sh4: Fix TB_FLAG_UNALIGN")
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Message-ID: <20221212011345.GA2235238@roeck-us.net>
[rth: Reduce to only the the superh_cpu_synchronize_from_tb change]
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
(cherry picked from commit bc2331635ce18ff068d2bb1e493bc546e1f786e1)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
 target/sh4/cpu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/target/sh4/cpu.c b/target/sh4/cpu.c
index 453268392b..827cee25af 100644
--- a/target/sh4/cpu.c
+++ b/target/sh4/cpu.c
@@ -47,7 +47,7 @@ static void superh_cpu_synchronize_from_tb(CPUState *cs,
     SuperHCPU *cpu = SUPERH_CPU(cs);
 
     cpu->env.pc = tb_pc(tb);
-    cpu->env.flags = tb->flags;
+    cpu->env.flags = tb->flags & TB_FLAG_ENVFLAGS_MASK;
 }
 
 static void superh_restore_state_to_opc(CPUState *cs,
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH 02/47] vhost: fix vq dirty bitmap syncing when vIOMMU is enabled
  2023-03-08 16:57 [RFC PATCH 00/47] Patch Round-up for stable 7.2.1 Michael Tokarev
  2023-03-08 16:57 ` [PATCH 01/47] target/sh4: Mask restore of env->flags from tb->flags Michael Tokarev
@ 2023-03-08 16:57 ` Michael Tokarev
  2023-03-08 16:57 ` [PATCH 03/47] virtio-mem: Fix the bitmap index of the section offset Michael Tokarev
                   ` (45 subsequent siblings)
  47 siblings, 0 replies; 50+ messages in thread
From: Michael Tokarev @ 2023-03-08 16:57 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-stable, Jason Wang, Lei Yang, Yalan Zhang,
	Michael S . Tsirkin, Michael Tokarev

From: Jason Wang <jasowang@redhat.com>

When vIOMMU is enabled, the vq->used_phys is actually the IOVA not
GPA. So we need to translate it to GPA before the syncing otherwise we
may hit the following crash since IOVA could be out of the scope of
the GPA log size. This could be noted when using virtio-IOMMU with
vhost using 1G memory.

Fixes: c471ad0e9bd46 ("vhost_net: device IOTLB support")
Cc: qemu-stable@nongnu.org
Tested-by: Lei Yang <leiyang@redhat.com>
Reported-by: Yalan Zhang <yalzhang@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
Message-Id: <20221216033552.77087-1-jasowang@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit 345cc1cbcbce2bab00abc2b88338d7d89c702d6b)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
 hw/virtio/vhost.c | 84 ++++++++++++++++++++++++++++++++++++-----------
 1 file changed, 64 insertions(+), 20 deletions(-)

diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index d1c4c20b8c..34d356e903 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -20,6 +20,7 @@
 #include "qemu/range.h"
 #include "qemu/error-report.h"
 #include "qemu/memfd.h"
+#include "qemu/log.h"
 #include "standard-headers/linux/vhost_types.h"
 #include "hw/virtio/virtio-bus.h"
 #include "hw/virtio/virtio-access.h"
@@ -106,6 +107,24 @@ static void vhost_dev_sync_region(struct vhost_dev *dev,
     }
 }
 
+static bool vhost_dev_has_iommu(struct vhost_dev *dev)
+{
+    VirtIODevice *vdev = dev->vdev;
+
+    /*
+     * For vhost, VIRTIO_F_IOMMU_PLATFORM means the backend support
+     * incremental memory mapping API via IOTLB API. For platform that
+     * does not have IOMMU, there's no need to enable this feature
+     * which may cause unnecessary IOTLB miss/update transactions.
+     */
+    if (vdev) {
+        return virtio_bus_device_iommu_enabled(vdev) &&
+            virtio_host_has_feature(vdev, VIRTIO_F_IOMMU_PLATFORM);
+    } else {
+        return false;
+    }
+}
+
 static int vhost_sync_dirty_bitmap(struct vhost_dev *dev,
                                    MemoryRegionSection *section,
                                    hwaddr first,
@@ -137,8 +156,51 @@ static int vhost_sync_dirty_bitmap(struct vhost_dev *dev,
             continue;
         }
 
-        vhost_dev_sync_region(dev, section, start_addr, end_addr, vq->used_phys,
-                              range_get_last(vq->used_phys, vq->used_size));
+        if (vhost_dev_has_iommu(dev)) {
+            IOMMUTLBEntry iotlb;
+            hwaddr used_phys = vq->used_phys, used_size = vq->used_size;
+            hwaddr phys, s, offset;
+
+            while (used_size) {
+                rcu_read_lock();
+                iotlb = address_space_get_iotlb_entry(dev->vdev->dma_as,
+                                                      used_phys,
+                                                      true,
+                                                      MEMTXATTRS_UNSPECIFIED);
+                rcu_read_unlock();
+
+                if (!iotlb.target_as) {
+                    qemu_log_mask(LOG_GUEST_ERROR, "translation "
+                                  "failure for used_iova %"PRIx64"\n",
+                                  used_phys);
+                    return -EINVAL;
+                }
+
+                offset = used_phys & iotlb.addr_mask;
+                phys = iotlb.translated_addr + offset;
+
+                /*
+                 * Distance from start of used ring until last byte of
+                 * IOMMU page.
+                 */
+                s = iotlb.addr_mask - offset;
+                /*
+                 * Size of used ring, or of the part of it until end
+                 * of IOMMU page. To avoid zero result, do the adding
+                 * outside of MIN().
+                 */
+                s = MIN(s, used_size - 1) + 1;
+
+                vhost_dev_sync_region(dev, section, start_addr, end_addr, phys,
+                                      range_get_last(phys, s));
+                used_size -= s;
+                used_phys += s;
+            }
+        } else {
+            vhost_dev_sync_region(dev, section, start_addr,
+                                  end_addr, vq->used_phys,
+                                  range_get_last(vq->used_phys, vq->used_size));
+        }
     }
     return 0;
 }
@@ -306,24 +368,6 @@ static inline void vhost_dev_log_resize(struct vhost_dev *dev, uint64_t size)
     dev->log_size = size;
 }
 
-static bool vhost_dev_has_iommu(struct vhost_dev *dev)
-{
-    VirtIODevice *vdev = dev->vdev;
-
-    /*
-     * For vhost, VIRTIO_F_IOMMU_PLATFORM means the backend support
-     * incremental memory mapping API via IOTLB API. For platform that
-     * does not have IOMMU, there's no need to enable this feature
-     * which may cause unnecessary IOTLB miss/update transactions.
-     */
-    if (vdev) {
-        return virtio_bus_device_iommu_enabled(vdev) &&
-            virtio_host_has_feature(vdev, VIRTIO_F_IOMMU_PLATFORM);
-    } else {
-        return false;
-    }
-}
-
 static void *vhost_memory_map(struct vhost_dev *dev, hwaddr addr,
                               hwaddr *plen, bool is_write)
 {
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH 03/47] virtio-mem: Fix the bitmap index of the section offset
  2023-03-08 16:57 [RFC PATCH 00/47] Patch Round-up for stable 7.2.1 Michael Tokarev
  2023-03-08 16:57 ` [PATCH 01/47] target/sh4: Mask restore of env->flags from tb->flags Michael Tokarev
  2023-03-08 16:57 ` [PATCH 02/47] vhost: fix vq dirty bitmap syncing when vIOMMU is enabled Michael Tokarev
@ 2023-03-08 16:57 ` Michael Tokarev
  2023-03-08 16:57 ` [PATCH 04/47] virtio-mem: Fix the iterator variable in a vmem->rdl_list loop Michael Tokarev
                   ` (44 subsequent siblings)
  47 siblings, 0 replies; 50+ messages in thread
From: Michael Tokarev @ 2023-03-08 16:57 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-stable, Chenyi Qiang, David Hildenbrand, Michael S . Tsirkin,
	Michael Tokarev

From: Chenyi Qiang <chenyi.qiang@intel.com>

vmem->bitmap indexes the memory region of the virtio-mem backend at a
granularity of block_size. To calculate the index of target section offset,
the block_size should be divided instead of the bitmap_size.

Fixes: 2044969f0b ("virtio-mem: Implement RamDiscardManager interface")
Signed-off-by: Chenyi Qiang <chenyi.qiang@intel.com>
Message-Id: <20221216062231.11181-1-chenyi.qiang@intel.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Cc: qemu-stable@nongnu.org
Signed-off-by: David Hildenbrand <david@redhat.com>
(cherry picked from commit b11cf32e07a2f7ff0d171b89497381a04c9d07e0)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
 hw/virtio/virtio-mem.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/virtio/virtio-mem.c b/hw/virtio/virtio-mem.c
index ed170def48..e19ee817fe 100644
--- a/hw/virtio/virtio-mem.c
+++ b/hw/virtio/virtio-mem.c
@@ -235,7 +235,7 @@ static int virtio_mem_for_each_plugged_section(const VirtIOMEM *vmem,
     uint64_t offset, size;
     int ret = 0;
 
-    first_bit = s->offset_within_region / vmem->bitmap_size;
+    first_bit = s->offset_within_region / vmem->block_size;
     first_bit = find_next_bit(vmem->bitmap, vmem->bitmap_size, first_bit);
     while (first_bit < vmem->bitmap_size) {
         MemoryRegionSection tmp = *s;
@@ -267,7 +267,7 @@ static int virtio_mem_for_each_unplugged_section(const VirtIOMEM *vmem,
     uint64_t offset, size;
     int ret = 0;
 
-    first_bit = s->offset_within_region / vmem->bitmap_size;
+    first_bit = s->offset_within_region / vmem->block_size;
     first_bit = find_next_zero_bit(vmem->bitmap, vmem->bitmap_size, first_bit);
     while (first_bit < vmem->bitmap_size) {
         MemoryRegionSection tmp = *s;
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH 04/47] virtio-mem: Fix the iterator variable in a vmem->rdl_list loop
  2023-03-08 16:57 [RFC PATCH 00/47] Patch Round-up for stable 7.2.1 Michael Tokarev
                   ` (2 preceding siblings ...)
  2023-03-08 16:57 ` [PATCH 03/47] virtio-mem: Fix the bitmap index of the section offset Michael Tokarev
@ 2023-03-08 16:57 ` Michael Tokarev
  2023-03-08 16:57 ` [PATCH 05/47] target/arm: fix handling of HLT semihosting in system mode Michael Tokarev
                   ` (43 subsequent siblings)
  47 siblings, 0 replies; 50+ messages in thread
From: Michael Tokarev @ 2023-03-08 16:57 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-stable, Chenyi Qiang, Philippe Mathieu-Daudé,
	David Hildenbrand, Michael Tokarev

From: Chenyi Qiang <chenyi.qiang@intel.com>

It should be the variable rdl2 to revert the already-notified listeners.

Fixes: 2044969f0b ("virtio-mem: Implement RamDiscardManager interface")
Signed-off-by: Chenyi Qiang <chenyi.qiang@intel.com>
Message-Id: <20221228090312.17276-1-chenyi.qiang@intel.com>
Cc: qemu-stable@nongnu.org
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: David Hildenbrand <david@redhat.com>
(cherry picked from commit 29f1b328e3b767cba2661920a8470738469b9e36)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
 hw/virtio/virtio-mem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/virtio/virtio-mem.c b/hw/virtio/virtio-mem.c
index e19ee817fe..56db586c89 100644
--- a/hw/virtio/virtio-mem.c
+++ b/hw/virtio/virtio-mem.c
@@ -341,7 +341,7 @@ static int virtio_mem_notify_plug(VirtIOMEM *vmem, uint64_t offset,
     if (ret) {
         /* Notify all already-notified listeners. */
         QLIST_FOREACH(rdl2, &vmem->rdl_list, next) {
-            MemoryRegionSection tmp = *rdl->section;
+            MemoryRegionSection tmp = *rdl2->section;
 
             if (rdl2 == rdl) {
                 break;
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH 05/47] target/arm: fix handling of HLT semihosting in system mode
  2023-03-08 16:57 [RFC PATCH 00/47] Patch Round-up for stable 7.2.1 Michael Tokarev
                   ` (3 preceding siblings ...)
  2023-03-08 16:57 ` [PATCH 04/47] virtio-mem: Fix the iterator variable in a vmem->rdl_list loop Michael Tokarev
@ 2023-03-08 16:57 ` Michael Tokarev
  2023-03-08 16:57 ` [PATCH 06/47] meson: accept relative symlinks in "meson introspect --installed" data Michael Tokarev
                   ` (42 subsequent siblings)
  47 siblings, 0 replies; 50+ messages in thread
From: Michael Tokarev @ 2023-03-08 16:57 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-stable, Alex Bennée, Peter Maydell, Michael Tokarev

From: Alex Bennée <alex.bennee@linaro.org>

The check semihosting_enabled() wants to know if the guest is
currently in user mode. Unlike the other cases the test was inverted
causing us to block semihosting calls in non-EL0 modes.

Cc: qemu-stable@nongnu.org
Fixes: 19b26317e9 (target/arm: Honour -semihosting-config userspace=on)
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
(cherry picked from commit 9788d4c007cbde7cda1b7a577b8b836335eb2b73)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
 target/arm/translate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/target/arm/translate.c b/target/arm/translate.c
index 74a903072f..1dcaefb8e7 100644
--- a/target/arm/translate.c
+++ b/target/arm/translate.c
@@ -1184,7 +1184,7 @@ static inline void gen_hlt(DisasContext *s, int imm)
      * semihosting, to provide some semblance of security
      * (and for consistency with our 32-bit semihosting).
      */
-    if (semihosting_enabled(s->current_el != 0) &&
+    if (semihosting_enabled(s->current_el == 0) &&
         (imm == (s->thumb ? 0x3c : 0xf000))) {
         gen_exception_internal_insn(s, EXCP_SEMIHOST);
         return;
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH 06/47] meson: accept relative symlinks in "meson introspect --installed" data
  2023-03-08 16:57 [RFC PATCH 00/47] Patch Round-up for stable 7.2.1 Michael Tokarev
                   ` (4 preceding siblings ...)
  2023-03-08 16:57 ` [PATCH 05/47] target/arm: fix handling of HLT semihosting in system mode Michael Tokarev
@ 2023-03-08 16:57 ` Michael Tokarev
  2023-03-08 16:57 ` [PATCH 07/47] target/riscv: Set pc_succ_insn for !rvc illegal insn Michael Tokarev
                   ` (41 subsequent siblings)
  47 siblings, 0 replies; 50+ messages in thread
From: Michael Tokarev @ 2023-03-08 16:57 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-stable, Paolo Bonzini, Michael Tokarev

From: Paolo Bonzini <pbonzini@redhat.com>

When installing shared libraries, as is the case for libvfio-user.so,
Meson will include relative symbolic links in the output of
"meson introspect --installed":

  {
    "libvfio-user.so": "/usr/local/lib64/libvfio-user.so",
    ...
  }

In the case of scripts/symlink-install-tree.py, this will
be a symbolic link to a symbolic link but, in any case, there is
no issue in creating it.

Cc: qemu-stable@nongnu.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
(cherry picked from commit f32eb0021a85efaca97f69b0e9201737562a8e4f)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
 scripts/symlink-install-tree.py | 1 -
 1 file changed, 1 deletion(-)

diff --git a/scripts/symlink-install-tree.py b/scripts/symlink-install-tree.py
index a5bf0b0d6d..67cb86dd52 100644
--- a/scripts/symlink-install-tree.py
+++ b/scripts/symlink-install-tree.py
@@ -17,7 +17,6 @@ def destdir_join(d1: str, d2: str) -> str:
 out = subprocess.run([*introspect.split(' '), '--installed'],
                      stdout=subprocess.PIPE, check=True).stdout
 for source, dest in json.loads(out).items():
-    assert os.path.isabs(source)
     bundle_dest = destdir_join('qemu-bundle', dest)
     path = os.path.dirname(bundle_dest)
     try:
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH 07/47] target/riscv: Set pc_succ_insn for !rvc illegal insn
  2023-03-08 16:57 [RFC PATCH 00/47] Patch Round-up for stable 7.2.1 Michael Tokarev
                   ` (5 preceding siblings ...)
  2023-03-08 16:57 ` [PATCH 06/47] meson: accept relative symlinks in "meson introspect --installed" data Michael Tokarev
@ 2023-03-08 16:57 ` Michael Tokarev
  2023-03-08 16:57 ` [PATCH 08/47] acpi: cpuhp: fix guest-visible maximum access size to the legacy reg block Michael Tokarev
                   ` (40 subsequent siblings)
  47 siblings, 0 replies; 50+ messages in thread
From: Michael Tokarev @ 2023-03-08 16:57 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-stable, Richard Henderson, Alistair Francis,
	Philippe Mathieu-Daudé, Michael Tokarev

From: Richard Henderson <richard.henderson@linaro.org>

Failure to set pc_succ_insn may result in a TB covering zero bytes,
which triggers an assert within the code generator.

Cc: qemu-stable@nongnu.org
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1224
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-Id: <20221203175744.151365-1-richard.henderson@linaro.org>
[ Changes by AF:
 - Add missing run-plugin-test-noc-% line
]
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
(cherry picked from commit ec2918b467228e7634f1dd5f35033ad3021b6ef7)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
 target/riscv/translate.c          | 12 ++++--------
 tests/tcg/Makefile.target         |  2 ++
 tests/tcg/riscv64/Makefile.target |  6 ++++++
 tests/tcg/riscv64/test-noc.S      | 32 +++++++++++++++++++++++++++++++
 4 files changed, 44 insertions(+), 8 deletions(-)
 create mode 100644 tests/tcg/riscv64/test-noc.S

diff --git a/target/riscv/translate.c b/target/riscv/translate.c
index db123da5ec..1ed4bb5ec3 100644
--- a/target/riscv/translate.c
+++ b/target/riscv/translate.c
@@ -1064,14 +1064,10 @@ static void decode_opc(CPURISCVState *env, DisasContext *ctx, uint16_t opcode)
 
     /* Check for compressed insn */
     if (insn_len(opcode) == 2) {
-        if (!has_ext(ctx, RVC)) {
-            gen_exception_illegal(ctx);
-        } else {
-            ctx->opcode = opcode;
-            ctx->pc_succ_insn = ctx->base.pc_next + 2;
-            if (decode_insn16(ctx, opcode)) {
-                return;
-            }
+        ctx->opcode = opcode;
+        ctx->pc_succ_insn = ctx->base.pc_next + 2;
+        if (has_ext(ctx, RVC) && decode_insn16(ctx, opcode)) {
+            return;
         }
     } else {
         uint32_t opcode32 = opcode;
diff --git a/tests/tcg/Makefile.target b/tests/tcg/Makefile.target
index 75257f2b29..14bc013181 100644
--- a/tests/tcg/Makefile.target
+++ b/tests/tcg/Makefile.target
@@ -117,6 +117,8 @@ endif
 
 %: %.c
 	$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS)
+%: %.S
+	$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS)
 else
 # For softmmu targets we include a different Makefile fragement as the
 # build options for bare programs are usually pretty different. They
diff --git a/tests/tcg/riscv64/Makefile.target b/tests/tcg/riscv64/Makefile.target
index b5b89dfb0e..cc3ed65ffd 100644
--- a/tests/tcg/riscv64/Makefile.target
+++ b/tests/tcg/riscv64/Makefile.target
@@ -4,3 +4,9 @@
 VPATH += $(SRC_PATH)/tests/tcg/riscv64
 TESTS += test-div
 TESTS += noexec
+
+# Disable compressed instructions for test-noc
+TESTS += test-noc
+test-noc: LDFLAGS = -nostdlib -static
+run-test-noc: QEMU_OPTS += -cpu rv64,c=false
+run-plugin-test-noc-%: QEMU_OPTS += -cpu rv64,c=false
diff --git a/tests/tcg/riscv64/test-noc.S b/tests/tcg/riscv64/test-noc.S
new file mode 100644
index 0000000000..e29d60c8b3
--- /dev/null
+++ b/tests/tcg/riscv64/test-noc.S
@@ -0,0 +1,32 @@
+#include <asm/unistd.h>
+
+	.text
+	.globl _start
+_start:
+	.option	norvc
+	li	a0, 4		/* SIGILL */
+	la	a1, sa
+	li	a2, 0
+	li	a3, 8
+	li	a7, __NR_rt_sigaction
+	scall
+
+	.option	rvc
+	li	a0, 1
+	j	exit
+	.option	norvc
+
+pass:
+	li	a0, 0
+exit:
+	li	a7, __NR_exit
+	scall
+
+	.data
+	/* struct kernel_sigaction sa = { .sa_handler = pass }; */
+	.type	sa, @object
+	.size	sa, 32
+sa:
+	.dword	pass
+	.zero	24
+
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH 08/47] acpi: cpuhp: fix guest-visible maximum access size to the legacy reg block
  2023-03-08 16:57 [RFC PATCH 00/47] Patch Round-up for stable 7.2.1 Michael Tokarev
                   ` (6 preceding siblings ...)
  2023-03-08 16:57 ` [PATCH 07/47] target/riscv: Set pc_succ_insn for !rvc illegal insn Michael Tokarev
@ 2023-03-08 16:57 ` Michael Tokarev
  2023-03-08 16:57 ` [PATCH 09/47] hw/nvme: fix missing endian conversions for doorbell buffers Michael Tokarev
                   ` (39 subsequent siblings)
  47 siblings, 0 replies; 50+ messages in thread
From: Michael Tokarev @ 2023-03-08 16:57 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-stable, Laszlo Ersek, Michael S. Tsirkin, Ani Sinha,
	Ard Biesheuvel, Igor Mammedov, Paolo Bonzini, Peter Maydell,
	Philippe Mathieu-Daudé, Michael Tokarev

From: Laszlo Ersek <lersek@redhat.com>

The modern ACPI CPU hotplug interface was introduced in the following
series (aa1dd39ca307..679dd1a957df), released in v2.7.0:

  1  abd49bc2ed2f docs: update ACPI CPU hotplug spec with new protocol
  2  16bcab97eb9f pc: piix4/ich9: add 'cpu-hotplug-legacy' property
  3  5e1b5d93887b acpi: cpuhp: add CPU devices AML with _STA method
  4  ac35f13ba8f8 pc: acpi: introduce AcpiDeviceIfClass.madt_cpu hook
  5  d2238cb6781d acpi: cpuhp: implement hot-add parts of CPU hotplug
                  interface
  6  8872c25a26cc acpi: cpuhp: implement hot-remove parts of CPU hotplug
                  interface
  7  76623d00ae57 acpi: cpuhp: add cpu._OST handling
  8  679dd1a957df pc: use new CPU hotplug interface since 2.7 machine type

Before patch#1, "docs/specs/acpi_cpu_hotplug.txt" only specified 1-byte
accesses for the hotplug register block.  Patch#1 preserved the same
restriction for the legacy register block, but:

- it specified DWORD accesses for some of the modern registers,

- in particular, the switch from the legacy block to the modern block
  would require a DWORD write to the *legacy* block.

The latter functionality was then implemented in cpu_status_write()
[hw/acpi/cpu_hotplug.c], in patch#8.

Unfortunately, all DWORD accesses depended on a dormant bug: the one
introduced in earlier commit a014ed07bd5a ("memory: accept mismatching
sizes in memory_region_access_valid", 2013-05-29); first released in
v1.6.0.  Due to commit a014ed07bd5a, the DWORD accesses to the *legacy*
CPU hotplug register block would work in spite of the above series *not*
relaxing "valid.max_access_size = 1" in "hw/acpi/cpu_hotplug.c":

> static const MemoryRegionOps AcpiCpuHotplug_ops = {
>     .read = cpu_status_read,
>     .write = cpu_status_write,
>     .endianness = DEVICE_LITTLE_ENDIAN,
>     .valid = {
>         .min_access_size = 1,
>         .max_access_size = 1,
>     },
> };

Later, in commits e6d0c3ce6895 ("acpi: cpuhp: introduce 'Command data 2'
field", 2020-01-22) and ae340aa3d256 ("acpi: cpuhp: spec: add typical
usecases", 2020-01-22), first released in v5.0.0, the modern CPU hotplug
interface (including the documentation) was extended with another DWORD
*read* access, namely to the "Command data 2" register, which would be
important for the guest to confirm whether it managed to switch the
register block from legacy to modern.

This functionality too silently depended on the bug from commit
a014ed07bd5a.

In commit 5d971f9e6725 ('memory: Revert "memory: accept mismatching sizes
in memory_region_access_valid"', 2020-06-26), first released in v5.1.0,
the bug from commit a014ed07bd5a was fixed (the commit was reverted).
That swiftly exposed the bug in "AcpiCpuHotplug_ops", still present from
the v2.7.0 series quoted at the top -- namely the fact that
"valid.max_access_size = 1" didn't match what the guest was supposed to
do, according to the spec ("docs/specs/acpi_cpu_hotplug.txt").

The symptom is that the "modern interface negotiation protocol"
described in commit ae340aa3d256:

> +      Use following steps to detect and enable modern CPU hotplug interface:
> +        1. Store 0x0 to the 'CPU selector' register,
> +           attempting to switch to modern mode
> +        2. Store 0x0 to the 'CPU selector' register,
> +           to ensure valid selector value
> +        3. Store 0x0 to the 'Command field' register,
> +        4. Read the 'Command data 2' register.
> +           If read value is 0x0, the modern interface is enabled.
> +           Otherwise legacy or no CPU hotplug interface available

falls apart for the guest: steps 1 and 2 are lost, because they are DWORD
writes; so no switching happens.  Step 3 (a single-byte write) is not
lost, but it has no effect; see the condition in cpu_status_write() in
patch#8.  And step 4 *misleads* the guest into thinking that the switch
worked: the DWORD read is lost again -- it returns zero to the guest
without ever reaching the device model, so the guest never learns the
switch didn't work.

This means that guest behavior centered on the "Command data 2" register
worked *only* in the v5.0.0 release; it got effectively regressed in
v5.1.0.

To make things *even more* complicated, the breakage was (and remains, as
of today) visible with TCG acceleration only.  Commit 5d971f9e6725 makes
no difference with KVM acceleration -- the DWORD accesses still work,
despite "valid.max_access_size = 1".

As commit 5d971f9e6725 suggests, fix the problem by raising
"valid.max_access_size" to 4 -- the spec now clearly instructs the guest
to perform DWORD accesses to the legacy register block too, for enabling
(and verifying!) the modern block.  In order to keep compatibility for the
device model implementation though, set "impl.max_access_size = 1", so
that wide accesses be split before they reach the legacy read/write
handlers, like they always have been on KVM, and like they were on TCG
before 5d971f9e6725 (v5.1.0).

Tested with:

- OVMF IA32 + qemu-system-i386, CPU hotplug/hot-unplug with SMM,
  intermixed with ACPI S3 suspend/resume, using KVM accel
  (regression-test);

- OVMF IA32X64 + qemu-system-x86_64, CPU hotplug/hot-unplug with SMM,
  intermixed with ACPI S3 suspend/resume, using KVM accel
  (regression-test);

- OVMF IA32 + qemu-system-i386, SMM enabled, using TCG accel; verified the
  register block switch and the present/possible CPU counting through the
  modern hotplug interface, during OVMF boot (bugfix test);

- I do not have any testcase (guest payload) for regression-testing CPU
  hotplug through the *legacy* CPU hotplug register block.

Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Ani Sinha <ani@anisinha.ca>
Cc: Ard Biesheuvel <ardb@kernel.org>
Cc: Igor Mammedov <imammedo@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Peter Maydell <peter.maydell@linaro.org>
Cc: Philippe Mathieu-Daudé <philmd@linaro.org>
Cc: qemu-stable@nongnu.org
Ref: "IO port write width clamping differs between TCG and KVM"
Link: http://mid.mail-archive.com/aaedee84-d3ed-a4f9-21e7-d221a28d1683@redhat.com
Link: https://lists.gnu.org/archive/html/qemu-devel/2023-01/msg00199.html
Reported-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Tested-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Tested-by: Igor Mammedov <imammedo@redhat.com>
Message-Id: <20230105161804.82486-1-lersek@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit dab30fbef3896bb652a09d46c37d3f55657cbcbb)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
 hw/acpi/cpu_hotplug.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/hw/acpi/cpu_hotplug.c b/hw/acpi/cpu_hotplug.c
index 53654f8638..ff14c3f410 100644
--- a/hw/acpi/cpu_hotplug.c
+++ b/hw/acpi/cpu_hotplug.c
@@ -52,6 +52,9 @@ static const MemoryRegionOps AcpiCpuHotplug_ops = {
     .endianness = DEVICE_LITTLE_ENDIAN,
     .valid = {
         .min_access_size = 1,
+        .max_access_size = 4,
+    },
+    .impl = {
         .max_access_size = 1,
     },
 };
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH 09/47] hw/nvme: fix missing endian conversions for doorbell buffers
  2023-03-08 16:57 [RFC PATCH 00/47] Patch Round-up for stable 7.2.1 Michael Tokarev
                   ` (7 preceding siblings ...)
  2023-03-08 16:57 ` [PATCH 08/47] acpi: cpuhp: fix guest-visible maximum access size to the legacy reg block Michael Tokarev
@ 2023-03-08 16:57 ` Michael Tokarev
  2023-03-08 16:57 ` [PATCH 10/47] hw/nvme: fix missing cq eventidx update Michael Tokarev
                   ` (38 subsequent siblings)
  47 siblings, 0 replies; 50+ messages in thread
From: Michael Tokarev @ 2023-03-08 16:57 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-stable, Klaus Jensen, Guenter Roeck, Keith Busch,
	Michael Tokarev

From: Klaus Jensen <k.jensen@samsung.com>

The eventidx and doorbell value are not handling endianness correctly.
Fix this.

Fixes: 3f7fe8de3d49 ("hw/nvme: Implement shadow doorbell buffer support")
Cc: qemu-stable@nongnu.org
Reported-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Keith Busch <kbusch@kernel.org>
Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
(cherry picked from commit 2fda0726e5149e032acfa5fe442db56cd6433c4c)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Conflicts: hw/nvme/ctrl.c
---
 hw/nvme/ctrl.c | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c
index ac3885ce50..83f5e58e8d 100644
--- a/hw/nvme/ctrl.c
+++ b/hw/nvme/ctrl.c
@@ -1333,8 +1333,12 @@ static inline void nvme_blk_write(BlockBackend *blk, int64_t offset,
 
 static void nvme_update_cq_head(NvmeCQueue *cq)
 {
-    pci_dma_read(&cq->ctrl->parent_obj, cq->db_addr, &cq->head,
-            sizeof(cq->head));
+    uint32_t v;
+
+    pci_dma_read(&cq->ctrl->parent_obj, cq->db_addr, &v, sizeof(v));
+
+    cq->head = le32_to_cpu(v);
+
     trace_pci_nvme_shadow_doorbell_cq(cq->cqid, cq->head);
 }
 
@@ -6221,15 +6225,21 @@ static uint16_t nvme_admin_cmd(NvmeCtrl *n, NvmeRequest *req)
 
 static void nvme_update_sq_eventidx(const NvmeSQueue *sq)
 {
-    pci_dma_write(&sq->ctrl->parent_obj, sq->ei_addr, &sq->tail,
-                  sizeof(sq->tail));
+    uint32_t v = cpu_to_le32(sq->tail);
+
+    pci_dma_write(&sq->ctrl->parent_obj, sq->ei_addr, &v, sizeof(v));
+
     trace_pci_nvme_eventidx_sq(sq->sqid, sq->tail);
 }
 
 static void nvme_update_sq_tail(NvmeSQueue *sq)
 {
-    pci_dma_read(&sq->ctrl->parent_obj, sq->db_addr, &sq->tail,
-                 sizeof(sq->tail));
+    uint32_t v;
+
+    pci_dma_read(&sq->ctrl->parent_obj, sq->db_addr, &v, sizeof(v));
+
+    sq->tail = le32_to_cpu(v);
+
     trace_pci_nvme_shadow_doorbell_sq(sq->sqid, sq->tail);
 }
 
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH 10/47] hw/nvme: fix missing cq eventidx update
  2023-03-08 16:57 [RFC PATCH 00/47] Patch Round-up for stable 7.2.1 Michael Tokarev
                   ` (8 preceding siblings ...)
  2023-03-08 16:57 ` [PATCH 09/47] hw/nvme: fix missing endian conversions for doorbell buffers Michael Tokarev
@ 2023-03-08 16:57 ` Michael Tokarev
  2023-03-08 16:57 ` [PATCH 11/47] configure: fix GLIB_VERSION for cross-compilation Michael Tokarev
                   ` (37 subsequent siblings)
  47 siblings, 0 replies; 50+ messages in thread
From: Michael Tokarev @ 2023-03-08 16:57 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-stable, Klaus Jensen, qemu-riscv, Guenter Roeck, Keith Busch,
	Michael Tokarev

From: Klaus Jensen <k.jensen@samsung.com>

Prior to reading the shadow doorbell cq head, we have to update the
eventidx. Otherwise, we risk that the driver will skip an mmio doorbell
write. This happens on riscv64, as reported by Guenter.

Adding the missing update to the cq eventidx fixes the issue.

Fixes: 3f7fe8de3d49 ("hw/nvme: Implement shadow doorbell buffer support")
Cc: qemu-stable@nongnu.org
Cc: qemu-riscv@nongnu.org
Reported-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Keith Busch <kbusch@kernel.org>
Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
(cherry picked from commit fa5db2aa168bdc0f15c269b6212ef47632fab8ba)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
 hw/nvme/ctrl.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c
index 83f5e58e8d..366b973a9e 100644
--- a/hw/nvme/ctrl.c
+++ b/hw/nvme/ctrl.c
@@ -1331,6 +1331,15 @@ static inline void nvme_blk_write(BlockBackend *blk, int64_t offset,
     }
 }
 
+static void nvme_update_cq_eventidx(const NvmeCQueue *cq)
+{
+    uint32_t v = cpu_to_le32(cq->head);
+
+    //not in 7.2: trace_pci_nvme_update_cq_eventidx(cq->cqid, cq->head);
+
+    pci_dma_write(PCI_DEVICE(cq->ctrl), cq->ei_addr, &v, sizeof(v));
+}
+
 static void nvme_update_cq_head(NvmeCQueue *cq)
 {
     uint32_t v;
@@ -1355,6 +1364,7 @@ static void nvme_post_cqes(void *opaque)
         hwaddr addr;
 
         if (n->dbbuf_enabled) {
+            nvme_update_cq_eventidx(cq);
             nvme_update_cq_head(cq);
         }
 
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH 11/47] configure: fix GLIB_VERSION for cross-compilation
  2023-03-08 16:57 [RFC PATCH 00/47] Patch Round-up for stable 7.2.1 Michael Tokarev
                   ` (9 preceding siblings ...)
  2023-03-08 16:57 ` [PATCH 10/47] hw/nvme: fix missing cq eventidx update Michael Tokarev
@ 2023-03-08 16:57 ` Michael Tokarev
  2023-03-08 16:57 ` [PATCH 12/47] target/arm: Fix sve_probe_page Michael Tokarev
                   ` (36 subsequent siblings)
  47 siblings, 0 replies; 50+ messages in thread
From: Michael Tokarev @ 2023-03-08 16:57 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-stable, Paolo Bonzini,
	Валентин,
	Michael Tokarev

From: Paolo Bonzini <pbonzini@redhat.com>

configure uses "pkg-config" directly so that GLIB_VERSION is always based
on host glib version.   To correctly handle cross-compilation it should use
"$pkg_config" and take GLIB_VERSION from the cross-compiled glib.

Reported-by: Валентин <val15032008@mail.ru>
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1414
Cc: qemu-stable@nongnu.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
(cherry picked from commit acedc9a660f83b362a1dec4b699e85d5dd82a067)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
 configure | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure b/configure
index 26c7bc5154..5f1828f1ec 100755
--- a/configure
+++ b/configure
@@ -2416,7 +2416,7 @@ echo "QEMU_OBJCFLAGS=$QEMU_OBJCFLAGS" >> $config_host_mak
 echo "GLIB_CFLAGS=$glib_cflags" >> $config_host_mak
 echo "GLIB_LIBS=$glib_libs" >> $config_host_mak
 echo "GLIB_BINDIR=$glib_bindir" >> $config_host_mak
-echo "GLIB_VERSION=$(pkg-config --modversion glib-2.0)" >> $config_host_mak
+echo "GLIB_VERSION=$($pkg_config --modversion glib-2.0)" >> $config_host_mak
 echo "QEMU_LDFLAGS=$QEMU_LDFLAGS" >> $config_host_mak
 echo "EXESUF=$EXESUF" >> $config_host_mak
 
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH 12/47] target/arm: Fix sve_probe_page
  2023-03-08 16:57 [RFC PATCH 00/47] Patch Round-up for stable 7.2.1 Michael Tokarev
                   ` (10 preceding siblings ...)
  2023-03-08 16:57 ` [PATCH 11/47] configure: fix GLIB_VERSION for cross-compilation Michael Tokarev
@ 2023-03-08 16:57 ` Michael Tokarev
  2023-03-08 16:57 ` [PATCH 13/47] target/arm: allow writes to SCR_EL3.HXEn bit when FEAT_HCX is enabled Michael Tokarev
                   ` (35 subsequent siblings)
  47 siblings, 0 replies; 50+ messages in thread
From: Michael Tokarev @ 2023-03-08 16:57 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-stable, Richard Henderson, Philippe Mathieu-Daudé,
	Peter Maydell, Michael Tokarev

From: Richard Henderson <richard.henderson@linaro.org>

Don't dereference CPUTLBEntryFull until we verify that
the page is valid.  Move the other user-only info field
updates after the valid check to match.

Cc: qemu-stable@nongnu.org
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1412
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-id: 20230104190056.305143-1-richard.henderson@linaro.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
(cherry picked from commit ce848378b999214777fa984a8a0a3e3deb1cf687)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
 target/arm/sve_helper.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c
index 1afeadf9c8..521fc9b969 100644
--- a/target/arm/sve_helper.c
+++ b/target/arm/sve_helper.c
@@ -5354,15 +5354,10 @@ bool sve_probe_page(SVEHostPage *info, bool nofault, CPUARMState *env,
 #ifdef CONFIG_USER_ONLY
     flags = probe_access_flags(env, addr, access_type, mmu_idx, nofault,
                                &info->host, retaddr);
-    memset(&info->attrs, 0, sizeof(info->attrs));
-    /* Require both ANON and MTE; see allocation_tag_mem(). */
-    info->tagged = (flags & PAGE_ANON) && (flags & PAGE_MTE);
 #else
     CPUTLBEntryFull *full;
     flags = probe_access_full(env, addr, access_type, mmu_idx, nofault,
                               &info->host, &full, retaddr);
-    info->attrs = full->attrs;
-    info->tagged = full->pte_attrs == 0xf0;
 #endif
     info->flags = flags;
 
@@ -5371,6 +5366,15 @@ bool sve_probe_page(SVEHostPage *info, bool nofault, CPUARMState *env,
         return false;
     }
 
+#ifdef CONFIG_USER_ONLY
+    memset(&info->attrs, 0, sizeof(info->attrs));
+    /* Require both ANON and MTE; see allocation_tag_mem(). */
+    info->tagged = (flags & PAGE_ANON) && (flags & PAGE_MTE);
+#else
+    info->attrs = full->attrs;
+    info->tagged = full->pte_attrs == 0xf0;
+#endif
+
     /* Ensure that info->host[] is relative to addr, not addr + mem_off. */
     info->host -= mem_off;
     return true;
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH 13/47] target/arm: allow writes to SCR_EL3.HXEn bit when FEAT_HCX is enabled
  2023-03-08 16:57 [RFC PATCH 00/47] Patch Round-up for stable 7.2.1 Michael Tokarev
                   ` (11 preceding siblings ...)
  2023-03-08 16:57 ` [PATCH 12/47] target/arm: Fix sve_probe_page Michael Tokarev
@ 2023-03-08 16:57 ` Michael Tokarev
  2023-03-08 16:57 ` [PATCH 14/47] target/arm: Fix in_debug path in S1_ptw_translate Michael Tokarev
                   ` (34 subsequent siblings)
  47 siblings, 0 replies; 50+ messages in thread
From: Michael Tokarev @ 2023-03-08 16:57 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-stable, Evgeny Iakovlev, Peter Maydell, Michael Tokarev

From: Evgeny Iakovlev <eiakovlev@linux.microsoft.com>

ARM trusted firmware, when built with FEAT_HCX support, sets SCR_EL3.HXEn bit
to allow EL2 to modify HCRX_EL2 register without trapping it in EL3. Qemu
uses a valid mask to clear unsupported SCR_EL3 bits when emulating SCR_EL3
write, and that mask doesn't include SCR_EL3.HXEn bit even if FEAT_HCX is
enabled and exposed to the guest. As a result EL3 writes of that bit are
ignored.

Cc: qemu-stable@nongnu.org
Signed-off-by: Evgeny Iakovlev <eiakovlev@linux.microsoft.com>
Message-id: 20230105221251.17896-4-eiakovlev@linux.microsoft.com
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
(cherry picked from commit 08899b5c68a55a3780d707e2464073c8f2670d31)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
 target/arm/helper.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/target/arm/helper.c b/target/arm/helper.c
index d8c8223ec3..22bc935242 100644
--- a/target/arm/helper.c
+++ b/target/arm/helper.c
@@ -1820,6 +1820,9 @@ static void scr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value)
         if (cpu_isar_feature(aa64_sme, cpu)) {
             valid_mask |= SCR_ENTP2;
         }
+        if (cpu_isar_feature(aa64_hcx, cpu)) {
+            valid_mask |= SCR_HXEN;
+        }
     } else {
         valid_mask &= ~(SCR_RW | SCR_ST);
         if (cpu_isar_feature(aa32_ras, cpu)) {
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH 14/47] target/arm: Fix in_debug path in S1_ptw_translate
  2023-03-08 16:57 [RFC PATCH 00/47] Patch Round-up for stable 7.2.1 Michael Tokarev
                   ` (12 preceding siblings ...)
  2023-03-08 16:57 ` [PATCH 13/47] target/arm: allow writes to SCR_EL3.HXEn bit when FEAT_HCX is enabled Michael Tokarev
@ 2023-03-08 16:57 ` Michael Tokarev
  2023-03-08 16:57 ` [PATCH 15/47] target/arm: Fix physical address resolution for Stage2 Michael Tokarev
                   ` (33 subsequent siblings)
  47 siblings, 0 replies; 50+ messages in thread
From: Michael Tokarev @ 2023-03-08 16:57 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-stable, Richard Henderson, Peter Maydell, Michael Tokarev

From: Richard Henderson <richard.henderson@linaro.org>

During the conversion, the test against get_phys_addr_lpae got inverted,
meaning that successful translations went to the 'failed' label.

Cc: qemu-stable@nongnu.org
Fixes: f3639a64f60 ("target/arm: Use softmmu tlbs for page table walking")
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1417
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20230114054605.2977022-1-richard.henderson@linaro.org
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
(cherry picked from commit 4a1103afb16efa64600ef0c2b03afe60f689fdc9)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
 target/arm/ptw.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/target/arm/ptw.c b/target/arm/ptw.c
index f812734bfb..bb22271a1d 100644
--- a/target/arm/ptw.c
+++ b/target/arm/ptw.c
@@ -238,8 +238,8 @@ static bool S1_ptw_translate(CPUARMState *env, S1Translate *ptw,
             };
             GetPhysAddrResult s2 = { };
 
-            if (!get_phys_addr_lpae(env, &s2ptw, addr, MMU_DATA_LOAD,
-                                    false, &s2, fi)) {
+            if (get_phys_addr_lpae(env, &s2ptw, addr, MMU_DATA_LOAD,
+                                   false, &s2, fi)) {
                 goto fail;
             }
             ptw->out_phys = s2.f.phys_addr;
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH 15/47] target/arm: Fix physical address resolution for Stage2
  2023-03-08 16:57 [RFC PATCH 00/47] Patch Round-up for stable 7.2.1 Michael Tokarev
                   ` (13 preceding siblings ...)
  2023-03-08 16:57 ` [PATCH 14/47] target/arm: Fix in_debug path in S1_ptw_translate Michael Tokarev
@ 2023-03-08 16:57 ` Michael Tokarev
  2023-03-08 16:57 ` [PATCH 16/47] migration/ram: Fix error handling in ram_write_tracking_start() Michael Tokarev
                   ` (32 subsequent siblings)
  47 siblings, 0 replies; 50+ messages in thread
From: Michael Tokarev @ 2023-03-08 16:57 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-stable, Richard Henderson, Sid Manning,
	Philippe Mathieu-Daudé, Peter Maydell, Michael Tokarev

From: Richard Henderson <richard.henderson@linaro.org>

Conversion to probe_access_full missed applying the page offset.

Cc: qemu-stable@nongnu.org
Reported-by: Sid Manning <sidneym@quicinc.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-id: 20230126233134.103193-1-richard.henderson@linaro.org
Fixes: f3639a64f602 ("target/arm: Use softmmu tlbs for page table walking")
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
(cherry picked from commit 9d2617ac7d3139d870ba14204aedd74395990192)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
 target/arm/ptw.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/target/arm/ptw.c b/target/arm/ptw.c
index bb22271a1d..0b16068557 100644
--- a/target/arm/ptw.c
+++ b/target/arm/ptw.c
@@ -266,7 +266,7 @@ static bool S1_ptw_translate(CPUARMState *env, S1Translate *ptw,
         if (unlikely(flags & TLB_INVALID_MASK)) {
             goto fail;
         }
-        ptw->out_phys = full->phys_addr;
+        ptw->out_phys = full->phys_addr | (addr & ~TARGET_PAGE_MASK);
         ptw->out_rw = full->prot & PAGE_WRITE;
         pte_attrs = full->pte_attrs;
         pte_secure = full->attrs.secure;
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH 16/47] migration/ram: Fix error handling in ram_write_tracking_start()
  2023-03-08 16:57 [RFC PATCH 00/47] Patch Round-up for stable 7.2.1 Michael Tokarev
                   ` (14 preceding siblings ...)
  2023-03-08 16:57 ` [PATCH 15/47] target/arm: Fix physical address resolution for Stage2 Michael Tokarev
@ 2023-03-08 16:57 ` Michael Tokarev
  2023-03-08 16:57 ` [PATCH 17/47] migration/ram: Fix populate_read_range() Michael Tokarev
                   ` (31 subsequent siblings)
  47 siblings, 0 replies; 50+ messages in thread
From: Michael Tokarev @ 2023-03-08 16:57 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-stable, David Hildenbrand, Peter Xu, Juan Quintela,
	Michael Tokarev

From: David Hildenbrand <david@redhat.com>

If something goes wrong during uffd_change_protection(), we would miss
to unregister uffd-wp and not release our reference. Fix it by
performing the uffd_change_protection(true) last.

Note that a uffd_change_protection(false) on the recovery path without a
prior uffd_change_protection(false) is fine.

Fixes: 278e2f551a09 ("migration: support UFFD write fault processing in ram_save_iterate()")
Cc: qemu-stable@nongnu.org
Reviewed-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
(cherry picked from commit 72ef3a370836aa07261ad7aaeea27ed5cbcee342)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
 migration/ram.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/migration/ram.c b/migration/ram.c
index 1338e47665..8062713c75 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -1885,13 +1885,14 @@ int ram_write_tracking_start(void)
                 block->max_length, UFFDIO_REGISTER_MODE_WP, NULL)) {
             goto fail;
         }
+        block->flags |= RAM_UF_WRITEPROTECT;
+        memory_region_ref(block->mr);
+
         /* Apply UFFD write protection to the block memory range */
         if (uffd_change_protection(rs->uffdio_fd, block->host,
                 block->max_length, true, false)) {
             goto fail;
         }
-        block->flags |= RAM_UF_WRITEPROTECT;
-        memory_region_ref(block->mr);
 
         trace_ram_write_tracking_ramblock_start(block->idstr, block->page_size,
                 block->host, block->max_length);
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH 17/47] migration/ram: Fix populate_read_range()
  2023-03-08 16:57 [RFC PATCH 00/47] Patch Round-up for stable 7.2.1 Michael Tokarev
                   ` (15 preceding siblings ...)
  2023-03-08 16:57 ` [PATCH 16/47] migration/ram: Fix error handling in ram_write_tracking_start() Michael Tokarev
@ 2023-03-08 16:57 ` Michael Tokarev
  2023-03-08 16:57 ` [PATCH 18/47] qcow2: Fix theoretical corruption in store_bitmap() error path Michael Tokarev
                   ` (30 subsequent siblings)
  47 siblings, 0 replies; 50+ messages in thread
From: Michael Tokarev @ 2023-03-08 16:57 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-stable, David Hildenbrand, Peter Xu, Juan Quintela,
	Michael Tokarev

From: David Hildenbrand <david@redhat.com>

Unfortunately, commit f7b9dcfbcf44 broke populate_read_range(): the loop
end condition is very wrong, resulting in that function not populating the
full range. Lets' fix that.

Fixes: f7b9dcfbcf44 ("migration/ram: Factor out populating pages readable in ram_block_populate_pages()")
Cc: qemu-stable@nongnu.org
Reviewed-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
(cherry picked from commit 5f19a4491941fdc5c5b50ce4ade6ffffe0f591b4)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
 migration/ram.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/migration/ram.c b/migration/ram.c
index 8062713c75..f25ebd9620 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -1765,13 +1765,15 @@ out:
 static inline void populate_read_range(RAMBlock *block, ram_addr_t offset,
                                        ram_addr_t size)
 {
+    const ram_addr_t end = offset + size;
+
     /*
      * We read one byte of each page; this will preallocate page tables if
      * required and populate the shared zeropage on MAP_PRIVATE anonymous memory
      * where no page was populated yet. This might require adaption when
      * supporting other mappings, like shmem.
      */
-    for (; offset < size; offset += block->page_size) {
+    for (; offset < end; offset += block->page_size) {
         char tmp = *((char *)block->host + offset);
 
         /* Don't optimize the read out */
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH 18/47] qcow2: Fix theoretical corruption in store_bitmap() error path
  2023-03-08 16:57 [RFC PATCH 00/47] Patch Round-up for stable 7.2.1 Michael Tokarev
                   ` (16 preceding siblings ...)
  2023-03-08 16:57 ` [PATCH 17/47] migration/ram: Fix populate_read_range() Michael Tokarev
@ 2023-03-08 16:57 ` Michael Tokarev
  2023-03-08 16:57 ` [PATCH 19/47] block: fix detect-zeroes= with BDRV_REQ_REGISTERED_BUF Michael Tokarev
                   ` (29 subsequent siblings)
  47 siblings, 0 replies; 50+ messages in thread
From: Michael Tokarev @ 2023-03-08 16:57 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-stable, Kevin Wolf, Hanna Czenczek,
	Philippe Mathieu-Daudé, Michael Tokarev

From: Kevin Wolf <kwolf@redhat.com>

In order to write the bitmap table to the image file, it is converted to
big endian. If the write fails, it is passed to clear_bitmap_table() to
free all of the clusters it had allocated before. However, if we don't
convert it back to native endianness first, we'll free things at a wrong
offset.

In practical terms, the offsets will be so high that we won't actually
free any allocated clusters, but just run into an error, but in theory
this can cause image corruption.

Cc: qemu-stable@nongnu.org
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Message-Id: <20230112191454.169353-2-kwolf@redhat.com>
Reviewed-by: Hanna Czenczek <hreitz@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
(cherry picked from commit b03dd9613bcf8fe948581b2b3585510cb525c382)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
 block/qcow2-bitmap.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/block/qcow2-bitmap.c b/block/qcow2-bitmap.c
index bcad567c0c..3dff99ba06 100644
--- a/block/qcow2-bitmap.c
+++ b/block/qcow2-bitmap.c
@@ -115,7 +115,7 @@ static int update_header_sync(BlockDriverState *bs)
     return bdrv_flush(bs->file->bs);
 }
 
-static inline void bitmap_table_to_be(uint64_t *bitmap_table, size_t size)
+static inline void bitmap_table_bswap_be(uint64_t *bitmap_table, size_t size)
 {
     size_t i;
 
@@ -1401,9 +1401,10 @@ static int store_bitmap(BlockDriverState *bs, Qcow2Bitmap *bm, Error **errp)
         goto fail;
     }
 
-    bitmap_table_to_be(tb, tb_size);
+    bitmap_table_bswap_be(tb, tb_size);
     ret = bdrv_pwrite(bs->file, tb_offset, tb_size * sizeof(tb[0]), tb, 0);
     if (ret < 0) {
+        bitmap_table_bswap_be(tb, tb_size);
         error_setg_errno(errp, -ret, "Failed to write bitmap '%s' to file",
                          bm_name);
         goto fail;
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH 19/47] block: fix detect-zeroes= with BDRV_REQ_REGISTERED_BUF
  2023-03-08 16:57 [RFC PATCH 00/47] Patch Round-up for stable 7.2.1 Michael Tokarev
                   ` (17 preceding siblings ...)
  2023-03-08 16:57 ` [PATCH 18/47] qcow2: Fix theoretical corruption in store_bitmap() error path Michael Tokarev
@ 2023-03-08 16:57 ` Michael Tokarev
  2023-03-08 16:57 ` [PATCH 20/47] tests/tcg/i386: Introduce and use reg_t consistently Michael Tokarev
                   ` (28 subsequent siblings)
  47 siblings, 0 replies; 50+ messages in thread
From: Michael Tokarev @ 2023-03-08 16:57 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-stable, Stefan Hajnoczi, Fiona Ebner, Eric Blake,
	Hanna Czenczek, Michael Tokarev

From: Stefan Hajnoczi <stefanha@redhat.com>

When a write request is converted into a write zeroes request by the
detect-zeroes= feature, it is no longer associated with an I/O buffer.
The BDRV_REQ_REGISTERED_BUF flag doesn't make sense without an I/O
buffer and must be cleared because bdrv_co_do_pwrite_zeroes() fails with
-EINVAL when it's set.

Fiona Ebner <f.ebner@proxmox.com> bisected and diagnosed this QEMU 7.2
regression where writes containing zeroes to a blockdev with
discard=unmap,detect-zeroes=unmap fail.

Buglink: https://gitlab.com/qemu-project/qemu/-/issues/1404
Fixes: e8b6535533be ("block: add BDRV_REQ_REGISTERED_BUF request flag")
Tested-by: Fiona Ebner <f.ebner@proxmox.com>
Cc: qemu-stable@nongnu.org
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Hanna Czenczek <hreitz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-Id: <20230207203719.242926-2-stefanha@redhat.com>
(cherry picked from commit 3c5867156eb81c7c71611d078b2c5c2c863f884a)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
 block/io.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/block/io.c b/block/io.c
index b9424024f9..bbaa0d1b2d 100644
--- a/block/io.c
+++ b/block/io.c
@@ -2087,6 +2087,9 @@ static int coroutine_fn bdrv_aligned_pwritev(BdrvChild *child,
         if (bs->detect_zeroes == BLOCKDEV_DETECT_ZEROES_OPTIONS_UNMAP) {
             flags |= BDRV_REQ_MAY_UNMAP;
         }
+
+        /* Can't use optimization hint with bufferless zero write */
+        flags &= ~BDRV_REQ_REGISTERED_BUF;
     }
 
     if (ret < 0) {
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH 20/47] tests/tcg/i386: Introduce and use reg_t consistently
  2023-03-08 16:57 [RFC PATCH 00/47] Patch Round-up for stable 7.2.1 Michael Tokarev
                   ` (18 preceding siblings ...)
  2023-03-08 16:57 ` [PATCH 19/47] block: fix detect-zeroes= with BDRV_REQ_REGISTERED_BUF Michael Tokarev
@ 2023-03-08 16:57 ` Michael Tokarev
  2023-03-08 16:57 ` [PATCH 21/47] target/i386: Fix BEXTR instruction Michael Tokarev
                   ` (27 subsequent siblings)
  47 siblings, 0 replies; 50+ messages in thread
From: Michael Tokarev @ 2023-03-08 16:57 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-stable, Richard Henderson, Philippe Mathieu-Daudé,
	Paolo Bonzini, Michael Tokarev

From: Richard Henderson <richard.henderson@linaro.org>

Define reg_t based on the actual register width.
Define the inlines using that type.  This will allow
input registers to 32-bit insns to be set to 64-bit
values on x86-64, which allows testing various edge cases.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-Id: <20230114230542.3116013-2-richard.henderson@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
(cherry picked from commit 5d62d6649cd367b5b4a3676e7514d2f9ca86cb03)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
 tests/tcg/i386/test-i386-bmi2.c | 182 ++++++++++++++++----------------
 1 file changed, 93 insertions(+), 89 deletions(-)

diff --git a/tests/tcg/i386/test-i386-bmi2.c b/tests/tcg/i386/test-i386-bmi2.c
index 5fadf47510..3c3ef85513 100644
--- a/tests/tcg/i386/test-i386-bmi2.c
+++ b/tests/tcg/i386/test-i386-bmi2.c
@@ -3,34 +3,40 @@
 #include <stdint.h>
 #include <stdio.h>
 
+#ifdef __x86_64
+typedef uint64_t reg_t;
+#else
+typedef uint32_t reg_t;
+#endif
+
 #define insn1q(name, arg0)                                                           \
-static inline uint64_t name##q(uint64_t arg0)                                        \
+static inline reg_t name##q(reg_t arg0)                                              \
 {                                                                                    \
-    uint64_t result64;                                                               \
+    reg_t result64;                                                                  \
     asm volatile (#name "q   %1, %0" : "=r"(result64) : "rm"(arg0));                 \
     return result64;                                                                 \
 }
 
 #define insn1l(name, arg0)                                                           \
-static inline uint32_t name##l(uint32_t arg0)                                        \
+static inline reg_t name##l(reg_t arg0)                                              \
 {                                                                                    \
-    uint32_t result32;                                                               \
+    reg_t result32;                                                                  \
     asm volatile (#name "l   %k1, %k0" : "=r"(result32) : "rm"(arg0));               \
     return result32;                                                                 \
 }
 
 #define insn2q(name, arg0, c0, arg1, c1)                                             \
-static inline uint64_t name##q(uint64_t arg0, uint64_t arg1)                         \
+static inline reg_t name##q(reg_t arg0, reg_t arg1)                                  \
 {                                                                                    \
-    uint64_t result64;                                                               \
+    reg_t result64;                                                                  \
     asm volatile (#name "q   %2, %1, %0" : "=r"(result64) : c0(arg0), c1(arg1));     \
     return result64;                                                                 \
 }
 
 #define insn2l(name, arg0, c0, arg1, c1)                                             \
-static inline uint32_t name##l(uint32_t arg0, uint32_t arg1)                         \
+static inline reg_t name##l(reg_t arg0, reg_t arg1)                                  \
 {                                                                                    \
-    uint32_t result32;                                                               \
+    reg_t result32;                                                                  \
     asm volatile (#name "l   %k2, %k1, %k0" : "=r"(result32) : c0(arg0), c1(arg1));  \
     return result32;                                                                 \
 }
@@ -65,130 +71,128 @@ insn1l(blsr, src)
 int main(int argc, char *argv[]) {
     uint64_t ehlo = 0x202020204f4c4845ull;
     uint64_t mask = 0xa080800302020001ull;
-    uint32_t result32;
+    reg_t result;
 
 #ifdef __x86_64
-    uint64_t result64;
-
     /* 64 bits */
-    result64 = andnq(mask, ehlo);
-    assert(result64 == 0x002020204d4c4844);
+    result = andnq(mask, ehlo);
+    assert(result == 0x002020204d4c4844);
 
-    result64 = pextq(ehlo, mask);
-    assert(result64 == 133);
+    result = pextq(ehlo, mask);
+    assert(result == 133);
 
-    result64 = pdepq(result64, mask);
-    assert(result64 == (ehlo & mask));
+    result = pdepq(result, mask);
+    assert(result == (ehlo & mask));
 
-    result64 = pextq(-1ull, mask);
-    assert(result64 == 511); /* mask has 9 bits set */
+    result = pextq(-1ull, mask);
+    assert(result == 511); /* mask has 9 bits set */
 
-    result64 = pdepq(-1ull, mask);
-    assert(result64 == mask);
+    result = pdepq(-1ull, mask);
+    assert(result == mask);
 
-    result64 = bextrq(mask, 0x3f00);
-    assert(result64 == (mask & ~INT64_MIN));
+    result = bextrq(mask, 0x3f00);
+    assert(result == (mask & ~INT64_MIN));
 
-    result64 = bextrq(mask, 0x1038);
-    assert(result64 == 0xa0);
+    result = bextrq(mask, 0x1038);
+    assert(result == 0xa0);
 
-    result64 = bextrq(mask, 0x10f8);
-    assert(result64 == 0);
+    result = bextrq(mask, 0x10f8);
+    assert(result == 0);
 
-    result64 = blsiq(0x30);
-    assert(result64 == 0x10);
+    result = blsiq(0x30);
+    assert(result == 0x10);
 
-    result64 = blsiq(0x30ull << 32);
-    assert(result64 == 0x10ull << 32);
+    result = blsiq(0x30ull << 32);
+    assert(result == 0x10ull << 32);
 
-    result64 = blsmskq(0x30);
-    assert(result64 == 0x1f);
+    result = blsmskq(0x30);
+    assert(result == 0x1f);
 
-    result64 = blsrq(0x30);
-    assert(result64 == 0x20);
+    result = blsrq(0x30);
+    assert(result == 0x20);
 
-    result64 = blsrq(0x30ull << 32);
-    assert(result64 == 0x20ull << 32);
+    result = blsrq(0x30ull << 32);
+    assert(result == 0x20ull << 32);
 
-    result64 = bzhiq(mask, 0x3f);
-    assert(result64 == (mask & ~INT64_MIN));
+    result = bzhiq(mask, 0x3f);
+    assert(result == (mask & ~INT64_MIN));
 
-    result64 = bzhiq(mask, 0x1f);
-    assert(result64 == (mask & ~(-1 << 30)));
+    result = bzhiq(mask, 0x1f);
+    assert(result == (mask & ~(-1 << 30)));
 
-    result64 = rorxq(0x2132435465768798, 8);
-    assert(result64 == 0x9821324354657687);
+    result = rorxq(0x2132435465768798, 8);
+    assert(result == 0x9821324354657687);
 
-    result64 = sarxq(0xffeeddccbbaa9988, 8);
-    assert(result64 == 0xffffeeddccbbaa99);
+    result = sarxq(0xffeeddccbbaa9988, 8);
+    assert(result == 0xffffeeddccbbaa99);
 
-    result64 = sarxq(0x77eeddccbbaa9988, 8 | 64);
-    assert(result64 == 0x0077eeddccbbaa99);
+    result = sarxq(0x77eeddccbbaa9988, 8 | 64);
+    assert(result == 0x0077eeddccbbaa99);
 
-    result64 = shrxq(0xffeeddccbbaa9988, 8);
-    assert(result64 == 0x00ffeeddccbbaa99);
+    result = shrxq(0xffeeddccbbaa9988, 8);
+    assert(result == 0x00ffeeddccbbaa99);
 
-    result64 = shrxq(0x77eeddccbbaa9988, 8 | 192);
-    assert(result64 == 0x0077eeddccbbaa99);
+    result = shrxq(0x77eeddccbbaa9988, 8 | 192);
+    assert(result == 0x0077eeddccbbaa99);
 
-    result64 = shlxq(0xffeeddccbbaa9988, 8);
-    assert(result64 == 0xeeddccbbaa998800);
+    result = shlxq(0xffeeddccbbaa9988, 8);
+    assert(result == 0xeeddccbbaa998800);
 #endif
 
     /* 32 bits */
-    result32 = andnl(mask, ehlo);
-    assert(result32 == 0x04d4c4844);
+    result = andnl(mask, ehlo);
+    assert(result == 0x04d4c4844);
 
-    result32 = pextl((uint32_t) ehlo, mask);
-    assert(result32 == 5);
+    result = pextl((uint32_t) ehlo, mask);
+    assert(result == 5);
 
-    result32 = pdepl(result32, mask);
-    assert(result32 == (uint32_t)(ehlo & mask));
+    result = pdepl(result, mask);
+    assert(result == (uint32_t)(ehlo & mask));
 
-    result32 = pextl(-1u, mask);
-    assert(result32 == 7); /* mask has 3 bits set */
+    result = pextl(-1u, mask);
+    assert(result == 7); /* mask has 3 bits set */
 
-    result32 = pdepl(-1u, mask);
-    assert(result32 == (uint32_t)mask);
+    result = pdepl(-1u, mask);
+    assert(result == (uint32_t)mask);
 
-    result32 = bextrl(mask, 0x1f00);
-    assert(result32 == (mask & ~INT32_MIN));
+    result = bextrl(mask, 0x1f00);
+    assert(result == (mask & ~INT32_MIN));
 
-    result32 = bextrl(ehlo, 0x1018);
-    assert(result32 == 0x4f);
+    result = bextrl(ehlo, 0x1018);
+    assert(result == 0x4f);
 
-    result32 = bextrl(mask, 0x1038);
-    assert(result32 == 0);
+    result = bextrl(mask, 0x1038);
+    assert(result == 0);
 
-    result32 = blsil(0xffff);
-    assert(result32 == 1);
+    result = blsil(0xffff);
+    assert(result == 1);
 
-    result32 = blsmskl(0x300);
-    assert(result32 == 0x1ff);
+    result = blsmskl(0x300);
+    assert(result == 0x1ff);
 
-    result32 = blsrl(0xffc);
-    assert(result32 == 0xff8);
+    result = blsrl(0xffc);
+    assert(result == 0xff8);
 
-    result32 = bzhil(mask, 0xf);
-    assert(result32 == 1);
+    result = bzhil(mask, 0xf);
+    assert(result == 1);
 
-    result32 = rorxl(0x65768798, 8);
-    assert(result32 == 0x98657687);
+    result = rorxl(0x65768798, 8);
+    assert(result == 0x98657687);
 
-    result32 = sarxl(0xffeeddcc, 8);
-    assert(result32 == 0xffffeedd);
+    result = sarxl(0xffeeddcc, 8);
+    assert(result == 0xffffeedd);
 
-    result32 = sarxl(0x77eeddcc, 8 | 32);
-    assert(result32 == 0x0077eedd);
+    result = sarxl(0x77eeddcc, 8 | 32);
+    assert(result == 0x0077eedd);
 
-    result32 = shrxl(0xffeeddcc, 8);
-    assert(result32 == 0x00ffeedd);
+    result = shrxl(0xffeeddcc, 8);
+    assert(result == 0x00ffeedd);
 
-    result32 = shrxl(0x77eeddcc, 8 | 128);
-    assert(result32 == 0x0077eedd);
+    result = shrxl(0x77eeddcc, 8 | 128);
+    assert(result == 0x0077eedd);
 
-    result32 = shlxl(0xffeeddcc, 8);
-    assert(result32 == 0xeeddcc00);
+    result = shlxl(0xffeeddcc, 8);
+    assert(result == 0xeeddcc00);
 
     return 0;
 }
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH 21/47] target/i386: Fix BEXTR instruction
  2023-03-08 16:57 [RFC PATCH 00/47] Patch Round-up for stable 7.2.1 Michael Tokarev
                   ` (19 preceding siblings ...)
  2023-03-08 16:57 ` [PATCH 20/47] tests/tcg/i386: Introduce and use reg_t consistently Michael Tokarev
@ 2023-03-08 16:57 ` Michael Tokarev
  2023-03-08 16:57 ` [PATCH 22/47] target/i386: Fix C flag for BLSI, BLSMSK, BLSR Michael Tokarev
                   ` (26 subsequent siblings)
  47 siblings, 0 replies; 50+ messages in thread
From: Michael Tokarev @ 2023-03-08 16:57 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-stable, Richard Henderson, Paolo Bonzini, Michael Tokarev

From: Richard Henderson <richard.henderson@linaro.org>

There were two problems here: not limiting the input to operand bits,
and not correctly handling large extraction length.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1372
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20230114230542.3116013-3-richard.henderson@linaro.org>
Cc: qemu-stable@nongnu.org
Fixes: 1d0b926150e5 ("target/i386: move scalar 0F 38 and 0F 3A instruction to new decoder", 2022-10-18)
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
(cherry picked from commit b14c0098975264ed03144f145bca0179a6763a07)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
 target/i386/tcg/emit.c.inc      | 22 +++++++++++-----------
 tests/tcg/i386/test-i386-bmi2.c | 12 ++++++++++++
 2 files changed, 23 insertions(+), 11 deletions(-)

diff --git a/target/i386/tcg/emit.c.inc b/target/i386/tcg/emit.c.inc
index 7037ff91c6..99f6ba6e19 100644
--- a/target/i386/tcg/emit.c.inc
+++ b/target/i386/tcg/emit.c.inc
@@ -1078,30 +1078,30 @@ static void gen_ANDN(DisasContext *s, CPUX86State *env, X86DecodedInsn *decode)
 static void gen_BEXTR(DisasContext *s, CPUX86State *env, X86DecodedInsn *decode)
 {
     MemOp ot = decode->op[0].ot;
-    TCGv bound, zero;
+    TCGv bound = tcg_constant_tl(ot == MO_64 ? 63 : 31);
+    TCGv zero = tcg_constant_tl(0);
+    TCGv mone = tcg_constant_tl(-1);
 
     /*
      * Extract START, and shift the operand.
      * Shifts larger than operand size get zeros.
      */
     tcg_gen_ext8u_tl(s->A0, s->T1);
+    if (TARGET_LONG_BITS == 64 && ot == MO_32) {
+        tcg_gen_ext32u_tl(s->T0, s->T0);
+    }
     tcg_gen_shr_tl(s->T0, s->T0, s->A0);
 
-    bound = tcg_constant_tl(ot == MO_64 ? 63 : 31);
-    zero = tcg_constant_tl(0);
     tcg_gen_movcond_tl(TCG_COND_LEU, s->T0, s->A0, bound, s->T0, zero);
 
     /*
-     * Extract the LEN into a mask.  Lengths larger than
-     * operand size get all ones.
+     * Extract the LEN into an inverse mask.  Lengths larger than
+     * operand size get all zeros, length 0 gets all ones.
      */
     tcg_gen_extract_tl(s->A0, s->T1, 8, 8);
-    tcg_gen_movcond_tl(TCG_COND_LEU, s->A0, s->A0, bound, s->A0, bound);
-
-    tcg_gen_movi_tl(s->T1, 1);
-    tcg_gen_shl_tl(s->T1, s->T1, s->A0);
-    tcg_gen_subi_tl(s->T1, s->T1, 1);
-    tcg_gen_and_tl(s->T0, s->T0, s->T1);
+    tcg_gen_shl_tl(s->T1, mone, s->A0);
+    tcg_gen_movcond_tl(TCG_COND_LEU, s->T1, s->A0, bound, s->T1, zero);
+    tcg_gen_andc_tl(s->T0, s->T0, s->T1);
 
     gen_op_update1_cc(s);
     set_cc_op(s, CC_OP_LOGICB + ot);
diff --git a/tests/tcg/i386/test-i386-bmi2.c b/tests/tcg/i386/test-i386-bmi2.c
index 3c3ef85513..982d4abda4 100644
--- a/tests/tcg/i386/test-i386-bmi2.c
+++ b/tests/tcg/i386/test-i386-bmi2.c
@@ -99,6 +99,9 @@ int main(int argc, char *argv[]) {
     result = bextrq(mask, 0x10f8);
     assert(result == 0);
 
+    result = bextrq(0xfedcba9876543210ull, 0x7f00);
+    assert(result == 0xfedcba9876543210ull);
+
     result = blsiq(0x30);
     assert(result == 0x10);
 
@@ -164,6 +167,15 @@ int main(int argc, char *argv[]) {
     result = bextrl(mask, 0x1038);
     assert(result == 0);
 
+    result = bextrl((reg_t)0x8f635a775ad3b9b4ull, 0x3018);
+    assert(result == 0x5a);
+
+    result = bextrl((reg_t)0xfedcba9876543210ull, 0x7f00);
+    assert(result == 0x76543210u);
+
+    result = bextrl(-1, 0);
+    assert(result == 0);
+
     result = blsil(0xffff);
     assert(result == 1);
 
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH 22/47] target/i386: Fix C flag for BLSI, BLSMSK, BLSR
  2023-03-08 16:57 [RFC PATCH 00/47] Patch Round-up for stable 7.2.1 Michael Tokarev
                   ` (20 preceding siblings ...)
  2023-03-08 16:57 ` [PATCH 21/47] target/i386: Fix BEXTR instruction Michael Tokarev
@ 2023-03-08 16:57 ` Michael Tokarev
  2023-03-08 16:57 ` [PATCH 23/47] target/i386: fix ADOX followed by ADCX Michael Tokarev
                   ` (25 subsequent siblings)
  47 siblings, 0 replies; 50+ messages in thread
From: Michael Tokarev @ 2023-03-08 16:57 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-stable, Richard Henderson, Paolo Bonzini, Michael Tokarev

From: Richard Henderson <richard.henderson@linaro.org>

We forgot to set cc_src, which is used for computing C.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1370
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20230114180601.2993644-1-richard.henderson@linaro.org>
Cc: qemu-stable@nongnu.org
Fixes: 1d0b926150e5 ("target/i386: move scalar 0F 38 and 0F 3A instruction to new decoder", 2022-10-18)
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
(cherry picked from commit 99282098dc74c2055bde5652bde6cf0067d0c370)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
 target/i386/tcg/emit.c.inc | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/target/i386/tcg/emit.c.inc b/target/i386/tcg/emit.c.inc
index 99f6ba6e19..4d7702c106 100644
--- a/target/i386/tcg/emit.c.inc
+++ b/target/i386/tcg/emit.c.inc
@@ -1111,6 +1111,7 @@ static void gen_BLSI(DisasContext *s, CPUX86State *env, X86DecodedInsn *decode)
 {
     MemOp ot = decode->op[0].ot;
 
+    tcg_gen_mov_tl(cpu_cc_src, s->T0);
     tcg_gen_neg_tl(s->T1, s->T0);
     tcg_gen_and_tl(s->T0, s->T0, s->T1);
     tcg_gen_mov_tl(cpu_cc_dst, s->T0);
@@ -1121,6 +1122,7 @@ static void gen_BLSMSK(DisasContext *s, CPUX86State *env, X86DecodedInsn *decode
 {
     MemOp ot = decode->op[0].ot;
 
+    tcg_gen_mov_tl(cpu_cc_src, s->T0);
     tcg_gen_subi_tl(s->T1, s->T0, 1);
     tcg_gen_xor_tl(s->T0, s->T0, s->T1);
     tcg_gen_mov_tl(cpu_cc_dst, s->T0);
@@ -1131,6 +1133,7 @@ static void gen_BLSR(DisasContext *s, CPUX86State *env, X86DecodedInsn *decode)
 {
     MemOp ot = decode->op[0].ot;
 
+    tcg_gen_mov_tl(cpu_cc_src, s->T0);
     tcg_gen_subi_tl(s->T1, s->T0, 1);
     tcg_gen_and_tl(s->T0, s->T0, s->T1);
     tcg_gen_mov_tl(cpu_cc_dst, s->T0);
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH 23/47] target/i386: fix ADOX followed by ADCX
  2023-03-08 16:57 [RFC PATCH 00/47] Patch Round-up for stable 7.2.1 Michael Tokarev
                   ` (21 preceding siblings ...)
  2023-03-08 16:57 ` [PATCH 22/47] target/i386: Fix C flag for BLSI, BLSMSK, BLSR Michael Tokarev
@ 2023-03-08 16:57 ` Michael Tokarev
  2023-03-08 16:57 ` [PATCH 24/47] target/i386: Fix BZHI instruction Michael Tokarev
                   ` (24 subsequent siblings)
  47 siblings, 0 replies; 50+ messages in thread
From: Michael Tokarev @ 2023-03-08 16:57 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-stable, Paolo Bonzini, Michael Tokarev

From: Paolo Bonzini <pbonzini@redhat.com>

When ADCX is followed by ADOX or vice versa, the second instruction's
carry comes from EFLAGS and the condition codes use the CC_OP_ADCOX
operation.  Retrieving the carry from EFLAGS is handled by this bit
of gen_ADCOX:

        tcg_gen_extract_tl(carry_in, cpu_cc_src,
            ctz32(cc_op == CC_OP_ADCX ? CC_C : CC_O), 1);

Unfortunately, in this case cc_op has been overwritten by the previous
"if" statement to CC_OP_ADCOX.  This works by chance when the first
instruction is ADCX; however, if the first instruction is ADOX,
ADCX will incorrectly take its carry from OF instead of CF.

Fix by moving the computation of the new cc_op at the end of the function.
The included exhaustive test case fails without this patch and passes
afterwards.

Because ADCX/ADOX need not be invoked through the VEX prefix, this
regression bisects to commit 16fc5726a6e2 ("target/i386: reimplement
0x0f 0x38, add AVX", 2022-10-18).  However, the mistake happened a
little earlier, when BMI instructions were rewritten using the new
decoder framework.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1471
Reported-by: Paul Jolly <https://gitlab.com/myitcv>
Fixes: 1d0b926150e5 ("target/i386: move scalar 0F 38 and 0F 3A instruction to new decoder", 2022-10-18)
Cc: qemu-stable@nongnu.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
(cherry picked from commit 60c7dd22e1383754d5f150bc9f7c2785c662a7b6)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
 target/i386/tcg/emit.c.inc       | 20 +++++----
 tests/tcg/i386/Makefile.target   |  6 ++-
 tests/tcg/i386/test-i386-adcox.c | 75 ++++++++++++++++++++++++++++++++
 3 files changed, 91 insertions(+), 10 deletions(-)
 create mode 100644 tests/tcg/i386/test-i386-adcox.c

diff --git a/target/i386/tcg/emit.c.inc b/target/i386/tcg/emit.c.inc
index 4d7702c106..0d7c6e80ae 100644
--- a/target/i386/tcg/emit.c.inc
+++ b/target/i386/tcg/emit.c.inc
@@ -1015,6 +1015,7 @@ VSIB_AVX(VPGATHERQ, vpgatherq)
 
 static void gen_ADCOX(DisasContext *s, CPUX86State *env, MemOp ot, int cc_op)
 {
+    int opposite_cc_op;
     TCGv carry_in = NULL;
     TCGv carry_out = (cc_op == CC_OP_ADCX ? cpu_cc_dst : cpu_cc_src2);
     TCGv zero;
@@ -1022,14 +1023,8 @@ static void gen_ADCOX(DisasContext *s, CPUX86State *env, MemOp ot, int cc_op)
     if (cc_op == s->cc_op || s->cc_op == CC_OP_ADCOX) {
         /* Re-use the carry-out from a previous round.  */
         carry_in = carry_out;
-        cc_op = s->cc_op;
-    } else if (s->cc_op == CC_OP_ADCX || s->cc_op == CC_OP_ADOX) {
-        /* Merge with the carry-out from the opposite instruction.  */
-        cc_op = CC_OP_ADCOX;
-    }
-
-    /* If we don't have a carry-in, get it out of EFLAGS.  */
-    if (!carry_in) {
+    } else {
+        /* We don't have a carry-in, get it out of EFLAGS.  */
         if (s->cc_op != CC_OP_ADCX && s->cc_op != CC_OP_ADOX) {
             gen_compute_eflags(s);
         }
@@ -1053,7 +1048,14 @@ static void gen_ADCOX(DisasContext *s, CPUX86State *env, MemOp ot, int cc_op)
         tcg_gen_add2_tl(s->T0, carry_out, s->T0, carry_out, s->T1, zero);
         break;
     }
-    set_cc_op(s, cc_op);
+
+    opposite_cc_op = cc_op == CC_OP_ADCX ? CC_OP_ADOX : CC_OP_ADCX;
+    if (s->cc_op == CC_OP_ADCOX || s->cc_op == opposite_cc_op) {
+        /* Merge with the carry-out from the opposite instruction.  */
+        set_cc_op(s, CC_OP_ADCOX);
+    } else {
+        set_cc_op(s, cc_op);
+    }
 }
 
 static void gen_ADCX(DisasContext *s, CPUX86State *env, X86DecodedInsn *decode)
diff --git a/tests/tcg/i386/Makefile.target b/tests/tcg/i386/Makefile.target
index 81831cafbc..bafd8c2180 100644
--- a/tests/tcg/i386/Makefile.target
+++ b/tests/tcg/i386/Makefile.target
@@ -14,7 +14,7 @@ config-cc.mak: Makefile
 I386_SRCS=$(notdir $(wildcard $(I386_SRC)/*.c))
 ALL_X86_TESTS=$(I386_SRCS:.c=)
 SKIP_I386_TESTS=test-i386-ssse3 test-avx test-3dnow test-mmx
-X86_64_TESTS:=$(filter test-i386-bmi2 $(SKIP_I386_TESTS), $(ALL_X86_TESTS))
+X86_64_TESTS:=$(filter test-i386-adcox test-i386-bmi2 $(SKIP_I386_TESTS), $(ALL_X86_TESTS))
 
 test-i386-sse-exceptions: CFLAGS += -msse4.1 -mfpmath=sse
 run-test-i386-sse-exceptions: QEMU_OPTS += -cpu max
@@ -28,6 +28,10 @@ test-i386-bmi2: CFLAGS=-O2
 run-test-i386-bmi2: QEMU_OPTS += -cpu max
 run-plugin-test-i386-bmi2-%: QEMU_OPTS += -cpu max
 
+test-i386-adcox: CFLAGS=-O2
+run-test-i386-adcox: QEMU_OPTS += -cpu max
+run-plugin-test-i386-adcox-%: QEMU_OPTS += -cpu max
+
 #
 # hello-i386 is a barebones app
 #
diff --git a/tests/tcg/i386/test-i386-adcox.c b/tests/tcg/i386/test-i386-adcox.c
new file mode 100644
index 0000000000..16169efff8
--- /dev/null
+++ b/tests/tcg/i386/test-i386-adcox.c
@@ -0,0 +1,75 @@
+/* See if various BMI2 instructions give expected results */
+#include <assert.h>
+#include <stdint.h>
+#include <stdio.h>
+
+#define CC_C 1
+#define CC_O (1 << 11)
+
+#ifdef __x86_64__
+#define REG uint64_t
+#else
+#define REG uint32_t
+#endif
+
+void test_adox_adcx(uint32_t in_c, uint32_t in_o, REG adcx_operand, REG adox_operand)
+{
+    REG flags;
+    REG out_adcx, out_adox;
+
+    asm("pushf; pop %0" : "=r"(flags));
+    flags &= ~(CC_C | CC_O);
+    flags |= (in_c ? CC_C : 0);
+    flags |= (in_o ? CC_O : 0);
+
+    out_adcx = adcx_operand;
+    out_adox = adox_operand;
+    asm("push %0; popf;"
+        "adox %3, %2;"
+        "adcx %3, %1;"
+        "pushf; pop %0"
+        : "+r" (flags), "+r" (out_adcx), "+r" (out_adox)
+        : "r" ((REG)-1), "0" (flags), "1" (out_adcx), "2" (out_adox));
+
+    assert(out_adcx == in_c + adcx_operand - 1);
+    assert(out_adox == in_o + adox_operand - 1);
+    assert(!!(flags & CC_C) == (in_c || adcx_operand));
+    assert(!!(flags & CC_O) == (in_o || adox_operand));
+}
+
+void test_adcx_adox(uint32_t in_c, uint32_t in_o, REG adcx_operand, REG adox_operand)
+{
+    REG flags;
+    REG out_adcx, out_adox;
+
+    asm("pushf; pop %0" : "=r"(flags));
+    flags &= ~(CC_C | CC_O);
+    flags |= (in_c ? CC_C : 0);
+    flags |= (in_o ? CC_O : 0);
+
+    out_adcx = adcx_operand;
+    out_adox = adox_operand;
+    asm("push %0; popf;"
+        "adcx %3, %1;"
+        "adox %3, %2;"
+        "pushf; pop %0"
+        : "+r" (flags), "+r" (out_adcx), "+r" (out_adox)
+        : "r" ((REG)-1), "0" (flags), "1" (out_adcx), "2" (out_adox));
+
+    assert(out_adcx == in_c + adcx_operand - 1);
+    assert(out_adox == in_o + adox_operand - 1);
+    assert(!!(flags & CC_C) == (in_c || adcx_operand));
+    assert(!!(flags & CC_O) == (in_o || adox_operand));
+}
+
+int main(int argc, char *argv[]) {
+    /* try all combinations of input CF, input OF, CF from op1+op2,  OF from op2+op1 */
+    int i;
+    for (i = 0; i <= 15; i++) {
+        printf("%d\n", i);
+        test_adcx_adox(!!(i & 1), !!(i & 2), !!(i & 4), !!(i & 8));
+        test_adox_adcx(!!(i & 1), !!(i & 2), !!(i & 4), !!(i & 8));
+    }
+    return 0;
+}
+
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH 24/47] target/i386: Fix BZHI instruction
  2023-03-08 16:57 [RFC PATCH 00/47] Patch Round-up for stable 7.2.1 Michael Tokarev
                   ` (22 preceding siblings ...)
  2023-03-08 16:57 ` [PATCH 23/47] target/i386: fix ADOX followed by ADCX Michael Tokarev
@ 2023-03-08 16:57 ` Michael Tokarev
  2023-03-08 16:57 ` [PATCH 25/47] block/iscsi: fix double-free on BUSY or similar statuses Michael Tokarev
                   ` (23 subsequent siblings)
  47 siblings, 0 replies; 50+ messages in thread
From: Michael Tokarev @ 2023-03-08 16:57 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-stable, Richard Henderson, Paolo Bonzini, Michael Tokarev

From: Richard Henderson <richard.henderson@linaro.org>

We did not correctly handle N >= operand size.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1374
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20230114233206.3118472-1-richard.henderson@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
(cherry picked from commit 9ad2ba6e8e7fc195d0dd0b76ab38bd2fceb1bdd4)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
 target/i386/tcg/emit.c.inc      | 14 +++++++-------
 tests/tcg/i386/test-i386-bmi2.c |  3 +++
 2 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/target/i386/tcg/emit.c.inc b/target/i386/tcg/emit.c.inc
index 0d7c6e80ae..7296f3952c 100644
--- a/target/i386/tcg/emit.c.inc
+++ b/target/i386/tcg/emit.c.inc
@@ -1145,20 +1145,20 @@ static void gen_BLSR(DisasContext *s, CPUX86State *env, X86DecodedInsn *decode)
 static void gen_BZHI(DisasContext *s, CPUX86State *env, X86DecodedInsn *decode)
 {
     MemOp ot = decode->op[0].ot;
-    TCGv bound;
+    TCGv bound = tcg_constant_tl(ot == MO_64 ? 63 : 31);
+    TCGv zero = tcg_constant_tl(0);
+    TCGv mone = tcg_constant_tl(-1);
 
-    tcg_gen_ext8u_tl(s->T1, cpu_regs[s->vex_v]);
-    bound = tcg_constant_tl(ot == MO_64 ? 63 : 31);
+    tcg_gen_ext8u_tl(s->T1, s->T1);
 
     /*
      * Note that since we're using BMILG (in order to get O
      * cleared) we need to store the inverse into C.
      */
-    tcg_gen_setcond_tl(TCG_COND_LT, cpu_cc_src, s->T1, bound);
-    tcg_gen_movcond_tl(TCG_COND_GT, s->T1, s->T1, bound, bound, s->T1);
+    tcg_gen_setcond_tl(TCG_COND_LEU, cpu_cc_src, s->T1, bound);
 
-    tcg_gen_movi_tl(s->A0, -1);
-    tcg_gen_shl_tl(s->A0, s->A0, s->T1);
+    tcg_gen_shl_tl(s->A0, mone, s->T1);
+    tcg_gen_movcond_tl(TCG_COND_LEU, s->A0, s->T1, bound, s->A0, zero);
     tcg_gen_andc_tl(s->T0, s->T0, s->A0);
 
     gen_op_update1_cc(s);
diff --git a/tests/tcg/i386/test-i386-bmi2.c b/tests/tcg/i386/test-i386-bmi2.c
index 982d4abda4..0244df7987 100644
--- a/tests/tcg/i386/test-i386-bmi2.c
+++ b/tests/tcg/i386/test-i386-bmi2.c
@@ -123,6 +123,9 @@ int main(int argc, char *argv[]) {
     result = bzhiq(mask, 0x1f);
     assert(result == (mask & ~(-1 << 30)));
 
+    result = bzhiq(mask, 0x40);
+    assert(result == mask);
+
     result = rorxq(0x2132435465768798, 8);
     assert(result == 0x9821324354657687);
 
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH 25/47] block/iscsi: fix double-free on BUSY or similar statuses
  2023-03-08 16:57 [RFC PATCH 00/47] Patch Round-up for stable 7.2.1 Michael Tokarev
                   ` (23 preceding siblings ...)
  2023-03-08 16:57 ` [PATCH 24/47] target/i386: Fix BZHI instruction Michael Tokarev
@ 2023-03-08 16:57 ` Michael Tokarev
  2023-03-08 16:57 ` [PATCH 26/47] hw/smbios: fix field corruption in type 4 table Michael Tokarev
                   ` (22 subsequent siblings)
  47 siblings, 0 replies; 50+ messages in thread
From: Michael Tokarev @ 2023-03-08 16:57 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-stable, Paolo Bonzini, Michael Tokarev

From: Paolo Bonzini <pbonzini@redhat.com>

Commit 8c460269aa77 ("iscsi: base all handling of check condition on
scsi_sense_to_errno", 2019-07-15) removed a "goto out" so that the
same coroutine is re-entered twice; once from iscsi_co_generic_cb,
once from the timer callback iscsi_retry_timer_expired.  This can
cause a crash.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1378
Reported-by: Grzegorz Zdanowski <https://gitlab.com/kiler129>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
(cherry picked from commit 5080152e2ef6cde7aa692e29880c62bd54acb750)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
 block/iscsi.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/block/iscsi.c b/block/iscsi.c
index a316d46d96..1bba42a71b 100644
--- a/block/iscsi.c
+++ b/block/iscsi.c
@@ -268,6 +268,7 @@ iscsi_co_generic_cb(struct iscsi_context *iscsi, int status,
                 timer_mod(&iTask->retry_timer,
                           qemu_clock_get_ms(QEMU_CLOCK_REALTIME) + retry_time);
                 iTask->do_retry = 1;
+                return;
             } else if (status == SCSI_STATUS_CHECK_CONDITION) {
                 int error = iscsi_translate_sense(&task->sense);
                 if (error == EAGAIN) {
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH 26/47] hw/smbios: fix field corruption in type 4 table
  2023-03-08 16:57 [RFC PATCH 00/47] Patch Round-up for stable 7.2.1 Michael Tokarev
                   ` (24 preceding siblings ...)
  2023-03-08 16:57 ` [PATCH 25/47] block/iscsi: fix double-free on BUSY or similar statuses Michael Tokarev
@ 2023-03-08 16:57 ` Michael Tokarev
  2023-03-08 16:57 ` [PATCH 27/47] Revert "x86: do not re-randomize RNG seed on snapshot load" Michael Tokarev
                   ` (21 subsequent siblings)
  47 siblings, 0 replies; 50+ messages in thread
From: Michael Tokarev @ 2023-03-08 16:57 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-stable, Julia Suvorova, Igor Mammedov, Ani Sinha,
	Michael S . Tsirkin, Michael Tokarev

From: Julia Suvorova <jusual@redhat.com>

Since table type 4 of SMBIOS version 2.6 is shorter than 3.0, the
strings which follow immediately after the struct fields have been
overwritten by unconditional filling of later fields such as core_count2.
Make these fields dependent on the SMBIOS version.

Fixes: 05e27d74c7 ("hw/smbios: add core_count2 to smbios table type 4")
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2169904

Signed-off-by: Julia Suvorova <jusual@redhat.com>
Message-Id: <20230223125747.254914-1-jusual@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Ani Sinha <ani@anisinha.ca>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit 60d09b8dc7dd4256d664ad680795cb1327805b2b)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
 hw/smbios/smbios.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c
index b4243de735..66a020999b 100644
--- a/hw/smbios/smbios.c
+++ b/hw/smbios/smbios.c
@@ -749,14 +749,16 @@ static void smbios_build_type_4_table(MachineState *ms, unsigned instance)
     t->core_count = (ms->smp.cores > 255) ? 0xFF : ms->smp.cores;
     t->core_enabled = t->core_count;
 
-    t->core_count2 = t->core_enabled2 = cpu_to_le16(ms->smp.cores);
-
     t->thread_count = (ms->smp.threads > 255) ? 0xFF : ms->smp.threads;
-    t->thread_count2 = cpu_to_le16(ms->smp.threads);
 
     t->processor_characteristics = cpu_to_le16(0x02); /* Unknown */
     t->processor_family2 = cpu_to_le16(0x01); /* Other */
 
+    if (tbl_len == SMBIOS_TYPE_4_LEN_V30) {
+        t->core_count2 = t->core_enabled2 = cpu_to_le16(ms->smp.cores);
+        t->thread_count2 = cpu_to_le16(ms->smp.threads);
+    }
+
     SMBIOS_BUILD_TABLE_POST;
     smbios_type4_count++;
 }
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH 27/47] Revert "x86: do not re-randomize RNG seed on snapshot load"
  2023-03-08 16:57 [RFC PATCH 00/47] Patch Round-up for stable 7.2.1 Michael Tokarev
                   ` (25 preceding siblings ...)
  2023-03-08 16:57 ` [PATCH 26/47] hw/smbios: fix field corruption in type 4 table Michael Tokarev
@ 2023-03-08 16:57 ` Michael Tokarev
  2023-03-08 16:57 ` [PATCH 28/47] Revert "x86: re-initialize RNG seed when selecting kernel" Michael Tokarev
                   ` (20 subsequent siblings)
  47 siblings, 0 replies; 50+ messages in thread
From: Michael Tokarev @ 2023-03-08 16:57 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-stable, Michael S. Tsirkin, Nathan Chancellor, Dov Murik,
	Daniel P . Berrangé, Michael Tokarev

From: "Michael S. Tsirkin" <mst@redhat.com>

This reverts commit 14b29fea742034186403914b4d013d0e83f19e78.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Fixes: 14b29fea74 ("x86: do not re-randomize RNG seed on snapshot load")
Tested-by: Nathan Chancellor <nathan@kernel.org>
Tested-by: Dov Murik <dovmurik@linux.ibm.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
(cherry picked from commit ef82d893de6d5bc0023026e636eae0f9a3e319dd)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
 hw/i386/x86.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/i386/x86.c b/hw/i386/x86.c
index 78cc131926..7984f65352 100644
--- a/hw/i386/x86.c
+++ b/hw/i386/x86.c
@@ -1115,7 +1115,7 @@ void x86_load_linux(X86MachineState *x86ms,
         setup_data->type = cpu_to_le32(SETUP_RNG_SEED);
         setup_data->len = cpu_to_le32(RNG_SEED_LENGTH);
         qemu_guest_getrandom_nofail(setup_data->data, RNG_SEED_LENGTH);
-        qemu_register_reset_nosnapshotload(reset_rng_seed, setup_data);
+        qemu_register_reset(reset_rng_seed, setup_data);
         fw_cfg_add_bytes_callback(fw_cfg, FW_CFG_KERNEL_DATA, reset_rng_seed, NULL,
                                   setup_data, kernel, kernel_size, true);
     } else {
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH 28/47] Revert "x86: re-initialize RNG seed when selecting kernel"
  2023-03-08 16:57 [RFC PATCH 00/47] Patch Round-up for stable 7.2.1 Michael Tokarev
                   ` (26 preceding siblings ...)
  2023-03-08 16:57 ` [PATCH 27/47] Revert "x86: do not re-randomize RNG seed on snapshot load" Michael Tokarev
@ 2023-03-08 16:57 ` Michael Tokarev
  2023-03-08 16:57 ` [PATCH 29/47] Revert "x86: reinitialize RNG seed on system reboot" Michael Tokarev
                   ` (19 subsequent siblings)
  47 siblings, 0 replies; 50+ messages in thread
From: Michael Tokarev @ 2023-03-08 16:57 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-stable, Michael S. Tsirkin, Nathan Chancellor, Dov Murik,
	Daniel P . Berrangé, Michael Tokarev

From: "Michael S. Tsirkin" <mst@redhat.com>

This reverts commit cc63374a5a7c240b7d3be734ef589dabbefc7527.

Fixes: cc63374a5a ("x86: re-initialize RNG seed when selecting kernel")
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Tested-by: Nathan Chancellor <nathan@kernel.org>
Tested-by: Dov Murik <dovmurik@linux.ibm.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
(cherry picked from commit b4bfa0a31d86caf89223e10e701c5b00df369b37)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
 hw/i386/x86.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/hw/i386/x86.c b/hw/i386/x86.c
index 7984f65352..e1a5f244a9 100644
--- a/hw/i386/x86.c
+++ b/hw/i386/x86.c
@@ -1116,14 +1116,11 @@ void x86_load_linux(X86MachineState *x86ms,
         setup_data->len = cpu_to_le32(RNG_SEED_LENGTH);
         qemu_guest_getrandom_nofail(setup_data->data, RNG_SEED_LENGTH);
         qemu_register_reset(reset_rng_seed, setup_data);
-        fw_cfg_add_bytes_callback(fw_cfg, FW_CFG_KERNEL_DATA, reset_rng_seed, NULL,
-                                  setup_data, kernel, kernel_size, true);
-    } else {
-        fw_cfg_add_bytes(fw_cfg, FW_CFG_KERNEL_DATA, kernel, kernel_size);
     }
 
     fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_ADDR, prot_addr);
     fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_SIZE, kernel_size);
+    fw_cfg_add_bytes(fw_cfg, FW_CFG_KERNEL_DATA, kernel, kernel_size);
     sev_load_ctx.kernel_data = (char *)kernel;
     sev_load_ctx.kernel_size = kernel_size;
 
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH 29/47] Revert "x86: reinitialize RNG seed on system reboot"
  2023-03-08 16:57 [RFC PATCH 00/47] Patch Round-up for stable 7.2.1 Michael Tokarev
                   ` (27 preceding siblings ...)
  2023-03-08 16:57 ` [PATCH 28/47] Revert "x86: re-initialize RNG seed when selecting kernel" Michael Tokarev
@ 2023-03-08 16:57 ` Michael Tokarev
  2023-03-08 16:57 ` [PATCH 30/47] Revert "x86: use typedef for SetupData struct" Michael Tokarev
                   ` (18 subsequent siblings)
  47 siblings, 0 replies; 50+ messages in thread
From: Michael Tokarev @ 2023-03-08 16:57 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-stable, Michael S. Tsirkin, Nathan Chancellor, Dov Murik,
	Daniel P . Berrangé, Michael Tokarev

From: "Michael S. Tsirkin" <mst@redhat.com>

This reverts commit 763a2828bf313ed55878b09759dc435355035f2e.

Fixes: 763a2828bf ("x86: reinitialize RNG seed on system reboot")
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Tested-by: Nathan Chancellor <nathan@kernel.org>
Tested-by: Dov Murik <dovmurik@linux.ibm.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
(cherry picked from commit fdc27ced04160904af1f290b561eded73abb8f1d)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
 hw/i386/x86.c | 7 -------
 1 file changed, 7 deletions(-)

diff --git a/hw/i386/x86.c b/hw/i386/x86.c
index e1a5f244a9..32f37ab7c2 100644
--- a/hw/i386/x86.c
+++ b/hw/i386/x86.c
@@ -787,12 +787,6 @@ static void reset_setup_data(void *opaque)
     stq_p(fixup->pos, fixup->orig_val);
 }
 
-static void reset_rng_seed(void *opaque)
-{
-    SetupData *setup_data = opaque;
-    qemu_guest_getrandom_nofail(setup_data->data, le32_to_cpu(setup_data->len));
-}
-
 void x86_load_linux(X86MachineState *x86ms,
                     FWCfgState *fw_cfg,
                     int acpi_data_size,
@@ -1115,7 +1109,6 @@ void x86_load_linux(X86MachineState *x86ms,
         setup_data->type = cpu_to_le32(SETUP_RNG_SEED);
         setup_data->len = cpu_to_le32(RNG_SEED_LENGTH);
         qemu_guest_getrandom_nofail(setup_data->data, RNG_SEED_LENGTH);
-        qemu_register_reset(reset_rng_seed, setup_data);
     }
 
     fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_ADDR, prot_addr);
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH 30/47] Revert "x86: use typedef for SetupData struct"
  2023-03-08 16:57 [RFC PATCH 00/47] Patch Round-up for stable 7.2.1 Michael Tokarev
                   ` (28 preceding siblings ...)
  2023-03-08 16:57 ` [PATCH 29/47] Revert "x86: reinitialize RNG seed on system reboot" Michael Tokarev
@ 2023-03-08 16:57 ` Michael Tokarev
  2023-03-08 16:57 ` [PATCH 31/47] Revert "x86: return modified setup_data only if read as memory, not as file" Michael Tokarev
                   ` (17 subsequent siblings)
  47 siblings, 0 replies; 50+ messages in thread
From: Michael Tokarev @ 2023-03-08 16:57 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-stable, Michael S. Tsirkin, Nathan Chancellor, Dov Murik,
	Daniel P . Berrangé, Michael Tokarev

From: "Michael S. Tsirkin" <mst@redhat.com>

This reverts commit eebb38a5633a77f5fa79d6486d5b2fcf8fbe3c07.

Fixes: eebb38a563 ("x86: use typedef for SetupData struct")
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Tested-by: Nathan Chancellor <nathan@kernel.org>
Tested-by: Dov Murik <dovmurik@linux.ibm.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
(cherry picked from commit ea96a784773259d469f3f2465f09e04eabb80a66)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
 hw/i386/x86.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/hw/i386/x86.c b/hw/i386/x86.c
index 32f37ab7c2..76b12108b4 100644
--- a/hw/i386/x86.c
+++ b/hw/i386/x86.c
@@ -657,12 +657,12 @@ DeviceState *ioapic_init_secondary(GSIState *gsi_state)
     return dev;
 }
 
-typedef struct SetupData {
+struct setup_data {
     uint64_t next;
     uint32_t type;
     uint32_t len;
     uint8_t data[];
-} __attribute__((packed)) SetupData;
+} __attribute__((packed));
 
 
 /*
@@ -803,7 +803,7 @@ void x86_load_linux(X86MachineState *x86ms,
     FILE *f;
     char *vmode;
     MachineState *machine = MACHINE(x86ms);
-    SetupData *setup_data;
+    struct setup_data *setup_data;
     const char *kernel_filename = machine->kernel_filename;
     const char *initrd_filename = machine->initrd_filename;
     const char *dtb_filename = machine->dtb;
@@ -1086,11 +1086,11 @@ void x86_load_linux(X86MachineState *x86ms,
         }
 
         setup_data_offset = QEMU_ALIGN_UP(kernel_size, 16);
-        kernel_size = setup_data_offset + sizeof(SetupData) + dtb_size;
+        kernel_size = setup_data_offset + sizeof(struct setup_data) + dtb_size;
         kernel = g_realloc(kernel, kernel_size);
 
 
-        setup_data = (SetupData *)(kernel + setup_data_offset);
+        setup_data = (struct setup_data *)(kernel + setup_data_offset);
         setup_data->next = cpu_to_le64(first_setup_data);
         first_setup_data = prot_addr + setup_data_offset;
         setup_data->type = cpu_to_le32(SETUP_DTB);
@@ -1101,9 +1101,9 @@ void x86_load_linux(X86MachineState *x86ms,
 
     if (!legacy_no_rng_seed) {
         setup_data_offset = QEMU_ALIGN_UP(kernel_size, 16);
-        kernel_size = setup_data_offset + sizeof(SetupData) + RNG_SEED_LENGTH;
+        kernel_size = setup_data_offset + sizeof(struct setup_data) + RNG_SEED_LENGTH;
         kernel = g_realloc(kernel, kernel_size);
-        setup_data = (SetupData *)(kernel + setup_data_offset);
+        setup_data = (struct setup_data *)(kernel + setup_data_offset);
         setup_data->next = cpu_to_le64(first_setup_data);
         first_setup_data = prot_addr + setup_data_offset;
         setup_data->type = cpu_to_le32(SETUP_RNG_SEED);
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH 31/47] Revert "x86: return modified setup_data only if read as memory, not as file"
  2023-03-08 16:57 [RFC PATCH 00/47] Patch Round-up for stable 7.2.1 Michael Tokarev
                   ` (29 preceding siblings ...)
  2023-03-08 16:57 ` [PATCH 30/47] Revert "x86: use typedef for SetupData struct" Michael Tokarev
@ 2023-03-08 16:57 ` Michael Tokarev
  2023-03-08 16:57 ` [PATCH 32/47] Revert "hw/i386: pass RNG seed via setup_data entry" Michael Tokarev
                   ` (16 subsequent siblings)
  47 siblings, 0 replies; 50+ messages in thread
From: Michael Tokarev @ 2023-03-08 16:57 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-stable, Michael S. Tsirkin, Nathan Chancellor, Dov Murik,
	Daniel P . Berrangé, Michael Tokarev

From: "Michael S. Tsirkin" <mst@redhat.com>

This reverts commit e935b735085dfa61d8e6d276b6f9e7687796a3c7.

Fixes: e935b73508 ("x86: return modified setup_data only if read as memory, not as file")
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Tested-by: Nathan Chancellor <nathan@kernel.org>
Tested-by: Dov Murik <dovmurik@linux.ibm.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
(cherry picked from commit ae80d81cfa865cbe443543679e013e7fa5fcd12c)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
 hw/i386/x86.c             | 46 +++++++++------------------------------
 hw/nvram/fw_cfg.c         | 12 +++++-----
 include/hw/nvram/fw_cfg.h | 22 -------------------
 3 files changed, 16 insertions(+), 64 deletions(-)

diff --git a/hw/i386/x86.c b/hw/i386/x86.c
index 76b12108b4..4831193c86 100644
--- a/hw/i386/x86.c
+++ b/hw/i386/x86.c
@@ -37,7 +37,6 @@
 #include "sysemu/whpx.h"
 #include "sysemu/numa.h"
 #include "sysemu/replay.h"
-#include "sysemu/reset.h"
 #include "sysemu/sysemu.h"
 #include "sysemu/cpu-timers.h"
 #include "sysemu/xen.h"
@@ -769,24 +768,6 @@ static bool load_elfboot(const char *kernel_filename,
     return true;
 }
 
-typedef struct SetupDataFixup {
-    void *pos;
-    hwaddr orig_val, new_val;
-    uint32_t addr;
-} SetupDataFixup;
-
-static void fixup_setup_data(void *opaque)
-{
-    SetupDataFixup *fixup = opaque;
-    stq_p(fixup->pos, fixup->new_val);
-}
-
-static void reset_setup_data(void *opaque)
-{
-    SetupDataFixup *fixup = opaque;
-    stq_p(fixup->pos, fixup->orig_val);
-}
-
 void x86_load_linux(X86MachineState *x86ms,
                     FWCfgState *fw_cfg,
                     int acpi_data_size,
@@ -1111,11 +1092,8 @@ void x86_load_linux(X86MachineState *x86ms,
         qemu_guest_getrandom_nofail(setup_data->data, RNG_SEED_LENGTH);
     }
 
-    fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_ADDR, prot_addr);
-    fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_SIZE, kernel_size);
-    fw_cfg_add_bytes(fw_cfg, FW_CFG_KERNEL_DATA, kernel, kernel_size);
-    sev_load_ctx.kernel_data = (char *)kernel;
-    sev_load_ctx.kernel_size = kernel_size;
+    /* Offset 0x250 is a pointer to the first setup_data link. */
+    stq_p(header + 0x250, first_setup_data);
 
     /*
      * If we're starting an encrypted VM, it will be OVMF based, which uses the
@@ -1125,20 +1103,16 @@ void x86_load_linux(X86MachineState *x86ms,
      * file the user passed in.
      */
     if (!sev_enabled()) {
-        SetupDataFixup *fixup = g_malloc(sizeof(*fixup));
-
         memcpy(setup, header, MIN(sizeof(header), setup_size));
-        /* Offset 0x250 is a pointer to the first setup_data link. */
-        fixup->pos = setup + 0x250;
-        fixup->orig_val = ldq_p(fixup->pos);
-        fixup->new_val = first_setup_data;
-        fixup->addr = cpu_to_le32(real_addr);
-        fw_cfg_add_bytes_callback(fw_cfg, FW_CFG_SETUP_ADDR, fixup_setup_data, NULL,
-                                  fixup, &fixup->addr, sizeof(fixup->addr), true);
-        qemu_register_reset(reset_setup_data, fixup);
-    } else {
-        fw_cfg_add_i32(fw_cfg, FW_CFG_SETUP_ADDR, real_addr);
     }
+
+    fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_ADDR, prot_addr);
+    fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_SIZE, kernel_size);
+    fw_cfg_add_bytes(fw_cfg, FW_CFG_KERNEL_DATA, kernel, kernel_size);
+    sev_load_ctx.kernel_data = (char *)kernel;
+    sev_load_ctx.kernel_size = kernel_size;
+
+    fw_cfg_add_i32(fw_cfg, FW_CFG_SETUP_ADDR, real_addr);
     fw_cfg_add_i32(fw_cfg, FW_CFG_SETUP_SIZE, setup_size);
     fw_cfg_add_bytes(fw_cfg, FW_CFG_SETUP_DATA, setup, setup_size);
     sev_load_ctx.setup_data = (char *)setup;
diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c
index 6edf5ea3e9..371a45dfe2 100644
--- a/hw/nvram/fw_cfg.c
+++ b/hw/nvram/fw_cfg.c
@@ -693,12 +693,12 @@ static const VMStateDescription vmstate_fw_cfg = {
     }
 };
 
-void fw_cfg_add_bytes_callback(FWCfgState *s, uint16_t key,
-                               FWCfgCallback select_cb,
-                               FWCfgWriteCallback write_cb,
-                               void *callback_opaque,
-                               void *data, size_t len,
-                               bool read_only)
+static void fw_cfg_add_bytes_callback(FWCfgState *s, uint16_t key,
+                                      FWCfgCallback select_cb,
+                                      FWCfgWriteCallback write_cb,
+                                      void *callback_opaque,
+                                      void *data, size_t len,
+                                      bool read_only)
 {
     int arch = !!(key & FW_CFG_ARCH_LOCAL);
 
diff --git a/include/hw/nvram/fw_cfg.h b/include/hw/nvram/fw_cfg.h
index 2e503904dc..c1f81a5f13 100644
--- a/include/hw/nvram/fw_cfg.h
+++ b/include/hw/nvram/fw_cfg.h
@@ -117,28 +117,6 @@ struct FWCfgMemState {
  */
 void fw_cfg_add_bytes(FWCfgState *s, uint16_t key, void *data, size_t len);
 
-/**
- * fw_cfg_add_bytes_callback:
- * @s: fw_cfg device being modified
- * @key: selector key value for new fw_cfg item
- * @select_cb: callback function when selecting
- * @write_cb: callback function after a write
- * @callback_opaque: argument to be passed into callback function
- * @data: pointer to start of item data
- * @len: size of item data
- * @read_only: is file read only
- *
- * Add a new fw_cfg item, available by selecting the given key, as a raw
- * "blob" of the given size. The data referenced by the starting pointer
- * is only linked, NOT copied, into the data structure of the fw_cfg device.
- */
-void fw_cfg_add_bytes_callback(FWCfgState *s, uint16_t key,
-                               FWCfgCallback select_cb,
-                               FWCfgWriteCallback write_cb,
-                               void *callback_opaque,
-                               void *data, size_t len,
-                               bool read_only);
-
 /**
  * fw_cfg_add_string:
  * @s: fw_cfg device being modified
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH 32/47] Revert "hw/i386: pass RNG seed via setup_data entry"
  2023-03-08 16:57 [RFC PATCH 00/47] Patch Round-up for stable 7.2.1 Michael Tokarev
                   ` (30 preceding siblings ...)
  2023-03-08 16:57 ` [PATCH 31/47] Revert "x86: return modified setup_data only if read as memory, not as file" Michael Tokarev
@ 2023-03-08 16:57 ` Michael Tokarev
  2023-03-08 16:57 ` [PATCH 33/47] vhost-user-gpio: Configure vhost_dev when connecting Michael Tokarev
                   ` (15 subsequent siblings)
  47 siblings, 0 replies; 50+ messages in thread
From: Michael Tokarev @ 2023-03-08 16:57 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-stable, Michael S. Tsirkin, Nathan Chancellor, Dov Murik,
	Daniel P . Berrangé, Michael Tokarev

From: "Michael S. Tsirkin" <mst@redhat.com>

This reverts commit 67f7e426e53833a5db75b0d813e8d537b8a75bd2.

Additionally to the automatic revert, I went over the code
and dropped all mentions of legacy_no_rng_seed manually,
effectively reverting a combination of 2 additional commits:

    commit ffe2d2382e5f1aae1abc4081af407905ef380311
    Author: Jason A. Donenfeld <Jason@zx2c4.com>
    Date:   Wed Sep 21 11:31:34 2022 +0200

        x86: re-enable rng seeding via SetupData

    commit 3824e25db1a84fadc50b88dfbe27047aa2f7f85d
    Author: Gerd Hoffmann <kraxel@redhat.com>
    Date:   Wed Aug 17 10:39:40 2022 +0200

        x86: disable rng seeding via setup_data

Fixes: 67f7e426e5 ("hw/i386: pass RNG seed via setup_data entry")
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Tested-by: Nathan Chancellor <nathan@kernel.org>
Tested-by: Dov Murik <dovmurik@linux.ibm.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
(cherry picked from commit 167f4873580d3729565044cda73c3e20997950f2)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Mjt: this required manual edit for stable-7.2
---
 hw/i386/microvm.c     |  2 +-
 hw/i386/pc.c          |  4 ++--
 hw/i386/pc_piix.c     |  2 --
 hw/i386/pc_q35.c      |  2 --
 hw/i386/x86.c         | 26 ++++----------------------
 include/hw/i386/pc.h  |  3 ---
 include/hw/i386/x86.h |  3 +--
 7 files changed, 8 insertions(+), 34 deletions(-)

diff --git a/hw/i386/microvm.c b/hw/i386/microvm.c
index 170a331e3f..b231ceda9a 100644
--- a/hw/i386/microvm.c
+++ b/hw/i386/microvm.c
@@ -330,7 +330,7 @@ static void microvm_memory_init(MicrovmMachineState *mms)
     rom_set_fw(fw_cfg);
 
     if (machine->kernel_filename != NULL) {
-        x86_load_linux(x86ms, fw_cfg, 0, true, false);
+        x86_load_linux(x86ms, fw_cfg, 0, true);
     }
 
     if (mms->option_roms) {
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 546b703cb4..ec5a10534b 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -799,7 +799,7 @@ void xen_load_linux(PCMachineState *pcms)
     rom_set_fw(fw_cfg);
 
     x86_load_linux(x86ms, fw_cfg, pcmc->acpi_data_size,
-                   pcmc->pvh_enabled, pcmc->legacy_no_rng_seed);
+                   pcmc->pvh_enabled);
     for (i = 0; i < nb_option_roms; i++) {
         assert(!strcmp(option_rom[i].name, "linuxboot.bin") ||
                !strcmp(option_rom[i].name, "linuxboot_dma.bin") ||
@@ -1119,7 +1119,7 @@ void pc_memory_init(PCMachineState *pcms,
 
     if (linux_boot) {
         x86_load_linux(x86ms, fw_cfg, pcmc->acpi_data_size,
-                       pcmc->pvh_enabled, pcmc->legacy_no_rng_seed);
+                       pcmc->pvh_enabled);
     }
 
     for (i = 0; i < nb_option_roms; i++) {
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 0ad0ed1603..24616bf924 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -449,11 +449,9 @@ DEFINE_I440FX_MACHINE(v7_2, "pc-i440fx-7.2", NULL,
 
 static void pc_i440fx_7_1_machine_options(MachineClass *m)
 {
-    PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
     pc_i440fx_7_2_machine_options(m);
     m->alias = NULL;
     m->is_default = false;
-    pcmc->legacy_no_rng_seed = true;
     compat_props_add(m->compat_props, hw_compat_7_1, hw_compat_7_1_len);
     compat_props_add(m->compat_props, pc_compat_7_1, pc_compat_7_1_len);
 }
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index a496bd6e74..f522874add 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -383,10 +383,8 @@ DEFINE_Q35_MACHINE(v7_2, "pc-q35-7.2", NULL,
 
 static void pc_q35_7_1_machine_options(MachineClass *m)
 {
-    PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
     pc_q35_7_2_machine_options(m);
     m->alias = NULL;
-    pcmc->legacy_no_rng_seed = true;
     compat_props_add(m->compat_props, hw_compat_7_1, hw_compat_7_1_len);
     compat_props_add(m->compat_props, pc_compat_7_1, pc_compat_7_1_len);
 }
diff --git a/hw/i386/x86.c b/hw/i386/x86.c
index 4831193c86..80be3032cc 100644
--- a/hw/i386/x86.c
+++ b/hw/i386/x86.c
@@ -26,7 +26,6 @@
 #include "qemu/cutils.h"
 #include "qemu/units.h"
 #include "qemu/datadir.h"
-#include "qemu/guest-random.h"
 #include "qapi/error.h"
 #include "qapi/qmp/qerror.h"
 #include "qapi/qapi-visit-common.h"
@@ -771,8 +770,7 @@ static bool load_elfboot(const char *kernel_filename,
 void x86_load_linux(X86MachineState *x86ms,
                     FWCfgState *fw_cfg,
                     int acpi_data_size,
-                    bool pvh_enabled,
-                    bool legacy_no_rng_seed)
+                    bool pvh_enabled)
 {
     bool linuxboot_dma_enabled = X86_MACHINE_GET_CLASS(x86ms)->fwcfg_dma_enabled;
     uint16_t protocol;
@@ -780,7 +778,7 @@ void x86_load_linux(X86MachineState *x86ms,
     int dtb_size, setup_data_offset;
     uint32_t initrd_max;
     uint8_t header[8192], *setup, *kernel;
-    hwaddr real_addr, prot_addr, cmdline_addr, initrd_addr = 0, first_setup_data = 0;
+    hwaddr real_addr, prot_addr, cmdline_addr, initrd_addr = 0;
     FILE *f;
     char *vmode;
     MachineState *machine = MACHINE(x86ms);
@@ -790,7 +788,6 @@ void x86_load_linux(X86MachineState *x86ms,
     const char *dtb_filename = machine->dtb;
     const char *kernel_cmdline = machine->kernel_cmdline;
     SevKernelLoaderContext sev_load_ctx = {};
-    enum { RNG_SEED_LENGTH = 32 };
 
     /* Align to 16 bytes as a paranoia measure */
     cmdline_size = (strlen(kernel_cmdline) + 16) & ~15;
@@ -1070,31 +1067,16 @@ void x86_load_linux(X86MachineState *x86ms,
         kernel_size = setup_data_offset + sizeof(struct setup_data) + dtb_size;
         kernel = g_realloc(kernel, kernel_size);
 
+        stq_p(header + 0x250, prot_addr + setup_data_offset);
 
         setup_data = (struct setup_data *)(kernel + setup_data_offset);
-        setup_data->next = cpu_to_le64(first_setup_data);
-        first_setup_data = prot_addr + setup_data_offset;
+        setup_data->next = 0;
         setup_data->type = cpu_to_le32(SETUP_DTB);
         setup_data->len = cpu_to_le32(dtb_size);
 
         load_image_size(dtb_filename, setup_data->data, dtb_size);
     }
 
-    if (!legacy_no_rng_seed) {
-        setup_data_offset = QEMU_ALIGN_UP(kernel_size, 16);
-        kernel_size = setup_data_offset + sizeof(struct setup_data) + RNG_SEED_LENGTH;
-        kernel = g_realloc(kernel, kernel_size);
-        setup_data = (struct setup_data *)(kernel + setup_data_offset);
-        setup_data->next = cpu_to_le64(first_setup_data);
-        first_setup_data = prot_addr + setup_data_offset;
-        setup_data->type = cpu_to_le32(SETUP_RNG_SEED);
-        setup_data->len = cpu_to_le32(RNG_SEED_LENGTH);
-        qemu_guest_getrandom_nofail(setup_data->data, RNG_SEED_LENGTH);
-    }
-
-    /* Offset 0x250 is a pointer to the first setup_data link. */
-    stq_p(header + 0x250, first_setup_data);
-
     /*
      * If we're starting an encrypted VM, it will be OVMF based, which uses the
      * efi stub for booting and doesn't require any values to be placed in the
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index c95333514e..0c76e82626 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -128,9 +128,6 @@ struct PCMachineClass {
 
     /* create kvmclock device even when KVM PV features are not exposed */
     bool kvmclock_create_always;
-
-    /* skip passing an rng seed for legacy machines */
-    bool legacy_no_rng_seed;
 };
 
 #define TYPE_PC_MACHINE "generic-pc-machine"
diff --git a/include/hw/i386/x86.h b/include/hw/i386/x86.h
index 62fa5774f8..df82c5fd42 100644
--- a/include/hw/i386/x86.h
+++ b/include/hw/i386/x86.h
@@ -126,8 +126,7 @@ void x86_bios_rom_init(MachineState *ms, const char *default_firmware,
 void x86_load_linux(X86MachineState *x86ms,
                     FWCfgState *fw_cfg,
                     int acpi_data_size,
-                    bool pvh_enabled,
-                    bool legacy_no_rng_seed);
+                    bool pvh_enabled);
 
 bool x86_machine_is_smm_enabled(const X86MachineState *x86ms);
 bool x86_machine_is_acpi_enabled(const X86MachineState *x86ms);
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH 33/47] vhost-user-gpio: Configure vhost_dev when connecting
  2023-03-08 16:57 [RFC PATCH 00/47] Patch Round-up for stable 7.2.1 Michael Tokarev
                   ` (31 preceding siblings ...)
  2023-03-08 16:57 ` [PATCH 32/47] Revert "hw/i386: pass RNG seed via setup_data entry" Michael Tokarev
@ 2023-03-08 16:57 ` Michael Tokarev
  2023-03-08 16:57 ` [PATCH 34/47] vhost-user-i2c: Back up vqs before cleaning up vhost_dev Michael Tokarev
                   ` (14 subsequent siblings)
  47 siblings, 0 replies; 50+ messages in thread
From: Michael Tokarev @ 2023-03-08 16:57 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-stable, Akihiko Odaki, Viresh Kumar, Alex Bennée,
	Michael S . Tsirkin, Michael Tokarev

From: Akihiko Odaki <akihiko.odaki@daynix.com>

vhost_dev_cleanup(), called from vu_gpio_disconnect(), clears vhost_dev
so vhost-user-gpio must set the members of vhost_dev each time
connecting.

do_vhost_user_cleanup() should also acquire the pointer to vqs directly
from VHostUserGPIO instead of referring to vhost_dev as it can be called
after vhost_dev_cleanup().

Fixes: 27ba7b027f ("hw/virtio: add boilerplate for vhost-user-gpio device")
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
Message-Id: <20230130140320.77999-1-akihiko.odaki@daynix.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit daae36c13abc73cf1055abc2d33cb71cc5d34310)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
 hw/virtio/vhost-user-gpio.c         | 10 ++++++----
 include/hw/virtio/vhost-user-gpio.h |  2 +-
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/hw/virtio/vhost-user-gpio.c b/hw/virtio/vhost-user-gpio.c
index 5851cb3bc9..72af765f33 100644
--- a/hw/virtio/vhost-user-gpio.c
+++ b/hw/virtio/vhost-user-gpio.c
@@ -16,6 +16,7 @@
 #include "trace.h"
 
 #define REALIZE_CONNECTION_RETRIES 3
+#define VHOST_NVQS 2
 
 /* Features required from VirtIO */
 static const int feature_bits[] = {
@@ -201,8 +202,7 @@ static void do_vhost_user_cleanup(VirtIODevice *vdev, VHostUserGPIO *gpio)
 {
     virtio_delete_queue(gpio->command_vq);
     virtio_delete_queue(gpio->interrupt_vq);
-    g_free(gpio->vhost_dev.vqs);
-    gpio->vhost_dev.vqs = NULL;
+    g_free(gpio->vhost_vqs);
     virtio_cleanup(vdev);
     vhost_user_cleanup(&gpio->vhost_user);
 }
@@ -222,6 +222,9 @@ static int vu_gpio_connect(DeviceState *dev, Error **errp)
     vhost_dev_set_config_notifier(vhost_dev, &gpio_ops);
     gpio->vhost_user.supports_config = true;
 
+    gpio->vhost_dev.nvqs = VHOST_NVQS;
+    gpio->vhost_dev.vqs = gpio->vhost_vqs;
+
     ret = vhost_dev_init(vhost_dev, &gpio->vhost_user,
                          VHOST_BACKEND_TYPE_USER, 0, errp);
     if (ret < 0) {
@@ -331,10 +334,9 @@ static void vu_gpio_device_realize(DeviceState *dev, Error **errp)
 
     virtio_init(vdev, VIRTIO_ID_GPIO, sizeof(gpio->config));
 
-    gpio->vhost_dev.nvqs = 2;
     gpio->command_vq = virtio_add_queue(vdev, 256, vu_gpio_handle_output);
     gpio->interrupt_vq = virtio_add_queue(vdev, 256, vu_gpio_handle_output);
-    gpio->vhost_dev.vqs = g_new0(struct vhost_virtqueue, gpio->vhost_dev.nvqs);
+    gpio->vhost_vqs = g_new0(struct vhost_virtqueue, VHOST_NVQS);
 
     gpio->connected = false;
 
diff --git a/include/hw/virtio/vhost-user-gpio.h b/include/hw/virtio/vhost-user-gpio.h
index 4fe9aeecc0..c17a5a351a 100644
--- a/include/hw/virtio/vhost-user-gpio.h
+++ b/include/hw/virtio/vhost-user-gpio.h
@@ -23,7 +23,7 @@ struct VHostUserGPIO {
     VirtIODevice parent_obj;
     CharBackend chardev;
     struct virtio_gpio_config config;
-    struct vhost_virtqueue *vhost_vq;
+    struct vhost_virtqueue *vhost_vqs;
     struct vhost_dev vhost_dev;
     VhostUserState vhost_user;
     VirtQueue *command_vq;
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH 34/47] vhost-user-i2c: Back up vqs before cleaning up vhost_dev
  2023-03-08 16:57 [RFC PATCH 00/47] Patch Round-up for stable 7.2.1 Michael Tokarev
                   ` (32 preceding siblings ...)
  2023-03-08 16:57 ` [PATCH 33/47] vhost-user-gpio: Configure vhost_dev when connecting Michael Tokarev
@ 2023-03-08 16:57 ` Michael Tokarev
  2023-03-08 16:57 ` [PATCH 35/47] vhost-user-rng: " Michael Tokarev
                   ` (13 subsequent siblings)
  47 siblings, 0 replies; 50+ messages in thread
From: Michael Tokarev @ 2023-03-08 16:57 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-stable, Akihiko Odaki, Michael S . Tsirkin, Michael Tokarev

From: Akihiko Odaki <akihiko.odaki@daynix.com>

vhost_dev_cleanup() clears vhost_dev so back up its vqs member to free
the memory pointed by the member.

Fixes: 7221d3b634 ("hw/virtio: add boilerplate for vhost-user-i2c device")
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
Message-Id: <20230130140435.78049-1-akihiko.odaki@daynix.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit 0126793bee853e7c134627f51d2de5428a612e99)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
 hw/virtio/vhost-user-i2c.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/hw/virtio/vhost-user-i2c.c b/hw/virtio/vhost-user-i2c.c
index 1c9f3d20dc..2634d81539 100644
--- a/hw/virtio/vhost-user-i2c.c
+++ b/hw/virtio/vhost-user-i2c.c
@@ -143,8 +143,6 @@ static void do_vhost_user_cleanup(VirtIODevice *vdev, VHostUserI2C *i2c)
     vhost_user_cleanup(&i2c->vhost_user);
     virtio_delete_queue(i2c->vq);
     virtio_cleanup(vdev);
-    g_free(i2c->vhost_dev.vqs);
-    i2c->vhost_dev.vqs = NULL;
 }
 
 static int vu_i2c_connect(DeviceState *dev)
@@ -228,6 +226,7 @@ static void vu_i2c_device_realize(DeviceState *dev, Error **errp)
     ret = vhost_dev_init(&i2c->vhost_dev, &i2c->vhost_user,
                          VHOST_BACKEND_TYPE_USER, 0, errp);
     if (ret < 0) {
+        g_free(i2c->vhost_dev.vqs);
         do_vhost_user_cleanup(vdev, i2c);
     }
 
@@ -239,10 +238,12 @@ static void vu_i2c_device_unrealize(DeviceState *dev)
 {
     VirtIODevice *vdev = VIRTIO_DEVICE(dev);
     VHostUserI2C *i2c = VHOST_USER_I2C(dev);
+    struct vhost_virtqueue *vhost_vqs = i2c->vhost_dev.vqs;
 
     /* This will stop vhost backend if appropriate. */
     vu_i2c_set_status(vdev, 0);
     vhost_dev_cleanup(&i2c->vhost_dev);
+    g_free(vhost_vqs);
     do_vhost_user_cleanup(vdev, i2c);
 }
 
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH 35/47] vhost-user-rng: Back up vqs before cleaning up vhost_dev
  2023-03-08 16:57 [RFC PATCH 00/47] Patch Round-up for stable 7.2.1 Michael Tokarev
                   ` (33 preceding siblings ...)
  2023-03-08 16:57 ` [PATCH 34/47] vhost-user-i2c: Back up vqs before cleaning up vhost_dev Michael Tokarev
@ 2023-03-08 16:57 ` Michael Tokarev
  2023-03-08 16:57 ` [PATCH 37/47] virtio-rng-pci: fix transitional migration compat for vectors Michael Tokarev
                   ` (12 subsequent siblings)
  47 siblings, 0 replies; 50+ messages in thread
From: Michael Tokarev @ 2023-03-08 16:57 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-stable, Akihiko Odaki, Michael S . Tsirkin, Michael Tokarev

From: Akihiko Odaki <akihiko.odaki@daynix.com>

vhost_dev_cleanup() clears vhost_dev so back up its vqs member to free
the memory pointed by the member.

Fixes: 821d28b88f ("vhost-user-rng: Add vhost-user-rng implementation")
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
Message-Id: <20230130140516.78078-1-akihiko.odaki@daynix.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit f0dac71596d4b87a1a77d1f4efb6a6adb4730d7b)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
 hw/virtio/vhost-user-rng.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/hw/virtio/vhost-user-rng.c b/hw/virtio/vhost-user-rng.c
index f9084cde58..3f7b59ec0d 100644
--- a/hw/virtio/vhost-user-rng.c
+++ b/hw/virtio/vhost-user-rng.c
@@ -229,6 +229,7 @@ static void vu_rng_device_realize(DeviceState *dev, Error **errp)
     return;
 
 vhost_dev_init_failed:
+    g_free(rng->vhost_dev.vqs);
     virtio_delete_queue(rng->req_vq);
 virtio_add_queue_failed:
     virtio_cleanup(vdev);
@@ -239,12 +240,12 @@ static void vu_rng_device_unrealize(DeviceState *dev)
 {
     VirtIODevice *vdev = VIRTIO_DEVICE(dev);
     VHostUserRNG *rng = VHOST_USER_RNG(dev);
+    struct vhost_virtqueue *vhost_vqs = rng->vhost_dev.vqs;
 
     vu_rng_set_status(vdev, 0);
 
     vhost_dev_cleanup(&rng->vhost_dev);
-    g_free(rng->vhost_dev.vqs);
-    rng->vhost_dev.vqs = NULL;
+    g_free(vhost_vqs);
     virtio_delete_queue(rng->req_vq);
     virtio_cleanup(vdev);
     vhost_user_cleanup(&rng->vhost_user);
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH 37/47] virtio-rng-pci: fix transitional migration compat for vectors
  2023-03-08 16:57 [RFC PATCH 00/47] Patch Round-up for stable 7.2.1 Michael Tokarev
                   ` (34 preceding siblings ...)
  2023-03-08 16:57 ` [PATCH 35/47] vhost-user-rng: " Michael Tokarev
@ 2023-03-08 16:57 ` Michael Tokarev
  2023-03-08 16:57 ` [PATCH 38/47] hw/timer/hpet: Fix expiration time overflow Michael Tokarev
                   ` (11 subsequent siblings)
  47 siblings, 0 replies; 50+ messages in thread
From: Michael Tokarev @ 2023-03-08 16:57 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-stable, Dr. David Alan Gilbert, Michael S . Tsirkin,
	Michael Tokarev

From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>

In bad9c5a516 ("virtio-rng-pci: fix migration compat for vectors") I
fixed the virtio-rng-pci migration compatibility, but it was discovered
that we also need to fix the other aliases of the device for the
transitional cases.

Fixes: 9ea02e8f1 ('virtio-rng-pci: Allow setting nvectors, so we can use MSI-X')
bz: https://bugzilla.redhat.com/show_bug.cgi?id=2162569
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Message-Id: <20230207174944.138255-1-dgilbert@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit 62bdb8871512076841f4464f7e26efdc7783f78d)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
 hw/core/machine.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/hw/core/machine.c b/hw/core/machine.c
index 77a0a131d1..035d078a74 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -43,6 +43,8 @@
 GlobalProperty hw_compat_7_1[] = {
     { "virtio-device", "queue_reset", "false" },
     { "virtio-rng-pci", "vectors", "0" },
+    { "virtio-rng-pci-transitional", "vectors", "0" },
+    { "virtio-rng-pci-non-transitional", "vectors", "0" },
 };
 const size_t hw_compat_7_1_len = G_N_ELEMENTS(hw_compat_7_1);
 
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH 38/47] hw/timer/hpet: Fix expiration time overflow
  2023-03-08 16:57 [RFC PATCH 00/47] Patch Round-up for stable 7.2.1 Michael Tokarev
                   ` (35 preceding siblings ...)
  2023-03-08 16:57 ` [PATCH 37/47] virtio-rng-pci: fix transitional migration compat for vectors Michael Tokarev
@ 2023-03-08 16:57 ` Michael Tokarev
  2023-03-08 16:57 ` [PATCH 39/47] vdpa: stop all svq on device deletion Michael Tokarev
                   ` (10 subsequent siblings)
  47 siblings, 0 replies; 50+ messages in thread
From: Michael Tokarev @ 2023-03-08 16:57 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-stable, Akihiko Odaki, Michael S . Tsirkin, Michael Tokarev

From: Akihiko Odaki <akihiko.odaki@daynix.com>

The expiration time provided for timer_mod() can overflow if a
ridiculously large value is set to the comparator register. The
resulting value can represent a past time after rounded, forcing the
timer to fire immediately. If the timer is configured as periodic, it
will rearm the timer again, and form an endless loop.

Check if the expiration value will overflow, and if it will, stop the
timer instead of rearming the timer with the overflowed time.

This bug was found by Alexander Bulekov when fuzzing igb, a new
network device emulation:
https://patchew.org/QEMU/20230129053316.1071513-1-alxndr@bu.edu/

The fixed test case is:
fuzz/crash_2d7036941dcda1ad4380bb8a9174ed0c949bcefd

Fixes: 16b29ae180 ("Add HPET emulation to qemu (Beth Kon)")
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Message-Id: <20230131030037.18856-1-akihiko.odaki@daynix.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit 37d2bcbc2a4e9c2e9061bec72a32c7e49b9f81ec)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
 hw/timer/hpet.c | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/hw/timer/hpet.c b/hw/timer/hpet.c
index 9520471be2..5f88ffdef8 100644
--- a/hw/timer/hpet.c
+++ b/hw/timer/hpet.c
@@ -352,6 +352,16 @@ static const VMStateDescription vmstate_hpet = {
     }
 };
 
+static void hpet_arm(HPETTimer *t, uint64_t ticks)
+{
+    if (ticks < ns_to_ticks(INT64_MAX / 2)) {
+        timer_mod(t->qemu_timer,
+                  qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + ticks_to_ns(ticks));
+    } else {
+        timer_del(t->qemu_timer);
+    }
+}
+
 /*
  * timer expiration callback
  */
@@ -374,13 +384,11 @@ static void hpet_timer(void *opaque)
             }
         }
         diff = hpet_calculate_diff(t, cur_tick);
-        timer_mod(t->qemu_timer,
-                       qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + (int64_t)ticks_to_ns(diff));
+        hpet_arm(t, diff);
     } else if (t->config & HPET_TN_32BIT && !timer_is_periodic(t)) {
         if (t->wrap_flag) {
             diff = hpet_calculate_diff(t, cur_tick);
-            timer_mod(t->qemu_timer, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) +
-                           (int64_t)ticks_to_ns(diff));
+            hpet_arm(t, diff);
             t->wrap_flag = 0;
         }
     }
@@ -407,8 +415,7 @@ static void hpet_set_timer(HPETTimer *t)
             t->wrap_flag = 1;
         }
     }
-    timer_mod(t->qemu_timer,
-                   qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + (int64_t)ticks_to_ns(diff));
+    hpet_arm(t, diff);
 }
 
 static void hpet_del_timer(HPETTimer *t)
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH 39/47] vdpa: stop all svq on device deletion
  2023-03-08 16:57 [RFC PATCH 00/47] Patch Round-up for stable 7.2.1 Michael Tokarev
                   ` (36 preceding siblings ...)
  2023-03-08 16:57 ` [PATCH 38/47] hw/timer/hpet: Fix expiration time overflow Michael Tokarev
@ 2023-03-08 16:57 ` Michael Tokarev
  2023-03-08 16:57 ` [PATCH 40/47] vhost: avoid a potential use of an uninitialized variable in vhost_svq_poll() Michael Tokarev
                   ` (9 subsequent siblings)
  47 siblings, 0 replies; 50+ messages in thread
From: Michael Tokarev @ 2023-03-08 16:57 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-stable, Eugenio Pérez, Lei Yang, Laurent Vivier,
	Jason Wang, Michael Tokarev

From: Eugenio Pérez <eperezma@redhat.com>

Not stopping them leave the device in a bad state when virtio-net
fronted device is unplugged with device_del monitor command.

This is not triggable in regular poweroff or qemu forces shutdown
because cleanup is called right after vhost_vdpa_dev_start(false).  But
devices hot unplug does not call vdpa device cleanups.  This lead to all
the vhost_vdpa devices without stop the SVQ but the last.

Fix it and clean the code, making it symmetric with
vhost_vdpa_svqs_start.

Fixes: dff4426fa656 ("vhost: Add Shadow VirtQueue kick forwarding capabilities")
Reported-by: Lei Yang <leiyang@redhat.com>
Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
Message-Id: <20230209170004.899472-1-eperezma@redhat.com>
Tested-by: Laurent Vivier <lvivier@redhat.com>
Acked-by: Jason Wang <jasowang@redhat.com>
(cherry picked from commit 2e1a9de96b487cf818a22d681cad8d3f5d18dcca)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Mjt: this required manual edit for stable-7.2
---
 hw/virtio/vhost-vdpa.c | 17 ++---------------
 1 file changed, 2 insertions(+), 15 deletions(-)

diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
index 7468e44b87..03c78d25d8 100644
--- a/hw/virtio/vhost-vdpa.c
+++ b/hw/virtio/vhost-vdpa.c
@@ -707,26 +707,11 @@ static int vhost_vdpa_get_device_id(struct vhost_dev *dev,
     return ret;
 }
 
-static void vhost_vdpa_reset_svq(struct vhost_vdpa *v)
-{
-    if (!v->shadow_vqs_enabled) {
-        return;
-    }
-
-    for (unsigned i = 0; i < v->shadow_vqs->len; ++i) {
-        VhostShadowVirtqueue *svq = g_ptr_array_index(v->shadow_vqs, i);
-        vhost_svq_stop(svq);
-    }
-}
-
 static int vhost_vdpa_reset_device(struct vhost_dev *dev)
 {
-    struct vhost_vdpa *v = dev->opaque;
     int ret;
     uint8_t status = 0;
 
-    vhost_vdpa_reset_svq(v);
-
     ret = vhost_vdpa_call(dev, VHOST_VDPA_SET_STATUS, &status);
     trace_vhost_vdpa_reset_device(dev, status);
     return ret;
@@ -1088,6 +1073,8 @@ static void vhost_vdpa_svqs_stop(struct vhost_dev *dev)
 
     for (unsigned i = 0; i < v->shadow_vqs->len; ++i) {
         VhostShadowVirtqueue *svq = g_ptr_array_index(v->shadow_vqs, i);
+
+        vhost_svq_stop(svq);
         vhost_vdpa_svq_unmap_rings(dev, svq);
     }
 }
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH 40/47] vhost: avoid a potential use of an uninitialized variable in vhost_svq_poll()
  2023-03-08 16:57 [RFC PATCH 00/47] Patch Round-up for stable 7.2.1 Michael Tokarev
                   ` (37 preceding siblings ...)
  2023-03-08 16:57 ` [PATCH 39/47] vdpa: stop all svq on device deletion Michael Tokarev
@ 2023-03-08 16:57 ` Michael Tokarev
  2023-03-08 16:57 ` [PATCH 41/47] libvhost-user: check for NULL when allocating a virtqueue element Michael Tokarev
                   ` (8 subsequent siblings)
  47 siblings, 0 replies; 50+ messages in thread
From: Michael Tokarev @ 2023-03-08 16:57 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-stable, Carlos López, Michael S . Tsirkin,
	Michael Tokarev

From: Carlos López <clopez@suse.de>

In vhost_svq_poll(), if vhost_svq_get_buf() fails due to a device
providing invalid descriptors, len is left uninitialized and returned
to the caller, potentally leaking stack data or causing undefined
behavior.

Fix this by initializing len to 0.

Found with GCC 13 and -fanalyzer (abridged):

../hw/virtio/vhost-shadow-virtqueue.c: In function ‘vhost_svq_poll’:
../hw/virtio/vhost-shadow-virtqueue.c:538:12: warning: use of uninitialized value ‘len’ [CWE-457] [-Wanalyzer-use-of-uninitialized-value]
  538 |     return len;
      |            ^~~
  ‘vhost_svq_poll’: events 1-4
    |
    |  522 | size_t vhost_svq_poll(VhostShadowVirtqueue *svq)
    |      |        ^~~~~~~~~~~~~~
    |      |        |
    |      |        (1) entry to ‘vhost_svq_poll’
    |......
    |  525 |     uint32_t len;
    |      |              ~~~
    |      |              |
    |      |              (2) region created on stack here
    |      |              (3) capacity: 4 bytes
    |......
    |  528 |         if (vhost_svq_more_used(svq)) {
    |      |             ~
    |      |             |
    |      |             (4) inlined call to ‘vhost_svq_more_used’ from ‘vhost_svq_poll’

    (...)

    |  528 |         if (vhost_svq_more_used(svq)) {
    |      |            ^~~~~~~~~~~~~~~~~~~~~~~~~
    |      |            ||
    |      |            |(8) ...to here
    |      |            (7) following ‘true’ branch...
    |......
    |  537 |     vhost_svq_get_buf(svq, &len);
    |      |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    |      |     |
    |      |     (9) calling ‘vhost_svq_get_buf’ from ‘vhost_svq_poll’
    |
    +--> ‘vhost_svq_get_buf’: events 10-11
           |
           |  416 | static VirtQueueElement *vhost_svq_get_buf(VhostShadowVirtqueue *svq,
           |      |                          ^~~~~~~~~~~~~~~~~
           |      |                          |
           |      |                          (10) entry to ‘vhost_svq_get_buf’
           |......
           |  423 |     if (!vhost_svq_more_used(svq)) {
           |      |          ~
           |      |          |
           |      |          (11) inlined call to ‘vhost_svq_more_used’ from ‘vhost_svq_get_buf’
           |

           (...)

           |
         ‘vhost_svq_get_buf’: event 14
           |
           |  423 |     if (!vhost_svq_more_used(svq)) {
           |      |        ^
           |      |        |
           |      |        (14) following ‘false’ branch...
           |
         ‘vhost_svq_get_buf’: event 15
           |
           |cc1:
           | (15): ...to here
           |
    <------+
    |
  ‘vhost_svq_poll’: events 16-17
    |
    |  537 |     vhost_svq_get_buf(svq, &len);
    |      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
    |      |     |
    |      |     (16) returning to ‘vhost_svq_poll’ from ‘vhost_svq_get_buf’
    |  538 |     return len;
    |      |            ~~~
    |      |            |
    |      |            (17) use of uninitialized value ‘len’ here

Note by  Laurent Vivier <lvivier@redhat.com>:

    The return value is only used to detect an error:

    vhost_svq_poll
        vhost_vdpa_net_cvq_add
            vhost_vdpa_net_load_cmd
                vhost_vdpa_net_load_mac
                  -> a negative return is only used to detect error
                vhost_vdpa_net_load_mq
                  -> a negative return is only used to detect error
            vhost_vdpa_net_handle_ctrl_avail
              -> a negative return is only used to detect error

Fixes: d368c0b052ad ("vhost: Do not depend on !NULL VirtQueueElement on vhost_svq_flush")
Signed-off-by: Carlos López <clopez@suse.de>
Message-Id: <20230213085747.19956-1-clopez@suse.de>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit e4dd39c699b7d63a06f686ec06ded8adbee989c1)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
 hw/virtio/vhost-shadow-virtqueue.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/virtio/vhost-shadow-virtqueue.c b/hw/virtio/vhost-shadow-virtqueue.c
index 5bd14cad96..a723073747 100644
--- a/hw/virtio/vhost-shadow-virtqueue.c
+++ b/hw/virtio/vhost-shadow-virtqueue.c
@@ -522,7 +522,7 @@ static void vhost_svq_flush(VhostShadowVirtqueue *svq,
 size_t vhost_svq_poll(VhostShadowVirtqueue *svq)
 {
     int64_t start_us = g_get_monotonic_time();
-    uint32_t len;
+    uint32_t len = 0;
 
     do {
         if (vhost_svq_more_used(svq)) {
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH 41/47] libvhost-user: check for NULL when allocating a virtqueue element
  2023-03-08 16:57 [RFC PATCH 00/47] Patch Round-up for stable 7.2.1 Michael Tokarev
                   ` (38 preceding siblings ...)
  2023-03-08 16:57 ` [PATCH 40/47] vhost: avoid a potential use of an uninitialized variable in vhost_svq_poll() Michael Tokarev
@ 2023-03-08 16:57 ` Michael Tokarev
  2023-03-08 16:57 ` [PATCH 42/47] chardev/char-socket: set s->listener = NULL in char_socket_finalize Michael Tokarev
                   ` (7 subsequent siblings)
  47 siblings, 0 replies; 50+ messages in thread
From: Michael Tokarev @ 2023-03-08 16:57 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-stable, Carlos López, Michael S . Tsirkin,
	Michael Tokarev

From: Carlos López <clopez@suse.de>

Check the return value for malloc(), avoiding a NULL pointer
dereference, and propagate error in function callers.

Found with GCC 13 and -fanalyzer:

../subprojects/libvhost-user/libvhost-user.c: In function ‘virtqueue_alloc_element’:
../subprojects/libvhost-user/libvhost-user.c:2556:19: error: dereference of possibly-NULL ‘elem’ [CWE-690] [-Werror=analyzer-possible-null-dereference]
 2556 |     elem->out_num = out_num;
      |     ~~~~~~~~~~~~~~^~~~~~~~~
  ‘virtqueue_alloc_element’: event 1
    |
    | 2554 |     assert(sz >= sizeof(VuVirtqElement));
    |      |     ^~~~~~
    |      |     |
    |      |     (1) following ‘true’ branch (when ‘sz > 31’)...
    |
  ‘virtqueue_alloc_element’: events 2-4
    |
    | 2555 |     elem = malloc(out_sg_end);
    |      |     ^~~~   ~~~~~~~~~~~~~~~~~~
    |      |     |      |
    |      |     |      (3) this call could return NULL
    |      |     (2) ...to here
    | 2556 |     elem->out_num = out_num;
    |      |     ~~~~~~~~~~~~~~~~~~~~~~~
    |      |                   |
    |      |                   (4) ‘elem’ could be NULL: unchecked value from (3)
    |

Signed-off-by: Carlos López <clopez@suse.de>
Message-Id: <20230210112514.16858-1-clopez@suse.de>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit 9c1916057a8b14411116106e5a5c0c33d551cfeb)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
 subprojects/libvhost-user/libvhost-user.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/subprojects/libvhost-user/libvhost-user.c b/subprojects/libvhost-user/libvhost-user.c
index d6ee6e7d91..b17e82b2b0 100644
--- a/subprojects/libvhost-user/libvhost-user.c
+++ b/subprojects/libvhost-user/libvhost-user.c
@@ -2547,6 +2547,10 @@ virtqueue_alloc_element(size_t sz,
 
     assert(sz >= sizeof(VuVirtqElement));
     elem = malloc(out_sg_end);
+    if (!elem) {
+        DPRINT("%s: failed to malloc virtqueue element\n", __func__);
+        return NULL;
+    }
     elem->out_num = out_num;
     elem->in_num = in_num;
     elem->in_sg = (void *)elem + in_sg_ofs;
@@ -2633,6 +2637,9 @@ vu_queue_map_desc(VuDev *dev, VuVirtq *vq, unsigned int idx, size_t sz)
 
     /* Now copy what we have collected and mapped */
     elem = virtqueue_alloc_element(sz, out_num, in_num);
+    if (!elem) {
+        return NULL;
+    }
     elem->index = idx;
     for (i = 0; i < out_num; i++) {
         elem->out_sg[i] = iov[i];
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH 42/47] chardev/char-socket: set s->listener = NULL in char_socket_finalize
  2023-03-08 16:57 [RFC PATCH 00/47] Patch Round-up for stable 7.2.1 Michael Tokarev
                   ` (39 preceding siblings ...)
  2023-03-08 16:57 ` [PATCH 41/47] libvhost-user: check for NULL when allocating a virtqueue element Michael Tokarev
@ 2023-03-08 16:57 ` Michael Tokarev
  2023-03-08 16:57 ` [PATCH 43/47] intel-iommu: fail MAP notifier without caching mode Michael Tokarev
                   ` (6 subsequent siblings)
  47 siblings, 0 replies; 50+ messages in thread
From: Michael Tokarev @ 2023-03-08 16:57 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-stable, Yajun Wu, Jiri Pirko, Marc-André Lureau,
	Michael S . Tsirkin, Michael Tokarev

From: Yajun Wu <yajunw@nvidia.com>

After live migration with virtio block device, qemu crash at:

	#0  0x000055914f46f795 in object_dynamic_cast_assert (obj=0x559151b7b090, typename=0x55914f80fbc4 "qio-channel", file=0x55914f80fb90 "/images/testvfe/sw/qemu.gerrit/include/io/channel.h", line=30, func=0x55914f80fcb8 <__func__.17257> "QIO_CHANNEL") at ../qom/object.c:872
	#1  0x000055914f480d68 in QIO_CHANNEL (obj=0x559151b7b090) at /images/testvfe/sw/qemu.gerrit/include/io/channel.h:29
	#2  0x000055914f4812f8 in qio_net_listener_set_client_func_full (listener=0x559151b7a720, func=0x55914f580b97 <tcp_chr_accept>, data=0x5591519f4ea0, notify=0x0, context=0x0) at ../io/net-listener.c:166
	#3  0x000055914f580059 in tcp_chr_update_read_handler (chr=0x5591519f4ea0) at ../chardev/char-socket.c:637
	#4  0x000055914f583dca in qemu_chr_be_update_read_handlers (s=0x5591519f4ea0, context=0x0) at ../chardev/char.c:226
	#5  0x000055914f57b7c9 in qemu_chr_fe_set_handlers_full (b=0x559152bf23a0, fd_can_read=0x0, fd_read=0x0, fd_event=0x0, be_change=0x0, opaque=0x0, context=0x0, set_open=false, sync_state=true) at ../chardev/char-fe.c:279
	#6  0x000055914f57b86d in qemu_chr_fe_set_handlers (b=0x559152bf23a0, fd_can_read=0x0, fd_read=0x0, fd_event=0x0, be_change=0x0, opaque=0x0, context=0x0, set_open=false) at ../chardev/char-fe.c:304
	#7  0x000055914f378caf in vhost_user_async_close (d=0x559152bf21a0, chardev=0x559152bf23a0, vhost=0x559152bf2420, cb=0x55914f2fb8c1 <vhost_user_blk_disconnect>) at ../hw/virtio/vhost-user.c:2725
	#8  0x000055914f2fba40 in vhost_user_blk_event (opaque=0x559152bf21a0, event=CHR_EVENT_CLOSED) at ../hw/block/vhost-user-blk.c:395
	#9  0x000055914f58388c in chr_be_event (s=0x5591519f4ea0, event=CHR_EVENT_CLOSED) at ../chardev/char.c:61
	#10 0x000055914f583905 in qemu_chr_be_event (s=0x5591519f4ea0, event=CHR_EVENT_CLOSED) at ../chardev/char.c:81
	#11 0x000055914f581275 in char_socket_finalize (obj=0x5591519f4ea0) at ../chardev/char-socket.c:1083
	#12 0x000055914f46f073 in object_deinit (obj=0x5591519f4ea0, type=0x5591519055c0) at ../qom/object.c:680
	#13 0x000055914f46f0e5 in object_finalize (data=0x5591519f4ea0) at ../qom/object.c:694
	#14 0x000055914f46ff06 in object_unref (objptr=0x5591519f4ea0) at ../qom/object.c:1202
	#15 0x000055914f4715a4 in object_finalize_child_property (obj=0x559151b76c50, name=0x559151b7b250 "char3", opaque=0x5591519f4ea0) at ../qom/object.c:1747
	#16 0x000055914f46ee86 in object_property_del_all (obj=0x559151b76c50) at ../qom/object.c:632
	#17 0x000055914f46f0d2 in object_finalize (data=0x559151b76c50) at ../qom/object.c:693
	#18 0x000055914f46ff06 in object_unref (objptr=0x559151b76c50) at ../qom/object.c:1202
	#19 0x000055914f4715a4 in object_finalize_child_property (obj=0x559151b6b560, name=0x559151b76630 "chardevs", opaque=0x559151b76c50) at ../qom/object.c:1747
	#20 0x000055914f46ef67 in object_property_del_child (obj=0x559151b6b560, child=0x559151b76c50) at ../qom/object.c:654
	#21 0x000055914f46f042 in object_unparent (obj=0x559151b76c50) at ../qom/object.c:673
	#22 0x000055914f58632a in qemu_chr_cleanup () at ../chardev/char.c:1189
	#23 0x000055914f16c66c in qemu_cleanup () at ../softmmu/runstate.c:830
	#24 0x000055914eee7b9e in qemu_default_main () at ../softmmu/main.c:38
	#25 0x000055914eee7bcc in main (argc=86, argv=0x7ffc97cb8d88) at ../softmmu/main.c:48

In char_socket_finalize after s->listener freed, event callback function
vhost_user_blk_event will be called to handle CHR_EVENT_CLOSED.
vhost_user_blk_event is calling qio_net_listener_set_client_func_full which
is still using s->listener.

Setting s->listener = NULL after object_unref(OBJECT(s->listener)) can
solve this issue.

Signed-off-by: Yajun Wu <yajunw@nvidia.com>
Acked-by: Jiri Pirko <jiri@nvidia.com>
Message-Id: <20230214021430.3638579-1-yajunw@nvidia.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit b8a7f51f59e28d5a8e0c07ed3919cc9695560ed2)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
 chardev/char-socket.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/chardev/char-socket.c b/chardev/char-socket.c
index 879564aa8a..b00efb1482 100644
--- a/chardev/char-socket.c
+++ b/chardev/char-socket.c
@@ -1065,6 +1065,7 @@ static void char_socket_finalize(Object *obj)
         qio_net_listener_set_client_func_full(s->listener, NULL, NULL,
                                               NULL, chr->gcontext);
         object_unref(OBJECT(s->listener));
+        s->listener = NULL;
     }
     if (s->tls_creds) {
         object_unref(OBJECT(s->tls_creds));
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH 43/47] intel-iommu: fail MAP notifier without caching mode
  2023-03-08 16:57 [RFC PATCH 00/47] Patch Round-up for stable 7.2.1 Michael Tokarev
                   ` (40 preceding siblings ...)
  2023-03-08 16:57 ` [PATCH 42/47] chardev/char-socket: set s->listener = NULL in char_socket_finalize Michael Tokarev
@ 2023-03-08 16:57 ` Michael Tokarev
  2023-03-08 16:57 ` [PATCH 44/47] intel-iommu: fail DEVIOTLB_UNMAP without dt mode Michael Tokarev
                   ` (5 subsequent siblings)
  47 siblings, 0 replies; 50+ messages in thread
From: Michael Tokarev @ 2023-03-08 16:57 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-stable, Jason Wang, Eric Auger, Viktor Prutyanov, Peter Xu,
	Michael S . Tsirkin, Michael Tokarev

From: Jason Wang <jasowang@redhat.com>

Without caching mode, MAP notifier won't work correctly since guest
won't send IOTLB update event when it establishes new mappings in the
I/O page tables. Let's fail the IOMMU notifiers early instead of
misbehaving silently.

Reviewed-by: Eric Auger <eric.auger@redhat.com>
Tested-by: Viktor Prutyanov <viktor@daynix.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
Message-Id: <20230223065924.42503-2-jasowang@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit b8d78277c091f26fdd64f239bc8bb7e55d74cecf)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
 hw/i386/intel_iommu.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c
index a08ee85edf..9143376677 100644
--- a/hw/i386/intel_iommu.c
+++ b/hw/i386/intel_iommu.c
@@ -3186,6 +3186,13 @@ static int vtd_iommu_notify_flag_changed(IOMMUMemoryRegion *iommu,
                          "Snoop Control with vhost or VFIO is not supported");
         return -ENOTSUP;
     }
+    if (!s->caching_mode && (new & IOMMU_NOTIFIER_MAP)) {
+        error_setg_errno(errp, ENOTSUP,
+                         "device %02x.%02x.%x requires caching mode",
+                         pci_bus_num(vtd_as->bus), PCI_SLOT(vtd_as->devfn),
+                         PCI_FUNC(vtd_as->devfn));
+        return -ENOTSUP;
+    }
 
     /* Update per-address-space notifier flags */
     vtd_as->notifier_flags = new;
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH 44/47] intel-iommu: fail DEVIOTLB_UNMAP without dt mode
  2023-03-08 16:57 [RFC PATCH 00/47] Patch Round-up for stable 7.2.1 Michael Tokarev
                   ` (41 preceding siblings ...)
  2023-03-08 16:57 ` [PATCH 43/47] intel-iommu: fail MAP notifier without caching mode Michael Tokarev
@ 2023-03-08 16:57 ` Michael Tokarev
  2023-03-08 16:57 ` [PATCH 45/47] block: Handle curl 7.55.0, 7.85.0 version changes Michael Tokarev
                   ` (4 subsequent siblings)
  47 siblings, 0 replies; 50+ messages in thread
From: Michael Tokarev @ 2023-03-08 16:57 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-stable, Jason Wang, Laurent Vivier, Viktor Prutyanov,
	Peter Xu, Michael S . Tsirkin, Michael Tokarev

From: Jason Wang <jasowang@redhat.com>

Without dt mode, device IOTLB notifier won't work since guest won't
send device IOTLB invalidation descriptor in this case. Let's fail
early instead of misbehaving silently.

Reviewed-by: Laurent Vivier <lvivier@redhat.com>
Tested-by: Laurent Vivier <lvivier@redhat.com>
Tested-by: Viktor Prutyanov <viktor@daynix.com>
Buglink: https://bugzilla.redhat.com/2156876
Signed-off-by: Jason Wang <jasowang@redhat.com>
Message-Id: <20230223065924.42503-3-jasowang@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit 09adb0e021207b60a0c51a68939b4539d98d3ef3)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
 hw/i386/intel_iommu.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c
index 9143376677..d025ef2873 100644
--- a/hw/i386/intel_iommu.c
+++ b/hw/i386/intel_iommu.c
@@ -3179,6 +3179,7 @@ static int vtd_iommu_notify_flag_changed(IOMMUMemoryRegion *iommu,
 {
     VTDAddressSpace *vtd_as = container_of(iommu, VTDAddressSpace, iommu);
     IntelIOMMUState *s = vtd_as->iommu_state;
+    X86IOMMUState *x86_iommu = X86_IOMMU_DEVICE(s);
 
     /* TODO: add support for VFIO and vhost users */
     if (s->snoop_control) {
@@ -3193,6 +3194,13 @@ static int vtd_iommu_notify_flag_changed(IOMMUMemoryRegion *iommu,
                          PCI_FUNC(vtd_as->devfn));
         return -ENOTSUP;
     }
+    if (!x86_iommu->dt_supported && (new & IOMMU_NOTIFIER_DEVIOTLB_UNMAP)) {
+        error_setg_errno(errp, ENOTSUP,
+                         "device %02x.%02x.%x requires device IOTLB mode",
+                         pci_bus_num(vtd_as->bus), PCI_SLOT(vtd_as->devfn),
+                         PCI_FUNC(vtd_as->devfn));
+        return -ENOTSUP;
+    }
 
     /* Update per-address-space notifier flags */
     vtd_as->notifier_flags = new;
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH 45/47] block: Handle curl 7.55.0, 7.85.0 version changes
  2023-03-08 16:57 [RFC PATCH 00/47] Patch Round-up for stable 7.2.1 Michael Tokarev
                   ` (42 preceding siblings ...)
  2023-03-08 16:57 ` [PATCH 44/47] intel-iommu: fail DEVIOTLB_UNMAP without dt mode Michael Tokarev
@ 2023-03-08 16:57 ` Michael Tokarev
  2023-03-08 16:57 ` [PATCH 46/47] tests/tcg: fix unused variable in linux-test Michael Tokarev
                   ` (3 subsequent siblings)
  47 siblings, 0 replies; 50+ messages in thread
From: Michael Tokarev @ 2023-03-08 16:57 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-stable, Anton Johansson, Philippe Mathieu-Daudé,
	Kevin Wolf, Michael Tokarev

From: Anton Johansson <anjo@rev.ng>

* 7.55.0 deprecates CURLINFO_CONTENT_LENGTH_DOWNLOAD in favour of a *_T
  version, which returns curl_off_t instead of a double.
* 7.85.0 deprecates CURLOPT_PROTOCOLS and CURLOPT_REDIR_PROTOCOLS in
  favour of *_STR variants, specifying the desired protocols via a
  string.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1440
Signed-off-by: Anton Johansson <anjo@rev.ng>
Message-Id: <20230123201431.23118-1-anjo@rev.ng>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
(cherry picked from commit e7b8d9d038f313c2b9e601609e7d7c3ca6ad0234)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
 block/curl.c | 44 +++++++++++++++++++++++++++++++++++++-------
 1 file changed, 37 insertions(+), 7 deletions(-)

diff --git a/block/curl.c b/block/curl.c
index cba4c4cac7..0b125095e3 100644
--- a/block/curl.c
+++ b/block/curl.c
@@ -37,8 +37,15 @@
 
 // #define DEBUG_VERBOSE
 
+/* CURL 7.85.0 switches to a string based API for specifying
+ * the desired protocols.
+ */
+#if LIBCURL_VERSION_NUM >= 0x075500
+#define PROTOCOLS "HTTP,HTTPS,FTP,FTPS"
+#else
 #define PROTOCOLS (CURLPROTO_HTTP | CURLPROTO_HTTPS | \
                    CURLPROTO_FTP | CURLPROTO_FTPS)
+#endif
 
 #define CURL_NUM_STATES 8
 #define CURL_NUM_ACB    8
@@ -509,9 +516,18 @@ static int curl_init_state(BDRVCURLState *s, CURLState *state)
          * obscure protocols.  For example, do not allow POP3/SMTP/IMAP see
          * CVE-2013-0249.
          *
-         * Restricting protocols is only supported from 7.19.4 upwards.
+         * Restricting protocols is only supported from 7.19.4 upwards. Note:
+         * version 7.85.0 deprecates CURLOPT_*PROTOCOLS in favour of a string
+         * based CURLOPT_*PROTOCOLS_STR API.
          */
-#if LIBCURL_VERSION_NUM >= 0x071304
+#if LIBCURL_VERSION_NUM >= 0x075500
+        if (curl_easy_setopt(state->curl,
+                             CURLOPT_PROTOCOLS_STR, PROTOCOLS) ||
+            curl_easy_setopt(state->curl,
+                             CURLOPT_REDIR_PROTOCOLS_STR, PROTOCOLS)) {
+            goto err;
+        }
+#elif LIBCURL_VERSION_NUM >= 0x071304
         if (curl_easy_setopt(state->curl, CURLOPT_PROTOCOLS, PROTOCOLS) ||
             curl_easy_setopt(state->curl, CURLOPT_REDIR_PROTOCOLS, PROTOCOLS)) {
             goto err;
@@ -669,7 +685,12 @@ static int curl_open(BlockDriverState *bs, QDict *options, int flags,
     const char *file;
     const char *cookie;
     const char *cookie_secret;
-    double d;
+    /* CURL >= 7.55.0 uses curl_off_t for content length instead of a double */
+#if LIBCURL_VERSION_NUM >= 0x073700
+    curl_off_t cl;
+#else
+    double cl;
+#endif
     const char *secretid;
     const char *protocol_delimiter;
     int ret;
@@ -796,27 +817,36 @@ static int curl_open(BlockDriverState *bs, QDict *options, int flags,
     }
     if (curl_easy_perform(state->curl))
         goto out;
-    if (curl_easy_getinfo(state->curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &d)) {
+    /* CURL 7.55.0 deprecates CURLINFO_CONTENT_LENGTH_DOWNLOAD in favour of
+     * the *_T version which returns a more sensible type for content length.
+     */
+#if LIBCURL_VERSION_NUM >= 0x073700
+    if (curl_easy_getinfo(state->curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD_T, &cl)) {
+        goto out;
+    }
+#else
+    if (curl_easy_getinfo(state->curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &cl)) {
         goto out;
     }
+#endif
     /* Prior CURL 7.19.4 return value of 0 could mean that the file size is not
      * know or the size is zero. From 7.19.4 CURL returns -1 if size is not
      * known and zero if it is really zero-length file. */
 #if LIBCURL_VERSION_NUM >= 0x071304
-    if (d < 0) {
+    if (cl < 0) {
         pstrcpy(state->errmsg, CURL_ERROR_SIZE,
                 "Server didn't report file size.");
         goto out;
     }
 #else
-    if (d <= 0) {
+    if (cl <= 0) {
         pstrcpy(state->errmsg, CURL_ERROR_SIZE,
                 "Unknown file size or zero-length file.");
         goto out;
     }
 #endif
 
-    s->len = d;
+    s->len = cl;
 
     if ((!strncasecmp(s->url, "http://", strlen("http://"))
         || !strncasecmp(s->url, "https://", strlen("https://")))
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH 46/47] tests/tcg: fix unused variable in linux-test
  2023-03-08 16:57 [RFC PATCH 00/47] Patch Round-up for stable 7.2.1 Michael Tokarev
                   ` (43 preceding siblings ...)
  2023-03-08 16:57 ` [PATCH 45/47] block: Handle curl 7.55.0, 7.85.0 version changes Michael Tokarev
@ 2023-03-08 16:57 ` Michael Tokarev
  2023-03-08 16:57 ` [PATCH 47/47] build-sys: fix crlf-ending C code Michael Tokarev
                   ` (2 subsequent siblings)
  47 siblings, 0 replies; 50+ messages in thread
From: Michael Tokarev @ 2023-03-08 16:57 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-stable, Alex Bennée, Philippe Mathieu-Daudé,
	Michael Tokarev

From: Alex Bennée <alex.bennee@linaro.org>

The latest hexagon compiler picks up that we never consume wcount.
Given the name of the #define that rcount checks against is WCOUNT_MAX
I figured the check just got missed.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-Id: <20221221090411.1995037-5-alex.bennee@linaro.org>
(cherry picked from commit 2bc6c79417b89c3306b724577e775f03fe61fb2e)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
 tests/tcg/multiarch/linux/linux-test.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/tests/tcg/multiarch/linux/linux-test.c b/tests/tcg/multiarch/linux/linux-test.c
index 5a2a4f2258..64f57cb287 100644
--- a/tests/tcg/multiarch/linux/linux-test.c
+++ b/tests/tcg/multiarch/linux/linux-test.c
@@ -354,13 +354,17 @@ static void test_pipe(void)
             if (FD_ISSET(fds[0], &rfds)) {
                 chk_error(read(fds[0], &ch, 1));
                 rcount++;
-                if (rcount >= WCOUNT_MAX)
+                if (rcount >= WCOUNT_MAX) {
                     break;
+                }
             }
             if (FD_ISSET(fds[1], &wfds)) {
                 ch = 'a';
                 chk_error(write(fds[1], &ch, 1));
                 wcount++;
+                if (wcount >= WCOUNT_MAX) {
+                    break;
+                }
             }
         }
     }
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH 47/47] build-sys: fix crlf-ending C code
  2023-03-08 16:57 [RFC PATCH 00/47] Patch Round-up for stable 7.2.1 Michael Tokarev
                   ` (44 preceding siblings ...)
  2023-03-08 16:57 ` [PATCH 46/47] tests/tcg: fix unused variable in linux-test Michael Tokarev
@ 2023-03-08 16:57 ` Michael Tokarev
  2023-03-08 19:22 ` [PATCH 36/47] virtio-rng-pci: fix migration compat for vectors Michael Tokarev
  2023-03-22  9:09 ` [RFC PATCH 00/47] Patch Round-up for stable 7.2.1 Thomas Huth
  47 siblings, 0 replies; 50+ messages in thread
From: Michael Tokarev @ 2023-03-08 16:57 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-stable, Marc-André Lureau, Thomas Huth,
	Alex Bennée, Michael Tokarev

From: Marc-André Lureau <marcandre.lureau@redhat.com>

On msys2, the shader-to-C script produces bad C:
./ui/shader/texture-blit-vert.h:2:5: error: missing terminating " character [-Werror]

Fix it by changing the line ending from crlf to lf, and convert the
script to Python (qemu build seems perl-free after that).

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Acked-by: Thomas Huth <thuth@redhat.com>
Message-Id: <20230110132700.833690-2-marcandre.lureau@redhat.com>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20230124180127.1881110-6-alex.bennee@linaro.org>
(cherry picked from commit e2c4012bc35894d60e54bd077ceaaae565d43c15)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
 meson.build              |  2 +-
 scripts/shaderinclude.pl | 16 ----------------
 scripts/shaderinclude.py | 26 ++++++++++++++++++++++++++
 3 files changed, 27 insertions(+), 17 deletions(-)
 delete mode 100644 scripts/shaderinclude.pl
 create mode 100644 scripts/shaderinclude.py

diff --git a/meson.build b/meson.build
index 5c6b5a1c75..b88867ca9d 100644
--- a/meson.build
+++ b/meson.build
@@ -2777,7 +2777,7 @@ config_host_data.set('CONFIG_SLIRP', slirp.found())
 genh += configure_file(output: 'config-host.h', configuration: config_host_data)
 
 hxtool = find_program('scripts/hxtool')
-shaderinclude = find_program('scripts/shaderinclude.pl')
+shaderinclude = find_program('scripts/shaderinclude.py')
 qapi_gen = find_program('scripts/qapi-gen.py')
 qapi_gen_depends = [ meson.current_source_dir() / 'scripts/qapi/__init__.py',
                      meson.current_source_dir() / 'scripts/qapi/commands.py',
diff --git a/scripts/shaderinclude.pl b/scripts/shaderinclude.pl
deleted file mode 100644
index cd3bb40b12..0000000000
--- a/scripts/shaderinclude.pl
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/usr/bin/env perl
-use strict;
-use warnings;
-
-my $file = shift;
-open FILE, "<", $file or die "open $file: $!";
-my $name = $file;
-$name =~ s|.*/||;
-$name =~ s/[-.]/_/g;
-print "static GLchar ${name}_src[] =\n";
-while (<FILE>) {
-    chomp;
-    printf "    \"%s\\n\"\n", $_;
-}
-print "    \"\\n\";\n";
-close FILE;
diff --git a/scripts/shaderinclude.py b/scripts/shaderinclude.py
new file mode 100644
index 0000000000..ab2aade2cd
--- /dev/null
+++ b/scripts/shaderinclude.py
@@ -0,0 +1,26 @@
+#!/usr/bin/env python3
+#
+# Copyright (C) 2023 Red Hat, Inc.
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+import sys
+import os
+
+
+def main(args):
+    file_path = args[1]
+    basename = os.path.basename(file_path)
+    varname = basename.replace('-', '_').replace('.', '_')
+
+    with os.fdopen(sys.stdout.fileno(), "wt", closefd=False, newline='\n') as stdout:
+        with open(file_path, "r", encoding='utf-8') as file:
+            print(f'static GLchar {varname}_src[] =', file=stdout)
+            for line in file:
+                line = line.rstrip()
+                print(f'    "{line}\\n"', file=stdout)
+            print('    "\\n";', file=stdout)
+
+
+if __name__ == '__main__':
+    sys.exit(main(sys.argv))
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH 36/47] virtio-rng-pci: fix migration compat for vectors
  2023-03-08 16:57 [RFC PATCH 00/47] Patch Round-up for stable 7.2.1 Michael Tokarev
                   ` (45 preceding siblings ...)
  2023-03-08 16:57 ` [PATCH 47/47] build-sys: fix crlf-ending C code Michael Tokarev
@ 2023-03-08 19:22 ` Michael Tokarev
  2023-03-22  9:09 ` [RFC PATCH 00/47] Patch Round-up for stable 7.2.1 Thomas Huth
  47 siblings, 0 replies; 50+ messages in thread
From: Michael Tokarev @ 2023-03-08 19:22 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-stable, Dr. David Alan Gilbert, Michael S . Tsirkin,
	Thomas Huth, David Daney, Philippe Mathieu-Daudé,
	Michael Tokarev

From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>

Fixup the migration compatibility for existing machine types
so that they do not enable msi-x.

Symptom:

(qemu) qemu: get_pci_config_device: Bad config data: i=0x34 read: 84 device: 98 cmask: ff wmask: 0 w1cmask:0
qemu: Failed to load PCIDevice:config
qemu: Failed to load virtio-rng:virtio
qemu: error while loading state for instance 0x0 of device '0000:00:03.0/virtio-rng'
qemu: load of migration failed: Invalid argument

Note: This fix will break migration from 7.2->7.2-fixed with this patch

bz: https://bugzilla.redhat.com/show_bug.cgi?id=2155749
Fixes: 9ea02e8f1 ("virtio-rng-pci: Allow setting nvectors, so we can use MSI-X")

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Message-Id: <20230109105809.163975-1-dgilbert@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Acked-by: David Daney <david.daney@fungible.com>
Fixes: 9ea02e8f1 ("virtio-rng-pci: Allow setting nvectors, so we can use MSI-X")
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
(cherry picked from commit bad9c5a5166fd5e3a892b7b0477cf2f4bd3a959a)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
 hw/core/machine.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/core/machine.c b/hw/core/machine.c
index 8d34caa31d..77a0a131d1 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -42,6 +42,7 @@
 
 GlobalProperty hw_compat_7_1[] = {
     { "virtio-device", "queue_reset", "false" },
+    { "virtio-rng-pci", "vectors", "0" },
 };
 const size_t hw_compat_7_1_len = G_N_ELEMENTS(hw_compat_7_1);
 
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 50+ messages in thread

* Re: [RFC PATCH 00/47] Patch Round-up for stable 7.2.1
  2023-03-08 16:57 [RFC PATCH 00/47] Patch Round-up for stable 7.2.1 Michael Tokarev
                   ` (46 preceding siblings ...)
  2023-03-08 19:22 ` [PATCH 36/47] virtio-rng-pci: fix migration compat for vectors Michael Tokarev
@ 2023-03-22  9:09 ` Thomas Huth
  2023-03-22 20:27   ` Michael Tokarev
  47 siblings, 1 reply; 50+ messages in thread
From: Thomas Huth @ 2023-03-22  9:09 UTC (permalink / raw)
  To: Michael Tokarev, qemu-devel; +Cc: qemu-stable

On 08/03/2023 17.57, Michael Tokarev wrote:
> Hello!
> 
> This is my first attempt to perform a stable qemu release.
> Doing it in a way similar to how Michael Roth did it before :)
> But since this is my first attempt, this is an RFC for now.
> 
> The following new patches are queued for QEMU stable v7.2.1:
> 
>    https://gitlab.com/mjt0k/qemu/-/commits/stable-7.2-staging/
> 
> Please respond here or CC qemu-stable@nongnu.org on any additional patches
> you think should (or shouldn't) be included in the release.
> 
> About some of the patches.
> 
> I picked up a few more than minimally necessary so that some of the CI
> tests are fixed. These are the curl forward compat change, two changes
> for tests/, and also "build-sys: fix crlf-ending C code" (fixes build
> failure on msys-win32). The same failures exists on 7.2.0 now, while
> the proposed 7.2.1 passes all tests I've tried so far (will try avocado
> tests too once additional hdd will arrive).
> 
> Two patches ("vdpa: stop all svq on device deletion" and "Revert "hw/i386:
> pass RNG seed via setup_data entry"") required conflict resolution when
> cherry-picking.
> 
> 2 virtio-rng-pci migration fixes makes certain v7.2.0 VMs non-migratable
> to v7.2.1.
> 
> -----------------------------------------------------------------------
> 
> Akihiko Odaki (4):
>    vhost-user-gpio: Configure vhost_dev when connecting
>    vhost-user-i2c: Back up vqs before cleaning up vhost_dev
>    vhost-user-rng: Back up vqs before cleaning up vhost_dev
>    hw/timer/hpet: Fix expiration time overflow
> 
> Alex Bennée (2):
>    target/arm: fix handling of HLT semihosting in system mode
>    tests/tcg: fix unused variable in linux-test
> 
> Anton Johansson (1):
>    block: Handle curl 7.55.0, 7.85.0 version changes
> 
> Carlos López (2):
>    vhost: avoid a potential use of an uninitialized variable in
>      vhost_svq_poll()
>    libvhost-user: check for NULL when allocating a virtqueue element
> 
> Chenyi Qiang (2):
>    virtio-mem: Fix the bitmap index of the section offset
>    virtio-mem: Fix the iterator variable in a vmem->rdl_list loop
> 
> David Hildenbrand (2):
>    migration/ram: Fix error handling in ram_write_tracking_start()
>    migration/ram: Fix populate_read_range()
> 
> Dr. David Alan Gilbert (2):
>    virtio-rng-pci: fix migration compat for vectors
>    virtio-rng-pci: fix transitional migration compat for vectors
> 
> Eugenio Pérez (1):
>    vdpa: stop all svq on device deletion
> 
> Evgeny Iakovlev (1):
>    target/arm: allow writes to SCR_EL3.HXEn bit when FEAT_HCX is enabled
> 
> Guenter Roeck (1):
>    target/sh4: Mask restore of env->flags from tb->flags
> 
> Jason Wang (3):
>    vhost: fix vq dirty bitmap syncing when vIOMMU is enabled
>    intel-iommu: fail MAP notifier without caching mode
>    intel-iommu: fail DEVIOTLB_UNMAP without dt mode
> 
> Julia Suvorova (1):
>    hw/smbios: fix field corruption in type 4 table
> 
> Kevin Wolf (1):
>    qcow2: Fix theoretical corruption in store_bitmap() error path
> 
> Klaus Jensen (2):
>    hw/nvme: fix missing endian conversions for doorbell buffers
>    hw/nvme: fix missing cq eventidx update
> 
> Laszlo Ersek (1):
>    acpi: cpuhp: fix guest-visible maximum access size to the legacy reg
>      block
> 
> Marc-André Lureau (1):
>    build-sys: fix crlf-ending C code
> 
> Michael S. Tsirkin (6):
>    Revert "x86: do not re-randomize RNG seed on snapshot load"
>    Revert "x86: re-initialize RNG seed when selecting kernel"
>    Revert "x86: reinitialize RNG seed on system reboot"
>    Revert "x86: use typedef for SetupData struct"
>    Revert "x86: return modified setup_data only if read as memory, not as
>      file"
>    Revert "hw/i386: pass RNG seed via setup_data entry"
> 
> Paolo Bonzini (4):
>    meson: accept relative symlinks in "meson introspect --installed" data
>    configure: fix GLIB_VERSION for cross-compilation
>    target/i386: fix ADOX followed by ADCX
>    block/iscsi: fix double-free on BUSY or similar statuses
> 
> Richard Henderson (8):
>    target/riscv: Set pc_succ_insn for !rvc illegal insn
>    target/arm: Fix sve_probe_page
>    target/arm: Fix in_debug path in S1_ptw_translate
>    target/arm: Fix physical address resolution for Stage2
>    tests/tcg/i386: Introduce and use reg_t consistently
>    target/i386: Fix BEXTR instruction
>    target/i386: Fix C flag for BLSI, BLSMSK, BLSR
>    target/i386: Fix BZHI instruction
> 
> Stefan Hajnoczi (1):
>    block: fix detect-zeroes= with BDRV_REQ_REGISTERED_BUF
> 
> Yajun Wu (1):
>    chardev/char-socket: set s->listener = NULL in char_socket_finalize

Maybe pick also these patches that mention "CVE" in the description:

  qga/win32: Remove change action from MSI installer
  qga/win32: Use rundll for VSS installation
  hw/net/vmxnet3: allow VMXNET3_MAX_MTU itself as a value
  hw/pvrdma: Protect against buggy or malicious guest driver

 From my s390x perspective, I'd like to suggest the following
patches (if they can be applied cleanly):

  target/s390x/arch_dump: Fix memory corruption in s390x_write_elf64_notes()
  target/s390x: Fix emulation of C(G)HRL
  target/s390x: Fix R[NOX]SBG with T=1
  target/s390x: Fix EXECUTE of relative long instructions

  Thanks,
   Thomas



^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [RFC PATCH 00/47] Patch Round-up for stable 7.2.1
  2023-03-22  9:09 ` [RFC PATCH 00/47] Patch Round-up for stable 7.2.1 Thomas Huth
@ 2023-03-22 20:27   ` Michael Tokarev
  0 siblings, 0 replies; 50+ messages in thread
From: Michael Tokarev @ 2023-03-22 20:27 UTC (permalink / raw)
  To: Thomas Huth, qemu-devel; +Cc: qemu-stable

22.03.2023 12:09, Thomas Huth пишет:
...> Maybe pick also these patches that mention "CVE" in the description:
> 
>   qga/win32: Remove change action from MSI installer
>   qga/win32: Use rundll for VSS installation

Yes, that one is a good idea.

>   hw/net/vmxnet3: allow VMXNET3_MAX_MTU itself as a value

Simple, picked up.

>   hw/pvrdma: Protect against buggy or malicious guest driver

This one has been in debian for quite a long time, it is finally
applied upstream, which is very good.

>  From my s390x perspective, I'd like to suggest the following
> patches (if they can be applied cleanly):
> 
>   target/s390x/arch_dump: Fix memory corruption in s390x_write_elf64_notes()
>   target/s390x: Fix emulation of C(G)HRL

Ok.

>   target/s390x: Fix R[NOX]SBG with T=1

9701596d821 says, in the commit message:

     Exposed by commit e2e641fa3d5 ("tcg: Change default temp lifetime to
     TEMP_TB").

Without this commit (e2e641fa3d5), commit 9701596d821 makes little sense
I think. Also, commit 9701596d821 applies after dd161de75f3
"target/s390x: Remove g_out, g_out2, g_in1, g_in2 from DisasContext".

>   target/s390x: Fix EXECUTE of relative long instructions

This one needs "target/s390x: Split out gen_ri2" first, it looks
like it's harmless to have.

Thank you very much for the suggestions, Thomas!

/mjt


^ permalink raw reply	[flat|nested] 50+ messages in thread

end of thread, other threads:[~2023-03-22 20:28 UTC | newest]

Thread overview: 50+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-08 16:57 [RFC PATCH 00/47] Patch Round-up for stable 7.2.1 Michael Tokarev
2023-03-08 16:57 ` [PATCH 01/47] target/sh4: Mask restore of env->flags from tb->flags Michael Tokarev
2023-03-08 16:57 ` [PATCH 02/47] vhost: fix vq dirty bitmap syncing when vIOMMU is enabled Michael Tokarev
2023-03-08 16:57 ` [PATCH 03/47] virtio-mem: Fix the bitmap index of the section offset Michael Tokarev
2023-03-08 16:57 ` [PATCH 04/47] virtio-mem: Fix the iterator variable in a vmem->rdl_list loop Michael Tokarev
2023-03-08 16:57 ` [PATCH 05/47] target/arm: fix handling of HLT semihosting in system mode Michael Tokarev
2023-03-08 16:57 ` [PATCH 06/47] meson: accept relative symlinks in "meson introspect --installed" data Michael Tokarev
2023-03-08 16:57 ` [PATCH 07/47] target/riscv: Set pc_succ_insn for !rvc illegal insn Michael Tokarev
2023-03-08 16:57 ` [PATCH 08/47] acpi: cpuhp: fix guest-visible maximum access size to the legacy reg block Michael Tokarev
2023-03-08 16:57 ` [PATCH 09/47] hw/nvme: fix missing endian conversions for doorbell buffers Michael Tokarev
2023-03-08 16:57 ` [PATCH 10/47] hw/nvme: fix missing cq eventidx update Michael Tokarev
2023-03-08 16:57 ` [PATCH 11/47] configure: fix GLIB_VERSION for cross-compilation Michael Tokarev
2023-03-08 16:57 ` [PATCH 12/47] target/arm: Fix sve_probe_page Michael Tokarev
2023-03-08 16:57 ` [PATCH 13/47] target/arm: allow writes to SCR_EL3.HXEn bit when FEAT_HCX is enabled Michael Tokarev
2023-03-08 16:57 ` [PATCH 14/47] target/arm: Fix in_debug path in S1_ptw_translate Michael Tokarev
2023-03-08 16:57 ` [PATCH 15/47] target/arm: Fix physical address resolution for Stage2 Michael Tokarev
2023-03-08 16:57 ` [PATCH 16/47] migration/ram: Fix error handling in ram_write_tracking_start() Michael Tokarev
2023-03-08 16:57 ` [PATCH 17/47] migration/ram: Fix populate_read_range() Michael Tokarev
2023-03-08 16:57 ` [PATCH 18/47] qcow2: Fix theoretical corruption in store_bitmap() error path Michael Tokarev
2023-03-08 16:57 ` [PATCH 19/47] block: fix detect-zeroes= with BDRV_REQ_REGISTERED_BUF Michael Tokarev
2023-03-08 16:57 ` [PATCH 20/47] tests/tcg/i386: Introduce and use reg_t consistently Michael Tokarev
2023-03-08 16:57 ` [PATCH 21/47] target/i386: Fix BEXTR instruction Michael Tokarev
2023-03-08 16:57 ` [PATCH 22/47] target/i386: Fix C flag for BLSI, BLSMSK, BLSR Michael Tokarev
2023-03-08 16:57 ` [PATCH 23/47] target/i386: fix ADOX followed by ADCX Michael Tokarev
2023-03-08 16:57 ` [PATCH 24/47] target/i386: Fix BZHI instruction Michael Tokarev
2023-03-08 16:57 ` [PATCH 25/47] block/iscsi: fix double-free on BUSY or similar statuses Michael Tokarev
2023-03-08 16:57 ` [PATCH 26/47] hw/smbios: fix field corruption in type 4 table Michael Tokarev
2023-03-08 16:57 ` [PATCH 27/47] Revert "x86: do not re-randomize RNG seed on snapshot load" Michael Tokarev
2023-03-08 16:57 ` [PATCH 28/47] Revert "x86: re-initialize RNG seed when selecting kernel" Michael Tokarev
2023-03-08 16:57 ` [PATCH 29/47] Revert "x86: reinitialize RNG seed on system reboot" Michael Tokarev
2023-03-08 16:57 ` [PATCH 30/47] Revert "x86: use typedef for SetupData struct" Michael Tokarev
2023-03-08 16:57 ` [PATCH 31/47] Revert "x86: return modified setup_data only if read as memory, not as file" Michael Tokarev
2023-03-08 16:57 ` [PATCH 32/47] Revert "hw/i386: pass RNG seed via setup_data entry" Michael Tokarev
2023-03-08 16:57 ` [PATCH 33/47] vhost-user-gpio: Configure vhost_dev when connecting Michael Tokarev
2023-03-08 16:57 ` [PATCH 34/47] vhost-user-i2c: Back up vqs before cleaning up vhost_dev Michael Tokarev
2023-03-08 16:57 ` [PATCH 35/47] vhost-user-rng: " Michael Tokarev
2023-03-08 16:57 ` [PATCH 37/47] virtio-rng-pci: fix transitional migration compat for vectors Michael Tokarev
2023-03-08 16:57 ` [PATCH 38/47] hw/timer/hpet: Fix expiration time overflow Michael Tokarev
2023-03-08 16:57 ` [PATCH 39/47] vdpa: stop all svq on device deletion Michael Tokarev
2023-03-08 16:57 ` [PATCH 40/47] vhost: avoid a potential use of an uninitialized variable in vhost_svq_poll() Michael Tokarev
2023-03-08 16:57 ` [PATCH 41/47] libvhost-user: check for NULL when allocating a virtqueue element Michael Tokarev
2023-03-08 16:57 ` [PATCH 42/47] chardev/char-socket: set s->listener = NULL in char_socket_finalize Michael Tokarev
2023-03-08 16:57 ` [PATCH 43/47] intel-iommu: fail MAP notifier without caching mode Michael Tokarev
2023-03-08 16:57 ` [PATCH 44/47] intel-iommu: fail DEVIOTLB_UNMAP without dt mode Michael Tokarev
2023-03-08 16:57 ` [PATCH 45/47] block: Handle curl 7.55.0, 7.85.0 version changes Michael Tokarev
2023-03-08 16:57 ` [PATCH 46/47] tests/tcg: fix unused variable in linux-test Michael Tokarev
2023-03-08 16:57 ` [PATCH 47/47] build-sys: fix crlf-ending C code Michael Tokarev
2023-03-08 19:22 ` [PATCH 36/47] virtio-rng-pci: fix migration compat for vectors Michael Tokarev
2023-03-22  9:09 ` [RFC PATCH 00/47] Patch Round-up for stable 7.2.1 Thomas Huth
2023-03-22 20:27   ` Michael Tokarev

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).