| 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. | 
| Alexander van Heukelum | 0bd7b79 | 2008-11-16 15:29:00 +0100 | [diff] [blame] | 14 | * | 
|  | 15 | * Normal syscalls and interrupts don't save a full stack frame, this is | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | * only done for syscall tracing, signals or fork/exec et.al. | 
| Alexander van Heukelum | 0bd7b79 | 2008-11-16 15:29:00 +0100 | [diff] [blame] | 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. | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | * - partial stack frame: partially saved registers upto R11. | 
| Alexander van Heukelum | 0bd7b79 | 2008-11-16 15:29:00 +0100 | [diff] [blame] | 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> | 
| Abhishek Sagar | 395a59d | 2008-06-21 23:47:27 +0530 | [diff] [blame] | 54 | #include <asm/ftrace.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 55 |  | 
| Roland McGrath | 86a1c34 | 2008-06-23 15:37:04 -0700 | [diff] [blame] | 56 | /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this.  */ | 
|  | 57 | #include <linux/elf-em.h> | 
|  | 58 | #define AUDIT_ARCH_X86_64	(EM_X86_64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE) | 
|  | 59 | #define __AUDIT_ARCH_64BIT 0x80000000 | 
|  | 60 | #define __AUDIT_ARCH_LE	   0x40000000 | 
|  | 61 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | .code64 | 
| Steven Rostedt | 606576c | 2008-10-06 19:06:12 -0400 | [diff] [blame] | 63 | #ifdef CONFIG_FUNCTION_TRACER | 
| Steven Rostedt | d61f82d | 2008-05-12 21:20:43 +0200 | [diff] [blame] | 64 | #ifdef CONFIG_DYNAMIC_FTRACE | 
|  | 65 | ENTRY(mcount) | 
| Steven Rostedt | d61f82d | 2008-05-12 21:20:43 +0200 | [diff] [blame] | 66 | retq | 
|  | 67 | END(mcount) | 
|  | 68 |  | 
|  | 69 | ENTRY(ftrace_caller) | 
| Steven Rostedt | 60a7ecf | 2008-11-05 16:05:44 -0500 | [diff] [blame] | 70 | cmpl $0, function_trace_stop | 
|  | 71 | jne  ftrace_stub | 
| Steven Rostedt | d61f82d | 2008-05-12 21:20:43 +0200 | [diff] [blame] | 72 |  | 
| Cyrill Gorcunov | d680fe4 | 2008-12-13 00:09:08 +0300 | [diff] [blame] | 73 | MCOUNT_SAVE_FRAME | 
| Steven Rostedt | d61f82d | 2008-05-12 21:20:43 +0200 | [diff] [blame] | 74 |  | 
|  | 75 | movq 0x38(%rsp), %rdi | 
|  | 76 | movq 8(%rbp), %rsi | 
| Abhishek Sagar | 395a59d | 2008-06-21 23:47:27 +0530 | [diff] [blame] | 77 | subq $MCOUNT_INSN_SIZE, %rdi | 
| Steven Rostedt | d61f82d | 2008-05-12 21:20:43 +0200 | [diff] [blame] | 78 |  | 
|  | 79 | .globl ftrace_call | 
|  | 80 | ftrace_call: | 
|  | 81 | call ftrace_stub | 
|  | 82 |  | 
| Cyrill Gorcunov | d680fe4 | 2008-12-13 00:09:08 +0300 | [diff] [blame] | 83 | MCOUNT_RESTORE_FRAME | 
| Steven Rostedt | d61f82d | 2008-05-12 21:20:43 +0200 | [diff] [blame] | 84 |  | 
| Frederic Weisbecker | 48d68b2 | 2008-12-02 00:20:39 +0100 | [diff] [blame] | 85 | #ifdef CONFIG_FUNCTION_GRAPH_TRACER | 
|  | 86 | .globl ftrace_graph_call | 
|  | 87 | ftrace_graph_call: | 
|  | 88 | jmp ftrace_stub | 
|  | 89 | #endif | 
| Steven Rostedt | d61f82d | 2008-05-12 21:20:43 +0200 | [diff] [blame] | 90 |  | 
|  | 91 | .globl ftrace_stub | 
|  | 92 | ftrace_stub: | 
|  | 93 | retq | 
|  | 94 | END(ftrace_caller) | 
|  | 95 |  | 
|  | 96 | #else /* ! CONFIG_DYNAMIC_FTRACE */ | 
| Arnaldo Carvalho de Melo | 16444a8 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 97 | ENTRY(mcount) | 
| Steven Rostedt | 60a7ecf | 2008-11-05 16:05:44 -0500 | [diff] [blame] | 98 | cmpl $0, function_trace_stop | 
|  | 99 | jne  ftrace_stub | 
|  | 100 |  | 
| Arnaldo Carvalho de Melo | 16444a8 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 101 | cmpq $ftrace_stub, ftrace_trace_function | 
|  | 102 | jnz trace | 
| Frederic Weisbecker | 48d68b2 | 2008-12-02 00:20:39 +0100 | [diff] [blame] | 103 |  | 
|  | 104 | #ifdef CONFIG_FUNCTION_GRAPH_TRACER | 
|  | 105 | cmpq $ftrace_stub, ftrace_graph_return | 
|  | 106 | jnz ftrace_graph_caller | 
| Steven Rostedt | e49dc19 | 2008-12-02 23:50:05 -0500 | [diff] [blame] | 107 |  | 
|  | 108 | cmpq $ftrace_graph_entry_stub, ftrace_graph_entry | 
|  | 109 | jnz ftrace_graph_caller | 
| Frederic Weisbecker | 48d68b2 | 2008-12-02 00:20:39 +0100 | [diff] [blame] | 110 | #endif | 
|  | 111 |  | 
| Arnaldo Carvalho de Melo | 16444a8 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 112 | .globl ftrace_stub | 
|  | 113 | ftrace_stub: | 
|  | 114 | retq | 
|  | 115 |  | 
|  | 116 | trace: | 
| Cyrill Gorcunov | d680fe4 | 2008-12-13 00:09:08 +0300 | [diff] [blame] | 117 | MCOUNT_SAVE_FRAME | 
| Arnaldo Carvalho de Melo | 16444a8 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 118 |  | 
|  | 119 | movq 0x38(%rsp), %rdi | 
|  | 120 | movq 8(%rbp), %rsi | 
| Abhishek Sagar | 395a59d | 2008-06-21 23:47:27 +0530 | [diff] [blame] | 121 | subq $MCOUNT_INSN_SIZE, %rdi | 
| Arnaldo Carvalho de Melo | 16444a8 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 122 |  | 
|  | 123 | call   *ftrace_trace_function | 
|  | 124 |  | 
| Cyrill Gorcunov | d680fe4 | 2008-12-13 00:09:08 +0300 | [diff] [blame] | 125 | MCOUNT_RESTORE_FRAME | 
| Arnaldo Carvalho de Melo | 16444a8 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 126 |  | 
|  | 127 | jmp ftrace_stub | 
|  | 128 | END(mcount) | 
| Steven Rostedt | d61f82d | 2008-05-12 21:20:43 +0200 | [diff] [blame] | 129 | #endif /* CONFIG_DYNAMIC_FTRACE */ | 
| Steven Rostedt | 606576c | 2008-10-06 19:06:12 -0400 | [diff] [blame] | 130 | #endif /* CONFIG_FUNCTION_TRACER */ | 
| Arnaldo Carvalho de Melo | 16444a8 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 131 |  | 
| Frederic Weisbecker | 48d68b2 | 2008-12-02 00:20:39 +0100 | [diff] [blame] | 132 | #ifdef CONFIG_FUNCTION_GRAPH_TRACER | 
|  | 133 | ENTRY(ftrace_graph_caller) | 
|  | 134 | cmpl $0, function_trace_stop | 
|  | 135 | jne ftrace_stub | 
|  | 136 |  | 
| Cyrill Gorcunov | d680fe4 | 2008-12-13 00:09:08 +0300 | [diff] [blame] | 137 | MCOUNT_SAVE_FRAME | 
| Frederic Weisbecker | 48d68b2 | 2008-12-02 00:20:39 +0100 | [diff] [blame] | 138 |  | 
|  | 139 | leaq 8(%rbp), %rdi | 
|  | 140 | movq 0x38(%rsp), %rsi | 
| Steven Rostedt | bb4304c | 2008-12-02 15:34:09 -0500 | [diff] [blame] | 141 | subq $MCOUNT_INSN_SIZE, %rsi | 
| Frederic Weisbecker | 48d68b2 | 2008-12-02 00:20:39 +0100 | [diff] [blame] | 142 |  | 
|  | 143 | call	prepare_ftrace_return | 
|  | 144 |  | 
| Cyrill Gorcunov | d680fe4 | 2008-12-13 00:09:08 +0300 | [diff] [blame] | 145 | MCOUNT_RESTORE_FRAME | 
|  | 146 |  | 
| Frederic Weisbecker | 48d68b2 | 2008-12-02 00:20:39 +0100 | [diff] [blame] | 147 | retq | 
|  | 148 | END(ftrace_graph_caller) | 
|  | 149 |  | 
|  | 150 |  | 
|  | 151 | .globl return_to_handler | 
|  | 152 | return_to_handler: | 
|  | 153 | subq  $80, %rsp | 
|  | 154 |  | 
|  | 155 | movq %rax, (%rsp) | 
|  | 156 | movq %rcx, 8(%rsp) | 
|  | 157 | movq %rdx, 16(%rsp) | 
|  | 158 | movq %rsi, 24(%rsp) | 
|  | 159 | movq %rdi, 32(%rsp) | 
|  | 160 | movq %r8, 40(%rsp) | 
|  | 161 | movq %r9, 48(%rsp) | 
|  | 162 | movq %r10, 56(%rsp) | 
|  | 163 | movq %r11, 64(%rsp) | 
|  | 164 |  | 
|  | 165 | call ftrace_return_to_handler | 
|  | 166 |  | 
|  | 167 | movq %rax, 72(%rsp) | 
|  | 168 | movq 64(%rsp), %r11 | 
|  | 169 | movq 56(%rsp), %r10 | 
| Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 170 | movq 48(%rsp), %r9 | 
|  | 171 | movq 40(%rsp), %r8 | 
|  | 172 | movq 32(%rsp), %rdi | 
|  | 173 | movq 24(%rsp), %rsi | 
|  | 174 | movq 16(%rsp), %rdx | 
|  | 175 | movq 8(%rsp), %rcx | 
|  | 176 | movq (%rsp), %rax | 
| Frederic Weisbecker | 48d68b2 | 2008-12-02 00:20:39 +0100 | [diff] [blame] | 177 | addq $72, %rsp | 
|  | 178 | retq | 
|  | 179 | #endif | 
| Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 180 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 181 |  | 
|  | 182 | #ifndef CONFIG_PREEMPT | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 183 | #define retint_kernel retint_restore_args | 
| Alexander van Heukelum | 0bd7b79 | 2008-11-16 15:29:00 +0100 | [diff] [blame] | 184 | #endif | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 185 |  | 
|  | 186 | #ifdef CONFIG_PARAVIRT | 
|  | 187 | ENTRY(native_usergs_sysret64) | 
|  | 188 | swapgs | 
|  | 189 | sysretq | 
|  | 190 | #endif /* CONFIG_PARAVIRT */ | 
|  | 191 |  | 
|  | 192 |  | 
|  | 193 | .macro TRACE_IRQS_IRETQ offset=ARGOFFSET | 
|  | 194 | #ifdef CONFIG_TRACE_IRQFLAGS | 
|  | 195 | bt   $9,EFLAGS-\offset(%rsp)	/* interrupts off? */ | 
|  | 196 | jnc  1f | 
|  | 197 | TRACE_IRQS_ON | 
|  | 198 | 1: | 
|  | 199 | #endif | 
|  | 200 | .endm | 
|  | 201 |  | 
|  | 202 | /* | 
| Alexander van Heukelum | 0bd7b79 | 2008-11-16 15:29:00 +0100 | [diff] [blame] | 203 | * C code is not supposed to know about undefined top of stack. Every time | 
|  | 204 | * a C function with an pt_regs argument is called from the SYSCALL based | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 205 | * fast path FIXUP_TOP_OF_STACK is needed. | 
|  | 206 | * RESTORE_TOP_OF_STACK syncs the syscall state after any possible ptregs | 
|  | 207 | * manipulation. | 
| Alexander van Heukelum | 0bd7b79 | 2008-11-16 15:29:00 +0100 | [diff] [blame] | 208 | */ | 
|  | 209 |  | 
|  | 210 | /* %rsp:at FRAMEEND */ | 
| Alexander van Heukelum | c002a1e | 2008-11-21 16:41:55 +0100 | [diff] [blame] | 211 | .macro FIXUP_TOP_OF_STACK tmp offset=0 | 
|  | 212 | movq %gs:pda_oldrsp,\tmp | 
|  | 213 | movq \tmp,RSP+\offset(%rsp) | 
|  | 214 | movq $__USER_DS,SS+\offset(%rsp) | 
|  | 215 | movq $__USER_CS,CS+\offset(%rsp) | 
|  | 216 | movq $-1,RCX+\offset(%rsp) | 
|  | 217 | movq R11+\offset(%rsp),\tmp  /* get eflags */ | 
|  | 218 | movq \tmp,EFLAGS+\offset(%rsp) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 219 | .endm | 
|  | 220 |  | 
| Alexander van Heukelum | c002a1e | 2008-11-21 16:41:55 +0100 | [diff] [blame] | 221 | .macro RESTORE_TOP_OF_STACK tmp offset=0 | 
|  | 222 | movq RSP+\offset(%rsp),\tmp | 
|  | 223 | movq \tmp,%gs:pda_oldrsp | 
|  | 224 | movq EFLAGS+\offset(%rsp),\tmp | 
|  | 225 | movq \tmp,R11+\offset(%rsp) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 226 | .endm | 
|  | 227 |  | 
|  | 228 | .macro FAKE_STACK_FRAME child_rip | 
|  | 229 | /* push in order ss, rsp, eflags, cs, rip */ | 
|  | 230 | xorl %eax, %eax | 
|  | 231 | pushq $__KERNEL_DS /* ss */ | 
|  | 232 | CFI_ADJUST_CFA_OFFSET	8 | 
|  | 233 | /*CFI_REL_OFFSET	ss,0*/ | 
|  | 234 | pushq %rax /* rsp */ | 
|  | 235 | CFI_ADJUST_CFA_OFFSET	8 | 
|  | 236 | CFI_REL_OFFSET	rsp,0 | 
| gorcunov@gmail.com | 3345453 | 2008-11-26 22:17:02 +0300 | [diff] [blame] | 237 | pushq $X86_EFLAGS_IF /* eflags - interrupts on */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 238 | CFI_ADJUST_CFA_OFFSET	8 | 
|  | 239 | /*CFI_REL_OFFSET	rflags,0*/ | 
|  | 240 | pushq $__KERNEL_CS /* cs */ | 
|  | 241 | CFI_ADJUST_CFA_OFFSET	8 | 
|  | 242 | /*CFI_REL_OFFSET	cs,0*/ | 
|  | 243 | pushq \child_rip /* rip */ | 
|  | 244 | CFI_ADJUST_CFA_OFFSET	8 | 
|  | 245 | CFI_REL_OFFSET	rip,0 | 
|  | 246 | pushq	%rax /* orig rax */ | 
|  | 247 | CFI_ADJUST_CFA_OFFSET	8 | 
|  | 248 | .endm | 
|  | 249 |  | 
|  | 250 | .macro UNFAKE_STACK_FRAME | 
|  | 251 | addq $8*6, %rsp | 
|  | 252 | CFI_ADJUST_CFA_OFFSET	-(6*8) | 
|  | 253 | .endm | 
|  | 254 |  | 
| Alexander van Heukelum | d99015b | 2008-11-19 01:18:11 +0100 | [diff] [blame] | 255 | /* | 
| Alexander van Heukelum | dcd072e | 2008-11-20 14:40:11 +0100 | [diff] [blame] | 256 | * initial frame state for interrupts (and exceptions without error code) | 
| Alexander van Heukelum | d99015b | 2008-11-19 01:18:11 +0100 | [diff] [blame] | 257 | */ | 
| Alexander van Heukelum | dcd072e | 2008-11-20 14:40:11 +0100 | [diff] [blame] | 258 | .macro EMPTY_FRAME start=1 offset=0 | 
|  | 259 | .if \start | 
| Alexander van Heukelum | d99015b | 2008-11-19 01:18:11 +0100 | [diff] [blame] | 260 | CFI_STARTPROC simple | 
|  | 261 | CFI_SIGNAL_FRAME | 
| Alexander van Heukelum | dcd072e | 2008-11-20 14:40:11 +0100 | [diff] [blame] | 262 | CFI_DEF_CFA rsp,8+\offset | 
|  | 263 | .else | 
|  | 264 | CFI_DEF_CFA_OFFSET 8+\offset | 
|  | 265 | .endif | 
| Alexander van Heukelum | d99015b | 2008-11-19 01:18:11 +0100 | [diff] [blame] | 266 | .endm | 
|  | 267 |  | 
|  | 268 | /* | 
|  | 269 | * initial frame state for interrupts (and exceptions without error code) | 
|  | 270 | */ | 
| Alexander van Heukelum | dcd072e | 2008-11-20 14:40:11 +0100 | [diff] [blame] | 271 | .macro INTR_FRAME start=1 offset=0 | 
| Ingo Molnar | e8a0e27 | 2008-11-21 15:11:32 +0100 | [diff] [blame] | 272 | EMPTY_FRAME \start, SS+8+\offset-RIP | 
|  | 273 | /*CFI_REL_OFFSET ss, SS+\offset-RIP*/ | 
|  | 274 | CFI_REL_OFFSET rsp, RSP+\offset-RIP | 
|  | 275 | /*CFI_REL_OFFSET rflags, EFLAGS+\offset-RIP*/ | 
|  | 276 | /*CFI_REL_OFFSET cs, CS+\offset-RIP*/ | 
|  | 277 | CFI_REL_OFFSET rip, RIP+\offset-RIP | 
| Alexander van Heukelum | dcd072e | 2008-11-20 14:40:11 +0100 | [diff] [blame] | 278 | .endm | 
|  | 279 |  | 
| Alexander van Heukelum | d99015b | 2008-11-19 01:18:11 +0100 | [diff] [blame] | 280 | /* | 
|  | 281 | * initial frame state for exceptions with error code (and interrupts | 
|  | 282 | * with vector already pushed) | 
|  | 283 | */ | 
| Alexander van Heukelum | dcd072e | 2008-11-20 14:40:11 +0100 | [diff] [blame] | 284 | .macro XCPT_FRAME start=1 offset=0 | 
| Ingo Molnar | e8a0e27 | 2008-11-21 15:11:32 +0100 | [diff] [blame] | 285 | INTR_FRAME \start, RIP+\offset-ORIG_RAX | 
| Alexander van Heukelum | dcd072e | 2008-11-20 14:40:11 +0100 | [diff] [blame] | 286 | /*CFI_REL_OFFSET orig_rax, ORIG_RAX-ORIG_RAX*/ | 
|  | 287 | .endm | 
|  | 288 |  | 
|  | 289 | /* | 
|  | 290 | * frame that enables calling into C. | 
|  | 291 | */ | 
|  | 292 | .macro PARTIAL_FRAME start=1 offset=0 | 
| Ingo Molnar | e8a0e27 | 2008-11-21 15:11:32 +0100 | [diff] [blame] | 293 | XCPT_FRAME \start, ORIG_RAX+\offset-ARGOFFSET | 
|  | 294 | CFI_REL_OFFSET rdi, RDI+\offset-ARGOFFSET | 
|  | 295 | CFI_REL_OFFSET rsi, RSI+\offset-ARGOFFSET | 
|  | 296 | CFI_REL_OFFSET rdx, RDX+\offset-ARGOFFSET | 
|  | 297 | CFI_REL_OFFSET rcx, RCX+\offset-ARGOFFSET | 
|  | 298 | CFI_REL_OFFSET rax, RAX+\offset-ARGOFFSET | 
|  | 299 | CFI_REL_OFFSET r8, R8+\offset-ARGOFFSET | 
|  | 300 | CFI_REL_OFFSET r9, R9+\offset-ARGOFFSET | 
|  | 301 | CFI_REL_OFFSET r10, R10+\offset-ARGOFFSET | 
|  | 302 | CFI_REL_OFFSET r11, R11+\offset-ARGOFFSET | 
| Alexander van Heukelum | dcd072e | 2008-11-20 14:40:11 +0100 | [diff] [blame] | 303 | .endm | 
|  | 304 |  | 
|  | 305 | /* | 
|  | 306 | * frame that enables passing a complete pt_regs to a C function. | 
|  | 307 | */ | 
|  | 308 | .macro DEFAULT_FRAME start=1 offset=0 | 
| Ingo Molnar | e8a0e27 | 2008-11-21 15:11:32 +0100 | [diff] [blame] | 309 | PARTIAL_FRAME \start, R11+\offset-R15 | 
| Alexander van Heukelum | dcd072e | 2008-11-20 14:40:11 +0100 | [diff] [blame] | 310 | CFI_REL_OFFSET rbx, RBX+\offset | 
|  | 311 | CFI_REL_OFFSET rbp, RBP+\offset | 
|  | 312 | CFI_REL_OFFSET r12, R12+\offset | 
|  | 313 | CFI_REL_OFFSET r13, R13+\offset | 
|  | 314 | CFI_REL_OFFSET r14, R14+\offset | 
|  | 315 | CFI_REL_OFFSET r15, R15+\offset | 
|  | 316 | .endm | 
| Alexander van Heukelum | d99015b | 2008-11-19 01:18:11 +0100 | [diff] [blame] | 317 |  | 
|  | 318 | /* save partial stack frame */ | 
|  | 319 | ENTRY(save_args) | 
|  | 320 | XCPT_FRAME | 
|  | 321 | cld | 
| Ingo Molnar | 14ae22b | 2008-11-21 15:20:47 +0100 | [diff] [blame] | 322 | movq_cfi rdi, RDI+16-ARGOFFSET | 
|  | 323 | movq_cfi rsi, RSI+16-ARGOFFSET | 
|  | 324 | movq_cfi rdx, RDX+16-ARGOFFSET | 
|  | 325 | movq_cfi rcx, RCX+16-ARGOFFSET | 
|  | 326 | movq_cfi rax, RAX+16-ARGOFFSET | 
|  | 327 | movq_cfi  r8,  R8+16-ARGOFFSET | 
|  | 328 | movq_cfi  r9,  R9+16-ARGOFFSET | 
|  | 329 | movq_cfi r10, R10+16-ARGOFFSET | 
|  | 330 | movq_cfi r11, R11+16-ARGOFFSET | 
|  | 331 |  | 
| Alexander van Heukelum | d99015b | 2008-11-19 01:18:11 +0100 | [diff] [blame] | 332 | leaq -ARGOFFSET+16(%rsp),%rdi	/* arg1 for handler */ | 
| Ingo Molnar | 14ae22b | 2008-11-21 15:20:47 +0100 | [diff] [blame] | 333 | movq_cfi rbp, 8		/* push %rbp */ | 
| Alexander van Heukelum | d99015b | 2008-11-19 01:18:11 +0100 | [diff] [blame] | 334 | leaq 8(%rsp), %rbp		/* mov %rsp, %ebp */ | 
|  | 335 | testl $3, CS(%rdi) | 
|  | 336 | je 1f | 
|  | 337 | SWAPGS | 
|  | 338 | /* | 
|  | 339 | * irqcount is used to check if a CPU is already on an interrupt stack | 
|  | 340 | * or not. While this is essentially redundant with preempt_count it is | 
|  | 341 | * a little cheaper to use a separate counter in the PDA (short of | 
|  | 342 | * moving irq_enter into assembly, which would be too much work) | 
|  | 343 | */ | 
|  | 344 | 1:	incl %gs:pda_irqcount | 
|  | 345 | jne 2f | 
| Ingo Molnar | 14ae22b | 2008-11-21 15:20:47 +0100 | [diff] [blame] | 346 | popq_cfi %rax			/* move return address... */ | 
| Alexander van Heukelum | d99015b | 2008-11-19 01:18:11 +0100 | [diff] [blame] | 347 | mov %gs:pda_irqstackptr,%rsp | 
| Alexander van Heukelum | dcd072e | 2008-11-20 14:40:11 +0100 | [diff] [blame] | 348 | EMPTY_FRAME 0 | 
| Ingo Molnar | 14ae22b | 2008-11-21 15:20:47 +0100 | [diff] [blame] | 349 | pushq_cfi %rax			/* ... to the new stack */ | 
| Alexander van Heukelum | d99015b | 2008-11-19 01:18:11 +0100 | [diff] [blame] | 350 | /* | 
|  | 351 | * We entered an interrupt context - irqs are off: | 
|  | 352 | */ | 
|  | 353 | 2:	TRACE_IRQS_OFF | 
|  | 354 | ret | 
|  | 355 | CFI_ENDPROC | 
|  | 356 | END(save_args) | 
|  | 357 |  | 
| Alexander van Heukelum | c002a1e | 2008-11-21 16:41:55 +0100 | [diff] [blame] | 358 | ENTRY(save_rest) | 
|  | 359 | PARTIAL_FRAME 1 REST_SKIP+8 | 
|  | 360 | movq 5*8+16(%rsp), %r11	/* save return address */ | 
|  | 361 | movq_cfi rbx, RBX+16 | 
|  | 362 | movq_cfi rbp, RBP+16 | 
|  | 363 | movq_cfi r12, R12+16 | 
|  | 364 | movq_cfi r13, R13+16 | 
|  | 365 | movq_cfi r14, R14+16 | 
|  | 366 | movq_cfi r15, R15+16 | 
|  | 367 | movq %r11, 8(%rsp)	/* return address */ | 
|  | 368 | FIXUP_TOP_OF_STACK %r11, 16 | 
|  | 369 | ret | 
|  | 370 | CFI_ENDPROC | 
|  | 371 | END(save_rest) | 
|  | 372 |  | 
| Alexander van Heukelum | e2f6bc2 | 2008-11-21 16:43:18 +0100 | [diff] [blame] | 373 | /* save complete stack frame */ | 
|  | 374 | ENTRY(save_paranoid) | 
|  | 375 | XCPT_FRAME 1 RDI+8 | 
|  | 376 | cld | 
|  | 377 | movq_cfi rdi, RDI+8 | 
|  | 378 | movq_cfi rsi, RSI+8 | 
|  | 379 | movq_cfi rdx, RDX+8 | 
|  | 380 | movq_cfi rcx, RCX+8 | 
|  | 381 | movq_cfi rax, RAX+8 | 
|  | 382 | movq_cfi r8, R8+8 | 
|  | 383 | movq_cfi r9, R9+8 | 
|  | 384 | movq_cfi r10, R10+8 | 
|  | 385 | movq_cfi r11, R11+8 | 
|  | 386 | movq_cfi rbx, RBX+8 | 
|  | 387 | movq_cfi rbp, RBP+8 | 
|  | 388 | movq_cfi r12, R12+8 | 
|  | 389 | movq_cfi r13, R13+8 | 
|  | 390 | movq_cfi r14, R14+8 | 
|  | 391 | movq_cfi r15, R15+8 | 
|  | 392 | movl $1,%ebx | 
|  | 393 | movl $MSR_GS_BASE,%ecx | 
|  | 394 | rdmsr | 
|  | 395 | testl %edx,%edx | 
|  | 396 | js 1f	/* negative -> in kernel */ | 
|  | 397 | SWAPGS | 
|  | 398 | xorl %ebx,%ebx | 
|  | 399 | 1:	ret | 
|  | 400 | CFI_ENDPROC | 
|  | 401 | END(save_paranoid) | 
|  | 402 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 403 | /* | 
| Ingo Molnar | 5b3eec0 | 2008-11-27 14:41:21 +0100 | [diff] [blame] | 404 | * A newly forked process directly context switches into this address. | 
|  | 405 | * | 
|  | 406 | * rdi: prev task we switched from | 
| Alexander van Heukelum | 0bd7b79 | 2008-11-16 15:29:00 +0100 | [diff] [blame] | 407 | */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 408 | ENTRY(ret_from_fork) | 
| Alexander van Heukelum | dcd072e | 2008-11-20 14:40:11 +0100 | [diff] [blame] | 409 | DEFAULT_FRAME | 
| Ingo Molnar | 5b3eec0 | 2008-11-27 14:41:21 +0100 | [diff] [blame] | 410 |  | 
| Andi Kleen | 658fdbe | 2006-09-26 10:52:41 +0200 | [diff] [blame] | 411 | push kernel_eflags(%rip) | 
| Alexander van Heukelum | e0a5a5d | 2008-07-22 18:14:16 +0200 | [diff] [blame] | 412 | CFI_ADJUST_CFA_OFFSET 8 | 
| Ingo Molnar | 5b3eec0 | 2008-11-27 14:41:21 +0100 | [diff] [blame] | 413 | popf					# reset kernel eflags | 
| Alexander van Heukelum | e0a5a5d | 2008-07-22 18:14:16 +0200 | [diff] [blame] | 414 | CFI_ADJUST_CFA_OFFSET -8 | 
| Ingo Molnar | 5b3eec0 | 2008-11-27 14:41:21 +0100 | [diff] [blame] | 415 |  | 
|  | 416 | call schedule_tail			# rdi: 'prev' task parameter | 
|  | 417 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 418 | GET_THREAD_INFO(%rcx) | 
| Ingo Molnar | 5b3eec0 | 2008-11-27 14:41:21 +0100 | [diff] [blame] | 419 |  | 
| Jan Beulich | 1cbd8b3 | 2008-10-30 10:45:36 +0000 | [diff] [blame] | 420 | CFI_REMEMBER_STATE | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 421 | RESTORE_REST | 
| Ingo Molnar | 5b3eec0 | 2008-11-27 14:41:21 +0100 | [diff] [blame] | 422 |  | 
|  | 423 | testl $3, CS-ARGOFFSET(%rsp)		# from kernel_thread? | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 424 | je   int_ret_from_sys_call | 
| Ingo Molnar | 5b3eec0 | 2008-11-27 14:41:21 +0100 | [diff] [blame] | 425 |  | 
|  | 426 | testl $_TIF_IA32, TI_flags(%rcx)	# 32-bit compat task needs IRET | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 427 | jnz  int_ret_from_sys_call | 
| Ingo Molnar | 5b3eec0 | 2008-11-27 14:41:21 +0100 | [diff] [blame] | 428 |  | 
| Alexander van Heukelum | c002a1e | 2008-11-21 16:41:55 +0100 | [diff] [blame] | 429 | RESTORE_TOP_OF_STACK %rdi, -ARGOFFSET | 
| Ingo Molnar | 5b3eec0 | 2008-11-27 14:41:21 +0100 | [diff] [blame] | 430 | jmp ret_from_sys_call			# go to the SYSRET fastpath | 
|  | 431 |  | 
| Jan Beulich | 1cbd8b3 | 2008-10-30 10:45:36 +0000 | [diff] [blame] | 432 | CFI_RESTORE_STATE | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 433 | CFI_ENDPROC | 
| Jan Beulich | 4b787e0 | 2006-06-26 13:56:55 +0200 | [diff] [blame] | 434 | END(ret_from_fork) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 435 |  | 
|  | 436 | /* | 
|  | 437 | * System call entry. Upto 6 arguments in registers are supported. | 
|  | 438 | * | 
|  | 439 | * SYSCALL does not save anything on the stack and does not change the | 
|  | 440 | * stack pointer. | 
|  | 441 | */ | 
| Alexander van Heukelum | 0bd7b79 | 2008-11-16 15:29:00 +0100 | [diff] [blame] | 442 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 443 | /* | 
| Alexander van Heukelum | 0bd7b79 | 2008-11-16 15:29:00 +0100 | [diff] [blame] | 444 | * Register setup: | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 445 | * rax  system call number | 
|  | 446 | * rdi  arg0 | 
| Alexander van Heukelum | 0bd7b79 | 2008-11-16 15:29:00 +0100 | [diff] [blame] | 447 | * rcx  return address for syscall/sysret, C arg3 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 448 | * rsi  arg1 | 
| Alexander van Heukelum | 0bd7b79 | 2008-11-16 15:29:00 +0100 | [diff] [blame] | 449 | * rdx  arg2 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 450 | * r10  arg3 	(--> moved to rcx for C) | 
|  | 451 | * r8   arg4 | 
|  | 452 | * r9   arg5 | 
|  | 453 | * r11  eflags for syscall/sysret, temporary for C | 
| Alexander van Heukelum | 0bd7b79 | 2008-11-16 15:29:00 +0100 | [diff] [blame] | 454 | * r12-r15,rbp,rbx saved by C code, not touched. | 
|  | 455 | * | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 456 | * Interrupts are off on entry. | 
|  | 457 | * Only called from user space. | 
|  | 458 | * | 
|  | 459 | * XXX	if we had a free scratch register we could save the RSP into the stack frame | 
|  | 460 | *      and report it properly in ps. Unfortunately we haven't. | 
| Andi Kleen | 7bf36bb | 2006-04-07 19:50:00 +0200 | [diff] [blame] | 461 | * | 
|  | 462 | * When user can change the frames always force IRET. That is because | 
|  | 463 | * it deals with uncanonical addresses better. SYSRET has trouble | 
|  | 464 | * with them due to bugs in both AMD and Intel CPUs. | 
| Alexander van Heukelum | 0bd7b79 | 2008-11-16 15:29:00 +0100 | [diff] [blame] | 465 | */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 466 |  | 
|  | 467 | ENTRY(system_call) | 
| Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 468 | CFI_STARTPROC	simple | 
| Jan Beulich | adf1423 | 2006-09-26 10:52:41 +0200 | [diff] [blame] | 469 | CFI_SIGNAL_FRAME | 
| Jan Beulich | dffead4 | 2006-06-26 13:57:38 +0200 | [diff] [blame] | 470 | CFI_DEF_CFA	rsp,PDA_STACKOFFSET | 
| Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 471 | CFI_REGISTER	rip,rcx | 
|  | 472 | /*CFI_REGISTER	rflags,r11*/ | 
| Glauber de Oliveira Costa | 72fe485 | 2008-01-30 13:32:08 +0100 | [diff] [blame] | 473 | SWAPGS_UNSAFE_STACK | 
|  | 474 | /* | 
|  | 475 | * A hypervisor implementation might want to use a label | 
|  | 476 | * after the swapgs, so that it can do the swapgs | 
|  | 477 | * for the guest and jump here on syscall. | 
|  | 478 | */ | 
|  | 479 | ENTRY(system_call_after_swapgs) | 
|  | 480 |  | 
| Alexander van Heukelum | 0bd7b79 | 2008-11-16 15:29:00 +0100 | [diff] [blame] | 481 | movq	%rsp,%gs:pda_oldrsp | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 482 | movq	%gs:pda_kernelstack,%rsp | 
| Ingo Molnar | 2601e64 | 2006-07-03 00:24:45 -0700 | [diff] [blame] | 483 | /* | 
|  | 484 | * No need to follow this irqs off/on section - it's straight | 
|  | 485 | * and short: | 
|  | 486 | */ | 
| Glauber de Oliveira Costa | 72fe485 | 2008-01-30 13:32:08 +0100 | [diff] [blame] | 487 | ENABLE_INTERRUPTS(CLBR_NONE) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 488 | SAVE_ARGS 8,1 | 
| Alexander van Heukelum | 0bd7b79 | 2008-11-16 15:29:00 +0100 | [diff] [blame] | 489 | movq  %rax,ORIG_RAX-ARGOFFSET(%rsp) | 
| Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 490 | movq  %rcx,RIP-ARGOFFSET(%rsp) | 
|  | 491 | CFI_REL_OFFSET rip,RIP-ARGOFFSET | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 492 | GET_THREAD_INFO(%rcx) | 
| Roland McGrath | d4d6715 | 2008-07-09 02:38:07 -0700 | [diff] [blame] | 493 | testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%rcx) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 494 | jnz tracesys | 
| Roland McGrath | 86a1c34 | 2008-06-23 15:37:04 -0700 | [diff] [blame] | 495 | system_call_fastpath: | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 496 | cmpq $__NR_syscall_max,%rax | 
|  | 497 | ja badsys | 
|  | 498 | movq %r10,%rcx | 
|  | 499 | call *sys_call_table(,%rax,8)  # XXX:	 rip relative | 
|  | 500 | movq %rax,RAX-ARGOFFSET(%rsp) | 
|  | 501 | /* | 
|  | 502 | * Syscall return path ending with SYSRET (fast path) | 
| Alexander van Heukelum | 0bd7b79 | 2008-11-16 15:29:00 +0100 | [diff] [blame] | 503 | * Has incomplete stack frame and undefined top of stack. | 
|  | 504 | */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 505 | ret_from_sys_call: | 
| Andi Kleen | 11b854b | 2005-04-16 15:25:02 -0700 | [diff] [blame] | 506 | movl $_TIF_ALLWORK_MASK,%edi | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 507 | /* edi:	flagmask */ | 
| Alexander van Heukelum | 0bd7b79 | 2008-11-16 15:29:00 +0100 | [diff] [blame] | 508 | sysret_check: | 
| Peter Zijlstra | 10cd706 | 2007-10-11 22:11:12 +0200 | [diff] [blame] | 509 | LOCKDEP_SYS_EXIT | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 510 | GET_THREAD_INFO(%rcx) | 
| Glauber de Oliveira Costa | 72fe485 | 2008-01-30 13:32:08 +0100 | [diff] [blame] | 511 | DISABLE_INTERRUPTS(CLBR_NONE) | 
| Ingo Molnar | 2601e64 | 2006-07-03 00:24:45 -0700 | [diff] [blame] | 512 | TRACE_IRQS_OFF | 
| Glauber Costa | 26ccb8a | 2008-06-24 11:19:35 -0300 | [diff] [blame] | 513 | movl TI_flags(%rcx),%edx | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 514 | andl %edi,%edx | 
| Alexander van Heukelum | 0bd7b79 | 2008-11-16 15:29:00 +0100 | [diff] [blame] | 515 | jnz  sysret_careful | 
| Jan Beulich | bcddc01 | 2006-12-07 02:14:02 +0100 | [diff] [blame] | 516 | CFI_REMEMBER_STATE | 
| Ingo Molnar | 2601e64 | 2006-07-03 00:24:45 -0700 | [diff] [blame] | 517 | /* | 
|  | 518 | * sysretq will re-enable interrupts: | 
|  | 519 | */ | 
|  | 520 | TRACE_IRQS_ON | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 521 | movq RIP-ARGOFFSET(%rsp),%rcx | 
| Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 522 | CFI_REGISTER	rip,rcx | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 523 | RESTORE_ARGS 0,-ARG_SKIP,1 | 
| Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 524 | /*CFI_REGISTER	rflags,r11*/ | 
| Jeremy Fitzhardinge | c7245da | 2008-06-25 00:19:27 -0400 | [diff] [blame] | 525 | movq	%gs:pda_oldrsp, %rsp | 
| Jeremy Fitzhardinge | 2be2998 | 2008-06-25 00:19:28 -0400 | [diff] [blame] | 526 | USERGS_SYSRET64 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 527 |  | 
| Jan Beulich | bcddc01 | 2006-12-07 02:14:02 +0100 | [diff] [blame] | 528 | CFI_RESTORE_STATE | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 529 | /* Handle reschedules */ | 
| Alexander van Heukelum | 0bd7b79 | 2008-11-16 15:29:00 +0100 | [diff] [blame] | 530 | /* edx:	work, edi: workmask */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 531 | sysret_careful: | 
|  | 532 | bt $TIF_NEED_RESCHED,%edx | 
|  | 533 | jnc sysret_signal | 
| Ingo Molnar | 2601e64 | 2006-07-03 00:24:45 -0700 | [diff] [blame] | 534 | TRACE_IRQS_ON | 
| Glauber de Oliveira Costa | 72fe485 | 2008-01-30 13:32:08 +0100 | [diff] [blame] | 535 | ENABLE_INTERRUPTS(CLBR_NONE) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 536 | pushq %rdi | 
| Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 537 | CFI_ADJUST_CFA_OFFSET 8 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 538 | call schedule | 
|  | 539 | popq  %rdi | 
| Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 540 | CFI_ADJUST_CFA_OFFSET -8 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 541 | jmp sysret_check | 
|  | 542 |  | 
| Alexander van Heukelum | 0bd7b79 | 2008-11-16 15:29:00 +0100 | [diff] [blame] | 543 | /* Handle a signal */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 544 | sysret_signal: | 
| Ingo Molnar | 2601e64 | 2006-07-03 00:24:45 -0700 | [diff] [blame] | 545 | TRACE_IRQS_ON | 
| Glauber de Oliveira Costa | 72fe485 | 2008-01-30 13:32:08 +0100 | [diff] [blame] | 546 | ENABLE_INTERRUPTS(CLBR_NONE) | 
| Roland McGrath | 86a1c34 | 2008-06-23 15:37:04 -0700 | [diff] [blame] | 547 | #ifdef CONFIG_AUDITSYSCALL | 
|  | 548 | bt $TIF_SYSCALL_AUDIT,%edx | 
|  | 549 | jc sysret_audit | 
|  | 550 | #endif | 
| Andi Kleen | 10ffdbb | 2005-05-16 21:53:19 -0700 | [diff] [blame] | 551 | /* edx:	work flags (arg3) */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 552 | leaq -ARGOFFSET(%rsp),%rdi # &pt_regs -> arg1 | 
|  | 553 | xorl %esi,%esi # oldset -> arg2 | 
| Alexander van Heukelum | c8108411 | 2008-11-21 22:59:52 +0100 | [diff] [blame] | 554 | SAVE_REST | 
|  | 555 | FIXUP_TOP_OF_STACK %r11 | 
|  | 556 | call do_notify_resume | 
|  | 557 | RESTORE_TOP_OF_STACK %r11 | 
|  | 558 | RESTORE_REST | 
| Roland McGrath | 15e8f34 | 2008-06-23 20:41:12 -0700 | [diff] [blame] | 559 | movl $_TIF_WORK_MASK,%edi | 
| Andi Kleen | 7bf36bb | 2006-04-07 19:50:00 +0200 | [diff] [blame] | 560 | /* Use IRET because user could have changed frame. This | 
|  | 561 | works because ptregscall_common has called FIXUP_TOP_OF_STACK. */ | 
| Glauber de Oliveira Costa | 72fe485 | 2008-01-30 13:32:08 +0100 | [diff] [blame] | 562 | DISABLE_INTERRUPTS(CLBR_NONE) | 
| Ingo Molnar | 2601e64 | 2006-07-03 00:24:45 -0700 | [diff] [blame] | 563 | TRACE_IRQS_OFF | 
| Andi Kleen | 7bf36bb | 2006-04-07 19:50:00 +0200 | [diff] [blame] | 564 | jmp int_with_check | 
| Alexander van Heukelum | 0bd7b79 | 2008-11-16 15:29:00 +0100 | [diff] [blame] | 565 |  | 
| Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 566 | badsys: | 
|  | 567 | movq $-ENOSYS,RAX-ARGOFFSET(%rsp) | 
|  | 568 | jmp ret_from_sys_call | 
|  | 569 |  | 
| Roland McGrath | 86a1c34 | 2008-06-23 15:37:04 -0700 | [diff] [blame] | 570 | #ifdef CONFIG_AUDITSYSCALL | 
|  | 571 | /* | 
|  | 572 | * Fast path for syscall audit without full syscall trace. | 
|  | 573 | * We just call audit_syscall_entry() directly, and then | 
|  | 574 | * jump back to the normal fast path. | 
|  | 575 | */ | 
|  | 576 | auditsys: | 
|  | 577 | movq %r10,%r9			/* 6th arg: 4th syscall arg */ | 
|  | 578 | movq %rdx,%r8			/* 5th arg: 3rd syscall arg */ | 
|  | 579 | movq %rsi,%rcx			/* 4th arg: 2nd syscall arg */ | 
|  | 580 | movq %rdi,%rdx			/* 3rd arg: 1st syscall arg */ | 
|  | 581 | movq %rax,%rsi			/* 2nd arg: syscall number */ | 
|  | 582 | movl $AUDIT_ARCH_X86_64,%edi	/* 1st arg: audit arch */ | 
|  | 583 | call audit_syscall_entry | 
|  | 584 | LOAD_ARGS 0		/* reload call-clobbered registers */ | 
|  | 585 | jmp system_call_fastpath | 
|  | 586 |  | 
|  | 587 | /* | 
|  | 588 | * Return fast path for syscall audit.  Call audit_syscall_exit() | 
|  | 589 | * directly and then jump back to the fast path with TIF_SYSCALL_AUDIT | 
|  | 590 | * masked off. | 
|  | 591 | */ | 
|  | 592 | sysret_audit: | 
|  | 593 | movq %rax,%rsi		/* second arg, syscall return value */ | 
|  | 594 | cmpq $0,%rax		/* is it < 0? */ | 
|  | 595 | setl %al		/* 1 if so, 0 if not */ | 
|  | 596 | movzbl %al,%edi		/* zero-extend that into %edi */ | 
|  | 597 | inc %edi /* first arg, 0->1(AUDITSC_SUCCESS), 1->2(AUDITSC_FAILURE) */ | 
|  | 598 | call audit_syscall_exit | 
|  | 599 | movl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),%edi | 
|  | 600 | jmp sysret_check | 
|  | 601 | #endif	/* CONFIG_AUDITSYSCALL */ | 
|  | 602 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 603 | /* Do syscall tracing */ | 
| Alexander van Heukelum | 0bd7b79 | 2008-11-16 15:29:00 +0100 | [diff] [blame] | 604 | tracesys: | 
| Roland McGrath | 86a1c34 | 2008-06-23 15:37:04 -0700 | [diff] [blame] | 605 | #ifdef CONFIG_AUDITSYSCALL | 
|  | 606 | testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%rcx) | 
|  | 607 | jz auditsys | 
|  | 608 | #endif | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 609 | SAVE_REST | 
| Roland McGrath | a31f8dd | 2008-03-16 21:59:11 -0700 | [diff] [blame] | 610 | movq $-ENOSYS,RAX(%rsp) /* ptrace can change this for a bad syscall */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 611 | FIXUP_TOP_OF_STACK %rdi | 
|  | 612 | movq %rsp,%rdi | 
|  | 613 | call syscall_trace_enter | 
| Roland McGrath | d4d6715 | 2008-07-09 02:38:07 -0700 | [diff] [blame] | 614 | /* | 
|  | 615 | * Reload arg registers from stack in case ptrace changed them. | 
|  | 616 | * We don't reload %rax because syscall_trace_enter() returned | 
|  | 617 | * the value it wants us to use in the table lookup. | 
|  | 618 | */ | 
|  | 619 | LOAD_ARGS ARGOFFSET, 1 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 620 | RESTORE_REST | 
|  | 621 | cmpq $__NR_syscall_max,%rax | 
| Roland McGrath | a31f8dd | 2008-03-16 21:59:11 -0700 | [diff] [blame] | 622 | ja   int_ret_from_sys_call	/* RAX(%rsp) set to -ENOSYS above */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 623 | movq %r10,%rcx	/* fixup for C */ | 
|  | 624 | call *sys_call_table(,%rax,8) | 
| Roland McGrath | a31f8dd | 2008-03-16 21:59:11 -0700 | [diff] [blame] | 625 | movq %rax,RAX-ARGOFFSET(%rsp) | 
| Andi Kleen | 7bf36bb | 2006-04-07 19:50:00 +0200 | [diff] [blame] | 626 | /* Use IRET because user could have changed frame */ | 
| Alexander van Heukelum | 0bd7b79 | 2008-11-16 15:29:00 +0100 | [diff] [blame] | 627 |  | 
|  | 628 | /* | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 629 | * Syscall return path ending with IRET. | 
|  | 630 | * Has correct top of stack, but partial stack frame. | 
| Jan Beulich | bcddc01 | 2006-12-07 02:14:02 +0100 | [diff] [blame] | 631 | */ | 
|  | 632 | .globl int_ret_from_sys_call | 
| Roland McGrath | 5cbf156 | 2008-06-24 01:13:31 -0700 | [diff] [blame] | 633 | .globl int_with_check | 
| Jan Beulich | bcddc01 | 2006-12-07 02:14:02 +0100 | [diff] [blame] | 634 | int_ret_from_sys_call: | 
| Glauber de Oliveira Costa | 72fe485 | 2008-01-30 13:32:08 +0100 | [diff] [blame] | 635 | DISABLE_INTERRUPTS(CLBR_NONE) | 
| Ingo Molnar | 2601e64 | 2006-07-03 00:24:45 -0700 | [diff] [blame] | 636 | TRACE_IRQS_OFF | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 637 | testl $3,CS-ARGOFFSET(%rsp) | 
|  | 638 | je retint_restore_args | 
|  | 639 | movl $_TIF_ALLWORK_MASK,%edi | 
|  | 640 | /* edi:	mask to check */ | 
|  | 641 | int_with_check: | 
| Peter Zijlstra | 10cd706 | 2007-10-11 22:11:12 +0200 | [diff] [blame] | 642 | LOCKDEP_SYS_EXIT_IRQ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 643 | GET_THREAD_INFO(%rcx) | 
| Glauber Costa | 26ccb8a | 2008-06-24 11:19:35 -0300 | [diff] [blame] | 644 | movl TI_flags(%rcx),%edx | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 645 | andl %edi,%edx | 
|  | 646 | jnz   int_careful | 
| Glauber Costa | 26ccb8a | 2008-06-24 11:19:35 -0300 | [diff] [blame] | 647 | andl    $~TS_COMPAT,TI_status(%rcx) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 648 | jmp   retint_swapgs | 
|  | 649 |  | 
|  | 650 | /* Either reschedule or signal or syscall exit tracking needed. */ | 
|  | 651 | /* First do a reschedule test. */ | 
|  | 652 | /* edx:	work, edi: workmask */ | 
|  | 653 | int_careful: | 
|  | 654 | bt $TIF_NEED_RESCHED,%edx | 
|  | 655 | jnc  int_very_careful | 
| Ingo Molnar | 2601e64 | 2006-07-03 00:24:45 -0700 | [diff] [blame] | 656 | TRACE_IRQS_ON | 
| Glauber de Oliveira Costa | 72fe485 | 2008-01-30 13:32:08 +0100 | [diff] [blame] | 657 | ENABLE_INTERRUPTS(CLBR_NONE) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 658 | pushq %rdi | 
| Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 659 | CFI_ADJUST_CFA_OFFSET 8 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 660 | call schedule | 
|  | 661 | popq %rdi | 
| Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 662 | CFI_ADJUST_CFA_OFFSET -8 | 
| Glauber de Oliveira Costa | 72fe485 | 2008-01-30 13:32:08 +0100 | [diff] [blame] | 663 | DISABLE_INTERRUPTS(CLBR_NONE) | 
| Ingo Molnar | 2601e64 | 2006-07-03 00:24:45 -0700 | [diff] [blame] | 664 | TRACE_IRQS_OFF | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 665 | jmp int_with_check | 
|  | 666 |  | 
|  | 667 | /* handle signals and tracing -- both require a full stack frame */ | 
|  | 668 | int_very_careful: | 
| Ingo Molnar | 2601e64 | 2006-07-03 00:24:45 -0700 | [diff] [blame] | 669 | TRACE_IRQS_ON | 
| Glauber de Oliveira Costa | 72fe485 | 2008-01-30 13:32:08 +0100 | [diff] [blame] | 670 | ENABLE_INTERRUPTS(CLBR_NONE) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 671 | SAVE_REST | 
| Alexander van Heukelum | 0bd7b79 | 2008-11-16 15:29:00 +0100 | [diff] [blame] | 672 | /* Check for syscall exit trace */ | 
| Roland McGrath | d4d6715 | 2008-07-09 02:38:07 -0700 | [diff] [blame] | 673 | testl $_TIF_WORK_SYSCALL_EXIT,%edx | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 674 | jz int_signal | 
|  | 675 | pushq %rdi | 
| Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 676 | CFI_ADJUST_CFA_OFFSET 8 | 
| Alexander van Heukelum | 0bd7b79 | 2008-11-16 15:29:00 +0100 | [diff] [blame] | 677 | leaq 8(%rsp),%rdi	# &ptregs -> arg1 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 678 | call syscall_trace_leave | 
|  | 679 | popq %rdi | 
| Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 680 | CFI_ADJUST_CFA_OFFSET -8 | 
| Roland McGrath | d4d6715 | 2008-07-09 02:38:07 -0700 | [diff] [blame] | 681 | andl $~(_TIF_WORK_SYSCALL_EXIT|_TIF_SYSCALL_EMU),%edi | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 682 | jmp int_restore_rest | 
| Alexander van Heukelum | 0bd7b79 | 2008-11-16 15:29:00 +0100 | [diff] [blame] | 683 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 684 | int_signal: | 
| Peter Zijlstra | 8f4d37e | 2008-01-25 21:08:29 +0100 | [diff] [blame] | 685 | testl $_TIF_DO_NOTIFY_MASK,%edx | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 686 | jz 1f | 
|  | 687 | movq %rsp,%rdi		# &ptregs -> arg1 | 
|  | 688 | xorl %esi,%esi		# oldset -> arg2 | 
|  | 689 | call do_notify_resume | 
| Roland McGrath | eca91e7 | 2008-07-10 14:50:39 -0700 | [diff] [blame] | 690 | 1:	movl $_TIF_WORK_MASK,%edi | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 691 | int_restore_rest: | 
|  | 692 | RESTORE_REST | 
| Glauber de Oliveira Costa | 72fe485 | 2008-01-30 13:32:08 +0100 | [diff] [blame] | 693 | DISABLE_INTERRUPTS(CLBR_NONE) | 
| Ingo Molnar | 2601e64 | 2006-07-03 00:24:45 -0700 | [diff] [blame] | 694 | TRACE_IRQS_OFF | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 695 | jmp int_with_check | 
|  | 696 | CFI_ENDPROC | 
| Jan Beulich | bcddc01 | 2006-12-07 02:14:02 +0100 | [diff] [blame] | 697 | END(system_call) | 
| Alexander van Heukelum | 0bd7b79 | 2008-11-16 15:29:00 +0100 | [diff] [blame] | 698 |  | 
|  | 699 | /* | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 700 | * Certain special system calls that need to save a complete full stack frame. | 
| Alexander van Heukelum | 0bd7b79 | 2008-11-16 15:29:00 +0100 | [diff] [blame] | 701 | */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 702 | .macro PTREGSCALL label,func,arg | 
| Alexander van Heukelum | c002a1e | 2008-11-21 16:41:55 +0100 | [diff] [blame] | 703 | ENTRY(\label) | 
|  | 704 | PARTIAL_FRAME 1 8		/* offset 8: return address */ | 
|  | 705 | subq $REST_SKIP, %rsp | 
|  | 706 | CFI_ADJUST_CFA_OFFSET REST_SKIP | 
|  | 707 | call save_rest | 
|  | 708 | DEFAULT_FRAME 0 8		/* offset 8: return address */ | 
|  | 709 | leaq 8(%rsp), \arg	/* pt_regs pointer */ | 
|  | 710 | call \func | 
|  | 711 | jmp ptregscall_common | 
|  | 712 | CFI_ENDPROC | 
| Jan Beulich | 4b787e0 | 2006-06-26 13:56:55 +0200 | [diff] [blame] | 713 | END(\label) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 714 | .endm | 
|  | 715 |  | 
|  | 716 | PTREGSCALL stub_clone, sys_clone, %r8 | 
|  | 717 | PTREGSCALL stub_fork, sys_fork, %rdi | 
|  | 718 | PTREGSCALL stub_vfork, sys_vfork, %rdi | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 719 | PTREGSCALL stub_sigaltstack, sys_sigaltstack, %rdx | 
|  | 720 | PTREGSCALL stub_iopl, sys_iopl, %rsi | 
|  | 721 |  | 
|  | 722 | ENTRY(ptregscall_common) | 
| Alexander van Heukelum | c002a1e | 2008-11-21 16:41:55 +0100 | [diff] [blame] | 723 | DEFAULT_FRAME 1 8	/* offset 8: return address */ | 
|  | 724 | RESTORE_TOP_OF_STACK %r11, 8 | 
|  | 725 | movq_cfi_restore R15+8, r15 | 
|  | 726 | movq_cfi_restore R14+8, r14 | 
|  | 727 | movq_cfi_restore R13+8, r13 | 
|  | 728 | movq_cfi_restore R12+8, r12 | 
|  | 729 | movq_cfi_restore RBP+8, rbp | 
|  | 730 | movq_cfi_restore RBX+8, rbx | 
|  | 731 | ret $REST_SKIP		/* pop extended registers */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 732 | CFI_ENDPROC | 
| Jan Beulich | 4b787e0 | 2006-06-26 13:56:55 +0200 | [diff] [blame] | 733 | END(ptregscall_common) | 
| Alexander van Heukelum | 0bd7b79 | 2008-11-16 15:29:00 +0100 | [diff] [blame] | 734 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 735 | ENTRY(stub_execve) | 
|  | 736 | CFI_STARTPROC | 
|  | 737 | popq %r11 | 
| Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 738 | CFI_ADJUST_CFA_OFFSET -8 | 
|  | 739 | CFI_REGISTER rip, r11 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 740 | SAVE_REST | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 741 | FIXUP_TOP_OF_STACK %r11 | 
| Ingo Molnar | 5d119b2 | 2008-02-26 12:55:57 +0100 | [diff] [blame] | 742 | movq %rsp, %rcx | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 743 | call sys_execve | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 744 | RESTORE_TOP_OF_STACK %r11 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 745 | movq %rax,RAX(%rsp) | 
|  | 746 | RESTORE_REST | 
|  | 747 | jmp int_ret_from_sys_call | 
|  | 748 | CFI_ENDPROC | 
| Jan Beulich | 4b787e0 | 2006-06-26 13:56:55 +0200 | [diff] [blame] | 749 | END(stub_execve) | 
| Alexander van Heukelum | 0bd7b79 | 2008-11-16 15:29:00 +0100 | [diff] [blame] | 750 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 751 | /* | 
|  | 752 | * sigreturn is special because it needs to restore all registers on return. | 
|  | 753 | * This cannot be done with SYSRET, so use the IRET return path instead. | 
| Alexander van Heukelum | 0bd7b79 | 2008-11-16 15:29:00 +0100 | [diff] [blame] | 754 | */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 755 | ENTRY(stub_rt_sigreturn) | 
|  | 756 | CFI_STARTPROC | 
| Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 757 | addq $8, %rsp | 
|  | 758 | CFI_ADJUST_CFA_OFFSET	-8 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 759 | SAVE_REST | 
|  | 760 | movq %rsp,%rdi | 
|  | 761 | FIXUP_TOP_OF_STACK %r11 | 
|  | 762 | call sys_rt_sigreturn | 
|  | 763 | movq %rax,RAX(%rsp) # fixme, this could be done at the higher layer | 
|  | 764 | RESTORE_REST | 
|  | 765 | jmp int_ret_from_sys_call | 
|  | 766 | CFI_ENDPROC | 
| Jan Beulich | 4b787e0 | 2006-06-26 13:56:55 +0200 | [diff] [blame] | 767 | END(stub_rt_sigreturn) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 768 |  | 
| Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 769 | /* | 
| H. Peter Anvin | 939b787 | 2008-11-11 13:51:52 -0800 | [diff] [blame] | 770 | * Build the entry stubs and pointer table with some assembler magic. | 
|  | 771 | * We pack 7 stubs into a single 32-byte chunk, which will fit in a | 
|  | 772 | * single cache line on all modern x86 implementations. | 
|  | 773 | */ | 
|  | 774 | .section .init.rodata,"a" | 
|  | 775 | ENTRY(interrupt) | 
|  | 776 | .text | 
|  | 777 | .p2align 5 | 
|  | 778 | .p2align CONFIG_X86_L1_CACHE_SHIFT | 
|  | 779 | ENTRY(irq_entries_start) | 
|  | 780 | INTR_FRAME | 
|  | 781 | vector=FIRST_EXTERNAL_VECTOR | 
|  | 782 | .rept (NR_VECTORS-FIRST_EXTERNAL_VECTOR+6)/7 | 
|  | 783 | .balign 32 | 
|  | 784 | .rept	7 | 
|  | 785 | .if vector < NR_VECTORS | 
| H. Peter Anvin | 8665596 | 2008-11-12 10:27:35 -0800 | [diff] [blame] | 786 | .if vector <> FIRST_EXTERNAL_VECTOR | 
| H. Peter Anvin | 939b787 | 2008-11-11 13:51:52 -0800 | [diff] [blame] | 787 | CFI_ADJUST_CFA_OFFSET -8 | 
|  | 788 | .endif | 
|  | 789 | 1:	pushq $(~vector+0x80)	/* Note: always in signed byte range */ | 
|  | 790 | CFI_ADJUST_CFA_OFFSET 8 | 
| H. Peter Anvin | 8665596 | 2008-11-12 10:27:35 -0800 | [diff] [blame] | 791 | .if ((vector-FIRST_EXTERNAL_VECTOR)%7) <> 6 | 
| H. Peter Anvin | 939b787 | 2008-11-11 13:51:52 -0800 | [diff] [blame] | 792 | jmp 2f | 
|  | 793 | .endif | 
|  | 794 | .previous | 
|  | 795 | .quad 1b | 
|  | 796 | .text | 
|  | 797 | vector=vector+1 | 
|  | 798 | .endif | 
|  | 799 | .endr | 
|  | 800 | 2:	jmp common_interrupt | 
|  | 801 | .endr | 
|  | 802 | CFI_ENDPROC | 
|  | 803 | END(irq_entries_start) | 
|  | 804 |  | 
|  | 805 | .previous | 
|  | 806 | END(interrupt) | 
|  | 807 | .previous | 
|  | 808 |  | 
| Alexander van Heukelum | d99015b | 2008-11-19 01:18:11 +0100 | [diff] [blame] | 809 | /* | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 810 | * Interrupt entry/exit. | 
|  | 811 | * | 
|  | 812 | * Interrupt entry points save only callee clobbered registers in fast path. | 
| Alexander van Heukelum | d99015b | 2008-11-19 01:18:11 +0100 | [diff] [blame] | 813 | * | 
|  | 814 | * Entry runs with interrupts off. | 
|  | 815 | */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 816 |  | 
| Alexander van Heukelum | 722024d | 2008-11-13 13:50:20 +0100 | [diff] [blame] | 817 | /* 0(%rsp): ~(interrupt number) */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 818 | .macro interrupt func | 
| Alexander van Heukelum | d99015b | 2008-11-19 01:18:11 +0100 | [diff] [blame] | 819 | subq $10*8, %rsp | 
|  | 820 | CFI_ADJUST_CFA_OFFSET 10*8 | 
|  | 821 | call save_args | 
| Alexander van Heukelum | dcd072e | 2008-11-20 14:40:11 +0100 | [diff] [blame] | 822 | PARTIAL_FRAME 0 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 823 | call \func | 
|  | 824 | .endm | 
|  | 825 |  | 
| Alexander van Heukelum | 722024d | 2008-11-13 13:50:20 +0100 | [diff] [blame] | 826 | /* | 
|  | 827 | * The interrupt stubs push (~vector+0x80) onto the stack and | 
|  | 828 | * then jump to common_interrupt. | 
|  | 829 | */ | 
| H. Peter Anvin | 939b787 | 2008-11-11 13:51:52 -0800 | [diff] [blame] | 830 | .p2align CONFIG_X86_L1_CACHE_SHIFT | 
|  | 831 | common_interrupt: | 
| Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 832 | XCPT_FRAME | 
| Alexander van Heukelum | 722024d | 2008-11-13 13:50:20 +0100 | [diff] [blame] | 833 | addq $-0x80,(%rsp)		/* Adjust vector to [-256,-1] range */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 834 | interrupt do_IRQ | 
|  | 835 | /* 0(%rsp): oldrsp-ARGOFFSET */ | 
| Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 836 | ret_from_intr: | 
| Glauber de Oliveira Costa | 72fe485 | 2008-01-30 13:32:08 +0100 | [diff] [blame] | 837 | DISABLE_INTERRUPTS(CLBR_NONE) | 
| Ingo Molnar | 2601e64 | 2006-07-03 00:24:45 -0700 | [diff] [blame] | 838 | TRACE_IRQS_OFF | 
| Andi Kleen | 3829ee6 | 2005-07-28 21:15:48 -0700 | [diff] [blame] | 839 | decl %gs:pda_irqcount | 
| Jan Beulich | 1de9c3f | 2006-06-26 13:57:35 +0200 | [diff] [blame] | 840 | leaveq | 
| Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 841 | CFI_DEF_CFA_REGISTER	rsp | 
| Jan Beulich | 1de9c3f | 2006-06-26 13:57:35 +0200 | [diff] [blame] | 842 | CFI_ADJUST_CFA_OFFSET	-8 | 
| Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 843 | exit_intr: | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 844 | GET_THREAD_INFO(%rcx) | 
|  | 845 | testl $3,CS-ARGOFFSET(%rsp) | 
|  | 846 | je retint_kernel | 
| Alexander van Heukelum | 0bd7b79 | 2008-11-16 15:29:00 +0100 | [diff] [blame] | 847 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 848 | /* Interrupt came from user space */ | 
|  | 849 | /* | 
|  | 850 | * Has a correct top of stack, but a partial stack frame | 
|  | 851 | * %rcx: thread info. Interrupts off. | 
| Alexander van Heukelum | 0bd7b79 | 2008-11-16 15:29:00 +0100 | [diff] [blame] | 852 | */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 853 | retint_with_reschedule: | 
|  | 854 | movl $_TIF_WORK_MASK,%edi | 
| Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 855 | retint_check: | 
| Peter Zijlstra | 10cd706 | 2007-10-11 22:11:12 +0200 | [diff] [blame] | 856 | LOCKDEP_SYS_EXIT_IRQ | 
| Glauber Costa | 26ccb8a | 2008-06-24 11:19:35 -0300 | [diff] [blame] | 857 | movl TI_flags(%rcx),%edx | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 858 | andl %edi,%edx | 
| Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 859 | CFI_REMEMBER_STATE | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 860 | jnz  retint_careful | 
| Peter Zijlstra | 10cd706 | 2007-10-11 22:11:12 +0200 | [diff] [blame] | 861 |  | 
|  | 862 | retint_swapgs:		/* return to user-space */ | 
| Ingo Molnar | 2601e64 | 2006-07-03 00:24:45 -0700 | [diff] [blame] | 863 | /* | 
|  | 864 | * The iretq could re-enable interrupts: | 
|  | 865 | */ | 
| Glauber de Oliveira Costa | 72fe485 | 2008-01-30 13:32:08 +0100 | [diff] [blame] | 866 | DISABLE_INTERRUPTS(CLBR_ANY) | 
| Ingo Molnar | 2601e64 | 2006-07-03 00:24:45 -0700 | [diff] [blame] | 867 | TRACE_IRQS_IRETQ | 
| Glauber de Oliveira Costa | 72fe485 | 2008-01-30 13:32:08 +0100 | [diff] [blame] | 868 | SWAPGS | 
| Ingo Molnar | 2601e64 | 2006-07-03 00:24:45 -0700 | [diff] [blame] | 869 | jmp restore_args | 
|  | 870 |  | 
| Peter Zijlstra | 10cd706 | 2007-10-11 22:11:12 +0200 | [diff] [blame] | 871 | retint_restore_args:	/* return to kernel space */ | 
| Glauber de Oliveira Costa | 72fe485 | 2008-01-30 13:32:08 +0100 | [diff] [blame] | 872 | DISABLE_INTERRUPTS(CLBR_ANY) | 
| Ingo Molnar | 2601e64 | 2006-07-03 00:24:45 -0700 | [diff] [blame] | 873 | /* | 
|  | 874 | * The iretq could re-enable interrupts: | 
|  | 875 | */ | 
|  | 876 | TRACE_IRQS_IRETQ | 
|  | 877 | restore_args: | 
| Ingo Molnar | 3701d863 | 2008-02-09 23:24:08 +0100 | [diff] [blame] | 878 | RESTORE_ARGS 0,8,0 | 
|  | 879 |  | 
| Adrian Bunk | f7f3d79 | 2008-02-13 23:29:53 +0200 | [diff] [blame] | 880 | irq_return: | 
| Glauber de Oliveira Costa | 72fe485 | 2008-01-30 13:32:08 +0100 | [diff] [blame] | 881 | INTERRUPT_RETURN | 
| Ingo Molnar | 3701d863 | 2008-02-09 23:24:08 +0100 | [diff] [blame] | 882 |  | 
|  | 883 | .section __ex_table, "a" | 
|  | 884 | .quad irq_return, bad_iret | 
|  | 885 | .previous | 
|  | 886 |  | 
|  | 887 | #ifdef CONFIG_PARAVIRT | 
| Glauber de Oliveira Costa | 72fe485 | 2008-01-30 13:32:08 +0100 | [diff] [blame] | 888 | ENTRY(native_iret) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 889 | iretq | 
|  | 890 |  | 
|  | 891 | .section __ex_table,"a" | 
| Glauber de Oliveira Costa | 72fe485 | 2008-01-30 13:32:08 +0100 | [diff] [blame] | 892 | .quad native_iret, bad_iret | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 893 | .previous | 
| Ingo Molnar | 3701d863 | 2008-02-09 23:24:08 +0100 | [diff] [blame] | 894 | #endif | 
|  | 895 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 896 | .section .fixup,"ax" | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 897 | bad_iret: | 
| Roland McGrath | 3aa4b37 | 2008-02-06 22:39:43 +0100 | [diff] [blame] | 898 | /* | 
|  | 899 | * The iret traps when the %cs or %ss being restored is bogus. | 
|  | 900 | * We've lost the original trap vector and error code. | 
|  | 901 | * #GPF is the most likely one to get for an invalid selector. | 
|  | 902 | * So pretend we completed the iret and took the #GPF in user mode. | 
|  | 903 | * | 
|  | 904 | * We are now running with the kernel GS after exception recovery. | 
|  | 905 | * But error_entry expects us to have user GS to match the user %cs, | 
|  | 906 | * so swap back. | 
|  | 907 | */ | 
|  | 908 | pushq $0 | 
|  | 909 |  | 
|  | 910 | SWAPGS | 
|  | 911 | jmp general_protection | 
|  | 912 |  | 
| Glauber de Oliveira Costa | 72fe485 | 2008-01-30 13:32:08 +0100 | [diff] [blame] | 913 | .previous | 
|  | 914 |  | 
| Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 915 | /* edi: workmask, edx: work */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 916 | retint_careful: | 
| Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 917 | CFI_RESTORE_STATE | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 918 | bt    $TIF_NEED_RESCHED,%edx | 
|  | 919 | jnc   retint_signal | 
| Ingo Molnar | 2601e64 | 2006-07-03 00:24:45 -0700 | [diff] [blame] | 920 | TRACE_IRQS_ON | 
| Glauber de Oliveira Costa | 72fe485 | 2008-01-30 13:32:08 +0100 | [diff] [blame] | 921 | ENABLE_INTERRUPTS(CLBR_NONE) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 922 | pushq %rdi | 
| Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 923 | CFI_ADJUST_CFA_OFFSET	8 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 924 | call  schedule | 
| Alexander van Heukelum | 0bd7b79 | 2008-11-16 15:29:00 +0100 | [diff] [blame] | 925 | popq %rdi | 
| Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 926 | CFI_ADJUST_CFA_OFFSET	-8 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 927 | GET_THREAD_INFO(%rcx) | 
| Glauber de Oliveira Costa | 72fe485 | 2008-01-30 13:32:08 +0100 | [diff] [blame] | 928 | DISABLE_INTERRUPTS(CLBR_NONE) | 
| Ingo Molnar | 2601e64 | 2006-07-03 00:24:45 -0700 | [diff] [blame] | 929 | TRACE_IRQS_OFF | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 930 | jmp retint_check | 
| Alexander van Heukelum | 0bd7b79 | 2008-11-16 15:29:00 +0100 | [diff] [blame] | 931 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 932 | retint_signal: | 
| Peter Zijlstra | 8f4d37e | 2008-01-25 21:08:29 +0100 | [diff] [blame] | 933 | testl $_TIF_DO_NOTIFY_MASK,%edx | 
| Andi Kleen | 10ffdbb | 2005-05-16 21:53:19 -0700 | [diff] [blame] | 934 | jz    retint_swapgs | 
| Ingo Molnar | 2601e64 | 2006-07-03 00:24:45 -0700 | [diff] [blame] | 935 | TRACE_IRQS_ON | 
| Glauber de Oliveira Costa | 72fe485 | 2008-01-30 13:32:08 +0100 | [diff] [blame] | 936 | ENABLE_INTERRUPTS(CLBR_NONE) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 937 | SAVE_REST | 
| Alexander van Heukelum | 0bd7b79 | 2008-11-16 15:29:00 +0100 | [diff] [blame] | 938 | movq $-1,ORIG_RAX(%rsp) | 
| Andi Kleen | 3829ee6 | 2005-07-28 21:15:48 -0700 | [diff] [blame] | 939 | xorl %esi,%esi		# oldset | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 940 | movq %rsp,%rdi		# &pt_regs | 
|  | 941 | call do_notify_resume | 
|  | 942 | RESTORE_REST | 
| Glauber de Oliveira Costa | 72fe485 | 2008-01-30 13:32:08 +0100 | [diff] [blame] | 943 | DISABLE_INTERRUPTS(CLBR_NONE) | 
| Ingo Molnar | 2601e64 | 2006-07-03 00:24:45 -0700 | [diff] [blame] | 944 | TRACE_IRQS_OFF | 
| Andi Kleen | be9e687 | 2005-05-01 08:58:51 -0700 | [diff] [blame] | 945 | GET_THREAD_INFO(%rcx) | 
| Roland McGrath | eca91e7 | 2008-07-10 14:50:39 -0700 | [diff] [blame] | 946 | jmp retint_with_reschedule | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 947 |  | 
|  | 948 | #ifdef CONFIG_PREEMPT | 
|  | 949 | /* Returning to kernel space. Check if we need preemption */ | 
|  | 950 | /* rcx:	 threadinfo. interrupts off. */ | 
| Andi Kleen | b06baba | 2006-09-26 10:52:29 +0200 | [diff] [blame] | 951 | ENTRY(retint_kernel) | 
| Glauber Costa | 26ccb8a | 2008-06-24 11:19:35 -0300 | [diff] [blame] | 952 | cmpl $0,TI_preempt_count(%rcx) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 953 | jnz  retint_restore_args | 
| Glauber Costa | 26ccb8a | 2008-06-24 11:19:35 -0300 | [diff] [blame] | 954 | bt  $TIF_NEED_RESCHED,TI_flags(%rcx) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 955 | jnc  retint_restore_args | 
|  | 956 | bt   $9,EFLAGS-ARGOFFSET(%rsp)	/* interrupts off? */ | 
|  | 957 | jnc  retint_restore_args | 
|  | 958 | call preempt_schedule_irq | 
|  | 959 | jmp exit_intr | 
| Alexander van Heukelum | 0bd7b79 | 2008-11-16 15:29:00 +0100 | [diff] [blame] | 960 | #endif | 
| Jan Beulich | 4b787e0 | 2006-06-26 13:56:55 +0200 | [diff] [blame] | 961 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 962 | CFI_ENDPROC | 
| Jan Beulich | 4b787e0 | 2006-06-26 13:56:55 +0200 | [diff] [blame] | 963 | END(common_interrupt) | 
| Alexander van Heukelum | 0bd7b79 | 2008-11-16 15:29:00 +0100 | [diff] [blame] | 964 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 965 | /* | 
|  | 966 | * APIC interrupts. | 
| Alexander van Heukelum | 0bd7b79 | 2008-11-16 15:29:00 +0100 | [diff] [blame] | 967 | */ | 
| Alexander van Heukelum | 322648d | 2008-11-23 10:08:28 +0100 | [diff] [blame] | 968 | .macro apicinterrupt num sym do_sym | 
|  | 969 | ENTRY(\sym) | 
| Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 970 | INTR_FRAME | 
| Rusty Russell | 19eadf9 | 2006-06-27 02:53:44 -0700 | [diff] [blame] | 971 | pushq $~(\num) | 
| Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 972 | CFI_ADJUST_CFA_OFFSET 8 | 
| Alexander van Heukelum | 322648d | 2008-11-23 10:08:28 +0100 | [diff] [blame] | 973 | interrupt \do_sym | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 974 | jmp ret_from_intr | 
|  | 975 | CFI_ENDPROC | 
| Alexander van Heukelum | 322648d | 2008-11-23 10:08:28 +0100 | [diff] [blame] | 976 | END(\sym) | 
|  | 977 | .endm | 
| Jacob Shin | 89b831e | 2005-11-05 17:25:53 +0100 | [diff] [blame] | 978 |  | 
| Alexander van Heukelum | 0bd7b79 | 2008-11-16 15:29:00 +0100 | [diff] [blame] | 979 | #ifdef CONFIG_SMP | 
| Alexander van Heukelum | 322648d | 2008-11-23 10:08:28 +0100 | [diff] [blame] | 980 | apicinterrupt IRQ_MOVE_CLEANUP_VECTOR \ | 
|  | 981 | irq_move_cleanup_interrupt smp_irq_move_cleanup_interrupt | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 982 | #endif | 
|  | 983 |  | 
| Cyrill Gorcunov | 5ae3a13 | 2008-11-27 00:02:10 +0300 | [diff] [blame] | 984 | apicinterrupt UV_BAU_MESSAGE \ | 
| Alexander van Heukelum | 322648d | 2008-11-23 10:08:28 +0100 | [diff] [blame] | 985 | uv_bau_message_intr1 uv_bau_message_interrupt | 
|  | 986 | apicinterrupt LOCAL_TIMER_VECTOR \ | 
|  | 987 | apic_timer_interrupt smp_apic_timer_interrupt | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 988 |  | 
| Alexander van Heukelum | 322648d | 2008-11-23 10:08:28 +0100 | [diff] [blame] | 989 | #ifdef CONFIG_SMP | 
|  | 990 | apicinterrupt INVALIDATE_TLB_VECTOR_START+0 \ | 
|  | 991 | invalidate_interrupt0 smp_invalidate_interrupt | 
|  | 992 | apicinterrupt INVALIDATE_TLB_VECTOR_START+1 \ | 
|  | 993 | invalidate_interrupt1 smp_invalidate_interrupt | 
|  | 994 | apicinterrupt INVALIDATE_TLB_VECTOR_START+2 \ | 
|  | 995 | invalidate_interrupt2 smp_invalidate_interrupt | 
|  | 996 | apicinterrupt INVALIDATE_TLB_VECTOR_START+3 \ | 
|  | 997 | invalidate_interrupt3 smp_invalidate_interrupt | 
|  | 998 | apicinterrupt INVALIDATE_TLB_VECTOR_START+4 \ | 
|  | 999 | invalidate_interrupt4 smp_invalidate_interrupt | 
|  | 1000 | apicinterrupt INVALIDATE_TLB_VECTOR_START+5 \ | 
|  | 1001 | invalidate_interrupt5 smp_invalidate_interrupt | 
|  | 1002 | apicinterrupt INVALIDATE_TLB_VECTOR_START+6 \ | 
|  | 1003 | invalidate_interrupt6 smp_invalidate_interrupt | 
|  | 1004 | apicinterrupt INVALIDATE_TLB_VECTOR_START+7 \ | 
|  | 1005 | invalidate_interrupt7 smp_invalidate_interrupt | 
|  | 1006 | #endif | 
| Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 1007 |  | 
| Alexander van Heukelum | 322648d | 2008-11-23 10:08:28 +0100 | [diff] [blame] | 1008 | apicinterrupt THRESHOLD_APIC_VECTOR \ | 
|  | 1009 | threshold_interrupt mce_threshold_interrupt | 
|  | 1010 | apicinterrupt THERMAL_APIC_VECTOR \ | 
|  | 1011 | thermal_interrupt smp_thermal_interrupt | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1012 |  | 
| Alexander van Heukelum | 322648d | 2008-11-23 10:08:28 +0100 | [diff] [blame] | 1013 | #ifdef CONFIG_SMP | 
|  | 1014 | apicinterrupt CALL_FUNCTION_SINGLE_VECTOR \ | 
|  | 1015 | call_function_single_interrupt smp_call_function_single_interrupt | 
|  | 1016 | apicinterrupt CALL_FUNCTION_VECTOR \ | 
|  | 1017 | call_function_interrupt smp_call_function_interrupt | 
|  | 1018 | apicinterrupt RESCHEDULE_VECTOR \ | 
|  | 1019 | reschedule_interrupt smp_reschedule_interrupt | 
|  | 1020 | #endif | 
|  | 1021 |  | 
|  | 1022 | apicinterrupt ERROR_APIC_VECTOR \ | 
|  | 1023 | error_interrupt smp_error_interrupt | 
|  | 1024 | apicinterrupt SPURIOUS_APIC_VECTOR \ | 
|  | 1025 | spurious_interrupt smp_spurious_interrupt | 
| Alexander van Heukelum | 0bd7b79 | 2008-11-16 15:29:00 +0100 | [diff] [blame] | 1026 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1027 | /* | 
|  | 1028 | * Exception entry points. | 
| Alexander van Heukelum | 0bd7b79 | 2008-11-16 15:29:00 +0100 | [diff] [blame] | 1029 | */ | 
| Alexander van Heukelum | 322648d | 2008-11-23 10:08:28 +0100 | [diff] [blame] | 1030 | .macro zeroentry sym do_sym | 
|  | 1031 | ENTRY(\sym) | 
| Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 1032 | INTR_FRAME | 
| Jeremy Fitzhardinge | fab5842 | 2008-06-25 00:19:31 -0400 | [diff] [blame] | 1033 | PARAVIRT_ADJUST_EXCEPTION_FRAME | 
| Ingo Molnar | 14ae22b | 2008-11-21 15:20:47 +0100 | [diff] [blame] | 1034 | pushq_cfi $-1		/* ORIG_RAX: no syscall to restart */ | 
| Alexander van Heukelum | d99015b | 2008-11-19 01:18:11 +0100 | [diff] [blame] | 1035 | subq $15*8,%rsp | 
|  | 1036 | CFI_ADJUST_CFA_OFFSET 15*8 | 
|  | 1037 | call error_entry | 
| Alexander van Heukelum | dcd072e | 2008-11-20 14:40:11 +0100 | [diff] [blame] | 1038 | DEFAULT_FRAME 0 | 
| Alexander van Heukelum | d99015b | 2008-11-19 01:18:11 +0100 | [diff] [blame] | 1039 | movq %rsp,%rdi		/* pt_regs pointer */ | 
|  | 1040 | xorl %esi,%esi		/* no error code */ | 
| Alexander van Heukelum | 322648d | 2008-11-23 10:08:28 +0100 | [diff] [blame] | 1041 | call \do_sym | 
| Alexander van Heukelum | d99015b | 2008-11-19 01:18:11 +0100 | [diff] [blame] | 1042 | jmp error_exit		/* %ebx: no swapgs flag */ | 
| Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 1043 | CFI_ENDPROC | 
| Alexander van Heukelum | 322648d | 2008-11-23 10:08:28 +0100 | [diff] [blame] | 1044 | END(\sym) | 
|  | 1045 | .endm | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1046 |  | 
| Alexander van Heukelum | 322648d | 2008-11-23 10:08:28 +0100 | [diff] [blame] | 1047 | .macro paranoidzeroentry sym do_sym | 
| Alexander van Heukelum | ddeb8f2 | 2008-11-24 13:24:28 +0100 | [diff] [blame] | 1048 | ENTRY(\sym) | 
| Alexander van Heukelum | b8b1d08 | 2008-11-21 16:44:28 +0100 | [diff] [blame] | 1049 | INTR_FRAME | 
|  | 1050 | PARAVIRT_ADJUST_EXCEPTION_FRAME | 
|  | 1051 | pushq $-1		/* ORIG_RAX: no syscall to restart */ | 
|  | 1052 | CFI_ADJUST_CFA_OFFSET 8 | 
|  | 1053 | subq $15*8, %rsp | 
|  | 1054 | call save_paranoid | 
|  | 1055 | TRACE_IRQS_OFF | 
|  | 1056 | movq %rsp,%rdi		/* pt_regs pointer */ | 
|  | 1057 | xorl %esi,%esi		/* no error code */ | 
| Alexander van Heukelum | 322648d | 2008-11-23 10:08:28 +0100 | [diff] [blame] | 1058 | call \do_sym | 
| Alexander van Heukelum | b8b1d08 | 2008-11-21 16:44:28 +0100 | [diff] [blame] | 1059 | jmp paranoid_exit	/* %ebx: no swapgs flag */ | 
|  | 1060 | CFI_ENDPROC | 
| Alexander van Heukelum | ddeb8f2 | 2008-11-24 13:24:28 +0100 | [diff] [blame] | 1061 | END(\sym) | 
| Alexander van Heukelum | 322648d | 2008-11-23 10:08:28 +0100 | [diff] [blame] | 1062 | .endm | 
| Alexander van Heukelum | b8b1d08 | 2008-11-21 16:44:28 +0100 | [diff] [blame] | 1063 |  | 
| Alexander van Heukelum | 322648d | 2008-11-23 10:08:28 +0100 | [diff] [blame] | 1064 | .macro paranoidzeroentry_ist sym do_sym ist | 
| Alexander van Heukelum | ddeb8f2 | 2008-11-24 13:24:28 +0100 | [diff] [blame] | 1065 | ENTRY(\sym) | 
| Cyrill Gorcunov | 9f1e87e | 2008-11-27 21:10:08 +0300 | [diff] [blame] | 1066 | INTR_FRAME | 
| Alexander van Heukelum | b8b1d08 | 2008-11-21 16:44:28 +0100 | [diff] [blame] | 1067 | PARAVIRT_ADJUST_EXCEPTION_FRAME | 
|  | 1068 | pushq $-1		/* ORIG_RAX: no syscall to restart */ | 
|  | 1069 | CFI_ADJUST_CFA_OFFSET 8 | 
|  | 1070 | subq $15*8, %rsp | 
|  | 1071 | call save_paranoid | 
|  | 1072 | TRACE_IRQS_OFF | 
|  | 1073 | movq %rsp,%rdi		/* pt_regs pointer */ | 
|  | 1074 | xorl %esi,%esi		/* no error code */ | 
|  | 1075 | movq %gs:pda_data_offset, %rbp | 
|  | 1076 | subq $EXCEPTION_STKSZ, per_cpu__init_tss + TSS_ist + (\ist - 1) * 8(%rbp) | 
| Alexander van Heukelum | 322648d | 2008-11-23 10:08:28 +0100 | [diff] [blame] | 1077 | call \do_sym | 
| Alexander van Heukelum | b8b1d08 | 2008-11-21 16:44:28 +0100 | [diff] [blame] | 1078 | addq $EXCEPTION_STKSZ, per_cpu__init_tss + TSS_ist + (\ist - 1) * 8(%rbp) | 
|  | 1079 | jmp paranoid_exit	/* %ebx: no swapgs flag */ | 
|  | 1080 | CFI_ENDPROC | 
| Alexander van Heukelum | ddeb8f2 | 2008-11-24 13:24:28 +0100 | [diff] [blame] | 1081 | END(\sym) | 
| Alexander van Heukelum | 322648d | 2008-11-23 10:08:28 +0100 | [diff] [blame] | 1082 | .endm | 
| Alexander van Heukelum | b8b1d08 | 2008-11-21 16:44:28 +0100 | [diff] [blame] | 1083 |  | 
| Alexander van Heukelum | ddeb8f2 | 2008-11-24 13:24:28 +0100 | [diff] [blame] | 1084 | .macro errorentry sym do_sym | 
| Alexander van Heukelum | 322648d | 2008-11-23 10:08:28 +0100 | [diff] [blame] | 1085 | ENTRY(\sym) | 
| Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 1086 | XCPT_FRAME | 
| Jeremy Fitzhardinge | fab5842 | 2008-06-25 00:19:31 -0400 | [diff] [blame] | 1087 | PARAVIRT_ADJUST_EXCEPTION_FRAME | 
| Alexander van Heukelum | d99015b | 2008-11-19 01:18:11 +0100 | [diff] [blame] | 1088 | subq $15*8,%rsp | 
|  | 1089 | CFI_ADJUST_CFA_OFFSET 15*8 | 
|  | 1090 | call error_entry | 
| Alexander van Heukelum | dcd072e | 2008-11-20 14:40:11 +0100 | [diff] [blame] | 1091 | DEFAULT_FRAME 0 | 
| Alexander van Heukelum | d99015b | 2008-11-19 01:18:11 +0100 | [diff] [blame] | 1092 | movq %rsp,%rdi			/* pt_regs pointer */ | 
|  | 1093 | movq ORIG_RAX(%rsp),%rsi	/* get error code */ | 
|  | 1094 | movq $-1,ORIG_RAX(%rsp)		/* no syscall to restart */ | 
| Alexander van Heukelum | 322648d | 2008-11-23 10:08:28 +0100 | [diff] [blame] | 1095 | call \do_sym | 
| Alexander van Heukelum | d99015b | 2008-11-19 01:18:11 +0100 | [diff] [blame] | 1096 | jmp error_exit			/* %ebx: no swapgs flag */ | 
| Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 1097 | CFI_ENDPROC | 
| Alexander van Heukelum | 322648d | 2008-11-23 10:08:28 +0100 | [diff] [blame] | 1098 | END(\sym) | 
| Alexander van Heukelum | 322648d | 2008-11-23 10:08:28 +0100 | [diff] [blame] | 1099 | .endm | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1100 |  | 
|  | 1101 | /* error code is on the stack already */ | 
| Alexander van Heukelum | ddeb8f2 | 2008-11-24 13:24:28 +0100 | [diff] [blame] | 1102 | .macro paranoiderrorentry sym do_sym | 
| Alexander van Heukelum | 322648d | 2008-11-23 10:08:28 +0100 | [diff] [blame] | 1103 | ENTRY(\sym) | 
| Alexander van Heukelum | b8b1d08 | 2008-11-21 16:44:28 +0100 | [diff] [blame] | 1104 | XCPT_FRAME | 
|  | 1105 | PARAVIRT_ADJUST_EXCEPTION_FRAME | 
|  | 1106 | subq $15*8,%rsp | 
| Alexander van Heukelum | e2f6bc2 | 2008-11-21 16:43:18 +0100 | [diff] [blame] | 1107 | CFI_ADJUST_CFA_OFFSET 15*8 | 
|  | 1108 | call save_paranoid | 
|  | 1109 | DEFAULT_FRAME 0 | 
| Alexander van Heukelum | 7e61a79 | 2008-09-26 14:03:03 +0200 | [diff] [blame] | 1110 | TRACE_IRQS_OFF | 
| Alexander van Heukelum | b8b1d08 | 2008-11-21 16:44:28 +0100 | [diff] [blame] | 1111 | movq %rsp,%rdi			/* pt_regs pointer */ | 
|  | 1112 | movq ORIG_RAX(%rsp),%rsi	/* get error code */ | 
|  | 1113 | movq $-1,ORIG_RAX(%rsp)		/* no syscall to restart */ | 
| Alexander van Heukelum | 322648d | 2008-11-23 10:08:28 +0100 | [diff] [blame] | 1114 | call \do_sym | 
| Alexander van Heukelum | b8b1d08 | 2008-11-21 16:44:28 +0100 | [diff] [blame] | 1115 | jmp paranoid_exit		/* %ebx: no swapgs flag */ | 
|  | 1116 | CFI_ENDPROC | 
| Alexander van Heukelum | 322648d | 2008-11-23 10:08:28 +0100 | [diff] [blame] | 1117 | END(\sym) | 
| Alexander van Heukelum | 322648d | 2008-11-23 10:08:28 +0100 | [diff] [blame] | 1118 | .endm | 
|  | 1119 |  | 
|  | 1120 | zeroentry divide_error do_divide_error | 
| Alexander van Heukelum | 322648d | 2008-11-23 10:08:28 +0100 | [diff] [blame] | 1121 | zeroentry overflow do_overflow | 
|  | 1122 | zeroentry bounds do_bounds | 
|  | 1123 | zeroentry invalid_op do_invalid_op | 
|  | 1124 | zeroentry device_not_available do_device_not_available | 
| Alexander van Heukelum | ddeb8f2 | 2008-11-24 13:24:28 +0100 | [diff] [blame] | 1125 | paranoiderrorentry double_fault do_double_fault | 
| Alexander van Heukelum | 322648d | 2008-11-23 10:08:28 +0100 | [diff] [blame] | 1126 | zeroentry coprocessor_segment_overrun do_coprocessor_segment_overrun | 
|  | 1127 | errorentry invalid_TSS do_invalid_TSS | 
|  | 1128 | errorentry segment_not_present do_segment_not_present | 
| Alexander van Heukelum | 322648d | 2008-11-23 10:08:28 +0100 | [diff] [blame] | 1129 | zeroentry spurious_interrupt_bug do_spurious_interrupt_bug | 
|  | 1130 | zeroentry coprocessor_error do_coprocessor_error | 
|  | 1131 | errorentry alignment_check do_alignment_check | 
| Alexander van Heukelum | 322648d | 2008-11-23 10:08:28 +0100 | [diff] [blame] | 1132 | zeroentry simd_coprocessor_error do_simd_coprocessor_error | 
| Ingo Molnar | 2601e64 | 2006-07-03 00:24:45 -0700 | [diff] [blame] | 1133 |  | 
| Cyrill Gorcunov | 9f1e87e | 2008-11-27 21:10:08 +0300 | [diff] [blame] | 1134 | /* Reload gs selector with exception handling */ | 
|  | 1135 | /* edi:  new selector */ | 
| Jeremy Fitzhardinge | 9f9d489 | 2008-06-25 00:19:32 -0400 | [diff] [blame] | 1136 | ENTRY(native_load_gs_index) | 
| Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 1137 | CFI_STARTPROC | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1138 | pushf | 
| Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 1139 | CFI_ADJUST_CFA_OFFSET 8 | 
| Glauber de Oliveira Costa | 72fe485 | 2008-01-30 13:32:08 +0100 | [diff] [blame] | 1140 | DISABLE_INTERRUPTS(CLBR_ANY | ~(CLBR_RDI)) | 
| Cyrill Gorcunov | 9f1e87e | 2008-11-27 21:10:08 +0300 | [diff] [blame] | 1141 | SWAPGS | 
| Alexander van Heukelum | 0bd7b79 | 2008-11-16 15:29:00 +0100 | [diff] [blame] | 1142 | gs_change: | 
| Cyrill Gorcunov | 9f1e87e | 2008-11-27 21:10:08 +0300 | [diff] [blame] | 1143 | movl %edi,%gs | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1144 | 2:	mfence		/* workaround */ | 
| Glauber de Oliveira Costa | 72fe485 | 2008-01-30 13:32:08 +0100 | [diff] [blame] | 1145 | SWAPGS | 
| Cyrill Gorcunov | 9f1e87e | 2008-11-27 21:10:08 +0300 | [diff] [blame] | 1146 | popf | 
| Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 1147 | CFI_ADJUST_CFA_OFFSET -8 | 
| Cyrill Gorcunov | 9f1e87e | 2008-11-27 21:10:08 +0300 | [diff] [blame] | 1148 | ret | 
| Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 1149 | CFI_ENDPROC | 
| Alexander van Heukelum | 6efdcfa | 2008-11-23 10:15:32 +0100 | [diff] [blame] | 1150 | END(native_load_gs_index) | 
| Alexander van Heukelum | 0bd7b79 | 2008-11-16 15:29:00 +0100 | [diff] [blame] | 1151 |  | 
| Cyrill Gorcunov | 9f1e87e | 2008-11-27 21:10:08 +0300 | [diff] [blame] | 1152 | .section __ex_table,"a" | 
|  | 1153 | .align 8 | 
|  | 1154 | .quad gs_change,bad_gs | 
|  | 1155 | .previous | 
|  | 1156 | .section .fixup,"ax" | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1157 | /* running with kernelgs */ | 
| Alexander van Heukelum | 0bd7b79 | 2008-11-16 15:29:00 +0100 | [diff] [blame] | 1158 | bad_gs: | 
| Glauber de Oliveira Costa | 72fe485 | 2008-01-30 13:32:08 +0100 | [diff] [blame] | 1159 | SWAPGS			/* switch back to user gs */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1160 | xorl %eax,%eax | 
| Cyrill Gorcunov | 9f1e87e | 2008-11-27 21:10:08 +0300 | [diff] [blame] | 1161 | movl %eax,%gs | 
|  | 1162 | jmp  2b | 
|  | 1163 | .previous | 
| Alexander van Heukelum | 0bd7b79 | 2008-11-16 15:29:00 +0100 | [diff] [blame] | 1164 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1165 | /* | 
|  | 1166 | * Create a kernel thread. | 
|  | 1167 | * | 
|  | 1168 | * C extern interface: | 
|  | 1169 | *	extern long kernel_thread(int (*fn)(void *), void * arg, unsigned long flags) | 
|  | 1170 | * | 
|  | 1171 | * asm input arguments: | 
|  | 1172 | *	rdi: fn, rsi: arg, rdx: flags | 
|  | 1173 | */ | 
|  | 1174 | ENTRY(kernel_thread) | 
|  | 1175 | CFI_STARTPROC | 
|  | 1176 | FAKE_STACK_FRAME $child_rip | 
|  | 1177 | SAVE_ALL | 
|  | 1178 |  | 
|  | 1179 | # rdi: flags, rsi: usp, rdx: will be &pt_regs | 
|  | 1180 | movq %rdx,%rdi | 
|  | 1181 | orq  kernel_thread_flags(%rip),%rdi | 
|  | 1182 | movq $-1, %rsi | 
|  | 1183 | movq %rsp, %rdx | 
|  | 1184 |  | 
|  | 1185 | xorl %r8d,%r8d | 
|  | 1186 | xorl %r9d,%r9d | 
| Alexander van Heukelum | 0bd7b79 | 2008-11-16 15:29:00 +0100 | [diff] [blame] | 1187 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1188 | # clone now | 
|  | 1189 | call do_fork | 
|  | 1190 | movq %rax,RAX(%rsp) | 
|  | 1191 | xorl %edi,%edi | 
|  | 1192 |  | 
|  | 1193 | /* | 
|  | 1194 | * It isn't worth to check for reschedule here, | 
|  | 1195 | * so internally to the x86_64 port you can rely on kernel_thread() | 
|  | 1196 | * not to reschedule the child before returning, this avoids the need | 
|  | 1197 | * of hacks for example to fork off the per-CPU idle tasks. | 
| Cyrill Gorcunov | 9f1e87e | 2008-11-27 21:10:08 +0300 | [diff] [blame] | 1198 | * [Hopefully no generic code relies on the reschedule -AK] | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1199 | */ | 
|  | 1200 | RESTORE_ALL | 
|  | 1201 | UNFAKE_STACK_FRAME | 
|  | 1202 | ret | 
|  | 1203 | CFI_ENDPROC | 
| Alexander van Heukelum | 6efdcfa | 2008-11-23 10:15:32 +0100 | [diff] [blame] | 1204 | END(kernel_thread) | 
| Alexander van Heukelum | 0bd7b79 | 2008-11-16 15:29:00 +0100 | [diff] [blame] | 1205 |  | 
| Cyrill Gorcunov | c2c631e | 2008-11-26 22:17:00 +0300 | [diff] [blame] | 1206 | ENTRY(child_rip) | 
| Andi Kleen | c05991e | 2006-08-30 19:37:08 +0200 | [diff] [blame] | 1207 | pushq $0		# fake return address | 
|  | 1208 | CFI_STARTPROC | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1209 | /* | 
|  | 1210 | * Here we are in the child and the registers are set as they were | 
|  | 1211 | * at kernel_thread() invocation in the parent. | 
|  | 1212 | */ | 
|  | 1213 | movq %rdi, %rax | 
|  | 1214 | movq %rsi, %rdi | 
|  | 1215 | call *%rax | 
|  | 1216 | # exit | 
| Andrey Mirkin | 1c5b5cf | 2007-10-17 18:04:33 +0200 | [diff] [blame] | 1217 | mov %eax, %edi | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1218 | call do_exit | 
| jia zhang | 5f5db59 | 2008-11-23 22:47:10 +0800 | [diff] [blame] | 1219 | ud2			# padding for call trace | 
| Andi Kleen | c05991e | 2006-08-30 19:37:08 +0200 | [diff] [blame] | 1220 | CFI_ENDPROC | 
| Alexander van Heukelum | 6efdcfa | 2008-11-23 10:15:32 +0100 | [diff] [blame] | 1221 | END(child_rip) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1222 |  | 
|  | 1223 | /* | 
|  | 1224 | * execve(). This function needs to use IRET, not SYSRET, to set up all state properly. | 
|  | 1225 | * | 
|  | 1226 | * C extern interface: | 
|  | 1227 | *	 extern long execve(char *name, char **argv, char **envp) | 
|  | 1228 | * | 
|  | 1229 | * asm input arguments: | 
|  | 1230 | *	rdi: name, rsi: argv, rdx: envp | 
|  | 1231 | * | 
|  | 1232 | * We want to fallback into: | 
| Ingo Molnar | 5d119b2 | 2008-02-26 12:55:57 +0100 | [diff] [blame] | 1233 | *	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] | 1234 | * | 
|  | 1235 | * do_sys_execve asm fallback arguments: | 
| Ingo Molnar | 5d119b2 | 2008-02-26 12:55:57 +0100 | [diff] [blame] | 1236 | *	rdi: name, rsi: argv, rdx: envp, rcx: fake frame on the stack | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1237 | */ | 
| Arnd Bergmann | 3db03b4 | 2006-10-02 02:18:31 -0700 | [diff] [blame] | 1238 | ENTRY(kernel_execve) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1239 | CFI_STARTPROC | 
|  | 1240 | FAKE_STACK_FRAME $0 | 
| Alexander van Heukelum | 0bd7b79 | 2008-11-16 15:29:00 +0100 | [diff] [blame] | 1241 | SAVE_ALL | 
| Ingo Molnar | 5d119b2 | 2008-02-26 12:55:57 +0100 | [diff] [blame] | 1242 | movq %rsp,%rcx | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1243 | call sys_execve | 
| Alexander van Heukelum | 0bd7b79 | 2008-11-16 15:29:00 +0100 | [diff] [blame] | 1244 | movq %rax, RAX(%rsp) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1245 | RESTORE_REST | 
|  | 1246 | testq %rax,%rax | 
|  | 1247 | je int_ret_from_sys_call | 
|  | 1248 | RESTORE_ARGS | 
|  | 1249 | UNFAKE_STACK_FRAME | 
|  | 1250 | ret | 
|  | 1251 | CFI_ENDPROC | 
| Alexander van Heukelum | 6efdcfa | 2008-11-23 10:15:32 +0100 | [diff] [blame] | 1252 | END(kernel_execve) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1253 |  | 
| Andi Kleen | 2699500 | 2006-08-02 22:37:28 +0200 | [diff] [blame] | 1254 | /* Call softirq on interrupt stack. Interrupts are off. */ | 
| Andi Kleen | ed6b676 | 2005-07-28 21:15:49 -0700 | [diff] [blame] | 1255 | ENTRY(call_softirq) | 
| Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 1256 | CFI_STARTPROC | 
| Andi Kleen | 2699500 | 2006-08-02 22:37:28 +0200 | [diff] [blame] | 1257 | push %rbp | 
|  | 1258 | CFI_ADJUST_CFA_OFFSET	8 | 
|  | 1259 | CFI_REL_OFFSET rbp,0 | 
|  | 1260 | mov  %rsp,%rbp | 
|  | 1261 | CFI_DEF_CFA_REGISTER rbp | 
| Andi Kleen | ed6b676 | 2005-07-28 21:15:49 -0700 | [diff] [blame] | 1262 | incl %gs:pda_irqcount | 
| Andi Kleen | 2699500 | 2006-08-02 22:37:28 +0200 | [diff] [blame] | 1263 | cmove %gs:pda_irqstackptr,%rsp | 
|  | 1264 | push  %rbp			# backlink for old unwinder | 
| Andi Kleen | ed6b676 | 2005-07-28 21:15:49 -0700 | [diff] [blame] | 1265 | call __do_softirq | 
| Andi Kleen | 2699500 | 2006-08-02 22:37:28 +0200 | [diff] [blame] | 1266 | leaveq | 
| Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 1267 | CFI_DEF_CFA_REGISTER	rsp | 
| Andi Kleen | 2699500 | 2006-08-02 22:37:28 +0200 | [diff] [blame] | 1268 | CFI_ADJUST_CFA_OFFSET   -8 | 
| Andi Kleen | ed6b676 | 2005-07-28 21:15:49 -0700 | [diff] [blame] | 1269 | decl %gs:pda_irqcount | 
| Andi Kleen | ed6b676 | 2005-07-28 21:15:49 -0700 | [diff] [blame] | 1270 | ret | 
| Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 1271 | CFI_ENDPROC | 
| Alexander van Heukelum | 6efdcfa | 2008-11-23 10:15:32 +0100 | [diff] [blame] | 1272 | END(call_softirq) | 
| Andi Kleen | 75154f4 | 2007-06-23 02:29:25 +0200 | [diff] [blame] | 1273 |  | 
| Jeremy Fitzhardinge | 3d75e1b | 2008-07-08 15:06:49 -0700 | [diff] [blame] | 1274 | #ifdef CONFIG_XEN | 
| Alexander van Heukelum | 322648d | 2008-11-23 10:08:28 +0100 | [diff] [blame] | 1275 | zeroentry xen_hypervisor_callback xen_do_hypervisor_callback | 
| Jeremy Fitzhardinge | 3d75e1b | 2008-07-08 15:06:49 -0700 | [diff] [blame] | 1276 |  | 
|  | 1277 | /* | 
| Cyrill Gorcunov | 9f1e87e | 2008-11-27 21:10:08 +0300 | [diff] [blame] | 1278 | * A note on the "critical region" in our callback handler. | 
|  | 1279 | * We want to avoid stacking callback handlers due to events occurring | 
|  | 1280 | * during handling of the last event. To do this, we keep events disabled | 
|  | 1281 | * until we've done all processing. HOWEVER, we must enable events before | 
|  | 1282 | * popping the stack frame (can't be done atomically) and so it would still | 
|  | 1283 | * be possible to get enough handler activations to overflow the stack. | 
|  | 1284 | * Although unlikely, bugs of that kind are hard to track down, so we'd | 
|  | 1285 | * like to avoid the possibility. | 
|  | 1286 | * So, on entry to the handler we detect whether we interrupted an | 
|  | 1287 | * existing activation in its critical region -- if so, we pop the current | 
|  | 1288 | * activation and restart the handler using the previous one. | 
|  | 1289 | */ | 
| Jeremy Fitzhardinge | 3d75e1b | 2008-07-08 15:06:49 -0700 | [diff] [blame] | 1290 | ENTRY(xen_do_hypervisor_callback)   # do_hypervisor_callback(struct *pt_regs) | 
|  | 1291 | CFI_STARTPROC | 
| Cyrill Gorcunov | 9f1e87e | 2008-11-27 21:10:08 +0300 | [diff] [blame] | 1292 | /* | 
|  | 1293 | * Since we don't modify %rdi, evtchn_do_upall(struct *pt_regs) will | 
|  | 1294 | * see the correct pointer to the pt_regs | 
|  | 1295 | */ | 
| Jeremy Fitzhardinge | 3d75e1b | 2008-07-08 15:06:49 -0700 | [diff] [blame] | 1296 | movq %rdi, %rsp            # we don't return, adjust the stack frame | 
|  | 1297 | CFI_ENDPROC | 
| Alexander van Heukelum | dcd072e | 2008-11-20 14:40:11 +0100 | [diff] [blame] | 1298 | DEFAULT_FRAME | 
| Jeremy Fitzhardinge | 3d75e1b | 2008-07-08 15:06:49 -0700 | [diff] [blame] | 1299 | 11:	incl %gs:pda_irqcount | 
|  | 1300 | movq %rsp,%rbp | 
|  | 1301 | CFI_DEF_CFA_REGISTER rbp | 
|  | 1302 | cmovzq %gs:pda_irqstackptr,%rsp | 
|  | 1303 | pushq %rbp			# backlink for old unwinder | 
|  | 1304 | call xen_evtchn_do_upcall | 
|  | 1305 | popq %rsp | 
|  | 1306 | CFI_DEF_CFA_REGISTER rsp | 
|  | 1307 | decl %gs:pda_irqcount | 
|  | 1308 | jmp  error_exit | 
|  | 1309 | CFI_ENDPROC | 
|  | 1310 | END(do_hypervisor_callback) | 
|  | 1311 |  | 
|  | 1312 | /* | 
| Cyrill Gorcunov | 9f1e87e | 2008-11-27 21:10:08 +0300 | [diff] [blame] | 1313 | * Hypervisor uses this for application faults while it executes. | 
|  | 1314 | * We get here for two reasons: | 
|  | 1315 | *  1. Fault while reloading DS, ES, FS or GS | 
|  | 1316 | *  2. Fault while executing IRET | 
|  | 1317 | * Category 1 we do not need to fix up as Xen has already reloaded all segment | 
|  | 1318 | * registers that could be reloaded and zeroed the others. | 
|  | 1319 | * Category 2 we fix up by killing the current process. We cannot use the | 
|  | 1320 | * normal Linux return path in this case because if we use the IRET hypercall | 
|  | 1321 | * to pop the stack frame we end up in an infinite loop of failsafe callbacks. | 
|  | 1322 | * We distinguish between categories by comparing each saved segment register | 
|  | 1323 | * with its current contents: any discrepancy means we in category 1. | 
|  | 1324 | */ | 
| Jeremy Fitzhardinge | 3d75e1b | 2008-07-08 15:06:49 -0700 | [diff] [blame] | 1325 | ENTRY(xen_failsafe_callback) | 
| Alexander van Heukelum | dcd072e | 2008-11-20 14:40:11 +0100 | [diff] [blame] | 1326 | INTR_FRAME 1 (6*8) | 
|  | 1327 | /*CFI_REL_OFFSET gs,GS*/ | 
|  | 1328 | /*CFI_REL_OFFSET fs,FS*/ | 
|  | 1329 | /*CFI_REL_OFFSET es,ES*/ | 
|  | 1330 | /*CFI_REL_OFFSET ds,DS*/ | 
|  | 1331 | CFI_REL_OFFSET r11,8 | 
|  | 1332 | CFI_REL_OFFSET rcx,0 | 
| Jeremy Fitzhardinge | 3d75e1b | 2008-07-08 15:06:49 -0700 | [diff] [blame] | 1333 | movw %ds,%cx | 
|  | 1334 | cmpw %cx,0x10(%rsp) | 
|  | 1335 | CFI_REMEMBER_STATE | 
|  | 1336 | jne 1f | 
|  | 1337 | movw %es,%cx | 
|  | 1338 | cmpw %cx,0x18(%rsp) | 
|  | 1339 | jne 1f | 
|  | 1340 | movw %fs,%cx | 
|  | 1341 | cmpw %cx,0x20(%rsp) | 
|  | 1342 | jne 1f | 
|  | 1343 | movw %gs,%cx | 
|  | 1344 | cmpw %cx,0x28(%rsp) | 
|  | 1345 | jne 1f | 
|  | 1346 | /* All segments match their saved values => Category 2 (Bad IRET). */ | 
|  | 1347 | movq (%rsp),%rcx | 
|  | 1348 | CFI_RESTORE rcx | 
|  | 1349 | movq 8(%rsp),%r11 | 
|  | 1350 | CFI_RESTORE r11 | 
|  | 1351 | addq $0x30,%rsp | 
|  | 1352 | CFI_ADJUST_CFA_OFFSET -0x30 | 
| Ingo Molnar | 14ae22b | 2008-11-21 15:20:47 +0100 | [diff] [blame] | 1353 | pushq_cfi $0	/* RIP */ | 
|  | 1354 | pushq_cfi %r11 | 
|  | 1355 | pushq_cfi %rcx | 
| Jeremy Fitzhardinge | 4a5c3e7 | 2008-07-08 15:07:09 -0700 | [diff] [blame] | 1356 | jmp general_protection | 
| Jeremy Fitzhardinge | 3d75e1b | 2008-07-08 15:06:49 -0700 | [diff] [blame] | 1357 | CFI_RESTORE_STATE | 
|  | 1358 | 1:	/* Segment mismatch => Category 1 (Bad segment). Retry the IRET. */ | 
|  | 1359 | movq (%rsp),%rcx | 
|  | 1360 | CFI_RESTORE rcx | 
|  | 1361 | movq 8(%rsp),%r11 | 
|  | 1362 | CFI_RESTORE r11 | 
|  | 1363 | addq $0x30,%rsp | 
|  | 1364 | CFI_ADJUST_CFA_OFFSET -0x30 | 
| Ingo Molnar | 14ae22b | 2008-11-21 15:20:47 +0100 | [diff] [blame] | 1365 | pushq_cfi $0 | 
| Jeremy Fitzhardinge | 3d75e1b | 2008-07-08 15:06:49 -0700 | [diff] [blame] | 1366 | SAVE_ALL | 
|  | 1367 | jmp error_exit | 
|  | 1368 | CFI_ENDPROC | 
| Jeremy Fitzhardinge | 3d75e1b | 2008-07-08 15:06:49 -0700 | [diff] [blame] | 1369 | END(xen_failsafe_callback) | 
|  | 1370 |  | 
|  | 1371 | #endif /* CONFIG_XEN */ | 
| Alexander van Heukelum | ddeb8f2 | 2008-11-24 13:24:28 +0100 | [diff] [blame] | 1372 |  | 
|  | 1373 | /* | 
|  | 1374 | * Some functions should be protected against kprobes | 
|  | 1375 | */ | 
|  | 1376 | .pushsection .kprobes.text, "ax" | 
|  | 1377 |  | 
|  | 1378 | paranoidzeroentry_ist debug do_debug DEBUG_STACK | 
|  | 1379 | paranoidzeroentry_ist int3 do_int3 DEBUG_STACK | 
|  | 1380 | paranoiderrorentry stack_segment do_stack_segment | 
|  | 1381 | errorentry general_protection do_general_protection | 
|  | 1382 | errorentry page_fault do_page_fault | 
|  | 1383 | #ifdef CONFIG_X86_MCE | 
|  | 1384 | paranoidzeroentry machine_check do_machine_check | 
|  | 1385 | #endif | 
|  | 1386 |  | 
|  | 1387 | /* | 
| Cyrill Gorcunov | 9f1e87e | 2008-11-27 21:10:08 +0300 | [diff] [blame] | 1388 | * "Paranoid" exit path from exception stack. | 
|  | 1389 | * Paranoid because this is used by NMIs and cannot take | 
| Alexander van Heukelum | ddeb8f2 | 2008-11-24 13:24:28 +0100 | [diff] [blame] | 1390 | * any kernel state for granted. | 
|  | 1391 | * We don't do kernel preemption checks here, because only | 
|  | 1392 | * NMI should be common and it does not enable IRQs and | 
|  | 1393 | * cannot get reschedule ticks. | 
|  | 1394 | * | 
|  | 1395 | * "trace" is 0 for the NMI handler only, because irq-tracing | 
|  | 1396 | * is fundamentally NMI-unsafe. (we cannot change the soft and | 
|  | 1397 | * hard flags at once, atomically) | 
|  | 1398 | */ | 
|  | 1399 |  | 
|  | 1400 | /* ebx:	no swapgs flag */ | 
|  | 1401 | ENTRY(paranoid_exit) | 
|  | 1402 | INTR_FRAME | 
|  | 1403 | DISABLE_INTERRUPTS(CLBR_NONE) | 
|  | 1404 | TRACE_IRQS_OFF | 
|  | 1405 | testl %ebx,%ebx				/* swapgs needed? */ | 
|  | 1406 | jnz paranoid_restore | 
|  | 1407 | testl $3,CS(%rsp) | 
|  | 1408 | jnz   paranoid_userspace | 
|  | 1409 | paranoid_swapgs: | 
|  | 1410 | TRACE_IRQS_IRETQ 0 | 
|  | 1411 | SWAPGS_UNSAFE_STACK | 
|  | 1412 | paranoid_restore: | 
|  | 1413 | RESTORE_ALL 8 | 
|  | 1414 | jmp irq_return | 
|  | 1415 | paranoid_userspace: | 
|  | 1416 | GET_THREAD_INFO(%rcx) | 
|  | 1417 | movl TI_flags(%rcx),%ebx | 
|  | 1418 | andl $_TIF_WORK_MASK,%ebx | 
|  | 1419 | jz paranoid_swapgs | 
|  | 1420 | movq %rsp,%rdi			/* &pt_regs */ | 
|  | 1421 | call sync_regs | 
|  | 1422 | movq %rax,%rsp			/* switch stack for scheduling */ | 
|  | 1423 | testl $_TIF_NEED_RESCHED,%ebx | 
|  | 1424 | jnz paranoid_schedule | 
|  | 1425 | movl %ebx,%edx			/* arg3: thread flags */ | 
|  | 1426 | TRACE_IRQS_ON | 
|  | 1427 | ENABLE_INTERRUPTS(CLBR_NONE) | 
|  | 1428 | xorl %esi,%esi 			/* arg2: oldset */ | 
|  | 1429 | movq %rsp,%rdi 			/* arg1: &pt_regs */ | 
|  | 1430 | call do_notify_resume | 
|  | 1431 | DISABLE_INTERRUPTS(CLBR_NONE) | 
|  | 1432 | TRACE_IRQS_OFF | 
|  | 1433 | jmp paranoid_userspace | 
|  | 1434 | paranoid_schedule: | 
|  | 1435 | TRACE_IRQS_ON | 
|  | 1436 | ENABLE_INTERRUPTS(CLBR_ANY) | 
|  | 1437 | call schedule | 
|  | 1438 | DISABLE_INTERRUPTS(CLBR_ANY) | 
|  | 1439 | TRACE_IRQS_OFF | 
|  | 1440 | jmp paranoid_userspace | 
|  | 1441 | CFI_ENDPROC | 
|  | 1442 | END(paranoid_exit) | 
|  | 1443 |  | 
|  | 1444 | /* | 
|  | 1445 | * Exception entry point. This expects an error code/orig_rax on the stack. | 
|  | 1446 | * returns in "no swapgs flag" in %ebx. | 
|  | 1447 | */ | 
|  | 1448 | ENTRY(error_entry) | 
|  | 1449 | XCPT_FRAME | 
|  | 1450 | CFI_ADJUST_CFA_OFFSET 15*8 | 
|  | 1451 | /* oldrax contains error code */ | 
|  | 1452 | cld | 
|  | 1453 | movq_cfi rdi, RDI+8 | 
|  | 1454 | movq_cfi rsi, RSI+8 | 
|  | 1455 | movq_cfi rdx, RDX+8 | 
|  | 1456 | movq_cfi rcx, RCX+8 | 
|  | 1457 | movq_cfi rax, RAX+8 | 
|  | 1458 | movq_cfi  r8,  R8+8 | 
|  | 1459 | movq_cfi  r9,  R9+8 | 
|  | 1460 | movq_cfi r10, R10+8 | 
|  | 1461 | movq_cfi r11, R11+8 | 
|  | 1462 | movq_cfi rbx, RBX+8 | 
|  | 1463 | movq_cfi rbp, RBP+8 | 
|  | 1464 | movq_cfi r12, R12+8 | 
|  | 1465 | movq_cfi r13, R13+8 | 
|  | 1466 | movq_cfi r14, R14+8 | 
|  | 1467 | movq_cfi r15, R15+8 | 
|  | 1468 | xorl %ebx,%ebx | 
|  | 1469 | testl $3,CS+8(%rsp) | 
|  | 1470 | je error_kernelspace | 
|  | 1471 | error_swapgs: | 
|  | 1472 | SWAPGS | 
|  | 1473 | error_sti: | 
|  | 1474 | TRACE_IRQS_OFF | 
|  | 1475 | ret | 
|  | 1476 | CFI_ENDPROC | 
|  | 1477 |  | 
|  | 1478 | /* | 
|  | 1479 | * There are two places in the kernel that can potentially fault with | 
|  | 1480 | * usergs. Handle them here. The exception handlers after iret run with | 
|  | 1481 | * kernel gs again, so don't set the user space flag. B stepping K8s | 
|  | 1482 | * sometimes report an truncated RIP for IRET exceptions returning to | 
|  | 1483 | * compat mode. Check for these here too. | 
|  | 1484 | */ | 
|  | 1485 | error_kernelspace: | 
|  | 1486 | incl %ebx | 
|  | 1487 | leaq irq_return(%rip),%rcx | 
|  | 1488 | cmpq %rcx,RIP+8(%rsp) | 
|  | 1489 | je error_swapgs | 
|  | 1490 | movl %ecx,%ecx	/* zero extend */ | 
|  | 1491 | cmpq %rcx,RIP+8(%rsp) | 
|  | 1492 | je error_swapgs | 
|  | 1493 | cmpq $gs_change,RIP+8(%rsp) | 
| Cyrill Gorcunov | 9f1e87e | 2008-11-27 21:10:08 +0300 | [diff] [blame] | 1494 | je error_swapgs | 
| Alexander van Heukelum | ddeb8f2 | 2008-11-24 13:24:28 +0100 | [diff] [blame] | 1495 | jmp error_sti | 
|  | 1496 | END(error_entry) | 
|  | 1497 |  | 
|  | 1498 |  | 
|  | 1499 | /* ebx:	no swapgs flag (1: don't need swapgs, 0: need it) */ | 
|  | 1500 | ENTRY(error_exit) | 
|  | 1501 | DEFAULT_FRAME | 
|  | 1502 | movl %ebx,%eax | 
|  | 1503 | RESTORE_REST | 
|  | 1504 | DISABLE_INTERRUPTS(CLBR_NONE) | 
|  | 1505 | TRACE_IRQS_OFF | 
|  | 1506 | GET_THREAD_INFO(%rcx) | 
|  | 1507 | testl %eax,%eax | 
|  | 1508 | jne retint_kernel | 
|  | 1509 | LOCKDEP_SYS_EXIT_IRQ | 
|  | 1510 | movl TI_flags(%rcx),%edx | 
|  | 1511 | movl $_TIF_WORK_MASK,%edi | 
|  | 1512 | andl %edi,%edx | 
|  | 1513 | jnz retint_careful | 
|  | 1514 | jmp retint_swapgs | 
|  | 1515 | CFI_ENDPROC | 
|  | 1516 | END(error_exit) | 
|  | 1517 |  | 
|  | 1518 |  | 
|  | 1519 | /* runs on exception stack */ | 
|  | 1520 | ENTRY(nmi) | 
|  | 1521 | INTR_FRAME | 
|  | 1522 | PARAVIRT_ADJUST_EXCEPTION_FRAME | 
|  | 1523 | pushq_cfi $-1 | 
|  | 1524 | subq $15*8, %rsp | 
|  | 1525 | CFI_ADJUST_CFA_OFFSET 15*8 | 
|  | 1526 | call save_paranoid | 
|  | 1527 | DEFAULT_FRAME 0 | 
|  | 1528 | /* paranoidentry do_nmi, 0; without TRACE_IRQS_OFF */ | 
|  | 1529 | movq %rsp,%rdi | 
|  | 1530 | movq $-1,%rsi | 
|  | 1531 | call do_nmi | 
|  | 1532 | #ifdef CONFIG_TRACE_IRQFLAGS | 
|  | 1533 | /* paranoidexit; without TRACE_IRQS_OFF */ | 
|  | 1534 | /* ebx:	no swapgs flag */ | 
|  | 1535 | DISABLE_INTERRUPTS(CLBR_NONE) | 
|  | 1536 | testl %ebx,%ebx				/* swapgs needed? */ | 
|  | 1537 | jnz nmi_restore | 
|  | 1538 | testl $3,CS(%rsp) | 
|  | 1539 | jnz nmi_userspace | 
|  | 1540 | nmi_swapgs: | 
|  | 1541 | SWAPGS_UNSAFE_STACK | 
|  | 1542 | nmi_restore: | 
|  | 1543 | RESTORE_ALL 8 | 
|  | 1544 | jmp irq_return | 
|  | 1545 | nmi_userspace: | 
|  | 1546 | GET_THREAD_INFO(%rcx) | 
|  | 1547 | movl TI_flags(%rcx),%ebx | 
|  | 1548 | andl $_TIF_WORK_MASK,%ebx | 
|  | 1549 | jz nmi_swapgs | 
|  | 1550 | movq %rsp,%rdi			/* &pt_regs */ | 
|  | 1551 | call sync_regs | 
|  | 1552 | movq %rax,%rsp			/* switch stack for scheduling */ | 
|  | 1553 | testl $_TIF_NEED_RESCHED,%ebx | 
|  | 1554 | jnz nmi_schedule | 
|  | 1555 | movl %ebx,%edx			/* arg3: thread flags */ | 
|  | 1556 | ENABLE_INTERRUPTS(CLBR_NONE) | 
|  | 1557 | xorl %esi,%esi 			/* arg2: oldset */ | 
|  | 1558 | movq %rsp,%rdi 			/* arg1: &pt_regs */ | 
|  | 1559 | call do_notify_resume | 
|  | 1560 | DISABLE_INTERRUPTS(CLBR_NONE) | 
|  | 1561 | jmp nmi_userspace | 
|  | 1562 | nmi_schedule: | 
|  | 1563 | ENABLE_INTERRUPTS(CLBR_ANY) | 
|  | 1564 | call schedule | 
|  | 1565 | DISABLE_INTERRUPTS(CLBR_ANY) | 
|  | 1566 | jmp nmi_userspace | 
|  | 1567 | CFI_ENDPROC | 
|  | 1568 | #else | 
|  | 1569 | jmp paranoid_exit | 
| Cyrill Gorcunov | 9f1e87e | 2008-11-27 21:10:08 +0300 | [diff] [blame] | 1570 | CFI_ENDPROC | 
| Alexander van Heukelum | ddeb8f2 | 2008-11-24 13:24:28 +0100 | [diff] [blame] | 1571 | #endif | 
|  | 1572 | END(nmi) | 
|  | 1573 |  | 
|  | 1574 | ENTRY(ignore_sysret) | 
|  | 1575 | CFI_STARTPROC | 
|  | 1576 | mov $-ENOSYS,%eax | 
|  | 1577 | sysret | 
|  | 1578 | CFI_ENDPROC | 
|  | 1579 | END(ignore_sysret) | 
|  | 1580 |  | 
|  | 1581 | /* | 
|  | 1582 | * End of kprobes section | 
|  | 1583 | */ | 
|  | 1584 | .popsection |