Skip to content
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

fix(x86_64): shutdown using triple fault on all platforms #1181

Merged
merged 1 commit into from
May 13, 2024
Merged
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
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