feat(libkernel): accept MAP_ALIGNED_SUPER in mmap #1909
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1909"
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 TheAggie on 2026-10-08T23:23:37Z.
What
mmaprejected any flag beyondMAP_PRIVATE | MAP_ANONfor anonymous mappings. Quake II (PPSA99007, the Yamagi-based homebrew port) addsMAP_ALIGNED_SUPER(0x1000000, FreeBSD'sMAP_ALIGNED(1)) to its hunk allocations of 2 MiB and more.With that flag, an anonymous private mapping is now placed on a 2 MiB superpage boundary.
DoMapAnontakes the alignment, defaulting to the 16 KiB page as before, and passes it to the existingMapAligned. Other flags are still rejected.Test (
guest_memory): aMAP_ALIGNED_SUPERmapping of 2 MiB + one page is 2 MiB aligned, writable at both ends and tracked with its full size, and unmaps. Another unsupported flag combination (0x2001002) is still rejected.Tested
Windows 11 Pro (26200), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release.
mainwith this PR and four other small PRs of mine merged together (SCHED_OTHER priority range, MAP_ALIGNED_SUPER, the compatible pad vibration mode, empty-PT_TLS stack-guard reads, pthread_attr scope/getters). It was run from the generatedCTestTestfile.cmakecommands because antivirus blocksctest.exeon this machine.tools/check_conventions.py --base origin/mainpasses on this branch alone.Not tested on Linux or macOS.
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
Imported from boykopovar/AnyPS5. Originally posted by klosixgaming-arch on 2026-10-09T00:40:56Z.
Review: APPROVED
Clean, correct support for
MAP_ALIGNED_SUPER(0x1000000) in the anonymousmmappath: the flag is accepted on top ofMAP_PRIVATE|MAP_ANONYMOUS(any other bit still returns ENOTSUPPORTED/45), the 2 MiB superpage alignment is threaded throughDoMapAnon→MapAligned, and the default staysPS5_PAGE_SIZEso existing callers are unaffected. The test verifies the returned pointer is actually 2 MiB-aligned, that the fullsuperpage + pagespan is readable/writable as a single allocation, and that an unsupported flag combination is still rejected.Written with AI assistance.
Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-09T02:58:10Z.
Review: COMMENTED
Verified on Linux — and this one has a behavioural differential.
guest_memory_testsbuilds and passes, exit 0.DirectMemoryfiles back atmainwith the test kept, rebuilt the same way → the test aborts, exit 134 (itsRequireisstd::abort()), i.e. onmainthe flag is still refused. So both the acceptance and the superpage placement come from this change.Claim cross-check:
DoMapAnontakes the alignment and defaults it toPS5_PAGE_SIZE, the anonymous path passesSuperpageSize(2 MiB) only whenGuestAlignedSuper(0x1000000) is set, and the guard became(flags & ~GuestAlignedSuper) != (GuestPrivate | GuestAnonymous)— every other flag is still refused. The test covers both halves: a 2 MiB + one page mapping lands on a 2 MiB boundary, is writable at both ends and tracked at its full size, and0x2001002is still rejected.Two notes:
MAP_ALIGNED_SUPERfinds nothing in the tree, because the code calls itGuestAlignedSuperandSuperpageSize. Worth spelling both out in the body, since a future reader will search the FreeBSD name.*addr != nullptr)?MapAlignedreceives*addr, and the test maps with a null hint — if a hint can win over the superpage alignment, a caller checking its own alignment would see something else.The title is named (Quake II PPSA99007).
Not verified: Windows, the author's platform.
Written with AI assistance.
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-09T20:14:48Z.
Same as #1868: Quake II stops at
system(#1859) andmkstemp(#1613) on main first. Please reopen when it reaches themmapcall.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T08:44:55Z.
Checked on Linux: build and ctest green (
guest_memorypasses); with the three non-test files reverted the new test fails, so it covers the change. Other flag bits are still rejected, and the default alignment is unchanged. Confirmed also by @Dextroid17's A/B run. Regarding the note about Quake II stopping earlier: the change is generic and correct on its own, so merging.