Skip to content

Commit 1417a6b

Browse files
ctmarinasRussell King
authored andcommitted
ARM: 8036/1: Enable IRQs before attempting to read user space in __und_usr
The Undef abort handler in the kernel reads the undefined instruction from user space. If the page table was modified from another CPU, the user access could fail and do_page_fault() will be executed with interrupts disabled. This can potentially deadlock on ARM11MPCore or on Cortex-A15 with erratum 798181 workaround enabled (both implying IPI for TLB maintenance with page table lock held). This patch enables the IRQs in __und_usr before attempting to read the instruction from user space. Signed-off-by: Catalin Marinas <catalin.marinas@arm.com> Tested-by: Arun KS <getarunks@gmail.com> Cc: Hartley Sweeten <hsweeten@visionengravers.com> Cc: Ryan Mallon <rmallon@gmail.com> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
1 parent bc94081 commit 1417a6b

4 files changed

Lines changed: 10 additions & 8 deletions

File tree

‎arch/arm/kernel/entry-armv.S‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,11 @@ __und_usr:
413413
@
414414
adr r9, BSYM(ret_from_exception)
415415

416+
@ IRQs must be enabled before attempting to read the instruction from
417+
@ user space since that could cause a page/translation fault if the
418+
@ page table was modified by another CPU.
419+
enable_irq
420+
416421
tst r3, #PSR_T_BIT @ Thumb mode?
417422
bne __und_usr_thumb
418423
sub r4, r2, #4 @ ARM instr at LR - 4
@@ -517,7 +522,7 @@ ENDPROC(__und_usr)
517522
* r9 = normal "successful" return address
518523
* r10 = this threads thread_info structure
519524
* lr = unrecognised instruction return address
520-
* IRQs disabled, FIQs enabled.
525+
* IRQs enabled, FIQs enabled.
521526
*/
522527
@
523528
@ Fall-through from Thumb-2 __und_usr
@@ -624,7 +629,6 @@ call_fpe:
624629
#endif
625630

626631
do_fpe:
627-
enable_irq
628632
ldr r4, .LCfp
629633
add r10, r10, #TI_FPSTATE @ r10 = workspace
630634
ldr pc, [r4] @ Call FP module USR entry point
@@ -652,8 +656,7 @@ __und_usr_fault_32:
652656
b 1f
653657
__und_usr_fault_16:
654658
mov r1, #2
655-
1: enable_irq
656-
mov r0, sp
659+
1: mov r0, sp
657660
adr lr, BSYM(ret_from_exception)
658661
b __und_fault
659662
ENDPROC(__und_usr_fault_32)

‎arch/arm/kernel/iwmmxt.S‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
* r9 = ret_from_exception
6363
* lr = undefined instr exit
6464
*
65-
* called from prefetch exception handler with interrupts disabled
65+
* called from prefetch exception handler with interrupts enabled
6666
*/
6767

6868
ENTRY(iwmmxt_task_enable)

‎arch/arm/mach-ep93xx/crunch-bits.S‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
* r9 = ret_from_exception
6464
* lr = undefined instr exit
6565
*
66-
* called from prefetch exception handler with interrupts disabled
66+
* called from prefetch exception handler with interrupts enabled
6767
*/
6868
ENTRY(crunch_task_enable)
6969
inc_preempt_count r10, r3

‎arch/arm/vfp/entry.S‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,10 @@
2222
@ r9 = normal "successful" return address
2323
@ r10 = this threads thread_info structure
2424
@ lr = unrecognised instruction return address
25-
@ IRQs disabled.
25+
@ IRQs enabled.
2626
@
2727
ENTRY(do_vfp)
2828
inc_preempt_count r10, r4
29-
enable_irq
3029
ldr r4, .LCvfp
3130
ldr r11, [r10, #TI_CPU] @ CPU number
3231
add r10, r10, #TI_VFPSTATE @ r10 = workspace

0 commit comments

Comments
 (0)