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:
AS_TOP (512 GiB), which the tables indexed by them are sized for, so they fit in
39 bits. NCE's address space is at most the console's 128 GiB layout (AS_MAX), its 64 GiB alias region among
them, which Android's moved layout keeps from any base up to 384 GiB; where none of those is free a smaller tier
takes it, with a smaller alias region (32 GiB in 64, 16 GiB in 48). Without NCE the game gets 512..nce brought from Linux ends the game
with the base it found. The NPDM has no ASLR bit to ask for fixed code otherwise (Eden reads bits 0 to 3 of its
flags, the 64-bit bit and the address space type).mem_place): in it, below its base (an address the
move left out) or past its end (one a layout smaller than the console's 512 GiB does not hold), and how far.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.