1/* SPDX-License-Identifier: GPL-2.0-only */ 2 3 .section ".text._idt", "ax", @progbits 4#if ENV_X86_64 5 .code64 6#else 7 .code32 8#endif 9.global vec0, vec1, vec2, vec3, vec4, vec5, vec6, vec7, vec8, vec9 10.global vec10, vec11, vec12, vec13, vec14, vec15, vec16, vec17, vec18, vec19 11vec0: 12 push $0 /* error code */ 13 push $0 /* vector */ 14 jmp int_hand 15vec1: 16 push $0 /* error code */ 17 push $1 /* vector */ 18 jmp int_hand 19 20vec2: 21 push $0 /* error code */ 22 push $2 /* vector */ 23 jmp int_hand 24 25vec3: 26 push $0 /* error code */ 27 push $3 /* vector */ 28 jmp int_hand 29 30vec4: 31 push $0 /* error code */ 32 push $4 /* vector */ 33 jmp int_hand 34 35vec5: 36 push $0 /* error code */ 37 push $5 /* vector */ 38 jmp int_hand 39 40vec6: 41 push $0 /* error code */ 42 push $6 /* vector */ 43 jmp int_hand 44 45vec7: 46 push $0 /* error code */ 47 push $7 /* vector */ 48 jmp int_hand 49 50vec8: 51 /* error code */ 52 push $8 /* vector */ 53 jmp int_hand 54 55vec9: 56 push $0 /* error code */ 57 push $9 /* vector */ 58 jmp int_hand 59 60vec10: 61 /* error code */ 62 push $10 /* vector */ 63 jmp int_hand 64 65vec11: 66 /* error code */ 67 push $11 /* vector */ 68 jmp int_hand 69 70vec12: 71 /* error code */ 72 push $12 /* vector */ 73 jmp int_hand 74 75vec13: 76 /* error code */ 77 push $13 /* vector */ 78 jmp int_hand 79 80vec14: 81 /* error code */ 82 push $14 /* vector */ 83 jmp int_hand 84 85vec15: 86 push $0 /* error code */ 87 push $15 /* vector */ 88 jmp int_hand 89 90vec16: 91 push $0 /* error code */ 92 push $16 /* vector */ 93 jmp int_hand 94 95vec17: 96 /* error code */ 97 push $17 /* vector */ 98 jmp int_hand 99 100vec18: 101 push $0 /* error code */ 102 push $18 /* vector */ 103 jmp int_hand 104 105vec19: 106 push $0 /* error code */ 107 push $19 /* vector */ 108 jmp int_hand 109 110.global int_hand 111int_hand: 112#if ENV_X86_64 113 /* At this point, on x86-64, on the stack there is: 114 * 0(%rsp) vector 115 * 8(%rsp) error code 116 * 16(%rsp) rip 117 * 24(%rsp) cs 118 * 32(%rsp) rflags 119 * 40(%rsp) rsp 120 * 48(%rsp) ss 121 */ 122 push %r15 123 push %r14 124 push %r13 125 push %r12 126 push %r11 127 push %r10 128 push %r9 129 push %r8 130 131 push %rdi 132 push %rsi 133 push %rbp 134 135 push %rbx 136 push %rdx 137 push %rcx 138 push %rax 139 140 /* Pass pointer to struct as first argument */ 141 mov %rsp, %rdi 142 143 /* Back up stack pointer */ 144 mov %rsp, %rbp 145 146 /* Align stack to 16 bytes. */ 147 and $(~0xf), %rsp 148 149 call x86_exception 150 151 /* Restore stack pointer from backup */ 152 mov %rbp, %rsp 153 154 pop %rax 155 pop %rcx 156 pop %rdx 157 pop %rbx 158 159 pop %rbp 160 pop %rsi 161 pop %rdi 162 163 pop %r8 164 pop %r9 165 pop %r10 166 pop %r11 167 pop %r12 168 pop %r13 169 pop %r14 170 pop %r15 171 172 add $16, %rsp /* pop of the vector and error code */ 173 iretq 174#else 175 /* At this point, on x86-32, on the stack there is: 176 * 0(%esp) vector 177 * 4(%esp) error code 178 * 8(%esp) eip 179 * 12(%esp) cs 180 * 16(%esp) eflags 181 */ 182 pushl %edi 183 pushl %esi 184 pushl %ebp 185 186 /* Original stack pointer */ 187 leal 32(%esp), %ebp 188 pushl %ebp 189 pushl %ebx 190 pushl %edx 191 pushl %ecx 192 pushl %eax 193 194 /* Save pointer to eregs structure */ 195 movl %esp, %ebp 196 /* Align stack to 16 bytes. */ 197 andl $0xfffffff0, %esp 198 /* Save original stack pointer while keeping stack alignment. This 199 value is also the eregs argument x86_exception(). */ 200 sub $12, %esp 201 pushl %ebp /* Pointer to structure on the stack */ 202 call x86_exception 203 pop %esp /* Unwind the stack alignment and argument passing. */ 204 205 popl %eax 206 popl %ecx 207 popl %edx 208 popl %ebx 209 popl %ebp /* Ignore saved %esp value */ 210 popl %ebp 211 popl %esi 212 popl %edi 213 214 addl $8, %esp /* pop of the vector and error code */ 215 iret 216#endif 217