Replace intrinsics::abort() call in switch_finish_hook with safer abort mechanism
abort will still run the illegal instruction interrupt handler which may not be safe.
This commit is contained in:
@@ -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));
|
||||
}
|
||||
|
||||
@@ -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")]
|
||||
|
||||
@@ -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")]
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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)]
|
||||
|
||||
Reference in New Issue
Block a user