Skip to content

Commit 6468178

Browse files
Marc Zyngierctmarinas
authored andcommitted
arm64: let the core code deal with preempt_count
Commit f27dde8 (sched: Add NEED_RESCHED to the preempt_count) introduced the use of bit 31 in preempt_count for obscure scheduling purposes. This causes interrupts taken from EL0 to hit the (open coded) BUG when this flag is flipped while handling the interrupt (we compare the values before and after, and kill the kernel if they are different). The fix is to stop messing with the preempt count entirely, as this is already being dealt with in the generic code (irq_enter/irq_exit). Tested on a dual A53 FPGA running cyclictest. Signed-off-by: Marc Zyngier <marc.zyngier@arm.com> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
1 parent 6ce4eac commit 6468178

File tree

1 file changed

+7
-22
lines changed

1 file changed

+7
-22
lines changed

arch/arm64/kernel/entry.S

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -309,15 +309,12 @@ el1_irq:
309309
#ifdef CONFIG_TRACE_IRQFLAGS
310310
bl trace_hardirqs_off
311311
#endif
312-
#ifdef CONFIG_PREEMPT
313-
get_thread_info tsk
314-
ldr w24, [tsk, #TI_PREEMPT] // get preempt count
315-
add w0, w24, #1 // increment it
316-
str w0, [tsk, #TI_PREEMPT]
317-
#endif
312+
318313
irq_handler
314+
319315
#ifdef CONFIG_PREEMPT
320-
str w24, [tsk, #TI_PREEMPT] // restore preempt count
316+
get_thread_info tsk
317+
ldr w24, [tsk, #TI_PREEMPT] // restore preempt count
321318
cbnz w24, 1f // preempt count != 0
322319
ldr x0, [tsk, #TI_FLAGS] // get flags
323320
tbz x0, #TIF_NEED_RESCHED, 1f // needs rescheduling?
@@ -507,22 +504,10 @@ el0_irq_naked:
507504
#ifdef CONFIG_TRACE_IRQFLAGS
508505
bl trace_hardirqs_off
509506
#endif
510-
get_thread_info tsk
511-
#ifdef CONFIG_PREEMPT
512-
ldr w24, [tsk, #TI_PREEMPT] // get preempt count
513-
add w23, w24, #1 // increment it
514-
str w23, [tsk, #TI_PREEMPT]
515-
#endif
507+
516508
irq_handler
517-
#ifdef CONFIG_PREEMPT
518-
ldr w0, [tsk, #TI_PREEMPT]
519-
str w24, [tsk, #TI_PREEMPT]
520-
cmp w0, w23
521-
b.eq 1f
522-
mov x1, #0
523-
str x1, [x1] // BUG
524-
1:
525-
#endif
509+
get_thread_info tsk
510+
526511
#ifdef CONFIG_TRACE_IRQFLAGS
527512
bl trace_hardirqs_on
528513
#endif

0 commit comments

Comments
 (0)