From e137c3853d08af9693626aca5c353f9e985da62b Mon Sep 17 00:00:00 2001 From: Alvin Chang Date: Wed, 24 Jul 2024 23:22:01 +0800 Subject: [PATCH] core: riscv: Update thread core local flags for native interrupts Record the type of stack and the type of interrupt into thread core local flags before handling the native interrupts. Once we finish the handling of the native interrupts, we clear the previous flags. Signed-off-by: Alvin Chang Reviewed-by: Yu Chien Peter Lin Acked-by: Jens Wiklander --- core/arch/riscv/kernel/thread_rv.S | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/core/arch/riscv/kernel/thread_rv.S b/core/arch/riscv/kernel/thread_rv.S index 93f18e5e918..8124973be6f 100644 --- a/core/arch/riscv/kernel/thread_rv.S +++ b/core/arch/riscv/kernel/thread_rv.S @@ -125,6 +125,12 @@ foreign_interrupt_from_kernel: tail thread_foreign_interrupt_handler native_interrupt_from_kernel: + /* Update 32-bit core local flags */ + lw a2, THREAD_CORE_LOCAL_FLAGS(tp) + slli a2, a2, THREAD_CLF_SAVED_SHIFT + ori a2, a2, (THREAD_CLF_TMP | THREAD_CLF_IRQ) + sw a2, THREAD_CORE_LOCAL_FLAGS(tp) + /* * a0 = struct thread_ctx_regs *regs * a1 = cause @@ -132,6 +138,11 @@ native_interrupt_from_kernel: */ call thread_native_interrupt_handler + /* Update 32-bit core local flags */ + lw a2, THREAD_CORE_LOCAL_FLAGS(tp) + srli a2, a2, THREAD_CLF_SAVED_SHIFT + sw a2, THREAD_CORE_LOCAL_FLAGS(tp) + /* Get thread context as sp */ get_thread_ctx sp, t0 /* Restore XEPC */ @@ -351,6 +362,12 @@ foreign_interrupt_from_user: tail thread_foreign_interrupt_handler native_interrupt_from_user: + /* Update 32-bit core local flags */ + lw a2, THREAD_CORE_LOCAL_FLAGS(tp) + slli a2, a2, THREAD_CLF_SAVED_SHIFT + ori a2, a2, (THREAD_CLF_TMP | THREAD_CLF_IRQ) + sw a2, THREAD_CORE_LOCAL_FLAGS(tp) + /* * a0 = struct thread_ctx_regs *regs * a1 = cause @@ -358,6 +375,11 @@ native_interrupt_from_user: */ call thread_native_interrupt_handler + /* Update 32-bit core local flags */ + lw a2, THREAD_CORE_LOCAL_FLAGS(tp) + srli a2, a2, THREAD_CLF_SAVED_SHIFT + sw a2, THREAD_CORE_LOCAL_FLAGS(tp) + /* Get thread context as sp */ get_thread_ctx sp, t0 /* Restore XEPC */