summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorEugenio Pérez <eperezma@redhat.com>2022-05-12 19:57:44 +0200
committerMichael S. Tsirkin <mst@redhat.com>2022-05-13 07:57:26 -0400
commit639036477ef890958415967e753ca2cbb348c16c (patch)
treee839c7ed99cb7a72199c46556957b092477e18c5
parent81abfa5724c9a6502d7a1d3a67c55f2a303a1170 (diff)
downloadfocaccia-qemu-639036477ef890958415967e753ca2cbb348c16c.tar.gz
focaccia-qemu-639036477ef890958415967e753ca2cbb348c16c.zip
vdpa: Fix bad index calculus at vhost_vdpa_get_vring_base
Fixes: 6d0b222666 ("vdpa: Adapt vhost_vdpa_get_vring_base to SVQ")

Acked-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
Message-Id: <20220512175747.142058-4-eperezma@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
-rw-r--r--hw/virtio/vhost-vdpa.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
index a30510ed17..493269b0b5 100644
--- a/hw/virtio/vhost-vdpa.c
+++ b/hw/virtio/vhost-vdpa.c
@@ -1172,11 +1172,11 @@ static int vhost_vdpa_get_vring_base(struct vhost_dev *dev,
                                        struct vhost_vring_state *ring)
 {
     struct vhost_vdpa *v = dev->opaque;
+    int vdpa_idx = ring->index - dev->vq_index;
     int ret;
 
     if (v->shadow_vqs_enabled) {
-        VhostShadowVirtqueue *svq = g_ptr_array_index(v->shadow_vqs,
-                                                      ring->index);
+        VhostShadowVirtqueue *svq = g_ptr_array_index(v->shadow_vqs, vdpa_idx);
 
         /*
          * Setting base as last used idx, so destination will see as available