Skip to content

Commit 80824bf

Browse files
committed
test: add tests for booting secret free VMs
Add a test that we can boot "normal" VMs on ARM with secret freedom enabled (e.g. I/O works through the swiotlb region), and test that on x86 we can boot at least an initrd (e.g. a very simple VM that doesnt have any I/O devices attached). Skip tets on m6g.metal, as currently direct map removal causes panics on this hardware. Signed-off-by: Patrick Roy <[email protected]>
1 parent 3fb0482 commit 80824bf

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Copyright 2025 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
"""Test secret-freedom related functionality."""
4+
5+
import platform
6+
7+
import pytest
8+
9+
from framework import defs
10+
from framework.microvm import Serial
11+
from framework.properties import global_props
12+
from integration_tests.performance.test_initrd import INITRD_FILESYSTEM
13+
14+
pytestmark = pytest.mark.skipif(
15+
global_props.host_linux_version_metrics != "next",
16+
reason="Secret Freedom is only supported on the in-dev upstream kernels for now",
17+
)
18+
19+
20+
@pytest.mark.skipif(
21+
platform.machine() != "aarch64",
22+
reason="only ARM can boot secret free VMs with I/O devices",
23+
)
24+
@pytest.mark.skipif(
25+
global_props.instance == "m6g.metal",
26+
reason="Secret Freedom currently only works on ARM hardware conforming to at least ARMv8.4 as absense of ARM64_HAS_STAGE2_FWB causes kernel panics because of dcache flushing during stage2 page table entry installation",
27+
)
28+
def test_secret_free_boot(microvm_factory, guest_kernel_linux_6_1, rootfs):
29+
"""Tests that a VM can boot if all virtio devices are bound to a swiotlb region, and
30+
that this swiotlb region is actually discovered by the guest."""
31+
vm = microvm_factory.build(guest_kernel_linux_6_1, rootfs)
32+
vm.spawn()
33+
vm.memory_monitor = None
34+
vm.basic_config(memory_config={"initial_swiotlb_size": 64, "secret_free": True})
35+
vm.add_net_iface()
36+
vm.start()
37+
38+
39+
def test_secret_free_initrd(microvm_factory, guest_kernel_linux_6_1):
40+
"""
41+
Test that we can boot a secret hidden initrd (e.g. a VM with no I/O devices)
42+
"""
43+
fs = defs.ARTIFACT_DIR / "initramfs.cpio"
44+
uvm = microvm_factory.build(guest_kernel_linux_6_1)
45+
uvm.initrd_file = fs
46+
uvm.help.enable_console()
47+
uvm.spawn()
48+
uvm.memory_monitor = None
49+
50+
uvm.basic_config(
51+
add_root_device=False,
52+
vcpu_count=1,
53+
boot_args="console=ttyS0 reboot=k panic=1 pci=off no-kvmclock",
54+
use_initrd=True,
55+
memory_config={"initial_swiotlb_size": 64, "secret_free": True},
56+
)
57+
58+
uvm.start()
59+
serial = Serial(uvm)
60+
serial.open()
61+
serial.rx(token="# ")
62+
serial.tx("mount |grep rootfs")
63+
serial.rx(token=f"rootfs on / type {INITRD_FILESYSTEM}")

0 commit comments

Comments
 (0)