Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
2 | * Compatibility mode system call entry point for x86-64. | |
3 | * | |
4 | * Copyright 2000-2002 Andi Kleen, SuSE Labs. | |
5 | */ | |
6 | ||
7 | #include <asm/dwarf2.h> | |
8 | #include <asm/calling.h> | |
e2d5df93 | 9 | #include <asm/asm-offsets.h> |
1da177e4 LT |
10 | #include <asm/current.h> |
11 | #include <asm/errno.h> | |
12 | #include <asm/ia32_unistd.h> | |
13 | #include <asm/thread_info.h> | |
14 | #include <asm/segment.h> | |
2601e64d | 15 | #include <asm/irqflags.h> |
1da177e4 LT |
16 | #include <linux/linkage.h> |
17 | ||
5cbf1565 RM |
18 | /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */ |
19 | #include <linux/elf-em.h> | |
20 | #define AUDIT_ARCH_I386 (EM_386|__AUDIT_ARCH_LE) | |
21 | #define __AUDIT_ARCH_LE 0x40000000 | |
22 | ||
23 | #ifndef CONFIG_AUDITSYSCALL | |
24 | #define sysexit_audit int_ret_from_sys_call | |
25 | #define sysretl_audit int_ret_from_sys_call | |
26 | #endif | |
27 | ||
67d53ea5 AK |
28 | #define IA32_NR_syscalls ((ia32_syscall_end - ia32_sys_call_table)/8) |
29 | ||
1da177e4 LT |
30 | .macro IA32_ARG_FIXUP noebp=0 |
31 | movl %edi,%r8d | |
32 | .if \noebp | |
33 | .else | |
34 | movl %ebp,%r9d | |
35 | .endif | |
36 | xchg %ecx,%esi | |
37 | movl %ebx,%edi | |
38 | movl %edx,%edx /* zero extension */ | |
39 | .endm | |
40 | ||
41 | /* clobbers %eax */ | |
42 | .macro CLEAR_RREGS | |
43 | xorl %eax,%eax | |
44 | movq %rax,R11(%rsp) | |
45 | movq %rax,R10(%rsp) | |
46 | movq %rax,R9(%rsp) | |
47 | movq %rax,R8(%rsp) | |
48 | .endm | |
49 | ||
d4d67150 RM |
50 | /* |
51 | * Reload arg registers from stack in case ptrace changed them. | |
52 | * We don't reload %eax because syscall_trace_enter() returned | |
53 | * the value it wants us to use in the table lookup. | |
54 | */ | |
176df245 AK |
55 | .macro LOAD_ARGS32 offset |
56 | movl \offset(%rsp),%r11d | |
57 | movl \offset+8(%rsp),%r10d | |
58 | movl \offset+16(%rsp),%r9d | |
59 | movl \offset+24(%rsp),%r8d | |
60 | movl \offset+40(%rsp),%ecx | |
61 | movl \offset+48(%rsp),%edx | |
62 | movl \offset+56(%rsp),%esi | |
63 | movl \offset+64(%rsp),%edi | |
176df245 AK |
64 | .endm |
65 | ||
2765130b JB |
66 | .macro CFI_STARTPROC32 simple |
67 | CFI_STARTPROC \simple | |
68 | CFI_UNDEFINED r8 | |
69 | CFI_UNDEFINED r9 | |
70 | CFI_UNDEFINED r10 | |
71 | CFI_UNDEFINED r11 | |
72 | CFI_UNDEFINED r12 | |
73 | CFI_UNDEFINED r13 | |
74 | CFI_UNDEFINED r14 | |
75 | CFI_UNDEFINED r15 | |
76 | .endm | |
77 | ||
2be29982 JF |
78 | #ifdef CONFIG_PARAVIRT |
79 | ENTRY(native_usergs_sysret32) | |
80 | swapgs | |
81 | sysretl | |
82 | ENDPROC(native_usergs_sysret32) | |
83 | ||
84 | ENTRY(native_irq_enable_sysexit) | |
85 | swapgs | |
86 | sti | |
87 | sysexit | |
88 | ENDPROC(native_irq_enable_sysexit) | |
89 | #endif | |
90 | ||
1da177e4 LT |
91 | /* |
92 | * 32bit SYSENTER instruction entry. | |
93 | * | |
94 | * Arguments: | |
95 | * %eax System call number. | |
96 | * %ebx Arg1 | |
97 | * %ecx Arg2 | |
98 | * %edx Arg3 | |
99 | * %esi Arg4 | |
100 | * %edi Arg5 | |
101 | * %ebp user stack | |
102 | * 0(%ebp) Arg6 | |
103 | * | |
104 | * Interrupts off. | |
105 | * | |
106 | * This is purely a fast path. For anything complicated we use the int 0x80 | |
107 | * path below. Set up a complete hardware stack frame to share code | |
108 | * with the int 0x80 path. | |
109 | */ | |
110 | ENTRY(ia32_sysenter_target) | |
2765130b | 111 | CFI_STARTPROC32 simple |
adf14236 | 112 | CFI_SIGNAL_FRAME |
7effaa88 JB |
113 | CFI_DEF_CFA rsp,0 |
114 | CFI_REGISTER rsp,rbp | |
457da70e | 115 | SWAPGS_UNSAFE_STACK |
1da177e4 LT |
116 | movq %gs:pda_kernelstack, %rsp |
117 | addq $(PDA_STACKOFFSET),%rsp | |
2601e64d IM |
118 | /* |
119 | * No need to follow this irqs on/off section: the syscall | |
120 | * disabled irqs, here we enable it straight after entry: | |
121 | */ | |
66804154 | 122 | ENABLE_INTERRUPTS(CLBR_NONE) |
1da177e4 LT |
123 | movl %ebp,%ebp /* zero extension */ |
124 | pushq $__USER32_DS | |
7effaa88 JB |
125 | CFI_ADJUST_CFA_OFFSET 8 |
126 | /*CFI_REL_OFFSET ss,0*/ | |
1da177e4 | 127 | pushq %rbp |
7effaa88 JB |
128 | CFI_ADJUST_CFA_OFFSET 8 |
129 | CFI_REL_OFFSET rsp,0 | |
1da177e4 | 130 | pushfq |
7effaa88 JB |
131 | CFI_ADJUST_CFA_OFFSET 8 |
132 | /*CFI_REL_OFFSET rflags,0*/ | |
26ccb8a7 | 133 | movl 8*3-THREAD_SIZE+TI_sysenter_return(%rsp), %r10d |
7effaa88 | 134 | CFI_REGISTER rip,r10 |
1da177e4 | 135 | pushq $__USER32_CS |
7effaa88 JB |
136 | CFI_ADJUST_CFA_OFFSET 8 |
137 | /*CFI_REL_OFFSET cs,0*/ | |
1da177e4 LT |
138 | movl %eax, %eax |
139 | pushq %r10 | |
7effaa88 JB |
140 | CFI_ADJUST_CFA_OFFSET 8 |
141 | CFI_REL_OFFSET rip,0 | |
1da177e4 | 142 | pushq %rax |
7effaa88 | 143 | CFI_ADJUST_CFA_OFFSET 8 |
1da177e4 | 144 | cld |
cdc1793e | 145 | SAVE_ARGS 0,0,1 |
1da177e4 LT |
146 | /* no need to do an access_ok check here because rbp has been |
147 | 32bit zero extended */ | |
148 | 1: movl (%rbp),%r9d | |
149 | .section __ex_table,"a" | |
150 | .quad 1b,ia32_badarg | |
151 | .previous | |
152 | GET_THREAD_INFO(%r10) | |
26ccb8a7 | 153 | orl $TS_COMPAT,TI_status(%r10) |
d4d67150 | 154 | testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r10) |
7effaa88 | 155 | CFI_REMEMBER_STATE |
1da177e4 | 156 | jnz sysenter_tracesys |
67d53ea5 AK |
157 | cmpl $(IA32_NR_syscalls-1),%eax |
158 | ja ia32_badsys | |
d4d67150 | 159 | sysenter_do_call: |
1da177e4 | 160 | IA32_ARG_FIXUP 1 |
5cbf1565 | 161 | sysenter_dispatch: |
1da177e4 LT |
162 | call *ia32_sys_call_table(,%rax,8) |
163 | movq %rax,RAX-ARGOFFSET(%rsp) | |
164 | GET_THREAD_INFO(%r10) | |
66804154 | 165 | DISABLE_INTERRUPTS(CLBR_NONE) |
2601e64d | 166 | TRACE_IRQS_OFF |
26ccb8a7 | 167 | testl $_TIF_ALLWORK_MASK,TI_flags(%r10) |
5cbf1565 RM |
168 | jnz sysexit_audit |
169 | sysexit_from_sys_call: | |
26ccb8a7 | 170 | andl $~TS_COMPAT,TI_status(%r10) |
1da177e4 LT |
171 | /* clear IF, that popfq doesn't enable interrupts early */ |
172 | andl $~0x200,EFLAGS-R11(%rsp) | |
36197c92 RM |
173 | movl RIP-R11(%rsp),%edx /* User %eip */ |
174 | CFI_REGISTER rip,rdx | |
1da177e4 LT |
175 | RESTORE_ARGS 1,24,1,1,1,1 |
176 | popfq | |
7effaa88 JB |
177 | CFI_ADJUST_CFA_OFFSET -8 |
178 | /*CFI_RESTORE rflags*/ | |
1da177e4 | 179 | popq %rcx /* User %esp */ |
7effaa88 JB |
180 | CFI_ADJUST_CFA_OFFSET -8 |
181 | CFI_REGISTER rsp,rcx | |
2601e64d | 182 | TRACE_IRQS_ON |
2be29982 | 183 | ENABLE_INTERRUPTS_SYSEXIT32 |
1da177e4 | 184 | |
5cbf1565 RM |
185 | #ifdef CONFIG_AUDITSYSCALL |
186 | .macro auditsys_entry_common | |
187 | movl %esi,%r9d /* 6th arg: 4th syscall arg */ | |
188 | movl %edx,%r8d /* 5th arg: 3rd syscall arg */ | |
189 | /* (already in %ecx) 4th arg: 2nd syscall arg */ | |
190 | movl %ebx,%edx /* 3rd arg: 1st syscall arg */ | |
191 | movl %eax,%esi /* 2nd arg: syscall number */ | |
192 | movl $AUDIT_ARCH_I386,%edi /* 1st arg: audit arch */ | |
193 | call audit_syscall_entry | |
194 | movl RAX-ARGOFFSET(%rsp),%eax /* reload syscall number */ | |
195 | cmpl $(IA32_NR_syscalls-1),%eax | |
196 | ja ia32_badsys | |
197 | movl %ebx,%edi /* reload 1st syscall arg */ | |
198 | movl RCX-ARGOFFSET(%rsp),%esi /* reload 2nd syscall arg */ | |
199 | movl RDX-ARGOFFSET(%rsp),%edx /* reload 3rd syscall arg */ | |
200 | movl RSI-ARGOFFSET(%rsp),%ecx /* reload 4th syscall arg */ | |
201 | movl RDI-ARGOFFSET(%rsp),%r8d /* reload 5th syscall arg */ | |
202 | .endm | |
203 | ||
204 | .macro auditsys_exit exit | |
205 | testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags(%r10) | |
206 | jnz int_ret_from_sys_call | |
207 | TRACE_IRQS_ON | |
208 | sti | |
209 | movl %eax,%esi /* second arg, syscall return value */ | |
210 | cmpl $0,%eax /* is it < 0? */ | |
211 | setl %al /* 1 if so, 0 if not */ | |
212 | movzbl %al,%edi /* zero-extend that into %edi */ | |
213 | inc %edi /* first arg, 0->1(AUDITSC_SUCCESS), 1->2(AUDITSC_FAILURE) */ | |
214 | call audit_syscall_exit | |
215 | GET_THREAD_INFO(%r10) | |
216 | movl RAX-ARGOFFSET(%rsp),%eax /* reload syscall return value */ | |
217 | movl RBP-ARGOFFSET(%rsp),%ebp /* reload user register value */ | |
218 | movl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),%edi | |
219 | cli | |
220 | TRACE_IRQS_OFF | |
221 | testl %edi,TI_flags(%r10) | |
222 | jnz int_with_check | |
223 | jmp \exit | |
224 | .endm | |
225 | ||
226 | sysenter_auditsys: | |
7effaa88 | 227 | CFI_RESTORE_STATE |
5cbf1565 RM |
228 | auditsys_entry_common |
229 | movl %ebp,%r9d /* reload 6th syscall arg */ | |
230 | jmp sysenter_dispatch | |
231 | ||
232 | sysexit_audit: | |
233 | auditsys_exit sysexit_from_sys_call | |
234 | #endif | |
235 | ||
236 | sysenter_tracesys: | |
ecd744ee | 237 | xchgl %r9d,%ebp |
5cbf1565 RM |
238 | #ifdef CONFIG_AUDITSYSCALL |
239 | testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r10) | |
240 | jz sysenter_auditsys | |
241 | #endif | |
1da177e4 LT |
242 | SAVE_REST |
243 | CLEAR_RREGS | |
ecd744ee | 244 | movq %r9,R9(%rsp) |
48ee679a | 245 | movq $-ENOSYS,RAX(%rsp)/* ptrace can change this for a bad syscall */ |
1da177e4 LT |
246 | movq %rsp,%rdi /* &pt_regs -> arg1 */ |
247 | call syscall_trace_enter | |
176df245 | 248 | LOAD_ARGS32 ARGOFFSET /* reload args from stack in case ptrace changed it */ |
1da177e4 | 249 | RESTORE_REST |
ecd744ee | 250 | xchgl %ebp,%r9d |
48ee679a RM |
251 | cmpl $(IA32_NR_syscalls-1),%eax |
252 | ja int_ret_from_sys_call /* sysenter_tracesys has set RAX(%rsp) */ | |
1da177e4 LT |
253 | jmp sysenter_do_call |
254 | CFI_ENDPROC | |
4b787e0b | 255 | ENDPROC(ia32_sysenter_target) |
1da177e4 LT |
256 | |
257 | /* | |
258 | * 32bit SYSCALL instruction entry. | |
259 | * | |
260 | * Arguments: | |
261 | * %eax System call number. | |
262 | * %ebx Arg1 | |
263 | * %ecx return EIP | |
264 | * %edx Arg3 | |
265 | * %esi Arg4 | |
266 | * %edi Arg5 | |
267 | * %ebp Arg2 [note: not saved in the stack frame, should not be touched] | |
268 | * %esp user stack | |
269 | * 0(%esp) Arg6 | |
270 | * | |
271 | * Interrupts off. | |
272 | * | |
273 | * This is purely a fast path. For anything complicated we use the int 0x80 | |
274 | * path below. Set up a complete hardware stack frame to share code | |
275 | * with the int 0x80 path. | |
276 | */ | |
277 | ENTRY(ia32_cstar_target) | |
2765130b | 278 | CFI_STARTPROC32 simple |
adf14236 | 279 | CFI_SIGNAL_FRAME |
dffead4e | 280 | CFI_DEF_CFA rsp,PDA_STACKOFFSET |
7effaa88 JB |
281 | CFI_REGISTER rip,rcx |
282 | /*CFI_REGISTER rflags,r11*/ | |
457da70e | 283 | SWAPGS_UNSAFE_STACK |
1da177e4 | 284 | movl %esp,%r8d |
7effaa88 | 285 | CFI_REGISTER rsp,r8 |
1da177e4 | 286 | movq %gs:pda_kernelstack,%rsp |
2601e64d IM |
287 | /* |
288 | * No need to follow this irqs on/off section: the syscall | |
289 | * disabled irqs and here we enable it straight after entry: | |
290 | */ | |
66804154 | 291 | ENABLE_INTERRUPTS(CLBR_NONE) |
1da177e4 LT |
292 | SAVE_ARGS 8,1,1 |
293 | movl %eax,%eax /* zero extension */ | |
294 | movq %rax,ORIG_RAX-ARGOFFSET(%rsp) | |
295 | movq %rcx,RIP-ARGOFFSET(%rsp) | |
7effaa88 | 296 | CFI_REL_OFFSET rip,RIP-ARGOFFSET |
1da177e4 LT |
297 | movq %rbp,RCX-ARGOFFSET(%rsp) /* this lies slightly to ptrace */ |
298 | movl %ebp,%ecx | |
299 | movq $__USER32_CS,CS-ARGOFFSET(%rsp) | |
300 | movq $__USER32_DS,SS-ARGOFFSET(%rsp) | |
301 | movq %r11,EFLAGS-ARGOFFSET(%rsp) | |
7effaa88 | 302 | /*CFI_REL_OFFSET rflags,EFLAGS-ARGOFFSET*/ |
1da177e4 | 303 | movq %r8,RSP-ARGOFFSET(%rsp) |
7effaa88 | 304 | CFI_REL_OFFSET rsp,RSP-ARGOFFSET |
1da177e4 LT |
305 | /* no need to do an access_ok check here because r8 has been |
306 | 32bit zero extended */ | |
307 | /* hardware stack frame is complete now */ | |
308 | 1: movl (%r8),%r9d | |
309 | .section __ex_table,"a" | |
310 | .quad 1b,ia32_badarg | |
311 | .previous | |
312 | GET_THREAD_INFO(%r10) | |
26ccb8a7 | 313 | orl $TS_COMPAT,TI_status(%r10) |
d4d67150 | 314 | testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r10) |
7effaa88 | 315 | CFI_REMEMBER_STATE |
1da177e4 LT |
316 | jnz cstar_tracesys |
317 | cstar_do_call: | |
67d53ea5 AK |
318 | cmpl $IA32_NR_syscalls-1,%eax |
319 | ja ia32_badsys | |
1da177e4 | 320 | IA32_ARG_FIXUP 1 |
5cbf1565 | 321 | cstar_dispatch: |
1da177e4 LT |
322 | call *ia32_sys_call_table(,%rax,8) |
323 | movq %rax,RAX-ARGOFFSET(%rsp) | |
324 | GET_THREAD_INFO(%r10) | |
66804154 | 325 | DISABLE_INTERRUPTS(CLBR_NONE) |
2601e64d | 326 | TRACE_IRQS_OFF |
26ccb8a7 | 327 | testl $_TIF_ALLWORK_MASK,TI_flags(%r10) |
5cbf1565 RM |
328 | jnz sysretl_audit |
329 | sysretl_from_sys_call: | |
26ccb8a7 | 330 | andl $~TS_COMPAT,TI_status(%r10) |
1da177e4 LT |
331 | RESTORE_ARGS 1,-ARG_SKIP,1,1,1 |
332 | movl RIP-ARGOFFSET(%rsp),%ecx | |
7effaa88 | 333 | CFI_REGISTER rip,rcx |
1da177e4 | 334 | movl EFLAGS-ARGOFFSET(%rsp),%r11d |
7effaa88 | 335 | /*CFI_REGISTER rflags,r11*/ |
2601e64d | 336 | TRACE_IRQS_ON |
1da177e4 | 337 | movl RSP-ARGOFFSET(%rsp),%esp |
7effaa88 | 338 | CFI_RESTORE rsp |
2be29982 | 339 | USERGS_SYSRET32 |
1da177e4 | 340 | |
5cbf1565 RM |
341 | #ifdef CONFIG_AUDITSYSCALL |
342 | cstar_auditsys: | |
7effaa88 | 343 | CFI_RESTORE_STATE |
5cbf1565 RM |
344 | movl %r9d,R9-ARGOFFSET(%rsp) /* register to be clobbered by call */ |
345 | auditsys_entry_common | |
346 | movl R9-ARGOFFSET(%rsp),%r9d /* reload 6th syscall arg */ | |
347 | jmp cstar_dispatch | |
348 | ||
349 | sysretl_audit: | |
350 | auditsys_exit sysretl_from_sys_call | |
351 | #endif | |
352 | ||
353 | cstar_tracesys: | |
354 | #ifdef CONFIG_AUDITSYSCALL | |
355 | testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r10) | |
356 | jz cstar_auditsys | |
357 | #endif | |
ecd744ee | 358 | xchgl %r9d,%ebp |
1da177e4 LT |
359 | SAVE_REST |
360 | CLEAR_RREGS | |
ecd744ee | 361 | movq %r9,R9(%rsp) |
48ee679a | 362 | movq $-ENOSYS,RAX(%rsp) /* ptrace can change this for a bad syscall */ |
1da177e4 LT |
363 | movq %rsp,%rdi /* &pt_regs -> arg1 */ |
364 | call syscall_trace_enter | |
176df245 | 365 | LOAD_ARGS32 ARGOFFSET /* reload args from stack in case ptrace changed it */ |
1da177e4 | 366 | RESTORE_REST |
ecd744ee | 367 | xchgl %ebp,%r9d |
1da177e4 | 368 | movl RSP-ARGOFFSET(%rsp), %r8d |
48ee679a RM |
369 | cmpl $(IA32_NR_syscalls-1),%eax |
370 | ja int_ret_from_sys_call /* cstar_tracesys has set RAX(%rsp) */ | |
1da177e4 | 371 | jmp cstar_do_call |
4b787e0b | 372 | END(ia32_cstar_target) |
1da177e4 LT |
373 | |
374 | ia32_badarg: | |
375 | movq $-EFAULT,%rax | |
376 | jmp ia32_sysret | |
377 | CFI_ENDPROC | |
378 | ||
379 | /* | |
380 | * Emulated IA32 system calls via int 0x80. | |
381 | * | |
382 | * Arguments: | |
383 | * %eax System call number. | |
384 | * %ebx Arg1 | |
385 | * %ecx Arg2 | |
386 | * %edx Arg3 | |
387 | * %esi Arg4 | |
388 | * %edi Arg5 | |
389 | * %ebp Arg6 [note: not saved in the stack frame, should not be touched] | |
390 | * | |
391 | * Notes: | |
392 | * Uses the same stack frame as the x86-64 version. | |
393 | * All registers except %eax must be saved (but ptrace may violate that) | |
394 | * Arguments are zero extended. For system calls that want sign extension and | |
395 | * take long arguments a wrapper is needed. Most calls can just be called | |
396 | * directly. | |
397 | * Assumes it is only called from user space and entered with interrupts off. | |
398 | */ | |
399 | ||
400 | ENTRY(ia32_syscall) | |
cdc1793e | 401 | CFI_STARTPROC32 simple |
adf14236 | 402 | CFI_SIGNAL_FRAME |
7effaa88 JB |
403 | CFI_DEF_CFA rsp,SS+8-RIP |
404 | /*CFI_REL_OFFSET ss,SS-RIP*/ | |
405 | CFI_REL_OFFSET rsp,RSP-RIP | |
406 | /*CFI_REL_OFFSET rflags,EFLAGS-RIP*/ | |
407 | /*CFI_REL_OFFSET cs,CS-RIP*/ | |
408 | CFI_REL_OFFSET rip,RIP-RIP | |
360c044e | 409 | PARAVIRT_ADJUST_EXCEPTION_FRAME |
66804154 | 410 | SWAPGS |
2601e64d IM |
411 | /* |
412 | * No need to follow this irqs on/off section: the syscall | |
413 | * disabled irqs and here we enable it straight after entry: | |
414 | */ | |
66804154 | 415 | ENABLE_INTERRUPTS(CLBR_NONE) |
1da177e4 LT |
416 | movl %eax,%eax |
417 | pushq %rax | |
7effaa88 | 418 | CFI_ADJUST_CFA_OFFSET 8 |
1da177e4 LT |
419 | cld |
420 | /* note the registers are not zero extended to the sf. | |
421 | this could be a problem. */ | |
422 | SAVE_ARGS 0,0,1 | |
423 | GET_THREAD_INFO(%r10) | |
26ccb8a7 | 424 | orl $TS_COMPAT,TI_status(%r10) |
d4d67150 | 425 | testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r10) |
1da177e4 LT |
426 | jnz ia32_tracesys |
427 | ia32_do_syscall: | |
67d53ea5 | 428 | cmpl $(IA32_NR_syscalls-1),%eax |
8ab32bb8 | 429 | ja int_ret_from_sys_call /* ia32_tracesys has set RAX(%rsp) */ |
1da177e4 LT |
430 | IA32_ARG_FIXUP |
431 | call *ia32_sys_call_table(,%rax,8) # xxx: rip relative | |
432 | ia32_sysret: | |
433 | movq %rax,RAX-ARGOFFSET(%rsp) | |
434 | jmp int_ret_from_sys_call | |
435 | ||
436 | ia32_tracesys: | |
437 | SAVE_REST | |
cdc1793e | 438 | CLEAR_RREGS |
8ab32bb8 | 439 | movq $-ENOSYS,RAX(%rsp) /* ptrace can change this for a bad syscall */ |
1da177e4 LT |
440 | movq %rsp,%rdi /* &pt_regs -> arg1 */ |
441 | call syscall_trace_enter | |
176df245 | 442 | LOAD_ARGS32 ARGOFFSET /* reload args from stack in case ptrace changed it */ |
1da177e4 LT |
443 | RESTORE_REST |
444 | jmp ia32_do_syscall | |
4b787e0b | 445 | END(ia32_syscall) |
1da177e4 LT |
446 | |
447 | ia32_badsys: | |
448 | movq $0,ORIG_RAX-ARGOFFSET(%rsp) | |
449 | movq $-ENOSYS,RAX-ARGOFFSET(%rsp) | |
450 | jmp int_ret_from_sys_call | |
451 | ||
1da177e4 LT |
452 | quiet_ni_syscall: |
453 | movq $-ENOSYS,%rax | |
454 | ret | |
455 | CFI_ENDPROC | |
456 | ||
457 | .macro PTREGSCALL label, func, arg | |
458 | .globl \label | |
459 | \label: | |
460 | leaq \func(%rip),%rax | |
461 | leaq -ARGOFFSET+8(%rsp),\arg /* 8 for return address */ | |
462 | jmp ia32_ptregs_common | |
463 | .endm | |
464 | ||
2765130b | 465 | CFI_STARTPROC32 |
7effaa88 | 466 | |
1da177e4 LT |
467 | PTREGSCALL stub32_rt_sigreturn, sys32_rt_sigreturn, %rdi |
468 | PTREGSCALL stub32_sigreturn, sys32_sigreturn, %rdi | |
469 | PTREGSCALL stub32_sigaltstack, sys32_sigaltstack, %rdx | |
1da177e4 LT |
470 | PTREGSCALL stub32_execve, sys32_execve, %rcx |
471 | PTREGSCALL stub32_fork, sys_fork, %rdi | |
472 | PTREGSCALL stub32_clone, sys32_clone, %rdx | |
473 | PTREGSCALL stub32_vfork, sys_vfork, %rdi | |
474 | PTREGSCALL stub32_iopl, sys_iopl, %rsi | |
1da177e4 LT |
475 | |
476 | ENTRY(ia32_ptregs_common) | |
1da177e4 | 477 | popq %r11 |
2765130b JB |
478 | CFI_ENDPROC |
479 | CFI_STARTPROC32 simple | |
adf14236 | 480 | CFI_SIGNAL_FRAME |
2765130b JB |
481 | CFI_DEF_CFA rsp,SS+8-ARGOFFSET |
482 | CFI_REL_OFFSET rax,RAX-ARGOFFSET | |
483 | CFI_REL_OFFSET rcx,RCX-ARGOFFSET | |
484 | CFI_REL_OFFSET rdx,RDX-ARGOFFSET | |
485 | CFI_REL_OFFSET rsi,RSI-ARGOFFSET | |
486 | CFI_REL_OFFSET rdi,RDI-ARGOFFSET | |
487 | CFI_REL_OFFSET rip,RIP-ARGOFFSET | |
488 | /* CFI_REL_OFFSET cs,CS-ARGOFFSET*/ | |
489 | /* CFI_REL_OFFSET rflags,EFLAGS-ARGOFFSET*/ | |
490 | CFI_REL_OFFSET rsp,RSP-ARGOFFSET | |
491 | /* CFI_REL_OFFSET ss,SS-ARGOFFSET*/ | |
1da177e4 LT |
492 | SAVE_REST |
493 | call *%rax | |
494 | RESTORE_REST | |
495 | jmp ia32_sysret /* misbalances the return cache */ | |
496 | CFI_ENDPROC | |
4b787e0b | 497 | END(ia32_ptregs_common) |
1da177e4 | 498 | |
bb152f53 | 499 | .section .rodata,"a" |
1da177e4 | 500 | .align 8 |
1da177e4 LT |
501 | ia32_sys_call_table: |
502 | .quad sys_restart_syscall | |
503 | .quad sys_exit | |
504 | .quad stub32_fork | |
505 | .quad sys_read | |
506 | .quad sys_write | |
e922efc3 | 507 | .quad compat_sys_open /* 5 */ |
1da177e4 LT |
508 | .quad sys_close |
509 | .quad sys32_waitpid | |
510 | .quad sys_creat | |
511 | .quad sys_link | |
512 | .quad sys_unlink /* 10 */ | |
513 | .quad stub32_execve | |
514 | .quad sys_chdir | |
515 | .quad compat_sys_time | |
516 | .quad sys_mknod | |
517 | .quad sys_chmod /* 15 */ | |
518 | .quad sys_lchown16 | |
519 | .quad quiet_ni_syscall /* old break syscall holder */ | |
520 | .quad sys_stat | |
521 | .quad sys32_lseek | |
522 | .quad sys_getpid /* 20 */ | |
523 | .quad compat_sys_mount /* mount */ | |
524 | .quad sys_oldumount /* old_umount */ | |
525 | .quad sys_setuid16 | |
526 | .quad sys_getuid16 | |
527 | .quad compat_sys_stime /* stime */ /* 25 */ | |
562b80ba | 528 | .quad compat_sys_ptrace /* ptrace */ |
1da177e4 LT |
529 | .quad sys_alarm |
530 | .quad sys_fstat /* (old)fstat */ | |
531 | .quad sys_pause | |
532 | .quad compat_sys_utime /* 30 */ | |
533 | .quad quiet_ni_syscall /* old stty syscall holder */ | |
534 | .quad quiet_ni_syscall /* old gtty syscall holder */ | |
535 | .quad sys_access | |
536 | .quad sys_nice | |
537 | .quad quiet_ni_syscall /* 35 */ /* old ftime syscall holder */ | |
538 | .quad sys_sync | |
539 | .quad sys32_kill | |
540 | .quad sys_rename | |
541 | .quad sys_mkdir | |
542 | .quad sys_rmdir /* 40 */ | |
543 | .quad sys_dup | |
544 | .quad sys32_pipe | |
545 | .quad compat_sys_times | |
546 | .quad quiet_ni_syscall /* old prof syscall holder */ | |
547 | .quad sys_brk /* 45 */ | |
548 | .quad sys_setgid16 | |
549 | .quad sys_getgid16 | |
550 | .quad sys_signal | |
551 | .quad sys_geteuid16 | |
552 | .quad sys_getegid16 /* 50 */ | |
553 | .quad sys_acct | |
554 | .quad sys_umount /* new_umount */ | |
555 | .quad quiet_ni_syscall /* old lock syscall holder */ | |
556 | .quad compat_sys_ioctl | |
557 | .quad compat_sys_fcntl64 /* 55 */ | |
558 | .quad quiet_ni_syscall /* old mpx syscall holder */ | |
559 | .quad sys_setpgid | |
560 | .quad quiet_ni_syscall /* old ulimit syscall holder */ | |
561 | .quad sys32_olduname | |
562 | .quad sys_umask /* 60 */ | |
563 | .quad sys_chroot | |
564 | .quad sys32_ustat | |
565 | .quad sys_dup2 | |
566 | .quad sys_getppid | |
567 | .quad sys_getpgrp /* 65 */ | |
568 | .quad sys_setsid | |
569 | .quad sys32_sigaction | |
570 | .quad sys_sgetmask | |
571 | .quad sys_ssetmask | |
572 | .quad sys_setreuid16 /* 70 */ | |
573 | .quad sys_setregid16 | |
5f0120b5 | 574 | .quad sys32_sigsuspend |
1da177e4 LT |
575 | .quad compat_sys_sigpending |
576 | .quad sys_sethostname | |
577 | .quad compat_sys_setrlimit /* 75 */ | |
578 | .quad compat_sys_old_getrlimit /* old_getrlimit */ | |
579 | .quad compat_sys_getrusage | |
580 | .quad sys32_gettimeofday | |
581 | .quad sys32_settimeofday | |
582 | .quad sys_getgroups16 /* 80 */ | |
583 | .quad sys_setgroups16 | |
584 | .quad sys32_old_select | |
585 | .quad sys_symlink | |
586 | .quad sys_lstat | |
587 | .quad sys_readlink /* 85 */ | |
1da177e4 | 588 | .quad sys_uselib |
1da177e4 LT |
589 | .quad sys_swapon |
590 | .quad sys_reboot | |
591 | .quad compat_sys_old_readdir | |
592 | .quad sys32_mmap /* 90 */ | |
593 | .quad sys_munmap | |
594 | .quad sys_truncate | |
595 | .quad sys_ftruncate | |
596 | .quad sys_fchmod | |
597 | .quad sys_fchown16 /* 95 */ | |
598 | .quad sys_getpriority | |
599 | .quad sys_setpriority | |
600 | .quad quiet_ni_syscall /* old profil syscall holder */ | |
601 | .quad compat_sys_statfs | |
602 | .quad compat_sys_fstatfs /* 100 */ | |
603 | .quad sys_ioperm | |
604 | .quad compat_sys_socketcall | |
605 | .quad sys_syslog | |
606 | .quad compat_sys_setitimer | |
607 | .quad compat_sys_getitimer /* 105 */ | |
608 | .quad compat_sys_newstat | |
609 | .quad compat_sys_newlstat | |
610 | .quad compat_sys_newfstat | |
611 | .quad sys32_uname | |
612 | .quad stub32_iopl /* 110 */ | |
613 | .quad sys_vhangup | |
614 | .quad quiet_ni_syscall /* old "idle" system call */ | |
615 | .quad sys32_vm86_warning /* vm86old */ | |
616 | .quad compat_sys_wait4 | |
617 | .quad sys_swapoff /* 115 */ | |
d4d23add | 618 | .quad compat_sys_sysinfo |
1da177e4 LT |
619 | .quad sys32_ipc |
620 | .quad sys_fsync | |
621 | .quad stub32_sigreturn | |
622 | .quad stub32_clone /* 120 */ | |
623 | .quad sys_setdomainname | |
624 | .quad sys_uname | |
625 | .quad sys_modify_ldt | |
3158e941 | 626 | .quad compat_sys_adjtimex |
1da177e4 LT |
627 | .quad sys32_mprotect /* 125 */ |
628 | .quad compat_sys_sigprocmask | |
629 | .quad quiet_ni_syscall /* create_module */ | |
630 | .quad sys_init_module | |
631 | .quad sys_delete_module | |
632 | .quad quiet_ni_syscall /* 130 get_kernel_syms */ | |
b716395e | 633 | .quad sys32_quotactl |
1da177e4 LT |
634 | .quad sys_getpgid |
635 | .quad sys_fchdir | |
636 | .quad quiet_ni_syscall /* bdflush */ | |
637 | .quad sys_sysfs /* 135 */ | |
638 | .quad sys_personality | |
639 | .quad quiet_ni_syscall /* for afs_syscall */ | |
640 | .quad sys_setfsuid16 | |
641 | .quad sys_setfsgid16 | |
642 | .quad sys_llseek /* 140 */ | |
643 | .quad compat_sys_getdents | |
644 | .quad compat_sys_select | |
645 | .quad sys_flock | |
646 | .quad sys_msync | |
647 | .quad compat_sys_readv /* 145 */ | |
648 | .quad compat_sys_writev | |
649 | .quad sys_getsid | |
650 | .quad sys_fdatasync | |
651 | .quad sys32_sysctl /* sysctl */ | |
652 | .quad sys_mlock /* 150 */ | |
653 | .quad sys_munlock | |
654 | .quad sys_mlockall | |
655 | .quad sys_munlockall | |
656 | .quad sys_sched_setparam | |
657 | .quad sys_sched_getparam /* 155 */ | |
658 | .quad sys_sched_setscheduler | |
659 | .quad sys_sched_getscheduler | |
660 | .quad sys_sched_yield | |
661 | .quad sys_sched_get_priority_max | |
662 | .quad sys_sched_get_priority_min /* 160 */ | |
a9bc3bfd | 663 | .quad sys32_sched_rr_get_interval |
1da177e4 LT |
664 | .quad compat_sys_nanosleep |
665 | .quad sys_mremap | |
666 | .quad sys_setresuid16 | |
667 | .quad sys_getresuid16 /* 165 */ | |
668 | .quad sys32_vm86_warning /* vm86 */ | |
669 | .quad quiet_ni_syscall /* query_module */ | |
670 | .quad sys_poll | |
671 | .quad compat_sys_nfsservctl | |
672 | .quad sys_setresgid16 /* 170 */ | |
673 | .quad sys_getresgid16 | |
674 | .quad sys_prctl | |
675 | .quad stub32_rt_sigreturn | |
676 | .quad sys32_rt_sigaction | |
677 | .quad sys32_rt_sigprocmask /* 175 */ | |
678 | .quad sys32_rt_sigpending | |
679 | .quad compat_sys_rt_sigtimedwait | |
680 | .quad sys32_rt_sigqueueinfo | |
5f0120b5 | 681 | .quad sys_rt_sigsuspend |
1da177e4 LT |
682 | .quad sys32_pread /* 180 */ |
683 | .quad sys32_pwrite | |
684 | .quad sys_chown16 | |
685 | .quad sys_getcwd | |
686 | .quad sys_capget | |
687 | .quad sys_capset | |
688 | .quad stub32_sigaltstack | |
689 | .quad sys32_sendfile | |
690 | .quad quiet_ni_syscall /* streams1 */ | |
691 | .quad quiet_ni_syscall /* streams2 */ | |
692 | .quad stub32_vfork /* 190 */ | |
693 | .quad compat_sys_getrlimit | |
694 | .quad sys32_mmap2 | |
695 | .quad sys32_truncate64 | |
696 | .quad sys32_ftruncate64 | |
697 | .quad sys32_stat64 /* 195 */ | |
698 | .quad sys32_lstat64 | |
699 | .quad sys32_fstat64 | |
700 | .quad sys_lchown | |
701 | .quad sys_getuid | |
702 | .quad sys_getgid /* 200 */ | |
703 | .quad sys_geteuid | |
704 | .quad sys_getegid | |
705 | .quad sys_setreuid | |
706 | .quad sys_setregid | |
707 | .quad sys_getgroups /* 205 */ | |
708 | .quad sys_setgroups | |
709 | .quad sys_fchown | |
710 | .quad sys_setresuid | |
711 | .quad sys_getresuid | |
712 | .quad sys_setresgid /* 210 */ | |
713 | .quad sys_getresgid | |
714 | .quad sys_chown | |
715 | .quad sys_setuid | |
716 | .quad sys_setgid | |
717 | .quad sys_setfsuid /* 215 */ | |
718 | .quad sys_setfsgid | |
719 | .quad sys_pivot_root | |
720 | .quad sys_mincore | |
721 | .quad sys_madvise | |
722 | .quad compat_sys_getdents64 /* 220 getdents64 */ | |
723 | .quad compat_sys_fcntl64 | |
724 | .quad quiet_ni_syscall /* tux */ | |
725 | .quad quiet_ni_syscall /* security */ | |
726 | .quad sys_gettid | |
e412ac49 | 727 | .quad sys32_readahead /* 225 */ |
1da177e4 LT |
728 | .quad sys_setxattr |
729 | .quad sys_lsetxattr | |
730 | .quad sys_fsetxattr | |
731 | .quad sys_getxattr | |
732 | .quad sys_lgetxattr /* 230 */ | |
733 | .quad sys_fgetxattr | |
734 | .quad sys_listxattr | |
735 | .quad sys_llistxattr | |
736 | .quad sys_flistxattr | |
737 | .quad sys_removexattr /* 235 */ | |
738 | .quad sys_lremovexattr | |
739 | .quad sys_fremovexattr | |
740 | .quad sys_tkill | |
741 | .quad sys_sendfile64 | |
742 | .quad compat_sys_futex /* 240 */ | |
743 | .quad compat_sys_sched_setaffinity | |
744 | .quad compat_sys_sched_getaffinity | |
efd1ca52 RM |
745 | .quad sys_set_thread_area |
746 | .quad sys_get_thread_area | |
1da177e4 LT |
747 | .quad compat_sys_io_setup /* 245 */ |
748 | .quad sys_io_destroy | |
749 | .quad compat_sys_io_getevents | |
750 | .quad compat_sys_io_submit | |
751 | .quad sys_io_cancel | |
e412ac49 | 752 | .quad sys32_fadvise64 /* 250 */ |
1da177e4 LT |
753 | .quad quiet_ni_syscall /* free_huge_pages */ |
754 | .quad sys_exit_group | |
755 | .quad sys32_lookup_dcookie | |
756 | .quad sys_epoll_create | |
757 | .quad sys_epoll_ctl /* 255 */ | |
758 | .quad sys_epoll_wait | |
759 | .quad sys_remap_file_pages | |
760 | .quad sys_set_tid_address | |
3a0f69d5 | 761 | .quad compat_sys_timer_create |
1da177e4 LT |
762 | .quad compat_sys_timer_settime /* 260 */ |
763 | .quad compat_sys_timer_gettime | |
764 | .quad sys_timer_getoverrun | |
765 | .quad sys_timer_delete | |
766 | .quad compat_sys_clock_settime | |
767 | .quad compat_sys_clock_gettime /* 265 */ | |
768 | .quad compat_sys_clock_getres | |
769 | .quad compat_sys_clock_nanosleep | |
770 | .quad compat_sys_statfs64 | |
771 | .quad compat_sys_fstatfs64 | |
772 | .quad sys_tgkill /* 270 */ | |
773 | .quad compat_sys_utimes | |
774 | .quad sys32_fadvise64_64 | |
775 | .quad quiet_ni_syscall /* sys_vserver */ | |
776 | .quad sys_mbind | |
777 | .quad compat_sys_get_mempolicy /* 275 */ | |
778 | .quad sys_set_mempolicy | |
779 | .quad compat_sys_mq_open | |
780 | .quad sys_mq_unlink | |
781 | .quad compat_sys_mq_timedsend | |
782 | .quad compat_sys_mq_timedreceive /* 280 */ | |
783 | .quad compat_sys_mq_notify | |
784 | .quad compat_sys_mq_getsetattr | |
5234f5eb | 785 | .quad compat_sys_kexec_load /* reserved for kexec */ |
1da177e4 | 786 | .quad compat_sys_waitid |
725b38ab | 787 | .quad quiet_ni_syscall /* 285: sys_altroot */ |
1da177e4 LT |
788 | .quad sys_add_key |
789 | .quad sys_request_key | |
790 | .quad sys_keyctl | |
725b38ab RL |
791 | .quad sys_ioprio_set |
792 | .quad sys_ioprio_get /* 290 */ | |
793 | .quad sys_inotify_init | |
794 | .quad sys_inotify_add_watch | |
795 | .quad sys_inotify_rm_watch | |
39743889 | 796 | .quad sys_migrate_pages |
a60fc519 UD |
797 | .quad compat_sys_openat /* 295 */ |
798 | .quad sys_mkdirat | |
799 | .quad sys_mknodat | |
800 | .quad sys_fchownat | |
3833a705 | 801 | .quad compat_sys_futimesat |
cff2b760 | 802 | .quad sys32_fstatat /* 300 */ |
a60fc519 UD |
803 | .quad sys_unlinkat |
804 | .quad sys_renameat | |
805 | .quad sys_linkat | |
806 | .quad sys_symlinkat | |
807 | .quad sys_readlinkat /* 305 */ | |
808 | .quad sys_fchmodat | |
809 | .quad sys_faccessat | |
957dc87c AK |
810 | .quad compat_sys_pselect6 |
811 | .quad compat_sys_ppoll | |
4b88f093 | 812 | .quad sys_unshare /* 310 */ |
8fdd6c6d IM |
813 | .quad compat_sys_set_robust_list |
814 | .quad compat_sys_get_robust_list | |
b8feb47f | 815 | .quad sys_splice |
e412ac49 | 816 | .quad sys32_sync_file_range |
1c710c89 | 817 | .quad sys_tee /* 315 */ |
d2610202 | 818 | .quad compat_sys_vmsplice |
1b2db9fb | 819 | .quad compat_sys_move_pages |
3cfc348b | 820 | .quad sys_getcpu |
9af3cf05 | 821 | .quad sys_epoll_pwait |
1c710c89 | 822 | .quad compat_sys_utimensat /* 320 */ |
ae7d5c86 | 823 | .quad compat_sys_signalfd |
cb9282ee | 824 | .quad sys_timerfd_create |
fdb902b1 | 825 | .quad sys_eventfd |
97ac7350 | 826 | .quad sys32_fallocate |
cb9282ee DL |
827 | .quad compat_sys_timerfd_settime /* 325 */ |
828 | .quad compat_sys_timerfd_gettime | |
9deb27ba | 829 | .quad compat_sys_signalfd4 |
b087498e | 830 | .quad sys_eventfd2 |
9fe5ad9c | 831 | .quad sys_epoll_create1 |
336dd1f7 | 832 | .quad sys_dup3 /* 330 */ |
ed8cae8b | 833 | .quad sys_pipe2 |
4006553b | 834 | .quad sys_inotify_init1 |
ae7d5c86 | 835 | ia32_syscall_end: |