Skip to content

Commit 1f07b5b

Browse files
dcpleungcfriedt
authored andcommitted
xtensa: userspace: save PS to thread struct later
This is simply done to conserve code space in the vector text areas. These vector text areas are very small and we should only put code that is absolutely necessary for interrupt and exception entrance. The saving of PS into the thread struct can be deferred a bit. So do that. Signed-off-by: Daniel Leung <daniel.leung@intel.com>
1 parent 4709e3f commit 1f07b5b

File tree

1 file changed

+26
-15
lines changed

1 file changed

+26
-15
lines changed

arch/xtensa/include/xtensa_asm2.inc.S

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,29 @@ _xstack_returned_\@:
431431
*/
432432
s32i a2, a1, ___xtensa_irq_bsa_t_scratch_OFFSET
433433

434+
#ifdef CONFIG_USERSPACE
435+
/* When restoring context via xtensa_switch and
436+
* returning from non-nested interrupts, we will be
437+
* using the stashed PS value in the thread struct
438+
* instead of the one in the thread stack. Both of
439+
* these scenarios will have nested value of 0.
440+
* So when nested value is zero, we store the PS
441+
* value into thread struct.
442+
*/
443+
rsr.ZSR_CPU a0
444+
l32i a2, a0, ___cpu_t_nested_OFFSET
445+
bnez a2, _excint_skip_ps_save_to_thread
446+
447+
l32i a2, a0, ___cpu_t_current_OFFSET
448+
s32i a3, a2, _thread_offset_to_return_ps
449+
450+
_excint_skip_ps_save_to_thread:
451+
/* DEF_EXCINT saved PS into A3 so we need to restore
452+
* A3 here before proceeding.
453+
*/
454+
l32i a3, a1, ___xtensa_irq_bsa_t_a3_OFFSET
455+
#endif
456+
434457
ODD_REG_SAVE a0, a1
435458

436459
#if XCHAL_HAVE_FP && defined(CONFIG_CPU_HAS_FPU) && defined(CONFIG_FPU_SHARING)
@@ -740,22 +763,10 @@ _not_triple_fault:
740763
.endif
741764

742765
#ifdef CONFIG_USERSPACE
743-
/* When restoring context via xtensa_switch and
744-
* returning from non-nested interrupts, we will be
745-
* using the stashed PS value in the thread struct
746-
* instead of the one in the thread stack. Both of
747-
* these scenarios will have nested value of 0.
748-
* So when nested value is zero, we store the PS
749-
* value into thread struct.
766+
/* Stash the PS into A3 so EXCINT_HANDLER can read this
767+
* and save it into thread struct if needed.
750768
*/
751-
rsr.ZSR_CPU a3
752-
l32i a2, a3, ___cpu_t_nested_OFFSET
753-
bnez a2, _excint_skip_ps_save_to_thread_\LVL
754-
755-
l32i a2, a3, ___cpu_t_current_OFFSET
756-
s32i a0, a2, _thread_offset_to_return_ps
757-
758-
_excint_skip_ps_save_to_thread_\LVL:
769+
mov a3, a0
759770
#endif
760771

761772
rsr.epc\LVL a0

0 commit comments

Comments
 (0)