Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * linux/arch/i386/entry.S |
| 3 | * |
| 4 | * Copyright (C) 1991, 1992 Linus Torvalds |
| 5 | */ |
| 6 | |
| 7 | /* |
| 8 | * entry.S contains the system-call and fault low-level handling routines. |
| 9 | * This also contains the timer-interrupt handler, as well as all interrupts |
| 10 | * and faults that can result in a task-switch. |
| 11 | * |
| 12 | * NOTE: This code handles signal-recognition, which happens every time |
| 13 | * after a timer-interrupt and after each system call. |
| 14 | * |
| 15 | * I changed all the .align's to 4 (16 byte alignment), as that's faster |
| 16 | * on a 486. |
| 17 | * |
| 18 | * Stack layout in 'ret_from_system_call': |
| 19 | * ptrace needs to have all regs on the stack. |
| 20 | * if the order here is changed, it needs to be |
| 21 | * updated in fork.c:copy_process, signal.c:do_signal, |
| 22 | * ptrace.c and ptrace.h |
| 23 | * |
| 24 | * 0(%esp) - %ebx |
| 25 | * 4(%esp) - %ecx |
| 26 | * 8(%esp) - %edx |
| 27 | * C(%esp) - %esi |
| 28 | * 10(%esp) - %edi |
| 29 | * 14(%esp) - %ebp |
| 30 | * 18(%esp) - %eax |
| 31 | * 1C(%esp) - %ds |
| 32 | * 20(%esp) - %es |
| 33 | * 24(%esp) - orig_eax |
| 34 | * 28(%esp) - %eip |
| 35 | * 2C(%esp) - %cs |
| 36 | * 30(%esp) - %eflags |
| 37 | * 34(%esp) - %oldesp |
| 38 | * 38(%esp) - %oldss |
| 39 | * |
| 40 | * "current" is in register %ebx during any slow entries. |
| 41 | */ |
| 42 | |
Linus 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> |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 51 | #include <asm/dwarf2.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | #include "irq_vectors.h" |
| 53 | |
| 54 | #define nr_syscalls ((syscall_table_size)/4) |
| 55 | |
| 56 | EBX = 0x00 |
| 57 | ECX = 0x04 |
| 58 | EDX = 0x08 |
| 59 | ESI = 0x0C |
| 60 | EDI = 0x10 |
| 61 | EBP = 0x14 |
| 62 | EAX = 0x18 |
| 63 | DS = 0x1C |
| 64 | ES = 0x20 |
| 65 | ORIG_EAX = 0x24 |
| 66 | EIP = 0x28 |
| 67 | CS = 0x2C |
| 68 | EFLAGS = 0x30 |
| 69 | OLDESP = 0x34 |
| 70 | OLDSS = 0x38 |
| 71 | |
| 72 | CF_MASK = 0x00000001 |
| 73 | TF_MASK = 0x00000100 |
| 74 | IF_MASK = 0x00000200 |
| 75 | DF_MASK = 0x00000400 |
| 76 | NT_MASK = 0x00004000 |
| 77 | VM_MASK = 0x00020000 |
| 78 | |
Rusty Russell | 0da5db3 | 2006-09-26 10:52:39 +0200 | [diff] [blame^] | 79 | /* These are replaces for paravirtualization */ |
| 80 | #define DISABLE_INTERRUPTS cli |
| 81 | #define ENABLE_INTERRUPTS sti |
| 82 | #define ENABLE_INTERRUPTS_SYSEXIT sti; sysexit |
| 83 | #define INTERRUPT_RETURN iret |
| 84 | #define GET_CR0_INTO_EAX movl %cr0, %eax |
| 85 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 86 | #ifdef CONFIG_PREEMPT |
Rusty Russell | 0da5db3 | 2006-09-26 10:52:39 +0200 | [diff] [blame^] | 87 | #define preempt_stop DISABLE_INTERRUPTS; TRACE_IRQS_OFF |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 88 | #else |
| 89 | #define preempt_stop |
| 90 | #define resume_kernel restore_nocheck |
| 91 | #endif |
| 92 | |
Ingo Molnar | 55f327f | 2006-07-03 00:24:43 -0700 | [diff] [blame] | 93 | .macro TRACE_IRQS_IRET |
| 94 | #ifdef CONFIG_TRACE_IRQFLAGS |
| 95 | testl $IF_MASK,EFLAGS(%esp) # interrupts off? |
| 96 | jz 1f |
| 97 | TRACE_IRQS_ON |
| 98 | 1: |
| 99 | #endif |
| 100 | .endm |
| 101 | |
Aleksey Gorelov | 4031ff3 | 2006-06-27 02:53:48 -0700 | [diff] [blame] | 102 | #ifdef CONFIG_VM86 |
| 103 | #define resume_userspace_sig check_userspace |
| 104 | #else |
| 105 | #define resume_userspace_sig resume_userspace |
| 106 | #endif |
| 107 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 108 | #define SAVE_ALL \ |
| 109 | cld; \ |
| 110 | pushl %es; \ |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 111 | CFI_ADJUST_CFA_OFFSET 4;\ |
| 112 | /*CFI_REL_OFFSET es, 0;*/\ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 113 | pushl %ds; \ |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 114 | CFI_ADJUST_CFA_OFFSET 4;\ |
| 115 | /*CFI_REL_OFFSET ds, 0;*/\ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 116 | pushl %eax; \ |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 117 | CFI_ADJUST_CFA_OFFSET 4;\ |
| 118 | CFI_REL_OFFSET eax, 0;\ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 119 | pushl %ebp; \ |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 120 | CFI_ADJUST_CFA_OFFSET 4;\ |
| 121 | CFI_REL_OFFSET ebp, 0;\ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 122 | pushl %edi; \ |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 123 | CFI_ADJUST_CFA_OFFSET 4;\ |
| 124 | CFI_REL_OFFSET edi, 0;\ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 125 | pushl %esi; \ |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 126 | CFI_ADJUST_CFA_OFFSET 4;\ |
| 127 | CFI_REL_OFFSET esi, 0;\ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 128 | pushl %edx; \ |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 129 | CFI_ADJUST_CFA_OFFSET 4;\ |
| 130 | CFI_REL_OFFSET edx, 0;\ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 131 | pushl %ecx; \ |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 132 | CFI_ADJUST_CFA_OFFSET 4;\ |
| 133 | CFI_REL_OFFSET ecx, 0;\ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 134 | pushl %ebx; \ |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 135 | CFI_ADJUST_CFA_OFFSET 4;\ |
| 136 | CFI_REL_OFFSET ebx, 0;\ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 137 | movl $(__USER_DS), %edx; \ |
| 138 | movl %edx, %ds; \ |
| 139 | movl %edx, %es; |
| 140 | |
| 141 | #define RESTORE_INT_REGS \ |
| 142 | popl %ebx; \ |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 143 | CFI_ADJUST_CFA_OFFSET -4;\ |
| 144 | CFI_RESTORE ebx;\ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 145 | popl %ecx; \ |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 146 | CFI_ADJUST_CFA_OFFSET -4;\ |
| 147 | CFI_RESTORE ecx;\ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 148 | popl %edx; \ |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 149 | CFI_ADJUST_CFA_OFFSET -4;\ |
| 150 | CFI_RESTORE edx;\ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 151 | popl %esi; \ |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 152 | CFI_ADJUST_CFA_OFFSET -4;\ |
| 153 | CFI_RESTORE esi;\ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 154 | popl %edi; \ |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 155 | CFI_ADJUST_CFA_OFFSET -4;\ |
| 156 | CFI_RESTORE edi;\ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 157 | popl %ebp; \ |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 158 | CFI_ADJUST_CFA_OFFSET -4;\ |
| 159 | CFI_RESTORE ebp;\ |
| 160 | popl %eax; \ |
| 161 | CFI_ADJUST_CFA_OFFSET -4;\ |
| 162 | CFI_RESTORE eax |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 163 | |
| 164 | #define RESTORE_REGS \ |
| 165 | RESTORE_INT_REGS; \ |
| 166 | 1: popl %ds; \ |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 167 | CFI_ADJUST_CFA_OFFSET -4;\ |
| 168 | /*CFI_RESTORE ds;*/\ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 169 | 2: popl %es; \ |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 170 | CFI_ADJUST_CFA_OFFSET -4;\ |
| 171 | /*CFI_RESTORE es;*/\ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 172 | .section .fixup,"ax"; \ |
| 173 | 3: movl $0,(%esp); \ |
| 174 | jmp 1b; \ |
| 175 | 4: movl $0,(%esp); \ |
| 176 | jmp 2b; \ |
| 177 | .previous; \ |
| 178 | .section __ex_table,"a";\ |
| 179 | .align 4; \ |
| 180 | .long 1b,3b; \ |
| 181 | .long 2b,4b; \ |
| 182 | .previous |
| 183 | |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 184 | #define RING0_INT_FRAME \ |
| 185 | CFI_STARTPROC simple;\ |
| 186 | CFI_DEF_CFA esp, 3*4;\ |
| 187 | /*CFI_OFFSET cs, -2*4;*/\ |
| 188 | CFI_OFFSET eip, -3*4 |
| 189 | |
| 190 | #define RING0_EC_FRAME \ |
| 191 | CFI_STARTPROC simple;\ |
| 192 | CFI_DEF_CFA esp, 4*4;\ |
| 193 | /*CFI_OFFSET cs, -2*4;*/\ |
| 194 | CFI_OFFSET eip, -3*4 |
| 195 | |
| 196 | #define RING0_PTREGS_FRAME \ |
| 197 | CFI_STARTPROC simple;\ |
| 198 | CFI_DEF_CFA esp, OLDESP-EBX;\ |
| 199 | /*CFI_OFFSET cs, CS-OLDESP;*/\ |
| 200 | CFI_OFFSET eip, EIP-OLDESP;\ |
| 201 | /*CFI_OFFSET es, ES-OLDESP;*/\ |
| 202 | /*CFI_OFFSET ds, DS-OLDESP;*/\ |
| 203 | CFI_OFFSET eax, EAX-OLDESP;\ |
| 204 | CFI_OFFSET ebp, EBP-OLDESP;\ |
| 205 | CFI_OFFSET edi, EDI-OLDESP;\ |
| 206 | CFI_OFFSET esi, ESI-OLDESP;\ |
| 207 | CFI_OFFSET edx, EDX-OLDESP;\ |
| 208 | CFI_OFFSET ecx, ECX-OLDESP;\ |
| 209 | CFI_OFFSET ebx, EBX-OLDESP |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 210 | |
| 211 | ENTRY(ret_from_fork) |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 212 | CFI_STARTPROC |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 213 | pushl %eax |
Markus Armbruster | 25d7dfd | 2006-07-30 03:04:08 -0700 | [diff] [blame] | 214 | CFI_ADJUST_CFA_OFFSET 4 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 215 | call schedule_tail |
| 216 | GET_THREAD_INFO(%ebp) |
| 217 | popl %eax |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 218 | CFI_ADJUST_CFA_OFFSET -4 |
Linus Torvalds | 47a5c6f | 2006-09-18 16:20:40 -0700 | [diff] [blame] | 219 | pushl $0x0202 # Reset kernel eflags |
| 220 | CFI_ADJUST_CFA_OFFSET 4 |
| 221 | popfl |
| 222 | CFI_ADJUST_CFA_OFFSET -4 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 223 | jmp syscall_exit |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 224 | CFI_ENDPROC |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 225 | |
| 226 | /* |
| 227 | * Return to user mode is not as complex as all this looks, |
| 228 | * but we want the default path for a system call return to |
| 229 | * go as quickly as possible which is why some of this is |
| 230 | * less clear than it otherwise should be. |
| 231 | */ |
| 232 | |
| 233 | # userspace resumption stub bypassing syscall exit tracing |
| 234 | ALIGN |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 235 | RING0_PTREGS_FRAME |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 236 | ret_from_exception: |
| 237 | preempt_stop |
| 238 | ret_from_intr: |
| 239 | GET_THREAD_INFO(%ebp) |
Aleksey Gorelov | 4031ff3 | 2006-06-27 02:53:48 -0700 | [diff] [blame] | 240 | check_userspace: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 241 | movl EFLAGS(%esp), %eax # mix EFLAGS and CS |
| 242 | movb CS(%esp), %al |
| 243 | testl $(VM_MASK | 3), %eax |
| 244 | jz resume_kernel |
| 245 | ENTRY(resume_userspace) |
Rusty Russell | 0da5db3 | 2006-09-26 10:52:39 +0200 | [diff] [blame^] | 246 | DISABLE_INTERRUPTS # make sure we don't miss an interrupt |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 247 | # setting need_resched or sigpending |
| 248 | # between sampling and the iret |
| 249 | movl TI_flags(%ebp), %ecx |
| 250 | andl $_TIF_WORK_MASK, %ecx # is there any work to be done on |
| 251 | # int/exception return? |
| 252 | jne work_pending |
| 253 | jmp restore_all |
| 254 | |
| 255 | #ifdef CONFIG_PREEMPT |
| 256 | ENTRY(resume_kernel) |
Rusty Russell | 0da5db3 | 2006-09-26 10:52:39 +0200 | [diff] [blame^] | 257 | DISABLE_INTERRUPTS |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 258 | cmpl $0,TI_preempt_count(%ebp) # non-zero preempt_count ? |
| 259 | jnz restore_nocheck |
| 260 | need_resched: |
| 261 | movl TI_flags(%ebp), %ecx # need_resched set ? |
| 262 | testb $_TIF_NEED_RESCHED, %cl |
| 263 | jz restore_all |
| 264 | testl $IF_MASK,EFLAGS(%esp) # interrupts off (exception path) ? |
| 265 | jz restore_all |
| 266 | call preempt_schedule_irq |
| 267 | jmp need_resched |
| 268 | #endif |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 269 | CFI_ENDPROC |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 270 | |
| 271 | /* SYSENTER_RETURN points to after the "sysenter" instruction in |
| 272 | the vsyscall page. See vsyscall-sysentry.S, which defines the symbol. */ |
| 273 | |
| 274 | # sysenter call handler stub |
| 275 | ENTRY(sysenter_entry) |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 276 | CFI_STARTPROC simple |
| 277 | CFI_DEF_CFA esp, 0 |
| 278 | CFI_REGISTER esp, ebp |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 279 | movl TSS_sysenter_esp0(%esp),%esp |
| 280 | sysenter_past_esp: |
Ingo Molnar | 55f327f | 2006-07-03 00:24:43 -0700 | [diff] [blame] | 281 | /* |
| 282 | * No need to follow this irqs on/off section: the syscall |
| 283 | * disabled irqs and here we enable it straight after entry: |
| 284 | */ |
Rusty Russell | 0da5db3 | 2006-09-26 10:52:39 +0200 | [diff] [blame^] | 285 | ENABLE_INTERRUPTS |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 286 | pushl $(__USER_DS) |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 287 | CFI_ADJUST_CFA_OFFSET 4 |
| 288 | /*CFI_REL_OFFSET ss, 0*/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 289 | pushl %ebp |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 290 | CFI_ADJUST_CFA_OFFSET 4 |
| 291 | CFI_REL_OFFSET esp, 0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 292 | pushfl |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 293 | CFI_ADJUST_CFA_OFFSET 4 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 294 | pushl $(__USER_CS) |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 295 | CFI_ADJUST_CFA_OFFSET 4 |
| 296 | /*CFI_REL_OFFSET cs, 0*/ |
Ingo Molnar | e6e5494 | 2006-06-27 02:53:50 -0700 | [diff] [blame] | 297 | /* |
| 298 | * Push current_thread_info()->sysenter_return to the stack. |
| 299 | * A tiny bit of offset fixup is necessary - 4*4 means the 4 words |
| 300 | * pushed above; +8 corresponds to copy_thread's esp0 setting. |
| 301 | */ |
| 302 | pushl (TI_sysenter_return-THREAD_SIZE+8+4*4)(%esp) |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 303 | CFI_ADJUST_CFA_OFFSET 4 |
| 304 | CFI_REL_OFFSET eip, 0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 305 | |
| 306 | /* |
| 307 | * Load the potential sixth argument from user stack. |
| 308 | * Careful about security. |
| 309 | */ |
| 310 | cmpl $__PAGE_OFFSET-3,%ebp |
| 311 | jae syscall_fault |
| 312 | 1: movl (%ebp),%ebp |
| 313 | .section __ex_table,"a" |
| 314 | .align 4 |
| 315 | .long 1b,syscall_fault |
| 316 | .previous |
| 317 | |
| 318 | pushl %eax |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 319 | CFI_ADJUST_CFA_OFFSET 4 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 320 | SAVE_ALL |
| 321 | GET_THREAD_INFO(%ebp) |
| 322 | |
| 323 | /* 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] | 324 | 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] | 325 | jnz syscall_trace_entry |
| 326 | cmpl $(nr_syscalls), %eax |
| 327 | jae syscall_badsys |
| 328 | call *sys_call_table(,%eax,4) |
| 329 | movl %eax,EAX(%esp) |
Rusty Russell | 0da5db3 | 2006-09-26 10:52:39 +0200 | [diff] [blame^] | 330 | DISABLE_INTERRUPTS |
Ingo Molnar | 55f327f | 2006-07-03 00:24:43 -0700 | [diff] [blame] | 331 | TRACE_IRQS_OFF |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 332 | movl TI_flags(%ebp), %ecx |
| 333 | testw $_TIF_ALLWORK_MASK, %cx |
| 334 | jne syscall_exit_work |
| 335 | /* if something modifies registers it must also disable sysexit */ |
| 336 | movl EIP(%esp), %edx |
| 337 | movl OLDESP(%esp), %ecx |
| 338 | xorl %ebp,%ebp |
Ingo Molnar | 55f327f | 2006-07-03 00:24:43 -0700 | [diff] [blame] | 339 | TRACE_IRQS_ON |
Rusty Russell | 0da5db3 | 2006-09-26 10:52:39 +0200 | [diff] [blame^] | 340 | ENABLE_INTERRUPTS_SYSEXIT |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 341 | CFI_ENDPROC |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 342 | |
| 343 | |
| 344 | # system call handler stub |
| 345 | ENTRY(system_call) |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 346 | RING0_INT_FRAME # can't unwind into user space anyway |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 347 | pushl %eax # save orig_eax |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 348 | CFI_ADJUST_CFA_OFFSET 4 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 349 | SAVE_ALL |
| 350 | GET_THREAD_INFO(%ebp) |
Chuck Ebbert | 635cf99 | 2006-03-23 02:59:48 -0800 | [diff] [blame] | 351 | testl $TF_MASK,EFLAGS(%esp) |
| 352 | jz no_singlestep |
| 353 | orl $_TIF_SINGLESTEP,TI_flags(%ebp) |
| 354 | no_singlestep: |
Laurent Vivier | ed75e8d | 2005-09-03 15:57:18 -0700 | [diff] [blame] | 355 | # system call tracing in operation / emulation |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 356 | /* 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] | 357 | 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] | 358 | jnz syscall_trace_entry |
| 359 | cmpl $(nr_syscalls), %eax |
| 360 | jae syscall_badsys |
| 361 | syscall_call: |
| 362 | call *sys_call_table(,%eax,4) |
| 363 | movl %eax,EAX(%esp) # store the return value |
| 364 | syscall_exit: |
Rusty Russell | 0da5db3 | 2006-09-26 10:52:39 +0200 | [diff] [blame^] | 365 | DISABLE_INTERRUPTS # make sure we don't miss an interrupt |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 366 | # setting need_resched or sigpending |
| 367 | # between sampling and the iret |
Ingo Molnar | 55f327f | 2006-07-03 00:24:43 -0700 | [diff] [blame] | 368 | TRACE_IRQS_OFF |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 369 | movl TI_flags(%ebp), %ecx |
| 370 | testw $_TIF_ALLWORK_MASK, %cx # current->work |
| 371 | jne syscall_exit_work |
| 372 | |
| 373 | restore_all: |
| 374 | movl EFLAGS(%esp), %eax # mix EFLAGS, SS and CS |
Stas Sergeev | 5df2408 | 2005-04-16 15:24:01 -0700 | [diff] [blame] | 375 | # Warning: OLDSS(%esp) contains the wrong/random values if we |
| 376 | # are returning to the kernel. |
| 377 | # See comments in process.c:copy_thread() for details. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 378 | movb OLDSS(%esp), %ah |
| 379 | movb CS(%esp), %al |
| 380 | andl $(VM_MASK | (4 << 8) | 3), %eax |
| 381 | cmpl $((4 << 8) | 3), %eax |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 382 | CFI_REMEMBER_STATE |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 383 | je ldt_ss # returning to user-space with LDT SS |
| 384 | restore_nocheck: |
Ingo Molnar | 55f327f | 2006-07-03 00:24:43 -0700 | [diff] [blame] | 385 | TRACE_IRQS_IRET |
| 386 | restore_nocheck_notrace: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 387 | RESTORE_REGS |
| 388 | addl $4, %esp |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 389 | CFI_ADJUST_CFA_OFFSET -4 |
Rusty Russell | 0da5db3 | 2006-09-26 10:52:39 +0200 | [diff] [blame^] | 390 | 1: INTERRUPT_RETURN |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 391 | .section .fixup,"ax" |
| 392 | iret_exc: |
Ingo Molnar | 55f327f | 2006-07-03 00:24:43 -0700 | [diff] [blame] | 393 | TRACE_IRQS_ON |
Rusty Russell | 0da5db3 | 2006-09-26 10:52:39 +0200 | [diff] [blame^] | 394 | ENABLE_INTERRUPTS |
Linus Torvalds | a879cbb | 2005-04-29 09:38:44 -0700 | [diff] [blame] | 395 | pushl $0 # no error code |
| 396 | pushl $do_iret_error |
| 397 | jmp error_code |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 398 | .previous |
| 399 | .section __ex_table,"a" |
| 400 | .align 4 |
| 401 | .long 1b,iret_exc |
| 402 | .previous |
| 403 | |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 404 | CFI_RESTORE_STATE |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 405 | ldt_ss: |
| 406 | larl OLDSS(%esp), %eax |
| 407 | jnz restore_nocheck |
| 408 | testl $0x00400000, %eax # returning to 32bit stack? |
| 409 | jnz restore_nocheck # allright, normal return |
| 410 | /* If returning to userspace with 16bit stack, |
| 411 | * try to fix the higher word of ESP, as the CPU |
| 412 | * won't restore it. |
| 413 | * This is an "official" bug of all the x86-compatible |
| 414 | * CPUs, which we can try to work around to make |
| 415 | * dosemu and wine happy. */ |
| 416 | subl $8, %esp # reserve space for switch16 pointer |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 417 | CFI_ADJUST_CFA_OFFSET 8 |
Rusty Russell | 0da5db3 | 2006-09-26 10:52:39 +0200 | [diff] [blame^] | 418 | DISABLE_INTERRUPTS |
Ingo Molnar | 55f327f | 2006-07-03 00:24:43 -0700 | [diff] [blame] | 419 | TRACE_IRQS_OFF |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 420 | movl %esp, %eax |
| 421 | /* Set up the 16bit stack frame with switch32 pointer on top, |
| 422 | * and a switch16 pointer on top of the current frame. */ |
| 423 | call setup_x86_bogus_stack |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 424 | CFI_ADJUST_CFA_OFFSET -8 # frame has moved |
Ingo Molnar | 55f327f | 2006-07-03 00:24:43 -0700 | [diff] [blame] | 425 | TRACE_IRQS_IRET |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 426 | RESTORE_REGS |
| 427 | lss 20+4(%esp), %esp # switch to 16bit stack |
Rusty Russell | 0da5db3 | 2006-09-26 10:52:39 +0200 | [diff] [blame^] | 428 | 1: INTERRUPT_RETURN |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 429 | .section __ex_table,"a" |
| 430 | .align 4 |
| 431 | .long 1b,iret_exc |
| 432 | .previous |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 433 | CFI_ENDPROC |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 434 | |
| 435 | # perform work that needs to be done immediately before resumption |
| 436 | ALIGN |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 437 | RING0_PTREGS_FRAME # can't unwind into user space anyway |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 438 | work_pending: |
| 439 | testb $_TIF_NEED_RESCHED, %cl |
| 440 | jz work_notifysig |
| 441 | work_resched: |
| 442 | call schedule |
Rusty Russell | 0da5db3 | 2006-09-26 10:52:39 +0200 | [diff] [blame^] | 443 | DISABLE_INTERRUPTS # make sure we don't miss an interrupt |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 444 | # setting need_resched or sigpending |
| 445 | # between sampling and the iret |
Ingo Molnar | 55f327f | 2006-07-03 00:24:43 -0700 | [diff] [blame] | 446 | TRACE_IRQS_OFF |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 447 | movl TI_flags(%ebp), %ecx |
| 448 | andl $_TIF_WORK_MASK, %ecx # is there any work to be done other |
| 449 | # than syscall tracing? |
| 450 | jz restore_all |
| 451 | testb $_TIF_NEED_RESCHED, %cl |
| 452 | jnz work_resched |
| 453 | |
| 454 | work_notifysig: # deal with pending signals and |
| 455 | # notify-resume requests |
| 456 | testl $VM_MASK, EFLAGS(%esp) |
| 457 | movl %esp, %eax |
| 458 | jne work_notifysig_v86 # returning to kernel-space or |
| 459 | # vm86-space |
| 460 | xorl %edx, %edx |
| 461 | call do_notify_resume |
Aleksey Gorelov | 4031ff3 | 2006-06-27 02:53:48 -0700 | [diff] [blame] | 462 | jmp resume_userspace_sig |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 463 | |
| 464 | ALIGN |
| 465 | work_notifysig_v86: |
Matt Mackall | 64ca900 | 2006-01-08 01:05:26 -0800 | [diff] [blame] | 466 | #ifdef CONFIG_VM86 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 467 | pushl %ecx # save ti_flags for do_notify_resume |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 468 | CFI_ADJUST_CFA_OFFSET 4 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 469 | call save_v86_state # %eax contains pt_regs pointer |
| 470 | popl %ecx |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 471 | CFI_ADJUST_CFA_OFFSET -4 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 472 | movl %eax, %esp |
| 473 | xorl %edx, %edx |
| 474 | call do_notify_resume |
Aleksey Gorelov | 4031ff3 | 2006-06-27 02:53:48 -0700 | [diff] [blame] | 475 | jmp resume_userspace_sig |
Matt Mackall | 64ca900 | 2006-01-08 01:05:26 -0800 | [diff] [blame] | 476 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 477 | |
| 478 | # perform syscall exit tracing |
| 479 | ALIGN |
| 480 | syscall_trace_entry: |
| 481 | movl $-ENOSYS,EAX(%esp) |
| 482 | movl %esp, %eax |
| 483 | xorl %edx,%edx |
| 484 | call do_syscall_trace |
Laurent Vivier | ed75e8d | 2005-09-03 15:57:18 -0700 | [diff] [blame] | 485 | cmpl $0, %eax |
Paolo 'Blaisorblade' Giarrusso | 640aa46 | 2005-09-03 15:57:22 -0700 | [diff] [blame] | 486 | jne resume_userspace # ret != 0 -> running under PTRACE_SYSEMU, |
Laurent Vivier | ed75e8d | 2005-09-03 15:57:18 -0700 | [diff] [blame] | 487 | # so must skip actual syscall |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 488 | movl ORIG_EAX(%esp), %eax |
| 489 | cmpl $(nr_syscalls), %eax |
| 490 | jnae syscall_call |
| 491 | jmp syscall_exit |
| 492 | |
| 493 | # perform syscall exit tracing |
| 494 | ALIGN |
| 495 | syscall_exit_work: |
| 496 | testb $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SINGLESTEP), %cl |
| 497 | jz work_pending |
Ingo Molnar | 55f327f | 2006-07-03 00:24:43 -0700 | [diff] [blame] | 498 | TRACE_IRQS_ON |
Rusty Russell | 0da5db3 | 2006-09-26 10:52:39 +0200 | [diff] [blame^] | 499 | ENABLE_INTERRUPTS # could let do_syscall_trace() call |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 500 | # schedule() instead |
| 501 | movl %esp, %eax |
| 502 | movl $1, %edx |
| 503 | call do_syscall_trace |
| 504 | jmp resume_userspace |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 505 | CFI_ENDPROC |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 506 | |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 507 | RING0_INT_FRAME # can't unwind into user space anyway |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 508 | syscall_fault: |
| 509 | pushl %eax # save orig_eax |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 510 | CFI_ADJUST_CFA_OFFSET 4 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 511 | SAVE_ALL |
| 512 | GET_THREAD_INFO(%ebp) |
| 513 | movl $-EFAULT,EAX(%esp) |
| 514 | jmp resume_userspace |
| 515 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 516 | syscall_badsys: |
| 517 | movl $-ENOSYS,EAX(%esp) |
| 518 | jmp resume_userspace |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 519 | CFI_ENDPROC |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 520 | |
| 521 | #define FIXUP_ESPFIX_STACK \ |
| 522 | movl %esp, %eax; \ |
| 523 | /* switch to 32bit stack using the pointer on top of 16bit stack */ \ |
| 524 | lss %ss:CPU_16BIT_STACK_SIZE-8, %esp; \ |
| 525 | /* copy data from 16bit stack to 32bit stack */ \ |
| 526 | call fixup_x86_bogus_stack; \ |
| 527 | /* put ESP to the proper location */ \ |
| 528 | movl %eax, %esp; |
| 529 | #define UNWIND_ESPFIX_STACK \ |
| 530 | pushl %eax; \ |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 531 | CFI_ADJUST_CFA_OFFSET 4; \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 532 | movl %ss, %eax; \ |
| 533 | /* see if on 16bit stack */ \ |
| 534 | cmpw $__ESPFIX_SS, %ax; \ |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 535 | je 28f; \ |
| 536 | 27: popl %eax; \ |
| 537 | CFI_ADJUST_CFA_OFFSET -4; \ |
| 538 | .section .fixup,"ax"; \ |
| 539 | 28: movl $__KERNEL_DS, %eax; \ |
| 540 | movl %eax, %ds; \ |
| 541 | movl %eax, %es; \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 542 | /* switch to 32bit stack */ \ |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 543 | FIXUP_ESPFIX_STACK; \ |
| 544 | jmp 27b; \ |
| 545 | .previous |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 546 | |
| 547 | /* |
| 548 | * Build the entry stubs and pointer table with |
| 549 | * some assembler magic. |
| 550 | */ |
| 551 | .data |
| 552 | ENTRY(interrupt) |
| 553 | .text |
| 554 | |
| 555 | vector=0 |
| 556 | ENTRY(irq_entries_start) |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 557 | RING0_INT_FRAME |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 558 | .rept NR_IRQS |
| 559 | ALIGN |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 560 | .if vector |
| 561 | CFI_ADJUST_CFA_OFFSET -4 |
| 562 | .endif |
Rusty Russell | 19eadf9 | 2006-06-27 02:53:44 -0700 | [diff] [blame] | 563 | 1: pushl $~(vector) |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 564 | CFI_ADJUST_CFA_OFFSET 4 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 565 | jmp common_interrupt |
| 566 | .data |
| 567 | .long 1b |
| 568 | .text |
| 569 | vector=vector+1 |
| 570 | .endr |
| 571 | |
Ingo Molnar | 55f327f | 2006-07-03 00:24:43 -0700 | [diff] [blame] | 572 | /* |
| 573 | * the CPU automatically disables interrupts when executing an IRQ vector, |
| 574 | * so IRQ-flags tracing has to follow that: |
| 575 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 576 | ALIGN |
| 577 | common_interrupt: |
| 578 | SAVE_ALL |
Ingo Molnar | 55f327f | 2006-07-03 00:24:43 -0700 | [diff] [blame] | 579 | TRACE_IRQS_OFF |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 580 | movl %esp,%eax |
| 581 | call do_IRQ |
| 582 | jmp ret_from_intr |
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 | |
| 585 | #define BUILD_INTERRUPT(name, nr) \ |
| 586 | ENTRY(name) \ |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 587 | RING0_INT_FRAME; \ |
Rusty Russell | 19eadf9 | 2006-06-27 02:53:44 -0700 | [diff] [blame] | 588 | pushl $~(nr); \ |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 589 | CFI_ADJUST_CFA_OFFSET 4; \ |
| 590 | SAVE_ALL; \ |
Ingo Molnar | 55f327f | 2006-07-03 00:24:43 -0700 | [diff] [blame] | 591 | TRACE_IRQS_OFF \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 592 | movl %esp,%eax; \ |
| 593 | call smp_/**/name; \ |
Ingo Molnar | 55f327f | 2006-07-03 00:24:43 -0700 | [diff] [blame] | 594 | jmp ret_from_intr; \ |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 595 | CFI_ENDPROC |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 596 | |
| 597 | /* The include is where all of the SMP etc. interrupts come from */ |
| 598 | #include "entry_arch.h" |
| 599 | |
Prasanna S.P | d28c439 | 2006-09-26 10:52:34 +0200 | [diff] [blame] | 600 | KPROBE_ENTRY(page_fault) |
| 601 | RING0_EC_FRAME |
| 602 | pushl $do_page_fault |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 603 | CFI_ADJUST_CFA_OFFSET 4 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 604 | ALIGN |
| 605 | error_code: |
| 606 | pushl %ds |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 607 | CFI_ADJUST_CFA_OFFSET 4 |
| 608 | /*CFI_REL_OFFSET ds, 0*/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 609 | pushl %eax |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 610 | CFI_ADJUST_CFA_OFFSET 4 |
| 611 | CFI_REL_OFFSET eax, 0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 612 | xorl %eax, %eax |
| 613 | pushl %ebp |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 614 | CFI_ADJUST_CFA_OFFSET 4 |
| 615 | CFI_REL_OFFSET ebp, 0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 616 | pushl %edi |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 617 | CFI_ADJUST_CFA_OFFSET 4 |
| 618 | CFI_REL_OFFSET edi, 0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 619 | pushl %esi |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 620 | CFI_ADJUST_CFA_OFFSET 4 |
| 621 | CFI_REL_OFFSET esi, 0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 622 | pushl %edx |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 623 | CFI_ADJUST_CFA_OFFSET 4 |
| 624 | CFI_REL_OFFSET edx, 0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 625 | decl %eax # eax = -1 |
| 626 | pushl %ecx |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 627 | CFI_ADJUST_CFA_OFFSET 4 |
| 628 | CFI_REL_OFFSET ecx, 0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 629 | pushl %ebx |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 630 | CFI_ADJUST_CFA_OFFSET 4 |
| 631 | CFI_REL_OFFSET ebx, 0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 632 | cld |
| 633 | pushl %es |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 634 | CFI_ADJUST_CFA_OFFSET 4 |
| 635 | /*CFI_REL_OFFSET es, 0*/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 636 | UNWIND_ESPFIX_STACK |
| 637 | popl %ecx |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 638 | CFI_ADJUST_CFA_OFFSET -4 |
| 639 | /*CFI_REGISTER es, ecx*/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 640 | movl ES(%esp), %edi # get the function address |
| 641 | movl ORIG_EAX(%esp), %edx # get the error code |
| 642 | movl %eax, ORIG_EAX(%esp) |
| 643 | movl %ecx, ES(%esp) |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 644 | /*CFI_REL_OFFSET es, ES*/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 645 | movl $(__USER_DS), %ecx |
| 646 | movl %ecx, %ds |
| 647 | movl %ecx, %es |
| 648 | movl %esp,%eax # pt_regs pointer |
| 649 | call *%edi |
| 650 | jmp ret_from_exception |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 651 | CFI_ENDPROC |
Prasanna S.P | d28c439 | 2006-09-26 10:52:34 +0200 | [diff] [blame] | 652 | KPROBE_END(page_fault) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 653 | |
| 654 | ENTRY(coprocessor_error) |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 655 | RING0_INT_FRAME |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 656 | pushl $0 |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 657 | CFI_ADJUST_CFA_OFFSET 4 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 658 | pushl $do_coprocessor_error |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 659 | CFI_ADJUST_CFA_OFFSET 4 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 660 | jmp error_code |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 661 | CFI_ENDPROC |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 662 | |
| 663 | ENTRY(simd_coprocessor_error) |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 664 | RING0_INT_FRAME |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 665 | pushl $0 |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 666 | CFI_ADJUST_CFA_OFFSET 4 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 667 | pushl $do_simd_coprocessor_error |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 668 | CFI_ADJUST_CFA_OFFSET 4 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 669 | jmp error_code |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 670 | CFI_ENDPROC |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 671 | |
| 672 | ENTRY(device_not_available) |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 673 | RING0_INT_FRAME |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 674 | pushl $-1 # mark this as an int |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 675 | CFI_ADJUST_CFA_OFFSET 4 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 676 | SAVE_ALL |
Rusty Russell | 0da5db3 | 2006-09-26 10:52:39 +0200 | [diff] [blame^] | 677 | GET_CR0_INTO_EAX |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 678 | testl $0x4, %eax # EM (math emulation bit) |
| 679 | jne device_not_available_emulate |
| 680 | preempt_stop |
| 681 | call math_state_restore |
| 682 | jmp ret_from_exception |
| 683 | device_not_available_emulate: |
| 684 | pushl $0 # temporary storage for ORIG_EIP |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 685 | CFI_ADJUST_CFA_OFFSET 4 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 686 | call math_emulate |
| 687 | addl $4, %esp |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 688 | CFI_ADJUST_CFA_OFFSET -4 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 689 | jmp ret_from_exception |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 690 | CFI_ENDPROC |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 691 | |
| 692 | /* |
| 693 | * Debug traps and NMI can happen at the one SYSENTER instruction |
| 694 | * that sets up the real kernel stack. Check here, since we can't |
| 695 | * allow the wrong stack to be used. |
| 696 | * |
| 697 | * "TSS_sysenter_esp0+12" is because the NMI/debug handler will have |
| 698 | * already pushed 3 words if it hits on the sysenter instruction: |
| 699 | * eflags, cs and eip. |
| 700 | * |
| 701 | * We just load the right stack, and push the three (known) values |
| 702 | * by hand onto the new stack - while updating the return eip past |
| 703 | * the instruction that would have done it for sysenter. |
| 704 | */ |
| 705 | #define FIX_STACK(offset, ok, label) \ |
| 706 | cmpw $__KERNEL_CS,4(%esp); \ |
| 707 | jne ok; \ |
| 708 | label: \ |
| 709 | movl TSS_sysenter_esp0+offset(%esp),%esp; \ |
Chuck Ebbert | a549b86 | 2006-09-26 10:52:37 +0200 | [diff] [blame] | 710 | CFI_DEF_CFA esp, 0; \ |
| 711 | CFI_UNDEFINED eip; \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 712 | pushfl; \ |
Chuck Ebbert | a549b86 | 2006-09-26 10:52:37 +0200 | [diff] [blame] | 713 | CFI_ADJUST_CFA_OFFSET 4; \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 714 | pushl $__KERNEL_CS; \ |
Chuck Ebbert | a549b86 | 2006-09-26 10:52:37 +0200 | [diff] [blame] | 715 | CFI_ADJUST_CFA_OFFSET 4; \ |
| 716 | pushl $sysenter_past_esp; \ |
| 717 | CFI_ADJUST_CFA_OFFSET 4; \ |
| 718 | CFI_REL_OFFSET eip, 0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 719 | |
Prasanna S Panchamukhi | 3d97ae5 | 2005-09-06 15:19:27 -0700 | [diff] [blame] | 720 | KPROBE_ENTRY(debug) |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 721 | RING0_INT_FRAME |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 722 | cmpl $sysenter_entry,(%esp) |
| 723 | jne debug_stack_correct |
| 724 | FIX_STACK(12, debug_stack_correct, debug_esp_fix_insn) |
| 725 | debug_stack_correct: |
| 726 | pushl $-1 # mark this as an int |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 727 | CFI_ADJUST_CFA_OFFSET 4 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 728 | SAVE_ALL |
| 729 | xorl %edx,%edx # error code 0 |
| 730 | movl %esp,%eax # pt_regs pointer |
| 731 | call do_debug |
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 |
Prasanna S.P | d28c439 | 2006-09-26 10:52:34 +0200 | [diff] [blame] | 734 | KPROBE_END(debug) |
| 735 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 736 | /* |
| 737 | * NMI is doubly nasty. It can happen _while_ we're handling |
| 738 | * a debug fault, and the debug fault hasn't yet been able to |
| 739 | * clear up the stack. So we first check whether we got an |
| 740 | * NMI on the sysenter entry path, but after that we need to |
| 741 | * check whether we got an NMI on the debug path where the debug |
| 742 | * fault happened on the sysenter path. |
| 743 | */ |
Fernando Luis Vázquez Cao | 0603975 | 2006-09-26 10:52:36 +0200 | [diff] [blame] | 744 | KPROBE_ENTRY(nmi) |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 745 | RING0_INT_FRAME |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 746 | pushl %eax |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 747 | CFI_ADJUST_CFA_OFFSET 4 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 748 | movl %ss, %eax |
| 749 | cmpw $__ESPFIX_SS, %ax |
| 750 | popl %eax |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 751 | CFI_ADJUST_CFA_OFFSET -4 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 752 | je nmi_16bit_stack |
| 753 | cmpl $sysenter_entry,(%esp) |
| 754 | je nmi_stack_fixup |
| 755 | pushl %eax |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 756 | CFI_ADJUST_CFA_OFFSET 4 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 757 | movl %esp,%eax |
| 758 | /* Do not access memory above the end of our stack page, |
| 759 | * it might not exist. |
| 760 | */ |
| 761 | andl $(THREAD_SIZE-1),%eax |
| 762 | cmpl $(THREAD_SIZE-20),%eax |
| 763 | popl %eax |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 764 | CFI_ADJUST_CFA_OFFSET -4 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 765 | jae nmi_stack_correct |
| 766 | cmpl $sysenter_entry,12(%esp) |
| 767 | je nmi_debug_stack_check |
| 768 | nmi_stack_correct: |
Chuck Ebbert | a549b86 | 2006-09-26 10:52:37 +0200 | [diff] [blame] | 769 | /* We have a RING0_INT_FRAME here */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 770 | pushl %eax |
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 # zero error code |
| 774 | movl %esp,%eax # pt_regs pointer |
| 775 | call do_nmi |
Ingo Molnar | 55f327f | 2006-07-03 00:24:43 -0700 | [diff] [blame] | 776 | jmp restore_nocheck_notrace |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 777 | CFI_ENDPROC |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 778 | |
| 779 | nmi_stack_fixup: |
Chuck Ebbert | a549b86 | 2006-09-26 10:52:37 +0200 | [diff] [blame] | 780 | RING0_INT_FRAME |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 781 | FIX_STACK(12,nmi_stack_correct, 1) |
| 782 | jmp nmi_stack_correct |
Chuck Ebbert | a549b86 | 2006-09-26 10:52:37 +0200 | [diff] [blame] | 783 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 784 | nmi_debug_stack_check: |
Chuck Ebbert | a549b86 | 2006-09-26 10:52:37 +0200 | [diff] [blame] | 785 | /* We have a RING0_INT_FRAME here */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 786 | cmpw $__KERNEL_CS,16(%esp) |
| 787 | jne nmi_stack_correct |
Jan Beulich | e271820 | 2005-11-13 16:06:52 -0800 | [diff] [blame] | 788 | cmpl $debug,(%esp) |
| 789 | jb nmi_stack_correct |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 790 | cmpl $debug_esp_fix_insn,(%esp) |
Jan Beulich | e271820 | 2005-11-13 16:06:52 -0800 | [diff] [blame] | 791 | ja nmi_stack_correct |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 792 | FIX_STACK(24,nmi_stack_correct, 1) |
| 793 | jmp nmi_stack_correct |
| 794 | |
| 795 | nmi_16bit_stack: |
Chuck Ebbert | a549b86 | 2006-09-26 10:52:37 +0200 | [diff] [blame] | 796 | /* We have a RING0_INT_FRAME here. |
| 797 | * |
| 798 | * create the pointer to lss back |
| 799 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 800 | pushl %ss |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 801 | CFI_ADJUST_CFA_OFFSET 4 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 802 | pushl %esp |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 803 | CFI_ADJUST_CFA_OFFSET 4 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 804 | movzwl %sp, %esp |
| 805 | addw $4, (%esp) |
| 806 | /* copy the iret frame of 12 bytes */ |
| 807 | .rept 3 |
| 808 | pushl 16(%esp) |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 809 | CFI_ADJUST_CFA_OFFSET 4 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 810 | .endr |
| 811 | pushl %eax |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 812 | CFI_ADJUST_CFA_OFFSET 4 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 813 | SAVE_ALL |
| 814 | FIXUP_ESPFIX_STACK # %eax == %esp |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 815 | CFI_ADJUST_CFA_OFFSET -20 # the frame has now moved |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 816 | xorl %edx,%edx # zero error code |
| 817 | call do_nmi |
| 818 | RESTORE_REGS |
| 819 | lss 12+4(%esp), %esp # back to 16bit stack |
Rusty Russell | 0da5db3 | 2006-09-26 10:52:39 +0200 | [diff] [blame^] | 820 | 1: INTERRUPT_RETURN |
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 | .section __ex_table,"a" |
| 823 | .align 4 |
| 824 | .long 1b,iret_exc |
| 825 | .previous |
Fernando Luis Vázquez Cao | 0603975 | 2006-09-26 10:52:36 +0200 | [diff] [blame] | 826 | KPROBE_END(nmi) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 827 | |
Prasanna S Panchamukhi | 3d97ae5 | 2005-09-06 15:19:27 -0700 | [diff] [blame] | 828 | KPROBE_ENTRY(int3) |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 829 | RING0_INT_FRAME |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 830 | pushl $-1 # mark this as an int |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 831 | CFI_ADJUST_CFA_OFFSET 4 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 832 | SAVE_ALL |
| 833 | xorl %edx,%edx # zero error code |
| 834 | movl %esp,%eax # pt_regs pointer |
| 835 | call do_int3 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 836 | jmp ret_from_exception |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 837 | CFI_ENDPROC |
Prasanna S.P | d28c439 | 2006-09-26 10:52:34 +0200 | [diff] [blame] | 838 | KPROBE_END(int3) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 839 | |
| 840 | ENTRY(overflow) |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 841 | RING0_INT_FRAME |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 842 | pushl $0 |
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 | pushl $do_overflow |
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 | jmp error_code |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 847 | CFI_ENDPROC |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 848 | |
| 849 | ENTRY(bounds) |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 850 | RING0_INT_FRAME |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 851 | pushl $0 |
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 | pushl $do_bounds |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 854 | CFI_ADJUST_CFA_OFFSET 4 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 855 | jmp error_code |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 856 | CFI_ENDPROC |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 857 | |
| 858 | ENTRY(invalid_op) |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 859 | RING0_INT_FRAME |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 860 | pushl $0 |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 861 | CFI_ADJUST_CFA_OFFSET 4 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 862 | pushl $do_invalid_op |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 863 | CFI_ADJUST_CFA_OFFSET 4 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 864 | jmp error_code |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 865 | CFI_ENDPROC |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 866 | |
| 867 | ENTRY(coprocessor_segment_overrun) |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 868 | RING0_INT_FRAME |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 869 | pushl $0 |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 870 | CFI_ADJUST_CFA_OFFSET 4 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 871 | pushl $do_coprocessor_segment_overrun |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 872 | CFI_ADJUST_CFA_OFFSET 4 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 873 | jmp error_code |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 874 | CFI_ENDPROC |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 875 | |
| 876 | ENTRY(invalid_TSS) |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 877 | RING0_EC_FRAME |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 878 | pushl $do_invalid_TSS |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 879 | CFI_ADJUST_CFA_OFFSET 4 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 880 | jmp error_code |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 881 | CFI_ENDPROC |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 882 | |
| 883 | ENTRY(segment_not_present) |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 884 | RING0_EC_FRAME |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 885 | pushl $do_segment_not_present |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 886 | CFI_ADJUST_CFA_OFFSET 4 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 887 | jmp error_code |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 888 | CFI_ENDPROC |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 889 | |
| 890 | ENTRY(stack_segment) |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 891 | RING0_EC_FRAME |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 892 | pushl $do_stack_segment |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 893 | CFI_ADJUST_CFA_OFFSET 4 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 894 | jmp error_code |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 895 | CFI_ENDPROC |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 896 | |
Prasanna S Panchamukhi | 3d97ae5 | 2005-09-06 15:19:27 -0700 | [diff] [blame] | 897 | KPROBE_ENTRY(general_protection) |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 898 | RING0_EC_FRAME |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 899 | pushl $do_general_protection |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 900 | CFI_ADJUST_CFA_OFFSET 4 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 901 | jmp error_code |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 902 | CFI_ENDPROC |
Prasanna S.P | d28c439 | 2006-09-26 10:52:34 +0200 | [diff] [blame] | 903 | KPROBE_END(general_protection) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 904 | |
| 905 | ENTRY(alignment_check) |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 906 | RING0_EC_FRAME |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 907 | pushl $do_alignment_check |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 908 | CFI_ADJUST_CFA_OFFSET 4 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 909 | jmp error_code |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 910 | CFI_ENDPROC |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 911 | |
Prasanna S.P | d28c439 | 2006-09-26 10:52:34 +0200 | [diff] [blame] | 912 | ENTRY(divide_error) |
| 913 | RING0_INT_FRAME |
| 914 | pushl $0 # no error code |
| 915 | CFI_ADJUST_CFA_OFFSET 4 |
| 916 | pushl $do_divide_error |
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 | jmp error_code |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 919 | CFI_ENDPROC |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 920 | |
| 921 | #ifdef CONFIG_X86_MCE |
| 922 | ENTRY(machine_check) |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 923 | RING0_INT_FRAME |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 924 | pushl $0 |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 925 | CFI_ADJUST_CFA_OFFSET 4 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 926 | pushl machine_check_vector |
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 | jmp error_code |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 929 | CFI_ENDPROC |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 930 | #endif |
| 931 | |
| 932 | ENTRY(spurious_interrupt_bug) |
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_spurious_interrupt_bug |
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 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 940 | |
Jan Beulich | 176a271 | 2006-06-26 13:57:41 +0200 | [diff] [blame] | 941 | #ifdef CONFIG_STACK_UNWIND |
| 942 | ENTRY(arch_unwind_init_running) |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 943 | CFI_STARTPROC |
Jan Beulich | 176a271 | 2006-06-26 13:57:41 +0200 | [diff] [blame] | 944 | movl 4(%esp), %edx |
| 945 | movl (%esp), %ecx |
| 946 | leal 4(%esp), %eax |
| 947 | movl %ebx, EBX(%edx) |
| 948 | xorl %ebx, %ebx |
| 949 | movl %ebx, ECX(%edx) |
| 950 | movl %ebx, EDX(%edx) |
| 951 | movl %esi, ESI(%edx) |
| 952 | movl %edi, EDI(%edx) |
| 953 | movl %ebp, EBP(%edx) |
| 954 | movl %ebx, EAX(%edx) |
| 955 | movl $__USER_DS, DS(%edx) |
| 956 | movl $__USER_DS, ES(%edx) |
| 957 | movl %ebx, ORIG_EAX(%edx) |
| 958 | movl %ecx, EIP(%edx) |
| 959 | movl 12(%esp), %ecx |
| 960 | movl $__KERNEL_CS, CS(%edx) |
| 961 | movl %ebx, EFLAGS(%edx) |
| 962 | movl %eax, OLDESP(%edx) |
| 963 | movl 8(%esp), %eax |
| 964 | movl %ecx, 8(%esp) |
| 965 | movl EBX(%edx), %ebx |
| 966 | movl $__KERNEL_DS, OLDSS(%edx) |
| 967 | jmpl *%eax |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 968 | CFI_ENDPROC |
Jan Beulich | 176a271 | 2006-06-26 13:57:41 +0200 | [diff] [blame] | 969 | ENDPROC(arch_unwind_init_running) |
| 970 | #endif |
| 971 | |
Andi Kleen | 02ba1a3 | 2006-09-26 10:52:35 +0200 | [diff] [blame] | 972 | ENTRY(kernel_thread_helper) |
| 973 | pushl $0 # fake return address for unwinder |
| 974 | CFI_STARTPROC |
| 975 | movl %edx,%eax |
| 976 | push %edx |
| 977 | CFI_ADJUST_CFA_OFFSET 4 |
| 978 | call *%ebx |
| 979 | push %eax |
| 980 | CFI_ADJUST_CFA_OFFSET 4 |
| 981 | call do_exit |
| 982 | CFI_ENDPROC |
| 983 | ENDPROC(kernel_thread_helper) |
| 984 | |
Arjan van de Ven | bb152f5 | 2006-01-06 00:12:05 -0800 | [diff] [blame] | 985 | .section .rodata,"a" |
Paolo 'Blaisorblade' Giarrusso | 5e7b83f | 2005-05-01 08:58:55 -0700 | [diff] [blame] | 986 | #include "syscall_table.S" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 987 | |
| 988 | syscall_table_size=(.-sys_call_table) |