diff --git a/tools/examples/baremetal/src/main.rs b/tools/examples/baremetal/src/main.rs index d7e4c08b30..0b063ed0d9 100644 --- a/tools/examples/baremetal/src/main.rs +++ b/tools/examples/baremetal/src/main.rs @@ -5,7 +5,7 @@ #![no_std] // don't link the Rust standard library #![no_main] // disable all Rust-level entry points -use core::arch::global_asm; +use core::arch::{asm, global_asm}; use core::panic::PanicInfo; use log::*; @@ -15,6 +15,12 @@ global_asm!(include_str!("../src/boot.asm")); /// This function is called on panic. #[panic_handler] fn panic(_info: &PanicInfo) -> ! { + // Execute a debug breakpoint instruction to cause a VMEXIT. + // SAFETY: This instruction will exit the hosting VM, so no further Rust code will execute. + unsafe { + asm!("int3"); + } + // Just in case we are still running somehow, spin forever. loop {} }