This commit was manufactured by cvs2svn to create tag
[linux-2.6.git] / arch / i386 / kernel / entry.S
1 /*
2  *  linux/arch/i386/entry.S
3  *
4  *  Copyright (C) 1991, 1992  Linus Torvalds
5  */
6
7 /*
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.
11  *
12  * NOTE: This code handles signal-recognition, which happens every time
13  * after a timer-interrupt and after each system call.
14  *
15  * I changed all the .align's to 4 (16 byte alignment), as that's faster
16  * on a 486.
17  *
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
23  *
24  *       0(%esp) - %ebx
25  *       4(%esp) - %ecx
26  *       8(%esp) - %edx
27  *       C(%esp) - %esi
28  *      10(%esp) - %edi
29  *      14(%esp) - %ebp
30  *      18(%esp) - %eax
31  *      1C(%esp) - %ds
32  *      20(%esp) - %es
33  *      24(%esp) - orig_eax
34  *      28(%esp) - %eip
35  *      2C(%esp) - %cs
36  *      30(%esp) - %eflags
37  *      34(%esp) - %oldesp
38  *      38(%esp) - %oldss
39  *
40  * "current" is in register %ebx during any slow entries.
41  */
42
43 #include <linux/config.h>
44 #include <linux/linkage.h>
45 #include <asm/thread_info.h>
46 #include <asm/errno.h>
47 #include <asm/segment.h>
48 #include <asm/smp.h>
49 #include <asm/page.h>
50 #include "irq_vectors.h"
51
52 #define nr_syscalls ((syscall_table_size)/4)
53
54 EBX             = 0x00
55 ECX             = 0x04
56 EDX             = 0x08
57 ESI             = 0x0C
58 EDI             = 0x10
59 EBP             = 0x14
60 EAX             = 0x18
61 DS              = 0x1C
62 ES              = 0x20
63 ORIG_EAX        = 0x24
64 EIP             = 0x28
65 CS              = 0x2C
66 EFLAGS          = 0x30
67 OLDESP          = 0x34
68 OLDSS           = 0x38
69
70 CF_MASK         = 0x00000001
71 TF_MASK         = 0x00000100
72 IF_MASK         = 0x00000200
73 DF_MASK         = 0x00000400 
74 NT_MASK         = 0x00004000
75 VM_MASK         = 0x00020000
76
77 #ifdef CONFIG_PREEMPT
78 #define preempt_stop            cli
79 #else
80 #define preempt_stop
81 #define resume_kernel           restore_all
82 #endif
83
84 #define SAVE_ALL \
85         cld; \
86         pushl %es; \
87         pushl %ds; \
88         pushl %eax; \
89         pushl %ebp; \
90         pushl %edi; \
91         pushl %esi; \
92         pushl %edx; \
93         pushl %ecx; \
94         pushl %ebx; \
95         movl $(__USER_DS), %edx; \
96         movl %edx, %ds; \
97         movl %edx, %es;
98
99 #define RESTORE_INT_REGS \
100         popl %ebx;      \
101         popl %ecx;      \
102         popl %edx;      \
103         popl %esi;      \
104         popl %edi;      \
105         popl %ebp;      \
106         popl %eax
107
108 #define RESTORE_REGS    \
109         RESTORE_INT_REGS; \
110 1:      popl %ds;       \
111 2:      popl %es;       \
112 .section .fixup,"ax";   \
113 3:      movl $0,(%esp); \
114         jmp 1b;         \
115 4:      movl $0,(%esp); \
116         jmp 2b;         \
117 .previous;              \
118 .section __ex_table,"a";\
119         .align 4;       \
120         .long 1b,3b;    \
121         .long 2b,4b;    \
122 .previous
123
124
125 #define RESTORE_ALL     \
126         RESTORE_REGS    \
127         addl $4, %esp;  \
128 1:      iret;           \
129 .section .fixup,"ax";   \
130 2:      sti;            \
131         movl $(__USER_DS), %edx; \
132         movl %edx, %ds; \
133         movl %edx, %es; \
134         pushl $11;      \
135         call do_exit;   \
136 .previous;              \
137 .section __ex_table,"a";\
138         .align 4;       \
139         .long 1b,2b;    \
140 .previous
141
142
143
144 ENTRY(lcall7)
145         pushfl                  # We get a different stack layout with call
146                                 # gates, which has to be cleaned up later..
147         pushl %eax
148         SAVE_ALL
149         movl %esp, %ebp
150         pushl %ebp
151         pushl $0x7
152 do_lcall:
153         movl EIP(%ebp), %eax    # due to call gates, this is eflags, not eip..
154         movl CS(%ebp), %edx     # this is eip..
155         movl EFLAGS(%ebp), %ecx # and this is cs..
156         movl %eax,EFLAGS(%ebp)  #
157         movl %edx,EIP(%ebp)     # Now we move them to their "normal" places
158         movl %ecx,CS(%ebp)      #
159         GET_THREAD_INFO_WITH_ESP(%ebp)  # GET_THREAD_INFO
160         movl TI_exec_domain(%ebp), %edx # Get the execution domain
161         call *EXEC_DOMAIN_handler(%edx) # Call the handler for the domain
162         addl $4, %esp
163         popl %eax
164         jmp resume_userspace
165
166 ENTRY(lcall27)
167         pushfl                  # We get a different stack layout with call
168                                 # gates, which has to be cleaned up later..
169         pushl %eax
170         SAVE_ALL
171         movl %esp, %ebp
172         pushl %ebp
173         pushl $0x27
174         jmp do_lcall
175
176
177 ENTRY(ret_from_fork)
178         pushl %eax
179         call schedule_tail
180         GET_THREAD_INFO(%ebp)
181         popl %eax
182         jmp syscall_exit
183
184 /*
185  * Return to user mode is not as complex as all this looks,
186  * but we want the default path for a system call return to
187  * go as quickly as possible which is why some of this is
188  * less clear than it otherwise should be.
189  */
190
191         # userspace resumption stub bypassing syscall exit tracing
192         ALIGN
193 ret_from_exception:
194         preempt_stop
195 ret_from_intr:
196         GET_THREAD_INFO(%ebp)
197         movl EFLAGS(%esp), %eax         # mix EFLAGS and CS
198         movb CS(%esp), %al
199         testl $(VM_MASK | 3), %eax
200         jz resume_kernel                # returning to kernel or vm86-space
201 ENTRY(resume_userspace)
202         cli                             # make sure we don't miss an interrupt
203                                         # setting need_resched or sigpending
204                                         # between sampling and the iret
205         movl TI_flags(%ebp), %ecx
206         andl $_TIF_WORK_MASK, %ecx      # is there any work to be done on
207                                         # int/exception return?
208         jne work_pending
209         jmp restore_all
210
211 #ifdef CONFIG_PREEMPT
212 ENTRY(resume_kernel)
213         cmpl $0,TI_preempt_count(%ebp)  # non-zero preempt_count ?
214         jnz restore_all
215 need_resched:
216         movl TI_flags(%ebp), %ecx       # need_resched set ?
217         testb $_TIF_NEED_RESCHED, %cl
218         jz restore_all
219         testl $IF_MASK,EFLAGS(%esp)     # interrupts off (exception path) ?
220         jz restore_all
221         movl $PREEMPT_ACTIVE,TI_preempt_count(%ebp)
222         sti
223         call schedule
224         movl $0,TI_preempt_count(%ebp)
225         cli
226         jmp need_resched
227 #endif
228
229 /* SYSENTER_RETURN points to after the "sysenter" instruction in
230    the vsyscall page.  See vsyscall-sysentry.S, which defines the symbol.  */
231
232         # sysenter call handler stub
233 ENTRY(sysenter_entry)
234         movl TSS_sysenter_esp0(%esp),%esp
235 sysenter_past_esp:
236         sti
237         pushl $(__USER_DS)
238         pushl %ebp
239         pushfl
240         pushl $(__USER_CS)
241         /*
242          * Push current_thread_info()->sysenter_return to the stack.
243          * A tiny bit of offset fixup is necessary - 4*4 means the 4 words
244          * pushed above, and the word being pushed now:
245          */
246         pushl (TI_sysenter_return-THREAD_SIZE+4*4)(%esp)
247 /*
248  * Load the potential sixth argument from user stack.
249  * Careful about security.
250  */
251         cmpl $__PAGE_OFFSET-3,%ebp
252         jae syscall_fault
253 1:      movl (%ebp),%ebp
254 .section __ex_table,"a"
255         .align 4
256         .long 1b,syscall_fault
257 .previous
258
259         pushl %eax
260         SAVE_ALL
261         GET_THREAD_INFO(%ebp)
262
263         testb $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT),TI_flags(%ebp)
264         jnz syscall_trace_entry
265         cmpl $(nr_syscalls), %eax
266         jae syscall_badsys
267         call *sys_call_table(,%eax,4)
268         movl %eax,EAX(%esp)
269         cli
270         movl TI_flags(%ebp), %ecx
271         testw $_TIF_ALLWORK_MASK, %cx
272         jne syscall_exit_work
273 /* if something modifies registers it must also disable sysexit */
274         movl EIP(%esp), %edx
275         movl OLDESP(%esp), %ecx
276         xorl %ebp,%ebp
277         sti
278         sysexit
279
280
281         # system call handler stub
282 ENTRY(system_call)
283         pushl %eax                      # save orig_eax
284         SAVE_ALL
285         GET_THREAD_INFO(%ebp)
286                                         # system call tracing in operation
287         testb $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT),TI_flags(%ebp)
288         jnz syscall_trace_entry
289         cmpl $(nr_syscalls), %eax
290         jae syscall_badsys
291 syscall_call:
292         call *sys_call_table(,%eax,4)
293         movl %eax,EAX(%esp)             # store the return value
294 syscall_exit:
295         cli                             # make sure we don't miss an interrupt
296                                         # setting need_resched or sigpending
297                                         # between sampling and the iret
298         movl TI_flags(%ebp), %ecx
299         testw $_TIF_ALLWORK_MASK, %cx   # current->work
300         jne syscall_exit_work
301 restore_all:
302         RESTORE_ALL
303
304         # perform work that needs to be done immediately before resumption
305         ALIGN
306 work_pending:
307         testb $_TIF_NEED_RESCHED, %cl
308         jz work_notifysig
309 work_resched:
310         call schedule
311         cli                             # make sure we don't miss an interrupt
312                                         # setting need_resched or sigpending
313                                         # between sampling and the iret
314         movl TI_flags(%ebp), %ecx
315         andl $_TIF_WORK_MASK, %ecx      # is there any work to be done other
316                                         # than syscall tracing?
317         jz restore_all
318         testb $_TIF_NEED_RESCHED, %cl
319         jnz work_resched
320
321 work_notifysig:                         # deal with pending signals and
322                                         # notify-resume requests
323         testl $VM_MASK, EFLAGS(%esp)
324         movl %esp, %eax
325         jne work_notifysig_v86          # returning to kernel-space or
326                                         # vm86-space
327         xorl %edx, %edx
328         call do_notify_resume
329         jmp restore_all
330
331         ALIGN
332 work_notifysig_v86:
333         pushl %ecx
334         call save_v86_state
335         popl %ecx
336         movl %eax, %esp
337         xorl %edx, %edx
338         call do_notify_resume
339         jmp restore_all
340
341         # perform syscall exit tracing
342         ALIGN
343 syscall_trace_entry:
344         movl $-ENOSYS,EAX(%esp)
345         movl %esp, %eax
346         xorl %edx,%edx
347         call do_syscall_trace
348         movl ORIG_EAX(%esp), %eax
349         cmpl $(nr_syscalls), %eax
350         jnae syscall_call
351         jmp syscall_exit
352
353         # perform syscall exit tracing
354         ALIGN
355 syscall_exit_work:
356         testb $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SINGLESTEP), %cl
357         jz work_pending
358         sti                             # could let do_syscall_trace() call
359                                         # schedule() instead
360         movl %esp, %eax
361         movl $1, %edx
362         call do_syscall_trace
363         jmp resume_userspace
364
365         ALIGN
366 syscall_fault:
367         pushl %eax                      # save orig_eax
368         SAVE_ALL
369         GET_THREAD_INFO(%ebp)
370         movl $-EFAULT,EAX(%esp)
371         jmp resume_userspace
372
373         ALIGN
374 syscall_badsys:
375         movl $-ENOSYS,EAX(%esp)
376         jmp resume_userspace
377
378 /*
379  * Build the entry stubs and pointer table with
380  * some assembler magic.
381  */
382 .data
383 ENTRY(interrupt)
384 .text
385
386 vector=0
387 ENTRY(irq_entries_start)
388 .rept NR_IRQS
389         ALIGN
390 1:      pushl $vector-256
391         jmp common_interrupt
392 .data
393         .long 1b
394 .text
395 vector=vector+1
396 .endr
397
398         ALIGN
399 common_interrupt:
400         SAVE_ALL
401         call do_IRQ
402         jmp ret_from_intr
403
404 #define BUILD_INTERRUPT(name, nr)       \
405 ENTRY(name)                             \
406         pushl $nr-256;                  \
407         SAVE_ALL                        \
408         call smp_/**/name;      \
409         jmp ret_from_intr;
410
411 /* The include is where all of the SMP etc. interrupts come from */
412 #include "entry_arch.h"
413
414 ENTRY(divide_error)
415         pushl $0                        # no error code
416         pushl $do_divide_error
417         ALIGN
418 error_code:
419         pushl %ds
420         pushl %eax
421         xorl %eax, %eax
422         pushl %ebp
423         pushl %edi
424         pushl %esi
425         pushl %edx
426         decl %eax                       # eax = -1
427         pushl %ecx
428         pushl %ebx
429         cld
430         movl %es, %ecx
431         movl ORIG_EAX(%esp), %esi       # get the error code
432         movl ES(%esp), %edi             # get the function address
433         movl %eax, ORIG_EAX(%esp)
434         movl %ecx, ES(%esp)
435         movl %esp, %edx
436         pushl %esi                      # push the error code
437         pushl %edx                      # push the pt_regs pointer
438         movl $(__USER_DS), %edx
439         movl %edx, %ds
440         movl %edx, %es
441         call *%edi
442         addl $8, %esp
443         jmp ret_from_exception
444
445 ENTRY(coprocessor_error)
446         pushl $0
447         pushl $do_coprocessor_error
448         jmp error_code
449
450 ENTRY(simd_coprocessor_error)
451         pushl $0
452         pushl $do_simd_coprocessor_error
453         jmp error_code
454
455 ENTRY(device_not_available)
456         pushl $-1                       # mark this as an int
457         SAVE_ALL
458         movl %cr0, %eax
459         testl $0x4, %eax                # EM (math emulation bit)
460         jne device_not_available_emulate
461         preempt_stop
462         call math_state_restore
463         jmp ret_from_exception
464 device_not_available_emulate:
465         pushl $0                        # temporary storage for ORIG_EIP
466         call math_emulate
467         addl $4, %esp
468         jmp ret_from_exception
469
470 /*
471  * Debug traps and NMI can happen at the one SYSENTER instruction
472  * that sets up the real kernel stack. Check here, since we can't
473  * allow the wrong stack to be used.
474  *
475  * "TSS_sysenter_esp0+12" is because the NMI/debug handler will have
476  * already pushed 3 words if it hits on the sysenter instruction:
477  * eflags, cs and eip.
478  *
479  * We just load the right stack, and push the three (known) values
480  * by hand onto the new stack - while updating the return eip past
481  * the instruction that would have done it for sysenter.
482  */
483 #define FIX_STACK(offset, ok, label)            \
484         cmpw $__KERNEL_CS,4(%esp);              \
485         jne ok;                                 \
486 label:                                          \
487         movl TSS_sysenter_esp0+offset(%esp),%esp;       \
488         pushfl;                                 \
489         pushl $__KERNEL_CS;                     \
490         pushl $sysenter_past_esp
491
492 ENTRY(debug)
493         cmpl $sysenter_entry,(%esp)
494         jne debug_stack_correct
495         FIX_STACK(12, debug_stack_correct, debug_esp_fix_insn)
496 debug_stack_correct:
497         pushl $-1                       # mark this as an int
498         SAVE_ALL
499         movl %esp,%edx
500         pushl $0
501         pushl %edx
502         call do_debug
503         addl $8,%esp
504         testl %eax,%eax
505         jnz restore_all
506         jmp ret_from_exception
507
508 /*
509  * NMI is doubly nasty. It can happen _while_ we're handling
510  * a debug fault, and the debug fault hasn't yet been able to
511  * clear up the stack. So we first check whether we got  an
512  * NMI on the sysenter entry path, but after that we need to
513  * check whether we got an NMI on the debug path where the debug
514  * fault happened on the sysenter path.
515  */
516 ENTRY(nmi)
517         cmpl $sysenter_entry,(%esp)
518         je nmi_stack_fixup
519         pushl %eax
520         movl %esp,%eax
521         /* Do not access memory above the end of our stack page,
522          * it might not exist.
523          */
524         andl $(THREAD_SIZE-1),%eax
525         cmpl $(THREAD_SIZE-20),%eax
526         popl %eax
527         jae nmi_stack_correct
528         cmpl $sysenter_entry,12(%esp)
529         je nmi_debug_stack_check
530 nmi_stack_correct:
531         pushl %eax
532         SAVE_ALL
533         movl %esp, %edx
534         pushl $0
535         pushl %edx
536         call do_nmi
537         addl $8, %esp
538         RESTORE_ALL
539
540 nmi_stack_fixup:
541         FIX_STACK(12,nmi_stack_correct, 1)
542         jmp nmi_stack_correct
543 nmi_debug_stack_check:
544         cmpw $__KERNEL_CS,16(%esp)
545         jne nmi_stack_correct
546         cmpl $debug - 1,(%esp)
547         jle nmi_stack_correct
548         cmpl $debug_esp_fix_insn,(%esp)
549         jle nmi_debug_stack_fixup
550 nmi_debug_stack_fixup:
551         FIX_STACK(24,nmi_stack_correct, 1)
552         jmp nmi_stack_correct
553
554 ENTRY(int3)
555         pushl $-1                       # mark this as an int
556         SAVE_ALL
557         movl %esp,%edx
558         pushl $0
559         pushl %edx
560         call do_int3
561         addl $8,%esp
562         testl %eax,%eax
563         jnz restore_all
564         jmp ret_from_exception
565
566 ENTRY(overflow)
567         pushl $0
568         pushl $do_overflow
569         jmp error_code
570
571 ENTRY(bounds)
572         pushl $0
573         pushl $do_bounds
574         jmp error_code
575
576 ENTRY(invalid_op)
577         pushl $0
578         pushl $do_invalid_op
579         jmp error_code
580
581 ENTRY(coprocessor_segment_overrun)
582         pushl $0
583         pushl $do_coprocessor_segment_overrun
584         jmp error_code
585
586 ENTRY(invalid_TSS)
587         pushl $do_invalid_TSS
588         jmp error_code
589
590 ENTRY(segment_not_present)
591         pushl $do_segment_not_present
592         jmp error_code
593
594 ENTRY(stack_segment)
595         pushl $do_stack_segment
596         jmp error_code
597
598 ENTRY(general_protection)
599         pushl $do_general_protection
600         jmp error_code
601
602 ENTRY(alignment_check)
603         pushl $do_alignment_check
604         jmp error_code
605
606 ENTRY(page_fault)
607         pushl $do_page_fault
608         jmp error_code
609
610 #ifdef CONFIG_X86_MCE
611 ENTRY(machine_check)
612         pushl $0
613         pushl machine_check_vector
614         jmp error_code
615 #endif
616
617 ENTRY(spurious_interrupt_bug)
618         pushl $0
619         pushl $do_spurious_interrupt_bug
620         jmp error_code
621
622 .data
623 ENTRY(sys_call_table)
624         .long sys_restart_syscall       /* 0 - old "setup()" system call, used for restarting */
625         .long sys_exit
626         .long sys_fork
627         .long sys_read
628         .long sys_write
629         .long sys_open          /* 5 */
630         .long sys_close
631         .long sys_waitpid
632         .long sys_creat
633         .long sys_link
634         .long sys_unlink        /* 10 */
635         .long sys_execve
636         .long sys_chdir
637         .long sys_time
638         .long sys_mknod
639         .long sys_chmod         /* 15 */
640         .long sys_lchown16
641         .long sys_ni_syscall    /* old break syscall holder */
642         .long sys_stat
643         .long sys_lseek
644         .long sys_getpid        /* 20 */
645         .long sys_mount
646         .long sys_oldumount
647         .long sys_setuid16
648         .long sys_getuid16
649         .long sys_stime         /* 25 */
650         .long sys_ptrace
651         .long sys_alarm
652         .long sys_fstat
653         .long sys_pause
654         .long sys_utime         /* 30 */
655         .long sys_ni_syscall    /* old stty syscall holder */
656         .long sys_ni_syscall    /* old gtty syscall holder */
657         .long sys_access
658         .long sys_nice
659         .long sys_ni_syscall    /* 35 - old ftime syscall holder */
660         .long sys_sync
661         .long sys_kill
662         .long sys_rename
663         .long sys_mkdir
664         .long sys_rmdir         /* 40 */
665         .long sys_dup
666         .long sys_pipe
667         .long sys_times
668         .long sys_ni_syscall    /* old prof syscall holder */
669         .long sys_brk           /* 45 */
670         .long sys_setgid16
671         .long sys_getgid16
672         .long sys_signal
673         .long sys_geteuid16
674         .long sys_getegid16     /* 50 */
675         .long sys_acct
676         .long sys_umount        /* recycled never used phys() */
677         .long sys_ni_syscall    /* old lock syscall holder */
678         .long sys_ioctl
679         .long sys_fcntl         /* 55 */
680         .long sys_ni_syscall    /* old mpx syscall holder */
681         .long sys_setpgid
682         .long sys_ni_syscall    /* old ulimit syscall holder */
683         .long sys_olduname
684         .long sys_umask         /* 60 */
685         .long sys_chroot
686         .long sys_ustat
687         .long sys_dup2
688         .long sys_getppid
689         .long sys_getpgrp       /* 65 */
690         .long sys_setsid
691         .long sys_sigaction
692         .long sys_sgetmask
693         .long sys_ssetmask
694         .long sys_setreuid16    /* 70 */
695         .long sys_setregid16
696         .long sys_sigsuspend
697         .long sys_sigpending
698         .long sys_sethostname
699         .long sys_setrlimit     /* 75 */
700         .long sys_old_getrlimit
701         .long sys_getrusage
702         .long sys_gettimeofday
703         .long sys_settimeofday
704         .long sys_getgroups16   /* 80 */
705         .long sys_setgroups16
706         .long old_select
707         .long sys_symlink
708         .long sys_lstat
709         .long sys_readlink      /* 85 */
710         .long sys_uselib
711         .long sys_swapon
712         .long sys_reboot
713         .long old_readdir
714         .long old_mmap          /* 90 */
715         .long sys_munmap
716         .long sys_truncate
717         .long sys_ftruncate
718         .long sys_fchmod
719         .long sys_fchown16      /* 95 */
720         .long sys_getpriority
721         .long sys_setpriority
722         .long sys_ni_syscall    /* old profil syscall holder */
723         .long sys_statfs
724         .long sys_fstatfs       /* 100 */
725         .long sys_ioperm
726         .long sys_socketcall
727         .long sys_syslog
728         .long sys_setitimer
729         .long sys_getitimer     /* 105 */
730         .long sys_newstat
731         .long sys_newlstat
732         .long sys_newfstat
733         .long sys_uname
734         .long sys_iopl          /* 110 */
735         .long sys_vhangup
736         .long sys_ni_syscall    /* old "idle" system call */
737         .long sys_vm86old
738         .long sys_wait4
739         .long sys_swapoff       /* 115 */
740         .long sys_sysinfo
741         .long sys_ipc
742         .long sys_fsync
743         .long sys_sigreturn
744         .long sys_clone         /* 120 */
745         .long sys_setdomainname
746         .long sys_newuname
747         .long sys_modify_ldt
748         .long sys_adjtimex
749         .long sys_mprotect      /* 125 */
750         .long sys_sigprocmask
751         .long sys_ni_syscall    /* old "create_module" */ 
752         .long sys_init_module
753         .long sys_delete_module
754         .long sys_ni_syscall    /* 130: old "get_kernel_syms" */
755         .long sys_quotactl
756         .long sys_getpgid
757         .long sys_fchdir
758         .long sys_bdflush
759         .long sys_sysfs         /* 135 */
760         .long sys_personality
761         .long sys_ni_syscall    /* reserved for afs_syscall */
762         .long sys_setfsuid16
763         .long sys_setfsgid16
764         .long sys_llseek        /* 140 */
765         .long sys_getdents
766         .long sys_select
767         .long sys_flock
768         .long sys_msync
769         .long sys_readv         /* 145 */
770         .long sys_writev
771         .long sys_getsid
772         .long sys_fdatasync
773         .long sys_sysctl
774         .long sys_mlock         /* 150 */
775         .long sys_munlock
776         .long sys_mlockall
777         .long sys_munlockall
778         .long sys_sched_setparam
779         .long sys_sched_getparam   /* 155 */
780         .long sys_sched_setscheduler
781         .long sys_sched_getscheduler
782         .long sys_sched_yield
783         .long sys_sched_get_priority_max
784         .long sys_sched_get_priority_min  /* 160 */
785         .long sys_sched_rr_get_interval
786         .long sys_nanosleep
787         .long sys_mremap
788         .long sys_setresuid16
789         .long sys_getresuid16   /* 165 */
790         .long sys_vm86
791         .long sys_ni_syscall    /* Old sys_query_module */
792         .long sys_poll
793         .long sys_nfsservctl
794         .long sys_setresgid16   /* 170 */
795         .long sys_getresgid16
796         .long sys_prctl
797         .long sys_rt_sigreturn
798         .long sys_rt_sigaction
799         .long sys_rt_sigprocmask        /* 175 */
800         .long sys_rt_sigpending
801         .long sys_rt_sigtimedwait
802         .long sys_rt_sigqueueinfo
803         .long sys_rt_sigsuspend
804         .long sys_pread64       /* 180 */
805         .long sys_pwrite64
806         .long sys_chown16
807         .long sys_getcwd
808         .long sys_capget
809         .long sys_capset        /* 185 */
810         .long sys_sigaltstack
811         .long sys_sendfile
812         .long sys_ni_syscall    /* reserved for streams1 */
813         .long sys_ni_syscall    /* reserved for streams2 */
814         .long sys_vfork         /* 190 */
815         .long sys_getrlimit
816         .long sys_mmap2
817         .long sys_truncate64
818         .long sys_ftruncate64
819         .long sys_stat64        /* 195 */
820         .long sys_lstat64
821         .long sys_fstat64
822         .long sys_lchown
823         .long sys_getuid
824         .long sys_getgid        /* 200 */
825         .long sys_geteuid
826         .long sys_getegid
827         .long sys_setreuid
828         .long sys_setregid
829         .long sys_getgroups     /* 205 */
830         .long sys_setgroups
831         .long sys_fchown
832         .long sys_setresuid
833         .long sys_getresuid
834         .long sys_setresgid     /* 210 */
835         .long sys_getresgid
836         .long sys_chown
837         .long sys_setuid
838         .long sys_setgid
839         .long sys_setfsuid      /* 215 */
840         .long sys_setfsgid
841         .long sys_pivot_root
842         .long sys_mincore
843         .long sys_madvise
844         .long sys_getdents64    /* 220 */
845         .long sys_fcntl64
846 #ifdef CONFIG_TUX
847         .long __sys_tux
848 #else
849 # ifdef CONFIG_TUX_MODULE
850         .long sys_tux
851 # else
852         .long sys_ni_syscall
853 # endif
854 #endif
855         .long sys_ni_syscall
856         .long sys_gettid
857         .long sys_readahead     /* 225 */
858         .long sys_setxattr
859         .long sys_lsetxattr
860         .long sys_fsetxattr
861         .long sys_getxattr
862         .long sys_lgetxattr     /* 230 */
863         .long sys_fgetxattr
864         .long sys_listxattr
865         .long sys_llistxattr
866         .long sys_flistxattr
867         .long sys_removexattr   /* 235 */
868         .long sys_lremovexattr
869         .long sys_fremovexattr
870         .long sys_tkill
871         .long sys_sendfile64
872         .long sys_futex         /* 240 */
873         .long sys_sched_setaffinity
874         .long sys_sched_getaffinity
875         .long sys_set_thread_area
876         .long sys_get_thread_area
877         .long sys_io_setup      /* 245 */
878         .long sys_io_destroy
879         .long sys_io_getevents
880         .long sys_io_submit
881         .long sys_io_cancel
882         .long sys_fadvise64     /* 250 */
883         .long sys_ni_syscall
884         .long sys_exit_group
885         .long sys_lookup_dcookie
886         .long sys_epoll_create
887         .long sys_epoll_ctl     /* 255 */
888         .long sys_epoll_wait
889         .long sys_remap_file_pages
890         .long sys_set_tid_address
891         .long sys_timer_create
892         .long sys_timer_settime         /* 260 */
893         .long sys_timer_gettime
894         .long sys_timer_getoverrun
895         .long sys_timer_delete
896         .long sys_clock_settime
897         .long sys_clock_gettime         /* 265 */
898         .long sys_clock_getres
899         .long sys_clock_nanosleep
900         .long sys_statfs64
901         .long sys_fstatfs64     
902         .long sys_tgkill        /* 270 */
903         .long sys_utimes
904         .long sys_fadvise64_64
905         .long sys_vserver
906         .long sys_mbind
907         .long sys_get_mempolicy
908         .long sys_set_mempolicy
909         .long sys_mq_open
910         .long sys_mq_unlink
911         .long sys_mq_timedsend
912         .long sys_mq_timedreceive       /* 280 */
913         .long sys_mq_notify
914         .long sys_mq_getsetattr
915         .long sys_kexec_load
916         .long sys_waitid
917 #ifdef USE_IOPRIO_SYSCALLS
918         .long sys_ioprio_set            /* 285 */
919         .long sys_ioprio_get
920 #else
921 #warning MEF not includig sys_ioprio_{set,get} syscalls
922 #endif  
923
924 syscall_table_size=(.-sys_call_table)
925
926 #ifdef CONFIG_X86_STACK_CHECK
927 .data
928 .globl stack_overflowed
929 stack_overflowed:
930         .long 0
931 .text
932
933 ENTRY(mcount)
934 #warning stack check enabled
935         push %eax
936         movl $(THREAD_SIZE - 1),%eax
937         andl %esp,%eax
938         cmpl $STACK_WARN,%eax
939         jle 1f
940 2:
941         popl %eax
942         ret
943 1:
944         /* prevent infinite recursion from call to mcount from the
945          * stack_overflow function.  Need to revisit this code for
946          * SMP based systems.
947          */
948         lock; btsl $0,stack_overflowed
949         jc 2b
950
951         /* prepare to jmp to stack_overflow directly, as if it were 
952          * called directly by the caller of mcount.  
953          */
954         pushl %ebp
955         pushl %ebx
956         pushl %esi
957         pushl %edi
958         
959         call stack_overflow
960         /* Note that stack_overflow() will clear the stack_overflowed
961          * variable.
962          */
963
964         popl %edi
965         popl %esi
966         popl %ebx
967         popl %ebp
968         
969         popl %eax       
970         ret
971 #endif