fix(libSceAgcDriver): validate PM4 write and copy data register destination bounds #14130

Merged
slopgobblercobbler merged 1 commit from upstream-pr/14130 into main 2026-11-06 15:54:55 +00:00
slopgobblercobbler commented 2026-10-31 19:57:50 +00:00 (Migrated from github.com)

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


What

In PM4 packet handling for IT_WRITE_DATA (opcode 0x37) and IT_COPY_DATA (opcode 0x40):

  • Validate that 32-bit register destination offsets and multi-register ranges do not exceed the 16-bit register space (< 0x10000u) and destination high address words are 0.
  • Validate destination select flags, returning appropriate errors for invalid or reserved destination selectors.
  • Update DecodeLabelWrite, ResolveStore, and DecodeStores to reject reserved, invalid, or non-memory destinations from decoding as memory writes.
  • Add comprehensive test coverage in core/libs/prx/libSceAgcDriver/tests/Pm4.cpp.

Tested

Host Clang 20 syntax compilation checks on modified driver execution and test sources. Verified python tools/check_conventions.py reports 0 findings.

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:5101041569 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14130). Originally posted by [slopgobblercobbler](https://github.com/slopgobblercobbler) on 2026-10-31T19:57:50Z. --- ### What In PM4 packet handling for `IT_WRITE_DATA` (opcode 0x37) and `IT_COPY_DATA` (opcode 0x40): - Validate that 32-bit register destination offsets and multi-register ranges do not exceed the 16-bit register space (< 0x10000u) and destination high address words are 0. - Validate destination select flags, returning appropriate errors for invalid or reserved destination selectors. - Update `DecodeLabelWrite`, `ResolveStore`, and `DecodeStores` to reject reserved, invalid, or non-memory destinations from decoding as memory writes. - Add comprehensive test coverage in `core/libs/prx/libSceAgcDriver/tests/Pm4.cpp`. ### Tested Host Clang 20 syntax compilation checks on modified driver execution and test sources. Verified `python tools/check_conventions.py` reports 0 findings. ### 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
MarcZX10 commented 2026-10-31 20:20:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-31T20:20:12Z.

Review: CHANGES_REQUESTED


Reviewed — changes requested

I found no source defect, but the required paired AGC validation evidence and VUID comparison are missing.

What I ran

Reviewed head 7ad84ad6d33dd4ab97937d6990731ea8f16a5cb8 against base 500d37a747c2b958e8696aa16213a0ee78d47505. Environment: Linux x86_64, Python 3.11.2, GCC 12.2.0. I did not build or compile during this initial review.

python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 14130
python3 tools/pr_test_quality.py --root /marc/AnyPS5 --json core/libs/prx/libSceAgcDriver/Execution/src/Pm4.cpp core/libs/prx/libSceAgcDriver/tests/Pm4.cpp
git diff --check 500d37a747c2b958e8696aa16213a0ee78d47505...7ad84ad6d33dd4ab97937d6990731ea8f16a5cb8
git grep -n 'tests/Pm4.cpp' 7ad84ad6d33dd4ab97937d6990731ea8f16a5cb8 -- core/libs/prx/libSceAgcDriver/CMakeLists.txt

Results

Check Result
Diff check Passed; exit 0, no output
Conventions and PR template Passed locally and on hosted CI
Changed PM4 source/tests Source inspection found the new register bounds and selector checks consistent with their decode paths; the C++ test target is registered in CMake
Test-quality heuristic One possible-unregistered-test warning; manually confirmed tests/Pm4.cpp is included in the test target and in the CTest registration loop
Hosted CI Windows passed; eligibility, intake, library portability, report and labels passed. Linux, relinker, ASAN and other specialized jobs were skipped.
No-build precheck The isolated checkout could not run two workspace-local helper scripts; I reran the quality heuristic from the workspace and checked registration manually. It performed no build-dependent tests.
Raw output from local checks
All conventions checks passed.

7ad84ad6d33dd4ab97937d6990731ea8f16a5cb8:core/libs/prx/libSceAgcDriver/CMakeLists.txt:2264:        tests/Pm4.cpp

{
  "findings": [
    {
      "path": "core/libs/prx/libSceAgcDriver/tests/Pm4.cpp",
      "line": 1,
      "kind": "possible-unregistered-cpp-test",
      "message": "Changed C++ test source path was not found literally in CMake files; inspect registration, generated source lists, and workflow coverage."
    }
  ],
  "negative_control_candidates": [],
  "limits": [
    "Heuristics can miss weak assertions and can flag valid tests; inspect every finding.",
    "A test that passes against base is not by itself proof that the PR test is inadequate.",
    "Negative controls are only candidates until the test actually runs against base and fails by assertion rather than import/setup error."
  ]
}

/usr/bin/python3: can't open file '/tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-14130-7ad84ad6d33d/head-7ad84ad6d33d-1ddef08e/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-14130-7ad84ad6d33d/head-7ad84ad6d33d-1ddef08e/tools/pr_test_quality.py': [Errno 2] No such file or directory

Findings

Blocking: The PR changes the AGC driver, but the PR description reports only host syntax compilation and does not include the repository-required paired focused test runs on main and this head with VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, ANYPS5_NO_SHADER_CACHE=1, and ANYPS5_REQUIRE_VULKAN=1, or a comparison showing no new VUIDs. Hosted Linux and specialized jobs were skipped, so they do not provide that evidence. Please attach both runs from the same machine and GPU, confirm the validation layer loaded in each log, and include the VUID comparison.

Non-blocking: I found no source-level defect. The test-registration heuristic warning is a false positive; tests/Pm4.cpp is registered in the CMake test target.

Sources

Not verified

No local build, CTest, Vulkan validation run, or GPU comparison was performed. The PR description's Clang syntax check was not independently reproduced.

To get this to a good state

Provide the paired validation-layer logs and VUID comparison requested above. I will rerun the same relevant checks on the new head.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5724767652 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14130#pullrequestreview-5724767652). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-31T20:20:12Z. **Review:** CHANGES_REQUESTED --- # Reviewed — changes requested I found no source defect, but the required paired AGC validation evidence and VUID comparison are missing. ## What I ran Reviewed head `7ad84ad6d33dd4ab97937d6990731ea8f16a5cb8` against base `500d37a747c2b958e8696aa16213a0ee78d47505`. Environment: Linux x86_64, Python 3.11.2, GCC 12.2.0. I did not build or compile during this initial review. ```sh python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 14130 python3 tools/pr_test_quality.py --root /marc/AnyPS5 --json core/libs/prx/libSceAgcDriver/Execution/src/Pm4.cpp core/libs/prx/libSceAgcDriver/tests/Pm4.cpp git diff --check 500d37a747c2b958e8696aa16213a0ee78d47505...7ad84ad6d33dd4ab97937d6990731ea8f16a5cb8 git grep -n 'tests/Pm4.cpp' 7ad84ad6d33dd4ab97937d6990731ea8f16a5cb8 -- core/libs/prx/libSceAgcDriver/CMakeLists.txt ``` ## Results | Check | Result | |---|---| | Diff check | Passed; exit 0, no output | | Conventions and PR template | Passed locally and on hosted CI | | Changed PM4 source/tests | Source inspection found the new register bounds and selector checks consistent with their decode paths; the C++ test target is registered in CMake | | Test-quality heuristic | One possible-unregistered-test warning; manually confirmed `tests/Pm4.cpp` is included in the test target and in the CTest registration loop | | Hosted CI | Windows passed; eligibility, intake, library portability, report and labels passed. Linux, relinker, ASAN and other specialized jobs were skipped. | | No-build precheck | The isolated checkout could not run two workspace-local helper scripts; I reran the quality heuristic from the workspace and checked registration manually. It performed no build-dependent tests. | <details><summary>Raw output from local checks</summary> ```text All conventions checks passed. 7ad84ad6d33dd4ab97937d6990731ea8f16a5cb8:core/libs/prx/libSceAgcDriver/CMakeLists.txt:2264: tests/Pm4.cpp { "findings": [ { "path": "core/libs/prx/libSceAgcDriver/tests/Pm4.cpp", "line": 1, "kind": "possible-unregistered-cpp-test", "message": "Changed C++ test source path was not found literally in CMake files; inspect registration, generated source lists, and workflow coverage." } ], "negative_control_candidates": [], "limits": [ "Heuristics can miss weak assertions and can flag valid tests; inspect every finding.", "A test that passes against base is not by itself proof that the PR test is inadequate.", "Negative controls are only candidates until the test actually runs against base and fails by assertion rather than import/setup error." ] } /usr/bin/python3: can't open file '/tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-14130-7ad84ad6d33d/head-7ad84ad6d33d-1ddef08e/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-14130-7ad84ad6d33d/head-7ad84ad6d33d-1ddef08e/tools/pr_test_quality.py': [Errno 2] No such file or directory ``` </details> ## Findings **Blocking:** The PR changes the AGC driver, but the PR description reports only host syntax compilation and does not include the repository-required paired focused test runs on `main` and this head with `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation`, `ANYPS5_NO_SHADER_CACHE=1`, and `ANYPS5_REQUIRE_VULKAN=1`, or a comparison showing no new VUIDs. Hosted Linux and specialized jobs were skipped, so they do not provide that evidence. Please attach both runs from the same machine and GPU, confirm the validation layer loaded in each log, and include the VUID comparison. **Non-blocking:** I found no source-level defect. The test-registration heuristic warning is a false positive; `tests/Pm4.cpp` is registered in the CMake test target. ## Sources - [Repository validation requirement](https://github.com/boykopovar/AnyPS5/blob/500d37a747c2b958e8696aa16213a0ee78d47505/CONTRIBUTING.md#L70) - [PM4 bounds checks and tests](https://github.com/boykopovar/AnyPS5/blob/7ad84ad6d33dd4ab97937d6990731ea8f16a5cb8/core/libs/prx/libSceAgcDriver/Execution/src/Pm4.cpp) - [CMake target and test registration for `tests/Pm4.cpp`](https://github.com/boykopovar/AnyPS5/blob/7ad84ad6d33dd4ab97937d6990731ea8f16a5cb8/core/libs/prx/libSceAgcDriver/CMakeLists.txt#L2263-L2279), [included in the registered AGC CTest target list](https://github.com/boykopovar/AnyPS5/blob/7ad84ad6d33dd4ab97937d6990731ea8f16a5cb8/core/libs/prx/libSceAgcDriver/CMakeLists.txt#L2899-L2910) ## Not verified No local build, CTest, Vulkan validation run, or GPU comparison was performed. The PR description's Clang syntax check was not independently reproduced. ## To get this to a good state Provide the paired validation-layer logs and VUID comparison requested above. I will rerun the same relevant checks on the new head.
MarcZX10 commented 2026-11-01 03:40:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-01T03:40:09Z.

Review: CHANGES_REQUESTED


Re-checked — new head, changes requested

The new head removes the questionable destination-4 throw assertion, but its required AGC validation evidence is still for an older base and head.

What I ran

Reviewed exact head 7101f798ac0cadbd2bd297dc77e2da21e5509532 (PR base dc9dc7eaaeaf99b1c491d426e68bb999def3da16). The latest upstream main I checked is ca82d0c0228597bf063b15e24aaac3b3cd1ce9d5; the PR merges cleanly onto it in the local preview. Environment: Linux x86_64, Python 3.11.2, GCC 12.2.0. I did not build or compile.

python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 14130
python3 tools/pr_stack_check.py 14130 --repo boykopovar/AnyPS5

Results

Check Result
Diff check and conventions Passed on the exact PR head.
Current-main merge preview Clean against ca82d0c0228597bf063b15e24aaac3b3cd1ce9d5.
Hosted CI Exact-head Windows, conventions, library portability, eligibility, report and labels passed. Linux and specialized jobs were skipped.
Author-provided GPU validation Detailed paired NVIDIA run is available for prior head 7ad84ad6d33dd4ab97937d6990731ea8f16a5cb8 against main 8a00f9c1cab0a4609f518eba09181cf7d9e25cb1. It reports no new VUIDs, but it does not cover this rebased head/current base.
Test assertion update Diff inspection confirms the destination-select-4 expectFailure assertion was removed; the implementation source is unchanged from the tested head.

Findings

Blocking: The paired run does not validate the current revision against the current base. Since that run, main advanced and changed Pm4.cpp; this PR was then rebased onto dc9dc7e, and the exact current head has no paired main/PR validation-layer run. The repository requires those focused runs on the same machine and GPU with ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, and VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, plus confirmation that the requested layer loaded and no new VUIDs appeared. Please provide the pair against current main and this head.

Non-blocking: I found no remaining issue with the removed destination-4 throw assertion.

Not verified

I did not run a build, CTest, or Vulkan/GPU test locally. The paired GPU results above are author-provided for the previous head/base, not independent results for this revision.

To get this to a good state

Attach the paired current-main/current-head focused logs and VUID comparison, confirming the validation layer loaded in both runs; I will re-check the same evidence on the exact new head.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5726267643 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14130#pullrequestreview-5726267643). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-01T03:40:09Z. **Review:** CHANGES_REQUESTED --- # Re-checked — new head, changes requested The new head removes the questionable destination-4 throw assertion, but its required AGC validation evidence is still for an older base and head. ## What I ran Reviewed exact head `7101f798ac0cadbd2bd297dc77e2da21e5509532` (PR base `dc9dc7eaaeaf99b1c491d426e68bb999def3da16`). The latest upstream `main` I checked is `ca82d0c0228597bf063b15e24aaac3b3cd1ce9d5`; the PR merges cleanly onto it in the local preview. Environment: Linux x86_64, Python 3.11.2, GCC 12.2.0. I did not build or compile. ```sh python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 14130 python3 tools/pr_stack_check.py 14130 --repo boykopovar/AnyPS5 ``` ## Results | Check | Result | |---|---| | Diff check and conventions | Passed on the exact PR head. | | Current-main merge preview | Clean against `ca82d0c0228597bf063b15e24aaac3b3cd1ce9d5`. | | Hosted CI | Exact-head Windows, conventions, library portability, eligibility, report and labels passed. Linux and specialized jobs were skipped. | | Author-provided GPU validation | Detailed paired NVIDIA run is available for prior head `7ad84ad6d33dd4ab97937d6990731ea8f16a5cb8` against `main` `8a00f9c1cab0a4609f518eba09181cf7d9e25cb1`. It reports no new VUIDs, but it does not cover this rebased head/current base. | | Test assertion update | Diff inspection confirms the destination-select-4 `expectFailure` assertion was removed; the implementation source is unchanged from the tested head. | ## Findings **Blocking:** The paired run does not validate the current revision against the current base. Since that run, `main` advanced and changed `Pm4.cpp`; this PR was then rebased onto `dc9dc7e`, and the exact current head has no paired `main`/PR validation-layer run. The repository requires those focused runs on the same machine and GPU with `ANYPS5_REQUIRE_VULKAN=1`, `ANYPS5_NO_SHADER_CACHE=1`, and `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation`, plus confirmation that the requested layer loaded and no new VUIDs appeared. Please provide the pair against current `main` and this head. **Non-blocking:** I found no remaining issue with the removed destination-4 throw assertion. ## Not verified I did not run a build, CTest, or Vulkan/GPU test locally. The paired GPU results above are author-provided for the previous head/base, not independent results for this revision. ## To get this to a good state Attach the paired current-main/current-head focused logs and VUID comparison, confirming the validation layer loaded in both runs; I will re-check the same evidence on the exact new 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!14130
No description provided.