blob: b427ef8ec8c647a5200d80154b08ea41f66852ce [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
Russell King6ebbf2c2014-06-30 16:29:12 +010011#include <asm/assembler.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070012#include <asm/unistd.h>
Abhishek Sagar395a59d2008-06-21 23:47:27 +053013#include <asm/ftrace.h>
Catalin Marinasc4c57162009-02-16 11:42:09 +010014#include <asm/unwind.h>
Thomas Garniere33f8d322017-09-07 08:30:46 -070015#include <asm/memory.h>
Russell King96a8fae2016-10-18 19:57:01 +010016#ifdef CONFIG_AEABI
17#include <asm/unistd-oabi.h>
18#endif
19
20 .equ NR_syscalls, __NR_syscalls
Linus Torvalds1da177e2005-04-16 15:20:36 -070021
Rob Herring13a50452012-02-07 09:28:22 -060022#ifdef CONFIG_NEED_RET_TO_USER
23#include <mach/entry-macro.S>
24#else
25 .macro arch_ret_to_user, tmp1, tmp2
26 .endm
27#endif
28
Linus Torvalds1da177e2005-04-16 15:20:36 -070029#include "entry-header.S"
30
Russell King309ee042017-03-24 16:15:45 +000031saved_psr .req r8
Russell Kingfcea4522017-03-24 16:22:10 +000032#if defined(CONFIG_TRACE_IRQFLAGS) || defined(CONFIG_CONTEXT_TRACKING)
33saved_pc .req r9
34#define TRACE(x...) x
35#else
Russell King309ee042017-03-24 16:15:45 +000036saved_pc .req lr
Russell Kingfcea4522017-03-24 16:22:10 +000037#define TRACE(x...)
38#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070039
Russell Kingc6089062017-11-24 23:54:22 +000040 .section .entry.text,"ax",%progbits
Linus Torvalds1da177e2005-04-16 15:20:36 -070041 .align 5
Mathieu Desnoyersb74406f2018-06-02 08:43:56 -040042#if !(IS_ENABLED(CONFIG_TRACE_IRQFLAGS) || IS_ENABLED(CONFIG_CONTEXT_TRACKING) || \
43 IS_ENABLED(CONFIG_DEBUG_RSEQ))
Linus Torvalds1da177e2005-04-16 15:20:36 -070044/*
Russell King3302cad2015-08-20 16:13:37 +010045 * This is the fast syscall return path. We do as little as possible here,
46 * such as avoiding writing r0 to the stack. We only use this path if we
Mathieu Desnoyersb74406f2018-06-02 08:43:56 -040047 * have tracing, context tracking and rseq debug disabled - the overheads
48 * from those features make this path too inefficient.
Linus Torvalds1da177e2005-04-16 15:20:36 -070049 */
50ret_fast_syscall:
Catalin Marinasc4c57162009-02-16 11:42:09 +010051 UNWIND(.fnstart )
52 UNWIND(.cantunwind )
Russell King3302cad2015-08-20 16:13:37 +010053 disable_irq_notrace @ disable interrupts
Thomas Garniere33f8d322017-09-07 08:30:46 -070054 ldr r2, [tsk, #TI_ADDR_LIMIT]
55 cmp r2, #TASK_SIZE
56 blne addr_limit_check_failed
Russell King1b979372015-05-15 11:02:23 +010057 ldr r1, [tsk, #TI_FLAGS] @ re-check for syscall tracing
Thomas Garnier24042692017-09-07 08:30:45 -070058 tst r1, #_TIF_SYSCALL_WORK | _TIF_WORK_MASK
Linus Torvalds1da177e2005-04-16 15:20:36 -070059 bne fast_work_pending
Russell Kingf4dc9a42005-04-26 15:20:34 +010060
Thomas Garniere33f8d322017-09-07 08:30:46 -070061
Dan Williamsf80dff92007-02-16 22:16:32 +010062 /* perform architecture specific actions before user return */
63 arch_ret_to_user r1, lr
64
Catalin Marinasb86040a2009-07-24 12:32:54 +010065 restore_user_regs fast = 1, offset = S_OFF
Catalin Marinasc4c57162009-02-16 11:42:09 +010066 UNWIND(.fnend )
Russell King3302cad2015-08-20 16:13:37 +010067ENDPROC(ret_fast_syscall)
Linus Torvalds1da177e2005-04-16 15:20:36 -070068
Russell King3302cad2015-08-20 16:13:37 +010069 /* Ok, we need to do extra processing, enter the slow path. */
Linus Torvalds1da177e2005-04-16 15:20:36 -070070fast_work_pending:
71 str r0, [sp, #S_R0+S_OFF]! @ returned r0
Russell King3302cad2015-08-20 16:13:37 +010072 /* fall through to work_pending */
73#else
74/*
Mathieu Desnoyersb74406f2018-06-02 08:43:56 -040075 * The "replacement" ret_fast_syscall for when tracing, context tracking,
76 * or rseq debug is enabled. As we will need to call out to some C functions,
77 * we save r0 first to avoid needing to save registers around each C function
78 * call.
Russell King3302cad2015-08-20 16:13:37 +010079 */
80ret_fast_syscall:
81 UNWIND(.fnstart )
82 UNWIND(.cantunwind )
83 str r0, [sp, #S_R0 + S_OFF]! @ save returned r0
Mathieu Desnoyersb74406f2018-06-02 08:43:56 -040084#if IS_ENABLED(CONFIG_DEBUG_RSEQ)
85 /* do_rseq_syscall needs interrupts enabled. */
86 mov r0, sp @ 'regs'
87 bl do_rseq_syscall
88#endif
Russell King3302cad2015-08-20 16:13:37 +010089 disable_irq_notrace @ disable interrupts
Thomas Garniere33f8d322017-09-07 08:30:46 -070090 ldr r2, [tsk, #TI_ADDR_LIMIT]
91 cmp r2, #TASK_SIZE
92 blne addr_limit_check_failed
Russell King3302cad2015-08-20 16:13:37 +010093 ldr r1, [tsk, #TI_FLAGS] @ re-check for syscall tracing
Thomas Garnier24042692017-09-07 08:30:45 -070094 tst r1, #_TIF_SYSCALL_WORK | _TIF_WORK_MASK
Russell King3302cad2015-08-20 16:13:37 +010095 beq no_work_pending
96 UNWIND(.fnend )
97ENDPROC(ret_fast_syscall)
98
99 /* Slower path - fall through to work_pending */
100#endif
101
102 tst r1, #_TIF_SYSCALL_WORK
103 bne __sys_trace_return_nosave
104slow_work_pending:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105 mov r0, sp @ 'regs'
106 mov r2, why @ 'syscall'
Al Viro0a267fa2012-07-19 17:47:55 +0100107 bl do_work_pending
Al Viro66285212012-07-19 17:48:50 +0100108 cmp r0, #0
Al Viro81783782012-07-19 17:48:21 +0100109 beq no_work_pending
Al Viro66285212012-07-19 17:48:50 +0100110 movlt scno, #(__NR_restart_syscall - __NR_SYSCALL_BASE)
Al Viro81783782012-07-19 17:48:21 +0100111 ldmia sp, {r0 - r6} @ have to reload r0 - r6
112 b local_restart @ ... and off we go
Drew Richardsone83dd372015-08-06 18:50:27 +0100113ENDPROC(ret_fast_syscall)
Al Viro81783782012-07-19 17:48:21 +0100114
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115/*
116 * "slow" syscall return path. "why" tells us if this was a real syscall.
Russell King3302cad2015-08-20 16:13:37 +0100117 * IRQs may be enabled here, so always disable them. Note that we use the
118 * "notrace" version to avoid calling into the tracing code unnecessarily.
119 * do_work_pending() will update this state if necessary.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120 */
121ENTRY(ret_to_user)
122ret_slow_syscall:
Mathieu Desnoyersb74406f2018-06-02 08:43:56 -0400123#if IS_ENABLED(CONFIG_DEBUG_RSEQ)
124 /* do_rseq_syscall needs interrupts enabled. */
125 enable_irq_notrace @ enable interrupts
126 mov r0, sp @ 'regs'
127 bl do_rseq_syscall
128#endif
Russell King3302cad2015-08-20 16:13:37 +0100129 disable_irq_notrace @ disable interrupts
Ming Lei9fc25522011-06-05 02:24:58 +0100130ENTRY(ret_to_user_from_irq)
Thomas Garniere33f8d322017-09-07 08:30:46 -0700131 ldr r2, [tsk, #TI_ADDR_LIMIT]
132 cmp r2, #TASK_SIZE
133 blne addr_limit_check_failed
Linus Torvalds1da177e2005-04-16 15:20:36 -0700134 ldr r1, [tsk, #TI_FLAGS]
135 tst r1, #_TIF_WORK_MASK
Russell King3302cad2015-08-20 16:13:37 +0100136 bne slow_work_pending
Linus Torvalds1da177e2005-04-16 15:20:36 -0700137no_work_pending:
Russell King3302cad2015-08-20 16:13:37 +0100138 asm_trace_hardirqs_on save = 0
Russell King651e9492013-03-28 11:44:25 +0000139
Dan Williamsf80dff92007-02-16 22:16:32 +0100140 /* perform architecture specific actions before user return */
141 arch_ret_to_user r1, lr
Kevin Hilmanb0088482013-03-28 22:54:40 +0100142 ct_user_enter save = 0
Dan Williamsf80dff92007-02-16 22:16:32 +0100143
Catalin Marinasb86040a2009-07-24 12:32:54 +0100144 restore_user_regs fast = 0, offset = 0
Ming Lei9fc25522011-06-05 02:24:58 +0100145ENDPROC(ret_to_user_from_irq)
Catalin Marinas93ed3972008-08-28 11:22:32 +0100146ENDPROC(ret_to_user)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700147
148/*
149 * This is how we return from a fork.
150 */
151ENTRY(ret_from_fork)
152 bl schedule_tail
Al Viro9fff2fa2012-10-10 22:23:29 -0400153 cmp r5, #0
154 movne r0, r4
Russell King14327c62015-04-21 14:17:25 +0100155 badrne lr, 1f
Russell King6ebbf2c2014-06-30 16:29:12 +0100156 retne r5
Russell King68687c82012-10-15 00:16:49 +01001571: get_thread_info tsk
Linus Torvalds1da177e2005-04-16 15:20:36 -0700158 b ret_slow_syscall
Catalin Marinas93ed3972008-08-28 11:22:32 +0100159ENDPROC(ret_from_fork)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700160
Linus Torvalds1da177e2005-04-16 15:20:36 -0700161/*=============================================================================
162 * SWI handler
163 *-----------------------------------------------------------------------------
164 */
165
Linus Torvalds1da177e2005-04-16 15:20:36 -0700166 .align 5
167ENTRY(vector_swi)
Uwe Kleine-König19c4d592010-05-21 18:06:42 +0100168#ifdef CONFIG_CPU_V7M
169 v7m_exception_entry
170#else
Russell King5745eef62016-05-10 16:34:27 +0100171 sub sp, sp, #PT_REGS_SIZE
Russell Kingf4dc9a42005-04-26 15:20:34 +0100172 stmia sp, {r0 - r12} @ Calling r0 - r12
Catalin Marinasb86040a2009-07-24 12:32:54 +0100173 ARM( add r8, sp, #S_PC )
174 ARM( stmdb r8, {sp, lr}^ ) @ Calling sp, lr
175 THUMB( mov r8, sp )
176 THUMB( store_user_sp_lr r8, r10, S_SP ) @ calling sp, lr
Russell King309ee042017-03-24 16:15:45 +0000177 mrs saved_psr, spsr @ called from non-FIQ mode, so ok.
Russell Kingfcea4522017-03-24 16:22:10 +0000178 TRACE( mov saved_pc, lr )
Russell King309ee042017-03-24 16:15:45 +0000179 str saved_pc, [sp, #S_PC] @ Save calling PC
180 str saved_psr, [sp, #S_PSR] @ Save CPSR
Russell Kingf4dc9a42005-04-26 15:20:34 +0100181 str r0, [sp, #S_OLD_R0] @ Save OLD_R0
Uwe Kleine-König19c4d592010-05-21 18:06:42 +0100182#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700183 zero_fp
Russell King195b58a2014-08-28 13:08:14 +0100184 alignment_trap r10, ip, __cr_alignment
Russell Kingdca778c2017-03-24 16:23:25 +0000185 asm_trace_hardirqs_on save=0
186 enable_irq_notrace
187 ct_user_exit save=0
Will Deacon1aa2b3b2013-06-05 11:25:13 +0100188
Russell Kinge0f9f4a2005-04-26 15:19:24 +0100189 /*
190 * Get the system call number.
191 */
Nicolas Pitre3f2829a2006-01-14 16:31:29 +0000192
Nicolas Pitredd35afc2006-01-14 16:36:12 +0000193#if defined(CONFIG_OABI_COMPAT)
Nicolas Pitre3f2829a2006-01-14 16:31:29 +0000194
Nicolas Pitredd35afc2006-01-14 16:36:12 +0000195 /*
196 * If we have CONFIG_OABI_COMPAT then we need to look at the swi
197 * value to determine if it is an EABI or an old ABI call.
198 */
199#ifdef CONFIG_ARM_THUMB
Russell King309ee042017-03-24 16:15:45 +0000200 tst saved_psr, #PSR_T_BIT
Nicolas Pitredd35afc2006-01-14 16:36:12 +0000201 movne r10, #0 @ no thumb OABI emulation
Russell King309ee042017-03-24 16:15:45 +0000202 USER( ldreq r10, [saved_pc, #-4] ) @ get SWI instruction
Nicolas Pitredd35afc2006-01-14 16:36:12 +0000203#else
Russell King309ee042017-03-24 16:15:45 +0000204 USER( ldr r10, [saved_pc, #-4] ) @ get SWI instruction
Nicolas Pitredd35afc2006-01-14 16:36:12 +0000205#endif
Ben Dooks457c2402013-02-12 18:59:57 +0000206 ARM_BE8(rev r10, r10) @ little endian instruction
Nicolas Pitredd35afc2006-01-14 16:36:12 +0000207
208#elif defined(CONFIG_AEABI)
209
210 /*
211 * Pure EABI user space always put syscall number into scno (r7).
212 */
Nicolas Pitre3f2829a2006-01-14 16:31:29 +0000213#elif defined(CONFIG_ARM_THUMB)
Nicolas Pitredd35afc2006-01-14 16:36:12 +0000214 /* Legacy ABI only, possibly thumb mode. */
Russell King309ee042017-03-24 16:15:45 +0000215 tst saved_psr, #PSR_T_BIT @ this is SPSR from save_user_regs
Russell Kinge0f9f4a2005-04-26 15:19:24 +0100216 addne scno, r7, #__NR_SYSCALL_BASE @ put OS number in
Russell King309ee042017-03-24 16:15:45 +0000217 USER( ldreq scno, [saved_pc, #-4] )
Nicolas Pitredd35afc2006-01-14 16:36:12 +0000218
Russell Kinge0f9f4a2005-04-26 15:19:24 +0100219#else
Nicolas Pitredd35afc2006-01-14 16:36:12 +0000220 /* Legacy ABI only. */
Russell King309ee042017-03-24 16:15:45 +0000221 USER( ldr scno, [saved_pc, #-4] ) @ get SWI instruction
Russell Kinge0f9f4a2005-04-26 15:19:24 +0100222#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700223
Russell King309ee042017-03-24 16:15:45 +0000224 /* saved_psr and saved_pc are now dead */
225
Russell King2190fed2015-08-20 10:32:02 +0100226 uaccess_disable tbl
227
Nicolas Pitredd35afc2006-01-14 16:36:12 +0000228 adr tbl, sys_call_table @ load syscall table pointer
Nicolas Pitredd35afc2006-01-14 16:36:12 +0000229
230#if defined(CONFIG_OABI_COMPAT)
231 /*
232 * If the swi argument is zero, this is an EABI call and we do nothing.
233 *
234 * If this is an old ABI call, get the syscall number into scno and
235 * get the old ABI syscall table address.
236 */
237 bics r10, r10, #0xff000000
238 eorne scno, r10, #__NR_OABI_SYSCALL_BASE
239 ldrne tbl, =sys_oabi_call_table
240#elif !defined(CONFIG_AEABI)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700241 bic scno, scno, #0xff000000 @ mask off SWI op-code
Russell Kinge0f9f4a2005-04-26 15:19:24 +0100242 eor scno, scno, #__NR_SYSCALL_BASE @ check OS number
Nicolas Pitre3f2829a2006-01-14 16:31:29 +0000243#endif
Russell Kingda594e32017-03-24 16:19:12 +0000244 get_thread_info tsk
Russell Kingdca778c2017-03-24 16:23:25 +0000245 /*
246 * Reload the registers that may have been corrupted on entry to
247 * the syscall assembly (by tracing or context tracking.)
248 */
249 TRACE( ldmia sp, {r0 - r3} )
Nicolas Pitredd35afc2006-01-14 16:36:12 +0000250
Al Viro81783782012-07-19 17:48:21 +0100251local_restart:
Nicolas Pitre70c70d92010-08-26 15:08:35 -0700252 ldr r10, [tsk, #TI_FLAGS] @ check for syscall tracing
Nicolas Pitre3f2829a2006-01-14 16:31:29 +0000253 stmdb sp!, {r4, r5} @ push fifth and sixth args
Nicolas Pitre70c70d92010-08-26 15:08:35 -0700254
Nathaniel Husted29ef73b2012-01-03 14:23:09 -0500255 tst r10, #_TIF_SYSCALL_WORK @ are we tracing syscalls?
Linus Torvalds1da177e2005-04-16 15:20:36 -0700256 bne __sys_trace
257
Linus Torvalds1da177e2005-04-16 15:20:36 -0700258 cmp scno, #NR_syscalls @ check upper syscall limit
Russell King14327c62015-04-21 14:17:25 +0100259 badr lr, ret_fast_syscall @ return address
Linus Torvalds1da177e2005-04-16 15:20:36 -0700260 ldrcc pc, [tbl, scno, lsl #2] @ call sys_* routine
261
262 add r1, sp, #S_OFF
Will Deacond95bc252013-09-19 10:32:20 +01002632: cmp scno, #(__ARM_NR_BASE - __NR_SYSCALL_BASE)
Russell Kinge0f9f4a2005-04-26 15:19:24 +0100264 eor r0, scno, #__NR_SYSCALL_BASE @ put OS number back
Will Deacon377747c2013-05-13 19:16:34 +0100265 bcs arm_syscall
Will Deacond95bc252013-09-19 10:32:20 +0100266 mov why, #0 @ no longer a real syscall
Linus Torvalds1da177e2005-04-16 15:20:36 -0700267 b sys_ni_syscall @ not private func
Will Deacon1aa2b3b2013-06-05 11:25:13 +0100268
269#if defined(CONFIG_OABI_COMPAT) || !defined(CONFIG_AEABI)
270 /*
271 * We failed to handle a fault trying to access the page
272 * containing the swi instruction, but we're not really in a
273 * position to return -EFAULT. Instead, return back to the
274 * instruction and re-enter the user fault handling path trying
275 * to page it in. This will likely result in sending SEGV to the
276 * current task.
277 */
2789001:
Russell King309ee042017-03-24 16:15:45 +0000279 sub lr, saved_pc, #4
Will Deacon1aa2b3b2013-06-05 11:25:13 +0100280 str lr, [sp, #S_PC]
Russell Kingda594e32017-03-24 16:19:12 +0000281 get_thread_info tsk
Will Deacon1aa2b3b2013-06-05 11:25:13 +0100282 b ret_fast_syscall
283#endif
Catalin Marinas93ed3972008-08-28 11:22:32 +0100284ENDPROC(vector_swi)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700285
286 /*
287 * This is the really slow path. We're going to be doing
288 * context switches, and waiting for our parent to respond.
289 */
290__sys_trace:
Will Deaconad722542012-07-06 15:50:14 +0100291 mov r1, scno
292 add r0, sp, #S_OFF
293 bl syscall_trace_enter
Linus Torvalds1da177e2005-04-16 15:20:36 -0700294
Russell King14327c62015-04-21 14:17:25 +0100295 badr lr, __sys_trace_return @ return address
Nicolas Pitre3f471122006-01-14 19:30:04 +0000296 mov scno, r0 @ syscall number (possibly new)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700297 add r1, sp, #S_R0 + S_OFF @ pointer to regs
298 cmp scno, #NR_syscalls @ check upper syscall limit
Will Deaconc7aa00d2012-07-19 17:49:22 +0100299 ldmccia r1, {r0 - r6} @ have to reload r0 - r6
300 stmccia sp, {r4, r5} @ and update the stack args
Linus Torvalds1da177e2005-04-16 15:20:36 -0700301 ldrcc pc, [tbl, scno, lsl #2] @ call sys_* routine
Kees Cookad75b512012-11-15 22:12:17 +0100302 cmp scno, #-1 @ skip the syscall?
303 bne 2b
304 add sp, sp, #S_OFF @ restore stack
305 b ret_slow_syscall
Linus Torvalds1da177e2005-04-16 15:20:36 -0700306
307__sys_trace_return:
308 str r0, [sp, #S_R0 + S_OFF]! @ save returned r0
Will Deaconad722542012-07-06 15:50:14 +0100309 mov r0, sp
310 bl syscall_trace_exit
Linus Torvalds1da177e2005-04-16 15:20:36 -0700311 b ret_slow_syscall
312
Russell King3302cad2015-08-20 16:13:37 +0100313__sys_trace_return_nosave:
Russell Kinge0aa3a62015-08-20 17:39:32 +0100314 enable_irq_notrace
Russell King3302cad2015-08-20 16:13:37 +0100315 mov r0, sp
316 bl syscall_trace_exit
317 b ret_slow_syscall
318
Linus Torvalds1da177e2005-04-16 15:20:36 -0700319 .align 5
320#ifdef CONFIG_ALIGNMENT_TRAP
321 .type __cr_alignment, #object
322__cr_alignment:
323 .word cr_alignment
324#endif
Nicolas Pitredd35afc2006-01-14 16:36:12 +0000325 .ltorg
326
Russell King96a8fae2016-10-18 19:57:01 +0100327 .macro syscall_table_start, sym
328 .equ __sys_nr, 0
329 .type \sym, #object
330ENTRY(\sym)
331 .endm
332
333 .macro syscall, nr, func
334 .ifgt __sys_nr - \nr
335 .error "Duplicated/unorded system call entry"
336 .endif
337 .rept \nr - __sys_nr
338 .long sys_ni_syscall
339 .endr
340 .long \func
341 .equ __sys_nr, \nr + 1
342 .endm
343
344 .macro syscall_table_end, sym
345 .ifgt __sys_nr - __NR_syscalls
346 .error "System call table too big"
347 .endif
348 .rept __NR_syscalls - __sys_nr
349 .long sys_ni_syscall
350 .endr
351 .size \sym, . - \sym
352 .endm
353
354#define NATIVE(nr, func) syscall nr, func
355
Nicolas Pitredd35afc2006-01-14 16:36:12 +0000356/*
357 * This is the syscall table declaration for native ABI syscalls.
358 * With EABI a couple syscalls are obsolete and defined as sys_ni_syscall.
359 */
Russell King96a8fae2016-10-18 19:57:01 +0100360 syscall_table_start sys_call_table
361#define COMPAT(nr, native, compat) syscall nr, native
Nicolas Pitredd35afc2006-01-14 16:36:12 +0000362#ifdef CONFIG_AEABI
Russell King96a8fae2016-10-18 19:57:01 +0100363#include <calls-eabi.S>
Nicolas Pitredd35afc2006-01-14 16:36:12 +0000364#else
Russell King96a8fae2016-10-18 19:57:01 +0100365#include <calls-oabi.S>
Nicolas Pitredd35afc2006-01-14 16:36:12 +0000366#endif
Russell King96a8fae2016-10-18 19:57:01 +0100367#undef COMPAT
368 syscall_table_end sys_call_table
Linus Torvalds1da177e2005-04-16 15:20:36 -0700369
370/*============================================================================
371 * Special system call wrappers
372 */
373@ r0 = syscall number
Russell King567bd982005-12-17 15:25:42 +0000374@ r8 = syscall table
Linus Torvalds1da177e2005-04-16 15:20:36 -0700375sys_syscall:
Paul Brook52475932006-05-16 14:25:55 +0100376 bic scno, r0, #__NR_OABI_SYSCALL_BASE
Linus Torvalds1da177e2005-04-16 15:20:36 -0700377 cmp scno, #__NR_syscall - __NR_SYSCALL_BASE
378 cmpne scno, #NR_syscalls @ check range
379 stmloia sp, {r5, r6} @ shuffle args
380 movlo r0, r1
381 movlo r1, r2
382 movlo r2, r3
383 movlo r3, r4
384 ldrlo pc, [tbl, scno, lsl #2]
385 b sys_ni_syscall
Catalin Marinas93ed3972008-08-28 11:22:32 +0100386ENDPROC(sys_syscall)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700387
Linus Torvalds1da177e2005-04-16 15:20:36 -0700388sys_sigreturn_wrapper:
389 add r0, sp, #S_OFF
Al Viro653d48b2010-09-17 14:34:39 +0100390 mov why, #0 @ prevent syscall restart handling
Linus Torvalds1da177e2005-04-16 15:20:36 -0700391 b sys_sigreturn
Catalin Marinas93ed3972008-08-28 11:22:32 +0100392ENDPROC(sys_sigreturn_wrapper)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700393
394sys_rt_sigreturn_wrapper:
395 add r0, sp, #S_OFF
Al Viro653d48b2010-09-17 14:34:39 +0100396 mov why, #0 @ prevent syscall restart handling
Linus Torvalds1da177e2005-04-16 15:20:36 -0700397 b sys_rt_sigreturn
Catalin Marinas93ed3972008-08-28 11:22:32 +0100398ENDPROC(sys_rt_sigreturn_wrapper)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700399
Nicolas Pitre713c4812006-01-14 16:35:03 +0000400sys_statfs64_wrapper:
401 teq r1, #88
402 moveq r1, #84
403 b sys_statfs64
Catalin Marinas93ed3972008-08-28 11:22:32 +0100404ENDPROC(sys_statfs64_wrapper)
Nicolas Pitre713c4812006-01-14 16:35:03 +0000405
406sys_fstatfs64_wrapper:
407 teq r1, #88
408 moveq r1, #84
409 b sys_fstatfs64
Catalin Marinas93ed3972008-08-28 11:22:32 +0100410ENDPROC(sys_fstatfs64_wrapper)
Nicolas Pitre713c4812006-01-14 16:35:03 +0000411
Linus Torvalds1da177e2005-04-16 15:20:36 -0700412/*
413 * Note: off_4k (r5) is always units of 4K. If we can't do the requested
414 * offset, we return EINVAL.
415 */
416sys_mmap2:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700417 str r5, [sp, #4]
Al Virof8b72562009-11-30 17:37:04 -0500418 b sys_mmap_pgoff
Catalin Marinas93ed3972008-08-28 11:22:32 +0100419ENDPROC(sys_mmap2)
Nicolas Pitre687ad012006-01-14 16:35:31 +0000420
421#ifdef CONFIG_OABI_COMPAT
Nicolas Pitredd35afc2006-01-14 16:36:12 +0000422
Nicolas Pitre687ad012006-01-14 16:35:31 +0000423/*
424 * These are syscalls with argument register differences
425 */
426
427sys_oabi_pread64:
428 stmia sp, {r3, r4}
429 b sys_pread64
Catalin Marinas93ed3972008-08-28 11:22:32 +0100430ENDPROC(sys_oabi_pread64)
Nicolas Pitre687ad012006-01-14 16:35:31 +0000431
432sys_oabi_pwrite64:
433 stmia sp, {r3, r4}
434 b sys_pwrite64
Catalin Marinas93ed3972008-08-28 11:22:32 +0100435ENDPROC(sys_oabi_pwrite64)
Nicolas Pitre687ad012006-01-14 16:35:31 +0000436
437sys_oabi_truncate64:
438 mov r3, r2
439 mov r2, r1
440 b sys_truncate64
Catalin Marinas93ed3972008-08-28 11:22:32 +0100441ENDPROC(sys_oabi_truncate64)
Nicolas Pitre687ad012006-01-14 16:35:31 +0000442
443sys_oabi_ftruncate64:
444 mov r3, r2
445 mov r2, r1
446 b sys_ftruncate64
Catalin Marinas93ed3972008-08-28 11:22:32 +0100447ENDPROC(sys_oabi_ftruncate64)
Nicolas Pitre687ad012006-01-14 16:35:31 +0000448
449sys_oabi_readahead:
450 str r3, [sp]
451 mov r3, r2
452 mov r2, r1
453 b sys_readahead
Catalin Marinas93ed3972008-08-28 11:22:32 +0100454ENDPROC(sys_oabi_readahead)
Nicolas Pitre687ad012006-01-14 16:35:31 +0000455
Nicolas Pitredd35afc2006-01-14 16:36:12 +0000456/*
457 * Let's declare a second syscall table for old ABI binaries
458 * using the compatibility syscall entries.
459 */
Russell King96a8fae2016-10-18 19:57:01 +0100460 syscall_table_start sys_oabi_call_table
461#define COMPAT(nr, native, compat) syscall nr, compat
462#include <calls-oabi.S>
463 syscall_table_end sys_oabi_call_table
Nicolas Pitredd35afc2006-01-14 16:36:12 +0000464
Nicolas Pitre687ad012006-01-14 16:35:31 +0000465#endif
466