Skip to content

Commit b53d0df

Browse files
committed
Remove static checks from AMDSEV initrd test
1 parent 42960dc commit b53d0df

File tree

2 files changed

+8
-109
lines changed

2 files changed

+8
-109
lines changed

misc/AMDSEV/README.md

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +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 validation (archive checks + plain QEMU boot smoke) |
42+
| `test-initrd.sh` | Runs isolated initrd boot smoke test in plain QEMU |
4343
| `build-config` | Pinned versions and checksums for reproducible builds |
4444
| `start-vm.sh` | Starts a TEE VM with SEV-SNP enabled using QEMU |
4545

@@ -119,17 +119,14 @@ The script:
119119

120120
## Isolated Initrd Testing
121121

122-
Use `test-initrd.sh` for focused initrd validation without the full SEV-SNP launch path:
122+
Use `test-initrd.sh` for focused initrd boot validation without the full SEV-SNP launch path:
123123

124124
```sh
125-
# Run static archive/content checks and plain-QEMU boot smoke test
125+
# Run plain-QEMU boot smoke test
126126
./misc/AMDSEV/test-initrd.sh
127127

128-
# Only check initrd archive contents
129-
./misc/AMDSEV/test-initrd.sh --static-only
130-
131-
# Only run plain-QEMU boot smoke test
132-
./misc/AMDSEV/test-initrd.sh --boot-only
128+
# Custom timeout/output directory
129+
./misc/AMDSEV/test-initrd.sh --output-dir ./misc/AMDSEV/output/qemu --timeout 300
133130
```
134131

135132
### Launch Measurement Verification

misc/AMDSEV/test-initrd.sh

Lines changed: 3 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,14 @@
33
# TEST-INITRD.SH - Isolated initrd validation for AMDSEV
44
# ==============================================================================
55
#
6-
# Runs focused checks for initrd behavior without requiring the full SEV-SNP
7-
# launch path:
8-
# 1) Static archive/content checks (no VM boot)
9-
# 2) Plain-QEMU boot smoke test with RPC health check (no OVMF/SEV)
6+
# Runs a focused initrd boot smoke test without requiring the full SEV-SNP
7+
# launch path. Uses plain QEMU (no OVMF/SEV) and validates Katana RPC readiness.
108
#
119
# Usage:
1210
# ./test-initrd.sh [OPTIONS]
1311
#
1412
# Options:
1513
# --output-dir DIR Boot artifacts directory (default: ./output/qemu)
16-
# --static-only Run only static initrd checks
17-
# --boot-only Run only boot smoke test
1814
# --host-rpc-port PORT Host port for forwarded Katana RPC (default: 15052)
1915
# --vm-rpc-port PORT Guest Katana RPC port (default: 5050)
2016
# --timeout SEC Boot wait timeout in seconds (default: 90)
@@ -31,15 +27,12 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
3127
OUTPUT_DIR="${SCRIPT_DIR}/output/qemu"
3228
INITRD_FILE=""
3329
KERNEL_FILE=""
34-
RUN_STATIC=1
35-
RUN_BOOT=1
3630
HOST_RPC_PORT=15052
3731
VM_RPC_PORT=5050
3832
BOOT_TIMEOUT=90
3933
TEST_DISK_SIZE="${TEST_DISK_SIZE:-1G}"
4034

4135
TEMP_DIR="$(mktemp -d /tmp/katana-amdsev-initrd-test.XXXXXX)"
42-
EXTRACT_DIR="${TEMP_DIR}/extract"
4336
SERIAL_LOG="${TEMP_DIR}/serial.log"
4437
DISK_IMG="${TEMP_DIR}/test-disk.img"
4538
QEMU_PID=""
@@ -50,8 +43,6 @@ Usage: $0 [OPTIONS]
5043
5144
Options:
5245
--output-dir DIR Boot artifacts directory (default: ./output/qemu)
53-
--static-only Run only static initrd checks
54-
--boot-only Run only boot smoke test
5546
--host-rpc-port PORT Host port for forwarded Katana RPC (default: 15052)
5647
--vm-rpc-port PORT Guest Katana RPC port (default: 5050)
5748
--timeout SEC Boot wait timeout in seconds (default: 90)
@@ -110,16 +101,6 @@ while [[ $# -gt 0 ]]; do
110101
OUTPUT_DIR="${2:?Missing value for --output-dir}"
111102
shift 2
112103
;;
113-
--static-only)
114-
RUN_STATIC=1
115-
RUN_BOOT=0
116-
shift
117-
;;
118-
--boot-only)
119-
RUN_STATIC=0
120-
RUN_BOOT=1
121-
shift
122-
;;
123104
--host-rpc-port)
124105
HOST_RPC_PORT="${2:?Missing value for --host-rpc-port}"
125106
shift 2
@@ -145,77 +126,6 @@ done
145126
INITRD_FILE="${OUTPUT_DIR}/initrd.img"
146127
KERNEL_FILE="${OUTPUT_DIR}/vmlinuz"
147128

148-
assert_extract_path() {
149-
local rel_path="$1"
150-
if [ ! -e "${EXTRACT_DIR}/${rel_path}" ]; then
151-
die "Expected initrd path missing: ${rel_path}"
152-
fi
153-
}
154-
155-
assert_init_contains() {
156-
local pattern="$1"
157-
if ! grep -Fq -- "$pattern" "${EXTRACT_DIR}/init"; then
158-
die "Expected pattern missing in init script: ${pattern}"
159-
fi
160-
}
161-
162-
run_static_checks() {
163-
log "Running static initrd checks"
164-
165-
require_tool gzip
166-
require_tool cpio
167-
require_tool grep
168-
169-
[ -f "$INITRD_FILE" ] || die "Initrd not found: $INITRD_FILE"
170-
171-
if ! gzip -t "$INITRD_FILE" 2>/dev/null; then
172-
die "Initrd is not valid gzip: $INITRD_FILE"
173-
fi
174-
175-
mkdir -p "$EXTRACT_DIR"
176-
(
177-
cd "$EXTRACT_DIR"
178-
gzip -dc "$INITRD_FILE" | cpio -id --quiet
179-
)
180-
181-
REQUIRED_PATHS=(
182-
init
183-
bin/busybox
184-
bin/katana
185-
etc/passwd
186-
etc/group
187-
bin/sh
188-
bin/mount
189-
bin/umount
190-
bin/ip
191-
bin/insmod
192-
bin/poweroff
193-
bin/sync
194-
)
195-
196-
for path in "${REQUIRED_PATHS[@]}"; do
197-
assert_extract_path "$path"
198-
done
199-
200-
[ -x "${EXTRACT_DIR}/init" ] || die "Init script is not executable"
201-
[ -x "${EXTRACT_DIR}/bin/katana" ] || die "Katana binary in initrd is not executable"
202-
203-
assert_init_contains "trap shutdown_handler TERM INT"
204-
assert_init_contains "poweroff -f"
205-
assert_init_contains "exec 0</dev/console"
206-
assert_init_contains "if [ -d /sys/class/net/eth0 ]; then"
207-
assert_init_contains "katana.args="
208-
209-
if [ ! -e "${EXTRACT_DIR}/lib/modules/tsm.ko" ]; then
210-
warn "tsm.ko not present in initrd"
211-
fi
212-
if [ ! -e "${EXTRACT_DIR}/lib/modules/sev-guest.ko" ]; then
213-
warn "sev-guest.ko not present in initrd"
214-
fi
215-
216-
log "Static initrd checks passed"
217-
}
218-
219129
resolve_qemu_bin() {
220130
if [ -n "${QEMU_BIN:-}" ]; then
221131
echo "$QEMU_BIN"
@@ -322,14 +232,6 @@ run_boot_smoke_test() {
322232
}
323233

324234
log "Output directory: $OUTPUT_DIR"
325-
log "Modes: static=$RUN_STATIC boot=$RUN_BOOT"
326-
327-
if [ "$RUN_STATIC" -eq 1 ]; then
328-
run_static_checks
329-
fi
330-
331-
if [ "$RUN_BOOT" -eq 1 ]; then
332-
run_boot_smoke_test
333-
fi
235+
run_boot_smoke_test
334236

335237
log "All requested initrd checks passed"

0 commit comments

Comments
 (0)