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:
bjorn3
2023-07-04 19:13:53 +02:00
parent 7500ffaa5a
commit e73e42be66
5 changed files with 18 additions and 13 deletions
+7 -5
View File
@@ -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));
}
+5 -3
View File
@@ -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")]
+5 -3
View File
@@ -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")]
+1 -1
View File
@@ -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);
}
-1
View File
@@ -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)]