All of lore.kernel.org
 help / color / mirror / Atom feed
* [PULL 00/29] Misc patches for 2023-01-10
@ 2023-01-10 16:02 Paolo Bonzini
  2023-01-10 16:02 ` [PULL 01/29] configure: fix GLIB_VERSION for cross-compilation Paolo Bonzini
                   ` (29 more replies)
  0 siblings, 30 replies; 37+ messages in thread
From: Paolo Bonzini @ 2023-01-10 16:02 UTC (permalink / raw)
  To: qemu-devel

The following changes since commit 3d83b78285d6e96636130f7d449fd02e2d4deee0:

  Merge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging (2023-01-08 14:27:40 +0000)

are available in the Git repository at:

  https://gitlab.com/bonzini/qemu.git tags/for-upstream

for you to fetch changes up to cd78f1d264c1ac7dfd7fa50abce0dec71a1f41ac:

  configure: remove backwards-compatibility code (2023-01-09 16:54:56 +0100)

----------------------------------------------------------------
* Atomic memslot updates for KVM (Emanuele, David)
* libvhost-user/libvduse warnings fixes (Marcel)
* i386 TCG fixes (Joe, myself)
* Remove compilation errors when -Werror=maybe-uninitialized (Eric)
* fix GLIB_VERSION for cross-compilation (Paolo)

----------------------------------------------------------------
Daniel P. Berrangé (8):
      gitlab: remove redundant setting of PKG_CONFIG_PATH
      disas: add G_GNUC_PRINTF to gstring_printf
      hw/xen: use G_GNUC_PRINTF/SCANF for various functions
      tools/virtiofsd: add G_GNUC_PRINTF for logging functions
      util/error: add G_GNUC_PRINTF for various functions
      tests: add G_GNUC_PRINTF for various functions
      enforce use of G_GNUC_PRINTF attributes
      hw/display: avoid creating empty loadable modules

David Hildenbrand (1):
      kvm: Atomic memslot updates

Emanuele Giuseppe Esposito (2):
      accel: introduce accelerator blocker API
      KVM: keep track of running ioctls

Eric Auger (1):
      target/i386: Remove compilation errors when -Werror=maybe-uninitialized

Joe Richey (1):
      i386: Emit correct error code for 64-bit IDT entry

Marcel Holtmann (12):
      libvhost-user: Provide _GNU_SOURCE when compiling outside of QEMU
      libvhost-user: Replace typeof with __typeof__
      libvhost-user: Cast rc variable to avoid compiler warning
      libvhost-user: Use unsigned int i for some for-loop iterations
      libvhost-user: Declare uffdio_register early to make it C90 compliant
      libvhost-user: Change dev->postcopy_ufd assignment to make it C90 compliant
      libvduse: Provide _GNU_SOURCE when compiling outside of QEMU
      libvduse: Switch to unsigned int for inuse field in struct VduseVirtq
      libvduse: Fix assignment in vring_set_avail_event
      libvhost-user: Fix assignment in vring_set_avail_event
      libvhost-user: Add extra compiler warnings
      libvduse: Add extra compiler warnings

Paolo Bonzini (4):
      configure: fix GLIB_VERSION for cross-compilation
      chardev: clean up chardev-parallel.c
      target/i386: fix operand size of unary SSE operations
      configure: remove backwards-compatibility code

 .gitlab-ci.d/crossbuild-template.yml      |   9 +-
 accel/accel-blocker.c                     | 154 ++++++++++++++++++++++++++++++
 accel/kvm/kvm-all.c                       | 108 ++++++++++++++++++---
 accel/meson.build                         |   2 +-
 chardev/char-parallel.c                   |  15 +--
 chardev/meson.build                       |   5 +-
 configure                                 |  14 +--
 disas.c                                   |   3 +-
 hw/core/cpu-common.c                      |   2 +
 hw/display/meson.build                    |  20 ++--
 hw/xen/xen-bus.c                          |   1 +
 hw/xen/xen_pvdev.c                        |   1 +
 include/hw/core/cpu.h                     |   3 +
 include/hw/xen/xen-bus-helper.h           |   6 +-
 include/hw/xen/xen-bus.h                  |   3 +-
 include/qemu/osdep.h                      |   5 -
 include/sysemu/accel-blocker.h            |  56 +++++++++++
 include/sysemu/kvm_int.h                  |   8 ++
 subprojects/libvduse/libvduse.c           |   9 +-
 subprojects/libvduse/meson.build          |   8 +-
 subprojects/libvhost-user/libvhost-user.c |  36 ++++---
 subprojects/libvhost-user/meson.build     |   8 +-
 target/i386/ops_sse.h                     |   4 +-
 target/i386/tcg/decode-new.c.inc          |  11 ++-
 target/i386/tcg/seg_helper.c              |   8 +-
 tests/qtest/ahci-test.c                   |   3 +
 tests/qtest/arm-cpu-features.c            |   1 +
 tests/qtest/erst-test.c                   |   2 +-
 tests/qtest/ide-test.c                    |   3 +-
 tests/qtest/ivshmem-test.c                |   4 +-
 tests/qtest/libqmp.c                      |   2 +-
 tests/qtest/libqos/libqos-pc.h            |   6 +-
 tests/qtest/libqos/libqos-spapr.h         |   6 +-
 tests/qtest/libqos/libqos.h               |   6 +-
 tests/qtest/libqos/virtio-9p.c            |   1 +
 tests/qtest/migration-helpers.h           |   1 +
 tests/qtest/rtas-test.c                   |   2 +-
 tests/qtest/usb-hcd-uhci-test.c           |   4 +-
 tests/unit/test-qmp-cmds.c                |  13 ++-
 tools/virtiofsd/fuse_log.c                |   1 +
 tools/virtiofsd/fuse_log.h                |   6 +-
 tools/virtiofsd/passthrough_ll.c          |   1 +
 util/error-report.c                       |   1 +
 util/error.c                              |   1 +
 util/meson.build                          |   2 +-
 45 files changed, 454 insertions(+), 111 deletions(-)
 create mode 100644 accel/accel-blocker.c
 create mode 100644 include/sysemu/accel-blocker.h
-- 
2.38.1



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

* [PULL 01/29] configure: fix GLIB_VERSION for cross-compilation
  2023-01-10 16:02 [PULL 00/29] Misc patches for 2023-01-10 Paolo Bonzini
@ 2023-01-10 16:02 ` Paolo Bonzini
  2023-01-10 16:02 ` [PULL 02/29] i386: Emit correct error code for 64-bit IDT entry Paolo Bonzini
                   ` (28 subsequent siblings)
  29 siblings, 0 replies; 37+ messages in thread
From: Paolo Bonzini @ 2023-01-10 16:02 UTC (permalink / raw)
  To: qemu-devel
  Cc: Валентин, qemu-stable

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>
---
 configure | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure b/configure
index 22818926576c..6f5e77a71361 100755
--- a/configure
+++ b/configure
@@ -2375,7 +2375,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.38.1



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

* [PULL 02/29] i386: Emit correct error code for 64-bit IDT entry
  2023-01-10 16:02 [PULL 00/29] Misc patches for 2023-01-10 Paolo Bonzini
  2023-01-10 16:02 ` [PULL 01/29] configure: fix GLIB_VERSION for cross-compilation Paolo Bonzini
@ 2023-01-10 16:02 ` Paolo Bonzini
  2023-01-10 16:02 ` [PULL 03/29] accel: introduce accelerator blocker API Paolo Bonzini
                   ` (27 subsequent siblings)
  29 siblings, 0 replies; 37+ messages in thread
From: Paolo Bonzini @ 2023-01-10 16:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: Joe Richey

From: Joe Richey <joerichey@google.com>

When in 64-bit mode, IDT entiries are 16 bytes, so `intno * 16` is used
for base/limit/offset calculations. However, even in 64-bit mode, the
exception error code still uses bits [3,16) for the invlaid interrupt
index.

This means the error code should still be `intno * 8 + 2` even in 64-bit
mode.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1382
Signed-off-by: Joe Richey <joerichey@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 target/i386/tcg/seg_helper.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/target/i386/tcg/seg_helper.c b/target/i386/tcg/seg_helper.c
index 539189b4d184..03b58e94a2d4 100644
--- a/target/i386/tcg/seg_helper.c
+++ b/target/i386/tcg/seg_helper.c
@@ -882,7 +882,7 @@ static void do_interrupt64(CPUX86State *env, int intno, int is_int,
 
     dt = &env->idt;
     if (intno * 16 + 15 > dt->limit) {
-        raise_exception_err(env, EXCP0D_GPF, intno * 16 + 2);
+        raise_exception_err(env, EXCP0D_GPF, intno * 8 + 2);
     }
     ptr = dt->base + intno * 16;
     e1 = cpu_ldl_kernel(env, ptr);
@@ -895,18 +895,18 @@ static void do_interrupt64(CPUX86State *env, int intno, int is_int,
     case 15: /* 386 trap gate */
         break;
     default:
-        raise_exception_err(env, EXCP0D_GPF, intno * 16 + 2);
+        raise_exception_err(env, EXCP0D_GPF, intno * 8 + 2);
         break;
     }
     dpl = (e2 >> DESC_DPL_SHIFT) & 3;
     cpl = env->hflags & HF_CPL_MASK;
     /* check privilege if software int */
     if (is_int && dpl < cpl) {
-        raise_exception_err(env, EXCP0D_GPF, intno * 16 + 2);
+        raise_exception_err(env, EXCP0D_GPF, intno * 8 + 2);
     }
     /* check valid bit */
     if (!(e2 & DESC_P_MASK)) {
-        raise_exception_err(env, EXCP0B_NOSEG, intno * 16 + 2);
+        raise_exception_err(env, EXCP0B_NOSEG, intno * 8 + 2);
     }
     selector = e1 >> 16;
     offset = ((target_ulong)e3 << 32) | (e2 & 0xffff0000) | (e1 & 0x0000ffff);
-- 
2.38.1



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

* [PULL 03/29] accel: introduce accelerator blocker API
  2023-01-10 16:02 [PULL 00/29] Misc patches for 2023-01-10 Paolo Bonzini
  2023-01-10 16:02 ` [PULL 01/29] configure: fix GLIB_VERSION for cross-compilation Paolo Bonzini
  2023-01-10 16:02 ` [PULL 02/29] i386: Emit correct error code for 64-bit IDT entry Paolo Bonzini
@ 2023-01-10 16:02 ` Paolo Bonzini
  2023-01-10 16:02 ` [PULL 04/29] KVM: keep track of running ioctls Paolo Bonzini
                   ` (26 subsequent siblings)
  29 siblings, 0 replies; 37+ messages in thread
From: Paolo Bonzini @ 2023-01-10 16:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: Emanuele Giuseppe Esposito, Philippe Mathieu-Daudé

From: Emanuele Giuseppe Esposito <eesposit@redhat.com>

This API allows the accelerators to prevent vcpus from issuing
new ioctls while execting a critical section marked with the
accel_ioctl_inhibit_begin/end functions.

Note that all functions submitting ioctls must mark where the
ioctl is being called with accel_{cpu_}ioctl_begin/end().

This API requires the caller to always hold the BQL.
API documentation is in sysemu/accel-blocker.h

Internally, it uses a QemuLockCnt together with a per-CPU QemuLockCnt
(to minimize cache line bouncing) to keep avoid that new ioctls
run when the critical section starts, and a QemuEvent to wait
that all running ioctls finish.

Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-Id: <20221111154758.1372674-2-eesposit@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 accel/accel-blocker.c          | 154 +++++++++++++++++++++++++++++++++
 accel/meson.build              |   2 +-
 hw/core/cpu-common.c           |   2 +
 include/hw/core/cpu.h          |   3 +
 include/sysemu/accel-blocker.h |  56 ++++++++++++
 util/meson.build               |   2 +-
 6 files changed, 217 insertions(+), 2 deletions(-)
 create mode 100644 accel/accel-blocker.c
 create mode 100644 include/sysemu/accel-blocker.h

diff --git a/accel/accel-blocker.c b/accel/accel-blocker.c
new file mode 100644
index 000000000000..1e7f423462df
--- /dev/null
+++ b/accel/accel-blocker.c
@@ -0,0 +1,154 @@
+/*
+ * Lock to inhibit accelerator ioctls
+ *
+ * Copyright (c) 2022 Red Hat Inc.
+ *
+ * Author: Emanuele Giuseppe Esposito       <eesposit@redhat.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include "qemu/osdep.h"
+#include "qemu/thread.h"
+#include "qemu/main-loop.h"
+#include "hw/core/cpu.h"
+#include "sysemu/accel-blocker.h"
+
+static QemuLockCnt accel_in_ioctl_lock;
+static QemuEvent accel_in_ioctl_event;
+
+void accel_blocker_init(void)
+{
+    qemu_lockcnt_init(&accel_in_ioctl_lock);
+    qemu_event_init(&accel_in_ioctl_event, false);
+}
+
+void accel_ioctl_begin(void)
+{
+    if (likely(qemu_mutex_iothread_locked())) {
+        return;
+    }
+
+    /* block if lock is taken in kvm_ioctl_inhibit_begin() */
+    qemu_lockcnt_inc(&accel_in_ioctl_lock);
+}
+
+void accel_ioctl_end(void)
+{
+    if (likely(qemu_mutex_iothread_locked())) {
+        return;
+    }
+
+    qemu_lockcnt_dec(&accel_in_ioctl_lock);
+    /* change event to SET. If event was BUSY, wake up all waiters */
+    qemu_event_set(&accel_in_ioctl_event);
+}
+
+void accel_cpu_ioctl_begin(CPUState *cpu)
+{
+    if (unlikely(qemu_mutex_iothread_locked())) {
+        return;
+    }
+
+    /* block if lock is taken in kvm_ioctl_inhibit_begin() */
+    qemu_lockcnt_inc(&cpu->in_ioctl_lock);
+}
+
+void accel_cpu_ioctl_end(CPUState *cpu)
+{
+    if (unlikely(qemu_mutex_iothread_locked())) {
+        return;
+    }
+
+    qemu_lockcnt_dec(&cpu->in_ioctl_lock);
+    /* change event to SET. If event was BUSY, wake up all waiters */
+    qemu_event_set(&accel_in_ioctl_event);
+}
+
+static bool accel_has_to_wait(void)
+{
+    CPUState *cpu;
+    bool needs_to_wait = false;
+
+    CPU_FOREACH(cpu) {
+        if (qemu_lockcnt_count(&cpu->in_ioctl_lock)) {
+            /* exit the ioctl, if vcpu is running it */
+            qemu_cpu_kick(cpu);
+            needs_to_wait = true;
+        }
+    }
+
+    return needs_to_wait || qemu_lockcnt_count(&accel_in_ioctl_lock);
+}
+
+void accel_ioctl_inhibit_begin(void)
+{
+    CPUState *cpu;
+
+    /*
+     * We allow to inhibit only when holding the BQL, so we can identify
+     * when an inhibitor wants to issue an ioctl easily.
+     */
+    g_assert(qemu_mutex_iothread_locked());
+
+    /* Block further invocations of the ioctls outside the BQL.  */
+    CPU_FOREACH(cpu) {
+        qemu_lockcnt_lock(&cpu->in_ioctl_lock);
+    }
+    qemu_lockcnt_lock(&accel_in_ioctl_lock);
+
+    /* Keep waiting until there are running ioctls */
+    while (true) {
+
+        /* Reset event to FREE. */
+        qemu_event_reset(&accel_in_ioctl_event);
+
+        if (accel_has_to_wait()) {
+            /*
+             * If event is still FREE, and there are ioctls still in progress,
+             * wait.
+             *
+             *  If an ioctl finishes before qemu_event_wait(), it will change
+             * the event state to SET. This will prevent qemu_event_wait() from
+             * blocking, but it's not a problem because if other ioctls are
+             * still running the loop will iterate once more and reset the event
+             * status to FREE so that it can wait properly.
+             *
+             * If an ioctls finishes while qemu_event_wait() is blocking, then
+             * it will be waken up, but also here the while loop makes sure
+             * to re-enter the wait if there are other running ioctls.
+             */
+            qemu_event_wait(&accel_in_ioctl_event);
+        } else {
+            /* No ioctl is running */
+            return;
+        }
+    }
+}
+
+void accel_ioctl_inhibit_end(void)
+{
+    CPUState *cpu;
+
+    qemu_lockcnt_unlock(&accel_in_ioctl_lock);
+    CPU_FOREACH(cpu) {
+        qemu_lockcnt_unlock(&cpu->in_ioctl_lock);
+    }
+}
+
diff --git a/accel/meson.build b/accel/meson.build
index 3a480cc2efef..49558dd232c2 100644
--- a/accel/meson.build
+++ b/accel/meson.build
@@ -1,4 +1,4 @@
-specific_ss.add(files('accel-common.c'))
+specific_ss.add(files('accel-common.c', 'accel-blocker.c'))
 softmmu_ss.add(files('accel-softmmu.c'))
 user_ss.add(files('accel-user.c'))
 
diff --git a/hw/core/cpu-common.c b/hw/core/cpu-common.c
index b177e761f010..5ccc3837b678 100644
--- a/hw/core/cpu-common.c
+++ b/hw/core/cpu-common.c
@@ -238,6 +238,7 @@ static void cpu_common_initfn(Object *obj)
     cpu->cflags_next_tb = -1;
 
     qemu_mutex_init(&cpu->work_mutex);
+    qemu_lockcnt_init(&cpu->in_ioctl_lock);
     QSIMPLEQ_INIT(&cpu->work_list);
     QTAILQ_INIT(&cpu->breakpoints);
     QTAILQ_INIT(&cpu->watchpoints);
@@ -249,6 +250,7 @@ static void cpu_common_finalize(Object *obj)
 {
     CPUState *cpu = CPU(obj);
 
+    qemu_lockcnt_destroy(&cpu->in_ioctl_lock);
     qemu_mutex_destroy(&cpu->work_mutex);
 }
 
diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h
index 88305461212f..2417597236bc 100644
--- a/include/hw/core/cpu.h
+++ b/include/hw/core/cpu.h
@@ -398,6 +398,9 @@ struct CPUState {
     uint32_t kvm_fetch_index;
     uint64_t dirty_pages;
 
+    /* Use by accel-block: CPU is executing an ioctl() */
+    QemuLockCnt in_ioctl_lock;
+
     /* Used for events with 'vcpu' and *without* the 'disabled' properties */
     DECLARE_BITMAP(trace_dstate_delayed, CPU_TRACE_DSTATE_MAX_EVENTS);
     DECLARE_BITMAP(trace_dstate, CPU_TRACE_DSTATE_MAX_EVENTS);
diff --git a/include/sysemu/accel-blocker.h b/include/sysemu/accel-blocker.h
new file mode 100644
index 000000000000..72020529ef35
--- /dev/null
+++ b/include/sysemu/accel-blocker.h
@@ -0,0 +1,56 @@
+/*
+ * Accelerator blocking API, to prevent new ioctls from starting and wait the
+ * running ones finish.
+ * This mechanism differs from pause/resume_all_vcpus() in that it does not
+ * release the BQL.
+ *
+ *  Copyright (c) 2022 Red Hat Inc.
+ *
+ * Author: Emanuele Giuseppe Esposito       <eesposit@redhat.com>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+#ifndef ACCEL_BLOCKER_H
+#define ACCEL_BLOCKER_H
+
+#include "qemu/osdep.h"
+#include "sysemu/cpus.h"
+
+extern void accel_blocker_init(void);
+
+/*
+ * accel_{cpu_}ioctl_begin/end:
+ * Mark when ioctl is about to run or just finished.
+ *
+ * accel_{cpu_}ioctl_begin will block after accel_ioctl_inhibit_begin() is
+ * called, preventing new ioctls to run. They will continue only after
+ * accel_ioctl_inibith_end().
+ */
+extern void accel_ioctl_begin(void);
+extern void accel_ioctl_end(void);
+extern void accel_cpu_ioctl_begin(CPUState *cpu);
+extern void accel_cpu_ioctl_end(CPUState *cpu);
+
+/*
+ * accel_ioctl_inhibit_begin: start critical section
+ *
+ * This function makes sure that:
+ * 1) incoming accel_{cpu_}ioctl_begin() calls block
+ * 2) wait that all ioctls that were already running reach
+ *    accel_{cpu_}ioctl_end(), kicking vcpus if necessary.
+ *
+ * This allows the caller to access shared data or perform operations without
+ * worrying of concurrent vcpus accesses.
+ */
+extern void accel_ioctl_inhibit_begin(void);
+
+/*
+ * accel_ioctl_inhibit_end: end critical section started by
+ * accel_ioctl_inhibit_begin()
+ *
+ * This function allows blocked accel_{cpu_}ioctl_begin() to continue.
+ */
+extern void accel_ioctl_inhibit_end(void);
+
+#endif /* ACCEL_BLOCKER_H */
diff --git a/util/meson.build b/util/meson.build
index d8d109ff842b..26c73e586be6 100644
--- a/util/meson.build
+++ b/util/meson.build
@@ -58,6 +58,7 @@ util_ss.add(files('yank.c'))
 util_ss.add(files('int128.c'))
 util_ss.add(files('memalign.c'))
 util_ss.add(files('interval-tree.c'))
+util_ss.add(files('lockcnt.c'))
 
 if have_user
   util_ss.add(files('selfmap.c'))
@@ -72,7 +73,6 @@ endif
 if have_block or have_ga
   util_ss.add(files('aiocb.c', 'async.c'))
   util_ss.add(files('base64.c'))
-  util_ss.add(files('lockcnt.c'))
   util_ss.add(files('main-loop.c'))
   util_ss.add(files('qemu-coroutine.c', 'qemu-coroutine-lock.c', 'qemu-coroutine-io.c'))
   util_ss.add(files('coroutine-@0@.c'.format(config_host['CONFIG_COROUTINE_BACKEND'])))
-- 
2.38.1



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

* [PULL 04/29] KVM: keep track of running ioctls
  2023-01-10 16:02 [PULL 00/29] Misc patches for 2023-01-10 Paolo Bonzini
                   ` (2 preceding siblings ...)
  2023-01-10 16:02 ` [PULL 03/29] accel: introduce accelerator blocker API Paolo Bonzini
@ 2023-01-10 16:02 ` Paolo Bonzini
  2023-01-10 16:02 ` [PULL 05/29] kvm: Atomic memslot updates Paolo Bonzini
                   ` (25 subsequent siblings)
  29 siblings, 0 replies; 37+ messages in thread
From: Paolo Bonzini @ 2023-01-10 16:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: Emanuele Giuseppe Esposito, David Hildenbrand

From: Emanuele Giuseppe Esposito <eesposit@redhat.com>

Using the new accel-blocker API, mark where ioctls are being called
in KVM. Next, we will implement the critical section that will take
care of performing memslots modifications atomically, therefore
preventing any new ioctl from running and allowing the running ones
to finish.

Signed-off-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
Message-Id: <20221111154758.1372674-3-eesposit@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 accel/kvm/kvm-all.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
index e86c33e0e612..8760d55002cc 100644
--- a/accel/kvm/kvm-all.c
+++ b/accel/kvm/kvm-all.c
@@ -2310,6 +2310,7 @@ static int kvm_init(MachineState *ms)
     assert(TARGET_PAGE_SIZE <= qemu_real_host_page_size());
 
     s->sigmask_len = 8;
+    accel_blocker_init();
 
 #ifdef KVM_CAP_SET_GUEST_DEBUG
     QTAILQ_INIT(&s->kvm_sw_breakpoints);
@@ -3014,7 +3015,9 @@ int kvm_vm_ioctl(KVMState *s, int type, ...)
     va_end(ap);
 
     trace_kvm_vm_ioctl(type, arg);
+    accel_ioctl_begin();
     ret = ioctl(s->vmfd, type, arg);
+    accel_ioctl_end();
     if (ret == -1) {
         ret = -errno;
     }
@@ -3032,7 +3035,9 @@ int kvm_vcpu_ioctl(CPUState *cpu, int type, ...)
     va_end(ap);
 
     trace_kvm_vcpu_ioctl(cpu->cpu_index, type, arg);
+    accel_cpu_ioctl_begin(cpu);
     ret = ioctl(cpu->kvm_fd, type, arg);
+    accel_cpu_ioctl_end(cpu);
     if (ret == -1) {
         ret = -errno;
     }
@@ -3050,7 +3055,9 @@ int kvm_device_ioctl(int fd, int type, ...)
     va_end(ap);
 
     trace_kvm_device_ioctl(fd, type, arg);
+    accel_ioctl_begin();
     ret = ioctl(fd, type, arg);
+    accel_ioctl_end();
     if (ret == -1) {
         ret = -errno;
     }
-- 
2.38.1



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

* [PULL 05/29] kvm: Atomic memslot updates
  2023-01-10 16:02 [PULL 00/29] Misc patches for 2023-01-10 Paolo Bonzini
                   ` (3 preceding siblings ...)
  2023-01-10 16:02 ` [PULL 04/29] KVM: keep track of running ioctls Paolo Bonzini
@ 2023-01-10 16:02 ` Paolo Bonzini
  2023-01-10 16:02 ` [PULL 06/29] target/i386: Remove compilation errors when -Werror=maybe-uninitialized Paolo Bonzini
                   ` (24 subsequent siblings)
  29 siblings, 0 replies; 37+ messages in thread
From: Paolo Bonzini @ 2023-01-10 16:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: David Hildenbrand, Emanuele Giuseppe Esposito

From: David Hildenbrand <david@redhat.com>

If we update an existing memslot (e.g., resize, split), we temporarily
remove the memslot to re-add it immediately afterwards. These updates
are not atomic, especially not for KVM VCPU threads, such that we can
get spurious faults.

Let's inhibit most KVM ioctls while performing relevant updates, such
that we can perform the update just as if it would happen atomically
without additional kernel support.

We capture the add/del changes and apply them in the notifier commit
stage instead. There, we can check for overlaps and perform the ioctl
inhibiting only if really required (-> overlap).

To keep things simple we don't perform additional checks that wouldn't
actually result in an overlap -- such as !RAM memory regions in some
cases (see kvm_set_phys_mem()).

To minimize cache-line bouncing, use a separate indicator
(in_ioctl_lock) per CPU.  Also, make sure to hold the kvm_slots_lock
while performing both actions (removing+re-adding).

We have to wait until all IOCTLs were exited and block new ones from
getting executed.

This approach cannot result in a deadlock as long as the inhibitor does
not hold any locks that might hinder an IOCTL from getting finished and
exited - something fairly unusual. The inhibitor will always hold the BQL.

AFAIKs, one possible candidate would be userfaultfd. If a page cannot be
placed (e.g., during postcopy), because we're waiting for a lock, or if the
userfaultfd thread cannot process a fault, because it is waiting for a
lock, there could be a deadlock. However, the BQL is not applicable here,
because any other guest memory access while holding the BQL would already
result in a deadlock.

Nothing else in the kernel should block forever and wait for userspace
intervention.

Note: pause_all_vcpus()/resume_all_vcpus() or
start_exclusive()/end_exclusive() cannot be used, as they either drop
the BQL or require to be called without the BQL - something inhibitors
cannot handle. We need a low-level locking mechanism that is
deadlock-free even when not releasing the BQL.

Signed-off-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
Tested-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
Message-Id: <20221111154758.1372674-4-eesposit@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 accel/kvm/kvm-all.c      | 101 ++++++++++++++++++++++++++++++++++-----
 include/sysemu/kvm_int.h |   8 ++++
 2 files changed, 98 insertions(+), 11 deletions(-)

diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
index 8760d55002cc..7e6a6076b16c 100644
--- a/accel/kvm/kvm-all.c
+++ b/accel/kvm/kvm-all.c
@@ -31,6 +31,7 @@
 #include "sysemu/kvm_int.h"
 #include "sysemu/runstate.h"
 #include "sysemu/cpus.h"
+#include "sysemu/accel-blocker.h"
 #include "qemu/bswap.h"
 #include "exec/memory.h"
 #include "exec/ram_addr.h"
@@ -46,6 +47,7 @@
 #include "sysemu/hw_accel.h"
 #include "kvm-cpus.h"
 #include "sysemu/dirtylimit.h"
+#include "qemu/range.h"
 
 #include "hw/boards.h"
 #include "monitor/stats.h"
@@ -1292,6 +1294,7 @@ void kvm_set_max_memslot_size(hwaddr max_slot_size)
     kvm_max_slot_size = max_slot_size;
 }
 
+/* Called with KVMMemoryListener.slots_lock held */
 static void kvm_set_phys_mem(KVMMemoryListener *kml,
                              MemoryRegionSection *section, bool add)
 {
@@ -1326,14 +1329,12 @@ static void kvm_set_phys_mem(KVMMemoryListener *kml,
     ram = memory_region_get_ram_ptr(mr) + mr_offset;
     ram_start_offset = memory_region_get_ram_addr(mr) + mr_offset;
 
-    kvm_slots_lock();
-
     if (!add) {
         do {
             slot_size = MIN(kvm_max_slot_size, size);
             mem = kvm_lookup_matching_slot(kml, start_addr, slot_size);
             if (!mem) {
-                goto out;
+                return;
             }
             if (mem->flags & KVM_MEM_LOG_DIRTY_PAGES) {
                 /*
@@ -1371,7 +1372,7 @@ static void kvm_set_phys_mem(KVMMemoryListener *kml,
             start_addr += slot_size;
             size -= slot_size;
         } while (size);
-        goto out;
+        return;
     }
 
     /* register the new slot */
@@ -1396,9 +1397,6 @@ static void kvm_set_phys_mem(KVMMemoryListener *kml,
         ram += slot_size;
         size -= slot_size;
     } while (size);
-
-out:
-    kvm_slots_unlock();
 }
 
 static void *kvm_dirty_ring_reaper_thread(void *data)
@@ -1455,18 +1453,95 @@ static void kvm_region_add(MemoryListener *listener,
                            MemoryRegionSection *section)
 {
     KVMMemoryListener *kml = container_of(listener, KVMMemoryListener, listener);
+    KVMMemoryUpdate *update;
 
-    memory_region_ref(section->mr);
-    kvm_set_phys_mem(kml, section, true);
+    update = g_new0(KVMMemoryUpdate, 1);
+    update->section = *section;
+
+    QSIMPLEQ_INSERT_TAIL(&kml->transaction_add, update, next);
 }
 
 static void kvm_region_del(MemoryListener *listener,
                            MemoryRegionSection *section)
 {
     KVMMemoryListener *kml = container_of(listener, KVMMemoryListener, listener);
+    KVMMemoryUpdate *update;
 
-    kvm_set_phys_mem(kml, section, false);
-    memory_region_unref(section->mr);
+    update = g_new0(KVMMemoryUpdate, 1);
+    update->section = *section;
+
+    QSIMPLEQ_INSERT_TAIL(&kml->transaction_del, update, next);
+}
+
+static void kvm_region_commit(MemoryListener *listener)
+{
+    KVMMemoryListener *kml = container_of(listener, KVMMemoryListener,
+                                          listener);
+    KVMMemoryUpdate *u1, *u2;
+    bool need_inhibit = false;
+
+    if (QSIMPLEQ_EMPTY(&kml->transaction_add) &&
+        QSIMPLEQ_EMPTY(&kml->transaction_del)) {
+        return;
+    }
+
+    /*
+     * We have to be careful when regions to add overlap with ranges to remove.
+     * We have to simulate atomic KVM memslot updates by making sure no ioctl()
+     * is currently active.
+     *
+     * The lists are order by addresses, so it's easy to find overlaps.
+     */
+    u1 = QSIMPLEQ_FIRST(&kml->transaction_del);
+    u2 = QSIMPLEQ_FIRST(&kml->transaction_add);
+    while (u1 && u2) {
+        Range r1, r2;
+
+        range_init_nofail(&r1, u1->section.offset_within_address_space,
+                          int128_get64(u1->section.size));
+        range_init_nofail(&r2, u2->section.offset_within_address_space,
+                          int128_get64(u2->section.size));
+
+        if (range_overlaps_range(&r1, &r2)) {
+            need_inhibit = true;
+            break;
+        }
+        if (range_lob(&r1) < range_lob(&r2)) {
+            u1 = QSIMPLEQ_NEXT(u1, next);
+        } else {
+            u2 = QSIMPLEQ_NEXT(u2, next);
+        }
+    }
+
+    kvm_slots_lock();
+    if (need_inhibit) {
+        accel_ioctl_inhibit_begin();
+    }
+
+    /* Remove all memslots before adding the new ones. */
+    while (!QSIMPLEQ_EMPTY(&kml->transaction_del)) {
+        u1 = QSIMPLEQ_FIRST(&kml->transaction_del);
+        QSIMPLEQ_REMOVE_HEAD(&kml->transaction_del, next);
+
+        kvm_set_phys_mem(kml, &u1->section, false);
+        memory_region_unref(u1->section.mr);
+
+        g_free(u1);
+    }
+    while (!QSIMPLEQ_EMPTY(&kml->transaction_add)) {
+        u1 = QSIMPLEQ_FIRST(&kml->transaction_add);
+        QSIMPLEQ_REMOVE_HEAD(&kml->transaction_add, next);
+
+        memory_region_ref(u1->section.mr);
+        kvm_set_phys_mem(kml, &u1->section, true);
+
+        g_free(u1);
+    }
+
+    if (need_inhibit) {
+        accel_ioctl_inhibit_end();
+    }
+    kvm_slots_unlock();
 }
 
 static void kvm_log_sync(MemoryListener *listener,
@@ -1610,8 +1685,12 @@ void kvm_memory_listener_register(KVMState *s, KVMMemoryListener *kml,
         kml->slots[i].slot = i;
     }
 
+    QSIMPLEQ_INIT(&kml->transaction_add);
+    QSIMPLEQ_INIT(&kml->transaction_del);
+
     kml->listener.region_add = kvm_region_add;
     kml->listener.region_del = kvm_region_del;
+    kml->listener.commit = kvm_region_commit;
     kml->listener.log_start = kvm_log_start;
     kml->listener.log_stop = kvm_log_stop;
     kml->listener.priority = 10;
diff --git a/include/sysemu/kvm_int.h b/include/sysemu/kvm_int.h
index 3b4adcdc101d..60b520a13e84 100644
--- a/include/sysemu/kvm_int.h
+++ b/include/sysemu/kvm_int.h
@@ -12,6 +12,7 @@
 #include "exec/memory.h"
 #include "qapi/qapi-types-common.h"
 #include "qemu/accel.h"
+#include "qemu/queue.h"
 #include "sysemu/kvm.h"
 
 typedef struct KVMSlot
@@ -31,10 +32,17 @@ typedef struct KVMSlot
     ram_addr_t ram_start_offset;
 } KVMSlot;
 
+typedef struct KVMMemoryUpdate {
+    QSIMPLEQ_ENTRY(KVMMemoryUpdate) next;
+    MemoryRegionSection section;
+} KVMMemoryUpdate;
+
 typedef struct KVMMemoryListener {
     MemoryListener listener;
     KVMSlot *slots;
     int as_id;
+    QSIMPLEQ_HEAD(, KVMMemoryUpdate) transaction_add;
+    QSIMPLEQ_HEAD(, KVMMemoryUpdate) transaction_del;
 } KVMMemoryListener;
 
 #define KVM_MSI_HASHTAB_SIZE    256
-- 
2.38.1



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

* [PULL 06/29] target/i386: Remove compilation errors when -Werror=maybe-uninitialized
  2023-01-10 16:02 [PULL 00/29] Misc patches for 2023-01-10 Paolo Bonzini
                   ` (4 preceding siblings ...)
  2023-01-10 16:02 ` [PULL 05/29] kvm: Atomic memslot updates Paolo Bonzini
@ 2023-01-10 16:02 ` Paolo Bonzini
  2023-01-10 17:19   ` Eric Auger
  2023-01-11 10:03   ` Philippe Mathieu-Daudé
  2023-01-10 16:02 ` [PULL 07/29] chardev: clean up chardev-parallel.c Paolo Bonzini
                   ` (23 subsequent siblings)
  29 siblings, 2 replies; 37+ messages in thread
From: Paolo Bonzini @ 2023-01-10 16:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: Eric Auger, Stefan Weil

From: Eric Auger <eric.auger@redhat.com>

To avoid compilation errors when -Werror=maybe-uninitialized is used,
replace 'case 3' by 'default'.

Otherwise we get:

../target/i386/ops_sse.h: In function ‘helper_vpermdq_ymm’:
../target/i386/ops_sse.h:2495:13: error: ‘r3’ may be used
uninitialized in this function [-Werror=maybe-uninitialized]
   2495 |     d->Q(3) = r3;
        |     ~~~~~~~~^~~~
../target/i386/ops_sse.h:2494:13: error: ‘r2’ may be used
uninitialized in this function [-Werror=maybe-uninitialized]
   2494 |     d->Q(2) = r2;
        |     ~~~~~~~~^~~~
../target/i386/ops_sse.h:2493:13: error: ‘r1’ may be used
uninitialized in this function [-Werror=maybe-uninitialized]
   2493 |     d->Q(1) = r1;
        |     ~~~~~~~~^~~~
../target/i386/ops_sse.h:2492:13: error: ‘r0’ may be used
uninitialized in this function [-Werror=maybe-uninitialized]
   2492 |     d->Q(0) = r0;
        |     ~~~~~~~~^~~~

Signed-off-by: Eric Auger <eric.auger@redhat.com>
Suggested-by: Stefan Weil <sw@weilnetz.de>
Fixes: 790684776861 ("target/i386: reimplement 0x0f 0x3a, add AVX")
Message-Id: <20221221163652.1239362-1-eric.auger@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 target/i386/ops_sse.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/target/i386/ops_sse.h b/target/i386/ops_sse.h
index 3cbc36a59d1a..c442c8c10cdc 100644
--- a/target/i386/ops_sse.h
+++ b/target/i386/ops_sse.h
@@ -2466,7 +2466,7 @@ void helper_vpermdq_ymm(Reg *d, Reg *v, Reg *s, uint32_t order)
         r0 = s->Q(0);
         r1 = s->Q(1);
         break;
-    case 3:
+    default:
         r0 = s->Q(2);
         r1 = s->Q(3);
         break;
@@ -2484,7 +2484,7 @@ void helper_vpermdq_ymm(Reg *d, Reg *v, Reg *s, uint32_t order)
         r2 = s->Q(0);
         r3 = s->Q(1);
         break;
-    case 3:
+    default:
         r2 = s->Q(2);
         r3 = s->Q(3);
         break;
-- 
2.38.1



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

* [PULL 07/29] chardev: clean up chardev-parallel.c
  2023-01-10 16:02 [PULL 00/29] Misc patches for 2023-01-10 Paolo Bonzini
                   ` (5 preceding siblings ...)
  2023-01-10 16:02 ` [PULL 06/29] target/i386: Remove compilation errors when -Werror=maybe-uninitialized Paolo Bonzini
@ 2023-01-10 16:02 ` Paolo Bonzini
  2023-01-10 16:02 ` [PULL 08/29] gitlab: remove redundant setting of PKG_CONFIG_PATH Paolo Bonzini
                   ` (22 subsequent siblings)
  29 siblings, 0 replies; 37+ messages in thread
From: Paolo Bonzini @ 2023-01-10 16:02 UTC (permalink / raw)
  To: qemu-devel

Replace HAVE_CHARDEV_PARPORT with a Meson conditional, remove unnecessary
defines, and close the file descriptor on FreeBSD/DragonFly.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 chardev/char-parallel.c | 15 ++-------------
 chardev/meson.build     |  5 ++++-
 include/qemu/osdep.h    |  5 -----
 3 files changed, 6 insertions(+), 19 deletions(-)

diff --git a/chardev/char-parallel.c b/chardev/char-parallel.c
index 05e7efbd6ca9..a5164f975af3 100644
--- a/chardev/char-parallel.c
+++ b/chardev/char-parallel.c
@@ -238,7 +238,6 @@ static void qemu_chr_open_pp_fd(Chardev *chr,
 }
 #endif
 
-#ifdef HAVE_CHARDEV_PARPORT
 static void qmp_chardev_open_parallel(Chardev *chr,
                                       ChardevBackend *backend,
                                       bool *be_opened,
@@ -276,29 +275,21 @@ static void char_parallel_class_init(ObjectClass *oc, void *data)
 
     cc->parse = qemu_chr_parse_parallel;
     cc->open = qmp_chardev_open_parallel;
-#if defined(__linux__)
     cc->chr_ioctl = pp_ioctl;
-#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || \
-    defined(__DragonFly__)
-    cc->chr_ioctl = pp_ioctl;
-#endif
 }
 
 static void char_parallel_finalize(Object *obj)
 {
-#if defined(__linux__)
     Chardev *chr = CHARDEV(obj);
     ParallelChardev *drv = PARALLEL_CHARDEV(chr);
     int fd = drv->fd;
 
+#if defined(__linux__)
     pp_hw_mode(drv, IEEE1284_MODE_COMPAT);
     ioctl(fd, PPRELEASE);
+#endif
     close(fd);
     qemu_chr_be_event(chr, CHR_EVENT_CLOSED);
-#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || \
-    defined(__DragonFly__)
-    /* FIXME: close fd? */
-#endif
 }
 
 static const TypeInfo char_parallel_type_info = {
@@ -315,5 +306,3 @@ static void register_types(void)
 }
 
 type_init(register_types);
-
-#endif
diff --git a/chardev/meson.build b/chardev/meson.build
index 664f77b8879a..789b50056ae4 100644
--- a/chardev/meson.build
+++ b/chardev/meson.build
@@ -14,9 +14,12 @@ chardev_ss.add(files(
 ))
 chardev_ss.add(when: 'CONFIG_POSIX', if_true: [files(
   'char-fd.c',
-  'char-parallel.c',
   'char-pty.c',
 ), util])
+if targetos in ['linux', 'gnu/kfreebsd', 'freebsd', 'dragonfly']
+  chardev_ss.add(files('char-parallel.c'))
+endif
+
 chardev_ss.add(when: 'CONFIG_WIN32', if_true: files(
   'char-console.c',
   'char-win-stdio.c',
diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
index b9c4307779c5..4886361be6a7 100644
--- a/include/qemu/osdep.h
+++ b/include/qemu/osdep.h
@@ -421,11 +421,6 @@ void qemu_anon_ram_free(void *ptr, size_t size);
 #define HAVE_CHARDEV_SERIAL 1
 #endif
 
-#if defined(__linux__) || defined(__FreeBSD__) ||               \
-    defined(__FreeBSD_kernel__) || defined(__DragonFly__)
-#define HAVE_CHARDEV_PARPORT 1
-#endif
-
 #if defined(__HAIKU__)
 #define SIGIO SIGPOLL
 #endif
-- 
2.38.1



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

* [PULL 08/29] gitlab: remove redundant setting of PKG_CONFIG_PATH
  2023-01-10 16:02 [PULL 00/29] Misc patches for 2023-01-10 Paolo Bonzini
                   ` (6 preceding siblings ...)
  2023-01-10 16:02 ` [PULL 07/29] chardev: clean up chardev-parallel.c Paolo Bonzini
@ 2023-01-10 16:02 ` Paolo Bonzini
  2023-01-10 16:40   ` Daniel P. Berrangé
  2023-01-10 16:02 ` [PULL 09/29] disas: add G_GNUC_PRINTF to gstring_printf Paolo Bonzini
                   ` (21 subsequent siblings)
  29 siblings, 1 reply; 37+ messages in thread
From: Paolo Bonzini @ 2023-01-10 16:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: Daniel P. Berrangé, Stefan Hajnoczi

From: Daniel P. Berrangé <berrange@redhat.com>

The PKG_CONFIG_PATH variable is not defined in GitLab CI
envs and even if it was, we don't need to set it to its
existing value.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-Id: <20221103173044.3969425-2-berrange@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 .gitlab-ci.d/crossbuild-template.yml | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/.gitlab-ci.d/crossbuild-template.yml b/.gitlab-ci.d/crossbuild-template.yml
index 5e8892fd4998..6d709628f127 100644
--- a/.gitlab-ci.d/crossbuild-template.yml
+++ b/.gitlab-ci.d/crossbuild-template.yml
@@ -6,8 +6,7 @@
   script:
     - mkdir build
     - cd build
-    - PKG_CONFIG_PATH=$PKG_CONFIG_PATH
-      ../configure --enable-werror --disable-docs $QEMU_CONFIGURE_OPTS
+    - ../configure --enable-werror --disable-docs $QEMU_CONFIGURE_OPTS
         --disable-user --target-list-exclude="arm-softmmu cris-softmmu
           i386-softmmu microblaze-softmmu mips-softmmu mipsel-softmmu
           mips64-softmmu ppc-softmmu riscv32-softmmu sh4-softmmu
@@ -32,8 +31,7 @@
   script:
     - mkdir build
     - cd build
-    - PKG_CONFIG_PATH=$PKG_CONFIG_PATH
-      ../configure --enable-werror --disable-docs $QEMU_CONFIGURE_OPTS
+    - ../configure --enable-werror --disable-docs $QEMU_CONFIGURE_OPTS
         --disable-tools --enable-${ACCEL:-kvm} $EXTRA_CONFIGURE_OPTS
     - make -j$(expr $(nproc) + 1) all check-build $MAKE_CHECK_ARGS
 
@@ -44,8 +42,7 @@
   script:
     - mkdir build
     - cd build
-    - PKG_CONFIG_PATH=$PKG_CONFIG_PATH
-      ../configure --enable-werror --disable-docs $QEMU_CONFIGURE_OPTS
+    - ../configure --enable-werror --disable-docs $QEMU_CONFIGURE_OPTS
         --disable-system --target-list-exclude="aarch64_be-linux-user
           alpha-linux-user cris-linux-user m68k-linux-user microblazeel-linux-user
           nios2-linux-user or1k-linux-user ppc-linux-user sparc-linux-user
-- 
2.38.1



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

* [PULL 09/29] disas: add G_GNUC_PRINTF to gstring_printf
  2023-01-10 16:02 [PULL 00/29] Misc patches for 2023-01-10 Paolo Bonzini
                   ` (7 preceding siblings ...)
  2023-01-10 16:02 ` [PULL 08/29] gitlab: remove redundant setting of PKG_CONFIG_PATH Paolo Bonzini
@ 2023-01-10 16:02 ` Paolo Bonzini
  2023-01-10 16:02 ` [PULL 10/29] hw/xen: use G_GNUC_PRINTF/SCANF for various functions Paolo Bonzini
                   ` (20 subsequent siblings)
  29 siblings, 0 replies; 37+ messages in thread
From: Paolo Bonzini @ 2023-01-10 16:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: Daniel P. Berrangé

From: Daniel P. Berrangé <berrange@redhat.com>

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Message-Id: <20221219130205.687815-2-berrange@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 disas.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/disas.c b/disas.c
index 94d3b4504260..3b31315f4038 100644
--- a/disas.c
+++ b/disas.c
@@ -239,7 +239,8 @@ void target_disas(FILE *out, CPUState *cpu, target_ulong code,
     }
 }
 
-static int gstring_printf(FILE *stream, const char *fmt, ...)
+static int G_GNUC_PRINTF(2, 3)
+gstring_printf(FILE *stream, const char *fmt, ...)
 {
     /* We abuse the FILE parameter to pass a GString. */
     GString *s = (GString *)stream;
-- 
2.38.1



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

* [PULL 10/29] hw/xen: use G_GNUC_PRINTF/SCANF for various functions
  2023-01-10 16:02 [PULL 00/29] Misc patches for 2023-01-10 Paolo Bonzini
                   ` (8 preceding siblings ...)
  2023-01-10 16:02 ` [PULL 09/29] disas: add G_GNUC_PRINTF to gstring_printf Paolo Bonzini
@ 2023-01-10 16:02 ` Paolo Bonzini
  2023-01-10 16:02 ` [PULL 11/29] tools/virtiofsd: add G_GNUC_PRINTF for logging functions Paolo Bonzini
                   ` (19 subsequent siblings)
  29 siblings, 0 replies; 37+ messages in thread
From: Paolo Bonzini @ 2023-01-10 16:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: Daniel P. Berrangé, Anthony PERARD

From: Daniel P. Berrangé <berrange@redhat.com>

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Acked-by: Anthony PERARD <anthony.perard@citrix.com>
Message-Id: <20221219130205.687815-3-berrange@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/xen/xen-bus.c                | 1 +
 hw/xen/xen_pvdev.c              | 1 +
 include/hw/xen/xen-bus-helper.h | 6 ++++--
 include/hw/xen/xen-bus.h        | 3 ++-
 4 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/hw/xen/xen-bus.c b/hw/xen/xen-bus.c
index 645a29a5a070..df3f6b9ae00f 100644
--- a/hw/xen/xen-bus.c
+++ b/hw/xen/xen-bus.c
@@ -561,6 +561,7 @@ void xen_device_backend_printf(XenDevice *xendev, const char *key,
     }
 }
 
+G_GNUC_SCANF(3, 4)
 static int xen_device_backend_scanf(XenDevice *xendev, const char *key,
                                     const char *fmt, ...)
 {
diff --git a/hw/xen/xen_pvdev.c b/hw/xen/xen_pvdev.c
index 037152f06350..1a5177b35468 100644
--- a/hw/xen/xen_pvdev.c
+++ b/hw/xen/xen_pvdev.c
@@ -196,6 +196,7 @@ const char *xenbus_strstate(enum xenbus_state state)
  *  2 == noisy debug messages (logfile only).
  *  3 == will flood your log (logfile only).
  */
+G_GNUC_PRINTF(3, 0)
 static void xen_pv_output_msg(struct XenLegacyDevice *xendev,
                               FILE *f, const char *fmt, va_list args)
 {
diff --git a/include/hw/xen/xen-bus-helper.h b/include/hw/xen/xen-bus-helper.h
index 629a904d1a86..8782f3055086 100644
--- a/include/hw/xen/xen-bus-helper.h
+++ b/include/hw/xen/xen-bus-helper.h
@@ -31,10 +31,12 @@ void xs_node_printf(struct xs_handle *xsh,  xs_transaction_t tid,
 /* Read from node/key unless node is empty, in which case read from key */
 int xs_node_vscanf(struct xs_handle *xsh,  xs_transaction_t tid,
                    const char *node, const char *key, Error **errp,
-                   const char *fmt, va_list ap);
+                   const char *fmt, va_list ap)
+    G_GNUC_SCANF(6, 0);
 int xs_node_scanf(struct xs_handle *xsh,  xs_transaction_t tid,
                   const char *node, const char *key, Error **errp,
-                  const char *fmt, ...);
+                  const char *fmt, ...)
+    G_GNUC_SCANF(6, 7);
 
 /* Watch node/key unless node is empty, in which case watch key */
 void xs_node_watch(struct xs_handle *xsh, const char *node, const char *key,
diff --git a/include/hw/xen/xen-bus.h b/include/hw/xen/xen-bus.h
index 713e763348f4..4d966a2dbbc1 100644
--- a/include/hw/xen/xen-bus.h
+++ b/include/hw/xen/xen-bus.h
@@ -94,7 +94,8 @@ void xen_device_frontend_printf(XenDevice *xendev, const char *key,
     G_GNUC_PRINTF(3, 4);
 
 int xen_device_frontend_scanf(XenDevice *xendev, const char *key,
-                              const char *fmt, ...);
+                              const char *fmt, ...)
+    G_GNUC_SCANF(3, 4);
 
 void xen_device_set_max_grant_refs(XenDevice *xendev, unsigned int nr_refs,
                                    Error **errp);
-- 
2.38.1



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

* [PULL 11/29] tools/virtiofsd: add G_GNUC_PRINTF for logging functions
  2023-01-10 16:02 [PULL 00/29] Misc patches for 2023-01-10 Paolo Bonzini
                   ` (9 preceding siblings ...)
  2023-01-10 16:02 ` [PULL 10/29] hw/xen: use G_GNUC_PRINTF/SCANF for various functions Paolo Bonzini
@ 2023-01-10 16:02 ` Paolo Bonzini
  2023-01-10 16:02 ` [PULL 12/29] util/error: add G_GNUC_PRINTF for various functions Paolo Bonzini
                   ` (18 subsequent siblings)
  29 siblings, 0 replies; 37+ messages in thread
From: Paolo Bonzini @ 2023-01-10 16:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: Daniel P. Berrangé

From: Daniel P. Berrangé <berrange@redhat.com>

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Message-Id: <20221219130205.687815-4-berrange@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 tools/virtiofsd/fuse_log.c       | 1 +
 tools/virtiofsd/fuse_log.h       | 6 ++++--
 tools/virtiofsd/passthrough_ll.c | 1 +
 3 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/tools/virtiofsd/fuse_log.c b/tools/virtiofsd/fuse_log.c
index 745d88cd2a49..2de3f48ee7ea 100644
--- a/tools/virtiofsd/fuse_log.c
+++ b/tools/virtiofsd/fuse_log.c
@@ -12,6 +12,7 @@
 #include "fuse_log.h"
 
 
+G_GNUC_PRINTF(2, 0)
 static void default_log_func(__attribute__((unused)) enum fuse_log_level level,
                              const char *fmt, va_list ap)
 {
diff --git a/tools/virtiofsd/fuse_log.h b/tools/virtiofsd/fuse_log.h
index 8d7091bd4d0b..e5c2967ab95a 100644
--- a/tools/virtiofsd/fuse_log.h
+++ b/tools/virtiofsd/fuse_log.h
@@ -45,7 +45,8 @@ enum fuse_log_level {
  * @param ap format string arguments
  */
 typedef void (*fuse_log_func_t)(enum fuse_log_level level, const char *fmt,
-                                va_list ap);
+                                va_list ap)
+    G_GNUC_PRINTF(2, 0);
 
 /**
  * Install a custom log handler function.
@@ -68,6 +69,7 @@ void fuse_set_log_func(fuse_log_func_t func);
  * @param level severity level (FUSE_LOG_ERR, FUSE_LOG_DEBUG, etc)
  * @param fmt sprintf-style format string including newline
  */
-void fuse_log(enum fuse_log_level level, const char *fmt, ...);
+void fuse_log(enum fuse_log_level level, const char *fmt, ...)
+    G_GNUC_PRINTF(2, 3);
 
 #endif /* FUSE_LOG_H_ */
diff --git a/tools/virtiofsd/passthrough_ll.c b/tools/virtiofsd/passthrough_ll.c
index 20f0f41f99a5..40ea2ed27fef 100644
--- a/tools/virtiofsd/passthrough_ll.c
+++ b/tools/virtiofsd/passthrough_ll.c
@@ -4182,6 +4182,7 @@ static void setup_nofile_rlimit(unsigned long rlimit_nofile)
     }
 }
 
+G_GNUC_PRINTF(2, 0)
 static void log_func(enum fuse_log_level level, const char *fmt, va_list ap)
 {
     g_autofree char *localfmt = NULL;
-- 
2.38.1



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

* [PULL 12/29] util/error: add G_GNUC_PRINTF for various functions
  2023-01-10 16:02 [PULL 00/29] Misc patches for 2023-01-10 Paolo Bonzini
                   ` (10 preceding siblings ...)
  2023-01-10 16:02 ` [PULL 11/29] tools/virtiofsd: add G_GNUC_PRINTF for logging functions Paolo Bonzini
@ 2023-01-10 16:02 ` Paolo Bonzini
  2023-01-10 16:02 ` [PULL 13/29] tests: " Paolo Bonzini
                   ` (17 subsequent siblings)
  29 siblings, 0 replies; 37+ messages in thread
From: Paolo Bonzini @ 2023-01-10 16:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: Daniel P. Berrangé, Philippe Mathieu-Daudé

From: Daniel P. Berrangé <berrange@redhat.com>

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-Id: <20221219130205.687815-5-berrange@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 util/error-report.c | 1 +
 util/error.c        | 1 +
 2 files changed, 2 insertions(+)

diff --git a/util/error-report.c b/util/error-report.c
index 5edb2e604061..6e44a5573217 100644
--- a/util/error-report.c
+++ b/util/error-report.c
@@ -193,6 +193,7 @@ real_time_iso8601(void)
  * a single phrase, with no newline or trailing punctuation.
  * Prepend the current location and append a newline.
  */
+G_GNUC_PRINTF(2, 0)
 static void vreport(report_type type, const char *fmt, va_list ap)
 {
     gchar *timestr;
diff --git a/util/error.c b/util/error.c
index b6c89d141208..1e7af665b838 100644
--- a/util/error.c
+++ b/util/error.c
@@ -45,6 +45,7 @@ static void error_handle_fatal(Error **errp, Error *err)
     }
 }
 
+G_GNUC_PRINTF(6, 0)
 static void error_setv(Error **errp,
                        const char *src, int line, const char *func,
                        ErrorClass err_class, const char *fmt, va_list ap,
-- 
2.38.1



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

* [PULL 13/29] tests: add G_GNUC_PRINTF for various functions
  2023-01-10 16:02 [PULL 00/29] Misc patches for 2023-01-10 Paolo Bonzini
                   ` (11 preceding siblings ...)
  2023-01-10 16:02 ` [PULL 12/29] util/error: add G_GNUC_PRINTF for various functions Paolo Bonzini
@ 2023-01-10 16:02 ` Paolo Bonzini
  2023-01-10 16:02 ` [PULL 14/29] enforce use of G_GNUC_PRINTF attributes Paolo Bonzini
                   ` (16 subsequent siblings)
  29 siblings, 0 replies; 37+ messages in thread
From: Paolo Bonzini @ 2023-01-10 16:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: Daniel P. Berrangé

From: Daniel P. Berrangé <berrange@redhat.com>

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Message-Id: <20221219130205.687815-6-berrange@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 tests/qtest/ahci-test.c           |  3 +++
 tests/qtest/arm-cpu-features.c    |  1 +
 tests/qtest/erst-test.c           |  2 +-
 tests/qtest/ide-test.c            |  3 ++-
 tests/qtest/ivshmem-test.c        |  4 ++--
 tests/qtest/libqmp.c              |  2 +-
 tests/qtest/libqos/libqos-pc.h    |  6 ++++--
 tests/qtest/libqos/libqos-spapr.h |  6 ++++--
 tests/qtest/libqos/libqos.h       |  6 ++++--
 tests/qtest/libqos/virtio-9p.c    |  1 +
 tests/qtest/migration-helpers.h   |  1 +
 tests/qtest/rtas-test.c           |  2 +-
 tests/qtest/usb-hcd-uhci-test.c   |  4 ++--
 tests/unit/test-qmp-cmds.c        | 13 +++++++++----
 14 files changed, 36 insertions(+), 18 deletions(-)

diff --git a/tests/qtest/ahci-test.c b/tests/qtest/ahci-test.c
index 66652fed0465..1967cd589855 100644
--- a/tests/qtest/ahci-test.c
+++ b/tests/qtest/ahci-test.c
@@ -154,6 +154,7 @@ static void ahci_migrate(AHCIQState *from, AHCIQState *to, const char *uri)
 /**
  * Start a Q35 machine and bookmark a handle to the AHCI device.
  */
+G_GNUC_PRINTF(1, 0)
 static AHCIQState *ahci_vboot(const char *cli, va_list ap)
 {
     AHCIQState *s;
@@ -171,6 +172,7 @@ static AHCIQState *ahci_vboot(const char *cli, va_list ap)
 /**
  * Start a Q35 machine and bookmark a handle to the AHCI device.
  */
+G_GNUC_PRINTF(1, 2)
 static AHCIQState *ahci_boot(const char *cli, ...)
 {
     AHCIQState *s;
@@ -209,6 +211,7 @@ static void ahci_shutdown(AHCIQState *ahci)
  * Boot and fully enable the HBA device.
  * @see ahci_boot, ahci_pci_enable and ahci_hba_enable.
  */
+G_GNUC_PRINTF(1, 2)
 static AHCIQState *ahci_boot_and_enable(const char *cli, ...)
 {
     AHCIQState *ahci;
diff --git a/tests/qtest/arm-cpu-features.c b/tests/qtest/arm-cpu-features.c
index 5a145273860c..8691802950ca 100644
--- a/tests/qtest/arm-cpu-features.c
+++ b/tests/qtest/arm-cpu-features.c
@@ -32,6 +32,7 @@ static QDict *do_query_no_props(QTestState *qts, const char *cpu_type)
                           QUERY_TAIL, cpu_type);
 }
 
+G_GNUC_PRINTF(3, 4)
 static QDict *do_query(QTestState *qts, const char *cpu_type,
                        const char *fmt, ...)
 {
diff --git a/tests/qtest/erst-test.c b/tests/qtest/erst-test.c
index 974e8bcfe5b7..c45bee7f054c 100644
--- a/tests/qtest/erst-test.c
+++ b/tests/qtest/erst-test.c
@@ -98,7 +98,7 @@ static void setup_vm_cmd(ERSTState *s, const char *cmd)
     const char *arch = qtest_get_arch();
 
     if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
-        s->qs = qtest_pc_boot(cmd);
+        s->qs = qtest_pc_boot("%s", cmd);
     } else {
         g_printerr("erst-test tests are only available on x86\n");
         exit(EXIT_FAILURE);
diff --git a/tests/qtest/ide-test.c b/tests/qtest/ide-test.c
index dbe1563b230f..dcb050bf9b4d 100644
--- a/tests/qtest/ide-test.c
+++ b/tests/qtest/ide-test.c
@@ -125,6 +125,7 @@ static QGuestAllocator guest_malloc;
 static char *tmp_path[2];
 static char *debug_path;
 
+G_GNUC_PRINTF(1, 2)
 static QTestState *ide_test_start(const char *cmdline_fmt, ...)
 {
     QTestState *qts;
@@ -788,7 +789,7 @@ static void test_flush_nodev(void)
     QPCIDevice *dev;
     QPCIBar bmdma_bar, ide_bar;
 
-    qts = ide_test_start("");
+    qts = ide_test_start("%s", "");
 
     dev = get_pci_device(qts, &bmdma_bar, &ide_bar);
 
diff --git a/tests/qtest/ivshmem-test.c b/tests/qtest/ivshmem-test.c
index cd550c8935ef..9bf8e78df672 100644
--- a/tests/qtest/ivshmem-test.c
+++ b/tests/qtest/ivshmem-test.c
@@ -109,9 +109,9 @@ static void setup_vm_cmd(IVState *s, const char *cmd, bool msix)
     const char *arch = qtest_get_arch();
 
     if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
-        s->qs = qtest_pc_boot(cmd);
+        s->qs = qtest_pc_boot("%s", cmd);
     } else if (strcmp(arch, "ppc64") == 0) {
-        s->qs = qtest_spapr_boot(cmd);
+        s->qs = qtest_spapr_boot("%s", cmd);
     } else {
         g_printerr("ivshmem-test tests are only available on x86 or ppc64\n");
         exit(EXIT_FAILURE);
diff --git a/tests/qtest/libqmp.c b/tests/qtest/libqmp.c
index 2b08382e5d1c..a89cab03c3b6 100644
--- a/tests/qtest/libqmp.c
+++ b/tests/qtest/libqmp.c
@@ -134,7 +134,7 @@ static void socket_send_fds(int socket_fd, int *fds, size_t fds_num,
  * in the case that they choose to discard all replies up until
  * a particular EVENT is received.
  */
-static void
+static G_GNUC_PRINTF(4, 0) void
 _qmp_fd_vsend_fds(int fd, int *fds, size_t fds_num,
                   const char *fmt, va_list ap)
 {
diff --git a/tests/qtest/libqos/libqos-pc.h b/tests/qtest/libqos/libqos-pc.h
index 1a9923ead42f..a2e4209a4932 100644
--- a/tests/qtest/libqos/libqos-pc.h
+++ b/tests/qtest/libqos/libqos-pc.h
@@ -3,8 +3,10 @@
 
 #include "libqos.h"
 
-QOSState *qtest_pc_vboot(const char *cmdline_fmt, va_list ap);
-QOSState *qtest_pc_boot(const char *cmdline_fmt, ...);
+QOSState *qtest_pc_vboot(const char *cmdline_fmt, va_list ap)
+    G_GNUC_PRINTF(1, 0);
+QOSState *qtest_pc_boot(const char *cmdline_fmt, ...)
+    G_GNUC_PRINTF(1, 2);
 void qtest_pc_shutdown(QOSState *qs);
 
 #endif
diff --git a/tests/qtest/libqos/libqos-spapr.h b/tests/qtest/libqos/libqos-spapr.h
index c61338917acd..e4483c14f801 100644
--- a/tests/qtest/libqos/libqos-spapr.h
+++ b/tests/qtest/libqos/libqos-spapr.h
@@ -3,8 +3,10 @@
 
 #include "libqos.h"
 
-QOSState *qtest_spapr_vboot(const char *cmdline_fmt, va_list ap);
-QOSState *qtest_spapr_boot(const char *cmdline_fmt, ...);
+QOSState *qtest_spapr_vboot(const char *cmdline_fmt, va_list ap)
+    G_GNUC_PRINTF(1, 0);
+QOSState *qtest_spapr_boot(const char *cmdline_fmt, ...)
+    G_GNUC_PRINTF(1, 2);
 void qtest_spapr_shutdown(QOSState *qs);
 
 /* List of capabilities needed to silence warnings with TCG */
diff --git a/tests/qtest/libqos/libqos.h b/tests/qtest/libqos/libqos.h
index 9b4dd509f08e..12d05b236595 100644
--- a/tests/qtest/libqos/libqos.h
+++ b/tests/qtest/libqos/libqos.h
@@ -21,8 +21,10 @@ struct QOSState {
     QOSOps *ops;
 };
 
-QOSState *qtest_vboot(QOSOps *ops, const char *cmdline_fmt, va_list ap);
-QOSState *qtest_boot(QOSOps *ops, const char *cmdline_fmt, ...);
+QOSState *qtest_vboot(QOSOps *ops, const char *cmdline_fmt, va_list ap)
+    G_GNUC_PRINTF(2, 0);
+QOSState *qtest_boot(QOSOps *ops, const char *cmdline_fmt, ...)
+    G_GNUC_PRINTF(2, 3);
 void qtest_common_shutdown(QOSState *qs);
 void qtest_shutdown(QOSState *qs);
 bool have_qemu_img(void);
diff --git a/tests/qtest/libqos/virtio-9p.c b/tests/qtest/libqos/virtio-9p.c
index 7f2102825622..186fcc1141ad 100644
--- a/tests/qtest/libqos/virtio-9p.c
+++ b/tests/qtest/libqos/virtio-9p.c
@@ -211,6 +211,7 @@ static void *virtio_9p_pci_create(void *pci_bus, QGuestAllocator *t_alloc,
  *                      variable arguments of this function to this
  *                      replacement string
  */
+G_GNUC_PRINTF(3, 4)
 static void regex_replace(GString *haystack, const char *pattern,
                           const char *replace_fmt, ...)
 {
diff --git a/tests/qtest/migration-helpers.h b/tests/qtest/migration-helpers.h
index db0684de48b2..a188b6278796 100644
--- a/tests/qtest/migration-helpers.h
+++ b/tests/qtest/migration-helpers.h
@@ -25,6 +25,7 @@ QDict *wait_command_fd(QTestState *who, int fd, const char *command, ...);
 G_GNUC_PRINTF(2, 3)
 QDict *wait_command(QTestState *who, const char *command, ...);
 
+G_GNUC_PRINTF(2, 3)
 QDict *qmp_command(QTestState *who, const char *command, ...);
 
 G_GNUC_PRINTF(3, 4)
diff --git a/tests/qtest/rtas-test.c b/tests/qtest/rtas-test.c
index 50df60e5b20e..1ba42b37d219 100644
--- a/tests/qtest/rtas-test.c
+++ b/tests/qtest/rtas-test.c
@@ -13,7 +13,7 @@ static void run_test_rtas_get_time_of_day(const char *machine)
     uint64_t ret;
     time_t t1, t2;
 
-    qs = qtest_spapr_boot(machine);
+    qs = qtest_spapr_boot("%s", machine);
 
     t1 = time(NULL);
     ret = qrtas_get_time_of_day(qs->qts, &qs->alloc, &tm, &ns);
diff --git a/tests/qtest/usb-hcd-uhci-test.c b/tests/qtest/usb-hcd-uhci-test.c
index 7a117b64d90c..f264d2bf734d 100644
--- a/tests/qtest/usb-hcd-uhci-test.c
+++ b/tests/qtest/usb-hcd-uhci-test.c
@@ -72,9 +72,9 @@ int main(int argc, char **argv)
     qtest_add_func("/uhci/pci/hotplug/usb-storage", test_usb_storage_hotplug);
 
     if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
-        qs = qtest_pc_boot(cmd);
+        qs = qtest_pc_boot("%s", cmd);
     } else if (strcmp(arch, "ppc64") == 0) {
-        qs = qtest_spapr_boot(cmd);
+        qs = qtest_spapr_boot("%s", cmd);
     } else {
         g_printerr("usb-hcd-uhci-test tests are only "
                    "available on x86 or ppc64\n");
diff --git a/tests/unit/test-qmp-cmds.c b/tests/unit/test-qmp-cmds.c
index 2373cd64cbfa..6d52b4e5d811 100644
--- a/tests/unit/test-qmp-cmds.c
+++ b/tests/unit/test-qmp-cmds.c
@@ -138,6 +138,7 @@ void qmp___org_qemu_x_command(__org_qemu_x_EnumList *a,
 }
 
 
+G_GNUC_PRINTF(2, 3)
 static QObject *do_qmp_dispatch(bool allow_oob, const char *template, ...)
 {
     va_list ap;
@@ -160,6 +161,7 @@ static QObject *do_qmp_dispatch(bool allow_oob, const char *template, ...)
     return ret;
 }
 
+G_GNUC_PRINTF(3, 4)
 static void do_qmp_dispatch_error(bool allow_oob, ErrorClass cls,
                                   const char *template, ...)
 {
@@ -269,7 +271,7 @@ static void test_dispatch_cmd_io(void)
 
 static void test_dispatch_cmd_deprecated(void)
 {
-    const char *cmd = "{ 'execute': 'test-command-features1' }";
+    #define cmd "{ 'execute': 'test-command-features1' }"
     QDict *ret;
 
     memset(&compat_policy, 0, sizeof(compat_policy));
@@ -287,12 +289,13 @@ static void test_dispatch_cmd_deprecated(void)
 
     compat_policy.deprecated_input = COMPAT_POLICY_INPUT_REJECT;
     do_qmp_dispatch_error(false, ERROR_CLASS_COMMAND_NOT_FOUND, cmd);
+    #undef cmd
 }
 
 static void test_dispatch_cmd_arg_deprecated(void)
 {
-    const char *cmd = "{ 'execute': 'test-features0',"
-        " 'arguments': { 'fs1': { 'foo': 42 } } }";
+    #define cmd "{ 'execute': 'test-features0'," \
+        " 'arguments': { 'fs1': { 'foo': 42 } } }"
     QDict *ret;
 
     memset(&compat_policy, 0, sizeof(compat_policy));
@@ -310,11 +313,12 @@ static void test_dispatch_cmd_arg_deprecated(void)
 
     compat_policy.deprecated_input = COMPAT_POLICY_INPUT_REJECT;
     do_qmp_dispatch_error(false, ERROR_CLASS_GENERIC_ERROR, cmd);
+    #undef cmd
 }
 
 static void test_dispatch_cmd_ret_deprecated(void)
 {
-    const char *cmd = "{ 'execute': 'test-features0' }";
+    #define cmd "{ 'execute': 'test-features0' }"
     QDict *ret;
 
     memset(&compat_policy, 0, sizeof(compat_policy));
@@ -334,6 +338,7 @@ static void test_dispatch_cmd_ret_deprecated(void)
     ret = qobject_to(QDict, do_qmp_dispatch(false, cmd));
     assert(ret && qdict_size(ret) == 0);
     qobject_unref(ret);
+    #undef cmd
 }
 
 /* test generated dealloc functions for generated types */
-- 
2.38.1



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

* [PULL 14/29] enforce use of G_GNUC_PRINTF attributes
  2023-01-10 16:02 [PULL 00/29] Misc patches for 2023-01-10 Paolo Bonzini
                   ` (12 preceding siblings ...)
  2023-01-10 16:02 ` [PULL 13/29] tests: " Paolo Bonzini
@ 2023-01-10 16:02 ` Paolo Bonzini
  2023-01-10 16:02 ` [PULL 15/29] hw/display: avoid creating empty loadable modules Paolo Bonzini
                   ` (15 subsequent siblings)
  29 siblings, 0 replies; 37+ messages in thread
From: Paolo Bonzini @ 2023-01-10 16:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: Daniel P. Berrangé

From: Daniel P. Berrangé <berrange@redhat.com>

We've been very gradually adding G_GNUC_PRINTF annotations
to functions over years. This has been useful in detecting
certain malformed printf strings, or cases where we pass
user data as the printf format which is a potential security
flaw.

Given the inherant memory corruption danger in use of format
strings vs mis-matched variadic arguments, it is worth applying
G_GNUC_PRINTF to all functions using printf, even if we know
they are safe.

The compilers can reasonably reliably identify such places
with the -Wsuggest-attribute=format / -Wmissing-format-attribute
flags.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Message-Id: <20221219130205.687815-7-berrange@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 configure | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/configure b/configure
index 6f5e77a71361..203b957a045f 100755
--- a/configure
+++ b/configure
@@ -1183,6 +1183,8 @@ add_to warn_flags -Wnested-externs
 add_to warn_flags -Wendif-labels
 add_to warn_flags -Wexpansion-to-defined
 add_to warn_flags -Wimplicit-fallthrough=2
+add_to warn_flags -Wsuggest-attribute=format
+add_to warn_flags -Wmissing-format-attribute
 
 nowarn_flags=
 add_to nowarn_flags -Wno-initializer-overrides
-- 
2.38.1



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

* [PULL 15/29] hw/display: avoid creating empty loadable modules
  2023-01-10 16:02 [PULL 00/29] Misc patches for 2023-01-10 Paolo Bonzini
                   ` (13 preceding siblings ...)
  2023-01-10 16:02 ` [PULL 14/29] enforce use of G_GNUC_PRINTF attributes Paolo Bonzini
@ 2023-01-10 16:02 ` Paolo Bonzini
  2023-01-10 16:02 ` [PULL 16/29] libvhost-user: Provide _GNU_SOURCE when compiling outside of QEMU Paolo Bonzini
                   ` (14 subsequent siblings)
  29 siblings, 0 replies; 37+ messages in thread
From: Paolo Bonzini @ 2023-01-10 16:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: Daniel P. Berrangé

From: Daniel P. Berrangé <berrange@redhat.com>

When using --disable-virglrenderer, QEMU still creates

  hw-display-virtio-gpu-gl.so
  hw-display-virtio-vga-gl.so
  hw-display-virtio-gpu-pci-gl.so

but when these are loaded, they provide no functionality as the code
which registers types is not compiled in. Funtionally this is
relatively harmless, because QEMU is fine loading a module with no
types.

This is rather confusing for users and OS distro maintainers though,
as they think they have the GL functionality built, but in fact the
module they are looking at provides nothing of value.

The root cause is the use of 'when/if_true' rules when adding sources
to the module source set. If all the rules evaluate to false, then we
have declared the module, but not added anything to it.  We need to
put declaration of the entire module inside a condition based on
existance of the 3rd party library deps that are mandatory.

Fixes: https://gitlab.com/qemu-project/qemu/-/issues/1352
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Message-Id: <20221219125830.2369169-1-berrange@redhat.com>
[Do not check for pixman. - Paolo]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/display/meson.build | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/hw/display/meson.build b/hw/display/meson.build
index 7a725ed80eb5..f860c2c562ac 100644
--- a/hw/display/meson.build
+++ b/hw/display/meson.build
@@ -73,10 +73,12 @@ if config_all_devices.has_key('CONFIG_VIRTIO_GPU')
   virtio_gpu_ss.add(when: 'CONFIG_VHOST_USER_GPU', if_true: files('vhost-user-gpu.c'))
   hw_display_modules += {'virtio-gpu': virtio_gpu_ss}
 
-  virtio_gpu_gl_ss = ss.source_set()
-  virtio_gpu_gl_ss.add(when: ['CONFIG_VIRTIO_GPU', virgl, opengl],
-                       if_true: [files('virtio-gpu-gl.c', 'virtio-gpu-virgl.c'), pixman, virgl])
-  hw_display_modules += {'virtio-gpu-gl': virtio_gpu_gl_ss}
+  if virgl.found() and opengl.found()
+    virtio_gpu_gl_ss = ss.source_set()
+    virtio_gpu_gl_ss.add(when: ['CONFIG_VIRTIO_GPU', virgl, opengl],
+                         if_true: [files('virtio-gpu-gl.c', 'virtio-gpu-virgl.c'), pixman, virgl])
+    hw_display_modules += {'virtio-gpu-gl': virtio_gpu_gl_ss}
+  endif
 endif
 
 if config_all_devices.has_key('CONFIG_VIRTIO_PCI')
@@ -87,10 +89,12 @@ if config_all_devices.has_key('CONFIG_VIRTIO_PCI')
                         if_true: files('vhost-user-gpu-pci.c'))
   hw_display_modules += {'virtio-gpu-pci': virtio_gpu_pci_ss}
 
-  virtio_gpu_pci_gl_ss = ss.source_set()
-  virtio_gpu_pci_gl_ss.add(when: ['CONFIG_VIRTIO_GPU', 'CONFIG_VIRTIO_PCI', virgl, opengl],
-                           if_true: [files('virtio-gpu-pci-gl.c'), pixman])
-  hw_display_modules += {'virtio-gpu-pci-gl': virtio_gpu_pci_gl_ss}
+  if virgl.found() and opengl.found()
+    virtio_gpu_pci_gl_ss = ss.source_set()
+    virtio_gpu_pci_gl_ss.add(when: ['CONFIG_VIRTIO_GPU', 'CONFIG_VIRTIO_PCI', virgl, opengl],
+                             if_true: [files('virtio-gpu-pci-gl.c'), pixman])
+    hw_display_modules += {'virtio-gpu-pci-gl': virtio_gpu_pci_gl_ss}
+  endif
 endif
 
 if config_all_devices.has_key('CONFIG_VIRTIO_VGA')
-- 
2.38.1



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

* [PULL 16/29] libvhost-user: Provide _GNU_SOURCE when compiling outside of QEMU
  2023-01-10 16:02 [PULL 00/29] Misc patches for 2023-01-10 Paolo Bonzini
                   ` (14 preceding siblings ...)
  2023-01-10 16:02 ` [PULL 15/29] hw/display: avoid creating empty loadable modules Paolo Bonzini
@ 2023-01-10 16:02 ` Paolo Bonzini
  2023-01-10 16:02 ` [PULL 17/29] libvhost-user: Replace typeof with __typeof__ Paolo Bonzini
                   ` (13 subsequent siblings)
  29 siblings, 0 replies; 37+ messages in thread
From: Paolo Bonzini @ 2023-01-10 16:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: Marcel Holtmann

From: Marcel Holtmann <marcel@holtmann.org>

Then the libvhost-user sources are used by another project, it can not
be guaranteed that _GNU_SOURCE is set by the build system. If it is for
example not set, errors like this show up.

  CC       libvhost-user.o
libvhost-user.c: In function ‘vu_panic’:
libvhost-user.c:195:9: error: implicit declaration of function ‘vasprintf’; did you mean ‘vsprintf’? [-Werror=implicit-function-declaration]
  195 |     if (vasprintf(&buf, msg, ap) < 0) {
      |         ^~~~~~~~~
      |         vsprintf

The simplest way to allow external complication of libvhost-user.[ch] is
by setting _GNU_SOURCE if it is not already set by the build system.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Message-Id: <be27dcc747a6b5cc6f8ae3f79e0b79171382bcef.1671741278.git.marcel@holtmann.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 subprojects/libvhost-user/libvhost-user.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/subprojects/libvhost-user/libvhost-user.c b/subprojects/libvhost-user/libvhost-user.c
index d6ee6e7d9168..b55b9e244d9a 100644
--- a/subprojects/libvhost-user/libvhost-user.c
+++ b/subprojects/libvhost-user/libvhost-user.c
@@ -13,6 +13,10 @@
  * later.  See the COPYING file in the top-level directory.
  */
 
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+
 /* this code avoids GLib dependency */
 #include <stdlib.h>
 #include <stdio.h>
-- 
2.38.1



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

* [PULL 17/29] libvhost-user: Replace typeof with __typeof__
  2023-01-10 16:02 [PULL 00/29] Misc patches for 2023-01-10 Paolo Bonzini
                   ` (15 preceding siblings ...)
  2023-01-10 16:02 ` [PULL 16/29] libvhost-user: Provide _GNU_SOURCE when compiling outside of QEMU Paolo Bonzini
@ 2023-01-10 16:02 ` Paolo Bonzini
  2023-01-10 16:02 ` [PULL 18/29] libvhost-user: Cast rc variable to avoid compiler warning Paolo Bonzini
                   ` (12 subsequent siblings)
  29 siblings, 0 replies; 37+ messages in thread
From: Paolo Bonzini @ 2023-01-10 16:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: Marcel Holtmann, Philippe Mathieu-Daudé

From: Marcel Holtmann <marcel@holtmann.org>

Strictly speaking only -std=gnu99 support the usage of typeof and for
easier inclusion in external projects, it is better to use __typeof__.

  CC       libvhost-user.o
libvhost-user.c: In function ‘vu_log_queue_fill’:
libvhost-user.c:86:13: error: implicit declaration of function ‘typeof’ [-Werror=implicit-function-declaration]
   86 |             typeof(x) _min1 = (x);              \
      |             ^~~~~~

Changing these two users of typeof makes the compiler happy and no extra
flags or pragmas need to be provided.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-Id: <981aa822bcaaa2b8d74f245339a99a85c25b346f.1671741278.git.marcel@holtmann.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 subprojects/libvhost-user/libvhost-user.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/subprojects/libvhost-user/libvhost-user.c b/subprojects/libvhost-user/libvhost-user.c
index b55b9e244d9a..67d75ece53b7 100644
--- a/subprojects/libvhost-user/libvhost-user.c
+++ b/subprojects/libvhost-user/libvhost-user.c
@@ -62,8 +62,8 @@
 #endif  /* !__GNUC__ */
 #ifndef MIN
 #define MIN(x, y) ({                            \
-            typeof(x) _min1 = (x);              \
-            typeof(y) _min2 = (y);              \
+            __typeof__(x) _min1 = (x);          \
+            __typeof__(y) _min2 = (y);          \
             (void) (&_min1 == &_min2);          \
             _min1 < _min2 ? _min1 : _min2; })
 #endif
-- 
2.38.1



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

* [PULL 18/29] libvhost-user: Cast rc variable to avoid compiler warning
  2023-01-10 16:02 [PULL 00/29] Misc patches for 2023-01-10 Paolo Bonzini
                   ` (16 preceding siblings ...)
  2023-01-10 16:02 ` [PULL 17/29] libvhost-user: Replace typeof with __typeof__ Paolo Bonzini
@ 2023-01-10 16:02 ` Paolo Bonzini
  2023-01-10 16:02 ` [PULL 19/29] libvhost-user: Use unsigned int i for some for-loop iterations Paolo Bonzini
                   ` (11 subsequent siblings)
  29 siblings, 0 replies; 37+ messages in thread
From: Paolo Bonzini @ 2023-01-10 16:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: Marcel Holtmann

From: Marcel Holtmann <marcel@holtmann.org>

The assert from recvmsg() return value against an uint32_t size field
from a protocol struct throws a compiler warning.

  CC       libvhost-user.o
In file included from libvhost-user.c:27:
libvhost-user.c: In function ‘vu_message_read_default’:
libvhost-user.c:363:19: error: comparison of integer expressions of different signedness: ‘int’ and ‘uint32_t’ {aka ‘unsigned int’} [-Werror=sign-compare]
  363 |         assert(rc == vmsg->size);
      |                   ^~

This is not critical, but annoying when the libvhost-user source are
used in an external project that has this compiler warning switched on.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Message-Id: <7a791e27b7bd3e0a8b8cc8fbb15090a870d226d5.1671741278.git.marcel@holtmann.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 subprojects/libvhost-user/libvhost-user.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/subprojects/libvhost-user/libvhost-user.c b/subprojects/libvhost-user/libvhost-user.c
index 67d75ece53b7..bcdf32a24f60 100644
--- a/subprojects/libvhost-user/libvhost-user.c
+++ b/subprojects/libvhost-user/libvhost-user.c
@@ -339,7 +339,7 @@ vu_message_read_default(VuDev *dev, int conn_fd, VhostUserMsg *vmsg)
             goto fail;
         }
 
-        assert(rc == vmsg->size);
+        assert((uint32_t)rc == vmsg->size);
     }
 
     return true;
-- 
2.38.1



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

* [PULL 19/29] libvhost-user: Use unsigned int i for some for-loop iterations
  2023-01-10 16:02 [PULL 00/29] Misc patches for 2023-01-10 Paolo Bonzini
                   ` (17 preceding siblings ...)
  2023-01-10 16:02 ` [PULL 18/29] libvhost-user: Cast rc variable to avoid compiler warning Paolo Bonzini
@ 2023-01-10 16:02 ` Paolo Bonzini
  2023-01-10 16:02 ` [PULL 20/29] libvhost-user: Declare uffdio_register early to make it C90 compliant Paolo Bonzini
                   ` (10 subsequent siblings)
  29 siblings, 0 replies; 37+ messages in thread
From: Paolo Bonzini @ 2023-01-10 16:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: Marcel Holtmann

From: Marcel Holtmann <marcel@holtmann.org>

The sign-compare warning also hits some of the for-loops, but it easy
fixed by just making the iterator variable unsigned int.

  CC       libvhost-user.o
libvhost-user.c: In function ‘vu_gpa_to_va’:
libvhost-user.c:223:19: error: comparison of integer expressions of different signedness: ‘int’ and ‘uint32_t’ {aka ‘unsigned int’} [-Werror=sign-compare]
  223 |     for (i = 0; i < dev->nregions; i++) {
      |                   ^

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Message-Id: <decb925e1a6fb9538738d2570bda2804f888fa15.1671741278.git.marcel@holtmann.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 subprojects/libvhost-user/libvhost-user.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/subprojects/libvhost-user/libvhost-user.c b/subprojects/libvhost-user/libvhost-user.c
index bcdf32a24f60..211d31a4cc88 100644
--- a/subprojects/libvhost-user/libvhost-user.c
+++ b/subprojects/libvhost-user/libvhost-user.c
@@ -192,7 +192,7 @@ vu_panic(VuDev *dev, const char *msg, ...)
 void *
 vu_gpa_to_va(VuDev *dev, uint64_t *plen, uint64_t guest_addr)
 {
-    int i;
+    unsigned int i;
 
     if (*plen == 0) {
         return NULL;
@@ -218,7 +218,7 @@ vu_gpa_to_va(VuDev *dev, uint64_t *plen, uint64_t guest_addr)
 static void *
 qva_to_va(VuDev *dev, uint64_t qemu_addr)
 {
-    int i;
+    unsigned int i;
 
     /* Find matching memory region.  */
     for (i = 0; i < dev->nregions; i++) {
@@ -621,7 +621,7 @@ map_ring(VuDev *dev, VuVirtq *vq)
 
 static bool
 generate_faults(VuDev *dev) {
-    int i;
+    unsigned int i;
     for (i = 0; i < dev->nregions; i++) {
         VuDevRegion *dev_region = &dev->regions[i];
         int ret;
@@ -829,7 +829,7 @@ static inline bool reg_equal(VuDevRegion *vudev_reg,
 static bool
 vu_rem_mem_reg(VuDev *dev, VhostUserMsg *vmsg) {
     VhostUserMemoryRegion m = vmsg->payload.memreg.region, *msg_region = &m;
-    int i;
+    unsigned int i;
     bool found = false;
 
     if (vmsg->fd_num > 1) {
@@ -895,7 +895,7 @@ vu_rem_mem_reg(VuDev *dev, VhostUserMsg *vmsg) {
 static bool
 vu_set_mem_table_exec_postcopy(VuDev *dev, VhostUserMsg *vmsg)
 {
-    int i;
+    unsigned int i;
     VhostUserMemory m = vmsg->payload.memory, *memory = &m;
     dev->nregions = memory->nregions;
 
@@ -972,7 +972,7 @@ vu_set_mem_table_exec_postcopy(VuDev *dev, VhostUserMsg *vmsg)
 static bool
 vu_set_mem_table_exec(VuDev *dev, VhostUserMsg *vmsg)
 {
-    int i;
+    unsigned int i;
     VhostUserMemory m = vmsg->payload.memory, *memory = &m;
 
     for (i = 0; i < dev->nregions; i++) {
@@ -1980,7 +1980,7 @@ end:
 void
 vu_deinit(VuDev *dev)
 {
-    int i;
+    unsigned int i;
 
     for (i = 0; i < dev->nregions; i++) {
         VuDevRegion *r = &dev->regions[i];
-- 
2.38.1



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

* [PULL 20/29] libvhost-user: Declare uffdio_register early to make it C90 compliant
  2023-01-10 16:02 [PULL 00/29] Misc patches for 2023-01-10 Paolo Bonzini
                   ` (18 preceding siblings ...)
  2023-01-10 16:02 ` [PULL 19/29] libvhost-user: Use unsigned int i for some for-loop iterations Paolo Bonzini
@ 2023-01-10 16:02 ` Paolo Bonzini
  2023-01-10 16:02 ` [PULL 21/29] libvhost-user: Change dev->postcopy_ufd assignment " Paolo Bonzini
                   ` (9 subsequent siblings)
  29 siblings, 0 replies; 37+ messages in thread
From: Paolo Bonzini @ 2023-01-10 16:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: Marcel Holtmann, Philippe Mathieu-Daudé

From: Marcel Holtmann <marcel@holtmann.org>

When using libvhost-user source in an external project that wants to
comply with the C90 standard, it is best to declare variables before
code.

  CC       libvhost-user.o
libvhost-user.c: In function ‘generate_faults’:
libvhost-user.c:683:9: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
  683 |         struct uffdio_register reg_struct;
      |         ^~~~~~

In this case, it is also simple enough and doesn't cause any extra
ifdef additions.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-Id: <556c2d00c01fa134d13c0371d4014c90694c2943.1671741278.git.marcel@holtmann.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 subprojects/libvhost-user/libvhost-user.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/subprojects/libvhost-user/libvhost-user.c b/subprojects/libvhost-user/libvhost-user.c
index 211d31a4cc88..bf92cc85c086 100644
--- a/subprojects/libvhost-user/libvhost-user.c
+++ b/subprojects/libvhost-user/libvhost-user.c
@@ -626,6 +626,8 @@ generate_faults(VuDev *dev) {
         VuDevRegion *dev_region = &dev->regions[i];
         int ret;
 #ifdef UFFDIO_REGISTER
+        struct uffdio_register reg_struct;
+
         /*
          * We should already have an open ufd. Mark each memory
          * range as ufd.
@@ -659,7 +661,7 @@ generate_faults(VuDev *dev) {
                     "%s: Failed to madvise(NOHUGEPAGE) region %d: %s\n",
                     __func__, i, strerror(errno));
         }
-        struct uffdio_register reg_struct;
+
         reg_struct.range.start = (uintptr_t)dev_region->mmap_addr;
         reg_struct.range.len = dev_region->size + dev_region->mmap_offset;
         reg_struct.mode = UFFDIO_REGISTER_MODE_MISSING;
-- 
2.38.1



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

* [PULL 21/29] libvhost-user: Change dev->postcopy_ufd assignment to make it C90 compliant
  2023-01-10 16:02 [PULL 00/29] Misc patches for 2023-01-10 Paolo Bonzini
                   ` (19 preceding siblings ...)
  2023-01-10 16:02 ` [PULL 20/29] libvhost-user: Declare uffdio_register early to make it C90 compliant Paolo Bonzini
@ 2023-01-10 16:02 ` Paolo Bonzini
  2023-01-10 16:02 ` [PULL 22/29] libvduse: Provide _GNU_SOURCE when compiling outside of QEMU Paolo Bonzini
                   ` (8 subsequent siblings)
  29 siblings, 0 replies; 37+ messages in thread
From: Paolo Bonzini @ 2023-01-10 16:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: Marcel Holtmann, Philippe Mathieu-Daudé

From: Marcel Holtmann <marcel@holtmann.org>

The assignment of dev->postcopy_ufd can be moved into an else clause and
then the code becomes C90 compliant.

  CC       libvhost-user.o
libvhost-user.c: In function ‘vu_set_postcopy_advise’:
libvhost-user.c:1625:5: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
 1625 |     struct uffdio_api api_struct;
      |     ^~~~~~

Understandable, it might be desired to avoid else clauses, but in this
case it seems clear enough and frankly the dev->postcopy_ufd is only
assigned once.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-Id: <74db52afb1203c4580ffc7fa462b4b2ba260a353.1671741278.git.marcel@holtmann.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 subprojects/libvhost-user/libvhost-user.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/subprojects/libvhost-user/libvhost-user.c b/subprojects/libvhost-user/libvhost-user.c
index bf92cc85c086..b28b66cdb159 100644
--- a/subprojects/libvhost-user/libvhost-user.c
+++ b/subprojects/libvhost-user/libvhost-user.c
@@ -1599,12 +1599,13 @@ vu_set_config(VuDev *dev, VhostUserMsg *vmsg)
 static bool
 vu_set_postcopy_advise(VuDev *dev, VhostUserMsg *vmsg)
 {
-    dev->postcopy_ufd = -1;
 #ifdef UFFDIO_API
     struct uffdio_api api_struct;
 
     dev->postcopy_ufd = syscall(__NR_userfaultfd, O_CLOEXEC | O_NONBLOCK);
     vmsg->size = 0;
+#else
+    dev->postcopy_ufd = -1;
 #endif
 
     if (dev->postcopy_ufd == -1) {
-- 
2.38.1



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

* [PULL 22/29] libvduse: Provide _GNU_SOURCE when compiling outside of QEMU
  2023-01-10 16:02 [PULL 00/29] Misc patches for 2023-01-10 Paolo Bonzini
                   ` (20 preceding siblings ...)
  2023-01-10 16:02 ` [PULL 21/29] libvhost-user: Change dev->postcopy_ufd assignment " Paolo Bonzini
@ 2023-01-10 16:02 ` Paolo Bonzini
  2023-01-10 16:02 ` [PULL 23/29] libvduse: Switch to unsigned int for inuse field in struct VduseVirtq Paolo Bonzini
                   ` (7 subsequent siblings)
  29 siblings, 0 replies; 37+ messages in thread
From: Paolo Bonzini @ 2023-01-10 16:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: Marcel Holtmann

From: Marcel Holtmann <marcel@holtmann.org>

When the libvduse sources are used by another project, it can not be
guaranteed that _GNU_SOURCE is set by the build system. If it is for
example not set, errors like this show up.

  CC       libvduse.o
libvduse.c: In function ‘vduse_log_get’:
libvduse.c:172:9: error: implicit declaration of function ‘ftruncate’; did you mean ‘strncat’? [-Werror=implicit-function-declaration]
  172 |     if (ftruncate(fd, size) == -1) {
      |         ^~~~~~~~~
      |         strncat

The simplest way to allow external complication of libvduse.[ch] by
setting _GNU_SOURCE if it is not already set by the build system.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Message-Id: <407f3665f0605df936e5bfe60831d180edfb8cca.1671741278.git.marcel@holtmann.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 subprojects/libvduse/libvduse.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/subprojects/libvduse/libvduse.c b/subprojects/libvduse/libvduse.c
index e089d4d546cf..c871bd331a6b 100644
--- a/subprojects/libvduse/libvduse.c
+++ b/subprojects/libvduse/libvduse.c
@@ -16,6 +16,10 @@
  * later.  See the COPYING file in the top-level directory.
  */
 
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+
 #include <stdlib.h>
 #include <stdio.h>
 #include <stdbool.h>
-- 
2.38.1



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

* [PULL 23/29] libvduse: Switch to unsigned int for inuse field in struct VduseVirtq
  2023-01-10 16:02 [PULL 00/29] Misc patches for 2023-01-10 Paolo Bonzini
                   ` (21 preceding siblings ...)
  2023-01-10 16:02 ` [PULL 22/29] libvduse: Provide _GNU_SOURCE when compiling outside of QEMU Paolo Bonzini
@ 2023-01-10 16:02 ` Paolo Bonzini
  2023-01-10 16:02 ` [PULL 24/29] libvduse: Fix assignment in vring_set_avail_event Paolo Bonzini
                   ` (6 subsequent siblings)
  29 siblings, 0 replies; 37+ messages in thread
From: Paolo Bonzini @ 2023-01-10 16:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: Marcel Holtmann, Xie Yongji

From: Marcel Holtmann <marcel@holtmann.org>

It seems there is no need to keep the inuse field signed and end up with
compiler warnings for sign-compare.

  CC       libvduse.o
libvduse.c: In function ‘vduse_queue_pop’:
libvduse.c:789:19: error: comparison of integer expressions of different signedness: ‘int’ and ‘unsigned int’ [-Werror=sign-compare]
  789 |     if (vq->inuse >= vq->vring.num) {
      |                   ^~

Instead of casting the comparison to unsigned int, just make the inuse
field unsigned int in the fist place.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Reviewed-by: Xie Yongji <xieyongji@bytedance.com>
Message-Id: <9fe3fd8b042e048bd04d506ca6e43d738b5c45b7.1671741278.git.marcel@holtmann.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 subprojects/libvduse/libvduse.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/subprojects/libvduse/libvduse.c b/subprojects/libvduse/libvduse.c
index c871bd331a6b..338ad5e352e7 100644
--- a/subprojects/libvduse/libvduse.c
+++ b/subprojects/libvduse/libvduse.c
@@ -101,7 +101,7 @@ struct VduseVirtq {
     uint16_t signalled_used;
     bool signalled_used_valid;
     int index;
-    int inuse;
+    unsigned int inuse;
     bool ready;
     int fd;
     VduseDev *dev;
-- 
2.38.1



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

* [PULL 24/29] libvduse: Fix assignment in vring_set_avail_event
  2023-01-10 16:02 [PULL 00/29] Misc patches for 2023-01-10 Paolo Bonzini
                   ` (22 preceding siblings ...)
  2023-01-10 16:02 ` [PULL 23/29] libvduse: Switch to unsigned int for inuse field in struct VduseVirtq Paolo Bonzini
@ 2023-01-10 16:02 ` Paolo Bonzini
  2023-01-10 16:02 ` [PULL 25/29] libvhost-user: " Paolo Bonzini
                   ` (5 subsequent siblings)
  29 siblings, 0 replies; 37+ messages in thread
From: Paolo Bonzini @ 2023-01-10 16:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: Marcel Holtmann, Xie Yongji

From: Marcel Holtmann <marcel@holtmann.org>

Since the assignment is causing a compiler warning, fix it by using
memcpy instead.

  CC       libvduse.o
libvduse.c: In function ‘vring_set_avail_event’:
libvduse.c:603:7: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasin]
  603 |     *((uint16_t *)&vq->vring.used->ring[vq->vring.num]) = htole16(val);
      |      ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Suggested-by: Xie Yongji <xieyongji@bytedance.com>
Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <4a0fe2a6436464473119fdbf0bc4076b36fbb37f.1671741278.git.marcel@holtmann.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 subprojects/libvduse/libvduse.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/subprojects/libvduse/libvduse.c b/subprojects/libvduse/libvduse.c
index 338ad5e352e7..377959a0b4fb 100644
--- a/subprojects/libvduse/libvduse.c
+++ b/subprojects/libvduse/libvduse.c
@@ -582,7 +582,8 @@ void vduse_queue_notify(VduseVirtq *vq)
 
 static inline void vring_set_avail_event(VduseVirtq *vq, uint16_t val)
 {
-    *((uint16_t *)&vq->vring.used->ring[vq->vring.num]) = htole16(val);
+    uint16_t val_le = htole16(val);
+    memcpy(&vq->vring.used->ring[vq->vring.num], &val_le, sizeof(uint16_t));
 }
 
 static bool vduse_queue_map_single_desc(VduseVirtq *vq, unsigned int *p_num_sg,
-- 
2.38.1



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

* [PULL 25/29] libvhost-user: Fix assignment in vring_set_avail_event
  2023-01-10 16:02 [PULL 00/29] Misc patches for 2023-01-10 Paolo Bonzini
                   ` (23 preceding siblings ...)
  2023-01-10 16:02 ` [PULL 24/29] libvduse: Fix assignment in vring_set_avail_event Paolo Bonzini
@ 2023-01-10 16:02 ` Paolo Bonzini
  2023-01-10 16:02 ` [PULL 26/29] libvhost-user: Add extra compiler warnings Paolo Bonzini
                   ` (4 subsequent siblings)
  29 siblings, 0 replies; 37+ messages in thread
From: Paolo Bonzini @ 2023-01-10 16:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: Marcel Holtmann

From: Marcel Holtmann <marcel@holtmann.org>

Since it was proposed to change the code in libvduse.c to use memcpy
instead of an assignment, the code in libvhost-user.c should also be
changed to use memcpy.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <502b22723264db064e4b05008233a9c1f2f8aaaa.1671741278.git.marcel@holtmann.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 subprojects/libvhost-user/libvhost-user.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/subprojects/libvhost-user/libvhost-user.c b/subprojects/libvhost-user/libvhost-user.c
index b28b66cdb159..fc69783d2bf6 100644
--- a/subprojects/libvhost-user/libvhost-user.c
+++ b/subprojects/libvhost-user/libvhost-user.c
@@ -2478,14 +2478,13 @@ vring_used_flags_unset_bit(VuVirtq *vq, int mask)
 static inline void
 vring_set_avail_event(VuVirtq *vq, uint16_t val)
 {
-    uint16_t *avail;
+    uint16_t val_le = htole16(val);
 
     if (!vq->notification) {
         return;
     }
 
-    avail = (uint16_t *)&vq->vring.used->ring[vq->vring.num];
-    *avail = htole16(val);
+    memcpy(&vq->vring.used->ring[vq->vring.num], &val_le, sizeof(uint16_t));
 }
 
 void
-- 
2.38.1



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

* [PULL 26/29] libvhost-user: Add extra compiler warnings
  2023-01-10 16:02 [PULL 00/29] Misc patches for 2023-01-10 Paolo Bonzini
                   ` (24 preceding siblings ...)
  2023-01-10 16:02 ` [PULL 25/29] libvhost-user: " Paolo Bonzini
@ 2023-01-10 16:02 ` Paolo Bonzini
  2023-01-10 16:02 ` [PULL 27/29] libvduse: " Paolo Bonzini
                   ` (3 subsequent siblings)
  29 siblings, 0 replies; 37+ messages in thread
From: Paolo Bonzini @ 2023-01-10 16:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: Marcel Holtmann

From: Marcel Holtmann <marcel@holtmann.org>

In case libvhost-user is used externally, that projects compiler
warnings might be more strict. Enforce an extra set of compiler warnings
to catch issues early on.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <737ebf2e697f8640558e6f73d96a692711f548f6.1671741278.git.marcel@holtmann.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 subprojects/libvhost-user/meson.build | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/subprojects/libvhost-user/meson.build b/subprojects/libvhost-user/meson.build
index 39825d9404ae..a18014e7f26f 100644
--- a/subprojects/libvhost-user/meson.build
+++ b/subprojects/libvhost-user/meson.build
@@ -1,6 +1,12 @@
 project('libvhost-user', 'c',
         license: 'GPL-2.0-or-later',
-        default_options: ['c_std=gnu99'])
+        default_options: ['warning_level=1', 'c_std=gnu99'])
+
+cc = meson.get_compiler('c')
+add_project_arguments(cc.get_supported_arguments('-Wsign-compare',
+                                                 '-Wdeclaration-after-statement',
+                                                 '-Wstrict-aliasing'),
+                      native: false, language: 'c')
 
 threads = dependency('threads')
 glib = dependency('glib-2.0')
-- 
2.38.1



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

* [PULL 27/29] libvduse: Add extra compiler warnings
  2023-01-10 16:02 [PULL 00/29] Misc patches for 2023-01-10 Paolo Bonzini
                   ` (25 preceding siblings ...)
  2023-01-10 16:02 ` [PULL 26/29] libvhost-user: Add extra compiler warnings Paolo Bonzini
@ 2023-01-10 16:02 ` Paolo Bonzini
  2023-01-10 16:02 ` [PULL 28/29] target/i386: fix operand size of unary SSE operations Paolo Bonzini
                   ` (2 subsequent siblings)
  29 siblings, 0 replies; 37+ messages in thread
From: Paolo Bonzini @ 2023-01-10 16:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: Marcel Holtmann

From: Marcel Holtmann <marcel@holtmann.org>

In case libvhost-user is used externally, that projects compiler
warnings might be more strict. Enforce an extra set of compiler warnings
to catch issues early on.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <08daa1896ad8824e17d57d6a970bc0b4bee73ece.1671741278.git.marcel@holtmann.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 subprojects/libvduse/meson.build | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/subprojects/libvduse/meson.build b/subprojects/libvduse/meson.build
index ba08f5ee1a03..3e3b53da33ae 100644
--- a/subprojects/libvduse/meson.build
+++ b/subprojects/libvduse/meson.build
@@ -1,6 +1,12 @@
 project('libvduse', 'c',
         license: 'GPL-2.0-or-later',
-        default_options: ['c_std=gnu99'])
+        default_options: ['warning_level=1', 'c_std=gnu99'])
+
+cc = meson.get_compiler('c')
+add_project_arguments(cc.get_supported_arguments('-Wsign-compare',
+                                                 '-Wdeclaration-after-statement',
+                                                 '-Wstrict-aliasing'),
+                      native: false, language: 'c')
 
 libvduse = static_library('vduse',
                           files('libvduse.c'),
-- 
2.38.1



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

* [PULL 28/29] target/i386: fix operand size of unary SSE operations
  2023-01-10 16:02 [PULL 00/29] Misc patches for 2023-01-10 Paolo Bonzini
                   ` (26 preceding siblings ...)
  2023-01-10 16:02 ` [PULL 27/29] libvduse: " Paolo Bonzini
@ 2023-01-10 16:02 ` Paolo Bonzini
  2023-01-10 16:02 ` [PULL 29/29] configure: remove backwards-compatibility code Paolo Bonzini
  2023-01-10 22:07 ` [PULL 00/29] Misc patches for 2023-01-10 Peter Maydell
  29 siblings, 0 replies; 37+ messages in thread
From: Paolo Bonzini @ 2023-01-10 16:02 UTC (permalink / raw)
  To: qemu-devel

VRCPSS, VRSQRTSS and VCVTSx2Sx have a 32-bit or 64-bit memory operand,
which is represented in the decoding tables by X86_VEX_REPScalar.  Add it
to the tables, and make validate_vex() handle the case of an instruction
that is in exception type 4 without the REP prefix and exception type 5
with it; this is the cas of VRCP and VRSQRT.

Reported-by: yongwoo <https://gitlab.com/yongwoo36>
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1377
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 target/i386/tcg/decode-new.c.inc | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/target/i386/tcg/decode-new.c.inc b/target/i386/tcg/decode-new.c.inc
index 80c579164ff2..d5fd8d965c44 100644
--- a/target/i386/tcg/decode-new.c.inc
+++ b/target/i386/tcg/decode-new.c.inc
@@ -105,6 +105,7 @@
 #define vex3 .vex_class = 3,
 #define vex4 .vex_class = 4,
 #define vex4_unal .vex_class = 4, .vex_special = X86_VEX_SSEUnaligned,
+#define vex4_rep5 .vex_class = 4, .vex_special = X86_VEX_REPScalar,
 #define vex5 .vex_class = 5,
 #define vex6 .vex_class = 6,
 #define vex7 .vex_class = 7,
@@ -839,8 +840,8 @@ static const X86OpEntry opcodes_0F[256] = {
 
     [0x50] = X86_OP_ENTRY3(MOVMSK,     G,y, None,None, U,x, vex7 p_00_66),
     [0x51] = X86_OP_GROUP3(sse_unary,  V,x, H,x, W,x, vex2_rep3 p_00_66_f3_f2),
-    [0x52] = X86_OP_GROUP3(sse_unary,  V,x, H,x, W,x, vex5 p_00_f3),
-    [0x53] = X86_OP_GROUP3(sse_unary,  V,x, H,x, W,x, vex5 p_00_f3),
+    [0x52] = X86_OP_GROUP3(sse_unary,  V,x, H,x, W,x, vex4_rep5 p_00_f3),
+    [0x53] = X86_OP_GROUP3(sse_unary,  V,x, H,x, W,x, vex4_rep5 p_00_f3),
     [0x54] = X86_OP_ENTRY3(PAND,       V,x, H,x, W,x,  vex4 p_00_66), /* vand */
     [0x55] = X86_OP_ENTRY3(PANDN,      V,x, H,x, W,x,  vex4 p_00_66), /* vandn */
     [0x56] = X86_OP_ENTRY3(POR,        V,x, H,x, W,x,  vex4 p_00_66), /* vor */
@@ -878,7 +879,7 @@ static const X86OpEntry opcodes_0F[256] = {
 
     [0x58] = X86_OP_ENTRY3(VADD,       V,x, H,x, W,x, vex2_rep3 p_00_66_f3_f2),
     [0x59] = X86_OP_ENTRY3(VMUL,       V,x, H,x, W,x, vex2_rep3 p_00_66_f3_f2),
-    [0x5a] = X86_OP_GROUP3(sse_unary,  V,x, H,x, W,x, vex3 p_00_66_f3_f2),
+    [0x5a] = X86_OP_GROUP3(sse_unary,  V,x, H,x, W,x, vex2_rep3 p_00_66_f3_f2),
     [0x5b] = X86_OP_GROUP0(0F5B),
     [0x5c] = X86_OP_ENTRY3(VSUB,       V,x, H,x, W,x, vex2_rep3 p_00_66_f3_f2),
     [0x5d] = X86_OP_ENTRY3(VMIN,       V,x, H,x, W,x, vex2_rep3 p_00_66_f3_f2),
@@ -1447,9 +1448,9 @@ static bool validate_vex(DisasContext *s, X86DecodedInsn *decode)
          * Instructions which differ between 00/66 and F2/F3 in the
          * exception classification and the size of the memory operand.
          */
-        assert(e->vex_class == 1 || e->vex_class == 2);
+        assert(e->vex_class == 1 || e->vex_class == 2 || e->vex_class == 4);
         if (s->prefix & (PREFIX_REPZ | PREFIX_REPNZ)) {
-            e->vex_class = 3;
+            e->vex_class = e->vex_class < 4 ? 3 : 5;
             if (s->vex_l) {
                 goto illegal;
             }
-- 
2.38.1



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

* [PULL 29/29] configure: remove backwards-compatibility code
  2023-01-10 16:02 [PULL 00/29] Misc patches for 2023-01-10 Paolo Bonzini
                   ` (27 preceding siblings ...)
  2023-01-10 16:02 ` [PULL 28/29] target/i386: fix operand size of unary SSE operations Paolo Bonzini
@ 2023-01-10 16:02 ` Paolo Bonzini
  2023-01-10 22:07 ` [PULL 00/29] Misc patches for 2023-01-10 Peter Maydell
  29 siblings, 0 replies; 37+ messages in thread
From: Paolo Bonzini @ 2023-01-10 16:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: Marc-André Lureau

The cmd_line.txt mangling is only needed when rebuilding from very old
trees and is kept mostly as an example of how to extend it.  However,
Meson 0.63 introduces a deprecation mechanism for meson_options.txt
that can be used instead, so get rid of our home-grown hack.

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 configure | 10 ----------
 1 file changed, 10 deletions(-)

diff --git a/configure b/configure
index 203b957a045f..77c77068c7d6 100755
--- a/configure
+++ b/configure
@@ -2569,16 +2569,6 @@ if test "$skip_meson" = no; then
   if test "$?" -ne 0 ; then
       error_exit "meson setup failed"
   fi
-else
-  if test -f meson-private/cmd_line.txt; then
-    # Adjust old command line options whose type was changed
-    # Avoids having to use "setup --wipe" when Meson is upgraded
-    perl -i -ne '
-      s/^gettext = true$/gettext = auto/;
-      s/^gettext = false$/gettext = disabled/;
-      /^b_staticpic/ && next;
-      print;' meson-private/cmd_line.txt
-  fi
 fi
 
 # Save the configure command line for later reuse.
-- 
2.38.1



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

* Re: [PULL 08/29] gitlab: remove redundant setting of PKG_CONFIG_PATH
  2023-01-10 16:02 ` [PULL 08/29] gitlab: remove redundant setting of PKG_CONFIG_PATH Paolo Bonzini
@ 2023-01-10 16:40   ` Daniel P. Berrangé
  2023-01-11  9:20     ` Paolo Bonzini
  0 siblings, 1 reply; 37+ messages in thread
From: Daniel P. Berrangé @ 2023-01-10 16:40 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: qemu-devel, Stefan Hajnoczi

On Tue, Jan 10, 2023 at 05:02:12PM +0100, Paolo Bonzini wrote:
> From: Daniel P. Berrang?? <berrange@redhat.com>
> 
> The PKG_CONFIG_PATH variable is not defined in GitLab CI
> envs and even if it was, we don't need to set it to its
> existing value.
> 
> Signed-off-by: Daniel P. Berrang?? <berrange@redhat.com>

This has mangled my name - think your client sending mail
needs to specify utf8 charset in the mail headers perhaps ?

> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
> Message-Id: <20221103173044.3969425-2-berrange@redhat.com>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|



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

* Re: [PULL 06/29] target/i386: Remove compilation errors when -Werror=maybe-uninitialized
  2023-01-10 16:02 ` [PULL 06/29] target/i386: Remove compilation errors when -Werror=maybe-uninitialized Paolo Bonzini
@ 2023-01-10 17:19   ` Eric Auger
  2023-01-11  9:18     ` Paolo Bonzini
  2023-01-11 10:03   ` Philippe Mathieu-Daudé
  1 sibling, 1 reply; 37+ messages in thread
From: Eric Auger @ 2023-01-10 17:19 UTC (permalink / raw)
  To: Paolo Bonzini, qemu-devel; +Cc: Stefan Weil

Hi Paolo,

On 1/10/23 17:02, Paolo Bonzini wrote:
> From: Eric Auger <eric.auger@redhat.com>
>
> To avoid compilation errors when -Werror=maybe-uninitialized is used,
> replace 'case 3' by 'default'.
>
> Otherwise we get:
>
> ../target/i386/ops_sse.h: In function ‘helper_vpermdq_ymm’:
> ../target/i386/ops_sse.h:2495:13: error: ‘r3’ may be used
> uninitialized in this function [-Werror=maybe-uninitialized]
>    2495 |     d->Q(3) = r3;
>         |     ~~~~~~~~^~~~
> ../target/i386/ops_sse.h:2494:13: error: ‘r2’ may be used
> uninitialized in this function [-Werror=maybe-uninitialized]
>    2494 |     d->Q(2) = r2;
>         |     ~~~~~~~~^~~~
> ../target/i386/ops_sse.h:2493:13: error: ‘r1’ may be used
> uninitialized in this function [-Werror=maybe-uninitialized]
>    2493 |     d->Q(1) = r1;
>         |     ~~~~~~~~^~~~
> ../target/i386/ops_sse.h:2492:13: error: ‘r0’ may be used
> uninitialized in this function [-Werror=maybe-uninitialized]
>    2492 |     d->Q(0) = r0;
>         |     ~~~~~~~~^~~~
>
> Signed-off-by: Eric Auger <eric.auger@redhat.com>
> Suggested-by: Stefan Weil <sw@weilnetz.de>
> Fixes: 790684776861 ("target/i386: reimplement 0x0f 0x3a, add AVX")
> Message-Id: <20221221163652.1239362-1-eric.auger@redhat.com>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

you pulled v1 but there were additional comments afterwards and last
iteration was:
https://lore.kernel.org/all/20221222140158.1260748-1-eric.auger@redhat.com/

Thanks

Eric
> ---
>  target/i386/ops_sse.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/target/i386/ops_sse.h b/target/i386/ops_sse.h
> index 3cbc36a59d1a..c442c8c10cdc 100644
> --- a/target/i386/ops_sse.h
> +++ b/target/i386/ops_sse.h
> @@ -2466,7 +2466,7 @@ void helper_vpermdq_ymm(Reg *d, Reg *v, Reg *s, uint32_t order)
>          r0 = s->Q(0);
>          r1 = s->Q(1);
>          break;
> -    case 3:
> +    default:
>          r0 = s->Q(2);
>          r1 = s->Q(3);
>          break;
> @@ -2484,7 +2484,7 @@ void helper_vpermdq_ymm(Reg *d, Reg *v, Reg *s, uint32_t order)
>          r2 = s->Q(0);
>          r3 = s->Q(1);
>          break;
> -    case 3:
> +    default:
>          r2 = s->Q(2);
>          r3 = s->Q(3);
>          break;



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

* Re: [PULL 00/29] Misc patches for 2023-01-10
  2023-01-10 16:02 [PULL 00/29] Misc patches for 2023-01-10 Paolo Bonzini
                   ` (28 preceding siblings ...)
  2023-01-10 16:02 ` [PULL 29/29] configure: remove backwards-compatibility code Paolo Bonzini
@ 2023-01-10 22:07 ` Peter Maydell
  29 siblings, 0 replies; 37+ messages in thread
From: Peter Maydell @ 2023-01-10 22:07 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: qemu-devel

On Tue, 10 Jan 2023 at 18:29, Paolo Bonzini <pbonzini@redhat.com> wrote:
>
> The following changes since commit 3d83b78285d6e96636130f7d449fd02e2d4deee0:
>
>   Merge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging (2023-01-08 14:27:40 +0000)
>
> are available in the Git repository at:
>
>   https://gitlab.com/bonzini/qemu.git tags/for-upstream
>
> for you to fetch changes up to cd78f1d264c1ac7dfd7fa50abce0dec71a1f41ac:
>
>   configure: remove backwards-compatibility code (2023-01-09 16:54:56 +0100)
>
> ----------------------------------------------------------------
> * Atomic memslot updates for KVM (Emanuele, David)
> * libvhost-user/libvduse warnings fixes (Marcel)
> * i386 TCG fixes (Joe, myself)
> * Remove compilation errors when -Werror=maybe-uninitialized (Eric)
> * fix GLIB_VERSION for cross-compilation (Paolo)
>
> ----------------------------------------------------------------

This provokes a new warning in compiling the testsuite on ppc:


../../tests/fp/berkeley-testfloat-3/source/fail.c: In function 'fail':
../../tests/fp/berkeley-testfloat-3/source/fail.c:53:5: warning:
function 'fail' might be a candidate for 'gnu_printf' format attribute
[-Wsuggest-attribute=format]
   53 |     vfprintf( stderr, messagePtr, varArgs );
      |     ^~~~~~~~


thanks
-- PMM


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

* Re: [PULL 06/29] target/i386: Remove compilation errors when -Werror=maybe-uninitialized
  2023-01-10 17:19   ` Eric Auger
@ 2023-01-11  9:18     ` Paolo Bonzini
  0 siblings, 0 replies; 37+ messages in thread
From: Paolo Bonzini @ 2023-01-11  9:18 UTC (permalink / raw)
  To: eric.auger, qemu-devel; +Cc: Stefan Weil

On 1/10/23 18:19, Eric Auger wrote:
> Hi Paolo,
> 
> On 1/10/23 17:02, Paolo Bonzini wrote:
>> From: Eric Auger <eric.auger@redhat.com>
>>
>> To avoid compilation errors when -Werror=maybe-uninitialized is used,
>> replace 'case 3' by 'default'.
>>
>> Otherwise we get:
>>
>> ../target/i386/ops_sse.h: In function ‘helper_vpermdq_ymm’:
>> ../target/i386/ops_sse.h:2495:13: error: ‘r3’ may be used
>> uninitialized in this function [-Werror=maybe-uninitialized]
>>     2495 |     d->Q(3) = r3;
>>          |     ~~~~~~~~^~~~
>> ../target/i386/ops_sse.h:2494:13: error: ‘r2’ may be used
>> uninitialized in this function [-Werror=maybe-uninitialized]
>>     2494 |     d->Q(2) = r2;
>>          |     ~~~~~~~~^~~~
>> ../target/i386/ops_sse.h:2493:13: error: ‘r1’ may be used
>> uninitialized in this function [-Werror=maybe-uninitialized]
>>     2493 |     d->Q(1) = r1;
>>          |     ~~~~~~~~^~~~
>> ../target/i386/ops_sse.h:2492:13: error: ‘r0’ may be used
>> uninitialized in this function [-Werror=maybe-uninitialized]
>>     2492 |     d->Q(0) = r0;
>>          |     ~~~~~~~~^~~~
>>
>> Signed-off-by: Eric Auger <eric.auger@redhat.com>
>> Suggested-by: Stefan Weil <sw@weilnetz.de>
>> Fixes: 790684776861 ("target/i386: reimplement 0x0f 0x3a, add AVX")
>> Message-Id: <20221221163652.1239362-1-eric.auger@redhat.com>
>> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> 
> you pulled v1 but there were additional comments afterwards and last
> iteration was:
> https://lore.kernel.org/all/20221222140158.1260748-1-eric.auger@redhat.com/

Ok, since I have to respin I will replace.  Thanks!

Paolo



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

* Re: [PULL 08/29] gitlab: remove redundant setting of PKG_CONFIG_PATH
  2023-01-10 16:40   ` Daniel P. Berrangé
@ 2023-01-11  9:20     ` Paolo Bonzini
  2023-01-11 10:18       ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 37+ messages in thread
From: Paolo Bonzini @ 2023-01-11  9:20 UTC (permalink / raw)
  To: Daniel P. Berrangé; +Cc: qemu-devel, Stefan Hajnoczi

On 1/10/23 17:40, Daniel P. Berrangé wrote:
>> Signed-off-by: Daniel P. Berrang??<berrange@redhat.com>
>
> This has mangled my name - think your client sending mail
> needs to specify utf8 charset in the mail headers perhaps ?

I have a "Content-type: text/plain" header added from the mimecast 
issues of last year, and git has started putting it *after* its own 
Content-type header with utf-8 charset instead of before.  I'll just 
remove the additional header.

Paolo



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

* Re: [PULL 06/29] target/i386: Remove compilation errors when -Werror=maybe-uninitialized
  2023-01-10 16:02 ` [PULL 06/29] target/i386: Remove compilation errors when -Werror=maybe-uninitialized Paolo Bonzini
  2023-01-10 17:19   ` Eric Auger
@ 2023-01-11 10:03   ` Philippe Mathieu-Daudé
  1 sibling, 0 replies; 37+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-01-11 10:03 UTC (permalink / raw)
  To: Paolo Bonzini, qemu-devel; +Cc: Eric Auger, Stefan Weil

On 10/1/23 17:02, Paolo Bonzini wrote:
> From: Eric Auger <eric.auger@redhat.com>
> 
> To avoid compilation errors when -Werror=maybe-uninitialized is used,
> replace 'case 3' by 'default'.
> 
> Otherwise we get:
> 
> ../target/i386/ops_sse.h: In function ‘helper_vpermdq_ymm’:
> ../target/i386/ops_sse.h:2495:13: error: ‘r3’ may be used

Thanksfully these odd chars                ^^^^^^^^ ...

> Signed-off-by: Eric Auger <eric.auger@redhat.com>
> Suggested-by: Stefan Weil <sw@weilnetz.de>
> Fixes: 790684776861 ("target/i386: reimplement 0x0f 0x3a, add AVX")
> Message-Id: <20221221163652.1239362-1-eric.auger@redhat.com>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>   target/i386/ops_sse.h | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)

... aren't included in your staged commits in
https://gitlab.com/bonzini/qemu.git tags/for-upstream:

commit c0a6665c3c4d63b113ab31c624c53d4a32de2926
Author: Eric Auger <eric.auger@redhat.com>
Date:   Thu Dec 22 15:01:58 2022 +0100

     ../target/i386/ops_sse.h: In function ‘helper_vpermdq_ymm’:
     ../target/i386/ops_sse.h:2495:13: error: ‘r3’ may be used
     uninitialized in this function [-Werror=maybe-uninitialized]
          2495 |     d->Q(3) = r3;
               |     ~~~~~~~~^~~~

So not a blocker.

Maybe a git-send-email issue?


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

* Re: [PULL 08/29] gitlab: remove redundant setting of PKG_CONFIG_PATH
  2023-01-11  9:20     ` Paolo Bonzini
@ 2023-01-11 10:18       ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 37+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-01-11 10:18 UTC (permalink / raw)
  To: Paolo Bonzini, Daniel P. Berrangé; +Cc: qemu-devel, Stefan Hajnoczi

On 11/1/23 10:20, Paolo Bonzini wrote:
> On 1/10/23 17:40, Daniel P. Berrangé wrote:
>>> Signed-off-by: Daniel P. Berrang??<berrange@redhat.com>
>>
>> This has mangled my name - think your client sending mail
>> needs to specify utf8 charset in the mail headers perhaps ?
> 
> I have a "Content-type: text/plain" header added from the mimecast 
> issues of last year, and git has started putting it *after* its own 
> Content-type header with utf-8 charset instead of before.  I'll just 
> remove the additional header.

Ah, now I see this post. So that confirms the commits are correct
in your staged branch, and it is just a git-send-email issue.



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

end of thread, other threads:[~2023-01-11 10:18 UTC | newest]

Thread overview: 37+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-10 16:02 [PULL 00/29] Misc patches for 2023-01-10 Paolo Bonzini
2023-01-10 16:02 ` [PULL 01/29] configure: fix GLIB_VERSION for cross-compilation Paolo Bonzini
2023-01-10 16:02 ` [PULL 02/29] i386: Emit correct error code for 64-bit IDT entry Paolo Bonzini
2023-01-10 16:02 ` [PULL 03/29] accel: introduce accelerator blocker API Paolo Bonzini
2023-01-10 16:02 ` [PULL 04/29] KVM: keep track of running ioctls Paolo Bonzini
2023-01-10 16:02 ` [PULL 05/29] kvm: Atomic memslot updates Paolo Bonzini
2023-01-10 16:02 ` [PULL 06/29] target/i386: Remove compilation errors when -Werror=maybe-uninitialized Paolo Bonzini
2023-01-10 17:19   ` Eric Auger
2023-01-11  9:18     ` Paolo Bonzini
2023-01-11 10:03   ` Philippe Mathieu-Daudé
2023-01-10 16:02 ` [PULL 07/29] chardev: clean up chardev-parallel.c Paolo Bonzini
2023-01-10 16:02 ` [PULL 08/29] gitlab: remove redundant setting of PKG_CONFIG_PATH Paolo Bonzini
2023-01-10 16:40   ` Daniel P. Berrangé
2023-01-11  9:20     ` Paolo Bonzini
2023-01-11 10:18       ` Philippe Mathieu-Daudé
2023-01-10 16:02 ` [PULL 09/29] disas: add G_GNUC_PRINTF to gstring_printf Paolo Bonzini
2023-01-10 16:02 ` [PULL 10/29] hw/xen: use G_GNUC_PRINTF/SCANF for various functions Paolo Bonzini
2023-01-10 16:02 ` [PULL 11/29] tools/virtiofsd: add G_GNUC_PRINTF for logging functions Paolo Bonzini
2023-01-10 16:02 ` [PULL 12/29] util/error: add G_GNUC_PRINTF for various functions Paolo Bonzini
2023-01-10 16:02 ` [PULL 13/29] tests: " Paolo Bonzini
2023-01-10 16:02 ` [PULL 14/29] enforce use of G_GNUC_PRINTF attributes Paolo Bonzini
2023-01-10 16:02 ` [PULL 15/29] hw/display: avoid creating empty loadable modules Paolo Bonzini
2023-01-10 16:02 ` [PULL 16/29] libvhost-user: Provide _GNU_SOURCE when compiling outside of QEMU Paolo Bonzini
2023-01-10 16:02 ` [PULL 17/29] libvhost-user: Replace typeof with __typeof__ Paolo Bonzini
2023-01-10 16:02 ` [PULL 18/29] libvhost-user: Cast rc variable to avoid compiler warning Paolo Bonzini
2023-01-10 16:02 ` [PULL 19/29] libvhost-user: Use unsigned int i for some for-loop iterations Paolo Bonzini
2023-01-10 16:02 ` [PULL 20/29] libvhost-user: Declare uffdio_register early to make it C90 compliant Paolo Bonzini
2023-01-10 16:02 ` [PULL 21/29] libvhost-user: Change dev->postcopy_ufd assignment " Paolo Bonzini
2023-01-10 16:02 ` [PULL 22/29] libvduse: Provide _GNU_SOURCE when compiling outside of QEMU Paolo Bonzini
2023-01-10 16:02 ` [PULL 23/29] libvduse: Switch to unsigned int for inuse field in struct VduseVirtq Paolo Bonzini
2023-01-10 16:02 ` [PULL 24/29] libvduse: Fix assignment in vring_set_avail_event Paolo Bonzini
2023-01-10 16:02 ` [PULL 25/29] libvhost-user: " Paolo Bonzini
2023-01-10 16:02 ` [PULL 26/29] libvhost-user: Add extra compiler warnings Paolo Bonzini
2023-01-10 16:02 ` [PULL 27/29] libvduse: " Paolo Bonzini
2023-01-10 16:02 ` [PULL 28/29] target/i386: fix operand size of unary SSE operations Paolo Bonzini
2023-01-10 16:02 ` [PULL 29/29] configure: remove backwards-compatibility code Paolo Bonzini
2023-01-10 22:07 ` [PULL 00/29] Misc patches for 2023-01-10 Peter Maydell

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.