Repository navigation
feat(libkernel): implement msync - #1857
Merged
Merged
Conversation
This was referenced Oct 8, 2026
|
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
|
9 tasks done
This was referenced Oct 8, 2026
msync follows FreeBSD 11's kern_msync and vm_map_sync over the guest's mappings as sceKernelVirtualQuery reports them: the address is rounded down to the page, a range that wraps and MS_ASYNC with MS_INVALIDATE are EINVAL, an unmapped start or page is ENOMEM, and length 0 checks the mapping that holds the address. The guest has no file mappings, so a successful call has nothing to write back. MS_INVALIDATE on a mapped range throws, since FreeBSD's EBUSY for mlocked pages needs lock state that is not tracked. EVO-PLAYER PPSA99039 v0.11.0 imports it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Collaborator
|
Checked The branch conflicted with |
9 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds
msyncto libkernel, next tommap,munmapandmprotectinDirectMemory/PosixMemory.cpp. It follows FreeBSD 11'skern_msyncandvm_map_syncover the guest's mappings assceKernelVirtualQueryreports them:kern_msync. A range whose end wraps isEINVAL.MS_ASYNC | MS_INVALIDATEisEINVAL. Other flag bits are not checked, as in FreeBSD.ENOMEM. Length 0 checks the mapping that holds the address (vm_map_syncwidensstart == endto that entry). Reservations count as mapped, since FreeBSD has a map entry for them.mmaponly creates private anonymous mappings, so there are no file mappings to sync.MS_INVALIDATEon a mapped range throws. FreeBSD returnsEBUSYthere when the range holdsmlocked pages, and locked pages are not tracked. TheENOMEMcheck comes first, as invm_map_sync.One limitation is recorded in TechnicalDebt with the rest: a page
munmaped from inside a larger mapping still counts as mapped, becausesceKernelVirtualQuerykeeps reporting the whole mapping after a partial unmap (onmaintoo).EVO-PLAYER PPSA99039 v0.11.0 (sainsaji/EVO-PLAYER-PS5) imports it for a mapped-file benchmark (
projects/evoplayer/src/evo_iobench.c,msync(p, len, MS_SYNC)). It's also in the absent lists of other titles in #1578, where it was claimed.Tested
687c0f0f…5349,eboot.binand the bundledlibc.prxunwrapped from their SELFs), relinked with--windowson Windows 11. Onmain364a56b with feat(libSceNet): implement sceNetResolverStartNtoaMultipleRecordsEx #1838, feat(libkernel): implement getdents and getdirentries #1634, feat(videoout): implement sceVideoOutGetResolutionStatus #1714 and feat(libkernel): implement the sigset functions #1641 merged locally (its earlier stops):FAIL: unresolved ELF import tZY4+SZNFhA from libkernel.prx(msync);KiJEPEWRyUY(sigaction, feat(libkernel): deliver sceKernelRaiseException on Linux #1431).guest_msynctest (Windows and Linux): success for the whole range,MS_ASYNC, an unaligned address inside the mapping, a range crossing a page boundary, length 0, an unknown flag bit and a reserved range, with errno untouched on success;EINVALforMS_ASYNC | MS_INVALIDATEand a wrapping range;ENOMEMaftermunmapfor the start, a range, length 0 andMS_INVALIDATE; theMS_INVALIDATEthrow on a mapped range.guest_msync5/5; full suite 482/482. Mutations, each with the test kept, all fail: the mapped check removed, theMS_ASYNC | MS_INVALIDATEcheck removed, the throw moved before the mapped check, and the wrap check removed.guest_msync5/5; full suite 488/488; the mapped-check mutation fails.mainae91d97:guest_msync3/3 on Windows;tools/check_conventions.py --base origin/mainpasses.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