thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone
ed5979
From 34a267758cf016f34b327318500efdbf0f606033 Mon Sep 17 00:00:00 2001
ed5979
From: Cindy Lu <lulu@redhat.com>
ed5979
Date: Thu, 22 Dec 2022 15:04:42 +0800
ed5979
Subject: [PATCH 01/31] virtio: introduce macro VIRTIO_CONFIG_IRQ_IDX
ed5979
MIME-Version: 1.0
ed5979
Content-Type: text/plain; charset=UTF-8
ed5979
Content-Transfer-Encoding: 8bit
ed5979
ed5979
RH-Author: Cindy Lu <lulu@redhat.com>
ed5979
RH-MergeRequest: 132: vhost-vdpa: support config interrupt in vhost-vdpa
ed5979
RH-Bugzilla: 1905805
ed5979
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
ed5979
RH-Acked-by: Eugenio PĂ©rez <eperezma@redhat.com>
ed5979
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
ed5979
RH-Commit: [1/10] f374aaae221bc5a4c2521a267d21350b812e11ba (lulu6/qemu-kvm3)
ed5979
ed5979
https://bugzilla.redhat.com/show_bug.cgi?id=1905805
ed5979
To support configure interrupt for vhost-vdpa
ed5979
Introduce VIRTIO_CONFIG_IRQ_IDX -1 as configure interrupt's queue index,
ed5979
Then we can reuse the functions guest_notifier_mask and guest_notifier_pending.
ed5979
Add the check of queue index in these drivers, if the driver does not support
ed5979
configure interrupt, the function will just return
ed5979
ed5979
Signed-off-by: Cindy Lu <lulu@redhat.com>
ed5979
Message-Id: <20221222070451.936503-2-lulu@redhat.com>
ed5979
Acked-by: Jason Wang <jasowang@redhat.com>
ed5979
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
ed5979
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
ed5979
(cherry picked from commit 544f0278afcab2bebab61b14e4c2c58e65911f5b)
ed5979
Signed-off-by: Cindy Lu <lulu@redhat.com>
ed5979
---
ed5979
 hw/display/vhost-user-gpu.c    | 18 ++++++++++++++++++
ed5979
 hw/net/virtio-net.c            | 22 ++++++++++++++++++++--
ed5979
 hw/virtio/vhost-user-fs.c      | 18 ++++++++++++++++++
ed5979
 hw/virtio/vhost-user-gpio.c    | 10 ++++++++++
ed5979
 hw/virtio/vhost-vsock-common.c | 18 ++++++++++++++++++
ed5979
 hw/virtio/virtio-crypto.c      | 18 ++++++++++++++++++
ed5979
 include/hw/virtio/virtio.h     |  3 +++
ed5979
 7 files changed, 105 insertions(+), 2 deletions(-)
ed5979
ed5979
diff --git a/hw/display/vhost-user-gpu.c b/hw/display/vhost-user-gpu.c
ed5979
index 19c0e20103..4380a5e672 100644
ed5979
--- a/hw/display/vhost-user-gpu.c
ed5979
+++ b/hw/display/vhost-user-gpu.c
ed5979
@@ -486,6 +486,15 @@ vhost_user_gpu_guest_notifier_pending(VirtIODevice *vdev, int idx)
ed5979
 {
ed5979
     VhostUserGPU *g = VHOST_USER_GPU(vdev);
ed5979
 
ed5979
+    /*
ed5979
+     * Add the check for configure interrupt, Use VIRTIO_CONFIG_IRQ_IDX -1
ed5979
+     * as the Marco of configure interrupt's IDX, If this driver does not
ed5979
+     * support, the function will return
ed5979
+     */
ed5979
+
ed5979
+    if (idx == VIRTIO_CONFIG_IRQ_IDX) {
ed5979
+        return false;
ed5979
+    }
ed5979
     return vhost_virtqueue_pending(&g->vhost->dev, idx);
ed5979
 }
ed5979
 
ed5979
@@ -494,6 +503,15 @@ vhost_user_gpu_guest_notifier_mask(VirtIODevice *vdev, int idx, bool mask)
ed5979
 {
ed5979
     VhostUserGPU *g = VHOST_USER_GPU(vdev);
ed5979
 
ed5979
+    /*
ed5979
+     * Add the check for configure interrupt, Use VIRTIO_CONFIG_IRQ_IDX -1
ed5979
+     * as the Marco of configure interrupt's IDX, If this driver does not
ed5979
+     * support, the function will return
ed5979
+     */
ed5979
+
ed5979
+    if (idx == VIRTIO_CONFIG_IRQ_IDX) {
ed5979
+        return;
ed5979
+    }
ed5979
     vhost_virtqueue_mask(&g->vhost->dev, vdev, idx, mask);
ed5979
 }
ed5979
 
ed5979
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
ed5979
index aba12759d5..bee35d6f9f 100644
ed5979
--- a/hw/net/virtio-net.c
ed5979
+++ b/hw/net/virtio-net.c
ed5979
@@ -3316,6 +3316,15 @@ static bool virtio_net_guest_notifier_pending(VirtIODevice *vdev, int idx)
ed5979
     } else {
ed5979
         nc = qemu_get_subqueue(n->nic, vq2q(idx));
ed5979
     }
ed5979
+    /*
ed5979
+     * Add the check for configure interrupt, Use VIRTIO_CONFIG_IRQ_IDX -1
ed5979
+     * as the Marco of configure interrupt's IDX, If this driver does not
ed5979
+     * support, the function will return false
ed5979
+     */
ed5979
+
ed5979
+    if (idx == VIRTIO_CONFIG_IRQ_IDX) {
ed5979
+        return false;
ed5979
+    }
ed5979
     return vhost_net_virtqueue_pending(get_vhost_net(nc->peer), idx);
ed5979
 }
ed5979
 
ed5979
@@ -3339,8 +3348,17 @@ static void virtio_net_guest_notifier_mask(VirtIODevice *vdev, int idx,
ed5979
     } else {
ed5979
         nc = qemu_get_subqueue(n->nic, vq2q(idx));
ed5979
     }
ed5979
-    vhost_net_virtqueue_mask(get_vhost_net(nc->peer),
ed5979
-                             vdev, idx, mask);
ed5979
+    /*
ed5979
+     *Add the check for configure interrupt, Use VIRTIO_CONFIG_IRQ_IDX -1
ed5979
+     * as the Marco of configure interrupt's IDX, If this driver does not
ed5979
+     * support, the function will return
ed5979
+     */
ed5979
+
ed5979
+    if (idx == VIRTIO_CONFIG_IRQ_IDX) {
ed5979
+        return;
ed5979
+    }
ed5979
+
ed5979
+    vhost_net_virtqueue_mask(get_vhost_net(nc->peer), vdev, idx, mask);
ed5979
 }
ed5979
 
ed5979
 static void virtio_net_set_config_size(VirtIONet *n, uint64_t host_features)
ed5979
diff --git a/hw/virtio/vhost-user-fs.c b/hw/virtio/vhost-user-fs.c
ed5979
index d97b179e6f..f5049735ac 100644
ed5979
--- a/hw/virtio/vhost-user-fs.c
ed5979
+++ b/hw/virtio/vhost-user-fs.c
ed5979
@@ -159,6 +159,15 @@ static void vuf_guest_notifier_mask(VirtIODevice *vdev, int idx,
ed5979
 {
ed5979
     VHostUserFS *fs = VHOST_USER_FS(vdev);
ed5979
 
ed5979
+    /*
ed5979
+     * Add the check for configure interrupt, Use VIRTIO_CONFIG_IRQ_IDX -1
ed5979
+     * as the Marco of configure interrupt's IDX, If this driver does not
ed5979
+     * support, the function will return
ed5979
+     */
ed5979
+
ed5979
+    if (idx == VIRTIO_CONFIG_IRQ_IDX) {
ed5979
+        return;
ed5979
+    }
ed5979
     vhost_virtqueue_mask(&fs->vhost_dev, vdev, idx, mask);
ed5979
 }
ed5979
 
ed5979
@@ -166,6 +175,15 @@ static bool vuf_guest_notifier_pending(VirtIODevice *vdev, int idx)
ed5979
 {
ed5979
     VHostUserFS *fs = VHOST_USER_FS(vdev);
ed5979
 
ed5979
+    /*
ed5979
+     * Add the check for configure interrupt, Use VIRTIO_CONFIG_IRQ_IDX -1
ed5979
+     * as the Marco of configure interrupt's IDX, If this driver does not
ed5979
+     * support, the function will return
ed5979
+     */
ed5979
+
ed5979
+    if (idx == VIRTIO_CONFIG_IRQ_IDX) {
ed5979
+        return false;
ed5979
+    }
ed5979
     return vhost_virtqueue_pending(&fs->vhost_dev, idx);
ed5979
 }
ed5979
 
ed5979
diff --git a/hw/virtio/vhost-user-gpio.c b/hw/virtio/vhost-user-gpio.c
ed5979
index b7b82a1099..fe3da32c74 100644
ed5979
--- a/hw/virtio/vhost-user-gpio.c
ed5979
+++ b/hw/virtio/vhost-user-gpio.c
ed5979
@@ -191,6 +191,16 @@ static void vu_gpio_guest_notifier_mask(VirtIODevice *vdev, int idx, bool mask)
ed5979
 {
ed5979
     VHostUserGPIO *gpio = VHOST_USER_GPIO(vdev);
ed5979
 
ed5979
+    /*
ed5979
+     * Add the check for configure interrupt, Use VIRTIO_CONFIG_IRQ_IDX -1
ed5979
+     * as the Marco of configure interrupt's IDX, If this driver does not
ed5979
+     * support, the function will return
ed5979
+     */
ed5979
+
ed5979
+    if (idx == VIRTIO_CONFIG_IRQ_IDX) {
ed5979
+        return;
ed5979
+    }
ed5979
+
ed5979
     vhost_virtqueue_mask(&gpio->vhost_dev, vdev, idx, mask);
ed5979
 }
ed5979
 
ed5979
diff --git a/hw/virtio/vhost-vsock-common.c b/hw/virtio/vhost-vsock-common.c
ed5979
index d21c72b401..d2b5519d5a 100644
ed5979
--- a/hw/virtio/vhost-vsock-common.c
ed5979
+++ b/hw/virtio/vhost-vsock-common.c
ed5979
@@ -127,6 +127,15 @@ static void vhost_vsock_common_guest_notifier_mask(VirtIODevice *vdev, int idx,
ed5979
 {
ed5979
     VHostVSockCommon *vvc = VHOST_VSOCK_COMMON(vdev);
ed5979
 
ed5979
+    /*
ed5979
+     * Add the check for configure interrupt, Use VIRTIO_CONFIG_IRQ_IDX -1
ed5979
+     * as the Marco of configure interrupt's IDX, If this driver does not
ed5979
+     * support, the function will return
ed5979
+     */
ed5979
+
ed5979
+    if (idx == VIRTIO_CONFIG_IRQ_IDX) {
ed5979
+        return;
ed5979
+    }
ed5979
     vhost_virtqueue_mask(&vvc->vhost_dev, vdev, idx, mask);
ed5979
 }
ed5979
 
ed5979
@@ -135,6 +144,15 @@ static bool vhost_vsock_common_guest_notifier_pending(VirtIODevice *vdev,
ed5979
 {
ed5979
     VHostVSockCommon *vvc = VHOST_VSOCK_COMMON(vdev);
ed5979
 
ed5979
+    /*
ed5979
+     * Add the check for configure interrupt, Use VIRTIO_CONFIG_IRQ_IDX -1
ed5979
+     * as the Marco of configure interrupt's IDX, If this driver does not
ed5979
+     * support, the function will return
ed5979
+     */
ed5979
+
ed5979
+    if (idx == VIRTIO_CONFIG_IRQ_IDX) {
ed5979
+        return false;
ed5979
+    }
ed5979
     return vhost_virtqueue_pending(&vvc->vhost_dev, idx);
ed5979
 }
ed5979
 
ed5979
diff --git a/hw/virtio/virtio-crypto.c b/hw/virtio/virtio-crypto.c
ed5979
index 97da74e719..516425e26a 100644
ed5979
--- a/hw/virtio/virtio-crypto.c
ed5979
+++ b/hw/virtio/virtio-crypto.c
ed5979
@@ -1182,6 +1182,15 @@ static void virtio_crypto_guest_notifier_mask(VirtIODevice *vdev, int idx,
ed5979
 
ed5979
     assert(vcrypto->vhost_started);
ed5979
 
ed5979
+    /*
ed5979
+     * Add the check for configure interrupt, Use VIRTIO_CONFIG_IRQ_IDX -1
ed5979
+     * as the Marco of configure interrupt's IDX, If this driver does not
ed5979
+     * support, the function will return
ed5979
+     */
ed5979
+
ed5979
+    if (idx == VIRTIO_CONFIG_IRQ_IDX) {
ed5979
+        return;
ed5979
+    }
ed5979
     cryptodev_vhost_virtqueue_mask(vdev, queue, idx, mask);
ed5979
 }
ed5979
 
ed5979
@@ -1192,6 +1201,15 @@ static bool virtio_crypto_guest_notifier_pending(VirtIODevice *vdev, int idx)
ed5979
 
ed5979
     assert(vcrypto->vhost_started);
ed5979
 
ed5979
+    /*
ed5979
+     * Add the check for configure interrupt, Use VIRTIO_CONFIG_IRQ_IDX -1
ed5979
+     * as the Marco of configure interrupt's IDX, If this driver does not
ed5979
+     * support, the function will return
ed5979
+     */
ed5979
+
ed5979
+    if (idx == VIRTIO_CONFIG_IRQ_IDX) {
ed5979
+        return false;
ed5979
+    }
ed5979
     return cryptodev_vhost_virtqueue_pending(vdev, queue, idx);
ed5979
 }
ed5979
 
ed5979
diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
ed5979
index acfd4df125..1f4a41b958 100644
ed5979
--- a/include/hw/virtio/virtio.h
ed5979
+++ b/include/hw/virtio/virtio.h
ed5979
@@ -79,6 +79,9 @@ typedef struct VirtQueueElement
ed5979
 
ed5979
 #define VIRTIO_NO_VECTOR 0xffff
ed5979
 
ed5979
+/* special index value used internally for config irqs */
ed5979
+#define VIRTIO_CONFIG_IRQ_IDX -1
ed5979
+
ed5979
 #define TYPE_VIRTIO_DEVICE "virtio-device"
ed5979
 OBJECT_DECLARE_TYPE(VirtIODevice, VirtioDeviceClass, VIRTIO_DEVICE)
ed5979
 
ed5979
-- 
ed5979
2.31.1
ed5979