blob: e8d2630fd19a201973b2df04efc8cc4e9b059cec [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*/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700273 pushl $SYSENTER_RETURN
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200274 CFI_ADJUST_CFA_OFFSET 4
275 CFI_REL_OFFSET eip, 0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700276
277/*
278 * Load the potential sixth argument from user stack.
279 * Careful about security.
280 */
281 cmpl $__PAGE_OFFSET-3,%ebp
282 jae syscall_fault
2831: movl (%ebp),%ebp
284.section __ex_table,"a"
285 .align 4
286 .long 1b,syscall_fault
287.previous
288
289 pushl %eax
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200290 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700291 SAVE_ALL
292 GET_THREAD_INFO(%ebp)
293
294 /* Note, _TIF_SECCOMP is bit number 8, and so it needs testw and not testb */
Laurent Viviered75e8d2005-09-03 15:57:18 -0700295 testw $(_TIF_SYSCALL_EMU|_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT),TI_flags(%ebp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700296 jnz syscall_trace_entry
297 cmpl $(nr_syscalls), %eax
298 jae syscall_badsys
299 call *sys_call_table(,%eax,4)
300 movl %eax,EAX(%esp)
301 cli
302 movl TI_flags(%ebp), %ecx
303 testw $_TIF_ALLWORK_MASK, %cx
304 jne syscall_exit_work
305/* if something modifies registers it must also disable sysexit */
306 movl EIP(%esp), %edx
307 movl OLDESP(%esp), %ecx
308 xorl %ebp,%ebp
309 sti
310 sysexit
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200311 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700312
313
314 # system call handler stub
315ENTRY(system_call)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200316 RING0_INT_FRAME # can't unwind into user space anyway
Linus Torvalds1da177e2005-04-16 15:20:36 -0700317 pushl %eax # save orig_eax
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200318 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700319 SAVE_ALL
320 GET_THREAD_INFO(%ebp)
Chuck Ebbert635cf992006-03-23 02:59:48 -0800321 testl $TF_MASK,EFLAGS(%esp)
322 jz no_singlestep
323 orl $_TIF_SINGLESTEP,TI_flags(%ebp)
324no_singlestep:
Laurent Viviered75e8d2005-09-03 15:57:18 -0700325 # system call tracing in operation / emulation
Linus Torvalds1da177e2005-04-16 15:20:36 -0700326 /* Note, _TIF_SECCOMP is bit number 8, and so it needs testw and not testb */
Laurent Viviered75e8d2005-09-03 15:57:18 -0700327 testw $(_TIF_SYSCALL_EMU|_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT),TI_flags(%ebp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700328 jnz syscall_trace_entry
329 cmpl $(nr_syscalls), %eax
330 jae syscall_badsys
331syscall_call:
332 call *sys_call_table(,%eax,4)
333 movl %eax,EAX(%esp) # store the return value
334syscall_exit:
335 cli # make sure we don't miss an interrupt
336 # setting need_resched or sigpending
337 # between sampling and the iret
338 movl TI_flags(%ebp), %ecx
339 testw $_TIF_ALLWORK_MASK, %cx # current->work
340 jne syscall_exit_work
341
342restore_all:
343 movl EFLAGS(%esp), %eax # mix EFLAGS, SS and CS
Stas Sergeev5df24082005-04-16 15:24:01 -0700344 # Warning: OLDSS(%esp) contains the wrong/random values if we
345 # are returning to the kernel.
346 # See comments in process.c:copy_thread() for details.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700347 movb OLDSS(%esp), %ah
348 movb CS(%esp), %al
349 andl $(VM_MASK | (4 << 8) | 3), %eax
350 cmpl $((4 << 8) | 3), %eax
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200351 CFI_REMEMBER_STATE
Linus Torvalds1da177e2005-04-16 15:20:36 -0700352 je ldt_ss # returning to user-space with LDT SS
353restore_nocheck:
354 RESTORE_REGS
355 addl $4, %esp
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200356 CFI_ADJUST_CFA_OFFSET -4
Linus Torvalds1da177e2005-04-16 15:20:36 -07003571: iret
358.section .fixup,"ax"
359iret_exc:
360 sti
Linus Torvaldsa879cbb2005-04-29 09:38:44 -0700361 pushl $0 # no error code
362 pushl $do_iret_error
363 jmp error_code
Linus Torvalds1da177e2005-04-16 15:20:36 -0700364.previous
365.section __ex_table,"a"
366 .align 4
367 .long 1b,iret_exc
368.previous
369
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200370 CFI_RESTORE_STATE
Linus Torvalds1da177e2005-04-16 15:20:36 -0700371ldt_ss:
372 larl OLDSS(%esp), %eax
373 jnz restore_nocheck
374 testl $0x00400000, %eax # returning to 32bit stack?
375 jnz restore_nocheck # allright, normal return
376 /* If returning to userspace with 16bit stack,
377 * try to fix the higher word of ESP, as the CPU
378 * won't restore it.
379 * This is an "official" bug of all the x86-compatible
380 * CPUs, which we can try to work around to make
381 * dosemu and wine happy. */
382 subl $8, %esp # reserve space for switch16 pointer
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200383 CFI_ADJUST_CFA_OFFSET 8
Linus Torvalds1da177e2005-04-16 15:20:36 -0700384 cli
385 movl %esp, %eax
386 /* Set up the 16bit stack frame with switch32 pointer on top,
387 * and a switch16 pointer on top of the current frame. */
388 call setup_x86_bogus_stack
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200389 CFI_ADJUST_CFA_OFFSET -8 # frame has moved
Linus Torvalds1da177e2005-04-16 15:20:36 -0700390 RESTORE_REGS
391 lss 20+4(%esp), %esp # switch to 16bit stack
3921: iret
393.section __ex_table,"a"
394 .align 4
395 .long 1b,iret_exc
396.previous
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200397 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700398
399 # perform work that needs to be done immediately before resumption
400 ALIGN
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200401 RING0_PTREGS_FRAME # can't unwind into user space anyway
Linus Torvalds1da177e2005-04-16 15:20:36 -0700402work_pending:
403 testb $_TIF_NEED_RESCHED, %cl
404 jz work_notifysig
405work_resched:
406 call schedule
407 cli # make sure we don't miss an interrupt
408 # setting need_resched or sigpending
409 # between sampling and the iret
410 movl TI_flags(%ebp), %ecx
411 andl $_TIF_WORK_MASK, %ecx # is there any work to be done other
412 # than syscall tracing?
413 jz restore_all
414 testb $_TIF_NEED_RESCHED, %cl
415 jnz work_resched
416
417work_notifysig: # deal with pending signals and
418 # notify-resume requests
419 testl $VM_MASK, EFLAGS(%esp)
420 movl %esp, %eax
421 jne work_notifysig_v86 # returning to kernel-space or
422 # vm86-space
423 xorl %edx, %edx
424 call do_notify_resume
Aleksey Gorelov4031ff32006-06-27 02:53:48 -0700425 jmp resume_userspace_sig
Linus Torvalds1da177e2005-04-16 15:20:36 -0700426
427 ALIGN
428work_notifysig_v86:
Matt Mackall64ca9002006-01-08 01:05:26 -0800429#ifdef CONFIG_VM86
Linus Torvalds1da177e2005-04-16 15:20:36 -0700430 pushl %ecx # save ti_flags for do_notify_resume
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200431 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700432 call save_v86_state # %eax contains pt_regs pointer
433 popl %ecx
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200434 CFI_ADJUST_CFA_OFFSET -4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700435 movl %eax, %esp
436 xorl %edx, %edx
437 call do_notify_resume
Aleksey Gorelov4031ff32006-06-27 02:53:48 -0700438 jmp resume_userspace_sig
Matt Mackall64ca9002006-01-08 01:05:26 -0800439#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700440
441 # perform syscall exit tracing
442 ALIGN
443syscall_trace_entry:
444 movl $-ENOSYS,EAX(%esp)
445 movl %esp, %eax
446 xorl %edx,%edx
447 call do_syscall_trace
Laurent Viviered75e8d2005-09-03 15:57:18 -0700448 cmpl $0, %eax
Paolo 'Blaisorblade' Giarrusso640aa462005-09-03 15:57:22 -0700449 jne resume_userspace # ret != 0 -> running under PTRACE_SYSEMU,
Laurent Viviered75e8d2005-09-03 15:57:18 -0700450 # so must skip actual syscall
Linus Torvalds1da177e2005-04-16 15:20:36 -0700451 movl ORIG_EAX(%esp), %eax
452 cmpl $(nr_syscalls), %eax
453 jnae syscall_call
454 jmp syscall_exit
455
456 # perform syscall exit tracing
457 ALIGN
458syscall_exit_work:
459 testb $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SINGLESTEP), %cl
460 jz work_pending
461 sti # could let do_syscall_trace() call
462 # schedule() instead
463 movl %esp, %eax
464 movl $1, %edx
465 call do_syscall_trace
466 jmp resume_userspace
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200467 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700468
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200469 RING0_INT_FRAME # can't unwind into user space anyway
Linus Torvalds1da177e2005-04-16 15:20:36 -0700470syscall_fault:
471 pushl %eax # save orig_eax
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200472 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700473 SAVE_ALL
474 GET_THREAD_INFO(%ebp)
475 movl $-EFAULT,EAX(%esp)
476 jmp resume_userspace
477
Linus Torvalds1da177e2005-04-16 15:20:36 -0700478syscall_badsys:
479 movl $-ENOSYS,EAX(%esp)
480 jmp resume_userspace
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200481 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700482
483#define FIXUP_ESPFIX_STACK \
484 movl %esp, %eax; \
485 /* switch to 32bit stack using the pointer on top of 16bit stack */ \
486 lss %ss:CPU_16BIT_STACK_SIZE-8, %esp; \
487 /* copy data from 16bit stack to 32bit stack */ \
488 call fixup_x86_bogus_stack; \
489 /* put ESP to the proper location */ \
490 movl %eax, %esp;
491#define UNWIND_ESPFIX_STACK \
492 pushl %eax; \
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200493 CFI_ADJUST_CFA_OFFSET 4; \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700494 movl %ss, %eax; \
495 /* see if on 16bit stack */ \
496 cmpw $__ESPFIX_SS, %ax; \
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200497 je 28f; \
49827: popl %eax; \
499 CFI_ADJUST_CFA_OFFSET -4; \
500.section .fixup,"ax"; \
50128: movl $__KERNEL_DS, %eax; \
502 movl %eax, %ds; \
503 movl %eax, %es; \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700504 /* switch to 32bit stack */ \
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200505 FIXUP_ESPFIX_STACK; \
506 jmp 27b; \
507.previous
Linus Torvalds1da177e2005-04-16 15:20:36 -0700508
509/*
510 * Build the entry stubs and pointer table with
511 * some assembler magic.
512 */
513.data
514ENTRY(interrupt)
515.text
516
517vector=0
518ENTRY(irq_entries_start)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200519 RING0_INT_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700520.rept NR_IRQS
521 ALIGN
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200522 .if vector
523 CFI_ADJUST_CFA_OFFSET -4
524 .endif
Rusty Russell19eadf92006-06-27 02:53:44 -07005251: pushl $~(vector)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200526 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700527 jmp common_interrupt
528.data
529 .long 1b
530.text
531vector=vector+1
532.endr
533
534 ALIGN
535common_interrupt:
536 SAVE_ALL
537 movl %esp,%eax
538 call do_IRQ
539 jmp ret_from_intr
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200540 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700541
542#define BUILD_INTERRUPT(name, nr) \
543ENTRY(name) \
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200544 RING0_INT_FRAME; \
Rusty Russell19eadf92006-06-27 02:53:44 -0700545 pushl $~(nr); \
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200546 CFI_ADJUST_CFA_OFFSET 4; \
547 SAVE_ALL; \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700548 movl %esp,%eax; \
549 call smp_/**/name; \
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200550 jmp ret_from_intr; \
551 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700552
553/* The include is where all of the SMP etc. interrupts come from */
554#include "entry_arch.h"
555
556ENTRY(divide_error)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200557 RING0_INT_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700558 pushl $0 # no error code
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200559 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700560 pushl $do_divide_error
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200561 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700562 ALIGN
563error_code:
564 pushl %ds
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200565 CFI_ADJUST_CFA_OFFSET 4
566 /*CFI_REL_OFFSET ds, 0*/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700567 pushl %eax
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200568 CFI_ADJUST_CFA_OFFSET 4
569 CFI_REL_OFFSET eax, 0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700570 xorl %eax, %eax
571 pushl %ebp
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200572 CFI_ADJUST_CFA_OFFSET 4
573 CFI_REL_OFFSET ebp, 0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700574 pushl %edi
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200575 CFI_ADJUST_CFA_OFFSET 4
576 CFI_REL_OFFSET edi, 0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700577 pushl %esi
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200578 CFI_ADJUST_CFA_OFFSET 4
579 CFI_REL_OFFSET esi, 0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700580 pushl %edx
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200581 CFI_ADJUST_CFA_OFFSET 4
582 CFI_REL_OFFSET edx, 0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700583 decl %eax # eax = -1
584 pushl %ecx
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200585 CFI_ADJUST_CFA_OFFSET 4
586 CFI_REL_OFFSET ecx, 0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700587 pushl %ebx
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200588 CFI_ADJUST_CFA_OFFSET 4
589 CFI_REL_OFFSET ebx, 0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700590 cld
591 pushl %es
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200592 CFI_ADJUST_CFA_OFFSET 4
593 /*CFI_REL_OFFSET es, 0*/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700594 UNWIND_ESPFIX_STACK
595 popl %ecx
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200596 CFI_ADJUST_CFA_OFFSET -4
597 /*CFI_REGISTER es, ecx*/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700598 movl ES(%esp), %edi # get the function address
599 movl ORIG_EAX(%esp), %edx # get the error code
600 movl %eax, ORIG_EAX(%esp)
601 movl %ecx, ES(%esp)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200602 /*CFI_REL_OFFSET es, ES*/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700603 movl $(__USER_DS), %ecx
604 movl %ecx, %ds
605 movl %ecx, %es
606 movl %esp,%eax # pt_regs pointer
607 call *%edi
608 jmp ret_from_exception
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200609 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700610
611ENTRY(coprocessor_error)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200612 RING0_INT_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700613 pushl $0
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200614 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700615 pushl $do_coprocessor_error
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200616 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700617 jmp error_code
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200618 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700619
620ENTRY(simd_coprocessor_error)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200621 RING0_INT_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700622 pushl $0
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200623 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700624 pushl $do_simd_coprocessor_error
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200625 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700626 jmp error_code
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200627 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700628
629ENTRY(device_not_available)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200630 RING0_INT_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700631 pushl $-1 # mark this as an int
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200632 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700633 SAVE_ALL
634 movl %cr0, %eax
635 testl $0x4, %eax # EM (math emulation bit)
636 jne device_not_available_emulate
637 preempt_stop
638 call math_state_restore
639 jmp ret_from_exception
640device_not_available_emulate:
641 pushl $0 # temporary storage for ORIG_EIP
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200642 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700643 call math_emulate
644 addl $4, %esp
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200645 CFI_ADJUST_CFA_OFFSET -4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700646 jmp ret_from_exception
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200647 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700648
649/*
650 * Debug traps and NMI can happen at the one SYSENTER instruction
651 * that sets up the real kernel stack. Check here, since we can't
652 * allow the wrong stack to be used.
653 *
654 * "TSS_sysenter_esp0+12" is because the NMI/debug handler will have
655 * already pushed 3 words if it hits on the sysenter instruction:
656 * eflags, cs and eip.
657 *
658 * We just load the right stack, and push the three (known) values
659 * by hand onto the new stack - while updating the return eip past
660 * the instruction that would have done it for sysenter.
661 */
662#define FIX_STACK(offset, ok, label) \
663 cmpw $__KERNEL_CS,4(%esp); \
664 jne ok; \
665label: \
666 movl TSS_sysenter_esp0+offset(%esp),%esp; \
667 pushfl; \
668 pushl $__KERNEL_CS; \
669 pushl $sysenter_past_esp
670
Prasanna S Panchamukhi3d97ae52005-09-06 15:19:27 -0700671KPROBE_ENTRY(debug)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200672 RING0_INT_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700673 cmpl $sysenter_entry,(%esp)
674 jne debug_stack_correct
675 FIX_STACK(12, debug_stack_correct, debug_esp_fix_insn)
676debug_stack_correct:
677 pushl $-1 # mark this as an int
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200678 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700679 SAVE_ALL
680 xorl %edx,%edx # error code 0
681 movl %esp,%eax # pt_regs pointer
682 call do_debug
Linus Torvalds1da177e2005-04-16 15:20:36 -0700683 jmp ret_from_exception
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200684 CFI_ENDPROC
Prasanna S Panchamukhi3d97ae52005-09-06 15:19:27 -0700685 .previous .text
Linus Torvalds1da177e2005-04-16 15:20:36 -0700686/*
687 * NMI is doubly nasty. It can happen _while_ we're handling
688 * a debug fault, and the debug fault hasn't yet been able to
689 * clear up the stack. So we first check whether we got an
690 * NMI on the sysenter entry path, but after that we need to
691 * check whether we got an NMI on the debug path where the debug
692 * fault happened on the sysenter path.
693 */
694ENTRY(nmi)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200695 RING0_INT_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700696 pushl %eax
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200697 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700698 movl %ss, %eax
699 cmpw $__ESPFIX_SS, %ax
700 popl %eax
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200701 CFI_ADJUST_CFA_OFFSET -4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700702 je nmi_16bit_stack
703 cmpl $sysenter_entry,(%esp)
704 je nmi_stack_fixup
705 pushl %eax
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200706 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700707 movl %esp,%eax
708 /* Do not access memory above the end of our stack page,
709 * it might not exist.
710 */
711 andl $(THREAD_SIZE-1),%eax
712 cmpl $(THREAD_SIZE-20),%eax
713 popl %eax
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200714 CFI_ADJUST_CFA_OFFSET -4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700715 jae nmi_stack_correct
716 cmpl $sysenter_entry,12(%esp)
717 je nmi_debug_stack_check
718nmi_stack_correct:
719 pushl %eax
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200720 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700721 SAVE_ALL
722 xorl %edx,%edx # zero error code
723 movl %esp,%eax # pt_regs pointer
724 call do_nmi
725 jmp restore_all
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200726 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700727
728nmi_stack_fixup:
729 FIX_STACK(12,nmi_stack_correct, 1)
730 jmp nmi_stack_correct
731nmi_debug_stack_check:
732 cmpw $__KERNEL_CS,16(%esp)
733 jne nmi_stack_correct
Jan Beuliche2718202005-11-13 16:06:52 -0800734 cmpl $debug,(%esp)
735 jb nmi_stack_correct
Linus Torvalds1da177e2005-04-16 15:20:36 -0700736 cmpl $debug_esp_fix_insn,(%esp)
Jan Beuliche2718202005-11-13 16:06:52 -0800737 ja nmi_stack_correct
Linus Torvalds1da177e2005-04-16 15:20:36 -0700738 FIX_STACK(24,nmi_stack_correct, 1)
739 jmp nmi_stack_correct
740
741nmi_16bit_stack:
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200742 RING0_INT_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700743 /* create the pointer to lss back */
744 pushl %ss
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200745 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700746 pushl %esp
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200747 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700748 movzwl %sp, %esp
749 addw $4, (%esp)
750 /* copy the iret frame of 12 bytes */
751 .rept 3
752 pushl 16(%esp)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200753 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700754 .endr
755 pushl %eax
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200756 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700757 SAVE_ALL
758 FIXUP_ESPFIX_STACK # %eax == %esp
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200759 CFI_ADJUST_CFA_OFFSET -20 # the frame has now moved
Linus Torvalds1da177e2005-04-16 15:20:36 -0700760 xorl %edx,%edx # zero error code
761 call do_nmi
762 RESTORE_REGS
763 lss 12+4(%esp), %esp # back to 16bit stack
7641: iret
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200765 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700766.section __ex_table,"a"
767 .align 4
768 .long 1b,iret_exc
769.previous
770
Prasanna S Panchamukhi3d97ae52005-09-06 15:19:27 -0700771KPROBE_ENTRY(int3)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200772 RING0_INT_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700773 pushl $-1 # mark this as an int
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200774 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700775 SAVE_ALL
776 xorl %edx,%edx # zero error code
777 movl %esp,%eax # pt_regs pointer
778 call do_int3
Linus Torvalds1da177e2005-04-16 15:20:36 -0700779 jmp ret_from_exception
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200780 CFI_ENDPROC
Prasanna S Panchamukhi3d97ae52005-09-06 15:19:27 -0700781 .previous .text
Linus Torvalds1da177e2005-04-16 15:20:36 -0700782
783ENTRY(overflow)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200784 RING0_INT_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700785 pushl $0
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200786 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700787 pushl $do_overflow
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200788 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700789 jmp error_code
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200790 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700791
792ENTRY(bounds)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200793 RING0_INT_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700794 pushl $0
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200795 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700796 pushl $do_bounds
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200797 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700798 jmp error_code
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200799 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700800
801ENTRY(invalid_op)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200802 RING0_INT_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700803 pushl $0
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200804 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700805 pushl $do_invalid_op
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200806 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700807 jmp error_code
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200808 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700809
810ENTRY(coprocessor_segment_overrun)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200811 RING0_INT_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700812 pushl $0
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200813 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700814 pushl $do_coprocessor_segment_overrun
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200815 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700816 jmp error_code
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200817 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700818
819ENTRY(invalid_TSS)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200820 RING0_EC_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700821 pushl $do_invalid_TSS
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(segment_not_present)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200827 RING0_EC_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700828 pushl $do_segment_not_present
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200829 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700830 jmp error_code
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200831 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700832
833ENTRY(stack_segment)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200834 RING0_EC_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700835 pushl $do_stack_segment
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200836 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700837 jmp error_code
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200838 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700839
Prasanna S Panchamukhi3d97ae52005-09-06 15:19:27 -0700840KPROBE_ENTRY(general_protection)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200841 RING0_EC_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700842 pushl $do_general_protection
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200843 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700844 jmp error_code
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200845 CFI_ENDPROC
Prasanna S Panchamukhi3d97ae52005-09-06 15:19:27 -0700846 .previous .text
Linus Torvalds1da177e2005-04-16 15:20:36 -0700847
848ENTRY(alignment_check)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200849 RING0_EC_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700850 pushl $do_alignment_check
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200851 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700852 jmp error_code
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200853 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700854
Prasanna S Panchamukhi3d97ae52005-09-06 15:19:27 -0700855KPROBE_ENTRY(page_fault)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200856 RING0_EC_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700857 pushl $do_page_fault
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200858 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700859 jmp error_code
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200860 CFI_ENDPROC
Prasanna S Panchamukhi3d97ae52005-09-06 15:19:27 -0700861 .previous .text
Linus Torvalds1da177e2005-04-16 15:20:36 -0700862
863#ifdef CONFIG_X86_MCE
864ENTRY(machine_check)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200865 RING0_INT_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700866 pushl $0
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200867 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700868 pushl machine_check_vector
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200869 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700870 jmp error_code
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200871 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700872#endif
873
874ENTRY(spurious_interrupt_bug)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200875 RING0_INT_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700876 pushl $0
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200877 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700878 pushl $do_spurious_interrupt_bug
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200879 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700880 jmp error_code
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200881 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700882
Jan Beulich176a2712006-06-26 13:57:41 +0200883#ifdef CONFIG_STACK_UNWIND
884ENTRY(arch_unwind_init_running)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200885 CFI_STARTPROC
Jan Beulich176a2712006-06-26 13:57:41 +0200886 movl 4(%esp), %edx
887 movl (%esp), %ecx
888 leal 4(%esp), %eax
889 movl %ebx, EBX(%edx)
890 xorl %ebx, %ebx
891 movl %ebx, ECX(%edx)
892 movl %ebx, EDX(%edx)
893 movl %esi, ESI(%edx)
894 movl %edi, EDI(%edx)
895 movl %ebp, EBP(%edx)
896 movl %ebx, EAX(%edx)
897 movl $__USER_DS, DS(%edx)
898 movl $__USER_DS, ES(%edx)
899 movl %ebx, ORIG_EAX(%edx)
900 movl %ecx, EIP(%edx)
901 movl 12(%esp), %ecx
902 movl $__KERNEL_CS, CS(%edx)
903 movl %ebx, EFLAGS(%edx)
904 movl %eax, OLDESP(%edx)
905 movl 8(%esp), %eax
906 movl %ecx, 8(%esp)
907 movl EBX(%edx), %ebx
908 movl $__KERNEL_DS, OLDSS(%edx)
909 jmpl *%eax
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200910 CFI_ENDPROC
Jan Beulich176a2712006-06-26 13:57:41 +0200911ENDPROC(arch_unwind_init_running)
912#endif
913
Arjan van de Venbb152f52006-01-06 00:12:05 -0800914.section .rodata,"a"
Paolo 'Blaisorblade' Giarrusso5e7b83f2005-05-01 08:58:55 -0700915#include "syscall_table.S"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700916
917syscall_table_size=(.-sys_call_table)