fix(libSceAgc): emit a 2^40-byte acquire range as whole address space #16197

Merged
MarcZX10 merged 4 commits from upstream-pr/16197 into main 2026-11-08 23:16:34 +00:00
MarcZX10 commented 2026-11-05 20:38:22 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-05T20:38:22Z.


What

sceAgcDcbAcquireMem checked sizeBytes > (1 << 40) before rounding the range outward to 256-byte units. A range of exactly 2^40 bytes, or one that rounds outward to 2^40 bytes (for example base 0x1 with size 2^40 - 0xff), passed the check and sizeBytes >> 8 was then truncated to 0 in the 32-bit size field. A size field of 0 is the whole-address-space encoding, but the packet kept the original base address, so the emitted packet did not describe the requested range.

The check now runs after rounding, and a rounded size of 2^40 bytes or more is emitted as the whole-address-space packet (size field 0, address 0), the same as sizes above 2^40 already were. sceAgcAcbAcquireMem forwards to this emitter, so there is one site.

Commits:

  • fix(libSceAgc): round first, then apply the whole-space rule.
  • test(libSceAgc): an acquire of exactly 1 TiB; an unaligned acquire that rounds up to 1 TiB (the control with 2^40 - 256 is in the same test).
  • docs(libSceAgc): debt entry saying the console result for these ranges is not measured.

Tested

  • python3 tools/check_conventions.py --base upstream/main: passed. git diff --check upstream/main: clean.
  • tools/pr_precheck.py (no-build): see the checks on the PR; it does not build or run tests.
  • Not run: the agc_commands build and ctest, and the negative control (fix removed, new tests expected to fail). A first build attempt failed on a stale local SPIRV-Headers checkout unrelated to this change; a rebuild is queued and its result will be added here.

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
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5178356652 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/16197). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-05T20:38:22Z. --- ### What `sceAgcDcbAcquireMem` checked `sizeBytes > (1 << 40)` before rounding the range outward to 256-byte units. A range of exactly 2^40 bytes, or one that rounds outward to 2^40 bytes (for example base `0x1` with size `2^40 - 0xff`), passed the check and `sizeBytes >> 8` was then truncated to 0 in the 32-bit size field. A size field of 0 is the whole-address-space encoding, but the packet kept the original base address, so the emitted packet did not describe the requested range. The check now runs after rounding, and a rounded size of 2^40 bytes or more is emitted as the whole-address-space packet (size field 0, address 0), the same as sizes above 2^40 already were. `sceAgcAcbAcquireMem` forwards to this emitter, so there is one site. Commits: - `fix(libSceAgc)`: round first, then apply the whole-space rule. - `test(libSceAgc)`: an acquire of exactly 1 TiB; an unaligned acquire that rounds up to 1 TiB (the control with `2^40 - 256` is in the same test). - `docs(libSceAgc)`: debt entry saying the console result for these ranges is not measured. ### Tested - `python3 tools/check_conventions.py --base upstream/main`: passed. `git diff --check upstream/main`: clean. - `tools/pr_precheck.py` (no-build): see the checks on the PR; it does not build or run tests. - Not run: the `agc_commands` build and ctest, and the negative control (fix removed, new tests expected to fail). A first build attempt failed on a stale local SPIRV-Headers checkout unrelated to this change; a rebuild is queued and its result will be added here. ### Checklist - [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 - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
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!16197
No description provided.