Unkernel browser architecture
I read the repo's source (kernel patches, js/core, web/src, guest/). One correction to the premise first: the kernel itself is compiled to wasm, but user programs are not. They are unmodified aarch64 Linux binaries running on kwemu, an aarch64 CPU emulator written in Zig and linked into the kernel. kwemu uses the kernel's real page tables. When a program makes a syscall, kwemu returns into the kernel's wasm code.
1. The React desktop doesn't make syscalls
You're right that it isn't a process. The desktop is ordinary page JavaScript: React and Tailwind, with its own window manager in web/src/wm.ts. It sits outside the machine, the way a hypervisor's UI sits outside a VM. It never makes a syscall. It talks to the kernel the way a host talks to a VM: through paravirtual devices.
- The kernel is a wasm module. It calls JS functions it imports (module
"unkernel",js/core/kernel.ts), such as "send this frame" or "here is my framebuffer". - JS talks back by queuing data and setting interrupt bits in
wasm_host_irqs. The kernel checks those bits when user code traps in, and in its idle loop. - The drivers are added by
kernel/patches/linux/0018–0026: kwblk (disk), kwnet, kwfb (/dev/fb0), kwinput (evdev), kwsnd (ALSA), kwvsock, kwshm and kwvirtio (GPU).
Anything more complex runs over AF_VSOCK, with the page as host CID 2, plus a small helper in the guest. For example, each Terminal tab is a vsock connection to kwtty on port 1022. kwtty opens a pty and starts a login shell. So the shell is a real guest process, and the React terminal is just the far end of a socket.
2. Wayland apps: wland, pixels, kwbox
wland has two halves:
- The relay
wlandris a guest process. It serves/run/user/UID/wayland-0, so apps likefootor a browser think they're talking to a normal compositor. It is not the window manager. It forwards the Wayland protocol over vsock port 1023 to the page (--link vsock:2:1023). It connects only when the first app does. - The compositor is wasm running in the page (
web/src/wayland.ts). Each app window it creates becomes a window in the React WM, and the WM handles moving, resizing and focus.
How the pixels get to the page. Apps draw into normal wl_shm buffers (memfd or shm pages). The kernel uses one flat address space, so virtual address = physical address = wasm memory offset. This means those pages already sit in memory JS can see. The kwshm driver (/dev/kwshm) pins a buffer's pages and tells the host where they are. The compositor then reads the damaged regions straight from wasm memory, usually without copying, and draws them onto a <canvas> per window. So yes, it does end up on an HTML canvas.
There are faster paths for GPU apps:
- GL apps: Mesa's virgl driver hands rendering to virglrenderer compiled to wasm, which draws with WebGL2. The compositor gets an
ImageBitmap, and the pixels never leave the GPU. - Vulkan apps: frames are rendered with WebGPU and handed over the same way.
- X apps: these go through xwayland-satellite.
Without those, GL falls back to llvmpipe, which renders on the CPU.
What kwbox is. It's one static musl binary that bundles the guest-side helpers so they share one libc (guest/src/kwbox.c):
tty: terminal sessionsvsock,9p: host directory mountsshmcmd: host commands exposed as guest commandswasi: runs WASI programsvtest: the GL forwardergrowfs
The one you see in ps is most likely /usr/bin/kwbox tty serve, which inittab keeps restarting (respawn). It serves your terminals. kwbox renames each tool's process (kwtty, vtest-bridge, …), so top shows those names while the command line still shows kwbox.
3. Networking, including DNS over UDP
The browser never sees raw packets. The flow (js/core/net.ts) is:
- The guest runs Linux's real TCP/IP stack and sends raw Ethernet frames out through kwnet.
- A small TCP/IP stack written in JS ("slirp-lite") receives those frames. It fakes a 10.0.2.0/24 network: gateway .2, DNS .3, guest .15. It answers ARP and ping, and runs a tiny DHCP server.
- Each TCP connection becomes a stream over a Wisp proxy, which multiplexes many TCP streams over one WebSocket (
wss://wisp.pi0.io:6680/by default). Under Node it uses real sockets instead. Afetch()shortcut exists only for chosen plain-HTTP hosts (net-fetch.ts).
UDP: the JS stack handles only DHCP and DNS itself. Any other UDP gets an ICMP "port unreachable" reply, and the README lists this under known limits. DNS works as follows:
- The guest's resolver sends an ordinary UDP query to 10.0.2.3:53. The JS stack parses it and calls
backend.lookup(name). - Wisp v1 can't resolve names, so
lookupreturns a made-up address from 198.18.0.0/15 and remembers which name it belongs to. - When the guest connects to that address, the JS stack turns it back into the name and sends a CONNECT with that name to the Wisp server. The server does the real DNS lookup.
- Side effect: every name appears to resolve, and a bad name only fails when you connect.
TLS runs inside the guest, so the proxy sees host names and ports but not HTTPS content. There are no inbound connections and no IPv6. Reaching servers in the guest from outside goes over vsock instead.
I checked the source for each of these.
kwemu
kwemu is a CPU emulator, not a VM manager. It emulates an aarch64 processor running user programs and nothing else. There are no virtual devices, no BIOS and no kernel mode. The Linux kernel does everything a hypervisor or OS normally does.
The split, per include/kw_emu.h:
- The kernel calls
kw_run(cpu, regs)for a task. kwemu runs that program's instructions, using the kernel's page tables to translate addresses. - When the program makes a syscall, faults on a page, or hits an instruction kwemu doesn't support,
kw_runreturns an event to the kernel. The kernel handles it as ordinary wasm code, then callskw_runagain. - Hot code is compiled by its JIT into small wasm modules at run time.
Part of unkernel or separate? It's part of the unkernel repo (src/a64, src/emu, written in Zig), not a separate project. zig build does produce it as a standalone library, libkwemu.a, for wasm64 and for your native machine, with a C interface. But it is only half of a machine: it expects a "kernel" that handles syscalls, page faults and page tables. The only other user is a test harness (src/emu/harness*.zig). So you can link it on its own, but you'd have to write that kernel side yourself. There's no packaged "kwemu by itself" product. It's GPL-2.0-or-later.
Node.js: yes, the whole of unkernel runs there, JIT included. npx unkernel boots Alpine in your terminal, and the npm package unkernel is the same kernel as a JS library (createKernel()). The README's benchmarks were measured under Node.
GPU: mostly existing drivers, with one written for Vulkan
Some background first. WebGL2 is the browser's version of OpenGL ES 3.0, the older and widely supported graphics API. WebGPU is the newer browser API, modelled on Vulkan, Metal and Direct3D 12. Both run on your real GPU. Node has neither, so guest GPU support exists only in the browser.
OpenGL (via WebGL2): mostly existing pieces. VMs already solved "guest GPU calls the host's GL". QEMU does it with virtio-gpu and virgl. unkernel reuses those parts:
- In the guest: Mesa's stock
virgldriver and the kernel's stockvirtio_gpudriver (/dev/dri/renderD128). They package GL commands into a command stream instead of driving hardware. - unkernel's own piece is small: a transport (kwvirtio) that carries that stream from the kernel to JS.
- On the page: virglrenderer, the existing open-source host side that QEMU uses, compiled to wasm with Emscripten. It replays the commands as WebGL2 calls. It needed about 20 patches (
gl/patches/), because WebGL2 lacks some of desktop GL.
Vulkan (via WebGPU): written for unkernel. There's no ready-made path, so they wrote:
- A guest Vulkan driver,
vk/icd. It sends Vulkan calls over vsock to the page. - A JS executor (
js/core/vk*.ts) that runs them on WebGPU. - Shader translation from Vulkan's SPIR-V to WebGPU's WGSL, using the naga library compiled to wasm.
So yes, that one is a virtual GPU driver that calls a browser API, as you guessed.
Wisp proxy
Browsers can't open raw TCP or UDP sockets. A page can only use HTTP (fetch, which CORS restricts), WebSocket, WebRTC and WebTransport. Wisp is a small protocol from MercuryWorkshop that works around this:
- The page opens one WebSocket to a Wisp server on the internet.
- Over it, the page sends "CONNECT example.com:443", and the server opens a real TCP socket.
- Bytes for many connections travel over that one WebSocket, each tagged with a stream ID (
js/core/net-wisp.ts).
So it's a relay that turns WebSocket messages into real sockets, like a SOCKS proxy that browsers can reach.
Practical details:
- Default server:
wss://wisp.pi0.io:6680/, run by the project. It only accepts pages from known origins, so if you host the page yourself, run your own Wisp server and pass?wisp=wss://…. - What the server sees: host names, ports and plain-HTTP content. HTTPS is encrypted inside the guest, so the server can't read it.
- UDP: I believe the Wisp spec defines UDP streams too, but unkernel's backend only opens TCP. The "no UDP beyond DHCP and DNS" limit comes from unkernel, not from Wisp.
- Under Node: Wisp isn't needed. The
directBackend()uses Node's real sockets.