[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL v2 04/16] virtio-mmio: fix guest kernel crash with SHM regions
From: |
Michael S. Tsirkin |
Subject: |
[PULL v2 04/16] virtio-mmio: fix guest kernel crash with SHM regions |
Date: |
Fri, 5 Feb 2021 10:03:41 -0500 |
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
- [PULL v2 00/16] pc,virtio,pci: fixes, features,code removal, Michael S. Tsirkin, 2021/02/05
- [PULL v2 01/16] pci: reject too large ROMs, Michael S. Tsirkin, 2021/02/05
- [PULL v2 03/16] virtio: move 'use-disabled-flag' property to hw_compat_4_2, Michael S. Tsirkin, 2021/02/05
- [PULL v2 02/16] pci: add romsize property, Michael S. Tsirkin, 2021/02/05
- [PULL v2 04/16] virtio-mmio: fix guest kernel crash with SHM regions,
Michael S. Tsirkin <=
- [PULL v2 05/16] virtio: Add corresponding memory_listener_unregister to unrealize, Michael S. Tsirkin, 2021/02/05
- [PULL v2 06/16] virtio-pmem: add trace events, Michael S. Tsirkin, 2021/02/05
- [PULL v2 07/16] vhost: Unbreak SMMU and virtio-iommu on dev-iotlb support, Michael S. Tsirkin, 2021/02/05
- [PULL v2 08/16] hw/i386: Remove the deprecated pc-1.x machine types, Michael S. Tsirkin, 2021/02/05
- [PULL v2 10/16] vhost: Check for valid vdev in vhost_backend_handle_iotlb_msg, Michael S. Tsirkin, 2021/02/05
- [PULL v2 11/16] tests/acpi: allow updates for expected data files, Michael S. Tsirkin, 2021/02/05
- [PULL v2 12/16] acpi: Permit OEM ID and OEM table ID fields to be changed, Michael S. Tsirkin, 2021/02/05
- [PULL v2 13/16] acpi: use constants as strncpy limit, Michael S. Tsirkin, 2021/02/05
- [PULL v2 16/16] tests/acpi: disallow updates for expected data files, Michael S. Tsirkin, 2021/02/05
- [PULL v2 15/16] tests/acpi: update expected data files, Michael S. Tsirkin, 2021/02/05