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

Commit 0bdce40

Browse files
vineetgarcgregkh
authored andcommitted
ARCv2: STAR 9000950267: Handle return from intr to Delay Slot #2
commit cbfe74a upstream. Returning to delay slot, riding an interrupti, had one loose end. AUX_USER_SP used for restoring user mode SP upon RTIE was not being setup from orig task's saved value, causing task to use wrong SP, leading to ProtV errors. The reason being: - INTERRUPT_EPILOGUE returns to a kernel trampoline, thus not expected to restore it - EXCEPTION_EPILOGUE is not used at all Fix that by restoring AUX_USER_SP explicitly in the trampoline. This was broken in the original workaround, but the error scenarios got reduced considerably since v3.14 due to following: 1. The Linuxthreads.old based userspace at the time caused many more exceptions in delay slot than the current NPTL based one. Infact with current userspace the error doesn't happen at all. 2. Return from interrupt (delay slot or otherwise) doesn't get exercised much after commit 4de0e52 ("Really Re-enable interrupts to avoid deadlocks") since IRQ_ACTIVE.active being clear means most returns are as if from pure kernel (even for active interrupts) Infact the issue only happened in an experimental branch where I was tinkering with reverted 4de0e52 Fixes: 4255b07 ("ARCv2: STAR 9000793984: Handle return from intr to Delay Slot") Signed-off-by: Vineet Gupta <vgupta@synopsys.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent aff4514 commit 0bdce40

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

arch/arc/kernel/entry-arcv2.S

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,11 @@ debug_marker_syscall:
211211
; (since IRQ NOT allowed in DS in ARCv2, this can only happen if orig
212212
; entry was via Exception in DS which got preempted in kernel).
213213
;
214-
; IRQ RTIE won't reliably restore DE bit and/or BTA, needs handling
214+
; IRQ RTIE won't reliably restore DE bit and/or BTA, needs workaround
215+
;
216+
; Solution is return from Intr w/o any delay slot quirks into a kernel trampoline
217+
; and from pure kernel mode return to delay slot which handles DS bit/BTA correctly
218+
215219
.Lintr_ret_to_delay_slot:
216220
debug_marker_ds:
217221

@@ -222,18 +226,23 @@ debug_marker_ds:
222226
ld r2, [sp, PT_ret]
223227
ld r3, [sp, PT_status32]
224228

229+
; STAT32 for Int return created from scratch
230+
; (No delay dlot, disable Further intr in trampoline)
231+
225232
bic r0, r3, STATUS_U_MASK|STATUS_DE_MASK|STATUS_IE_MASK|STATUS_L_MASK
226233
st r0, [sp, PT_status32]
227234

228235
mov r1, .Lintr_ret_to_delay_slot_2
229236
st r1, [sp, PT_ret]
230237

238+
; Orig exception PC/STAT32 safekept @orig_r0 and @event stack slots
231239
st r2, [sp, 0]
232240
st r3, [sp, 4]
233241

234242
b .Lisr_ret_fast_path
235243

236244
.Lintr_ret_to_delay_slot_2:
245+
; Trampoline to restore orig exception PC/STAT32/BTA/AUX_USER_SP
237246
sub sp, sp, SZ_PT_REGS
238247
st r9, [sp, -4]
239248

@@ -243,11 +252,19 @@ debug_marker_ds:
243252
ld r9, [sp, 4]
244253
sr r9, [erstatus]
245254

255+
; restore AUX_USER_SP if returning to U mode
256+
bbit0 r9, STATUS_U_BIT, 1f
257+
ld r9, [sp, PT_sp]
258+
sr r9, [AUX_USER_SP]
259+
260+
1:
246261
ld r9, [sp, 8]
247262
sr r9, [erbta]
248263

249264
ld r9, [sp, -4]
250265
add sp, sp, SZ_PT_REGS
266+
267+
; return from pure kernel mode to delay slot
251268
rtie
252269

253270
END(ret_from_exception)

0 commit comments

Comments
 (0)