Emulate the AMD-only CLZERO instruction in the Windows crash handler #27524
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
Imported from boykopovar/AnyPS5. Originally posted by akkadbakkad89 on 2026-11-26T16:21:06Z.
CLZERO is an AMD-only cache instruction (
0f 01 fc) that zeroes the 64-byte cache line containing the linear address inrax. Intel hosts raiseSTATUS_ILLEGAL_INSTRUCTION(0xc000001d) when a converted title executes it.Observed with title PPSA38500 (see discussion #27523), which uses
clzero; add rax, 0x40loops for bulk memory zeroing. On an Intel host (i7-10700) the run dies in the crash reporter withCLZERO is an AMD-only instruction this CPU lacks: relink with --to-intel.The suggested static path does not cover this binary:
--to-intelconversion fails withBranch enters an AMD-only instruction(offset 0x22e111), because a branch target lands inside the instruction window the trampoline overwrite would relocate. Runtime-generated code is also out of scope for static conversion by design.The crash handler already emulates the AMD-only SSE4a instructions EXTRQ/INSERTQ on the faulting thread's CONTEXT (
core/libs/prx/libc/src/specifics/windows/Sse4aEmulation.hpp). CLZERO fits the same pattern: decode0f 01 fc, zero(rax & ~63) .. +64, advance rip by 3, resume. A local implementation of exactly this boots the title past the fault.Open questions for the implementation:
specifies/windows); whether a Linux equivalent is needed is a separate question since the SSE4a machinery has no Linux counterpart either.