libkernel: non-fixed map hints inside a sceKernelReserveVirtualRange range are placed elsewhere #2687
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 ps54all on 2026-10-10T10:56:07Z.
PPSA01474 (Ratchet & Clank: Rift Apart) reserves 64 GiB with
sceKernelReserveVirtualRange(0x12c3000000+0x1000000000) and then maps its heaps inside that range with a hint and noMAP_FIXED(0x1307000000+0x204000, prot 0x42, flagsNO_COALESCE). The hint is not honoured: the range is mapped past the end of the reservation (0x22c3100000), the title keeps using0x1307000000, andsceAmprCommandBufferSetBufferfaults writing a command buffer object at0x1307200000.Cause:
DoMapDirectandDoMapAnontreat any address withoutMAP_FIXEDas a pure hint, even when the whole range is still reserved.Fix:
ps54all/AnyPS5:fix/libkernel-reserved-range-hint(one commit,fd39361b, onmaina29ef592). A non-fixed hint that lies wholly inside a still-reserved range is placed there, as a fixed map into the reservation would be; other hints are unchanged. Includes aguest_memorycase that fails without the change, and a TechnicalDebt line (the behaviour comes from the title, not a console measurement). Details and test results: #2667 (closed by the intake pause).Happy for anyone with intake access to carry it.
Written with AI assistance.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-10T11:59:02Z.
Concurrency review note for the proposed hint promotion
I reviewed the
PlaceHintInReservationchange from #2667 against currentmain. One race may make the hint fixed after its reservation is gone:Reserved(addr, len)returns true andPlaceHintInReservationaddsMAP_FIXEDGuestAllocations::Mutation, releases/unmaps the reservation, then releases the rangeMutationwith the staleMAP_FIXEDflag;ReplaceFixedOverlapcan unmap the new mappingDoReserveVirtualandUnmapRegisteredupdate the reservation map while holdingGuestAllocations::Mutation. CouldPlaceHintInReservationbe called after constructing theMutationin bothDoMapDirectandDoMapAnon, beforeFixedNoOverwriteConflictandReplaceFixedOverlap? That would make the reservation check and map operation share the registry mutation lock, following the existing mutation-then-reservation-lock order.The added
guest_memorycase checks the serial behavior; it would not catch this interleaving. I have not run this branch or reproduced the race, so this is a source-level concurrency concern for review rather than a confirmed runtime failure.Imported from boykopovar/AnyPS5. Originally posted by ps54all on 2026-10-10T14:09:46Z.
Thanks, that interleaving is real: the reservation check ran before the registry mutation was taken. Fixed on the branch:
PlaceHintInReservationnow runs afterGuestAllocations::Mutationis constructed in bothDoMapDirectandDoMapAnon, so the check and the map share the mutation, asFixedNoOverwriteConflictalready does (g_reservationLockstays a leaf lock under it). Branchfix/libkernel-reserved-range-hintis rebased onto currentmain(head987be674). The serialguest_memorycase still passes; like you, I have no deterministic test for the race itself.Written with AI assistance.