qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PULL 0/3] virtio: regression fixes
@ 2024-08-20 11:01 Michael S. Tsirkin
  2024-08-20 11:01 ` [PULL 1/3] vhost: Add VIRTIO_NET_F_RSC_EXT to vhost feature bits Michael S. Tsirkin
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Michael S. Tsirkin @ 2024-08-20 11:01 UTC (permalink / raw)
  To: qemu-devel; +Cc: Peter Maydell

The following changes since commit 76277cf82f0e1123bd69ec59d22014b8f78485ec:

  Merge tag 'hw-misc-20240820' of https://github.com/philmd/qemu into staging (2024-08-20 09:17:41 +1000)

are available in the Git repository at:

  https://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git tags/for_upstream

for you to fetch changes up to a8e63ff289d137197ad7a701a587cc432872d798:

  virtio-pci: Fix the use of an uninitialized irqfd (2024-08-20 06:57:47 -0400)

----------------------------------------------------------------
virtio: regression fixes

3 small patches to make sure we don't ship regressions.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>

----------------------------------------------------------------
Akihiko Odaki (1):
      vhost: Add VIRTIO_NET_F_RSC_EXT to vhost feature bits

Cindy Lu (1):
      virtio-pci: Fix the use of an uninitialized irqfd

Volker Rümelin (1):
      hw/audio/virtio-snd: fix invalid param check

 hw/audio/virtio-snd.c  | 4 ++--
 hw/net/vhost_net.c     | 2 ++
 hw/virtio/virtio-pci.c | 3 +++
 net/vhost-vdpa.c       | 1 +
 4 files changed, 8 insertions(+), 2 deletions(-)



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

* [PULL 1/3] vhost: Add VIRTIO_NET_F_RSC_EXT to vhost feature bits
  2024-08-20 11:01 [PULL 0/3] virtio: regression fixes Michael S. Tsirkin
@ 2024-08-20 11:01 ` Michael S. Tsirkin
  2024-08-20 11:01 ` [PULL 2/3] hw/audio/virtio-snd: fix invalid param check Michael S. Tsirkin
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Michael S. Tsirkin @ 2024-08-20 11:01 UTC (permalink / raw)
  To: qemu-devel; +Cc: Peter Maydell, Akihiko Odaki, Jason Wang, Stefano Garzarella

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

VIRTIO_NET_F_RSC_EXT is implemented in the rx data path, which vhost
implements, so vhost needs to support the feature if it is ever to be
enabled with vhost. The feature must be disabled otherwise.

Fixes: 2974e916df87 ("virtio-net: support RSC v4/v6 tcp traffic for Windows HCK")
Reported-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
Message-Id: <20240802-rsc-v1-1-2b607bd2f555@daynix.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 hw/net/vhost_net.c | 2 ++
 net/vhost-vdpa.c   | 1 +
 2 files changed, 3 insertions(+)

diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
index a788e6937e..dedf9ad7c2 100644
--- a/hw/net/vhost_net.c
+++ b/hw/net/vhost_net.c
@@ -50,6 +50,7 @@ static const int kernel_feature_bits[] = {
     VIRTIO_F_RING_RESET,
     VIRTIO_F_IN_ORDER,
     VIRTIO_F_NOTIFICATION_DATA,
+    VIRTIO_NET_F_RSC_EXT,
     VIRTIO_NET_F_HASH_REPORT,
     VHOST_INVALID_FEATURE_BIT
 };
@@ -81,6 +82,7 @@ static const int user_feature_bits[] = {
     VIRTIO_F_RING_RESET,
     VIRTIO_F_IN_ORDER,
     VIRTIO_NET_F_RSS,
+    VIRTIO_NET_F_RSC_EXT,
     VIRTIO_NET_F_HASH_REPORT,
     VIRTIO_NET_F_GUEST_USO4,
     VIRTIO_NET_F_GUEST_USO6,
diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
index 03457ead66..46b02c50be 100644
--- a/net/vhost-vdpa.c
+++ b/net/vhost-vdpa.c
@@ -88,6 +88,7 @@ const int vdpa_feature_bits[] = {
     VIRTIO_NET_F_MQ,
     VIRTIO_NET_F_MRG_RXBUF,
     VIRTIO_NET_F_MTU,
+    VIRTIO_NET_F_RSC_EXT,
     VIRTIO_NET_F_RSS,
     VIRTIO_NET_F_STATUS,
     VIRTIO_RING_F_EVENT_IDX,
-- 
MST



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

* [PULL 2/3] hw/audio/virtio-snd: fix invalid param check
  2024-08-20 11:01 [PULL 0/3] virtio: regression fixes Michael S. Tsirkin
  2024-08-20 11:01 ` [PULL 1/3] vhost: Add VIRTIO_NET_F_RSC_EXT to vhost feature bits Michael S. Tsirkin
@ 2024-08-20 11:01 ` Michael S. Tsirkin
  2024-08-30  5:12   ` Volker Rümelin
  2024-08-20 11:01 ` [PULL 3/3] virtio-pci: Fix the use of an uninitialized irqfd Michael S. Tsirkin
  2024-08-20 22:46 ` [PULL 0/3] virtio: regression fixes Richard Henderson
  3 siblings, 1 reply; 6+ messages in thread
From: Michael S. Tsirkin @ 2024-08-20 11:01 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Volker Rümelin, Manos Pitsidianakis,
	Gerd Hoffmann

From: Volker Rümelin <vr_qemu@t-online.de>

Commit 9b6083465f ("virtio-snd: check for invalid param shift
operands") tries to prevent invalid parameters specified by the
guest. However, the code is not correct.

Change the code so that the parameters format and rate, which are
a bit numbers, are compared with the bit size of the data type.

Fixes: 9b6083465f ("virtio-snd: check for invalid param shift operands")
Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
Message-Id: <20240802071805.7123-1-vr_qemu@t-online.de>
Reviewed-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 hw/audio/virtio-snd.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/audio/virtio-snd.c b/hw/audio/virtio-snd.c
index e5196aa4bb..d1cf5eb445 100644
--- a/hw/audio/virtio-snd.c
+++ b/hw/audio/virtio-snd.c
@@ -282,12 +282,12 @@ uint32_t virtio_snd_set_pcm_params(VirtIOSound *s,
         error_report("Number of channels is not supported.");
         return cpu_to_le32(VIRTIO_SND_S_NOT_SUPP);
     }
-    if (BIT(params->format) > sizeof(supported_formats) ||
+    if (params->format >= sizeof(supported_formats) * BITS_PER_BYTE ||
         !(supported_formats & BIT(params->format))) {
         error_report("Stream format is not supported.");
         return cpu_to_le32(VIRTIO_SND_S_NOT_SUPP);
     }
-    if (BIT(params->rate) > sizeof(supported_rates) ||
+    if (params->rate >= sizeof(supported_rates) * BITS_PER_BYTE ||
         !(supported_rates & BIT(params->rate))) {
         error_report("Stream rate is not supported.");
         return cpu_to_le32(VIRTIO_SND_S_NOT_SUPP);
-- 
MST



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

* [PULL 3/3] virtio-pci: Fix the use of an uninitialized irqfd
  2024-08-20 11:01 [PULL 0/3] virtio: regression fixes Michael S. Tsirkin
  2024-08-20 11:01 ` [PULL 1/3] vhost: Add VIRTIO_NET_F_RSC_EXT to vhost feature bits Michael S. Tsirkin
  2024-08-20 11:01 ` [PULL 2/3] hw/audio/virtio-snd: fix invalid param check Michael S. Tsirkin
@ 2024-08-20 11:01 ` Michael S. Tsirkin
  2024-08-20 22:46 ` [PULL 0/3] virtio: regression fixes Richard Henderson
  3 siblings, 0 replies; 6+ messages in thread
From: Michael S. Tsirkin @ 2024-08-20 11:01 UTC (permalink / raw)
  To: qemu-devel; +Cc: Peter Maydell, Cindy Lu, qemu-stable, Jason Wang

From: Cindy Lu <lulu@redhat.com>

The crash was reported in MAC OS and NixOS, here is the link for this bug
https://gitlab.com/qemu-project/qemu/-/issues/2334
https://gitlab.com/qemu-project/qemu/-/issues/2321

In this bug, they are using the virtio_input device. The guest notifier was
not supported for this device, The function virtio_pci_set_guest_notifiers()
was not called, and the vector_irqfd was not initialized.

So the fix is adding the check for vector_irqfd in virtio_pci_get_notifier()

The function virtio_pci_get_notifier() can be used in various devices.
It could also be called when VIRTIO_CONFIG_S_DRIVER_OK is not set. In this situation,
the vector_irqfd being NULL is acceptable. We can allow the device continue to boot

If the vector_irqfd still hasn't been initialized after VIRTIO_CONFIG_S_DRIVER_OK
is set, it means that the function set_guest_notifiers was not called before the
driver started. This indicates that the device is not using the notifier.
At this point, we will let the check fail.

This fix is verified in vyatta,MacOS,NixOS,fedora system.

The bt tree for this bug is:
Thread 6 "CPU 0/KVM" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7c817be006c0 (LWP 1269146)]
kvm_virtio_pci_vq_vector_use () at ../qemu-9.0.0/hw/virtio/virtio-pci.c:817
817         if (irqfd->users == 0) {
(gdb) thread apply all bt
...
Thread 6 (Thread 0x7c817be006c0 (LWP 1269146) "CPU 0/KVM"):
0  kvm_virtio_pci_vq_vector_use () at ../qemu-9.0.0/hw/virtio/virtio-pci.c:817
1  kvm_virtio_pci_vector_use_one () at ../qemu-9.0.0/hw/virtio/virtio-pci.c:893
2  0x00005983657045e2 in memory_region_write_accessor () at ../qemu-9.0.0/system/memory.c:497
3  0x0000598365704ba6 in access_with_adjusted_size () at ../qemu-9.0.0/system/memory.c:573
4  0x0000598365705059 in memory_region_dispatch_write () at ../qemu-9.0.0/system/memory.c:1528
5  0x00005983659b8e1f in flatview_write_continue_step.isra.0 () at ../qemu-9.0.0/system/physmem.c:2713
6  0x000059836570ba7d in flatview_write_continue () at ../qemu-9.0.0/system/physmem.c:2743
7  flatview_write () at ../qemu-9.0.0/system/physmem.c:2774
8  0x000059836570bb76 in address_space_write () at ../qemu-9.0.0/system/physmem.c:2894
9  0x0000598365763afe in address_space_rw () at ../qemu-9.0.0/system/physmem.c:2904
10 kvm_cpu_exec () at ../qemu-9.0.0/accel/kvm/kvm-all.c:2917
11 0x000059836576656e in kvm_vcpu_thread_fn () at ../qemu-9.0.0/accel/kvm/kvm-accel-ops.c:50
12 0x0000598365926ca8 in qemu_thread_start () at ../qemu-9.0.0/util/qemu-thread-posix.c:541
13 0x00007c8185bcd1cf in ??? () at /usr/lib/libc.so.6
14 0x00007c8185c4e504 in clone () at /usr/lib/libc.so.6

Fixes: 2ce6cff94d ("virtio-pci: fix use of a released vector")
Cc: qemu-stable@nongnu.org
Signed-off-by: Cindy Lu <lulu@redhat.com>
Message-Id: <20240806093715.65105-1-lulu@redhat.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 hw/virtio/virtio-pci.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
index 9534730bba..524b63e5c7 100644
--- a/hw/virtio/virtio-pci.c
+++ b/hw/virtio/virtio-pci.c
@@ -866,6 +866,9 @@ static int virtio_pci_get_notifier(VirtIOPCIProxy *proxy, int queue_no,
     VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
     VirtQueue *vq;
 
+    if (!proxy->vector_irqfd && vdev->status & VIRTIO_CONFIG_S_DRIVER_OK)
+        return -1;
+
     if (queue_no == VIRTIO_CONFIG_IRQ_IDX) {
         *n = virtio_config_get_guest_notifier(vdev);
         *vector = vdev->config_vector;
-- 
MST



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

* Re: [PULL 0/3] virtio: regression fixes
  2024-08-20 11:01 [PULL 0/3] virtio: regression fixes Michael S. Tsirkin
                   ` (2 preceding siblings ...)
  2024-08-20 11:01 ` [PULL 3/3] virtio-pci: Fix the use of an uninitialized irqfd Michael S. Tsirkin
@ 2024-08-20 22:46 ` Richard Henderson
  3 siblings, 0 replies; 6+ messages in thread
From: Richard Henderson @ 2024-08-20 22:46 UTC (permalink / raw)
  To: Michael S. Tsirkin, qemu-devel; +Cc: Peter Maydell

On 8/20/24 21:01, Michael S. Tsirkin wrote:
> The following changes since commit 76277cf82f0e1123bd69ec59d22014b8f78485ec:
> 
>    Merge tag 'hw-misc-20240820' ofhttps://github.com/philmd/qemu into staging (2024-08-20 09:17:41 +1000)
> 
> are available in the Git repository at:
> 
>    https://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git tags/for_upstream
> 
> for you to fetch changes up to a8e63ff289d137197ad7a701a587cc432872d798:
> 
>    virtio-pci: Fix the use of an uninitialized irqfd (2024-08-20 06:57:47 -0400)
> 
> ----------------------------------------------------------------
> virtio: regression fixes
> 
> 3 small patches to make sure we don't ship regressions.


Applied, thanks.  Please update https://wiki.qemu.org/ChangeLog/9.1 as appropriate.

r~


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

* Re: [PULL 2/3] hw/audio/virtio-snd: fix invalid param check
  2024-08-20 11:01 ` [PULL 2/3] hw/audio/virtio-snd: fix invalid param check Michael S. Tsirkin
@ 2024-08-30  5:12   ` Volker Rümelin
  0 siblings, 0 replies; 6+ messages in thread
From: Volker Rümelin @ 2024-08-30  5:12 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-stable, Michael Tokarev

Cc: qemu-stable@nongnu.org

Without this patch, the virtio-sound device will not work in the next
QEMU stable-8.2 and stable-9.0 versions.

With best regards,
Volker

> From: Volker Rümelin <vr_qemu@t-online.de>
>
> Commit 9b6083465f ("virtio-snd: check for invalid param shift
> operands") tries to prevent invalid parameters specified by the
> guest. However, the code is not correct.
>
> Change the code so that the parameters format and rate, which are
> a bit numbers, are compared with the bit size of the data type.
>
> Fixes: 9b6083465f ("virtio-snd: check for invalid param shift operands")
> Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
> Message-Id: <20240802071805.7123-1-vr_qemu@t-online.de>
> Reviewed-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
> Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
>  hw/audio/virtio-snd.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/hw/audio/virtio-snd.c b/hw/audio/virtio-snd.c
> index e5196aa4bb..d1cf5eb445 100644
> --- a/hw/audio/virtio-snd.c
> +++ b/hw/audio/virtio-snd.c
> @@ -282,12 +282,12 @@ uint32_t virtio_snd_set_pcm_params(VirtIOSound *s,
>          error_report("Number of channels is not supported.");
>          return cpu_to_le32(VIRTIO_SND_S_NOT_SUPP);
>      }
> -    if (BIT(params->format) > sizeof(supported_formats) ||
> +    if (params->format >= sizeof(supported_formats) * BITS_PER_BYTE ||
>          !(supported_formats & BIT(params->format))) {
>          error_report("Stream format is not supported.");
>          return cpu_to_le32(VIRTIO_SND_S_NOT_SUPP);
>      }
> -    if (BIT(params->rate) > sizeof(supported_rates) ||
> +    if (params->rate >= sizeof(supported_rates) * BITS_PER_BYTE ||
>          !(supported_rates & BIT(params->rate))) {
>          error_report("Stream rate is not supported.");
>          return cpu_to_le32(VIRTIO_SND_S_NOT_SUPP);



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

end of thread, other threads:[~2024-08-30  5:13 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-20 11:01 [PULL 0/3] virtio: regression fixes Michael S. Tsirkin
2024-08-20 11:01 ` [PULL 1/3] vhost: Add VIRTIO_NET_F_RSC_EXT to vhost feature bits Michael S. Tsirkin
2024-08-20 11:01 ` [PULL 2/3] hw/audio/virtio-snd: fix invalid param check Michael S. Tsirkin
2024-08-30  5:12   ` Volker Rümelin
2024-08-20 11:01 ` [PULL 3/3] virtio-pci: Fix the use of an uninitialized irqfd Michael S. Tsirkin
2024-08-20 22:46 ` [PULL 0/3] virtio: regression fixes Richard Henderson

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).