Skip to content

Commit

Permalink
armv6m: fix regresion from #14881
Browse files Browse the repository at this point in the history
reason:
svc call may trigger hardfalt

Signed-off-by: hujun5 <[email protected]>
  • Loading branch information
hujun260 authored and xiaoxiang781216 committed Dec 9, 2024
1 parent 001a663 commit d20189b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion arch/arm/src/armv6-m/arm_doirq.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ uint32_t *arm_doirq(int irq, uint32_t *regs)
* is invalid, and we can safely overwrite it.
*/

if (!(NVIC_IRQ_SVCALL == irq && regs[REG_R0] == SYS_restore_context))
if (*running_task != NULL)
{
tcb->xcp.regs = regs;
}
Expand Down
1 change: 1 addition & 0 deletions arch/arm/src/armv6-m/arm_sigdeliver.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ void arm_sigdeliver(void)
rtcb->irqcount--;
#endif

g_running_tasks[this_cpu()] = NULL;
rtcb->xcp.regs = rtcb->xcp.saved_regs;
arm_fullcontextrestore();
UNUSED(regs);
Expand Down
11 changes: 10 additions & 1 deletion arch/arm/src/common/arm_exit.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,18 @@ void up_exit(int status)

nxtask_exit();

/* Scheduler parameters will update inside syscall */
/* Update g_running_tasks */

#ifdef CONFIG_ARCH_ARMV6M
/* ARMV6M syscal may trigger hard fault, We use
* running_task != NULL to determine whether it is
* a context for restoration.
*/

g_running_tasks[this_cpu()] = NULL;
#else
g_running_tasks[this_cpu()] = this_task();
#endif

/* Then switch contexts */

Expand Down

0 comments on commit d20189b

Please sign in to comment.