All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/2] vdpa: Fix SIGSEGV on failed vdpa devices
@ 2021-11-25 10:16 Eugenio Pérez
  2021-11-25 10:16 ` [PATCH v2 1/2] vdpa: Add dummy receive callback Eugenio Pérez
  2021-11-25 10:16 ` [PATCH v2 2/2] virtio-net: Fix log message Eugenio Pérez
  0 siblings, 2 replies; 7+ messages in thread
From: Eugenio Pérez @ 2021-11-25 10:16 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Jason Wang, qemu-stable, Cindy Lu, Michael S. Tsirkin

Qemu falls back on userland handlers even if vhost-user and vhost-vdpa
cases. These assumes a tap device can handle the packets.

If a vdpa device fail to start, it can trigger a sigsegv because of
that. Add dummy receivers that return no progress so it can keep
running.

Tested with a modified version of vp_vdpa to fail negotiation.

v2:
* Replace dummy receive_{iov,raw} with receive callback.
* Delete fix indentation commit, we don't touch that code anymore.

Eugenio Pérez (2):
  vdpa: Add dummy receive callback
  virtio-net: Fix log message

 hw/net/virtio-net.c | 11 ++++++-----
 net/vhost-vdpa.c    |  8 ++++++++
 2 files changed, 14 insertions(+), 5 deletions(-)

-- 
2.27.0




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

* [PATCH v2 1/2] vdpa: Add dummy receive callback
  2021-11-25 10:16 [PATCH v2 0/2] vdpa: Fix SIGSEGV on failed vdpa devices Eugenio Pérez
@ 2021-11-25 10:16 ` Eugenio Pérez
  2021-11-26  2:54   ` Jason Wang
  2021-11-25 10:16 ` [PATCH v2 2/2] virtio-net: Fix log message Eugenio Pérez
  1 sibling, 1 reply; 7+ messages in thread
From: Eugenio Pérez @ 2021-11-25 10:16 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Jason Wang, qemu-stable, Cindy Lu, Michael S. Tsirkin

Qemu falls back on userland handlers even if vhost-user and vhost-vdpa
cases. These assumes a tap device can handle the packets.

If a vdpa device fail to start, it can trigger a sigsegv because of
that. Add dummy receiver that returns no progress so it can keep
running.

Fixes: 1e0a84ea49 ("vhost-vdpa: introduce vhost-vdpa net client")
Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
---
 net/vhost-vdpa.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
index 2e3c22a8c7..25dd6dd975 100644
--- a/net/vhost-vdpa.c
+++ b/net/vhost-vdpa.c
@@ -170,9 +170,17 @@ static bool vhost_vdpa_check_peer_type(NetClientState *nc, ObjectClass *oc,
     return true;
 }
 
+/** Dummy receive in case qemu falls back to userland tap networking */
+static ssize_t vhost_vdpa_receive(NetClientState *nc, const uint8_t *buf,
+                                  size_t size)
+{
+    return 0;
+}
+
 static NetClientInfo net_vhost_vdpa_info = {
         .type = NET_CLIENT_DRIVER_VHOST_VDPA,
         .size = sizeof(VhostVDPAState),
+        .receive = vhost_vdpa_receive,
         .cleanup = vhost_vdpa_cleanup,
         .has_vnet_hdr = vhost_vdpa_has_vnet_hdr,
         .has_ufo = vhost_vdpa_has_ufo,
-- 
2.27.0



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

* [PATCH v2 2/2] virtio-net: Fix log message
  2021-11-25 10:16 [PATCH v2 0/2] vdpa: Fix SIGSEGV on failed vdpa devices Eugenio Pérez
  2021-11-25 10:16 ` [PATCH v2 1/2] vdpa: Add dummy receive callback Eugenio Pérez
@ 2021-11-25 10:16 ` Eugenio Pérez
  2021-11-26  2:54   ` Jason Wang
  1 sibling, 1 reply; 7+ messages in thread
From: Eugenio Pérez @ 2021-11-25 10:16 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Jason Wang, qemu-stable, Cindy Lu, Michael S. Tsirkin

The message has never been true in the case of non tap networking, so
only tell that userland networking will be used if possible.

Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
---
 hw/net/virtio-net.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index f2014d5ea0..d6c98c3c2d 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -245,6 +245,7 @@ static void virtio_net_vhost_status(VirtIONet *n, uint8_t status)
     NetClientState *nc = qemu_get_queue(n->nic);
     int queue_pairs = n->multiqueue ? n->max_queue_pairs : 1;
     int cvq = n->max_ncs - n->max_queue_pairs;
+    bool tap_backend = nc->peer->info->type == NET_CLIENT_DRIVER_TAP;
 
     if (!get_vhost_net(nc->peer)) {
         return;
@@ -258,9 +259,9 @@ static void virtio_net_vhost_status(VirtIONet *n, uint8_t status)
         int r, i;
 
         if (n->needs_vnet_hdr_swap) {
-            error_report("backend does not support %s vnet headers; "
-                         "falling back on userspace virtio",
-                         virtio_is_big_endian(vdev) ? "BE" : "LE");
+            error_report("backend does not support %s vnet headers%s",
+                    virtio_is_big_endian(vdev) ? "BE" : "LE",
+                    tap_backend ? "; falling back on userspace virtio" : "");
             return;
         }
 
@@ -288,8 +289,8 @@ static void virtio_net_vhost_status(VirtIONet *n, uint8_t status)
         n->vhost_started = 1;
         r = vhost_net_start(vdev, n->nic->ncs, queue_pairs, cvq);
         if (r < 0) {
-            error_report("unable to start vhost net: %d: "
-                         "falling back on userspace virtio", -r);
+            error_report("unable to start vhost net: %d%s", -r,
+                       tap_backend ? " falling back on userspace virtio" : "");
             n->vhost_started = 0;
         }
     } else {
-- 
2.27.0



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

* Re: [PATCH v2 1/2] vdpa: Add dummy receive callback
  2021-11-25 10:16 ` [PATCH v2 1/2] vdpa: Add dummy receive callback Eugenio Pérez
@ 2021-11-26  2:54   ` Jason Wang
  0 siblings, 0 replies; 7+ messages in thread
From: Jason Wang @ 2021-11-26  2:54 UTC (permalink / raw)
  To: Eugenio Pérez
  Cc: Laurent Vivier, Michael S. Tsirkin, qemu-devel, Cindy Lu, qemu-stable

On Thu, Nov 25, 2021 at 6:16 PM Eugenio Pérez <eperezma@redhat.com> wrote:
>
> Qemu falls back on userland handlers even if vhost-user and vhost-vdpa
> cases. These assumes a tap device can handle the packets.
>
> If a vdpa device fail to start, it can trigger a sigsegv because of
> that. Add dummy receiver that returns no progress so it can keep
> running.
>
> Fixes: 1e0a84ea49 ("vhost-vdpa: introduce vhost-vdpa net client")
> Signed-off-by: Eugenio Pérez <eperezma@redhat.com>

Acked-by: Jason Wang <jasowang@redhat.com>

> ---
>  net/vhost-vdpa.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
>
> diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
> index 2e3c22a8c7..25dd6dd975 100644
> --- a/net/vhost-vdpa.c
> +++ b/net/vhost-vdpa.c
> @@ -170,9 +170,17 @@ static bool vhost_vdpa_check_peer_type(NetClientState *nc, ObjectClass *oc,
>      return true;
>  }
>
> +/** Dummy receive in case qemu falls back to userland tap networking */
> +static ssize_t vhost_vdpa_receive(NetClientState *nc, const uint8_t *buf,
> +                                  size_t size)
> +{
> +    return 0;
> +}
> +
>  static NetClientInfo net_vhost_vdpa_info = {
>          .type = NET_CLIENT_DRIVER_VHOST_VDPA,
>          .size = sizeof(VhostVDPAState),
> +        .receive = vhost_vdpa_receive,
>          .cleanup = vhost_vdpa_cleanup,
>          .has_vnet_hdr = vhost_vdpa_has_vnet_hdr,
>          .has_ufo = vhost_vdpa_has_ufo,
> --
> 2.27.0
>



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

* Re: [PATCH v2 2/2] virtio-net: Fix log message
  2021-11-25 10:16 ` [PATCH v2 2/2] virtio-net: Fix log message Eugenio Pérez
@ 2021-11-26  2:54   ` Jason Wang
  2021-11-29 13:43     ` Michael S. Tsirkin
  0 siblings, 1 reply; 7+ messages in thread
From: Jason Wang @ 2021-11-26  2:54 UTC (permalink / raw)
  To: Eugenio Pérez
  Cc: Laurent Vivier, Michael S. Tsirkin, qemu-devel, Cindy Lu, qemu-stable

On Thu, Nov 25, 2021 at 6:16 PM Eugenio Pérez <eperezma@redhat.com> wrote:
>
> The message has never been true in the case of non tap networking, so
> only tell that userland networking will be used if possible.
>
> Signed-off-by: Eugenio Pérez <eperezma@redhat.com>

Acked-by: Jason Wang <jasowang@redhat.com>

> ---
>  hw/net/virtio-net.c | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
>
> diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
> index f2014d5ea0..d6c98c3c2d 100644
> --- a/hw/net/virtio-net.c
> +++ b/hw/net/virtio-net.c
> @@ -245,6 +245,7 @@ static void virtio_net_vhost_status(VirtIONet *n, uint8_t status)
>      NetClientState *nc = qemu_get_queue(n->nic);
>      int queue_pairs = n->multiqueue ? n->max_queue_pairs : 1;
>      int cvq = n->max_ncs - n->max_queue_pairs;
> +    bool tap_backend = nc->peer->info->type == NET_CLIENT_DRIVER_TAP;
>
>      if (!get_vhost_net(nc->peer)) {
>          return;
> @@ -258,9 +259,9 @@ static void virtio_net_vhost_status(VirtIONet *n, uint8_t status)
>          int r, i;
>
>          if (n->needs_vnet_hdr_swap) {
> -            error_report("backend does not support %s vnet headers; "
> -                         "falling back on userspace virtio",
> -                         virtio_is_big_endian(vdev) ? "BE" : "LE");
> +            error_report("backend does not support %s vnet headers%s",
> +                    virtio_is_big_endian(vdev) ? "BE" : "LE",
> +                    tap_backend ? "; falling back on userspace virtio" : "");
>              return;
>          }
>
> @@ -288,8 +289,8 @@ static void virtio_net_vhost_status(VirtIONet *n, uint8_t status)
>          n->vhost_started = 1;
>          r = vhost_net_start(vdev, n->nic->ncs, queue_pairs, cvq);
>          if (r < 0) {
> -            error_report("unable to start vhost net: %d: "
> -                         "falling back on userspace virtio", -r);
> +            error_report("unable to start vhost net: %d%s", -r,
> +                       tap_backend ? " falling back on userspace virtio" : "");
>              n->vhost_started = 0;
>          }
>      } else {
> --
> 2.27.0
>



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

* Re: [PATCH v2 2/2] virtio-net: Fix log message
  2021-11-26  2:54   ` Jason Wang
@ 2021-11-29 13:43     ` Michael S. Tsirkin
  2021-11-29 14:56       ` Eugenio Perez Martin
  0 siblings, 1 reply; 7+ messages in thread
From: Michael S. Tsirkin @ 2021-11-29 13:43 UTC (permalink / raw)
  To: Jason Wang
  Cc: Laurent Vivier, Eugenio Pérez, qemu-devel, Cindy Lu, qemu-stable

On Fri, Nov 26, 2021 at 10:54:32AM +0800, Jason Wang wrote:
> On Thu, Nov 25, 2021 at 6:16 PM Eugenio Pérez <eperezma@redhat.com> wrote:
> >
> > The message has never been true in the case of non tap networking, so
> > only tell that userland networking will be used if possible.
> >
> > Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
> 
> Acked-by: Jason Wang <jasowang@redhat.com>

Breaks make check. I suspect it's called without a peer or something.

Dropped for 6.2.

> > ---
> >  hw/net/virtio-net.c | 11 ++++++-----
> >  1 file changed, 6 insertions(+), 5 deletions(-)
> >
> > diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
> > index f2014d5ea0..d6c98c3c2d 100644
> > --- a/hw/net/virtio-net.c
> > +++ b/hw/net/virtio-net.c
> > @@ -245,6 +245,7 @@ static void virtio_net_vhost_status(VirtIONet *n, uint8_t status)
> >      NetClientState *nc = qemu_get_queue(n->nic);
> >      int queue_pairs = n->multiqueue ? n->max_queue_pairs : 1;
> >      int cvq = n->max_ncs - n->max_queue_pairs;
> > +    bool tap_backend = nc->peer->info->type == NET_CLIENT_DRIVER_TAP;
> >
> >      if (!get_vhost_net(nc->peer)) {
> >          return;
> > @@ -258,9 +259,9 @@ static void virtio_net_vhost_status(VirtIONet *n, uint8_t status)
> >          int r, i;
> >
> >          if (n->needs_vnet_hdr_swap) {
> > -            error_report("backend does not support %s vnet headers; "
> > -                         "falling back on userspace virtio",
> > -                         virtio_is_big_endian(vdev) ? "BE" : "LE");
> > +            error_report("backend does not support %s vnet headers%s",
> > +                    virtio_is_big_endian(vdev) ? "BE" : "LE",
> > +                    tap_backend ? "; falling back on userspace virtio" : "");
> >              return;
> >          }
> >
> > @@ -288,8 +289,8 @@ static void virtio_net_vhost_status(VirtIONet *n, uint8_t status)
> >          n->vhost_started = 1;
> >          r = vhost_net_start(vdev, n->nic->ncs, queue_pairs, cvq);
> >          if (r < 0) {
> > -            error_report("unable to start vhost net: %d: "
> > -                         "falling back on userspace virtio", -r);
> > +            error_report("unable to start vhost net: %d%s", -r,
> > +                       tap_backend ? " falling back on userspace virtio" : "");
> >              n->vhost_started = 0;
> >          }
> >      } else {
> > --
> > 2.27.0
> >



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

* Re: [PATCH v2 2/2] virtio-net: Fix log message
  2021-11-29 13:43     ` Michael S. Tsirkin
@ 2021-11-29 14:56       ` Eugenio Perez Martin
  0 siblings, 0 replies; 7+ messages in thread
From: Eugenio Perez Martin @ 2021-11-29 14:56 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: Laurent Vivier, Jason Wang, qemu-devel, Cindy Lu, qemu-stable

On Mon, Nov 29, 2021 at 2:43 PM Michael S. Tsirkin <mst@redhat.com> wrote:
>
> On Fri, Nov 26, 2021 at 10:54:32AM +0800, Jason Wang wrote:
> > On Thu, Nov 25, 2021 at 6:16 PM Eugenio Pérez <eperezma@redhat.com> wrote:
> > >
> > > The message has never been true in the case of non tap networking, so
> > > only tell that userland networking will be used if possible.
> > >
> > > Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
> >
> > Acked-by: Jason Wang <jasowang@redhat.com>
>
> Breaks make check. I suspect it's called without a peer or something.
>

You're right, sending it as a separate patch since I saw the other one
made it into the pull request.

Thanks!

> Dropped for 6.2.
>
> > > ---
> > >  hw/net/virtio-net.c | 11 ++++++-----
> > >  1 file changed, 6 insertions(+), 5 deletions(-)
> > >
> > > diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
> > > index f2014d5ea0..d6c98c3c2d 100644
> > > --- a/hw/net/virtio-net.c
> > > +++ b/hw/net/virtio-net.c
> > > @@ -245,6 +245,7 @@ static void virtio_net_vhost_status(VirtIONet *n, uint8_t status)
> > >      NetClientState *nc = qemu_get_queue(n->nic);
> > >      int queue_pairs = n->multiqueue ? n->max_queue_pairs : 1;
> > >      int cvq = n->max_ncs - n->max_queue_pairs;
> > > +    bool tap_backend = nc->peer->info->type == NET_CLIENT_DRIVER_TAP;
> > >
> > >      if (!get_vhost_net(nc->peer)) {
> > >          return;
> > > @@ -258,9 +259,9 @@ static void virtio_net_vhost_status(VirtIONet *n, uint8_t status)
> > >          int r, i;
> > >
> > >          if (n->needs_vnet_hdr_swap) {
> > > -            error_report("backend does not support %s vnet headers; "
> > > -                         "falling back on userspace virtio",
> > > -                         virtio_is_big_endian(vdev) ? "BE" : "LE");
> > > +            error_report("backend does not support %s vnet headers%s",
> > > +                    virtio_is_big_endian(vdev) ? "BE" : "LE",
> > > +                    tap_backend ? "; falling back on userspace virtio" : "");
> > >              return;
> > >          }
> > >
> > > @@ -288,8 +289,8 @@ static void virtio_net_vhost_status(VirtIONet *n, uint8_t status)
> > >          n->vhost_started = 1;
> > >          r = vhost_net_start(vdev, n->nic->ncs, queue_pairs, cvq);
> > >          if (r < 0) {
> > > -            error_report("unable to start vhost net: %d: "
> > > -                         "falling back on userspace virtio", -r);
> > > +            error_report("unable to start vhost net: %d%s", -r,
> > > +                       tap_backend ? " falling back on userspace virtio" : "");
> > >              n->vhost_started = 0;
> > >          }
> > >      } else {
> > > --
> > > 2.27.0
> > >
>



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

end of thread, other threads:[~2021-11-29 14:59 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-25 10:16 [PATCH v2 0/2] vdpa: Fix SIGSEGV on failed vdpa devices Eugenio Pérez
2021-11-25 10:16 ` [PATCH v2 1/2] vdpa: Add dummy receive callback Eugenio Pérez
2021-11-26  2:54   ` Jason Wang
2021-11-25 10:16 ` [PATCH v2 2/2] virtio-net: Fix log message Eugenio Pérez
2021-11-26  2:54   ` Jason Wang
2021-11-29 13:43     ` Michael S. Tsirkin
2021-11-29 14:56       ` Eugenio Perez Martin

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