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> 12a9ff6961SLinus Walleij#include <asm/page.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 191da177e4SLinus Torvalds#include "entry-header.S" 201da177e4SLinus Torvalds 21309ee042SRussell Kingsaved_psr .req r8 2224a9c541SFrederic Weisbecker#if defined(CONFIG_TRACE_IRQFLAGS) || defined(CONFIG_CONTEXT_TRACKING_USER) 23fcea4523SRussell Kingsaved_pc .req r9 24fcea4523SRussell King#define TRACE(x...) x 25fcea4523SRussell King#else 26309ee042SRussell Kingsaved_pc .req lr 27fcea4523SRussell King#define TRACE(x...) 28fcea4523SRussell King#endif 291da177e4SLinus Torvalds 30c6089061SRussell King .section .entry.text,"ax",%progbits 311da177e4SLinus Torvalds .align 5 3224a9c541SFrederic Weisbecker#if !(IS_ENABLED(CONFIG_TRACE_IRQFLAGS) || IS_ENABLED(CONFIG_CONTEXT_TRACKING_USER) || \ 33b74406f3SMathieu Desnoyers IS_ENABLED(CONFIG_DEBUG_RSEQ)) 341da177e4SLinus Torvalds/* 353302caddSRussell King * This is the fast syscall return path. We do as little as possible here, 363302caddSRussell King * such as avoiding writing r0 to the stack. We only use this path if we 37b74406f3SMathieu Desnoyers * have tracing, context tracking and rseq debug disabled - the overheads 38b74406f3SMathieu Desnoyers * from those features make this path too inefficient. 391da177e4SLinus Torvalds */ 401da177e4SLinus Torvaldsret_fast_syscall: 41afc9f65eSVincent Whitchurch__ret_fast_syscall: 42c4c5716eSCatalin Marinas UNWIND(.fnstart ) 43c4c5716eSCatalin Marinas UNWIND(.cantunwind ) 443302caddSRussell King disable_irq_notrace @ disable interrupts 451b979372SRussell King ldr r1, [tsk, #TI_FLAGS] @ re-check for syscall tracing 4632d59773SJens Axboe movs r1, r1, lsl #16 471da177e4SLinus Torvalds bne fast_work_pending 48f4dc9a4cSRussell King 49b86040a5SCatalin Marinas restore_user_regs fast = 1, offset = S_OFF 50c4c5716eSCatalin Marinas UNWIND(.fnend ) 513302caddSRussell KingENDPROC(ret_fast_syscall) 521da177e4SLinus Torvalds 533302caddSRussell King /* Ok, we need to do extra processing, enter the slow path. */ 541da177e4SLinus Torvaldsfast_work_pending: 551da177e4SLinus Torvalds str r0, [sp, #S_R0+S_OFF]! @ returned r0 563302caddSRussell King /* fall through to work_pending */ 573302caddSRussell King#else 583302caddSRussell King/* 59b74406f3SMathieu Desnoyers * The "replacement" ret_fast_syscall for when tracing, context tracking, 60b74406f3SMathieu Desnoyers * or rseq debug is enabled. As we will need to call out to some C functions, 61b74406f3SMathieu Desnoyers * we save r0 first to avoid needing to save registers around each C function 62b74406f3SMathieu Desnoyers * call. 633302caddSRussell King */ 643302caddSRussell Kingret_fast_syscall: 65afc9f65eSVincent Whitchurch__ret_fast_syscall: 663302caddSRussell King UNWIND(.fnstart ) 673302caddSRussell King UNWIND(.cantunwind ) 683302caddSRussell King str r0, [sp, #S_R0 + S_OFF]! @ save returned r0 69b74406f3SMathieu Desnoyers#if IS_ENABLED(CONFIG_DEBUG_RSEQ) 70b74406f3SMathieu Desnoyers /* do_rseq_syscall needs interrupts enabled. */ 71b74406f3SMathieu Desnoyers mov r0, sp @ 'regs' 72b74406f3SMathieu Desnoyers bl do_rseq_syscall 73b74406f3SMathieu Desnoyers#endif 743302caddSRussell King disable_irq_notrace @ disable interrupts 753302caddSRussell King ldr r1, [tsk, #TI_FLAGS] @ re-check for syscall tracing 7632d59773SJens Axboe movs r1, r1, lsl #16 773302caddSRussell King beq no_work_pending 783302caddSRussell King UNWIND(.fnend ) 793302caddSRussell KingENDPROC(ret_fast_syscall) 803302caddSRussell King 813302caddSRussell King /* Slower path - fall through to work_pending */ 823302caddSRussell King#endif 833302caddSRussell King 843302caddSRussell King tst r1, #_TIF_SYSCALL_WORK 853302caddSRussell King bne __sys_trace_return_nosave 863302caddSRussell Kingslow_work_pending: 871da177e4SLinus Torvalds mov r0, sp @ 'regs' 881da177e4SLinus Torvalds mov r2, why @ 'syscall' 890a267fa6SAl Viro bl do_work_pending 9066285217SAl Viro cmp r0, #0 9181783786SAl Viro beq no_work_pending 9266285217SAl Viro movlt scno, #(__NR_restart_syscall - __NR_SYSCALL_BASE) 93cf007647SKees Cook str scno, [tsk, #TI_ABI_SYSCALL] @ make sure tracers see update 9481783786SAl Viro ldmia sp, {r0 - r6} @ have to reload r0 - r6 9581783786SAl Viro b local_restart @ ... and off we go 96e83dd377SDrew RichardsonENDPROC(ret_fast_syscall) 9781783786SAl Viro 981da177e4SLinus Torvalds/* 991da177e4SLinus Torvalds * "slow" syscall return path. "why" tells us if this was a real syscall. 1003302caddSRussell King * IRQs may be enabled here, so always disable them. Note that we use the 1013302caddSRussell King * "notrace" version to avoid calling into the tracing code unnecessarily. 1023302caddSRussell King * do_work_pending() will update this state if necessary. 1031da177e4SLinus Torvalds */ 1041da177e4SLinus TorvaldsENTRY(ret_to_user) 1051da177e4SLinus Torvaldsret_slow_syscall: 106b74406f3SMathieu Desnoyers#if IS_ENABLED(CONFIG_DEBUG_RSEQ) 107b74406f3SMathieu Desnoyers /* do_rseq_syscall needs interrupts enabled. */ 108b74406f3SMathieu Desnoyers enable_irq_notrace @ enable interrupts 109b74406f3SMathieu Desnoyers mov r0, sp @ 'regs' 110b74406f3SMathieu Desnoyers bl do_rseq_syscall 111b74406f3SMathieu Desnoyers#endif 1123302caddSRussell King disable_irq_notrace @ disable interrupts 1139fc2552aSMing LeiENTRY(ret_to_user_from_irq) 1141da177e4SLinus Torvalds ldr r1, [tsk, #TI_FLAGS] 11532d59773SJens Axboe movs r1, r1, lsl #16 1163302caddSRussell King bne slow_work_pending 1171da177e4SLinus Torvaldsno_work_pending: 1183302caddSRussell King asm_trace_hardirqs_on save = 0 119651e9499SRussell King 120b0088480SKevin Hilman ct_user_enter save = 0 121f80dff9dSDan Williams 122*2335c9cbSJinjie Ruan#ifdef CONFIG_GCC_PLUGIN_STACKLEAK 123*2335c9cbSJinjie Ruan bl stackleak_erase_on_task_stack 124*2335c9cbSJinjie Ruan#endif 125b86040a5SCatalin Marinas restore_user_regs fast = 0, offset = 0 1269fc2552aSMing LeiENDPROC(ret_to_user_from_irq) 12793ed3970SCatalin MarinasENDPROC(ret_to_user) 1281da177e4SLinus Torvalds 1291da177e4SLinus Torvalds/* 1301da177e4SLinus Torvalds * This is how we return from a fork. 1311da177e4SLinus Torvalds */ 1321da177e4SLinus TorvaldsENTRY(ret_from_fork) 1331da177e4SLinus Torvalds bl schedule_tail 1349fff2fa0SAl Viro cmp r5, #0 1359fff2fa0SAl Viro movne r0, r4 13614327c66SRussell King badrne lr, 1f 1376ebbf2ceSRussell King retne r5 13868687c84SRussell King1: get_thread_info tsk 1391da177e4SLinus Torvalds b ret_slow_syscall 14093ed3970SCatalin MarinasENDPROC(ret_from_fork) 1411da177e4SLinus Torvalds 1421da177e4SLinus Torvalds/*============================================================================= 1431da177e4SLinus Torvalds * SWI handler 1441da177e4SLinus Torvalds *----------------------------------------------------------------------------- 1451da177e4SLinus Torvalds */ 1461da177e4SLinus Torvalds 1471da177e4SLinus Torvalds .align 5 148b9baf5c8SRussell King (Oracle)#ifdef CONFIG_HARDEN_BRANCH_HISTORY 149b9baf5c8SRussell King (Oracle)ENTRY(vector_bhb_loop8_swi) 150b9baf5c8SRussell King (Oracle) sub sp, sp, #PT_REGS_SIZE 151b9baf5c8SRussell King (Oracle) stmia sp, {r0 - r12} 152b9baf5c8SRussell King (Oracle) mov r8, #8 153b9baf5c8SRussell King (Oracle)1: b 2f 154b9baf5c8SRussell King (Oracle)2: subs r8, r8, #1 155b9baf5c8SRussell King (Oracle) bne 1b 156892c608aSArd Biesheuvel dsb nsh 157b9baf5c8SRussell King (Oracle) isb 158b9baf5c8SRussell King (Oracle) b 3f 159b9baf5c8SRussell King (Oracle)ENDPROC(vector_bhb_loop8_swi) 160b9baf5c8SRussell King (Oracle) 161b9baf5c8SRussell King (Oracle) .align 5 162b9baf5c8SRussell King (Oracle)ENTRY(vector_bhb_bpiall_swi) 163b9baf5c8SRussell King (Oracle) sub sp, sp, #PT_REGS_SIZE 164b9baf5c8SRussell King (Oracle) stmia sp, {r0 - r12} 165b9baf5c8SRussell King (Oracle) mcr p15, 0, r8, c7, c5, 6 @ BPIALL 166b9baf5c8SRussell King (Oracle) isb 167b9baf5c8SRussell King (Oracle) b 3f 168b9baf5c8SRussell King (Oracle)ENDPROC(vector_bhb_bpiall_swi) 169b9baf5c8SRussell King (Oracle)#endif 170b9baf5c8SRussell King (Oracle) .align 5 1711da177e4SLinus TorvaldsENTRY(vector_swi) 17219c4d593SUwe Kleine-König#ifdef CONFIG_CPU_V7M 17319c4d593SUwe Kleine-König v7m_exception_entry 17419c4d593SUwe Kleine-König#else 1755745eef6SRussell King sub sp, sp, #PT_REGS_SIZE 176f4dc9a4cSRussell King stmia sp, {r0 - r12} @ Calling r0 - r12 177b9baf5c8SRussell King (Oracle)3: 178b86040a5SCatalin Marinas ARM( add r8, sp, #S_PC ) 179b86040a5SCatalin Marinas ARM( stmdb r8, {sp, lr}^ ) @ Calling sp, lr 180b86040a5SCatalin Marinas THUMB( mov r8, sp ) 181b86040a5SCatalin Marinas THUMB( store_user_sp_lr r8, r10, S_SP ) @ calling sp, lr 182309ee042SRussell King mrs saved_psr, spsr @ called from non-FIQ mode, so ok. 183fcea4523SRussell King TRACE( mov saved_pc, lr ) 184309ee042SRussell King str saved_pc, [sp, #S_PC] @ Save calling PC 185309ee042SRussell King str saved_psr, [sp, #S_PSR] @ Save CPSR 186f4dc9a4cSRussell King str r0, [sp, #S_OLD_R0] @ Save OLD_R0 18719c4d593SUwe Kleine-König#endif 18850596b75SArd Biesheuvel reload_current r10, ip 1891da177e4SLinus Torvalds zero_fp 19050807460SArd Biesheuvel alignment_trap r10, ip, cr_alignment 191dca778c5SRussell King asm_trace_hardirqs_on save=0 192dca778c5SRussell King enable_irq_notrace 193dca778c5SRussell King ct_user_exit save=0 1941aa2b3b7SWill Deacon 195e0f9f4a6SRussell King /* 196e0f9f4a6SRussell King * Get the system call number. 197e0f9f4a6SRussell King */ 1983f2829a3SNicolas Pitre 199dd35afc2SNicolas Pitre#if defined(CONFIG_OABI_COMPAT) 2003f2829a3SNicolas Pitre 201dd35afc2SNicolas Pitre /* 202dd35afc2SNicolas Pitre * If we have CONFIG_OABI_COMPAT then we need to look at the swi 203dd35afc2SNicolas Pitre * value to determine if it is an EABI or an old ABI call. 204dd35afc2SNicolas Pitre */ 205dd35afc2SNicolas Pitre#ifdef CONFIG_ARM_THUMB 206309ee042SRussell King tst saved_psr, #PSR_T_BIT 207dd35afc2SNicolas Pitre movne r10, #0 @ no thumb OABI emulation 208309ee042SRussell King USER( ldreq r10, [saved_pc, #-4] ) @ get SWI instruction 209dd35afc2SNicolas Pitre#else 210309ee042SRussell King USER( ldr r10, [saved_pc, #-4] ) @ get SWI instruction 211dd35afc2SNicolas Pitre#endif 212457c2403SBen Dooks ARM_BE8(rev r10, r10) @ little endian instruction 213dd35afc2SNicolas Pitre 214dd35afc2SNicolas Pitre#elif defined(CONFIG_AEABI) 215dd35afc2SNicolas Pitre 216dd35afc2SNicolas Pitre /* 217dd35afc2SNicolas Pitre * Pure EABI user space always put syscall number into scno (r7). 218dd35afc2SNicolas Pitre */ 2193f2829a3SNicolas Pitre#elif defined(CONFIG_ARM_THUMB) 220dd35afc2SNicolas Pitre /* Legacy ABI only, possibly thumb mode. */ 221309ee042SRussell King tst saved_psr, #PSR_T_BIT @ this is SPSR from save_user_regs 222e0f9f4a6SRussell King addne scno, r7, #__NR_SYSCALL_BASE @ put OS number in 223309ee042SRussell King USER( ldreq scno, [saved_pc, #-4] ) 224dd35afc2SNicolas Pitre 225e0f9f4a6SRussell King#else 226dd35afc2SNicolas Pitre /* Legacy ABI only. */ 227309ee042SRussell King USER( ldr scno, [saved_pc, #-4] ) @ get SWI instruction 228e0f9f4a6SRussell King#endif 2291da177e4SLinus Torvalds 230309ee042SRussell King /* saved_psr and saved_pc are now dead */ 231309ee042SRussell King 2322190fed6SRussell King uaccess_disable tbl 2334e57a4ddSArnd Bergmann get_thread_info tsk 2342190fed6SRussell King 235dd35afc2SNicolas Pitre adr tbl, sys_call_table @ load syscall table pointer 236dd35afc2SNicolas Pitre 237dd35afc2SNicolas Pitre#if defined(CONFIG_OABI_COMPAT) 238dd35afc2SNicolas Pitre /* 239dd35afc2SNicolas Pitre * If the swi argument is zero, this is an EABI call and we do nothing. 240dd35afc2SNicolas Pitre * 241dd35afc2SNicolas Pitre * If this is an old ABI call, get the syscall number into scno and 242dd35afc2SNicolas Pitre * get the old ABI syscall table address. 243dd35afc2SNicolas Pitre */ 244dd35afc2SNicolas Pitre bics r10, r10, #0xff000000 2454e57a4ddSArnd Bergmann strne r10, [tsk, #TI_ABI_SYSCALL] 2464e57a4ddSArnd Bergmann streq scno, [tsk, #TI_ABI_SYSCALL] 247dd35afc2SNicolas Pitre eorne scno, r10, #__NR_OABI_SYSCALL_BASE 248dd35afc2SNicolas Pitre ldrne tbl, =sys_oabi_call_table 249dd35afc2SNicolas Pitre#elif !defined(CONFIG_AEABI) 2501da177e4SLinus Torvalds bic scno, scno, #0xff000000 @ mask off SWI op-code 2514e57a4ddSArnd Bergmann str scno, [tsk, #TI_ABI_SYSCALL] 252e0f9f4a6SRussell King eor scno, scno, #__NR_SYSCALL_BASE @ check OS number 2534e57a4ddSArnd Bergmann#else 2544e57a4ddSArnd Bergmann str scno, [tsk, #TI_ABI_SYSCALL] 2553f2829a3SNicolas Pitre#endif 256dca778c5SRussell King /* 257dca778c5SRussell King * Reload the registers that may have been corrupted on entry to 258dca778c5SRussell King * the syscall assembly (by tracing or context tracking.) 259dca778c5SRussell King */ 260dca778c5SRussell King TRACE( ldmia sp, {r0 - r3} ) 261dd35afc2SNicolas Pitre 26281783786SAl Virolocal_restart: 26370c70d97SNicolas Pitre ldr r10, [tsk, #TI_FLAGS] @ check for syscall tracing 2643f2829a3SNicolas Pitre stmdb sp!, {r4, r5} @ push fifth and sixth args 26570c70d97SNicolas Pitre 26629ef73b7SNathaniel Husted tst r10, #_TIF_SYSCALL_WORK @ are we tracing syscalls? 2671da177e4SLinus Torvalds bne __sys_trace 2681da177e4SLinus Torvalds 269afc9f65eSVincent Whitchurch invoke_syscall tbl, scno, r10, __ret_fast_syscall 2701da177e4SLinus Torvalds 2711da177e4SLinus Torvalds add r1, sp, #S_OFF 272d95bc250SWill Deacon2: cmp scno, #(__ARM_NR_BASE - __NR_SYSCALL_BASE) 273e0f9f4a6SRussell King eor r0, scno, #__NR_SYSCALL_BASE @ put OS number back 2741da177e4SLinus Torvalds bcs arm_syscall 275d95bc250SWill Deacon mov why, #0 @ no longer a real syscall 2761da177e4SLinus Torvalds b sys_ni_syscall @ not private func 2771aa2b3b7SWill Deacon 2781aa2b3b7SWill Deacon#if defined(CONFIG_OABI_COMPAT) || !defined(CONFIG_AEABI) 2791aa2b3b7SWill Deacon /* 2801aa2b3b7SWill Deacon * We failed to handle a fault trying to access the page 2811aa2b3b7SWill Deacon * containing the swi instruction, but we're not really in a 2821aa2b3b7SWill Deacon * position to return -EFAULT. Instead, return back to the 2831aa2b3b7SWill Deacon * instruction and re-enter the user fault handling path trying 2841aa2b3b7SWill Deacon * to page it in. This will likely result in sending SEGV to the 2851aa2b3b7SWill Deacon * current task. 2861aa2b3b7SWill Deacon */ 2871aa2b3b7SWill Deacon9001: 288309ee042SRussell King sub lr, saved_pc, #4 2891aa2b3b7SWill Deacon str lr, [sp, #S_PC] 290da594e3fSRussell King get_thread_info tsk 2911aa2b3b7SWill Deacon b ret_fast_syscall 2921aa2b3b7SWill Deacon#endif 29393ed3970SCatalin MarinasENDPROC(vector_swi) 29429589ca0SArd Biesheuvel .ltorg 2951da177e4SLinus Torvalds 2961da177e4SLinus Torvalds /* 2971da177e4SLinus Torvalds * This is the really slow path. We're going to be doing 2981da177e4SLinus Torvalds * context switches, and waiting for our parent to respond. 2991da177e4SLinus Torvalds */ 3001da177e4SLinus Torvalds__sys_trace: 301ad722541SWill Deacon add r0, sp, #S_OFF 302ad722541SWill Deacon bl syscall_trace_enter 30310573ae5SRussell King mov scno, r0 30410573ae5SRussell King invoke_syscall tbl, scno, r10, __sys_trace_return, reload=1 305ad75b514SKees Cook cmp scno, #-1 @ skip the syscall? 306ad75b514SKees Cook bne 2b 307ad75b514SKees Cook add sp, sp, #S_OFF @ restore stack 3081da177e4SLinus Torvalds 309f18aef74STimothy E Baldwin__sys_trace_return_nosave: 310f18aef74STimothy E Baldwin enable_irq_notrace 311ad722541SWill Deacon mov r0, sp 312ad722541SWill Deacon bl syscall_trace_exit 3131da177e4SLinus Torvalds b ret_slow_syscall 3141da177e4SLinus Torvalds 315f18aef74STimothy E Baldwin__sys_trace_return: 316f18aef74STimothy E Baldwin str r0, [sp, #S_R0 + S_OFF]! @ save returned r0 3173302caddSRussell King mov r0, sp 3183302caddSRussell King bl syscall_trace_exit 3193302caddSRussell King b ret_slow_syscall 3203302caddSRussell King 32196a8fae0SRussell King .macro syscall_table_start, sym 32296a8fae0SRussell King .equ __sys_nr, 0 32396a8fae0SRussell King .type \sym, #object 32496a8fae0SRussell KingENTRY(\sym) 32596a8fae0SRussell King .endm 32696a8fae0SRussell King 32796a8fae0SRussell King .macro syscall, nr, func 32896a8fae0SRussell King .ifgt __sys_nr - \nr 32996a8fae0SRussell King .error "Duplicated/unorded system call entry" 33096a8fae0SRussell King .endif 33196a8fae0SRussell King .rept \nr - __sys_nr 33296a8fae0SRussell King .long sys_ni_syscall 33396a8fae0SRussell King .endr 33496a8fae0SRussell King .long \func 33596a8fae0SRussell King .equ __sys_nr, \nr + 1 33696a8fae0SRussell King .endm 33796a8fae0SRussell King 33896a8fae0SRussell King .macro syscall_table_end, sym 33996a8fae0SRussell King .ifgt __sys_nr - __NR_syscalls 34096a8fae0SRussell King .error "System call table too big" 34196a8fae0SRussell King .endif 34296a8fae0SRussell King .rept __NR_syscalls - __sys_nr 34396a8fae0SRussell King .long sys_ni_syscall 34496a8fae0SRussell King .endr 34596a8fae0SRussell King .size \sym, . - \sym 34696a8fae0SRussell King .endm 34796a8fae0SRussell King 3480047eb9fSMasahiro Yamada#define __SYSCALL_WITH_COMPAT(nr, native, compat) __SYSCALL(nr, native) 3490047eb9fSMasahiro Yamada#define __SYSCALL(nr, func) syscall nr, func 35096a8fae0SRussell King 351dd35afc2SNicolas Pitre/* 352dd35afc2SNicolas Pitre * This is the syscall table declaration for native ABI syscalls. 353dd35afc2SNicolas Pitre * With EABI a couple syscalls are obsolete and defined as sys_ni_syscall. 354dd35afc2SNicolas Pitre */ 35596a8fae0SRussell King syscall_table_start sys_call_table 356dd35afc2SNicolas Pitre#ifdef CONFIG_AEABI 35796a8fae0SRussell King#include <calls-eabi.S> 358dd35afc2SNicolas Pitre#else 35996a8fae0SRussell King#include <calls-oabi.S> 360dd35afc2SNicolas Pitre#endif 36196a8fae0SRussell King syscall_table_end sys_call_table 3621da177e4SLinus Torvalds 3631da177e4SLinus Torvalds/*============================================================================ 3641da177e4SLinus Torvalds * Special system call wrappers 3651da177e4SLinus Torvalds */ 3661da177e4SLinus Torvalds@ r0 = syscall number 367567bd980SRussell King@ r8 = syscall table 3681da177e4SLinus Torvaldssys_syscall: 3695247593cSPaul Brook bic scno, r0, #__NR_OABI_SYSCALL_BASE 3701da177e4SLinus Torvalds cmp scno, #__NR_syscall - __NR_SYSCALL_BASE 3711da177e4SLinus Torvalds cmpne scno, #NR_syscalls @ check range 37210573ae5SRussell King#ifdef CONFIG_CPU_SPECTRE 37310573ae5SRussell King movhs scno, #0 37410573ae5SRussell King csdb 37510573ae5SRussell King#endif 376e44fc388SStefan Agner stmialo sp, {r5, r6} @ shuffle args 3771da177e4SLinus Torvalds movlo r0, r1 3781da177e4SLinus Torvalds movlo r1, r2 3791da177e4SLinus Torvalds movlo r2, r3 3801da177e4SLinus Torvalds movlo r3, r4 3811da177e4SLinus Torvalds ldrlo pc, [tbl, scno, lsl #2] 3821da177e4SLinus Torvalds b sys_ni_syscall 38393ed3970SCatalin MarinasENDPROC(sys_syscall) 3841da177e4SLinus Torvalds 3851da177e4SLinus Torvaldssys_sigreturn_wrapper: 3861da177e4SLinus Torvalds add r0, sp, #S_OFF 387653d48b2SAl Viro mov why, #0 @ prevent syscall restart handling 3881da177e4SLinus Torvalds b sys_sigreturn 38993ed3970SCatalin MarinasENDPROC(sys_sigreturn_wrapper) 3901da177e4SLinus Torvalds 3911da177e4SLinus Torvaldssys_rt_sigreturn_wrapper: 3921da177e4SLinus Torvalds add r0, sp, #S_OFF 393653d48b2SAl Viro mov why, #0 @ prevent syscall restart handling 3941da177e4SLinus Torvalds b sys_rt_sigreturn 39593ed3970SCatalin MarinasENDPROC(sys_rt_sigreturn_wrapper) 3961da177e4SLinus Torvalds 397713c4815SNicolas Pitresys_statfs64_wrapper: 398713c4815SNicolas Pitre teq r1, #88 399713c4815SNicolas Pitre moveq r1, #84 400713c4815SNicolas Pitre b sys_statfs64 40193ed3970SCatalin MarinasENDPROC(sys_statfs64_wrapper) 402713c4815SNicolas Pitre 403713c4815SNicolas Pitresys_fstatfs64_wrapper: 404713c4815SNicolas Pitre teq r1, #88 405713c4815SNicolas Pitre moveq r1, #84 406713c4815SNicolas Pitre b sys_fstatfs64 40793ed3970SCatalin MarinasENDPROC(sys_fstatfs64_wrapper) 408713c4815SNicolas Pitre 4091da177e4SLinus Torvalds/* 4101da177e4SLinus Torvalds * Note: off_4k (r5) is always units of 4K. If we can't do the requested 4111da177e4SLinus Torvalds * offset, we return EINVAL. 4121da177e4SLinus Torvalds */ 4131da177e4SLinus Torvaldssys_mmap2: 4141da177e4SLinus Torvalds str r5, [sp, #4] 415f8b72560SAl Viro b sys_mmap_pgoff 41693ed3970SCatalin MarinasENDPROC(sys_mmap2) 417687ad019SNicolas Pitre 418687ad019SNicolas Pitre#ifdef CONFIG_OABI_COMPAT 419dd35afc2SNicolas Pitre 420687ad019SNicolas Pitre/* 421687ad019SNicolas Pitre * These are syscalls with argument register differences 422687ad019SNicolas Pitre */ 423687ad019SNicolas Pitre 424687ad019SNicolas Pitresys_oabi_pread64: 425687ad019SNicolas Pitre stmia sp, {r3, r4} 426687ad019SNicolas Pitre b sys_pread64 42793ed3970SCatalin MarinasENDPROC(sys_oabi_pread64) 428687ad019SNicolas Pitre 429687ad019SNicolas Pitresys_oabi_pwrite64: 430687ad019SNicolas Pitre stmia sp, {r3, r4} 431687ad019SNicolas Pitre b sys_pwrite64 43293ed3970SCatalin MarinasENDPROC(sys_oabi_pwrite64) 433687ad019SNicolas Pitre 434687ad019SNicolas Pitresys_oabi_truncate64: 435687ad019SNicolas Pitre mov r3, r2 436687ad019SNicolas Pitre mov r2, r1 437687ad019SNicolas Pitre b sys_truncate64 43893ed3970SCatalin MarinasENDPROC(sys_oabi_truncate64) 439687ad019SNicolas Pitre 440687ad019SNicolas Pitresys_oabi_ftruncate64: 441687ad019SNicolas Pitre mov r3, r2 442687ad019SNicolas Pitre mov r2, r1 443687ad019SNicolas Pitre b sys_ftruncate64 44493ed3970SCatalin MarinasENDPROC(sys_oabi_ftruncate64) 445687ad019SNicolas Pitre 446687ad019SNicolas Pitresys_oabi_readahead: 447687ad019SNicolas Pitre str r3, [sp] 448687ad019SNicolas Pitre mov r3, r2 449687ad019SNicolas Pitre mov r2, r1 450687ad019SNicolas Pitre b sys_readahead 45193ed3970SCatalin MarinasENDPROC(sys_oabi_readahead) 452687ad019SNicolas Pitre 453dd35afc2SNicolas Pitre/* 454dd35afc2SNicolas Pitre * Let's declare a second syscall table for old ABI binaries 455dd35afc2SNicolas Pitre * using the compatibility syscall entries. 456dd35afc2SNicolas Pitre */ 45796a8fae0SRussell King syscall_table_start sys_oabi_call_table 4580047eb9fSMasahiro Yamada#undef __SYSCALL_WITH_COMPAT 4590047eb9fSMasahiro Yamada#define __SYSCALL_WITH_COMPAT(nr, native, compat) __SYSCALL(nr, compat) 46096a8fae0SRussell King#include <calls-oabi.S> 46196a8fae0SRussell King syscall_table_end sys_oabi_call_table 462dd35afc2SNicolas Pitre 463687ad019SNicolas Pitre#endif 464687ad019SNicolas Pitre 465