Skip to content

Commit 41f5cb7

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 41f5cb7

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
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 = [
15+
pytest.mark.skipif(
16+
global_props.host_linux_version_metrics != "next",
17+
reason="Secret Freedom is only supported on the in-dev upstream kernels for now",
18+
),
19+
pytest.mark.skipif(
20+
global_props.instance == "m6g.metal",
21+
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",
22+
),
23+
]
24+
25+
26+
@pytest.mark.skipif(
27+
platform.machine() != "aarch64",
28+
reason="only ARM can boot secret free VMs with I/O devices",
29+
)
30+
def test_secret_free_boot(microvm_factory, guest_kernel_linux_6_1, rootfs):
31+
"""Tests that a VM can boot if all virtio devices are bound to a swiotlb region, and
32+
that this swiotlb region is actually discovered by the guest."""
33+
vm = microvm_factory.build(guest_kernel_linux_6_1, rootfs)
34+
vm.spawn()
35+
vm.memory_monitor = None
36+
vm.basic_config(memory_config={"initial_swiotlb_size": 64, "secret_free": True})
37+
vm.add_net_iface()
38+
vm.start()
39+
40+
41+
def test_secret_free_initrd(microvm_factory, guest_kernel_linux_6_1):
42+
"""
43+
Test that we can boot a secret hidden initrd (e.g. a VM with no I/O devices)
44+
"""
45+
fs = defs.ARTIFACT_DIR / "initramfs.cpio"
46+
uvm = microvm_factory.build(guest_kernel_linux_6_1)
47+
uvm.initrd_file = fs
48+
uvm.help.enable_console()
49+
uvm.spawn()
50+
uvm.memory_monitor = None
51+
52+
uvm.basic_config(
53+
add_root_device=False,
54+
vcpu_count=1,
55+
boot_args="console=ttyS0 reboot=k panic=1 pci=off no-kvmclock",
56+
use_initrd=True,
57+
memory_config={"initial_swiotlb_size": 64, "secret_free": True},
58+
)
59+
60+
uvm.start()
61+
serial = Serial(uvm)
62+
serial.open()
63+
serial.rx(token="# ")
64+
serial.tx("mount |grep rootfs")
65+
serial.rx(token=f"rootfs on / type {INITRD_FILESYSTEM}")

0 commit comments

Comments
 (0)