thebeanogamer / rpms / qemu-kvm

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