fix(libkernel): ignore MAP_EXCL in fixed anonymous mmap as measured on a PS5 #11173
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/11173"
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 p3n1cillin on 2026-10-25T20:35:24Z.
What
mmapwithMAP_FIXED | MAP_EXCLfollowed FreeBSD 11.4: over an occupied range or a reservation it failed withENOMEMand left the range alone. The console behaves differently.Prospero Win (PPSA99995) records this in patch 0570: the PS5 kernel accepts
MAP_EXCLbut ignores it.MAP_FIXED | MAP_EXCL | MAP_PRIVATE | MAP_ANONover an existing mapping replaces it without error, measured on firmware 12.02. Wine's initial reservations unmapped the title's own code that way, which is why that patch moved Wine tosceKernelReserveVirtualRangewith the no-overwrite flag.A title that relies on the console's behaviour gets
ENOMEMhere where the console succeeds.mmap: now acceptsMAP_EXCLand ignores it, so the range is replaced and zeroed exactly as withMAP_FIXEDalone.MAP_EXCLwithoutMAP_FIXED: stillEINVAL, following FreeBSD. That case is not measured.sceKernelReserveVirtualRange's own no-overwrite flag and the other mapping calls are unchanged.Tests that pinned the FreeBSD result now expect the console's:
GuestMemory:MAP_EXCLover a mapped page and over a reservation succeeds and zeroes the range, and the neighbouring pages keep their contents.GuestLowAddressMemory: the same over a low-address mapping.GuestKernelStackProtect(Windows): the case expectingMAP_EXCLover a stack page to be refused is removed. PlainMAP_FIXEDmay replace that page, so withMAP_EXCLignored it isn't a refusal.Tested
main7a25f87620: all 395 tests registered by libc and libkernel pass.guest_memoryandguest_low_address_memorypass.tools/check_conventions.py --base origin/mainpasses.tools/pr_overlap.pyreports only #10192, which rewrites the same libkernel debt entry for failed fixed reservations without changingMAP_EXCL. The two only conflict in that line's text.MAP_EXCL, so no title run shows the difference.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T20:42:17Z.
Review: COMMENTED
I reviewed the change at head
8df80bdc3f124a86d1fe1a4fe6e12709569af1a7. The fixed-anonymous path now stripsMAP_EXCLbefore calling the shared remap machinery, while retaining the existingMAP_EXCL-without-MAP_FIXEDvalidation. The revised tests cover replacement of both a committed mapping and a reservation, zero-fill, and the non-fixed invalid case. I did not find a concrete issue in this narrow change.tools/check_conventions.py --base upstream/main --head HEADcompleted with no errors (it emits the existing long-debt-entry warning), andgit diff --checkpassed. The PR reports passing Windows and focused Linux memory tests and includes the console behavior evidence; I have not reproduced the PS5 measurement. Hosted eligibility, conventions, intake, labels, and report passed, while product build jobs were skipped. This is a comment-only review, not an independent platform approval.Imported from boykopovar/AnyPS5. Originally posted by klosixgaming-arch on 2026-10-25T21:45:48Z.
Review: COMMENTED
Reviewed head
8df80bdc3fby reading the diff and the existing review thread. I did not build or run this, so everything below is from the code, not from a test of mine.What it does. Fixed anonymous
mmapwithMAP_EXCLnow ignores the flag: the range is replaced and zeroed as withMAP_FIXEDalone, instead of failing withENOMEMand leaving the range alone.MAP_EXCLwithoutMAP_FIXEDis stillEINVAL. The code change is small and clean:placementis justMAP_FIXED, andDoMapAnonis called withexclusive = false.My concern is the evidence, not the code. This flips behaviour from FreeBSD 11.4's (documented, safe) to a destructive one, so the quality of the measurement matters. The PR cites patch 0570 of Prospero Win, a Wine patch, whose comment says the PS5 kernel "accepts
MAP_EXCLbut ignores it", measured on firmware 12.02. That is a second-hand report from another project's patch, not a measurement in this repo, and the PR says no title run shows the difference ("Prospero Win itself no longer usesMAP_EXCL"). Titles that probe withMAP_EXCLexpecting failure would now overwrite a live mapping silently.Asks:
GuestMapExclusiveorGuestMapNoOverwriteconstant inPosixMemory.cpp; with-Werroran unused constexpr in an anonymous namespace may or may not warn on the supported compilers.The overlap with #10192 is real but, as MarcZX10 checked, only in the text of one debt line.
I would approve once point 1 is settled one way or the other. I am not blocking because the PR describes its source honestly.
AI-assisted: yes. Written with AI assistance and reviewed by me.
Imported from boykopovar/AnyPS5. Originally posted by klosixgaming-arch on 2026-10-26T07:21:19Z.
Review: APPROVED
Re-reviewed head
2387f0ece7by reading the diff since my first review. I did not build or run it.My three points are addressed. The debt entry now says the behaviour is reported by Prospero Win (firmware 12.02) and not measured here, and that the no-
MAP_FIXEDcase is not measured either. The test now checks that the pages before each replaced range keep their bytes. The constants are still in use. Approving, with the usual caveat that the claim is second-hand until someone measures it on a console.AI-assisted: yes. Written with AI assistance and reviewed by me.