cpu: lower xsavec and xsavec64 in the XSAVE state translator #1260
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1267"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T06:17:27Z.
Change
Lower
xsavecandxsavec64in the bounded XSAVE state translator (tools/cpu_xsave_aot.py). They use the existing localXStateand write the compacted format: only components selected byXINUSE & RFBMare stored,XSTATE_BV = XINUSE & RFBM,XCOMP_BV = bit 63 | RFBM, and the reserved header bytes stay untouched. Alignment and request-mask faults are raised before the first store, so a rejected call leaves memory intact. With only x87/SSE/AVX the compacted offsets equal the standard ones (AVX at 576); packed offsets and 64-byte component alignment need components beyond XCR0[2:0] and are not covered.AI-assisted. No issue is claimed.
Verification
Run on Linux (llvm-ml-19 + lld-link-19 for the fixture, MinGW for the lifted C++, Wine on a CPU with XSAVEC):
python -B tests/cpu/xsave_state_check.pyrejection/alt-encoding part against the Linux-built fixture: 6 alternate-encoding lift checks, 39 unit rejection controls, 10 PE-patched rejection controls passed.ALTER_OPdiverged on all 6 altered exports (xsave64 instead of xsavec64: 7/7; request mask ignored: 7/7).cpu_xsave_aot.pythere stops with "unsupported XSAVE-family instruction ... xsavec [r8]". Mutated lifted outputs (XCOMP_BV without bit 63, request mask ignored, XSTATE_BV = RFBM, unused components written) each fail the new comparison (28, 9, 21, 21 cases).git diff --check,tests/docs_links_check.py,tests/bidi_controls_check.pypass.Not run here: the MSVC build and the full Windows harness. Outside
--preset pr; to run on Windows Server 2025 (Debug and/O2):ctest --preset dev -R '^cpu_aot_xsave_state$'.Evidence and follow-up
The fixture is source-built MASM (
tests/cpu/xsave_state.asm), no external binaries. Observed on the Linux host CPU: XSAVEC leaves header bytes [528..575] untouched and stores MXCSR only with the SSE slot; the native comparison treats those bytes, extra initialized x87/SSE slots and x87 pointer fields as implementation-defined. Follow-up:xsaves,xrstors,xsaveopt, and compactedxrstor.Checklist
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T06:27:34Z.
Review: COMMENTED
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit:
3d03af0446ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T06:37:32Z.
Review: COMMENTED
No description provided.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T06:37:33Z.
Review: COMMENTED
No description provided.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T06:21:17Z.
Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207) at
3d03af04:--preset dev):ctest --preset dev -R "^cpu_aot_xsave_state$"— 1/1 PASS (0.27s, build3.75s)/O2(--preset release):ctest --preset release -R "^cpu_aot_xsave_state$"— 1/1 PASS (0.31s, build1.20s)Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T06:37:36Z.
AI-assisted follow-up for the two P2 findings in tests/cpu/xsave_state_check.py (
afbcbcff):Checked on Linux with llvm-ml-19, lld-link-19, MinGW and Wine: 84 native/lifted/reference cases, 24 misalignment checks, dynamic-mask checks and the rejection controls pass.
PR #1267 fuori preset pr: ctest --preset dev -R '^cpu_aot_xsave_state$' va rieseguito sul nodo Windows.
@codex review
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T06:46:46Z.
Re-verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207) at
afbcbcff:--preset dev):ctest --preset dev -R "^cpu_aot_xsave_state$"— 1/1 PASS (0.26s, build3.75s)/O2(--preset release):ctest --preset release -R "^cpu_aot_xsave_state$"— 1/1 PASS (0.30s, build1.32s)Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T06:21:27Z.
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
e8f1a64ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T06:27:34Z.
Code review location:
tests/cpu/xsave_state_check.py; line 662For the existing
XSTATE_BV=7fixture input, this fallback replaces the expected x87 control/ST and XMM bytes with the observed bytes, so the native comparison stops validating both live components. Flipping byte 0 (FCW) or byte 160 (XMM0) in an otherwise correct result is accepted byassert_equal_output('native', ...), even though neither difference is an initialized-component or pointer-field exception. This allows shared lowering/reference mistakes to pass the native differential check. Limit the relaxation to additional initialized components and explicitly probed fields; the new controls using themutationlabel do not exercise this permissive branch.Useful? React with 👍 / 👎.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T06:27:35Z.
Code review location:
tests/cpu/xsave_state_check.py; line 730On an XSAVE/OSXSAVE/AVX-capable Windows host without XSAVEC, such as Haswell or a VM masking that feature,
check_differential()passes its capability gate becausehost_has_xsave()checks only CPUID.1 and XCR0. These new native calls then raise an illegal-instruction exception instead of the expected alignment #GP, causing the previously supportedcpu_aot_xsave_statetest to fail rather than report a capability skip. Probe CPUID.(0xD,1):EAX[1] and gate the native XSAVEC cases, or return the configured skip code when that feature is unavailable.Useful? React with 👍 / 👎.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T06:37:32Z.
Code review location:
tests/cpu/xsave_state_check.py; line 662Fixed in
afbcbcff.Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T06:37:33Z.
Code review location:
tests/cpu/xsave_state_check.py; line 730Fixed in
afbcbcff.Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T06:49:00Z.
Code review location:
tools/cpu_xsave_aot.py; line 606With a valid restore image containing
XSTATE_BV[1]=0andMXCSR=0x3F80,op_xrstorloads the non-default MXCSR but clears the SSE in-use bit. Passingusedtoop_xsavethen skips bytes 24–31 and marks SSE initialized, so the newly supported compacted save loses live rounding-control state; the standard save still writes MXCSR. A native Linux/Xeon 8272CL probe saves0x3F80withXSTATE_BV[1]=1, whereas the lifted/model path leaves the0x5Afill bytes, and the native comparator accepts that mismatch. Include MXCSR in the SSE liveness calculation and add a vector with non-default MXCSR and the input SSE bit clear.Useful? React with 👍 / 👎.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T06:49:00Z.
Review: COMMENTED
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit:
afbcbcff20ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T07:05:55Z.
Review: COMMENTED
No description provided.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T07:06:01Z.
AI-assisted follow-up for the P2 finding in tools/cpu_xsave_aot.py (
e8f1a64e):xsavecnow treats SSE as in use when MXCSR differs from 0x1F80 (SDM vol.1 13.6), so a restore image with XSTATE_BV[1]=0 and MXCSR=0x3F80 saves MXCSR and sets XSTATE_BV[1]. The reverse case (default MXCSR, XMM clear) still compacts SSE away. Standardxsaveis unchanged: a native probe shows it leaves XSTATE_BV[1] clear in that case.PR #1267 fuori preset pr: ctest --preset dev -R '^cpu_aot_xsave_state$' va rieseguito sul nodo Windows.
@codex review
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T07:05:55Z.
Code review location:
tools/cpu_xsave_aot.py; line 606Fixed in
e8f1a64e.Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T07:09:04Z.
Re-verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207) at
e8f1a64e:--preset dev):ctest --preset dev -R "^cpu_aot_xsave_state$"— 1/1 PASS (0.27s, build3.40s)/O2(--preset release):ctest --preset release -R "^cpu_aot_xsave_state$"— 1/1 PASS (0.26s, build0.98s)Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T07:12:57Z.
Codex Review: Didn't find any major issues. Already looking forward to the next diff.
Reviewed commit:
e8f1a64e27ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T07:24:34Z.
Re-verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207) at
6c6b9f2d:--preset dev):ctest --preset dev -R "^cpu_aot_xsave_state$"— 1/1 PASS (0.26s, build3.10s)/O2(--preset release):ctest --preset release -R "^cpu_aot_xsave_state$"— 1/1 PASS (0.25s, build0.62s)