Revert "virtio: reject shm region if length is zero"
PATCH v2 1/1 Revert "virtio: reject shm region if length is zero"
The commit 206cc44588f7 ("virtio: reject shm region if length is zero") breaks the Virtio-gpu host_visible feature.
Right now in the Virtio-gpu code, host_visible_region.len is zero because the struct comes directly from the kzalloc allocation. And Virtio-gpu is 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.
As the Virtio-gpu relies on the previous behavior, this patch reverts the offending commit.
This reverts commit 206cc44588f72b49ad4d7e21a7472ab2a72a83df.
---
v2: Improve the commit message (Michael S. Tsirkin)
include/linux/virtio_config.h | 2 -- 1 file changed, 2 deletions(-)
include/linux/virtio_config.h +0 -2
@@ -329,8 +329,6 @@ static inlinebool 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);
Signature · 1 line
2.49.0
Michael S. Tsirkin
maintainerQuoted 17 lines · Igor Torrente
The commit
206cc44588f7("virtio: reject shm region if length is zero") breaks the Virtio-gpuhost_visiblefeature.Right now in the Virtio-gpu code,
host_visible_region.lenis zero because the struct comes directly from thekzallocallocation. And Virtio-gpu is using thevm_get_shm_region(drivers/virtio/virtio_mmio.c:536) to read theaddrandlenfrom 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.
Quoted 8 lines
As the Virtio-gpu relies on the previous behavior, this patch reverts the offending commit.
Fixes 206cc44588f7 ("virtio: reject shm region if length is zero` breaks the Virtio-gpu `host_visible")This reverts commit
206cc44588f72b49ad4d7e21a7472ab2a72a83df.Signed-off-by Igor Torrente <[email protected]>
Fixes has to be adjacent to Signed-off-by.
But anyway, I already included v1 in my tree, pls check it out and tell me if more fixes are needed.
Quoted 21 lines
---
v2: Improve the commit message (Michael S. Tsirkin)include/linux/virtio_config.h | 2 -- 1 file changed, 2 deletions(-)include/linux/virtio_config.h +0
-2@@ -329,8 +329,6 @@ static inlinebool 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);Signature · 1 line
2.49.0
---- El vie., 08 ago. 2025 08:26:08 -0300, Michael S. Tsirkin <[email protected]> escribió ----
Quoted 21 lines · Igor Torrente
Quoted 20 lines
The commit
206cc44588f7("virtio: reject shm region if length is zero") breaks the Virtio-gpuhost_visiblefeature.Right now in the Virtio-gpu code,
host_visible_region.lenis zero because the struct comes directly from thekzallocallocation. And Virtio-gpu is using thevm_get_shm_region(drivers/virtio/virtio_mmio.c:536) to read theaddrandlenfrom 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.
As the Virtio-gpu relies on the previous behavior, this patch reverts the offending commit.
Quoted 8 lines
Quoted 5 lines
Fixes 206cc44588f7 ("virtio: reject shm region if length is zero` breaks the Virtio-gpu `host_visible")This reverts commit
206cc44588f72b49ad4d7e21a7472ab2a72a83df.Signed-off-by Igor Torrente <[email protected]>Fixes has to be adjacent to Signed-off-by.
Ohh, I will pay attention to this next time.
Quoted 2 lines
But anyway, I already included v1 in my tree, pls check it out and tell me if more fixes are needed.
I tested here your branch, and it's working fine.
``` [ 0.298365] [drm] pci: virtio-gpu-pci detected at 0000:00:04.0 [ 0.298506] [drm] Host memory window: 0x200000000 +0x200000000 [ 0.298510] [drm] features: +virgl +edid +resource_blob +host_visible ``` ``` Linux debian-arm64-vm-chromebook 6.16.0mst_virt_repo_linux-next+ #159 SMP PREEMPT_DYNAMIC Fri Aug 8 11:53:04 -03 2025 aarch64 GNU/Linux ```
Thanks for applying it,
---
Igor Torrente
Quoted 24 lines
Quoted 22 lines
---
v2: Improve the commit message (Michael S. Tsirkin)include/linux/virtio_config.h | 2 -- 1 file changed, 2 deletions(-)include/linux/virtio_config.h +0
-2@@ -329,8 +329,6 @@ static inlinebool 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);Signature · 1 line
2.49.0