aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVineet Gupta <vgupta@synopsys.com>2013-07-09 05:37:13 -0400
committerVineet Gupta <vgupta@synopsys.com>2013-08-26 00:10:25 -0400
commit37f3ac498c988536f0d42b4659fb5d2c050b2f96 (patch)
tree1e680c84ddf182c3e830517f96763c752928a099
parentfe240f11cdab5831d0c4c1ecbaab00b7d302f295 (diff)
ARC: Exception Handlers Code consolidation
After the recent cleanups, all the exception handlers now have same boilerplate prologue code. Move that into common macro. This reduces readability but helps greatly with sharing / duplicating entry code with ARCv2 ISA where the handlers are pretty much the same, just the entry prologue is different (due to hardware assist). Also while at it, add the missing FAKE_RET_FROM_EXCPN calls in couple of places to drop down to pure kernel mode (from exception mode) before jumping off into "C" code. Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
-rw-r--r--arch/arc/include/asm/entry.h24
-rw-r--r--arch/arc/kernel/entry.S56
-rw-r--r--arch/arc/mm/tlbex.S8
3 files changed, 37 insertions, 51 deletions
diff --git a/arch/arc/include/asm/entry.h b/arch/arc/include/asm/entry.h
index df57611652e5..884081099f80 100644
--- a/arch/arc/include/asm/entry.h
+++ b/arch/arc/include/asm/entry.h
@@ -365,7 +365,7 @@
365 * it to memory (non-SMP case) or SCRATCH0 Aux Reg (SMP). 365 * it to memory (non-SMP case) or SCRATCH0 Aux Reg (SMP).
366 * 366 *
367 * Before saving the full regfile - this reg is restored back, only 367 * Before saving the full regfile - this reg is restored back, only
368 * to be saved again on kernel mode stack, as part of ptregs. 368 * to be saved again on kernel mode stack, as part of pt_regs.
369 *-------------------------------------------------------------*/ 369 *-------------------------------------------------------------*/
370.macro EXCPN_PROLOG_FREEUP_REG reg 370.macro EXCPN_PROLOG_FREEUP_REG reg
371#ifdef CONFIG_SMP 371#ifdef CONFIG_SMP
@@ -384,6 +384,28 @@
384.endm 384.endm
385 385
386/*-------------------------------------------------------------- 386/*--------------------------------------------------------------
387 * Exception Entry prologue
388 * -Switches stack to K mode (if not already)
389 * -Saves the register file
390 *
391 * After this it is safe to call the "C" handlers
392 *-------------------------------------------------------------*/
393.macro EXCEPTION_PROLOGUE
394
395 /* Need at least 1 reg to code the early exception prologue */
396 EXCPN_PROLOG_FREEUP_REG r9
397
398 /* U/K mode at time of exception (stack not switched if already K) */
399 lr r9, [erstatus]
400
401 /* ARC700 doesn't provide auto-stack switching */
402 SWITCH_TO_KERNEL_STK
403
404 /* save the regfile */
405 SAVE_ALL_SYS
406.endm
407
408/*--------------------------------------------------------------
387 * Save all registers used by Exceptions (TLB Miss, Prot-V, Mem err etc) 409 * Save all registers used by Exceptions (TLB Miss, Prot-V, Mem err etc)
388 * Requires SP to be already switched to kernel mode Stack 410 * Requires SP to be already switched to kernel mode Stack
389 * sp points to the next free element on the stack at exit of this macro. 411 * sp points to the next free element on the stack at exit of this macro.
diff --git a/arch/arc/kernel/entry.S b/arch/arc/kernel/entry.S
index 1d7165156e17..059ca94e3df8 100644
--- a/arch/arc/kernel/entry.S
+++ b/arch/arc/kernel/entry.S
@@ -267,12 +267,7 @@ ARC_EXIT handle_interrupt_level1
267 267
268ARC_ENTRY instr_service 268ARC_ENTRY instr_service
269 269
270 EXCPN_PROLOG_FREEUP_REG r9 270 EXCEPTION_PROLOGUE
271
272 lr r9, [erstatus]
273
274 SWITCH_TO_KERNEL_STK
275 SAVE_ALL_SYS
276 271
277 lr r0, [efa] 272 lr r0, [efa]
278 mov r1, sp 273 mov r1, sp
@@ -289,15 +284,13 @@ ARC_EXIT instr_service
289 284
290ARC_ENTRY mem_service 285ARC_ENTRY mem_service
291 286
292 EXCPN_PROLOG_FREEUP_REG r9 287 EXCEPTION_PROLOGUE
293
294 lr r9, [erstatus]
295
296 SWITCH_TO_KERNEL_STK
297 SAVE_ALL_SYS
298 288
299 lr r0, [efa] 289 lr r0, [efa]
300 mov r1, sp 290 mov r1, sp
291
292 FAKE_RET_FROM_EXCPN r9
293
301 bl do_memory_error 294 bl do_memory_error
302 b ret_from_exception 295 b ret_from_exception
303ARC_EXIT mem_service 296ARC_EXIT mem_service
@@ -308,11 +301,7 @@ ARC_EXIT mem_service
308 301
309ARC_ENTRY EV_MachineCheck 302ARC_ENTRY EV_MachineCheck
310 303
311 EXCPN_PROLOG_FREEUP_REG r9 304 EXCEPTION_PROLOGUE
312 lr r9, [erstatus]
313
314 SWITCH_TO_KERNEL_STK
315 SAVE_ALL_SYS
316 305
317 lr r2, [ecr] 306 lr r2, [ecr]
318 lr r0, [efa] 307 lr r0, [efa]
@@ -342,13 +331,7 @@ ARC_EXIT EV_MachineCheck
342 331
343ARC_ENTRY EV_TLBProtV 332ARC_ENTRY EV_TLBProtV
344 333
345 EXCPN_PROLOG_FREEUP_REG r9 334 EXCEPTION_PROLOGUE
346
347 ;Which mode (user/kernel) was the system in when Exception occured
348 lr r9, [erstatus]
349
350 SWITCH_TO_KERNEL_STK
351 SAVE_ALL_SYS
352 335
353 ;---------(3) Save some more regs----------------- 336 ;---------(3) Save some more regs-----------------
354 ; vineetg: Mar 6th: Random Seg Fault issue #1 337 ; vineetg: Mar 6th: Random Seg Fault issue #1
@@ -406,12 +389,7 @@ ARC_EXIT EV_TLBProtV
406; --------------------------------------------- 389; ---------------------------------------------
407ARC_ENTRY EV_PrivilegeV 390ARC_ENTRY EV_PrivilegeV
408 391
409 EXCPN_PROLOG_FREEUP_REG r9 392 EXCEPTION_PROLOGUE
410
411 lr r9, [erstatus]
412
413 SWITCH_TO_KERNEL_STK
414 SAVE_ALL_SYS
415 393
416 lr r0, [efa] 394 lr r0, [efa]
417 mov r1, sp 395 mov r1, sp
@@ -427,14 +405,13 @@ ARC_EXIT EV_PrivilegeV
427; --------------------------------------------- 405; ---------------------------------------------
428ARC_ENTRY EV_Extension 406ARC_ENTRY EV_Extension
429 407
430 EXCPN_PROLOG_FREEUP_REG r9 408 EXCEPTION_PROLOGUE
431 lr r9, [erstatus]
432
433 SWITCH_TO_KERNEL_STK
434 SAVE_ALL_SYS
435 409
436 lr r0, [efa] 410 lr r0, [efa]
437 mov r1, sp 411 mov r1, sp
412
413 FAKE_RET_FROM_EXCPN r9
414
438 bl do_extension_fault 415 bl do_extension_fault
439 b ret_from_exception 416 b ret_from_exception
440ARC_EXIT EV_Extension 417ARC_EXIT EV_Extension
@@ -526,14 +503,7 @@ trap_with_param:
526 503
527ARC_ENTRY EV_Trap 504ARC_ENTRY EV_Trap
528 505
529 ; Need at least 1 reg to code the early exception prolog 506 EXCEPTION_PROLOGUE
530 EXCPN_PROLOG_FREEUP_REG r9
531
532 ;Which mode (user/kernel) was the system in when intr occured
533 lr r9, [erstatus]
534
535 SWITCH_TO_KERNEL_STK
536 SAVE_ALL_SYS
537 507
538 ;------- (4) What caused the Trap -------------- 508 ;------- (4) What caused the Trap --------------
539 lr r12, [ecr] 509 lr r12, [ecr]
diff --git a/arch/arc/mm/tlbex.S b/arch/arc/mm/tlbex.S
index 5c5bb23001b0..fc34ebc103bc 100644
--- a/arch/arc/mm/tlbex.S
+++ b/arch/arc/mm/tlbex.S
@@ -371,13 +371,7 @@ do_slow_path_pf:
371 371
372 ; Slow path TLB Miss handled as a regular ARC Exception 372 ; Slow path TLB Miss handled as a regular ARC Exception
373 ; (stack switching / save the complete reg-file). 373 ; (stack switching / save the complete reg-file).
374 ; That requires freeing up r9 374 EXCEPTION_PROLOGUE
375 EXCPN_PROLOG_FREEUP_REG r9
376
377 lr r9, [erstatus]
378
379 SWITCH_TO_KERNEL_STK
380 SAVE_ALL_SYS
381 375
382 ; ------- setup args for Linux Page fault Hanlder --------- 376 ; ------- setup args for Linux Page fault Hanlder ---------
383 mov_s r0, sp 377 mov_s r0, sp