2 * linux/arch/i386/entry.S
4 * Copyright (C) 1991, 1992 Linus Torvalds
8 * entry.S contains the system-call and fault low-level handling routines.
9 * This also contains the timer-interrupt handler, as well as all interrupts
10 * and faults that can result in a task-switch.
12 * NOTE: This code handles signal-recognition, which happens every time
13 * after a timer-interrupt and after each system call.
15 * I changed all the .align's to 4 (16 byte alignment), as that's faster
18 * Stack layout in 'ret_from_system_call':
19 * ptrace needs to have all regs on the stack.
20 * if the order here is changed, it needs to be
21 * updated in fork.c:copy_process, signal.c:do_signal,
22 * ptrace.c and ptrace.h
40 * "current" is in register %ebx during any slow entries.
43 #include <linux/sys.h>
44 #include <linux/linkage.h>
45 #include <asm/segment.h>
71 * these are offsets into the task-struct.
94 movl $(__KERNEL_DS),%edx; \
110 .section .fixup,"ax"; \
122 .section __ex_table,"a";\
129 #define GET_CURRENT(reg) \
134 pushfl # We get a different stack layout with call gates,
135 pushl %eax # which has to be cleaned up later..
137 movl EIP(%esp),%eax # due to call gates, this is eflags, not eip..
138 movl CS(%esp),%edx # this is eip..
139 movl EFLAGS(%esp),%ecx # and this is cs..
140 movl %eax,EFLAGS(%esp) #
141 movl %edx,EIP(%esp) # Now we move them to their "normal" places
145 andl $-8192,%ebx # GET_CURRENT
146 movl exec_domain(%ebx),%edx # Get the execution domain
147 movl 4(%edx),%edx # Get the lcall7 handler for the domain
150 jmp ret_from_sys_call
157 call SYMBOL_NAME(schedule_tail)
160 jmp ret_from_sys_call
163 * Return to user mode is not as complex as all this looks,
164 * but we want the default path for a system call return to
165 * go as quickly as possible which is why some of this is
166 * less clear than it otherwise should be.
170 pushl %eax # save orig_eax
173 cmpl $(NR_syscalls),%eax
175 testb $0x20,flags(%ebx) # PF_TRACESYS
177 call *SYMBOL_NAME(sys_call_table)(,%eax,4)
178 movl %eax,EAX(%esp) # save the return value
180 .globl ret_from_sys_call
183 movl SYMBOL_NAME(bh_mask),%eax
184 andl SYMBOL_NAME(bh_active),%eax
185 jne handle_bottom_half
187 cmpl $0,need_resched(%ebx)
189 cmpl $0,sigpending(%ebx)
196 sti # we can get here from an interrupt handler
197 testl $(VM_MASK),EFLAGS(%esp)
199 jne v86_signal_return
201 call SYMBOL_NAME(do_signal)
206 call SYMBOL_NAME(save_v86_state)
209 call SYMBOL_NAME(do_signal)
214 movl $-ENOSYS,EAX(%esp)
215 call SYMBOL_NAME(syscall_trace)
216 movl ORIG_EAX(%esp),%eax
217 call *SYMBOL_NAME(sys_call_table)(,%eax,4)
218 movl %eax,EAX(%esp) # save the return value
219 call SYMBOL_NAME(syscall_trace)
220 jmp ret_from_sys_call
222 movl $-ENOSYS,EAX(%esp)
223 jmp ret_from_sys_call
227 movl SYMBOL_NAME(bh_mask),%eax
228 andl SYMBOL_NAME(bh_active),%eax
229 jne handle_bottom_half
233 movl EFLAGS(%esp),%eax # mix EFLAGS and CS
235 testl $(VM_MASK | 3),%eax # return to VM86 mode or non-supervisor?
236 jne ret_with_reschedule
241 call SYMBOL_NAME(do_bottom_half)
246 call SYMBOL_NAME(schedule) # test
247 jmp ret_from_sys_call
250 pushl $0 # no error code
251 pushl $ SYMBOL_NAME(do_divide_error)
266 xchgl %eax, ORIG_EAX(%esp) # orig_eax (get the error code. )
268 xchgl %ecx, ES(%esp) # get the address and save es.
269 pushl %eax # push the error code
271 movl $(__KERNEL_DS),%edx
277 jmp ret_from_exception
279 ENTRY(coprocessor_error)
281 pushl $ SYMBOL_NAME(do_coprocessor_error)
284 ENTRY(device_not_available)
285 pushl $-1 # mark this as an int
288 pushl $ret_from_exception
290 testl $0x4,%eax # EM (math emulation bit)
291 je SYMBOL_NAME(math_state_restore)
292 pushl $0 # temporary storage for ORIG_EIP
293 call SYMBOL_NAME(math_emulate)
299 pushl $ SYMBOL_NAME(do_debug)
304 pushl $ SYMBOL_NAME(do_nmi)
309 pushl $ SYMBOL_NAME(do_int3)
314 pushl $ SYMBOL_NAME(do_overflow)
319 pushl $ SYMBOL_NAME(do_bounds)
324 pushl $ SYMBOL_NAME(do_invalid_op)
327 ENTRY(coprocessor_segment_overrun)
329 pushl $ SYMBOL_NAME(do_coprocessor_segment_overrun)
334 pushl $ SYMBOL_NAME(do_reserved)
338 pushl $ SYMBOL_NAME(do_double_fault)
342 pushl $ SYMBOL_NAME(do_invalid_TSS)
345 ENTRY(segment_not_present)
346 pushl $ SYMBOL_NAME(do_segment_not_present)
350 pushl $ SYMBOL_NAME(do_stack_segment)
353 ENTRY(general_protection)
354 pushl $ SYMBOL_NAME(do_general_protection)
357 ENTRY(alignment_check)
358 pushl $ SYMBOL_NAME(do_alignment_check)
362 pushl $ SYMBOL_NAME(do_page_fault)
365 ENTRY(spurious_interrupt_bug)
367 pushl $ SYMBOL_NAME(do_spurious_interrupt_bug)
371 ENTRY(sys_call_table)
372 .long SYMBOL_NAME(sys_ni_syscall) /* 0 - old "setup()" system call*/
373 .long SYMBOL_NAME(sys_exit)
374 .long SYMBOL_NAME(sys_fork)
375 .long SYMBOL_NAME(sys_read)
376 .long SYMBOL_NAME(sys_write)
377 .long SYMBOL_NAME(sys_open) /* 5 */
378 .long SYMBOL_NAME(sys_close)
379 .long SYMBOL_NAME(sys_waitpid)
380 .long SYMBOL_NAME(sys_creat)
381 .long SYMBOL_NAME(sys_link)
382 .long SYMBOL_NAME(sys_unlink) /* 10 */
383 .long SYMBOL_NAME(sys_execve)
384 .long SYMBOL_NAME(sys_chdir)
385 .long SYMBOL_NAME(sys_time)
386 .long SYMBOL_NAME(sys_mknod)
387 .long SYMBOL_NAME(sys_chmod) /* 15 */
388 .long SYMBOL_NAME(sys_lchown)
389 .long SYMBOL_NAME(sys_ni_syscall) /* old break syscall holder */
390 .long SYMBOL_NAME(sys_stat)
391 .long SYMBOL_NAME(sys_lseek)
392 .long SYMBOL_NAME(sys_getpid) /* 20 */
393 .long SYMBOL_NAME(sys_mount)
394 .long SYMBOL_NAME(sys_oldumount)
395 .long SYMBOL_NAME(sys_setuid)
396 .long SYMBOL_NAME(sys_getuid)
397 .long SYMBOL_NAME(sys_stime) /* 25 */
398 .long SYMBOL_NAME(sys_ptrace)
399 .long SYMBOL_NAME(sys_alarm)
400 .long SYMBOL_NAME(sys_fstat)
401 .long SYMBOL_NAME(sys_pause)
402 .long SYMBOL_NAME(sys_utime) /* 30 */
403 .long SYMBOL_NAME(sys_ni_syscall) /* old stty syscall holder */
404 .long SYMBOL_NAME(sys_ni_syscall) /* old gtty syscall holder */
405 .long SYMBOL_NAME(sys_access)
406 .long SYMBOL_NAME(sys_nice)
407 .long SYMBOL_NAME(sys_ni_syscall) /* 35 */ /* old ftime syscall holder */
408 .long SYMBOL_NAME(sys_sync)
409 .long SYMBOL_NAME(sys_kill)
410 .long SYMBOL_NAME(sys_rename)
411 .long SYMBOL_NAME(sys_mkdir)
412 .long SYMBOL_NAME(sys_rmdir) /* 40 */
413 .long SYMBOL_NAME(sys_dup)
414 .long SYMBOL_NAME(sys_pipe)
415 .long SYMBOL_NAME(sys_times)
416 .long SYMBOL_NAME(sys_ni_syscall) /* old prof syscall holder */
417 .long SYMBOL_NAME(sys_brk) /* 45 */
418 .long SYMBOL_NAME(sys_setgid)
419 .long SYMBOL_NAME(sys_getgid)
420 .long SYMBOL_NAME(sys_signal)
421 .long SYMBOL_NAME(sys_geteuid)
422 .long SYMBOL_NAME(sys_getegid) /* 50 */
423 .long SYMBOL_NAME(sys_acct)
424 .long SYMBOL_NAME(sys_umount) /* recycled never used phys() */
425 .long SYMBOL_NAME(sys_ni_syscall) /* old lock syscall holder */
426 .long SYMBOL_NAME(sys_ioctl)
427 .long SYMBOL_NAME(sys_fcntl) /* 55 */
428 .long SYMBOL_NAME(sys_ni_syscall) /* old mpx syscall holder */
429 .long SYMBOL_NAME(sys_setpgid)
430 .long SYMBOL_NAME(sys_ni_syscall) /* old ulimit syscall holder */
431 .long SYMBOL_NAME(sys_olduname)
432 .long SYMBOL_NAME(sys_umask) /* 60 */
433 .long SYMBOL_NAME(sys_chroot)
434 .long SYMBOL_NAME(sys_ustat)
435 .long SYMBOL_NAME(sys_dup2)
436 .long SYMBOL_NAME(sys_getppid)
437 .long SYMBOL_NAME(sys_getpgrp) /* 65 */
438 .long SYMBOL_NAME(sys_setsid)
439 .long SYMBOL_NAME(sys_sigaction)
440 .long SYMBOL_NAME(sys_sgetmask)
441 .long SYMBOL_NAME(sys_ssetmask)
442 .long SYMBOL_NAME(sys_setreuid) /* 70 */
443 .long SYMBOL_NAME(sys_setregid)
444 .long SYMBOL_NAME(sys_sigsuspend)
445 .long SYMBOL_NAME(sys_sigpending)
446 .long SYMBOL_NAME(sys_sethostname)
447 .long SYMBOL_NAME(sys_setrlimit) /* 75 */
448 .long SYMBOL_NAME(sys_getrlimit)
449 .long SYMBOL_NAME(sys_getrusage)
450 .long SYMBOL_NAME(sys_gettimeofday)
451 .long SYMBOL_NAME(sys_settimeofday)
452 .long SYMBOL_NAME(sys_getgroups) /* 80 */
453 .long SYMBOL_NAME(sys_setgroups)
454 .long SYMBOL_NAME(old_select)
455 .long SYMBOL_NAME(sys_symlink)
456 .long SYMBOL_NAME(sys_lstat)
457 .long SYMBOL_NAME(sys_readlink) /* 85 */
458 .long SYMBOL_NAME(sys_uselib)
459 .long SYMBOL_NAME(sys_swapon)
460 .long SYMBOL_NAME(sys_reboot)
461 .long SYMBOL_NAME(old_readdir)
462 .long SYMBOL_NAME(old_mmap) /* 90 */
463 .long SYMBOL_NAME(sys_munmap)
464 .long SYMBOL_NAME(sys_truncate)
465 .long SYMBOL_NAME(sys_ftruncate)
466 .long SYMBOL_NAME(sys_fchmod)
467 .long SYMBOL_NAME(sys_fchown) /* 95 */
468 .long SYMBOL_NAME(sys_getpriority)
469 .long SYMBOL_NAME(sys_setpriority)
470 .long SYMBOL_NAME(sys_ni_syscall) /* old profil syscall holder */
471 .long SYMBOL_NAME(sys_statfs)
472 .long SYMBOL_NAME(sys_fstatfs) /* 100 */
473 .long SYMBOL_NAME(sys_ioperm)
474 .long SYMBOL_NAME(sys_socketcall)
475 .long SYMBOL_NAME(sys_syslog)
476 .long SYMBOL_NAME(sys_setitimer)
477 .long SYMBOL_NAME(sys_getitimer) /* 105 */
478 .long SYMBOL_NAME(sys_newstat)
479 .long SYMBOL_NAME(sys_newlstat)
480 .long SYMBOL_NAME(sys_newfstat)
481 .long SYMBOL_NAME(sys_uname)
482 .long SYMBOL_NAME(sys_iopl) /* 110 */
483 .long SYMBOL_NAME(sys_vhangup)
484 .long SYMBOL_NAME(sys_idle)
485 .long SYMBOL_NAME(sys_vm86old)
486 .long SYMBOL_NAME(sys_wait4)
487 .long SYMBOL_NAME(sys_swapoff) /* 115 */
488 .long SYMBOL_NAME(sys_sysinfo)
489 .long SYMBOL_NAME(sys_ipc)
490 .long SYMBOL_NAME(sys_fsync)
491 .long SYMBOL_NAME(sys_sigreturn)
492 .long SYMBOL_NAME(sys_clone) /* 120 */
493 .long SYMBOL_NAME(sys_setdomainname)
494 .long SYMBOL_NAME(sys_newuname)
495 .long SYMBOL_NAME(sys_modify_ldt)
496 .long SYMBOL_NAME(sys_adjtimex)
497 .long SYMBOL_NAME(sys_mprotect) /* 125 */
498 .long SYMBOL_NAME(sys_sigprocmask)
499 .long SYMBOL_NAME(sys_create_module)
500 .long SYMBOL_NAME(sys_init_module)
501 .long SYMBOL_NAME(sys_delete_module)
502 .long SYMBOL_NAME(sys_get_kernel_syms) /* 130 */
503 .long SYMBOL_NAME(sys_quotactl)
504 .long SYMBOL_NAME(sys_getpgid)
505 .long SYMBOL_NAME(sys_fchdir)
506 .long SYMBOL_NAME(sys_bdflush)
507 .long SYMBOL_NAME(sys_sysfs) /* 135 */
508 .long SYMBOL_NAME(sys_personality)
509 .long SYMBOL_NAME(sys_ni_syscall) /* for afs_syscall */
510 .long SYMBOL_NAME(sys_setfsuid)
511 .long SYMBOL_NAME(sys_setfsgid)
512 .long SYMBOL_NAME(sys_llseek) /* 140 */
513 .long SYMBOL_NAME(sys_getdents)
514 .long SYMBOL_NAME(sys_select)
515 .long SYMBOL_NAME(sys_flock)
516 .long SYMBOL_NAME(sys_msync)
517 .long SYMBOL_NAME(sys_readv) /* 145 */
518 .long SYMBOL_NAME(sys_writev)
519 .long SYMBOL_NAME(sys_getsid)
520 .long SYMBOL_NAME(sys_fdatasync)
521 .long SYMBOL_NAME(sys_sysctl)
522 .long SYMBOL_NAME(sys_mlock) /* 150 */
523 .long SYMBOL_NAME(sys_munlock)
524 .long SYMBOL_NAME(sys_mlockall)
525 .long SYMBOL_NAME(sys_munlockall)
526 .long SYMBOL_NAME(sys_sched_setparam)
527 .long SYMBOL_NAME(sys_sched_getparam) /* 155 */
528 .long SYMBOL_NAME(sys_sched_setscheduler)
529 .long SYMBOL_NAME(sys_sched_getscheduler)
530 .long SYMBOL_NAME(sys_sched_yield)
531 .long SYMBOL_NAME(sys_sched_get_priority_max)
532 .long SYMBOL_NAME(sys_sched_get_priority_min) /* 160 */
533 .long SYMBOL_NAME(sys_sched_rr_get_interval)
534 .long SYMBOL_NAME(sys_nanosleep)
535 .long SYMBOL_NAME(sys_mremap)
536 .long SYMBOL_NAME(sys_setresuid)
537 .long SYMBOL_NAME(sys_getresuid) /* 165 */
538 .long SYMBOL_NAME(sys_vm86)
539 .long SYMBOL_NAME(sys_query_module)
540 .long SYMBOL_NAME(sys_poll)
541 .long SYMBOL_NAME(sys_nfsservctl)
542 .long SYMBOL_NAME(sys_setresgid) /* 170 */
543 .long SYMBOL_NAME(sys_getresgid)
544 .long SYMBOL_NAME(sys_prctl)
545 .long SYMBOL_NAME(sys_rt_sigreturn)
546 .long SYMBOL_NAME(sys_rt_sigaction)
547 .long SYMBOL_NAME(sys_rt_sigprocmask) /* 175 */
548 .long SYMBOL_NAME(sys_rt_sigpending)
549 .long SYMBOL_NAME(sys_rt_sigtimedwait)
550 .long SYMBOL_NAME(sys_rt_sigqueueinfo)
551 .long SYMBOL_NAME(sys_rt_sigsuspend)
552 .long SYMBOL_NAME(sys_pread) /* 180 */
553 .long SYMBOL_NAME(sys_pwrite)
554 .long SYMBOL_NAME(sys_chown)
555 .long SYMBOL_NAME(sys_getcwd)
556 .long SYMBOL_NAME(sys_capget)
557 .long SYMBOL_NAME(sys_capset) /* 185 */
558 .long SYMBOL_NAME(sys_sigaltstack)
559 .long SYMBOL_NAME(sys_sendfile)
560 .long SYMBOL_NAME(sys_ni_syscall) /* streams1 */
561 .long SYMBOL_NAME(sys_ni_syscall) /* streams2 */
562 .long SYMBOL_NAME(sys_vfork) /* 190 */
565 * NOTE!! This doesn't have to be exact - we just have
566 * to make sure we have _enough_ of the "sys_ni_syscall"
567 * entries. Don't panic if you notice that this hasn't
568 * been shrunk every time we add a new system call.
570 .rept NR_syscalls-190
571 .long SYMBOL_NAME(sys_ni_syscall)