diff --git a/arch/xtensa/core/thread.c b/arch/xtensa/core/thread.c index 2bf1a7e11d3..80ddf16363c 100644 --- a/arch/xtensa/core/thread.c +++ b/arch/xtensa/core/thread.c @@ -120,6 +120,10 @@ void arch_new_thread(struct k_thread *thread, k_thread_stack_t *stack, { thread->switch_handle = init_stack(thread, (int *)stack_ptr, entry, p1, p2, p3); +#ifdef CONFIG_XTENSA_LAZY_HIFI_SHARING + memset(thread->arch.hifi_regs, 0, sizeof(thread->arch.hifi_regs)); +#endif /* CONFIG_XTENSA_LAZY_HIFI_SHARING */ + #ifdef CONFIG_KERNEL_COHERENCE __ASSERT((((size_t)stack) % XCHAL_DCACHE_LINESIZE) == 0, ""); __ASSERT((((size_t)stack_ptr) % XCHAL_DCACHE_LINESIZE) == 0, ""); diff --git a/include/zephyr/arch/xtensa/thread.h b/include/zephyr/arch/xtensa/thread.h index 0b5112fb6d9..489dece8c53 100644 --- a/include/zephyr/arch/xtensa/thread.h +++ b/include/zephyr/arch/xtensa/thread.h @@ -14,6 +14,10 @@ #include #endif +#ifdef CONFIG_XTENSA_LAZY_HIFI_SHARING +#include +#endif + /* Xtensa doesn't use these structs, but Zephyr core requires they be * defined so they can be included in struct _thread_base. Dummy * field exists for sizeof compatibility with C++. @@ -48,6 +52,11 @@ struct _thread_arch { */ uint32_t return_ps; #endif + +#ifdef CONFIG_XTENSA_LAZY_HIFI_SHARING + /* A non-BSA region is required for lazy save/restore */ + uint8_t hifi_regs[XCHAL_CP1_SA_SIZE] __aligned(XCHAL_CP1_SA_ALIGN); +#endif }; typedef struct _thread_arch _thread_arch_t;