physics-mv
FORGE: request-bound machine realization, providers and verification for AienOS. Host, simulated and GB10 hardware paths have separate evidence.
Brought by drakestapleton
physics-mv / physics.control-flow
| 1 | # PHYSICS AUTHORITY NUCLEUS CONTROL FLOW SPECIFICATION |
| 2 | ## Milestone 2: Deterministic Boot Sequence & Fault Confinement |
| 3 | |
| 4 | ### Flowchart Overview |
| 5 | ```mermaid |
| 6 | graph TD |
| 7 | A[Atlas Handoff br x19 @ 0x40200000] --> B{Verify Cookie x2 == 'PHYSICS0'?} |
| 8 | B -- Mismatch --> C[Panic: Bad Cookie -> Quiescent Halt wfe] |
| 9 | B -- Valid --> D{Verify Descriptor x0 == 0x401FE000?} |
| 10 | D -- Mismatch --> E[Panic: Bad Descriptor -> Quiescent Halt wfe] |
| 11 | D -- Valid --> F[Read Boot Descriptor: RAM Base, RAM Size, UART Base] |
| 12 | F --> G[Migrate Stack: SP = 0x40208000] |
| 13 | G --> H[Emit Telemetry: PHYSICS: AWAKEN & DESCRIPTOR_VALID] |
| 14 | H --> I{Query CurrentEL} |
| 15 | I -- EL1 --> J[msr vbar_el1, x1] |
| 16 | I -- EL2 --> K[msr vbar_el2, x1] |
| 17 | J --> L[Emit Telemetry: PHYSICS: VBAR_INSTALLED] |
| 18 | K --> L |
| 19 | L --> M[Call frame_allocator_init: Window 0x40208000..DRAM_END] |
| 20 | M --> N[Emit Telemetry: PHYSICS: MEMORY_BOUND] |
| 21 | N --> O[Call root_capability_synthesis: Synthesize CAP_ROOT @ 0x40206000] |
| 22 | O --> P[Emit Telemetry: PHYSICS: ROOT_CAP_GENESIS] |
| 23 | P --> Q[Emit Telemetry: PHYSICS: QUIESCENT_READY] |
| 24 | Q --> R[Terminal Quiescence Loop: wfe; b .] |
| 25 | |
| 26 | subgraph Exception Confinement [VBAR Vector Traps @ 0x40201000] |
| 27 | S[Trap Triggered: Sync / IRQ / FIQ / SError] --> T[Preserve GPRs x0-x30] |
| 28 | T --> U[Capture Raw State: CurrentEL, ESR, FAR, ELR, SPSR] |
| 29 | U --> V[Emit Raw Hex Telemetry to Console] |
| 30 | V --> W[Fail-Closed Quiescence: wfe; b .] |
| 31 | end |
| 32 | ``` |
| 33 | |
| 34 | ### Textual State Machine Transition Sequence |
| 35 | 1. **ENTRY STATE**: Invoked from Atlas via `br x19` at `0x40200000`. |
| 36 | - `x0`: Pointer to Machine Boot Descriptor at `0x401FE000`. |
| 37 | - `x1`: Payload size. |
| 38 | - `x2`: Verification Cookie `0x5048595349435330` (`PHYSICS0`). |
| 39 | - Interrupts masked (`DAIF = 0x3c0`). |
| 40 | 2. **INGRESS VALIDATION**: |
| 41 | - Compares `x2` to literal `'PHYSICS0'`. Mismatch vectors to `.Lpanic_bad_cookie`. |
| 42 | - Compares `x0` to literal `0x401FE000`. Mismatch vectors to `.Lpanic_bad_descriptor`. |
| 43 | 3. **STACK ISOLATION**: |
| 44 | - Updates `SP` to dedicated kernel stack `0x40208000` (or `0x40205800`), completely vacating and uncoupling Atlas scratchpad RAM. |
| 45 | 4. **TELEMETRY & VBAR REGISTRATION**: |
| 46 | - Emits `"PHYSICS: AWAKEN |
| 47 | "` and `"PHYSICS: DESCRIPTOR_VALID |
| 48 | "`. |
| 49 | - Loads `vector_table` address (`0x40201000`). Checks `CurrentEL` and programs `VBAR_EL1` or `VBAR_EL2`. |
| 50 | - Emits `"PHYSICS: VBAR_INSTALLED |
| 51 | "`. |
| 52 | 5. **PHYSICAL FRAME AUTHORITY**: |
| 53 | - Invokes `frame_allocator_init(ram_base, ram_size)`. |
| 54 | - Calculates available frames above `0x40208000` up to `DRAM_END`. |
| 55 | - Clears frame bitmask in static memory. |
| 56 | - Emits `"PHYSICS: MEMORY_BOUND |
| 57 | "`. |
| 58 | 6. **CAPABILITY GENESIS**: |
| 59 | - Invokes `root_capability_synthesis()`. |
| 60 | - Writes `CAP_ROOT` record at `0x40206000` (or `0x40209000`), anchoring pinned Atlas SHA-256 provenance hash. |
| 61 | - Emits `"PHYSICS: ROOT_CAP_GENESIS |
| 62 | "`. |
| 63 | 7. **TERMINAL QUIESCENCE**: |
| 64 | - Emits `"PHYSICS: QUIESCENT_READY |
| 65 | "`. |
| 66 | - Executes `wfe; b .` waiting for authoritative sovereign workload synthesis. |
| 67 | 8. **FAULT CONFINEMENT**: |
| 68 | - Any synchronous exception, unmapped access, or fault traps into `VBAR` at `0x40201000`. |
| 69 | - Trap handler saves full context, logs diagnostic crash telemetry, and halts safely in `wfe; b .`. |