loader: validate ModRM for ClzeroLoop cmp rax, <reg> #497

Open
ahmetbagci8 wants to merge 1 commit from upstream-pr/497 into main
ahmetbagci8 commented 2026-12-01 17:46:18 +00:00 (Migrated from github.com)

Imported from TaynanGT/Vice-Tay. Originally posted by ahmetbagci8 on 2026-12-01T17:46:18Z.


Summary

  • \console_insn_decode::decode: check \code[i + 9] & 0xC7 == 0xC0\ (\mod == 3,
    m == 0\ for
    ax) when matching the \clzero; add rax, 0x40; cmp rax, ; jb -12\ loop pattern.
  • Without this check, \cmp\ instructions targeting another register (e.g. \48 39 D1\ = \cmp rcx, rdx) or memory (e.g. \48 39 10\ = \cmp [rax], rdx) were misdecoded as \ConsoleOnly::ClzeroLoop, causing the handler to zero [rax..end_reg)\ and advance RIP by 12 bytes instead of emulating a single \clzero.

Verification

  • \cargo test -p vice-tay-loader --lib decodes_the_console_only_instructions\ (passed, including new regression assertions for non-
    ax\ and memory \cmp\ encodings).
<!-- greyfinch-sync:TaynanGT/Vice-Tay:issue:5591214847 --> Imported from [TaynanGT/Vice-Tay](https://github.com/TaynanGT/Vice-Tay/pull/497). Originally posted by [ahmetbagci8](https://github.com/ahmetbagci8) on 2026-12-01T17:46:18Z. --- ## Summary - \console_insn_decode::decode\: check \code[i + 9] & 0xC7 == 0xC0\ (\mod == 3\, \ m == 0\ for \ ax\) when matching the \clzero; add rax, 0x40; cmp rax, <reg>; jb -12\ loop pattern. - Without this check, \cmp\ instructions targeting another register (e.g. \48 39 D1\ = \cmp rcx, rdx\) or memory (e.g. \48 39 10\ = \cmp [rax], rdx\) were misdecoded as \ConsoleOnly::ClzeroLoop\, causing the handler to zero \[rax..end_reg)\ and advance RIP by 12 bytes instead of emulating a single \clzero\. ## Verification - \cargo test -p vice-tay-loader --lib decodes_the_console_only_instructions\ (passed, including new regression assertions for non-\ ax\ and memory \cmp\ encodings).
Aniseto commented 2026-12-01 17:59:42 +00:00 (Migrated from github.com)

Imported from TaynanGT/Vice-Tay. Originally posted by Aniseto on 2026-12-01T17:59:42Z.


Ran the named loader regression test at b6efd54a on an NVIDIA Blackwell desktop part with 16 GB of VRAM.

Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, 16 GB, mesh shaders) driver 32.0.16.2140 (621.40), Intel Core i5-12400F, 64 GB RAM, rustc 1.98.1 (48a229cea 2026-09-01), MSVC 14.44.35207, debug build, detached worktree at the exact PR head, own CARGO_TARGET_DIR, no local patches.

cargo test -q --locked -p vice-tay-loader --lib decodes_the_console_only_instructions -- --test-threads=1
1 passed; 0 failed; 0 ignored; 74 filtered out      (exit 0)

The test passes here, including the new assertions for non-rax and memory cmp encodings. This is a decoder regression test: no title was run, and no console-only instruction was executed on the GPU.

Not tested: the full workspace suite, a retail title, Wine, AMD adapters, release profile, game data.

AI-assisted (OpenCode), model: MiMo-V2.6-Flash Free - checked out the PR's head commit in a detached worktree, built it, ran the test, wrote this report; the worktree was not modified; no game data was used.

<!-- greyfinch-sync:TaynanGT/Vice-Tay:comment:7320211949 --> Imported from [TaynanGT/Vice-Tay](https://github.com/TaynanGT/Vice-Tay/pull/497#issuecomment-7320211949). Originally posted by [Aniseto](https://github.com/Aniseto) on 2026-12-01T17:59:42Z. --- Ran the named loader regression test at `b6efd54a` on an NVIDIA Blackwell desktop part with 16 GB of VRAM. Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, 16 GB, mesh shaders) driver 32.0.16.2140 (621.40), Intel Core i5-12400F, 64 GB RAM, rustc 1.98.1 (48a229cea 2026-09-01), MSVC 14.44.35207, debug build, detached worktree at the exact PR head, own `CARGO_TARGET_DIR`, no local patches. ``` cargo test -q --locked -p vice-tay-loader --lib decodes_the_console_only_instructions -- --test-threads=1 1 passed; 0 failed; 0 ignored; 74 filtered out (exit 0) ``` The test passes here, including the new assertions for non-`rax` and memory `cmp` encodings. This is a decoder regression test: no title was run, and no console-only instruction was executed on the GPU. Not tested: the full workspace suite, a retail title, Wine, AMD adapters, release profile, game data. AI-assisted (OpenCode), model: **MiMo-V2.6-Flash Free** - checked out the PR's head commit in a detached worktree, built it, ran the test, wrote this report; the worktree was not modified; no game data was used.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/497:upstream-pr/497'
git switch 'upstream-pr/497'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/497'
git switch 'upstream-pr/497'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/497'
git switch 'upstream-pr/497'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/497'
git switch 'main'
git merge --squash 'upstream-pr/497'
git switch 'main'
git merge --ff-only 'upstream-pr/497'
git switch 'main'
git merge 'upstream-pr/497'
git push origin 'main'
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
TaynanGT/Vice-Tay!497
No description provided.