fix(libkernel): fail msync MS_INVALIDATE with EBUSY as measured on a PS5 #8728
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/8728"
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 orezraey on 2026-10-20T22:37:36Z.
What
msyncthrew forMS_INVALIDATEon a mapped range. The debt entry gave the reason: FreeBSD 11 returnsEBUSYonly when the range holdsmlocked pages, and locked pages are not tracked here.In a payload process on a PS5 (firmware 13.60),
MS_INVALIDATEon anonymous memory fails withEBUSYwhether or not any page is locked, presumably because the console never pages memory out. This PR returnsEBUSYthere:mmapmainbefore this PRMS_SYNC,MS_ASYNCMS_INVALIDATE,MS_SYNC | MS_INVALIDATEEBUSYEBUSYmlockof the first 16 KiBEBUSYEBUSYMS_INVALIDATEwith length 0, or ataddr + 1for 16 bytesEBUSYEBUSYMS_INVALIDATEover the range aftermunmapof a page inside itEBUSYEBUSYMS_ASYNC | MS_INVALIDATEEINVALEINVAL0x8MS_INVALIDATEorMS_SYNCaftermunmapof the whole rangeENOMEMENOMEMThe rows marked unchanged were already right. The range with a hole agrees with the existing rule that a page unmapped from inside a larger mapping still counts as mapped.
Debt: the
msyncentry indocs/dev/debt/libkernel.mdno longer says the call is unmeasured. It records theEBUSYresult and what was not measured: a title process, reservations, direct memory and flexible memory.How the console was measured
resolveline shows thatmsyncwas taken fromlibkernel_sys.sprxbydlsymand called through that pointer.mmap, with its first byte written.errnowas cleared before each call.mlockon the first 16 KiB, which succeeded.main.crenamed<probe>_main.c. The probe also measuredsceKernelSyncOnAddressWait, which is #8725.Console output (excerpt, lines copied unchanged)
Tested
Build: Windows 11 x86-64, WinLibs MinGW-w64 GCC 15.2.0 (posix-seh, ucrt, r7),
-DBUILD_TESTING=ON, onmaine25333e39.Tests:
guest_msyncpasses. It now checksEBUSYforMS_INVALIDATE, forMS_SYNC | MS_INVALIDATE, for length 0 and for a misaligned start, and that flag0x8succeeds.Old code, new test: with
PosixMemory.cppreverted tomain,guest_msyncaborts withmsync: MS_INVALIDATE is not implemented.Not run here: Linux and macOS.
Console: behaviour measured on a PS5 (firmware 13.60), as described above.
Overlaps:
tools/pr_overlap.pylists #8499, which adds an entry next to themsyncentry indocs/dev/debt/libkernel.md. No open PR changesmsync.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)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-20T22:43:21Z.
I reviewed the exact diff. The new
EBUSYpath is after the existing wrap, invalid flag combination, and mapped-range checks, so the testedENOMEM/EINVALbehavior remains intact; the updated test covers mapped invalidate, sync+invalidate, zero length, misaligned start, and the accepted unknown flag. The console measurement and debt entry also clearly limit what was observed. I found no issue in this focused change. I did not run a local build here; the hosted build jobs are skipped, so the Windows test and console probe remain the available runtime evidence.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-20T22:53:14Z.
Review: APPROVED
Reviewed the current diff at
692cb4af. The EBUSY result is returned after existing flag, range, and alignment validation, preserving the tested EINVAL/ENOMEM cases; regression coverage includes mapped invalidation and relevant validation edges. The PR reports PS5 payload measurements and its limitations. The metadata checks pass; platform build jobs are skipped, and I did not run a local platform build.Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-21T08:45:30Z.
Linux data point for
692cb4af09: WSL2 Ubuntu 24.04 (virtualised kernel, not bare-metal Linux), GCC 13.3.0, Release,BUILD_TESTING=ON, PR head alone (not merged ontomain).ctest -R '^guest_msync$'passes 3 of 3.core/libs/prx/libkernel/DirectMemory/PosixMemory.cpprestored to the merge-base (new test kept): fails (Subprocess aborted).Not tested: macOS, Windows, a title run.
AI-assisted (Claude Code).