From e8ec8fb4b41d2fbe23accf3591b637a195d218fe Mon Sep 17 00:00:00 2001 From: Masayuki Ishikawa Date: Tue, 29 Sep 2020 08:25:20 +0900 Subject: [PATCH] arch: risc-v: Fix up_interrupt_context() for SMP Summary: - Apply the same fix for Arm SMP Impact: - Affects SMP only Testing: - Tested with maix-bit:smp (qemu) Signed-off-by: Masayuki Ishikawa --- arch/risc-v/src/common/riscv_interruptcontext.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/arch/risc-v/src/common/riscv_interruptcontext.c b/arch/risc-v/src/common/riscv_interruptcontext.c index c5980d74e3f..631f8092dda 100644 --- a/arch/risc-v/src/common/riscv_interruptcontext.c +++ b/arch/risc-v/src/common/riscv_interruptcontext.c @@ -67,7 +67,17 @@ bool up_interrupt_context(void) { #ifdef CONFIG_ARCH_RV64GC - return CURRENT_REGS != NULL; +#ifdef CONFIG_SMP + irqstate_t flags = up_irq_save(); +#endif + + bool ret = CURRENT_REGS != NULL; + +#ifdef CONFIG_SMP + up_irq_restore(flags); +#endif + + return ret; #else return g_current_regs != NULL; #endif