diff options
| author | user <user@clank> | 2026-09-25 16:11:26 +0200 |
|---|---|---|
| committer | user <user@clank> | 2026-09-25 16:11:26 +0200 |
| commit | ef3524b12549e893dcc6409ded9d20ace3267569 (patch) | |
| tree | 37c49989e570fc43310c435cbfe15f4c138076db | |
| parent | Narrow ASD's registration failure to sub_D14AA4 returning 7 (diff) | |
| download | amd-psp-re-ef3524b12549e893dcc6409ded9d20ace3267569.tar.gz amd-psp-re-ef3524b12549e893dcc6409ded9d20ace3267569.tar.xz amd-psp-re-ef3524b12549e893dcc6409ded9d20ace3267569.zip | |
Clear the display-surface blocker: ASD registers when the platform-id byte is set
sub_D14AA4's 7 was a missing environment input, not a firmware defect. It calls
svc 0x8d, which in sOS is just `ldr r0,=0x80d0 ; ldrb r4,[r0]`, and then requires
1 <= id <= 0x35 before its per-platform tbb dispatch. Nothing writes 0x80D0:
exactly one literal reference exists in the whole sOS image and it is this
reader, with zero references in SYS_DRV and ASD. The byte comes from a boot stage
this emulator does not run, so it reads 0 and ASD always declined registration.
New harness psp_emu/harness/display_chain_e2e.py measures it:
platform id UNSET: LOAD_TA asd -> 0x7 dest2 = 0x00
platform id = 0x1: LOAD_TA asd -> 0x0 dest2 = 0x04
Both controls pass -- a valid id registers service 2, and leaving the byte at 0
reproduces the original failure, so the harness cannot pass by always
registering. Sweeping ASD's OWN accepted set (the 22 ids with distinct handlers
in its tbb table at 0xD14ACC) registers 21 of 22; only 0x18 is table-accepted yet
still refused, a firmware-side difference worth a later look.
Supplying the byte is modelling, not patching: it is an input an earlier stage
provides rather than a value firmware computes, every check including ASD's range
test and per-platform dispatch runs unmodified, and the value is swept over the
set ASD's own table defines rather than invented. Caveat recorded in both the doc
and the harness output: which id real Navi31 reports is still unknown.
Remaining for end-to-end: stage 2, driving HDCP cmd 0x0E through the now
registered service into the display RPCs. With ASD and HDCP both loaded the ring
does not reliably dispatch a third command -- one run reached the ASD dispatcher,
a rerun reached nothing, statuses read stale. That is ring plumbing, not
firmware, and it is the last step.
| -rw-r--r-- | psp_emu/harness/display_chain_e2e.py | 155 | ||||
| -rw-r--r-- | psp_out/ANGLE-DISPLAY-SINK-INPUT-SURFACE.md | 54 |
2 files changed, 209 insertions, 0 deletions
diff --git a/psp_emu/harness/display_chain_e2e.py b/psp_emu/harness/display_chain_e2e.py new file mode 100644 index 0000000..5914d94 --- /dev/null +++ b/psp_emu/harness/display_chain_e2e.py @@ -0,0 +1,155 @@ +#!/usr/bin/env python3 +"""End-to-end display chain in the emulator: ASD registration -> display RPCs. + +WHY THIS EXISTS + `psp_out/ANGLE-DISPLAY-SINK-INPUT-SURFACE.md` traced a five-link chain from + "can a monitor open attack surface" down to one blocker: + + display RPC surface reachable + <- dest 2 (SERVICE_ASD) registered in sOS's table @0xE4A8 + <- LOAD_TA asd returns 0, not 7 + <- ASD's 0xFFFF0002 registration succeeds + <- sub_D14AA4 returns 0 instead of 7 + + `sub_D14AA4` does: + + 00d14abc svc #0x8d ; -> sOS returns the byte at global 0x80D0 + 00d14abe subs r2, r0, #1 + 00d14ac2 movs r0, #7 ; default status + 00d14ac4 cmp r2, #0x34 + 00d14ac6 bhi -> return 7 ; id must satisfy 1 <= id <= 0x35 + 00d14ac8 tbb [pc, r2] ; per-platform handler + + and sOS's SVC 0x8D handler is just + + 0000627c ldr r0, =0x000080d0 + 0000627e ldrb r4, [r0] ; return that byte + + Nothing in sOS, SYS_DRV or ASD ever WRITES 0x80D0 (one literal reference in + the whole sOS image, and it is this reader). The byte is supplied by a boot + stage this emulator does not run, so it is 0 here and ASD always declines + registration. + +WHAT IS MODELLED, AND WHY THAT IS LEGITIMATE + This harness writes that one byte. It is an INPUT handed to sOS by an earlier + boot stage, not a result the firmware computes -- so supplying it models a + missing environment, in the same class as the measured SVC values in + `pspemu/services.py`. It is NOT a patch around firmware behaviour: every + check, including ASD's own 1..0x35 range test and its per-platform dispatch, + runs unmodified. + + The value is not invented either. ASD's own `tbb` table at 0xD14ACC defines + which ids it accepts: 22 of the 53 entries have distinct handlers + (0x1-0x5, 0x14-0x1b, 0x1d, 0x23-0x25, 0x2b, 0x2d, 0x31, 0x33, 0x35) and the + other 31 route to the error path. The harness sweeps that firmware-defined + set rather than guessing one. WHICH id is Navi31's is still UNKNOWN -- see + the caveat printed at the end. + +CONTROLS + positive : with a valid id, LOAD_TA asd must return 0 AND dest 2 must appear + in sOS's service table + negative : with the byte left at 0 (this emulator's normal state), LOAD_TA + asd must still return 7 and dest 2 must stay unregistered + Without the negative control a harness that always registers would look + identical to one that proved something. +""" +import os +import sys +import struct + +sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..")) +sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) + +import importlib.util # noqa: E402 +_s = importlib.util.spec_from_file_location( + "fs", os.path.join(os.path.dirname(os.path.abspath(__file__)), "full_system.py")) +FS = importlib.util.module_from_spec(_s); _s.loader.exec_module(FS) +BM, M = FS.BM, FS.M +from pspemu.oracle import Probe # noqa: E402 + +PLATFORM_ID_BYTE = 0x80D0 # sOS global returned by SVC 0x8D +SERVICE_TABLE = 0xE4A8 # sOS RPC service table; index 2 == SERVICE_ASD +ASD_VALID_IDS = (0x1, 0x2, 0x3, 0x4, 0x5, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, + 0x1a, 0x1b, 0x1d, 0x23, 0x24, 0x25, 0x2b, 0x2d, 0x31, 0x33, 0x35) + + +def boot(platform_id=None): + """Fresh boot; optionally supply the platform-id byte an earlier stage sets.""" + c, ccp, irqs, exc = BM.build() + run, _ = M.make_det_runner(c, irqs) + BM.drain_until(run, lambda: int.from_bytes(c.uc.mem_read(M.RING_STATUS, 4), "little") == 0x80000000, + slices=12, blocks=500_000) + M.install_debug_gpio(c) + box = M.Mailbox(c, irqs) + if platform_id is not None: + c.uc.mem_write(PLATFORM_ID_BYTE, bytes([platform_id])) + c.uc.mem_write(BM.RING_PA, b"\x00" * BM.RING_SZ) + rp = bytearray(0x1C) + rp[0x10:0x14] = struct.pack("<I", BM.RING_PA) + rp[0x18:0x1C] = struct.pack("<I", BM.RING_SZ) + box.submit(2, bytes(rp), timeout=12, runner=run) + ring = M.Ring(c, irqs, BM.RING_PA, BM.RING_SZ, BM.CMDBUF_PA, run) + return c, ring, run + + +def load_asd(platform_id): + """One observation on a fresh emulator: does ASD register as service 2?""" + c, ring, run = boot(platform_id) + img = FS.load_images()["asd_full.bin"] + for b in (FS.TA_IMAGE_PA, FS.TA_IMAGE_PA + M.Ring.ALIAS): + c.uc.mem_write(b, img) + ld = bytearray(0x20) + ld[0:4] = struct.pack("<I", FS.TA_IMAGE_PA) + ld[8:12] = struct.pack("<I", len(img)) + ring.submit(1, bytes(ld), timeout=10, probe=[]) + for _ in range(4): + run(2_000_000) + status = ring.response()[0] + table = bytes(c.uc.mem_read(SERVICE_TABLE, 16)) + return status, table[2], table + + +def main(): + print("Stage 1 -- ASD registration, the blocker for the whole display surface\n") + off_status, off_dest2, off_table = load_asd(None) + print(" platform id UNSET (this emulator's normal state):") + print(" LOAD_TA asd -> %#x dest2 = %#x table = %s" + % (off_status, off_dest2, off_table[:6].hex(" "))) + on_status, on_dest2, on_table = load_asd(ASD_VALID_IDS[0]) + print(" platform id = %#x (from ASD's own accepted set):" % ASD_VALID_IDS[0]) + print(" LOAD_TA asd -> %#x dest2 = %#x table = %s" + % (on_status, on_dest2, on_table[:6].hex(" "))) + print() + p = Probe("supplying the platform-id byte lets ASD register as service 2", + measure=lambda: (on_status, on_dest2, off_status, off_dest2), + positive=lambda: on_status == 0 and on_dest2 != 0, + negative=lambda: off_status == 0 or off_dest2 != 0, + positive_desc="with a valid id: LOAD_TA asd == 0 and dest 2 registered", + negative_desc="with no id: LOAD_TA asd still 7 and dest 2 unregistered") + rc = p.report(fmt=lambda v: "id set -> status %#x dest2 %#x | id unset -> status %#x dest2 %#x" % v) + if rc: + return rc + + print("\nStage 1b -- which of ASD's accepted ids actually register") + ok = [] + for pid in ASD_VALID_IDS: + st, d2, _ = load_asd(pid) + if st == 0 and d2: + ok.append(pid) + print(" %d/%d ids register: %s" % (len(ok), len(ASD_VALID_IDS), [hex(i) for i in ok])) + rejected = [hex(i) for i in ASD_VALID_IDS if i not in ok] + print(" ids ASD's table accepts but registration still refuses: %s" % (rejected or "none")) + + print() + print("CAVEAT, stated so this is not over-read: the platform id for THIS part") + print("(Navi31/gfx1100) is not known. Registration succeeding under a swept id") + print("shows the mechanism and unblocks the chain; it does not establish which") + print("id real silicon reports. Stage 2 (driving HDCP cmd 0x0E through the now") + print("registered service to the display RPCs) is not yet included -- the ring") + print("does not reliably dispatch a third command after two LOAD_TAs in this") + print("harness, and that is a plumbing question, not a firmware one.") + return 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/psp_out/ANGLE-DISPLAY-SINK-INPUT-SURFACE.md b/psp_out/ANGLE-DISPLAY-SINK-INPUT-SURFACE.md index 4332013..babcfc8 100644 --- a/psp_out/ANGLE-DISPLAY-SINK-INPUT-SURFACE.md +++ b/psp_out/ANGLE-DISPLAY-SINK-INPUT-SURFACE.md @@ -530,3 +530,57 @@ question — and it is one function deep, in code we hold. Every link verified by execution, no hardware involved. Note also that the sink model is *not* what unblocks this: ASD performs **zero** `svc 0x7b` register reads while handling the registration, measured across all 135 sites. + +--- + +# BLOCKER CLEARED: ASD registers once the platform-id byte is supplied + +`sub_D14AA4`'s 7 came from a missing environment input, not a firmware defect. + + 00d14abc svc #0x8d ; sOS returns the byte at global 0x80D0 + 00d14abe subs r2, r0, #1 + 00d14ac2 movs r0, #7 ; default + 00d14ac4 cmp r2, #0x34 + 00d14ac6 bhi -> 7 ; requires 1 <= id <= 0x35 + 00d14ac8 tbb [pc, r2] ; per-platform dispatch + +and sOS's SVC 0x8D handler is only + + 0000627c ldr r0, =0x000080d0 + 0000627e ldrb r4, [r0] + +**Nothing writes `0x80D0`** — one literal reference in the entire sOS image, and +it is this reader; zero references in SYS_DRV and ASD. The byte is handed to sOS +by a boot stage this emulator does not run, so it reads 0 and ASD always declined +registration. + +## Measured (`psp_emu/harness/display_chain_e2e.py`) + + platform id UNSET: LOAD_TA asd -> 0x7 dest2 = 0x00 table 00 01 00 ... + platform id = 0x1: LOAD_TA asd -> 0x0 dest2 = 0x04 table 00 01 04 ... + +Both controls pass: a valid id registers service 2, and with the byte left at 0 +the failure reproduces exactly. Sweeping ASD's **own** accepted set (the 22 ids +with distinct handlers in its `tbb` table at 0xD14ACC), **21 of 22 register**; +only `0x18` is accepted by the table yet still refused, which is a real +firmware-side difference worth a later look. + +## Why supplying that byte is modelling, not patching + +It is an input an earlier boot stage provides, not a value the firmware computes — +the same class as the measured SVC returns in `pspemu/services.py`. Every check +runs unmodified, including ASD's 1..0x35 range test and its per-platform +dispatch. And the value is not invented: it is swept over the set ASD's own table +defines. + +**Caveat:** which id real Navi31 silicon reports is still UNKNOWN. Registration +under a swept id demonstrates the mechanism and unblocks the chain; it does not +identify the true id. + +## Remaining for end-to-end + +Stage 2 — driving HDCP cmd 0x0E through the now-registered service into the +display RPCs — is not yet in the harness. With ASD and HDCP both loaded, the ring +does not reliably dispatch a third command (one run reached the ASD dispatcher, +a rerun reached nothing, statuses read stale). That is ring plumbing, not +firmware, and it is the last step. |
