From: Andrew Melnychenko <andrew@daynix.com>
To: mst@redhat.com
Cc: qemu-devel@nongnu.org
Subject: [PATCH 3/3] virtio-pci: Changed return values for "notify", "device" and "isr" read.
Date: Wed, 9 Jun 2021 12:58:43 +0300 [thread overview]
Message-ID: <20210609095843.141378-4-andrew@daynix.com> (raw)
In-Reply-To: <20210609095843.141378-1-andrew@daynix.com>
Added check for "notify" memory region. Now reads will return "-1" if a virtio
device is not present on a virtio bus.
Signed-off-by: Andrew Melnychenko <andrew@daynix.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 186b7bc0f6..447f13beae 100644
--- a/hw/virtio/virtio-pci.c
+++ b/hw/virtio/virtio-pci.c
@@ -1348,6 +1348,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;
}
@@ -1385,7 +1390,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);
@@ -1406,7 +1411,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) {
--
2.31.1
prev parent reply other threads:[~2021-06-09 10:02 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-09 9:58 [PATCH 0/3] virtio-pci: Checks for virtio device presence on the bus Andrew Melnychenko
2021-06-09 9:58 ` [PATCH 1/3] virtio-pci: Added check for virtio device presence in mm callbacks Andrew Melnychenko
2021-06-09 9:58 ` [PATCH 2/3] virtio-pci: Added check for virtio device in PCI config cbs Andrew Melnychenko
2021-06-09 9:58 ` Andrew Melnychenko [this message]
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=20210609095843.141378-4-andrew@daynix.com \
--to=andrew@daynix.com \
--cc=mst@redhat.com \
--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).