Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * linux/arch/x86_64/entry.S |
| 3 | * |
| 4 | * Copyright (C) 1991, 1992 Linus Torvalds |
| 5 | * Copyright (C) 2000, 2001, 2002 Andi Kleen SuSE Labs |
| 6 | * Copyright (C) 2000 Pavel Machek <pavel@suse.cz> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | /* |
| 10 | * entry.S contains the system-call and fault low-level handling routines. |
| 11 | * |
| 12 | * NOTE: This code handles signal-recognition, which happens every time |
| 13 | * after an interrupt and after each system call. |
| 14 | * |
| 15 | * Normal syscalls and interrupts don't save a full stack frame, this is |
| 16 | * only done for syscall tracing, signals or fork/exec et.al. |
| 17 | * |
| 18 | * A note on terminology: |
| 19 | * - top of stack: Architecture defined interrupt frame from SS to RIP |
| 20 | * at the top of the kernel process stack. |
| 21 | * - partial stack frame: partially saved registers upto R11. |
| 22 | * - full stack frame: Like partial stack frame, but all register saved. |
Andi Kleen | 2e91a17 | 2006-09-26 10:52:29 +0200 | [diff] [blame] | 23 | * |
| 24 | * Some macro usage: |
| 25 | * - CFI macros are used to generate dwarf2 unwind information for better |
| 26 | * backtraces. They don't change any code. |
| 27 | * - SAVE_ALL/RESTORE_ALL - Save/restore all registers |
| 28 | * - SAVE_ARGS/RESTORE_ARGS - Save/restore registers that C functions modify. |
| 29 | * There are unfortunately lots of special cases where some registers |
| 30 | * not touched. The macro is a big mess that should be cleaned up. |
| 31 | * - SAVE_REST/RESTORE_REST - Handle the registers not saved by SAVE_ARGS. |
| 32 | * Gives a full stack frame. |
| 33 | * - ENTRY/END Define functions in the symbol table. |
| 34 | * - FIXUP_TOP_OF_STACK/RESTORE_TOP_OF_STACK - Fix up the hardware stack |
| 35 | * frame that is otherwise undefined after a SYSCALL |
| 36 | * - TRACE_IRQ_* - Trace hard interrupt state for lock debugging. |
| 37 | * - errorentry/paranoidentry/zeroentry - Define exception entry points. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | */ |
| 39 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | #include <linux/linkage.h> |
| 41 | #include <asm/segment.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | #include <asm/cache.h> |
| 43 | #include <asm/errno.h> |
| 44 | #include <asm/dwarf2.h> |
| 45 | #include <asm/calling.h> |
Sam Ravnborg | e2d5df9 | 2005-09-09 21:28:48 +0200 | [diff] [blame] | 46 | #include <asm/asm-offsets.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | #include <asm/msr.h> |
| 48 | #include <asm/unistd.h> |
| 49 | #include <asm/thread_info.h> |
| 50 | #include <asm/hw_irq.h> |
Andi Kleen | 5f8efbb | 2006-01-16 01:56:39 +0100 | [diff] [blame] | 51 | #include <asm/page.h> |
Ingo Molnar | 2601e64 | 2006-07-03 00:24:45 -0700 | [diff] [blame] | 52 | #include <asm/irqflags.h> |
Glauber de Oliveira Costa | 72fe485 | 2008-01-30 13:32:08 +0100 | [diff] [blame] | 53 | #include <asm/paravirt.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | |
| 55 | .code64 |
| 56 | |
Andi Kleen | dc37db4 | 2005-04-16 15:25:05 -0700 | [diff] [blame] | 57 | #ifndef CONFIG_PREEMPT |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | #define retint_kernel retint_restore_args |
| 59 | #endif |
Ingo Molnar | 2601e64 | 2006-07-03 00:24:45 -0700 | [diff] [blame] | 60 | |
Glauber de Oliveira Costa | 72fe485 | 2008-01-30 13:32:08 +0100 | [diff] [blame] | 61 | #ifdef CONFIG_PARAVIRT |
Jeremy Fitzhardinge | 2be2998 | 2008-06-25 00:19:28 -0400 | [diff] [blame] | 62 | ENTRY(native_usergs_sysret64) |
Glauber de Oliveira Costa | 72fe485 | 2008-01-30 13:32:08 +0100 | [diff] [blame] | 63 | swapgs |
| 64 | sysretq |
| 65 | #endif /* CONFIG_PARAVIRT */ |
| 66 | |
Ingo Molnar | 2601e64 | 2006-07-03 00:24:45 -0700 | [diff] [blame] | 67 | |
| 68 | .macro TRACE_IRQS_IRETQ offset=ARGOFFSET |
| 69 | #ifdef CONFIG_TRACE_IRQFLAGS |
| 70 | bt $9,EFLAGS-\offset(%rsp) /* interrupts off? */ |
| 71 | jnc 1f |
| 72 | TRACE_IRQS_ON |
| 73 | 1: |
| 74 | #endif |
| 75 | .endm |
| 76 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 | /* |
| 78 | * C code is not supposed to know about undefined top of stack. Every time |
| 79 | * a C function with an pt_regs argument is called from the SYSCALL based |
| 80 | * fast path FIXUP_TOP_OF_STACK is needed. |
| 81 | * RESTORE_TOP_OF_STACK syncs the syscall state after any possible ptregs |
| 82 | * manipulation. |
| 83 | */ |
| 84 | |
| 85 | /* %rsp:at FRAMEEND */ |
| 86 | .macro FIXUP_TOP_OF_STACK tmp |
| 87 | movq %gs:pda_oldrsp,\tmp |
| 88 | movq \tmp,RSP(%rsp) |
| 89 | movq $__USER_DS,SS(%rsp) |
| 90 | movq $__USER_CS,CS(%rsp) |
| 91 | movq $-1,RCX(%rsp) |
| 92 | movq R11(%rsp),\tmp /* get eflags */ |
| 93 | movq \tmp,EFLAGS(%rsp) |
| 94 | .endm |
| 95 | |
| 96 | .macro RESTORE_TOP_OF_STACK tmp,offset=0 |
| 97 | movq RSP-\offset(%rsp),\tmp |
| 98 | movq \tmp,%gs:pda_oldrsp |
| 99 | movq EFLAGS-\offset(%rsp),\tmp |
| 100 | movq \tmp,R11-\offset(%rsp) |
| 101 | .endm |
| 102 | |
| 103 | .macro FAKE_STACK_FRAME child_rip |
| 104 | /* push in order ss, rsp, eflags, cs, rip */ |
Andi Kleen | 3829ee6 | 2005-07-28 21:15:48 -0700 | [diff] [blame] | 105 | xorl %eax, %eax |
Jeremy Fitzhardinge | e04e0a6 | 2008-06-25 00:19:25 -0400 | [diff] [blame] | 106 | pushq $__KERNEL_DS /* ss */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 107 | CFI_ADJUST_CFA_OFFSET 8 |
Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 108 | /*CFI_REL_OFFSET ss,0*/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 109 | pushq %rax /* rsp */ |
| 110 | CFI_ADJUST_CFA_OFFSET 8 |
Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 111 | CFI_REL_OFFSET rsp,0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 112 | pushq $(1<<9) /* eflags - interrupts on */ |
| 113 | CFI_ADJUST_CFA_OFFSET 8 |
Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 114 | /*CFI_REL_OFFSET rflags,0*/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 115 | pushq $__KERNEL_CS /* cs */ |
| 116 | CFI_ADJUST_CFA_OFFSET 8 |
Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 117 | /*CFI_REL_OFFSET cs,0*/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 118 | pushq \child_rip /* rip */ |
| 119 | CFI_ADJUST_CFA_OFFSET 8 |
Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 120 | CFI_REL_OFFSET rip,0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 121 | pushq %rax /* orig rax */ |
| 122 | CFI_ADJUST_CFA_OFFSET 8 |
| 123 | .endm |
| 124 | |
| 125 | .macro UNFAKE_STACK_FRAME |
| 126 | addq $8*6, %rsp |
| 127 | CFI_ADJUST_CFA_OFFSET -(6*8) |
| 128 | .endm |
| 129 | |
Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 130 | .macro CFI_DEFAULT_STACK start=1 |
| 131 | .if \start |
| 132 | CFI_STARTPROC simple |
Jan Beulich | adf1423 | 2006-09-26 10:52:41 +0200 | [diff] [blame] | 133 | CFI_SIGNAL_FRAME |
Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 134 | CFI_DEF_CFA rsp,SS+8 |
| 135 | .else |
| 136 | CFI_DEF_CFA_OFFSET SS+8 |
| 137 | .endif |
| 138 | CFI_REL_OFFSET r15,R15 |
| 139 | CFI_REL_OFFSET r14,R14 |
| 140 | CFI_REL_OFFSET r13,R13 |
| 141 | CFI_REL_OFFSET r12,R12 |
| 142 | CFI_REL_OFFSET rbp,RBP |
| 143 | CFI_REL_OFFSET rbx,RBX |
| 144 | CFI_REL_OFFSET r11,R11 |
| 145 | CFI_REL_OFFSET r10,R10 |
| 146 | CFI_REL_OFFSET r9,R9 |
| 147 | CFI_REL_OFFSET r8,R8 |
| 148 | CFI_REL_OFFSET rax,RAX |
| 149 | CFI_REL_OFFSET rcx,RCX |
| 150 | CFI_REL_OFFSET rdx,RDX |
| 151 | CFI_REL_OFFSET rsi,RSI |
| 152 | CFI_REL_OFFSET rdi,RDI |
| 153 | CFI_REL_OFFSET rip,RIP |
| 154 | /*CFI_REL_OFFSET cs,CS*/ |
| 155 | /*CFI_REL_OFFSET rflags,EFLAGS*/ |
| 156 | CFI_REL_OFFSET rsp,RSP |
| 157 | /*CFI_REL_OFFSET ss,SS*/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 158 | .endm |
| 159 | /* |
| 160 | * A newly forked process directly context switches into this. |
| 161 | */ |
| 162 | /* rdi: prev */ |
| 163 | ENTRY(ret_from_fork) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 164 | CFI_DEFAULT_STACK |
Andi Kleen | 658fdbe | 2006-09-26 10:52:41 +0200 | [diff] [blame] | 165 | push kernel_eflags(%rip) |
| 166 | CFI_ADJUST_CFA_OFFSET 4 |
| 167 | popf # reset kernel eflags |
| 168 | CFI_ADJUST_CFA_OFFSET -4 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 169 | call schedule_tail |
| 170 | GET_THREAD_INFO(%rcx) |
Glauber Costa | 26ccb8a | 2008-06-24 11:19:35 -0300 | [diff] [blame^] | 171 | testl $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT),TI_flags(%rcx) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 172 | jnz rff_trace |
| 173 | rff_action: |
| 174 | RESTORE_REST |
| 175 | testl $3,CS-ARGOFFSET(%rsp) # from kernel_thread? |
| 176 | je int_ret_from_sys_call |
Glauber Costa | 26ccb8a | 2008-06-24 11:19:35 -0300 | [diff] [blame^] | 177 | testl $_TIF_IA32,TI_flags(%rcx) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 178 | jnz int_ret_from_sys_call |
| 179 | RESTORE_TOP_OF_STACK %rdi,ARGOFFSET |
| 180 | jmp ret_from_sys_call |
| 181 | rff_trace: |
| 182 | movq %rsp,%rdi |
| 183 | call syscall_trace_leave |
| 184 | GET_THREAD_INFO(%rcx) |
| 185 | jmp rff_action |
| 186 | CFI_ENDPROC |
Jan Beulich | 4b787e0 | 2006-06-26 13:56:55 +0200 | [diff] [blame] | 187 | END(ret_from_fork) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 188 | |
| 189 | /* |
| 190 | * System call entry. Upto 6 arguments in registers are supported. |
| 191 | * |
| 192 | * SYSCALL does not save anything on the stack and does not change the |
| 193 | * stack pointer. |
| 194 | */ |
| 195 | |
| 196 | /* |
| 197 | * Register setup: |
| 198 | * rax system call number |
| 199 | * rdi arg0 |
| 200 | * rcx return address for syscall/sysret, C arg3 |
| 201 | * rsi arg1 |
| 202 | * rdx arg2 |
| 203 | * r10 arg3 (--> moved to rcx for C) |
| 204 | * r8 arg4 |
| 205 | * r9 arg5 |
| 206 | * r11 eflags for syscall/sysret, temporary for C |
| 207 | * r12-r15,rbp,rbx saved by C code, not touched. |
| 208 | * |
| 209 | * Interrupts are off on entry. |
| 210 | * Only called from user space. |
| 211 | * |
| 212 | * XXX if we had a free scratch register we could save the RSP into the stack frame |
| 213 | * and report it properly in ps. Unfortunately we haven't. |
Andi Kleen | 7bf36bb | 2006-04-07 19:50:00 +0200 | [diff] [blame] | 214 | * |
| 215 | * When user can change the frames always force IRET. That is because |
| 216 | * it deals with uncanonical addresses better. SYSRET has trouble |
| 217 | * with them due to bugs in both AMD and Intel CPUs. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 218 | */ |
| 219 | |
| 220 | ENTRY(system_call) |
Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 221 | CFI_STARTPROC simple |
Jan Beulich | adf1423 | 2006-09-26 10:52:41 +0200 | [diff] [blame] | 222 | CFI_SIGNAL_FRAME |
Jan Beulich | dffead4 | 2006-06-26 13:57:38 +0200 | [diff] [blame] | 223 | CFI_DEF_CFA rsp,PDA_STACKOFFSET |
Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 224 | CFI_REGISTER rip,rcx |
| 225 | /*CFI_REGISTER rflags,r11*/ |
Glauber de Oliveira Costa | 72fe485 | 2008-01-30 13:32:08 +0100 | [diff] [blame] | 226 | SWAPGS_UNSAFE_STACK |
| 227 | /* |
| 228 | * A hypervisor implementation might want to use a label |
| 229 | * after the swapgs, so that it can do the swapgs |
| 230 | * for the guest and jump here on syscall. |
| 231 | */ |
| 232 | ENTRY(system_call_after_swapgs) |
| 233 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 234 | movq %rsp,%gs:pda_oldrsp |
| 235 | movq %gs:pda_kernelstack,%rsp |
Ingo Molnar | 2601e64 | 2006-07-03 00:24:45 -0700 | [diff] [blame] | 236 | /* |
| 237 | * No need to follow this irqs off/on section - it's straight |
| 238 | * and short: |
| 239 | */ |
Glauber de Oliveira Costa | 72fe485 | 2008-01-30 13:32:08 +0100 | [diff] [blame] | 240 | ENABLE_INTERRUPTS(CLBR_NONE) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 241 | SAVE_ARGS 8,1 |
| 242 | movq %rax,ORIG_RAX-ARGOFFSET(%rsp) |
Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 243 | movq %rcx,RIP-ARGOFFSET(%rsp) |
| 244 | CFI_REL_OFFSET rip,RIP-ARGOFFSET |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 245 | GET_THREAD_INFO(%rcx) |
Glauber Costa | 26ccb8a | 2008-06-24 11:19:35 -0300 | [diff] [blame^] | 246 | testl $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP), \ |
| 247 | TI_flags(%rcx) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 248 | jnz tracesys |
| 249 | cmpq $__NR_syscall_max,%rax |
| 250 | ja badsys |
| 251 | movq %r10,%rcx |
| 252 | call *sys_call_table(,%rax,8) # XXX: rip relative |
| 253 | movq %rax,RAX-ARGOFFSET(%rsp) |
| 254 | /* |
| 255 | * Syscall return path ending with SYSRET (fast path) |
| 256 | * Has incomplete stack frame and undefined top of stack. |
| 257 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 258 | ret_from_sys_call: |
Andi Kleen | 11b854b | 2005-04-16 15:25:02 -0700 | [diff] [blame] | 259 | movl $_TIF_ALLWORK_MASK,%edi |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 260 | /* edi: flagmask */ |
| 261 | sysret_check: |
Peter Zijlstra | 10cd706 | 2007-10-11 22:11:12 +0200 | [diff] [blame] | 262 | LOCKDEP_SYS_EXIT |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 263 | GET_THREAD_INFO(%rcx) |
Glauber de Oliveira Costa | 72fe485 | 2008-01-30 13:32:08 +0100 | [diff] [blame] | 264 | DISABLE_INTERRUPTS(CLBR_NONE) |
Ingo Molnar | 2601e64 | 2006-07-03 00:24:45 -0700 | [diff] [blame] | 265 | TRACE_IRQS_OFF |
Glauber Costa | 26ccb8a | 2008-06-24 11:19:35 -0300 | [diff] [blame^] | 266 | movl TI_flags(%rcx),%edx |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 267 | andl %edi,%edx |
| 268 | jnz sysret_careful |
Jan Beulich | bcddc01 | 2006-12-07 02:14:02 +0100 | [diff] [blame] | 269 | CFI_REMEMBER_STATE |
Ingo Molnar | 2601e64 | 2006-07-03 00:24:45 -0700 | [diff] [blame] | 270 | /* |
| 271 | * sysretq will re-enable interrupts: |
| 272 | */ |
| 273 | TRACE_IRQS_ON |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 274 | movq RIP-ARGOFFSET(%rsp),%rcx |
Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 275 | CFI_REGISTER rip,rcx |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 276 | RESTORE_ARGS 0,-ARG_SKIP,1 |
Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 277 | /*CFI_REGISTER rflags,r11*/ |
Jeremy Fitzhardinge | c7245da | 2008-06-25 00:19:27 -0400 | [diff] [blame] | 278 | movq %gs:pda_oldrsp, %rsp |
Jeremy Fitzhardinge | 2be2998 | 2008-06-25 00:19:28 -0400 | [diff] [blame] | 279 | USERGS_SYSRET64 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 280 | |
Jan Beulich | bcddc01 | 2006-12-07 02:14:02 +0100 | [diff] [blame] | 281 | CFI_RESTORE_STATE |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 282 | /* Handle reschedules */ |
| 283 | /* edx: work, edi: workmask */ |
| 284 | sysret_careful: |
| 285 | bt $TIF_NEED_RESCHED,%edx |
| 286 | jnc sysret_signal |
Ingo Molnar | 2601e64 | 2006-07-03 00:24:45 -0700 | [diff] [blame] | 287 | TRACE_IRQS_ON |
Glauber de Oliveira Costa | 72fe485 | 2008-01-30 13:32:08 +0100 | [diff] [blame] | 288 | ENABLE_INTERRUPTS(CLBR_NONE) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 289 | pushq %rdi |
Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 290 | CFI_ADJUST_CFA_OFFSET 8 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 291 | call schedule |
| 292 | popq %rdi |
Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 293 | CFI_ADJUST_CFA_OFFSET -8 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 294 | jmp sysret_check |
| 295 | |
| 296 | /* Handle a signal */ |
| 297 | sysret_signal: |
Ingo Molnar | 2601e64 | 2006-07-03 00:24:45 -0700 | [diff] [blame] | 298 | TRACE_IRQS_ON |
Glauber de Oliveira Costa | 72fe485 | 2008-01-30 13:32:08 +0100 | [diff] [blame] | 299 | ENABLE_INTERRUPTS(CLBR_NONE) |
Peter Zijlstra | 8f4d37e | 2008-01-25 21:08:29 +0100 | [diff] [blame] | 300 | testl $_TIF_DO_NOTIFY_MASK,%edx |
Andi Kleen | 10ffdbb | 2005-05-16 21:53:19 -0700 | [diff] [blame] | 301 | jz 1f |
| 302 | |
| 303 | /* Really a signal */ |
| 304 | /* edx: work flags (arg3) */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 305 | leaq do_notify_resume(%rip),%rax |
| 306 | leaq -ARGOFFSET(%rsp),%rdi # &pt_regs -> arg1 |
| 307 | xorl %esi,%esi # oldset -> arg2 |
| 308 | call ptregscall_common |
Andi Kleen | 10ffdbb | 2005-05-16 21:53:19 -0700 | [diff] [blame] | 309 | 1: movl $_TIF_NEED_RESCHED,%edi |
Andi Kleen | 7bf36bb | 2006-04-07 19:50:00 +0200 | [diff] [blame] | 310 | /* Use IRET because user could have changed frame. This |
| 311 | works because ptregscall_common has called FIXUP_TOP_OF_STACK. */ |
Glauber de Oliveira Costa | 72fe485 | 2008-01-30 13:32:08 +0100 | [diff] [blame] | 312 | DISABLE_INTERRUPTS(CLBR_NONE) |
Ingo Molnar | 2601e64 | 2006-07-03 00:24:45 -0700 | [diff] [blame] | 313 | TRACE_IRQS_OFF |
Andi Kleen | 7bf36bb | 2006-04-07 19:50:00 +0200 | [diff] [blame] | 314 | jmp int_with_check |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 315 | |
Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 316 | badsys: |
| 317 | movq $-ENOSYS,RAX-ARGOFFSET(%rsp) |
| 318 | jmp ret_from_sys_call |
| 319 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 320 | /* Do syscall tracing */ |
| 321 | tracesys: |
| 322 | SAVE_REST |
Roland McGrath | a31f8dd | 2008-03-16 21:59:11 -0700 | [diff] [blame] | 323 | movq $-ENOSYS,RAX(%rsp) /* ptrace can change this for a bad syscall */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 324 | FIXUP_TOP_OF_STACK %rdi |
| 325 | movq %rsp,%rdi |
| 326 | call syscall_trace_enter |
| 327 | LOAD_ARGS ARGOFFSET /* reload args from stack in case ptrace changed it */ |
| 328 | RESTORE_REST |
| 329 | cmpq $__NR_syscall_max,%rax |
Roland McGrath | a31f8dd | 2008-03-16 21:59:11 -0700 | [diff] [blame] | 330 | ja int_ret_from_sys_call /* RAX(%rsp) set to -ENOSYS above */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 331 | movq %r10,%rcx /* fixup for C */ |
| 332 | call *sys_call_table(,%rax,8) |
Roland McGrath | a31f8dd | 2008-03-16 21:59:11 -0700 | [diff] [blame] | 333 | movq %rax,RAX-ARGOFFSET(%rsp) |
Andi Kleen | 7bf36bb | 2006-04-07 19:50:00 +0200 | [diff] [blame] | 334 | /* Use IRET because user could have changed frame */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 335 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 336 | /* |
| 337 | * Syscall return path ending with IRET. |
| 338 | * Has correct top of stack, but partial stack frame. |
Jan Beulich | bcddc01 | 2006-12-07 02:14:02 +0100 | [diff] [blame] | 339 | */ |
| 340 | .globl int_ret_from_sys_call |
| 341 | int_ret_from_sys_call: |
Glauber de Oliveira Costa | 72fe485 | 2008-01-30 13:32:08 +0100 | [diff] [blame] | 342 | DISABLE_INTERRUPTS(CLBR_NONE) |
Ingo Molnar | 2601e64 | 2006-07-03 00:24:45 -0700 | [diff] [blame] | 343 | TRACE_IRQS_OFF |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 344 | testl $3,CS-ARGOFFSET(%rsp) |
| 345 | je retint_restore_args |
| 346 | movl $_TIF_ALLWORK_MASK,%edi |
| 347 | /* edi: mask to check */ |
| 348 | int_with_check: |
Peter Zijlstra | 10cd706 | 2007-10-11 22:11:12 +0200 | [diff] [blame] | 349 | LOCKDEP_SYS_EXIT_IRQ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 350 | GET_THREAD_INFO(%rcx) |
Glauber Costa | 26ccb8a | 2008-06-24 11:19:35 -0300 | [diff] [blame^] | 351 | movl TI_flags(%rcx),%edx |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 352 | andl %edi,%edx |
| 353 | jnz int_careful |
Glauber Costa | 26ccb8a | 2008-06-24 11:19:35 -0300 | [diff] [blame^] | 354 | andl $~TS_COMPAT,TI_status(%rcx) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 355 | jmp retint_swapgs |
| 356 | |
| 357 | /* Either reschedule or signal or syscall exit tracking needed. */ |
| 358 | /* First do a reschedule test. */ |
| 359 | /* edx: work, edi: workmask */ |
| 360 | int_careful: |
| 361 | bt $TIF_NEED_RESCHED,%edx |
| 362 | jnc int_very_careful |
Ingo Molnar | 2601e64 | 2006-07-03 00:24:45 -0700 | [diff] [blame] | 363 | TRACE_IRQS_ON |
Glauber de Oliveira Costa | 72fe485 | 2008-01-30 13:32:08 +0100 | [diff] [blame] | 364 | ENABLE_INTERRUPTS(CLBR_NONE) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 365 | pushq %rdi |
Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 366 | CFI_ADJUST_CFA_OFFSET 8 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 367 | call schedule |
| 368 | popq %rdi |
Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 369 | CFI_ADJUST_CFA_OFFSET -8 |
Glauber de Oliveira Costa | 72fe485 | 2008-01-30 13:32:08 +0100 | [diff] [blame] | 370 | DISABLE_INTERRUPTS(CLBR_NONE) |
Ingo Molnar | 2601e64 | 2006-07-03 00:24:45 -0700 | [diff] [blame] | 371 | TRACE_IRQS_OFF |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 372 | jmp int_with_check |
| 373 | |
| 374 | /* handle signals and tracing -- both require a full stack frame */ |
| 375 | int_very_careful: |
Ingo Molnar | 2601e64 | 2006-07-03 00:24:45 -0700 | [diff] [blame] | 376 | TRACE_IRQS_ON |
Glauber de Oliveira Costa | 72fe485 | 2008-01-30 13:32:08 +0100 | [diff] [blame] | 377 | ENABLE_INTERRUPTS(CLBR_NONE) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 378 | SAVE_REST |
| 379 | /* Check for syscall exit trace */ |
| 380 | testl $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SINGLESTEP),%edx |
| 381 | jz int_signal |
| 382 | pushq %rdi |
Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 383 | CFI_ADJUST_CFA_OFFSET 8 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 384 | leaq 8(%rsp),%rdi # &ptregs -> arg1 |
| 385 | call syscall_trace_leave |
| 386 | popq %rdi |
Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 387 | CFI_ADJUST_CFA_OFFSET -8 |
Andi Kleen | 36c1104 | 2005-04-16 15:25:01 -0700 | [diff] [blame] | 388 | andl $~(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SINGLESTEP),%edi |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 389 | jmp int_restore_rest |
| 390 | |
| 391 | int_signal: |
Peter Zijlstra | 8f4d37e | 2008-01-25 21:08:29 +0100 | [diff] [blame] | 392 | testl $_TIF_DO_NOTIFY_MASK,%edx |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 393 | jz 1f |
| 394 | movq %rsp,%rdi # &ptregs -> arg1 |
| 395 | xorl %esi,%esi # oldset -> arg2 |
| 396 | call do_notify_resume |
| 397 | 1: movl $_TIF_NEED_RESCHED,%edi |
| 398 | int_restore_rest: |
| 399 | RESTORE_REST |
Glauber de Oliveira Costa | 72fe485 | 2008-01-30 13:32:08 +0100 | [diff] [blame] | 400 | DISABLE_INTERRUPTS(CLBR_NONE) |
Ingo Molnar | 2601e64 | 2006-07-03 00:24:45 -0700 | [diff] [blame] | 401 | TRACE_IRQS_OFF |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 402 | jmp int_with_check |
| 403 | CFI_ENDPROC |
Jan Beulich | bcddc01 | 2006-12-07 02:14:02 +0100 | [diff] [blame] | 404 | END(system_call) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 405 | |
| 406 | /* |
| 407 | * Certain special system calls that need to save a complete full stack frame. |
| 408 | */ |
| 409 | |
| 410 | .macro PTREGSCALL label,func,arg |
| 411 | .globl \label |
| 412 | \label: |
| 413 | leaq \func(%rip),%rax |
| 414 | leaq -ARGOFFSET+8(%rsp),\arg /* 8 for return address */ |
| 415 | jmp ptregscall_common |
Jan Beulich | 4b787e0 | 2006-06-26 13:56:55 +0200 | [diff] [blame] | 416 | END(\label) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 417 | .endm |
| 418 | |
Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 419 | CFI_STARTPROC |
| 420 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 421 | PTREGSCALL stub_clone, sys_clone, %r8 |
| 422 | PTREGSCALL stub_fork, sys_fork, %rdi |
| 423 | PTREGSCALL stub_vfork, sys_vfork, %rdi |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 424 | PTREGSCALL stub_sigaltstack, sys_sigaltstack, %rdx |
| 425 | PTREGSCALL stub_iopl, sys_iopl, %rsi |
| 426 | |
| 427 | ENTRY(ptregscall_common) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 428 | popq %r11 |
Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 429 | CFI_ADJUST_CFA_OFFSET -8 |
| 430 | CFI_REGISTER rip, r11 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 431 | SAVE_REST |
| 432 | movq %r11, %r15 |
Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 433 | CFI_REGISTER rip, r15 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 434 | FIXUP_TOP_OF_STACK %r11 |
| 435 | call *%rax |
| 436 | RESTORE_TOP_OF_STACK %r11 |
| 437 | movq %r15, %r11 |
Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 438 | CFI_REGISTER rip, r11 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 439 | RESTORE_REST |
| 440 | pushq %r11 |
Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 441 | CFI_ADJUST_CFA_OFFSET 8 |
| 442 | CFI_REL_OFFSET rip, 0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 443 | ret |
| 444 | CFI_ENDPROC |
Jan Beulich | 4b787e0 | 2006-06-26 13:56:55 +0200 | [diff] [blame] | 445 | END(ptregscall_common) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 446 | |
| 447 | ENTRY(stub_execve) |
| 448 | CFI_STARTPROC |
| 449 | popq %r11 |
Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 450 | CFI_ADJUST_CFA_OFFSET -8 |
| 451 | CFI_REGISTER rip, r11 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 452 | SAVE_REST |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 453 | FIXUP_TOP_OF_STACK %r11 |
Ingo Molnar | 5d119b2 | 2008-02-26 12:55:57 +0100 | [diff] [blame] | 454 | movq %rsp, %rcx |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 455 | call sys_execve |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 456 | RESTORE_TOP_OF_STACK %r11 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 457 | movq %rax,RAX(%rsp) |
| 458 | RESTORE_REST |
| 459 | jmp int_ret_from_sys_call |
| 460 | CFI_ENDPROC |
Jan Beulich | 4b787e0 | 2006-06-26 13:56:55 +0200 | [diff] [blame] | 461 | END(stub_execve) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 462 | |
| 463 | /* |
| 464 | * sigreturn is special because it needs to restore all registers on return. |
| 465 | * This cannot be done with SYSRET, so use the IRET return path instead. |
| 466 | */ |
| 467 | ENTRY(stub_rt_sigreturn) |
| 468 | CFI_STARTPROC |
Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 469 | addq $8, %rsp |
| 470 | CFI_ADJUST_CFA_OFFSET -8 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 471 | SAVE_REST |
| 472 | movq %rsp,%rdi |
| 473 | FIXUP_TOP_OF_STACK %r11 |
| 474 | call sys_rt_sigreturn |
| 475 | movq %rax,RAX(%rsp) # fixme, this could be done at the higher layer |
| 476 | RESTORE_REST |
| 477 | jmp int_ret_from_sys_call |
| 478 | CFI_ENDPROC |
Jan Beulich | 4b787e0 | 2006-06-26 13:56:55 +0200 | [diff] [blame] | 479 | END(stub_rt_sigreturn) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 480 | |
Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 481 | /* |
| 482 | * initial frame state for interrupts and exceptions |
| 483 | */ |
| 484 | .macro _frame ref |
| 485 | CFI_STARTPROC simple |
Jan Beulich | adf1423 | 2006-09-26 10:52:41 +0200 | [diff] [blame] | 486 | CFI_SIGNAL_FRAME |
Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 487 | CFI_DEF_CFA rsp,SS+8-\ref |
| 488 | /*CFI_REL_OFFSET ss,SS-\ref*/ |
| 489 | CFI_REL_OFFSET rsp,RSP-\ref |
| 490 | /*CFI_REL_OFFSET rflags,EFLAGS-\ref*/ |
| 491 | /*CFI_REL_OFFSET cs,CS-\ref*/ |
| 492 | CFI_REL_OFFSET rip,RIP-\ref |
| 493 | .endm |
| 494 | |
| 495 | /* initial frame state for interrupts (and exceptions without error code) */ |
| 496 | #define INTR_FRAME _frame RIP |
| 497 | /* initial frame state for exceptions with error code (and interrupts with |
| 498 | vector already pushed) */ |
| 499 | #define XCPT_FRAME _frame ORIG_RAX |
| 500 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 501 | /* |
| 502 | * Interrupt entry/exit. |
| 503 | * |
| 504 | * Interrupt entry points save only callee clobbered registers in fast path. |
| 505 | * |
| 506 | * Entry runs with interrupts off. |
| 507 | */ |
| 508 | |
| 509 | /* 0(%rsp): interrupt number */ |
| 510 | .macro interrupt func |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 511 | cld |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 512 | SAVE_ARGS |
| 513 | leaq -ARGOFFSET(%rsp),%rdi # arg1 for handler |
Jan Beulich | 1de9c3f | 2006-06-26 13:57:35 +0200 | [diff] [blame] | 514 | pushq %rbp |
| 515 | CFI_ADJUST_CFA_OFFSET 8 |
| 516 | CFI_REL_OFFSET rbp, 0 |
| 517 | movq %rsp,%rbp |
| 518 | CFI_DEF_CFA_REGISTER rbp |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 519 | testl $3,CS(%rdi) |
| 520 | je 1f |
Glauber de Oliveira Costa | 72fe485 | 2008-01-30 13:32:08 +0100 | [diff] [blame] | 521 | SWAPGS |
Andi Kleen | 96e5404 | 2006-09-26 10:52:39 +0200 | [diff] [blame] | 522 | /* irqcount is used to check if a CPU is already on an interrupt |
| 523 | stack or not. While this is essentially redundant with preempt_count |
| 524 | it is a little cheaper to use a separate counter in the PDA |
| 525 | (short of moving irq_enter into assembly, which would be too |
| 526 | much work) */ |
| 527 | 1: incl %gs:pda_irqcount |
Jan Beulich | 1de9c3f | 2006-06-26 13:57:35 +0200 | [diff] [blame] | 528 | cmoveq %gs:pda_irqstackptr,%rsp |
Andi Kleen | 2699500 | 2006-08-02 22:37:28 +0200 | [diff] [blame] | 529 | push %rbp # backlink for old unwinder |
Ingo Molnar | 2601e64 | 2006-07-03 00:24:45 -0700 | [diff] [blame] | 530 | /* |
| 531 | * We entered an interrupt context - irqs are off: |
| 532 | */ |
| 533 | TRACE_IRQS_OFF |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 534 | call \func |
| 535 | .endm |
| 536 | |
| 537 | ENTRY(common_interrupt) |
Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 538 | XCPT_FRAME |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 539 | interrupt do_IRQ |
| 540 | /* 0(%rsp): oldrsp-ARGOFFSET */ |
Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 541 | ret_from_intr: |
Glauber de Oliveira Costa | 72fe485 | 2008-01-30 13:32:08 +0100 | [diff] [blame] | 542 | DISABLE_INTERRUPTS(CLBR_NONE) |
Ingo Molnar | 2601e64 | 2006-07-03 00:24:45 -0700 | [diff] [blame] | 543 | TRACE_IRQS_OFF |
Andi Kleen | 3829ee6 | 2005-07-28 21:15:48 -0700 | [diff] [blame] | 544 | decl %gs:pda_irqcount |
Jan Beulich | 1de9c3f | 2006-06-26 13:57:35 +0200 | [diff] [blame] | 545 | leaveq |
Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 546 | CFI_DEF_CFA_REGISTER rsp |
Jan Beulich | 1de9c3f | 2006-06-26 13:57:35 +0200 | [diff] [blame] | 547 | CFI_ADJUST_CFA_OFFSET -8 |
Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 548 | exit_intr: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 549 | GET_THREAD_INFO(%rcx) |
| 550 | testl $3,CS-ARGOFFSET(%rsp) |
| 551 | je retint_kernel |
| 552 | |
| 553 | /* Interrupt came from user space */ |
| 554 | /* |
| 555 | * Has a correct top of stack, but a partial stack frame |
| 556 | * %rcx: thread info. Interrupts off. |
| 557 | */ |
| 558 | retint_with_reschedule: |
| 559 | movl $_TIF_WORK_MASK,%edi |
Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 560 | retint_check: |
Peter Zijlstra | 10cd706 | 2007-10-11 22:11:12 +0200 | [diff] [blame] | 561 | LOCKDEP_SYS_EXIT_IRQ |
Glauber Costa | 26ccb8a | 2008-06-24 11:19:35 -0300 | [diff] [blame^] | 562 | movl TI_flags(%rcx),%edx |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 563 | andl %edi,%edx |
Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 564 | CFI_REMEMBER_STATE |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 565 | jnz retint_careful |
Peter Zijlstra | 10cd706 | 2007-10-11 22:11:12 +0200 | [diff] [blame] | 566 | |
| 567 | retint_swapgs: /* return to user-space */ |
Ingo Molnar | 2601e64 | 2006-07-03 00:24:45 -0700 | [diff] [blame] | 568 | /* |
| 569 | * The iretq could re-enable interrupts: |
| 570 | */ |
Glauber de Oliveira Costa | 72fe485 | 2008-01-30 13:32:08 +0100 | [diff] [blame] | 571 | DISABLE_INTERRUPTS(CLBR_ANY) |
Ingo Molnar | 2601e64 | 2006-07-03 00:24:45 -0700 | [diff] [blame] | 572 | TRACE_IRQS_IRETQ |
Glauber de Oliveira Costa | 72fe485 | 2008-01-30 13:32:08 +0100 | [diff] [blame] | 573 | SWAPGS |
Ingo Molnar | 2601e64 | 2006-07-03 00:24:45 -0700 | [diff] [blame] | 574 | jmp restore_args |
| 575 | |
Peter Zijlstra | 10cd706 | 2007-10-11 22:11:12 +0200 | [diff] [blame] | 576 | retint_restore_args: /* return to kernel space */ |
Glauber de Oliveira Costa | 72fe485 | 2008-01-30 13:32:08 +0100 | [diff] [blame] | 577 | DISABLE_INTERRUPTS(CLBR_ANY) |
Ingo Molnar | 2601e64 | 2006-07-03 00:24:45 -0700 | [diff] [blame] | 578 | /* |
| 579 | * The iretq could re-enable interrupts: |
| 580 | */ |
| 581 | TRACE_IRQS_IRETQ |
| 582 | restore_args: |
Ingo Molnar | 3701d863 | 2008-02-09 23:24:08 +0100 | [diff] [blame] | 583 | RESTORE_ARGS 0,8,0 |
| 584 | |
Adrian Bunk | f7f3d79 | 2008-02-13 23:29:53 +0200 | [diff] [blame] | 585 | irq_return: |
Glauber de Oliveira Costa | 72fe485 | 2008-01-30 13:32:08 +0100 | [diff] [blame] | 586 | INTERRUPT_RETURN |
Ingo Molnar | 3701d863 | 2008-02-09 23:24:08 +0100 | [diff] [blame] | 587 | |
| 588 | .section __ex_table, "a" |
| 589 | .quad irq_return, bad_iret |
| 590 | .previous |
| 591 | |
| 592 | #ifdef CONFIG_PARAVIRT |
Glauber de Oliveira Costa | 72fe485 | 2008-01-30 13:32:08 +0100 | [diff] [blame] | 593 | ENTRY(native_iret) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 594 | iretq |
| 595 | |
| 596 | .section __ex_table,"a" |
Glauber de Oliveira Costa | 72fe485 | 2008-01-30 13:32:08 +0100 | [diff] [blame] | 597 | .quad native_iret, bad_iret |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 598 | .previous |
Ingo Molnar | 3701d863 | 2008-02-09 23:24:08 +0100 | [diff] [blame] | 599 | #endif |
| 600 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 601 | .section .fixup,"ax" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 602 | bad_iret: |
Roland McGrath | 3aa4b37 | 2008-02-06 22:39:43 +0100 | [diff] [blame] | 603 | /* |
| 604 | * The iret traps when the %cs or %ss being restored is bogus. |
| 605 | * We've lost the original trap vector and error code. |
| 606 | * #GPF is the most likely one to get for an invalid selector. |
| 607 | * So pretend we completed the iret and took the #GPF in user mode. |
| 608 | * |
| 609 | * We are now running with the kernel GS after exception recovery. |
| 610 | * But error_entry expects us to have user GS to match the user %cs, |
| 611 | * so swap back. |
| 612 | */ |
| 613 | pushq $0 |
| 614 | |
| 615 | SWAPGS |
| 616 | jmp general_protection |
| 617 | |
Glauber de Oliveira Costa | 72fe485 | 2008-01-30 13:32:08 +0100 | [diff] [blame] | 618 | .previous |
| 619 | |
Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 620 | /* edi: workmask, edx: work */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 621 | retint_careful: |
Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 622 | CFI_RESTORE_STATE |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 623 | bt $TIF_NEED_RESCHED,%edx |
| 624 | jnc retint_signal |
Ingo Molnar | 2601e64 | 2006-07-03 00:24:45 -0700 | [diff] [blame] | 625 | TRACE_IRQS_ON |
Glauber de Oliveira Costa | 72fe485 | 2008-01-30 13:32:08 +0100 | [diff] [blame] | 626 | ENABLE_INTERRUPTS(CLBR_NONE) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 627 | pushq %rdi |
Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 628 | CFI_ADJUST_CFA_OFFSET 8 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 629 | call schedule |
| 630 | popq %rdi |
Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 631 | CFI_ADJUST_CFA_OFFSET -8 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 632 | GET_THREAD_INFO(%rcx) |
Glauber de Oliveira Costa | 72fe485 | 2008-01-30 13:32:08 +0100 | [diff] [blame] | 633 | DISABLE_INTERRUPTS(CLBR_NONE) |
Ingo Molnar | 2601e64 | 2006-07-03 00:24:45 -0700 | [diff] [blame] | 634 | TRACE_IRQS_OFF |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 635 | jmp retint_check |
| 636 | |
| 637 | retint_signal: |
Peter Zijlstra | 8f4d37e | 2008-01-25 21:08:29 +0100 | [diff] [blame] | 638 | testl $_TIF_DO_NOTIFY_MASK,%edx |
Andi Kleen | 10ffdbb | 2005-05-16 21:53:19 -0700 | [diff] [blame] | 639 | jz retint_swapgs |
Ingo Molnar | 2601e64 | 2006-07-03 00:24:45 -0700 | [diff] [blame] | 640 | TRACE_IRQS_ON |
Glauber de Oliveira Costa | 72fe485 | 2008-01-30 13:32:08 +0100 | [diff] [blame] | 641 | ENABLE_INTERRUPTS(CLBR_NONE) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 642 | SAVE_REST |
| 643 | movq $-1,ORIG_RAX(%rsp) |
Andi Kleen | 3829ee6 | 2005-07-28 21:15:48 -0700 | [diff] [blame] | 644 | xorl %esi,%esi # oldset |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 645 | movq %rsp,%rdi # &pt_regs |
| 646 | call do_notify_resume |
| 647 | RESTORE_REST |
Glauber de Oliveira Costa | 72fe485 | 2008-01-30 13:32:08 +0100 | [diff] [blame] | 648 | DISABLE_INTERRUPTS(CLBR_NONE) |
Ingo Molnar | 2601e64 | 2006-07-03 00:24:45 -0700 | [diff] [blame] | 649 | TRACE_IRQS_OFF |
Andi Kleen | 10ffdbb | 2005-05-16 21:53:19 -0700 | [diff] [blame] | 650 | movl $_TIF_NEED_RESCHED,%edi |
Andi Kleen | be9e687 | 2005-05-01 08:58:51 -0700 | [diff] [blame] | 651 | GET_THREAD_INFO(%rcx) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 652 | jmp retint_check |
| 653 | |
| 654 | #ifdef CONFIG_PREEMPT |
| 655 | /* Returning to kernel space. Check if we need preemption */ |
| 656 | /* rcx: threadinfo. interrupts off. */ |
Andi Kleen | b06baba | 2006-09-26 10:52:29 +0200 | [diff] [blame] | 657 | ENTRY(retint_kernel) |
Glauber Costa | 26ccb8a | 2008-06-24 11:19:35 -0300 | [diff] [blame^] | 658 | cmpl $0,TI_preempt_count(%rcx) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 659 | jnz retint_restore_args |
Glauber Costa | 26ccb8a | 2008-06-24 11:19:35 -0300 | [diff] [blame^] | 660 | bt $TIF_NEED_RESCHED,TI_flags(%rcx) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 661 | jnc retint_restore_args |
| 662 | bt $9,EFLAGS-ARGOFFSET(%rsp) /* interrupts off? */ |
| 663 | jnc retint_restore_args |
| 664 | call preempt_schedule_irq |
| 665 | jmp exit_intr |
| 666 | #endif |
Jan Beulich | 4b787e0 | 2006-06-26 13:56:55 +0200 | [diff] [blame] | 667 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 668 | CFI_ENDPROC |
Jan Beulich | 4b787e0 | 2006-06-26 13:56:55 +0200 | [diff] [blame] | 669 | END(common_interrupt) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 670 | |
| 671 | /* |
| 672 | * APIC interrupts. |
| 673 | */ |
| 674 | .macro apicinterrupt num,func |
Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 675 | INTR_FRAME |
Rusty Russell | 19eadf9 | 2006-06-27 02:53:44 -0700 | [diff] [blame] | 676 | pushq $~(\num) |
Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 677 | CFI_ADJUST_CFA_OFFSET 8 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 678 | interrupt \func |
| 679 | jmp ret_from_intr |
| 680 | CFI_ENDPROC |
| 681 | .endm |
| 682 | |
| 683 | ENTRY(thermal_interrupt) |
| 684 | apicinterrupt THERMAL_APIC_VECTOR,smp_thermal_interrupt |
Jan Beulich | 4b787e0 | 2006-06-26 13:56:55 +0200 | [diff] [blame] | 685 | END(thermal_interrupt) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 686 | |
Jacob Shin | 89b831e | 2005-11-05 17:25:53 +0100 | [diff] [blame] | 687 | ENTRY(threshold_interrupt) |
| 688 | apicinterrupt THRESHOLD_APIC_VECTOR,mce_threshold_interrupt |
Jan Beulich | 4b787e0 | 2006-06-26 13:56:55 +0200 | [diff] [blame] | 689 | END(threshold_interrupt) |
Jacob Shin | 89b831e | 2005-11-05 17:25:53 +0100 | [diff] [blame] | 690 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 691 | #ifdef CONFIG_SMP |
| 692 | ENTRY(reschedule_interrupt) |
| 693 | apicinterrupt RESCHEDULE_VECTOR,smp_reschedule_interrupt |
Jan Beulich | 4b787e0 | 2006-06-26 13:56:55 +0200 | [diff] [blame] | 694 | END(reschedule_interrupt) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 695 | |
Andi Kleen | e5bc8b6 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 696 | .macro INVALIDATE_ENTRY num |
| 697 | ENTRY(invalidate_interrupt\num) |
| 698 | apicinterrupt INVALIDATE_TLB_VECTOR_START+\num,smp_invalidate_interrupt |
Jan Beulich | 4b787e0 | 2006-06-26 13:56:55 +0200 | [diff] [blame] | 699 | END(invalidate_interrupt\num) |
Andi Kleen | e5bc8b6 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 700 | .endm |
| 701 | |
| 702 | INVALIDATE_ENTRY 0 |
| 703 | INVALIDATE_ENTRY 1 |
| 704 | INVALIDATE_ENTRY 2 |
| 705 | INVALIDATE_ENTRY 3 |
| 706 | INVALIDATE_ENTRY 4 |
| 707 | INVALIDATE_ENTRY 5 |
| 708 | INVALIDATE_ENTRY 6 |
| 709 | INVALIDATE_ENTRY 7 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 710 | |
| 711 | ENTRY(call_function_interrupt) |
| 712 | apicinterrupt CALL_FUNCTION_VECTOR,smp_call_function_interrupt |
Jan Beulich | 4b787e0 | 2006-06-26 13:56:55 +0200 | [diff] [blame] | 713 | END(call_function_interrupt) |
Eric W. Biederman | 6101429 | 2007-02-23 04:40:58 -0700 | [diff] [blame] | 714 | ENTRY(irq_move_cleanup_interrupt) |
| 715 | apicinterrupt IRQ_MOVE_CLEANUP_VECTOR,smp_irq_move_cleanup_interrupt |
| 716 | END(irq_move_cleanup_interrupt) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 717 | #endif |
| 718 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 719 | ENTRY(apic_timer_interrupt) |
| 720 | apicinterrupt LOCAL_TIMER_VECTOR,smp_apic_timer_interrupt |
Jan Beulich | 4b787e0 | 2006-06-26 13:56:55 +0200 | [diff] [blame] | 721 | END(apic_timer_interrupt) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 722 | |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 723 | ENTRY(uv_bau_message_intr1) |
| 724 | apicinterrupt 220,uv_bau_message_interrupt |
| 725 | END(uv_bau_message_intr1) |
| 726 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 727 | ENTRY(error_interrupt) |
| 728 | apicinterrupt ERROR_APIC_VECTOR,smp_error_interrupt |
Jan Beulich | 4b787e0 | 2006-06-26 13:56:55 +0200 | [diff] [blame] | 729 | END(error_interrupt) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 730 | |
| 731 | ENTRY(spurious_interrupt) |
| 732 | apicinterrupt SPURIOUS_APIC_VECTOR,smp_spurious_interrupt |
Jan Beulich | 4b787e0 | 2006-06-26 13:56:55 +0200 | [diff] [blame] | 733 | END(spurious_interrupt) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 734 | |
| 735 | /* |
| 736 | * Exception entry points. |
| 737 | */ |
| 738 | .macro zeroentry sym |
Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 739 | INTR_FRAME |
Jeremy Fitzhardinge | fab5842 | 2008-06-25 00:19:31 -0400 | [diff] [blame] | 740 | PARAVIRT_ADJUST_EXCEPTION_FRAME |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 741 | pushq $0 /* push error code/oldrax */ |
Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 742 | CFI_ADJUST_CFA_OFFSET 8 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 743 | pushq %rax /* push real oldrax to the rdi slot */ |
Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 744 | CFI_ADJUST_CFA_OFFSET 8 |
Jan Beulich | 3755090 | 2007-05-02 19:27:05 +0200 | [diff] [blame] | 745 | CFI_REL_OFFSET rax,0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 746 | leaq \sym(%rip),%rax |
| 747 | jmp error_entry |
Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 748 | CFI_ENDPROC |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 749 | .endm |
| 750 | |
| 751 | .macro errorentry sym |
Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 752 | XCPT_FRAME |
Jeremy Fitzhardinge | fab5842 | 2008-06-25 00:19:31 -0400 | [diff] [blame] | 753 | PARAVIRT_ADJUST_EXCEPTION_FRAME |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 754 | pushq %rax |
Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 755 | CFI_ADJUST_CFA_OFFSET 8 |
Jan Beulich | 3755090 | 2007-05-02 19:27:05 +0200 | [diff] [blame] | 756 | CFI_REL_OFFSET rax,0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 757 | leaq \sym(%rip),%rax |
| 758 | jmp error_entry |
Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 759 | CFI_ENDPROC |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 760 | .endm |
| 761 | |
| 762 | /* error code is on the stack already */ |
| 763 | /* handle NMI like exceptions that can happen everywhere */ |
Ingo Molnar | 2601e64 | 2006-07-03 00:24:45 -0700 | [diff] [blame] | 764 | .macro paranoidentry sym, ist=0, irqtrace=1 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 765 | SAVE_ALL |
| 766 | cld |
| 767 | movl $1,%ebx |
| 768 | movl $MSR_GS_BASE,%ecx |
| 769 | rdmsr |
| 770 | testl %edx,%edx |
| 771 | js 1f |
Glauber de Oliveira Costa | 72fe485 | 2008-01-30 13:32:08 +0100 | [diff] [blame] | 772 | SWAPGS |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 773 | xorl %ebx,%ebx |
Jan Beulich | b556b35 | 2006-01-11 22:43:00 +0100 | [diff] [blame] | 774 | 1: |
| 775 | .if \ist |
| 776 | movq %gs:pda_data_offset, %rbp |
| 777 | .endif |
| 778 | movq %rsp,%rdi |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 779 | movq ORIG_RAX(%rsp),%rsi |
| 780 | movq $-1,ORIG_RAX(%rsp) |
Jan Beulich | b556b35 | 2006-01-11 22:43:00 +0100 | [diff] [blame] | 781 | .if \ist |
Andi Kleen | 5f8efbb | 2006-01-16 01:56:39 +0100 | [diff] [blame] | 782 | subq $EXCEPTION_STKSZ, per_cpu__init_tss + TSS_ist + (\ist - 1) * 8(%rbp) |
Jan Beulich | b556b35 | 2006-01-11 22:43:00 +0100 | [diff] [blame] | 783 | .endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 784 | call \sym |
Jan Beulich | b556b35 | 2006-01-11 22:43:00 +0100 | [diff] [blame] | 785 | .if \ist |
Andi Kleen | 5f8efbb | 2006-01-16 01:56:39 +0100 | [diff] [blame] | 786 | addq $EXCEPTION_STKSZ, per_cpu__init_tss + TSS_ist + (\ist - 1) * 8(%rbp) |
Jan Beulich | b556b35 | 2006-01-11 22:43:00 +0100 | [diff] [blame] | 787 | .endif |
Glauber de Oliveira Costa | 72fe485 | 2008-01-30 13:32:08 +0100 | [diff] [blame] | 788 | DISABLE_INTERRUPTS(CLBR_NONE) |
Ingo Molnar | 2601e64 | 2006-07-03 00:24:45 -0700 | [diff] [blame] | 789 | .if \irqtrace |
| 790 | TRACE_IRQS_OFF |
| 791 | .endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 792 | .endm |
Ingo Molnar | 2601e64 | 2006-07-03 00:24:45 -0700 | [diff] [blame] | 793 | |
| 794 | /* |
| 795 | * "Paranoid" exit path from exception stack. |
| 796 | * Paranoid because this is used by NMIs and cannot take |
| 797 | * any kernel state for granted. |
| 798 | * We don't do kernel preemption checks here, because only |
| 799 | * NMI should be common and it does not enable IRQs and |
| 800 | * cannot get reschedule ticks. |
| 801 | * |
| 802 | * "trace" is 0 for the NMI handler only, because irq-tracing |
| 803 | * is fundamentally NMI-unsafe. (we cannot change the soft and |
| 804 | * hard flags at once, atomically) |
| 805 | */ |
| 806 | .macro paranoidexit trace=1 |
| 807 | /* ebx: no swapgs flag */ |
| 808 | paranoid_exit\trace: |
| 809 | testl %ebx,%ebx /* swapgs needed? */ |
| 810 | jnz paranoid_restore\trace |
| 811 | testl $3,CS(%rsp) |
| 812 | jnz paranoid_userspace\trace |
| 813 | paranoid_swapgs\trace: |
Andi Kleen | 7a0a2df | 2006-09-26 10:52:37 +0200 | [diff] [blame] | 814 | .if \trace |
Ingo Molnar | 2601e64 | 2006-07-03 00:24:45 -0700 | [diff] [blame] | 815 | TRACE_IRQS_IRETQ 0 |
Andi Kleen | 7a0a2df | 2006-09-26 10:52:37 +0200 | [diff] [blame] | 816 | .endif |
Glauber de Oliveira Costa | 72fe485 | 2008-01-30 13:32:08 +0100 | [diff] [blame] | 817 | SWAPGS_UNSAFE_STACK |
Ingo Molnar | 2601e64 | 2006-07-03 00:24:45 -0700 | [diff] [blame] | 818 | paranoid_restore\trace: |
| 819 | RESTORE_ALL 8 |
Ingo Molnar | 3701d863 | 2008-02-09 23:24:08 +0100 | [diff] [blame] | 820 | jmp irq_return |
Ingo Molnar | 2601e64 | 2006-07-03 00:24:45 -0700 | [diff] [blame] | 821 | paranoid_userspace\trace: |
| 822 | GET_THREAD_INFO(%rcx) |
Glauber Costa | 26ccb8a | 2008-06-24 11:19:35 -0300 | [diff] [blame^] | 823 | movl TI_flags(%rcx),%ebx |
Ingo Molnar | 2601e64 | 2006-07-03 00:24:45 -0700 | [diff] [blame] | 824 | andl $_TIF_WORK_MASK,%ebx |
| 825 | jz paranoid_swapgs\trace |
| 826 | movq %rsp,%rdi /* &pt_regs */ |
| 827 | call sync_regs |
| 828 | movq %rax,%rsp /* switch stack for scheduling */ |
| 829 | testl $_TIF_NEED_RESCHED,%ebx |
| 830 | jnz paranoid_schedule\trace |
| 831 | movl %ebx,%edx /* arg3: thread flags */ |
| 832 | .if \trace |
| 833 | TRACE_IRQS_ON |
| 834 | .endif |
Glauber de Oliveira Costa | 72fe485 | 2008-01-30 13:32:08 +0100 | [diff] [blame] | 835 | ENABLE_INTERRUPTS(CLBR_NONE) |
Ingo Molnar | 2601e64 | 2006-07-03 00:24:45 -0700 | [diff] [blame] | 836 | xorl %esi,%esi /* arg2: oldset */ |
| 837 | movq %rsp,%rdi /* arg1: &pt_regs */ |
| 838 | call do_notify_resume |
Glauber de Oliveira Costa | 72fe485 | 2008-01-30 13:32:08 +0100 | [diff] [blame] | 839 | DISABLE_INTERRUPTS(CLBR_NONE) |
Ingo Molnar | 2601e64 | 2006-07-03 00:24:45 -0700 | [diff] [blame] | 840 | .if \trace |
| 841 | TRACE_IRQS_OFF |
| 842 | .endif |
| 843 | jmp paranoid_userspace\trace |
| 844 | paranoid_schedule\trace: |
| 845 | .if \trace |
| 846 | TRACE_IRQS_ON |
| 847 | .endif |
Glauber de Oliveira Costa | 72fe485 | 2008-01-30 13:32:08 +0100 | [diff] [blame] | 848 | ENABLE_INTERRUPTS(CLBR_ANY) |
Ingo Molnar | 2601e64 | 2006-07-03 00:24:45 -0700 | [diff] [blame] | 849 | call schedule |
Glauber de Oliveira Costa | 72fe485 | 2008-01-30 13:32:08 +0100 | [diff] [blame] | 850 | DISABLE_INTERRUPTS(CLBR_ANY) |
Ingo Molnar | 2601e64 | 2006-07-03 00:24:45 -0700 | [diff] [blame] | 851 | .if \trace |
| 852 | TRACE_IRQS_OFF |
| 853 | .endif |
| 854 | jmp paranoid_userspace\trace |
| 855 | CFI_ENDPROC |
| 856 | .endm |
| 857 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 858 | /* |
| 859 | * Exception entry point. This expects an error code/orig_rax on the stack |
| 860 | * and the exception handler in %rax. |
| 861 | */ |
Prasanna S.P | d28c439 | 2006-09-26 10:52:34 +0200 | [diff] [blame] | 862 | KPROBE_ENTRY(error_entry) |
Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 863 | _frame RDI |
Jan Beulich | 3755090 | 2007-05-02 19:27:05 +0200 | [diff] [blame] | 864 | CFI_REL_OFFSET rax,0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 865 | /* rdi slot contains rax, oldrax contains error code */ |
| 866 | cld |
| 867 | subq $14*8,%rsp |
| 868 | CFI_ADJUST_CFA_OFFSET (14*8) |
| 869 | movq %rsi,13*8(%rsp) |
| 870 | CFI_REL_OFFSET rsi,RSI |
| 871 | movq 14*8(%rsp),%rsi /* load rax from rdi slot */ |
Jan Beulich | 3755090 | 2007-05-02 19:27:05 +0200 | [diff] [blame] | 872 | CFI_REGISTER rax,rsi |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 873 | movq %rdx,12*8(%rsp) |
| 874 | CFI_REL_OFFSET rdx,RDX |
| 875 | movq %rcx,11*8(%rsp) |
| 876 | CFI_REL_OFFSET rcx,RCX |
| 877 | movq %rsi,10*8(%rsp) /* store rax */ |
| 878 | CFI_REL_OFFSET rax,RAX |
| 879 | movq %r8, 9*8(%rsp) |
| 880 | CFI_REL_OFFSET r8,R8 |
| 881 | movq %r9, 8*8(%rsp) |
| 882 | CFI_REL_OFFSET r9,R9 |
| 883 | movq %r10,7*8(%rsp) |
| 884 | CFI_REL_OFFSET r10,R10 |
| 885 | movq %r11,6*8(%rsp) |
| 886 | CFI_REL_OFFSET r11,R11 |
| 887 | movq %rbx,5*8(%rsp) |
| 888 | CFI_REL_OFFSET rbx,RBX |
| 889 | movq %rbp,4*8(%rsp) |
| 890 | CFI_REL_OFFSET rbp,RBP |
| 891 | movq %r12,3*8(%rsp) |
| 892 | CFI_REL_OFFSET r12,R12 |
| 893 | movq %r13,2*8(%rsp) |
| 894 | CFI_REL_OFFSET r13,R13 |
| 895 | movq %r14,1*8(%rsp) |
| 896 | CFI_REL_OFFSET r14,R14 |
| 897 | movq %r15,(%rsp) |
| 898 | CFI_REL_OFFSET r15,R15 |
| 899 | xorl %ebx,%ebx |
| 900 | testl $3,CS(%rsp) |
| 901 | je error_kernelspace |
| 902 | error_swapgs: |
Glauber de Oliveira Costa | 72fe485 | 2008-01-30 13:32:08 +0100 | [diff] [blame] | 903 | SWAPGS |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 904 | error_sti: |
| 905 | movq %rdi,RDI(%rsp) |
Jan Beulich | 3755090 | 2007-05-02 19:27:05 +0200 | [diff] [blame] | 906 | CFI_REL_OFFSET rdi,RDI |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 907 | movq %rsp,%rdi |
| 908 | movq ORIG_RAX(%rsp),%rsi /* get error code */ |
| 909 | movq $-1,ORIG_RAX(%rsp) |
| 910 | call *%rax |
Peter Zijlstra | 10cd706 | 2007-10-11 22:11:12 +0200 | [diff] [blame] | 911 | /* ebx: no swapgs flag (1: don't need swapgs, 0: need it) */ |
| 912 | error_exit: |
| 913 | movl %ebx,%eax |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 914 | RESTORE_REST |
Glauber de Oliveira Costa | 72fe485 | 2008-01-30 13:32:08 +0100 | [diff] [blame] | 915 | DISABLE_INTERRUPTS(CLBR_NONE) |
Ingo Molnar | 2601e64 | 2006-07-03 00:24:45 -0700 | [diff] [blame] | 916 | TRACE_IRQS_OFF |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 917 | GET_THREAD_INFO(%rcx) |
| 918 | testl %eax,%eax |
| 919 | jne retint_kernel |
Peter Zijlstra | 10cd706 | 2007-10-11 22:11:12 +0200 | [diff] [blame] | 920 | LOCKDEP_SYS_EXIT_IRQ |
Glauber Costa | 26ccb8a | 2008-06-24 11:19:35 -0300 | [diff] [blame^] | 921 | movl TI_flags(%rcx),%edx |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 922 | movl $_TIF_WORK_MASK,%edi |
| 923 | andl %edi,%edx |
| 924 | jnz retint_careful |
Peter Zijlstra | 10cd706 | 2007-10-11 22:11:12 +0200 | [diff] [blame] | 925 | jmp retint_swapgs |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 926 | CFI_ENDPROC |
| 927 | |
| 928 | error_kernelspace: |
| 929 | incl %ebx |
| 930 | /* There are two places in the kernel that can potentially fault with |
| 931 | usergs. Handle them here. The exception handlers after |
| 932 | iret run with kernel gs again, so don't set the user space flag. |
| 933 | B stepping K8s sometimes report an truncated RIP for IRET |
| 934 | exceptions returning to compat mode. Check for these here too. */ |
Vegard Nossum | 9d8ad5d | 2008-06-27 17:22:17 +0200 | [diff] [blame] | 935 | leaq irq_return(%rip),%rcx |
| 936 | cmpq %rcx,RIP(%rsp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 937 | je error_swapgs |
Vegard Nossum | 9d8ad5d | 2008-06-27 17:22:17 +0200 | [diff] [blame] | 938 | movl %ecx,%ecx /* zero extend */ |
| 939 | cmpq %rcx,RIP(%rsp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 940 | je error_swapgs |
| 941 | cmpq $gs_change,RIP(%rsp) |
| 942 | je error_swapgs |
| 943 | jmp error_sti |
Prasanna S.P | d28c439 | 2006-09-26 10:52:34 +0200 | [diff] [blame] | 944 | KPROBE_END(error_entry) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 945 | |
| 946 | /* Reload gs selector with exception handling */ |
| 947 | /* edi: new selector */ |
Jeremy Fitzhardinge | 9f9d489 | 2008-06-25 00:19:32 -0400 | [diff] [blame] | 948 | ENTRY(native_load_gs_index) |
Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 949 | CFI_STARTPROC |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 950 | pushf |
Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 951 | CFI_ADJUST_CFA_OFFSET 8 |
Glauber de Oliveira Costa | 72fe485 | 2008-01-30 13:32:08 +0100 | [diff] [blame] | 952 | DISABLE_INTERRUPTS(CLBR_ANY | ~(CLBR_RDI)) |
| 953 | SWAPGS |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 954 | gs_change: |
| 955 | movl %edi,%gs |
| 956 | 2: mfence /* workaround */ |
Glauber de Oliveira Costa | 72fe485 | 2008-01-30 13:32:08 +0100 | [diff] [blame] | 957 | SWAPGS |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 958 | popf |
Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 959 | CFI_ADJUST_CFA_OFFSET -8 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 960 | ret |
Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 961 | CFI_ENDPROC |
Jeremy Fitzhardinge | 9f9d489 | 2008-06-25 00:19:32 -0400 | [diff] [blame] | 962 | ENDPROC(native_load_gs_index) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 963 | |
| 964 | .section __ex_table,"a" |
| 965 | .align 8 |
| 966 | .quad gs_change,bad_gs |
| 967 | .previous |
| 968 | .section .fixup,"ax" |
| 969 | /* running with kernelgs */ |
| 970 | bad_gs: |
Glauber de Oliveira Costa | 72fe485 | 2008-01-30 13:32:08 +0100 | [diff] [blame] | 971 | SWAPGS /* switch back to user gs */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 972 | xorl %eax,%eax |
| 973 | movl %eax,%gs |
| 974 | jmp 2b |
| 975 | .previous |
| 976 | |
| 977 | /* |
| 978 | * Create a kernel thread. |
| 979 | * |
| 980 | * C extern interface: |
| 981 | * extern long kernel_thread(int (*fn)(void *), void * arg, unsigned long flags) |
| 982 | * |
| 983 | * asm input arguments: |
| 984 | * rdi: fn, rsi: arg, rdx: flags |
| 985 | */ |
| 986 | ENTRY(kernel_thread) |
| 987 | CFI_STARTPROC |
| 988 | FAKE_STACK_FRAME $child_rip |
| 989 | SAVE_ALL |
| 990 | |
| 991 | # rdi: flags, rsi: usp, rdx: will be &pt_regs |
| 992 | movq %rdx,%rdi |
| 993 | orq kernel_thread_flags(%rip),%rdi |
| 994 | movq $-1, %rsi |
| 995 | movq %rsp, %rdx |
| 996 | |
| 997 | xorl %r8d,%r8d |
| 998 | xorl %r9d,%r9d |
| 999 | |
| 1000 | # clone now |
| 1001 | call do_fork |
| 1002 | movq %rax,RAX(%rsp) |
| 1003 | xorl %edi,%edi |
| 1004 | |
| 1005 | /* |
| 1006 | * It isn't worth to check for reschedule here, |
| 1007 | * so internally to the x86_64 port you can rely on kernel_thread() |
| 1008 | * not to reschedule the child before returning, this avoids the need |
| 1009 | * of hacks for example to fork off the per-CPU idle tasks. |
| 1010 | * [Hopefully no generic code relies on the reschedule -AK] |
| 1011 | */ |
| 1012 | RESTORE_ALL |
| 1013 | UNFAKE_STACK_FRAME |
| 1014 | ret |
| 1015 | CFI_ENDPROC |
Jan Beulich | 4b787e0 | 2006-06-26 13:56:55 +0200 | [diff] [blame] | 1016 | ENDPROC(kernel_thread) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1017 | |
| 1018 | child_rip: |
Andi Kleen | c05991e | 2006-08-30 19:37:08 +0200 | [diff] [blame] | 1019 | pushq $0 # fake return address |
| 1020 | CFI_STARTPROC |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1021 | /* |
| 1022 | * Here we are in the child and the registers are set as they were |
| 1023 | * at kernel_thread() invocation in the parent. |
| 1024 | */ |
| 1025 | movq %rdi, %rax |
| 1026 | movq %rsi, %rdi |
| 1027 | call *%rax |
| 1028 | # exit |
Andrey Mirkin | 1c5b5cf | 2007-10-17 18:04:33 +0200 | [diff] [blame] | 1029 | mov %eax, %edi |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1030 | call do_exit |
Andi Kleen | c05991e | 2006-08-30 19:37:08 +0200 | [diff] [blame] | 1031 | CFI_ENDPROC |
Jan Beulich | 4b787e0 | 2006-06-26 13:56:55 +0200 | [diff] [blame] | 1032 | ENDPROC(child_rip) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1033 | |
| 1034 | /* |
| 1035 | * execve(). This function needs to use IRET, not SYSRET, to set up all state properly. |
| 1036 | * |
| 1037 | * C extern interface: |
| 1038 | * extern long execve(char *name, char **argv, char **envp) |
| 1039 | * |
| 1040 | * asm input arguments: |
| 1041 | * rdi: name, rsi: argv, rdx: envp |
| 1042 | * |
| 1043 | * We want to fallback into: |
Ingo Molnar | 5d119b2 | 2008-02-26 12:55:57 +0100 | [diff] [blame] | 1044 | * extern long sys_execve(char *name, char **argv,char **envp, struct pt_regs *regs) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1045 | * |
| 1046 | * do_sys_execve asm fallback arguments: |
Ingo Molnar | 5d119b2 | 2008-02-26 12:55:57 +0100 | [diff] [blame] | 1047 | * rdi: name, rsi: argv, rdx: envp, rcx: fake frame on the stack |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1048 | */ |
Arnd Bergmann | 3db03b4 | 2006-10-02 02:18:31 -0700 | [diff] [blame] | 1049 | ENTRY(kernel_execve) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1050 | CFI_STARTPROC |
| 1051 | FAKE_STACK_FRAME $0 |
| 1052 | SAVE_ALL |
Ingo Molnar | 5d119b2 | 2008-02-26 12:55:57 +0100 | [diff] [blame] | 1053 | movq %rsp,%rcx |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1054 | call sys_execve |
| 1055 | movq %rax, RAX(%rsp) |
| 1056 | RESTORE_REST |
| 1057 | testq %rax,%rax |
| 1058 | je int_ret_from_sys_call |
| 1059 | RESTORE_ARGS |
| 1060 | UNFAKE_STACK_FRAME |
| 1061 | ret |
| 1062 | CFI_ENDPROC |
Arnd Bergmann | 3db03b4 | 2006-10-02 02:18:31 -0700 | [diff] [blame] | 1063 | ENDPROC(kernel_execve) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1064 | |
Prasanna S Panchamukhi | 0f2fbdc | 2005-09-06 15:19:28 -0700 | [diff] [blame] | 1065 | KPROBE_ENTRY(page_fault) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1066 | errorentry do_page_fault |
Prasanna S.P | d28c439 | 2006-09-26 10:52:34 +0200 | [diff] [blame] | 1067 | KPROBE_END(page_fault) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1068 | |
| 1069 | ENTRY(coprocessor_error) |
| 1070 | zeroentry do_coprocessor_error |
Jan Beulich | 4b787e0 | 2006-06-26 13:56:55 +0200 | [diff] [blame] | 1071 | END(coprocessor_error) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1072 | |
| 1073 | ENTRY(simd_coprocessor_error) |
| 1074 | zeroentry do_simd_coprocessor_error |
Jan Beulich | 4b787e0 | 2006-06-26 13:56:55 +0200 | [diff] [blame] | 1075 | END(simd_coprocessor_error) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1076 | |
| 1077 | ENTRY(device_not_available) |
| 1078 | zeroentry math_state_restore |
Jan Beulich | 4b787e0 | 2006-06-26 13:56:55 +0200 | [diff] [blame] | 1079 | END(device_not_available) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1080 | |
| 1081 | /* runs on exception stack */ |
Prasanna S Panchamukhi | 0f2fbdc | 2005-09-06 15:19:28 -0700 | [diff] [blame] | 1082 | KPROBE_ENTRY(debug) |
Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 1083 | INTR_FRAME |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1084 | pushq $0 |
| 1085 | CFI_ADJUST_CFA_OFFSET 8 |
Andi Kleen | 5f8efbb | 2006-01-16 01:56:39 +0100 | [diff] [blame] | 1086 | paranoidentry do_debug, DEBUG_STACK |
Ingo Molnar | 2601e64 | 2006-07-03 00:24:45 -0700 | [diff] [blame] | 1087 | paranoidexit |
Prasanna S.P | d28c439 | 2006-09-26 10:52:34 +0200 | [diff] [blame] | 1088 | KPROBE_END(debug) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1089 | |
| 1090 | /* runs on exception stack */ |
Andi Kleen | eddb6fb | 2006-02-03 21:50:41 +0100 | [diff] [blame] | 1091 | KPROBE_ENTRY(nmi) |
Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 1092 | INTR_FRAME |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1093 | pushq $-1 |
Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 1094 | CFI_ADJUST_CFA_OFFSET 8 |
Ingo Molnar | 2601e64 | 2006-07-03 00:24:45 -0700 | [diff] [blame] | 1095 | paranoidentry do_nmi, 0, 0 |
| 1096 | #ifdef CONFIG_TRACE_IRQFLAGS |
| 1097 | paranoidexit 0 |
| 1098 | #else |
| 1099 | jmp paranoid_exit1 |
| 1100 | CFI_ENDPROC |
| 1101 | #endif |
Prasanna S.P | d28c439 | 2006-09-26 10:52:34 +0200 | [diff] [blame] | 1102 | KPROBE_END(nmi) |
Andi Kleen | 6fefb0d | 2005-04-16 15:25:03 -0700 | [diff] [blame] | 1103 | |
Prasanna S Panchamukhi | 0f2fbdc | 2005-09-06 15:19:28 -0700 | [diff] [blame] | 1104 | KPROBE_ENTRY(int3) |
Jan Beulich | b556b35 | 2006-01-11 22:43:00 +0100 | [diff] [blame] | 1105 | INTR_FRAME |
| 1106 | pushq $0 |
| 1107 | CFI_ADJUST_CFA_OFFSET 8 |
Andi Kleen | 5f8efbb | 2006-01-16 01:56:39 +0100 | [diff] [blame] | 1108 | paranoidentry do_int3, DEBUG_STACK |
Ingo Molnar | 2601e64 | 2006-07-03 00:24:45 -0700 | [diff] [blame] | 1109 | jmp paranoid_exit1 |
Jan Beulich | b556b35 | 2006-01-11 22:43:00 +0100 | [diff] [blame] | 1110 | CFI_ENDPROC |
Prasanna S.P | d28c439 | 2006-09-26 10:52:34 +0200 | [diff] [blame] | 1111 | KPROBE_END(int3) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1112 | |
| 1113 | ENTRY(overflow) |
| 1114 | zeroentry do_overflow |
Jan Beulich | 4b787e0 | 2006-06-26 13:56:55 +0200 | [diff] [blame] | 1115 | END(overflow) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1116 | |
| 1117 | ENTRY(bounds) |
| 1118 | zeroentry do_bounds |
Jan Beulich | 4b787e0 | 2006-06-26 13:56:55 +0200 | [diff] [blame] | 1119 | END(bounds) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1120 | |
| 1121 | ENTRY(invalid_op) |
| 1122 | zeroentry do_invalid_op |
Jan Beulich | 4b787e0 | 2006-06-26 13:56:55 +0200 | [diff] [blame] | 1123 | END(invalid_op) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1124 | |
| 1125 | ENTRY(coprocessor_segment_overrun) |
| 1126 | zeroentry do_coprocessor_segment_overrun |
Jan Beulich | 4b787e0 | 2006-06-26 13:56:55 +0200 | [diff] [blame] | 1127 | END(coprocessor_segment_overrun) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1128 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1129 | /* runs on exception stack */ |
| 1130 | ENTRY(double_fault) |
Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 1131 | XCPT_FRAME |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1132 | paranoidentry do_double_fault |
Ingo Molnar | 2601e64 | 2006-07-03 00:24:45 -0700 | [diff] [blame] | 1133 | jmp paranoid_exit1 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1134 | CFI_ENDPROC |
Jan Beulich | 4b787e0 | 2006-06-26 13:56:55 +0200 | [diff] [blame] | 1135 | END(double_fault) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1136 | |
| 1137 | ENTRY(invalid_TSS) |
| 1138 | errorentry do_invalid_TSS |
Jan Beulich | 4b787e0 | 2006-06-26 13:56:55 +0200 | [diff] [blame] | 1139 | END(invalid_TSS) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1140 | |
| 1141 | ENTRY(segment_not_present) |
| 1142 | errorentry do_segment_not_present |
Jan Beulich | 4b787e0 | 2006-06-26 13:56:55 +0200 | [diff] [blame] | 1143 | END(segment_not_present) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1144 | |
| 1145 | /* runs on exception stack */ |
| 1146 | ENTRY(stack_segment) |
Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 1147 | XCPT_FRAME |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1148 | paranoidentry do_stack_segment |
Ingo Molnar | 2601e64 | 2006-07-03 00:24:45 -0700 | [diff] [blame] | 1149 | jmp paranoid_exit1 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1150 | CFI_ENDPROC |
Jan Beulich | 4b787e0 | 2006-06-26 13:56:55 +0200 | [diff] [blame] | 1151 | END(stack_segment) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1152 | |
Prasanna S Panchamukhi | 0f2fbdc | 2005-09-06 15:19:28 -0700 | [diff] [blame] | 1153 | KPROBE_ENTRY(general_protection) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1154 | errorentry do_general_protection |
Prasanna S.P | d28c439 | 2006-09-26 10:52:34 +0200 | [diff] [blame] | 1155 | KPROBE_END(general_protection) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1156 | |
| 1157 | ENTRY(alignment_check) |
| 1158 | errorentry do_alignment_check |
Jan Beulich | 4b787e0 | 2006-06-26 13:56:55 +0200 | [diff] [blame] | 1159 | END(alignment_check) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1160 | |
| 1161 | ENTRY(divide_error) |
| 1162 | zeroentry do_divide_error |
Jan Beulich | 4b787e0 | 2006-06-26 13:56:55 +0200 | [diff] [blame] | 1163 | END(divide_error) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1164 | |
| 1165 | ENTRY(spurious_interrupt_bug) |
| 1166 | zeroentry do_spurious_interrupt_bug |
Jan Beulich | 4b787e0 | 2006-06-26 13:56:55 +0200 | [diff] [blame] | 1167 | END(spurious_interrupt_bug) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1168 | |
| 1169 | #ifdef CONFIG_X86_MCE |
| 1170 | /* runs on exception stack */ |
| 1171 | ENTRY(machine_check) |
Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 1172 | INTR_FRAME |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1173 | pushq $0 |
| 1174 | CFI_ADJUST_CFA_OFFSET 8 |
| 1175 | paranoidentry do_machine_check |
Ingo Molnar | 2601e64 | 2006-07-03 00:24:45 -0700 | [diff] [blame] | 1176 | jmp paranoid_exit1 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1177 | CFI_ENDPROC |
Jan Beulich | 4b787e0 | 2006-06-26 13:56:55 +0200 | [diff] [blame] | 1178 | END(machine_check) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1179 | #endif |
| 1180 | |
Andi Kleen | 2699500 | 2006-08-02 22:37:28 +0200 | [diff] [blame] | 1181 | /* Call softirq on interrupt stack. Interrupts are off. */ |
Andi Kleen | ed6b676 | 2005-07-28 21:15:49 -0700 | [diff] [blame] | 1182 | ENTRY(call_softirq) |
Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 1183 | CFI_STARTPROC |
Andi Kleen | 2699500 | 2006-08-02 22:37:28 +0200 | [diff] [blame] | 1184 | push %rbp |
| 1185 | CFI_ADJUST_CFA_OFFSET 8 |
| 1186 | CFI_REL_OFFSET rbp,0 |
| 1187 | mov %rsp,%rbp |
| 1188 | CFI_DEF_CFA_REGISTER rbp |
Andi Kleen | ed6b676 | 2005-07-28 21:15:49 -0700 | [diff] [blame] | 1189 | incl %gs:pda_irqcount |
Andi Kleen | 2699500 | 2006-08-02 22:37:28 +0200 | [diff] [blame] | 1190 | cmove %gs:pda_irqstackptr,%rsp |
| 1191 | push %rbp # backlink for old unwinder |
Andi Kleen | ed6b676 | 2005-07-28 21:15:49 -0700 | [diff] [blame] | 1192 | call __do_softirq |
Andi Kleen | 2699500 | 2006-08-02 22:37:28 +0200 | [diff] [blame] | 1193 | leaveq |
Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 1194 | CFI_DEF_CFA_REGISTER rsp |
Andi Kleen | 2699500 | 2006-08-02 22:37:28 +0200 | [diff] [blame] | 1195 | CFI_ADJUST_CFA_OFFSET -8 |
Andi Kleen | ed6b676 | 2005-07-28 21:15:49 -0700 | [diff] [blame] | 1196 | decl %gs:pda_irqcount |
Andi Kleen | ed6b676 | 2005-07-28 21:15:49 -0700 | [diff] [blame] | 1197 | ret |
Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 1198 | CFI_ENDPROC |
Jan Beulich | 4b787e0 | 2006-06-26 13:56:55 +0200 | [diff] [blame] | 1199 | ENDPROC(call_softirq) |
Andi Kleen | 75154f4 | 2007-06-23 02:29:25 +0200 | [diff] [blame] | 1200 | |
| 1201 | KPROBE_ENTRY(ignore_sysret) |
| 1202 | CFI_STARTPROC |
| 1203 | mov $-ENOSYS,%eax |
| 1204 | sysret |
| 1205 | CFI_ENDPROC |
| 1206 | ENDPROC(ignore_sysret) |