Skip to content

Commit e329a21

Browse files
authored
Add isolated AMDSEV initrd tests (#439)
Adds an isolated AMDSEV initrd test script for archive validation and plain QEMU boot smoke checks.
1 parent 8b71ea9 commit e329a21

File tree

5 files changed

+446
-3
lines changed

5 files changed

+446
-3
lines changed
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
name: amdsev-initrd-test
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- "misc/AMDSEV/**"
9+
- "scripts/build-musl.sh"
10+
- ".github/workflows/amdsev-initrd-test.yml"
11+
12+
pull_request:
13+
types: [opened, synchronize, ready_for_review]
14+
paths:
15+
- "misc/AMDSEV/**"
16+
- "scripts/build-musl.sh"
17+
- ".github/workflows/amdsev-initrd-test.yml"
18+
19+
concurrency:
20+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
21+
cancel-in-progress: true
22+
23+
env:
24+
CARGO_TERM_COLOR: always
25+
26+
jobs:
27+
amdsev-initrd-test:
28+
runs-on: ubuntu-latest
29+
timeout-minutes: 90
30+
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.draft == false)
31+
container:
32+
image: ghcr.io/dojoengine/katana-dev:latest
33+
34+
steps:
35+
- uses: actions/checkout@v4
36+
with:
37+
submodules: recursive
38+
39+
# Workaround for https://github.com/actions/runner-images/issues/6775
40+
- run: git config --global --add safe.directory "*"
41+
42+
- name: Install dependencies
43+
run: |
44+
export DEBIAN_FRONTEND=noninteractive
45+
apt-get update
46+
apt-get install -y \
47+
qemu-system-x86 \
48+
cpio \
49+
zstd \
50+
e2fsprogs \
51+
curl \
52+
socat \
53+
musl-tools \
54+
clang \
55+
file
56+
57+
- name: Add Ubuntu package repo for AMDSEV artifacts
58+
run: |
59+
cat >/etc/apt/sources.list.d/ubuntu-noble.list <<'EOF'
60+
deb [trusted=yes] http://archive.ubuntu.com/ubuntu noble main universe
61+
deb [trusted=yes] http://archive.ubuntu.com/ubuntu noble-updates main universe
62+
deb [trusted=yes] http://security.ubuntu.com/ubuntu noble-security main universe
63+
EOF
64+
apt-get update
65+
66+
- uses: Swatinem/rust-cache@v2
67+
with:
68+
key: ci-${{ github.job }}
69+
shared-key: katana-ci-cache-musl
70+
71+
- name: Build contract artifacts
72+
run: make contracts
73+
74+
- name: Build required VM components
75+
shell: bash
76+
run: |
77+
set -euo pipefail
78+
set -a
79+
source misc/AMDSEV/build-config
80+
set +a
81+
export SOURCE_DATE_EPOCH="$(git log -1 --format=%ct)"
82+
83+
./scripts/build-musl.sh
84+
KATANA_BINARY="./target/x86_64-unknown-linux-musl/performance/katana"
85+
86+
./misc/AMDSEV/build-kernel.sh ./misc/AMDSEV/output/qemu
87+
./misc/AMDSEV/build-initrd.sh "$KATANA_BINARY" ./misc/AMDSEV/output/qemu/initrd.img "$KERNEL_VERSION"
88+
89+
cp "$KATANA_BINARY" ./misc/AMDSEV/output/qemu/katana
90+
91+
- name: Run isolated initrd tests
92+
run: |
93+
./misc/AMDSEV/test-initrd.sh --output-dir ./misc/AMDSEV/output/qemu --timeout 300
94+
95+
- name: Upload AMDSEV build output on failure
96+
if: failure()
97+
uses: actions/upload-artifact@v4
98+
with:
99+
name: amdsev-initrd-output-${{ github.run_id }}
100+
if-no-files-found: ignore
101+
path: |
102+
misc/AMDSEV/output/qemu

misc/AMDSEV/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ If `--katana` is not provided, `build.sh` prompts for confirmation (`y/N`) befor
3939
| `build-ovmf.sh` | Builds OVMF firmware from AMD's fork with SEV-SNP support |
4040
| `build-kernel.sh` | Downloads and extracts Ubuntu kernel (`vmlinuz`) |
4141
| `build-initrd.sh` | Creates minimal initrd with busybox, SEV-SNP modules, and katana |
42+
| `test-initrd.sh` | Runs isolated initrd boot smoke test in plain QEMU |
4243
| `build-config` | Pinned versions and checksums for reproducible builds |
4344
| `start-vm.sh` | Starts a TEE VM with SEV-SNP and launches Katana asynchronously |
4445

@@ -155,6 +156,18 @@ The script:
155156
- Forwards RPC port 5050 to host port 15051
156157
- Outputs serial log to a temp file and follows it
157158

159+
## Isolated Initrd Testing
160+
161+
Use `test-initrd.sh` for focused initrd boot validation without the full SEV-SNP launch path:
162+
163+
```sh
164+
# Run plain-QEMU boot smoke test
165+
./misc/AMDSEV/test-initrd.sh
166+
167+
# Custom timeout/output directory
168+
./misc/AMDSEV/test-initrd.sh --output-dir ./misc/AMDSEV/output/qemu --timeout 300
169+
```
170+
158171
### Launch Measurement Verification
159172

160173
To verify a TEE VM's integrity, compute the expected launch measurement using `snp-digest`:

misc/AMDSEV/build-initrd.sh

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,17 @@ if [[ $# -lt 2 ]] || [[ "${1:-}" == "-h" ]] || [[ "${1:-}" == "--help" ]]; then
8484
usage
8585
fi
8686

87-
KATANA_BINARY="$1"
88-
OUTPUT_INITRD="$2"
87+
to_abs_path() {
88+
local path="$1"
89+
if [[ "$path" = /* ]]; then
90+
printf '%s\n' "$path"
91+
else
92+
printf '%s/%s\n' "$(pwd -P)" "$path"
93+
fi
94+
}
95+
96+
KATANA_BINARY="$(to_abs_path "$1")"
97+
OUTPUT_INITRD="$(to_abs_path "$2")"
8998
KERNEL_VERSION="${3:-${KERNEL_VERSION:?KERNEL_VERSION must be set or passed as third argument}}"
9099
OUTPUT_DIR="$(dirname "$OUTPUT_INITRD")"
91100

misc/AMDSEV/build-kernel.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,16 @@ if [[ $# -lt 1 ]] || [[ "${1:-}" == "-h" ]] || [[ "${1:-}" == "--help" ]]; then
5151
usage
5252
fi
5353

54-
DEST="$1"
54+
to_abs_path() {
55+
local path="$1"
56+
if [[ "$path" = /* ]]; then
57+
printf '%s\n' "$path"
58+
else
59+
printf '%s/%s\n' "$(pwd -P)" "$path"
60+
fi
61+
}
62+
63+
DEST="$(to_abs_path "$1")"
5564

5665
# Validate required environment variables
5766
KERNEL_VER="${KERNEL_VERSION:?KERNEL_VERSION not set - source build-config first}"

0 commit comments

Comments
 (0)