Commit 195b58ad authored by Russell King's avatar Russell King

ARM: Avoid writing to control register on every exception

If we are not changing the control register value, avoid writing to it.
Writes to the control register can be very expensive, taking around a
hundred cycles or so.
Signed-off-by: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
parent 8b521cb2
...@@ -321,6 +321,9 @@ ENDPROC(__pabt_svc) ...@@ -321,6 +321,9 @@ ENDPROC(__pabt_svc)
ARM( stmib sp, {r1 - r12} ) ARM( stmib sp, {r1 - r12} )
THUMB( stmia sp, {r0 - r12} ) THUMB( stmia sp, {r0 - r12} )
ATRAP( mrc p15, 0, r7, c1, c0, 0)
ATRAP( ldr r8, .LCcralign)
ldmia r0, {r3 - r5} ldmia r0, {r3 - r5}
add r0, sp, #S_PC @ here for interlock avoidance add r0, sp, #S_PC @ here for interlock avoidance
mov r6, #-1 @ "" "" "" "" mov r6, #-1 @ "" "" "" ""
...@@ -328,6 +331,8 @@ ENDPROC(__pabt_svc) ...@@ -328,6 +331,8 @@ ENDPROC(__pabt_svc)
str r3, [sp] @ save the "real" r0 copied str r3, [sp] @ save the "real" r0 copied
@ from the exception stack @ from the exception stack
ATRAP( ldr r8, [r8, #0])
@ @
@ We are now ready to fill in the remaining blanks on the stack: @ We are now ready to fill in the remaining blanks on the stack:
@ @
...@@ -341,10 +346,9 @@ ENDPROC(__pabt_svc) ...@@ -341,10 +346,9 @@ ENDPROC(__pabt_svc)
ARM( stmdb r0, {sp, lr}^ ) ARM( stmdb r0, {sp, lr}^ )
THUMB( store_user_sp_lr r0, r1, S_SP - S_PC ) THUMB( store_user_sp_lr r0, r1, S_SP - S_PC )
@
@ Enable the alignment trap while in kernel mode @ Enable the alignment trap while in kernel mode
@ ATRAP( teq r8, r7)
alignment_trap r0, .LCcralign ATRAP( mcrne p15, 0, r8, c1, c0, 0)
@ @
@ Clear FP to mark the first stack frame @ Clear FP to mark the first stack frame
......
...@@ -366,7 +366,7 @@ ENTRY(vector_swi) ...@@ -366,7 +366,7 @@ ENTRY(vector_swi)
str r0, [sp, #S_OLD_R0] @ Save OLD_R0 str r0, [sp, #S_OLD_R0] @ Save OLD_R0
#endif #endif
zero_fp zero_fp
alignment_trap ip, __cr_alignment alignment_trap r10, ip, __cr_alignment
enable_irq enable_irq
ct_user_exit ct_user_exit
get_thread_info tsk get_thread_info tsk
......
...@@ -37,11 +37,19 @@ ...@@ -37,11 +37,19 @@
#endif #endif
.endm .endm
.macro alignment_trap, rtemp, label
#ifdef CONFIG_ALIGNMENT_TRAP #ifdef CONFIG_ALIGNMENT_TRAP
ldr \rtemp, \label #define ATRAP(x...) x
ldr \rtemp, [\rtemp] #else
mcr p15, 0, \rtemp, c1, c0 #define ATRAP(x...)
#endif
.macro alignment_trap, rtmp1, rtmp2, label
#ifdef CONFIG_ALIGNMENT_TRAP
mrc p15, 0, \rtmp2, c1, c0, 0
ldr \rtmp1, \label
ldr \rtmp1, [\rtmp1]
teq \rtmp1, \rtmp2
mcrne p15, 0, \rtmp1, c1, c0, 0
#endif #endif
.endm .endm
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment