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.
93 movl $(__KERNEL_DS),%edx; \
110 #define GET_CURRENT(reg) \
115 pushfl # We get a different stack layout with call gates,
116 pushl %eax # which has to be cleaned up later..
118 movl EIP(%esp),%eax # due to call gates, this is eflags, not eip..
119 movl CS(%esp),%edx # this is eip..
120 movl EFLAGS(%esp),%ecx # and this is cs..
121 movl %eax,EFLAGS(%esp) #
122 movl %edx,EIP(%esp) # Now we move them to their "normal" places
126 andl $-8192,%ebx # GET_CURRENT
127 movl exec_domain(%ebx),%edx # Get the execution domain
128 movl 4(%edx),%edx # Get the lcall7 handler for the domain
131 jmp ret_from_sys_call
136 .globl ret_from_smpfork
139 btrl $0, SYMBOL_NAME(scheduler_lock)
140 jmp ret_from_sys_call
144 * Return to user mode is not as complex as all this looks,
145 * but we want the default path for a system call return to
146 * go as quickly as possible which is why some of this is
147 * less clear than it otherwise should be.
151 pushl %eax # save orig_eax
154 cmpl $(NR_syscalls),%eax
156 testb $0x20,flags(%ebx) # PF_TRACESYS
158 call SYMBOL_NAME(sys_call_table)(,%eax,4)
159 movl %eax,EAX(%esp) # save the return value
161 .globl ret_from_sys_call
164 movl SYMBOL_NAME(bh_mask),%eax
165 andl SYMBOL_NAME(bh_active),%eax
166 jne handle_bottom_half
168 cmpl $0,SYMBOL_NAME(need_resched)
170 cmpl $0,sigpending(%ebx)
175 testl $(VM_MASK),EFLAGS(%esp)
177 jne v86_signal_return
179 call SYMBOL_NAME(do_signal)
184 call SYMBOL_NAME(save_v86_state)
188 call SYMBOL_NAME(do_signal)
193 movl $-ENOSYS,EAX(%esp)
194 call SYMBOL_NAME(syscall_trace)
195 movl ORIG_EAX(%esp),%eax
196 call SYMBOL_NAME(sys_call_table)(,%eax,4)
197 movl %eax,EAX(%esp) # save the return value
198 call SYMBOL_NAME(syscall_trace)
199 jmp ret_from_sys_call
201 movl $-ENOSYS,EAX(%esp)
202 jmp ret_from_sys_call
206 movl SYMBOL_NAME(bh_mask),%eax
207 andl SYMBOL_NAME(bh_active),%eax
208 jne handle_bottom_half
212 movl EFLAGS(%esp),%eax # mix EFLAGS and CS
214 testl $(VM_MASK | 3),%eax # return to VM86 mode or non-supervisor?
215 jne ret_with_reschedule
221 jmp SYMBOL_NAME(do_bottom_half)
225 pushl $ret_from_sys_call
226 jmp SYMBOL_NAME(schedule) # test
230 pushl $0 # no error code
231 pushl $ SYMBOL_NAME(do_divide_error)
244 xorl %ecx,%ecx # zero ecx
246 mov %es,%cx # get the lower order bits of es
247 xchgl %eax, ORIG_EAX(%esp) # orig_eax (get the error code. )
249 xchgl %ecx, ES(%esp) # get the address and save es.
250 pushl %eax # push the error code
252 movl $(__KERNEL_DS),%edx
258 jmp ret_from_exception
260 ENTRY(coprocessor_error)
262 pushl $ SYMBOL_NAME(do_coprocessor_error)
265 ENTRY(device_not_available)
266 pushl $-1 # mark this as an int
269 pushl $ret_from_exception
271 testl $0x4,%eax # EM (math emulation bit)
272 je SYMBOL_NAME(math_state_restore)
273 pushl $0 # temporary storage for ORIG_EIP
274 call SYMBOL_NAME(math_emulate)
280 pushl $ SYMBOL_NAME(do_debug)
285 pushl $ SYMBOL_NAME(do_nmi)
290 pushl $ SYMBOL_NAME(do_int3)
295 pushl $ SYMBOL_NAME(do_overflow)
300 pushl $ SYMBOL_NAME(do_bounds)
305 pushl $ SYMBOL_NAME(do_invalid_op)
308 ENTRY(coprocessor_segment_overrun)
310 pushl $ SYMBOL_NAME(do_coprocessor_segment_overrun)
315 pushl $ SYMBOL_NAME(do_reserved)
319 pushl $ SYMBOL_NAME(do_double_fault)
323 pushl $ SYMBOL_NAME(do_invalid_TSS)
326 ENTRY(segment_not_present)
327 pushl $ SYMBOL_NAME(do_segment_not_present)
331 pushl $ SYMBOL_NAME(do_stack_segment)
334 ENTRY(general_protection)
335 pushl $ SYMBOL_NAME(do_general_protection)
338 ENTRY(alignment_check)
339 pushl $ SYMBOL_NAME(do_alignment_check)
343 pushl $ SYMBOL_NAME(do_page_fault)
346 ENTRY(spurious_interrupt_bug)
348 pushl $ SYMBOL_NAME(do_spurious_interrupt_bug)
352 ENTRY(sys_call_table)
353 .long SYMBOL_NAME(sys_setup) /* 0 */
354 .long SYMBOL_NAME(sys_exit)
355 .long SYMBOL_NAME(sys_fork)
356 .long SYMBOL_NAME(sys_read)
357 .long SYMBOL_NAME(sys_write)
358 .long SYMBOL_NAME(sys_open) /* 5 */
359 .long SYMBOL_NAME(sys_close)
360 .long SYMBOL_NAME(sys_waitpid)
361 .long SYMBOL_NAME(sys_creat)
362 .long SYMBOL_NAME(sys_link)
363 .long SYMBOL_NAME(sys_unlink) /* 10 */
364 .long SYMBOL_NAME(sys_execve)
365 .long SYMBOL_NAME(sys_chdir)
366 .long SYMBOL_NAME(sys_time)
367 .long SYMBOL_NAME(sys_mknod)
368 .long SYMBOL_NAME(sys_chmod) /* 15 */
369 .long SYMBOL_NAME(sys_chown)
370 .long SYMBOL_NAME(sys_ni_syscall) /* old break syscall holder */
371 .long SYMBOL_NAME(sys_stat)
372 .long SYMBOL_NAME(sys_lseek)
373 .long SYMBOL_NAME(sys_getpid) /* 20 */
374 .long SYMBOL_NAME(sys_mount)
375 .long SYMBOL_NAME(sys_umount)
376 .long SYMBOL_NAME(sys_setuid)
377 .long SYMBOL_NAME(sys_getuid)
378 .long SYMBOL_NAME(sys_stime) /* 25 */
379 .long SYMBOL_NAME(sys_ptrace)
380 .long SYMBOL_NAME(sys_alarm)
381 .long SYMBOL_NAME(sys_fstat)
382 .long SYMBOL_NAME(sys_pause)
383 .long SYMBOL_NAME(sys_utime) /* 30 */
384 .long SYMBOL_NAME(sys_ni_syscall) /* old stty syscall holder */
385 .long SYMBOL_NAME(sys_ni_syscall) /* old gtty syscall holder */
386 .long SYMBOL_NAME(sys_access)
387 .long SYMBOL_NAME(sys_nice)
388 .long SYMBOL_NAME(sys_ni_syscall) /* 35 */ /* old ftime syscall holder */
389 .long SYMBOL_NAME(sys_sync)
390 .long SYMBOL_NAME(sys_kill)
391 .long SYMBOL_NAME(sys_rename)
392 .long SYMBOL_NAME(sys_mkdir)
393 .long SYMBOL_NAME(sys_rmdir) /* 40 */
394 .long SYMBOL_NAME(sys_dup)
395 .long SYMBOL_NAME(sys_pipe)
396 .long SYMBOL_NAME(sys_times)
397 .long SYMBOL_NAME(sys_ni_syscall) /* old prof syscall holder */
398 .long SYMBOL_NAME(sys_brk) /* 45 */
399 .long SYMBOL_NAME(sys_setgid)
400 .long SYMBOL_NAME(sys_getgid)
401 .long SYMBOL_NAME(sys_signal)
402 .long SYMBOL_NAME(sys_geteuid)
403 .long SYMBOL_NAME(sys_getegid) /* 50 */
404 .long SYMBOL_NAME(sys_acct)
405 .long SYMBOL_NAME(sys_ni_syscall) /* old phys syscall holder */
406 .long SYMBOL_NAME(sys_ni_syscall) /* old lock syscall holder */
407 .long SYMBOL_NAME(sys_ioctl)
408 .long SYMBOL_NAME(sys_fcntl) /* 55 */
409 .long SYMBOL_NAME(sys_ni_syscall) /* old mpx syscall holder */
410 .long SYMBOL_NAME(sys_setpgid)
411 .long SYMBOL_NAME(sys_ni_syscall) /* old ulimit syscall holder */
412 .long SYMBOL_NAME(sys_olduname)
413 .long SYMBOL_NAME(sys_umask) /* 60 */
414 .long SYMBOL_NAME(sys_chroot)
415 .long SYMBOL_NAME(sys_ustat)
416 .long SYMBOL_NAME(sys_dup2)
417 .long SYMBOL_NAME(sys_getppid)
418 .long SYMBOL_NAME(sys_getpgrp) /* 65 */
419 .long SYMBOL_NAME(sys_setsid)
420 .long SYMBOL_NAME(sys_sigaction)
421 .long SYMBOL_NAME(sys_sgetmask)
422 .long SYMBOL_NAME(sys_ssetmask)
423 .long SYMBOL_NAME(sys_setreuid) /* 70 */
424 .long SYMBOL_NAME(sys_setregid)
425 .long SYMBOL_NAME(sys_sigsuspend)
426 .long SYMBOL_NAME(sys_sigpending)
427 .long SYMBOL_NAME(sys_sethostname)
428 .long SYMBOL_NAME(sys_setrlimit) /* 75 */
429 .long SYMBOL_NAME(sys_getrlimit)
430 .long SYMBOL_NAME(sys_getrusage)
431 .long SYMBOL_NAME(sys_gettimeofday)
432 .long SYMBOL_NAME(sys_settimeofday)
433 .long SYMBOL_NAME(sys_getgroups) /* 80 */
434 .long SYMBOL_NAME(sys_setgroups)
435 .long SYMBOL_NAME(old_select)
436 .long SYMBOL_NAME(sys_symlink)
437 .long SYMBOL_NAME(sys_lstat)
438 .long SYMBOL_NAME(sys_readlink) /* 85 */
439 .long SYMBOL_NAME(sys_uselib)
440 .long SYMBOL_NAME(sys_swapon)
441 .long SYMBOL_NAME(sys_reboot)
442 .long SYMBOL_NAME(old_readdir)
443 .long SYMBOL_NAME(old_mmap) /* 90 */
444 .long SYMBOL_NAME(sys_munmap)
445 .long SYMBOL_NAME(sys_truncate)
446 .long SYMBOL_NAME(sys_ftruncate)
447 .long SYMBOL_NAME(sys_fchmod)
448 .long SYMBOL_NAME(sys_fchown) /* 95 */
449 .long SYMBOL_NAME(sys_getpriority)
450 .long SYMBOL_NAME(sys_setpriority)
451 .long SYMBOL_NAME(sys_ni_syscall) /* old profil syscall holder */
452 .long SYMBOL_NAME(sys_statfs)
453 .long SYMBOL_NAME(sys_fstatfs) /* 100 */
454 .long SYMBOL_NAME(sys_ioperm)
455 .long SYMBOL_NAME(sys_socketcall)
456 .long SYMBOL_NAME(sys_syslog)
457 .long SYMBOL_NAME(sys_setitimer)
458 .long SYMBOL_NAME(sys_getitimer) /* 105 */
459 .long SYMBOL_NAME(sys_newstat)
460 .long SYMBOL_NAME(sys_newlstat)
461 .long SYMBOL_NAME(sys_newfstat)
462 .long SYMBOL_NAME(sys_uname)
463 .long SYMBOL_NAME(sys_iopl) /* 110 */
464 .long SYMBOL_NAME(sys_vhangup)
465 .long SYMBOL_NAME(sys_idle)
466 .long SYMBOL_NAME(sys_vm86old)
467 .long SYMBOL_NAME(sys_wait4)
468 .long SYMBOL_NAME(sys_swapoff) /* 115 */
469 .long SYMBOL_NAME(sys_sysinfo)
470 .long SYMBOL_NAME(sys_ipc)
471 .long SYMBOL_NAME(sys_fsync)
472 .long SYMBOL_NAME(sys_sigreturn)
473 .long SYMBOL_NAME(sys_clone) /* 120 */
474 .long SYMBOL_NAME(sys_setdomainname)
475 .long SYMBOL_NAME(sys_newuname)
476 .long SYMBOL_NAME(sys_modify_ldt)
477 .long SYMBOL_NAME(sys_adjtimex)
478 .long SYMBOL_NAME(sys_mprotect) /* 125 */
479 .long SYMBOL_NAME(sys_sigprocmask)
480 .long SYMBOL_NAME(sys_create_module)
481 .long SYMBOL_NAME(sys_init_module)
482 .long SYMBOL_NAME(sys_delete_module)
483 .long SYMBOL_NAME(sys_get_kernel_syms) /* 130 */
484 .long SYMBOL_NAME(sys_quotactl)
485 .long SYMBOL_NAME(sys_getpgid)
486 .long SYMBOL_NAME(sys_fchdir)
487 .long SYMBOL_NAME(sys_bdflush)
488 .long SYMBOL_NAME(sys_sysfs) /* 135 */
489 .long SYMBOL_NAME(sys_personality)
490 .long SYMBOL_NAME(sys_ni_syscall) /* for afs_syscall */
491 .long SYMBOL_NAME(sys_setfsuid)
492 .long SYMBOL_NAME(sys_setfsgid)
493 .long SYMBOL_NAME(sys_llseek) /* 140 */
494 .long SYMBOL_NAME(sys_getdents)
495 .long SYMBOL_NAME(sys_select)
496 .long SYMBOL_NAME(sys_flock)
497 .long SYMBOL_NAME(sys_msync)
498 .long SYMBOL_NAME(sys_readv) /* 145 */
499 .long SYMBOL_NAME(sys_writev)
500 .long SYMBOL_NAME(sys_getsid)
501 .long SYMBOL_NAME(sys_fdatasync)
502 .long SYMBOL_NAME(sys_sysctl)
503 .long SYMBOL_NAME(sys_mlock) /* 150 */
504 .long SYMBOL_NAME(sys_munlock)
505 .long SYMBOL_NAME(sys_mlockall)
506 .long SYMBOL_NAME(sys_munlockall)
507 .long SYMBOL_NAME(sys_sched_setparam)
508 .long SYMBOL_NAME(sys_sched_getparam) /* 155 */
509 .long SYMBOL_NAME(sys_sched_setscheduler)
510 .long SYMBOL_NAME(sys_sched_getscheduler)
511 .long SYMBOL_NAME(sys_sched_yield)
512 .long SYMBOL_NAME(sys_sched_get_priority_max)
513 .long SYMBOL_NAME(sys_sched_get_priority_min) /* 160 */
514 .long SYMBOL_NAME(sys_sched_rr_get_interval)
515 .long SYMBOL_NAME(sys_nanosleep)
516 .long SYMBOL_NAME(sys_mremap)
517 .long SYMBOL_NAME(sys_setresuid)
518 .long SYMBOL_NAME(sys_getresuid) /* 165 */
519 .long SYMBOL_NAME(sys_vm86)
520 .long SYMBOL_NAME(sys_query_module)
521 .long SYMBOL_NAME(sys_poll)
522 .long SYMBOL_NAME(sys_nfsservctl)
523 .long SYMBOL_NAME(sys_setresgid) /* 170 */
524 .long SYMBOL_NAME(sys_getresgid)
525 .long SYMBOL_NAME(sys_prctl)
526 .long SYMBOL_NAME(sys_rt_sigreturn)
527 .long SYMBOL_NAME(sys_rt_sigaction)
528 .long SYMBOL_NAME(sys_rt_sigprocmask) /* 175 */
529 .long SYMBOL_NAME(sys_rt_sigpending)
530 .long SYMBOL_NAME(sys_rt_sigtimedwait)
531 .long SYMBOL_NAME(sys_rt_sigqueueinfo)
532 .long SYMBOL_NAME(sys_rt_sigsuspend)
533 .long SYMBOL_NAME(sys_pread) /* 180 */
534 .long SYMBOL_NAME(sys_pwrite)
535 .long SYMBOL_NAME(sys_lchown);
537 .rept NR_syscalls-182
538 .long SYMBOL_NAME(sys_ni_syscall)