From 5b92dd9874729e1f558f01065a28146c58cb1618 Mon Sep 17 00:00:00 2001 From: Sean Cross Date: Mon, 10 May 2021 14:15:47 +0800 Subject: [PATCH] kernel: services: use exception stack for kernel interrupts When the kernel is processing an interrupt, use the exception stack. This ensures that the kernel interrupt handler can switch processes without having its stack go away. This is used for debug information. Signed-off-by: Sean Cross --- kernel/src/services.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/kernel/src/services.rs b/kernel/src/services.rs index f46e09d7c..58bf789aa 100644 --- a/kernel/src/services.rs +++ b/kernel/src/services.rs @@ -527,7 +527,11 @@ impl SystemServices { // function returns, it will jump to the RETURN_FROM_ISR address, // causing an instruction fault and exiting the interrupt. ArchProcess::with_current_mut(|arch_process| { - let sp = arch_process.current_thread().stack_pointer(); + let sp = if pid.get() == 1 { + arch::mem::EXCEPTION_STACK_TOP + } else { + arch_process.current_thread().stack_pointer() + }; // Activate the current context arch_process.set_thread(arch::process::IRQ_TID).unwrap();