CLI: check every extension the title uses unchecked, not only AVX2 (depends on #238) #558

Closed
github-bot wants to merge 3 commits from gh-pr/558/head into gh-pr/558/base
Owner

@⁠mercuryVM on GitHub · 2026-11-24 04:53 UTC · original
mercuryVM:cli/cpu-check-measured-features → main · +150 −3 · 2 files · 3 commits · closed without merging

Depends on #238 (this branch is #238's commit plus one on top; once #238 lands, only the second commit remains).

#238 stops victory run --execute on a CPU without AVX2. The title needs more than that, and it does not ask first, so a CPU missing any of the rest still dies on STATUS_ILLEGAL_INSTRUCTION (#102, #103, #106, #108, #210 are crashes of this kind).

What the title uses (Grand Theft Auto VI 1.0.2.1, measured)

dumpbin /disasm over the executable's code: 26.7 M instructions, cpuid from 9 places only. Counts only, nothing of the title quoted:

Extension Uses Checked here
FMA3 204,279 yes
AVX/AVX2 (ymm) 259,868 yes (avx2)
BMI1 (bextr, andn, tzcnt, blsr, ...) 60,850 yes
BMI2 (shlx, mulx, shrx, rorx, bzhi, pext, ...) 14,959 yes
F16C 3,303 yes
AES-NI / VAES 3,107 yes (aes)
PCLMULQDQ 1,128 yes
POPCNT 458 yes
MOVBE 422 yes
LZCNT 321 yes
ADX 2,678 no: all in one 0.26 MB block right after the title's AES code, so it may be picked by cpuid; requiring it would turn away Haswell CPUs that may run fine
SSE4a insertq 19, clzero 10, clwb 8, monitorx/mwaitx 2+2 no: victory_loader::crash emulates them on main
SHA, AVX-512, XOP, FMA4, RDPRU 0 —

Change

  • REQUIRED_FEATURES lists the ten; missing_cpu_features() detects each with is_x86_feature_detected!; the error names every missing one (not just the first), and VICTORY_SKIP_CPU_CHECK=1 still bypasses it.
  • README's requirement line names the extensions.
  • Tests: the pure check_cpu_features_with cases (nothing missing, AVX2 missing, several missing named, skip), the host check, and that the list has no duplicates.

Tested

c27c9df on Windows 11, Rust 1.98.1, AMD Ryzen + RTX 5070: cargo test --workspace 271 passed, 0 failed; rustfmt --check on the changed file; cargo xtask policy ok. Not run against the title (no package on this machine), and I have no CPU without these extensions to see the message on real hardware.

Note: cargo fmt --all -- --check fails on main itself (31 files); this PR does not touch them.

🤖 Generated with Claude Code

**@⁠mercuryVM** on GitHub · 2026-11-24 04:53 UTC · [original](https://github.com/Marvisak/VIctory/pull/558) `mercuryVM:cli/cpu-check-measured-features` → `main` · +150 −3 · 2 files · 3 commits · closed without merging Depends on #238 (this branch is #238's commit plus one on top; once #238 lands, only the second commit remains). #238 stops `victory run --execute` on a CPU without AVX2. The title needs more than that, and it does not ask first, so a CPU missing any of the rest still dies on `STATUS_ILLEGAL_INSTRUCTION` (#102, #103, #106, #108, #210 are crashes of this kind). ## What the title uses (Grand Theft Auto VI 1.0.2.1, measured) `dumpbin /disasm` over the executable's code: 26.7 M instructions, `cpuid` from 9 places only. Counts only, nothing of the title quoted: | Extension | Uses | Checked here | |---|---:|---| | FMA3 | 204,279 | yes | | AVX/AVX2 (ymm) | 259,868 | yes (`avx2`) | | BMI1 (`bextr`, `andn`, `tzcnt`, `blsr`, ...) | 60,850 | yes | | BMI2 (`shlx`, `mulx`, `shrx`, `rorx`, `bzhi`, `pext`, ...) | 14,959 | yes | | F16C | 3,303 | yes | | AES-NI / VAES | 3,107 | yes (`aes`) | | PCLMULQDQ | 1,128 | yes | | POPCNT | 458 | yes | | MOVBE | 422 | yes | | LZCNT | 321 | yes | | ADX | 2,678 | **no**: all in one 0.26 MB block right after the title's AES code, so it may be picked by `cpuid`; requiring it would turn away Haswell CPUs that may run fine | | SSE4a `insertq` 19, `clzero` 10, `clwb` 8, `monitorx`/`mwaitx` 2+2 | | no: `victory_loader::crash` emulates them on main | | SHA, AVX-512, XOP, FMA4, RDPRU | 0 | — | ## Change - `REQUIRED_FEATURES` lists the ten; `missing_cpu_features()` detects each with `is_x86_feature_detected!`; the error names every missing one (not just the first), and `VICTORY_SKIP_CPU_CHECK=1` still bypasses it. - README's requirement line names the extensions. - Tests: the pure `check_cpu_features_with` cases (nothing missing, AVX2 missing, several missing named, skip), the host check, and that the list has no duplicates. ## Tested `c27c9df` on Windows 11, Rust 1.98.1, AMD Ryzen + RTX 5070: `cargo test --workspace` 271 passed, 0 failed; `rustfmt --check` on the changed file; `cargo xtask policy` ok. Not run against the title (no package on this machine), and I have no CPU without these extensions to see the message on real hardware. Note: `cargo fmt --all -- --check` fails on main itself (31 files); this PR does not touch them. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Measured on Grand Theft Auto VI 1.0.2.1 (26.7 M instructions, `cpuid` from
9 places only): besides AVX2 the title runs FMA3, BMI1, BMI2, F16C, MOVBE,
LZCNT, POPCNT, AES-NI and PCLMULQDQ throughout, so a CPU without one of them
faults on an illegal instruction. The pre-flight check now lists every
missing one. The console's AMD-only instructions and clwb stay out (the
loader emulates them), and so does ADX, which only appears next to the
title's AES code and may be chosen by cpuid.

Depends on #238.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:08:16 +00:00
github-bot closed this pull request 2026-11-26 04:08:16 +00:00
Author
Owner

@⁠mercuryVM on GitHub · 2026-11-24 12:54 UTC · original

@⁠catminou4 thanks for the review. CI hasn't run on this PR yet; I think fork PRs wait for a maintainer to approve workflow runs. Here is the same check locally on Windows 11 x64 (AMD CPU, RTX 5070, rustc 1.98.1 MSVC), head fa83a31 (main 8e79c80 merged in), with the CI's own commands: cargo clippy --workspace --all-targets --locked -- -D warnings and the --all-features variant are clean, and cargo test -p victory --locked has 8 passed, the CPU-check tests among them.

AI-assisted (Claude Code).

**@⁠mercuryVM** on GitHub · 2026-11-24 12:54 UTC · [original](https://github.com/Marvisak/VIctory/pull/558#issuecomment-7132089840) @⁠catminou4 thanks for the review. CI hasn't run on this PR yet; I think fork PRs wait for a maintainer to approve workflow runs. Here is the same check locally on Windows 11 x64 (AMD CPU, RTX 5070, rustc 1.98.1 MSVC), head `fa83a31` (`main` `8e79c80` merged in), with the CI's own commands: `cargo clippy --workspace --all-targets --locked -- -D warnings` and the `--all-features` variant are clean, and `cargo test -p victory --locked` has 8 passed, the CPU-check tests among them. AI-assisted (Claude Code).
Author
Owner

@⁠hadrianhola on GitHub · 2026-11-24 20:30 UTC · original

On the open question in the table ("may be picked by cpuid"): it is. Static analysis of game_scarlett_master.exe 1.0.2.1 (dumpbin /disasm, the same 26.7 M instructions and the same counts as above), counts only:

  • Of the 9 cpuid sites, 3 are the MSVC CRT's __isa_available setup. 4 belong to a feature-detection routine of the library that holds the ADX code: it tests leaf/register/bit one at a time and records AVX, AVX2, RDRAND, RDSEED, BMI1, BMI2, AES, ADX (leaf 7 EBX bit 19), MOVBE and SHA as bits of one flags word. The other 2 read leaf 7 subleaves 0/1 for AVX2, BMI2, AVX-512 and VNNI, and record nothing for ADX.
  • All 2,678 adcx/adox sit in one 0.26 MB block. Building the control flow of that block gives the addresses from which an ADX instruction can be reached. All 289 direct code references from outside the block into those addresses go through a function that reads the flags word and tests a mask that includes ADX, within at most 8 call levels. ADX is always tested together with BMI2 (0x50), or with AVX2 and BMI2 (0x52), and the other branch takes a generic path. I checked one dispatcher by hand: not flags; test flags, 0x52; jnz generic.
  • No 64-bit pointer in .rdata/.data points into ADX-reachable code. Three 32-bit values do, but they land in the middle of unrolled mulx/adcx runs with no indirect jump around them, so they look coincidental.
  • Not covered: indirect calls through pointers built at run time.

So a CPU without ADX (Haswell, as in #68) should take the generic path. Leaving ADX out of REQUIRED_FEATURES looks right. The CPU here is a Haswell-E i7-5820K (no ADX, CPUID-checked); the title has not been run on it yet.

AI-assisted (Claude Code); analysis on my machine, nothing of the title quoted.

**@⁠hadrianhola** on GitHub · 2026-11-24 20:30 UTC · [original](https://github.com/Marvisak/VIctory/pull/558#issuecomment-7143658540) On the open question in the table ("may be picked by `cpuid`"): it is. Static analysis of `game_scarlett_master.exe` 1.0.2.1 (`dumpbin /disasm`, the same 26.7 M instructions and the same counts as above), counts only: - Of the 9 `cpuid` sites, 3 are the MSVC CRT's `__isa_available` setup. 4 belong to a feature-detection routine of the library that holds the ADX code: it tests leaf/register/bit one at a time and records AVX, AVX2, RDRAND, RDSEED, BMI1, BMI2, AES, **ADX (leaf 7 EBX bit 19)**, MOVBE and SHA as bits of one flags word. The other 2 read leaf 7 subleaves 0/1 for AVX2, BMI2, AVX-512 and VNNI, and record nothing for ADX. - All 2,678 `adcx`/`adox` sit in one 0.26 MB block. Building the control flow of that block gives the addresses from which an ADX instruction can be reached. All **289** direct code references from outside the block into those addresses go through a function that reads the flags word and tests a mask that includes ADX, within at most 8 call levels. ADX is always tested together with BMI2 (`0x50`), or with AVX2 and BMI2 (`0x52`), and the other branch takes a generic path. I checked one dispatcher by hand: `not flags; test flags, 0x52; jnz generic`. - No 64-bit pointer in `.rdata`/`.data` points into ADX-reachable code. Three 32-bit values do, but they land in the middle of unrolled `mulx`/`adcx` runs with no indirect jump around them, so they look coincidental. - Not covered: indirect calls through pointers built at run time. So a CPU without ADX (Haswell, as in #68) should take the generic path. Leaving ADX out of `REQUIRED_FEATURES` looks right. The CPU here is a Haswell-E i7-5820K (no ADX, CPUID-checked); the title has not been run on it yet. AI-assisted (Claude Code); analysis on my machine, nothing of the title quoted.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 00:24 UTC · original

Automated triage for the maintainers. Closing because another open pull request covers the same change.

See #238. #238's commit plus checks for FMA, BMI1/2, F16C, LZCNT, POPCNT, MOVBE, AES and PCLMULQDQ, which by its own comment every AVX2 CPU has, so the added checks cannot fire where #238's does not; also edits the README to say victory run checks them. Take #238.

If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

**@⁠Marvisak** on GitHub · 2026-11-25 00:24 UTC · [original](https://github.com/Marvisak/VIctory/pull/558#issuecomment-7148485087) Automated triage for the maintainers. Closing because another open pull request covers the same change. See #238. #238's commit plus checks for FMA, BMI1/2, F16C, LZCNT, POPCNT, MOVBE, AES and PCLMULQDQ, which by its own comment every AVX2 CPU has, so the added checks cannot fire where #238's does not; also edits the README to say `victory run` checks them. Take #238. If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

Pull request closed

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!558
No description provided.