ARC: [arcompact] Handle bus error from userspace as Interrupt not exception
authorVineet Gupta <vgupta@synopsys.com>
Fri, 30 Oct 2015 19:52:51 +0000 (01:22 +0530)
committerVineet Gupta <vgupta@synopsys.com>
Sat, 14 Nov 2015 07:42:20 +0000 (13:12 +0530)
Bus errors from userspace on ARCompact based cores are handled by core
as a high priority L2 interrupt but current code treated it as interrupt
Handling an interrupt like exception is certainly not going to go unnoticed.
(and it worked so far as we never saw a Bus error from userspace until
IPPK guys tested a DDR controller with ECC error detection etc hence
needed to explicitly trigger/handle such errors)

 - So move mem_service exception handler from common code into ARCv2 code.
 - In ARCompact code, define  mem_service as L2 interrupt handler which
   just drops down to pure kernel mode and goes of to enqueue SIGBUS

Reported-by: Nelson Pereira <npereira@synopsys.com>
Tested-by: Ana Martins <amartins@synopsys.com>
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
arch/arc/kernel/entry-arcv2.S
arch/arc/kernel/entry-compact.S
arch/arc/kernel/entry.S

index 445e63a..cbfec79 100644 (file)
@@ -91,6 +91,25 @@ ENTRY(EV_DCError)
        flag 1
 END(EV_DCError)
 
+; ---------------------------------------------
+; Memory Error Exception Handler
+;   - Unlike ARCompact, handles Bus errors for both User/Kernel mode,
+;     Instruction fetch or Data access, under a single Exception Vector
+; ---------------------------------------------
+
+ENTRY(mem_service)
+
+       EXCEPTION_PROLOGUE
+
+       lr  r0, [efa]
+       mov r1, sp
+
+       FAKE_RET_FROM_EXCPN
+
+       bl  do_memory_error
+       b   ret_from_exception
+END(mem_service)
+
 ENTRY(EV_Misaligned)
 
        EXCEPTION_PROLOGUE
index 59f5203..4314339 100644 (file)
@@ -142,16 +142,12 @@ int1_saved_reg:
        .zero 4
 
 /* Each Interrupt level needs its own scratch */
-#ifdef CONFIG_ARC_COMPACT_IRQ_LEVELS
-
 ARCFP_DATA int2_saved_reg
        .type   int2_saved_reg, @object
        .size   int2_saved_reg, 4
 int2_saved_reg:
        .zero 4
 
-#endif
-
 ; ---------------------------------------------
        .section .text, "ax",@progbits
 
@@ -215,6 +211,31 @@ END(handle_interrupt_level2)
 
 #endif
 
+; ---------------------------------------------
+; User Mode Memory Bus Error Interrupt Handler
+; (Kernel mode memory errors handled via seperate exception vectors)
+; ---------------------------------------------
+ENTRY(mem_service)
+
+       INTERRUPT_PROLOGUE 2
+
+       mov r0, ilink2
+       mov r1, sp
+
+       ; User process needs to be killed with SIGBUS, but first need to get
+       ; out of the L2 interrupt context (drop to pure kernel mode) and jump
+       ; off to "C" code where SIGBUS in enqueued
+       lr  r3, [status32]
+       bclr r3, r3, STATUS_A2_BIT
+       or  r3, r3, (STATUS_E1_MASK|STATUS_E2_MASK)
+       sr  r3, [status32_l2]
+       mov ilink2, 1f
+       rtie
+1:
+       bl  do_memory_error
+       b   ret_from_exception
+END(mem_service)
+
 ; ---------------------------------------------
 ;  Level 1 ISR
 ; ---------------------------------------------
index 589abf5..2efb062 100644 (file)
@@ -92,23 +92,6 @@ ENTRY(instr_service)
        b   ret_from_exception
 END(instr_service)
 
-; ---------------------------------------------
-; Memory Error Exception Handler
-; ---------------------------------------------
-
-ENTRY(mem_service)
-
-       EXCEPTION_PROLOGUE
-
-       lr  r0, [efa]
-       mov r1, sp
-
-       FAKE_RET_FROM_EXCPN
-
-       bl  do_memory_error
-       b   ret_from_exception
-END(mem_service)
-
 ; ---------------------------------------------
 ; Machine Check Exception Handler
 ; ---------------------------------------------