diff --git a/arch/arm64/core/thread.c b/arch/arm64/core/thread.c index e8902d505e7..a0e604ef979 100644 --- a/arch/arm64/core/thread.c +++ b/arch/arm64/core/thread.c @@ -69,6 +69,12 @@ void arch_new_thread(struct k_thread *thread, k_thread_stack_t *stack, extern void z_arm64_exit_exc(void); z_arch_esf_t *pInitCtx; + /* + * Clean the thread->arch to avoid unexpected behavior because the + * thread->arch might be dirty + */ + memset(&thread->arch, 0, sizeof(thread->arch)); + /* * The ESF is now hosted at the top of the stack. For user threads this * is also fine because at this stage they are still running in EL1. @@ -100,9 +106,6 @@ void arch_new_thread(struct k_thread *thread, k_thread_stack_t *stack, pInitCtx->elr = (uint64_t)z_thread_entry; } -#if defined(CONFIG_ARM_MPU) - atomic_clear(&thread->arch.flushing); -#endif #else pInitCtx->elr = (uint64_t)z_thread_entry; #endif