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
182 CFI_DEF_CFA rsp,PDA_STACKOFFSET
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
331 .macro PTREGSCALL label, func, arg
334 leaq \func(%rip),%rax
335 leaq -ARGOFFSET+8(%rsp),\arg /* 8 for return address */
336 jmp ia32_ptregs_common
341 PTREGSCALL stub32_rt_sigreturn, sys32_rt_sigreturn, %rdi
342 PTREGSCALL stub32_sigreturn, sys32_sigreturn, %rdi
343 PTREGSCALL stub32_sigaltstack, sys32_sigaltstack, %rdx
344 PTREGSCALL stub32_sigsuspend, sys32_sigsuspend, %rcx
345 PTREGSCALL stub32_execve, sys32_execve, %rcx
346 PTREGSCALL stub32_fork, sys_fork, %rdi
347 PTREGSCALL stub32_clone, sys32_clone, %rdx
348 PTREGSCALL stub32_vfork, sys_vfork, %rdi
349 PTREGSCALL stub32_iopl, sys_iopl, %rsi
350 PTREGSCALL stub32_rt_sigsuspend, sys_rt_sigsuspend, %rdx
352 ENTRY(ia32_ptregs_common)
355 CFI_STARTPROC32 simple
356 CFI_DEF_CFA rsp,SS+8-ARGOFFSET
357 CFI_REL_OFFSET rax,RAX-ARGOFFSET
358 CFI_REL_OFFSET rcx,RCX-ARGOFFSET
359 CFI_REL_OFFSET rdx,RDX-ARGOFFSET
360 CFI_REL_OFFSET rsi,RSI-ARGOFFSET
361 CFI_REL_OFFSET rdi,RDI-ARGOFFSET
362 CFI_REL_OFFSET rip,RIP-ARGOFFSET
363 /* CFI_REL_OFFSET cs,CS-ARGOFFSET*/
364 /* CFI_REL_OFFSET rflags,EFLAGS-ARGOFFSET*/
365 CFI_REL_OFFSET rsp,RSP-ARGOFFSET
366 /* CFI_REL_OFFSET ss,SS-ARGOFFSET*/
370 jmp ia32_sysret /* misbalances the return cache */
372 END(ia32_ptregs_common)
377 .quad sys_restart_syscall
382 .quad compat_sys_open /* 5 */
387 .quad sys_unlink /* 10 */
390 .quad compat_sys_time
392 .quad sys_chmod /* 15 */
394 .quad quiet_ni_syscall /* old break syscall holder */
397 .quad sys_getpid /* 20 */
398 .quad compat_sys_mount /* mount */
399 .quad sys_oldumount /* old_umount */
402 .quad compat_sys_stime /* stime */ /* 25 */
403 .quad sys32_ptrace /* ptrace */
405 .quad sys_fstat /* (old)fstat */
407 .quad compat_sys_utime /* 30 */
408 .quad quiet_ni_syscall /* old stty syscall holder */
409 .quad quiet_ni_syscall /* old gtty syscall holder */
412 .quad quiet_ni_syscall /* 35 */ /* old ftime syscall holder */
417 .quad sys_rmdir /* 40 */
420 .quad compat_sys_times
421 .quad quiet_ni_syscall /* old prof syscall holder */
422 .quad sys_brk /* 45 */
427 .quad sys_getegid16 /* 50 */
429 .quad sys_umount /* new_umount */
430 .quad quiet_ni_syscall /* old lock syscall holder */
431 .quad compat_sys_ioctl
432 .quad compat_sys_fcntl64 /* 55 */
433 .quad quiet_ni_syscall /* old mpx syscall holder */
435 .quad quiet_ni_syscall /* old ulimit syscall holder */
437 .quad sys_umask /* 60 */
442 .quad sys_getpgrp /* 65 */
444 .quad sys32_sigaction
447 .quad sys_setreuid16 /* 70 */
449 .quad stub32_sigsuspend
450 .quad compat_sys_sigpending
451 .quad sys_sethostname
452 .quad compat_sys_setrlimit /* 75 */
453 .quad compat_sys_old_getrlimit /* old_getrlimit */
454 .quad compat_sys_getrusage
455 .quad sys32_gettimeofday
456 .quad sys32_settimeofday
457 .quad sys_getgroups16 /* 80 */
458 .quad sys_setgroups16
459 .quad sys32_old_select
462 .quad sys_readlink /* 85 */
463 #ifdef CONFIG_IA32_AOUT
466 .quad quiet_ni_syscall
470 .quad compat_sys_old_readdir
471 .quad sys32_mmap /* 90 */
476 .quad sys_fchown16 /* 95 */
477 .quad sys_getpriority
478 .quad sys_setpriority
479 .quad quiet_ni_syscall /* old profil syscall holder */
480 .quad compat_sys_statfs
481 .quad compat_sys_fstatfs /* 100 */
483 .quad compat_sys_socketcall
485 .quad compat_sys_setitimer
486 .quad compat_sys_getitimer /* 105 */
487 .quad compat_sys_newstat
488 .quad compat_sys_newlstat
489 .quad compat_sys_newfstat
491 .quad stub32_iopl /* 110 */
493 .quad quiet_ni_syscall /* old "idle" system call */
494 .quad sys32_vm86_warning /* vm86old */
495 .quad compat_sys_wait4
496 .quad sys_swapoff /* 115 */
500 .quad stub32_sigreturn
501 .quad stub32_clone /* 120 */
502 .quad sys_setdomainname
505 .quad compat_sys_adjtimex
506 .quad sys32_mprotect /* 125 */
507 .quad compat_sys_sigprocmask
508 .quad quiet_ni_syscall /* create_module */
509 .quad sys_init_module
510 .quad sys_delete_module
511 .quad quiet_ni_syscall /* 130 get_kernel_syms */
515 .quad quiet_ni_syscall /* bdflush */
516 .quad sys_sysfs /* 135 */
517 .quad sys_personality
518 .quad quiet_ni_syscall /* for afs_syscall */
521 .quad sys_llseek /* 140 */
522 .quad compat_sys_getdents
523 .quad compat_sys_select
526 .quad compat_sys_readv /* 145 */
527 .quad compat_sys_writev
530 .quad sys32_sysctl /* sysctl */
531 .quad sys_mlock /* 150 */
535 .quad sys_sched_setparam
536 .quad sys_sched_getparam /* 155 */
537 .quad sys_sched_setscheduler
538 .quad sys_sched_getscheduler
539 .quad sys_sched_yield
540 .quad sys_sched_get_priority_max
541 .quad sys_sched_get_priority_min /* 160 */
542 .quad sys_sched_rr_get_interval
543 .quad compat_sys_nanosleep
545 .quad sys_setresuid16
546 .quad sys_getresuid16 /* 165 */
547 .quad sys32_vm86_warning /* vm86 */
548 .quad quiet_ni_syscall /* query_module */
550 .quad compat_sys_nfsservctl
551 .quad sys_setresgid16 /* 170 */
552 .quad sys_getresgid16
554 .quad stub32_rt_sigreturn
555 .quad sys32_rt_sigaction
556 .quad sys32_rt_sigprocmask /* 175 */
557 .quad sys32_rt_sigpending
558 .quad compat_sys_rt_sigtimedwait
559 .quad sys32_rt_sigqueueinfo
560 .quad stub32_rt_sigsuspend
561 .quad sys32_pread /* 180 */
567 .quad stub32_sigaltstack
569 .quad quiet_ni_syscall /* streams1 */
570 .quad quiet_ni_syscall /* streams2 */
571 .quad stub32_vfork /* 190 */
572 .quad compat_sys_getrlimit
574 .quad sys32_truncate64
575 .quad sys32_ftruncate64
576 .quad sys32_stat64 /* 195 */
581 .quad sys_getgid /* 200 */
586 .quad sys_getgroups /* 205 */
591 .quad sys_setresgid /* 210 */
596 .quad sys_setfsuid /* 215 */
601 .quad compat_sys_getdents64 /* 220 getdents64 */
602 .quad compat_sys_fcntl64
603 .quad quiet_ni_syscall /* tux */
604 .quad quiet_ni_syscall /* security */
606 .quad sys_readahead /* 225 */
611 .quad sys_lgetxattr /* 230 */
616 .quad sys_removexattr /* 235 */
617 .quad sys_lremovexattr
618 .quad sys_fremovexattr
621 .quad compat_sys_futex /* 240 */
622 .quad compat_sys_sched_setaffinity
623 .quad compat_sys_sched_getaffinity
624 .quad sys32_set_thread_area
625 .quad sys32_get_thread_area
626 .quad compat_sys_io_setup /* 245 */
628 .quad compat_sys_io_getevents
629 .quad compat_sys_io_submit
631 .quad sys_fadvise64 /* 250 */
632 .quad quiet_ni_syscall /* free_huge_pages */
634 .quad sys32_lookup_dcookie
635 .quad sys_epoll_create
636 .quad sys_epoll_ctl /* 255 */
638 .quad sys_remap_file_pages
639 .quad sys_set_tid_address
640 .quad compat_sys_timer_create
641 .quad compat_sys_timer_settime /* 260 */
642 .quad compat_sys_timer_gettime
643 .quad sys_timer_getoverrun
644 .quad sys_timer_delete
645 .quad compat_sys_clock_settime
646 .quad compat_sys_clock_gettime /* 265 */
647 .quad compat_sys_clock_getres
648 .quad compat_sys_clock_nanosleep
649 .quad compat_sys_statfs64
650 .quad compat_sys_fstatfs64
651 .quad sys_tgkill /* 270 */
652 .quad compat_sys_utimes
653 .quad sys32_fadvise64_64
654 .quad quiet_ni_syscall /* sys_vserver */
656 .quad compat_sys_get_mempolicy /* 275 */
657 .quad sys_set_mempolicy
658 .quad compat_sys_mq_open
660 .quad compat_sys_mq_timedsend
661 .quad compat_sys_mq_timedreceive /* 280 */
662 .quad compat_sys_mq_notify
663 .quad compat_sys_mq_getsetattr
664 .quad compat_sys_kexec_load /* reserved for kexec */
665 .quad compat_sys_waitid
666 .quad quiet_ni_syscall /* 285: sys_altroot */
668 .quad sys_request_key
671 .quad sys_ioprio_get /* 290 */
672 .quad sys_inotify_init
673 .quad sys_inotify_add_watch
674 .quad sys_inotify_rm_watch
675 .quad sys_migrate_pages
676 .quad compat_sys_openat /* 295 */
680 .quad compat_sys_futimesat
681 .quad sys32_fstatat /* 300 */
686 .quad sys_readlinkat /* 305 */
689 .quad quiet_ni_syscall /* pselect6 for now */
690 .quad quiet_ni_syscall /* ppoll for now */
691 .quad sys_unshare /* 310 */
692 .quad compat_sys_set_robust_list
693 .quad compat_sys_get_robust_list
695 .quad sys_sync_file_range
697 .quad compat_sys_vmsplice
698 .quad compat_sys_move_pages