Files
ARMSX2/common
Brian Degenhardt 77d008af1d iOS W^X: route every JIT code write through the dual-map RW alias
Port the W^X protocol from the previous ARMSX2 recompilers (aR*/aVU) onto
the transplanted JIT so it runs under all four DarwinMisc JIT modes:
Simulator (MAP_JIT + pthread_jit_write_protect_np toggle), iOS 26 LuckTXM
and LuckNoTXM (vm_remap dual-mapping, writes at rx + g_code_rw_offset),
and Legacy (mprotect RW/RX toggle, iOS <= 18).

- AsmHelpers: export armGetWritableCodePtr (RX -> RW alias, identity off
  Apple); armStartBlock/armEndBlock switch to BeginCodeWriteRange with a
  1 MiB Legacy write window and construct the MacroAssembler over the RW
  alias while armAsmPtr stays the RX base, so armGetCurrentCodePointer()
  and all displacement math remain in execute space; armEmitJmpPtr and the
  constant-pool trampoline/literal writes go through the alias with their
  own write scopes.
- Arm64BaseBlocks::PatchAtomic (block linking + exception-path unlink) and
  recPatchIslandB store via the alias; displacements/icache flushes stay RX.
- RecStubs fastmem backpatch stores the redirect B via the alias.
- microVU: the persistent per-VU MacroAssembler is built over the alias of
  prog.x86start; ProgCache hydration fixups patch through the alias while
  Rel26/ADRP math keeps using the RX chunk address.
- recExecute re-arms Legacy-mode execute protection via
  DarwinMisc::LegacyEnsureExecutable (mirrors the previous recompiler).
- BeginCodeWrite/EndCodeWrite skip the macOS MAP_JIT toggle when a
  dual-mapping is active (offset != 0), matching the iOS branches.
- CI validation without an iOS device: ARMSX2_FORCE_DUAL_MAP=1 now also
  works on macOS (Memory.cpp routes the code arena through
  DarwinMisc::MmapCodeDualMap, which builds the vm_remap RW alias there),
  and the macOS workflow reruns recompiler_tests under it, forcing every
  emission/patch path through the alias. Production macOS keeps MAP_JIT
  with offset 0, unchanged.

Linux/Android paths compile to identity no-ops. Gates: recompiler_tests
1359/1359, gs_vertex_tests 21/21, mvu_progcache_versioning_tests 13/13.
2026-07-19 17:18:39 -07:00
..
2026-07-09 23:01:22 +02:00