eBPF Subsystem
Relevant source files
- kernel/crates/kernel_bpf/README.md
- kernel/crates/kernel_bpf/src/lib.rs
- kernel/crates/kernel_bpf/docs/ARCHITECTURE.md
- kernel/crates/kernel_bpf/docs/PROFILES.md
- kernel/src/bpf/mod.rs
- kernel/src/syscall/bpf.rs
- docs/security/bpf-trust.md
- docs/decisions/0004-bpf-jit-policy.md
The axiomOS eBPF subsystem lets user-supplied, verified bytecode run synchronously inside kernel hooks (timer tick, syscall entry and exit, scheduler switch, GPIO and IIO events). It is split into a no_std library crate, kernel_bpf, that provides mechanisms (loader, verifier, interpreter, maps, signing, actuation policy) and a kernel-side integration layer, kernel/src/bpf, that owns policy (authorization, quotas, handles, hook snapshots).
Execution is interpreter-only. No shipped profile enables a JIT (see Execution and JIT).
Crate layout
| Location | Role |
|---|---|
kernel/crates/kernel_bpf/src/bytecode | Raw instructions, opcodes, registers, and the BpfProgram / VerifiedProgram representations |
kernel/crates/kernel_bpf/src/loader | ELF64 parser, relocations, subprogram call normalization |
kernel/crates/kernel_bpf/src/verifier | CFG, register/stack state, tnum, pruning, liveness, helper registry, WCET cost model, admission ledger |
kernel/crates/kernel_bpf/src/execution | Interpreter, BpfContext, hook context structs; non-shipped compilers |
kernel/crates/kernel_bpf/src/maps | Array, hash, ring buffer, time-series maps |
kernel/crates/kernel_bpf/src/attach | Attach metadata types (GPIO, IIO, PWM, kprobe, tracepoint) and the GPIO route table |
kernel/crates/kernel_bpf/src/signing | Signed container (RBPF) parsing and Ed25519 verification |
kernel/crates/kernel_bpf/src/profile | CloudProfile and EmbeddedProfile constants |
kernel/crates/kernel_bpf/src/actuation | ARM-A actuation reference monitor decision core |
kernel/crates/kernel_bpf/src/concurrency | EpochSnapshot used to publish hook snapshots |
kernel/src/bpf | BpfManager, authorization, handles, limits, trust, snapshot, helpers |
kernel/src/syscall/bpf.rs | sys_bpf command dispatch and capability gating |
kernel/crates/kernel_abi/src/bpf.rs | Command, map type, attach type, helper and capability constants shared with userspace |
Tests and tooling live in kernel/crates/kernel_bpf/tests (integration, profile contracts, semantic consistency, concurrency model), kernel/crates/kernel_bpf/fuzz (four libfuzzer targets: verify_only, verify_then_exec, signed_container, ringbuf_sequences), and kernel/crates/kernel_bpf/benches.
Build-time profiles
Exactly one of the cloud-profile or embedded-profile features must be enabled on kernel_bpf; enabling both or neither is a compile_error!. The profile is exposed as the ActiveProfile type alias.
| Constant | Cloud | Embedded |
|---|---|---|
| Stack | 512 KiB | 8 KiB |
| Max instructions | 1,000,000 | 100,000 |
| Per-map profile budget | 0 (kernel quotas only) | 64 KiB |
JIT_ALLOWED | false | false |
| Per-program WCET budget | unbounded | 1 ms period at 6 ns per unit (about 166,666 units) |
| Utilization budget | unbounded | 500,000,000 ns per second |
| Map resize methods | compiled | erased |
See PROFILES.md for the normative table.
Load-to-fire pipeline
Key properties, each described in detail on the linked pages:
- Only verifier-produced
VerifiedProgramvalues can reach the interpreter (Verifier). - Raw instruction loads carry no signature and are rejected whenever signature enforcement is active (Trust Model).
- Attach re-runs verification with the exact payload size for the hook and forbids logging helpers on latency-sensitive hooks (Hooks).
- Hook dispatch reads a fixed-capacity immutable snapshot and takes no manager lock (Hooks).
Honest scope notes
The crate documentation states that the embedded profile does not provide an EDF BPF scheduler or a static allocator: admission is a utilization ledger, and all maps use checked heap allocation. Performance figures quoted in source comments (for example the 6 ns per WCET unit calibration) come from historical benchmark records; the source itself notes they are not claimed as current artifact-backed measurement. This documentation does not restate them as current results.
Page map
- Loader: ELF parsing, relocations, subprograms,
sys_bpfcommands - Verifier: safety analysis, WCET, admission, limits
- Execution and JIT: interpreter, JIT policy
- Hooks: attach types and dispatch
- Maps and Helpers: map types and helper table
- Trust Model: signing, authorization, handles, quotas