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