Skip to content

Commit

Permalink
Merge pull request #1181 from hermit-os/triple-fault
Browse files Browse the repository at this point in the history
fix(x86_64): shutdown using triple fault on all platforms
  • Loading branch information
stlankes authored May 13, 2024
2 parents 0eb96c0 + 02dfb18 commit 6a028b3
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 6a028b3

Please sign in to comment.