cpu_aot_xsave_state raises #GP on a host with XSAVEOPT but no XSAVEC: native compacted XRSTOR not gated #2331

Closed
opened 2026-11-25 12:50:17 +00:00 by lukaslw-lab · 0 comments
lukaslw-lab commented 2026-11-25 12:50:17 +00:00 (Migrated from github.com)
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-11-25T12:50:17Z.


Commit or build

eda7cc3c (upstream main), dev preset

Reproduction

ctest --preset dev --no-tests=error -R '^cpu_aot_xsave_state$' -V

Expected behavior

The test passes, or skips the native compacted cases, on a host without XSAVEC. It already prints
Host CPU lacks XSAVEC (CPUID.(0xD,1):EAX[1]); native xsavec fixtures are skipped, lifted xsavec still checked.

Observed behavior

File "tests/cpu/xsave_state_check.py", line 1221, in check_entry_state_contracts
    got_n_comp = invoke_native(
        harness, native_fns["op_xrstor64_avx_xsaveopt64_avx"], compacted_avx, dummy, entry_ptr=sse_ptr
OSError: exception: access violation reading 0xFFFFFFFFFFFFFFFF

Without XSAVEC a restore with XCOMP_BV[63] set always raises #GP, which Windows reports as this access violation
(the script's own GP_MESSAGE). native_exports_for_host drops the compacted fixtures on such a host, as its
docstring says, but two native compacted restores are still reached:

  • the entry-MXCSR control in check_entry_state_contracts (step 3, added in 73e2110f) restores compacted_avx
    through op_xrstor64_avx_xsaveopt64_avx, a general export that the gate keeps;
  • SSE_COMPACTED_CONTROL_EXPORT always restores a compacted image, but the gate drops it only without XSAVEOPT.

The gate's own check (native_exports_for_host(native, False, False)) only covers a host with neither feature, so
a host with XSAVEOPT and no XSAVEC (Haswell, Broadwell) is not checked. Hosts with XSAVEC, such as the CI runners,
do not reach this path.

Environment

Windows 10 22H2 build 19045, Intel Core i7-4790K (Haswell: XSAVE, XSAVEOPT, no XSAVEC; XCR0=0x7, XSAVE area
832 bytes), Visual Studio 2026 18.x (MSVC 19.52), Python 3.13.7. No GPU involved.

AI-assisted (Claude Code); the commands and results above were run on the author's PC.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6604872217 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/2339). Originally posted by [lukaslw-lab](https://github.com/lukaslw-lab) on 2026-11-25T12:50:17Z. --- ### Commit or build `eda7cc3c` (upstream main), `dev` preset ### Reproduction ```shell ctest --preset dev --no-tests=error -R '^cpu_aot_xsave_state$' -V ``` ### Expected behavior The test passes, or skips the native compacted cases, on a host without XSAVEC. It already prints `Host CPU lacks XSAVEC (CPUID.(0xD,1):EAX[1]); native xsavec fixtures are skipped, lifted xsavec still checked.` ### Observed behavior ```text File "tests/cpu/xsave_state_check.py", line 1221, in check_entry_state_contracts got_n_comp = invoke_native( harness, native_fns["op_xrstor64_avx_xsaveopt64_avx"], compacted_avx, dummy, entry_ptr=sse_ptr OSError: exception: access violation reading 0xFFFFFFFFFFFFFFFF ``` Without XSAVEC a restore with XCOMP_BV[63] set always raises #GP, which Windows reports as this access violation (the script's own `GP_MESSAGE`). `native_exports_for_host` drops the compacted fixtures on such a host, as its docstring says, but two native compacted restores are still reached: - the entry-MXCSR control in `check_entry_state_contracts` (step 3, added in `73e2110f`) restores `compacted_avx` through `op_xrstor64_avx_xsaveopt64_avx`, a general export that the gate keeps; - `SSE_COMPACTED_CONTROL_EXPORT` always restores a compacted image, but the gate drops it only without XSAVEOPT. The gate's own check (`native_exports_for_host(native, False, False)`) only covers a host with neither feature, so a host with XSAVEOPT and no XSAVEC (Haswell, Broadwell) is not checked. Hosts with XSAVEC, such as the CI runners, do not reach this path. ### Environment Windows 10 22H2 build 19045, Intel Core i7-4790K (Haswell: XSAVE, XSAVEOPT, no XSAVEC; XCR0=0x7, XSAVE area 832 bytes), Visual Studio 2026 18.x (MSVC 19.52), Python 3.13.7. No GPU involved. AI-assisted (Claude Code); the commands and results above were run on the author's PC.
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#2331
No description provided.