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