feat(libkernel): implement sceKernelGetSystemSwVersion #2945
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2945"
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 MarcZX10 on 2026-10-10T18:45:17Z.
What
Implement
sceKernelGetSystemSwVersionfor the startup path reported by ProsperoStore (PPSA99000). It checks a null output pointer and the expected 40-byte size, returnsSCE_KERNEL_ERROR_EFAULTorSCE_KERNEL_ERROR_EINVALwithout changing guesterrno, and writes the baseline version01.000.000/0x01000000.The 40-byte structure uses a 64-bit
sizeat offset 0,versionStringat offset 8, andversionat0x24. This matches the caller in ProsperoStore and the declarations in shadPS4, fpPS4 and OpenOrbis. The guest test pins these offsets withstatic_asserts. These references support the ABI layout, but do not verify the reported console firmware value0x01000000, which remains documented as unverified inTechnicalDebt.md.This carries the implementation and error-handling correction from Pushkar Reddy while preserving his commit authorship.
Depends on: none. #2902 and #3218 touch the same guest test file, so the branch that merges second may need a small rebase to resolve the shared test call site.
Tested
On current
main(961b25fe) after rebasing, Linux GCC 12.2 Release:cmake --build /tmp/AnyPS5-build-2945-rebased-release --target guest_system_configuration_tests -j2ctest --test-dir /tmp/AnyPS5-build-2945-rebased-release -R "^guest_system_configuration$" --output-on-failure(1/1 passed)python3 tools/check_conventions.py --base upstream/mainandgit diff upstream/main...HEAD --check(passed)The console firmware value remains unverified.
Checklist
main; no other open PR implements the same functionNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repositoryImported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-10T19:07:46Z.
Progress report (
2a4e03c→1583126)➖ System libraries: 85.83% (+0.0%, +1 implemented functions)
✅ 1 implemented
sceKernelGetSystemSwVersion_nid_postfixImported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-10T19:18:13Z.
The error paths at
SystemConfiguration.cpp:117-124return -1 and set errno; please returnSCE_KERNEL_ERROR_EFAULTandSCE_KERNEL_ERROR_EINVALinstead, as the othersceKernel*functions do (e.g.Aio.cpp), and update the test to match.Imported from boykopovar/AnyPS5. Originally posted by pushkarreddyy on 2026-10-10T19:49:18Z.
Updated error handling per review feedback:
sceKernelGetSystemSwVersion_nid_postfixnow returnsSCE_KERNEL_ERROR_EFAULTon null pointer andSCE_KERNEL_ERROR_EINVALon size mismatch without altering errno, and unit test assertions inGuestSystemConfiguration.cpphave been updated to match.The updated commit is ready on my fork branch:
github.com/pushkarreddyy/AnyPS5@f3dc623465Imported from boykopovar/AnyPS5. Originally posted by pushkarreddyy on 2026-10-10T20:06:01Z.
@oneandonlydean I have updated the error paths per your review: sceKernelGetSystemSwVersion_nid_postfix now returns SCE_KERNEL_ERROR_EFAULT on null pointer and SCE_KERNEL_ERROR_EINVAL on size mismatch directly without setting errno, and the guest unit tests in GuestSystemConfiguration.cpp have been updated to assert these error codes and verify errno remains untouched.
The updated commit is ready on my branch and PR:
github.com/pushkarreddyy/AnyPS5@9712ae6e95Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-10T20:21:44Z.
Thanks @oneandonlydean for identifying the error convention, and thanks @pushkarreddyy for preparing the correction and updated assertions. I reviewed and carried Pushkar's commit onto current
main, preserving its author attribution.The null and size-mismatch cases now return
SCE_KERNEL_ERROR_EFAULTandSCE_KERNEL_ERROR_EINVALdirectly, and the tests verify that guesterrnois unchanged. The Release build ofguest_system_configuration_testssucceeds, andguest_system_configurationpasses 1/1. Conventions andgit diff --checkpass as well.Imported from boykopovar/AnyPS5. Originally posted by screamm on 2026-10-10T20:47:13Z.
Windows validation of the current head
7eb6db10merged ontomain56fb1b3b(without #2902, which conflicts in the same file; this PR alone merges cleanly).Windows 11 Pro 26220, WinLibs MinGW-w64 GCC 15.2.0 r7, Ninja, Release,
BUILD_TESTING=ON, full build including thelibstarget.guest_system_configurationpasses 3/3 (--repeat until-fail:3).ctest -j8 -E "^agc_|video_out"passes 388/388.main'sSystemConfiguration.cppand this PR's test, the test fails, so the coverage detects the missing export.Validation run with Claude Code assistance.
Imported from boykopovar/AnyPS5. Originally posted by pushkarreddyy on 2026-10-10T21:03:48Z.
Thank you @screamm for taking the time to validate this on Windows 11, really appreciate the thorough testing!
Special thanks to @oneandonlydean and @MarcZX100 for reviewing, guiding me on conventions, and carrying these patches forward — really grateful for the support and looking forward to contributing more to AnyPS5.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-10T21:06:01Z.
Thanks, Pushkar. I compared
9712ae6with the correction already carried in this PR (ed41cc3): they have the same patch, including the guesterrnopreservation assertions. Your correction is already present here with your original commit author attribution preserved, so no duplicate commit or extra PR update is needed. The current PR checks are green, and the Windows validation posted above covers the corrected head.Imported from boykopovar/AnyPS5. Originally posted by screamm on 2026-10-10T21:12:24Z.
Rerun on the corrected head
ed41cc35merged ontomain262c0316, same Windows 11 / WinLibs GCC 15.2.0 r7 / Release setup:guest_system_configurationpasses 3/3 andctest -j8 -E "^agc_|video_out"passes 388/388.Imported from boykopovar/AnyPS5. Originally posted by fma-rc on 2026-10-10T22:38:13Z.
A question on the struct layout, since the test uses the same struct as the implementation and can't catch a difference. The PR has
uint32_t size; char versionString[0x1C]; uint32_t version; uint32_t unk_24;, so the string starts at offset 4 andversionis at 0x20. shadPS4's definition for the PS4 call (src/core/libraries/kernel/kernel.h,SwVersionStruct) isu64 struct_size; char text_representation[0x1c]; u32 hex_representation;, which puts the string at 8 and the number at 0x24. Both are 40 bytes, so the size check passes either way.I have no title here that calls it, so I can't say which one the PS5 uses. If the layout in the PR comes from a disassembly of a caller, a line saying so in the TechnicalDebt entry would settle it.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-10T23:01:58Z.
Thanks for pointing out that the test and implementation share the same declaration. The layout was not taken from a caller disassembly: issue #2906 proposes the 40-byte structure but provides no source for the field offsets. I added that explicitly to the
TechnicalDebt.mdentry, including the assumed offsets and the test's ABI limitation, and updated the PR description to match.The implementation and test commits are unchanged and retain Pushkar Reddy's authorship. I rebased onto current
main(64baa79b); conventions andgit diff --checkpass. The focused Release CTest passed on the prior corrected head. I could not repeat the build after rebasing because this worktree lacks third-party submodule checkouts, and no console ABI measurement is available.Imported from boykopovar/AnyPS5. Originally posted by orishamir on 2026-10-10T23:26:16Z.
The caller the blocker names is open source and answers @fma-rc's layout question. ProsperoStore
src/diag/trace.cpp, call at lines 180-183:sizeis 8 bytes, the string starts at 8 andversionis at 0x24. shadPS4 (SwVersionStruct), fpPS4 (t_sw_version) and the OpenOrbis header (OrbisKernelSwVersion) declare the same 40 bytes: a 64-bit size,char[0x1c],uint32_t. None has this PR's 32-bitsize, string at 4,versionat 0x20 andunk_24.Effect on the title, measured by calling this PR's function body verbatim (struct and code from
SystemConfiguration.cpp@ b3f476ec) through the title's struct in a host g++ probe: the size check passes (the low dword of the 64-bit size is 40), the call returns 0, and the title's trace line comes out asfirmware: 00.000 (0x00000000), since it reads the string from offset 8 andversionfrom 0x24, where this PR writesunk_24 = 0. The import resolves, so the startup stop in #2908 is gone either way; the wrong values appear only in the store's "Debug log" trace (trace_consoleruns when that setting is on; the GNUmakefile says the trace is in every build).std::uint64_t sizeand nounk_24is the layout all four sources use, and the TechnicalDebt entry could cite them instead of calling the layout unverified.probe
Linux run of b3f476ec, since the description says the rebased head could not be built: replica of the CI
linuxjob (ubuntu 24.04, GCC 13.3, llvmpipe), build clean,guest_system_configuration5/5, full suite 737/738 (the one failure is #2386's newagc_driver_image_packed16_loadon lavapipe, red in CI'slinuxjob onmainsince 22:41Z and unrelated to this PR). Revert-pin, main'sSystemConfiguration.cppwith this PR's test: the test binary does not link (undefined reference to sceKernelGetSystemSwVersion_nid_postfix), so the test pins the export.Merge order: with #2902 merged first, this head still conflicts in
core/libs/tests/GuestSystemConfiguration.cpp(both add a check function and its call inmain()at the same place); the other order conflicts the same way, so whichever lands second needs a one-hunk rebase.Thanks @MarcZX100 for carrying this and @fma-rc for asking.
AI-assisted: yes (Claude Code Fable 5.1 xhigh)
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T00:11:55Z.
Review: CHANGES_REQUESTED
Thanks for carrying this. One blocking problem, the struct layout (raised by @fma-rc, confirmed by @orishamir's probe):
core/libs/prx/libkernel/System/src/SystemConfiguration.cpp:19-24declaresuint32_t size; char versionString[0x1C]; uint32_t version; uint32_t unk_24;. Every available source declares a 64-bit size:u64 struct_size; char text_representation[0x1c]; u32 hex_representation;(shadPS4kernel.hSwVersionStruct, fpPS4t_sw_version, OpenOrbisOrbisKernelSwVersion), and the ProsperoStore caller itself (src/diag/trace.cpp:20) usesuint64_t size; char text[0x1c]; uint32_t version;. That puts the string at offset 8 andversionat 0x24, not 4 and 0x20, and there is nounk_24.firmware: 00.000 (0x00000000).core/libs/tests/GuestSystemConfiguration.cpp:8-13repeats the implementation's struct, so it cannot catch this. Please declare the struct as the title does and check the string at offset 8 andversionat 0x24 (e.g.offsetof/static_assert).docs/dev/TechnicalDebt.md:47: cite those four sources for the layout; what stays unverified is only the value01.000.000/0x01000000on a console.Also, #2902 and this PR conflict in
GuestSystemConfiguration.cpp(both add a check function and its call inmain()at the same spot); whichever lands second needs a one-hunk rebase.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-11T01:16:35Z.
Thanks for tracing the caller and comparing the available declarations. I corrected the structure to match the observed 40-byte layout:
uint64_t size0x00char versionString[0x1c]0x08uint32_t version0x24The unused
unk_24field is removed. The guest test now asserts those offsets and the total size independently of runtime values.TechnicalDebt.mdcites the ProsperoStore caller, shadPS4, fpPS4, and OpenOrbis as layout evidence; only the reported firmware value remains unverified.I rebased onto current
mainand pushed the correction in2169405f9(fix(libkernel): correct system version ABI layout), preserving Pushkar Reddy's implementation and error-handling commit authorship. GCC C++20 syntax checks for the implementation and test, conventions, andgit diff --checkpass. I could not run the runtime CTest on this head because this worktree lacks the third-party submodules required for a full build.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-11T03:16:00Z.
The overlap notice points to #3218, which adds the independent
kern.rng_pseudoexport. It sharesSystemConfiguration.cppand the guest system-configuration test translation unit, but this PR does not depend on it and the exports are distinct. No dependency is needed; if either merges first, the remaining branch will need the corresponding rebase/conflict resolution.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-11T03:41:19Z.
Thanks for the blocking ABI review and for the caller probe. The current head
7d39777dcorrects the structure touint64_t size,versionStringat0x08, andversionat0x24, removesunk_24, and pins the offsets and 40-byte size with independent teststatic_asserts. The TechnicalDebt entry now cites the ProsperoStore caller plus shadPS4, fpPS4, and OpenOrbis; only the console firmware value remains unverified.I rebased the four authored commits onto current
main(961b25fe), rebuilt the Release test target, andguest_system_configurationpasses (1/1); conventions and diff checks pass. The description now lists no dependency: #2902 and #3218 are independent changes that share the test call site, so whichever merges second may need a small rebase. Please re-review the corrected head when convenient.Imported from boykopovar/AnyPS5. Originally posted by pushkarreddyy on 2026-10-11T06:38:46Z.
Thank you @adriadam10 for the thorough ABI review. All requested changes have been addressed by @MarcZX100 on head
7d39777d:uint64_t size),versionStringat offset0x08, andversionat0x24, withunk_24removed.static_assertoffset and size checks added toGuestSystemConfiguration.cpp.TechnicalDebt.mdcitations updated with all 4 sources.main(1690db9a2) withguest_system_configurationpassing 100% andMergeable: True.cc @oneandonlydean @MarcZX100: Ready for re-review and merge whenever convenient!
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T07:16:54Z.
Review: APPROVED
Checked the layout against the ProsperoStore caller, shadPS4, fpPS4 and OpenOrbis (u64 size @0, text @8, version @0x24), the EFAULT/EINVAL returns, and the new test (it fails to link without the change). Build and ctest on the area pass; merging.
Added one commit: the
TechnicalDebt.mdentry now also records that the null/size checks are unverified on a console (shadPS4 returns success for null and never readssize).Imported from boykopovar/AnyPS5. Originally posted by Mouhand-Kaddo on 2026-10-11T07:31:38Z.
Additional platform validation of standalone PR head
9516ca9991b55d1bcd72bc97df6b2b76eb474fb8(2026-10-11):Windows: passed — Windows 11, WinLibs GCC 15.2.0 UCRT/POSIX/SEH r7; CMake 4.3.1 / Ninja; Release,
BUILD_TESTING=ON.1 checks, 0 failures, 0 CTest skips. Built the selected targets and dependencies; this is focused validation, not a full build or full-suite run.
Checks:
guest_system_configuration.Command after building:
ctest --test-dir <build> --verbose --no-tests=error --timeout 30 -R "^guest_system_configuration$".No title/gameplay validation. These results cover the standalone head, not a merge with current main.
Imported from boykopovar/AnyPS5. Originally posted by pushkarreddyy on 2026-10-11T07:32:48Z.
@MarcZX100 @adriadam10 Just a heads up: PR #3056 (
sceKernelGetAppInfo) recently landed onmain(bd0692590), introducing a minor 1-line conflict indocs/dev/TechnicalDebt.md. The C++ code inSystemConfiguration.cppandGuestSystemConfiguration.cppremains 100% clean and conflict-free. Whenever convenient, a quick rebase ontoorigin/mainwill restore mergeability!Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T07:44:29Z.
Rebased onto current
main(only conflict: theTechnicalDebt.mdline next to #3056, both entries kept). Diff unchanged; build andguest_system_configurationplus the area's ctest pass; merging.