Repository navigation
feat(libkernel): answer kern.proc.env for the calling process - #9736
Conversation
|
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.
|
|
I checked this against current |
PS5VR (PPSA99177) reads sysctl {CTL_KERN, KERN_PROC, KERN_PROC_ENV, pid}
for its own pid at start-up and stopped on "unsupported MIB 1.14.35.<pid>".
The call now returns the empty start-up environment that environ and
libc's getenv also begin with, and follows FreeBSD 11's
sysctl_kern_proc_env for the errors: EINVAL for a MIB without exactly one
pid, ESRCH for another pid or -1, EPERM for a write.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
b436f15 to
6e1df42
Compare
|
Rebased on current
The PR description is updated to match. |
harisibrar1
left a comment
There was a problem hiding this comment.
Checked against main 3ca07d0 and FreeBSD releng/11.4 sys/kern/kern_proc.c (sysctl_kern_proc_env, lines 1975-2001, node flags at 2956):
- The errors match FreeBSD 11.4: EINVAL when
namelen != 1, ESRCH frompgetfor a foreign pid and for -1, and EPERM for a write from theCTLFLAG_RDnode before the handler runs. The EPERM-before-EINVAL order in the new branch matches too. - 0 bytes is consistent with main:
environ_nid_postfixstarts asemptyEnvironment(libkernel/System/src/Process.cpp:224) and libc's table starts empty (libc/src/Environment.cpp:26). The console's real start-up environment is recorded in the debt entry. - No commit since cc00785 touches the three files, so the refresh MarcZX10 asked for should be conflict-free.
- Optional nit:
CopyOut(nullptr, 0, ...)ends instd::memcpy(oldValue, nullptr, 0), which is formally UB even with a zero length. A one-byte static empty buffer as the source would sidestep it. Not blocking.
Reviewed with AI assistance (Claude Code); the checks above were run locally on my machine.
What
PS5VR (PPSA99177) stops at start-up, right after it loads
libSceVrTracker2:That MIB is {
CTL_KERN,KERN_PROC,KERN_PROC_ENV, pid}, and the title asks for its own pid.sysctlnow answers it as FreeBSD 11'ssysctl_kern_proc_envdoes for the calling process:environlibkernel exports and libc'sgetenvboth begin empty. So the call returns 0 bytes. FreeBSD reads the start-up strings, not latersetenvchanges, so those changes don't show up there either.EINVALfor a MIB without exactly one pid.ESRCHfor any other pid, -1 included, aspgetgives.EPERMfor a write. These are the same rules as thekern.proc.vmmaphandler next to it.Which variables, if any, the console starts an application with is unverified. That is recorded in
docs/dev/debt/libkernel.md.Tested
Windows 11, Ryzen AI 7 350 / Radeon 860M, WinLibs GCC 15.2, Release.
maincc00785: the title ends with theunsupported MIB 1.14.35.<pid>exception above.main8b3a6ba (run again after the rebase): it gets past the call and lists its library (library: list Library -> ok, 7 items). It then shows its TV screen: the PS5VR logo, "Put on your PlayStation VR2" and the phone-link QR code. It also logsvr: headset setup failed, as expected with no PlayStation VR2 attached (sceHmd2Initialize->0x81110016).guest_system_configurationhas a newCheckEnvSysctl, which covers:errnounchanged;It fails on
main'sSystemConfiguration.cppand passes with this change.ctest -R "sysctl|system_config|guest_process": 6 of 6 pass.python tools/check_conventions.py --base origin/mainpasses.tools/pr_overlap.pyon the rebased branch:docs/dev/debt/libkernel.mdline afterkern.proc.vmmap, so the new entry sits beforekern.proc.vmmapinstead. A local merge of fix(libkernel): return ENOENT for unknown sysctl names #8910 into this branch is clean.kern.smp.maxcpus,kern.stackprot,kern.sched.name,kern.timecounter.hardware). It already conflicts withmainindocs/dev/debt/libSceIme.md, a file this PR doesn't touch.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)