reason:
svc call may trigger hardfalt

Signed-off-by: hujun5 <hujun5@xiaomi.com>
This commit is contained in:
hujun5 2024-12-06 21:29:08 +08:00 committed by Xiang Xiao
parent d368c0cc04
commit 702affa63b
3 changed files with 12 additions and 2 deletions

View file

@ -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;
}

View file

@ -165,6 +165,7 @@ retry:
rtcb->irqcount--;
#endif
g_running_tasks[this_cpu()] = NULL;
rtcb->xcp.regs = rtcb->xcp.saved_regs;
arm_fullcontextrestore();
UNUSED(regs);

View file

@ -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 */