| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | * | 
|  | 3 | *  Copyright (C) 1991, 1992  Linus Torvalds | 
|  | 4 | */ | 
|  | 5 |  | 
|  | 6 | /* | 
|  | 7 | * entry.S contains the system-call and fault low-level handling routines. | 
|  | 8 | * This also contains the timer-interrupt handler, as well as all interrupts | 
|  | 9 | * and faults that can result in a task-switch. | 
|  | 10 | * | 
|  | 11 | * NOTE: This code handles signal-recognition, which happens every time | 
|  | 12 | * after a timer-interrupt and after each system call. | 
|  | 13 | * | 
|  | 14 | * I changed all the .align's to 4 (16 byte alignment), as that's faster | 
|  | 15 | * on a 486. | 
|  | 16 | * | 
| Andi Kleen | 889f21c | 2007-05-02 19:27:19 +0200 | [diff] [blame] | 17 | * Stack layout in 'syscall_exit': | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | * 	ptrace needs to have all regs on the stack. | 
|  | 19 | *	if the order here is changed, it needs to be | 
|  | 20 | *	updated in fork.c:copy_process, signal.c:do_signal, | 
|  | 21 | *	ptrace.c and ptrace.h | 
|  | 22 | * | 
|  | 23 | *	 0(%esp) - %ebx | 
|  | 24 | *	 4(%esp) - %ecx | 
|  | 25 | *	 8(%esp) - %edx | 
|  | 26 | *       C(%esp) - %esi | 
|  | 27 | *	10(%esp) - %edi | 
|  | 28 | *	14(%esp) - %ebp | 
|  | 29 | *	18(%esp) - %eax | 
|  | 30 | *	1C(%esp) - %ds | 
|  | 31 | *	20(%esp) - %es | 
| Jeremy Fitzhardinge | 464d1a7 | 2007-02-13 13:26:20 +0100 | [diff] [blame] | 32 | *	24(%esp) - %fs | 
| Jeremy Fitzhardinge | f95d47c | 2006-12-07 02:14:02 +0100 | [diff] [blame] | 33 | *	28(%esp) - orig_eax | 
|  | 34 | *	2C(%esp) - %eip | 
|  | 35 | *	30(%esp) - %cs | 
|  | 36 | *	34(%esp) - %eflags | 
|  | 37 | *	38(%esp) - %oldesp | 
|  | 38 | *	3C(%esp) - %oldss | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 39 | * | 
|  | 40 | * "current" is in register %ebx during any slow entries. | 
|  | 41 | */ | 
|  | 42 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | #include <linux/linkage.h> | 
|  | 44 | #include <asm/thread_info.h> | 
| Ingo Molnar | 55f327f | 2006-07-03 00:24:43 -0700 | [diff] [blame] | 45 | #include <asm/irqflags.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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> | 
| Stas Sergeev | be44d2a | 2006-12-07 02:14:01 +0100 | [diff] [blame] | 51 | #include <asm/percpu.h> | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 52 | #include <asm/dwarf2.h> | 
| Cyrill Gorcunov | ab68ed9 | 2008-03-25 22:16:32 +0300 | [diff] [blame] | 53 | #include <asm/processor-flags.h> | 
| Abhishek Sagar | 395a59d | 2008-06-21 23:47:27 +0530 | [diff] [blame] | 54 | #include <asm/ftrace.h> | 
| Thomas Gleixner | 9b7dc56 | 2008-05-02 20:10:09 +0200 | [diff] [blame] | 55 | #include <asm/irq_vectors.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 56 |  | 
| Roland McGrath | af0575b | 2008-06-24 04:16:52 -0700 | [diff] [blame] | 57 | /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this.  */ | 
|  | 58 | #include <linux/elf-em.h> | 
|  | 59 | #define AUDIT_ARCH_I386		(EM_386|__AUDIT_ARCH_LE) | 
|  | 60 | #define __AUDIT_ARCH_LE	   0x40000000 | 
|  | 61 |  | 
|  | 62 | #ifndef CONFIG_AUDITSYSCALL | 
|  | 63 | #define sysenter_audit	syscall_trace_entry | 
|  | 64 | #define sysexit_audit	syscall_exit_work | 
|  | 65 | #endif | 
|  | 66 |  | 
| Rusty Russell | 139ec7c | 2006-12-07 02:14:08 +0100 | [diff] [blame] | 67 | /* | 
|  | 68 | * We use macros for low-level operations which need to be overridden | 
|  | 69 | * for paravirtualization.  The following will never clobber any registers: | 
|  | 70 | *   INTERRUPT_RETURN (aka. "iret") | 
|  | 71 | *   GET_CR0_INTO_EAX (aka. "movl %cr0, %eax") | 
| Jeremy Fitzhardinge | d75cd22 | 2008-06-25 00:19:26 -0400 | [diff] [blame] | 72 | *   ENABLE_INTERRUPTS_SYSEXIT (aka "sti; sysexit"). | 
| Rusty Russell | 139ec7c | 2006-12-07 02:14:08 +0100 | [diff] [blame] | 73 | * | 
|  | 74 | * For DISABLE_INTERRUPTS/ENABLE_INTERRUPTS (aka "cli"/"sti"), you must | 
|  | 75 | * specify what registers can be overwritten (CLBR_NONE, CLBR_EAX/EDX/ECX/ANY). | 
|  | 76 | * Allowing a register to be clobbered can shrink the paravirt replacement | 
|  | 77 | * enough to patch inline, increasing performance. | 
|  | 78 | */ | 
|  | 79 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | #define nr_syscalls ((syscall_table_size)/4) | 
|  | 81 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 82 | #ifdef CONFIG_PREEMPT | 
| Rusty Russell | 139ec7c | 2006-12-07 02:14:08 +0100 | [diff] [blame] | 83 | #define preempt_stop(clobbers)	DISABLE_INTERRUPTS(clobbers); TRACE_IRQS_OFF | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | #else | 
| Rusty Russell | 139ec7c | 2006-12-07 02:14:08 +0100 | [diff] [blame] | 85 | #define preempt_stop(clobbers) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 86 | #define resume_kernel		restore_nocheck | 
|  | 87 | #endif | 
|  | 88 |  | 
| Ingo Molnar | 55f327f | 2006-07-03 00:24:43 -0700 | [diff] [blame] | 89 | .macro TRACE_IRQS_IRET | 
|  | 90 | #ifdef CONFIG_TRACE_IRQFLAGS | 
| Cyrill Gorcunov | ab68ed9 | 2008-03-25 22:16:32 +0300 | [diff] [blame] | 91 | testl $X86_EFLAGS_IF,PT_EFLAGS(%esp)     # interrupts off? | 
| Ingo Molnar | 55f327f | 2006-07-03 00:24:43 -0700 | [diff] [blame] | 92 | jz 1f | 
|  | 93 | TRACE_IRQS_ON | 
|  | 94 | 1: | 
|  | 95 | #endif | 
|  | 96 | .endm | 
|  | 97 |  | 
| Aleksey Gorelov | 4031ff3 | 2006-06-27 02:53:48 -0700 | [diff] [blame] | 98 | #ifdef CONFIG_VM86 | 
|  | 99 | #define resume_userspace_sig	check_userspace | 
|  | 100 | #else | 
|  | 101 | #define resume_userspace_sig	resume_userspace | 
|  | 102 | #endif | 
|  | 103 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 104 | #define SAVE_ALL \ | 
|  | 105 | cld; \ | 
| Jeremy Fitzhardinge | 464d1a7 | 2007-02-13 13:26:20 +0100 | [diff] [blame] | 106 | pushl %fs; \ | 
| Jeremy Fitzhardinge | f95d47c | 2006-12-07 02:14:02 +0100 | [diff] [blame] | 107 | CFI_ADJUST_CFA_OFFSET 4;\ | 
| Jeremy Fitzhardinge | 464d1a7 | 2007-02-13 13:26:20 +0100 | [diff] [blame] | 108 | /*CFI_REL_OFFSET fs, 0;*/\ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 109 | pushl %es; \ | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 110 | CFI_ADJUST_CFA_OFFSET 4;\ | 
|  | 111 | /*CFI_REL_OFFSET es, 0;*/\ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 112 | pushl %ds; \ | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 113 | CFI_ADJUST_CFA_OFFSET 4;\ | 
|  | 114 | /*CFI_REL_OFFSET ds, 0;*/\ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 115 | pushl %eax; \ | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 116 | CFI_ADJUST_CFA_OFFSET 4;\ | 
|  | 117 | CFI_REL_OFFSET eax, 0;\ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 118 | pushl %ebp; \ | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 119 | CFI_ADJUST_CFA_OFFSET 4;\ | 
|  | 120 | CFI_REL_OFFSET ebp, 0;\ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 121 | pushl %edi; \ | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 122 | CFI_ADJUST_CFA_OFFSET 4;\ | 
|  | 123 | CFI_REL_OFFSET edi, 0;\ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 124 | pushl %esi; \ | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 125 | CFI_ADJUST_CFA_OFFSET 4;\ | 
|  | 126 | CFI_REL_OFFSET esi, 0;\ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 127 | pushl %edx; \ | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 128 | CFI_ADJUST_CFA_OFFSET 4;\ | 
|  | 129 | CFI_REL_OFFSET edx, 0;\ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 130 | pushl %ecx; \ | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 131 | CFI_ADJUST_CFA_OFFSET 4;\ | 
|  | 132 | CFI_REL_OFFSET ecx, 0;\ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 133 | pushl %ebx; \ | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 134 | CFI_ADJUST_CFA_OFFSET 4;\ | 
|  | 135 | CFI_REL_OFFSET ebx, 0;\ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 136 | movl $(__USER_DS), %edx; \ | 
|  | 137 | movl %edx, %ds; \ | 
| Jeremy Fitzhardinge | f95d47c | 2006-12-07 02:14:02 +0100 | [diff] [blame] | 138 | movl %edx, %es; \ | 
| Jeremy Fitzhardinge | 7c3576d | 2007-05-02 19:27:16 +0200 | [diff] [blame] | 139 | movl $(__KERNEL_PERCPU), %edx; \ | 
| Jeremy Fitzhardinge | 464d1a7 | 2007-02-13 13:26:20 +0100 | [diff] [blame] | 140 | movl %edx, %fs | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 141 |  | 
|  | 142 | #define RESTORE_INT_REGS \ | 
|  | 143 | popl %ebx;	\ | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 144 | CFI_ADJUST_CFA_OFFSET -4;\ | 
|  | 145 | CFI_RESTORE ebx;\ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 146 | popl %ecx;	\ | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 147 | CFI_ADJUST_CFA_OFFSET -4;\ | 
|  | 148 | CFI_RESTORE ecx;\ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 149 | popl %edx;	\ | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 150 | CFI_ADJUST_CFA_OFFSET -4;\ | 
|  | 151 | CFI_RESTORE edx;\ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 152 | popl %esi;	\ | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 153 | CFI_ADJUST_CFA_OFFSET -4;\ | 
|  | 154 | CFI_RESTORE esi;\ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 155 | popl %edi;	\ | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 156 | CFI_ADJUST_CFA_OFFSET -4;\ | 
|  | 157 | CFI_RESTORE edi;\ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 158 | popl %ebp;	\ | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 159 | CFI_ADJUST_CFA_OFFSET -4;\ | 
|  | 160 | CFI_RESTORE ebp;\ | 
|  | 161 | popl %eax;	\ | 
|  | 162 | CFI_ADJUST_CFA_OFFSET -4;\ | 
|  | 163 | CFI_RESTORE eax | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 164 |  | 
|  | 165 | #define RESTORE_REGS	\ | 
|  | 166 | RESTORE_INT_REGS; \ | 
|  | 167 | 1:	popl %ds;	\ | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 168 | CFI_ADJUST_CFA_OFFSET -4;\ | 
|  | 169 | /*CFI_RESTORE ds;*/\ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 170 | 2:	popl %es;	\ | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 171 | CFI_ADJUST_CFA_OFFSET -4;\ | 
|  | 172 | /*CFI_RESTORE es;*/\ | 
| Jeremy Fitzhardinge | 464d1a7 | 2007-02-13 13:26:20 +0100 | [diff] [blame] | 173 | 3:	popl %fs;	\ | 
| Jeremy Fitzhardinge | f95d47c | 2006-12-07 02:14:02 +0100 | [diff] [blame] | 174 | CFI_ADJUST_CFA_OFFSET -4;\ | 
| Jeremy Fitzhardinge | 464d1a7 | 2007-02-13 13:26:20 +0100 | [diff] [blame] | 175 | /*CFI_RESTORE fs;*/\ | 
| Jeremy Fitzhardinge | f95d47c | 2006-12-07 02:14:02 +0100 | [diff] [blame] | 176 | .pushsection .fixup,"ax";	\ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 177 | 4:	movl $0,(%esp);	\ | 
| Jeremy Fitzhardinge | f95d47c | 2006-12-07 02:14:02 +0100 | [diff] [blame] | 178 | jmp 1b;		\ | 
|  | 179 | 5:	movl $0,(%esp);	\ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 180 | jmp 2b;		\ | 
| Jeremy Fitzhardinge | f95d47c | 2006-12-07 02:14:02 +0100 | [diff] [blame] | 181 | 6:	movl $0,(%esp);	\ | 
|  | 182 | jmp 3b;		\ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 183 | .section __ex_table,"a";\ | 
|  | 184 | .align 4;	\ | 
| Jeremy Fitzhardinge | f95d47c | 2006-12-07 02:14:02 +0100 | [diff] [blame] | 185 | .long 1b,4b;	\ | 
|  | 186 | .long 2b,5b;	\ | 
|  | 187 | .long 3b,6b;	\ | 
|  | 188 | .popsection | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 189 |  | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 190 | #define RING0_INT_FRAME \ | 
|  | 191 | CFI_STARTPROC simple;\ | 
| Jan Beulich | adf1423 | 2006-09-26 10:52:41 +0200 | [diff] [blame] | 192 | CFI_SIGNAL_FRAME;\ | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 193 | CFI_DEF_CFA esp, 3*4;\ | 
|  | 194 | /*CFI_OFFSET cs, -2*4;*/\ | 
|  | 195 | CFI_OFFSET eip, -3*4 | 
|  | 196 |  | 
|  | 197 | #define RING0_EC_FRAME \ | 
|  | 198 | CFI_STARTPROC simple;\ | 
| Jan Beulich | adf1423 | 2006-09-26 10:52:41 +0200 | [diff] [blame] | 199 | CFI_SIGNAL_FRAME;\ | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 200 | CFI_DEF_CFA esp, 4*4;\ | 
|  | 201 | /*CFI_OFFSET cs, -2*4;*/\ | 
|  | 202 | CFI_OFFSET eip, -3*4 | 
|  | 203 |  | 
|  | 204 | #define RING0_PTREGS_FRAME \ | 
|  | 205 | CFI_STARTPROC simple;\ | 
| Jan Beulich | adf1423 | 2006-09-26 10:52:41 +0200 | [diff] [blame] | 206 | CFI_SIGNAL_FRAME;\ | 
| Jeremy Fitzhardinge | eb5b7b9 | 2006-12-07 02:14:02 +0100 | [diff] [blame] | 207 | CFI_DEF_CFA esp, PT_OLDESP-PT_EBX;\ | 
|  | 208 | /*CFI_OFFSET cs, PT_CS-PT_OLDESP;*/\ | 
|  | 209 | CFI_OFFSET eip, PT_EIP-PT_OLDESP;\ | 
|  | 210 | /*CFI_OFFSET es, PT_ES-PT_OLDESP;*/\ | 
|  | 211 | /*CFI_OFFSET ds, PT_DS-PT_OLDESP;*/\ | 
|  | 212 | CFI_OFFSET eax, PT_EAX-PT_OLDESP;\ | 
|  | 213 | CFI_OFFSET ebp, PT_EBP-PT_OLDESP;\ | 
|  | 214 | CFI_OFFSET edi, PT_EDI-PT_OLDESP;\ | 
|  | 215 | CFI_OFFSET esi, PT_ESI-PT_OLDESP;\ | 
|  | 216 | CFI_OFFSET edx, PT_EDX-PT_OLDESP;\ | 
|  | 217 | CFI_OFFSET ecx, PT_ECX-PT_OLDESP;\ | 
|  | 218 | CFI_OFFSET ebx, PT_EBX-PT_OLDESP | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 219 |  | 
|  | 220 | ENTRY(ret_from_fork) | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 221 | CFI_STARTPROC | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 222 | pushl %eax | 
| Markus Armbruster | 25d7dfd | 2006-07-30 03:04:08 -0700 | [diff] [blame] | 223 | CFI_ADJUST_CFA_OFFSET 4 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 224 | call schedule_tail | 
|  | 225 | GET_THREAD_INFO(%ebp) | 
|  | 226 | popl %eax | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 227 | CFI_ADJUST_CFA_OFFSET -4 | 
| Linus Torvalds | 47a5c6f | 2006-09-18 16:20:40 -0700 | [diff] [blame] | 228 | pushl $0x0202			# Reset kernel eflags | 
|  | 229 | CFI_ADJUST_CFA_OFFSET 4 | 
|  | 230 | popfl | 
|  | 231 | CFI_ADJUST_CFA_OFFSET -4 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 232 | jmp syscall_exit | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 233 | CFI_ENDPROC | 
| Jan Beulich | 47a55cd | 2007-02-13 13:26:24 +0100 | [diff] [blame] | 234 | END(ret_from_fork) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 235 |  | 
|  | 236 | /* | 
|  | 237 | * Return to user mode is not as complex as all this looks, | 
|  | 238 | * but we want the default path for a system call return to | 
|  | 239 | * go as quickly as possible which is why some of this is | 
|  | 240 | * less clear than it otherwise should be. | 
|  | 241 | */ | 
|  | 242 |  | 
|  | 243 | # userspace resumption stub bypassing syscall exit tracing | 
|  | 244 | ALIGN | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 245 | RING0_PTREGS_FRAME | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 246 | ret_from_exception: | 
| Rusty Russell | 139ec7c | 2006-12-07 02:14:08 +0100 | [diff] [blame] | 247 | preempt_stop(CLBR_ANY) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 248 | ret_from_intr: | 
|  | 249 | GET_THREAD_INFO(%ebp) | 
| Aleksey Gorelov | 4031ff3 | 2006-06-27 02:53:48 -0700 | [diff] [blame] | 250 | check_userspace: | 
| Jeremy Fitzhardinge | eb5b7b9 | 2006-12-07 02:14:02 +0100 | [diff] [blame] | 251 | movl PT_EFLAGS(%esp), %eax	# mix EFLAGS and CS | 
|  | 252 | movb PT_CS(%esp), %al | 
| Cyrill Gorcunov | ab68ed9 | 2008-03-25 22:16:32 +0300 | [diff] [blame] | 253 | andl $(X86_EFLAGS_VM | SEGMENT_RPL_MASK), %eax | 
| Rusty Russell | 78be370 | 2006-09-26 10:52:39 +0200 | [diff] [blame] | 254 | cmpl $USER_RPL, %eax | 
|  | 255 | jb resume_kernel		# not returning to v8086 or userspace | 
| Jeremy Fitzhardinge | f95d47c | 2006-12-07 02:14:02 +0100 | [diff] [blame] | 256 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 257 | ENTRY(resume_userspace) | 
| Peter Zijlstra | c7e872e | 2007-10-11 22:11:12 +0200 | [diff] [blame] | 258 | LOCKDEP_SYS_EXIT | 
| Rusty Russell | 139ec7c | 2006-12-07 02:14:08 +0100 | [diff] [blame] | 259 | DISABLE_INTERRUPTS(CLBR_ANY)	# make sure we don't miss an interrupt | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 260 | # setting need_resched or sigpending | 
|  | 261 | # between sampling and the iret | 
| Peter Zijlstra | e32e58a | 2008-06-06 10:14:08 +0200 | [diff] [blame] | 262 | TRACE_IRQS_OFF | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 263 | movl TI_flags(%ebp), %ecx | 
|  | 264 | andl $_TIF_WORK_MASK, %ecx	# is there any work to be done on | 
|  | 265 | # int/exception return? | 
|  | 266 | jne work_pending | 
|  | 267 | jmp restore_all | 
| Jan Beulich | 47a55cd | 2007-02-13 13:26:24 +0100 | [diff] [blame] | 268 | END(ret_from_exception) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 269 |  | 
|  | 270 | #ifdef CONFIG_PREEMPT | 
|  | 271 | ENTRY(resume_kernel) | 
| Rusty Russell | 139ec7c | 2006-12-07 02:14:08 +0100 | [diff] [blame] | 272 | DISABLE_INTERRUPTS(CLBR_ANY) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 273 | cmpl $0,TI_preempt_count(%ebp)	# non-zero preempt_count ? | 
|  | 274 | jnz restore_nocheck | 
|  | 275 | need_resched: | 
|  | 276 | movl TI_flags(%ebp), %ecx	# need_resched set ? | 
|  | 277 | testb $_TIF_NEED_RESCHED, %cl | 
|  | 278 | jz restore_all | 
| Cyrill Gorcunov | ab68ed9 | 2008-03-25 22:16:32 +0300 | [diff] [blame] | 279 | testl $X86_EFLAGS_IF,PT_EFLAGS(%esp)	# interrupts off (exception path) ? | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 280 | jz restore_all | 
|  | 281 | call preempt_schedule_irq | 
|  | 282 | jmp need_resched | 
| Jan Beulich | 47a55cd | 2007-02-13 13:26:24 +0100 | [diff] [blame] | 283 | END(resume_kernel) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 284 | #endif | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 285 | CFI_ENDPROC | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 286 |  | 
|  | 287 | /* SYSENTER_RETURN points to after the "sysenter" instruction in | 
|  | 288 | the vsyscall page.  See vsyscall-sysentry.S, which defines the symbol.  */ | 
|  | 289 |  | 
|  | 290 | # sysenter call handler stub | 
| Roland McGrath | 0aa97fb | 2008-01-30 13:30:43 +0100 | [diff] [blame] | 291 | ENTRY(ia32_sysenter_target) | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 292 | CFI_STARTPROC simple | 
| Jan Beulich | adf1423 | 2006-09-26 10:52:41 +0200 | [diff] [blame] | 293 | CFI_SIGNAL_FRAME | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 294 | CFI_DEF_CFA esp, 0 | 
|  | 295 | CFI_REGISTER esp, ebp | 
| H. Peter Anvin | faca622 | 2008-01-30 13:31:02 +0100 | [diff] [blame] | 296 | movl TSS_sysenter_sp0(%esp),%esp | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 297 | sysenter_past_esp: | 
| Ingo Molnar | 55f327f | 2006-07-03 00:24:43 -0700 | [diff] [blame] | 298 | /* | 
| Jeremy Fitzhardinge | d93c870 | 2008-03-24 16:43:21 -0700 | [diff] [blame] | 299 | * Interrupts are disabled here, but we can't trace it until | 
|  | 300 | * enough kernel state to call TRACE_IRQS_OFF can be called - but | 
|  | 301 | * we immediately enable interrupts at that point anyway. | 
| Ingo Molnar | 55f327f | 2006-07-03 00:24:43 -0700 | [diff] [blame] | 302 | */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 303 | pushl $(__USER_DS) | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 304 | CFI_ADJUST_CFA_OFFSET 4 | 
|  | 305 | /*CFI_REL_OFFSET ss, 0*/ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 306 | pushl %ebp | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 307 | CFI_ADJUST_CFA_OFFSET 4 | 
|  | 308 | CFI_REL_OFFSET esp, 0 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 309 | pushfl | 
| Jeremy Fitzhardinge | d93c870 | 2008-03-24 16:43:21 -0700 | [diff] [blame] | 310 | orl $X86_EFLAGS_IF, (%esp) | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 311 | CFI_ADJUST_CFA_OFFSET 4 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 312 | pushl $(__USER_CS) | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 313 | CFI_ADJUST_CFA_OFFSET 4 | 
|  | 314 | /*CFI_REL_OFFSET cs, 0*/ | 
| Ingo Molnar | e6e5494 | 2006-06-27 02:53:50 -0700 | [diff] [blame] | 315 | /* | 
|  | 316 | * Push current_thread_info()->sysenter_return to the stack. | 
|  | 317 | * A tiny bit of offset fixup is necessary - 4*4 means the 4 words | 
|  | 318 | * pushed above; +8 corresponds to copy_thread's esp0 setting. | 
|  | 319 | */ | 
|  | 320 | pushl (TI_sysenter_return-THREAD_SIZE+8+4*4)(%esp) | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 321 | CFI_ADJUST_CFA_OFFSET 4 | 
|  | 322 | CFI_REL_OFFSET eip, 0 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 323 |  | 
| Jeremy Fitzhardinge | d93c870 | 2008-03-24 16:43:21 -0700 | [diff] [blame] | 324 | pushl %eax | 
|  | 325 | CFI_ADJUST_CFA_OFFSET 4 | 
|  | 326 | SAVE_ALL | 
|  | 327 | ENABLE_INTERRUPTS(CLBR_NONE) | 
|  | 328 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 329 | /* | 
|  | 330 | * Load the potential sixth argument from user stack. | 
|  | 331 | * Careful about security. | 
|  | 332 | */ | 
|  | 333 | cmpl $__PAGE_OFFSET-3,%ebp | 
|  | 334 | jae syscall_fault | 
|  | 335 | 1:	movl (%ebp),%ebp | 
| Jeremy Fitzhardinge | d93c870 | 2008-03-24 16:43:21 -0700 | [diff] [blame] | 336 | movl %ebp,PT_EBP(%esp) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 337 | .section __ex_table,"a" | 
|  | 338 | .align 4 | 
|  | 339 | .long 1b,syscall_fault | 
|  | 340 | .previous | 
|  | 341 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 342 | GET_THREAD_INFO(%ebp) | 
|  | 343 |  | 
|  | 344 | /* Note, _TIF_SECCOMP is bit number 8, and so it needs testw and not testb */ | 
| Roland McGrath | d4d6715 | 2008-07-09 02:38:07 -0700 | [diff] [blame] | 345 | testw $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp) | 
| Roland McGrath | af0575b | 2008-06-24 04:16:52 -0700 | [diff] [blame] | 346 | jnz sysenter_audit | 
|  | 347 | sysenter_do_call: | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 348 | cmpl $(nr_syscalls), %eax | 
|  | 349 | jae syscall_badsys | 
|  | 350 | call *sys_call_table(,%eax,4) | 
| Jeremy Fitzhardinge | eb5b7b9 | 2006-12-07 02:14:02 +0100 | [diff] [blame] | 351 | movl %eax,PT_EAX(%esp) | 
| Peter Zijlstra | c7e872e | 2007-10-11 22:11:12 +0200 | [diff] [blame] | 352 | LOCKDEP_SYS_EXIT | 
| Jeremy Fitzhardinge | 42c24fa | 2007-05-02 19:27:14 +0200 | [diff] [blame] | 353 | DISABLE_INTERRUPTS(CLBR_ANY) | 
| Ingo Molnar | 55f327f | 2006-07-03 00:24:43 -0700 | [diff] [blame] | 354 | TRACE_IRQS_OFF | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 355 | movl TI_flags(%ebp), %ecx | 
|  | 356 | testw $_TIF_ALLWORK_MASK, %cx | 
| Roland McGrath | af0575b | 2008-06-24 04:16:52 -0700 | [diff] [blame] | 357 | jne sysexit_audit | 
|  | 358 | sysenter_exit: | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 359 | /* if something modifies registers it must also disable sysexit */ | 
| Jeremy Fitzhardinge | eb5b7b9 | 2006-12-07 02:14:02 +0100 | [diff] [blame] | 360 | movl PT_EIP(%esp), %edx | 
|  | 361 | movl PT_OLDESP(%esp), %ecx | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 362 | xorl %ebp,%ebp | 
| Ingo Molnar | 55f327f | 2006-07-03 00:24:43 -0700 | [diff] [blame] | 363 | TRACE_IRQS_ON | 
| Jeremy Fitzhardinge | 464d1a7 | 2007-02-13 13:26:20 +0100 | [diff] [blame] | 364 | 1:	mov  PT_FS(%esp), %fs | 
| Jeremy Fitzhardinge | d75cd22 | 2008-06-25 00:19:26 -0400 | [diff] [blame] | 365 | ENABLE_INTERRUPTS_SYSEXIT | 
| Roland McGrath | af0575b | 2008-06-24 04:16:52 -0700 | [diff] [blame] | 366 |  | 
|  | 367 | #ifdef CONFIG_AUDITSYSCALL | 
|  | 368 | sysenter_audit: | 
|  | 369 | testw $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%ebp) | 
|  | 370 | jnz syscall_trace_entry | 
|  | 371 | addl $4,%esp | 
|  | 372 | CFI_ADJUST_CFA_OFFSET -4 | 
|  | 373 | /* %esi already in 8(%esp)	   6th arg: 4th syscall arg */ | 
|  | 374 | /* %edx already in 4(%esp)	   5th arg: 3rd syscall arg */ | 
|  | 375 | /* %ecx already in 0(%esp)	   4th arg: 2nd syscall arg */ | 
|  | 376 | movl %ebx,%ecx			/* 3rd arg: 1st syscall arg */ | 
|  | 377 | movl %eax,%edx			/* 2nd arg: syscall number */ | 
|  | 378 | movl $AUDIT_ARCH_I386,%eax	/* 1st arg: audit arch */ | 
|  | 379 | call audit_syscall_entry | 
|  | 380 | pushl %ebx | 
|  | 381 | CFI_ADJUST_CFA_OFFSET 4 | 
|  | 382 | movl PT_EAX(%esp),%eax		/* reload syscall number */ | 
|  | 383 | jmp sysenter_do_call | 
|  | 384 |  | 
|  | 385 | sysexit_audit: | 
|  | 386 | testw $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT), %cx | 
|  | 387 | jne syscall_exit_work | 
|  | 388 | TRACE_IRQS_ON | 
|  | 389 | ENABLE_INTERRUPTS(CLBR_ANY) | 
|  | 390 | movl %eax,%edx		/* second arg, syscall return value */ | 
|  | 391 | cmpl $0,%eax		/* is it < 0? */ | 
|  | 392 | setl %al		/* 1 if so, 0 if not */ | 
|  | 393 | movzbl %al,%eax		/* zero-extend that */ | 
|  | 394 | inc %eax /* first arg, 0->1(AUDITSC_SUCCESS), 1->2(AUDITSC_FAILURE) */ | 
|  | 395 | call audit_syscall_exit | 
|  | 396 | DISABLE_INTERRUPTS(CLBR_ANY) | 
|  | 397 | TRACE_IRQS_OFF | 
|  | 398 | movl TI_flags(%ebp), %ecx | 
|  | 399 | testw $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT), %cx | 
|  | 400 | jne syscall_exit_work | 
|  | 401 | movl PT_EAX(%esp),%eax	/* reload syscall return value */ | 
|  | 402 | jmp sysenter_exit | 
|  | 403 | #endif | 
|  | 404 |  | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 405 | CFI_ENDPROC | 
| Jeremy Fitzhardinge | f95d47c | 2006-12-07 02:14:02 +0100 | [diff] [blame] | 406 | .pushsection .fixup,"ax" | 
| Jeremy Fitzhardinge | 464d1a7 | 2007-02-13 13:26:20 +0100 | [diff] [blame] | 407 | 2:	movl $0,PT_FS(%esp) | 
| Jeremy Fitzhardinge | f95d47c | 2006-12-07 02:14:02 +0100 | [diff] [blame] | 408 | jmp 1b | 
|  | 409 | .section __ex_table,"a" | 
|  | 410 | .align 4 | 
|  | 411 | .long 1b,2b | 
|  | 412 | .popsection | 
| Roland McGrath | 0aa97fb | 2008-01-30 13:30:43 +0100 | [diff] [blame] | 413 | ENDPROC(ia32_sysenter_target) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 414 |  | 
|  | 415 | # system call handler stub | 
|  | 416 | ENTRY(system_call) | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 417 | RING0_INT_FRAME			# can't unwind into user space anyway | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 418 | pushl %eax			# save orig_eax | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 419 | CFI_ADJUST_CFA_OFFSET 4 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 420 | SAVE_ALL | 
|  | 421 | GET_THREAD_INFO(%ebp) | 
| Laurent Vivier | ed75e8d | 2005-09-03 15:57:18 -0700 | [diff] [blame] | 422 | # system call tracing in operation / emulation | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 423 | /* Note, _TIF_SECCOMP is bit number 8, and so it needs testw and not testb */ | 
| Roland McGrath | d4d6715 | 2008-07-09 02:38:07 -0700 | [diff] [blame] | 424 | testw $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 425 | jnz syscall_trace_entry | 
|  | 426 | cmpl $(nr_syscalls), %eax | 
|  | 427 | jae syscall_badsys | 
|  | 428 | syscall_call: | 
|  | 429 | call *sys_call_table(,%eax,4) | 
| Jeremy Fitzhardinge | eb5b7b9 | 2006-12-07 02:14:02 +0100 | [diff] [blame] | 430 | movl %eax,PT_EAX(%esp)		# store the return value | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 431 | syscall_exit: | 
| Peter Zijlstra | c7e872e | 2007-10-11 22:11:12 +0200 | [diff] [blame] | 432 | LOCKDEP_SYS_EXIT | 
| Rusty Russell | 139ec7c | 2006-12-07 02:14:08 +0100 | [diff] [blame] | 433 | DISABLE_INTERRUPTS(CLBR_ANY)	# make sure we don't miss an interrupt | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 434 | # setting need_resched or sigpending | 
|  | 435 | # between sampling and the iret | 
| Ingo Molnar | 55f327f | 2006-07-03 00:24:43 -0700 | [diff] [blame] | 436 | TRACE_IRQS_OFF | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 437 | movl TI_flags(%ebp), %ecx | 
|  | 438 | testw $_TIF_ALLWORK_MASK, %cx	# current->work | 
|  | 439 | jne syscall_exit_work | 
|  | 440 |  | 
|  | 441 | restore_all: | 
| Jeremy Fitzhardinge | eb5b7b9 | 2006-12-07 02:14:02 +0100 | [diff] [blame] | 442 | movl PT_EFLAGS(%esp), %eax	# mix EFLAGS, SS and CS | 
|  | 443 | # Warning: PT_OLDSS(%esp) contains the wrong/random values if we | 
| Stas Sergeev | 5df2408 | 2005-04-16 15:24:01 -0700 | [diff] [blame] | 444 | # are returning to the kernel. | 
|  | 445 | # See comments in process.c:copy_thread() for details. | 
| Jeremy Fitzhardinge | eb5b7b9 | 2006-12-07 02:14:02 +0100 | [diff] [blame] | 446 | movb PT_OLDSS(%esp), %ah | 
|  | 447 | movb PT_CS(%esp), %al | 
| Cyrill Gorcunov | ab68ed9 | 2008-03-25 22:16:32 +0300 | [diff] [blame] | 448 | andl $(X86_EFLAGS_VM | (SEGMENT_TI_MASK << 8) | SEGMENT_RPL_MASK), %eax | 
| Rusty Russell | 78be370 | 2006-09-26 10:52:39 +0200 | [diff] [blame] | 449 | cmpl $((SEGMENT_LDT << 8) | USER_RPL), %eax | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 450 | CFI_REMEMBER_STATE | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 451 | je ldt_ss			# returning to user-space with LDT SS | 
|  | 452 | restore_nocheck: | 
| Ingo Molnar | 55f327f | 2006-07-03 00:24:43 -0700 | [diff] [blame] | 453 | TRACE_IRQS_IRET | 
|  | 454 | restore_nocheck_notrace: | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 455 | RESTORE_REGS | 
| Jeremy Fitzhardinge | f95d47c | 2006-12-07 02:14:02 +0100 | [diff] [blame] | 456 | addl $4, %esp			# skip orig_eax/error_code | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 457 | CFI_ADJUST_CFA_OFFSET -4 | 
| Adrian Bunk | f7f3d79 | 2008-02-13 23:29:53 +0200 | [diff] [blame] | 458 | irq_return: | 
| Ingo Molnar | 3701d863 | 2008-02-09 23:24:08 +0100 | [diff] [blame] | 459 | INTERRUPT_RETURN | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 460 | .section .fixup,"ax" | 
| Jeremy Fitzhardinge | 90e9f53 | 2008-03-17 16:37:12 -0700 | [diff] [blame] | 461 | ENTRY(iret_exc) | 
| Linus Torvalds | a879cbb | 2005-04-29 09:38:44 -0700 | [diff] [blame] | 462 | pushl $0			# no error code | 
|  | 463 | pushl $do_iret_error | 
|  | 464 | jmp error_code | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 465 | .previous | 
|  | 466 | .section __ex_table,"a" | 
|  | 467 | .align 4 | 
| Ingo Molnar | 3701d863 | 2008-02-09 23:24:08 +0100 | [diff] [blame] | 468 | .long irq_return,iret_exc | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 469 | .previous | 
|  | 470 |  | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 471 | CFI_RESTORE_STATE | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 472 | ldt_ss: | 
| Jeremy Fitzhardinge | eb5b7b9 | 2006-12-07 02:14:02 +0100 | [diff] [blame] | 473 | larl PT_OLDSS(%esp), %eax | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 474 | jnz restore_nocheck | 
|  | 475 | testl $0x00400000, %eax		# returning to 32bit stack? | 
|  | 476 | jnz restore_nocheck		# allright, normal return | 
| Rusty Russell | d3561b7 | 2006-12-07 02:14:07 +0100 | [diff] [blame] | 477 |  | 
|  | 478 | #ifdef CONFIG_PARAVIRT | 
|  | 479 | /* | 
|  | 480 | * The kernel can't run on a non-flat stack if paravirt mode | 
|  | 481 | * is active.  Rather than try to fixup the high bits of | 
|  | 482 | * ESP, bypass this code entirely.  This may break DOSemu | 
|  | 483 | * and/or Wine support in a paravirt VM, although the option | 
|  | 484 | * is still available to implement the setting of the high | 
|  | 485 | * 16-bits in the INTERRUPT_RETURN paravirt-op. | 
|  | 486 | */ | 
| Jeremy Fitzhardinge | 93b1eab | 2007-10-16 11:51:29 -0700 | [diff] [blame] | 487 | cmpl $0, pv_info+PARAVIRT_enabled | 
| Rusty Russell | d3561b7 | 2006-12-07 02:14:07 +0100 | [diff] [blame] | 488 | jne restore_nocheck | 
|  | 489 | #endif | 
|  | 490 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 491 | /* If returning to userspace with 16bit stack, | 
|  | 492 | * try to fix the higher word of ESP, as the CPU | 
|  | 493 | * won't restore it. | 
|  | 494 | * This is an "official" bug of all the x86-compatible | 
|  | 495 | * CPUs, which we can try to work around to make | 
|  | 496 | * dosemu and wine happy. */ | 
| Jeremy Fitzhardinge | eb5b7b9 | 2006-12-07 02:14:02 +0100 | [diff] [blame] | 497 | movl PT_OLDESP(%esp), %eax | 
| Stas Sergeev | be44d2a | 2006-12-07 02:14:01 +0100 | [diff] [blame] | 498 | movl %esp, %edx | 
|  | 499 | call patch_espfix_desc | 
|  | 500 | pushl $__ESPFIX_SS | 
|  | 501 | CFI_ADJUST_CFA_OFFSET 4 | 
|  | 502 | pushl %eax | 
|  | 503 | CFI_ADJUST_CFA_OFFSET 4 | 
| Rusty Russell | 139ec7c | 2006-12-07 02:14:08 +0100 | [diff] [blame] | 504 | DISABLE_INTERRUPTS(CLBR_EAX) | 
| Ingo Molnar | 55f327f | 2006-07-03 00:24:43 -0700 | [diff] [blame] | 505 | TRACE_IRQS_OFF | 
| Stas Sergeev | be44d2a | 2006-12-07 02:14:01 +0100 | [diff] [blame] | 506 | lss (%esp), %esp | 
|  | 507 | CFI_ADJUST_CFA_OFFSET -8 | 
|  | 508 | jmp restore_nocheck | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 509 | CFI_ENDPROC | 
| Jan Beulich | 47a55cd | 2007-02-13 13:26:24 +0100 | [diff] [blame] | 510 | ENDPROC(system_call) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 511 |  | 
|  | 512 | # perform work that needs to be done immediately before resumption | 
|  | 513 | ALIGN | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 514 | RING0_PTREGS_FRAME		# can't unwind into user space anyway | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 515 | work_pending: | 
|  | 516 | testb $_TIF_NEED_RESCHED, %cl | 
|  | 517 | jz work_notifysig | 
|  | 518 | work_resched: | 
|  | 519 | call schedule | 
| Peter Zijlstra | c7e872e | 2007-10-11 22:11:12 +0200 | [diff] [blame] | 520 | LOCKDEP_SYS_EXIT | 
| Rusty Russell | 139ec7c | 2006-12-07 02:14:08 +0100 | [diff] [blame] | 521 | DISABLE_INTERRUPTS(CLBR_ANY)	# make sure we don't miss an interrupt | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 522 | # setting need_resched or sigpending | 
|  | 523 | # between sampling and the iret | 
| Ingo Molnar | 55f327f | 2006-07-03 00:24:43 -0700 | [diff] [blame] | 524 | TRACE_IRQS_OFF | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 525 | movl TI_flags(%ebp), %ecx | 
|  | 526 | andl $_TIF_WORK_MASK, %ecx	# is there any work to be done other | 
|  | 527 | # than syscall tracing? | 
|  | 528 | jz restore_all | 
|  | 529 | testb $_TIF_NEED_RESCHED, %cl | 
|  | 530 | jnz work_resched | 
|  | 531 |  | 
|  | 532 | work_notifysig:				# deal with pending signals and | 
|  | 533 | # notify-resume requests | 
| Joe Korty | 74b47a7 | 2006-12-07 02:14:04 +0100 | [diff] [blame] | 534 | #ifdef CONFIG_VM86 | 
| Cyrill Gorcunov | ab68ed9 | 2008-03-25 22:16:32 +0300 | [diff] [blame] | 535 | testl $X86_EFLAGS_VM, PT_EFLAGS(%esp) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 536 | movl %esp, %eax | 
|  | 537 | jne work_notifysig_v86		# returning to kernel-space or | 
|  | 538 | # vm86-space | 
|  | 539 | xorl %edx, %edx | 
|  | 540 | call do_notify_resume | 
| Aleksey Gorelov | 4031ff3 | 2006-06-27 02:53:48 -0700 | [diff] [blame] | 541 | jmp resume_userspace_sig | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 542 |  | 
|  | 543 | ALIGN | 
|  | 544 | work_notifysig_v86: | 
|  | 545 | pushl %ecx			# save ti_flags for do_notify_resume | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 546 | CFI_ADJUST_CFA_OFFSET 4 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 547 | call save_v86_state		# %eax contains pt_regs pointer | 
|  | 548 | popl %ecx | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 549 | CFI_ADJUST_CFA_OFFSET -4 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 550 | movl %eax, %esp | 
| Joe Korty | 74b47a7 | 2006-12-07 02:14:04 +0100 | [diff] [blame] | 551 | #else | 
|  | 552 | movl %esp, %eax | 
|  | 553 | #endif | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 554 | xorl %edx, %edx | 
|  | 555 | call do_notify_resume | 
| Aleksey Gorelov | 4031ff3 | 2006-06-27 02:53:48 -0700 | [diff] [blame] | 556 | jmp resume_userspace_sig | 
| Jan Beulich | 47a55cd | 2007-02-13 13:26:24 +0100 | [diff] [blame] | 557 | END(work_pending) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 558 |  | 
|  | 559 | # perform syscall exit tracing | 
|  | 560 | ALIGN | 
|  | 561 | syscall_trace_entry: | 
| Jeremy Fitzhardinge | eb5b7b9 | 2006-12-07 02:14:02 +0100 | [diff] [blame] | 562 | movl $-ENOSYS,PT_EAX(%esp) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 563 | movl %esp, %eax | 
| Roland McGrath | d4d6715 | 2008-07-09 02:38:07 -0700 | [diff] [blame] | 564 | call syscall_trace_enter | 
|  | 565 | /* What it returned is what we'll actually use.  */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 566 | cmpl $(nr_syscalls), %eax | 
|  | 567 | jnae syscall_call | 
|  | 568 | jmp syscall_exit | 
| Jan Beulich | 47a55cd | 2007-02-13 13:26:24 +0100 | [diff] [blame] | 569 | END(syscall_trace_entry) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 570 |  | 
|  | 571 | # perform syscall exit tracing | 
|  | 572 | ALIGN | 
|  | 573 | syscall_exit_work: | 
| Roland McGrath | d4d6715 | 2008-07-09 02:38:07 -0700 | [diff] [blame] | 574 | testb $_TIF_WORK_SYSCALL_EXIT, %cl | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 575 | jz work_pending | 
| Ingo Molnar | 55f327f | 2006-07-03 00:24:43 -0700 | [diff] [blame] | 576 | TRACE_IRQS_ON | 
| Roland McGrath | d4d6715 | 2008-07-09 02:38:07 -0700 | [diff] [blame] | 577 | ENABLE_INTERRUPTS(CLBR_ANY)	# could let syscall_trace_leave() call | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 578 | # schedule() instead | 
|  | 579 | movl %esp, %eax | 
| Roland McGrath | d4d6715 | 2008-07-09 02:38:07 -0700 | [diff] [blame] | 580 | call syscall_trace_leave | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 581 | jmp resume_userspace | 
| Jan Beulich | 47a55cd | 2007-02-13 13:26:24 +0100 | [diff] [blame] | 582 | END(syscall_exit_work) | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 583 | CFI_ENDPROC | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 584 |  | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 585 | RING0_INT_FRAME			# can't unwind into user space anyway | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 586 | syscall_fault: | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 587 | GET_THREAD_INFO(%ebp) | 
| Jeremy Fitzhardinge | eb5b7b9 | 2006-12-07 02:14:02 +0100 | [diff] [blame] | 588 | movl $-EFAULT,PT_EAX(%esp) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 589 | jmp resume_userspace | 
| Jan Beulich | 47a55cd | 2007-02-13 13:26:24 +0100 | [diff] [blame] | 590 | END(syscall_fault) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 591 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 592 | syscall_badsys: | 
| Jeremy Fitzhardinge | eb5b7b9 | 2006-12-07 02:14:02 +0100 | [diff] [blame] | 593 | movl $-ENOSYS,PT_EAX(%esp) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 594 | jmp resume_userspace | 
| Jan Beulich | 47a55cd | 2007-02-13 13:26:24 +0100 | [diff] [blame] | 595 | END(syscall_badsys) | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 596 | CFI_ENDPROC | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 597 |  | 
|  | 598 | #define FIXUP_ESPFIX_STACK \ | 
| Stas Sergeev | be44d2a | 2006-12-07 02:14:01 +0100 | [diff] [blame] | 599 | /* since we are on a wrong stack, we cant make it a C code :( */ \ | 
| Jeremy Fitzhardinge | 7a61d35 | 2007-05-02 19:27:15 +0200 | [diff] [blame] | 600 | PER_CPU(gdt_page, %ebx); \ | 
| Stas Sergeev | be44d2a | 2006-12-07 02:14:01 +0100 | [diff] [blame] | 601 | GET_DESC_BASE(GDT_ENTRY_ESPFIX_SS, %ebx, %eax, %ax, %al, %ah); \ | 
|  | 602 | addl %esp, %eax; \ | 
|  | 603 | pushl $__KERNEL_DS; \ | 
|  | 604 | CFI_ADJUST_CFA_OFFSET 4; \ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 605 | pushl %eax; \ | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 606 | CFI_ADJUST_CFA_OFFSET 4; \ | 
| Stas Sergeev | be44d2a | 2006-12-07 02:14:01 +0100 | [diff] [blame] | 607 | lss (%esp), %esp; \ | 
|  | 608 | CFI_ADJUST_CFA_OFFSET -8; | 
|  | 609 | #define UNWIND_ESPFIX_STACK \ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 610 | movl %ss, %eax; \ | 
| Stas Sergeev | be44d2a | 2006-12-07 02:14:01 +0100 | [diff] [blame] | 611 | /* see if on espfix stack */ \ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 612 | cmpw $__ESPFIX_SS, %ax; \ | 
| Stas Sergeev | be44d2a | 2006-12-07 02:14:01 +0100 | [diff] [blame] | 613 | jne 27f; \ | 
|  | 614 | movl $__KERNEL_DS, %eax; \ | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 615 | movl %eax, %ds; \ | 
|  | 616 | movl %eax, %es; \ | 
| Stas Sergeev | be44d2a | 2006-12-07 02:14:01 +0100 | [diff] [blame] | 617 | /* switch to normal stack */ \ | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 618 | FIXUP_ESPFIX_STACK; \ | 
| Stas Sergeev | be44d2a | 2006-12-07 02:14:01 +0100 | [diff] [blame] | 619 | 27:; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 620 |  | 
|  | 621 | /* | 
|  | 622 | * Build the entry stubs and pointer table with | 
|  | 623 | * some assembler magic. | 
|  | 624 | */ | 
| Jan Beulich | 3e7622f | 2008-01-30 13:31:23 +0100 | [diff] [blame] | 625 | .section .rodata,"a" | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 626 | ENTRY(interrupt) | 
|  | 627 | .text | 
|  | 628 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 629 | ENTRY(irq_entries_start) | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 630 | RING0_INT_FRAME | 
| Jan Beulich | 47a55cd | 2007-02-13 13:26:24 +0100 | [diff] [blame] | 631 | vector=0 | 
| Yinghai Lu | 497c9a1 | 2008-08-19 20:50:28 -0700 | [diff] [blame] | 632 | .rept NR_VECTORS | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 633 | ALIGN | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 634 | .if vector | 
|  | 635 | CFI_ADJUST_CFA_OFFSET -4 | 
|  | 636 | .endif | 
| Rusty Russell | 19eadf9 | 2006-06-27 02:53:44 -0700 | [diff] [blame] | 637 | 1:	pushl $~(vector) | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 638 | CFI_ADJUST_CFA_OFFSET 4 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 639 | jmp common_interrupt | 
| Jan Beulich | 47a55cd | 2007-02-13 13:26:24 +0100 | [diff] [blame] | 640 | .previous | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 641 | .long 1b | 
| Jan Beulich | 47a55cd | 2007-02-13 13:26:24 +0100 | [diff] [blame] | 642 | .text | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 643 | vector=vector+1 | 
|  | 644 | .endr | 
| Jan Beulich | 47a55cd | 2007-02-13 13:26:24 +0100 | [diff] [blame] | 645 | END(irq_entries_start) | 
|  | 646 |  | 
|  | 647 | .previous | 
|  | 648 | END(interrupt) | 
|  | 649 | .previous | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 650 |  | 
| Ingo Molnar | 55f327f | 2006-07-03 00:24:43 -0700 | [diff] [blame] | 651 | /* | 
|  | 652 | * the CPU automatically disables interrupts when executing an IRQ vector, | 
|  | 653 | * so IRQ-flags tracing has to follow that: | 
|  | 654 | */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 655 | ALIGN | 
|  | 656 | common_interrupt: | 
|  | 657 | SAVE_ALL | 
| Ingo Molnar | 55f327f | 2006-07-03 00:24:43 -0700 | [diff] [blame] | 658 | TRACE_IRQS_OFF | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 659 | movl %esp,%eax | 
|  | 660 | call do_IRQ | 
|  | 661 | jmp ret_from_intr | 
| Jan Beulich | 47a55cd | 2007-02-13 13:26:24 +0100 | [diff] [blame] | 662 | ENDPROC(common_interrupt) | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 663 | CFI_ENDPROC | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 664 |  | 
|  | 665 | #define BUILD_INTERRUPT(name, nr)	\ | 
|  | 666 | ENTRY(name)				\ | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 667 | RING0_INT_FRAME;		\ | 
| Rusty Russell | 19eadf9 | 2006-06-27 02:53:44 -0700 | [diff] [blame] | 668 | pushl $~(nr);			\ | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 669 | CFI_ADJUST_CFA_OFFSET 4;	\ | 
|  | 670 | SAVE_ALL;			\ | 
| Ingo Molnar | 55f327f | 2006-07-03 00:24:43 -0700 | [diff] [blame] | 671 | TRACE_IRQS_OFF			\ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 672 | movl %esp,%eax;			\ | 
| Jeremy Fitzhardinge | f76c392 | 2007-05-02 19:27:05 +0200 | [diff] [blame] | 673 | call smp_##name;		\ | 
| Ingo Molnar | 55f327f | 2006-07-03 00:24:43 -0700 | [diff] [blame] | 674 | jmp ret_from_intr;		\ | 
| Jan Beulich | 47a55cd | 2007-02-13 13:26:24 +0100 | [diff] [blame] | 675 | CFI_ENDPROC;			\ | 
|  | 676 | ENDPROC(name) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 677 |  | 
|  | 678 | /* The include is where all of the SMP etc. interrupts come from */ | 
|  | 679 | #include "entry_arch.h" | 
|  | 680 |  | 
| Prasanna S.P | d28c439 | 2006-09-26 10:52:34 +0200 | [diff] [blame] | 681 | KPROBE_ENTRY(page_fault) | 
|  | 682 | RING0_EC_FRAME | 
|  | 683 | pushl $do_page_fault | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 684 | CFI_ADJUST_CFA_OFFSET 4 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 685 | ALIGN | 
|  | 686 | error_code: | 
| Jeremy Fitzhardinge | 464d1a7 | 2007-02-13 13:26:20 +0100 | [diff] [blame] | 687 | /* the function address is in %fs's slot on the stack */ | 
| Jeremy Fitzhardinge | f95d47c | 2006-12-07 02:14:02 +0100 | [diff] [blame] | 688 | pushl %es | 
|  | 689 | CFI_ADJUST_CFA_OFFSET 4 | 
|  | 690 | /*CFI_REL_OFFSET es, 0*/ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 691 | pushl %ds | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 692 | CFI_ADJUST_CFA_OFFSET 4 | 
|  | 693 | /*CFI_REL_OFFSET ds, 0*/ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 694 | pushl %eax | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 695 | CFI_ADJUST_CFA_OFFSET 4 | 
|  | 696 | CFI_REL_OFFSET eax, 0 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 697 | pushl %ebp | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 698 | CFI_ADJUST_CFA_OFFSET 4 | 
|  | 699 | CFI_REL_OFFSET ebp, 0 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 700 | pushl %edi | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 701 | CFI_ADJUST_CFA_OFFSET 4 | 
|  | 702 | CFI_REL_OFFSET edi, 0 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 703 | pushl %esi | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 704 | CFI_ADJUST_CFA_OFFSET 4 | 
|  | 705 | CFI_REL_OFFSET esi, 0 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 706 | pushl %edx | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 707 | CFI_ADJUST_CFA_OFFSET 4 | 
|  | 708 | CFI_REL_OFFSET edx, 0 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 709 | pushl %ecx | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 710 | CFI_ADJUST_CFA_OFFSET 4 | 
|  | 711 | CFI_REL_OFFSET ecx, 0 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 712 | pushl %ebx | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 713 | CFI_ADJUST_CFA_OFFSET 4 | 
|  | 714 | CFI_REL_OFFSET ebx, 0 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 715 | cld | 
| Jeremy Fitzhardinge | 464d1a7 | 2007-02-13 13:26:20 +0100 | [diff] [blame] | 716 | pushl %fs | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 717 | CFI_ADJUST_CFA_OFFSET 4 | 
| Jeremy Fitzhardinge | 464d1a7 | 2007-02-13 13:26:20 +0100 | [diff] [blame] | 718 | /*CFI_REL_OFFSET fs, 0*/ | 
| Jeremy Fitzhardinge | 7c3576d | 2007-05-02 19:27:16 +0200 | [diff] [blame] | 719 | movl $(__KERNEL_PERCPU), %ecx | 
| Jeremy Fitzhardinge | 464d1a7 | 2007-02-13 13:26:20 +0100 | [diff] [blame] | 720 | movl %ecx, %fs | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 721 | UNWIND_ESPFIX_STACK | 
|  | 722 | popl %ecx | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 723 | CFI_ADJUST_CFA_OFFSET -4 | 
|  | 724 | /*CFI_REGISTER es, ecx*/ | 
| Jeremy Fitzhardinge | 464d1a7 | 2007-02-13 13:26:20 +0100 | [diff] [blame] | 725 | movl PT_FS(%esp), %edi		# get the function address | 
| Jeremy Fitzhardinge | eb5b7b9 | 2006-12-07 02:14:02 +0100 | [diff] [blame] | 726 | movl PT_ORIG_EAX(%esp), %edx	# get the error code | 
| Jeremy Fitzhardinge | f95d47c | 2006-12-07 02:14:02 +0100 | [diff] [blame] | 727 | movl $-1, PT_ORIG_EAX(%esp)	# no syscall to restart | 
| Jeremy Fitzhardinge | 464d1a7 | 2007-02-13 13:26:20 +0100 | [diff] [blame] | 728 | mov  %ecx, PT_FS(%esp) | 
|  | 729 | /*CFI_REL_OFFSET fs, ES*/ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 730 | movl $(__USER_DS), %ecx | 
|  | 731 | movl %ecx, %ds | 
|  | 732 | movl %ecx, %es | 
| Alexander van Heukelum | 85cea51 | 2008-09-09 21:56:14 +0200 | [diff] [blame] | 733 | TRACE_IRQS_OFF | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 734 | movl %esp,%eax			# pt_regs pointer | 
|  | 735 | call *%edi | 
|  | 736 | jmp ret_from_exception | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 737 | CFI_ENDPROC | 
| Prasanna S.P | d28c439 | 2006-09-26 10:52:34 +0200 | [diff] [blame] | 738 | KPROBE_END(page_fault) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 739 |  | 
|  | 740 | ENTRY(coprocessor_error) | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 741 | RING0_INT_FRAME | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 742 | pushl $0 | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 743 | CFI_ADJUST_CFA_OFFSET 4 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 744 | pushl $do_coprocessor_error | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 745 | CFI_ADJUST_CFA_OFFSET 4 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 746 | jmp error_code | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 747 | CFI_ENDPROC | 
| Jan Beulich | 47a55cd | 2007-02-13 13:26:24 +0100 | [diff] [blame] | 748 | END(coprocessor_error) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 749 |  | 
|  | 750 | ENTRY(simd_coprocessor_error) | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 751 | RING0_INT_FRAME | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 752 | pushl $0 | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 753 | CFI_ADJUST_CFA_OFFSET 4 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 754 | pushl $do_simd_coprocessor_error | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 755 | CFI_ADJUST_CFA_OFFSET 4 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 756 | jmp error_code | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 757 | CFI_ENDPROC | 
| Jan Beulich | 47a55cd | 2007-02-13 13:26:24 +0100 | [diff] [blame] | 758 | END(simd_coprocessor_error) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 759 |  | 
|  | 760 | ENTRY(device_not_available) | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 761 | RING0_INT_FRAME | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 762 | pushl $-1			# mark this as an int | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 763 | CFI_ADJUST_CFA_OFFSET 4 | 
| Alexander van Heukelum | 7643e9b | 2008-09-09 21:56:02 +0200 | [diff] [blame] | 764 | pushl $do_device_not_available | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 765 | CFI_ADJUST_CFA_OFFSET 4 | 
| Alexander van Heukelum | 7643e9b | 2008-09-09 21:56:02 +0200 | [diff] [blame] | 766 | jmp error_code | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 767 | CFI_ENDPROC | 
| Jan Beulich | 47a55cd | 2007-02-13 13:26:24 +0100 | [diff] [blame] | 768 | END(device_not_available) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 769 |  | 
|  | 770 | /* | 
|  | 771 | * Debug traps and NMI can happen at the one SYSENTER instruction | 
|  | 772 | * that sets up the real kernel stack. Check here, since we can't | 
|  | 773 | * allow the wrong stack to be used. | 
|  | 774 | * | 
| H. Peter Anvin | faca622 | 2008-01-30 13:31:02 +0100 | [diff] [blame] | 775 | * "TSS_sysenter_sp0+12" is because the NMI/debug handler will have | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 776 | * already pushed 3 words if it hits on the sysenter instruction: | 
|  | 777 | * eflags, cs and eip. | 
|  | 778 | * | 
|  | 779 | * We just load the right stack, and push the three (known) values | 
|  | 780 | * by hand onto the new stack - while updating the return eip past | 
|  | 781 | * the instruction that would have done it for sysenter. | 
|  | 782 | */ | 
|  | 783 | #define FIX_STACK(offset, ok, label)		\ | 
|  | 784 | cmpw $__KERNEL_CS,4(%esp);		\ | 
|  | 785 | jne ok;					\ | 
|  | 786 | label:						\ | 
| H. Peter Anvin | faca622 | 2008-01-30 13:31:02 +0100 | [diff] [blame] | 787 | movl TSS_sysenter_sp0+offset(%esp),%esp;	\ | 
| Chuck Ebbert | a549b86 | 2006-09-26 10:52:37 +0200 | [diff] [blame] | 788 | CFI_DEF_CFA esp, 0;			\ | 
|  | 789 | CFI_UNDEFINED eip;			\ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 790 | pushfl;					\ | 
| Chuck Ebbert | a549b86 | 2006-09-26 10:52:37 +0200 | [diff] [blame] | 791 | CFI_ADJUST_CFA_OFFSET 4;		\ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 792 | pushl $__KERNEL_CS;			\ | 
| Chuck Ebbert | a549b86 | 2006-09-26 10:52:37 +0200 | [diff] [blame] | 793 | CFI_ADJUST_CFA_OFFSET 4;		\ | 
|  | 794 | pushl $sysenter_past_esp;		\ | 
|  | 795 | CFI_ADJUST_CFA_OFFSET 4;		\ | 
|  | 796 | CFI_REL_OFFSET eip, 0 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 797 |  | 
| Prasanna S Panchamukhi | 3d97ae5 | 2005-09-06 15:19:27 -0700 | [diff] [blame] | 798 | KPROBE_ENTRY(debug) | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 799 | RING0_INT_FRAME | 
| Roland McGrath | 0aa97fb | 2008-01-30 13:30:43 +0100 | [diff] [blame] | 800 | cmpl $ia32_sysenter_target,(%esp) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 801 | jne debug_stack_correct | 
|  | 802 | FIX_STACK(12, debug_stack_correct, debug_esp_fix_insn) | 
|  | 803 | debug_stack_correct: | 
|  | 804 | pushl $-1			# mark this as an int | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 805 | CFI_ADJUST_CFA_OFFSET 4 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 806 | SAVE_ALL | 
| Alexander van Heukelum | 43024a8 | 2008-09-09 21:56:15 +0200 | [diff] [blame] | 807 | TRACE_IRQS_OFF | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 808 | xorl %edx,%edx			# error code 0 | 
|  | 809 | movl %esp,%eax			# pt_regs pointer | 
|  | 810 | call do_debug | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 811 | jmp ret_from_exception | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 812 | CFI_ENDPROC | 
| Prasanna S.P | d28c439 | 2006-09-26 10:52:34 +0200 | [diff] [blame] | 813 | KPROBE_END(debug) | 
|  | 814 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 815 | /* | 
|  | 816 | * NMI is doubly nasty. It can happen _while_ we're handling | 
|  | 817 | * a debug fault, and the debug fault hasn't yet been able to | 
|  | 818 | * clear up the stack. So we first check whether we got  an | 
|  | 819 | * NMI on the sysenter entry path, but after that we need to | 
|  | 820 | * check whether we got an NMI on the debug path where the debug | 
|  | 821 | * fault happened on the sysenter path. | 
|  | 822 | */ | 
| Fernando Luis Vázquez Cao | 0603975 | 2006-09-26 10:52:36 +0200 | [diff] [blame] | 823 | KPROBE_ENTRY(nmi) | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 824 | RING0_INT_FRAME | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 825 | pushl %eax | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 826 | CFI_ADJUST_CFA_OFFSET 4 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 827 | movl %ss, %eax | 
|  | 828 | cmpw $__ESPFIX_SS, %ax | 
|  | 829 | popl %eax | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 830 | CFI_ADJUST_CFA_OFFSET -4 | 
| Stas Sergeev | be44d2a | 2006-12-07 02:14:01 +0100 | [diff] [blame] | 831 | je nmi_espfix_stack | 
| Roland McGrath | 0aa97fb | 2008-01-30 13:30:43 +0100 | [diff] [blame] | 832 | cmpl $ia32_sysenter_target,(%esp) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 833 | je nmi_stack_fixup | 
|  | 834 | pushl %eax | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 835 | CFI_ADJUST_CFA_OFFSET 4 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 836 | movl %esp,%eax | 
|  | 837 | /* Do not access memory above the end of our stack page, | 
|  | 838 | * it might not exist. | 
|  | 839 | */ | 
|  | 840 | andl $(THREAD_SIZE-1),%eax | 
|  | 841 | cmpl $(THREAD_SIZE-20),%eax | 
|  | 842 | popl %eax | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 843 | CFI_ADJUST_CFA_OFFSET -4 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 844 | jae nmi_stack_correct | 
| Roland McGrath | 0aa97fb | 2008-01-30 13:30:43 +0100 | [diff] [blame] | 845 | cmpl $ia32_sysenter_target,12(%esp) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 846 | je nmi_debug_stack_check | 
|  | 847 | nmi_stack_correct: | 
| Chuck Ebbert | a549b86 | 2006-09-26 10:52:37 +0200 | [diff] [blame] | 848 | /* We have a RING0_INT_FRAME here */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 849 | pushl %eax | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 850 | CFI_ADJUST_CFA_OFFSET 4 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 851 | SAVE_ALL | 
| Alexander van Heukelum | e0c7317 | 2008-09-09 21:56:16 +0200 | [diff] [blame] | 852 | TRACE_IRQS_OFF | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 853 | xorl %edx,%edx		# zero error code | 
|  | 854 | movl %esp,%eax		# pt_regs pointer | 
|  | 855 | call do_nmi | 
| Ingo Molnar | 55f327f | 2006-07-03 00:24:43 -0700 | [diff] [blame] | 856 | jmp restore_nocheck_notrace | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 857 | CFI_ENDPROC | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 858 |  | 
|  | 859 | nmi_stack_fixup: | 
| Chuck Ebbert | a549b86 | 2006-09-26 10:52:37 +0200 | [diff] [blame] | 860 | RING0_INT_FRAME | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 861 | FIX_STACK(12,nmi_stack_correct, 1) | 
|  | 862 | jmp nmi_stack_correct | 
| Chuck Ebbert | a549b86 | 2006-09-26 10:52:37 +0200 | [diff] [blame] | 863 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 864 | nmi_debug_stack_check: | 
| Chuck Ebbert | a549b86 | 2006-09-26 10:52:37 +0200 | [diff] [blame] | 865 | /* We have a RING0_INT_FRAME here */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 866 | cmpw $__KERNEL_CS,16(%esp) | 
|  | 867 | jne nmi_stack_correct | 
| Jan Beulich | e271820 | 2005-11-13 16:06:52 -0800 | [diff] [blame] | 868 | cmpl $debug,(%esp) | 
|  | 869 | jb nmi_stack_correct | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 870 | cmpl $debug_esp_fix_insn,(%esp) | 
| Jan Beulich | e271820 | 2005-11-13 16:06:52 -0800 | [diff] [blame] | 871 | ja nmi_stack_correct | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 872 | FIX_STACK(24,nmi_stack_correct, 1) | 
|  | 873 | jmp nmi_stack_correct | 
|  | 874 |  | 
| Stas Sergeev | be44d2a | 2006-12-07 02:14:01 +0100 | [diff] [blame] | 875 | nmi_espfix_stack: | 
| Chuck Ebbert | a549b86 | 2006-09-26 10:52:37 +0200 | [diff] [blame] | 876 | /* We have a RING0_INT_FRAME here. | 
|  | 877 | * | 
|  | 878 | * create the pointer to lss back | 
|  | 879 | */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 880 | pushl %ss | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 881 | CFI_ADJUST_CFA_OFFSET 4 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 882 | pushl %esp | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 883 | CFI_ADJUST_CFA_OFFSET 4 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 884 | addw $4, (%esp) | 
|  | 885 | /* copy the iret frame of 12 bytes */ | 
|  | 886 | .rept 3 | 
|  | 887 | pushl 16(%esp) | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 888 | CFI_ADJUST_CFA_OFFSET 4 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 889 | .endr | 
|  | 890 | pushl %eax | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 891 | CFI_ADJUST_CFA_OFFSET 4 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 892 | SAVE_ALL | 
| Alexander van Heukelum | e0c7317 | 2008-09-09 21:56:16 +0200 | [diff] [blame] | 893 | TRACE_IRQS_OFF | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 894 | FIXUP_ESPFIX_STACK		# %eax == %esp | 
|  | 895 | xorl %edx,%edx			# zero error code | 
|  | 896 | call do_nmi | 
|  | 897 | RESTORE_REGS | 
| Stas Sergeev | be44d2a | 2006-12-07 02:14:01 +0100 | [diff] [blame] | 898 | lss 12+4(%esp), %esp		# back to espfix stack | 
|  | 899 | CFI_ADJUST_CFA_OFFSET -24 | 
| Ingo Molnar | 3701d863 | 2008-02-09 23:24:08 +0100 | [diff] [blame] | 900 | jmp irq_return | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 901 | CFI_ENDPROC | 
| Fernando Luis Vázquez Cao | 0603975 | 2006-09-26 10:52:36 +0200 | [diff] [blame] | 902 | KPROBE_END(nmi) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 903 |  | 
| Rusty Russell | d3561b7 | 2006-12-07 02:14:07 +0100 | [diff] [blame] | 904 | #ifdef CONFIG_PARAVIRT | 
|  | 905 | ENTRY(native_iret) | 
| Ingo Molnar | 3701d863 | 2008-02-09 23:24:08 +0100 | [diff] [blame] | 906 | iret | 
| Rusty Russell | d3561b7 | 2006-12-07 02:14:07 +0100 | [diff] [blame] | 907 | .section __ex_table,"a" | 
|  | 908 | .align 4 | 
| Ingo Molnar | 3701d863 | 2008-02-09 23:24:08 +0100 | [diff] [blame] | 909 | .long native_iret, iret_exc | 
| Rusty Russell | d3561b7 | 2006-12-07 02:14:07 +0100 | [diff] [blame] | 910 | .previous | 
| Jan Beulich | 47a55cd | 2007-02-13 13:26:24 +0100 | [diff] [blame] | 911 | END(native_iret) | 
| Rusty Russell | d3561b7 | 2006-12-07 02:14:07 +0100 | [diff] [blame] | 912 |  | 
| Jeremy Fitzhardinge | d75cd22 | 2008-06-25 00:19:26 -0400 | [diff] [blame] | 913 | ENTRY(native_irq_enable_sysexit) | 
| Rusty Russell | d3561b7 | 2006-12-07 02:14:07 +0100 | [diff] [blame] | 914 | sti | 
|  | 915 | sysexit | 
| Jeremy Fitzhardinge | d75cd22 | 2008-06-25 00:19:26 -0400 | [diff] [blame] | 916 | END(native_irq_enable_sysexit) | 
| Rusty Russell | d3561b7 | 2006-12-07 02:14:07 +0100 | [diff] [blame] | 917 | #endif | 
|  | 918 |  | 
| Prasanna S Panchamukhi | 3d97ae5 | 2005-09-06 15:19:27 -0700 | [diff] [blame] | 919 | KPROBE_ENTRY(int3) | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 920 | RING0_INT_FRAME | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 921 | pushl $-1			# mark this as an int | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 922 | CFI_ADJUST_CFA_OFFSET 4 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 923 | SAVE_ALL | 
| Alexander van Heukelum | a790392 | 2008-09-09 21:56:17 +0200 | [diff] [blame] | 924 | TRACE_IRQS_OFF | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 925 | xorl %edx,%edx		# zero error code | 
|  | 926 | movl %esp,%eax		# pt_regs pointer | 
|  | 927 | call do_int3 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 928 | jmp ret_from_exception | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 929 | CFI_ENDPROC | 
| Prasanna S.P | d28c439 | 2006-09-26 10:52:34 +0200 | [diff] [blame] | 930 | KPROBE_END(int3) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 931 |  | 
|  | 932 | ENTRY(overflow) | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 933 | RING0_INT_FRAME | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 934 | pushl $0 | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 935 | CFI_ADJUST_CFA_OFFSET 4 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 936 | pushl $do_overflow | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 937 | CFI_ADJUST_CFA_OFFSET 4 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 938 | jmp error_code | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 939 | CFI_ENDPROC | 
| Jan Beulich | 47a55cd | 2007-02-13 13:26:24 +0100 | [diff] [blame] | 940 | END(overflow) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 941 |  | 
|  | 942 | ENTRY(bounds) | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 943 | RING0_INT_FRAME | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 944 | pushl $0 | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 945 | CFI_ADJUST_CFA_OFFSET 4 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 946 | pushl $do_bounds | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 947 | CFI_ADJUST_CFA_OFFSET 4 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 948 | jmp error_code | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 949 | CFI_ENDPROC | 
| Jan Beulich | 47a55cd | 2007-02-13 13:26:24 +0100 | [diff] [blame] | 950 | END(bounds) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 951 |  | 
|  | 952 | ENTRY(invalid_op) | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 953 | RING0_INT_FRAME | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 954 | pushl $0 | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 955 | CFI_ADJUST_CFA_OFFSET 4 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 956 | pushl $do_invalid_op | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 957 | CFI_ADJUST_CFA_OFFSET 4 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 958 | jmp error_code | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 959 | CFI_ENDPROC | 
| Jan Beulich | 47a55cd | 2007-02-13 13:26:24 +0100 | [diff] [blame] | 960 | END(invalid_op) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 961 |  | 
|  | 962 | ENTRY(coprocessor_segment_overrun) | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 963 | RING0_INT_FRAME | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 964 | pushl $0 | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 965 | CFI_ADJUST_CFA_OFFSET 4 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 966 | pushl $do_coprocessor_segment_overrun | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 967 | CFI_ADJUST_CFA_OFFSET 4 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 968 | jmp error_code | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 969 | CFI_ENDPROC | 
| Jan Beulich | 47a55cd | 2007-02-13 13:26:24 +0100 | [diff] [blame] | 970 | END(coprocessor_segment_overrun) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 971 |  | 
|  | 972 | ENTRY(invalid_TSS) | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 973 | RING0_EC_FRAME | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 974 | pushl $do_invalid_TSS | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 975 | CFI_ADJUST_CFA_OFFSET 4 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 976 | jmp error_code | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 977 | CFI_ENDPROC | 
| Jan Beulich | 47a55cd | 2007-02-13 13:26:24 +0100 | [diff] [blame] | 978 | END(invalid_TSS) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 979 |  | 
|  | 980 | ENTRY(segment_not_present) | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 981 | RING0_EC_FRAME | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 982 | pushl $do_segment_not_present | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 983 | CFI_ADJUST_CFA_OFFSET 4 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 984 | jmp error_code | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 985 | CFI_ENDPROC | 
| Jan Beulich | 47a55cd | 2007-02-13 13:26:24 +0100 | [diff] [blame] | 986 | END(segment_not_present) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 987 |  | 
|  | 988 | ENTRY(stack_segment) | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 989 | RING0_EC_FRAME | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 990 | pushl $do_stack_segment | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 991 | CFI_ADJUST_CFA_OFFSET 4 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 992 | jmp error_code | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 993 | CFI_ENDPROC | 
| Jan Beulich | 47a55cd | 2007-02-13 13:26:24 +0100 | [diff] [blame] | 994 | END(stack_segment) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 995 |  | 
| Prasanna S Panchamukhi | 3d97ae5 | 2005-09-06 15:19:27 -0700 | [diff] [blame] | 996 | KPROBE_ENTRY(general_protection) | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 997 | RING0_EC_FRAME | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 998 | pushl $do_general_protection | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 999 | CFI_ADJUST_CFA_OFFSET 4 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1000 | jmp error_code | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 1001 | CFI_ENDPROC | 
| Prasanna S.P | d28c439 | 2006-09-26 10:52:34 +0200 | [diff] [blame] | 1002 | KPROBE_END(general_protection) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1003 |  | 
|  | 1004 | ENTRY(alignment_check) | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 1005 | RING0_EC_FRAME | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1006 | pushl $do_alignment_check | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 1007 | CFI_ADJUST_CFA_OFFSET 4 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1008 | jmp error_code | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 1009 | CFI_ENDPROC | 
| Jan Beulich | 47a55cd | 2007-02-13 13:26:24 +0100 | [diff] [blame] | 1010 | END(alignment_check) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1011 |  | 
| Prasanna S.P | d28c439 | 2006-09-26 10:52:34 +0200 | [diff] [blame] | 1012 | ENTRY(divide_error) | 
|  | 1013 | RING0_INT_FRAME | 
|  | 1014 | pushl $0			# no error code | 
|  | 1015 | CFI_ADJUST_CFA_OFFSET 4 | 
|  | 1016 | pushl $do_divide_error | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 1017 | CFI_ADJUST_CFA_OFFSET 4 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1018 | jmp error_code | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 1019 | CFI_ENDPROC | 
| Jan Beulich | 47a55cd | 2007-02-13 13:26:24 +0100 | [diff] [blame] | 1020 | END(divide_error) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1021 |  | 
|  | 1022 | #ifdef CONFIG_X86_MCE | 
|  | 1023 | ENTRY(machine_check) | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 1024 | RING0_INT_FRAME | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1025 | pushl $0 | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 1026 | CFI_ADJUST_CFA_OFFSET 4 | 
| Andi Kleen | d2f6f7a | 2008-10-21 22:45:22 +0200 | [diff] [blame] | 1027 | pushl machine_check_vector | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 1028 | CFI_ADJUST_CFA_OFFSET 4 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1029 | jmp error_code | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 1030 | CFI_ENDPROC | 
| Jan Beulich | 47a55cd | 2007-02-13 13:26:24 +0100 | [diff] [blame] | 1031 | END(machine_check) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1032 | #endif | 
|  | 1033 |  | 
|  | 1034 | ENTRY(spurious_interrupt_bug) | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 1035 | RING0_INT_FRAME | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1036 | pushl $0 | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 1037 | CFI_ADJUST_CFA_OFFSET 4 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1038 | pushl $do_spurious_interrupt_bug | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 1039 | CFI_ADJUST_CFA_OFFSET 4 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1040 | jmp error_code | 
| Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 1041 | CFI_ENDPROC | 
| Jan Beulich | 47a55cd | 2007-02-13 13:26:24 +0100 | [diff] [blame] | 1042 | END(spurious_interrupt_bug) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1043 |  | 
| Andi Kleen | 02ba1a3 | 2006-09-26 10:52:35 +0200 | [diff] [blame] | 1044 | ENTRY(kernel_thread_helper) | 
|  | 1045 | pushl $0		# fake return address for unwinder | 
|  | 1046 | CFI_STARTPROC | 
|  | 1047 | movl %edx,%eax | 
|  | 1048 | push %edx | 
|  | 1049 | CFI_ADJUST_CFA_OFFSET 4 | 
|  | 1050 | call *%ebx | 
|  | 1051 | push %eax | 
|  | 1052 | CFI_ADJUST_CFA_OFFSET 4 | 
|  | 1053 | call do_exit | 
|  | 1054 | CFI_ENDPROC | 
|  | 1055 | ENDPROC(kernel_thread_helper) | 
|  | 1056 |  | 
| Jeremy Fitzhardinge | 5ead97c | 2007-07-17 18:37:04 -0700 | [diff] [blame] | 1057 | #ifdef CONFIG_XEN | 
| Jeremy Fitzhardinge | e2a81ba | 2008-03-17 16:37:17 -0700 | [diff] [blame] | 1058 | /* Xen doesn't set %esp to be precisely what the normal sysenter | 
|  | 1059 | entrypoint expects, so fix it up before using the normal path. */ | 
|  | 1060 | ENTRY(xen_sysenter_target) | 
|  | 1061 | RING0_INT_FRAME | 
|  | 1062 | addl $5*4, %esp		/* remove xen-provided frame */ | 
| Jan Beulich | 2ddf9b7 | 2008-07-18 13:32:23 +0100 | [diff] [blame] | 1063 | CFI_ADJUST_CFA_OFFSET -5*4 | 
| Jeremy Fitzhardinge | e2a81ba | 2008-03-17 16:37:17 -0700 | [diff] [blame] | 1064 | jmp sysenter_past_esp | 
| Glauber Costa | 557d7d4 | 2008-07-10 15:09:20 -0300 | [diff] [blame] | 1065 | CFI_ENDPROC | 
| Jeremy Fitzhardinge | e2a81ba | 2008-03-17 16:37:17 -0700 | [diff] [blame] | 1066 |  | 
| Jeremy Fitzhardinge | 5ead97c | 2007-07-17 18:37:04 -0700 | [diff] [blame] | 1067 | ENTRY(xen_hypervisor_callback) | 
|  | 1068 | CFI_STARTPROC | 
|  | 1069 | pushl $0 | 
|  | 1070 | CFI_ADJUST_CFA_OFFSET 4 | 
|  | 1071 | SAVE_ALL | 
|  | 1072 | TRACE_IRQS_OFF | 
| Jeremy Fitzhardinge | 9ec2b80 | 2007-07-17 18:37:07 -0700 | [diff] [blame] | 1073 |  | 
|  | 1074 | /* Check to see if we got the event in the critical | 
|  | 1075 | region in xen_iret_direct, after we've reenabled | 
|  | 1076 | events and checked for pending events.  This simulates | 
|  | 1077 | iret instruction's behaviour where it delivers a | 
|  | 1078 | pending interrupt when enabling interrupts. */ | 
|  | 1079 | movl PT_EIP(%esp),%eax | 
|  | 1080 | cmpl $xen_iret_start_crit,%eax | 
|  | 1081 | jb   1f | 
|  | 1082 | cmpl $xen_iret_end_crit,%eax | 
|  | 1083 | jae  1f | 
|  | 1084 |  | 
| Jeremy Fitzhardinge | 0f2c876 | 2008-03-17 16:37:22 -0700 | [diff] [blame] | 1085 | jmp  xen_iret_crit_fixup | 
| Jeremy Fitzhardinge | 9ec2b80 | 2007-07-17 18:37:07 -0700 | [diff] [blame] | 1086 |  | 
| Jeremy Fitzhardinge | e2a81ba | 2008-03-17 16:37:17 -0700 | [diff] [blame] | 1087 | ENTRY(xen_do_upcall) | 
| Jeremy Fitzhardinge | b77797f | 2008-04-02 10:54:11 -0700 | [diff] [blame] | 1088 | 1:	mov %esp, %eax | 
| Jeremy Fitzhardinge | 5ead97c | 2007-07-17 18:37:04 -0700 | [diff] [blame] | 1089 | call xen_evtchn_do_upcall | 
|  | 1090 | jmp  ret_from_intr | 
|  | 1091 | CFI_ENDPROC | 
|  | 1092 | ENDPROC(xen_hypervisor_callback) | 
|  | 1093 |  | 
|  | 1094 | # Hypervisor uses this for application faults while it executes. | 
|  | 1095 | # We get here for two reasons: | 
|  | 1096 | #  1. Fault while reloading DS, ES, FS or GS | 
|  | 1097 | #  2. Fault while executing IRET | 
|  | 1098 | # Category 1 we fix up by reattempting the load, and zeroing the segment | 
|  | 1099 | # register if the load fails. | 
|  | 1100 | # Category 2 we fix up by jumping to do_iret_error. We cannot use the | 
|  | 1101 | # normal Linux return path in this case because if we use the IRET hypercall | 
|  | 1102 | # to pop the stack frame we end up in an infinite loop of failsafe callbacks. | 
|  | 1103 | # We distinguish between categories by maintaining a status value in EAX. | 
|  | 1104 | ENTRY(xen_failsafe_callback) | 
|  | 1105 | CFI_STARTPROC | 
|  | 1106 | pushl %eax | 
|  | 1107 | CFI_ADJUST_CFA_OFFSET 4 | 
|  | 1108 | movl $1,%eax | 
|  | 1109 | 1:	mov 4(%esp),%ds | 
|  | 1110 | 2:	mov 8(%esp),%es | 
|  | 1111 | 3:	mov 12(%esp),%fs | 
|  | 1112 | 4:	mov 16(%esp),%gs | 
|  | 1113 | testl %eax,%eax | 
|  | 1114 | popl %eax | 
|  | 1115 | CFI_ADJUST_CFA_OFFSET -4 | 
|  | 1116 | lea 16(%esp),%esp | 
|  | 1117 | CFI_ADJUST_CFA_OFFSET -16 | 
|  | 1118 | jz 5f | 
|  | 1119 | addl $16,%esp | 
|  | 1120 | jmp iret_exc		# EAX != 0 => Category 2 (Bad IRET) | 
|  | 1121 | 5:	pushl $0		# EAX == 0 => Category 1 (Bad segment) | 
|  | 1122 | CFI_ADJUST_CFA_OFFSET 4 | 
|  | 1123 | SAVE_ALL | 
|  | 1124 | jmp ret_from_exception | 
|  | 1125 | CFI_ENDPROC | 
|  | 1126 |  | 
|  | 1127 | .section .fixup,"ax" | 
|  | 1128 | 6:	xorl %eax,%eax | 
|  | 1129 | movl %eax,4(%esp) | 
|  | 1130 | jmp 1b | 
|  | 1131 | 7:	xorl %eax,%eax | 
|  | 1132 | movl %eax,8(%esp) | 
|  | 1133 | jmp 2b | 
|  | 1134 | 8:	xorl %eax,%eax | 
|  | 1135 | movl %eax,12(%esp) | 
|  | 1136 | jmp 3b | 
|  | 1137 | 9:	xorl %eax,%eax | 
|  | 1138 | movl %eax,16(%esp) | 
|  | 1139 | jmp 4b | 
|  | 1140 | .previous | 
|  | 1141 | .section __ex_table,"a" | 
|  | 1142 | .align 4 | 
|  | 1143 | .long 1b,6b | 
|  | 1144 | .long 2b,7b | 
|  | 1145 | .long 3b,8b | 
|  | 1146 | .long 4b,9b | 
|  | 1147 | .previous | 
|  | 1148 | ENDPROC(xen_failsafe_callback) | 
|  | 1149 |  | 
|  | 1150 | #endif	/* CONFIG_XEN */ | 
|  | 1151 |  | 
| Arnaldo Carvalho de Melo | 16444a8 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 1152 | #ifdef CONFIG_FTRACE | 
| Steven Rostedt | d61f82d | 2008-05-12 21:20:43 +0200 | [diff] [blame] | 1153 | #ifdef CONFIG_DYNAMIC_FTRACE | 
|  | 1154 |  | 
|  | 1155 | ENTRY(mcount) | 
| Steven Rostedt | d61f82d | 2008-05-12 21:20:43 +0200 | [diff] [blame] | 1156 | ret | 
|  | 1157 | END(mcount) | 
|  | 1158 |  | 
|  | 1159 | ENTRY(ftrace_caller) | 
|  | 1160 | pushl %eax | 
|  | 1161 | pushl %ecx | 
|  | 1162 | pushl %edx | 
|  | 1163 | movl 0xc(%esp), %eax | 
|  | 1164 | movl 0x4(%ebp), %edx | 
| Abhishek Sagar | 395a59d | 2008-06-21 23:47:27 +0530 | [diff] [blame] | 1165 | subl $MCOUNT_INSN_SIZE, %eax | 
| Steven Rostedt | d61f82d | 2008-05-12 21:20:43 +0200 | [diff] [blame] | 1166 |  | 
|  | 1167 | .globl ftrace_call | 
|  | 1168 | ftrace_call: | 
|  | 1169 | call ftrace_stub | 
|  | 1170 |  | 
|  | 1171 | popl %edx | 
|  | 1172 | popl %ecx | 
|  | 1173 | popl %eax | 
|  | 1174 |  | 
|  | 1175 | .globl ftrace_stub | 
|  | 1176 | ftrace_stub: | 
|  | 1177 | ret | 
|  | 1178 | END(ftrace_caller) | 
|  | 1179 |  | 
|  | 1180 | #else /* ! CONFIG_DYNAMIC_FTRACE */ | 
|  | 1181 |  | 
| Arnaldo Carvalho de Melo | 16444a8 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 1182 | ENTRY(mcount) | 
|  | 1183 | cmpl $ftrace_stub, ftrace_trace_function | 
|  | 1184 | jnz trace | 
| Arnaldo Carvalho de Melo | 16444a8 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 1185 | .globl ftrace_stub | 
|  | 1186 | ftrace_stub: | 
|  | 1187 | ret | 
|  | 1188 |  | 
|  | 1189 | /* taken from glibc */ | 
|  | 1190 | trace: | 
|  | 1191 | pushl %eax | 
|  | 1192 | pushl %ecx | 
|  | 1193 | pushl %edx | 
|  | 1194 | movl 0xc(%esp), %eax | 
|  | 1195 | movl 0x4(%ebp), %edx | 
| Abhishek Sagar | 395a59d | 2008-06-21 23:47:27 +0530 | [diff] [blame] | 1196 | subl $MCOUNT_INSN_SIZE, %eax | 
| Arnaldo Carvalho de Melo | 16444a8 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 1197 |  | 
| Steven Rostedt | d61f82d | 2008-05-12 21:20:43 +0200 | [diff] [blame] | 1198 | call *ftrace_trace_function | 
| Arnaldo Carvalho de Melo | 16444a8 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 1199 |  | 
|  | 1200 | popl %edx | 
|  | 1201 | popl %ecx | 
|  | 1202 | popl %eax | 
|  | 1203 |  | 
|  | 1204 | jmp ftrace_stub | 
|  | 1205 | END(mcount) | 
| Steven Rostedt | d61f82d | 2008-05-12 21:20:43 +0200 | [diff] [blame] | 1206 | #endif /* CONFIG_DYNAMIC_FTRACE */ | 
|  | 1207 | #endif /* CONFIG_FTRACE */ | 
| Arnaldo Carvalho de Melo | 16444a8 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 1208 |  | 
| Arjan van de Ven | bb152f5 | 2006-01-06 00:12:05 -0800 | [diff] [blame] | 1209 | .section .rodata,"a" | 
| Thomas Gleixner | 541054d | 2007-10-11 11:12:00 +0200 | [diff] [blame] | 1210 | #include "syscall_table_32.S" | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1211 |  | 
|  | 1212 | syscall_table_size=(.-sys_call_table) |