fix(libkernel): reserve the AMM virtual address ranges at the top of the guest arena #3281
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3281"
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 oneandonlydean on 2026-10-11T05:06:52Z.
What
Fixes #3146.
The AMM ranges (32 GiB plus the 32 GiB multimap range) were reserved address-less on first use, so since #861 they land at the lowest free address of the arena, directly after the title's last mapping. Titles keep mapping their heaps with hints just above their own mappings, and those hints now fall inside the AMM ranges. They are reserved at a fixed place instead: the last 64 GiB of the guest arena, which ends at the application map area end (
0xFC_0000_0000). Maps withoutMAP_FIXEDare placed lowest first, so neither they nor hints derived from them reach that end of the window. If the range is not free there, the reservation throws; nothing else is tried.Where the console puts the AMM ranges is not known. ampr_emu reads them from
sceKernelMapperGetParam, so they are the mapper's own ranges, not a reservation made in the title's map area. KytyPS5 puts them above the application area (0x800_0000_0000). Here every guest mapping has to be inside the arena, so the top of the arena is the place furthest from the title's own maps.The trace in #2704 shows the same thing. The address-less 64 GiB reservation at
0x12c2600000with alignment0x200000is this AMM reservation, not one the title makes. Before #861 it went to a host address (0x7ef4ffe00000) and the title's hinted maps landed on their hints. With the ranges moved, PPSA01474's heaps land on their hints again, outside the AMM ranges, whether or not #2907 promotes hints inside a reservation.TechnicalDebt's AMM line now says where the ranges are and that the console's addresses are not known.
Tested
Linux (CachyOS, GCC), Release with
BUILD_TESTING=ON, onmain06da117642:guest_ampr_markerscase: the AMM ranges end at the end of the arena, and maps hinted at 4 MiB steps above an address-less map land on their hints, outside the AMM ranges. It fails onmainatGuestAmpr.cpp:661(the ranges end where the lowest free 64 GiB ends, not at the end of the arena).guest_ampr_markers,guest_ampr_threads,guest_memoryand the otherguest_*/application_heap_*tests pass.agc_driver_dcc_keys_first_write, fails the same way onmain.tools/check_conventions.pypasses.0x4000000000hint did.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
https://claude.ai/code/session_01A2cY3SsTYnh4u4ZtEr2Adx
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T07:26:57Z.
Checked on Linux (GCC, Release) with the PR merged onto main: libs/libkernel ctest 94/94 green;
guest_ampr_markersfails without theApr.cppchange and passes with it. The TechnicalDebt line is accurate. Merging; @fma-rc, please confirm on PPSA01474.Imported from boykopovar/AnyPS5. Originally posted by fma-rc on 2026-10-12T01:27:17Z.
Late confirmation, sorry for the gap: Ratchet & Clank (PPSA01474) on
maina73a1af9c, which has this PR, no longer segfaults at 40 s. Linux, RTX 5080, two runs. Neither has a segfault; the longer one gets about 200 s in and then aborts onunmap address is not registeredfrom the title'ssceKernelMunmap, which is a different stop.