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 / m3 / atlas_m3.s
| 1 | /* |
| 2 | * m3/atlas_m3.s - Atlas Bootstrap Seed for Milestone 3 (PHYSICS_EFFECTS) |
| 3 | * Target Platform: QEMU virt AArch64 / Sovereign Machine |
| 4 | * Normative Base: 0x00000000 |
| 5 | * |
| 6 | * Populates Machine Boot Descriptor @ 0x401FE000, verifies physics.bin |
| 7 | * (18,432 bytes) at 0x40200000 with NIST SHA-256 against pinned digest, |
| 8 | * sets up PHYSICS_ENTRY_ABI registers, and executes handoff jump. |
| 9 | */ |
| 10 | |
| 11 | .ifndef DESC_MAGIC |
| 12 | .equ DESC_MAGIC, 0x4D424453435F3031 |
| 13 | .endif |
| 14 | .ifndef DESC_VERSION |
| 15 | .equ DESC_VERSION, 1 |
| 16 | .endif |
| 17 | .ifndef DESC_LENGTH |
| 18 | .equ DESC_LENGTH, 64 |
| 19 | .endif |
| 20 | .ifndef DESC_FLAGS |
| 21 | .equ DESC_FLAGS, 0 |
| 22 | .endif |
| 23 | .ifndef DESC_RAM_BASE |
| 24 | .equ DESC_RAM_BASE, 0x40000000 |
| 25 | .endif |
| 26 | .ifndef DESC_RAM_SIZE |
| 27 | .equ DESC_RAM_SIZE, 0x08000000 |
| 28 | .endif |
| 29 | .ifndef DESC_UART_BASE |
| 30 | .equ DESC_UART_BASE, 0x09000000 |
| 31 | .endif |
| 32 | .ifndef DESC_PHYSICS_BASE |
| 33 | .equ DESC_PHYSICS_BASE, 0x40200000 |
| 34 | .endif |
| 35 | .ifndef DESC_PHYSICS_SIZE |
| 36 | .equ DESC_PHYSICS_SIZE, 18432 |
| 37 | .endif |
| 38 | .ifndef ABI_X0 |
| 39 | .equ ABI_X0, 0x401FE000 |
| 40 | .endif |
| 41 | .ifndef ABI_X1 |
| 42 | .equ ABI_X1, 18432 |
| 43 | .endif |
| 44 | .ifndef ABI_X2 |
| 45 | .equ ABI_X2, 0x5048595349435330 |
| 46 | .endif |
| 47 | |
| 48 | .global _start |
| 49 | .section .text |
| 50 | .balign 64 |
| 51 | |
| 52 | _start: |
| 53 | /* 1. Mask all interrupts (DAIF) */ |
| 54 | msr daifset, #0xf |
| 55 | |
| 56 | /* 2. Initialize Stack Pointer in scratchpad RAM (0x401FC000) */ |
| 57 | ldr x0, =0x401FC000 |
| 58 | mov sp, x0 |
| 59 | |
| 60 | /* 3. Emit Checkpoint 1: AWAKEN */ |
| 61 | adr x21, msg_awaken |
| 62 | bl print_string |
| 63 | |
| 64 | /* 4. Populate Machine Boot Descriptor @ 0x401FE000 */ |
| 65 | ldr x22, =0x401FE000 |
| 66 | ldr x0, =DESC_MAGIC |
| 67 | str x0, [x22, #0] |
| 68 | ldr w0, =DESC_VERSION |
| 69 | str w0, [x22, #8] |
| 70 | ldr w0, =DESC_LENGTH |
| 71 | str w0, [x22, #12] |
| 72 | ldr x0, =DESC_FLAGS |
| 73 | str x0, [x22, #16] |
| 74 | ldr x0, =DESC_RAM_BASE |
| 75 | str x0, [x22, #24] |
| 76 | ldr x0, =DESC_RAM_SIZE |
| 77 | str x0, [x22, #32] |
| 78 | ldr x0, =DESC_UART_BASE |
| 79 | str x0, [x22, #40] |
| 80 | ldr x0, =DESC_PHYSICS_BASE |
| 81 | str x0, [x22, #48] |
| 82 | ldr x0, =DESC_PHYSICS_SIZE |
| 83 | str x0, [x22, #56] |
| 84 | |
| 85 | /* 5. Emit Checkpoint 2: VERIFY */ |
| 86 | adr x21, msg_verify |
| 87 | bl print_string |
| 88 | |
| 89 | /* 6. Verify PHYSICS Integrity using SHA-256 */ |
| 90 | ldr x0, =0x40200000 /* Payload base */ |
| 91 | ldr x1, =18432 /* Payload size */ |
| 92 | ldr x2, =0x401FE100 /* 128-byte scratchpad */ |
| 93 | ldr x3, =0x401FE080 /* 32-byte digest output buffer */ |
| 94 | bl sha256_compute |
| 95 | |
| 96 | /* 7. Compare computed digest with pinned digest */ |
| 97 | ldr x0, =0x401FE080 |
| 98 | adr x1, pinned_physics_sha256 |
| 99 | mov x2, #4 /* 4 pairs of 64-bit words */ |
| 100 | .Lcmp_digest: |
| 101 | cbz x2, .Lverify_pass |
| 102 | ldr x3, [x0], #8 |
| 103 | ldr x4, [x1], #8 |
| 104 | cmp x3, x4 |
| 105 | b.ne .Lverify_fail |
| 106 | sub x2, x2, #1 |
| 107 | b .Lcmp_digest |
| 108 | |
| 109 | .Lverify_pass: |
| 110 | /* 8. Emit Checkpoint 3: HANDOFF */ |
| 111 | adr x21, msg_handoff |
| 112 | bl print_string |
| 113 | |
| 114 | /* 9. Set up PHYSICS_ENTRY_ABI registers */ |
| 115 | ldr x0, =ABI_X0 |
| 116 | ldr x1, =ABI_X1 |
| 117 | ldr x2, =ABI_X2 |
| 118 | ldr x19, =0x40200000 |
| 119 | br x19 /* Transfer physical authority to Physics */ |
| 120 | |
| 121 | .Lverify_fail: |
| 122 | adr x21, msg_panic_verify |
| 123 | bl print_string |
| 124 | .Lpanic_halt: |
| 125 | wfe |
| 126 | b .Lpanic_halt |
| 127 | |
| 128 | /* Diagnostic UART */ |
| 129 | print_string: |
| 130 | ldr x20, =0x09000000 |
| 131 | .Lput_loop: |
| 132 | ldrb w0, [x21], #1 |
| 133 | cbz w0, .Lput_done |
| 134 | 1: ldrb w1, [x20, #24] |
| 135 | tst w1, #32 |
| 136 | b.ne 1b |
| 137 | strb w0, [x20] |
| 138 | b .Lput_loop |
| 139 | .Lput_done: |
| 140 | ret |
| 141 | |
| 142 | .section .rodata |
| 143 | .balign 8 |
| 144 | msg_awaken: |
| 145 | .asciz "ATLAS: AWAKEN\n" |
| 146 | msg_verify: |
| 147 | .asciz "ATLAS: VERIFY\n" |
| 148 | msg_handoff: |
| 149 | .asciz "ATLAS: HANDOFF\n" |
| 150 | msg_panic_verify: |
| 151 | .asciz "PANIC: VERIFICATION_FAILED\n" |
| 152 | |
| 153 | .balign 8 |
| 154 | pinned_physics_sha256: |
| 155 | .include "m3_physics_pin.inc" |