fix(libkernel): map non-fixed hints inside a reserved range in place #2907
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2907"
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-10T18:23:04Z.
What
Fixes #2687. Carry of ps54all's fix from that issue, with the race MarcZX100 found in review fixed (the reservation is now checked under the registry mutation).
A map without
MAP_FIXEDwhose hint lies wholly inside a range still reserved bysceKernelReserveVirtualRangeis placed at the hint, as a fixed map into the reservation would be. Hints outside reservations, or over a partly mapped range, stay hints.PPSA01474 reserves 64 GiB with no address, then maps direct memory with hints inside it and no
MAP_FIXED, and uses the hinted addresses. On main the maps land above the reservation and the title faults on thePROT_NONEreservation (#2704, bisected to #861):Tested
Linux (CachyOS, GCC), Release:
guest_memory,guest_kernel_*,guest_accessandapplication_heap_*pass. The newguest_memorycase fails without theDirectMemory.cppchange (GuestMemory.cpp:526).tools/check_conventions.pypasses. Merges cleanly with #2758, which changes where the reservation itself goes.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 EdouardSence on 2026-10-10T19:43:05Z.
Tested on Ratchet & Clank: Rift Apart (PPSA01474), the title from #2704 (closed as a duplicate of #2687). On this title the PR moves the crash rather than removing it.
Setup: CachyOS (kernel 7.2.9), RX 9070 XT (RADV), Release, headless gamescope with scripted input. This PR (
3444ebf5c) merged onto main4a747c487, nothing else.SEGV_ACCERR) about 12 s in, at the hinted address, as in #2704.si_code 128) insceAmprAmmCommandBufferMap, writing throughbase = 0xaaaaaaac00000000read from the guest'sCommandBufferobject at0x12c5700018. The object's memory holds a repeating{0x80, 0xaaaaaaac00000000}pattern instead of a command buffer.APS5_TRACE_MEMORY=1shows why:Of the 26 mappings that land inside the 64 GiB range, 3 pairs overlap:
0x12c56b0000+0x60000over0x12c5600000+0x104000, and0x12c6170000+0x800000over both0x12c6200000+0x104000and0x12c6600000+0x4000.0x12c5700018sits in the first pair.So here the title uses its address-less 64 GiB reservation as its own heap (it fills it with
remap fixedfrom the physical block it allocated right after), and separately hints direct maps just above its previous mapping. In #2704's trace before #861, the reservation went to0x7ef4ffe00000and the hinted maps landed on their hints, outside it. With #861 the reservation is placed right where those hints point. With this PR the hints are honoured inside it, so both users get the same addresses.So #2687's title wants a hint inside its own reservation honoured. This title needs its address-less reservation not to cover the addresses it hints next, and honouring the hint inside the reservation corrupts it. I don't have a PS5 placement rule to propose. Placing an address-less reservation away from the bottom of the arena, as before #861, would satisfy this title, but I haven't checked that against #2687's title.
Tested and written by Claude (AI assistant) on a contributor's machine.
Imported from boykopovar/AnyPS5. Originally posted by screamm on 2026-10-10T20:59:36Z.
Windows validation of the current head
3444ebf5merged ontomain56fb1b3b.Windows 11 Pro 26220, WinLibs MinGW-w64 GCC 15.2.0 r7, Ninja, Release,
BUILD_TESTING=ON, full build including thelibstarget.guest_memoryandguest_addresspass 3/3 (--repeat until-fail:3).ctest -j8 -E "^agc_|video_out"passes 388/388.main'sDirectMemory.cppand this PR's test,guest_memoryaborts atGuestMemory.cpp:542(the hinted direct map lands outside the reservation), so the new case detects the previous behaviour on Windows as well.Validation run with Claude Code assistance.
Imported from boykopovar/AnyPS5. Originally posted by EdouardSence on 2026-10-11T13:15:56Z.
Follow-up to my report above: on
maina11c8f7f, thesceAmprAmmCommandBufferMapfault at about 16 s no longer happens. Ratchet & Clank: Rift Apart (PPSA01474) runs the whole 120 s run without a fault (Linux, RX 9070 XT), so this PR is fine for it.Tested and written by Claude (AI assistant) on a contributor's machine.