0
Fork 0
mirror of https://github.com/Droid-VM/crosvm.git synced 2026-11-17 06:58:03 +00:00
crosvm/hypervisor/src/lib.rs
HuJK e8b8b15f76 gunyah: share a driver's DMA-BUF from its own sg-table, not through its mapping
Sharing a blob means building a memparcel out of pages, and the only way to get
pages out of a userspace address is GUP. That works for a memfd. It does not
work for what the GPU driver exports: those DMA-BUFs mmap as VM_PFNMAP or
VM_MIXEDMAP, and GUP is REQUIRED to refuse such a VMA -- there is no page
reference to take. Which left the blobs that matter most reachable only by
copying them somewhere GUP would accept, or by making the VMM rewrite the
allocation's backing before handing it over.

GHSM_SHARE_DMABUF takes the fd instead. The module holds a DMA-BUF attachment
and builds the parcel from the exporter's own sg-table, so the buffer keeps the
backing its allocator chose and crosvm has no opinion about it at all. That
replaces the VMM-side per-blob folio policy this used to need: the policy
belongs with whoever allocates, and crosvm is not that.

ENOTTY falls back to the existing VA/GUP path, which is both an older module and
the ordinary case of a pool memfd -- neither should be a failure.
2026-08-31 13:44:25 +08:00

800 lines
31 KiB