From: "Michael S. Tsirkin" <mst@redhat.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
Stefano Garzarella <sgarzare@redhat.com>,
Laurent Vivier <laurent@vivier.eu>,
Gerd Hoffmann <kraxel@redhat.com>
Subject: [PULL 2/9] virtio-mmio: fix guest kernel crash with SHM regions
Date: Tue, 2 Feb 2021 10:12:29 -0500 [thread overview]
Message-ID: <20210202151116.1573669-3-mst@redhat.com> (raw)
In-Reply-To: <20210202151116.1573669-1-mst@redhat.com>
From: Laurent Vivier <laurent@vivier.eu>
In the kernel, virtio_gpu_init() uses virtio_get_shm_region()
since
commit 6076a9711dc5 ("drm/virtio: implement blob resources: probe for host visible region")
but vm_get_shm_region() unconditionally uses VIRTIO_MMIO_SHM_SEL to
get the address and the length of the region.
commit 38e895487afc ("virtio: Implement get_shm_region for MMIO transport"
As this is not implemented in QEMU, address and length are 0 and passed
as is to devm_request_mem_region() that triggers a crash:
[drm:virtio_gpu_init] *ERROR* Could not reserve host visible region
Unable to handle kernel NULL pointer dereference at virtual address (ptrval)
According to the comments in the kernel, a non existent shared region
has a length of (u64)-1.
This is what we return now with this patch to disable the region.
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20201220163539.2255963-1-laurent@vivier.eu>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/virtio/virtio-mmio.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/hw/virtio/virtio-mmio.c b/hw/virtio/virtio-mmio.c
index e1b5c3b81e..610661d6a5 100644
--- a/hw/virtio/virtio-mmio.c
+++ b/hw/virtio/virtio-mmio.c
@@ -191,6 +191,14 @@ static uint64_t virtio_mmio_read(void *opaque, hwaddr offset, unsigned size)
return 0;
}
return vdev->generation;
+ case VIRTIO_MMIO_SHM_LEN_LOW:
+ case VIRTIO_MMIO_SHM_LEN_HIGH:
+ /*
+ * VIRTIO_MMIO_SHM_SEL is unimplemented
+ * according to the linux driver, if region length is -1
+ * the shared memory doesn't exist
+ */
+ return -1;
case VIRTIO_MMIO_DEVICE_FEATURES_SEL:
case VIRTIO_MMIO_DRIVER_FEATURES:
case VIRTIO_MMIO_DRIVER_FEATURES_SEL:
--
MST
next prev parent reply other threads:[~2021-02-02 15:35 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-02 15:12 [PULL 0/9] pc,virtio: fixes, features Michael S. Tsirkin
2021-02-02 15:12 ` [PULL 1/9] virtio: move 'use-disabled-flag' property to hw_compat_4_2 Michael S. Tsirkin
2021-02-02 15:12 ` Michael S. Tsirkin [this message]
2021-02-02 15:12 ` [PULL 3/9] virtio: Add corresponding memory_listener_unregister to unrealize Michael S. Tsirkin
2021-02-02 15:12 ` [PULL 4/9] tests/acpi: allow updates for expected data files Michael S. Tsirkin
2021-02-02 15:12 ` [PULL 5/9] acpi: Permit OEM ID and OEM table ID fields to be changed Michael S. Tsirkin
2021-02-02 15:12 ` [PULL 6/9] tests/acpi: add OEM ID and OEM TABLE ID test Michael S. Tsirkin
2021-02-02 15:12 ` [PULL 7/9] tests/acpi: update expected data files Michael S. Tsirkin
2021-02-02 15:12 ` [PULL 9/9] virtio-pmem: add trace events Michael S. Tsirkin
2021-02-02 15:12 ` [PULL 8/9] tests/acpi: disallow updates for expected data files Michael S. Tsirkin
2021-02-02 22:44 ` [PULL 0/9] pc,virtio: fixes, features Peter Maydell
2021-02-02 22:57 ` Michael S. Tsirkin
2021-02-03 14:15 ` 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=20210202151116.1573669-3-mst@redhat.com \
--to=mst@redhat.com \
--cc=kraxel@redhat.com \
--cc=laurent@vivier.eu \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=sgarzare@redhat.com \
/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).