Skip to content

fix: boottimer device MMIO address #5249

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion resources/overlay/usr/local/bin/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// Position on the bus is defined by MMIO_LEN increments, where MMIO_LEN is
// defined as 0x1000 in vmm/src/device_manager/mmio.rs.
#ifdef __x86_64__
#define MAGIC_MMIO_SIGNAL_GUEST_BOOT_COMPLETE 0xd0000000
#define MAGIC_MMIO_SIGNAL_GUEST_BOOT_COMPLETE 0xc0000000
#endif
#ifdef __aarch64__
#define MAGIC_MMIO_SIGNAL_GUEST_BOOT_COMPLETE 0x40000000
Expand Down
2 changes: 1 addition & 1 deletion resources/rebuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ function build_initramfs {

# Report guest boot time back to Firecracker via MMIO
# See arch/src/lib.rs and the BootTimer device
MAGIC_BOOT_ADDRESS=0xd0000000
MAGIC_BOOT_ADDRESS=0xc0000000
if [ $ARCH = "aarch64" ]; then
MAGIC_BOOT_ADDRESS=0x40000000
fi
Expand Down
42 changes: 29 additions & 13 deletions tests/integration_tests/performance/test_boottime.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,33 @@ def to_ms(v, unit):
return kernel, userspace, total


def launch_vm_with_boot_timer(
microvm_factory, guest_kernel_acpi, rootfs_rw, vcpu_count, mem_size_mib
):
"""Launches a microVM with guest-timer and returns the reported metrics for it"""
vm = microvm_factory.build(guest_kernel_acpi, rootfs_rw)
vm.jailer.extra_args.update({"boot-timer": None})
vm.spawn()
vm.basic_config(
vcpu_count=vcpu_count,
mem_size_mib=mem_size_mib,
boot_args=DEFAULT_BOOT_ARGS + " init=/usr/local/bin/init",
enable_entropy_device=True,
)
vm.add_net_iface()
vm.start()
vm.pin_threads(0)

boot_time_us, cpu_boot_time_us = get_boottime_device_info(vm)

return (vm, boot_time_us, cpu_boot_time_us)


def test_boot_timer(microvm_factory, guest_kernel_acpi, rootfs):
"""Tests that the boot timer device works"""
launch_vm_with_boot_timer(microvm_factory, guest_kernel_acpi, rootfs, 1, 128)


@pytest.mark.parametrize(
"vcpu_count,mem_size_mib",
[(1, 128), (1, 1024), (2, 2048), (4, 4096)],
Expand All @@ -105,20 +132,9 @@ def test_boottime(
"""Test boot time with different guest configurations"""

for i in range(10):
vm = microvm_factory.build(guest_kernel_acpi, rootfs_rw)
vm.jailer.extra_args.update({"boot-timer": None})
vm.spawn()
vm.basic_config(
vcpu_count=vcpu_count,
mem_size_mib=mem_size_mib,
boot_args=DEFAULT_BOOT_ARGS + " init=/usr/local/bin/init",
enable_entropy_device=True,
vm, boot_time_us, cpu_boot_time_us = launch_vm_with_boot_timer(
microvm_factory, guest_kernel_acpi, rootfs_rw, vcpu_count, mem_size_mib
)
vm.add_net_iface()
vm.start()
vm.pin_threads(0)

boot_time_us, cpu_boot_time_us = get_boottime_device_info(vm)

if i == 0:
metrics.set_dimensions(
Expand Down