Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 2 | * Copyright (C) 1991,1992 Linus Torvalds |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3 | * |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 4 | * entry_32.S contains the system-call and low-level fault and trap handling routines. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5 | * |
Andy Lutomirski | 39e8701 | 2015-10-05 17:48:13 -0700 | [diff] [blame] | 6 | * Stack layout while running C code: |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 7 | * ptrace needs to have all registers on the stack. |
| 8 | * If the order here is changed, it needs to be |
| 9 | * updated in fork.c:copy_process(), signal.c:do_signal(), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | * ptrace.c and ptrace.h |
| 11 | * |
| 12 | * 0(%esp) - %ebx |
| 13 | * 4(%esp) - %ecx |
| 14 | * 8(%esp) - %edx |
Denys Vlasenko | 9b47feb | 2015-06-08 22:35:33 +0200 | [diff] [blame] | 15 | * C(%esp) - %esi |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | * 10(%esp) - %edi |
| 17 | * 14(%esp) - %ebp |
| 18 | * 18(%esp) - %eax |
| 19 | * 1C(%esp) - %ds |
| 20 | * 20(%esp) - %es |
Jeremy Fitzhardinge | 464d1a7 | 2007-02-13 13:26:20 +0100 | [diff] [blame] | 21 | * 24(%esp) - %fs |
Tejun Heo | ccbeed3 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 22 | * 28(%esp) - %gs saved iff !CONFIG_X86_32_LAZY_GS |
| 23 | * 2C(%esp) - orig_eax |
| 24 | * 30(%esp) - %eip |
| 25 | * 34(%esp) - %cs |
| 26 | * 38(%esp) - %eflags |
| 27 | * 3C(%esp) - %oldesp |
| 28 | * 40(%esp) - %oldss |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 29 | */ |
| 30 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | #include <linux/linkage.h> |
Eric Paris | d7e7528 | 2012-01-03 14:23:06 -0500 | [diff] [blame] | 32 | #include <linux/err.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | #include <asm/thread_info.h> |
Ingo Molnar | 55f327f | 2006-07-03 00:24:43 -0700 | [diff] [blame] | 34 | #include <asm/irqflags.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | #include <asm/errno.h> |
| 36 | #include <asm/segment.h> |
| 37 | #include <asm/smp.h> |
Jeremy Fitzhardinge | 0341c14 | 2009-02-13 11:14:01 -0800 | [diff] [blame] | 38 | #include <asm/page_types.h> |
Stas Sergeev | be44d2a | 2006-12-07 02:14:01 +0100 | [diff] [blame] | 39 | #include <asm/percpu.h> |
Cyrill Gorcunov | ab68ed9 | 2008-03-25 22:16:32 +0300 | [diff] [blame] | 40 | #include <asm/processor-flags.h> |
Abhishek Sagar | 395a59d | 2008-06-21 23:47:27 +0530 | [diff] [blame] | 41 | #include <asm/ftrace.h> |
Thomas Gleixner | 9b7dc56 | 2008-05-02 20:10:09 +0200 | [diff] [blame] | 42 | #include <asm/irq_vectors.h> |
Brian Gerst | 40d2e76 | 2010-03-21 09:00:43 -0400 | [diff] [blame] | 43 | #include <asm/cpufeature.h> |
Andy Lutomirski | b4ca46e | 2011-08-25 16:10:33 -0400 | [diff] [blame] | 44 | #include <asm/alternative-asm.h> |
H. Peter Anvin | 6837a54 | 2012-04-20 12:19:50 -0700 | [diff] [blame] | 45 | #include <asm/asm.h> |
H. Peter Anvin | e59d1b0 | 2012-09-21 13:58:10 -0700 | [diff] [blame] | 46 | #include <asm/smap.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | |
Jiri Olsa | ea71454 | 2011-03-07 19:10:39 +0100 | [diff] [blame] | 48 | .section .entry.text, "ax" |
| 49 | |
Rusty Russell | 139ec7c | 2006-12-07 02:14:08 +0100 | [diff] [blame] | 50 | /* |
| 51 | * We use macros for low-level operations which need to be overridden |
| 52 | * for paravirtualization. The following will never clobber any registers: |
| 53 | * INTERRUPT_RETURN (aka. "iret") |
| 54 | * GET_CR0_INTO_EAX (aka. "movl %cr0, %eax") |
Jeremy Fitzhardinge | d75cd22 | 2008-06-25 00:19:26 -0400 | [diff] [blame] | 55 | * ENABLE_INTERRUPTS_SYSEXIT (aka "sti; sysexit"). |
Rusty Russell | 139ec7c | 2006-12-07 02:14:08 +0100 | [diff] [blame] | 56 | * |
| 57 | * For DISABLE_INTERRUPTS/ENABLE_INTERRUPTS (aka "cli"/"sti"), you must |
| 58 | * specify what registers can be overwritten (CLBR_NONE, CLBR_EAX/EDX/ECX/ANY). |
| 59 | * Allowing a register to be clobbered can shrink the paravirt replacement |
| 60 | * enough to patch inline, increasing performance. |
| 61 | */ |
| 62 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | #ifdef CONFIG_PREEMPT |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 64 | # define preempt_stop(clobbers) DISABLE_INTERRUPTS(clobbers); TRACE_IRQS_OFF |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | #else |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 66 | # define preempt_stop(clobbers) |
| 67 | # define resume_kernel restore_all |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | #endif |
| 69 | |
Ingo Molnar | 55f327f | 2006-07-03 00:24:43 -0700 | [diff] [blame] | 70 | .macro TRACE_IRQS_IRET |
| 71 | #ifdef CONFIG_TRACE_IRQFLAGS |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 72 | testl $X86_EFLAGS_IF, PT_EFLAGS(%esp) # interrupts off? |
| 73 | jz 1f |
Ingo Molnar | 55f327f | 2006-07-03 00:24:43 -0700 | [diff] [blame] | 74 | TRACE_IRQS_ON |
| 75 | 1: |
| 76 | #endif |
| 77 | .endm |
| 78 | |
Tejun Heo | ccbeed3 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 79 | /* |
| 80 | * User gs save/restore |
| 81 | * |
| 82 | * %gs is used for userland TLS and kernel only uses it for stack |
| 83 | * canary which is required to be at %gs:20 by gcc. Read the comment |
| 84 | * at the top of stackprotector.h for more info. |
| 85 | * |
| 86 | * Local labels 98 and 99 are used. |
| 87 | */ |
| 88 | #ifdef CONFIG_X86_32_LAZY_GS |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 89 | |
Tejun Heo | ccbeed3 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 90 | /* unfortunately push/pop can't be no-op */ |
| 91 | .macro PUSH_GS |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 92 | pushl $0 |
Tejun Heo | ccbeed3 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 93 | .endm |
| 94 | .macro POP_GS pop=0 |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 95 | addl $(4 + \pop), %esp |
Tejun Heo | ccbeed3 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 96 | .endm |
| 97 | .macro POP_GS_EX |
| 98 | .endm |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 99 | |
Tejun Heo | ccbeed3 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 100 | /* all the rest are no-op */ |
| 101 | .macro PTGS_TO_GS |
| 102 | .endm |
| 103 | .macro PTGS_TO_GS_EX |
| 104 | .endm |
| 105 | .macro GS_TO_REG reg |
| 106 | .endm |
| 107 | .macro REG_TO_PTGS reg |
| 108 | .endm |
| 109 | .macro SET_KERNEL_GS reg |
| 110 | .endm |
| 111 | |
| 112 | #else /* CONFIG_X86_32_LAZY_GS */ |
| 113 | |
| 114 | .macro PUSH_GS |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 115 | pushl %gs |
Tejun Heo | ccbeed3 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 116 | .endm |
| 117 | |
| 118 | .macro POP_GS pop=0 |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 119 | 98: popl %gs |
Tejun Heo | ccbeed3 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 120 | .if \pop <> 0 |
Denys Vlasenko | 9b47feb | 2015-06-08 22:35:33 +0200 | [diff] [blame] | 121 | add $\pop, %esp |
Tejun Heo | ccbeed3 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 122 | .endif |
| 123 | .endm |
| 124 | .macro POP_GS_EX |
| 125 | .pushsection .fixup, "ax" |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 126 | 99: movl $0, (%esp) |
| 127 | jmp 98b |
Jeremy Fitzhardinge | f95d47c | 2006-12-07 02:14:02 +0100 | [diff] [blame] | 128 | .popsection |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 129 | _ASM_EXTABLE(98b, 99b) |
Tejun Heo | ccbeed3 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 130 | .endm |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 131 | |
Tejun Heo | ccbeed3 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 132 | .macro PTGS_TO_GS |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 133 | 98: mov PT_GS(%esp), %gs |
Tejun Heo | ccbeed3 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 134 | .endm |
| 135 | .macro PTGS_TO_GS_EX |
| 136 | .pushsection .fixup, "ax" |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 137 | 99: movl $0, PT_GS(%esp) |
| 138 | jmp 98b |
Tejun Heo | ccbeed3 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 139 | .popsection |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 140 | _ASM_EXTABLE(98b, 99b) |
Tejun Heo | ccbeed3 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 141 | .endm |
| 142 | |
| 143 | .macro GS_TO_REG reg |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 144 | movl %gs, \reg |
Tejun Heo | ccbeed3 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 145 | .endm |
| 146 | .macro REG_TO_PTGS reg |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 147 | movl \reg, PT_GS(%esp) |
Tejun Heo | ccbeed3 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 148 | .endm |
| 149 | .macro SET_KERNEL_GS reg |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 150 | movl $(__KERNEL_STACK_CANARY), \reg |
| 151 | movl \reg, %gs |
Tejun Heo | ccbeed3 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 152 | .endm |
| 153 | |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 154 | #endif /* CONFIG_X86_32_LAZY_GS */ |
Tejun Heo | ccbeed3 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 155 | |
Andy Lutomirski | 150ac78 | 2015-10-05 17:48:14 -0700 | [diff] [blame] | 156 | .macro SAVE_ALL pt_regs_ax=%eax |
Tejun Heo | f0d9611 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 157 | cld |
Tejun Heo | ccbeed3 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 158 | PUSH_GS |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 159 | pushl %fs |
| 160 | pushl %es |
| 161 | pushl %ds |
Andy Lutomirski | 150ac78 | 2015-10-05 17:48:14 -0700 | [diff] [blame] | 162 | pushl \pt_regs_ax |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 163 | pushl %ebp |
| 164 | pushl %edi |
| 165 | pushl %esi |
| 166 | pushl %edx |
| 167 | pushl %ecx |
| 168 | pushl %ebx |
| 169 | movl $(__USER_DS), %edx |
| 170 | movl %edx, %ds |
| 171 | movl %edx, %es |
| 172 | movl $(__KERNEL_PERCPU), %edx |
| 173 | movl %edx, %fs |
Tejun Heo | ccbeed3 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 174 | SET_KERNEL_GS %edx |
Tejun Heo | f0d9611 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 175 | .endm |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 176 | |
Tejun Heo | f0d9611 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 177 | .macro RESTORE_INT_REGS |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 178 | popl %ebx |
| 179 | popl %ecx |
| 180 | popl %edx |
| 181 | popl %esi |
| 182 | popl %edi |
| 183 | popl %ebp |
| 184 | popl %eax |
Tejun Heo | f0d9611 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 185 | .endm |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 186 | |
Tejun Heo | ccbeed3 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 187 | .macro RESTORE_REGS pop=0 |
Tejun Heo | f0d9611 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 188 | RESTORE_INT_REGS |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 189 | 1: popl %ds |
| 190 | 2: popl %es |
| 191 | 3: popl %fs |
Tejun Heo | ccbeed3 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 192 | POP_GS \pop |
Tejun Heo | f0d9611 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 193 | .pushsection .fixup, "ax" |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 194 | 4: movl $0, (%esp) |
| 195 | jmp 1b |
| 196 | 5: movl $0, (%esp) |
| 197 | jmp 2b |
| 198 | 6: movl $0, (%esp) |
| 199 | jmp 3b |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 200 | .popsection |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 201 | _ASM_EXTABLE(1b, 4b) |
| 202 | _ASM_EXTABLE(2b, 5b) |
| 203 | _ASM_EXTABLE(3b, 6b) |
Tejun Heo | ccbeed3 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 204 | POP_GS_EX |
Tejun Heo | f0d9611 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 205 | .endm |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 206 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 207 | ENTRY(ret_from_fork) |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 208 | pushl %eax |
| 209 | call schedule_tail |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 210 | GET_THREAD_INFO(%ebp) |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 211 | popl %eax |
| 212 | pushl $0x0202 # Reset kernel eflags |
Ingo Molnar | 131484c | 2015-05-28 12:21:47 +0200 | [diff] [blame] | 213 | popfl |
Andy Lutomirski | 39e8701 | 2015-10-05 17:48:13 -0700 | [diff] [blame] | 214 | |
| 215 | /* When we fork, we trace the syscall return in the child, too. */ |
| 216 | movl %esp, %eax |
| 217 | call syscall_return_slowpath |
| 218 | jmp restore_all |
Jan Beulich | 47a55cd | 2007-02-13 13:26:24 +0100 | [diff] [blame] | 219 | END(ret_from_fork) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 220 | |
Al Viro | 22e2430d | 2012-10-10 21:35:42 -0400 | [diff] [blame] | 221 | ENTRY(ret_from_kernel_thread) |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 222 | pushl %eax |
| 223 | call schedule_tail |
Al Viro | 6783eaa | 2012-08-02 23:05:11 +0400 | [diff] [blame] | 224 | GET_THREAD_INFO(%ebp) |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 225 | popl %eax |
| 226 | pushl $0x0202 # Reset kernel eflags |
Ingo Molnar | 131484c | 2015-05-28 12:21:47 +0200 | [diff] [blame] | 227 | popfl |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 228 | movl PT_EBP(%esp), %eax |
| 229 | call *PT_EBX(%esp) |
| 230 | movl $0, PT_EAX(%esp) |
Andy Lutomirski | 39e8701 | 2015-10-05 17:48:13 -0700 | [diff] [blame] | 231 | |
| 232 | /* |
| 233 | * Kernel threads return to userspace as if returning from a syscall. |
| 234 | * We should check whether anything actually uses this path and, if so, |
| 235 | * consider switching it over to ret_from_fork. |
| 236 | */ |
| 237 | movl %esp, %eax |
| 238 | call syscall_return_slowpath |
| 239 | jmp restore_all |
Al Viro | 22e2430d | 2012-10-10 21:35:42 -0400 | [diff] [blame] | 240 | ENDPROC(ret_from_kernel_thread) |
Al Viro | 6783eaa | 2012-08-02 23:05:11 +0400 | [diff] [blame] | 241 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 242 | /* |
| 243 | * Return to user mode is not as complex as all this looks, |
| 244 | * but we want the default path for a system call return to |
| 245 | * go as quickly as possible which is why some of this is |
| 246 | * less clear than it otherwise should be. |
| 247 | */ |
| 248 | |
| 249 | # userspace resumption stub bypassing syscall exit tracing |
| 250 | ALIGN |
| 251 | ret_from_exception: |
Rusty Russell | 139ec7c | 2006-12-07 02:14:08 +0100 | [diff] [blame] | 252 | preempt_stop(CLBR_ANY) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 253 | ret_from_intr: |
| 254 | GET_THREAD_INFO(%ebp) |
Dmitry Adamushko | 29a2e28 | 2012-03-22 21:39:25 +0100 | [diff] [blame] | 255 | #ifdef CONFIG_VM86 |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 256 | movl PT_EFLAGS(%esp), %eax # mix EFLAGS and CS |
| 257 | movb PT_CS(%esp), %al |
| 258 | andl $(X86_EFLAGS_VM | SEGMENT_RPL_MASK), %eax |
Dmitry Adamushko | 29a2e28 | 2012-03-22 21:39:25 +0100 | [diff] [blame] | 259 | #else |
| 260 | /* |
Al Viro | 6783eaa | 2012-08-02 23:05:11 +0400 | [diff] [blame] | 261 | * We can be coming here from child spawned by kernel_thread(). |
Dmitry Adamushko | 29a2e28 | 2012-03-22 21:39:25 +0100 | [diff] [blame] | 262 | */ |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 263 | movl PT_CS(%esp), %eax |
| 264 | andl $SEGMENT_RPL_MASK, %eax |
Dmitry Adamushko | 29a2e28 | 2012-03-22 21:39:25 +0100 | [diff] [blame] | 265 | #endif |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 266 | cmpl $USER_RPL, %eax |
| 267 | jb resume_kernel # not returning to v8086 or userspace |
Jeremy Fitzhardinge | f95d47c | 2006-12-07 02:14:02 +0100 | [diff] [blame] | 268 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 269 | ENTRY(resume_userspace) |
Andy Lutomirski | 5d73fc7 | 2015-07-31 14:41:09 -0700 | [diff] [blame] | 270 | DISABLE_INTERRUPTS(CLBR_ANY) |
Peter Zijlstra | e32e58a | 2008-06-06 10:14:08 +0200 | [diff] [blame] | 271 | TRACE_IRQS_OFF |
Andy Lutomirski | 5d73fc7 | 2015-07-31 14:41:09 -0700 | [diff] [blame] | 272 | movl %esp, %eax |
| 273 | call prepare_exit_to_usermode |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 274 | jmp restore_all |
Jan Beulich | 47a55cd | 2007-02-13 13:26:24 +0100 | [diff] [blame] | 275 | END(ret_from_exception) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 276 | |
| 277 | #ifdef CONFIG_PREEMPT |
| 278 | ENTRY(resume_kernel) |
Rusty Russell | 139ec7c | 2006-12-07 02:14:08 +0100 | [diff] [blame] | 279 | DISABLE_INTERRUPTS(CLBR_ANY) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 280 | need_resched: |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 281 | cmpl $0, PER_CPU_VAR(__preempt_count) |
| 282 | jnz restore_all |
| 283 | testl $X86_EFLAGS_IF, PT_EFLAGS(%esp) # interrupts off (exception path) ? |
| 284 | jz restore_all |
| 285 | call preempt_schedule_irq |
| 286 | jmp need_resched |
Jan Beulich | 47a55cd | 2007-02-13 13:26:24 +0100 | [diff] [blame] | 287 | END(resume_kernel) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 288 | #endif |
| 289 | |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 290 | # SYSENTER call handler stub |
Ingo Molnar | 4c8cd0c | 2015-06-08 08:33:56 +0200 | [diff] [blame] | 291 | ENTRY(entry_SYSENTER_32) |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 292 | movl TSS_sysenter_sp0(%esp), %esp |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 293 | sysenter_past_esp: |
Andy Lutomirski | 5f310f7 | 2015-10-05 17:48:15 -0700 | [diff] [blame] | 294 | pushl $__USER_DS /* pt_regs->ss */ |
Andy Lutomirski | 30bfa7b | 2015-12-16 23:18:48 -0800 | [diff] [blame] | 295 | pushl %ebp /* pt_regs->sp (stashed in bp) */ |
Andy Lutomirski | 5f310f7 | 2015-10-05 17:48:15 -0700 | [diff] [blame] | 296 | pushfl /* pt_regs->flags (except IF = 0) */ |
| 297 | orl $X86_EFLAGS_IF, (%esp) /* Fix IF */ |
| 298 | pushl $__USER_CS /* pt_regs->cs */ |
| 299 | pushl $0 /* pt_regs->ip = 0 (placeholder) */ |
| 300 | pushl %eax /* pt_regs->orig_ax */ |
| 301 | SAVE_ALL pt_regs_ax=$-ENOSYS /* save rest */ |
| 302 | |
Ingo Molnar | 55f327f | 2006-07-03 00:24:43 -0700 | [diff] [blame] | 303 | /* |
Andy Lutomirski | 5f310f7 | 2015-10-05 17:48:15 -0700 | [diff] [blame] | 304 | * User mode is traced as though IRQs are on, and SYSENTER |
| 305 | * turned them off. |
Ingo Molnar | 55f327f | 2006-07-03 00:24:43 -0700 | [diff] [blame] | 306 | */ |
Ingo Molnar | 55f327f | 2006-07-03 00:24:43 -0700 | [diff] [blame] | 307 | TRACE_IRQS_OFF |
Andy Lutomirski | 5f310f7 | 2015-10-05 17:48:15 -0700 | [diff] [blame] | 308 | |
| 309 | movl %esp, %eax |
| 310 | call do_fast_syscall_32 |
Boris Ostrovsky | 91e2eea | 2015-11-19 16:55:45 -0500 | [diff] [blame] | 311 | /* XEN PV guests always use IRET path */ |
| 312 | ALTERNATIVE "testl %eax, %eax; jz .Lsyscall_32_done", \ |
| 313 | "jmp .Lsyscall_32_done", X86_FEATURE_XENPV |
Andy Lutomirski | 5f310f7 | 2015-10-05 17:48:15 -0700 | [diff] [blame] | 314 | |
| 315 | /* Opportunistic SYSEXIT */ |
| 316 | TRACE_IRQS_ON /* User mode traces as IRQs on. */ |
| 317 | movl PT_EIP(%esp), %edx /* pt_regs->ip */ |
| 318 | movl PT_OLDESP(%esp), %ecx /* pt_regs->sp */ |
Andy Lutomirski | 3bd2951 | 2015-10-16 15:42:55 -0700 | [diff] [blame] | 319 | 1: mov PT_FS(%esp), %fs |
| 320 | PTGS_TO_GS |
Andy Lutomirski | 5f310f7 | 2015-10-05 17:48:15 -0700 | [diff] [blame] | 321 | popl %ebx /* pt_regs->bx */ |
| 322 | addl $2*4, %esp /* skip pt_regs->cx and pt_regs->dx */ |
| 323 | popl %esi /* pt_regs->si */ |
| 324 | popl %edi /* pt_regs->di */ |
| 325 | popl %ebp /* pt_regs->bp */ |
| 326 | popl %eax /* pt_regs->ax */ |
Andy Lutomirski | 5f310f7 | 2015-10-05 17:48:15 -0700 | [diff] [blame] | 327 | |
| 328 | /* |
| 329 | * Return back to the vDSO, which will pop ecx and edx. |
| 330 | * Don't bother with DS and ES (they already contain __USER_DS). |
| 331 | */ |
Boris Ostrovsky | 88c15ec | 2015-11-19 16:55:46 -0500 | [diff] [blame] | 332 | sti |
| 333 | sysexit |
Roland McGrath | af0575b | 2008-06-24 04:16:52 -0700 | [diff] [blame] | 334 | |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 335 | .pushsection .fixup, "ax" |
| 336 | 2: movl $0, PT_FS(%esp) |
| 337 | jmp 1b |
Jeremy Fitzhardinge | f95d47c | 2006-12-07 02:14:02 +0100 | [diff] [blame] | 338 | .popsection |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 339 | _ASM_EXTABLE(1b, 2b) |
Tejun Heo | ccbeed3 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 340 | PTGS_TO_GS_EX |
Ingo Molnar | 4c8cd0c | 2015-06-08 08:33:56 +0200 | [diff] [blame] | 341 | ENDPROC(entry_SYSENTER_32) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 342 | |
| 343 | # system call handler stub |
Ingo Molnar | b2502b4 | 2015-06-08 08:42:03 +0200 | [diff] [blame] | 344 | ENTRY(entry_INT80_32) |
H. Peter Anvin | e59d1b0 | 2012-09-21 13:58:10 -0700 | [diff] [blame] | 345 | ASM_CLAC |
Andy Lutomirski | 150ac78 | 2015-10-05 17:48:14 -0700 | [diff] [blame] | 346 | pushl %eax /* pt_regs->orig_ax */ |
Andy Lutomirski | 5f310f7 | 2015-10-05 17:48:15 -0700 | [diff] [blame] | 347 | SAVE_ALL pt_regs_ax=$-ENOSYS /* save rest */ |
Andy Lutomirski | 150ac78 | 2015-10-05 17:48:14 -0700 | [diff] [blame] | 348 | |
| 349 | /* |
Andy Lutomirski | 657c1ee | 2015-10-16 15:42:54 -0700 | [diff] [blame] | 350 | * User mode is traced as though IRQs are on. Unlike the 64-bit |
| 351 | * case, INT80 is a trap gate on 32-bit kernels, so interrupts |
| 352 | * are already on (unless user code is messing around with iopl). |
Andy Lutomirski | 150ac78 | 2015-10-05 17:48:14 -0700 | [diff] [blame] | 353 | */ |
Andy Lutomirski | 150ac78 | 2015-10-05 17:48:14 -0700 | [diff] [blame] | 354 | |
| 355 | movl %esp, %eax |
Andy Lutomirski | 657c1ee | 2015-10-16 15:42:54 -0700 | [diff] [blame] | 356 | call do_syscall_32_irqs_on |
Andy Lutomirski | 5f310f7 | 2015-10-05 17:48:15 -0700 | [diff] [blame] | 357 | .Lsyscall_32_done: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 358 | |
| 359 | restore_all: |
Alexander van Heukelum | 2e04bc7 | 2009-06-18 00:35:57 +0200 | [diff] [blame] | 360 | TRACE_IRQS_IRET |
| 361 | restore_all_notrace: |
H. Peter Anvin | 34273f4 | 2014-05-04 10:36:22 -0700 | [diff] [blame] | 362 | #ifdef CONFIG_X86_ESPFIX32 |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 363 | movl PT_EFLAGS(%esp), %eax # mix EFLAGS, SS and CS |
| 364 | /* |
| 365 | * Warning: PT_OLDSS(%esp) contains the wrong/random values if we |
| 366 | * are returning to the kernel. |
| 367 | * See comments in process.c:copy_thread() for details. |
| 368 | */ |
| 369 | movb PT_OLDSS(%esp), %ah |
| 370 | movb PT_CS(%esp), %al |
| 371 | andl $(X86_EFLAGS_VM | (SEGMENT_TI_MASK << 8) | SEGMENT_RPL_MASK), %eax |
| 372 | cmpl $((SEGMENT_LDT << 8) | USER_RPL), %eax |
| 373 | je ldt_ss # returning to user-space with LDT SS |
H. Peter Anvin | 34273f4 | 2014-05-04 10:36:22 -0700 | [diff] [blame] | 374 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 375 | restore_nocheck: |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 376 | RESTORE_REGS 4 # skip orig_eax/error_code |
Adrian Bunk | f7f3d79 | 2008-02-13 23:29:53 +0200 | [diff] [blame] | 377 | irq_return: |
Ingo Molnar | 3701d863 | 2008-02-09 23:24:08 +0100 | [diff] [blame] | 378 | INTERRUPT_RETURN |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 379 | .section .fixup, "ax" |
| 380 | ENTRY(iret_exc ) |
| 381 | pushl $0 # no error code |
| 382 | pushl $do_iret_error |
| 383 | jmp error_code |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 384 | .previous |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 385 | _ASM_EXTABLE(irq_return, iret_exc) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 386 | |
H. Peter Anvin | 34273f4 | 2014-05-04 10:36:22 -0700 | [diff] [blame] | 387 | #ifdef CONFIG_X86_ESPFIX32 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 388 | ldt_ss: |
Rusty Russell | d3561b7 | 2006-12-07 02:14:07 +0100 | [diff] [blame] | 389 | #ifdef CONFIG_PARAVIRT |
| 390 | /* |
| 391 | * The kernel can't run on a non-flat stack if paravirt mode |
| 392 | * is active. Rather than try to fixup the high bits of |
| 393 | * ESP, bypass this code entirely. This may break DOSemu |
| 394 | * and/or Wine support in a paravirt VM, although the option |
| 395 | * is still available to implement the setting of the high |
| 396 | * 16-bits in the INTERRUPT_RETURN paravirt-op. |
| 397 | */ |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 398 | cmpl $0, pv_info+PARAVIRT_enabled |
| 399 | jne restore_nocheck |
Rusty Russell | d3561b7 | 2006-12-07 02:14:07 +0100 | [diff] [blame] | 400 | #endif |
| 401 | |
Alexander van Heukelum | dc4c2a0 | 2009-06-18 00:35:58 +0200 | [diff] [blame] | 402 | /* |
| 403 | * Setup and switch to ESPFIX stack |
| 404 | * |
| 405 | * We're returning to userspace with a 16 bit stack. The CPU will not |
| 406 | * restore the high word of ESP for us on executing iret... This is an |
| 407 | * "official" bug of all the x86-compatible CPUs, which we can work |
| 408 | * around to make dosemu and wine happy. We do this by preloading the |
| 409 | * high word of ESP with the high word of the userspace ESP while |
| 410 | * compensating for the offset by changing to the ESPFIX segment with |
| 411 | * a base address that matches for the difference. |
| 412 | */ |
Brian Gerst | 72c511d | 2010-07-31 12:48:23 -0400 | [diff] [blame] | 413 | #define GDT_ESPFIX_SS PER_CPU_VAR(gdt_page) + (GDT_ENTRY_ESPFIX_SS * 8) |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 414 | mov %esp, %edx /* load kernel esp */ |
| 415 | mov PT_OLDESP(%esp), %eax /* load userspace esp */ |
| 416 | mov %dx, %ax /* eax: new kernel esp */ |
Denys Vlasenko | 9b47feb | 2015-06-08 22:35:33 +0200 | [diff] [blame] | 417 | sub %eax, %edx /* offset (low word is 0) */ |
| 418 | shr $16, %edx |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 419 | mov %dl, GDT_ESPFIX_SS + 4 /* bits 16..23 */ |
| 420 | mov %dh, GDT_ESPFIX_SS + 7 /* bits 24..31 */ |
| 421 | pushl $__ESPFIX_SS |
| 422 | pushl %eax /* new kernel esp */ |
| 423 | /* |
| 424 | * Disable interrupts, but do not irqtrace this section: we |
Alexander van Heukelum | 2e04bc7 | 2009-06-18 00:35:57 +0200 | [diff] [blame] | 425 | * will soon execute iret and the tracer was already set to |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 426 | * the irqstate after the IRET: |
| 427 | */ |
Rusty Russell | 139ec7c | 2006-12-07 02:14:08 +0100 | [diff] [blame] | 428 | DISABLE_INTERRUPTS(CLBR_EAX) |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 429 | lss (%esp), %esp /* switch to espfix segment */ |
| 430 | jmp restore_nocheck |
H. Peter Anvin | 34273f4 | 2014-05-04 10:36:22 -0700 | [diff] [blame] | 431 | #endif |
Ingo Molnar | b2502b4 | 2015-06-08 08:42:03 +0200 | [diff] [blame] | 432 | ENDPROC(entry_INT80_32) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 433 | |
Tejun Heo | f0d9611 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 434 | .macro FIXUP_ESPFIX_STACK |
Alexander van Heukelum | dc4c2a0 | 2009-06-18 00:35:58 +0200 | [diff] [blame] | 435 | /* |
| 436 | * Switch back for ESPFIX stack to the normal zerobased stack |
| 437 | * |
| 438 | * We can't call C functions using the ESPFIX stack. This code reads |
| 439 | * the high word of the segment base from the GDT and swiches to the |
| 440 | * normal stack and adjusts ESP with the matching offset. |
| 441 | */ |
H. Peter Anvin | 34273f4 | 2014-05-04 10:36:22 -0700 | [diff] [blame] | 442 | #ifdef CONFIG_X86_ESPFIX32 |
Alexander van Heukelum | dc4c2a0 | 2009-06-18 00:35:58 +0200 | [diff] [blame] | 443 | /* fixup the stack */ |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 444 | mov GDT_ESPFIX_SS + 4, %al /* bits 16..23 */ |
| 445 | mov GDT_ESPFIX_SS + 7, %ah /* bits 24..31 */ |
Denys Vlasenko | 9b47feb | 2015-06-08 22:35:33 +0200 | [diff] [blame] | 446 | shl $16, %eax |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 447 | addl %esp, %eax /* the adjusted stack pointer */ |
| 448 | pushl $__KERNEL_DS |
| 449 | pushl %eax |
| 450 | lss (%esp), %esp /* switch to the normal stack segment */ |
H. Peter Anvin | 34273f4 | 2014-05-04 10:36:22 -0700 | [diff] [blame] | 451 | #endif |
Tejun Heo | f0d9611 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 452 | .endm |
| 453 | .macro UNWIND_ESPFIX_STACK |
H. Peter Anvin | 34273f4 | 2014-05-04 10:36:22 -0700 | [diff] [blame] | 454 | #ifdef CONFIG_X86_ESPFIX32 |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 455 | movl %ss, %eax |
Tejun Heo | f0d9611 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 456 | /* see if on espfix stack */ |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 457 | cmpw $__ESPFIX_SS, %ax |
| 458 | jne 27f |
| 459 | movl $__KERNEL_DS, %eax |
| 460 | movl %eax, %ds |
| 461 | movl %eax, %es |
Tejun Heo | f0d9611 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 462 | /* switch to normal stack */ |
| 463 | FIXUP_ESPFIX_STACK |
| 464 | 27: |
H. Peter Anvin | 34273f4 | 2014-05-04 10:36:22 -0700 | [diff] [blame] | 465 | #endif |
Tejun Heo | f0d9611 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 466 | .endm |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 467 | |
| 468 | /* |
Denys Vlasenko | 3304c9c | 2015-04-03 21:49:13 +0200 | [diff] [blame] | 469 | * Build the entry stubs with some assembler magic. |
| 470 | * We pack 1 stub into every 8-byte block. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 471 | */ |
Denys Vlasenko | 3304c9c | 2015-04-03 21:49:13 +0200 | [diff] [blame] | 472 | .align 8 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 473 | ENTRY(irq_entries_start) |
Denys Vlasenko | 3304c9c | 2015-04-03 21:49:13 +0200 | [diff] [blame] | 474 | vector=FIRST_EXTERNAL_VECTOR |
| 475 | .rept (FIRST_SYSTEM_VECTOR - FIRST_EXTERNAL_VECTOR) |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 476 | pushl $(~vector+0x80) /* Note: always in signed byte range */ |
Denys Vlasenko | 3304c9c | 2015-04-03 21:49:13 +0200 | [diff] [blame] | 477 | vector=vector+1 |
| 478 | jmp common_interrupt |
Denys Vlasenko | 3304c9c | 2015-04-03 21:49:13 +0200 | [diff] [blame] | 479 | .align 8 |
| 480 | .endr |
Jan Beulich | 47a55cd | 2007-02-13 13:26:24 +0100 | [diff] [blame] | 481 | END(irq_entries_start) |
| 482 | |
Ingo Molnar | 55f327f | 2006-07-03 00:24:43 -0700 | [diff] [blame] | 483 | /* |
| 484 | * the CPU automatically disables interrupts when executing an IRQ vector, |
| 485 | * so IRQ-flags tracing has to follow that: |
| 486 | */ |
H. Peter Anvin | b7c6244 | 2008-11-11 13:24:58 -0800 | [diff] [blame] | 487 | .p2align CONFIG_X86_L1_CACHE_SHIFT |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 488 | common_interrupt: |
H. Peter Anvin | e59d1b0 | 2012-09-21 13:58:10 -0700 | [diff] [blame] | 489 | ASM_CLAC |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 490 | addl $-0x80, (%esp) /* Adjust vector into the [-256, -1] range */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 491 | SAVE_ALL |
Ingo Molnar | 55f327f | 2006-07-03 00:24:43 -0700 | [diff] [blame] | 492 | TRACE_IRQS_OFF |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 493 | movl %esp, %eax |
| 494 | call do_IRQ |
| 495 | jmp ret_from_intr |
Jan Beulich | 47a55cd | 2007-02-13 13:26:24 +0100 | [diff] [blame] | 496 | ENDPROC(common_interrupt) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 497 | |
Tejun Heo | 02cf94c | 2009-01-21 17:26:06 +0900 | [diff] [blame] | 498 | #define BUILD_INTERRUPT3(name, nr, fn) \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 499 | ENTRY(name) \ |
H. Peter Anvin | e59d1b0 | 2012-09-21 13:58:10 -0700 | [diff] [blame] | 500 | ASM_CLAC; \ |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 501 | pushl $~(nr); \ |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 502 | SAVE_ALL; \ |
Ingo Molnar | 55f327f | 2006-07-03 00:24:43 -0700 | [diff] [blame] | 503 | TRACE_IRQS_OFF \ |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 504 | movl %esp, %eax; \ |
| 505 | call fn; \ |
| 506 | jmp ret_from_intr; \ |
Jan Beulich | 47a55cd | 2007-02-13 13:26:24 +0100 | [diff] [blame] | 507 | ENDPROC(name) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 508 | |
Seiji Aguchi | cf910e8 | 2013-06-20 11:46:53 -0400 | [diff] [blame] | 509 | |
| 510 | #ifdef CONFIG_TRACING |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 511 | # define TRACE_BUILD_INTERRUPT(name, nr) BUILD_INTERRUPT3(trace_##name, nr, smp_trace_##name) |
Seiji Aguchi | cf910e8 | 2013-06-20 11:46:53 -0400 | [diff] [blame] | 512 | #else |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 513 | # define TRACE_BUILD_INTERRUPT(name, nr) |
Seiji Aguchi | cf910e8 | 2013-06-20 11:46:53 -0400 | [diff] [blame] | 514 | #endif |
| 515 | |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 516 | #define BUILD_INTERRUPT(name, nr) \ |
| 517 | BUILD_INTERRUPT3(name, nr, smp_##name); \ |
Seiji Aguchi | cf910e8 | 2013-06-20 11:46:53 -0400 | [diff] [blame] | 518 | TRACE_BUILD_INTERRUPT(name, nr) |
Tejun Heo | 02cf94c | 2009-01-21 17:26:06 +0900 | [diff] [blame] | 519 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 520 | /* The include is where all of the SMP etc. interrupts come from */ |
Ingo Molnar | 1164dd0 | 2009-01-28 19:34:09 +0100 | [diff] [blame] | 521 | #include <asm/entry_arch.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 522 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 523 | ENTRY(coprocessor_error) |
H. Peter Anvin | e59d1b0 | 2012-09-21 13:58:10 -0700 | [diff] [blame] | 524 | ASM_CLAC |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 525 | pushl $0 |
| 526 | pushl $do_coprocessor_error |
| 527 | jmp error_code |
Jan Beulich | 47a55cd | 2007-02-13 13:26:24 +0100 | [diff] [blame] | 528 | END(coprocessor_error) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 529 | |
| 530 | ENTRY(simd_coprocessor_error) |
H. Peter Anvin | e59d1b0 | 2012-09-21 13:58:10 -0700 | [diff] [blame] | 531 | ASM_CLAC |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 532 | pushl $0 |
Brian Gerst | 40d2e76 | 2010-03-21 09:00:43 -0400 | [diff] [blame] | 533 | #ifdef CONFIG_X86_INVD_BUG |
| 534 | /* AMD 486 bug: invd from userspace calls exception 19 instead of #GP */ |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 535 | ALTERNATIVE "pushl $do_general_protection", \ |
| 536 | "pushl $do_simd_coprocessor_error", \ |
Borislav Petkov | 8e65f6e | 2015-01-18 12:35:55 +0100 | [diff] [blame] | 537 | X86_FEATURE_XMM |
Brian Gerst | 40d2e76 | 2010-03-21 09:00:43 -0400 | [diff] [blame] | 538 | #else |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 539 | pushl $do_simd_coprocessor_error |
Brian Gerst | 40d2e76 | 2010-03-21 09:00:43 -0400 | [diff] [blame] | 540 | #endif |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 541 | jmp error_code |
Jan Beulich | 47a55cd | 2007-02-13 13:26:24 +0100 | [diff] [blame] | 542 | END(simd_coprocessor_error) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 543 | |
| 544 | ENTRY(device_not_available) |
H. Peter Anvin | e59d1b0 | 2012-09-21 13:58:10 -0700 | [diff] [blame] | 545 | ASM_CLAC |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 546 | pushl $-1 # mark this as an int |
| 547 | pushl $do_device_not_available |
| 548 | jmp error_code |
Jan Beulich | 47a55cd | 2007-02-13 13:26:24 +0100 | [diff] [blame] | 549 | END(device_not_available) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 550 | |
Rusty Russell | d3561b7 | 2006-12-07 02:14:07 +0100 | [diff] [blame] | 551 | #ifdef CONFIG_PARAVIRT |
| 552 | ENTRY(native_iret) |
Ingo Molnar | 3701d863 | 2008-02-09 23:24:08 +0100 | [diff] [blame] | 553 | iret |
H. Peter Anvin | 6837a54 | 2012-04-20 12:19:50 -0700 | [diff] [blame] | 554 | _ASM_EXTABLE(native_iret, iret_exc) |
Jan Beulich | 47a55cd | 2007-02-13 13:26:24 +0100 | [diff] [blame] | 555 | END(native_iret) |
Rusty Russell | d3561b7 | 2006-12-07 02:14:07 +0100 | [diff] [blame] | 556 | #endif |
| 557 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 558 | ENTRY(overflow) |
H. Peter Anvin | e59d1b0 | 2012-09-21 13:58:10 -0700 | [diff] [blame] | 559 | ASM_CLAC |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 560 | pushl $0 |
| 561 | pushl $do_overflow |
| 562 | jmp error_code |
Jan Beulich | 47a55cd | 2007-02-13 13:26:24 +0100 | [diff] [blame] | 563 | END(overflow) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 564 | |
| 565 | ENTRY(bounds) |
H. Peter Anvin | e59d1b0 | 2012-09-21 13:58:10 -0700 | [diff] [blame] | 566 | ASM_CLAC |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 567 | pushl $0 |
| 568 | pushl $do_bounds |
| 569 | jmp error_code |
Jan Beulich | 47a55cd | 2007-02-13 13:26:24 +0100 | [diff] [blame] | 570 | END(bounds) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 571 | |
| 572 | ENTRY(invalid_op) |
H. Peter Anvin | e59d1b0 | 2012-09-21 13:58:10 -0700 | [diff] [blame] | 573 | ASM_CLAC |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 574 | pushl $0 |
| 575 | pushl $do_invalid_op |
| 576 | jmp error_code |
Jan Beulich | 47a55cd | 2007-02-13 13:26:24 +0100 | [diff] [blame] | 577 | END(invalid_op) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 578 | |
| 579 | ENTRY(coprocessor_segment_overrun) |
H. Peter Anvin | e59d1b0 | 2012-09-21 13:58:10 -0700 | [diff] [blame] | 580 | ASM_CLAC |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 581 | pushl $0 |
| 582 | pushl $do_coprocessor_segment_overrun |
| 583 | jmp error_code |
Jan Beulich | 47a55cd | 2007-02-13 13:26:24 +0100 | [diff] [blame] | 584 | END(coprocessor_segment_overrun) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 585 | |
| 586 | ENTRY(invalid_TSS) |
H. Peter Anvin | e59d1b0 | 2012-09-21 13:58:10 -0700 | [diff] [blame] | 587 | ASM_CLAC |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 588 | pushl $do_invalid_TSS |
| 589 | jmp error_code |
Jan Beulich | 47a55cd | 2007-02-13 13:26:24 +0100 | [diff] [blame] | 590 | END(invalid_TSS) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 591 | |
| 592 | ENTRY(segment_not_present) |
H. Peter Anvin | e59d1b0 | 2012-09-21 13:58:10 -0700 | [diff] [blame] | 593 | ASM_CLAC |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 594 | pushl $do_segment_not_present |
| 595 | jmp error_code |
Jan Beulich | 47a55cd | 2007-02-13 13:26:24 +0100 | [diff] [blame] | 596 | END(segment_not_present) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 597 | |
| 598 | ENTRY(stack_segment) |
H. Peter Anvin | e59d1b0 | 2012-09-21 13:58:10 -0700 | [diff] [blame] | 599 | ASM_CLAC |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 600 | pushl $do_stack_segment |
| 601 | jmp error_code |
Jan Beulich | 47a55cd | 2007-02-13 13:26:24 +0100 | [diff] [blame] | 602 | END(stack_segment) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 603 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 604 | ENTRY(alignment_check) |
H. Peter Anvin | e59d1b0 | 2012-09-21 13:58:10 -0700 | [diff] [blame] | 605 | ASM_CLAC |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 606 | pushl $do_alignment_check |
| 607 | jmp error_code |
Jan Beulich | 47a55cd | 2007-02-13 13:26:24 +0100 | [diff] [blame] | 608 | END(alignment_check) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 609 | |
Prasanna S.P | d28c439 | 2006-09-26 10:52:34 +0200 | [diff] [blame] | 610 | ENTRY(divide_error) |
H. Peter Anvin | e59d1b0 | 2012-09-21 13:58:10 -0700 | [diff] [blame] | 611 | ASM_CLAC |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 612 | pushl $0 # no error code |
| 613 | pushl $do_divide_error |
| 614 | jmp error_code |
Jan Beulich | 47a55cd | 2007-02-13 13:26:24 +0100 | [diff] [blame] | 615 | END(divide_error) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 616 | |
| 617 | #ifdef CONFIG_X86_MCE |
| 618 | ENTRY(machine_check) |
H. Peter Anvin | e59d1b0 | 2012-09-21 13:58:10 -0700 | [diff] [blame] | 619 | ASM_CLAC |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 620 | pushl $0 |
| 621 | pushl machine_check_vector |
| 622 | jmp error_code |
Jan Beulich | 47a55cd | 2007-02-13 13:26:24 +0100 | [diff] [blame] | 623 | END(machine_check) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 624 | #endif |
| 625 | |
| 626 | ENTRY(spurious_interrupt_bug) |
H. Peter Anvin | e59d1b0 | 2012-09-21 13:58:10 -0700 | [diff] [blame] | 627 | ASM_CLAC |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 628 | pushl $0 |
| 629 | pushl $do_spurious_interrupt_bug |
| 630 | jmp error_code |
Jan Beulich | 47a55cd | 2007-02-13 13:26:24 +0100 | [diff] [blame] | 631 | END(spurious_interrupt_bug) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 632 | |
Jeremy Fitzhardinge | 5ead97c | 2007-07-17 18:37:04 -0700 | [diff] [blame] | 633 | #ifdef CONFIG_XEN |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 634 | /* |
| 635 | * Xen doesn't set %esp to be precisely what the normal SYSENTER |
| 636 | * entry point expects, so fix it up before using the normal path. |
| 637 | */ |
Jeremy Fitzhardinge | e2a81ba | 2008-03-17 16:37:17 -0700 | [diff] [blame] | 638 | ENTRY(xen_sysenter_target) |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 639 | addl $5*4, %esp /* remove xen-provided frame */ |
| 640 | jmp sysenter_past_esp |
Jeremy Fitzhardinge | e2a81ba | 2008-03-17 16:37:17 -0700 | [diff] [blame] | 641 | |
Jeremy Fitzhardinge | 5ead97c | 2007-07-17 18:37:04 -0700 | [diff] [blame] | 642 | ENTRY(xen_hypervisor_callback) |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 643 | pushl $-1 /* orig_ax = -1 => not a system call */ |
Jeremy Fitzhardinge | 5ead97c | 2007-07-17 18:37:04 -0700 | [diff] [blame] | 644 | SAVE_ALL |
| 645 | TRACE_IRQS_OFF |
Jeremy Fitzhardinge | 9ec2b80 | 2007-07-17 18:37:07 -0700 | [diff] [blame] | 646 | |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 647 | /* |
| 648 | * Check to see if we got the event in the critical |
| 649 | * region in xen_iret_direct, after we've reenabled |
| 650 | * events and checked for pending events. This simulates |
| 651 | * iret instruction's behaviour where it delivers a |
| 652 | * pending interrupt when enabling interrupts: |
| 653 | */ |
| 654 | movl PT_EIP(%esp), %eax |
| 655 | cmpl $xen_iret_start_crit, %eax |
| 656 | jb 1f |
| 657 | cmpl $xen_iret_end_crit, %eax |
| 658 | jae 1f |
Jeremy Fitzhardinge | 9ec2b80 | 2007-07-17 18:37:07 -0700 | [diff] [blame] | 659 | |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 660 | jmp xen_iret_crit_fixup |
Jeremy Fitzhardinge | 9ec2b80 | 2007-07-17 18:37:07 -0700 | [diff] [blame] | 661 | |
Jeremy Fitzhardinge | e2a81ba | 2008-03-17 16:37:17 -0700 | [diff] [blame] | 662 | ENTRY(xen_do_upcall) |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 663 | 1: mov %esp, %eax |
| 664 | call xen_evtchn_do_upcall |
David Vrabel | fdfd811 | 2015-02-19 15:23:17 +0000 | [diff] [blame] | 665 | #ifndef CONFIG_PREEMPT |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 666 | call xen_maybe_preempt_hcall |
David Vrabel | fdfd811 | 2015-02-19 15:23:17 +0000 | [diff] [blame] | 667 | #endif |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 668 | jmp ret_from_intr |
Jeremy Fitzhardinge | 5ead97c | 2007-07-17 18:37:04 -0700 | [diff] [blame] | 669 | ENDPROC(xen_hypervisor_callback) |
| 670 | |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 671 | /* |
| 672 | * Hypervisor uses this for application faults while it executes. |
| 673 | * We get here for two reasons: |
| 674 | * 1. Fault while reloading DS, ES, FS or GS |
| 675 | * 2. Fault while executing IRET |
| 676 | * Category 1 we fix up by reattempting the load, and zeroing the segment |
| 677 | * register if the load fails. |
| 678 | * Category 2 we fix up by jumping to do_iret_error. We cannot use the |
| 679 | * normal Linux return path in this case because if we use the IRET hypercall |
| 680 | * to pop the stack frame we end up in an infinite loop of failsafe callbacks. |
| 681 | * We distinguish between categories by maintaining a status value in EAX. |
| 682 | */ |
Jeremy Fitzhardinge | 5ead97c | 2007-07-17 18:37:04 -0700 | [diff] [blame] | 683 | ENTRY(xen_failsafe_callback) |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 684 | pushl %eax |
| 685 | movl $1, %eax |
| 686 | 1: mov 4(%esp), %ds |
| 687 | 2: mov 8(%esp), %es |
| 688 | 3: mov 12(%esp), %fs |
| 689 | 4: mov 16(%esp), %gs |
David Vrabel | a349e23d1 | 2012-10-19 17:29:07 +0100 | [diff] [blame] | 690 | /* EAX == 0 => Category 1 (Bad segment) |
| 691 | EAX != 0 => Category 2 (Bad IRET) */ |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 692 | testl %eax, %eax |
| 693 | popl %eax |
| 694 | lea 16(%esp), %esp |
| 695 | jz 5f |
| 696 | jmp iret_exc |
| 697 | 5: pushl $-1 /* orig_ax = -1 => not a system call */ |
Jeremy Fitzhardinge | 5ead97c | 2007-07-17 18:37:04 -0700 | [diff] [blame] | 698 | SAVE_ALL |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 699 | jmp ret_from_exception |
Jeremy Fitzhardinge | 5ead97c | 2007-07-17 18:37:04 -0700 | [diff] [blame] | 700 | |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 701 | .section .fixup, "ax" |
| 702 | 6: xorl %eax, %eax |
| 703 | movl %eax, 4(%esp) |
| 704 | jmp 1b |
| 705 | 7: xorl %eax, %eax |
| 706 | movl %eax, 8(%esp) |
| 707 | jmp 2b |
| 708 | 8: xorl %eax, %eax |
| 709 | movl %eax, 12(%esp) |
| 710 | jmp 3b |
| 711 | 9: xorl %eax, %eax |
| 712 | movl %eax, 16(%esp) |
| 713 | jmp 4b |
Jeremy Fitzhardinge | 5ead97c | 2007-07-17 18:37:04 -0700 | [diff] [blame] | 714 | .previous |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 715 | _ASM_EXTABLE(1b, 6b) |
| 716 | _ASM_EXTABLE(2b, 7b) |
| 717 | _ASM_EXTABLE(3b, 8b) |
| 718 | _ASM_EXTABLE(4b, 9b) |
Jeremy Fitzhardinge | 5ead97c | 2007-07-17 18:37:04 -0700 | [diff] [blame] | 719 | ENDPROC(xen_failsafe_callback) |
| 720 | |
K. Y. Srinivasan | bc2b033 | 2013-02-03 17:22:39 -0800 | [diff] [blame] | 721 | BUILD_INTERRUPT3(xen_hvm_callback_vector, HYPERVISOR_CALLBACK_VECTOR, |
Sheng Yang | 38e20b0 | 2010-05-14 12:40:51 +0100 | [diff] [blame] | 722 | xen_evtchn_do_upcall) |
| 723 | |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 724 | #endif /* CONFIG_XEN */ |
Jeremy Fitzhardinge | 5ead97c | 2007-07-17 18:37:04 -0700 | [diff] [blame] | 725 | |
K. Y. Srinivasan | bc2b033 | 2013-02-03 17:22:39 -0800 | [diff] [blame] | 726 | #if IS_ENABLED(CONFIG_HYPERV) |
| 727 | |
| 728 | BUILD_INTERRUPT3(hyperv_callback_vector, HYPERVISOR_CALLBACK_VECTOR, |
| 729 | hyperv_vector_handler) |
| 730 | |
| 731 | #endif /* CONFIG_HYPERV */ |
| 732 | |
Steven Rostedt | 606576c | 2008-10-06 19:06:12 -0400 | [diff] [blame] | 733 | #ifdef CONFIG_FUNCTION_TRACER |
Steven Rostedt | d61f82d | 2008-05-12 21:20:43 +0200 | [diff] [blame] | 734 | #ifdef CONFIG_DYNAMIC_FTRACE |
| 735 | |
| 736 | ENTRY(mcount) |
Steven Rostedt | d61f82d | 2008-05-12 21:20:43 +0200 | [diff] [blame] | 737 | ret |
| 738 | END(mcount) |
| 739 | |
| 740 | ENTRY(ftrace_caller) |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 741 | pushl %eax |
| 742 | pushl %ecx |
| 743 | pushl %edx |
| 744 | pushl $0 /* Pass NULL as regs pointer */ |
| 745 | movl 4*4(%esp), %eax |
| 746 | movl 0x4(%ebp), %edx |
| 747 | movl function_trace_op, %ecx |
| 748 | subl $MCOUNT_INSN_SIZE, %eax |
Steven Rostedt | d61f82d | 2008-05-12 21:20:43 +0200 | [diff] [blame] | 749 | |
| 750 | .globl ftrace_call |
| 751 | ftrace_call: |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 752 | call ftrace_stub |
Steven Rostedt | d61f82d | 2008-05-12 21:20:43 +0200 | [diff] [blame] | 753 | |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 754 | addl $4, %esp /* skip NULL pointer */ |
| 755 | popl %edx |
| 756 | popl %ecx |
| 757 | popl %eax |
Steven Rostedt | 4de7239 | 2012-06-05 20:00:11 -0400 | [diff] [blame] | 758 | ftrace_ret: |
Steven Rostedt | 5a45cfe | 2008-11-26 00:16:24 -0500 | [diff] [blame] | 759 | #ifdef CONFIG_FUNCTION_GRAPH_TRACER |
| 760 | .globl ftrace_graph_call |
| 761 | ftrace_graph_call: |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 762 | jmp ftrace_stub |
Steven Rostedt | 5a45cfe | 2008-11-26 00:16:24 -0500 | [diff] [blame] | 763 | #endif |
Steven Rostedt | d61f82d | 2008-05-12 21:20:43 +0200 | [diff] [blame] | 764 | |
| 765 | .globl ftrace_stub |
| 766 | ftrace_stub: |
| 767 | ret |
| 768 | END(ftrace_caller) |
| 769 | |
Steven Rostedt | 4de7239 | 2012-06-05 20:00:11 -0400 | [diff] [blame] | 770 | ENTRY(ftrace_regs_caller) |
| 771 | pushf /* push flags before compare (in cs location) */ |
Steven Rostedt | 4de7239 | 2012-06-05 20:00:11 -0400 | [diff] [blame] | 772 | |
| 773 | /* |
| 774 | * i386 does not save SS and ESP when coming from kernel. |
| 775 | * Instead, to get sp, ®s->sp is used (see ptrace.h). |
| 776 | * Unfortunately, that means eflags must be at the same location |
| 777 | * as the current return ip is. We move the return ip into the |
| 778 | * ip location, and move flags into the return ip location. |
| 779 | */ |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 780 | pushl 4(%esp) /* save return ip into ip slot */ |
Steven Rostedt | 4de7239 | 2012-06-05 20:00:11 -0400 | [diff] [blame] | 781 | |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 782 | pushl $0 /* Load 0 into orig_ax */ |
| 783 | pushl %gs |
| 784 | pushl %fs |
| 785 | pushl %es |
| 786 | pushl %ds |
| 787 | pushl %eax |
| 788 | pushl %ebp |
| 789 | pushl %edi |
| 790 | pushl %esi |
| 791 | pushl %edx |
| 792 | pushl %ecx |
| 793 | pushl %ebx |
Steven Rostedt | 4de7239 | 2012-06-05 20:00:11 -0400 | [diff] [blame] | 794 | |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 795 | movl 13*4(%esp), %eax /* Get the saved flags */ |
| 796 | movl %eax, 14*4(%esp) /* Move saved flags into regs->flags location */ |
| 797 | /* clobbering return ip */ |
| 798 | movl $__KERNEL_CS, 13*4(%esp) |
Steven Rostedt | 4de7239 | 2012-06-05 20:00:11 -0400 | [diff] [blame] | 799 | |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 800 | movl 12*4(%esp), %eax /* Load ip (1st parameter) */ |
| 801 | subl $MCOUNT_INSN_SIZE, %eax /* Adjust ip */ |
| 802 | movl 0x4(%ebp), %edx /* Load parent ip (2nd parameter) */ |
| 803 | movl function_trace_op, %ecx /* Save ftrace_pos in 3rd parameter */ |
| 804 | pushl %esp /* Save pt_regs as 4th parameter */ |
Steven Rostedt | 4de7239 | 2012-06-05 20:00:11 -0400 | [diff] [blame] | 805 | |
| 806 | GLOBAL(ftrace_regs_call) |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 807 | call ftrace_stub |
Steven Rostedt | 4de7239 | 2012-06-05 20:00:11 -0400 | [diff] [blame] | 808 | |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 809 | addl $4, %esp /* Skip pt_regs */ |
| 810 | movl 14*4(%esp), %eax /* Move flags back into cs */ |
| 811 | movl %eax, 13*4(%esp) /* Needed to keep addl from modifying flags */ |
| 812 | movl 12*4(%esp), %eax /* Get return ip from regs->ip */ |
| 813 | movl %eax, 14*4(%esp) /* Put return ip back for ret */ |
Steven Rostedt | 4de7239 | 2012-06-05 20:00:11 -0400 | [diff] [blame] | 814 | |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 815 | popl %ebx |
| 816 | popl %ecx |
| 817 | popl %edx |
| 818 | popl %esi |
| 819 | popl %edi |
| 820 | popl %ebp |
| 821 | popl %eax |
| 822 | popl %ds |
| 823 | popl %es |
| 824 | popl %fs |
| 825 | popl %gs |
| 826 | addl $8, %esp /* Skip orig_ax and ip */ |
| 827 | popf /* Pop flags at end (no addl to corrupt flags) */ |
| 828 | jmp ftrace_ret |
Steven Rostedt | 4de7239 | 2012-06-05 20:00:11 -0400 | [diff] [blame] | 829 | |
Steven Rostedt | 4de7239 | 2012-06-05 20:00:11 -0400 | [diff] [blame] | 830 | popf |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 831 | jmp ftrace_stub |
Steven Rostedt | d61f82d | 2008-05-12 21:20:43 +0200 | [diff] [blame] | 832 | #else /* ! CONFIG_DYNAMIC_FTRACE */ |
| 833 | |
Arnaldo Carvalho de Melo | 16444a8 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 834 | ENTRY(mcount) |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 835 | cmpl $__PAGE_OFFSET, %esp |
| 836 | jb ftrace_stub /* Paging not enabled yet? */ |
H. Peter Anvin | af058ab | 2013-08-30 17:29:29 -0700 | [diff] [blame] | 837 | |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 838 | cmpl $ftrace_stub, ftrace_trace_function |
| 839 | jnz trace |
Frederic Weisbecker | fb52607 | 2008-11-25 21:07:04 +0100 | [diff] [blame] | 840 | #ifdef CONFIG_FUNCTION_GRAPH_TRACER |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 841 | cmpl $ftrace_stub, ftrace_graph_return |
| 842 | jnz ftrace_graph_caller |
Steven Rostedt | e49dc19 | 2008-12-02 23:50:05 -0500 | [diff] [blame] | 843 | |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 844 | cmpl $ftrace_graph_entry_stub, ftrace_graph_entry |
| 845 | jnz ftrace_graph_caller |
Frederic Weisbecker | caf4b32 | 2008-11-11 07:03:45 +0100 | [diff] [blame] | 846 | #endif |
Arnaldo Carvalho de Melo | 16444a8 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 847 | .globl ftrace_stub |
| 848 | ftrace_stub: |
| 849 | ret |
| 850 | |
| 851 | /* taken from glibc */ |
| 852 | trace: |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 853 | pushl %eax |
| 854 | pushl %ecx |
| 855 | pushl %edx |
| 856 | movl 0xc(%esp), %eax |
| 857 | movl 0x4(%ebp), %edx |
| 858 | subl $MCOUNT_INSN_SIZE, %eax |
Arnaldo Carvalho de Melo | 16444a8 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 859 | |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 860 | call *ftrace_trace_function |
Arnaldo Carvalho de Melo | 16444a8 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 861 | |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 862 | popl %edx |
| 863 | popl %ecx |
| 864 | popl %eax |
| 865 | jmp ftrace_stub |
Arnaldo Carvalho de Melo | 16444a8 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 866 | END(mcount) |
Steven Rostedt | d61f82d | 2008-05-12 21:20:43 +0200 | [diff] [blame] | 867 | #endif /* CONFIG_DYNAMIC_FTRACE */ |
Steven Rostedt | 606576c | 2008-10-06 19:06:12 -0400 | [diff] [blame] | 868 | #endif /* CONFIG_FUNCTION_TRACER */ |
Arnaldo Carvalho de Melo | 16444a8 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 869 | |
Frederic Weisbecker | fb52607 | 2008-11-25 21:07:04 +0100 | [diff] [blame] | 870 | #ifdef CONFIG_FUNCTION_GRAPH_TRACER |
| 871 | ENTRY(ftrace_graph_caller) |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 872 | pushl %eax |
| 873 | pushl %ecx |
| 874 | pushl %edx |
| 875 | movl 0xc(%esp), %eax |
| 876 | lea 0x4(%ebp), %edx |
| 877 | movl (%ebp), %ecx |
| 878 | subl $MCOUNT_INSN_SIZE, %eax |
| 879 | call prepare_ftrace_return |
| 880 | popl %edx |
| 881 | popl %ecx |
| 882 | popl %eax |
Frederic Weisbecker | e7d3737 | 2008-11-16 06:02:06 +0100 | [diff] [blame] | 883 | ret |
Frederic Weisbecker | fb52607 | 2008-11-25 21:07:04 +0100 | [diff] [blame] | 884 | END(ftrace_graph_caller) |
Frederic Weisbecker | caf4b32 | 2008-11-11 07:03:45 +0100 | [diff] [blame] | 885 | |
| 886 | .globl return_to_handler |
| 887 | return_to_handler: |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 888 | pushl %eax |
| 889 | pushl %edx |
| 890 | movl %ebp, %eax |
| 891 | call ftrace_return_to_handler |
| 892 | movl %eax, %ecx |
| 893 | popl %edx |
| 894 | popl %eax |
| 895 | jmp *%ecx |
Frederic Weisbecker | e7d3737 | 2008-11-16 06:02:06 +0100 | [diff] [blame] | 896 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 897 | |
Seiji Aguchi | 25c74b1 | 2013-10-30 16:37:00 -0400 | [diff] [blame] | 898 | #ifdef CONFIG_TRACING |
| 899 | ENTRY(trace_page_fault) |
Seiji Aguchi | 25c74b1 | 2013-10-30 16:37:00 -0400 | [diff] [blame] | 900 | ASM_CLAC |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 901 | pushl $trace_do_page_fault |
| 902 | jmp error_code |
Seiji Aguchi | 25c74b1 | 2013-10-30 16:37:00 -0400 | [diff] [blame] | 903 | END(trace_page_fault) |
| 904 | #endif |
| 905 | |
Alexander van Heukelum | d211af0 | 2008-11-24 15:38:45 +0100 | [diff] [blame] | 906 | ENTRY(page_fault) |
H. Peter Anvin | e59d1b0 | 2012-09-21 13:58:10 -0700 | [diff] [blame] | 907 | ASM_CLAC |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 908 | pushl $do_page_fault |
Alexander van Heukelum | d211af0 | 2008-11-24 15:38:45 +0100 | [diff] [blame] | 909 | ALIGN |
| 910 | error_code: |
Tejun Heo | ccbeed3 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 911 | /* the function address is in %gs's slot on the stack */ |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 912 | pushl %fs |
| 913 | pushl %es |
| 914 | pushl %ds |
| 915 | pushl %eax |
| 916 | pushl %ebp |
| 917 | pushl %edi |
| 918 | pushl %esi |
| 919 | pushl %edx |
| 920 | pushl %ecx |
| 921 | pushl %ebx |
Alexander van Heukelum | d211af0 | 2008-11-24 15:38:45 +0100 | [diff] [blame] | 922 | cld |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 923 | movl $(__KERNEL_PERCPU), %ecx |
| 924 | movl %ecx, %fs |
Alexander van Heukelum | d211af0 | 2008-11-24 15:38:45 +0100 | [diff] [blame] | 925 | UNWIND_ESPFIX_STACK |
Tejun Heo | ccbeed3 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 926 | GS_TO_REG %ecx |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 927 | movl PT_GS(%esp), %edi # get the function address |
| 928 | movl PT_ORIG_EAX(%esp), %edx # get the error code |
| 929 | movl $-1, PT_ORIG_EAX(%esp) # no syscall to restart |
Tejun Heo | ccbeed3 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 930 | REG_TO_PTGS %ecx |
| 931 | SET_KERNEL_GS %ecx |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 932 | movl $(__USER_DS), %ecx |
| 933 | movl %ecx, %ds |
| 934 | movl %ecx, %es |
Alexander van Heukelum | d211af0 | 2008-11-24 15:38:45 +0100 | [diff] [blame] | 935 | TRACE_IRQS_OFF |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 936 | movl %esp, %eax # pt_regs pointer |
| 937 | call *%edi |
| 938 | jmp ret_from_exception |
Alexander van Heukelum | d211af0 | 2008-11-24 15:38:45 +0100 | [diff] [blame] | 939 | END(page_fault) |
| 940 | |
| 941 | /* |
| 942 | * Debug traps and NMI can happen at the one SYSENTER instruction |
| 943 | * that sets up the real kernel stack. Check here, since we can't |
| 944 | * allow the wrong stack to be used. |
| 945 | * |
| 946 | * "TSS_sysenter_sp0+12" is because the NMI/debug handler will have |
| 947 | * already pushed 3 words if it hits on the sysenter instruction: |
| 948 | * eflags, cs and eip. |
| 949 | * |
| 950 | * We just load the right stack, and push the three (known) values |
| 951 | * by hand onto the new stack - while updating the return eip past |
| 952 | * the instruction that would have done it for sysenter. |
| 953 | */ |
Tejun Heo | f0d9611 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 954 | .macro FIX_STACK offset ok label |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 955 | cmpw $__KERNEL_CS, 4(%esp) |
| 956 | jne \ok |
Tejun Heo | f0d9611 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 957 | \label: |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 958 | movl TSS_sysenter_sp0 + \offset(%esp), %esp |
Ingo Molnar | 131484c | 2015-05-28 12:21:47 +0200 | [diff] [blame] | 959 | pushfl |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 960 | pushl $__KERNEL_CS |
| 961 | pushl $sysenter_past_esp |
Tejun Heo | f0d9611 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 962 | .endm |
Alexander van Heukelum | d211af0 | 2008-11-24 15:38:45 +0100 | [diff] [blame] | 963 | |
| 964 | ENTRY(debug) |
H. Peter Anvin | e59d1b0 | 2012-09-21 13:58:10 -0700 | [diff] [blame] | 965 | ASM_CLAC |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 966 | cmpl $entry_SYSENTER_32, (%esp) |
| 967 | jne debug_stack_correct |
Tejun Heo | f0d9611 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 968 | FIX_STACK 12, debug_stack_correct, debug_esp_fix_insn |
Alexander van Heukelum | d211af0 | 2008-11-24 15:38:45 +0100 | [diff] [blame] | 969 | debug_stack_correct: |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 970 | pushl $-1 # mark this as an int |
Alexander van Heukelum | d211af0 | 2008-11-24 15:38:45 +0100 | [diff] [blame] | 971 | SAVE_ALL |
| 972 | TRACE_IRQS_OFF |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 973 | xorl %edx, %edx # error code 0 |
| 974 | movl %esp, %eax # pt_regs pointer |
| 975 | call do_debug |
| 976 | jmp ret_from_exception |
Alexander van Heukelum | d211af0 | 2008-11-24 15:38:45 +0100 | [diff] [blame] | 977 | END(debug) |
| 978 | |
| 979 | /* |
| 980 | * NMI is doubly nasty. It can happen _while_ we're handling |
| 981 | * a debug fault, and the debug fault hasn't yet been able to |
| 982 | * clear up the stack. So we first check whether we got an |
| 983 | * NMI on the sysenter entry path, but after that we need to |
| 984 | * check whether we got an NMI on the debug path where the debug |
| 985 | * fault happened on the sysenter path. |
| 986 | */ |
| 987 | ENTRY(nmi) |
H. Peter Anvin | e59d1b0 | 2012-09-21 13:58:10 -0700 | [diff] [blame] | 988 | ASM_CLAC |
H. Peter Anvin | 34273f4 | 2014-05-04 10:36:22 -0700 | [diff] [blame] | 989 | #ifdef CONFIG_X86_ESPFIX32 |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 990 | pushl %eax |
| 991 | movl %ss, %eax |
| 992 | cmpw $__ESPFIX_SS, %ax |
| 993 | popl %eax |
| 994 | je nmi_espfix_stack |
H. Peter Anvin | 34273f4 | 2014-05-04 10:36:22 -0700 | [diff] [blame] | 995 | #endif |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 996 | cmpl $entry_SYSENTER_32, (%esp) |
| 997 | je nmi_stack_fixup |
| 998 | pushl %eax |
| 999 | movl %esp, %eax |
| 1000 | /* |
| 1001 | * Do not access memory above the end of our stack page, |
Alexander van Heukelum | d211af0 | 2008-11-24 15:38:45 +0100 | [diff] [blame] | 1002 | * it might not exist. |
| 1003 | */ |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 1004 | andl $(THREAD_SIZE-1), %eax |
| 1005 | cmpl $(THREAD_SIZE-20), %eax |
| 1006 | popl %eax |
| 1007 | jae nmi_stack_correct |
| 1008 | cmpl $entry_SYSENTER_32, 12(%esp) |
| 1009 | je nmi_debug_stack_check |
Alexander van Heukelum | d211af0 | 2008-11-24 15:38:45 +0100 | [diff] [blame] | 1010 | nmi_stack_correct: |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 1011 | pushl %eax |
Alexander van Heukelum | d211af0 | 2008-11-24 15:38:45 +0100 | [diff] [blame] | 1012 | SAVE_ALL |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 1013 | xorl %edx, %edx # zero error code |
| 1014 | movl %esp, %eax # pt_regs pointer |
| 1015 | call do_nmi |
| 1016 | jmp restore_all_notrace |
Alexander van Heukelum | d211af0 | 2008-11-24 15:38:45 +0100 | [diff] [blame] | 1017 | |
| 1018 | nmi_stack_fixup: |
Tejun Heo | f0d9611 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 1019 | FIX_STACK 12, nmi_stack_correct, 1 |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 1020 | jmp nmi_stack_correct |
Alexander van Heukelum | d211af0 | 2008-11-24 15:38:45 +0100 | [diff] [blame] | 1021 | |
| 1022 | nmi_debug_stack_check: |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 1023 | cmpw $__KERNEL_CS, 16(%esp) |
| 1024 | jne nmi_stack_correct |
| 1025 | cmpl $debug, (%esp) |
| 1026 | jb nmi_stack_correct |
| 1027 | cmpl $debug_esp_fix_insn, (%esp) |
| 1028 | ja nmi_stack_correct |
Tejun Heo | f0d9611 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 1029 | FIX_STACK 24, nmi_stack_correct, 1 |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 1030 | jmp nmi_stack_correct |
Alexander van Heukelum | d211af0 | 2008-11-24 15:38:45 +0100 | [diff] [blame] | 1031 | |
H. Peter Anvin | 34273f4 | 2014-05-04 10:36:22 -0700 | [diff] [blame] | 1032 | #ifdef CONFIG_X86_ESPFIX32 |
Alexander van Heukelum | d211af0 | 2008-11-24 15:38:45 +0100 | [diff] [blame] | 1033 | nmi_espfix_stack: |
Ingo Molnar | 131484c | 2015-05-28 12:21:47 +0200 | [diff] [blame] | 1034 | /* |
Alexander van Heukelum | d211af0 | 2008-11-24 15:38:45 +0100 | [diff] [blame] | 1035 | * create the pointer to lss back |
| 1036 | */ |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 1037 | pushl %ss |
| 1038 | pushl %esp |
| 1039 | addl $4, (%esp) |
Alexander van Heukelum | d211af0 | 2008-11-24 15:38:45 +0100 | [diff] [blame] | 1040 | /* copy the iret frame of 12 bytes */ |
| 1041 | .rept 3 |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 1042 | pushl 16(%esp) |
Alexander van Heukelum | d211af0 | 2008-11-24 15:38:45 +0100 | [diff] [blame] | 1043 | .endr |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 1044 | pushl %eax |
Alexander van Heukelum | d211af0 | 2008-11-24 15:38:45 +0100 | [diff] [blame] | 1045 | SAVE_ALL |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 1046 | FIXUP_ESPFIX_STACK # %eax == %esp |
| 1047 | xorl %edx, %edx # zero error code |
| 1048 | call do_nmi |
Alexander van Heukelum | d211af0 | 2008-11-24 15:38:45 +0100 | [diff] [blame] | 1049 | RESTORE_REGS |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 1050 | lss 12+4(%esp), %esp # back to espfix stack |
| 1051 | jmp irq_return |
H. Peter Anvin | 34273f4 | 2014-05-04 10:36:22 -0700 | [diff] [blame] | 1052 | #endif |
Alexander van Heukelum | d211af0 | 2008-11-24 15:38:45 +0100 | [diff] [blame] | 1053 | END(nmi) |
| 1054 | |
| 1055 | ENTRY(int3) |
H. Peter Anvin | e59d1b0 | 2012-09-21 13:58:10 -0700 | [diff] [blame] | 1056 | ASM_CLAC |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 1057 | pushl $-1 # mark this as an int |
Alexander van Heukelum | d211af0 | 2008-11-24 15:38:45 +0100 | [diff] [blame] | 1058 | SAVE_ALL |
| 1059 | TRACE_IRQS_OFF |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 1060 | xorl %edx, %edx # zero error code |
| 1061 | movl %esp, %eax # pt_regs pointer |
| 1062 | call do_int3 |
| 1063 | jmp ret_from_exception |
Alexander van Heukelum | d211af0 | 2008-11-24 15:38:45 +0100 | [diff] [blame] | 1064 | END(int3) |
| 1065 | |
| 1066 | ENTRY(general_protection) |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 1067 | pushl $do_general_protection |
| 1068 | jmp error_code |
Alexander van Heukelum | d211af0 | 2008-11-24 15:38:45 +0100 | [diff] [blame] | 1069 | END(general_protection) |
| 1070 | |
Gleb Natapov | 631bc48 | 2010-10-14 11:22:52 +0200 | [diff] [blame] | 1071 | #ifdef CONFIG_KVM_GUEST |
| 1072 | ENTRY(async_page_fault) |
H. Peter Anvin | e59d1b0 | 2012-09-21 13:58:10 -0700 | [diff] [blame] | 1073 | ASM_CLAC |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 1074 | pushl $do_async_page_fault |
| 1075 | jmp error_code |
Sedat Dilek | 2ae9d29 | 2011-03-08 22:39:24 +0100 | [diff] [blame] | 1076 | END(async_page_fault) |
Gleb Natapov | 631bc48 | 2010-10-14 11:22:52 +0200 | [diff] [blame] | 1077 | #endif |