Jimmy Brisson | 958a0b1 | 2020-09-30 15:28:03 -0500 | [diff] [blame] | 1 | /* |
Sona Mathew | fe405d0 | 2023-01-11 17:04:24 -0600 | [diff] [blame] | 2 | * Copyright (c) 2019-2023, Arm Limited. All rights reserved. |
Jimmy Brisson | 958a0b1 | 2020-09-30 15:28:03 -0500 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #include <arch.h> |
| 8 | #include <asm_macros.S> |
| 9 | #include <common/bl_common.h> |
| 10 | #include <neoverse_v1.h> |
| 11 | #include <cpu_macros.S> |
| 12 | #include <plat_macros.S> |
Bipin Ravi | 8649974 | 2022-01-18 01:59:06 -0600 | [diff] [blame] | 13 | #include "wa_cve_2022_23960_bhb_vector.S" |
Jimmy Brisson | 958a0b1 | 2020-09-30 15:28:03 -0500 | [diff] [blame] | 14 | |
| 15 | /* Hardware handled coherency */ |
| 16 | #if HW_ASSISTED_COHERENCY == 0 |
| 17 | #error "Neoverse V1 must be compiled with HW_ASSISTED_COHERENCY enabled" |
| 18 | #endif |
| 19 | |
| 20 | /* 64-bit only core */ |
| 21 | #if CTX_INCLUDE_AARCH32_REGS == 1 |
| 22 | #error "Neoverse-V1 supports only AArch64. Compile with CTX_INCLUDE_AARCH32_REGS=0" |
| 23 | #endif |
| 24 | |
Bipin Ravi | 8649974 | 2022-01-18 01:59:06 -0600 | [diff] [blame] | 25 | #if WORKAROUND_CVE_2022_23960 |
| 26 | wa_cve_2022_23960_bhb_vector_table NEOVERSE_V1_BHB_LOOP_COUNT, neoverse_v1 |
| 27 | #endif /* WORKAROUND_CVE_2022_23960 */ |
| 28 | |
johpow01 | c73b03c | 2021-05-03 15:33:39 -0500 | [diff] [blame] | 29 | /* -------------------------------------------------- |
Juan Pablo Conde | 31c9337 | 2022-02-28 14:14:44 -0500 | [diff] [blame] | 30 | * Errata Workaround for Neoverse V1 Errata #1618635. |
| 31 | * This applies to revision r0p0 and is fixed in |
| 32 | * r1p0. |
| 33 | * x0: variant[4:7] and revision[0:3] of current cpu. |
| 34 | * Shall clobber: x0, x17 |
| 35 | * -------------------------------------------------- |
| 36 | */ |
| 37 | func errata_neoverse_v1_1618635_wa |
| 38 | /* Check workaround compatibility. */ |
| 39 | mov x17, x30 |
| 40 | bl check_errata_1618635 |
| 41 | cbz x0, 1f |
| 42 | |
| 43 | /* Inserts a DMB SY before and after MRS PAR_EL1 */ |
| 44 | ldr x0, =0x0 |
| 45 | msr NEOVERSE_V1_CPUPSELR_EL3, x0 |
| 46 | ldr x0, = 0xEE070F14 |
| 47 | msr NEOVERSE_V1_CPUPOR_EL3, x0 |
| 48 | ldr x0, = 0xFFFF0FFF |
| 49 | msr NEOVERSE_V1_CPUPMR_EL3, x0 |
| 50 | ldr x0, =0x4005027FF |
| 51 | msr NEOVERSE_V1_CPUPCR_EL3, x0 |
| 52 | |
| 53 | /* Inserts a DMB SY before STREX imm offset */ |
| 54 | ldr x0, =0x1 |
| 55 | msr NEOVERSE_V1_CPUPSELR_EL3, x0 |
| 56 | ldr x0, =0x00e8400000 |
| 57 | msr NEOVERSE_V1_CPUPOR_EL3, x0 |
| 58 | ldr x0, =0x00fff00000 |
| 59 | msr NEOVERSE_V1_CPUPMR_EL3, x0 |
| 60 | ldr x0, = 0x4001027FF |
| 61 | msr NEOVERSE_V1_CPUPCR_EL3, x0 |
| 62 | |
| 63 | /* Inserts a DMB SY before STREX[BHD}/STLEX* */ |
| 64 | ldr x0, =0x2 |
| 65 | msr NEOVERSE_V1_CPUPSELR_EL3, x0 |
| 66 | ldr x0, =0x00e8c00040 |
| 67 | msr NEOVERSE_V1_CPUPOR_EL3, x0 |
| 68 | ldr x0, =0x00fff00040 |
| 69 | msr NEOVERSE_V1_CPUPMR_EL3, x0 |
| 70 | ldr x0, = 0x4001027FF |
| 71 | msr NEOVERSE_V1_CPUPCR_EL3, x0 |
| 72 | |
| 73 | /* Inserts a DMB SY after STREX imm offset */ |
| 74 | ldr x0, =0x3 |
| 75 | msr NEOVERSE_V1_CPUPSELR_EL3, x0 |
| 76 | ldr x0, =0x00e8400000 |
| 77 | msr NEOVERSE_V1_CPUPOR_EL3, x0 |
| 78 | ldr x0, =0x00fff00000 |
| 79 | msr NEOVERSE_V1_CPUPMR_EL3, x0 |
| 80 | ldr x0, = 0x4004027FF |
| 81 | msr NEOVERSE_V1_CPUPCR_EL3, x0 |
| 82 | |
| 83 | /* Inserts a DMB SY after STREX[BHD}/STLEX* */ |
| 84 | ldr x0, =0x4 |
| 85 | msr NEOVERSE_V1_CPUPSELR_EL3, x0 |
| 86 | ldr x0, =0x00e8c00040 |
| 87 | msr NEOVERSE_V1_CPUPOR_EL3, x0 |
| 88 | ldr x0, =0x00fff00040 |
| 89 | msr NEOVERSE_V1_CPUPMR_EL3, x0 |
| 90 | ldr x0, = 0x4004027FF |
| 91 | msr NEOVERSE_V1_CPUPCR_EL3, x0 |
| 92 | |
| 93 | /* Synchronize to enable patches */ |
| 94 | isb |
| 95 | 1: |
| 96 | ret x17 |
| 97 | endfunc errata_neoverse_v1_1618635_wa |
| 98 | |
| 99 | func check_errata_1618635 |
| 100 | /* Applies to revision r0p0. */ |
| 101 | mov x1, #0x00 |
| 102 | b cpu_rev_var_ls |
| 103 | endfunc check_errata_1618635 |
| 104 | |
| 105 | /* -------------------------------------------------- |
laurenw-arm | 3c86d83 | 2021-08-02 13:22:32 -0500 | [diff] [blame] | 106 | * Errata Workaround for Neoverse V1 Errata #1774420. |
| 107 | * This applies to revisions r0p0 and r1p0, fixed in r1p1. |
| 108 | * x0: variant[4:7] and revision[0:3] of current cpu. |
| 109 | * Shall clobber: x0-x17 |
| 110 | * -------------------------------------------------- |
| 111 | */ |
| 112 | func errata_neoverse_v1_1774420_wa |
| 113 | /* Check workaround compatibility. */ |
| 114 | mov x17, x30 |
| 115 | bl check_errata_1774420 |
| 116 | cbz x0, 1f |
| 117 | |
| 118 | /* Set bit 53 in CPUECTLR_EL1 */ |
| 119 | mrs x1, NEOVERSE_V1_CPUECTLR_EL1 |
| 120 | orr x1, x1, #NEOVERSE_V1_CPUECTLR_EL1_BIT_53 |
| 121 | msr NEOVERSE_V1_CPUECTLR_EL1, x1 |
| 122 | isb |
| 123 | 1: |
| 124 | ret x17 |
| 125 | endfunc errata_neoverse_v1_1774420_wa |
| 126 | |
| 127 | func check_errata_1774420 |
| 128 | /* Applies to r0p0 and r1p0. */ |
| 129 | mov x1, #0x10 |
| 130 | b cpu_rev_var_ls |
| 131 | endfunc check_errata_1774420 |
| 132 | |
| 133 | /* -------------------------------------------------- |
johpow01 | c73b03c | 2021-05-03 15:33:39 -0500 | [diff] [blame] | 134 | * Errata Workaround for Neoverse V1 Errata #1791573. |
| 135 | * This applies to revisions r0p0 and r1p0, fixed in r1p1. |
| 136 | * x0: variant[4:7] and revision[0:3] of current cpu. |
| 137 | * Shall clobber: x0-x17 |
| 138 | * -------------------------------------------------- |
| 139 | */ |
| 140 | func errata_neoverse_v1_1791573_wa |
| 141 | /* Check workaround compatibility. */ |
| 142 | mov x17, x30 |
| 143 | bl check_errata_1791573 |
| 144 | cbz x0, 1f |
| 145 | |
| 146 | /* Set bit 2 in ACTLR2_EL1 */ |
laurenw-arm | 3c86d83 | 2021-08-02 13:22:32 -0500 | [diff] [blame] | 147 | mrs x1, NEOVERSE_V1_ACTLR2_EL1 |
johpow01 | c73b03c | 2021-05-03 15:33:39 -0500 | [diff] [blame] | 148 | orr x1, x1, #NEOVERSE_V1_ACTLR2_EL1_BIT_2 |
laurenw-arm | 3c86d83 | 2021-08-02 13:22:32 -0500 | [diff] [blame] | 149 | msr NEOVERSE_V1_ACTLR2_EL1, x1 |
johpow01 | c73b03c | 2021-05-03 15:33:39 -0500 | [diff] [blame] | 150 | isb |
| 151 | 1: |
| 152 | ret x17 |
| 153 | endfunc errata_neoverse_v1_1791573_wa |
| 154 | |
| 155 | func check_errata_1791573 |
| 156 | /* Applies to r0p0 and r1p0. */ |
| 157 | mov x1, #0x10 |
| 158 | b cpu_rev_var_ls |
| 159 | endfunc check_errata_1791573 |
| 160 | |
johpow01 | 07acb4f | 2020-10-07 16:38:37 -0500 | [diff] [blame] | 161 | /* -------------------------------------------------- |
laurenw-arm | b1923e9 | 2021-08-02 14:40:08 -0500 | [diff] [blame] | 162 | * Errata Workaround for Neoverse V1 Errata #1852267. |
| 163 | * This applies to revisions r0p0 and r1p0, fixed in r1p1. |
| 164 | * x0: variant[4:7] and revision[0:3] of current cpu. |
| 165 | * Shall clobber: x0-x17 |
| 166 | * -------------------------------------------------- |
| 167 | */ |
| 168 | func errata_neoverse_v1_1852267_wa |
| 169 | /* Check workaround compatibility. */ |
| 170 | mov x17, x30 |
| 171 | bl check_errata_1852267 |
| 172 | cbz x0, 1f |
| 173 | |
| 174 | /* Set bit 28 in ACTLR2_EL1 */ |
| 175 | mrs x1, NEOVERSE_V1_ACTLR2_EL1 |
| 176 | orr x1, x1, #NEOVERSE_V1_ACTLR2_EL1_BIT_28 |
| 177 | msr NEOVERSE_V1_ACTLR2_EL1, x1 |
| 178 | isb |
| 179 | 1: |
| 180 | ret x17 |
| 181 | endfunc errata_neoverse_v1_1852267_wa |
| 182 | |
| 183 | func check_errata_1852267 |
| 184 | /* Applies to r0p0 and r1p0. */ |
| 185 | mov x1, #0x10 |
| 186 | b cpu_rev_var_ls |
| 187 | endfunc check_errata_1852267 |
| 188 | |
| 189 | /* -------------------------------------------------- |
laurenw-arm | 6b56f96 | 2021-08-02 15:00:15 -0500 | [diff] [blame] | 190 | * Errata Workaround for Neoverse V1 Errata #1925756. |
| 191 | * This applies to revisions <= r1p1. |
| 192 | * x0: variant[4:7] and revision[0:3] of current cpu. |
| 193 | * Shall clobber: x0-x17 |
| 194 | * -------------------------------------------------- |
| 195 | */ |
| 196 | func errata_neoverse_v1_1925756_wa |
| 197 | /* Check workaround compatibility. */ |
| 198 | mov x17, x30 |
| 199 | bl check_errata_1925756 |
| 200 | cbz x0, 1f |
| 201 | |
| 202 | /* Set bit 8 in CPUECTLR_EL1 */ |
| 203 | mrs x1, NEOVERSE_V1_CPUECTLR_EL1 |
| 204 | orr x1, x1, #NEOVERSE_V1_CPUECTLR_EL1_BIT_8 |
| 205 | msr NEOVERSE_V1_CPUECTLR_EL1, x1 |
| 206 | isb |
| 207 | 1: |
| 208 | ret x17 |
| 209 | endfunc errata_neoverse_v1_1925756_wa |
| 210 | |
| 211 | func check_errata_1925756 |
| 212 | /* Applies to <= r1p1. */ |
| 213 | mov x1, #0x11 |
| 214 | b cpu_rev_var_ls |
| 215 | endfunc check_errata_1925756 |
| 216 | |
| 217 | /* -------------------------------------------------- |
johpow01 | 07acb4f | 2020-10-07 16:38:37 -0500 | [diff] [blame] | 218 | * Errata Workaround for Neoverse V1 Erratum #1940577 |
| 219 | * This applies to revisions r1p0 - r1p1 and is open. |
| 220 | * It also exists in r0p0 but there is no fix in that |
| 221 | * revision. |
| 222 | * Inputs: |
| 223 | * x0: variant[4:7] and revision[0:3] of current cpu. |
| 224 | * Shall clobber: x0-x17 |
| 225 | * -------------------------------------------------- |
| 226 | */ |
| 227 | func errata_neoverse_v1_1940577_wa |
| 228 | /* Compare x0 against revisions r1p0 - r1p1 */ |
| 229 | mov x17, x30 |
| 230 | bl check_errata_1940577 |
| 231 | cbz x0, 1f |
| 232 | |
| 233 | mov x0, #0 |
| 234 | msr S3_6_C15_C8_0, x0 |
| 235 | ldr x0, =0x10E3900002 |
| 236 | msr S3_6_C15_C8_2, x0 |
| 237 | ldr x0, =0x10FFF00083 |
| 238 | msr S3_6_C15_C8_3, x0 |
| 239 | ldr x0, =0x2001003FF |
| 240 | msr S3_6_C15_C8_1, x0 |
| 241 | |
| 242 | mov x0, #1 |
| 243 | msr S3_6_C15_C8_0, x0 |
| 244 | ldr x0, =0x10E3800082 |
| 245 | msr S3_6_C15_C8_2, x0 |
| 246 | ldr x0, =0x10FFF00083 |
| 247 | msr S3_6_C15_C8_3, x0 |
| 248 | ldr x0, =0x2001003FF |
| 249 | msr S3_6_C15_C8_1, x0 |
| 250 | |
| 251 | mov x0, #2 |
| 252 | msr S3_6_C15_C8_0, x0 |
| 253 | ldr x0, =0x10E3800200 |
| 254 | msr S3_6_C15_C8_2, x0 |
| 255 | ldr x0, =0x10FFF003E0 |
| 256 | msr S3_6_C15_C8_3, x0 |
| 257 | ldr x0, =0x2001003FF |
| 258 | msr S3_6_C15_C8_1, x0 |
| 259 | |
| 260 | isb |
| 261 | 1: |
| 262 | ret x17 |
| 263 | endfunc errata_neoverse_v1_1940577_wa |
| 264 | |
| 265 | func check_errata_1940577 |
| 266 | /* Applies to revisions r1p0 - r1p1. */ |
| 267 | mov x1, #0x10 |
| 268 | mov x2, #0x11 |
| 269 | b cpu_rev_var_range |
| 270 | endfunc check_errata_1940577 |
| 271 | |
johpow01 | 97db675 | 2021-08-02 18:59:08 -0500 | [diff] [blame] | 272 | /* -------------------------------------------------- |
| 273 | * Errata Workaround for Neoverse V1 Errata #1966096 |
| 274 | * This applies to revisions r1p0 - r1p1 and is open. |
| 275 | * It also exists in r0p0 but there is no workaround |
| 276 | * for that revision. |
| 277 | * x0: variant[4:7] and revision[0:3] of current cpu. |
| 278 | * Shall clobber: x0-x17 |
| 279 | * -------------------------------------------------- |
| 280 | */ |
| 281 | func errata_neoverse_v1_1966096_wa |
| 282 | /* Check workaround compatibility. */ |
| 283 | mov x17, x30 |
| 284 | bl check_errata_1966096 |
| 285 | cbz x0, 1f |
| 286 | |
| 287 | /* Apply the workaround. */ |
| 288 | mov x0, #0x3 |
| 289 | msr S3_6_C15_C8_0, x0 |
| 290 | ldr x0, =0xEE010F12 |
| 291 | msr S3_6_C15_C8_2, x0 |
| 292 | ldr x0, =0xFFFF0FFF |
| 293 | msr S3_6_C15_C8_3, x0 |
| 294 | ldr x0, =0x80000000003FF |
| 295 | msr S3_6_C15_C8_1, x0 |
| 296 | isb |
| 297 | |
| 298 | 1: |
| 299 | ret x17 |
| 300 | endfunc errata_neoverse_v1_1966096_wa |
| 301 | |
| 302 | func check_errata_1966096 |
| 303 | mov x1, #0x10 |
| 304 | mov x2, #0x11 |
| 305 | b cpu_rev_var_range |
| 306 | endfunc check_errata_1966096 |
| 307 | |
johpow01 | ad1ca34 | 2021-08-03 14:35:20 -0500 | [diff] [blame] | 308 | /* -------------------------------------------------- |
| 309 | * Errata Workaround for Neoverse V1 Errata #2139242. |
| 310 | * This applies to revisions r0p0, r1p0, and r1p1, it |
| 311 | * is still open. |
| 312 | * x0: variant[4:7] and revision[0:3] of current cpu. |
| 313 | * Shall clobber: x0-x17 |
| 314 | * -------------------------------------------------- |
| 315 | */ |
| 316 | func errata_neoverse_v1_2139242_wa |
| 317 | /* Check workaround compatibility. */ |
| 318 | mov x17, x30 |
| 319 | bl check_errata_2139242 |
| 320 | cbz x0, 1f |
| 321 | |
| 322 | /* Apply the workaround. */ |
| 323 | mov x0, #0x3 |
| 324 | msr S3_6_C15_C8_0, x0 |
| 325 | ldr x0, =0xEE720F14 |
| 326 | msr S3_6_C15_C8_2, x0 |
| 327 | ldr x0, =0xFFFF0FDF |
| 328 | msr S3_6_C15_C8_3, x0 |
| 329 | ldr x0, =0x40000005003FF |
| 330 | msr S3_6_C15_C8_1, x0 |
| 331 | isb |
| 332 | |
| 333 | 1: |
| 334 | ret x17 |
| 335 | endfunc errata_neoverse_v1_2139242_wa |
| 336 | |
| 337 | func check_errata_2139242 |
| 338 | /* Applies to r0p0, r1p0, r1p1 */ |
| 339 | mov x1, #0x11 |
| 340 | b cpu_rev_var_ls |
| 341 | endfunc check_errata_2139242 |
| 342 | |
nayanpatel-arm | fc26ffe | 2021-09-28 13:41:03 -0700 | [diff] [blame] | 343 | /* -------------------------------------------------- |
| 344 | * Errata Workaround for Neoverse V1 Errata #2108267. |
| 345 | * This applies to revisions r0p0, r1p0, and r1p1, it |
| 346 | * is still open. |
| 347 | * x0: variant[4:7] and revision[0:3] of current cpu. |
| 348 | * Shall clobber: x0-x1, x17 |
| 349 | * -------------------------------------------------- |
| 350 | */ |
| 351 | func errata_neoverse_v1_2108267_wa |
| 352 | /* Check workaround compatibility. */ |
| 353 | mov x17, x30 |
| 354 | bl check_errata_2108267 |
| 355 | cbz x0, 1f |
| 356 | |
| 357 | /* Apply the workaround. */ |
| 358 | mrs x1, NEOVERSE_V1_CPUECTLR_EL1 |
| 359 | mov x0, #NEOVERSE_V1_CPUECTLR_EL1_PF_MODE_CNSRV |
| 360 | bfi x1, x0, #CPUECTLR_EL1_PF_MODE_LSB, #CPUECTLR_EL1_PF_MODE_WIDTH |
| 361 | msr NEOVERSE_V1_CPUECTLR_EL1, x1 |
| 362 | 1: |
| 363 | ret x17 |
| 364 | endfunc errata_neoverse_v1_2108267_wa |
| 365 | |
| 366 | func check_errata_2108267 |
| 367 | /* Applies to r0p0, r1p0, r1p1 */ |
| 368 | mov x1, #0x11 |
| 369 | b cpu_rev_var_ls |
| 370 | endfunc check_errata_2108267 |
| 371 | |
johpow01 | 4de29cb | 2021-09-02 18:29:17 -0500 | [diff] [blame] | 372 | /* -------------------------------------------------- |
| 373 | * Errata Workaround for Neoverse V1 Errata #2216392. |
| 374 | * This applies to revisions r1p0 and r1p1 and is |
| 375 | * still open. |
| 376 | * This issue is also present in r0p0 but there is no |
| 377 | * workaround in that revision. |
| 378 | * x0: variant[4:7] and revision[0:3] of current cpu. |
| 379 | * Shall clobber: x0-x17 |
| 380 | * -------------------------------------------------- |
| 381 | */ |
| 382 | func errata_neoverse_v1_2216392_wa |
| 383 | /* Check workaround compatibility. */ |
| 384 | mov x17, x30 |
| 385 | bl check_errata_2216392 |
| 386 | cbz x0, 1f |
| 387 | |
| 388 | ldr x0, =0x5 |
| 389 | msr S3_6_c15_c8_0, x0 /* CPUPSELR_EL3 */ |
| 390 | ldr x0, =0x10F600E000 |
| 391 | msr S3_6_c15_c8_2, x0 /* CPUPOR_EL3 */ |
| 392 | ldr x0, =0x10FF80E000 |
| 393 | msr S3_6_c15_c8_3, x0 /* CPUPMR_EL3 */ |
| 394 | ldr x0, =0x80000000003FF |
| 395 | msr S3_6_c15_c8_1, x0 /* CPUPCR_EL3 */ |
| 396 | |
| 397 | isb |
| 398 | 1: |
| 399 | ret x17 |
| 400 | endfunc errata_neoverse_v1_2216392_wa |
| 401 | |
| 402 | func check_errata_2216392 |
| 403 | /* Applies to revisions r1p0 and r1p1. */ |
| 404 | mov x1, #CPU_REV(1, 0) |
| 405 | mov x2, #CPU_REV(1, 1) |
| 406 | b cpu_rev_var_range |
| 407 | endfunc check_errata_2216392 |
| 408 | |
Bipin Ravi | 971938f | 2022-06-08 16:28:46 -0500 | [diff] [blame] | 409 | /* ----------------------------------------------------------------- |
| 410 | * Errata Workaround for Neoverse V1 Errata #2294912. |
| 411 | * This applies to revisions r0p0, r1p0, and r1p1 and is still open. |
| 412 | * x0: variant[4:7] and revision[0:3] of current cpu. |
| 413 | * Shall clobber: x0-x17 |
| 414 | * ----------------------------------------------------------------- |
| 415 | */ |
| 416 | func errata_neoverse_v1_2294912_wa |
| 417 | /* Check workaround compatibility. */ |
| 418 | mov x17, x30 |
| 419 | bl check_errata_2294912 |
| 420 | cbz x0, 1f |
| 421 | |
| 422 | /* Set bit 0 in ACTLR2_EL1 */ |
| 423 | mrs x1, NEOVERSE_V1_ACTLR2_EL1 |
| 424 | orr x1, x1, #NEOVERSE_V1_ACTLR2_EL1_BIT_0 |
| 425 | msr NEOVERSE_V1_ACTLR2_EL1, x1 |
| 426 | isb |
| 427 | 1: |
| 428 | ret x17 |
| 429 | endfunc errata_neoverse_v1_2294912_wa |
| 430 | |
| 431 | func check_errata_2294912 |
| 432 | /* Applies to r0p0, r1p0, and r1p1 right now */ |
| 433 | mov x1, #0x11 |
| 434 | b cpu_rev_var_ls |
| 435 | endfunc check_errata_2294912 |
| 436 | |
Bipin Ravi | b4cb31f | 2022-06-14 17:09:23 -0500 | [diff] [blame] | 437 | /* --------------------------------------------------- |
| 438 | * Errata Workaround for Neoverse V1 Errata #2372203. |
| 439 | * This applies to revisions <= r1p1 and is still open. |
| 440 | * x0: variant[4:7] and revision[0:3] of current cpu. |
| 441 | * Shall clobber: x0-x17 |
| 442 | * ---------------------------------------------------- |
| 443 | */ |
| 444 | func errata_neoverse_v1_2372203_wa |
| 445 | /* Check workaround compatibility. */ |
| 446 | mov x17, x30 |
| 447 | bl check_errata_2372203 |
| 448 | cbz x0, 1f |
| 449 | |
| 450 | /* Set bit 40 in ACTLR2_EL1 */ |
| 451 | mrs x1, NEOVERSE_V1_ACTLR2_EL1 |
| 452 | orr x1, x1, #NEOVERSE_V1_ACTLR2_EL1_BIT_40 |
| 453 | msr NEOVERSE_V1_ACTLR2_EL1, x1 |
| 454 | isb |
| 455 | 1: |
| 456 | ret x17 |
| 457 | endfunc errata_neoverse_v1_2372203_wa |
| 458 | |
| 459 | func check_errata_2372203 |
| 460 | /* Applies to <= r1p1. */ |
| 461 | mov x1, #0x11 |
| 462 | b cpu_rev_var_ls |
| 463 | endfunc check_errata_2372203 |
| 464 | |
Bipin Ravi | fe4b0c4 | 2022-12-15 11:57:53 -0600 | [diff] [blame] | 465 | /* ---------------------------------------------------- |
| 466 | * Errata Workaround for Neoverse V1 Errata #2743093. |
| 467 | * This applies to revisions <= r1p2 and is still open. |
| 468 | * x0: variant[4:7] and revision[0:3] of current cpu. |
| 469 | * Shall clobber: x0-x17 |
| 470 | * ---------------------------------------------------- |
| 471 | */ |
| 472 | func errata_neoverse_v1_2743093_wa |
| 473 | mov x17, x30 |
| 474 | bl check_errata_2743093 |
| 475 | cbz x0, 1f |
| 476 | |
| 477 | /* dsb before isb of power down sequence */ |
| 478 | dsb sy |
| 479 | 1: |
| 480 | ret x17 |
| 481 | endfunc errata_neoverse_v1_2743093_wa |
| 482 | |
| 483 | func check_errata_2743093 |
| 484 | /* Applies to all revisions <= r1p2 */ |
| 485 | mov x1, #0x12 |
| 486 | b cpu_rev_var_ls |
| 487 | endfunc check_errata_2743093 |
| 488 | |
Sona Mathew | 2ef5db7 | 2023-03-02 15:07:55 -0600 | [diff] [blame] | 489 | /* --------------------------------------------------- |
| 490 | * Errata Workaround for Neoverse V1 Errata #2743233. |
| 491 | * This applies to revisions r0p0, r1p0, r1p1 and r1p2. |
| 492 | * It is still open. |
| 493 | * x0: variant[4:7] and revisions[0:3] of current cpu. |
| 494 | * Shall clobber: x0-x1, x17 |
| 495 | * --------------------------------------------------- |
| 496 | */ |
| 497 | func errata_neoverse_v1_2743233_wa |
| 498 | /* Check revision. */ |
| 499 | mov x17, x30 |
| 500 | bl check_errata_2743233 |
| 501 | cbz x0, 1f |
| 502 | |
| 503 | /* Apply the workaround */ |
| 504 | mrs x1, NEOVERSE_V1_ACTLR5_EL1 |
| 505 | bic x1, x1, #BIT(56) |
| 506 | orr x1, x1, #BIT(55) |
| 507 | msr NEOVERSE_V1_ACTLR5_EL1, x1 |
| 508 | |
| 509 | 1: |
| 510 | ret x17 |
| 511 | endfunc errata_neoverse_v1_2743233_wa |
| 512 | |
| 513 | func check_errata_2743233 |
| 514 | /* Applies to r0p0, r1p0, r1p1 and r1p2 */ |
| 515 | mov x1, #CPU_REV(1,2) |
| 516 | b cpu_rev_var_ls |
| 517 | endfunc check_errata_2743233 |
| 518 | |
| 519 | |
Sona Mathew | fe405d0 | 2023-01-11 17:04:24 -0600 | [diff] [blame] | 520 | /* ---------------------------------------------------- |
| 521 | * Errata Workaround for Neoverse V1 Errata #2779461. |
| 522 | * This applies to revisions r0p0, r1p0, r1p1, and r1p2. |
| 523 | * It is still open. |
| 524 | * x0: variant[4:7] and revision[0:3] of current cpu. |
| 525 | * Shall clobber: x0-x1, x17 |
| 526 | * ---------------------------------------------------- |
| 527 | */ |
| 528 | func errata_neoverse_v1_2779461_wa |
| 529 | /* Check revision. */ |
| 530 | mov x17, x30 |
| 531 | bl check_errata_2779461 |
| 532 | cbz x0, 1f |
| 533 | |
| 534 | /* Apply the workaround */ |
| 535 | mrs x1, NEOVERSE_V1_ACTLR3_EL1 |
| 536 | orr x1, x1, #BIT(47) |
| 537 | msr NEOVERSE_V1_ACTLR3_EL1, x1 |
| 538 | |
| 539 | 1: |
| 540 | ret x17 |
| 541 | endfunc errata_neoverse_v1_2779461_wa |
| 542 | |
| 543 | func check_errata_2779461 |
| 544 | /* Applies to r0p0, r1p0, r1p1, r1p2 */ |
| 545 | mov x1, #CPU_REV(1, 2) |
| 546 | b cpu_rev_var_ls |
| 547 | endfunc check_errata_2779461 |
| 548 | |
Bipin Ravi | 8649974 | 2022-01-18 01:59:06 -0600 | [diff] [blame] | 549 | func check_errata_cve_2022_23960 |
| 550 | #if WORKAROUND_CVE_2022_23960 |
| 551 | mov x0, #ERRATA_APPLIES |
| 552 | #else |
| 553 | mov x0, #ERRATA_MISSING |
| 554 | #endif |
| 555 | ret |
| 556 | endfunc check_errata_cve_2022_23960 |
| 557 | |
Jimmy Brisson | 958a0b1 | 2020-09-30 15:28:03 -0500 | [diff] [blame] | 558 | /* --------------------------------------------- |
| 559 | * HW will do the cache maintenance while powering down |
| 560 | * --------------------------------------------- |
| 561 | */ |
| 562 | func neoverse_v1_core_pwr_dwn |
| 563 | /* --------------------------------------------- |
| 564 | * Enable CPU power down bit in power control register |
| 565 | * --------------------------------------------- |
| 566 | */ |
| 567 | mrs x0, NEOVERSE_V1_CPUPWRCTLR_EL1 |
| 568 | orr x0, x0, #NEOVERSE_V1_CPUPWRCTLR_EL1_CORE_PWRDN_BIT |
| 569 | msr NEOVERSE_V1_CPUPWRCTLR_EL1, x0 |
Bipin Ravi | fe4b0c4 | 2022-12-15 11:57:53 -0600 | [diff] [blame] | 570 | #if ERRATA_V1_2743093 |
| 571 | mov x15, x30 |
| 572 | bl cpu_get_rev_var |
| 573 | bl errata_neoverse_v1_2743093_wa |
| 574 | mov x30, x15 |
| 575 | #endif /* ERRATA_V1_2743093 */ |
Jimmy Brisson | 958a0b1 | 2020-09-30 15:28:03 -0500 | [diff] [blame] | 576 | isb |
| 577 | ret |
| 578 | endfunc neoverse_v1_core_pwr_dwn |
| 579 | |
| 580 | /* |
| 581 | * Errata printing function for Neoverse V1. Must follow AAPCS. |
| 582 | */ |
| 583 | #if REPORT_ERRATA |
| 584 | func neoverse_v1_errata_report |
johpow01 | c73b03c | 2021-05-03 15:33:39 -0500 | [diff] [blame] | 585 | stp x8, x30, [sp, #-16]! |
| 586 | |
| 587 | bl cpu_get_rev_var |
| 588 | mov x8, x0 |
| 589 | |
| 590 | /* |
| 591 | * Report all errata. The revision-variant information is passed to |
| 592 | * checking functions of each errata. |
| 593 | */ |
Juan Pablo Conde | 31c9337 | 2022-02-28 14:14:44 -0500 | [diff] [blame] | 594 | report_errata ERRATA_V1_1618635, neoverse_v1, 1618635 |
laurenw-arm | 3c86d83 | 2021-08-02 13:22:32 -0500 | [diff] [blame] | 595 | report_errata ERRATA_V1_1774420, neoverse_v1, 1774420 |
johpow01 | c73b03c | 2021-05-03 15:33:39 -0500 | [diff] [blame] | 596 | report_errata ERRATA_V1_1791573, neoverse_v1, 1791573 |
laurenw-arm | b1923e9 | 2021-08-02 14:40:08 -0500 | [diff] [blame] | 597 | report_errata ERRATA_V1_1852267, neoverse_v1, 1852267 |
laurenw-arm | 6b56f96 | 2021-08-02 15:00:15 -0500 | [diff] [blame] | 598 | report_errata ERRATA_V1_1925756, neoverse_v1, 1925756 |
johpow01 | 07acb4f | 2020-10-07 16:38:37 -0500 | [diff] [blame] | 599 | report_errata ERRATA_V1_1940577, neoverse_v1, 1940577 |
johpow01 | 97db675 | 2021-08-02 18:59:08 -0500 | [diff] [blame] | 600 | report_errata ERRATA_V1_1966096, neoverse_v1, 1966096 |
nayanpatel-arm | fc26ffe | 2021-09-28 13:41:03 -0700 | [diff] [blame] | 601 | report_errata ERRATA_V1_2108267, neoverse_v1, 2108267 |
Bipin Ravi | 3f4cd57 | 2022-10-19 10:29:16 -0500 | [diff] [blame] | 602 | report_errata ERRATA_V1_2139242, neoverse_v1, 2139242 |
johpow01 | 4de29cb | 2021-09-02 18:29:17 -0500 | [diff] [blame] | 603 | report_errata ERRATA_V1_2216392, neoverse_v1, 2216392 |
Bipin Ravi | 971938f | 2022-06-08 16:28:46 -0500 | [diff] [blame] | 604 | report_errata ERRATA_V1_2294912, neoverse_v1, 2294912 |
Bipin Ravi | b4cb31f | 2022-06-14 17:09:23 -0500 | [diff] [blame] | 605 | report_errata ERRATA_V1_2372203, neoverse_v1, 2372203 |
Bipin Ravi | fe4b0c4 | 2022-12-15 11:57:53 -0600 | [diff] [blame] | 606 | report_errata ERRATA_V1_2743093, neoverse_v1, 2743093 |
Sona Mathew | 2ef5db7 | 2023-03-02 15:07:55 -0600 | [diff] [blame] | 607 | report_errata ERRATA_V1_2743233, neoverse_v1, 2743233 |
Sona Mathew | fe405d0 | 2023-01-11 17:04:24 -0600 | [diff] [blame] | 608 | report_errata ERRATA_V1_2779461, neoverse_v1, 2779461 |
Bipin Ravi | 8649974 | 2022-01-18 01:59:06 -0600 | [diff] [blame] | 609 | report_errata WORKAROUND_CVE_2022_23960, neoverse_v1, cve_2022_23960 |
johpow01 | c73b03c | 2021-05-03 15:33:39 -0500 | [diff] [blame] | 610 | |
| 611 | ldp x8, x30, [sp], #16 |
Jimmy Brisson | 958a0b1 | 2020-09-30 15:28:03 -0500 | [diff] [blame] | 612 | ret |
| 613 | endfunc neoverse_v1_errata_report |
| 614 | #endif |
| 615 | |
| 616 | func neoverse_v1_reset_func |
| 617 | mov x19, x30 |
| 618 | |
| 619 | /* Disable speculative loads */ |
| 620 | msr SSBS, xzr |
Jimmy Brisson | 958a0b1 | 2020-09-30 15:28:03 -0500 | [diff] [blame] | 621 | isb |
johpow01 | c73b03c | 2021-05-03 15:33:39 -0500 | [diff] [blame] | 622 | |
Bipin Ravi | 3f4cd57 | 2022-10-19 10:29:16 -0500 | [diff] [blame] | 623 | /* Get the CPU revision and stash it in x18. */ |
| 624 | bl cpu_get_rev_var |
| 625 | mov x18, x0 |
| 626 | |
Juan Pablo Conde | 31c9337 | 2022-02-28 14:14:44 -0500 | [diff] [blame] | 627 | #if ERRATA_V1_1618635 |
| 628 | mov x0, x18 |
| 629 | bl errata_neoverse_v1_1618635_wa |
| 630 | #endif |
| 631 | |
laurenw-arm | 3c86d83 | 2021-08-02 13:22:32 -0500 | [diff] [blame] | 632 | #if ERRATA_V1_1774420 |
| 633 | mov x0, x18 |
| 634 | bl errata_neoverse_v1_1774420_wa |
| 635 | #endif |
| 636 | |
johpow01 | c73b03c | 2021-05-03 15:33:39 -0500 | [diff] [blame] | 637 | #if ERRATA_V1_1791573 |
| 638 | mov x0, x18 |
| 639 | bl errata_neoverse_v1_1791573_wa |
| 640 | #endif |
| 641 | |
laurenw-arm | b1923e9 | 2021-08-02 14:40:08 -0500 | [diff] [blame] | 642 | #if ERRATA_V1_1852267 |
| 643 | mov x0, x18 |
| 644 | bl errata_neoverse_v1_1852267_wa |
| 645 | #endif |
| 646 | |
laurenw-arm | 6b56f96 | 2021-08-02 15:00:15 -0500 | [diff] [blame] | 647 | #if ERRATA_V1_1925756 |
| 648 | mov x0, x18 |
| 649 | bl errata_neoverse_v1_1925756_wa |
| 650 | #endif |
| 651 | |
johpow01 | 07acb4f | 2020-10-07 16:38:37 -0500 | [diff] [blame] | 652 | #if ERRATA_V1_1940577 |
| 653 | mov x0, x18 |
| 654 | bl errata_neoverse_v1_1940577_wa |
| 655 | #endif |
| 656 | |
johpow01 | 97db675 | 2021-08-02 18:59:08 -0500 | [diff] [blame] | 657 | #if ERRATA_V1_1966096 |
| 658 | mov x0, x18 |
| 659 | bl errata_neoverse_v1_1966096_wa |
| 660 | #endif |
| 661 | |
johpow01 | ad1ca34 | 2021-08-03 14:35:20 -0500 | [diff] [blame] | 662 | #if ERRATA_V1_2139242 |
| 663 | mov x0, x18 |
| 664 | bl errata_neoverse_v1_2139242_wa |
| 665 | #endif |
| 666 | |
nayanpatel-arm | fc26ffe | 2021-09-28 13:41:03 -0700 | [diff] [blame] | 667 | #if ERRATA_V1_2108267 |
| 668 | mov x0, x18 |
| 669 | bl errata_neoverse_v1_2108267_wa |
| 670 | #endif |
| 671 | |
johpow01 | 4de29cb | 2021-09-02 18:29:17 -0500 | [diff] [blame] | 672 | #if ERRATA_V1_2216392 |
| 673 | mov x0, x18 |
| 674 | bl errata_neoverse_v1_2216392_wa |
| 675 | #endif |
| 676 | |
Bipin Ravi | 971938f | 2022-06-08 16:28:46 -0500 | [diff] [blame] | 677 | #if ERRATA_V1_2294912 |
| 678 | mov x0, x18 |
| 679 | bl errata_neoverse_v1_2294912_wa |
| 680 | #endif |
| 681 | |
Bipin Ravi | b4cb31f | 2022-06-14 17:09:23 -0500 | [diff] [blame] | 682 | #if ERRATA_V1_2372203 |
| 683 | mov x0, x18 |
| 684 | bl errata_neoverse_v1_2372203_wa |
| 685 | #endif |
| 686 | |
Sona Mathew | 2ef5db7 | 2023-03-02 15:07:55 -0600 | [diff] [blame] | 687 | #if ERRATA_V1_2743233 |
| 688 | mov x0, x18 |
| 689 | bl errata_neoverse_v1_2743233_wa |
| 690 | #endif |
| 691 | |
Sona Mathew | fe405d0 | 2023-01-11 17:04:24 -0600 | [diff] [blame] | 692 | #if ERRATA_V1_2779461 |
| 693 | mov x0, x18 |
| 694 | bl errata_neoverse_v1_2779461_wa |
| 695 | #endif |
| 696 | |
Bipin Ravi | 8649974 | 2022-01-18 01:59:06 -0600 | [diff] [blame] | 697 | #if IMAGE_BL31 && WORKAROUND_CVE_2022_23960 |
| 698 | /* |
| 699 | * The Neoverse-V1 generic vectors are overridden to apply errata |
| 700 | * mitigation on exception entry from lower ELs. |
| 701 | */ |
| 702 | adr x0, wa_cve_vbar_neoverse_v1 |
| 703 | msr vbar_el3, x0 |
| 704 | #endif /* IMAGE_BL31 && WORKAROUND_CVE_2022_23960 */ |
| 705 | |
| 706 | isb |
Jimmy Brisson | 958a0b1 | 2020-09-30 15:28:03 -0500 | [diff] [blame] | 707 | ret x19 |
| 708 | endfunc neoverse_v1_reset_func |
| 709 | |
| 710 | /* --------------------------------------------- |
| 711 | * This function provides Neoverse-V1 specific |
| 712 | * register information for crash reporting. |
| 713 | * It needs to return with x6 pointing to |
| 714 | * a list of register names in ascii and |
| 715 | * x8 - x15 having values of registers to be |
| 716 | * reported. |
| 717 | * --------------------------------------------- |
| 718 | */ |
| 719 | .section .rodata.neoverse_v1_regs, "aS" |
| 720 | neoverse_v1_regs: /* The ascii list of register names to be reported */ |
| 721 | .asciz "cpuectlr_el1", "" |
| 722 | |
| 723 | func neoverse_v1_cpu_reg_dump |
| 724 | adr x6, neoverse_v1_regs |
| 725 | mrs x8, NEOVERSE_V1_CPUECTLR_EL1 |
| 726 | ret |
| 727 | endfunc neoverse_v1_cpu_reg_dump |
| 728 | |
| 729 | declare_cpu_ops neoverse_v1, NEOVERSE_V1_MIDR, \ |
| 730 | neoverse_v1_reset_func, \ |
| 731 | neoverse_v1_core_pwr_dwn |