Repository navigation
Conversation
Zen 2 has SSE4a, which no Intel CPU has. A retail game uses INSERTQ (19 of them, immediate form, in its float-to-half packing): on an Intel CPU it ran for two minutes, then stopped with STATUS_ILLEGAL_INSTRUCTION at `insertq xmm0, xmm1, 16, 16` when its first menu reacted to input. insn::decode takes the F2 prefix into account and decodes the immediate forms with register operands: F2 0F 78 /r ib ib (insertq) and 66 0F 78 /0 ib ib (extrq). The emulation works on the low quadword of the XMM registers in the exception's context, as AMD's manual defines it (a field of `len` bits at `idx`, length 0 meaning 64); the upper quadword, undefined on the hardware, is left as it was. Tests: the game's encodings (REX.R / REX.B included) and the bit-field semantics. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Independent static code & AMD64 ISA audit of Summary: Looks solid for immediate SSE4a
|
|
Review of Result: on every valid encoding, the emulated low quadword equals the CPU's, including
Method. A test-only probe, not part of the PR.
When len+idx > 64 (undefined per AMD), the CPU drops the bits past 63, exactly like the PR's Edge encodings: the CPU's behaviour, and what the PR's handler does (✓ means they agree):
Control: the same probe on The #151 gaps besides 0x67 are untouched by this PR, as expected: CLZERO still checks that the line is readable (not writable), and MWAITX does not pause. Tested
Not tested
AI use: Claude Code, Claude Opus 5.5 |
…ecides, 0x67 and early REX ignored From Kalmarv's hardware comparison on PR #209 (32 779 cases, a Ryzen 9 9950X running the instructions natively against the handler): the CPU zeroes the destination's high quadword; the last of F2 / F3 decides and 66 next to them does not (F2 F3 / F3 66 / 66 F3 raise #UD, 66 F2 / F2 66 / F3 F2 are INSERTQ); a 0x67 prefix and a REX before a legacy prefix are ignored – also for CLZERO and the other console-only instructions.
|
Thanks - this crossed with the same fix on main for #216 (0cd0a53, written before I saw this PR), so the branch now conflicts; closing it as superseded rather than merging a second copy. Your Intel run (i7-12700H: past the INSERTQ, loading screen with text) is the confirmation main was missing, and @Kalmarv's hardware comparison is now on main too (af20b4b): the destination's high quadword is zeroed as the Zen 5 does in all 32 779 cases, the last of F2 / F3 decides (F2 F3, F3 66, 66 F3 stay #UD; 66 F2, F2 66, F3 F2 are INSERTQ), 0x67 and a REX before a legacy prefix are ignored (for CLZERO and the rest too), and the register forms 0F 79 are emulated. Checked on an RX 9070 host: |
|
I tested the experimental SSE4a build again. The new log confirms that INSERTQ at game_scarlett_master.exe+0x2e7ff1 is now being emulated successfully. The previous illegal-instruction crash no longer appears in the log. The game continues running and records over 1,000 translated draws, but I still get extremely stuttery narration audio, followed by a green screen and severely distorted audio. I've attached the new log and report.json. System: Intel i9-12900K, RTX 5070, 32GB RAM, Windows 11 25H2. |
|
Ran current
|
Summary
Zen 2 has SSE4a, which no Intel CPU has (the possible further
#UDsource noted in the review of #151). A retail game usesINSERTQ: 19 of them, all the immediate form, in its float-to-half packing. On an Intel CPU, with #151 in place, it ran for about two minutes and presented 900+ frames. Then, when its first menu reacted to input, it stopped withSTATUS_ILLEGAL_INSTRUCTIONatinsertq xmm0, xmm1, 16, 16(F2 0F 78 C1 10 10).This adds SSE4a's immediate forms to #151's decoder and emulation:
insn::decode): now tracks theF2prefix. It decodesF2 0F 78 /r ib ib(insertq xmm, xmm, len, idx) and66 0F 78 /0 ib ib(extrq xmm, len, idx), with REX.R / REX.B, register operands only (the encoding has no memory form).0F 78without a prefix (vmread) is left alone.eh::emulate_console_only): works on the low quadword of the XMM registers in the exception's context. It inserts or extracts a field oflenbits atidx, length 0 meaning 64, as AMD's manual (APM vol. 4) defines them. The upper quadword, undefined on the hardware, is left as it was.A scan of the game's code sections found no
EXTRQand no SSE4a register forms (0F 79) orMOVNTSS/MOVNTSD.EXTRQ's immediate form is included since it shares the opcode.Testing
cargo test --release --workspace: all pass. New:insn::tests::decodes_sse4a(the game's encodings, with REX.R and REX.R + REX.B, plus what must not decode) andinsn::tests::sse4a_semantics.main+ this: the game runs past theINSERTQand shows its loading screen with text.🤖 Generated with Claude Code