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"
158 ENDPROC(ia32_sysenter_target)
161 * 32bit SYSCALL instruction entry.
164 * %eax System call number.
170 * %ebp Arg2 [note: not saved in the stack frame, should not be touched]
176 * This is purely a fast path. For anything complicated we use the int 0x80
177 * path below. Set up a complete hardware stack frame to share code
178 * with the int 0x80 path.
180 ENTRY(ia32_cstar_target)
181 CFI_STARTPROC32 simple
184 /*CFI_REGISTER rflags,r11*/
188 movq %gs:pda_kernelstack,%rsp
191 movl %eax,%eax /* zero extension */
192 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
193 movq %rcx,RIP-ARGOFFSET(%rsp)
194 CFI_REL_OFFSET rip,RIP-ARGOFFSET
195 movq %rbp,RCX-ARGOFFSET(%rsp) /* this lies slightly to ptrace */
197 movq $__USER32_CS,CS-ARGOFFSET(%rsp)
198 movq $__USER32_DS,SS-ARGOFFSET(%rsp)
199 movq %r11,EFLAGS-ARGOFFSET(%rsp)
200 /*CFI_REL_OFFSET rflags,EFLAGS-ARGOFFSET*/
201 movq %r8,RSP-ARGOFFSET(%rsp)
202 CFI_REL_OFFSET rsp,RSP-ARGOFFSET
203 /* no need to do an access_ok check here because r8 has been
204 32bit zero extended */
205 /* hardware stack frame is complete now */
207 .section __ex_table,"a"
210 GET_THREAD_INFO(%r10)
211 orl $TS_COMPAT,threadinfo_status(%r10)
212 testl $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP),threadinfo_flags(%r10)
216 cmpl $IA32_NR_syscalls-1,%eax
219 call *ia32_sys_call_table(,%rax,8)
220 movq %rax,RAX-ARGOFFSET(%rsp)
221 GET_THREAD_INFO(%r10)
223 testl $_TIF_ALLWORK_MASK,threadinfo_flags(%r10)
224 jnz int_ret_from_sys_call
225 andl $~TS_COMPAT,threadinfo_status(%r10)
226 RESTORE_ARGS 1,-ARG_SKIP,1,1,1
227 movl RIP-ARGOFFSET(%rsp),%ecx
229 movl EFLAGS-ARGOFFSET(%rsp),%r11d
230 /*CFI_REGISTER rflags,r11*/
231 movl RSP-ARGOFFSET(%rsp),%esp
240 movq $-ENOSYS,RAX(%rsp) /* really needed? */
241 movq %rsp,%rdi /* &pt_regs -> arg1 */
242 call syscall_trace_enter
243 LOAD_ARGS ARGOFFSET /* reload args from stack in case ptrace changed it */
245 movl RSP-ARGOFFSET(%rsp), %r8d
246 /* no need to do an access_ok check here because r8 has been
247 32bit zero extended */
249 .section __ex_table,"a"
253 END(ia32_cstar_target)
261 * Emulated IA32 system calls via int 0x80.
264 * %eax System call number.
270 * %ebp Arg6 [note: not saved in the stack frame, should not be touched]
273 * Uses the same stack frame as the x86-64 version.
274 * All registers except %eax must be saved (but ptrace may violate that)
275 * Arguments are zero extended. For system calls that want sign extension and
276 * take long arguments a wrapper is needed. Most calls can just be called
278 * Assumes it is only called from user space and entered with interrupts off.
283 CFI_DEF_CFA rsp,SS+8-RIP
284 /*CFI_REL_OFFSET ss,SS-RIP*/
285 CFI_REL_OFFSET rsp,RSP-RIP
286 /*CFI_REL_OFFSET rflags,EFLAGS-RIP*/
287 /*CFI_REL_OFFSET cs,CS-RIP*/
288 CFI_REL_OFFSET rip,RIP-RIP
293 CFI_ADJUST_CFA_OFFSET 8
295 /* note the registers are not zero extended to the sf.
296 this could be a problem. */
298 GET_THREAD_INFO(%r10)
299 orl $TS_COMPAT,threadinfo_status(%r10)
300 testl $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP),threadinfo_flags(%r10)
303 cmpl $(IA32_NR_syscalls-1),%eax
306 call *ia32_sys_call_table(,%rax,8) # xxx: rip relative
308 movq %rax,RAX-ARGOFFSET(%rsp)
309 jmp int_ret_from_sys_call
313 movq $-ENOSYS,RAX(%rsp) /* really needed? */
314 movq %rsp,%rdi /* &pt_regs -> arg1 */
315 call syscall_trace_enter
316 LOAD_ARGS ARGOFFSET /* reload args from stack in case ptrace changed it */
322 movq $0,ORIG_RAX-ARGOFFSET(%rsp)
323 movq $-ENOSYS,RAX-ARGOFFSET(%rsp)
324 jmp int_ret_from_sys_call
335 .macro PTREGSCALL label, func, arg
338 leaq \func(%rip),%rax
339 leaq -ARGOFFSET+8(%rsp),\arg /* 8 for return address */
340 jmp ia32_ptregs_common
345 PTREGSCALL stub32_rt_sigreturn, sys32_rt_sigreturn, %rdi
346 PTREGSCALL stub32_sigreturn, sys32_sigreturn, %rdi
347 PTREGSCALL stub32_sigaltstack, sys32_sigaltstack, %rdx
348 PTREGSCALL stub32_sigsuspend, sys32_sigsuspend, %rcx
349 PTREGSCALL stub32_execve, sys32_execve, %rcx
350 PTREGSCALL stub32_fork, sys_fork, %rdi
351 PTREGSCALL stub32_clone, sys32_clone, %rdx
352 PTREGSCALL stub32_vfork, sys_vfork, %rdi
353 PTREGSCALL stub32_iopl, sys_iopl, %rsi
354 PTREGSCALL stub32_rt_sigsuspend, sys_rt_sigsuspend, %rdx
356 ENTRY(ia32_ptregs_common)
359 CFI_STARTPROC32 simple
360 CFI_DEF_CFA rsp,SS+8-ARGOFFSET
361 CFI_REL_OFFSET rax,RAX-ARGOFFSET
362 CFI_REL_OFFSET rcx,RCX-ARGOFFSET
363 CFI_REL_OFFSET rdx,RDX-ARGOFFSET
364 CFI_REL_OFFSET rsi,RSI-ARGOFFSET
365 CFI_REL_OFFSET rdi,RDI-ARGOFFSET
366 CFI_REL_OFFSET rip,RIP-ARGOFFSET
367 /* CFI_REL_OFFSET cs,CS-ARGOFFSET*/
368 /* CFI_REL_OFFSET rflags,EFLAGS-ARGOFFSET*/
369 CFI_REL_OFFSET rsp,RSP-ARGOFFSET
370 /* CFI_REL_OFFSET ss,SS-ARGOFFSET*/
374 jmp ia32_sysret /* misbalances the return cache */
376 END(ia32_ptregs_common)
381 .quad sys_restart_syscall
386 .quad compat_sys_open /* 5 */
391 .quad sys_unlink /* 10 */
394 .quad compat_sys_time
396 .quad sys_chmod /* 15 */
398 .quad quiet_ni_syscall /* old break syscall holder */
401 .quad sys_getpid /* 20 */
402 .quad compat_sys_mount /* mount */
403 .quad sys_oldumount /* old_umount */
406 .quad compat_sys_stime /* stime */ /* 25 */
407 .quad sys32_ptrace /* ptrace */
409 .quad sys_fstat /* (old)fstat */
411 .quad compat_sys_utime /* 30 */
412 .quad quiet_ni_syscall /* old stty syscall holder */
413 .quad quiet_ni_syscall /* old gtty syscall holder */
416 .quad quiet_ni_syscall /* 35 */ /* old ftime syscall holder */
421 .quad sys_rmdir /* 40 */
424 .quad compat_sys_times
425 .quad quiet_ni_syscall /* old prof syscall holder */
426 .quad sys_brk /* 45 */
431 .quad sys_getegid16 /* 50 */
433 .quad sys_umount /* new_umount */
434 .quad quiet_ni_syscall /* old lock syscall holder */
435 .quad compat_sys_ioctl
436 .quad compat_sys_fcntl64 /* 55 */
437 .quad quiet_ni_syscall /* old mpx syscall holder */
439 .quad quiet_ni_syscall /* old ulimit syscall holder */
441 .quad sys_umask /* 60 */
446 .quad sys_getpgrp /* 65 */
448 .quad sys32_sigaction
451 .quad sys_setreuid16 /* 70 */
453 .quad stub32_sigsuspend
454 .quad compat_sys_sigpending
455 .quad sys_sethostname
456 .quad compat_sys_setrlimit /* 75 */
457 .quad compat_sys_old_getrlimit /* old_getrlimit */
458 .quad compat_sys_getrusage
459 .quad sys32_gettimeofday
460 .quad sys32_settimeofday
461 .quad sys_getgroups16 /* 80 */
462 .quad sys_setgroups16
463 .quad sys32_old_select
466 .quad sys_readlink /* 85 */
467 #ifdef CONFIG_IA32_AOUT
470 .quad quiet_ni_syscall
474 .quad compat_sys_old_readdir
475 .quad sys32_mmap /* 90 */
480 .quad sys_fchown16 /* 95 */
481 .quad sys_getpriority
482 .quad sys_setpriority
483 .quad quiet_ni_syscall /* old profil syscall holder */
484 .quad compat_sys_statfs
485 .quad compat_sys_fstatfs /* 100 */
487 .quad compat_sys_socketcall
489 .quad compat_sys_setitimer
490 .quad compat_sys_getitimer /* 105 */
491 .quad compat_sys_newstat
492 .quad compat_sys_newlstat
493 .quad compat_sys_newfstat
495 .quad stub32_iopl /* 110 */
497 .quad quiet_ni_syscall /* old "idle" system call */
498 .quad sys32_vm86_warning /* vm86old */
499 .quad compat_sys_wait4
500 .quad sys_swapoff /* 115 */
504 .quad stub32_sigreturn
505 .quad stub32_clone /* 120 */
506 .quad sys_setdomainname
509 .quad compat_sys_adjtimex
510 .quad sys32_mprotect /* 125 */
511 .quad compat_sys_sigprocmask
512 .quad quiet_ni_syscall /* create_module */
513 .quad sys_init_module
514 .quad sys_delete_module
515 .quad quiet_ni_syscall /* 130 get_kernel_syms */
519 .quad quiet_ni_syscall /* bdflush */
520 .quad sys_sysfs /* 135 */
521 .quad sys_personality
522 .quad quiet_ni_syscall /* for afs_syscall */
525 .quad sys_llseek /* 140 */
526 .quad compat_sys_getdents
527 .quad compat_sys_select
530 .quad compat_sys_readv /* 145 */
531 .quad compat_sys_writev
534 .quad sys32_sysctl /* sysctl */
535 .quad sys_mlock /* 150 */
539 .quad sys_sched_setparam
540 .quad sys_sched_getparam /* 155 */
541 .quad sys_sched_setscheduler
542 .quad sys_sched_getscheduler
543 .quad sys_sched_yield
544 .quad sys_sched_get_priority_max
545 .quad sys_sched_get_priority_min /* 160 */
546 .quad sys_sched_rr_get_interval
547 .quad compat_sys_nanosleep
549 .quad sys_setresuid16
550 .quad sys_getresuid16 /* 165 */
551 .quad sys32_vm86_warning /* vm86 */
552 .quad quiet_ni_syscall /* query_module */
554 .quad compat_sys_nfsservctl
555 .quad sys_setresgid16 /* 170 */
556 .quad sys_getresgid16
558 .quad stub32_rt_sigreturn
559 .quad sys32_rt_sigaction
560 .quad sys32_rt_sigprocmask /* 175 */
561 .quad sys32_rt_sigpending
562 .quad compat_sys_rt_sigtimedwait
563 .quad sys32_rt_sigqueueinfo
564 .quad stub32_rt_sigsuspend
565 .quad sys32_pread /* 180 */
571 .quad stub32_sigaltstack
573 .quad quiet_ni_syscall /* streams1 */
574 .quad quiet_ni_syscall /* streams2 */
575 .quad stub32_vfork /* 190 */
576 .quad compat_sys_getrlimit
578 .quad sys32_truncate64
579 .quad sys32_ftruncate64
580 .quad sys32_stat64 /* 195 */
585 .quad sys_getgid /* 200 */
590 .quad sys_getgroups /* 205 */
595 .quad sys_setresgid /* 210 */
600 .quad sys_setfsuid /* 215 */
605 .quad compat_sys_getdents64 /* 220 getdents64 */
606 .quad compat_sys_fcntl64
607 .quad quiet_ni_syscall /* tux */
608 .quad quiet_ni_syscall /* security */
610 .quad sys_readahead /* 225 */
615 .quad sys_lgetxattr /* 230 */
620 .quad sys_removexattr /* 235 */
621 .quad sys_lremovexattr
622 .quad sys_fremovexattr
625 .quad compat_sys_futex /* 240 */
626 .quad compat_sys_sched_setaffinity
627 .quad compat_sys_sched_getaffinity
628 .quad sys32_set_thread_area
629 .quad sys32_get_thread_area
630 .quad compat_sys_io_setup /* 245 */
632 .quad compat_sys_io_getevents
633 .quad compat_sys_io_submit
635 .quad sys_fadvise64 /* 250 */
636 .quad quiet_ni_syscall /* free_huge_pages */
638 .quad sys32_lookup_dcookie
639 .quad sys_epoll_create
640 .quad sys_epoll_ctl /* 255 */
642 .quad sys_remap_file_pages
643 .quad sys_set_tid_address
644 .quad compat_sys_timer_create
645 .quad compat_sys_timer_settime /* 260 */
646 .quad compat_sys_timer_gettime
647 .quad sys_timer_getoverrun
648 .quad sys_timer_delete
649 .quad compat_sys_clock_settime
650 .quad compat_sys_clock_gettime /* 265 */
651 .quad compat_sys_clock_getres
652 .quad compat_sys_clock_nanosleep
653 .quad compat_sys_statfs64
654 .quad compat_sys_fstatfs64
655 .quad sys_tgkill /* 270 */
656 .quad compat_sys_utimes
657 .quad sys32_fadvise64_64
658 .quad quiet_ni_syscall /* sys_vserver */
660 .quad compat_sys_get_mempolicy /* 275 */
661 .quad sys_set_mempolicy
662 .quad compat_sys_mq_open
664 .quad compat_sys_mq_timedsend
665 .quad compat_sys_mq_timedreceive /* 280 */
666 .quad compat_sys_mq_notify
667 .quad compat_sys_mq_getsetattr
668 .quad compat_sys_kexec_load /* reserved for kexec */
669 .quad compat_sys_waitid
670 .quad quiet_ni_syscall /* 285: sys_altroot */
672 .quad sys_request_key
675 .quad sys_ioprio_get /* 290 */
676 .quad sys_inotify_init
677 .quad sys_inotify_add_watch
678 .quad sys_inotify_rm_watch
679 .quad sys_migrate_pages
680 .quad compat_sys_openat /* 295 */
684 .quad compat_sys_futimesat
685 .quad sys32_fstatat /* 300 */
690 .quad sys_readlinkat /* 305 */
693 .quad quiet_ni_syscall /* pselect6 for now */
694 .quad quiet_ni_syscall /* ppoll for now */
695 .quad sys_unshare /* 310 */
696 .quad compat_sys_set_robust_list
697 .quad compat_sys_get_robust_list
699 .quad sys_sync_file_range
701 .quad compat_sys_vmsplice
702 .quad compat_sys_move_pages