xref: /linux/arch/arm/kernel/entry-common.S (revision 50596b7559bf226bb35ad55855ee979453ec06a1)
1d2912cb1SThomas Gleixner/* SPDX-License-Identifier: GPL-2.0-only */
21da177e4SLinus Torvalds/*
31da177e4SLinus Torvalds *  linux/arch/arm/kernel/entry-common.S
41da177e4SLinus Torvalds *
51da177e4SLinus Torvalds *  Copyright (C) 2000 Russell King
61da177e4SLinus Torvalds */
71da177e4SLinus Torvalds
86ebbf2ceSRussell King#include <asm/assembler.h>
91da177e4SLinus Torvalds#include <asm/unistd.h>
10395a59d0SAbhishek Sagar#include <asm/ftrace.h>
11c4c5716eSCatalin Marinas#include <asm/unwind.h>
12e33f8d32SThomas Garnier#include <asm/memory.h>
1396a8fae0SRussell King#ifdef CONFIG_AEABI
1496a8fae0SRussell King#include <asm/unistd-oabi.h>
1596a8fae0SRussell King#endif
1696a8fae0SRussell King
1796a8fae0SRussell King	.equ	NR_syscalls, __NR_syscalls
181da177e4SLinus Torvalds
1913a5045dSRob Herring#ifdef CONFIG_NEED_RET_TO_USER
2013a5045dSRob Herring#include <mach/entry-macro.S>
2113a5045dSRob Herring#else
2213a5045dSRob Herring	.macro  arch_ret_to_user, tmp1, tmp2
2313a5045dSRob Herring	.endm
2413a5045dSRob Herring#endif
2513a5045dSRob Herring
261da177e4SLinus Torvalds#include "entry-header.S"
271da177e4SLinus Torvalds
28309ee042SRussell Kingsaved_psr	.req	r8
29fcea4523SRussell King#if defined(CONFIG_TRACE_IRQFLAGS) || defined(CONFIG_CONTEXT_TRACKING)
30fcea4523SRussell Kingsaved_pc	.req	r9
31fcea4523SRussell King#define TRACE(x...) x
32fcea4523SRussell King#else
33309ee042SRussell Kingsaved_pc	.req	lr
34fcea4523SRussell King#define TRACE(x...)
35fcea4523SRussell King#endif
361da177e4SLinus Torvalds
37c6089061SRussell King	.section .entry.text,"ax",%progbits
381da177e4SLinus Torvalds	.align	5
39b74406f3SMathieu Desnoyers#if !(IS_ENABLED(CONFIG_TRACE_IRQFLAGS) || IS_ENABLED(CONFIG_CONTEXT_TRACKING) || \
40b74406f3SMathieu Desnoyers	IS_ENABLED(CONFIG_DEBUG_RSEQ))
411da177e4SLinus Torvalds/*
423302caddSRussell King * This is the fast syscall return path.  We do as little as possible here,
433302caddSRussell King * such as avoiding writing r0 to the stack.  We only use this path if we
44b74406f3SMathieu Desnoyers * have tracing, context tracking and rseq debug disabled - the overheads
45b74406f3SMathieu Desnoyers * from those features make this path too inefficient.
461da177e4SLinus Torvalds */
471da177e4SLinus Torvaldsret_fast_syscall:
48afc9f65eSVincent Whitchurch__ret_fast_syscall:
49c4c5716eSCatalin Marinas UNWIND(.fnstart	)
50c4c5716eSCatalin Marinas UNWIND(.cantunwind	)
513302caddSRussell King	disable_irq_notrace			@ disable interrupts
521b979372SRussell King	ldr	r1, [tsk, #TI_FLAGS]		@ re-check for syscall tracing
5332d59773SJens Axboe	movs	r1, r1, lsl #16
541da177e4SLinus Torvalds	bne	fast_work_pending
55f4dc9a4cSRussell King
56e33f8d32SThomas Garnier
57f80dff9dSDan Williams	/* perform architecture specific actions before user return */
58f80dff9dSDan Williams	arch_ret_to_user r1, lr
59f80dff9dSDan Williams
60b86040a5SCatalin Marinas	restore_user_regs fast = 1, offset = S_OFF
61c4c5716eSCatalin Marinas UNWIND(.fnend		)
623302caddSRussell KingENDPROC(ret_fast_syscall)
631da177e4SLinus Torvalds
643302caddSRussell King	/* Ok, we need to do extra processing, enter the slow path. */
651da177e4SLinus Torvaldsfast_work_pending:
661da177e4SLinus Torvalds	str	r0, [sp, #S_R0+S_OFF]!		@ returned r0
673302caddSRussell King	/* fall through to work_pending */
683302caddSRussell King#else
693302caddSRussell King/*
70b74406f3SMathieu Desnoyers * The "replacement" ret_fast_syscall for when tracing, context tracking,
71b74406f3SMathieu Desnoyers * or rseq debug is enabled.  As we will need to call out to some C functions,
72b74406f3SMathieu Desnoyers * we save r0 first to avoid needing to save registers around each C function
73b74406f3SMathieu Desnoyers * call.
743302caddSRussell King */
753302caddSRussell Kingret_fast_syscall:
76afc9f65eSVincent Whitchurch__ret_fast_syscall:
773302caddSRussell King UNWIND(.fnstart	)
783302caddSRussell King UNWIND(.cantunwind	)
793302caddSRussell King	str	r0, [sp, #S_R0 + S_OFF]!	@ save returned r0
80b74406f3SMathieu Desnoyers#if IS_ENABLED(CONFIG_DEBUG_RSEQ)
81b74406f3SMathieu Desnoyers	/* do_rseq_syscall needs interrupts enabled. */
82b74406f3SMathieu Desnoyers	mov	r0, sp				@ 'regs'
83b74406f3SMathieu Desnoyers	bl	do_rseq_syscall
84b74406f3SMathieu Desnoyers#endif
853302caddSRussell King	disable_irq_notrace			@ disable interrupts
863302caddSRussell King	ldr	r1, [tsk, #TI_FLAGS]		@ re-check for syscall tracing
8732d59773SJens Axboe	movs	r1, r1, lsl #16
883302caddSRussell King	beq	no_work_pending
893302caddSRussell King UNWIND(.fnend		)
903302caddSRussell KingENDPROC(ret_fast_syscall)
913302caddSRussell King
923302caddSRussell King	/* Slower path - fall through to work_pending */
933302caddSRussell King#endif
943302caddSRussell King
953302caddSRussell King	tst	r1, #_TIF_SYSCALL_WORK
963302caddSRussell King	bne	__sys_trace_return_nosave
973302caddSRussell Kingslow_work_pending:
981da177e4SLinus Torvalds	mov	r0, sp				@ 'regs'
991da177e4SLinus Torvalds	mov	r2, why				@ 'syscall'
1000a267fa6SAl Viro	bl	do_work_pending
10166285217SAl Viro	cmp	r0, #0
10281783786SAl Viro	beq	no_work_pending
10366285217SAl Viro	movlt	scno, #(__NR_restart_syscall - __NR_SYSCALL_BASE)
10481783786SAl Viro	ldmia	sp, {r0 - r6}			@ have to reload r0 - r6
10581783786SAl Viro	b	local_restart			@ ... and off we go
106e83dd377SDrew RichardsonENDPROC(ret_fast_syscall)
10781783786SAl Viro
1081da177e4SLinus Torvalds/*
1091da177e4SLinus Torvalds * "slow" syscall return path.  "why" tells us if this was a real syscall.
1103302caddSRussell King * IRQs may be enabled here, so always disable them.  Note that we use the
1113302caddSRussell King * "notrace" version to avoid calling into the tracing code unnecessarily.
1123302caddSRussell King * do_work_pending() will update this state if necessary.
1131da177e4SLinus Torvalds */
1141da177e4SLinus TorvaldsENTRY(ret_to_user)
1151da177e4SLinus Torvaldsret_slow_syscall:
116b74406f3SMathieu Desnoyers#if IS_ENABLED(CONFIG_DEBUG_RSEQ)
117b74406f3SMathieu Desnoyers	/* do_rseq_syscall needs interrupts enabled. */
118b74406f3SMathieu Desnoyers	enable_irq_notrace			@ enable interrupts
119b74406f3SMathieu Desnoyers	mov	r0, sp				@ 'regs'
120b74406f3SMathieu Desnoyers	bl	do_rseq_syscall
121b74406f3SMathieu Desnoyers#endif
1223302caddSRussell King	disable_irq_notrace			@ disable interrupts
1239fc2552aSMing LeiENTRY(ret_to_user_from_irq)
1241da177e4SLinus Torvalds	ldr	r1, [tsk, #TI_FLAGS]
12532d59773SJens Axboe	movs	r1, r1, lsl #16
1263302caddSRussell King	bne	slow_work_pending
1271da177e4SLinus Torvaldsno_work_pending:
1283302caddSRussell King	asm_trace_hardirqs_on save = 0
129651e9499SRussell King
130f80dff9dSDan Williams	/* perform architecture specific actions before user return */
131f80dff9dSDan Williams	arch_ret_to_user r1, lr
132b0088480SKevin Hilman	ct_user_enter save = 0
133f80dff9dSDan Williams
134b86040a5SCatalin Marinas	restore_user_regs fast = 0, offset = 0
1359fc2552aSMing LeiENDPROC(ret_to_user_from_irq)
13693ed3970SCatalin MarinasENDPROC(ret_to_user)
1371da177e4SLinus Torvalds
1381da177e4SLinus Torvalds/*
1391da177e4SLinus Torvalds * This is how we return from a fork.
1401da177e4SLinus Torvalds */
1411da177e4SLinus TorvaldsENTRY(ret_from_fork)
1421da177e4SLinus Torvalds	bl	schedule_tail
1439fff2fa0SAl Viro	cmp	r5, #0
1449fff2fa0SAl Viro	movne	r0, r4
14514327c66SRussell King	badrne	lr, 1f
1466ebbf2ceSRussell King	retne	r5
14768687c84SRussell King1:	get_thread_info tsk
1481da177e4SLinus Torvalds	b	ret_slow_syscall
14993ed3970SCatalin MarinasENDPROC(ret_from_fork)
1501da177e4SLinus Torvalds
1511da177e4SLinus Torvalds/*=============================================================================
1521da177e4SLinus Torvalds * SWI handler
1531da177e4SLinus Torvalds *-----------------------------------------------------------------------------
1541da177e4SLinus Torvalds */
1551da177e4SLinus Torvalds
1561da177e4SLinus Torvalds	.align	5
1571da177e4SLinus TorvaldsENTRY(vector_swi)
15819c4d593SUwe Kleine-König#ifdef CONFIG_CPU_V7M
15919c4d593SUwe Kleine-König	v7m_exception_entry
16019c4d593SUwe Kleine-König#else
1615745eef6SRussell King	sub	sp, sp, #PT_REGS_SIZE
162f4dc9a4cSRussell King	stmia	sp, {r0 - r12}			@ Calling r0 - r12
163b86040a5SCatalin Marinas ARM(	add	r8, sp, #S_PC		)
164b86040a5SCatalin Marinas ARM(	stmdb	r8, {sp, lr}^		)	@ Calling sp, lr
165b86040a5SCatalin Marinas THUMB(	mov	r8, sp			)
166b86040a5SCatalin Marinas THUMB(	store_user_sp_lr r8, r10, S_SP	)	@ calling sp, lr
167309ee042SRussell King	mrs	saved_psr, spsr			@ called from non-FIQ mode, so ok.
168fcea4523SRussell King TRACE(	mov	saved_pc, lr		)
169309ee042SRussell King	str	saved_pc, [sp, #S_PC]		@ Save calling PC
170309ee042SRussell King	str	saved_psr, [sp, #S_PSR]		@ Save CPSR
171f4dc9a4cSRussell King	str	r0, [sp, #S_OLD_R0]		@ Save OLD_R0
17219c4d593SUwe Kleine-König#endif
173*50596b75SArd Biesheuvel	reload_current r10, ip
1741da177e4SLinus Torvalds	zero_fp
175195b58adSRussell King	alignment_trap r10, ip, __cr_alignment
176dca778c5SRussell King	asm_trace_hardirqs_on save=0
177dca778c5SRussell King	enable_irq_notrace
178dca778c5SRussell King	ct_user_exit save=0
1791aa2b3b7SWill Deacon
180e0f9f4a6SRussell King	/*
181e0f9f4a6SRussell King	 * Get the system call number.
182e0f9f4a6SRussell King	 */
1833f2829a3SNicolas Pitre
184dd35afc2SNicolas Pitre#if defined(CONFIG_OABI_COMPAT)
1853f2829a3SNicolas Pitre
186dd35afc2SNicolas Pitre	/*
187dd35afc2SNicolas Pitre	 * If we have CONFIG_OABI_COMPAT then we need to look at the swi
188dd35afc2SNicolas Pitre	 * value to determine if it is an EABI or an old ABI call.
189dd35afc2SNicolas Pitre	 */
190dd35afc2SNicolas Pitre#ifdef CONFIG_ARM_THUMB
191309ee042SRussell King	tst	saved_psr, #PSR_T_BIT
192dd35afc2SNicolas Pitre	movne	r10, #0				@ no thumb OABI emulation
193309ee042SRussell King USER(	ldreq	r10, [saved_pc, #-4]	)	@ get SWI instruction
194dd35afc2SNicolas Pitre#else
195309ee042SRussell King USER(	ldr	r10, [saved_pc, #-4]	)	@ get SWI instruction
196dd35afc2SNicolas Pitre#endif
197457c2403SBen Dooks ARM_BE8(rev	r10, r10)			@ little endian instruction
198dd35afc2SNicolas Pitre
199dd35afc2SNicolas Pitre#elif defined(CONFIG_AEABI)
200dd35afc2SNicolas Pitre
201dd35afc2SNicolas Pitre	/*
202dd35afc2SNicolas Pitre	 * Pure EABI user space always put syscall number into scno (r7).
203dd35afc2SNicolas Pitre	 */
2043f2829a3SNicolas Pitre#elif defined(CONFIG_ARM_THUMB)
205dd35afc2SNicolas Pitre	/* Legacy ABI only, possibly thumb mode. */
206309ee042SRussell King	tst	saved_psr, #PSR_T_BIT		@ this is SPSR from save_user_regs
207e0f9f4a6SRussell King	addne	scno, r7, #__NR_SYSCALL_BASE	@ put OS number in
208309ee042SRussell King USER(	ldreq	scno, [saved_pc, #-4]	)
209dd35afc2SNicolas Pitre
210e0f9f4a6SRussell King#else
211dd35afc2SNicolas Pitre	/* Legacy ABI only. */
212309ee042SRussell King USER(	ldr	scno, [saved_pc, #-4]	)	@ get SWI instruction
213e0f9f4a6SRussell King#endif
2141da177e4SLinus Torvalds
215309ee042SRussell King	/* saved_psr and saved_pc are now dead */
216309ee042SRussell King
2172190fed6SRussell King	uaccess_disable tbl
2184e57a4ddSArnd Bergmann	get_thread_info tsk
2192190fed6SRussell King
220dd35afc2SNicolas Pitre	adr	tbl, sys_call_table		@ load syscall table pointer
221dd35afc2SNicolas Pitre
222dd35afc2SNicolas Pitre#if defined(CONFIG_OABI_COMPAT)
223dd35afc2SNicolas Pitre	/*
224dd35afc2SNicolas Pitre	 * If the swi argument is zero, this is an EABI call and we do nothing.
225dd35afc2SNicolas Pitre	 *
226dd35afc2SNicolas Pitre	 * If this is an old ABI call, get the syscall number into scno and
227dd35afc2SNicolas Pitre	 * get the old ABI syscall table address.
228dd35afc2SNicolas Pitre	 */
229dd35afc2SNicolas Pitre	bics	r10, r10, #0xff000000
2304e57a4ddSArnd Bergmann	strne	r10, [tsk, #TI_ABI_SYSCALL]
2314e57a4ddSArnd Bergmann	streq	scno, [tsk, #TI_ABI_SYSCALL]
232dd35afc2SNicolas Pitre	eorne	scno, r10, #__NR_OABI_SYSCALL_BASE
233dd35afc2SNicolas Pitre	ldrne	tbl, =sys_oabi_call_table
234dd35afc2SNicolas Pitre#elif !defined(CONFIG_AEABI)
2351da177e4SLinus Torvalds	bic	scno, scno, #0xff000000		@ mask off SWI op-code
2364e57a4ddSArnd Bergmann	str	scno, [tsk, #TI_ABI_SYSCALL]
237e0f9f4a6SRussell King	eor	scno, scno, #__NR_SYSCALL_BASE	@ check OS number
2384e57a4ddSArnd Bergmann#else
2394e57a4ddSArnd Bergmann	str	scno, [tsk, #TI_ABI_SYSCALL]
2403f2829a3SNicolas Pitre#endif
241dca778c5SRussell King	/*
242dca778c5SRussell King	 * Reload the registers that may have been corrupted on entry to
243dca778c5SRussell King	 * the syscall assembly (by tracing or context tracking.)
244dca778c5SRussell King	 */
245dca778c5SRussell King TRACE(	ldmia	sp, {r0 - r3}		)
246dd35afc2SNicolas Pitre
24781783786SAl Virolocal_restart:
24870c70d97SNicolas Pitre	ldr	r10, [tsk, #TI_FLAGS]		@ check for syscall tracing
2493f2829a3SNicolas Pitre	stmdb	sp!, {r4, r5}			@ push fifth and sixth args
25070c70d97SNicolas Pitre
25129ef73b7SNathaniel Husted	tst	r10, #_TIF_SYSCALL_WORK		@ are we tracing syscalls?
2521da177e4SLinus Torvalds	bne	__sys_trace
2531da177e4SLinus Torvalds
254afc9f65eSVincent Whitchurch	invoke_syscall tbl, scno, r10, __ret_fast_syscall
2551da177e4SLinus Torvalds
2561da177e4SLinus Torvalds	add	r1, sp, #S_OFF
257d95bc250SWill Deacon2:	cmp	scno, #(__ARM_NR_BASE - __NR_SYSCALL_BASE)
258e0f9f4a6SRussell King	eor	r0, scno, #__NR_SYSCALL_BASE	@ put OS number back
2591da177e4SLinus Torvalds	bcs	arm_syscall
260d95bc250SWill Deacon	mov	why, #0				@ no longer a real syscall
2611da177e4SLinus Torvalds	b	sys_ni_syscall			@ not private func
2621aa2b3b7SWill Deacon
2631aa2b3b7SWill Deacon#if defined(CONFIG_OABI_COMPAT) || !defined(CONFIG_AEABI)
2641aa2b3b7SWill Deacon	/*
2651aa2b3b7SWill Deacon	 * We failed to handle a fault trying to access the page
2661aa2b3b7SWill Deacon	 * containing the swi instruction, but we're not really in a
2671aa2b3b7SWill Deacon	 * position to return -EFAULT. Instead, return back to the
2681aa2b3b7SWill Deacon	 * instruction and re-enter the user fault handling path trying
2691aa2b3b7SWill Deacon	 * to page it in. This will likely result in sending SEGV to the
2701aa2b3b7SWill Deacon	 * current task.
2711aa2b3b7SWill Deacon	 */
2721aa2b3b7SWill Deacon9001:
273309ee042SRussell King	sub	lr, saved_pc, #4
2741aa2b3b7SWill Deacon	str	lr, [sp, #S_PC]
275da594e3fSRussell King	get_thread_info tsk
2761aa2b3b7SWill Deacon	b	ret_fast_syscall
2771aa2b3b7SWill Deacon#endif
27893ed3970SCatalin MarinasENDPROC(vector_swi)
2791da177e4SLinus Torvalds
2801da177e4SLinus Torvalds	/*
2811da177e4SLinus Torvalds	 * This is the really slow path.  We're going to be doing
2821da177e4SLinus Torvalds	 * context switches, and waiting for our parent to respond.
2831da177e4SLinus Torvalds	 */
2841da177e4SLinus Torvalds__sys_trace:
285ad722541SWill Deacon	add	r0, sp, #S_OFF
286ad722541SWill Deacon	bl	syscall_trace_enter
28710573ae5SRussell King	mov	scno, r0
28810573ae5SRussell King	invoke_syscall tbl, scno, r10, __sys_trace_return, reload=1
289ad75b514SKees Cook	cmp	scno, #-1			@ skip the syscall?
290ad75b514SKees Cook	bne	2b
291ad75b514SKees Cook	add	sp, sp, #S_OFF			@ restore stack
2921da177e4SLinus Torvalds
293f18aef74STimothy E Baldwin__sys_trace_return_nosave:
294f18aef74STimothy E Baldwin	enable_irq_notrace
295ad722541SWill Deacon	mov	r0, sp
296ad722541SWill Deacon	bl	syscall_trace_exit
2971da177e4SLinus Torvalds	b	ret_slow_syscall
2981da177e4SLinus Torvalds
299f18aef74STimothy E Baldwin__sys_trace_return:
300f18aef74STimothy E Baldwin	str	r0, [sp, #S_R0 + S_OFF]!	@ save returned r0
3013302caddSRussell King	mov	r0, sp
3023302caddSRussell King	bl	syscall_trace_exit
3033302caddSRussell King	b	ret_slow_syscall
3043302caddSRussell King
3051da177e4SLinus Torvalds	.align	5
3061da177e4SLinus Torvalds#ifdef CONFIG_ALIGNMENT_TRAP
3071da177e4SLinus Torvalds	.type	__cr_alignment, #object
3081da177e4SLinus Torvalds__cr_alignment:
3091da177e4SLinus Torvalds	.word	cr_alignment
3101da177e4SLinus Torvalds#endif
311dd35afc2SNicolas Pitre	.ltorg
312dd35afc2SNicolas Pitre
31396a8fae0SRussell King	.macro	syscall_table_start, sym
31496a8fae0SRussell King	.equ	__sys_nr, 0
31596a8fae0SRussell King	.type	\sym, #object
31696a8fae0SRussell KingENTRY(\sym)
31796a8fae0SRussell King	.endm
31896a8fae0SRussell King
31996a8fae0SRussell King	.macro	syscall, nr, func
32096a8fae0SRussell King	.ifgt	__sys_nr - \nr
32196a8fae0SRussell King	.error	"Duplicated/unorded system call entry"
32296a8fae0SRussell King	.endif
32396a8fae0SRussell King	.rept	\nr - __sys_nr
32496a8fae0SRussell King	.long	sys_ni_syscall
32596a8fae0SRussell King	.endr
32696a8fae0SRussell King	.long	\func
32796a8fae0SRussell King	.equ	__sys_nr, \nr + 1
32896a8fae0SRussell King	.endm
32996a8fae0SRussell King
33096a8fae0SRussell King	.macro	syscall_table_end, sym
33196a8fae0SRussell King	.ifgt	__sys_nr - __NR_syscalls
33296a8fae0SRussell King	.error	"System call table too big"
33396a8fae0SRussell King	.endif
33496a8fae0SRussell King	.rept	__NR_syscalls - __sys_nr
33596a8fae0SRussell King	.long	sys_ni_syscall
33696a8fae0SRussell King	.endr
33796a8fae0SRussell King	.size	\sym, . - \sym
33896a8fae0SRussell King	.endm
33996a8fae0SRussell King
3400047eb9fSMasahiro Yamada#define __SYSCALL_WITH_COMPAT(nr, native, compat)	__SYSCALL(nr, native)
3410047eb9fSMasahiro Yamada#define __SYSCALL(nr, func) syscall nr, func
34296a8fae0SRussell King
343dd35afc2SNicolas Pitre/*
344dd35afc2SNicolas Pitre * This is the syscall table declaration for native ABI syscalls.
345dd35afc2SNicolas Pitre * With EABI a couple syscalls are obsolete and defined as sys_ni_syscall.
346dd35afc2SNicolas Pitre */
34796a8fae0SRussell King	syscall_table_start sys_call_table
348dd35afc2SNicolas Pitre#ifdef CONFIG_AEABI
34996a8fae0SRussell King#include <calls-eabi.S>
350dd35afc2SNicolas Pitre#else
35196a8fae0SRussell King#include <calls-oabi.S>
352dd35afc2SNicolas Pitre#endif
35396a8fae0SRussell King	syscall_table_end sys_call_table
3541da177e4SLinus Torvalds
3551da177e4SLinus Torvalds/*============================================================================
3561da177e4SLinus Torvalds * Special system call wrappers
3571da177e4SLinus Torvalds */
3581da177e4SLinus Torvalds@ r0 = syscall number
359567bd980SRussell King@ r8 = syscall table
3601da177e4SLinus Torvaldssys_syscall:
3615247593cSPaul Brook		bic	scno, r0, #__NR_OABI_SYSCALL_BASE
3621da177e4SLinus Torvalds		cmp	scno, #__NR_syscall - __NR_SYSCALL_BASE
3631da177e4SLinus Torvalds		cmpne	scno, #NR_syscalls	@ check range
36410573ae5SRussell King#ifdef CONFIG_CPU_SPECTRE
36510573ae5SRussell King		movhs	scno, #0
36610573ae5SRussell King		csdb
36710573ae5SRussell King#endif
368e44fc388SStefan Agner		stmialo	sp, {r5, r6}		@ shuffle args
3691da177e4SLinus Torvalds		movlo	r0, r1
3701da177e4SLinus Torvalds		movlo	r1, r2
3711da177e4SLinus Torvalds		movlo	r2, r3
3721da177e4SLinus Torvalds		movlo	r3, r4
3731da177e4SLinus Torvalds		ldrlo	pc, [tbl, scno, lsl #2]
3741da177e4SLinus Torvalds		b	sys_ni_syscall
37593ed3970SCatalin MarinasENDPROC(sys_syscall)
3761da177e4SLinus Torvalds
3771da177e4SLinus Torvaldssys_sigreturn_wrapper:
3781da177e4SLinus Torvalds		add	r0, sp, #S_OFF
379653d48b2SAl Viro		mov	why, #0		@ prevent syscall restart handling
3801da177e4SLinus Torvalds		b	sys_sigreturn
38193ed3970SCatalin MarinasENDPROC(sys_sigreturn_wrapper)
3821da177e4SLinus Torvalds
3831da177e4SLinus Torvaldssys_rt_sigreturn_wrapper:
3841da177e4SLinus Torvalds		add	r0, sp, #S_OFF
385653d48b2SAl Viro		mov	why, #0		@ prevent syscall restart handling
3861da177e4SLinus Torvalds		b	sys_rt_sigreturn
38793ed3970SCatalin MarinasENDPROC(sys_rt_sigreturn_wrapper)
3881da177e4SLinus Torvalds
389713c4815SNicolas Pitresys_statfs64_wrapper:
390713c4815SNicolas Pitre		teq	r1, #88
391713c4815SNicolas Pitre		moveq	r1, #84
392713c4815SNicolas Pitre		b	sys_statfs64
39393ed3970SCatalin MarinasENDPROC(sys_statfs64_wrapper)
394713c4815SNicolas Pitre
395713c4815SNicolas Pitresys_fstatfs64_wrapper:
396713c4815SNicolas Pitre		teq	r1, #88
397713c4815SNicolas Pitre		moveq	r1, #84
398713c4815SNicolas Pitre		b	sys_fstatfs64
39993ed3970SCatalin MarinasENDPROC(sys_fstatfs64_wrapper)
400713c4815SNicolas Pitre
4011da177e4SLinus Torvalds/*
4021da177e4SLinus Torvalds * Note: off_4k (r5) is always units of 4K.  If we can't do the requested
4031da177e4SLinus Torvalds * offset, we return EINVAL.
4041da177e4SLinus Torvalds */
4051da177e4SLinus Torvaldssys_mmap2:
4061da177e4SLinus Torvalds		str	r5, [sp, #4]
407f8b72560SAl Viro		b	sys_mmap_pgoff
40893ed3970SCatalin MarinasENDPROC(sys_mmap2)
409687ad019SNicolas Pitre
410687ad019SNicolas Pitre#ifdef CONFIG_OABI_COMPAT
411dd35afc2SNicolas Pitre
412687ad019SNicolas Pitre/*
413687ad019SNicolas Pitre * These are syscalls with argument register differences
414687ad019SNicolas Pitre */
415687ad019SNicolas Pitre
416687ad019SNicolas Pitresys_oabi_pread64:
417687ad019SNicolas Pitre		stmia	sp, {r3, r4}
418687ad019SNicolas Pitre		b	sys_pread64
41993ed3970SCatalin MarinasENDPROC(sys_oabi_pread64)
420687ad019SNicolas Pitre
421687ad019SNicolas Pitresys_oabi_pwrite64:
422687ad019SNicolas Pitre		stmia	sp, {r3, r4}
423687ad019SNicolas Pitre		b	sys_pwrite64
42493ed3970SCatalin MarinasENDPROC(sys_oabi_pwrite64)
425687ad019SNicolas Pitre
426687ad019SNicolas Pitresys_oabi_truncate64:
427687ad019SNicolas Pitre		mov	r3, r2
428687ad019SNicolas Pitre		mov	r2, r1
429687ad019SNicolas Pitre		b	sys_truncate64
43093ed3970SCatalin MarinasENDPROC(sys_oabi_truncate64)
431687ad019SNicolas Pitre
432687ad019SNicolas Pitresys_oabi_ftruncate64:
433687ad019SNicolas Pitre		mov	r3, r2
434687ad019SNicolas Pitre		mov	r2, r1
435687ad019SNicolas Pitre		b	sys_ftruncate64
43693ed3970SCatalin MarinasENDPROC(sys_oabi_ftruncate64)
437687ad019SNicolas Pitre
438687ad019SNicolas Pitresys_oabi_readahead:
439687ad019SNicolas Pitre		str	r3, [sp]
440687ad019SNicolas Pitre		mov	r3, r2
441687ad019SNicolas Pitre		mov	r2, r1
442687ad019SNicolas Pitre		b	sys_readahead
44393ed3970SCatalin MarinasENDPROC(sys_oabi_readahead)
444687ad019SNicolas Pitre
445dd35afc2SNicolas Pitre/*
446dd35afc2SNicolas Pitre * Let's declare a second syscall table for old ABI binaries
447dd35afc2SNicolas Pitre * using the compatibility syscall entries.
448dd35afc2SNicolas Pitre */
44996a8fae0SRussell King	syscall_table_start sys_oabi_call_table
4500047eb9fSMasahiro Yamada#undef __SYSCALL_WITH_COMPAT
4510047eb9fSMasahiro Yamada#define __SYSCALL_WITH_COMPAT(nr, native, compat)	__SYSCALL(nr, compat)
45296a8fae0SRussell King#include <calls-oabi.S>
45396a8fae0SRussell King	syscall_table_end sys_oabi_call_table
454dd35afc2SNicolas Pitre
455687ad019SNicolas Pitre#endif
456687ad019SNicolas Pitre
457