fix(shader): reject modified v_add_co_ci_u32 in address carry tracing #3362

Open
github-bot wants to merge 1 commit from github-bot/gh-3362 into main AGit
Owner

@⁠reeledMarek on GitHub · 2026-11-26 20:25 UTC · original
reeledMarek:fix/shader-carried-valu-modifiers → main · +66 −0 · 1 files · 1 commits · open

Summary

  • Tracer::carried matched v_add_co_ci_u32 without checking VALU input/output modifiers (abs, neg, opsel, clamp, omod, sdwa, dpp).
  • A saturating (clamp), SDWA sub-dword, or DPP lane-permuted v_add_co_ci_u32 was therefore accepted as a plain 64-bit address high-half carry, misclassifying the resulting global memory address as belonging to a root descriptor parameter instead of falling back to MEMORY.
  • Guards Tracer::carried to require unmodified v_add_co_ci_u32 (abs == 0 && neg == 0 && opsel == 0 && !clamp && omod == 0 && sdwa.is_none() && dpp.is_none()).
  • Adds regression test modified_v_add_co_ci_u32_is_not_treated_as_plain_address_carry covering plain vs clamped, SDWA, and DPP16 encodings.

Verification

  • Executed all 4 machine-code cases directly against victory-shader on Linux
  • cargo clippy -p victory-shader --all-targets --target x86_64-pc-windows-msvc --locked -- -D warnings
  • cargo test -p xtask --locked
**@⁠reeledMarek** on GitHub · 2026-11-26 20:25 UTC · [original](https://github.com/Marvisak/VIctory/pull/3362) `reeledMarek:fix/shader-carried-valu-modifiers` → `main` · +66 −0 · 1 files · 1 commits · open ### Summary - `Tracer::carried` matched `v_add_co_ci_u32` without checking VALU input/output modifiers (`abs`, `neg`, `opsel`, `clamp`, `omod`, `sdwa`, `dpp`). - A saturating (`clamp`), SDWA sub-dword, or DPP lane-permuted `v_add_co_ci_u32` was therefore accepted as a plain 64-bit address high-half carry, misclassifying the resulting global memory address as belonging to a root descriptor parameter instead of falling back to `MEMORY`. - Guards `Tracer::carried` to require unmodified `v_add_co_ci_u32` (`abs == 0 && neg == 0 && opsel == 0 && !clamp && omod == 0 && sdwa.is_none() && dpp.is_none()`). - Adds regression test `modified_v_add_co_ci_u32_is_not_treated_as_plain_address_carry` covering plain vs clamped, SDWA, and DPP16 encodings. ### Verification - Executed all 4 machine-code cases directly against `victory-shader` on Linux - `cargo clippy -p victory-shader --all-targets --target x86_64-pc-windows-msvc --locked -- -D warnings` - `cargo test -p xtask --locked`
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 20:26:28 +00:00
Author
Owner

@⁠Dukestar69 on GitHub · 2026-11-26 20:27 UTC · original · approved these changes

LGTM — verified on Windows against origin/main (63bcca4).

  • Rejecting v_add_co_ci_u32 instructions with VALU modifiers (abs, neg, opsel, clamp, omod, sdwa, dpp) during address carry tracing avoids misclassifying saturating/SDWA/DPP operations as plain 64-bit address high-half carries.
  • cargo test -p victory-shader --lib resource:: -- --test-threads=1: 36 passed, 0 failed (including modified_v_add_co_ci_u32_is_not_treated_as_plain_address_carry).
  • cargo clippy -p victory-shader --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

**@⁠Dukestar69** on GitHub · 2026-11-26 20:27 UTC · [original](https://github.com/Marvisak/VIctory/pull/3362#pullrequestreview-6080148252) · **approved these changes** LGTM — verified on Windows against `origin/main` (`63bcca4`). - Rejecting `v_add_co_ci_u32` instructions with VALU modifiers (`abs`, `neg`, `opsel`, `clamp`, `omod`, `sdwa`, `dpp`) during address carry tracing avoids misclassifying saturating/SDWA/DPP operations as plain 64-bit address high-half carries. - `cargo test -p victory-shader --lib resource:: -- --test-threads=1`: 36 passed, 0 failed (including `modified_v_add_co_ci_u32_is_not_treated_as_plain_address_carry`). - `cargo clippy -p victory-shader --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 20:48 UTC · original · approved these changes

LGTM — adding the VALU modifier guards (abs, neg, opsel, clamp, omod, sdwa, dpp) to Tracer::carried prevents modified v_add_co_ci_u32 instructions from being misclassified as plain 64-bit address high-half carries.

Verified

  • cargo clippy --locked -p victory-shader --all-targets -- -D warnings (default & --all-features): clean.
  • rustfmt --edition 2024: clean on all PR-touched hunks in crates/victory-shader/src/resource.rs.
  • cargo test --locked -p victory-shader --lib resource::tests:: -- --test-threads=1: 36 passed, 0 failed (including modified_v_add_co_ci_u32_is_not_treated_as_plain_address_carry).
  • cargo test --locked -p victory-shader --lib -- --test-threads=1 ir:: structure:: io:: emit::lower::: 59 passed, 0 failed, 1 ignored.

Non-blocking follow-up notes

  • Pre-existing siblings in resource.rs (vadd at 731-753, vorigin at 764-777, and reaches_pc at 863) have similar gaps (missing clamp/omod guards on v_mov_b32/v_add_*, and carried not yet validating the other addend or carry-in provenance).
  • Note on the SDWA case (resource.rs:3937): since 48-bit global addresses drop the upper 16 bits, dst_sel:WORD_0 with zero-pad still produces the same effective address and exercises conservative fallback to MEMORY.
**@⁠fuzeofficlal** on GitHub · 2026-11-26 20:48 UTC · [original](https://github.com/Marvisak/VIctory/pull/3362#pullrequestreview-6080339614) · **approved these changes** LGTM — adding the VALU modifier guards (`abs`, `neg`, `opsel`, `clamp`, `omod`, `sdwa`, `dpp`) to `Tracer::carried` prevents modified `v_add_co_ci_u32` instructions from being misclassified as plain 64-bit address high-half carries. ### Verified - `cargo clippy --locked -p victory-shader --all-targets -- -D warnings` (default & `--all-features`): clean. - `rustfmt --edition 2024`: clean on all PR-touched hunks in `crates/victory-shader/src/resource.rs`. - `cargo test --locked -p victory-shader --lib resource::tests:: -- --test-threads=1`: **36 passed, 0 failed** (including `modified_v_add_co_ci_u32_is_not_treated_as_plain_address_carry`). - `cargo test --locked -p victory-shader --lib -- --test-threads=1 ir:: structure:: io:: emit::lower::`: **59 passed, 0 failed, 1 ignored**. ### Non-blocking follow-up notes - Pre-existing siblings in `resource.rs` (`vadd` at `731-753`, `vorigin` at `764-777`, and `reaches_pc` at `863`) have similar gaps (missing `clamp`/`omod` guards on `v_mov_b32`/`v_add_*`, and `carried` not yet validating the other addend or carry-in provenance). - Note on the SDWA case (`resource.rs:3937`): since 48-bit global addresses drop the upper 16 bits, `dst_sel:WORD_0` with zero-pad still produces the same effective address and exercises conservative fallback to `MEMORY`.
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/3362/head:github-bot/gh-3362'
git switch 'github-bot/gh-3362'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3362'
git switch 'github-bot/gh-3362'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3362'
git switch 'github-bot/gh-3362'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3362'
git switch 'main'
git merge --squash 'github-bot/gh-3362'
git switch 'main'
git merge --ff-only 'github-bot/gh-3362'
git switch 'main'
git merge 'github-bot/gh-3362'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!3362
No description provided.