mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2024-11-28 17:44:10 +00:00
examples/baremetal: exit instead of hanging
Use an INT3 (0xCC) instruction to cause the example to exit after printing the message. This is more convenient than having to manually kill crosvm from another terminal. BUG=None TEST=Run baremetal and observe that it exits Change-Id: I4baeecca41d156c82bb1e1b27d0f8c2ba93959f9 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3691966 Reviewed-by: Anton Romanov <romanton@google.com> Reviewed-by: Alexandre Courbot <acourbot@chromium.org> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
parent
bf7d3bd38f
commit
9fde8f499a
1 changed files with 7 additions and 1 deletions
|
@ -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 {}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue