#!/usr/bin/env python3 """Command-surface fuzz across the twelve TAs, on silicon. Everything before this was static or emulated. The emulator was shown to produce false positives for these TAs (one fault refuted on hardware), so this runs the real thing. For each TA: LOAD, then for each command id, invoke with several payload profiles and record (status, first 32 bytes out). Flags anything that is not one of the two benign outcomes (0x0 accepted / 0xffff0000 id rejected), plus any case where a TA's response to a FIXED probe command changes after some other command ran -- that is the signature of state corruption. Controls: * a benign profile must produce the same statuses as the six-TA differential already recorded (OC 0->0, AUC 0->0xffff0000, ...); if not, the harness is wrong; * the fixed re-probe after each command detects harness-induced drift too. Safety: ordinary INVOKEs. XGMI is the only TA that emits SYS_DRV opcode 0xd and it is included -- but with a zeroed staging path the 0xd handler takes its bounded branch, which is what the emulation and the static reading both show. """ import argparse, glob, os, struct, sys, time PROFILES = { 'zero': lambda b: None, 'big': lambda b: [struct.pack_into('>32; t.app_len=len(blob) t.cmd_buf_phy_addr_lo,t.cmd_buf_phy_addr_hi = cmc&0xFFFFFFFF, cmc>>32; t.cmd_buf_len=0x8000 try: r=psp._ring_submit(c); return r.resp.status&0xFFFFFFFF, r.resp.session_id, cp except Exception as e: try: return int(str(e).strip().split()[-1])&0xFFFFFFFF, None, cp except Exception: return -1, None, cp def invoke(sid, shm, cid, prof): buf = bytearray(0x2000); struct.pack_into(' 2.0: odd.append((cid,prof,'SLOW %.1fs'%dt)) r2, rout = invoke(sid, shm, 0, 'zero') if (r2, rout) != (ref_st, ref_out): drift.append((cid, hex(r2), rout[:8].hex())) unload(sid) print('%-10s odd=%-3d drift=%-3d %s' % (name, len(odd), len(drift), (odd[:3] if odd else '') if odd else ('DRIFT %s'%drift[:3] if drift else 'clean'))) if odd or drift: anomalies.append((name, odd, drift)) print('\nTAs with anomalies: %s' % ([n for n,_,_ in anomalies] or 'NONE')) for n,odd,drift in anomalies: print(' %s odd(%d): %s'%(n,len(odd),odd[:8])) print(' %s drift(%d): %s'%(n,len(drift),drift[:8])) return 0 if __name__=='__main__': sys.exit(main())