11da177e4SLinus Torvalds/* 21da177e4SLinus Torvalds * linux/arch/arm/kernel/entry-common.S 31da177e4SLinus Torvalds * 41da177e4SLinus Torvalds * Copyright (C) 2000 Russell King 51da177e4SLinus Torvalds * 61da177e4SLinus Torvalds * This program is free software; you can redistribute it and/or modify 71da177e4SLinus Torvalds * it under the terms of the GNU General Public License version 2 as 81da177e4SLinus Torvalds * published by the Free Software Foundation. 91da177e4SLinus Torvalds */ 101da177e4SLinus Torvalds 111da177e4SLinus Torvalds#include <asm/unistd.h> 12395a59d0SAbhishek Sagar#include <asm/ftrace.h> 13a09e64fbSRussell King#include <mach/entry-macro.S> 14c4c5716eSCatalin Marinas#include <asm/unwind.h> 151da177e4SLinus Torvalds 161da177e4SLinus Torvalds#include "entry-header.S" 171da177e4SLinus Torvalds 181da177e4SLinus Torvalds 191da177e4SLinus Torvalds .align 5 201da177e4SLinus Torvalds/* 211da177e4SLinus Torvalds * This is the fast syscall return path. We do as little as 221da177e4SLinus Torvalds * possible here, and this includes saving r0 back into the SVC 231da177e4SLinus Torvalds * stack. 241da177e4SLinus Torvalds */ 251da177e4SLinus Torvaldsret_fast_syscall: 26c4c5716eSCatalin Marinas UNWIND(.fnstart ) 27c4c5716eSCatalin Marinas UNWIND(.cantunwind ) 281ec42c0cSRussell King disable_irq @ disable interrupts 291da177e4SLinus Torvalds ldr r1, [tsk, #TI_FLAGS] 301da177e4SLinus Torvalds tst r1, #_TIF_WORK_MASK 311da177e4SLinus Torvalds bne fast_work_pending 32d13e5eddSTodd Android Poynor#if defined(CONFIG_IRQSOFF_TRACER) 33d13e5eddSTodd Android Poynor asm_trace_hardirqs_on 34d13e5eddSTodd Android Poynor#endif 35f4dc9a4cSRussell King 36f80dff9dSDan Williams /* perform architecture specific actions before user return */ 37f80dff9dSDan Williams arch_ret_to_user r1, lr 38f80dff9dSDan Williams 39b86040a5SCatalin Marinas restore_user_regs fast = 1, offset = S_OFF 40c4c5716eSCatalin Marinas UNWIND(.fnend ) 411da177e4SLinus Torvalds 421da177e4SLinus Torvalds/* 431da177e4SLinus Torvalds * Ok, we need to do extra processing, enter the slow path. 441da177e4SLinus Torvalds */ 451da177e4SLinus Torvaldsfast_work_pending: 461da177e4SLinus Torvalds str r0, [sp, #S_R0+S_OFF]! @ returned r0 471da177e4SLinus Torvaldswork_pending: 481da177e4SLinus Torvalds tst r1, #_TIF_NEED_RESCHED 491da177e4SLinus Torvalds bne work_resched 50d0420c83SDavid Howells tst r1, #_TIF_SIGPENDING|_TIF_NOTIFY_RESUME 511da177e4SLinus Torvalds beq no_work_pending 521da177e4SLinus Torvalds mov r0, sp @ 'regs' 531da177e4SLinus Torvalds mov r2, why @ 'syscall' 54b2b163bbSRussell King tst r1, #_TIF_SIGPENDING @ delivering a signal? 55b2b163bbSRussell King movne why, #0 @ prevent further restarts 561da177e4SLinus Torvalds bl do_notify_resume 57a6c61e9dSDaniel Jacobowitz b ret_slow_syscall @ Check work again 581da177e4SLinus Torvalds 591da177e4SLinus Torvaldswork_resched: 601da177e4SLinus Torvalds bl schedule 611da177e4SLinus Torvalds/* 621da177e4SLinus Torvalds * "slow" syscall return path. "why" tells us if this was a real syscall. 631da177e4SLinus Torvalds */ 641da177e4SLinus TorvaldsENTRY(ret_to_user) 651da177e4SLinus Torvaldsret_slow_syscall: 661ec42c0cSRussell King disable_irq @ disable interrupts 671da177e4SLinus Torvalds ldr r1, [tsk, #TI_FLAGS] 681da177e4SLinus Torvalds tst r1, #_TIF_WORK_MASK 691da177e4SLinus Torvalds bne work_pending 701da177e4SLinus Torvaldsno_work_pending: 71d13e5eddSTodd Android Poynor#if defined(CONFIG_IRQSOFF_TRACER) 72d13e5eddSTodd Android Poynor asm_trace_hardirqs_on 73d13e5eddSTodd Android Poynor#endif 74f80dff9dSDan Williams /* perform architecture specific actions before user return */ 75f80dff9dSDan Williams arch_ret_to_user r1, lr 76f80dff9dSDan Williams 77b86040a5SCatalin Marinas restore_user_regs fast = 0, offset = 0 7893ed3970SCatalin MarinasENDPROC(ret_to_user) 791da177e4SLinus Torvalds 801da177e4SLinus Torvalds/* 811da177e4SLinus Torvalds * This is how we return from a fork. 821da177e4SLinus Torvalds */ 831da177e4SLinus TorvaldsENTRY(ret_from_fork) 841da177e4SLinus Torvalds bl schedule_tail 851da177e4SLinus Torvalds get_thread_info tsk 861da177e4SLinus Torvalds ldr r1, [tsk, #TI_FLAGS] @ check for syscall tracing 871da177e4SLinus Torvalds mov why, #1 881da177e4SLinus Torvalds tst r1, #_TIF_SYSCALL_TRACE @ are we tracing syscalls? 891da177e4SLinus Torvalds beq ret_slow_syscall 901da177e4SLinus Torvalds mov r1, sp 911da177e4SLinus Torvalds mov r0, #1 @ trace exit [IP = 1] 921da177e4SLinus Torvalds bl syscall_trace 931da177e4SLinus Torvalds b ret_slow_syscall 9493ed3970SCatalin MarinasENDPROC(ret_from_fork) 951da177e4SLinus Torvalds 96fa1b4f91SAl Viro .equ NR_syscalls,0 97fa1b4f91SAl Viro#define CALL(x) .equ NR_syscalls,NR_syscalls+1 981da177e4SLinus Torvalds#include "calls.S" 99fa1b4f91SAl Viro#undef CALL 100fa1b4f91SAl Viro#define CALL(x) .long x 1011da177e4SLinus Torvalds 102606576ceSSteven Rostedt#ifdef CONFIG_FUNCTION_TRACER 103686ff228SRabin Vincent/* 104686ff228SRabin Vincent * When compiling with -pg, gcc inserts a call to the mcount routine at the 105686ff228SRabin Vincent * start of every function. In mcount, apart from the function's address (in 106686ff228SRabin Vincent * lr), we need to get hold of the function's caller's address. 107686ff228SRabin Vincent * 108686ff228SRabin Vincent * Older GCCs (pre-4.4) inserted a call to a routine called mcount like this: 109686ff228SRabin Vincent * 110686ff228SRabin Vincent * bl mcount 111686ff228SRabin Vincent * 112686ff228SRabin Vincent * These versions have the limitation that in order for the mcount routine to 113686ff228SRabin Vincent * be able to determine the function's caller's address, an APCS-style frame 114686ff228SRabin Vincent * pointer (which is set up with something like the code below) is required. 115686ff228SRabin Vincent * 116686ff228SRabin Vincent * mov ip, sp 117686ff228SRabin Vincent * push {fp, ip, lr, pc} 118686ff228SRabin Vincent * sub fp, ip, #4 119686ff228SRabin Vincent * 120686ff228SRabin Vincent * With EABI, these frame pointers are not available unless -mapcs-frame is 121686ff228SRabin Vincent * specified, and if building as Thumb-2, not even then. 122686ff228SRabin Vincent * 123686ff228SRabin Vincent * Newer GCCs (4.4+) solve this problem by introducing a new version of mcount, 124686ff228SRabin Vincent * with call sites like: 125686ff228SRabin Vincent * 126686ff228SRabin Vincent * push {lr} 127686ff228SRabin Vincent * bl __gnu_mcount_nc 128686ff228SRabin Vincent * 129686ff228SRabin Vincent * With these compilers, frame pointers are not necessary. 130686ff228SRabin Vincent * 131686ff228SRabin Vincent * mcount can be thought of as a function called in the middle of a subroutine 132686ff228SRabin Vincent * call. As such, it needs to be transparent for both the caller and the 133686ff228SRabin Vincent * callee: the original lr needs to be restored when leaving mcount, and no 134686ff228SRabin Vincent * registers should be clobbered. (In the __gnu_mcount_nc implementation, we 135686ff228SRabin Vincent * clobber the ip register. This is OK because the ARM calling convention 136686ff228SRabin Vincent * allows it to be clobbered in subroutines and doesn't use it to hold 137686ff228SRabin Vincent * parameters.) 1383b6c223bSRabin Vincent * 1393b6c223bSRabin Vincent * When using dynamic ftrace, we patch out the mcount call by a "mov r0, r0" 1403b6c223bSRabin Vincent * for the mcount case, and a "pop {lr}" for the __gnu_mcount_nc case (see 1413b6c223bSRabin Vincent * arch/arm/kernel/ftrace.c). 142686ff228SRabin Vincent */ 14309bfafacSRabin Vincent 14409bfafacSRabin Vincent#ifndef CONFIG_OLD_MCOUNT 14509bfafacSRabin Vincent#if (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 4)) 14609bfafacSRabin Vincent#error Ftrace requires CONFIG_FRAME_POINTER=y with GCC older than 4.4.0. 14709bfafacSRabin Vincent#endif 14809bfafacSRabin Vincent#endif 14909bfafacSRabin Vincent 150014c257cSAbhishek Sagar#ifdef CONFIG_DYNAMIC_FTRACE 1513b6c223bSRabin VincentENTRY(__gnu_mcount_nc) 1523b6c223bSRabin Vincent mov ip, lr 1533b6c223bSRabin Vincent ldmia sp!, {lr} 1543b6c223bSRabin Vincent mov pc, ip 1553b6c223bSRabin VincentENDPROC(__gnu_mcount_nc) 1563b6c223bSRabin Vincent 1573b6c223bSRabin VincentENTRY(ftrace_caller) 158014c257cSAbhishek Sagar stmdb sp!, {r0-r3, lr} 159014c257cSAbhishek Sagar mov r0, lr 160395a59d0SAbhishek Sagar sub r0, r0, #MCOUNT_INSN_SIZE 1613b6c223bSRabin Vincent ldr r1, [sp, #20] 162014c257cSAbhishek Sagar 1633b6c223bSRabin Vincent .global ftrace_call 1643b6c223bSRabin Vincentftrace_call: 165014c257cSAbhishek Sagar bl ftrace_stub 1663b6c223bSRabin Vincent ldmia sp!, {r0-r3, ip, lr} 1673b6c223bSRabin Vincent mov pc, ip 1683b6c223bSRabin VincentENDPROC(ftrace_caller) 169014c257cSAbhishek Sagar 1703b6c223bSRabin Vincent#ifdef CONFIG_OLD_MCOUNT 1713b6c223bSRabin VincentENTRY(mcount) 1723b6c223bSRabin Vincent stmdb sp!, {lr} 1733b6c223bSRabin Vincent ldr lr, [fp, #-4] 1743b6c223bSRabin Vincent ldmia sp!, {pc} 17572fa62faSRabin VincentENDPROC(mcount) 176014c257cSAbhishek Sagar 1773b6c223bSRabin VincentENTRY(ftrace_caller_old) 178014c257cSAbhishek Sagar stmdb sp!, {r0-r3, lr} 179014c257cSAbhishek Sagar ldr r1, [fp, #-4] 180014c257cSAbhishek Sagar mov r0, lr 181395a59d0SAbhishek Sagar sub r0, r0, #MCOUNT_INSN_SIZE 182014c257cSAbhishek Sagar 1833b6c223bSRabin Vincent .globl ftrace_call_old 1843b6c223bSRabin Vincentftrace_call_old: 185014c257cSAbhishek Sagar bl ftrace_stub 186d4cc510cSUwe Kleine-König ldr lr, [fp, #-4] @ restore lr 187014c257cSAbhishek Sagar ldmia sp!, {r0-r3, pc} 1883b6c223bSRabin VincentENDPROC(ftrace_caller_old) 1893b6c223bSRabin Vincent#endif 190014c257cSAbhishek Sagar 191014c257cSAbhishek Sagar#else 192014c257cSAbhishek Sagar 193181f817eSUwe Kleine-KönigENTRY(__gnu_mcount_nc) 194181f817eSUwe Kleine-König stmdb sp!, {r0-r3, lr} 195181f817eSUwe Kleine-König ldr r0, =ftrace_trace_function 196181f817eSUwe Kleine-König ldr r2, [r0] 197a3ba87a6SRabin Vincent adr r0, .Lftrace_stub 198181f817eSUwe Kleine-König cmp r0, r2 199181f817eSUwe Kleine-König bne gnu_trace 200181f817eSUwe Kleine-König ldmia sp!, {r0-r3, ip, lr} 2016176d394SDmitry Artamonow mov pc, ip 202181f817eSUwe Kleine-König 203181f817eSUwe Kleine-Königgnu_trace: 204181f817eSUwe Kleine-König ldr r1, [sp, #20] @ lr of instrumented routine 205181f817eSUwe Kleine-König mov r0, lr 206181f817eSUwe Kleine-König sub r0, r0, #MCOUNT_INSN_SIZE 207a3ba87a6SRabin Vincent adr lr, BSYM(1f) 208181f817eSUwe Kleine-König mov pc, r2 209a3ba87a6SRabin Vincent1: 210181f817eSUwe Kleine-König ldmia sp!, {r0-r3, ip, lr} 2116176d394SDmitry Artamonow mov pc, ip 21272fa62faSRabin VincentENDPROC(__gnu_mcount_nc) 213181f817eSUwe Kleine-König 21409bfafacSRabin Vincent#ifdef CONFIG_OLD_MCOUNT 21509bfafacSRabin Vincent/* 21609bfafacSRabin Vincent * This is under an ifdef in order to force link-time errors for people trying 21709bfafacSRabin Vincent * to build with !FRAME_POINTER with a GCC which doesn't use the new-style 21809bfafacSRabin Vincent * mcount. 21909bfafacSRabin Vincent */ 220014c257cSAbhishek SagarENTRY(mcount) 221014c257cSAbhishek Sagar stmdb sp!, {r0-r3, lr} 222014c257cSAbhishek Sagar ldr r0, =ftrace_trace_function 223014c257cSAbhishek Sagar ldr r2, [r0] 224014c257cSAbhishek Sagar adr r0, ftrace_stub 225014c257cSAbhishek Sagar cmp r0, r2 226014c257cSAbhishek Sagar bne trace 227d4cc510cSUwe Kleine-König ldr lr, [fp, #-4] @ restore lr 228014c257cSAbhishek Sagar ldmia sp!, {r0-r3, pc} 229014c257cSAbhishek Sagar 230014c257cSAbhishek Sagartrace: 231b3c960b2SUwe Kleine-König ldr r1, [fp, #-4] @ lr of instrumented routine 232014c257cSAbhishek Sagar mov r0, lr 233395a59d0SAbhishek Sagar sub r0, r0, #MCOUNT_INSN_SIZE 234014c257cSAbhishek Sagar mov lr, pc 235014c257cSAbhishek Sagar mov pc, r2 2363ef7143dSUwe Kleine-König ldr lr, [fp, #-4] @ restore lr 237014c257cSAbhishek Sagar ldmia sp!, {r0-r3, pc} 23872fa62faSRabin VincentENDPROC(mcount) 23909bfafacSRabin Vincent#endif 240014c257cSAbhishek Sagar 241014c257cSAbhishek Sagar#endif /* CONFIG_DYNAMIC_FTRACE */ 242014c257cSAbhishek Sagar 24372fa62faSRabin VincentENTRY(ftrace_stub) 244a3ba87a6SRabin Vincent.Lftrace_stub: 245014c257cSAbhishek Sagar mov pc, lr 24672fa62faSRabin VincentENDPROC(ftrace_stub) 247014c257cSAbhishek Sagar 248606576ceSSteven Rostedt#endif /* CONFIG_FUNCTION_TRACER */ 249014c257cSAbhishek Sagar 2501da177e4SLinus Torvalds/*============================================================================= 2511da177e4SLinus Torvalds * SWI handler 2521da177e4SLinus Torvalds *----------------------------------------------------------------------------- 2531da177e4SLinus Torvalds */ 2541da177e4SLinus Torvalds 2551da177e4SLinus Torvalds /* If we're optimising for StrongARM the resulting code won't 2561da177e4SLinus Torvalds run on an ARM7 and we can save a couple of instructions. 2571da177e4SLinus Torvalds --pb */ 2581da177e4SLinus Torvalds#ifdef CONFIG_CPU_ARM710 2593f2829a3SNicolas Pitre#define A710(code...) code 2603f2829a3SNicolas Pitre.Larm710bug: 2611da177e4SLinus Torvalds ldmia sp, {r0 - lr}^ @ Get calling r0 - lr 2621da177e4SLinus Torvalds mov r0, r0 2631da177e4SLinus Torvalds add sp, sp, #S_FRAME_SIZE 26460ac133aSNicolas Pitre subs pc, lr, #4 2651da177e4SLinus Torvalds#else 2663f2829a3SNicolas Pitre#define A710(code...) 2671da177e4SLinus Torvalds#endif 2681da177e4SLinus Torvalds 2691da177e4SLinus Torvalds .align 5 2701da177e4SLinus TorvaldsENTRY(vector_swi) 271f4dc9a4cSRussell King sub sp, sp, #S_FRAME_SIZE 272f4dc9a4cSRussell King stmia sp, {r0 - r12} @ Calling r0 - r12 273b86040a5SCatalin Marinas ARM( add r8, sp, #S_PC ) 274b86040a5SCatalin Marinas ARM( stmdb r8, {sp, lr}^ ) @ Calling sp, lr 275b86040a5SCatalin Marinas THUMB( mov r8, sp ) 276b86040a5SCatalin Marinas THUMB( store_user_sp_lr r8, r10, S_SP ) @ calling sp, lr 277f4dc9a4cSRussell King mrs r8, spsr @ called from non-FIQ mode, so ok. 278f4dc9a4cSRussell King str lr, [sp, #S_PC] @ Save calling PC 279f4dc9a4cSRussell King str r8, [sp, #S_PSR] @ Save CPSR 280f4dc9a4cSRussell King str r0, [sp, #S_OLD_R0] @ Save OLD_R0 2811da177e4SLinus Torvalds zero_fp 282e0f9f4a6SRussell King 283e0f9f4a6SRussell King /* 284e0f9f4a6SRussell King * Get the system call number. 285e0f9f4a6SRussell King */ 2863f2829a3SNicolas Pitre 287dd35afc2SNicolas Pitre#if defined(CONFIG_OABI_COMPAT) 2883f2829a3SNicolas Pitre 289dd35afc2SNicolas Pitre /* 290dd35afc2SNicolas Pitre * If we have CONFIG_OABI_COMPAT then we need to look at the swi 291dd35afc2SNicolas Pitre * value to determine if it is an EABI or an old ABI call. 292dd35afc2SNicolas Pitre */ 293dd35afc2SNicolas Pitre#ifdef CONFIG_ARM_THUMB 294dd35afc2SNicolas Pitre tst r8, #PSR_T_BIT 295dd35afc2SNicolas Pitre movne r10, #0 @ no thumb OABI emulation 296dd35afc2SNicolas Pitre ldreq r10, [lr, #-4] @ get SWI instruction 297dd35afc2SNicolas Pitre#else 298dd35afc2SNicolas Pitre ldr r10, [lr, #-4] @ get SWI instruction 299dd35afc2SNicolas Pitre A710( and ip, r10, #0x0f000000 @ check for SWI ) 300dd35afc2SNicolas Pitre A710( teq ip, #0x0f000000 ) 301dd35afc2SNicolas Pitre A710( bne .Larm710bug ) 302dd35afc2SNicolas Pitre#endif 30326584853SCatalin Marinas#ifdef CONFIG_CPU_ENDIAN_BE8 30426584853SCatalin Marinas rev r10, r10 @ little endian instruction 30526584853SCatalin Marinas#endif 306dd35afc2SNicolas Pitre 307dd35afc2SNicolas Pitre#elif defined(CONFIG_AEABI) 308dd35afc2SNicolas Pitre 309dd35afc2SNicolas Pitre /* 310dd35afc2SNicolas Pitre * Pure EABI user space always put syscall number into scno (r7). 311dd35afc2SNicolas Pitre */ 3123f2829a3SNicolas Pitre A710( ldr ip, [lr, #-4] @ get SWI instruction ) 3133f2829a3SNicolas Pitre A710( and ip, ip, #0x0f000000 @ check for SWI ) 3143f2829a3SNicolas Pitre A710( teq ip, #0x0f000000 ) 3153f2829a3SNicolas Pitre A710( bne .Larm710bug ) 316dd35afc2SNicolas Pitre 3173f2829a3SNicolas Pitre#elif defined(CONFIG_ARM_THUMB) 318dd35afc2SNicolas Pitre 319dd35afc2SNicolas Pitre /* Legacy ABI only, possibly thumb mode. */ 320e0f9f4a6SRussell King tst r8, #PSR_T_BIT @ this is SPSR from save_user_regs 321e0f9f4a6SRussell King addne scno, r7, #__NR_SYSCALL_BASE @ put OS number in 322e0f9f4a6SRussell King ldreq scno, [lr, #-4] 323dd35afc2SNicolas Pitre 324e0f9f4a6SRussell King#else 325dd35afc2SNicolas Pitre 326dd35afc2SNicolas Pitre /* Legacy ABI only. */ 327e0f9f4a6SRussell King ldr scno, [lr, #-4] @ get SWI instruction 3283f2829a3SNicolas Pitre A710( and ip, scno, #0x0f000000 @ check for SWI ) 3293f2829a3SNicolas Pitre A710( teq ip, #0x0f000000 ) 3303f2829a3SNicolas Pitre A710( bne .Larm710bug ) 331dd35afc2SNicolas Pitre 332e0f9f4a6SRussell King#endif 3331da177e4SLinus Torvalds 3341da177e4SLinus Torvalds#ifdef CONFIG_ALIGNMENT_TRAP 3351da177e4SLinus Torvalds ldr ip, __cr_alignment 3361da177e4SLinus Torvalds ldr ip, [ip] 3371da177e4SLinus Torvalds mcr p15, 0, ip, c1, c0 @ update control register 3381da177e4SLinus Torvalds#endif 3391ec42c0cSRussell King enable_irq 3401da177e4SLinus Torvalds 3411da177e4SLinus Torvalds get_thread_info tsk 342dd35afc2SNicolas Pitre adr tbl, sys_call_table @ load syscall table pointer 343dd35afc2SNicolas Pitre 344dd35afc2SNicolas Pitre#if defined(CONFIG_OABI_COMPAT) 345dd35afc2SNicolas Pitre /* 346dd35afc2SNicolas Pitre * If the swi argument is zero, this is an EABI call and we do nothing. 347dd35afc2SNicolas Pitre * 348dd35afc2SNicolas Pitre * If this is an old ABI call, get the syscall number into scno and 349dd35afc2SNicolas Pitre * get the old ABI syscall table address. 350dd35afc2SNicolas Pitre */ 351dd35afc2SNicolas Pitre bics r10, r10, #0xff000000 352dd35afc2SNicolas Pitre eorne scno, r10, #__NR_OABI_SYSCALL_BASE 353dd35afc2SNicolas Pitre ldrne tbl, =sys_oabi_call_table 354dd35afc2SNicolas Pitre#elif !defined(CONFIG_AEABI) 3551da177e4SLinus Torvalds bic scno, scno, #0xff000000 @ mask off SWI op-code 356e0f9f4a6SRussell King eor scno, scno, #__NR_SYSCALL_BASE @ check OS number 3573f2829a3SNicolas Pitre#endif 358dd35afc2SNicolas Pitre 35970c70d97SNicolas Pitre ldr r10, [tsk, #TI_FLAGS] @ check for syscall tracing 3603f2829a3SNicolas Pitre stmdb sp!, {r4, r5} @ push fifth and sixth args 36170c70d97SNicolas Pitre 36270c70d97SNicolas Pitre#ifdef CONFIG_SECCOMP 36370c70d97SNicolas Pitre tst r10, #_TIF_SECCOMP 36470c70d97SNicolas Pitre beq 1f 36570c70d97SNicolas Pitre mov r0, scno 36670c70d97SNicolas Pitre bl __secure_computing 36770c70d97SNicolas Pitre add r0, sp, #S_R0 + S_OFF @ pointer to regs 36870c70d97SNicolas Pitre ldmia r0, {r0 - r3} @ have to reload r0 - r3 36970c70d97SNicolas Pitre1: 37070c70d97SNicolas Pitre#endif 37170c70d97SNicolas Pitre 37270c70d97SNicolas Pitre tst r10, #_TIF_SYSCALL_TRACE @ are we tracing syscalls? 3731da177e4SLinus Torvalds bne __sys_trace 3741da177e4SLinus Torvalds 3751da177e4SLinus Torvalds cmp scno, #NR_syscalls @ check upper syscall limit 376b86040a5SCatalin Marinas adr lr, BSYM(ret_fast_syscall) @ return address 3771da177e4SLinus Torvalds ldrcc pc, [tbl, scno, lsl #2] @ call sys_* routine 3781da177e4SLinus Torvalds 3791da177e4SLinus Torvalds add r1, sp, #S_OFF 3801da177e4SLinus Torvalds2: mov why, #0 @ no longer a real syscall 381e0f9f4a6SRussell King cmp scno, #(__ARM_NR_BASE - __NR_SYSCALL_BASE) 382e0f9f4a6SRussell King eor r0, scno, #__NR_SYSCALL_BASE @ put OS number back 3831da177e4SLinus Torvalds bcs arm_syscall 3841da177e4SLinus Torvalds b sys_ni_syscall @ not private func 38593ed3970SCatalin MarinasENDPROC(vector_swi) 3861da177e4SLinus Torvalds 3871da177e4SLinus Torvalds /* 3881da177e4SLinus Torvalds * This is the really slow path. We're going to be doing 3891da177e4SLinus Torvalds * context switches, and waiting for our parent to respond. 3901da177e4SLinus Torvalds */ 3911da177e4SLinus Torvalds__sys_trace: 3923f471126SNicolas Pitre mov r2, scno 3931da177e4SLinus Torvalds add r1, sp, #S_OFF 3941da177e4SLinus Torvalds mov r0, #0 @ trace entry [IP = 0] 3951da177e4SLinus Torvalds bl syscall_trace 3961da177e4SLinus Torvalds 397b86040a5SCatalin Marinas adr lr, BSYM(__sys_trace_return) @ return address 3983f471126SNicolas Pitre mov scno, r0 @ syscall number (possibly new) 3991da177e4SLinus Torvalds add r1, sp, #S_R0 + S_OFF @ pointer to regs 4001da177e4SLinus Torvalds cmp scno, #NR_syscalls @ check upper syscall limit 4011da177e4SLinus Torvalds ldmccia r1, {r0 - r3} @ have to reload r0 - r3 4021da177e4SLinus Torvalds ldrcc pc, [tbl, scno, lsl #2] @ call sys_* routine 4031da177e4SLinus Torvalds b 2b 4041da177e4SLinus Torvalds 4051da177e4SLinus Torvalds__sys_trace_return: 4061da177e4SLinus Torvalds str r0, [sp, #S_R0 + S_OFF]! @ save returned r0 4073f471126SNicolas Pitre mov r2, scno 4081da177e4SLinus Torvalds mov r1, sp 4091da177e4SLinus Torvalds mov r0, #1 @ trace exit [IP = 1] 4101da177e4SLinus Torvalds bl syscall_trace 4111da177e4SLinus Torvalds b ret_slow_syscall 4121da177e4SLinus Torvalds 4131da177e4SLinus Torvalds .align 5 4141da177e4SLinus Torvalds#ifdef CONFIG_ALIGNMENT_TRAP 4151da177e4SLinus Torvalds .type __cr_alignment, #object 4161da177e4SLinus Torvalds__cr_alignment: 4171da177e4SLinus Torvalds .word cr_alignment 4181da177e4SLinus Torvalds#endif 419dd35afc2SNicolas Pitre .ltorg 420dd35afc2SNicolas Pitre 421dd35afc2SNicolas Pitre/* 422dd35afc2SNicolas Pitre * This is the syscall table declaration for native ABI syscalls. 423dd35afc2SNicolas Pitre * With EABI a couple syscalls are obsolete and defined as sys_ni_syscall. 424dd35afc2SNicolas Pitre */ 425dd35afc2SNicolas Pitre#define ABI(native, compat) native 426dd35afc2SNicolas Pitre#ifdef CONFIG_AEABI 427dd35afc2SNicolas Pitre#define OBSOLETE(syscall) sys_ni_syscall 428dd35afc2SNicolas Pitre#else 429dd35afc2SNicolas Pitre#define OBSOLETE(syscall) syscall 430dd35afc2SNicolas Pitre#endif 4311da177e4SLinus Torvalds 4321da177e4SLinus Torvalds .type sys_call_table, #object 4331da177e4SLinus TorvaldsENTRY(sys_call_table) 4341da177e4SLinus Torvalds#include "calls.S" 435dd35afc2SNicolas Pitre#undef ABI 436dd35afc2SNicolas Pitre#undef OBSOLETE 4371da177e4SLinus Torvalds 4381da177e4SLinus Torvalds/*============================================================================ 4391da177e4SLinus Torvalds * Special system call wrappers 4401da177e4SLinus Torvalds */ 4411da177e4SLinus Torvalds@ r0 = syscall number 442567bd980SRussell King@ r8 = syscall table 4431da177e4SLinus Torvaldssys_syscall: 4445247593cSPaul Brook bic scno, r0, #__NR_OABI_SYSCALL_BASE 4451da177e4SLinus Torvalds cmp scno, #__NR_syscall - __NR_SYSCALL_BASE 4461da177e4SLinus Torvalds cmpne scno, #NR_syscalls @ check range 4471da177e4SLinus Torvalds stmloia sp, {r5, r6} @ shuffle args 4481da177e4SLinus Torvalds movlo r0, r1 4491da177e4SLinus Torvalds movlo r1, r2 4501da177e4SLinus Torvalds movlo r2, r3 4511da177e4SLinus Torvalds movlo r3, r4 4521da177e4SLinus Torvalds ldrlo pc, [tbl, scno, lsl #2] 4531da177e4SLinus Torvalds b sys_ni_syscall 45493ed3970SCatalin MarinasENDPROC(sys_syscall) 4551da177e4SLinus Torvalds 4561da177e4SLinus Torvaldssys_fork_wrapper: 4571da177e4SLinus Torvalds add r0, sp, #S_OFF 4581da177e4SLinus Torvalds b sys_fork 45993ed3970SCatalin MarinasENDPROC(sys_fork_wrapper) 4601da177e4SLinus Torvalds 4611da177e4SLinus Torvaldssys_vfork_wrapper: 4621da177e4SLinus Torvalds add r0, sp, #S_OFF 4631da177e4SLinus Torvalds b sys_vfork 46493ed3970SCatalin MarinasENDPROC(sys_vfork_wrapper) 4651da177e4SLinus Torvalds 4661da177e4SLinus Torvaldssys_execve_wrapper: 4671da177e4SLinus Torvalds add r3, sp, #S_OFF 4681da177e4SLinus Torvalds b sys_execve 46993ed3970SCatalin MarinasENDPROC(sys_execve_wrapper) 4701da177e4SLinus Torvalds 4711da177e4SLinus Torvaldssys_clone_wrapper: 4721da177e4SLinus Torvalds add ip, sp, #S_OFF 4731da177e4SLinus Torvalds str ip, [sp, #4] 4741da177e4SLinus Torvalds b sys_clone 47593ed3970SCatalin MarinasENDPROC(sys_clone_wrapper) 4761da177e4SLinus Torvalds 4771da177e4SLinus Torvaldssys_sigreturn_wrapper: 4781da177e4SLinus Torvalds add r0, sp, #S_OFF 479653d48b2SAl Viro mov why, #0 @ prevent syscall restart handling 4801da177e4SLinus Torvalds b sys_sigreturn 48193ed3970SCatalin MarinasENDPROC(sys_sigreturn_wrapper) 4821da177e4SLinus Torvalds 4831da177e4SLinus Torvaldssys_rt_sigreturn_wrapper: 4841da177e4SLinus Torvalds add r0, sp, #S_OFF 485653d48b2SAl Viro mov why, #0 @ prevent syscall restart handling 4861da177e4SLinus Torvalds b sys_rt_sigreturn 48793ed3970SCatalin MarinasENDPROC(sys_rt_sigreturn_wrapper) 4881da177e4SLinus Torvalds 4891da177e4SLinus Torvaldssys_sigaltstack_wrapper: 4901da177e4SLinus Torvalds ldr r2, [sp, #S_OFF + S_SP] 4911da177e4SLinus Torvalds b do_sigaltstack 49293ed3970SCatalin MarinasENDPROC(sys_sigaltstack_wrapper) 4931da177e4SLinus Torvalds 494713c4815SNicolas Pitresys_statfs64_wrapper: 495713c4815SNicolas Pitre teq r1, #88 496713c4815SNicolas Pitre moveq r1, #84 497713c4815SNicolas Pitre b sys_statfs64 49893ed3970SCatalin MarinasENDPROC(sys_statfs64_wrapper) 499713c4815SNicolas Pitre 500713c4815SNicolas Pitresys_fstatfs64_wrapper: 501713c4815SNicolas Pitre teq r1, #88 502713c4815SNicolas Pitre moveq r1, #84 503713c4815SNicolas Pitre b sys_fstatfs64 50493ed3970SCatalin MarinasENDPROC(sys_fstatfs64_wrapper) 505713c4815SNicolas Pitre 5061da177e4SLinus Torvalds/* 5071da177e4SLinus Torvalds * Note: off_4k (r5) is always units of 4K. If we can't do the requested 5081da177e4SLinus Torvalds * offset, we return EINVAL. 5091da177e4SLinus Torvalds */ 5101da177e4SLinus Torvaldssys_mmap2: 5111da177e4SLinus Torvalds#if PAGE_SHIFT > 12 5121da177e4SLinus Torvalds tst r5, #PGOFF_MASK 5131da177e4SLinus Torvalds moveq r5, r5, lsr #PAGE_SHIFT - 12 5141da177e4SLinus Torvalds streq r5, [sp, #4] 515f8b72560SAl Viro beq sys_mmap_pgoff 5161da177e4SLinus Torvalds mov r0, #-EINVAL 5177999d8d7SRussell King mov pc, lr 5181da177e4SLinus Torvalds#else 5191da177e4SLinus Torvalds str r5, [sp, #4] 520f8b72560SAl Viro b sys_mmap_pgoff 5211da177e4SLinus Torvalds#endif 52293ed3970SCatalin MarinasENDPROC(sys_mmap2) 523687ad019SNicolas Pitre 524687ad019SNicolas Pitre#ifdef CONFIG_OABI_COMPAT 525dd35afc2SNicolas Pitre 526687ad019SNicolas Pitre/* 527687ad019SNicolas Pitre * These are syscalls with argument register differences 528687ad019SNicolas Pitre */ 529687ad019SNicolas Pitre 530687ad019SNicolas Pitresys_oabi_pread64: 531687ad019SNicolas Pitre stmia sp, {r3, r4} 532687ad019SNicolas Pitre b sys_pread64 53393ed3970SCatalin MarinasENDPROC(sys_oabi_pread64) 534687ad019SNicolas Pitre 535687ad019SNicolas Pitresys_oabi_pwrite64: 536687ad019SNicolas Pitre stmia sp, {r3, r4} 537687ad019SNicolas Pitre b sys_pwrite64 53893ed3970SCatalin MarinasENDPROC(sys_oabi_pwrite64) 539687ad019SNicolas Pitre 540687ad019SNicolas Pitresys_oabi_truncate64: 541687ad019SNicolas Pitre mov r3, r2 542687ad019SNicolas Pitre mov r2, r1 543687ad019SNicolas Pitre b sys_truncate64 54493ed3970SCatalin MarinasENDPROC(sys_oabi_truncate64) 545687ad019SNicolas Pitre 546687ad019SNicolas Pitresys_oabi_ftruncate64: 547687ad019SNicolas Pitre mov r3, r2 548687ad019SNicolas Pitre mov r2, r1 549687ad019SNicolas Pitre b sys_ftruncate64 55093ed3970SCatalin MarinasENDPROC(sys_oabi_ftruncate64) 551687ad019SNicolas Pitre 552687ad019SNicolas Pitresys_oabi_readahead: 553687ad019SNicolas Pitre str r3, [sp] 554687ad019SNicolas Pitre mov r3, r2 555687ad019SNicolas Pitre mov r2, r1 556687ad019SNicolas Pitre b sys_readahead 55793ed3970SCatalin MarinasENDPROC(sys_oabi_readahead) 558687ad019SNicolas Pitre 559dd35afc2SNicolas Pitre/* 560dd35afc2SNicolas Pitre * Let's declare a second syscall table for old ABI binaries 561dd35afc2SNicolas Pitre * using the compatibility syscall entries. 562dd35afc2SNicolas Pitre */ 563dd35afc2SNicolas Pitre#define ABI(native, compat) compat 564dd35afc2SNicolas Pitre#define OBSOLETE(syscall) syscall 565dd35afc2SNicolas Pitre 566dd35afc2SNicolas Pitre .type sys_oabi_call_table, #object 567dd35afc2SNicolas PitreENTRY(sys_oabi_call_table) 568dd35afc2SNicolas Pitre#include "calls.S" 569dd35afc2SNicolas Pitre#undef ABI 570dd35afc2SNicolas Pitre#undef OBSOLETE 571dd35afc2SNicolas Pitre 572687ad019SNicolas Pitre#endif 573687ad019SNicolas Pitre 574