Skip to content

Commit

Permalink
ARC: [arcompact] Handle bus error from userspace as Interrupt not exc…
Browse files Browse the repository at this point in the history
…eption

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 <[email protected]>
Tested-by: Ana Martins <[email protected]>
Signed-off-by: Vineet Gupta <[email protected]>
  • Loading branch information
vineetgarc committed Nov 14, 2015
1 parent 76a8c40 commit 541366d
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 21 deletions.
19 changes: 19 additions & 0 deletions arch/arc/kernel/entry-arcv2.S
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
29 changes: 25 additions & 4 deletions arch/arc/kernel/entry-compact.S
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
; ---------------------------------------------
Expand Down
17 changes: 0 additions & 17 deletions arch/arc/kernel/entry.S
Original file line number Diff line number Diff line change
Expand Up @@ -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
; ---------------------------------------------
Expand Down

0 comments on commit 541366d

Please sign in to comment.