From 0d794815403224d6942e72a576e6c8694f524e01 Mon Sep 17 00:00:00 2001 From: Daniel Leung Date: Wed, 30 Aug 2023 15:36:21 -0700 Subject: [PATCH] xtensa: userspace: only write 0xAA to stack if INIT_STACKS Only clear the user stack to 0xAA if CONFIG_INIT_STACKS is enabled. Otherwise, write 0x00 as if the stack is in BSS. Signed-off-by: Daniel Leung --- arch/xtensa/core/xtensa_mmu.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/xtensa/core/xtensa_mmu.c b/arch/xtensa/core/xtensa_mmu.c index eba89c970ad..2130a870e77 100644 --- a/arch/xtensa/core/xtensa_mmu.c +++ b/arch/xtensa/core/xtensa_mmu.c @@ -1057,8 +1057,9 @@ static inline int reset_region(uint32_t *ptables, uintptr_t start, size_t size, void xtensa_user_stack_perms(struct k_thread *thread) { - (void)memset((void *)thread->stack_info.start, 0xAA, - thread->stack_info.size - thread->stack_info.delta); + (void)memset((void *)thread->stack_info.start, + (IS_ENABLED(CONFIG_INIT_STACKS)) ? 0xAA : 0x00, + thread->stack_info.size - thread->stack_info.delta); update_region(thread_page_tables_get(thread), thread->stack_info.start, thread->stack_info.size,