blob: d19adcf6c580c4d1f7be7a909896490cca534e30 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * linux/arch/arm/kernel/entry-armv.S
3 *
4 * Copyright (C) 1996,1997,1998 Russell King.
5 * ARM700 fix by Matthew Godbolt (linux-user@willothewisp.demon.co.uk)
Hyok S. Choiafeb90c2006-01-13 21:05:25 +00006 * nommu support by Hyok S. Choi (hyok.choi@samsung.com)
Linus Torvalds1da177e2005-04-16 15:20:36 -07007 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 *
12 * Low-level vector interface routines
13 *
Nicolas Pitre70b6f2b2007-12-04 14:33:33 +010014 * Note: there is a StrongARM bug in the STMIA rn, {regs}^ instruction
15 * that causes it to save wrong values... Be aware!
Linus Torvalds1da177e2005-04-16 15:20:36 -070016 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070017
Paul Gortmaker9b9cf812015-05-01 20:13:42 -040018#include <linux/init.h>
19
Rob Herring6f6f6a72012-03-10 10:30:31 -060020#include <asm/assembler.h>
Nicolas Pitref09b9972005-10-29 21:44:55 +010021#include <asm/memory.h>
Russell King753790e2011-02-06 15:32:24 +000022#include <asm/glue-df.h>
23#include <asm/glue-pf.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070024#include <asm/vfpmacros.h>
Rob Herring243c8652012-02-08 18:26:34 -060025#ifndef CONFIG_MULTI_IRQ_HANDLER
Russell Kinga09e64f2008-08-05 16:14:15 +010026#include <mach/entry-macro.S>
Rob Herring243c8652012-02-08 18:26:34 -060027#endif
Russell Kingd6551e82006-06-21 13:31:52 +010028#include <asm/thread_notify.h>
Catalin Marinasc4c57162009-02-16 11:42:09 +010029#include <asm/unwind.h>
Russell Kingcc20d422009-11-09 23:53:29 +000030#include <asm/unistd.h>
Tony Lindgrenf159f4e2010-07-05 14:53:10 +010031#include <asm/tls.h>
David Howells9f97da72012-03-28 18:30:01 +010032#include <asm/system_info.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070033
34#include "entry-header.S"
Magnus Dammcd544ce2010-12-22 13:20:08 +010035#include <asm/entry-macro-multi.S>
Wang Nana0266c22015-01-05 19:29:25 +080036#include <asm/probes.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070037
38/*
Russell Kingd9600c92011-06-26 10:34:02 +010039 * Interrupt handling.
Russell King187a51a2005-05-21 18:14:44 +010040 */
41 .macro irq_handler
eric miao52108642010-12-13 09:42:34 +010042#ifdef CONFIG_MULTI_IRQ_HANDLER
Russell Kingd9600c92011-06-26 10:34:02 +010043 ldr r1, =handle_arch_irq
eric miao52108642010-12-13 09:42:34 +010044 mov r0, sp
Russell King14327c62015-04-21 14:17:25 +010045 badr lr, 9997f
Marc Zyngierabeb24a2011-09-06 09:23:26 +010046 ldr pc, [r1]
47#else
Magnus Dammcd544ce2010-12-22 13:20:08 +010048 arch_irq_handler_default
Marc Zyngierabeb24a2011-09-06 09:23:26 +010049#endif
Russell Kingf00ec482010-09-04 10:47:48 +0100509997:
Russell King187a51a2005-05-21 18:14:44 +010051 .endm
52
Russell Kingac8b9c12011-06-26 10:22:08 +010053 .macro pabt_helper
Russell King8dfe7ac2011-06-26 12:37:35 +010054 @ PABORT handler takes pt_regs in r2, fault address in r4 and psr in r5
Russell Kingac8b9c12011-06-26 10:22:08 +010055#ifdef MULTI_PABORT
Russell King0402bec2011-06-25 15:46:08 +010056 ldr ip, .LCprocfns
Russell Kingac8b9c12011-06-26 10:22:08 +010057 mov lr, pc
Russell King0402bec2011-06-25 15:46:08 +010058 ldr pc, [ip, #PROCESSOR_PABT_FUNC]
Russell Kingac8b9c12011-06-26 10:22:08 +010059#else
60 bl CPU_PABORT_HANDLER
61#endif
62 .endm
63
64 .macro dabt_helper
65
66 @
67 @ Call the processor-specific abort handler:
68 @
Russell Kingda740472011-06-26 16:01:26 +010069 @ r2 - pt_regs
Russell King3e287be2011-06-26 14:35:07 +010070 @ r4 - aborted context pc
71 @ r5 - aborted context psr
Russell Kingac8b9c12011-06-26 10:22:08 +010072 @
73 @ The abort handler must return the aborted address in r0, and
74 @ the fault status register in r1. r9 must be preserved.
75 @
76#ifdef MULTI_DABORT
Russell King0402bec2011-06-25 15:46:08 +010077 ldr ip, .LCprocfns
Russell Kingac8b9c12011-06-26 10:22:08 +010078 mov lr, pc
Russell King0402bec2011-06-25 15:46:08 +010079 ldr pc, [ip, #PROCESSOR_DABT_FUNC]
Russell Kingac8b9c12011-06-26 10:22:08 +010080#else
81 bl CPU_DABORT_HANDLER
82#endif
83 .endm
84
Nicolas Pitre785d3cd2007-12-03 15:27:56 -050085#ifdef CONFIG_KPROBES
86 .section .kprobes.text,"ax",%progbits
87#else
88 .text
89#endif
90
Russell King187a51a2005-05-21 18:14:44 +010091/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070092 * Invalid mode handlers
93 */
Russell Kingccea7a12005-05-31 22:22:32 +010094 .macro inv_entry, reason
95 sub sp, sp, #S_FRAME_SIZE
Catalin Marinasb86040a2009-07-24 12:32:54 +010096 ARM( stmib sp, {r1 - lr} )
97 THUMB( stmia sp, {r0 - r12} )
98 THUMB( str sp, [sp, #S_SP] )
99 THUMB( str lr, [sp, #S_LR] )
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100 mov r1, #\reason
101 .endm
102
103__pabt_invalid:
Russell Kingccea7a12005-05-31 22:22:32 +0100104 inv_entry BAD_PREFETCH
105 b common_invalid
Catalin Marinas93ed3972008-08-28 11:22:32 +0100106ENDPROC(__pabt_invalid)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107
108__dabt_invalid:
Russell Kingccea7a12005-05-31 22:22:32 +0100109 inv_entry BAD_DATA
110 b common_invalid
Catalin Marinas93ed3972008-08-28 11:22:32 +0100111ENDPROC(__dabt_invalid)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112
113__irq_invalid:
Russell Kingccea7a12005-05-31 22:22:32 +0100114 inv_entry BAD_IRQ
115 b common_invalid
Catalin Marinas93ed3972008-08-28 11:22:32 +0100116ENDPROC(__irq_invalid)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700117
118__und_invalid:
Russell Kingccea7a12005-05-31 22:22:32 +0100119 inv_entry BAD_UNDEFINSTR
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120
Russell Kingccea7a12005-05-31 22:22:32 +0100121 @
122 @ XXX fall through to common_invalid
123 @
124
125@
126@ common_invalid - generic code for failed exception (re-entrant version of handlers)
127@
128common_invalid:
129 zero_fp
130
131 ldmia r0, {r4 - r6}
132 add r0, sp, #S_PC @ here for interlock avoidance
133 mov r7, #-1 @ "" "" "" ""
134 str r4, [sp] @ save preserved r0
135 stmia r0, {r5 - r7} @ lr_<exception>,
136 @ cpsr_<exception>, "old_r0"
137
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138 mov r0, sp
Linus Torvalds1da177e2005-04-16 15:20:36 -0700139 b bad_mode
Catalin Marinas93ed3972008-08-28 11:22:32 +0100140ENDPROC(__und_invalid)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141
142/*
143 * SVC mode handlers
144 */
Nicolas Pitre2dede2d2006-01-14 16:18:08 +0000145
146#if defined(CONFIG_AEABI) && (__LINUX_ARM_ARCH__ >= 5)
147#define SPFIX(code...) code
148#else
149#define SPFIX(code...)
150#endif
151
Daniel Thompsonc0e7f7e2014-09-17 17:12:06 +0100152 .macro svc_entry, stack_hole=0, trace=1
Catalin Marinasc4c57162009-02-16 11:42:09 +0100153 UNWIND(.fnstart )
154 UNWIND(.save {r0 - pc} )
Catalin Marinasb86040a2009-07-24 12:32:54 +0100155 sub sp, sp, #(S_FRAME_SIZE + \stack_hole - 4)
156#ifdef CONFIG_THUMB2_KERNEL
157 SPFIX( str r0, [sp] ) @ temporarily saved
158 SPFIX( mov r0, sp )
159 SPFIX( tst r0, #4 ) @ test original stack alignment
160 SPFIX( ldr r0, [sp] ) @ restored
161#else
Nicolas Pitre2dede2d2006-01-14 16:18:08 +0000162 SPFIX( tst sp, #4 )
Catalin Marinasb86040a2009-07-24 12:32:54 +0100163#endif
164 SPFIX( subeq sp, sp, #4 )
165 stmia sp, {r1 - r12}
Russell Kingccea7a12005-05-31 22:22:32 +0100166
Russell Kingb059bdc2011-06-25 15:44:20 +0100167 ldmia r0, {r3 - r5}
168 add r7, sp, #S_SP - 4 @ here for interlock avoidance
169 mov r6, #-1 @ "" "" "" ""
170 add r2, sp, #(S_FRAME_SIZE + \stack_hole - 4)
171 SPFIX( addeq r2, r2, #4 )
172 str r3, [sp, #-4]! @ save the "real" r0 copied
Russell Kingccea7a12005-05-31 22:22:32 +0100173 @ from the exception stack
174
Russell Kingb059bdc2011-06-25 15:44:20 +0100175 mov r3, lr
Linus Torvalds1da177e2005-04-16 15:20:36 -0700176
177 @
178 @ We are now ready to fill in the remaining blanks on the stack:
179 @
Russell Kingb059bdc2011-06-25 15:44:20 +0100180 @ r2 - sp_svc
181 @ r3 - lr_svc
182 @ r4 - lr_<exception>, already fixed up for correct return/restart
183 @ r5 - spsr_<exception>
184 @ r6 - orig_r0 (see pt_regs definition in ptrace.h)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700185 @
Russell Kingb059bdc2011-06-25 15:44:20 +0100186 stmia r7, {r2 - r6}
Russell Kingf2741b72011-06-25 17:35:19 +0100187
Daniel Thompsonc0e7f7e2014-09-17 17:12:06 +0100188 .if \trace
Russell Kingf2741b72011-06-25 17:35:19 +0100189#ifdef CONFIG_TRACE_IRQFLAGS
190 bl trace_hardirqs_off
191#endif
Daniel Thompsonc0e7f7e2014-09-17 17:12:06 +0100192 .endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700193 .endm
194
195 .align 5
196__dabt_svc:
Russell Kingccea7a12005-05-31 22:22:32 +0100197 svc_entry
Linus Torvalds1da177e2005-04-16 15:20:36 -0700198 mov r2, sp
Russell Kingda740472011-06-26 16:01:26 +0100199 dabt_helper
Marc Zyngiere16b31b2013-11-04 11:42:29 +0100200 THUMB( ldr r5, [sp, #S_PSR] ) @ potentially updated CPSR
Russell Kingb059bdc2011-06-25 15:44:20 +0100201 svc_exit r5 @ return from exception
Catalin Marinasc4c57162009-02-16 11:42:09 +0100202 UNWIND(.fnend )
Catalin Marinas93ed3972008-08-28 11:22:32 +0100203ENDPROC(__dabt_svc)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700204
205 .align 5
206__irq_svc:
Russell Kingccea7a12005-05-31 22:22:32 +0100207 svc_entry
Russell King1613cc12011-06-25 10:57:57 +0100208 irq_handler
209
Linus Torvalds1da177e2005-04-16 15:20:36 -0700210#ifdef CONFIG_PREEMPT
Russell King706fdd92005-05-21 18:15:45 +0100211 get_thread_info tsk
212 ldr r8, [tsk, #TI_PREEMPT] @ get preempt count
Russell King706fdd92005-05-21 18:15:45 +0100213 ldr r0, [tsk, #TI_FLAGS] @ get flags
Russell King28fab1a2008-04-13 17:47:35 +0100214 teq r8, #0 @ if preempt count != 0
215 movne r0, #0 @ force flags to 0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700216 tst r0, #_TIF_NEED_RESCHED
217 blne svc_preempt
Linus Torvalds1da177e2005-04-16 15:20:36 -0700218#endif
Russell King30891c92011-06-26 12:47:08 +0100219
Russell King9b56feb2013-03-28 12:57:40 +0000220 svc_exit r5, irq = 1 @ return from exception
Catalin Marinasc4c57162009-02-16 11:42:09 +0100221 UNWIND(.fnend )
Catalin Marinas93ed3972008-08-28 11:22:32 +0100222ENDPROC(__irq_svc)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700223
224 .ltorg
225
226#ifdef CONFIG_PREEMPT
227svc_preempt:
Russell King28fab1a2008-04-13 17:47:35 +0100228 mov r8, lr
Linus Torvalds1da177e2005-04-16 15:20:36 -07002291: bl preempt_schedule_irq @ irq en/disable is done inside
Russell King706fdd92005-05-21 18:15:45 +0100230 ldr r0, [tsk, #TI_FLAGS] @ get new tasks TI_FLAGS
Linus Torvalds1da177e2005-04-16 15:20:36 -0700231 tst r0, #_TIF_NEED_RESCHED
Russell King6ebbf2c2014-06-30 16:29:12 +0100232 reteq r8 @ go again
Linus Torvalds1da177e2005-04-16 15:20:36 -0700233 b 1b
234#endif
235
Russell King15ac49b2012-07-30 19:42:10 +0100236__und_fault:
237 @ Correct the PC such that it is pointing at the instruction
238 @ which caused the fault. If the faulting instruction was ARM
239 @ the PC will be pointing at the next instruction, and have to
240 @ subtract 4. Otherwise, it is Thumb, and the PC will be
241 @ pointing at the second half of the Thumb instruction. We
242 @ have to subtract 2.
243 ldr r2, [r0, #S_PC]
244 sub r2, r2, r1
245 str r2, [r0, #S_PC]
246 b do_undefinstr
247ENDPROC(__und_fault)
248
Linus Torvalds1da177e2005-04-16 15:20:36 -0700249 .align 5
250__und_svc:
Nicolas Pitred30a0c82007-12-14 15:56:01 -0500251#ifdef CONFIG_KPROBES
252 @ If a kprobe is about to simulate a "stmdb sp..." instruction,
253 @ it obviously needs free stack space which then will belong to
254 @ the saved context.
Wang Nana0266c22015-01-05 19:29:25 +0800255 svc_entry MAX_STACK_SIZE
Nicolas Pitred30a0c82007-12-14 15:56:01 -0500256#else
Russell Kingccea7a12005-05-31 22:22:32 +0100257 svc_entry
Nicolas Pitred30a0c82007-12-14 15:56:01 -0500258#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700259 @
260 @ call emulation code, which returns using r9 if it has emulated
261 @ the instruction, or the more conventional lr if we are to treat
262 @ this as a real undefined instruction
263 @
264 @ r0 - instruction
265 @
Russell King15ac49b2012-07-30 19:42:10 +0100266#ifndef CONFIG_THUMB2_KERNEL
Russell Kingb059bdc2011-06-25 15:44:20 +0100267 ldr r0, [r4, #-4]
Catalin Marinas83e686e2009-09-18 23:27:07 +0100268#else
Russell King15ac49b2012-07-30 19:42:10 +0100269 mov r1, #2
Russell Kingb059bdc2011-06-25 15:44:20 +0100270 ldrh r0, [r4, #-2] @ Thumb instruction at LR - 2
Dave Martin85519182011-08-19 17:59:27 +0100271 cmp r0, #0xe800 @ 32-bit instruction if xx >= 0
Russell King15ac49b2012-07-30 19:42:10 +0100272 blo __und_svc_fault
273 ldrh r9, [r4] @ bottom 16 bits
274 add r4, r4, #2
275 str r4, [sp, #S_PC]
276 orr r0, r9, r0, lsl #16
Catalin Marinas83e686e2009-09-18 23:27:07 +0100277#endif
Russell King14327c62015-04-21 14:17:25 +0100278 badr r9, __und_svc_finish
Russell Kingb059bdc2011-06-25 15:44:20 +0100279 mov r2, r4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700280 bl call_fpe
281
Russell King15ac49b2012-07-30 19:42:10 +0100282 mov r1, #4 @ PC correction to apply
283__und_svc_fault:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700284 mov r0, sp @ struct pt_regs *regs
Russell King15ac49b2012-07-30 19:42:10 +0100285 bl __und_fault
Linus Torvalds1da177e2005-04-16 15:20:36 -0700286
Russell King15ac49b2012-07-30 19:42:10 +0100287__und_svc_finish:
Russell Kingb059bdc2011-06-25 15:44:20 +0100288 ldr r5, [sp, #S_PSR] @ Get SVC cpsr
289 svc_exit r5 @ return from exception
Catalin Marinasc4c57162009-02-16 11:42:09 +0100290 UNWIND(.fnend )
Catalin Marinas93ed3972008-08-28 11:22:32 +0100291ENDPROC(__und_svc)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700292
293 .align 5
294__pabt_svc:
Russell Kingccea7a12005-05-31 22:22:32 +0100295 svc_entry
Kirill A. Shutemov4fb28472009-09-25 13:39:47 +0100296 mov r2, sp @ regs
Russell King8dfe7ac2011-06-26 12:37:35 +0100297 pabt_helper
Russell Kingb059bdc2011-06-25 15:44:20 +0100298 svc_exit r5 @ return from exception
Catalin Marinasc4c57162009-02-16 11:42:09 +0100299 UNWIND(.fnend )
Catalin Marinas93ed3972008-08-28 11:22:32 +0100300ENDPROC(__pabt_svc)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700301
302 .align 5
Daniel Thompsonc0e7f7e2014-09-17 17:12:06 +0100303__fiq_svc:
304 svc_entry trace=0
305 mov r0, sp @ struct pt_regs *regs
306 bl handle_fiq_as_nmi
307 svc_exit_via_fiq
308 UNWIND(.fnend )
309ENDPROC(__fiq_svc)
310
311 .align 5
Russell King49f680e2005-05-31 18:02:00 +0100312.LCcralign:
313 .word cr_alignment
Paul Brook48d79272008-04-18 22:43:07 +0100314#ifdef MULTI_DABORT
Linus Torvalds1da177e2005-04-16 15:20:36 -0700315.LCprocfns:
316 .word processor
317#endif
318.LCfp:
319 .word fp_enter
Linus Torvalds1da177e2005-04-16 15:20:36 -0700320
321/*
Daniel Thompsonc0e7f7e2014-09-17 17:12:06 +0100322 * Abort mode handlers
323 */
324
325@
326@ Taking a FIQ in abort mode is similar to taking a FIQ in SVC mode
327@ and reuses the same macros. However in abort mode we must also
328@ save/restore lr_abt and spsr_abt to make nested aborts safe.
329@
330 .align 5
331__fiq_abt:
332 svc_entry trace=0
333
334 ARM( msr cpsr_c, #ABT_MODE | PSR_I_BIT | PSR_F_BIT )
335 THUMB( mov r0, #ABT_MODE | PSR_I_BIT | PSR_F_BIT )
336 THUMB( msr cpsr_c, r0 )
337 mov r1, lr @ Save lr_abt
338 mrs r2, spsr @ Save spsr_abt, abort is now safe
339 ARM( msr cpsr_c, #SVC_MODE | PSR_I_BIT | PSR_F_BIT )
340 THUMB( mov r0, #SVC_MODE | PSR_I_BIT | PSR_F_BIT )
341 THUMB( msr cpsr_c, r0 )
342 stmfd sp!, {r1 - r2}
343
344 add r0, sp, #8 @ struct pt_regs *regs
345 bl handle_fiq_as_nmi
346
347 ldmfd sp!, {r1 - r2}
348 ARM( msr cpsr_c, #ABT_MODE | PSR_I_BIT | PSR_F_BIT )
349 THUMB( mov r0, #ABT_MODE | PSR_I_BIT | PSR_F_BIT )
350 THUMB( msr cpsr_c, r0 )
351 mov lr, r1 @ Restore lr_abt, abort is unsafe
352 msr spsr_cxsf, r2 @ Restore spsr_abt
353 ARM( msr cpsr_c, #SVC_MODE | PSR_I_BIT | PSR_F_BIT )
354 THUMB( mov r0, #SVC_MODE | PSR_I_BIT | PSR_F_BIT )
355 THUMB( msr cpsr_c, r0 )
356
357 svc_exit_via_fiq
358 UNWIND(.fnend )
359ENDPROC(__fiq_abt)
360
361/*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700362 * User mode handlers
Nicolas Pitre2dede2d2006-01-14 16:18:08 +0000363 *
364 * EABI note: sp_svc is always 64-bit aligned here, so should S_FRAME_SIZE
Linus Torvalds1da177e2005-04-16 15:20:36 -0700365 */
Nicolas Pitre2dede2d2006-01-14 16:18:08 +0000366
367#if defined(CONFIG_AEABI) && (__LINUX_ARM_ARCH__ >= 5) && (S_FRAME_SIZE & 7)
368#error "sizeof(struct pt_regs) must be a multiple of 8"
369#endif
370
Daniel Thompsonc0e7f7e2014-09-17 17:12:06 +0100371 .macro usr_entry, trace=1
Catalin Marinasc4c57162009-02-16 11:42:09 +0100372 UNWIND(.fnstart )
373 UNWIND(.cantunwind ) @ don't unwind the user space
Russell Kingccea7a12005-05-31 22:22:32 +0100374 sub sp, sp, #S_FRAME_SIZE
Catalin Marinasb86040a2009-07-24 12:32:54 +0100375 ARM( stmib sp, {r1 - r12} )
376 THUMB( stmia sp, {r0 - r12} )
Russell Kingccea7a12005-05-31 22:22:32 +0100377
Russell King195b58a2014-08-28 13:08:14 +0100378 ATRAP( mrc p15, 0, r7, c1, c0, 0)
379 ATRAP( ldr r8, .LCcralign)
380
Russell Kingb059bdc2011-06-25 15:44:20 +0100381 ldmia r0, {r3 - r5}
Russell Kingccea7a12005-05-31 22:22:32 +0100382 add r0, sp, #S_PC @ here for interlock avoidance
Russell Kingb059bdc2011-06-25 15:44:20 +0100383 mov r6, #-1 @ "" "" "" ""
Russell Kingccea7a12005-05-31 22:22:32 +0100384
Russell Kingb059bdc2011-06-25 15:44:20 +0100385 str r3, [sp] @ save the "real" r0 copied
Russell Kingccea7a12005-05-31 22:22:32 +0100386 @ from the exception stack
Linus Torvalds1da177e2005-04-16 15:20:36 -0700387
Russell King195b58a2014-08-28 13:08:14 +0100388 ATRAP( ldr r8, [r8, #0])
389
Linus Torvalds1da177e2005-04-16 15:20:36 -0700390 @
391 @ We are now ready to fill in the remaining blanks on the stack:
392 @
Russell Kingb059bdc2011-06-25 15:44:20 +0100393 @ r4 - lr_<exception>, already fixed up for correct return/restart
394 @ r5 - spsr_<exception>
395 @ r6 - orig_r0 (see pt_regs definition in ptrace.h)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700396 @
397 @ Also, separately save sp_usr and lr_usr
398 @
Russell Kingb059bdc2011-06-25 15:44:20 +0100399 stmia r0, {r4 - r6}
Catalin Marinasb86040a2009-07-24 12:32:54 +0100400 ARM( stmdb r0, {sp, lr}^ )
401 THUMB( store_user_sp_lr r0, r1, S_SP - S_PC )
Linus Torvalds1da177e2005-04-16 15:20:36 -0700402
Linus Torvalds1da177e2005-04-16 15:20:36 -0700403 @ Enable the alignment trap while in kernel mode
Russell King195b58a2014-08-28 13:08:14 +0100404 ATRAP( teq r8, r7)
405 ATRAP( mcrne p15, 0, r8, c1, c0, 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700406
407 @
408 @ Clear FP to mark the first stack frame
409 @
410 zero_fp
Russell Kingf2741b72011-06-25 17:35:19 +0100411
Daniel Thompsonc0e7f7e2014-09-17 17:12:06 +0100412 .if \trace
Russell Kingf2741b72011-06-25 17:35:19 +0100413#ifdef CONFIG_IRQSOFF_TRACER
414 bl trace_hardirqs_off
415#endif
Kevin Hilmanb0088482013-03-28 22:54:40 +0100416 ct_user_exit save = 0
Daniel Thompsonc0e7f7e2014-09-17 17:12:06 +0100417 .endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700418 .endm
419
Nicolas Pitreb49c0f22007-11-20 17:20:29 +0100420 .macro kuser_cmpxchg_check
Russell King1b16c4b2013-08-06 09:48:42 +0100421#if !defined(CONFIG_CPU_32v6K) && defined(CONFIG_KUSER_HELPERS) && \
422 !defined(CONFIG_NEEDS_SYSCALL_FOR_CMPXCHG)
Nicolas Pitreb49c0f22007-11-20 17:20:29 +0100423#ifndef CONFIG_MMU
424#warning "NPTL on non MMU needs fixing"
425#else
426 @ Make sure our user space atomic helper is restarted
427 @ if it was interrupted in a critical region. Here we
428 @ perform a quick test inline since it should be false
429 @ 99.9999% of the time. The rest is done out of line.
Russell Kingb059bdc2011-06-25 15:44:20 +0100430 cmp r4, #TASK_SIZE
Nicolas Pitre40fb79c2011-06-19 23:36:03 -0400431 blhs kuser_cmpxchg64_fixup
Nicolas Pitreb49c0f22007-11-20 17:20:29 +0100432#endif
433#endif
434 .endm
435
Linus Torvalds1da177e2005-04-16 15:20:36 -0700436 .align 5
437__dabt_usr:
Russell Kingccea7a12005-05-31 22:22:32 +0100438 usr_entry
Nicolas Pitreb49c0f22007-11-20 17:20:29 +0100439 kuser_cmpxchg_check
Linus Torvalds1da177e2005-04-16 15:20:36 -0700440 mov r2, sp
Russell Kingda740472011-06-26 16:01:26 +0100441 dabt_helper
442 b ret_from_exception
Catalin Marinasc4c57162009-02-16 11:42:09 +0100443 UNWIND(.fnend )
Catalin Marinas93ed3972008-08-28 11:22:32 +0100444ENDPROC(__dabt_usr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700445
446 .align 5
447__irq_usr:
Russell Kingccea7a12005-05-31 22:22:32 +0100448 usr_entry
Russell Kingbc089602011-06-25 18:28:19 +0100449 kuser_cmpxchg_check
Russell King187a51a2005-05-21 18:14:44 +0100450 irq_handler
Russell King1613cc12011-06-25 10:57:57 +0100451 get_thread_info tsk
Linus Torvalds1da177e2005-04-16 15:20:36 -0700452 mov why, #0
Ming Lei9fc25522011-06-05 02:24:58 +0100453 b ret_to_user_from_irq
Catalin Marinasc4c57162009-02-16 11:42:09 +0100454 UNWIND(.fnend )
Catalin Marinas93ed3972008-08-28 11:22:32 +0100455ENDPROC(__irq_usr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700456
457 .ltorg
458
459 .align 5
460__und_usr:
Russell Kingccea7a12005-05-31 22:22:32 +0100461 usr_entry
Russell Kingbc089602011-06-25 18:28:19 +0100462
Russell Kingb059bdc2011-06-25 15:44:20 +0100463 mov r2, r4
464 mov r3, r5
Linus Torvalds1da177e2005-04-16 15:20:36 -0700465
Russell King15ac49b2012-07-30 19:42:10 +0100466 @ r2 = regs->ARM_pc, which is either 2 or 4 bytes ahead of the
467 @ faulting instruction depending on Thumb mode.
468 @ r3 = regs->ARM_cpsr
Linus Torvalds1da177e2005-04-16 15:20:36 -0700469 @
Russell King15ac49b2012-07-30 19:42:10 +0100470 @ The emulation code returns using r9 if it has emulated the
471 @ instruction, or the more conventional lr if we are to treat
472 @ this as a real undefined instruction
Linus Torvalds1da177e2005-04-16 15:20:36 -0700473 @
Russell King14327c62015-04-21 14:17:25 +0100474 badr r9, ret_from_exception
Russell King15ac49b2012-07-30 19:42:10 +0100475
Catalin Marinas1417a6b2014-04-22 16:14:29 +0100476 @ IRQs must be enabled before attempting to read the instruction from
477 @ user space since that could cause a page/translation fault if the
478 @ page table was modified by another CPU.
479 enable_irq
480
Paul Brookcb170a42008-04-18 22:43:08 +0100481 tst r3, #PSR_T_BIT @ Thumb mode?
Russell King15ac49b2012-07-30 19:42:10 +0100482 bne __und_usr_thumb
483 sub r4, r2, #4 @ ARM instr at LR - 4
4841: ldrt r0, [r4]
Ben Dooks457c2402013-02-12 18:59:57 +0000485 ARM_BE8(rev r0, r0) @ little endian instruction
486
Russell King15ac49b2012-07-30 19:42:10 +0100487 @ r0 = 32-bit ARM instruction which caused the exception
488 @ r2 = PC value for the following instruction (:= regs->ARM_pc)
489 @ r4 = PC value for the faulting instruction
490 @ lr = 32-bit undefined instruction function
Russell King14327c62015-04-21 14:17:25 +0100491 badr lr, __und_usr_fault_32
Russell King15ac49b2012-07-30 19:42:10 +0100492 b call_fpe
493
494__und_usr_thumb:
Paul Brookcb170a42008-04-18 22:43:08 +0100495 @ Thumb instruction
Russell King15ac49b2012-07-30 19:42:10 +0100496 sub r4, r2, #2 @ First half of thumb instr at LR - 2
Dave Martinef4c5362011-08-19 18:00:08 +0100497#if CONFIG_ARM_THUMB && __LINUX_ARM_ARCH__ >= 6 && CONFIG_CPU_V7
498/*
499 * Thumb-2 instruction handling. Note that because pre-v6 and >= v6 platforms
500 * can never be supported in a single kernel, this code is not applicable at
501 * all when __LINUX_ARM_ARCH__ < 6. This allows simplifying assumptions to be
502 * made about .arch directives.
503 */
504#if __LINUX_ARM_ARCH__ < 7
505/* If the target CPU may not be Thumb-2-capable, a run-time check is needed: */
506#define NEED_CPU_ARCHITECTURE
507 ldr r5, .LCcpu_architecture
508 ldr r5, [r5]
509 cmp r5, #CPU_ARCH_ARMv7
Russell King15ac49b2012-07-30 19:42:10 +0100510 blo __und_usr_fault_16 @ 16bit undefined instruction
Dave Martinef4c5362011-08-19 18:00:08 +0100511/*
512 * The following code won't get run unless the running CPU really is v7, so
513 * coding round the lack of ldrht on older arches is pointless. Temporarily
514 * override the assembler target arch with the minimum required instead:
515 */
516 .arch armv6t2
517#endif
Russell King15ac49b2012-07-30 19:42:10 +01005182: ldrht r5, [r4]
Victor Kamenskyf8fe23e2014-01-21 06:45:11 +0100519ARM_BE8(rev16 r5, r5) @ little endian instruction
Dave Martin85519182011-08-19 17:59:27 +0100520 cmp r5, #0xe800 @ 32bit instruction if xx != 0
Russell King15ac49b2012-07-30 19:42:10 +0100521 blo __und_usr_fault_16 @ 16bit undefined instruction
5223: ldrht r0, [r2]
Victor Kamenskyf8fe23e2014-01-21 06:45:11 +0100523ARM_BE8(rev16 r0, r0) @ little endian instruction
Paul Brookcb170a42008-04-18 22:43:08 +0100524 add r2, r2, #2 @ r2 is PC + 2, make it PC + 4
Russell King15ac49b2012-07-30 19:42:10 +0100525 str r2, [sp, #S_PC] @ it's a 2x16bit instr, update
Paul Brookcb170a42008-04-18 22:43:08 +0100526 orr r0, r0, r5, lsl #16
Russell King14327c62015-04-21 14:17:25 +0100527 badr lr, __und_usr_fault_32
Russell King15ac49b2012-07-30 19:42:10 +0100528 @ r0 = the two 16-bit Thumb instructions which caused the exception
529 @ r2 = PC value for the following Thumb instruction (:= regs->ARM_pc)
530 @ r4 = PC value for the first 16-bit Thumb instruction
531 @ lr = 32bit undefined instruction function
Dave Martinef4c5362011-08-19 18:00:08 +0100532
533#if __LINUX_ARM_ARCH__ < 7
534/* If the target arch was overridden, change it back: */
535#ifdef CONFIG_CPU_32v6K
536 .arch armv6k
Paul Brookcb170a42008-04-18 22:43:08 +0100537#else
Dave Martinef4c5362011-08-19 18:00:08 +0100538 .arch armv6
539#endif
540#endif /* __LINUX_ARM_ARCH__ < 7 */
541#else /* !(CONFIG_ARM_THUMB && __LINUX_ARM_ARCH__ >= 6 && CONFIG_CPU_V7) */
Russell King15ac49b2012-07-30 19:42:10 +0100542 b __und_usr_fault_16
Paul Brookcb170a42008-04-18 22:43:08 +0100543#endif
Russell King15ac49b2012-07-30 19:42:10 +0100544 UNWIND(.fnend)
Catalin Marinas93ed3972008-08-28 11:22:32 +0100545ENDPROC(__und_usr)
Paul Brookcb170a42008-04-18 22:43:08 +0100546
Linus Torvalds1da177e2005-04-16 15:20:36 -0700547/*
Russell King15ac49b2012-07-30 19:42:10 +0100548 * The out of line fixup for the ldrt instructions above.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700549 */
Ard Biesheuvelc4a84ae2015-03-24 10:41:09 +0100550 .pushsection .text.fixup, "ax"
Will Deacon667d1b42012-06-15 16:49:58 +0100551 .align 2
Arun K S3780f7a2014-05-19 11:43:00 +01005524: str r4, [sp, #S_PC] @ retry current instruction
Russell King6ebbf2c2014-06-30 16:29:12 +0100553 ret r9
Russell King42604152010-04-19 10:15:03 +0100554 .popsection
555 .pushsection __ex_table,"a"
Paul Brookcb170a42008-04-18 22:43:08 +0100556 .long 1b, 4b
Guennadi Liakhovetskic89cefe2011-11-22 23:42:12 +0100557#if CONFIG_ARM_THUMB && __LINUX_ARM_ARCH__ >= 6 && CONFIG_CPU_V7
Paul Brookcb170a42008-04-18 22:43:08 +0100558 .long 2b, 4b
559 .long 3b, 4b
560#endif
Russell King42604152010-04-19 10:15:03 +0100561 .popsection
Linus Torvalds1da177e2005-04-16 15:20:36 -0700562
563/*
564 * Check whether the instruction is a co-processor instruction.
565 * If yes, we need to call the relevant co-processor handler.
566 *
567 * Note that we don't do a full check here for the co-processor
568 * instructions; all instructions with bit 27 set are well
569 * defined. The only instructions that should fault are the
570 * co-processor instructions. However, we have to watch out
571 * for the ARM6/ARM7 SWI bug.
572 *
Catalin Marinasb5872db2008-01-10 19:16:17 +0100573 * NEON is a special case that has to be handled here. Not all
574 * NEON instructions are co-processor instructions, so we have
575 * to make a special case of checking for them. Plus, there's
576 * five groups of them, so we have a table of mask/opcode pairs
577 * to check against, and if any match then we branch off into the
578 * NEON handler code.
579 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700580 * Emulators may wish to make use of the following registers:
Russell King15ac49b2012-07-30 19:42:10 +0100581 * r0 = instruction opcode (32-bit ARM or two 16-bit Thumb)
582 * r2 = PC value to resume execution after successful emulation
Russell Kingdb6ccbb62007-01-06 22:53:48 +0000583 * r9 = normal "successful" return address
Russell King15ac49b2012-07-30 19:42:10 +0100584 * r10 = this threads thread_info structure
Russell Kingdb6ccbb62007-01-06 22:53:48 +0000585 * lr = unrecognised instruction return address
Catalin Marinas1417a6b2014-04-22 16:14:29 +0100586 * IRQs enabled, FIQs enabled.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700587 */
Paul Brookcb170a42008-04-18 22:43:08 +0100588 @
589 @ Fall-through from Thumb-2 __und_usr
590 @
591#ifdef CONFIG_NEON
Russell Kingd3f79582013-02-23 17:53:52 +0000592 get_thread_info r10 @ get current thread
Paul Brookcb170a42008-04-18 22:43:08 +0100593 adr r6, .LCneon_thumb_opcodes
594 b 2f
595#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700596call_fpe:
Russell Kingd3f79582013-02-23 17:53:52 +0000597 get_thread_info r10 @ get current thread
Catalin Marinasb5872db2008-01-10 19:16:17 +0100598#ifdef CONFIG_NEON
Paul Brookcb170a42008-04-18 22:43:08 +0100599 adr r6, .LCneon_arm_opcodes
Russell Kingd3f79582013-02-23 17:53:52 +00006002: ldr r5, [r6], #4 @ mask value
Catalin Marinasb5872db2008-01-10 19:16:17 +0100601 ldr r7, [r6], #4 @ opcode bits matching in mask
Russell Kingd3f79582013-02-23 17:53:52 +0000602 cmp r5, #0 @ end mask?
603 beq 1f
604 and r8, r0, r5
Catalin Marinasb5872db2008-01-10 19:16:17 +0100605 cmp r8, r7 @ NEON instruction?
606 bne 2b
Catalin Marinasb5872db2008-01-10 19:16:17 +0100607 mov r7, #1
608 strb r7, [r10, #TI_USED_CP + 10] @ mark CP#10 as used
609 strb r7, [r10, #TI_USED_CP + 11] @ mark CP#11 as used
610 b do_vfp @ let VFP handler handle this
6111:
612#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700613 tst r0, #0x08000000 @ only CDP/CPRT/LDC/STC have bit 27
Paul Brookcb170a42008-04-18 22:43:08 +0100614 tstne r0, #0x04000000 @ bit 26 set on both ARM and Thumb-2
Russell King6ebbf2c2014-06-30 16:29:12 +0100615 reteq lr
Linus Torvalds1da177e2005-04-16 15:20:36 -0700616 and r8, r0, #0x00000f00 @ mask out CP number
Catalin Marinasb86040a2009-07-24 12:32:54 +0100617 THUMB( lsr r8, r8, #8 )
Linus Torvalds1da177e2005-04-16 15:20:36 -0700618 mov r7, #1
619 add r6, r10, #TI_USED_CP
Catalin Marinasb86040a2009-07-24 12:32:54 +0100620 ARM( strb r7, [r6, r8, lsr #8] ) @ set appropriate used_cp[]
621 THUMB( strb r7, [r6, r8] ) @ set appropriate used_cp[]
Linus Torvalds1da177e2005-04-16 15:20:36 -0700622#ifdef CONFIG_IWMMXT
623 @ Test if we need to give access to iWMMXt coprocessors
624 ldr r5, [r10, #TI_FLAGS]
625 rsbs r7, r8, #(1 << 8) @ CP 0 or 1 only
626 movcss r7, r5, lsr #(TIF_USING_IWMMXT + 1)
627 bcs iwmmxt_task_enable
628#endif
Catalin Marinasb86040a2009-07-24 12:32:54 +0100629 ARM( add pc, pc, r8, lsr #6 )
630 THUMB( lsl r8, r8, #2 )
631 THUMB( add pc, r8 )
632 nop
Linus Torvalds1da177e2005-04-16 15:20:36 -0700633
Russell King6ebbf2c2014-06-30 16:29:12 +0100634 ret.w lr @ CP#0
Catalin Marinasb86040a2009-07-24 12:32:54 +0100635 W(b) do_fpe @ CP#1 (FPE)
636 W(b) do_fpe @ CP#2 (FPE)
Russell King6ebbf2c2014-06-30 16:29:12 +0100637 ret.w lr @ CP#3
Lennert Buytenhekc17fad12006-06-27 23:03:03 +0100638#ifdef CONFIG_CRUNCH
639 b crunch_task_enable @ CP#4 (MaverickCrunch)
640 b crunch_task_enable @ CP#5 (MaverickCrunch)
641 b crunch_task_enable @ CP#6 (MaverickCrunch)
642#else
Russell King6ebbf2c2014-06-30 16:29:12 +0100643 ret.w lr @ CP#4
644 ret.w lr @ CP#5
645 ret.w lr @ CP#6
Lennert Buytenhekc17fad12006-06-27 23:03:03 +0100646#endif
Russell King6ebbf2c2014-06-30 16:29:12 +0100647 ret.w lr @ CP#7
648 ret.w lr @ CP#8
649 ret.w lr @ CP#9
Linus Torvalds1da177e2005-04-16 15:20:36 -0700650#ifdef CONFIG_VFP
Catalin Marinasb86040a2009-07-24 12:32:54 +0100651 W(b) do_vfp @ CP#10 (VFP)
652 W(b) do_vfp @ CP#11 (VFP)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700653#else
Russell King6ebbf2c2014-06-30 16:29:12 +0100654 ret.w lr @ CP#10 (VFP)
655 ret.w lr @ CP#11 (VFP)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700656#endif
Russell King6ebbf2c2014-06-30 16:29:12 +0100657 ret.w lr @ CP#12
658 ret.w lr @ CP#13
659 ret.w lr @ CP#14 (Debug)
660 ret.w lr @ CP#15 (Control)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700661
Dave Martinef4c5362011-08-19 18:00:08 +0100662#ifdef NEED_CPU_ARCHITECTURE
663 .align 2
664.LCcpu_architecture:
665 .word __cpu_architecture
666#endif
667
Catalin Marinasb5872db2008-01-10 19:16:17 +0100668#ifdef CONFIG_NEON
669 .align 6
670
Paul Brookcb170a42008-04-18 22:43:08 +0100671.LCneon_arm_opcodes:
Catalin Marinasb5872db2008-01-10 19:16:17 +0100672 .word 0xfe000000 @ mask
673 .word 0xf2000000 @ opcode
674
675 .word 0xff100000 @ mask
676 .word 0xf4000000 @ opcode
677
678 .word 0x00000000 @ mask
679 .word 0x00000000 @ opcode
Paul Brookcb170a42008-04-18 22:43:08 +0100680
681.LCneon_thumb_opcodes:
682 .word 0xef000000 @ mask
683 .word 0xef000000 @ opcode
684
685 .word 0xff100000 @ mask
686 .word 0xf9000000 @ opcode
687
688 .word 0x00000000 @ mask
689 .word 0x00000000 @ opcode
Catalin Marinasb5872db2008-01-10 19:16:17 +0100690#endif
691
Linus Torvalds1da177e2005-04-16 15:20:36 -0700692do_fpe:
693 ldr r4, .LCfp
694 add r10, r10, #TI_FPSTATE @ r10 = workspace
695 ldr pc, [r4] @ Call FP module USR entry point
696
697/*
698 * The FP module is called with these registers set:
699 * r0 = instruction
700 * r2 = PC+4
701 * r9 = normal "successful" return address
702 * r10 = FP workspace
703 * lr = unrecognised FP instruction return address
704 */
705
Santosh Shilimkar124efc22010-04-30 10:45:46 +0100706 .pushsection .data
Linus Torvalds1da177e2005-04-16 15:20:36 -0700707ENTRY(fp_enter)
Russell Kingdb6ccbb62007-01-06 22:53:48 +0000708 .word no_fp
Santosh Shilimkar124efc22010-04-30 10:45:46 +0100709 .popsection
Linus Torvalds1da177e2005-04-16 15:20:36 -0700710
Catalin Marinas83e686e2009-09-18 23:27:07 +0100711ENTRY(no_fp)
Russell King6ebbf2c2014-06-30 16:29:12 +0100712 ret lr
Catalin Marinas83e686e2009-09-18 23:27:07 +0100713ENDPROC(no_fp)
Russell Kingdb6ccbb62007-01-06 22:53:48 +0000714
Russell King15ac49b2012-07-30 19:42:10 +0100715__und_usr_fault_32:
716 mov r1, #4
717 b 1f
718__und_usr_fault_16:
719 mov r1, #2
Catalin Marinas1417a6b2014-04-22 16:14:29 +01007201: mov r0, sp
Russell King14327c62015-04-21 14:17:25 +0100721 badr lr, ret_from_exception
Russell King15ac49b2012-07-30 19:42:10 +0100722 b __und_fault
723ENDPROC(__und_usr_fault_32)
724ENDPROC(__und_usr_fault_16)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700725
726 .align 5
727__pabt_usr:
Russell Kingccea7a12005-05-31 22:22:32 +0100728 usr_entry
Kirill A. Shutemov4fb28472009-09-25 13:39:47 +0100729 mov r2, sp @ regs
Russell King8dfe7ac2011-06-26 12:37:35 +0100730 pabt_helper
Catalin Marinasc4c57162009-02-16 11:42:09 +0100731 UNWIND(.fnend )
Linus Torvalds1da177e2005-04-16 15:20:36 -0700732 /* fall through */
733/*
734 * This is the return code to user mode for abort handlers
735 */
736ENTRY(ret_from_exception)
Catalin Marinasc4c57162009-02-16 11:42:09 +0100737 UNWIND(.fnstart )
738 UNWIND(.cantunwind )
Linus Torvalds1da177e2005-04-16 15:20:36 -0700739 get_thread_info tsk
740 mov why, #0
741 b ret_to_user
Catalin Marinasc4c57162009-02-16 11:42:09 +0100742 UNWIND(.fnend )
Catalin Marinas93ed3972008-08-28 11:22:32 +0100743ENDPROC(__pabt_usr)
744ENDPROC(ret_from_exception)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700745
Daniel Thompsonc0e7f7e2014-09-17 17:12:06 +0100746 .align 5
747__fiq_usr:
748 usr_entry trace=0
749 kuser_cmpxchg_check
750 mov r0, sp @ struct pt_regs *regs
751 bl handle_fiq_as_nmi
752 get_thread_info tsk
753 restore_user_regs fast = 0, offset = 0
754 UNWIND(.fnend )
755ENDPROC(__fiq_usr)
756
Linus Torvalds1da177e2005-04-16 15:20:36 -0700757/*
758 * Register switch for ARMv3 and ARMv4 processors
759 * r0 = previous task_struct, r1 = previous thread_info, r2 = next thread_info
760 * previous and next are guaranteed not to be the same.
761 */
762ENTRY(__switch_to)
Catalin Marinasc4c57162009-02-16 11:42:09 +0100763 UNWIND(.fnstart )
764 UNWIND(.cantunwind )
Linus Torvalds1da177e2005-04-16 15:20:36 -0700765 add ip, r1, #TI_CPU_SAVE
Catalin Marinasb86040a2009-07-24 12:32:54 +0100766 ARM( stmia ip!, {r4 - sl, fp, sp, lr} ) @ Store most regs on stack
767 THUMB( stmia ip!, {r4 - sl, fp} ) @ Store most regs on stack
768 THUMB( str sp, [ip], #4 )
769 THUMB( str lr, [ip], #4 )
André Hentschela4780ad2013-06-18 23:23:26 +0100770 ldr r4, [r2, #TI_TP_VALUE]
771 ldr r5, [r2, #TI_TP_VALUE + 4]
Catalin Marinas247055a2010-09-13 16:03:21 +0100772#ifdef CONFIG_CPU_USE_DOMAINS
Russell King1eef5d22015-08-19 21:23:48 +0100773 mrc p15, 0, r6, c3, c0, 0 @ Get domain register
774 str r6, [r1, #TI_CPU_DOMAIN] @ Save old domain register
Russell Kingd6551e82006-06-21 13:31:52 +0100775 ldr r6, [r2, #TI_CPU_DOMAIN]
Hyok S. Choiafeb90c2006-01-13 21:05:25 +0000776#endif
André Hentschela4780ad2013-06-18 23:23:26 +0100777 switch_tls r1, r4, r5, r3, r7
Nicolas Pitredf0698b2010-06-07 21:50:33 -0400778#if defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_SMP)
779 ldr r7, [r2, #TI_TASK]
780 ldr r8, =__stack_chk_guard
781 ldr r7, [r7, #TSK_STACK_CANARY]
782#endif
Catalin Marinas247055a2010-09-13 16:03:21 +0100783#ifdef CONFIG_CPU_USE_DOMAINS
Linus Torvalds1da177e2005-04-16 15:20:36 -0700784 mcr p15, 0, r6, c3, c0, 0 @ Set domain register
Hyok S. Choiafeb90c2006-01-13 21:05:25 +0000785#endif
Russell Kingd6551e82006-06-21 13:31:52 +0100786 mov r5, r0
787 add r4, r2, #TI_CPU_SAVE
788 ldr r0, =thread_notify_head
789 mov r1, #THREAD_NOTIFY_SWITCH
790 bl atomic_notifier_call_chain
Nicolas Pitredf0698b2010-06-07 21:50:33 -0400791#if defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_SMP)
792 str r7, [r8]
793#endif
Catalin Marinasb86040a2009-07-24 12:32:54 +0100794 THUMB( mov ip, r4 )
Russell Kingd6551e82006-06-21 13:31:52 +0100795 mov r0, r5
Catalin Marinasb86040a2009-07-24 12:32:54 +0100796 ARM( ldmia r4, {r4 - sl, fp, sp, pc} ) @ Load all regs saved previously
797 THUMB( ldmia ip!, {r4 - sl, fp} ) @ Load all regs saved previously
798 THUMB( ldr sp, [ip], #4 )
799 THUMB( ldr pc, [ip] )
Catalin Marinasc4c57162009-02-16 11:42:09 +0100800 UNWIND(.fnend )
Catalin Marinas93ed3972008-08-28 11:22:32 +0100801ENDPROC(__switch_to)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700802
803 __INIT
Nicolas Pitre2d2669b2005-04-29 22:08:33 +0100804
805/*
806 * User helpers.
807 *
Nicolas Pitre2d2669b2005-04-29 22:08:33 +0100808 * Each segment is 32-byte aligned and will be moved to the top of the high
809 * vector page. New segments (if ever needed) must be added in front of
810 * existing ones. This mechanism should be used only for things that are
811 * really small and justified, and not be abused freely.
812 *
Nicolas Pitre37b83042011-06-19 23:36:03 -0400813 * See Documentation/arm/kernel_user_helpers.txt for formal definitions.
Nicolas Pitre2d2669b2005-04-29 22:08:33 +0100814 */
Catalin Marinasb86040a2009-07-24 12:32:54 +0100815 THUMB( .arm )
Nicolas Pitre2d2669b2005-04-29 22:08:33 +0100816
Nicolas Pitreba9b5d72006-08-18 17:20:15 +0100817 .macro usr_ret, reg
818#ifdef CONFIG_ARM_THUMB
819 bx \reg
820#else
Russell King6ebbf2c2014-06-30 16:29:12 +0100821 ret \reg
Nicolas Pitreba9b5d72006-08-18 17:20:15 +0100822#endif
823 .endm
824
Russell King5b43e7a2013-07-04 11:32:04 +0100825 .macro kuser_pad, sym, size
826 .if (. - \sym) & 3
827 .rept 4 - (. - \sym) & 3
828 .byte 0
829 .endr
830 .endif
831 .rept (\size - (. - \sym)) / 4
832 .word 0xe7fddef1
833 .endr
834 .endm
835
Russell Kingf6f91b02013-07-23 18:37:00 +0100836#ifdef CONFIG_KUSER_HELPERS
Nicolas Pitre2d2669b2005-04-29 22:08:33 +0100837 .align 5
838 .globl __kuser_helper_start
839__kuser_helper_start:
840
841/*
Nicolas Pitre40fb79c2011-06-19 23:36:03 -0400842 * Due to the length of some sequences, __kuser_cmpxchg64 spans 2 regular
843 * kuser "slots", therefore 0xffff0f80 is not used as a valid entry point.
Nicolas Pitre7c612bf2005-12-19 22:20:51 +0000844 */
845
Nicolas Pitre40fb79c2011-06-19 23:36:03 -0400846__kuser_cmpxchg64: @ 0xffff0f60
847
848#if defined(CONFIG_NEEDS_SYSCALL_FOR_CMPXCHG)
849
850 /*
851 * Poor you. No fast solution possible...
852 * The kernel itself must perform the operation.
853 * A special ghost syscall is used for that (see traps.c).
854 */
855 stmfd sp!, {r7, lr}
856 ldr r7, 1f @ it's 20 bits
857 swi __ARM_NR_cmpxchg64
858 ldmfd sp!, {r7, pc}
8591: .word __ARM_NR_cmpxchg64
860
861#elif defined(CONFIG_CPU_32v6K)
862
863 stmfd sp!, {r4, r5, r6, r7}
864 ldrd r4, r5, [r0] @ load old val
865 ldrd r6, r7, [r1] @ load new val
866 smp_dmb arm
8671: ldrexd r0, r1, [r2] @ load current val
868 eors r3, r0, r4 @ compare with oldval (1)
869 eoreqs r3, r1, r5 @ compare with oldval (2)
870 strexdeq r3, r6, r7, [r2] @ store newval if eq
871 teqeq r3, #1 @ success?
872 beq 1b @ if no then retry
873 smp_dmb arm
874 rsbs r0, r3, #0 @ set returned val and C flag
875 ldmfd sp!, {r4, r5, r6, r7}
Will Deacon5a97d0a2012-02-03 11:08:05 +0100876 usr_ret lr
Nicolas Pitre40fb79c2011-06-19 23:36:03 -0400877
878#elif !defined(CONFIG_SMP)
879
880#ifdef CONFIG_MMU
881
882 /*
883 * The only thing that can break atomicity in this cmpxchg64
884 * implementation is either an IRQ or a data abort exception
885 * causing another process/thread to be scheduled in the middle of
886 * the critical sequence. The same strategy as for cmpxchg is used.
887 */
888 stmfd sp!, {r4, r5, r6, lr}
889 ldmia r0, {r4, r5} @ load old val
890 ldmia r1, {r6, lr} @ load new val
8911: ldmia r2, {r0, r1} @ load current val
892 eors r3, r0, r4 @ compare with oldval (1)
893 eoreqs r3, r1, r5 @ compare with oldval (2)
8942: stmeqia r2, {r6, lr} @ store newval if eq
895 rsbs r0, r3, #0 @ set return val and C flag
896 ldmfd sp!, {r4, r5, r6, pc}
897
898 .text
899kuser_cmpxchg64_fixup:
900 @ Called from kuser_cmpxchg_fixup.
Russell King3ad55152011-07-22 23:09:07 +0100901 @ r4 = address of interrupted insn (must be preserved).
Nicolas Pitre40fb79c2011-06-19 23:36:03 -0400902 @ sp = saved regs. r7 and r8 are clobbered.
903 @ 1b = first critical insn, 2b = last critical insn.
Russell King3ad55152011-07-22 23:09:07 +0100904 @ If r4 >= 1b and r4 <= 2b then saved pc_usr is set to 1b.
Nicolas Pitre40fb79c2011-06-19 23:36:03 -0400905 mov r7, #0xffff0fff
906 sub r7, r7, #(0xffff0fff - (0xffff0f60 + (1b - __kuser_cmpxchg64)))
Russell King3ad55152011-07-22 23:09:07 +0100907 subs r8, r4, r7
Nicolas Pitre40fb79c2011-06-19 23:36:03 -0400908 rsbcss r8, r8, #(2b - 1b)
909 strcs r7, [sp, #S_PC]
910#if __LINUX_ARM_ARCH__ < 6
911 bcc kuser_cmpxchg32_fixup
912#endif
Russell King6ebbf2c2014-06-30 16:29:12 +0100913 ret lr
Nicolas Pitre40fb79c2011-06-19 23:36:03 -0400914 .previous
915
916#else
917#warning "NPTL on non MMU needs fixing"
918 mov r0, #-1
919 adds r0, r0, #0
920 usr_ret lr
921#endif
922
923#else
924#error "incoherent kernel configuration"
925#endif
926
Russell King5b43e7a2013-07-04 11:32:04 +0100927 kuser_pad __kuser_cmpxchg64, 64
Nicolas Pitre40fb79c2011-06-19 23:36:03 -0400928
Nicolas Pitre7c612bf2005-12-19 22:20:51 +0000929__kuser_memory_barrier: @ 0xffff0fa0
Dave Martined3768a2010-12-01 15:39:23 +0100930 smp_dmb arm
Nicolas Pitreba9b5d72006-08-18 17:20:15 +0100931 usr_ret lr
Nicolas Pitre7c612bf2005-12-19 22:20:51 +0000932
Russell King5b43e7a2013-07-04 11:32:04 +0100933 kuser_pad __kuser_memory_barrier, 32
Nicolas Pitre7c612bf2005-12-19 22:20:51 +0000934
Nicolas Pitre2d2669b2005-04-29 22:08:33 +0100935__kuser_cmpxchg: @ 0xffff0fc0
936
Nicolas Pitredcef1f62005-06-08 19:00:47 +0100937#if defined(CONFIG_NEEDS_SYSCALL_FOR_CMPXCHG)
Nicolas Pitre2d2669b2005-04-29 22:08:33 +0100938
Nicolas Pitredcef1f62005-06-08 19:00:47 +0100939 /*
940 * Poor you. No fast solution possible...
941 * The kernel itself must perform the operation.
942 * A special ghost syscall is used for that (see traps.c).
943 */
Nicolas Pitre5e097442006-01-18 22:38:49 +0000944 stmfd sp!, {r7, lr}
Dave Martin55afd262010-12-01 18:12:43 +0100945 ldr r7, 1f @ it's 20 bits
Russell Kingcc20d422009-11-09 23:53:29 +0000946 swi __ARM_NR_cmpxchg
Nicolas Pitre5e097442006-01-18 22:38:49 +0000947 ldmfd sp!, {r7, pc}
Russell Kingcc20d422009-11-09 23:53:29 +00009481: .word __ARM_NR_cmpxchg
Nicolas Pitredcef1f62005-06-08 19:00:47 +0100949
950#elif __LINUX_ARM_ARCH__ < 6
Nicolas Pitre2d2669b2005-04-29 22:08:33 +0100951
Nicolas Pitre49bca4c2006-02-08 21:19:37 +0000952#ifdef CONFIG_MMU
Nicolas Pitreb49c0f22007-11-20 17:20:29 +0100953
954 /*
955 * The only thing that can break atomicity in this cmpxchg
956 * implementation is either an IRQ or a data abort exception
957 * causing another process/thread to be scheduled in the middle
958 * of the critical sequence. To prevent this, code is added to
959 * the IRQ and data abort exception handlers to set the pc back
960 * to the beginning of the critical section if it is found to be
961 * within that critical section (see kuser_cmpxchg_fixup).
962 */
9631: ldr r3, [r2] @ load current val
964 subs r3, r3, r0 @ compare with oldval
9652: streq r1, [r2] @ store newval if eq
966 rsbs r0, r3, #0 @ set return val and C flag
967 usr_ret lr
968
969 .text
Nicolas Pitre40fb79c2011-06-19 23:36:03 -0400970kuser_cmpxchg32_fixup:
Nicolas Pitreb49c0f22007-11-20 17:20:29 +0100971 @ Called from kuser_cmpxchg_check macro.
Russell Kingb059bdc2011-06-25 15:44:20 +0100972 @ r4 = address of interrupted insn (must be preserved).
Nicolas Pitreb49c0f22007-11-20 17:20:29 +0100973 @ sp = saved regs. r7 and r8 are clobbered.
974 @ 1b = first critical insn, 2b = last critical insn.
Russell Kingb059bdc2011-06-25 15:44:20 +0100975 @ If r4 >= 1b and r4 <= 2b then saved pc_usr is set to 1b.
Nicolas Pitreb49c0f22007-11-20 17:20:29 +0100976 mov r7, #0xffff0fff
977 sub r7, r7, #(0xffff0fff - (0xffff0fc0 + (1b - __kuser_cmpxchg)))
Russell Kingb059bdc2011-06-25 15:44:20 +0100978 subs r8, r4, r7
Nicolas Pitreb49c0f22007-11-20 17:20:29 +0100979 rsbcss r8, r8, #(2b - 1b)
980 strcs r7, [sp, #S_PC]
Russell King6ebbf2c2014-06-30 16:29:12 +0100981 ret lr
Nicolas Pitreb49c0f22007-11-20 17:20:29 +0100982 .previous
983
Nicolas Pitre49bca4c2006-02-08 21:19:37 +0000984#else
985#warning "NPTL on non MMU needs fixing"
986 mov r0, #-1
987 adds r0, r0, #0
Nicolas Pitreba9b5d72006-08-18 17:20:15 +0100988 usr_ret lr
Nicolas Pitreb49c0f22007-11-20 17:20:29 +0100989#endif
Nicolas Pitre2d2669b2005-04-29 22:08:33 +0100990
991#else
992
Dave Martined3768a2010-12-01 15:39:23 +0100993 smp_dmb arm
Nicolas Pitreb49c0f22007-11-20 17:20:29 +01009941: ldrex r3, [r2]
Nicolas Pitre2d2669b2005-04-29 22:08:33 +0100995 subs r3, r3, r0
996 strexeq r3, r1, [r2]
Nicolas Pitreb49c0f22007-11-20 17:20:29 +0100997 teqeq r3, #1
998 beq 1b
Nicolas Pitre2d2669b2005-04-29 22:08:33 +0100999 rsbs r0, r3, #0
Nicolas Pitreb49c0f22007-11-20 17:20:29 +01001000 /* beware -- each __kuser slot must be 8 instructions max */
Russell Kingf00ec482010-09-04 10:47:48 +01001001 ALT_SMP(b __kuser_memory_barrier)
1002 ALT_UP(usr_ret lr)
Nicolas Pitre2d2669b2005-04-29 22:08:33 +01001003
1004#endif
1005
Russell King5b43e7a2013-07-04 11:32:04 +01001006 kuser_pad __kuser_cmpxchg, 32
Nicolas Pitre2d2669b2005-04-29 22:08:33 +01001007
Nicolas Pitre2d2669b2005-04-29 22:08:33 +01001008__kuser_get_tls: @ 0xffff0fe0
Tony Lindgrenf159f4e2010-07-05 14:53:10 +01001009 ldr r0, [pc, #(16 - 8)] @ read TLS, set in kuser_get_tls_init
Nicolas Pitreba9b5d72006-08-18 17:20:15 +01001010 usr_ret lr
Tony Lindgrenf159f4e2010-07-05 14:53:10 +01001011 mrc p15, 0, r0, c13, c0, 3 @ 0xffff0fe8 hardware TLS code
Russell King5b43e7a2013-07-04 11:32:04 +01001012 kuser_pad __kuser_get_tls, 16
1013 .rep 3
Tony Lindgrenf159f4e2010-07-05 14:53:10 +01001014 .word 0 @ 0xffff0ff0 software TLS value, then
1015 .endr @ pad up to __kuser_helper_version
Nicolas Pitre2d2669b2005-04-29 22:08:33 +01001016
Nicolas Pitre2d2669b2005-04-29 22:08:33 +01001017__kuser_helper_version: @ 0xffff0ffc
1018 .word ((__kuser_helper_end - __kuser_helper_start) >> 5)
1019
1020 .globl __kuser_helper_end
1021__kuser_helper_end:
1022
Russell Kingf6f91b02013-07-23 18:37:00 +01001023#endif
1024
Catalin Marinasb86040a2009-07-24 12:32:54 +01001025 THUMB( .thumb )
Nicolas Pitre2d2669b2005-04-29 22:08:33 +01001026
Linus Torvalds1da177e2005-04-16 15:20:36 -07001027/*
1028 * Vector stubs.
1029 *
Russell King19accfd2013-07-04 11:40:32 +01001030 * This code is copied to 0xffff1000 so we can use branches in the
1031 * vectors, rather than ldr's. Note that this code must not exceed
1032 * a page size.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001033 *
1034 * Common stub entry macro:
1035 * Enter in IRQ mode, spsr = SVC/USR CPSR, lr = SVC/USR PC
Russell Kingccea7a12005-05-31 22:22:32 +01001036 *
1037 * SP points to a minimal amount of processor-private memory, the address
1038 * of which is copied into r0 for the mode specific abort handler.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001039 */
Nicolas Pitreb7ec4792005-11-06 14:42:37 +00001040 .macro vector_stub, name, mode, correction=0
Linus Torvalds1da177e2005-04-16 15:20:36 -07001041 .align 5
1042
1043vector_\name:
Linus Torvalds1da177e2005-04-16 15:20:36 -07001044 .if \correction
1045 sub lr, lr, #\correction
1046 .endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001047
Russell Kingccea7a12005-05-31 22:22:32 +01001048 @
1049 @ Save r0, lr_<exception> (parent PC) and spsr_<exception>
1050 @ (parent CPSR)
1051 @
1052 stmia sp, {r0, lr} @ save r0, lr
1053 mrs lr, spsr
1054 str lr, [sp, #8] @ save spsr
1055
1056 @
1057 @ Prepare for SVC32 mode. IRQs remain disabled.
1058 @
1059 mrs r0, cpsr
Catalin Marinasb86040a2009-07-24 12:32:54 +01001060 eor r0, r0, #(\mode ^ SVC_MODE | PSR_ISETSTATE)
Russell Kingccea7a12005-05-31 22:22:32 +01001061 msr spsr_cxsf, r0
1062
1063 @
1064 @ the branch table must immediately follow this code
1065 @
Russell Kingccea7a12005-05-31 22:22:32 +01001066 and lr, lr, #0x0f
Catalin Marinasb86040a2009-07-24 12:32:54 +01001067 THUMB( adr r0, 1f )
1068 THUMB( ldr lr, [r0, lr, lsl #2] )
Nicolas Pitreb7ec4792005-11-06 14:42:37 +00001069 mov r0, sp
Catalin Marinasb86040a2009-07-24 12:32:54 +01001070 ARM( ldr lr, [pc, lr, lsl #2] )
Russell Kingccea7a12005-05-31 22:22:32 +01001071 movs pc, lr @ branch to handler in SVC mode
Catalin Marinas93ed3972008-08-28 11:22:32 +01001072ENDPROC(vector_\name)
Catalin Marinas88987ef2009-07-24 12:32:52 +01001073
1074 .align 2
1075 @ handler addresses follow this label
10761:
Linus Torvalds1da177e2005-04-16 15:20:36 -07001077 .endm
1078
Russell Kingb9b32bf2013-07-04 12:03:31 +01001079 .section .stubs, "ax", %progbits
Linus Torvalds1da177e2005-04-16 15:20:36 -07001080__stubs_start:
Russell King19accfd2013-07-04 11:40:32 +01001081 @ This must be the first word
1082 .word vector_swi
1083
1084vector_rst:
1085 ARM( swi SYS_ERROR0 )
1086 THUMB( svc #0 )
1087 THUMB( nop )
1088 b vector_und
1089
Linus Torvalds1da177e2005-04-16 15:20:36 -07001090/*
1091 * Interrupt dispatcher
1092 */
Nicolas Pitreb7ec4792005-11-06 14:42:37 +00001093 vector_stub irq, IRQ_MODE, 4
Linus Torvalds1da177e2005-04-16 15:20:36 -07001094
1095 .long __irq_usr @ 0 (USR_26 / USR_32)
1096 .long __irq_invalid @ 1 (FIQ_26 / FIQ_32)
1097 .long __irq_invalid @ 2 (IRQ_26 / IRQ_32)
1098 .long __irq_svc @ 3 (SVC_26 / SVC_32)
1099 .long __irq_invalid @ 4
1100 .long __irq_invalid @ 5
1101 .long __irq_invalid @ 6
1102 .long __irq_invalid @ 7
1103 .long __irq_invalid @ 8
1104 .long __irq_invalid @ 9
1105 .long __irq_invalid @ a
1106 .long __irq_invalid @ b
1107 .long __irq_invalid @ c
1108 .long __irq_invalid @ d
1109 .long __irq_invalid @ e
1110 .long __irq_invalid @ f
1111
1112/*
1113 * Data abort dispatcher
1114 * Enter in ABT mode, spsr = USR CPSR, lr = USR PC
1115 */
Nicolas Pitreb7ec4792005-11-06 14:42:37 +00001116 vector_stub dabt, ABT_MODE, 8
Linus Torvalds1da177e2005-04-16 15:20:36 -07001117
1118 .long __dabt_usr @ 0 (USR_26 / USR_32)
1119 .long __dabt_invalid @ 1 (FIQ_26 / FIQ_32)
1120 .long __dabt_invalid @ 2 (IRQ_26 / IRQ_32)
1121 .long __dabt_svc @ 3 (SVC_26 / SVC_32)
1122 .long __dabt_invalid @ 4
1123 .long __dabt_invalid @ 5
1124 .long __dabt_invalid @ 6
1125 .long __dabt_invalid @ 7
1126 .long __dabt_invalid @ 8
1127 .long __dabt_invalid @ 9
1128 .long __dabt_invalid @ a
1129 .long __dabt_invalid @ b
1130 .long __dabt_invalid @ c
1131 .long __dabt_invalid @ d
1132 .long __dabt_invalid @ e
1133 .long __dabt_invalid @ f
1134
1135/*
1136 * Prefetch abort dispatcher
1137 * Enter in ABT mode, spsr = USR CPSR, lr = USR PC
1138 */
Nicolas Pitreb7ec4792005-11-06 14:42:37 +00001139 vector_stub pabt, ABT_MODE, 4
Linus Torvalds1da177e2005-04-16 15:20:36 -07001140
1141 .long __pabt_usr @ 0 (USR_26 / USR_32)
1142 .long __pabt_invalid @ 1 (FIQ_26 / FIQ_32)
1143 .long __pabt_invalid @ 2 (IRQ_26 / IRQ_32)
1144 .long __pabt_svc @ 3 (SVC_26 / SVC_32)
1145 .long __pabt_invalid @ 4
1146 .long __pabt_invalid @ 5
1147 .long __pabt_invalid @ 6
1148 .long __pabt_invalid @ 7
1149 .long __pabt_invalid @ 8
1150 .long __pabt_invalid @ 9
1151 .long __pabt_invalid @ a
1152 .long __pabt_invalid @ b
1153 .long __pabt_invalid @ c
1154 .long __pabt_invalid @ d
1155 .long __pabt_invalid @ e
1156 .long __pabt_invalid @ f
1157
1158/*
1159 * Undef instr entry dispatcher
1160 * Enter in UND mode, spsr = SVC/USR CPSR, lr = SVC/USR PC
1161 */
Nicolas Pitreb7ec4792005-11-06 14:42:37 +00001162 vector_stub und, UND_MODE
Linus Torvalds1da177e2005-04-16 15:20:36 -07001163
1164 .long __und_usr @ 0 (USR_26 / USR_32)
1165 .long __und_invalid @ 1 (FIQ_26 / FIQ_32)
1166 .long __und_invalid @ 2 (IRQ_26 / IRQ_32)
1167 .long __und_svc @ 3 (SVC_26 / SVC_32)
1168 .long __und_invalid @ 4
1169 .long __und_invalid @ 5
1170 .long __und_invalid @ 6
1171 .long __und_invalid @ 7
1172 .long __und_invalid @ 8
1173 .long __und_invalid @ 9
1174 .long __und_invalid @ a
1175 .long __und_invalid @ b
1176 .long __und_invalid @ c
1177 .long __und_invalid @ d
1178 .long __und_invalid @ e
1179 .long __und_invalid @ f
1180
1181 .align 5
1182
1183/*=============================================================================
Russell King19accfd2013-07-04 11:40:32 +01001184 * Address exception handler
1185 *-----------------------------------------------------------------------------
1186 * These aren't too critical.
1187 * (they're not supposed to happen, and won't happen in 32-bit data mode).
1188 */
1189
1190vector_addrexcptn:
1191 b vector_addrexcptn
1192
1193/*=============================================================================
Daniel Thompsonc0e7f7e2014-09-17 17:12:06 +01001194 * FIQ "NMI" handler
Linus Torvalds1da177e2005-04-16 15:20:36 -07001195 *-----------------------------------------------------------------------------
Daniel Thompsonc0e7f7e2014-09-17 17:12:06 +01001196 * Handle a FIQ using the SVC stack allowing FIQ act like NMI on x86
1197 * systems.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001198 */
Daniel Thompsonc0e7f7e2014-09-17 17:12:06 +01001199 vector_stub fiq, FIQ_MODE, 4
1200
1201 .long __fiq_usr @ 0 (USR_26 / USR_32)
1202 .long __fiq_svc @ 1 (FIQ_26 / FIQ_32)
1203 .long __fiq_svc @ 2 (IRQ_26 / IRQ_32)
1204 .long __fiq_svc @ 3 (SVC_26 / SVC_32)
1205 .long __fiq_svc @ 4
1206 .long __fiq_svc @ 5
1207 .long __fiq_svc @ 6
1208 .long __fiq_abt @ 7
1209 .long __fiq_svc @ 8
1210 .long __fiq_svc @ 9
1211 .long __fiq_svc @ a
1212 .long __fiq_svc @ b
1213 .long __fiq_svc @ c
1214 .long __fiq_svc @ d
1215 .long __fiq_svc @ e
1216 .long __fiq_svc @ f
Linus Torvalds1da177e2005-04-16 15:20:36 -07001217
Russell Kinge39e3f32013-07-09 01:03:17 +01001218 .globl vector_fiq_offset
1219 .equ vector_fiq_offset, vector_fiq
1220
Russell Kingb9b32bf2013-07-04 12:03:31 +01001221 .section .vectors, "ax", %progbits
Russell King79335232005-04-26 15:17:42 +01001222__vectors_start:
Russell Kingb9b32bf2013-07-04 12:03:31 +01001223 W(b) vector_rst
1224 W(b) vector_und
1225 W(ldr) pc, __vectors_start + 0x1000
1226 W(b) vector_pabt
1227 W(b) vector_dabt
1228 W(b) vector_addrexcptn
1229 W(b) vector_irq
1230 W(b) vector_fiq
Linus Torvalds1da177e2005-04-16 15:20:36 -07001231
1232 .data
1233
Linus Torvalds1da177e2005-04-16 15:20:36 -07001234 .globl cr_alignment
Linus Torvalds1da177e2005-04-16 15:20:36 -07001235cr_alignment:
1236 .space 4
eric miao52108642010-12-13 09:42:34 +01001237
1238#ifdef CONFIG_MULTI_IRQ_HANDLER
1239 .globl handle_arch_irq
1240handle_arch_irq:
1241 .space 4
1242#endif