SSE4a on Intel CPUs: MOVNTSS and MOVNTSD emulated #234

Open
github-bot wants to merge 1 commit from github-bot/gh-234 into main AGit
Owner

@⁠philip-sudowicki on GitHub · 2026-11-23 21:41 UTC · original
philip-sudowicki:sse4a-movnts → main · +200 −5 · 3 files · 1 commits · open

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
**@⁠philip-sudowicki** on GitHub · 2026-11-23 21:41 UTC · [original](https://github.com/xcl-dev/xcl/pull/234) `philip-sudowicki:sse4a-movnts` → `main` · +200 −5 · 3 files · 1 commits · open 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
The rest of SSE4a after EXTRQ / INSERTQ (#216): the scalar streaming stores
movntss m32, xmm (F3 0F 2B /r) and movntsd m64, xmm (F2 0F 2B /r) raise
STATUS_ILLEGAL_INSTRUCTION on an Intel CPU as well. They are decoded with
their memory operand (ModRM, SIB, disp8 / disp32, rip-relative, REX.R / X / B,
a 0x67 32-bit address; the last of F2 / F3 decides, as for EXTRQ / INSERTQ)
and done as a plain store of the XMM register's low dword / quadword. A store
through fs / gs is not decoded (its segment base is not in the context), and
one to memory that is not readable is left to fault, as the real store would.

Not seen in a retail title yet: this closes the SSE4a set, so a title that
streams scalars (_mm_stream_ss / _mm_stream_sd) does not stop on Intel.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Jb9jP9N4iPe9ifX4YaaTrF
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:17:01 +00:00
Author
Owner

@⁠AlpPesen on GitHub · 2026-11-23 22:14 UTC · original

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.

**@⁠AlpPesen** on GitHub · 2026-11-23 22:14 UTC · [original](https://github.com/xcl-dev/xcl/pull/234#issuecomment-7115508056) 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.*
Author
Owner

@⁠ersinhf on GitHub · 2026-11-23 23:26 UTC · original

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.
**@⁠ersinhf** on GitHub · 2026-11-23 23:26 UTC · [original](https://github.com/xcl-dev/xcl/pull/234#issuecomment-7116961790) 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.
Author
Owner

@⁠SlopTart on GitHub · 2026-11-24 06:01 UTC · original

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.

**@⁠SlopTart** on GitHub · 2026-11-24 06:01 UTC · [original](https://github.com/xcl-dev/xcl/pull/234#issuecomment-7123505309) 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.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-25 15:19 UTC · original

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

**@⁠DavidM1911** on GitHub · 2026-11-25 15:19 UTC · [original](https://github.com/xcl-dev/xcl/pull/234#issuecomment-7166669123) Verification on RTX 3060 Ti (Windows 11): **merge conflict with current `main`** — needs a rebase before it can be tested.
This pull request has changes conflicting with the target branch.
  • crates/xcl/src/eh.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/234/head:github-bot/gh-234'
git switch 'github-bot/gh-234'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-234'
git switch 'github-bot/gh-234'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-234'
git switch 'github-bot/gh-234'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-234'
git switch 'main'
git merge --squash 'github-bot/gh-234'
git switch 'main'
git merge --ff-only 'github-bot/gh-234'
git switch 'main'
git merge 'github-bot/gh-234'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.