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
77 movq %gs:pda_kernelstack, %rsp
78 addq $(PDA_STACKOFFSET),%rsp
80 * No need to follow this irqs on/off section: the syscall
81 * disabled irqs, here we enable it straight after entry:
84 movl %ebp,%ebp /* zero extension */
86 CFI_ADJUST_CFA_OFFSET 8
87 /*CFI_REL_OFFSET ss,0*/
89 CFI_ADJUST_CFA_OFFSET 8
92 CFI_ADJUST_CFA_OFFSET 8
93 /*CFI_REL_OFFSET rflags,0*/
94 movl $VSYSCALL32_SYSEXIT, %r10d
97 CFI_ADJUST_CFA_OFFSET 8
98 /*CFI_REL_OFFSET cs,0*/
101 CFI_ADJUST_CFA_OFFSET 8
104 CFI_ADJUST_CFA_OFFSET 8
107 /* no need to do an access_ok check here because rbp has been
108 32bit zero extended */
110 .section __ex_table,"a"
113 GET_THREAD_INFO(%r10)
114 orl $TS_COMPAT,threadinfo_status(%r10)
115 testl $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP),threadinfo_flags(%r10)
117 jnz sysenter_tracesys
119 cmpl $(IA32_NR_syscalls-1),%eax
122 call *ia32_sys_call_table(,%rax,8)
123 movq %rax,RAX-ARGOFFSET(%rsp)
124 GET_THREAD_INFO(%r10)
127 testl $_TIF_ALLWORK_MASK,threadinfo_flags(%r10)
128 jnz int_ret_from_sys_call
129 andl $~TS_COMPAT,threadinfo_status(%r10)
130 /* clear IF, that popfq doesn't enable interrupts early */
131 andl $~0x200,EFLAGS-R11(%rsp)
132 RESTORE_ARGS 1,24,1,1,1,1
134 CFI_ADJUST_CFA_OFFSET -8
135 /*CFI_RESTORE rflags*/
136 popq %rcx /* User %esp */
137 CFI_ADJUST_CFA_OFFSET -8
139 movl $VSYSCALL32_SYSEXIT,%edx /* User %eip */
143 sti /* sti only takes effect after the next instruction */
151 movq $-ENOSYS,RAX(%rsp) /* really needed? */
152 movq %rsp,%rdi /* &pt_regs -> arg1 */
153 call syscall_trace_enter
154 LOAD_ARGS ARGOFFSET /* reload args from stack in case ptrace changed it */
157 /* no need to do an access_ok check here because rbp has been
158 32bit zero extended */
160 .section __ex_table,"a"
165 ENDPROC(ia32_sysenter_target)
168 * 32bit SYSCALL instruction entry.
171 * %eax System call number.
177 * %ebp Arg2 [note: not saved in the stack frame, should not be touched]
183 * This is purely a fast path. For anything complicated we use the int 0x80
184 * path below. Set up a complete hardware stack frame to share code
185 * with the int 0x80 path.
187 ENTRY(ia32_cstar_target)
188 CFI_STARTPROC32 simple
189 CFI_DEF_CFA rsp,PDA_STACKOFFSET
191 /*CFI_REGISTER rflags,r11*/
195 movq %gs:pda_kernelstack,%rsp
197 * No need to follow this irqs on/off section: the syscall
198 * disabled irqs and here we enable it straight after entry:
202 movl %eax,%eax /* zero extension */
203 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
204 movq %rcx,RIP-ARGOFFSET(%rsp)
205 CFI_REL_OFFSET rip,RIP-ARGOFFSET
206 movq %rbp,RCX-ARGOFFSET(%rsp) /* this lies slightly to ptrace */
208 movq $__USER32_CS,CS-ARGOFFSET(%rsp)
209 movq $__USER32_DS,SS-ARGOFFSET(%rsp)
210 movq %r11,EFLAGS-ARGOFFSET(%rsp)
211 /*CFI_REL_OFFSET rflags,EFLAGS-ARGOFFSET*/
212 movq %r8,RSP-ARGOFFSET(%rsp)
213 CFI_REL_OFFSET rsp,RSP-ARGOFFSET
214 /* no need to do an access_ok check here because r8 has been
215 32bit zero extended */
216 /* hardware stack frame is complete now */
218 .section __ex_table,"a"
221 GET_THREAD_INFO(%r10)
222 orl $TS_COMPAT,threadinfo_status(%r10)
223 testl $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP),threadinfo_flags(%r10)
227 cmpl $IA32_NR_syscalls-1,%eax
230 call *ia32_sys_call_table(,%rax,8)
231 movq %rax,RAX-ARGOFFSET(%rsp)
232 GET_THREAD_INFO(%r10)
235 testl $_TIF_ALLWORK_MASK,threadinfo_flags(%r10)
236 jnz int_ret_from_sys_call
237 andl $~TS_COMPAT,threadinfo_status(%r10)
238 RESTORE_ARGS 1,-ARG_SKIP,1,1,1
239 movl RIP-ARGOFFSET(%rsp),%ecx
241 movl EFLAGS-ARGOFFSET(%rsp),%r11d
242 /*CFI_REGISTER rflags,r11*/
244 movl RSP-ARGOFFSET(%rsp),%esp
253 movq $-ENOSYS,RAX(%rsp) /* really needed? */
254 movq %rsp,%rdi /* &pt_regs -> arg1 */
255 call syscall_trace_enter
256 LOAD_ARGS ARGOFFSET /* reload args from stack in case ptrace changed it */
258 movl RSP-ARGOFFSET(%rsp), %r8d
259 /* no need to do an access_ok check here because r8 has been
260 32bit zero extended */
262 .section __ex_table,"a"
266 END(ia32_cstar_target)
274 * Emulated IA32 system calls via int 0x80.
277 * %eax System call number.
283 * %ebp Arg6 [note: not saved in the stack frame, should not be touched]
286 * Uses the same stack frame as the x86-64 version.
287 * All registers except %eax must be saved (but ptrace may violate that)
288 * Arguments are zero extended. For system calls that want sign extension and
289 * take long arguments a wrapper is needed. Most calls can just be called
291 * Assumes it is only called from user space and entered with interrupts off.
296 CFI_DEF_CFA rsp,SS+8-RIP
297 /*CFI_REL_OFFSET ss,SS-RIP*/
298 CFI_REL_OFFSET rsp,RSP-RIP
299 /*CFI_REL_OFFSET rflags,EFLAGS-RIP*/
300 /*CFI_REL_OFFSET cs,CS-RIP*/
301 CFI_REL_OFFSET rip,RIP-RIP
304 * No need to follow this irqs on/off section: the syscall
305 * disabled irqs and here we enable it straight after entry:
310 CFI_ADJUST_CFA_OFFSET 8
312 /* note the registers are not zero extended to the sf.
313 this could be a problem. */
315 GET_THREAD_INFO(%r10)
316 orl $TS_COMPAT,threadinfo_status(%r10)
317 testl $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP),threadinfo_flags(%r10)
320 cmpl $(IA32_NR_syscalls-1),%eax
323 call *ia32_sys_call_table(,%rax,8) # xxx: rip relative
325 movq %rax,RAX-ARGOFFSET(%rsp)
326 jmp int_ret_from_sys_call
330 movq $-ENOSYS,RAX(%rsp) /* really needed? */
331 movq %rsp,%rdi /* &pt_regs -> arg1 */
332 call syscall_trace_enter
333 LOAD_ARGS ARGOFFSET /* reload args from stack in case ptrace changed it */
339 movq $0,ORIG_RAX-ARGOFFSET(%rsp)
340 movq $-ENOSYS,RAX-ARGOFFSET(%rsp)
341 jmp int_ret_from_sys_call
348 .macro PTREGSCALL label, func, arg
351 leaq \func(%rip),%rax
352 leaq -ARGOFFSET+8(%rsp),\arg /* 8 for return address */
353 jmp ia32_ptregs_common
358 PTREGSCALL stub32_rt_sigreturn, sys32_rt_sigreturn, %rdi
359 PTREGSCALL stub32_sigreturn, sys32_sigreturn, %rdi
360 PTREGSCALL stub32_sigaltstack, sys32_sigaltstack, %rdx
361 PTREGSCALL stub32_sigsuspend, sys32_sigsuspend, %rcx
362 PTREGSCALL stub32_execve, sys32_execve, %rcx
363 PTREGSCALL stub32_fork, sys_fork, %rdi
364 PTREGSCALL stub32_clone, sys32_clone, %rdx
365 PTREGSCALL stub32_vfork, sys_vfork, %rdi
366 PTREGSCALL stub32_iopl, sys_iopl, %rsi
367 PTREGSCALL stub32_rt_sigsuspend, sys_rt_sigsuspend, %rdx
369 ENTRY(ia32_ptregs_common)
372 CFI_STARTPROC32 simple
373 CFI_DEF_CFA rsp,SS+8-ARGOFFSET
374 CFI_REL_OFFSET rax,RAX-ARGOFFSET
375 CFI_REL_OFFSET rcx,RCX-ARGOFFSET
376 CFI_REL_OFFSET rdx,RDX-ARGOFFSET
377 CFI_REL_OFFSET rsi,RSI-ARGOFFSET
378 CFI_REL_OFFSET rdi,RDI-ARGOFFSET
379 CFI_REL_OFFSET rip,RIP-ARGOFFSET
380 /* CFI_REL_OFFSET cs,CS-ARGOFFSET*/
381 /* CFI_REL_OFFSET rflags,EFLAGS-ARGOFFSET*/
382 CFI_REL_OFFSET rsp,RSP-ARGOFFSET
383 /* CFI_REL_OFFSET ss,SS-ARGOFFSET*/
387 jmp ia32_sysret /* misbalances the return cache */
389 END(ia32_ptregs_common)
394 .quad sys_restart_syscall
399 .quad compat_sys_open /* 5 */
404 .quad sys_unlink /* 10 */
407 .quad compat_sys_time
409 .quad sys_chmod /* 15 */
411 .quad quiet_ni_syscall /* old break syscall holder */
414 .quad sys_getpid /* 20 */
415 .quad compat_sys_mount /* mount */
416 .quad sys_oldumount /* old_umount */
419 .quad compat_sys_stime /* stime */ /* 25 */
420 .quad sys32_ptrace /* ptrace */
422 .quad sys_fstat /* (old)fstat */
424 .quad compat_sys_utime /* 30 */
425 .quad quiet_ni_syscall /* old stty syscall holder */
426 .quad quiet_ni_syscall /* old gtty syscall holder */
429 .quad quiet_ni_syscall /* 35 */ /* old ftime syscall holder */
434 .quad sys_rmdir /* 40 */
437 .quad compat_sys_times
438 .quad quiet_ni_syscall /* old prof syscall holder */
439 .quad sys_brk /* 45 */
444 .quad sys_getegid16 /* 50 */
446 .quad sys_umount /* new_umount */
447 .quad quiet_ni_syscall /* old lock syscall holder */
448 .quad compat_sys_ioctl
449 .quad compat_sys_fcntl64 /* 55 */
450 .quad quiet_ni_syscall /* old mpx syscall holder */
452 .quad quiet_ni_syscall /* old ulimit syscall holder */
454 .quad sys_umask /* 60 */
459 .quad sys_getpgrp /* 65 */
461 .quad sys32_sigaction
464 .quad sys_setreuid16 /* 70 */
466 .quad stub32_sigsuspend
467 .quad compat_sys_sigpending
468 .quad sys_sethostname
469 .quad compat_sys_setrlimit /* 75 */
470 .quad compat_sys_old_getrlimit /* old_getrlimit */
471 .quad compat_sys_getrusage
472 .quad sys32_gettimeofday
473 .quad sys32_settimeofday
474 .quad sys_getgroups16 /* 80 */
475 .quad sys_setgroups16
476 .quad sys32_old_select
479 .quad sys_readlink /* 85 */
480 #ifdef CONFIG_IA32_AOUT
483 .quad quiet_ni_syscall
487 .quad compat_sys_old_readdir
488 .quad sys32_mmap /* 90 */
493 .quad sys_fchown16 /* 95 */
494 .quad sys_getpriority
495 .quad sys_setpriority
496 .quad quiet_ni_syscall /* old profil syscall holder */
497 .quad compat_sys_statfs
498 .quad compat_sys_fstatfs /* 100 */
500 .quad compat_sys_socketcall
502 .quad compat_sys_setitimer
503 .quad compat_sys_getitimer /* 105 */
504 .quad compat_sys_newstat
505 .quad compat_sys_newlstat
506 .quad compat_sys_newfstat
508 .quad stub32_iopl /* 110 */
510 .quad quiet_ni_syscall /* old "idle" system call */
511 .quad sys32_vm86_warning /* vm86old */
512 .quad compat_sys_wait4
513 .quad sys_swapoff /* 115 */
517 .quad stub32_sigreturn
518 .quad stub32_clone /* 120 */
519 .quad sys_setdomainname
522 .quad compat_sys_adjtimex
523 .quad sys32_mprotect /* 125 */
524 .quad compat_sys_sigprocmask
525 .quad quiet_ni_syscall /* create_module */
526 .quad sys_init_module
527 .quad sys_delete_module
528 .quad quiet_ni_syscall /* 130 get_kernel_syms */
532 .quad quiet_ni_syscall /* bdflush */
533 .quad sys_sysfs /* 135 */
534 .quad sys_personality
535 .quad quiet_ni_syscall /* for afs_syscall */
538 .quad sys_llseek /* 140 */
539 .quad compat_sys_getdents
540 .quad compat_sys_select
543 .quad compat_sys_readv /* 145 */
544 .quad compat_sys_writev
547 .quad sys32_sysctl /* sysctl */
548 .quad sys_mlock /* 150 */
552 .quad sys_sched_setparam
553 .quad sys_sched_getparam /* 155 */
554 .quad sys_sched_setscheduler
555 .quad sys_sched_getscheduler
556 .quad sys_sched_yield
557 .quad sys_sched_get_priority_max
558 .quad sys_sched_get_priority_min /* 160 */
559 .quad sys_sched_rr_get_interval
560 .quad compat_sys_nanosleep
562 .quad sys_setresuid16
563 .quad sys_getresuid16 /* 165 */
564 .quad sys32_vm86_warning /* vm86 */
565 .quad quiet_ni_syscall /* query_module */
567 .quad compat_sys_nfsservctl
568 .quad sys_setresgid16 /* 170 */
569 .quad sys_getresgid16
571 .quad stub32_rt_sigreturn
572 .quad sys32_rt_sigaction
573 .quad sys32_rt_sigprocmask /* 175 */
574 .quad sys32_rt_sigpending
575 .quad compat_sys_rt_sigtimedwait
576 .quad sys32_rt_sigqueueinfo
577 .quad stub32_rt_sigsuspend
578 .quad sys32_pread /* 180 */
584 .quad stub32_sigaltstack
586 .quad quiet_ni_syscall /* streams1 */
587 .quad quiet_ni_syscall /* streams2 */
588 .quad stub32_vfork /* 190 */
589 .quad compat_sys_getrlimit
591 .quad sys32_truncate64
592 .quad sys32_ftruncate64
593 .quad sys32_stat64 /* 195 */
598 .quad sys_getgid /* 200 */
603 .quad sys_getgroups /* 205 */
608 .quad sys_setresgid /* 210 */
613 .quad sys_setfsuid /* 215 */
618 .quad compat_sys_getdents64 /* 220 getdents64 */
619 .quad compat_sys_fcntl64
620 .quad quiet_ni_syscall /* tux */
621 .quad quiet_ni_syscall /* security */
623 .quad sys_readahead /* 225 */
628 .quad sys_lgetxattr /* 230 */
633 .quad sys_removexattr /* 235 */
634 .quad sys_lremovexattr
635 .quad sys_fremovexattr
638 .quad compat_sys_futex /* 240 */
639 .quad compat_sys_sched_setaffinity
640 .quad compat_sys_sched_getaffinity
641 .quad sys32_set_thread_area
642 .quad sys32_get_thread_area
643 .quad compat_sys_io_setup /* 245 */
645 .quad compat_sys_io_getevents
646 .quad compat_sys_io_submit
648 .quad sys_fadvise64 /* 250 */
649 .quad quiet_ni_syscall /* free_huge_pages */
651 .quad sys32_lookup_dcookie
652 .quad sys_epoll_create
653 .quad sys_epoll_ctl /* 255 */
655 .quad sys_remap_file_pages
656 .quad sys_set_tid_address
657 .quad compat_sys_timer_create
658 .quad compat_sys_timer_settime /* 260 */
659 .quad compat_sys_timer_gettime
660 .quad sys_timer_getoverrun
661 .quad sys_timer_delete
662 .quad compat_sys_clock_settime
663 .quad compat_sys_clock_gettime /* 265 */
664 .quad compat_sys_clock_getres
665 .quad compat_sys_clock_nanosleep
666 .quad compat_sys_statfs64
667 .quad compat_sys_fstatfs64
668 .quad sys_tgkill /* 270 */
669 .quad compat_sys_utimes
670 .quad sys32_fadvise64_64
671 .quad quiet_ni_syscall /* sys_vserver */
673 .quad compat_sys_get_mempolicy /* 275 */
674 .quad sys_set_mempolicy
675 .quad compat_sys_mq_open
677 .quad compat_sys_mq_timedsend
678 .quad compat_sys_mq_timedreceive /* 280 */
679 .quad compat_sys_mq_notify
680 .quad compat_sys_mq_getsetattr
681 .quad compat_sys_kexec_load /* reserved for kexec */
682 .quad compat_sys_waitid
683 .quad quiet_ni_syscall /* 285: sys_altroot */
685 .quad sys_request_key
688 .quad sys_ioprio_get /* 290 */
689 .quad sys_inotify_init
690 .quad sys_inotify_add_watch
691 .quad sys_inotify_rm_watch
692 .quad sys_migrate_pages
693 .quad compat_sys_openat /* 295 */
697 .quad compat_sys_futimesat
698 .quad sys32_fstatat /* 300 */
703 .quad sys_readlinkat /* 305 */
706 .quad quiet_ni_syscall /* pselect6 for now */
707 .quad quiet_ni_syscall /* ppoll for now */
708 .quad sys_unshare /* 310 */
709 .quad compat_sys_set_robust_list
710 .quad compat_sys_get_robust_list
712 .quad sys_sync_file_range
714 .quad compat_sys_vmsplice
715 .quad compat_sys_move_pages