summaryrefslogtreecommitdiffstats
path: root/drivers/vhost/net.c
diff options
context:
space:
mode:
authorEric Auger <eric.auger@redhat.com>2023-01-17 10:15:18 -0500
committerMichael S. Tsirkin <mst@redhat.com>2023-01-27 06:18:41 -0500
commit9526f9a2b762af16be94a72aca5d65c677d28f50 (patch)
tree867ef7feabc780255ac03d53f2afc3b036513fdd /drivers/vhost/net.c
parent2241ab53cbb5cdb08a6b2d4688feb13971058f65 (diff)
downloadlinux-9526f9a2b762af16be94a72aca5d65c677d28f50.tar.gz
linux-9526f9a2b762af16be94a72aca5d65c677d28f50.tar.bz2
linux-9526f9a2b762af16be94a72aca5d65c677d28f50.zip
vhost/net: Clear the pending messages when the backend is removed
When the vhost iotlb is used along with a guest virtual iommu and the guest gets rebooted, some MISS messages may have been recorded just before the reboot and spuriously executed by the virtual iommu after the reboot. As vhost does not have any explicit reset user API, VHOST_NET_SET_BACKEND looks a reasonable point where to clear the pending messages, in case the backend is removed. Export vhost_clear_msg() and call it in vhost_net_set_backend() when fd == -1. Signed-off-by: Eric Auger <eric.auger@redhat.com> Suggested-by: Jason Wang <jasowang@redhat.com> Fixes: 6b1e6cc7855b0 ("vhost: new device IOTLB API") Message-Id: <20230117151518.44725-3-eric.auger@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'drivers/vhost/net.c')
-rw-r--r--drivers/vhost/net.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
index 9af19b0cf3b7..4c538b30fd76 100644
--- a/drivers/vhost/net.c
+++ b/drivers/vhost/net.c
@@ -1511,6 +1511,9 @@ static long vhost_net_set_backend(struct vhost_net *n, unsigned index, int fd)
nvq = &n->vqs[index];
mutex_lock(&vq->mutex);
+ if (fd == -1)
+ vhost_clear_msg(&n->dev);
+
/* Verify that ring has been setup correctly. */
if (!vhost_vq_access_ok(vq)) {
r = -EFAULT;