xref: /linux/arch/arm/kernel/entry-common.S (revision 6f5d248d05db9c4991366154f1a657a630faa583)
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
19*6f5d248dSArnd Bergmann	.macro  arch_ret_to_user, tmp
20*6f5d248dSArnd Bergmann#ifdef CONFIG_ARCH_IOP32X
21*6f5d248dSArnd Bergmann	mrc	p15, 0, \tmp, c15, c1, 0
22*6f5d248dSArnd Bergmann	tst	\tmp, #(1 << 6)
23*6f5d248dSArnd Bergmann	bicne	\tmp, \tmp, #(1 << 6)
24*6f5d248dSArnd Bergmann	mcrne	p15, 0, \tmp, c15, c1, 0	@ Disable cp6 access
2513a5045dSRob Herring#endif
26*6f5d248dSArnd Bergmann	.endm
2713a5045dSRob Herring
281da177e4SLinus Torvalds#include "entry-header.S"
291da177e4SLinus Torvalds
30309ee042SRussell Kingsaved_psr	.req	r8
31fcea4523SRussell King#if defined(CONFIG_TRACE_IRQFLAGS) || defined(CONFIG_CONTEXT_TRACKING)
32fcea4523SRussell Kingsaved_pc	.req	r9
33fcea4523SRussell King#define TRACE(x...) x
34fcea4523SRussell King#else
35309ee042SRussell Kingsaved_pc	.req	lr
36fcea4523SRussell King#define TRACE(x...)
37fcea4523SRussell King#endif
381da177e4SLinus Torvalds
39c6089061SRussell King	.section .entry.text,"ax",%progbits
401da177e4SLinus Torvalds	.align	5
41b74406f3SMathieu Desnoyers#if !(IS_ENABLED(CONFIG_TRACE_IRQFLAGS) || IS_ENABLED(CONFIG_CONTEXT_TRACKING) || \
42b74406f3SMathieu Desnoyers	IS_ENABLED(CONFIG_DEBUG_RSEQ))
431da177e4SLinus Torvalds/*
443302caddSRussell King * This is the fast syscall return path.  We do as little as possible here,
453302caddSRussell King * such as avoiding writing r0 to the stack.  We only use this path if we
46b74406f3SMathieu Desnoyers * have tracing, context tracking and rseq debug disabled - the overheads
47b74406f3SMathieu Desnoyers * from those features make this path too inefficient.
481da177e4SLinus Torvalds */
491da177e4SLinus Torvaldsret_fast_syscall:
50afc9f65eSVincent Whitchurch__ret_fast_syscall:
51c4c5716eSCatalin Marinas UNWIND(.fnstart	)
52c4c5716eSCatalin Marinas UNWIND(.cantunwind	)
533302caddSRussell King	disable_irq_notrace			@ disable interrupts
541b979372SRussell King	ldr	r1, [tsk, #TI_FLAGS]		@ re-check for syscall tracing
5532d59773SJens Axboe	movs	r1, r1, lsl #16
561da177e4SLinus Torvalds	bne	fast_work_pending
57f4dc9a4cSRussell King
58e33f8d32SThomas Garnier
59f80dff9dSDan Williams	/* perform architecture specific actions before user return */
60*6f5d248dSArnd Bergmann	arch_ret_to_user r1
61f80dff9dSDan Williams
62b86040a5SCatalin Marinas	restore_user_regs fast = 1, offset = S_OFF
63c4c5716eSCatalin Marinas UNWIND(.fnend		)
643302caddSRussell KingENDPROC(ret_fast_syscall)
651da177e4SLinus Torvalds
663302caddSRussell King	/* Ok, we need to do extra processing, enter the slow path. */
671da177e4SLinus Torvaldsfast_work_pending:
681da177e4SLinus Torvalds	str	r0, [sp, #S_R0+S_OFF]!		@ returned r0
693302caddSRussell King	/* fall through to work_pending */
703302caddSRussell King#else
713302caddSRussell King/*
72b74406f3SMathieu Desnoyers * The "replacement" ret_fast_syscall for when tracing, context tracking,
73b74406f3SMathieu Desnoyers * or rseq debug is enabled.  As we will need to call out to some C functions,
74b74406f3SMathieu Desnoyers * we save r0 first to avoid needing to save registers around each C function
75b74406f3SMathieu Desnoyers * call.
763302caddSRussell King */
773302caddSRussell Kingret_fast_syscall:
78afc9f65eSVincent Whitchurch__ret_fast_syscall:
793302caddSRussell King UNWIND(.fnstart	)
803302caddSRussell King UNWIND(.cantunwind	)
813302caddSRussell King	str	r0, [sp, #S_R0 + S_OFF]!	@ save returned r0
82b74406f3SMathieu Desnoyers#if IS_ENABLED(CONFIG_DEBUG_RSEQ)
83b74406f3SMathieu Desnoyers	/* do_rseq_syscall needs interrupts enabled. */
84b74406f3SMathieu Desnoyers	mov	r0, sp				@ 'regs'
85b74406f3SMathieu Desnoyers	bl	do_rseq_syscall
86b74406f3SMathieu Desnoyers#endif
873302caddSRussell King	disable_irq_notrace			@ disable interrupts
883302caddSRussell King	ldr	r1, [tsk, #TI_FLAGS]		@ re-check for syscall tracing
8932d59773SJens Axboe	movs	r1, r1, lsl #16
903302caddSRussell King	beq	no_work_pending
913302caddSRussell King UNWIND(.fnend		)
923302caddSRussell KingENDPROC(ret_fast_syscall)
933302caddSRussell King
943302caddSRussell King	/* Slower path - fall through to work_pending */
953302caddSRussell King#endif
963302caddSRussell King
973302caddSRussell King	tst	r1, #_TIF_SYSCALL_WORK
983302caddSRussell King	bne	__sys_trace_return_nosave
993302caddSRussell Kingslow_work_pending:
1001da177e4SLinus Torvalds	mov	r0, sp				@ 'regs'
1011da177e4SLinus Torvalds	mov	r2, why				@ 'syscall'
1020a267fa6SAl Viro	bl	do_work_pending
10366285217SAl Viro	cmp	r0, #0
10481783786SAl Viro	beq	no_work_pending
10566285217SAl Viro	movlt	scno, #(__NR_restart_syscall - __NR_SYSCALL_BASE)
10681783786SAl Viro	ldmia	sp, {r0 - r6}			@ have to reload r0 - r6
10781783786SAl Viro	b	local_restart			@ ... and off we go
108e83dd377SDrew RichardsonENDPROC(ret_fast_syscall)
10981783786SAl Viro
1101da177e4SLinus Torvalds/*
1111da177e4SLinus Torvalds * "slow" syscall return path.  "why" tells us if this was a real syscall.
1123302caddSRussell King * IRQs may be enabled here, so always disable them.  Note that we use the
1133302caddSRussell King * "notrace" version to avoid calling into the tracing code unnecessarily.
1143302caddSRussell King * do_work_pending() will update this state if necessary.
1151da177e4SLinus Torvalds */
1161da177e4SLinus TorvaldsENTRY(ret_to_user)
1171da177e4SLinus Torvaldsret_slow_syscall:
118b74406f3SMathieu Desnoyers#if IS_ENABLED(CONFIG_DEBUG_RSEQ)
119b74406f3SMathieu Desnoyers	/* do_rseq_syscall needs interrupts enabled. */
120b74406f3SMathieu Desnoyers	enable_irq_notrace			@ enable interrupts
121b74406f3SMathieu Desnoyers	mov	r0, sp				@ 'regs'
122b74406f3SMathieu Desnoyers	bl	do_rseq_syscall
123b74406f3SMathieu Desnoyers#endif
1243302caddSRussell King	disable_irq_notrace			@ disable interrupts
1259fc2552aSMing LeiENTRY(ret_to_user_from_irq)
1261da177e4SLinus Torvalds	ldr	r1, [tsk, #TI_FLAGS]
12732d59773SJens Axboe	movs	r1, r1, lsl #16
1283302caddSRussell King	bne	slow_work_pending
1291da177e4SLinus Torvaldsno_work_pending:
1303302caddSRussell King	asm_trace_hardirqs_on save = 0
131651e9499SRussell King
132f80dff9dSDan Williams	/* perform architecture specific actions before user return */
133*6f5d248dSArnd Bergmann	arch_ret_to_user r1
134b0088480SKevin Hilman	ct_user_enter save = 0
135f80dff9dSDan Williams
136b86040a5SCatalin Marinas	restore_user_regs fast = 0, offset = 0
1379fc2552aSMing LeiENDPROC(ret_to_user_from_irq)
13893ed3970SCatalin MarinasENDPROC(ret_to_user)
1391da177e4SLinus Torvalds
1401da177e4SLinus Torvalds/*
1411da177e4SLinus Torvalds * This is how we return from a fork.
1421da177e4SLinus Torvalds */
1431da177e4SLinus TorvaldsENTRY(ret_from_fork)
1441da177e4SLinus Torvalds	bl	schedule_tail
1459fff2fa0SAl Viro	cmp	r5, #0
1469fff2fa0SAl Viro	movne	r0, r4
14714327c66SRussell King	badrne	lr, 1f
1486ebbf2ceSRussell King	retne	r5
14968687c84SRussell King1:	get_thread_info tsk
1501da177e4SLinus Torvalds	b	ret_slow_syscall
15193ed3970SCatalin MarinasENDPROC(ret_from_fork)
1521da177e4SLinus Torvalds
1531da177e4SLinus Torvalds/*=============================================================================
1541da177e4SLinus Torvalds * SWI handler
1551da177e4SLinus Torvalds *-----------------------------------------------------------------------------
1561da177e4SLinus Torvalds */
1571da177e4SLinus Torvalds
1581da177e4SLinus Torvalds	.align	5
1591da177e4SLinus TorvaldsENTRY(vector_swi)
16019c4d593SUwe Kleine-König#ifdef CONFIG_CPU_V7M
16119c4d593SUwe Kleine-König	v7m_exception_entry
16219c4d593SUwe Kleine-König#else
1635745eef6SRussell King	sub	sp, sp, #PT_REGS_SIZE
164f4dc9a4cSRussell King	stmia	sp, {r0 - r12}			@ Calling r0 - r12
165b86040a5SCatalin Marinas ARM(	add	r8, sp, #S_PC		)
166b86040a5SCatalin Marinas ARM(	stmdb	r8, {sp, lr}^		)	@ Calling sp, lr
167b86040a5SCatalin Marinas THUMB(	mov	r8, sp			)
168b86040a5SCatalin Marinas THUMB(	store_user_sp_lr r8, r10, S_SP	)	@ calling sp, lr
169309ee042SRussell King	mrs	saved_psr, spsr			@ called from non-FIQ mode, so ok.
170fcea4523SRussell King TRACE(	mov	saved_pc, lr		)
171309ee042SRussell King	str	saved_pc, [sp, #S_PC]		@ Save calling PC
172309ee042SRussell King	str	saved_psr, [sp, #S_PSR]		@ Save CPSR
173f4dc9a4cSRussell King	str	r0, [sp, #S_OLD_R0]		@ Save OLD_R0
17419c4d593SUwe Kleine-König#endif
17550596b75SArd Biesheuvel	reload_current r10, ip
1761da177e4SLinus Torvalds	zero_fp
177195b58adSRussell King	alignment_trap r10, ip, __cr_alignment
178dca778c5SRussell King	asm_trace_hardirqs_on save=0
179dca778c5SRussell King	enable_irq_notrace
180dca778c5SRussell King	ct_user_exit save=0
1811aa2b3b7SWill Deacon
182e0f9f4a6SRussell King	/*
183e0f9f4a6SRussell King	 * Get the system call number.
184e0f9f4a6SRussell King	 */
1853f2829a3SNicolas Pitre
186dd35afc2SNicolas Pitre#if defined(CONFIG_OABI_COMPAT)
1873f2829a3SNicolas Pitre
188dd35afc2SNicolas Pitre	/*
189dd35afc2SNicolas Pitre	 * If we have CONFIG_OABI_COMPAT then we need to look at the swi
190dd35afc2SNicolas Pitre	 * value to determine if it is an EABI or an old ABI call.
191dd35afc2SNicolas Pitre	 */
192dd35afc2SNicolas Pitre#ifdef CONFIG_ARM_THUMB
193309ee042SRussell King	tst	saved_psr, #PSR_T_BIT
194dd35afc2SNicolas Pitre	movne	r10, #0				@ no thumb OABI emulation
195309ee042SRussell King USER(	ldreq	r10, [saved_pc, #-4]	)	@ get SWI instruction
196dd35afc2SNicolas Pitre#else
197309ee042SRussell King USER(	ldr	r10, [saved_pc, #-4]	)	@ get SWI instruction
198dd35afc2SNicolas Pitre#endif
199457c2403SBen Dooks ARM_BE8(rev	r10, r10)			@ little endian instruction
200dd35afc2SNicolas Pitre
201dd35afc2SNicolas Pitre#elif defined(CONFIG_AEABI)
202dd35afc2SNicolas Pitre
203dd35afc2SNicolas Pitre	/*
204dd35afc2SNicolas Pitre	 * Pure EABI user space always put syscall number into scno (r7).
205dd35afc2SNicolas Pitre	 */
2063f2829a3SNicolas Pitre#elif defined(CONFIG_ARM_THUMB)
207dd35afc2SNicolas Pitre	/* Legacy ABI only, possibly thumb mode. */
208309ee042SRussell King	tst	saved_psr, #PSR_T_BIT		@ this is SPSR from save_user_regs
209e0f9f4a6SRussell King	addne	scno, r7, #__NR_SYSCALL_BASE	@ put OS number in
210309ee042SRussell King USER(	ldreq	scno, [saved_pc, #-4]	)
211dd35afc2SNicolas Pitre
212e0f9f4a6SRussell King#else
213dd35afc2SNicolas Pitre	/* Legacy ABI only. */
214309ee042SRussell King USER(	ldr	scno, [saved_pc, #-4]	)	@ get SWI instruction
215e0f9f4a6SRussell King#endif
2161da177e4SLinus Torvalds
217309ee042SRussell King	/* saved_psr and saved_pc are now dead */
218309ee042SRussell King
2192190fed6SRussell King	uaccess_disable tbl
2204e57a4ddSArnd Bergmann	get_thread_info tsk
2212190fed6SRussell King
222dd35afc2SNicolas Pitre	adr	tbl, sys_call_table		@ load syscall table pointer
223dd35afc2SNicolas Pitre
224dd35afc2SNicolas Pitre#if defined(CONFIG_OABI_COMPAT)
225dd35afc2SNicolas Pitre	/*
226dd35afc2SNicolas Pitre	 * If the swi argument is zero, this is an EABI call and we do nothing.
227dd35afc2SNicolas Pitre	 *
228dd35afc2SNicolas Pitre	 * If this is an old ABI call, get the syscall number into scno and
229dd35afc2SNicolas Pitre	 * get the old ABI syscall table address.
230dd35afc2SNicolas Pitre	 */
231dd35afc2SNicolas Pitre	bics	r10, r10, #0xff000000
2324e57a4ddSArnd Bergmann	strne	r10, [tsk, #TI_ABI_SYSCALL]
2334e57a4ddSArnd Bergmann	streq	scno, [tsk, #TI_ABI_SYSCALL]
234dd35afc2SNicolas Pitre	eorne	scno, r10, #__NR_OABI_SYSCALL_BASE
235dd35afc2SNicolas Pitre	ldrne	tbl, =sys_oabi_call_table
236dd35afc2SNicolas Pitre#elif !defined(CONFIG_AEABI)
2371da177e4SLinus Torvalds	bic	scno, scno, #0xff000000		@ mask off SWI op-code
2384e57a4ddSArnd Bergmann	str	scno, [tsk, #TI_ABI_SYSCALL]
239e0f9f4a6SRussell King	eor	scno, scno, #__NR_SYSCALL_BASE	@ check OS number
2404e57a4ddSArnd Bergmann#else
2414e57a4ddSArnd Bergmann	str	scno, [tsk, #TI_ABI_SYSCALL]
2423f2829a3SNicolas Pitre#endif
243dca778c5SRussell King	/*
244dca778c5SRussell King	 * Reload the registers that may have been corrupted on entry to
245dca778c5SRussell King	 * the syscall assembly (by tracing or context tracking.)
246dca778c5SRussell King	 */
247dca778c5SRussell King TRACE(	ldmia	sp, {r0 - r3}		)
248dd35afc2SNicolas Pitre
24981783786SAl Virolocal_restart:
25070c70d97SNicolas Pitre	ldr	r10, [tsk, #TI_FLAGS]		@ check for syscall tracing
2513f2829a3SNicolas Pitre	stmdb	sp!, {r4, r5}			@ push fifth and sixth args
25270c70d97SNicolas Pitre
25329ef73b7SNathaniel Husted	tst	r10, #_TIF_SYSCALL_WORK		@ are we tracing syscalls?
2541da177e4SLinus Torvalds	bne	__sys_trace
2551da177e4SLinus Torvalds
256afc9f65eSVincent Whitchurch	invoke_syscall tbl, scno, r10, __ret_fast_syscall
2571da177e4SLinus Torvalds
2581da177e4SLinus Torvalds	add	r1, sp, #S_OFF
259d95bc250SWill Deacon2:	cmp	scno, #(__ARM_NR_BASE - __NR_SYSCALL_BASE)
260e0f9f4a6SRussell King	eor	r0, scno, #__NR_SYSCALL_BASE	@ put OS number back
2611da177e4SLinus Torvalds	bcs	arm_syscall
262d95bc250SWill Deacon	mov	why, #0				@ no longer a real syscall
2631da177e4SLinus Torvalds	b	sys_ni_syscall			@ not private func
2641aa2b3b7SWill Deacon
2651aa2b3b7SWill Deacon#if defined(CONFIG_OABI_COMPAT) || !defined(CONFIG_AEABI)
2661aa2b3b7SWill Deacon	/*
2671aa2b3b7SWill Deacon	 * We failed to handle a fault trying to access the page
2681aa2b3b7SWill Deacon	 * containing the swi instruction, but we're not really in a
2691aa2b3b7SWill Deacon	 * position to return -EFAULT. Instead, return back to the
2701aa2b3b7SWill Deacon	 * instruction and re-enter the user fault handling path trying
2711aa2b3b7SWill Deacon	 * to page it in. This will likely result in sending SEGV to the
2721aa2b3b7SWill Deacon	 * current task.
2731aa2b3b7SWill Deacon	 */
2741aa2b3b7SWill Deacon9001:
275309ee042SRussell King	sub	lr, saved_pc, #4
2761aa2b3b7SWill Deacon	str	lr, [sp, #S_PC]
277da594e3fSRussell King	get_thread_info tsk
2781aa2b3b7SWill Deacon	b	ret_fast_syscall
2791aa2b3b7SWill Deacon#endif
28093ed3970SCatalin MarinasENDPROC(vector_swi)
2811da177e4SLinus Torvalds
2821da177e4SLinus Torvalds	/*
2831da177e4SLinus Torvalds	 * This is the really slow path.  We're going to be doing
2841da177e4SLinus Torvalds	 * context switches, and waiting for our parent to respond.
2851da177e4SLinus Torvalds	 */
2861da177e4SLinus Torvalds__sys_trace:
287ad722541SWill Deacon	add	r0, sp, #S_OFF
288ad722541SWill Deacon	bl	syscall_trace_enter
28910573ae5SRussell King	mov	scno, r0
29010573ae5SRussell King	invoke_syscall tbl, scno, r10, __sys_trace_return, reload=1
291ad75b514SKees Cook	cmp	scno, #-1			@ skip the syscall?
292ad75b514SKees Cook	bne	2b
293ad75b514SKees Cook	add	sp, sp, #S_OFF			@ restore stack
2941da177e4SLinus Torvalds
295f18aef74STimothy E Baldwin__sys_trace_return_nosave:
296f18aef74STimothy E Baldwin	enable_irq_notrace
297ad722541SWill Deacon	mov	r0, sp
298ad722541SWill Deacon	bl	syscall_trace_exit
2991da177e4SLinus Torvalds	b	ret_slow_syscall
3001da177e4SLinus Torvalds
301f18aef74STimothy E Baldwin__sys_trace_return:
302f18aef74STimothy E Baldwin	str	r0, [sp, #S_R0 + S_OFF]!	@ save returned r0
3033302caddSRussell King	mov	r0, sp
3043302caddSRussell King	bl	syscall_trace_exit
3053302caddSRussell King	b	ret_slow_syscall
3063302caddSRussell King
3071da177e4SLinus Torvalds	.align	5
3081da177e4SLinus Torvalds#ifdef CONFIG_ALIGNMENT_TRAP
3091da177e4SLinus Torvalds	.type	__cr_alignment, #object
3101da177e4SLinus Torvalds__cr_alignment:
3111da177e4SLinus Torvalds	.word	cr_alignment
3121da177e4SLinus Torvalds#endif
313dd35afc2SNicolas Pitre	.ltorg
314dd35afc2SNicolas Pitre
31596a8fae0SRussell King	.macro	syscall_table_start, sym
31696a8fae0SRussell King	.equ	__sys_nr, 0
31796a8fae0SRussell King	.type	\sym, #object
31896a8fae0SRussell KingENTRY(\sym)
31996a8fae0SRussell King	.endm
32096a8fae0SRussell King
32196a8fae0SRussell King	.macro	syscall, nr, func
32296a8fae0SRussell King	.ifgt	__sys_nr - \nr
32396a8fae0SRussell King	.error	"Duplicated/unorded system call entry"
32496a8fae0SRussell King	.endif
32596a8fae0SRussell King	.rept	\nr - __sys_nr
32696a8fae0SRussell King	.long	sys_ni_syscall
32796a8fae0SRussell King	.endr
32896a8fae0SRussell King	.long	\func
32996a8fae0SRussell King	.equ	__sys_nr, \nr + 1
33096a8fae0SRussell King	.endm
33196a8fae0SRussell King
33296a8fae0SRussell King	.macro	syscall_table_end, sym
33396a8fae0SRussell King	.ifgt	__sys_nr - __NR_syscalls
33496a8fae0SRussell King	.error	"System call table too big"
33596a8fae0SRussell King	.endif
33696a8fae0SRussell King	.rept	__NR_syscalls - __sys_nr
33796a8fae0SRussell King	.long	sys_ni_syscall
33896a8fae0SRussell King	.endr
33996a8fae0SRussell King	.size	\sym, . - \sym
34096a8fae0SRussell King	.endm
34196a8fae0SRussell King
3420047eb9fSMasahiro Yamada#define __SYSCALL_WITH_COMPAT(nr, native, compat)	__SYSCALL(nr, native)
3430047eb9fSMasahiro Yamada#define __SYSCALL(nr, func) syscall nr, func
34496a8fae0SRussell King
345dd35afc2SNicolas Pitre/*
346dd35afc2SNicolas Pitre * This is the syscall table declaration for native ABI syscalls.
347dd35afc2SNicolas Pitre * With EABI a couple syscalls are obsolete and defined as sys_ni_syscall.
348dd35afc2SNicolas Pitre */
34996a8fae0SRussell King	syscall_table_start sys_call_table
350dd35afc2SNicolas Pitre#ifdef CONFIG_AEABI
35196a8fae0SRussell King#include <calls-eabi.S>
352dd35afc2SNicolas Pitre#else
35396a8fae0SRussell King#include <calls-oabi.S>
354dd35afc2SNicolas Pitre#endif
35596a8fae0SRussell King	syscall_table_end sys_call_table
3561da177e4SLinus Torvalds
3571da177e4SLinus Torvalds/*============================================================================
3581da177e4SLinus Torvalds * Special system call wrappers
3591da177e4SLinus Torvalds */
3601da177e4SLinus Torvalds@ r0 = syscall number
361567bd980SRussell King@ r8 = syscall table
3621da177e4SLinus Torvaldssys_syscall:
3635247593cSPaul Brook		bic	scno, r0, #__NR_OABI_SYSCALL_BASE
3641da177e4SLinus Torvalds		cmp	scno, #__NR_syscall - __NR_SYSCALL_BASE
3651da177e4SLinus Torvalds		cmpne	scno, #NR_syscalls	@ check range
36610573ae5SRussell King#ifdef CONFIG_CPU_SPECTRE
36710573ae5SRussell King		movhs	scno, #0
36810573ae5SRussell King		csdb
36910573ae5SRussell King#endif
370e44fc388SStefan Agner		stmialo	sp, {r5, r6}		@ shuffle args
3711da177e4SLinus Torvalds		movlo	r0, r1
3721da177e4SLinus Torvalds		movlo	r1, r2
3731da177e4SLinus Torvalds		movlo	r2, r3
3741da177e4SLinus Torvalds		movlo	r3, r4
3751da177e4SLinus Torvalds		ldrlo	pc, [tbl, scno, lsl #2]
3761da177e4SLinus Torvalds		b	sys_ni_syscall
37793ed3970SCatalin MarinasENDPROC(sys_syscall)
3781da177e4SLinus Torvalds
3791da177e4SLinus Torvaldssys_sigreturn_wrapper:
3801da177e4SLinus Torvalds		add	r0, sp, #S_OFF
381653d48b2SAl Viro		mov	why, #0		@ prevent syscall restart handling
3821da177e4SLinus Torvalds		b	sys_sigreturn
38393ed3970SCatalin MarinasENDPROC(sys_sigreturn_wrapper)
3841da177e4SLinus Torvalds
3851da177e4SLinus Torvaldssys_rt_sigreturn_wrapper:
3861da177e4SLinus Torvalds		add	r0, sp, #S_OFF
387653d48b2SAl Viro		mov	why, #0		@ prevent syscall restart handling
3881da177e4SLinus Torvalds		b	sys_rt_sigreturn
38993ed3970SCatalin MarinasENDPROC(sys_rt_sigreturn_wrapper)
3901da177e4SLinus Torvalds
391713c4815SNicolas Pitresys_statfs64_wrapper:
392713c4815SNicolas Pitre		teq	r1, #88
393713c4815SNicolas Pitre		moveq	r1, #84
394713c4815SNicolas Pitre		b	sys_statfs64
39593ed3970SCatalin MarinasENDPROC(sys_statfs64_wrapper)
396713c4815SNicolas Pitre
397713c4815SNicolas Pitresys_fstatfs64_wrapper:
398713c4815SNicolas Pitre		teq	r1, #88
399713c4815SNicolas Pitre		moveq	r1, #84
400713c4815SNicolas Pitre		b	sys_fstatfs64
40193ed3970SCatalin MarinasENDPROC(sys_fstatfs64_wrapper)
402713c4815SNicolas Pitre
4031da177e4SLinus Torvalds/*
4041da177e4SLinus Torvalds * Note: off_4k (r5) is always units of 4K.  If we can't do the requested
4051da177e4SLinus Torvalds * offset, we return EINVAL.
4061da177e4SLinus Torvalds */
4071da177e4SLinus Torvaldssys_mmap2:
4081da177e4SLinus Torvalds		str	r5, [sp, #4]
409f8b72560SAl Viro		b	sys_mmap_pgoff
41093ed3970SCatalin MarinasENDPROC(sys_mmap2)
411687ad019SNicolas Pitre
412687ad019SNicolas Pitre#ifdef CONFIG_OABI_COMPAT
413dd35afc2SNicolas Pitre
414687ad019SNicolas Pitre/*
415687ad019SNicolas Pitre * These are syscalls with argument register differences
416687ad019SNicolas Pitre */
417687ad019SNicolas Pitre
418687ad019SNicolas Pitresys_oabi_pread64:
419687ad019SNicolas Pitre		stmia	sp, {r3, r4}
420687ad019SNicolas Pitre		b	sys_pread64
42193ed3970SCatalin MarinasENDPROC(sys_oabi_pread64)
422687ad019SNicolas Pitre
423687ad019SNicolas Pitresys_oabi_pwrite64:
424687ad019SNicolas Pitre		stmia	sp, {r3, r4}
425687ad019SNicolas Pitre		b	sys_pwrite64
42693ed3970SCatalin MarinasENDPROC(sys_oabi_pwrite64)
427687ad019SNicolas Pitre
428687ad019SNicolas Pitresys_oabi_truncate64:
429687ad019SNicolas Pitre		mov	r3, r2
430687ad019SNicolas Pitre		mov	r2, r1
431687ad019SNicolas Pitre		b	sys_truncate64
43293ed3970SCatalin MarinasENDPROC(sys_oabi_truncate64)
433687ad019SNicolas Pitre
434687ad019SNicolas Pitresys_oabi_ftruncate64:
435687ad019SNicolas Pitre		mov	r3, r2
436687ad019SNicolas Pitre		mov	r2, r1
437687ad019SNicolas Pitre		b	sys_ftruncate64
43893ed3970SCatalin MarinasENDPROC(sys_oabi_ftruncate64)
439687ad019SNicolas Pitre
440687ad019SNicolas Pitresys_oabi_readahead:
441687ad019SNicolas Pitre		str	r3, [sp]
442687ad019SNicolas Pitre		mov	r3, r2
443687ad019SNicolas Pitre		mov	r2, r1
444687ad019SNicolas Pitre		b	sys_readahead
44593ed3970SCatalin MarinasENDPROC(sys_oabi_readahead)
446687ad019SNicolas Pitre
447dd35afc2SNicolas Pitre/*
448dd35afc2SNicolas Pitre * Let's declare a second syscall table for old ABI binaries
449dd35afc2SNicolas Pitre * using the compatibility syscall entries.
450dd35afc2SNicolas Pitre */
45196a8fae0SRussell King	syscall_table_start sys_oabi_call_table
4520047eb9fSMasahiro Yamada#undef __SYSCALL_WITH_COMPAT
4530047eb9fSMasahiro Yamada#define __SYSCALL_WITH_COMPAT(nr, native, compat)	__SYSCALL(nr, compat)
45496a8fae0SRussell King#include <calls-oabi.S>
45596a8fae0SRussell King	syscall_table_end sys_oabi_call_table
456dd35afc2SNicolas Pitre
457687ad019SNicolas Pitre#endif
458687ad019SNicolas Pitre
459