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