Repository navigation
RT-500: cpu_feature_scan lists the executable's CPU instructions a desktop CPU may lack (AMD-only SSE4a, CLZERO, MONITORX; CLWB) - #7013
Conversation
… desktop CPU may lack The runtime runs the Xbox Series (Zen 2) executable natively, so an instruction the host CPU lacks raises #UD where it is reached. tools/cpu_feature_scan.py streams dumpbin /disasm like inline_scan.py, maps each instruction to its CPUID feature or privilege class (AMD-only, newer-Intel-only, not on Zen 2, privileged, kernel call, host query, baseline), and splits the counts by .pdata range. docs/cpu_features.md records the 1.0.2.1 result (counts only): 19 SSE4a, 10 CLZERO and 4 MONITORX/MWAITX sites (AMD only) and 8 CLWB sites, all real code; the privileged hits are jump-table data. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
0a52f9a to
85daaa1
Compare
|
Independent CPU review at
|
|
Reran
|
… the first Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@SweatierKey thanks, applied in 2f9e1e3: |
|
Tested 2f9e1e3 merged with main 8575d36 on Linux/Python 3.12.16: pass The PR adds a new tool, its test and a doc page (tools/cpu_feature_scan.py, tests/test_cpu_feature_scan.py, docs/cpu_features.md, plus index lines in docs/README.md and docs/design.md). Because every code file is new, there is no main version to restore for a negative control; I used a mutation instead. Commands run (merged worktree,
Not reproduced: the measured counts in docs/cpu_features.md (26,674,075 instructions, 19 SSE4a, 10 CLZERO, 4 MONITORX, 8 CLWB, ...) come from running dumpbin on the retail executable, which I did not do here. The tests use hand-written listings and a synthetic PE with only a .pdata table, and the doc quotes counts only, no bytes or names from the executable. |
|
Host data point for the "AMD Zen 2 or later" line in Host: AMD Ryzen 7 5700X3D (Zen 3, family 19h model 21h, one CCD, 8 cores / 16 threads, 96 MiB L3), Windows 11 Pro 26200. CPUID: SSE4a, CLZERO, MONITORX/MWAITX and CLWB are all reported. The rest of the baseline the doc lists is present too (AVX2, FMA3, F16C, BMI1/2, ADX, MOVBE, AES-NI, PCLMULQDQ; also SHA, RDPID, RDSEED, CLFLUSHOPT, WBNOINVD, invariant TSC). No AVX-512, which the scan doesn't flag anyway. Retail runs: own 1.0.2.1 copy, So a Zen 3 desktop host needs none of the emulation in #7055, #7096, #7098, #7100 or #7111. Outcomes only, no game data. AI-assisted (Claude Code). |
|
Tested 2f9e1e3 on Windows 11, Python 3.15.2, NVIDIA RTX 4060 Ti (driver 621.24; CPU-only checks, no game files, no GPU/llvm-mc/MSVC used): pass. Ran the test files this PR adds or changes, from a clean checkout of the PR head: AI-assisted (Claude Code). |
RT-500 (RT-5 / EXE), claimed in the coordination issue: #6750 (comment)
What
docs/design.mdsays the CPU code runs natively and only "what can't run on desktop" gets patched, but nothing listed what that is. The Xbox Series CPU is a Zen 2, and code built for one known CPU uses its instructions without asking CPUID. On a host that lacks one, the game getsSTATUS_ILLEGAL_INSTRUCTIONwhere it reaches it.tools/cpu_feature_scan.pystreamsdumpbin /disasm:nobytes(astools/inline_scan.pydoes), maps every instruction to its CPUID feature or privilege class (amd-only,newer-intel,not-zen2,privileged,kernel-call,host-query,baseline) and splits each count by.pdatarange.--sitesprints the RVA of each flagged instruction,--jsonthe report. A saved listing works too (--imagefor.pdata). Standard library only; nothing is executed.docs/cpu_features.md: the 1.0.2.1 result, counts only. Indexed indocs/README.mdand added as step 7 of "Day one" indocs/design.md.Result on the retail executable (counts only)
insertq)#UDon every Intel CPU#UDon every Intel CPU#UDon every Intel CPU#UDon Intel client CPUs before Ice LakeAll 41 were read by hand in my own copy and are real code. The 9 privileged /
int nhits are jump-table data in.text. No AVX-512, VAES, SHA, RDPID, SYSCALL or RDTSC. So on an Intel host the game stops at the first of these it reaches. A follow-up PR (same claim) adds a#UDhandler ingta6rtthat emulates them when the host lacks them.Tested
python -I tests/test_cpu_feature_scan.py: 22 tests OK (hand-written dumpbin-style listings and a synthetic PE with only a.pdatatable; no game files, no dumpbin).python -I tests/test_inline_scan.py,test_pe_inspect.py,test_docs_repo_paths.py,test_docs_links.py,test_docs_cli_flags.py,test_docs_design_rows.py: OK. (test_text_write_line_endings.pyfails onmaintoo, fortools/f64_omod_probe.py:268, not touched here.)game_scarlett_master.exe(own copy):python -I tools/cpu_feature_scan.py <exe>runs in 1 min 45 s and gives the same counts as a saved listing with--image.Windows 11, Intel Core i7-10700K (one of the hosts that lacks all four features), MSVC 14.51
dumpbin, Python 3.14. No GPU involved.AI-assisted (Claude Code).
🤖 Generated with Claude Code