From 74c0f2127aa4604110154f39c63ee67884c424e4 Mon Sep 17 00:00:00 2001 From: MaxsTechReview Date: Sun, 8 Nov 2026 10:43:57 -0500 Subject: [PATCH] fix(proot): lay out ARM64 programs like the kernel so large reservations fit (#2279) --- tools/proot/PATCHES.md | 10 ++++++++++ .../0026-arm64-kernel-program-layout.patch | 17 +++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 tools/proot/patches/0026-arm64-kernel-program-layout.patch diff --git a/tools/proot/PATCHES.md b/tools/proot/PATCHES.md index ddb3278d7e..cc120bd3e4 100644 --- a/tools/proot/PATCHES.md +++ b/tools/proot/PATCHES.md @@ -142,6 +142,16 @@ Prototype (inert unless `PROOT_FASTPATH` is set; see `docs/development/proot-per `statx` (`newfstatat`) and `memfd_create`. Syscalls outside the trampoline and sessions without `PROOT_FASTPATH` are unchanged. `bench/statx-trap.c` traps `statx` and checks an existing directory still reads as one. +- `0026-arm64-kernel-program-layout.patch` - on ARM64, PRoot put its loader at 128 GiB, a PIE + program at 192 GiB and its interpreter at 252 GiB. Android kernels give a process a 39-bit + (512 GiB) address space, so those three split the low half into holes of 64 GiB or less, and a + program that reserves one large contiguous range there could not get it. The Linux kernel loads + a PIE program at two thirds of the address space (`ELF_ET_DYN_BASE`, 0x5555555000 with 39 bits) + and keeps the range below it free; the loader, program and interpreter now sit there too, which + leaves 64 GiB to 336 GiB free as on a native kernel. Switch emulators that run guest code + natively reserve 256 GiB above 64 GiB for guest memory: under PRoot the reservation failed and + the first guest instruction faulted forever. 48-bit address spaces and 32-bit programs are + unchanged in practice. Old kernel fixes: diff --git a/tools/proot/patches/0026-arm64-kernel-program-layout.patch b/tools/proot/patches/0026-arm64-kernel-program-layout.patch new file mode 100644 index 0000000000..57e05e452d --- /dev/null +++ b/tools/proot/patches/0026-arm64-kernel-program-layout.patch @@ -0,0 +1,17 @@ +diff --git a/src/arch.h b/src/arch.h +index 06b7f1b..db129a9 100644 +--- a/src/arch.h ++++ b/src/arch.h +@@ -135,9 +135,9 @@ typedef unsigned char byte_t; + #define OFFSETOF_STAT_UID_32 24 + #define OFFSETOF_STAT_GID_32 28 + +- #define LOADER_ADDRESS 0x2000000000 +- #define EXEC_PIC_ADDRESS 0x3000000000 +- #define INTERP_PIC_ADDRESS 0x3f00000000 ++ #define LOADER_ADDRESS 0x5400000000 ++ #define EXEC_PIC_ADDRESS 0x5555000000 ++ #define INTERP_PIC_ADDRESS 0x5f00000000 + #define HAS_POKEDATA_WORKAROUND true + + #define HAS_LOADER_32BIT true