Commit Graph
496 Commits
Author SHA1 Message Date
Dean ff9902091c Merge pull request #15219 from EagleBearerYS/fix/libkernel-setaffinity-set-sizes
fix(libkernel): take the console's 8- to 16-byte sets in pthread_setaffinity_np
2026-11-07 14:37:53 +13:00
Dean d85fad483e Merge pull request #3986 from Silverash-i8/fix/per-thread-signal-mask
fix(libkernel): keep the signal mask per thread
2026-11-07 11:23:32 +13:00
Adrià 399e7fb57e Merge pull request #14111 from slopgobblercobbler/fix/libkernel-posix-cond-null-validation
fix(libkernel): validate null pointers in pthread cond functions
2026-11-06 16:49:34 +01:00
slopgobblercobbler 405310c630 fix(libkernel): validate memory pointers and argument bounds in pthread barrier 2026-11-06 05:55:51 +01:00
Abdulrahman Elkordy 694b2b4704 fix(libkernel): keep the signal mask per thread
The blocked mask of sigprocmask, _sigprocmask, pthread_sigmask and
sigsuspend was one process-wide set, so a thread changing its mask changed
every thread's, and scePthreadCreate did not hand the creating thread's mask
to the new thread. Each guest thread now has its own blocked mask and handler
holds, and a new thread starts with its creator's mask. The pending set stays
the process-wide one, so a signal that raise leaves pending is still taken by
sigwait and sigtimedwait on any thread and delivered by the first thread that
unblocks it. A SIGALRM expiry checks the mask of the thread that armed the
timer.

Fixes #2879.

Claude-Session: https://claude.ai/code/session_012SLQbhAiexxW6TtjYToW8a
2026-11-05 15:08:08 +00:00
Dean f305293bb0 Merge pull request #15698 from javierUDP/fix/macos-exec-path-after-stack-move
fix(libkernel): keep the process start block mapped when the main stack moves
2026-11-06 01:29:35 +13:00
Dean 2238042b81 Merge pull request #15705 from oneandonlydean/rr/pr3-gpu
feat(run-report): count milestones, frames, GPU and shader diagnostics
2026-11-05 21:24:14 +13:00
Dean 5e2f04007b Merge pull request #9326 from erickerxhalli/feat/libkernel-mutex-prioceiling
feat(libkernel): implement pthread_mutex_getprioceiling and setprioceiling
2026-11-05 08:19:17 +13:00
Dean 92cdaf6337 Merge pull request #11624 from Felipebmaitan/feat/windows-guest-gs-state
feat(libkernel): maintain per-thread guest GS bases on Windows
2026-11-05 06:35:52 +13:00
javierUDP dd5ee9e4c6 fix(libkernel): keep the process start block mapped when the main stack moves
On macOS under Rosetta, Aps5StartGuest moves the main thread off the host
stack and releases the old range to the guest arena. dyld keeps its own
pointers into the process start block at the top of that range and offers
no call that redirects them, where argv and environ have one:
_NSGetExecutablePath copies the path string out of the block on every
call, so the first call after the move read unmapped memory and the
process died with KERN_PROTECTION_FAILURE. A title does not have to call
it: libxpc reaches it from xpc_connection_resume, and ShaderCacheDirectory
calls it for the shader disk cache.

Release the old stack only up to the pages that hold the block, and only
while argv still points into the stack. They are the top two pages, 8 KiB
of the 8372224-byte stack here, so a title that fixes a mapping over that
range now fails with a host region overlap; the rest is free as before.

guest_main_stack_move asked for a 64 KiB guest mapping aligned down from
a local of main, which falls inside the kept pages. It now probes the
64 KiB below them, requires the kept pages to be refused, and calls
_NSGetExecutablePath after the move, which segfaults without this change.
2026-11-04 04:22:23 -03:00
Dean Galvin 0003ec72c7 Merge rr/pr2-writer into rr/pr3-gpu 2026-11-04 20:21:16 +13:00
Dean b593093818 Merge pull request #12146 from AlexFigas/feat/libc-shared-mutex
feat(libc): implement the _Smtx shared mutex calls over libkernel's rwlocks
2026-11-04 18:34:09 +13:00
Felipebmaitan 41bbc32070 chore: refresh GS state with current main 2026-11-03 14:34:25 -03:00
JJenkx 4199ddb205 fix(libkernel): refresh adopted thread bounds when entering the main stack 2026-11-03 04:32:26 -05:00
Dean 8835460b5e Merge pull request #7532 from hugodearaujo/fix/linux-guest-main-stack
fix(linux): enter the guest entry on a main stack at the console's address
2026-11-03 21:07:51 +13:00
Yunus Shaikh bf4f7b7239 Merge main into fix/libkernel-setaffinity-set-sizes 2026-11-02 21:28:57 -08:00
Dean a03cc0dde6 Merge pull request #14885 from oneandonlydean/carry-7135
fix(libkernel): follow kern_cpuset for the base cpuset, level checks and interrupt targets
2026-11-03 18:14:20 +13:00
Dean Galvin df788026b6 fix(libkernel): refuse cpuset sizes the console rejects and record the EPERM difference
cpuset_getaffinity and cpuset_setaffinity return ERANGE from 24 bytes, as a PS5 payload process did (rooklz sweep, #7135 comment 6391606624: 8 to 16 accepted, below 8 and from 24 up ERANGE), and throw for the unmeasured 17 to 23, as pthread_getaffinity_np does. The tests that used 32 bytes use 16 and pin 7, 24, 32 and 64 to ERANGE. The setter entry records that the console answers EPERM for a CPU outside the process's set where this clips and returns 0.
2026-11-03 15:15:35 +13:00
Dean Galvin cc73f16c59 fix(libkernel): answer CPU_LEVEL_ROOT and test the cpuset sizes the console accepts
cpuset_getaffinity at CPU_LEVEL_ROOT returns 0xffff, as a PS5 payload process read it (rooklz, #7135 comment 6390891591), instead of throwing; the target is checked as at the other levels. The level 2 base-set test now passes 8 and 16 bytes, which the console accepts (it returns ERANGE from 24 bytes), instead of depending on the 32 bytes it rejects. The debt entry records the root measurement and that the title root set is unmeasured.
2026-11-03 15:11:23 +13:00
Dean Galvin 2d8e93e6b4 Merge commit '88bb16c20e757658078b3efce912c96b1b03502a' into HEAD
# Conflicts:
#	core/libs/prx/libkernel_sys/Export.Discovery.cpp
#	core/libs/prx/libkernel_sys/include/Api.hpp
2026-11-03 11:45:12 +13:00
Yunus Shaikh 85a860abe0 fix(libkernel): take the console's 8- to 16-byte sets in pthread_setaffinity_np
The setter accepted only FreeBSD's 32-byte cpuset_t. On a PS5 it takes 8 and 16 bytes and returns ERANGE for 0, 1, 4, 32, 64 and 128, and cpuset_setaffinity, which FreeBSD's libthr setter calls, takes 8 to 16 and returns ERANGE below 8 and from 24. It now follows that rule, as pthread_getaffinity_np does: 17 to 23 bytes throw as unmeasured, and bytes past the first 8 must be zero (EINVAL otherwise), as kern_cpuset_setaffinity requires.
2026-11-02 12:20:18 -08:00
Dean e35691b9a0 Merge pull request #14402 from roboterspinne/fix/libkernel-thread-description-utf8
fix(libkernel): convert guest thread names from UTF-8 for the Windows thread description
2026-11-03 08:49:38 +13:00
Alexandre Figueiredo 7542cc18c8 Merge upstream main into feat/libc-shared-mutex 2026-11-02 19:46:24 +00:00
Dean b0c4915518 Merge pull request #14039 from EagleBearerYS/fix/kernel-getaffinity-console-sizes
fix(libkernel): follow the console's set sizes in pthread_getaffinity_np
2026-11-03 08:45:45 +13:00
Dean b052a9307b Merge pull request #12005 from akkadbakkad89/exception-drain-mailbox
fix(libkernel): post guest raises to the delivery drain mailbox on Windows
2026-11-03 01:29:04 +13:00
Dean eeb3dfea52 Merge pull request #11849 from AlexFigas/fix/libkernel-guest-thread-x87-control-word
fix(libkernel): start guest threads with the x87 control word 0x037f
2026-11-03 01:27:12 +13:00
Dean 947ebf3d2c Merge pull request #10817 from MarcZX10/marc/fix-thread-join-detach-released
fix(libkernel): return ESRCH from join, detach and cancel of a released thread handle
2026-11-02 23:24:36 +13:00
Dean 0ba2a2a124 Merge pull request #10810 from MarcZX10/marc/fix-thread-detached-race
fix(libkernel): read and write the detached state of a guest thread atomically
2026-11-02 23:24:31 +13:00
Dean 4b1076c483 Merge pull request #8477 from ycarogabriel-lgtm/codex/macos-host-fault-signals
fix(libkernel): keep host fault signals available on macOS
2026-11-02 20:56:46 +13:00
Dean 042c5fa5ce Merge pull request #12925 from KernelPanicNT/feat/libkernel-condattr-getclock-null-output
feat(libkernel): throw for a null pthread_condattr_getclock output
2026-11-02 20:55:04 +13:00
Alexandre Figueiredo b9bd78e26d Merge upstream main into feat/libc-shared-mutex 2026-11-01 23:10:45 +00:00
erickerxhalli cdcea60a80 Merge remote-tracking branch 'upstream/main' into feat/libkernel-mutex-prioceiling
# Conflicts:
#	core/libs/prx/libkernel/Pthread/include/Pthread.hpp
#	docs/dev/debt/libkernel.md
2026-11-01 20:07:02 +00:00
Dean GalvinandAlexej Szpevák f82fb8a9c9 fix(libkernel): carry cpuset base-set and level handling
Carry #7135 by @AlexOfTheForest. Preserve current checked guest-memory copies and unrelated debt; remove the ten newly added unsupported-call throw assertions while retaining implemented success and error coverage.

Co-authored-by: Alexej Szpevák <[email protected]>
2026-11-02 08:21:01 +13:00
Ycaro Gabriel adefe80eea chore(merge): sync host fault signals with upstream main
Update the host-fault signal change to current main while preserving the Windows pending-exception delivery path and macOS unblocked fault signals.
2026-11-01 14:10:11 -03:00
slopgobblercobbler caaddb4b9d fix(libkernel): validate null pointers in pthread cond functions 2026-11-01 15:14:08 +01:00
roboterspinne fd1ec93315 fix(libkernel): convert guest thread names from UTF-8 for the Windows thread description 2026-11-01 11:40:34 +01:00
Dean Galvin 09690aaa78 Merge commit 'd5ec8e6575be37f4340ded9c64c51b1d07076b51' into HEAD
# Conflicts:
#	core/libs/prx/libkernel/System/src/Process.cpp
#	core/libs/tests/write_watch/CMakeLists.txt
#	docs/dev/debt/libkernel.md
2026-11-01 23:40:31 +13:00
Dean Galvin e4fb5da8c1 Merge main into rr/pr3-gpu 2026-11-01 22:52:42 +13:00
Dean Galvin 0e3bb2c125 Merge rr/pr2-writer into rr/pr3-gpu
# Conflicts:
#	core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
#	core/shader/recompiler/Recompiler.cpp
#	docs/dev/debt/libc.md
2026-11-01 22:52:36 +13:00
Yunus Shaikh 711f3a69f1 Merge main into fix/kernel-getaffinity-console-sizes
The conflict with #13908 in docs/dev/debt/libkernel.md keeps both sides: this branch's pthread_getaffinity_np entry, followed by #13908's sentence on the EFAULT fallback for a mask pointer that cannot be read or written.
2026-11-01 01:01:07 -08:00
Adrià 6c0bdd2014 Merge pull request #13908 from DeveshB-1/fix/cpuset-affinity-efault
fix(libkernel): return EFAULT from cpuset and pthread affinity for invalid memory
2026-11-01 09:55:39 +01:00
Dean Galvin c4629cbbe0 Merge main into feat/libkernel-condattr-getclock-null-output
# Conflicts:
#	docs/dev/debt/libkernel.md
#	docs/dev/debt/libkernel_sys.md
2026-11-01 21:13:14 +13:00
akkadbakkad89andDevin 7ff3b7091b fix(libkernel): post guest raises to the delivery drain mailbox on Windows
Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-11-01 13:23:10 +05:30
DeveshB-1 51bd568169 fix(libkernel): return EFAULT from cpuset and pthread affinity for invalid memory 2026-11-01 08:18:41 +01:00
GruzzberryandClaude Sonnet 5.5 5ba892d391 fix(libkernel): fail rtprio_thread, sched_setscheduler and setpriority with the jail privilege errors
A title is jailed (agreed on #11216). FreeBSD 11.4 prison_priv_check denies
PRIV_SCHED_RTPRIO, PRIV_SCHED_SET and PRIV_SCHED_SETPRIORITY to a jailed caller.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-11-01 07:56:25 +01:00
Dean Galvin fd4f6c74d9 feat(run-report): count milestones, frames, GPU and shader diagnostics
The run report now records how far a run got (loaded, started, first draw,
first present), the frames presented and the average frame rate, the selected
GPU, the number of shaders compiled, failed and served from the cache, the
instructions the shader recompiler could not translate, the guest image
formats looked up or rejected, and the descriptor kinds that shaders bind.
The counters are relaxed atomics and are only touched while a report is being
collected. The window system's request to quit is recorded as the reason a run
ended.
2026-11-01 17:15:09 +13:00
Adrià 97ca8c8751 Merge pull request #13832 from zaryabzip/fix/pthread-cond-signalto-esrch
fix(libkernel): return ESRCH from signalto for a handle that is not a thread
2026-11-01 04:28:11 +01:00
Adrià cac9da41e4 Merge pull request #13725 from cocoa55/fix/cond-relock-spin
fix(libkernel): spin and yield when a condition variable wait relocks its mutex
2026-10-31 22:20:43 +01:00
Yunus Shaikh 6093634622 fix(libkernel): follow the console's set sizes in pthread_getaffinity_np
rooklz measured on a PS5 that pthread_getaffinity_np accepts any set of 8 to
16 bytes, zero-fills it past byte 8, and returns ERANGE below 8 bytes and from
24 up. Sets of 17 to 23 bytes are not measured and still throw.
2026-10-31 15:58:18 +00:00
Adrià e23eea90e2 Merge pull request #13660 from w4rc0n/fix/sched-own-pid-main-thread
fix(libkernel): select the registered main thread for own-pid scheduling
2026-10-31 12:45:48 +01:00