feat(libSceGnmDriver): answer the CU mask and tessellation ring queries as firmware 13.42 does #16882

Merged
BunnyFl merged 4 commits from upstream-pr/16882 into main 2026-11-11 14:50:15 +00:00
BunnyFl commented 2026-11-07 19:53:13 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-07T19:53:13Z.


What

sceGnmLogicalCuMaskToPhysicalCuMask and sceGnmGetTheTessellationFactorRingBufferBaseAddress threw. Firmware 13.42 libSceGnmDriver.sprx answers both without reading memory or calling anything:

Export NID Firmware 13.42 body Returns here
sceGnmLogicalCuMaskToPhysicalCuMask RU74kek-N0c mov %esi,%eax; ret at 0x4c10 its second argument, unchanged
sceGnmGetTheTessellationFactorRingBufferBaseAddress ln33zjBrfjk movabs $0xff0000000,%rax; ret at 0x4c70 0xff0000000
  • core/libs/prx/libSceGnmDriver/Export.cpp:559 and :568, declarations at core/libs/prx/libSceGnmDriver/include/Api.hpp:44 and :46 (at 1415816433).
  • The mask call takes (std::uint32_t, std::uint32_t mask) and returns std::uint32_t (core/libs/prx/libSceGnmDriver/include/Api.hpp:46): the body at 0x4c10 reads only esi and writes only eax, so the first argument is left unnamed and its width is not claimed. Returning the full 32 bits of mask reproduces mov %esi,%eax at 0x4c10 for any value in esi.
  • The ring base address returns std::uint64_t (core/libs/prx/libSceGnmDriver/include/Api.hpp:44), since movabs at 0x4c70 writes all of rax.

docs/dev/debt/libSceGnmDriver.md:11 (at 1415816433): the entry covered both CU calls and said the mask mapping "depends on which units are disabled on each chip and is not documented". The 13.42 module returns the mask unchanged (0x4c10), so the mask call leaves the entry, which is cut to sceGnmLogicalCuIndexToPhysicalCuIndex (docs/dev/debt/libSceGnmDriver.md:11). That one still throws: its body at 0x4bc0 (0x4c bytes) returns 0xffffffff when the first argument is at most 1 (unsigned) and the second is below 9. Otherwise it calls the PLT stub at 0x85a0 (jmp *0x14158) with "%s failed: %s\n" (0xffa5), its own name (0xefe1) and "invalid value for engine" (0xf2b6, first argument above 1) or "invalid value for cuIndex" (0xfedb), and returns 0. Which import the stub at 0x85a0 reaches (slot 0x14158) was not resolved, so the message is not reproduced and the entry records it (docs/dev/debt/libSceGnmDriver.md:11).

Source

Firmware 13.42 system/common/lib/libSceGnmDriver.sprx (sha256 0169144cf56c80cff9c89d1c7c136f288ea7983584231ae77825a7631f5c260f), read from disassembly, not run on a console. The module's dynamic symbol table gives RU74kek-N0c at 0x4c10 (size 3) and ln33zjBrfjk at 0x4c70 (size 0xb). Each body, every instruction to its return:

4c10: mov    %esi,%eax
4c12: ret

4c70: movabs $0xff0000000,%rax
4c7a: ret

The index call, for the debt entry (0x4bc0, to its return):

4bc0: push   %rbp
4bc1: mov    %rsp,%rbp
4bc4: push   %rbx
4bc5: push   %rax
4bc6: cmp    $0x1,%edi
4bc9: ja     0x4bde
4bcb: mov    $0xffffffff,%ebx
4bd0: cmp    $0x9,%esi
4bd3: jb     0x4c03
4bd5: lea    0xb2ff(%rip),%rcx
4bdc: jmp    0x4be5
4bde: lea    0xa6d1(%rip),%rcx
4be5: mov    0xf4ac(%rip),%rdi
4bec: lea    0xb3b2(%rip),%rsi
4bf3: lea    0xa3e7(%rip),%rdx
4bfa: xor    %eax,%eax
4bfc: xor    %ebx,%ebx
4bfe: call   0x85a0
4c03: mov    %ebx,%eax
4c05: add    $0x8,%rsp
4c09: pop    %rbx
4c0a: pop    %rbp
4c0b: ret

85a0: jmp    *0xbbb2(%rip)        # 0x14158

Strings: 0xffa5 %s failed: %s\n, 0xefe1 sceGnmLogicalCuIndexToPhysicalCuIndex, 0xf2b6 invalid value for engine, 0xfedb invalid value for cuIndex.

Tested

Windows 11 Pro 10.0.26300, WinLibs GCC, Release, head 1415816433 (on main 8f7c957ed0):

  • 2 of 2 pass, none Not Run, with the test executable rebuilt at this head: guest_gnm_driver and public_headers. The libSceGnmDriver library target builds too.

  • TestQueries in core/libs/tests/GuestGnmDriver.cpp (lines 127-133 at 1415816433) checks the ring base address and the mask call with first arguments 0, 1, 7 and 0xffffffff, including masks 0, 0x1f, 0xabcd and 0xffffffff.

  • Negative controls at this head, each rebuilt and run, each failing guest_gnm_driver (1 of 1 failed):

    • NotImplemented_nid_no_patch(__func__) put back in both bodies, which is main's behaviour, with this branch's test: it aborts with sceGnmGetTheTessellationFactorRingBufferBaseAddress not implemented.
    • The mask call returning mask & 0xff.
    • The ring base address returning 0xf0000000 (the 32-bit truncation).
  • After the controls, the test executable and the library were rebuilt and the 2 tests pass again.

  • The two changed declarations: every file on the tree that names them was mapped to its target and built (guest_gnm_driver_tests, libSceGnmDriver); none outside this branch's own files.

  • tools/check_conventions.py --base upstream/main on the committed head 1415816433: all checks pass.

  • tools/pr_overlap.py --branch feat/gnm-cu-mask-tess-ring --jobs 8 at 1415816433, against 1,769 open pull requests: 1 shares a file, and the run failed closed on it, #14212, which conflicts with main, for docs/dev/debt/libSceGnmDriver.md. Its diff of that file only inserts blank lines between entries, one of them right before the entry this branch cuts; it names neither call. Whichever lands later keeps that blank line.

  • Linux and macOS were not built or run. No title was run, and no GPU test is involved.
    Upkeep at head 975e93eba4 (main 39a172839a merged in; the merge touched no file this branch changes):

  • 2 of 2 pass, none Not Run (100% tests passed, 0 tests failed out of 2), with both test executables rebuilt at this head and the libSceGnmDriver target built: guest_gnm_driver and guest_avplayer.

  • tools/check_conventions.py --base upstream/main on the committed head 975e93eba4: all checks pass.

  • review-tools/sig_users.py HEAD --build at this head: the two changed declarations are named in 3 files, none outside this branch's own changes, and both targets that name them (guest_gnm_driver_tests, libSceGnmDriver) build.

  • tools/pr_overlap.py --branch feat/gnm-cu-mask-tess-ring --jobs 8 at this head, against 1,939 open pull requests: 2 share a file with the branch, none has a conflicting line, and the run failed closed on #14212, which conflicts with main itself, for docs/dev/debt/libSceGnmDriver.md. Its diff was searched by hand at this head for sceGnmGetTheTessellationFactorRingBufferBaseAddress and sceGnmLogicalCuMaskToPhysicalCuMask in every added and removed line: neither appears.

  • The negative controls above were not repeated at this head; the branch's own diff against main is unchanged by the merge.

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

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5205285592 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/16882). Originally posted by [BunnyFl](https://github.com/BunnyFl) on 2026-11-07T19:53:13Z. --- ### What `sceGnmLogicalCuMaskToPhysicalCuMask` and `sceGnmGetTheTessellationFactorRingBufferBaseAddress` threw. Firmware 13.42 `libSceGnmDriver.sprx` answers both without reading memory or calling anything: | Export | NID | Firmware 13.42 body | Returns here | |---|---|---|---| | `sceGnmLogicalCuMaskToPhysicalCuMask` | `RU74kek-N0c` | `mov %esi,%eax; ret` at `0x4c10` | its second argument, unchanged | | `sceGnmGetTheTessellationFactorRingBufferBaseAddress` | `ln33zjBrfjk` | `movabs $0xff0000000,%rax; ret` at `0x4c70` | `0xff0000000` | - `core/libs/prx/libSceGnmDriver/Export.cpp:559` and `:568`, declarations at `core/libs/prx/libSceGnmDriver/include/Api.hpp:44` and `:46` (at `1415816433`). - The mask call takes `(std::uint32_t, std::uint32_t mask)` and returns `std::uint32_t` (`core/libs/prx/libSceGnmDriver/include/Api.hpp:46`): the body at `0x4c10` reads only `esi` and writes only `eax`, so the first argument is left unnamed and its width is not claimed. Returning the full 32 bits of `mask` reproduces `mov %esi,%eax` at `0x4c10` for any value in `esi`. - The ring base address returns `std::uint64_t` (`core/libs/prx/libSceGnmDriver/include/Api.hpp:44`), since `movabs` at `0x4c70` writes all of `rax`. `docs/dev/debt/libSceGnmDriver.md:11` (at `1415816433`): the entry covered both CU calls and said the mask mapping "depends on which units are disabled on each chip and is not documented". The 13.42 module returns the mask unchanged (`0x4c10`), so the mask call leaves the entry, which is cut to `sceGnmLogicalCuIndexToPhysicalCuIndex` (`docs/dev/debt/libSceGnmDriver.md:11`). That one still throws: its body at `0x4bc0` (0x4c bytes) returns `0xffffffff` when the first argument is at most 1 (unsigned) and the second is below 9. Otherwise it calls the PLT stub at `0x85a0` (`jmp *0x14158`) with `"%s failed: %s\n"` (`0xffa5`), its own name (`0xefe1`) and `"invalid value for engine"` (`0xf2b6`, first argument above 1) or `"invalid value for cuIndex"` (`0xfedb`), and returns 0. Which import the stub at `0x85a0` reaches (slot `0x14158`) was not resolved, so the message is not reproduced and the entry records it (`docs/dev/debt/libSceGnmDriver.md:11`). ### Source Firmware 13.42 `system/common/lib/libSceGnmDriver.sprx` (sha256 `0169144cf56c80cff9c89d1c7c136f288ea7983584231ae77825a7631f5c260f`), read from disassembly, not run on a console. The module's dynamic symbol table gives `RU74kek-N0c` at `0x4c10` (size 3) and `ln33zjBrfjk` at `0x4c70` (size 0xb). Each body, every instruction to its return: ``` 4c10: mov %esi,%eax 4c12: ret 4c70: movabs $0xff0000000,%rax 4c7a: ret ``` The index call, for the debt entry (`0x4bc0`, to its return): ``` 4bc0: push %rbp 4bc1: mov %rsp,%rbp 4bc4: push %rbx 4bc5: push %rax 4bc6: cmp $0x1,%edi 4bc9: ja 0x4bde 4bcb: mov $0xffffffff,%ebx 4bd0: cmp $0x9,%esi 4bd3: jb 0x4c03 4bd5: lea 0xb2ff(%rip),%rcx 4bdc: jmp 0x4be5 4bde: lea 0xa6d1(%rip),%rcx 4be5: mov 0xf4ac(%rip),%rdi 4bec: lea 0xb3b2(%rip),%rsi 4bf3: lea 0xa3e7(%rip),%rdx 4bfa: xor %eax,%eax 4bfc: xor %ebx,%ebx 4bfe: call 0x85a0 4c03: mov %ebx,%eax 4c05: add $0x8,%rsp 4c09: pop %rbx 4c0a: pop %rbp 4c0b: ret 85a0: jmp *0xbbb2(%rip) # 0x14158 ``` Strings: `0xffa5` `%s failed: %s\n`, `0xefe1` `sceGnmLogicalCuIndexToPhysicalCuIndex`, `0xf2b6` `invalid value for engine`, `0xfedb` `invalid value for cuIndex`. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Windows 11 Pro 10.0.26300, WinLibs GCC, Release, head `1415816433` (on `main` `8f7c957ed0`): - **2 of 2 pass, none Not Run**, with the test executable rebuilt at this head: `guest_gnm_driver` and `public_headers`. The `libSceGnmDriver` library target builds too. - `TestQueries` in `core/libs/tests/GuestGnmDriver.cpp` (lines 127-133 at `1415816433`) checks the ring base address and the mask call with first arguments 0, 1, 7 and `0xffffffff`, including masks `0`, `0x1f`, `0xabcd` and `0xffffffff`. - **Negative controls** at this head, each rebuilt and run, each failing `guest_gnm_driver` (1 of 1 failed): - `NotImplemented_nid_no_patch(__func__)` put back in both bodies, which is `main`'s behaviour, with this branch's test: it aborts with `sceGnmGetTheTessellationFactorRingBufferBaseAddress not implemented`. - The mask call returning `mask & 0xff`. - The ring base address returning `0xf0000000` (the 32-bit truncation). - After the controls, the test executable and the library were rebuilt and the 2 tests pass again. - The two changed declarations: every file on the tree that names them was mapped to its target and built (`guest_gnm_driver_tests`, `libSceGnmDriver`); none outside this branch's own files. - `tools/check_conventions.py --base upstream/main` on the committed head `1415816433`: all checks pass. - `tools/pr_overlap.py --branch feat/gnm-cu-mask-tess-ring --jobs 8` at `1415816433`, against 1,769 open pull requests: 1 shares a file, and the run failed closed on it, #14212, which conflicts with `main`, for `docs/dev/debt/libSceGnmDriver.md`. Its diff of that file only inserts blank lines between entries, one of them right before the entry this branch cuts; it names neither call. Whichever lands later keeps that blank line. - Linux and macOS were not built or run. No title was run, and no GPU test is involved. **Upkeep at head `975e93eba4`** (`main` `39a172839a` merged in; the merge touched no file this branch changes): - **2 of 2 pass, none Not Run** (100% tests passed, 0 tests failed out of 2), with both test executables rebuilt at this head and the `libSceGnmDriver` target built: `guest_gnm_driver` and `guest_avplayer`. - `tools/check_conventions.py --base upstream/main` on the committed head `975e93eba4`: all checks pass. - `review-tools/sig_users.py HEAD --build` at this head: the two changed declarations are named in 3 files, none outside this branch's own changes, and both targets that name them (`guest_gnm_driver_tests`, `libSceGnmDriver`) build. - `tools/pr_overlap.py --branch feat/gnm-cu-mask-tess-ring --jobs 8` at this head, against 1,939 open pull requests: 2 share a file with the branch, none has a conflicting line, and the run failed closed on [#14212](https://github.com/boykopovar/AnyPS5/pull/14212), which conflicts with `main` itself, for `docs/dev/debt/libSceGnmDriver.md`. Its diff was searched by hand at this head for `sceGnmGetTheTessellationFactorRingBufferBaseAddress` and `sceGnmLogicalCuMaskToPhysicalCuMask` in every added and removed line: neither appears. - The negative controls above were not repeated at this head; the branch's own diff against `main` is unchanged by the merge. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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 - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/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!16882
No description provided.