blob: fbdb933251b643b8e726feefe8e350205dbd7396 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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 <asm/desc.h>
Jan Beulichfe7cacc2006-06-26 13:57:44 +020051#include <asm/dwarf2.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070052#include "irq_vectors.h"
53
54#define nr_syscalls ((syscall_table_size)/4)
55
56EBX = 0x00
57ECX = 0x04
58EDX = 0x08
59ESI = 0x0C
60EDI = 0x10
61EBP = 0x14
62EAX = 0x18
63DS = 0x1C
64ES = 0x20
65ORIG_EAX = 0x24
66EIP = 0x28
67CS = 0x2C
68EFLAGS = 0x30
69OLDESP = 0x34
70OLDSS = 0x38
71
72CF_MASK = 0x00000001
73TF_MASK = 0x00000100
74IF_MASK = 0x00000200
75DF_MASK = 0x00000400
76NT_MASK = 0x00004000
77VM_MASK = 0x00020000
78
79#ifdef CONFIG_PREEMPT
80#define preempt_stop cli
81#else
82#define preempt_stop
83#define resume_kernel restore_nocheck
84#endif
85
Aleksey Gorelov4031ff32006-06-27 02:53:48 -070086#ifdef CONFIG_VM86
87#define resume_userspace_sig check_userspace
88#else
89#define resume_userspace_sig resume_userspace
90#endif
91
Linus Torvalds1da177e2005-04-16 15:20:36 -070092#define SAVE_ALL \
93 cld; \
94 pushl %es; \
Jan Beulichfe7cacc2006-06-26 13:57:44 +020095 CFI_ADJUST_CFA_OFFSET 4;\
96 /*CFI_REL_OFFSET es, 0;*/\
Linus Torvalds1da177e2005-04-16 15:20:36 -070097 pushl %ds; \
Jan Beulichfe7cacc2006-06-26 13:57:44 +020098 CFI_ADJUST_CFA_OFFSET 4;\
99 /*CFI_REL_OFFSET ds, 0;*/\
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100 pushl %eax; \
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200101 CFI_ADJUST_CFA_OFFSET 4;\
102 CFI_REL_OFFSET eax, 0;\
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103 pushl %ebp; \
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200104 CFI_ADJUST_CFA_OFFSET 4;\
105 CFI_REL_OFFSET ebp, 0;\
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106 pushl %edi; \
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200107 CFI_ADJUST_CFA_OFFSET 4;\
108 CFI_REL_OFFSET edi, 0;\
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109 pushl %esi; \
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200110 CFI_ADJUST_CFA_OFFSET 4;\
111 CFI_REL_OFFSET esi, 0;\
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112 pushl %edx; \
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200113 CFI_ADJUST_CFA_OFFSET 4;\
114 CFI_REL_OFFSET edx, 0;\
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115 pushl %ecx; \
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200116 CFI_ADJUST_CFA_OFFSET 4;\
117 CFI_REL_OFFSET ecx, 0;\
Linus Torvalds1da177e2005-04-16 15:20:36 -0700118 pushl %ebx; \
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200119 CFI_ADJUST_CFA_OFFSET 4;\
120 CFI_REL_OFFSET ebx, 0;\
Linus Torvalds1da177e2005-04-16 15:20:36 -0700121 movl $(__USER_DS), %edx; \
122 movl %edx, %ds; \
123 movl %edx, %es;
124
125#define RESTORE_INT_REGS \
126 popl %ebx; \
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200127 CFI_ADJUST_CFA_OFFSET -4;\
128 CFI_RESTORE ebx;\
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129 popl %ecx; \
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200130 CFI_ADJUST_CFA_OFFSET -4;\
131 CFI_RESTORE ecx;\
Linus Torvalds1da177e2005-04-16 15:20:36 -0700132 popl %edx; \
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200133 CFI_ADJUST_CFA_OFFSET -4;\
134 CFI_RESTORE edx;\
Linus Torvalds1da177e2005-04-16 15:20:36 -0700135 popl %esi; \
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200136 CFI_ADJUST_CFA_OFFSET -4;\
137 CFI_RESTORE esi;\
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138 popl %edi; \
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200139 CFI_ADJUST_CFA_OFFSET -4;\
140 CFI_RESTORE edi;\
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141 popl %ebp; \
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200142 CFI_ADJUST_CFA_OFFSET -4;\
143 CFI_RESTORE ebp;\
144 popl %eax; \
145 CFI_ADJUST_CFA_OFFSET -4;\
146 CFI_RESTORE eax
Linus Torvalds1da177e2005-04-16 15:20:36 -0700147
148#define RESTORE_REGS \
149 RESTORE_INT_REGS; \
1501: popl %ds; \
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200151 CFI_ADJUST_CFA_OFFSET -4;\
152 /*CFI_RESTORE ds;*/\
Linus Torvalds1da177e2005-04-16 15:20:36 -07001532: popl %es; \
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200154 CFI_ADJUST_CFA_OFFSET -4;\
155 /*CFI_RESTORE es;*/\
Linus Torvalds1da177e2005-04-16 15:20:36 -0700156.section .fixup,"ax"; \
1573: movl $0,(%esp); \
158 jmp 1b; \
1594: movl $0,(%esp); \
160 jmp 2b; \
161.previous; \
162.section __ex_table,"a";\
163 .align 4; \
164 .long 1b,3b; \
165 .long 2b,4b; \
166.previous
167
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200168#define RING0_INT_FRAME \
169 CFI_STARTPROC simple;\
170 CFI_DEF_CFA esp, 3*4;\
171 /*CFI_OFFSET cs, -2*4;*/\
172 CFI_OFFSET eip, -3*4
173
174#define RING0_EC_FRAME \
175 CFI_STARTPROC simple;\
176 CFI_DEF_CFA esp, 4*4;\
177 /*CFI_OFFSET cs, -2*4;*/\
178 CFI_OFFSET eip, -3*4
179
180#define RING0_PTREGS_FRAME \
181 CFI_STARTPROC simple;\
182 CFI_DEF_CFA esp, OLDESP-EBX;\
183 /*CFI_OFFSET cs, CS-OLDESP;*/\
184 CFI_OFFSET eip, EIP-OLDESP;\
185 /*CFI_OFFSET es, ES-OLDESP;*/\
186 /*CFI_OFFSET ds, DS-OLDESP;*/\
187 CFI_OFFSET eax, EAX-OLDESP;\
188 CFI_OFFSET ebp, EBP-OLDESP;\
189 CFI_OFFSET edi, EDI-OLDESP;\
190 CFI_OFFSET esi, ESI-OLDESP;\
191 CFI_OFFSET edx, EDX-OLDESP;\
192 CFI_OFFSET ecx, ECX-OLDESP;\
193 CFI_OFFSET ebx, EBX-OLDESP
Linus Torvalds1da177e2005-04-16 15:20:36 -0700194
195ENTRY(ret_from_fork)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200196 CFI_STARTPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700197 pushl %eax
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200198 CFI_ADJUST_CFA_OFFSET -4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700199 call schedule_tail
200 GET_THREAD_INFO(%ebp)
201 popl %eax
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200202 CFI_ADJUST_CFA_OFFSET -4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700203 jmp syscall_exit
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200204 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700205
206/*
207 * Return to user mode is not as complex as all this looks,
208 * but we want the default path for a system call return to
209 * go as quickly as possible which is why some of this is
210 * less clear than it otherwise should be.
211 */
212
213 # userspace resumption stub bypassing syscall exit tracing
214 ALIGN
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200215 RING0_PTREGS_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700216ret_from_exception:
217 preempt_stop
218ret_from_intr:
219 GET_THREAD_INFO(%ebp)
Aleksey Gorelov4031ff32006-06-27 02:53:48 -0700220check_userspace:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700221 movl EFLAGS(%esp), %eax # mix EFLAGS and CS
222 movb CS(%esp), %al
223 testl $(VM_MASK | 3), %eax
224 jz resume_kernel
225ENTRY(resume_userspace)
226 cli # make sure we don't miss an interrupt
227 # setting need_resched or sigpending
228 # between sampling and the iret
229 movl TI_flags(%ebp), %ecx
230 andl $_TIF_WORK_MASK, %ecx # is there any work to be done on
231 # int/exception return?
232 jne work_pending
233 jmp restore_all
234
235#ifdef CONFIG_PREEMPT
236ENTRY(resume_kernel)
237 cli
238 cmpl $0,TI_preempt_count(%ebp) # non-zero preempt_count ?
239 jnz restore_nocheck
240need_resched:
241 movl TI_flags(%ebp), %ecx # need_resched set ?
242 testb $_TIF_NEED_RESCHED, %cl
243 jz restore_all
244 testl $IF_MASK,EFLAGS(%esp) # interrupts off (exception path) ?
245 jz restore_all
246 call preempt_schedule_irq
247 jmp need_resched
248#endif
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200249 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700250
251/* SYSENTER_RETURN points to after the "sysenter" instruction in
252 the vsyscall page. See vsyscall-sysentry.S, which defines the symbol. */
253
254 # sysenter call handler stub
255ENTRY(sysenter_entry)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200256 CFI_STARTPROC simple
257 CFI_DEF_CFA esp, 0
258 CFI_REGISTER esp, ebp
Linus Torvalds1da177e2005-04-16 15:20:36 -0700259 movl TSS_sysenter_esp0(%esp),%esp
260sysenter_past_esp:
261 sti
262 pushl $(__USER_DS)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200263 CFI_ADJUST_CFA_OFFSET 4
264 /*CFI_REL_OFFSET ss, 0*/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700265 pushl %ebp
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200266 CFI_ADJUST_CFA_OFFSET 4
267 CFI_REL_OFFSET esp, 0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700268 pushfl
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200269 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700270 pushl $(__USER_CS)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200271 CFI_ADJUST_CFA_OFFSET 4
272 /*CFI_REL_OFFSET cs, 0*/
Ingo Molnare6e54942006-06-27 02:53:50 -0700273 /*
274 * Push current_thread_info()->sysenter_return to the stack.
275 * A tiny bit of offset fixup is necessary - 4*4 means the 4 words
276 * pushed above; +8 corresponds to copy_thread's esp0 setting.
277 */
278 pushl (TI_sysenter_return-THREAD_SIZE+8+4*4)(%esp)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200279 CFI_ADJUST_CFA_OFFSET 4
280 CFI_REL_OFFSET eip, 0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700281
282/*
283 * Load the potential sixth argument from user stack.
284 * Careful about security.
285 */
286 cmpl $__PAGE_OFFSET-3,%ebp
287 jae syscall_fault
2881: movl (%ebp),%ebp
289.section __ex_table,"a"
290 .align 4
291 .long 1b,syscall_fault
292.previous
293
294 pushl %eax
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200295 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700296 SAVE_ALL
297 GET_THREAD_INFO(%ebp)
298
299 /* Note, _TIF_SECCOMP is bit number 8, and so it needs testw and not testb */
Laurent Viviered75e8d2005-09-03 15:57:18 -0700300 testw $(_TIF_SYSCALL_EMU|_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT),TI_flags(%ebp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700301 jnz syscall_trace_entry
302 cmpl $(nr_syscalls), %eax
303 jae syscall_badsys
304 call *sys_call_table(,%eax,4)
305 movl %eax,EAX(%esp)
306 cli
307 movl TI_flags(%ebp), %ecx
308 testw $_TIF_ALLWORK_MASK, %cx
309 jne syscall_exit_work
310/* if something modifies registers it must also disable sysexit */
311 movl EIP(%esp), %edx
312 movl OLDESP(%esp), %ecx
313 xorl %ebp,%ebp
314 sti
315 sysexit
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200316 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700317
318
319 # system call handler stub
320ENTRY(system_call)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200321 RING0_INT_FRAME # can't unwind into user space anyway
Linus Torvalds1da177e2005-04-16 15:20:36 -0700322 pushl %eax # save orig_eax
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200323 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700324 SAVE_ALL
325 GET_THREAD_INFO(%ebp)
Chuck Ebbert635cf992006-03-23 02:59:48 -0800326 testl $TF_MASK,EFLAGS(%esp)
327 jz no_singlestep
328 orl $_TIF_SINGLESTEP,TI_flags(%ebp)
329no_singlestep:
Laurent Viviered75e8d2005-09-03 15:57:18 -0700330 # system call tracing in operation / emulation
Linus Torvalds1da177e2005-04-16 15:20:36 -0700331 /* Note, _TIF_SECCOMP is bit number 8, and so it needs testw and not testb */
Laurent Viviered75e8d2005-09-03 15:57:18 -0700332 testw $(_TIF_SYSCALL_EMU|_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT),TI_flags(%ebp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700333 jnz syscall_trace_entry
334 cmpl $(nr_syscalls), %eax
335 jae syscall_badsys
336syscall_call:
337 call *sys_call_table(,%eax,4)
338 movl %eax,EAX(%esp) # store the return value
339syscall_exit:
340 cli # make sure we don't miss an interrupt
341 # setting need_resched or sigpending
342 # between sampling and the iret
343 movl TI_flags(%ebp), %ecx
344 testw $_TIF_ALLWORK_MASK, %cx # current->work
345 jne syscall_exit_work
346
347restore_all:
348 movl EFLAGS(%esp), %eax # mix EFLAGS, SS and CS
Stas Sergeev5df24082005-04-16 15:24:01 -0700349 # Warning: OLDSS(%esp) contains the wrong/random values if we
350 # are returning to the kernel.
351 # See comments in process.c:copy_thread() for details.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700352 movb OLDSS(%esp), %ah
353 movb CS(%esp), %al
354 andl $(VM_MASK | (4 << 8) | 3), %eax
355 cmpl $((4 << 8) | 3), %eax
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200356 CFI_REMEMBER_STATE
Linus Torvalds1da177e2005-04-16 15:20:36 -0700357 je ldt_ss # returning to user-space with LDT SS
358restore_nocheck:
359 RESTORE_REGS
360 addl $4, %esp
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200361 CFI_ADJUST_CFA_OFFSET -4
Linus Torvalds1da177e2005-04-16 15:20:36 -07003621: iret
363.section .fixup,"ax"
364iret_exc:
365 sti
Linus Torvaldsa879cbb2005-04-29 09:38:44 -0700366 pushl $0 # no error code
367 pushl $do_iret_error
368 jmp error_code
Linus Torvalds1da177e2005-04-16 15:20:36 -0700369.previous
370.section __ex_table,"a"
371 .align 4
372 .long 1b,iret_exc
373.previous
374
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200375 CFI_RESTORE_STATE
Linus Torvalds1da177e2005-04-16 15:20:36 -0700376ldt_ss:
377 larl OLDSS(%esp), %eax
378 jnz restore_nocheck
379 testl $0x00400000, %eax # returning to 32bit stack?
380 jnz restore_nocheck # allright, normal return
381 /* If returning to userspace with 16bit stack,
382 * try to fix the higher word of ESP, as the CPU
383 * won't restore it.
384 * This is an "official" bug of all the x86-compatible
385 * CPUs, which we can try to work around to make
386 * dosemu and wine happy. */
387 subl $8, %esp # reserve space for switch16 pointer
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200388 CFI_ADJUST_CFA_OFFSET 8
Linus Torvalds1da177e2005-04-16 15:20:36 -0700389 cli
390 movl %esp, %eax
391 /* Set up the 16bit stack frame with switch32 pointer on top,
392 * and a switch16 pointer on top of the current frame. */
393 call setup_x86_bogus_stack
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200394 CFI_ADJUST_CFA_OFFSET -8 # frame has moved
Linus Torvalds1da177e2005-04-16 15:20:36 -0700395 RESTORE_REGS
396 lss 20+4(%esp), %esp # switch to 16bit stack
3971: iret
398.section __ex_table,"a"
399 .align 4
400 .long 1b,iret_exc
401.previous
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200402 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700403
404 # perform work that needs to be done immediately before resumption
405 ALIGN
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200406 RING0_PTREGS_FRAME # can't unwind into user space anyway
Linus Torvalds1da177e2005-04-16 15:20:36 -0700407work_pending:
408 testb $_TIF_NEED_RESCHED, %cl
409 jz work_notifysig
410work_resched:
411 call schedule
412 cli # make sure we don't miss an interrupt
413 # setting need_resched or sigpending
414 # between sampling and the iret
415 movl TI_flags(%ebp), %ecx
416 andl $_TIF_WORK_MASK, %ecx # is there any work to be done other
417 # than syscall tracing?
418 jz restore_all
419 testb $_TIF_NEED_RESCHED, %cl
420 jnz work_resched
421
422work_notifysig: # deal with pending signals and
423 # notify-resume requests
424 testl $VM_MASK, EFLAGS(%esp)
425 movl %esp, %eax
426 jne work_notifysig_v86 # returning to kernel-space or
427 # vm86-space
428 xorl %edx, %edx
429 call do_notify_resume
Aleksey Gorelov4031ff32006-06-27 02:53:48 -0700430 jmp resume_userspace_sig
Linus Torvalds1da177e2005-04-16 15:20:36 -0700431
432 ALIGN
433work_notifysig_v86:
Matt Mackall64ca9002006-01-08 01:05:26 -0800434#ifdef CONFIG_VM86
Linus Torvalds1da177e2005-04-16 15:20:36 -0700435 pushl %ecx # save ti_flags for do_notify_resume
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200436 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700437 call save_v86_state # %eax contains pt_regs pointer
438 popl %ecx
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200439 CFI_ADJUST_CFA_OFFSET -4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700440 movl %eax, %esp
441 xorl %edx, %edx
442 call do_notify_resume
Aleksey Gorelov4031ff32006-06-27 02:53:48 -0700443 jmp resume_userspace_sig
Matt Mackall64ca9002006-01-08 01:05:26 -0800444#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700445
446 # perform syscall exit tracing
447 ALIGN
448syscall_trace_entry:
449 movl $-ENOSYS,EAX(%esp)
450 movl %esp, %eax
451 xorl %edx,%edx
452 call do_syscall_trace
Laurent Viviered75e8d2005-09-03 15:57:18 -0700453 cmpl $0, %eax
Paolo 'Blaisorblade' Giarrusso640aa462005-09-03 15:57:22 -0700454 jne resume_userspace # ret != 0 -> running under PTRACE_SYSEMU,
Laurent Viviered75e8d2005-09-03 15:57:18 -0700455 # so must skip actual syscall
Linus Torvalds1da177e2005-04-16 15:20:36 -0700456 movl ORIG_EAX(%esp), %eax
457 cmpl $(nr_syscalls), %eax
458 jnae syscall_call
459 jmp syscall_exit
460
461 # perform syscall exit tracing
462 ALIGN
463syscall_exit_work:
464 testb $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SINGLESTEP), %cl
465 jz work_pending
466 sti # could let do_syscall_trace() call
467 # schedule() instead
468 movl %esp, %eax
469 movl $1, %edx
470 call do_syscall_trace
471 jmp resume_userspace
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200472 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700473
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200474 RING0_INT_FRAME # can't unwind into user space anyway
Linus Torvalds1da177e2005-04-16 15:20:36 -0700475syscall_fault:
476 pushl %eax # save orig_eax
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200477 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700478 SAVE_ALL
479 GET_THREAD_INFO(%ebp)
480 movl $-EFAULT,EAX(%esp)
481 jmp resume_userspace
482
Linus Torvalds1da177e2005-04-16 15:20:36 -0700483syscall_badsys:
484 movl $-ENOSYS,EAX(%esp)
485 jmp resume_userspace
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200486 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700487
488#define FIXUP_ESPFIX_STACK \
489 movl %esp, %eax; \
490 /* switch to 32bit stack using the pointer on top of 16bit stack */ \
491 lss %ss:CPU_16BIT_STACK_SIZE-8, %esp; \
492 /* copy data from 16bit stack to 32bit stack */ \
493 call fixup_x86_bogus_stack; \
494 /* put ESP to the proper location */ \
495 movl %eax, %esp;
496#define UNWIND_ESPFIX_STACK \
497 pushl %eax; \
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200498 CFI_ADJUST_CFA_OFFSET 4; \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700499 movl %ss, %eax; \
500 /* see if on 16bit stack */ \
501 cmpw $__ESPFIX_SS, %ax; \
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200502 je 28f; \
50327: popl %eax; \
504 CFI_ADJUST_CFA_OFFSET -4; \
505.section .fixup,"ax"; \
50628: movl $__KERNEL_DS, %eax; \
507 movl %eax, %ds; \
508 movl %eax, %es; \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700509 /* switch to 32bit stack */ \
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200510 FIXUP_ESPFIX_STACK; \
511 jmp 27b; \
512.previous
Linus Torvalds1da177e2005-04-16 15:20:36 -0700513
514/*
515 * Build the entry stubs and pointer table with
516 * some assembler magic.
517 */
518.data
519ENTRY(interrupt)
520.text
521
522vector=0
523ENTRY(irq_entries_start)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200524 RING0_INT_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700525.rept NR_IRQS
526 ALIGN
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200527 .if vector
528 CFI_ADJUST_CFA_OFFSET -4
529 .endif
Rusty Russell19eadf92006-06-27 02:53:44 -07005301: pushl $~(vector)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200531 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700532 jmp common_interrupt
533.data
534 .long 1b
535.text
536vector=vector+1
537.endr
538
539 ALIGN
540common_interrupt:
541 SAVE_ALL
542 movl %esp,%eax
543 call do_IRQ
544 jmp ret_from_intr
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200545 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700546
547#define BUILD_INTERRUPT(name, nr) \
548ENTRY(name) \
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200549 RING0_INT_FRAME; \
Rusty Russell19eadf92006-06-27 02:53:44 -0700550 pushl $~(nr); \
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200551 CFI_ADJUST_CFA_OFFSET 4; \
552 SAVE_ALL; \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700553 movl %esp,%eax; \
554 call smp_/**/name; \
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200555 jmp ret_from_intr; \
556 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700557
558/* The include is where all of the SMP etc. interrupts come from */
559#include "entry_arch.h"
560
561ENTRY(divide_error)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200562 RING0_INT_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700563 pushl $0 # no error code
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200564 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700565 pushl $do_divide_error
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200566 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700567 ALIGN
568error_code:
569 pushl %ds
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200570 CFI_ADJUST_CFA_OFFSET 4
571 /*CFI_REL_OFFSET ds, 0*/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700572 pushl %eax
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200573 CFI_ADJUST_CFA_OFFSET 4
574 CFI_REL_OFFSET eax, 0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700575 xorl %eax, %eax
576 pushl %ebp
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200577 CFI_ADJUST_CFA_OFFSET 4
578 CFI_REL_OFFSET ebp, 0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700579 pushl %edi
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200580 CFI_ADJUST_CFA_OFFSET 4
581 CFI_REL_OFFSET edi, 0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700582 pushl %esi
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200583 CFI_ADJUST_CFA_OFFSET 4
584 CFI_REL_OFFSET esi, 0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700585 pushl %edx
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200586 CFI_ADJUST_CFA_OFFSET 4
587 CFI_REL_OFFSET edx, 0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700588 decl %eax # eax = -1
589 pushl %ecx
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200590 CFI_ADJUST_CFA_OFFSET 4
591 CFI_REL_OFFSET ecx, 0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700592 pushl %ebx
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200593 CFI_ADJUST_CFA_OFFSET 4
594 CFI_REL_OFFSET ebx, 0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700595 cld
596 pushl %es
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200597 CFI_ADJUST_CFA_OFFSET 4
598 /*CFI_REL_OFFSET es, 0*/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700599 UNWIND_ESPFIX_STACK
600 popl %ecx
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200601 CFI_ADJUST_CFA_OFFSET -4
602 /*CFI_REGISTER es, ecx*/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700603 movl ES(%esp), %edi # get the function address
604 movl ORIG_EAX(%esp), %edx # get the error code
605 movl %eax, ORIG_EAX(%esp)
606 movl %ecx, ES(%esp)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200607 /*CFI_REL_OFFSET es, ES*/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700608 movl $(__USER_DS), %ecx
609 movl %ecx, %ds
610 movl %ecx, %es
611 movl %esp,%eax # pt_regs pointer
612 call *%edi
613 jmp ret_from_exception
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200614 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700615
616ENTRY(coprocessor_error)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200617 RING0_INT_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700618 pushl $0
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200619 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700620 pushl $do_coprocessor_error
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200621 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700622 jmp error_code
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200623 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700624
625ENTRY(simd_coprocessor_error)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200626 RING0_INT_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700627 pushl $0
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200628 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700629 pushl $do_simd_coprocessor_error
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200630 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700631 jmp error_code
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200632 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700633
634ENTRY(device_not_available)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200635 RING0_INT_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700636 pushl $-1 # mark this as an int
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200637 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700638 SAVE_ALL
639 movl %cr0, %eax
640 testl $0x4, %eax # EM (math emulation bit)
641 jne device_not_available_emulate
642 preempt_stop
643 call math_state_restore
644 jmp ret_from_exception
645device_not_available_emulate:
646 pushl $0 # temporary storage for ORIG_EIP
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200647 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700648 call math_emulate
649 addl $4, %esp
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200650 CFI_ADJUST_CFA_OFFSET -4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700651 jmp ret_from_exception
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200652 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700653
654/*
655 * Debug traps and NMI can happen at the one SYSENTER instruction
656 * that sets up the real kernel stack. Check here, since we can't
657 * allow the wrong stack to be used.
658 *
659 * "TSS_sysenter_esp0+12" is because the NMI/debug handler will have
660 * already pushed 3 words if it hits on the sysenter instruction:
661 * eflags, cs and eip.
662 *
663 * We just load the right stack, and push the three (known) values
664 * by hand onto the new stack - while updating the return eip past
665 * the instruction that would have done it for sysenter.
666 */
667#define FIX_STACK(offset, ok, label) \
668 cmpw $__KERNEL_CS,4(%esp); \
669 jne ok; \
670label: \
671 movl TSS_sysenter_esp0+offset(%esp),%esp; \
672 pushfl; \
673 pushl $__KERNEL_CS; \
674 pushl $sysenter_past_esp
675
Prasanna S Panchamukhi3d97ae52005-09-06 15:19:27 -0700676KPROBE_ENTRY(debug)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200677 RING0_INT_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700678 cmpl $sysenter_entry,(%esp)
679 jne debug_stack_correct
680 FIX_STACK(12, debug_stack_correct, debug_esp_fix_insn)
681debug_stack_correct:
682 pushl $-1 # mark this as an int
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200683 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700684 SAVE_ALL
685 xorl %edx,%edx # error code 0
686 movl %esp,%eax # pt_regs pointer
687 call do_debug
Linus Torvalds1da177e2005-04-16 15:20:36 -0700688 jmp ret_from_exception
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200689 CFI_ENDPROC
Prasanna S Panchamukhi3d97ae52005-09-06 15:19:27 -0700690 .previous .text
Linus Torvalds1da177e2005-04-16 15:20:36 -0700691/*
692 * NMI is doubly nasty. It can happen _while_ we're handling
693 * a debug fault, and the debug fault hasn't yet been able to
694 * clear up the stack. So we first check whether we got an
695 * NMI on the sysenter entry path, but after that we need to
696 * check whether we got an NMI on the debug path where the debug
697 * fault happened on the sysenter path.
698 */
699ENTRY(nmi)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200700 RING0_INT_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700701 pushl %eax
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200702 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700703 movl %ss, %eax
704 cmpw $__ESPFIX_SS, %ax
705 popl %eax
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200706 CFI_ADJUST_CFA_OFFSET -4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700707 je nmi_16bit_stack
708 cmpl $sysenter_entry,(%esp)
709 je nmi_stack_fixup
710 pushl %eax
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200711 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700712 movl %esp,%eax
713 /* Do not access memory above the end of our stack page,
714 * it might not exist.
715 */
716 andl $(THREAD_SIZE-1),%eax
717 cmpl $(THREAD_SIZE-20),%eax
718 popl %eax
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200719 CFI_ADJUST_CFA_OFFSET -4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700720 jae nmi_stack_correct
721 cmpl $sysenter_entry,12(%esp)
722 je nmi_debug_stack_check
723nmi_stack_correct:
724 pushl %eax
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200725 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700726 SAVE_ALL
727 xorl %edx,%edx # zero error code
728 movl %esp,%eax # pt_regs pointer
729 call do_nmi
730 jmp restore_all
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200731 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700732
733nmi_stack_fixup:
734 FIX_STACK(12,nmi_stack_correct, 1)
735 jmp nmi_stack_correct
736nmi_debug_stack_check:
737 cmpw $__KERNEL_CS,16(%esp)
738 jne nmi_stack_correct
Jan Beuliche2718202005-11-13 16:06:52 -0800739 cmpl $debug,(%esp)
740 jb nmi_stack_correct
Linus Torvalds1da177e2005-04-16 15:20:36 -0700741 cmpl $debug_esp_fix_insn,(%esp)
Jan Beuliche2718202005-11-13 16:06:52 -0800742 ja nmi_stack_correct
Linus Torvalds1da177e2005-04-16 15:20:36 -0700743 FIX_STACK(24,nmi_stack_correct, 1)
744 jmp nmi_stack_correct
745
746nmi_16bit_stack:
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200747 RING0_INT_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700748 /* create the pointer to lss back */
749 pushl %ss
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200750 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700751 pushl %esp
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200752 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700753 movzwl %sp, %esp
754 addw $4, (%esp)
755 /* copy the iret frame of 12 bytes */
756 .rept 3
757 pushl 16(%esp)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200758 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700759 .endr
760 pushl %eax
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200761 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700762 SAVE_ALL
763 FIXUP_ESPFIX_STACK # %eax == %esp
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200764 CFI_ADJUST_CFA_OFFSET -20 # the frame has now moved
Linus Torvalds1da177e2005-04-16 15:20:36 -0700765 xorl %edx,%edx # zero error code
766 call do_nmi
767 RESTORE_REGS
768 lss 12+4(%esp), %esp # back to 16bit stack
7691: iret
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200770 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700771.section __ex_table,"a"
772 .align 4
773 .long 1b,iret_exc
774.previous
775
Prasanna S Panchamukhi3d97ae52005-09-06 15:19:27 -0700776KPROBE_ENTRY(int3)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200777 RING0_INT_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700778 pushl $-1 # mark this as an int
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200779 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700780 SAVE_ALL
781 xorl %edx,%edx # zero error code
782 movl %esp,%eax # pt_regs pointer
783 call do_int3
Linus Torvalds1da177e2005-04-16 15:20:36 -0700784 jmp ret_from_exception
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200785 CFI_ENDPROC
Prasanna S Panchamukhi3d97ae52005-09-06 15:19:27 -0700786 .previous .text
Linus Torvalds1da177e2005-04-16 15:20:36 -0700787
788ENTRY(overflow)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200789 RING0_INT_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700790 pushl $0
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200791 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700792 pushl $do_overflow
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200793 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700794 jmp error_code
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200795 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700796
797ENTRY(bounds)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200798 RING0_INT_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700799 pushl $0
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200800 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700801 pushl $do_bounds
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200802 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700803 jmp error_code
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200804 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700805
806ENTRY(invalid_op)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200807 RING0_INT_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700808 pushl $0
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200809 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700810 pushl $do_invalid_op
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200811 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700812 jmp error_code
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200813 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700814
815ENTRY(coprocessor_segment_overrun)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200816 RING0_INT_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700817 pushl $0
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200818 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700819 pushl $do_coprocessor_segment_overrun
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200820 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700821 jmp error_code
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200822 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700823
824ENTRY(invalid_TSS)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200825 RING0_EC_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700826 pushl $do_invalid_TSS
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200827 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700828 jmp error_code
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200829 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700830
831ENTRY(segment_not_present)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200832 RING0_EC_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700833 pushl $do_segment_not_present
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200834 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700835 jmp error_code
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200836 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700837
838ENTRY(stack_segment)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200839 RING0_EC_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700840 pushl $do_stack_segment
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200841 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700842 jmp error_code
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200843 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700844
Prasanna S Panchamukhi3d97ae52005-09-06 15:19:27 -0700845KPROBE_ENTRY(general_protection)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200846 RING0_EC_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700847 pushl $do_general_protection
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200848 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700849 jmp error_code
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200850 CFI_ENDPROC
Prasanna S Panchamukhi3d97ae52005-09-06 15:19:27 -0700851 .previous .text
Linus Torvalds1da177e2005-04-16 15:20:36 -0700852
853ENTRY(alignment_check)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200854 RING0_EC_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700855 pushl $do_alignment_check
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200856 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700857 jmp error_code
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200858 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700859
Prasanna S Panchamukhi3d97ae52005-09-06 15:19:27 -0700860KPROBE_ENTRY(page_fault)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200861 RING0_EC_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700862 pushl $do_page_fault
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200863 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700864 jmp error_code
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200865 CFI_ENDPROC
Prasanna S Panchamukhi3d97ae52005-09-06 15:19:27 -0700866 .previous .text
Linus Torvalds1da177e2005-04-16 15:20:36 -0700867
868#ifdef CONFIG_X86_MCE
869ENTRY(machine_check)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200870 RING0_INT_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700871 pushl $0
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200872 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700873 pushl machine_check_vector
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200874 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700875 jmp error_code
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200876 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700877#endif
878
879ENTRY(spurious_interrupt_bug)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200880 RING0_INT_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700881 pushl $0
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200882 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700883 pushl $do_spurious_interrupt_bug
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200884 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700885 jmp error_code
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200886 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700887
Jan Beulich176a2712006-06-26 13:57:41 +0200888#ifdef CONFIG_STACK_UNWIND
889ENTRY(arch_unwind_init_running)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200890 CFI_STARTPROC
Jan Beulich176a2712006-06-26 13:57:41 +0200891 movl 4(%esp), %edx
892 movl (%esp), %ecx
893 leal 4(%esp), %eax
894 movl %ebx, EBX(%edx)
895 xorl %ebx, %ebx
896 movl %ebx, ECX(%edx)
897 movl %ebx, EDX(%edx)
898 movl %esi, ESI(%edx)
899 movl %edi, EDI(%edx)
900 movl %ebp, EBP(%edx)
901 movl %ebx, EAX(%edx)
902 movl $__USER_DS, DS(%edx)
903 movl $__USER_DS, ES(%edx)
904 movl %ebx, ORIG_EAX(%edx)
905 movl %ecx, EIP(%edx)
906 movl 12(%esp), %ecx
907 movl $__KERNEL_CS, CS(%edx)
908 movl %ebx, EFLAGS(%edx)
909 movl %eax, OLDESP(%edx)
910 movl 8(%esp), %eax
911 movl %ecx, 8(%esp)
912 movl EBX(%edx), %ebx
913 movl $__KERNEL_DS, OLDSS(%edx)
914 jmpl *%eax
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200915 CFI_ENDPROC
Jan Beulich176a2712006-06-26 13:57:41 +0200916ENDPROC(arch_unwind_init_running)
917#endif
918
Arjan van de Venbb152f52006-01-06 00:12:05 -0800919.section .rodata,"a"
Paolo 'Blaisorblade' Giarrusso5e7b83f2005-05-01 08:58:55 -0700920#include "syscall_table.S"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700921
922syscall_table_size=(.-sys_call_table)