From 14364e09c6600b1c4bdbdd90ce213ca3b2446bd7 Mon Sep 17 00:00:00 2001 From: bunnie Date: Fri, 8 Mar 2024 18:29:10 +0800 Subject: [PATCH] ensure compliance with unsafe conditions on exit_blocking_call() --- kernel/src/arch/riscv/irq.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/kernel/src/arch/riscv/irq.rs b/kernel/src/arch/riscv/irq.rs index a3ed05b91..c3f5f1cc9 100644 --- a/kernel/src/arch/riscv/irq.rs +++ b/kernel/src/arch/riscv/irq.rs @@ -310,8 +310,10 @@ pub extern "C" fn trap_handler( RiscvException::InstructionPageFault(RETURN_FROM_SWAPPER, _offset) => { // Cleanup after the swapper - let response = - Swap::with_mut(|s| s.exit_blocking_call()).unwrap_or_else(xous_kernel::Result::Error); + let response = Swap::with_mut(|s| + // safety: this is safe because on return from swapper, we're in the swapper's memory space. + unsafe { s.exit_blocking_call() }) + .unwrap_or_else(xous_kernel::Result::Error); // Resume like we're returning from a syscall. enable_all_irqs(); ArchProcess::with_current_mut(|p| {