Files
reims-vgpu/docs
Anees Iqbal 426724ff52 🆕 Map the guest's Shared pool's blocks into a range the host reserves
metal2vulkan's new runtime allocates the GPU memory the guest's Shared
buffers live in, and the device maps those blocks into the guest (plan D2,
route 1). This is the host side of that pool: the guest's side, and the
wire it reads the range and its pieces from, come with the D2 guest work.

The library: a pool per device (crates/reims-vgpu/src/pool.rs) over the
range the host reserved. Its thread takes Shared blocks from a block source
and asks the host to map each at the lowest free 2 MiB-aligned address
(pool_add); the host says when the guest's address space has it
(rvg_graphics_device_pool_added). The source's unmap hook takes a piece out
of the lookups, waits for every hold on it, asks the host to unmap it
(pool_remove) and returns once the host says it is gone
(rvg_graphics_device_pool_removed); only then may the source free the block.
The pool keeps one empty piece as headroom, asks for a block more when the
guest uses the last empty one, and gives back a piece that stayed empty for
5 s above the lowest empty one. The source's calls and hook have
metal2vulkan-rt's shape (take_block, release_block, BlockMappings::unmap,
BlockInfo); until the device runs on that runtime the source is the
process's own memory (HostBlocks), so only the source changes then.

The C API: RvgGraphicsDeviceConfig and RvgGraphicsCallbacks go to their fifth
version (pool_physical_address and _length; pool_add and pool_remove), with
rvg_graphics_device_pool_added, _pool_removed and _pool_grow (the host's ask
for more pool now, which QEMU's x-pool-grow property drives).

QEMU (vendor/qemu): the device reserves 64 GiB past the RAM and the host
bridge's default 64-bit window, raises etc/reserved-memory-end past it so
OVMF's 64-bit window goes above it, turns KVM's zap-every-slot quirk off, maps
each piece as a RAM region of its own (a pure add) on its main loop, and under
WHPX runs the hypervisor's map outside the BQL. Its teardown takes every piece
out before the release, which frees the blocks before the process exits.

For the guest: the firmware's 64-bit PCI window starts past the reserved
range, 32 GiB or more higher than before; nothing else changes until the
guest's side maps the pool.
2026-11-17 06:35:09 -08:00
..