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

Open
opened 2026-11-26 20:21:46 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1560
Author: @IlyassRS3
Created: 11/25/2026
Status: 🔄 Open

Base: main ← Head: fix/cpu-feature-scan-classify-and-cli


📝 Commits (1)

  • 2828d5c cpu_feature_scan: flag AVX-512VL regs, fix int/prefix parsing, and guard CLI --base/read errors

📊 Changes

2 files changed (+78 additions, -12 deletions)

View changed files

📝 tests/test_cpu_feature_scan.py (+49 -1)
📝 tools/cpu_feature_scan.py (+29 -11)

📄 Description

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)).

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/1560 **Author:** [@IlyassRS3](https://github.com/IlyassRS3) **Created:** 11/25/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/cpu-feature-scan-classify-and-cli` --- ### 📝 Commits (1) - [`2828d5c`](https://github.com/ubiquitarianism/leonida/commit/2828d5ccfd95ebf832b3bd13207359466cb8fe2d) cpu_feature_scan: flag AVX-512VL regs, fix int/prefix parsing, and guard CLI --base/read errors ### 📊 Changes **2 files changed** (+78 additions, -12 deletions) <details> <summary>View changed files</summary> 📝 `tests/test_cpu_feature_scan.py` (+49 -1) 📝 `tools/cpu_feature_scan.py` (+29 -11) </details> ### 📄 Description 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)`). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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
starred/leonida#1586
No description provided.