feat(libkernel): run threads for a lifted guest #15803
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/15803"
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 oberonlift on 2026-11-04T16:24:04Z.
Merge after #15802. Until the PRs before it merge, this PR also shows their changes; oberonlift/AnyPS5#13 shows only its 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-previewmerges 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 7 of 8 PRs that let AnyPS5's libraries run a lifted program; the lifter itself follows them.
x86-64: behaviour unchanged. Thread objects stay on the host heap; the stack size arithmetic shared with lifted builds computes the same values.
What
GuestCpu, and a lifted thread entry, which the bridge already turned into a native thunk, is called directly. The x86 assembly forsigsetjmp,siglongjmp,getcontextand their kin is left out of lifted builds, where the runtime provides the jumps and context switching reports itself as not implemented.GuestCpuUseStackand reported byscePthreadAttrGet; the host stack is the sizeGuestCpuHostStackSizegives. The thread takes its guest stack and the console's x87 control word before it unblocks signals, so a signal raised at a new or suspended thread runs its handler on that guest stack.DoMprotectreports the pages each protection change makes writable toGuestCpuMakingWritable_nid_no_patch. ps5lift loads from read-only segments without ordering, and its runtime stops the program when such pages overlap one. AMAP_FIXEDmapping over such a segment is not reported yet.GuestCpuCallInterruptedand sees the guest registers thatGuestCpuInterruptedContextreports; the signal-delivery assembly is left out of lifted builds.sceKernelWaitOnAddressreads a misaligned value with a plain copy followed by an acquire fence instead of x86'smov.EnterGuestMainStackcalls the guest entry on the stack the runtime gave the main thread, instead of switching to a main stack at the console's address.MAP_FIXEDgap, the host stack that the main and adopted threads report, and the zerofpstate,csandssan exception handler reads.#5021 also changes some of the same files:
Thread.cpp,Pthread.hpp,Exception.cpp,SignalSets.cpp,DirectMemory.cpp.Tested
Compiled for x86-64 Linux before and after this PR (GCC 13, same flags): 158 of the 162 objects it reaches are byte-identical;
Thread.cppdiffers inscePthreadCreate's register allocation and a line-number constant, andException.cpp,SyncOnAddress.cppandUserContext.cpponly in line-number constants.On a DGX Spark (aarch64 Linux, NVIDIA GB10, LLVM 18), with all eight PRs and ps5lift on top: every library builds for a lifted program, 2,285 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
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)🤖 Generated with Claude Code
Pull request closed