feat(relinker): lower MONITORX and MWAITX for --to-intel #201
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/201"
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 ljkx on 2026-10-01T00:29:18Z.
What
Addresses part of the
--to-intelitem indocs/dev/TechnicalDebt.md: a MONITORX (0F 01 FA) or MWAITX (0F 01 FB) anywhere in a converted segment failed the whole relink. Since #151, guest modules (a title's ownsce_modulePRX such as libc and libSceJobManager) go through the same conversion. No title is currently known to contain these instructions.Both are now replaced in place, at the same length, by the matcher:
F3 90) followed by NOPs up to the instruction's length.Why this is exact rather than an approximation, from the AMD APM Vol. 3 (rev 3.36, MWAITX):
Correct callers therefore loop and re-check, as the Linux kernel's
delay_haltdoes around MWAITX ("these functions may return earlier than requested"). The replacement returns at once every time, which real hardware also does. On a Ryzen 7 7800X3D, MWAITX without an armed monitor and with a 2·10⁹-cycle timer returned after ~900 cycles. rFLAGS: none for either instruction.Limits:
CLZERO, RDPRU and MCOMMIT still fail the relink:
MOVNTDQof zero to the aligned 64-byte line match its non-temporal, weakly ordered store. It needs an out-of-line stub, so it is left for a follow-up PR using the stub builder from #200.TechnicalDebt.md: the item now lists CLZERO/RDPRU/MCOMMIT.Rebased onto
mainafter #200; the conflicts with it in the matcher, its tests and theTechnicalDebt.mdline were resolved by keeping both changes.Tested
mainincluding #200) passes on Windows 11 (Clang 23, and MinGW-w64 GCC 16.2 with static linking) and on Ubuntu 24.04 under WSL (GCC 13.3).amd64_only_converter:0F 1F 00, MWAITX →F3 90 90, and the prefixed forms67 0F 01 FA→0F 1F 40 00and2E 41 0F 01 FB→F3 90 0F 1F 00.Checklist
main; no other open PR implements the same functions.mdfiles or images added to the repository