fix(libSceAjm.native): check sceAjmBatchJobRunSplit as firmware 13.42 does #15846
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/15846"
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-04T19:04:52Z.
What
sceAjmBatchJobRunSplitnow checks its arguments, and whether the job fits, in the order firmware 13.42'slibSceAjm.native.sprxdoes. That order comes from @BunnyFl's disassembly of the export (Z9NVCesiP0Q), posted on #15321 and left there for a follow-up. It was read from the module, not run on a console.maininfo, orsideband_output_size < 8:0x809300050x80930005NotImplemented(CheckedAppend)0x80930005NotImplementedoffset + (in + out) * 16 + 0x20 > size:0x80930012, withinfo->offsetmoved to that end anyway0x80930005for a count over 255,0x80930007when the job doesn't fitThe job size is the host's own record: a 32-byte
PackedJobplus 16 bytes per buffer, the same as the firmware's0x20 + 16 * (in + out).0x80930012isORBIS_AJM_ERROR_JOB_CREATIONin shadPS4'sajm_error.h.Still throws. These cases aren't refused by 13.42, but this implementation can't follow them:
Unchanged.
sceAjmBatchJobRun,DecodeSplit,GetGaplessDecode,GetInfoandGetCodecInfoused to call this export. They now call a helper with the old checks, because whether their 13.42 bodies share these checks is unread. That matters forGetCodecInfo, which passes the caller'sresult_sizeas the sideband size. The other builders keep0x80930007for a full batch. The null-list throw in that helper is astd::runtime_error, as elsewhere inAjm.cpp, sotools/progress.pycounts the five wrappers as implemented, as onmain. libSceAjm.native's counts are unchanged.Test.
TestBatchJobRunSplitCheckscovers:0x80930012and the offset moved to the job's end;0x80930012with the offset moved past the size, thensceAjmBatchJobClearContext's0x80930007on that batch.Since review. @BunnyFl's review found that 13.42 stores the job's end into
info->offsetbefore comparing it with the size (0x26c2). So the refusal still advances the offset, whichfeed151116now does. What later builders orsceAjmBatchStartBufferdo with an offset past the size is unread and left as it was:Appendrefuses with0x80930007.Three existing spots in
GuestAjm.cpppinned the old behaviour, and now follow the firmware:0x80930005;On
main, the test builds and aborts at the first null-list call inguest_ajm, whichmain'sCheckedAppendstill throws for (AJM batch job with a null buffer list and a nonzero buffer count not implemented).Overlap: five open PRs touch these files.
git merge-treemerges this cleanly with #12613 and #14226 (mine), #15491 (BunnyFl) and #14078. #14212 conflicts with it, but #14212 already conflicts withmain.Tested
632f88d054merged ontomain0263899e99, a clean merge.guest_ajmpasses in 3 of 3 runs. That is beforefeed151116.main+ #15855 +632f88d054.guest_ajmpasses, and withAjm.cppfrommainit aborts.feed151116merged ontomainb611e634f7(review):guest_ajmpasses. WithAjm.cppfrommainit aborts (0xc0000409). With the offset store removed ((void)end;) it aborts as well, so the reworked rows catch a missing store.feed151116on its base9ab6a281ea(comment): Ubuntu 24.04.5, GCC 13.3.0, and Windows 11 Home 25H2, WinLibs GCC 15.2.0 r7, both Release.ctest -R "guest_ajm|atrac9|ngs2"passes all 56 tests on WSL2 and all 55 on Windows (guest_ajm_teardownis Linux-only), and--repeat until-fail:3passes every round on both. WithAjm.cppfrommain,guest_ajmaborts with "AJM batch job with a null buffer list and a nonzero buffer count not implemented" (0xC0000409on Windows, SIGABRT on Linux).Checked so far, on macOS (arm64, no full build possible there):
Ajm.cpp, andGuestAjm.cpp, pass an x86-64clang++ -fsyntax-only.tools/check_conventions.py --base mainpasses.tools/progress.py --module libSceAjm.nativegives the same done and todo counts asmain(32 and 20).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 BunnyFl on 2026-11-04T20:05:38Z.
Review: CHANGES_REQUESTED
@zaryabzip thanks for taking this on. The check order, the codes and the job size all match firmware 13.42. One thing differs, and it's partly my fault: my disassembly note on #15321 left out a store, which I've now corrected there.
Confirmed bug (P2): a job refused with
0x80930012still advancesinfo->offseton 13.42libSceAjm.native.sprx(firmware 13.42, sha2568eea270172e7ea177e69fa7865493b72131670f87afa91798d7d749ac183d5c0),sceAjmBatchJobRunSplit=Z9NVCesiP0Qat0x2650, read to the return:0x27d1only restores the saved registers, so nothing puts the old offset back. I also ran the export underreview-tools/emu_sprx.py(a Unicorn harness with imports stubbed, not measured on a console):info->offsetbefore → after0x200x809300120x0→0x400x40, size0x600x809300120x40→0x802^32 + 1inputs + 1 output, size0x1000x809300120x0→0x10000000400x809300050x0→0x00x809300050x0→0x00x10000x0→0x40The
0x80930005refusals return before the store and leave the offset as it was; only the size refusal moves it.At this head,
sceAjmBatchJobRunSplitreturnsSCE_AJM_ERROR_JOB_CREATIONatcore/libs/prx/libSceAjm.native/src/Ajm.cpp:2085without touchinginfo->offset.TestBatchJobRunSplitCheckspins that:Require(info.offset == 0)atcore/libs/tests/GuestAjm.cpp:966after the threejobCreationrows, andRequire(info.offset == storage.size())atcore/libs/tests/GuestAjm.cpp:971after the last one. On 13.42 those rows leave the offset pastinfo->size.Suggested fix: on the size refusal, store
info->offset + sizeof(PackedJob) + buffers * sizeof(AjmBuffer)intoinfo->offsetbefore returning0x80930012(your 64-bit guard above it already keeps that sum from wrapping), and give each refused row its ownAjmBatchInfoin the test with the advanced offset as the expected value. I haven't read what the console's later builders orsceAjmBatchStartBufferdo with an offset pastsize, so I'd leave that out of this PR and say so in the debt entry.What I ran
Windows 11 Pro 10.0.26300, WinLibs GCC 15.2, Release.
main0263899e99doesn't compilelibSceAgcDriveratcore/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp:1623onmain(#15301 against #10472; fix in #15855). The tree here ismain+ #15855 + this PR (91877ff97f, both merges clean):guest_ajm: 1 of 1 passes.core/libs/prx/libSceAjm.native/src/Ajm.cppfrommainaborts (0xc0000409), so the test reaches the change.tools/pr_overlap.py --branchon this head: 6 open PRs share files; 4 were compared with no overlapping lines. The 2 it couldn't compare (they conflict withmain) I compared by hand: #13486 changessceAjmBatchJobRunBufferRaand a console-job helper inAjm.cpp, notsceAjmBatchJobRunSplitorAppendRun; #14212 only adds blank lines between entries ofdocs/dev/debt/libSceAjm.native.md.The rest checks out against 13.42:
0x80930005(0x2662,0x2685,0x26a0).(in + out) * 16 + 0x20againstinfo->sizeat+0x10. The0x20issizeof(PackedJob), asserted as 32 atcore/libs/prx/libSceAjm.native/src/Ajm.cpp:236.AjmBuffer(pointer andsize_t,core/libs/SceTypes.hpp:496).Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-04T20:43:33Z.
Review: APPROVED
@zaryabzip thanks, that's it.
feed151116matches 13.42: the size refusal now movesinfo->offsettooffset + 0x20 + (in + out) * 16(core/libs/prx/libSceAjm.native/src/Ajm.cpp:2085andcore/libs/prx/libSceAjm.native/src/Ajm.cpp:2087), and the0x80930005refusals still return before it, as at0x26c2in my previous review. The expected offsets inrefusedForare the ones the emulator run gave (0x1000000040for2^32 + 1inputs plus one output,0x20past the end for the full batch).What I ran
Windows 11 Pro 10.0.26300, WinLibs GCC 15.2, Release. This head merged cleanly onto
mainb611e634f7(f3fb5a15a3):guest_ajm: 1 of 1 passes.core/libs/prx/libSceAjm.native/src/Ajm.cppfrommainaborts (0xc0000409).main9f35c937da+ #15855 + this head (6280498c59): withinfo->offset = end;replaced by(void)end;(one match),guest_ajmaborts (0xc0000409). The reworked rows catch a missing offset store.tools/check_conventions.py --base upstream/main --headthis head, with the PR's title and description: all checks pass.Not run: a console. The firmware reading and the emulator run (imports stubbed) are the evidence for the offset store.