fix(libSceAjm.native): stop checking sceAjmInitialize's reserved #16974
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/16974"
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 zaryabzip on 2026-11-08T03:15:28Z.
What
This fixes a regression from #15906.
sceAjmInitializeno longer checksreserved, as before #15906; only a null output returns0x80930005. #15906 refused any nonzero value, and retail titles that pass one stopped working.Titles that pass a nonzero
reserved, all of which work on a console:0x300000000, loaded as a 64-bit immediate right before the call, in five titles: LEGO Batman: Legacy of the Dark Knight (PPSA16833), Planet Zoo (PPSA18026), Ghost of Tsushima (PPSA02225), Death Stranding 2 (PPSA02015, #17659) and Cyberpunk 2077 (PPSA03974). With #15906 they fault during start-up. Tamalero found the immediate and bisected the first one (comment).0x20, from Hades II (PPSA36082)'s bundled FMOD (kiansaeidnia's report). It masks a global to 7 bits and passes it. With #15906, FMOD gets0x80930005, loads no sound banks and the game shows "Audio disabled".Why ignore it rather than check part of it. An earlier version of this PR compared only the low 32 bits. That fixed the
0x300000000titles but still refused Hades II's0x20. The three known results don't fit any rule the sources support:reserved0x809300050x3000000000x20BunnyFl's 13.42 read shows the native module passes all 64 bits to the AJM driver without checking them, and the driver's own check hasn't been read. So the safe choice is the one that refuses no value a retail title passes. The census case is recorded as a known difference in the debt entry.
Test.
GuestAjm.cpp(ctestguest_ajm) checks thatsceAjmInitializereturns 0 and writes distinct contexts for0x20and0x300000000, and finalizes each. The row that pinned the stack-address refusal is removed. The two invalid-context rows usehighHalf + 1, since each extra context takes the next ID.Overlap. The overlap bot couldn't compare #14212 (janzezno's blank-line reformat of the debt files), because it already conflicts with
main. I checked it withgit merge-tree. Its conflict hunks inlibSceAjm.native.mdare the same two with this PR as withmain. ThesceAjmInitializeline is already inside one of them, so this PR adds no new conflict.Tested
a3ae88f573(tree3cb23d653f), onmain3aa0ac20df(comment):ctest -R guest_ajmpasses 5 of 5 in each of 3 runs.main'sAjm.cpp,guest_ajmaborts on both at the newsceAjmInitialize(0x300000000, &highHalf)row (GuestAjm.cpp:1021).Ajm.cpporGuestAjm.cpp.242942dcbb, aborted atGuestAjm.cpp:1035: the new row allocated the context the test had used as the unallocated one.a3ae88f573fixes this.a3ae88f573merged ontomaine6108f3d8e, a clean merge (comment). Windows 11 Enterprise 22621, WinLibs GCC 15.2 UCRT, Release:guest_ajmpasses 3 of 3, none skipped.a3ae88f573merged ontomain57aaadb561, with no revert and no local changes (comment). On Linux, the title runs the full 300 s withAPS5_NET_DISCONNECTED=1, 3,782 frames and no error.mainalone segfaults 5–10 s in.784752f2bcmerged ontomain522df1e176, a clean merge (comment). Windows 10 Pro 22H2, RTX 5080 (driver 621.14), WinLibs GCC 15.2.0 r7, Release:mainfaults during start-up, writing to0xa4on theRenderthread.eboot.elfloadsmovabs $0x300000000,%rdibefore the call too, at va0x14d97e.784752f2bcmerged ontomain0bae53facd, a clean merge (comment). Ubuntu 26.04.1, RTX 4070 Ti, GCC 15.2, Release:reserved = 0x300000000as a 64-bit immediate too.mainsegfaults after 3 s. With this PR it runs 106 s, to a later GPU stop that has nothing to do with AJM.2516536621(tree486cb5d33c), onmain3aa0ac20df, after thesceAjmFinalize(highHalf)row was added (comment):ctest -R guest_ajm, run once, Release, on the same toolchains as above: 5 of 5 pass on Windows and 6 of 6 on WSL2.Ajm.cpporGuestAjm.cpp.maind792f1ad5f, a clean merge (comment): all 6guest_ajm*tests pass. Withreserved != 0restored and the new test kept,guest_ajmaborts.maind34caa9dbe(comment): the title boots to its title screen again.maincrashes in libkernel about 5 s in.2516536621).4f1bc06940ignoresreservedentirely; its rerun is below.4f1bc06940(tree85c1d308b6), onmain3aa0ac20df, afterreservedstopped being checked (comment):ctest -R guest_ajm, run once, Release, on the same toolchains as above: 5 of 5 pass on Windows and 6 of 6 on WSL2.2516536621'sAjm.cpp(the low-32-bit check),guest_ajmaborts at the newsceAjmInitialize(0x20, &lowValue)row (GuestAjm.cpp:1019).Ajm.cpporGuestAjm.cpp.Checked so far, on macOS (arm64, where no full build is possible):
2516536621differs froma3ae88f573only in the debt entry's wording (784752f2bc) and onesceAjmFinalize(highHalf)test line, which the rerun above covers.GuestAjm.cpppasses an x86-64clang++ -fsyntax-only.Ajm.cppneeds the ATRAC9 headers, so it wasn't checked here. The change there is one cast.tools/check_conventions.py --base mainpasses.main3aa0ac20dfor with any open PR that merges with it.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)Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-11-09T07:51:34Z.
Review: APPROVED
Read
784752f2bcagainstmainb66ca0e85a(the merge preview is clean).Change.
static_cast<std::uint32_t>(reserved) != 0keeps the one measured refusal (the census passed a stack address, whose low 32 bits are never zero) and accepts0x300000000. Ghost of Tsushima passes that value as well, and with this head it gets past start-up (my run above).libSceAjm.nativeis the only library in the tree that exportssceAjmInitialize, so there is no second implementation to keep in step.Test. The new row is right, and the change to the old rows is needed.
other + 1was the unallocated context ID thatsceAjmBatchWaitandsceAjmBatchStartwere checked against, but with the extrasceAjmInitializethat ID is nowhighHalf, an allocated context. Moving those checks tohighHalf + 1keeps them testing an unallocated ID, which they would otherwise silently stop doing.Small thing, not blocking. The test finalizes
otherbut nothighHalf. Per the debt entry, finalization doesn't release anything yet, so it changes no result. AsceAjmFinalize(highHalf)next to the existing one would keep the pairing if finalization starts releasing contexts later.Docs. The entry now gives the low-32-bit rule, the PPSA16833 immediate and what the 13.42 module does with the upper word, all sourced.
I didn't rebuild
guest_ajmmyself; JJenkx's Windows run and your WSL and Windows runs cover it.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-11-09T08:09:34Z.
Review: APPROVED
Re-checked
2516536621: the only change since784752f2bcisRequire(sceAjmFinalize(highHalf) == 0);inTestBatchContextOwnership, so the context initialised with the nonzero high half is now released likeother. It still merges cleanly into currentmain. Approval carried over to this head.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-11-09T17:11:52Z.
Review: APPROVED
Re-checked
4f1bc06940. Ignoringreservedmakes sense given the three data points: a set that rejects a stack address but accepts both0x300000000and0x20has no rule the sources support. Accepting everything is what titles need, and it's what the code did before #15906.contextreturns0x80930005, so every value the low-32-bit version accepted is still accepted, GoT's0x300000000included (I ran GoT past this call on the earlier head). Hades II's0x20is now accepted too.0x20and0x300000000each get a fresh, distinct context, and both are finalized.highHalf + 1is still the first unallocated context, because contexts come fromg_nextContext.fetch_addandhighHalfis the last one taken, so the invalid-context rows still probe an id nobody owns. No refusal row is left, in line with the positive-only test guidance.AI-assisted: yes (Claude Code)