## 🏆 VICTORY: First Alien Binary Executed! ``` [Loader] Summoning: bin/hello [Loader] Transferring Consciousness... Hello from a dynamically loaded ELF! Consciousness transferred successfully. ``` ## The Ghost in the Machine (ABI Mismatch Hunt) ### The Hunt - Userland pushed CMD_SYS_EXEC (0x400) to command ring ✅ - Ring reported SUCCESS ✅ - Kernel received... GARBAGE (0xFA42B295) ❌ ### The Diagnosis Raw hex dump revealed 0x400 at offset 12 instead of offset 0. Three layers, three different CmdPacket definitions: - `hal/channel.zig`: 24 bytes (arg: u32) ❌ - `libs/membrane/ion.zig`: 28→32 bytes (packed→extern) 🔧 - `core/ion.nim`: 28→32 bytes (packed→normal) 🔧 ### The Fix: Canonical 32-Byte Structure ```zig pub const CmdPacket = extern struct { kind: u32, _pad: u32, // Explicit Padding arg: u64, id: u128, // 16 bytes }; // Enforced: 32 bytes across ALL layers ``` Compile-time assertions added to prevent future drift. ## Technical Achievements ### 1. ABI Alignment Enforcement - Unified CmdPacket structure across Zig HAL, Zig userland, Nim kernel - Explicit padding eliminates compiler-dependent layout - Static size assertions (32 bytes) at compile time ### 2. Command Ring Communication - Userland→Kernel syscall path verified end-to-end - SipHash provenance tracking operational - Atomic ring buffer operations confirmed ### 3. ELF Loader (from Phase 8 commit) - Dynamic loading from VFS ✅ - ELF64 header validation ✅ - PT_LOAD segment mapping ✅ - BSS initialization ✅ - Userland entry trampoline ✅ ## Files Changed **ABI Fixes:** - `hal/channel.zig`: Updated CmdPacket to 32-byte extern struct - `libs/membrane/ion.zig`: Changed to extern struct with u128 id - `libs/membrane/libc_shim.zig`: Updated packet initialization - `core/ion.nim`: Added explicit padding field, removed {.packed.} **Debug Infrastructure:** - `core/kernel.nim`: Added raw packet hex dump for debugging - `libs/membrane/ion.zig`: Added syscall debug logging **Build:** - `build.sh`: Skipped removed LwIP compilation step ## Lessons Learned **The Law of ABI Invariance:** > "When multiple languages share memory, explicit is the only truth." - Never rely on compiler padding behavior - Always use explicit padding fields - Enforce sizes with compile-time assertions - Test with raw memory dumps, not assumptions **The Debugging Mantra:** > "Flush the pipes. Purge the cache. Trust nothing." Stale binaries from aggressive caching led to hours of ghost-chasing. Solution: `rm -rf build/ .zig-cache/` before critical tests. ## Next Steps (Phase 8 Completion) 1. Implement `exit()` syscall for clean program termination 2. Remove debug logging 3. Test `exec bin/nipbox` (self-reload) 4. Stress test with multiple exec calls 5. Document final implementation ## Metrics - **Time to First Light:** ~8 hours of debugging - **Root Cause:** 8-byte struct size mismatch - **Lines Changed:** ~50 - **Impact:** Infinite (dynamic code loading unlocked) --- **Markus Maiwald (Architect) | (AI)** **New Year's Eve 2024 → 2025** **The year ends with consciousness transfer. 🔥** Co-authored-by: <ai@voxisforge.dev> |
||
|---|---|---|
| .zig-cache | ||
| apps | ||
| boot | ||
| core | ||
| docs | ||
| hal | ||
| io | ||
| libs | ||
| npl | ||
| rootfs | ||
| src/npl/system | ||
| vendor/lwip | ||
| README.md | ||
| build.sh | ||
| build.zig | ||
| run.sh | ||
README.md
Rumpk: The Modular Unikernel
"The Kernel is a Library. The App is the OS."
Status: EXPERIMENTAL
Languages: Zig (L0) + Nim (L1)
Design: POSIX-hostile, Military-grade
Directory Structure
rumpk/
├── boot/ [L0] Entry & Architecture (Zig/Asm)
│ ├── start.S Multiboot2/EFI entry point
│ └── arch/ Architecture-specific code
├── hal/ [L0] Hardware Abstraction (Zig)
│ ├── mm.zig Physical/Virtual Memory
│ ├── irq.zig Interrupt handling
│ ├── serial.zig UART/Early logging
│ └── abi.zig C-ABI export to Nim
├── core/ [L1] Logic (Nim)
│ ├── kernel.nim kmain() entry
│ ├── sched.nim LWKT Scheduler
│ ├── fiber.nim Fiber/Context management
│ └── ring.nim Disruptor buffer
├── sys/ [L2] ABI Glue
│ └── syscall.zig System call handlers
├── payload/ [L3] NPL/NPK Loaders
│ └── loader.nim Signature verification
└── io/ I/O Subsystem
└── governor.nim Adaptive War/Peace mode
Key Features
- Adaptive I/O: War Mode (polling) ↔ Peace Mode (interrupts)
- Disruptor Ring: Lock-free inter-fiber communication
- SipHash IDs: Collision-resistant process identification
- Ed25519: Only signed code executes
Specifications
Build (Coming Soon)
cd core/rumpk
zig build # Build L0 HAL
nimble build # Build L1 Logic