From 6e66603da5cd936a1dc5b14ca42970c26b590310 Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Sat, 17 Dec 2022 04:10:06 +0800 Subject: [PATCH] arch/sim: Disable interrupt in up_interrupt_context for SMP like other arch to fix the race condition Signed-off-by: Xiang Xiao --- arch/sim/include/irq.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/arch/sim/include/irq.h b/arch/sim/include/irq.h index 94c1b9bb2a..5d1b343f81 100644 --- a/arch/sim/include/irq.h +++ b/arch/sim/include/irq.h @@ -146,7 +146,17 @@ static inline uintptr_t up_getsp(void) static inline bool up_interrupt_context(void) { - 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; } #undef EXTERN