fix(libSceAgcDriver): validate PM4 index base and indirect draw count address bounds #14110

Merged
slopgobblercobbler merged 1 commit from upstream-pr/14110 into main 2026-11-05 23:15:05 +00:00
slopgobblercobbler commented 2026-10-31 19:16:50 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by slopgobblercobbler on 2026-10-31T19:16:50Z.


What

Validates index base alignment and address space bounds in PM4 opcode 0x26 (INDEX_BASE), requiring 2-byte alignment and upper 16-bit address bounds (packet[2] <= 0xffffu). Also validates 48-bit address space bounds on indirect multi-draw count buffer addresses (packet[7] <= 0xffffu) in opcodes 0x2c and 0x38.

Tested

  • python tools/check_conventions.py --base upstream/main --head HEAD (0 findings)
  • Unit tests added in core/libs/prx/libSceAgcDriver/tests/Pm4.cpp covering misaligned index base addresses, high address bits in INDEX_BASE, and out-of-bounds indirect multi-draw count buffer addresses on both 0x2c and 0x38.

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 (CPU PM4 packet validation tests)
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5100722952 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14110). Originally posted by [slopgobblercobbler](https://github.com/slopgobblercobbler) on 2026-10-31T19:16:50Z. --- ### What Validates index base alignment and address space bounds in PM4 opcode 0x26 (`INDEX_BASE`), requiring 2-byte alignment and upper 16-bit address bounds (`packet[2] <= 0xffffu`). Also validates 48-bit address space bounds on indirect multi-draw count buffer addresses (`packet[7] <= 0xffffu`) in opcodes 0x2c and 0x38. ### Tested - `python tools/check_conventions.py --base upstream/main --head HEAD` (0 findings) - Unit tests added in `core/libs/prx/libSceAgcDriver/tests/Pm4.cpp` covering misaligned index base addresses, high address bits in `INDEX_BASE`, and out-of-bounds indirect multi-draw count buffer addresses on both 0x2c and 0x38. ### 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 (CPU PM4 packet validation tests) - [x] AI-assisted: yes
MarcZX10 commented 2026-10-31 19:32:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-31T19:32:23Z.

Review: APPROVED


Reviewed — looks good

The PM4 validation changes reject misaligned or out-of-range addresses, and the exact-head Windows job passes all 14 selected PM4 tests.

What I ran

Reviewed head 812b91f65b7f0cbfbcf4c9c3b66825c7d22e4182 against base f14ae07e2961a7f033b1c8e6e9c0de8514eefa94; GitHub reports the PR mergeable. Environment: Linux 6.1.0-54-amd64, Python 3.11.2, GCC 12.2.0. No local build was run.

git diff --check f14ae07e2961a7f033b1c8e6e9c0de8514eefa94...812b91f65b7f0cbfbcf4c9c3b66825c7d22e4182
python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 14110
gh run view 41233462270 -R boykopovar/AnyPS5 --job 124633051841 --log

Results

Check Result
Diff check Passed.
Conventions, eligibility, intake, report, and library portability Passed on the PR head.
Dependency/mergeability precheck Passed; mergeable.
Hosted Windows PM4 tests Passed: 14/14 selected tests, including agc_driver_pm4.
ABI and test-quality helpers Could not run in the isolated PR worktree because the local-only helper scripts are absent there; this is a tooling limitation.
Labels Pending when checked.
Linux product, relinker, and sanitizer jobs Skipped by CI path eligibility.
Unedited relevant Windows log output
windows Build and run changed guest core/libs tests 2026-10-31T19:27:36.7193138Z [4/5] Linking CXX executable tests\agc_driver_pm4_tests.exe
windows Build and run changed guest core/libs tests 2026-10-31T19:27:37.5971326Z       Start 1090: agc_driver_pm4
windows Build and run changed guest core/libs tests 2026-10-31T19:27:38.1394907Z  8/14 Test #1090: agc_driver_pm4 ..........................   Passed    0.54 sec
windows Build and run changed guest core/libs tests 2026-10-31T19:27:42.4702128Z 100% tests passed, 0 tests failed out of 14
Unedited relevant precheck output
All conventions checks passed.

/usr/bin/python3: can't open file '/tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-14110-812b91f65b7f/head-812b91f65b7f-c805e08b/tools/pr_abi_audit.py': [Errno 2] No such file or directory
/usr/bin/python3: can't open file '/tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-14110-812b91f65b7f/head-812b91f65b7f-c805e08b/tools/pr_test_quality.py': [Errno 2] No such file or directory

Sources

Not verified

I did not run the C++ tests locally or test on Linux, a GPU, or a PS5 console. The Windows hosted job passed for this exact head.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5724564125 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14110#pullrequestreview-5724564125). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-31T19:32:23Z. **Review:** APPROVED --- # Reviewed — looks good The PM4 validation changes reject misaligned or out-of-range addresses, and the exact-head Windows job passes all 14 selected PM4 tests. ## What I ran Reviewed head `812b91f65b7f0cbfbcf4c9c3b66825c7d22e4182` against base `f14ae07e2961a7f033b1c8e6e9c0de8514eefa94`; GitHub reports the PR mergeable. Environment: Linux 6.1.0-54-amd64, Python 3.11.2, GCC 12.2.0. No local build was run. ```sh git diff --check f14ae07e2961a7f033b1c8e6e9c0de8514eefa94...812b91f65b7f0cbfbcf4c9c3b66825c7d22e4182 python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 14110 gh run view 41233462270 -R boykopovar/AnyPS5 --job 124633051841 --log ``` ## Results | Check | Result | |---|---| | Diff check | Passed. | | Conventions, eligibility, intake, report, and library portability | Passed on the PR head. | | Dependency/mergeability precheck | Passed; mergeable. | | Hosted Windows PM4 tests | Passed: 14/14 selected tests, including `agc_driver_pm4`. | | ABI and test-quality helpers | Could not run in the isolated PR worktree because the local-only helper scripts are absent there; this is a tooling limitation. | | Labels | Pending when checked. | | Linux product, relinker, and sanitizer jobs | Skipped by CI path eligibility. | <details><summary>Unedited relevant Windows log output</summary> ```text windows Build and run changed guest core/libs tests 2026-10-31T19:27:36.7193138Z [4/5] Linking CXX executable tests\agc_driver_pm4_tests.exe windows Build and run changed guest core/libs tests 2026-10-31T19:27:37.5971326Z Start 1090: agc_driver_pm4 windows Build and run changed guest core/libs tests 2026-10-31T19:27:38.1394907Z 8/14 Test #1090: agc_driver_pm4 .......................... Passed 0.54 sec windows Build and run changed guest core/libs tests 2026-10-31T19:27:42.4702128Z 100% tests passed, 0 tests failed out of 14 ``` </details> <details><summary>Unedited relevant precheck output</summary> ```text All conventions checks passed. /usr/bin/python3: can't open file '/tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-14110-812b91f65b7f/head-812b91f65b7f-c805e08b/tools/pr_abi_audit.py': [Errno 2] No such file or directory /usr/bin/python3: can't open file '/tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-14110-812b91f65b7f/head-812b91f65b7f-c805e08b/tools/pr_test_quality.py': [Errno 2] No such file or directory ``` </details> ## Sources - [PR-head PM4 address validation](https://github.com/boykopovar/AnyPS5/blob/812b91f65b7f0cbfbcf4c9c3b66825c7d22e4182/core/libs/prx/libSceAgcDriver/Execution/src/Pm4.cpp#L315-L318) - [PR-head indirect count validation](https://github.com/boykopovar/AnyPS5/blob/812b91f65b7f0cbfbcf4c9c3b66825c7d22e4182/core/libs/prx/libSceAgcDriver/Execution/src/Pm4.cpp#L354-L362) - [PR-head boundary tests](https://github.com/boykopovar/AnyPS5/blob/812b91f65b7f0cbfbcf4c9c3b66825c7d22e4182/core/libs/prx/libSceAgcDriver/tests/Pm4.cpp#L259-L260) - [PR-head count-address tests](https://github.com/boykopovar/AnyPS5/blob/812b91f65b7f0cbfbcf4c9c3b66825c7d22e4182/core/libs/prx/libSceAgcDriver/tests/Pm4.cpp#L452-L453) ## Not verified I did not run the C++ tests locally or test on Linux, a GPU, or a PS5 console. The Windows hosted job passed for this exact head.
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!14110
No description provided.