Files
reims-vgpu/scripts
Anees Iqbal afdb76f844 🆕 Give every x86-64 VM the IOSurface device over PCI
An x86-64 macOS guest running Apple's arm64 GPU driver, ported, needs the
IOSurface host device vmapple has as apple-gfx-mmio's second region: the
driver's start waits for its mapper's service, and every texture over an
IOSurface is a mapper texture. reims-ctl now gives every x86-64 VM on
reims-vgpu that device, with no opt-in, and Apple's own x86-64 driver keeps
running as before.

For the guest:
- apple-gfx-iosurface-pci (106b:eeef, ours) sits at 00:06.0 next to the GPU
  at 00:04.0: its registers in BAR 0 at 0x1000, 8-byte accesses passed
  whole, one MSI vector per completed command. A reset returns its
  registers to 0, ring size aside.
- 0x1028 offers the second, 0x400-byte descriptor form only where its table
  holds all 8192 mapping ids (16 KiB pages); on x86-64's 4 KiB pages it
  reads 0, and the guest's mapper takes the first form, which fills them.
- On apple-gfx-pci, a task other than task 0 runs isolated only if the
  IOSurface device has a descriptor table when the guest defines it, and
  device info offers argument buffers (key 33 bit 0x20, key 42) only while
  it has one. Apple's x86-64 driver, stock (binary version 6) or patched by
  reims-util (245), never programs the IOSurface device and makes ref
  textures whose backing is in task 0, which an isolated task does not
  serve (testing.md 6.20); its tasks stay in process and its device info
  is as without isolation. The ported driver's mapper programs the device
  before its GPU driver starts, and its tasks run isolated, which its info
  replies need. apple-gfx-mmio still isolates every task.

For the host:
- apple-gfx-pci has no option for this: adding apple-gfx-iosurface-pci is
  the only switch, and a VM without it runs as before. Its gpu link is
  optional, the machine's only apple-gfx-pci when unset. vendor/qemu moves
  to bd95509a.
- RvgDeviceConfig gains process_isolation_follows_guest at its end (64
  bytes; a host that passes 56 reads it false), and the Rust API's
  DeviceConfig the same field; apple-gfx-pci always sets it with
  use_iosurface_mapper and process_isolation. Each task made under it logs
  whether it runs isolated or in process, and device info logs each change
  of its argument-buffer answer.
- reims-ctl's q35-x86_64 profile adds
  apple-gfx-iosurface-pci,id=iosfc,gpu=gfx,addr=0x6; vmware-svga and
  vmapple VMs are unchanged. reims-ctl and QEMU from this commit go
  together, as its installer installs them.
- On Linux, the detach heap's temporary and a writable alias with zeros
  past its pages come from a range of a file of the library's own, so the
  Vulkan platform can alias and import them; QEMU no longer ends at an
  x86-64 guest's first such heap. macOS is unchanged.
- The first command given to a task whose service has died writes one
  warning naming the task.
- scripts/qtest_iosurface_pci.py checks the device under qtest (27 checks).

Checked: cargo xtask check and the suite on the M3 Max; reims-ctl's install
and a cold boot on um780; stock, reims-util and ported-driver guests booted
on gem10 and ms01 with the isolation rule, Apple's driver's tasks in
process at about 62 fps, the port's isolated.
2026-10-17 06:43:31 +03:00
..