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