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