Repository navigation
feat(libSceNpTrophy): answer the trophy set, group and count helpers as firmware 13.42 does - #13005
Conversation
…s firmware 13.42 does Firmware 13.42's sceNpTrophySystemDbgCtl, GetDbgParam, GetDbgParamInt, SetDbgParam and SetDbgParamInt each return 0x80551692 and do nothing else.
…as firmware 13.42 does Firmware 13.42's sceNpTrophyNumInfoGetTotal, GroupArrayGetNum, SetInfoGetTrophyNum, SetInfoGetTrophyFlagArray and ConfigHasGroupFeature read only their arguments: sums, bit counts, an OR of the flag arrays and one feature bit.
Progress report (7d5f46e → 85ff681)📈 System libraries: 44.73% (+0.06%, +10 implemented functions) ✅ 10 implemented
Changed libraries (implemented exports)
|
rooklz
left a comment
There was a problem hiding this comment.
Approving. I checked the diff against BunnyFl's section-2 measurements and section-3 reading (comment) and against the PR's own test.
Provenance / scope
- The five helpers match the comment exactly: the 4-word wrapping sum, popcount of word 0 only, popcount of bytes 0x00–0x3F, a 16-byte OR of +0x00/+0x10/+0x20/+0x30 with the rest of the output untouched, and
HasGroupFeaturereturning 0 for null and otherwiseconfig[0x90] & 1. Like the module, the first four have no null check. The other 73 stay throwing, which matches sections 3–5. Source 2 is cited in the debt entry. - No other code in main calls these exports, so the parameterised declarations break no callers.
Mechanics (head 34b21b0, base bb04a4f, main 52f212e)
git merge-treeagainst main andgit diff --checkare both clean.check_conventions.pypasses.pr_overlap.py: 0 of 1443 open PRs overlap. #12957 is the declared parent.- clang x86_64
-fsyntax-onlyonExport.cppandGuestNpTrophyHelpers.cpp: 0 errors. The windows lane passes.
Behaviour (standalone on macOS, x86_64, ASan+UBSan)
- I built the five PR function bodies verbatim into a dylib and ran the unmodified
GuestNpTrophyHelpers.cppagainst it:NpTrophy helper tests passed, rc=0. - 13 mutants, 13 killed (134): null config → 1,
& 3, offset 0x8f, popcount of words 0+1, sum of 3 words, saturating 64-bit sum, 32-byte output, OR missing the 4th array,&instead of|, off-by-one array offset, flag-array call returning 1, popcount over 128 and over 48 bytes.
Non-blocking
- The
sceNpTrophySetInfoGetTrophyFlagArrayreturn value wasn't measured. The PR answers 0 and says so in the Functional entry. Since the result is assumed, a maintainer may want that one sentence moved under Silent stubs, or the return value read in BunnyFl's next native run (the test already pins it to 0, so the change would be a single row).
AI-assisted: yes (Claude Code)
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — changes requested
The five helpers are otherwise supported by the reported module analysis and tests, but the flag-array helper's return value is unknown while the implementation and test both assume success is 0.
What I ran
Reviewed head 34b21b0b3f838085d7f47b0abfddb066c7216d08 against current upstream main 52f212ec053f917455f2f87674ddb708dcc545d8; the merge preview is clean. The PR is explicitly stacked on open #12957. I inspected the changed exports, declarations, tests and debt entry and ran the repository checks below. No local build or tests were run.
git merge-tree --write-tree refs/remotes/upstream/main refs/review/pr-13005-head
git diff --check refs/remotes/upstream/main...refs/review/pr-13005-head
python3 tools/check_conventions.py --base upstream/main --head refs/review/pr-13005-headResults
| Check | Result |
|---|---|
| Merge preview | Clean |
| Diff check | Passed (no output) |
| Repository conventions | Passed |
| Hosted Windows workflow | Passed |
| Focused tests | Author reports 7/7 Windows and 6/6 Linux guest_np_trophy tests passing, with the new helper test repeated 3 times; not independently rerun |
| Negative control | Author reports the helper test aborts on the #12957-only baseline at the first new helper; not independently reproduced |
Findings
Blocking
-
sceNpTrophySetInfoGetTrophyFlagArrayreturns 0, andGuestNpTrophyHelpers.cppasserts that return value. The debt entry and PR body both say the firmware module's return value was not reported. The function's output bytes are measured, but its return is part of the public ABI and is not established by those observations.Please capture the helper's return value from the firmware 13.42 module or confirm it from the disassembly, then update the implementation and assertion. If it remains unmeasured, keep that result explicitly unresolved rather than treating 0 as firmware-matched.
Non-blocking
- The four argument-only helper calculations are consistent with the reported firmware-module runs; the config feature helper is described from disassembly. The reported module execution is not a physical-console measurement.
Sources
- Helper return implementation at the reviewed head
- Return-value assertion at the reviewed head
- Unknown return recorded at the reviewed head
Not verified
I did not locally build or run tests. The reported Windows/WSL2 test results are author-provided; no physical PS5 run is reported.
To get this to a good state
Please provide the measured or disassembled return result and update the code, test and debt entry to agree. I will re-run the same source checks on the new head.
|
@MarcZX10 Agreed. The return value isn't established, and the test shouldn't pin 0. @BunnyFl One more detail from the same 13.42 runs, if you have it: what does |
|
@zaryabzip @MarcZX10 It returns a value: the number of set bits in the 16-byte flag array it has just written, from 0 to 128. From the disassembly (firmware 13.42
Native run (the same harness as before; 3 runs, identical apart from the stack address):
The full AI-assisted: yes (Claude Code) |
…GetTrophyFlagArray Firmware 13.42's helper tail-calls its bit loop, which counts the set bits of the output it writes, so the export returns 0 to 128.
|
@MarcZX10 Fixed in 85ff681. BunnyFl settled the return value from the disassembly and a native run: it's the set-bit count of the 16-byte output, 0 to 128. The export now returns that count. The test pins 128, 4, 0 and 1, and the debt entry and description cite the reading. It passes on Windows and on WSL2 merged into |
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — looks good
The exact head implements the five measured trophy helpers, including the corrected set-bit return value, and the available test evidence supports the change.
What I ran
Reviewed PR head 85ff6817f0732bdb9965f102a07aa764f504b3d2 against base 9624d8c6bb9e96b7aa92b815f55690f69b0a88d5; refreshed current main is f46f453a56f91d77e29ce0cbd7fe5bfb2fb69834. The merge preview with current main is clean (tree 36d0d39c6b66c8c055d71ff7925fb1dcb01bedb0). Environment: Linux 6.1.0-54-amd64 x86_64; no local compiler, build, or test run.
git diff --check upstream/main...refs/review/pr-13005-current
python3 tools/check_conventions.py --base upstream/main
git merge-tree --write-tree upstream/main refs/review/pr-13005-current
gh pr checks 13005 --repo boykopovar/AnyPS5Results
| Check | Result |
|---|---|
| Diff whitespace check | Pass; exit 0, no output. |
| Repository conventions | Pass. |
Merge preview with current main |
Clean. |
| Hosted Windows job | Pass on this exact head; 11m41s. |
| Other hosted jobs | Eligibility, labels, report pass; Linux and specialized jobs skipped. |
| Focused trophy tests | The author reports 7 Windows tests and 6 WSL2 tests pass, with the new helper test passing 3/3 on both hosts. WSL2 was tested with this PR merged into main at 7a225bb303; I did not rerun either environment. |
Unedited output from local and hosted checks
$ git diff --check upstream/main...refs/review/pr-13005-current
(exit 0; no output)
$ python3 tools/check_conventions.py --base upstream/main
All conventions checks passed.
$ git merge-tree --write-tree upstream/main refs/review/pr-13005-current
36d0d39c6b66c8c055d71ff7925fb1dcb01bedb0
$ gh pr checks 13005 --repo boykopovar/AnyPS5
conventions pass 21s https://github.com/boykopovar/AnyPS5/actions/runs/40970129188/job/123784511071
labels pass 7s https://github.com/boykopovar/AnyPS5/actions/runs/40970129177/job/123786982471
windows pass 11m41s https://github.com/boykopovar/AnyPS5/actions/runs/40970131246/job/123786593567
linux skipping 0 https://github.com/boykopovar/AnyPS5/actions/runs/40970131246/job/123786596405
register-context skipping 0 https://github.com/boykopovar/AnyPS5/actions/runs/40970131246/job/123786595212
relinker skipping 0 https://github.com/boykopovar/AnyPS5/actions/runs/40970131246/job/123786595146
relinker-asan skipping 0 https://github.com/boykopovar/AnyPS5/actions/runs/40970131246/job/123786596254
write-watch skipping 0 https://github.com/boykopovar/AnyPS5/actions/runs/40970131246/job/123786595233
eligibility pass 4s https://github.com/boykopovar/AnyPS5/actions/runs/40970131246/job/123784513129
report pass 29s https://github.com/boykopovar/AnyPS5/actions/runs/40970131561/job/123784513881
The Windows/WSL2 focused results are author-reported in the PR description, not local runs. PR #12957 is still open; this PR contains its already-approved dependency commit 161792da247e010f24fa9c5924ab44daf215eb47.
Negative control
| Assertion | Change to code under test | Did the new test fail? |
|---|---|---|
| Unimplemented trophy helpers are detected | The author reports testing the added helper test against #12957 with the helpers unimplemented. | Yes; it stopped at sceNpTrophyNumInfoGetTotal not implemented. |
| The flag-array return count is checked | The author reports testing the new test against the previous implementation, which returned 0. | Yes; it failed the expected 128-bit result. |
Findings
Blocking
None found in the reviewed head. The implementation and tests cover the wrapping count sum, relevant bit counts, 16-byte OR output with untouched trailing bytes, the config feature bit, and the measured 0–128 return count.
Non-blocking
The behavior is based on firmware 13.42 disassembly and native-emulator runs reported by the author; it was not independently measured on a physical console.
Sources
- Trophy helper implementations and tests at this head
- Firmware reading and native return-value run reported by BunnyFl
- Initial firmware 13.42 helper evidence
Not verified
I did not build or run tests locally, independently reproduce the Windows or WSL2 results, run Linux hosted product tests, or test on a physical console. The specialized hosted jobs were skipped.
|
Windows run (Windows 11, MSYS2 UCRT64 GCC 16.1), this PR (85ff681) merged onto main f7f03da, 3x each:
Note: AI-assisted: yes (Claude Code) |
|
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.
|
What
Five libSceNpTrophy helpers that read only their arguments now do what firmware 13.42's module does. @BunnyFl sorted the 78 remaining NpTrophy exports from the disassembly (comment) and ran the first four natively, three runs with identical output:
sceNpTrophyNumInfoGetTotal(numInfo): the sum of the fouruint32counts, wrapping at 32 bits.{1, 20, 300, 4000}gives 4321, and{0xffffffff, 2, 0, 0}gives 1.sceNpTrophyGroupArrayGetNum(groupArray): the number of set bits in the firstuint32only.sceNpTrophySetInfoGetTrophyNum(setInfo): the number of set bits in bytes 0x00–0x3F, the four 16-byte trophy flag arrays. Later bytes aren't read.sceNpTrophySetInfoGetTrophyFlagArray(setInfo, flagArray): writes the OR of the four arrays into the first 16 bytes offlagArrayand leaves the rest alone. It returns the number of set bits in that output, 0 to 128. BunnyFl's follow-up read this from the disassembly, where the export tail-calls the bit loop that counts, and confirmed it natively: 0, 1, 120 and 128 for four inputs.sceNpTrophyConfigHasGroupFeature(config): 0 for a null config, otherwise bit 0 of the byte at +0x90.The first four have no null checks in the module, so they fault on null here too. The declarations gain these parameters. libSceNpTrophy goes from 17 to 22 of 97. Of the 78, the module sends 45 to the trophy service and the rest read its state or its config object, so those keep throwing.
GuestNpTrophyHelpers.cpplooks the five up at runtime, becausemaindeclares them without parameters. It checks BunnyFl's values: the sums, the bit counts, that bytes past 0x3F and past the 16-byte output are left alone, the OR and the feature bit. Onmainit builds and aborts at the first call.#12957, which this was stacked on, has merged.
Tested
Windows 11 Home 10.0.26200 (WinLibs MinGW-w64 GCC 15.2.0 UCRT r7, CMake 4.3.1, Ninja 1.13.2) at 85ff681, and Ubuntu 24.04.5 on WSL2 (GCC 13.3.0, CMake 3.28.3, Ninja 1.11.1) with it merged into
main7a225bb:-Wformat-truncationlinesmainalready has inExport.cpp, one line lower because of the new<bit>include.ctest -R "^guest_np_trophy": all pass (7 on Windows, 6 on Linux). The new test printsNpTrophy helper tests passedand passes 3 of 3 on--repeat until-fail:3.guest_np_ps4_imports, which also includes the header, passes too.libSceNpTrophy/include/Api.hpprebuilds without new warnings, and the header builds on its own.CMakeLists.txtblock, the test builds and then aborts withsceNpTrophyNumInfoGetTotal not implementedon both hosts (Windows exit 0xc0000409, Linux SIGABRT).a full flag array did not return 128 set bitson both hosts.tools/check_conventions.pypasses. No other open PR touches libSceNpTrophy.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)