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