[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Stable-7.2.5 39/44] vdpa: Return -EIO if device ack is VIRTIO_NET_ERR i
From: |
Michael Tokarev |
Subject: |
[Stable-7.2.5 39/44] vdpa: Return -EIO if device ack is VIRTIO_NET_ERR in _load_mac() |
Date: |
Sat, 5 Aug 2023 22:38:02 +0300 |
From: Hawkins Jiawei <yin31149@gmail.com>
According to VirtIO standard, "The class, command and
command-specific-data are set by the driver,
and the device sets the ack byte.
There is little it can do except issue a diagnostic
if ack is not VIRTIO_NET_OK."
Therefore, QEMU should stop sending the queued SVQ commands and
cancel the device startup if the device's ack is not VIRTIO_NET_OK.
Yet the problem is that, vhost_vdpa_net_load_mac() returns 1 based on
`*s->status != VIRTIO_NET_OK` when the device's ack is VIRTIO_NET_ERR.
As a result, net->nc->info->load() also returns 1, this makes
vhost_net_start_one() incorrectly assume the device state is
successfully loaded by vhost_vdpa_net_load() and return 0, instead of
goto `fail` label to cancel the device startup, as vhost_net_start_one()
only cancels the device startup when net->nc->info->load() returns a
negative value.
This patch fixes this problem by returning -EIO when the device's
ack is not VIRTIO_NET_OK.
Fixes: f73c0c43ac ("vdpa: extract vhost_vdpa_net_load_mac from
vhost_vdpa_net_load")
Signed-off-by: Hawkins Jiawei <yin31149@gmail.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Acked-by: Eugenio Pérez <eperezma@redhat.com>
Message-Id:
<a21731518644abbd0c495c5b7960527c5911f80d.1688438055.git.yin31149@gmail.com>
Tested-by: Lei Yang <leiyang@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit b479bc3c9d5e473553137641fd31069c251f0d6e)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
index 3a6cbc47bb..2c3a9e138f 100644
--- a/net/vhost-vdpa.c
+++ b/net/vhost-vdpa.c
@@ -403,8 +403,9 @@ static int vhost_vdpa_net_load_mac(VhostVDPAState *s, const
VirtIONet *n)
if (unlikely(dev_written < 0)) {
return dev_written;
}
-
- return *s->status != VIRTIO_NET_OK;
+ if (*s->status != VIRTIO_NET_OK) {
+ return -EIO;
+ }
}
return 0;
--
2.39.2
- [Stable-7.2.5 00/44] Patch Round-up for stable 7.2.5, freeze on 2023-08-05, Michael Tokarev, 2023/08/05
- [Stable-7.2.5 37/44] vfio/pci: Disable INTx in vfio_realize error path, Michael Tokarev, 2023/08/05
- [Stable-7.2.5 38/44] vdpa: Fix possible use-after-free for VirtQueueElement, Michael Tokarev, 2023/08/05
- [Stable-7.2.5 39/44] vdpa: Return -EIO if device ack is VIRTIO_NET_ERR in _load_mac(),
Michael Tokarev <=
- [Stable-7.2.5 40/44] vdpa: Return -EIO if device ack is VIRTIO_NET_ERR in _load_mq(), Michael Tokarev, 2023/08/05
- [Stable-7.2.5 41/44] target/ppc: Implement ASDR register for ISA v3.0 for HPT, Michael Tokarev, 2023/08/05
- [Stable-7.2.5 42/44] target/ppc: Fix pending HDEC when entering PM state, Michael Tokarev, 2023/08/05
- [Stable-7.2.5 43/44] target/ppc: Fix VRMA page size for ISA v3.0, Michael Tokarev, 2023/08/05
- [Stable-7.2.5 44/44] target/i386: Check CR0.TS before enter_mmx, Michael Tokarev, 2023/08/05