Skip to content

Commit 05a669c

Browse files
Wayne Renandrewboie
authored andcommitted
arch: arc: fix the bug where regular irq comes out in user mode
if USERSPACE is configured, it needs to record the user/kernel mode of interrupted thread, because the switch of aux_sec_k_sp/aux_user_sp depends on the aux_irq_act's U bit. Signed-off-by: Wayne Ren <[email protected]>
1 parent d1f1572 commit 05a669c

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

arch/arc/core/regular_irq.S

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,15 @@ _rirq_reschedule:
303303
lr r3, [_ARC_V2_SEC_STAT]
304304
push_s r3
305305
#endif
306+
307+
#if defined(CONFIG_USERSPACE)
308+
/*
309+
* need to remember the user/kernel status of interrupted thread
310+
*/
311+
lr r3, [_ARC_V2_AUX_IRQ_ACT]
312+
and r3, r3, 0x80000000
313+
push_s r3
314+
#endif
306315
/* _save_callee_saved_regs expects outgoing thread in r2 */
307316
_save_callee_saved_regs
308317

@@ -400,6 +409,15 @@ _rirq_return_from_coop:
400409
.balign 4
401410
_rirq_return_from_firq:
402411
_rirq_return_from_rirq:
412+
#if defined(CONFIG_USERSPACE)
413+
/*
414+
* need to recover the user/kernel status of interrupted thread
415+
*/
416+
pop_s r3
417+
lr r2, [_ARC_V2_AUX_IRQ_ACT]
418+
or r2, r2, r3
419+
sr r2, [_ARC_V2_AUX_IRQ_ACT]
420+
#endif
403421
#ifdef CONFIG_ARC_SECURE_FIRMWARE
404422
/* here need to recover SEC_STAT.IRM bit */
405423
pop_s r3

arch/arc/core/switch.S

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,16 @@ return_loc:
162162
_switch_return_from_rirq:
163163
_switch_return_from_firq:
164164

165+
#if defined(CONFIG_USERSPACE)
166+
/*
167+
* need to recover the user/kernel status of interrupted thread
168+
*/
169+
pop_s r3
170+
lr r2, [_ARC_V2_AUX_IRQ_ACT]
171+
or r2, r2, r3
172+
sr r2, [_ARC_V2_AUX_IRQ_ACT]
173+
#endif
174+
165175
#ifdef CONFIG_ARC_SECURE_FIRMWARE
166176
/* here need to recover SEC_STAT.IRM bit */
167177
pop_s r3

0 commit comments

Comments
 (0)