Commit 0fc3760
Adam Ford
virtio/gpu: mmap dma-buf blob fds into the guest shm region
resource_map_blob() in the virgl_resource_map2/Linux variant only mmaps
SHM (memfd) blob fds into the guest's virtio shm region directly. DMABUF
blob fds are delegated to Rutabaga::resource_map ->
virgl_renderer_resource_map2, which is designed for
virglrenderer-allocated GPU memory and has no machinery to mmap an
external dma-buf fd into a host VA range. For dma-bufs that are not
virglrenderer-managed (V4L2 capture buffers exported via VIDIOC_EXPBUF,
dma-bufs forwarded to the guest by a host PipeWire daemon, etc.) it
silently no-ops and the guest's blob is left backed by zero pages.
The user-visible symptom is camera capture across the muvm PipeWire
bridge delivering all-zero frames even though every layer reports
success: SCM_RIGHTS forwards the dma-buf fd, libkrun classifies it
correctly as DMABUF, the guest issues DRM_IOCTL_VIRTGPU_RESOURCE_CREATE_BLOB
which succeeds, and multifilesink writes plausible-sized files that turn
out to be 0x00 bytes from offset 0 to EOF.
A V4L2 EXPBUF dma-buf wraps regular kernel pages allocated via
VIDIOC_REQBUFS/V4L2_MEMORY_MMAP and is CPU-mappable. It can be mmap'd
into the guest's pre-reserved shm region with MAP_FIXED exactly the same
way SHM (memfd) blobs are. Extending the existing SHM branch to also
accept DMABUF gives the guest live pages and fixes camera capture
without changes to the bridge, PipeWire, or the v4l2 userspace stack.
If the dma-buf is GPU-only and not CPU-mappable, mmap returns MAP_FAILED
and we surface ErrUnspec, no worse than the prior silent no-op. The
handle_type is now included in the error log to help diagnose mismatches.
The fd lifetime is fine: Rutabaga::export_blob returns a try_clone() of
the descriptor, and the mapping persists past the temporary's drop
because the original fd is retained in the resource's persistent handle
slot.
Signed-off-by: Adam Ford <[email protected]>1 parent a3b7ae2 commit 0fc3760
1 file changed
Lines changed: 20 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
| 24 | + | |
23 | 25 | | |
24 | 26 | | |
25 | 27 | | |
| |||
837 | 839 | | |
838 | 840 | | |
839 | 841 | | |
840 | | - | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
841 | 856 | | |
842 | 857 | | |
843 | 858 | | |
| |||
849 | 864 | | |
850 | 865 | | |
851 | 866 | | |
852 | | - | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
853 | 871 | | |
854 | 872 | | |
855 | 873 | | |
| |||
0 commit comments