fix(libkernel): export sysarch so modules that import it load #6028

Merged
milescoviello merged 1 commit from upstream-pr/6028 into main 2026-10-17 22:18:17 +00:00
milescoviello commented 2026-10-14 19:38:32 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-14T19:38:32Z.


What

The Wine port (PPSA99995, prospero-win) does not start on main:

./app.elf: symbol lookup error: .../app0/win/wine/lib/wine/x86_64-unix/ntdll.prx.guest.prx: undefined symbol: b7uXQmnfB2s

Update (10-15): since #5559 (merged 11:38), Linux and macOS defer a runtime-only module such as ntdll until a module that needs it is used. On main 940eba9a2 the title starts on Linux without this PR: its launcher, with an empty game library, does not load ntdll in a 40 s run (LD_DEBUG=files), so the error above no longer appears there. #5559 keeps eager loading on Windows, so there the load should still stop at this import (not checked here). On Linux, the import would only be resolved once ntdll is loaded, which my runs don't reach.

b7uXQmnfB2s is sysarch (tools/nid_names.py --nid b7uXQmnfB2s), the FreeBSD call that gets and sets the FS and GS bases. Its ntdll module imports it, and libkernel does not export it, so loading stops before the title runs.

libkernel now exports sysarch as a stub that reports that it is not implemented, next to the other unimplemented exports in Unimplemented.cpp. With it the title loads and runs its launcher, and it does not call sysarch in a 125 s run. An implementation would have to set the GS base through arch_prctl on Linux and could not on Windows or macOS, where the host owns that register, so that waits for a title that calls it.

guest_sysarch checks that the call reports sysarch not implemented. Without the export it does not link.

Tested

Ubuntu 24.04, GCC 13.3 (CI's compiler), Release with CI's configure flags, on main 9f03c4fe0, then rebased onto main 358e218a4:

  • All 376 guest_* tests pass, guest_sysarch included.
  • PPSA99995 (catalog release), relinked with --to-intel and run on Linux for 40 s; the builds differ only in libkernel.prx:
    • main: exits with 127 at 0 s on the error above.
    • This PR: runs the 40 s. Its own session log (/data/prospero-win/logs/session-0.log) records the keyboard and mouse modules opening, the data mount, an empty game library and the launcher's state (launcher video=state pad=ok hid=ok frame=1 apps=0).
  • tools/check_conventions.py --base upstream/main passes, and tools/pr_overlap.py --branch finds no overlap.

@screamm checked it on Windows (RTX 4070, WinLibs GCC 15.2.0), alone and stacked with #6102 and #6135 on main 5d9dcc42d. Windows still binds ntdll's imports at load. With #6102 and #6135 but without this PR, Prospero Win (PPSA99995) exits within 1 to 3 s on FAIL: unresolved ELF import b7uXQmnfB2s from libkernel.prx, 2 of 2. With all three, 2 of 2 runs reach the 125 s limit at its launcher's library screen, with no stop line. guest_sysarch passes 3 of 3 and fails both negative controls. Of 1,093 relinked import registries from 51 titles, only PPSA99995 imports sysarch.

Not checked on a console.

Follow-up (10-17): #7095 builds on this PR and implements the GS base operations (AMD64_SET_GSBASE, AMD64_GET_GSBASE, AMD64_GET_FSBASE), because Forever Launcher's Wine (PPSA99030) now calls sysarch(AMD64_SET_GSBASE, ...) for its TEB. This PR stays the declaration that lets the modules load.

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
  • Unblocks: Prospero Win (PPSA99995) on Windows, with #6102 and #6135
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4863464369 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6028). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-10-14T19:38:32Z. --- ### What The Wine port (PPSA99995, `prospero-win`) does not start on `main`: ``` ./app.elf: symbol lookup error: .../app0/win/wine/lib/wine/x86_64-unix/ntdll.prx.guest.prx: undefined symbol: b7uXQmnfB2s ``` **Update (10-15):** since #5559 (merged 11:38), Linux and macOS defer a runtime-only module such as `ntdll` until a module that needs it is used. On `main` 940eba9a2 the title starts on Linux without this PR: its launcher, with an empty game library, does not load `ntdll` in a 40 s run (`LD_DEBUG=files`), so the error above no longer appears there. #5559 keeps eager loading on Windows, so there the load should still stop at this import (not checked here). On Linux, the import would only be resolved once `ntdll` is loaded, which my runs don't reach. `b7uXQmnfB2s` is `sysarch` (`tools/nid_names.py --nid b7uXQmnfB2s`), the FreeBSD call that gets and sets the FS and GS bases. Its `ntdll` module imports it, and libkernel does not export it, so loading stops before the title runs. libkernel now exports `sysarch` as a stub that reports that it is not implemented, next to the other unimplemented exports in `Unimplemented.cpp`. With it the title loads and runs its launcher, and it does not call `sysarch` in a 125 s run. An implementation would have to set the GS base through `arch_prctl` on Linux and could not on Windows or macOS, where the host owns that register, so that waits for a title that calls it. `guest_sysarch` checks that the call reports `sysarch not implemented`. Without the export it does not link. ### Tested Ubuntu 24.04, GCC 13.3 (CI's compiler), Release with CI's configure flags, on `main` 9f03c4fe0, then rebased onto `main` 358e218a4: - All 376 `guest_*` tests pass, `guest_sysarch` included. - PPSA99995 (catalog release), relinked with `--to-intel` and run on Linux for 40 s; the builds differ only in `libkernel.prx`: - `main`: exits with 127 at 0 s on the error above. - This PR: runs the 40 s. Its own session log (`/data/prospero-win/logs/session-0.log`) records the keyboard and mouse modules opening, the data mount, an empty game library and the launcher's state (`launcher video=state pad=ok hid=ok frame=1 apps=0`). - `tools/check_conventions.py --base upstream/main` passes, and `tools/pr_overlap.py --branch` finds no overlap. @screamm [checked it on Windows](https://github.com/boykopovar/AnyPS5/pull/6028#issuecomment-6211311309) (RTX 4070, WinLibs GCC 15.2.0), alone and stacked with #6102 and #6135 on `main` 5d9dcc42d. Windows still binds `ntdll`'s imports at load. With #6102 and #6135 but without this PR, Prospero Win (PPSA99995) exits within 1 to 3 s on `FAIL: unresolved ELF import b7uXQmnfB2s from libkernel.prx`, 2 of 2. With all three, 2 of 2 runs reach the 125 s limit at its launcher's library screen, with no stop line. `guest_sysarch` passes 3 of 3 and fails both negative controls. Of 1,093 relinked import registries from 51 titles, only PPSA99995 imports `sysarch`. Not checked on a console. **Follow-up (10-17):** #7095 builds on this PR and implements the GS base operations (`AMD64_SET_GSBASE`, `AMD64_GET_GSBASE`, `AMD64_GET_FSBASE`), because Forever Launcher's Wine (PPSA99030) now calls `sysarch(AMD64_SET_GSBASE, ...)` for its TEB. This PR stays the declaration that lets the modules load. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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] Unblocks: Prospero Win (PPSA99995) on Windows, with #6102 and #6135 - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
github-actions[bot] commented 2026-10-14 19:39:19 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-14T19:39:19Z.


Progress report (90fcd20 → 162f4af)

📉 System libraries: 89.62% (-0.03%, +1 declared functions)

🆕 1 declared as stubs
Library Name
libkernel sysarch
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6176772243 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6028#issuecomment-6176772243). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-14T19:39:19Z. --- <!-- progress-report --> ### Progress report (90fcd20 → 162f4af) 📉 **System libraries**: 89.62% (-0.03%, +1 declared functions) <details> <summary>🆕 1 declared as stubs</summary> | Library | Name | | - | - | | libkernel | `sysarch` | </details>
github-actions[bot] commented 2026-10-15 12:13:37 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T12:13:37Z.


Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 6915 core/libs/prx/libkernel/Unimplemented.cpp L12

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 4972 core/libs/prx/libkernel/CMakeLists.txt
PR 5021 core/libs/prx/libkernel/CMakeLists.txt
PR 6044 core/libs/prx/libkernel/CMakeLists.txt
PR 6222 core/libs/prx/libkernel/CMakeLists.txt
PR 6287 core/libs/prx/libkernel/CMakeLists.txt
PR 6414 core/libs/prx/libkernel/Unimplemented.cpp
PR 6908 core/libs/prx/libkernel/CMakeLists.txt
PR 6942 core/libs/prx/libkernel/CMakeLists.txt
PR 7129 core/libs/prx/libkernel/CMakeLists.txt
PR 7201 core/libs/prx/libkernel/CMakeLists.txt
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6191775224 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6028#issuecomment-6191775224). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-15T12:13:37Z. --- <!-- pr-overlap --> Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in **Depends on**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | [PR 6915](https://www.github.com/boykopovar/AnyPS5/pull/6915) | `core/libs/prx/libkernel/Unimplemented.cpp` [L12](https://github.com/boykopovar/AnyPS5/blob/084bd39a085cf5a85a1dea19163184ba74ac1905/core/libs/prx/libkernel/Unimplemented.cpp#L12) | | | Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap. | Pull request | Shared files not compared | |---|---| | [PR 4972](https://www.github.com/boykopovar/AnyPS5/pull/4972) | `core/libs/prx/libkernel/CMakeLists.txt` | | [PR 5021](https://www.github.com/boykopovar/AnyPS5/pull/5021) | `core/libs/prx/libkernel/CMakeLists.txt` | | [PR 6044](https://www.github.com/boykopovar/AnyPS5/pull/6044) | `core/libs/prx/libkernel/CMakeLists.txt` | | [PR 6222](https://www.github.com/boykopovar/AnyPS5/pull/6222) | `core/libs/prx/libkernel/CMakeLists.txt` | | [PR 6287](https://www.github.com/boykopovar/AnyPS5/pull/6287) | `core/libs/prx/libkernel/CMakeLists.txt` | | [PR 6414](https://www.github.com/boykopovar/AnyPS5/pull/6414) | `core/libs/prx/libkernel/Unimplemented.cpp` | | [PR 6908](https://www.github.com/boykopovar/AnyPS5/pull/6908) | `core/libs/prx/libkernel/CMakeLists.txt` | | [PR 6942](https://www.github.com/boykopovar/AnyPS5/pull/6942) | `core/libs/prx/libkernel/CMakeLists.txt` | | [PR 7129](https://www.github.com/boykopovar/AnyPS5/pull/7129) | `core/libs/prx/libkernel/CMakeLists.txt` | | [PR 7201](https://www.github.com/boykopovar/AnyPS5/pull/7201) | `core/libs/prx/libkernel/CMakeLists.txt` |
screamm commented 2026-10-16 08:24:11 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by screamm on 2026-10-16T08:24:11Z.


Cross-validation on Windows of head fb0f83ddf, alone and stacked with #6102 (f1735f59f) and #6135 (10bc2f05a), on main 5d9dcc42d. My earlier run of this PR was at 183782ddc (posted in #6135); fb0f83ddf is the same commit rebased (git range-diff shows patch and message unchanged).

Windows 11 Pro 26220, Ryzen 7 5700X, NVIDIA RTX 4070 (596.21), WinLibs MinGW-w64 GCC 15.2.0 r7, Ninja, Release.

  • Merges: clean alone and in the order #6028 -> #6102 -> #6135. Full build with -k 0 on the stack: only agc_driver_gpu_indirect_arguments_misaligned_writer_ahead_tests fails (the 64 KiB alignas that also fails on main, #6452/#6478); libs builds; no warnings in the changed files.
  • guest_sysarch, --repeat until-fail:3: 3 of 3.
  • Negative controls: with Unimplemented.cpp as on main the test does not link (undefined reference to 'sysarch'); with only the NotImplemented_nid_no_patch call removed it fails with sysarch returned instead of reporting that it is not implemented.
  • Exports of the built libs: libkernel.prx 1646 -> 1647 (only b7uXQmnfB2s added), 62614 -> 62615 in total. Of 1093 relinked import registries of 51 local titles, only PPSA99995 imports b7uXQmnfB2s (ntdll.prx and wow64native.prx).
  • Non-GPU suite on the stack (-j8 --timeout 120 -E '^agc_driver_|^video_out_flip'): 837 of 840 pass, 2 skipped, hardware_oracle_compare timed out under load and passes alone (11.2 s).
  • tools/check_conventions.py --base origin/main and git diff --check: pass.

Prospero Win (PPSA99995), --trap-sdk-syscall-stubs --module-dir win/wine/lib/wine/x86_64-unix, display on, 125 s limit. This answers the "not checked on Windows" point: Windows still binds ntdll's imports at load.

  • main, and main + this PR alone: conversion stops at FAIL: Unsupported Windows guest TLS instruction (bytes: 65 48 8b 0c 25 78 03 00 00) (offset 0x3214c) (that is #6102's part).
  • #6102 + #6135 without this PR, 2 runs: exit 0xC0000139 after 1-3 s, 0 frames:
    FAIL: unresolved ELF import b7uXQmnfB2s from libkernel.prx
    FAIL: unresolved ELF import b7uXQmnfB2s from libkernel.prx
    FAIL: unresolved ELF import b7uXQmnfB2s from libkernel.prx
    GetLastError: 127 - The specified procedure could not be found.
    
  • #6102 + this PR (without #6135), 2 runs: the b7uXQmnfB2s lines are gone; only the four libSceVideoOut.prx cursor imports remain.
  • All three, 2 runs: still running at 125 s, 104 and 119 frames (about 1 FPS), no stop line and no not implemented. The window shows the launcher's library screen ("NO APPLICATION PROFILES FOUND"), and session-0.log has launcher video=ok pad=ok hid=ok frame=1 apps=0. So the launcher does not call sysarch in that time.

Suggestion: "Unblocks: none" could become "PPSA99995 on Windows, with #6102 and #6135", since that is where the stop line moves.

Not checked: Linux, a console, any program run inside Prospero Win.

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

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6211311309 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6028#issuecomment-6211311309). Originally posted by [screamm](https://github.com/screamm) on 2026-10-16T08:24:11Z. --- Cross-validation on Windows of head `fb0f83ddf`, alone and stacked with #6102 (`f1735f59f`) and #6135 (`10bc2f05a`), on main `5d9dcc42d`. My earlier run of this PR was at `183782ddc` (posted in #6135); `fb0f83ddf` is the same commit rebased (`git range-diff` shows patch and message unchanged). Windows 11 Pro 26220, Ryzen 7 5700X, NVIDIA RTX 4070 (596.21), WinLibs MinGW-w64 GCC 15.2.0 r7, Ninja, Release. - Merges: clean alone and in the order #6028 -> #6102 -> #6135. Full build with `-k 0` on the stack: only `agc_driver_gpu_indirect_arguments_misaligned_writer_ahead_tests` fails (the 64 KiB `alignas` that also fails on `main`, #6452/#6478); `libs` builds; no warnings in the changed files. - `guest_sysarch`, `--repeat until-fail:3`: 3 of 3. - Negative controls: with `Unimplemented.cpp` as on `main` the test does not link (`undefined reference to 'sysarch'`); with only the `NotImplemented_nid_no_patch` call removed it fails with `sysarch returned instead of reporting that it is not implemented`. - Exports of the built `libs`: `libkernel.prx` 1646 -> 1647 (only `b7uXQmnfB2s` added), 62614 -> 62615 in total. Of 1093 relinked import registries of 51 local titles, only PPSA99995 imports `b7uXQmnfB2s` (`ntdll.prx` and `wow64native.prx`). - Non-GPU suite on the stack (`-j8 --timeout 120 -E '^agc_driver_|^video_out_flip'`): 837 of 840 pass, 2 skipped, `hardware_oracle_compare` timed out under load and passes alone (11.2 s). - `tools/check_conventions.py --base origin/main` and `git diff --check`: pass. **Prospero Win (PPSA99995)**, `--trap-sdk-syscall-stubs --module-dir win/wine/lib/wine/x86_64-unix`, display on, 125 s limit. This answers the "not checked on Windows" point: Windows still binds `ntdll`'s imports at load. - `main`, and `main` + this PR alone: conversion stops at `FAIL: Unsupported Windows guest TLS instruction (bytes: 65 48 8b 0c 25 78 03 00 00) (offset 0x3214c)` (that is #6102's part). - #6102 + #6135 without this PR, 2 runs: exit `0xC0000139` after 1-3 s, 0 frames: ``` FAIL: unresolved ELF import b7uXQmnfB2s from libkernel.prx FAIL: unresolved ELF import b7uXQmnfB2s from libkernel.prx FAIL: unresolved ELF import b7uXQmnfB2s from libkernel.prx GetLastError: 127 - The specified procedure could not be found. ``` - #6102 + this PR (without #6135), 2 runs: the `b7uXQmnfB2s` lines are gone; only the four `libSceVideoOut.prx` cursor imports remain. - All three, 2 runs: still running at 125 s, 104 and 119 frames (about 1 FPS), no stop line and no `not implemented`. The window shows the launcher's library screen ("NO APPLICATION PROFILES FOUND"), and `session-0.log` has `launcher video=ok pad=ok hid=ok frame=1 apps=0`. So the launcher does not call `sysarch` in that time. Suggestion: "Unblocks: none" could become "PPSA99995 on Windows, with #6102 and #6135", since that is where the stop line moves. Not checked: Linux, a console, any program run inside Prospero Win. Written with Claude Code assistance (validation by a subagent, reviewed in this session).
milescoviello commented 2026-10-16 08:29:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-16T08:29:53Z.


Thanks @screamm, that answers the Windows question properly. Your results are in the description, and "Unblocks" now names Prospero Win on Windows with #6102 and #6135.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6211411656 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6028#issuecomment-6211411656). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-10-16T08:29:53Z. --- Thanks @screamm, that answers the Windows question properly. Your results are in the description, and "Unblocks" now names Prospero Win on Windows with #6102 and #6135. AI-assisted: yes
oneandonlydean commented 2026-10-17 22:19:21 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-17T22:19:21Z.


@adriadam10 FYI: this landed through #7095, which carried this PR's commit fb0f83ddf, so GitHub now shows it as merged. I've added myself as co-assignee for the follow-up; you're still on it as before.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6242115102 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6028#issuecomment-6242115102). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-17T22:19:21Z. --- @adriadam10 FYI: this landed through #7095, which carried this PR's commit fb0f83ddf, so GitHub now shows it as merged. I've added myself as co-assignee for the follow-up; you're still on it as before.
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!6028
No description provided.