feat(libkernel_sys): finish sched_setscheduler and sigreturn #10838
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/10838"
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 EagleBearerYS on 2026-10-25T03:54:54Z.
What
Finishes two libkernel_sys calls:
sched_setschedulerfollows FreeBSD 11'ssys_sched_setscheduler:EFAULT,ESRCHfor another process,EINVALfor an unknown policy. Pid 0 sets the calling thread throughscePthreadSetschedparam.sigreturnapplies FreeBSD 11's amd64sys_sigreturnandset_fpcontextchecks and restores the context through the pathsetcontextuses.Values the console's answer is unknown for still throw: a scheduler policy
scePthreadSetschedparamrejects, the first thread by pid, a non-user%cs, an extended FPU state. The debt file has an entry for each.chown,lchownandfchownatkeepmain's owner check, following the review of #8457 (comment, comment): the guest is modelled as root, and FreeBSD's root keeps the privilege to change a file's owner, so another owner or group still throws after the path lookup until a console measurement showsEPERM.Related: #9187 (
sched_getparam,sched_getscheduler,sched_setparam) and #9389 (sigqueue) each touch the line next to one this PR changes, so whichever merges second needs a one-line merge. #8457 and #10434 have merged, and this branch merges them.Tested
guest_kernel_sys,guest_user_context,guest_user_context_exit,guest_sched_priority,guest_semaphoreandguest_pthread_sempass 10 runs in a row, 6 run, 6 pass, 0 skip, 0 fail on Linux and on Windows. The libc and libkernel suites pass on both (143 and 206 tests on Linux, 170 and 222 on Windows), run withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.guest_kernel_sys,guest_user_context,guest_user_context_exit,guest_sched_priority,guest_semaphoreandguest_pthread_sempass 10 of 10 on Linux and on Windows, 0 skipped. Main's implementation doesn't build against the new tests, because main declaressigreturnwithout parameters. The libc and libkernel suites pass on both.No title tested.
main9a2020c220. The only conflict wasdocs/dev/debt/libkernel_sys.md, where #10434 (Retr0G28,linkat) rewrote thelinkatentry next to this PR'schownentry; the merge keeps both, and the PR's own added and removed lines are unchanged. On GitHub's runners (run),guest_kernel_sys,guest_user_context,guest_user_context_exit,guest_sched_priority,guest_semaphoreandguest_pthread_sempass 10 runs in a row, 6 run, 6 pass, 0 skip, 0 fail on Linux and on Windows;main's code doesn't build against the new tests. The libc and libkernel suites pass on both (144 and 207 tests on Linux, 171 and 223 on Windows), run withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.main4e43321bd6and the owner-check change (run). The merge (e5e06128e7) keeps both sides: #11186 extends the module-info debt entry next to this PR's two new entries; #8457 callsRequireGuestOwnerfromfchown, so that helper stays; and #9379's swapcontext keepsAps5SwapcontextFinishin theextern "C"block besidesetcontext, which this PR moves after itsRestoreContexthelper. 8daa84f8cc then putschown,lchownandfchownatback onRequireGuestOwner, so their owner path ismain's again; theEPERMassertions are gone, with no throw assertions in their place, and the lookup error checks stay.guest_kernel_sys,guest_kernel_sys_swapcontext,guest_user_context,guest_user_context_exit,guest_sched_priority,guest_semaphoreandguest_pthread_sempass 10 runs in a row; withmain's implementation the test file doesn't build, asmaindeclaressched_setschedulerwith no parameters. Linux: 7 run, 7 pass, 0 skip, 0 fail. Windows: 7 run, 7 pass, 0 skip, 0 fail. Suites: libc and libkernel pass on Linux (145 and 210), and libc passes on Windows (172). Windows' libkernel suite runs 231 tests and failsguest_timed_join_import_libkernel_sysandguest_timed_join_import_libkernel_web, which this PR doesn't touch;main88f99678bffails the same two in this verify's Windows job (run). The suites ran withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.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)kenv, adjacent lines incore/libs/tests/GuestKernelSys.cpp): this PR first, then #11032 rebases onto itImported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T04:05:11Z.
Review: DISMISSED
The Linux/Windows verification run is green (10/10 on each runner), and the chown and scheduler paths appear consistent with the cited FreeBSD behavior. I found one blocking gap in the new
sigreturnrestore path.FreeBSD 11.4
sys_sigreturncopies the saved machine context into the trapframe and then restoresmc_fsbaseandmc_gsbase(machdep.c, lines 3149-3155). Here,SigreturnContext_nid_no_patchreachesRestoreContext, whoseRegisterFramecontains neither bases nor the saved segment selectors;Aps5ContextRestore_nid_no_patchpushes the current%cs/%ss. As a result, a context with differentfsbase,gsbase, or another RPL-3 code selector returns successfully while silently restoring the current host state instead. The debt text currently says those bases are restored as FreeBSD would.Please route these values through a safe guest-context mechanism, or explicitly reject unsupported non-current values with
NotImplemented_nid_no_patchuntil they can be represented. Add a regression that changes the bases and a valid-but-different user%csso a successful return cannot silently discard them. The reference is FreeBSD 11.4sys_sigreturn.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T04:54:48Z.
Review: COMMENTED
Review note on exact-head verification for the new
sigreturnpath.