Skip to content

Commit

Permalink
ARC: Exception Handlers Code consolidation
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
vineetgarc committed Aug 26, 2013
1 parent fe240f1 commit 37f3ac4
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 51 deletions.
24 changes: 23 additions & 1 deletion arch/arc/include/asm/entry.h
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@
* it to memory (non-SMP case) or SCRATCH0 Aux Reg (SMP).
*
* Before saving the full regfile - this reg is restored back, only
* to be saved again on kernel mode stack, as part of ptregs.
* to be saved again on kernel mode stack, as part of pt_regs.
*-------------------------------------------------------------*/
.macro EXCPN_PROLOG_FREEUP_REG reg
#ifdef CONFIG_SMP
Expand All @@ -383,6 +383,28 @@
#endif
.endm

/*--------------------------------------------------------------
* Exception Entry prologue
* -Switches stack to K mode (if not already)
* -Saves the register file
*
* After this it is safe to call the "C" handlers
*-------------------------------------------------------------*/
.macro EXCEPTION_PROLOGUE

/* Need at least 1 reg to code the early exception prologue */
EXCPN_PROLOG_FREEUP_REG r9

/* U/K mode at time of exception (stack not switched if already K) */
lr r9, [erstatus]

/* ARC700 doesn't provide auto-stack switching */
SWITCH_TO_KERNEL_STK

/* save the regfile */
SAVE_ALL_SYS
.endm

/*--------------------------------------------------------------
* Save all registers used by Exceptions (TLB Miss, Prot-V, Mem err etc)
* Requires SP to be already switched to kernel mode Stack
Expand Down
56 changes: 13 additions & 43 deletions arch/arc/kernel/entry.S
Original file line number Diff line number Diff line change
Expand Up @@ -267,12 +267,7 @@ ARC_EXIT handle_interrupt_level1

ARC_ENTRY instr_service

EXCPN_PROLOG_FREEUP_REG r9

lr r9, [erstatus]

SWITCH_TO_KERNEL_STK
SAVE_ALL_SYS
EXCEPTION_PROLOGUE

lr r0, [efa]
mov r1, sp
Expand All @@ -289,15 +284,13 @@ ARC_EXIT instr_service

ARC_ENTRY mem_service

EXCPN_PROLOG_FREEUP_REG r9

lr r9, [erstatus]

SWITCH_TO_KERNEL_STK
SAVE_ALL_SYS
EXCEPTION_PROLOGUE

lr r0, [efa]
mov r1, sp

FAKE_RET_FROM_EXCPN r9

bl do_memory_error
b ret_from_exception
ARC_EXIT mem_service
Expand All @@ -308,11 +301,7 @@ ARC_EXIT mem_service

ARC_ENTRY EV_MachineCheck

EXCPN_PROLOG_FREEUP_REG r9
lr r9, [erstatus]

SWITCH_TO_KERNEL_STK
SAVE_ALL_SYS
EXCEPTION_PROLOGUE

lr r2, [ecr]
lr r0, [efa]
Expand Down Expand Up @@ -342,13 +331,7 @@ ARC_EXIT EV_MachineCheck

ARC_ENTRY EV_TLBProtV

EXCPN_PROLOG_FREEUP_REG r9

;Which mode (user/kernel) was the system in when Exception occured
lr r9, [erstatus]

SWITCH_TO_KERNEL_STK
SAVE_ALL_SYS
EXCEPTION_PROLOGUE

;---------(3) Save some more regs-----------------
; vineetg: Mar 6th: Random Seg Fault issue #1
Expand Down Expand Up @@ -406,12 +389,7 @@ ARC_EXIT EV_TLBProtV
; ---------------------------------------------
ARC_ENTRY EV_PrivilegeV

EXCPN_PROLOG_FREEUP_REG r9

lr r9, [erstatus]

SWITCH_TO_KERNEL_STK
SAVE_ALL_SYS
EXCEPTION_PROLOGUE

lr r0, [efa]
mov r1, sp
Expand All @@ -427,14 +405,13 @@ ARC_EXIT EV_PrivilegeV
; ---------------------------------------------
ARC_ENTRY EV_Extension

EXCPN_PROLOG_FREEUP_REG r9
lr r9, [erstatus]

SWITCH_TO_KERNEL_STK
SAVE_ALL_SYS
EXCEPTION_PROLOGUE

lr r0, [efa]
mov r1, sp

FAKE_RET_FROM_EXCPN r9

bl do_extension_fault
b ret_from_exception
ARC_EXIT EV_Extension
Expand Down Expand Up @@ -526,14 +503,7 @@ trap_with_param:

ARC_ENTRY EV_Trap

; Need at least 1 reg to code the early exception prolog
EXCPN_PROLOG_FREEUP_REG r9

;Which mode (user/kernel) was the system in when intr occured
lr r9, [erstatus]

SWITCH_TO_KERNEL_STK
SAVE_ALL_SYS
EXCEPTION_PROLOGUE

;------- (4) What caused the Trap --------------
lr r12, [ecr]
Expand Down
8 changes: 1 addition & 7 deletions arch/arc/mm/tlbex.S
Original file line number Diff line number Diff line change
Expand Up @@ -371,13 +371,7 @@ do_slow_path_pf:

; Slow path TLB Miss handled as a regular ARC Exception
; (stack switching / save the complete reg-file).
; That requires freeing up r9
EXCPN_PROLOG_FREEUP_REG r9

lr r9, [erstatus]

SWITCH_TO_KERNEL_STK
SAVE_ALL_SYS
EXCEPTION_PROLOGUE

; ------- setup args for Linux Page fault Hanlder ---------
mov_s r0, sp
Expand Down

0 comments on commit 37f3ac4

Please sign in to comment.