The guest's addresses: moved above 64 GiB

The guest's addresses are the host's. An app's process holds the low 4 GiB (ART's heap, whose references are 32-bit, and its boot image), where the guest's code region lies at 128 MiB. On Android the whole layout moves up: the reservation takes the first base from 64 GiB, in 2 MiB steps, where a tier of the address space is free (mem_reserve_identity, as Eden takes its base above 36 bits in host_memory.cpp). Every region, the module's addresses (nce_module) and the .nce file's (kept from the first module's base) move with it. The log names the base: the code region from ....

Limits:

The guest's addresses share the process with ART's heap and JIT, the allocator and the GPU's driver. The reservation holds them all, so none of those is given one by an mmap of its own; one that maps over guest memory at a fixed address of its own would make memory the game's code reads and writes as its own. As the game's code starts, the log names anything there that is not the game's (mem_foreign: a mapping with a name, or a run nothing maps; the alias pool and a GPU's buffer that guest memory moved into are the runtime's), and a crash report names it again. With nce_foreign_scan=N (Debug, seconds) the kicks' thread looks again every N s while the game runs and logs each new finding once; off, it reads the setting and nothing else (nce_foreign_look). A plain anonymous mapping of another owner reads as the game's, so this diagnoses and guards nothing. The maps are read while other threads change them: a run they list as empty is asked again (msync) before it is named, and a failed read of them is no answer.

The path for the 36-bit games is to run the runtime outside ART: an executable child of GameActivity, as the driver already is (libscarletnx-run.so), whose low addresses are free. The window would come from the app over a socket (AHardwareBuffer). Built for API 29, such an executable could also take static TLS.


Made from docs/platforms/nx/nce.md at 69237645142c. GPL-3.0-or-later.