Skip to content

Commit 13347c1

Browse files
committed
ARC: entry: Add more common chores to EXCEPTION_PROLOGUE
THe high level structure of most ARC exception handlers is 1. save regfile with EXCEPTION_PROLOGUE 2. setup r0: EFA (not part of pt_regs) 3. setup r1: pointer to pt_regs (SP) 4. drop down to pure kernel mode (from exception) 5. call the Linux "C" handler Remove the boiler plate code by moving #2, #3, #4 into #1. The exceptions to most exceptions are syscall Trap and Machine check which don't do some of above for various reasons, so call a newly introduced variant EXCEPTION_PROLOGUE_KEEP_AE (same as original EXCEPTION_PROLOGUE) Tested-by: Pavel Kozlov <[email protected]> Signed-off-by: Vineet Gupta <[email protected]>
1 parent 0e93eca commit 13347c1

File tree

5 files changed

+24
-47
lines changed

5 files changed

+24
-47
lines changed

arch/arc/include/asm/entry-arcv2.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
.endm
7676

7777
/*------------------------------------------------------------------------*/
78-
.macro EXCEPTION_PROLOGUE
78+
.macro EXCEPTION_PROLOGUE_KEEP_AE
7979

8080
; Before jumping to Exception Vector, hardware micro-ops did following:
8181
; 1. SP auto-switched to kernel mode stack
@@ -104,6 +104,16 @@
104104
; OUTPUT: r10 has ECR expected by EV_Trap
105105
.endm
106106

107+
.macro EXCEPTION_PROLOGUE
108+
109+
EXCEPTION_PROLOGUE_KEEP_AE ; return ECR in r10
110+
111+
lr r0, [efa]
112+
mov r1, sp
113+
114+
FAKE_RET_FROM_EXCPN ; clobbers r9
115+
.endm
116+
107117
/*------------------------------------------------------------------------
108118
* This macro saves the registers manually which would normally be autosaved
109119
* by hardware on taken interrupts. It is used by

arch/arc/include/asm/entry-compact.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@
140140
*
141141
* After this it is safe to call the "C" handlers
142142
*-------------------------------------------------------------*/
143-
.macro EXCEPTION_PROLOGUE
143+
.macro EXCEPTION_PROLOGUE_KEEP_AE
144144

145145
/* Need at least 1 reg to code the early exception prologue */
146146
PROLOG_FREEUP_REG r9, @ex_saved_reg1
@@ -179,6 +179,16 @@
179179
; OUTPUT: r10 has ECR expected by EV_Trap
180180
.endm
181181

182+
.macro EXCEPTION_PROLOGUE
183+
184+
EXCEPTION_PROLOGUE_KEEP_AE ; return ECR in r10
185+
186+
lr r0, [efa]
187+
mov r1, sp
188+
189+
FAKE_RET_FROM_EXCPN ; clobbers r9
190+
.endm
191+
182192
/*--------------------------------------------------------------
183193
* Restore all registers used by system call or Exceptions
184194
* SP should always be pointing to the next free stack element

arch/arc/kernel/entry-arcv2.S

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,6 @@ ENTRY(mem_service)
125125

126126
EXCEPTION_PROLOGUE
127127

128-
lr r0, [efa]
129-
mov r1, sp
130-
131-
FAKE_RET_FROM_EXCPN
132-
133128
bl do_memory_error
134129
b ret_from_exception
135130
END(mem_service)
@@ -138,11 +133,6 @@ ENTRY(EV_Misaligned)
138133

139134
EXCEPTION_PROLOGUE
140135

141-
lr r0, [efa] ; Faulting Data address
142-
mov r1, sp
143-
144-
FAKE_RET_FROM_EXCPN
145-
146136
SAVE_CALLEE_SAVED_USER
147137
mov r2, sp ; callee_regs
148138

@@ -163,11 +153,6 @@ ENTRY(EV_TLBProtV)
163153

164154
EXCEPTION_PROLOGUE
165155

166-
lr r0, [efa] ; Faulting Data address
167-
mov r1, sp ; pt_regs
168-
169-
FAKE_RET_FROM_EXCPN
170-
171156
mov blink, ret_from_exception
172157
b do_page_fault
173158

arch/arc/kernel/entry-compact.S

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -256,16 +256,6 @@ ENTRY(EV_TLBProtV)
256256

257257
EXCEPTION_PROLOGUE ; ECR returned in r10
258258

259-
lr r0, [efa] ; Faulting Data address (not part of pt_regs saved above)
260-
261-
; Exception auto-disables further Intr/exceptions.
262-
; Re-enable them by pretending to return from exception
263-
; (so rest of handler executes in pure K mode)
264-
265-
FAKE_RET_FROM_EXCPN
266-
267-
mov r1, sp ; Handle to pt_regs
268-
269259
;------ (5) Type of Protection Violation? ----------
270260
;
271261
; ProtV Hardware Exception is triggered for Access Faults of 2 types
@@ -301,9 +291,6 @@ END(EV_TLBProtV)
301291
ENTRY(call_do_page_fault)
302292

303293
EXCEPTION_PROLOGUE
304-
lr r0, [efa] ; Faulting Data address
305-
mov r1, sp
306-
FAKE_RET_FROM_EXCPN
307294

308295
mov blink, ret_from_exception
309296
b do_page_fault

arch/arc/kernel/entry.S

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,6 @@ ENTRY(instr_service)
8080

8181
EXCEPTION_PROLOGUE
8282

83-
lr r0, [efa]
84-
mov r1, sp
85-
86-
FAKE_RET_FROM_EXCPN
87-
8883
bl do_insterror_or_kprobe
8984
b ret_from_exception
9085
END(instr_service)
@@ -95,7 +90,7 @@ END(instr_service)
9590

9691
ENTRY(EV_MachineCheck)
9792

98-
EXCEPTION_PROLOGUE ; ECR returned in r10
93+
EXCEPTION_PROLOGUE_KEEP_AE ; ECR returned in r10
9994

10095
lr r0, [efa]
10196
mov r1, sp
@@ -128,11 +123,6 @@ ENTRY(EV_PrivilegeV)
128123

129124
EXCEPTION_PROLOGUE
130125

131-
lr r0, [efa]
132-
mov r1, sp
133-
134-
FAKE_RET_FROM_EXCPN
135-
136126
bl do_privilege_fault
137127
b ret_from_exception
138128
END(EV_PrivilegeV)
@@ -144,11 +134,6 @@ ENTRY(EV_Extension)
144134

145135
EXCEPTION_PROLOGUE
146136

147-
lr r0, [efa]
148-
mov r1, sp
149-
150-
FAKE_RET_FROM_EXCPN
151-
152137
bl do_extension_fault
153138
b ret_from_exception
154139
END(EV_Extension)
@@ -229,7 +214,7 @@ trap_with_param:
229214

230215
ENTRY(EV_Trap)
231216

232-
EXCEPTION_PROLOGUE
217+
EXCEPTION_PROLOGUE_KEEP_AE
233218

234219
lr r12, [efa]
235220

0 commit comments

Comments
 (0)