Skip to content

fix(libkernel): fail _umtx_op operation 1 with EOPNOTSUPP as measured on a PS5 - #7842

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
ionut27001:fix/libkernel-umtx-op1-eopnotsupp
Oct 19, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
ionut27001:fix/libkernel-umtx-op1-eopnotsupp

Conversation

@ionut27001

Copy link
Copy Markdown
Contributor

What

_umtx_op operation 1 threw NotImplemented as unverified, so a title whose call_once path reaches it stops; the debt entry names PPSA12544's libc.prx and Unity's PS5Util.prx (PPSA18194) as callers that wait for a running call_once with it.

Measured in a payload process on a PS5 (firmware 12.70; payload SDK v0.44, clang 18.1.8), calling _umtx_op resolved from libkernel_sys.sprx: for operations 0 and 1 the object is a word of the probe's own and val the calling thread's id from scePthreadGetthreadid; the semaphore operations get a usem or usem2 of the probe's own, val 0, and for the waits a 100 ms relative timespec with size argument 16 (probe p78_libkernel, source and log attached: p78-umtx-ops.zip; lines quoted unchanged with a p78: prefix):

p78: case umtx_setup tid=102084
p78: case umtx unlock_unowned op=1 ret=-1 errno=45 word_after=0
p78: case umtx unlock_owned op=1 ret=-1 errno=45 word_after=0x18ec4
p78: case umtx unlock_owned_contested op=1 ret=-1 errno=45 word_after=0x8000000000018ec4
p78: case umtx unlock_other_owner op=1 ret=-1 errno=45 word_after=0x1e240
p78: case umtx lock_unowned op=0 ret=-1 errno=45 word_after=0
p78: case umtx lock_unowned_timeout op=0 ret=-1 errno=45 word_after=0
p78: case umtx sem_wait_count1 op=19 ret=0 errno=0
p78: case umtx_sem_after_wait has_waiters=1 count=1
p78: case umtx sem_wait_count0_timeout op=19 ret=-1 errno=60
p78: case umtx_sem_after_wait0 has_waiters=1 count=0
p78: case umtx sem_wake_no_waiter op=20 ret=0 errno=0
p78: case umtx sem2_wait_count1 op=23 ret=0 errno=0
p78: case umtx_sem2_after_wait count=0x1
p78: case umtx sem2_wait_count0_timeout op=23 ret=0 errno=0
p78: case umtx_sem2_after_wait0 count=0

Operation 1 fails with EOPNOTSUPP (45) and leaves the word unchanged whether it holds 0, the calling thread's id, that id with bit 63 set or another value, and operation 0 does the same for a word of 0, with a null time argument and with a 100 ms timespec. That is FreeBSD 11's __umtx_op_unimpl, which the operation table assigns to operations 0 and 1. The change answers operation 1 like operation 0 (error = GUEST_EOPNOTSUPP), with no other operation touched. guest_umtx_op now requires EOPNOTSUPP and an unchanged word from operations 0 and 1 for the words 0, 123456 and 123456 with bit 63 set, with val 123456, instead of a throw from operation 1; operation 0 was measured only with a word of 0, and the test's expectation for the other two words rests on __umtx_op_unimpl ignoring the word.

The same run also answered the semaphore operations, which still throw here and are recorded in the debt entry without a code change: UMTX_OP_SEM_WAIT (19) returned 0 for a count of 1 and set _has_waiters, and ETIMEDOUT for a count of 0 with a 100 ms relative timeout, and UMTX_OP_SEM_WAKE (20) returned 0 without a waiter, the answers FreeBSD 11's do_sem_wait and do_sem_wake give when built under COMPAT_FREEBSD9 or COMPAT_FREEBSD10; UMTX_OP_SEM2_WAIT (23) returned 0 for a count of 1, leaving the count 1, as FreeBSD 11's do_sem2_wait does, and 0 (not ETIMEDOUT) for a count of 0 with the same timeout, leaving the count 0, where FreeBSD 11 would set USEM_HAS_WAITERS and time out. The log ends before the result line of UMTX_OP_SEM2_WAKE (24) without a waiter: within the runner's 120 s the process printed nothing more and no crash line (the probe's guard reports SIGSEGV, SIGBUS, SIGILL and SIGFPE), so whether that call blocked or the process ended another way was not determined, and operations 27, 100 and -1 were not measured in this run.

Not measured: what libc.prx or PS5Util.prx do after EOPNOTSUPP from operation 1 (no title was run), a contended operation 0 or 1, and a game process.

Overlaps: tools/pr_overlap.py reports no open PR that changes the same lines or exports; it could not compare 23 PRs that conflict with main and share a file with this branch: #2528 (SyncOnAddress.cpp), #6044 (GuestUmtxOp.cpp) and, for the libkernel debt file, #5021, #6149, #6446, #6469, #6519, #6825, #6908, #6936, #6977, #7039, #7049, #7075, #7088, #7105, #7121, #7129, #7149, #7192, #7299, #7332 and #7509. #2528 does not touch the operation switch, #6044 only moves the test file, and none of the 21 changes the _umtx_op entry. No open PR implements _umtx_op operation 1 (the closed #6447 answered it with EOPNOTSUPP without a measurement).

Tested

Windows 11 Pro 10.0.26300, WinLibs MinGW-w64 GCC 15.2.0 r7 (posix, UCRT), Ninja, Release, -DBUILD_TESTING=ON, branch built and tested on main 83bf557, then rebased on 36f60df (six pull requests merged since, 16 files: AGC driver, Videodec2, libc file and heap code, the relinker and shader recompiler, and the libc and Videodec2 debt files; none touches SyncOnAddress.cpp, GuestUmtxOp.cpp or the libkernel debt file); guest_umtx_op rebuilt and rerun after the rebase, passed.

  • guest_umtx_op passes with the change (four runs, including the one after the rebase).
  • Revert check: with SyncOnAddress.cpp from main and the new test kept, guest_umtx_op aborts with "unhandled exception 'St13runtime_error' ... what(): _umtx_op operation 1 not implemented"; restored, it passes.
  • guest_sync_on_address, guest_once, guest_execute_once, guest_std_execute_once, guest_cond_timedwait, guest_pthread_mutex_errors and guest_umtx_op: 7 of 7 pass with the change.
  • python tools/check_conventions.py --base origin/main passes.
  • Probe p78_libkernel built with the payload SDK v0.44 and clang 18.1.8 (-target x86_64-sie-ps5), launched once through the payload manager; the log in the attachment ends at operation 24 with no further output within the runner's 120 s.

Not tested: Linux (the change is one branch of a switch with no host-specific code), PPSA12544 and PPSA18194.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

… on a PS5

Operation 1 threw as unverified, so a title whose call_once path reaches it
stopped. In a payload process on a PS5 (firmware 12.70) operations 0 and 1
fail with EOPNOTSUPP and leave the word unchanged for every word tried,
as FreeBSD 11's __umtx_op_unimpl does. Answer operation 1 like operation 0.
@github-actions

github-actions Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 2528 core/libs/prx/libkernel/SyncOnAddress/src/SyncOnAddress.cpp
PR 5021 docs/dev/debt/libkernel.md
PR 6044 core/libs/tests/GuestUmtxOp.cpp
PR 6149 docs/dev/debt/libkernel.md
PR 6446 docs/dev/debt/libkernel.md
PR 6469 docs/dev/debt/libkernel.md
PR 6519 docs/dev/debt/libkernel.md
PR 6740 docs/dev/debt/libkernel.md
PR 6936 docs/dev/debt/libkernel.md
PR 6977 docs/dev/debt/libkernel.md
PR 7049 docs/dev/debt/libkernel.md
PR 7105 docs/dev/debt/libkernel.md
PR 7135 docs/dev/debt/libkernel.md
PR 7149 docs/dev/debt/libkernel.md
PR 7332 docs/dev/debt/libkernel.md
PR 7509 docs/dev/debt/libkernel.md

@fogydes fogydes left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Built and verified locally on Windows 11 with WinLibs MinGW-w64 GCC 15.2.0, Release (-DBUILD_TESTING=ON):

  • Target guest_umtx_op_tests builds cleanly with Ninja.
  • ctest --test-dir build-libs -R "guest_umtx_op" --output-on-failure:
    • guest_umtx_op: Passed (0.94s)
  • Hardware probe evidence on a PS5 (firmware 12.70) validates that uncontended _umtx_op operation 1 fails with EOPNOTSUPP rather than throwing, and that the word value is preserved.
  • Diff in core/libs/prx/libkernel/SyncOnAddress/src/SyncOnAddress.cpp is minimal (+2 / −3 lines), replacing the artificial exception throw with GUEST_EOPNOTSUPP when operation <= UMTX_OP_RESERVED1.
  • docs/dev/debt/libkernel.md updated cleanly with hardware measurements.
  • Zero code comments added; tools/check_conventions.py --base origin/main passes with 0 findings.

Ready to merge.

AI-assisted: yes

@oneandonlydean oneandonlydean self-assigned this Oct 19, 2026
@oneandonlydean
oneandonlydean merged commit c66a207 into boykopovar:main Oct 19, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants