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 .macro IA32_ARG_FIXUP noebp=0
26 movl %edx,%edx /* zero extension */
38 .macro CFI_STARTPROC32 simple
51 * 32bit SYSENTER instruction entry.
54 * %eax System call number.
65 * This is purely a fast path. For anything complicated we use the int 0x80
66 * path below. Set up a complete hardware stack frame to share code
67 * with the int 0x80 path.
69 ENTRY(ia32_sysenter_target)
70 CFI_STARTPROC32 simple
74 movq %gs:pda_kernelstack, %rsp
75 addq $(PDA_STACKOFFSET),%rsp
77 movl %ebp,%ebp /* zero extension */
79 CFI_ADJUST_CFA_OFFSET 8
80 /*CFI_REL_OFFSET ss,0*/
82 CFI_ADJUST_CFA_OFFSET 8
85 CFI_ADJUST_CFA_OFFSET 8
86 /*CFI_REL_OFFSET rflags,0*/
87 movl $VSYSCALL32_SYSEXIT, %r10d
90 CFI_ADJUST_CFA_OFFSET 8
91 /*CFI_REL_OFFSET cs,0*/
94 CFI_ADJUST_CFA_OFFSET 8
97 CFI_ADJUST_CFA_OFFSET 8
100 /* no need to do an access_ok check here because rbp has been
101 32bit zero extended */
103 .section __ex_table,"a"
106 GET_THREAD_INFO(%r10)
107 orl $TS_COMPAT,threadinfo_status(%r10)
108 testl $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP),threadinfo_flags(%r10)
110 jnz sysenter_tracesys
112 cmpl $(IA32_NR_syscalls),%eax
115 call *ia32_sys_call_table(,%rax,8)
116 movq %rax,RAX-ARGOFFSET(%rsp)
117 GET_THREAD_INFO(%r10)
119 testl $_TIF_ALLWORK_MASK,threadinfo_flags(%r10)
120 jnz int_ret_from_sys_call
121 andl $~TS_COMPAT,threadinfo_status(%r10)
122 /* clear IF, that popfq doesn't enable interrupts early */
123 andl $~0x200,EFLAGS-R11(%rsp)
124 RESTORE_ARGS 1,24,1,1,1,1
126 CFI_ADJUST_CFA_OFFSET -8
127 /*CFI_RESTORE rflags*/
128 popq %rcx /* User %esp */
129 CFI_ADJUST_CFA_OFFSET -8
131 movl $VSYSCALL32_SYSEXIT,%edx /* User %eip */
134 sti /* sti only takes effect after the next instruction */
142 movq $-ENOSYS,RAX(%rsp) /* really needed? */
143 movq %rsp,%rdi /* &pt_regs -> arg1 */
144 call syscall_trace_enter
145 LOAD_ARGS ARGOFFSET /* reload args from stack in case ptrace changed it */
148 /* no need to do an access_ok check here because rbp has been
149 32bit zero extended */
151 .section __ex_table,"a"
158 * 32bit SYSCALL instruction entry.
161 * %eax System call number.
167 * %ebp Arg2 [note: not saved in the stack frame, should not be touched]
173 * This is purely a fast path. For anything complicated we use the int 0x80
174 * path below. Set up a complete hardware stack frame to share code
175 * with the int 0x80 path.
177 ENTRY(ia32_cstar_target)
178 CFI_STARTPROC32 simple
181 /*CFI_REGISTER rflags,r11*/
185 movq %gs:pda_kernelstack,%rsp
188 movl %eax,%eax /* zero extension */
189 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
190 movq %rcx,RIP-ARGOFFSET(%rsp)
191 CFI_REL_OFFSET rip,RIP-ARGOFFSET
192 movq %rbp,RCX-ARGOFFSET(%rsp) /* this lies slightly to ptrace */
194 movq $__USER32_CS,CS-ARGOFFSET(%rsp)
195 movq $__USER32_DS,SS-ARGOFFSET(%rsp)
196 movq %r11,EFLAGS-ARGOFFSET(%rsp)
197 /*CFI_REL_OFFSET rflags,EFLAGS-ARGOFFSET*/
198 movq %r8,RSP-ARGOFFSET(%rsp)
199 CFI_REL_OFFSET rsp,RSP-ARGOFFSET
200 /* no need to do an access_ok check here because r8 has been
201 32bit zero extended */
202 /* hardware stack frame is complete now */
204 .section __ex_table,"a"
207 GET_THREAD_INFO(%r10)
208 orl $TS_COMPAT,threadinfo_status(%r10)
209 testl $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP),threadinfo_flags(%r10)
213 cmpl $IA32_NR_syscalls,%eax
216 call *ia32_sys_call_table(,%rax,8)
217 movq %rax,RAX-ARGOFFSET(%rsp)
218 GET_THREAD_INFO(%r10)
220 testl $_TIF_ALLWORK_MASK,threadinfo_flags(%r10)
221 jnz int_ret_from_sys_call
222 andl $~TS_COMPAT,threadinfo_status(%r10)
223 RESTORE_ARGS 1,-ARG_SKIP,1,1,1
224 movl RIP-ARGOFFSET(%rsp),%ecx
226 movl EFLAGS-ARGOFFSET(%rsp),%r11d
227 /*CFI_REGISTER rflags,r11*/
228 movl RSP-ARGOFFSET(%rsp),%esp
237 movq $-ENOSYS,RAX(%rsp) /* really needed? */
238 movq %rsp,%rdi /* &pt_regs -> arg1 */
239 call syscall_trace_enter
240 LOAD_ARGS ARGOFFSET /* reload args from stack in case ptrace changed it */
242 movl RSP-ARGOFFSET(%rsp), %r8d
243 /* no need to do an access_ok check here because r8 has been
244 32bit zero extended */
246 .section __ex_table,"a"
257 * Emulated IA32 system calls via int 0x80.
260 * %eax System call number.
266 * %ebp Arg6 [note: not saved in the stack frame, should not be touched]
269 * Uses the same stack frame as the x86-64 version.
270 * All registers except %eax must be saved (but ptrace may violate that)
271 * Arguments are zero extended. For system calls that want sign extension and
272 * take long arguments a wrapper is needed. Most calls can just be called
274 * Assumes it is only called from user space and entered with interrupts off.
279 CFI_DEF_CFA rsp,SS+8-RIP
280 /*CFI_REL_OFFSET ss,SS-RIP*/
281 CFI_REL_OFFSET rsp,RSP-RIP
282 /*CFI_REL_OFFSET rflags,EFLAGS-RIP*/
283 /*CFI_REL_OFFSET cs,CS-RIP*/
284 CFI_REL_OFFSET rip,RIP-RIP
289 CFI_ADJUST_CFA_OFFSET 8
291 /* note the registers are not zero extended to the sf.
292 this could be a problem. */
294 GET_THREAD_INFO(%r10)
295 orl $TS_COMPAT,threadinfo_status(%r10)
296 testl $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP),threadinfo_flags(%r10)
299 cmpl $(IA32_NR_syscalls),%eax
302 call *ia32_sys_call_table(,%rax,8) # xxx: rip relative
304 movq %rax,RAX-ARGOFFSET(%rsp)
305 jmp int_ret_from_sys_call
309 movq $-ENOSYS,RAX(%rsp) /* really needed? */
310 movq %rsp,%rdi /* &pt_regs -> arg1 */
311 call syscall_trace_enter
312 LOAD_ARGS ARGOFFSET /* reload args from stack in case ptrace changed it */
317 movq $0,ORIG_RAX-ARGOFFSET(%rsp)
318 movq $-ENOSYS,RAX-ARGOFFSET(%rsp)
319 jmp int_ret_from_sys_call
330 .macro PTREGSCALL label, func, arg
333 leaq \func(%rip),%rax
334 leaq -ARGOFFSET+8(%rsp),\arg /* 8 for return address */
335 jmp ia32_ptregs_common
340 PTREGSCALL stub32_rt_sigreturn, sys32_rt_sigreturn, %rdi
341 PTREGSCALL stub32_sigreturn, sys32_sigreturn, %rdi
342 PTREGSCALL stub32_sigaltstack, sys32_sigaltstack, %rdx
343 PTREGSCALL stub32_sigsuspend, sys32_sigsuspend, %rcx
344 PTREGSCALL stub32_execve, sys32_execve, %rcx
345 PTREGSCALL stub32_fork, sys_fork, %rdi
346 PTREGSCALL stub32_clone, sys32_clone, %rdx
347 PTREGSCALL stub32_vfork, sys_vfork, %rdi
348 PTREGSCALL stub32_iopl, sys_iopl, %rsi
349 PTREGSCALL stub32_rt_sigsuspend, sys_rt_sigsuspend, %rdx
351 ENTRY(ia32_ptregs_common)
354 CFI_STARTPROC32 simple
355 CFI_DEF_CFA rsp,SS+8-ARGOFFSET
356 CFI_REL_OFFSET rax,RAX-ARGOFFSET
357 CFI_REL_OFFSET rcx,RCX-ARGOFFSET
358 CFI_REL_OFFSET rdx,RDX-ARGOFFSET
359 CFI_REL_OFFSET rsi,RSI-ARGOFFSET
360 CFI_REL_OFFSET rdi,RDI-ARGOFFSET
361 CFI_REL_OFFSET rip,RIP-ARGOFFSET
362 /* CFI_REL_OFFSET cs,CS-ARGOFFSET*/
363 /* CFI_REL_OFFSET rflags,EFLAGS-ARGOFFSET*/
364 CFI_REL_OFFSET rsp,RSP-ARGOFFSET
365 /* CFI_REL_OFFSET ss,SS-ARGOFFSET*/
369 jmp ia32_sysret /* misbalances the return cache */
374 .globl ia32_sys_call_table
376 .quad sys_restart_syscall
381 .quad compat_sys_open /* 5 */
386 .quad sys_unlink /* 10 */
389 .quad compat_sys_time
391 .quad sys_chmod /* 15 */
393 .quad quiet_ni_syscall /* old break syscall holder */
396 .quad sys_getpid /* 20 */
397 .quad compat_sys_mount /* mount */
398 .quad sys_oldumount /* old_umount */
401 .quad compat_sys_stime /* stime */ /* 25 */
402 .quad sys32_ptrace /* ptrace */
404 .quad sys_fstat /* (old)fstat */
406 .quad compat_sys_utime /* 30 */
407 .quad quiet_ni_syscall /* old stty syscall holder */
408 .quad quiet_ni_syscall /* old gtty syscall holder */
411 .quad quiet_ni_syscall /* 35 */ /* old ftime syscall holder */
416 .quad sys_rmdir /* 40 */
419 .quad compat_sys_times
420 .quad quiet_ni_syscall /* old prof syscall holder */
421 .quad sys_brk /* 45 */
426 .quad sys_getegid16 /* 50 */
428 .quad sys_umount /* new_umount */
429 .quad quiet_ni_syscall /* old lock syscall holder */
430 .quad compat_sys_ioctl
431 .quad compat_sys_fcntl64 /* 55 */
432 .quad quiet_ni_syscall /* old mpx syscall holder */
434 .quad quiet_ni_syscall /* old ulimit syscall holder */
436 .quad sys_umask /* 60 */
441 .quad sys_getpgrp /* 65 */
443 .quad sys32_sigaction
446 .quad sys_setreuid16 /* 70 */
448 .quad stub32_sigsuspend
449 .quad compat_sys_sigpending
450 .quad sys_sethostname
451 .quad compat_sys_setrlimit /* 75 */
452 .quad compat_sys_old_getrlimit /* old_getrlimit */
453 .quad compat_sys_getrusage
454 .quad sys32_gettimeofday
455 .quad sys32_settimeofday
456 .quad sys_getgroups16 /* 80 */
457 .quad sys_setgroups16
458 .quad sys32_old_select
461 .quad sys_readlink /* 85 */
462 #ifdef CONFIG_IA32_AOUT
465 .quad quiet_ni_syscall
469 .quad compat_sys_old_readdir
470 .quad sys32_mmap /* 90 */
475 .quad sys_fchown16 /* 95 */
476 .quad sys_getpriority
477 .quad sys_setpriority
478 .quad quiet_ni_syscall /* old profil syscall holder */
479 .quad compat_sys_statfs
480 .quad compat_sys_fstatfs /* 100 */
482 .quad compat_sys_socketcall
484 .quad compat_sys_setitimer
485 .quad compat_sys_getitimer /* 105 */
486 .quad compat_sys_newstat
487 .quad compat_sys_newlstat
488 .quad compat_sys_newfstat
490 .quad stub32_iopl /* 110 */
492 .quad quiet_ni_syscall /* old "idle" system call */
493 .quad sys32_vm86_warning /* vm86old */
494 .quad compat_sys_wait4
495 .quad sys_swapoff /* 115 */
499 .quad stub32_sigreturn
500 .quad stub32_clone /* 120 */
501 .quad sys_setdomainname
505 .quad sys32_mprotect /* 125 */
506 .quad compat_sys_sigprocmask
507 .quad quiet_ni_syscall /* create_module */
508 .quad sys_init_module
509 .quad sys_delete_module
510 .quad quiet_ni_syscall /* 130 get_kernel_syms */
514 .quad quiet_ni_syscall /* bdflush */
515 .quad sys_sysfs /* 135 */
516 .quad sys_personality
517 .quad quiet_ni_syscall /* for afs_syscall */
520 .quad sys_llseek /* 140 */
521 .quad compat_sys_getdents
522 .quad compat_sys_select
525 .quad compat_sys_readv /* 145 */
526 .quad compat_sys_writev
529 .quad sys32_sysctl /* sysctl */
530 .quad sys_mlock /* 150 */
534 .quad sys_sched_setparam
535 .quad sys_sched_getparam /* 155 */
536 .quad sys_sched_setscheduler
537 .quad sys_sched_getscheduler
538 .quad sys_sched_yield
539 .quad sys_sched_get_priority_max
540 .quad sys_sched_get_priority_min /* 160 */
541 .quad sys_sched_rr_get_interval
542 .quad compat_sys_nanosleep
544 .quad sys_setresuid16
545 .quad sys_getresuid16 /* 165 */
546 .quad sys32_vm86_warning /* vm86 */
547 .quad quiet_ni_syscall /* query_module */
549 .quad compat_sys_nfsservctl
550 .quad sys_setresgid16 /* 170 */
551 .quad sys_getresgid16
553 .quad stub32_rt_sigreturn
554 .quad sys32_rt_sigaction
555 .quad sys32_rt_sigprocmask /* 175 */
556 .quad sys32_rt_sigpending
557 .quad compat_sys_rt_sigtimedwait
558 .quad sys32_rt_sigqueueinfo
559 .quad stub32_rt_sigsuspend
560 .quad sys32_pread /* 180 */
566 .quad stub32_sigaltstack
568 .quad quiet_ni_syscall /* streams1 */
569 .quad quiet_ni_syscall /* streams2 */
570 .quad stub32_vfork /* 190 */
571 .quad compat_sys_getrlimit
573 .quad sys32_truncate64
574 .quad sys32_ftruncate64
575 .quad sys32_stat64 /* 195 */
580 .quad sys_getgid /* 200 */
585 .quad sys_getgroups /* 205 */
590 .quad sys_setresgid /* 210 */
595 .quad sys_setfsuid /* 215 */
600 .quad compat_sys_getdents64 /* 220 getdents64 */
601 .quad compat_sys_fcntl64
602 .quad quiet_ni_syscall /* tux */
603 .quad quiet_ni_syscall /* security */
605 .quad sys_readahead /* 225 */
610 .quad sys_lgetxattr /* 230 */
615 .quad sys_removexattr /* 235 */
616 .quad sys_lremovexattr
617 .quad sys_fremovexattr
620 .quad compat_sys_futex /* 240 */
621 .quad compat_sys_sched_setaffinity
622 .quad compat_sys_sched_getaffinity
623 .quad sys32_set_thread_area
624 .quad sys32_get_thread_area
625 .quad compat_sys_io_setup /* 245 */
627 .quad compat_sys_io_getevents
628 .quad compat_sys_io_submit
630 .quad sys_fadvise64 /* 250 */
631 .quad quiet_ni_syscall /* free_huge_pages */
633 .quad sys32_lookup_dcookie
634 .quad sys_epoll_create
635 .quad sys_epoll_ctl /* 255 */
637 .quad sys_remap_file_pages
638 .quad sys_set_tid_address
639 .quad compat_sys_timer_create
640 .quad compat_sys_timer_settime /* 260 */
641 .quad compat_sys_timer_gettime
642 .quad sys_timer_getoverrun
643 .quad sys_timer_delete
644 .quad compat_sys_clock_settime
645 .quad compat_sys_clock_gettime /* 265 */
646 .quad compat_sys_clock_getres
647 .quad compat_sys_clock_nanosleep
648 .quad compat_sys_statfs64
649 .quad compat_sys_fstatfs64
650 .quad sys_tgkill /* 270 */
651 .quad compat_sys_utimes
652 .quad sys32_fadvise64_64
653 .quad quiet_ni_syscall /* sys_vserver */
655 .quad compat_sys_get_mempolicy /* 275 */
656 .quad sys_set_mempolicy
657 .quad compat_sys_mq_open
659 .quad compat_sys_mq_timedsend
660 .quad compat_sys_mq_timedreceive /* 280 */
661 .quad compat_sys_mq_notify
662 .quad compat_sys_mq_getsetattr
663 .quad compat_sys_kexec_load /* reserved for kexec */
664 .quad compat_sys_waitid
665 .quad quiet_ni_syscall /* 285: sys_altroot */
667 .quad sys_request_key
670 .quad sys_ioprio_get /* 290 */
671 .quad sys_inotify_init
672 .quad sys_inotify_add_watch
673 .quad sys_inotify_rm_watch
674 .quad sys_migrate_pages
675 .quad compat_sys_openat /* 295 */
679 .quad compat_sys_futimesat
680 .quad compat_sys_newfstatat /* 300 */
685 .quad sys_readlinkat /* 305 */
689 .rept IA32_NR_syscalls-(ia32_syscall_end-ia32_sys_call_table)/8