Isla Mitchell | ea84d6b | 2017-08-03 16:04:46 +0100 | [diff] [blame] | 1 | /* |
Anthony Steinhauser | 0f7e601 | 2020-01-07 15:44:06 -0800 | [diff] [blame] | 2 | * Copyright (c) 2017-2020, ARM Limited and Contributors. All rights reserved. |
Isla Mitchell | ea84d6b | 2017-08-03 16:04:46 +0100 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #include <arch.h> |
| 8 | #include <asm_macros.S> |
John Tsichritzis | 56369c1 | 2019-02-19 13:49:06 +0000 | [diff] [blame] | 9 | #include <neoverse_n1.h> |
Dimitris Papastamos | 89736dd | 2018-02-13 11:28:02 +0000 | [diff] [blame] | 10 | #include <cpuamu.h> |
Isla Mitchell | ea84d6b | 2017-08-03 16:04:46 +0100 | [diff] [blame] | 11 | #include <cpu_macros.S> |
laurenw-arm | 94accd3 | 2019-08-20 15:51:24 -0500 | [diff] [blame] | 12 | #include <context.h> |
Dimitris Papastamos | 89736dd | 2018-02-13 11:28:02 +0000 | [diff] [blame] | 13 | |
John Tsichritzis | fe6df39 | 2019-03-19 17:20:52 +0000 | [diff] [blame] | 14 | /* Hardware handled coherency */ |
| 15 | #if HW_ASSISTED_COHERENCY == 0 |
| 16 | #error "Neoverse N1 must be compiled with HW_ASSISTED_COHERENCY enabled" |
| 17 | #endif |
| 18 | |
John Tsichritzis | 7557c66 | 2019-06-03 13:54:30 +0100 | [diff] [blame] | 19 | /* 64-bit only core */ |
| 20 | #if CTX_INCLUDE_AARCH32_REGS == 1 |
| 21 | #error "Neoverse-N1 supports only AArch64. Compile with CTX_INCLUDE_AARCH32_REGS=0" |
| 22 | #endif |
| 23 | |
laurenw-arm | 94accd3 | 2019-08-20 15:51:24 -0500 | [diff] [blame] | 24 | .global neoverse_n1_errata_ic_trap_handler |
laurenw-arm | 94accd3 | 2019-08-20 15:51:24 -0500 | [diff] [blame] | 25 | |
Dimitris Papastamos | 7ca21db | 2018-03-26 16:46:01 +0100 | [diff] [blame] | 26 | /* -------------------------------------------------- |
Andre Przywara | b934740 | 2019-05-20 14:57:06 +0100 | [diff] [blame] | 27 | * Errata Workaround for Neoverse N1 Erratum 1043202. |
John Tsichritzis | 56369c1 | 2019-02-19 13:49:06 +0000 | [diff] [blame] | 28 | * This applies to revision r0p0 and r1p0 of Neoverse N1. |
Dimitris Papastamos | 7ca21db | 2018-03-26 16:46:01 +0100 | [diff] [blame] | 29 | * Inputs: |
| 30 | * x0: variant[4:7] and revision[0:3] of current cpu. |
| 31 | * Shall clobber: x0-x17 |
| 32 | * -------------------------------------------------- |
| 33 | */ |
John Tsichritzis | 56369c1 | 2019-02-19 13:49:06 +0000 | [diff] [blame] | 34 | func errata_n1_1043202_wa |
Dimitris Papastamos | 7ca21db | 2018-03-26 16:46:01 +0100 | [diff] [blame] | 35 | /* Compare x0 against revision r1p0 */ |
| 36 | mov x17, x30 |
| 37 | bl check_errata_1043202 |
| 38 | cbz x0, 1f |
| 39 | |
| 40 | /* Apply instruction patching sequence */ |
| 41 | ldr x0, =0x0 |
| 42 | msr CPUPSELR_EL3, x0 |
| 43 | ldr x0, =0xF3BF8F2F |
| 44 | msr CPUPOR_EL3, x0 |
| 45 | ldr x0, =0xFFFFFFFF |
| 46 | msr CPUPMR_EL3, x0 |
| 47 | ldr x0, =0x800200071 |
| 48 | msr CPUPCR_EL3, x0 |
laurenw-arm | 33e58f3 | 2019-08-19 11:06:18 -0500 | [diff] [blame] | 49 | isb |
Dimitris Papastamos | 7ca21db | 2018-03-26 16:46:01 +0100 | [diff] [blame] | 50 | 1: |
| 51 | ret x17 |
John Tsichritzis | 56369c1 | 2019-02-19 13:49:06 +0000 | [diff] [blame] | 52 | endfunc errata_n1_1043202_wa |
Dimitris Papastamos | 7ca21db | 2018-03-26 16:46:01 +0100 | [diff] [blame] | 53 | |
| 54 | func check_errata_1043202 |
| 55 | /* Applies to r0p0 and r1p0 */ |
| 56 | mov x1, #0x10 |
| 57 | b cpu_rev_var_ls |
| 58 | endfunc check_errata_1043202 |
| 59 | |
Sami Mujawar | a8722e9 | 2019-05-10 14:28:37 +0100 | [diff] [blame] | 60 | /* -------------------------------------------------- |
| 61 | * Disable speculative loads if Neoverse N1 supports |
| 62 | * SSBS. |
| 63 | * |
| 64 | * Shall clobber: x0. |
| 65 | * -------------------------------------------------- |
| 66 | */ |
| 67 | func neoverse_n1_disable_speculative_loads |
| 68 | /* Check if the PE implements SSBS */ |
| 69 | mrs x0, id_aa64pfr1_el1 |
| 70 | tst x0, #(ID_AA64PFR1_EL1_SSBS_MASK << ID_AA64PFR1_EL1_SSBS_SHIFT) |
| 71 | b.eq 1f |
| 72 | |
| 73 | /* Disable speculative loads */ |
| 74 | msr SSBS, xzr |
Sami Mujawar | a8722e9 | 2019-05-10 14:28:37 +0100 | [diff] [blame] | 75 | |
| 76 | 1: |
| 77 | ret |
| 78 | endfunc neoverse_n1_disable_speculative_loads |
| 79 | |
Andre Przywara | b934740 | 2019-05-20 14:57:06 +0100 | [diff] [blame] | 80 | /* -------------------------------------------------- |
lauwal01 | bd555f4 | 2019-06-24 11:23:50 -0500 | [diff] [blame] | 81 | * Errata Workaround for Neoverse N1 Errata #1073348 |
| 82 | * This applies to revision r0p0 and r1p0 of Neoverse N1. |
| 83 | * Inputs: |
| 84 | * x0: variant[4:7] and revision[0:3] of current cpu. |
| 85 | * Shall clobber: x0-x17 |
| 86 | * -------------------------------------------------- |
| 87 | */ |
| 88 | func errata_n1_1073348_wa |
| 89 | /* Compare x0 against revision r1p0 */ |
| 90 | mov x17, x30 |
| 91 | bl check_errata_1073348 |
| 92 | cbz x0, 1f |
| 93 | mrs x1, NEOVERSE_N1_CPUACTLR_EL1 |
| 94 | orr x1, x1, NEOVERSE_N1_CPUACTLR_EL1_BIT_6 |
| 95 | msr NEOVERSE_N1_CPUACTLR_EL1, x1 |
lauwal01 | bd555f4 | 2019-06-24 11:23:50 -0500 | [diff] [blame] | 96 | 1: |
| 97 | ret x17 |
| 98 | endfunc errata_n1_1073348_wa |
| 99 | |
| 100 | func check_errata_1073348 |
| 101 | /* Applies to r0p0 and r1p0 */ |
| 102 | mov x1, #0x10 |
| 103 | b cpu_rev_var_ls |
| 104 | endfunc check_errata_1073348 |
| 105 | |
| 106 | /* -------------------------------------------------- |
lauwal01 | 363ee3c | 2019-06-24 11:28:34 -0500 | [diff] [blame] | 107 | * Errata Workaround for Neoverse N1 Errata #1130799 |
| 108 | * This applies to revision <=r2p0 of Neoverse N1. |
| 109 | * Inputs: |
| 110 | * x0: variant[4:7] and revision[0:3] of current cpu. |
| 111 | * Shall clobber: x0-x17 |
| 112 | * -------------------------------------------------- |
| 113 | */ |
| 114 | func errata_n1_1130799_wa |
| 115 | /* Compare x0 against revision r2p0 */ |
| 116 | mov x17, x30 |
| 117 | bl check_errata_1130799 |
| 118 | cbz x0, 1f |
| 119 | mrs x1, NEOVERSE_N1_CPUACTLR2_EL1 |
| 120 | orr x1, x1, NEOVERSE_N1_CPUACTLR2_EL1_BIT_59 |
| 121 | msr NEOVERSE_N1_CPUACTLR2_EL1, x1 |
lauwal01 | 363ee3c | 2019-06-24 11:28:34 -0500 | [diff] [blame] | 122 | 1: |
| 123 | ret x17 |
| 124 | endfunc errata_n1_1130799_wa |
| 125 | |
| 126 | func check_errata_1130799 |
| 127 | /* Applies to <=r2p0 */ |
| 128 | mov x1, #0x20 |
| 129 | b cpu_rev_var_ls |
| 130 | endfunc check_errata_1130799 |
| 131 | |
| 132 | /* -------------------------------------------------- |
lauwal01 | f2adb13 | 2019-06-24 11:32:40 -0500 | [diff] [blame] | 133 | * Errata Workaround for Neoverse N1 Errata #1165347 |
| 134 | * This applies to revision <=r2p0 of Neoverse N1. |
| 135 | * Inputs: |
| 136 | * x0: variant[4:7] and revision[0:3] of current cpu. |
| 137 | * Shall clobber: x0-x17 |
| 138 | * -------------------------------------------------- |
| 139 | */ |
| 140 | func errata_n1_1165347_wa |
| 141 | /* Compare x0 against revision r2p0 */ |
| 142 | mov x17, x30 |
| 143 | bl check_errata_1165347 |
| 144 | cbz x0, 1f |
| 145 | mrs x1, NEOVERSE_N1_CPUACTLR2_EL1 |
| 146 | orr x1, x1, NEOVERSE_N1_CPUACTLR2_EL1_BIT_0 |
| 147 | orr x1, x1, NEOVERSE_N1_CPUACTLR2_EL1_BIT_15 |
| 148 | msr NEOVERSE_N1_CPUACTLR2_EL1, x1 |
lauwal01 | f2adb13 | 2019-06-24 11:32:40 -0500 | [diff] [blame] | 149 | 1: |
| 150 | ret x17 |
| 151 | endfunc errata_n1_1165347_wa |
| 152 | |
| 153 | func check_errata_1165347 |
| 154 | /* Applies to <=r2p0 */ |
| 155 | mov x1, #0x20 |
| 156 | b cpu_rev_var_ls |
| 157 | endfunc check_errata_1165347 |
| 158 | |
| 159 | /* -------------------------------------------------- |
lauwal01 | e159044 | 2019-06-24 11:35:37 -0500 | [diff] [blame] | 160 | * Errata Workaround for Neoverse N1 Errata #1207823 |
| 161 | * This applies to revision <=r2p0 of Neoverse N1. |
| 162 | * Inputs: |
| 163 | * x0: variant[4:7] and revision[0:3] of current cpu. |
| 164 | * Shall clobber: x0-x17 |
| 165 | * -------------------------------------------------- |
| 166 | */ |
| 167 | func errata_n1_1207823_wa |
| 168 | /* Compare x0 against revision r2p0 */ |
| 169 | mov x17, x30 |
| 170 | bl check_errata_1207823 |
| 171 | cbz x0, 1f |
| 172 | mrs x1, NEOVERSE_N1_CPUACTLR2_EL1 |
| 173 | orr x1, x1, NEOVERSE_N1_CPUACTLR2_EL1_BIT_11 |
| 174 | msr NEOVERSE_N1_CPUACTLR2_EL1, x1 |
lauwal01 | e159044 | 2019-06-24 11:35:37 -0500 | [diff] [blame] | 175 | 1: |
| 176 | ret x17 |
| 177 | endfunc errata_n1_1207823_wa |
| 178 | |
| 179 | func check_errata_1207823 |
| 180 | /* Applies to <=r2p0 */ |
| 181 | mov x1, #0x20 |
| 182 | b cpu_rev_var_ls |
| 183 | endfunc check_errata_1207823 |
| 184 | |
| 185 | /* -------------------------------------------------- |
lauwal01 | 197f14c | 2019-06-24 11:38:53 -0500 | [diff] [blame] | 186 | * Errata Workaround for Neoverse N1 Errata #1220197 |
| 187 | * This applies to revision <=r2p0 of Neoverse N1. |
| 188 | * Inputs: |
| 189 | * x0: variant[4:7] and revision[0:3] of current cpu. |
| 190 | * Shall clobber: x0-x17 |
| 191 | * -------------------------------------------------- |
| 192 | */ |
| 193 | func errata_n1_1220197_wa |
| 194 | /* Compare x0 against revision r2p0 */ |
| 195 | mov x17, x30 |
| 196 | bl check_errata_1220197 |
| 197 | cbz x0, 1f |
| 198 | mrs x1, NEOVERSE_N1_CPUECTLR_EL1 |
| 199 | orr x1, x1, NEOVERSE_N1_WS_THR_L2_MASK |
| 200 | msr NEOVERSE_N1_CPUECTLR_EL1, x1 |
lauwal01 | 197f14c | 2019-06-24 11:38:53 -0500 | [diff] [blame] | 201 | 1: |
| 202 | ret x17 |
| 203 | endfunc errata_n1_1220197_wa |
| 204 | |
| 205 | func check_errata_1220197 |
| 206 | /* Applies to <=r2p0 */ |
| 207 | mov x1, #0x20 |
| 208 | b cpu_rev_var_ls |
| 209 | endfunc check_errata_1220197 |
| 210 | |
| 211 | /* -------------------------------------------------- |
lauwal01 | 07c2a23 | 2019-06-24 11:42:02 -0500 | [diff] [blame] | 212 | * Errata Workaround for Neoverse N1 Errata #1257314 |
| 213 | * This applies to revision <=r3p0 of Neoverse N1. |
| 214 | * Inputs: |
| 215 | * x0: variant[4:7] and revision[0:3] of current cpu. |
| 216 | * Shall clobber: x0-x17 |
| 217 | * -------------------------------------------------- |
| 218 | */ |
| 219 | func errata_n1_1257314_wa |
| 220 | /* Compare x0 against revision r3p0 */ |
| 221 | mov x17, x30 |
| 222 | bl check_errata_1257314 |
| 223 | cbz x0, 1f |
| 224 | mrs x1, NEOVERSE_N1_CPUACTLR3_EL1 |
| 225 | orr x1, x1, NEOVERSE_N1_CPUACTLR3_EL1_BIT_10 |
| 226 | msr NEOVERSE_N1_CPUACTLR3_EL1, x1 |
lauwal01 | 07c2a23 | 2019-06-24 11:42:02 -0500 | [diff] [blame] | 227 | 1: |
| 228 | ret x17 |
| 229 | endfunc errata_n1_1257314_wa |
| 230 | |
| 231 | func check_errata_1257314 |
| 232 | /* Applies to <=r3p0 */ |
| 233 | mov x1, #0x30 |
| 234 | b cpu_rev_var_ls |
| 235 | endfunc check_errata_1257314 |
| 236 | |
| 237 | /* -------------------------------------------------- |
lauwal01 | 42771af | 2019-06-24 11:44:58 -0500 | [diff] [blame] | 238 | * Errata Workaround for Neoverse N1 Errata #1262606 |
| 239 | * This applies to revision <=r3p0 of Neoverse N1. |
| 240 | * Inputs: |
| 241 | * x0: variant[4:7] and revision[0:3] of current cpu. |
| 242 | * Shall clobber: x0-x17 |
| 243 | * -------------------------------------------------- |
| 244 | */ |
| 245 | func errata_n1_1262606_wa |
| 246 | /* Compare x0 against revision r3p0 */ |
| 247 | mov x17, x30 |
| 248 | bl check_errata_1262606 |
| 249 | cbz x0, 1f |
| 250 | mrs x1, NEOVERSE_N1_CPUACTLR_EL1 |
| 251 | orr x1, x1, NEOVERSE_N1_CPUACTLR_EL1_BIT_13 |
| 252 | msr NEOVERSE_N1_CPUACTLR_EL1, x1 |
lauwal01 | 42771af | 2019-06-24 11:44:58 -0500 | [diff] [blame] | 253 | 1: |
| 254 | ret x17 |
| 255 | endfunc errata_n1_1262606_wa |
| 256 | |
| 257 | func check_errata_1262606 |
| 258 | /* Applies to <=r3p0 */ |
| 259 | mov x1, #0x30 |
| 260 | b cpu_rev_var_ls |
| 261 | endfunc check_errata_1262606 |
| 262 | |
| 263 | /* -------------------------------------------------- |
lauwal01 | 00396bf | 2019-06-24 11:47:30 -0500 | [diff] [blame] | 264 | * Errata Workaround for Neoverse N1 Errata #1262888 |
| 265 | * This applies to revision <=r3p0 of Neoverse N1. |
| 266 | * Inputs: |
| 267 | * x0: variant[4:7] and revision[0:3] of current cpu. |
| 268 | * Shall clobber: x0-x17 |
| 269 | * -------------------------------------------------- |
| 270 | */ |
| 271 | func errata_n1_1262888_wa |
| 272 | /* Compare x0 against revision r3p0 */ |
| 273 | mov x17, x30 |
| 274 | bl check_errata_1262888 |
| 275 | cbz x0, 1f |
| 276 | mrs x1, NEOVERSE_N1_CPUECTLR_EL1 |
| 277 | orr x1, x1, NEOVERSE_N1_CPUECTLR_EL1_MM_TLBPF_DIS_BIT |
| 278 | msr NEOVERSE_N1_CPUECTLR_EL1, x1 |
lauwal01 | 00396bf | 2019-06-24 11:47:30 -0500 | [diff] [blame] | 279 | 1: |
| 280 | ret x17 |
| 281 | endfunc errata_n1_1262888_wa |
| 282 | |
| 283 | func check_errata_1262888 |
| 284 | /* Applies to <=r3p0 */ |
| 285 | mov x1, #0x30 |
| 286 | b cpu_rev_var_ls |
| 287 | endfunc check_errata_1262888 |
| 288 | |
| 289 | /* -------------------------------------------------- |
lauwal01 | 644b6ed | 2019-06-24 11:49:01 -0500 | [diff] [blame] | 290 | * Errata Workaround for Neoverse N1 Errata #1275112 |
| 291 | * This applies to revision <=r3p0 of Neoverse N1. |
| 292 | * Inputs: |
| 293 | * x0: variant[4:7] and revision[0:3] of current cpu. |
| 294 | * Shall clobber: x0-x17 |
| 295 | * -------------------------------------------------- |
| 296 | */ |
| 297 | func errata_n1_1275112_wa |
| 298 | /* Compare x0 against revision r3p0 */ |
| 299 | mov x17, x30 |
| 300 | bl check_errata_1275112 |
| 301 | cbz x0, 1f |
| 302 | mrs x1, NEOVERSE_N1_CPUACTLR_EL1 |
| 303 | orr x1, x1, NEOVERSE_N1_CPUACTLR_EL1_BIT_13 |
| 304 | msr NEOVERSE_N1_CPUACTLR_EL1, x1 |
lauwal01 | 644b6ed | 2019-06-24 11:49:01 -0500 | [diff] [blame] | 305 | 1: |
| 306 | ret x17 |
| 307 | endfunc errata_n1_1275112_wa |
| 308 | |
| 309 | func check_errata_1275112 |
| 310 | /* Applies to <=r3p0 */ |
| 311 | mov x1, #0x30 |
| 312 | b cpu_rev_var_ls |
| 313 | endfunc check_errata_1275112 |
| 314 | |
| 315 | /* -------------------------------------------------- |
Andre Przywara | b934740 | 2019-05-20 14:57:06 +0100 | [diff] [blame] | 316 | * Errata Workaround for Neoverse N1 Erratum 1315703. |
| 317 | * This applies to revision <= r3p0 of Neoverse N1. |
| 318 | * Inputs: |
| 319 | * x0: variant[4:7] and revision[0:3] of current cpu. |
| 320 | * Shall clobber: x0-x17 |
| 321 | * -------------------------------------------------- |
| 322 | */ |
| 323 | func errata_n1_1315703_wa |
| 324 | /* Compare x0 against revision r3p1 */ |
| 325 | mov x17, x30 |
| 326 | bl check_errata_1315703 |
| 327 | cbz x0, 1f |
| 328 | |
| 329 | mrs x0, NEOVERSE_N1_CPUACTLR2_EL1 |
| 330 | orr x0, x0, #NEOVERSE_N1_CPUACTLR2_EL1_BIT_16 |
| 331 | msr NEOVERSE_N1_CPUACTLR2_EL1, x0 |
Andre Przywara | b934740 | 2019-05-20 14:57:06 +0100 | [diff] [blame] | 332 | |
| 333 | 1: |
| 334 | ret x17 |
| 335 | endfunc errata_n1_1315703_wa |
| 336 | |
| 337 | func check_errata_1315703 |
| 338 | /* Applies to everything <= r3p0. */ |
| 339 | mov x1, #0x30 |
| 340 | b cpu_rev_var_ls |
| 341 | endfunc check_errata_1315703 |
| 342 | |
laurenw-arm | 94accd3 | 2019-08-20 15:51:24 -0500 | [diff] [blame] | 343 | /* -------------------------------------------------- |
| 344 | * Errata Workaround for Neoverse N1 Erratum 1542419. |
| 345 | * This applies to revisions r3p0 - r4p0 of Neoverse N1 |
| 346 | * Inputs: |
| 347 | * x0: variant[4:7] and revision[0:3] of current cpu. |
| 348 | * Shall clobber: x0-x17 |
| 349 | * -------------------------------------------------- |
| 350 | */ |
| 351 | func errata_n1_1542419_wa |
| 352 | /* Compare x0 against revision r3p0 and r4p0 */ |
| 353 | mov x17, x30 |
| 354 | bl check_errata_1542419 |
| 355 | cbz x0, 1f |
| 356 | |
laurenw-arm | cd9a943 | 2019-10-11 15:45:24 -0500 | [diff] [blame] | 357 | /* Apply instruction patching sequence */ |
laurenw-arm | 94accd3 | 2019-08-20 15:51:24 -0500 | [diff] [blame] | 358 | ldr x0, =0x0 |
| 359 | msr CPUPSELR_EL3, x0 |
| 360 | ldr x0, =0xEE670D35 |
| 361 | msr CPUPOR_EL3, x0 |
| 362 | ldr x0, =0xFFFF0FFF |
| 363 | msr CPUPMR_EL3, x0 |
| 364 | ldr x0, =0x08000020007D |
| 365 | msr CPUPCR_EL3, x0 |
| 366 | isb |
| 367 | 1: |
| 368 | ret x17 |
| 369 | endfunc errata_n1_1542419_wa |
| 370 | |
| 371 | func check_errata_1542419 |
| 372 | /* Applies to everything r3p0 - r4p0. */ |
| 373 | mov x1, #0x30 |
| 374 | mov x2, #0x40 |
| 375 | b cpu_rev_var_range |
| 376 | endfunc check_errata_1542419 |
| 377 | |
John Tsichritzis | 56369c1 | 2019-02-19 13:49:06 +0000 | [diff] [blame] | 378 | func neoverse_n1_reset_func |
Dimitris Papastamos | 7ca21db | 2018-03-26 16:46:01 +0100 | [diff] [blame] | 379 | mov x19, x30 |
John Tsichritzis | 1f9ff49 | 2019-03-04 16:41:26 +0000 | [diff] [blame] | 380 | |
Sami Mujawar | a8722e9 | 2019-05-10 14:28:37 +0100 | [diff] [blame] | 381 | bl neoverse_n1_disable_speculative_loads |
John Tsichritzis | 1f9ff49 | 2019-03-04 16:41:26 +0000 | [diff] [blame] | 382 | |
Louis Mayencourt | b58142b | 2019-04-18 14:34:11 +0100 | [diff] [blame] | 383 | /* Forces all cacheable atomic instructions to be near */ |
| 384 | mrs x0, NEOVERSE_N1_CPUACTLR2_EL1 |
| 385 | orr x0, x0, #NEOVERSE_N1_CPUACTLR2_EL1_BIT_2 |
| 386 | msr NEOVERSE_N1_CPUACTLR2_EL1, x0 |
| 387 | isb |
| 388 | |
Dimitris Papastamos | 7ca21db | 2018-03-26 16:46:01 +0100 | [diff] [blame] | 389 | bl cpu_get_rev_var |
| 390 | mov x18, x0 |
| 391 | |
John Tsichritzis | 56369c1 | 2019-02-19 13:49:06 +0000 | [diff] [blame] | 392 | #if ERRATA_N1_1043202 |
Dimitris Papastamos | 7ca21db | 2018-03-26 16:46:01 +0100 | [diff] [blame] | 393 | mov x0, x18 |
John Tsichritzis | 56369c1 | 2019-02-19 13:49:06 +0000 | [diff] [blame] | 394 | bl errata_n1_1043202_wa |
Dimitris Papastamos | 7ca21db | 2018-03-26 16:46:01 +0100 | [diff] [blame] | 395 | #endif |
| 396 | |
lauwal01 | bd555f4 | 2019-06-24 11:23:50 -0500 | [diff] [blame] | 397 | #if ERRATA_N1_1073348 |
| 398 | mov x0, x18 |
| 399 | bl errata_n1_1073348_wa |
| 400 | #endif |
| 401 | |
lauwal01 | 363ee3c | 2019-06-24 11:28:34 -0500 | [diff] [blame] | 402 | #if ERRATA_N1_1130799 |
| 403 | mov x0, x18 |
| 404 | bl errata_n1_1130799_wa |
| 405 | #endif |
| 406 | |
lauwal01 | f2adb13 | 2019-06-24 11:32:40 -0500 | [diff] [blame] | 407 | #if ERRATA_N1_1165347 |
| 408 | mov x0, x18 |
| 409 | bl errata_n1_1165347_wa |
| 410 | #endif |
| 411 | |
lauwal01 | e159044 | 2019-06-24 11:35:37 -0500 | [diff] [blame] | 412 | #if ERRATA_N1_1207823 |
| 413 | mov x0, x18 |
| 414 | bl errata_n1_1207823_wa |
| 415 | #endif |
| 416 | |
lauwal01 | 197f14c | 2019-06-24 11:38:53 -0500 | [diff] [blame] | 417 | #if ERRATA_N1_1220197 |
| 418 | mov x0, x18 |
| 419 | bl errata_n1_1220197_wa |
| 420 | #endif |
| 421 | |
lauwal01 | 07c2a23 | 2019-06-24 11:42:02 -0500 | [diff] [blame] | 422 | #if ERRATA_N1_1257314 |
| 423 | mov x0, x18 |
| 424 | bl errata_n1_1257314_wa |
| 425 | #endif |
| 426 | |
lauwal01 | 42771af | 2019-06-24 11:44:58 -0500 | [diff] [blame] | 427 | #if ERRATA_N1_1262606 |
| 428 | mov x0, x18 |
| 429 | bl errata_n1_1262606_wa |
| 430 | #endif |
| 431 | |
lauwal01 | 00396bf | 2019-06-24 11:47:30 -0500 | [diff] [blame] | 432 | #if ERRATA_N1_1262888 |
| 433 | mov x0, x18 |
| 434 | bl errata_n1_1262888_wa |
| 435 | #endif |
| 436 | |
lauwal01 | 644b6ed | 2019-06-24 11:49:01 -0500 | [diff] [blame] | 437 | #if ERRATA_N1_1275112 |
| 438 | mov x0, x18 |
| 439 | bl errata_n1_1275112_wa |
| 440 | #endif |
| 441 | |
Andre Przywara | b934740 | 2019-05-20 14:57:06 +0100 | [diff] [blame] | 442 | #if ERRATA_N1_1315703 |
| 443 | mov x0, x18 |
| 444 | bl errata_n1_1315703_wa |
| 445 | #endif |
| 446 | |
laurenw-arm | 94accd3 | 2019-08-20 15:51:24 -0500 | [diff] [blame] | 447 | #if ERRATA_N1_1542419 |
| 448 | mov x0, x18 |
| 449 | bl errata_n1_1542419_wa |
| 450 | #endif |
| 451 | |
Dimitris Papastamos | 89736dd | 2018-02-13 11:28:02 +0000 | [diff] [blame] | 452 | #if ENABLE_AMU |
| 453 | /* Make sure accesses from EL0/EL1 and EL2 are not trapped to EL3 */ |
| 454 | mrs x0, actlr_el3 |
John Tsichritzis | 56369c1 | 2019-02-19 13:49:06 +0000 | [diff] [blame] | 455 | orr x0, x0, #NEOVERSE_N1_ACTLR_AMEN_BIT |
Dimitris Papastamos | 89736dd | 2018-02-13 11:28:02 +0000 | [diff] [blame] | 456 | msr actlr_el3, x0 |
Dimitris Papastamos | 89736dd | 2018-02-13 11:28:02 +0000 | [diff] [blame] | 457 | |
| 458 | /* Make sure accesses from EL0/EL1 are not trapped to EL2 */ |
| 459 | mrs x0, actlr_el2 |
John Tsichritzis | 56369c1 | 2019-02-19 13:49:06 +0000 | [diff] [blame] | 460 | orr x0, x0, #NEOVERSE_N1_ACTLR_AMEN_BIT |
Dimitris Papastamos | 89736dd | 2018-02-13 11:28:02 +0000 | [diff] [blame] | 461 | msr actlr_el2, x0 |
Dimitris Papastamos | 89736dd | 2018-02-13 11:28:02 +0000 | [diff] [blame] | 462 | |
| 463 | /* Enable group0 counters */ |
John Tsichritzis | 56369c1 | 2019-02-19 13:49:06 +0000 | [diff] [blame] | 464 | mov x0, #NEOVERSE_N1_AMU_GROUP0_MASK |
Dimitris Papastamos | 89736dd | 2018-02-13 11:28:02 +0000 | [diff] [blame] | 465 | msr CPUAMCNTENSET_EL0, x0 |
Dimitris Papastamos | 89736dd | 2018-02-13 11:28:02 +0000 | [diff] [blame] | 466 | #endif |
Louis Mayencourt | 8b8b13b | 2019-06-10 16:43:39 +0100 | [diff] [blame] | 467 | |
| 468 | #if ERRATA_DSU_936184 |
| 469 | bl errata_dsu_936184_wa |
| 470 | #endif |
| 471 | |
lauwal01 | cf12f26 | 2019-06-27 11:03:25 -0500 | [diff] [blame] | 472 | isb |
Dimitris Papastamos | 7ca21db | 2018-03-26 16:46:01 +0100 | [diff] [blame] | 473 | ret x19 |
John Tsichritzis | 56369c1 | 2019-02-19 13:49:06 +0000 | [diff] [blame] | 474 | endfunc neoverse_n1_reset_func |
Isla Mitchell | ea84d6b | 2017-08-03 16:04:46 +0100 | [diff] [blame] | 475 | |
| 476 | /* --------------------------------------------- |
| 477 | * HW will do the cache maintenance while powering down |
| 478 | * --------------------------------------------- |
| 479 | */ |
John Tsichritzis | 56369c1 | 2019-02-19 13:49:06 +0000 | [diff] [blame] | 480 | func neoverse_n1_core_pwr_dwn |
Isla Mitchell | ea84d6b | 2017-08-03 16:04:46 +0100 | [diff] [blame] | 481 | /* --------------------------------------------- |
| 482 | * Enable CPU power down bit in power control register |
| 483 | * --------------------------------------------- |
| 484 | */ |
John Tsichritzis | 56369c1 | 2019-02-19 13:49:06 +0000 | [diff] [blame] | 485 | mrs x0, NEOVERSE_N1_CPUPWRCTLR_EL1 |
| 486 | orr x0, x0, #NEOVERSE_N1_CORE_PWRDN_EN_MASK |
| 487 | msr NEOVERSE_N1_CPUPWRCTLR_EL1, x0 |
Isla Mitchell | ea84d6b | 2017-08-03 16:04:46 +0100 | [diff] [blame] | 488 | isb |
| 489 | ret |
John Tsichritzis | 56369c1 | 2019-02-19 13:49:06 +0000 | [diff] [blame] | 490 | endfunc neoverse_n1_core_pwr_dwn |
Isla Mitchell | ea84d6b | 2017-08-03 16:04:46 +0100 | [diff] [blame] | 491 | |
Dimitris Papastamos | 7ca21db | 2018-03-26 16:46:01 +0100 | [diff] [blame] | 492 | #if REPORT_ERRATA |
| 493 | /* |
John Tsichritzis | 56369c1 | 2019-02-19 13:49:06 +0000 | [diff] [blame] | 494 | * Errata printing function for Neoverse N1. Must follow AAPCS. |
Dimitris Papastamos | 7ca21db | 2018-03-26 16:46:01 +0100 | [diff] [blame] | 495 | */ |
John Tsichritzis | 56369c1 | 2019-02-19 13:49:06 +0000 | [diff] [blame] | 496 | func neoverse_n1_errata_report |
Dimitris Papastamos | 7ca21db | 2018-03-26 16:46:01 +0100 | [diff] [blame] | 497 | stp x8, x30, [sp, #-16]! |
| 498 | |
| 499 | bl cpu_get_rev_var |
| 500 | mov x8, x0 |
| 501 | |
| 502 | /* |
| 503 | * Report all errata. The revision-variant information is passed to |
| 504 | * checking functions of each errata. |
| 505 | */ |
John Tsichritzis | 56369c1 | 2019-02-19 13:49:06 +0000 | [diff] [blame] | 506 | report_errata ERRATA_N1_1043202, neoverse_n1, 1043202 |
lauwal01 | bd555f4 | 2019-06-24 11:23:50 -0500 | [diff] [blame] | 507 | report_errata ERRATA_N1_1073348, neoverse_n1, 1073348 |
lauwal01 | 363ee3c | 2019-06-24 11:28:34 -0500 | [diff] [blame] | 508 | report_errata ERRATA_N1_1130799, neoverse_n1, 1130799 |
lauwal01 | f2adb13 | 2019-06-24 11:32:40 -0500 | [diff] [blame] | 509 | report_errata ERRATA_N1_1165347, neoverse_n1, 1165347 |
lauwal01 | e159044 | 2019-06-24 11:35:37 -0500 | [diff] [blame] | 510 | report_errata ERRATA_N1_1207823, neoverse_n1, 1207823 |
lauwal01 | 197f14c | 2019-06-24 11:38:53 -0500 | [diff] [blame] | 511 | report_errata ERRATA_N1_1220197, neoverse_n1, 1220197 |
lauwal01 | 07c2a23 | 2019-06-24 11:42:02 -0500 | [diff] [blame] | 512 | report_errata ERRATA_N1_1257314, neoverse_n1, 1257314 |
lauwal01 | 42771af | 2019-06-24 11:44:58 -0500 | [diff] [blame] | 513 | report_errata ERRATA_N1_1262606, neoverse_n1, 1262606 |
lauwal01 | 00396bf | 2019-06-24 11:47:30 -0500 | [diff] [blame] | 514 | report_errata ERRATA_N1_1262888, neoverse_n1, 1262888 |
lauwal01 | 644b6ed | 2019-06-24 11:49:01 -0500 | [diff] [blame] | 515 | report_errata ERRATA_N1_1275112, neoverse_n1, 1275112 |
Andre Przywara | b934740 | 2019-05-20 14:57:06 +0100 | [diff] [blame] | 516 | report_errata ERRATA_N1_1315703, neoverse_n1, 1315703 |
laurenw-arm | 94accd3 | 2019-08-20 15:51:24 -0500 | [diff] [blame] | 517 | report_errata ERRATA_N1_1542419, neoverse_n1, 1542419 |
Louis Mayencourt | 8b8b13b | 2019-06-10 16:43:39 +0100 | [diff] [blame] | 518 | report_errata ERRATA_DSU_936184, neoverse_n1, dsu_936184 |
Dimitris Papastamos | 7ca21db | 2018-03-26 16:46:01 +0100 | [diff] [blame] | 519 | |
| 520 | ldp x8, x30, [sp], #16 |
| 521 | ret |
John Tsichritzis | 56369c1 | 2019-02-19 13:49:06 +0000 | [diff] [blame] | 522 | endfunc neoverse_n1_errata_report |
Dimitris Papastamos | 7ca21db | 2018-03-26 16:46:01 +0100 | [diff] [blame] | 523 | #endif |
laurenw-arm | 94accd3 | 2019-08-20 15:51:24 -0500 | [diff] [blame] | 524 | |
| 525 | /* |
| 526 | * Handle trap of EL0 IC IVAU instructions to EL3 by executing a TLB |
| 527 | * inner-shareable invalidation to an arbitrary address followed by a DSB. |
| 528 | * |
| 529 | * x1: Exception Syndrome |
| 530 | */ |
| 531 | func neoverse_n1_errata_ic_trap_handler |
| 532 | cmp x1, #NEOVERSE_N1_EC_IC_TRAP |
| 533 | b.ne 1f |
| 534 | tlbi vae3is, xzr |
| 535 | dsb sy |
| 536 | |
laurenw-arm | cd9a943 | 2019-10-11 15:45:24 -0500 | [diff] [blame] | 537 | # Skip the IC instruction itself |
| 538 | mrs x3, elr_el3 |
| 539 | add x3, x3, #4 |
| 540 | msr elr_el3, x3 |
laurenw-arm | 94accd3 | 2019-08-20 15:51:24 -0500 | [diff] [blame] | 541 | |
| 542 | ldp x0, x1, [sp, #CTX_GPREGS_OFFSET + CTX_GPREG_X0] |
| 543 | ldp x2, x3, [sp, #CTX_GPREGS_OFFSET + CTX_GPREG_X2] |
| 544 | ldp x4, x5, [sp, #CTX_GPREGS_OFFSET + CTX_GPREG_X4] |
| 545 | ldr x30, [sp, #CTX_GPREGS_OFFSET + CTX_GPREG_LR] |
| 546 | |
| 547 | #if IMAGE_BL31 && RAS_EXTENSION |
| 548 | /* |
| 549 | * Issue Error Synchronization Barrier to synchronize SErrors before |
| 550 | * exiting EL3. We're running with EAs unmasked, so any synchronized |
| 551 | * errors would be taken immediately; therefore no need to inspect |
| 552 | * DISR_EL1 register. |
| 553 | */ |
| 554 | esb |
| 555 | #endif |
Anthony Steinhauser | 0f7e601 | 2020-01-07 15:44:06 -0800 | [diff] [blame] | 556 | exception_return |
laurenw-arm | 94accd3 | 2019-08-20 15:51:24 -0500 | [diff] [blame] | 557 | 1: |
| 558 | ret |
| 559 | endfunc neoverse_n1_errata_ic_trap_handler |
Dimitris Papastamos | 7ca21db | 2018-03-26 16:46:01 +0100 | [diff] [blame] | 560 | |
Isla Mitchell | ea84d6b | 2017-08-03 16:04:46 +0100 | [diff] [blame] | 561 | /* --------------------------------------------- |
John Tsichritzis | 56369c1 | 2019-02-19 13:49:06 +0000 | [diff] [blame] | 562 | * This function provides neoverse_n1 specific |
Isla Mitchell | ea84d6b | 2017-08-03 16:04:46 +0100 | [diff] [blame] | 563 | * register information for crash reporting. |
| 564 | * It needs to return with x6 pointing to |
| 565 | * a list of register names in ascii and |
| 566 | * x8 - x15 having values of registers to be |
| 567 | * reported. |
| 568 | * --------------------------------------------- |
| 569 | */ |
John Tsichritzis | 56369c1 | 2019-02-19 13:49:06 +0000 | [diff] [blame] | 570 | .section .rodata.neoverse_n1_regs, "aS" |
| 571 | neoverse_n1_regs: /* The ascii list of register names to be reported */ |
Isla Mitchell | ea84d6b | 2017-08-03 16:04:46 +0100 | [diff] [blame] | 572 | .asciz "cpuectlr_el1", "" |
| 573 | |
John Tsichritzis | 56369c1 | 2019-02-19 13:49:06 +0000 | [diff] [blame] | 574 | func neoverse_n1_cpu_reg_dump |
| 575 | adr x6, neoverse_n1_regs |
| 576 | mrs x8, NEOVERSE_N1_CPUECTLR_EL1 |
Isla Mitchell | ea84d6b | 2017-08-03 16:04:46 +0100 | [diff] [blame] | 577 | ret |
John Tsichritzis | 56369c1 | 2019-02-19 13:49:06 +0000 | [diff] [blame] | 578 | endfunc neoverse_n1_cpu_reg_dump |
Isla Mitchell | ea84d6b | 2017-08-03 16:04:46 +0100 | [diff] [blame] | 579 | |
laurenw-arm | 94accd3 | 2019-08-20 15:51:24 -0500 | [diff] [blame] | 580 | declare_cpu_ops_eh neoverse_n1, NEOVERSE_N1_MIDR, \ |
John Tsichritzis | 56369c1 | 2019-02-19 13:49:06 +0000 | [diff] [blame] | 581 | neoverse_n1_reset_func, \ |
laurenw-arm | 94accd3 | 2019-08-20 15:51:24 -0500 | [diff] [blame] | 582 | neoverse_n1_errata_ic_trap_handler, \ |
John Tsichritzis | 56369c1 | 2019-02-19 13:49:06 +0000 | [diff] [blame] | 583 | neoverse_n1_core_pwr_dwn |