feat(libs): mirror libkernel exports through libkernel_web #18112
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/18112"
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 akkadbakkad89 on 2026-11-10T13:28:00Z.
What
libkernel_webis a pure mirror oflibkernelin firmware 4.03: its 1,205 exports are a strict NID subset of libkernel's 1,240, and every shared function body is instruction-identical once PLT/GOT layout and RIP-relative displacements are normalized (1,199/1,199 matched, 0 divergent). The module therefore does not need 1,100 independent implementations — it needs the same NIDs re-exported through the providers we already have.This PR turns
libkernel_webfrom 43 exports into 1,198 by adding:Forwards.cpp/Forwards.hpp— 1,086 generated forwarders in the established*_nid_disambigN_nid_postfixconvention already used by_dup2/_execve/_execvpe. Each forwarder calls anX_nid_no_patchprovider resolved by name, so nothing in libkernel_web binds through the patched NID export surface: 716 providers added inlibkernel/LibKernelSysProviders.cpp, 60 sys-owned providers (ksem_*,blockpool_*,sched_*,tc*,get_authinfo,pthread_setschedother_np, …) added inlibkernel_sys/AdditionalExports.cpp, and the pre-existinglibkernel_sysUnknown_*/libkernel_webUnknown_*no-patch trampolines for callees with no named implementation. Provider declarations come from each provider's own public header (included per-symbol), not from new declarations, so the public-header audit's one-declaration rule holds.APS5_EXPORT("<nid>", libkernel_webUnknown_*)) for firmware's unnamed exports, forwarding into the matchinglibkernel_sysUnknown_*stubs so a later real implementation stays single-source._sigintrand__stack_chk_guard(__stack_chk_guarduses the same0xDEADBEEFCAFEBABEcookie libc exports)..prxnow links-Bsymbolic-functions: afternid_patcherrenamesX_nid_postfixexports to the NID name, patchedlibkernel_web.prxandlibkernel.prxexport identical<NID>symbols, and this binds each library's internal references to its own definitions so alibkernel_web-first global scope cannot interpose a provider's call back into the mirror. Guest module loads are alreadyRTLD_LOCAL, which keeps patched NID exports out of the global scope in the first place.errno(host-TLS backed), the unnamed 8-byteAxgW94umKqU,__progname/environ(COFF cannot forward another module's storage; a web-local copy goes stale aftersetprogname/environment updates) andgetcontext/swapcontext/sigsetjmp(asm providers capture the caller's frame, which a C++ forwarder frame cannot survive) — plus the assumptions behind the mirror approach.Coverage vs the firmware 4.03 export catalog: 1,155 of 1,162 missing
libkernel_webNIDs now export; the seven left areerrno,AxgW94umKqU,__progname,environ,getcontext,swapcontextandsigsetjmp, all debt-documented.Notes:
tools/pr_overlap.pyreports export-name overlap with #18035. That PR adds the AMM mapper/command-buffer names tolibkernel; this PR re-exports the same names fromlibkernel_web(a different module — firmware exports them from both). No file overlap; merge order does not matter.libkernel,libkernel_sysandlibkernel_webalike.LibKernelSysProviders.cpp, so whichever lands second rebases to a strict superset rather than conflicting.Tested
Windows 11, MinGW/Ninja.
libkernel_webbuilds clean; 43 existing definitions + 1,086 forwarders + 67APS5_EXPORTtrampolines + 2 web-local objects.guest_kernel_web_forwardsctest passes. It resolves_dup2,_execve,_execvpeandfstatthroughlibkernel_web— each forwarder calls anX_nid_no_patchprovider added here (dup2,execveandfstatare three of the 716 libkernel providers) — and checks the call lands on the libkernel implementation:dup2actually duplicates a working pipe descriptor,fstatreports FIFOst_modeon a pipe, and theexecve/execvpeerror paths return the libkernel errnos. The test linkslibkernel_webbeforelibkernel, so its lookup scope is web-first.guest_kernel_sys,guest_kernel_sys_aio/neo_mode/app_category/swapcontext,guest_kernel_rem_pio2,guest_kernel_app_archive_*,guest_timed_join_import_libkernel_{sys,web},windows_kernel_variant_{sys,web}all pass.tools/check_conventions.py --base origin/mainclean;core/libs/tests/test_public_headers.py --audit-onlyclean (407 libraries, 34,939 exports).ubuntu-latestCI job. The-Bsymbolic-functionslink makes provider binding order-independent rather than relying on lookup scope.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)libkernel_webfunctions the module did not exportSummary by CodeRabbit
New Features
Bug Fixes
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-16T16:30:38Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing blocks this change based on the code inspected; the broad generated forwarding surface and Linux symbol-binding changes still need full build and test validation.
What I ran
Reviewed head
3b8d3f3a8a28396e6742381d5304c6624f26d010. I used the prepared diff andrepo_read.pyto inspect changed lines and targeted context. I did not run build or test commands.Results
Findings
Blocking
None identified in the inspected code.
Non-blocking
None.
Not verified
The complete contents of every changed file were not read, including the full generated forwarder/provider sets and all added declarations. The review-folder list marks 33 changed files included, and no changed files were excluded by its manifest; inspection was targeted rather than exhaustive. No build, test suite, Linux binding check, or console behavior was verified. Author-reported CI and test results were not independently checked.
To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T05:41:28Z.
Review: DISMISSED
Reviewed — changes requested
Changes are required before merge: fix the generated
getargvprovider call so it resolves to the existinglibkernelimplementation.What I ran
Reviewed head
7ce6e25371854a3b7fa1a06dbe4b5905532b314bfrom the prepared diff and pinned repository reader. No build or tests were run here; test results in the description are author-reported.Results
getargvprovider calls an undefined postfix symbolFindings
Blocking
core/libs/prx/libkernel/LibKernelSysProviders.cpp:356callsgetargv_nid_postfix(), but the existing libkernel API declaresgetargv_nid_disambig1_nid_postfix(). The mismatched call has no matching declaration or implementation in the inspected provider context, so this generated provider cannot compile. Correct the target name to the existing disambiguated API. The changed call is atcore/libs/prx/libkernel/LibKernelSysProviders.cpp:356.Non-blocking
None.
Not verified
No local build or test command was run. Console behavior was not verified. The prepared manifest marks all 17 changed files as included; I inspected the diff and targeted ranges in the forwarding/provider code, CMake setup, test addition, API declaration, and debt notes. I did not read every line of all included changed files. No files were excluded according to the manifest.
To get this to a good state
Fix the
getargvprovider target and rerun the reported build and forwarding tests on the new head.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T12:14:51Z.
Review: COMMENTED
Reviewed — comments
The generated mirror and its binding strategy are only partially verified here, so a formal approval is not justified.
What I ran
Reviewed the prepared diff for head
5e34e243359439362e1b840951f6ab062aae091d. No build or tests were run. The author reports Windows and Linux checks in the PR description; those were not run by me.Results
Findings
Blocking
None verified.
Non-blocking
fstatexercises one forwarding path. The PR description claims extensive generated export coverage, but this review did not check every forwarder’s signature and target provider._sigintris a web-local copy while signal implementations use libkernel’s cell. This leaves guest writes to the web export disconnected from those implementations (docs/dev/debt/libkernel_web.md, described atreview/diff.patch:12818).Not verified
files.json(the attempted path was unavailable).To get this to a good state
Nothing is required. Optional: add targeted checks for representative ABI-sensitive forwarders and for
_sigintrwrites reaching the signal implementation.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T16:28:55Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing blocks this merge based on the portions inspected; the Linux internal-binding change and representative forwarders appear consistent with the stated design.
What I ran
Reviewed head
d010d93b4f38b3a65d9370178d73612e71ab923cusing the prepared diff and pinned repository reader. No commands or tests were run. I read the description, commits, diff, manifest, libkernel_web build configuration and exports, representative forwarders and their declarations, the added forwarder test, shared PRX link configuration, and the start of the sys export implementation. All 16 changed files listed by the manifest are included, but I did not read every changed file in full.Results
Findings
Blocking
None in the inspected code.
Non-blocking
None.
Not verified
The generated provider and forwarder tables, the full added sys exports, all ABI signatures, firmware export coverage and disassembly claims, and runtime behavior on Linux or console were not exhaustively verified. The description reports Windows and Linux checks, but they were not run as part of this review.
To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-25T07:46:23Z.
Review: COMMENTED
Reviewed — no blocking findings
The inspected excerpts show no verified blocking defect, but the full change was not reviewed, so a formal approval is not justified.
What I ran
Inspected the prepared review metadata and diff for head
22899fc029877606abf63d1c8af70181ce44b53d, then read targeted excerpts throughrepo_read.py. No build or tests were run.Results
Findings
Blocking
None verified in the inspected excerpts.
Non-blocking
The review is incomplete; the many generated forwarders and provider signatures were not audited end to end.
Not verified
Read:
description.md,commits.md,manifest.json, the beginning ofdiff.patch, excerpts fromLibKernelSysProviders.cpp, and excerpts fromForwards.cpp. The manifest lists 16 changed files, all included in the prepared folder; the full text of most changed files and the remainder of the diff were not read. No build, tests, Linux linking behavior, firmware export coverage, or console behavior was verified. The author-reported test results were not independently run.To get this to a good state
Nothing is required. Optional: complete the audit of the generated forwarders and provider signatures, then run the relevant build and tests.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-29T22:09:06Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the author can merge it, with the optional note below.
What I ran
Reviewed head
431afcf77fdd91cc223b6dea8c32baa8c01182a7. No commands or tests were run; the PR description reports Windows tests and CI results, which I did not independently verify.Results
Findings
Blocking
None.
Non-blocking
TestFstatcloses both pipe descriptors only after all assertions pass. Iffstatfails or reports an unexpected mode, the test aborts with both descriptors open. This is test-only cleanup and does not affect the forwarding behavior. Consider an RAII descriptor wrapper or cleanup before asserting.core/libs/tests/GuestKernelWebForwards.cpp:61Not verified
No tests, builds, firmware checks, or console behavior were run independently. The PR description’s claimed test results and firmware analysis were not verified. The prepared bundle excluded no changed files; all 17 changed files listed in the manifest were included and read.
To get this to a good state
Nothing is required. The test cleanup suggestion is optional.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-29T22:12:02Z.
Review: COMMENTED
Actionable comments posted: 6
5b9459b3-5014-4b49-84ce-160ca505f4b3Reviewing files that changed from the base of the PR and between
6b222c7ccdand431afcf77f.core/libs/prx/libc/include/Api.hppcore/libs/prx/libc/include/GuestLocale.hppcore/libs/prx/libc/src/Filesystem.cppcore/libs/prx/libc/src/General.cppcore/libs/prx/libc/src/Process.cppcore/libs/prx/libkernel/CMakeLists.txtcore/libs/prx/libkernel/LibKernelSysProviders.cppcore/libs/prx/libkernel/include/LibKernelSysProviders.hppcore/libs/prx/libkernel_sys/AdditionalExports.cppcore/libs/prx/libkernel_sys/include/AdditionalExports.hppcore/libs/prx/libkernel_web/CMakeLists.txtcore/libs/prx/libkernel_web/Export.cppcore/libs/prx/libkernel_web/Forwards.cppcore/libs/prx/libkernel_web/include/Api.hppcore/libs/prx/libkernel_web/include/Forwards.hppcore/libs/tests/GuestKernelWebForwards.cppdocs/dev/debt/libkernel_web.mdIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-30T20:16:51Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing blocks this; the points below are optional.
What I ran
Reviewed head
8789ea7167c42323fb59c843b95cd9e32b2fd9db. I read the prepared description, commits, manifest and selected diff hunks, then usedrepo_read.pyto inspect targeted source ranges. No builds or tests were run.Results
Negative control
Not run; no test was run.
Findings
Blocking
No verified blocking defect in the inspected ranges.
Non-blocking
None.
Sources
Not verified
The manifest lists 18 changed files and no exclusions. This review inspected selected ranges, not every changed line. In particular, the generated
Forwards.cppandLibKernelSysProviders.cppimplementations and their corresponding headers, plus the fullAdditionalExports.cppadditions, were not reviewed line by line. Builds, tests, Linux behavior and console behavior were not verified; test results in the PR description are author-reported.To get this to a good state
Nothing is required. Optional: complete a line-by-line audit of the generated forwarders and provider additions before making a formal approval decision.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T16:38:03Z.
Review: COMMENTED
On Linux, CTest passed
guest_kernel_web_forwardswith this revision integrated. The fixture creates a pipe and checks that callingfstatthrough the libkernel_web export reports it as a FIFO. This exercises the cross-library call and its guest structure, with coverage limited to that forwarding path.AI-assisted: yes.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.