0
Fork 0
mirror of https://github.com/Droid-VM/crosvm.git synced 2026-11-17 06:58:03 +00:00
crosvm/resources
HuJK 20f1e3a2fb gunyah: boot-blessed GPU pools, shared once before start instead of per blob
Sharing a blob at a time works, but it costs an RM round trip and a stage-2
table churn per resource, and on a phone that is the difference between a
compositor that hitches and one that does not. A pool is the alternative: a
slab of address space carved out after guest RAM, SHARE'd once before the VM
starts, and sub-allocated by the renderer afterwards. Nothing is transferred at
run time, so nothing can fail at run time either.

`--pre-alloc` sizes them and each one appears in the device tree as a
/reserved-memory node named for who uses it and which side allocates from it --
`gfx_host`, `gpu_guest`, `drm2kgsl_host`. Those names are wire: the guest driver
finds its pool by matching the prefix, so renaming one is a cross-repo change.
The `reg` of such a node must match the memparcel registered before VM start
exactly; the RM walks every /reserved-memory child, compares by address and
size, and refuses the VM outright when nothing matches. Adding a pool is four
mechanical steps (a MemoryRegionPurpose variant, a carve-out, a node, a driver
that looks for the name) precisely because both readers are generic.

A pool-resident blob is reported to the guest through the existing map_info
response: VIRTIO_GPU_MAP_INFO_POOL says "this is a pool offset", and the field
that used to be `padding` carries the offset. The guest then maps pool_base +
offset out of RAM it was already given and never accepts anything. Resource ids
are recycled by the guest, so the offset must be CLEARED for a resource that is
not pool-resident -- inheriting the previous tenant's offset makes crosvm map
the wrong GPA into the guest, which is a corrupted screen rather than an error.

The pages are prepared before they are shared: collapsed into 2 MiB folios,
mlocked and cache-cleaned, and the whole region goes over as ONE memparcel. The
per-2 MiB chunking this replaces cost a linear number of RM calls and produced
nothing the single parcel does not.

pci_bar_size defaults to 256 MiB rather than 8 GiB. The BAR is address space,
but the IPA window it needs is not free on this hypervisor, and 8 GiB of it
pushed the layout past what the RM would accept.

Co-authored-by: lateautumn233 <lateautumn233@foxmail.com>
History 2026-08-31 13:44:23 +08:00
..
src gunyah: boot-blessed GPU pools, shared once before start instead of per blob 2026-08-31 13:44:23 +08:00
Android.bp ANDROID: simplify crosvm_defaults 2025-02-10 18:41:03 -08:00
Cargo.toml Move PciAddress from devices to resources 2024-11-26 22:29:52 +00:00