Skip to content

Commit f3b6943

Browse files
committed
misc/AMDSEV: strengthen reproducible build guarantees
1 parent cf05ec6 commit f3b6943

File tree

8 files changed

+748
-361
lines changed

8 files changed

+748
-361
lines changed

misc/AMDSEV/README.md

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,12 +194,46 @@ Use `ovmf-metadata` to inspect the OVMF firmware's SEV metadata sections:
194194

195195
## Reproducible Builds
196196

197-
Set `SOURCE_DATE_EPOCH` for deterministic output:
197+
`SOURCE_DATE_EPOCH` is required for deterministic builds:
198198

199199
```sh
200-
SOURCE_DATE_EPOCH=$(git log -1 --format=%ct) ./misc/AMDSEV/build.sh
200+
export SOURCE_DATE_EPOCH=$(git log -1 --format=%ct)
201+
./misc/AMDSEV/build.sh
202+
```
203+
204+
For stronger package source determinism, pin apt to a snapshot:
205+
206+
```sh
207+
export APT_SNAPSHOT_URL="http://snapshot.ubuntu.com/ubuntu/20250115T000000Z/"
208+
export APT_SNAPSHOT_SUITE="noble"
209+
export APT_SNAPSHOT_COMPONENTS="main"
201210
```
202211

212+
If building in a containerized pipeline, set the image digest for provenance tracking:
213+
214+
```sh
215+
export BUILD_CONTAINER_IMAGE_DIGEST="sha256:<digest>"
216+
```
217+
218+
Run a built-in reproducibility check (double build + hash compare):
219+
220+
```sh
221+
export KATANA_STRICT_REPRO=1 # optional: requires vendored cargo deps for strict katana reproducibility
222+
./misc/AMDSEV/build.sh --katana /path/to/katana --repro-check
223+
```
224+
225+
You can also compare two build output directories directly:
226+
227+
```sh
228+
./misc/AMDSEV/verify-build.sh --compare /path/to/build-a /path/to/build-b
229+
```
230+
231+
Each build writes deterministic provenance metadata to:
232+
- `build-info.txt`
233+
- `materials.lock`
234+
235+
See [`REPRODUCIBILITY.md`](./REPRODUCIBILITY.md) for the full policy.
236+
203237
## Troubleshooting
204238

205239
### `SEV: guest firmware hashes table area is invalid (base=0x0 size=0x0)`

misc/AMDSEV/REPRODUCIBILITY.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# AMD SEV-SNP Build Reproducibility Policy
2+
3+
## Scope
4+
5+
This policy targets byte-identical outputs for the following artifacts when built with the same:
6+
- source tree revision
7+
- `build-config` pins
8+
- `SOURCE_DATE_EPOCH`
9+
- toolchain/runtime environment
10+
11+
Artifacts:
12+
- `OVMF.fd`
13+
- `vmlinuz`
14+
- `initrd.img`
15+
- `katana`
16+
17+
## Required Inputs
18+
19+
- `SOURCE_DATE_EPOCH` must be explicitly set and fixed.
20+
- `OVMF_COMMIT` must be pinned.
21+
- Package versions and SHA256 values in `build-config` must remain pinned.
22+
- `BUILD_CONTAINER_IMAGE_DIGEST` should be set when using a containerized CI pipeline.
23+
- For katana, prefer passing a prebuilt pinned binary via `--katana`. If auto-building, set `KATANA_STRICT_REPRO=1` with vendored dependencies.
24+
25+
## Stronger Package Source Determinism
26+
27+
To avoid host apt source drift, set:
28+
- `APT_SNAPSHOT_URL`
29+
- `APT_SNAPSHOT_SUITE`
30+
- `APT_SNAPSHOT_COMPONENTS`
31+
32+
If unset, build scripts use host apt sources and reproducibility guarantees are weaker.
33+
34+
## Validation
35+
36+
- Use `./misc/AMDSEV/build.sh --repro-check` to run a double-build and hash comparison.
37+
- Use `./misc/AMDSEV/verify-build.sh --compare DIR_A DIR_B` for explicit directory comparisons.
38+
39+
## Provenance Files
40+
41+
Each build emits:
42+
- `build-info.txt` with pinned inputs and output checksums
43+
- `materials.lock` with immutable input and artifact hashes

misc/AMDSEV/build-config

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,13 @@ BUSYBOX_PKG_SHA256="944b2728f53ceb3916cec2c962873c9951e612408099601751db2a0a5d81
2020
# Kernel modules extra (Ubuntu package, for initrd SEV-SNP support)
2121
KERNEL_MODULES_EXTRA_PKG_VERSION="6.8.0-90.91"
2222
KERNEL_MODULES_EXTRA_PKG_SHA256="c17bd76779ce68a076dc1ef9b1669947f35f1868f6736dbd0a8a7ccacf7571f3"
23+
24+
# Optional apt snapshot source for stronger reproducibility guarantees.
25+
# When set, build scripts use this source instead of host /etc/apt/sources.list.
26+
# Example:
27+
# APT_SNAPSHOT_URL="http://snapshot.ubuntu.com/ubuntu/20250115T000000Z/"
28+
# APT_SNAPSHOT_SUITE="noble"
29+
# APT_SNAPSHOT_COMPONENTS="main"
30+
APT_SNAPSHOT_URL=""
31+
APT_SNAPSHOT_SUITE="noble"
32+
APT_SNAPSHOT_COMPONENTS="main"

0 commit comments

Comments
 (0)