fix(libSceAgc): write the console's poll and cache control words in sceAgcDcbAcquireMem #16855

Merged
xXPBSXx merged 8 commits from upstream-pr/16855 into main 2026-11-11 15:08:35 +00:00
xXPBSXx commented 2026-11-07 18:26:25 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-11-07T18:26:25Z.


What

sceAgcDcbAcquireMem divided the poll cycles by 40 and wrote the cache control as given. On a PS5 the poll word is the poll cycles shifted right by four, and bit 14 of the cache control also sets bit 15 in the control word. It now does the same. sceAgcAcbAcquireMem writes the same packet through this call, so its poll word changes too; it was not measured on its own. The size, address and engine words already matched. A poll of 0x100000 or more (the shifted value above 0xffff) is written as 0xffff on the console, without an error, so it is saturated here at 0xffff (before: it threw above 0x27ffff); a poll of exactly 0xfffff and sceAgcDcbWaitRegMem were not measured. The title call sites checked have a constant poll of 0x190; about 190 sites do not load the poll as a constant and were not checked. The console's other differences (a size of 1 << 40, an unbounded size, the cbDbOp bits) are not changed here and are listed in the debt entry.

Tested

Measured on a PS5 with firmware 11.60 (kernel_get_fw_version 0x11600005), from a homebrew payload process (ps5-payload-sdk v0.45, elfldr) that only builds packets in its own memory, on 2026-11-06 at 20:55 UTC and 22:26 UTC; the console's own clock read about 1 h 41 min more (see the first comment). A title process may differ.

sceAgcDcbAcquireMem(cb, 0, 0, 0x4380, 0x100000, 0x1000, poll) word 6 PS5, payload process, firmware 11.60 main before here now
poll 0, 1, 15 0 0 0
poll 16 1 0 1
poll 39, 40 2 0, 1 2
poll 160 10 4 10
poll 400 25 10 25
poll 1000000 62500 25000 62500
word 7 for gcrControl PS5, payload process, firmware 11.60 main before here now
0x4000, 0x4001, 0x4300, 0x4380 0xc000, 0xc001, 0xc300, 0xc380 0x4000, 0x4001, 0x4300, 0x4380 0xc000, 0xc001, 0xc300, 0xc380
0x8000, 0x9000, 0xc380, 0x1234 unchanged unchanged unchanged
0x77fff 0x7ffff 0x77fff 0x7ffff

The test agc_commands now checks 18 poll values and 15 cache control values from the measurement, and that sceAgcAcbAcquireMem saturates the same way. On Ubuntu 24.04 under WSL2 with GCC 13.3.0 and an AddressSanitizer build, on main 72a1308d27 the test commit alone fails ("acquire packet does not round its range outward to 256 bytes"), and with the fix commit on the same main agc_commands and agc_initialization pass. The five polls above 0xfffff were measured on 2026-11-09 at 22:33 UTC (probe in the second comment); on head 8dd63f39a2 the new test commit alone fails ("acquire poll interval overflow") and passes with the fix commit. tools/check_conventions.py --base upstream/main passes.

Overlap: the open pull requests that change DcbFlow/src/Memory.cpp, tests/Commands.cpp or docs/dev/debt/libSceAgc.md were checked on 2026-11-07 between 18:05 UTC and 18:19 UTC against main 07c8408713 (the base of this change is the older 72a1308d27; it still merges without a conflict): six pull requests, found by listing all open pull requests by update time. #12315 and #14212 already conflict with main without this change, and #14212 also conflicts in docs/dev/debt/libSceAgc.md with this change, because it adds a blank line between every entry. #16197 (emit a 2^40-byte acquire range as whole address space) conflicts in DcbFlow/src/Memory.cpp only with this change, because both edit the same function, sceAgcDcbAcquireMem: it changes how the size is rounded and when the whole address space is written, this change the poll and cache control words, which are different lines. Whichever merges second needs a small rebase. #16194, #8314 and #16334 merge cleanly with and without this change. Re-checked on 2026-11-10 at about 06:10 UTC against main 53bb992782 (this head merges into it without a conflict): of the open pull requests that change these files, #12315 and #14212 conflict with main without this change as well, and #16987, #17613 and #17742 merge cleanly with and without it; #16197, #16194 and #16334 have merged since.

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 (tests build packets on the CPU; no Vulkan instance)
  • AI-assisted: yes

AI-assisted (Claude Code).

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5204627571 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/16855). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-11-07T18:26:25Z. --- ### What `sceAgcDcbAcquireMem` divided the poll cycles by 40 and wrote the cache control as given. On a PS5 the poll word is the poll cycles shifted right by four, and bit 14 of the cache control also sets bit 15 in the control word. It now does the same. `sceAgcAcbAcquireMem` writes the same packet through this call, so its poll word changes too; it was not measured on its own. The size, address and engine words already matched. A poll of 0x100000 or more (the shifted value above 0xffff) is written as 0xffff on the console, without an error, so it is saturated here at 0xffff (before: it threw above 0x27ffff); a poll of exactly 0xfffff and `sceAgcDcbWaitRegMem` were not measured. The title call sites checked have a constant poll of 0x190; about 190 sites do not load the poll as a constant and were not checked. The console's other differences (a size of 1 << 40, an unbounded size, the `cbDbOp` bits) are not changed here and are listed in the debt entry. ### Tested Measured on a PS5 with firmware 11.60 (`kernel_get_fw_version` 0x11600005), from a homebrew payload process (ps5-payload-sdk v0.45, elfldr) that only builds packets in its own memory, on 2026-11-06 at 20:55 UTC and 22:26 UTC; the console's own clock read about 1 h 41 min more (see the first comment). A title process may differ. | `sceAgcDcbAcquireMem(cb, 0, 0, 0x4380, 0x100000, 0x1000, poll)` word 6 | PS5, payload process, firmware 11.60 | `main` before | here now | |---|---|---|---| | poll 0, 1, 15 | 0 | 0 | 0 | | poll 16 | 1 | 0 | 1 | | poll 39, 40 | 2 | 0, 1 | 2 | | poll 160 | 10 | 4 | 10 | | poll 400 | 25 | 10 | 25 | | poll 1000000 | 62500 | 25000 | 62500 | | word 7 for gcrControl | PS5, payload process, firmware 11.60 | `main` before | here now | |---|---|---|---| | 0x4000, 0x4001, 0x4300, 0x4380 | 0xc000, 0xc001, 0xc300, 0xc380 | 0x4000, 0x4001, 0x4300, 0x4380 | 0xc000, 0xc001, 0xc300, 0xc380 | | 0x8000, 0x9000, 0xc380, 0x1234 | unchanged | unchanged | unchanged | | 0x77fff | 0x7ffff | 0x77fff | 0x7ffff | The test `agc_commands` now checks 18 poll values and 15 cache control values from the measurement, and that `sceAgcAcbAcquireMem` saturates the same way. On Ubuntu 24.04 under WSL2 with GCC 13.3.0 and an AddressSanitizer build, on `main` `72a1308d27` the test commit alone fails ("acquire packet does not round its range outward to 256 bytes"), and with the fix commit on the same `main` `agc_commands` and `agc_initialization` pass. The five polls above 0xfffff were measured on 2026-11-09 at 22:33 UTC (probe in the second comment); on head `8dd63f39a2` the new test commit alone fails ("acquire poll interval overflow") and passes with the fix commit. `tools/check_conventions.py --base upstream/main` passes. Overlap: the open pull requests that change `DcbFlow/src/Memory.cpp`, `tests/Commands.cpp` or `docs/dev/debt/libSceAgc.md` were checked on 2026-11-07 between 18:05 UTC and 18:19 UTC against `main` `07c8408713` (the base of this change is the older `72a1308d27`; it still merges without a conflict): six pull requests, found by listing all open pull requests by update time. #12315 and #14212 already conflict with `main` without this change, and #14212 also conflicts in `docs/dev/debt/libSceAgc.md` with this change, because it adds a blank line between every entry. #16197 (emit a 2^40-byte acquire range as whole address space) conflicts in `DcbFlow/src/Memory.cpp` only with this change, because both edit the same function, `sceAgcDcbAcquireMem`: it changes how the size is rounded and when the whole address space is written, this change the poll and cache control words, which are different lines. Whichever merges second needs a small rebase. #16194, #8314 and #16334 merge cleanly with and without this change. Re-checked on 2026-11-10 at about 06:10 UTC against `main` `53bb992782` (this head merges into it without a conflict): of the open pull requests that change these files, #12315 and #14212 conflict with `main` without this change as well, and #16987, #17613 and #17742 merge cleanly with and without it; #16197, #16194 and #16334 have merged since. ### 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: none <!-- #PR, or none --> - [x] Fixes: none <!-- issue it closes as Fixes #N, or none --> - [x] Unblocks: none <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> - [x] GPUs tested: n/a (tests build packets on the CPU; no Vulkan instance) <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> - [x] AI-assisted: yes <!-- yes / no --> AI-assisted (Claude Code). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
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!16855
No description provided.