blob: e6e4506e749acbe079f9196fab1a05a6e333a753 [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
86#define SAVE_ALL \
87 cld; \
88 pushl %es; \
Jan Beulichfe7cacc2006-06-26 13:57:44 +020089 CFI_ADJUST_CFA_OFFSET 4;\
90 /*CFI_REL_OFFSET es, 0;*/\
Linus Torvalds1da177e2005-04-16 15:20:36 -070091 pushl %ds; \
Jan Beulichfe7cacc2006-06-26 13:57:44 +020092 CFI_ADJUST_CFA_OFFSET 4;\
93 /*CFI_REL_OFFSET ds, 0;*/\
Linus Torvalds1da177e2005-04-16 15:20:36 -070094 pushl %eax; \
Jan Beulichfe7cacc2006-06-26 13:57:44 +020095 CFI_ADJUST_CFA_OFFSET 4;\
96 CFI_REL_OFFSET eax, 0;\
Linus Torvalds1da177e2005-04-16 15:20:36 -070097 pushl %ebp; \
Jan Beulichfe7cacc2006-06-26 13:57:44 +020098 CFI_ADJUST_CFA_OFFSET 4;\
99 CFI_REL_OFFSET ebp, 0;\
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100 pushl %edi; \
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200101 CFI_ADJUST_CFA_OFFSET 4;\
102 CFI_REL_OFFSET edi, 0;\
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103 pushl %esi; \
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200104 CFI_ADJUST_CFA_OFFSET 4;\
105 CFI_REL_OFFSET esi, 0;\
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106 pushl %edx; \
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200107 CFI_ADJUST_CFA_OFFSET 4;\
108 CFI_REL_OFFSET edx, 0;\
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109 pushl %ecx; \
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200110 CFI_ADJUST_CFA_OFFSET 4;\
111 CFI_REL_OFFSET ecx, 0;\
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112 pushl %ebx; \
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200113 CFI_ADJUST_CFA_OFFSET 4;\
114 CFI_REL_OFFSET ebx, 0;\
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115 movl $(__USER_DS), %edx; \
116 movl %edx, %ds; \
117 movl %edx, %es;
118
119#define RESTORE_INT_REGS \
120 popl %ebx; \
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200121 CFI_ADJUST_CFA_OFFSET -4;\
122 CFI_RESTORE ebx;\
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123 popl %ecx; \
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200124 CFI_ADJUST_CFA_OFFSET -4;\
125 CFI_RESTORE ecx;\
Linus Torvalds1da177e2005-04-16 15:20:36 -0700126 popl %edx; \
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200127 CFI_ADJUST_CFA_OFFSET -4;\
128 CFI_RESTORE edx;\
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129 popl %esi; \
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200130 CFI_ADJUST_CFA_OFFSET -4;\
131 CFI_RESTORE esi;\
Linus Torvalds1da177e2005-04-16 15:20:36 -0700132 popl %edi; \
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200133 CFI_ADJUST_CFA_OFFSET -4;\
134 CFI_RESTORE edi;\
Linus Torvalds1da177e2005-04-16 15:20:36 -0700135 popl %ebp; \
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200136 CFI_ADJUST_CFA_OFFSET -4;\
137 CFI_RESTORE ebp;\
138 popl %eax; \
139 CFI_ADJUST_CFA_OFFSET -4;\
140 CFI_RESTORE eax
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141
142#define RESTORE_REGS \
143 RESTORE_INT_REGS; \
1441: popl %ds; \
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200145 CFI_ADJUST_CFA_OFFSET -4;\
146 /*CFI_RESTORE ds;*/\
Linus Torvalds1da177e2005-04-16 15:20:36 -07001472: popl %es; \
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200148 CFI_ADJUST_CFA_OFFSET -4;\
149 /*CFI_RESTORE es;*/\
Linus Torvalds1da177e2005-04-16 15:20:36 -0700150.section .fixup,"ax"; \
1513: movl $0,(%esp); \
152 jmp 1b; \
1534: movl $0,(%esp); \
154 jmp 2b; \
155.previous; \
156.section __ex_table,"a";\
157 .align 4; \
158 .long 1b,3b; \
159 .long 2b,4b; \
160.previous
161
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200162#define RING0_INT_FRAME \
163 CFI_STARTPROC simple;\
164 CFI_DEF_CFA esp, 3*4;\
165 /*CFI_OFFSET cs, -2*4;*/\
166 CFI_OFFSET eip, -3*4
167
168#define RING0_EC_FRAME \
169 CFI_STARTPROC simple;\
170 CFI_DEF_CFA esp, 4*4;\
171 /*CFI_OFFSET cs, -2*4;*/\
172 CFI_OFFSET eip, -3*4
173
174#define RING0_PTREGS_FRAME \
175 CFI_STARTPROC simple;\
176 CFI_DEF_CFA esp, OLDESP-EBX;\
177 /*CFI_OFFSET cs, CS-OLDESP;*/\
178 CFI_OFFSET eip, EIP-OLDESP;\
179 /*CFI_OFFSET es, ES-OLDESP;*/\
180 /*CFI_OFFSET ds, DS-OLDESP;*/\
181 CFI_OFFSET eax, EAX-OLDESP;\
182 CFI_OFFSET ebp, EBP-OLDESP;\
183 CFI_OFFSET edi, EDI-OLDESP;\
184 CFI_OFFSET esi, ESI-OLDESP;\
185 CFI_OFFSET edx, EDX-OLDESP;\
186 CFI_OFFSET ecx, ECX-OLDESP;\
187 CFI_OFFSET ebx, EBX-OLDESP
Linus Torvalds1da177e2005-04-16 15:20:36 -0700188
189ENTRY(ret_from_fork)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200190 CFI_STARTPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700191 pushl %eax
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200192 CFI_ADJUST_CFA_OFFSET -4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700193 call schedule_tail
194 GET_THREAD_INFO(%ebp)
195 popl %eax
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200196 CFI_ADJUST_CFA_OFFSET -4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700197 jmp syscall_exit
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200198 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700199
200/*
201 * Return to user mode is not as complex as all this looks,
202 * but we want the default path for a system call return to
203 * go as quickly as possible which is why some of this is
204 * less clear than it otherwise should be.
205 */
206
207 # userspace resumption stub bypassing syscall exit tracing
208 ALIGN
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200209 RING0_PTREGS_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700210ret_from_exception:
211 preempt_stop
212ret_from_intr:
213 GET_THREAD_INFO(%ebp)
214 movl EFLAGS(%esp), %eax # mix EFLAGS and CS
215 movb CS(%esp), %al
216 testl $(VM_MASK | 3), %eax
217 jz resume_kernel
218ENTRY(resume_userspace)
219 cli # make sure we don't miss an interrupt
220 # setting need_resched or sigpending
221 # between sampling and the iret
222 movl TI_flags(%ebp), %ecx
223 andl $_TIF_WORK_MASK, %ecx # is there any work to be done on
224 # int/exception return?
225 jne work_pending
226 jmp restore_all
227
228#ifdef CONFIG_PREEMPT
229ENTRY(resume_kernel)
230 cli
231 cmpl $0,TI_preempt_count(%ebp) # non-zero preempt_count ?
232 jnz restore_nocheck
233need_resched:
234 movl TI_flags(%ebp), %ecx # need_resched set ?
235 testb $_TIF_NEED_RESCHED, %cl
236 jz restore_all
237 testl $IF_MASK,EFLAGS(%esp) # interrupts off (exception path) ?
238 jz restore_all
239 call preempt_schedule_irq
240 jmp need_resched
241#endif
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200242 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700243
244/* SYSENTER_RETURN points to after the "sysenter" instruction in
245 the vsyscall page. See vsyscall-sysentry.S, which defines the symbol. */
246
247 # sysenter call handler stub
248ENTRY(sysenter_entry)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200249 CFI_STARTPROC simple
250 CFI_DEF_CFA esp, 0
251 CFI_REGISTER esp, ebp
Linus Torvalds1da177e2005-04-16 15:20:36 -0700252 movl TSS_sysenter_esp0(%esp),%esp
253sysenter_past_esp:
254 sti
255 pushl $(__USER_DS)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200256 CFI_ADJUST_CFA_OFFSET 4
257 /*CFI_REL_OFFSET ss, 0*/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700258 pushl %ebp
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200259 CFI_ADJUST_CFA_OFFSET 4
260 CFI_REL_OFFSET esp, 0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700261 pushfl
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200262 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700263 pushl $(__USER_CS)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200264 CFI_ADJUST_CFA_OFFSET 4
265 /*CFI_REL_OFFSET cs, 0*/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700266 pushl $SYSENTER_RETURN
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200267 CFI_ADJUST_CFA_OFFSET 4
268 CFI_REL_OFFSET eip, 0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700269
270/*
271 * Load the potential sixth argument from user stack.
272 * Careful about security.
273 */
274 cmpl $__PAGE_OFFSET-3,%ebp
275 jae syscall_fault
2761: movl (%ebp),%ebp
277.section __ex_table,"a"
278 .align 4
279 .long 1b,syscall_fault
280.previous
281
282 pushl %eax
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200283 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700284 SAVE_ALL
285 GET_THREAD_INFO(%ebp)
286
287 /* Note, _TIF_SECCOMP is bit number 8, and so it needs testw and not testb */
Laurent Viviered75e8d2005-09-03 15:57:18 -0700288 testw $(_TIF_SYSCALL_EMU|_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT),TI_flags(%ebp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700289 jnz syscall_trace_entry
290 cmpl $(nr_syscalls), %eax
291 jae syscall_badsys
292 call *sys_call_table(,%eax,4)
293 movl %eax,EAX(%esp)
294 cli
295 movl TI_flags(%ebp), %ecx
296 testw $_TIF_ALLWORK_MASK, %cx
297 jne syscall_exit_work
298/* if something modifies registers it must also disable sysexit */
299 movl EIP(%esp), %edx
300 movl OLDESP(%esp), %ecx
301 xorl %ebp,%ebp
302 sti
303 sysexit
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200304 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700305
306
307 # system call handler stub
308ENTRY(system_call)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200309 RING0_INT_FRAME # can't unwind into user space anyway
Linus Torvalds1da177e2005-04-16 15:20:36 -0700310 pushl %eax # save orig_eax
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200311 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700312 SAVE_ALL
313 GET_THREAD_INFO(%ebp)
Chuck Ebbert635cf992006-03-23 02:59:48 -0800314 testl $TF_MASK,EFLAGS(%esp)
315 jz no_singlestep
316 orl $_TIF_SINGLESTEP,TI_flags(%ebp)
317no_singlestep:
Laurent Viviered75e8d2005-09-03 15:57:18 -0700318 # system call tracing in operation / emulation
Linus Torvalds1da177e2005-04-16 15:20:36 -0700319 /* Note, _TIF_SECCOMP is bit number 8, and so it needs testw and not testb */
Laurent Viviered75e8d2005-09-03 15:57:18 -0700320 testw $(_TIF_SYSCALL_EMU|_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT),TI_flags(%ebp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700321 jnz syscall_trace_entry
322 cmpl $(nr_syscalls), %eax
323 jae syscall_badsys
324syscall_call:
325 call *sys_call_table(,%eax,4)
326 movl %eax,EAX(%esp) # store the return value
327syscall_exit:
328 cli # make sure we don't miss an interrupt
329 # setting need_resched or sigpending
330 # between sampling and the iret
331 movl TI_flags(%ebp), %ecx
332 testw $_TIF_ALLWORK_MASK, %cx # current->work
333 jne syscall_exit_work
334
335restore_all:
336 movl EFLAGS(%esp), %eax # mix EFLAGS, SS and CS
Stas Sergeev5df24082005-04-16 15:24:01 -0700337 # Warning: OLDSS(%esp) contains the wrong/random values if we
338 # are returning to the kernel.
339 # See comments in process.c:copy_thread() for details.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700340 movb OLDSS(%esp), %ah
341 movb CS(%esp), %al
342 andl $(VM_MASK | (4 << 8) | 3), %eax
343 cmpl $((4 << 8) | 3), %eax
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200344 CFI_REMEMBER_STATE
Linus Torvalds1da177e2005-04-16 15:20:36 -0700345 je ldt_ss # returning to user-space with LDT SS
346restore_nocheck:
347 RESTORE_REGS
348 addl $4, %esp
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200349 CFI_ADJUST_CFA_OFFSET -4
Linus Torvalds1da177e2005-04-16 15:20:36 -07003501: iret
351.section .fixup,"ax"
352iret_exc:
353 sti
Linus Torvaldsa879cbb2005-04-29 09:38:44 -0700354 pushl $0 # no error code
355 pushl $do_iret_error
356 jmp error_code
Linus Torvalds1da177e2005-04-16 15:20:36 -0700357.previous
358.section __ex_table,"a"
359 .align 4
360 .long 1b,iret_exc
361.previous
362
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200363 CFI_RESTORE_STATE
Linus Torvalds1da177e2005-04-16 15:20:36 -0700364ldt_ss:
365 larl OLDSS(%esp), %eax
366 jnz restore_nocheck
367 testl $0x00400000, %eax # returning to 32bit stack?
368 jnz restore_nocheck # allright, normal return
369 /* If returning to userspace with 16bit stack,
370 * try to fix the higher word of ESP, as the CPU
371 * won't restore it.
372 * This is an "official" bug of all the x86-compatible
373 * CPUs, which we can try to work around to make
374 * dosemu and wine happy. */
375 subl $8, %esp # reserve space for switch16 pointer
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200376 CFI_ADJUST_CFA_OFFSET 8
Linus Torvalds1da177e2005-04-16 15:20:36 -0700377 cli
378 movl %esp, %eax
379 /* Set up the 16bit stack frame with switch32 pointer on top,
380 * and a switch16 pointer on top of the current frame. */
381 call setup_x86_bogus_stack
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200382 CFI_ADJUST_CFA_OFFSET -8 # frame has moved
Linus Torvalds1da177e2005-04-16 15:20:36 -0700383 RESTORE_REGS
384 lss 20+4(%esp), %esp # switch to 16bit stack
3851: iret
386.section __ex_table,"a"
387 .align 4
388 .long 1b,iret_exc
389.previous
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200390 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700391
392 # perform work that needs to be done immediately before resumption
393 ALIGN
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200394 RING0_PTREGS_FRAME # can't unwind into user space anyway
Linus Torvalds1da177e2005-04-16 15:20:36 -0700395work_pending:
396 testb $_TIF_NEED_RESCHED, %cl
397 jz work_notifysig
398work_resched:
399 call schedule
400 cli # make sure we don't miss an interrupt
401 # setting need_resched or sigpending
402 # between sampling and the iret
403 movl TI_flags(%ebp), %ecx
404 andl $_TIF_WORK_MASK, %ecx # is there any work to be done other
405 # than syscall tracing?
406 jz restore_all
407 testb $_TIF_NEED_RESCHED, %cl
408 jnz work_resched
409
410work_notifysig: # deal with pending signals and
411 # notify-resume requests
412 testl $VM_MASK, EFLAGS(%esp)
413 movl %esp, %eax
414 jne work_notifysig_v86 # returning to kernel-space or
415 # vm86-space
416 xorl %edx, %edx
417 call do_notify_resume
Roland McGrathc3ff8ec2005-09-11 01:44:45 -0700418 jmp resume_userspace
Linus Torvalds1da177e2005-04-16 15:20:36 -0700419
420 ALIGN
421work_notifysig_v86:
Matt Mackall64ca9002006-01-08 01:05:26 -0800422#ifdef CONFIG_VM86
Linus Torvalds1da177e2005-04-16 15:20:36 -0700423 pushl %ecx # save ti_flags for do_notify_resume
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200424 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700425 call save_v86_state # %eax contains pt_regs pointer
426 popl %ecx
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200427 CFI_ADJUST_CFA_OFFSET -4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700428 movl %eax, %esp
429 xorl %edx, %edx
430 call do_notify_resume
Roland McGrathc3ff8ec2005-09-11 01:44:45 -0700431 jmp resume_userspace
Matt Mackall64ca9002006-01-08 01:05:26 -0800432#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700433
434 # perform syscall exit tracing
435 ALIGN
436syscall_trace_entry:
437 movl $-ENOSYS,EAX(%esp)
438 movl %esp, %eax
439 xorl %edx,%edx
440 call do_syscall_trace
Laurent Viviered75e8d2005-09-03 15:57:18 -0700441 cmpl $0, %eax
Paolo 'Blaisorblade' Giarrusso640aa462005-09-03 15:57:22 -0700442 jne resume_userspace # ret != 0 -> running under PTRACE_SYSEMU,
Laurent Viviered75e8d2005-09-03 15:57:18 -0700443 # so must skip actual syscall
Linus Torvalds1da177e2005-04-16 15:20:36 -0700444 movl ORIG_EAX(%esp), %eax
445 cmpl $(nr_syscalls), %eax
446 jnae syscall_call
447 jmp syscall_exit
448
449 # perform syscall exit tracing
450 ALIGN
451syscall_exit_work:
452 testb $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SINGLESTEP), %cl
453 jz work_pending
454 sti # could let do_syscall_trace() call
455 # schedule() instead
456 movl %esp, %eax
457 movl $1, %edx
458 call do_syscall_trace
459 jmp resume_userspace
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200460 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700461
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200462 RING0_INT_FRAME # can't unwind into user space anyway
Linus Torvalds1da177e2005-04-16 15:20:36 -0700463syscall_fault:
464 pushl %eax # save orig_eax
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200465 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700466 SAVE_ALL
467 GET_THREAD_INFO(%ebp)
468 movl $-EFAULT,EAX(%esp)
469 jmp resume_userspace
470
Linus Torvalds1da177e2005-04-16 15:20:36 -0700471syscall_badsys:
472 movl $-ENOSYS,EAX(%esp)
473 jmp resume_userspace
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200474 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700475
476#define FIXUP_ESPFIX_STACK \
477 movl %esp, %eax; \
478 /* switch to 32bit stack using the pointer on top of 16bit stack */ \
479 lss %ss:CPU_16BIT_STACK_SIZE-8, %esp; \
480 /* copy data from 16bit stack to 32bit stack */ \
481 call fixup_x86_bogus_stack; \
482 /* put ESP to the proper location */ \
483 movl %eax, %esp;
484#define UNWIND_ESPFIX_STACK \
485 pushl %eax; \
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200486 CFI_ADJUST_CFA_OFFSET 4; \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700487 movl %ss, %eax; \
488 /* see if on 16bit stack */ \
489 cmpw $__ESPFIX_SS, %ax; \
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200490 je 28f; \
49127: popl %eax; \
492 CFI_ADJUST_CFA_OFFSET -4; \
493.section .fixup,"ax"; \
49428: movl $__KERNEL_DS, %eax; \
495 movl %eax, %ds; \
496 movl %eax, %es; \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700497 /* switch to 32bit stack */ \
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200498 FIXUP_ESPFIX_STACK; \
499 jmp 27b; \
500.previous
Linus Torvalds1da177e2005-04-16 15:20:36 -0700501
502/*
503 * Build the entry stubs and pointer table with
504 * some assembler magic.
505 */
506.data
507ENTRY(interrupt)
508.text
509
510vector=0
511ENTRY(irq_entries_start)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200512 RING0_INT_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700513.rept NR_IRQS
514 ALIGN
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200515 .if vector
516 CFI_ADJUST_CFA_OFFSET -4
517 .endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07005181: pushl $vector-256
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200519 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700520 jmp common_interrupt
521.data
522 .long 1b
523.text
524vector=vector+1
525.endr
526
527 ALIGN
528common_interrupt:
529 SAVE_ALL
530 movl %esp,%eax
531 call do_IRQ
532 jmp ret_from_intr
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200533 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700534
535#define BUILD_INTERRUPT(name, nr) \
536ENTRY(name) \
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200537 RING0_INT_FRAME; \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700538 pushl $nr-256; \
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200539 CFI_ADJUST_CFA_OFFSET 4; \
540 SAVE_ALL; \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700541 movl %esp,%eax; \
542 call smp_/**/name; \
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200543 jmp ret_from_intr; \
544 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700545
546/* The include is where all of the SMP etc. interrupts come from */
547#include "entry_arch.h"
548
549ENTRY(divide_error)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200550 RING0_INT_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700551 pushl $0 # no error code
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200552 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700553 pushl $do_divide_error
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200554 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700555 ALIGN
556error_code:
557 pushl %ds
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200558 CFI_ADJUST_CFA_OFFSET 4
559 /*CFI_REL_OFFSET ds, 0*/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700560 pushl %eax
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200561 CFI_ADJUST_CFA_OFFSET 4
562 CFI_REL_OFFSET eax, 0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700563 xorl %eax, %eax
564 pushl %ebp
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200565 CFI_ADJUST_CFA_OFFSET 4
566 CFI_REL_OFFSET ebp, 0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700567 pushl %edi
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200568 CFI_ADJUST_CFA_OFFSET 4
569 CFI_REL_OFFSET edi, 0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700570 pushl %esi
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200571 CFI_ADJUST_CFA_OFFSET 4
572 CFI_REL_OFFSET esi, 0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700573 pushl %edx
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200574 CFI_ADJUST_CFA_OFFSET 4
575 CFI_REL_OFFSET edx, 0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700576 decl %eax # eax = -1
577 pushl %ecx
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200578 CFI_ADJUST_CFA_OFFSET 4
579 CFI_REL_OFFSET ecx, 0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700580 pushl %ebx
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200581 CFI_ADJUST_CFA_OFFSET 4
582 CFI_REL_OFFSET ebx, 0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700583 cld
584 pushl %es
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200585 CFI_ADJUST_CFA_OFFSET 4
586 /*CFI_REL_OFFSET es, 0*/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700587 UNWIND_ESPFIX_STACK
588 popl %ecx
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200589 CFI_ADJUST_CFA_OFFSET -4
590 /*CFI_REGISTER es, ecx*/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700591 movl ES(%esp), %edi # get the function address
592 movl ORIG_EAX(%esp), %edx # get the error code
593 movl %eax, ORIG_EAX(%esp)
594 movl %ecx, ES(%esp)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200595 /*CFI_REL_OFFSET es, ES*/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700596 movl $(__USER_DS), %ecx
597 movl %ecx, %ds
598 movl %ecx, %es
599 movl %esp,%eax # pt_regs pointer
600 call *%edi
601 jmp ret_from_exception
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200602 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700603
604ENTRY(coprocessor_error)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200605 RING0_INT_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700606 pushl $0
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200607 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700608 pushl $do_coprocessor_error
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200609 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700610 jmp error_code
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200611 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700612
613ENTRY(simd_coprocessor_error)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200614 RING0_INT_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700615 pushl $0
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200616 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700617 pushl $do_simd_coprocessor_error
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200618 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700619 jmp error_code
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200620 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700621
622ENTRY(device_not_available)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200623 RING0_INT_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700624 pushl $-1 # mark this as an int
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200625 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700626 SAVE_ALL
627 movl %cr0, %eax
628 testl $0x4, %eax # EM (math emulation bit)
629 jne device_not_available_emulate
630 preempt_stop
631 call math_state_restore
632 jmp ret_from_exception
633device_not_available_emulate:
634 pushl $0 # temporary storage for ORIG_EIP
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200635 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700636 call math_emulate
637 addl $4, %esp
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200638 CFI_ADJUST_CFA_OFFSET -4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700639 jmp ret_from_exception
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200640 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700641
642/*
643 * Debug traps and NMI can happen at the one SYSENTER instruction
644 * that sets up the real kernel stack. Check here, since we can't
645 * allow the wrong stack to be used.
646 *
647 * "TSS_sysenter_esp0+12" is because the NMI/debug handler will have
648 * already pushed 3 words if it hits on the sysenter instruction:
649 * eflags, cs and eip.
650 *
651 * We just load the right stack, and push the three (known) values
652 * by hand onto the new stack - while updating the return eip past
653 * the instruction that would have done it for sysenter.
654 */
655#define FIX_STACK(offset, ok, label) \
656 cmpw $__KERNEL_CS,4(%esp); \
657 jne ok; \
658label: \
659 movl TSS_sysenter_esp0+offset(%esp),%esp; \
660 pushfl; \
661 pushl $__KERNEL_CS; \
662 pushl $sysenter_past_esp
663
Prasanna S Panchamukhi3d97ae52005-09-06 15:19:27 -0700664KPROBE_ENTRY(debug)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200665 RING0_INT_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700666 cmpl $sysenter_entry,(%esp)
667 jne debug_stack_correct
668 FIX_STACK(12, debug_stack_correct, debug_esp_fix_insn)
669debug_stack_correct:
670 pushl $-1 # mark this as an int
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200671 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700672 SAVE_ALL
673 xorl %edx,%edx # error code 0
674 movl %esp,%eax # pt_regs pointer
675 call do_debug
Linus Torvalds1da177e2005-04-16 15:20:36 -0700676 jmp ret_from_exception
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200677 CFI_ENDPROC
Prasanna S Panchamukhi3d97ae52005-09-06 15:19:27 -0700678 .previous .text
Linus Torvalds1da177e2005-04-16 15:20:36 -0700679/*
680 * NMI is doubly nasty. It can happen _while_ we're handling
681 * a debug fault, and the debug fault hasn't yet been able to
682 * clear up the stack. So we first check whether we got an
683 * NMI on the sysenter entry path, but after that we need to
684 * check whether we got an NMI on the debug path where the debug
685 * fault happened on the sysenter path.
686 */
687ENTRY(nmi)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200688 RING0_INT_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700689 pushl %eax
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200690 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700691 movl %ss, %eax
692 cmpw $__ESPFIX_SS, %ax
693 popl %eax
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200694 CFI_ADJUST_CFA_OFFSET -4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700695 je nmi_16bit_stack
696 cmpl $sysenter_entry,(%esp)
697 je nmi_stack_fixup
698 pushl %eax
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200699 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700700 movl %esp,%eax
701 /* Do not access memory above the end of our stack page,
702 * it might not exist.
703 */
704 andl $(THREAD_SIZE-1),%eax
705 cmpl $(THREAD_SIZE-20),%eax
706 popl %eax
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200707 CFI_ADJUST_CFA_OFFSET -4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700708 jae nmi_stack_correct
709 cmpl $sysenter_entry,12(%esp)
710 je nmi_debug_stack_check
711nmi_stack_correct:
712 pushl %eax
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200713 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700714 SAVE_ALL
715 xorl %edx,%edx # zero error code
716 movl %esp,%eax # pt_regs pointer
717 call do_nmi
718 jmp restore_all
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200719 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700720
721nmi_stack_fixup:
722 FIX_STACK(12,nmi_stack_correct, 1)
723 jmp nmi_stack_correct
724nmi_debug_stack_check:
725 cmpw $__KERNEL_CS,16(%esp)
726 jne nmi_stack_correct
Jan Beuliche2718202005-11-13 16:06:52 -0800727 cmpl $debug,(%esp)
728 jb nmi_stack_correct
Linus Torvalds1da177e2005-04-16 15:20:36 -0700729 cmpl $debug_esp_fix_insn,(%esp)
Jan Beuliche2718202005-11-13 16:06:52 -0800730 ja nmi_stack_correct
Linus Torvalds1da177e2005-04-16 15:20:36 -0700731 FIX_STACK(24,nmi_stack_correct, 1)
732 jmp nmi_stack_correct
733
734nmi_16bit_stack:
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200735 RING0_INT_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700736 /* create the pointer to lss back */
737 pushl %ss
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200738 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700739 pushl %esp
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200740 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700741 movzwl %sp, %esp
742 addw $4, (%esp)
743 /* copy the iret frame of 12 bytes */
744 .rept 3
745 pushl 16(%esp)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200746 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700747 .endr
748 pushl %eax
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200749 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700750 SAVE_ALL
751 FIXUP_ESPFIX_STACK # %eax == %esp
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200752 CFI_ADJUST_CFA_OFFSET -20 # the frame has now moved
Linus Torvalds1da177e2005-04-16 15:20:36 -0700753 xorl %edx,%edx # zero error code
754 call do_nmi
755 RESTORE_REGS
756 lss 12+4(%esp), %esp # back to 16bit stack
7571: iret
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200758 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700759.section __ex_table,"a"
760 .align 4
761 .long 1b,iret_exc
762.previous
763
Prasanna S Panchamukhi3d97ae52005-09-06 15:19:27 -0700764KPROBE_ENTRY(int3)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200765 RING0_INT_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700766 pushl $-1 # mark this as an int
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200767 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700768 SAVE_ALL
769 xorl %edx,%edx # zero error code
770 movl %esp,%eax # pt_regs pointer
771 call do_int3
Linus Torvalds1da177e2005-04-16 15:20:36 -0700772 jmp ret_from_exception
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200773 CFI_ENDPROC
Prasanna S Panchamukhi3d97ae52005-09-06 15:19:27 -0700774 .previous .text
Linus Torvalds1da177e2005-04-16 15:20:36 -0700775
776ENTRY(overflow)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200777 RING0_INT_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700778 pushl $0
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200779 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700780 pushl $do_overflow
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200781 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700782 jmp error_code
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200783 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700784
785ENTRY(bounds)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200786 RING0_INT_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700787 pushl $0
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200788 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700789 pushl $do_bounds
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200790 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700791 jmp error_code
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200792 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700793
794ENTRY(invalid_op)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200795 RING0_INT_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700796 pushl $0
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200797 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700798 pushl $do_invalid_op
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200799 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700800 jmp error_code
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200801 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700802
803ENTRY(coprocessor_segment_overrun)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200804 RING0_INT_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700805 pushl $0
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200806 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700807 pushl $do_coprocessor_segment_overrun
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200808 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700809 jmp error_code
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200810 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700811
812ENTRY(invalid_TSS)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200813 RING0_EC_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700814 pushl $do_invalid_TSS
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(segment_not_present)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200820 RING0_EC_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700821 pushl $do_segment_not_present
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(stack_segment)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200827 RING0_EC_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700828 pushl $do_stack_segment
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
Prasanna S Panchamukhi3d97ae52005-09-06 15:19:27 -0700833KPROBE_ENTRY(general_protection)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200834 RING0_EC_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700835 pushl $do_general_protection
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
Prasanna S Panchamukhi3d97ae52005-09-06 15:19:27 -0700839 .previous .text
Linus Torvalds1da177e2005-04-16 15:20:36 -0700840
841ENTRY(alignment_check)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200842 RING0_EC_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700843 pushl $do_alignment_check
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200844 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700845 jmp error_code
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200846 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700847
Prasanna S Panchamukhi3d97ae52005-09-06 15:19:27 -0700848KPROBE_ENTRY(page_fault)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200849 RING0_EC_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700850 pushl $do_page_fault
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
Prasanna S Panchamukhi3d97ae52005-09-06 15:19:27 -0700854 .previous .text
Linus Torvalds1da177e2005-04-16 15:20:36 -0700855
856#ifdef CONFIG_X86_MCE
857ENTRY(machine_check)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200858 RING0_INT_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700859 pushl $0
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200860 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700861 pushl machine_check_vector
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200862 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700863 jmp error_code
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200864 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700865#endif
866
867ENTRY(spurious_interrupt_bug)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200868 RING0_INT_FRAME
Linus Torvalds1da177e2005-04-16 15:20:36 -0700869 pushl $0
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200870 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700871 pushl $do_spurious_interrupt_bug
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200872 CFI_ADJUST_CFA_OFFSET 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700873 jmp error_code
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200874 CFI_ENDPROC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700875
Jan Beulich176a2712006-06-26 13:57:41 +0200876#ifdef CONFIG_STACK_UNWIND
877ENTRY(arch_unwind_init_running)
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200878 CFI_STARTPROC
Jan Beulich176a2712006-06-26 13:57:41 +0200879 movl 4(%esp), %edx
880 movl (%esp), %ecx
881 leal 4(%esp), %eax
882 movl %ebx, EBX(%edx)
883 xorl %ebx, %ebx
884 movl %ebx, ECX(%edx)
885 movl %ebx, EDX(%edx)
886 movl %esi, ESI(%edx)
887 movl %edi, EDI(%edx)
888 movl %ebp, EBP(%edx)
889 movl %ebx, EAX(%edx)
890 movl $__USER_DS, DS(%edx)
891 movl $__USER_DS, ES(%edx)
892 movl %ebx, ORIG_EAX(%edx)
893 movl %ecx, EIP(%edx)
894 movl 12(%esp), %ecx
895 movl $__KERNEL_CS, CS(%edx)
896 movl %ebx, EFLAGS(%edx)
897 movl %eax, OLDESP(%edx)
898 movl 8(%esp), %eax
899 movl %ecx, 8(%esp)
900 movl EBX(%edx), %ebx
901 movl $__KERNEL_DS, OLDSS(%edx)
902 jmpl *%eax
Jan Beulichfe7cacc2006-06-26 13:57:44 +0200903 CFI_ENDPROC
Jan Beulich176a2712006-06-26 13:57:41 +0200904ENDPROC(arch_unwind_init_running)
905#endif
906
Arjan van de Venbb152f52006-01-06 00:12:05 -0800907.section .rodata,"a"
Paolo 'Blaisorblade' Giarrusso5e7b83f2005-05-01 08:58:55 -0700908#include "syscall_table.S"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700909
910syscall_table_size=(.-sys_call_table)