Linux: direct-memory mappings with addr == NULL get a top-down address, and titles that require the low window assert at start-up #692
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 jeffrey12cali on 2026-10-05T16:02:20Z.
Symptom. Running a Unity PS5 title on the Linux back end, the very first
sceKernelAllocateDirectMemory+sceKernelMapDirectMemory2pair (256 MB,prot=0xf3,align=0x200000,type=12) succeeds, but the title immediately re-issues the identical request andthen aborts inside its own allocator (a
call+ud2assert, not a kernel error).Root cause. The title passes
addr == NULLand expects a low virtual address. On Windows theguest arena supplies one: the first mapping lands at
0x200000000and later regions followcontiguously. On Linux
MapPlaced()(core/libs/prx/libkernel/DirectMemory/DirectMemory.cpp) fallsthrough to
mmap(nullptr, ...), so the caller gets a top-down0x7f...address, rejects it andretries; the retry trips the allocator's bookkeeping assert.
Measured with the
map directtrace on both platforms:sos_runtime.exe)0x200000000+0x10000000reserve 0x210000000+0x1000000x7fffdb200000+0x10000000map directof another 256 MB, then SIGABRTFix we use locally. A Linux-only low arena: reserve
0x200000000for 16 GiB withMAP_FIXED_NOREPLACE | PROT_NONE | MAP_NORESERVEonce, then bump-allocate alignedMAP_FIXEDchunksinside it when
MapPlaced()is called with no requested address; fall back to the current behaviour ifthe reservation fails. After that, mappings land at
0x200000000/0x210000000exactly as on Windowsand the start-up assert is gone.
Questions. Is there an intended Linux placement policy for direct memory (matching the Windows
guest arena)? Would you take a patch that adds a low-window reservation, ideally behind the same
knob that decides the Windows arena base? Happy to open a PR.
Imported from boykopovar/AnyPS5. Originally posted by alfalfa-star on 2026-10-05T18:32:53Z.
A second title hits the same gap, through flexible memory rather than direct memory: LEGO Horizon Adventures (PPSA14632, Unreal Engine), which bundles its own
libc.prxandlibSceNpCppWebApi.prx.Symptom. On Linux the title segfaults in its online subsystem while preparing
sceNpSessionSignalingInitialize: one of its interface pointers was never set.Cause. The bundled
sce::Np::CppWebApi::Common::initializemaps its 0x80000-byte heap withsceKernelMapNamedFlexibleMemory(prot 2, no address), gets a host address (0x7ffff197c000), and passes it tosceLibcMspaceCreatein the title's ownlibc.prx. That function returns NULL, soinitializereturns0x80553504and the interface is not created. Per the disassembly of the bundled libc, mspace creation only accepts a base and capacity that lie in one of two windows:base >= 0x400000andbase + capacity < 0xFC_0000_0001, orbase >= 0x800_0000_0000andbase + capacity < 0xF00_0000_0001So any title whose libc builds an mspace on memory it maps without an address cannot work while Linux places such mappings top-down.
Check. As a local experiment only,
MapPlaced()on Linux with no address returnedMapAtOrAbove(0x200000000, ...)instead ofmmap(nullptr, ...). The title's direct memory then lands at0x200000000 - 0x81c0000000(as on Windows),initializesucceeds, the segfault is gone and it runs on to an unrelated missing export. A Linux arena at the Windows base with the same end as the Windows arena would cover both ranges this libc accepts in the first window.Tested on Arch Linux, GCC 16.2,
mainat33e9a121plus #672, #580, #722, #723, #730 and #734. Happy to run a Linux arena PR against this title.Imported from boykopovar/AnyPS5. Originally posted by jeffrey12cali on 2026-10-05T23:21:50Z.
Confirmed on our side, and opened as a draft PR: #780 (first commit).
The low-window reservation makes Linux match the Windows back end for this title:
@alfalfa-star your two-window analysis of
sceLibcMspaceCreateis consistent with what we see, and thereservation here is
0x200000000+ 16 GiB (MAP_FIXED_NOREPLACE,PROT_NONE,MAP_NORESERVE, thenaligned
MAP_FIXEDchunks), so bothMapPlaced()users - direct memory and flexible memory - landinside your first accepted window (
base >= 0x400000,base + capacity < 0xFC00000001). If you wouldrather land a Linux-arena PR for the flexible-memory side, say so and I will keep #780 to the direct
memory path and rebase onto yours.
Progress this unblocked: the start-up assert is gone and the title now reaches on-screen output - the
PS boot logo and the publisher (MCS) logo, holding ~60 FPS, with
vo459 /agc204 /pm4900,which are the same counts the working Windows build of the same commit produces.
Imported from boykopovar/AnyPS5. Originally posted by jeffrey12cali on 2026-10-10T11:07:36Z.
Closing the loop on this issue: #861 merged today, so the direct-memory case in the title is fixed on
main—addr == NULLmappings inside the PS5 window now land in the low arena instead of getting a top-down address.I want to be precise about what that does and does not cover, because @alfalfa-star's report is a different
mechanism. #861 places the guest address space; it does not change how flexible memory allocates. So the
PPSA14632symptom described above (bundledlibc.prxandlibSceNpCppWebApi.prx, segfault in the onlinesubsystem while preparing
sceNpSessionSignalInvitation) is not something I have tested and I am not claimingthis issue covers it. If anyone can retest that title on current
main, it is worth knowing whether thefailure is now the same one or a separate flexible-memory gap.
For our own reference on the direct-memory side:
PPSA28997reaches its main menu and holds 60 FPS through 15minutes of continuous play on a tree that carries this change.