arch: arm64: thread: Clean thread arch when creating thread
Clean the thread->arch during the arch_new_thread to avoid unexpected behavior. If the thread struct is allocated from heap or in stack, the data in thread->arch might be dirty. Signed-off-by: Jaxson Han <jaxson.han@arm.com>
This commit is contained in:
parent
c57fa2c231
commit
1ac3d1cc5e
1 changed files with 6 additions and 3 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue