Skip to content

Commit b018e3b

Browse files
committed
fix: boottimer device MMIO address
When we re-arranged the MMIO address space in commit 9a165d1 (arch: define 64-bit capable MMIO memory regions) we moved the MMIO region of the boot timer device for x86 systems, but we didn't update the init scripts that hardcode it and use it to report boot time timestamp back to Firecracker. Update the init.c and initramfs values for the region. Also, add a functional test that runs during CI PR tests and makes sure the boot timer works. Signed-off-by: Babis Chalios <bchalios@amazon.es>
1 parent be5a600 commit b018e3b

File tree

3 files changed

+31
-15
lines changed

3 files changed

+31
-15
lines changed

resources/overlay/usr/local/bin/init.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// Position on the bus is defined by MMIO_LEN increments, where MMIO_LEN is
1414
// defined as 0x1000 in vmm/src/device_manager/mmio.rs.
1515
#ifdef __x86_64__
16-
#define MAGIC_MMIO_SIGNAL_GUEST_BOOT_COMPLETE 0xd0000000
16+
#define MAGIC_MMIO_SIGNAL_GUEST_BOOT_COMPLETE 0xc0000000
1717
#endif
1818
#ifdef __aarch64__
1919
#define MAGIC_MMIO_SIGNAL_GUEST_BOOT_COMPLETE 0x40000000

resources/rebuild.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ function build_initramfs {
9292

9393
# Report guest boot time back to Firecracker via MMIO
9494
# See arch/src/lib.rs and the BootTimer device
95-
MAGIC_BOOT_ADDRESS=0xd0000000
95+
MAGIC_BOOT_ADDRESS=0xc0000000
9696
if [ $ARCH = "aarch64" ]; then
9797
MAGIC_BOOT_ADDRESS=0x40000000
9898
fi

tests/integration_tests/performance/test_boottime.py

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,33 @@ def to_ms(v, unit):
9494
return kernel, userspace, total
9595

9696

97+
def launch_vm_with_boot_timer(
98+
microvm_factory, guest_kernel_acpi, rootfs_rw, vcpu_count, mem_size_mib
99+
):
100+
"""Launches a microVM with guest-timer and returns the reported metrics for it"""
101+
vm = microvm_factory.build(guest_kernel_acpi, rootfs_rw)
102+
vm.jailer.extra_args.update({"boot-timer": None})
103+
vm.spawn()
104+
vm.basic_config(
105+
vcpu_count=vcpu_count,
106+
mem_size_mib=mem_size_mib,
107+
boot_args=DEFAULT_BOOT_ARGS + " init=/usr/local/bin/init",
108+
enable_entropy_device=True,
109+
)
110+
vm.add_net_iface()
111+
vm.start()
112+
vm.pin_threads(0)
113+
114+
boot_time_us, cpu_boot_time_us = get_boottime_device_info(vm)
115+
116+
return (vm, boot_time_us, cpu_boot_time_us)
117+
118+
119+
def test_boot_timer(microvm_factory, guest_kernel_acpi, rootfs):
120+
"""Tests that the boot timer device works"""
121+
launch_vm_with_boot_timer(microvm_factory, guest_kernel_acpi, rootfs, 1, 128)
122+
123+
97124
@pytest.mark.parametrize(
98125
"vcpu_count,mem_size_mib",
99126
[(1, 128), (1, 1024), (2, 2048), (4, 4096)],
@@ -105,20 +132,9 @@ def test_boottime(
105132
"""Test boot time with different guest configurations"""
106133

107134
for i in range(10):
108-
vm = microvm_factory.build(guest_kernel_acpi, rootfs_rw)
109-
vm.jailer.extra_args.update({"boot-timer": None})
110-
vm.spawn()
111-
vm.basic_config(
112-
vcpu_count=vcpu_count,
113-
mem_size_mib=mem_size_mib,
114-
boot_args=DEFAULT_BOOT_ARGS + " init=/usr/local/bin/init",
115-
enable_entropy_device=True,
135+
vm, boot_time_us, cpu_boot_time_us = launch_vm_with_boot_timer(
136+
microvm_factory, guest_kernel_acpi, rootfs_rw, vcpu_count, mem_size_mib
116137
)
117-
vm.add_net_iface()
118-
vm.start()
119-
vm.pin_threads(0)
120-
121-
boot_time_us, cpu_boot_time_us = get_boottime_device_info(vm)
122138

123139
if i == 0:
124140
metrics.set_dimensions(

0 commit comments

Comments
 (0)