From 02dfb187b1b6a17a6f4d06f993eb78d8c4b8c68c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Kr=C3=B6ning?= Date: Tue, 7 May 2024 17:21:31 +0200 Subject: [PATCH] fix(x86_64): shutdown using triple fault on all platforms MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Kröning --- src/arch/x86_64/kernel/processor.rs | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/src/arch/x86_64/kernel/processor.rs b/src/arch/x86_64/kernel/processor.rs index 522f333bbb..1c6afcbcf8 100644 --- a/src/arch/x86_64/kernel/processor.rs +++ b/src/arch/x86_64/kernel/processor.rs @@ -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() -> ! { @@ -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 {