blob: 2a4c42427d9ae261f26a5bbe99656c08441e1b35 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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>
Sam Ravnborge2d5df92005-09-09 21:28:48 +02009#include <asm/asm-offsets.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010#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>
Ingo Molnar2601e642006-07-03 00:24:45 -070015#include <asm/irqflags.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070016#include <linux/linkage.h>
17
Andi Kleen67d53ea2006-04-07 19:50:31 +020018#define IA32_NR_syscalls ((ia32_syscall_end - ia32_sys_call_table)/8)
19
Linus Torvalds1da177e2005-04-16 15:20:36 -070020 .macro IA32_ARG_FIXUP noebp=0
21 movl %edi,%r8d
22 .if \noebp
23 .else
24 movl %ebp,%r9d
25 .endif
26 xchg %ecx,%esi
27 movl %ebx,%edi
28 movl %edx,%edx /* zero extension */
29 .endm
30
31 /* clobbers %eax */
32 .macro CLEAR_RREGS
33 xorl %eax,%eax
34 movq %rax,R11(%rsp)
35 movq %rax,R10(%rsp)
36 movq %rax,R9(%rsp)
37 movq %rax,R8(%rsp)
38 .endm
39
Andi Kleen176df242007-09-21 16:16:18 +020040 .macro LOAD_ARGS32 offset
41 movl \offset(%rsp),%r11d
42 movl \offset+8(%rsp),%r10d
43 movl \offset+16(%rsp),%r9d
44 movl \offset+24(%rsp),%r8d
45 movl \offset+40(%rsp),%ecx
46 movl \offset+48(%rsp),%edx
47 movl \offset+56(%rsp),%esi
48 movl \offset+64(%rsp),%edi
49 movl \offset+72(%rsp),%eax
50 .endm
51
Jan Beulich27651302006-01-11 22:41:59 +010052 .macro CFI_STARTPROC32 simple
53 CFI_STARTPROC \simple
54 CFI_UNDEFINED r8
55 CFI_UNDEFINED r9
56 CFI_UNDEFINED r10
57 CFI_UNDEFINED r11
58 CFI_UNDEFINED r12
59 CFI_UNDEFINED r13
60 CFI_UNDEFINED r14
61 CFI_UNDEFINED r15
62 .endm
63
Jeremy Fitzhardinge2be29982008-06-25 00:19:28 -040064#ifdef CONFIG_PARAVIRT
65ENTRY(native_usergs_sysret32)
66 swapgs
67 sysretl
68ENDPROC(native_usergs_sysret32)
69
70ENTRY(native_irq_enable_sysexit)
71 swapgs
72 sti
73 sysexit
74ENDPROC(native_irq_enable_sysexit)
75#endif
76
Linus Torvalds1da177e2005-04-16 15:20:36 -070077/*
78 * 32bit SYSENTER instruction entry.
79 *
80 * Arguments:
81 * %eax System call number.
82 * %ebx Arg1
83 * %ecx Arg2
84 * %edx Arg3
85 * %esi Arg4
86 * %edi Arg5
87 * %ebp user stack
88 * 0(%ebp) Arg6
89 *
90 * Interrupts off.
91 *
92 * This is purely a fast path. For anything complicated we use the int 0x80
93 * path below. Set up a complete hardware stack frame to share code
94 * with the int 0x80 path.
95 */
96ENTRY(ia32_sysenter_target)
Jan Beulich27651302006-01-11 22:41:59 +010097 CFI_STARTPROC32 simple
Jan Beulichadf14232006-09-26 10:52:41 +020098 CFI_SIGNAL_FRAME
Jan Beulich7effaa82005-09-12 18:49:24 +020099 CFI_DEF_CFA rsp,0
100 CFI_REGISTER rsp,rbp
Linus Torvalds1da177e2005-04-16 15:20:36 -0700101 swapgs
102 movq %gs:pda_kernelstack, %rsp
103 addq $(PDA_STACKOFFSET),%rsp
Ingo Molnar2601e642006-07-03 00:24:45 -0700104 /*
105 * No need to follow this irqs on/off section: the syscall
106 * disabled irqs, here we enable it straight after entry:
107 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108 sti
109 movl %ebp,%ebp /* zero extension */
110 pushq $__USER32_DS
Jan Beulich7effaa82005-09-12 18:49:24 +0200111 CFI_ADJUST_CFA_OFFSET 8
112 /*CFI_REL_OFFSET ss,0*/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700113 pushq %rbp
Jan Beulich7effaa82005-09-12 18:49:24 +0200114 CFI_ADJUST_CFA_OFFSET 8
115 CFI_REL_OFFSET rsp,0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116 pushfq
Jan Beulich7effaa82005-09-12 18:49:24 +0200117 CFI_ADJUST_CFA_OFFSET 8
118 /*CFI_REL_OFFSET rflags,0*/
Roland McGrath36197c92008-01-30 13:30:43 +0100119 movl 8*3-THREAD_SIZE+threadinfo_sysenter_return(%rsp), %r10d
Jan Beulich7effaa82005-09-12 18:49:24 +0200120 CFI_REGISTER rip,r10
Linus Torvalds1da177e2005-04-16 15:20:36 -0700121 pushq $__USER32_CS
Jan Beulich7effaa82005-09-12 18:49:24 +0200122 CFI_ADJUST_CFA_OFFSET 8
123 /*CFI_REL_OFFSET cs,0*/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700124 movl %eax, %eax
125 pushq %r10
Jan Beulich7effaa82005-09-12 18:49:24 +0200126 CFI_ADJUST_CFA_OFFSET 8
127 CFI_REL_OFFSET rip,0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700128 pushq %rax
Jan Beulich7effaa82005-09-12 18:49:24 +0200129 CFI_ADJUST_CFA_OFFSET 8
Linus Torvalds1da177e2005-04-16 15:20:36 -0700130 cld
Jan Beulichcdc17932007-07-21 17:10:20 +0200131 SAVE_ARGS 0,0,1
Linus Torvalds1da177e2005-04-16 15:20:36 -0700132 /* no need to do an access_ok check here because rbp has been
133 32bit zero extended */
1341: movl (%rbp),%r9d
135 .section __ex_table,"a"
136 .quad 1b,ia32_badarg
137 .previous
138 GET_THREAD_INFO(%r10)
Andi Kleenbf2fcc62006-01-11 22:44:06 +0100139 orl $TS_COMPAT,threadinfo_status(%r10)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140 testl $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP),threadinfo_flags(%r10)
Jan Beulich7effaa82005-09-12 18:49:24 +0200141 CFI_REMEMBER_STATE
Linus Torvalds1da177e2005-04-16 15:20:36 -0700142 jnz sysenter_tracesys
143sysenter_do_call:
Andi Kleen67d53ea2006-04-07 19:50:31 +0200144 cmpl $(IA32_NR_syscalls-1),%eax
145 ja ia32_badsys
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146 IA32_ARG_FIXUP 1
147 call *ia32_sys_call_table(,%rax,8)
148 movq %rax,RAX-ARGOFFSET(%rsp)
149 GET_THREAD_INFO(%r10)
150 cli
Ingo Molnar2601e642006-07-03 00:24:45 -0700151 TRACE_IRQS_OFF
Linus Torvalds1da177e2005-04-16 15:20:36 -0700152 testl $_TIF_ALLWORK_MASK,threadinfo_flags(%r10)
153 jnz int_ret_from_sys_call
Andi Kleenbf2fcc62006-01-11 22:44:06 +0100154 andl $~TS_COMPAT,threadinfo_status(%r10)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700155 /* clear IF, that popfq doesn't enable interrupts early */
156 andl $~0x200,EFLAGS-R11(%rsp)
Roland McGrath36197c92008-01-30 13:30:43 +0100157 movl RIP-R11(%rsp),%edx /* User %eip */
158 CFI_REGISTER rip,rdx
Linus Torvalds1da177e2005-04-16 15:20:36 -0700159 RESTORE_ARGS 1,24,1,1,1,1
160 popfq
Jan Beulich7effaa82005-09-12 18:49:24 +0200161 CFI_ADJUST_CFA_OFFSET -8
162 /*CFI_RESTORE rflags*/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700163 popq %rcx /* User %esp */
Jan Beulich7effaa82005-09-12 18:49:24 +0200164 CFI_ADJUST_CFA_OFFSET -8
165 CFI_REGISTER rsp,rcx
Ingo Molnar2601e642006-07-03 00:24:45 -0700166 TRACE_IRQS_ON
Jeremy Fitzhardinge2be29982008-06-25 00:19:28 -0400167 ENABLE_INTERRUPTS_SYSEXIT32
Linus Torvalds1da177e2005-04-16 15:20:36 -0700168
169sysenter_tracesys:
Jan Beulich7effaa82005-09-12 18:49:24 +0200170 CFI_RESTORE_STATE
Chuck Ebbertecd744e2007-11-07 10:48:39 -0500171 xchgl %r9d,%ebp
Linus Torvalds1da177e2005-04-16 15:20:36 -0700172 SAVE_REST
173 CLEAR_RREGS
Chuck Ebbertecd744e2007-11-07 10:48:39 -0500174 movq %r9,R9(%rsp)
Roland McGrath48ee6792008-03-18 18:23:50 -0700175 movq $-ENOSYS,RAX(%rsp)/* ptrace can change this for a bad syscall */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700176 movq %rsp,%rdi /* &pt_regs -> arg1 */
177 call syscall_trace_enter
Andi Kleen176df242007-09-21 16:16:18 +0200178 LOAD_ARGS32 ARGOFFSET /* reload args from stack in case ptrace changed it */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700179 RESTORE_REST
Chuck Ebbertecd744e2007-11-07 10:48:39 -0500180 xchgl %ebp,%r9d
Roland McGrath48ee6792008-03-18 18:23:50 -0700181 cmpl $(IA32_NR_syscalls-1),%eax
182 ja int_ret_from_sys_call /* sysenter_tracesys has set RAX(%rsp) */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700183 jmp sysenter_do_call
184 CFI_ENDPROC
Jan Beulich4b787e02006-06-26 13:56:55 +0200185ENDPROC(ia32_sysenter_target)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700186
187/*
188 * 32bit SYSCALL instruction entry.
189 *
190 * Arguments:
191 * %eax System call number.
192 * %ebx Arg1
193 * %ecx return EIP
194 * %edx Arg3
195 * %esi Arg4
196 * %edi Arg5
197 * %ebp Arg2 [note: not saved in the stack frame, should not be touched]
198 * %esp user stack
199 * 0(%esp) Arg6
200 *
201 * Interrupts off.
202 *
203 * This is purely a fast path. For anything complicated we use the int 0x80
204 * path below. Set up a complete hardware stack frame to share code
205 * with the int 0x80 path.
206 */
207ENTRY(ia32_cstar_target)
Jan Beulich27651302006-01-11 22:41:59 +0100208 CFI_STARTPROC32 simple
Jan Beulichadf14232006-09-26 10:52:41 +0200209 CFI_SIGNAL_FRAME
Jan Beulichdffead42006-06-26 13:57:38 +0200210 CFI_DEF_CFA rsp,PDA_STACKOFFSET
Jan Beulich7effaa82005-09-12 18:49:24 +0200211 CFI_REGISTER rip,rcx
212 /*CFI_REGISTER rflags,r11*/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700213 swapgs
214 movl %esp,%r8d
Jan Beulich7effaa82005-09-12 18:49:24 +0200215 CFI_REGISTER rsp,r8
Linus Torvalds1da177e2005-04-16 15:20:36 -0700216 movq %gs:pda_kernelstack,%rsp
Ingo Molnar2601e642006-07-03 00:24:45 -0700217 /*
218 * No need to follow this irqs on/off section: the syscall
219 * disabled irqs and here we enable it straight after entry:
220 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700221 sti
222 SAVE_ARGS 8,1,1
223 movl %eax,%eax /* zero extension */
224 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
225 movq %rcx,RIP-ARGOFFSET(%rsp)
Jan Beulich7effaa82005-09-12 18:49:24 +0200226 CFI_REL_OFFSET rip,RIP-ARGOFFSET
Linus Torvalds1da177e2005-04-16 15:20:36 -0700227 movq %rbp,RCX-ARGOFFSET(%rsp) /* this lies slightly to ptrace */
228 movl %ebp,%ecx
229 movq $__USER32_CS,CS-ARGOFFSET(%rsp)
230 movq $__USER32_DS,SS-ARGOFFSET(%rsp)
231 movq %r11,EFLAGS-ARGOFFSET(%rsp)
Jan Beulich7effaa82005-09-12 18:49:24 +0200232 /*CFI_REL_OFFSET rflags,EFLAGS-ARGOFFSET*/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700233 movq %r8,RSP-ARGOFFSET(%rsp)
Jan Beulich7effaa82005-09-12 18:49:24 +0200234 CFI_REL_OFFSET rsp,RSP-ARGOFFSET
Linus Torvalds1da177e2005-04-16 15:20:36 -0700235 /* no need to do an access_ok check here because r8 has been
236 32bit zero extended */
237 /* hardware stack frame is complete now */
2381: movl (%r8),%r9d
239 .section __ex_table,"a"
240 .quad 1b,ia32_badarg
241 .previous
242 GET_THREAD_INFO(%r10)
Andi Kleenbf2fcc62006-01-11 22:44:06 +0100243 orl $TS_COMPAT,threadinfo_status(%r10)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700244 testl $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP),threadinfo_flags(%r10)
Jan Beulich7effaa82005-09-12 18:49:24 +0200245 CFI_REMEMBER_STATE
Linus Torvalds1da177e2005-04-16 15:20:36 -0700246 jnz cstar_tracesys
247cstar_do_call:
Andi Kleen67d53ea2006-04-07 19:50:31 +0200248 cmpl $IA32_NR_syscalls-1,%eax
249 ja ia32_badsys
Linus Torvalds1da177e2005-04-16 15:20:36 -0700250 IA32_ARG_FIXUP 1
251 call *ia32_sys_call_table(,%rax,8)
252 movq %rax,RAX-ARGOFFSET(%rsp)
253 GET_THREAD_INFO(%r10)
254 cli
Ingo Molnar2601e642006-07-03 00:24:45 -0700255 TRACE_IRQS_OFF
Linus Torvalds1da177e2005-04-16 15:20:36 -0700256 testl $_TIF_ALLWORK_MASK,threadinfo_flags(%r10)
257 jnz int_ret_from_sys_call
Andi Kleenbf2fcc62006-01-11 22:44:06 +0100258 andl $~TS_COMPAT,threadinfo_status(%r10)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700259 RESTORE_ARGS 1,-ARG_SKIP,1,1,1
260 movl RIP-ARGOFFSET(%rsp),%ecx
Jan Beulich7effaa82005-09-12 18:49:24 +0200261 CFI_REGISTER rip,rcx
Linus Torvalds1da177e2005-04-16 15:20:36 -0700262 movl EFLAGS-ARGOFFSET(%rsp),%r11d
Jan Beulich7effaa82005-09-12 18:49:24 +0200263 /*CFI_REGISTER rflags,r11*/
Ingo Molnar2601e642006-07-03 00:24:45 -0700264 TRACE_IRQS_ON
Linus Torvalds1da177e2005-04-16 15:20:36 -0700265 movl RSP-ARGOFFSET(%rsp),%esp
Jan Beulich7effaa82005-09-12 18:49:24 +0200266 CFI_RESTORE rsp
Jeremy Fitzhardinge2be29982008-06-25 00:19:28 -0400267 USERGS_SYSRET32
Linus Torvalds1da177e2005-04-16 15:20:36 -0700268
269cstar_tracesys:
Jan Beulich7effaa82005-09-12 18:49:24 +0200270 CFI_RESTORE_STATE
Chuck Ebbertecd744e2007-11-07 10:48:39 -0500271 xchgl %r9d,%ebp
Linus Torvalds1da177e2005-04-16 15:20:36 -0700272 SAVE_REST
273 CLEAR_RREGS
Chuck Ebbertecd744e2007-11-07 10:48:39 -0500274 movq %r9,R9(%rsp)
Roland McGrath48ee6792008-03-18 18:23:50 -0700275 movq $-ENOSYS,RAX(%rsp) /* ptrace can change this for a bad syscall */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700276 movq %rsp,%rdi /* &pt_regs -> arg1 */
277 call syscall_trace_enter
Andi Kleen176df242007-09-21 16:16:18 +0200278 LOAD_ARGS32 ARGOFFSET /* reload args from stack in case ptrace changed it */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700279 RESTORE_REST
Chuck Ebbertecd744e2007-11-07 10:48:39 -0500280 xchgl %ebp,%r9d
Linus Torvalds1da177e2005-04-16 15:20:36 -0700281 movl RSP-ARGOFFSET(%rsp), %r8d
Roland McGrath48ee6792008-03-18 18:23:50 -0700282 cmpl $(IA32_NR_syscalls-1),%eax
283 ja int_ret_from_sys_call /* cstar_tracesys has set RAX(%rsp) */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700284 jmp cstar_do_call
Jan Beulich4b787e02006-06-26 13:56:55 +0200285END(ia32_cstar_target)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700286
287ia32_badarg:
288 movq $-EFAULT,%rax
289 jmp ia32_sysret
290 CFI_ENDPROC
291
292/*
293 * Emulated IA32 system calls via int 0x80.
294 *
295 * Arguments:
296 * %eax System call number.
297 * %ebx Arg1
298 * %ecx Arg2
299 * %edx Arg3
300 * %esi Arg4
301 * %edi Arg5
302 * %ebp Arg6 [note: not saved in the stack frame, should not be touched]
303 *
304 * Notes:
305 * Uses the same stack frame as the x86-64 version.
306 * All registers except %eax must be saved (but ptrace may violate that)
307 * Arguments are zero extended. For system calls that want sign extension and
308 * take long arguments a wrapper is needed. Most calls can just be called
309 * directly.
310 * Assumes it is only called from user space and entered with interrupts off.
311 */
312
313ENTRY(ia32_syscall)
Jan Beulichcdc17932007-07-21 17:10:20 +0200314 CFI_STARTPROC32 simple
Jan Beulichadf14232006-09-26 10:52:41 +0200315 CFI_SIGNAL_FRAME
Jan Beulich7effaa82005-09-12 18:49:24 +0200316 CFI_DEF_CFA rsp,SS+8-RIP
317 /*CFI_REL_OFFSET ss,SS-RIP*/
318 CFI_REL_OFFSET rsp,RSP-RIP
319 /*CFI_REL_OFFSET rflags,EFLAGS-RIP*/
320 /*CFI_REL_OFFSET cs,CS-RIP*/
321 CFI_REL_OFFSET rip,RIP-RIP
Ingo Molnar2601e642006-07-03 00:24:45 -0700322 swapgs
323 /*
324 * No need to follow this irqs on/off section: the syscall
325 * disabled irqs and here we enable it straight after entry:
326 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700327 sti
328 movl %eax,%eax
329 pushq %rax
Jan Beulich7effaa82005-09-12 18:49:24 +0200330 CFI_ADJUST_CFA_OFFSET 8
Linus Torvalds1da177e2005-04-16 15:20:36 -0700331 cld
332 /* note the registers are not zero extended to the sf.
333 this could be a problem. */
334 SAVE_ARGS 0,0,1
335 GET_THREAD_INFO(%r10)
Andi Kleenbf2fcc62006-01-11 22:44:06 +0100336 orl $TS_COMPAT,threadinfo_status(%r10)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700337 testl $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP),threadinfo_flags(%r10)
338 jnz ia32_tracesys
339ia32_do_syscall:
Andi Kleen67d53ea2006-04-07 19:50:31 +0200340 cmpl $(IA32_NR_syscalls-1),%eax
Roland McGrath8ab32bb2008-03-16 21:57:41 -0700341 ja int_ret_from_sys_call /* ia32_tracesys has set RAX(%rsp) */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700342 IA32_ARG_FIXUP
343 call *ia32_sys_call_table(,%rax,8) # xxx: rip relative
344ia32_sysret:
345 movq %rax,RAX-ARGOFFSET(%rsp)
346 jmp int_ret_from_sys_call
347
348ia32_tracesys:
349 SAVE_REST
Jan Beulichcdc17932007-07-21 17:10:20 +0200350 CLEAR_RREGS
Roland McGrath8ab32bb2008-03-16 21:57:41 -0700351 movq $-ENOSYS,RAX(%rsp) /* ptrace can change this for a bad syscall */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700352 movq %rsp,%rdi /* &pt_regs -> arg1 */
353 call syscall_trace_enter
Andi Kleen176df242007-09-21 16:16:18 +0200354 LOAD_ARGS32 ARGOFFSET /* reload args from stack in case ptrace changed it */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700355 RESTORE_REST
356 jmp ia32_do_syscall
Jan Beulich4b787e02006-06-26 13:56:55 +0200357END(ia32_syscall)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700358
359ia32_badsys:
360 movq $0,ORIG_RAX-ARGOFFSET(%rsp)
361 movq $-ENOSYS,RAX-ARGOFFSET(%rsp)
362 jmp int_ret_from_sys_call
363
Linus Torvalds1da177e2005-04-16 15:20:36 -0700364quiet_ni_syscall:
365 movq $-ENOSYS,%rax
366 ret
367 CFI_ENDPROC
368
369 .macro PTREGSCALL label, func, arg
370 .globl \label
371\label:
372 leaq \func(%rip),%rax
373 leaq -ARGOFFSET+8(%rsp),\arg /* 8 for return address */
374 jmp ia32_ptregs_common
375 .endm
376
Jan Beulich27651302006-01-11 22:41:59 +0100377 CFI_STARTPROC32
Jan Beulich7effaa82005-09-12 18:49:24 +0200378
Linus Torvalds1da177e2005-04-16 15:20:36 -0700379 PTREGSCALL stub32_rt_sigreturn, sys32_rt_sigreturn, %rdi
380 PTREGSCALL stub32_sigreturn, sys32_sigreturn, %rdi
381 PTREGSCALL stub32_sigaltstack, sys32_sigaltstack, %rdx
Linus Torvalds1da177e2005-04-16 15:20:36 -0700382 PTREGSCALL stub32_execve, sys32_execve, %rcx
383 PTREGSCALL stub32_fork, sys_fork, %rdi
384 PTREGSCALL stub32_clone, sys32_clone, %rdx
385 PTREGSCALL stub32_vfork, sys_vfork, %rdi
386 PTREGSCALL stub32_iopl, sys_iopl, %rsi
Linus Torvalds1da177e2005-04-16 15:20:36 -0700387
388ENTRY(ia32_ptregs_common)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700389 popq %r11
Jan Beulich27651302006-01-11 22:41:59 +0100390 CFI_ENDPROC
391 CFI_STARTPROC32 simple
Jan Beulichadf14232006-09-26 10:52:41 +0200392 CFI_SIGNAL_FRAME
Jan Beulich27651302006-01-11 22:41:59 +0100393 CFI_DEF_CFA rsp,SS+8-ARGOFFSET
394 CFI_REL_OFFSET rax,RAX-ARGOFFSET
395 CFI_REL_OFFSET rcx,RCX-ARGOFFSET
396 CFI_REL_OFFSET rdx,RDX-ARGOFFSET
397 CFI_REL_OFFSET rsi,RSI-ARGOFFSET
398 CFI_REL_OFFSET rdi,RDI-ARGOFFSET
399 CFI_REL_OFFSET rip,RIP-ARGOFFSET
400/* CFI_REL_OFFSET cs,CS-ARGOFFSET*/
401/* CFI_REL_OFFSET rflags,EFLAGS-ARGOFFSET*/
402 CFI_REL_OFFSET rsp,RSP-ARGOFFSET
403/* CFI_REL_OFFSET ss,SS-ARGOFFSET*/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700404 SAVE_REST
405 call *%rax
406 RESTORE_REST
407 jmp ia32_sysret /* misbalances the return cache */
408 CFI_ENDPROC
Jan Beulich4b787e02006-06-26 13:56:55 +0200409END(ia32_ptregs_common)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700410
Arjan van de Venbb152f52006-01-06 00:12:05 -0800411 .section .rodata,"a"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700412 .align 8
Linus Torvalds1da177e2005-04-16 15:20:36 -0700413ia32_sys_call_table:
414 .quad sys_restart_syscall
415 .quad sys_exit
416 .quad stub32_fork
417 .quad sys_read
418 .quad sys_write
Miklos Szeredie922efc2005-09-06 15:18:25 -0700419 .quad compat_sys_open /* 5 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700420 .quad sys_close
421 .quad sys32_waitpid
422 .quad sys_creat
423 .quad sys_link
424 .quad sys_unlink /* 10 */
425 .quad stub32_execve
426 .quad sys_chdir
427 .quad compat_sys_time
428 .quad sys_mknod
429 .quad sys_chmod /* 15 */
430 .quad sys_lchown16
431 .quad quiet_ni_syscall /* old break syscall holder */
432 .quad sys_stat
433 .quad sys32_lseek
434 .quad sys_getpid /* 20 */
435 .quad compat_sys_mount /* mount */
436 .quad sys_oldumount /* old_umount */
437 .quad sys_setuid16
438 .quad sys_getuid16
439 .quad compat_sys_stime /* stime */ /* 25 */
Roland McGrath562b80b2008-04-22 12:21:25 -0700440 .quad compat_sys_ptrace /* ptrace */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700441 .quad sys_alarm
442 .quad sys_fstat /* (old)fstat */
443 .quad sys_pause
444 .quad compat_sys_utime /* 30 */
445 .quad quiet_ni_syscall /* old stty syscall holder */
446 .quad quiet_ni_syscall /* old gtty syscall holder */
447 .quad sys_access
448 .quad sys_nice
449 .quad quiet_ni_syscall /* 35 */ /* old ftime syscall holder */
450 .quad sys_sync
451 .quad sys32_kill
452 .quad sys_rename
453 .quad sys_mkdir
454 .quad sys_rmdir /* 40 */
455 .quad sys_dup
456 .quad sys32_pipe
457 .quad compat_sys_times
458 .quad quiet_ni_syscall /* old prof syscall holder */
459 .quad sys_brk /* 45 */
460 .quad sys_setgid16
461 .quad sys_getgid16
462 .quad sys_signal
463 .quad sys_geteuid16
464 .quad sys_getegid16 /* 50 */
465 .quad sys_acct
466 .quad sys_umount /* new_umount */
467 .quad quiet_ni_syscall /* old lock syscall holder */
468 .quad compat_sys_ioctl
469 .quad compat_sys_fcntl64 /* 55 */
470 .quad quiet_ni_syscall /* old mpx syscall holder */
471 .quad sys_setpgid
472 .quad quiet_ni_syscall /* old ulimit syscall holder */
473 .quad sys32_olduname
474 .quad sys_umask /* 60 */
475 .quad sys_chroot
476 .quad sys32_ustat
477 .quad sys_dup2
478 .quad sys_getppid
479 .quad sys_getpgrp /* 65 */
480 .quad sys_setsid
481 .quad sys32_sigaction
482 .quad sys_sgetmask
483 .quad sys_ssetmask
484 .quad sys_setreuid16 /* 70 */
485 .quad sys_setregid16
Jan Beulich5f0120b2008-06-18 12:42:11 +0100486 .quad sys32_sigsuspend
Linus Torvalds1da177e2005-04-16 15:20:36 -0700487 .quad compat_sys_sigpending
488 .quad sys_sethostname
489 .quad compat_sys_setrlimit /* 75 */
490 .quad compat_sys_old_getrlimit /* old_getrlimit */
491 .quad compat_sys_getrusage
492 .quad sys32_gettimeofday
493 .quad sys32_settimeofday
494 .quad sys_getgroups16 /* 80 */
495 .quad sys_setgroups16
496 .quad sys32_old_select
497 .quad sys_symlink
498 .quad sys_lstat
499 .quad sys_readlink /* 85 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700500 .quad sys_uselib
Linus Torvalds1da177e2005-04-16 15:20:36 -0700501 .quad sys_swapon
502 .quad sys_reboot
503 .quad compat_sys_old_readdir
504 .quad sys32_mmap /* 90 */
505 .quad sys_munmap
506 .quad sys_truncate
507 .quad sys_ftruncate
508 .quad sys_fchmod
509 .quad sys_fchown16 /* 95 */
510 .quad sys_getpriority
511 .quad sys_setpriority
512 .quad quiet_ni_syscall /* old profil syscall holder */
513 .quad compat_sys_statfs
514 .quad compat_sys_fstatfs /* 100 */
515 .quad sys_ioperm
516 .quad compat_sys_socketcall
517 .quad sys_syslog
518 .quad compat_sys_setitimer
519 .quad compat_sys_getitimer /* 105 */
520 .quad compat_sys_newstat
521 .quad compat_sys_newlstat
522 .quad compat_sys_newfstat
523 .quad sys32_uname
524 .quad stub32_iopl /* 110 */
525 .quad sys_vhangup
526 .quad quiet_ni_syscall /* old "idle" system call */
527 .quad sys32_vm86_warning /* vm86old */
528 .quad compat_sys_wait4
529 .quad sys_swapoff /* 115 */
Kyle McMartind4d23ad2007-02-10 01:46:00 -0800530 .quad compat_sys_sysinfo
Linus Torvalds1da177e2005-04-16 15:20:36 -0700531 .quad sys32_ipc
532 .quad sys_fsync
533 .quad stub32_sigreturn
534 .quad stub32_clone /* 120 */
535 .quad sys_setdomainname
536 .quad sys_uname
537 .quad sys_modify_ldt
Stephen Rothwell3158e942006-03-26 01:37:29 -0800538 .quad compat_sys_adjtimex
Linus Torvalds1da177e2005-04-16 15:20:36 -0700539 .quad sys32_mprotect /* 125 */
540 .quad compat_sys_sigprocmask
541 .quad quiet_ni_syscall /* create_module */
542 .quad sys_init_module
543 .quad sys_delete_module
544 .quad quiet_ni_syscall /* 130 get_kernel_syms */
Vasily Tarasovb7163952007-07-15 23:41:12 -0700545 .quad sys32_quotactl
Linus Torvalds1da177e2005-04-16 15:20:36 -0700546 .quad sys_getpgid
547 .quad sys_fchdir
548 .quad quiet_ni_syscall /* bdflush */
549 .quad sys_sysfs /* 135 */
550 .quad sys_personality
551 .quad quiet_ni_syscall /* for afs_syscall */
552 .quad sys_setfsuid16
553 .quad sys_setfsgid16
554 .quad sys_llseek /* 140 */
555 .quad compat_sys_getdents
556 .quad compat_sys_select
557 .quad sys_flock
558 .quad sys_msync
559 .quad compat_sys_readv /* 145 */
560 .quad compat_sys_writev
561 .quad sys_getsid
562 .quad sys_fdatasync
563 .quad sys32_sysctl /* sysctl */
564 .quad sys_mlock /* 150 */
565 .quad sys_munlock
566 .quad sys_mlockall
567 .quad sys_munlockall
568 .quad sys_sched_setparam
569 .quad sys_sched_getparam /* 155 */
570 .quad sys_sched_setscheduler
571 .quad sys_sched_getscheduler
572 .quad sys_sched_yield
573 .quad sys_sched_get_priority_max
574 .quad sys_sched_get_priority_min /* 160 */
Alexandr Andreeva9bc3bf2007-03-16 21:07:36 +0100575 .quad sys32_sched_rr_get_interval
Linus Torvalds1da177e2005-04-16 15:20:36 -0700576 .quad compat_sys_nanosleep
577 .quad sys_mremap
578 .quad sys_setresuid16
579 .quad sys_getresuid16 /* 165 */
580 .quad sys32_vm86_warning /* vm86 */
581 .quad quiet_ni_syscall /* query_module */
582 .quad sys_poll
583 .quad compat_sys_nfsservctl
584 .quad sys_setresgid16 /* 170 */
585 .quad sys_getresgid16
586 .quad sys_prctl
587 .quad stub32_rt_sigreturn
588 .quad sys32_rt_sigaction
589 .quad sys32_rt_sigprocmask /* 175 */
590 .quad sys32_rt_sigpending
591 .quad compat_sys_rt_sigtimedwait
592 .quad sys32_rt_sigqueueinfo
Jan Beulich5f0120b2008-06-18 12:42:11 +0100593 .quad sys_rt_sigsuspend
Linus Torvalds1da177e2005-04-16 15:20:36 -0700594 .quad sys32_pread /* 180 */
595 .quad sys32_pwrite
596 .quad sys_chown16
597 .quad sys_getcwd
598 .quad sys_capget
599 .quad sys_capset
600 .quad stub32_sigaltstack
601 .quad sys32_sendfile
602 .quad quiet_ni_syscall /* streams1 */
603 .quad quiet_ni_syscall /* streams2 */
604 .quad stub32_vfork /* 190 */
605 .quad compat_sys_getrlimit
606 .quad sys32_mmap2
607 .quad sys32_truncate64
608 .quad sys32_ftruncate64
609 .quad sys32_stat64 /* 195 */
610 .quad sys32_lstat64
611 .quad sys32_fstat64
612 .quad sys_lchown
613 .quad sys_getuid
614 .quad sys_getgid /* 200 */
615 .quad sys_geteuid
616 .quad sys_getegid
617 .quad sys_setreuid
618 .quad sys_setregid
619 .quad sys_getgroups /* 205 */
620 .quad sys_setgroups
621 .quad sys_fchown
622 .quad sys_setresuid
623 .quad sys_getresuid
624 .quad sys_setresgid /* 210 */
625 .quad sys_getresgid
626 .quad sys_chown
627 .quad sys_setuid
628 .quad sys_setgid
629 .quad sys_setfsuid /* 215 */
630 .quad sys_setfsgid
631 .quad sys_pivot_root
632 .quad sys_mincore
633 .quad sys_madvise
634 .quad compat_sys_getdents64 /* 220 getdents64 */
635 .quad compat_sys_fcntl64
636 .quad quiet_ni_syscall /* tux */
637 .quad quiet_ni_syscall /* security */
638 .quad sys_gettid
Andi Kleene412ac42007-06-20 12:23:30 +0200639 .quad sys32_readahead /* 225 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700640 .quad sys_setxattr
641 .quad sys_lsetxattr
642 .quad sys_fsetxattr
643 .quad sys_getxattr
644 .quad sys_lgetxattr /* 230 */
645 .quad sys_fgetxattr
646 .quad sys_listxattr
647 .quad sys_llistxattr
648 .quad sys_flistxattr
649 .quad sys_removexattr /* 235 */
650 .quad sys_lremovexattr
651 .quad sys_fremovexattr
652 .quad sys_tkill
653 .quad sys_sendfile64
654 .quad compat_sys_futex /* 240 */
655 .quad compat_sys_sched_setaffinity
656 .quad compat_sys_sched_getaffinity
Roland McGrathefd1ca52008-01-30 13:30:46 +0100657 .quad sys_set_thread_area
658 .quad sys_get_thread_area
Linus Torvalds1da177e2005-04-16 15:20:36 -0700659 .quad compat_sys_io_setup /* 245 */
660 .quad sys_io_destroy
661 .quad compat_sys_io_getevents
662 .quad compat_sys_io_submit
663 .quad sys_io_cancel
Andi Kleene412ac42007-06-20 12:23:30 +0200664 .quad sys32_fadvise64 /* 250 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700665 .quad quiet_ni_syscall /* free_huge_pages */
666 .quad sys_exit_group
667 .quad sys32_lookup_dcookie
668 .quad sys_epoll_create
669 .quad sys_epoll_ctl /* 255 */
670 .quad sys_epoll_wait
671 .quad sys_remap_file_pages
672 .quad sys_set_tid_address
Christoph Hellwig3a0f69d2006-01-09 20:52:08 -0800673 .quad compat_sys_timer_create
Linus Torvalds1da177e2005-04-16 15:20:36 -0700674 .quad compat_sys_timer_settime /* 260 */
675 .quad compat_sys_timer_gettime
676 .quad sys_timer_getoverrun
677 .quad sys_timer_delete
678 .quad compat_sys_clock_settime
679 .quad compat_sys_clock_gettime /* 265 */
680 .quad compat_sys_clock_getres
681 .quad compat_sys_clock_nanosleep
682 .quad compat_sys_statfs64
683 .quad compat_sys_fstatfs64
684 .quad sys_tgkill /* 270 */
685 .quad compat_sys_utimes
686 .quad sys32_fadvise64_64
687 .quad quiet_ni_syscall /* sys_vserver */
688 .quad sys_mbind
689 .quad compat_sys_get_mempolicy /* 275 */
690 .quad sys_set_mempolicy
691 .quad compat_sys_mq_open
692 .quad sys_mq_unlink
693 .quad compat_sys_mq_timedsend
694 .quad compat_sys_mq_timedreceive /* 280 */
695 .quad compat_sys_mq_notify
696 .quad compat_sys_mq_getsetattr
Eric W. Biederman5234f5e2005-06-25 14:58:02 -0700697 .quad compat_sys_kexec_load /* reserved for kexec */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700698 .quad compat_sys_waitid
Robert Love725b38ab2005-07-25 15:19:29 -0400699 .quad quiet_ni_syscall /* 285: sys_altroot */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700700 .quad sys_add_key
701 .quad sys_request_key
702 .quad sys_keyctl
Robert Love725b38ab2005-07-25 15:19:29 -0400703 .quad sys_ioprio_set
704 .quad sys_ioprio_get /* 290 */
705 .quad sys_inotify_init
706 .quad sys_inotify_add_watch
707 .quad sys_inotify_rm_watch
Christoph Lameter39743882006-01-08 01:00:51 -0800708 .quad sys_migrate_pages
Ulrich Dreppera60fc512006-01-18 17:43:56 -0800709 .quad compat_sys_openat /* 295 */
710 .quad sys_mkdirat
711 .quad sys_mknodat
712 .quad sys_fchownat
Andrew Morton3833a702006-02-01 03:04:32 -0800713 .quad compat_sys_futimesat
Ulrich Dreppercff2b762006-02-11 17:55:47 -0800714 .quad sys32_fstatat /* 300 */
Ulrich Dreppera60fc512006-01-18 17:43:56 -0800715 .quad sys_unlinkat
716 .quad sys_renameat
717 .quad sys_linkat
718 .quad sys_symlinkat
719 .quad sys_readlinkat /* 305 */
720 .quad sys_fchmodat
721 .quad sys_faccessat
Andi Kleen957dc872006-09-26 10:52:27 +0200722 .quad compat_sys_pselect6
723 .quad compat_sys_ppoll
Andi Kleen4b88f092006-02-09 00:35:50 +0100724 .quad sys_unshare /* 310 */
Ingo Molnar8fdd6c62006-03-27 01:16:26 -0800725 .quad compat_sys_set_robust_list
726 .quad compat_sys_get_robust_list
Andi Kleenb8feb472006-04-07 19:50:34 +0200727 .quad sys_splice
Andi Kleene412ac42007-06-20 12:23:30 +0200728 .quad sys32_sync_file_range
Ulrich Drepper1c710c82007-05-08 00:33:25 -0700729 .quad sys_tee /* 315 */
Andi Kleend2610202006-05-01 12:15:48 -0700730 .quad compat_sys_vmsplice
Christoph Lameter1b2db9f2006-06-23 02:03:56 -0700731 .quad compat_sys_move_pages
Andi Kleen3cfc3482006-09-26 10:52:28 +0200732 .quad sys_getcpu
Ralf Baechle9af3cf02007-02-13 13:26:26 +0100733 .quad sys_epoll_pwait
Ulrich Drepper1c710c82007-05-08 00:33:25 -0700734 .quad compat_sys_utimensat /* 320 */
Heiko Carstensae7d5c82007-05-12 17:27:41 +0200735 .quad compat_sys_signalfd
Davide Libenzicb9282e2008-02-04 22:27:28 -0800736 .quad sys_timerfd_create
Davide Libenzifdb902b12007-05-10 22:23:20 -0700737 .quad sys_eventfd
Amit Arora97ac7352007-07-17 21:42:44 -0400738 .quad sys32_fallocate
Davide Libenzicb9282e2008-02-04 22:27:28 -0800739 .quad compat_sys_timerfd_settime /* 325 */
740 .quad compat_sys_timerfd_gettime
Heiko Carstensae7d5c82007-05-12 17:27:41 +0200741ia32_syscall_end: