Skip to content

docs(libSceAgc): record the values sceAgcAcbJumpGetSize and sceAgcAcbRewindGetSize returned on firmware 11.60 - #26730

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
xXPBSXx:docs/libsceagc-acb-jump-rewind-size-measured
Nov 24, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
xXPBSXx:docs/libsceagc-acb-jump-rewind-size-measured

Conversation

@xXPBSXx

@xXPBSXx xXPBSXx commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

What

The debt entries of sceAgcAcbJumpGetSize and sceAgcAcbRewindGetSize (silent stubs of libSceAgc, the code is in core/libs/prx/libSceAgc/Acb/src/Control.cpp) say that AnyPS5 returns 16 and 8 dwords as an estimate of the size of the jump and rewind command packets, and that "the console module's packet size is unmeasured". Both entries are in fragments that are not folded into libSceAgc.md yet: docs/dev/debt/changes/fix-libSceAgc-sceAgcAcbJumpGetSize-silent-stub.md and docs/dev/debt/changes/fix-libSceAgc-sceAgcAcbRewindGetSize-silent-stub.md. This pull request replaces the end of each entry (one line in each file, no code); a second fragment on the same entry would collide when they are folded, so the existing files are edited.

A PS5 payload process on firmware 11.60 loaded libSceAgc.sprx and libkernel.sprx (the loading of libSceAgc.sprx printed one line of the Agc driver, "Initialized", in the output), took both functions and a control name of the same module (sceAgcCbCondWriteGetSize) with dlsym (all three found; a name that does not exist was not found), and called them with the prototype int (void) assumed, at 15:36 UTC on 2026-11-24 (one run): sceAgcAcbJumpGetSize() three times, sceAgcAcbRewindGetSize() three times, and each of the two once more with the argument registers 0, 1, 2 and 3. sceAgcAcbJumpGetSize returned 16 in all four calls (lines 6 to 8 and 12 of the output) and sceAgcAcbRewindGetSize returned 8 in all four (lines 9 to 11 and 13); no call raised a signal. The control sceAgcCbCondWriteGetSize() returned 36 (line 5), the value an earlier run of the project had measured. No submit was made, no packet was written and no context was created.

I read the two functions in core/libs/prx/libSceAgc/Acb/src/Control.cpp on main 45fc4e2: sceAgcAcbJumpGetSize (line 50) returns 16 and sceAgcAcbRewindGetSize (line 70) returns 8. So the library returns the values the console returned; the library's own code was not run against these calls. A test pins the jump size at 16 (core/libs/prx/libSceAgc/tests/Commands.cpp, line 699); for the rewind size a test compares it with the size of the packet the library writes (line 1370), which does not fix its value.

What the two returned numbers do not show: the unit (dwords is assumed), the size of a packet that is written by the console's own sceAgcAcbJump or sceAgcAcbRewind (it was not measured, which is why the entries keep saying so), a title process, other firmware, and whether the prototype is the console's. Title use of the two functions is not established: the entries are silent stubs listed for completeness.

Tested

Measured on a PS5 with firmware 11.60 (kernel_get_fw_version 0x11600005), from a homebrew payload process (ps5-payload-sdk, elfldr) that loads libSceAgc.sprx and takes the functions with dlsym, on 2026-11-24 at 15:36 UTC (one run). A title process may differ. The probe source and the complete output are in the first comment.

Call (prototype int (void) assumed) PS5 payload process, firmware 11.60 Control.cpp read on main (not run)
sceAgcAcbJumpGetSize(), three calls 16, 16, 16 return 16;
sceAgcAcbRewindGetSize(), three calls 8, 8, 8 return 8;
both with the argument registers 0, 1, 2, 3 16 and 8 arguments not read

The change is 2 files, 1 line replaced in each, no code and no test. The entries go from 198 to 469 characters (jump) and from 201 to 471 characters (rewind), counted with the leading - as tools/check_conventions.py does, so both stay under the limit of 1000. I ran tools/check_conventions.py --base (with this title and this body) and tools/debt_fold.py --check on the merge of this head into main at 940402d (a merge commit made with git merge-tree, in a separate checkout): check_conventions passes and the merge has no conflict; debt_fold --check prints the same one finding on main itself and on the merge, about two fragments of libSceRudp (fix-rudp-unconnected-read-write.md and fix-rudp-net-received-checks.md, both on the same entry), and nothing about the two fragments of this change. This is a documentation change, so no GPU test applies. Not tested: the emulator against these calls, the size of a written packet, a title process, other firmware, and the cases listed above as not measured.

Overlap: counted on 2026-11-24 from 16:46 to 17:08 UTC, starting from the list of the 2495 open pull requests (file lists from the GitHub API; the 17 with 100 or more files were read in full through the files API) against main at 940402d; the 7 open pull requests that have one of the two fragment files or docs/dev/debt/libSceAgc.md (#12315, #17742, #19051, #19486, #20294, #20548 and #21376) were each merged with this branch and with main (git merge-tree), and the patches of the debt files and of the libSceAgc files of the 1787 open pull requests that change a file under docs/dev/debt/, a libSceAgc file or 100 or more files (read between 08:09 on 23 November and 17:08 UTC; the ones new or changed since 16:12 UTC on 23 November were read again today) were searched for sceAgcAcbJumpGetSize, sceAgcAcbRewindGetSize and the names of the two fragments. This change replaces one line in each of the two existing fragment files docs/dev/debt/changes/fix-libSceAgc-sceAgcAcbJumpGetSize-silent-stub.md and docs/dev/debt/changes/fix-libSceAgc-sceAgcAcbRewindGetSize-silent-stub.md (added by #20912 and #20913, merged on 15 November) and no code. No open pull request changes either fragment against main, and no open pull request changes the returned values of the two functions; of the 7, #19051 and #21376 merge cleanly with this branch and with main, and #12315, #17742, #19486, #20294 and #20548 conflict with main already. The two functions appear in patches only as unchanged context: of the pull requests whose patches show them, #21653, #22535, #22574, #22667 and #22712 merge cleanly with this branch and with main, #6743 (an AGC draft with 100 or more files) shows both functions in its patch against an older base but changes none of the Acb code or the two fragments against main (it merges cleanly), and #19486 and #20294 conflict with main already (#20294 adds lines after sceAgcAcbRewindGetSize in Control.cpp); none of their changed lines names either function or its returned value. A search of open and recently merged pull requests (since 15 November) for the two names finds only #20912 and #20913, which added the two fragments; the test of the packet sizes (#16987) is merged and in main. This pull request does not depend on any of them (Depends on: none).

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 and the licence notice of code adapted from upstream (see AGENTS.md)
  • 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 (documentation only)
  • AI-assisted: yes

…RewindGetSize returned on firmware 11.60

A PS5 payload process on firmware 11.60 returned 16 from
sceAgcAcbJumpGetSize and 8 from sceAgcAcbRewindGetSize in three calls
each, also with the argument registers 0, 1, 2, 3, which equals the
values AnyPS5 returns (run 2026-11-24T153625Z). The two existing
entries now say that the return value is measured and that the size of
a written packet is not.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@xXPBSXx

xXPBSXx commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

Probe source (built with ps5-payload-sdk; PROBE_BUILD is the first 12 hex digits of the source's SHA-256) and the complete raw output of the run on 2026-11-24 at 15:36 UTC. The utc in the PROBE line is the console's own clock, about 1 h 42 min ahead of real UTC; the time in the pull request is real UTC. The probe loads libSceAgc.sprx and libkernel.sprx, looks up the two functions, a control name of the module and a name that does not exist (expected not found) with dlsym, calls the control once, each of the two functions three times and each once more with the argument registers 0, 1, 2 and 3, every call guarded against signals. The pull request cites lines 5 to 13. The probe's internal number and case label were removed from the header comment and the code is unchanged; the build ID is the hash of the original file. An internal reference number of the control value (ledger no 125) stays in one description string of the code and in line 5 of the output, because the raw output cannot be changed; it has no meaning for the measurement.

Probe: probe.c (build c38a2500f3c7)
/* Probe: sceAgcAcbJumpGetSize and sceAgcAcbRewindGetSize of libSceAgc.sprx on firmware 11.60 (debt changes/fix-libSceAgc-sceAgcAcbJumpGetSize-silent-stub.md:5 and fix-libSceAgc-sceAgcAcbRewindGetSize-silent-stub.md:5: AnyPS5 returns 16 and 8 dwords, "the console module packet size is unmeasured"). Assumption of this probe: both exports take no argument and return an int (a size in dwords); the call needs no driver or context initialisation. Case 0: dlopen libSceAgc and libkernel, case 0b: dlsym of the two functions, the control sceAgcCbCondWriteGetSize (measured 36 in a payload process) and a negative control (expect not found). Case a: the control size getter once, case b: sceAgcAcbJumpGetSize three times in a row, case c: sceAgcAcbRewindGetSize three times in a row, case d: each of the two once more with the argument registers 0, 1, 2, 3 (the arguments are ignored if the contract holds). Each call is guarded; a fault ends the probe after the first one. No submit, no packet is written, no context is created. About 12 calls. */
#include <dlfcn.h>
#include <errno.h>
#include <pthread.h>
#include <signal.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <ps5/kernel.h>   /* only for kernel_get_fw_version() */

#ifndef PROBE_NAME
#define PROBE_NAME "unnamed"
#endif
#ifndef PROBE_BUILD
#define PROBE_BUILD "unbuilt"
#endif
/* Self limit: the runner can only close the connection, it cannot end the process on the console, so the probe ends
   itself after PROBE_MAX_S seconds at the latest (set by the build script). */
#ifndef PROBE_MAX_S
#define PROBE_MAX_S 50
#endif

static volatile int g_handle = -1;
static int (*volatile g_setmargins)(int, int, int) = 0; /* unused here */
static void reset_rate(void) {
  if (g_setmargins && g_handle >= 0) g_setmargins(g_handle, 0, 0);
}

static void probe_alarm(int sig) {
  static const char msg[] = "TIMEOUT\tprobe self limit\n";
  (void)sig;
  (void)!write(1, msg, sizeof msg - 1);
  reset_rate();
  _exit(124);
}

/* Watchdog thread: alarm()/SIGALRM does not help when the main thread hangs in a blocking system call or IPC. The
   thread sleeps PROBE_MAX_S seconds, writes TIMEOUT with write() and ends the process with _exit(124). alarm() stays
   as a second safeguard. */
static void* probe_watchdog(void* arg) {
  static const char msg[] = "TIMEOUT\tprobe watchdog thread\n";
  unsigned left = PROBE_MAX_S;
  (void)arg;
  while (left) left = sleep(left);
  (void)!write(1, msg, sizeof msg - 1);
  reset_rate();
  _exit(124);
  return 0;
}

static void probe_watchdog_start(void) {
  pthread_t t;
  if (pthread_create(&t, 0, probe_watchdog, 0) == 0) pthread_detach(t);
}

static int cases = 0;

static void probe_header(void) {
  char utc[32];
  time_t now = time(0);
  probe_watchdog_start();
  struct tm tmv;
  gmtime_r(&now, &tmv);
  strftime(utc, sizeof utc, "%Y-%m-%dT%H:%M:%SZ", &tmv);
  printf("PROBE\t%s\tfw=0x%08x\tbuild=%s\tpid=%d\tutc=%s\n", PROBE_NAME, kernel_get_fw_version(), PROBE_BUILD,
         getpid(), utc);
  fflush(stdout);
}

static void probe_case(const char* id, const char* call, long ret, int err, const char* extra) {
  printf("CASE\t%s\t%s\t%ld\t%d\t%s\n", id, call, ret, err, extra ? extra : "-");
  fflush(stdout);
  cases++;
}

static void probe_end(void) {
  printf("END\t%d\n", cases);
  fflush(stdout);
}



#include <setjmp.h>
#include <sys/mman.h>

typedef int (*fn_mprot)(void*, size_t, int);
static sigjmp_buf guard_env;
static volatile int guard_sig = 0, guard_active = 0, guard_hits = 0;
static void guard_handler(int s) {
  static const char msg[] = "FAULT" "\t" "guard" "\n";
  guard_sig = s;
  if (!guard_active || ++guard_hits > 8) { (void)!write(1, msg, sizeof msg - 1); _exit(125); }
  guard_active = 0;
  siglongjmp(guard_env, 1);
}
static int stopped = 0;
#define GUARDED(stmt) do { guard_sig = 0; if (sigsetjmp(guard_env, 1) == 0) { guard_active = 1; errno = 0; stmt; guard_active = 0; } else stopped = 1; } while (0)
static unsigned char pages[32768] __attribute__((aligned(16384)));
static char extra[400], id[16], label[140];

typedef int (*fn0)(void);
typedef int (*fn4)(long, long, long, long);

static void call0(const char* i, const char* l, fn0 f) {
  int rc = -77;
  GUARDED(rc = f());
  snprintf(extra, sizeof extra, "rc=%d hex=0x%x fault_signal=%d", rc, (unsigned)rc, (int)guard_sig);
  probe_case(i, l, rc, 0, extra);
}
static void call4(const char* i, const char* l, fn4 f, long a, long b, long c, long d) {
  int rc = -77;
  GUARDED(rc = f(a, b, c, d));
  snprintf(extra, sizeof extra, "rc=%d hex=0x%x fault_signal=%d", rc, (unsigned)rc, (int)guard_sig);
  probe_case(i, l, rc, 0, extra);
}

int main(void) {
  struct sigaction sa;
  memset(&sa, 0, sizeof sa);
  sa.sa_handler = guard_handler;
  sigaction(SIGSEGV, &sa, 0);
  sigaction(SIGBUS, &sa, 0);
  signal(SIGALRM, probe_alarm);
  alarm(PROBE_MAX_S);
  probe_header();
  errno = 0;
  void* ag = dlopen("libSceAgc.sprx", RTLD_LAZY);
  void* lk = dlopen("libkernel.sprx", RTLD_LAZY);
  snprintf(extra, sizeof extra, "libSceAgc=%d libkernel=%d", ag != 0, lk != 0);
  probe_case("0", "load libSceAgc.sprx and libkernel.sprx", ag ? 0 : -1, errno, extra);
  if (!ag) { probe_end(); return 0; }
  fn0 jump = (fn0)dlsym(ag, "sceAgcAcbJumpGetSize");
  fn0 rew = (fn0)dlsym(ag, "sceAgcAcbRewindGetSize");
  fn0 ctl = (fn0)dlsym(ag, "sceAgcCbCondWriteGetSize");
  void* neg = dlsym(ag, "sceAgcAcbNoSuchGetSizeProbeName");
  snprintf(extra, sizeof extra, "sceAgcAcbJumpGetSize=%d sceAgcAcbRewindGetSize=%d control_sceAgcCbCondWriteGetSize=%d negative_control=%d (1 found, 0 not found)", jump != 0, rew != 0, ctl != 0, neg != 0);
  probe_case("0b", "dlsym of the functions, the control and a negative control", (jump && rew) ? 0 : -1, 0, extra);
  if (ctl && !neg) call0("a", "control sceAgcCbCondWriteGetSize() once (ledger no 125: 36)", ctl);
  for (int k = 0; k < 3 && jump && !stopped; ++k) {
    snprintf(id, sizeof id, "b.%d", k + 1);
    call0(id, "sceAgcAcbJumpGetSize()", jump);
  }
  for (int k = 0; k < 3 && rew && !stopped; ++k) {
    snprintf(id, sizeof id, "c.%d", k + 1);
    call0(id, "sceAgcAcbRewindGetSize()", rew);
  }
  if (jump && !stopped) call4("d.1", "sceAgcAcbJumpGetSize with the argument registers 0, 1, 2, 3", (fn4)jump, 0, 1, 2, 3);
  if (rew && !stopped) call4("d.2", "sceAgcAcbRewindGetSize with the argument registers 0, 1, 2, 3", (fn4)rew, 0, 1, 2, 3);
  if (stopped) probe_case("4", "cases stopped after the first fault", 0, 0, "remaining cases skipped by design");
  probe_end();
  return 0;
}
Probe: stdout
PROBE	libSceAgc_acb_jump_rewind_size	fw=0x11600005	build=c38a2500f3c7	pid=539	utc=2026-11-24T17:18:22Z
[AgcDriver] Info - Initialized, submit.mode= 1. 
CASE	0	load libSceAgc.sprx and libkernel.sprx	0	2	libSceAgc=1 libkernel=1
CASE	0b	dlsym of the functions, the control and a negative control	0	0	sceAgcAcbJumpGetSize=1 sceAgcAcbRewindGetSize=1 control_sceAgcCbCondWriteGetSize=1 negative_control=0 (1 found, 0 not found)
CASE	a	control sceAgcCbCondWriteGetSize() once (ledger no 125: 36)	36	0	rc=36 hex=0x24 fault_signal=0
CASE	b.1	sceAgcAcbJumpGetSize()	16	0	rc=16 hex=0x10 fault_signal=0
CASE	b.2	sceAgcAcbJumpGetSize()	16	0	rc=16 hex=0x10 fault_signal=0
CASE	b.3	sceAgcAcbJumpGetSize()	16	0	rc=16 hex=0x10 fault_signal=0
CASE	c.1	sceAgcAcbRewindGetSize()	8	0	rc=8 hex=0x8 fault_signal=0
CASE	c.2	sceAgcAcbRewindGetSize()	8	0	rc=8 hex=0x8 fault_signal=0
CASE	c.3	sceAgcAcbRewindGetSize()	8	0	rc=8 hex=0x8 fault_signal=0
CASE	d.1	sceAgcAcbJumpGetSize with the argument registers 0, 1, 2, 3	16	0	rc=16 hex=0x10 fault_signal=0
CASE	d.2	sceAgcAcbRewindGetSize with the argument registers 0, 1, 2, 3	8	0	rc=8 hex=0x8 fault_signal=0
END	11

AI-assisted (Claude Code).

@github-actions github-actions Bot added the docs label Nov 24, 2026
@oneandonlydean
oneandonlydean merged commit 1f8b6a1 into boykopovar:main Nov 24, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants