Skip to content

docs(libSceAgcDriver): record the measured null argument answer of sceAgcDriverGetRegShadowInfo - #23451

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
xXPBSXx:docs/libsceagcdriver-regshadow-null-measured
Nov 19, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
xXPBSXx:docs/libsceagcdriver-regshadow-null-measured

Conversation

@xXPBSXx

@xXPBSXx xXPBSXx commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

What

The sceAgcDriverGetRegShadowInfo and sceAgcDriverGetRegShadowInfoAgr entry in docs/dev/debt/libSceAgcDriver.md (line 66) says that a null argument returns 0x8A6D0003 before anything else is read, as firmware 13.42's module does, "read to the return, disassembly only, not measured on a console". A probe on a PS5 with firmware 11.60, from a payload process, called both functions with a null argument and each returned 0x8A6D0003 without a fault (cases 1 and 2, lines 5 and 6 of the raw output). The entry now says that for firmware 11.60. The rest of the entry, the path that depends on the driver context (0x8A6D0001 when its field at +8 is nonzero, otherwise a 0x28-byte record) and the throwing of every other call, is not measured: the probe passes no other argument. Loading libSceAgcDriver.sprx runs the module's constructor, which the probe cannot influence, and the raw output shows [AgcDriver] Info - Initialized, submit.mode= 1. (line 2). Only this one entry changes, as a new fragment in docs/dev/debt/changes/; no code does.

AnyPS5 returns the same: both functions return 0x8A6D0003 for a null argument (core/libs/prx/libSceAgcDriver/Export.cpp lines 36 and 37 and 41 and 42).

Tested

Measured on a PS5 with firmware 11.60 (kernel_get_fw_version 0x11600005, line 1 of the raw output), from a homebrew payload process, on 2026-11-19 at 00:34 UTC (the console's own clock in the PROBE line reads 02:16:21Z, 1 h 42 min ahead of the runner's clock). A title process may differ. The cases are 0 to 2, lines 3 to 6 of the raw output in the first comment; the control sceAgcDriverIsEsvmProcess was looked up and not called (line 4).

Call PS5, payload process, firmware 11.60 AnyPS5 (source, not run) here
sceAgcDriverGetRegShadowInfo(NULL) 0x8A6D0003, no fault (line 5) 0x8A6D0003 (Export.cpp line 37) entry states it is measured
sceAgcDriverGetRegShadowInfoAgr(NULL) 0x8A6D0003, no fault (line 6) 0x8A6D0003 (Export.cpp line 42) entry states it is measured

The line numbers of Export.cpp are those of main at f7f560c. tools/check_conventions.py reports no error on the branch and debt_fold --check returns 0; the changed entry is 990 characters without the list marker. This is a documentation change, so no test was added or run. Not tested: Linux, macOS, the CI runner, a title process, a non-null argument, and firmware other than 11.60.

Overlap: counted on 2026-11-19 at 02:09 UTC from the 2003 open pull requests (file lists from the GitHub API; the ten with 100 or more files were read in full through the files API; the patches of the 1091 pull requests that change a file under docs/dev/debt/ or the cited source file were searched for sceAgcDriverGetRegShadowInfo and sceAgcDriverGetRegShadowInfoAgr) against main at f7f560c. This pull request adds one file, docs/dev/debt/changes/docs-libsceagcdriver-regshadow-null-measured.md, and no code; no open pull request has a file of that name. No open pull request changes core/libs/prx/libSceAgcDriver/Export.cpp, and no patch of the open pull requests names the two functions. About a hundred open pull requests change docs/dev/debt/libSceAgcDriver.md, and #20447, #20406, #20001 and #19999 add libSceAgcDriver fragments about other output-pointer probes; none touches the entry of the two functions (line 66). A search of the open pull requests for the function names finds nothing. 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
  • 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 (no graphics change)
  • AI-assisted: yes

…eAgcDriverGetRegShadowInfo

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

xXPBSXx commented Nov 19, 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, 15157d3ff206) and its raw output from the run of 2026-11-19 at 00:34 UTC (runner clock). The clock in the PROBE line is the console's own clock. In the first line of the header comment an internal label (N2) was removed; nothing else differs from the original, and the build ID is the hash of the original file.

probe.c
/* Probe: sceAgcDriverGetRegShadowInfo and sceAgcDriverGetRegShadowInfoAgr with a null argument only (debt libSceAgcDriver.md:66: a null argument returns 0x8A6D0003 before anything else is read, as the libSceAgcDriver of firmware 13.42 does (read in disassembly, not measured on a console); every other call throws; in the module the other path depends on the driver context that the module constructor fills at load, when its field at +8 is nonzero the call returns 0x8A6D0001, otherwise it copies a 0x28-byte register-shadow record). Payload process, firmware 11.60 (a title process may differ). The module is opened with dlopen("libSceAgcDriver.sprx") (its constructor runs, which the probe cannot influence), every name is looked up with dlsym first (both functions and the control name sceAgcDriverIsEsvmProcess, which is only looked up and never called). Each of the two functions is called exactly once, the first argument NULL and the others zero, never with a valid pointer, nothing in the driver state is changed. A fault is caught by a guard (one hit per case, more than eight end the probe with _exit(125)); a fault is a result and the calls stop after the first fault. Nothing is written to a file, nothing is sent, no service is initialised by the probe. */
#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>

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 char extra[400];

typedef uint32_t (*fn_rs)(void*, void*, void*, void*);

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* dr = dlopen("libSceAgcDriver.sprx", RTLD_LAZY);
  snprintf(extra, sizeof extra, "libSceAgcDriver=%d", dr != 0);
  probe_case("0", "load libSceAgcDriver.sprx", dr ? 0 : -1, errno, extra);
  if (!dr) { probe_end(); return 0; }
  fn_rs f1 = (fn_rs)dlsym(dr, "sceAgcDriverGetRegShadowInfo");
  fn_rs f2 = (fn_rs)dlsym(dr, "sceAgcDriverGetRegShadowInfoAgr");
  void* ctl = dlsym(dr, "sceAgcDriverIsEsvmProcess");
  snprintf(extra, sizeof extra, "sceAgcDriverGetRegShadowInfo=%d sceAgcDriverGetRegShadowInfoAgr=%d control_IsEsvmProcess_not_called=%d", f1 != 0, f2 != 0, ctl != 0);
  probe_case("0b", "dlsym of the functions", 0, 0, extra);

  uint32_t rc = 0xDEADBEEFu;
  if (f1) {
    GUARDED(rc = f1(0, 0, 0, 0));
    snprintf(extra, sizeof extra, "rc=0x%08x fault_signal=%d", rc, (int)guard_sig);
    probe_case("1", "sceAgcDriverGetRegShadowInfo(NULL)", (long)rc, 0, extra);
  }
  if (f2 && !stopped) {
    rc = 0xDEADBEEFu;
    GUARDED(rc = f2(0, 0, 0, 0));
    snprintf(extra, sizeof extra, "rc=0x%08x fault_signal=%d", rc, (int)guard_sig);
    probe_case("2", "sceAgcDriverGetRegShadowInfoAgr(NULL)", (long)rc, 0, extra);
  }
  if (stopped) probe_case("3", "calls stopped after the first fault", 0, 0, "remaining calls skipped by design");
  probe_end();
  return 0;
}
raw output (stdout)
PROBE	libSceAgcDriver_regshadow_null	fw=0x11600005	build=15157d3ff206	pid=364	utc=2026-11-19T02:16:21Z
[AgcDriver] Info - Initialized, submit.mode= 1. 
CASE	0	load libSceAgcDriver.sprx	0	3	libSceAgcDriver=1
CASE	0b	dlsym of the functions	0	0	sceAgcDriverGetRegShadowInfo=1 sceAgcDriverGetRegShadowInfoAgr=1 control_IsEsvmProcess_not_called=1
CASE	1	sceAgcDriverGetRegShadowInfo(NULL)	2322399235	0	rc=0x8a6d0003 fault_signal=0
CASE	2	sceAgcDriverGetRegShadowInfoAgr(NULL)	2322399235	0	rc=0x8a6d0003 fault_signal=0
END	4

@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.

Reviewed — no blocking findings

The documentation fragment matches the measured null-call results and the implementation; no blocking defect was verified.

What I ran

Reviewed head d04a7283b4794fc1255137484e49c9a273c37e4c. Read the PR description, commit message, manifest, diff, changed fragment, and relevant technical-debt entry and export implementation through repo_read.py. No commands or tests were run; the check results in the description are author-reported.

Results

Check Result Note
Changed-line review passed All four added lines read
Documentation checks not run Reported by author only
Tests not applicable Documentation-only change

Negative control

Not run; this documentation-only change adds no test.

Findings

Blocking

None.

Non-blocking

None.

Sources

The fragment records the two null-call results and explicitly limits the measurement to firmware 11.60 in a payload process. The implementation returns 0x8A6D0003 for null in both functions and sends non-null calls to NotImplemented_nid_no_patch (core/libs/prx/libSceAgcDriver/Export.cpp, lines 36–43). The existing debt entry it updates is docs/dev/debt/libSceAgcDriver.md, line 66.

Not verified

No excluded changed files; the manifest lists one changed file and it was read in full. I did not independently verify the console probe, the author's reported convention and debt-fold checks, title-process behavior, non-null console behavior, or behavior on other firmware versions.

To get this to a good state

Nothing is required. The console measurement and check results are author-reported, not independently verified.

@github-actions github-actions Bot added the docs label Nov 19, 2026
@oneandonlydean
oneandonlydean merged commit 632bb53 into boykopovar:main Nov 19, 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.

3 participants