diff --git a/src/arch/aarch64/stop.rs b/src/arch/aarch64/stop.rs index 90f55227f13a2f37409edd679da920f87d8dc295..6f12001777869276ba1b32761c757a029f8514bd 100644 --- a/src/arch/aarch64/stop.rs +++ b/src/arch/aarch64/stop.rs @@ -6,9 +6,13 @@ pub unsafe extern fn kreset() -> ! { let val: u32 = 0x8400_0009; asm!("mov x0, {}", in(reg) val); - asm!("hvc #0"); + asm!("hvc #0", options(noreturn)); +} - unreachable!(); +pub unsafe fn emergency_reset() -> ! { + let val: u32 = 0x8400_0009; + asm!("mov x0, {}", in(reg) val); + asm!("hvc #0", options(noreturn)); } #[no_mangle] @@ -17,7 +21,5 @@ pub unsafe extern fn kstop() -> ! { let val: u32 = 0x8400_0008; asm!("mov x0, {}", in(reg) val); - asm!("hvc #0"); - - unreachable!(); + asm!("hvc #0", options(noreturn)); } diff --git a/src/arch/x86/stop.rs b/src/arch/x86/stop.rs index 38aaef8739f5fe06695ae67c3911b0c25d93cd69..246d1ddde21833fd124292ffead65cae27bceb43 100644 --- a/src/arch/x86/stop.rs +++ b/src/arch/x86/stop.rs @@ -19,14 +19,16 @@ pub unsafe extern fn kreset() -> ! { port.write(0xFE); } + emergency_reset(); +} + +pub unsafe fn emergency_reset() -> ! { // Use triple fault to guarantee reset core::arch::asm!(" cli lidt cs:0 int $3 - "); - - unreachable!(); + ", options(noreturn)); } #[cfg(feature = "acpi")] diff --git a/src/arch/x86_64/stop.rs b/src/arch/x86_64/stop.rs index 38aaef8739f5fe06695ae67c3911b0c25d93cd69..246d1ddde21833fd124292ffead65cae27bceb43 100644 --- a/src/arch/x86_64/stop.rs +++ b/src/arch/x86_64/stop.rs @@ -19,14 +19,16 @@ pub unsafe extern fn kreset() -> ! { port.write(0xFE); } + emergency_reset(); +} + +pub unsafe fn emergency_reset() -> ! { // Use triple fault to guarantee reset core::arch::asm!(" cli lidt cs:0 int $3 - "); - - unreachable!(); + ", options(noreturn)); } #[cfg(feature = "acpi")] diff --git a/src/context/switch.rs b/src/context/switch.rs index 5d3a4d1803273f1ea89d45c3f959dfc8499e8427..bca5f7aca52c4f6fdd7436cf7cbf53da26f13ea1 100644 --- a/src/context/switch.rs +++ b/src/context/switch.rs @@ -97,7 +97,7 @@ pub unsafe extern "C" fn switch_finish_hook() { next_lock.force_write_unlock(); } else { // TODO: unreachable_unchecked()? - core::intrinsics::abort(); + crate::arch::stop::emergency_reset(); } arch::CONTEXT_SWITCH_LOCK.store(false, Ordering::SeqCst); } diff --git a/src/lib.rs b/src/lib.rs index ec53c4e479cd80a71b515c932fb2c09d650d938c..3be0afc1132c271abe0a65e8dc2b09f9eed088e3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -47,7 +47,6 @@ #![feature(array_chunks)] #![feature(iter_array_chunks)] #![feature(asm_const)] // TODO: Relax requirements of most asm invocations -#![feature(core_intrinsics)] #![feature(int_roundings)] #![feature(naked_functions)] #![feature(slice_ptr_get, slice_ptr_len)]