Blame SOURCES/kvm-vdpa-Fix-bad-index-calculus-at-vhost_vdpa_get_vring_.patch

586cba
From e19adb058502e24580dbc4f6f944cd951ca288ed Mon Sep 17 00:00:00 2001
586cba
From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= <eperezma@redhat.com>
586cba
Date: Thu, 12 May 2022 19:57:44 +0200
586cba
Subject: [PATCH 08/11] vdpa: Fix bad index calculus at
586cba
 vhost_vdpa_get_vring_base
586cba
MIME-Version: 1.0
586cba
Content-Type: text/plain; charset=UTF-8
586cba
Content-Transfer-Encoding: 8bit
586cba
586cba
RH-Author: Eugenio Pérez <eperezma@redhat.com>
586cba
RH-MergeRequest: 114: vdpa: Fix memory listener deletions of iova tree
586cba
RH-Commit: [1/4] 754fb8960684fa7a91bddb18c8df58c3b947ee75 (eperezmartin/qemu-kvm)
586cba
RH-Bugzilla: 2116876
586cba
RH-Acked-by: Jason Wang <jasowang@redhat.com>
586cba
RH-Acked-by: Cindy Lu <lulu@redhat.com>
586cba
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
586cba
586cba
Fixes: 6d0b222666 ("vdpa: Adapt vhost_vdpa_get_vring_base to SVQ")
586cba
586cba
Acked-by: Jason Wang <jasowang@redhat.com>
586cba
Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
586cba
Message-Id: <20220512175747.142058-4-eperezma@redhat.com>
586cba
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
586cba
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
586cba
(cherry picked from commit 639036477ef890958415967e753ca2cbb348c16c)
586cba
---
586cba
 hw/virtio/vhost-vdpa.c | 4 ++--
586cba
 1 file changed, 2 insertions(+), 2 deletions(-)
586cba
586cba
diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
586cba
index e3e5bce4bb..a7dfac530f 100644
586cba
--- a/hw/virtio/vhost-vdpa.c
586cba
+++ b/hw/virtio/vhost-vdpa.c
586cba
@@ -1193,11 +1193,11 @@ static int vhost_vdpa_get_vring_base(struct vhost_dev *dev,
586cba
                                        struct vhost_vring_state *ring)
586cba
 {
586cba
     struct vhost_vdpa *v = dev->opaque;
586cba
+    int vdpa_idx = ring->index - dev->vq_index;
586cba
     int ret;
586cba
 
586cba
     if (v->shadow_vqs_enabled) {
586cba
-        VhostShadowVirtqueue *svq = g_ptr_array_index(v->shadow_vqs,
586cba
-                                                      ring->index);
586cba
+        VhostShadowVirtqueue *svq = g_ptr_array_index(v->shadow_vqs, vdpa_idx);
586cba
 
586cba
         /*
586cba
          * Setting base as last used idx, so destination will see as available
586cba
-- 
586cba
2.31.1
586cba