Console CPU instructions: enforce mandatory prefix precedence for CLWB and RDPID #1555

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

@⁠b3IKK on GitHub · 2026-11-24 17:37 UTC · original
b3IKK:eh/insn-prefix-precedence → main · +12 −10 · 1 files · 1 commits · open

insn::decode tracked rep (the last of 0xF2 / 0xF3) for SSE4a, but checked raw p66 for CLWB (66 0F AE /6) and a sticky pf3 for RDPID (F3 0F C7 /7). As a result, #UD encodings with conflicting mandatory prefixes (F3 66 0F AE 30, F2 66 0F AE 30, 66 F3 0F AE 30, and F3 F2 0F C7 F8) were misdecoded as CLWB or RDPID and silently emulated.

This requires rep == 0 && p66 for CLWB and rep == 0xF3 for RDPID, dropping the unused sticky pf3 flag.

What is in it

  • crates/xcl/src/insn.rs: enforce rep == 0 && p66 for CLWB and rep == 0xF3 for RDPID; add prefix-precedence assertions to decodes_the_console_only_instructions (verified failing before the fix).

Tested

  • hardware (GPU + driver, CPU), Windows build, Rust version, debug / release: NVIDIA GeForce RTX 5080 (driver 32.0.16.1088), AMD Ryzen 9 9950X3D, Windows 11 10.0.26300, Rust 1.100.0 (stable-x86_64-pc-windows-msvc), DXC 1.9.2609.5, debug (scripts/test.ps1) and release (scripts/smoke.ps1)
  • .\scripts\test.ps1 (cargo build --workspace + cargo test --workspace -- --test-threads=4): 776 passed, 0 failed, 41 ignored (SKIPPED GPU tests: 2 no wave64 — gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask, gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware; 1 no heap windows — heap_window_out_of_memory_falls_back_to_the_switch_form)
  • cargo test -p xcl --lib insn::tests: 2 passed, 0 failed (decodes_the_console_only_instructions failed before the fix)

Regression run

main:

xcl-smoke v1
commit: 47efa2ecea0a12934719ae69b81930cf02a4b1c3
gpu: NVIDIA GeForce RTX 5080
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1226 (PresentX 1226)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15341 MB

PR:

xcl-smoke v1
commit: f27e63dee989771062f075a7ce85fe9e0e9239b7
gpu: NVIDIA GeForce RTX 5080
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1653 (PresentX 1653)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14599 MB

Not tested

  • AMD GPUs and native wave64 hardware
  • other titles (Minecraft Preview, Unicorn Overlord, Fortnite, XDefiant) and Linux / Wine

AI use

  • OpenCode, Gemini 4 Neon: audited insn.rs, wrote the fix and unit test cases, ran the test suite and scripts/smoke.ps1 regression runs, and drafted this PR description.
**@⁠b3IKK** on GitHub · 2026-11-24 17:37 UTC · [original](https://github.com/xcl-dev/xcl/pull/1555) `b3IKK:eh/insn-prefix-precedence` → `main` · +12 −10 · 1 files · 1 commits · open `insn::decode` tracked `rep` (the last of `0xF2` / `0xF3`) for SSE4a, but checked raw `p66` for `CLWB` (`66 0F AE /6`) and a sticky `pf3` for `RDPID` (`F3 0F C7 /7`). As a result, `#UD` encodings with conflicting mandatory prefixes (`F3 66 0F AE 30`, `F2 66 0F AE 30`, `66 F3 0F AE 30`, and `F3 F2 0F C7 F8`) were misdecoded as `CLWB` or `RDPID` and silently emulated. This requires `rep == 0 && p66` for `CLWB` and `rep == 0xF3` for `RDPID`, dropping the unused sticky `pf3` flag. **What is in it** - `crates/xcl/src/insn.rs`: enforce `rep == 0 && p66` for `CLWB` and `rep == 0xF3` for `RDPID`; add prefix-precedence assertions to `decodes_the_console_only_instructions` (verified failing before the fix). **Tested** - hardware (GPU + driver, CPU), Windows build, Rust version, debug / release: NVIDIA GeForce RTX 5080 (driver 32.0.16.1088), AMD Ryzen 9 9950X3D, Windows 11 10.0.26300, Rust 1.100.0 (`stable-x86_64-pc-windows-msvc`), DXC 1.9.2609.5, debug (`scripts/test.ps1`) and release (`scripts/smoke.ps1`) - `.\scripts\test.ps1` (`cargo build --workspace` + `cargo test --workspace -- --test-threads=4`): 776 passed, 0 failed, 41 ignored (SKIPPED GPU tests: 2 `no wave64` — `gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware`; 1 `no heap windows` — `heap_window_out_of_memory_falls_back_to_the_switch_form`) - `cargo test -p xcl --lib insn::tests`: 2 passed, 0 failed (`decodes_the_console_only_instructions` failed before the fix) **Regression run** main: ``` xcl-smoke v1 commit: 47efa2ecea0a12934719ae69b81930cf02a4b1c3 gpu: NVIDIA GeForce RTX 5080 title: 9cc6a39e seconds: 60 exit: 0x0 frames shown: 1226 (PresentX 1226) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 15341 MB ``` PR: ``` xcl-smoke v1 commit: f27e63dee989771062f075a7ce85fe9e0e9239b7 gpu: NVIDIA GeForce RTX 5080 title: 9cc6a39e seconds: 60 exit: 0x0 frames shown: 1653 (PresentX 1653) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14599 MB ``` **Not tested** - AMD GPUs and native wave64 hardware - other titles (Minecraft Preview, Unicorn Overlord, Fortnite, XDefiant) and Linux / Wine **AI use** - OpenCode, Gemini 4 Neon: audited `insn.rs`, wrote the fix and unit test cases, ran the test suite and `scripts/smoke.ps1` regression runs, and drafted this PR description.
insn::decode tracked `rep` (the last of 0xF2 / 0xF3) for SSE4a but
checked raw `p66` for CLWB (66 0F AE /6) and a sticky `pf3` for RDPID
(F3 0F C7 /7). As a result, `#UD` encodings with conflicting mandatory
prefixes (`F3 66 0F AE 30`, `F2 66 0F AE 30`, `66 F3 0F AE 30`, and
`F3 F2 0F C7 F8`) were misdecoded as CLWB or RDPID and silently emulated.

Require `rep == 0 && p66` for CLWB and `rep == 0xF3` for RDPID, and
drop the unused sticky `pf3` flag.

Assisted-by: OpenCode (Gemini 4 Neon)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:57:22 +00:00
Author
Owner

@⁠futurepro62 on GitHub · 2026-11-24 18:51 UTC · original

Full-suite run, since this PR has no test report yet. Tested exact head f27e63d (on its base 9e3831e).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 616.64, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, DXC + dxil.dll 1.9.2602.17 (Windows SDK 10.0.26100), debug, D3D12 debug layer installed.
  • cargo build --workspace, then XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form: 775 passed, 0 failed, 41 ignored. SKIPPED (no wave64): gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware.
  • No new #[test] functions in the diff.
  • Same head on the AMD Radeon integrated GPU (iGPU) of the Ryzen 7 9800X3D (RDNA2, XCL_ADAPTER=radeon), cargo test --workspace -- --test-threads=4: 776 passed, 0 failed, 41 ignored. SKIPPED: heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows).
  • heap_window_out_of_memory_falls_back_to_the_switch_form was skipped with --skip. It fails on main 9e3831e too, not because of this PR: under XCL_REQUIRE_GPU=mesh, runner::skip_test turns every skip except "no wave64" into a failure, including this test's opt-in "no heap windows" skip (XCL_HEAP_WINDOWS unset). Reported as #1651.

Not tested

  • a release build, a game (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
**@⁠futurepro62** on GitHub · 2026-11-24 18:51 UTC · [original](https://github.com/xcl-dev/xcl/pull/1555#issuecomment-7141239777) Full-suite run, since this PR has no test report yet. Tested exact head `f27e63d` (on its base `9e3831e`). **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 616.64, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, DXC + dxil.dll 1.9.2602.17 (Windows SDK 10.0.26100), debug, D3D12 debug layer installed. - `cargo build --workspace`, then `XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form`: **775 passed, 0 failed, 41 ignored**. SKIPPED (no wave64): `gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu_wave32_program_in_wave64_hardware`. - No new `#[test]` functions in the diff. - Same head on the AMD Radeon integrated GPU (iGPU) of the Ryzen 7 9800X3D (RDNA2, `XCL_ADAPTER=radeon`), `cargo test --workspace -- --test-threads=4`: **776 passed, 0 failed, 41 ignored**. SKIPPED: `heap_window_out_of_memory_falls_back_to_the_switch_form` (no heap windows). - `heap_window_out_of_memory_falls_back_to_the_switch_form` was skipped with `--skip`. It fails on main `9e3831e` too, not because of this PR: under `XCL_REQUIRE_GPU=mesh`, `runner::skip_test` turns every skip except "no wave64" into a failure, including this test's opt-in "no heap windows" skip (`XCL_HEAP_WINDOWS` unset). Reported as #1651. **Not tested** - a release build, a game (test run only). **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-24 19:32 UTC · original

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, ~22 ignored. (Intermittent single-test flake under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodified main.)

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-24 19:32 UTC · [original](https://github.com/xcl-dev/xcl/pull/1555#issuecomment-7142242814) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~22 ignored. (Intermittent single-test flake under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodified `main`.) Thanks!
Author
Owner

@⁠upipibi on GitHub · 2026-11-26 16:08 UTC · original

NVIDIA test report for f27e63d: RTX 3070 8 GB (Ampere, driver 616.56), Windows 11 26100, Rust 1.100.0, debug. Head tested as-is on its base 9e3831e.

  • cargo test -p xcl --lib -- --skip hle::xaudio2 --test-threads=4: 718 passed, 0 failed, 21 ignored; 2 SKIPPED (no wave64: gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware), neither in a file this PR changes.
  • insn::tests::decodes_the_console_only_instructions with --exact --test-threads=1 --nocapture, 3 runs: 3/3 passed, 0 SKIPPED.
    Lib tests only; no title run.
    AI-assisted (Claude Code, Claude Opus 5.5).
**@⁠upipibi** on GitHub · 2026-11-26 16:08 UTC · [original](https://github.com/xcl-dev/xcl/pull/1555#issuecomment-7197229410) NVIDIA test report for `f27e63d`: RTX 3070 8 GB (Ampere, driver 616.56), Windows 11 26100, Rust 1.100.0, debug. Head tested as-is on its base `9e3831e`. - `cargo test -p xcl --lib -- --skip hle::xaudio2 --test-threads=4`: 718 passed, 0 failed, 21 ignored; 2 SKIPPED (`no wave64`: gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware), neither in a file this PR changes. - `insn::tests::decodes_the_console_only_instructions` with `--exact --test-threads=1 --nocapture`, 3 runs: 3/3 passed, 0 SKIPPED. Lib tests only; no title run. AI-assisted (Claude Code, Claude Opus 5.5).
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

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

Merge

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