tests: gate the native compacted XRSTOR controls on XSAVEC #2333

Merged
lukaslw-lab merged 1 commit from upstream-pr/2341 into main 2026-11-25 12:53:10 +00:00
lukaslw-lab commented 2026-11-25 12:50:33 +00:00 (Migrated from github.com)

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


Change

On a host with XSAVEOPT but no XSAVEC, cpu_aot_xsave_state ran a native XRSTOR of a compacted image and stopped
with #GP (access violation reading 0xffffffffffffffff) (#2339). In tests/cpu/xsave_state_check.py:

  • check_entry_state_contracts takes has_xsavec. The native compacted restore in the entry-MXCSR control runs
    only with it; the native standard-image comparison of the same export still runs on every host.
  • native_exports_for_host drops SSE_COMPACTED_CONTROL_EXPORT without XSAVEC, with the other compacted fixtures.
  • The gate check also covers a host with XSAVEOPT but no XSAVEC: the SSE compacted control is dropped and
    op_xrstor64_avx_xsaveopt64_avx is kept.

Test-only; the lifted checks and the translator are unchanged. Fixes #2339.

Verification

Commit 199c285f (on eda7cc3c) on Windows 10 22H2 (build 19045), Intel Core i7-4790K (XSAVEOPT, no XSAVEC),
Visual Studio 2026 (MSVC 19.52), Python 3.13.7.

ctest --preset dev --no-tests=error -R '^cpu_aot_xsave'
1 total: 1 passed, 0 skipped, 0 failed

The script prints 200 native/lifted/reference XSAVE/XRSTOR cases across 20 exports matched bit-for-bit.

Check (same build, same arguments as CTest) Result
upstream tests/cpu/xsave_state_check.py OSError: exception: access violation reading 0xFFFFFFFFFFFFFFFF, exit 1
this branch exit 0
native_exports_for_host(..., has_xsavec=False, has_xsaveopt=True), upstream keeps SSE_COMPACTED_CONTROL_EXPORT
the same, this branch drops it; keeps op_xrstor64_avx_xsaveopt64_avx

Not run here: the new gate assertions themselves. They sit in the block that runs only with XSAVEC, so CI's
runners execute them; the last two rows check the same function directly. The release preset was not run.

Evidence and follow-up

  • No new fixture. Negative controls: the unchanged upstream script on the same build, and the upstream gate
    function for the XSAVEOPT-without-XSAVEC host (rows above).
  • Open #1646 also edits this file; it merges cleanly with this branch.

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. (No capability or requirement changed.)
  • I did not include game files, dumps, distribution links or secrets.

AI-assisted: prepared with Claude Code; the commands and results above were run on the author's PC.

🤖 Generated with Claude Code

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6604876931 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2341). Originally posted by [lukaslw-lab](https://github.com/lukaslw-lab) on 2026-11-25T12:50:33Z. --- ## Change On a host with XSAVEOPT but no XSAVEC, `cpu_aot_xsave_state` ran a native XRSTOR of a compacted image and stopped with #GP (`access violation reading 0xffffffffffffffff`) (#2339). In `tests/cpu/xsave_state_check.py`: - `check_entry_state_contracts` takes `has_xsavec`. The native compacted restore in the entry-MXCSR control runs only with it; the native standard-image comparison of the same export still runs on every host. - `native_exports_for_host` drops `SSE_COMPACTED_CONTROL_EXPORT` without XSAVEC, with the other compacted fixtures. - The gate check also covers a host with XSAVEOPT but no XSAVEC: the SSE compacted control is dropped and `op_xrstor64_avx_xsaveopt64_avx` is kept. Test-only; the lifted checks and the translator are unchanged. Fixes #2339. ## Verification Commit `199c285f` (on `eda7cc3c`) on Windows 10 22H2 (build 19045), Intel Core i7-4790K (XSAVEOPT, no XSAVEC), Visual Studio 2026 (MSVC 19.52), Python 3.13.7. ctest --preset dev --no-tests=error -R '^cpu_aot_xsave' 1 total: 1 passed, 0 skipped, 0 failed The script prints `200 native/lifted/reference XSAVE/XRSTOR cases across 20 exports matched bit-for-bit`. | Check (same build, same arguments as CTest) | Result | |---|---| | upstream `tests/cpu/xsave_state_check.py` | `OSError: exception: access violation reading 0xFFFFFFFFFFFFFFFF`, exit 1 | | this branch | exit 0 | | `native_exports_for_host(..., has_xsavec=False, has_xsaveopt=True)`, upstream | keeps `SSE_COMPACTED_CONTROL_EXPORT` | | the same, this branch | drops it; keeps `op_xrstor64_avx_xsaveopt64_avx` | Not run here: the new gate assertions themselves. They sit in the block that runs only with XSAVEC, so CI's runners execute them; the last two rows check the same function directly. The `release` preset was not run. ## Evidence and follow-up - No new fixture. Negative controls: the unchanged upstream script on the same build, and the upstream gate function for the XSAVEOPT-without-XSAVEC host (rows above). - Open #1646 also edits this file; it merges cleanly with this branch. ## 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. - [ ] I updated README/docs when a capability or build requirement changed. (No capability or requirement changed.) - [x] I did not include game files, dumps, distribution links or secrets. _AI-assisted: prepared with Claude Code; the commands and results above were run on the author's PC._ 🤖 Generated with [Claude Code](https://claude.com/claude-code)
upstream-sync closed this pull request 2026-11-25 13:00:55 +00:00
tedin7 commented 2026-11-25 13:00:56 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T12:51:53Z.

Review: COMMENTED


Review of head 199c285f7d8025de085c5744a57e56cebe9cc093 (only tests/cpu/xsave_state_check.py).

Findings: 0 P1, 0 P2.

  • SSE_COMPACTED_CONTROL_EXPORT (op_xrstor64_sse_compacted_avx_xsaveopt64_avx) always restores a compacted image (XCOMP_BV[63] set). On a host without XSAVEC that native restore raises #GP, so gating it with the XSAVEC exports is right. It stays gated on XSAVEOPT too.
  • check_entry_state_contracts now takes has_xsavec and skips only the native compacted restore. The native standard-image comparison still runs. The caller passes the has_xsavec it already computed from host_has_xsavec.
  • The new XSAVEOPT-without-XSAVEC case (Haswell/Broadwell) asserts that the compacted SSE control is dropped and that op_xrstor64_avx_xsaveopt64_avx stays. It also asserts that no XSAVEC or compacted export remains.
  • No other open PR touches this gating (single-file test change).

Commands executed locally:

  • python3 tests/docs_links_check.py: PASS (19 files, 452 links)
  • python3 tests/bidi_controls_check.py: PASS
  • git diff --check origin/main...HEAD: clean
  • python3 -I -c "ast.parse(...)" on the file: syntax OK
  • Mutation: removed the new name != SSE_COMPACTED_CONTROL_EXPORT clause from native_exports_for_host. The new gated_opt assertion then fails with AssertionError. Restored with git checkout -- .; without the mutation the same assertions PASS.

The native differential run needs Windows. This is a .py-only PR, so I rely on the pure-Python fast path plus the GitHub Windows CI.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6057945799 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2341#pullrequestreview-6057945799). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T12:51:53Z. **Review:** COMMENTED --- Review of head `199c285f7d8025de085c5744a57e56cebe9cc093` (only `tests/cpu/xsave_state_check.py`). Findings: 0 P1, 0 P2. - `SSE_COMPACTED_CONTROL_EXPORT` (`op_xrstor64_sse_compacted_avx_xsaveopt64_avx`) always restores a compacted image (XCOMP_BV[63] set). On a host without XSAVEC that native restore raises #GP, so gating it with the XSAVEC exports is right. It stays gated on XSAVEOPT too. - `check_entry_state_contracts` now takes `has_xsavec` and skips only the native compacted restore. The native standard-image comparison still runs. The caller passes the `has_xsavec` it already computed from `host_has_xsavec`. - The new XSAVEOPT-without-XSAVEC case (Haswell/Broadwell) asserts that the compacted SSE control is dropped and that `op_xrstor64_avx_xsaveopt64_avx` stays. It also asserts that no XSAVEC or compacted export remains. - No other open PR touches this gating (single-file test change). Commands executed locally: - `python3 tests/docs_links_check.py`: PASS (19 files, 452 links) - `python3 tests/bidi_controls_check.py`: PASS - `git diff --check origin/main...HEAD`: clean - `python3 -I -c "ast.parse(...)"` on the file: syntax OK - Mutation: removed the new `name != SSE_COMPACTED_CONTROL_EXPORT` clause from `native_exports_for_host`. The new `gated_opt` assertion then fails with AssertionError. Restored with `git checkout -- .`; without the mutation the same assertions PASS. The native differential run needs Windows. This is a .py-only PR, so I rely on the pure-Python fast path plus the GitHub Windows CI. AI-assisted; commands listed were executed locally.
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!2333
No description provided.