BPF Capsule - Run complex C programs inside eBPF
Show HN: DOOM in the kernel, or fibers in eBPF
BPF Capsule is a compiler and runtime that transforms large C, C++, or no_std Rust programs into a form the stock Linux verifier accepts, enabling complex application logic to run directly in the kernel. It achieves this through regions, fibers, and a software stack, without kernel patches or a userspace VM. The project demonstrates its power by running DOOM entirely in eBPF, but the real value is in packet parsing, statistics, and other kernel-side tasks that previously required manual rewriting. Try it with one command on Linux 5.15+.
DOOM initialization, game logic, and rendering all execute in the kernel. One game tick, including the complete frame, finishes in a single BPF invocation.
- tptacek
There's so much good content in here, it's a shame you sandblasted your writeup with AI. "To the verifier, it is a number with a biography" is where I veered off the road and into a culvert.
- markrwilliams
Skip the first half of the article to learn how the project overcame eBPF programs' limited runtime environment:
"On Linux 6.9 and newer (6.10 on arm64, where JIT support for the arena landed later), the window is backed by bpf_arena... On kernels without a usable arena, the same four gigabytes are assembled from 4-MiB pieces... [in] separate global-data maps."
These maps are of type BPF_MAP_TYPE_ARRAY.
See https://lwn.net/Articles/961941/ for a discussion of `bpf_arena`.
- phishin
I appreciate adherence to the all caps requirement.