feat(libkernel_sys): implement sceKernelTitleWorkaroundIsEnabled and sceKernelGetProcessType #9040
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/9040"
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 YossiYad on 2026-10-21T10:35:28Z.
What
Two libkernel_sys calls threw. They now follow shadPS4's kernel.cpp:
sceKernelTitleWorkaroundIsEnabled(workaround, bit, enabled)reads bitbitof the{s32 version, s32 align, u64 ids[2]}block a title gets fromsceKernelGetAppInfoand writes 0 or 1. A null block or output isEFAULT, and a bit of 0x3A or more isEINVAL(shadPS4 notes that this limit moves between firmwares). shadPS4 compares the bit signed, so a negative bit indexes beforeids; here the compare is unsigned and a negative bit isEINVALtoo.sceKernelGetProcessType(pid)returns 0 (big application) for the title's own pid, -1 and 0, andESRCHfor any other pid, using the same pid thatsceKernelGetAppInfochecks.The misspelled
sceKernelTitleWorkdaroundIsEnabledexport (NIDGST42pfUfMc) is left throwing: shadPS4 registers only1yca4VvfcNA. Neither result is measured on a PS5; the debt entries say so.Tested
Linux (Fedora 44, GCC, Ninja,
-DBUILD_TESTING=ON), based onmain2abfb1beb4:guest_kernel_sys(core/libs/tests/GuestKernelSys.cpp) gainsCheckProcessQueries: null block and null output, bits 0x3A, 63 and -1 refused with the output untouched, bits 3 and 0x39 set and 4 and 0x38 clear, and the four pid cases. It aborts onmain, and fails with each of these changes: a signed bit compare, a limit of 0x3B, a 5-bit shift mask, dropping the -1 pid, returning 0 for a foreign pid, and no null check on the output.ctest: 1784 of 1792 pass. The 8 failures fail the same way onmainon this machine and do not link libkernel_sys:application_heap_scripting,application_heap_lazy,agc_driver_guest_memory_lifetime,agc_driver_image_array_window_past_layer_limit,agc_driver_tessellationand the threenet_dontwait_blocking_*cases.tools/progress.py --compare: libraries +0.03%, 2 functions implemented, none lost.tools/check_conventions.py --base upstream/mainpasses.tools/pr_overlap.pyfinds no PR with the same exports; #6525, #8457, #8531 and #8987 edit lines next to this PR's test and debt additions.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)Imported from boykopovar/AnyPS5. Originally posted by harisibrar1 on 2026-10-22T04:12:29Z.
Review: COMMENTED
Checked against main
6ef5a1c4cand shadPS4 a808e76src/core/libraries/kernel/kernel.{cpp,h}:sceKernelTitleWorkaroundIsEnabledmatches shadPS4's decompiled bit test (EFAULT for null, EINVAL for bit >= 0x3A,ids[bit>>6] >> (bit&0x3F) & 1), and the unsigned bound check for negative bits is a sensible, documented deviation.sceKernelGetProcessTypematches shadPS4 exactly (own pid, -1 and 0 give 0, anything else gives ESRCH).title_workaroundblock fromsceKernelGetAppInfo, and itssceKernelGetAppInfozero-fills the wholeOrbisKernelAppInfo. Main'ssceKernelGetAppInfo(core/libs/prx/libkernel/System/src/Process.cpp:282-295) only writesapp_idand the title ID and deliberately leaves the rest untouched;GuestAppInfo.cppasserts that anddocs/dev/debt/libkernel.mddocuments it.sceKernelGetAppInfo(getpid(), &info)on a stack struct and thensceKernelTitleWorkaroundIsEnabled(&info.title_workaround, n, &r)now gets 0 back with whatever stack bits were there, so workarounds are enabled at random, where before this PR it threw. Could the newdocs/dev/debt/libkernel_sys.mdentry forsceKernelTitleWorkaroundIsEnabledrecord that its input is not populated on this platform? If a title motivated this, which call site is it, and where does its block come from?BUILD_TESTING=ONbuild) merged onto main6ef5a1c4c; the only failing step is the existingImageArrayWindowPastLayerLimit.cppalignment error that #8310 fixes. Not run here: this machine's Smart App Control blocks freshly built test executables.Reviewed with AI assistance (Claude Code); the checks above were run locally on my machine.
Imported from boykopovar/AnyPS5. Originally posted by YossiYad on 2026-10-22T05:21:50Z.
@harisibrar1 thanks, that's a real gap. The
sceKernelTitleWorkaroundIsEnableddebt entry now says that titles usually pass thetitle_workaroundblock ofsceKernelGetAppInfo, thatsceKernelGetAppInfodoesn't write that block here, and that the bits read are whatever the caller's memory held.No title motivated this. The two calls were among the throwing libkernel_sys exports that shadPS4 already covers, so the PR says Unblocks: none. I left
sceKernelGetAppInfoalone because the size problem that keeps it from writing past the title ID is its own topic.Imported from boykopovar/AnyPS5. Originally posted by harisibrar1 on 2026-10-22T05:31:37Z.
Review: APPROVED
Rechecked be12c45d7: the
sceKernelTitleWorkaroundIsEnableddebt entry now records that titles usually pass thetitle_workaroundblock fromsceKernelGetAppInfo, that this platform doesn't write that block, and that the bits read are whatever the caller's memory held. That covers my point, and keeping thesceKernelGetAppInfosize question as its own topic makes sense. The change since my review is documentation only.Reviewed with AI assistance (Claude Code); the checks above were run locally on my machine.
Imported from boykopovar/AnyPS5. Originally posted by YossiYad on 2026-10-22T12:58:47Z.
Rebased onto
main8b3a6ba88after #9279 (heade99e0d93a). The conflicts were #9279's code and debt entry next to this PR's; I kept both, and this PR's lines are unchanged.guest_kernel_syspasses 3 of 3.