Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * linux/arch/arm/kernel/entry-common.S |
| 3 | * |
| 4 | * Copyright (C) 2000 Russell King |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License version 2 as |
| 8 | * published by the Free Software Foundation. |
| 9 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | |
Russell King | 6ebbf2c | 2014-06-30 16:29:12 +0100 | [diff] [blame] | 11 | #include <asm/assembler.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | #include <asm/unistd.h> |
Abhishek Sagar | 395a59d | 2008-06-21 23:47:27 +0530 | [diff] [blame] | 13 | #include <asm/ftrace.h> |
Catalin Marinas | c4c5716 | 2009-02-16 11:42:09 +0100 | [diff] [blame] | 14 | #include <asm/unwind.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | |
Rob Herring | 13a5045 | 2012-02-07 09:28:22 -0600 | [diff] [blame] | 16 | #ifdef CONFIG_NEED_RET_TO_USER |
| 17 | #include <mach/entry-macro.S> |
| 18 | #else |
| 19 | .macro arch_ret_to_user, tmp1, tmp2 |
| 20 | .endm |
| 21 | #endif |
| 22 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | #include "entry-header.S" |
| 24 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | |
| 26 | .align 5 |
Russell King | 3302cad | 2015-08-20 16:13:37 +0100 | [diff] [blame] | 27 | #if !(IS_ENABLED(CONFIG_TRACE_IRQFLAGS) || IS_ENABLED(CONFIG_CONTEXT_TRACKING)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | /* |
Russell King | 3302cad | 2015-08-20 16:13:37 +0100 | [diff] [blame] | 29 | * This is the fast syscall return path. We do as little as possible here, |
| 30 | * such as avoiding writing r0 to the stack. We only use this path if we |
| 31 | * have tracing and context tracking disabled - the overheads from those |
| 32 | * features make this path too inefficient. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | */ |
| 34 | ret_fast_syscall: |
Catalin Marinas | c4c5716 | 2009-02-16 11:42:09 +0100 | [diff] [blame] | 35 | UNWIND(.fnstart ) |
| 36 | UNWIND(.cantunwind ) |
Russell King | 3302cad | 2015-08-20 16:13:37 +0100 | [diff] [blame] | 37 | disable_irq_notrace @ disable interrupts |
Russell King | 1b97937 | 2015-05-15 11:02:23 +0100 | [diff] [blame] | 38 | ldr r1, [tsk, #TI_FLAGS] @ re-check for syscall tracing |
Russell King | 3302cad | 2015-08-20 16:13:37 +0100 | [diff] [blame] | 39 | tst r1, #_TIF_SYSCALL_WORK | _TIF_WORK_MASK |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | bne fast_work_pending |
Russell King | f4dc9a4 | 2005-04-26 15:20:34 +0100 | [diff] [blame] | 41 | |
Dan Williams | f80dff9 | 2007-02-16 22:16:32 +0100 | [diff] [blame] | 42 | /* perform architecture specific actions before user return */ |
| 43 | arch_ret_to_user r1, lr |
| 44 | |
Catalin Marinas | b86040a | 2009-07-24 12:32:54 +0100 | [diff] [blame] | 45 | restore_user_regs fast = 1, offset = S_OFF |
Catalin Marinas | c4c5716 | 2009-02-16 11:42:09 +0100 | [diff] [blame] | 46 | UNWIND(.fnend ) |
Russell King | 3302cad | 2015-08-20 16:13:37 +0100 | [diff] [blame] | 47 | ENDPROC(ret_fast_syscall) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | |
Russell King | 3302cad | 2015-08-20 16:13:37 +0100 | [diff] [blame] | 49 | /* Ok, we need to do extra processing, enter the slow path. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | fast_work_pending: |
| 51 | str r0, [sp, #S_R0+S_OFF]! @ returned r0 |
Russell King | 3302cad | 2015-08-20 16:13:37 +0100 | [diff] [blame] | 52 | /* fall through to work_pending */ |
| 53 | #else |
| 54 | /* |
| 55 | * The "replacement" ret_fast_syscall for when tracing or context tracking |
| 56 | * is enabled. As we will need to call out to some C functions, we save |
| 57 | * r0 first to avoid needing to save registers around each C function call. |
| 58 | */ |
| 59 | ret_fast_syscall: |
| 60 | UNWIND(.fnstart ) |
| 61 | UNWIND(.cantunwind ) |
| 62 | str r0, [sp, #S_R0 + S_OFF]! @ save returned r0 |
| 63 | disable_irq_notrace @ disable interrupts |
| 64 | ldr r1, [tsk, #TI_FLAGS] @ re-check for syscall tracing |
| 65 | tst r1, #_TIF_SYSCALL_WORK | _TIF_WORK_MASK |
| 66 | beq no_work_pending |
| 67 | UNWIND(.fnend ) |
| 68 | ENDPROC(ret_fast_syscall) |
| 69 | |
| 70 | /* Slower path - fall through to work_pending */ |
| 71 | #endif |
| 72 | |
| 73 | tst r1, #_TIF_SYSCALL_WORK |
| 74 | bne __sys_trace_return_nosave |
| 75 | slow_work_pending: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | mov r0, sp @ 'regs' |
| 77 | mov r2, why @ 'syscall' |
Al Viro | 0a267fa | 2012-07-19 17:47:55 +0100 | [diff] [blame] | 78 | bl do_work_pending |
Al Viro | 6628521 | 2012-07-19 17:48:50 +0100 | [diff] [blame] | 79 | cmp r0, #0 |
Al Viro | 8178378 | 2012-07-19 17:48:21 +0100 | [diff] [blame] | 80 | beq no_work_pending |
Al Viro | 6628521 | 2012-07-19 17:48:50 +0100 | [diff] [blame] | 81 | movlt scno, #(__NR_restart_syscall - __NR_SYSCALL_BASE) |
Al Viro | 8178378 | 2012-07-19 17:48:21 +0100 | [diff] [blame] | 82 | ldmia sp, {r0 - r6} @ have to reload r0 - r6 |
| 83 | b local_restart @ ... and off we go |
| 84 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | /* |
| 86 | * "slow" syscall return path. "why" tells us if this was a real syscall. |
Russell King | 3302cad | 2015-08-20 16:13:37 +0100 | [diff] [blame] | 87 | * IRQs may be enabled here, so always disable them. Note that we use the |
| 88 | * "notrace" version to avoid calling into the tracing code unnecessarily. |
| 89 | * do_work_pending() will update this state if necessary. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | */ |
| 91 | ENTRY(ret_to_user) |
| 92 | ret_slow_syscall: |
Russell King | 3302cad | 2015-08-20 16:13:37 +0100 | [diff] [blame] | 93 | disable_irq_notrace @ disable interrupts |
Ming Lei | 9fc2552 | 2011-06-05 02:24:58 +0100 | [diff] [blame] | 94 | ENTRY(ret_to_user_from_irq) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 95 | ldr r1, [tsk, #TI_FLAGS] |
| 96 | tst r1, #_TIF_WORK_MASK |
Russell King | 3302cad | 2015-08-20 16:13:37 +0100 | [diff] [blame] | 97 | bne slow_work_pending |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 98 | no_work_pending: |
Russell King | 3302cad | 2015-08-20 16:13:37 +0100 | [diff] [blame] | 99 | asm_trace_hardirqs_on save = 0 |
Russell King | 651e949 | 2013-03-28 11:44:25 +0000 | [diff] [blame] | 100 | |
Dan Williams | f80dff9 | 2007-02-16 22:16:32 +0100 | [diff] [blame] | 101 | /* perform architecture specific actions before user return */ |
| 102 | arch_ret_to_user r1, lr |
Kevin Hilman | b008848 | 2013-03-28 22:54:40 +0100 | [diff] [blame] | 103 | ct_user_enter save = 0 |
Dan Williams | f80dff9 | 2007-02-16 22:16:32 +0100 | [diff] [blame] | 104 | |
Catalin Marinas | b86040a | 2009-07-24 12:32:54 +0100 | [diff] [blame] | 105 | restore_user_regs fast = 0, offset = 0 |
Ming Lei | 9fc2552 | 2011-06-05 02:24:58 +0100 | [diff] [blame] | 106 | ENDPROC(ret_to_user_from_irq) |
Catalin Marinas | 93ed397 | 2008-08-28 11:22:32 +0100 | [diff] [blame] | 107 | ENDPROC(ret_to_user) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 108 | |
| 109 | /* |
| 110 | * This is how we return from a fork. |
| 111 | */ |
| 112 | ENTRY(ret_from_fork) |
| 113 | bl schedule_tail |
Al Viro | 9fff2fa | 2012-10-10 22:23:29 -0400 | [diff] [blame] | 114 | cmp r5, #0 |
| 115 | movne r0, r4 |
Russell King | 14327c6 | 2015-04-21 14:17:25 +0100 | [diff] [blame] | 116 | badrne lr, 1f |
Russell King | 6ebbf2c | 2014-06-30 16:29:12 +0100 | [diff] [blame] | 117 | retne r5 |
Russell King | 68687c8 | 2012-10-15 00:16:49 +0100 | [diff] [blame] | 118 | 1: get_thread_info tsk |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 119 | b ret_slow_syscall |
Catalin Marinas | 93ed397 | 2008-08-28 11:22:32 +0100 | [diff] [blame] | 120 | ENDPROC(ret_from_fork) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 121 | |
Al Viro | fa1b4f9 | 2006-01-19 12:57:01 +0000 | [diff] [blame] | 122 | .equ NR_syscalls,0 |
| 123 | #define CALL(x) .equ NR_syscalls,NR_syscalls+1 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 124 | #include "calls.S" |
Wade Farnsworth | 1f66e06 | 2012-09-07 18:18:25 +0100 | [diff] [blame] | 125 | |
| 126 | /* |
| 127 | * Ensure that the system call table is equal to __NR_syscalls, |
| 128 | * which is the value the rest of the system sees |
| 129 | */ |
| 130 | .ifne NR_syscalls - __NR_syscalls |
| 131 | .error "__NR_syscalls is not equal to the size of the syscall table" |
| 132 | .endif |
| 133 | |
Al Viro | fa1b4f9 | 2006-01-19 12:57:01 +0000 | [diff] [blame] | 134 | #undef CALL |
| 135 | #define CALL(x) .long x |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 136 | |
| 137 | /*============================================================================= |
| 138 | * SWI handler |
| 139 | *----------------------------------------------------------------------------- |
| 140 | */ |
| 141 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 142 | .align 5 |
| 143 | ENTRY(vector_swi) |
Uwe Kleine-König | 19c4d59 | 2010-05-21 18:06:42 +0100 | [diff] [blame] | 144 | #ifdef CONFIG_CPU_V7M |
| 145 | v7m_exception_entry |
| 146 | #else |
Russell King | f4dc9a4 | 2005-04-26 15:20:34 +0100 | [diff] [blame] | 147 | sub sp, sp, #S_FRAME_SIZE |
| 148 | stmia sp, {r0 - r12} @ Calling r0 - r12 |
Catalin Marinas | b86040a | 2009-07-24 12:32:54 +0100 | [diff] [blame] | 149 | ARM( add r8, sp, #S_PC ) |
| 150 | ARM( stmdb r8, {sp, lr}^ ) @ Calling sp, lr |
| 151 | THUMB( mov r8, sp ) |
| 152 | THUMB( store_user_sp_lr r8, r10, S_SP ) @ calling sp, lr |
Russell King | f4dc9a4 | 2005-04-26 15:20:34 +0100 | [diff] [blame] | 153 | mrs r8, spsr @ called from non-FIQ mode, so ok. |
| 154 | str lr, [sp, #S_PC] @ Save calling PC |
| 155 | str r8, [sp, #S_PSR] @ Save CPSR |
| 156 | str r0, [sp, #S_OLD_R0] @ Save OLD_R0 |
Uwe Kleine-König | 19c4d59 | 2010-05-21 18:06:42 +0100 | [diff] [blame] | 157 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 158 | zero_fp |
Russell King | 195b58a | 2014-08-28 13:08:14 +0100 | [diff] [blame] | 159 | alignment_trap r10, ip, __cr_alignment |
Will Deacon | 1aa2b3b | 2013-06-05 11:25:13 +0100 | [diff] [blame] | 160 | enable_irq |
| 161 | ct_user_exit |
| 162 | get_thread_info tsk |
| 163 | |
Russell King | e0f9f4a | 2005-04-26 15:19:24 +0100 | [diff] [blame] | 164 | /* |
| 165 | * Get the system call number. |
| 166 | */ |
Nicolas Pitre | 3f2829a | 2006-01-14 16:31:29 +0000 | [diff] [blame] | 167 | |
Nicolas Pitre | dd35afc | 2006-01-14 16:36:12 +0000 | [diff] [blame] | 168 | #if defined(CONFIG_OABI_COMPAT) |
Nicolas Pitre | 3f2829a | 2006-01-14 16:31:29 +0000 | [diff] [blame] | 169 | |
Nicolas Pitre | dd35afc | 2006-01-14 16:36:12 +0000 | [diff] [blame] | 170 | /* |
| 171 | * If we have CONFIG_OABI_COMPAT then we need to look at the swi |
| 172 | * value to determine if it is an EABI or an old ABI call. |
| 173 | */ |
| 174 | #ifdef CONFIG_ARM_THUMB |
| 175 | tst r8, #PSR_T_BIT |
| 176 | movne r10, #0 @ no thumb OABI emulation |
Will Deacon | 1aa2b3b | 2013-06-05 11:25:13 +0100 | [diff] [blame] | 177 | USER( ldreq r10, [lr, #-4] ) @ get SWI instruction |
Nicolas Pitre | dd35afc | 2006-01-14 16:36:12 +0000 | [diff] [blame] | 178 | #else |
Will Deacon | 1aa2b3b | 2013-06-05 11:25:13 +0100 | [diff] [blame] | 179 | USER( ldr r10, [lr, #-4] ) @ get SWI instruction |
Nicolas Pitre | dd35afc | 2006-01-14 16:36:12 +0000 | [diff] [blame] | 180 | #endif |
Ben Dooks | 457c240 | 2013-02-12 18:59:57 +0000 | [diff] [blame] | 181 | ARM_BE8(rev r10, r10) @ little endian instruction |
Nicolas Pitre | dd35afc | 2006-01-14 16:36:12 +0000 | [diff] [blame] | 182 | |
| 183 | #elif defined(CONFIG_AEABI) |
| 184 | |
| 185 | /* |
| 186 | * Pure EABI user space always put syscall number into scno (r7). |
| 187 | */ |
Nicolas Pitre | 3f2829a | 2006-01-14 16:31:29 +0000 | [diff] [blame] | 188 | #elif defined(CONFIG_ARM_THUMB) |
Nicolas Pitre | dd35afc | 2006-01-14 16:36:12 +0000 | [diff] [blame] | 189 | /* Legacy ABI only, possibly thumb mode. */ |
Russell King | e0f9f4a | 2005-04-26 15:19:24 +0100 | [diff] [blame] | 190 | tst r8, #PSR_T_BIT @ this is SPSR from save_user_regs |
| 191 | addne scno, r7, #__NR_SYSCALL_BASE @ put OS number in |
Will Deacon | 1aa2b3b | 2013-06-05 11:25:13 +0100 | [diff] [blame] | 192 | USER( ldreq scno, [lr, #-4] ) |
Nicolas Pitre | dd35afc | 2006-01-14 16:36:12 +0000 | [diff] [blame] | 193 | |
Russell King | e0f9f4a | 2005-04-26 15:19:24 +0100 | [diff] [blame] | 194 | #else |
Nicolas Pitre | dd35afc | 2006-01-14 16:36:12 +0000 | [diff] [blame] | 195 | /* Legacy ABI only. */ |
Will Deacon | 1aa2b3b | 2013-06-05 11:25:13 +0100 | [diff] [blame] | 196 | USER( ldr scno, [lr, #-4] ) @ get SWI instruction |
Russell King | e0f9f4a | 2005-04-26 15:19:24 +0100 | [diff] [blame] | 197 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 198 | |
Nicolas Pitre | dd35afc | 2006-01-14 16:36:12 +0000 | [diff] [blame] | 199 | adr tbl, sys_call_table @ load syscall table pointer |
Nicolas Pitre | dd35afc | 2006-01-14 16:36:12 +0000 | [diff] [blame] | 200 | |
| 201 | #if defined(CONFIG_OABI_COMPAT) |
| 202 | /* |
| 203 | * If the swi argument is zero, this is an EABI call and we do nothing. |
| 204 | * |
| 205 | * If this is an old ABI call, get the syscall number into scno and |
| 206 | * get the old ABI syscall table address. |
| 207 | */ |
| 208 | bics r10, r10, #0xff000000 |
| 209 | eorne scno, r10, #__NR_OABI_SYSCALL_BASE |
| 210 | ldrne tbl, =sys_oabi_call_table |
| 211 | #elif !defined(CONFIG_AEABI) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 212 | bic scno, scno, #0xff000000 @ mask off SWI op-code |
Russell King | e0f9f4a | 2005-04-26 15:19:24 +0100 | [diff] [blame] | 213 | eor scno, scno, #__NR_SYSCALL_BASE @ check OS number |
Nicolas Pitre | 3f2829a | 2006-01-14 16:31:29 +0000 | [diff] [blame] | 214 | #endif |
Nicolas Pitre | dd35afc | 2006-01-14 16:36:12 +0000 | [diff] [blame] | 215 | |
Al Viro | 8178378 | 2012-07-19 17:48:21 +0100 | [diff] [blame] | 216 | local_restart: |
Nicolas Pitre | 70c70d9 | 2010-08-26 15:08:35 -0700 | [diff] [blame] | 217 | ldr r10, [tsk, #TI_FLAGS] @ check for syscall tracing |
Nicolas Pitre | 3f2829a | 2006-01-14 16:31:29 +0000 | [diff] [blame] | 218 | stmdb sp!, {r4, r5} @ push fifth and sixth args |
Nicolas Pitre | 70c70d9 | 2010-08-26 15:08:35 -0700 | [diff] [blame] | 219 | |
Nathaniel Husted | 29ef73b | 2012-01-03 14:23:09 -0500 | [diff] [blame] | 220 | tst r10, #_TIF_SYSCALL_WORK @ are we tracing syscalls? |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 221 | bne __sys_trace |
| 222 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 223 | cmp scno, #NR_syscalls @ check upper syscall limit |
Russell King | 14327c6 | 2015-04-21 14:17:25 +0100 | [diff] [blame] | 224 | badr lr, ret_fast_syscall @ return address |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 225 | ldrcc pc, [tbl, scno, lsl #2] @ call sys_* routine |
| 226 | |
| 227 | add r1, sp, #S_OFF |
Will Deacon | d95bc25 | 2013-09-19 10:32:20 +0100 | [diff] [blame] | 228 | 2: cmp scno, #(__ARM_NR_BASE - __NR_SYSCALL_BASE) |
Russell King | e0f9f4a | 2005-04-26 15:19:24 +0100 | [diff] [blame] | 229 | eor r0, scno, #__NR_SYSCALL_BASE @ put OS number back |
Will Deacon | 377747c | 2013-05-13 19:16:34 +0100 | [diff] [blame] | 230 | bcs arm_syscall |
Will Deacon | d95bc25 | 2013-09-19 10:32:20 +0100 | [diff] [blame] | 231 | mov why, #0 @ no longer a real syscall |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 232 | b sys_ni_syscall @ not private func |
Will Deacon | 1aa2b3b | 2013-06-05 11:25:13 +0100 | [diff] [blame] | 233 | |
| 234 | #if defined(CONFIG_OABI_COMPAT) || !defined(CONFIG_AEABI) |
| 235 | /* |
| 236 | * We failed to handle a fault trying to access the page |
| 237 | * containing the swi instruction, but we're not really in a |
| 238 | * position to return -EFAULT. Instead, return back to the |
| 239 | * instruction and re-enter the user fault handling path trying |
| 240 | * to page it in. This will likely result in sending SEGV to the |
| 241 | * current task. |
| 242 | */ |
| 243 | 9001: |
| 244 | sub lr, lr, #4 |
| 245 | str lr, [sp, #S_PC] |
| 246 | b ret_fast_syscall |
| 247 | #endif |
Catalin Marinas | 93ed397 | 2008-08-28 11:22:32 +0100 | [diff] [blame] | 248 | ENDPROC(vector_swi) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 249 | |
| 250 | /* |
| 251 | * This is the really slow path. We're going to be doing |
| 252 | * context switches, and waiting for our parent to respond. |
| 253 | */ |
| 254 | __sys_trace: |
Will Deacon | ad72254 | 2012-07-06 15:50:14 +0100 | [diff] [blame] | 255 | mov r1, scno |
| 256 | add r0, sp, #S_OFF |
| 257 | bl syscall_trace_enter |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 258 | |
Russell King | 14327c6 | 2015-04-21 14:17:25 +0100 | [diff] [blame] | 259 | badr lr, __sys_trace_return @ return address |
Nicolas Pitre | 3f47112 | 2006-01-14 19:30:04 +0000 | [diff] [blame] | 260 | mov scno, r0 @ syscall number (possibly new) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 261 | add r1, sp, #S_R0 + S_OFF @ pointer to regs |
| 262 | cmp scno, #NR_syscalls @ check upper syscall limit |
Will Deacon | c7aa00d | 2012-07-19 17:49:22 +0100 | [diff] [blame] | 263 | ldmccia r1, {r0 - r6} @ have to reload r0 - r6 |
| 264 | stmccia sp, {r4, r5} @ and update the stack args |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 265 | ldrcc pc, [tbl, scno, lsl #2] @ call sys_* routine |
Kees Cook | ad75b51 | 2012-11-15 22:12:17 +0100 | [diff] [blame] | 266 | cmp scno, #-1 @ skip the syscall? |
| 267 | bne 2b |
| 268 | add sp, sp, #S_OFF @ restore stack |
| 269 | b ret_slow_syscall |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 270 | |
| 271 | __sys_trace_return: |
| 272 | str r0, [sp, #S_R0 + S_OFF]! @ save returned r0 |
Will Deacon | ad72254 | 2012-07-06 15:50:14 +0100 | [diff] [blame] | 273 | mov r0, sp |
| 274 | bl syscall_trace_exit |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 275 | b ret_slow_syscall |
| 276 | |
Russell King | 3302cad | 2015-08-20 16:13:37 +0100 | [diff] [blame] | 277 | __sys_trace_return_nosave: |
Russell King | e0aa3a6 | 2015-08-20 17:39:32 +0100 | [diff] [blame^] | 278 | enable_irq_notrace |
Russell King | 3302cad | 2015-08-20 16:13:37 +0100 | [diff] [blame] | 279 | mov r0, sp |
| 280 | bl syscall_trace_exit |
| 281 | b ret_slow_syscall |
| 282 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 283 | .align 5 |
| 284 | #ifdef CONFIG_ALIGNMENT_TRAP |
| 285 | .type __cr_alignment, #object |
| 286 | __cr_alignment: |
| 287 | .word cr_alignment |
| 288 | #endif |
Nicolas Pitre | dd35afc | 2006-01-14 16:36:12 +0000 | [diff] [blame] | 289 | .ltorg |
| 290 | |
| 291 | /* |
| 292 | * This is the syscall table declaration for native ABI syscalls. |
| 293 | * With EABI a couple syscalls are obsolete and defined as sys_ni_syscall. |
| 294 | */ |
| 295 | #define ABI(native, compat) native |
| 296 | #ifdef CONFIG_AEABI |
| 297 | #define OBSOLETE(syscall) sys_ni_syscall |
| 298 | #else |
| 299 | #define OBSOLETE(syscall) syscall |
| 300 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 301 | |
| 302 | .type sys_call_table, #object |
| 303 | ENTRY(sys_call_table) |
| 304 | #include "calls.S" |
Nicolas Pitre | dd35afc | 2006-01-14 16:36:12 +0000 | [diff] [blame] | 305 | #undef ABI |
| 306 | #undef OBSOLETE |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 307 | |
| 308 | /*============================================================================ |
| 309 | * Special system call wrappers |
| 310 | */ |
| 311 | @ r0 = syscall number |
Russell King | 567bd98 | 2005-12-17 15:25:42 +0000 | [diff] [blame] | 312 | @ r8 = syscall table |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 313 | sys_syscall: |
Paul Brook | 5247593 | 2006-05-16 14:25:55 +0100 | [diff] [blame] | 314 | bic scno, r0, #__NR_OABI_SYSCALL_BASE |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 315 | cmp scno, #__NR_syscall - __NR_SYSCALL_BASE |
| 316 | cmpne scno, #NR_syscalls @ check range |
| 317 | stmloia sp, {r5, r6} @ shuffle args |
| 318 | movlo r0, r1 |
| 319 | movlo r1, r2 |
| 320 | movlo r2, r3 |
| 321 | movlo r3, r4 |
| 322 | ldrlo pc, [tbl, scno, lsl #2] |
| 323 | b sys_ni_syscall |
Catalin Marinas | 93ed397 | 2008-08-28 11:22:32 +0100 | [diff] [blame] | 324 | ENDPROC(sys_syscall) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 325 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 326 | sys_sigreturn_wrapper: |
| 327 | add r0, sp, #S_OFF |
Al Viro | 653d48b | 2010-09-17 14:34:39 +0100 | [diff] [blame] | 328 | mov why, #0 @ prevent syscall restart handling |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 329 | b sys_sigreturn |
Catalin Marinas | 93ed397 | 2008-08-28 11:22:32 +0100 | [diff] [blame] | 330 | ENDPROC(sys_sigreturn_wrapper) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 331 | |
| 332 | sys_rt_sigreturn_wrapper: |
| 333 | add r0, sp, #S_OFF |
Al Viro | 653d48b | 2010-09-17 14:34:39 +0100 | [diff] [blame] | 334 | mov why, #0 @ prevent syscall restart handling |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 335 | b sys_rt_sigreturn |
Catalin Marinas | 93ed397 | 2008-08-28 11:22:32 +0100 | [diff] [blame] | 336 | ENDPROC(sys_rt_sigreturn_wrapper) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 337 | |
Nicolas Pitre | 713c481 | 2006-01-14 16:35:03 +0000 | [diff] [blame] | 338 | sys_statfs64_wrapper: |
| 339 | teq r1, #88 |
| 340 | moveq r1, #84 |
| 341 | b sys_statfs64 |
Catalin Marinas | 93ed397 | 2008-08-28 11:22:32 +0100 | [diff] [blame] | 342 | ENDPROC(sys_statfs64_wrapper) |
Nicolas Pitre | 713c481 | 2006-01-14 16:35:03 +0000 | [diff] [blame] | 343 | |
| 344 | sys_fstatfs64_wrapper: |
| 345 | teq r1, #88 |
| 346 | moveq r1, #84 |
| 347 | b sys_fstatfs64 |
Catalin Marinas | 93ed397 | 2008-08-28 11:22:32 +0100 | [diff] [blame] | 348 | ENDPROC(sys_fstatfs64_wrapper) |
Nicolas Pitre | 713c481 | 2006-01-14 16:35:03 +0000 | [diff] [blame] | 349 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 350 | /* |
| 351 | * Note: off_4k (r5) is always units of 4K. If we can't do the requested |
| 352 | * offset, we return EINVAL. |
| 353 | */ |
| 354 | sys_mmap2: |
| 355 | #if PAGE_SHIFT > 12 |
| 356 | tst r5, #PGOFF_MASK |
| 357 | moveq r5, r5, lsr #PAGE_SHIFT - 12 |
| 358 | streq r5, [sp, #4] |
Al Viro | f8b7256 | 2009-11-30 17:37:04 -0500 | [diff] [blame] | 359 | beq sys_mmap_pgoff |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 360 | mov r0, #-EINVAL |
Russell King | 6ebbf2c | 2014-06-30 16:29:12 +0100 | [diff] [blame] | 361 | ret lr |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 362 | #else |
| 363 | str r5, [sp, #4] |
Al Viro | f8b7256 | 2009-11-30 17:37:04 -0500 | [diff] [blame] | 364 | b sys_mmap_pgoff |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 365 | #endif |
Catalin Marinas | 93ed397 | 2008-08-28 11:22:32 +0100 | [diff] [blame] | 366 | ENDPROC(sys_mmap2) |
Nicolas Pitre | 687ad01 | 2006-01-14 16:35:31 +0000 | [diff] [blame] | 367 | |
| 368 | #ifdef CONFIG_OABI_COMPAT |
Nicolas Pitre | dd35afc | 2006-01-14 16:36:12 +0000 | [diff] [blame] | 369 | |
Nicolas Pitre | 687ad01 | 2006-01-14 16:35:31 +0000 | [diff] [blame] | 370 | /* |
| 371 | * These are syscalls with argument register differences |
| 372 | */ |
| 373 | |
| 374 | sys_oabi_pread64: |
| 375 | stmia sp, {r3, r4} |
| 376 | b sys_pread64 |
Catalin Marinas | 93ed397 | 2008-08-28 11:22:32 +0100 | [diff] [blame] | 377 | ENDPROC(sys_oabi_pread64) |
Nicolas Pitre | 687ad01 | 2006-01-14 16:35:31 +0000 | [diff] [blame] | 378 | |
| 379 | sys_oabi_pwrite64: |
| 380 | stmia sp, {r3, r4} |
| 381 | b sys_pwrite64 |
Catalin Marinas | 93ed397 | 2008-08-28 11:22:32 +0100 | [diff] [blame] | 382 | ENDPROC(sys_oabi_pwrite64) |
Nicolas Pitre | 687ad01 | 2006-01-14 16:35:31 +0000 | [diff] [blame] | 383 | |
| 384 | sys_oabi_truncate64: |
| 385 | mov r3, r2 |
| 386 | mov r2, r1 |
| 387 | b sys_truncate64 |
Catalin Marinas | 93ed397 | 2008-08-28 11:22:32 +0100 | [diff] [blame] | 388 | ENDPROC(sys_oabi_truncate64) |
Nicolas Pitre | 687ad01 | 2006-01-14 16:35:31 +0000 | [diff] [blame] | 389 | |
| 390 | sys_oabi_ftruncate64: |
| 391 | mov r3, r2 |
| 392 | mov r2, r1 |
| 393 | b sys_ftruncate64 |
Catalin Marinas | 93ed397 | 2008-08-28 11:22:32 +0100 | [diff] [blame] | 394 | ENDPROC(sys_oabi_ftruncate64) |
Nicolas Pitre | 687ad01 | 2006-01-14 16:35:31 +0000 | [diff] [blame] | 395 | |
| 396 | sys_oabi_readahead: |
| 397 | str r3, [sp] |
| 398 | mov r3, r2 |
| 399 | mov r2, r1 |
| 400 | b sys_readahead |
Catalin Marinas | 93ed397 | 2008-08-28 11:22:32 +0100 | [diff] [blame] | 401 | ENDPROC(sys_oabi_readahead) |
Nicolas Pitre | 687ad01 | 2006-01-14 16:35:31 +0000 | [diff] [blame] | 402 | |
Nicolas Pitre | dd35afc | 2006-01-14 16:36:12 +0000 | [diff] [blame] | 403 | /* |
| 404 | * Let's declare a second syscall table for old ABI binaries |
| 405 | * using the compatibility syscall entries. |
| 406 | */ |
| 407 | #define ABI(native, compat) compat |
| 408 | #define OBSOLETE(syscall) syscall |
| 409 | |
| 410 | .type sys_oabi_call_table, #object |
| 411 | ENTRY(sys_oabi_call_table) |
| 412 | #include "calls.S" |
| 413 | #undef ABI |
| 414 | #undef OBSOLETE |
| 415 | |
Nicolas Pitre | 687ad01 | 2006-01-14 16:35:31 +0000 | [diff] [blame] | 416 | #endif |
| 417 | |