Skip to content

Commit 30387cf

Browse files
author
Herton R. Krzesinski
committed
Merge: vhost/net: Clear the pending messages when the backend is removed
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/1999 Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2093791 Upstream: Yes Test: multiple VM resets featuring virtio-iommu + vhost 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: 6b1e6cc ("vhost: new device IOTLB API") Message-Id: <20230117151518.44725-3-eric.auger@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> (cherry picked from commit 9526f9a) Signed-off-by: Eric Auger <eric.auger@redhat.com> Approved-by: MST <mst@redhat.com> Approved-by: Laurent Vivier <lvivier@redhat.com> Signed-off-by: Herton R. Krzesinski <herton@redhat.com>
2 parents 9170382 + 886424c commit 30387cf

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

drivers/vhost/net.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1523,6 +1523,9 @@ static long vhost_net_set_backend(struct vhost_net *n, unsigned index, int fd)
15231523
nvq = &n->vqs[index];
15241524
mutex_lock(&vq->mutex);
15251525

1526+
if (fd == -1)
1527+
vhost_clear_msg(&n->dev);
1528+
15261529
/* Verify that ring has been setup correctly. */
15271530
if (!vhost_vq_access_ok(vq)) {
15281531
r = -EFAULT;

drivers/vhost/vhost.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ void vhost_dev_stop(struct vhost_dev *dev)
669669
}
670670
EXPORT_SYMBOL_GPL(vhost_dev_stop);
671671

672-
static void vhost_clear_msg(struct vhost_dev *dev)
672+
void vhost_clear_msg(struct vhost_dev *dev)
673673
{
674674
struct vhost_msg_node *node, *n;
675675

@@ -687,6 +687,7 @@ static void vhost_clear_msg(struct vhost_dev *dev)
687687

688688
spin_unlock(&dev->iotlb_lock);
689689
}
690+
EXPORT_SYMBOL_GPL(vhost_clear_msg);
690691

691692
void vhost_dev_cleanup(struct vhost_dev *dev)
692693
{

drivers/vhost/vhost.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ long vhost_dev_ioctl(struct vhost_dev *, unsigned int ioctl, void __user *argp);
182182
long vhost_vring_ioctl(struct vhost_dev *d, unsigned int ioctl, void __user *argp);
183183
bool vhost_vq_access_ok(struct vhost_virtqueue *vq);
184184
bool vhost_log_access_ok(struct vhost_dev *);
185+
void vhost_clear_msg(struct vhost_dev *dev);
185186

186187
int vhost_get_vq_desc(struct vhost_virtqueue *,
187188
struct iovec iov[], unsigned int iov_count,

0 commit comments

Comments
 (0)