diff mbox series

[26/31] vdpa: Clear VHOST_VRING_F_LOG at vhost_vdpa_set_vring_addr in SVQ

Message ID 20220121202733.404989-27-eperezma@redhat.com (mailing list archive)
State New, archived
Headers show
Series vDPA shadow virtqueue | expand

Commit Message

Eugenio Perez Martin Jan. 21, 2022, 8:27 p.m. UTC
Doing so would cause the device to export writes to SVQ addresses, which
are not part of the guest's IOVA.

Like the previous patch, this is currently not possible since SVQ does
not run if the device exports VHOST_VRING_F_LOG. But it's needed to
enable migration with SVQ.

Signed-off-by: Eugenio PĂ©rez <eperezma@redhat.com>
---
 hw/virtio/vhost-vdpa.c | 6 ++++++
 1 file changed, 6 insertions(+)
diff mbox series

Patch

diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
index 887857c177..ab729b3371 100644
--- a/hw/virtio/vhost-vdpa.c
+++ b/hw/virtio/vhost-vdpa.c
@@ -660,10 +660,16 @@  static int vhost_vdpa_set_log_base(struct vhost_dev *dev, uint64_t base,
 static int vhost_vdpa_set_vring_addr(struct vhost_dev *dev,
                                        struct vhost_vring_addr *addr)
 {
+    struct vhost_vdpa *v = dev->opaque;
+
     trace_vhost_vdpa_set_vring_addr(dev, addr->index, addr->flags,
                                     addr->desc_user_addr, addr->used_user_addr,
                                     addr->avail_user_addr,
                                     addr->log_guest_addr);
+
+    if (v->shadow_vqs_enabled) {
+        addr->flags &= ~BIT_ULL(VHOST_VRING_F_LOG);
+    }
     return vhost_vdpa_call(dev, VHOST_SET_VRING_ADDR, addr);
 }