A verified, bounded Scheme bytecode VM — a ground-up rewrite of
Animula executing .lef bytecode
compiled by laco.
One C11 core serves two deployment profiles isolated through the VOS (Virtual OS) layer:
- Embedded / Maker & IoT VM (
vos/linux, future MCU RTOS layers): lean bytecode runtime for Cortex-M class hardware (96 KiB RAM target) and Linux userland, with optional cryptographic signing excluded by default so small images carry zero extra footprint. - Linux Kernel Policy VM (
animula-boom,vos/boom): a hardened, no-FPU, no-allocation-at-runtime kernel-tier VM for running customer Scheme policies alongside sonicboom-lite online-learning primitives, with mandatory-ready stateless hash-based.lefsignatures, RCU hot swap, and formal static verification.
For full Animula ecosystem documentation, hardware guides, and tutorials, see animula-docs.
animula-ng is the next-generation evolution of the
Animula embedded Scheme VM
(originally inspired by Picobit and built to bring real Scheme to
Cortex-M MCUs and Zephyr RTOS). Earlier versions split the runtime across
separate animula, animula-linux, and animula-zephyr repositories.
animula-ng unifies all targets into a single clean-room C11 codebase
isolated by the VOS layer while preserving the compact .lef bytecode
format — adding a static CFG/stack verifier, formal verification (Frama-C
Eva and CBMC), and the animula-boom Linux kernel module layer alongside
the original embedded/maker hardware path.
The Compiler: laco
animula-ng stays tiny, fast, and statically verifiable without a JIT
because the heavy lifting happens ahead of time in
laco — a full CPS-optimizing
R7RS-small Scheme compiler (Scheme -> CPS -> optimizer -> LIR -> .lef):
- Real CPS optimization pipeline: alpha-renaming, beta/eta reduction, constant folding, escape analysis, closure conversion, lambda lifting, and assignment conversion.
- Modern R7RS-small support: hygienic
syntax-rulesmacros,define-library/import(including unmodified chibi(srfi 1)and zero-overhead(boom learn)), rest parameters, multiple values, and escape-onlyguard/ exceptions. - Compile-time specialization (
laco-inline): variadic library procedures like+,<, andappendfold directly into single VM instructions when called with known arity, while remaining first-class procedures everywhere else. - Tight VM contract: emits compact
.lefbinaries with canonical s-expression metadata trailers ((learn ...),(rest ...)), letting the VM verifier prove safety statically and keeping both 96 KiB MCUs and Linux kernel modules lean.
- Verify before execution. Every
.lefpasses a static verifier (core/verify.c) performing abstract interpretation over the control-flow graph: instruction decoding, jump targets, stack-depth balance at every join, prelude/call pairing, local/global/constant bounds, arity and rest metadata, and tier/helper whitelists. Verified bytecode is lowered to a typed internal IR with explicit tail calls. - No JIT, no
eval, no source in the kernel. Bytecode only; nocall/ccorraise-continuablein any tier. - Strictly bounded, fail closed. Every run is capped by instruction
budget, call-depth limit, fixed stack, and fixed GC heap. No
abort, no recursion in core C, no function pointers (switchdispatch in kernel builds); every failure returns anan_statuscode. - Single-threaded VM. Designed for MCUs and deterministic execution; in
animula-boom, the OS layer serializes VM entry. - Clean separation of compute and policy. Online-learning math and
BLAKE2s hashing live in
sonicboom-lite(submodule), operating on a non-moving, pointer-free learning region outside the GC heap; Scheme sees opaque handles only.
| Path | Contents |
|---|---|
core/ |
Portable VM core (verify.c, interp.c, prim.c, heap.c, learn.c, csexp.c, sig.c, print.c); includes only vos/vos.h |
spec/isa-spec.scm |
Machine-readable ISA, primitive, and helper specification (single source of truth); generates core/prim_table.h and laco helper tables |
vos/ |
VOS contract (vos.h) and OS layers: linux (userland/CI), boom (Linux kernel module + pre-allocated boom_pool), boom-um (boom layer in userland) |
sonicboom-lite/ |
Git submodule: freestanding integer online learning (sbl_learn) and BLAKE2s-256 (blake2s) |
tools/ |
animula-vm CLI, animula-sign offline key/signature tool, gen-prim-table.scm |
tests/ |
laco full-tier corpus, kernel-tier suite, signature suite (run-sig.sh), boom-um unit tests (test_boom.c), libFuzzer target |
verify/ |
Frama-C Eva and CBMC formal verification harnesses (verify/run.sh, verify/TRIAGE.md) |
doc/ |
design.md, coding-rules.md, laco-issues.md |
git submodule update --init
# 1. Standard / Maker build (signatures excluded by default: ENABLE_SIG=0)
make
build/linux/animula-vm prog.lef
build/linux/animula-vm --dump prog.lef
# 2. Opt-in signature verification on non-boom VOS
make ENABLE_SIG=1
build/linux/animula-vm --tier=kernel --pubkey=boom.pk prog.signed.lef
# 3. Userland simulation of animula-boom (kernel tier, boom_pool, signatures on)
make VOS=boom-um
build/boom-um/animula-vm --tier=kernel --verify prog.lef
# 4. Offline signing tool (build/sign/animula-sign)
make sign-toolUseful CLI flags on animula-vm:
--tier=full|kernel,--verify,--dump,--print-result--budget=N,--heap=N,--stack=N,--depth=N--learn-max=N,--helpers=learn|all|none--pubkey=<file>,--require-sig(when built withENABLE_SIG=1orVOS=boom-um)
vos/boom always compiles with signature support (AN_SIG) enabled.
- Local development (unsigned
.lefallowed; prints a reminder after building):make kmod KDIR=/lib/modules/$(uname -r)/build - Production release (embeds trusted public key(s) into
animula_boom.koat compile time — mirroring Linux module signing so trust anchors cannot be altered at run time — enablessig_enforce=1by default, and signs.lefpolicies):# Print full parameter help and examples: make release # First-time release (generates keypair under build/keys/ and signs LEFS): make release GEN_KEY=1 LEFS="policy.lef" # Release using an existing offline keypair: make release SIGN_KEY=/secure/boom.sk PUB_KEY=/secure/boom.pk LEFS="a.lef b.lef" # Build only the signature-enforcing module from a public key: make release PUB_KEY=/secure/boom.pk KMOD_ONLY=1
Signed .lef files carry a LEFS trailer after the optional LEFM metadata,
covering every preceding byte (header + body + optional LEFM). The loader
verifies the signature before allocating memory or parsing bytecode or
metadata.
- Algorithm: stateless hash-based
SPHINCS+-128s-simple(FIPS 205 construction) instantiated withsonicboom-lite's BLAKE2s-256 — zero RSA/ECC or lattice assumptions, sharing one fast 32-bit hash across kernel, userland, and Cortex-M MCUs. - Footprint: 32 B public key, 7,856 B signature, zero heap allocation and < 1 KiB stack during verification (~0.2 ms verify on x86_64).
- Offline tool (
build/sign/animula-sign):build/sign/animula-sign keygen boom.sk boom.pk build/sign/animula-sign pubkey-c boom.pk > keys.h build/sign/animula-sign sign boom.sk policy.lef policy.signed.lef build/sign/animula-sign verify boom.pk policy.signed.lef
/dev/animula-boom-ctl(0600,CAP_SYS_ADMIN): write one.lefto verify, initialize, and publish via RCU hot swap. A replacement that fails signature check, verification, or pool allocation leaves the active program untouched; the old slot is reclaimed aftersynchronize_rcu()in process context./dev/animula-boom(0600): session-based query device parsed by the verified, bounded readable s-expression reader (an_sexp_parseincore/csexp.c). Write one request, read one answer:(status)— load state, signature flag, generation, swap/reject/query counts, pool usage, GC count(version)— VM version, platform, tier(params)— active module limits,sig-enforce, trusted key count(helpers)— enabled helper categories(learn-info)— statically declared learning objects and byte layout(ping)/(ping <atom|string>)— session echo / parser check
/sys/kernel/animula-boom/: read-onlystatus,version, andlast_errorattributes.
| Parameter | Mode | Default | Description |
|---|---|---|---|
pool_kb |
0444 |
4096 |
Single pre-allocated region reserved at module init (KiB); the interpreter never allocates from the kernel |
heap_kb |
0444 |
1024 |
GC heap per loaded program (KiB) |
stack_slots |
0444 |
4096 |
VM stack capacity in slots |
depth_limit |
0444 |
256 |
Maximum call depth |
budget |
0444 |
1000000 |
Instruction budget per run (clamped >= 1 in kernel) |
learn_max |
0644 |
1048576 |
Max learning-state region per .lef in bytes (writable at run time; applies to subsequent loads) |
helpers |
0444 |
"learn" |
Comma-separated enabled helper categories (learn, all, none) |
sig_enforce |
0444 |
1 if keys built in, else 0 |
Require valid SPHINCS+-BLAKE2s signature on every .lef (read-only at run time) |
Kernel-tier policies using online learning import (boom learn) (compiled
with laco --tier=kernel) and declare objects statically:
(import (laco core) (boom learn))
(define-learn lat (ewma 4))
(define-learn freq (cms 8 4))
(define-learn dist (hist (0 10 100 1000)))
(define-learn head (lin 8 1024 65536 -65536 65536))laco emits a (learn ...) metadata trailer; the loader validates every
declaration against learn_max and helpers=, allocates the exact region
and reference snapshot once at load time, and exposes opaque handles via
%learn-ref.
make test # corpus + kernel suite + sig suite (linux & boom-um) + boom-um unit tests
make test-switch asan ubsan # switch dispatch, ASan, UBSan (incl. -fsanitize=integer)
make fuzz fuzz-run SECONDS=60
make eva # Frama-C Eva (EVA_STRICT=2 default: fails on any alarm)
make cbmc # CBMC bounded model checking- laco full-tier corpus (71 programs): 70 pass, 0 fail, 1 XFAIL
(
raise-cont, unsupported by design; seetests/corpus/DIVERGENCES.md). - Kernel-tier suite: 21/21 pass on both
linuxandboom-um(identical BLAKE2s learning-state hash across both platforms). - Signature suite (
run-sig.sh): 12/12 pass onlinux(ENABLE_SIG=1),boom-um, ASan, and UBSan (signed with/without metadata, unsigned reject, untrusted key reject, tampered bytecode/metadata/signature/truncated reject,pubkey-c). boom-umunit suite (test-boom): 42/42 pass (readable s-expression parser and two-slot RCU hot-swap lifecycle overboom_pool).- Sanitizers & Fuzzing: ASan and UBSan (including
-fsanitize=integer) clean; libFuzzer 2.4M runs with no findings. - Frama-C Eva (
EVA_STRICT=2): all 5 fast jobs at 0 alarms —eva:csexp,eva:load,eva:learn,eva:heap, andeva:sig. - CBMC: parser, decoder, metadata, and
boom_poolharnesses (0 failed properties). - Kernel module: builds cleanly with
make kmodandmake release.
- Replacing the stopgap mark-sweep GC (
core/heap.c) withobg - Kernel event entry point (LSM/event hooks) and hash-chained audit log
- Cross-swap learning-state migration policy
- Zephyr / Cortex-M VOS layer
GPL-2.0-or-later.