[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-116624":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":15,"stars7d":14,"stars30d":14,"stars90d":16,"forks30d":16,"starsTrendScore":17,"compositeScore":18,"rankGlobal":10,"rankLanguage":10,"license":19,"archived":20,"fork":20,"defaultBranch":21,"hasWiki":22,"hasPages":20,"topics":23,"createdAt":10,"pushedAt":34,"updatedAt":35,"readmeContent":36,"aiSummary":37,"trendingCount":16,"starSnapshotCount":16,"syncStatus":38,"lastSyncTime":39,"discoverSource":40},116624,"ps5-kernel-qemu","R0nov4\u002Fps5-kernel-qemu","R0nov4","Research harness for booting the PlayStation 5 (13.60) kernel in QEMU, reaching complete SYSINIT execution and SceSwapper idle state.","",null,"Python",55,9,3,1,0,5,46.8,"MIT License",false,"main",true,[24,25,26,27,28,29,30,31,32,33],"freebsd","freebsd-kernel","kernel-research","osdev","playstation-5","ps5","ps5-kernel","qemu","reverse-engineering-","sysinit","2026-11-06 19:18:02","2026-11-22 21:38:13","\u003Cdiv align=\"center\">\n\n# 🎮 PS5 13.60 Kernel → QEMU Boot Kit\n\n### Booting Sony's unmodified Orbis OS kernel (FreeBSD-derived, OS 13.60) inside a plain x86-64 QEMU virtual machine —\n### with a hand-built multiboot loader, 676 in-memory patches, and a reproducible chain of 50+ crash-site guards.\n\n![target](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Ftarget-PS5%20Orbis%2013.60-0b1f3a?style=for-the-badge)\n![host](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Fhost-QEMU%20TCG%20%C2%B7%20x86--64-1f6feb?style=for-the-badge)\n![image](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Fkernel__raw.bin-65%2C224%2C704%20B-8250df?style=for-the-badge)\n![status](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Fstatus-late%20SYSINIT%20%C2%B7%20crash--free%20log-2da44e?style=for-the-badge)\n![md5](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Fimage%20md5-520808c9…-lightgrey?style=for-the-badge)\n\n**[TL;DR](#-tldr) · [Status](#-status-at-a-glance) · [Quickstart](#-quickstart) · [Architecture](#-architecture) · [Deep dive](#-technical-deep-dive) · [Patch methodology](#-patch-methodology-caves-slots-seeds) · [Timeline](#-work-package-timeline-wp1--wp32) · [Layout](#-repository-layout) · [Integrity](#-integrity--reproducibility) · [Caveats](#-known-limitations--honest-caveats) · [Next steps](#-next-steps--triage-playbook)**\n\n\u003C\u002Fdiv>\n\n---\n\n## 📌 TL;DR\n\nThis repository is a *research snapshot*: a complete, reproducible toolchain that takes the public\nPS5 13.60 live kernel dump and gets Sony's real kernel to run its own `mi_startup()` SYSINIT march — banner,\nmemory-mode table, ~1000 sysctl registrations, CPU\u002FAPIC\u002FACPI enumeration, device-module wave, filesystem\nregistration, timecounters, TCP\u002FIP init — on a stock QEMU `-M pc -cpu EPYC` machine. Nothing here emulates the PS5's\nSoC; the kernel is booted *as an x86-64 FreeBSD kernel* and every place where it expects real PS5 hardware or\nloader state is either neutralised, seeded, or answered by a tiny hand-assembled code cave.\n\n\u003Cdiv align=\"center\">\n\n![Sony's own kernel banner printed on the serial console](docs\u002Fimg\u002Fboot-banner.png)\n\n*Sony's real kernel printing its own banner, build ID and memory mode inside QEMU.*\n\n\u003C\u002Fdiv>\n\n### ⚡ 30-second start\n\n```bash\n# 1) unpack (the archive uses the BCJ2 filter: needs 7z \u002F 7zz \u002F p7zip, py7zr cannot extract it)\n7z x ps5-13_60-qemu-boot-ultra.7z -o ps5-13.60-qemu-boot && cd ps5-13.60-qemu-boot\n\n# 2) install QEMU (Debian\u002FUbuntu)\nsudo apt install -y qemu-system-x86\n\n# 3) boot (240 s cap; stops by itself after 45 s of serial silence); full output lands in serial.log\nbash run.sh 240\n```\n\nOnly `qemu-system-x86_64` is required — the BIOS files (`bios\u002F`), the loader (`wp3_boot\u002Ftrampoline.elf`) and the\npatched kernel image (`wp3_boot\u002Fkernel_raw.bin`) ship inside the archive.\n\n---\n\n## 📊 Status at a glance\n\n| Item | Value |\n|---|---|\n| **Shipped kernel image** | `wp3_boot\u002Fkernel_raw.bin` — **md5 `520808c90b58241f454baeae0db0c8cc`** (verified while preparing this README), exactly **65,224,704 bytes** |\n| **Cumulative patch level** | WP1 → **WP32** (per `scripts\u002Fapply_all_wp1_to_wp32_patches.py`); documented in the worklog up to **WP29**, with WP30\u002F31 (G52–G54) documented in the script headers |\n| **Trampoline (loader) patches** | **676** in-memory patches (`wp3_boot\u002Fpatches.inc`, `PATCH_COUNT equ 676`) applied *after* the image is copied to RAM |\n| **Latest boot log** | `serial.log` — **1,436 lines**, no `Fatal trap` \u002F `panic:` line anywhere in it |\n| **Last line of the log** | `sx_slock(allproc): SceSwapper has nonsleeping lock` (current frontier; see [Next steps](#-next-steps--triage-playbook)) |\n| **Furthest landmarks reached** | `Device configuration finished.` · `Timecounters tick every 1.000 msec` · `ipfw2 (+ipv6) initialized` · `Timecounter \"TSC-low\" … quality 1000` |\n| **SYSINIT stages** | 1,235 unique stages after reconstruction (1,236 slots incl. terminator); last documented march: stages up to ≈ #1339 (`WP23: sysinit walk complete; parking.` is the designed park point) |\n| **Machine** | `qemu-system-x86_64 -M pc -cpu EPYC -m 2G -smp 8`, **TCG** (no KVM required) |\n| **Console path** | kernel `putc` → patched to `out 0x402` → QEMU `isa-debugcon` → `serial.log` |\n\n### 🗺 Boot-log anatomy (line numbers refer to the shipped `serial.log`)\n\n| Line | Landmark | Meaning |\n|---:|---|---|\n| 1 – 112 | SeaBIOS, PCI probing, `Relocating init…` | Firmware stage; the kit bundles SeaBIOS + option ROMs in `bios\u002F` |\n| 113 – 114 | `PS5-TRAMPOLINE: booting 13.60 kernel` → `entering long mode -> btext 0xffffffff9e642a90` | Our multiboot loader hands over to Sony's real cold entry point |\n| 136 – 144 | `SIE CONFIDENTIAL`, copyright, `r229358\u002Freleases\u002F13.60 Jul 17 2026 … amd64`, `mDBG: Kernel Build ID = 99dd70d51abadddd` | **First real Sony banner** |\n| 145 – 163 | `Memory mode: 1: PPR16 (GDDR6 : 16 GiB, DDR5 : 0 GiB)` + memory profile table | App 256 MiB, FS-cache 140 MiB, direct 64 MiB, vision 32 MiB (profile sizes shrunk to fit the VM) |\n| 164 – 1162 | **999** × `can't re-use a leaf (…)!` (from `swap_avail` … to `randompid`) | sysctl-tree registration storm (duplicate-leaf noise from the static image) |\n| 1163 | `Preloaded elf kernel \"kernel\" at 0xffffffffa2224000.` | Preload-metadata chain (modulep) parsed |\n| 1164 – 1191 | `CPU: AMD EPYC Processor`, `Hypervisor: Origin = \"TCGTCGTCGTCG\"`, `CPU Features: SMAP Enabled`, `Event timer \"LAPIC\" quality 400`, `ACPI APIC Table: \u003CBOCHS BXPC>`, `FreeBSD\u002FSMP: …` | CPU\u002Fcache identification, LAPIC event timer, ACPI\u002FMADT, SMP enumeration |\n| 1206 – 1208 | `lapic: Routing NMI -> LINT1 …` | IOAPIC\u002FLAPIC setup complete |\n| 1229 – 1230 | `contigmalloc failed.` \u002F `MOD_LOAD (pfsmgr …) error 12` | Designed ENOMEM tolerance — first of many `error 12` module prints |\n| 1260 | `hdcp packet is set to 1` | WP20\u002FWP21 landmark (hypervisor settle-wait removed, G16) |\n| **1384** | **`Device configuration finished.`** | WP22 landmark (sysinit sub 0x14) |\n| 1385 – 1390 | `mca taskq` \u002F `camera` error-12 prints, `acm: Failed to initialize module.` (error 5), `[BAPM] C0 wc param` | Post-landmark stages #1184+ |\n| 1391 – 1405 | 15 × `MOD_LOAD (\u003Cfs>) error 17` — tmpfs, exfatfs, nullfs, mlfs, nsfs, ufs, pfs, udf2, ppr_pfs, transaction_pfs, bfs, transactionfs, cd9660, devfs, unionfs | EEXIST double-registration noise (the image statically pre-registers its filesystems) |\n| 1406 – 1414 | `lapic: calib failed(…)` ×3 → `Timecounters tick every 1.000 msec` → `Session ID: 000…0` → `tcp_init … tcbhashsize auto tuned to 512` | Late-boot stages (WP27 era) |\n| 1415 – 1430 | `ipfw2 (+ipv6) initialized`, `if_attachdomain1 called more than once on lo0`, `fake a53io ctrlr is loaded.`, `srtc` error 45, `failed to kick bufdaemon`, `invalid tsc freq` | Post-G53 stages |\n| 1431 | `Timecounter \"TSC-low\" frequency 12500000 Hz quality 1000` | Passed the TSC-low registration (sysinit #1328, G54) |\n| 1432 – 1436 | `a53mm … error 16`, `cdinit_proc kproc_create fail.`, `sceSblServiceSysMailSend 1073774592`, **`sx_slock(allproc): SceSwapper has nonsleeping lock`** | **Current frontier** |\n\n\u003Cdiv align=\"center\">\n\n![The Device configuration finished landmark in serial.log](docs\u002Fimg\u002Fdevice-config-finished.png)\n\n*Landmark at line 1,384: `Device configuration finished.`*\n\n\u003C\u002Fdiv>\n\n> **How to read the noise.** FreeBSD errno values: `error 12` = `ENOMEM`, `error 17` = `EEXIST`, `error 45` = `EOPNOTSUPP`,\n> `error 16` = `EBUSY`, `error 5` = `EIO`. In this kit almost every kthread\u002Fkproc creation and many allocations *deliberately* fail with ENOMEM\n> (the \"ENOMEM era\"), and the kernel's own error paths are what carry the boot forward. These are expected, not regressions.\n\n---\n\n## 🚀 Quickstart\n\n### Requirements\n\n| Tool | Needed for | Notes |\n|---|---|---|\n| `qemu-system-x86_64` ≥ 6 | all paths | BIOS roms are bundled in `bios\u002F` (used via `-L .\u002Fbios`) |\n| `7z` \u002F `7zz` \u002F `p7zip` | unpacking the archive | The archive uses the **BCJ2** filter — `py7zr` cannot extract it |\n| `bash`, `curl`\u002F`wget`, `gzip` | path B | to fetch the public dump |\n| `python3` (stdlib) | paths B\u002FC\u002FD | `capstone` + `keystone` only if you want to *re-run analysis\u002Fpatch scripts* |\n| `nasm`, `ld` (binutils) | path C | rebuilds the trampoline from `scripts\u002Ftrampoline.asm` |\n| `gdb` ≥ 12 | optional | `gdb\u002F` sessions attach to QEMU's gdbstub |\n\n```bash\n# Debian \u002F Ubuntu — everything in one go\nsudo apt install -y qemu-system-x86 p7zip-full nasm binutils python3 curl gzip gdb\npython3 -m pip install --user capstone keystone-engine      # only for analysis \u002F re-patching scripts\n```\n\n### Path A — boot the prebuilt image (fastest)\n\n```bash\nbash run.sh 240\n```\n\n`run.sh` auto-detects QEMU, wipes the old `serial.log`, boots, and **stops early after 45 s without new serial output**\n(once the log is > 200 bytes), then prints the last 25 lines. If `wp3_boot\u002Fkernel_raw.bin` is missing it calls\n`fetch_and_build.sh` (Path B) automatically.\n\n### Path B — rebuild the kernel image from the public dump\n\n```bash\nbash fetch_and_build.sh\n```\n\nWhat it does: downloads `kernel-13.60-live.bin.gz` from the public GitHub repo (with a Git-LFS media-endpoint fallback),\ndecompresses it, and runs `build_kernel.py`, which verifies the **base md5** `ca43f306298bab963974f2c2b028f4b8`,\napplies a zlib+base64-packed byte-diff, and asserts the **target md5** `520808c90b58241f454baeae0db0c8cc`.\nIf the image already verifies, it exits immediately (\"Nothing to do\").\n\n### Path C — rebuild from the reconstructed ELF (the WP2 → WP3 original flow)\n\n```bash\nsudo apt install -y qemu-system-x86 nasm binutils python3\nbash scripts\u002Frun_local.sh 150 .\u002Fps5_kernel_1360_reconstructed.elf\n```\n\nFlow: `make_kernel_raw.py` (ELF → flat physical image) → `nasm -f elf32` + `ld -m elf_i386 -T wp3_boot\u002Ftramp.ld`\n(trampoline, 676 patches) → `qemu-system-x86_64` TCG boot, console on debugcon `0x402` →\n`wp3_boot\u002Fserial.log`. The ELF itself (62.2 MiB, sha256 `e87dbe643e285d0b59a18c926fc0eb1a20f3157ea99cde6d2e7ade5ea7b17cae`)\nis **not** in this archive.\n\n### Path D — move an existing WP29 image forward (WP29 → WP31)\n\n```bash\ncp \u002Fpath\u002Fto\u002FWP29\u002Fkernel_raw.bin wp3_boot\u002Fkernel_raw.bin      # md5 e9cccbeb03f468c4708d53361fbde1f6\npython3 scripts\u002Fwp31_build_from_wp29.py                      # idempotent; byte-verifies every patch site\nbash run.sh 240\n```\n\nChain: `WP29 e9cccbeb… ──G52──▶ WP30 706ec1ee… ──G53+G54──▶ WP31 c85632c9…`. The script refuses to write anything\nif the input md5 is not the expected WP29 base.\n\n### The QEMU command line (copy-paste ready)\n\n```bash\nqemu-system-x86_64 -L .\u002Fbios \\\n  -M pc -cpu EPYC -m 2G -smp 8 \\\n  -kernel wp3_boot\u002Ftrampoline.elf \\\n  -initrd wp3_boot\u002Fkernel_raw.bin \\\n  -display none -serial null -monitor none \\\n  -chardev file,id=dbg,path=serial.log \\\n  -device isa-debugcon,iobase=0x402,chardev=dbg \\\n  -no-reboot\n```\n\n| Piece | Role |\n|---|---|\n| `-M pc -cpu EPYC` | i440fx PC with Zen-family CPUID (the kernel identifies as `AMD EPYC Processor`) |\n| `-kernel …\u002Ftrampoline.elf` | our multiboot ELF32 loader, linked at `0x100000` |\n| `-initrd …\u002Fkernel_raw.bin` | delivered as a multiboot *module*: the flat 62.2 MiB kernel image |\n| `-serial null -monitor none -display none` | headless; the real UART is intentionally unused |\n| `-chardev file … -device isa-debugcon,iobase=0x402` | console sink — the kernel's patched `putc` writes to I\u002FO port `0x402` |\n| `-no-reboot` | a triple fault ends the run instead of reboot-looping |\n\n**Why these particular values**\n\n| Flag | Why it matters |\n|---|---|\n| `-cpu EPYC` | Zen-family CPUID\u002Ffeature bits (the kernel identifies as `AMD EPYC Processor`); `CPU Features: SMAP Enabled` |\n| `-m 2G` | The app-memory carve base was patched from 4 GiB to 1 GiB (WP5, root-cause #7); profiles then carve exactly `[1 GiB, 2 GiB)`. SMAP top is `0x80000000` |\n| TCG (no `-enable-kvm`) | Unknown MSRs read as 0 on the reference QEMU and the in-kernel MSR sites were neutralised; under KVM a different host may still `#GP` on remaining `rdmsr` sites. Try KVM only after a clean TCG run |\n| `-smp 8` | Matches the live machine's CPU count; the trampoline never sends INIT-SIPI, and the SMP-gate residue was zeroed so everything takes the single-CPU fast path |\n| `-no-reboot` | A fault cascade ends QEMU rather than reboot-looping |\n\n\n---\n\n## 🧱 Architecture\n\n### Boot pipeline\n\n```mermaid\nflowchart LR\n    subgraph HOST[\"QEMU host · TCG\"]\n        A[\"-M pc -cpu EPYC\u003Cbr\u002F>-m 2G -smp 8\"] --> B[\"SeaBIOS 1.16.3\"]\n    end\n    B --> C[\"Multiboot ELF32 trampoline\u003Cbr\u002F>linked @ 0x100000\"]\n    C -->|\"copy 62.2 MiB image\u003Cbr\u002F>to phys 0x1E3F0000\"| M[(\"RAM\")]\n    C -->|\"676 byte-verified\u003Cbr\u002F>in-memory patches\"| M\n    C -->|\"PML4: identity + KVA 0x1FF + DMAP 0x11C\u003Cbr\u002F>modulep + SMAP + param block\"| L[\"64-bit long mode\"]\n    L --> E[\"btext\u003Cbr\u002F>0xffffffff9e642a90\"]\n    E --> F[\"machine_init\u003Cbr\u002F>0xffffffff9edf8790\"]\n    F --> G[\"mi_startup\u003Cbr\u002F>0xffffffff9e9261f0\"]\n    G --> H[\"1235 SYSINIT stages\"]\n    H --> I[\"Sony printf \u002F mDBG\"]\n    I -->|\"patched putc → out 0x402\"| J[(\"serial.log\")]\n```\n\n### Three layers of patching\n\n```mermaid\nflowchart TB\n    P[\"Public live dump\u003Cbr\u002F>kernel-13.60-live.bin.gz\"] -->|\"reconstruct (WP2)\"| R[\"Pristine reconstructed image\u003Cbr\u002F>65,224,704 B\"]\n    R -->|\"WP7 → WP32 patch chain\u003Cbr\u002F>caves · guards · seeds · wipes\"| K[\"kernel_raw.bin\u003Cbr\u002F>md5 520808c9…\"]\n    K --> T\n    subgraph T[\"inside the trampoline at boot\"]\n        T1[\"copy image to phys 0x1E3F0000\"] --> T2[\"676 verified patches\u003Cbr\u002F>MSR · CFI · console · pmap · hypercalls\"]\n        T2 --> T3[\"page tables · mmap rewrite · modulep · params\"]\n    end\n    T --> RUN[\"Running kernel\u003Cbr\u002F>+ runtime caves: guards, bump allocators, lazy-inits\"]\n```\n\n| Layer | Where it lives | Applied | Typical content |\n|---|---|---|---|\n| **1 · Baked image patches** | inside `kernel_raw.bin` (built by `scripts\u002Fwp*_patch_*.py`, or in one shot by `build_kernel.py` \u002F `apply_all_wp1_to_wp32_patches.py`) | offline | code caves & slots, `.data` residue wipes, seed pointers, designed-exit retargets |\n| **2 · Trampoline patches** | `wp3_boot\u002Fpatches.inc` (676 entries; each = image offset + length + *expected original bytes* + *replacement bytes*) | at boot, after the image copy; the loader halts with `patch mismatch` if an expected byte differs | 33 `vmmcall` → `xor eax,eax; nop` (hypercall \"returns 0\"), 37 `wrmsr` NOPs, 481 `rdmsr` neutralisations, `cfi_check_fail → ret`, console un-mute, `putc → out 0x402`, pmap constants |\n| **3 · Runtime caves** | `.text` 0xCC padding at the start of the image (`0x9E400000…`) and the dead ICC body (`0x9EE30xxx`) | runs when the kernel reaches the hooked site | NULL-return guards, lazy `TAILQ_INIT`, bump allocators, designed-error exits |\n\n### Physical memory map (as built by the trampoline + kernel)\n\n```text\n PHYS                       CONTENT                                                      OWNER\n ─────────────────────────  ───────────────────────────────────────────────────────────  ───────────────\n 0x00000000 – 0x000FFFFF    IVT\u002FBDA, SeaBIOS, option ROMs · phys param block 0x9B000-     SeaBIOS \u002F\n                            0x9BFFF (22 params) · contract words 0x9BF4C\u002F0x9BF54\u002F0x9B6F4  trampoline\n 0x00080000 – 0x00086FFF    trampoline page tables: PML4 · PDPT(id\u002FKVA\u002FDMAP) · PD(...)    trampoline\n 0x00088000 \u002F 0x00097000    trampoline stack \u002F btext entry stack (transient)              trampoline\n 0x00100000 –               trampoline ELF32 (multiboot, from -kernel)                    QEMU\n 0x00F00000 –               msgbuf window (msgbufp redirected here, struct magic          WP7 patches\n                            0x63062, size 0x17FB8)\n 0x1E3F0000 – 0x1F0AFFFF    kernel .text   (0xCC0000 B)                                   kernel image\n 0x1F0B0000 – 0x22223FFF    kernel .data\u002F.bss (0x3174000 B)                               kernel image\n 0x22224000                 modulep — preload metadata (136 B incl. SMAP)                 trampoline\n 0x22225000                 physfree (first free page after image + metadata)             kernel\n 0x22230000 – 0x24261000    kernel's own page-table region (0x2031 × 4 KiB)               kernel pmap\n 0x23000000 – 0x23A00000    seeds \"in the hole\": bucket arrays + callout tables           caves (WP15)\n 0x3F000000 – 0x3FFFFFFF    SEED WINDOW — bump allocators, arena pool, fake objects       caves (WP9-WP17)\n 0x40000000 – 0x7FFDFFFF    RAM · app-memory profile carve [1 GiB, 2 GiB)                 kernel\n 0x7FFE0000 – 0x7FFFFFFF    reserved (SeaBIOS tables)                                     SeaBIOS\n```\n\nPreload-metadata **SMAP** (decoded from `wp3_boot\u002Fmeta.inc`): `[0x1000, 0x9B000)`, `[0x9C000, 0xF0000)`,\n`[0x100000, 0x80000000)` — all type 1 (RAM). The *multiboot* memory map that QEMU hands the trampoline is additionally\nrewritten by an injected 109-byte `mmap_fix` routine (WP11) to `RAM[1 MiB,0x3F000000) + RESERVED[0x3F000000,0x40000000) +\nRAM[0x40000000,0x7FFE0000) + RESERVED[0x7FFE0000,0x80000000)`.\n\n### Virtual memory map\n\n| Region | Virtual address | Notes |\n|---|---|---|\n| Kernel `.text` | `0xffffffff9e3f0000` + `0xCC0000` | **KVA = `0xFFFFFFFF80000000` + PA** (PML4 slot `0x1FF`) |\n| Kernel `.data`\u002F`.bss` | `0xffffffff9f0b0000` → `0xffffffffa2224000` | 49.4 MB image; the original dump's ~38.5 MB runtime heap is excluded |\n| Preload\u002Fmodule VA | `0xffffffffa2224000` | printed as `Preloaded elf kernel \"kernel\" at …` |\n| **Direct map (DMAP)** | `0xffff8e7700000000` + PA | PML4 slot `0x11C`, PDPT slot `0x1DC`: `0xffff800000000000 \\| (0x11C\u003C\u003C39) \\| (0x1DC\u003C\u003C30)` — byte-verified against a live pointer |\n| Identity map | VA = PA (low) | used by the loader before the kernel's `CR3` switch; the kernel's new tables do **not** map PML4[0] |\n| kmem submap window | `0xffffffffa4000000` → `0xffffffffa8000000` | handed out by the WP16 region-manager bump (cave47) |\n| **Page size** | **16 KiB** (`0x4000`) | unlike stock FreeBSD — a classic source of \"off by 4×\" mistakes |\n\n### The loader contract the trampoline implements (20 items, abridged)\n\n| # | Contract item | Value \u002F behaviour |\n|---:|---|---|\n| 1 | Entry | `btext` `0xffffffff9e642a90`, `rsp → [any][modulep>>12][physfree>>12]` |\n| 2 | Args (corrected in WP2) | `dword[rsp+4] = 0x22224`, `dword[rsp+8] = 0x22225` — **page numbers**, *not* `boothowto`\u002F`bootdev` (`boothowto` is hard-coded `0x20001000` by a cpu-init hook) |\n| 3 | Physical words | `0x9BF4C` KERNBASE-GB selector (console 0) · `0x9BF54` low-mem\u002FDMAP base `0x1E1E0000` · `0x9B6F4` kernel-phys delta 0 · `0x472` warm-boot flag (written *by* the kernel) |\n| 4 | Param block | 22 byte-strings at `0x9B310…0x9BF78` (`wp3_boot\u002Fparams.inc`) |\n| 5 | Preload metadata | `kernel` \u002F `elf kernel` modinfo + `MODINFOMD_SMAP 0x9001` (3 entries) |\n| 6 | Page tables | identity slot 0 + KVA slot `0x1FF` + DMAP slot `0x11C` \u002F PDPT `0x1DC` |\n| 7 | Hypercall `0x1F` | issued by `machine_init` before `mi_startup`; must return 0 → all 33 `vmmcall` sites (`0F 01 D9`) are rewritten to `31 C0 90` (`xor eax,eax; nop`) |\n| 8 | MSR whitelist | 10 Sony-custom MSRs read\u002Fwritten on *every* interrupt entry; neutralised in-image (see below) |\n| 9 | pmap_bootstrap constants | forced `slot=0x18C \u002F d39=0x11C \u002F d30=0x1DC` |\n| 10 | Console | Titania\u002FUART `putc` → `out 0x402`; log-mute gates cleared |\n\n---\n\n## 🔬 Technical deep dive\n\n### 1 · Target & provenance\n\n| Fact | Value |\n|---|---|\n| Public dump | `terrafirma2021\u002Fps5-13.60-kernel-dump` — 103,546,880 B, SHA-256 `c3f745e25dc25ee7afef89eb418b295b6334bbefe8aa17e6886483c35d78cddd` (exact match); 688 zero pages at data VA `0xffffffffa4400000–0xa46b0000` |\n| Nature of the dump | A **live, post-decryption** snapshot of a running kernel — *not resumable*, so it is **reconstructed** into a cold-bootable image |\n| Kernel identity | `r229358\u002Freleases\u002F13.60 Jul 17 2026 amd64`, `mDBG: Kernel Build ID = 99dd70d51abadddd`, source tree prefix `W:\u002FBuild\u002FJ03950001\u002Fsys\u002Ffreebsd\u002Fsys\u002F…`, FreeBSD 9.3-style `SI_SUB` ordering |\n| Reconstructed ELF (WP2) | 62.2 MiB, `e_entry = 0xffffffff9e642a90`; `PT_LOAD .text 0xffffffff9e3f0000 \u002F 0xCC0000 \u002F R+E \u002F paddr 0x1E3F0000`, `PT_LOAD .data 0xffffffff9f0b0000 \u002F 0x3174000 \u002F RW \u002F paddr 0x1F0B0000`; SHA-256 `e87dbe64…7cae` |\n| Text layout | first ≈ 2.4 MB of `.text` is `0xCC` (int3) padding; real code starts near `0xffffffff9e640000` — that padding is where the later caves live |\n| Out of scope (parked in Tasks 1–4) | the 26.07\u002F14.20 `PS5UPDATE.pup` (SLB2 container, AES layers, per-FW SELF keys) — not needed for the kernel-dump route and **not** part of this kit |\n\n### 2 · What WP1 learned about the platform\n\n\u003Cdetails>\n\u003Csummary>\u003Cb>Hypervisor call (VMMCALL) ABI — 33 sites, 26 wrappers, 25 unique numbers\u003C\u002Fb>\u003C\u002Fsummary>\n\nAll real `vmmcall` (`0F 01 D9`) instructions live in one wrapper region `0xffffffff9f006a10 – 0x9f00720d` (1.7 KB),\ngenerated from `sys\u002Fkern\u002Fkern_hv.c`. Of 37 raw byte matches, 4 were false positives inside `fadd`\u002F`call` displacements\n(`0x9e6ab6c9`, `0x9e6ab7be`, `0x9e6ab8a3`, `0x9ed157fd`). **ABI:** hypercall number in `EAX`, System-V AMD64 argument\nregisters (+ `EBX` marshalling variants), result in `EAX` (hc `0xD` returns a quad in `RBX\u002FRDX\u002FRDI\u002FRSI`).\n\n| hc | Role (inferred from caller strings\u002Ffiles) |\n|---|---|\n| `0x04 \u002F 0x05 \u002F 0x1F` | CPU-mode switch (`orbis_cpumode.c`; `ps4` exec mode; `TSC_AUX` wrmsr) |\n| `0x06 – 0x0B` | AMD IOMMU family |\n| `0x0A` | has a 100 000 × retry loop with `delay(10)` |\n| `0x0D` | HV state-block reader (index in `EBX`, mutex-protected, 16-block loop + table-driven dump fn) |\n| `0x10` | AP start \u002F resume (`acpi_wakeup`, \"AP failed\" strings) |\n| `0x13` | LAPIC timer (`local_apic.c`) |\n| `0x14 \u002F 0x15` | TMR map\u002Funmap for PSP\u002FTEE (`psp_mbox_map_tmr`, `hv_restore_pt_tmr`, `sceSblSvpMapPrdyTeeArea`) |\n| `0x20` | sysctl-exposed statistic (tail-called from a sysctl handler) |\n\n9 wrappers have no callers. In this kit every site is rewritten by the trampoline from `0F 01 D9` to `31 C0 90` (`xor eax,eax; nop`), i.e. every hypercall \"succeeds with 0\"; `0x1F` in particular must return 0.\n\u003C\u002Fdetails>\n\n\u003Cdetails>\n\u003Csummary>\u003Cb>MSR map — 1,397 verified sites, 197 keys, and the \"Triple-Fault trap\"\u003C\u002Fb>\u003C\u002Fsummary>\n\n* 1,397 verified `rdmsr`\u002F`wrmsr` sites (1,383 function-anchored); 189 constant + 8 dynamic MSR keys. A tracking bug (the kernel uses both `mov rcx,imm` and `movabs rcx,imm`) had mis-attributed 210 sites before it was fixed.\n* **Sony-custom family `0xC0000110 – 0xC0000117`** (×51 each): not saved by `savectx`; they live in **extended trap frames**. Every one of the 256 IDT vectors (`IDT @0xa1fa4300`) runs a stub (`0x9e642c00 – 0x9e648200`) that `rdmsr`s `0x1DD`, `0x1DE` and these eight into frame slots `+0x90..+0xd8`; three exit paths (`sysret 0x9e644a7c`, `doreti 0x9e647a1f`, `ast 0x9e647ff1`) restore them *iff* frame flag bit 3 is set — which the kernel never sets.\n* `0x1DD \u002F 0x1DE` are the Zen-2 **LBR FromIP\u002FToIP** MSRs (crash printer string `last branch from = 0x%lx`).\n* Other families: x2APIC block `0x800–0x85x`, MCA banks, MTRR pairs, AMD perf counters, `orbis_pmc.c` customs (`0x52C \u002F 0x539`), `0xC0010200–0xC0010247` perf-counter-like pairs.\n* **Policy that made TCG boot possible:** values are *not recoverable and not needed* (the C code never reads them). On the reference QEMU unknown MSRs read 0, so the kit neutralises **518 instructions** in-image — 37 `wrmsr` (29 with Sony ECX, incl. `0x9edf959b`) → NOP, 481 stub `rdmsr` → `xor eax,eax \u002F xor edx,edx` (470 combos + 11 plain). Under a hypervisor that `#GP`s unknown MSRs, the first interrupt would triple-fault.\n\u003C\u002Fdetails>\n\n\u003Cdetails>\n\u003Csummary>\u003Cb>Entry chain, \u003Ccode>mi_startup\u003C\u002Fcode> and the SYSINIT array\u003C\u002Fb>\u003C\u002Fsummary>\n\n| Symbol | Address | Notes |\n|---|---|---|\n| wakeup trampoline | `0x9e3f0010` | S3 resume path, `lgdt` temp GDT `@0xa1e8dce0` |\n| `savectx` \u002F `resumectx` | `0x9e6427d0` \u002F `0x9e6428f0` | (WP1 first mis-labelled `resumectx` as `hammer_time`; corrected in WP1-fix) |\n| **`btext`** (cold entry) | `0x9e642a90` | writes warm flag `[0x472]=0x1234`, bootstack, calls machine init, then `mi_startup`, then `hlt` |\n| AP entry | `0x9e642a40` | per-CPU bootstack via `mul rdi` |\n| **`machine_init`** | `0x9edf8790` | 2,912 B \u002F 540 insns; builds GDT\u002FIDT\u002FTSS\u002Fpcpu\u002Fproc0\u002Fthread0 itself; reads modulep\u002Fphysfree; issues hc `0x1F` |\n| memory-map builder | `0x9edf9310` | reads SMAP from preload metadata; `physmem` → `[0xa1fdef08]` |\n| **`mi_startup`** | `0x9e9261f0` | confirmed by the `init_main.c` `__FILE__` string |\n| `sysinit_set` | `[0x9fe51fb0, 0x9fe55488)` | **1,691 slots**, stock FreeBSD 9.3 `{si_sub, si_order, func, udata}`; runtime *single adjacent-sweep* sort (not the double loop) |\n\nExec loop: skip `si_sub \u003C 2` (`cmp dword[rax],2 \u002F jb` @`0x9e926311`), stamp `mov dword[rax],1` (`SI_SUB_DONE`) @`0x9e926337`. The live dump holds **1,586 DONE + 105 DUMMY** slots, of which **351 are duplicates** → **1,235 unique stages**. Reconstruction: `[105 dummies (sub 0)] + [1,235 uniques in dump order, sub := 2..40 (39 groups detected via si_order resets)] + [351 zero slots]`; zero-swap and order-preservation proofs pass on the built ELF.\n\u003C\u002Fdetails>\n\n\u003Cdetails>\n\u003Csummary>\u003Cb>CFI, residue and other \"live-machine\" traps discovered along the way\u003C\u002Fb>\u003C\u002Fsummary>\n\n* **Clang CFI everywhere:** 5,629 `sub rax,r14; ror rax,3; cmp rax,imm; ja cfi_check_fail` sites. `cfi_check_fail` (`0x9e83f8c0`) is patched to `ret`, which turns every failed check into a no-op (callers' jump-backs still make the call).\n* **Live-dump residue:** pointers into DMAP regions that don't exist on a 2 GiB VM (app\u002FGPU memory of the real console). 965 `.data` qwords pointing above 1 GiB were wiped in WP7 (P9), 36 more into the seed window in WP11, plus later families (`0xffffff80…` prefix, 11 domains' `vm_dom` arrays, per-CPU callout tables, …).\n* **Cold vs. hot state:** e.g. `[0xa20fe870]=1` (\"SMP started, 8 CPUs\") made `stop_cpus()` wait forever; thread0 was captured *mid-sleep* (`wmesg \"swprsus\"`), so `td_sleepqueue` is NULL by design.\n* **Hard-coded 4 GiB app-memory floor** (`movabs $0x100000000` @`0x9edfe277`) → patched to 1 GiB; memory-profile descriptors that requested 12.71 GB (and 16\u002F32 GB alignments) were shrunk to 256 MB \u002F 2 MB.\n\u003C\u002Fdetails>\n\n---\n\n## 🧰 Patch methodology: caves, slots, seeds\n\nThe kernel image is *not* rebuilt from source — it is a 65,224,704-byte binary that is edited in place, always at a fixed\nsize (every build script asserts `size == 65224704`). Three primitives do all the work:\n\n| Primitive | What it is | Why it works |\n|---|---|---|\n| **Guard \u002F hook** | a 5-byte `E9 rel32` (+ NOP padding) at a crash site that jumps to a *slot* | the slot replays the displaced instructions, tests for the bad condition, and either rejoins the original stream or exits through the **function's own designed error path** |\n| **Cave \u002F slot** | 128-byte (`0x80`) code cells carved out of pristine `0xCC` padding | every slot is checked to be all-`0xCC` before use; the replay is *byte-exact* and RIP-free so it is relocatable |\n| **Seed** | a pre-zeroed page the kernel is pointed at (`.data` pointer rewritten) so \"never-initialised\" objects read as valid-and-empty | the kernel's own cold-boot semantics (`NULL`\u002F`0` = empty) then take designed paths |\n\n### Cave \u002F slot ledger\n\n| Region | Range | Era | Contents |\n|---|---|---|---|\n| **Dead ICC body** | `0x9EE30100 – 0x9EE30CA0` (+ relocated `0x9EE30CA3 – 0x9EE30D9F`) | WP9–WP13 | W1 bump allocator `@0x9EE30100`, W8 PD builder `@0x9EE30200`, cave v4 `@0x9EE30400`, caves 2–21, ICC stubs `@0x9EE30CA0 \u002F 0x9EE2FF80`. ⚠ **Live code starts at `0x9EE30DB0`** — two caves placed there in WP13 destroyed a live loop; the boot then died at PT-VERIFY |\n| **`.text` 0xCC island** | `0x9E400000 →` | WP14+ | `cave22` arena bootstrap `@0x9E400000`, `cave23` sleepq guard `@0x9E400400`, `cave24` pv-list lazy-init `@0x9E400500` … `cave62 @0x9E401800` (WP16) … WP17\u002F18 caves up to `0x9E402A80` |\n| G-series slots | `0x9E402B00 – 0x9E403C00` | WP20 | G2 devclass lazy-init, G3 entropy, G4 contig family, G5 IPMI, G6 vm-page-free, G8 `da` TAILQ + AES key-expansion, G9 dmem\u002FmDBG trio, G10–G15 |\n| | `0x9E403F00`, `0x9E404000 – 0x9E404800` | WP21–WP23 | G26 park stub; **G29 `kextract` software page walk `@0x9E404000`**; G30 memcpy oracle; G33\u002FG34\u002FG37\u002FG38; G40 trie-block oracle `@0x9E404600`; G41 end-of-walk park `@0x9E404700` (+ G50 port-`0x402` emitter); 1 KiB zero fake block `@0x9E404800` |\n| | `0x9E404C00 – 0x9E405A80` | WP24–WP25 | G42 (NULL-zone accessor ×5) and G43\u002FG44 (24 guards) |\n| | `0x9E405B00 – 0x9E413A80` (step `0x80`) | WP26 | **G46 — 448 panic-site diversions** |\n| | `0x9E413B00`, `0x9E413B80 – 0x9E414880` | WP27–WP28 | G47 rib-head guard; G49 — 25 `M_WAITOK → M_NOWAIT` downgrades |\n| | `0x9E414880 → 0x9E415200+` | WP30+ scripts | `wp30_auto.py` (`0x9E414880`), `autopilot_to_park.py` (`0x9E414A80`), `finish_to_park.py` (`0x9E414C80`), `guaranteed_park.py` \u002F `final_sprint.py` (`0x9E414F00`), `checkmate_park.py` (`0x9E415200`) |\n\n### Seed-window ledger (`DMAP(0x3F000000 … 0x40000000)`)\n\n\u003Cdetails>\n\u003Csummary>\u003Cb>Show the full ledger as recorded in the worklog\u003C\u002Fb>\u003C\u002Fsummary>\n\n| Range \u002F address | Purpose | Introduced |\n|---|---|---|\n| `[0x3F000000, 0x3F010000)` | W1-bump pointer, W6 head, W4 bitmap, W8 page-directory | WP9 composite |\n| `0x3F002000` | `kern_envp` seed (`0x1008`-byte zero page; `array[0] = NULL`) | WP13 #8 |\n| `[0x3F004000, 0x3F009000)` | `cave22` scratch (init flag + `next`); pool-next `@0x3F004008` | WP14 |\n| `0x3F00A000` | mDBG state base (fresh zero page) | WP12 #6 |\n| `0x3F00D000` | zero \"region-manager\" page (guarded in WP16) | WP12 |\n| `[0x3F010000, 0x3F0F0000)` | W1 objects, **step `0xF0`** (was `0x78`; the overlap corrupted `vm_page.plinks.q`) | WP15 #3 |\n| `[0x3F0F0000, 0x3F100000)` | constructor-object bump (`cave48`, `0x400` granular) | WP16 |\n| `0x3F100000 \u002F 110000 \u002F 120000` | chunk-hash arrays (kernel \u002F buffer \u002F transient arenas) | WP14 |\n| `0x3F140000 \u002F 150000 \u002F 160000` | 1024-node chains (`0x40` B each) per arena | WP14 |\n| `[0x3F170000, 0x3F190000)` | `vm_dom[i]+0x10` block arrays (128 KB = 1024 blocks) | WP15 #5 |\n| `0x3F190000` | fake `gs:[8]` object (later superseded by `thread0`) | WP15\u002F16 |\n| `0x3F1A0000` | pcb seed (zero) | WP15 #19 |\n| `0x3F1A0800 \u002F 0810 \u002F 0820 \u002F 0830 \u002F 0840` | PIC-mask flag · region-mgr VA bump · ctor bump · **shared malloc bump** · W1-ext base | WP16\u002F17 |\n| `[0x3F1A0880, 0x3F1A0998)` | seeded zone for the zone-table global `[0xa18ea8c0]` | WP17 #3 |\n| `[0x3F1A1000, 0x3F740000)` | **malloc \u002F zone-import bump window** (380 KB → 5.6 MB) | WP16 → WP17 |\n| `[0x3F200000, 0x40000000)` | arena-extent pool (≈ 14 MB; capped 1 MB per serve) | WP14 |\n| `[0x22225000, 0x26410000)` \"the hole\" | `[0x23000000,0x23800000)` bucket arrays + `[0x23800000,0x23A00000)` callout tables | WP15 |\n| `0x3FE00000` | arena limit raised by the autopilot script (room for a 1.37 MB `a53io` alloc) | WP32 scripts |\n\n> ⚠ **Audit note.** As recorded, the arena pool (`0x3F200000 →`) and the malloc window (`→ 0x3F740000`) overlap in\n> `[0x3F200000, 0x3F740000)`. The two bumps are independent pointers, so this has not bitten yet, but check it before\n> extending either allocator.\n\u003C\u002Fdetails>\n\n---\n\n## 🧪 Crash-class taxonomy\n\nEvery frontier in this project was one of a small number of *classes*. Recognising the class is most of the fix.\n\n| # | Class | Symptom | Root cause | Standard remedy | First seen |\n|---:|---|---|---|---|---|\n| 1 | **Unknown-MSR triple fault** | `#GP` → `#DF` → triple fault right after `CR3` switch | extended trap-frame stubs `rdmsr` Sony MSRs on *every* interrupt | neutralise 518 MSR instructions | WP3\u002F4 |\n| 2 | **CFI cascade** | recursive faults, IST exhaustion, `#DF` | residue fn-pointer outside CFI callee range → `cfi_check_fail` → log path faults → `ud2` → stub → … | `cfi_check_fail → ret`; null-putc stubs → debugcon | WP4 |\n| 3 | **Residue spin** | silent, `DELAY()` loop at `0x9e85e2f0` | stale softc\u002Fmutex pointer into the initrd staging area | zero the residue pointers (`[0xa184f370]`…) | WP4 |\n| 4 | **NULL-`curthread` window** | read at VA `0x108` returns the BIOS IVT qword `0xc0007240f000ff53` | `gs:0x20` is NULL between pcpu-bzero and thread0 | use the code's own NULL fallback (`xor eax,eax @0x9e7dea86`) | WP5 |\n| 5 | **Impossible sizes** | `panic: Failed to allocate application memory` | 12.71 GB profile, 16\u002F32 GB alignment, 4 GiB floor | shrink to 256 MB \u002F 2 MB \u002F 1 GiB | WP4\u002F5 |\n| 6 | **Zero-lock mutex** | `mtx_lock` adaptive-spin dereferences owner NULL (`CR2=0x400`) | lock word 0..7 never `mtx_init`'d | widen the fast-path bound (`cmp rax,0xF`) | WP11\u002F13 |\n| 7 | **ENOMEM-era NULL deref** | `CR2 = small offset`, write\u002Fread through NULL+n | `malloc`\u002Fzone alloc returns NULL, caller doesn't test | guard at the site, exit via the fn's **own error value** (`0xc`, or NULL by caller convention) | WP13 → G48 |\n| 8 | **TAILQ on raw zero** | write through `*tqh_last == NULL` | `TAILQ_INIT` never ran | lazy self-anchor cave (`tqh_last = &tqh_first`) | WP15 |\n| 9 | **Divide by zero** | trap 18 | MSR-backed counters read 0 | force a non-zero divisor (`or edi,1`) | WP13 |\n| 10 | **False `#DF`** | `panic: double fault`, `rip` = `tf_cs` | pending PIC IRQ0 (vector 8) fires at the first `IF=1` before the ICU is remapped | mask both 8259s once in `critical_exit` | WP16 |\n| 11 | **Never-completing wait** | silence (hypervisor settle-wait) | HV completion packet never arrives | answer instantly (`mov eax,edi; ret @0x9ea52730`) | WP21 |\n| 12 | **Self-map dependence** | page fault walking PML4[0] | `pmap_kextract` on unmapped low VAs | software page walk through the DMAP only (G29) | WP22 |\n| 13 | **Canonical-but-unmapped residue** | `rep movs`\u002F`stos` fault in memcpy\u002Fmemset | stale `0xffffff80…` pointers | oracle guards using the G29 walk (G21\u002FG30\u002FG37) | WP21\u002F22 |\n| 14 | **`M_WAITOK` livelock** | 45 s of silence, rip in `malloc` small path, `r12=0x102` | wait\u002Fretry loops forever when memory can never be found | downgrade to `M_NOWAIT` at 25 tail-only sites (G49) | WP28 |\n| 15 | **Cyclic static list** | same as 14, but *the caller* loops | statically pre-linked `domains` list + `domain_add` closes a 4-cycle | zero the list head (`[0xa1f0eea0] ← 0`, G51) | WP29 |\n| 16 | **Self-linked residue list** | timecounter insert-head creates a self-cycle | head pointed at an element | zero the head `[0xa0cbbab8]` (G54) | WP31 |\n| 17 | **Broken guard geometry** | `pop rbp` eats the return address | guard assumed a frame in a *frameless* function | CFG-exact unwind, per-fn prologue\u002Fepilogue check | WP32 scripts |\n\n### Case studies worth reading\n\n\u003Cdetails>\n\u003Csummary>\u003Cb>① The IVT read — \u003Ccode>0xc0007240f000ff53\u003C\u002Fcode> (WP5)\u003C\u002Fb>\u003C\u002Fsummary>\n\nA garbage jump target looked like random hash residue. It was actually a `qword` read at **physical address `0x108`** —\nIVT[0x42] = `F000:FF53` (SeaBIOS default handler) and IVT[0x43] = `C000:7240` (VGA hook) — fetched through the kernel's\nlow identity map after `mov 0x108(%rax),%rax` with `rax = curthread = NULL`, stored as a function pointer at `[r14+0xe8]`\nand later *called*. The fix reused the code's own designed NULL fallback instead of inventing one.\n\u003C\u002Fdetails>\n\n\u003Cdetails>\n\u003Csummary>\u003Cb>② The false double fault (WP16)\u003C\u002Fb>\u003C\u002Fsummary>\n\nBoot ran with `IF = 0` through all of SYSINIT. The first `popfq` in `critical_exit` enabled interrupts while the PIT's\nIRQ0 was pending on the *un-remapped* 8259 → delivered as **vector 8**, which is the `#DF` vector, **with no error code**.\nThe `#DF` handler's frame arithmetic shifted by 8, printed `tf_cs` (0x20) as `rip` and `tf_ss` (0x28) as `rsp`, and then\nfaulted on its own `swapgs`. Cure: a one-shot `out 0x21,0xFF; out 0xA1,0xFF` before the `popfq`. (An early version returned\n5 bytes too far, into the middle of `mov rbx,gs:[0]` — a reminder that return jumps must land on instruction boundaries.)\n\u003C\u002Fdetails>\n\n\u003Cdetails>\n\u003Csummary>\u003Cb>③ The four-cycle that looked like a memory problem (WP29)\u003C\u002Fb>\u003C\u002Fsummary>\n\n45 seconds of silence, zero crashes, `rip` cycling through `malloc`. Frame decoding showed the caller was\n`rt_tables_init` (SYSINIT #1266) iterating the **`domains` list** — which the static image had *already* pre-linked\n(`local → inet6 → inet → route → NULL`). Four `domain_add()` calls (`dom->next = head; head = dom`) on a non-NULL head\nclosed it into `local → inet6 → inet → route → local`. Each lap called `dom_rtattach` → `rib_head_create` →\n`malloc(0x1a0, M_WAITOK|M_ZERO)`: ~250 arena bumps, then fast-NULL forever. One 8-byte `.data` write\n(`[0xa1f0eea0] ← 0`) lets the rebuild produce the canonical list. *Methodology bonus:* the saved `r14`\u002F`rbx` in the\nframe carried the dispatcher's identity.\n\u003C\u002Fdetails>\n\n\u003Cdetails>\n\u003Csummary>\u003Cb>④ \"Claimed\" vs \"verified\" — the WP17 → WP18 rollback and the WP20 audit\u003C\u002Fb>\u003C\u002Fsummary>\n\nWP17 added 11 systemic seeds (OID parents, witness head, malloc-NULL bumps…) and *shipped silently broken*: allocators now\nreturned raw pages instead of the designed NULL, activating witness\u002Fearly zones before `Preloaded elf kernel`; the old\nbuild script verified with `|| echo`. WP18 rolled back to WP16 + 8 fixes and rebuilt every gate as `grep … || exit 1`.\nWP20 repeated the lesson: a previous session *claimed* `done = 1158` but its on-disk `serial.log` showed a crash at\n`0x9eff8e19` (a later family had restored original Sony bytes over a WP13 guard) — so the round restarted from the golden\nWP18 image, byte-exact.\n\u003C\u002Fdetails>\n\n\u003Cdetails>\n\u003Csummary>\u003Cb>⑤ When a sweep is worse than the disease (WP27 → WP28)\u003C\u002Fb>\u003C\u002Fsummary>\n\nG48 auto-guarded ~37 \"interior-LEA\" sites (19 LEA guards + 18 call-site guards) across a 5,499-function closure. The first guard (`0x9e6b6eea`) sat *above* the WP16\n`cave48` hook (`0x9e6b6ef1`) and `xor eax,eax`'d out before the cave could run → `panic: kmem_suballoc: cannot create\nsubmap`. G48 was **discarded entirely** and the G47-only image (`175a002c…`) became the base. Rule adopted: *no speculative\npatches* — sweeps are generated as **reports** (`wp29_retry_scan.txt`: 863 `call; test rax; je back` patterns over 7,278\nfunctions) and only the site that actually fires gets patched.\n\u003C\u002Fdetails>\n\n### Rules the project converged on\n\n1. **Byte-verify before every patch**, make every patch idempotent, and assert the image size (`65224704`) after each step.\n2. **Hook at the crash site or at a designed exit.** Never change an allocator's NULL-on-failure contract (WP17 lesson).\n3. **Return through the function's own epilogue**; a bare `ret` mid-function corrupts the frame. Return jumps land on the *next instruction boundary*.\n4. **Keep replays byte-exact and RIP-free**; derive unwinds from verified prologues (19 prologues were hand-eyeballed for G44).\n5. **Gates are `|| exit 1`**, never `|| echo`. Rebuilds must reproduce the delivered md5 byte-for-byte.\n6. **Never put caves in live code** — verify the target slot is pristine `0xCC`.\n7. **No blanket wipes** (a 3,700-slot wipe halted the trampoline with `patch mismatch`); stay surgical.\n8. **Prefer static analysis** (`capstone` + trap frames) over long GDB sessions; keep QEMU boots per round ≤ 2 (the WP21 \"anti-timeout laws\").\n9. **Beware hand-typed hex in GDB** (`0xF000000` vs `0xF00000` cost two dump rounds) — use expression variables (`$mbp`).\n10. **Keystone quirks:** no `cmp r64, imm64` (use `movabs` into a scratch), no inline `;` comments inside the asm block.\n\n---\n\n## 📅 Work-package timeline (WP1 → WP32)\n\n> Sources: `worklog_full_history.md` (Tasks 1–19, then WP18–WP29), the headers of the later scripts, and the milestone logs in `docs_reports\u002F`.\n> The worklog itself says it was *recreated after a sandbox reset on 2026-10-27*, so Tasks 1–4's artifacts were lost; WP8–WP10 and WP30–WP32 are known only from scripts.\n\n| WP | Theme | Headline results | Evidence |\n|---|---|---|---|\n| **Tasks 1–4** | Firmware reconnaissance | Fetched `PS5UPDATE.pup` (SHA-256 verified); SLB2\u002FPUP layout + crypto layers mapped; feasibility verdict: *native install = dead end, LLE VM = only route*; 19-question consultation pack. **Parked** — not part of the kit | worklog |\n| **Task 5** | Kernel-dump mining | Public 13.60 dump downloaded + hash-matched; **33 real VMMCALLs** found (4 false positives); 56,092 strings; naming of *Titania* (security processor), *Baikal* (southbridge), *CCP* (crypto) confirmed from kernel strings | `ps5_wp1\u002F` |\n| **WP1** (Tasks 6–7) | Platform dossier | Hypercall ABI (25 numbers), 1,397 MSR sites\u002F197 keys, entry chain, 1,691-slot sysinit array; **correction round:** real `btext = 0x9e642a90`, `mi_startup = 0x9e9261f0`, 8 custom MSRs live in extended trap frames | `wp1_report.md`, `wp1_4_hammertime_correction.txt`, `wp2_constants.json` |\n| **WP2** (Task 8) | Reconstructor | `machine_init` dissected (args are *page numbers*); `.data` sanitisation; 1,586 → **1,235 unique stages**; bootable **62.2 MiB ELF**; zero-swap proof passes | `ps5_wp2\u002F`, `wp2_final_report.txt` |\n| **WP3** (Task 9) | Loader \u002F trampoline | Pmap contract (33.9 MB above physfree), console chain, nasm multiboot trampoline with 49 patches; kernel gets past `pmap_bootstrap` | `ps5_wp3\u002F`, `trampoline.asm` |\n| **WP4** (Task 10) | First words | 584 patches: 518 MSR instr. neutralised, **CFI** defused, null-putc → debugcon; stuck-mutex residue, 12.7 GB profile, 16 GB alignment fixed → **first real kernel text on serial** | `wp3_4_first_kernel_serial.log` |\n| **WP5** (Task 11) | Deep SYSINIT | 675 patches; **IVT-read** root cause, PT-window family (×42 sites), 4 GiB floor, SMP residue gate; msgbuf shows real device hints & tmpfs init | `ps5_wp3\u002Fwp3_5_deep_boot_msgbuf.txt` |\n| **WP6–WP7** (Task 12) | msgbuf & first Sony text | msgbuf redirected; ICC recovery\u002Fsubmit **defused**; 965 residue qwords wiped; **mDBG** messages appear; BIOS-symlink footgun found; AHCI allocator frontier | `gdb\u002Fwp7_*`, `scripts\u002Fwp7_patch_kernel.py` |\n| **WP8–WP10** | *(script-only)* | `wp8\u002F9\u002F10_patch_kernel.py`, W1…W10 caves (bump allocator, PD builder), MADT loop fix | scripts |\n| **WP11** (Task 13) | UMA \u002F preinit pool | Composite rebuilt bit-exact; **`SIE CONFIDENTIAL` + Build ID**; mtx zero-lock, null-callback, tail-jmp, bogus-object guards; trampoline `mmap_fix` | `wp11_*` |\n| **WP12** (Task 14) | Memory mode | `Memory mode: 1: PPR16 (GDDR6 16 GiB)`; **999 sysctl leaves**; zone_seed regression found & removed; allocator NULL-zone guard | `wp12_*` |\n| **WP13** (Task 15) | 17 fixes | `free()`\u002F`malloc`\u002F`mtx_init`\u002Flinker families; **first designed panic** (`link_elf_init`) retargeted; first divide fault; **cave-safety incident** | `wp13_*` |\n| **WP14** (Task 16) | Arena bootstrap | Fake arena-extend callback + lazy bootstrap (`cave22`) — **`vm_page_startup()` boots**; `sleepq_add` guard | `wp14_*` |\n| **WP15** (Task 17) | 19 fixes | pv-list lazy-init, `vm_dom` block arrays, W1 bump step bug, callout residue → double fault in `cpu_switch` | `wp15_*` |\n| **WP16** (Task 18) | Scheduler basics | `cpu_switch` no-op guard; **thread0 = idle thread**; PIC mask; `kmem_suballoc` machinery; **LAPIC timer, ACPI\u002FMADT, SMP enumeration** printed | `serial.log.wp18`'s ancestor, `wp16_*` |\n| **WP17** (Task 19) | Zone\u002Fchunk family | Zone-drain guard, kmem-arena bootstrap, malloc window 380 KB → 5.6 MB — **then 11 seeds regressed the boot** | `wp17_*` |\n| **WP18** | Rollback + local guards | WP16 + 8 fixes + 24 **local** guards; kernel **idles alive, crash-free**; 1,214-line log; strict `\\|\\| exit 1` gates | `serial.log.wp18` |\n| **WP19** | *(abandoned)* | 14 patch scripts (`cave80…94`) never ran in the golden chain; rolled back in WP20 | `wp19_*` |\n| **WP20** | Golden rollback + G1–G15 | Byte-exact restore from the WP18 golden; 15 comprehensive patch groups; **done 734 → 1,006 \u002F 1,236**; lands at `hdcp packet is set to 1` | `serial.log.wp20` |\n| **WP21** | G16–G28, anti-timeout laws | Hypervisor settle-wait (`0x9ea52730`) answered instantly; MP1 cpupstate slot-table bound; APIC-vector tolerance; designed park (G26) | `serial.log.wp21` |\n| **WP22** | G29–G38 | `kextract` software walk, memcpy\u002Fmemset oracles, SBL\u002Fcontig\u002Fgbase tolerances → **`Device configuration finished.`** (log line 1,384) — byte-exact 23-script chain | `serial.log.wp22boot1` |\n| **WP23** | G39–G41 | Unpark; **trie-block oracle** (`0x9eb6e9d0`); end-of-walk park (`WP23: sysinit walk complete; parking.`) | `serial.log.wp23boot1_user` |\n| **WP24–25** | G42, G43+G44 | NULL-zone accessor family ×5, constructor guard, 24-guard sweep for the remaining walk (#1185–#1339) | `wp24\u002F25_*` |\n| **WP26** | G45 + **G46** | `crossmp` panic fixed; **448 panic sites diverted** across a 2,330-function closure (184 skipped, triaged in the report) | `wp26_g46_report.txt` |\n| **WP27** | G47 (+ G48 discarded) | RIB-head crash fixed; reaches filesystems, lapic calibration, `tcp_init`; G48 **regressed early boot and was dropped** | `wp27_g48_report.txt` |\n| **WP28** | G49 + G50 | 25 `M_WAITOK → M_NOWAIT` downgrades; direct port-`0x402` park emitter | `wp28_report.txt`, `wp28_tail_stages.txt` |\n| **WP29** | G51 | The `domains` 4-cycle (stage #1266) | `wp29_report.txt`, `wp29_retry_scan.txt` |\n| **WP30–31** | G52–G54 | NULL zone-alloc skip (ip_id\u002Farc4rand), post-`ipfw2` `bcopy(NULL,…)` guard, timecounter-head residue → passes `ipfw2` and TSC-low | `wp31_build_from_wp29.py` |\n| **WP32** | cumulative image | `apply_all_wp1_to_wp32_patches.py` → md5 `520808c9…` (**the shipped image**); autopilot-style scripts for the a53io\u002Fa53mm\u002FSMP-spin tail | scripts only |\n\n### What the late \"autopilot\" scripts do (read from their headers — **not** described in the worklog)\n\n| Script | Visible behaviour |\n|---|---|\n| `wp30_auto.py` | capstone + keystone **crash-site auto-diverter**: finds the function and its real epilogue, allocates the next free `0xCC` slot (from `0x9E414880`, step `0x80`), writes a guard; can also divert panic call sites |\n| `autopilot_to_park.py` | backs up to `kernel_raw.bin.pre_autopilot.bak`; sets the arena limit to `0x3fe00000`; retargets `a53io_initialize_cbuf @0x9e9aaf72` to its clean epilogue `0x9e9ab02b`; then loops *boot → classify → patch* until the park |\n| `finish_to_park.py` | breaks the **stage #1315 SMP spin loop** `@0x9ec0eed9` (`74 F5 → 90 90`) and NOPs other tight spin loops it finds |\n| `guaranteed_park.py` \u002F `final_sprint.py` | repairs the slot `@0x9e414e80` guarding `0x9f02d7f0` (a *frameless* function — the guard's `pop rbp` had been eating the return address); CFG-exact unwind; stubs handlers that wedge a SYSINIT stage to `xor eax,eax; ret` |\n| `checkmate_park.py` | neutralises every function referencing `app_bufs[0] != NULL` \u002F `a53mm_util.c` asserts (`xor eax,eax; ret`) |\n\n---\n\n## 📁 Repository layout\n\n```text\nps5-13.60-qemu-boot\u002F                       636 files · 138.4 MB unpacked · 18.7 MB as .7z\n├── README.md                              this file (the previous README mixed a WP31 header with WP7 text)\n├── run.sh                                 boot: TCG, 2 GiB, 8 vCPU, early stop after 45 s of silence\n├── fetch_and_build.sh                     public dump → build_kernel.py → wp3_boot\u002Fkernel_raw.bin\n├── build_kernel.py                        zlib+base64 byte-diff patcher (base md5 ca43f306… → 520808c9…)\n├── serial.log                             latest boot — 1,436 lines\n├── worklog_full_history.md                the full engineering log (142,606 B · 1,170 lines)\n│\n├── bios\u002F                    (33 files)    SeaBIOS bios.bin \u002F bios-256k.bin, 10 VGA BIOSes, linuxboot[_dma],\n│                                          multiboot[_dma], kvmvapic, 8 × efi-*.rom, 8 × pxe-*.rom (self-contained -L dir)\n├── wp3_boot\u002F                (9 files)     the boot payload — see below\n├── gdb\u002F                     (165 files)   GDB command scripts + captured outputs from the forensics rounds\n├── ps5_wp1\u002F  ps5_wp2\u002F  ps5_wp3\u002F           analysis deliverables of work packages 1–3\n├── docs_reports\u002F            (14 files)    milestone serial logs and per-WP reports\n└── scripts\u002F                 (385 files)   analysis tools, patchers, build chains, runners\n```\n\n\u003Cdetails open>\n\u003Csummary>\u003Cb>\u003Ccode>wp3_boot\u002F\u003C\u002Fcode> — the boot payload (130.6 MB)\u003C\u002Fb>\u003C\u002Fsummary>\n\n| File | Size | What it is |\n|---|---:|---|\n| `trampoline.elf` | 23,516 B | multiboot ELF32 loader (copies the image, applies 676 patches, builds page tables, rewrites mmap, jumps to `btext`) |\n| `kernel_raw.bin` | 65,224,704 B | **flat kernel image with every baked patch** — md5 `520808c9…` |\n| `kernel_raw.bin.pre_autopilot.bak` | 65,224,704 B | backup taken before the autopilot scripts — md5 `79307796…` |\n| `patches.inc` | 100,909 B | nasm data: 676 × {image offset, length, expected bytes, new bytes} |\n| `meta.inc` | 468 B (136 B blob) | preload metadata: `kernel`, `elf kernel`, SMAP ×3 |\n| `params.inc` | 1,173 B | 22 phys-param writes (block at `0x9B000…`) |\n| `tramp.ld` \u002F `probe.ld` | 230 B each | linker scripts (trampoline at `0x100000`) |\n| `trampoline.asm` | 11,614 B | source (also under `scripts\u002F`) |\n\u003C\u002Fdetails>\n\n\u003Cdetails>\n\u003Csummary>\u003Cb>\u003Ccode>ps5_wp1\u002F ps5_wp2\u002F ps5_wp3\u002F\u003C\u002Fcode> — analysis deliverables\u003C\u002Fb>\u003C\u002Fsummary>\n\n| Path | Size | Content |\n|---|---:|---|\n| `ps5_wp1\u002Fwp1_report.md` | 29.9 KB | unified WP1 report: hypercall ABI, MSR map, entry\u002Fsysinit |\n| `ps5_wp1\u002Fwp1_1_hypercalls.{txt,json}` | 55 \u002F 69 KB | per-wrapper EAX + argument marshalling + xrefs |\n| `ps5_wp1\u002Fwp1_2_msr.{txt,json}` | 38 \u002F 247 KB | 1,397 MSR sites with direction\u002Fsubsystem |\n| `ps5_wp1\u002Fwp1_3_entry_sysinit.txt`, `wp1_3_sysinit.json` | 23 KB \u002F 522 KB | entry chain + the whole sysinit array |\n| `ps5_wp1\u002Fwp1_4_hammertime_correction.txt`, `wp2_constants.json` | 12.6 \u002F 3.1 KB | the correction round, machine-readable constants (entry VAs, patch points, MSR policy, IDT map) |\n| `ps5_wp2\u002Fmachine_init_disasm.txt`, `memmap_builder_disasm.txt` | 47 \u002F 64.5 KB | annotated disassembly |\n| `ps5_wp2\u002Fwp2_1_machine_init_loader_contract.txt`, `wp2_loader_contract.json` | 16 \u002F 3 KB | the loader contract |\n| `ps5_wp2\u002Fwp2_2_bss_sanitization.txt`, `wp2_2_sanitization.json`, `wp2_held_mutexes.json` | 9 \u002F 1 \u002F 1.7 KB | `.data\u002F.bss` sanitisation, the 11 held mutexes released |\n| `ps5_wp2\u002Fwp2_3_sysinit_plan.json` | 199 KB | the reconstruction plan for the sysinit array |\n| `ps5_wp2\u002Fwp2_final_report.txt` | 14 KB | final WP2 report (incl. verbatim `readelf`) |\n| `ps5_wp3\u002Fwp3_1_pmap_bootstrap.txt`, `wp3_1_pmap_contract.md` | 79 \u002F 5 KB | `pmap_bootstrap` anatomy and the initial-page-table contract |\n| `ps5_wp3\u002Fwp3_2_console.txt`, `wp3_2_console_chain.md` | 3 \u002F 6 KB | console\u002Fprintf chain |\n| `ps5_wp3\u002Fwp3_4_first_kernel_serial.log` | 8 KB | the first-ever real kernel text (milestone) |\n| `ps5_wp3\u002Fwp3_5_deep_boot_msgbuf.txt` | 25 KB | msgbuf dump from the deep-SYSINIT boot |\n\u003C\u002Fdetails>\n\n\u003Cdetails>\n\u003Csummary>\u003Cb>\u003Ccode>docs_reports\u002F\u003C\u002Fcode> — milestone logs and reports\u003C\u002Fb>\u003C\u002Fsummary>\n\n| File | Lines \u002F size | Last landmark |\n|---|---|---|\n| `serial.log.wp18` | 1,215 lines | `_taskqueue_start_threads: kthread_add(…): error 12` — crash-free idle |\n| `serial.log.wp20` | 1,260 lines | `hdcp packet is set to 1` |\n| `serial.log.wp21` | 1,275 lines | `mDBG: Power down…` (after G27 boot) |\n| `serial.log.wp22boot1` | 1,291 lines | `mDBG: Power down…` (G28 confirmation boot) |\n| `serial.log.wp23boot1_user` | 17 lines | `panic: page fault` (the user's own unparked run, trap at `0x9eb6e9e7`) |\n| `wp26_g46_report.txt` | 68.6 KB | the 448 diverted sites + 184 skipped with reasons |\n| `wp27_g48_report.txt` | 13 KB | G48 sweep + 19 BSS candidates |\n| `wp28_report.txt`, `wp28_tail_stages.txt` | 4 \u002F 7 KB | G49 table; the 45 tail stages #1295–#1339 |\n| `wp29_report.txt`, `wp29_retry_scan.txt` | 4 \u002F 87 KB | the domains 4-cycle; 863 retry patterns |\n| `wp1_4_hammertime_correction.txt`, `wp2_constants.json`, `wp2_final_report.txt` | — | duplicates of the `ps5_wp1\u002F2` files |\n\u003C\u002Fdetails>\n\n\u003Cdetails>\n\u003Csummary>\u003Cb>\u003Ccode>gdb\u002F\u003C\u002Fcode> — 165 files of forensics\u003C\u002Fb>\u003C\u002Fsummary>\n\n* **136 `.gdb` command scripts**, named by round: `wp7c…e`, `wp8_*`, `wp9a…k`, `wp11a…j`, `wp15_gdb_c1…6`, `wp16_gdb_c1…26`, `wp17_gdb_c1…25`, `wp18_gdb_c1…10`, `wp19_gdb_c1…33 + phase1\u002F2`, `wp20_catch_memset`, `wp20\u002F21\u002F22_gdb_probe`.\n* **Captured outputs** `gdb_*.txt` — allocator chains (`gdb_alloc*`), IVT hunts (`gdb_ivt*`), mutex\u002Fspin (`gdb_mutex`, `gdb_spin`), power-management (`gdb_pm*`), trap-9 (`gdb_trap9`), sampling (`gdb_sample`), origins (`gdb_origin`, `gdb_hunt3\u002F4`).\n* **`wp7_msgbuf.bin`** — a 98,304-byte msgbuf dump; `wp8_fnscan.py`, `wp8_probe.sh`, `wp8_sysinit_trace.txt`.\n* `wp20_gdb_probe.gdb` shows the standard probe: it reads the SYSINIT compact-end\u002Fscan-base\u002Fbeing-run globals (`0xa19781a8 \u002F b0 \u002F 0xa1978198`) and counts done-stamped vs pending slots.\n\u003C\u002Fdetails>\n\n\u003Cdetails>\n\u003Csummary>\u003Cb>\u003Ccode>scripts\u002F\u003C\u002Fcode> — 385 files (302 \u003Ccode>.py\u003C\u002Fcode>, 80 \u003Ccode>.sh\u003C\u002Fcode>, 3 \u003Ccode>.asm\u003C\u002Fcode>)\u003C\u002Fb>\u003C\u002Fsummary>\n\n| Family | Files | Role |\n|---|---:|---|\n| `wp1_*`, `wp1_lib.py` | 12 | WP1 analysis: hypercall ABI, MSR table, entry\u002Fsysinit, compile scripts, shared helpers (VA↔offset, call-target map, back-sweep verifier) |\n| `wp2_*` | 14 | machine_init dissection, globals, `.bss` sanitisation, sysinit plan, ELF builder, final verifier |\n| `wp3_*` | 17 | pmap\u002Fconsole forensics, `wp3_3_build.py`, **`wp3_5_build.py`** (generates `patches.inc`, 584→676 patches) |\n| `wp4_*`–`wp6_*` | 19 | forensics, timer, backtrace\u002Fstep\u002Fsample scripts |\n| `wp7_*`–`wp10_*` | 14 | first baked-image patchers (`wp7_patch_kernel.py` etc.) |\n| `wp11_*` … `wp29_*` | 262 | **178 `*_patch_*.py`** (one per fix), **19 `wpNN_build_all.sh`** (the reproducible chains WP11…WP29), `*_gdb_run.sh`, recon\u002Fscan\u002Fanalysis tools (`wp26_recon`, `wp27_recon\u002Frecon2\u002Fscan`, `wp28_1…7`, `wp29_1…5c`, `wp22_an_g29*`, `wp24_an_g42*`) |\n| `wp30_auto.py`, `wp31_build_from_wp29.py`, `apply_all_wp1_to_wp32_patches.py` | 3 | WP30–WP32 tooling |\n| autopilot family | 5 | `autopilot_to_park`, `finish_to_park`, `guaranteed_park`, `final_sprint`, `checkmate_park` |\n| `s4…s13*.sh`, `sample*.sh`, `bp_test`, `bytes_test`, `deep*.sh`, `putc_test`, `qdbg`, `find_rsdp` | ~30 | ad-hoc GDB hunt scripts |\n| `kdis.py`, `xref.py`, `sc.py`, `dump_first_pass.py` + `dump_pass1b\u002Fc\u002Fd.py` | 7 | **tools:** disassembler \u002F data reader (`dis`, `rd`, `q`, `d`, `find`, `findq`, `callers`, `str`), RIP-relative xref finder, entropy\u002Fmagic probe, first-pass dump mining |\n| `make_kernel_raw.py`, `run_local.sh`, `trampoline.asm`, `msrprobe*.asm`, `apply_final_patches.py`, `harvest_all_wps.py` | 7 | builder\u002Frunner\u002Fsource files; `harvest_all_wps.py` is the script that collected this repo (Persian comments) |\n\u003C\u002Fdetails>\n\n---\n\n## 🔐 Integrity & reproducibility\n\nEvery stage of the chain is pinned by an md5 and every image is exactly **65,224,704 bytes**. The `wpNN_build_all.sh`\nscripts chain these as gates (`|| exit 1`).\n\n| Stage | md5 | What changed |\n|---|---|---|\n| WP7 kit base | `f242f55e…` *(prefix only in the worklog)* | pristine base for the WP12+ chains |\n| WP18 golden | `7b34855040fb6504078d5370b103a072` | rollback anchor used by WP20 |\n| WP21 result | `4dea684be5d34bb6b07ed0cafc72947d` | G16–G28 |\n| WP22 | `2f821627fc6f9277b30c0ca9d60b6e5c` | G29–G38 (boot-verified: parks at `Device configuration finished.`) |\n| WP23 | `f1cedeeefdc7e1cf8ad403b1df8a3575` | G39–G41 |\n| WP24 | `697f263214a4104623bad46a83c75537` | G42 |\n| WP25 | `5d438a939e327950884e8e97289d18a6` | G43 (`3a3913c0…`) + G44 |\n| WP26 | `a822c626c50d38a29af2c0a4960d9dae` | G45 + G46 |\n| WP27 *(discarded)* | `e7962171e0918e27152a141d9d4fa40e` | G47 + G48 — regressed early boot |\n| WP27, G47 only | `175a002cf7665ff88bb43a04241a6d95` | the user's rebuilt base |\n| WP28 | `a7f800301bb9571039aff7ab61ce23b8` | G49 + G50 |\n| WP29 | `e9cccbeb03f468c4708d53361fbde1f6` | G51 |\n| WP30 | `706ec1eeb50ae46ee0e47a0c4d11c8ea` | G52 |\n| WP31 | `c85632c931c85b4ec2ae1db1a2ba3374` | G53 + G54 |\n| **Shipped image** | **`520808c90b58241f454baeae0db0c8cc`** | cumulative WP1 → WP32 *(checked against the archive's `kernel_raw.bin`)* |\n| `…pre_autopilot.bak` | `7930779699f1b2df2cb71441cfe38776` | backup before the autopilot scripts *(checked)* |\n| input of `apply_all_wp1_to_wp32_patches.py` | `488414ba12dae305091401cab5342735` | \"Pristine Reconstructed\" image |\n| base of `build_kernel.py` | `ca43f306298bab963974f2c2b028f4b8` | the public-dump-derived base |\n\nOther fixed points: public dump SHA-256 `c3f745e2…cddd`, reconstructed ELF SHA-256 `e87dbe64…7cae`, trampoline patch count `676`.\n\n```bash\n# verify what you have\nmd5sum wp3_boot\u002Fkernel_raw.bin\n# expected: 520808c90b58241f454baeae0db0c8cc\nstat -c '%s' wp3_boot\u002Fkernel_raw.bin\n# expected: 65224704\n```\n\n---\n\n## ⚠️ Known limitations & honest caveats\n\n1. **Not a PS5 emulator.** Only the kernel runs, as an x86-64 FreeBSD-style kernel. No userland, no GPU (Oberon), no SSD complex, no Syscon\u002FTitania\u002FBaikal devices — the SBL\u002Fmailbox lines (`sceSblDriverSendMsg 1073774592`) fail by design.\n2. **The \"ENOMEM era\".** Most `kthread_add` \u002F `kproc_create` calls fail on purpose (error 12), so there is no real scheduler hand-off yet. The designed end-of-walk park (`WP23: sysinit walk complete; parking.`) is **not** present in the shipped `serial.log`.\n3. **TCG only.** Under KVM, remaining `rdmsr` sites and the unknown-MSR policy of the host may fault. LAPIC calibration fails (`calib failed(…)`, fallback 12.5 MHz) and TSC warnings are expected.\n4. **Seed-window audit.** The arena pool and the malloc window overlap in `[0x3F200000, 0x3F740000)` as recorded (see the audit note).\n5. **Documentation drift.**\n   * The worklog ends at **WP29**; WP30–WP32 and the autopilot scripts are known only from script headers.\n   * The relation between the WP31 image (`c85632c9…`) and the shipped WP32 image (`520808c9…`) is **not documented**.\n   * `build_kernel.py` and `apply_all_wp1_to_wp32_patches.py` start from *different* base md5s (`ca43f306…` vs `488414ba…`); I could not reconcile them without the base files.\n   * `run.sh`'s header still says \"WP7 kit\"; the previous README mixed WP31 and WP7 text.\n   * `scripts\u002Fkir.sh` actually contains a **Python** script (a copy of `wp31_build_from_wp29.py`).\n   * Many scripts hard-code the original sandbox paths (`\u002Fhome\u002Fz\u002Fmy-project`, `~\u002Flol`) — edit before running (`run_gdb.sh`, `wp*_gdb_run.sh`, `xref.py`, `harvest_all_wps.py`).\n6. **The chains need baselines that are not in this archive** (pristine WP7 kit, the WP20 golden image, the reconstructed ELF). Use Path B\u002FD, or the incremental modes of the late `build_all` scripts.\n7. **Self-reported numbers.** Counts like \"done 1,006\u002F1,236\" come from the worklog's GDB probes; the logs in `docs_reports\u002F` are the primary evidence.\n8. **Archive format.** BCJ2 filter — extract with `7z`, not `py7zr`.\n\n### Scope & legal note\n\nThis is reverse-engineering\u002Finteroperability research on a **publicly available** kernel dump. The kit contains **no keys,\nno firmware (PUP) contents, no game or userland code.** `wp3_boot\u002Fkernel_raw.bin` is, however, a patched derivative of a Sony kernel\nimage: check the rules in your jurisdiction before redistributing it. `fetch_and_build.sh` + `build_kernel.py` exist so that the\nimage can be rebuilt locally from the public dump instead of being shipped. This project is not affiliated with or endorsed by\nSony Interactive Entertainment.\n\n---\n\n## 🧭 Next steps & triage playbook\n\n**Where things stand.** The last line of the shipped log is `sx_slock(allproc): SceSwapper has nonsleeping lock` after the\n`TSC-low` timecounter registration (sysinit #1328 era). No trap, panic or dump follows. Whether QEMU then idles or spins is not\nrecorded — **first re-run and look.**\n\nThe tail of the shipped `serial.log` (text, not a screenshot):\n\n```text\nfailed to kick bufdaemon 'SceBufdaemon2'\nWarning: invalid tsc freq = 147173365\n_taskqueue_start_threads: kthread_add(cpumode_taskq): error 12\nERROR: sblServiceRequest(103) sceSblDriverSendMsg 1073774592\nERROR: ivmStart(528) SysMail failed: 1073774592\nTSC clock: 1600000000 Hz\nTSC timecounter discards lower 7 bit(s)\nTimecounter \"TSC-low\" frequency 12500000 Hz quality 1000\nmodule_register_init: MOD_LOAD (a53mm, 0xffffffff9e6588e0, 0) error 16\ncdinit_proc kproc_create fail.\nERROR: sblServiceRequest(103) sceSblDriverSendMsg 1073774592\nERROR: sceSblServiceSpawn(179) sceSblServiceSysMailSend 1073774592\nsx_slock(allproc): SceSwapper has nonsleeping lock\n```\n\n```bash\n# 1) boot and classify the end state\nbash run.sh 240 > \u002Fdev\u002Fnull 2>&1\ngrep -aE 'Fatal trap|panic:|kernel trap|double fault|instruction pointer|mDBG: System error' serial.log | head\ntail -n 8 serial.log\n```\n\n```bash\n# 2) if the log is silent, boot with the gdbstub open (terminal 1) ...\nqemu-system-x86_64 -L .\u002Fbios -M pc -cpu EPYC -m 2G -smp 8 \\\n  -kernel wp3_boot\u002Ftrampoline.elf -initrd wp3_boot\u002Fkernel_raw.bin \\\n  -display none -serial null -monitor none \\\n  -chardev file,id=dbg,path=serial.log \\\n  -device isa-debugcon,iobase=0x402,chardev=dbg \\\n  -gdb tcp::1234 -no-reboot\n```\n\n```bash\n# ... and attach after ~15 s of silence (terminal 2)\ngdb -q -batch \\\n  -ex 'set architecture i386:x86-64' \\\n  -ex 'target remote :1234' \\\n  -ex 'info registers rip rsp rbp rdi rsi rdx r12 r14' \\\n  -ex 'x\u002F16gx $rsp'\n```\n\n**Classify, then fix** (see the [taxonomy](#-crash-class-taxonomy)):\n\n| Observation | Likely class | First move |\n|---|---|---|\n| `Fatal trap 12`, small `CR2` | ENOMEM-era NULL deref (#7) | `python3 scripts\u002Fkdis.py dis \u003Crip>`; find the NULL register; guard + exit via the fn's own error value |\n| silence, `rip` in `malloc` small path, `r12 = 0x102` | `M_WAITOK` livelock (#14) or cyclic list (#15) | decode saved `r14`\u002F`rbx` in the frame — they identify the dispatcher |\n| silence, `rip` in a tight `je` loop | spin on never-completing wait (#11) \u002F residue lock (#3) | `finish_to_park.py`-style loop break, or answer the wait instantly |\n| `panic:` from a canonical FreeBSD string | designed panic | retarget the `je` to the function's clean epilogue |\n| `#DF` with odd `rip` | frame-math artefact (#10) | check for pending IRQs \u002F error-code-less vectors |\n\n**Pre-triaged shortlists:** `docs_reports\u002Fwp29_retry_scan.txt` (863 patterns), `wp28_report.txt` (R1 rows),\n`wp27_g48_report.txt` (3 skipped + 19 BSS candidates), `wp26_g46_report.txt` (184 skipped panic sites).\n\n**Roadmap beyond SYSINIT (from the worklog):** scheduler hand-off at `0x9e92aa50` (kthreads, idle loop) → real device models\n(AHCI\u002Fscbus) → GPU\u002FSyscon stubs → KVM with an out-of-tree hypercall\u002FMSR shim (stock KVM answers unknown `VMMCALL` with `-ENOSYS`).\n\n---\n\n## 📖 Glossary\n\n| Term | Meaning here |\n|---|---|\n| **Orbis** | Sony's FreeBSD-derived OS (kernel sources tagged `W:\u002FBuild\u002FJ03950001\u002Fsys\u002Ffreebsd\u002F…`) |\n| **btext** | cold-boot entry point (`0xffffffff9e642a90`) |\n| **SYSINIT \u002F `mi_startup`** | FreeBSD's ordered init-stage array and the loop that runs it |\n| **modulep \u002F physfree** | preload-metadata page and first free physical page handed over by the loader (as *page numbers* on the stack) |\n| **SMAP** | two unrelated things: the **BIOS memory map** in preload metadata (`MODINFOMD_SMAP`) and the CPU feature *Supervisor Mode Access Prevention* (`CPU Features: SMAP Enabled`) |\n| **DMAP \u002F KVA** | direct map of physical memory \u002F kernel virtual window (`0xFFFFFFFF80000000 + PA`) |\n| **Residue** | stale pointers\u002Fstate in the live dump that are meaningless on a cold VM |\n| **Cave \u002F slot \u002F seed \u002F guard** | see [Patch methodology](#-patch-methodology-caves-slots-seeds) |\n| **ENOMEM era** | the phase in which allocations\u002Fkprocs deliberately fail with error 12 and the kernel's error paths carry the boot |\n| **CFI** | Clang control-flow-integrity checks (5,629 sites) |\n| **mDBG** | Sony's debug\u002Fsystem-dump subsystem (`Performing systemdump`) |\n| **Titania \u002F Baikal \u002F CCP** | security processor \u002F southbridge \u002F crypto subsystem (named from kernel strings) |\n| **PPR16** | memory profile 1: GDDR6 16 GiB, DDR5 0 GiB |\n| **TCG** | QEMU's software CPU emulation (no KVM) |\n| **debugcon** | QEMU `isa-debugcon` device; I\u002FO port `0x402` is the log channel |\n| **WPn \u002F Gn** | work package *n* \u002F numbered guard *n* (G1 … G54) |\n\n---\n\n## 🙏 Credits & sources\n\n* Public 13.60 kernel dump: `terrafirma2021\u002Fps5-13.60-kernel-dump`.\n* Tooling: QEMU, SeaBIOS, GDB, capstone, keystone, nasm\u002Fbinutils.\n* Reference material used for cross-checking: FreeBSD 9.3 `kernel.h` (`SI_SUB` enum) and public PS5 research (TitaniaPy, Byepervisor-Reborn notes, the Orbital PS4 emulator as an LLE precedent).\n\n\u003Cdiv align=\"center\">\n\n*Every line of the boot log above was printed by Sony's own kernel, not by us.*\n\n\u003C\u002Fdiv>\n","该项目是一个用于在标准x86-64 QEMU虚拟机中启动未修改的PlayStation 5（系统版本13.60）内核的研究工具链。它通过手工构建的多引导加载器、676处内存补丁及50余个崩溃防护点，使源自FreeBSD的PS5内核成功执行完整SYSINIT初始化流程，直至进入SceSwapper空闲状态，并输出原生内核启动日志与Banner。核心技术包括内核二进制动态修补、硬件抽象层适配、QEMU TCG环境下的状态模拟与可复现崩溃防护机制。适用于操作系统底层研究、主机平台内核逆向分析、嵌入式\u002F定制OS启动验证等安全与系统开发场景。",2,"2026-11-24 04:54:05","CREATED_QUERY"]