feat(libSceNpCommon): implement the npid platform-tag exports #12829
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/12829"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by hypermoist on 2026-10-29T11:48:45Z.
What
Implements five npid platform-tag exports in place of their
NotImplementedstubs:sceNpSetPlatformType,sceNpIntGetPlatformType,sceNpIntSetPlatformType,sceNpUtilCanonicalizeNpIdForPs4andsceNpUtilCanonicalizeNpIdForPsp2. The signatures and behaviour are read fromlibSceNpCommon.sprxof firmware 13.60 (disassembly, not measured on a console).This is stacked on #12825. Only the last commit (
feat(libSceNpCommon): implement the npid platform-tag exports) is new. Both PRs edit the same debt-file entry, so this one is based on #12825 to avoid a conflict.The platform tag is the 4 bytes at
opt[4..7]of anNpIdFull. Types 0 to 3 are: no tag (opt[4] == 0),ps3\0,psp2andps4\0. The existingsceNpGetPlatformTypenow shares that lookup, with unchanged behaviour.sceNpSetPlatformType(NpIdFull*, uint32_t type): writes the tag for types 0 to 3. Returns0x80550003for a null npid and0x80550004for any other type.sceNpIntGetPlatformType(const NpIdFull*): likesceNpGetPlatformType, but also reports thecomptag as type 4.sceNpGetPlatformTypestill returns0x80550004forcomp, as the module does.sceNpIntSetPlatformType(NpIdFull*, uint32_t type): writescompfor type 4 and otherwise behaves likesceNpSetPlatformType.sceNpUtilCanonicalizeNpIdForPs4/ForPsp2(NpIdFull*, int32_t replace):0x80550601for a null npid.replacefirst clears the tag.reserved[0]is not 1 then returns0x80550605, which has no name in any source, keeping the cleared tag.ps4\0orpsp2.The debt file replaces the five "signature unknown" entries with one entry that states the source and the quirks. The entry that said these functions throw now lists only
sceNpGetNavSdkVersion.Tested
Linux (CachyOS, GCC, Release):
ctest --test-dir build -R 'np_common|public_headers' --output-on-failure, 70/70 passed.GuestNpCommon.cppcovers:compand the out-of-range types;replace, and withreserved[0]not 1;Comparison against the firmware code: I relinked the 13.60 module with this repo's relinker and ran all six functions (including the existing
sceNpGetPlatformType) under unicorn (x86-64 emulation on a PC, not a console).optbytes, ten tags (the five real ones and near misses such asps5\0,\0ps4andcomq), andreserved[0]drawn from 0, 1, 2 and 255. Arguments were drawn from 0 to 6,0x100,0x80000000,0xFFFFFFFFand random values.Windows not built. Not run on a console.
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)Assisted With AI: Yes. All tests were run locally on computer hardware (AMD Ryzen 5 5600G, 32 GB RAM, NVIDIA GeForce RTX 3060, CachyOS Linux 7.3, GCC 16.2), not on an actual console.
🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by rooklz on 2026-10-29T12:01:07Z.
Review: COMMENTED
I reviewed only the new commit,
846ca893ac(git diff 9b48ab5214 846ca893ac). My setup was macOS arm64 with Apple clang, ASan and UBSan, and-fno-sanitize-recover=all. I built a standalone harness from the six platform-tag functions, copied verbatim fromExport.cpp, plus the newtestIdsrows fromGuestNpCommon.cpp. I didn't run the full CMake lane.Result: the new rows pass with no sanitizer reports.
check_conventions(base main),git diff --checkandgit merge-treeagainst main are all clean.pr_overlapprobed 1390 PRs. It reports only #12830, which is stacked on this commit and declaresDepends on. The removedPendingExports.cppstubs line up one-to-one with the new definitions, and theApi.hppsignatures match.Mutation check: I applied 17 single-line mutants to
platformTypeOf,canonicalizeNpId,setPlatformTagand the four new exports.opt[4] == 0shortcut,>=changed to>in the setter, filling the tag unconditionally, tagging a refused npid before thereserved[0]check,IntSetwritingcompfor every type ≥ 4, and the wrong null error inIntGet.compafterplatformTypeOfinstead of before.compnever matches aPLATFORM_TAGSentry, and itsopt[4]is not 0, so the result is the same.platformTypeOfchecks the whole tag for 0 instead ofopt[4], so00 70 73 34would be invalid instead of type 0.opt[4].IntGetmatchescompon its first byte only.replace != 0changed toreplace == 1.replace != 0changed to(replace & 0xff) != 0.replace != 0changed toreplace > 0.reserved[0] != 1changed toreserved[0] == 0.replaceclears all ofoptinstead ofopt[4..7].setPlatformTagalso zeroesopt[0..3].sceNpSetPlatformTypeclears the tag.Your unicorn differential probably already pins these, since its corpus has the
comq-style near misses,reserved[0]drawn from 0/1/2/255 and a full 40-byte compare. The in-repo test only coversreserved[0]values 0 and 1,replacevalues 0 and 1, and checks the tag rather than the whole npid. The rows below kill all 10. They go at the end of the new block intestIds, after the null canonicalize row, and reusetags,UTIL_INVALID_NP_IDandnpIdWithTag. Please confirm the expected values against your differential before taking them; I derived them from your implementation, not from the module.With these rows the harness passes, and the 10 survivors are killed. The equivalent mutant still survives, as expected.
Nit (same as on #12825): the line "Assisted With AI: Yes But all test done locally on actual hardware" conflicts with "Not run on a console" in Tested. It would help to say which hardware was meant.
Imported from boykopovar/AnyPS5. Originally posted by rooklz on 2026-10-29T12:38:52Z.
Review: APPROVED
I re-reviewed the PR at
2f6f0e13a9. Since the commit I reviewed (846ca893ac), the only changes are tests: the merge of #12825's test commit (GuestNpCommonRuntime.cpp) and the new rows inGuestNpCommon.cpp.Export.cpp,Api.hppand the debt file are the same as before.Setup: the same standalone harness as last time. The six platform-tag functions are copied verbatim from
Export.cppat this head, along with the whole platform part oftestIds, including the new rows. I built it with Apple clang on macOS arm64 using ASan, UBSan and-fno-sanitize-recover=all.Results:
compfirst byte,replace == 1/& 0xff/> 0,reserved[0] == 0, replace clearing all ofopt, the setter zeroingopt[0..3], and a refused type clearing the tag.compafterplatformTypeOf) still survives, as expected.check_conventions(base main),git diff --checkandgit merge-treeagainst main5454cd2e45are all clean.Thanks for checking each row against 13.60 under unicorn. The AI line is resolved too.
Approving. The order with #12825 is unchanged: this lands after it.
Imported from boykopovar/AnyPS5. Originally posted by CnRJay on 2026-11-01T19:54:06Z.
Review: COMMENTED
Withdrawn. This review applied a title-ID/log requirement that is not in CONTRIBUTING (
Unblocks: noneis allowed), and it contained no code review.