]>
Commit | Line | Data |
---|---|---|
4de9440f TL |
1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 |
2 | From: Xueming Li <xuemingl@nvidia.com> | |
3 | Date: Mon, 7 Feb 2022 15:19:28 +0800 | |
4 | Subject: [PATCH] vhost-user: remove VirtQ notifier restore | |
5 | ||
6 | Notifier set when vhost-user backend asks qemu to mmap an FD and | |
7 | offset. When vhost-user backend restart or getting killed, VQ notifier | |
8 | FD and mmap addresses become invalid. After backend restart, MR contains | |
9 | the invalid address will be restored and fail on notifier access. | |
10 | ||
11 | On the other hand, qemu should munmap the notifier, release underlying | |
12 | hardware resources to enable backend restart and allocate hardware | |
13 | notifier resources correctly. | |
14 | ||
15 | Qemu shouldn't reference and use resources of disconnected backend. | |
16 | ||
17 | This patch removes VQ notifier restore, uses the default vhost-user | |
18 | notifier to avoid invalid address access. | |
19 | ||
20 | After backend restart, the backend should ask qemu to install a hardware | |
21 | notifier if needed. | |
22 | ||
23 | Fixes: 44866521bd6e ("vhost-user: support registering external host notifiers") | |
24 | Cc: qemu-stable@nongnu.org | |
25 | Signed-off-by: Xueming Li <xuemingl@nvidia.com> | |
26 | Message-Id: <20220207071929.527149-2-xuemingl@nvidia.com> | |
27 | Reviewed-by: Michael S. Tsirkin <mst@redhat.com> | |
28 | Signed-off-by: Michael S. Tsirkin <mst@redhat.com> | |
29 | (cherry picked from commit e867144b73b3c5009266b6df07d5ff44acfb82c3) | |
30 | Signed-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 | ||
36 | diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c | |
37 | index 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 | } | |
87 | diff --git a/include/hw/virtio/vhost-user.h b/include/hw/virtio/vhost-user.h | |
88 | index 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 { |