fix(libkernel): _umtx_op operation 27 returns 0 like the console #17887

Merged
AasishDairelSahayaGrinspan merged 2 commits from upstream-pr/17887 into main 2026-11-15 20:15:10 +00:00
AasishDairelSahayaGrinspan commented 2026-11-09 20:47:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by AasishDairelSahayaGrinspan on 2026-11-09T20:47:31Z.


What

A payload process on a PS5 (firmware 13.40) got 0 from _umtx_op with operation 27, as the _umtx_op entry of the technical debt records; this implementation failed with EINVAL because 27 sits at UMTX_OP_MAX and the range check rejected it before the switch. Operation 27 now returns 0 without reading its arguments, as the measurement shows. What operation 27 does with valid arguments is unmeasured; the debt entry keeps that gap.

The guest test guest_umtx_op pinned the old EINVAL; it now pins operation 27 returning 0 and adds operation 28 failing with EINVAL, so the upper bound stays guarded.

Tested

macOS 15 (arm64, x86_64 target via Rosetta toolchain), Apple Clang, Release, BUILD_TESTING=ON:

  • ctest --test-dir build -R guest_umtx_op -V: passes, including the new operation 27 and 28 pins.
  • python3 tools/check_conventions.py --base origin/main: passed.

Windows and Linux were not compiled here; the change is one added case label with no platform-dependent code, and CI covers them.

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
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5230927351 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/17887). Originally posted by [AasishDairelSahayaGrinspan](https://github.com/AasishDairelSahayaGrinspan) on 2026-11-09T20:47:31Z. --- ### What A payload process on a PS5 (firmware 13.40) got 0 from `_umtx_op` with operation 27, as the [_umtx_op entry](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/debt/libkernel.md) of the technical debt records; this implementation failed with `EINVAL` because 27 sits at `UMTX_OP_MAX` and the range check rejected it before the switch. Operation 27 now returns 0 without reading its arguments, as the measurement shows. What operation 27 does with valid arguments is unmeasured; the debt entry keeps that gap. The guest test `guest_umtx_op` pinned the old `EINVAL`; it now pins operation 27 returning 0 and adds operation 28 failing with `EINVAL`, so the upper bound stays guarded. ### Tested macOS 15 (arm64, x86_64 target via Rosetta toolchain), Apple Clang, Release, `BUILD_TESTING=ON`: - `ctest --test-dir build -R guest_umtx_op -V`: passes, including the new operation 27 and 28 pins. - `python3 tools/check_conventions.py --base origin/main`: passed. Windows and Linux were not compiled here; the change is one added `case` label with no platform-dependent code, and CI covers them. ### 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 under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [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 <!-- #PR, or none --> - [x] Fixes: none <!-- issue it closes as Fixes #N, or none --> - [x] Unblocks: none <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> - [x] GPUs tested: n/a <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> - [x] AI-assisted: yes <!-- yes / no -->
milescoviello commented 2026-11-09 21:31:05 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-11-09T21:31:05Z.

Review: COMMENTED


Read at 784fefe681. The fix does what the description says. The range check sits in default (SyncOnAddress.cpp:876), so the new case UMTX_OP_MAX returns 0 for operation 27 before reaching it.

Two small points:

  1. Operation 28 → EINVAL isn't measured. The _umtx_op debt entry records the console measurement for 27 ("27 returns 0 on the console and EINVAL here") and nothing above it. So the new FailsWith(Umtx(&value, UMTX_OP_MAX + 1, 0), GUEST_EINVAL) pins a refusal the console was never seen to give. If 28 is a real operation there, the pin would be wrong in the same way the old 27 pin was. Either drop that line or note in the debt entry that 28 and above are unmeasured.
  2. case UMTX_OP_MAX: reads as "the out-of-range sentinel" next to the operation >= UMTX_OP_MAX check below it. A named constant for 27 would make the intent clearer, for example UMTX_OP_MEASURED_NOOP = 27, or the FreeBSD name if Sony's numbering follows it. The test could then stop doing arithmetic on UMTX_OP_MAX.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5833082873 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/17887#pullrequestreview-5833082873). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-11-09T21:31:05Z. **Review:** COMMENTED --- Read at `784fefe681`. The fix does what the description says. The range check sits in `default` (`SyncOnAddress.cpp:876`), so the new `case UMTX_OP_MAX` returns 0 for operation 27 before reaching it. Two small points: 1. **Operation 28 → `EINVAL` isn't measured.** The `_umtx_op` debt entry records the console measurement for 27 ("27 returns 0 on the console and `EINVAL` here") and nothing above it. So the new `FailsWith(Umtx(&value, UMTX_OP_MAX + 1, 0), GUEST_EINVAL)` pins a refusal the console was never seen to give. If 28 is a real operation there, the pin would be wrong in the same way the old 27 pin was. Either drop that line or note in the debt entry that 28 and above are unmeasured. 2. **`case UMTX_OP_MAX:` reads as "the out-of-range sentinel"** next to the `operation >= UMTX_OP_MAX` check below it. A named constant for 27 would make the intent clearer, for example `UMTX_OP_MEASURED_NOOP = 27`, or the FreeBSD name if Sony's numbering follows it. The test could then stop doing arithmetic on `UMTX_OP_MAX`. AI-assisted: yes (Claude Code)
milescoviello commented 2026-11-10 13:34:16 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-11-10T13:34:16Z.

Review: APPROVED


Approving 70bd6cc643. Both points are addressed:

  • The debt entry now says operations above 27 are unmeasured.
  • UMTX_OP_MEASURED_NOOP names the measured no-op in both the case label and the test, while UMTX_OP_MAX stays the range-check bound.

The op-28 EINVAL pin is a host refusal rather than a measured console answer, but the entry now says so, and it guards the range check. That's a fair trade.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5842694814 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/17887#pullrequestreview-5842694814). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-11-10T13:34:16Z. **Review:** APPROVED --- Approving `70bd6cc643`. Both points are addressed: - The debt entry now says operations above 27 are unmeasured. - `UMTX_OP_MEASURED_NOOP` names the measured no-op in both the `case` label and the test, while `UMTX_OP_MAX` stays the range-check bound. The op-28 `EINVAL` pin is a host refusal rather than a measured console answer, but the entry now says so, and it guards the range check. That's a fair trade. AI-assisted: yes (Claude Code)
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!17887
No description provided.