« All posts

DOOM runs inside the Linux kernel via unmodified eBPF

BPF Capsule compiles DOOM and other complex C/C++/Rust programs into standard eBPF, running them unmodified through the stock Linux verifier and JIT.

BPF Capsule is a compiler and runtime that gets large C/C++/Rust programs—including a full port of DOOM—loaded and executed by a stock Linux kernel's eBPF verifier and JIT, with no kernel patches. The entire game tick, from initialization to rendering, completes in a single BPF invocation: userspace hands over the WAD file and keyboard input and receives a pointer to the finished framebuffer.

The eBPF verifier requires every memory access to be provably safe and every loop provably finite, enforced through tight limits: a 512-byte stack, five argument registers, an acyclic call graph, and roughly a million instructions of analysis budget. Pointers stored in memory and reloaded later lose their provenance to the verifier, and even LLVM optimizations can reshape provably-safe code into a form the verifier can no longer follow. To work around this, the author first compiled DOOM to a userspace BPF VM (uBPF) without a verifier to isolate codegen bugs, then hand-trimmed the code to satisfy the verifier, then built an interpreter running inside eBPF, and finally arrived at a scheme of regions, fibers, and a software stack.

The same approach already runs Lua, QuickJS, SQLite, zlib, wasm3, llama2.c, and CPython 3.14 inside eBPF, with Lua and Python inspecting live packets via XDP. This demonstrates a general technique for porting complex application logic into eBPF without manually rewriting it to fit the verifier's constraints—relevant to engineers building kernel-space packet processing, observability, and tracing tools.

This synthesis was produced from its source by AI; there is no human editor or manual review step. How we work