WillowOS

How the kernel works

A plain walk-through of how WillowOS is put together.

The short version

WillowOS runs its own kernel, written in Rust from scratch. It isn't Linux or BSD underneath. It's a hybrid kernel: the core parts that need to be fast live in the kernel, and the riskier parts, like the code that handles secure web connections, run outside it as normal programs that can crash and restart without taking the system down.

ring 3: user mode desktop shellapps (Files, Term...)Linux apps (early) tlsd: TLS 1.3usbhiddusbmsddpatchd updates syscall gate: capability checks + SQ/CQ driver rings ring 0: kernel scheduler, 1000 Hzmemory, ASLR, CoWVFS + NovaFS (CoW) TCP/IP, DHCP, DNSWireGuard, cryptocapability broker drivers: NVMe, AHCI, xHCI, e1000e, HDA audio, virtio

Top half runs as normal programs. Bottom half is the kernel. The dashed line is where every request from a program gets checked.

What's in the kernel

The kernel is written in no_std Rust. Rust stops whole kinds of memory bugs at compile time, the kind behind a lot of the worst security holes in other systems. The rules say kernel code never uses unwrap(), and nothing allocates memory inside an interrupt handler.

What runs outside the kernel

The desktop, the apps and some drivers run as normal programs in user mode. That means a bug in them can't touch kernel memory.

These services talk to the kernel through shared request and completion rings, so they don't pay for a system call on every small message. Moving more drivers out this way, including graphics, is planned.

How programs get limited

Every request a program makes goes through one gate, the system call layer. There are over 75 native system calls, kept small on purpose. New ones get added only when a feature needs them. Network, device and file requests are each checked against what that program is allowed to do. If the answer is no, the program gets "access denied" and the attempt is logged.

Linux programs use a separate compatibility layer that currently handles 88 Linux system calls. That's enough for test programs, not real apps yet.

Storage: NovaFS and DuperDB

NovaFS is the file system. It's copy-on-write, so a change never overwrites the old data in place, which means a crash mid-write can't leave a file half changed. Turn on encryption and each file is encrypted with AES-256-GCM, and the disk unlocks with your passphrase at boot. Because old data sticks around, the system can take a snapshot of your files every hour, and the Rewind app can take them back. Ctrl+Z in Files works the same way.

DuperDB is a small database built into the kernel. It holds settings, file tags, the activity timeline, saved passwords and which services are turned on. Every change is all or nothing, it keeps 64 past versions so settings can be undone, and its pages can be encrypted with the same passphrase. It has its own space on the disk, apart from NovaFS. Database calls only happen from normal program context, never from interrupt handlers, and nothing else gets locked while it's held, so it can't cause a deadlock.

Booting, updates and crashes

How it's tested

Every change has to boot in a virtual machine and pass the built-in self-tests before it can merge. There are 170+ of them right now, covering things like the crypto code, the permission gate, and the database surviving a crash in the middle of a write. The tests run inside the real kernel at boot, not in a separate test harness, so they test the code that actually ships.

Outside code

Almost everything is mine. The kernel uses a handful of small outside Rust crates (x86_64, spin, pc-keyboard, lz4_flex, ruzstd and a few others), all under MIT or Apache licenses. There's no GPL code in it, and no code copied from Linux or Windows. Where I needed hardware details, I wrote my own code from datasheets and public specs.

Back to the homepage