blob: d9a260f2efb4d24086bf7ee4c1e8e1ab7eaf8c5e [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
Linus Torvalds1da177e2005-04-16 15:20:36 -070043#include <linux/linkage.h>
44#include <asm/thread_info.h>
Ingo Molnar55f327f2006-07-03 00:24:43 -070045#include <asm/irqflags.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070046#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
Ingo Molnar55f327f2006-07-03 00:24:43 -070080#define preempt_stop cli; TRACE_IRQS_OFF
Linus Torvalds1da177e2005-04-16 15:20:36 -070081#else
82#define preempt_stop
83#define resume_kernel restore_nocheck
84#endif
85
Ingo Molnar55f327f2006-07-03 00:24:43 -070086.macro TRACE_IRQS_IRET
87#ifdef CONFIG_TRACE_IRQFLAGS
88 testl $IF_MASK,EFLAGS(%esp) # interrupts off?
89 jz 1f
90 TRACE_IRQS_ON
911:
92#endif
93.endm
94
Aleksey Gorelov4031ff32006-06-27 02:53:48 -070095#ifdef CONFIG_VM86
96#define resume_userspace_sig check_userspace
97#else
98#define resume_userspace_sig resume_userspace
99#endif
100
Linus Torvalds1da177e2005-04-16 15:20:36 -0700101#define SAVE_ALL \
102 cld; \
103 pushl %es; \
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200104 CFI_ADJUST_CFA_OFFSET 4;\
105 /*CFI_REL_OFFSET es, 0;*/\
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106 pushl %ds; \
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200107 CFI_ADJUST_CFA_OFFSET 4;\
108 /*CFI_REL_OFFSET ds, 0;*/\
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109 pushl %eax; \
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200110 CFI_ADJUST_CFA_OFFSET 4;\
111 CFI_REL_OFFSET eax, 0;\
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112 pushl %ebp; \
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200113 CFI_ADJUST_CFA_OFFSET 4;\
114 CFI_REL_OFFSET ebp, 0;\
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115 pushl %edi; \
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200116 CFI_ADJUST_CFA_OFFSET 4;\
117 CFI_REL_OFFSET edi, 0;\
Linus Torvalds1da177e2005-04-16 15:20:36 -0700118 pushl %esi; \
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200119 CFI_ADJUST_CFA_OFFSET 4;\
120 CFI_REL_OFFSET esi, 0;\
Linus Torvalds1da177e2005-04-16 15:20:36 -0700121 pushl %edx; \
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200122 CFI_ADJUST_CFA_OFFSET 4;\
123 CFI_REL_OFFSET edx, 0;\
Linus Torvalds1da177e2005-04-16 15:20:36 -0700124 pushl %ecx; \
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200125 CFI_ADJUST_CFA_OFFSET 4;\
126 CFI_REL_OFFSET ecx, 0;\
Linus Torvalds1da177e2005-04-16 15:20:36 -0700127 pushl %ebx; \
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200128 CFI_ADJUST_CFA_OFFSET 4;\
129 CFI_REL_OFFSET ebx, 0;\
Linus Torvalds1da177e2005-04-16 15:20:36 -0700130 movl $(__USER_DS), %edx; \
131 movl %edx, %ds; \
132 movl %edx, %es;
133
134#define RESTORE_INT_REGS \
135 popl %ebx; \
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200136 CFI_ADJUST_CFA_OFFSET -4;\
137 CFI_RESTORE ebx;\
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138 popl %ecx; \
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200139 CFI_ADJUST_CFA_OFFSET -4;\
140 CFI_RESTORE ecx;\
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141 popl %edx; \
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200142 CFI_ADJUST_CFA_OFFSET -4;\
143 CFI_RESTORE edx;\
Linus Torvalds1da177e2005-04-16 15:20:36 -0700144 popl %esi; \
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200145 CFI_ADJUST_CFA_OFFSET -4;\
146 CFI_RESTORE esi;\
Linus Torvalds1da177e2005-04-16 15:20:36 -0700147 popl %edi; \
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200148 CFI_ADJUST_CFA_OFFSET -4;\
149 CFI_RESTORE edi;\
Linus Torvalds1da177e2005-04-16 15:20:36 -0700150 popl %ebp; \
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200151 CFI_ADJUST_CFA_OFFSET -4;\
152 CFI_RESTORE ebp;\
153 popl %eax; \
154 CFI_ADJUST_CFA_OFFSET -4;\
155 CFI_RESTORE eax
Linus Torvalds1da177e2005-04-16 15:20:36 -0700156
157#define RESTORE_REGS \
158 RESTORE_INT_REGS; \
1591: popl %ds; \
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200160 CFI_ADJUST_CFA_OFFSET -4;\
161 /*CFI_RESTORE ds;*/\
Linus Torvalds1da177e2005-04-16 15:20:36 -07001622: popl %es; \
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200163 CFI_ADJUST_CFA_OFFSET -4;\
164 /*CFI_RESTORE es;*/\
Linus Torvalds1da177e2005-04-16 15:20:36 -0700165.section .fixup,"ax"; \
1663: movl $0,(%esp); \
167 jmp 1b; \
1684: movl $0,(%esp); \
169 jmp 2b; \
170.previous; \
171.section __ex_table,"a";\
172 .align 4; \
173 .long 1b,3b; \
174 .long 2b,4b; \
175.previous
176
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200177#define RING0_INT_FRAME \
178 CFI_STARTPROC simple;\
179 CFI_DEF_CFA esp, 3*4;\
180 /*CFI_OFFSET cs, -2*4;*/\
181 CFI_OFFSET eip, -3*4
182
183#define RING0_EC_FRAME \
184 CFI_STARTPROC simple;\
185 CFI_DEF_CFA esp, 4*4;\
186 /*CFI_OFFSET cs, -2*4;*/\
187 CFI_OFFSET eip, -3*4
188
189#define RING0_PTREGS_FRAME \
190 CFI_STARTPROC simple;\
191 CFI_DEF_CFA esp, OLDESP-EBX;\
192 /*CFI_OFFSET cs, CS-OLDESP;*/\
193 CFI_OFFSET eip, EIP-OLDESP;\
194 /*CFI_OFFSET es, ES-OLDESP;*/\
195 /*CFI_OFFSET ds, DS-OLDESP;*/\
196 CFI_OFFSET eax, EAX-OLDESP;\
197 CFI_OFFSET ebp, EBP-OLDESP;\
198 CFI_OFFSET edi, EDI-OLDESP;\
199 CFI_OFFSET esi, ESI-OLDESP;\
200 CFI_OFFSET edx, EDX-OLDESP;\
201 CFI_OFFSET ecx, ECX-OLDESP;\
202 CFI_OFFSET ebx, EBX-OLDESP
Linus Torvalds1da177e2005-04-16 15:20:36 -0700203
204ENTRY(ret_from_fork)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200205 CFI_STARTPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700206 pushl %eax
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200207 CFI_ADJUST_CFA_OFFSET -4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700208 call schedule_tail
209 GET_THREAD_INFO(%ebp)
210 popl %eax
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200211 CFI_ADJUST_CFA_OFFSET -4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700212 jmp syscall_exit
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200213 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700214
215/*
216 * Return to user mode is not as complex as all this looks,
217 * but we want the default path for a system call return to
218 * go as quickly as possible which is why some of this is
219 * less clear than it otherwise should be.
220 */
221
222 # userspace resumption stub bypassing syscall exit tracing
223 ALIGN
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200224 RING0_PTREGS_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700225ret_from_exception:
226 preempt_stop
227ret_from_intr:
228 GET_THREAD_INFO(%ebp)
Aleksey Gorelov4031ff32006-06-27 02:53:48 -0700229check_userspace:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700230 movl EFLAGS(%esp), %eax # mix EFLAGS and CS
231 movb CS(%esp), %al
232 testl $(VM_MASK | 3), %eax
233 jz resume_kernel
234ENTRY(resume_userspace)
235 cli # make sure we don't miss an interrupt
236 # setting need_resched or sigpending
237 # between sampling and the iret
238 movl TI_flags(%ebp), %ecx
239 andl $_TIF_WORK_MASK, %ecx # is there any work to be done on
240 # int/exception return?
241 jne work_pending
242 jmp restore_all
243
244#ifdef CONFIG_PREEMPT
245ENTRY(resume_kernel)
246 cli
247 cmpl $0,TI_preempt_count(%ebp) # non-zero preempt_count ?
248 jnz restore_nocheck
249need_resched:
250 movl TI_flags(%ebp), %ecx # need_resched set ?
251 testb $_TIF_NEED_RESCHED, %cl
252 jz restore_all
253 testl $IF_MASK,EFLAGS(%esp) # interrupts off (exception path) ?
254 jz restore_all
255 call preempt_schedule_irq
256 jmp need_resched
257#endif
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200258 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700259
260/* SYSENTER_RETURN points to after the "sysenter" instruction in
261 the vsyscall page. See vsyscall-sysentry.S, which defines the symbol. */
262
263 # sysenter call handler stub
264ENTRY(sysenter_entry)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200265 CFI_STARTPROC simple
266 CFI_DEF_CFA esp, 0
267 CFI_REGISTER esp, ebp
Linus Torvalds1da177e2005-04-16 15:20:36 -0700268 movl TSS_sysenter_esp0(%esp),%esp
269sysenter_past_esp:
Ingo Molnar55f327f2006-07-03 00:24:43 -0700270 /*
271 * No need to follow this irqs on/off section: the syscall
272 * disabled irqs and here we enable it straight after entry:
273 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700274 sti
275 pushl $(__USER_DS)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200276 CFI_ADJUST_CFA_OFFSET 4
277 /*CFI_REL_OFFSET ss, 0*/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700278 pushl %ebp
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200279 CFI_ADJUST_CFA_OFFSET 4
280 CFI_REL_OFFSET esp, 0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700281 pushfl
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200282 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700283 pushl $(__USER_CS)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200284 CFI_ADJUST_CFA_OFFSET 4
285 /*CFI_REL_OFFSET cs, 0*/
Ingo Molnare6e54942006-06-27 02:53:50 -0700286 /*
287 * Push current_thread_info()->sysenter_return to the stack.
288 * A tiny bit of offset fixup is necessary - 4*4 means the 4 words
289 * pushed above; +8 corresponds to copy_thread's esp0 setting.
290 */
291 pushl (TI_sysenter_return-THREAD_SIZE+8+4*4)(%esp)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200292 CFI_ADJUST_CFA_OFFSET 4
293 CFI_REL_OFFSET eip, 0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700294
295/*
296 * Load the potential sixth argument from user stack.
297 * Careful about security.
298 */
299 cmpl $__PAGE_OFFSET-3,%ebp
300 jae syscall_fault
3011: movl (%ebp),%ebp
302.section __ex_table,"a"
303 .align 4
304 .long 1b,syscall_fault
305.previous
306
307 pushl %eax
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200308 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700309 SAVE_ALL
310 GET_THREAD_INFO(%ebp)
311
312 /* Note, _TIF_SECCOMP is bit number 8, and so it needs testw and not testb */
Laurent Viviered75e8d2005-09-03 15:57:18 -0700313 testw $(_TIF_SYSCALL_EMU|_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT),TI_flags(%ebp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700314 jnz syscall_trace_entry
315 cmpl $(nr_syscalls), %eax
316 jae syscall_badsys
317 call *sys_call_table(,%eax,4)
318 movl %eax,EAX(%esp)
319 cli
Ingo Molnar55f327f2006-07-03 00:24:43 -0700320 TRACE_IRQS_OFF
Linus Torvalds1da177e2005-04-16 15:20:36 -0700321 movl TI_flags(%ebp), %ecx
322 testw $_TIF_ALLWORK_MASK, %cx
323 jne syscall_exit_work
324/* if something modifies registers it must also disable sysexit */
325 movl EIP(%esp), %edx
326 movl OLDESP(%esp), %ecx
327 xorl %ebp,%ebp
Ingo Molnar55f327f2006-07-03 00:24:43 -0700328 TRACE_IRQS_ON
Linus Torvalds1da177e2005-04-16 15:20:36 -0700329 sti
330 sysexit
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200331 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700332
333
334 # system call handler stub
335ENTRY(system_call)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200336 RING0_INT_FRAME # can't unwind into user space anyway
Linus Torvalds1da177e2005-04-16 15:20:36 -0700337 pushl %eax # save orig_eax
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200338 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700339 SAVE_ALL
340 GET_THREAD_INFO(%ebp)
Chuck Ebbert635cf992006-03-23 02:59:48 -0800341 testl $TF_MASK,EFLAGS(%esp)
342 jz no_singlestep
343 orl $_TIF_SINGLESTEP,TI_flags(%ebp)
344no_singlestep:
Laurent Viviered75e8d2005-09-03 15:57:18 -0700345 # system call tracing in operation / emulation
Linus Torvalds1da177e2005-04-16 15:20:36 -0700346 /* Note, _TIF_SECCOMP is bit number 8, and so it needs testw and not testb */
Laurent Viviered75e8d2005-09-03 15:57:18 -0700347 testw $(_TIF_SYSCALL_EMU|_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT),TI_flags(%ebp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700348 jnz syscall_trace_entry
349 cmpl $(nr_syscalls), %eax
350 jae syscall_badsys
351syscall_call:
352 call *sys_call_table(,%eax,4)
353 movl %eax,EAX(%esp) # store the return value
354syscall_exit:
355 cli # make sure we don't miss an interrupt
356 # setting need_resched or sigpending
357 # between sampling and the iret
Ingo Molnar55f327f2006-07-03 00:24:43 -0700358 TRACE_IRQS_OFF
Linus Torvalds1da177e2005-04-16 15:20:36 -0700359 movl TI_flags(%ebp), %ecx
360 testw $_TIF_ALLWORK_MASK, %cx # current->work
361 jne syscall_exit_work
362
363restore_all:
364 movl EFLAGS(%esp), %eax # mix EFLAGS, SS and CS
Stas Sergeev5df24082005-04-16 15:24:01 -0700365 # Warning: OLDSS(%esp) contains the wrong/random values if we
366 # are returning to the kernel.
367 # See comments in process.c:copy_thread() for details.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700368 movb OLDSS(%esp), %ah
369 movb CS(%esp), %al
370 andl $(VM_MASK | (4 << 8) | 3), %eax
371 cmpl $((4 << 8) | 3), %eax
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200372 CFI_REMEMBER_STATE
Linus Torvalds1da177e2005-04-16 15:20:36 -0700373 je ldt_ss # returning to user-space with LDT SS
374restore_nocheck:
Ingo Molnar55f327f2006-07-03 00:24:43 -0700375 TRACE_IRQS_IRET
376restore_nocheck_notrace:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700377 RESTORE_REGS
378 addl $4, %esp
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200379 CFI_ADJUST_CFA_OFFSET -4
Linus Torvalds1da177e2005-04-16 15:20:36 -07003801: iret
381.section .fixup,"ax"
382iret_exc:
Ingo Molnar55f327f2006-07-03 00:24:43 -0700383 TRACE_IRQS_ON
Linus Torvalds1da177e2005-04-16 15:20:36 -0700384 sti
Linus Torvaldsa879cbb2005-04-29 09:38:44 -0700385 pushl $0 # no error code
386 pushl $do_iret_error
387 jmp error_code
Linus Torvalds1da177e2005-04-16 15:20:36 -0700388.previous
389.section __ex_table,"a"
390 .align 4
391 .long 1b,iret_exc
392.previous
393
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200394 CFI_RESTORE_STATE
Linus Torvalds1da177e2005-04-16 15:20:36 -0700395ldt_ss:
396 larl OLDSS(%esp), %eax
397 jnz restore_nocheck
398 testl $0x00400000, %eax # returning to 32bit stack?
399 jnz restore_nocheck # allright, normal return
400 /* If returning to userspace with 16bit stack,
401 * try to fix the higher word of ESP, as the CPU
402 * won't restore it.
403 * This is an "official" bug of all the x86-compatible
404 * CPUs, which we can try to work around to make
405 * dosemu and wine happy. */
406 subl $8, %esp # reserve space for switch16 pointer
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200407 CFI_ADJUST_CFA_OFFSET 8
Linus Torvalds1da177e2005-04-16 15:20:36 -0700408 cli
Ingo Molnar55f327f2006-07-03 00:24:43 -0700409 TRACE_IRQS_OFF
Linus Torvalds1da177e2005-04-16 15:20:36 -0700410 movl %esp, %eax
411 /* Set up the 16bit stack frame with switch32 pointer on top,
412 * and a switch16 pointer on top of the current frame. */
413 call setup_x86_bogus_stack
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200414 CFI_ADJUST_CFA_OFFSET -8 # frame has moved
Ingo Molnar55f327f2006-07-03 00:24:43 -0700415 TRACE_IRQS_IRET
Linus Torvalds1da177e2005-04-16 15:20:36 -0700416 RESTORE_REGS
417 lss 20+4(%esp), %esp # switch to 16bit stack
4181: iret
419.section __ex_table,"a"
420 .align 4
421 .long 1b,iret_exc
422.previous
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200423 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700424
425 # perform work that needs to be done immediately before resumption
426 ALIGN
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200427 RING0_PTREGS_FRAME # can't unwind into user space anyway
Linus Torvalds1da177e2005-04-16 15:20:36 -0700428work_pending:
429 testb $_TIF_NEED_RESCHED, %cl
430 jz work_notifysig
431work_resched:
432 call schedule
433 cli # make sure we don't miss an interrupt
434 # setting need_resched or sigpending
435 # between sampling and the iret
Ingo Molnar55f327f2006-07-03 00:24:43 -0700436 TRACE_IRQS_OFF
Linus Torvalds1da177e2005-04-16 15:20:36 -0700437 movl TI_flags(%ebp), %ecx
438 andl $_TIF_WORK_MASK, %ecx # is there any work to be done other
439 # than syscall tracing?
440 jz restore_all
441 testb $_TIF_NEED_RESCHED, %cl
442 jnz work_resched
443
444work_notifysig: # deal with pending signals and
445 # notify-resume requests
446 testl $VM_MASK, EFLAGS(%esp)
447 movl %esp, %eax
448 jne work_notifysig_v86 # returning to kernel-space or
449 # vm86-space
450 xorl %edx, %edx
451 call do_notify_resume
Aleksey Gorelov4031ff32006-06-27 02:53:48 -0700452 jmp resume_userspace_sig
Linus Torvalds1da177e2005-04-16 15:20:36 -0700453
454 ALIGN
455work_notifysig_v86:
Matt Mackall64ca9002006-01-08 01:05:26 -0800456#ifdef CONFIG_VM86
Linus Torvalds1da177e2005-04-16 15:20:36 -0700457 pushl %ecx # save ti_flags for do_notify_resume
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200458 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700459 call save_v86_state # %eax contains pt_regs pointer
460 popl %ecx
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200461 CFI_ADJUST_CFA_OFFSET -4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700462 movl %eax, %esp
463 xorl %edx, %edx
464 call do_notify_resume
Aleksey Gorelov4031ff32006-06-27 02:53:48 -0700465 jmp resume_userspace_sig
Matt Mackall64ca9002006-01-08 01:05:26 -0800466#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700467
468 # perform syscall exit tracing
469 ALIGN
470syscall_trace_entry:
471 movl $-ENOSYS,EAX(%esp)
472 movl %esp, %eax
473 xorl %edx,%edx
474 call do_syscall_trace
Laurent Viviered75e8d2005-09-03 15:57:18 -0700475 cmpl $0, %eax
Paolo 'Blaisorblade' Giarrusso640aa462005-09-03 15:57:22 -0700476 jne resume_userspace # ret != 0 -> running under PTRACE_SYSEMU,
Laurent Viviered75e8d2005-09-03 15:57:18 -0700477 # so must skip actual syscall
Linus Torvalds1da177e2005-04-16 15:20:36 -0700478 movl ORIG_EAX(%esp), %eax
479 cmpl $(nr_syscalls), %eax
480 jnae syscall_call
481 jmp syscall_exit
482
483 # perform syscall exit tracing
484 ALIGN
485syscall_exit_work:
486 testb $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SINGLESTEP), %cl
487 jz work_pending
Ingo Molnar55f327f2006-07-03 00:24:43 -0700488 TRACE_IRQS_ON
Linus Torvalds1da177e2005-04-16 15:20:36 -0700489 sti # could let do_syscall_trace() call
490 # schedule() instead
491 movl %esp, %eax
492 movl $1, %edx
493 call do_syscall_trace
494 jmp resume_userspace
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200495 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700496
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200497 RING0_INT_FRAME # can't unwind into user space anyway
Linus Torvalds1da177e2005-04-16 15:20:36 -0700498syscall_fault:
499 pushl %eax # save orig_eax
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200500 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700501 SAVE_ALL
502 GET_THREAD_INFO(%ebp)
503 movl $-EFAULT,EAX(%esp)
504 jmp resume_userspace
505
Linus Torvalds1da177e2005-04-16 15:20:36 -0700506syscall_badsys:
507 movl $-ENOSYS,EAX(%esp)
508 jmp resume_userspace
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200509 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700510
511#define FIXUP_ESPFIX_STACK \
512 movl %esp, %eax; \
513 /* switch to 32bit stack using the pointer on top of 16bit stack */ \
514 lss %ss:CPU_16BIT_STACK_SIZE-8, %esp; \
515 /* copy data from 16bit stack to 32bit stack */ \
516 call fixup_x86_bogus_stack; \
517 /* put ESP to the proper location */ \
518 movl %eax, %esp;
519#define UNWIND_ESPFIX_STACK \
520 pushl %eax; \
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200521 CFI_ADJUST_CFA_OFFSET 4; \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700522 movl %ss, %eax; \
523 /* see if on 16bit stack */ \
524 cmpw $__ESPFIX_SS, %ax; \
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200525 je 28f; \
52627: popl %eax; \
527 CFI_ADJUST_CFA_OFFSET -4; \
528.section .fixup,"ax"; \
52928: movl $__KERNEL_DS, %eax; \
530 movl %eax, %ds; \
531 movl %eax, %es; \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700532 /* switch to 32bit stack */ \
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200533 FIXUP_ESPFIX_STACK; \
534 jmp 27b; \
535.previous
Linus Torvalds1da177e2005-04-16 15:20:36 -0700536
537/*
538 * Build the entry stubs and pointer table with
539 * some assembler magic.
540 */
541.data
542ENTRY(interrupt)
543.text
544
545vector=0
546ENTRY(irq_entries_start)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200547 RING0_INT_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700548.rept NR_IRQS
549 ALIGN
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200550 .if vector
551 CFI_ADJUST_CFA_OFFSET -4
552 .endif
Rusty Russell19eadf92006-06-27 02:53:44 -07005531: pushl $~(vector)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200554 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700555 jmp common_interrupt
556.data
557 .long 1b
558.text
559vector=vector+1
560.endr
561
Ingo Molnar55f327f2006-07-03 00:24:43 -0700562/*
563 * the CPU automatically disables interrupts when executing an IRQ vector,
564 * so IRQ-flags tracing has to follow that:
565 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700566 ALIGN
567common_interrupt:
568 SAVE_ALL
Ingo Molnar55f327f2006-07-03 00:24:43 -0700569 TRACE_IRQS_OFF
Linus Torvalds1da177e2005-04-16 15:20:36 -0700570 movl %esp,%eax
571 call do_IRQ
572 jmp ret_from_intr
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200573 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700574
575#define BUILD_INTERRUPT(name, nr) \
576ENTRY(name) \
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200577 RING0_INT_FRAME; \
Rusty Russell19eadf92006-06-27 02:53:44 -0700578 pushl $~(nr); \
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200579 CFI_ADJUST_CFA_OFFSET 4; \
580 SAVE_ALL; \
Ingo Molnar55f327f2006-07-03 00:24:43 -0700581 TRACE_IRQS_OFF \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700582 movl %esp,%eax; \
583 call smp_/**/name; \
Ingo Molnar55f327f2006-07-03 00:24:43 -0700584 jmp ret_from_intr; \
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200585 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700586
587/* The include is where all of the SMP etc. interrupts come from */
588#include "entry_arch.h"
589
590ENTRY(divide_error)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200591 RING0_INT_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700592 pushl $0 # no error code
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200593 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700594 pushl $do_divide_error
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200595 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700596 ALIGN
597error_code:
598 pushl %ds
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200599 CFI_ADJUST_CFA_OFFSET 4
600 /*CFI_REL_OFFSET ds, 0*/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700601 pushl %eax
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200602 CFI_ADJUST_CFA_OFFSET 4
603 CFI_REL_OFFSET eax, 0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700604 xorl %eax, %eax
605 pushl %ebp
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200606 CFI_ADJUST_CFA_OFFSET 4
607 CFI_REL_OFFSET ebp, 0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700608 pushl %edi
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200609 CFI_ADJUST_CFA_OFFSET 4
610 CFI_REL_OFFSET edi, 0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700611 pushl %esi
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200612 CFI_ADJUST_CFA_OFFSET 4
613 CFI_REL_OFFSET esi, 0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700614 pushl %edx
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200615 CFI_ADJUST_CFA_OFFSET 4
616 CFI_REL_OFFSET edx, 0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700617 decl %eax # eax = -1
618 pushl %ecx
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200619 CFI_ADJUST_CFA_OFFSET 4
620 CFI_REL_OFFSET ecx, 0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700621 pushl %ebx
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200622 CFI_ADJUST_CFA_OFFSET 4
623 CFI_REL_OFFSET ebx, 0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700624 cld
625 pushl %es
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200626 CFI_ADJUST_CFA_OFFSET 4
627 /*CFI_REL_OFFSET es, 0*/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700628 UNWIND_ESPFIX_STACK
629 popl %ecx
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200630 CFI_ADJUST_CFA_OFFSET -4
631 /*CFI_REGISTER es, ecx*/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700632 movl ES(%esp), %edi # get the function address
633 movl ORIG_EAX(%esp), %edx # get the error code
634 movl %eax, ORIG_EAX(%esp)
635 movl %ecx, ES(%esp)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200636 /*CFI_REL_OFFSET es, ES*/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700637 movl $(__USER_DS), %ecx
638 movl %ecx, %ds
639 movl %ecx, %es
640 movl %esp,%eax # pt_regs pointer
641 call *%edi
642 jmp ret_from_exception
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200643 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700644
645ENTRY(coprocessor_error)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200646 RING0_INT_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700647 pushl $0
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200648 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700649 pushl $do_coprocessor_error
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200650 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700651 jmp error_code
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200652 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700653
654ENTRY(simd_coprocessor_error)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200655 RING0_INT_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700656 pushl $0
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200657 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700658 pushl $do_simd_coprocessor_error
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200659 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700660 jmp error_code
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200661 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700662
663ENTRY(device_not_available)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200664 RING0_INT_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700665 pushl $-1 # mark this as an int
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200666 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700667 SAVE_ALL
668 movl %cr0, %eax
669 testl $0x4, %eax # EM (math emulation bit)
670 jne device_not_available_emulate
671 preempt_stop
672 call math_state_restore
673 jmp ret_from_exception
674device_not_available_emulate:
675 pushl $0 # temporary storage for ORIG_EIP
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200676 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700677 call math_emulate
678 addl $4, %esp
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200679 CFI_ADJUST_CFA_OFFSET -4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700680 jmp ret_from_exception
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200681 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700682
683/*
684 * Debug traps and NMI can happen at the one SYSENTER instruction
685 * that sets up the real kernel stack. Check here, since we can't
686 * allow the wrong stack to be used.
687 *
688 * "TSS_sysenter_esp0+12" is because the NMI/debug handler will have
689 * already pushed 3 words if it hits on the sysenter instruction:
690 * eflags, cs and eip.
691 *
692 * We just load the right stack, and push the three (known) values
693 * by hand onto the new stack - while updating the return eip past
694 * the instruction that would have done it for sysenter.
695 */
696#define FIX_STACK(offset, ok, label) \
697 cmpw $__KERNEL_CS,4(%esp); \
698 jne ok; \
699label: \
700 movl TSS_sysenter_esp0+offset(%esp),%esp; \
701 pushfl; \
702 pushl $__KERNEL_CS; \
703 pushl $sysenter_past_esp
704
Prasanna S Panchamukhi3d97ae52005-09-06 15:19:27 -0700705KPROBE_ENTRY(debug)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200706 RING0_INT_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700707 cmpl $sysenter_entry,(%esp)
708 jne debug_stack_correct
709 FIX_STACK(12, debug_stack_correct, debug_esp_fix_insn)
710debug_stack_correct:
711 pushl $-1 # mark this as an int
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200712 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700713 SAVE_ALL
714 xorl %edx,%edx # error code 0
715 movl %esp,%eax # pt_regs pointer
716 call do_debug
Linus Torvalds1da177e2005-04-16 15:20:36 -0700717 jmp ret_from_exception
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200718 CFI_ENDPROC
Prasanna S Panchamukhi3d97ae52005-09-06 15:19:27 -0700719 .previous .text
Linus Torvalds1da177e2005-04-16 15:20:36 -0700720/*
721 * NMI is doubly nasty. It can happen _while_ we're handling
722 * a debug fault, and the debug fault hasn't yet been able to
723 * clear up the stack. So we first check whether we got an
724 * NMI on the sysenter entry path, but after that we need to
725 * check whether we got an NMI on the debug path where the debug
726 * fault happened on the sysenter path.
727 */
728ENTRY(nmi)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200729 RING0_INT_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700730 pushl %eax
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200731 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700732 movl %ss, %eax
733 cmpw $__ESPFIX_SS, %ax
734 popl %eax
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200735 CFI_ADJUST_CFA_OFFSET -4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700736 je nmi_16bit_stack
737 cmpl $sysenter_entry,(%esp)
738 je nmi_stack_fixup
739 pushl %eax
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200740 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700741 movl %esp,%eax
742 /* Do not access memory above the end of our stack page,
743 * it might not exist.
744 */
745 andl $(THREAD_SIZE-1),%eax
746 cmpl $(THREAD_SIZE-20),%eax
747 popl %eax
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200748 CFI_ADJUST_CFA_OFFSET -4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700749 jae nmi_stack_correct
750 cmpl $sysenter_entry,12(%esp)
751 je nmi_debug_stack_check
752nmi_stack_correct:
753 pushl %eax
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200754 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700755 SAVE_ALL
756 xorl %edx,%edx # zero error code
757 movl %esp,%eax # pt_regs pointer
758 call do_nmi
Ingo Molnar55f327f2006-07-03 00:24:43 -0700759 jmp restore_nocheck_notrace
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200760 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700761
762nmi_stack_fixup:
763 FIX_STACK(12,nmi_stack_correct, 1)
764 jmp nmi_stack_correct
765nmi_debug_stack_check:
766 cmpw $__KERNEL_CS,16(%esp)
767 jne nmi_stack_correct
Jan Beuliche2718202005-11-13 16:06:52 -0800768 cmpl $debug,(%esp)
769 jb nmi_stack_correct
Linus Torvalds1da177e2005-04-16 15:20:36 -0700770 cmpl $debug_esp_fix_insn,(%esp)
Jan Beuliche2718202005-11-13 16:06:52 -0800771 ja nmi_stack_correct
Linus Torvalds1da177e2005-04-16 15:20:36 -0700772 FIX_STACK(24,nmi_stack_correct, 1)
773 jmp nmi_stack_correct
774
775nmi_16bit_stack:
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200776 RING0_INT_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700777 /* create the pointer to lss back */
778 pushl %ss
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200779 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700780 pushl %esp
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200781 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700782 movzwl %sp, %esp
783 addw $4, (%esp)
784 /* copy the iret frame of 12 bytes */
785 .rept 3
786 pushl 16(%esp)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200787 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700788 .endr
789 pushl %eax
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200790 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700791 SAVE_ALL
792 FIXUP_ESPFIX_STACK # %eax == %esp
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200793 CFI_ADJUST_CFA_OFFSET -20 # the frame has now moved
Linus Torvalds1da177e2005-04-16 15:20:36 -0700794 xorl %edx,%edx # zero error code
795 call do_nmi
796 RESTORE_REGS
797 lss 12+4(%esp), %esp # back to 16bit stack
7981: iret
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200799 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700800.section __ex_table,"a"
801 .align 4
802 .long 1b,iret_exc
803.previous
804
Prasanna S Panchamukhi3d97ae52005-09-06 15:19:27 -0700805KPROBE_ENTRY(int3)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200806 RING0_INT_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700807 pushl $-1 # mark this as an int
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200808 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700809 SAVE_ALL
810 xorl %edx,%edx # zero error code
811 movl %esp,%eax # pt_regs pointer
812 call do_int3
Linus Torvalds1da177e2005-04-16 15:20:36 -0700813 jmp ret_from_exception
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200814 CFI_ENDPROC
Prasanna S Panchamukhi3d97ae52005-09-06 15:19:27 -0700815 .previous .text
Linus Torvalds1da177e2005-04-16 15:20:36 -0700816
817ENTRY(overflow)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200818 RING0_INT_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700819 pushl $0
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200820 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700821 pushl $do_overflow
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200822 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700823 jmp error_code
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200824 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700825
826ENTRY(bounds)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200827 RING0_INT_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700828 pushl $0
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200829 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700830 pushl $do_bounds
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200831 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700832 jmp error_code
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200833 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700834
835ENTRY(invalid_op)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200836 RING0_INT_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700837 pushl $0
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200838 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700839 pushl $do_invalid_op
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200840 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700841 jmp error_code
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200842 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700843
844ENTRY(coprocessor_segment_overrun)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200845 RING0_INT_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700846 pushl $0
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200847 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700848 pushl $do_coprocessor_segment_overrun
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200849 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700850 jmp error_code
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200851 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700852
853ENTRY(invalid_TSS)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200854 RING0_EC_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700855 pushl $do_invalid_TSS
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
860ENTRY(segment_not_present)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200861 RING0_EC_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700862 pushl $do_segment_not_present
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
Linus Torvalds1da177e2005-04-16 15:20:36 -0700866
867ENTRY(stack_segment)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200868 RING0_EC_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700869 pushl $do_stack_segment
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200870 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700871 jmp error_code
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200872 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700873
Prasanna S Panchamukhi3d97ae52005-09-06 15:19:27 -0700874KPROBE_ENTRY(general_protection)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200875 RING0_EC_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700876 pushl $do_general_protection
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200877 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700878 jmp error_code
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200879 CFI_ENDPROC
Prasanna S Panchamukhi3d97ae52005-09-06 15:19:27 -0700880 .previous .text
Linus Torvalds1da177e2005-04-16 15:20:36 -0700881
882ENTRY(alignment_check)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200883 RING0_EC_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700884 pushl $do_alignment_check
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200885 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700886 jmp error_code
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200887 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700888
Prasanna S Panchamukhi3d97ae52005-09-06 15:19:27 -0700889KPROBE_ENTRY(page_fault)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200890 RING0_EC_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700891 pushl $do_page_fault
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200892 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700893 jmp error_code
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200894 CFI_ENDPROC
Prasanna S Panchamukhi3d97ae52005-09-06 15:19:27 -0700895 .previous .text
Linus Torvalds1da177e2005-04-16 15:20:36 -0700896
897#ifdef CONFIG_X86_MCE
898ENTRY(machine_check)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200899 RING0_INT_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700900 pushl $0
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200901 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700902 pushl machine_check_vector
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200903 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700904 jmp error_code
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200905 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700906#endif
907
908ENTRY(spurious_interrupt_bug)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200909 RING0_INT_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700910 pushl $0
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200911 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700912 pushl $do_spurious_interrupt_bug
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200913 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700914 jmp error_code
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200915 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700916
Jan Beulich176a2712006-06-26 13:57:41 +0200917#ifdef CONFIG_STACK_UNWIND
918ENTRY(arch_unwind_init_running)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200919 CFI_STARTPROC
Jan Beulich176a2712006-06-26 13:57:41 +0200920 movl 4(%esp), %edx
921 movl (%esp), %ecx
922 leal 4(%esp), %eax
923 movl %ebx, EBX(%edx)
924 xorl %ebx, %ebx
925 movl %ebx, ECX(%edx)
926 movl %ebx, EDX(%edx)
927 movl %esi, ESI(%edx)
928 movl %edi, EDI(%edx)
929 movl %ebp, EBP(%edx)
930 movl %ebx, EAX(%edx)
931 movl $__USER_DS, DS(%edx)
932 movl $__USER_DS, ES(%edx)
933 movl %ebx, ORIG_EAX(%edx)
934 movl %ecx, EIP(%edx)
935 movl 12(%esp), %ecx
936 movl $__KERNEL_CS, CS(%edx)
937 movl %ebx, EFLAGS(%edx)
938 movl %eax, OLDESP(%edx)
939 movl 8(%esp), %eax
940 movl %ecx, 8(%esp)
941 movl EBX(%edx), %ebx
942 movl $__KERNEL_DS, OLDSS(%edx)
943 jmpl *%eax
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200944 CFI_ENDPROC
Jan Beulich176a2712006-06-26 13:57:41 +0200945ENDPROC(arch_unwind_init_running)
946#endif
947
Arjan van de Venbb152f52006-01-06 00:12:05 -0800948.section .rodata,"a"
Paolo 'Blaisorblade' Giarrusso5e7b83f2005-05-01 08:58:55 -0700949#include "syscall_table.S"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700950
951syscall_table_size=(.-sys_call_table)