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 <asm/irqflags.h>
17 #include <linux/linkage.h>
19 #define IA32_NR_syscalls ((ia32_syscall_end - ia32_sys_call_table)/8)
21 .macro IA32_ARG_FIXUP noebp=0
29 movl %edx,%edx /* zero extension */
41 .macro CFI_STARTPROC32 simple
54 * 32bit SYSENTER instruction entry.
57 * %eax System call number.
68 * This is purely a fast path. For anything complicated we use the int 0x80
69 * path below. Set up a complete hardware stack frame to share code
70 * with the int 0x80 path.
72 ENTRY(ia32_sysenter_target)
73 CFI_STARTPROC32 simple
78 movq %gs:pda_kernelstack, %rsp
79 addq $(PDA_STACKOFFSET),%rsp
81 * No need to follow this irqs on/off section: the syscall
82 * disabled irqs, here we enable it straight after entry:
85 movl %ebp,%ebp /* zero extension */
87 CFI_ADJUST_CFA_OFFSET 8
88 /*CFI_REL_OFFSET ss,0*/
90 CFI_ADJUST_CFA_OFFSET 8
93 CFI_ADJUST_CFA_OFFSET 8
94 /*CFI_REL_OFFSET rflags,0*/
95 movl $VSYSCALL32_SYSEXIT, %r10d
98 CFI_ADJUST_CFA_OFFSET 8
99 /*CFI_REL_OFFSET cs,0*/
102 CFI_ADJUST_CFA_OFFSET 8
105 CFI_ADJUST_CFA_OFFSET 8
108 /* no need to do an access_ok check here because rbp has been
109 32bit zero extended */
111 .section __ex_table,"a"
114 GET_THREAD_INFO(%r10)
115 orl $TS_COMPAT,threadinfo_status(%r10)
116 testl $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP),threadinfo_flags(%r10)
118 jnz sysenter_tracesys
120 cmpl $(IA32_NR_syscalls-1),%eax
123 call *ia32_sys_call_table(,%rax,8)
124 movq %rax,RAX-ARGOFFSET(%rsp)
125 GET_THREAD_INFO(%r10)
128 testl $_TIF_ALLWORK_MASK,threadinfo_flags(%r10)
129 jnz int_ret_from_sys_call
130 andl $~TS_COMPAT,threadinfo_status(%r10)
131 /* clear IF, that popfq doesn't enable interrupts early */
132 andl $~0x200,EFLAGS-R11(%rsp)
133 RESTORE_ARGS 1,24,1,1,1,1
135 CFI_ADJUST_CFA_OFFSET -8
136 /*CFI_RESTORE rflags*/
137 popq %rcx /* User %esp */
138 CFI_ADJUST_CFA_OFFSET -8
140 movl $VSYSCALL32_SYSEXIT,%edx /* User %eip */
144 sti /* sti only takes effect after the next instruction */
152 movq $-ENOSYS,RAX(%rsp) /* really needed? */
153 movq %rsp,%rdi /* &pt_regs -> arg1 */
154 call syscall_trace_enter
155 LOAD_ARGS ARGOFFSET /* reload args from stack in case ptrace changed it */
158 /* no need to do an access_ok check here because rbp has been
159 32bit zero extended */
161 .section __ex_table,"a"
166 ENDPROC(ia32_sysenter_target)
169 * 32bit SYSCALL instruction entry.
172 * %eax System call number.
178 * %ebp Arg2 [note: not saved in the stack frame, should not be touched]
184 * This is purely a fast path. For anything complicated we use the int 0x80
185 * path below. Set up a complete hardware stack frame to share code
186 * with the int 0x80 path.
188 ENTRY(ia32_cstar_target)
189 CFI_STARTPROC32 simple
191 CFI_DEF_CFA rsp,PDA_STACKOFFSET
193 /*CFI_REGISTER rflags,r11*/
197 movq %gs:pda_kernelstack,%rsp
199 * No need to follow this irqs on/off section: the syscall
200 * disabled irqs and here we enable it straight after entry:
204 movl %eax,%eax /* zero extension */
205 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
206 movq %rcx,RIP-ARGOFFSET(%rsp)
207 CFI_REL_OFFSET rip,RIP-ARGOFFSET
208 movq %rbp,RCX-ARGOFFSET(%rsp) /* this lies slightly to ptrace */
210 movq $__USER32_CS,CS-ARGOFFSET(%rsp)
211 movq $__USER32_DS,SS-ARGOFFSET(%rsp)
212 movq %r11,EFLAGS-ARGOFFSET(%rsp)
213 /*CFI_REL_OFFSET rflags,EFLAGS-ARGOFFSET*/
214 movq %r8,RSP-ARGOFFSET(%rsp)
215 CFI_REL_OFFSET rsp,RSP-ARGOFFSET
216 /* no need to do an access_ok check here because r8 has been
217 32bit zero extended */
218 /* hardware stack frame is complete now */
220 .section __ex_table,"a"
223 GET_THREAD_INFO(%r10)
224 orl $TS_COMPAT,threadinfo_status(%r10)
225 testl $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP),threadinfo_flags(%r10)
229 cmpl $IA32_NR_syscalls-1,%eax
232 call *ia32_sys_call_table(,%rax,8)
233 movq %rax,RAX-ARGOFFSET(%rsp)
234 GET_THREAD_INFO(%r10)
237 testl $_TIF_ALLWORK_MASK,threadinfo_flags(%r10)
238 jnz int_ret_from_sys_call
239 andl $~TS_COMPAT,threadinfo_status(%r10)
240 RESTORE_ARGS 1,-ARG_SKIP,1,1,1
241 movl RIP-ARGOFFSET(%rsp),%ecx
243 movl EFLAGS-ARGOFFSET(%rsp),%r11d
244 /*CFI_REGISTER rflags,r11*/
246 movl RSP-ARGOFFSET(%rsp),%esp
255 movq $-ENOSYS,RAX(%rsp) /* really needed? */
256 movq %rsp,%rdi /* &pt_regs -> arg1 */
257 call syscall_trace_enter
258 LOAD_ARGS ARGOFFSET /* reload args from stack in case ptrace changed it */
260 movl RSP-ARGOFFSET(%rsp), %r8d
261 /* no need to do an access_ok check here because r8 has been
262 32bit zero extended */
264 .section __ex_table,"a"
268 END(ia32_cstar_target)
276 * Emulated IA32 system calls via int 0x80.
279 * %eax System call number.
285 * %ebp Arg6 [note: not saved in the stack frame, should not be touched]
288 * Uses the same stack frame as the x86-64 version.
289 * All registers except %eax must be saved (but ptrace may violate that)
290 * Arguments are zero extended. For system calls that want sign extension and
291 * take long arguments a wrapper is needed. Most calls can just be called
293 * Assumes it is only called from user space and entered with interrupts off.
299 CFI_DEF_CFA rsp,SS+8-RIP
300 /*CFI_REL_OFFSET ss,SS-RIP*/
301 CFI_REL_OFFSET rsp,RSP-RIP
302 /*CFI_REL_OFFSET rflags,EFLAGS-RIP*/
303 /*CFI_REL_OFFSET cs,CS-RIP*/
304 CFI_REL_OFFSET rip,RIP-RIP
307 * No need to follow this irqs on/off section: the syscall
308 * disabled irqs and here we enable it straight after entry:
313 CFI_ADJUST_CFA_OFFSET 8
315 /* note the registers are not zero extended to the sf.
316 this could be a problem. */
318 GET_THREAD_INFO(%r10)
319 orl $TS_COMPAT,threadinfo_status(%r10)
320 testl $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP),threadinfo_flags(%r10)
323 cmpl $(IA32_NR_syscalls-1),%eax
326 call *ia32_sys_call_table(,%rax,8) # xxx: rip relative
328 movq %rax,RAX-ARGOFFSET(%rsp)
329 jmp int_ret_from_sys_call
333 movq $-ENOSYS,RAX(%rsp) /* really needed? */
334 movq %rsp,%rdi /* &pt_regs -> arg1 */
335 call syscall_trace_enter
336 LOAD_ARGS ARGOFFSET /* reload args from stack in case ptrace changed it */
342 movq $0,ORIG_RAX-ARGOFFSET(%rsp)
343 movq $-ENOSYS,RAX-ARGOFFSET(%rsp)
344 jmp int_ret_from_sys_call
351 .macro PTREGSCALL label, func, arg
354 leaq \func(%rip),%rax
355 leaq -ARGOFFSET+8(%rsp),\arg /* 8 for return address */
356 jmp ia32_ptregs_common
361 PTREGSCALL stub32_rt_sigreturn, sys32_rt_sigreturn, %rdi
362 PTREGSCALL stub32_sigreturn, sys32_sigreturn, %rdi
363 PTREGSCALL stub32_sigaltstack, sys32_sigaltstack, %rdx
364 PTREGSCALL stub32_sigsuspend, sys32_sigsuspend, %rcx
365 PTREGSCALL stub32_execve, sys32_execve, %rcx
366 PTREGSCALL stub32_fork, sys_fork, %rdi
367 PTREGSCALL stub32_clone, sys32_clone, %rdx
368 PTREGSCALL stub32_vfork, sys_vfork, %rdi
369 PTREGSCALL stub32_iopl, sys_iopl, %rsi
370 PTREGSCALL stub32_rt_sigsuspend, sys_rt_sigsuspend, %rdx
372 ENTRY(ia32_ptregs_common)
375 CFI_STARTPROC32 simple
377 CFI_DEF_CFA rsp,SS+8-ARGOFFSET
378 CFI_REL_OFFSET rax,RAX-ARGOFFSET
379 CFI_REL_OFFSET rcx,RCX-ARGOFFSET
380 CFI_REL_OFFSET rdx,RDX-ARGOFFSET
381 CFI_REL_OFFSET rsi,RSI-ARGOFFSET
382 CFI_REL_OFFSET rdi,RDI-ARGOFFSET
383 CFI_REL_OFFSET rip,RIP-ARGOFFSET
384 /* CFI_REL_OFFSET cs,CS-ARGOFFSET*/
385 /* CFI_REL_OFFSET rflags,EFLAGS-ARGOFFSET*/
386 CFI_REL_OFFSET rsp,RSP-ARGOFFSET
387 /* CFI_REL_OFFSET ss,SS-ARGOFFSET*/
391 jmp ia32_sysret /* misbalances the return cache */
393 END(ia32_ptregs_common)
398 .quad sys_restart_syscall
403 .quad compat_sys_open /* 5 */
408 .quad sys_unlink /* 10 */
411 .quad compat_sys_time
413 .quad sys_chmod /* 15 */
415 .quad quiet_ni_syscall /* old break syscall holder */
418 .quad sys_getpid /* 20 */
419 .quad compat_sys_mount /* mount */
420 .quad sys_oldumount /* old_umount */
423 .quad compat_sys_stime /* stime */ /* 25 */
424 .quad sys32_ptrace /* ptrace */
426 .quad sys_fstat /* (old)fstat */
428 .quad compat_sys_utime /* 30 */
429 .quad quiet_ni_syscall /* old stty syscall holder */
430 .quad quiet_ni_syscall /* old gtty syscall holder */
433 .quad quiet_ni_syscall /* 35 */ /* old ftime syscall holder */
438 .quad sys_rmdir /* 40 */
441 .quad compat_sys_times
442 .quad quiet_ni_syscall /* old prof syscall holder */
443 .quad sys_brk /* 45 */
448 .quad sys_getegid16 /* 50 */
450 .quad sys_umount /* new_umount */
451 .quad quiet_ni_syscall /* old lock syscall holder */
452 .quad compat_sys_ioctl
453 .quad compat_sys_fcntl64 /* 55 */
454 .quad quiet_ni_syscall /* old mpx syscall holder */
456 .quad quiet_ni_syscall /* old ulimit syscall holder */
458 .quad sys_umask /* 60 */
463 .quad sys_getpgrp /* 65 */
465 .quad sys32_sigaction
468 .quad sys_setreuid16 /* 70 */
470 .quad stub32_sigsuspend
471 .quad compat_sys_sigpending
472 .quad sys_sethostname
473 .quad compat_sys_setrlimit /* 75 */
474 .quad compat_sys_old_getrlimit /* old_getrlimit */
475 .quad compat_sys_getrusage
476 .quad sys32_gettimeofday
477 .quad sys32_settimeofday
478 .quad sys_getgroups16 /* 80 */
479 .quad sys_setgroups16
480 .quad sys32_old_select
483 .quad sys_readlink /* 85 */
484 #ifdef CONFIG_IA32_AOUT
487 .quad quiet_ni_syscall
491 .quad compat_sys_old_readdir
492 .quad sys32_mmap /* 90 */
497 .quad sys_fchown16 /* 95 */
498 .quad sys_getpriority
499 .quad sys_setpriority
500 .quad quiet_ni_syscall /* old profil syscall holder */
501 .quad compat_sys_statfs
502 .quad compat_sys_fstatfs /* 100 */
504 .quad compat_sys_socketcall
506 .quad compat_sys_setitimer
507 .quad compat_sys_getitimer /* 105 */
508 .quad compat_sys_newstat
509 .quad compat_sys_newlstat
510 .quad compat_sys_newfstat
512 .quad stub32_iopl /* 110 */
514 .quad quiet_ni_syscall /* old "idle" system call */
515 .quad sys32_vm86_warning /* vm86old */
516 .quad compat_sys_wait4
517 .quad sys_swapoff /* 115 */
518 .quad compat_sys_sysinfo
521 .quad stub32_sigreturn
522 .quad stub32_clone /* 120 */
523 .quad sys_setdomainname
526 .quad compat_sys_adjtimex
527 .quad sys32_mprotect /* 125 */
528 .quad compat_sys_sigprocmask
529 .quad quiet_ni_syscall /* create_module */
530 .quad sys_init_module
531 .quad sys_delete_module
532 .quad quiet_ni_syscall /* 130 get_kernel_syms */
536 .quad quiet_ni_syscall /* bdflush */
537 .quad sys_sysfs /* 135 */
538 .quad sys_personality
539 .quad quiet_ni_syscall /* for afs_syscall */
542 .quad sys_llseek /* 140 */
543 .quad compat_sys_getdents
544 .quad compat_sys_select
547 .quad compat_sys_readv /* 145 */
548 .quad compat_sys_writev
551 .quad sys32_sysctl /* sysctl */
552 .quad sys_mlock /* 150 */
556 .quad sys_sched_setparam
557 .quad sys_sched_getparam /* 155 */
558 .quad sys_sched_setscheduler
559 .quad sys_sched_getscheduler
560 .quad sys_sched_yield
561 .quad sys_sched_get_priority_max
562 .quad sys_sched_get_priority_min /* 160 */
563 .quad sys_sched_rr_get_interval
564 .quad compat_sys_nanosleep
566 .quad sys_setresuid16
567 .quad sys_getresuid16 /* 165 */
568 .quad sys32_vm86_warning /* vm86 */
569 .quad quiet_ni_syscall /* query_module */
571 .quad compat_sys_nfsservctl
572 .quad sys_setresgid16 /* 170 */
573 .quad sys_getresgid16
575 .quad stub32_rt_sigreturn
576 .quad sys32_rt_sigaction
577 .quad sys32_rt_sigprocmask /* 175 */
578 .quad sys32_rt_sigpending
579 .quad compat_sys_rt_sigtimedwait
580 .quad sys32_rt_sigqueueinfo
581 .quad stub32_rt_sigsuspend
582 .quad sys32_pread /* 180 */
588 .quad stub32_sigaltstack
590 .quad quiet_ni_syscall /* streams1 */
591 .quad quiet_ni_syscall /* streams2 */
592 .quad stub32_vfork /* 190 */
593 .quad compat_sys_getrlimit
595 .quad sys32_truncate64
596 .quad sys32_ftruncate64
597 .quad sys32_stat64 /* 195 */
602 .quad sys_getgid /* 200 */
607 .quad sys_getgroups /* 205 */
612 .quad sys_setresgid /* 210 */
617 .quad sys_setfsuid /* 215 */
622 .quad compat_sys_getdents64 /* 220 getdents64 */
623 .quad compat_sys_fcntl64
624 .quad quiet_ni_syscall /* tux */
625 .quad quiet_ni_syscall /* security */
627 .quad sys_readahead /* 225 */
632 .quad sys_lgetxattr /* 230 */
637 .quad sys_removexattr /* 235 */
638 .quad sys_lremovexattr
639 .quad sys_fremovexattr
642 .quad compat_sys_futex /* 240 */
643 .quad compat_sys_sched_setaffinity
644 .quad compat_sys_sched_getaffinity
645 .quad sys32_set_thread_area
646 .quad sys32_get_thread_area
647 .quad compat_sys_io_setup /* 245 */
649 .quad compat_sys_io_getevents
650 .quad compat_sys_io_submit
652 .quad sys_fadvise64 /* 250 */
653 .quad quiet_ni_syscall /* free_huge_pages */
655 .quad sys32_lookup_dcookie
656 .quad sys_epoll_create
657 .quad sys_epoll_ctl /* 255 */
659 .quad sys_remap_file_pages
660 .quad sys_set_tid_address
661 .quad compat_sys_timer_create
662 .quad compat_sys_timer_settime /* 260 */
663 .quad compat_sys_timer_gettime
664 .quad sys_timer_getoverrun
665 .quad sys_timer_delete
666 .quad compat_sys_clock_settime
667 .quad compat_sys_clock_gettime /* 265 */
668 .quad compat_sys_clock_getres
669 .quad compat_sys_clock_nanosleep
670 .quad compat_sys_statfs64
671 .quad compat_sys_fstatfs64
672 .quad sys_tgkill /* 270 */
673 .quad compat_sys_utimes
674 .quad sys32_fadvise64_64
675 .quad quiet_ni_syscall /* sys_vserver */
677 .quad compat_sys_get_mempolicy /* 275 */
678 .quad sys_set_mempolicy
679 .quad compat_sys_mq_open
681 .quad compat_sys_mq_timedsend
682 .quad compat_sys_mq_timedreceive /* 280 */
683 .quad compat_sys_mq_notify
684 .quad compat_sys_mq_getsetattr
685 .quad compat_sys_kexec_load /* reserved for kexec */
686 .quad compat_sys_waitid
687 .quad quiet_ni_syscall /* 285: sys_altroot */
689 .quad sys_request_key
692 .quad sys_ioprio_get /* 290 */
693 .quad sys_inotify_init
694 .quad sys_inotify_add_watch
695 .quad sys_inotify_rm_watch
696 .quad sys_migrate_pages
697 .quad compat_sys_openat /* 295 */
701 .quad compat_sys_futimesat
702 .quad sys32_fstatat /* 300 */
707 .quad sys_readlinkat /* 305 */
710 .quad compat_sys_pselect6
711 .quad compat_sys_ppoll
712 .quad sys_unshare /* 310 */
713 .quad compat_sys_set_robust_list
714 .quad compat_sys_get_robust_list
716 .quad sys_sync_file_range
718 .quad compat_sys_vmsplice
719 .quad compat_sys_move_pages
721 .quad sys_epoll_pwait