Skip to content

lab: the probes boot the TPM and shirudo machine unless asked for the plain one - #850

Merged
aledbf merged 1 commit into
mainfrom
lab-shirudo-default
Nov 29, 2026
Merged

aledbf merged 1 commit into
mainfrom
lab-shirudo-default

Conversation

@aledbf

@aledbf aledbf commented Nov 29, 2026 •

Copy link
Copy Markdown
Member

Why

#809's goal is the first SSH login of a machine with a TPM that boots under shirudo, and a machine without shirudo is asked for by name, never fallen back to. This is step 2: the lab's probes boot that machine by default.

What changed

  • The machine. A new shape option, machine, is shirudo by default and takes plain. On the shirudo machine BootArgs adds --initrd, --tpm (a fresh state dir for each boot, a restore's too), --lockdown shirudo and --disk-under the shirudo root, after every other flag. Its base is 512 MiB unless given (spin-stack/spin#1708). Tables and records say a TPM and shirudo. --opt machine=plain boots the old machine, per run or per tree.
  • Made once a tree. The first experiment that boots a tree's shirudo machine runs shirudo.Make on the tree's own release. It installs the result in a raw copy of the tree's base and wraps that as a qcow2, as image/build.sh wraps the release's. The result goes in TREE/shirudo/{initrd.img,rootfs.qcow2}, and the manifest names it (shirudo, with the initrd's SHA256, checked on open). Later boots reuse it. restore and start get --disk-under too, usage's chain sits over that root, and pcrs hashes the kernel and initrd before anything is measured (spin-machine boot --tpm hashes the kernel at every boot: +26 ms on the lab's clock #776's cache), so no measured boot hashes them.
  • Refused by name, before anything boots, unless the run asks for plain: a release with no guest/shirudo or no operator half, or a spin-machine without boot --initrd/--tpm/--lockdown/--disk-under, pcrs --tpm or the probe's restore/start --disk-under.
  • Release trees get the operator half. --from release[:TAG] unpacks the release's second tarball over the first when the release publishes one (release.FetchOperator, checked by sha256 and signature as the first is). shirudo.Make follows links, since a tree is links into its release.
  • spin's handoff no longer mounts /proc and /run over the initrd's. Before, shirudo.service in the root never ran on the default login path.
  • bootchart charts the plain machine and takes no machine option. Its sampler is the root's PID 1, which the shirudo machine starts after its initrd, and there it lost its boot.

Scope

Not here: machine.Spec and spin-machine boot defaults (step 3), docs and goal text (step 4), the bench baseline (step 5). lab compat stays plain and says why. #848 is lived with, since the probes time the login and never read shirudo's status.

Tradeoffs

The first boot of each tree pays for the operator's guest: 18 s on the laptop, and boot:shirudo bounds it at 15 min. Each tree is ~1 GiB larger. The shirudo root is a qcow2 made as the release's is, so overlays over either read the same format.

Blast Radius

Every probe, the ladder and releases measure now boot the shirudo machine. A release tree from before v20261127.03 is refused that machine by name: in the ladder its cell says so, and machine=plain boots it. Cold numbers jump by ~2.8 s on the laptop (below). That is the shirudo machine's real cost, and step 4 reads it.

Verification

  • Unit tests for the default and plain flags, the memory, per-tree options, refusal by name, per-tree reuse and hashing, and the manifest check. task lint passes. task mutate: 166 refused, 0 survived. TestTheLabTalksToGitHub with SPIN_LAB_RELEASE=1 fetched the newest release with its operator half.
  • Laptop, v20261127.03, interleaved (leads only): ssh-first first login p50 3172 ms shirudo against 357 plain (8 a side). restore-first cached login 131 against 110, cold 3106 against 353 (5 a side). Inside a lab-booted guest: lockdown [integrity], /dev/tpm0 TPM 2.0, the initrd ran, and shirudo status is ok with the keyring sealed and the LSM attached. Every other probe ran once on the default machine with 0 lost. Tables, the guest's answers and where the 2.8 s goes: lab: the probes boot the TPM and shirudo machine unless asked for the plain one #850 (comment).

Part of #809.

🤖 Generated with Claude Code

… plain one

#809's goal is a shirudo machine's first login, and the decision is that a
machine without shirudo is asked for, never fallen back to. Every probe now
boots shirudo's machine by default: a TPM with a state of each boot's own,
shirudo's initrd and lockdown, and a root with shirudo installed, at 512 MiB
(spin's 128 cannot unpack the initrd, spin-stack/spin#1708). --opt
machine=plain boots the machine they booted before, per run or per tree.

A release cannot ship that machine, so a tree makes its own the first time an
experiment boots it: the release's operator half in a guest
(internal/shirudo), installed in a raw copy of the tree's base, wrapped as a
qcow2 as image/build.sh wraps the release's. It is kept under the tree's
shirudo/ and named in its manifest, and later boots reuse it. The lab now
unpacks a release's operator half, its second tarball, when a tree starts from
it. A tree that cannot make or boot the machine is refused by name before
anything boots. Its kernel and initrd are hashed before the first boot, so
that no measured boot hashes them.

spin's handoff no longer mounts /proc and /run over the initrd's. Over them,
shirudo.service in the root never ran. bootchart charts the plain machine: its
sampler is the root's PID 1, which the shirudo machine starts after its initrd.

Laptop, v20261127.03, 8 boots a side interleaved: cold first login 3172 ms
p50 on the shirudo machine against 357 on the plain one. Restored (cached):
131 against 110. The guest says lockdown integrity, a TPM 2.0, shirudo ok
and sealed, and an initrd that ran.

Part of #809.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@aledbf

aledbf commented Nov 29, 2026

Copy link
Copy Markdown
Member Author

Evidence: the lab's probes on the shirudo machine, laptop

Laptop (Ryzen 9 5900X, KVM), v20261127.03 with its operator half, the release's own spin-machine, spin-machine-dev from this branch. The probes ran in a privileged container because the laptop has no passwordless sudo for NBD. Laptop numbers are leads, not decisions. Two trees of the release in one interleaved run: shirudo (the default) and plain (--opt machine=plain). REL is the unpacked release.

ssh-first, 8 boots a side

ssh-first: ms from the moment before QEMU is exec'd to sshd accepting on vsock, and to `true` run over SSH, as spin or, on spin's login, root
p50/p95 over 8 of each, interleaved, in 1 of 16 vCPUs, 512 of 8192 MiB, 16 hotplug disks, sized to 2048 MiB, spin's login, a TPM and shirudo; laptop (AMD Ryzen 9 5900X 12-Core Processor, 24 CPUs, nested false), scratch on /dev/mapper/var

             SSHD_ACCEPTS ms FIRST_LOGIN ms ACCEPT_TO_LOGIN ms SECOND_LOGIN ms CONSOLE_PROMPT ms CURVE25519_IN count  QEMU_RSS MiB QEMU_RSS_ANON MiB QEMU_RSS_FILE MiB QEMU_RSS_SHMEM MiB   LOST
  shirudo          3099/3419      3172/3489          71.9/74.5       33.8/42.6         3198/3512                 0/0       422/430           353/360         69.3/69.3                0/0      0
  plain              312/324        357/364          40.6/55.1       25.6/30.5           518/523                 0/0       251/255           207/211         43.8/43.8                0/0      0

  Δ p50 against shirudo [95% interval]: a change only when the interval excludes 0
  plain      sshd_accepts ms     -2786.3 [-2924.7, -2764.5]
  plain      first_login ms      -2814.7 [-2954.0, -2784.7]
  plain      accept_to_login ms  -31.3 [-33.7, -22.0]
  plain      second_login ms     -8.2 [-10.1, -4.9]
  plain      console_prompt ms   -2679.8 [-2808.7, -2657.6]
  plain      curve25519_in count +0.0 [+0.0, +0.0] within noise
  plain      qemu_rss MiB        -171.1 [-173.3, -167.1]
  plain      qemu_rss_anon MiB   -145.6 [-147.8, -141.6]
  plain      qemu_rss_file MiB   -25.5 [-25.5, -25.5]
  plain      qemu_rss_shmem MiB  +0.0 [+0.0, +0.0] within noise

  trees:
    shirudo: kernel REL; qemu REL; image REL; spin-machine REL;
    plain: kernel REL; qemu REL; image REL; spin-machine REL; machine=plain;

restore-first, 5 boots a side

restore-first: ms from the moment before QEMU is exec'd to the first SSH login, booted cold and restored from a saved state
p50/p95 over 5 of each, interleaved, in 1 of 16 vCPUs, 512 of 8192 MiB, 16 hotplug disks, sized to 2048 MiB, spin's login, a TPM and shirudo; touched=0; laptop (AMD Ryzen 9 5900X 12-Core Processor, 24 CPUs, nested false), scratch on /dev/mapper/var

                       STATE MiB COLD_LOGIN ms   FINISHED ms       SAVE ms       READ ms  LISTENING ms    RUNNING ms      LOGIN ms   LOST
  shirudo, evicted       278/279     3166/3341     3213/3387       174/183             -       2.4/2.5       145/326       167/347      0
  shirudo, cached        278/280     3106/3217     3150/3257       180/204       210/215       2.6/2.9       110/117       131/138      0
  plain, evicted         159/160       357/363       539/542       137/139             -       2.4/2.5      99.7/105       121/127      0
  plain, cached          160/160       353/371       537/558       130/142       132/134       2.5/2.6     90.1/95.2       110/116      0

  Δ p50 against shirudo [95% interval]: a change only when the interval excludes 0
  plain, evicted   state MiB     -119.1 [-120.1, -118.4]
  plain, evicted   cold_login ms -2809.7 [-2984.0, -2767.4]
  plain, evicted   finished ms   -2674.5 [-2848.6, -2634.5]
  plain, evicted   save ms       -37.3 [-55.0, -33.8]
  plain, evicted   read ms       -
  plain, evicted   listening ms  -0.0 [-0.2, +0.2] within noise
  plain, evicted   running ms    -45.0 [-226.3, -39.3]
  plain, evicted   login ms      -46.9 [-226.2, -38.4]
  plain, cached    state MiB     -118.7 [-120.1, -118.3]
  plain, cached    cold_login ms -2753.1 [-2864.1, -2731.0]
  plain, cached    finished ms   -2613.0 [-2720.0, -2592.2]
  plain, cached    save ms       -50.0 [-74.1, -37.6]
  plain, cached    read ms       -77.8 [-82.9, -75.6]
  plain, cached    listening ms  -0.0 [-0.3, +0.1] within noise
  plain, cached    running ms    -19.8 [-26.9, -13.3]
  plain, cached    login ms      -20.9 [-27.1, -13.3]

  trees:
    shirudo: kernel REL; qemu REL; image REL; spin-machine REL;
    plain: kernel REL; qemu REL; image REL; spin-machine REL; machine=plain;

The guest really boots under shirudo

These are from a lab-booted guest on spin's login path (the default): the probes' overlay, BootArgs and handoff, and a root login after the first one.

cmdline   ... bpf.keyring_unsealed=1 dm_verity.keyring_unsealed=1 systemd.tpm2_measured_os=1 init=/usr/local/sbin/spin-lab-handoff
lockdown  none [integrity] confidentiality
tpm       /dev/tpm0, /dev/tpmrm0, tpm_version_major 2
initrd    "Freeing initrd memory: 26100K", "systemd[1]: Running in initrd.", shirudo-initrd.service Result=success
root      shirudo.service ActiveState=active SubState=exited Result=success
status    Status: ok; LsmAttached OK; KeyringSealed OK; ChainIntact OK; TpmMeasured OK; ConfigActive OK
memory    MemTotal 2049812 kB (512 MiB base, sized to 2048)
/run      one tmpfs, the initrd's, with /run/shirudo/{bpffs,config,config-candidate,runtime} and /run/initramfs

Before the handoff fix, the same guest had two tmpfs on /run (the handoff's over the initrd's). It had no /run/shirudo, shirudo.service was inactive/dead, and the runtime's shirudo binary was missing. On login=lane (init=/sbin/init, no handoff), shirudo.service was active, and systemd-analyze read 193ms (kernel) + 2.405s (initrd) + 225ms (userspace).

Every other probe, once, on the default machine

probe shape lost
initcalls shirudo; freeing 178 ms, initcalls 145 0
exits shirudo; first login 3375 ms 0
usage shirudo, depth=2 (layers over the shirudo root) 0
prestart shirudo; cold 3184, prestarted 3294, restored 342, into prestarted 176 0
transport shirudo, echoes=20; cold 3254, restored 166 0
run-delay shirudo, crowds=0 2 0
density shirudo, crowds=0 2 settle=2; 3102 / 3172 0
restore-together shirudo, together=1 2 0
ledger shirudo, --kernel traceable:v20261127.03 --edit ledger 0
ssh-first login=lane over the release and its floor (--edit floor) shirudo; release 2900, floor 2695 0
bootchart plain (it takes no machine option); first login 373, PID 1 at 94 0

On the shirudo machine, bootchart lost its one boot: no sampler was running at the first login to stop.

Where the shirudo machine's cold boot goes (one boot, leads for #809's later steps)

These are from the guest's journal, monotonic:

 0.31  the initrd's systemd starts (kernel and the 26 MB initramfs before it)
 0.46  systemd-fsck-root done
 1.25  Mounting sysroot.mount             <- 0.8 s with nothing logged; not the memory plug (plugged=0 read the same 3.2 s)
 1.26  shirudo-initrd.service starts
 1.35    bpf keyring: certificate enrolled and sealed
 1.91    bpf2 and seal attached: lsm/bpf gate live
 2.63    tpm: register bound in the initrd and extended
 2.69  shirudo-initrd.service done        <- 1.43 s
 2.78  Switching root

The ledger of the same machine: PID 1, to the login's sshd-session 2889.4 ms, of which 1373.6 idle (the vCPU waiting, likely on swtpm), shirudo 405.0 unattributed, and shirudo.service 63.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant