Skip to content

Commit 541366d

Browse files
committed
ARC: [arcompact] Handle bus error from userspace as Interrupt not exception
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>
1 parent 76a8c40 commit 541366d

File tree

3 files changed

+44
-21
lines changed

3 files changed

+44
-21
lines changed

arch/arc/kernel/entry-arcv2.S

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,25 @@ ENTRY(EV_DCError)
9191
flag 1
9292
END(EV_DCError)
9393

94+
; ---------------------------------------------
95+
; Memory Error Exception Handler
96+
; - Unlike ARCompact, handles Bus errors for both User/Kernel mode,
97+
; Instruction fetch or Data access, under a single Exception Vector
98+
; ---------------------------------------------
99+
100+
ENTRY(mem_service)
101+
102+
EXCEPTION_PROLOGUE
103+
104+
lr r0, [efa]
105+
mov r1, sp
106+
107+
FAKE_RET_FROM_EXCPN
108+
109+
bl do_memory_error
110+
b ret_from_exception
111+
END(mem_service)
112+
94113
ENTRY(EV_Misaligned)
95114

96115
EXCEPTION_PROLOGUE

arch/arc/kernel/entry-compact.S

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,16 +142,12 @@ int1_saved_reg:
142142
.zero 4
143143

144144
/* Each Interrupt level needs its own scratch */
145-
#ifdef CONFIG_ARC_COMPACT_IRQ_LEVELS
146-
147145
ARCFP_DATA int2_saved_reg
148146
.type int2_saved_reg, @object
149147
.size int2_saved_reg, 4
150148
int2_saved_reg:
151149
.zero 4
152150

153-
#endif
154-
155151
; ---------------------------------------------
156152
.section .text, "ax",@progbits
157153

@@ -215,6 +211,31 @@ END(handle_interrupt_level2)
215211

216212
#endif
217213

214+
; ---------------------------------------------
215+
; User Mode Memory Bus Error Interrupt Handler
216+
; (Kernel mode memory errors handled via seperate exception vectors)
217+
; ---------------------------------------------
218+
ENTRY(mem_service)
219+
220+
INTERRUPT_PROLOGUE 2
221+
222+
mov r0, ilink2
223+
mov r1, sp
224+
225+
; User process needs to be killed with SIGBUS, but first need to get
226+
; out of the L2 interrupt context (drop to pure kernel mode) and jump
227+
; off to "C" code where SIGBUS in enqueued
228+
lr r3, [status32]
229+
bclr r3, r3, STATUS_A2_BIT
230+
or r3, r3, (STATUS_E1_MASK|STATUS_E2_MASK)
231+
sr r3, [status32_l2]
232+
mov ilink2, 1f
233+
rtie
234+
1:
235+
bl do_memory_error
236+
b ret_from_exception
237+
END(mem_service)
238+
218239
; ---------------------------------------------
219240
; Level 1 ISR
220241
; ---------------------------------------------

arch/arc/kernel/entry.S

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -92,23 +92,6 @@ ENTRY(instr_service)
9292
b ret_from_exception
9393
END(instr_service)
9494

95-
; ---------------------------------------------
96-
; Memory Error Exception Handler
97-
; ---------------------------------------------
98-
99-
ENTRY(mem_service)
100-
101-
EXCEPTION_PROLOGUE
102-
103-
lr r0, [efa]
104-
mov r1, sp
105-
106-
FAKE_RET_FROM_EXCPN
107-
108-
bl do_memory_error
109-
b ret_from_exception
110-
END(mem_service)
111-
11295
; ---------------------------------------------
11396
; Machine Check Exception Handler
11497
; ---------------------------------------------

0 commit comments

Comments
 (0)