diff options
author | Will Deacon <will.deacon@arm.com> | 2010-11-28 09:57:24 -0500 |
---|---|---|
committer | Will Deacon <will.deacon@arm.com> | 2010-12-06 06:55:56 -0500 |
commit | 7e20269647169e7ea08a62bdc4979a3ba32e615c (patch) | |
tree | b66a6c5e893a34ee9659403f66f44841dfb34232 /arch/arm/kernel/entry-armv.S | |
parent | 6ee33c2712fcdff2568d9bbadb25c8e5a7c36212 (diff) |
ARM: hw_breakpoint: disable preemption during debug exception handling
On ARM, debug exceptions occur in the form of data or prefetch aborts.
One difference is that debug exceptions require access to per-cpu banked
registers and data structures which are not saved in the low-level exception
code. For kernels built with CONFIG_PREEMPT, there is an unlikely scenario
that the debug handler ends up running on a different CPU from the one
that originally signalled the event, resulting in random data being read
from the wrong registers.
This patch adds a debug_entry macro to the low-level exception handling
code which checks whether the taken exception is a debug exception. If
it is, the preempt count for the faulting process is incremented. After
the debug handler has finished, the count is decremented.
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Diffstat (limited to 'arch/arm/kernel/entry-armv.S')
-rw-r--r-- | arch/arm/kernel/entry-armv.S | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S index c09e3573c5de..34bbef0d2e7e 100644 --- a/arch/arm/kernel/entry-armv.S +++ b/arch/arm/kernel/entry-armv.S | |||
@@ -198,6 +198,7 @@ __dabt_svc: | |||
198 | @ | 198 | @ |
199 | @ set desired IRQ state, then call main handler | 199 | @ set desired IRQ state, then call main handler |
200 | @ | 200 | @ |
201 | debug_entry r1 | ||
201 | msr cpsr_c, r9 | 202 | msr cpsr_c, r9 |
202 | mov r2, sp | 203 | mov r2, sp |
203 | bl do_DataAbort | 204 | bl do_DataAbort |
@@ -324,6 +325,7 @@ __pabt_svc: | |||
324 | #else | 325 | #else |
325 | bl CPU_PABORT_HANDLER | 326 | bl CPU_PABORT_HANDLER |
326 | #endif | 327 | #endif |
328 | debug_entry r1 | ||
327 | msr cpsr_c, r9 @ Maybe enable interrupts | 329 | msr cpsr_c, r9 @ Maybe enable interrupts |
328 | mov r2, sp @ regs | 330 | mov r2, sp @ regs |
329 | bl do_PrefetchAbort @ call abort handler | 331 | bl do_PrefetchAbort @ call abort handler |
@@ -439,6 +441,7 @@ __dabt_usr: | |||
439 | @ | 441 | @ |
440 | @ IRQs on, then call the main handler | 442 | @ IRQs on, then call the main handler |
441 | @ | 443 | @ |
444 | debug_entry r1 | ||
442 | enable_irq | 445 | enable_irq |
443 | mov r2, sp | 446 | mov r2, sp |
444 | adr lr, BSYM(ret_from_exception) | 447 | adr lr, BSYM(ret_from_exception) |
@@ -703,6 +706,7 @@ __pabt_usr: | |||
703 | #else | 706 | #else |
704 | bl CPU_PABORT_HANDLER | 707 | bl CPU_PABORT_HANDLER |
705 | #endif | 708 | #endif |
709 | debug_entry r1 | ||
706 | enable_irq @ Enable interrupts | 710 | enable_irq @ Enable interrupts |
707 | mov r2, sp @ regs | 711 | mov r2, sp @ regs |
708 | bl do_PrefetchAbort @ call abort handler | 712 | bl do_PrefetchAbort @ call abort handler |