qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Stable-7.2.10 v0 00/33] Patch Round-up for stable 7.2.10, freeze on 2024-03-02
@ 2024-02-21 21:46 Michael Tokarev
  2024-02-21 21:46 ` [Stable-7.2.10 01/33] migration: Fix use-after-free of migration state object Michael Tokarev
                   ` (32 more replies)
  0 siblings, 33 replies; 34+ messages in thread
From: Michael Tokarev @ 2024-02-21 21:46 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-stable, Michael Tokarev

The following patches are queued for QEMU stable v7.2.10:

  https://gitlab.com/qemu-project/qemu/-/commits/staging-7.2

Patch freeze is 2024-03-02, and the release is planned for 2024-03-04:

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

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

The changes which are staging for inclusion, with the original commit hash
from master branch, are given below the bottom line.

Thanks!

/mjt

--------------------------------------
01 27eb8499edb2 Fabiano Rosas:
   migration: Fix use-after-free of migration state object
02 db101376af52 Yihuan Pan:
   qemu-docs: Update options for graphical frontends
03 615eaeab3d31 Richard W.M. Jones:
   block/blkio: Make s->mem_region_alignment be 64 bits
04 f670be1aad33 Jan Klötzke:
   target/arm: fix exception syndrome for AArch32 bkpt insn
05 d2019a9d0c34 Peter Maydell:
   system/vl.c: Fix handling of '-serial none -serial something'
06 747bfaf3a9d2 Peter Maydell:
   qemu-options.hx: Improve -serial option documentation
07 8a7315202033 Guenter Roeck:
   pci-host: designware: Limit value range of iATU viewport register
08 cd8a35b913c2 Akihiko Odaki:
   hw/smbios: Fix OEM strings table option validation
09 196578c9d051 Akihiko Odaki:
   hw/smbios: Fix port connector option validation
10 aa05bd9ef407 Andrey Ignatov:
   vhost-user.rst: Fix vring address description
11 c62926f730d0 Ira Weiny:
   cxl/cdat: Handle cdat table build errors
12 64fdad5e6758 Ira Weiny:
   cxl/cdat: Fix header sum value in CDAT checksum
13 729d45a6af06 Li Zhijian:
   hw/cxl: Pass CXLComponentState to cache_mem_ops
14 9a457383ce9d Zhenzhong Duan:
   virtio_iommu: Clear IOMMUPciBus pointer cache when system reset
15 8a6b3f4dc95a Zhenzhong Duan:
   smmu: Clear SMMUPciBus pointer cache when system reset
16 14ec4ff3e429 Jonathan Cameron:
   tests/acpi: Allow update of DSDT.cxl
17 d9ae5802f656 Jonathan Cameron:
   hw/i386: Fix _STA return value for ACPI0017
18 b24a981b9f1c Jonathan Cameron:
   tests/acpi: Update DSDT.cxl to reflect change _STA return value.
19 681dfc0d5529 Richard Henderson:
   linux-user/aarch64: Choose SYNC as the preferred MTE mode
20 64c6e7444dff Richard Henderson:
   target/arm: Fix nregs computation in do_{ld,st}_zpa
21 855f94eca80c Richard Henderson:
   target/arm: Fix SVE/SME gross MTE suppression checks
22 ac1d88e9e7ca Peter Maydell:
   target/arm: Don't get MDCR_EL2 in pmu_counter_enabled() before checking 
   ARM_FEATURE_PMU
23 cc29c12ec629 Kevin Wolf:
   iotests: Make 144 deterministic again
24 81f5cad3858f Xiaoyao Li:
   i386/cpu: Clear FEAT_XSAVE_XSS_LO/HI leafs when CPUID_EXT_XSAVE is not 
   available
25 a11a365159b9 Xiaoyao Li:
   i386/cpu: Mask with XCR0/XSS mask for FEAT_XSAVE_XCR0_HI and 
   FEAT_XSAVE_XSS_HI leafs
26 10f92799af8b Xiaoyao Li:
   i386/cpuid: Decrease cpuid_i when skipping CPUID leaf 1F
27 0729857c7075 Xiaoyao Li:
   i386/cpuid: Move leaf 7 to correct group
28 99d0dcd7f102 Ziqiao Kong:
   target/i386: Generate an illegal opcode exception on cmp instructions 
   with lock prefix
29 4cba8388968b Daniel P. Berrangé:
   ui: reject extended clipboard message if not activated
30 405484b29f65 Fiona Ebner:
   ui/clipboard: mark type as not available when there is no data
31 9c416582611b Fiona Ebner:
   ui/clipboard: add asserts for update and request
32 95b08fee8f68 Tianlan Zhou:
   ui/console: Fix console resize with placeholder surface
33 d67611907590 Akihiko Odaki:
   audio: Depend on dbus_display1_dep


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

* [Stable-7.2.10 01/33] migration: Fix use-after-free of migration state object
  2024-02-21 21:46 [Stable-7.2.10 v0 00/33] Patch Round-up for stable 7.2.10, freeze on 2024-03-02 Michael Tokarev
@ 2024-02-21 21:46 ` Michael Tokarev
  2024-02-21 21:46 ` [Stable-7.2.10 02/33] qemu-docs: Update options for graphical frontends Michael Tokarev
                   ` (31 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: Michael Tokarev @ 2024-02-21 21:46 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-stable, Fabiano Rosas, Peter Xu, Michael Tokarev

From: Fabiano Rosas <farosas@suse.de>

We're currently allowing the process_incoming_migration_bh bottom-half
to run without holding a reference to the 'current_migration' object,
which leads to a segmentation fault if the BH is still live after
migration_shutdown() has dropped the last reference to
current_migration.

In my system the bug manifests as migrate_multifd() returning true
when it shouldn't and multifd_load_shutdown() calling
multifd_recv_terminate_threads() which crashes due to an uninitialized
multifd_recv_state.

Fix the issue by holding a reference to the object when scheduling the
BH and dropping it before returning from the BH. The same is already
done for the cleanup_bh at migrate_fd_cleanup_schedule().

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1969
Signed-off-by: Fabiano Rosas <farosas@suse.de>
Link: https://lore.kernel.org/r/20240119233922.32588-2-farosas@suse.de
Signed-off-by: Peter Xu <peterx@redhat.com>
(cherry picked from commit 27eb8499edb2bc952c29ddae0bdac9fc959bf7b1)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>

diff --git a/migration/migration.c b/migration/migration.c
index c8ca7927b4..9b496cce1d 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -572,6 +572,7 @@ static void process_incoming_migration_bh(void *opaque)
                       MIGRATION_STATUS_COMPLETED);
     qemu_bh_delete(mis->bh);
     migration_incoming_state_destroy();
+    object_unref(OBJECT(migrate_get_current()));
 }
 
 static void coroutine_fn
@@ -638,6 +639,7 @@ process_incoming_migration_co(void *opaque)
         goto fail;
     }
     mis->bh = qemu_bh_new(process_incoming_migration_bh, mis);
+    object_ref(OBJECT(migrate_get_current()));
     qemu_bh_schedule(mis->bh);
     mis->migration_incoming_co = NULL;
     return;
-- 
2.39.2



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

* [Stable-7.2.10 02/33] qemu-docs: Update options for graphical frontends
  2024-02-21 21:46 [Stable-7.2.10 v0 00/33] Patch Round-up for stable 7.2.10, freeze on 2024-03-02 Michael Tokarev
  2024-02-21 21:46 ` [Stable-7.2.10 01/33] migration: Fix use-after-free of migration state object Michael Tokarev
@ 2024-02-21 21:46 ` Michael Tokarev
  2024-02-21 21:46 ` [Stable-7.2.10 03/33] block/blkio: Make s->mem_region_alignment be 64 bits Michael Tokarev
                   ` (30 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: Michael Tokarev @ 2024-02-21 21:46 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-stable, Yihuan Pan, Michael Tokarev

From: Yihuan Pan <xun794@gmail.com>

The command line options `-ctrl-grab` and `-alt-grab` have been removed
in QEMU 7.1. Instead, use the `-display sdl,grab-mod=<modifiers>` option
to specify the grab modifiers.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2103
Signed-off-by: Yihuan Pan <xun794@gmail.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
(cherry picked from commit db101376af52e81f740a27f5fa38260ad171323c)

diff --git a/docs/system/keys.rst.inc b/docs/system/keys.rst.inc
index bd9b8e5f6f..2e2c97aa23 100644
--- a/docs/system/keys.rst.inc
+++ b/docs/system/keys.rst.inc
@@ -1,8 +1,9 @@
-During the graphical emulation, you can use special key combinations to
-change modes. The default key mappings are shown below, but if you use
-``-alt-grab`` then the modifier is Ctrl-Alt-Shift (instead of Ctrl-Alt)
-and if you use ``-ctrl-grab`` then the modifier is the right Ctrl key
-(instead of Ctrl-Alt):
+During the graphical emulation, you can use special key combinations from
+the following table to change modes. By default the modifier is Ctrl-Alt
+(used in the table below) which can be changed with ``-display`` suboption
+``mod=`` where appropriate. For example, ``-display sdl,
+grab-mod=lshift-lctrl-lalt`` changes the modifier key to Ctrl-Alt-Shift,
+while ``-display sdl,grab-mod=rctrl`` changes it to the right Ctrl key.
 
 Ctrl-Alt-f
    Toggle full screen
-- 
2.39.2



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

* [Stable-7.2.10 03/33] block/blkio: Make s->mem_region_alignment be 64 bits
  2024-02-21 21:46 [Stable-7.2.10 v0 00/33] Patch Round-up for stable 7.2.10, freeze on 2024-03-02 Michael Tokarev
  2024-02-21 21:46 ` [Stable-7.2.10 01/33] migration: Fix use-after-free of migration state object Michael Tokarev
  2024-02-21 21:46 ` [Stable-7.2.10 02/33] qemu-docs: Update options for graphical frontends Michael Tokarev
@ 2024-02-21 21:46 ` Michael Tokarev
  2024-02-21 21:46 ` [Stable-7.2.10 04/33] target/arm: fix exception syndrome for AArch32 bkpt insn Michael Tokarev
                   ` (29 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: Michael Tokarev @ 2024-02-21 21:46 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-stable, Richard W.M. Jones, Stefan Hajnoczi, Michael Tokarev

From: "Richard W.M. Jones" <rjones@redhat.com>

With GCC 14 the code failed to compile on i686 (and was wrong for any
version of GCC):

../block/blkio.c: In function ‘blkio_file_open’:
../block/blkio.c:857:28: error: passing argument 3 of ‘blkio_get_uint64’ from incompatible pointer type [-Wincompatible-pointer-types]
  857 |                            &s->mem_region_alignment);
      |                            ^~~~~~~~~~~~~~~~~~~~~~~~
      |                            |
      |                            size_t * {aka unsigned int *}
In file included from ../block/blkio.c:12:
/usr/include/blkio.h:49:67: note: expected ‘uint64_t *’ {aka ‘long long unsigned int *’} but argument is of type ‘size_t *’ {aka ‘unsigned int *’}
   49 | int blkio_get_uint64(struct blkio *b, const char *name, uint64_t *value);
      |                                                         ~~~~~~~~~~^~~~~

Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
Message-id: 20240130122006.2977938-1-rjones@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
(cherry picked from commit 615eaeab3d318ba239d54141a4251746782f65c1)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>

diff --git a/block/blkio.c b/block/blkio.c
index 5eae3adfaf..cb66160268 100644
--- a/block/blkio.c
+++ b/block/blkio.c
@@ -74,7 +74,7 @@ typedef struct {
     CoQueue bounce_available;
 
     /* The value of the "mem-region-alignment" property */
-    size_t mem_region_alignment;
+    uint64_t mem_region_alignment;
 
     /* Can we skip adding/deleting blkio_mem_regions? */
     bool needs_mem_regions;
-- 
2.39.2



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

* [Stable-7.2.10 04/33] target/arm: fix exception syndrome for AArch32 bkpt insn
  2024-02-21 21:46 [Stable-7.2.10 v0 00/33] Patch Round-up for stable 7.2.10, freeze on 2024-03-02 Michael Tokarev
                   ` (2 preceding siblings ...)
  2024-02-21 21:46 ` [Stable-7.2.10 03/33] block/blkio: Make s->mem_region_alignment be 64 bits Michael Tokarev
@ 2024-02-21 21:46 ` Michael Tokarev
  2024-02-21 21:46 ` [Stable-7.2.10 05/33] system/vl.c: Fix handling of '-serial none -serial something' Michael Tokarev
                   ` (28 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: Michael Tokarev @ 2024-02-21 21:46 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-stable, Jan Klötzke, Richard Henderson, Peter Maydell,
	Michael Tokarev

From: Jan Klötzke <jan.kloetzke@kernkonzept.com>

Debug exceptions that target AArch32 Hyp mode are reported differently
than on AAarch64. Internally, Qemu uses the AArch64 syndromes. Therefore
such exceptions need to be either converted to a prefetch abort
(breakpoints, vector catch) or a data abort (watchpoints).

Cc: qemu-stable@nongnu.org
Signed-off-by: Jan Klötzke <jan.kloetzke@kernkonzept.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20240127202758.3326381-1-jan.kloetzke@kernkonzept.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
(cherry picked from commit f670be1aad33e801779af580398895b9455747ee)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>

diff --git a/target/arm/helper.c b/target/arm/helper.c
index 02cfeece45..343acfab3a 100644
--- a/target/arm/helper.c
+++ b/target/arm/helper.c
@@ -9836,6 +9836,24 @@ static void arm_cpu_do_interrupt_aarch32(CPUState *cs)
     }
 
     if (env->exception.target_el == 2) {
+        /* Debug exceptions are reported differently on AArch32 */
+        switch (syn_get_ec(env->exception.syndrome)) {
+        case EC_BREAKPOINT:
+        case EC_BREAKPOINT_SAME_EL:
+        case EC_AA32_BKPT:
+        case EC_VECTORCATCH:
+            env->exception.syndrome = syn_insn_abort(arm_current_el(env) == 2,
+                                                     0, 0, 0x22);
+            break;
+        case EC_WATCHPOINT:
+            env->exception.syndrome = syn_set_ec(env->exception.syndrome,
+                                                 EC_DATAABORT);
+            break;
+        case EC_WATCHPOINT_SAME_EL:
+            env->exception.syndrome = syn_set_ec(env->exception.syndrome,
+                                                 EC_DATAABORT_SAME_EL);
+            break;
+        }
         arm_cpu_do_interrupt_aarch32_hyp(cs);
         return;
     }
diff --git a/target/arm/syndrome.h b/target/arm/syndrome.h
index 15334a3d15..75a3327a30 100644
--- a/target/arm/syndrome.h
+++ b/target/arm/syndrome.h
@@ -25,6 +25,8 @@
 #ifndef TARGET_ARM_SYNDROME_H
 #define TARGET_ARM_SYNDROME_H
 
+#include "qemu/bitops.h"
+
 /* Valid Syndrome Register EC field values */
 enum arm_exception_class {
     EC_UNCATEGORIZED          = 0x00,
@@ -76,6 +78,7 @@ typedef enum {
     SME_ET_InactiveZA,
 } SMEExceptionType;
 
+#define ARM_EL_EC_LENGTH 6
 #define ARM_EL_EC_SHIFT 26
 #define ARM_EL_IL_SHIFT 25
 #define ARM_EL_ISV_SHIFT 24
@@ -87,6 +90,11 @@ static inline uint32_t syn_get_ec(uint32_t syn)
     return syn >> ARM_EL_EC_SHIFT;
 }
 
+static inline uint32_t syn_set_ec(uint32_t syn, uint32_t ec)
+{
+    return deposit32(syn, ARM_EL_EC_SHIFT, ARM_EL_EC_LENGTH, ec);
+}
+
 /*
  * Utility functions for constructing various kinds of syndrome value.
  * Note that in general we follow the AArch64 syndrome values; in a
-- 
2.39.2



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

* [Stable-7.2.10 05/33] system/vl.c: Fix handling of '-serial none -serial something'
  2024-02-21 21:46 [Stable-7.2.10 v0 00/33] Patch Round-up for stable 7.2.10, freeze on 2024-03-02 Michael Tokarev
                   ` (3 preceding siblings ...)
  2024-02-21 21:46 ` [Stable-7.2.10 04/33] target/arm: fix exception syndrome for AArch32 bkpt insn Michael Tokarev
@ 2024-02-21 21:46 ` Michael Tokarev
  2024-02-21 21:46 ` [Stable-7.2.10 06/33] qemu-options.hx: Improve -serial option documentation Michael Tokarev
                   ` (27 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: Michael Tokarev @ 2024-02-21 21:46 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-stable, Peter Maydell, Bohdan Kostiv,
	Daniel P . Berrangé, Richard Henderson, Michael Tokarev

From: Peter Maydell <peter.maydell@linaro.org>

Currently if the user passes multiple -serial options on the command
line, we mostly treat those as applying to the different serial
devices in order, so that for example
 -serial stdio -serial file:filename
will connect the first serial port to stdio and the second to the
named file.

The exception to this is the '-serial none' serial device type.  This
means "don't allocate this serial device", but a bug means that
following -serial options are not correctly handled, so that
 -serial none -serial stdio
has the unexpected effect that stdio is connected to the first serial
port, not the second.

This is a very long-standing bug that dates back at least as far as
commit 998bbd74b9d81 from 2009.

Make the 'none' serial type move forward in the indexing of serial
devices like all the other serial types, so that any subsequent
-serial options are correctly handled.

Note that if your commandline mistakenly had a '-serial none' that
was being overridden by a following '-serial something' option, you
should delete the unnecessary '-serial none'.  This will give you the
same behaviour as before, on QEMU versions both with and without this
bug fix.

Cc: qemu-stable@nongnu.org
Reported-by: Bohdan Kostiv <bohdan.kostiv@tii.ae>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20240122163607.459769-2-peter.maydell@linaro.org
Fixes: 998bbd74b9d81 ("default devices: core code & serial lines")
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
(cherry picked from commit d2019a9d0c34a4fdcb5b5df550d73040dc0637d9)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>

diff --git a/softmmu/vl.c b/softmmu/vl.c
index ce88869618..ab4394c53d 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -1363,18 +1363,22 @@ static void qemu_create_default_devices(void)
 static int serial_parse(const char *devname)
 {
     int index = num_serial_hds;
-    char label[32];
 
-    if (strcmp(devname, "none") == 0)
-        return 0;
-    snprintf(label, sizeof(label), "serial%d", index);
     serial_hds = g_renew(Chardev *, serial_hds, index + 1);
 
-    serial_hds[index] = qemu_chr_new_mux_mon(label, devname, NULL);
-    if (!serial_hds[index]) {
-        error_report("could not connect serial device"
-                     " to character backend '%s'", devname);
-        return -1;
+    if (strcmp(devname, "none") == 0) {
+        /* Don't allocate a serial device for this index */
+        serial_hds[index] = NULL;
+    } else {
+        char label[32];
+        snprintf(label, sizeof(label), "serial%d", index);
+
+        serial_hds[index] = qemu_chr_new_mux_mon(label, devname, NULL);
+        if (!serial_hds[index]) {
+            error_report("could not connect serial device"
+                         " to character backend '%s'", devname);
+            return -1;
+        }
     }
     num_serial_hds++;
     return 0;
-- 
2.39.2



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

* [Stable-7.2.10 06/33] qemu-options.hx: Improve -serial option documentation
  2024-02-21 21:46 [Stable-7.2.10 v0 00/33] Patch Round-up for stable 7.2.10, freeze on 2024-03-02 Michael Tokarev
                   ` (4 preceding siblings ...)
  2024-02-21 21:46 ` [Stable-7.2.10 05/33] system/vl.c: Fix handling of '-serial none -serial something' Michael Tokarev
@ 2024-02-21 21:46 ` Michael Tokarev
  2024-02-21 21:46 ` [Stable-7.2.10 07/33] pci-host: designware: Limit value range of iATU viewport register Michael Tokarev
                   ` (26 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: Michael Tokarev @ 2024-02-21 21:46 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-stable, Peter Maydell, Daniel P . Berrangé,
	Philippe Mathieu-Daudé, Michael Tokarev

From: Peter Maydell <peter.maydell@linaro.org>

The -serial option documentation is a bit brief about '-serial none'
and '-serial null'. In particular it's not very clear about the
difference between them, and it doesn't mention that it's up to
the machine model whether '-serial none' means "don't create the
serial port" or "don't wire the serial port up to anything".

Expand on these points.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-id: 20240122163607.459769-3-peter.maydell@linaro.org
(cherry picked from commit 747bfaf3a9d2f3cd51674763dc1f7575100cd200)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>

diff --git a/qemu-options.hx b/qemu-options.hx
index 379692da86..7f798ce47e 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -3968,7 +3968,8 @@ SRST
     This option can be used several times to simulate up to 4 serial
     ports.
 
-    Use ``-serial none`` to disable all serial ports.
+    You can use ``-serial none`` to suppress the creation of default
+    serial devices.
 
     Available character devices are:
 
@@ -3990,10 +3991,17 @@ SRST
         [Linux only] Pseudo TTY (a new PTY is automatically allocated)
 
     ``none``
-        No device is allocated.
+        No device is allocated. Note that for machine types which
+        emulate systems where a serial device is always present in
+        real hardware, this may be equivalent to the ``null`` option,
+        in that the serial device is still present but all output
+        is discarded. For boards where the number of serial ports is
+        truly variable, this suppresses the creation of the device.
 
     ``null``
-        void device
+        A guest will see the UART or serial device as present in the
+        machine, but all output is discarded, and there is no input.
+        Conceptually equivalent to redirecting the output to ``/dev/null``.
 
     ``chardev:id``
         Use a named character device defined with the ``-chardev``
-- 
2.39.2



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

* [Stable-7.2.10 07/33] pci-host: designware: Limit value range of iATU viewport register
  2024-02-21 21:46 [Stable-7.2.10 v0 00/33] Patch Round-up for stable 7.2.10, freeze on 2024-03-02 Michael Tokarev
                   ` (5 preceding siblings ...)
  2024-02-21 21:46 ` [Stable-7.2.10 06/33] qemu-options.hx: Improve -serial option documentation Michael Tokarev
@ 2024-02-21 21:46 ` Michael Tokarev
  2024-02-21 21:46 ` [Stable-7.2.10 08/33] hw/smbios: Fix OEM strings table option validation Michael Tokarev
                   ` (25 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: Michael Tokarev @ 2024-02-21 21:46 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-stable, Guenter Roeck, Andrey Smirnov, Nikita Ostrenkov,
	Peter Maydell, Michael Tokarev

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

The latest version of qemu (v8.2.0-869-g7a1dc45af5) crashes when booting
the mcimx7d-sabre emulation with Linux v5.11 and later.

qemu-system-arm: ../system/memory.c:2750: memory_region_set_alias_offset: Assertion `mr->alias' failed.

Problem is that the Designware PCIe emulation accepts the full value range
for the iATU Viewport Register. However, both hardware and emulation only
support four inbound and four outbound viewports.

The Linux kernel determines the number of supported viewports by writing
0xff into the viewport register and reading the value back. The expected
value when reading the register is the highest supported viewport index.
Match that code by masking the supported viewport value range when the
register is written. With this change, the Linux kernel reports

imx6q-pcie 33800000.pcie: iATU: unroll F, 4 ob, 4 ib, align 0K, limit 4G

as expected and supported.

Fixes: d64e5eabc4c7 ("pci: Add support for Designware IP block")
Cc: Andrey Smirnov <andrew.smirnov@gmail.com>
Cc: Nikita Ostrenkov <n.ostrenkov@gmail.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Message-id: 20240129060055.2616989-1-linux@roeck-us.net
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
(cherry picked from commit 8a73152020337a7fbf34daf0a006d4d89ec1494e)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>

diff --git a/hw/pci-host/designware.c b/hw/pci-host/designware.c
index bde3a343a2..c235b9daa3 100644
--- a/hw/pci-host/designware.c
+++ b/hw/pci-host/designware.c
@@ -340,6 +340,8 @@ static void designware_pcie_root_config_write(PCIDevice *d, uint32_t address,
         break;
 
     case DESIGNWARE_PCIE_ATU_VIEWPORT:
+        val &= DESIGNWARE_PCIE_ATU_REGION_INBOUND |
+                (DESIGNWARE_PCIE_NUM_VIEWPORTS - 1);
         root->atu_viewport = val;
         break;
 
-- 
2.39.2



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

* [Stable-7.2.10 08/33] hw/smbios: Fix OEM strings table option validation
  2024-02-21 21:46 [Stable-7.2.10 v0 00/33] Patch Round-up for stable 7.2.10, freeze on 2024-03-02 Michael Tokarev
                   ` (6 preceding siblings ...)
  2024-02-21 21:46 ` [Stable-7.2.10 07/33] pci-host: designware: Limit value range of iATU viewport register Michael Tokarev
@ 2024-02-21 21:46 ` Michael Tokarev
  2024-02-21 21:46 ` [Stable-7.2.10 09/33] hw/smbios: Fix port connector " Michael Tokarev
                   ` (24 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: Michael Tokarev @ 2024-02-21 21:46 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-stable, Akihiko Odaki, Michael Tokarev, Ani Sinha,
	Michael S . Tsirkin

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

qemu_smbios_type11_opts did not have the list terminator and that
resulted in out-of-bound memory access. It also needs to have an element
for the type option.

Cc: qemu-stable@nongnu.org
Fixes: 2d6dcbf93fb0 ("smbios: support setting OEM strings table")
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
Reviewed-by: Michael Tokarev <mjt@tls.msk.ru>
Reviewed-by: Ani Sinha <anisinha@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
(cherry picked from commit cd8a35b913c24248267c682cb9a348461c106139)

diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c
index cd43185417..7a58d50d80 100644
--- a/hw/smbios/smbios.c
+++ b/hw/smbios/smbios.c
@@ -368,6 +368,11 @@ static const QemuOptDesc qemu_smbios_type8_opts[] = {
 };
 
 static const QemuOptDesc qemu_smbios_type11_opts[] = {
+    {
+        .name = "type",
+        .type = QEMU_OPT_NUMBER,
+        .help = "SMBIOS element type",
+    },
     {
         .name = "value",
         .type = QEMU_OPT_STRING,
@@ -378,6 +383,7 @@ static const QemuOptDesc qemu_smbios_type11_opts[] = {
         .type = QEMU_OPT_STRING,
         .help = "OEM string data from file",
     },
+    { /* end of list */ }
 };
 
 static const QemuOptDesc qemu_smbios_type17_opts[] = {
-- 
2.39.2



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

* [Stable-7.2.10 09/33] hw/smbios: Fix port connector option validation
  2024-02-21 21:46 [Stable-7.2.10 v0 00/33] Patch Round-up for stable 7.2.10, freeze on 2024-03-02 Michael Tokarev
                   ` (7 preceding siblings ...)
  2024-02-21 21:46 ` [Stable-7.2.10 08/33] hw/smbios: Fix OEM strings table option validation Michael Tokarev
@ 2024-02-21 21:46 ` Michael Tokarev
  2024-02-21 21:46 ` [Stable-7.2.10 10/33] vhost-user.rst: Fix vring address description Michael Tokarev
                   ` (23 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: Michael Tokarev @ 2024-02-21 21:46 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-stable, Akihiko Odaki, Michael Tokarev, Ani Sinha,
	Michael S . Tsirkin

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

qemu_smbios_type8_opts did not have the list terminator and that
resulted in out-of-bound memory access. It also needs to have an element
for the type option.

Cc: qemu-stable@nongnu.org
Fixes: fd8caa253c56 ("hw/smbios: support for type 8 (port connector)")
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
Reviewed-by: Michael Tokarev <mjt@tls.msk.ru>
Reviewed-by: Ani Sinha <anisinha@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
(cherry picked from commit 196578c9d051d19c23e6c13e97b791a41b318315)

diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c
index 7a58d50d80..9f4d007d96 100644
--- a/hw/smbios/smbios.c
+++ b/hw/smbios/smbios.c
@@ -345,6 +345,11 @@ static const QemuOptDesc qemu_smbios_type4_opts[] = {
 };
 
 static const QemuOptDesc qemu_smbios_type8_opts[] = {
+    {
+        .name = "type",
+        .type = QEMU_OPT_NUMBER,
+        .help = "SMBIOS element type",
+    },
     {
         .name = "internal_reference",
         .type = QEMU_OPT_STRING,
@@ -365,6 +370,7 @@ static const QemuOptDesc qemu_smbios_type8_opts[] = {
         .type = QEMU_OPT_NUMBER,
         .help = "port type",
     },
+    { /* end of list */ }
 };
 
 static const QemuOptDesc qemu_smbios_type11_opts[] = {
-- 
2.39.2



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

* [Stable-7.2.10 10/33] vhost-user.rst: Fix vring address description
  2024-02-21 21:46 [Stable-7.2.10 v0 00/33] Patch Round-up for stable 7.2.10, freeze on 2024-03-02 Michael Tokarev
                   ` (8 preceding siblings ...)
  2024-02-21 21:46 ` [Stable-7.2.10 09/33] hw/smbios: Fix port connector " Michael Tokarev
@ 2024-02-21 21:46 ` Michael Tokarev
  2024-02-21 21:46 ` [Stable-7.2.10 11/33] cxl/cdat: Handle cdat table build errors Michael Tokarev
                   ` (22 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: Michael Tokarev @ 2024-02-21 21:46 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-stable, Andrey Ignatov, Michael S . Tsirkin, Michael Tokarev

From: Andrey Ignatov <rdna@apple.com>

There is no "size" field in vring address structure. Remove it.

Fixes: 5fc0e00291 ("Add vhost-user protocol documentation")
Signed-off-by: Andrey Ignatov <rdna@apple.com>
Message-Id: <20240112004555.64900-1-rdna@apple.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit aa05bd9ef4073ccb72d04ad78de32916af31c7c3)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>

diff --git a/docs/interop/vhost-user.rst b/docs/interop/vhost-user.rst
index 3f18ab424e..936de705e1 100644
--- a/docs/interop/vhost-user.rst
+++ b/docs/interop/vhost-user.rst
@@ -111,9 +111,9 @@ A vring state description
 A vring address description
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
-+-------+-------+------+------------+------+-----------+-----+
-| index | flags | size | descriptor | used | available | log |
-+-------+-------+------+------------+------+-----------+-----+
++-------+-------+------------+------+-----------+-----+
+| index | flags | descriptor | used | available | log |
++-------+-------+------------+------+-----------+-----+
 
 :index: a 32-bit vring index
 
-- 
2.39.2



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

* [Stable-7.2.10 11/33] cxl/cdat: Handle cdat table build errors
  2024-02-21 21:46 [Stable-7.2.10 v0 00/33] Patch Round-up for stable 7.2.10, freeze on 2024-03-02 Michael Tokarev
                   ` (9 preceding siblings ...)
  2024-02-21 21:46 ` [Stable-7.2.10 10/33] vhost-user.rst: Fix vring address description Michael Tokarev
@ 2024-02-21 21:46 ` Michael Tokarev
  2024-02-21 21:46 ` [Stable-7.2.10 12/33] cxl/cdat: Fix header sum value in CDAT checksum Michael Tokarev
                   ` (21 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: Michael Tokarev @ 2024-02-21 21:46 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-stable, Ira Weiny, Huai-Cheng Kuo, Dave Jiang, Fan Ni,
	Jonathan Cameron, Michael S . Tsirkin, Michael Tokarev

From: Ira Weiny <ira.weiny@intel.com>

The callback for building CDAT tables may return negative error codes.
This was previously unhandled and will result in potentially huge
allocations later on in ct3_build_cdat()

Detect the negative error code and defer cdat building.

Fixes: f5ee7413d592 ("hw/mem/cxl-type3: Add CXL CDAT Data Object Exchange")
Cc: Huai-Cheng Kuo <hchkuo@avery-design.com.tw>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Reviewed-by: Fan Ni <fan.ni@samsung.com>
Signed-off-by: Ira Weiny <ira.weiny@intel.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Message-Id: <20240126120132.24248-2-Jonathan.Cameron@huawei.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit c62926f730d08450502d36548e28dd727c998ace)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>

diff --git a/hw/cxl/cxl-cdat.c b/hw/cxl/cxl-cdat.c
index 3653aa56f0..931693f02d 100644
--- a/hw/cxl/cxl-cdat.c
+++ b/hw/cxl/cxl-cdat.c
@@ -62,7 +62,7 @@ static void ct3_build_cdat(CDATObject *cdat, Error **errp)
 
     cdat->built_buf_len = cdat->build_cdat_table(&cdat->built_buf, cdat->private);
 
-    if (!cdat->built_buf_len) {
+    if (cdat->built_buf_len <= 0) {
         /* Build later as not all data available yet */
         cdat->to_update = true;
         return;
-- 
2.39.2



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

* [Stable-7.2.10 12/33] cxl/cdat: Fix header sum value in CDAT checksum
  2024-02-21 21:46 [Stable-7.2.10 v0 00/33] Patch Round-up for stable 7.2.10, freeze on 2024-03-02 Michael Tokarev
                   ` (10 preceding siblings ...)
  2024-02-21 21:46 ` [Stable-7.2.10 11/33] cxl/cdat: Handle cdat table build errors Michael Tokarev
@ 2024-02-21 21:46 ` Michael Tokarev
  2024-02-21 21:46 ` [Stable-7.2.10 13/33] hw/cxl: Pass CXLComponentState to cache_mem_ops Michael Tokarev
                   ` (20 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: Michael Tokarev @ 2024-02-21 21:46 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-stable, Ira Weiny, Huai-Cheng Kuo, Dave Jiang, Fan Ni,
	Jonathan Cameron, Michael S . Tsirkin, Michael Tokarev

From: Ira Weiny <ira.weiny@intel.com>

The addition of the DCD support for CXL type-3 devices extended the CDAT
table large enough that the checksum being returned was incorrect.[1]

This was because the checksum value was using the header length field
rather than each of the 4 bytes of the length field.  This was
previously not seen because the length of the CDAT data was less than
256 thus resulting in an equivalent checksum value.

Properly calculate the checksum for the CDAT header.

[1] https://lore.kernel.org/all/20231116-fix-cdat-devm-free-v1-1-b148b40707d7@intel.com/

Fixes: aba578bdace5 ("hw/cxl/cdat: CXL CDAT Data Object Exchange implementation")
Cc: Huai-Cheng Kuo <hchkuo@avery-design.com.tw>
Signed-off-by: Ira Weiny <ira.weiny@intel.com>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Reviewed-by: Fan Ni <fan.ni@samsung.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

Message-Id: <20240126120132.24248-5-Jonathan.Cameron@huawei.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit 64fdad5e67587e88c2f1d8f294e89403856a4a31)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>

diff --git a/hw/cxl/cxl-cdat.c b/hw/cxl/cxl-cdat.c
index 931693f02d..0cde11854e 100644
--- a/hw/cxl/cxl-cdat.c
+++ b/hw/cxl/cxl-cdat.c
@@ -49,6 +49,7 @@ static void ct3_build_cdat(CDATObject *cdat, Error **errp)
     g_autofree CDATTableHeader *cdat_header = NULL;
     g_autofree CDATEntry *cdat_st = NULL;
     uint8_t sum = 0;
+    uint8_t *hdr_buf;
     int ent, i;
 
     /* Use default table if fopen == NULL */
@@ -94,8 +95,12 @@ static void ct3_build_cdat(CDATObject *cdat, Error **errp)
     /* For now, no runtime updates */
     cdat_header->sequence = 0;
     cdat_header->length += sizeof(CDATTableHeader);
-    sum += cdat_header->revision + cdat_header->sequence +
-        cdat_header->length;
+
+    hdr_buf = (uint8_t *)cdat_header;
+    for (i = 0; i < sizeof(*cdat_header); i++) {
+        sum += hdr_buf[i];
+    }
+
     /* Sum of all bytes including checksum must be 0 */
     cdat_header->checksum = ~sum + 1;
 
-- 
2.39.2



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

* [Stable-7.2.10 13/33] hw/cxl: Pass CXLComponentState to cache_mem_ops
  2024-02-21 21:46 [Stable-7.2.10 v0 00/33] Patch Round-up for stable 7.2.10, freeze on 2024-03-02 Michael Tokarev
                   ` (11 preceding siblings ...)
  2024-02-21 21:46 ` [Stable-7.2.10 12/33] cxl/cdat: Fix header sum value in CDAT checksum Michael Tokarev
@ 2024-02-21 21:46 ` Michael Tokarev
  2024-02-21 21:46 ` [Stable-7.2.10 14/33] virtio_iommu: Clear IOMMUPciBus pointer cache when system reset Michael Tokarev
                   ` (19 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: Michael Tokarev @ 2024-02-21 21:46 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-stable, Li Zhijian, Fan Ni, Jonathan Cameron,
	Michael S . Tsirkin, Michael Tokarev

From: Li Zhijian <lizhijian@fujitsu.com>

cache_mem_ops.{read,write}() interprets opaque as
CXLComponentState(cxl_cstate) instead of ComponentRegisters(cregs).

Fortunately, cregs is the first member of cxl_cstate, so their values are
the same.

Fixes: 9e58f52d3f8 ("hw/cxl/component: Introduce CXL components (8.1.x, 8.2.5)")
Reviewed-by: Fan Ni <fan.ni@samsung.com>
Signed-off-by: Li Zhijian <lizhijian@fujitsu.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Message-Id: <20240126120132.24248-8-Jonathan.Cameron@huawei.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit 729d45a6af06753d3e330f589c248fe9687c5cd5)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>

diff --git a/hw/cxl/cxl-component-utils.c b/hw/cxl/cxl-component-utils.c
index 3edd303a33..5934b95848 100644
--- a/hw/cxl/cxl-component-utils.c
+++ b/hw/cxl/cxl-component-utils.c
@@ -126,7 +126,7 @@ void cxl_component_register_block_init(Object *obj,
     /* io registers controls link which we don't care about in QEMU */
     memory_region_init_io(&cregs->io, obj, NULL, cregs, ".io",
                           CXL2_COMPONENT_IO_REGION_SIZE);
-    memory_region_init_io(&cregs->cache_mem, obj, &cache_mem_ops, cregs,
+    memory_region_init_io(&cregs->cache_mem, obj, &cache_mem_ops, cxl_cstate,
                           ".cache_mem", CXL2_COMPONENT_CM_REGION_SIZE);
 
     memory_region_add_subregion(&cregs->component_registers, 0, &cregs->io);
-- 
2.39.2



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

* [Stable-7.2.10 14/33] virtio_iommu: Clear IOMMUPciBus pointer cache when system reset
  2024-02-21 21:46 [Stable-7.2.10 v0 00/33] Patch Round-up for stable 7.2.10, freeze on 2024-03-02 Michael Tokarev
                   ` (12 preceding siblings ...)
  2024-02-21 21:46 ` [Stable-7.2.10 13/33] hw/cxl: Pass CXLComponentState to cache_mem_ops Michael Tokarev
@ 2024-02-21 21:46 ` Michael Tokarev
  2024-02-21 21:46 ` [Stable-7.2.10 15/33] smmu: Clear SMMUPciBus " Michael Tokarev
                   ` (18 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: Michael Tokarev @ 2024-02-21 21:46 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-stable, Zhenzhong Duan, Eric Auger, Michael S . Tsirkin,
	Michael Tokarev

From: Zhenzhong Duan <zhenzhong.duan@intel.com>

s->iommu_pcibus_by_bus_num is a IOMMUPciBus pointer cache indexed
by bus number, bus number may not always be a fixed value,
i.e., guest reboot to different kernel which set bus number with
different algorithm.

This could lead to endpoint binding to wrong iommu MR in
virtio_iommu_get_endpoint(), then vfio device setup wrong
mapping from other device.

Remove the memset in virtio_iommu_device_realize() to avoid
redundancy with memset in system reset.

Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
Message-Id: <20240125073706.339369-2-zhenzhong.duan@intel.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Tested-by: Eric Auger <eric.auger@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit 9a457383ce9d309d4679b079fafb51f0a2d949aa)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>

diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c
index eb82462c95..95db19f144 100644
--- a/hw/virtio/virtio-iommu.c
+++ b/hw/virtio/virtio-iommu.c
@@ -1140,6 +1140,8 @@ static void virtio_iommu_system_reset(void *opaque)
 
     trace_virtio_iommu_system_reset();
 
+    memset(s->iommu_pcibus_by_bus_num, 0, sizeof(s->iommu_pcibus_by_bus_num));
+
     /*
      * config.bypass is sticky across device reset, but should be restored on
      * system reset
@@ -1156,8 +1158,6 @@ static void virtio_iommu_device_realize(DeviceState *dev, Error **errp)
 
     virtio_init(vdev, VIRTIO_ID_IOMMU, sizeof(struct virtio_iommu_config));
 
-    memset(s->iommu_pcibus_by_bus_num, 0, sizeof(s->iommu_pcibus_by_bus_num));
-
     s->req_vq = virtio_add_queue(vdev, VIOMMU_DEFAULT_QUEUE_SIZE,
                              virtio_iommu_handle_command);
     s->event_vq = virtio_add_queue(vdev, VIOMMU_DEFAULT_QUEUE_SIZE, NULL);
-- 
2.39.2



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

* [Stable-7.2.10 15/33] smmu: Clear SMMUPciBus pointer cache when system reset
  2024-02-21 21:46 [Stable-7.2.10 v0 00/33] Patch Round-up for stable 7.2.10, freeze on 2024-03-02 Michael Tokarev
                   ` (13 preceding siblings ...)
  2024-02-21 21:46 ` [Stable-7.2.10 14/33] virtio_iommu: Clear IOMMUPciBus pointer cache when system reset Michael Tokarev
@ 2024-02-21 21:46 ` Michael Tokarev
  2024-02-21 21:46 ` [Stable-7.2.10 16/33] tests/acpi: Allow update of DSDT.cxl Michael Tokarev
                   ` (17 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: Michael Tokarev @ 2024-02-21 21:46 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-stable, Zhenzhong Duan, Eric Auger, Michael S . Tsirkin,
	Michael Tokarev

From: Zhenzhong Duan <zhenzhong.duan@intel.com>

s->smmu_pcibus_by_bus_num is a SMMUPciBus pointer cache indexed
by bus number, bus number may not always be a fixed value,
i.e., guest reboot to different kernel which set bus number with
different algorithm.

This could lead to smmu_iommu_mr() providing the wrong iommu MR.

Suggested-by: Eric Auger <eric.auger@redhat.com>
Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
Message-Id: <20240125073706.339369-3-zhenzhong.duan@intel.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Tested-by: Eric Auger <eric.auger@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit 8a6b3f4dc95a064e88adaca86374108da0ecb38d)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>

diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c
index bbca3a8db3..7abc166eb3 100644
--- a/hw/arm/smmu-common.c
+++ b/hw/arm/smmu-common.c
@@ -529,6 +529,8 @@ static void smmu_base_reset(DeviceState *dev)
 {
     SMMUState *s = ARM_SMMU(dev);
 
+    memset(s->smmu_pcibus_by_bus_num, 0, sizeof(s->smmu_pcibus_by_bus_num));
+
     g_hash_table_remove_all(s->configs);
     g_hash_table_remove_all(s->iotlb);
 }
-- 
2.39.2



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

* [Stable-7.2.10 16/33] tests/acpi: Allow update of DSDT.cxl
  2024-02-21 21:46 [Stable-7.2.10 v0 00/33] Patch Round-up for stable 7.2.10, freeze on 2024-03-02 Michael Tokarev
                   ` (14 preceding siblings ...)
  2024-02-21 21:46 ` [Stable-7.2.10 15/33] smmu: Clear SMMUPciBus " Michael Tokarev
@ 2024-02-21 21:46 ` Michael Tokarev
  2024-02-21 21:47 ` [Stable-7.2.10 17/33] hw/i386: Fix _STA return value for ACPI0017 Michael Tokarev
                   ` (16 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: Michael Tokarev @ 2024-02-21 21:46 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-stable, Jonathan Cameron, Michael S . Tsirkin,
	Michael Tokarev

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

The _STA value returned currently indicates the ACPI0017 device
is not enabled.  Whilst this isn't a real device, setting _STA
like this may prevent an OS from enumerating it correctly and
hence from parsing the CEDT table.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Message-Id: <20240126120132.24248-11-Jonathan.Cameron@huawei.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit 14ec4ff3e4293635240ba5a7afe7a0f3ba447d31)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>

diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios-tables-test-allowed-diff.h
index dfb8523c8b..9ce0f596cc 100644
--- a/tests/qtest/bios-tables-test-allowed-diff.h
+++ b/tests/qtest/bios-tables-test-allowed-diff.h
@@ -1 +1,2 @@
 /* List of comma-separated changed AML files to ignore */
+"tests/data/acpi/q35/DSDT.cxl",
-- 
2.39.2



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

* [Stable-7.2.10 17/33] hw/i386: Fix _STA return value for ACPI0017
  2024-02-21 21:46 [Stable-7.2.10 v0 00/33] Patch Round-up for stable 7.2.10, freeze on 2024-03-02 Michael Tokarev
                   ` (15 preceding siblings ...)
  2024-02-21 21:46 ` [Stable-7.2.10 16/33] tests/acpi: Allow update of DSDT.cxl Michael Tokarev
@ 2024-02-21 21:47 ` Michael Tokarev
  2024-02-21 21:47 ` [Stable-7.2.10 18/33] tests/acpi: Update DSDT.cxl to reflect change _STA return value Michael Tokarev
                   ` (15 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: Michael Tokarev @ 2024-02-21 21:47 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-stable, Jonathan Cameron, Michael S . Tsirkin,
	Michael Tokarev

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

Found whilst testing a series for the linux kernel that actually
bothers to check if enabled is set. 0xB is the option used
for vast majority of DSDT entries in QEMU.
It is a little odd for a device that doesn't really exist and
is simply a hook to tell the OS there is a CEDT table but 0xB
seems a reasonable choice and avoids need to special case
this device in the OS.

Means:
* Device present.
* Device enabled and decoding it's resources.
* Not shown in UI
* Functioning properly
* No battery (on this device!)

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Message-Id: <20240126120132.24248-12-Jonathan.Cameron@huawei.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit d9ae5802f656f6fb53b788747ba557a826b6e740)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>

diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index d9eaa5fc4d..f9cdacadb1 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -1311,7 +1311,7 @@ static void build_acpi0017(Aml *table)
     aml_append(dev, aml_name_decl("_HID", aml_string("ACPI0017")));
 
     method = aml_method("_STA", 0, AML_NOTSERIALIZED);
-    aml_append(method, aml_return(aml_int(0x01)));
+    aml_append(method, aml_return(aml_int(0x0B)));
     aml_append(dev, method);
 
     aml_append(scope, dev);
-- 
2.39.2



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

* [Stable-7.2.10 18/33] tests/acpi: Update DSDT.cxl to reflect change _STA return value.
  2024-02-21 21:46 [Stable-7.2.10 v0 00/33] Patch Round-up for stable 7.2.10, freeze on 2024-03-02 Michael Tokarev
                   ` (16 preceding siblings ...)
  2024-02-21 21:47 ` [Stable-7.2.10 17/33] hw/i386: Fix _STA return value for ACPI0017 Michael Tokarev
@ 2024-02-21 21:47 ` Michael Tokarev
  2024-02-21 21:47 ` [Stable-7.2.10 19/33] linux-user/aarch64: Choose SYNC as the preferred MTE mode Michael Tokarev
                   ` (14 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: Michael Tokarev @ 2024-02-21 21:47 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-stable, Jonathan Cameron, Michael S . Tsirkin,
	Michael Tokarev

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

_STA will now return 0xB (in common with most other devices)
rather than not setting the bits to indicate this fake device
has not been enabled, and self tests haven't passed.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Message-Id: <20240126120132.24248-13-Jonathan.Cameron@huawei.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit b24a981b9f1c4767aaea815e504a2c7aeb405d72)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
(Mjt: rebuild tests/data/acpi/q35/DSDT.cxl for 7.2.x)

diff --git a/tests/data/acpi/q35/DSDT.cxl b/tests/data/acpi/q35/DSDT.cxl
index f9c6dd4ee0..267709e4e4 100644
Binary files a/tests/data/acpi/q35/DSDT.cxl and b/tests/data/acpi/q35/DSDT.cxl differ
diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios-tables-test-allowed-diff.h
index 9ce0f596cc..dfb8523c8b 100644
--- a/tests/qtest/bios-tables-test-allowed-diff.h
+++ b/tests/qtest/bios-tables-test-allowed-diff.h
@@ -1,2 +1 @@
 /* List of comma-separated changed AML files to ignore */
-"tests/data/acpi/q35/DSDT.cxl",
-- 
2.39.2



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

* [Stable-7.2.10 19/33] linux-user/aarch64: Choose SYNC as the preferred MTE mode
  2024-02-21 21:46 [Stable-7.2.10 v0 00/33] Patch Round-up for stable 7.2.10, freeze on 2024-03-02 Michael Tokarev
                   ` (17 preceding siblings ...)
  2024-02-21 21:47 ` [Stable-7.2.10 18/33] tests/acpi: Update DSDT.cxl to reflect change _STA return value Michael Tokarev
@ 2024-02-21 21:47 ` Michael Tokarev
  2024-02-21 21:47 ` [Stable-7.2.10 20/33] target/arm: Fix nregs computation in do_{ld, st}_zpa Michael Tokarev
                   ` (13 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: Michael Tokarev @ 2024-02-21 21:47 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-stable, Richard Henderson, Gustavo Romero, Peter Maydell,
	Michael Tokarev

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

The API does not generate an error for setting ASYNC | SYNC; that merely
constrains the selection vs the per-cpu default.  For qemu linux-user,
choose SYNC as the default.

Cc: qemu-stable@nongnu.org
Reported-by: Gustavo Romero <gustavo.romero@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Tested-by: Gustavo Romero <gustavo.romero@linaro.org>
Message-id: 20240207025210.8837-2-richard.henderson@linaro.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
(cherry picked from commit 681dfc0d552963d4d598350d26097a692900b408)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>

diff --git a/linux-user/aarch64/target_prctl.h b/linux-user/aarch64/target_prctl.h
index 907c314146..d9f6648e27 100644
--- a/linux-user/aarch64/target_prctl.h
+++ b/linux-user/aarch64/target_prctl.h
@@ -171,21 +171,26 @@ static abi_long do_prctl_set_tagged_addr_ctrl(CPUArchState *env, abi_long arg2)
     env->tagged_addr_enable = arg2 & PR_TAGGED_ADDR_ENABLE;
 
     if (cpu_isar_feature(aa64_mte, cpu)) {
-        switch (arg2 & PR_MTE_TCF_MASK) {
-        case PR_MTE_TCF_NONE:
-        case PR_MTE_TCF_SYNC:
-        case PR_MTE_TCF_ASYNC:
-            break;
-        default:
-            return -EINVAL;
-        }
-
         /*
          * Write PR_MTE_TCF to SCTLR_EL1[TCF0].
-         * Note that the syscall values are consistent with hw.
+         *
+         * The kernel has a per-cpu configuration for the sysadmin,
+         * /sys/devices/system/cpu/cpu<N>/mte_tcf_preferred,
+         * which qemu does not implement.
+         *
+         * Because there is no performance difference between the modes, and
+         * because SYNC is most useful for debugging MTE errors, choose SYNC
+         * as the preferred mode.  With this preference, and the way the API
+         * uses only two bits, there is no way for the program to select
+         * ASYMM mode.
          */
-        env->cp15.sctlr_el[1] =
-            deposit64(env->cp15.sctlr_el[1], 38, 2, arg2 >> PR_MTE_TCF_SHIFT);
+        unsigned tcf = 0;
+        if (arg2 & PR_MTE_TCF_SYNC) {
+            tcf = 1;
+        } else if (arg2 & PR_MTE_TCF_ASYNC) {
+            tcf = 2;
+        }
+        env->cp15.sctlr_el[1] = deposit64(env->cp15.sctlr_el[1], 38, 2, tcf);
 
         /*
          * Write PR_MTE_TAG to GCR_EL1[Exclude].
-- 
2.39.2



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

* [Stable-7.2.10 20/33] target/arm: Fix nregs computation in do_{ld, st}_zpa
  2024-02-21 21:46 [Stable-7.2.10 v0 00/33] Patch Round-up for stable 7.2.10, freeze on 2024-03-02 Michael Tokarev
                   ` (18 preceding siblings ...)
  2024-02-21 21:47 ` [Stable-7.2.10 19/33] linux-user/aarch64: Choose SYNC as the preferred MTE mode Michael Tokarev
@ 2024-02-21 21:47 ` Michael Tokarev
  2024-02-21 21:47 ` [Stable-7.2.10 21/33] target/arm: Fix SVE/SME gross MTE suppression checks Michael Tokarev
                   ` (12 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: Michael Tokarev @ 2024-02-21 21:47 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-stable, Richard Henderson, Gustavo Romero, Peter Maydell,
	Michael Tokarev

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

The field is encoded as [0-3], which is convenient for
indexing our array of function pointers, but the true
value is [1-4].  Adjust before calling do_mem_zpa.

Add an assert, and move the comment re passing ZT to
the helper back next to the relevant code.

Cc: qemu-stable@nongnu.org
Fixes: 206adacfb8d ("target/arm: Add mte helpers for sve scalar + int loads")
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Tested-by: Gustavo Romero <gustavo.romero@linaro.org>
Message-id: 20240207025210.8837-3-richard.henderson@linaro.org
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
(cherry picked from commit 64c6e7444dff64b42d11b836b9aec9acfbe8ecc2)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>

diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c
index 621a2abb22..7388e1dbc7 100644
--- a/target/arm/translate-sve.c
+++ b/target/arm/translate-sve.c
@@ -4587,11 +4587,7 @@ static void do_mem_zpa(DisasContext *s, int zt, int pg, TCGv_i64 addr,
     TCGv_ptr t_pg;
     int desc = 0;
 
-    /*
-     * For e.g. LD4, there are not enough arguments to pass all 4
-     * registers as pointers, so encode the regno into the data field.
-     * For consistency, do this even for LD1.
-     */
+    assert(mte_n >= 1 && mte_n <= 4);
     if (s->mte_active[0]) {
         int msz = dtype_msz(dtype);
 
@@ -4605,6 +4601,11 @@ static void do_mem_zpa(DisasContext *s, int zt, int pg, TCGv_i64 addr,
         addr = clean_data_tbi(s, addr);
     }
 
+    /*
+     * For e.g. LD4, there are not enough arguments to pass all 4
+     * registers as pointers, so encode the regno into the data field.
+     * For consistency, do this even for LD1.
+     */
     desc = simd_desc(vsz, vsz, zt | desc);
     t_pg = tcg_temp_new_ptr();
 
@@ -4744,7 +4745,7 @@ static void do_ld_zpa(DisasContext *s, int zt, int pg,
      * accessible via the instruction encoding.
      */
     assert(fn != NULL);
-    do_mem_zpa(s, zt, pg, addr, dtype, nreg, false, fn);
+    do_mem_zpa(s, zt, pg, addr, dtype, nreg + 1, false, fn);
 }
 
 static bool trans_LD_zprr(DisasContext *s, arg_rprr_load *a)
@@ -5320,14 +5321,13 @@ static void do_st_zpa(DisasContext *s, int zt, int pg, TCGv_i64 addr,
     if (nreg == 0) {
         /* ST1 */
         fn = fn_single[s->mte_active[0]][be][msz][esz];
-        nreg = 1;
     } else {
         /* ST2, ST3, ST4 -- msz == esz, enforced by encoding */
         assert(msz == esz);
         fn = fn_multiple[s->mte_active[0]][be][nreg - 1][msz];
     }
     assert(fn != NULL);
-    do_mem_zpa(s, zt, pg, addr, msz_dtype(s, msz), nreg, true, fn);
+    do_mem_zpa(s, zt, pg, addr, msz_dtype(s, msz), nreg + 1, true, fn);
 }
 
 static bool trans_ST_zprr(DisasContext *s, arg_rprr_store *a)
-- 
2.39.2



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

* [Stable-7.2.10 21/33] target/arm: Fix SVE/SME gross MTE suppression checks
  2024-02-21 21:46 [Stable-7.2.10 v0 00/33] Patch Round-up for stable 7.2.10, freeze on 2024-03-02 Michael Tokarev
                   ` (19 preceding siblings ...)
  2024-02-21 21:47 ` [Stable-7.2.10 20/33] target/arm: Fix nregs computation in do_{ld, st}_zpa Michael Tokarev
@ 2024-02-21 21:47 ` Michael Tokarev
  2024-02-21 21:47 ` [Stable-7.2.10 22/33] target/arm: Don't get MDCR_EL2 in pmu_counter_enabled() before checking ARM_FEATURE_PMU Michael Tokarev
                   ` (11 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: Michael Tokarev @ 2024-02-21 21:47 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-stable, Richard Henderson, Peter Maydell, Gustavo Romero,
	Michael Tokarev

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

The TBI and TCMA bits are located within mtedesc, not desc.

Cc: qemu-stable@nongnu.org
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Tested-by: Gustavo Romero <gustavo.romero@linaro.org>
Message-id: 20240207025210.8837-7-richard.henderson@linaro.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
(cherry picked from commit 855f94eca80c85a99f459e36684ea2f98f6a3243)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>

diff --git a/target/arm/sme_helper.c b/target/arm/sme_helper.c
index 8856773635..d592c78ec9 100644
--- a/target/arm/sme_helper.c
+++ b/target/arm/sme_helper.c
@@ -606,8 +606,8 @@ void sme_ld1_mte(CPUARMState *env, void *za, uint64_t *vg,
     desc = extract32(desc, 0, SIMD_DATA_SHIFT + SVE_MTEDESC_SHIFT);
 
     /* Perform gross MTE suppression early. */
-    if (!tbi_check(desc, bit55) ||
-        tcma_check(desc, bit55, allocation_tag_from_addr(addr))) {
+    if (!tbi_check(mtedesc, bit55) ||
+        tcma_check(mtedesc, bit55, allocation_tag_from_addr(addr))) {
         mtedesc = 0;
     }
 
@@ -783,8 +783,8 @@ void sme_st1_mte(CPUARMState *env, void *za, uint64_t *vg, target_ulong addr,
     desc = extract32(desc, 0, SIMD_DATA_SHIFT + SVE_MTEDESC_SHIFT);
 
     /* Perform gross MTE suppression early. */
-    if (!tbi_check(desc, bit55) ||
-        tcma_check(desc, bit55, allocation_tag_from_addr(addr))) {
+    if (!tbi_check(mtedesc, bit55) ||
+        tcma_check(mtedesc, bit55, allocation_tag_from_addr(addr))) {
         mtedesc = 0;
     }
 
diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c
index 27838fb6e2..45a93755fe 100644
--- a/target/arm/sve_helper.c
+++ b/target/arm/sve_helper.c
@@ -5803,8 +5803,8 @@ void sve_ldN_r_mte(CPUARMState *env, uint64_t *vg, target_ulong addr,
     desc = extract32(desc, 0, SIMD_DATA_SHIFT + SVE_MTEDESC_SHIFT);
 
     /* Perform gross MTE suppression early. */
-    if (!tbi_check(desc, bit55) ||
-        tcma_check(desc, bit55, allocation_tag_from_addr(addr))) {
+    if (!tbi_check(mtedesc, bit55) ||
+        tcma_check(mtedesc, bit55, allocation_tag_from_addr(addr))) {
         mtedesc = 0;
     }
 
@@ -6159,8 +6159,8 @@ void sve_ldnfff1_r_mte(CPUARMState *env, void *vg, target_ulong addr,
     desc = extract32(desc, 0, SIMD_DATA_SHIFT + SVE_MTEDESC_SHIFT);
 
     /* Perform gross MTE suppression early. */
-    if (!tbi_check(desc, bit55) ||
-        tcma_check(desc, bit55, allocation_tag_from_addr(addr))) {
+    if (!tbi_check(mtedesc, bit55) ||
+        tcma_check(mtedesc, bit55, allocation_tag_from_addr(addr))) {
         mtedesc = 0;
     }
 
@@ -6413,8 +6413,8 @@ void sve_stN_r_mte(CPUARMState *env, uint64_t *vg, target_ulong addr,
     desc = extract32(desc, 0, SIMD_DATA_SHIFT + SVE_MTEDESC_SHIFT);
 
     /* Perform gross MTE suppression early. */
-    if (!tbi_check(desc, bit55) ||
-        tcma_check(desc, bit55, allocation_tag_from_addr(addr))) {
+    if (!tbi_check(mtedesc, bit55) ||
+        tcma_check(mtedesc, bit55, allocation_tag_from_addr(addr))) {
         mtedesc = 0;
     }
 
-- 
2.39.2



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

* [Stable-7.2.10 22/33] target/arm: Don't get MDCR_EL2 in pmu_counter_enabled() before checking ARM_FEATURE_PMU
  2024-02-21 21:46 [Stable-7.2.10 v0 00/33] Patch Round-up for stable 7.2.10, freeze on 2024-03-02 Michael Tokarev
                   ` (20 preceding siblings ...)
  2024-02-21 21:47 ` [Stable-7.2.10 21/33] target/arm: Fix SVE/SME gross MTE suppression checks Michael Tokarev
@ 2024-02-21 21:47 ` Michael Tokarev
  2024-02-21 21:47 ` [Stable-7.2.10 23/33] iotests: Make 144 deterministic again Michael Tokarev
                   ` (10 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: Michael Tokarev @ 2024-02-21 21:47 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-stable, Peter Maydell, Philippe Mathieu-Daudé,
	Richard Henderson, Michael Tokarev

From: Peter Maydell <peter.maydell@linaro.org>

It doesn't make sense to read the value of MDCR_EL2 on a non-A-profile
CPU, and in fact if you try to do it we will assert:

#6  0x00007ffff4b95e96 in __GI___assert_fail
    (assertion=0x5555565a8c70 "!arm_feature(env, ARM_FEATURE_M)", file=0x5555565a6e5c "../../target/arm/helper.c", line=12600, function=0x5555565a9560 <__PRETTY_FUNCTION__.0> "arm_security_space_below_el3") at ./assert/assert.c:101
#7  0x0000555555ebf412 in arm_security_space_below_el3 (env=0x555557bc8190) at ../../target/arm/helper.c:12600
#8  0x0000555555ea6f89 in arm_is_el2_enabled (env=0x555557bc8190) at ../../target/arm/cpu.h:2595
#9  0x0000555555ea942f in arm_mdcr_el2_eff (env=0x555557bc8190) at ../../target/arm/internals.h:1512

We might call pmu_counter_enabled() on an M-profile CPU (for example
from the migration pre/post hooks in machine.c); this should always
return false because these CPUs don't set ARM_FEATURE_PMU.

Avoid the assertion by not calling arm_mdcr_el2_eff() before we
have done the early return for "PMU not present".

This fixes an assertion failure if you try to do a loadvm or
savevm for an M-profile board.

Cc: qemu-stable@nongnu.org
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2155
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20240208153346.970021-1-peter.maydell@linaro.org
(cherry picked from commit ac1d88e9e7ca0bed83e91e07ce6d0597f10cc77d)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>

diff --git a/target/arm/helper.c b/target/arm/helper.c
index 343acfab3a..2e284e048c 100644
--- a/target/arm/helper.c
+++ b/target/arm/helper.c
@@ -1125,13 +1125,21 @@ static bool pmu_counter_enabled(CPUARMState *env, uint8_t counter)
     bool enabled, prohibited = false, filtered;
     bool secure = arm_is_secure(env);
     int el = arm_current_el(env);
-    uint64_t mdcr_el2 = arm_mdcr_el2_eff(env);
-    uint8_t hpmn = mdcr_el2 & MDCR_HPMN;
+    uint64_t mdcr_el2;
+    uint8_t hpmn;
 
+    /*
+     * We might be called for M-profile cores where MDCR_EL2 doesn't
+     * exist and arm_mdcr_el2_eff() will assert, so this early-exit check
+     * must be before we read that value.
+     */
     if (!arm_feature(env, ARM_FEATURE_PMU)) {
         return false;
     }
 
+    mdcr_el2 = arm_mdcr_el2_eff(env);
+    hpmn = mdcr_el2 & MDCR_HPMN;
+
     if (!arm_feature(env, ARM_FEATURE_EL2) ||
             (counter < hpmn || counter == 31)) {
         e = env->cp15.c9_pmcr & PMCRE;
-- 
2.39.2



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

* [Stable-7.2.10 23/33] iotests: Make 144 deterministic again
  2024-02-21 21:46 [Stable-7.2.10 v0 00/33] Patch Round-up for stable 7.2.10, freeze on 2024-03-02 Michael Tokarev
                   ` (21 preceding siblings ...)
  2024-02-21 21:47 ` [Stable-7.2.10 22/33] target/arm: Don't get MDCR_EL2 in pmu_counter_enabled() before checking ARM_FEATURE_PMU Michael Tokarev
@ 2024-02-21 21:47 ` Michael Tokarev
  2024-02-21 21:47 ` [Stable-7.2.10 24/33] i386/cpu: Clear FEAT_XSAVE_XSS_LO/HI leafs when CPUID_EXT_XSAVE is not available Michael Tokarev
                   ` (9 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: Michael Tokarev @ 2024-02-21 21:47 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-stable, Kevin Wolf, Stefan Hajnoczi, Peter Maydell,
	Michael Tokarev

From: Kevin Wolf <kwolf@redhat.com>

Since commit effd60c8 changed how QMP commands are processed, the order
of the block-commit return value and job events in iotests 144 wasn't
fixed and more and caused the test to fail intermittently.

Change the test to cache events first and then print them in a
predefined order.

Waiting three times for JOB_STATUS_CHANGE is a bit uglier than just
waiting for the JOB_STATUS_CHANGE that has "status": "ready", but the
tooling we have doesn't seem to allow the latter easily.

Fixes: effd60c878176bcaf97fa7ce2b12d04bb8ead6f7
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2126
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-id: 20240209173103.239994-1-kwolf@redhat.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
(cherry picked from commit cc29c12ec629ba68a4a6cb7d165c94cc8502815a)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>

diff --git a/tests/qemu-iotests/144 b/tests/qemu-iotests/144
index bdcc498fa2..d284a0e442 100755
--- a/tests/qemu-iotests/144
+++ b/tests/qemu-iotests/144
@@ -83,12 +83,22 @@ echo
 echo === Performing block-commit on active layer ===
 echo
 
+capture_events="BLOCK_JOB_READY JOB_STATUS_CHANGE"
+
 # Block commit on active layer, push the new overlay into base
 _send_qemu_cmd $h "{ 'execute': 'block-commit',
                                 'arguments': {
                                                  'device': 'virtio0'
                                               }
-                    }" "READY"
+                    }" "return"
+
+_wait_event $h "JOB_STATUS_CHANGE"
+_wait_event $h "JOB_STATUS_CHANGE"
+_wait_event $h "JOB_STATUS_CHANGE"
+
+_wait_event $h "BLOCK_JOB_READY"
+
+capture_events=
 
 _send_qemu_cmd $h "{ 'execute': 'block-job-complete',
                                 'arguments': {
diff --git a/tests/qemu-iotests/144.out b/tests/qemu-iotests/144.out
index b3b4812015..2245ddfa10 100644
--- a/tests/qemu-iotests/144.out
+++ b/tests/qemu-iotests/144.out
@@ -25,9 +25,9 @@ Formatting 'TEST_DIR/tmp.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off co
                                                  'device': 'virtio0'
                                               }
                     }
+{"return": {}}
 {"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "created", "id": "virtio0"}}
 {"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "running", "id": "virtio0"}}
-{"return": {}}
 {"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "ready", "id": "virtio0"}}
 {"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "BLOCK_JOB_READY", "data": {"device": "virtio0", "len": 0, "offset": 0, "speed": 0, "type": "commit"}}
 { 'execute': 'block-job-complete',
-- 
2.39.2



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

* [Stable-7.2.10 24/33] i386/cpu: Clear FEAT_XSAVE_XSS_LO/HI leafs when CPUID_EXT_XSAVE is not available
  2024-02-21 21:46 [Stable-7.2.10 v0 00/33] Patch Round-up for stable 7.2.10, freeze on 2024-03-02 Michael Tokarev
                   ` (22 preceding siblings ...)
  2024-02-21 21:47 ` [Stable-7.2.10 23/33] iotests: Make 144 deterministic again Michael Tokarev
@ 2024-02-21 21:47 ` Michael Tokarev
  2024-02-21 21:47 ` [Stable-7.2.10 25/33] i386/cpu: Mask with XCR0/XSS mask for FEAT_XSAVE_XCR0_HI and FEAT_XSAVE_XSS_HI leafs Michael Tokarev
                   ` (8 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: Michael Tokarev @ 2024-02-21 21:47 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-stable, Xiaoyao Li, Yang Weijiang, Paolo Bonzini,
	Michael Tokarev

From: Xiaoyao Li <xiaoyao.li@intel.com>

Leaf FEAT_XSAVE_XSS_LO and FEAT_XSAVE_XSS_HI also need to be cleared
when CPUID_EXT_XSAVE is not set.

Fixes: 301e90675c3f ("target/i386: Enable support for XSAVES based features")
Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com>
Reviewed-by: Yang Weijiang <weijiang.yang@intel.com>
Message-ID: <20240115091325.1904229-2-xiaoyao.li@intel.com>
Cc: qemu-stable@nongnu.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
(cherry picked from commit 81f5cad3858f27623b1b14467926032d229b76cc)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>

diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index 0f71ff9fea..952fa5780f 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -6114,6 +6114,8 @@ static void x86_cpu_enable_xsave_components(X86CPU *cpu)
     if (!(env->features[FEAT_1_ECX] & CPUID_EXT_XSAVE)) {
         env->features[FEAT_XSAVE_XCR0_LO] = 0;
         env->features[FEAT_XSAVE_XCR0_HI] = 0;
+        env->features[FEAT_XSAVE_XSS_LO] = 0;
+        env->features[FEAT_XSAVE_XSS_HI] = 0;
         return;
     }
 
-- 
2.39.2



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

* [Stable-7.2.10 25/33] i386/cpu: Mask with XCR0/XSS mask for FEAT_XSAVE_XCR0_HI and FEAT_XSAVE_XSS_HI leafs
  2024-02-21 21:46 [Stable-7.2.10 v0 00/33] Patch Round-up for stable 7.2.10, freeze on 2024-03-02 Michael Tokarev
                   ` (23 preceding siblings ...)
  2024-02-21 21:47 ` [Stable-7.2.10 24/33] i386/cpu: Clear FEAT_XSAVE_XSS_LO/HI leafs when CPUID_EXT_XSAVE is not available Michael Tokarev
@ 2024-02-21 21:47 ` Michael Tokarev
  2024-02-21 21:47 ` [Stable-7.2.10 26/33] i386/cpuid: Decrease cpuid_i when skipping CPUID leaf 1F Michael Tokarev
                   ` (7 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: Michael Tokarev @ 2024-02-21 21:47 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-stable, Xiaoyao Li, Yang Weijiang, Paolo Bonzini,
	Michael Tokarev

From: Xiaoyao Li <xiaoyao.li@intel.com>

The value of FEAT_XSAVE_XCR0_HI leaf and FEAT_XSAVE_XSS_HI leaf also
need to be masked by XCR0 and XSS mask respectively, to make it
logically correct.

Fixes: 301e90675c3f ("target/i386: Enable support for XSAVES based features")
Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com>
Reviewed-by: Yang Weijiang <weijiang.yang@intel.com>
Message-ID: <20240115091325.1904229-3-xiaoyao.li@intel.com>
Cc: qemu-stable@nongnu.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
(cherry picked from commit a11a365159b944e05be76f3ec3b98c8b38cb70fd)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>

diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index 952fa5780f..52a3020032 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -6134,9 +6134,9 @@ static void x86_cpu_enable_xsave_components(X86CPU *cpu)
     }
 
     env->features[FEAT_XSAVE_XCR0_LO] = mask & CPUID_XSTATE_XCR0_MASK;
-    env->features[FEAT_XSAVE_XCR0_HI] = mask >> 32;
+    env->features[FEAT_XSAVE_XCR0_HI] = (mask & CPUID_XSTATE_XCR0_MASK) >> 32;
     env->features[FEAT_XSAVE_XSS_LO] = mask & CPUID_XSTATE_XSS_MASK;
-    env->features[FEAT_XSAVE_XSS_HI] = mask >> 32;
+    env->features[FEAT_XSAVE_XSS_HI] = (mask & CPUID_XSTATE_XSS_MASK) >> 32;
 }
 
 /***** Steps involved on loading and filtering CPUID data
-- 
2.39.2



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

* [Stable-7.2.10 26/33] i386/cpuid: Decrease cpuid_i when skipping CPUID leaf 1F
  2024-02-21 21:46 [Stable-7.2.10 v0 00/33] Patch Round-up for stable 7.2.10, freeze on 2024-03-02 Michael Tokarev
                   ` (24 preceding siblings ...)
  2024-02-21 21:47 ` [Stable-7.2.10 25/33] i386/cpu: Mask with XCR0/XSS mask for FEAT_XSAVE_XCR0_HI and FEAT_XSAVE_XSS_HI leafs Michael Tokarev
@ 2024-02-21 21:47 ` Michael Tokarev
  2024-02-21 21:47 ` [Stable-7.2.10 27/33] i386/cpuid: Move leaf 7 to correct group Michael Tokarev
                   ` (6 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: Michael Tokarev @ 2024-02-21 21:47 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-stable, Xiaoyao Li, Paolo Bonzini, Michael Tokarev

From: Xiaoyao Li <xiaoyao.li@intel.com>

Existing code misses a decrement of cpuid_i when skip leaf 0x1F.
There's a blank CPUID entry(with leaf, subleaf as 0, and all fields
stuffed 0s) left in the CPUID array.

It conflicts with correct CPUID leaf 0.

Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com>
Reviewed-by:Yang Weijiang <weijiang.yang@intel.com>
Message-ID: <20240125024016.2521244-2-xiaoyao.li@intel.com>
Cc: qemu-stable@nongnu.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
(cherry picked from commit 10f92799af8ba3c3cef2352adcd4780f13fbab31)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>

diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c
index 002b699030..5779b80ecb 100644
--- a/target/i386/kvm/kvm.c
+++ b/target/i386/kvm/kvm.c
@@ -1859,6 +1859,7 @@ int kvm_arch_init_vcpu(CPUState *cs)
         }
         case 0x1f:
             if (env->nr_dies < 2) {
+                cpuid_i--;
                 break;
             }
             /* fallthrough */
-- 
2.39.2



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

* [Stable-7.2.10 27/33] i386/cpuid: Move leaf 7 to correct group
  2024-02-21 21:46 [Stable-7.2.10 v0 00/33] Patch Round-up for stable 7.2.10, freeze on 2024-03-02 Michael Tokarev
                   ` (25 preceding siblings ...)
  2024-02-21 21:47 ` [Stable-7.2.10 26/33] i386/cpuid: Decrease cpuid_i when skipping CPUID leaf 1F Michael Tokarev
@ 2024-02-21 21:47 ` Michael Tokarev
  2024-02-21 21:47 ` [Stable-7.2.10 28/33] target/i386: Generate an illegal opcode exception on cmp instructions with lock prefix Michael Tokarev
                   ` (5 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: Michael Tokarev @ 2024-02-21 21:47 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-stable, Xiaoyao Li, Paolo Bonzini, Michael Tokarev

From: Xiaoyao Li <xiaoyao.li@intel.com>

CPUID leaf 7 was grouped together with SGX leaf 0x12 by commit
b9edbadefb9e ("i386: Propagate SGX CPUID sub-leafs to KVM") by mistake.

SGX leaf 0x12 has its specific logic to check if subleaf (starting from 2)
is valid or not by checking the bit 0:3 of corresponding EAX is 1 or
not.

Leaf 7 follows the logic that EAX of subleaf 0 enumerates the maximum
valid subleaf.

Fixes: b9edbadefb9e ("i386: Propagate SGX CPUID sub-leafs to KVM")
Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com>
Message-ID: <20240125024016.2521244-4-xiaoyao.li@intel.com>
Cc: qemu-stable@nongnu.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
(cherry picked from commit 0729857c707535847d7fe31d3d91eb8b2a118e3c)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>

diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c
index 5779b80ecb..4d83bb5784 100644
--- a/target/i386/kvm/kvm.c
+++ b/target/i386/kvm/kvm.c
@@ -1900,7 +1900,6 @@ int kvm_arch_init_vcpu(CPUState *cs)
                 c = &cpuid_data.entries[cpuid_i++];
             }
             break;
-        case 0x7:
         case 0x12:
             for (j = 0; ; j++) {
                 c->function = i;
@@ -1920,6 +1919,7 @@ int kvm_arch_init_vcpu(CPUState *cs)
                 c = &cpuid_data.entries[cpuid_i++];
             }
             break;
+        case 0x7:
         case 0x14:
         case 0x1d:
         case 0x1e: {
-- 
2.39.2



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

* [Stable-7.2.10 28/33] target/i386: Generate an illegal opcode exception on cmp instructions with lock prefix
  2024-02-21 21:46 [Stable-7.2.10 v0 00/33] Patch Round-up for stable 7.2.10, freeze on 2024-03-02 Michael Tokarev
                   ` (26 preceding siblings ...)
  2024-02-21 21:47 ` [Stable-7.2.10 27/33] i386/cpuid: Move leaf 7 to correct group Michael Tokarev
@ 2024-02-21 21:47 ` Michael Tokarev
  2024-02-21 21:47 ` [Stable-7.2.10 29/33] ui: reject extended clipboard message if not activated Michael Tokarev
                   ` (4 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: Michael Tokarev @ 2024-02-21 21:47 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-stable, Ziqiao Kong, Paolo Bonzini, Michael Tokarev

From: Ziqiao Kong <ziqiaokong@gmail.com>

target/i386: As specified by Intel Manual Vol2 3-180, cmp instructions
are not allowed to have lock prefix and a `UD` should be raised. Without
this patch, s1->T0 will be uninitialized and used in the case OP_CMPL.

Signed-off-by: Ziqiao Kong <ziqiaokong@gmail.com>
Message-ID: <20240215095015.570748-2-ziqiaokong@gmail.com>
Cc: qemu-stable@nongnu.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
(cherry picked from commit 99d0dcd7f102c07a510200d768cae65e5db25d23)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>

diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c
index 68c42fd9ff..abacb91ddf 100644
--- a/target/i386/tcg/translate.c
+++ b/target/i386/tcg/translate.c
@@ -1501,12 +1501,13 @@ static bool check_iopl(DisasContext *s)
 /* if d == OR_TMP0, it means memory operand (address in A0) */
 static void gen_op(DisasContext *s1, int op, MemOp ot, int d)
 {
+    /* Invalid lock prefix when destination is not memory or OP_CMPL. */
+    if ((d != OR_TMP0 || op == OP_CMPL) && s1->prefix & PREFIX_LOCK) {
+        gen_illegal_opcode(s1);
+        return;
+    }
+
     if (d != OR_TMP0) {
-        if (s1->prefix & PREFIX_LOCK) {
-            /* Lock prefix when destination is not memory.  */
-            gen_illegal_opcode(s1);
-            return;
-        }
         gen_op_mov_v_reg(s1, ot, s1->T0, d);
     } else if (!(s1->prefix & PREFIX_LOCK)) {
         gen_op_ld_v(s1, ot, s1->T0, s1->A0);
-- 
2.39.2



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

* [Stable-7.2.10 29/33] ui: reject extended clipboard message if not activated
  2024-02-21 21:46 [Stable-7.2.10 v0 00/33] Patch Round-up for stable 7.2.10, freeze on 2024-03-02 Michael Tokarev
                   ` (27 preceding siblings ...)
  2024-02-21 21:47 ` [Stable-7.2.10 28/33] target/i386: Generate an illegal opcode exception on cmp instructions with lock prefix Michael Tokarev
@ 2024-02-21 21:47 ` Michael Tokarev
  2024-02-21 21:47 ` [Stable-7.2.10 30/33] ui/clipboard: mark type as not available when there is no data Michael Tokarev
                   ` (3 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: Michael Tokarev @ 2024-02-21 21:47 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-stable, Daniel P. Berrangé, Marc-André Lureau,
	Michael Tokarev

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

The extended clipboard message protocol requires that the client
activate the extension by requesting a psuedo encoding. If this
is not done, then any extended clipboard messages from the client
should be considered invalid and the client dropped.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20240115095119.654271-1-berrange@redhat.com>
(cherry picked from commit 4cba8388968b70fe20e290221dc421c717051fdd)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>

diff --git a/ui/vnc.c b/ui/vnc.c
index 1ca16c0ff6..629a500adc 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -2456,6 +2456,11 @@ static int protocol_client_msg(VncState *vs, uint8_t *data, size_t len)
         }
 
         if (read_s32(data, 4) < 0) {
+            if (!vnc_has_feature(vs, VNC_FEATURE_CLIPBOARD_EXT)) {
+                error_report("vnc: extended clipboard message while disabled");
+                vnc_client_error(vs);
+                break;
+            }
             if (dlen < 4) {
                 error_report("vnc: malformed payload (header less than 4 bytes)"
                              " in extended clipboard pseudo-encoding.");
-- 
2.39.2



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

* [Stable-7.2.10 30/33] ui/clipboard: mark type as not available when there is no data
  2024-02-21 21:46 [Stable-7.2.10 v0 00/33] Patch Round-up for stable 7.2.10, freeze on 2024-03-02 Michael Tokarev
                   ` (28 preceding siblings ...)
  2024-02-21 21:47 ` [Stable-7.2.10 29/33] ui: reject extended clipboard message if not activated Michael Tokarev
@ 2024-02-21 21:47 ` Michael Tokarev
  2024-02-21 21:47 ` [Stable-7.2.10 31/33] ui/clipboard: add asserts for update and request Michael Tokarev
                   ` (2 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: Michael Tokarev @ 2024-02-21 21:47 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-stable, Fiona Ebner, Markus Frank, Marc-André Lureau,
	Michael Tokarev

From: Fiona Ebner <f.ebner@proxmox.com>

With VNC, a client can send a non-extended VNC_MSG_CLIENT_CUT_TEXT
message with len=0. In qemu_clipboard_set_data(), the clipboard info
will be updated setting data to NULL (because g_memdup(data, size)
returns NULL when size is 0). If the client does not set the
VNC_ENCODING_CLIPBOARD_EXT feature when setting up the encodings, then
the 'request' callback for the clipboard peer is not initialized.
Later, because data is NULL, qemu_clipboard_request() can be reached
via vdagent_chr_write() and vdagent_clipboard_recv_request() and
there, the clipboard owner's 'request' callback will be attempted to
be called, but that is a NULL pointer.

In particular, this can happen when using the KRDC (22.12.3) VNC
client.

Another scenario leading to the same issue is with two clients (say
noVNC and KRDC):

The noVNC client sets the extension VNC_FEATURE_CLIPBOARD_EXT and
initializes its cbpeer.

The KRDC client does not, but triggers a vnc_client_cut_text() (note
it's not the _ext variant)). There, a new clipboard info with it as
the 'owner' is created and via qemu_clipboard_set_data() is called,
which in turn calls qemu_clipboard_update() with that info.

In qemu_clipboard_update(), the notifier for the noVNC client will be
called, i.e. vnc_clipboard_notify() and also set vs->cbinfo for the
noVNC client. The 'owner' in that clipboard info is the clipboard peer
for the KRDC client, which did not initialize the 'request' function.
That sounds correct to me, it is the owner of that clipboard info.

Then when noVNC sends a VNC_MSG_CLIENT_CUT_TEXT message (it did set
the VNC_FEATURE_CLIPBOARD_EXT feature correctly, so a check for it
passes), that clipboard info is passed to qemu_clipboard_request() and
the original segfault still happens.

Fix the issue by handling updates with size 0 differently. In
particular, mark in the clipboard info that the type is not available.

While at it, switch to g_memdup2(), because g_memdup() is deprecated.

Cc: qemu-stable@nongnu.org
Fixes: CVE-2023-6683
Reported-by: Markus Frank <m.frank@proxmox.com>
Suggested-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Tested-by: Markus Frank <m.frank@proxmox.com>
Message-ID: <20240124105749.204610-1-f.ebner@proxmox.com>
(cherry picked from commit 405484b29f6548c7b86549b0f961b906337aa68a)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>

diff --git a/ui/clipboard.c b/ui/clipboard.c
index 3d14bffaf8..b3f6fa3c9e 100644
--- a/ui/clipboard.c
+++ b/ui/clipboard.c
@@ -163,9 +163,15 @@ void qemu_clipboard_set_data(QemuClipboardPeer *peer,
     }
 
     g_free(info->types[type].data);
-    info->types[type].data = g_memdup(data, size);
-    info->types[type].size = size;
-    info->types[type].available = true;
+    if (size) {
+        info->types[type].data = g_memdup2(data, size);
+        info->types[type].size = size;
+        info->types[type].available = true;
+    } else {
+        info->types[type].data = NULL;
+        info->types[type].size = 0;
+        info->types[type].available = false;
+    }
 
     if (update) {
         qemu_clipboard_update(info);
-- 
2.39.2



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

* [Stable-7.2.10 31/33] ui/clipboard: add asserts for update and request
  2024-02-21 21:46 [Stable-7.2.10 v0 00/33] Patch Round-up for stable 7.2.10, freeze on 2024-03-02 Michael Tokarev
                   ` (29 preceding siblings ...)
  2024-02-21 21:47 ` [Stable-7.2.10 30/33] ui/clipboard: mark type as not available when there is no data Michael Tokarev
@ 2024-02-21 21:47 ` Michael Tokarev
  2024-02-21 21:47 ` [Stable-7.2.10 32/33] ui/console: Fix console resize with placeholder surface Michael Tokarev
  2024-02-21 21:47 ` [Stable-7.2.10 33/33] audio: Depend on dbus_display1_dep Michael Tokarev
  32 siblings, 0 replies; 34+ messages in thread
From: Michael Tokarev @ 2024-02-21 21:47 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-stable, Fiona Ebner, Marc-André Lureau, Michael Tokarev

From: Fiona Ebner <f.ebner@proxmox.com>

Should an issue like CVE-2023-6683 ever appear again in the future,
it will be more obvious which assumption was violated.

Suggested-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-ID: <20240124105749.204610-2-f.ebner@proxmox.com>
(cherry picked from commit 9c416582611b7495bdddb4c5456c7acb64b78938)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>

diff --git a/ui/clipboard.c b/ui/clipboard.c
index b3f6fa3c9e..4264884a6c 100644
--- a/ui/clipboard.c
+++ b/ui/clipboard.c
@@ -65,12 +65,24 @@ bool qemu_clipboard_check_serial(QemuClipboardInfo *info, bool client)
 
 void qemu_clipboard_update(QemuClipboardInfo *info)
 {
+    uint32_t type;
     QemuClipboardNotify notify = {
         .type = QEMU_CLIPBOARD_UPDATE_INFO,
         .info = info,
     };
     assert(info->selection < QEMU_CLIPBOARD_SELECTION__COUNT);
 
+    for (type = 0; type < QEMU_CLIPBOARD_TYPE__COUNT; type++) {
+        /*
+         * If data is missing, the clipboard owner's 'request' callback needs to
+         * be set. Otherwise, there is no way to get the clipboard data and
+         * qemu_clipboard_request() cannot be called.
+         */
+        if (info->types[type].available && !info->types[type].data) {
+            assert(info->owner && info->owner->request);
+        }
+    }
+
     notifier_list_notify(&clipboard_notifiers, &notify);
 
     if (cbinfo[info->selection] != info) {
@@ -132,6 +144,8 @@ void qemu_clipboard_request(QemuClipboardInfo *info,
         !info->owner)
         return;
 
+    assert(info->owner->request);
+
     info->types[type].requested = true;
     info->owner->request(info, type);
 }
-- 
2.39.2



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

* [Stable-7.2.10 32/33] ui/console: Fix console resize with placeholder surface
  2024-02-21 21:46 [Stable-7.2.10 v0 00/33] Patch Round-up for stable 7.2.10, freeze on 2024-03-02 Michael Tokarev
                   ` (30 preceding siblings ...)
  2024-02-21 21:47 ` [Stable-7.2.10 31/33] ui/clipboard: add asserts for update and request Michael Tokarev
@ 2024-02-21 21:47 ` Michael Tokarev
  2024-02-21 21:47 ` [Stable-7.2.10 33/33] audio: Depend on dbus_display1_dep Michael Tokarev
  32 siblings, 0 replies; 34+ messages in thread
From: Michael Tokarev @ 2024-02-21 21:47 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-stable, Tianlan Zhou, Marc-André Lureau,
	Michael Tokarev

From: Tianlan Zhou <bobby825@126.com>

In `qemu_console_resize()`, the old surface of the console is keeped if the new
console size is the same as the old one. If the old surface is a placeholder,
and the new size of console is the same as the placeholder surface (640*480),
the surface won't be replace.
In this situation, the surface's `QEMU_PLACEHOLDER_FLAG` flag is still set, so
the console won't be displayed in SDL display mode.
This patch fixes this problem by forcing a new surface if the old one is a
placeholder.

Signed-off-by: Tianlan Zhou <bobby825@126.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-ID: <20240207172024.8-1-bobby825@126.com>
(cherry picked from commit 95b08fee8f68d284a5028d37fd28be7a70c8e92b)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>

diff --git a/ui/console.c b/ui/console.c
index 52414d6aa3..269cf27163 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -2583,7 +2583,7 @@ void qemu_console_resize(QemuConsole *s, int width, int height)
     assert(s->console_type == GRAPHIC_CONSOLE);
 
     if ((s->scanout.kind != SCANOUT_SURFACE ||
-         (surface && surface->flags & QEMU_ALLOCATED_FLAG)) &&
+         (surface && !is_buffer_shared(surface) && !is_placeholder(surface))) &&
         qemu_console_get_width(s, -1) == width &&
         qemu_console_get_height(s, -1) == height) {
         return;
-- 
2.39.2



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

* [Stable-7.2.10 33/33] audio: Depend on dbus_display1_dep
  2024-02-21 21:46 [Stable-7.2.10 v0 00/33] Patch Round-up for stable 7.2.10, freeze on 2024-03-02 Michael Tokarev
                   ` (31 preceding siblings ...)
  2024-02-21 21:47 ` [Stable-7.2.10 32/33] ui/console: Fix console resize with placeholder surface Michael Tokarev
@ 2024-02-21 21:47 ` Michael Tokarev
  32 siblings, 0 replies; 34+ messages in thread
From: Michael Tokarev @ 2024-02-21 21:47 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-stable, Akihiko Odaki, Marc-André Lureau,
	Michael Tokarev

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

dbusaudio needs dbus_display1_dep.

Fixes: 739362d4205c ("audio: add "dbus" audio backend")
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20240214-dbus-v7-1-7eff29f04c34@daynix.com>
(cherry picked from commit d67611907590a1e6c998b7c5a5cb4394acf84329)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
(Mjt: fixup in audio/meson.build due to missing v8.0.0-2306-ga95a464777
 "audio: dbus requires pixman")

diff --git a/audio/meson.build b/audio/meson.build
index 34aed78342..ce171f710d 100644
--- a/audio/meson.build
+++ b/audio/meson.build
@@ -29,7 +29,8 @@ endforeach
 
 if dbus_display
     module_ss = ss.source_set()
-    module_ss.add(when: gio, if_true: files('dbusaudio.c'))
+    module_ss.add(when: [gio, dbus_display1_dep],
+                  if_true: files('dbusaudio.c'))
     audio_modules += {'dbus': module_ss}
 endif
 
-- 
2.39.2



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

end of thread, other threads:[~2024-02-21 21:52 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-21 21:46 [Stable-7.2.10 v0 00/33] Patch Round-up for stable 7.2.10, freeze on 2024-03-02 Michael Tokarev
2024-02-21 21:46 ` [Stable-7.2.10 01/33] migration: Fix use-after-free of migration state object Michael Tokarev
2024-02-21 21:46 ` [Stable-7.2.10 02/33] qemu-docs: Update options for graphical frontends Michael Tokarev
2024-02-21 21:46 ` [Stable-7.2.10 03/33] block/blkio: Make s->mem_region_alignment be 64 bits Michael Tokarev
2024-02-21 21:46 ` [Stable-7.2.10 04/33] target/arm: fix exception syndrome for AArch32 bkpt insn Michael Tokarev
2024-02-21 21:46 ` [Stable-7.2.10 05/33] system/vl.c: Fix handling of '-serial none -serial something' Michael Tokarev
2024-02-21 21:46 ` [Stable-7.2.10 06/33] qemu-options.hx: Improve -serial option documentation Michael Tokarev
2024-02-21 21:46 ` [Stable-7.2.10 07/33] pci-host: designware: Limit value range of iATU viewport register Michael Tokarev
2024-02-21 21:46 ` [Stable-7.2.10 08/33] hw/smbios: Fix OEM strings table option validation Michael Tokarev
2024-02-21 21:46 ` [Stable-7.2.10 09/33] hw/smbios: Fix port connector " Michael Tokarev
2024-02-21 21:46 ` [Stable-7.2.10 10/33] vhost-user.rst: Fix vring address description Michael Tokarev
2024-02-21 21:46 ` [Stable-7.2.10 11/33] cxl/cdat: Handle cdat table build errors Michael Tokarev
2024-02-21 21:46 ` [Stable-7.2.10 12/33] cxl/cdat: Fix header sum value in CDAT checksum Michael Tokarev
2024-02-21 21:46 ` [Stable-7.2.10 13/33] hw/cxl: Pass CXLComponentState to cache_mem_ops Michael Tokarev
2024-02-21 21:46 ` [Stable-7.2.10 14/33] virtio_iommu: Clear IOMMUPciBus pointer cache when system reset Michael Tokarev
2024-02-21 21:46 ` [Stable-7.2.10 15/33] smmu: Clear SMMUPciBus " Michael Tokarev
2024-02-21 21:46 ` [Stable-7.2.10 16/33] tests/acpi: Allow update of DSDT.cxl Michael Tokarev
2024-02-21 21:47 ` [Stable-7.2.10 17/33] hw/i386: Fix _STA return value for ACPI0017 Michael Tokarev
2024-02-21 21:47 ` [Stable-7.2.10 18/33] tests/acpi: Update DSDT.cxl to reflect change _STA return value Michael Tokarev
2024-02-21 21:47 ` [Stable-7.2.10 19/33] linux-user/aarch64: Choose SYNC as the preferred MTE mode Michael Tokarev
2024-02-21 21:47 ` [Stable-7.2.10 20/33] target/arm: Fix nregs computation in do_{ld, st}_zpa Michael Tokarev
2024-02-21 21:47 ` [Stable-7.2.10 21/33] target/arm: Fix SVE/SME gross MTE suppression checks Michael Tokarev
2024-02-21 21:47 ` [Stable-7.2.10 22/33] target/arm: Don't get MDCR_EL2 in pmu_counter_enabled() before checking ARM_FEATURE_PMU Michael Tokarev
2024-02-21 21:47 ` [Stable-7.2.10 23/33] iotests: Make 144 deterministic again Michael Tokarev
2024-02-21 21:47 ` [Stable-7.2.10 24/33] i386/cpu: Clear FEAT_XSAVE_XSS_LO/HI leafs when CPUID_EXT_XSAVE is not available Michael Tokarev
2024-02-21 21:47 ` [Stable-7.2.10 25/33] i386/cpu: Mask with XCR0/XSS mask for FEAT_XSAVE_XCR0_HI and FEAT_XSAVE_XSS_HI leafs Michael Tokarev
2024-02-21 21:47 ` [Stable-7.2.10 26/33] i386/cpuid: Decrease cpuid_i when skipping CPUID leaf 1F Michael Tokarev
2024-02-21 21:47 ` [Stable-7.2.10 27/33] i386/cpuid: Move leaf 7 to correct group Michael Tokarev
2024-02-21 21:47 ` [Stable-7.2.10 28/33] target/i386: Generate an illegal opcode exception on cmp instructions with lock prefix Michael Tokarev
2024-02-21 21:47 ` [Stable-7.2.10 29/33] ui: reject extended clipboard message if not activated Michael Tokarev
2024-02-21 21:47 ` [Stable-7.2.10 30/33] ui/clipboard: mark type as not available when there is no data Michael Tokarev
2024-02-21 21:47 ` [Stable-7.2.10 31/33] ui/clipboard: add asserts for update and request Michael Tokarev
2024-02-21 21:47 ` [Stable-7.2.10 32/33] ui/console: Fix console resize with placeholder surface Michael Tokarev
2024-02-21 21:47 ` [Stable-7.2.10 33/33] audio: Depend on dbus_display1_dep Michael Tokarev

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