aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86_64/ia32/ia32entry.S
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /arch/x86_64/ia32/ia32entry.S
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'arch/x86_64/ia32/ia32entry.S')
-rw-r--r--arch/x86_64/ia32/ia32entry.S602
1 files changed, 602 insertions, 0 deletions
diff --git a/arch/x86_64/ia32/ia32entry.S b/arch/x86_64/ia32/ia32entry.S
new file mode 100644
index 000000000000..f3ca0db85b5b
--- /dev/null
+++ b/arch/x86_64/ia32/ia32entry.S
@@ -0,0 +1,602 @@
1/*
2 * Compatibility mode system call entry point for x86-64.
3 *
4 * Copyright 2000-2002 Andi Kleen, SuSE Labs.
5 */
6
7#include <asm/dwarf2.h>
8#include <asm/calling.h>
9#include <asm/offset.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>
17
18 .macro IA32_ARG_FIXUP noebp=0
19 movl %edi,%r8d
20 .if \noebp
21 .else
22 movl %ebp,%r9d
23 .endif
24 xchg %ecx,%esi
25 movl %ebx,%edi
26 movl %edx,%edx /* zero extension */
27 .endm
28
29 /* clobbers %eax */
30 .macro CLEAR_RREGS
31 xorl %eax,%eax
32 movq %rax,R11(%rsp)
33 movq %rax,R10(%rsp)
34 movq %rax,R9(%rsp)
35 movq %rax,R8(%rsp)
36 .endm
37
38/*
39 * 32bit SYSENTER instruction entry.
40 *
41 * Arguments:
42 * %eax System call number.
43 * %ebx Arg1
44 * %ecx Arg2
45 * %edx Arg3
46 * %esi Arg4
47 * %edi Arg5
48 * %ebp user stack
49 * 0(%ebp) Arg6
50 *
51 * Interrupts off.
52 *
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.
56 */
57ENTRY(ia32_sysenter_target)
58 CFI_STARTPROC
59 swapgs
60 movq %gs:pda_kernelstack, %rsp
61 addq $(PDA_STACKOFFSET),%rsp
62 sti
63 movl %ebp,%ebp /* zero extension */
64 pushq $__USER32_DS
65 pushq %rbp
66 pushfq
67 movl $VSYSCALL32_SYSEXIT, %r10d
68 pushq $__USER32_CS
69 movl %eax, %eax
70 pushq %r10
71 pushq %rax
72 cld
73 SAVE_ARGS 0,0,1
74 /* no need to do an access_ok check here because rbp has been
75 32bit zero extended */
761: movl (%rbp),%r9d
77 .section __ex_table,"a"
78 .quad 1b,ia32_badarg
79 .previous
80 GET_THREAD_INFO(%r10)
81 testl $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP),threadinfo_flags(%r10)
82 jnz sysenter_tracesys
83sysenter_do_call:
84 cmpl $(IA32_NR_syscalls),%eax
85 jae ia32_badsys
86 IA32_ARG_FIXUP 1
87 call *ia32_sys_call_table(,%rax,8)
88 movq %rax,RAX-ARGOFFSET(%rsp)
89 GET_THREAD_INFO(%r10)
90 cli
91 testl $_TIF_ALLWORK_MASK,threadinfo_flags(%r10)
92 jnz int_ret_from_sys_call
93 /* clear IF, that popfq doesn't enable interrupts early */
94 andl $~0x200,EFLAGS-R11(%rsp)
95 RESTORE_ARGS 1,24,1,1,1,1
96 popfq
97 popq %rcx /* User %esp */
98 movl $VSYSCALL32_SYSEXIT,%edx /* User %eip */
99 swapgs
100 sti /* sti only takes effect after the next instruction */
101 /* sysexit */
102 .byte 0xf, 0x35
103
104sysenter_tracesys:
105 SAVE_REST
106 CLEAR_RREGS
107 movq $-ENOSYS,RAX(%rsp) /* really needed? */
108 movq %rsp,%rdi /* &pt_regs -> arg1 */
109 call syscall_trace_enter
110 LOAD_ARGS ARGOFFSET /* reload args from stack in case ptrace changed it */
111 RESTORE_REST
112 movl %ebp, %ebp
113 /* no need to do an access_ok check here because rbp has been
114 32bit zero extended */
1151: movl (%rbp),%r9d
116 .section __ex_table,"a"
117 .quad 1b,ia32_badarg
118 .previous
119 jmp sysenter_do_call
120 CFI_ENDPROC
121
122/*
123 * 32bit SYSCALL instruction entry.
124 *
125 * Arguments:
126 * %eax System call number.
127 * %ebx Arg1
128 * %ecx return EIP
129 * %edx Arg3
130 * %esi Arg4
131 * %edi Arg5
132 * %ebp Arg2 [note: not saved in the stack frame, should not be touched]
133 * %esp user stack
134 * 0(%esp) Arg6
135 *
136 * Interrupts off.
137 *
138 * This is purely a fast path. For anything complicated we use the int 0x80
139 * path below. Set up a complete hardware stack frame to share code
140 * with the int 0x80 path.
141 */
142ENTRY(ia32_cstar_target)
143 CFI_STARTPROC
144 swapgs
145 movl %esp,%r8d
146 movq %gs:pda_kernelstack,%rsp
147 sti
148 SAVE_ARGS 8,1,1
149 movl %eax,%eax /* zero extension */
150 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
151 movq %rcx,RIP-ARGOFFSET(%rsp)
152 movq %rbp,RCX-ARGOFFSET(%rsp) /* this lies slightly to ptrace */
153 movl %ebp,%ecx
154 movq $__USER32_CS,CS-ARGOFFSET(%rsp)
155 movq $__USER32_DS,SS-ARGOFFSET(%rsp)
156 movq %r11,EFLAGS-ARGOFFSET(%rsp)
157 movq %r8,RSP-ARGOFFSET(%rsp)
158 /* no need to do an access_ok check here because r8 has been
159 32bit zero extended */
160 /* hardware stack frame is complete now */
1611: movl (%r8),%r9d
162 .section __ex_table,"a"
163 .quad 1b,ia32_badarg
164 .previous
165 GET_THREAD_INFO(%r10)
166 testl $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP),threadinfo_flags(%r10)
167 jnz cstar_tracesys
168cstar_do_call:
169 cmpl $IA32_NR_syscalls,%eax
170 jae ia32_badsys
171 IA32_ARG_FIXUP 1
172 call *ia32_sys_call_table(,%rax,8)
173 movq %rax,RAX-ARGOFFSET(%rsp)
174 GET_THREAD_INFO(%r10)
175 cli
176 testl $_TIF_ALLWORK_MASK,threadinfo_flags(%r10)
177 jnz int_ret_from_sys_call
178 RESTORE_ARGS 1,-ARG_SKIP,1,1,1
179 movl RIP-ARGOFFSET(%rsp),%ecx
180 movl EFLAGS-ARGOFFSET(%rsp),%r11d
181 movl RSP-ARGOFFSET(%rsp),%esp
182 swapgs
183 sysretl
184
185cstar_tracesys:
186 SAVE_REST
187 CLEAR_RREGS
188 movq $-ENOSYS,RAX(%rsp) /* really needed? */
189 movq %rsp,%rdi /* &pt_regs -> arg1 */
190 call syscall_trace_enter
191 LOAD_ARGS ARGOFFSET /* reload args from stack in case ptrace changed it */
192 RESTORE_REST
193 movl RSP-ARGOFFSET(%rsp), %r8d
194 /* no need to do an access_ok check here because r8 has been
195 32bit zero extended */
1961: movl (%r8),%r9d
197 .section __ex_table,"a"
198 .quad 1b,ia32_badarg
199 .previous
200 jmp cstar_do_call
201
202ia32_badarg:
203 movq $-EFAULT,%rax
204 jmp ia32_sysret
205 CFI_ENDPROC
206
207/*
208 * Emulated IA32 system calls via int 0x80.
209 *
210 * Arguments:
211 * %eax System call number.
212 * %ebx Arg1
213 * %ecx Arg2
214 * %edx Arg3
215 * %esi Arg4
216 * %edi Arg5
217 * %ebp Arg6 [note: not saved in the stack frame, should not be touched]
218 *
219 * Notes:
220 * Uses the same stack frame as the x86-64 version.
221 * All registers except %eax must be saved (but ptrace may violate that)
222 * Arguments are zero extended. For system calls that want sign extension and
223 * take long arguments a wrapper is needed. Most calls can just be called
224 * directly.
225 * Assumes it is only called from user space and entered with interrupts off.
226 */
227
228ENTRY(ia32_syscall)
229 CFI_STARTPROC
230 swapgs
231 sti
232 movl %eax,%eax
233 pushq %rax
234 cld
235 /* note the registers are not zero extended to the sf.
236 this could be a problem. */
237 SAVE_ARGS 0,0,1
238 GET_THREAD_INFO(%r10)
239 testl $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP),threadinfo_flags(%r10)
240 jnz ia32_tracesys
241ia32_do_syscall:
242 cmpl $(IA32_NR_syscalls),%eax
243 jae ia32_badsys
244 IA32_ARG_FIXUP
245 call *ia32_sys_call_table(,%rax,8) # xxx: rip relative
246ia32_sysret:
247 movq %rax,RAX-ARGOFFSET(%rsp)
248 jmp int_ret_from_sys_call
249
250ia32_tracesys:
251 SAVE_REST
252 movq $-ENOSYS,RAX(%rsp) /* really needed? */
253 movq %rsp,%rdi /* &pt_regs -> arg1 */
254 call syscall_trace_enter
255 LOAD_ARGS ARGOFFSET /* reload args from stack in case ptrace changed it */
256 RESTORE_REST
257 jmp ia32_do_syscall
258
259ia32_badsys:
260 movq $0,ORIG_RAX-ARGOFFSET(%rsp)
261 movq $-ENOSYS,RAX-ARGOFFSET(%rsp)
262 jmp int_ret_from_sys_call
263
264ni_syscall:
265 movq %rax,%rdi
266 jmp sys32_ni_syscall
267
268quiet_ni_syscall:
269 movq $-ENOSYS,%rax
270 ret
271 CFI_ENDPROC
272
273 .macro PTREGSCALL label, func, arg
274 .globl \label
275\label:
276 leaq \func(%rip),%rax
277 leaq -ARGOFFSET+8(%rsp),\arg /* 8 for return address */
278 jmp ia32_ptregs_common
279 .endm
280
281 PTREGSCALL stub32_rt_sigreturn, sys32_rt_sigreturn, %rdi
282 PTREGSCALL stub32_sigreturn, sys32_sigreturn, %rdi
283 PTREGSCALL stub32_sigaltstack, sys32_sigaltstack, %rdx
284 PTREGSCALL stub32_sigsuspend, sys32_sigsuspend, %rcx
285 PTREGSCALL stub32_execve, sys32_execve, %rcx
286 PTREGSCALL stub32_fork, sys_fork, %rdi
287 PTREGSCALL stub32_clone, sys32_clone, %rdx
288 PTREGSCALL stub32_vfork, sys_vfork, %rdi
289 PTREGSCALL stub32_iopl, sys_iopl, %rsi
290 PTREGSCALL stub32_rt_sigsuspend, sys_rt_sigsuspend, %rdx
291
292ENTRY(ia32_ptregs_common)
293 CFI_STARTPROC
294 popq %r11
295 SAVE_REST
296 call *%rax
297 RESTORE_REST
298 jmp ia32_sysret /* misbalances the return cache */
299 CFI_ENDPROC
300
301 .data
302 .align 8
303 .globl ia32_sys_call_table
304ia32_sys_call_table:
305 .quad sys_restart_syscall
306 .quad sys_exit
307 .quad stub32_fork
308 .quad sys_read
309 .quad sys_write
310 .quad sys32_open /* 5 */
311 .quad sys_close
312 .quad sys32_waitpid
313 .quad sys_creat
314 .quad sys_link
315 .quad sys_unlink /* 10 */
316 .quad stub32_execve
317 .quad sys_chdir
318 .quad compat_sys_time
319 .quad sys_mknod
320 .quad sys_chmod /* 15 */
321 .quad sys_lchown16
322 .quad quiet_ni_syscall /* old break syscall holder */
323 .quad sys_stat
324 .quad sys32_lseek
325 .quad sys_getpid /* 20 */
326 .quad compat_sys_mount /* mount */
327 .quad sys_oldumount /* old_umount */
328 .quad sys_setuid16
329 .quad sys_getuid16
330 .quad compat_sys_stime /* stime */ /* 25 */
331 .quad sys32_ptrace /* ptrace */
332 .quad sys_alarm
333 .quad sys_fstat /* (old)fstat */
334 .quad sys_pause
335 .quad compat_sys_utime /* 30 */
336 .quad quiet_ni_syscall /* old stty syscall holder */
337 .quad quiet_ni_syscall /* old gtty syscall holder */
338 .quad sys_access
339 .quad sys_nice
340 .quad quiet_ni_syscall /* 35 */ /* old ftime syscall holder */
341 .quad sys_sync
342 .quad sys32_kill
343 .quad sys_rename
344 .quad sys_mkdir
345 .quad sys_rmdir /* 40 */
346 .quad sys_dup
347 .quad sys32_pipe
348 .quad compat_sys_times
349 .quad quiet_ni_syscall /* old prof syscall holder */
350 .quad sys_brk /* 45 */
351 .quad sys_setgid16
352 .quad sys_getgid16
353 .quad sys_signal
354 .quad sys_geteuid16
355 .quad sys_getegid16 /* 50 */
356 .quad sys_acct
357 .quad sys_umount /* new_umount */
358 .quad quiet_ni_syscall /* old lock syscall holder */
359 .quad compat_sys_ioctl
360 .quad compat_sys_fcntl64 /* 55 */
361 .quad quiet_ni_syscall /* old mpx syscall holder */
362 .quad sys_setpgid
363 .quad quiet_ni_syscall /* old ulimit syscall holder */
364 .quad sys32_olduname
365 .quad sys_umask /* 60 */
366 .quad sys_chroot
367 .quad sys32_ustat
368 .quad sys_dup2
369 .quad sys_getppid
370 .quad sys_getpgrp /* 65 */
371 .quad sys_setsid
372 .quad sys32_sigaction
373 .quad sys_sgetmask
374 .quad sys_ssetmask
375 .quad sys_setreuid16 /* 70 */
376 .quad sys_setregid16
377 .quad stub32_sigsuspend
378 .quad compat_sys_sigpending
379 .quad sys_sethostname
380 .quad compat_sys_setrlimit /* 75 */
381 .quad compat_sys_old_getrlimit /* old_getrlimit */
382 .quad compat_sys_getrusage
383 .quad sys32_gettimeofday
384 .quad sys32_settimeofday
385 .quad sys_getgroups16 /* 80 */
386 .quad sys_setgroups16
387 .quad sys32_old_select
388 .quad sys_symlink
389 .quad sys_lstat
390 .quad sys_readlink /* 85 */
391#ifdef CONFIG_IA32_AOUT
392 .quad sys_uselib
393#else
394 .quad quiet_ni_syscall
395#endif
396 .quad sys_swapon
397 .quad sys_reboot
398 .quad compat_sys_old_readdir
399 .quad sys32_mmap /* 90 */
400 .quad sys_munmap
401 .quad sys_truncate
402 .quad sys_ftruncate
403 .quad sys_fchmod
404 .quad sys_fchown16 /* 95 */
405 .quad sys_getpriority
406 .quad sys_setpriority
407 .quad quiet_ni_syscall /* old profil syscall holder */
408 .quad compat_sys_statfs
409 .quad compat_sys_fstatfs /* 100 */
410 .quad sys_ioperm
411 .quad compat_sys_socketcall
412 .quad sys_syslog
413 .quad compat_sys_setitimer
414 .quad compat_sys_getitimer /* 105 */
415 .quad compat_sys_newstat
416 .quad compat_sys_newlstat
417 .quad compat_sys_newfstat
418 .quad sys32_uname
419 .quad stub32_iopl /* 110 */
420 .quad sys_vhangup
421 .quad quiet_ni_syscall /* old "idle" system call */
422 .quad sys32_vm86_warning /* vm86old */
423 .quad compat_sys_wait4
424 .quad sys_swapoff /* 115 */
425 .quad sys32_sysinfo
426 .quad sys32_ipc
427 .quad sys_fsync
428 .quad stub32_sigreturn
429 .quad stub32_clone /* 120 */
430 .quad sys_setdomainname
431 .quad sys_uname
432 .quad sys_modify_ldt
433 .quad sys32_adjtimex
434 .quad sys32_mprotect /* 125 */
435 .quad compat_sys_sigprocmask
436 .quad quiet_ni_syscall /* create_module */
437 .quad sys_init_module
438 .quad sys_delete_module
439 .quad quiet_ni_syscall /* 130 get_kernel_syms */
440 .quad sys_quotactl
441 .quad sys_getpgid
442 .quad sys_fchdir
443 .quad quiet_ni_syscall /* bdflush */
444 .quad sys_sysfs /* 135 */
445 .quad sys_personality
446 .quad quiet_ni_syscall /* for afs_syscall */
447 .quad sys_setfsuid16
448 .quad sys_setfsgid16
449 .quad sys_llseek /* 140 */
450 .quad compat_sys_getdents
451 .quad compat_sys_select
452 .quad sys_flock
453 .quad sys_msync
454 .quad compat_sys_readv /* 145 */
455 .quad compat_sys_writev
456 .quad sys_getsid
457 .quad sys_fdatasync
458 .quad sys32_sysctl /* sysctl */
459 .quad sys_mlock /* 150 */
460 .quad sys_munlock
461 .quad sys_mlockall
462 .quad sys_munlockall
463 .quad sys_sched_setparam
464 .quad sys_sched_getparam /* 155 */
465 .quad sys_sched_setscheduler
466 .quad sys_sched_getscheduler
467 .quad sys_sched_yield
468 .quad sys_sched_get_priority_max
469 .quad sys_sched_get_priority_min /* 160 */
470 .quad sys_sched_rr_get_interval
471 .quad compat_sys_nanosleep
472 .quad sys_mremap
473 .quad sys_setresuid16
474 .quad sys_getresuid16 /* 165 */
475 .quad sys32_vm86_warning /* vm86 */
476 .quad quiet_ni_syscall /* query_module */
477 .quad sys_poll
478 .quad compat_sys_nfsservctl
479 .quad sys_setresgid16 /* 170 */
480 .quad sys_getresgid16
481 .quad sys_prctl
482 .quad stub32_rt_sigreturn
483 .quad sys32_rt_sigaction
484 .quad sys32_rt_sigprocmask /* 175 */
485 .quad sys32_rt_sigpending
486 .quad compat_sys_rt_sigtimedwait
487 .quad sys32_rt_sigqueueinfo
488 .quad stub32_rt_sigsuspend
489 .quad sys32_pread /* 180 */
490 .quad sys32_pwrite
491 .quad sys_chown16
492 .quad sys_getcwd
493 .quad sys_capget
494 .quad sys_capset
495 .quad stub32_sigaltstack
496 .quad sys32_sendfile
497 .quad quiet_ni_syscall /* streams1 */
498 .quad quiet_ni_syscall /* streams2 */
499 .quad stub32_vfork /* 190 */
500 .quad compat_sys_getrlimit
501 .quad sys32_mmap2
502 .quad sys32_truncate64
503 .quad sys32_ftruncate64
504 .quad sys32_stat64 /* 195 */
505 .quad sys32_lstat64
506 .quad sys32_fstat64
507 .quad sys_lchown
508 .quad sys_getuid
509 .quad sys_getgid /* 200 */
510 .quad sys_geteuid
511 .quad sys_getegid
512 .quad sys_setreuid
513 .quad sys_setregid
514 .quad sys_getgroups /* 205 */
515 .quad sys_setgroups
516 .quad sys_fchown
517 .quad sys_setresuid
518 .quad sys_getresuid
519 .quad sys_setresgid /* 210 */
520 .quad sys_getresgid
521 .quad sys_chown
522 .quad sys_setuid
523 .quad sys_setgid
524 .quad sys_setfsuid /* 215 */
525 .quad sys_setfsgid
526 .quad sys_pivot_root
527 .quad sys_mincore
528 .quad sys_madvise
529 .quad compat_sys_getdents64 /* 220 getdents64 */
530 .quad compat_sys_fcntl64
531 .quad quiet_ni_syscall /* tux */
532 .quad quiet_ni_syscall /* security */
533 .quad sys_gettid
534 .quad sys_readahead /* 225 */
535 .quad sys_setxattr
536 .quad sys_lsetxattr
537 .quad sys_fsetxattr
538 .quad sys_getxattr
539 .quad sys_lgetxattr /* 230 */
540 .quad sys_fgetxattr
541 .quad sys_listxattr
542 .quad sys_llistxattr
543 .quad sys_flistxattr
544 .quad sys_removexattr /* 235 */
545 .quad sys_lremovexattr
546 .quad sys_fremovexattr
547 .quad sys_tkill
548 .quad sys_sendfile64
549 .quad compat_sys_futex /* 240 */
550 .quad compat_sys_sched_setaffinity
551 .quad compat_sys_sched_getaffinity
552 .quad sys32_set_thread_area
553 .quad sys32_get_thread_area
554 .quad compat_sys_io_setup /* 245 */
555 .quad sys_io_destroy
556 .quad compat_sys_io_getevents
557 .quad compat_sys_io_submit
558 .quad sys_io_cancel
559 .quad sys_fadvise64 /* 250 */
560 .quad quiet_ni_syscall /* free_huge_pages */
561 .quad sys_exit_group
562 .quad sys32_lookup_dcookie
563 .quad sys_epoll_create
564 .quad sys_epoll_ctl /* 255 */
565 .quad sys_epoll_wait
566 .quad sys_remap_file_pages
567 .quad sys_set_tid_address
568 .quad sys32_timer_create
569 .quad compat_sys_timer_settime /* 260 */
570 .quad compat_sys_timer_gettime
571 .quad sys_timer_getoverrun
572 .quad sys_timer_delete
573 .quad compat_sys_clock_settime
574 .quad compat_sys_clock_gettime /* 265 */
575 .quad compat_sys_clock_getres
576 .quad compat_sys_clock_nanosleep
577 .quad compat_sys_statfs64
578 .quad compat_sys_fstatfs64
579 .quad sys_tgkill /* 270 */
580 .quad compat_sys_utimes
581 .quad sys32_fadvise64_64
582 .quad quiet_ni_syscall /* sys_vserver */
583 .quad sys_mbind
584 .quad compat_sys_get_mempolicy /* 275 */
585 .quad sys_set_mempolicy
586 .quad compat_sys_mq_open
587 .quad sys_mq_unlink
588 .quad compat_sys_mq_timedsend
589 .quad compat_sys_mq_timedreceive /* 280 */
590 .quad compat_sys_mq_notify
591 .quad compat_sys_mq_getsetattr
592 .quad quiet_ni_syscall /* reserved for kexec */
593 .quad compat_sys_waitid
594 .quad quiet_ni_syscall /* sys_altroot */
595 .quad sys_add_key
596 .quad sys_request_key
597 .quad sys_keyctl
598 /* don't forget to change IA32_NR_syscalls */
599ia32_syscall_end:
600 .rept IA32_NR_syscalls-(ia32_syscall_end-ia32_sys_call_table)/8
601 .quad ni_syscall
602 .endr