fix(relinker): initialize MXCSR in macOS guest entry #7741
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/7741"
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 MarcZX10 on 2026-10-19T05:26:40Z.
What
The macOS Mach-O
LC_MAINentry stub calls the bound guest-start routine without applying the measured PS5 payload MXCSR to the main guest thread. Save the host MXCSR in aligned stack storage, load guest MXCSR0x9fc0immediately before the start call, and restore the host value if the call returns. The guest stack pointer is captured before the temporary slot is allocated. This complements #7594's Linux and Windows main-entry paths and #7565's created-thread path.Tested
Linux x86_64, GCC 12.2.0, relinker-only Release build. Full CTest: 210/210 passed. The
macos_outputtest checks the emitted setup and restore instructions, the guest entry target, and the bound start slot.python3 tools/check_conventions.py --base upstream/mainpassed.python3 tools/pr_overlap.py --branch codex/macos-main-thread-mxcsrreported no overlap. No native macOS runtime test was run.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-19T05:43:03Z.
Review: COMMENTED
Native macOS run of the new stub, since the description has none. Apple M2 Max, macOS 27.2, Apple clang 21, head
b5d55bd80merged onmain4ffb0cd12.Relinker-only Release, Python 3.9.6:
ctest201/201 on arm64 and on x86_64 under Rosetta 2. On the base relinker,macos_outputwith the new check fails withentry stub does not save host MXCSR and load guest MXCSR 0x9fc0, and it passes with the fix.Rosetta 2 runtime: an x86_64 probe that runs the exact stub bytes (
mov rsi, rsp,sub rsp, 0x10/stmxcsr/mov dword [rsp+4], 0x9fc0/ldmxcsr,call [rip+slot],ldmxcsr [rsp]/add rsp, 0x10) around a C callee:0x9fc0;0x1f80plus its sticky flags) is restored.So Rosetta 2 accepts the DAZ bit in
ldmxcsrwithout a fault and applies both modes.Not tested: a full relinked title through
LC_MAIN.Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-19T16:52:19Z.
Thanks for the native macOS and Rosetta validation. The relinker-only suite passes 201/201 on both arm64 and x86_64, and the negative control fails with the expected missing guest MXCSR setup. The runtime probe also confirms the stub restores host MXCSR on return. This fills the native macOS evidence gap for the current change; I’ll keep the exact tested head and scope in the PR record.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-21T01:22:59Z.
Manual overlap check for #8658 against #7741, using the current GitHub heads (
b5d55bd804a9andfc7d30780fac). The two PR heads merge together without a conflict. InMacOsImage.cpp, #7741 extends theEntryStubinstructions and updatesEntryStubStartDisplacement; #8658 changes thestubOffsetcalculation to reserve space after load commands. These hunks are separate and compose cleanly. #8658's current merge conflict withmainis indocs/dev/debt/libkernel.md, outside this overlap. I don't see a dependency or code change needed in #7741.