Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Low-level exception handling code |
| 3 | * |
| 4 | * Copyright (C) 2012 ARM Ltd. |
| 5 | * Authors: Catalin Marinas <catalin.marinas@arm.com> |
| 6 | * Will Deacon <will.deacon@arm.com> |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License version 2 as |
| 10 | * published by the Free Software Foundation. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 19 | */ |
| 20 | |
| 21 | #include <linux/init.h> |
| 22 | #include <linux/linkage.h> |
| 23 | |
Marc Zyngier | 8d883b2 | 2015-06-01 10:47:41 +0100 | [diff] [blame] | 24 | #include <asm/alternative.h> |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 25 | #include <asm/assembler.h> |
| 26 | #include <asm/asm-offsets.h> |
Will Deacon | 905e8c5 | 2015-03-23 19:07:02 +0000 | [diff] [blame] | 27 | #include <asm/cpufeature.h> |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 28 | #include <asm/errno.h> |
Marc Zyngier | 5c1ce6f | 2013-04-08 17:17:03 +0100 | [diff] [blame] | 29 | #include <asm/esr.h> |
James Morse | 8e23dac | 2015-12-04 11:02:27 +0000 | [diff] [blame] | 30 | #include <asm/irq.h> |
James Morse | e19a6ee | 2016-06-20 18:28:01 +0100 | [diff] [blame] | 31 | #include <asm/memory.h> |
Will Deacon | 78a0cec | 2018-04-03 12:09:04 +0100 | [diff] [blame] | 32 | #include <asm/mmu.h> |
Mark Rutland | 27eeced | 2018-04-12 12:10:59 +0100 | [diff] [blame] | 33 | #include <asm/processor.h> |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 34 | #include <asm/thread_info.h> |
Kristina Martsenko | 9e09d90 | 2017-06-06 20:14:10 +0100 | [diff] [blame] | 35 | #include <asm/asm-uaccess.h> |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 36 | #include <asm/unistd.h> |
Will Deacon | 78a0cec | 2018-04-03 12:09:04 +0100 | [diff] [blame] | 37 | #include <asm/kernel-pgtable.h> |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 38 | |
| 39 | /* |
Larry Bassel | 6c81fe7 | 2014-05-30 12:34:15 -0700 | [diff] [blame] | 40 | * Context tracking subsystem. Used to instrument transitions |
| 41 | * between user and kernel mode. |
| 42 | */ |
| 43 | .macro ct_user_exit, syscall = 0 |
| 44 | #ifdef CONFIG_CONTEXT_TRACKING |
| 45 | bl context_tracking_user_exit |
| 46 | .if \syscall == 1 |
| 47 | /* |
| 48 | * Save/restore needed during syscalls. Restore syscall arguments from |
| 49 | * the values already saved on stack during kernel_entry. |
| 50 | */ |
| 51 | ldp x0, x1, [sp] |
| 52 | ldp x2, x3, [sp, #S_X2] |
| 53 | ldp x4, x5, [sp, #S_X4] |
| 54 | ldp x6, x7, [sp, #S_X6] |
| 55 | .endif |
| 56 | #endif |
| 57 | .endm |
| 58 | |
| 59 | .macro ct_user_enter |
| 60 | #ifdef CONFIG_CONTEXT_TRACKING |
| 61 | bl context_tracking_user_enter |
| 62 | #endif |
| 63 | .endm |
| 64 | |
| 65 | /* |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 66 | * Bad Abort numbers |
| 67 | *----------------- |
| 68 | */ |
| 69 | #define BAD_SYNC 0 |
| 70 | #define BAD_IRQ 1 |
| 71 | #define BAD_FIQ 2 |
| 72 | #define BAD_ERROR 3 |
| 73 | |
Will Deacon | d0b3c71 | 2018-04-03 12:09:06 +0100 | [diff] [blame] | 74 | .macro kernel_ventry, el, label, regsize = 64 |
Mark Rutland | e355d4b | 2018-04-03 12:09:02 +0100 | [diff] [blame] | 75 | .align 7 |
Will Deacon | ded93ce | 2018-04-03 12:09:07 +0100 | [diff] [blame] | 76 | #ifdef CONFIG_UNMAP_KERNEL_AT_EL0 |
Will Deacon | bfca157 | 2018-04-03 12:09:09 +0100 | [diff] [blame] | 77 | alternative_if ARM64_UNMAP_KERNEL_AT_EL0 |
Will Deacon | ded93ce | 2018-04-03 12:09:07 +0100 | [diff] [blame] | 78 | .if \el == 0 |
| 79 | .if \regsize == 64 |
| 80 | mrs x30, tpidrro_el0 |
| 81 | msr tpidrro_el0, xzr |
| 82 | .else |
| 83 | mov x30, xzr |
| 84 | .endif |
| 85 | .endif |
Will Deacon | bfca157 | 2018-04-03 12:09:09 +0100 | [diff] [blame] | 86 | alternative_else_nop_endif |
Will Deacon | ded93ce | 2018-04-03 12:09:07 +0100 | [diff] [blame] | 87 | #endif |
| 88 | |
Will Deacon | 63648dd | 2014-09-29 12:26:41 +0100 | [diff] [blame] | 89 | sub sp, sp, #S_FRAME_SIZE |
Will Deacon | d0b3c71 | 2018-04-03 12:09:06 +0100 | [diff] [blame] | 90 | b el\()\el\()_\label |
Mark Rutland | e355d4b | 2018-04-03 12:09:02 +0100 | [diff] [blame] | 91 | .endm |
| 92 | |
Will Deacon | ded93ce | 2018-04-03 12:09:07 +0100 | [diff] [blame] | 93 | .macro tramp_alias, dst, sym |
| 94 | mov_q \dst, TRAMP_VALIAS |
| 95 | add \dst, \dst, #(\sym - .entry.tramp.text) |
| 96 | .endm |
| 97 | |
Mark Rutland | e355d4b | 2018-04-03 12:09:02 +0100 | [diff] [blame] | 98 | .macro kernel_entry, el, regsize = 64 |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 99 | .if \regsize == 32 |
| 100 | mov w0, w0 // zero upper 32 bits of x0 |
| 101 | .endif |
Will Deacon | 63648dd | 2014-09-29 12:26:41 +0100 | [diff] [blame] | 102 | stp x0, x1, [sp, #16 * 0] |
| 103 | stp x2, x3, [sp, #16 * 1] |
| 104 | stp x4, x5, [sp, #16 * 2] |
| 105 | stp x6, x7, [sp, #16 * 3] |
| 106 | stp x8, x9, [sp, #16 * 4] |
| 107 | stp x10, x11, [sp, #16 * 5] |
| 108 | stp x12, x13, [sp, #16 * 6] |
| 109 | stp x14, x15, [sp, #16 * 7] |
| 110 | stp x16, x17, [sp, #16 * 8] |
| 111 | stp x18, x19, [sp, #16 * 9] |
| 112 | stp x20, x21, [sp, #16 * 10] |
| 113 | stp x22, x23, [sp, #16 * 11] |
| 114 | stp x24, x25, [sp, #16 * 12] |
| 115 | stp x26, x27, [sp, #16 * 13] |
| 116 | stp x28, x29, [sp, #16 * 14] |
| 117 | |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 118 | .if \el == 0 |
| 119 | mrs x21, sp_el0 |
Jungseok Lee | 6cdf9c7 | 2015-12-04 11:02:25 +0000 | [diff] [blame] | 120 | mov tsk, sp |
| 121 | and tsk, tsk, #~(THREAD_SIZE - 1) // Ensure MDSCR_EL1.SS is clear, |
Will Deacon | 2a28307 | 2014-04-29 19:04:06 +0100 | [diff] [blame] | 122 | ldr x19, [tsk, #TI_FLAGS] // since we can unmask debug |
| 123 | disable_step_tsk x19, x20 // exceptions when scheduling. |
James Morse | 49003a8 | 2015-12-10 10:22:41 +0000 | [diff] [blame] | 124 | |
| 125 | mov x29, xzr // fp pointed to user-space |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 126 | .else |
| 127 | add x21, sp, #S_FRAME_SIZE |
James Morse | e19a6ee | 2016-06-20 18:28:01 +0100 | [diff] [blame] | 128 | get_thread_info tsk |
Mark Rutland | c910086 | 2018-04-12 12:11:00 +0100 | [diff] [blame^] | 129 | /* Save the task's original addr_limit and set USER_DS */ |
James Morse | e19a6ee | 2016-06-20 18:28:01 +0100 | [diff] [blame] | 130 | ldr x20, [tsk, #TI_ADDR_LIMIT] |
| 131 | str x20, [sp, #S_ORIG_ADDR_LIMIT] |
Mark Rutland | c910086 | 2018-04-12 12:11:00 +0100 | [diff] [blame^] | 132 | mov x20, #USER_DS |
James Morse | e19a6ee | 2016-06-20 18:28:01 +0100 | [diff] [blame] | 133 | str x20, [tsk, #TI_ADDR_LIMIT] |
Vladimir Murzin | 563cada | 2016-09-01 14:35:59 +0100 | [diff] [blame] | 134 | /* No need to reset PSTATE.UAO, hardware's already set it to 0 for us */ |
James Morse | e19a6ee | 2016-06-20 18:28:01 +0100 | [diff] [blame] | 135 | .endif /* \el == 0 */ |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 136 | mrs x22, elr_el1 |
| 137 | mrs x23, spsr_el1 |
| 138 | stp lr, x21, [sp, #S_LR] |
| 139 | stp x22, x23, [sp, #S_PC] |
| 140 | |
| 141 | /* |
| 142 | * Set syscallno to -1 by default (overridden later if real syscall). |
| 143 | */ |
| 144 | .if \el == 0 |
| 145 | mvn x21, xzr |
| 146 | str x21, [sp, #S_SYSCALLNO] |
| 147 | .endif |
| 148 | |
| 149 | /* |
Jungseok Lee | 6cdf9c7 | 2015-12-04 11:02:25 +0000 | [diff] [blame] | 150 | * Set sp_el0 to current thread_info. |
| 151 | */ |
| 152 | .if \el == 0 |
| 153 | msr sp_el0, tsk |
| 154 | .endif |
| 155 | |
| 156 | /* |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 157 | * Registers that may be useful after this macro is invoked: |
| 158 | * |
| 159 | * x21 - aborted SP |
| 160 | * x22 - aborted PC |
| 161 | * x23 - aborted PSTATE |
| 162 | */ |
| 163 | .endm |
| 164 | |
Will Deacon | 412fcb6 | 2015-08-19 15:57:09 +0100 | [diff] [blame] | 165 | .macro kernel_exit, el |
James Morse | e19a6ee | 2016-06-20 18:28:01 +0100 | [diff] [blame] | 166 | .if \el != 0 |
| 167 | /* Restore the task's original addr_limit. */ |
| 168 | ldr x20, [sp, #S_ORIG_ADDR_LIMIT] |
| 169 | str x20, [tsk, #TI_ADDR_LIMIT] |
| 170 | |
| 171 | /* No need to restore UAO, it will be restored from SPSR_EL1 */ |
| 172 | .endif |
| 173 | |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 174 | ldp x21, x22, [sp, #S_PC] // load ELR, SPSR |
| 175 | .if \el == 0 |
Larry Bassel | 6c81fe7 | 2014-05-30 12:34:15 -0700 | [diff] [blame] | 176 | ct_user_enter |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 177 | ldr x23, [sp, #S_SP] // load return stack pointer |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 178 | msr sp_el0, x23 |
Will Deacon | ded93ce | 2018-04-03 12:09:07 +0100 | [diff] [blame] | 179 | tst x22, #PSR_MODE32_BIT // native task? |
| 180 | b.eq 3f |
| 181 | |
Will Deacon | 905e8c5 | 2015-03-23 19:07:02 +0000 | [diff] [blame] | 182 | #ifdef CONFIG_ARM64_ERRATUM_845719 |
Mark Rutland | 6ba3b55 | 2016-09-07 11:07:09 +0100 | [diff] [blame] | 183 | alternative_if ARM64_WORKAROUND_845719 |
Daniel Thompson | e28cabf | 2015-07-22 12:21:03 +0100 | [diff] [blame] | 184 | #ifdef CONFIG_PID_IN_CONTEXTIDR |
| 185 | mrs x29, contextidr_el1 |
| 186 | msr contextidr_el1, x29 |
| 187 | #else |
| 188 | msr contextidr_el1, xzr |
| 189 | #endif |
Mark Rutland | 6ba3b55 | 2016-09-07 11:07:09 +0100 | [diff] [blame] | 190 | alternative_else_nop_endif |
Will Deacon | 905e8c5 | 2015-03-23 19:07:02 +0000 | [diff] [blame] | 191 | #endif |
Will Deacon | ded93ce | 2018-04-03 12:09:07 +0100 | [diff] [blame] | 192 | 3: |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 193 | .endif |
Will Deacon | 63648dd | 2014-09-29 12:26:41 +0100 | [diff] [blame] | 194 | msr elr_el1, x21 // set up the return data |
| 195 | msr spsr_el1, x22 |
Will Deacon | 63648dd | 2014-09-29 12:26:41 +0100 | [diff] [blame] | 196 | ldp x0, x1, [sp, #16 * 0] |
Will Deacon | 63648dd | 2014-09-29 12:26:41 +0100 | [diff] [blame] | 197 | ldp x2, x3, [sp, #16 * 1] |
| 198 | ldp x4, x5, [sp, #16 * 2] |
| 199 | ldp x6, x7, [sp, #16 * 3] |
| 200 | ldp x8, x9, [sp, #16 * 4] |
| 201 | ldp x10, x11, [sp, #16 * 5] |
| 202 | ldp x12, x13, [sp, #16 * 6] |
| 203 | ldp x14, x15, [sp, #16 * 7] |
| 204 | ldp x16, x17, [sp, #16 * 8] |
| 205 | ldp x18, x19, [sp, #16 * 9] |
| 206 | ldp x20, x21, [sp, #16 * 10] |
| 207 | ldp x22, x23, [sp, #16 * 11] |
| 208 | ldp x24, x25, [sp, #16 * 12] |
| 209 | ldp x26, x27, [sp, #16 * 13] |
| 210 | ldp x28, x29, [sp, #16 * 14] |
| 211 | ldr lr, [sp, #S_LR] |
| 212 | add sp, sp, #S_FRAME_SIZE // restore sp |
Will Deacon | ded93ce | 2018-04-03 12:09:07 +0100 | [diff] [blame] | 213 | |
Will Deacon | ded93ce | 2018-04-03 12:09:07 +0100 | [diff] [blame] | 214 | .if \el == 0 |
Will Deacon | bfca157 | 2018-04-03 12:09:09 +0100 | [diff] [blame] | 215 | alternative_insn eret, nop, ARM64_UNMAP_KERNEL_AT_EL0 |
| 216 | #ifdef CONFIG_UNMAP_KERNEL_AT_EL0 |
Will Deacon | ded93ce | 2018-04-03 12:09:07 +0100 | [diff] [blame] | 217 | bne 4f |
| 218 | msr far_el1, x30 |
| 219 | tramp_alias x30, tramp_exit_native |
| 220 | br x30 |
| 221 | 4: |
| 222 | tramp_alias x30, tramp_exit_compat |
| 223 | br x30 |
Will Deacon | bfca157 | 2018-04-03 12:09:09 +0100 | [diff] [blame] | 224 | #endif |
Will Deacon | ded93ce | 2018-04-03 12:09:07 +0100 | [diff] [blame] | 225 | .else |
| 226 | eret |
| 227 | .endif |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 228 | .endm |
| 229 | |
| 230 | .macro get_thread_info, rd |
Jungseok Lee | 6cdf9c7 | 2015-12-04 11:02:25 +0000 | [diff] [blame] | 231 | mrs \rd, sp_el0 |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 232 | .endm |
| 233 | |
James Morse | 971c67c | 2015-12-15 11:21:25 +0000 | [diff] [blame] | 234 | .macro irq_stack_entry |
James Morse | 8e23dac | 2015-12-04 11:02:27 +0000 | [diff] [blame] | 235 | mov x19, sp // preserve the original sp |
| 236 | |
James Morse | 8e23dac | 2015-12-04 11:02:27 +0000 | [diff] [blame] | 237 | /* |
James Morse | d224a69 | 2015-12-18 16:01:47 +0000 | [diff] [blame] | 238 | * Compare sp with the current thread_info, if the top |
| 239 | * ~(THREAD_SIZE - 1) bits match, we are on a task stack, and |
| 240 | * should switch to the irq stack. |
James Morse | 8e23dac | 2015-12-04 11:02:27 +0000 | [diff] [blame] | 241 | */ |
James Morse | d224a69 | 2015-12-18 16:01:47 +0000 | [diff] [blame] | 242 | and x25, x19, #~(THREAD_SIZE - 1) |
| 243 | cmp x25, tsk |
| 244 | b.ne 9998f |
James Morse | 8e23dac | 2015-12-04 11:02:27 +0000 | [diff] [blame] | 245 | |
James Morse | d224a69 | 2015-12-18 16:01:47 +0000 | [diff] [blame] | 246 | this_cpu_ptr irq_stack, x25, x26 |
James Morse | 8e23dac | 2015-12-04 11:02:27 +0000 | [diff] [blame] | 247 | mov x26, #IRQ_STACK_START_SP |
| 248 | add x26, x25, x26 |
James Morse | d224a69 | 2015-12-18 16:01:47 +0000 | [diff] [blame] | 249 | |
| 250 | /* switch to the irq stack */ |
James Morse | 8e23dac | 2015-12-04 11:02:27 +0000 | [diff] [blame] | 251 | mov sp, x26 |
| 252 | |
James Morse | 971c67c | 2015-12-15 11:21:25 +0000 | [diff] [blame] | 253 | /* |
| 254 | * Add a dummy stack frame, this non-standard format is fixed up |
| 255 | * by unwind_frame() |
| 256 | */ |
| 257 | stp x29, x19, [sp, #-16]! |
James Morse | 8e23dac | 2015-12-04 11:02:27 +0000 | [diff] [blame] | 258 | mov x29, sp |
James Morse | 8e23dac | 2015-12-04 11:02:27 +0000 | [diff] [blame] | 259 | |
| 260 | 9998: |
| 261 | .endm |
| 262 | |
| 263 | /* |
| 264 | * x19 should be preserved between irq_stack_entry and |
| 265 | * irq_stack_exit. |
| 266 | */ |
| 267 | .macro irq_stack_exit |
| 268 | mov sp, x19 |
| 269 | .endm |
| 270 | |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 271 | /* |
| 272 | * These are the registers used in the syscall handler, and allow us to |
| 273 | * have in theory up to 7 arguments to a function - x0 to x6. |
| 274 | * |
| 275 | * x7 is reserved for the system call number in 32-bit mode. |
| 276 | */ |
| 277 | sc_nr .req x25 // number of system calls |
| 278 | scno .req x26 // syscall number |
| 279 | stbl .req x27 // syscall table pointer |
| 280 | tsk .req x28 // current thread_info |
| 281 | |
| 282 | /* |
| 283 | * Interrupt handling. |
| 284 | */ |
| 285 | .macro irq_handler |
James Morse | 8e23dac | 2015-12-04 11:02:27 +0000 | [diff] [blame] | 286 | ldr_l x1, handle_arch_irq |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 287 | mov x0, sp |
James Morse | 971c67c | 2015-12-15 11:21:25 +0000 | [diff] [blame] | 288 | irq_stack_entry |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 289 | blr x1 |
James Morse | 8e23dac | 2015-12-04 11:02:27 +0000 | [diff] [blame] | 290 | irq_stack_exit |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 291 | .endm |
| 292 | |
| 293 | .text |
| 294 | |
| 295 | /* |
| 296 | * Exception vectors. |
| 297 | */ |
Pratyush Anand | 888b3c8 | 2016-07-08 12:35:50 -0400 | [diff] [blame] | 298 | .pushsection ".entry.text", "ax" |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 299 | |
| 300 | .align 11 |
| 301 | ENTRY(vectors) |
Will Deacon | d0b3c71 | 2018-04-03 12:09:06 +0100 | [diff] [blame] | 302 | kernel_ventry 1, sync_invalid // Synchronous EL1t |
| 303 | kernel_ventry 1, irq_invalid // IRQ EL1t |
| 304 | kernel_ventry 1, fiq_invalid // FIQ EL1t |
| 305 | kernel_ventry 1, error_invalid // Error EL1t |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 306 | |
Will Deacon | d0b3c71 | 2018-04-03 12:09:06 +0100 | [diff] [blame] | 307 | kernel_ventry 1, sync // Synchronous EL1h |
| 308 | kernel_ventry 1, irq // IRQ EL1h |
| 309 | kernel_ventry 1, fiq_invalid // FIQ EL1h |
| 310 | kernel_ventry 1, error_invalid // Error EL1h |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 311 | |
Will Deacon | d0b3c71 | 2018-04-03 12:09:06 +0100 | [diff] [blame] | 312 | kernel_ventry 0, sync // Synchronous 64-bit EL0 |
| 313 | kernel_ventry 0, irq // IRQ 64-bit EL0 |
| 314 | kernel_ventry 0, fiq_invalid // FIQ 64-bit EL0 |
| 315 | kernel_ventry 0, error_invalid // Error 64-bit EL0 |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 316 | |
| 317 | #ifdef CONFIG_COMPAT |
Will Deacon | d0b3c71 | 2018-04-03 12:09:06 +0100 | [diff] [blame] | 318 | kernel_ventry 0, sync_compat, 32 // Synchronous 32-bit EL0 |
| 319 | kernel_ventry 0, irq_compat, 32 // IRQ 32-bit EL0 |
| 320 | kernel_ventry 0, fiq_invalid_compat, 32 // FIQ 32-bit EL0 |
| 321 | kernel_ventry 0, error_invalid_compat, 32 // Error 32-bit EL0 |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 322 | #else |
Will Deacon | d0b3c71 | 2018-04-03 12:09:06 +0100 | [diff] [blame] | 323 | kernel_ventry 0, sync_invalid, 32 // Synchronous 32-bit EL0 |
| 324 | kernel_ventry 0, irq_invalid, 32 // IRQ 32-bit EL0 |
| 325 | kernel_ventry 0, fiq_invalid, 32 // FIQ 32-bit EL0 |
| 326 | kernel_ventry 0, error_invalid, 32 // Error 32-bit EL0 |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 327 | #endif |
| 328 | END(vectors) |
| 329 | |
| 330 | /* |
| 331 | * Invalid mode handlers |
| 332 | */ |
| 333 | .macro inv_entry, el, reason, regsize = 64 |
Ard Biesheuvel | b660950 | 2016-03-18 10:58:09 +0100 | [diff] [blame] | 334 | kernel_entry \el, \regsize |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 335 | mov x0, sp |
| 336 | mov x1, #\reason |
| 337 | mrs x2, esr_el1 |
| 338 | b bad_mode |
| 339 | .endm |
| 340 | |
| 341 | el0_sync_invalid: |
| 342 | inv_entry 0, BAD_SYNC |
| 343 | ENDPROC(el0_sync_invalid) |
| 344 | |
| 345 | el0_irq_invalid: |
| 346 | inv_entry 0, BAD_IRQ |
| 347 | ENDPROC(el0_irq_invalid) |
| 348 | |
| 349 | el0_fiq_invalid: |
| 350 | inv_entry 0, BAD_FIQ |
| 351 | ENDPROC(el0_fiq_invalid) |
| 352 | |
| 353 | el0_error_invalid: |
| 354 | inv_entry 0, BAD_ERROR |
| 355 | ENDPROC(el0_error_invalid) |
| 356 | |
| 357 | #ifdef CONFIG_COMPAT |
| 358 | el0_fiq_invalid_compat: |
| 359 | inv_entry 0, BAD_FIQ, 32 |
| 360 | ENDPROC(el0_fiq_invalid_compat) |
| 361 | |
| 362 | el0_error_invalid_compat: |
| 363 | inv_entry 0, BAD_ERROR, 32 |
| 364 | ENDPROC(el0_error_invalid_compat) |
| 365 | #endif |
| 366 | |
| 367 | el1_sync_invalid: |
| 368 | inv_entry 1, BAD_SYNC |
| 369 | ENDPROC(el1_sync_invalid) |
| 370 | |
| 371 | el1_irq_invalid: |
| 372 | inv_entry 1, BAD_IRQ |
| 373 | ENDPROC(el1_irq_invalid) |
| 374 | |
| 375 | el1_fiq_invalid: |
| 376 | inv_entry 1, BAD_FIQ |
| 377 | ENDPROC(el1_fiq_invalid) |
| 378 | |
| 379 | el1_error_invalid: |
| 380 | inv_entry 1, BAD_ERROR |
| 381 | ENDPROC(el1_error_invalid) |
| 382 | |
| 383 | /* |
| 384 | * EL1 mode handlers. |
| 385 | */ |
| 386 | .align 6 |
| 387 | el1_sync: |
| 388 | kernel_entry 1 |
| 389 | mrs x1, esr_el1 // read the syndrome register |
Mark Rutland | aed40e0 | 2014-11-24 12:31:40 +0000 | [diff] [blame] | 390 | lsr x24, x1, #ESR_ELx_EC_SHIFT // exception class |
| 391 | cmp x24, #ESR_ELx_EC_DABT_CUR // data abort in EL1 |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 392 | b.eq el1_da |
Laura Abbott | 9adeb8e | 2016-08-09 18:25:26 -0700 | [diff] [blame] | 393 | cmp x24, #ESR_ELx_EC_IABT_CUR // instruction abort in EL1 |
| 394 | b.eq el1_ia |
Mark Rutland | aed40e0 | 2014-11-24 12:31:40 +0000 | [diff] [blame] | 395 | cmp x24, #ESR_ELx_EC_SYS64 // configurable trap |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 396 | b.eq el1_undef |
Mark Rutland | aed40e0 | 2014-11-24 12:31:40 +0000 | [diff] [blame] | 397 | cmp x24, #ESR_ELx_EC_SP_ALIGN // stack alignment exception |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 398 | b.eq el1_sp_pc |
Mark Rutland | aed40e0 | 2014-11-24 12:31:40 +0000 | [diff] [blame] | 399 | cmp x24, #ESR_ELx_EC_PC_ALIGN // pc alignment exception |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 400 | b.eq el1_sp_pc |
Mark Rutland | aed40e0 | 2014-11-24 12:31:40 +0000 | [diff] [blame] | 401 | cmp x24, #ESR_ELx_EC_UNKNOWN // unknown exception in EL1 |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 402 | b.eq el1_undef |
Mark Rutland | aed40e0 | 2014-11-24 12:31:40 +0000 | [diff] [blame] | 403 | cmp x24, #ESR_ELx_EC_BREAKPT_CUR // debug exception in EL1 |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 404 | b.ge el1_dbg |
| 405 | b el1_inv |
Laura Abbott | 9adeb8e | 2016-08-09 18:25:26 -0700 | [diff] [blame] | 406 | |
| 407 | el1_ia: |
| 408 | /* |
| 409 | * Fall through to the Data abort case |
| 410 | */ |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 411 | el1_da: |
| 412 | /* |
| 413 | * Data abort handling |
| 414 | */ |
Kristina Martsenko | 9e09d90 | 2017-06-06 20:14:10 +0100 | [diff] [blame] | 415 | mrs x3, far_el1 |
Will Deacon | 2a28307 | 2014-04-29 19:04:06 +0100 | [diff] [blame] | 416 | enable_dbg |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 417 | // re-enable interrupts if they were enabled in the aborted context |
| 418 | tbnz x23, #7, 1f // PSR_I_BIT |
| 419 | enable_irq |
| 420 | 1: |
Kristina Martsenko | 9e09d90 | 2017-06-06 20:14:10 +0100 | [diff] [blame] | 421 | clear_address_tag x0, x3 |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 422 | mov x2, sp // struct pt_regs |
| 423 | bl do_mem_abort |
| 424 | |
| 425 | // disable interrupts before pulling preserved data off the stack |
| 426 | disable_irq |
| 427 | kernel_exit 1 |
| 428 | el1_sp_pc: |
| 429 | /* |
| 430 | * Stack or PC alignment exception handling |
| 431 | */ |
| 432 | mrs x0, far_el1 |
Will Deacon | 2a28307 | 2014-04-29 19:04:06 +0100 | [diff] [blame] | 433 | enable_dbg |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 434 | mov x2, sp |
| 435 | b do_sp_pc_abort |
| 436 | el1_undef: |
| 437 | /* |
| 438 | * Undefined instruction |
| 439 | */ |
Will Deacon | 2a28307 | 2014-04-29 19:04:06 +0100 | [diff] [blame] | 440 | enable_dbg |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 441 | mov x0, sp |
| 442 | b do_undefinstr |
| 443 | el1_dbg: |
| 444 | /* |
| 445 | * Debug exception handling |
| 446 | */ |
Mark Rutland | aed40e0 | 2014-11-24 12:31:40 +0000 | [diff] [blame] | 447 | cmp x24, #ESR_ELx_EC_BRK64 // if BRK64 |
Sandeepa Prabhu | ee6214c | 2013-12-04 05:50:20 +0000 | [diff] [blame] | 448 | cinc x24, x24, eq // set bit '0' |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 449 | tbz x24, #0, el1_inv // EL1 only |
| 450 | mrs x0, far_el1 |
| 451 | mov x2, sp // struct pt_regs |
| 452 | bl do_debug_exception |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 453 | kernel_exit 1 |
| 454 | el1_inv: |
| 455 | // TODO: add support for undefined instructions in kernel mode |
Will Deacon | 2a28307 | 2014-04-29 19:04:06 +0100 | [diff] [blame] | 456 | enable_dbg |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 457 | mov x0, sp |
Mark Rutland | 1b42804 | 2015-07-07 18:00:49 +0100 | [diff] [blame] | 458 | mov x2, x1 |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 459 | mov x1, #BAD_SYNC |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 460 | b bad_mode |
| 461 | ENDPROC(el1_sync) |
| 462 | |
| 463 | .align 6 |
| 464 | el1_irq: |
| 465 | kernel_entry 1 |
Will Deacon | 2a28307 | 2014-04-29 19:04:06 +0100 | [diff] [blame] | 466 | enable_dbg |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 467 | #ifdef CONFIG_TRACE_IRQFLAGS |
| 468 | bl trace_hardirqs_off |
| 469 | #endif |
Marc Zyngier | 6468178 | 2013-11-12 17:11:53 +0000 | [diff] [blame] | 470 | |
| 471 | irq_handler |
| 472 | |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 473 | #ifdef CONFIG_PREEMPT |
Neil Zhang | 883c057 | 2014-01-13 08:57:56 +0000 | [diff] [blame] | 474 | ldr w24, [tsk, #TI_PREEMPT] // get preempt count |
Marc Zyngier | 717321f | 2013-11-04 20:14:58 +0000 | [diff] [blame] | 475 | cbnz w24, 1f // preempt count != 0 |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 476 | ldr x0, [tsk, #TI_FLAGS] // get flags |
| 477 | tbz x0, #TIF_NEED_RESCHED, 1f // needs rescheduling? |
| 478 | bl el1_preempt |
| 479 | 1: |
| 480 | #endif |
| 481 | #ifdef CONFIG_TRACE_IRQFLAGS |
| 482 | bl trace_hardirqs_on |
| 483 | #endif |
| 484 | kernel_exit 1 |
| 485 | ENDPROC(el1_irq) |
| 486 | |
| 487 | #ifdef CONFIG_PREEMPT |
| 488 | el1_preempt: |
| 489 | mov x24, lr |
Will Deacon | 2a28307 | 2014-04-29 19:04:06 +0100 | [diff] [blame] | 490 | 1: bl preempt_schedule_irq // irq en/disable is done inside |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 491 | ldr x0, [tsk, #TI_FLAGS] // get new tasks TI_FLAGS |
| 492 | tbnz x0, #TIF_NEED_RESCHED, 1b // needs rescheduling? |
| 493 | ret x24 |
| 494 | #endif |
| 495 | |
| 496 | /* |
| 497 | * EL0 mode handlers. |
| 498 | */ |
| 499 | .align 6 |
| 500 | el0_sync: |
| 501 | kernel_entry 0 |
| 502 | mrs x25, esr_el1 // read the syndrome register |
Mark Rutland | aed40e0 | 2014-11-24 12:31:40 +0000 | [diff] [blame] | 503 | lsr x24, x25, #ESR_ELx_EC_SHIFT // exception class |
| 504 | cmp x24, #ESR_ELx_EC_SVC64 // SVC in 64-bit state |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 505 | b.eq el0_svc |
Mark Rutland | aed40e0 | 2014-11-24 12:31:40 +0000 | [diff] [blame] | 506 | cmp x24, #ESR_ELx_EC_DABT_LOW // data abort in EL0 |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 507 | b.eq el0_da |
Mark Rutland | aed40e0 | 2014-11-24 12:31:40 +0000 | [diff] [blame] | 508 | cmp x24, #ESR_ELx_EC_IABT_LOW // instruction abort in EL0 |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 509 | b.eq el0_ia |
Mark Rutland | aed40e0 | 2014-11-24 12:31:40 +0000 | [diff] [blame] | 510 | cmp x24, #ESR_ELx_EC_FP_ASIMD // FP/ASIMD access |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 511 | b.eq el0_fpsimd_acc |
Mark Rutland | aed40e0 | 2014-11-24 12:31:40 +0000 | [diff] [blame] | 512 | cmp x24, #ESR_ELx_EC_FP_EXC64 // FP/ASIMD exception |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 513 | b.eq el0_fpsimd_exc |
Mark Rutland | aed40e0 | 2014-11-24 12:31:40 +0000 | [diff] [blame] | 514 | cmp x24, #ESR_ELx_EC_SYS64 // configurable trap |
Andre Przywara | 7dd01ae | 2016-06-28 18:07:32 +0100 | [diff] [blame] | 515 | b.eq el0_sys |
Mark Rutland | aed40e0 | 2014-11-24 12:31:40 +0000 | [diff] [blame] | 516 | cmp x24, #ESR_ELx_EC_SP_ALIGN // stack alignment exception |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 517 | b.eq el0_sp_pc |
Mark Rutland | aed40e0 | 2014-11-24 12:31:40 +0000 | [diff] [blame] | 518 | cmp x24, #ESR_ELx_EC_PC_ALIGN // pc alignment exception |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 519 | b.eq el0_sp_pc |
Mark Rutland | aed40e0 | 2014-11-24 12:31:40 +0000 | [diff] [blame] | 520 | cmp x24, #ESR_ELx_EC_UNKNOWN // unknown exception in EL0 |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 521 | b.eq el0_undef |
Mark Rutland | aed40e0 | 2014-11-24 12:31:40 +0000 | [diff] [blame] | 522 | cmp x24, #ESR_ELx_EC_BREAKPT_LOW // debug exception in EL0 |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 523 | b.ge el0_dbg |
| 524 | b el0_inv |
| 525 | |
| 526 | #ifdef CONFIG_COMPAT |
| 527 | .align 6 |
| 528 | el0_sync_compat: |
| 529 | kernel_entry 0, 32 |
| 530 | mrs x25, esr_el1 // read the syndrome register |
Mark Rutland | aed40e0 | 2014-11-24 12:31:40 +0000 | [diff] [blame] | 531 | lsr x24, x25, #ESR_ELx_EC_SHIFT // exception class |
| 532 | cmp x24, #ESR_ELx_EC_SVC32 // SVC in 32-bit state |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 533 | b.eq el0_svc_compat |
Mark Rutland | aed40e0 | 2014-11-24 12:31:40 +0000 | [diff] [blame] | 534 | cmp x24, #ESR_ELx_EC_DABT_LOW // data abort in EL0 |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 535 | b.eq el0_da |
Mark Rutland | aed40e0 | 2014-11-24 12:31:40 +0000 | [diff] [blame] | 536 | cmp x24, #ESR_ELx_EC_IABT_LOW // instruction abort in EL0 |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 537 | b.eq el0_ia |
Mark Rutland | aed40e0 | 2014-11-24 12:31:40 +0000 | [diff] [blame] | 538 | cmp x24, #ESR_ELx_EC_FP_ASIMD // FP/ASIMD access |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 539 | b.eq el0_fpsimd_acc |
Mark Rutland | aed40e0 | 2014-11-24 12:31:40 +0000 | [diff] [blame] | 540 | cmp x24, #ESR_ELx_EC_FP_EXC32 // FP/ASIMD exception |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 541 | b.eq el0_fpsimd_exc |
Mark Salyzyn | 77f3228f | 2015-10-13 14:30:51 -0700 | [diff] [blame] | 542 | cmp x24, #ESR_ELx_EC_PC_ALIGN // pc alignment exception |
| 543 | b.eq el0_sp_pc |
Mark Rutland | aed40e0 | 2014-11-24 12:31:40 +0000 | [diff] [blame] | 544 | cmp x24, #ESR_ELx_EC_UNKNOWN // unknown exception in EL0 |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 545 | b.eq el0_undef |
Mark Rutland | aed40e0 | 2014-11-24 12:31:40 +0000 | [diff] [blame] | 546 | cmp x24, #ESR_ELx_EC_CP15_32 // CP15 MRC/MCR trap |
Mark Rutland | 381cc2b | 2013-05-24 12:02:35 +0100 | [diff] [blame] | 547 | b.eq el0_undef |
Mark Rutland | aed40e0 | 2014-11-24 12:31:40 +0000 | [diff] [blame] | 548 | cmp x24, #ESR_ELx_EC_CP15_64 // CP15 MRRC/MCRR trap |
Mark Rutland | 381cc2b | 2013-05-24 12:02:35 +0100 | [diff] [blame] | 549 | b.eq el0_undef |
Mark Rutland | aed40e0 | 2014-11-24 12:31:40 +0000 | [diff] [blame] | 550 | cmp x24, #ESR_ELx_EC_CP14_MR // CP14 MRC/MCR trap |
Mark Rutland | 381cc2b | 2013-05-24 12:02:35 +0100 | [diff] [blame] | 551 | b.eq el0_undef |
Mark Rutland | aed40e0 | 2014-11-24 12:31:40 +0000 | [diff] [blame] | 552 | cmp x24, #ESR_ELx_EC_CP14_LS // CP14 LDC/STC trap |
Mark Rutland | 381cc2b | 2013-05-24 12:02:35 +0100 | [diff] [blame] | 553 | b.eq el0_undef |
Mark Rutland | aed40e0 | 2014-11-24 12:31:40 +0000 | [diff] [blame] | 554 | cmp x24, #ESR_ELx_EC_CP14_64 // CP14 MRRC/MCRR trap |
Mark Rutland | 381cc2b | 2013-05-24 12:02:35 +0100 | [diff] [blame] | 555 | b.eq el0_undef |
Mark Rutland | aed40e0 | 2014-11-24 12:31:40 +0000 | [diff] [blame] | 556 | cmp x24, #ESR_ELx_EC_BREAKPT_LOW // debug exception in EL0 |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 557 | b.ge el0_dbg |
| 558 | b el0_inv |
| 559 | el0_svc_compat: |
| 560 | /* |
| 561 | * AArch32 syscall handling |
| 562 | */ |
Catalin Marinas | 0156411 | 2015-01-06 16:42:32 +0000 | [diff] [blame] | 563 | adrp stbl, compat_sys_call_table // load compat syscall table pointer |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 564 | uxtw scno, w7 // syscall number in w7 (r7) |
| 565 | mov sc_nr, #__NR_compat_syscalls |
| 566 | b el0_svc_naked |
| 567 | |
| 568 | .align 6 |
| 569 | el0_irq_compat: |
| 570 | kernel_entry 0, 32 |
| 571 | b el0_irq_naked |
| 572 | #endif |
| 573 | |
| 574 | el0_da: |
| 575 | /* |
| 576 | * Data abort handling |
| 577 | */ |
Larry Bassel | 6ab6463 | 2014-05-30 20:34:14 +0100 | [diff] [blame] | 578 | mrs x26, far_el1 |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 579 | // enable interrupts before calling the main handler |
Will Deacon | 2a28307 | 2014-04-29 19:04:06 +0100 | [diff] [blame] | 580 | enable_dbg_and_irq |
Larry Bassel | 6c81fe7 | 2014-05-30 12:34:15 -0700 | [diff] [blame] | 581 | ct_user_exit |
Kristina Martsenko | 9e09d90 | 2017-06-06 20:14:10 +0100 | [diff] [blame] | 582 | clear_address_tag x0, x26 |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 583 | mov x1, x25 |
| 584 | mov x2, sp |
Will Deacon | d54e81f | 2014-09-29 11:44:01 +0100 | [diff] [blame] | 585 | bl do_mem_abort |
| 586 | b ret_to_user |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 587 | el0_ia: |
| 588 | /* |
| 589 | * Instruction abort handling |
| 590 | */ |
Larry Bassel | 6ab6463 | 2014-05-30 20:34:14 +0100 | [diff] [blame] | 591 | mrs x26, far_el1 |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 592 | // enable interrupts before calling the main handler |
Will Deacon | 2a28307 | 2014-04-29 19:04:06 +0100 | [diff] [blame] | 593 | enable_dbg_and_irq |
Larry Bassel | 6c81fe7 | 2014-05-30 12:34:15 -0700 | [diff] [blame] | 594 | ct_user_exit |
Larry Bassel | 6ab6463 | 2014-05-30 20:34:14 +0100 | [diff] [blame] | 595 | mov x0, x26 |
Mark Rutland | 541ec87 | 2016-05-31 12:33:03 +0100 | [diff] [blame] | 596 | mov x1, x25 |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 597 | mov x2, sp |
Will Deacon | d54e81f | 2014-09-29 11:44:01 +0100 | [diff] [blame] | 598 | bl do_mem_abort |
| 599 | b ret_to_user |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 600 | el0_fpsimd_acc: |
| 601 | /* |
| 602 | * Floating Point or Advanced SIMD access |
| 603 | */ |
Will Deacon | 2a28307 | 2014-04-29 19:04:06 +0100 | [diff] [blame] | 604 | enable_dbg |
Larry Bassel | 6c81fe7 | 2014-05-30 12:34:15 -0700 | [diff] [blame] | 605 | ct_user_exit |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 606 | mov x0, x25 |
| 607 | mov x1, sp |
Will Deacon | d54e81f | 2014-09-29 11:44:01 +0100 | [diff] [blame] | 608 | bl do_fpsimd_acc |
| 609 | b ret_to_user |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 610 | el0_fpsimd_exc: |
| 611 | /* |
| 612 | * Floating Point or Advanced SIMD exception |
| 613 | */ |
Will Deacon | 2a28307 | 2014-04-29 19:04:06 +0100 | [diff] [blame] | 614 | enable_dbg |
Larry Bassel | 6c81fe7 | 2014-05-30 12:34:15 -0700 | [diff] [blame] | 615 | ct_user_exit |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 616 | mov x0, x25 |
| 617 | mov x1, sp |
Will Deacon | d54e81f | 2014-09-29 11:44:01 +0100 | [diff] [blame] | 618 | bl do_fpsimd_exc |
| 619 | b ret_to_user |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 620 | el0_sp_pc: |
| 621 | /* |
| 622 | * Stack or PC alignment exception handling |
| 623 | */ |
Larry Bassel | 6ab6463 | 2014-05-30 20:34:14 +0100 | [diff] [blame] | 624 | mrs x26, far_el1 |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 625 | // enable interrupts before calling the main handler |
Will Deacon | 2a28307 | 2014-04-29 19:04:06 +0100 | [diff] [blame] | 626 | enable_dbg_and_irq |
Mark Rutland | 46b0567 | 2015-06-15 16:40:27 +0100 | [diff] [blame] | 627 | ct_user_exit |
Larry Bassel | 6ab6463 | 2014-05-30 20:34:14 +0100 | [diff] [blame] | 628 | mov x0, x26 |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 629 | mov x1, x25 |
| 630 | mov x2, sp |
Will Deacon | d54e81f | 2014-09-29 11:44:01 +0100 | [diff] [blame] | 631 | bl do_sp_pc_abort |
| 632 | b ret_to_user |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 633 | el0_undef: |
| 634 | /* |
| 635 | * Undefined instruction |
| 636 | */ |
Catalin Marinas | 2600e13 | 2013-08-22 11:47:37 +0100 | [diff] [blame] | 637 | // enable interrupts before calling the main handler |
Will Deacon | 2a28307 | 2014-04-29 19:04:06 +0100 | [diff] [blame] | 638 | enable_dbg_and_irq |
Larry Bassel | 6c81fe7 | 2014-05-30 12:34:15 -0700 | [diff] [blame] | 639 | ct_user_exit |
Will Deacon | 2a28307 | 2014-04-29 19:04:06 +0100 | [diff] [blame] | 640 | mov x0, sp |
Will Deacon | d54e81f | 2014-09-29 11:44:01 +0100 | [diff] [blame] | 641 | bl do_undefinstr |
| 642 | b ret_to_user |
Andre Przywara | 7dd01ae | 2016-06-28 18:07:32 +0100 | [diff] [blame] | 643 | el0_sys: |
| 644 | /* |
| 645 | * System instructions, for trapped cache maintenance instructions |
| 646 | */ |
| 647 | enable_dbg_and_irq |
| 648 | ct_user_exit |
| 649 | mov x0, x25 |
| 650 | mov x1, sp |
| 651 | bl do_sysinstr |
| 652 | b ret_to_user |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 653 | el0_dbg: |
| 654 | /* |
| 655 | * Debug exception handling |
| 656 | */ |
| 657 | tbnz x24, #0, el0_inv // EL0 only |
| 658 | mrs x0, far_el1 |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 659 | mov x1, x25 |
| 660 | mov x2, sp |
Will Deacon | 2a28307 | 2014-04-29 19:04:06 +0100 | [diff] [blame] | 661 | bl do_debug_exception |
| 662 | enable_dbg |
Larry Bassel | 6c81fe7 | 2014-05-30 12:34:15 -0700 | [diff] [blame] | 663 | ct_user_exit |
Will Deacon | 2a28307 | 2014-04-29 19:04:06 +0100 | [diff] [blame] | 664 | b ret_to_user |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 665 | el0_inv: |
Will Deacon | 2a28307 | 2014-04-29 19:04:06 +0100 | [diff] [blame] | 666 | enable_dbg |
Larry Bassel | 6c81fe7 | 2014-05-30 12:34:15 -0700 | [diff] [blame] | 667 | ct_user_exit |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 668 | mov x0, sp |
| 669 | mov x1, #BAD_SYNC |
Mark Rutland | 1b42804 | 2015-07-07 18:00:49 +0100 | [diff] [blame] | 670 | mov x2, x25 |
Mark Rutland | de32794 | 2017-01-18 17:23:41 +0000 | [diff] [blame] | 671 | bl bad_el0_sync |
Will Deacon | d54e81f | 2014-09-29 11:44:01 +0100 | [diff] [blame] | 672 | b ret_to_user |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 673 | ENDPROC(el0_sync) |
| 674 | |
| 675 | .align 6 |
| 676 | el0_irq: |
| 677 | kernel_entry 0 |
| 678 | el0_irq_naked: |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 679 | enable_dbg |
| 680 | #ifdef CONFIG_TRACE_IRQFLAGS |
| 681 | bl trace_hardirqs_off |
| 682 | #endif |
Marc Zyngier | 6468178 | 2013-11-12 17:11:53 +0000 | [diff] [blame] | 683 | |
Larry Bassel | 6c81fe7 | 2014-05-30 12:34:15 -0700 | [diff] [blame] | 684 | ct_user_exit |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 685 | irq_handler |
Marc Zyngier | 6468178 | 2013-11-12 17:11:53 +0000 | [diff] [blame] | 686 | |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 687 | #ifdef CONFIG_TRACE_IRQFLAGS |
| 688 | bl trace_hardirqs_on |
| 689 | #endif |
| 690 | b ret_to_user |
| 691 | ENDPROC(el0_irq) |
| 692 | |
| 693 | /* |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 694 | * Register switch for AArch64. The callee-saved registers need to be saved |
| 695 | * and restored. On entry: |
| 696 | * x0 = previous task_struct (must be preserved across the switch) |
| 697 | * x1 = next task_struct |
| 698 | * Previous and next are guaranteed not to be the same. |
| 699 | * |
| 700 | */ |
| 701 | ENTRY(cpu_switch_to) |
Will Deacon | c0d3fce | 2015-07-20 15:14:53 +0100 | [diff] [blame] | 702 | mov x10, #THREAD_CPU_CONTEXT |
| 703 | add x8, x0, x10 |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 704 | mov x9, sp |
| 705 | stp x19, x20, [x8], #16 // store callee-saved registers |
| 706 | stp x21, x22, [x8], #16 |
| 707 | stp x23, x24, [x8], #16 |
| 708 | stp x25, x26, [x8], #16 |
| 709 | stp x27, x28, [x8], #16 |
| 710 | stp x29, x9, [x8], #16 |
| 711 | str lr, [x8] |
Will Deacon | c0d3fce | 2015-07-20 15:14:53 +0100 | [diff] [blame] | 712 | add x8, x1, x10 |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 713 | ldp x19, x20, [x8], #16 // restore callee-saved registers |
| 714 | ldp x21, x22, [x8], #16 |
| 715 | ldp x23, x24, [x8], #16 |
| 716 | ldp x25, x26, [x8], #16 |
| 717 | ldp x27, x28, [x8], #16 |
| 718 | ldp x29, x9, [x8], #16 |
| 719 | ldr lr, [x8] |
| 720 | mov sp, x9 |
Jungseok Lee | 6cdf9c7 | 2015-12-04 11:02:25 +0000 | [diff] [blame] | 721 | and x9, x9, #~(THREAD_SIZE - 1) |
| 722 | msr sp_el0, x9 |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 723 | ret |
| 724 | ENDPROC(cpu_switch_to) |
| 725 | |
| 726 | /* |
| 727 | * This is the fast syscall return path. We do as little as possible here, |
| 728 | * and this includes saving x0 back into the kernel stack. |
| 729 | */ |
| 730 | ret_fast_syscall: |
| 731 | disable_irq // disable interrupts |
Will Deacon | 412fcb6 | 2015-08-19 15:57:09 +0100 | [diff] [blame] | 732 | str x0, [sp, #S_X0] // returned x0 |
Josh Stone | 04d7e09 | 2015-06-05 14:28:03 -0700 | [diff] [blame] | 733 | ldr x1, [tsk, #TI_FLAGS] // re-check for syscall tracing |
| 734 | and x2, x1, #_TIF_SYSCALL_WORK |
| 735 | cbnz x2, ret_fast_syscall_trace |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 736 | and x2, x1, #_TIF_WORK_MASK |
Will Deacon | 412fcb6 | 2015-08-19 15:57:09 +0100 | [diff] [blame] | 737 | cbnz x2, work_pending |
Will Deacon | 2a28307 | 2014-04-29 19:04:06 +0100 | [diff] [blame] | 738 | enable_step_tsk x1, x2 |
Will Deacon | 412fcb6 | 2015-08-19 15:57:09 +0100 | [diff] [blame] | 739 | kernel_exit 0 |
Josh Stone | 04d7e09 | 2015-06-05 14:28:03 -0700 | [diff] [blame] | 740 | ret_fast_syscall_trace: |
| 741 | enable_irq // enable interrupts |
Will Deacon | 412fcb6 | 2015-08-19 15:57:09 +0100 | [diff] [blame] | 742 | b __sys_trace_return_skipped // we already saved x0 |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 743 | |
| 744 | /* |
| 745 | * Ok, we need to do extra processing, enter the slow path. |
| 746 | */ |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 747 | work_pending: |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 748 | mov x0, sp // 'regs' |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 749 | bl do_notify_resume |
Catalin Marinas | db3899a | 2015-12-04 12:42:29 +0000 | [diff] [blame] | 750 | #ifdef CONFIG_TRACE_IRQFLAGS |
Chris Metcalf | 421dd6f | 2016-07-14 16:48:14 -0400 | [diff] [blame] | 751 | bl trace_hardirqs_on // enabled while in userspace |
Catalin Marinas | db3899a | 2015-12-04 12:42:29 +0000 | [diff] [blame] | 752 | #endif |
Chris Metcalf | 421dd6f | 2016-07-14 16:48:14 -0400 | [diff] [blame] | 753 | ldr x1, [tsk, #TI_FLAGS] // re-check for single-step |
| 754 | b finish_ret_to_user |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 755 | /* |
| 756 | * "slow" syscall return path. |
| 757 | */ |
Catalin Marinas | 59dc67b | 2012-09-10 16:11:46 +0100 | [diff] [blame] | 758 | ret_to_user: |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 759 | disable_irq // disable interrupts |
| 760 | ldr x1, [tsk, #TI_FLAGS] |
| 761 | and x2, x1, #_TIF_WORK_MASK |
| 762 | cbnz x2, work_pending |
Chris Metcalf | 421dd6f | 2016-07-14 16:48:14 -0400 | [diff] [blame] | 763 | finish_ret_to_user: |
Will Deacon | 2a28307 | 2014-04-29 19:04:06 +0100 | [diff] [blame] | 764 | enable_step_tsk x1, x2 |
Will Deacon | 412fcb6 | 2015-08-19 15:57:09 +0100 | [diff] [blame] | 765 | kernel_exit 0 |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 766 | ENDPROC(ret_to_user) |
| 767 | |
| 768 | /* |
| 769 | * This is how we return from a fork. |
| 770 | */ |
| 771 | ENTRY(ret_from_fork) |
| 772 | bl schedule_tail |
Catalin Marinas | c34501d | 2012-10-05 12:31:20 +0100 | [diff] [blame] | 773 | cbz x19, 1f // not a kernel thread |
| 774 | mov x0, x20 |
| 775 | blr x19 |
| 776 | 1: get_thread_info tsk |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 777 | b ret_to_user |
| 778 | ENDPROC(ret_from_fork) |
| 779 | |
| 780 | /* |
| 781 | * SVC handler. |
| 782 | */ |
| 783 | .align 6 |
| 784 | el0_svc: |
| 785 | adrp stbl, sys_call_table // load syscall table pointer |
| 786 | uxtw scno, w8 // syscall number in w8 |
| 787 | mov sc_nr, #__NR_syscalls |
| 788 | el0_svc_naked: // compat entry point |
| 789 | stp x0, scno, [sp, #S_ORIG_X0] // save the original x0 and syscall number |
Will Deacon | 2a28307 | 2014-04-29 19:04:06 +0100 | [diff] [blame] | 790 | enable_dbg_and_irq |
Larry Bassel | 6c81fe7 | 2014-05-30 12:34:15 -0700 | [diff] [blame] | 791 | ct_user_exit 1 |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 792 | |
AKASHI Takahiro | 449f81a | 2014-04-30 10:51:29 +0100 | [diff] [blame] | 793 | ldr x16, [tsk, #TI_FLAGS] // check for syscall hooks |
| 794 | tst x16, #_TIF_SYSCALL_WORK |
| 795 | b.ne __sys_trace |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 796 | cmp scno, sc_nr // check upper syscall limit |
| 797 | b.hs ni_sys |
| 798 | ldr x16, [stbl, scno, lsl #3] // address in the syscall table |
Will Deacon | d54e81f | 2014-09-29 11:44:01 +0100 | [diff] [blame] | 799 | blr x16 // call sys_* routine |
| 800 | b ret_fast_syscall |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 801 | ni_sys: |
| 802 | mov x0, sp |
Will Deacon | d54e81f | 2014-09-29 11:44:01 +0100 | [diff] [blame] | 803 | bl do_ni_syscall |
| 804 | b ret_fast_syscall |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 805 | ENDPROC(el0_svc) |
| 806 | |
| 807 | /* |
| 808 | * This is the really slow path. We're going to be doing context |
| 809 | * switches, and waiting for our parent to respond. |
| 810 | */ |
| 811 | __sys_trace: |
AKASHI Takahiro | 1014c81 | 2014-11-28 05:26:35 +0000 | [diff] [blame] | 812 | mov w0, #-1 // set default errno for |
| 813 | cmp scno, x0 // user-issued syscall(-1) |
| 814 | b.ne 1f |
| 815 | mov x0, #-ENOSYS |
| 816 | str x0, [sp, #S_X0] |
| 817 | 1: mov x0, sp |
AKASHI Takahiro | 3157858 | 2014-04-30 10:51:30 +0100 | [diff] [blame] | 818 | bl syscall_trace_enter |
AKASHI Takahiro | 1014c81 | 2014-11-28 05:26:35 +0000 | [diff] [blame] | 819 | cmp w0, #-1 // skip the syscall? |
| 820 | b.eq __sys_trace_return_skipped |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 821 | uxtw scno, w0 // syscall number (possibly new) |
| 822 | mov x1, sp // pointer to regs |
| 823 | cmp scno, sc_nr // check upper syscall limit |
Will Deacon | d54e81f | 2014-09-29 11:44:01 +0100 | [diff] [blame] | 824 | b.hs __ni_sys_trace |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 825 | ldp x0, x1, [sp] // restore the syscall args |
| 826 | ldp x2, x3, [sp, #S_X2] |
| 827 | ldp x4, x5, [sp, #S_X4] |
| 828 | ldp x6, x7, [sp, #S_X6] |
| 829 | ldr x16, [stbl, scno, lsl #3] // address in the syscall table |
Will Deacon | d54e81f | 2014-09-29 11:44:01 +0100 | [diff] [blame] | 830 | blr x16 // call sys_* routine |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 831 | |
| 832 | __sys_trace_return: |
AKASHI Takahiro | 1014c81 | 2014-11-28 05:26:35 +0000 | [diff] [blame] | 833 | str x0, [sp, #S_X0] // save returned x0 |
| 834 | __sys_trace_return_skipped: |
AKASHI Takahiro | 3157858 | 2014-04-30 10:51:30 +0100 | [diff] [blame] | 835 | mov x0, sp |
| 836 | bl syscall_trace_exit |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 837 | b ret_to_user |
| 838 | |
Will Deacon | d54e81f | 2014-09-29 11:44:01 +0100 | [diff] [blame] | 839 | __ni_sys_trace: |
| 840 | mov x0, sp |
| 841 | bl do_ni_syscall |
| 842 | b __sys_trace_return |
| 843 | |
Pratyush Anand | 888b3c8 | 2016-07-08 12:35:50 -0400 | [diff] [blame] | 844 | .popsection // .entry.text |
| 845 | |
Will Deacon | 78a0cec | 2018-04-03 12:09:04 +0100 | [diff] [blame] | 846 | #ifdef CONFIG_UNMAP_KERNEL_AT_EL0 |
| 847 | /* |
| 848 | * Exception vectors trampoline. |
| 849 | */ |
| 850 | .pushsection ".entry.tramp.text", "ax" |
| 851 | |
| 852 | .macro tramp_map_kernel, tmp |
| 853 | mrs \tmp, ttbr1_el1 |
| 854 | sub \tmp, \tmp, #SWAPPER_DIR_SIZE |
| 855 | bic \tmp, \tmp, #USER_ASID_FLAG |
| 856 | msr ttbr1_el1, \tmp |
| 857 | .endm |
| 858 | |
| 859 | .macro tramp_unmap_kernel, tmp |
| 860 | mrs \tmp, ttbr1_el1 |
| 861 | add \tmp, \tmp, #SWAPPER_DIR_SIZE |
| 862 | orr \tmp, \tmp, #USER_ASID_FLAG |
| 863 | msr ttbr1_el1, \tmp |
| 864 | /* |
Will Deacon | a80d8e2 | 2018-04-03 12:09:22 +0100 | [diff] [blame] | 865 | * We avoid running the post_ttbr_update_workaround here because |
| 866 | * it's only needed by Cavium ThunderX, which requires KPTI to be |
| 867 | * disabled. |
Will Deacon | 78a0cec | 2018-04-03 12:09:04 +0100 | [diff] [blame] | 868 | */ |
| 869 | .endm |
| 870 | |
| 871 | .macro tramp_ventry, regsize = 64 |
| 872 | .align 7 |
| 873 | 1: |
| 874 | .if \regsize == 64 |
| 875 | msr tpidrro_el0, x30 // Restored in kernel_ventry |
| 876 | .endif |
Will Deacon | f6af532 | 2018-04-03 12:09:11 +0100 | [diff] [blame] | 877 | /* |
| 878 | * Defend against branch aliasing attacks by pushing a dummy |
| 879 | * entry onto the return stack and using a RET instruction to |
| 880 | * enter the full-fat kernel vectors. |
| 881 | */ |
| 882 | bl 2f |
| 883 | b . |
| 884 | 2: |
Will Deacon | 78a0cec | 2018-04-03 12:09:04 +0100 | [diff] [blame] | 885 | tramp_map_kernel x30 |
Will Deacon | 9675042 | 2018-04-03 12:09:10 +0100 | [diff] [blame] | 886 | #ifdef CONFIG_RANDOMIZE_BASE |
| 887 | adr x30, tramp_vectors + PAGE_SIZE |
| 888 | isb |
| 889 | ldr x30, [x30] |
| 890 | #else |
Will Deacon | 78a0cec | 2018-04-03 12:09:04 +0100 | [diff] [blame] | 891 | ldr x30, =vectors |
Will Deacon | 9675042 | 2018-04-03 12:09:10 +0100 | [diff] [blame] | 892 | #endif |
Will Deacon | 78a0cec | 2018-04-03 12:09:04 +0100 | [diff] [blame] | 893 | prfm plil1strm, [x30, #(1b - tramp_vectors)] |
| 894 | msr vbar_el1, x30 |
| 895 | add x30, x30, #(1b - tramp_vectors) |
| 896 | isb |
Will Deacon | f6af532 | 2018-04-03 12:09:11 +0100 | [diff] [blame] | 897 | ret |
Will Deacon | 78a0cec | 2018-04-03 12:09:04 +0100 | [diff] [blame] | 898 | .endm |
| 899 | |
| 900 | .macro tramp_exit, regsize = 64 |
| 901 | adr x30, tramp_vectors |
| 902 | msr vbar_el1, x30 |
| 903 | tramp_unmap_kernel x30 |
| 904 | .if \regsize == 64 |
| 905 | mrs x30, far_el1 |
| 906 | .endif |
| 907 | eret |
| 908 | .endm |
| 909 | |
| 910 | .align 11 |
| 911 | ENTRY(tramp_vectors) |
| 912 | .space 0x400 |
| 913 | |
| 914 | tramp_ventry |
| 915 | tramp_ventry |
| 916 | tramp_ventry |
| 917 | tramp_ventry |
| 918 | |
| 919 | tramp_ventry 32 |
| 920 | tramp_ventry 32 |
| 921 | tramp_ventry 32 |
| 922 | tramp_ventry 32 |
| 923 | END(tramp_vectors) |
| 924 | |
| 925 | ENTRY(tramp_exit_native) |
| 926 | tramp_exit |
| 927 | END(tramp_exit_native) |
| 928 | |
| 929 | ENTRY(tramp_exit_compat) |
| 930 | tramp_exit 32 |
| 931 | END(tramp_exit_compat) |
| 932 | |
| 933 | .ltorg |
| 934 | .popsection // .entry.tramp.text |
Will Deacon | 9675042 | 2018-04-03 12:09:10 +0100 | [diff] [blame] | 935 | #ifdef CONFIG_RANDOMIZE_BASE |
| 936 | .pushsection ".rodata", "a" |
| 937 | .align PAGE_SHIFT |
| 938 | .globl __entry_tramp_data_start |
| 939 | __entry_tramp_data_start: |
| 940 | .quad vectors |
| 941 | .popsection // .rodata |
| 942 | #endif /* CONFIG_RANDOMIZE_BASE */ |
Will Deacon | 78a0cec | 2018-04-03 12:09:04 +0100 | [diff] [blame] | 943 | #endif /* CONFIG_UNMAP_KERNEL_AT_EL0 */ |
| 944 | |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 945 | /* |
| 946 | * Special system call wrappers. |
| 947 | */ |
Catalin Marinas | 60ffc30 | 2012-03-05 11:49:27 +0000 | [diff] [blame] | 948 | ENTRY(sys_rt_sigreturn_wrapper) |
| 949 | mov x0, sp |
| 950 | b sys_rt_sigreturn |
| 951 | ENDPROC(sys_rt_sigreturn_wrapper) |