Repository navigation
feat(libkernel_sys): implement scePthreadMutexIsowned, utrace and tcsetsid - #9713
Conversation
Progress report (a4eca2a → 73cebee)📈 System libraries: 26.04% (+0.0082%, +3 implemented functions) ✅ 3 implemented
⚪ 1 behaviourally empty (constant return or throw)
Changed libraries (implemented exports)
|
|
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
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.
|
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed exact head 085590d. The implementations are narrowly scoped and the checked behaviors line up with the cited FreeBSD 11.4 sources: the mutex ownership query returns a boolean-style result, switch hooks return ENOTSUP, and tcsetsid validates the session before issuing TIOCSCTTY. The tests cover owner/non-owner and destroyed-mutex cases, errno precedence, and utrace argument sizes. Current conventions and diff checks pass; merge is clean. I could not independently run guest_kernel_sys because there is no configured build here and the filesystem is full. The PR’s Linux/ASan run and Windows/macOS status are author-reported; hosted product CI is skipped. Please refresh this 13-commits-behind branch to current main and rerun the focused suite on that base before approval. No code-level defect found in this review.
|
I reviewed this head alongside open #9582, which removes the throwing |
There was a problem hiding this comment.
I reviewed exact head 085590d.
Checks run locally:
- C++20 syntax-only compilation passed for the exact-head libkernel_sys/Export.cpp and GuestKernelSys.cpp using current-main shared headers.
- git diff --check passed.
- tools/check_conventions.py passed against current main.
- Hosted eligibility, intake, conventions, labels and report checks pass; hosted Linux/Windows and other product jobs are skipped. The Linux/ASan 7/7 runtime suite in the PR description is author-reported and was not independently rerun here because there is no configured build tree.
The mutex ownership query, unsupported switch hooks, and untraced utrace behavior are consistent with the cited FreeBSD 11.4 implementations, subject to the PS5 KTRACE assumption already documented in the debt note. I found no major functional defect.
One small fidelity detail: FreeBSD 11.4 tcsetsid calls ioctl(fd, TIOCSCTTY, NULL), while this implementation passes a pointer to a local zero integer. AnyPS5 currently returns ENOTTY for guest file descriptors either way, so this does not change the covered result, but forwarding nullptr would match the cited libc behavior.
Before merge, update the branch to current main and rerun the focused suite. This head is 63 commits behind current main; CONTRIBUTING.md requires branches to stay up to date. The main commits since its base do not touch the four changed paths, but the sync and post-sync validation remain outstanding.
|
I’ve noticed that asking you to hold this PR was unnecessary. It’s fine to keep submitting PRs; maintainers will handle them in due course. |
|
Windows run of 085590d merged onto current Environment: Windows 11 Home 10.0.26200, WinLibs MinGW-w64 GCC 15.2.0 r7 (UCRT), Ninja, Release, Focused suite (
Baseline: with Full suite: 1886 of 1894 pass. The 8 failures are AGC tests that fail on this machine's AMD GPU on The branch itself still needs the rebase the review asks for. This only shows that the change holds on Windows on top of current AI-assisted: yes |
085590d to
c45fd94
Compare
|
@MarcZX10 thanks. Rebased on
Linux run of c45fd94 (Ubuntu 24.04 x86-64 container under Rosetta on Apple silicon, GCC 13, RelWithDebInfo with ASan): the full build has no errors in AnyPS5 code; the only failure is the On overlap: the rebased head merges into main cleanly, but it conflicts with #8890 and #9582 (and adjacent removals in #9195, #9242, #9326) in AI-assisted: yes |
c45fd94 to
44fa8ea
Compare
|
#8890 merged right after the push above, so I rebased again: 44fa8ea on Linux run of 44fa8ea, same container and configuration as above: no build errors in AnyPS5 code (only the known AI-assisted: yes |
44fa8ea to
dbb29c0
Compare
|
Rebased again for the Linux run of dbb29c0, same container and configuration as above: no build errors in AnyPS5 code (only the known AI-assisted: yes |
dbb29c0 to
9c49cb2
Compare
Dismissing a stale review: the requested changes were addressed after it (new head) and the merge queue blocks on it. Please request changes again if anything is still open.
|
Integration note from the re-reviewed #11402: its current head adds pointer-validation assertions in GuestKernelSys.cpp within CheckSettimeofday, while this PR adds the separate ThreadAndSessionTests helper and call. The author proposes #11402 first; if rebasing after it lands, please retain both changes. I found no behavioral overlap in those test additions. |
|
@simonbronk Thanks. This now conflicts with |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@oneandonlydean merged
Linux run of 8d0d8c6, same container and configuration as before: the full build has no errors (exit 0), and 46 focused tests pass, AI-assisted: yes |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Merged Linux run of eea3c72, same container and configuration as before: 48 focused tests pass, AI-assisted: yes |
|
@simonbronk #13695 adds a branch for |
# Conflicts: # core/libs/prx/libkernel/Socket/src/Udp.cpp
What
Implements 3 libkernel_sys exports that were discovery stubs:
scePthreadMutexIsownedreturns 0 when libkernel's existingpthread_mutex_isowned_npreturns 0, and0x80020000plus its result (0x80020001) when the calling thread owns the mutex. That is what firmware 13.42'slibkernel_sys.sprxdoes, as BunnyFl measured by running the export in an emulator. An uninitialized or destroyed mutex, or one another thread owns, gets 0.utracereturns 0 without reading its record.sys_utracedoes that for a process ktrace does not trace, and nothing traces the guest.tcsetsid(fd, pid)fails withEINVALunlesspidisgetsid(0), then issuesTIOCSCTTYwith a null argument through the guestioctl, as libc'stermios.cdoes and as BunnyFl confirmed in firmware 13.42's module. No guest descriptor is a terminal, so an open descriptor getsENOTTYand a closed oneEBADF.The guest socket
ioctlreturnedEFAULTfor any null argument before looking at the request, which would maketcsetsidon a socket fail withEFAULT. As in FreeBSD'ssys_ioctl, which copies nothing for a void request without a parameter length,Udp.cppnow faults on a null argument only for a request with input or a length; the existing socket checks inguest_kernel_fcntlkeep theirEFAULT.The implementations are in
libkernel_sys/Export.cpp, next to the other implemented exports, and their stubs are removed fromExport.Discovery.cpp. Thepthread_switch_add_np/pthread_switch_delete_nppart of this PR was dropped when it was rebased, since #9172 already returnsENOTSUPfrom both. The debt entry records what was measured and the assumption that the PS5 kernel hasKTRACE(without itutracewould returnENOSYS).Tested
Linux, Ubuntu 24.04 x86-64 container under Rosetta on Apple silicon (Colima), GCC 13, RelWithDebInfo with ASan, head eea3c72 (
maind820fef merged in).guest_kernel_sysgets new checks:scePthreadMutexIsownedbefore init, after init, while locked (0x80020001from the owner, 0 from another thread), after unlock and after destroy;utracewith a record, with an empty one and with 4096 bytes (errno untouched);tcsetsidwith a wrong session (EINVAL, checked before the descriptor), on an open file and on a UDP socket (ENOTTY) and on -1 (EBADF).The full build fails only in
libSceAddressSanitizer, which this PR does not touch: in an ASan build its declarations clash with GCC's__asan_*built-ins, the same onmaind820fef, and #12894 stops building it under ASan. Every test target below was then built explicitly (exit 0). 48 focused tests pass with no ASan reports: theguest_kernel_sys*tests,guest_pthread_mutex_errors,guest_pthread_mutexattr,guest_pthread_barrier,guest_getlogin,guest_getlogin_no_session,guest_np_session_signaling,guest_net_socket_state,guest_kernel_fcntl,guest_kernel_fcntl_sync,guest_udp,guest_sendfileand theguest_socket_*tests. Windows: Dom3005 ran an earlier head onmain11f976b (focused suite passes). macOS not run.check_conventions.py --base origin/mainpasses.pr_overlap.pyreports no PR with the same exports; its only conflicting lines are with #11219, which edits the socketioctlnext to theUdp.cppline changed here; orezraey will keep both if this lands first. No title tested.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