Commit ced17ee3 authored by Igor Torrente's avatar Igor Torrente Committed by Michael S. Tsirkin
Browse files

Revert "virtio: reject shm region if length is zero"



The commit 206cc445 ("virtio: reject shm region if length is zero")
breaks the Virtio-gpu `host_visible` feature.

As you can see in the snippet below, host_visible_region is zero because
of the `kzalloc`.  It's using the `vm_get_shm_region`
(drivers/virtio/virtio_mmio.c:536) to read the `addr` and `len` from
qemu/crosvm.

```
drivers/gpu/drm/virtio/virtgpu_kms.c
132         vgdev = drmm_kzalloc(dev, sizeof(struct virtio_gpu_device), GFP_KERNEL);
[...]
177         if (virtio_get_shm_region(vgdev->vdev, &vgdev->host_visible_region,
178                                   VIRTIO_GPU_SHM_ID_HOST_VISIBLE)) {
```
Now it always fails.

To fix, revert the offending commit.

Fixes: 206cc445 ("virtio: reject shm region if length is zero")
Signed-off-by: default avatarIgor Torrente <igor.torrente@collabora.com>
Message-Id: <20250807124145.81816-1-igor.torrente@collabora.com>
Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
parent dd54bcf8
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -328,8 +328,6 @@ static inline
bool virtio_get_shm_region(struct virtio_device *vdev,
			   struct virtio_shm_region *region, u8 id)
{
	if (!region->len)
		return false;
	if (!vdev->config->get_shm_region)
		return false;
	return vdev->config->get_shm_region(vdev, region, id);