unkernel-rs 0.7.0

Native Rust + Wasmtime host library and CLI for unkernel (Linux 7.x on WebAssembly) — zero Node, zero JSPI, zero KVM
Documentation
# unkernel-rs

Native Rust + `wasmtime` host library and CLI for [`pithings/unkernel`](https://github.com/pithings/unkernel) — booting an unmodified Linux 7.x Wasm kernel and `aarch64` Alpine/Debian rootfs without Node.js, V8, JSPI, Docker, or `/dev/kvm`.

## Architecture

- **Library + binary crate:** `src/lib.rs` exports the embeddable Rust API (`Vm`, `VmConfig`, `ExecOptions`, `Mount`); `src/main.rs` provides the `unkernel-rs` CLI (`exec`, `shell`, `serve`, `bench`, `fetch`).
- **Task switching without JSPI:** Unpacks the SMP kernel patch (`unkernel.kernel.smp.kwpatch`) natively in `src/kwpatch.rs`. Because the SMP module uses `SharedMemory`, 38 passive data segments initialized atomically once, and only 5 mutable globals (`__stack_pointer`, `__tls_base`, `current`, `kw_irq_flags`, `kw_irq_word`), each Linux kernel task runs in its own `wasmtime::Store` + `Instance` on an OS thread cooperatively (`wasm_cpu_count = 1`), exchanging the 5 globals over an `mpsc::sync_channel(1)`.
- **Guest JIT:** `src/jit.rs` implements `kw_host_jit_*` using Cranelift (`wasmtime::Module::new`) and syncs compiled slots across per-task `Store`s via an atomic `jit_epoch` counter.
- **Host I/O & isolation:** `src/vsock.rs`, `src/kwtty.rs`, and `src/fs9p.rs` expose structured `exec` and scoped host 9P2000.L mounts without exposing host networking or host paths outside configured mounts. `src/sandbox.rs` applies `wasmtime` resource/epoch limits and Linux Landlock + `PR_SET_NO_NEW_PRIVS` self-sandboxing.

## Licensing Boundary

This repository is dual-licensed MIT OR Apache-2.0. Do **not** commit `unkernel.wasm` (GPL-2.0-only) or distro `.erofs` images into Git; fetch and cache them at runtime in `~/.cache/unkernel-rs/` with pinned SHA-256 verification.

## Build & Verify

```bash
export PATH="$HOME/.cargo/bin:$PATH"
cargo test --release
cargo run --release -- exec -- uname -a
```