Repository navigation
Conversation
Console evidenceMeasurement context: PS5 Pro, Probe Bits 0x3f, 0x40, 0x77, 0x78, 0x79, 0x7a, 0x7d and 0x7f all returned Probe Probe sources: tw1/main.c#include <ps5/kernel.h>
#include <dlfcn.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
typedef int (*EnabledFn)(const void* workaround, int32_t bit, int32_t* out);
typedef int (*Enabled2Fn)(const void* workaround, uint64_t selector, uint32_t bit, int32_t* out);
typedef int (*OutIntFn)(int32_t* out);
typedef int (*ArkFn)(int32_t a, int32_t b, int32_t c);
typedef int (*StateOutFn)(const void* state, uint32_t* out);
typedef int (*CtxFn)(uint32_t* ctx);
typedef int (*FiveFn)(void* s, const void* src, uint32_t len, void* dst, int32_t n);
typedef int (*SixFn)(void* s, const void* src, uint32_t len, void* dst, int32_t n, int32_t prio);
typedef int (*OnePtrFn)(void* p);
static unsigned char g_buf[0x200];
#define SENT 0xAAAAAAAAu
static void step(const char* what) {
printf("TW1|STEP|%s\n", what);
fflush(stdout);
}
static int32_t g_out;
static void show_int(const char* id, int rc, long long extra, int has_extra) {
if (has_extra) {
printf("TW1|%s|rc=0x%x|val=0x%llx\n", id, (unsigned)rc, (unsigned long long)extra);
} else {
printf("TW1|%s|rc=0x%x\n", id, (unsigned)rc);
}
fflush(stdout);
}
int main(void) {
printf("TW1|FW|0x%x\n", kernel_get_fw_version());
fflush(stdout);
step("dlopen-libkernel_sys");
void* lk = dlopen("libkernel_sys.sprx", RTLD_LAZY);
printf("TW1|LK|%p|%s\n", lk, lk ? "ok" : dlerror());
fflush(stdout);
EnabledFn E = 0;
Enabled2Fn E2 = 0;
EnabledFn EM = 0;
OutIntFn GC = 0;
if (lk) {
E = (EnabledFn)dlsym(lk, "sceKernelTitleWorkaroundIsEnabled");
E2 = (Enabled2Fn)dlsym(lk, "sceKernelTitleWorkaroundIsEnabled2");
EM = (EnabledFn)dlsym(lk, "sceKernelTitleWorkdaroundIsEnabled");
GC = (OutIntFn)dlsym(lk, "sceKernelGetCpumodeGame");
printf("TW1|SYM|E=%p E2=%p EM=%p GC=%p\n", (void*)E, (void*)E2, (void*)EM, (void*)GC);
fflush(stdout);
}
if (E) {
int rc;
step("A1-E-buf-bit0");
g_out = (int32_t)SENT;
rc = E(g_buf, 0, &g_out);
show_int("A1_E_0", rc, g_out, 1);
step("A2-E-null-wa");
g_out = (int32_t)SENT; rc = E(0, 0, &g_out); show_int("A2_E_nullwa", rc, g_out, 1);
step("A3-E-null-out");
rc = E(g_buf, 0, 0); show_int("A3_E_nullout", rc, 0, 0);
static const int32_t bits[] = {0x3f, 0x40, 0x77, 0x78, 0x79, 0x7a, 0x7d, 0x7f, 0x80, 0x81};
for (unsigned i = 0; i < sizeof(bits) / sizeof(bits[0]); ++i) {
char id[32];
snprintf(id, sizeof(id), "B-%02x", (unsigned)bits[i]);
step(id);
g_out = (int32_t)SENT;
rc = E(g_buf, bits[i], &g_out);
show_int(id, rc, g_out, 1);
}
step("B-neg");
g_out = (int32_t)SENT;
rc = E(g_buf, -1, &g_out);
show_int("B-neg", rc, g_out, 1);
}
if (E2) {
int rc;
static const uint64_t sels[] = {0, 0x28, 0x29, 0x2a, 0xffffffffffffffffull};
for (unsigned i = 0; i < sizeof(sels) / sizeof(sels[0]); ++i) {
char id[32];
snprintf(id, sizeof(id), "S-%llx", (unsigned long long)sels[i]);
step(id);
g_out = (int32_t)SENT;
rc = E2(g_buf, sels[i], 0, &g_out);
show_int(id, rc, g_out, 1);
}
step("S1-bit7f");
g_out = (int32_t)SENT;
rc = E2(g_buf, 1, 0x7f, &g_out);
show_int("S1_bit7f", rc, g_out, 1);
step("S2-bit80");
g_out = (int32_t)SENT;
rc = E2(g_buf, 0, 0x80, &g_out);
show_int("S2_bit80", rc, g_out, 1);
step("S3-nullwa");
g_out = (int32_t)SENT;
rc = E2(0, 0, 0, &g_out);
show_int("S3_nullwa", rc, g_out, 1);
step("S4-nullout");
rc = E2(g_buf, 0, 0, 0);
show_int("S4_nullout", rc, 0, 0);
}
if (EM) {
int rc;
step("M1-alias-bit78");
g_out = (int32_t)SENT;
rc = EM(g_buf, 0x78, &g_out);
show_int("M1_78", rc, g_out, 1);
step("M2-alias-bit7a");
g_out = (int32_t)SENT;
rc = EM(g_buf, 0x7a, &g_out);
show_int("M2_7a", rc, g_out, 1);
}
if (GC) {
int32_t mode = (int32_t)SENT;
step("G1-cpumode");
int rc = GC(&mode);
show_int("G1_cpumode", rc, mode, 1);
}
step("dlopen-libSceOpusDec");
void* od = dlopen("libSceOpusDec.sprx", RTLD_LAZY);
printf("TW1|OD|%p|%s\n", od, od ? "ok" : dlerror());
fflush(stdout);
if (od) {
ArkFn ARK = (ArkFn)dlsym(od, "ark0tPj4meI");
StateOutFn AJM = (StateOutFn)dlsym(od, "sceOpusDecGetAjmContext");
StateOutFn GMZ = (StateOutFn)dlsym(od, "gMazl3u8Y40");
CtxFn JXV = (CtxFn)dlsym(od, "jXVNwfmd1II");
FiveFn CT4 = (FiveFn)dlsym(od, "ct42RpB2CaM");
SixFn EJQ = (SixFn)dlsym(od, "eJQx7Emrwb0");
SixFn ZBX = (SixFn)dlsym(od, "ZBx02KtHz2Y");
OnePtrFn LFT = (OnePtrFn)dlsym(od, "lFTdHt-AuKU");
printf("TW1|SYM2|ARK=%p AJM=%p GMZ=%p JXV=%p CT4=%p EJQ=%p ZBX=%p LFT=%p\n",
(void*)ARK, (void*)AJM, (void*)GMZ, (void*)JXV,
(void*)CT4, (void*)EJQ, (void*)ZBX, (void*)LFT);
fflush(stdout);
if (ARK) {
struct T { int32_t a, b, c; };
static const struct T trips[] = {
{1,1,1},{0,1,1},{13,1,1},{-1,1,1},{1,0,1},{1,13,1},{1,-1,1},
{1,1,2},{1,1,-1},{12,1,0},{1,12,0},{1,12,1},{1,6,6},{1,7,6}
};
for (unsigned i = 0; i < sizeof(trips) / sizeof(trips[0]); ++i) {
char id[32];
snprintf(id, sizeof(id), "K-%u-%d-%d-%d", i, trips[i].a, trips[i].b, trips[i].c);
step(id);
int rc = ARK(trips[i].a, trips[i].b, trips[i].c);
show_int(id, rc, 0, 0);
}
}
if (AJM) {
step("N1-ajm-nullnull");
int rc = AJM(0, 0);
show_int("N1_ajm_nn", rc, 0, 0);
step("N2-ajm-bufnull");
rc = AJM(g_buf, 0);
show_int("N2_ajm_bn", rc, 0, 0);
}
if (GMZ) {
step("O1-gmz-nullnull");
int rc = GMZ(0, 0);
show_int("O1_gmz_nn", rc, 0, 0);
step("O2-gmz-bufnull");
rc = GMZ(g_buf, 0);
show_int("O2_gmz_bn", rc, 0, 0);
}
if (JXV) {
step("P1-jxv-null");
int rc = JXV(0);
show_int("P1_jxv_null", rc, 0, 0);
}
if (CT4) {
step("Q1-ct4-null");
int rc = CT4(0, g_buf, 1, g_buf, 1);
show_int("Q1_ct4_null", rc, 0, 0);
step("Q2-ct4-nullsrc");
rc = CT4(g_buf, 0, 1, g_buf, 1);
show_int("Q2_ct4_nsrc", rc, 0, 0);
step("Q3-ct4-biglen");
rc = CT4(g_buf, g_buf, 0x1f4c, g_buf, 1);
show_int("Q3_ct4_big", rc, 0, 0);
step("Q4-ct4-nulldst");
rc = CT4(g_buf, g_buf, 1, 0, 1);
show_int("Q4_ct4_ndst", rc, 0, 0);
step("Q5-ct4-zeroN");
rc = CT4(g_buf, g_buf, 1, g_buf, 0);
show_int("Q5_ct4_zn", rc, 0, 0);
}
if (EJQ) {
step("R1-ejq-null");
int rc = EJQ(0, g_buf, 1, g_buf, 1, 50);
show_int("R1_ejq_null", rc, 0, 0);
step("R2-ejq-prio19");
rc = EJQ(g_buf, g_buf, 1, g_buf, 1, 19);
show_int("R2_ejq_p19", rc, 0, 0);
step("R3-ejq-prio101");
rc = EJQ(g_buf, g_buf, 1, g_buf, 1, 101);
show_int("R3_ejq_p101", rc, 0, 0);
}
if (ZBX) {
step("T1-zbx-null");
int rc = ZBX(0, g_buf, 1, g_buf, 1, 50);
show_int("T1_zbx_null", rc, 0, 0);
step("T2-zbx-prio19");
rc = ZBX(g_buf, g_buf, 1, g_buf, 1, 19);
show_int("T2_zbx_p19", rc, 0, 0);
}
step("LAST-ct4-allpass");
if (CT4) {
int rc = CT4(g_buf, g_buf, 1, g_buf, 1);
show_int("U1_ct4_pass", rc, 0, 0);
}
step("LAST-ejq-allpass");
if (EJQ) {
int rc = EJQ(g_buf, g_buf, 1, g_buf, 1, 50);
show_int("U2_ejq_pass", rc, 0, 0);
}
step("LAST-zbx-allpass");
if (ZBX) {
int rc = ZBX(g_buf, g_buf, 1, g_buf, 1, 50);
show_int("U3_zbx_pass", rc, 0, 0);
}
step("LAST-lft-buf");
if (LFT) {
int rc = LFT(g_buf);
show_int("U4_lft_buf", rc, 0, 0);
}
}
printf("TW1|DONE\n");
fflush(stdout);
return 0;
}tw2/main.c#include <ps5/kernel.h>
#include <dlfcn.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
typedef int (*EnabledFn)(const void* workaround, int32_t bit, int32_t* out);
typedef int (*Enabled2Fn)(const void* workaround, uint64_t selector, uint32_t bit, int32_t* out);
static unsigned char g_buf[0x80] __attribute__((aligned(8)));
static EnabledFn E;
static Enabled2Fn E2;
static int query(int32_t bit) {
int32_t out = -1;
int rc = E(g_buf, bit, &out);
if (rc != 0) return -1;
return out;
}
int main(void) {
printf("TW2|FW|0x%x\n", kernel_get_fw_version());
fflush(stdout);
void* lk = dlopen("libkernel_sys.sprx", RTLD_LAZY);
E = (EnabledFn)dlsym(lk, "sceKernelTitleWorkaroundIsEnabled");
E2 = (Enabled2Fn)dlsym(lk, "sceKernelTitleWorkaroundIsEnabled2");
printf("TW2|SYM|lk=%p E=%p E2=%p\n", lk, (void*)E, (void*)E2);
fflush(stdout);
memset(g_buf, 0xFF, sizeof(g_buf));
for (int32_t bit = 0; bit <= 0x7F; bit += 8) {
printf("TW2|ALLFF|%d|%d\n", (int)bit, query(bit));
fflush(stdout);
}
static const int32_t SAMPLES[] = {0, 1, 7, 8, 31, 32, 63, 64, 79, 95, 111, 120, 127};
for (unsigned w = 0; w < 11; ++w) {
printf("TW2|STEP|word%u\n", w);
fflush(stdout);
memset(g_buf, 0, sizeof(g_buf));
uint64_t word = ~(uint64_t)0;
memcpy(g_buf + w * 8, &word, 8);
for (unsigned s = 0; s < sizeof(SAMPLES) / sizeof(SAMPLES[0]); ++s) {
printf("TW2|W%u|%d|%d\n", w, (int)SAMPLES[s], query(SAMPLES[s]));
fflush(stdout);
}
}
memset(g_buf, 0, sizeof(g_buf));
printf("TW2|ZERO78|%d\n", query(0x78));
fflush(stdout);
memset(g_buf, 0xFF, sizeof(g_buf));
int32_t out = -1;
int rc = E2(g_buf, 0, 0x78, &out);
printf("TW2|E2FF|rc=0x%x|out=%d\n", (unsigned)rc, out);
fflush(stdout);
memset(g_buf, 0xFF, sizeof(g_buf));
g_buf[0] = 0;
printf("TW2|VER0|%d\n", query(0));
fflush(stdout);
printf("TW2|DONE\n");
fflush(stdout);
return 0;
} |
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — looks good
Nothing blocks this change; the reviewed implementation and boundary tests match the stated 0–0x7F range.
What I ran
Read the prepared diff and the changed implementation, tests, and debt entries at head 3bf4c2b1d9ae60411b468bc1058b77391e2b95d1. No commands or tests were run. The author reports 66/66 server tests and convention checks passed.
Results
| Check | Result | Note |
|---|---|---|
| Source review | passed | Changed behavior and callers inspected |
| Tests | not run | Author reports 66/66 passed |
| Negative control | not run | No assertion change run |
Findings
Blocking
None.
Non-blocking
None.
Not verified
No tests were run independently, and the reported console probes and test results were not independently verified. All three changed files were read: core/libs/prx/libkernel_sys/Export.cpp, core/libs/tests/GuestKernelSys.cpp, and docs/dev/debt/libkernel_sys.md. No files were excluded in the manifest.
To get this to a good state
Nothing is required.
|
Tested head Setup: Windows 11 Pro 10.0.26200, Ryzen 7 9800X3D, WinLibs GCC 15.2.0 r7, Release,
Whole batch: the full This is one combined tree, not a run of this PR alone. AI-assisted: yes (Claude Code) |
|
Closing this myself after a collision check found the change conflicts with merged work.
Data kept here for whoever folds next:
If a follow-up wants the newest-kernel behavior it needs a firmware-conditional limit with a boundary nobody has measured yet (somewhere in 12.x/13.x); I would rather see the pending 11.60 entry folded first and this documented as a version divergence. Apologies for the overlap - my due diligence checked open PRs, not pending fragments. |
|
Closing as superseded by the pending #22365-line fragment; version-divergence data preserved in my previous comment. |
What
QueryTitleWorkaroundrefused any bit above 0x78 withSCE_KERNEL_ERROR_EINVAL. A payload process on a PS5 Pro (firmware 13.60) accepted bits 0 to 0x7F inclusive - 0x79, 0x7a, 0x7d and 0x7f all returned 0 with the output written - and refused only 0x80, 0x81 and -1 unsigned, so the accepted range is 0 to 0x7F and the limit was off by seven. The same probe confirmed on the console the parts of the entry that were disassembly-only: null workaround and output pointers returnSCE_KERNEL_ERROR_EFAULT(0x8002000e) before the bit check, the misspelledsceKernelTitleWorkdaroundIsEnabledresolves to the same code, andsceKernelTitleWorkaroundIsEnabled2accepts selectors 0 and 0x28 while refusing 0x29, 0x2A and~0ull.A second probe located the bit storage: setting one 64-bit word at a time in a buffer lit bits 0-63 only from offset 8 and bits 64-0x7F only from offset 16, no other word had any effect, and zeroing the version field changed nothing. The
{version, align, ids[2]}layout is therefore confirmed, closing the "where title_workaround sits is unmeasured" clause;IsEnabled2reads the same words. The debt entries now state measured facts, and the tests pin 0x79 and 0x7E as clear and 0x7F as set (the fixture already sets bit 63 of the second word).Probe sources and raw session output are in the first comment. Measurement context:
kernel_get_fw_version=0x13600007, payload process loaded over elfldr (port 9021), sessions 2026-11-20T21:12Z and 21:30 UTC; a title process was not measured.Tested
tw1andtw2, one flushedSTEPline before every call, both exited by themselves; the libkernel_sys part oftw1is quoted in full in the first comment.guest_kernel_sysfamily - 66/66 tests passed with the change on01ac7c81be.python3 tools/check_conventions.py --base origin/main: passed.git diff --check: clean.python3 tools/pr_overlap.py --branch fix/libkernel-title-workaround-bit-limit: exit 0; it lists ten open PRs sharing these files without comparison, and each patch was then grepped - none touches the title workaround code, its tests or its debt entries (PR 18190 only renames_nid_postfixcall sites a few lines away).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)