Skip to content

feat(swtpm): software TPM 2.0 for ephemeral CI VMs (#3)#4

Closed
foil-copy-overrate wants to merge 1 commit into
mainfrom
feature/swtpm-ci
Closed

feat(swtpm): software TPM 2.0 for ephemeral CI VMs (#3)#4
foil-copy-overrate wants to merge 1 commit into
mainfrom
feature/swtpm-ci

Conversation

@foil-copy-overrate

Copy link
Copy Markdown
Member

Software TPM 2.0 for ephemeral CI VMs

Implements the bcvk side of issue #3 / yubiOS ADR-016 §Feature 1 / BLOCKER-006.
Pairs with yubiOS PR bootc-dev#34 (guest-side systemd-tpm2-swtpm.service drop-in).

What this does

bcvk run --feature tpm2-swtpm launches an swtpm process and wires an emulated
TPM 2.0 into the guest (-tpmdev emulator + arch-aware tpm-tis/tpm-tis-device),
so /dev/tpm0 is present inside CI VMs without hardware. Exercises TPM2 code paths
(PCR measurements, LUKS2 PCR binding, ConditionSecurity=measured-os).

Changes

  • new crates/bcvk-qemu/src/swtpm.rsSwtpmConfig, QEMU arg generation, arch device selection, socket wait, table-driven unit tests.
  • crates/bcvk-qemu/src/lib.rs — export module.
  • crates/bcvk-qemu/src/qemu.rsQemuConfig::enable_swtpm() + swtpm field; spawn swtpm before QEMU and kill it on wait(); emit TPM device args.
  • crates/kit/src/run_ephemeral.rs--feature tpm2-swtpm on CommonVmOpts, wired into the qemu config build.
  • docs/swtpm-tpm2.md.

Mirrors the --yubikey USB-passthrough pattern (PR #2).

⚠️ Review notes (not yet built)

  • Authored via the GitHub API; not compiled in this environment. Needs cargo build + cargo nextest run -p bcvk-qemu on a dev box before merge.
  • Assumes swtpm/swtpm-tools are present where QEMU runs (the test image / runner); a clear error is surfaced if missing.
  • enable_swtpm() is called in run_impl (container-entrypoint stage) so swtpm + QEMU share a namespace.
  • Per AGENTS.md/DCO: an LLM must not add Signed-off-by; a human must add it after review.
  • Phase 0: do not merge without Jenny’s review.

Adds a `--feature tpm2-swtpm` path to `bcvk run` that launches an swtpm
(IBM software TPM 2.0) process on the QEMU side and wires an emulated TPM
2.0 into the guest via -tpmdev emulator + an arch-aware tpm-tis device, so
/dev/tpm0 is available inside ephemeral CI VMs without hardware.

New: crates/bcvk-qemu/src/swtpm.rs (config, arg generation, arch device
selection, socket wait, table-driven tests). Wired through QemuConfig
(enable_swtpm + swtpm field), RunningQemu (spawn swtpm before QEMU, kill on
wait), and CommonVmOpts (--feature flag), mirroring the --yubikey passthrough
pattern in PR #2.

For yubiOS ADR-016 Feature 1 / BLOCKER-006; pairs with yubiOS PR bootc-dev#34
(guest-side systemd-tpm2-swtpm.service drop-in). swtpm is test coverage
only; production trust anchor remains YubiKey FIDO2 (ADR-003).

Assisted-by: Sauna (claude-opus-4.8)
@foil-copy-overrate

Copy link
Copy Markdown
Member Author

Closing as the duplicate of the canonical swtpm branch. Two parallel runs produced competing approaches for #3: this PR (feature/swtpm-ci, host-side QEMU -tpmdev emulator) and feat/swtpm-ci (in-guest systemd-tpm2-swtpm.service + --feature tpm2-swtpm + /dev/tpm0). The in-guest route matches the #3 scope literally, so feat/swtpm-ci is canonical. Per Phase 0 policy bcvk is referenced by branch, never merged, so closing this PR — work continues on feat/swtpm-ci.

@foil-copy-overrate

Copy link
Copy Markdown
Member Author

Superseded by the canonical swtpm branch feat/swtpm-ci (@2cc8a75), which takes the in-guest route (systemd-tpm2-swtpm.service + tpm_vtpm_proxy, Dockerfile.swtpm fixture, swtpm_feature.rs integration test) and matches issue #3 scope items 1–2 more literally. This host-side QEMU -tpmdev emulator approach is a valid alternative kept on branch feature/swtpm-ci for reference. Closing to avoid two competing draft PRs for the same task. Per yubiOS doctrine, no bcvk branch is merged — yubiOS references the branch directly. Re #3.

@foil-copy-overrate foil-copy-overrate deleted the feature/swtpm-ci branch June 26, 2026 09:18
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