SSE4a on Intel CPUs: MOVNTSS and MOVNTSD emulated #231

Open
philip-sudowicki wants to merge 1 commit from upstream-pr/234 into main
philip-sudowicki commented 2026-11-23 21:41:04 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by philip-sudowicki on 2026-11-23T21:41:04Z.


SSE4a's scalar streaming stores, movntss m32, xmm (F3 0F 2B /r) and movntsd m64, xmm (F2 0F 2B /r), are emulated like EXTRQ / INSERTQ (#216, 0cd0a53 / af20b4b): on an Intel CPU they raise STATUS_ILLEGAL_INSTRUCTION too, and they were the part of SSE4a still missing. One commit on main 60565c4. No retail title is known to use them yet; this closes the set so a title that streams scalars (_mm_stream_ss / _mm_stream_sd) does not stop on Intel.

What is in it

  • crates/xcl/src/insn.rs: ConsoleOnly::Movnts { bytes, src, mem } and a memory-operand decoder (Mem, mem_operand, address): ModRM / SIB, disp8 / disp32, rip-relative, REX.R / X / B, 0x67 (32-bit address). The last of F2 / F3 decides, as for EXTRQ / INSERTQ; 0F 2B without them (movntps) or with 66 alone (movntpd) is not decoded, nor a register operand, nor a store through fs / gs (its segment base is not in the context).
  • crates/xcl/src/eh.rs: the store of the XMM register's low dword / quadword at the computed address; memory that is not readable is left to fault, as the real store would. End-to-end test sse4a_streaming_stores_run_in_a_title_image: real movntsd / movntss / rip-relative movntsd in a registered title page, through the vectored handler (on an AMD CPU they run natively, same results).
  • HANDOFF.md: the SSE4a sentence in "Console CPU instructions the PC lacks".

Tested

  • CPU: Intel Xeon @ 2.10 GHz, no SSE4a (the trap path runs: the log shows Movnts { .. } in …+0x5 – a console CPU instruction this CPU lacks: emulated)
  • Linux, cross-compiled x86_64-pc-windows-gnu (mingw-w64 13.2), Rust 1.97.0, debug; run under Wine 9.0
  • xcl-*.exe insn:: eh:: on top of 60565c4: 8 passed, 0 failed (the new decodes_the_sse4a_streaming_stores, memory_operand_addresses, sse4a_streaming_stores_run_in_a_title_image, and the existing insn / eh tests, clzero_with_an_address_size_prefix_zeroes_at_eax included)
  • cargo check --workspace --all-targets --target x86_64-pc-windows-gnu: no warnings

Not tested

  • Windows itself, the MSVC toolchain, scripts/test.ps1 / the full suite (the D3D12 and audio tests cannot run under Wine on this machine)
  • an AMD CPU (the native path) and the F2 / F3 order on hardware for 0F 2B (it follows the rule measured for EXTRQ / INSERTQ in af20b4b)
  • any retail title
<!-- greyfinch-sync:ivall/xcl:issue:5461701958 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/234). Originally posted by [philip-sudowicki](https://github.com/philip-sudowicki) on 2026-11-23T21:41:04Z. --- SSE4a's scalar streaming stores, `movntss m32, xmm` (F3 0F 2B /r) and `movntsd m64, xmm` (F2 0F 2B /r), are emulated like EXTRQ / INSERTQ (#216, 0cd0a53 / af20b4b): on an Intel CPU they raise STATUS_ILLEGAL_INSTRUCTION too, and they were the part of SSE4a still missing. One commit on `main` 60565c4. No retail title is known to use them yet; this closes the set so a title that streams scalars (`_mm_stream_ss` / `_mm_stream_sd`) does not stop on Intel. **What is in it** - `crates/xcl/src/insn.rs`: `ConsoleOnly::Movnts { bytes, src, mem }` and a memory-operand decoder (`Mem`, `mem_operand`, `address`): ModRM / SIB, disp8 / disp32, rip-relative, REX.R / X / B, 0x67 (32-bit address). The last of F2 / F3 decides, as for EXTRQ / INSERTQ; 0F 2B without them (movntps) or with 66 alone (movntpd) is not decoded, nor a register operand, nor a store through fs / gs (its segment base is not in the context). - `crates/xcl/src/eh.rs`: the store of the XMM register's low dword / quadword at the computed address; memory that is not readable is left to fault, as the real store would. End-to-end test `sse4a_streaming_stores_run_in_a_title_image`: real movntsd / movntss / rip-relative movntsd in a registered title page, through the vectored handler (on an AMD CPU they run natively, same results). - `HANDOFF.md`: the SSE4a sentence in "Console CPU instructions the PC lacks". **Tested** - CPU: Intel Xeon @ 2.10 GHz, **no SSE4a** (the trap path runs: the log shows `Movnts { .. } in …+0x5 – a console CPU instruction this CPU lacks: emulated`) - Linux, cross-compiled `x86_64-pc-windows-gnu` (mingw-w64 13.2), Rust 1.97.0, debug; run under Wine 9.0 - `xcl-*.exe insn:: eh::` on top of 60565c4: 8 passed, 0 failed (the new `decodes_the_sse4a_streaming_stores`, `memory_operand_addresses`, `sse4a_streaming_stores_run_in_a_title_image`, and the existing `insn` / `eh` tests, `clzero_with_an_address_size_prefix_zeroes_at_eax` included) - `cargo check --workspace --all-targets --target x86_64-pc-windows-gnu`: no warnings **Not tested** - Windows itself, the MSVC toolchain, `scripts/test.ps1` / the full suite (the D3D12 and audio tests cannot run under Wine on this machine) - an AMD CPU (the native path) and the F2 / F3 order on hardware for 0F 2B (it follows the rule measured for EXTRQ / INSERTQ in af20b4b) - any retail title
AlpPesen commented 2026-11-24 07:04:31 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by AlpPesen on 2026-11-23T22:14:38Z.


Tested commit 099f1abe0fc8430f94fe8c1543a3e43bd5f19c17 natively on Windows 11 (MSVC) + Intel Core i9-9900K (Coffee Lake, no SSE4a) + AMD Radeon RX 6800 (driver 32.0.21045.29003, DXC 1.9.2602.17, rustc 1.100.0, debug).

Tested

  • XCL_REQUIRE_GPU=wave64,mesh + .\scripts\test.ps1: 654 passed, 0 failed, 40 ignored, 0 GPU skipped (xcl lib: 614 passed / 20 ignored; integration/e2e: 40 passed / 20 ignored; XCL_SAMPLE_* unset).
  • Confirmed on i9-9900K that eh::tests::sse4a_streaming_stores_run_in_a_title_image triggers the real #UD VEH trap (Movnts ... emulated (logged once)) and passes, alongside insn::tests::decodes_the_sse4a_streaming_stores and insn::tests::memory_operand_addresses.

Not tested

  • AMD CPU native execution path (no AMD host CPU here).
  • Retail title run (scripts/smoke.ps1).

Review notes

  1. crates/xcl/src/eh.rs (ConsoleOnly::Movnts): the write guard currently calls crate::gpu::shader::readable(at, bytes as usize) instead of is_writable(at, bytes as usize) (already used right above for Clzero/ClzeroLoop). For a PAGE_READONLY / PAGE_EXECUTE_READ target, readable() returns true and write_unaligned will fault inside the VEH instead of cleanly returning 0.
  2. HANDOFF.md: now that CONTRIBUTING.md is merged, feature PRs should leave HANDOFF.md untouched for the maintainer.
  3. Needs a rebase onto current main (especially around 0x67 handling in insn.rs after #227).

Tested and reviewed with Antigravity (Gemini 4 Neon); each point checked by the author before posting.

<!-- greyfinch-sync:ivall/xcl:comment:7115508056 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/234#issuecomment-7115508056). Originally posted by [AlpPesen](https://github.com/AlpPesen) on 2026-11-23T22:14:38Z. --- Tested commit `099f1abe0fc8430f94fe8c1543a3e43bd5f19c17` natively on Windows 11 (MSVC) + Intel Core i9-9900K (Coffee Lake, no SSE4a) + AMD Radeon RX 6800 (driver `32.0.21045.29003`, DXC `1.9.2602.17`, `rustc 1.100.0`, debug). **Tested** - `XCL_REQUIRE_GPU=wave64,mesh` + `.\scripts\test.ps1`: **654 passed, 0 failed, 40 ignored, 0 GPU skipped** (`xcl` lib: 614 passed / 20 ignored; integration/e2e: 40 passed / 20 ignored; `XCL_SAMPLE_*` unset). - Confirmed on i9-9900K that `eh::tests::sse4a_streaming_stores_run_in_a_title_image` triggers the real `#UD` VEH trap (`Movnts ... emulated (logged once)`) and passes, alongside `insn::tests::decodes_the_sse4a_streaming_stores` and `insn::tests::memory_operand_addresses`. **Not tested** - AMD CPU native execution path (no AMD host CPU here). - Retail title run (`scripts/smoke.ps1`). **Review notes** 1. `crates/xcl/src/eh.rs` (`ConsoleOnly::Movnts`): the write guard currently calls `crate::gpu::shader::readable(at, bytes as usize)` instead of `is_writable(at, bytes as usize)` (already used right above for `Clzero`/`ClzeroLoop`). For a `PAGE_READONLY` / `PAGE_EXECUTE_READ` target, `readable()` returns `true` and `write_unaligned` will fault inside the VEH instead of cleanly returning `0`. 2. `HANDOFF.md`: now that `CONTRIBUTING.md` is merged, feature PRs should leave `HANDOFF.md` untouched for the maintainer. 3. Needs a rebase onto current `main` (especially around `0x67` handling in `insn.rs` after #227). *Tested and reviewed with Antigravity (Gemini 4 Neon); each point checked by the author before posting.*
ersinhf commented 2026-11-24 07:04:40 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by ersinhf on 2026-11-23T23:26:43Z.


Tested 099f1abe0fc8430f94fe8c1543a3e43bd5f19c17 on an AMD CPU with SSE4a (the native path this PR lists under Not tested), clean tree.

Tested

  • AMD Ryzen 5 7500F (Zen 4; CPUID 8000_0001 ECX bit 6 = SSE4a), 32 GB; NVIDIA GeForce RTX 4070, driver 621.14 (32.0.16.2114); Windows 11 build 26200; rustc 1.100.0 stable-x86_64-pc-windows-msvc, debug; DXC 1.9.2602.17 (SDK 10.0.26100.0); no XCL_SAMPLE_* set
  • .\scripts\test.ps1: 654 passed, 0 failed, 40 ignored; SKIPPED 2 (no wave64): gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware
  • eh::tests::sse4a_streaming_stores_run_in_a_title_image, insn::tests::decodes_the_sse4a_streaming_stores and insn::tests::sse4a_bit_fields pass. On this CPU the first one runs the stores natively, so the expected memory contents it asserts are what the hardware writes.

The F2 / F3 order of 0F 2B on hardware

A standalone probe (not part of XCL) ran movq xmm0, rdx; <prefixes> 0F 2B 01; ret natively on the 7500F into a 0xAA-filled buffer and counted the bytes written:

prefixes bytes stored
F3 0F 2B 4 (movntss)
F2 0F 2B 8 (movntsd)
F2 F3 0F 2B 4
F3 F2 0F 2B 8
66 F2 0F 2B / F2 66 0F 2B 8 / 8
66 F3 0F 2B / F3 66 0F 2B 4 / 4

So on Zen 4 the last of F2 / F3 decides and a 66 next to them does not matter, the same rule as for EXTRQ / INSERTQ. That is what decode does and what decodes_the_sse4a_streaming_stores asserts (F2 F3 → 4 bytes, 66 F2 → 8 bytes).

Not tested

  • Zen 2 itself (the console's CPU) and Intel (covered by the report above)
  • the fs / gs-relative and 0x67 forms on hardware (the probe used [rcx] only)
  • a retail title / scripts/smoke.ps1

AI use

  • Claude Code with Claude Opus 5.5 ran the build, the suite and the probe on this machine and wrote this comment; the person posting it checked each point.
<!-- greyfinch-sync:ivall/xcl:comment:7116961790 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/234#issuecomment-7116961790). Originally posted by [ersinhf](https://github.com/ersinhf) on 2026-11-23T23:26:43Z. --- Tested `099f1abe0fc8430f94fe8c1543a3e43bd5f19c17` on an **AMD CPU with SSE4a** (the native path this PR lists under **Not tested**), clean tree. **Tested** - AMD Ryzen 5 7500F (Zen 4; CPUID 8000_0001 ECX bit 6 = SSE4a), 32 GB; NVIDIA GeForce RTX 4070, driver 621.14 (32.0.16.2114); Windows 11 build 26200; rustc 1.100.0 `stable-x86_64-pc-windows-msvc`, debug; DXC 1.9.2602.17 (SDK 10.0.26100.0); no `XCL_SAMPLE_*` set - `.\scripts\test.ps1`: **654 passed, 0 failed, 40 ignored**; `SKIPPED` 2 (no wave64): `gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu_wave32_program_in_wave64_hardware` - `eh::tests::sse4a_streaming_stores_run_in_a_title_image`, `insn::tests::decodes_the_sse4a_streaming_stores` and `insn::tests::sse4a_bit_fields` pass. On this CPU the first one runs the stores natively, so the expected memory contents it asserts are what the hardware writes. **The F2 / F3 order of 0F 2B on hardware** A standalone probe (not part of XCL) ran `movq xmm0, rdx; <prefixes> 0F 2B 01; ret` natively on the 7500F into a 0xAA-filled buffer and counted the bytes written: | prefixes | bytes stored | |---|---| | `F3 0F 2B` | 4 (movntss) | | `F2 0F 2B` | 8 (movntsd) | | `F2 F3 0F 2B` | 4 | | `F3 F2 0F 2B` | 8 | | `66 F2 0F 2B` / `F2 66 0F 2B` | 8 / 8 | | `66 F3 0F 2B` / `F3 66 0F 2B` | 4 / 4 | So on Zen 4 the last of F2 / F3 decides and a 66 next to them does not matter, the same rule as for EXTRQ / INSERTQ. That is what `decode` does and what `decodes_the_sse4a_streaming_stores` asserts (`F2 F3` → 4 bytes, `66 F2` → 8 bytes). **Not tested** - Zen 2 itself (the console's CPU) and Intel (covered by the report above) - the fs / gs-relative and 0x67 forms on hardware (the probe used `[rcx]` only) - a retail title / `scripts/smoke.ps1` **AI use** - Claude Code with Claude Opus 5.5 ran the build, the suite and the probe on this machine and wrote this comment; the person posting it checked each point.
SlopTart commented 2026-11-24 07:06:42 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by SlopTart on 2026-11-24T06:01:52Z.


AMD-native-path and full-suite datapoints — the two axes your row lists as not tested.

Machine: Ryzen 9 9900X (SSE4a native: MOVNTSS/MOVNTSD decode and execute in hardware), RX 7900 XT (RADV NAVI31), Mesa 26.2.5, kernel 7.2 (Arch), Wine = Proton Experimental (wine-11.0), patched vkd3d-proton v3.1, Rust 1.100.0 cross x86_64-pc-windows-gnu. Release profile, XCL_NETWORK=0. (Same rig as my Linux rows in #42 / #718.)

Merged state: your head 099f1abe0 onto main d5442d2 — one conflict, only at the tail of mod tests in eh.rs (both sides append tests; kept both). Everything else auto-merged.

Targeted, cargo test -p xcl --lib -- sse4a: 3/3 pass —

  • insn::tests::decodes_the_sse4a_streaming_stores
  • eh::tests::sse4a_streaming_stores_run_in_a_title_image
  • insn::tests::sse4a_bit_fields

On this CPU the stores never raise STATUS_ILLEGAL_INSTRUCTION, so sse4a_streaming_stores_run_in_a_title_image passing here means the handler stays out of the way and the native stores land the same values (the test is written to hold on either path, which it does).

Full suite on the merged head, cargo test --workspace --release --no-fail-fast -- --test-threads=4: 697 passed, 10 failed, 41 ignored (17 suites) — vs 697 / 7 / 41 on plain d5442d2 on this rig. The 7 are this rig's stable Wine-lane failures (listed in my #42 row); the 3 extra were placed_title_textures_share_vram_and_preserve_pixels, transitions_apply_when_their_list_is_submitted and d32s8_targets_take_their_own_size_of_video_memory — the known #718 flaky trio, which has hit ~2 of 5 full-suite runs here regardless of PRs. Nothing in the failure set touches SSE4a, and no new failures.

Not tested: Windows, retail titles, an Intel box under these exact conditions (an Intel Xeon + Wine 9.0 row is already in your own testing notes above).
Counts only, no game data.
AI use: Hermes agent (local Qwen-class) ran the tests and drafted this; I checked it before posting.

<!-- greyfinch-sync:ivall/xcl:comment:7123505309 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/234#issuecomment-7123505309). Originally posted by [SlopTart](https://github.com/SlopTart) on 2026-11-24T06:01:52Z. --- AMD-native-path and full-suite datapoints — the two axes your row lists as not tested. **Machine:** Ryzen 9 9900X (SSE4a native: MOVNTSS/MOVNTSD decode and execute in hardware), RX 7900 XT (RADV NAVI31), Mesa 26.2.5, kernel 7.2 (Arch), Wine = Proton Experimental (wine-11.0), patched vkd3d-proton v3.1, Rust 1.100.0 cross `x86_64-pc-windows-gnu`. Release profile, `XCL_NETWORK=0`. (Same rig as my Linux rows in #42 / #718.) **Merged state:** your head `099f1abe0` onto main `d5442d2` — one conflict, only at the tail of `mod tests` in `eh.rs` (both sides append tests; kept both). Everything else auto-merged. **Targeted, `cargo test -p xcl --lib -- sse4a`:** 3/3 pass — - `insn::tests::decodes_the_sse4a_streaming_stores` - `eh::tests::sse4a_streaming_stores_run_in_a_title_image` - `insn::tests::sse4a_bit_fields` On this CPU the stores never raise `STATUS_ILLEGAL_INSTRUCTION`, so `sse4a_streaming_stores_run_in_a_title_image` passing here means the handler stays out of the way and the native stores land the same values (the test is written to hold on either path, which it does). **Full suite on the merged head, `cargo test --workspace --release --no-fail-fast -- --test-threads=4`:** **697 passed, 10 failed, 41 ignored** (17 suites) — vs **697 / 7 / 41** on plain `d5442d2` on this rig. The 7 are this rig's stable Wine-lane failures (listed in my #42 row); the 3 extra were `placed_title_textures_share_vram_and_preserve_pixels`, `transitions_apply_when_their_list_is_submitted` and `d32s8_targets_take_their_own_size_of_video_memory` — the known #718 flaky trio, which has hit ~2 of 5 full-suite runs here regardless of PRs. Nothing in the failure set touches SSE4a, and no new failures. **Not tested:** Windows, retail titles, an Intel box under these exact conditions (an Intel Xeon + Wine 9.0 row is already in your own testing notes above). Counts only, no game data. AI use: Hermes agent (local Qwen-class) ran the tests and drafted this; I checked it before posting.
DavidM1911 commented 2026-11-25 16:12:08 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T15:19:43Z.


Verification on RTX 3060 Ti (Windows 11): merge conflict with current main — needs a rebase before it can be tested.

<!-- greyfinch-sync:ivall/xcl:comment:7166669123 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/234#issuecomment-7166669123). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-25T15:19:43Z. --- Verification on RTX 3060 Ti (Windows 11): **merge conflict with current `main`** — needs a rebase before it can be tested.
github-actions[bot] commented 2026-11-29 20:42:56 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-11-29T20:42:56Z.


Nothing has happened on this PR for 3 days, so it is marked stale and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto main if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.

<!-- greyfinch-sync:ivall/xcl:comment:7262300162 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/234#issuecomment-7262300162). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-29T20:42:56Z. --- Nothing has happened on this PR for 3 days, so it is marked `stale` and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto `main` if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.
Foniass commented 2026-12-01 03:01:08 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T03:01:08Z.


Triage (#1607) – head 099f1ab

No open or merged PR emulates MOVNTSS/MOVNTSD (#434 and #829 test other SSE4a/console-only instructions), and main does not decode them.
Small problem in eh.rs: emulate_console_only: the store target is checked with shader::readable, which says nothing about writability. A movnts to a read-only page faults inside the handler instead of returning to let the original exception through.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

<!-- greyfinch-sync:ivall/xcl:comment:7299234899 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/234#issuecomment-7299234899). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T03:01:08Z. --- **Triage (#1607)** – head 099f1ab No open or merged PR emulates MOVNTSS/MOVNTSD (#434 and #829 test other SSE4a/console-only instructions), and main does not decode them. Small problem in `eh.rs: emulate_console_only`: the store target is checked with `shader::readable`, which says nothing about writability. A movnts to a read-only page faults inside the handler instead of returning to let the original exception through. Recommendation: keep open. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/234:upstream-pr/234'
git switch 'upstream-pr/234'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/234'
git switch 'upstream-pr/234'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/234'
git switch 'upstream-pr/234'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/234'
git switch 'main'
git merge --squash 'upstream-pr/234'
git switch 'main'
git merge --ff-only 'upstream-pr/234'
git switch 'main'
git merge 'upstream-pr/234'
git push origin 'main'
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
xcl-dev/xcl!231
No description provided.