Guest memory is a private anonymous reservation (plat_vm_reserve), and memory mapped at two guest addresses comes
from a memfd mapped shared (the alias pool, plat_posix.c). An owned span is moved into the pool when its trap is
made (mem.c's promote_nl), so it has a mirror (plat_alias_host) and its edge pages keep the CPU's bytes in the
page cache. The move is no write: plat_alias_map keeps what write tracking says of each page of the range
mem_own_prepare froze, as plat_vm_share does for a dma-buf region (below). The pool's mapping is registered with
the write watch before the trap takes it out of the scans, and a scan on another thread between the two would report
every moved page: marked after the result published there took its baseline, they would read as the CPU's writes, and
the image stored there again would keep memory's bytes on them.
MADV_DONTNEED). A guest access then blocks the faulting thread in the
kernel. A handler thread, in ordinary thread context, lands the GPU data through the mirror and installs the page
with UFFDIO_CONTINUE. No Vulkan call, lock or allocation runs in a signal handler.plat_ww_scan skips them. A span the
trap lets go is mapped with UFFDIO_CONTINUE and registered for write tracking again while no scan runs: it reads as
written once, with what the woken thread writes.plat_trap_arm never unregisters a page that is in minor mode already: it registers the range in minor
mode first, and only on EBUSY lets go of the write watch's runs on it (PAGEMAP_SCAN, PAGE_IS_WPALLOWED). A
thread woken by an unregister would map the page with the CPU's bytes before the register, with no fault for the
new owner. Then plat_trap_arm wakes the range it arms, and such a thread faults again into the new owner
(tests/memory_own.c's test_rearm_sleeper).UFFD_USER_MODE_ONLY (needed without privileges) means a system call that reads or writes an owned page from the
kernel gets EFAULT rather than a fault. Every system call that takes a guest pointer and pread/pwrite on the
pool first acquires the range (own_acquire): fs.c's IFile Read and Write and IStorage Read (the RomFS, a DLC's,
a file's), bsd.c's receives and sends. The rest copy through host buffers or touch guest memory in user mode
(TLS through OpenSSL, DNS, LDN, audio, the services' replies), which faults and lands.PAGEMAP_SCAN 6.7. Debian 13 (6.12) has all of them.A Linux host without minor faults (older kernels, Android's 5.10 kernels, or any Linux with memory_traps=1)
uses Skyline's own shape: plat_trap_arm makes the span's views inaccessible with mprotect, and the SIGSEGV
handler, checked before the crash handler, posts the page to the trap's own thread through a lock-free ring and waits
on a futex. That thread lands it as the userfaultfd's would, and plat_trap_continue opens the pages and wakes the
waiters, whose accesses then go again. Nothing but atomics, mprotect and futexes runs in the handler. FreeBSD and
macOS have no alias pool yet, so no mirror and no traps.
Made from docs/layers/gpu/ownership.md at 69237645142c. GPL-3.0-or-later.