Relinked executable lies outside the guest arena, so JITs cannot reserve memory near their code (PS5CEMU-HAR's Azahar) #5217
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by YossiYad on 2026-10-13T14:54:08Z.
PS5CEMU-HAR (PPSA99360, catalog 3.5.0) cannot start its 3DS emulator: Azahar's JIT wants its code buffer within 2 GiB of the executable's code, and the relinked executable is loaded at a host address outside the guest arena, so no guest mapping can be that close.
How it shows up. Linux (Fedora 44 distrobox, GCC 16, Release), RX 7700 XT,
main0f2683cbwith #4514, #4469 and #4467 applied (the title's three earlier stops; #3787 is merged). The launcher runs at 60 fps. Launchingftpd.3dsx(mtheall/ftpd v3.2.1, GPL) from the 3DS side:what(): mapping address hint is above the guest address space arena. The core dump shows the title's code callingsceKernelReserveVirtualRangewith noMAP_FIXEDand the hint0x564c90000000, from a loop that steps 64 MiB at a time through the 2 GiB around its code (DoReserveVirtual→MapPlaced→GuestArenaAllocateAtOrAbove).vm_map_find_min), nothing throws: the reservation lands inside the arena, the title's allocator finds it too far from its code, and it reportsftpd pro did not start: Azahar did not start: can't alloc(Xbyak's allocation error) and returns to its library.Why. On the console the executable sits low in the application area, so a hint derived from a code address is an ordinary guest address. Here the relinked
app.elfis a host PIE (0x564c...in this run), above the arena's end at0xFC00000000. Fixed mappings outside the arena are refused (fixed mapping is outside the guest address space arena), so the title cannot place its JIT memory near its code either way.The same applies to any title or emulator whose JIT uses
rel32calls into its own executable (dynarmic and Xbyak-based code buffers do), and Cemu on the Wii U side of the same title reserves through the same path (port/cemu/MemMapperPS5.cpp).Question for the maintainers. Should the executable (and its modules) be loaded inside the guest arena, where the console would place them, or should mappings near a host-loaded executable be allowed outside the arena? Both touch the loader and the arena's guarantees, so I have not started on either.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-13T15:01:31Z.
I traced the current Linux path to clarify the scope of #5218.
GuestArenareserves the console application interval (0x2_0000_0000through0xfc00_000000) and records existing host mappings there as occupied.MapPlacedthen allocates non-fixed guest mappings from that arena. So the fallback in #5218 can make the reservation succeed, but it cannot put the result within 2 GiB of a PIE executable mapped above the arena, as in the reported0x564c...run. Simply allowing arbitrary out-of-arena mappings would also need defined behavior for guest containment, protection, unmap, and memory tracking. This looks like a separate loader/address-space design decision: constrain the host executable placement into a suitable guest range, or add a separately tracked near-code mapping region. I have not established which is compatible across Linux, Windows, and macOS.Imported from boykopovar/AnyPS5. Originally posted by YossiYad on 2026-10-13T16:39:15Z.
A second title that depends on where the executable sits, and it gives the console address: Ruffle Flash (PPSA68091, catalog 1.2.0) segfaults on Linux
main0214069eright after its ownRuffle PS5: jailbreak oklog line.Its early init (
ruffle_ps5_early_init) opens/app0/imports.txt(362 lines,00000000024d5370 _init_env, ...: the GOT slot of each import, relative to image base 0), reads each line withfscanf("%lx %127s"), and checks*(0x400000 + offset) != 0, printingRuffle PS5: unresolved import: %sotherwise (cmpq $0x0,0x400000(%rax)at the crash). So it assumes the executable's image base is0x400000, as the console loads it. Here the relinkedapp.elfis at0x55e555760000, so0x400000 + 0x24d5370is unmapped and the read faults.That makes two shapes of the same dependency: PS5CEMU-HAR's JIT wants memory near the code, and Ruffle reads its own GOT at the console's absolute address. Loading the executable at its console base would cover both; a near-code mapping region would cover only the first.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-13T22:18:15Z.
The second report strengthens the evidence, but I checked the current allocator and there is a constraint to reconcile before choosing a base.
GuestArena.cppstarts the arena at0x200000000(8 GiB), andAllocateAtOrAboveclamps lower hints to that start. If the executable were fixed at Ruffle’s0x400000, a JIT request near its code would still be placed at least about 8 GiB away, beyond the reported 2 GiB search window. Conversely, putting the executable inside the arena would leave Ruffle’s hard-coded0x400000 + GOT offsetreads unmapped unless we also provide a compatible alias or relocation strategy. So these two reports do not appear to be solved by one simple fixed image base; the loader and arena design needs to account for both constraints.Imported from boykopovar/AnyPS5. Originally posted by 0xRickx on 2026-10-15T15:49:26Z.
A third title that needs console-like addresses, in a different shape: Super Mario Sunshine (PPSA99312, catalog 0.10.0, griches/PS5_Sunshine) needs memory below 2 GiB.
On Windows
main92e50418with #6220 (its earlierunamesysctl stop), it exits 2 s in:The game code is not published, but the port's probe title is (
ps5/probe/memprobe.c). It says the PC port keeps every address the game can see in 32 bits, and it shows what it asks the console for: a plain anonymousmmapwith a low hint and noMAP_FIXED(64 MiB at0x20000000, a 128 MiB stack pool at0x40000000; the comment notes that the title'slibc.prxsits at0x80000000and that a hint is taken when the range is free), thenpthread_attr_setstackon that pool.Two things stand in the way here:
mmap_nid_postfixdrops the hint of a private anonymous mapping withoutMAP_FIXED(PosixMemory.cpppassesnullptron toDoMapAnon), so the hint handling from #5218 never sees it.0x200000000(GuestArena.cpp), so nothing below 2 GiB can be returned.So the address-space decision would need to cover low 32-bit guest mappings too, besides memory near the code (PS5CEMU-HAR) and the image at
0x400000(Ruffle). I can't check what the port does past this point: the next step needs the user's own disc image.AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by QRMOE on 2026-10-15T16:32:06Z.
@0xRickx I implemented the low anonymous mapping part in draft #6469, based on current main
0029e62f9. The regression uses the two sizes and hints from the public probe: main returns 0x200000000 / 0x204000000, while the branch returns 0x20000000 / 0x40000000 on this Windows host. Both changes are needed: forwarding mmap’s hint and extending the arena below 8 GiB. Unhinted allocations still start at 8 GiB. Libraries build and 25 related tests pass.I also found a separate next-step limitation: pthread_attr_setstack stores the supplied address, but scePthreadCreate does not use it on Windows or Linux. This PR only addresses allocation; it does not establish that the game runs or resolve the other titles’ high-loaded PIE/JIT placement.
Title tracking is now #6468, with #6220 and #6469 listed. If you can rerun the title with those patches, please post the next stop there; no disc image or other game assets need to be shared. Full Linux/Windows CI and title confirmation are still pending.