feat(libSceAjm): build sceAjmBatchJobRunBufferRa jobs as firmware 13.42 does #12372

Merged
zaryabzip merged 1 commit from upstream-pr/12372 into main 2026-10-30 05:57:51 +00:00
zaryabzip commented 2026-10-28 11:44:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by zaryabzip on 2026-10-28T11:44:38Z.


What

Makes sceAjmBatchJobRunBufferRa write the bytes firmware 13.42 writes, and implements the throwing libSceAjmi copy with the same routine. It builds on #11238 (now merged): the test reuses its libSceAjmi loader and the libSceAjmi.prx argument.

Merge order with #3205, which also changes core/libs/tests/GuestAjm.cpp and needs a rebase: this PR, then #3205 rebased on top (proposed on #3205).

BunnyFl ran 13.42's sceAjmBatchJobRunBufferRa from libSceAjm.sprx (0xb90) and libSceAjmi.sprx (0xc50) in an x86-64 emulator on a 0xCC-filled buffer. Both modules wrote the same bytes, returned the same pointer and called no import (layout, flags). It has not been measured on a console. Against main, the routine differs in two ways:

  • Header words keep old bits.
    • The job header writes bits 0-25 (kind 0, then the low 20 bits of the instance) and keeps bits 26-31.
    • A buffer chunk writes only its kind and direction (bits 0-4) and keeps the rest.
    • The flags chunk writes bits 0-25 and keeps bits 26-31.
    • main writes all of these words fresh, as sceAjmBatchJobInlineBuffer did before #11238's review.
  • Flags are masked to 0x0000e00000001fff. Bits 0-12 go to the second word, and bits 45-47 go to the payload. The rest are dropped. main stores every bit. The same mask is prosper's AJM_RUN_FLAGS_MASK.

The run left two points open, because the fill had those bits clear:

  • bit 5 of a buffer chunk is kept;
  • bits 24-25 of the flags chunk are written.

Both follow the PS4 trace already recorded in docs/dev/debt/libSceAjm.native.md.

The libSceAjm reader already ignores the kept bits. TestConsoleStaleHeaderBits covers that, and the end-to-end run jobs in TestConsoleBufferJobs and TestConsoleInlineBuffer now go through stale bits and still decode.

sceAjmBatchJobRunBufferRa no longer forwards to sceAjmBatchJobRunSplitBufferRa. Neither sceAjmBatchJobRunSplitBufferRa nor sceAjmBatchJobControlBufferRa was run, so both still write fresh words and every flag bit. The debt entry says so.

In libSceAjmi, sceAjmBatchJobRunBufferRa_nid_disambig1 now has the full signature and the same writes. That makes both of its declared exports implemented.

The test checks both libraries against BunnyFl's bytes:

  • the full 0x50-byte job with a return address, and the 0x40-byte job without one;
  • the return values;
  • the job header for instance 0xABCDEF;
  • the flags chunk for each value in the flags table.

TestConsoleBufferJobs now expects the kept bits in the run job's chunk words.

Tested

Rebased onto main 578b8311ac for the review; the rebase was clean and only context lines changed. Windows 11 Home 25H2 (i7-11800H, WinLibs MinGW-w64 GCC 15.2.0 UCRT r7, CMake 4.3.1, Ninja 1.13.2, Release, BUILD_TESTING=ON) at 6a7a2c7ccf, and Ubuntu 24.04.5 on WSL2 (GCC 13.3.0, CMake 3.28.3) with it merged into main 1db077e876:

  • No warnings in the changed files on either host.
  • ctest -R "guest_ajm|atrac9": 100% tests passed, 0 tests failed out of 7 on Windows, and out of 8 on Linux (Linux adds guest_ajm_teardown).
  • guest_ajm with --repeat until-fail:3: 3 of 3 on both hosts.
  • Baseline: on main 1db077e876 with only this GuestAjm.cpp, guest_ajm builds and then aborts on both hosts (Windows exit 0xc0000409). Require gives no message, but the return address maps to TestConsoleBufferJobs, the function whose run-chunk expectation this PR changes.
  • The patched libSceAjmi.prx exports stlghnic3Jc and ElslOCpOIns once each, and libSceAjm.prx and libSceAjm.native.prx export the builder NIDs once each.
  • tools/check_conventions.py passes. tools/pr_overlap.py lists only #3205, whose order is above.

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 (Claude Code)
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5049908143 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12372). Originally posted by [zaryabzip](https://github.com/zaryabzip) on 2026-10-28T11:44:38Z. --- ### What Makes `sceAjmBatchJobRunBufferRa` write the bytes firmware 13.42 writes, and implements the throwing libSceAjmi copy with the same routine. It builds on #11238 (now merged): the test reuses its libSceAjmi loader and the `libSceAjmi.prx` argument. Merge order with #3205, which also changes `core/libs/tests/GuestAjm.cpp` and needs a rebase: this PR, then #3205 rebased on top ([proposed on #3205](https://github.com/boykopovar/AnyPS5/pull/3205#issuecomment-6481999792)). BunnyFl ran 13.42's `sceAjmBatchJobRunBufferRa` from `libSceAjm.sprx` (0xb90) and `libSceAjmi.sprx` (0xc50) in an x86-64 emulator on a 0xCC-filled buffer. Both modules wrote the same bytes, returned the same pointer and called no import ([layout](https://github.com/boykopovar/AnyPS5/pull/11238#issuecomment-6442306780), [flags](https://github.com/boykopovar/AnyPS5/pull/11238#issuecomment-6450694292)). It has not been measured on a console. Against `main`, the routine differs in two ways: - **Header words keep old bits.** - The job header writes bits 0-25 (kind 0, then the low 20 bits of the instance) and keeps bits 26-31. - A buffer chunk writes only its kind and direction (bits 0-4) and keeps the rest. - The flags chunk writes bits 0-25 and keeps bits 26-31. - `main` writes all of these words fresh, as `sceAjmBatchJobInlineBuffer` did before #11238's review. - **Flags are masked to `0x0000e00000001fff`.** Bits 0-12 go to the second word, and bits 45-47 go to the payload. The rest are dropped. `main` stores every bit. The same mask is prosper's `AJM_RUN_FLAGS_MASK`. The run left two points open, because the fill had those bits clear: - bit 5 of a buffer chunk is kept; - bits 24-25 of the flags chunk are written. Both follow the PS4 trace already recorded in `docs/dev/debt/libSceAjm.native.md`. The libSceAjm reader already ignores the kept bits. `TestConsoleStaleHeaderBits` covers that, and the end-to-end run jobs in `TestConsoleBufferJobs` and `TestConsoleInlineBuffer` now go through stale bits and still decode. `sceAjmBatchJobRunBufferRa` no longer forwards to `sceAjmBatchJobRunSplitBufferRa`. Neither `sceAjmBatchJobRunSplitBufferRa` nor `sceAjmBatchJobControlBufferRa` was run, so both still write fresh words and every flag bit. The debt entry says so. In libSceAjmi, `sceAjmBatchJobRunBufferRa_nid_disambig1` now has the full signature and the same writes. That makes both of its declared exports implemented. The test checks both libraries against BunnyFl's bytes: - the full 0x50-byte job with a return address, and the 0x40-byte job without one; - the return values; - the job header for instance 0xABCDEF; - the flags chunk for each value in the flags table. `TestConsoleBufferJobs` now expects the kept bits in the run job's chunk words. ### 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. --> Rebased onto `main` 578b8311ac for the review; the rebase was clean and only context lines changed. Windows 11 Home 25H2 (i7-11800H, WinLibs MinGW-w64 GCC 15.2.0 UCRT r7, CMake 4.3.1, Ninja 1.13.2, Release, `BUILD_TESTING=ON`) at 6a7a2c7ccf, and Ubuntu 24.04.5 on WSL2 (GCC 13.3.0, CMake 3.28.3) with it merged into `main` 1db077e876: - No warnings in the changed files on either host. - `ctest -R "guest_ajm|atrac9"`: `100% tests passed, 0 tests failed out of 7` on Windows, and `out of 8` on Linux (Linux adds `guest_ajm_teardown`). - `guest_ajm` with `--repeat until-fail:3`: 3 of 3 on both hosts. - Baseline: on `main` 1db077e876 with only this `GuestAjm.cpp`, `guest_ajm` builds and then aborts on both hosts (Windows exit 0xc0000409). `Require` gives no message, but the return address maps to `TestConsoleBufferJobs`, the function whose run-chunk expectation this PR changes. - The patched `libSceAjmi.prx` exports `stlghnic3Jc` and `ElslOCpOIns` once each, and `libSceAjm.prx` and `libSceAjm.native.prx` export the builder NIDs once each. - `tools/check_conventions.py` passes. `tools/pr_overlap.py` lists only #3205, whose order is above. ### 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: <!-- #PR, or none --> none - [x] Fixes: <!-- issue it closes as Fixes #N, or none --> none - [x] Unblocks: <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> none - [x] GPUs tested: <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> n/a - [x] AI-assisted: <!-- yes / no --> yes (Claude Code)
MarcZX10 commented 2026-10-28 12:00:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-28T12:00:38Z.

Review: CHANGES_REQUESTED


Reviewed exact head 6deff286e38136ecdd53e663b81bb0a056a6e724. The focused Linux build completed for guest_ajm_tests and libSceAjmi (215 Ninja steps). Native execution aborts before test code because this host lacks required Zen 2 CPU features; running the same test under qemu-x86_64 -cpu max succeeds (exit 0). git diff --check and tools/check_conventions.py --base upstream/main pass. The hosted conventions, intake, labels, eligibility and report checks pass; the Windows test is still pending.

One integration item remains under CONTRIBUTING.md: the PR overlap workflow could not compare #3205 because that branch conflicts with main. I inspected the shared GuestAjm.cpp changes and ran a three-way merge of the exact heads; it reports content conflicts at the include/declaration area and test insertion points. #3205 is still open and has needs rebase; I found no documented merge-order agreement. Please coordinate with its author on which change should land first and record the order (and Depends on if this PR needs #3205) so the test-file conflict is handled deliberately. This is an integration request, not a request to drop either PR.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5682236047 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12372#pullrequestreview-5682236047). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-28T12:00:38Z. **Review:** CHANGES_REQUESTED --- Reviewed exact head `6deff286e38136ecdd53e663b81bb0a056a6e724`. The focused Linux build completed for `guest_ajm_tests` and `libSceAjmi` (215 Ninja steps). Native execution aborts before test code because this host lacks required Zen 2 CPU features; running the same test under `qemu-x86_64 -cpu max` succeeds (exit 0). `git diff --check` and `tools/check_conventions.py --base upstream/main` pass. The hosted conventions, intake, labels, eligibility and report checks pass; the Windows test is still pending. One integration item remains under `CONTRIBUTING.md`: the PR overlap workflow could not compare #3205 because that branch conflicts with `main`. I inspected the shared `GuestAjm.cpp` changes and ran a three-way merge of the exact heads; it reports content conflicts at the include/declaration area and test insertion points. #3205 is still open and has `needs rebase`; I found no documented merge-order agreement. Please coordinate with its author on which change should land first and record the order (and `Depends on` if this PR needs #3205) so the test-file conflict is handled deliberately. This is an integration request, not a request to drop either PR.
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!12372
No description provided.