This is FreeBSD 16-CURRENT running entirely in your browser: the real
FreeBSD kernel, compiled to WebAssembly, running real FreeBSD/arm64
programs. No server runs anything; the page only downloads files.
The kernel
FreeBSD's kernel gains a new architecture, wasm, built
with LLVM from FreeBSD's source as 64-bit WebAssembly and lowered to
32-bit memory with Binaryen so every browser can run it. WebAssembly has
no MMU, so kernel addresses are offsets into its memory: kernel memory
is physically contiguous, and disk I/O works on lists of pages instead
of mapped buffers. Each kernel thread has its own stack, switched with
JSPI (WebAssembly JavaScript Promise Integration); interrupts are bits
the host sets and the kernel polls.
Programs
User space is an unmodified FreeBSD/arm64 world built from the same
tree. Its programs run on kwemu, an AArch64 emulator linked into the
kernel: the kernel runs a process until it makes a system call or
faults, then handles that the usual way. Each process has its own
address space, walked through software page tables.
Terminals
The Console tab is the kernel's console. + opens up to nine
more terminals, each a root login shell on a pty of its own, served by
kwtty, a small agent in the guest that the page reaches
over a virtual socket (AF_VSOCK). Shortcuts: Ctrl-A
then n opens one, 1–9 and 0 switch,
x closes; Ctrl-A twice sends Ctrl-A
itself. Ctrl-Shift and a digit switches too.
Disks
The root file system is FreeBSD's minimal base set: UFS, compressed
with mkuzip (about 50 MB) and read-only, fetched piece by piece
with HTTP range requests as the kernel reads it.
Your changes go to a second disk, kept in the browser's private file
system (OPFS). On first boot rc.d/kwdata formats it and
mounts it on /data; /usr/local,
/root, /home and /var live there
(nullfs), and /etc is a union of the image's files and the
ones you changed (unionfs). They survive reloads; Reset the data
disk (in the menu) erases them. One browser tab at a time owns the
disk.
Network
The kwnet driver hands Ethernet frames to unkernel's TCP/IP stack in
JavaScript, which serves DHCP and DNS. A page cannot open TCP
connections, so the stack sends each one over a WebSocket to a relay
speaking the Wisp protocol, which opens the real connection. The relay
allows web, ssh and git ports only (no mail, nothing private), limits
each visitor's connections and speed, and logs no destinations. That
is enough for pkg install, fetch,
git and ssh; ping and UDP do not work.
Credits
Built on unkernel by Pooya Parsa
(source), which runs
Linux the same way: this port reuses its AArch64 emulator, its
JavaScript host and SDK, and its device protocols. And on the
FreeBSD project. The port:
freebsd-unkernel
and its kernel
source.