Skip to content
This repository was archived by the owner on Oct 5, 2018. It is now read-only.

Commit 4255b07

Browse files
committed
ARCv2: STAR 9000793984: Handle return from intr to Delay Slot
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
1 parent 1f6ccff commit 4255b07

File tree

3 files changed

+53
-0
lines changed

3 files changed

+53
-0
lines changed

arch/arc/kernel/asm-offsets.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ int main(void)
5656
DEFINE(PT_r5, offsetof(struct pt_regs, r5));
5757
DEFINE(PT_r6, offsetof(struct pt_regs, r6));
5858
DEFINE(PT_r7, offsetof(struct pt_regs, r7));
59+
DEFINE(PT_ret, offsetof(struct pt_regs, ret));
5960

6061
DEFINE(SZ_CALLEE_REGS, sizeof(struct callee_regs));
6162
DEFINE(SZ_PT_REGS, sizeof(struct pt_regs));

arch/arc/kernel/entry-arcv2.S

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,9 @@ END(EV_TLBProtV)
163163
;####### Return from Intr #######
164164

165165
debug_marker_l1:
166+
bbit1.nt r0, STATUS_DE_BIT, .Lintr_ret_to_delay_slot
167+
168+
.Lisr_ret_fast_path:
166169
; Handle special case #1: (Entry via Exception, Return via IRQ)
167170
;
168171
; Exception in U mode, preempted in kernel, Intr taken (K mode), orig
@@ -186,4 +189,51 @@ debug_marker_syscall:
186189
EXCEPTION_EPILOGUE
187190
rtie
188191

192+
;####### Return from Intr to insn in delay slot #######
193+
194+
; Handle special case #2: (Entry via Exception in Delay Slot, Return via IRQ)
195+
;
196+
; Intr returning to a Delay Slot (DS) insn
197+
; (since IRQ NOT allowed in DS in ARCv2, this can only happen if orig
198+
; entry was via Exception in DS which got preempted in kernel).
199+
;
200+
; IRQ RTIE won't reliably restore DE bit and/or BTA, needs handling
201+
.Lintr_ret_to_delay_slot:
202+
debug_marker_ds:
203+
204+
ld r2, [@intr_to_DE_cnt]
205+
add r2, r2, 1
206+
st r2, [@intr_to_DE_cnt]
207+
208+
ld r2, [sp, PT_ret]
209+
ld r3, [sp, PT_status32]
210+
211+
bic r0, r3, STATUS_U_MASK|STATUS_DE_MASK|STATUS_IE_MASK|STATUS_L_MASK
212+
st r0, [sp, PT_status32]
213+
214+
mov r1, .Lintr_ret_to_delay_slot_2
215+
st r1, [sp, PT_ret]
216+
217+
st r2, [sp, 0]
218+
st r3, [sp, 4]
219+
220+
b .Lisr_ret_fast_path
221+
222+
.Lintr_ret_to_delay_slot_2:
223+
sub sp, sp, SZ_PT_REGS
224+
st r9, [sp, -4]
225+
226+
ld r9, [sp, 0]
227+
sr r9, [eret]
228+
229+
ld r9, [sp, 4]
230+
sr r9, [erstatus]
231+
232+
ld r9, [sp, 8]
233+
sr r9, [erbta]
234+
235+
ld r9, [sp, -4]
236+
add sp, sp, SZ_PT_REGS
237+
rtie
238+
189239
END(ret_from_exception)

arch/arc/kernel/setup.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030

3131
#define FIX_PTR(x) __asm__ __volatile__(";" : "+r"(x))
3232

33+
unsigned int intr_to_DE_cnt;
34+
3335
/* Part of U-boot ABI: see head.S */
3436
int __initdata uboot_tag;
3537
char __initdata *uboot_arg;

0 commit comments

Comments
 (0)