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

Closed
opened 2026-11-26 22:41:06 +00:00 by github-bot · 4 comments
Owner

@⁠legacy-code-archaeologist on GitHub · 2026-11-24 00:55 UTC · original

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

**@⁠legacy-code-archaeologist** on GitHub · 2026-11-24 00:55 UTC · [original](https://github.com/R0Y00/Xbox2Windows/issues/1093) ### 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).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 22:41:06 +00:00
Author
Owner

@⁠R0Y00 on GitHub · 2026-11-24 01:14 UTC · original

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.

**@⁠R0Y00** on GitHub · 2026-11-24 01:14 UTC · [original](https://github.com/R0Y00/Xbox2Windows/issues/1093#issuecomment-7118906531) 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.
Author
Owner

@⁠tedin7 on GitHub · 2026-11-24 01:30 UTC · original

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** on GitHub · 2026-11-24 01:30 UTC · [original](https://github.com/R0Y00/Xbox2Windows/issues/1093#issuecomment-7119160545) 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.
Author
Owner

@⁠tedin7 on GitHub · 2026-11-24 02:08 UTC · original

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

**@⁠tedin7** on GitHub · 2026-11-24 02:08 UTC · [original](https://github.com/R0Y00/Xbox2Windows/issues/1093#issuecomment-7119798013) #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.
Author
Owner

@⁠R0Y00 on GitHub · 2026-11-24 02:17 UTC · original

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.

**@⁠R0Y00** on GitHub · 2026-11-24 02:17 UTC · [original](https://github.com/R0Y00/Xbox2Windows/issues/1093#issuecomment-7119968102) 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.
This discussion has been locked. Commenting is limited to contributors.
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.

Dependencies

No dependencies set

Reference
github/R0Y00--Xbox2Windows#1093
No description provided.