diff --git a/arch/arm64/src/common/arm64_syscall.c b/arch/arm64/src/common/arm64_syscall.c index 4ada7b2288a..d7d0a66a03e 100644 --- a/arch/arm64/src/common/arm64_syscall.c +++ b/arch/arm64/src/common/arm64_syscall.c @@ -192,7 +192,11 @@ uint64_t *arm64_syscall(uint64_t *regs) /* Restore the cpu lock */ restore_critical_section(tcb, cpu); +#ifdef CONFIG_ARCH_ADDRENV + addrenv_switch(tcb); +#endif break; + case SYS_switch_context: /* Update scheduler parameters */ @@ -204,6 +208,9 @@ uint64_t *arm64_syscall(uint64_t *regs) /* Restore the cpu lock */ restore_critical_section(tcb, cpu); +#ifdef CONFIG_ARCH_ADDRENV + addrenv_switch(tcb); +#endif break; #ifdef CONFIG_BUILD_KERNEL @@ -315,18 +322,5 @@ uint64_t *arm64_syscall(uint64_t *regs) break; } -#ifdef CONFIG_ARCH_ADDRENV - /* Make sure that the address environment for the previously - * running task is closed down gracefully (data caches dump, - * MMU flushed) and set up the address environment for the new - * thread at the head of the ready-to-run list. - */ - - if (SYS_restore_context == cmd || SYS_switch_context == cmd) - { - addrenv_switch(NULL); - } -#endif - return tcb->xcp.regs; }