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

Closed
opened 2026-11-24 00:55:08 +00:00 by legacy-code-archaeologist · 4 comments
legacy-code-archaeologist commented 2026-11-24 00:55:08 +00:00 (Migrated from github.com)
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by legacy-code-archaeologist on 2026-11-24T00:55:08Z.


Claim: VLDMXCSR and VSTMXCSR in the host-MXCSR profile (follow-up to #1009 and #1057)

vldmxcsr and vstmxcsr (AVX group of docs/coverage/x64_zen2.tsv) are still refused, also in the opt-in host-MXCSR profile. When closing #995 you listed the VEX spellings as a separate follow-up, with their own encoding and host-capability checks. Compilers emit the VEX forms in AVX code paths, and the console CPU's code uses AVX, so I'd like to take this follow-up.

Proposed behavior (same profile, same boundary)

  • Under the existing host_mxcsr profile (and its denormals opt-in), VLDMXCSR m32 and VSTMXCSR m32 lower exactly like the legacy forms:
    • the same pre-load checks and statuses;
    • the same _mm_setcsr / _mm_getcsr;
    • the same caller-word restoration.
  • Encoding check: only the defined encoding is accepted, VEX.128 (L = 0) with vvvv = 1111. iced already decodes VEX.L = 1 (c5 fc ae 10) and vvvv ≠ 1111 (c5 b8 ae 10) as invalid; both raise #UD natively. So they never reach the lowering, and region() refuses the interval. The fixture would pin that, so a future decoder change cannot make them lowerable.
  • Host capability: the translated code uses only SSE MXCSR access, so it does not need AVX on the host. The native comparison does: the test exits 77 for the native part when CPUID.01H:ECX bit 28 (AVX), OSXSAVE and XCR0 bits 1 and 2 are not all set. The translated checks against fixed expectations still run.

Proposed fixture (extends cpu_aot_mxcsr with VEX exports, or a sibling test)

  • VEX copies of the round-trip, refusal, leak and fault exports: all four rounding modes, the four refused words, the caller-word restore on return, refusal and both fault sites, and the marker after a refusal.
  • One export mixes the forms: legacy LDMXCSR then VSTMXCSR, and the reverse.
  • The default profile refuses each VEX instruction on its own. Byte-patched VEX.L = 1 and vvvv ≠ 1111 forms are refused, with the native #UD recorded in a child process as a reference.
  • Controls: noload and fixed as in #1009, applied to the VEX statements. Both must fail.
  • /O2 and both presets.

Question: should the VEX forms share the legacy host_mxcsr opt-in, or need an explicit flag of their own? I'd share it, since the architectural effect is the same.

Test host: Intel Skylake (i7-6820HQ, AVX and OSXSAVE present) on Windows 11 26100.

AI-assisted (Claude Code).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6572110075 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1093). Originally posted by [legacy-code-archaeologist](https://github.com/legacy-code-archaeologist) on 2026-11-24T00:55:08Z. --- ### Claim: VLDMXCSR and VSTMXCSR in the host-MXCSR profile (follow-up to #1009 and #1057) `vldmxcsr` and `vstmxcsr` (AVX group of `docs/coverage/x64_zen2.tsv`) are still refused, also in the opt-in host-MXCSR profile. When closing #995 you listed the VEX spellings as a separate follow-up, with their own encoding and host-capability checks. Compilers emit the VEX forms in AVX code paths, and the console CPU's code uses AVX, so I'd like to take this follow-up. **Proposed behavior (same profile, same boundary)** - Under the existing `host_mxcsr` profile (and its `denormals` opt-in), `VLDMXCSR m32` and `VSTMXCSR m32` lower exactly like the legacy forms: - the same pre-load checks and statuses; - the same `_mm_setcsr` / `_mm_getcsr`; - the same caller-word restoration. - **Encoding check:** only the defined encoding is accepted, VEX.128 (L = 0) with `vvvv` = 1111. iced already decodes VEX.L = 1 (`c5 fc ae 10`) and `vvvv` ≠ 1111 (`c5 b8 ae 10`) as invalid; both raise #UD natively. So they never reach the lowering, and `region()` refuses the interval. The fixture would pin that, so a future decoder change cannot make them lowerable. - **Host capability:** the translated code uses only SSE MXCSR access, so it does not need AVX on the host. The native comparison does: the test exits 77 for the native part when CPUID.01H:ECX bit 28 (AVX), OSXSAVE and XCR0 bits 1 and 2 are not all set. The translated checks against fixed expectations still run. **Proposed fixture (extends `cpu_aot_mxcsr` with VEX exports, or a sibling test)** - VEX copies of the round-trip, refusal, leak and fault exports: all four rounding modes, the four refused words, the caller-word restore on return, refusal and both fault sites, and the marker after a refusal. - One export mixes the forms: legacy `LDMXCSR` then `VSTMXCSR`, and the reverse. - The default profile refuses each VEX instruction on its own. Byte-patched VEX.L = 1 and `vvvv` ≠ 1111 forms are refused, with the native #UD recorded in a child process as a reference. - Controls: `noload` and `fixed` as in #1009, applied to the VEX statements. Both must fail. - `/O2` and both presets. **Question:** should the VEX forms share the legacy `host_mxcsr` opt-in, or need an explicit flag of their own? I'd share it, since the architectural effect is the same. Test host: Intel Skylake (i7-6820HQ, AVX and OSXSAVE present) on Windows 11 26100. AI-assisted (Claude Code).
R0Y00 commented 2026-11-24 06:50:01 +00:00 (Migrated from github.com)
Author
Contributor

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


The VEX forms can share the existing host_mxcsr opt-in, with the same word validation, fault behavior and caller-state restoration. Please keep the default-profile refusal and the malformed VEX controls. Keep the translated fixed-reference tests runnable without AVX, and make the native AVX comparison a separate capability skip so its return 77 cannot hide a translated-path failure. The mixed legacy/VEX controls are in scope.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7118906531 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1093#issuecomment-7118906531). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-24T01:14:44Z. --- The VEX forms can share the existing `host_mxcsr` opt-in, with the same word validation, fault behavior and caller-state restoration. Please keep the default-profile refusal and the malformed VEX controls. Keep the translated fixed-reference tests runnable without AVX, and make the native AVX comparison a separate capability skip so its return 77 cannot hide a translated-path failure. The mixed legacy/VEX controls are in scope.
tedin7 commented 2026-11-24 06:50:02 +00:00 (Migrated from github.com)
Author
Contributor

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


Claiming the host_mxcsr VEX slice: lowering M.VLDMXCSR/M.VSTMXCSR (VEX.128, L=0, vvvv=1111) under host_mxcsr, with default-profile refusal, malformed-VEX and mixed legacy/VEX controls, a translated fixed-reference run, and a capability-skipped native AVX comparison. Environment: Linux with LLVM 19 locally; I rely on the Ubuntu LLVM 15 job and the Windows WARP jobs for the rest. AI-assisted. CI: Windows MSVC/ML64.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7119160545 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1093#issuecomment-7119160545). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T01:30:06Z. --- Claiming the host_mxcsr VEX slice: lowering M.VLDMXCSR/M.VSTMXCSR (VEX.128, L=0, vvvv=1111) under host_mxcsr, with default-profile refusal, malformed-VEX and mixed legacy/VEX controls, a translated fixed-reference run, and a capability-skipped native AVX comparison. Environment: Linux with LLVM 19 locally; I rely on the Ubuntu LLVM 15 job and the Windows WARP jobs for the rest. AI-assisted. CI: Windows MSVC/ML64.
tedin7 commented 2026-11-24 06:50:08 +00:00 (Migrated from github.com)
Author
Contributor

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


#1130 was already open (as a draft) before #1134 and is now green on all four CI jobs, including both Windows builds, so I have moved it to ready. It lowers VLDMXCSR/VSTMXCSR (VEX.128, L=0, vvvv=1111) under the existing host_mxcsr opt-in, refuses them in the default profile, refuses malformed VEX, and has a translated fixed-reference run plus a capability-skipped native AVX comparison.

If #1134 has controls that #1130 lacks, I would be glad to fold them into #1130, or to review the differences together so that only one of the two lands.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7119798013 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1093#issuecomment-7119798013). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T02:08:35Z. --- #1130 was already open (as a draft) before #1134 and is now green on all four CI jobs, including both Windows builds, so I have moved it to ready. It lowers VLDMXCSR/VSTMXCSR (VEX.128, L=0, vvvv=1111) under the existing host_mxcsr opt-in, refuses them in the default profile, refuses malformed VEX, and has a translated fixed-reference run plus a capability-skipped native AVX comparison. If #1134 has controls that #1130 lacks, I would be glad to fold them into #1130, or to review the differences together so that only one of the two lands. AI-assisted.
R0Y00 commented 2026-11-24 06:50:09 +00:00 (Migrated from github.com)
Author
Contributor

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


Implemented in #1134. The Windows fixture compares VEX MXCSR load/store with native execution and separately checks the fixed expected values, malformed encodings, and caller MXCSR restoration.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7119968102 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1093#issuecomment-7119968102). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-24T02:17:09Z. --- Implemented in #1134. The Windows fixture compares VEX MXCSR load/store with native execution and separately checks the fixed expected values, malformed encodings, and caller MXCSR restoration.
Sign in to join this conversation.
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#1086
No description provided.