Jinoh Kang (@iamahuman) commented about dlls/ntdll/unix/signal_arm64.c:
static void ill_handler( int signal, siginfo_t *siginfo, void *sigcontext ) { EXCEPTION_RECORD rec = { EXCEPTION_ILLEGAL_INSTRUCTION };
- ucontext_t *context = sigcontext;
- if (!(PSTATE_sig( context ) & 0x10) && /* AArch64 (not WoW) */
!(PC_sig( context ) & 3))
- {
ULONG instr = *(ULONG *)PC_sig( context );
/* emulate mrs xN, CurrentEL */
if ((instr & ~0x1f) == 0xd5384240) {
REGn_sig(instr & 0x1f, context) = 0;
For MRS, register 31 is XZR, not SP:
```suggestion:-0+0 ULONG reg = instr & 0x1f; if (reg != 31) /* 31: XZR */ REGn_sig(reg, context) = 0; ```
`mrs xzr, CurrentEL` could be emitted by volatile inline asm `mrs %0, CurrentEL` where the compiler optimized out the destination. It could also be part of incorrect JIT code, and such deviation could be difficult to debug.