Skip to content

feat(libkernel): implement the system-ex version, lower-limit and trace memory queries - #10110

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
BunnyFl:feat/libkernel-version-trace-queries
Oct 24, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
BunnyFl:feat/libkernel-version-trace-queries

Conversation

@BunnyFl

@BunnyFl BunnyFl commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

What

sceKernelGetSystemExVersion, sysKernelGetLowerLimitSysexVersion, sysKernelGetLowerLimitUpdVersion and sceKernelGetTraceMemoryStats were NotImplemented stubs in libkernel_sys. In libkernel.sprx, libkernel_sys.sprx and libkernel_web.sprx of firmware 13.42 (read from disassembly, not measured on a console), none of them asks the kernel:

Export Firmware 13.42
sceKernelGetSystemExVersion(char*, char*) writes an empty string (one zero byte) to both outputs and returns 0; returns a plain 22, not SCE_KERNEL_ERROR_EINVAL, when either is null, without writing
sysKernelGetLowerLimitSysexVersion(char*) writes one zero byte; SCE_KERNEL_ERROR_EINVAL for null
sysKernelGetLowerLimitUpdVersion(uint32_t*) writes a 32-bit 0; SCE_KERNEL_ERROR_EINVAL for null
sceKernelGetTraceMemoryStats(uint64_t*, uint64_t*) writes 0 to each output that is not null; always returns 0

They now do the same in libkernel, next to sceKernelGetSystemSwVersion and sceKernelGetPageTableStats, and the stubs are removed. A libkernel debt entry cites the source and says the meaning of the outputs is unknown.

The stubs of these functions in libkernel_sys/Export.Discovery.cpp are removed, so a libkernel_sys import reaches the implementation in libkernel: the Windows entry stub searches libkernel after libkernel_sys (WindowsEntryStubBuilder.cpp), and the other hosts resolve symbols that libkernel_sys does not define from libkernel.prx. That is why the progress report lists them as removed from libkernel_sys and implemented in libkernel.

Tested

Windows 11 (MinGW GCC 15). No title was run.

  • guest_system_configuration and guest_page_table_stats gained checks: exact bytes written (neighbouring bytes unchanged), null handling and return codes, and errno left alone.
  • Locally I ran the firmware functions of all three modules under a CPU emulator for every null/non-null combination. They gave the return codes and bytes these checks require. Nothing from the firmware is attached or added.
  • ctest -R "^guest_|^kernel" -E "agc|vulkan": 635/635 pass.
  • check_conventions.py --base upstream/main: passed.
  • No merge conflict with any open PR that merges cleanly into main, checked by merging each one into this branch. The debt entry sits between two entries that no open PR changes.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes (Claude Code)

🤖 Generated with Claude Code

@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

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.

Pull request Shared files not compared
PR 4630 docs/dev/debt/libkernel.md
PR 5021 core/libs/prx/libkernel/DirectMemory/Export.cpp
docs/dev/debt/libkernel.md
PR 6149 docs/dev/debt/libkernel.md
PR 6740 docs/dev/debt/libkernel.md
PR 6830 docs/dev/debt/libkernel.md
PR 6936 docs/dev/debt/libkernel.md
PR 7088 docs/dev/debt/libkernel.md
PR 7090 docs/dev/debt/libkernel.md
PR 7105 core/libs/prx/libkernel/DirectMemory/Export.cpp
docs/dev/debt/libkernel.md
PR 7121 docs/dev/debt/libkernel.md
PR 7149 docs/dev/debt/libkernel.md
PR 7192 docs/dev/debt/libkernel.md
PR 7201 core/libs/prx/libkernel/DirectMemory/Export.cpp
PR 7509 docs/dev/debt/libkernel.md
PR 7511 docs/dev/debt/libkernel.md
PR 8010 docs/dev/debt/libkernel.md
PR 8605 docs/dev/debt/libkernel.md
PR 9019 core/libs/prx/libkernel_sys/Export.Discovery.cpp
PR 9097 core/libs/prx/libkernel_sys/Export.Discovery.cpp
PR 9123 docs/dev/debt/libkernel.md
PR 9156 core/libs/prx/libkernel_sys/Export.Discovery.cpp
docs/dev/debt/libkernel.md
PR 9160 core/libs/prx/libkernel_sys/Export.Discovery.cpp
docs/dev/debt/libkernel.md
PR 9161 core/libs/prx/libkernel_sys/Export.Discovery.cpp
PR 9187 core/libs/prx/libkernel_sys/Export.Discovery.cpp
docs/dev/debt/libkernel.md
PR 9199 docs/dev/debt/libkernel.md
PR 9263 docs/dev/debt/libkernel.md
PR 9284 core/libs/prx/libkernel_sys/Export.Discovery.cpp
docs/dev/debt/libkernel.md
PR 9293 core/libs/prx/libkernel_sys/Export.Discovery.cpp
docs/dev/debt/libkernel.md
PR 9297 core/libs/prx/libkernel_sys/Export.Discovery.cpp
docs/dev/debt/libkernel.md
PR 9302 core/libs/prx/libkernel_sys/Export.Discovery.cpp
docs/dev/debt/libkernel.md
PR 9509 docs/dev/debt/libkernel.md
PR 9557 docs/dev/debt/libkernel.md
PR 9561 docs/dev/debt/libkernel.md
PR 9566 docs/dev/debt/libkernel.md
PR 9575 docs/dev/debt/libkernel.md
PR 9669 docs/dev/debt/libkernel.md
PR 9693 core/libs/prx/libkernel_sys/Export.Discovery.cpp
docs/dev/debt/libkernel.md
PR 9843 docs/dev/debt/libkernel.md
PR 9947 docs/dev/debt/libkernel.md
PR 10179 docs/dev/debt/libkernel.md

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reviewed exact head 5f3ca8c. The firmware 13.42 disassembly evidence is carefully separated from console measurement, and the tests check exact bytes, neighboring memory, null behavior and errno. The removal from libkernel_sys is consistent with current symbol resolution; current main still has the four discovery stubs. Exact-head conventions and whitespace checks pass; the reported 635/635 Windows tests and emulator-derived null/non-null cases are relevant.

Before approval, please refresh against current main and rerun the focused tests on the resulting merge candidate. check_main_sync.py reports 681 commits behind. The textual merge is clean, but Export.Discovery.cpp changed since the base, and the current PR workflows did not run product tests for these paths (the hosted relinker/build jobs are skipped). I could not configure the local full build because SDL2 development files are missing, so I did not run a local C++ test.

@MarcZX10

Copy link
Copy Markdown
Contributor

Correction: my earlier sync-check command accidentally inspected the workspace branch. For this exact PR worktree, the result is 1 ahead/36 behind current upstream/main, clean merge; libkernel_sys/Export.Discovery.cpp is the one shared changed file since the base (including merged #9141 and #9382). The request to refresh and rerun remains, but the accurate behind count is 36, not 681. Exact-head conventions pass.

…ce memory queries

sceKernelGetSystemExVersion, sysKernelGetLowerLimitSysexVersion,
sysKernelGetLowerLimitUpdVersion and sceKernelGetTraceMemoryStats were
NotImplemented stubs in libkernel_sys. libkernel, libkernel_sys and
libkernel_web of firmware 13.42 answer them without asking the kernel:
empty strings, a zero version and zero statistics, with the null checks
and return codes the firmware uses, including the plain 22 of
sceKernelGetSystemExVersion.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@BunnyFl
BunnyFl force-pushed the feat/libkernel-version-trace-queries branch from 5f3ca8c to 9aa0f22 Compare October 23, 2026 10:41
@BunnyFl

BunnyFl commented Oct 23, 2026

Copy link
Copy Markdown
Contributor Author

@MarcZX10 thanks for the review. I rebased the branch onto main 513ca7e. The new head is 9aa0f22, and git range-diff shows the commit unchanged. Since then main has gained only #9047 (LibreSSL DES), which touches none of this PR's files, and the head still merges cleanly.

Export.Discovery.cpp changed on main since the old base, in #9382 (sched_rr_get_interval) and #9141 (the pthread scope, atfork and setconcurrency forms). Neither touches the four removed stubs. On the new head, the four functions are defined only in libkernel.

On the new head (Windows 11, WinLibs GCC 15.2.0 r7 (MinGW-w64 UCRT), Release, BUILD_TESTING=ON):

  • Full build: no failures.
  • ctest -R "^guest_|^kernel" -E "agc|vulkan": 642/642 pass, including guest_system_configuration and guest_page_table_stats.
  • tools/check_conventions.py --base upstream/main: passes.
  • git diff --check: clean.

AI-assisted: yes (Claude Code).

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed exact head 9aa0f22dc72db45687aa2c38d8bf12221bc366bd. The previously requested current-main refresh and focused tests are addressed: the author reports a full Windows build and 642/642 selected kernel/library tests passing, including the two updated cases. I verified exact-head conventions and diff check; sync is 1 ahead/13 behind current main with a clean merge. The removal of the four libkernel_sys stubs is consistent with the entry-stub fallback to libkernel; I checked the current #10132 shared SystemConfiguration.cpp change pairwise and it merges cleanly, while touching different functions. The 13.42 disassembly evidence is accurately labeled as unmeasured firmware behavior. I did not independently run the Windows suite.

@oneandonlydean oneandonlydean self-assigned this Oct 23, 2026
@oneandonlydean
oneandonlydean merged commit 9a1ea5d into boykopovar:main Oct 24, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants