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/asm-offsets.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 #define IA32_NR_syscalls ((ia32_syscall_end - ia32_sys_call_table)/8)
20 .macro IA32_ARG_FIXUP noebp=0
28 movl %edx,%edx /* zero extension */
40 .macro CFI_STARTPROC32 simple
53 * 32bit SYSENTER instruction entry.
56 * %eax System call number.
67 * This is purely a fast path. For anything complicated we use the int 0x80
68 * path below. Set up a complete hardware stack frame to share code
69 * with the int 0x80 path.
71 ENTRY(ia32_sysenter_target)
72 CFI_STARTPROC32 simple
76 movq %gs:pda_kernelstack, %rsp
77 addq $(PDA_STACKOFFSET),%rsp
79 movl %ebp,%ebp /* zero extension */
81 CFI_ADJUST_CFA_OFFSET 8
82 /*CFI_REL_OFFSET ss,0*/
84 CFI_ADJUST_CFA_OFFSET 8
87 CFI_ADJUST_CFA_OFFSET 8
88 /*CFI_REL_OFFSET rflags,0*/
89 movl $VSYSCALL32_SYSEXIT, %r10d
92 CFI_ADJUST_CFA_OFFSET 8
93 /*CFI_REL_OFFSET cs,0*/
96 CFI_ADJUST_CFA_OFFSET 8
99 CFI_ADJUST_CFA_OFFSET 8
102 /* no need to do an access_ok check here because rbp has been
103 32bit zero extended */
105 .section __ex_table,"a"
108 GET_THREAD_INFO(%r10)
109 orl $TS_COMPAT,threadinfo_status(%r10)
110 testl $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP),threadinfo_flags(%r10)
112 jnz sysenter_tracesys
114 cmpl $(IA32_NR_syscalls-1),%eax
117 call *ia32_sys_call_table(,%rax,8)
118 movq %rax,RAX-ARGOFFSET(%rsp)
119 GET_THREAD_INFO(%r10)
121 testl $_TIF_ALLWORK_MASK,threadinfo_flags(%r10)
122 jnz int_ret_from_sys_call
123 andl $~TS_COMPAT,threadinfo_status(%r10)
124 /* clear IF, that popfq doesn't enable interrupts early */
125 andl $~0x200,EFLAGS-R11(%rsp)
126 RESTORE_ARGS 1,24,1,1,1,1
128 CFI_ADJUST_CFA_OFFSET -8
129 /*CFI_RESTORE rflags*/
130 popq %rcx /* User %esp */
131 CFI_ADJUST_CFA_OFFSET -8
133 movl $VSYSCALL32_SYSEXIT,%edx /* User %eip */
136 sti /* sti only takes effect after the next instruction */
144 movq $-ENOSYS,RAX(%rsp) /* really needed? */
145 movq %rsp,%rdi /* &pt_regs -> arg1 */
146 call syscall_trace_enter
147 LOAD_ARGS ARGOFFSET /* reload args from stack in case ptrace changed it */
150 /* no need to do an access_ok check here because rbp has been
151 32bit zero extended */
153 .section __ex_table,"a"
160 * 32bit SYSCALL instruction entry.
163 * %eax System call number.
169 * %ebp Arg2 [note: not saved in the stack frame, should not be touched]
175 * This is purely a fast path. For anything complicated we use the int 0x80
176 * path below. Set up a complete hardware stack frame to share code
177 * with the int 0x80 path.
179 ENTRY(ia32_cstar_target)
180 CFI_STARTPROC32 simple
183 /*CFI_REGISTER rflags,r11*/
187 movq %gs:pda_kernelstack,%rsp
190 movl %eax,%eax /* zero extension */
191 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
192 movq %rcx,RIP-ARGOFFSET(%rsp)
193 CFI_REL_OFFSET rip,RIP-ARGOFFSET
194 movq %rbp,RCX-ARGOFFSET(%rsp) /* this lies slightly to ptrace */
196 movq $__USER32_CS,CS-ARGOFFSET(%rsp)
197 movq $__USER32_DS,SS-ARGOFFSET(%rsp)
198 movq %r11,EFLAGS-ARGOFFSET(%rsp)
199 /*CFI_REL_OFFSET rflags,EFLAGS-ARGOFFSET*/
200 movq %r8,RSP-ARGOFFSET(%rsp)
201 CFI_REL_OFFSET rsp,RSP-ARGOFFSET
202 /* no need to do an access_ok check here because r8 has been
203 32bit zero extended */
204 /* hardware stack frame is complete now */
206 .section __ex_table,"a"
209 GET_THREAD_INFO(%r10)
210 orl $TS_COMPAT,threadinfo_status(%r10)
211 testl $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP),threadinfo_flags(%r10)
215 cmpl $IA32_NR_syscalls-1,%eax
218 call *ia32_sys_call_table(,%rax,8)
219 movq %rax,RAX-ARGOFFSET(%rsp)
220 GET_THREAD_INFO(%r10)
222 testl $_TIF_ALLWORK_MASK,threadinfo_flags(%r10)
223 jnz int_ret_from_sys_call
224 andl $~TS_COMPAT,threadinfo_status(%r10)
225 RESTORE_ARGS 1,-ARG_SKIP,1,1,1
226 movl RIP-ARGOFFSET(%rsp),%ecx
228 movl EFLAGS-ARGOFFSET(%rsp),%r11d
229 /*CFI_REGISTER rflags,r11*/
230 movl RSP-ARGOFFSET(%rsp),%esp
239 movq $-ENOSYS,RAX(%rsp) /* really needed? */
240 movq %rsp,%rdi /* &pt_regs -> arg1 */
241 call syscall_trace_enter
242 LOAD_ARGS ARGOFFSET /* reload args from stack in case ptrace changed it */
244 movl RSP-ARGOFFSET(%rsp), %r8d
245 /* no need to do an access_ok check here because r8 has been
246 32bit zero extended */
248 .section __ex_table,"a"
259 * Emulated IA32 system calls via int 0x80.
262 * %eax System call number.
268 * %ebp Arg6 [note: not saved in the stack frame, should not be touched]
271 * Uses the same stack frame as the x86-64 version.
272 * All registers except %eax must be saved (but ptrace may violate that)
273 * Arguments are zero extended. For system calls that want sign extension and
274 * take long arguments a wrapper is needed. Most calls can just be called
276 * Assumes it is only called from user space and entered with interrupts off.
281 CFI_DEF_CFA rsp,SS+8-RIP
282 /*CFI_REL_OFFSET ss,SS-RIP*/
283 CFI_REL_OFFSET rsp,RSP-RIP
284 /*CFI_REL_OFFSET rflags,EFLAGS-RIP*/
285 /*CFI_REL_OFFSET cs,CS-RIP*/
286 CFI_REL_OFFSET rip,RIP-RIP
291 CFI_ADJUST_CFA_OFFSET 8
293 /* note the registers are not zero extended to the sf.
294 this could be a problem. */
296 GET_THREAD_INFO(%r10)
297 orl $TS_COMPAT,threadinfo_status(%r10)
298 testl $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP),threadinfo_flags(%r10)
301 cmpl $(IA32_NR_syscalls-1),%eax
304 call *ia32_sys_call_table(,%rax,8) # xxx: rip relative
306 movq %rax,RAX-ARGOFFSET(%rsp)
307 jmp int_ret_from_sys_call
311 movq $-ENOSYS,RAX(%rsp) /* really needed? */
312 movq %rsp,%rdi /* &pt_regs -> arg1 */
313 call syscall_trace_enter
314 LOAD_ARGS ARGOFFSET /* reload args from stack in case ptrace changed it */
319 movq $0,ORIG_RAX-ARGOFFSET(%rsp)
320 movq $-ENOSYS,RAX-ARGOFFSET(%rsp)
321 jmp int_ret_from_sys_call
332 .macro PTREGSCALL label, func, arg
335 leaq \func(%rip),%rax
336 leaq -ARGOFFSET+8(%rsp),\arg /* 8 for return address */
337 jmp ia32_ptregs_common
342 PTREGSCALL stub32_rt_sigreturn, sys32_rt_sigreturn, %rdi
343 PTREGSCALL stub32_sigreturn, sys32_sigreturn, %rdi
344 PTREGSCALL stub32_sigaltstack, sys32_sigaltstack, %rdx
345 PTREGSCALL stub32_sigsuspend, sys32_sigsuspend, %rcx
346 PTREGSCALL stub32_execve, sys32_execve, %rcx
347 PTREGSCALL stub32_fork, sys_fork, %rdi
348 PTREGSCALL stub32_clone, sys32_clone, %rdx
349 PTREGSCALL stub32_vfork, sys_vfork, %rdi
350 PTREGSCALL stub32_iopl, sys_iopl, %rsi
351 PTREGSCALL stub32_rt_sigsuspend, sys_rt_sigsuspend, %rdx
353 ENTRY(ia32_ptregs_common)
356 CFI_STARTPROC32 simple
357 CFI_DEF_CFA rsp,SS+8-ARGOFFSET
358 CFI_REL_OFFSET rax,RAX-ARGOFFSET
359 CFI_REL_OFFSET rcx,RCX-ARGOFFSET
360 CFI_REL_OFFSET rdx,RDX-ARGOFFSET
361 CFI_REL_OFFSET rsi,RSI-ARGOFFSET
362 CFI_REL_OFFSET rdi,RDI-ARGOFFSET
363 CFI_REL_OFFSET rip,RIP-ARGOFFSET
364 /* CFI_REL_OFFSET cs,CS-ARGOFFSET*/
365 /* CFI_REL_OFFSET rflags,EFLAGS-ARGOFFSET*/
366 CFI_REL_OFFSET rsp,RSP-ARGOFFSET
367 /* CFI_REL_OFFSET ss,SS-ARGOFFSET*/
371 jmp ia32_sysret /* misbalances the return cache */
376 .globl ia32_sys_call_table
378 .quad sys_restart_syscall
383 .quad compat_sys_open /* 5 */
388 .quad sys_unlink /* 10 */
391 .quad compat_sys_time
393 .quad sys_chmod /* 15 */
395 .quad quiet_ni_syscall /* old break syscall holder */
398 .quad sys_getpid /* 20 */
399 .quad compat_sys_mount /* mount */
400 .quad sys_oldumount /* old_umount */
403 .quad compat_sys_stime /* stime */ /* 25 */
404 .quad sys32_ptrace /* ptrace */
406 .quad sys_fstat /* (old)fstat */
408 .quad compat_sys_utime /* 30 */
409 .quad quiet_ni_syscall /* old stty syscall holder */
410 .quad quiet_ni_syscall /* old gtty syscall holder */
413 .quad quiet_ni_syscall /* 35 */ /* old ftime syscall holder */
418 .quad sys_rmdir /* 40 */
421 .quad compat_sys_times
422 .quad quiet_ni_syscall /* old prof syscall holder */
423 .quad sys_brk /* 45 */
428 .quad sys_getegid16 /* 50 */
430 .quad sys_umount /* new_umount */
431 .quad quiet_ni_syscall /* old lock syscall holder */
432 .quad compat_sys_ioctl
433 .quad compat_sys_fcntl64 /* 55 */
434 .quad quiet_ni_syscall /* old mpx syscall holder */
436 .quad quiet_ni_syscall /* old ulimit syscall holder */
438 .quad sys_umask /* 60 */
443 .quad sys_getpgrp /* 65 */
445 .quad sys32_sigaction
448 .quad sys_setreuid16 /* 70 */
450 .quad stub32_sigsuspend
451 .quad compat_sys_sigpending
452 .quad sys_sethostname
453 .quad compat_sys_setrlimit /* 75 */
454 .quad compat_sys_old_getrlimit /* old_getrlimit */
455 .quad compat_sys_getrusage
456 .quad sys32_gettimeofday
457 .quad sys32_settimeofday
458 .quad sys_getgroups16 /* 80 */
459 .quad sys_setgroups16
460 .quad sys32_old_select
463 .quad sys_readlink /* 85 */
464 #ifdef CONFIG_IA32_AOUT
467 .quad quiet_ni_syscall
471 .quad compat_sys_old_readdir
472 .quad sys32_mmap /* 90 */
477 .quad sys_fchown16 /* 95 */
478 .quad sys_getpriority
479 .quad sys_setpriority
480 .quad quiet_ni_syscall /* old profil syscall holder */
481 .quad compat_sys_statfs
482 .quad compat_sys_fstatfs /* 100 */
484 .quad compat_sys_socketcall
486 .quad compat_sys_setitimer
487 .quad compat_sys_getitimer /* 105 */
488 .quad compat_sys_newstat
489 .quad compat_sys_newlstat
490 .quad compat_sys_newfstat
492 .quad stub32_iopl /* 110 */
494 .quad quiet_ni_syscall /* old "idle" system call */
495 .quad sys32_vm86_warning /* vm86old */
496 .quad compat_sys_wait4
497 .quad sys_swapoff /* 115 */
501 .quad stub32_sigreturn
502 .quad stub32_clone /* 120 */
503 .quad sys_setdomainname
506 .quad compat_sys_adjtimex
507 .quad sys32_mprotect /* 125 */
508 .quad compat_sys_sigprocmask
509 .quad quiet_ni_syscall /* create_module */
510 .quad sys_init_module
511 .quad sys_delete_module
512 .quad quiet_ni_syscall /* 130 get_kernel_syms */
516 .quad quiet_ni_syscall /* bdflush */
517 .quad sys_sysfs /* 135 */
518 .quad sys_personality
519 .quad quiet_ni_syscall /* for afs_syscall */
522 .quad sys_llseek /* 140 */
523 .quad compat_sys_getdents
524 .quad compat_sys_select
527 .quad compat_sys_readv /* 145 */
528 .quad compat_sys_writev
531 .quad sys32_sysctl /* sysctl */
532 .quad sys_mlock /* 150 */
536 .quad sys_sched_setparam
537 .quad sys_sched_getparam /* 155 */
538 .quad sys_sched_setscheduler
539 .quad sys_sched_getscheduler
540 .quad sys_sched_yield
541 .quad sys_sched_get_priority_max
542 .quad sys_sched_get_priority_min /* 160 */
543 .quad sys_sched_rr_get_interval
544 .quad compat_sys_nanosleep
546 .quad sys_setresuid16
547 .quad sys_getresuid16 /* 165 */
548 .quad sys32_vm86_warning /* vm86 */
549 .quad quiet_ni_syscall /* query_module */
551 .quad compat_sys_nfsservctl
552 .quad sys_setresgid16 /* 170 */
553 .quad sys_getresgid16
555 .quad stub32_rt_sigreturn
556 .quad sys32_rt_sigaction
557 .quad sys32_rt_sigprocmask /* 175 */
558 .quad sys32_rt_sigpending
559 .quad compat_sys_rt_sigtimedwait
560 .quad sys32_rt_sigqueueinfo
561 .quad stub32_rt_sigsuspend
562 .quad sys32_pread /* 180 */
568 .quad stub32_sigaltstack
570 .quad quiet_ni_syscall /* streams1 */
571 .quad quiet_ni_syscall /* streams2 */
572 .quad stub32_vfork /* 190 */
573 .quad compat_sys_getrlimit
575 .quad sys32_truncate64
576 .quad sys32_ftruncate64
577 .quad sys32_stat64 /* 195 */
582 .quad sys_getgid /* 200 */
587 .quad sys_getgroups /* 205 */
592 .quad sys_setresgid /* 210 */
597 .quad sys_setfsuid /* 215 */
602 .quad compat_sys_getdents64 /* 220 getdents64 */
603 .quad compat_sys_fcntl64
604 .quad quiet_ni_syscall /* tux */
605 .quad quiet_ni_syscall /* security */
607 .quad sys_readahead /* 225 */
612 .quad sys_lgetxattr /* 230 */
617 .quad sys_removexattr /* 235 */
618 .quad sys_lremovexattr
619 .quad sys_fremovexattr
622 .quad compat_sys_futex /* 240 */
623 .quad compat_sys_sched_setaffinity
624 .quad compat_sys_sched_getaffinity
625 .quad sys32_set_thread_area
626 .quad sys32_get_thread_area
627 .quad compat_sys_io_setup /* 245 */
629 .quad compat_sys_io_getevents
630 .quad compat_sys_io_submit
632 .quad sys_fadvise64 /* 250 */
633 .quad quiet_ni_syscall /* free_huge_pages */
635 .quad sys32_lookup_dcookie
636 .quad sys_epoll_create
637 .quad sys_epoll_ctl /* 255 */
639 .quad sys_remap_file_pages
640 .quad sys_set_tid_address
641 .quad compat_sys_timer_create
642 .quad compat_sys_timer_settime /* 260 */
643 .quad compat_sys_timer_gettime
644 .quad sys_timer_getoverrun
645 .quad sys_timer_delete
646 .quad compat_sys_clock_settime
647 .quad compat_sys_clock_gettime /* 265 */
648 .quad compat_sys_clock_getres
649 .quad compat_sys_clock_nanosleep
650 .quad compat_sys_statfs64
651 .quad compat_sys_fstatfs64
652 .quad sys_tgkill /* 270 */
653 .quad compat_sys_utimes
654 .quad sys32_fadvise64_64
655 .quad quiet_ni_syscall /* sys_vserver */
657 .quad compat_sys_get_mempolicy /* 275 */
658 .quad sys_set_mempolicy
659 .quad compat_sys_mq_open
661 .quad compat_sys_mq_timedsend
662 .quad compat_sys_mq_timedreceive /* 280 */
663 .quad compat_sys_mq_notify
664 .quad compat_sys_mq_getsetattr
665 .quad compat_sys_kexec_load /* reserved for kexec */
666 .quad compat_sys_waitid
667 .quad quiet_ni_syscall /* 285: sys_altroot */
669 .quad sys_request_key
672 .quad sys_ioprio_get /* 290 */
673 .quad sys_inotify_init
674 .quad sys_inotify_add_watch
675 .quad sys_inotify_rm_watch
676 .quad sys_migrate_pages
677 .quad compat_sys_openat /* 295 */
681 .quad compat_sys_futimesat
682 .quad sys32_fstatat /* 300 */
687 .quad sys_readlinkat /* 305 */
690 .quad quiet_ni_syscall /* pselect6 for now */
691 .quad quiet_ni_syscall /* ppoll for now */
692 .quad sys_unshare /* 310 */
693 .quad compat_sys_set_robust_list
694 .quad compat_sys_get_robust_list
696 .quad sys_sync_file_range
698 .quad compat_sys_vmsplice