cpu_feature_scan: flag AVX-512VL regs, fix int/prefix parsing, and guard CLI --base/read errors (CPU-FEATURE-SCAN-CLASSIFY-AND-CLI) #1560

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

@⁠IlyassRS3 on GitHub · 2026-11-25 04:36 UTC · original
IlyassRS3:fix/cpu-feature-scan-classify-and-cli → main · +78 −12 · 2 files · 1 commits · open

Item ID: CPU-FEATURE-SCAN-CLASSIFY-AND-CLI (new item; coordination issue #14 is at GitHub's 2,500-comment cap with no open successor at PR time — confirmed 0 open PRs touch tools/cpu_feature_scan.py)

Summary

  • Flag AVX-512VL high vector registers (xmm16–xmm31, ymm16–ymm31): ZMM previously matched only zmm* and {k*}, misclassifying EVEX instructions using xmm16..31 / ymm16..31 (which #UD on Zen 2) as baseline AVX/AVX2 or VAES.
  • Fix int immediate matching: IMMEDIATE previously accepted only uppercase hex with optional h, causing lowercase (int 2ch, int 2dh) and 0x-prefixed (int 0x29, int 0x2c, int 0x2d, int 0x3) Windows-served interrupt vectors to be falsely flagged as kernel-call INT.
  • Fix prefix splitting and case sensitivity in classify(): splitting prefixes with ops.partition(" ") dropped the following mnemonic when separated by multiple spaces or a tab (e.g. lock + cmpxchg16b, rep + \tinsb), and uppercase mnemonics/registers bypassed classification.
  • Harden CLI --base and source reads in main(): reject negative --base values with a clean parser error (replacing <lambda>), and catch OSError from inline_scan.read_lines(args.source) cleanly with exit code 2 instead of a traceback.

Testing

  • AI-assisted: yes
  • GPUs tested: none (CPU/Python stdlib tool; no GPU, no game files)
  • python3 -W error -I tests/test_cpu_feature_scan.py -v: 26/26 passed
  • python3 -W error -I tests/test_text_write_line_endings.py -v: 3/3 passed
  • python3 -I scripts/check_no_game_data.py tools/cpu_feature_scan.py tests/test_cpu_feature_scan.py: passed
  • python3 -m compileall -q make_game.py tools tests: passed
  • Mutation check against unpatched main:tools/cpu_feature_scan.py: all 5 new/updated tests fail (FAILED (failures=5, errors=1)).
**@⁠IlyassRS3** on GitHub · 2026-11-25 04:36 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1560) `IlyassRS3:fix/cpu-feature-scan-classify-and-cli` → `main` · +78 −12 · 2 files · 1 commits · open Item ID: `CPU-FEATURE-SCAN-CLASSIFY-AND-CLI` (new item; coordination issue #14 is at GitHub's 2,500-comment cap with no open successor at PR time — confirmed 0 open PRs touch `tools/cpu_feature_scan.py`) ## Summary - **Flag AVX-512VL high vector registers (`xmm16`–`xmm31`, `ymm16`–`ymm31`)**: `ZMM` previously matched only `zmm*` and `{k*}`, misclassifying EVEX instructions using `xmm16..31` / `ymm16..31` (which `#UD` on Zen 2) as baseline `AVX`/`AVX2` or `VAES`. - **Fix `int` immediate matching**: `IMMEDIATE` previously accepted only uppercase hex with optional `h`, causing lowercase (`int 2ch`, `int 2dh`) and `0x`-prefixed (`int 0x29`, `int 0x2c`, `int 0x2d`, `int 0x3`) Windows-served interrupt vectors to be falsely flagged as kernel-call `INT`. - **Fix prefix splitting and case sensitivity in `classify()`**: splitting prefixes with `ops.partition(" ")` dropped the following mnemonic when separated by multiple spaces or a tab (e.g. `lock` + ` cmpxchg16b`, `rep` + `\tinsb`), and uppercase mnemonics/registers bypassed classification. - **Harden CLI `--base` and source reads in `main()`**: reject negative `--base` values with a clean parser error (replacing `<lambda>`), and catch `OSError` from `inline_scan.read_lines(args.source)` cleanly with exit code 2 instead of a traceback. ## Testing - AI-assisted: yes - GPUs tested: none (CPU/Python stdlib tool; no GPU, no game files) - `python3 -W error -I tests/test_cpu_feature_scan.py -v`: **26/26 passed** - `python3 -W error -I tests/test_text_write_line_endings.py -v`: **3/3 passed** - `python3 -I scripts/check_no_game_data.py tools/cpu_feature_scan.py tests/test_cpu_feature_scan.py`: passed - `python3 -m compileall -q make_game.py tools tests`: passed - Mutation check against unpatched `main:tools/cpu_feature_scan.py`: all 5 new/updated tests fail (`FAILED (failures=5, errors=1)`).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:56:38 +00:00
Author
Owner

@⁠copilot-pull-request-reviewer[bot] on GitHub · 2026-11-25 04:36 UTC · original · reviewed

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

**@⁠copilot-pull-request-reviewer[bot]** on GitHub · 2026-11-25 04:36 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1560#pullrequestreview-6051922651) · **reviewed** Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
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/1560/head:github-bot/gh-1560'
git switch 'github-bot/gh-1560'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1560'
git switch 'github-bot/gh-1560'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1560'
git switch 'github-bot/gh-1560'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1560'
git switch 'main'
git merge --squash 'github-bot/gh-1560'
git switch 'main'
git merge --ff-only 'github-bot/gh-1560'
git switch 'main'
git merge 'github-bot/gh-1560'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.