feat(libkernel): implement _umtx_op wait and wake operations #1482

Merged
awake-devel merged 3 commits from upstream-pr/1482 into main 2026-10-11 09:26:13 +00:00
awake-devel commented 2026-10-08 08:54:59 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by awake-devel on 2026-10-08T08:54:59Z.


What

Hollow Knight: Silksong (PPSA12544) ships its own sce_module/libc.prx and Unity's Media/Modules/PS5Util.prx. Both import _umtx_op (NID 04AjkP0jO9U) from libkernel, which AnyPS5 does not export, so on Linux the relinked title stops at load with undefined symbol: 04AjkP0jO9U.

This adds _umtx_op to libkernel for the operations those modules pass, following FreeBSD 11's kern_umtx.c:

op name behaviour
2 UMTX_OP_WAIT sleep while the 64-bit value at obj equals val; return 0 at once when it differs (do_wait, compat32 = 0)
11 / 15 UMTX_OP_WAIT_UINT / _PRIVATE the same with a 32-bit comparison (do_wait, compat32 = 1)
3 / 16 UMTX_OP_WAKE / _PRIVATE wake up to val waiters; val <= 0 still wakes one (umtxq_signal_queue)

Timeouts follow umtx_copyin_umtx_time: when uaddr (the size) is at most 16, uaddr2 is a relative timespec; otherwise it is an _umtx_time, absolute with UMTX_ABSTIME on its clock. A negative second count or a nanosecond count outside [0, 1e9) fails with EINVAL, and a wait that times out fails with ETIMEDOUT. Errors are returned as -1 with the guest errno set, like the system call. A null object gives EFAULT (except WAKE_PRIVATE, which does not look up the address). Operations 0 and 1 fail with EOPNOTSUPP and operations above 26 with EINVAL, as in FreeBSD 11's op_table. The mutex, condition variable, rwlock, semaphore, shm and robust-list operations throw NotImplemented, as does a misaligned object.

Waiters use the existing sceKernelSyncOnAddressWait queue and TimedWait (no platform-specific code), so _umtx_op and sceKernelSyncOnAddressWake wake each other's waiters.

What the title calls. I disassembled the two modules:

  • PS5Util.prx: a wait helper at 0x700 (UMTX_OP_WAIT, a timespec built from a microsecond timeout) and a wake helper at 0x750 (UMTX_OP_WAKE). The result is read through __error.
  • libc.prx: helpers at 0x116b80 (UMTX_OP_WAIT_UINT), 0x116b90 (UMTX_OP_WAIT) and 0x116ba0 (UMTX_OP_WAKE). They are used by exported atomic-wait functions (name string SceLibcV2AtomicWait) and by a call_once (SceLibcIV2Once), which waits with operation 1 and wakes every waiter with UMTX_OP_WAKE(INT_MAX).

Two things in these modules disagree with FreeBSD and could not be checked without a console. Both are recorded in TechnicalDebt:

  • libc passes the WAIT operations a pointer to a 4-byte microsecond timeout, with size 0 (the layout of sceKernelSyncOnAddressWait), while PS5Util passes a timespec. With FreeBSD's rule, libc's 4-byte value is read as a timespec. The nanosecond half is then almost always out of range, so the wait returns EINVAL at once and libc's loop checks again. Only the untimed waits (null timeout) block.
  • libc's call_once waits with operation 1, which FreeBSD 11 rejects with EOPNOTSUPP. The once loop then checks the flag again until it reaches the done state, so it spins instead of sleeping.

AI-assisted: the call sites were found and this change was written with Claude Code.

This PR was investigated and written by Claude Code (AI), and posted by me after review.

Tested

Arch Linux (kernel 7.2.8), i7-8750H, GTX 1050 Ti Max-Q (NVIDIA 580.178.04), GCC 16.2.1, Release build. Each run is compared with unmodified main bc1fbe81 on the same machine. All runs set APS5_WRITE_WATCH_IMPORTS=watch; without it this NVIDIA driver creates no Vulkan device (#1289) and the GPU tests are skipped.

  • ctest -j4: 424/424 passed, 0 skipped, 0 failed (baseline 423/423, 0 skipped). The only new test is guest_umtx_op.

  • VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ctest -j2 -V: 424/424 passed. 27 Validation Error lines, the same as the baseline, with identical per-VUID counts.

  • New test core/libs/tests/GuestUmtxOp.cpp (modelled on GuestSyncOnAddress) covers:

    • a wait returning at once when the value differs;
    • 64-bit comparison for WAIT and 32-bit for WAIT_UINT;
    • relative timespec, relative _umtx_time and absolute CLOCK_MONOTONIC timeouts, including one in the past;
    • rejected timeouts;
    • a wake that releases a waiter without a value change;
    • the wake count (1, then 0 waking one, then INT_MAX), with a waiter on another address left untouched;
    • null objects, reserved and out-of-range operations, and unimplemented operations throwing.
  • Mutation check. With the test kept and the fix changed, the test failed every time:

    • fix removed: the test no longer links;
    • a wake of 0 wakes nobody: test fails;
    • UMTX_OP_WAIT compares 32 bits: test fails;
    • the timeout is ignored: test fails.

    The fix was then restored byte for byte and rebuilt, and guest_umtx_op and guest_sync_on_address passed.

  • Windows: not tested. The change has no Windows-specific code; it uses std::uint64_t for the guest u_long.

  • Silksong (PPSA12544), Linux, relinked with #846 (--module-dir Media/Plugins) and local throwing stubs for unrelated missing imports. On main the loader fails with undefined symbol: 04AjkP0jO9U. With this change, all modules load, the title starts, reads /app0/Media/boot.config, and stops at a later, unrelated gap: sceKernelLoadStartModule with start arguments not implemented. The log does not show whether _umtx_op ran before that point, so the wait and wake paths are covered only by the unit test.

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 in TechnicalDebt
  • 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
  • AI-assisted: yes

🤖 Generated with Claude Code

https://claude.ai/code/session_01HeC9bA3n74TzJRYv9AgBE8

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4784307219 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1482). Originally posted by [awake-devel](https://github.com/awake-devel) on 2026-10-08T08:54:59Z. --- ### What Hollow Knight: Silksong (PPSA12544) ships its own `sce_module/libc.prx` and Unity's `Media/Modules/PS5Util.prx`. Both import `_umtx_op` (NID `04AjkP0jO9U`) from libkernel, which AnyPS5 does not export, so on Linux the relinked title stops at load with `undefined symbol: 04AjkP0jO9U`. This adds `_umtx_op` to libkernel for the operations those modules pass, following FreeBSD 11's [kern_umtx.c](https://github.com/freebsd/freebsd-src/blob/stable/11/sys/kern/kern_umtx.c): | op | name | behaviour | | --- | --- | --- | | 2 | `UMTX_OP_WAIT` | sleep while the 64-bit value at `obj` equals `val`; return 0 at once when it differs (`do_wait`, compat32 = 0) | | 11 / 15 | `UMTX_OP_WAIT_UINT` / `_PRIVATE` | the same with a 32-bit comparison (`do_wait`, compat32 = 1) | | 3 / 16 | `UMTX_OP_WAKE` / `_PRIVATE` | wake up to `val` waiters; `val <= 0` still wakes one (`umtxq_signal_queue`) | Timeouts follow `umtx_copyin_umtx_time`: when `uaddr` (the size) is at most 16, `uaddr2` is a relative `timespec`; otherwise it is an `_umtx_time`, absolute with `UMTX_ABSTIME` on its clock. A negative second count or a nanosecond count outside [0, 1e9) fails with `EINVAL`, and a wait that times out fails with `ETIMEDOUT`. Errors are returned as -1 with the guest `errno` set, like the system call. A null object gives `EFAULT` (except `WAKE_PRIVATE`, which does not look up the address). Operations 0 and 1 fail with `EOPNOTSUPP` and operations above 26 with `EINVAL`, as in FreeBSD 11's `op_table`. The mutex, condition variable, rwlock, semaphore, shm and robust-list operations throw `NotImplemented`, as does a misaligned object. Waiters use the existing `sceKernelSyncOnAddressWait` queue and `TimedWait` (no platform-specific code), so `_umtx_op` and `sceKernelSyncOnAddressWake` wake each other's waiters. **What the title calls.** I disassembled the two modules: - `PS5Util.prx`: a wait helper at 0x700 (`UMTX_OP_WAIT`, a `timespec` built from a microsecond timeout) and a wake helper at 0x750 (`UMTX_OP_WAKE`). The result is read through `__error`. - `libc.prx`: helpers at 0x116b80 (`UMTX_OP_WAIT_UINT`), 0x116b90 (`UMTX_OP_WAIT`) and 0x116ba0 (`UMTX_OP_WAKE`). They are used by exported atomic-wait functions (name string `SceLibcV2AtomicWait`) and by a call_once (`SceLibcIV2Once`), which waits with **operation 1** and wakes every waiter with `UMTX_OP_WAKE(INT_MAX)`. Two things in these modules disagree with FreeBSD and could not be checked without a console. Both are recorded in TechnicalDebt: - libc passes the WAIT operations a pointer to a **4-byte microsecond** timeout, with size 0 (the layout of `sceKernelSyncOnAddressWait`), while PS5Util passes a `timespec`. With FreeBSD's rule, libc's 4-byte value is read as a `timespec`. The nanosecond half is then almost always out of range, so the wait returns `EINVAL` at once and libc's loop checks again. Only the untimed waits (null timeout) block. - libc's call_once waits with operation 1, which FreeBSD 11 rejects with `EOPNOTSUPP`. The once loop then checks the flag again until it reaches the done state, so it spins instead of sleeping. AI-assisted: the call sites were found and this change was written with Claude Code. This PR was investigated and written by Claude Code (AI), and posted by me after review. ### Tested Arch Linux (kernel 7.2.8), i7-8750H, GTX 1050 Ti Max-Q (NVIDIA 580.178.04), GCC 16.2.1, Release build. Each run is compared with unmodified `main` bc1fbe81 on the same machine. All runs set `APS5_WRITE_WATCH_IMPORTS=watch`; without it this NVIDIA driver creates no Vulkan device (#1289) and the GPU tests are skipped. - `ctest -j4`: 424/424 passed, 0 skipped, 0 failed (baseline 423/423, 0 skipped). The only new test is `guest_umtx_op`. - `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ctest -j2 -V`: 424/424 passed. 27 `Validation Error` lines, the same as the baseline, with identical per-VUID counts. - New test `core/libs/tests/GuestUmtxOp.cpp` (modelled on `GuestSyncOnAddress`) covers: - a wait returning at once when the value differs; - 64-bit comparison for `WAIT` and 32-bit for `WAIT_UINT`; - relative `timespec`, relative `_umtx_time` and absolute `CLOCK_MONOTONIC` timeouts, including one in the past; - rejected timeouts; - a wake that releases a waiter without a value change; - the wake count (1, then 0 waking one, then `INT_MAX`), with a waiter on another address left untouched; - null objects, reserved and out-of-range operations, and unimplemented operations throwing. - Mutation check. With the test kept and the fix changed, the test failed every time: - fix removed: the test no longer links; - a wake of 0 wakes nobody: test fails; - `UMTX_OP_WAIT` compares 32 bits: test fails; - the timeout is ignored: test fails. The fix was then restored byte for byte and rebuilt, and `guest_umtx_op` and `guest_sync_on_address` passed. - Windows: not tested. The change has no Windows-specific code; it uses `std::uint64_t` for the guest `u_long`. - Silksong (PPSA12544), Linux, relinked with #846 (`--module-dir Media/Plugins`) and local throwing stubs for unrelated missing imports. On `main` the loader fails with `undefined symbol: 04AjkP0jO9U`. With this change, all modules load, the title starts, reads `/app0/Media/boot.config`, and stops at a later, unrelated gap: `sceKernelLoadStartModule with start arguments not implemented`. The log does not show whether `_umtx_op` ran before that point, so the wait and wake paths are covered only by the unit test. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01HeC9bA3n74TzJRYv9AgBE8
popcoder565 commented 2026-10-08 09:58:58 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by popcoder565 on 2026-10-08T09:58:58Z.


Tested on Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release, Intel Core i7-12700H (20 logical CPUs). I merged it onto main 73ac9ef7 together with #1477, #1482 and #1490 to share one build.

  • guest_umtx_op: 5 of 5 runs pass, 0.59 to 0.62 s each.
  • Full ctest on that build: 430 of 431 pass. The one failure is agc_driver_srgb8_color_target, an NVIDIA import flake (#1434).

Tested with AI assistance (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6057381113 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1482#issuecomment-6057381113). Originally posted by [popcoder565](https://github.com/popcoder565) on 2026-10-08T09:58:58Z. --- Tested on Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release, Intel Core i7-12700H (20 logical CPUs). I merged it onto `main` 73ac9ef7 together with #1477, #1482 and #1490 to share one build. - `guest_umtx_op`: 5 of 5 runs pass, 0.59 to 0.62 s each. - Full ctest on that build: 430 of 431 pass. The one failure is `agc_driver_srgb8_color_target`, an NVIDIA import flake (#1434). Tested with AI assistance (Claude Code).
fisherjoey commented 2026-10-09 01:13:26 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by fisherjoey on 2026-10-09T01:13:26Z.


One difference from FreeBSD 11 in the WAIT_UINT path. do_wait takes u_long id, and with compat32 it reads the word with fueword32, zero-extends it into tmp and then checks tmp == id (kern_umtx.c:965-978 on stable/11). So a val with any of the high 32 bits set never matches and the call returns 0 right away.

Here the case does static_cast<std::uint32_t>(value) first, so a stored 1 with val = 0x700000001 sleeps. GuestUmtxOp.cpp:85 asserts that (ETIMEDOUT), while FreeBSD 11 would return 0 for the same call. Sign extension hits the same path: an int comparand of -1 passed as 0xffffffffffffffff against a stored 0xffffffff spins on FreeBSD and blocks here.

I checked it on the PR head (85c43cde, merged onto main 29e533ac, Linux, GCC 16.2.1, Release). The PR's own guest_umtx_op passes, and a small probe gives:

stored op val timeout result here FreeBSD 11
0x1 WAIT_UINT and WAIT_UINT_PRIVATE 0x700000001 0 -1, ETIMEDOUT 0
0x1 WAIT_UINT 0x700000001 200 ms -1, ETIMEDOUT after 200 ms 0, no sleep
0xffffffff WAIT_UINT 0xffffffffffffffff 200 ms -1, ETIMEDOUT after 200 ms 0, no sleep

It doesn't matter much in practice, and I can't say what the PS5 kernel does. Since the description says this follows do_wait, though, the minimal change is to pass the full value to UmtxWait, return 0 when expected > std::numeric_limits<TValue>::max() (after the timeout/null/alignment checks, to keep the error order), and flip line 85 to expect 0.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6072231251 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1482#issuecomment-6072231251). Originally posted by [fisherjoey](https://github.com/fisherjoey) on 2026-10-09T01:13:26Z. --- One difference from FreeBSD 11 in the WAIT_UINT path. `do_wait` takes `u_long id`, and with compat32 it reads the word with `fueword32`, zero-extends it into `tmp` and then checks `tmp == id` (kern_umtx.c:965-978 on stable/11). So a `val` with any of the high 32 bits set never matches and the call returns 0 right away. Here the case does `static_cast<std::uint32_t>(value)` first, so a stored 1 with `val = 0x700000001` sleeps. GuestUmtxOp.cpp:85 asserts that (ETIMEDOUT), while FreeBSD 11 would return 0 for the same call. Sign extension hits the same path: an `int` comparand of -1 passed as 0xffffffffffffffff against a stored 0xffffffff spins on FreeBSD and blocks here. I checked it on the PR head (85c43cde, merged onto main 29e533ac, Linux, GCC 16.2.1, Release). The PR's own `guest_umtx_op` passes, and a small probe gives: | stored | op | `val` | timeout | result here | FreeBSD 11 | |---|---|---|---|---|---| | 0x1 | `WAIT_UINT` and `WAIT_UINT_PRIVATE` | 0x700000001 | 0 | -1, ETIMEDOUT | 0 | | 0x1 | `WAIT_UINT` | 0x700000001 | 200 ms | -1, ETIMEDOUT after 200 ms | 0, no sleep | | 0xffffffff | `WAIT_UINT` | 0xffffffffffffffff | 200 ms | -1, ETIMEDOUT after 200 ms | 0, no sleep | It doesn't matter much in practice, and I can't say what the PS5 kernel does. Since the description says this follows `do_wait`, though, the minimal change is to pass the full value to `UmtxWait`, return 0 when `expected > std::numeric_limits<TValue>::max()` (after the timeout/null/alignment checks, to keep the error order), and flip line 85 to expect 0. AI-assisted: yes
oneandonlydean commented 2026-10-09 09:22:10 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-09T09:22:10Z.


For the two cases where PPSA12544's own libc.prx doesn't match FreeBSD 11 (a 4-byte microsecond timeout with size 0 on the WAIT ops, and operation 1 in its call_once), please throw instead of returning EINVAL/EOPNOTSUPP in SyncOnAddress.cpp. The title's libc shows the console handles those calls some other way, and returning FreeBSD's error makes it spin. Unknown behaviour throws here. The rest can go in.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6078118813 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1482#issuecomment-6078118813). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-09T09:22:10Z. --- For the two cases where PPSA12544's own `libc.prx` doesn't match FreeBSD 11 (a 4-byte microsecond timeout with size 0 on the WAIT ops, and operation 1 in its call_once), please throw instead of returning `EINVAL`/`EOPNOTSUPP` in `SyncOnAddress.cpp`. The title's libc shows the console handles those calls some other way, and returning FreeBSD's error makes it spin. Unknown behaviour throws here. The rest can go in.
adriadam10 commented 2026-10-09 23:30:59 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-09T23:30:59Z.

Review: CHANGES_REQUESTED


Thanks for the detailed write-up. Two things before this can go in:

  • As @oneandonlydean asked, throw (NotImplemented_nid_no_patch) instead of returning an error in the two cases where the title's libc.prx disagrees with FreeBSD 11: the 4-byte microsecond timeout with size argument 0 on the WAIT ops, and operation 1 (SyncOnAddress.cpp:250-254, UmtxDeadline at :128). Please also say how a libc call is told apart from PS5Util's timespec call if both pass size 0; if they can't be told apart, say so in TechnicalDebt and throw only on what is certain.
  • As @fisherjoey noted, FreeBSD's do_wait with compat32 compares the zero-extended word against the full val, so WAIT_UINT with any high bit set in val returns 0 at once. SyncOnAddress.cpp:243 truncates to 32 bits, and GuestUmtxOp.cpp:83 asserts the opposite. Pass the full value and return 0 when it doesn't fit (after the timeout/null/alignment checks), and flip that assertion.

Update the TechnicalDebt line (TechnicalDebt.md:132) to match. Happy to look again once pushed.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5476322002 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1482#pullrequestreview-5476322002). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-09T23:30:59Z. **Review:** CHANGES_REQUESTED --- Thanks for the detailed write-up. Two things before this can go in: - As @oneandonlydean asked, throw (`NotImplemented_nid_no_patch`) instead of returning an error in the two cases where the title's `libc.prx` disagrees with FreeBSD 11: the 4-byte microsecond timeout with size argument 0 on the WAIT ops, and operation 1 (`SyncOnAddress.cpp:250-254`, `UmtxDeadline` at `:128`). Please also say how a libc call is told apart from PS5Util's `timespec` call if both pass size 0; if they can't be told apart, say so in TechnicalDebt and throw only on what is certain. - As @fisherjoey noted, FreeBSD's `do_wait` with compat32 compares the zero-extended word against the full `val`, so `WAIT_UINT` with any high bit set in `val` returns 0 at once. `SyncOnAddress.cpp:243` truncates to 32 bits, and `GuestUmtxOp.cpp:83` asserts the opposite. Pass the full value and return 0 when it doesn't fit (after the timeout/null/alignment checks), and flip that assertion. Update the TechnicalDebt line (`TechnicalDebt.md:132`) to match. Happy to look again once pushed.
github-actions[bot] commented 2026-10-09 23:49:22 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-09T23:49:22Z.


Progress report (4c9686f → 3879e7e)

📉 System libraries: 85.42% (-0.03%, +1 declared functions)

🆕 1 declared as stubs
Library Name
libkernel _umtx_op_nid_postfix
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6091229067 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1482#issuecomment-6091229067). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-09T23:49:22Z. --- <!-- progress-report --> ### Progress report (4c9686f → 3879e7e) 📉 **System libraries**: 85.42% (-0.03%, +1 declared functions) <details> <summary>🆕 1 declared as stubs</summary> | Library | Name | | - | - | | libkernel | `_umtx_op_nid_postfix` | </details>
babyhuey commented 2026-10-10 01:55:11 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by babyhuey on 2026-10-10T01:55:11Z.


Checked the current head (85c43cde, before the change requested above) on main ee501326 (clean merge), Linux (Ubuntu 24.04, GCC 13) and Windows 11 (MinGW-w64 GCC from WinLibs), Release.

  • guest_umtx_op passes 5/5 on both (--repeat until-fail:5); no CRT assertion dialog on Windows.
  • Three catalog titles stop at _umtx_op on main, and all three get past it on both, to the same next stop:
    • VITA5 (PPSA39410), PS5 OpenGL Showcase (PPSA99005), Homebrew UI Lab (PPSA99050)
    • Linux: app.elf: symbol lookup error: app.elf: undefined symbol: JZKw5+Wrnaw (pthread_sigmask)
    • Windows: FAIL: unresolved ELF import JZKw5+Wrnaw (pthread_sigmask) from libkernel.prx

ProsperoLight (PPSA99002) and Lichess (PPSA99009) also reach _umtx_op once flockfile and sceHttpSetRecvBlockSize exist (#1578).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6092417103 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1482#issuecomment-6092417103). Originally posted by [babyhuey](https://github.com/babyhuey) on 2026-10-10T01:55:11Z. --- Checked the current head (85c43cde, before the change requested above) on `main` ee501326 (clean merge), Linux (Ubuntu 24.04, GCC 13) and Windows 11 (MinGW-w64 GCC from WinLibs), Release. - `guest_umtx_op` passes 5/5 on both (`--repeat until-fail:5`); no CRT assertion dialog on Windows. - Three catalog titles stop at `_umtx_op` on `main`, and all three get past it on both, to the same next stop: - VITA5 (PPSA39410), PS5 OpenGL Showcase (PPSA99005), Homebrew UI Lab (PPSA99050) - Linux: `app.elf: symbol lookup error: app.elf: undefined symbol: JZKw5+Wrnaw` (`pthread_sigmask`) - Windows: `FAIL: unresolved ELF import JZKw5+Wrnaw (pthread_sigmask) from libkernel.prx` ProsperoLight (PPSA99002) and Lichess (PPSA99009) also reach `_umtx_op` once `flockfile` and `sceHttpSetRecvBlockSize` exist (#1578).
babyhuey commented 2026-10-10 20:24:39 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by babyhuey on 2026-10-10T20:24:39Z.


For priority: on main 56fb1b3b this is now the next stop for 10 catalog titles (catalog builds with sce_module/libc.prx unwrapped as #2605 requires; tracked in #1578), with undefined symbol: 04AjkP0jO9U on Linux and FAIL: unresolved ELF import 04AjkP0jO9U (_umtx_op) from libkernel.prx on Windows:

SymphonyStation5 (PPSA17641), VITA5 (PPSA39410), Stremio Plus (PPSA74126), PokeMMO (PPSA98001), ProsperoLight (PPSA99002), PS5 OpenGL Showcase (PPSA99005), ProsperoPuzzles (PPSA99006), ProsperoLichess (PPSA99009), Homebrew UI Lab (PPSA99050) and Cloud Play (PPSA99600), plus ccleste, RommPS and vkQuake once utime (#2967) is in.

The two changes requested above are the only open items I can see. The WAIT_UINT one is mechanical; the size-0 timeout one needs the PS5Util disassembly from the description, so it is @awake-devel's call.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6101823441 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1482#issuecomment-6101823441). Originally posted by [babyhuey](https://github.com/babyhuey) on 2026-10-10T20:24:39Z. --- For priority: on `main` 56fb1b3b this is now the next stop for 10 catalog titles (catalog builds with `sce_module/libc.prx` unwrapped as #2605 requires; tracked in #1578), with `undefined symbol: 04AjkP0jO9U` on Linux and `FAIL: unresolved ELF import 04AjkP0jO9U (_umtx_op) from libkernel.prx` on Windows: SymphonyStation5 (PPSA17641), VITA5 (PPSA39410), Stremio Plus (PPSA74126), PokeMMO (PPSA98001), ProsperoLight (PPSA99002), PS5 OpenGL Showcase (PPSA99005), ProsperoPuzzles (PPSA99006), ProsperoLichess (PPSA99009), Homebrew UI Lab (PPSA99050) and Cloud Play (PPSA99600), plus ccleste, RommPS and vkQuake once `utime` (#2967) is in. The two changes requested above are the only open items I can see. The `WAIT_UINT` one is mechanical; the size-0 timeout one needs the PS5Util disassembly from the description, so it is @awake-devel's call.
fma-rc commented 2026-10-10 20:29:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by fma-rc on 2026-10-10T20:29:09Z.


Tested the current head (85c43cde, merged cleanly onto main 56fb1b3b) on Arch Linux, GCC 16.2.1, Release, and looked at a second title's libc.prx, which may help with the operation 1 question.

Tests

  • guest_umtx_op: 100 of 100 with --repeat until-fail:100; guest_sync_on_address: 20 of 20.
  • Under load (8 parallel loops of the test binary pinned to 2 CPUs next to 4 busy loops on the same CPUs): 200 of 200 pass.
  • A small probe for the claim that the two APIs share a queue: an UMTX_OP_WAIT waiter is released by sceKernelSyncOnAddressWake, and a sceKernelSyncOnAddressWait64 waiter by UMTX_OP_WAKE; both return 0 right after the wake. The PR's test does not cover this.

Astro Bot (PPSA21567, 01.019)

Its sce_module/libc.prx imports _umtx_op too.

  • main 56fb1b3b: symbol lookup error: .../sce_module/libc.prx.guest.prx: undefined symbol: 04AjkP0jO9U.
  • With this PR: the title loads and runs until a shader recompiler error that has nothing to do with this change (GetImageResource dword 0 is not a valid runtime value), within the 120 s run. With a temporary log line in _umtx_op, the function was not called once in that run, so like the Silksong run this only shows the import resolving.

What this libc passes

The only direct references to the import that I found in the module's text segment are two helpers, which reach it through a shared stub that sets the fourth argument (size) to 0:

115b50:  mov r8,rdx        ; timeout
         mov rdx,rsi       ; val
         push 2 / pop rsi  ; UMTX_OP_WAIT
         jmp 1150e1
115b60:  movsxd rdx,esi    ; val
         push 3 / pop rsi  ; UMTX_OP_WAKE
         xor r8d,r8d
         jmp 1150e1
1150e1:  mov r9d,0xffffffff
         xor ecx,ecx
         jmp [_umtx_op]

Each helper has one caller, and both are the call_once pair:

111460:  xor ecx,ecx
         cmp rax,2         ; state == done
         je  111481
         mov esi,1         ; second argument of the helper = val
         mov rdi,r14       ; the once flag
         mov rcx,r15       ; name string, overwritten by the stub
         xor edx,edx       ; timeout = null
         call 115b50
         jmp 11143e        ; re-read the flag
...
1114b0:  mov [rdi],rax     ; new state
         mov esi,0x7fffffff
         call 115b60

So in this libc the once loop waits with UMTX_OP_WAIT (2), val = 1 (the "running" state), a null timeout and size 0, and the finisher wakes with UMTX_OP_WAKE(INT_MAX). The 1 is the comparand, not the operation. This build has no UMTX_OP_WAIT_UINT helper and no timed wait.

@awake-devel could you check whether the 1 in PPSA12544's call_once is also the value argument of the helper at 0x116b90 rather than the operation? I don't have that title, so I can't tell; the two libcs are different builds (different helper addresses, and yours has a WAIT_UINT helper).

For the Astro Bot shape, the PR already does the right thing: four threads in _umtx_op(&state, UMTX_OP_WAIT, 1, 0, nullptr) with state = 1 stay blocked (0 of 4 returned after 300 ms), and after storing 2 and _umtx_op(&state, UMTX_OP_WAKE, INT_MAX, 0, nullptr) all four return 0.

Not checked: Windows, and the two points already under review (the WAIT_UINT comparison and the 4-byte timeout).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6101860773 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1482#issuecomment-6101860773). Originally posted by [fma-rc](https://github.com/fma-rc) on 2026-10-10T20:29:09Z. --- Tested the current head (85c43cde, merged cleanly onto `main` 56fb1b3b) on Arch Linux, GCC 16.2.1, Release, and looked at a second title's `libc.prx`, which may help with the operation 1 question. **Tests** - `guest_umtx_op`: 100 of 100 with `--repeat until-fail:100`; `guest_sync_on_address`: 20 of 20. - Under load (8 parallel loops of the test binary pinned to 2 CPUs next to 4 busy loops on the same CPUs): 200 of 200 pass. - A small probe for the claim that the two APIs share a queue: an `UMTX_OP_WAIT` waiter is released by `sceKernelSyncOnAddressWake`, and a `sceKernelSyncOnAddressWait64` waiter by `UMTX_OP_WAKE`; both return 0 right after the wake. The PR's test does not cover this. **Astro Bot (PPSA21567, 01.019)** Its `sce_module/libc.prx` imports `_umtx_op` too. - `main` 56fb1b3b: `symbol lookup error: .../sce_module/libc.prx.guest.prx: undefined symbol: 04AjkP0jO9U`. - With this PR: the title loads and runs until a shader recompiler error that has nothing to do with this change (`GetImageResource dword 0 is not a valid runtime value`), within the 120 s run. With a temporary log line in `_umtx_op`, the function was not called once in that run, so like the Silksong run this only shows the import resolving. **What this libc passes** The only direct references to the import that I found in the module's text segment are two helpers, which reach it through a shared stub that sets the fourth argument (size) to 0: ``` 115b50: mov r8,rdx ; timeout mov rdx,rsi ; val push 2 / pop rsi ; UMTX_OP_WAIT jmp 1150e1 115b60: movsxd rdx,esi ; val push 3 / pop rsi ; UMTX_OP_WAKE xor r8d,r8d jmp 1150e1 1150e1: mov r9d,0xffffffff xor ecx,ecx jmp [_umtx_op] ``` Each helper has one caller, and both are the call_once pair: ``` 111460: xor ecx,ecx cmp rax,2 ; state == done je 111481 mov esi,1 ; second argument of the helper = val mov rdi,r14 ; the once flag mov rcx,r15 ; name string, overwritten by the stub xor edx,edx ; timeout = null call 115b50 jmp 11143e ; re-read the flag ... 1114b0: mov [rdi],rax ; new state mov esi,0x7fffffff call 115b60 ``` So in this libc the once loop waits with `UMTX_OP_WAIT` (2), `val` = 1 (the "running" state), a null timeout and size 0, and the finisher wakes with `UMTX_OP_WAKE(INT_MAX)`. The `1` is the comparand, not the operation. This build has no `UMTX_OP_WAIT_UINT` helper and no timed wait. @awake-devel could you check whether the `1` in PPSA12544's call_once is also the value argument of the helper at 0x116b90 rather than the operation? I don't have that title, so I can't tell; the two libcs are different builds (different helper addresses, and yours has a `WAIT_UINT` helper). For the Astro Bot shape, the PR already does the right thing: four threads in `_umtx_op(&state, UMTX_OP_WAIT, 1, 0, nullptr)` with `state` = 1 stay blocked (0 of 4 returned after 300 ms), and after storing 2 and `_umtx_op(&state, UMTX_OP_WAKE, INT_MAX, 0, nullptr)` all four return 0. Not checked: Windows, and the two points already under review (the `WAIT_UINT` comparison and the 4-byte timeout).
awake-devel commented 2026-10-10 20:37:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by awake-devel on 2026-10-10T20:37:46Z.


I'll take a look around Monday, busy this weekend, sorry

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6101934252 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1482#issuecomment-6101934252). Originally posted by [awake-devel](https://github.com/awake-devel) on 2026-10-10T20:37:46Z. --- I'll take a look around Monday, busy this weekend, sorry
babyhuey commented 2026-10-10 20:44:29 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by babyhuey on 2026-10-10T20:44:29Z.


@awake-devel no rush. In case it saves you time on Monday, I put the two mechanical parts on top of your commit in babyhuey:help/umtx-op-1482 (8ec80b31), for you to pull in or ignore:

  • UMTX_OP_WAIT_UINT and _PRIVATE pass the full val to UmtxWait, which returns 0 when it doesn't fit in 32 bits, after the timeout, null and alignment checks. GuestUmtxOp.cpp now expects 0 for 0x700000001 and for 0xffffffffffffffff against a stored 0xffffffff.
  • Operation 1 throws NotImplemented; operation 0 keeps EOPNOTSUPP. The TechnicalDebt line says so.

I left the size-0 microsecond timeout alone, since telling it apart from PS5Util's timespec needs your disassembly. Merged onto main 56fb1b3b, guest_umtx_op and guest_sync_on_address pass on Linux and check_conventions.py passes.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6101991649 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1482#issuecomment-6101991649). Originally posted by [babyhuey](https://github.com/babyhuey) on 2026-10-10T20:44:29Z. --- @awake-devel no rush. In case it saves you time on Monday, I put the two mechanical parts on top of your commit in [babyhuey:help/umtx-op-1482](https://github.com/babyhuey/AnyPS5/tree/help/umtx-op-1482) (8ec80b31), for you to pull in or ignore: - `UMTX_OP_WAIT_UINT` and `_PRIVATE` pass the full `val` to `UmtxWait`, which returns 0 when it doesn't fit in 32 bits, after the timeout, null and alignment checks. `GuestUmtxOp.cpp` now expects 0 for `0x700000001` and for `0xffffffffffffffff` against a stored `0xffffffff`. - Operation 1 throws `NotImplemented`; operation 0 keeps `EOPNOTSUPP`. The TechnicalDebt line says so. I left the size-0 microsecond timeout alone, since telling it apart from PS5Util's `timespec` needs your disassembly. Merged onto `main` 56fb1b3b, `guest_umtx_op` and `guest_sync_on_address` pass on Linux and `check_conventions.py` passes.
GustavoGamarra95 commented 2026-10-11 02:48:05 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by GustavoGamarra95 on 2026-10-11T02:48:05Z.


Another title this unblocks on Linux: God of War Sons of Sparta (PPSA28997, Unity IL2CPP).

On main the loader stops at undefined symbol: 04AjkP0jO9U from Media/Modules/PS5Util.prx. With head 85c43cde applied (on main 942a174e, together with #1431 for sceKernelRaiseException), all modules load, and the title boots and plays through several levels, with saves and trophies working.

_umtx_op runs a lot there. During gameplay the main thread and another Unity thread were inside _umtx_op → WaitOnAddressUntil, called from PS5Util.prx, in 38 and 36 of 40 eu-stack samples. Those are the frame waits between Unity's threads, so the wait and wake path is exercised continuously. I saw no hang or lost wake-up over several play sessions, the longest about ten minutes.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6104749485 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1482#issuecomment-6104749485). Originally posted by [GustavoGamarra95](https://github.com/GustavoGamarra95) on 2026-10-11T02:48:05Z. --- Another title this unblocks on Linux: God of War Sons of Sparta (PPSA28997, Unity IL2CPP). On `main` the loader stops at `undefined symbol: 04AjkP0jO9U` from `Media/Modules/PS5Util.prx`. With head 85c43cde applied (on `main` 942a174e, together with #1431 for `sceKernelRaiseException`), all modules load, and the title boots and plays through several levels, with saves and trophies working. `_umtx_op` runs a lot there. During gameplay the main thread and another Unity thread were inside `_umtx_op` → `WaitOnAddressUntil`, called from `PS5Util.prx`, in 38 and 36 of 40 `eu-stack` samples. Those are the frame waits between Unity's threads, so the wait and wake path is exercised continuously. I saw no hang or lost wake-up over several play sessions, the longest about ten minutes.
overlordxrz-source commented 2026-10-11 03:58:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by overlordxrz-source on 2026-10-11T03:58:00Z.


For priority, an update from a catalog run on main 6c9cb3a5 (Linux). _umtx_op (04AjkP0jO9U) is the first stop for these 9 titles:

  • VITA5 (PPSA39410)
  • Stremio Plus (PPSA74126)
  • ProsperoLight (PPSA99002)
  • ProsperoTV (PPSA99003)
  • PS5 OpenGL Showcase (PPSA99005)
  • ProsperoPuzzles (PPSA99006)
  • ProsperoLichess (PPSA99009)
  • Homebrew UI Lab (PPSA99050)
  • Forwarder Manager (PPSA99930)

Two more stop here once the relinker gets past their SDK syscall stubs with the opt-in flag discussed in #2136: OliSe (PPSA01153) and PS5CEMU-HAR (PPSA99360). That makes 11.

No rush, @awake-devel. Thanks for the PR.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6105223672 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1482#issuecomment-6105223672). Originally posted by [overlordxrz-source](https://github.com/overlordxrz-source) on 2026-10-11T03:58:00Z. --- For priority, an update from a catalog run on `main` 6c9cb3a5 (Linux). `_umtx_op` (`04AjkP0jO9U`) is the first stop for these 9 titles: - VITA5 (PPSA39410) - Stremio Plus (PPSA74126) - ProsperoLight (PPSA99002) - ProsperoTV (PPSA99003) - PS5 OpenGL Showcase (PPSA99005) - ProsperoPuzzles (PPSA99006) - ProsperoLichess (PPSA99009) - Homebrew UI Lab (PPSA99050) - Forwarder Manager (PPSA99930) Two more stop here once the relinker gets past their SDK syscall stubs with the opt-in flag discussed in #2136: OliSe (PPSA01153) and PS5CEMU-HAR (PPSA99360). That makes 11. No rush, @awake-devel. Thanks for the PR.
LeandroLP23 commented 2026-10-11 08:29:29 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by LeandroLP23 on 2026-10-11T08:29:29Z.


Windows data point, two more catalog titles. Head 85c43cde merged onto main f60923bf, Windows 11 (26300), WinLibs GCC 15.2.0 r7, Release, titles relinked with their own libc.prx unwrapped:

Title main with this PR
PS5 OpenGL Showcase (PPSA99005) FAIL: unresolved ELF import 04AjkP0jO9U from libkernel.prx gets past it to 7Psx1DlAyE4 (getprogname, #3347)
ProsperoRadio (PPSA99001) same same

guest_umtx_op passes 3/3 here. With #3347 on top as well, the OpenGL showcase loads, brings up Mesa and stops in the shader recompiler (#2631), and ProsperoRadio stops at setcontext.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6107140129 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1482#issuecomment-6107140129). Originally posted by [LeandroLP23](https://github.com/LeandroLP23) on 2026-10-11T08:29:29Z. --- Windows data point, two more catalog titles. Head `85c43cde` merged onto `main` f60923bf, Windows 11 (26300), WinLibs GCC 15.2.0 r7, Release, titles relinked with their own `libc.prx` unwrapped: | Title | `main` | with this PR | |---|---|---| | PS5 OpenGL Showcase (PPSA99005) | `FAIL: unresolved ELF import 04AjkP0jO9U from libkernel.prx` | gets past it to `7Psx1DlAyE4` (`getprogname`, #3347) | | ProsperoRadio (PPSA99001) | same | same | `guest_umtx_op` passes 3/3 here. With #3347 on top as well, the OpenGL showcase loads, brings up Mesa and stops in the shader recompiler (#2631), and ProsperoRadio stops at `setcontext`.
adriadam10 commented 2026-10-11 09:22:15 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T09:22:15Z.

Review: APPROVED


Thanks all for the testing. Pushed the review fixes on top of your commit:

  • UMTX_OP_WAIT_UINT/_PRIVATE now pass the full val and return 0 at once when it doesn't fit in 32 bits (FreeBSD's zero-extended compare), after the timeout/null/alignment checks; test flipped. Commit by @babyhuey (help/umtx-op-1482), cherry-picked.
  • Operation 1 throws NotImplemented_nid_no_patch; operation 0 keeps EOPNOTSUPP.
  • A timeout with size argument 0 that isn't a valid timespec (negative seconds, nanoseconds outside [0, 1e9)) throws instead of returning EINVAL. A libc microsecond value can't be told apart from a timespec by the size alone, so a value that reads as a valid timespec is waited on as one; this is in TechnicalDebt. EINVAL tests now pass a size.

Rebased on main; guest_umtx_op and guest_sync_on_address pass; the test no longer links without the change.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5482739852 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1482#pullrequestreview-5482739852). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-11T09:22:15Z. **Review:** APPROVED --- Thanks all for the testing. Pushed the review fixes on top of your commit: - `UMTX_OP_WAIT_UINT`/`_PRIVATE` now pass the full `val` and return 0 at once when it doesn't fit in 32 bits (FreeBSD's zero-extended compare), after the timeout/null/alignment checks; test flipped. Commit by @babyhuey (help/umtx-op-1482), cherry-picked. - Operation 1 throws `NotImplemented_nid_no_patch`; operation 0 keeps `EOPNOTSUPP`. - A timeout with size argument 0 that isn't a valid `timespec` (negative seconds, nanoseconds outside [0, 1e9)) throws instead of returning `EINVAL`. A libc microsecond value can't be told apart from a `timespec` by the size alone, so a value that reads as a valid `timespec` is waited on as one; this is in TechnicalDebt. `EINVAL` tests now pass a size. Rebased on main; `guest_umtx_op` and `guest_sync_on_address` pass; the test no longer links without the change.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!1482
No description provided.