2 * Compatibility mode system call entry point for x86-64.
4 * Copyright 2000-2002 Andi Kleen, SuSE Labs.
7 #include <asm/dwarf2.h>
8 #include <asm/calling.h>
9 #include <asm/offset.h>
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>
15 #include <asm/vsyscall32.h>
16 #include <linux/linkage.h>
18 .macro IA32_ARG_FIXUP noebp=0
26 movl %edx,%edx /* zero extension */
39 * 32bit SYSENTER instruction entry.
42 * %eax System call number.
53 * This is purely a fast path. For anything complicated we use the int 0x80
54 * path below. Set up a complete hardware stack frame to share code
55 * with the int 0x80 path.
57 ENTRY(ia32_sysenter_target)
60 movq %gs:pda_kernelstack, %rsp
61 addq $(PDA_STACKOFFSET),%rsp
63 movl %ebp,%ebp /* zero extension */
67 movl $VSYSCALL32_SYSEXIT, %r10d
74 /* no need to do an access_ok check here because rbp has been
75 32bit zero extended */
77 .section __ex_table,"a"
81 testl $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT),threadinfo_flags(%r10)
84 cmpl $(IA32_NR_syscalls),%eax
87 call *ia32_sys_call_table(,%rax,8)
88 movq %rax,RAX-ARGOFFSET(%rsp)
91 testl $_TIF_ALLWORK_MASK,threadinfo_flags(%r10)
92 jnz int_ret_from_sys_call
93 /* clear IF, that popfq doesn't enable interrupts early */
94 andl $~0x200,EFLAGS-R11(%rsp)
95 RESTORE_ARGS 1,24,1,1,1,1
97 popq %rcx /* User %esp */
98 movl $VSYSCALL32_SYSEXIT,%edx /* User %eip */
100 sti /* sti only takes effect after the next instruction */
107 movq $-ENOSYS,RAX(%rsp) /* really needed? */
108 movq %rsp,%rdi /* &pt_regs -> arg1 */
109 call syscall_trace_enter
110 LOAD_ARGS ARGOFFSET /* reload args from stack in case ptrace changed it */
113 /* no need to do an access_ok check here because rbp has been
114 32bit zero extended */
116 .section __ex_table,"a"
123 * 32bit SYSCALL instruction entry.
126 * %eax System call number.
132 * %ebp Arg2 [note: not saved in the stack frame, should not be touched]
138 * This is purely a fast path. For anything complicated we use the int 0x80
139 * path below. Set up a complete hardware stack frame to share code
140 * with the int 0x80 path.
142 ENTRY(ia32_cstar_target)
146 movq %gs:pda_kernelstack,%rsp
149 movl %eax,%eax /* zero extension */
150 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
151 movq %rcx,RIP-ARGOFFSET(%rsp)
152 movq %rbp,RCX-ARGOFFSET(%rsp) /* this lies slightly to ptrace */
154 movq $__USER32_CS,CS-ARGOFFSET(%rsp)
155 movq $__USER32_DS,SS-ARGOFFSET(%rsp)
156 movq %r11,EFLAGS-ARGOFFSET(%rsp)
157 movq %r8,RSP-ARGOFFSET(%rsp)
158 /* no need to do an access_ok check here because r8 has been
159 32bit zero extended */
160 /* hardware stack frame is complete now */
162 .section __ex_table,"a"
165 GET_THREAD_INFO(%r10)
166 testl $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT),threadinfo_flags(%r10)
169 cmpl $IA32_NR_syscalls,%eax
172 call *ia32_sys_call_table(,%rax,8)
173 movq %rax,RAX-ARGOFFSET(%rsp)
174 GET_THREAD_INFO(%r10)
176 testl $_TIF_ALLWORK_MASK,threadinfo_flags(%r10)
177 jnz int_ret_from_sys_call
178 RESTORE_ARGS 1,-ARG_SKIP,1,1,1
179 movl RIP-ARGOFFSET(%rsp),%ecx
180 movl EFLAGS-ARGOFFSET(%rsp),%r11d
181 movl RSP-ARGOFFSET(%rsp),%esp
188 movq $-ENOSYS,RAX(%rsp) /* really needed? */
189 movq %rsp,%rdi /* &pt_regs -> arg1 */
190 call syscall_trace_enter
191 LOAD_ARGS ARGOFFSET /* reload args from stack in case ptrace changed it */
193 movl RSP-ARGOFFSET(%rsp), %r8d
194 /* no need to do an access_ok check here because r8 has been
195 32bit zero extended */
197 .section __ex_table,"a"
208 * Emulated IA32 system calls via int 0x80.
211 * %eax System call number.
217 * %ebp Arg6 [note: not saved in the stack frame, should not be touched]
220 * Uses the same stack frame as the x86-64 version.
221 * All registers except %eax must be saved (but ptrace may violate that)
222 * Arguments are zero extended. For system calls that want sign extension and
223 * take long arguments a wrapper is needed. Most calls can just be called
225 * Assumes it is only called from user space and entered with interrupts off.
235 /* note the registers are not zero extended to the sf.
236 this could be a problem. */
238 GET_THREAD_INFO(%r10)
239 testl $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT),threadinfo_flags(%r10)
242 cmpl $(IA32_NR_syscalls),%eax
245 call *ia32_sys_call_table(,%rax,8) # xxx: rip relative
247 movq %rax,RAX-ARGOFFSET(%rsp)
248 jmp int_ret_from_sys_call
252 movq $-ENOSYS,RAX(%rsp) /* really needed? */
253 movq %rsp,%rdi /* &pt_regs -> arg1 */
254 call syscall_trace_enter
255 LOAD_ARGS ARGOFFSET /* reload args from stack in case ptrace changed it */
260 movq $0,ORIG_RAX-ARGOFFSET(%rsp)
261 movq $-ENOSYS,RAX-ARGOFFSET(%rsp)
262 jmp int_ret_from_sys_call
273 .macro PTREGSCALL label, func, arg
276 leaq \func(%rip),%rax
277 leaq -ARGOFFSET+8(%rsp),\arg /* 8 for return address */
278 jmp ia32_ptregs_common
281 PTREGSCALL stub32_rt_sigreturn, sys32_rt_sigreturn, %rdi
282 PTREGSCALL stub32_sigreturn, sys32_sigreturn, %rdi
283 PTREGSCALL stub32_sigaltstack, sys32_sigaltstack, %rdx
284 PTREGSCALL stub32_sigsuspend, sys32_sigsuspend, %rcx
285 PTREGSCALL stub32_execve, sys32_execve, %rcx
286 PTREGSCALL stub32_fork, sys_fork, %rdi
287 PTREGSCALL stub32_clone, sys32_clone, %rdx
288 PTREGSCALL stub32_vfork, sys_vfork, %rdi
289 PTREGSCALL stub32_iopl, sys_iopl, %rsi
290 PTREGSCALL stub32_rt_sigsuspend, sys_rt_sigsuspend, %rdx
292 ENTRY(ia32_ptregs_common)
298 jmp ia32_sysret /* misbalances the return cache */
303 .globl ia32_sys_call_table
305 .quad sys_restart_syscall
310 .quad sys32_open /* 5 */
315 .quad sys_unlink /* 10 */
320 .quad sys_chmod /* 15 */
322 .quad quiet_ni_syscall /* old break syscall holder */
325 .quad sys_getpid /* 20 */
326 .quad compat_sys_mount /* mount */
327 .quad sys_oldumount /* old_umount */
330 .quad sys_stime /* stime */ /* 25 */
331 .quad sys32_ptrace /* ptrace */
333 .quad sys_fstat /* (old)fstat */
335 .quad compat_sys_utime /* 30 */
336 .quad quiet_ni_syscall /* old stty syscall holder */
337 .quad quiet_ni_syscall /* old gtty syscall holder */
340 .quad quiet_ni_syscall /* 35 */ /* old ftime syscall holder */
345 .quad sys_rmdir /* 40 */
348 .quad compat_sys_times
349 .quad quiet_ni_syscall /* old prof syscall holder */
350 .quad sys_brk /* 45 */
355 .quad sys_getegid16 /* 50 */
357 .quad sys_umount /* new_umount */
358 .quad quiet_ni_syscall /* old lock syscall holder */
359 .quad compat_sys_ioctl
360 .quad compat_sys_fcntl64 /* 55 */
361 .quad quiet_ni_syscall /* old mpx syscall holder */
363 .quad quiet_ni_syscall /* old ulimit syscall holder */
365 .quad sys_umask /* 60 */
370 .quad sys_getpgrp /* 65 */
372 .quad sys32_sigaction
375 .quad sys_setreuid16 /* 70 */
377 .quad stub32_sigsuspend
378 .quad compat_sys_sigpending
379 .quad sys_sethostname
380 .quad compat_sys_setrlimit /* 75 */
381 .quad compat_sys_old_getrlimit /* old_getrlimit */
382 .quad compat_sys_getrusage
383 .quad sys32_gettimeofday
384 .quad sys32_settimeofday
385 .quad sys_getgroups16 /* 80 */
386 .quad sys_setgroups16
387 .quad sys32_old_select
390 .quad sys_readlink /* 85 */
394 .quad sys32_oldreaddir
395 .quad sys32_mmap /* 90 */
400 .quad sys_fchown16 /* 95 */
401 .quad sys_getpriority
402 .quad sys_setpriority
403 .quad quiet_ni_syscall /* old profil syscall holder */
404 .quad compat_sys_statfs
405 .quad compat_sys_fstatfs /* 100 */
407 .quad compat_sys_socketcall
409 .quad compat_sys_setitimer
410 .quad compat_sys_getitimer /* 105 */
411 .quad compat_sys_newstat
412 .quad compat_sys_newlstat
413 .quad compat_sys_newfstat
415 .quad stub32_iopl /* 110 */
417 .quad quiet_ni_syscall /* old "idle" system call */
418 .quad sys32_vm86_warning /* vm86old */
419 .quad compat_sys_wait4
420 .quad sys_swapoff /* 115 */
424 .quad stub32_sigreturn
425 .quad stub32_clone /* 120 */
426 .quad sys_setdomainname
430 .quad sys32_mprotect /* 125 */
431 .quad compat_sys_sigprocmask
432 .quad quiet_ni_syscall /* create_module */
433 .quad sys_init_module
434 .quad sys_delete_module
435 .quad quiet_ni_syscall /* 130 get_kernel_syms */
436 .quad sys32_quotactl /* quotactl */
439 .quad quiet_ni_syscall /* bdflush */
440 .quad sys_sysfs /* 135 */
441 .quad sys_personality
442 .quad quiet_ni_syscall /* for afs_syscall */
445 .quad sys_llseek /* 140 */
447 .quad compat_sys_select
450 .quad compat_sys_readv /* 145 */
451 .quad compat_sys_writev
454 .quad sys32_sysctl /* sysctl */
455 .quad sys_mlock /* 150 */
459 .quad sys_sched_setparam
460 .quad sys_sched_getparam /* 155 */
461 .quad sys_sched_setscheduler
462 .quad sys_sched_getscheduler
463 .quad sys_sched_yield
464 .quad sys_sched_get_priority_max
465 .quad sys_sched_get_priority_min /* 160 */
466 .quad sys_sched_rr_get_interval
467 .quad compat_sys_nanosleep
469 .quad sys_setresuid16
470 .quad sys_getresuid16 /* 165 */
471 .quad sys32_vm86_warning /* vm86 */
472 .quad quiet_ni_syscall /* query_module */
474 .quad compat_sys_nfsservctl
475 .quad sys_setresgid16 /* 170 */
476 .quad sys_getresgid16
478 .quad stub32_rt_sigreturn
479 .quad sys32_rt_sigaction
480 .quad sys32_rt_sigprocmask /* 175 */
481 .quad sys32_rt_sigpending
482 .quad sys32_rt_sigtimedwait
483 .quad sys32_rt_sigqueueinfo
484 .quad stub32_rt_sigsuspend
485 .quad sys32_pread /* 180 */
491 .quad stub32_sigaltstack
493 .quad quiet_ni_syscall /* streams1 */
494 .quad quiet_ni_syscall /* streams2 */
495 .quad stub32_vfork /* 190 */
496 .quad compat_sys_getrlimit
498 .quad sys32_truncate64
499 .quad sys32_ftruncate64
500 .quad sys32_stat64 /* 195 */
505 .quad sys_getgid /* 200 */
510 .quad sys_getgroups /* 205 */
515 .quad sys_setresgid /* 210 */
520 .quad sys_setfsuid /* 215 */
525 .quad sys_getdents64 /* 220 getdents64 */
526 .quad compat_sys_fcntl64
527 .quad quiet_ni_syscall /* tux */
528 .quad quiet_ni_syscall /* security */
530 .quad sys_readahead /* 225 */
535 .quad sys_lgetxattr /* 230 */
540 .quad sys_removexattr /* 235 */
541 .quad sys_lremovexattr
542 .quad sys_fremovexattr
545 .quad compat_sys_futex /* 240 */
546 .quad compat_sys_sched_setaffinity
547 .quad compat_sys_sched_getaffinity
548 .quad sys32_set_thread_area
549 .quad sys32_get_thread_area
550 .quad sys32_io_setup /* 245 */
552 .quad sys32_io_getevents
553 .quad sys32_io_submit
555 .quad sys_fadvise64 /* 250 */
556 .quad quiet_ni_syscall /* free_huge_pages */
558 .quad sys32_lookup_dcookie
559 .quad sys_epoll_create
560 .quad sys_epoll_ctl /* 255 */
562 .quad sys_remap_file_pages
563 .quad sys_set_tid_address
564 .quad sys32_timer_create
565 .quad compat_timer_settime /* 260 */
566 .quad compat_timer_gettime
567 .quad sys_timer_getoverrun
568 .quad sys_timer_delete
569 .quad compat_clock_settime
570 .quad compat_clock_gettime /* 265 */
571 .quad compat_clock_getres
572 .quad compat_clock_nanosleep
573 .quad compat_statfs64
574 .quad compat_fstatfs64
575 .quad sys_tgkill /* 270 */
576 .quad compat_sys_utimes
577 .quad sys32_fadvise64_64
578 .quad quiet_ni_syscall /* sys_vserver */
580 .quad compat_get_mempolicy /* 275 */
581 .quad sys_set_mempolicy
582 .quad compat_sys_mq_open
584 .quad compat_sys_mq_timedsend
585 .quad compat_sys_mq_timedreceive /* 280 */
586 .quad compat_sys_mq_notify
587 .quad compat_sys_mq_getsetattr
588 .quad quiet_ni_syscall /* reserved for kexec */
590 /* don't forget to change IA32_NR_syscalls */
592 .rept IA32_NR_syscalls-(ia32_syscall_end-ia32_sys_call_table)/8