From dbbe9d07b50895873e7be6578da4eedb558f23dc Mon Sep 17 00:00:00 2001 From: Flavio Ceolin Date: Tue, 6 Feb 2024 19:52:19 -0800 Subject: [PATCH] xtensa: userspace: Fixes in xtensa_userspace_enter - spill windows in the current context (before switching task) since it will be erased. - Remove unnucessary load/mov Signed-off-by: Flavio Ceolin --- arch/xtensa/core/userspace.S | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/arch/xtensa/core/userspace.S b/arch/xtensa/core/userspace.S index 42fe86f52e..1578e3be97 100644 --- a/arch/xtensa/core/userspace.S +++ b/arch/xtensa/core/userspace.S @@ -276,13 +276,12 @@ xtensa_userspace_enter: */ entry a1, 16 + SPILL_ALL_WINDOWS + /* We have to switch to kernel stack before spill kernel data and * erase user stack to avoid leak from previous context. */ mov a1, a7 /* stack start (low address) */ - addi a1, a1, -16 - - SPILL_ALL_WINDOWS rsr a0, ZSR_CPU l32i a0, a0, ___cpu_t_current_OFFSET @@ -329,11 +328,8 @@ xtensa_userspace_enter: l32i a8, a1, 12 l32i a9, a1, 8 - /* stash user stack */ - l32i a0, a1, 4 - /* Go back to user stack */ - mov a1, a0 + l32i a1, a1, 4 movi a0, z_thread_entry wsr.epc2 a0 @@ -352,6 +348,7 @@ xtensa_userspace_enter: wsr a0, EPS2 + /* Wipe out a0 (thre is no return from this function */ movi a0, 0 rfi 2