Skip to content

Commit

Permalink
fix(x86_64): shutdown using triple fault on all platforms
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Kröning <[email protected]>
  • Loading branch information
mkroening committed May 7, 2024
1 parent 6d228aa commit 02dfb18
Showing 1 changed file with 7 additions and 15 deletions.
22 changes: 7 additions & 15 deletions src/arch/x86_64/kernel/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1013,7 +1013,7 @@ pub fn halt() {
///
/// Triple faults cause CPU resets.
/// On KVM, this results in `KVM_EXIT_SHUTDOWN`.
/// This is the preferred way of shutting down the CPU on firecracker.
/// This is the preferred way of shutting down the CPU on firecracker and in QEMU's `microvm` virtual platform.
///
/// See [Triple Faulting the CPU](http://www.rcollins.org/Productivity/TripleFault.html).
fn triple_fault() -> ! {
Expand All @@ -1035,22 +1035,14 @@ fn qemu_exit(success: bool) {

/// Shutdown the system
pub fn shutdown(error_code: i32) -> ! {
match boot_info().platform_info {
PlatformInfo::LinuxBootParams { .. } => triple_fault(),
PlatformInfo::Uhyve { .. } => unreachable!(),
_ => {
qemu_exit(error_code == 0);

#[cfg(feature = "acpi")]
{
acpi::poweroff();
}
qemu_exit(error_code == 0);

loop {
halt();
}
}
#[cfg(feature = "acpi")]
{
acpi::poweroff();
}

triple_fault()
}

pub fn get_timer_ticks() -> u64 {
Expand Down

0 comments on commit 02dfb18

Please sign in to comment.