qemu-kvm/kvm-virtio-add-ability-to-delete-vq-through-a-pointer.patch
Danilo C. L. de Paula 77ffa9e8e9 * Sun Feb 23 2020 Danilo Cesar Lemes de Paula <ddepaula@redhat.com> - 4.2.0-11.el8
- kvm-spapr-Enable-DD2.3-accelerated-count-cache-flush-in-.patch [bz#1796240]
- kvm-util-add-slirp_fmt-helpers.patch [bz#1798994]
- kvm-tcp_emu-fix-unsafe-snprintf-usages.patch [bz#1798994]
- kvm-virtio-add-ability-to-delete-vq-through-a-pointer.patch [bz#1791590]
- kvm-virtio-make-virtio_delete_queue-idempotent.patch [bz#1791590]
- kvm-virtio-reset-region-cache-when-on-queue-deletion.patch [bz#1791590]
- kvm-virtio-net-delete-also-control-queue-when-TX-RX-dele.patch [bz#1791590]
- Resolves: bz#1791590
  ([Q35] No "DEVICE_DELETED" event in qmp after unplug virtio-net-pci device)
- Resolves: bz#1796240
  (Enable hw accelerated cache-count-flush by default for POWER9 DD2.3 cpus)
- Resolves: bz#1798994
  (CVE-2020-8608 qemu-kvm: QEMU: Slirp: potential OOB access due to unsafe snprintf() usages [rhel-av-8.2.0])
2020-02-23 05:41:47 +00:00

81 lines
2.6 KiB
Diff

From b395ad369278d0923a590975fabbb99ec7716c6b Mon Sep 17 00:00:00 2001
From: Julia Suvorova <jusual@redhat.com>
Date: Wed, 19 Feb 2020 21:34:28 +0000
Subject: [PATCH 4/7] virtio: add ability to delete vq through a pointer
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
RH-Author: Julia Suvorova <jusual@redhat.com>
Message-id: <20200219213431.11913-2-jusual@redhat.com>
Patchwork-id: 93980
O-Subject: [RHEL-AV-8.2.0 qemu-kvm PATCH 1/4] virtio: add ability to delete vq through a pointer
Bugzilla: 1791590
RH-Acked-by: Danilo de Paula <ddepaula@redhat.com>
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
From: "Michael S. Tsirkin" <mst@redhat.com>
Devices tend to maintain vq pointers, allow deleting them trough a vq pointer.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
(cherry picked from commit 722f8c51d8af223751dfb1d02de40043e8ba067e)
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
---
hw/virtio/virtio.c | 15 ++++++++++-----
include/hw/virtio/virtio.h | 2 ++
2 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index 3211135..d63a369 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -2335,17 +2335,22 @@ VirtQueue *virtio_add_queue(VirtIODevice *vdev, int queue_size,
return &vdev->vq[i];
}
+void virtio_delete_queue(VirtQueue *vq)
+{
+ vq->vring.num = 0;
+ vq->vring.num_default = 0;
+ vq->handle_output = NULL;
+ vq->handle_aio_output = NULL;
+ g_free(vq->used_elems);
+}
+
void virtio_del_queue(VirtIODevice *vdev, int n)
{
if (n < 0 || n >= VIRTIO_QUEUE_MAX) {
abort();
}
- vdev->vq[n].vring.num = 0;
- vdev->vq[n].vring.num_default = 0;
- vdev->vq[n].handle_output = NULL;
- vdev->vq[n].handle_aio_output = NULL;
- g_free(vdev->vq[n].used_elems);
+ virtio_delete_queue(&vdev->vq[n]);
}
static void virtio_set_isr(VirtIODevice *vdev, int value)
diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
index 6a20442..91167f6 100644
--- a/include/hw/virtio/virtio.h
+++ b/include/hw/virtio/virtio.h
@@ -183,6 +183,8 @@ VirtQueue *virtio_add_queue(VirtIODevice *vdev, int queue_size,
void virtio_del_queue(VirtIODevice *vdev, int n);
+void virtio_delete_queue(VirtQueue *vq);
+
void virtqueue_push(VirtQueue *vq, const VirtQueueElement *elem,
unsigned int len);
void virtqueue_flush(VirtQueue *vq, unsigned int count);
--
1.8.3.1