Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
5ce3d83
build: generate SB varstores in-tree (mkvarstore.py); harness --forward
HarryR Nov 4, 2026
9257705
Dockerfile.build: drop virt-firmware and python3-pip
HarryR Nov 4, 2026
305ef85
harness: pin, multi-arch (host-aware KVM/TCG + mock), publish per rel…
HarryR Nov 4, 2026
e6dfd03
harness: probe vTPM provisioning via getcap (nvreadpublic segfaults)
HarryR Nov 4, 2026
0c7db36
selftest: harness --timeout, aarch64 PL011 capture, selftest-<arch>
HarryR Nov 4, 2026
90b550e
release: tag releases as plain v*
HarryR Nov 4, 2026
cbc0173
release: attest the files inside the release zips (+ qemu-test.sh)
HarryR Nov 4, 2026
faa8604
publish: fix teardown safety, GCP image reuse, SNP/t2a launch, consol…
HarryR Nov 5, 2026
be996b4
stage0: accept User or Deployed Mode; test payload mode probes
HarryR Nov 5, 2026
34bd6fa
gvnic: UEFI SNP driver for the Google Virtual NIC, embedded in stage0
HarryR Nov 5, 2026
db8caab
stage0: signal UDP4 RecycleSignal after copying a datagram out
HarryR Nov 5, 2026
b3df2b0
dbx: emit our own dbx for GCP as a KEK-signed authenticated update
HarryR Nov 5, 2026
aeecd8d
tooling: dev key reuse, verbose stage0 builds, self-ending console fo…
HarryR Nov 5, 2026
9331e1f
keys: use GCP's fixed signature owner GUID for PK/KEK/db
HarryR Nov 6, 2026
5feb45f
publish: create.sh exits 0 on success; tag EC2 instances Project=lock…
HarryR Nov 6, 2026
315e8de
pcrs: reproduce stage0's PCRs from its release artifacts; ship pcrs.json
HarryR Nov 6, 2026
af0957c
pcrs: emit stage0.replay.json (pcr-replay/v1) alongside the reference…
HarryR Nov 9, 2026
bd5f47c
gvnic: one summary line by default, on stage0's log timeline
HarryR Nov 9, 2026
615b810
gvnic: direct BAR2 doorbells; full device teardown at ExitBootServices
HarryR Nov 10, 2026
34dbc69
stage0: supply a local-APIC timer tick when the firmware's never arri…
HarryR Nov 10, 2026
8322629
predict-pcrs: list replay events in firmware log order
HarryR Nov 10, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
115 changes: 107 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ name: build
on:
push:
branches: [main]
# stage0 is the db-signed root of trust; tag stage0-v* to cut a release.
tags: ['stage0-v*']
# stage0 is the db-signed root of trust; tag v* to cut a release.
tags: ['v*']
pull_request:
branches: [main]
workflow_dispatch:
Expand Down Expand Up @@ -44,16 +44,20 @@ jobs:
build/${{ matrix.arch }}/boot.disk
build/${{ matrix.arch }}/BOOT*.EFI
build/${{ matrix.arch }}/efi-vars.*
build/${{ matrix.arch }}/dbx.esl
build/${{ matrix.arch }}/dbx.auth.bin
build/${{ matrix.arch }}/pcrs.json
build/${{ matrix.arch }}/stage0.replay.json
build/${{ matrix.arch }}/os-release
build/${{ matrix.arch }}/*.cer
build/${{ matrix.arch }}/*.guid
if-no-files-found: error

# ---- Release track (tag: stage0-v*) --------------------------------------
# ---- Release track (tag: v*) --------------------------------------
release-stage0:
runs-on: ubuntu-latest
needs: build
if: startsWith(github.ref, 'refs/tags/stage0-v')
if: startsWith(github.ref, 'refs/tags/v')
permissions:
contents: write
id-token: write
Expand All @@ -73,12 +77,27 @@ jobs:
gh api repos/${{ github.repository }}/actions/artifacts/${ARTIFACT_ID}/zip > stage0-${arch}.zip
done

- name: Attest stage0 zips
# One attestation covering the release zips, every file inside them, and the released
# harness script. Consumers can verify a zip and extract from it, or verify an extracted file
# on its own (`gh attestation verify BOOTX64.EFI --repo ...`). Subjects are named via a
# checksums file so the per-arch copies of same-named files stay distinguishable
# (x86_64/... vs aarch64/...); verification itself matches by digest.
- name: List attestation subjects (zips + their contents + qemu-test.sh)
run: |
for arch in x86_64 aarch64; do
mkdir -p "contents/$arch" && unzip -q "stage0-$arch.zip" -d "contents/$arch"
done
{
sha256sum stage0-x86_64.zip stage0-aarch64.zip
(cd tools && sha256sum qemu-test.sh)
(cd contents && find . -type f -printf '%P\n' | LC_ALL=C sort | xargs -r -d '\n' sha256sum)
} > subjects.sha256
cat subjects.sha256

- name: Attest stage0 zips, their contents, and qemu-test.sh
uses: actions/attest-build-provenance@977bb373ede98d70efdf65b84cb5f73e068dcc2a # v3.0.0
with:
subject-path: |
stage0-x86_64.zip
stage0-aarch64.zip
subject-checksums: subjects.sha256

- name: Create stage0 release
uses: softprops/action-gh-release@718ea10b132b3b2eba29c1007bb80653f286566b # v3.0.1
Expand All @@ -94,3 +113,83 @@ jobs:
prerelease: true
generate_release_notes: true
make_latest: true

# ---- QEMU test-harness image (tag: v*) -----------------------------
# End-user harness: qemu + swtpm + OVMF/AAVMF + the EC2 metadata mock, qemu-test.sh as entrypoint.
# Published with the stage0 release it ships beside: its firmware boots that release's efi-vars.
# Multi-arch so it runs identically on amd64 and arm64 hosts (KVM when host == guest arch, TCG
# otherwise). Consumers pin the digest appended to the release notes below, not the tag.
release-harness:
runs-on: ubuntu-latest
needs: release-stage0
if: startsWith(github.ref, 'refs/tags/v')
permissions:
contents: write
packages: write
id-token: write
attestations: write

steps:
- name: Checkout repository
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0

- name: Set up QEMU (arm64 layers on the amd64 runner)
uses: docker/setup-qemu-action@99012661954931238ded8c8b007157a8430204e1 # v4.4.0

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4.1.0

- name: Log in to GitHub Container Registry
uses: docker/login-action@650006c6eb7dba73a995cc03b0b2d7f5ca915bee # v4.2.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@80c7e94dd9b9319bd5eb7a0e0fe9291e23a2a2e9 # v6.1.0
with:
images: ghcr.io/${{ github.repository }}-harness
tags: |
type=ref,event=tag
flavor: |
latest=false

- name: Build and push multi-arch harness
id: push
uses: docker/build-push-action@f9f3042f7e2789586610d6e8b85c8f03e5195baf # v7.2.0
with:
context: .
file: ./Dockerfile.harness
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
annotations: ${{ steps.meta.outputs.annotations }}
provenance: true
sbom: true

- name: Attest harness image
uses: actions/attest-build-provenance@977bb373ede98d70efdf65b84cb5f73e068dcc2a # v3.0.0
with:
subject-name: ghcr.io/${{ github.repository }}-harness
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true

- name: Append image digest to the release notes
env:
GH_TOKEN: ${{ github.token }}
TAG: ${{ github.ref_name }}
DIGEST: ${{ steps.push.outputs.digest }}
run: |
gh release view "$TAG" -R "${{ github.repository }}" --json body -q .body > notes.md
{
echo
echo "### Test harness image"
echo
echo '```'
echo "ghcr.io/${{ github.repository }}-harness@${DIGEST}"
echo '```'
} >> notes.md
gh release edit "$TAG" -R "${{ github.repository }}" --notes-file notes.md
4 changes: 1 addition & 3 deletions Dockerfile.build
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,14 @@ RUN apt-get -qq update && \
openssl \
ovmf \
python3 \
python3-pip \
qemu-efi-aarch64 \
rpm \
rpm2cpio \
sbsigntool \
util-linux \
uuid-runtime \
wget \
xz-utils && \
pip3 install --break-system-packages virt-firmware
xz-utils

# Reproducible builds environment
ENV SOURCE_DATE_EPOCH=0
Expand Down
30 changes: 21 additions & 9 deletions Dockerfile.harness
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Lean QEMU test-harness runtime for qemu-test.sh: no rust/sbsign/kernel toolchain,
# just the qemu/swtpm layer needed to boot a disk and mock the metadata service.
FROM debian:bookworm-slim
# Pinned by digest (multi-arch index): the OVMF/AAVMF CODE images here are what boot the varstores
# tools/mkvarstore.py lays out for bookworm's pflash geometry, so the firmware must not drift.
# Published multi-arch (linux/amd64 + linux/arm64) to ghcr on stage0-v* tags, alongside the
# stage0 release it was built with.
FROM debian:bookworm-slim@sha256:99c0b25c46d0214d5a2091092e7908907dcaecd6a962cde0ac700acee222b6f3

RUN apt-get -qq update && \
apt-get install -y --no-install-recommends \
Expand All @@ -22,15 +26,23 @@ RUN apt-get -qq update && \
tcpdump && \
rm -rf /var/lib/apt/lists/*

# Pre-bake the EC2 metadata mock so make/CI runs don't download into the
# bind-mounted repo. qemu-test.sh checks EC2_MOCK_CACHE (set to /opt by the
# Makefile) before falling back to its own download.
# Pre-bake the EC2 metadata mock for the image's arch so make/CI runs don't download into the
# bind-mounted repo. qemu-test.sh checks EC2_MOCK_CACHE (set to /opt by the Makefile) before
# falling back to its own download; hashes match the ones in qemu-test.sh.
ARG TARGETARCH
ARG AEMM_VERSION=v1.13.0
ARG AEMM_SHA256=4f89ddc71ac53ce540bda1f9c340526d558eed8e41349761f2798acf1b254950
RUN curl -fsSL -o /opt/ec2-metadata-mock-linux-amd64 \
"https://github.com/aws/amazon-ec2-metadata-mock/releases/download/${AEMM_VERSION}/ec2-metadata-mock-linux-amd64" && \
echo "${AEMM_SHA256} /opt/ec2-metadata-mock-linux-amd64" | sha256sum -c - && \
chmod +x /opt/ec2-metadata-mock-linux-amd64
ARG AEMM_SHA256_amd64=4f89ddc71ac53ce540bda1f9c340526d558eed8e41349761f2798acf1b254950
ARG AEMM_SHA256_arm64=9dae5b5849365dbaa133309da81f49bafe94ec0aa7e6b05ce3eb7a8f151c2217
RUN case "${TARGETARCH}" in \
amd64) sha="${AEMM_SHA256_amd64}" ;; \
arm64) sha="${AEMM_SHA256_arm64}" ;; \
*) echo "unsupported TARGETARCH: ${TARGETARCH}" >&2; exit 1 ;; \
esac && \
f=/opt/ec2-metadata-mock-linux-${TARGETARCH} && \
curl -fsSL -o "$f" \
"https://github.com/aws/amazon-ec2-metadata-mock/releases/download/${AEMM_VERSION}/ec2-metadata-mock-linux-${TARGETARCH}" && \
echo "${sha} $f" | sha256sum -c - && \
chmod +x "$f"

# The mock is baked at /opt; point the entrypoint script at it by default.
ENV EC2_MOCK_CACHE=/opt
Expand Down
55 changes: 46 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
build/%/stage0.efi build/%/payload.efi build/%/boot.disk

STAGE0_DIR = crates/stage0
# STAGE0_FEATURES=verbose: debug build of stage0 (DNS/TCP/HTTP step logging). Changes the
# measured binary -- debug only, never a release.
STAGE0_FEATURES ?=

# Default to the host architecture (uname -m gives x86_64 / aarch64 on Linux), so
# bare `make`, `make boot`, `make test` "just work". Override with ARCH=... or by
Expand All @@ -35,8 +38,22 @@ docker-build-harness:
# ---- Secure Boot keys: stage0's own snakeoil PK/KEK/db (regenerated per build) ----
# The pattern rule generates the whole set into build/keys via tools/gen-keys.sh;
# release.pem (below) is matched by its explicit rule instead.
#
# HAZMAT_WARNING_NO_REGEN_KEYS_DEV_ONLY=1 -- DEV ITERATION ONLY: reuse the existing build/keys
# instead of re-minting them, so a rebuilt boot.disk still matches a cloud image/varstore already
# enrolled with these keys (fast driver/debug loops: swap the disk, keep the keys). Never for a
# release or any published image: the keys then outlive a single build. Refused under CI.
ifeq ($(HAZMAT_WARNING_NO_REGEN_KEYS_DEV_ONLY),1)
ifneq ($(CI),)
$(error HAZMAT_WARNING_NO_REGEN_KEYS_DEV_ONLY is refused under CI)
endif
$(warning !!! HAZMAT_WARNING_NO_REGEN_KEYS_DEV_ONLY=1: REUSING existing Secure Boot keys in build/keys -- DEV ONLY, never release/publish this build !!!)
build/keys/%:
@test -f $@ || { echo "HAZMAT_WARNING_NO_REGEN_KEYS_DEV_ONLY: $@ missing -- build once without it to mint keys" >&2; exit 1; }
else
build/keys/%: docker-build-base
$(DOCKER_RUN) $(DOCKER_SAMEUSER) $(BUILD_IMAGE) ./tools/gen-keys.sh build/keys
endif

# ---- stage0-sign: this repo's standalone host-side signer (ed25519 keygen + domain-separated
# signatures), so stage0 builds + tests without stage1's deploy tool. Built + run in the container.
Expand All @@ -53,17 +70,17 @@ sign-test: docker-build-base

# ---- CI gate: fmt + clippy + unit tests across all crates (what the branch ruleset requires) ----
# stage0 is not one cargo workspace: 4 independent crates in two target families. The EFI crates
# (ena, stage0, stage0-test-payload) are no_std UEFI and not host-testable -> fmt + clippy on the
# (ena, gvnic, stage0, stage0-test-payload) are no_std UEFI and not host-testable -> fmt + clippy on the
# UEFI target; the host signer (stage0-sign) also runs its unit tests (incl. the golden vector).
UEFI_CRATES := ena stage0 stage0-test-payload
UEFI_CRATES := ena gvnic stage0 stage0-test-payload
HOST_CRATES := stage0-sign
.PHONY: ci fmt-fix
fmt-fix: docker-build-base ## Apply rustfmt across all crates (no --check)
$(DOCKER_RUN) $(DOCKER_SAMEUSER) $(BUILD_IMAGE) bash -c '\
for c in $(UEFI_CRATES) $(HOST_CRATES); do cargo fmt --manifest-path crates/$$c/Cargo.toml; done'
# ena.efi is include_bytes!'d by the stage0 crate, so it must exist before clippy/check can
# ena.efi + gvnic.efi are include_bytes!'d by the stage0 crate, so they must exist before clippy/check can
# compile it (a clean CI checkout has no build/ artifacts; a warm local tree hid this).
ci: docker-build-base build/x86_64/ena.efi
ci: docker-build-base build/x86_64/ena.efi build/x86_64/gvnic.efi
$(DOCKER_RUN) $(DOCKER_SAMEUSER) $(BUILD_IMAGE) bash -c '\
set -e; rustup target add x86_64-unknown-uefi x86_64-unknown-linux-musl; \
for c in $(UEFI_CRATES) $(HOST_CRATES); do \
Expand Down Expand Up @@ -93,14 +110,22 @@ build/%/ena.efi: docker-build-base
$(DOCKER_RUN) -e ARCH=$* $(DOCKER_SAMEUSER) $(BUILD_IMAGE) \
bash -c "mkdir -p build/$* && rustup target add $*-unknown-uefi && cargo build --release --manifest-path crates/ena/Cargo.toml --target $*-unknown-uefi && cp -v crates/ena/target/$*-unknown-uefi/release/ena.efi $@"

# ---- Build the gvnic.efi UEFI driver (embedded into stage0 for GCP/gVNIC netboot) ----
# Same shape as ena.efi, for the Google Virtual NIC: GCP's UEFI firmware ships no gVNIC
# driver, and GCP requires gVNIC for Confidential VMs and Arm. Embedded unconditionally.
.PRECIOUS: build/%/gvnic.efi
build/%/gvnic.efi: docker-build-base
$(DOCKER_RUN) -e ARCH=$* $(DOCKER_SAMEUSER) $(BUILD_IMAGE) \
bash -c "mkdir -p build/$* && rustup target add $*-unknown-uefi && cargo build --release --manifest-path crates/gvnic/Cargo.toml --target $*-unknown-uefi && cp -v crates/gvnic/target/$*-unknown-uefi/release/gvnic.efi $@"

# ---- Build the stage0 UEFI binary ----
# mkdir runs inside the container (as DOCKER_SAMEUSER) so the output dir is owned
# by the build user, not by the host caller (which is root under `gh act`).
# stage0 include_bytes! build/$*/ena.efi unconditionally (one measured unit), so the
# ena.efi prerequisite must be built first; nothing extra to pass on the command line.
build/%/stage0.efi: build/%/ena.efi docker-build-base
# stage0 include_bytes! build/$*/{ena,gvnic}.efi unconditionally (one measured unit), so the
# driver prerequisites must be built first; nothing extra to pass on the command line.
build/%/stage0.efi: build/%/ena.efi build/%/gvnic.efi docker-build-base
$(DOCKER_RUN) -e ARCH=$* $(DOCKER_SAMEUSER) $(BUILD_IMAGE) \
bash -c "mkdir -p build/$* && rustup target add $*-unknown-uefi && cargo build --release --manifest-path $(STAGE0_DIR)/Cargo.toml --target $*-unknown-uefi && cp -v $(STAGE0_DIR)/target/$*-unknown-uefi/release/stage0.efi $@"
bash -c "mkdir -p build/$* && rustup target add $*-unknown-uefi && cargo build --release --manifest-path $(STAGE0_DIR)/Cargo.toml --target $*-unknown-uefi $(if $(STAGE0_FEATURES),--features $(STAGE0_FEATURES)) && cp -v $(STAGE0_DIR)/target/$*-unknown-uefi/release/stage0.efi $@"

# ---- Assemble + db-sign the boot disk (privileged: losetup/mount) ----
build/%/boot.disk: build/%/stage0.efi build/keys/db.crt
Expand Down Expand Up @@ -132,9 +157,10 @@ build/%/args.json.sig: build/keys/release.pem | sign-bin

# ---- QEMU harness: the lean harness image bakes qemu-test.sh as its entrypoint
# (and the EC2_MOCK_CACHE + iptables-ack env), so we just append CLI args. ----
# HARNESS_TIMEOUT=<s> bounds each boot (qemu-test.sh --timeout); unset = no limit.
STAGE0_QEMU = $(DOCKER_RUN) $(DOCKER_OPT_KVM) \
--cap-add=NET_ADMIN --device=/dev/net/tun \
$(HARNESS_IMAGE)
$(HARNESS_IMAGE) $(if $(HARNESS_TIMEOUT),--timeout $(HARNESS_TIMEOUT))

# Boot stage0 under QEMU. Serves a staging dir (so payload, signed args, and a signed
# manifest are all served uniformly at http://SERVE_HOST/<file>) and regenerates the
Expand Down Expand Up @@ -220,6 +246,17 @@ smoke-boot-%: build/%/boot.disk build/%/payload.efi build/%/args.json.sig docker

smoke-boot: smoke-boot-$(ARCH)

# ---- Self-test: stage0's part of the workspace `make selftest` (PASS/FAIL, non-zero on FAIL).
# The boot-test matrix above, with every boot time-bounded so a hang fails instead of blocking.
# One bound for both arches (~3x the slowest measured boot; aarch64 is TCG-emulated but fast).
SELFTEST_TIMEOUT_x86_64 ?= 300
SELFTEST_TIMEOUT_aarch64 ?= 300
.PHONY: selftest
selftest:
@echo "needs an arch suffix, e.g. 'make selftest-x86_64'." >&2; exit 2
selftest-%:
$(MAKE) --no-print-directory smoke-boot-$* HARNESS_TIMEOUT=$(SELFTEST_TIMEOUT_$*)

# Arch-less convenience forms target the host architecture ($(ARCH)).
.PHONY: build boot test
build: build-$(ARCH)
Expand Down
Loading
Loading