]> git.proxmox.com Git - pve-qemu.git/blame - debian/patches/extra/0015-vhost-user-remove-VirtQ-notifier-restore.patch
bump version to 6.2.0-11
[pve-qemu.git] / debian / patches / extra / 0015-vhost-user-remove-VirtQ-notifier-restore.patch
CommitLineData
4de9440f
TL
1From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2From: Xueming Li <xuemingl@nvidia.com>
3Date: Mon, 7 Feb 2022 15:19:28 +0800
4Subject: [PATCH] vhost-user: remove VirtQ notifier restore
5
6Notifier set when vhost-user backend asks qemu to mmap an FD and
7offset. When vhost-user backend restart or getting killed, VQ notifier
8FD and mmap addresses become invalid. After backend restart, MR contains
9the invalid address will be restored and fail on notifier access.
10
11On the other hand, qemu should munmap the notifier, release underlying
12hardware resources to enable backend restart and allocate hardware
13notifier resources correctly.
14
15Qemu shouldn't reference and use resources of disconnected backend.
16
17This patch removes VQ notifier restore, uses the default vhost-user
18notifier to avoid invalid address access.
19
20After backend restart, the backend should ask qemu to install a hardware
21notifier if needed.
22
23Fixes: 44866521bd6e ("vhost-user: support registering external host notifiers")
24Cc: qemu-stable@nongnu.org
25Signed-off-by: Xueming Li <xuemingl@nvidia.com>
26Message-Id: <20220207071929.527149-2-xuemingl@nvidia.com>
27Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
28Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
29(cherry picked from commit e867144b73b3c5009266b6df07d5ff44acfb82c3)
30Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
31---
32 hw/virtio/vhost-user.c | 19 +------------------
33 include/hw/virtio/vhost-user.h | 1 -
34 2 files changed, 1 insertion(+), 19 deletions(-)
35
36diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
37index bf6e50223c..c671719e9b 100644
38--- a/hw/virtio/vhost-user.c
39+++ b/hw/virtio/vhost-user.c
40@@ -1143,19 +1143,6 @@ static int vhost_user_set_vring_num(struct vhost_dev *dev,
41 return vhost_set_vring(dev, VHOST_USER_SET_VRING_NUM, ring);
42 }
43
44-static void vhost_user_host_notifier_restore(struct vhost_dev *dev,
45- int queue_idx)
46-{
47- struct vhost_user *u = dev->opaque;
48- VhostUserHostNotifier *n = &u->user->notifier[queue_idx];
49- VirtIODevice *vdev = dev->vdev;
50-
51- if (n->addr && !n->set) {
52- virtio_queue_set_host_notifier_mr(vdev, queue_idx, &n->mr, true);
53- n->set = true;
54- }
55-}
56-
57 static void vhost_user_host_notifier_remove(struct vhost_dev *dev,
58 int queue_idx)
59 {
60@@ -1163,17 +1150,14 @@ static void vhost_user_host_notifier_remove(struct vhost_dev *dev,
61 VhostUserHostNotifier *n = &u->user->notifier[queue_idx];
62 VirtIODevice *vdev = dev->vdev;
63
64- if (n->addr && n->set) {
65+ if (n->addr) {
66 virtio_queue_set_host_notifier_mr(vdev, queue_idx, &n->mr, false);
67- n->set = false;
68 }
69 }
70
71 static int vhost_user_set_vring_base(struct vhost_dev *dev,
72 struct vhost_vring_state *ring)
73 {
74- vhost_user_host_notifier_restore(dev, ring->index);
75-
76 return vhost_set_vring(dev, VHOST_USER_SET_VRING_BASE, ring);
77 }
78
79@@ -1538,7 +1522,6 @@ static int vhost_user_slave_handle_vring_host_notifier(struct vhost_dev *dev,
80 }
81
82 n->addr = addr;
83- n->set = true;
84
85 return 0;
86 }
87diff --git a/include/hw/virtio/vhost-user.h b/include/hw/virtio/vhost-user.h
88index a9abca3288..f6012b2078 100644
89--- a/include/hw/virtio/vhost-user.h
90+++ b/include/hw/virtio/vhost-user.h
91@@ -14,7 +14,6 @@
92 typedef struct VhostUserHostNotifier {
93 MemoryRegion mr;
94 void *addr;
95- bool set;
96 } VhostUserHostNotifier;
97
98 typedef struct VhostUserState {