Skip to content
Permalink
Browse files

arch: arc: fix the bug caused by hardware sp switch in interrupt

* if thread switchs in interrupt, the target sp must be in
thread's kernel stack, no need to do hardware sp switch

Signed-off-by: Wayne Ren <wei.ren@synopsys.com>
  • Loading branch information...
vonhust authored and andrewboie committed Jul 1, 2019
1 parent ace11bb commit 4f2e873454f12f7a6291a9b829decdf0b682ebd5
Showing with 24 additions and 0 deletions.
  1. +8 −0 arch/arc/core/fast_irq.S
  2. +16 −0 arch/arc/core/regular_irq.S
@@ -238,6 +238,14 @@ _firq_reschedule:
pop_s r2
#endif

#if defined(CONFIG_USERSPACE)
/*
* see comments in regular_irq.S
*/
lr r0, [_ARC_V2_AUX_IRQ_ACT]
bclr r0, r0, 31
sr r0, [_ARC_V2_AUX_IRQ_ACT]
#endif
ld r3, [r2, _thread_offset_to_relinquish_cause]

breq r3, _CAUSE_RIRQ, _firq_return_from_rirq
@@ -181,6 +181,22 @@ _rirq_common_interrupt_swap:
pop_s r2
#endif

#if defined(CONFIG_USERSPACE)
/*
* when USERSPACE is enabled, according to ARCv2 ISA, SP will be switched
* if interrupt comes out in user mode, and will be recorded in bit 31
* (U bit) of IRQ_ACT. when interrupt exits, SP will be switched back
* according to U bit.
*
* For the case that context switches in interrupt, the target sp must be
* thread's kernel stack, no need to do hardware sp switch. so, U bit should
* be cleared.
*/
lr r0, [_ARC_V2_AUX_IRQ_ACT]
bclr r0, r0, 31
sr r0, [_ARC_V2_AUX_IRQ_ACT]
#endif

ld r3, [r2, _thread_offset_to_relinquish_cause]

breq r3, _CAUSE_RIRQ, _rirq_return_from_rirq

0 comments on commit 4f2e873

Please sign in to comment.
You can’t perform that action at this time.