fix(relinker): initialize main guest MXCSR at entry #7594

Merged
MarcZX10 merged 7 commits from upstream-pr/7594 into main 2026-11-14 03:24:37 +00:00
MarcZX10 commented 2026-10-18 16:19:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-18T16:19:06Z.


What

The main guest ELF entry runs directly from the relinker startup stubs and bypasses Aps5CallGuestEntry_nid_no_patch, which is covered separately by #7565. This change initializes MXCSR to the measured PS5 payload value 0x9fc0 immediately before the main guest entry on the Linux and Windows startup stubs, then restores the host MXCSR after the entry returns. It leaves the existing frame record intact and preserves stack alignment. It complements #7565 and does not close #7548; the macOS launcher path is outside this change.

Tested

  • Linux x86_64, GCC 12.2.0, relinker-only Release build.
  • All 198 registered CTest tests passed.
  • entry_stub checks emitted Linux and Windows startup stub instructions, including setting guest MXCSR and restoring host MXCSR.
  • linux_entry_argv exercises the Linux entry stub, including its rel32 call range and argument handling.
  • python3 tools/check_conventions.py --base upstream/main passed; git diff --check passed.
  • Windows stub generation was checked on Linux; no Windows runtime test was run.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none; follows up on #7548 without closing it
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4910719093 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7594). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-18T16:19:06Z. --- ### What The main guest ELF entry runs directly from the relinker startup stubs and bypasses `Aps5CallGuestEntry_nid_no_patch`, which is covered separately by #7565. This change initializes MXCSR to the measured PS5 payload value `0x9fc0` immediately before the main guest entry on the Linux and Windows startup stubs, then restores the host MXCSR after the entry returns. It leaves the existing frame record intact and preserves stack alignment. It complements #7565 and does not close #7548; the macOS launcher path is outside this change. ### Tested - Linux x86_64, GCC 12.2.0, relinker-only Release build. - All 198 registered CTest tests passed. - `entry_stub` checks emitted Linux and Windows startup stub instructions, including setting guest MXCSR and restoring host MXCSR. - `linux_entry_argv` exercises the Linux entry stub, including its rel32 call range and argument handling. - `python3 tools/check_conventions.py --base upstream/main` passed; `git diff --check` passed. - Windows stub generation was checked on Linux; no Windows runtime test was run. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none; follows up on #7548 without closing it - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
oneandonlydean commented 2026-10-18 16:52:21 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-18T16:52:21Z.


The stubs look right. One question before merge: with the main thread (here) and created guest threads (#7565) at 0x9fc0, host code called from the guest, and host threads created from a guest thread on Linux (which inherit MXCSR), will run with FTZ/DAZ. Which host work runs in that context, especially the shader recompiler's constant folding and the driver workers? Should host-owned worker threads set the host default MXCSR when they start, so console FP semantics stay on guest code?

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6252539474 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7594#issuecomment-6252539474). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-18T16:52:21Z. --- The stubs look right. One question before merge: with the main thread (here) and created guest threads (#7565) at 0x9fc0, host code called from the guest, and host threads created from a guest thread on Linux (which inherit MXCSR), will run with FTZ/DAZ. Which host work runs in that context, especially the shader recompiler's constant folding and the driver workers? Should host-owned worker threads set the host default MXCSR when they start, so console FP semantics stay on guest code?
MarcZX10 commented 2026-10-18 17:30:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-18T17:30:56Z.


You're right to flag this. Once guest entry installs 0x9fc0, host calls made synchronously on that guest thread also execute with FTZ/DAZ set. On Linux, a std::thread created from that context inherits its creator's floating-point environment unless its entry explicitly resets it. The code has lazily created host workers in graphics/pipeline paths, so the worker-entry boundary needs an audit too. I have not established that every such worker performs floating-point recompiler or driver work, and I do not want to claim that the current setting is harmless. This PR only sets the required MXCSR around the main guest entry; isolating host work is a separate follow-up concern.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6252943511 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7594#issuecomment-6252943511). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-18T17:30:56Z. --- You're right to flag this. Once guest entry installs `0x9fc0`, host calls made synchronously on that guest thread also execute with FTZ/DAZ set. On Linux, a `std::thread` created from that context inherits its creator's floating-point environment unless its entry explicitly resets it. The code has lazily created host workers in graphics/pipeline paths, so the worker-entry boundary needs an audit too. I have not established that every such worker performs floating-point recompiler or driver work, and I do not want to claim that the current setting is harmless. This PR only sets the required MXCSR around the main guest entry; isolating host work is a separate follow-up concern.
MarcZX10 commented 2026-10-18 17:41:33 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-18T17:41:33Z.


I opened follow-up #7622 for host-owned worker startup. It resets MXCSR to 0x1f80 at native worker entry, including the shader registration pool trampoline, and adds a focused regression checking worker and caller MXCSR independently. The change covers native std::thread creation sites; guest-created threads remain under guest MXCSR semantics. Linux focused test and conventions pass. Full project configuration is blocked in this checkout by the missing SDL2 submodule and XRandR development support, so broader CI is still needed.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6253051171 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7594#issuecomment-6253051171). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-18T17:41:33Z. --- I opened follow-up #7622 for host-owned worker startup. It resets MXCSR to 0x1f80 at native worker entry, including the shader registration pool trampoline, and adds a focused regression checking worker and caller MXCSR independently. The change covers native std::thread creation sites; guest-created threads remain under guest MXCSR semantics. Linux focused test and conventions pass. Full project configuration is blocked in this checkout by the missing SDL2 submodule and XRandR development support, so broader CI is still needed.
hugodearaujo commented 2026-10-18 17:42:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by hugodearaujo on 2026-10-18T17:42:00Z.


#7532 changes the same Linux entry stub: when libkernel.prx is in DT_NEEDED, the stub calls EnterGuestMainStack_nid_no_patch through a GLOB_DAT slot instead of calling the entry directly, so the title's main thread runs on a stack at the console's address. The two changes conflict only in EntryStubBuilder.cpp and fit together: EnterGuestMainStack_nid_no_patch does not touch MXCSR, so the value this PR sets before the call reaches the entry unchanged. Whichever lands second can be rebased onto the other; I'm fine either way. Which order do you prefer?

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6253055812 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7594#issuecomment-6253055812). Originally posted by [hugodearaujo](https://github.com/hugodearaujo) on 2026-10-18T17:42:00Z. --- #7532 changes the same Linux entry stub: when `libkernel.prx` is in DT_NEEDED, the stub calls `EnterGuestMainStack_nid_no_patch` through a GLOB_DAT slot instead of calling the entry directly, so the title's main thread runs on a stack at the console's address. The two changes conflict only in `EntryStubBuilder.cpp` and fit together: `EnterGuestMainStack_nid_no_patch` does not touch MXCSR, so the value this PR sets before the call reaches the entry unchanged. Whichever lands second can be rebased onto the other; I'm fine either way. Which order do you prefer?
MarcZX10 commented 2026-10-18 17:50:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-18T17:50:36Z.


I recommend merging #7532 first, then rebasing #7594 onto it and checking the combined Linux entry path. #7532 changes the startup call target to EnterGuestMainStack_nid_no_patch, which switches stacks and calls the ELF entry itself. With #7594 layered outside that helper, MXCSR 0x9fc0 does reach the ELF entry, but the outer stub’s restore-after-call instruction is unreachable on that route because the helper ends with ud2 after the guest entry returns. The combined code should either restore host MXCSR inside the helper after the entry returns, or explicitly document why the Linux path cannot return; its test should assert the composed call shape. Windows remains independent. This is an integration/rebase concern, not a reason to hold either change if the owners are ready to coordinate.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6253144874 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7594#issuecomment-6253144874). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-18T17:50:36Z. --- I recommend merging #7532 first, then rebasing #7594 onto it and checking the combined Linux entry path. #7532 changes the startup call target to EnterGuestMainStack_nid_no_patch, which switches stacks and calls the ELF entry itself. With #7594 layered outside that helper, MXCSR 0x9fc0 does reach the ELF entry, but the outer stub’s restore-after-call instruction is unreachable on that route because the helper ends with ud2 after the guest entry returns. The combined code should either restore host MXCSR inside the helper after the entry returns, or explicitly document why the Linux path cannot return; its test should assert the composed call shape. Windows remains independent. This is an integration/rebase concern, not a reason to hold either change if the owners are ready to coordinate.
DProkos commented 2026-10-18 19:33:45 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by DProkos on 2026-10-18T19:33:45Z.


Windows check of eae903496 merged onto current main (c4c2b3aa7, clean merge).

Windows 11 Pro 26200, WinLibs GCC 15.2.0 r7 UCRT, Ninja, Release, ANYPS5_RELINKER_ONLY=ON, BUILD_TESTING=ON, Python 3.11.0.

  • entry_stub: passed.
  • Full relinker suite: 196/196 passed.

Negative control: with EntryStubBuilder.cpp and WindowsEntryStubBuilder.cpp restored to main and the new test kept, entry_stub fails with the stub does not initialize MXCSR before guest entry.

Not run: titles or homebrew, so MXCSR at guest entry was only checked through the emitted stub, not in a running title.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6254214750 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7594#issuecomment-6254214750). Originally posted by [DProkos](https://github.com/DProkos) on 2026-10-18T19:33:45Z. --- Windows check of eae903496 merged onto current `main` (`c4c2b3aa7`, clean merge). Windows 11 Pro 26200, WinLibs GCC 15.2.0 r7 UCRT, Ninja, Release, `ANYPS5_RELINKER_ONLY=ON`, `BUILD_TESTING=ON`, Python 3.11.0. - `entry_stub`: passed. - Full relinker suite: 196/196 passed. **Negative control:** with `EntryStubBuilder.cpp` and `WindowsEntryStubBuilder.cpp` restored to `main` and the new test kept, `entry_stub` fails with `the stub does not initialize MXCSR before guest entry`. Not run: titles or homebrew, so MXCSR at guest entry was only checked through the emitted stub, not in a running title. AI-assisted: yes
MarcZX10 commented 2026-10-18 22:09:28 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-18T22:09:28Z.


Thanks for the Windows recheck on eae903496. The entry_stub pass, 196/196 relinker tests, and negative control confirm the emitted MXCSR setup on Windows. This is a Windows stub result; the title-level MXCSR value is still not measured. The separate #7532 Linux call path remains an integration point to resolve when that dependency lands.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6255761337 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7594#issuecomment-6255761337). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-18T22:09:28Z. --- Thanks for the Windows recheck on `eae903496`. The `entry_stub` pass, 196/196 relinker tests, and negative control confirm the emitted MXCSR setup on Windows. This is a Windows stub result; the title-level MXCSR value is still not measured. The separate #7532 Linux call path remains an integration point to resolve when that dependency lands.
blawesom commented 2026-10-19 07:42:40 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by blawesom on 2026-10-19T07:42:40Z.


Rebase handoff — rebased onto current main (authorship unchanged). Conflicts resolved: the CMake registration in main's single-line form, the test includes unioned, and main's helper forms kept where both sides had evolved the same helpers.

Verified on Linux (CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release, BUILD_TESTING=ON, AMD RX 9070 XT / RADV): builds; the entry-stub tests pass; conventions pass; full suite green apart from the four known main regressions (#5444 Mesa, #7584 BDA, #7766, #7784), none from this PR.

To pick it up:

git fetch https://github.com/blawesom/AnyPS5 rebase/7594
git checkout <your branch>
git merge --ff-only FETCH_HEAD

Head is 86a6d668c.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6262241527 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7594#issuecomment-6262241527). Originally posted by [blawesom](https://github.com/blawesom) on 2026-10-19T07:42:40Z. --- **Rebase handoff** — rebased onto current `main` (authorship unchanged). Conflicts resolved: the CMake registration in `main`'s single-line form, the test includes unioned, and `main`'s helper forms kept where both sides had evolved the same helpers. Verified on Linux (CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release, `BUILD_TESTING=ON`, AMD RX 9070 XT / RADV): builds; the entry-stub tests pass; conventions pass; **full suite green apart from the four known `main` regressions** (#5444 Mesa, #7584 BDA, #7766, #7784), none from this PR. **To pick it up:** ``` git fetch https://github.com/blawesom/AnyPS5 rebase/7594 git checkout <your branch> git merge --ff-only FETCH_HEAD ``` Head is `86a6d668c`.
oneandonlydean commented 2026-10-19 08:22:13 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-19T08:22:13Z.


Thanks for the rebase, @blawesom. The production changes carry over line for line, and keeping main's single-line CMake registration is right.

One thing got lost in the conflict resolution: the Windows test windowsStubInitializesMxcsrBeforeGuestEntry() in core/relinker/elfpatcher/tests/EntryStubTests.cpp (and its call in main(), after windowsStubRejectsAnOverlongAllocatorPath();) isn't in 86a6d668c. Only its WindowsImportBuilder.hpp include survived. Without it, the WindowsEntryStubBuilder.cpp change has no test. We restored it verbatim on top of your rebase: entry_stub passes, and with main's WindowsEntryStubBuilder.cpp it fails with "the Windows stub does not initialize MXCSR immediately before guest entry", so it still catches the regression it was written for.

Also, the pick-up steps won't work as written: 86a6d668c isn't a descendant of the PR head eae903496, so git merge --ff-only FETCH_HEAD will refuse. Either of these works:

# (a) take the rebase (after restoring the test)
git fetch https://github.com/blawesom/AnyPS5 rebase/7594
git reset --hard FETCH_HEAD
git push --force-with-lease

# (b) or keep history and merge main into the PR branch
git fetch origin main
git merge origin/main

cc @MarcZX10: whichever route you prefer, please keep the Windows test. Merge order is unchanged: #7532 first, then this PR's combined Linux entry path gets re-checked.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6262895834 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7594#issuecomment-6262895834). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-19T08:22:13Z. --- Thanks for the rebase, @blawesom. The production changes carry over line for line, and keeping `main`'s single-line CMake registration is right. One thing got lost in the conflict resolution: the Windows test `windowsStubInitializesMxcsrBeforeGuestEntry()` in `core/relinker/elfpatcher/tests/EntryStubTests.cpp` (and its call in `main()`, after `windowsStubRejectsAnOverlongAllocatorPath();`) isn't in `86a6d668c`. Only its `WindowsImportBuilder.hpp` include survived. Without it, the `WindowsEntryStubBuilder.cpp` change has no test. We restored it verbatim on top of your rebase: `entry_stub` passes, and with `main`'s `WindowsEntryStubBuilder.cpp` it fails with "the Windows stub does not initialize MXCSR immediately before guest entry", so it still catches the regression it was written for. Also, the pick-up steps won't work as written: `86a6d668c` isn't a descendant of the PR head `eae903496`, so `git merge --ff-only FETCH_HEAD` will refuse. Either of these works: ``` # (a) take the rebase (after restoring the test) git fetch https://github.com/blawesom/AnyPS5 rebase/7594 git reset --hard FETCH_HEAD git push --force-with-lease # (b) or keep history and merge main into the PR branch git fetch origin main git merge origin/main ``` cc @MarcZX10: whichever route you prefer, please keep the Windows test. Merge order is unchanged: #7532 first, then this PR's combined Linux entry path gets re-checked.
MarcZX10 commented 2026-10-19 16:00:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-19T16:00:03Z.


Thanks for the rebase review. I checked the current PR head 9ebc1073381bed08382b368f8926438984781fab: it contains windowsStubInitializesMxcsrBeforeGuestEntry() and calls it from main() immediately after windowsStubRejectsAnOverlongAllocatorPath(), so the Windows regression test is present. The hosted relinker matrix and conventions checks on this head are green; Linux/Windows full Build jobs are skipped by the workflow.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6271490773 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7594#issuecomment-6271490773). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-19T16:00:03Z. --- Thanks for the rebase review. I checked the current PR head `9ebc1073381bed08382b368f8926438984781fab`: it contains `windowsStubInitializesMxcsrBeforeGuestEntry()` and calls it from `main()` immediately after `windowsStubRejectsAnOverlongAllocatorPath()`, so the Windows regression test is present. The hosted relinker matrix and conventions checks on this head are green; Linux/Windows full Build jobs are skipped by the workflow.
DProkos commented 2026-10-19 19:11:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by DProkos on 2026-10-19T19:11:57Z.


Windows re-check of the rebased head 9ebc10733 merged onto current main (585075cb7, clean merge).

Windows 11 Pro 26200, WinLibs GCC 15.2.0 r7 UCRT, Ninja, Release, ANYPS5_RELINKER_ONLY=ON, BUILD_TESTING=ON, Python 3.11.0.

  • entry_stub: passed.
  • Full relinker suite: 212/212 passed.

Negative control, Windows part only: with only WindowsEntryStubBuilder.cpp restored to main, entry_stub fails with the Windows stub does not initialize MXCSR immediately before guest entry. So the restored windowsStubInitializesMxcsrBeforeGuestEntry() runs and catches the Windows change on its own.

Not run: titles or homebrew.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6275159393 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7594#issuecomment-6275159393). Originally posted by [DProkos](https://github.com/DProkos) on 2026-10-19T19:11:57Z. --- Windows re-check of the rebased head 9ebc10733 merged onto current `main` (`585075cb7`, clean merge). Windows 11 Pro 26200, WinLibs GCC 15.2.0 r7 UCRT, Ninja, Release, `ANYPS5_RELINKER_ONLY=ON`, `BUILD_TESTING=ON`, Python 3.11.0. - `entry_stub`: passed. - Full relinker suite: 212/212 passed. **Negative control, Windows part only:** with only `WindowsEntryStubBuilder.cpp` restored to `main`, `entry_stub` fails with `the Windows stub does not initialize MXCSR immediately before guest entry`. So the restored `windowsStubInitializesMxcsrBeforeGuestEntry()` runs and catches the Windows change on its own. Not run: titles or homebrew. AI-assisted: yes
MarcZX10 commented 2026-10-19 20:27:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-19T20:27:06Z.


Thanks for the Windows re-check and negative control. The full relinker suite passes 212/212 on the rebased head, and restoring the Windows stub to main makes the new focused assertion fail as expected. That confirms the regression test detects the Windows entry-stub change. I’ll keep the validation claim scoped to the relinker tests; no title or homebrew run was made.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6276587554 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7594#issuecomment-6276587554). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-19T20:27:06Z. --- Thanks for the Windows re-check and negative control. The full relinker suite passes 212/212 on the rebased head, and restoring the Windows stub to main makes the new focused assertion fail as expected. That confirms the regression test detects the Windows entry-stub change. I’ll keep the validation claim scoped to the relinker tests; no title or homebrew run was made.
screamm commented 2026-10-20 14:05:04 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by screamm on 2026-10-20T14:05:04Z.


Windows title-level check of 9ebc10733, stacked with #7622 (50c1efcf5) on main 1d4164552 (clean merge; also merges cleanly onto d50ec76da).

Windows 11 Pro 26220, NVIDIA GeForce RTX 4070 (driver 596.21), Ryzen 7 5700X, WinLibs MinGW-w64 GCC 15.2.0 r7, Ninja, Release, BUILD_TESTING=ON. Built relinker, the relinker tests and libs (not the full all target).

Tests

  • entry_stub and linux_entry_argv: 3/3 each.
  • Relinker suite (the 154 tests registered under core/relinker, serial): one serial pass, 152/154. The other 2 (tls_function_coverage_register_address_loads, windows_diagnostic_fixture_isolation) hit their hard 30 s limit on my loaded host and pass when run directly (14.2 s and 2.9 s). I did not finish a 3x repeat of the whole suite.
  • Negative control: with only WindowsEntryStubBuilder.cpp from main, entry_stub fails with the Windows stub does not initialize MXCSR immediately before guest entry. With both stub builders from main it fails with the stub does not initialize MXCSR before guest entry. With the PR files back: 3/3 pass.

Relink of my local titles (--windows, main relinker vs this PR): 50 relink on both sides, PPSA99360 fails identically (Base relocation target crosses a page boundary). All 50 app.exe differ. All *.registry.json, *.needed.json and guest .prx outputs are byte-identical. The relinker is deterministic: same sha256 over repeated runs. For PPSA99005 the diff is the PE checksum, four displacement bytes and one run starting at the new ldmxcsr sequence, which occurs exactly once.

MXCSR in running titles. I read CONTEXT.MxCsr from every thread with GetThreadContext at 15 s and 40 s:

Title main: guest main thread PR: guest main thread PR: threads with FTZ+DAZ
PPSA99005 Showcase 0x1fa3 0x9fe1 1 of 53
PPSA28319 Ping Pong 0x1fa3 0x9fe1 1 of 107
PPSA99169 RetroArch launcher (15 s) 0x1fa0 0x9fe0 3 of 7 (main + 2 guest pthreads at 0x9fc0)
PPSA99169 picker child (40 s, 6 runs each) 0x1fa3 0x1fa3 0

So on Windows the guest main thread does run with FTZ/DAZ (0x9fc0 plus sticky flags), and on Showcase and Ping Pong no other thread does. The RetroArch picker resets MXCSR itself after entry, even though its relinked exe has the new stub. A byte scan finds ldmxcsr encodings in picker.bin and none in the Showcase or Ping Pong eboots. I did not trace which code does it.

Titles, 60 s each, main vs PR (same harness, display on):

  • PPSA99005 Showcase: running at 60 s on both, 189 vs 252 frames (load-bound).
  • PPSA99010 vkQuake: exit 0 on both with QUAKE ERROR: W_LoadWadFile: couldn't load gfx.wad (missing data).
  • PPSA28319 Ping Pong: running at 60 s on both, 2840 vs 2758 frames.
  • PPSA99169 RetroArch, 6 interleaved runs each: the PR side ran to 60 s every time (2220, 3140, 4425, 4824, 5230, 3919 frames). Main ran to 60 s four times (4271, 5348, 4302, 5153) and twice exited at about 49 s after the picker logged FAILED after 18.24 s / 14.68 s: Fatal : VkResult is ERROR_DEVICE_LOST. That picker device loss also shows up in older main-only runs I have, and 2 of 6 vs 0 of 6 is not significant (p ≈ 0.45). So I am not counting it for or against this PR.

There is no FAIL:, FATAL:, not implemented or what() line in any run. Frame dumps are not time-aligned, so they cannot show a float difference: 2 of 12 Ping Pong dump pairs are bit-identical and the rest differ by animation phase.

check_conventions.py --base origin/main passes and git diff --check is clean.

Not checked: Linux and the composed #7532 entry path, macOS, the full test suite and GPU tests, and the MXCSR value at the exact entry instruction (I sampled at 15 s and 40 s).

Written with Claude Code assistance (validation by a subagent, reviewed in this session).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6292738827 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7594#issuecomment-6292738827). Originally posted by [screamm](https://github.com/screamm) on 2026-10-20T14:05:04Z. --- Windows title-level check of `9ebc10733`, stacked with #7622 (`50c1efcf5`) on `main` `1d4164552` (clean merge; also merges cleanly onto `d50ec76da`). Windows 11 Pro 26220, NVIDIA GeForce RTX 4070 (driver 596.21), Ryzen 7 5700X, WinLibs MinGW-w64 GCC 15.2.0 r7, Ninja, Release, `BUILD_TESTING=ON`. Built `relinker`, the relinker tests and `libs` (not the full `all` target). **Tests** - `entry_stub` and `linux_entry_argv`: 3/3 each. - Relinker suite (the 154 tests registered under `core/relinker`, serial): one serial pass, 152/154. The other 2 (`tls_function_coverage_register_address_loads`, `windows_diagnostic_fixture_isolation`) hit their hard 30 s limit on my loaded host and pass when run directly (14.2 s and 2.9 s). I did not finish a 3x repeat of the whole suite. - Negative control: with only `WindowsEntryStubBuilder.cpp` from `main`, `entry_stub` fails with `the Windows stub does not initialize MXCSR immediately before guest entry`. With both stub builders from `main` it fails with `the stub does not initialize MXCSR before guest entry`. With the PR files back: 3/3 pass. **Relink of my local titles** (`--windows`, main relinker vs this PR): 50 relink on both sides, PPSA99360 fails identically (`Base relocation target crosses a page boundary`). All 50 `app.exe` differ. All `*.registry.json`, `*.needed.json` and guest `.prx` outputs are byte-identical. The relinker is deterministic: same sha256 over repeated runs. For PPSA99005 the diff is the PE checksum, four displacement bytes and one run starting at the new `ldmxcsr` sequence, which occurs exactly once. **MXCSR in running titles.** I read `CONTEXT.MxCsr` from every thread with `GetThreadContext` at 15 s and 40 s: | Title | main: guest main thread | PR: guest main thread | PR: threads with FTZ+DAZ | |---|---|---|---| | PPSA99005 Showcase | `0x1fa3` | `0x9fe1` | 1 of 53 | | PPSA28319 Ping Pong | `0x1fa3` | `0x9fe1` | 1 of 107 | | PPSA99169 RetroArch launcher (15 s) | `0x1fa0` | `0x9fe0` | 3 of 7 (main + 2 guest pthreads at `0x9fc0`) | | PPSA99169 picker child (40 s, 6 runs each) | `0x1fa3` | `0x1fa3` | 0 | So on Windows the guest main thread does run with FTZ/DAZ (`0x9fc0` plus sticky flags), and on Showcase and Ping Pong no other thread does. The RetroArch picker resets MXCSR itself after entry, even though its relinked exe has the new stub. A byte scan finds `ldmxcsr` encodings in `picker.bin` and none in the Showcase or Ping Pong eboots. I did not trace which code does it. **Titles, 60 s each, main vs PR** (same harness, display on): - PPSA99005 Showcase: running at 60 s on both, 189 vs 252 frames (load-bound). - PPSA99010 vkQuake: exit 0 on both with `QUAKE ERROR: W_LoadWadFile: couldn't load gfx.wad` (missing data). - PPSA28319 Ping Pong: running at 60 s on both, 2840 vs 2758 frames. - PPSA99169 RetroArch, 6 interleaved runs each: the PR side ran to 60 s every time (2220, 3140, 4425, 4824, 5230, 3919 frames). Main ran to 60 s four times (4271, 5348, 4302, 5153) and twice exited at about 49 s after the picker logged `FAILED after 18.24 s` / `14.68 s: Fatal : VkResult is ERROR_DEVICE_LOST`. That picker device loss also shows up in older main-only runs I have, and 2 of 6 vs 0 of 6 is not significant (p ≈ 0.45). So I am not counting it for or against this PR. There is no `FAIL:`, `FATAL:`, `not implemented` or `what()` line in any run. Frame dumps are not time-aligned, so they cannot show a float difference: 2 of 12 Ping Pong dump pairs are bit-identical and the rest differ by animation phase. `check_conventions.py --base origin/main` passes and `git diff --check` is clean. Not checked: Linux and the composed #7532 entry path, macOS, the full test suite and GPU tests, and the MXCSR value at the exact entry instruction (I sampled at 15 s and 40 s). Written with Claude Code assistance (validation by a subagent, reviewed in this session).
MarcZX10 commented 2026-10-20 21:48:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-20T21:48:07Z.


Thanks for the detailed Windows title-level comparison. The negative controls establish the MXCSR setup difference, and the title results distinguish the entry-stub behavior from the RetroArch picker resetting MXCSR later. I’ve noted the two serial timeout cases passed directly, and that Linux, macOS and exact-entry sampling remain untested.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6302361912 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7594#issuecomment-6302361912). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-20T21:48:07Z. --- Thanks for the detailed Windows title-level comparison. The negative controls establish the MXCSR setup difference, and the title results distinguish the entry-stub behavior from the RetroArch picker resetting MXCSR later. I’ve noted the two serial timeout cases passed directly, and that Linux, macOS and exact-entry sampling remain untested.
MarcZX10 commented 2026-11-02 04:56:58 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-02T04:56:58Z.

Review: COMMENTED


Replies checked — MXCSR value matches the code, console log is external

The entry stub at this head writes MXCSR 0x9fc0 before guest entry, which is the value the reviewers' evidence points to, and the console figure they cite was not checked here.

What I ran

  • Live head 58581509c5d1cdda8164287688525e542483f465 (OPEN, unchanged from batch).
  • gh api comments and reviews on #7594, newer than 2026-10-20T21:48:07Z, excluding MarcZX10 and bots.
  • gh pr view 7594 --json statusCheckRollup.
  • git show 58581509:core/relinker/elfpatcher/src/general/EntryStubBuilder.cpp; git grep for MXCSR in the head and upstream/main.
  • git merge-tree --write-tree upstream/main 58581509 (exit 0).
  • Nothing built or run.

Results

Check Result Note
Live head matches batch OPEN
merge-tree vs upstream/main exit 0 9651 behind, 2 ahead
Hosted relinker (ubuntu, macOS, windows), relinker-asan, conventions SUCCESS windows aggregate, linux, register-context, write-watch SKIPPED

Findings

  • @Dextroid17 (2026-10-24) reports an exact-entry read: 0x1f80 from main, 0x9fc0 at guest entry on this head. Consistent with the code: the stub stores 0x9fc0 at EntryStubBuilder.cpp L26-L32 before the call, and restores the host value at L44-L48. Main has no MXCSR code in this file. Not reproduced.
  • @p3n1cillin (2026-10-26) says a PS5 title starts at 0x9fe0, which is 0x9fc0 plus the precision-exception flag (bit 5). The arithmetic is correct. The console log is an external repository and was not checked. Answer needed: confirm 0x9fc0 is the intended value, and note that this is not a PS5 measurement from this repo.
  • No reviewer asks for a code change on this head.

Sources

Not verified

  • The PS5_Vulkan hardware log (HARDWARE_FINDINGS.md) cited by p3n1cillin.
  • Dextroid17's gdb readings, the Linux negative control, and any macOS behaviour.
  • Any build or test result.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5732246679 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7594#pullrequestreview-5732246679). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-02T04:56:58Z. **Review:** COMMENTED --- # Replies checked — MXCSR value matches the code, console log is external The entry stub at this head writes MXCSR 0x9fc0 before guest entry, which is the value the reviewers' evidence points to, and the console figure they cite was not checked here. ## What I ran - Live head `58581509c5d1cdda8164287688525e542483f465` (OPEN, unchanged from batch). - `gh api` comments and reviews on #7594, newer than 2026-10-20T21:48:07Z, excluding MarcZX10 and bots. - `gh pr view 7594 --json statusCheckRollup`. - `git show 58581509:core/relinker/elfpatcher/src/general/EntryStubBuilder.cpp`; `git grep` for MXCSR in the head and upstream/main. - `git merge-tree --write-tree upstream/main 58581509` (exit 0). - Nothing built or run. ## Results | Check | Result | Note | |---|---|---| | Live head | matches batch | OPEN | | `merge-tree` vs upstream/main | exit 0 | 9651 behind, 2 ahead | | Hosted relinker (ubuntu, macOS, windows), relinker-asan, conventions | SUCCESS | `windows` aggregate, `linux`, `register-context`, `write-watch` SKIPPED | ## Findings - @Dextroid17 (2026-10-24) reports an exact-entry read: 0x1f80 from main, 0x9fc0 at guest entry on this head. Consistent with the code: the stub stores `0x9fc0` at `EntryStubBuilder.cpp` L26-L32 before the call, and restores the host value at L44-L48. Main has no MXCSR code in this file. Not reproduced. - @p3n1cillin (2026-10-26) says a PS5 title starts at 0x9fe0, which is 0x9fc0 plus the precision-exception flag (bit 5). The arithmetic is correct. The console log is an external repository and was not checked. Answer needed: confirm 0x9fc0 is the intended value, and note that this is not a PS5 measurement from this repo. - No reviewer asks for a code change on this head. ## Sources - https://github.com/boykopovar/AnyPS5/blob/58581509c5d1cdda8164287688525e542483f465/core/relinker/elfpatcher/src/general/EntryStubBuilder.cpp#L26-L32 - https://github.com/boykopovar/AnyPS5/blob/58581509c5d1cdda8164287688525e542483f465/core/relinker/elfpatcher/src/general/EntryStubBuilder.cpp#L44-L48 ## Not verified - The PS5_Vulkan hardware log (`HARDWARE_FINDINGS.md`) cited by p3n1cillin. - Dextroid17's gdb readings, the Linux negative control, and any macOS behaviour. - Any build or test result.
Sign in to join this conversation.
No reviewers
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!7594
No description provided.