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|_TIF_SECCOMP),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|_TIF_SECCOMP),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|_TIF_SECCOMP),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 */
318 .quad compat_sys_time
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 compat_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 */
391 #ifdef CONFIG_IA32_AOUT
394 .quad quiet_ni_syscall
398 .quad compat_sys_old_readdir
399 .quad sys32_mmap /* 90 */
404 .quad sys_fchown16 /* 95 */
405 .quad sys_getpriority
406 .quad sys_setpriority
407 .quad quiet_ni_syscall /* old profil syscall holder */
408 .quad compat_sys_statfs
409 .quad compat_sys_fstatfs /* 100 */
411 .quad compat_sys_socketcall
413 .quad compat_sys_setitimer
414 .quad compat_sys_getitimer /* 105 */
415 .quad compat_sys_newstat
416 .quad compat_sys_newlstat
417 .quad compat_sys_newfstat
419 .quad stub32_iopl /* 110 */
421 .quad quiet_ni_syscall /* old "idle" system call */
422 .quad sys32_vm86_warning /* vm86old */
423 .quad compat_sys_wait4
424 .quad sys_swapoff /* 115 */
428 .quad stub32_sigreturn
429 .quad stub32_clone /* 120 */
430 .quad sys_setdomainname
434 .quad sys32_mprotect /* 125 */
435 .quad compat_sys_sigprocmask
436 .quad quiet_ni_syscall /* create_module */
437 .quad sys_init_module
438 .quad sys_delete_module
439 .quad quiet_ni_syscall /* 130 get_kernel_syms */
443 .quad quiet_ni_syscall /* bdflush */
444 .quad sys_sysfs /* 135 */
445 .quad sys_personality
446 .quad quiet_ni_syscall /* for afs_syscall */
449 .quad sys_llseek /* 140 */
450 .quad compat_sys_getdents
451 .quad compat_sys_select
454 .quad compat_sys_readv /* 145 */
455 .quad compat_sys_writev
458 .quad sys32_sysctl /* sysctl */
459 .quad sys_mlock /* 150 */
463 .quad sys_sched_setparam
464 .quad sys_sched_getparam /* 155 */
465 .quad sys_sched_setscheduler
466 .quad sys_sched_getscheduler
467 .quad sys_sched_yield
468 .quad sys_sched_get_priority_max
469 .quad sys_sched_get_priority_min /* 160 */
470 .quad sys_sched_rr_get_interval
471 .quad compat_sys_nanosleep
473 .quad sys_setresuid16
474 .quad sys_getresuid16 /* 165 */
475 .quad sys32_vm86_warning /* vm86 */
476 .quad quiet_ni_syscall /* query_module */
478 .quad compat_sys_nfsservctl
479 .quad sys_setresgid16 /* 170 */
480 .quad sys_getresgid16
482 .quad stub32_rt_sigreturn
483 .quad sys32_rt_sigaction
484 .quad sys32_rt_sigprocmask /* 175 */
485 .quad sys32_rt_sigpending
486 .quad compat_sys_rt_sigtimedwait
487 .quad sys32_rt_sigqueueinfo
488 .quad stub32_rt_sigsuspend
489 .quad sys32_pread /* 180 */
495 .quad stub32_sigaltstack
497 .quad quiet_ni_syscall /* streams1 */
498 .quad quiet_ni_syscall /* streams2 */
499 .quad stub32_vfork /* 190 */
500 .quad compat_sys_getrlimit
502 .quad sys32_truncate64
503 .quad sys32_ftruncate64
504 .quad sys32_stat64 /* 195 */
509 .quad sys_getgid /* 200 */
514 .quad sys_getgroups /* 205 */
519 .quad sys_setresgid /* 210 */
524 .quad sys_setfsuid /* 215 */
529 .quad compat_sys_getdents64 /* 220 getdents64 */
530 .quad compat_sys_fcntl64
531 .quad quiet_ni_syscall /* tux */
532 .quad quiet_ni_syscall /* security */
534 .quad sys_readahead /* 225 */
539 .quad sys_lgetxattr /* 230 */
544 .quad sys_removexattr /* 235 */
545 .quad sys_lremovexattr
546 .quad sys_fremovexattr
549 .quad compat_sys_futex /* 240 */
550 .quad compat_sys_sched_setaffinity
551 .quad compat_sys_sched_getaffinity
552 .quad sys32_set_thread_area
553 .quad sys32_get_thread_area
554 .quad compat_sys_io_setup /* 245 */
556 .quad compat_sys_io_getevents
557 .quad compat_sys_io_submit
559 .quad sys_fadvise64 /* 250 */
560 .quad quiet_ni_syscall /* free_huge_pages */
562 .quad sys32_lookup_dcookie
563 .quad sys_epoll_create
564 .quad sys_epoll_ctl /* 255 */
566 .quad sys_remap_file_pages
567 .quad sys_set_tid_address
568 .quad sys32_timer_create
569 .quad compat_sys_timer_settime /* 260 */
570 .quad compat_sys_timer_gettime
571 .quad sys_timer_getoverrun
572 .quad sys_timer_delete
573 .quad compat_sys_clock_settime
574 .quad compat_sys_clock_gettime /* 265 */
575 .quad compat_sys_clock_getres
576 .quad compat_sys_clock_nanosleep
577 .quad compat_sys_statfs64
578 .quad compat_sys_fstatfs64
579 .quad sys_tgkill /* 270 */
580 .quad compat_sys_utimes
581 .quad sys32_fadvise64_64
582 .quad quiet_ni_syscall /* sys_vserver */
584 .quad compat_sys_get_mempolicy /* 275 */
585 .quad sys_set_mempolicy
586 .quad compat_sys_mq_open
588 .quad compat_sys_mq_timedsend
589 .quad compat_sys_mq_timedreceive /* 280 */
590 .quad compat_sys_mq_notify
591 .quad compat_sys_mq_getsetattr
592 .quad compat_sys_kexec_load /* reserved for kexec */
593 .quad compat_sys_waitid
594 .quad quiet_ni_syscall /* sys_altroot */
596 .quad sys_request_key
598 /* don't forget to change IA32_NR_syscalls */
600 .rept IA32_NR_syscalls-(ia32_syscall_end-ia32_sys_call_table)/8