[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 06/13] virtio-pci: Changed return values for "notify", "device" an
From: |
Michael S. Tsirkin |
Subject: |
[PULL 06/13] virtio-pci: Changed return values for "notify", "device" and "isr" read. |
Date: |
Wed, 7 Jul 2021 11:03:14 -0400 |
From: Andrew Melnychenko <andrew@daynix.com>
At some point, after unplugging virtio-pci the virtio device may be unrealised,
but the memory regions may be present in flatview. So, it's a possible situation
when memory region's callbacks are called for "unplugged" device.
Previous two patches made sure this case does not cause QEMU to crash.
This patch adds check for "notify" memory region. Now reads will return "-1" if
a virtio
device is not present on a virtio bus.
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1938042
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1743098
Signed-off-by: Andrew Melnychenko <andrew@daynix.com>
Message-Id: <20210609095843.141378-4-andrew@daynix.com>
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Reviewed-by: Raphael Norwitz <raphael.norwitz@nutanix.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.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 c0d9c47df7..433060ac02 100644
--- a/hw/virtio/virtio-pci.c
+++ b/hw/virtio/virtio-pci.c
@@ -1349,6 +1349,11 @@ static void virtio_pci_common_write(void *opaque, hwaddr
addr,
static uint64_t virtio_pci_notify_read(void *opaque, hwaddr addr,
unsigned size)
{
+ VirtIOPCIProxy *proxy = opaque;
+ if (virtio_bus_get_device(&proxy->bus) == NULL) {
+ return UINT64_MAX;
+ }
+
return 0;
}
@@ -1386,7 +1391,7 @@ static uint64_t virtio_pci_isr_read(void *opaque, hwaddr
addr,
uint64_t val;
if (vdev == NULL) {
- return 0;
+ return UINT64_MAX;
}
val = qatomic_xchg(&vdev->isr, 0);
@@ -1407,7 +1412,7 @@ static uint64_t virtio_pci_device_read(void *opaque,
hwaddr addr,
uint64_t val;
if (vdev == NULL) {
- return 0;
+ return UINT64_MAX;
}
switch (size) {
--
MST
- [PULL 00/13] pc,pci,virtio: bugfixes, improvements, Michael S. Tsirkin, 2021/07/07
- [PULL 01/13] virtio: disable ioeventfd for record/replay, Michael S. Tsirkin, 2021/07/07
- [PULL 03/13] hw/pci-host/q35: Ignore write of reserved PCIEXBAR LENGTH field, Michael S. Tsirkin, 2021/07/07
- [PULL 05/13] virtio-pci: Added check for virtio device in PCI config cbs., Michael S. Tsirkin, 2021/07/07
- [PULL 04/13] virtio-pci: Added check for virtio device presence in mm callbacks., Michael S. Tsirkin, 2021/07/07
- [PULL 02/13] virtio: Clarify MR transaction optimization, Michael S. Tsirkin, 2021/07/07
- [PULL 06/13] virtio-pci: Changed return values for "notify", "device" and "isr" read.,
Michael S. Tsirkin <=
- [PULL 07/13] migration: failover: reset partially_hotplugged, Michael S. Tsirkin, 2021/07/07
- [PULL 08/13] tests: acpi: prepare for changing DSDT tables, Michael S. Tsirkin, 2021/07/07
- [PULL 09/13] acpi: pc: revert back to v5.2 PCI slot enumeration, Michael S. Tsirkin, 2021/07/07
- [PULL 10/13] tests: acpi: pc: update expected DSDT blobs, Michael S. Tsirkin, 2021/07/07
- [PULL 11/13] acpi/ged: fix reset cause, Michael S. Tsirkin, 2021/07/07
- [PULL 12/13] docs: add slot when adding new PCIe root port, Michael S. Tsirkin, 2021/07/07
- [PULL 13/13] MAINTAINERS: Add maintainer for vhost-user RNG implementation, Michael S. Tsirkin, 2021/07/07