Console CPU instructions: CLZERO with an address-size prefix zeroes the line at EAX #227
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!227
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/227/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@Kalmarv on GitHub · 2026-11-23 21:22 UTC · original
Kalmarv:fix/clzero-addr32→main· +42 −1 · 2 files · 1 commits · merged 2026-11-23 21:31 UTCFollows #216 /
af20b4b.Since
af20b4b, 0x67 is an ignored prefix, so67 0F 01 FCdecodes as CLZERO. With that prefix, the CPU zeroes the line at EAX (zero-extended), but the handler used the full RAX:This change makes the handler use EAX when 0x67 is among the prefixes before
0F 01 FC. It changes no other instruction.Tested
bc59624onaf20b4b.67 0F 01 FCzeroed the 64-byte line at the 32-bit address. Onaf20b4b, the handler returned 0 and zeroed nothing, in both cases tried.eh::tests::clzero_with_an_address_size_prefix_zeroes_at_eax:af20b4b's handler (its "the line at EAX" assertion).eh::3/3 andinsn::2/2 pass.Not tested
67 0F 01 FC(none is known);AI use: Claude Code, Claude Opus 5.5
@ryosen0 on GitHub · 2026-11-23 21:26 UTC · original
Independent confirmation on a second Zen 5 part (Ryzen 7 9800X3D, Windows 11, MSVC 14.44):
Raw bytes run natively on a scratch line mapped at
0x3000_0000(below 4 GiB), a VEH recording the fault code and address:67 0F 01 FC0x3000_000067 0F 01 FC0x1_3000_0000(upper half set)0x3000_0000zeroed, no fault0F 01 FC0x1_3000_00000x1_3000_0000, line untouched0F 01 FC0x3000_0000So the addr32 form truncates to EAX and zero-extends even with RAX's upper half set, matching the PR's description; the plain form faults on the full 64-bit address. With the scratch in the process image (above 4 GiB) the addr32 form faults at the truncated address - the EAX address must be mapped, which is the case the handler's
readablecheck already covers.Also ran the SSE4a formulas (
insn::extrq/insn::insertqsemantics) against the CPU here: 32,776 cases (imm forms, every len 0..63 x idx 0..63 on 4 patterns each, reg-form control words with garbage outside the 6-bit fields) - 0 mismatches, high quadword zero in every case, agreeing with the 9950X numbers above.@Kalmarv on GitHub · 2026-11-23 21:28 UTC · original
Rebased on main
d4f17ca(6b9f2ba). #217 reworked the CLZERO handler (is_writable, theClzeroLoopfast-forward), so the EAX rule now sits on the new lone-CLZERO path.The fast-forward must not run under 0x67: the loop's
jb -12jumps back to the0F, past the prefix, so on the CPU only the first CLZERO is at EAX and the rest of the loop is at RAX. The decoder therefore leaves a 0x67-prefixed CLZERO unfused and steps it alone (length 4); the next trap, at the0F, takes the fast-forward as on main.ehtest covers the lone67 0F 01 FCand the first CLZERO of a 0x67-prefixed loop: only the line at EAX is zeroed, nothing at RAX, and RIP moves by 4. Theinsndecode test has a case for the prefixed loop.eh::3/3 andinsn::2/2 pass (Ryzen 9 9950X, debug).Thanks @ryosen0 for the second Zen 5 run.
🤖 Claude Opus 5.5
@ivall on GitHub · 2026-11-23 21:31 UTC · original
Merged (main
60565c4), your rebased head with the 0x67 / CLZERO-loop fix. Checked on an RX 9070 (RDNA4):cargo build --workspace && cargo test --workspace -- --test-threads=4- 611 unit tests passed, 0 failed; the retail game still reaches its first menu at 30 fps.