qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
	Andrew Melnychenko <andrew@daynix.com>
Subject: [PULL 04/13] virtio-pci: Added check for virtio device presence in mm callbacks.
Date: Wed, 7 Jul 2021 11:03:06 -0400	[thread overview]
Message-ID: <20210707150157.52328-5-mst@redhat.com> (raw)
In-Reply-To: <20210707150157.52328-1-mst@redhat.com>

From: Andrew Melnychenko <andrew@daynix.com>

During unplug the virtio device is unplugged from virtio-bus on pci. In some cases,
requests to virtio-pci mm may acquire during/after unplug. Added check that virtio
device is on the bus, for "common" memory region.

Signed-off-by: Andrew Melnychenko <andrew@daynix.com>
Message-Id: <20210609095843.141378-2-andrew@daynix.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 hw/virtio/virtio-pci.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
index f1e105fa52..1bef7a2be8 100644
--- a/hw/virtio/virtio-pci.c
+++ b/hw/virtio/virtio-pci.c
@@ -1147,6 +1147,10 @@ static uint64_t virtio_pci_common_read(void *opaque, hwaddr addr,
     uint32_t val = 0;
     int i;
 
+    if (vdev == NULL) {
+        return UINT64_MAX;
+    }
+
     switch (addr) {
     case VIRTIO_PCI_COMMON_DFSELECT:
         val = proxy->dfselect;
@@ -1230,6 +1234,10 @@ static void virtio_pci_common_write(void *opaque, hwaddr addr,
     VirtIOPCIProxy *proxy = opaque;
     VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
 
+    if (vdev == NULL) {
+        return;
+    }
+
     switch (addr) {
     case VIRTIO_PCI_COMMON_DFSELECT:
         proxy->dfselect = val;
-- 
MST



  parent reply	other threads:[~2021-07-07 15:06 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-07 15:02 [PULL 00/13] pc,pci,virtio: bugfixes, improvements Michael S. Tsirkin
2021-07-07 15:02 ` [PULL 01/13] virtio: disable ioeventfd for record/replay Michael S. Tsirkin
2021-07-07 15:02 ` [PULL 02/13] virtio: Clarify MR transaction optimization Michael S. Tsirkin
2021-07-07 15:03 ` [PULL 03/13] hw/pci-host/q35: Ignore write of reserved PCIEXBAR LENGTH field Michael S. Tsirkin
2021-07-07 15:03 ` Michael S. Tsirkin [this message]
2021-07-07 15:03 ` [PULL 05/13] virtio-pci: Added check for virtio device in PCI config cbs Michael S. Tsirkin
2021-07-07 15:03 ` [PULL 06/13] virtio-pci: Changed return values for "notify", "device" and "isr" read Michael S. Tsirkin
2021-07-07 15:03 ` [PULL 07/13] migration: failover: reset partially_hotplugged Michael S. Tsirkin
2021-07-07 15:03 ` [PULL 08/13] tests: acpi: prepare for changing DSDT tables Michael S. Tsirkin
2021-07-07 15:03 ` [PULL 09/13] acpi: pc: revert back to v5.2 PCI slot enumeration Michael S. Tsirkin
2021-07-07 15:03 ` [PULL 10/13] tests: acpi: pc: update expected DSDT blobs Michael S. Tsirkin
2021-07-07 15:03 ` [PULL 11/13] acpi/ged: fix reset cause Michael S. Tsirkin
2021-07-07 15:03 ` [PULL 12/13] docs: add slot when adding new PCIe root port Michael S. Tsirkin
2021-07-07 15:03 ` [PULL 13/13] MAINTAINERS: Add maintainer for vhost-user RNG implementation Michael S. Tsirkin
2021-07-08 22:01   ` Mathieu Poirier
2021-07-09  6:58     ` Michael S. Tsirkin
2021-07-09  7:02       ` Michael S. Tsirkin
2021-07-09 14:59 ` [PULL 00/13] pc,pci,virtio: bugfixes, improvements Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210707150157.52328-5-mst@redhat.com \
    --to=mst@redhat.com \
    --cc=andrew@daynix.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).