blob: 8ae58c47dce6f69129364b4800fce33622f3bd84 [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
Al Viro81783782012-07-19 17:48:21 +010057 tst r0, #1
58 beq no_work_pending
59 ldmia sp, {r0 - r6} @ have to reload r0 - r6
60 b local_restart @ ... and off we go
61
Linus Torvalds1da177e2005-04-16 15:20:36 -070062/*
63 * "slow" syscall return path. "why" tells us if this was a real syscall.
64 */
65ENTRY(ret_to_user)
66ret_slow_syscall:
Russell King1ec42c02005-04-26 15:18:26 +010067 disable_irq @ disable interrupts
Ming Lei9fc25522011-06-05 02:24:58 +010068ENTRY(ret_to_user_from_irq)
Linus Torvalds1da177e2005-04-16 15:20:36 -070069 ldr r1, [tsk, #TI_FLAGS]
70 tst r1, #_TIF_WORK_MASK
71 bne work_pending
72no_work_pending:
Todd Android Poynord13e5ed2010-12-23 01:52:44 +010073#if defined(CONFIG_IRQSOFF_TRACER)
74 asm_trace_hardirqs_on
75#endif
Dan Williamsf80dff92007-02-16 22:16:32 +010076 /* perform architecture specific actions before user return */
77 arch_ret_to_user r1, lr
78
Catalin Marinasb86040a2009-07-24 12:32:54 +010079 restore_user_regs fast = 0, offset = 0
Ming Lei9fc25522011-06-05 02:24:58 +010080ENDPROC(ret_to_user_from_irq)
Catalin Marinas93ed3972008-08-28 11:22:32 +010081ENDPROC(ret_to_user)
Linus Torvalds1da177e2005-04-16 15:20:36 -070082
83/*
84 * This is how we return from a fork.
85 */
86ENTRY(ret_from_fork)
87 bl schedule_tail
88 get_thread_info tsk
Linus Torvalds1da177e2005-04-16 15:20:36 -070089 mov why, #1
Linus Torvalds1da177e2005-04-16 15:20:36 -070090 b ret_slow_syscall
Catalin Marinas93ed3972008-08-28 11:22:32 +010091ENDPROC(ret_from_fork)
Linus Torvalds1da177e2005-04-16 15:20:36 -070092
Al Virofa1b4f92006-01-19 12:57:01 +000093 .equ NR_syscalls,0
94#define CALL(x) .equ NR_syscalls,NR_syscalls+1
Linus Torvalds1da177e2005-04-16 15:20:36 -070095#include "calls.S"
Al Virofa1b4f92006-01-19 12:57:01 +000096#undef CALL
97#define CALL(x) .long x
Linus Torvalds1da177e2005-04-16 15:20:36 -070098
Steven Rostedt606576c2008-10-06 19:06:12 -040099#ifdef CONFIG_FUNCTION_TRACER
Rabin Vincent686ff222010-08-03 17:09:40 +0100100/*
101 * When compiling with -pg, gcc inserts a call to the mcount routine at the
102 * start of every function. In mcount, apart from the function's address (in
103 * lr), we need to get hold of the function's caller's address.
104 *
105 * Older GCCs (pre-4.4) inserted a call to a routine called mcount like this:
106 *
107 * bl mcount
108 *
109 * These versions have the limitation that in order for the mcount routine to
110 * be able to determine the function's caller's address, an APCS-style frame
111 * pointer (which is set up with something like the code below) is required.
112 *
113 * mov ip, sp
114 * push {fp, ip, lr, pc}
115 * sub fp, ip, #4
116 *
117 * With EABI, these frame pointers are not available unless -mapcs-frame is
118 * specified, and if building as Thumb-2, not even then.
119 *
120 * Newer GCCs (4.4+) solve this problem by introducing a new version of mcount,
121 * with call sites like:
122 *
123 * push {lr}
124 * bl __gnu_mcount_nc
125 *
126 * With these compilers, frame pointers are not necessary.
127 *
128 * mcount can be thought of as a function called in the middle of a subroutine
129 * call. As such, it needs to be transparent for both the caller and the
130 * callee: the original lr needs to be restored when leaving mcount, and no
131 * registers should be clobbered. (In the __gnu_mcount_nc implementation, we
132 * clobber the ip register. This is OK because the ARM calling convention
133 * allows it to be clobbered in subroutines and doesn't use it to hold
134 * parameters.)
Rabin Vincent3b6c2232010-08-10 19:43:28 +0100135 *
136 * When using dynamic ftrace, we patch out the mcount call by a "mov r0, r0"
137 * for the mcount case, and a "pop {lr}" for the __gnu_mcount_nc case (see
138 * arch/arm/kernel/ftrace.c).
Rabin Vincent686ff222010-08-03 17:09:40 +0100139 */
Rabin Vincent09bfafa2010-08-10 19:32:37 +0100140
141#ifndef CONFIG_OLD_MCOUNT
142#if (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 4))
143#error Ftrace requires CONFIG_FRAME_POINTER=y with GCC older than 4.4.0.
144#endif
145#endif
146
Rabin Vincentd68133b2012-01-24 16:52:52 +0100147.macro mcount_adjust_addr rd, rn
148 bic \rd, \rn, #1 @ clear the Thumb bit if present
149 sub \rd, \rd, #MCOUNT_INSN_SIZE
150.endm
151
Rabin Vincentd3b9dc92010-10-07 17:39:47 +0530152.macro __mcount suffix
153 mcount_enter
Rabin Vincent28e192d2010-08-03 17:08:09 +0100154 ldr r0, =ftrace_trace_function
155 ldr r2, [r0]
Rabin Vincenta3ba87a2010-08-10 19:37:21 +0100156 adr r0, .Lftrace_stub
Rabin Vincent28e192d2010-08-03 17:08:09 +0100157 cmp r0, r2
Rabin Vincentd3b9dc92010-10-07 17:39:47 +0530158 bne 1f
Uwe Kleine-König181f8172009-08-13 20:38:16 +0200159
Tim Bird376cfa82010-10-09 22:24:38 +0530160#ifdef CONFIG_FUNCTION_GRAPH_TRACER
161 ldr r1, =ftrace_graph_return
162 ldr r2, [r1]
163 cmp r0, r2
164 bne ftrace_graph_caller\suffix
165
166 ldr r1, =ftrace_graph_entry
167 ldr r2, [r1]
168 ldr r0, =ftrace_graph_entry_stub
169 cmp r0, r2
170 bne ftrace_graph_caller\suffix
171#endif
172
Rabin Vincentd3b9dc92010-10-07 17:39:47 +0530173 mcount_exit
Uwe Kleine-König181f8172009-08-13 20:38:16 +0200174
Rabin Vincentd3b9dc92010-10-07 17:39:47 +05301751: mcount_get_lr r1 @ lr of instrumented func
Rabin Vincentd68133b2012-01-24 16:52:52 +0100176 mcount_adjust_addr r0, lr @ instrumented function
Rabin Vincentd3b9dc92010-10-07 17:39:47 +0530177 adr lr, BSYM(2f)
Rabin Vincent28e192d2010-08-03 17:08:09 +0100178 mov pc, r2
Rabin Vincentd3b9dc92010-10-07 17:39:47 +05301792: mcount_exit
180.endm
181
182.macro __ftrace_caller suffix
183 mcount_enter
184
185 mcount_get_lr r1 @ lr of instrumented func
Rabin Vincentd68133b2012-01-24 16:52:52 +0100186 mcount_adjust_addr r0, lr @ instrumented function
Rabin Vincentd3b9dc92010-10-07 17:39:47 +0530187
188 .globl ftrace_call\suffix
189ftrace_call\suffix:
190 bl ftrace_stub
191
Rabin Vincentdd686eb2010-11-06 23:03:21 +0530192#ifdef CONFIG_FUNCTION_GRAPH_TRACER
193 .globl ftrace_graph_call\suffix
194ftrace_graph_call\suffix:
195 mov r0, r0
196#endif
197
Rabin Vincentd3b9dc92010-10-07 17:39:47 +0530198 mcount_exit
199.endm
Uwe Kleine-König181f8172009-08-13 20:38:16 +0200200
Tim Bird376cfa82010-10-09 22:24:38 +0530201.macro __ftrace_graph_caller
202 sub r0, fp, #4 @ &lr of instrumented routine (&parent)
Rabin Vincentdd686eb2010-11-06 23:03:21 +0530203#ifdef CONFIG_DYNAMIC_FTRACE
204 @ called from __ftrace_caller, saved in mcount_enter
205 ldr r1, [sp, #16] @ instrumented routine (func)
Rabin Vincentd68133b2012-01-24 16:52:52 +0100206 mcount_adjust_addr r1, r1
Rabin Vincentdd686eb2010-11-06 23:03:21 +0530207#else
208 @ called from __mcount, untouched in lr
Rabin Vincentd68133b2012-01-24 16:52:52 +0100209 mcount_adjust_addr r1, lr @ instrumented routine (func)
Rabin Vincentdd686eb2010-11-06 23:03:21 +0530210#endif
Tim Bird376cfa82010-10-09 22:24:38 +0530211 mov r2, fp @ frame pointer
212 bl prepare_ftrace_return
213 mcount_exit
214.endm
Abhishek Sagar014c2572008-05-31 14:23:50 +0530215
Rabin Vincent09bfafa2010-08-10 19:32:37 +0100216#ifdef CONFIG_OLD_MCOUNT
217/*
Rabin Vincentd3b9dc92010-10-07 17:39:47 +0530218 * mcount
Rabin Vincent09bfafa2010-08-10 19:32:37 +0100219 */
Abhishek Sagar014c2572008-05-31 14:23:50 +0530220
Rabin Vincentd3b9dc92010-10-07 17:39:47 +0530221.macro mcount_enter
222 stmdb sp!, {r0-r3, lr}
223.endm
224
225.macro mcount_get_lr reg
226 ldr \reg, [fp, #-4]
227.endm
228
229.macro mcount_exit
230 ldr lr, [fp, #-4]
Rabin Vincent28e192d2010-08-03 17:08:09 +0100231 ldmia sp!, {r0-r3, pc}
Rabin Vincentd3b9dc92010-10-07 17:39:47 +0530232.endm
233
234ENTRY(mcount)
235#ifdef CONFIG_DYNAMIC_FTRACE
236 stmdb sp!, {lr}
237 ldr lr, [fp, #-4]
238 ldmia sp!, {pc}
239#else
240 __mcount _old
241#endif
Rabin Vincent72fa62f2010-08-10 19:33:52 +0100242ENDPROC(mcount)
Rabin Vincentd3b9dc92010-10-07 17:39:47 +0530243
244#ifdef CONFIG_DYNAMIC_FTRACE
245ENTRY(ftrace_caller_old)
246 __ftrace_caller _old
247ENDPROC(ftrace_caller_old)
Rabin Vincent09bfafa2010-08-10 19:32:37 +0100248#endif
Abhishek Sagar014c2572008-05-31 14:23:50 +0530249
Tim Bird376cfa82010-10-09 22:24:38 +0530250#ifdef CONFIG_FUNCTION_GRAPH_TRACER
251ENTRY(ftrace_graph_caller_old)
252 __ftrace_graph_caller
253ENDPROC(ftrace_graph_caller_old)
254#endif
255
Rabin Vincentd3b9dc92010-10-07 17:39:47 +0530256.purgem mcount_enter
257.purgem mcount_get_lr
258.purgem mcount_exit
259#endif
260
261/*
262 * __gnu_mcount_nc
263 */
264
265.macro mcount_enter
266 stmdb sp!, {r0-r3, lr}
267.endm
268
269.macro mcount_get_lr reg
270 ldr \reg, [sp, #20]
271.endm
272
273.macro mcount_exit
274 ldmia sp!, {r0-r3, ip, lr}
275 mov pc, ip
276.endm
277
278ENTRY(__gnu_mcount_nc)
279#ifdef CONFIG_DYNAMIC_FTRACE
280 mov ip, lr
281 ldmia sp!, {lr}
282 mov pc, ip
283#else
284 __mcount
285#endif
286ENDPROC(__gnu_mcount_nc)
287
288#ifdef CONFIG_DYNAMIC_FTRACE
289ENTRY(ftrace_caller)
290 __ftrace_caller
291ENDPROC(ftrace_caller)
292#endif
293
Tim Bird376cfa82010-10-09 22:24:38 +0530294#ifdef CONFIG_FUNCTION_GRAPH_TRACER
295ENTRY(ftrace_graph_caller)
296 __ftrace_graph_caller
297ENDPROC(ftrace_graph_caller)
298#endif
299
Rabin Vincentd3b9dc92010-10-07 17:39:47 +0530300.purgem mcount_enter
301.purgem mcount_get_lr
302.purgem mcount_exit
Abhishek Sagar014c2572008-05-31 14:23:50 +0530303
Tim Bird376cfa82010-10-09 22:24:38 +0530304#ifdef CONFIG_FUNCTION_GRAPH_TRACER
305 .globl return_to_handler
306return_to_handler:
307 stmdb sp!, {r0-r3}
308 mov r0, fp @ frame pointer
309 bl ftrace_return_to_handler
310 mov lr, r0 @ r0 has real ret addr
311 ldmia sp!, {r0-r3}
312 mov pc, lr
313#endif
Abhishek Sagar014c2572008-05-31 14:23:50 +0530314
Rabin Vincent72fa62f2010-08-10 19:33:52 +0100315ENTRY(ftrace_stub)
Rabin Vincenta3ba87a2010-08-10 19:37:21 +0100316.Lftrace_stub:
Rabin Vincent28e192d2010-08-03 17:08:09 +0100317 mov pc, lr
Rabin Vincent72fa62f2010-08-10 19:33:52 +0100318ENDPROC(ftrace_stub)
Abhishek Sagar014c2572008-05-31 14:23:50 +0530319
Steven Rostedt606576c2008-10-06 19:06:12 -0400320#endif /* CONFIG_FUNCTION_TRACER */
Abhishek Sagar014c2572008-05-31 14:23:50 +0530321
Linus Torvalds1da177e2005-04-16 15:20:36 -0700322/*=============================================================================
323 * SWI handler
324 *-----------------------------------------------------------------------------
325 */
326
Linus Torvalds1da177e2005-04-16 15:20:36 -0700327 .align 5
328ENTRY(vector_swi)
Russell Kingf4dc9a42005-04-26 15:20:34 +0100329 sub sp, sp, #S_FRAME_SIZE
330 stmia sp, {r0 - r12} @ Calling r0 - r12
Catalin Marinasb86040a2009-07-24 12:32:54 +0100331 ARM( add r8, sp, #S_PC )
332 ARM( stmdb r8, {sp, lr}^ ) @ Calling sp, lr
333 THUMB( mov r8, sp )
334 THUMB( store_user_sp_lr r8, r10, S_SP ) @ calling sp, lr
Russell Kingf4dc9a42005-04-26 15:20:34 +0100335 mrs r8, spsr @ called from non-FIQ mode, so ok.
336 str lr, [sp, #S_PC] @ Save calling PC
337 str r8, [sp, #S_PSR] @ Save CPSR
338 str r0, [sp, #S_OLD_R0] @ Save OLD_R0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700339 zero_fp
Russell Kinge0f9f4a2005-04-26 15:19:24 +0100340
341 /*
342 * Get the system call number.
343 */
Nicolas Pitre3f2829a2006-01-14 16:31:29 +0000344
Nicolas Pitredd35afc2006-01-14 16:36:12 +0000345#if defined(CONFIG_OABI_COMPAT)
Nicolas Pitre3f2829a2006-01-14 16:31:29 +0000346
Nicolas Pitredd35afc2006-01-14 16:36:12 +0000347 /*
348 * If we have CONFIG_OABI_COMPAT then we need to look at the swi
349 * value to determine if it is an EABI or an old ABI call.
350 */
351#ifdef CONFIG_ARM_THUMB
352 tst r8, #PSR_T_BIT
353 movne r10, #0 @ no thumb OABI emulation
354 ldreq r10, [lr, #-4] @ get SWI instruction
355#else
356 ldr r10, [lr, #-4] @ get SWI instruction
Nicolas Pitredd35afc2006-01-14 16:36:12 +0000357#endif
Catalin Marinas26584852009-05-30 14:00:18 +0100358#ifdef CONFIG_CPU_ENDIAN_BE8
359 rev r10, r10 @ little endian instruction
360#endif
Nicolas Pitredd35afc2006-01-14 16:36:12 +0000361
362#elif defined(CONFIG_AEABI)
363
364 /*
365 * Pure EABI user space always put syscall number into scno (r7).
366 */
Nicolas Pitre3f2829a2006-01-14 16:31:29 +0000367#elif defined(CONFIG_ARM_THUMB)
Nicolas Pitredd35afc2006-01-14 16:36:12 +0000368 /* Legacy ABI only, possibly thumb mode. */
Russell Kinge0f9f4a2005-04-26 15:19:24 +0100369 tst r8, #PSR_T_BIT @ this is SPSR from save_user_regs
370 addne scno, r7, #__NR_SYSCALL_BASE @ put OS number in
371 ldreq scno, [lr, #-4]
Nicolas Pitredd35afc2006-01-14 16:36:12 +0000372
Russell Kinge0f9f4a2005-04-26 15:19:24 +0100373#else
Nicolas Pitredd35afc2006-01-14 16:36:12 +0000374 /* Legacy ABI only. */
Russell Kinge0f9f4a2005-04-26 15:19:24 +0100375 ldr scno, [lr, #-4] @ get SWI instruction
376#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700377
378#ifdef CONFIG_ALIGNMENT_TRAP
379 ldr ip, __cr_alignment
380 ldr ip, [ip]
381 mcr p15, 0, ip, c1, c0 @ update control register
382#endif
Russell King1ec42c02005-04-26 15:18:26 +0100383 enable_irq
Linus Torvalds1da177e2005-04-16 15:20:36 -0700384
Linus Torvalds1da177e2005-04-16 15:20:36 -0700385 get_thread_info tsk
Nicolas Pitredd35afc2006-01-14 16:36:12 +0000386 adr tbl, sys_call_table @ load syscall table pointer
Nicolas Pitredd35afc2006-01-14 16:36:12 +0000387
388#if defined(CONFIG_OABI_COMPAT)
389 /*
390 * If the swi argument is zero, this is an EABI call and we do nothing.
391 *
392 * If this is an old ABI call, get the syscall number into scno and
393 * get the old ABI syscall table address.
394 */
395 bics r10, r10, #0xff000000
396 eorne scno, r10, #__NR_OABI_SYSCALL_BASE
397 ldrne tbl, =sys_oabi_call_table
398#elif !defined(CONFIG_AEABI)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700399 bic scno, scno, #0xff000000 @ mask off SWI op-code
Russell Kinge0f9f4a2005-04-26 15:19:24 +0100400 eor scno, scno, #__NR_SYSCALL_BASE @ check OS number
Nicolas Pitre3f2829a2006-01-14 16:31:29 +0000401#endif
Nicolas Pitredd35afc2006-01-14 16:36:12 +0000402
Al Viro81783782012-07-19 17:48:21 +0100403local_restart:
Nicolas Pitre70c70d92010-08-26 15:08:35 -0700404 ldr r10, [tsk, #TI_FLAGS] @ check for syscall tracing
Nicolas Pitre3f2829a2006-01-14 16:31:29 +0000405 stmdb sp!, {r4, r5} @ push fifth and sixth args
Nicolas Pitre70c70d92010-08-26 15:08:35 -0700406
407#ifdef CONFIG_SECCOMP
408 tst r10, #_TIF_SECCOMP
409 beq 1f
410 mov r0, scno
411 bl __secure_computing
412 add r0, sp, #S_R0 + S_OFF @ pointer to regs
413 ldmia r0, {r0 - r3} @ have to reload r0 - r3
4141:
415#endif
416
Nathaniel Husted29ef73b2012-01-03 14:23:09 -0500417 tst r10, #_TIF_SYSCALL_WORK @ are we tracing syscalls?
Linus Torvalds1da177e2005-04-16 15:20:36 -0700418 bne __sys_trace
419
Linus Torvalds1da177e2005-04-16 15:20:36 -0700420 cmp scno, #NR_syscalls @ check upper syscall limit
Catalin Marinasb86040a2009-07-24 12:32:54 +0100421 adr lr, BSYM(ret_fast_syscall) @ return address
Linus Torvalds1da177e2005-04-16 15:20:36 -0700422 ldrcc pc, [tbl, scno, lsl #2] @ call sys_* routine
423
424 add r1, sp, #S_OFF
4252: mov why, #0 @ no longer a real syscall
Russell Kinge0f9f4a2005-04-26 15:19:24 +0100426 cmp scno, #(__ARM_NR_BASE - __NR_SYSCALL_BASE)
427 eor r0, scno, #__NR_SYSCALL_BASE @ put OS number back
Linus Torvalds1da177e2005-04-16 15:20:36 -0700428 bcs arm_syscall
429 b sys_ni_syscall @ not private func
Catalin Marinas93ed3972008-08-28 11:22:32 +0100430ENDPROC(vector_swi)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700431
432 /*
433 * This is the really slow path. We're going to be doing
434 * context switches, and waiting for our parent to respond.
435 */
436__sys_trace:
Will Deaconad722542012-07-06 15:50:14 +0100437 mov r1, scno
438 add r0, sp, #S_OFF
439 bl syscall_trace_enter
Linus Torvalds1da177e2005-04-16 15:20:36 -0700440
Catalin Marinasb86040a2009-07-24 12:32:54 +0100441 adr lr, BSYM(__sys_trace_return) @ return address
Nicolas Pitre3f471122006-01-14 19:30:04 +0000442 mov scno, r0 @ syscall number (possibly new)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700443 add r1, sp, #S_R0 + S_OFF @ pointer to regs
444 cmp scno, #NR_syscalls @ check upper syscall limit
445 ldmccia r1, {r0 - r3} @ have to reload r0 - r3
446 ldrcc pc, [tbl, scno, lsl #2] @ call sys_* routine
447 b 2b
448
449__sys_trace_return:
450 str r0, [sp, #S_R0 + S_OFF]! @ save returned r0
Will Deaconad722542012-07-06 15:50:14 +0100451 mov r1, scno
452 mov r0, sp
453 bl syscall_trace_exit
Linus Torvalds1da177e2005-04-16 15:20:36 -0700454 b ret_slow_syscall
455
456 .align 5
457#ifdef CONFIG_ALIGNMENT_TRAP
458 .type __cr_alignment, #object
459__cr_alignment:
460 .word cr_alignment
461#endif
Nicolas Pitredd35afc2006-01-14 16:36:12 +0000462 .ltorg
463
464/*
465 * This is the syscall table declaration for native ABI syscalls.
466 * With EABI a couple syscalls are obsolete and defined as sys_ni_syscall.
467 */
468#define ABI(native, compat) native
469#ifdef CONFIG_AEABI
470#define OBSOLETE(syscall) sys_ni_syscall
471#else
472#define OBSOLETE(syscall) syscall
473#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700474
475 .type sys_call_table, #object
476ENTRY(sys_call_table)
477#include "calls.S"
Nicolas Pitredd35afc2006-01-14 16:36:12 +0000478#undef ABI
479#undef OBSOLETE
Linus Torvalds1da177e2005-04-16 15:20:36 -0700480
481/*============================================================================
482 * Special system call wrappers
483 */
484@ r0 = syscall number
Russell King567bd982005-12-17 15:25:42 +0000485@ r8 = syscall table
Linus Torvalds1da177e2005-04-16 15:20:36 -0700486sys_syscall:
Paul Brook52475932006-05-16 14:25:55 +0100487 bic scno, r0, #__NR_OABI_SYSCALL_BASE
Linus Torvalds1da177e2005-04-16 15:20:36 -0700488 cmp scno, #__NR_syscall - __NR_SYSCALL_BASE
489 cmpne scno, #NR_syscalls @ check range
490 stmloia sp, {r5, r6} @ shuffle args
491 movlo r0, r1
492 movlo r1, r2
493 movlo r2, r3
494 movlo r3, r4
495 ldrlo pc, [tbl, scno, lsl #2]
496 b sys_ni_syscall
Catalin Marinas93ed3972008-08-28 11:22:32 +0100497ENDPROC(sys_syscall)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700498
499sys_fork_wrapper:
500 add r0, sp, #S_OFF
501 b sys_fork
Catalin Marinas93ed3972008-08-28 11:22:32 +0100502ENDPROC(sys_fork_wrapper)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700503
504sys_vfork_wrapper:
505 add r0, sp, #S_OFF
506 b sys_vfork
Catalin Marinas93ed3972008-08-28 11:22:32 +0100507ENDPROC(sys_vfork_wrapper)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700508
509sys_execve_wrapper:
510 add r3, sp, #S_OFF
511 b sys_execve
Catalin Marinas93ed3972008-08-28 11:22:32 +0100512ENDPROC(sys_execve_wrapper)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700513
514sys_clone_wrapper:
515 add ip, sp, #S_OFF
516 str ip, [sp, #4]
517 b sys_clone
Catalin Marinas93ed3972008-08-28 11:22:32 +0100518ENDPROC(sys_clone_wrapper)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700519
Linus Torvalds1da177e2005-04-16 15:20:36 -0700520sys_sigreturn_wrapper:
521 add r0, sp, #S_OFF
Al Viro653d48b2010-09-17 14:34:39 +0100522 mov why, #0 @ prevent syscall restart handling
Linus Torvalds1da177e2005-04-16 15:20:36 -0700523 b sys_sigreturn
Catalin Marinas93ed3972008-08-28 11:22:32 +0100524ENDPROC(sys_sigreturn_wrapper)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700525
526sys_rt_sigreturn_wrapper:
527 add r0, sp, #S_OFF
Al Viro653d48b2010-09-17 14:34:39 +0100528 mov why, #0 @ prevent syscall restart handling
Linus Torvalds1da177e2005-04-16 15:20:36 -0700529 b sys_rt_sigreturn
Catalin Marinas93ed3972008-08-28 11:22:32 +0100530ENDPROC(sys_rt_sigreturn_wrapper)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700531
532sys_sigaltstack_wrapper:
533 ldr r2, [sp, #S_OFF + S_SP]
534 b do_sigaltstack
Catalin Marinas93ed3972008-08-28 11:22:32 +0100535ENDPROC(sys_sigaltstack_wrapper)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700536
Nicolas Pitre713c4812006-01-14 16:35:03 +0000537sys_statfs64_wrapper:
538 teq r1, #88
539 moveq r1, #84
540 b sys_statfs64
Catalin Marinas93ed3972008-08-28 11:22:32 +0100541ENDPROC(sys_statfs64_wrapper)
Nicolas Pitre713c4812006-01-14 16:35:03 +0000542
543sys_fstatfs64_wrapper:
544 teq r1, #88
545 moveq r1, #84
546 b sys_fstatfs64
Catalin Marinas93ed3972008-08-28 11:22:32 +0100547ENDPROC(sys_fstatfs64_wrapper)
Nicolas Pitre713c4812006-01-14 16:35:03 +0000548
Linus Torvalds1da177e2005-04-16 15:20:36 -0700549/*
550 * Note: off_4k (r5) is always units of 4K. If we can't do the requested
551 * offset, we return EINVAL.
552 */
553sys_mmap2:
554#if PAGE_SHIFT > 12
555 tst r5, #PGOFF_MASK
556 moveq r5, r5, lsr #PAGE_SHIFT - 12
557 streq r5, [sp, #4]
Al Virof8b72562009-11-30 17:37:04 -0500558 beq sys_mmap_pgoff
Linus Torvalds1da177e2005-04-16 15:20:36 -0700559 mov r0, #-EINVAL
Russell King7999d8d2006-06-25 11:17:23 +0100560 mov pc, lr
Linus Torvalds1da177e2005-04-16 15:20:36 -0700561#else
562 str r5, [sp, #4]
Al Virof8b72562009-11-30 17:37:04 -0500563 b sys_mmap_pgoff
Linus Torvalds1da177e2005-04-16 15:20:36 -0700564#endif
Catalin Marinas93ed3972008-08-28 11:22:32 +0100565ENDPROC(sys_mmap2)
Nicolas Pitre687ad012006-01-14 16:35:31 +0000566
567#ifdef CONFIG_OABI_COMPAT
Nicolas Pitredd35afc2006-01-14 16:36:12 +0000568
Nicolas Pitre687ad012006-01-14 16:35:31 +0000569/*
570 * These are syscalls with argument register differences
571 */
572
573sys_oabi_pread64:
574 stmia sp, {r3, r4}
575 b sys_pread64
Catalin Marinas93ed3972008-08-28 11:22:32 +0100576ENDPROC(sys_oabi_pread64)
Nicolas Pitre687ad012006-01-14 16:35:31 +0000577
578sys_oabi_pwrite64:
579 stmia sp, {r3, r4}
580 b sys_pwrite64
Catalin Marinas93ed3972008-08-28 11:22:32 +0100581ENDPROC(sys_oabi_pwrite64)
Nicolas Pitre687ad012006-01-14 16:35:31 +0000582
583sys_oabi_truncate64:
584 mov r3, r2
585 mov r2, r1
586 b sys_truncate64
Catalin Marinas93ed3972008-08-28 11:22:32 +0100587ENDPROC(sys_oabi_truncate64)
Nicolas Pitre687ad012006-01-14 16:35:31 +0000588
589sys_oabi_ftruncate64:
590 mov r3, r2
591 mov r2, r1
592 b sys_ftruncate64
Catalin Marinas93ed3972008-08-28 11:22:32 +0100593ENDPROC(sys_oabi_ftruncate64)
Nicolas Pitre687ad012006-01-14 16:35:31 +0000594
595sys_oabi_readahead:
596 str r3, [sp]
597 mov r3, r2
598 mov r2, r1
599 b sys_readahead
Catalin Marinas93ed3972008-08-28 11:22:32 +0100600ENDPROC(sys_oabi_readahead)
Nicolas Pitre687ad012006-01-14 16:35:31 +0000601
Nicolas Pitredd35afc2006-01-14 16:36:12 +0000602/*
603 * Let's declare a second syscall table for old ABI binaries
604 * using the compatibility syscall entries.
605 */
606#define ABI(native, compat) compat
607#define OBSOLETE(syscall) syscall
608
609 .type sys_oabi_call_table, #object
610ENTRY(sys_oabi_call_table)
611#include "calls.S"
612#undef ABI
613#undef OBSOLETE
614
Nicolas Pitre687ad012006-01-14 16:35:31 +0000615#endif
616