feat(ps5lift): add the runtime for lifted programs #15798

Closed
oberonlift wants to merge 3 commits from upstream-pr/15798 into main
oberonlift commented 2026-11-04 16:23:50 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oberonlift on 2026-11-04T16:23:50Z.


Merge after #15797. Until it merges, this PR also shows #15797's changes; oberonlift/AnyPS5#18 shows only this PR's own.

ps5lift is a static recompiler for PS5 executables: it lifts a game's x86-64 code to LLVM IR and compiles it ahead of time to aarch64, which runs on Linux against AnyPS5's own libraries with no interpreter or JIT. It runs AnyPS5's PS5-style test programs and a homebrew media player to its home screen; commercial games are not playable yet. Branch ps5lift-preview merges all of its PRs (how to try it); native Apple Silicon support is coming along fast. It is a separate approach from the ARM64 compiler in #5021; #1835 has an introduction.

This is 2 of 8 PRs that let AnyPS5's libraries run a lifted program; the lifter itself follows them. The runtime does not need #15797; this branch is stacked on it.

What

ps5lift's runtime is the library a lifted program links, and the one AnyPS5's libraries link when they are built for a lifted program.

  • Runtime (ps5lift/runtime): maps the guest images at their link addresses, dispatches indirect calls, lays out TLS as x86-64 does, runs x87 code on Berkeley SoftFloat, answers cpuid and xgetbv as the PS5's Zen 2, and calls native functions through guest function pointers and back.
  • For AnyPS5's libraries: 36 GuestCpu* functions, which the later PRs call under ANYPS5_GUEST_LIFTED: the guest's MXCSR and x87 state, x87 extended-precision arithmetic, the timestamp counter, cpuid and xgetbv, calls into guest code and interrupted contexts, guest stacks and fibers, unwinding, and the program's images and their symbols. State.h and Bridge.hpp are the headers lifted code and the generated import bridges build against.
  • Build: tools/ps5lift.py runtime builds it with SoftFloat, a new submodule, into a shared library for a target and CPU, and the program's main into an archive. The CPU is the one the lifted code targets, neoverse-v2 on aarch64 unless --cpu names another, so the runtime needs no feature the program doesn't; a library older than any of its objects is linked again.
  • CI: a workflow builds the runtime on GitHub's Linux arm64 runner every night, on request, and for PRs that change ps5lift/ or the workflow.
  • Technical debt: a ps5lift section lists the runtime's known bugs and gaps.

Tested

On a DGX Spark (aarch64 Linux, NVIDIA GB10, LLVM 18), tools/ps5lift.py runtime builds the runtime for aarch64-unknown-linux-gnu. The later PRs exercise it: with all eight PRs and ps5lift on top: every library builds for a lifted program, 2,288 of AnyPS5's own tests pass in that build on lavapipe, and ps5lift's 69 tests pass, among them its libc, exceptions, kernel, fiber and module-loading fixtures and upstream's libc test programs.

The conventions check passes on this branch.

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: SoftFloat
  • Generic behaviour, not specific to one title
  • Depends on: #15797
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5157732868 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15798). Originally posted by [oberonlift](https://github.com/oberonlift) on 2026-11-04T16:23:50Z. --- **Merge after #15797.** Until it merges, this PR also shows #15797's changes; oberonlift/AnyPS5#18 shows only this PR's own. **ps5lift** is a static recompiler for PS5 executables: it lifts a game's x86-64 code to LLVM IR and compiles it ahead of time to aarch64, which runs on Linux against AnyPS5's own libraries with no interpreter or JIT. It runs AnyPS5's PS5-style test programs and a homebrew media player to its home screen; commercial games are not playable yet. Branch [`ps5lift-preview`](https://github.com/oberonlift/AnyPS5/tree/ps5lift-preview) merges all of its PRs ([how to try it](https://github.com/oberonlift/AnyPS5/blob/ps5lift-preview/PS5LIFT_PREVIEW.md)); native Apple Silicon support is coming along fast. It is a separate approach from the ARM64 compiler in #5021; #1835 has an introduction. This is 2 of 8 PRs that let AnyPS5's libraries run a lifted program; the lifter itself follows them. The runtime does not need #15797; this branch is stacked on it. ### What ps5lift's runtime is the library a lifted program links, and the one AnyPS5's libraries link when they are built for a lifted program. - **Runtime** (`ps5lift/runtime`): maps the guest images at their link addresses, dispatches indirect calls, lays out TLS as x86-64 does, runs x87 code on Berkeley SoftFloat, answers `cpuid` and `xgetbv` as the PS5's Zen 2, and calls native functions through guest function pointers and back. - **For AnyPS5's libraries**: 36 `GuestCpu*` functions, which the later PRs call under `ANYPS5_GUEST_LIFTED`: the guest's MXCSR and x87 state, x87 extended-precision arithmetic, the timestamp counter, `cpuid` and `xgetbv`, calls into guest code and interrupted contexts, guest stacks and fibers, unwinding, and the program's images and their symbols. `State.h` and `Bridge.hpp` are the headers lifted code and the generated import bridges build against. - **Build**: `tools/ps5lift.py runtime` builds it with SoftFloat, a new submodule, into a shared library for a target and CPU, and the program's `main` into an archive. The CPU is the one the lifted code targets, `neoverse-v2` on aarch64 unless `--cpu` names another, so the runtime needs no feature the program doesn't; a library older than any of its objects is linked again. - **CI**: a workflow builds the runtime on GitHub's Linux arm64 runner every night, on request, and for PRs that change `ps5lift/` or the workflow. - **Technical debt**: a ps5lift section lists the runtime's known bugs and gaps. ### Tested On a DGX Spark (aarch64 Linux, NVIDIA GB10, LLVM 18), `tools/ps5lift.py runtime` builds the runtime for `aarch64-unknown-linux-gnu`. The later PRs exercise it: with all eight PRs and ps5lift on top: every library builds for a lifted program, 2,288 of AnyPS5's own tests pass in that build on lavapipe, and ps5lift's 69 tests pass, among them its libc, exceptions, kernel, fiber and module-loading fixtures and upstream's libc test programs. The conventions check passes on this branch. ### 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: SoftFloat - [x] Generic behaviour, not specific to one title - [x] Depends on: #15797 - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)

Pull request closed

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!15798
No description provided.