From 1c800fb0253a7ccdbb50e5f484a21eca1ce261ea Mon Sep 17 00:00:00 2001 From: Mohamed Malek Aifa <32399935+malekaifa@users.noreply.github.com> Date: Tue, 24 Nov 2026 00:02:55 +0100 Subject: [PATCH] fix(libkernel): match write throttling status failure --- core/libs/prx/libkernel/File/src/Stdio.cpp | 5 ++--- core/libs/tests/GuestFilesystem.cpp | 4 ++-- .../debt/changes/fix-libkernel-write-throttling-status.md | 5 +++++ 3 files changed, 9 insertions(+), 5 deletions(-) create mode 100644 docs/dev/debt/changes/fix-libkernel-write-throttling-status.md diff --git a/core/libs/prx/libkernel/File/src/Stdio.cpp b/core/libs/prx/libkernel/File/src/Stdio.cpp index 6038068d174a..e23105cc67a8 100644 --- a/core/libs/prx/libkernel/File/src/Stdio.cpp +++ b/core/libs/prx/libkernel/File/src/Stdio.cpp @@ -1525,9 +1525,8 @@ int APS5_VABI sceKernelFdatasync(int fd) { int APS5_VABI sceKernelWriteThrottlingStatus(std::uint64_t* status) { if (status == nullptr) return SceErrorFromErrno(GUEST_EINVAL); - const std::uint64_t values[4]{std::numeric_limits::max(), 0, 0, 0}; - if (!GuestCopyOut_nid_no_patch(status, values, sizeof(values))) return SceErrorFromErrno(GUEST_EFAULT); - return 0; + if (!GuestWritable_nid_no_patch(status, 4 * sizeof(*status))) return SceErrorFromErrno(GUEST_EFAULT); + return SCE_KERNEL_ERROR_ESRCH; } #ifdef _WIN32 diff --git a/core/libs/tests/GuestFilesystem.cpp b/core/libs/tests/GuestFilesystem.cpp index c1ab8f17f5c9..bd07e6cf07b0 100644 --- a/core/libs/tests/GuestFilesystem.cpp +++ b/core/libs/tests/GuestFilesystem.cpp @@ -850,8 +850,8 @@ int main() { Require(sceKernelStat(".", nullptr) == static_cast(0x8002000eu)); Require(sceKernelDebugOutText(-1, "text") == static_cast(0x80020016u)); std::uint64_t throttling[4] = {1, 2, 3, 4}; - Require(sceKernelWriteThrottlingStatus(throttling) == 0); - Require(throttling[0] == 0xffffffffu && throttling[1] == 0 && throttling[2] == 0 && throttling[3] == 0); + Require(sceKernelWriteThrottlingStatus(throttling) == static_cast(0x80020003u)); + Require(throttling[0] == 1 && throttling[1] == 2 && throttling[2] == 3 && throttling[3] == 4); Require(sceKernelWriteThrottlingStatus(nullptr) == static_cast(0x80020016u)); Require(sceKernelWriteThrottlingStatus(reinterpret_cast(0x10)) == static_cast(0x8002000eu)); Require(sceKernelDebugOutText(0, nullptr) == static_cast(0x8002000eu)); diff --git a/docs/dev/debt/changes/fix-libkernel-write-throttling-status.md b/docs/dev/debt/changes/fix-libkernel-write-throttling-status.md new file mode 100644 index 000000000000..ef8dcea88daf --- /dev/null +++ b/docs/dev/debt/changes/fix-libkernel-write-throttling-status.md @@ -0,0 +1,5 @@ +# libkernel + +## change [sceKernelWriteThrottlingStatus] + +- [sceKernelWriteThrottlingStatus](../../../core/libs/prx/libkernel/File/src/Stdio.cpp) (libkernel) returns `ESRCH` (`0x80020003`) for a valid 32-byte status buffer and leaves all four qwords untouched, as a payload process on a PS5 (firmware 11.60) did. A null status pointer returns `EINVAL` (`0x80020016`), also as measured there. An unwritable non-null buffer returns `EFAULT` (`0x8002000e`) through a non-mutating guest writeability check as a host-safety fallback; console fault behaviour and title-process behaviour are unmeasured. PPSA17221 reads only the first qword on success, but on failure assumes `0x4B000001` bytes, which selects the same highest write-budget tier as the previous host-defined `UINT32_MAX` success. What the hardware status value measures and the meanings of the other qwords remain unknown.