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