Skip to content

feat(libkernel): read and set the GS base through sysarch - #7095

Merged
oneandonlydean merged 2 commits into
boykopovar:mainfrom
milescoviello:feat/sysarch-gsbase
Oct 17, 2026
Merged

oneandonlydean merged 2 commits into
boykopovar:mainfrom
milescoviello:feat/sysarch-gsbase

Conversation

@milescoviello

Copy link
Copy Markdown
Contributor

What

#6028 exports sysarch as a throwing declaration so modules that import it load. Forever Launcher's Wine (PPSA99030) now calls it: amd64_set_gsbase (sysarch(AMD64_SET_GSBASE, &base)) to point GS at its TEB. This PR implements the three operations that are safe here, following FreeBSD 11's amd64 sysarch, on Linux x86-64 hosts through the host's arch_prctl:

  • AMD64_SET_GSBASE (131) sets the calling thread's GS base. A base at or above 0x800000000000 (VM_MAXUSER_ADDRESS) returns EINVAL, and a null argument returns EFAULT. Nothing on the host side uses GS on Linux x86-64.
  • AMD64_GET_GSBASE (130) and AMD64_GET_FSBASE (128) copy the base out, with the same EFAULT.
  • Still throws:
    • AMD64_SET_FSBASE: guest and host code share the thread's FS base for their TLS.
    • The other operations.
    • Any operation on other hosts (Windows keeps its TEB in GS).

The implementation moves from Unimplemented.cpp to System/src/Process.cpp, and docs/dev/debt/libkernel.md gets an entry.

Tested

Ubuntu 24.04, GCC 13.3, Release, on #6028's head fb0f83d.

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: fix(libkernel): export sysarch so modules that import it load #6028 (this branch is stacked on it; its first commit is fix(libkernel): export sysarch so modules that import it load #6028's)
  • Fixes: none
  • Unblocks: PPSA99030 (Forever Launcher), with the PRs listed under Tested; no bring-up discussion exists yet
  • GPUs tested: n/a
  • AI-assisted: yes (Claude Code)

🤖 Generated with Claude Code

@github-actions

github-actions Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Progress report (3e83446 → d7c83db)

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

🆕 1 declared as stubs
Library Name
libkernel sysarch

@github-actions

github-actions Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

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 4630 docs/dev/debt/libkernel.md
PR 4972 core/libs/prx/libkernel/CMakeLists.txt
PR 5021 core/libs/prx/libkernel/CMakeLists.txt
core/libs/prx/libkernel/System/src/Process.cpp
docs/dev/debt/libkernel.md
PR 6044 core/libs/prx/libkernel/CMakeLists.txt
PR 6222 core/libs/prx/libkernel/CMakeLists.txt
core/libs/prx/libkernel/System/src/Process.cpp
docs/dev/debt/libkernel.md
PR 6287 core/libs/prx/libkernel/CMakeLists.txt
PR 6447 core/libs/prx/libkernel/System/src/Process.cpp
PR 6510 docs/dev/debt/libkernel.md
PR 6710 docs/dev/debt/libkernel.md
PR 6836 docs/dev/debt/libkernel.md
PR 6908 core/libs/prx/libkernel/CMakeLists.txt
docs/dev/debt/libkernel.md
PR 6942 core/libs/prx/libkernel/CMakeLists.txt
PR 6962 docs/dev/debt/libkernel.md
PR 7049 docs/dev/debt/libkernel.md
PR 7075 docs/dev/debt/libkernel.md
PR 7088 docs/dev/debt/libkernel.md
PR 7121 docs/dev/debt/libkernel.md
PR 7129 core/libs/prx/libkernel/CMakeLists.txt
docs/dev/debt/libkernel.md
PR 7135 docs/dev/debt/libkernel.md
PR 7139 docs/dev/debt/libkernel.md
PR 7201 core/libs/prx/libkernel/CMakeLists.txt
core/libs/prx/libkernel/System/src/Process.cpp
PR 7248 docs/dev/debt/libkernel.md

milescoviello and others added 2 commits October 17, 2026 20:43
The Wine port (PPSA99995) ships an ntdll module that imports sysarch
(b7uXQmnfB2s). libkernel did not export it, so loading stopped with
"undefined symbol: b7uXQmnfB2s" before the title ran.

Export sysarch as a stub that reports that it is not implemented: the
title loads and runs its launcher without calling it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sysarch's AMD64_GET_FSBASE, AMD64_GET_GSBASE and AMD64_SET_GSBASE now
follow FreeBSD 11's amd64 sysarch on Linux x86-64 through arch_prctl: the
GS base is the calling thread's, a base at or above VM_MAXUSER_ADDRESS
returns EINVAL and a null argument EFAULT. AMD64_SET_FSBASE, whose base
guest and host code share for their TLS, other operations and other hosts
still throw. Wine sets its TEB this way.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@oneandonlydean
oneandonlydean merged commit fbb76ae into boykopovar:main Oct 17, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants