cpu: lower VLDMXCSR and VSTMXCSR in the host-MXCSR profile #1123

Closed
tedin7 wants to merge 1 commit from upstream-pr/1130 into main
tedin7 commented 2026-11-24 01:35:25 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T01:35:25Z.


Change

Lowers the VEX.128 MXCSR forms VLDMXCSR and VSTMXCSR (L=0, vvvv=1111, 32-bit memory operand) under the opt-in host-MXCSR profile, with the same checks and refusal statuses as LDMXCSR and STMXCSR. The default profile still refuses them. Malformed VEX encodings (L=1, vvvv other than 1111) do not decode as either instruction and are refused. Refs #1093.

AI-assisted. The change is one shared-lowerer branch plus the fixture, test, docs and CMake wiring.

Verification

Run on Linux (llvm-ml-19 and lld-link-19 build the fixture DLL, the repo venv runs the Python):

  • default-profile refusal: 26 MXCSR instructions refused one at a time (8 LDMXCSR, 6 STMXCSR, 7 VLDMXCSR, 5 VSTMXCSR).
  • malformed VEX: 4 encodings (L=1 and vvvv=1110, load and store) refused by region and lower; the same bytes with the payload byte set to 0xF8 lower.
  • all 9 mutation variants (2 existing, 7 new) emit the translated C++ with their replacements.
  • Negative control: with tools/ffx_version_query.py from origin/main the new check fails with unsupported query operation ... vldmxcsr dword ptr [rcx]; with this change it passes.
  • python3 -B tests/docs_links_check.py: passed.

Not run here (needs Windows MSVC and ML64): ctest --preset dev --no-tests=error -R '^cpu_aot_mxcsr(_vex_native)?$' -V, the translated-readback checks (mxcsr_vex_round, the two mixed exports, leak, refused words, fault), the seven new controls' violations, the /O2 walk and the native AVX comparison. The CI Windows jobs are the first run of these.

Evidence and follow-up

  • The fixture is source-built (tests/cpu/mxcsr.asm); the four malformed encodings are written as bytes and are never executed.
  • The translated VEX and mixed exports are checked against fixed per-mode expectations and the native legacy mxcsr_round, so that check needs no AVX. cpu_aot_mxcsr_vex_native compares the native VEX exports and skips with 77 without AVX.
  • New controls: vexnoload, vexfixed, vexunmasked, mixvldload, mixvstread, mixvstentry, mixvldrestore; each must break a rule in its own export.
  • Docs: docs/experiments.md host-MXCSR paragraph updated. Not covered: VEX.256.

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:6572597013 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1130). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T01:35:25Z. --- ## Change Lowers the VEX.128 MXCSR forms `VLDMXCSR` and `VSTMXCSR` (L=0, vvvv=1111, 32-bit memory operand) under the opt-in host-MXCSR profile, with the same checks and refusal statuses as `LDMXCSR` and `STMXCSR`. The default profile still refuses them. Malformed VEX encodings (L=1, vvvv other than 1111) do not decode as either instruction and are refused. Refs #1093. AI-assisted. The change is one shared-lowerer branch plus the fixture, test, docs and CMake wiring. ## Verification Run on Linux (llvm-ml-19 and lld-link-19 build the fixture DLL, the repo venv runs the Python): - default-profile refusal: 26 MXCSR instructions refused one at a time (8 LDMXCSR, 6 STMXCSR, 7 VLDMXCSR, 5 VSTMXCSR). - malformed VEX: 4 encodings (L=1 and vvvv=1110, load and store) refused by `region` and `lower`; the same bytes with the payload byte set to 0xF8 lower. - all 9 mutation variants (2 existing, 7 new) emit the translated C++ with their replacements. - Negative control: with `tools/ffx_version_query.py` from origin/main the new check fails with `unsupported query operation ... vldmxcsr dword ptr [rcx]`; with this change it passes. - `python3 -B tests/docs_links_check.py`: passed. Not run here (needs Windows MSVC and ML64): `ctest --preset dev --no-tests=error -R '^cpu_aot_mxcsr(_vex_native)?$' -V`, the translated-readback checks (`mxcsr_vex_round`, the two mixed exports, leak, refused words, fault), the seven new controls' violations, the /O2 walk and the native AVX comparison. The CI Windows jobs are the first run of these. ## Evidence and follow-up - The fixture is source-built (`tests/cpu/mxcsr.asm`); the four malformed encodings are written as bytes and are never executed. - The translated VEX and mixed exports are checked against fixed per-mode expectations and the native legacy `mxcsr_round`, so that check needs no AVX. `cpu_aot_mxcsr_vex_native` compares the native VEX exports and skips with 77 without AVX. - New controls: `vexnoload`, `vexfixed`, `vexunmasked`, `mixvldload`, `mixvstread`, `mixvstentry`, `mixvldrestore`; each must break a rule in its own export. - Docs: `docs/experiments.md` host-MXCSR paragraph updated. Not covered: VEX.256. ## 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:46:29 +00:00
chatgpt-codex-connector[bot commented 2026-11-24 06:50:09 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T02:08:46Z.


Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-24T02:15:20.772646Z 6510597 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7119801083 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1130#issuecomment-7119801083). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T02:08:46Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"65105974185531ef1849734328ada45b1cf2cf79","has_any_findings":false,"has_unresolved_findings":false,"status":"completed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} --> <details> <summary><strong>Codex Review Summary</strong>: ✅ Completed</summary> This comment shows the latest Codex review activity on this pull request. | Review | Status | Commit | Review trigger | | --- | --- | --- | --- | | 📝 **Code Review** | ✅ **Completed** <relative-time datetime="2026-11-24T02:15:20.772646Z">2026-11-24T02:15:20.772646Z</relative-time> | `6510597` | Draft marked ready | <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@codex review" or "@codex security review". Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. </details> </details>
R0Y00 commented 2026-11-24 06:50:09 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T02:17:14Z.


Thanks for building this in parallel. The shared VLDMXCSR/VSTMXCSR lowering is implemented in #1134, which also landed separate native and fixed-reference tests. If you see a distinct case in this branch that still adds coverage, it can be reviewed as a test-only diff against current main.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7119969718 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1130#issuecomment-7119969718). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-24T02:17:14Z. --- Thanks for building this in parallel. The shared VLDMXCSR/VSTMXCSR lowering is implemented in #1134, which also landed separate native and fixed-reference tests. If you see a distinct case in this branch that still adds coverage, it can be reviewed as a test-only diff against current main.
tedin7 commented 2026-11-24 06:50:14 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T03:27:47Z.


Thank you for #1134. The shared lowering and its tests cover the same behavior as this branch, so I am closing this PR (AI-assisted).

The cases this branch had that #1134 does not pin are now a test-only change in #1181, as you suggested: the lowering itself refusing malformed VEX loads and stores (store forms included), an unmasked-exception control, and one control per MXCSR instruction of the mixed exports. Nothing in tools/ changes there.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7121115061 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1130#issuecomment-7121115061). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T03:27:47Z. --- Thank you for #1134. The shared lowering and its tests cover the same behavior as this branch, so I am closing this PR (AI-assisted). The cases this branch had that #1134 does not pin are now a test-only change in #1181, as you suggested: the lowering itself refusing malformed VEX loads and stores (store forms included), an unmasked-exception control, and one control per MXCSR instruction of the mixed exports. Nothing in `tools/` changes there.

Pull request closed

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