cpu: add malformed legacy-prefix VEX negative controls for BMI2 #494

Merged
agilesh08 merged 2 commits from upstream-pr/500 into main 2026-11-23 02:40:45 +00:00
agilesh08 commented 2026-11-22 07:54:54 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by agilesh08 on 2026-11-22T07:54:54Z.


Change

Adds malformed legacy-prefix/VEX (0x66-prefixed VEX) negative controls for the 8 BMI2 instructions (BZHI, MULX, PDEP, PEXT, RORX, SARX, SHLX, SHRX) in tests/cpu/bmi2.py:

  • Explicitly asserts via iced-x86 that each 0x66-prefixed VEX byte sequence decodes as Mnemonic.INVALID and is rejected by the lifter's invalid-instruction diagnostic.
  • Explicitly asserts via iced-x86 that stripping the leading 0x66 byte decodes to the valid unprefixed 32-bit BMI2 neighbor (bzhi eax, ecx, eax, etc.).

Verification

  • Executed the malformed legacy-prefix/VEX negative controls in tests/cpu/bmi2.py with "D:\XboxToWin repo\.venv\Scripts\python.exe" -B (passed, exit code 0).
  • python -B tests/form_coverage_check.py: passed (exit code 0).
  • python -B tests/docs_links_check.py and tests/bidi_controls_check.py: 0 errors.
  • git -c core.whitespace=cr-at-eol diff --check: 0 errors.

Evidence and follow-up

Uses 100% synthetic in-memory byte sequences decoded with iced-x86. No commercial binaries or copyrighted dumps are included.

Assisted by AI.

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I considered a negative control or failure case for a new fixture.
  • I updated README/docs when a capability or build requirement changed.
  • I did not include game files, dumps, distribution links or secrets.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6540008726 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/500). Originally posted by [agilesh08](https://github.com/agilesh08) on 2026-11-22T07:54:54Z. --- ## Change Adds malformed legacy-prefix/VEX (`0x66`-prefixed VEX) negative controls for the 8 BMI2 instructions (`BZHI`, `MULX`, `PDEP`, `PEXT`, `RORX`, `SARX`, `SHLX`, `SHRX`) in `tests/cpu/bmi2.py`: - Explicitly asserts via `iced-x86` that each `0x66`-prefixed VEX byte sequence decodes as `Mnemonic.INVALID` and is rejected by the lifter's invalid-instruction diagnostic. - Explicitly asserts via `iced-x86` that stripping the leading `0x66` byte decodes to the valid unprefixed 32-bit BMI2 neighbor (`bzhi eax, ecx, eax`, etc.). ## Verification - Executed the malformed legacy-prefix/VEX negative controls in `tests/cpu/bmi2.py` with `"D:\XboxToWin repo\.venv\Scripts\python.exe" -B` (passed, exit code 0). - `python -B tests/form_coverage_check.py`: passed (exit code 0). - `python -B tests/docs_links_check.py` and `tests/bidi_controls_check.py`: 0 errors. - `git -c core.whitespace=cr-at-eol diff --check`: 0 errors. ## Evidence and follow-up Uses 100% synthetic in-memory byte sequences decoded with `iced-x86`. No commercial binaries or copyrighted dumps are included. Assisted by AI. ## Checklist - [x] This pull request covers one reviewable behavior. - [x] I included the exact command and result for every check I ran. - [x] I considered a negative control or failure case for a new fixture. - [x] I updated README/docs when a capability or build requirement changed. - [x] I did not include game files, dumps, distribution links or secrets.
upstream-sync closed this pull request 2026-11-24 06:43:22 +00:00
R0Y00 commented 2026-11-24 06:43:22 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-22T08:08:09Z.

Review: CHANGES_REQUESTED


I reproduced this on 910f407 with the repository's iced-x86 decoder. The first word sequence starts with an invalid instruction: removing 66h decodes as bzhi eax,ecx,eax. The new check therefore passes on the generic invalid-opcode diagnostic, before reaching the BMI2 lowering. The diff also introduces no new positive input vectors or flag comparisons. Please describe these as malformed legacy-prefix/VEX controls, assert that decode result explicitly with the valid unprefixed neighbor for each case, and correct the PR description (or add the advertised differential vectors). This keeps the negative coverage reproducible without claiming an encodable 16-bit BMI2 operation.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6011165258 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/500#pullrequestreview-6011165258). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-22T08:08:09Z. **Review:** CHANGES_REQUESTED --- I reproduced this on 910f407 with the repository's iced-x86 decoder. The first word sequence starts with an invalid instruction: removing 66h decodes as `bzhi eax,ecx,eax`. The new check therefore passes on the generic invalid-opcode diagnostic, before reaching the BMI2 lowering. The diff also introduces no new positive input vectors or flag comparisons. Please describe these as malformed legacy-prefix/VEX controls, assert that decode result explicitly with the valid unprefixed neighbor for each case, and correct the PR description (or add the advertised differential vectors). This keeps the negative coverage reproducible without claiming an encodable 16-bit BMI2 operation.
agilesh08 commented 2026-11-24 06:48:29 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by agilesh08 on 2026-11-22T09:44:05Z.


@R0Y00 Updated feat/cpu-bmi2-followup and PR #500's title/description per your review:

  • Described these accurately as malformed legacy-prefix/VEX (0x66-prefixed VEX) negative controls rather than encodable 16-bit BMI2 forms.
  • Added explicit iced-x86 assertions verifying that each 0x66-prefixed sequence decodes as Mnemonic.INVALID (and triggers the invalid-instruction diagnostic), while stripping 0x66 decodes to its valid unprefixed 32-bit BMI2 neighbor.
  • Updated the PR title and body to match the exact diff without claiming unadded differential vectors.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7077335964 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/500#issuecomment-7077335964). Originally posted by [agilesh08](https://github.com/agilesh08) on 2026-11-22T09:44:05Z. --- @R0Y00 Updated `feat/cpu-bmi2-followup` and PR #500's title/description per your review: - Described these accurately as malformed legacy-prefix/VEX (`0x66`-prefixed VEX) negative controls rather than encodable 16-bit BMI2 forms. - Added explicit `iced-x86` assertions verifying that each `0x66`-prefixed sequence decodes as `Mnemonic.INVALID` (and triggers the invalid-instruction diagnostic), while stripping `0x66` decodes to its valid unprefixed 32-bit BMI2 neighbor. - Updated the PR title and body to match the exact diff without claiming unadded differential vectors.
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
R0Y00/Xbox2Windows!494
No description provided.