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 */
39 * 32bit SYSENTER instruction entry.
42 * %eax System call number.
53 * This is purely a fast path. For anything complicated we use the int 0x80
54 * path below. Set up a complete hardware stack frame to share code
55 * with the int 0x80 path.
57 ENTRY(ia32_sysenter_target)
62 movq %gs:pda_kernelstack, %rsp
63 addq $(PDA_STACKOFFSET),%rsp
65 movl %ebp,%ebp /* zero extension */
67 CFI_ADJUST_CFA_OFFSET 8
68 /*CFI_REL_OFFSET ss,0*/
70 CFI_ADJUST_CFA_OFFSET 8
73 CFI_ADJUST_CFA_OFFSET 8
74 /*CFI_REL_OFFSET rflags,0*/
75 movl $VSYSCALL32_SYSEXIT, %r10d
78 CFI_ADJUST_CFA_OFFSET 8
79 /*CFI_REL_OFFSET cs,0*/
82 CFI_ADJUST_CFA_OFFSET 8
85 CFI_ADJUST_CFA_OFFSET 8
88 /* no need to do an access_ok check here because rbp has been
89 32bit zero extended */
91 .section __ex_table,"a"
95 testl $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP),threadinfo_flags(%r10)
99 cmpl $(IA32_NR_syscalls),%eax
102 call *ia32_sys_call_table(,%rax,8)
103 movq %rax,RAX-ARGOFFSET(%rsp)
104 GET_THREAD_INFO(%r10)
106 testl $_TIF_ALLWORK_MASK,threadinfo_flags(%r10)
107 jnz int_ret_from_sys_call
108 /* clear IF, that popfq doesn't enable interrupts early */
109 andl $~0x200,EFLAGS-R11(%rsp)
110 RESTORE_ARGS 1,24,1,1,1,1
112 CFI_ADJUST_CFA_OFFSET -8
113 /*CFI_RESTORE rflags*/
114 popq %rcx /* User %esp */
115 CFI_ADJUST_CFA_OFFSET -8
117 movl $VSYSCALL32_SYSEXIT,%edx /* User %eip */
120 sti /* sti only takes effect after the next instruction */
128 movq $-ENOSYS,RAX(%rsp) /* really needed? */
129 movq %rsp,%rdi /* &pt_regs -> arg1 */
130 call syscall_trace_enter
131 LOAD_ARGS ARGOFFSET /* reload args from stack in case ptrace changed it */
134 /* no need to do an access_ok check here because rbp has been
135 32bit zero extended */
137 .section __ex_table,"a"
144 * 32bit SYSCALL instruction entry.
147 * %eax System call number.
153 * %ebp Arg2 [note: not saved in the stack frame, should not be touched]
159 * This is purely a fast path. For anything complicated we use the int 0x80
160 * path below. Set up a complete hardware stack frame to share code
161 * with the int 0x80 path.
163 ENTRY(ia32_cstar_target)
167 /*CFI_REGISTER rflags,r11*/
171 movq %gs:pda_kernelstack,%rsp
174 movl %eax,%eax /* zero extension */
175 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
176 movq %rcx,RIP-ARGOFFSET(%rsp)
177 CFI_REL_OFFSET rip,RIP-ARGOFFSET
178 movq %rbp,RCX-ARGOFFSET(%rsp) /* this lies slightly to ptrace */
180 movq $__USER32_CS,CS-ARGOFFSET(%rsp)
181 movq $__USER32_DS,SS-ARGOFFSET(%rsp)
182 movq %r11,EFLAGS-ARGOFFSET(%rsp)
183 /*CFI_REL_OFFSET rflags,EFLAGS-ARGOFFSET*/
184 movq %r8,RSP-ARGOFFSET(%rsp)
185 CFI_REL_OFFSET rsp,RSP-ARGOFFSET
186 /* no need to do an access_ok check here because r8 has been
187 32bit zero extended */
188 /* hardware stack frame is complete now */
190 .section __ex_table,"a"
193 GET_THREAD_INFO(%r10)
194 testl $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP),threadinfo_flags(%r10)
198 cmpl $IA32_NR_syscalls,%eax
201 call *ia32_sys_call_table(,%rax,8)
202 movq %rax,RAX-ARGOFFSET(%rsp)
203 GET_THREAD_INFO(%r10)
205 testl $_TIF_ALLWORK_MASK,threadinfo_flags(%r10)
206 jnz int_ret_from_sys_call
207 RESTORE_ARGS 1,-ARG_SKIP,1,1,1
208 movl RIP-ARGOFFSET(%rsp),%ecx
210 movl EFLAGS-ARGOFFSET(%rsp),%r11d
211 /*CFI_REGISTER rflags,r11*/
212 movl RSP-ARGOFFSET(%rsp),%esp
221 movq $-ENOSYS,RAX(%rsp) /* really needed? */
222 movq %rsp,%rdi /* &pt_regs -> arg1 */
223 call syscall_trace_enter
224 LOAD_ARGS ARGOFFSET /* reload args from stack in case ptrace changed it */
226 movl RSP-ARGOFFSET(%rsp), %r8d
227 /* no need to do an access_ok check here because r8 has been
228 32bit zero extended */
230 .section __ex_table,"a"
241 * Emulated IA32 system calls via int 0x80.
244 * %eax System call number.
250 * %ebp Arg6 [note: not saved in the stack frame, should not be touched]
253 * Uses the same stack frame as the x86-64 version.
254 * All registers except %eax must be saved (but ptrace may violate that)
255 * Arguments are zero extended. For system calls that want sign extension and
256 * take long arguments a wrapper is needed. Most calls can just be called
258 * Assumes it is only called from user space and entered with interrupts off.
263 CFI_DEF_CFA rsp,SS+8-RIP
264 /*CFI_REL_OFFSET ss,SS-RIP*/
265 CFI_REL_OFFSET rsp,RSP-RIP
266 /*CFI_REL_OFFSET rflags,EFLAGS-RIP*/
267 /*CFI_REL_OFFSET cs,CS-RIP*/
268 CFI_REL_OFFSET rip,RIP-RIP
273 CFI_ADJUST_CFA_OFFSET 8
275 /* note the registers are not zero extended to the sf.
276 this could be a problem. */
278 GET_THREAD_INFO(%r10)
279 testl $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP),threadinfo_flags(%r10)
282 cmpl $(IA32_NR_syscalls),%eax
285 call *ia32_sys_call_table(,%rax,8) # xxx: rip relative
287 movq %rax,RAX-ARGOFFSET(%rsp)
288 jmp int_ret_from_sys_call
292 movq $-ENOSYS,RAX(%rsp) /* really needed? */
293 movq %rsp,%rdi /* &pt_regs -> arg1 */
294 call syscall_trace_enter
295 LOAD_ARGS ARGOFFSET /* reload args from stack in case ptrace changed it */
300 movq $0,ORIG_RAX-ARGOFFSET(%rsp)
301 movq $-ENOSYS,RAX-ARGOFFSET(%rsp)
302 jmp int_ret_from_sys_call
313 .macro PTREGSCALL label, func, arg
316 leaq \func(%rip),%rax
317 leaq -ARGOFFSET+8(%rsp),\arg /* 8 for return address */
318 jmp ia32_ptregs_common
323 PTREGSCALL stub32_rt_sigreturn, sys32_rt_sigreturn, %rdi
324 PTREGSCALL stub32_sigreturn, sys32_sigreturn, %rdi
325 PTREGSCALL stub32_sigaltstack, sys32_sigaltstack, %rdx
326 PTREGSCALL stub32_sigsuspend, sys32_sigsuspend, %rcx
327 PTREGSCALL stub32_execve, sys32_execve, %rcx
328 PTREGSCALL stub32_fork, sys_fork, %rdi
329 PTREGSCALL stub32_clone, sys32_clone, %rdx
330 PTREGSCALL stub32_vfork, sys_vfork, %rdi
331 PTREGSCALL stub32_iopl, sys_iopl, %rsi
332 PTREGSCALL stub32_rt_sigsuspend, sys_rt_sigsuspend, %rdx
334 ENTRY(ia32_ptregs_common)
336 CFI_ADJUST_CFA_OFFSET -8
337 CFI_REGISTER rip, r11
341 jmp ia32_sysret /* misbalances the return cache */
346 .globl ia32_sys_call_table
348 .quad sys_restart_syscall
353 .quad compat_sys_open /* 5 */
358 .quad sys_unlink /* 10 */
361 .quad compat_sys_time
363 .quad sys_chmod /* 15 */
365 .quad quiet_ni_syscall /* old break syscall holder */
368 .quad sys_getpid /* 20 */
369 .quad compat_sys_mount /* mount */
370 .quad sys_oldumount /* old_umount */
373 .quad compat_sys_stime /* stime */ /* 25 */
374 .quad sys32_ptrace /* ptrace */
376 .quad sys_fstat /* (old)fstat */
378 .quad compat_sys_utime /* 30 */
379 .quad quiet_ni_syscall /* old stty syscall holder */
380 .quad quiet_ni_syscall /* old gtty syscall holder */
383 .quad quiet_ni_syscall /* 35 */ /* old ftime syscall holder */
388 .quad sys_rmdir /* 40 */
391 .quad compat_sys_times
392 .quad quiet_ni_syscall /* old prof syscall holder */
393 .quad sys_brk /* 45 */
398 .quad sys_getegid16 /* 50 */
400 .quad sys_umount /* new_umount */
401 .quad quiet_ni_syscall /* old lock syscall holder */
402 .quad compat_sys_ioctl
403 .quad compat_sys_fcntl64 /* 55 */
404 .quad quiet_ni_syscall /* old mpx syscall holder */
406 .quad quiet_ni_syscall /* old ulimit syscall holder */
408 .quad sys_umask /* 60 */
413 .quad sys_getpgrp /* 65 */
415 .quad sys32_sigaction
418 .quad sys_setreuid16 /* 70 */
420 .quad stub32_sigsuspend
421 .quad compat_sys_sigpending
422 .quad sys_sethostname
423 .quad compat_sys_setrlimit /* 75 */
424 .quad compat_sys_old_getrlimit /* old_getrlimit */
425 .quad compat_sys_getrusage
426 .quad sys32_gettimeofday
427 .quad sys32_settimeofday
428 .quad sys_getgroups16 /* 80 */
429 .quad sys_setgroups16
430 .quad sys32_old_select
433 .quad sys_readlink /* 85 */
434 #ifdef CONFIG_IA32_AOUT
437 .quad quiet_ni_syscall
441 .quad compat_sys_old_readdir
442 .quad sys32_mmap /* 90 */
447 .quad sys_fchown16 /* 95 */
448 .quad sys_getpriority
449 .quad sys_setpriority
450 .quad quiet_ni_syscall /* old profil syscall holder */
451 .quad compat_sys_statfs
452 .quad compat_sys_fstatfs /* 100 */
454 .quad compat_sys_socketcall
456 .quad compat_sys_setitimer
457 .quad compat_sys_getitimer /* 105 */
458 .quad compat_sys_newstat
459 .quad compat_sys_newlstat
460 .quad compat_sys_newfstat
462 .quad stub32_iopl /* 110 */
464 .quad quiet_ni_syscall /* old "idle" system call */
465 .quad sys32_vm86_warning /* vm86old */
466 .quad compat_sys_wait4
467 .quad sys_swapoff /* 115 */
471 .quad stub32_sigreturn
472 .quad stub32_clone /* 120 */
473 .quad sys_setdomainname
477 .quad sys32_mprotect /* 125 */
478 .quad compat_sys_sigprocmask
479 .quad quiet_ni_syscall /* create_module */
480 .quad sys_init_module
481 .quad sys_delete_module
482 .quad quiet_ni_syscall /* 130 get_kernel_syms */
486 .quad quiet_ni_syscall /* bdflush */
487 .quad sys_sysfs /* 135 */
488 .quad sys_personality
489 .quad quiet_ni_syscall /* for afs_syscall */
492 .quad sys_llseek /* 140 */
493 .quad compat_sys_getdents
494 .quad compat_sys_select
497 .quad compat_sys_readv /* 145 */
498 .quad compat_sys_writev
501 .quad sys32_sysctl /* sysctl */
502 .quad sys_mlock /* 150 */
506 .quad sys_sched_setparam
507 .quad sys_sched_getparam /* 155 */
508 .quad sys_sched_setscheduler
509 .quad sys_sched_getscheduler
510 .quad sys_sched_yield
511 .quad sys_sched_get_priority_max
512 .quad sys_sched_get_priority_min /* 160 */
513 .quad sys_sched_rr_get_interval
514 .quad compat_sys_nanosleep
516 .quad sys_setresuid16
517 .quad sys_getresuid16 /* 165 */
518 .quad sys32_vm86_warning /* vm86 */
519 .quad quiet_ni_syscall /* query_module */
521 .quad compat_sys_nfsservctl
522 .quad sys_setresgid16 /* 170 */
523 .quad sys_getresgid16
525 .quad stub32_rt_sigreturn
526 .quad sys32_rt_sigaction
527 .quad sys32_rt_sigprocmask /* 175 */
528 .quad sys32_rt_sigpending
529 .quad compat_sys_rt_sigtimedwait
530 .quad sys32_rt_sigqueueinfo
531 .quad stub32_rt_sigsuspend
532 .quad sys32_pread /* 180 */
538 .quad stub32_sigaltstack
540 .quad quiet_ni_syscall /* streams1 */
541 .quad quiet_ni_syscall /* streams2 */
542 .quad stub32_vfork /* 190 */
543 .quad compat_sys_getrlimit
545 .quad sys32_truncate64
546 .quad sys32_ftruncate64
547 .quad sys32_stat64 /* 195 */
552 .quad sys_getgid /* 200 */
557 .quad sys_getgroups /* 205 */
562 .quad sys_setresgid /* 210 */
567 .quad sys_setfsuid /* 215 */
572 .quad compat_sys_getdents64 /* 220 getdents64 */
573 .quad compat_sys_fcntl64
574 .quad quiet_ni_syscall /* tux */
575 .quad quiet_ni_syscall /* security */
577 .quad sys_readahead /* 225 */
582 .quad sys_lgetxattr /* 230 */
587 .quad sys_removexattr /* 235 */
588 .quad sys_lremovexattr
589 .quad sys_fremovexattr
592 .quad compat_sys_futex /* 240 */
593 .quad compat_sys_sched_setaffinity
594 .quad compat_sys_sched_getaffinity
595 .quad sys32_set_thread_area
596 .quad sys32_get_thread_area
597 .quad compat_sys_io_setup /* 245 */
599 .quad compat_sys_io_getevents
600 .quad compat_sys_io_submit
602 .quad sys_fadvise64 /* 250 */
603 .quad quiet_ni_syscall /* free_huge_pages */
605 .quad sys32_lookup_dcookie
606 .quad sys_epoll_create
607 .quad sys_epoll_ctl /* 255 */
609 .quad sys_remap_file_pages
610 .quad sys_set_tid_address
611 .quad sys32_timer_create
612 .quad compat_sys_timer_settime /* 260 */
613 .quad compat_sys_timer_gettime
614 .quad sys_timer_getoverrun
615 .quad sys_timer_delete
616 .quad compat_sys_clock_settime
617 .quad compat_sys_clock_gettime /* 265 */
618 .quad compat_sys_clock_getres
619 .quad compat_sys_clock_nanosleep
620 .quad compat_sys_statfs64
621 .quad compat_sys_fstatfs64
622 .quad sys_tgkill /* 270 */
623 .quad compat_sys_utimes
624 .quad sys32_fadvise64_64
625 .quad quiet_ni_syscall /* sys_vserver */
627 .quad compat_sys_get_mempolicy /* 275 */
628 .quad sys_set_mempolicy
629 .quad compat_sys_mq_open
631 .quad compat_sys_mq_timedsend
632 .quad compat_sys_mq_timedreceive /* 280 */
633 .quad compat_sys_mq_notify
634 .quad compat_sys_mq_getsetattr
635 .quad compat_sys_kexec_load /* reserved for kexec */
636 .quad compat_sys_waitid
637 .quad quiet_ni_syscall /* 285: sys_altroot */
639 .quad sys_request_key
642 .quad sys_ioprio_get /* 290 */
643 .quad sys_inotify_init
644 .quad sys_inotify_add_watch
645 .quad sys_inotify_rm_watch
647 .rept IA32_NR_syscalls-(ia32_syscall_end-ia32_sys_call_table)/8