Definition
rBPF is a small virtual machine §2.3 that runs eBPF §2.1 (extended Berkeley Packet Filter) bytecode §2.4 on microcontrollers §6.1, the single-chip computers of Internet of Things (IoT) devices, which typically have tens to hundreds of kilobytes of RAM and no memory management unit §6.9. Koen Zandberg and Emmanuel Baccelli introduced it in 2020, with a prototype in the RIOT operating system. rBPF interprets each program and isolates it in software by checking every memory access and every jump target. Its authors call it a register-based virtual machine and do not expand the r.
The idea
A memory management unit (MMU) is the hardware that gives each process its own address space. Typical microcontrollers, such as those built on Arm Cortex-M processors, lack one: all firmware shares one address space, and native code can read or write any memory, including the registers that control the radio and the sensors. Changing a device’s behavior normally means sending a whole new firmware image over a slow, low-power radio link and restarting. A small virtual machine lets the device receive a short program instead, run it in an interpreter §2.13 that checks what the program touches, and leave the firmware unchanged.
eBPF suits a small memory budget: it is a register machine §2.5 with a small instruction set, a stack fixed at 512 bytes and no heap. The rBPF paper compares it with WebAssembly §19.5.6 (Wasm), a stack machine whose memory grows in pages of 64 KiB, run by the Wasm3 interpreter. Both run far slower than native code, but rBPF adds less than a tenth to the firmware’s memory, while the Wasm interpreter more than doubles it.
How it works
The paper describes this design.
Develop. A developer writes the logic in C, or in another language that the LLVM §12.18 compiler infrastructure can compile to eBPF, and compiles it to bytecode.
Deliver. The bytecode travels over the network and is stored on the device, and an administrator attaches each stored program to an event, such as a request to the device’s server or a packet passing through its network stack.
Check before running. Before the first run, the virtual machine checks that every jump lands inside the program. One check suffices because the eBPF instruction set that rBPF implements has no indirect jump: every jump target is written in the instruction itself.
Run. The virtual machine runs as an ordinary RIOT thread at a configured priority, so it does not disturb threads with real-time duties and is not meant for real-time work itself. Each run receives an argument from the triggering event and returns a code to it. The guest’s registers and 512-byte stack live in the host’s memory.
Check every access. The caller configures memory regions, each allowed for reading, writing or both, and every load and store, including those to the stack, is checked against them.
Call the host. Function bindings give access to services such as sensor values and network packet creation. A key-value store, with storage shared by all programs and storage private to each, keeps values such as counters from one run to the next.
The measurements used a board with the nRF52840 §6.4, a Nordic Semiconductor microcontroller with an Arm Cortex-M4 §6.3 processor, 256 KiB of RAM and 1 MiB of flash memory §6.6.
Worked example
Memory. In the paper, the firmware without a virtual machine needs 52,760 bytes of flash and 14,856 bytes of RAM. The rBPF interpreter adds 4,364 bytes of flash and 660 bytes of RAM: , about 8.3% more flash, and , about 4.4% more RAM. The Wasm3 interpreter adds 64 KiB of flash, bytes, and 85 KiB of RAM, bytes: , so 124% more flash, and , so 586% more RAM.
Time. The paper timed the Fletcher-32 checksum §4.32, a simple error-detecting sum, over 361 bytes: 27 microseconds natively and 1,923 microseconds in rBPF. Since , rBPF is about 70 times slower, and each run costs microseconds extra. Whether that matters depends on the rate, and the rates below are invented to show it. At one run per second the extra time is 1,896 of every 1,000,000 microseconds, or 0.19% of the processor. At 100 runs per second it is microseconds per second, or 19%. The processor could do at most interpreted runs per second, against native ones. A large ratio is harmless for a rule that runs rarely and decisive for one that runs on every packet.
Stated precisely
For a run, let the host configure regions , where is a start address, a length in bytes and the permitted operations; the guest’s stack is one of the regions. Let the program have instructions, numbered 0 to . The isolation the paper describes is: every load of bytes at address satisfies and for some region whose includes reading, likewise for stores and writing; and every jump target satisfies .
This rests on three assumptions: the interpreter’s code is correct, every function binding is safe for every argument the program can pass, and the regions name only memory the program may use. The interpreter itself runs in the same unprotected address space as the firmware, so a bug in it or in a binding is not contained. The two mechanisms concern memory and control flow; a bound on running time must come from the implementation in use or from the host.
RIOT as the host
RIOT is an open-source operating system for low-power IoT devices. It is written in C, runs on many 8-bit, 16-bit and 32-bit microcontrollers, and schedules multiple threads by priority. Besides rBPF, RIOT hosts Femto-Containers §21.4 (2022), later work by the same research group that extends rBPF to deploy small software functions over the network and isolate them on the device; its authors report that their implementation was formally verified for fault isolation. CertrBPF §21.3, from the same group, is a version of the rBPF interpreter verified with the Coq proof assistant.
The rBPF paper calls RIOT an arbitrary choice and says the approach could apply to other operating systems of the same kind. The Zephyr RTOS §6.33 (real-time operating system) is one. The interpreter’s core is portable C that needs only memory, a caller and function bindings. Moving it to Zephyr changes the host side: the thread and event interfaces that trigger runs, the services each binding wraps, such as the two systems’ different sensor interfaces, and the build system: RIOT builds with make files, Zephyr with the CMake §12.12 build tool, the Kconfig §6.40 configuration language and devicetree §6.39 hardware descriptions. Protection can differ too. On a processor with a memory protection unit §6.8 (MPU), Zephyr can run a thread in user mode, where the MPU limits the memory the thread can reach, so the interpreter itself could be confined. The rBPF design deliberately does not depend on such hardware.
Limits and common mistakes
The paper’s numbers belong to its prototype, board and benchmark. They do not describe other eBPF interpreters, later versions of rBPF, or other workloads.
Software isolation protects the firmware from the guest program, not from the interpreter or the function bindings, which run as native code with access to all memory.
No MMU does not mean no hardware protection. Many microcontrollers have an MPU, which enforces read, write and execute rules on a few memory regions; rBPF does not rely on one, so it also runs where there is none.
The name is easily confused: rbpf, in lower case, is an unrelated eBPF virtual machine written in the Rust language.
Questions answered
What changes when there is no MMU and little RAM?
Without a memory management unit (MMU), the hardware that gives each process its own address space, all code on the device shares one address space, so a guest program can be kept away from the rest of the firmware only by checks that some layer performs. A virtual machine such as rBPF performs them in software: it checks every load and store against the memory regions the host allows, and every jump target before the program runs, which suffices because the eBPF instruction set that rBPF implements has no indirect jumps. A memory protection unit, where present, can add hardware protection, but for only a few regions. The checks cost time: in the rBPF paper a checksum took 1,923 microseconds against 27 natively, about 70 times longer.
Little RAM, kilobytes rather than gigabytes, decides which design fits. An interpreter is preferred to a just-in-time compiler §2.14, which needs a code buffer and memory that may execute. A fixed 512-byte stack and no heap keep each run’s memory known in advance, but every concurrent run needs its own stack: eight concurrent runs take bytes, a quarter of a 16 KiB RAM. In the rBPF paper the interpreter added 660 bytes of RAM to a firmware using 14,856, while a WebAssembly interpreter added 85 KiB.
Related entries: Virtual machine (VM) (§2.3), Resource confinement (§2.40), Memory management unit (MMU) (§6.9), Memory protection unit (MPU) (§6.8), Microcontroller (MCU) (§6.1), Zephyr RTOS (§6.33), Femto-Containers: small functions rather than whole process containers (§21.4), CertrBPF: connecting a VM specification to generated C (§21.3), Interpreter (§2.13), Software fault isolation (SFI) (§2.41). Further reading: [4, 205, 206].