52 lines
1.8 KiB
Diff
52 lines
1.8 KiB
Diff
|
|
From 8e15820dcf4f343ad21e01d8a6c9516b79ee4e7c Mon Sep 17 00:00:00 2001
|
||
|
|
From: tangbinzy <tangbin_yewu@cmss.chinamobile.com>
|
||
|
|
Date: Tue, 30 Apr 2024 09:42:08 +0000
|
||
|
|
Subject: [PATCH] hw/virtio: handle un-configured shutdown in virtio-pci
|
||
|
|
mainline inclusion commit 5a9d5f09b1f61bc7072c2389ba5b11350ae76b0d category:
|
||
|
|
bugfix
|
||
|
|
MIME-Version: 1.0
|
||
|
|
Content-Type: text/plain; charset=UTF-8
|
||
|
|
Content-Transfer-Encoding: 8bit
|
||
|
|
|
||
|
|
---------------------------------------------------------------
|
||
|
|
|
||
|
|
The assert() protecting against leakage is a little aggressive and
|
||
|
|
causes needless crashes if a device is shutdown without having been
|
||
|
|
configured. In this case no descriptors are lost because none have
|
||
|
|
been assigned.
|
||
|
|
|
||
|
|
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
|
||
|
|
Message-Id: <20220728135503.1060062-4-alex.bennee@linaro.org>
|
||
|
|
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
|
||
|
|
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
|
||
|
|
|
||
|
|
Signed-off-by: tangbinzy <tangbin_yewu@cmss.chinamobile.com>
|
||
|
|
---
|
||
|
|
hw/virtio/virtio-pci.c | 9 +++++++--
|
||
|
|
1 file changed, 7 insertions(+), 2 deletions(-)
|
||
|
|
|
||
|
|
diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
|
||
|
|
index 6b45683280..389a8db0ec 100644
|
||
|
|
--- a/hw/virtio/virtio-pci.c
|
||
|
|
+++ b/hw/virtio/virtio-pci.c
|
||
|
|
@@ -1213,9 +1213,14 @@ static int virtio_pci_set_guest_notifiers(DeviceState *d, int nvqs, bool assign)
|
||
|
|
|
||
|
|
nvqs = MIN(nvqs, VIRTIO_QUEUE_MAX);
|
||
|
|
|
||
|
|
- /* When deassigning, pass a consistent nvqs value
|
||
|
|
- * to avoid leaking notifiers.
|
||
|
|
+ /*
|
||
|
|
+ * When deassigning, pass a consistent nvqs value to avoid leaking
|
||
|
|
+ * notifiers. But first check we've actually been configured, exit
|
||
|
|
+ * early if we haven't.
|
||
|
|
*/
|
||
|
|
+ if (!assign && !proxy->nvqs_with_notifiers) {
|
||
|
|
+ return 0;
|
||
|
|
+ }
|
||
|
|
assert(assign || nvqs == proxy->nvqs_with_notifiers);
|
||
|
|
|
||
|
|
proxy->nvqs_with_notifiers = nvqs;
|
||
|
|
--
|
||
|
|
2.27.0
|
||
|
|
|