blob: 271cb8a1eba1eefe4469db9ae5a677385fa8c2cc [file] [log] [blame]
Thomas Gleixnerd2912cb2019-06-04 10:11:33 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/*
3 * linux/arch/arm/kernel/entry-common.S
4 *
5 * Copyright (C) 2000 Russell King
Linus Torvalds1da177e2005-04-16 15:20:36 -07006 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007
Russell King6ebbf2c2014-06-30 16:29:12 +01008#include <asm/assembler.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07009#include <asm/unistd.h>
Abhishek Sagar395a59d2008-06-21 23:47:27 +053010#include <asm/ftrace.h>
Catalin Marinasc4c57162009-02-16 11:42:09 +010011#include <asm/unwind.h>
Thomas Garniere33f8d322017-09-07 08:30:46 -070012#include <asm/memory.h>
Russell King96a8fae2016-10-18 19:57:01 +010013#ifdef CONFIG_AEABI
14#include <asm/unistd-oabi.h>
15#endif
16
17 .equ NR_syscalls, __NR_syscalls
Linus Torvalds1da177e2005-04-16 15:20:36 -070018
Rob Herring13a50452012-02-07 09:28:22 -060019#ifdef CONFIG_NEED_RET_TO_USER
20#include <mach/entry-macro.S>
21#else
22 .macro arch_ret_to_user, tmp1, tmp2
23 .endm
24#endif
25
Linus Torvalds1da177e2005-04-16 15:20:36 -070026#include "entry-header.S"
27
Russell King309ee042017-03-24 16:15:45 +000028saved_psr .req r8
Russell Kingfcea4522017-03-24 16:22:10 +000029#if defined(CONFIG_TRACE_IRQFLAGS) || defined(CONFIG_CONTEXT_TRACKING)
30saved_pc .req r9
31#define TRACE(x...) x
32#else
Russell King309ee042017-03-24 16:15:45 +000033saved_pc .req lr
Russell Kingfcea4522017-03-24 16:22:10 +000034#define TRACE(x...)
35#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070036
Russell Kingc6089062017-11-24 23:54:22 +000037 .section .entry.text,"ax",%progbits
Linus Torvalds1da177e2005-04-16 15:20:36 -070038 .align 5
Mathieu Desnoyersb74406f2018-06-02 08:43:56 -040039#if !(IS_ENABLED(CONFIG_TRACE_IRQFLAGS) || IS_ENABLED(CONFIG_CONTEXT_TRACKING) || \
40 IS_ENABLED(CONFIG_DEBUG_RSEQ))
Linus Torvalds1da177e2005-04-16 15:20:36 -070041/*
Russell King3302cad2015-08-20 16:13:37 +010042 * This is the fast syscall return path. We do as little as possible here,
43 * such as avoiding writing r0 to the stack. We only use this path if we
Mathieu Desnoyersb74406f2018-06-02 08:43:56 -040044 * have tracing, context tracking and rseq debug disabled - the overheads
45 * from those features make this path too inefficient.
Linus Torvalds1da177e2005-04-16 15:20:36 -070046 */
47ret_fast_syscall:
Vincent Whitchurchafc9f652018-07-13 11:12:22 +010048__ret_fast_syscall:
Catalin Marinasc4c57162009-02-16 11:42:09 +010049 UNWIND(.fnstart )
50 UNWIND(.cantunwind )
Russell King3302cad2015-08-20 16:13:37 +010051 disable_irq_notrace @ disable interrupts
Thomas Garniere33f8d322017-09-07 08:30:46 -070052 ldr r2, [tsk, #TI_ADDR_LIMIT]
53 cmp r2, #TASK_SIZE
54 blne addr_limit_check_failed
Russell King1b979372015-05-15 11:02:23 +010055 ldr r1, [tsk, #TI_FLAGS] @ re-check for syscall tracing
Thomas Garnier24042692017-09-07 08:30:45 -070056 tst r1, #_TIF_SYSCALL_WORK | _TIF_WORK_MASK
Linus Torvalds1da177e2005-04-16 15:20:36 -070057 bne fast_work_pending
Russell Kingf4dc9a42005-04-26 15:20:34 +010058
Thomas Garniere33f8d322017-09-07 08:30:46 -070059
Dan Williamsf80dff92007-02-16 22:16:32 +010060 /* perform architecture specific actions before user return */
61 arch_ret_to_user r1, lr
62
Catalin Marinasb86040a2009-07-24 12:32:54 +010063 restore_user_regs fast = 1, offset = S_OFF
Catalin Marinasc4c57162009-02-16 11:42:09 +010064 UNWIND(.fnend )
Russell King3302cad2015-08-20 16:13:37 +010065ENDPROC(ret_fast_syscall)
Linus Torvalds1da177e2005-04-16 15:20:36 -070066
Russell King3302cad2015-08-20 16:13:37 +010067 /* Ok, we need to do extra processing, enter the slow path. */
Linus Torvalds1da177e2005-04-16 15:20:36 -070068fast_work_pending:
69 str r0, [sp, #S_R0+S_OFF]! @ returned r0
Russell King3302cad2015-08-20 16:13:37 +010070 /* fall through to work_pending */
71#else
72/*
Mathieu Desnoyersb74406f2018-06-02 08:43:56 -040073 * The "replacement" ret_fast_syscall for when tracing, context tracking,
74 * or rseq debug is enabled. As we will need to call out to some C functions,
75 * we save r0 first to avoid needing to save registers around each C function
76 * call.
Russell King3302cad2015-08-20 16:13:37 +010077 */
78ret_fast_syscall:
Vincent Whitchurchafc9f652018-07-13 11:12:22 +010079__ret_fast_syscall:
Russell King3302cad2015-08-20 16:13:37 +010080 UNWIND(.fnstart )
81 UNWIND(.cantunwind )
82 str r0, [sp, #S_R0 + S_OFF]! @ save returned r0
Mathieu Desnoyersb74406f2018-06-02 08:43:56 -040083#if IS_ENABLED(CONFIG_DEBUG_RSEQ)
84 /* do_rseq_syscall needs interrupts enabled. */
85 mov r0, sp @ 'regs'
86 bl do_rseq_syscall
87#endif
Russell King3302cad2015-08-20 16:13:37 +010088 disable_irq_notrace @ disable interrupts
Thomas Garniere33f8d322017-09-07 08:30:46 -070089 ldr r2, [tsk, #TI_ADDR_LIMIT]
90 cmp r2, #TASK_SIZE
91 blne addr_limit_check_failed
Russell King3302cad2015-08-20 16:13:37 +010092 ldr r1, [tsk, #TI_FLAGS] @ re-check for syscall tracing
Thomas Garnier24042692017-09-07 08:30:45 -070093 tst r1, #_TIF_SYSCALL_WORK | _TIF_WORK_MASK
Russell King3302cad2015-08-20 16:13:37 +010094 beq no_work_pending
95 UNWIND(.fnend )
96ENDPROC(ret_fast_syscall)
97
98 /* Slower path - fall through to work_pending */
99#endif
100
101 tst r1, #_TIF_SYSCALL_WORK
102 bne __sys_trace_return_nosave
103slow_work_pending:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104 mov r0, sp @ 'regs'
105 mov r2, why @ 'syscall'
Al Viro0a267fa2012-07-19 17:47:55 +0100106 bl do_work_pending
Al Viro66285212012-07-19 17:48:50 +0100107 cmp r0, #0
Al Viro81783782012-07-19 17:48:21 +0100108 beq no_work_pending
Al Viro66285212012-07-19 17:48:50 +0100109 movlt scno, #(__NR_restart_syscall - __NR_SYSCALL_BASE)
Al Viro81783782012-07-19 17:48:21 +0100110 ldmia sp, {r0 - r6} @ have to reload r0 - r6
111 b local_restart @ ... and off we go
Drew Richardsone83dd372015-08-06 18:50:27 +0100112ENDPROC(ret_fast_syscall)
Al Viro81783782012-07-19 17:48:21 +0100113
Linus Torvalds1da177e2005-04-16 15:20:36 -0700114/*
115 * "slow" syscall return path. "why" tells us if this was a real syscall.
Russell King3302cad2015-08-20 16:13:37 +0100116 * IRQs may be enabled here, so always disable them. Note that we use the
117 * "notrace" version to avoid calling into the tracing code unnecessarily.
118 * do_work_pending() will update this state if necessary.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700119 */
120ENTRY(ret_to_user)
121ret_slow_syscall:
Mathieu Desnoyersb74406f2018-06-02 08:43:56 -0400122#if IS_ENABLED(CONFIG_DEBUG_RSEQ)
123 /* do_rseq_syscall needs interrupts enabled. */
124 enable_irq_notrace @ enable interrupts
125 mov r0, sp @ 'regs'
126 bl do_rseq_syscall
127#endif
Russell King3302cad2015-08-20 16:13:37 +0100128 disable_irq_notrace @ disable interrupts
Ming Lei9fc25522011-06-05 02:24:58 +0100129ENTRY(ret_to_user_from_irq)
Thomas Garniere33f8d322017-09-07 08:30:46 -0700130 ldr r2, [tsk, #TI_ADDR_LIMIT]
131 cmp r2, #TASK_SIZE
132 blne addr_limit_check_failed
Linus Torvalds1da177e2005-04-16 15:20:36 -0700133 ldr r1, [tsk, #TI_FLAGS]
134 tst r1, #_TIF_WORK_MASK
Russell King3302cad2015-08-20 16:13:37 +0100135 bne slow_work_pending
Linus Torvalds1da177e2005-04-16 15:20:36 -0700136no_work_pending:
Russell King3302cad2015-08-20 16:13:37 +0100137 asm_trace_hardirqs_on save = 0
Russell King651e9492013-03-28 11:44:25 +0000138
Dan Williamsf80dff92007-02-16 22:16:32 +0100139 /* perform architecture specific actions before user return */
140 arch_ret_to_user r1, lr
Kevin Hilmanb0088482013-03-28 22:54:40 +0100141 ct_user_enter save = 0
Dan Williamsf80dff92007-02-16 22:16:32 +0100142
Catalin Marinasb86040a2009-07-24 12:32:54 +0100143 restore_user_regs fast = 0, offset = 0
Ming Lei9fc25522011-06-05 02:24:58 +0100144ENDPROC(ret_to_user_from_irq)
Catalin Marinas93ed3972008-08-28 11:22:32 +0100145ENDPROC(ret_to_user)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146
147/*
148 * This is how we return from a fork.
149 */
150ENTRY(ret_from_fork)
151 bl schedule_tail
Al Viro9fff2fa2012-10-10 22:23:29 -0400152 cmp r5, #0
153 movne r0, r4
Russell King14327c62015-04-21 14:17:25 +0100154 badrne lr, 1f
Russell King6ebbf2c2014-06-30 16:29:12 +0100155 retne r5
Russell King68687c82012-10-15 00:16:49 +01001561: get_thread_info tsk
Linus Torvalds1da177e2005-04-16 15:20:36 -0700157 b ret_slow_syscall
Catalin Marinas93ed3972008-08-28 11:22:32 +0100158ENDPROC(ret_from_fork)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700159
Linus Torvalds1da177e2005-04-16 15:20:36 -0700160/*=============================================================================
161 * SWI handler
162 *-----------------------------------------------------------------------------
163 */
164
Linus Torvalds1da177e2005-04-16 15:20:36 -0700165 .align 5
166ENTRY(vector_swi)
Uwe Kleine-König19c4d592010-05-21 18:06:42 +0100167#ifdef CONFIG_CPU_V7M
168 v7m_exception_entry
169#else
Russell King5745eef62016-05-10 16:34:27 +0100170 sub sp, sp, #PT_REGS_SIZE
Russell Kingf4dc9a42005-04-26 15:20:34 +0100171 stmia sp, {r0 - r12} @ Calling r0 - r12
Catalin Marinasb86040a2009-07-24 12:32:54 +0100172 ARM( add r8, sp, #S_PC )
173 ARM( stmdb r8, {sp, lr}^ ) @ Calling sp, lr
174 THUMB( mov r8, sp )
175 THUMB( store_user_sp_lr r8, r10, S_SP ) @ calling sp, lr
Russell King309ee042017-03-24 16:15:45 +0000176 mrs saved_psr, spsr @ called from non-FIQ mode, so ok.
Russell Kingfcea4522017-03-24 16:22:10 +0000177 TRACE( mov saved_pc, lr )
Russell King309ee042017-03-24 16:15:45 +0000178 str saved_pc, [sp, #S_PC] @ Save calling PC
179 str saved_psr, [sp, #S_PSR] @ Save CPSR
Russell Kingf4dc9a42005-04-26 15:20:34 +0100180 str r0, [sp, #S_OLD_R0] @ Save OLD_R0
Uwe Kleine-König19c4d592010-05-21 18:06:42 +0100181#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700182 zero_fp
Russell King195b58a2014-08-28 13:08:14 +0100183 alignment_trap r10, ip, __cr_alignment
Russell Kingdca778c2017-03-24 16:23:25 +0000184 asm_trace_hardirqs_on save=0
185 enable_irq_notrace
186 ct_user_exit save=0
Will Deacon1aa2b3b2013-06-05 11:25:13 +0100187
Russell Kinge0f9f4a2005-04-26 15:19:24 +0100188 /*
189 * Get the system call number.
190 */
Nicolas Pitre3f2829a2006-01-14 16:31:29 +0000191
Nicolas Pitredd35afc2006-01-14 16:36:12 +0000192#if defined(CONFIG_OABI_COMPAT)
Nicolas Pitre3f2829a2006-01-14 16:31:29 +0000193
Nicolas Pitredd35afc2006-01-14 16:36:12 +0000194 /*
195 * If we have CONFIG_OABI_COMPAT then we need to look at the swi
196 * value to determine if it is an EABI or an old ABI call.
197 */
198#ifdef CONFIG_ARM_THUMB
Russell King309ee042017-03-24 16:15:45 +0000199 tst saved_psr, #PSR_T_BIT
Nicolas Pitredd35afc2006-01-14 16:36:12 +0000200 movne r10, #0 @ no thumb OABI emulation
Russell King309ee042017-03-24 16:15:45 +0000201 USER( ldreq r10, [saved_pc, #-4] ) @ get SWI instruction
Nicolas Pitredd35afc2006-01-14 16:36:12 +0000202#else
Russell King309ee042017-03-24 16:15:45 +0000203 USER( ldr r10, [saved_pc, #-4] ) @ get SWI instruction
Nicolas Pitredd35afc2006-01-14 16:36:12 +0000204#endif
Ben Dooks457c2402013-02-12 18:59:57 +0000205 ARM_BE8(rev r10, r10) @ little endian instruction
Nicolas Pitredd35afc2006-01-14 16:36:12 +0000206
207#elif defined(CONFIG_AEABI)
208
209 /*
210 * Pure EABI user space always put syscall number into scno (r7).
211 */
Nicolas Pitre3f2829a2006-01-14 16:31:29 +0000212#elif defined(CONFIG_ARM_THUMB)
Nicolas Pitredd35afc2006-01-14 16:36:12 +0000213 /* Legacy ABI only, possibly thumb mode. */
Russell King309ee042017-03-24 16:15:45 +0000214 tst saved_psr, #PSR_T_BIT @ this is SPSR from save_user_regs
Russell Kinge0f9f4a2005-04-26 15:19:24 +0100215 addne scno, r7, #__NR_SYSCALL_BASE @ put OS number in
Russell King309ee042017-03-24 16:15:45 +0000216 USER( ldreq scno, [saved_pc, #-4] )
Nicolas Pitredd35afc2006-01-14 16:36:12 +0000217
Russell Kinge0f9f4a2005-04-26 15:19:24 +0100218#else
Nicolas Pitredd35afc2006-01-14 16:36:12 +0000219 /* Legacy ABI only. */
Russell King309ee042017-03-24 16:15:45 +0000220 USER( ldr scno, [saved_pc, #-4] ) @ get SWI instruction
Russell Kinge0f9f4a2005-04-26 15:19:24 +0100221#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700222
Russell King309ee042017-03-24 16:15:45 +0000223 /* saved_psr and saved_pc are now dead */
224
Russell King2190fed2015-08-20 10:32:02 +0100225 uaccess_disable tbl
226
Nicolas Pitredd35afc2006-01-14 16:36:12 +0000227 adr tbl, sys_call_table @ load syscall table pointer
Nicolas Pitredd35afc2006-01-14 16:36:12 +0000228
229#if defined(CONFIG_OABI_COMPAT)
230 /*
231 * If the swi argument is zero, this is an EABI call and we do nothing.
232 *
233 * If this is an old ABI call, get the syscall number into scno and
234 * get the old ABI syscall table address.
235 */
236 bics r10, r10, #0xff000000
237 eorne scno, r10, #__NR_OABI_SYSCALL_BASE
238 ldrne tbl, =sys_oabi_call_table
239#elif !defined(CONFIG_AEABI)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700240 bic scno, scno, #0xff000000 @ mask off SWI op-code
Russell Kinge0f9f4a2005-04-26 15:19:24 +0100241 eor scno, scno, #__NR_SYSCALL_BASE @ check OS number
Nicolas Pitre3f2829a2006-01-14 16:31:29 +0000242#endif
Russell Kingda594e32017-03-24 16:19:12 +0000243 get_thread_info tsk
Russell Kingdca778c2017-03-24 16:23:25 +0000244 /*
245 * Reload the registers that may have been corrupted on entry to
246 * the syscall assembly (by tracing or context tracking.)
247 */
248 TRACE( ldmia sp, {r0 - r3} )
Nicolas Pitredd35afc2006-01-14 16:36:12 +0000249
Al Viro81783782012-07-19 17:48:21 +0100250local_restart:
Nicolas Pitre70c70d92010-08-26 15:08:35 -0700251 ldr r10, [tsk, #TI_FLAGS] @ check for syscall tracing
Nicolas Pitre3f2829a2006-01-14 16:31:29 +0000252 stmdb sp!, {r4, r5} @ push fifth and sixth args
Nicolas Pitre70c70d92010-08-26 15:08:35 -0700253
Nathaniel Husted29ef73b2012-01-03 14:23:09 -0500254 tst r10, #_TIF_SYSCALL_WORK @ are we tracing syscalls?
Linus Torvalds1da177e2005-04-16 15:20:36 -0700255 bne __sys_trace
256
Vincent Whitchurchafc9f652018-07-13 11:12:22 +0100257 invoke_syscall tbl, scno, r10, __ret_fast_syscall
Linus Torvalds1da177e2005-04-16 15:20:36 -0700258
259 add r1, sp, #S_OFF
Will Deacond95bc252013-09-19 10:32:20 +01002602: cmp scno, #(__ARM_NR_BASE - __NR_SYSCALL_BASE)
Russell Kinge0f9f4a2005-04-26 15:19:24 +0100261 eor r0, scno, #__NR_SYSCALL_BASE @ put OS number back
Will Deacon377747c2013-05-13 19:16:34 +0100262 bcs arm_syscall
Will Deacond95bc252013-09-19 10:32:20 +0100263 mov why, #0 @ no longer a real syscall
Linus Torvalds1da177e2005-04-16 15:20:36 -0700264 b sys_ni_syscall @ not private func
Will Deacon1aa2b3b2013-06-05 11:25:13 +0100265
266#if defined(CONFIG_OABI_COMPAT) || !defined(CONFIG_AEABI)
267 /*
268 * We failed to handle a fault trying to access the page
269 * containing the swi instruction, but we're not really in a
270 * position to return -EFAULT. Instead, return back to the
271 * instruction and re-enter the user fault handling path trying
272 * to page it in. This will likely result in sending SEGV to the
273 * current task.
274 */
2759001:
Russell King309ee042017-03-24 16:15:45 +0000276 sub lr, saved_pc, #4
Will Deacon1aa2b3b2013-06-05 11:25:13 +0100277 str lr, [sp, #S_PC]
Russell Kingda594e32017-03-24 16:19:12 +0000278 get_thread_info tsk
Will Deacon1aa2b3b2013-06-05 11:25:13 +0100279 b ret_fast_syscall
280#endif
Catalin Marinas93ed3972008-08-28 11:22:32 +0100281ENDPROC(vector_swi)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700282
283 /*
284 * This is the really slow path. We're going to be doing
285 * context switches, and waiting for our parent to respond.
286 */
287__sys_trace:
Will Deaconad722542012-07-06 15:50:14 +0100288 mov r1, scno
289 add r0, sp, #S_OFF
290 bl syscall_trace_enter
Russell King10573ae2018-05-11 11:16:22 +0100291 mov scno, r0
292 invoke_syscall tbl, scno, r10, __sys_trace_return, reload=1
Kees Cookad75b512012-11-15 22:12:17 +0100293 cmp scno, #-1 @ skip the syscall?
294 bne 2b
295 add sp, sp, #S_OFF @ restore stack
Linus Torvalds1da177e2005-04-16 15:20:36 -0700296
Timothy E Baldwinf18aef72018-10-08 19:26:48 +0100297__sys_trace_return_nosave:
298 enable_irq_notrace
Will Deaconad722542012-07-06 15:50:14 +0100299 mov r0, sp
300 bl syscall_trace_exit
Linus Torvalds1da177e2005-04-16 15:20:36 -0700301 b ret_slow_syscall
302
Timothy E Baldwinf18aef72018-10-08 19:26:48 +0100303__sys_trace_return:
304 str r0, [sp, #S_R0 + S_OFF]! @ save returned r0
Russell King3302cad2015-08-20 16:13:37 +0100305 mov r0, sp
306 bl syscall_trace_exit
307 b ret_slow_syscall
308
Linus Torvalds1da177e2005-04-16 15:20:36 -0700309 .align 5
310#ifdef CONFIG_ALIGNMENT_TRAP
311 .type __cr_alignment, #object
312__cr_alignment:
313 .word cr_alignment
314#endif
Nicolas Pitredd35afc2006-01-14 16:36:12 +0000315 .ltorg
316
Russell King96a8fae2016-10-18 19:57:01 +0100317 .macro syscall_table_start, sym
318 .equ __sys_nr, 0
319 .type \sym, #object
320ENTRY(\sym)
321 .endm
322
323 .macro syscall, nr, func
324 .ifgt __sys_nr - \nr
325 .error "Duplicated/unorded system call entry"
326 .endif
327 .rept \nr - __sys_nr
328 .long sys_ni_syscall
329 .endr
330 .long \func
331 .equ __sys_nr, \nr + 1
332 .endm
333
334 .macro syscall_table_end, sym
335 .ifgt __sys_nr - __NR_syscalls
336 .error "System call table too big"
337 .endif
338 .rept __NR_syscalls - __sys_nr
339 .long sys_ni_syscall
340 .endr
341 .size \sym, . - \sym
342 .endm
343
344#define NATIVE(nr, func) syscall nr, func
345
Nicolas Pitredd35afc2006-01-14 16:36:12 +0000346/*
347 * This is the syscall table declaration for native ABI syscalls.
348 * With EABI a couple syscalls are obsolete and defined as sys_ni_syscall.
349 */
Russell King96a8fae2016-10-18 19:57:01 +0100350 syscall_table_start sys_call_table
351#define COMPAT(nr, native, compat) syscall nr, native
Nicolas Pitredd35afc2006-01-14 16:36:12 +0000352#ifdef CONFIG_AEABI
Russell King96a8fae2016-10-18 19:57:01 +0100353#include <calls-eabi.S>
Nicolas Pitredd35afc2006-01-14 16:36:12 +0000354#else
Russell King96a8fae2016-10-18 19:57:01 +0100355#include <calls-oabi.S>
Nicolas Pitredd35afc2006-01-14 16:36:12 +0000356#endif
Russell King96a8fae2016-10-18 19:57:01 +0100357#undef COMPAT
358 syscall_table_end sys_call_table
Linus Torvalds1da177e2005-04-16 15:20:36 -0700359
360/*============================================================================
361 * Special system call wrappers
362 */
363@ r0 = syscall number
Russell King567bd982005-12-17 15:25:42 +0000364@ r8 = syscall table
Linus Torvalds1da177e2005-04-16 15:20:36 -0700365sys_syscall:
Paul Brook52475932006-05-16 14:25:55 +0100366 bic scno, r0, #__NR_OABI_SYSCALL_BASE
Linus Torvalds1da177e2005-04-16 15:20:36 -0700367 cmp scno, #__NR_syscall - __NR_SYSCALL_BASE
368 cmpne scno, #NR_syscalls @ check range
Russell King10573ae2018-05-11 11:16:22 +0100369#ifdef CONFIG_CPU_SPECTRE
370 movhs scno, #0
371 csdb
372#endif
Stefan Agnere44fc382019-02-18 00:57:38 +0100373 stmialo sp, {r5, r6} @ shuffle args
Linus Torvalds1da177e2005-04-16 15:20:36 -0700374 movlo r0, r1
375 movlo r1, r2
376 movlo r2, r3
377 movlo r3, r4
378 ldrlo pc, [tbl, scno, lsl #2]
379 b sys_ni_syscall
Catalin Marinas93ed3972008-08-28 11:22:32 +0100380ENDPROC(sys_syscall)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700381
Linus Torvalds1da177e2005-04-16 15:20:36 -0700382sys_sigreturn_wrapper:
383 add r0, sp, #S_OFF
Al Viro653d48b2010-09-17 14:34:39 +0100384 mov why, #0 @ prevent syscall restart handling
Linus Torvalds1da177e2005-04-16 15:20:36 -0700385 b sys_sigreturn
Catalin Marinas93ed3972008-08-28 11:22:32 +0100386ENDPROC(sys_sigreturn_wrapper)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700387
388sys_rt_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_rt_sigreturn
Catalin Marinas93ed3972008-08-28 11:22:32 +0100392ENDPROC(sys_rt_sigreturn_wrapper)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700393
Nicolas Pitre713c4812006-01-14 16:35:03 +0000394sys_statfs64_wrapper:
395 teq r1, #88
396 moveq r1, #84
397 b sys_statfs64
Catalin Marinas93ed3972008-08-28 11:22:32 +0100398ENDPROC(sys_statfs64_wrapper)
Nicolas Pitre713c4812006-01-14 16:35:03 +0000399
400sys_fstatfs64_wrapper:
401 teq r1, #88
402 moveq r1, #84
403 b sys_fstatfs64
Catalin Marinas93ed3972008-08-28 11:22:32 +0100404ENDPROC(sys_fstatfs64_wrapper)
Nicolas Pitre713c4812006-01-14 16:35:03 +0000405
Linus Torvalds1da177e2005-04-16 15:20:36 -0700406/*
407 * Note: off_4k (r5) is always units of 4K. If we can't do the requested
408 * offset, we return EINVAL.
409 */
410sys_mmap2:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700411 str r5, [sp, #4]
Al Virof8b72562009-11-30 17:37:04 -0500412 b sys_mmap_pgoff
Catalin Marinas93ed3972008-08-28 11:22:32 +0100413ENDPROC(sys_mmap2)
Nicolas Pitre687ad012006-01-14 16:35:31 +0000414
415#ifdef CONFIG_OABI_COMPAT
Nicolas Pitredd35afc2006-01-14 16:36:12 +0000416
Nicolas Pitre687ad012006-01-14 16:35:31 +0000417/*
418 * These are syscalls with argument register differences
419 */
420
421sys_oabi_pread64:
422 stmia sp, {r3, r4}
423 b sys_pread64
Catalin Marinas93ed3972008-08-28 11:22:32 +0100424ENDPROC(sys_oabi_pread64)
Nicolas Pitre687ad012006-01-14 16:35:31 +0000425
426sys_oabi_pwrite64:
427 stmia sp, {r3, r4}
428 b sys_pwrite64
Catalin Marinas93ed3972008-08-28 11:22:32 +0100429ENDPROC(sys_oabi_pwrite64)
Nicolas Pitre687ad012006-01-14 16:35:31 +0000430
431sys_oabi_truncate64:
432 mov r3, r2
433 mov r2, r1
434 b sys_truncate64
Catalin Marinas93ed3972008-08-28 11:22:32 +0100435ENDPROC(sys_oabi_truncate64)
Nicolas Pitre687ad012006-01-14 16:35:31 +0000436
437sys_oabi_ftruncate64:
438 mov r3, r2
439 mov r2, r1
440 b sys_ftruncate64
Catalin Marinas93ed3972008-08-28 11:22:32 +0100441ENDPROC(sys_oabi_ftruncate64)
Nicolas Pitre687ad012006-01-14 16:35:31 +0000442
443sys_oabi_readahead:
444 str r3, [sp]
445 mov r3, r2
446 mov r2, r1
447 b sys_readahead
Catalin Marinas93ed3972008-08-28 11:22:32 +0100448ENDPROC(sys_oabi_readahead)
Nicolas Pitre687ad012006-01-14 16:35:31 +0000449
Nicolas Pitredd35afc2006-01-14 16:36:12 +0000450/*
451 * Let's declare a second syscall table for old ABI binaries
452 * using the compatibility syscall entries.
453 */
Russell King96a8fae2016-10-18 19:57:01 +0100454 syscall_table_start sys_oabi_call_table
455#define COMPAT(nr, native, compat) syscall nr, compat
456#include <calls-oabi.S>
457 syscall_table_end sys_oabi_call_table
Nicolas Pitredd35afc2006-01-14 16:36:12 +0000458
Nicolas Pitre687ad012006-01-14 16:35:31 +0000459#endif
460