9ae3a8
From c518aac987c63baaf6f039589c043e3da966974e Mon Sep 17 00:00:00 2001
9ae3a8
From: Michael S. Tsirkin <mst@redhat.com>
9ae3a8
Date: Wed, 14 May 2014 08:34:08 +0200
9ae3a8
Subject: [PATCH 17/31] virtio: allow mapping up to max queue size
9ae3a8
9ae3a8
RH-Author: Michael S. Tsirkin <mst@redhat.com>
9ae3a8
Message-id: <1400056377-6802-2-git-send-email-mst@redhat.com>
9ae3a8
Patchwork-id: 58863
9ae3a8
O-Subject: [PATCH qemu-kvm RHEL7.1 2/2] virtio: allow mapping up to max queue size
9ae3a8
Bugzilla: 1095766
9ae3a8
RH-Acked-by: Dr. David Alan Gilbert (git) <dgilbert@redhat.com>
9ae3a8
RH-Acked-by: Xiao Wang <jasowang@redhat.com>
9ae3a8
RH-Acked-by: Amos Kong <akong@redhat.com>
9ae3a8
9ae3a8
It's a loop from i < num_sg  and the array is VIRTQUEUE_MAX_SIZE - so
9ae3a8
it's OK if the value read is VIRTQUEUE_MAX_SIZE.
9ae3a8
9ae3a8
Not a big problem in practice as people don't use
9ae3a8
such big queues, but it's inelegant.
9ae3a8
9ae3a8
Reported-by: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
9ae3a8
Cc: qemu-stable@nongnu.org
9ae3a8
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
9ae3a8
9ae3a8
Upstream status: 937251408051e0489f78e4db3c92e045b147b38b
9ae3a8
(in maintainer's tree, pull request sent)
9ae3a8
Tested: lightly on developer's box
9ae3a8
Brew build: http://brewweb.devel.redhat.com/brew/taskinfo?taskID=7452039
9ae3a8
Bugzilla:1095766
9ae3a8
---
9ae3a8
 hw/virtio/virtio.c | 2 +-
9ae3a8
 1 file changed, 1 insertion(+), 1 deletion(-)
9ae3a8
9ae3a8
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
---
9ae3a8
 hw/virtio/virtio.c |    2 +-
9ae3a8
 1 files changed, 1 insertions(+), 1 deletions(-)
9ae3a8
9ae3a8
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
9ae3a8
index 2667390..44309c2 100644
9ae3a8
--- a/hw/virtio/virtio.c
9ae3a8
+++ b/hw/virtio/virtio.c
9ae3a8
@@ -423,7 +423,7 @@ void virtqueue_map_sg(struct iovec *sg, hwaddr *addr,
9ae3a8
     unsigned int i;
9ae3a8
     hwaddr len;
9ae3a8
 
9ae3a8
-    if (num_sg >= VIRTQUEUE_MAX_SIZE) {
9ae3a8
+    if (num_sg > VIRTQUEUE_MAX_SIZE) {
9ae3a8
         error_report("virtio: map attempt out of bounds: %zd > %d",
9ae3a8
                      num_sg, VIRTQUEUE_MAX_SIZE);
9ae3a8
         exit(1);
9ae3a8
-- 
9ae3a8
1.7.1
9ae3a8