Akuma, Bohemian Operating System
Self-hosting a Rust kernel
with mostly open models
Kirill Maksimov · rust.org.il · akuma.sh/self-hosting-rust-kernel
=#= .-
+*#*:.:-**
+%%#%##***
+%%%#%%#**.
+%@@@%%%+*:
:::::--=+++*%@%@%%%%*-
:-+##%%%%%%%%@%@#%%@%%%%##%+
.=##%%%%%%%%%@@@@@%#%%@%%%@@@%%-
.*%%%%%%%@%%%%@%@@@@%%%%@%%%%%@@#-
%@%%%%%%%%%%@%%%%%@@@%%%@@@@@%%%#+
*%%%%%@%@@%@@@%%%%#%@@@@@@@%%@@%@@@*+--
::=+*#@@@@@@@@@@@%%%%%%@%%@#----=**@%@#
.--+**%@@@@@%@@%%@@%* :-.
::::---#@%%*
Capability test
Can a weak open model write a kernel that runs real workloads?
- Why open models? Dario won’t let you write a Wi-Fi driver.
- My custom rust kernel Akuma was mostly written by commercial models and it was already self-hosting for a few months.
- To speed up kernel development I used GLM 5.3 Flash to build KVM from AMD’s spec PDFs.
- I had a talk in 10 days, a hypothesis, and a lot of free time.
The experiment
Speedrunning cargo build
- Development runs on Akuma (GLM-5.3-Flash + Goose)
- Sloppy methodology leads to questionalbe results
- Every step ends in a gate a machine can check.
- 390 interventions including real bangers like this one is a classic, read the docs with about 70% accuracy in guessing where the bugs are
- GLM reached the equivalent of a self-hosting C kernel: HTTPS
curl,apk, fork, pipes, all running on Akuma’s KVM.
AI is good at what you can verify.
The Rust bar
Rust is much harder to host
Akuma had already self-hosted Rust, so feasibility was never in question, only the route and the clock.
| Syscalls dispatched | Count | of Linux’s 383 |
|---|---|---|
C-level kernel: HTTPS curl, apk, fork, pipes, static binaries | 83 | 22% |
| The brief’s estimate for Rust (a guess, before any measurement) | ~70–90 | 18–23% |
Rust self-host: rustc, cargo -j4, K1 == K2 | 120 | 31% |
Counted from Taoxichuan’s dispatcher at the GLM handoff (bc626f98, 83 arms, 4 of them Akuma-private) and at the first fixed point (6af48c06, 120 with legacy folds).
Why Rust
Extraction is cheap, build system is excellent
| Date | Dev stage | Crates | Forbid unsafe | Auditable lines | unsafe sites | unsafe share |
|---|---|---|---|---|---|---|
| 2026-09-02 | before the amd64 port | 52 | 32 | 52,814 | 374 | 2.8% |
| 2026-09-20 | after the port’s cleanup | 70 | 50 | 76,350 | 714 | 3.4% |
| 2026-10-17 | port stabilized | 86 | 66 | 101,133 | 811 | 2.8% |
| 2026-10-24 | after KVM | 101 | 73 | 118,115 | 485 | 1.5% |
| 2026-11-02 | after Taoxichuan | 117 | 87 | 123,209 | 481 | 1.4% |
- Composition: the Taoxichuan kernel (a KVM guest) runs inside Akuma (the bare-metal KVM host), and 93% of its live lines were already live in Akuma.
- Traits and inversion of control.
- Host-tested crates make debugging cheaper.
- Isolation of
unsafein specific crates: 87 of 117 crates forbid it outright, and the rest keep it in small leaf crates.
Cleanup
GLM and Sonnet got kernel to the fixed point, Opus cleaned up
| Audit lines unless noted | Before cleanup | After cleanup | Change |
|---|---|---|---|
| The guest · Taoxichuan | |||
| Audit lines (live code in the image) | 87,761 | 77,839 | −11% |
| The kernel’s own code | 7,844 | 3,771 | −52% |
| Third-party code (crates.io) | 41,748 · 22 crates | 21,861 · 15 crates | −48% |
unsafe lines | 2,850 | 1,668 | −41% |
| Build-time host code | 31,743 | 428 | −99% |
| The host · Akuma amd64, and the two together | |||
| Host audit lines | 152,104 | 136,727 | −10% |
| Taoxichuan on an Akuma host (shared lines once) | 161,128 | 141,903 | −12% |
| What Taoxichuan adds to the host | 9,024 | 5,176 | −43% |
| Share of Taoxichuan already live in the host | 90% | 93% | +3 pts |
Less capability in theory means a smaller attack surface and it's easier to reason about
Kernel that only runs tokio
Install a kernel from crates.io, and have your whole supply chain hijacked
- Shanghai, new kernel built by GLM from a crate README.
- This kernel runs tokio.
- As a regrettable side effect, Python runs too.
//! Shanghai: a kernel built from the `akuma-tokio-kernel` README. The whole //! kernel is this file plus a skyline. #![no_std] #![no_main] akuma_tokio_kernel::entry!(main); fn main(kernel: akuma_tokio_kernel::Kernel) -> ! { kernel .name("Shanghai") .banner(include_str!("banner.txt")) .console() .disk() .net() .smp() .run_init() }
Costs and benefits
The real cost is mostly in my sanity
If GLM had done it alone (extrapolation, not a measurement)
| GLM slower than Claude by | GLM tokens | Agent-hours | One $18 Lite plan |
|---|---|---|---|
| 2× | 0.67–0.81B | 122–147 | 3.4–4.1 weeks |
| 3× | 0.81–1.03B | 147–187 | 4.1–5.2 weeks |
| 4× | 0.95–1.24B | 173–225 | 4.8–6.2 weeks |
Top row: actual numbers. GLM-alone rows: adjusted for refined process from day one, no supervision counted; extrapolated from Sonnet work as closest available model with similar capabilities.
Costs and benefits
Benefits for Akuma
| Before the experiment 2026-10-24 | Now 2026-11-03 | Change | |
|---|---|---|---|
| Crates in Akuma | 98 | 117 | +19 |
| Fixes in Akuma’s bug-fix list | 1,470 · 406 docs | 1,493 · 424 docs | +23 |
| Fixes in Taoxichuan’s own list | 0 | 119 · 35 docs | +119 |
| Third-party crates in the guest image * | 22 | 15 | −7 |
| Third-party code in the guest image, lines * | 41,748 | 21,861 | −48% |
Third-party unsafe lines in the guest image * | 1,872 | 789 | −58% |
| Build-time host code, lines * | 31,743 | 428 | −99% |
* Dependency cut: before = the cutover (2026-11-01), after = B15 (2026-11-02). The in-tree virtio driver replaced virtio-drivers and its stack in every kernel, and with it went syn, the proc-macros and most of the third-party unsafe. Our own barely moved (978 to 879 lines).
Real workload
GLM strips AWS out of an agent runtime, builds it, and runs it on the new kernel
Cargo.lock- Unattended: goose with GLM, inside a Taoxichuan guest, under Akuma’s hypervisor on bare metal.
- The job: clone infinity, cut every AWS dependency, build what is left (cut first, then build).
- It swapped OpenSSL for rustls, since the guest has no OpenSSL headers, cmake or clang.
- Proof: the agent answered
PONGthroughapi.z.ai, then ranuname -athrough its own tool path. - Three of the six builds failed on kernel bugs, which were fixed along the way.
What’s next
Hardening, then verification
Hardening
- Read-only disk image, no ext2 write paths.
- Syscall table as a compile-time allow-list built from the census.
- No dynamic library loading.
- Execution locked to signed binaries under a signed kernel.
- Egress allow-list in the socket table.
- Kernel code locked by the hypervisor through nested page tables.
- Layered walls: box, ring 3 process, KVM guest.
Verification
- Fuzzing and static analysis on the pure crates.
- Kani and Miri on the invariants.
- LLM-drafted Verus proofs for small pure crates.
- Linux differential tests.
Sources
Everything is in the repo
| What | Document | Holds |
|---|---|---|
| Talk notes | RUST_ORG_IL_TALK.md | the numbers and arguments behind these slides |
| Taoxichuan: the brief | MINIMAL_SELF_HOSTING_EXPERIMENT.md | the experiment as set up, with its syscall estimate |
| Taoxichuan: the log | MINIMAL_SELF_HOSTING_EXPERIMENT_AGENT_LOG.md | stage by stage, supervision, tokenomics, prompt counts |
| Taoxichuan: the fixed point | TAOXICHUAN_FIXED_POINT.md | K1 == K2, step by step |
| Infinity: the log | INFINITY_ON_TAOXICHUAN.md | GLM strips AWS out of an agent runtime and builds it |