MONITORX/MWAITX crash on Intel hosts when static --to-intel conversion cannot apply #27564

Open
opened 2026-11-26 18:10:26 +00:00 by akkadbakkad89 · 0 comments
akkadbakkad89 commented 2026-11-26 18:10:26 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by akkadbakkad89 on 2026-11-26T18:10:26Z.


Problem

Titles that use MONITORX/MWAITX spin-wait primitives crash on Intel hosts with STATUS_ILLEGAL_INSTRUCTION (0xc000001d) even after CLZERO emulation (#27524, PR #27532), because no runtime emulation exists for the AMD-only monitor/mwait pair. The vectored exception handler already diagnoses them (MONITORX is an AMD-only instruction this CPU lacks) but then the process dies.

Why the static path cannot cover this

  • --to-intel lowering for MONITORX/MWAITX exists since #201, and MWAITX correctly lowers to pause because spurious wakeups are architecturally permitted. But the relink itself fails on at least one observed AAA binary with FAIL: Branch enters an AMD-only instruction — a branch target lands inside an instruction the lowering must rewrite, which static rewriting cannot survive. (This is the same conversion limitation that motivates runtime CLZERO emulation in #27532.)
  • Runtime-generated code never passes through static conversion at all, so even a perfect relinker cannot cover titles that JIT.

Proposed fix

Runtime emulation in the vectored exception handler, mirroring the SSE4a/CLZERO header pattern:

  • MONITORX (0F 01 FA): skip. Arming the monitor is an optimization hint with no mandatory architectural effect, so a no-op is semantics-exact.
  • MWAITX (0F 01 FB): skip (optionally with a light yield). Wakeups are voluntary — software must re-test its condition in a loop — so returning immediately is architecturally correct. The trade-off versus native behavior is spin-loop power/CPU cost, matching what the static pause lowering already accepts.

Evidence

Crash report from an Intel i7-10700 boot of PPSA38500, immediately after the title's first GPU frame submission (PM4 FLIP):

FATAL: unhandled exception 0xc000001d on thread 2736 ''
  rip 0x0000000000655e75 app.exe+0x265e75
  bytes 0f 01 fa 49 8b 07 48 29 (sse4a emulation on, 0 emulated so far)
  MONITORX is an AMD-only instruction this CPU lacks: relink with --to-intel ...

The faulting rip is inside statically converted guest code — this binary is exactly the case --to-intel cannot convert (its relink fails as described above), so the instruction reaches the host CPU unrewritten.

Notes

  • The existing diagnostic message in the crash reporter mentions MONITORX by name; no emulation is attempted (0 emulated so far refers to the SSE4a counter).
  • I am implementing this and will open a PR.
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:6632591601 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/27564). Originally posted by [akkadbakkad89](https://github.com/akkadbakkad89) on 2026-11-26T18:10:26Z. --- **Problem** Titles that use MONITORX/MWAITX spin-wait primitives crash on Intel hosts with `STATUS_ILLEGAL_INSTRUCTION` (0xc000001d) even after CLZERO emulation (#27524, PR #27532), because no runtime emulation exists for the AMD-only monitor/mwait pair. The vectored exception handler already diagnoses them (`MONITORX is an AMD-only instruction this CPU lacks`) but then the process dies. **Why the static path cannot cover this** - `--to-intel` lowering for MONITORX/MWAITX exists since #201, and MWAITX correctly lowers to `pause` because spurious wakeups are architecturally permitted. But the relink itself fails on at least one observed AAA binary with `FAIL: Branch enters an AMD-only instruction` — a branch target lands inside an instruction the lowering must rewrite, which static rewriting cannot survive. (This is the same conversion limitation that motivates runtime CLZERO emulation in #27532.) - Runtime-generated code never passes through static conversion at all, so even a perfect relinker cannot cover titles that JIT. **Proposed fix** Runtime emulation in the vectored exception handler, mirroring the SSE4a/CLZERO header pattern: - MONITORX (`0F 01 FA`): skip. Arming the monitor is an optimization hint with no mandatory architectural effect, so a no-op is semantics-exact. - MWAITX (`0F 01 FB`): skip (optionally with a light yield). Wakeups are voluntary — software must re-test its condition in a loop — so returning immediately is architecturally correct. The trade-off versus native behavior is spin-loop power/CPU cost, matching what the static `pause` lowering already accepts. **Evidence** Crash report from an Intel i7-10700 boot of PPSA38500, immediately after the title's first GPU frame submission (PM4 FLIP): ``` FATAL: unhandled exception 0xc000001d on thread 2736 '' rip 0x0000000000655e75 app.exe+0x265e75 bytes 0f 01 fa 49 8b 07 48 29 (sse4a emulation on, 0 emulated so far) MONITORX is an AMD-only instruction this CPU lacks: relink with --to-intel ... ``` The faulting rip is inside statically converted guest code — this binary is exactly the case `--to-intel` cannot convert (its relink fails as described above), so the instruction reaches the host CPU unrewritten. **Notes** - The existing diagnostic message in the crash reporter mentions MONITORX by name; no emulation is attempted (`0 emulated so far` refers to the SSE4a counter). - I am implementing this and will open a PR.
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5#27564
No description provided.