fix(libkernel): replace partly overlapped allocations with a fixed mapping #1370
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1370"
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 gjonn on 2026-10-08T00:35:29Z.
What
A fixed mapping (
MAP_FIXED, without no-overwrite) replaces existing mappings on the console, as on FreeBSD.sceKernelMapDirectMemoryand the anonymous/flexible paths already did that when the new range lay entirely inside registered allocations (RemapFixedIntoRegistered), but threwfixed mapping ... overlaps a registered guest allocationwhen it only partly overlapped them. They now unmap the overlapped registered pieces (the same path assceKernelMunmap, factored intoUnmapRegistered) and then map. Fixed no-overwrite mappings are unchanged (#994:ENOMEMover live memory).A title maps 32 MiB of direct memory at
0xf410000000, releases the physical memory without unmapping, places a fixed 6 MiB mapping inside the old range, and then a fixed0xa600000-byte mapping at0xf410e00000, which starts on the remaining 18 MiB of the old allocation and extends past its end. This aborted the title intermittently 13-20 s after start.Tested
CheckFixedMappingReplacesPartialOverlapinGuestMemory.cpp(a fixed 3-page mapping over a live 1-page allocation and two free pages). It fails onmainwithfixed mapping 0x200000000+0xc000 overlaps a registered guest allocation 0x200000000+0x4000and passes with this change;guest_memoryandguest_ampr_markerspass.Not addressed here:
GuestAllocationsUnmapstill throws when the range crosses a hole inside one allocation (for example a reservation whose tail was already unmapped); that is a separate topic.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)