OS cooperation and the Horizon boundary

Rosetta's macOS path has cooperation from the platform that it targets. Apple documents kernel involvement in loading translated processes and a system service for AOT artifacts. This is an architectural advantage, not a service that ScarletNX can assume from Linux or another host OS. See Apple's Rosetta 2 platform security documentation.

Horizon supplies its own kernel and service contracts. It provides no compatibility contract for substituting Linux, Windows or another host. The practical requirement behind treating Horizon as uncooperative is to preserve its observable behavior at each boundary. This plan makes no claim about the intent behind Horizon's design. Its SVCs include handle operations, address arbitration and memory mapping, which cannot be replaced by matching host calls on the basis of a name alone (Switchbrew SVC reference).

ScarletNX supplies this behavior in src/nx/hle/ and src/nx/memory/. Its existing code shows why translation speed alone is insufficient: src/nx/hle/kernel/thread.c manages guest cores and scheduling, src/nx/hle/kernel/ipc.c implements IPC, and src/nx/memory/own.c coordinates guest accesses with GPU-owned pages. Generated code enters this runtime through RtAPI, including RtAPI.svcs (src/common/cpu/recompiler/llvm/ir_codegen.c).

BoundaryContract required before an optimization
Guest calls and linked SDK codeExplicit register, stack and callback rules, plus a path for nonlocal returns and runtime re-entry. AAPCS64 alone does not describe an SVC or an arbitrary hand-written guest routine.
SVC and IPCHorizon results, handle ownership, TLS buffers and blocking behavior must remain correct. Declared register arguments do not describe all memory or scheduling effects.
Threads and waitsRetain guest core, priority, wakeup and context rules through the host scheduler.
Memory and faultsRetain guest mappings and permissions, code invalidation, and GPU ownership. Host faults must be distinguished from guest faults and from deliberate ownership traps.
Shared SDK translation layerDefine entry points, guest layouts, TLS, callbacks, state visibility and version selection. Linking a layer does not remove the Horizon contracts below it.

Every optimization that crosses one of these boundaries must name its preconditions, its state synchronization points and a tested fallback. S1 cannot narrow state saves from hos.svc alone. R2 cannot run code directly merely because the host is AArch64. The same rule applies to the planned SDK translation layer: it is a maintainer-stated direction, not an implementation confirmed by this document. Keep the existing HLE path until replacement behavior is proven.


Made from docs/layers/cpu/plan.md at 69237645142c. GPL-3.0-or-later.