blob: 1873f653641c3b0b979018852ce094b972939035 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * linux/arch/arm/kernel/entry-common.S
3 *
4 * Copyright (C) 2000 Russell King
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070010
Linus Torvalds1da177e2005-04-16 15:20:36 -070011#include <asm/unistd.h>
Abhishek Sagar395a59d2008-06-21 23:47:27 +053012#include <asm/ftrace.h>
Catalin Marinasc4c57162009-02-16 11:42:09 +010013#include <asm/unwind.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070014
Rob Herring13a50452012-02-07 09:28:22 -060015#ifdef CONFIG_NEED_RET_TO_USER
16#include <mach/entry-macro.S>
17#else
18 .macro arch_ret_to_user, tmp1, tmp2
19 .endm
20#endif
21
Linus Torvalds1da177e2005-04-16 15:20:36 -070022#include "entry-header.S"
23
Linus Torvalds1da177e2005-04-16 15:20:36 -070024
25 .align 5
26/*
27 * This is the fast syscall return path. We do as little as
28 * possible here, and this includes saving r0 back into the SVC
29 * stack.
30 */
31ret_fast_syscall:
Catalin Marinasc4c57162009-02-16 11:42:09 +010032 UNWIND(.fnstart )
33 UNWIND(.cantunwind )
Russell King1ec42c02005-04-26 15:18:26 +010034 disable_irq @ disable interrupts
Linus Torvalds1da177e2005-04-16 15:20:36 -070035 ldr r1, [tsk, #TI_FLAGS]
36 tst r1, #_TIF_WORK_MASK
37 bne fast_work_pending
Todd Android Poynord13e5ed2010-12-23 01:52:44 +010038#if defined(CONFIG_IRQSOFF_TRACER)
39 asm_trace_hardirqs_on
40#endif
Russell Kingf4dc9a42005-04-26 15:20:34 +010041
Dan Williamsf80dff92007-02-16 22:16:32 +010042 /* perform architecture specific actions before user return */
43 arch_ret_to_user r1, lr
44
Catalin Marinasb86040a2009-07-24 12:32:54 +010045 restore_user_regs fast = 1, offset = S_OFF
Catalin Marinasc4c57162009-02-16 11:42:09 +010046 UNWIND(.fnend )
Linus Torvalds1da177e2005-04-16 15:20:36 -070047
48/*
49 * Ok, we need to do extra processing, enter the slow path.
50 */
51fast_work_pending:
52 str r0, [sp, #S_R0+S_OFF]! @ returned r0
53work_pending:
Linus Torvalds1da177e2005-04-16 15:20:36 -070054 mov r0, sp @ 'regs'
55 mov r2, why @ 'syscall'
Al Viro0a267fa2012-07-19 17:47:55 +010056 bl do_work_pending
57 b no_work_pending
Linus Torvalds1da177e2005-04-16 15:20:36 -070058/*
59 * "slow" syscall return path. "why" tells us if this was a real syscall.
60 */
61ENTRY(ret_to_user)
62ret_slow_syscall:
Russell King1ec42c02005-04-26 15:18:26 +010063 disable_irq @ disable interrupts
Ming Lei9fc25522011-06-05 02:24:58 +010064ENTRY(ret_to_user_from_irq)
Linus Torvalds1da177e2005-04-16 15:20:36 -070065 ldr r1, [tsk, #TI_FLAGS]
66 tst r1, #_TIF_WORK_MASK
67 bne work_pending
68no_work_pending:
Todd Android Poynord13e5ed2010-12-23 01:52:44 +010069#if defined(CONFIG_IRQSOFF_TRACER)
70 asm_trace_hardirqs_on
71#endif
Dan Williamsf80dff92007-02-16 22:16:32 +010072 /* perform architecture specific actions before user return */
73 arch_ret_to_user r1, lr
74
Catalin Marinasb86040a2009-07-24 12:32:54 +010075 restore_user_regs fast = 0, offset = 0
Ming Lei9fc25522011-06-05 02:24:58 +010076ENDPROC(ret_to_user_from_irq)
Catalin Marinas93ed3972008-08-28 11:22:32 +010077ENDPROC(ret_to_user)
Linus Torvalds1da177e2005-04-16 15:20:36 -070078
79/*
80 * This is how we return from a fork.
81 */
82ENTRY(ret_from_fork)
83 bl schedule_tail
84 get_thread_info tsk
Linus Torvalds1da177e2005-04-16 15:20:36 -070085 mov why, #1
Linus Torvalds1da177e2005-04-16 15:20:36 -070086 b ret_slow_syscall
Catalin Marinas93ed3972008-08-28 11:22:32 +010087ENDPROC(ret_from_fork)
Linus Torvalds1da177e2005-04-16 15:20:36 -070088
Al Virofa1b4f92006-01-19 12:57:01 +000089 .equ NR_syscalls,0
90#define CALL(x) .equ NR_syscalls,NR_syscalls+1
Linus Torvalds1da177e2005-04-16 15:20:36 -070091#include "calls.S"
Al Virofa1b4f92006-01-19 12:57:01 +000092#undef CALL
93#define CALL(x) .long x
Linus Torvalds1da177e2005-04-16 15:20:36 -070094
Steven Rostedt606576c2008-10-06 19:06:12 -040095#ifdef CONFIG_FUNCTION_TRACER
Rabin Vincent686ff222010-08-03 17:09:40 +010096/*
97 * When compiling with -pg, gcc inserts a call to the mcount routine at the
98 * start of every function. In mcount, apart from the function's address (in
99 * lr), we need to get hold of the function's caller's address.
100 *
101 * Older GCCs (pre-4.4) inserted a call to a routine called mcount like this:
102 *
103 * bl mcount
104 *
105 * These versions have the limitation that in order for the mcount routine to
106 * be able to determine the function's caller's address, an APCS-style frame
107 * pointer (which is set up with something like the code below) is required.
108 *
109 * mov ip, sp
110 * push {fp, ip, lr, pc}
111 * sub fp, ip, #4
112 *
113 * With EABI, these frame pointers are not available unless -mapcs-frame is
114 * specified, and if building as Thumb-2, not even then.
115 *
116 * Newer GCCs (4.4+) solve this problem by introducing a new version of mcount,
117 * with call sites like:
118 *
119 * push {lr}
120 * bl __gnu_mcount_nc
121 *
122 * With these compilers, frame pointers are not necessary.
123 *
124 * mcount can be thought of as a function called in the middle of a subroutine
125 * call. As such, it needs to be transparent for both the caller and the
126 * callee: the original lr needs to be restored when leaving mcount, and no
127 * registers should be clobbered. (In the __gnu_mcount_nc implementation, we
128 * clobber the ip register. This is OK because the ARM calling convention
129 * allows it to be clobbered in subroutines and doesn't use it to hold
130 * parameters.)
Rabin Vincent3b6c2232010-08-10 19:43:28 +0100131 *
132 * When using dynamic ftrace, we patch out the mcount call by a "mov r0, r0"
133 * for the mcount case, and a "pop {lr}" for the __gnu_mcount_nc case (see
134 * arch/arm/kernel/ftrace.c).
Rabin Vincent686ff222010-08-03 17:09:40 +0100135 */
Rabin Vincent09bfafa2010-08-10 19:32:37 +0100136
137#ifndef CONFIG_OLD_MCOUNT
138#if (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 4))
139#error Ftrace requires CONFIG_FRAME_POINTER=y with GCC older than 4.4.0.
140#endif
141#endif
142
Rabin Vincentd68133b2012-01-24 16:52:52 +0100143.macro mcount_adjust_addr rd, rn
144 bic \rd, \rn, #1 @ clear the Thumb bit if present
145 sub \rd, \rd, #MCOUNT_INSN_SIZE
146.endm
147
Rabin Vincentd3b9dc92010-10-07 17:39:47 +0530148.macro __mcount suffix
149 mcount_enter
Rabin Vincent28e192d2010-08-03 17:08:09 +0100150 ldr r0, =ftrace_trace_function
151 ldr r2, [r0]
Rabin Vincenta3ba87a2010-08-10 19:37:21 +0100152 adr r0, .Lftrace_stub
Rabin Vincent28e192d2010-08-03 17:08:09 +0100153 cmp r0, r2
Rabin Vincentd3b9dc92010-10-07 17:39:47 +0530154 bne 1f
Uwe Kleine-König181f8172009-08-13 20:38:16 +0200155
Tim Bird376cfa82010-10-09 22:24:38 +0530156#ifdef CONFIG_FUNCTION_GRAPH_TRACER
157 ldr r1, =ftrace_graph_return
158 ldr r2, [r1]
159 cmp r0, r2
160 bne ftrace_graph_caller\suffix
161
162 ldr r1, =ftrace_graph_entry
163 ldr r2, [r1]
164 ldr r0, =ftrace_graph_entry_stub
165 cmp r0, r2
166 bne ftrace_graph_caller\suffix
167#endif
168
Rabin Vincentd3b9dc92010-10-07 17:39:47 +0530169 mcount_exit
Uwe Kleine-König181f8172009-08-13 20:38:16 +0200170
Rabin Vincentd3b9dc92010-10-07 17:39:47 +05301711: mcount_get_lr r1 @ lr of instrumented func
Rabin Vincentd68133b2012-01-24 16:52:52 +0100172 mcount_adjust_addr r0, lr @ instrumented function
Rabin Vincentd3b9dc92010-10-07 17:39:47 +0530173 adr lr, BSYM(2f)
Rabin Vincent28e192d2010-08-03 17:08:09 +0100174 mov pc, r2
Rabin Vincentd3b9dc92010-10-07 17:39:47 +05301752: mcount_exit
176.endm
177
178.macro __ftrace_caller suffix
179 mcount_enter
180
181 mcount_get_lr r1 @ lr of instrumented func
Rabin Vincentd68133b2012-01-24 16:52:52 +0100182 mcount_adjust_addr r0, lr @ instrumented function
Rabin Vincentd3b9dc92010-10-07 17:39:47 +0530183
184 .globl ftrace_call\suffix
185ftrace_call\suffix:
186 bl ftrace_stub
187
Rabin Vincentdd686eb2010-11-06 23:03:21 +0530188#ifdef CONFIG_FUNCTION_GRAPH_TRACER
189 .globl ftrace_graph_call\suffix
190ftrace_graph_call\suffix:
191 mov r0, r0
192#endif
193
Rabin Vincentd3b9dc92010-10-07 17:39:47 +0530194 mcount_exit
195.endm
Uwe Kleine-König181f8172009-08-13 20:38:16 +0200196
Tim Bird376cfa82010-10-09 22:24:38 +0530197.macro __ftrace_graph_caller
198 sub r0, fp, #4 @ &lr of instrumented routine (&parent)
Rabin Vincentdd686eb2010-11-06 23:03:21 +0530199#ifdef CONFIG_DYNAMIC_FTRACE
200 @ called from __ftrace_caller, saved in mcount_enter
201 ldr r1, [sp, #16] @ instrumented routine (func)
Rabin Vincentd68133b2012-01-24 16:52:52 +0100202 mcount_adjust_addr r1, r1
Rabin Vincentdd686eb2010-11-06 23:03:21 +0530203#else
204 @ called from __mcount, untouched in lr
Rabin Vincentd68133b2012-01-24 16:52:52 +0100205 mcount_adjust_addr r1, lr @ instrumented routine (func)
Rabin Vincentdd686eb2010-11-06 23:03:21 +0530206#endif
Tim Bird376cfa82010-10-09 22:24:38 +0530207 mov r2, fp @ frame pointer
208 bl prepare_ftrace_return
209 mcount_exit
210.endm
Abhishek Sagar014c2572008-05-31 14:23:50 +0530211
Rabin Vincent09bfafa2010-08-10 19:32:37 +0100212#ifdef CONFIG_OLD_MCOUNT
213/*
Rabin Vincentd3b9dc92010-10-07 17:39:47 +0530214 * mcount
Rabin Vincent09bfafa2010-08-10 19:32:37 +0100215 */
Abhishek Sagar014c2572008-05-31 14:23:50 +0530216
Rabin Vincentd3b9dc92010-10-07 17:39:47 +0530217.macro mcount_enter
218 stmdb sp!, {r0-r3, lr}
219.endm
220
221.macro mcount_get_lr reg
222 ldr \reg, [fp, #-4]
223.endm
224
225.macro mcount_exit
226 ldr lr, [fp, #-4]
Rabin Vincent28e192d2010-08-03 17:08:09 +0100227 ldmia sp!, {r0-r3, pc}
Rabin Vincentd3b9dc92010-10-07 17:39:47 +0530228.endm
229
230ENTRY(mcount)
231#ifdef CONFIG_DYNAMIC_FTRACE
232 stmdb sp!, {lr}
233 ldr lr, [fp, #-4]
234 ldmia sp!, {pc}
235#else
236 __mcount _old
237#endif
Rabin Vincent72fa62f2010-08-10 19:33:52 +0100238ENDPROC(mcount)
Rabin Vincentd3b9dc92010-10-07 17:39:47 +0530239
240#ifdef CONFIG_DYNAMIC_FTRACE
241ENTRY(ftrace_caller_old)
242 __ftrace_caller _old
243ENDPROC(ftrace_caller_old)
Rabin Vincent09bfafa2010-08-10 19:32:37 +0100244#endif
Abhishek Sagar014c2572008-05-31 14:23:50 +0530245
Tim Bird376cfa82010-10-09 22:24:38 +0530246#ifdef CONFIG_FUNCTION_GRAPH_TRACER
247ENTRY(ftrace_graph_caller_old)
248 __ftrace_graph_caller
249ENDPROC(ftrace_graph_caller_old)
250#endif
251
Rabin Vincentd3b9dc92010-10-07 17:39:47 +0530252.purgem mcount_enter
253.purgem mcount_get_lr
254.purgem mcount_exit
255#endif
256
257/*
258 * __gnu_mcount_nc
259 */
260
261.macro mcount_enter
262 stmdb sp!, {r0-r3, lr}
263.endm
264
265.macro mcount_get_lr reg
266 ldr \reg, [sp, #20]
267.endm
268
269.macro mcount_exit
270 ldmia sp!, {r0-r3, ip, lr}
271 mov pc, ip
272.endm
273
274ENTRY(__gnu_mcount_nc)
275#ifdef CONFIG_DYNAMIC_FTRACE
276 mov ip, lr
277 ldmia sp!, {lr}
278 mov pc, ip
279#else
280 __mcount
281#endif
282ENDPROC(__gnu_mcount_nc)
283
284#ifdef CONFIG_DYNAMIC_FTRACE
285ENTRY(ftrace_caller)
286 __ftrace_caller
287ENDPROC(ftrace_caller)
288#endif
289
Tim Bird376cfa82010-10-09 22:24:38 +0530290#ifdef CONFIG_FUNCTION_GRAPH_TRACER
291ENTRY(ftrace_graph_caller)
292 __ftrace_graph_caller
293ENDPROC(ftrace_graph_caller)
294#endif
295
Rabin Vincentd3b9dc92010-10-07 17:39:47 +0530296.purgem mcount_enter
297.purgem mcount_get_lr
298.purgem mcount_exit
Abhishek Sagar014c2572008-05-31 14:23:50 +0530299
Tim Bird376cfa82010-10-09 22:24:38 +0530300#ifdef CONFIG_FUNCTION_GRAPH_TRACER
301 .globl return_to_handler
302return_to_handler:
303 stmdb sp!, {r0-r3}
304 mov r0, fp @ frame pointer
305 bl ftrace_return_to_handler
306 mov lr, r0 @ r0 has real ret addr
307 ldmia sp!, {r0-r3}
308 mov pc, lr
309#endif
Abhishek Sagar014c2572008-05-31 14:23:50 +0530310
Rabin Vincent72fa62f2010-08-10 19:33:52 +0100311ENTRY(ftrace_stub)
Rabin Vincenta3ba87a2010-08-10 19:37:21 +0100312.Lftrace_stub:
Rabin Vincent28e192d2010-08-03 17:08:09 +0100313 mov pc, lr
Rabin Vincent72fa62f2010-08-10 19:33:52 +0100314ENDPROC(ftrace_stub)
Abhishek Sagar014c2572008-05-31 14:23:50 +0530315
Steven Rostedt606576c2008-10-06 19:06:12 -0400316#endif /* CONFIG_FUNCTION_TRACER */
Abhishek Sagar014c2572008-05-31 14:23:50 +0530317
Linus Torvalds1da177e2005-04-16 15:20:36 -0700318/*=============================================================================
319 * SWI handler
320 *-----------------------------------------------------------------------------
321 */
322
Linus Torvalds1da177e2005-04-16 15:20:36 -0700323 .align 5
324ENTRY(vector_swi)
Russell Kingf4dc9a42005-04-26 15:20:34 +0100325 sub sp, sp, #S_FRAME_SIZE
326 stmia sp, {r0 - r12} @ Calling r0 - r12
Catalin Marinasb86040a2009-07-24 12:32:54 +0100327 ARM( add r8, sp, #S_PC )
328 ARM( stmdb r8, {sp, lr}^ ) @ Calling sp, lr
329 THUMB( mov r8, sp )
330 THUMB( store_user_sp_lr r8, r10, S_SP ) @ calling sp, lr
Russell Kingf4dc9a42005-04-26 15:20:34 +0100331 mrs r8, spsr @ called from non-FIQ mode, so ok.
332 str lr, [sp, #S_PC] @ Save calling PC
333 str r8, [sp, #S_PSR] @ Save CPSR
334 str r0, [sp, #S_OLD_R0] @ Save OLD_R0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700335 zero_fp
Russell Kinge0f9f4a2005-04-26 15:19:24 +0100336
337 /*
338 * Get the system call number.
339 */
Nicolas Pitre3f2829a2006-01-14 16:31:29 +0000340
Nicolas Pitredd35afc2006-01-14 16:36:12 +0000341#if defined(CONFIG_OABI_COMPAT)
Nicolas Pitre3f2829a2006-01-14 16:31:29 +0000342
Nicolas Pitredd35afc2006-01-14 16:36:12 +0000343 /*
344 * If we have CONFIG_OABI_COMPAT then we need to look at the swi
345 * value to determine if it is an EABI or an old ABI call.
346 */
347#ifdef CONFIG_ARM_THUMB
348 tst r8, #PSR_T_BIT
349 movne r10, #0 @ no thumb OABI emulation
350 ldreq r10, [lr, #-4] @ get SWI instruction
351#else
352 ldr r10, [lr, #-4] @ get SWI instruction
Nicolas Pitredd35afc2006-01-14 16:36:12 +0000353#endif
Catalin Marinas26584852009-05-30 14:00:18 +0100354#ifdef CONFIG_CPU_ENDIAN_BE8
355 rev r10, r10 @ little endian instruction
356#endif
Nicolas Pitredd35afc2006-01-14 16:36:12 +0000357
358#elif defined(CONFIG_AEABI)
359
360 /*
361 * Pure EABI user space always put syscall number into scno (r7).
362 */
Nicolas Pitre3f2829a2006-01-14 16:31:29 +0000363#elif defined(CONFIG_ARM_THUMB)
Nicolas Pitredd35afc2006-01-14 16:36:12 +0000364 /* Legacy ABI only, possibly thumb mode. */
Russell Kinge0f9f4a2005-04-26 15:19:24 +0100365 tst r8, #PSR_T_BIT @ this is SPSR from save_user_regs
366 addne scno, r7, #__NR_SYSCALL_BASE @ put OS number in
367 ldreq scno, [lr, #-4]
Nicolas Pitredd35afc2006-01-14 16:36:12 +0000368
Russell Kinge0f9f4a2005-04-26 15:19:24 +0100369#else
Nicolas Pitredd35afc2006-01-14 16:36:12 +0000370 /* Legacy ABI only. */
Russell Kinge0f9f4a2005-04-26 15:19:24 +0100371 ldr scno, [lr, #-4] @ get SWI instruction
372#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700373
374#ifdef CONFIG_ALIGNMENT_TRAP
375 ldr ip, __cr_alignment
376 ldr ip, [ip]
377 mcr p15, 0, ip, c1, c0 @ update control register
378#endif
Russell King1ec42c02005-04-26 15:18:26 +0100379 enable_irq
Linus Torvalds1da177e2005-04-16 15:20:36 -0700380
Linus Torvalds1da177e2005-04-16 15:20:36 -0700381 get_thread_info tsk
Nicolas Pitredd35afc2006-01-14 16:36:12 +0000382 adr tbl, sys_call_table @ load syscall table pointer
Nicolas Pitredd35afc2006-01-14 16:36:12 +0000383
384#if defined(CONFIG_OABI_COMPAT)
385 /*
386 * If the swi argument is zero, this is an EABI call and we do nothing.
387 *
388 * If this is an old ABI call, get the syscall number into scno and
389 * get the old ABI syscall table address.
390 */
391 bics r10, r10, #0xff000000
392 eorne scno, r10, #__NR_OABI_SYSCALL_BASE
393 ldrne tbl, =sys_oabi_call_table
394#elif !defined(CONFIG_AEABI)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700395 bic scno, scno, #0xff000000 @ mask off SWI op-code
Russell Kinge0f9f4a2005-04-26 15:19:24 +0100396 eor scno, scno, #__NR_SYSCALL_BASE @ check OS number
Nicolas Pitre3f2829a2006-01-14 16:31:29 +0000397#endif
Nicolas Pitredd35afc2006-01-14 16:36:12 +0000398
Nicolas Pitre70c70d92010-08-26 15:08:35 -0700399 ldr r10, [tsk, #TI_FLAGS] @ check for syscall tracing
Nicolas Pitre3f2829a2006-01-14 16:31:29 +0000400 stmdb sp!, {r4, r5} @ push fifth and sixth args
Nicolas Pitre70c70d92010-08-26 15:08:35 -0700401
402#ifdef CONFIG_SECCOMP
403 tst r10, #_TIF_SECCOMP
404 beq 1f
405 mov r0, scno
406 bl __secure_computing
407 add r0, sp, #S_R0 + S_OFF @ pointer to regs
408 ldmia r0, {r0 - r3} @ have to reload r0 - r3
4091:
410#endif
411
Nathaniel Husted29ef73b2012-01-03 14:23:09 -0500412 tst r10, #_TIF_SYSCALL_WORK @ are we tracing syscalls?
Linus Torvalds1da177e2005-04-16 15:20:36 -0700413 bne __sys_trace
414
Linus Torvalds1da177e2005-04-16 15:20:36 -0700415 cmp scno, #NR_syscalls @ check upper syscall limit
Catalin Marinasb86040a2009-07-24 12:32:54 +0100416 adr lr, BSYM(ret_fast_syscall) @ return address
Linus Torvalds1da177e2005-04-16 15:20:36 -0700417 ldrcc pc, [tbl, scno, lsl #2] @ call sys_* routine
418
419 add r1, sp, #S_OFF
4202: mov why, #0 @ no longer a real syscall
Russell Kinge0f9f4a2005-04-26 15:19:24 +0100421 cmp scno, #(__ARM_NR_BASE - __NR_SYSCALL_BASE)
422 eor r0, scno, #__NR_SYSCALL_BASE @ put OS number back
Linus Torvalds1da177e2005-04-16 15:20:36 -0700423 bcs arm_syscall
424 b sys_ni_syscall @ not private func
Catalin Marinas93ed3972008-08-28 11:22:32 +0100425ENDPROC(vector_swi)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700426
427 /*
428 * This is the really slow path. We're going to be doing
429 * context switches, and waiting for our parent to respond.
430 */
431__sys_trace:
Will Deaconad722542012-07-06 15:50:14 +0100432 mov r1, scno
433 add r0, sp, #S_OFF
434 bl syscall_trace_enter
Linus Torvalds1da177e2005-04-16 15:20:36 -0700435
Catalin Marinasb86040a2009-07-24 12:32:54 +0100436 adr lr, BSYM(__sys_trace_return) @ return address
Nicolas Pitre3f471122006-01-14 19:30:04 +0000437 mov scno, r0 @ syscall number (possibly new)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700438 add r1, sp, #S_R0 + S_OFF @ pointer to regs
439 cmp scno, #NR_syscalls @ check upper syscall limit
440 ldmccia r1, {r0 - r3} @ have to reload r0 - r3
441 ldrcc pc, [tbl, scno, lsl #2] @ call sys_* routine
442 b 2b
443
444__sys_trace_return:
445 str r0, [sp, #S_R0 + S_OFF]! @ save returned r0
Will Deaconad722542012-07-06 15:50:14 +0100446 mov r1, scno
447 mov r0, sp
448 bl syscall_trace_exit
Linus Torvalds1da177e2005-04-16 15:20:36 -0700449 b ret_slow_syscall
450
451 .align 5
452#ifdef CONFIG_ALIGNMENT_TRAP
453 .type __cr_alignment, #object
454__cr_alignment:
455 .word cr_alignment
456#endif
Nicolas Pitredd35afc2006-01-14 16:36:12 +0000457 .ltorg
458
459/*
460 * This is the syscall table declaration for native ABI syscalls.
461 * With EABI a couple syscalls are obsolete and defined as sys_ni_syscall.
462 */
463#define ABI(native, compat) native
464#ifdef CONFIG_AEABI
465#define OBSOLETE(syscall) sys_ni_syscall
466#else
467#define OBSOLETE(syscall) syscall
468#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700469
470 .type sys_call_table, #object
471ENTRY(sys_call_table)
472#include "calls.S"
Nicolas Pitredd35afc2006-01-14 16:36:12 +0000473#undef ABI
474#undef OBSOLETE
Linus Torvalds1da177e2005-04-16 15:20:36 -0700475
476/*============================================================================
477 * Special system call wrappers
478 */
479@ r0 = syscall number
Russell King567bd982005-12-17 15:25:42 +0000480@ r8 = syscall table
Linus Torvalds1da177e2005-04-16 15:20:36 -0700481sys_syscall:
Paul Brook52475932006-05-16 14:25:55 +0100482 bic scno, r0, #__NR_OABI_SYSCALL_BASE
Linus Torvalds1da177e2005-04-16 15:20:36 -0700483 cmp scno, #__NR_syscall - __NR_SYSCALL_BASE
484 cmpne scno, #NR_syscalls @ check range
485 stmloia sp, {r5, r6} @ shuffle args
486 movlo r0, r1
487 movlo r1, r2
488 movlo r2, r3
489 movlo r3, r4
490 ldrlo pc, [tbl, scno, lsl #2]
491 b sys_ni_syscall
Catalin Marinas93ed3972008-08-28 11:22:32 +0100492ENDPROC(sys_syscall)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700493
494sys_fork_wrapper:
495 add r0, sp, #S_OFF
496 b sys_fork
Catalin Marinas93ed3972008-08-28 11:22:32 +0100497ENDPROC(sys_fork_wrapper)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700498
499sys_vfork_wrapper:
500 add r0, sp, #S_OFF
501 b sys_vfork
Catalin Marinas93ed3972008-08-28 11:22:32 +0100502ENDPROC(sys_vfork_wrapper)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700503
504sys_execve_wrapper:
505 add r3, sp, #S_OFF
506 b sys_execve
Catalin Marinas93ed3972008-08-28 11:22:32 +0100507ENDPROC(sys_execve_wrapper)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700508
509sys_clone_wrapper:
510 add ip, sp, #S_OFF
511 str ip, [sp, #4]
512 b sys_clone
Catalin Marinas93ed3972008-08-28 11:22:32 +0100513ENDPROC(sys_clone_wrapper)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700514
Linus Torvalds1da177e2005-04-16 15:20:36 -0700515sys_sigreturn_wrapper:
516 add r0, sp, #S_OFF
Al Viro653d48b2010-09-17 14:34:39 +0100517 mov why, #0 @ prevent syscall restart handling
Linus Torvalds1da177e2005-04-16 15:20:36 -0700518 b sys_sigreturn
Catalin Marinas93ed3972008-08-28 11:22:32 +0100519ENDPROC(sys_sigreturn_wrapper)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700520
521sys_rt_sigreturn_wrapper:
522 add r0, sp, #S_OFF
Al Viro653d48b2010-09-17 14:34:39 +0100523 mov why, #0 @ prevent syscall restart handling
Linus Torvalds1da177e2005-04-16 15:20:36 -0700524 b sys_rt_sigreturn
Catalin Marinas93ed3972008-08-28 11:22:32 +0100525ENDPROC(sys_rt_sigreturn_wrapper)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700526
527sys_sigaltstack_wrapper:
528 ldr r2, [sp, #S_OFF + S_SP]
529 b do_sigaltstack
Catalin Marinas93ed3972008-08-28 11:22:32 +0100530ENDPROC(sys_sigaltstack_wrapper)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700531
Nicolas Pitre713c4812006-01-14 16:35:03 +0000532sys_statfs64_wrapper:
533 teq r1, #88
534 moveq r1, #84
535 b sys_statfs64
Catalin Marinas93ed3972008-08-28 11:22:32 +0100536ENDPROC(sys_statfs64_wrapper)
Nicolas Pitre713c4812006-01-14 16:35:03 +0000537
538sys_fstatfs64_wrapper:
539 teq r1, #88
540 moveq r1, #84
541 b sys_fstatfs64
Catalin Marinas93ed3972008-08-28 11:22:32 +0100542ENDPROC(sys_fstatfs64_wrapper)
Nicolas Pitre713c4812006-01-14 16:35:03 +0000543
Linus Torvalds1da177e2005-04-16 15:20:36 -0700544/*
545 * Note: off_4k (r5) is always units of 4K. If we can't do the requested
546 * offset, we return EINVAL.
547 */
548sys_mmap2:
549#if PAGE_SHIFT > 12
550 tst r5, #PGOFF_MASK
551 moveq r5, r5, lsr #PAGE_SHIFT - 12
552 streq r5, [sp, #4]
Al Virof8b72562009-11-30 17:37:04 -0500553 beq sys_mmap_pgoff
Linus Torvalds1da177e2005-04-16 15:20:36 -0700554 mov r0, #-EINVAL
Russell King7999d8d2006-06-25 11:17:23 +0100555 mov pc, lr
Linus Torvalds1da177e2005-04-16 15:20:36 -0700556#else
557 str r5, [sp, #4]
Al Virof8b72562009-11-30 17:37:04 -0500558 b sys_mmap_pgoff
Linus Torvalds1da177e2005-04-16 15:20:36 -0700559#endif
Catalin Marinas93ed3972008-08-28 11:22:32 +0100560ENDPROC(sys_mmap2)
Nicolas Pitre687ad012006-01-14 16:35:31 +0000561
562#ifdef CONFIG_OABI_COMPAT
Nicolas Pitredd35afc2006-01-14 16:36:12 +0000563
Nicolas Pitre687ad012006-01-14 16:35:31 +0000564/*
565 * These are syscalls with argument register differences
566 */
567
568sys_oabi_pread64:
569 stmia sp, {r3, r4}
570 b sys_pread64
Catalin Marinas93ed3972008-08-28 11:22:32 +0100571ENDPROC(sys_oabi_pread64)
Nicolas Pitre687ad012006-01-14 16:35:31 +0000572
573sys_oabi_pwrite64:
574 stmia sp, {r3, r4}
575 b sys_pwrite64
Catalin Marinas93ed3972008-08-28 11:22:32 +0100576ENDPROC(sys_oabi_pwrite64)
Nicolas Pitre687ad012006-01-14 16:35:31 +0000577
578sys_oabi_truncate64:
579 mov r3, r2
580 mov r2, r1
581 b sys_truncate64
Catalin Marinas93ed3972008-08-28 11:22:32 +0100582ENDPROC(sys_oabi_truncate64)
Nicolas Pitre687ad012006-01-14 16:35:31 +0000583
584sys_oabi_ftruncate64:
585 mov r3, r2
586 mov r2, r1
587 b sys_ftruncate64
Catalin Marinas93ed3972008-08-28 11:22:32 +0100588ENDPROC(sys_oabi_ftruncate64)
Nicolas Pitre687ad012006-01-14 16:35:31 +0000589
590sys_oabi_readahead:
591 str r3, [sp]
592 mov r3, r2
593 mov r2, r1
594 b sys_readahead
Catalin Marinas93ed3972008-08-28 11:22:32 +0100595ENDPROC(sys_oabi_readahead)
Nicolas Pitre687ad012006-01-14 16:35:31 +0000596
Nicolas Pitredd35afc2006-01-14 16:36:12 +0000597/*
598 * Let's declare a second syscall table for old ABI binaries
599 * using the compatibility syscall entries.
600 */
601#define ABI(native, compat) compat
602#define OBSOLETE(syscall) syscall
603
604 .type sys_oabi_call_table, #object
605ENTRY(sys_oabi_call_table)
606#include "calls.S"
607#undef ABI
608#undef OBSOLETE
609
Nicolas Pitre687ad012006-01-14 16:35:31 +0000610#endif
611