How the dom0 image is built
This note is for a developer who changes what the appliance’s dom0 boots. It says what goes into the dom0 image, the rule the build enforces, and where the check lives. How to run the build is in building.md.
The layers
- dom0: one package,
scrotwmos(make pkg), with no dependencies. It boots the machine and runs the compositor. It holds no applications. - A container session: a Void root of its own, with the
applications and its own
scrotwmd. It runs as its own uid in a namespace and shares dom0’s kernel. - A VM session:
swm-vmm, a signed guest kernel (make kernel), and an XFS volume made from a session root.
Applications live in sessions, never in dom0.
What dom0 holds
The package holds:
swm-wl,swm-vmm, andvmm-gfx, each fully static against musl;- the default
dom0.conf; - the Terminus bitmap font for the bar, and libinput’s device quirks;
kernel/TREE, the tree’s marker, andkernel/keys/kernel.pub, the key the VM kernels are checked with;- an empty
usr/local/build/, where the root monitor mounts the world’s kernel store, read-only, at boot.
make kernel-host packs the package’s tree as the initramfs of the
dom0 kernel, with swm-wl as /init and two keymaps compiled in: the
one for SWM_KEYMAP_LAYOUT, and US. make release signs it as
dom0.signed. The stub checks and boots it. It runs whole in RAM.
There is no shell, no init system, no udev, and no seat daemon:
swm-wl is PID 1, its own privsep monitor, and the seat server.
Three programs, and nothing else
dom0 runs three programs: swm-wl, swm-vmm, and vmm-gfx, which
runs a VM’s GPU commands on the display GPU. Nothing else in the image
can run. At run time, dom0 execs nothing else.
mk/dom0-payload.mk holds the one check. make pkg
runs it on the package, and make kernel-host on the image. It fails
closed. A tree passes only when:
usr/local/bin/swm-wl,swm-vmm, andvmm-gfxare regular, executable, fully static ELF files;- no other file is an ELF or has an execute bit;
- nothing is setuid or setgid, or writable by group or others;
- no file is a kernel image, and
usr/local/build/is empty; - there is no device node, FIFO, or socket, and no link but
/init; - the package holds only
usrandetc, with no xbpsINSTALLorREMOVEscript; - no path holds a newline.
At run time the same rule holds:
- The compositor refuses every spawn that would run in dom0: a
workspace routed to
host, a session with no isolation,autorun,bar_action, and the search menu. - The compositor runs under a seccomp filter that refuses
execveandexecveat. - PID 1 mounts
/tmp,/dev/shm,/run,/dev, and/dev/ptsnoexec, and every disk of a world’s fstabnoexecin dom0. - The dom0 kernel runs no usermode helper:
CONFIG_STATIC_USERMODEHELPERsends each one to/dev/null.
A container is not dom0. Its programs come from its own root, after the pivot, so a container still runs them.
This check does not cover the firmware that the kernel loads.
The size
The boot partition, the ESP, holds one signed dom0 image for each boot
slot. Its twin, the disk’s last partition, holds them again: each
change to the ESP copies the whole ESP there (installer/appliance.c
appliance_esp_close()). To measure the image and the package after a
build:
ls -l build/release/dom0.signed build/pkg/*.xbps
Session roots
make rootfs (mk/rootfs.mk) builds a Void root for a session.
make volume turns a root into an XFS volume. A container root the
swm-wl-only dom0 mounts by label, with the session daemon in it:
make rootfs ROOTFS=/srv/work ROOTFS_AGENT=build/agent/scrotwmd
make volume ROOTFS=/srv/work VOLUME=work.img VOLUME_LABEL=swm-work
scrotwmos.conf(5), SESSIONS, has the session keys.