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> |
Stas Sergeev | be44d2a | 2006-12-07 02:14:01 +0100 | [diff] [blame] | 38 | #include <asm/percpu.h> |
Cyrill Gorcunov | ab68ed9 | 2008-03-25 22:16:32 +0300 | [diff] [blame] | 39 | #include <asm/processor-flags.h> |
Thomas Gleixner | 9b7dc56 | 2008-05-02 20:10:09 +0200 | [diff] [blame] | 40 | #include <asm/irq_vectors.h> |
Borislav Petkov | cd4d09e | 2016-01-26 22:12:04 +0100 | [diff] [blame] | 41 | #include <asm/cpufeatures.h> |
Andy Lutomirski | b4ca46e | 2011-08-25 16:10:33 -0400 | [diff] [blame] | 42 | #include <asm/alternative-asm.h> |
H. Peter Anvin | 6837a54 | 2012-04-20 12:19:50 -0700 | [diff] [blame] | 43 | #include <asm/asm.h> |
H. Peter Anvin | e59d1b0 | 2012-09-21 13:58:10 -0700 | [diff] [blame] | 44 | #include <asm/smap.h> |
Josh Poimboeuf | 4d516f4 | 2016-09-21 16:04:01 -0500 | [diff] [blame] | 45 | #include <asm/frame.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | |
Jiri Olsa | ea71454 | 2011-03-07 19:10:39 +0100 | [diff] [blame] | 47 | .section .entry.text, "ax" |
| 48 | |
Rusty Russell | 139ec7c | 2006-12-07 02:14:08 +0100 | [diff] [blame] | 49 | /* |
| 50 | * We use macros for low-level operations which need to be overridden |
| 51 | * for paravirtualization. The following will never clobber any registers: |
| 52 | * INTERRUPT_RETURN (aka. "iret") |
| 53 | * GET_CR0_INTO_EAX (aka. "movl %cr0, %eax") |
Jeremy Fitzhardinge | d75cd22 | 2008-06-25 00:19:26 -0400 | [diff] [blame] | 54 | * ENABLE_INTERRUPTS_SYSEXIT (aka "sti; sysexit"). |
Rusty Russell | 139ec7c | 2006-12-07 02:14:08 +0100 | [diff] [blame] | 55 | * |
| 56 | * For DISABLE_INTERRUPTS/ENABLE_INTERRUPTS (aka "cli"/"sti"), you must |
| 57 | * specify what registers can be overwritten (CLBR_NONE, CLBR_EAX/EDX/ECX/ANY). |
| 58 | * Allowing a register to be clobbered can shrink the paravirt replacement |
| 59 | * enough to patch inline, increasing performance. |
| 60 | */ |
| 61 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | #ifdef CONFIG_PREEMPT |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 63 | # define preempt_stop(clobbers) DISABLE_INTERRUPTS(clobbers); TRACE_IRQS_OFF |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | #else |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 65 | # define preempt_stop(clobbers) |
| 66 | # define resume_kernel restore_all |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | #endif |
| 68 | |
Ingo Molnar | 55f327f | 2006-07-03 00:24:43 -0700 | [diff] [blame] | 69 | .macro TRACE_IRQS_IRET |
| 70 | #ifdef CONFIG_TRACE_IRQFLAGS |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 71 | testl $X86_EFLAGS_IF, PT_EFLAGS(%esp) # interrupts off? |
| 72 | jz 1f |
Ingo Molnar | 55f327f | 2006-07-03 00:24:43 -0700 | [diff] [blame] | 73 | TRACE_IRQS_ON |
| 74 | 1: |
| 75 | #endif |
| 76 | .endm |
| 77 | |
Tejun Heo | ccbeed3 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 78 | /* |
| 79 | * User gs save/restore |
| 80 | * |
| 81 | * %gs is used for userland TLS and kernel only uses it for stack |
| 82 | * canary which is required to be at %gs:20 by gcc. Read the comment |
| 83 | * at the top of stackprotector.h for more info. |
| 84 | * |
| 85 | * Local labels 98 and 99 are used. |
| 86 | */ |
| 87 | #ifdef CONFIG_X86_32_LAZY_GS |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 88 | |
Tejun Heo | ccbeed3 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 89 | /* unfortunately push/pop can't be no-op */ |
| 90 | .macro PUSH_GS |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 91 | pushl $0 |
Tejun Heo | ccbeed3 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 92 | .endm |
| 93 | .macro POP_GS pop=0 |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 94 | addl $(4 + \pop), %esp |
Tejun Heo | ccbeed3 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 95 | .endm |
| 96 | .macro POP_GS_EX |
| 97 | .endm |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 98 | |
Tejun Heo | ccbeed3 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 99 | /* all the rest are no-op */ |
| 100 | .macro PTGS_TO_GS |
| 101 | .endm |
| 102 | .macro PTGS_TO_GS_EX |
| 103 | .endm |
| 104 | .macro GS_TO_REG reg |
| 105 | .endm |
| 106 | .macro REG_TO_PTGS reg |
| 107 | .endm |
| 108 | .macro SET_KERNEL_GS reg |
| 109 | .endm |
| 110 | |
| 111 | #else /* CONFIG_X86_32_LAZY_GS */ |
| 112 | |
| 113 | .macro PUSH_GS |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 114 | pushl %gs |
Tejun Heo | ccbeed3 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 115 | .endm |
| 116 | |
| 117 | .macro POP_GS pop=0 |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 118 | 98: popl %gs |
Tejun Heo | ccbeed3 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 119 | .if \pop <> 0 |
Denys Vlasenko | 9b47feb | 2015-06-08 22:35:33 +0200 | [diff] [blame] | 120 | add $\pop, %esp |
Tejun Heo | ccbeed3 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 121 | .endif |
| 122 | .endm |
| 123 | .macro POP_GS_EX |
| 124 | .pushsection .fixup, "ax" |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 125 | 99: movl $0, (%esp) |
| 126 | jmp 98b |
Jeremy Fitzhardinge | f95d47c | 2006-12-07 02:14:02 +0100 | [diff] [blame] | 127 | .popsection |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 128 | _ASM_EXTABLE(98b, 99b) |
Tejun Heo | ccbeed3 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 129 | .endm |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 130 | |
Tejun Heo | ccbeed3 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 131 | .macro PTGS_TO_GS |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 132 | 98: mov PT_GS(%esp), %gs |
Tejun Heo | ccbeed3 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 133 | .endm |
| 134 | .macro PTGS_TO_GS_EX |
| 135 | .pushsection .fixup, "ax" |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 136 | 99: movl $0, PT_GS(%esp) |
| 137 | jmp 98b |
Tejun Heo | ccbeed3 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 138 | .popsection |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 139 | _ASM_EXTABLE(98b, 99b) |
Tejun Heo | ccbeed3 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 140 | .endm |
| 141 | |
| 142 | .macro GS_TO_REG reg |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 143 | movl %gs, \reg |
Tejun Heo | ccbeed3 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 144 | .endm |
| 145 | .macro REG_TO_PTGS reg |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 146 | movl \reg, PT_GS(%esp) |
Tejun Heo | ccbeed3 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 147 | .endm |
| 148 | .macro SET_KERNEL_GS reg |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 149 | movl $(__KERNEL_STACK_CANARY), \reg |
| 150 | movl \reg, %gs |
Tejun Heo | ccbeed3 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 151 | .endm |
| 152 | |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 153 | #endif /* CONFIG_X86_32_LAZY_GS */ |
Tejun Heo | ccbeed3 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 154 | |
Andy Lutomirski | 150ac78 | 2015-10-05 17:48:14 -0700 | [diff] [blame] | 155 | .macro SAVE_ALL pt_regs_ax=%eax |
Tejun Heo | f0d9611 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 156 | cld |
Tejun Heo | ccbeed3 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 157 | PUSH_GS |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 158 | pushl %fs |
| 159 | pushl %es |
| 160 | pushl %ds |
Andy Lutomirski | 150ac78 | 2015-10-05 17:48:14 -0700 | [diff] [blame] | 161 | pushl \pt_regs_ax |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 162 | pushl %ebp |
| 163 | pushl %edi |
| 164 | pushl %esi |
| 165 | pushl %edx |
| 166 | pushl %ecx |
| 167 | pushl %ebx |
| 168 | movl $(__USER_DS), %edx |
| 169 | movl %edx, %ds |
| 170 | movl %edx, %es |
| 171 | movl $(__KERNEL_PERCPU), %edx |
| 172 | movl %edx, %fs |
Tejun Heo | ccbeed3 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 173 | SET_KERNEL_GS %edx |
Tejun Heo | f0d9611 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 174 | .endm |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 175 | |
Josh Poimboeuf | 946c191 | 2016-10-20 11:34:40 -0500 | [diff] [blame] | 176 | /* |
| 177 | * This is a sneaky trick to help the unwinder find pt_regs on the stack. The |
| 178 | * frame pointer is replaced with an encoded pointer to pt_regs. The encoding |
| 179 | * is just setting the LSB, which makes it an invalid stack address and is also |
| 180 | * a signal to the unwinder that it's a pt_regs pointer in disguise. |
| 181 | * |
| 182 | * NOTE: This macro must be used *after* SAVE_ALL because it corrupts the |
| 183 | * original rbp. |
| 184 | */ |
| 185 | .macro ENCODE_FRAME_POINTER |
| 186 | #ifdef CONFIG_FRAME_POINTER |
| 187 | mov %esp, %ebp |
| 188 | orl $0x1, %ebp |
| 189 | #endif |
| 190 | .endm |
| 191 | |
Tejun Heo | f0d9611 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 192 | .macro RESTORE_INT_REGS |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 193 | popl %ebx |
| 194 | popl %ecx |
| 195 | popl %edx |
| 196 | popl %esi |
| 197 | popl %edi |
| 198 | popl %ebp |
| 199 | popl %eax |
Tejun Heo | f0d9611 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 200 | .endm |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 201 | |
Tejun Heo | ccbeed3 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 202 | .macro RESTORE_REGS pop=0 |
Tejun Heo | f0d9611 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 203 | RESTORE_INT_REGS |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 204 | 1: popl %ds |
| 205 | 2: popl %es |
| 206 | 3: popl %fs |
Tejun Heo | ccbeed3 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 207 | POP_GS \pop |
Tejun Heo | f0d9611 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 208 | .pushsection .fixup, "ax" |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 209 | 4: movl $0, (%esp) |
| 210 | jmp 1b |
| 211 | 5: movl $0, (%esp) |
| 212 | jmp 2b |
| 213 | 6: movl $0, (%esp) |
| 214 | jmp 3b |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 215 | .popsection |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 216 | _ASM_EXTABLE(1b, 4b) |
| 217 | _ASM_EXTABLE(2b, 5b) |
| 218 | _ASM_EXTABLE(3b, 6b) |
Tejun Heo | ccbeed3 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 219 | POP_GS_EX |
Tejun Heo | f0d9611 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 220 | .endm |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 221 | |
Brian Gerst | 0100301 | 2016-08-13 12:38:19 -0400 | [diff] [blame] | 222 | /* |
| 223 | * %eax: prev task |
| 224 | * %edx: next task |
| 225 | */ |
| 226 | ENTRY(__switch_to_asm) |
| 227 | /* |
| 228 | * Save callee-saved registers |
| 229 | * This must match the order in struct inactive_task_frame |
| 230 | */ |
| 231 | pushl %ebp |
| 232 | pushl %ebx |
| 233 | pushl %edi |
| 234 | pushl %esi |
| 235 | |
| 236 | /* switch stack */ |
| 237 | movl %esp, TASK_threadsp(%eax) |
| 238 | movl TASK_threadsp(%edx), %esp |
| 239 | |
| 240 | #ifdef CONFIG_CC_STACKPROTECTOR |
| 241 | movl TASK_stack_canary(%edx), %ebx |
| 242 | movl %ebx, PER_CPU_VAR(stack_canary)+stack_canary_offset |
| 243 | #endif |
| 244 | |
| 245 | /* restore callee-saved registers */ |
| 246 | popl %esi |
| 247 | popl %edi |
| 248 | popl %ebx |
| 249 | popl %ebp |
| 250 | |
| 251 | jmp __switch_to |
| 252 | END(__switch_to_asm) |
| 253 | |
| 254 | /* |
| 255 | * A newly forked process directly context switches into this address. |
| 256 | * |
| 257 | * eax: prev task we switched from |
Brian Gerst | 616d248 | 2016-08-13 12:38:20 -0400 | [diff] [blame] | 258 | * ebx: kernel thread func (NULL for user thread) |
| 259 | * edi: kernel thread arg |
Brian Gerst | 0100301 | 2016-08-13 12:38:19 -0400 | [diff] [blame] | 260 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 261 | ENTRY(ret_from_fork) |
Josh Poimboeuf | ff3f7e2 | 2017-01-09 12:00:25 -0600 | [diff] [blame] | 262 | FRAME_BEGIN /* help unwinder find end of stack */ |
| 263 | |
| 264 | /* |
| 265 | * schedule_tail() is asmlinkage so we have to put its 'prev' argument |
| 266 | * on the stack. |
| 267 | */ |
| 268 | pushl %eax |
| 269 | call schedule_tail |
| 270 | popl %eax |
Andy Lutomirski | 39e8701 | 2015-10-05 17:48:13 -0700 | [diff] [blame] | 271 | |
Brian Gerst | 616d248 | 2016-08-13 12:38:20 -0400 | [diff] [blame] | 272 | testl %ebx, %ebx |
| 273 | jnz 1f /* kernel threads are uncommon */ |
| 274 | |
| 275 | 2: |
Andy Lutomirski | 39e8701 | 2015-10-05 17:48:13 -0700 | [diff] [blame] | 276 | /* When we fork, we trace the syscall return in the child, too. */ |
Josh Poimboeuf | ff3f7e2 | 2017-01-09 12:00:25 -0600 | [diff] [blame] | 277 | leal FRAME_OFFSET(%esp), %eax |
Andy Lutomirski | 39e8701 | 2015-10-05 17:48:13 -0700 | [diff] [blame] | 278 | call syscall_return_slowpath |
Josh Poimboeuf | ff3f7e2 | 2017-01-09 12:00:25 -0600 | [diff] [blame] | 279 | FRAME_END |
Andy Lutomirski | 39e8701 | 2015-10-05 17:48:13 -0700 | [diff] [blame] | 280 | jmp restore_all |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 281 | |
Brian Gerst | 616d248 | 2016-08-13 12:38:20 -0400 | [diff] [blame] | 282 | /* kernel thread */ |
| 283 | 1: movl %edi, %eax |
| 284 | call *%ebx |
Andy Lutomirski | 39e8701 | 2015-10-05 17:48:13 -0700 | [diff] [blame] | 285 | /* |
Brian Gerst | 616d248 | 2016-08-13 12:38:20 -0400 | [diff] [blame] | 286 | * A kernel thread is allowed to return here after successfully |
| 287 | * calling do_execve(). Exit to userspace to complete the execve() |
| 288 | * syscall. |
Andy Lutomirski | 39e8701 | 2015-10-05 17:48:13 -0700 | [diff] [blame] | 289 | */ |
Brian Gerst | 616d248 | 2016-08-13 12:38:20 -0400 | [diff] [blame] | 290 | movl $0, PT_EAX(%esp) |
| 291 | jmp 2b |
| 292 | END(ret_from_fork) |
Al Viro | 6783eaa | 2012-08-02 23:05:11 +0400 | [diff] [blame] | 293 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 294 | /* |
| 295 | * Return to user mode is not as complex as all this looks, |
| 296 | * but we want the default path for a system call return to |
| 297 | * go as quickly as possible which is why some of this is |
| 298 | * less clear than it otherwise should be. |
| 299 | */ |
| 300 | |
| 301 | # userspace resumption stub bypassing syscall exit tracing |
| 302 | ALIGN |
| 303 | ret_from_exception: |
Rusty Russell | 139ec7c | 2006-12-07 02:14:08 +0100 | [diff] [blame] | 304 | preempt_stop(CLBR_ANY) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 305 | ret_from_intr: |
Dmitry Adamushko | 29a2e28 | 2012-03-22 21:39:25 +0100 | [diff] [blame] | 306 | #ifdef CONFIG_VM86 |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 307 | movl PT_EFLAGS(%esp), %eax # mix EFLAGS and CS |
| 308 | movb PT_CS(%esp), %al |
| 309 | andl $(X86_EFLAGS_VM | SEGMENT_RPL_MASK), %eax |
Dmitry Adamushko | 29a2e28 | 2012-03-22 21:39:25 +0100 | [diff] [blame] | 310 | #else |
| 311 | /* |
Al Viro | 6783eaa | 2012-08-02 23:05:11 +0400 | [diff] [blame] | 312 | * We can be coming here from child spawned by kernel_thread(). |
Dmitry Adamushko | 29a2e28 | 2012-03-22 21:39:25 +0100 | [diff] [blame] | 313 | */ |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 314 | movl PT_CS(%esp), %eax |
| 315 | andl $SEGMENT_RPL_MASK, %eax |
Dmitry Adamushko | 29a2e28 | 2012-03-22 21:39:25 +0100 | [diff] [blame] | 316 | #endif |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 317 | cmpl $USER_RPL, %eax |
| 318 | jb resume_kernel # not returning to v8086 or userspace |
Jeremy Fitzhardinge | f95d47c | 2006-12-07 02:14:02 +0100 | [diff] [blame] | 319 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 320 | ENTRY(resume_userspace) |
Andy Lutomirski | 5d73fc7 | 2015-07-31 14:41:09 -0700 | [diff] [blame] | 321 | DISABLE_INTERRUPTS(CLBR_ANY) |
Peter Zijlstra | e32e58a | 2008-06-06 10:14:08 +0200 | [diff] [blame] | 322 | TRACE_IRQS_OFF |
Andy Lutomirski | 5d73fc7 | 2015-07-31 14:41:09 -0700 | [diff] [blame] | 323 | movl %esp, %eax |
| 324 | call prepare_exit_to_usermode |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 325 | jmp restore_all |
Jan Beulich | 47a55cd | 2007-02-13 13:26:24 +0100 | [diff] [blame] | 326 | END(ret_from_exception) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 327 | |
| 328 | #ifdef CONFIG_PREEMPT |
| 329 | ENTRY(resume_kernel) |
Rusty Russell | 139ec7c | 2006-12-07 02:14:08 +0100 | [diff] [blame] | 330 | DISABLE_INTERRUPTS(CLBR_ANY) |
Josh Poimboeuf | 1b00255 | 2016-09-21 16:03:59 -0500 | [diff] [blame] | 331 | .Lneed_resched: |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 332 | cmpl $0, PER_CPU_VAR(__preempt_count) |
| 333 | jnz restore_all |
| 334 | testl $X86_EFLAGS_IF, PT_EFLAGS(%esp) # interrupts off (exception path) ? |
| 335 | jz restore_all |
| 336 | call preempt_schedule_irq |
Josh Poimboeuf | 1b00255 | 2016-09-21 16:03:59 -0500 | [diff] [blame] | 337 | jmp .Lneed_resched |
Jan Beulich | 47a55cd | 2007-02-13 13:26:24 +0100 | [diff] [blame] | 338 | END(resume_kernel) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 339 | #endif |
| 340 | |
Andy Lutomirski | f2b3757 | 2016-03-09 19:00:30 -0800 | [diff] [blame] | 341 | GLOBAL(__begin_SYSENTER_singlestep_region) |
| 342 | /* |
| 343 | * All code from here through __end_SYSENTER_singlestep_region is subject |
| 344 | * to being single-stepped if a user program sets TF and executes SYSENTER. |
| 345 | * There is absolutely nothing that we can do to prevent this from happening |
| 346 | * (thanks Intel!). To keep our handling of this situation as simple as |
| 347 | * possible, we handle TF just like AC and NT, except that our #DB handler |
| 348 | * will ignore all of the single-step traps generated in this range. |
| 349 | */ |
| 350 | |
| 351 | #ifdef CONFIG_XEN |
| 352 | /* |
| 353 | * Xen doesn't set %esp to be precisely what the normal SYSENTER |
| 354 | * entry point expects, so fix it up before using the normal path. |
| 355 | */ |
| 356 | ENTRY(xen_sysenter_target) |
| 357 | addl $5*4, %esp /* remove xen-provided frame */ |
Josh Poimboeuf | 1b00255 | 2016-09-21 16:03:59 -0500 | [diff] [blame] | 358 | jmp .Lsysenter_past_esp |
Andy Lutomirski | f2b3757 | 2016-03-09 19:00:30 -0800 | [diff] [blame] | 359 | #endif |
| 360 | |
Andy Lutomirski | fda57b2 | 2016-03-09 19:00:35 -0800 | [diff] [blame] | 361 | /* |
| 362 | * 32-bit SYSENTER entry. |
| 363 | * |
| 364 | * 32-bit system calls through the vDSO's __kernel_vsyscall enter here |
| 365 | * if X86_FEATURE_SEP is available. This is the preferred system call |
| 366 | * entry on 32-bit systems. |
| 367 | * |
| 368 | * The SYSENTER instruction, in principle, should *only* occur in the |
| 369 | * vDSO. In practice, a small number of Android devices were shipped |
| 370 | * with a copy of Bionic that inlined a SYSENTER instruction. This |
| 371 | * never happened in any of Google's Bionic versions -- it only happened |
| 372 | * in a narrow range of Intel-provided versions. |
| 373 | * |
| 374 | * SYSENTER loads SS, ESP, CS, and EIP from previously programmed MSRs. |
| 375 | * IF and VM in RFLAGS are cleared (IOW: interrupts are off). |
| 376 | * SYSENTER does not save anything on the stack, |
| 377 | * and does not save old EIP (!!!), ESP, or EFLAGS. |
| 378 | * |
| 379 | * To avoid losing track of EFLAGS.VM (and thus potentially corrupting |
| 380 | * user and/or vm86 state), we explicitly disable the SYSENTER |
| 381 | * instruction in vm86 mode by reprogramming the MSRs. |
| 382 | * |
| 383 | * Arguments: |
| 384 | * eax system call number |
| 385 | * ebx arg1 |
| 386 | * ecx arg2 |
| 387 | * edx arg3 |
| 388 | * esi arg4 |
| 389 | * edi arg5 |
| 390 | * ebp user stack |
| 391 | * 0(%ebp) arg6 |
| 392 | */ |
Ingo Molnar | 4c8cd0c | 2015-06-08 08:33:56 +0200 | [diff] [blame] | 393 | ENTRY(entry_SYSENTER_32) |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 394 | movl TSS_sysenter_sp0(%esp), %esp |
Josh Poimboeuf | 1b00255 | 2016-09-21 16:03:59 -0500 | [diff] [blame] | 395 | .Lsysenter_past_esp: |
Andy Lutomirski | 5f310f7 | 2015-10-05 17:48:15 -0700 | [diff] [blame] | 396 | pushl $__USER_DS /* pt_regs->ss */ |
Andy Lutomirski | 30bfa7b | 2015-12-16 23:18:48 -0800 | [diff] [blame] | 397 | pushl %ebp /* pt_regs->sp (stashed in bp) */ |
Andy Lutomirski | 5f310f7 | 2015-10-05 17:48:15 -0700 | [diff] [blame] | 398 | pushfl /* pt_regs->flags (except IF = 0) */ |
| 399 | orl $X86_EFLAGS_IF, (%esp) /* Fix IF */ |
| 400 | pushl $__USER_CS /* pt_regs->cs */ |
| 401 | pushl $0 /* pt_regs->ip = 0 (placeholder) */ |
| 402 | pushl %eax /* pt_regs->orig_ax */ |
| 403 | SAVE_ALL pt_regs_ax=$-ENOSYS /* save rest */ |
| 404 | |
Ingo Molnar | 55f327f | 2006-07-03 00:24:43 -0700 | [diff] [blame] | 405 | /* |
Andy Lutomirski | f2b3757 | 2016-03-09 19:00:30 -0800 | [diff] [blame] | 406 | * SYSENTER doesn't filter flags, so we need to clear NT, AC |
| 407 | * and TF ourselves. To save a few cycles, we can check whether |
Andy Lutomirski | 67f590e | 2016-03-09 19:00:26 -0800 | [diff] [blame] | 408 | * either was set instead of doing an unconditional popfq. |
| 409 | * This needs to happen before enabling interrupts so that |
| 410 | * we don't get preempted with NT set. |
| 411 | * |
Andy Lutomirski | f2b3757 | 2016-03-09 19:00:30 -0800 | [diff] [blame] | 412 | * If TF is set, we will single-step all the way to here -- do_debug |
| 413 | * will ignore all the traps. (Yes, this is slow, but so is |
| 414 | * single-stepping in general. This allows us to avoid having |
| 415 | * a more complicated code to handle the case where a user program |
| 416 | * forces us to single-step through the SYSENTER entry code.) |
| 417 | * |
Andy Lutomirski | 67f590e | 2016-03-09 19:00:26 -0800 | [diff] [blame] | 418 | * NB.: .Lsysenter_fix_flags is a label with the code under it moved |
| 419 | * out-of-line as an optimization: NT is unlikely to be set in the |
| 420 | * majority of the cases and instead of polluting the I$ unnecessarily, |
| 421 | * we're keeping that code behind a branch which will predict as |
| 422 | * not-taken and therefore its instructions won't be fetched. |
| 423 | */ |
Andy Lutomirski | f2b3757 | 2016-03-09 19:00:30 -0800 | [diff] [blame] | 424 | testl $X86_EFLAGS_NT|X86_EFLAGS_AC|X86_EFLAGS_TF, PT_EFLAGS(%esp) |
Andy Lutomirski | 67f590e | 2016-03-09 19:00:26 -0800 | [diff] [blame] | 425 | jnz .Lsysenter_fix_flags |
| 426 | .Lsysenter_flags_fixed: |
| 427 | |
| 428 | /* |
Andy Lutomirski | 5f310f7 | 2015-10-05 17:48:15 -0700 | [diff] [blame] | 429 | * User mode is traced as though IRQs are on, and SYSENTER |
| 430 | * turned them off. |
Ingo Molnar | 55f327f | 2006-07-03 00:24:43 -0700 | [diff] [blame] | 431 | */ |
Ingo Molnar | 55f327f | 2006-07-03 00:24:43 -0700 | [diff] [blame] | 432 | TRACE_IRQS_OFF |
Andy Lutomirski | 5f310f7 | 2015-10-05 17:48:15 -0700 | [diff] [blame] | 433 | |
| 434 | movl %esp, %eax |
| 435 | call do_fast_syscall_32 |
Boris Ostrovsky | 91e2eea | 2015-11-19 16:55:45 -0500 | [diff] [blame] | 436 | /* XEN PV guests always use IRET path */ |
| 437 | ALTERNATIVE "testl %eax, %eax; jz .Lsyscall_32_done", \ |
| 438 | "jmp .Lsyscall_32_done", X86_FEATURE_XENPV |
Andy Lutomirski | 5f310f7 | 2015-10-05 17:48:15 -0700 | [diff] [blame] | 439 | |
| 440 | /* Opportunistic SYSEXIT */ |
| 441 | TRACE_IRQS_ON /* User mode traces as IRQs on. */ |
| 442 | movl PT_EIP(%esp), %edx /* pt_regs->ip */ |
| 443 | movl PT_OLDESP(%esp), %ecx /* pt_regs->sp */ |
Andy Lutomirski | 3bd2951 | 2015-10-16 15:42:55 -0700 | [diff] [blame] | 444 | 1: mov PT_FS(%esp), %fs |
| 445 | PTGS_TO_GS |
Andy Lutomirski | 5f310f7 | 2015-10-05 17:48:15 -0700 | [diff] [blame] | 446 | popl %ebx /* pt_regs->bx */ |
| 447 | addl $2*4, %esp /* skip pt_regs->cx and pt_regs->dx */ |
| 448 | popl %esi /* pt_regs->si */ |
| 449 | popl %edi /* pt_regs->di */ |
| 450 | popl %ebp /* pt_regs->bp */ |
| 451 | popl %eax /* pt_regs->ax */ |
Andy Lutomirski | 5f310f7 | 2015-10-05 17:48:15 -0700 | [diff] [blame] | 452 | |
| 453 | /* |
Andy Lutomirski | c2c9b52 | 2016-03-09 19:00:27 -0800 | [diff] [blame] | 454 | * Restore all flags except IF. (We restore IF separately because |
| 455 | * STI gives a one-instruction window in which we won't be interrupted, |
| 456 | * whereas POPF does not.) |
| 457 | */ |
| 458 | addl $PT_EFLAGS-PT_DS, %esp /* point esp at pt_regs->flags */ |
| 459 | btr $X86_EFLAGS_IF_BIT, (%esp) |
| 460 | popfl |
| 461 | |
| 462 | /* |
Andy Lutomirski | 5f310f7 | 2015-10-05 17:48:15 -0700 | [diff] [blame] | 463 | * Return back to the vDSO, which will pop ecx and edx. |
| 464 | * Don't bother with DS and ES (they already contain __USER_DS). |
| 465 | */ |
Boris Ostrovsky | 88c15ec | 2015-11-19 16:55:46 -0500 | [diff] [blame] | 466 | sti |
| 467 | sysexit |
Roland McGrath | af0575b | 2008-06-24 04:16:52 -0700 | [diff] [blame] | 468 | |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 469 | .pushsection .fixup, "ax" |
| 470 | 2: movl $0, PT_FS(%esp) |
| 471 | jmp 1b |
Jeremy Fitzhardinge | f95d47c | 2006-12-07 02:14:02 +0100 | [diff] [blame] | 472 | .popsection |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 473 | _ASM_EXTABLE(1b, 2b) |
Tejun Heo | ccbeed3 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 474 | PTGS_TO_GS_EX |
Andy Lutomirski | 67f590e | 2016-03-09 19:00:26 -0800 | [diff] [blame] | 475 | |
| 476 | .Lsysenter_fix_flags: |
| 477 | pushl $X86_EFLAGS_FIXED |
| 478 | popfl |
| 479 | jmp .Lsysenter_flags_fixed |
Andy Lutomirski | f2b3757 | 2016-03-09 19:00:30 -0800 | [diff] [blame] | 480 | GLOBAL(__end_SYSENTER_singlestep_region) |
Ingo Molnar | 4c8cd0c | 2015-06-08 08:33:56 +0200 | [diff] [blame] | 481 | ENDPROC(entry_SYSENTER_32) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 482 | |
Andy Lutomirski | fda57b2 | 2016-03-09 19:00:35 -0800 | [diff] [blame] | 483 | /* |
| 484 | * 32-bit legacy system call entry. |
| 485 | * |
| 486 | * 32-bit x86 Linux system calls traditionally used the INT $0x80 |
| 487 | * instruction. INT $0x80 lands here. |
| 488 | * |
| 489 | * This entry point can be used by any 32-bit perform system calls. |
| 490 | * Instances of INT $0x80 can be found inline in various programs and |
| 491 | * libraries. It is also used by the vDSO's __kernel_vsyscall |
| 492 | * fallback for hardware that doesn't support a faster entry method. |
| 493 | * Restarted 32-bit system calls also fall back to INT $0x80 |
| 494 | * regardless of what instruction was originally used to do the system |
| 495 | * call. (64-bit programs can use INT $0x80 as well, but they can |
| 496 | * only run on 64-bit kernels and therefore land in |
| 497 | * entry_INT80_compat.) |
| 498 | * |
| 499 | * This is considered a slow path. It is not used by most libc |
| 500 | * implementations on modern hardware except during process startup. |
| 501 | * |
| 502 | * Arguments: |
| 503 | * eax system call number |
| 504 | * ebx arg1 |
| 505 | * ecx arg2 |
| 506 | * edx arg3 |
| 507 | * esi arg4 |
| 508 | * edi arg5 |
| 509 | * ebp arg6 |
| 510 | */ |
Ingo Molnar | b2502b4 | 2015-06-08 08:42:03 +0200 | [diff] [blame] | 511 | ENTRY(entry_INT80_32) |
H. Peter Anvin | e59d1b0 | 2012-09-21 13:58:10 -0700 | [diff] [blame] | 512 | ASM_CLAC |
Andy Lutomirski | 150ac78 | 2015-10-05 17:48:14 -0700 | [diff] [blame] | 513 | pushl %eax /* pt_regs->orig_ax */ |
Andy Lutomirski | 5f310f7 | 2015-10-05 17:48:15 -0700 | [diff] [blame] | 514 | SAVE_ALL pt_regs_ax=$-ENOSYS /* save rest */ |
Andy Lutomirski | 150ac78 | 2015-10-05 17:48:14 -0700 | [diff] [blame] | 515 | |
| 516 | /* |
Andy Lutomirski | a798f09 | 2016-03-09 13:24:32 -0800 | [diff] [blame] | 517 | * User mode is traced as though IRQs are on, and the interrupt gate |
| 518 | * turned them off. |
Andy Lutomirski | 150ac78 | 2015-10-05 17:48:14 -0700 | [diff] [blame] | 519 | */ |
Andy Lutomirski | a798f09 | 2016-03-09 13:24:32 -0800 | [diff] [blame] | 520 | TRACE_IRQS_OFF |
Andy Lutomirski | 150ac78 | 2015-10-05 17:48:14 -0700 | [diff] [blame] | 521 | |
| 522 | movl %esp, %eax |
Andy Lutomirski | a798f09 | 2016-03-09 13:24:32 -0800 | [diff] [blame] | 523 | call do_int80_syscall_32 |
Andy Lutomirski | 5f310f7 | 2015-10-05 17:48:15 -0700 | [diff] [blame] | 524 | .Lsyscall_32_done: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 525 | |
| 526 | restore_all: |
Alexander van Heukelum | 2e04bc7 | 2009-06-18 00:35:57 +0200 | [diff] [blame] | 527 | TRACE_IRQS_IRET |
Josh Poimboeuf | 1b00255 | 2016-09-21 16:03:59 -0500 | [diff] [blame] | 528 | .Lrestore_all_notrace: |
H. Peter Anvin | 34273f4 | 2014-05-04 10:36:22 -0700 | [diff] [blame] | 529 | #ifdef CONFIG_X86_ESPFIX32 |
Josh Poimboeuf | 1b00255 | 2016-09-21 16:03:59 -0500 | [diff] [blame] | 530 | ALTERNATIVE "jmp .Lrestore_nocheck", "", X86_BUG_ESPFIX |
Andy Lutomirski | 58a5aac | 2016-02-29 15:50:19 -0800 | [diff] [blame] | 531 | |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 532 | movl PT_EFLAGS(%esp), %eax # mix EFLAGS, SS and CS |
| 533 | /* |
| 534 | * Warning: PT_OLDSS(%esp) contains the wrong/random values if we |
| 535 | * are returning to the kernel. |
| 536 | * See comments in process.c:copy_thread() for details. |
| 537 | */ |
| 538 | movb PT_OLDSS(%esp), %ah |
| 539 | movb PT_CS(%esp), %al |
| 540 | andl $(X86_EFLAGS_VM | (SEGMENT_TI_MASK << 8) | SEGMENT_RPL_MASK), %eax |
| 541 | cmpl $((SEGMENT_LDT << 8) | USER_RPL), %eax |
Josh Poimboeuf | 1b00255 | 2016-09-21 16:03:59 -0500 | [diff] [blame] | 542 | je .Lldt_ss # returning to user-space with LDT SS |
H. Peter Anvin | 34273f4 | 2014-05-04 10:36:22 -0700 | [diff] [blame] | 543 | #endif |
Josh Poimboeuf | 1b00255 | 2016-09-21 16:03:59 -0500 | [diff] [blame] | 544 | .Lrestore_nocheck: |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 545 | RESTORE_REGS 4 # skip orig_eax/error_code |
Josh Poimboeuf | 1b00255 | 2016-09-21 16:03:59 -0500 | [diff] [blame] | 546 | .Lirq_return: |
Ingo Molnar | 3701d863 | 2008-02-09 23:24:08 +0100 | [diff] [blame] | 547 | INTERRUPT_RETURN |
Josh Poimboeuf | 1b00255 | 2016-09-21 16:03:59 -0500 | [diff] [blame] | 548 | |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 549 | .section .fixup, "ax" |
| 550 | ENTRY(iret_exc ) |
| 551 | pushl $0 # no error code |
| 552 | pushl $do_iret_error |
Josh Poimboeuf | 7252c4c | 2016-09-21 16:04:00 -0500 | [diff] [blame] | 553 | jmp common_exception |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 554 | .previous |
Josh Poimboeuf | 1b00255 | 2016-09-21 16:03:59 -0500 | [diff] [blame] | 555 | _ASM_EXTABLE(.Lirq_return, iret_exc) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 556 | |
H. Peter Anvin | 34273f4 | 2014-05-04 10:36:22 -0700 | [diff] [blame] | 557 | #ifdef CONFIG_X86_ESPFIX32 |
Josh Poimboeuf | 1b00255 | 2016-09-21 16:03:59 -0500 | [diff] [blame] | 558 | .Lldt_ss: |
Alexander van Heukelum | dc4c2a0 | 2009-06-18 00:35:58 +0200 | [diff] [blame] | 559 | /* |
| 560 | * Setup and switch to ESPFIX stack |
| 561 | * |
| 562 | * We're returning to userspace with a 16 bit stack. The CPU will not |
| 563 | * restore the high word of ESP for us on executing iret... This is an |
| 564 | * "official" bug of all the x86-compatible CPUs, which we can work |
| 565 | * around to make dosemu and wine happy. We do this by preloading the |
| 566 | * high word of ESP with the high word of the userspace ESP while |
| 567 | * compensating for the offset by changing to the ESPFIX segment with |
| 568 | * a base address that matches for the difference. |
| 569 | */ |
Brian Gerst | 72c511d | 2010-07-31 12:48:23 -0400 | [diff] [blame] | 570 | #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] | 571 | mov %esp, %edx /* load kernel esp */ |
| 572 | mov PT_OLDESP(%esp), %eax /* load userspace esp */ |
| 573 | mov %dx, %ax /* eax: new kernel esp */ |
Denys Vlasenko | 9b47feb | 2015-06-08 22:35:33 +0200 | [diff] [blame] | 574 | sub %eax, %edx /* offset (low word is 0) */ |
| 575 | shr $16, %edx |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 576 | mov %dl, GDT_ESPFIX_SS + 4 /* bits 16..23 */ |
| 577 | mov %dh, GDT_ESPFIX_SS + 7 /* bits 24..31 */ |
| 578 | pushl $__ESPFIX_SS |
| 579 | pushl %eax /* new kernel esp */ |
| 580 | /* |
| 581 | * Disable interrupts, but do not irqtrace this section: we |
Alexander van Heukelum | 2e04bc7 | 2009-06-18 00:35:57 +0200 | [diff] [blame] | 582 | * will soon execute iret and the tracer was already set to |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 583 | * the irqstate after the IRET: |
| 584 | */ |
Jan Beulich | fdbd518 | 2017-02-03 01:58:03 -0700 | [diff] [blame] | 585 | DISABLE_INTERRUPTS(CLBR_ANY) |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 586 | lss (%esp), %esp /* switch to espfix segment */ |
Josh Poimboeuf | 1b00255 | 2016-09-21 16:03:59 -0500 | [diff] [blame] | 587 | jmp .Lrestore_nocheck |
H. Peter Anvin | 34273f4 | 2014-05-04 10:36:22 -0700 | [diff] [blame] | 588 | #endif |
Ingo Molnar | b2502b4 | 2015-06-08 08:42:03 +0200 | [diff] [blame] | 589 | ENDPROC(entry_INT80_32) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 590 | |
Tejun Heo | f0d9611 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 591 | .macro FIXUP_ESPFIX_STACK |
Alexander van Heukelum | dc4c2a0 | 2009-06-18 00:35:58 +0200 | [diff] [blame] | 592 | /* |
| 593 | * Switch back for ESPFIX stack to the normal zerobased stack |
| 594 | * |
| 595 | * We can't call C functions using the ESPFIX stack. This code reads |
| 596 | * the high word of the segment base from the GDT and swiches to the |
| 597 | * normal stack and adjusts ESP with the matching offset. |
| 598 | */ |
H. Peter Anvin | 34273f4 | 2014-05-04 10:36:22 -0700 | [diff] [blame] | 599 | #ifdef CONFIG_X86_ESPFIX32 |
Alexander van Heukelum | dc4c2a0 | 2009-06-18 00:35:58 +0200 | [diff] [blame] | 600 | /* fixup the stack */ |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 601 | mov GDT_ESPFIX_SS + 4, %al /* bits 16..23 */ |
| 602 | mov GDT_ESPFIX_SS + 7, %ah /* bits 24..31 */ |
Denys Vlasenko | 9b47feb | 2015-06-08 22:35:33 +0200 | [diff] [blame] | 603 | shl $16, %eax |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 604 | addl %esp, %eax /* the adjusted stack pointer */ |
| 605 | pushl $__KERNEL_DS |
| 606 | pushl %eax |
| 607 | lss (%esp), %esp /* switch to the normal stack segment */ |
H. Peter Anvin | 34273f4 | 2014-05-04 10:36:22 -0700 | [diff] [blame] | 608 | #endif |
Tejun Heo | f0d9611 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 609 | .endm |
| 610 | .macro UNWIND_ESPFIX_STACK |
H. Peter Anvin | 34273f4 | 2014-05-04 10:36:22 -0700 | [diff] [blame] | 611 | #ifdef CONFIG_X86_ESPFIX32 |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 612 | movl %ss, %eax |
Tejun Heo | f0d9611 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 613 | /* see if on espfix stack */ |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 614 | cmpw $__ESPFIX_SS, %ax |
| 615 | jne 27f |
| 616 | movl $__KERNEL_DS, %eax |
| 617 | movl %eax, %ds |
| 618 | movl %eax, %es |
Tejun Heo | f0d9611 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 619 | /* switch to normal stack */ |
| 620 | FIXUP_ESPFIX_STACK |
| 621 | 27: |
H. Peter Anvin | 34273f4 | 2014-05-04 10:36:22 -0700 | [diff] [blame] | 622 | #endif |
Tejun Heo | f0d9611 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 623 | .endm |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 624 | |
| 625 | /* |
Denys Vlasenko | 3304c9c | 2015-04-03 21:49:13 +0200 | [diff] [blame] | 626 | * Build the entry stubs with some assembler magic. |
| 627 | * We pack 1 stub into every 8-byte block. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 628 | */ |
Denys Vlasenko | 3304c9c | 2015-04-03 21:49:13 +0200 | [diff] [blame] | 629 | .align 8 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 630 | ENTRY(irq_entries_start) |
Denys Vlasenko | 3304c9c | 2015-04-03 21:49:13 +0200 | [diff] [blame] | 631 | vector=FIRST_EXTERNAL_VECTOR |
| 632 | .rept (FIRST_SYSTEM_VECTOR - FIRST_EXTERNAL_VECTOR) |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 633 | pushl $(~vector+0x80) /* Note: always in signed byte range */ |
Denys Vlasenko | 3304c9c | 2015-04-03 21:49:13 +0200 | [diff] [blame] | 634 | vector=vector+1 |
| 635 | jmp common_interrupt |
Denys Vlasenko | 3304c9c | 2015-04-03 21:49:13 +0200 | [diff] [blame] | 636 | .align 8 |
| 637 | .endr |
Jan Beulich | 47a55cd | 2007-02-13 13:26:24 +0100 | [diff] [blame] | 638 | END(irq_entries_start) |
| 639 | |
Ingo Molnar | 55f327f | 2006-07-03 00:24:43 -0700 | [diff] [blame] | 640 | /* |
| 641 | * the CPU automatically disables interrupts when executing an IRQ vector, |
| 642 | * so IRQ-flags tracing has to follow that: |
| 643 | */ |
H. Peter Anvin | b7c6244 | 2008-11-11 13:24:58 -0800 | [diff] [blame] | 644 | .p2align CONFIG_X86_L1_CACHE_SHIFT |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 645 | common_interrupt: |
H. Peter Anvin | e59d1b0 | 2012-09-21 13:58:10 -0700 | [diff] [blame] | 646 | ASM_CLAC |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 647 | addl $-0x80, (%esp) /* Adjust vector into the [-256, -1] range */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 648 | SAVE_ALL |
Josh Poimboeuf | 946c191 | 2016-10-20 11:34:40 -0500 | [diff] [blame] | 649 | ENCODE_FRAME_POINTER |
Ingo Molnar | 55f327f | 2006-07-03 00:24:43 -0700 | [diff] [blame] | 650 | TRACE_IRQS_OFF |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 651 | movl %esp, %eax |
| 652 | call do_IRQ |
| 653 | jmp ret_from_intr |
Jan Beulich | 47a55cd | 2007-02-13 13:26:24 +0100 | [diff] [blame] | 654 | ENDPROC(common_interrupt) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 655 | |
Tejun Heo | 02cf94c | 2009-01-21 17:26:06 +0900 | [diff] [blame] | 656 | #define BUILD_INTERRUPT3(name, nr, fn) \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 657 | ENTRY(name) \ |
H. Peter Anvin | e59d1b0 | 2012-09-21 13:58:10 -0700 | [diff] [blame] | 658 | ASM_CLAC; \ |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 659 | pushl $~(nr); \ |
Jan Beulich | fe7cacc | 2006-06-26 13:57:44 +0200 | [diff] [blame] | 660 | SAVE_ALL; \ |
Josh Poimboeuf | 946c191 | 2016-10-20 11:34:40 -0500 | [diff] [blame] | 661 | ENCODE_FRAME_POINTER; \ |
Ingo Molnar | 55f327f | 2006-07-03 00:24:43 -0700 | [diff] [blame] | 662 | TRACE_IRQS_OFF \ |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 663 | movl %esp, %eax; \ |
| 664 | call fn; \ |
| 665 | jmp ret_from_intr; \ |
Jan Beulich | 47a55cd | 2007-02-13 13:26:24 +0100 | [diff] [blame] | 666 | ENDPROC(name) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 667 | |
Seiji Aguchi | cf910e8 | 2013-06-20 11:46:53 -0400 | [diff] [blame] | 668 | |
| 669 | #ifdef CONFIG_TRACING |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 670 | # 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] | 671 | #else |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 672 | # define TRACE_BUILD_INTERRUPT(name, nr) |
Seiji Aguchi | cf910e8 | 2013-06-20 11:46:53 -0400 | [diff] [blame] | 673 | #endif |
| 674 | |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 675 | #define BUILD_INTERRUPT(name, nr) \ |
| 676 | BUILD_INTERRUPT3(name, nr, smp_##name); \ |
Seiji Aguchi | cf910e8 | 2013-06-20 11:46:53 -0400 | [diff] [blame] | 677 | TRACE_BUILD_INTERRUPT(name, nr) |
Tejun Heo | 02cf94c | 2009-01-21 17:26:06 +0900 | [diff] [blame] | 678 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 679 | /* The include is where all of the SMP etc. interrupts come from */ |
Ingo Molnar | 1164dd0 | 2009-01-28 19:34:09 +0100 | [diff] [blame] | 680 | #include <asm/entry_arch.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 681 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 682 | ENTRY(coprocessor_error) |
H. Peter Anvin | e59d1b0 | 2012-09-21 13:58:10 -0700 | [diff] [blame] | 683 | ASM_CLAC |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 684 | pushl $0 |
| 685 | pushl $do_coprocessor_error |
Josh Poimboeuf | 7252c4c | 2016-09-21 16:04:00 -0500 | [diff] [blame] | 686 | jmp common_exception |
Jan Beulich | 47a55cd | 2007-02-13 13:26:24 +0100 | [diff] [blame] | 687 | END(coprocessor_error) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 688 | |
| 689 | ENTRY(simd_coprocessor_error) |
H. Peter Anvin | e59d1b0 | 2012-09-21 13:58:10 -0700 | [diff] [blame] | 690 | ASM_CLAC |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 691 | pushl $0 |
Brian Gerst | 40d2e76 | 2010-03-21 09:00:43 -0400 | [diff] [blame] | 692 | #ifdef CONFIG_X86_INVD_BUG |
| 693 | /* AMD 486 bug: invd from userspace calls exception 19 instead of #GP */ |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 694 | ALTERNATIVE "pushl $do_general_protection", \ |
| 695 | "pushl $do_simd_coprocessor_error", \ |
Borislav Petkov | 8e65f6e | 2015-01-18 12:35:55 +0100 | [diff] [blame] | 696 | X86_FEATURE_XMM |
Brian Gerst | 40d2e76 | 2010-03-21 09:00:43 -0400 | [diff] [blame] | 697 | #else |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 698 | pushl $do_simd_coprocessor_error |
Brian Gerst | 40d2e76 | 2010-03-21 09:00:43 -0400 | [diff] [blame] | 699 | #endif |
Josh Poimboeuf | 7252c4c | 2016-09-21 16:04:00 -0500 | [diff] [blame] | 700 | jmp common_exception |
Jan Beulich | 47a55cd | 2007-02-13 13:26:24 +0100 | [diff] [blame] | 701 | END(simd_coprocessor_error) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 702 | |
| 703 | ENTRY(device_not_available) |
H. Peter Anvin | e59d1b0 | 2012-09-21 13:58:10 -0700 | [diff] [blame] | 704 | ASM_CLAC |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 705 | pushl $-1 # mark this as an int |
| 706 | pushl $do_device_not_available |
Josh Poimboeuf | 7252c4c | 2016-09-21 16:04:00 -0500 | [diff] [blame] | 707 | jmp common_exception |
Jan Beulich | 47a55cd | 2007-02-13 13:26:24 +0100 | [diff] [blame] | 708 | END(device_not_available) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 709 | |
Rusty Russell | d3561b7 | 2006-12-07 02:14:07 +0100 | [diff] [blame] | 710 | #ifdef CONFIG_PARAVIRT |
| 711 | ENTRY(native_iret) |
Ingo Molnar | 3701d863 | 2008-02-09 23:24:08 +0100 | [diff] [blame] | 712 | iret |
H. Peter Anvin | 6837a54 | 2012-04-20 12:19:50 -0700 | [diff] [blame] | 713 | _ASM_EXTABLE(native_iret, iret_exc) |
Jan Beulich | 47a55cd | 2007-02-13 13:26:24 +0100 | [diff] [blame] | 714 | END(native_iret) |
Rusty Russell | d3561b7 | 2006-12-07 02:14:07 +0100 | [diff] [blame] | 715 | #endif |
| 716 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 717 | ENTRY(overflow) |
H. Peter Anvin | e59d1b0 | 2012-09-21 13:58:10 -0700 | [diff] [blame] | 718 | ASM_CLAC |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 719 | pushl $0 |
| 720 | pushl $do_overflow |
Josh Poimboeuf | 7252c4c | 2016-09-21 16:04:00 -0500 | [diff] [blame] | 721 | jmp common_exception |
Jan Beulich | 47a55cd | 2007-02-13 13:26:24 +0100 | [diff] [blame] | 722 | END(overflow) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 723 | |
| 724 | ENTRY(bounds) |
H. Peter Anvin | e59d1b0 | 2012-09-21 13:58:10 -0700 | [diff] [blame] | 725 | ASM_CLAC |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 726 | pushl $0 |
| 727 | pushl $do_bounds |
Josh Poimboeuf | 7252c4c | 2016-09-21 16:04:00 -0500 | [diff] [blame] | 728 | jmp common_exception |
Jan Beulich | 47a55cd | 2007-02-13 13:26:24 +0100 | [diff] [blame] | 729 | END(bounds) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 730 | |
| 731 | ENTRY(invalid_op) |
H. Peter Anvin | e59d1b0 | 2012-09-21 13:58:10 -0700 | [diff] [blame] | 732 | ASM_CLAC |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 733 | pushl $0 |
| 734 | pushl $do_invalid_op |
Josh Poimboeuf | 7252c4c | 2016-09-21 16:04:00 -0500 | [diff] [blame] | 735 | jmp common_exception |
Jan Beulich | 47a55cd | 2007-02-13 13:26:24 +0100 | [diff] [blame] | 736 | END(invalid_op) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 737 | |
| 738 | ENTRY(coprocessor_segment_overrun) |
H. Peter Anvin | e59d1b0 | 2012-09-21 13:58:10 -0700 | [diff] [blame] | 739 | ASM_CLAC |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 740 | pushl $0 |
| 741 | pushl $do_coprocessor_segment_overrun |
Josh Poimboeuf | 7252c4c | 2016-09-21 16:04:00 -0500 | [diff] [blame] | 742 | jmp common_exception |
Jan Beulich | 47a55cd | 2007-02-13 13:26:24 +0100 | [diff] [blame] | 743 | END(coprocessor_segment_overrun) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 744 | |
| 745 | ENTRY(invalid_TSS) |
H. Peter Anvin | e59d1b0 | 2012-09-21 13:58:10 -0700 | [diff] [blame] | 746 | ASM_CLAC |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 747 | pushl $do_invalid_TSS |
Josh Poimboeuf | 7252c4c | 2016-09-21 16:04:00 -0500 | [diff] [blame] | 748 | jmp common_exception |
Jan Beulich | 47a55cd | 2007-02-13 13:26:24 +0100 | [diff] [blame] | 749 | END(invalid_TSS) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 750 | |
| 751 | ENTRY(segment_not_present) |
H. Peter Anvin | e59d1b0 | 2012-09-21 13:58:10 -0700 | [diff] [blame] | 752 | ASM_CLAC |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 753 | pushl $do_segment_not_present |
Josh Poimboeuf | 7252c4c | 2016-09-21 16:04:00 -0500 | [diff] [blame] | 754 | jmp common_exception |
Jan Beulich | 47a55cd | 2007-02-13 13:26:24 +0100 | [diff] [blame] | 755 | END(segment_not_present) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 756 | |
| 757 | ENTRY(stack_segment) |
H. Peter Anvin | e59d1b0 | 2012-09-21 13:58:10 -0700 | [diff] [blame] | 758 | ASM_CLAC |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 759 | pushl $do_stack_segment |
Josh Poimboeuf | 7252c4c | 2016-09-21 16:04:00 -0500 | [diff] [blame] | 760 | jmp common_exception |
Jan Beulich | 47a55cd | 2007-02-13 13:26:24 +0100 | [diff] [blame] | 761 | END(stack_segment) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 762 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 763 | ENTRY(alignment_check) |
H. Peter Anvin | e59d1b0 | 2012-09-21 13:58:10 -0700 | [diff] [blame] | 764 | ASM_CLAC |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 765 | pushl $do_alignment_check |
Josh Poimboeuf | 7252c4c | 2016-09-21 16:04:00 -0500 | [diff] [blame] | 766 | jmp common_exception |
Jan Beulich | 47a55cd | 2007-02-13 13:26:24 +0100 | [diff] [blame] | 767 | END(alignment_check) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 768 | |
Prasanna S.P | d28c439 | 2006-09-26 10:52:34 +0200 | [diff] [blame] | 769 | ENTRY(divide_error) |
H. Peter Anvin | e59d1b0 | 2012-09-21 13:58:10 -0700 | [diff] [blame] | 770 | ASM_CLAC |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 771 | pushl $0 # no error code |
| 772 | pushl $do_divide_error |
Josh Poimboeuf | 7252c4c | 2016-09-21 16:04:00 -0500 | [diff] [blame] | 773 | jmp common_exception |
Jan Beulich | 47a55cd | 2007-02-13 13:26:24 +0100 | [diff] [blame] | 774 | END(divide_error) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 775 | |
| 776 | #ifdef CONFIG_X86_MCE |
| 777 | ENTRY(machine_check) |
H. Peter Anvin | e59d1b0 | 2012-09-21 13:58:10 -0700 | [diff] [blame] | 778 | ASM_CLAC |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 779 | pushl $0 |
| 780 | pushl machine_check_vector |
Josh Poimboeuf | 7252c4c | 2016-09-21 16:04:00 -0500 | [diff] [blame] | 781 | jmp common_exception |
Jan Beulich | 47a55cd | 2007-02-13 13:26:24 +0100 | [diff] [blame] | 782 | END(machine_check) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 783 | #endif |
| 784 | |
| 785 | ENTRY(spurious_interrupt_bug) |
H. Peter Anvin | e59d1b0 | 2012-09-21 13:58:10 -0700 | [diff] [blame] | 786 | ASM_CLAC |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 787 | pushl $0 |
| 788 | pushl $do_spurious_interrupt_bug |
Josh Poimboeuf | 7252c4c | 2016-09-21 16:04:00 -0500 | [diff] [blame] | 789 | jmp common_exception |
Jan Beulich | 47a55cd | 2007-02-13 13:26:24 +0100 | [diff] [blame] | 790 | END(spurious_interrupt_bug) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 791 | |
Jeremy Fitzhardinge | 5ead97c | 2007-07-17 18:37:04 -0700 | [diff] [blame] | 792 | #ifdef CONFIG_XEN |
| 793 | ENTRY(xen_hypervisor_callback) |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 794 | pushl $-1 /* orig_ax = -1 => not a system call */ |
Jeremy Fitzhardinge | 5ead97c | 2007-07-17 18:37:04 -0700 | [diff] [blame] | 795 | SAVE_ALL |
Josh Poimboeuf | 946c191 | 2016-10-20 11:34:40 -0500 | [diff] [blame] | 796 | ENCODE_FRAME_POINTER |
Jeremy Fitzhardinge | 5ead97c | 2007-07-17 18:37:04 -0700 | [diff] [blame] | 797 | TRACE_IRQS_OFF |
Jeremy Fitzhardinge | 9ec2b80 | 2007-07-17 18:37:07 -0700 | [diff] [blame] | 798 | |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 799 | /* |
| 800 | * Check to see if we got the event in the critical |
| 801 | * region in xen_iret_direct, after we've reenabled |
| 802 | * events and checked for pending events. This simulates |
| 803 | * iret instruction's behaviour where it delivers a |
| 804 | * pending interrupt when enabling interrupts: |
| 805 | */ |
| 806 | movl PT_EIP(%esp), %eax |
| 807 | cmpl $xen_iret_start_crit, %eax |
| 808 | jb 1f |
| 809 | cmpl $xen_iret_end_crit, %eax |
| 810 | jae 1f |
Jeremy Fitzhardinge | 9ec2b80 | 2007-07-17 18:37:07 -0700 | [diff] [blame] | 811 | |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 812 | jmp xen_iret_crit_fixup |
Jeremy Fitzhardinge | 9ec2b80 | 2007-07-17 18:37:07 -0700 | [diff] [blame] | 813 | |
Jeremy Fitzhardinge | e2a81ba | 2008-03-17 16:37:17 -0700 | [diff] [blame] | 814 | ENTRY(xen_do_upcall) |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 815 | 1: mov %esp, %eax |
| 816 | call xen_evtchn_do_upcall |
David Vrabel | fdfd811 | 2015-02-19 15:23:17 +0000 | [diff] [blame] | 817 | #ifndef CONFIG_PREEMPT |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 818 | call xen_maybe_preempt_hcall |
David Vrabel | fdfd811 | 2015-02-19 15:23:17 +0000 | [diff] [blame] | 819 | #endif |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 820 | jmp ret_from_intr |
Jeremy Fitzhardinge | 5ead97c | 2007-07-17 18:37:04 -0700 | [diff] [blame] | 821 | ENDPROC(xen_hypervisor_callback) |
| 822 | |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 823 | /* |
| 824 | * Hypervisor uses this for application faults while it executes. |
| 825 | * We get here for two reasons: |
| 826 | * 1. Fault while reloading DS, ES, FS or GS |
| 827 | * 2. Fault while executing IRET |
| 828 | * Category 1 we fix up by reattempting the load, and zeroing the segment |
| 829 | * register if the load fails. |
| 830 | * Category 2 we fix up by jumping to do_iret_error. We cannot use the |
| 831 | * normal Linux return path in this case because if we use the IRET hypercall |
| 832 | * to pop the stack frame we end up in an infinite loop of failsafe callbacks. |
| 833 | * We distinguish between categories by maintaining a status value in EAX. |
| 834 | */ |
Jeremy Fitzhardinge | 5ead97c | 2007-07-17 18:37:04 -0700 | [diff] [blame] | 835 | ENTRY(xen_failsafe_callback) |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 836 | pushl %eax |
| 837 | movl $1, %eax |
| 838 | 1: mov 4(%esp), %ds |
| 839 | 2: mov 8(%esp), %es |
| 840 | 3: mov 12(%esp), %fs |
| 841 | 4: mov 16(%esp), %gs |
David Vrabel | a349e23d1 | 2012-10-19 17:29:07 +0100 | [diff] [blame] | 842 | /* EAX == 0 => Category 1 (Bad segment) |
| 843 | EAX != 0 => Category 2 (Bad IRET) */ |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 844 | testl %eax, %eax |
| 845 | popl %eax |
| 846 | lea 16(%esp), %esp |
| 847 | jz 5f |
| 848 | jmp iret_exc |
| 849 | 5: pushl $-1 /* orig_ax = -1 => not a system call */ |
Jeremy Fitzhardinge | 5ead97c | 2007-07-17 18:37:04 -0700 | [diff] [blame] | 850 | SAVE_ALL |
Josh Poimboeuf | 946c191 | 2016-10-20 11:34:40 -0500 | [diff] [blame] | 851 | ENCODE_FRAME_POINTER |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 852 | jmp ret_from_exception |
Jeremy Fitzhardinge | 5ead97c | 2007-07-17 18:37:04 -0700 | [diff] [blame] | 853 | |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 854 | .section .fixup, "ax" |
| 855 | 6: xorl %eax, %eax |
| 856 | movl %eax, 4(%esp) |
| 857 | jmp 1b |
| 858 | 7: xorl %eax, %eax |
| 859 | movl %eax, 8(%esp) |
| 860 | jmp 2b |
| 861 | 8: xorl %eax, %eax |
| 862 | movl %eax, 12(%esp) |
| 863 | jmp 3b |
| 864 | 9: xorl %eax, %eax |
| 865 | movl %eax, 16(%esp) |
| 866 | jmp 4b |
Jeremy Fitzhardinge | 5ead97c | 2007-07-17 18:37:04 -0700 | [diff] [blame] | 867 | .previous |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 868 | _ASM_EXTABLE(1b, 6b) |
| 869 | _ASM_EXTABLE(2b, 7b) |
| 870 | _ASM_EXTABLE(3b, 8b) |
| 871 | _ASM_EXTABLE(4b, 9b) |
Jeremy Fitzhardinge | 5ead97c | 2007-07-17 18:37:04 -0700 | [diff] [blame] | 872 | ENDPROC(xen_failsafe_callback) |
| 873 | |
K. Y. Srinivasan | bc2b033 | 2013-02-03 17:22:39 -0800 | [diff] [blame] | 874 | BUILD_INTERRUPT3(xen_hvm_callback_vector, HYPERVISOR_CALLBACK_VECTOR, |
Sheng Yang | 38e20b0 | 2010-05-14 12:40:51 +0100 | [diff] [blame] | 875 | xen_evtchn_do_upcall) |
| 876 | |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 877 | #endif /* CONFIG_XEN */ |
Jeremy Fitzhardinge | 5ead97c | 2007-07-17 18:37:04 -0700 | [diff] [blame] | 878 | |
K. Y. Srinivasan | bc2b033 | 2013-02-03 17:22:39 -0800 | [diff] [blame] | 879 | #if IS_ENABLED(CONFIG_HYPERV) |
| 880 | |
| 881 | BUILD_INTERRUPT3(hyperv_callback_vector, HYPERVISOR_CALLBACK_VECTOR, |
| 882 | hyperv_vector_handler) |
| 883 | |
| 884 | #endif /* CONFIG_HYPERV */ |
| 885 | |
Seiji Aguchi | 25c74b1 | 2013-10-30 16:37:00 -0400 | [diff] [blame] | 886 | #ifdef CONFIG_TRACING |
| 887 | ENTRY(trace_page_fault) |
Seiji Aguchi | 25c74b1 | 2013-10-30 16:37:00 -0400 | [diff] [blame] | 888 | ASM_CLAC |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 889 | pushl $trace_do_page_fault |
Josh Poimboeuf | 7252c4c | 2016-09-21 16:04:00 -0500 | [diff] [blame] | 890 | jmp common_exception |
Seiji Aguchi | 25c74b1 | 2013-10-30 16:37:00 -0400 | [diff] [blame] | 891 | END(trace_page_fault) |
| 892 | #endif |
| 893 | |
Alexander van Heukelum | d211af0 | 2008-11-24 15:38:45 +0100 | [diff] [blame] | 894 | ENTRY(page_fault) |
H. Peter Anvin | e59d1b0 | 2012-09-21 13:58:10 -0700 | [diff] [blame] | 895 | ASM_CLAC |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 896 | pushl $do_page_fault |
Alexander van Heukelum | d211af0 | 2008-11-24 15:38:45 +0100 | [diff] [blame] | 897 | ALIGN |
Josh Poimboeuf | 7252c4c | 2016-09-21 16:04:00 -0500 | [diff] [blame] | 898 | jmp common_exception |
| 899 | END(page_fault) |
| 900 | |
| 901 | common_exception: |
Tejun Heo | ccbeed3 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 902 | /* the function address is in %gs's slot on the stack */ |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 903 | pushl %fs |
| 904 | pushl %es |
| 905 | pushl %ds |
| 906 | pushl %eax |
| 907 | pushl %ebp |
| 908 | pushl %edi |
| 909 | pushl %esi |
| 910 | pushl %edx |
| 911 | pushl %ecx |
| 912 | pushl %ebx |
Josh Poimboeuf | 946c191 | 2016-10-20 11:34:40 -0500 | [diff] [blame] | 913 | ENCODE_FRAME_POINTER |
Alexander van Heukelum | d211af0 | 2008-11-24 15:38:45 +0100 | [diff] [blame] | 914 | cld |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 915 | movl $(__KERNEL_PERCPU), %ecx |
| 916 | movl %ecx, %fs |
Alexander van Heukelum | d211af0 | 2008-11-24 15:38:45 +0100 | [diff] [blame] | 917 | UNWIND_ESPFIX_STACK |
Tejun Heo | ccbeed3 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 918 | GS_TO_REG %ecx |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 919 | movl PT_GS(%esp), %edi # get the function address |
| 920 | movl PT_ORIG_EAX(%esp), %edx # get the error code |
| 921 | movl $-1, PT_ORIG_EAX(%esp) # no syscall to restart |
Tejun Heo | ccbeed3 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 922 | REG_TO_PTGS %ecx |
| 923 | SET_KERNEL_GS %ecx |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 924 | movl $(__USER_DS), %ecx |
| 925 | movl %ecx, %ds |
| 926 | movl %ecx, %es |
Alexander van Heukelum | d211af0 | 2008-11-24 15:38:45 +0100 | [diff] [blame] | 927 | TRACE_IRQS_OFF |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 928 | movl %esp, %eax # pt_regs pointer |
| 929 | call *%edi |
| 930 | jmp ret_from_exception |
Josh Poimboeuf | 7252c4c | 2016-09-21 16:04:00 -0500 | [diff] [blame] | 931 | END(common_exception) |
Alexander van Heukelum | d211af0 | 2008-11-24 15:38:45 +0100 | [diff] [blame] | 932 | |
Alexander van Heukelum | d211af0 | 2008-11-24 15:38:45 +0100 | [diff] [blame] | 933 | ENTRY(debug) |
Andy Lutomirski | 7536656 | 2016-03-09 19:00:32 -0800 | [diff] [blame] | 934 | /* |
| 935 | * #DB can happen at the first instruction of |
| 936 | * entry_SYSENTER_32 or in Xen's SYSENTER prologue. If this |
| 937 | * happens, then we will be running on a very small stack. We |
| 938 | * need to detect this condition and switch to the thread |
| 939 | * stack before calling any C code at all. |
| 940 | * |
| 941 | * If you edit this code, keep in mind that NMIs can happen in here. |
| 942 | */ |
H. Peter Anvin | e59d1b0 | 2012-09-21 13:58:10 -0700 | [diff] [blame] | 943 | ASM_CLAC |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 944 | pushl $-1 # mark this as an int |
Alexander van Heukelum | d211af0 | 2008-11-24 15:38:45 +0100 | [diff] [blame] | 945 | SAVE_ALL |
Josh Poimboeuf | 946c191 | 2016-10-20 11:34:40 -0500 | [diff] [blame] | 946 | ENCODE_FRAME_POINTER |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 947 | xorl %edx, %edx # error code 0 |
| 948 | movl %esp, %eax # pt_regs pointer |
Andy Lutomirski | 7536656 | 2016-03-09 19:00:32 -0800 | [diff] [blame] | 949 | |
| 950 | /* Are we currently on the SYSENTER stack? */ |
| 951 | PER_CPU(cpu_tss + CPU_TSS_SYSENTER_stack + SIZEOF_SYSENTER_stack, %ecx) |
| 952 | subl %eax, %ecx /* ecx = (end of SYSENTER_stack) - esp */ |
| 953 | cmpl $SIZEOF_SYSENTER_stack, %ecx |
| 954 | jb .Ldebug_from_sysenter_stack |
| 955 | |
| 956 | TRACE_IRQS_OFF |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 957 | call do_debug |
| 958 | jmp ret_from_exception |
Andy Lutomirski | 7536656 | 2016-03-09 19:00:32 -0800 | [diff] [blame] | 959 | |
| 960 | .Ldebug_from_sysenter_stack: |
| 961 | /* We're on the SYSENTER stack. Switch off. */ |
Josh Poimboeuf | 946c191 | 2016-10-20 11:34:40 -0500 | [diff] [blame] | 962 | movl %esp, %ebx |
Andy Lutomirski | 7536656 | 2016-03-09 19:00:32 -0800 | [diff] [blame] | 963 | movl PER_CPU_VAR(cpu_current_top_of_stack), %esp |
| 964 | TRACE_IRQS_OFF |
| 965 | call do_debug |
Josh Poimboeuf | 946c191 | 2016-10-20 11:34:40 -0500 | [diff] [blame] | 966 | movl %ebx, %esp |
Andy Lutomirski | 7536656 | 2016-03-09 19:00:32 -0800 | [diff] [blame] | 967 | jmp ret_from_exception |
Alexander van Heukelum | d211af0 | 2008-11-24 15:38:45 +0100 | [diff] [blame] | 968 | END(debug) |
| 969 | |
| 970 | /* |
Andy Lutomirski | 7536656 | 2016-03-09 19:00:32 -0800 | [diff] [blame] | 971 | * NMI is doubly nasty. It can happen on the first instruction of |
| 972 | * entry_SYSENTER_32 (just like #DB), but it can also interrupt the beginning |
| 973 | * of the #DB handler even if that #DB in turn hit before entry_SYSENTER_32 |
| 974 | * switched stacks. We handle both conditions by simply checking whether we |
| 975 | * interrupted kernel code running on the SYSENTER stack. |
Alexander van Heukelum | d211af0 | 2008-11-24 15:38:45 +0100 | [diff] [blame] | 976 | */ |
| 977 | ENTRY(nmi) |
H. Peter Anvin | e59d1b0 | 2012-09-21 13:58:10 -0700 | [diff] [blame] | 978 | ASM_CLAC |
H. Peter Anvin | 34273f4 | 2014-05-04 10:36:22 -0700 | [diff] [blame] | 979 | #ifdef CONFIG_X86_ESPFIX32 |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 980 | pushl %eax |
| 981 | movl %ss, %eax |
| 982 | cmpw $__ESPFIX_SS, %ax |
| 983 | popl %eax |
Josh Poimboeuf | 1b00255 | 2016-09-21 16:03:59 -0500 | [diff] [blame] | 984 | je .Lnmi_espfix_stack |
H. Peter Anvin | 34273f4 | 2014-05-04 10:36:22 -0700 | [diff] [blame] | 985 | #endif |
Andy Lutomirski | 7536656 | 2016-03-09 19:00:32 -0800 | [diff] [blame] | 986 | |
| 987 | pushl %eax # pt_regs->orig_ax |
Alexander van Heukelum | d211af0 | 2008-11-24 15:38:45 +0100 | [diff] [blame] | 988 | SAVE_ALL |
Josh Poimboeuf | 946c191 | 2016-10-20 11:34:40 -0500 | [diff] [blame] | 989 | ENCODE_FRAME_POINTER |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 990 | xorl %edx, %edx # zero error code |
| 991 | movl %esp, %eax # pt_regs pointer |
Andy Lutomirski | 7536656 | 2016-03-09 19:00:32 -0800 | [diff] [blame] | 992 | |
| 993 | /* Are we currently on the SYSENTER stack? */ |
| 994 | PER_CPU(cpu_tss + CPU_TSS_SYSENTER_stack + SIZEOF_SYSENTER_stack, %ecx) |
| 995 | subl %eax, %ecx /* ecx = (end of SYSENTER_stack) - esp */ |
| 996 | cmpl $SIZEOF_SYSENTER_stack, %ecx |
| 997 | jb .Lnmi_from_sysenter_stack |
| 998 | |
| 999 | /* Not on SYSENTER stack. */ |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 1000 | call do_nmi |
Josh Poimboeuf | 1b00255 | 2016-09-21 16:03:59 -0500 | [diff] [blame] | 1001 | jmp .Lrestore_all_notrace |
Alexander van Heukelum | d211af0 | 2008-11-24 15:38:45 +0100 | [diff] [blame] | 1002 | |
Andy Lutomirski | 7536656 | 2016-03-09 19:00:32 -0800 | [diff] [blame] | 1003 | .Lnmi_from_sysenter_stack: |
| 1004 | /* |
| 1005 | * We're on the SYSENTER stack. Switch off. No one (not even debug) |
| 1006 | * is using the thread stack right now, so it's safe for us to use it. |
| 1007 | */ |
Josh Poimboeuf | 946c191 | 2016-10-20 11:34:40 -0500 | [diff] [blame] | 1008 | movl %esp, %ebx |
Andy Lutomirski | 7536656 | 2016-03-09 19:00:32 -0800 | [diff] [blame] | 1009 | movl PER_CPU_VAR(cpu_current_top_of_stack), %esp |
| 1010 | call do_nmi |
Josh Poimboeuf | 946c191 | 2016-10-20 11:34:40 -0500 | [diff] [blame] | 1011 | movl %ebx, %esp |
Josh Poimboeuf | 1b00255 | 2016-09-21 16:03:59 -0500 | [diff] [blame] | 1012 | jmp .Lrestore_all_notrace |
Alexander van Heukelum | d211af0 | 2008-11-24 15:38:45 +0100 | [diff] [blame] | 1013 | |
H. Peter Anvin | 34273f4 | 2014-05-04 10:36:22 -0700 | [diff] [blame] | 1014 | #ifdef CONFIG_X86_ESPFIX32 |
Josh Poimboeuf | 1b00255 | 2016-09-21 16:03:59 -0500 | [diff] [blame] | 1015 | .Lnmi_espfix_stack: |
Ingo Molnar | 131484c | 2015-05-28 12:21:47 +0200 | [diff] [blame] | 1016 | /* |
Alexander van Heukelum | d211af0 | 2008-11-24 15:38:45 +0100 | [diff] [blame] | 1017 | * create the pointer to lss back |
| 1018 | */ |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 1019 | pushl %ss |
| 1020 | pushl %esp |
| 1021 | addl $4, (%esp) |
Alexander van Heukelum | d211af0 | 2008-11-24 15:38:45 +0100 | [diff] [blame] | 1022 | /* copy the iret frame of 12 bytes */ |
| 1023 | .rept 3 |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 1024 | pushl 16(%esp) |
Alexander van Heukelum | d211af0 | 2008-11-24 15:38:45 +0100 | [diff] [blame] | 1025 | .endr |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 1026 | pushl %eax |
Alexander van Heukelum | d211af0 | 2008-11-24 15:38:45 +0100 | [diff] [blame] | 1027 | SAVE_ALL |
Josh Poimboeuf | 946c191 | 2016-10-20 11:34:40 -0500 | [diff] [blame] | 1028 | ENCODE_FRAME_POINTER |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 1029 | FIXUP_ESPFIX_STACK # %eax == %esp |
| 1030 | xorl %edx, %edx # zero error code |
| 1031 | call do_nmi |
Alexander van Heukelum | d211af0 | 2008-11-24 15:38:45 +0100 | [diff] [blame] | 1032 | RESTORE_REGS |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 1033 | lss 12+4(%esp), %esp # back to espfix stack |
Josh Poimboeuf | 1b00255 | 2016-09-21 16:03:59 -0500 | [diff] [blame] | 1034 | jmp .Lirq_return |
H. Peter Anvin | 34273f4 | 2014-05-04 10:36:22 -0700 | [diff] [blame] | 1035 | #endif |
Alexander van Heukelum | d211af0 | 2008-11-24 15:38:45 +0100 | [diff] [blame] | 1036 | END(nmi) |
| 1037 | |
| 1038 | ENTRY(int3) |
H. Peter Anvin | e59d1b0 | 2012-09-21 13:58:10 -0700 | [diff] [blame] | 1039 | ASM_CLAC |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 1040 | pushl $-1 # mark this as an int |
Alexander van Heukelum | d211af0 | 2008-11-24 15:38:45 +0100 | [diff] [blame] | 1041 | SAVE_ALL |
Josh Poimboeuf | 946c191 | 2016-10-20 11:34:40 -0500 | [diff] [blame] | 1042 | ENCODE_FRAME_POINTER |
Alexander van Heukelum | d211af0 | 2008-11-24 15:38:45 +0100 | [diff] [blame] | 1043 | TRACE_IRQS_OFF |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 1044 | xorl %edx, %edx # zero error code |
| 1045 | movl %esp, %eax # pt_regs pointer |
| 1046 | call do_int3 |
| 1047 | jmp ret_from_exception |
Alexander van Heukelum | d211af0 | 2008-11-24 15:38:45 +0100 | [diff] [blame] | 1048 | END(int3) |
| 1049 | |
| 1050 | ENTRY(general_protection) |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 1051 | pushl $do_general_protection |
Josh Poimboeuf | 7252c4c | 2016-09-21 16:04:00 -0500 | [diff] [blame] | 1052 | jmp common_exception |
Alexander van Heukelum | d211af0 | 2008-11-24 15:38:45 +0100 | [diff] [blame] | 1053 | END(general_protection) |
| 1054 | |
Gleb Natapov | 631bc48 | 2010-10-14 11:22:52 +0200 | [diff] [blame] | 1055 | #ifdef CONFIG_KVM_GUEST |
| 1056 | ENTRY(async_page_fault) |
H. Peter Anvin | e59d1b0 | 2012-09-21 13:58:10 -0700 | [diff] [blame] | 1057 | ASM_CLAC |
Ingo Molnar | a49976d | 2015-06-08 09:49:11 +0200 | [diff] [blame] | 1058 | pushl $do_async_page_fault |
Josh Poimboeuf | 7252c4c | 2016-09-21 16:04:00 -0500 | [diff] [blame] | 1059 | jmp common_exception |
Sedat Dilek | 2ae9d29 | 2011-03-08 22:39:24 +0100 | [diff] [blame] | 1060 | END(async_page_fault) |
Gleb Natapov | 631bc48 | 2010-10-14 11:22:52 +0200 | [diff] [blame] | 1061 | #endif |
Andy Lutomirski | 2deb4be | 2016-07-14 13:22:55 -0700 | [diff] [blame] | 1062 | |
| 1063 | ENTRY(rewind_stack_do_exit) |
| 1064 | /* Prevent any naive code from trying to unwind to our caller. */ |
| 1065 | xorl %ebp, %ebp |
| 1066 | |
| 1067 | movl PER_CPU_VAR(cpu_current_top_of_stack), %esi |
| 1068 | leal -TOP_OF_KERNEL_STACK_PADDING-PTREGS_SIZE(%esi), %esp |
| 1069 | |
| 1070 | call do_exit |
| 1071 | 1: jmp 1b |
| 1072 | END(rewind_stack_do_exit) |