Repository navigation
feat(libkernel): deliver guest signals on Linux and keep signal masks per thread - #1
Open
Zaid-Talib wants to merge 2455 commits into
Open
Zaid-Talib wants to merge 2455 commits into
Zaid-Talib wants to merge 2455 commits into
Conversation
Zaid-Talib
force-pushed
the
claude/focused-turing-ivfmjn
branch
3 times, most recently
from
October 8, 2026 15:21
24f89cf to
7714301
Compare
Progress report (311c049 → c356112)📈 System libraries: 85.6% (+0.48%, +321 implemented, +143 declared, -1 reverted, -45 removed functions) ✅ 321 implemented
🆕 143 declared as stubs
|
| Library | Name |
|---|---|
| libSceHttp | sceHttpWaitRequest |
🗑️ 45 removed
| Library | Name |
|---|---|
| libSceAgc | sceAgcAcb_gQkqkLttcpw |
| libSceAgc | sceAgcCreateInterpolantMapping |
| libSceAgc | sceAgcCreateInterpolantMappingVsPs |
| libSceAgc | sceAgcDcbContextStateAnotherOp |
| libSceAgc | sceAgcGetDataPacketPayloadAddressUnk |
| libSceAgc | sceAgcUnknownFuseShaderHalves |
| libSceAgc | sceAgcUnknownGetFusedShaderSize |
| libSceAgc | sceAgcUnknownInitState |
| libSceAgc | sceAgcUnknown_7Wa3aeJgeVU |
| libSceAgc | sceAgcUnknown_Ikfdt_MrIqCE |
| libSceAgc | sceAgcUnknown__MKRzWekV120 |
| libSceAgc | sceAgcUnknown_rP5xLdOf26k |
| libSceAjm.native | sceAjmWVorbisUnknown00 |
| libSceAjm.native | sceAjmWVorbisUnknown01 |
| libSceAppContent | sceAppContentUnknown00 |
| libSceJson2 | sceJson2Unknown00 |
| libSceNpPartner001 | sceNpPartnerUnknown_7CxI50_MxlCk |
| libSceNpPartner001 | sceNpPartnerUnknown_pMxXhNozUX8 |
| libScePsml_debug | scePsmlMfsr2Unknown_0GAw7SmkwII |
| libScePsml_debug | scePsmlMfsr2Unknown_1ic5q_MkdOsc |
| libScePsml_debug | scePsmlMfsr2Unknown_5z2gBlqxJ_P0 |
| libScePsml_debug | scePsmlMfsr2Unknown_Kyy1baXgaVU |
| libScePsml_debug | scePsmlMfsr2Unknown_ZLL31lzzxr4 |
| libScePsml_debug | scePsmlMfsr2Unknown_gMduXCLYrNg |
| libScePsml_debug | scePsmlMfsr2Unknown_lrJwpLjKXRc |
| libScePsml_debug | scePsmlMfsr2Unknown_m9JLPc3wOQw |
| libScePsml_debug | scePsmlMfsr2Unknown_o_PNM86gEwFE |
| libSceVideoOut | sceVideoOutUnknown00 |
| libSceVideoOut | sceVideoOutUnknown01 |
| libc | LibcHeapErrorReportForGame_nid_postfix |
| libc | libcCyberUnknown03 |
| libc | libcCyberUnknown05 |
| libc | libcCyberUnknown07 |
| libc | libcCyberUnknown09 |
| libc | libcCyberUnknown10 |
| libc | libcCyberUnknown11 |
| libc | libcCyberUnknown12 |
| libc | libcCyberUnknown13 |
| libc | libcCyberUnknown14 |
| libc | libcCyberUnknown16 |
| libc | libcCyberUnknown18 |
| libc | libcCyberUnknown19 |
| libc | libcUnknown_u2tMGOLaqnE |
| libc | sceLibcUnknown_BnMAMrsfVWo |
| libkernel | sceCoredumpUnknown01 |
🔗 1 now sharing sources
| Library | Name |
|---|---|
| libScePsml | libScePsml_debug |
📈 GPU shader instructions: 100.0% (+3.0%, +35 implemented instructions)
✅ 35 implemented
| Encoding | Name |
|---|---|
| DS | DS_CONDXCHG32_RTN_B64 |
| DS | DS_GWS_BARRIER |
| DS | DS_GWS_INIT |
| DS | DS_GWS_SEMA_BR |
| DS | DS_GWS_SEMA_P |
| DS | DS_GWS_SEMA_RELEASE_ALL |
| DS | DS_GWS_SEMA_V |
| DS | DS_ORDERED_COUNT |
| MIMG | IMAGE_GATHER4H_PCK |
| MIMG | IMAGE_GATHER8H_PCK |
| MIMG | IMAGE_LOAD_BY2 |
| MIMG | IMAGE_LOAD_BY4 |
| MIMG | IMAGE_LOAD_MIP_BY2 |
| MIMG | IMAGE_LOAD_MIP_BY4 |
| MIMG | IMAGE_LOAD_MIP_PCK2 |
| MIMG | IMAGE_LOAD_MIP_PCK4 |
| MIMG | IMAGE_LOAD_PCK2 |
| MIMG | IMAGE_LOAD_PCK4 |
| MIMG | IMAGE_STORE_BY2 |
| MIMG | IMAGE_STORE_BY4 |
| MIMG | IMAGE_STORE_MIP_BY2 |
| MIMG | IMAGE_STORE_MIP_BY4 |
| MIMG | IMAGE_STORE_MIP_PCK2 |
| MIMG | IMAGE_STORE_MIP_PCK4 |
| MIMG | IMAGE_STORE_PCK2 |
| MIMG | IMAGE_STORE_PCK4 |
| SOP1 | S_RFE_B64 |
| SOP1 | S_SWAPPC_B64 |
| SOPK | S_CALL_B64 |
| SOPP | S_CODE_END |
| SOPP | S_SENDMSGHALT |
| SOPP | S_SETHALT |
| VOP3 | V_INTERP_P1LL_F16 |
| VOP3 | V_INTERP_P1LV_F16 |
| VOP3 | V_INTERP_P2_F16 |
…round family (cherry picked from commit a56de63)
The original fix predates llroundf, which was added in boykopovar#2933. Use the same guest range and exception behavior for the fourth wrapper and include it in the edge-case checks.
…a16-float feat(agc): present 16-bit float display buffers
…sse2 perf(agc): store write-back changes sixteen bytes at a time
…Int64Atomics Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…tex-fetch-aliasing fix(shader): preserve aliased embedded fetch attributes
fix(shader): convert f16 bits to f32 without UnpackHalf2x16
…s-programs feat(agc): accept graphics programs without an AGC shader header
feat(libSceVideoOut): accept VRR peg and unpeg on a fixed-rate output
…ad-set-name-np feat(libkernel): implement pthread_set_name_np
…odule-lifetime fix(agc): keep a shader library part's modules until the part is destroyed
…ad-kill feat(libkernel): implement pthread_kill
…ir-read-only-3049 fix(libkernel): remove read-only directories with rmdir on Windows
…ector-io fix(libkernel): route vector I/O on guest sockets
Add standard quiet NaN generators nanf (DZU+K1wozGI) and nan (zck+6bVj5pA) to libc. Resolves startup failure in VLC for PS5 (PPSA85300) where execution halts at nanf on Linux once strsep is available.
…lared-binding fix(relinker): bind Linux guest imports by declared module identity
…-short fix(libc): keep EINVAL from strerror_r for an unknown error with a short buffer
…etadata perf(agc): write draw descriptors from retained CPU metadata
…-info-st-size fix(libkernel): ignore the input st_size of sceKernelGetModuleInfoFromAddr
…y-pool-stats feat(libSceNpWebApi2): implement sceNpWebApi2GetMemoryPoolStats
… third-party results Drops the stale pending-dependency note (boykopovar#553 boykopovar#683 boykopovar#684 boykopovar#685 are merged), adds the package source and the Linux, extended-gameplay, save/load and audio results reported in the thread, and replaces the cold-start note with the measured cause. The UCRT diagnostic note is removed: no report on current main. Co-Authored-By: Claude <noreply@anthropic.com>
…-denorm-flush fix(shader): flush v_ldexp_f16 denormals per the f16 denormal mode
…r-images fix(agc): typed image heaps on devices without nullDescriptor
feat(libc): implement nan and nanf
…getprogname feat(libSceLibcInternal): implement getprogname
fix(libScePad): queue input states for scePadRead
feat(libkernel): implement getppid
…connection-info fix(libSceSharePlay): export sceSharePlayGetCurrentConnectionInfoA with no Share Play session
…-2832 fix(agc): keep polling unsatisfied memory waits after diagnostics
…iteral-braces fix(progress): ignore braces in literals and comments when scanning bodies
…ad on a directory
…red-compare-nvidia fix(shader): emit unordered f32 relations as negated ordered ones
Add an optional input helper for test runs without desktop input injection. Preserve physical input and release injected buttons automatically. Validation: guest_pad tests and Python helper CLI smoke checks passed. Written with AI assistance.
…ew-compatibility docs: record DOOM homebrew integration compatibility
Map red and blue exports, write masks and constant-color blend factors together. Reject conflicting simultaneous target constants. Semantics: Mesa 26.2.2 src/amd/common/ac_formats.c ac_translate_colorswap; console equivalence remains unverified. Graphics tests passed. Written with AI assistance.
feat(pad): accept timed controller pulses from a local command file
…-errors fix(libkernel): translate scalar POSIX I/O errors
…order fix(agc): support alternate channel order in 16-bit color targets
sceKernelRaiseException threw on Linux, so a title whose garbage collector stops threads with it (Unity's PS5Util raises SIGUSR1 on each thread and reads mc_rsp from the handler's context) could not run there. The raise now sends the host SIGUSR1 to the target thread with pthread_kill. The host handler, installed on first use with SA_SIGINFO and SA_RESTART, builds the FreeBSD-layout ucontext from the interrupted registers and the FXSAVE area, calls the guest handler on the target's own stack and writes the registers back, so the handler's changes reach the interrupted code, as they do on Windows. errno is left as the handler leaves it, as libthr does. A raise on another thread takes the target's join lock with the host signal blocked and returns ESRCH once the thread has finished, so a detached thread's pthread_t is never signalled after it exits. The pthread_t is recorded when the thread is created or adopted. Handlers are now lock-free atomics, as the host handler reads them. guest_raise_exception now runs on every platform. It also checks that r13 and xmm8 reach the handler and that r12 and xmm8 written by the handler reach the interrupted code. AI-assisted: yes Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LwJx7AHrSUaMGSpEGhL1Kb
…ndler's MXCSR Two defects found in review of the Linux delivery: A raise right after scePthreadCreate reached the new thread before RunThread set currentThread, so scePthreadSelf() in the handler adopted a second handle, and could deadlock on glibc's thread lock when the signal interrupted pthread_getattr_np. The creator now blocks all signals around the std::thread construction, so the child starts with them blocked, and RunThread restores the creator's mask once the thread is registered, as libthr does. A raise in that window stays pending and is delivered just before the entry runs. A handler that set reserved MXCSR bits made rt_sigreturn fail with SIGSEGV. The MXCSR the handler leaves is now masked with the frame's MXCSR_MASK (0xffbf when it reads 0), as FreeBSD's fpusetregs does, on both platforms; Windows also keeps CONTEXT.MxCsr equal to FltSave.MxCsr. guest_raise_exception raises right after each of 50 thread creations and checks scePthreadSelf() in the handler, and its context round trip sets a reserved MXCSR bit and FZ and checks that only FZ is kept. AI-assisted: yes Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LwJx7AHrSUaMGSpEGhL1Kb
adriadam10
force-pushed
the
claude/focused-turing-ivfmjn
branch
from
October 11, 2026 09:20
7714301 to
c356112
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Guest signal delivery in libkernel on Linux, and per-thread guest signal masks on both platforms. Based on current upstream
main(311c049). Five commits; commits 2, 4 and 5 fix defects that adversarial reviews of the commit before each found and confirmed:1.
feat(libkernel): deliver sceKernelRaiseException on LinuxsceKernelRaiseExceptionthrew on Linux (NotImplemented), so a title whose garbage collector stops threads with it could not run there. Unity's PS5Util module does this: it installs a SIGUSR1 handler withsceKernelInstallExceptionHandler, raises SIGUSR1 on each thread and readsmc_rspfrom the handler's context (see the existing TechnicalDebt entry). shadPS4 records that libkernel's install is asigactionwrapper (SA_SIGINFO | SA_RESTART) and the raise apthread_kill; this follows that model.pthread_kill. The host handler builds the FreeBSD-layoutucontextthe Windows path already uses: general registers,rip,rsp,rflags,cs,ssand the 512-byte FXSAVE area. It calls the guest handler on the target's own stack and writes the registers back. Only the 416 bytes up to XMM15 are written back; the rest of the FXSAVE area holds the kernel's XSAVE frame marker, and overwriting it would make sigreturn drop the upper YMM halves.errnois left as the handler leaves it. libthr does the same:handle_signalinlib/libthr/thread/thr_sig.csaveserrnoafter the user handler.ESRCHonce the thread has finished, so a detached thread'spthread_tis never used after the thread exits.PthreadPrivaterecords thepthread_tat creation and adoption.GuestUcontextisalignas(16)like FreeBSD'smcontext_t; its layout and size do not change.2.
fix(libkernel): keep raises off unregistered threads and clamp the handler's MXCSRThree defects found by an adversarial review of commit 1, each reproduced before the fix:
scePthreadCreatereached the thread beforeRunThreadsetcurrentThread.scePthreadSelf()in the handler then adopted a second handle (1997 of 2000 immediate raises), and could deadlock on glibc's per-thread lock when the signal interruptedpthread_getattr_np(gdb backtrace in the review). The creator now blocks all signals around thestd::threadconstruction, so the child starts with them blocked.RunThreadrestores the creator's mask once the thread is registered, as libthr does.rt_sigreturnfail with SIGSEGV. The MXCSR the handler leaves is masked withMXCSR_MASK(0xffbf when it reads 0), as FreeBSD'sfpusetregsdoes. This applies on both platforms; Windows also keepsCONTEXT.MxCsrequal toFltSave.MxCsr.sceAudioOutOutput/sceAudioOutOutputs(sleepUs, since fix(audioout): keep ports without a device in real time boykopovar/AnyPS5#955) returned early when a raise interrupted it. It now sleeps the remaining time, asTimedWait::SleepNanosdoes.3.
fix(libkernel): keep guest signal masks per thread in FreeBSD's bit layoutsigprocmaskkept one process-wide mask, read only its first word, and tested signal n at bit n. FreeBSD'ssigset_tkeeps signal n at bit n − 1 (_SIG_BIT), so blocking SIGTERM blocked SIGURG instead. A signal raised while blocked was dropped, andsceKernelRaiseExceptionignored the target's mask.sigprocmaskis (it forwards to the kernel's per-thread mask). All 128 bits are kept inPthreadPrivate, a new thread starts with its creator's mask, and SIGKILL, SIGSTOP and SIGTHR cannot be blocked (SIG_CANTMASK, libthr'sSIGCANCEL).sigprocmaskreturns.raiseand the CRT dispatcher record a blocked one, a raise on another thread checks the mask while the target is suspended, andsigprocmaskdelivers what it unblocks.4.
fix(libkernel): block a signal while its handler runs and restore the mask after itfetch_or, while the target is suspended (or is the caller); a second raise finds the bit set and stays pending until the handler returns. The CRT dispatcher blocks the signal it delivers the same way.uc_sigmask. The SIGUSR1 handler's context now carries the interrupted mask, and whatever mask the handler leaves there is installed when it returns. On Linux its mapped bits go to the host frame'suc_sigmask; the CRT dispatcher restores the mask the thread had before the handler.tdsendsignaldoes. On Windows, installing SIG_IGN discards the calling thread's pending signal.abort()'s SIGABRT, which FreeBSD'sabort()unblocks first.5.
fix(libkernel): make sigprocmask atomic and redeliver a pending raise in placesigprocmaskon Linux: a SIGUSR1 delivered betweensigprocmask's store of the new mask and its host update wrote the handler's interrupted mask back over it. The call returned 0, but the change to a mapped signal was lost (about one call in 100000 under constant raises).sigprocmasknow blocks the mapped host signals while it reads, changes and stores the mask, and installs the result with onepthread_sigmask, as the console's system call is atomic.sigprocmaskon Windows: it claims SIGUSR1's bit for the same span, so a raise in that span stays pending and is delivered when the call returns.Delivernow runs the pending raise itself, as FreeBSD delivers after sigreturn: with the interrupted context the previous handler left, the mask it claims, and the handler installed at that moment.setjmp/longjmpdo not save the signal mask as FreeBSD's do.TechnicalDebt: the "throws on Linux" and "does not consult the target thread's signal mask" lines are replaced by what still differs from the console. A new entry records that a SIGINT or SIGTERM sent from outside the process can run the handler on an emulator thread. On Linux, the handler runs wherever the thread was interrupted, emulator code included. On the console, kernel objects are syscalls and libthr defers signals while a thread holds its internal locks; here a host lock held by the interrupted code stays held. Host waits and sleeps resume after the handler, and the calls Linux does not restart return
EINTRto the guest.Tested
-DBUILD_TESTING=ON, after each commit: full build, thenctestwith lavapipe andANYPS5_REQUIRE_VULKAN=1: 409 passed, 0 failed. 23 GPU tests skipped themselves because they need host subgroups wider than lavapipe's 8 lanes.guest_sce_netaborts, and it aborts the same way with this branch's files reverted tomain, so it is broken onmainitself (the IPv6 change in fix(net): provide IPv6 unspecified address object boykopovar/AnyPS5#1248 is the likely cause), not by this branch.guest_raise_exception, now registered on every platform, covers:sceKernelWaitSema, blocked on a host mutex, leaving a wait;r12,r13,xmm8and MXCSR, including a reserved MXCSR bit;scePthreadCreate, each checkingscePthreadSelf()in the handler;uc_sigmaskround-tripping, and a raise inside the handler being deferred;r12of the interrupted code after the handler returns;sigprocmaskfails 4 runs in 5);ESRCH.guest_signals(commit 3); 80/80 serial and 32/32 in parallel, each together withguest_signals(commit 4); 40/40 serial withguest_signalsand 24/24 in parallel (commit 5).guest_signalscovers:r13read, the startup signal block, the MXCSR clamp, the bit layout, the host-mask update, the unblockable-signal filter, the creator-mask copy, the mask restore after a CRT handler, the SIG_IGN discard, or theuc_sigmaskfill and write-back.x86_64-w64-mingw32-g++(GCC 13,-fsyntax-only -Wall -Wextra);Thread.cpphits the same three errors onmain, from that toolchain's older headers (SetThreadDescription,EfficiencyClass). The Windows logic was reviewed by reading only. CI runs it.Checklist
main; no other open PR implements the same functions. I checked every open PR's diff:waitCount) is also done here. Whichever lands second needs a small merge.NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
https://claude.ai/code/session_01LwJx7AHrSUaMGSpEGhL1Kb