aienux
Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.
Brought by drakestapleton
aienux / crates / aienos-artifact-tool / fixtures / p2_5 / p25exec / probe.S
| 1 | // P2-5 execution probe: AArch64 EL0, position independent, no relocations. |
| 2 | // Entry (task_runtime ABI): x0 = handle array VA, x1 = handle count, |
| 3 | // x2 = data base VA, x3 = data memory length. All other registers zero. |
| 4 | // Exit code 0 means every check passed; otherwise each set bit names one |
| 5 | // failed check: |
| 6 | // 0x01 handle count != 1 0x02 data word mismatch |
| 7 | // 0x04 data write/readback 0x08 stack write/readback |
| 8 | // 0x10 object read via handle 0x20 forged handle not denied |
| 9 | .text |
| 10 | .global _start |
| 11 | _start: |
| 12 | mov x19, x0 // handle array |
| 13 | mov x20, x1 // handle count |
| 14 | mov x21, x2 // data base |
| 15 | mov x22, xzr // failure bitmask |
| 16 | |
| 17 | // 0x01: exactly one granted handle |
| 18 | cmp x20, #1 |
| 19 | b.eq 1f |
| 20 | orr x22, x22, #0x01 |
| 21 | 1: |
| 22 | // 0x02: first data word is "CEXE5-2P" = 0x50322d3545584543 |
| 23 | ldr x9, [x21] |
| 24 | movz x10, #0x4543 |
| 25 | movk x10, #0x4558, lsl #16 |
| 26 | movk x10, #0x2d35, lsl #32 |
| 27 | movk x10, #0x5032, lsl #48 |
| 28 | cmp x9, x10 |
| 29 | b.eq 2f |
| 30 | orr x22, x22, #0x02 |
| 31 | 2: |
| 32 | // 0x04: data is writable |
| 33 | movz x11, #0xbeef |
| 34 | movk x11, #0xdead, lsl #16 |
| 35 | str x11, [x21, #8] |
| 36 | ldr x12, [x21, #8] |
| 37 | cmp x11, x12 |
| 38 | b.eq 3f |
| 39 | orr x22, x22, #0x04 |
| 40 | 3: |
| 41 | // 0x08: stack is writable |
| 42 | sub sp, sp, #16 |
| 43 | str x11, [sp] |
| 44 | ldr x12, [sp] |
| 45 | add sp, sp, #16 |
| 46 | cmp x11, x12 |
| 47 | b.eq 4f |
| 48 | orr x22, x22, #0x08 |
| 49 | 4: |
| 50 | // No handle: both capability checks fail without touching the array. |
| 51 | cbnz x20, 5f |
| 52 | orr x22, x22, #0x30 |
| 53 | b 7f |
| 54 | 5: |
| 55 | // 0x10: SYS_OBJECT_READ(handle[0], 0) == SEED_OBJECT_WORDS[0] |
| 56 | ldr x23, [x19] |
| 57 | mov x0, x23 |
| 58 | mov x1, #0 |
| 59 | mov x8, #6 |
| 60 | svc #0 |
| 61 | movz x10, #0x0001 |
| 62 | movk x10, #0x5eed, lsl #32 |
| 63 | movk x10, #0xa1e0, lsl #48 |
| 64 | cmp x0, x10 |
| 65 | b.eq 6f |
| 66 | orr x22, x22, #0x10 |
| 67 | 6: |
| 68 | // 0x20: a forged generation must be denied (SYSCALL_DENIED = u64::MAX) |
| 69 | mov x9, #1 |
| 70 | lsl x9, x9, #32 |
| 71 | eor x0, x23, x9 |
| 72 | mov x1, #0 |
| 73 | mov x8, #6 |
| 74 | svc #0 |
| 75 | cmn x0, #1 |
| 76 | b.eq 7f |
| 77 | orr x22, x22, #0x20 |
| 78 | 7: |
| 79 | // SYS_EXIT(bitmask) |
| 80 | mov x0, x22 |
| 81 | mov x8, #2 |
| 82 | svc #0 |
| 83 | 8: b 8b |