Javier Almansa Sobrino | 9faad3c | 2020-10-23 13:22:07 +0100 | [diff] [blame] | 1 | /* |
Arvind Ram Prakash | 5b27ecf | 2023-06-23 14:47:30 -0500 | [diff] [blame] | 2 | * Copyright (c) 2020-2023, Arm Limited. All rights reserved. |
Javier Almansa Sobrino | 9faad3c | 2020-10-23 13:22:07 +0100 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #include <arch.h> |
| 8 | #include <asm_macros.S> |
| 9 | #include <cpu_macros.S> |
| 10 | #include <neoverse_n2.h> |
Bipin Ravi | 8649974 | 2022-01-18 01:59:06 -0600 | [diff] [blame] | 11 | #include "wa_cve_2022_23960_bhb_vector.S" |
Javier Almansa Sobrino | 9faad3c | 2020-10-23 13:22:07 +0100 | [diff] [blame] | 12 | |
| 13 | /* Hardware handled coherency */ |
| 14 | #if HW_ASSISTED_COHERENCY == 0 |
| 15 | #error "Neoverse N2 must be compiled with HW_ASSISTED_COHERENCY enabled" |
| 16 | #endif |
| 17 | |
| 18 | /* 64-bit only core */ |
| 19 | #if CTX_INCLUDE_AARCH32_REGS == 1 |
| 20 | #error "Neoverse-N2 supports only AArch64. Compile with CTX_INCLUDE_AARCH32_REGS=0" |
| 21 | #endif |
| 22 | |
Bipin Ravi | 8649974 | 2022-01-18 01:59:06 -0600 | [diff] [blame] | 23 | #if WORKAROUND_CVE_2022_23960 |
| 24 | wa_cve_2022_23960_bhb_vector_table NEOVERSE_N2_BHB_LOOP_COUNT, neoverse_n2 |
| 25 | #endif /* WORKAROUND_CVE_2022_23960 */ |
| 26 | |
Arvind Ram Prakash | 7aea56c | 2023-06-26 15:05:40 -0500 | [diff] [blame] | 27 | /* |
| 28 | * ERRATA_DSU_2313941: |
| 29 | * The errata is defined in dsu_helpers.S and applies to Neoverse N2. |
| 30 | * Henceforth creating symbolic names to the already existing errata |
| 31 | * workaround functions to get them registered under the Errata Framework. |
nayanpatel-arm | 277581e | 2021-08-06 17:46:10 -0700 | [diff] [blame] | 32 | */ |
Arvind Ram Prakash | 7aea56c | 2023-06-26 15:05:40 -0500 | [diff] [blame] | 33 | .equ check_erratum_neoverse_n2_2313941, check_errata_dsu_2313941 |
| 34 | .equ erratum_neoverse_n2_2313941_wa, errata_dsu_2313941_wa |
| 35 | add_erratum_entry neoverse_n2, ERRATUM(2313941), ERRATA_DSU_2313941, APPLY_AT_RESET |
nayanpatel-arm | 277581e | 2021-08-06 17:46:10 -0700 | [diff] [blame] | 36 | |
Arvind Ram Prakash | 7aea56c | 2023-06-26 15:05:40 -0500 | [diff] [blame] | 37 | workaround_reset_start neoverse_n2, ERRATUM(2002655), ERRATA_N2_2002655 |
nayanpatel-arm | 277581e | 2021-08-06 17:46:10 -0700 | [diff] [blame] | 38 | /* Apply instruction patching sequence */ |
| 39 | ldr x0,=0x6 |
| 40 | msr S3_6_c15_c8_0,x0 |
| 41 | ldr x0,=0xF3A08002 |
| 42 | msr S3_6_c15_c8_2,x0 |
| 43 | ldr x0,=0xFFF0F7FE |
| 44 | msr S3_6_c15_c8_3,x0 |
| 45 | ldr x0,=0x40000001003ff |
| 46 | msr S3_6_c15_c8_1,x0 |
| 47 | ldr x0,=0x7 |
| 48 | msr S3_6_c15_c8_0,x0 |
| 49 | ldr x0,=0xBF200000 |
| 50 | msr S3_6_c15_c8_2,x0 |
| 51 | ldr x0,=0xFFEF0000 |
| 52 | msr S3_6_c15_c8_3,x0 |
| 53 | ldr x0,=0x40000001003f3 |
| 54 | msr S3_6_c15_c8_1,x0 |
Arvind Ram Prakash | 7aea56c | 2023-06-26 15:05:40 -0500 | [diff] [blame] | 55 | workaround_reset_end neoverse_n2, ERRATUM(2002655) |
nayanpatel-arm | 277581e | 2021-08-06 17:46:10 -0700 | [diff] [blame] | 56 | |
Arvind Ram Prakash | 7aea56c | 2023-06-26 15:05:40 -0500 | [diff] [blame] | 57 | check_erratum_ls neoverse_n2, ERRATUM(2002655), CPU_REV(0, 0) |
nayanpatel-arm | 277581e | 2021-08-06 17:46:10 -0700 | [diff] [blame] | 58 | |
Arvind Ram Prakash | 7aea56c | 2023-06-26 15:05:40 -0500 | [diff] [blame] | 59 | workaround_reset_start neoverse_n2, ERRATUM(2025414), ERRATA_N2_2025414 |
Arvind Ram Prakash | 05464d9 | 2023-06-27 09:54:23 -0500 | [diff] [blame] | 60 | sysreg_bit_set NEOVERSE_N2_CPUECTLR_EL1, NEOVERSE_N2_CPUECTLR_EL1_PFSTIDIS_BIT |
Arvind Ram Prakash | 7aea56c | 2023-06-26 15:05:40 -0500 | [diff] [blame] | 61 | workaround_reset_end neoverse_n2, ERRATUM(2025414) |
Bipin Ravi | 7f56547 | 2021-03-31 10:10:27 -0500 | [diff] [blame] | 62 | |
Arvind Ram Prakash | 7aea56c | 2023-06-26 15:05:40 -0500 | [diff] [blame] | 63 | check_erratum_ls neoverse_n2, ERRATUM(2025414), CPU_REV(0, 0) |
Bipin Ravi | 7f56547 | 2021-03-31 10:10:27 -0500 | [diff] [blame] | 64 | |
Arvind Ram Prakash | 7aea56c | 2023-06-26 15:05:40 -0500 | [diff] [blame] | 65 | workaround_reset_start neoverse_n2, ERRATUM(2067956), ERRATA_N2_2067956 |
Arvind Ram Prakash | 05464d9 | 2023-06-27 09:54:23 -0500 | [diff] [blame] | 66 | sysreg_bit_set NEOVERSE_N2_CPUACTLR_EL1, NEOVERSE_N2_CPUACTLR_EL1_BIT_46 |
Arvind Ram Prakash | 7aea56c | 2023-06-26 15:05:40 -0500 | [diff] [blame] | 67 | workaround_reset_end neoverse_n2, ERRATUM(2067956) |
Bipin Ravi | 7e03069 | 2021-08-30 13:02:51 -0500 | [diff] [blame] | 68 | |
Arvind Ram Prakash | 7aea56c | 2023-06-26 15:05:40 -0500 | [diff] [blame] | 69 | check_erratum_ls neoverse_n2, ERRATUM(2067956), CPU_REV(0, 0) |
Arvind Ram Prakash | 5b27ecf | 2023-06-23 14:47:30 -0500 | [diff] [blame] | 70 | |
Bipin Ravi | dd5bc63 | 2023-08-29 13:59:09 -0500 | [diff] [blame] | 71 | workaround_runtime_start neoverse_n2, ERRATUM(2009478), ERRATA_N2_2009478 |
| 72 | /* Stash ERRSELR_EL1 in x2 */ |
| 73 | mrs x2, ERRSELR_EL1 |
| 74 | |
| 75 | /* Select error record 0 and clear ED bit */ |
| 76 | msr ERRSELR_EL1, xzr |
| 77 | mrs x1, ERXCTLR_EL1 |
| 78 | bfi x1, xzr, #ERXCTLR_ED_SHIFT, #1 |
| 79 | msr ERXCTLR_EL1, x1 |
| 80 | |
| 81 | /* Restore ERRSELR_EL1 from x2 */ |
| 82 | msr ERRSELR_EL1, x2 |
| 83 | workaround_runtime_end neoverse_n2, ERRATUM(2009478), NO_ISB |
| 84 | |
| 85 | check_erratum_ls neoverse_n2, ERRATUM(2009478), CPU_REV(0, 0) |
| 86 | |
Arvind Ram Prakash | 7aea56c | 2023-06-26 15:05:40 -0500 | [diff] [blame] | 87 | workaround_reset_start neoverse_n2, ERRATUM(2138953), ERRATA_N2_2138953 |
Arvind Ram Prakash | 5b27ecf | 2023-06-23 14:47:30 -0500 | [diff] [blame] | 88 | /* Apply instruction patching sequence */ |
| 89 | mrs x1, NEOVERSE_N2_CPUECTLR2_EL1 |
| 90 | mov x0, #NEOVERSE_N2_CPUECTLR2_EL1_PF_MODE_CNSRV |
| 91 | bfi x1, x0, #CPUECTLR2_EL1_PF_MODE_LSB, #CPUECTLR2_EL1_PF_MODE_WIDTH |
| 92 | msr NEOVERSE_N2_CPUECTLR2_EL1, x1 |
Arvind Ram Prakash | 7aea56c | 2023-06-26 15:05:40 -0500 | [diff] [blame] | 93 | workaround_reset_end neoverse_n2, ERRATUM(2138953) |
Bipin Ravi | 7e03069 | 2021-08-30 13:02:51 -0500 | [diff] [blame] | 94 | |
Arvind Ram Prakash | f99b798 | 2023-06-29 16:17:23 -0500 | [diff] [blame] | 95 | check_erratum_ls neoverse_n2, ERRATUM(2138953), CPU_REV(0, 3) |
Bipin Ravi | 0ba631c | 2021-09-01 01:36:43 -0500 | [diff] [blame] | 96 | |
Arvind Ram Prakash | 7aea56c | 2023-06-26 15:05:40 -0500 | [diff] [blame] | 97 | workaround_reset_start neoverse_n2, ERRATUM(2138956), ERRATA_N2_2138956 |
Bipin Ravi | 0ba631c | 2021-09-01 01:36:43 -0500 | [diff] [blame] | 98 | /* Apply instruction patching sequence */ |
| 99 | ldr x0,=0x3 |
| 100 | msr S3_6_c15_c8_0,x0 |
| 101 | ldr x0,=0xF3A08002 |
| 102 | msr S3_6_c15_c8_2,x0 |
| 103 | ldr x0,=0xFFF0F7FE |
| 104 | msr S3_6_c15_c8_3,x0 |
| 105 | ldr x0,=0x10002001003FF |
| 106 | msr S3_6_c15_c8_1,x0 |
| 107 | ldr x0,=0x4 |
| 108 | msr S3_6_c15_c8_0,x0 |
| 109 | ldr x0,=0xBF200000 |
| 110 | msr S3_6_c15_c8_2,x0 |
| 111 | ldr x0,=0xFFEF0000 |
| 112 | msr S3_6_c15_c8_3,x0 |
| 113 | ldr x0,=0x10002001003F3 |
| 114 | msr S3_6_c15_c8_1,x0 |
Arvind Ram Prakash | 7aea56c | 2023-06-26 15:05:40 -0500 | [diff] [blame] | 115 | workaround_reset_end neoverse_n2, ERRATUM(2138956) |
Bipin Ravi | 0ba631c | 2021-09-01 01:36:43 -0500 | [diff] [blame] | 116 | |
Arvind Ram Prakash | 7aea56c | 2023-06-26 15:05:40 -0500 | [diff] [blame] | 117 | check_erratum_ls neoverse_n2, ERRATUM(2138956), CPU_REV(0, 0) |
Bipin Ravi | 0ba631c | 2021-09-01 01:36:43 -0500 | [diff] [blame] | 118 | |
nayanpatel-arm | 2f15399 | 2021-10-06 15:31:24 -0700 | [diff] [blame] | 119 | |
Arvind Ram Prakash | 7aea56c | 2023-06-26 15:05:40 -0500 | [diff] [blame] | 120 | workaround_reset_start neoverse_n2, ERRATUM(2138958), ERRATA_N2_2138958 |
nayanpatel-arm | 2f15399 | 2021-10-06 15:31:24 -0700 | [diff] [blame] | 121 | /* Apply instruction patching sequence */ |
Arvind Ram Prakash | 05464d9 | 2023-06-27 09:54:23 -0500 | [diff] [blame] | 122 | sysreg_bit_set NEOVERSE_N2_CPUACTLR5_EL1, NEOVERSE_N2_CPUACTLR5_EL1_BIT_13 |
Arvind Ram Prakash | 7aea56c | 2023-06-26 15:05:40 -0500 | [diff] [blame] | 123 | workaround_reset_end neoverse_n2, ERRATUM(2138958) |
nayanpatel-arm | 2f15399 | 2021-10-06 15:31:24 -0700 | [diff] [blame] | 124 | |
Arvind Ram Prakash | 7aea56c | 2023-06-26 15:05:40 -0500 | [diff] [blame] | 125 | check_erratum_ls neoverse_n2, ERRATUM(2138958), CPU_REV(0, 0) |
nayanpatel-arm | 2f15399 | 2021-10-06 15:31:24 -0700 | [diff] [blame] | 126 | |
Arvind Ram Prakash | 7aea56c | 2023-06-26 15:05:40 -0500 | [diff] [blame] | 127 | workaround_reset_start neoverse_n2, ERRATUM(2189731), ERRATA_N2_2189731 |
Arvind Ram Prakash | 05464d9 | 2023-06-27 09:54:23 -0500 | [diff] [blame] | 128 | sysreg_bit_set NEOVERSE_N2_CPUACTLR5_EL1, NEOVERSE_N2_CPUACTLR5_EL1_BIT_44 |
Arvind Ram Prakash | 7aea56c | 2023-06-26 15:05:40 -0500 | [diff] [blame] | 129 | workaround_reset_end neoverse_n2, ERRATUM(2189731) |
nayanpatel-arm | d4c5f9c | 2021-09-28 09:46:45 -0700 | [diff] [blame] | 130 | |
Arvind Ram Prakash | 7aea56c | 2023-06-26 15:05:40 -0500 | [diff] [blame] | 131 | check_erratum_ls neoverse_n2, ERRATUM(2189731), CPU_REV(0, 0) |
nayanpatel-arm | 8e1aa01 | 2021-10-20 18:28:58 -0700 | [diff] [blame] | 132 | |
Arvind Ram Prakash | 7aea56c | 2023-06-26 15:05:40 -0500 | [diff] [blame] | 133 | workaround_reset_start neoverse_n2, ERRATUM(2242400), ERRATA_N2_2242400 |
nayanpatel-arm | 8e1aa01 | 2021-10-20 18:28:58 -0700 | [diff] [blame] | 134 | /* Apply instruction patching sequence */ |
Arvind Ram Prakash | 05464d9 | 2023-06-27 09:54:23 -0500 | [diff] [blame] | 135 | sysreg_bit_set NEOVERSE_N2_CPUACTLR5_EL1, NEOVERSE_N2_CPUACTLR5_EL1_BIT_17 |
Arvind Ram Prakash | 5b27ecf | 2023-06-23 14:47:30 -0500 | [diff] [blame] | 136 | ldr x0, =0x2 |
| 137 | msr S3_6_c15_c8_0, x0 |
| 138 | ldr x0, =0x10F600E000 |
| 139 | msr S3_6_c15_c8_2, x0 |
| 140 | ldr x0, =0x10FF80E000 |
| 141 | msr S3_6_c15_c8_3, x0 |
| 142 | ldr x0, =0x80000000003FF |
| 143 | msr S3_6_c15_c8_1, x0 |
Arvind Ram Prakash | 7aea56c | 2023-06-26 15:05:40 -0500 | [diff] [blame] | 144 | workaround_reset_end neoverse_n2, ERRATUM(2242400) |
nayanpatel-arm | 8e1aa01 | 2021-10-20 18:28:58 -0700 | [diff] [blame] | 145 | |
Arvind Ram Prakash | 7aea56c | 2023-06-26 15:05:40 -0500 | [diff] [blame] | 146 | check_erratum_ls neoverse_n2, ERRATUM(2242400), CPU_REV(0, 0) |
nayanpatel-arm | 8e1aa01 | 2021-10-20 18:28:58 -0700 | [diff] [blame] | 147 | |
Arvind Ram Prakash | 7aea56c | 2023-06-26 15:05:40 -0500 | [diff] [blame] | 148 | workaround_reset_start neoverse_n2, ERRATUM(2242415), ERRATA_N2_2242415 |
Arvind Ram Prakash | 05464d9 | 2023-06-27 09:54:23 -0500 | [diff] [blame] | 149 | sysreg_bit_set NEOVERSE_N2_CPUACTLR_EL1, NEOVERSE_N2_CPUACTLR_EL1_BIT_22 |
Arvind Ram Prakash | 7aea56c | 2023-06-26 15:05:40 -0500 | [diff] [blame] | 150 | workaround_reset_end neoverse_n2, ERRATUM(2242415) |
nayanpatel-arm | fed9813 | 2021-10-07 17:59:33 -0700 | [diff] [blame] | 151 | |
Arvind Ram Prakash | 7aea56c | 2023-06-26 15:05:40 -0500 | [diff] [blame] | 152 | check_erratum_ls neoverse_n2, ERRATUM(2242415), CPU_REV(0, 0) |
nayanpatel-arm | fed9813 | 2021-10-07 17:59:33 -0700 | [diff] [blame] | 153 | |
Arvind Ram Prakash | 7aea56c | 2023-06-26 15:05:40 -0500 | [diff] [blame] | 154 | workaround_reset_start neoverse_n2, ERRATUM(2280757), ERRATA_N2_2280757 |
nayanpatel-arm | 45b9f6f | 2021-10-20 17:30:46 -0700 | [diff] [blame] | 155 | /* Apply instruction patching sequence */ |
Arvind Ram Prakash | 05464d9 | 2023-06-27 09:54:23 -0500 | [diff] [blame] | 156 | sysreg_bit_set NEOVERSE_N2_CPUACTLR_EL1, NEOVERSE_N2_CPUACTLR_EL1_BIT_22 |
Arvind Ram Prakash | 7aea56c | 2023-06-26 15:05:40 -0500 | [diff] [blame] | 157 | workaround_reset_end neoverse_n2, ERRATUM(2280757) |
nayanpatel-arm | 45b9f6f | 2021-10-20 17:30:46 -0700 | [diff] [blame] | 158 | |
Arvind Ram Prakash | 7aea56c | 2023-06-26 15:05:40 -0500 | [diff] [blame] | 159 | check_erratum_ls neoverse_n2, ERRATUM(2280757), CPU_REV(0, 0) |
Boyan Karatotev | d3f8b4d | 2022-10-03 14:07:08 +0100 | [diff] [blame] | 160 | |
Arvind Ram Prakash | 7aea56c | 2023-06-26 15:05:40 -0500 | [diff] [blame] | 161 | workaround_runtime_start neoverse_n2, ERRATUM(2326639), ERRATA_N2_2326639 |
Boyan Karatotev | d3f8b4d | 2022-10-03 14:07:08 +0100 | [diff] [blame] | 162 | /* Set bit 36 in ACTLR2_EL1 */ |
Arvind Ram Prakash | 05464d9 | 2023-06-27 09:54:23 -0500 | [diff] [blame] | 163 | sysreg_bit_set NEOVERSE_N2_CPUACTLR2_EL1, NEOVERSE_N2_CPUACTLR2_EL1_BIT_36 |
Arvind Ram Prakash | 7aea56c | 2023-06-26 15:05:40 -0500 | [diff] [blame] | 164 | workaround_runtime_end neoverse_n2, ERRATUM(2326639) |
Akram Ahmad | b621bda | 2022-07-18 12:27:29 +0100 | [diff] [blame] | 165 | |
Arvind Ram Prakash | 7aea56c | 2023-06-26 15:05:40 -0500 | [diff] [blame] | 166 | check_erratum_ls neoverse_n2, ERRATUM(2326639), CPU_REV(0, 0) |
Akram Ahmad | b621bda | 2022-07-18 12:27:29 +0100 | [diff] [blame] | 167 | |
Bipin Ravi | 2997ab9 | 2023-10-17 06:21:15 -0500 | [diff] [blame] | 168 | workaround_runtime_start neoverse_n2, ERRATUM(2340933), ERRATA_N2_2340933 |
| 169 | /* Set bit 61 in CPUACTLR5_EL1 */ |
| 170 | sysreg_bit_set NEOVERSE_N2_CPUACTLR5_EL1, BIT(61) |
| 171 | workaround_runtime_end neoverse_n2, ERRATUM(2340933) |
| 172 | |
| 173 | check_erratum_ls neoverse_n2, ERRATUM(2340933), CPU_REV(0, 0) |
| 174 | |
Bipin Ravi | 03ba5d8 | 2023-10-17 05:56:01 -0500 | [diff] [blame] | 175 | workaround_runtime_start neoverse_n2, ERRATUM(2346952), ERRATA_N2_2346952 |
| 176 | /* Set TXREQ to STATIC and full L2 TQ size */ |
| 177 | mrs x1, NEOVERSE_N2_CPUECTLR2_EL1 |
| 178 | mov x0, #CPUECTLR2_EL1_TXREQ_STATIC_FULL |
| 179 | bfi x1, x0, #CPUECTLR2_EL1_TXREQ_LSB, #CPUECTLR2_EL1_TXREQ_WIDTH |
| 180 | msr NEOVERSE_N2_CPUECTLR2_EL1, x1 |
| 181 | workaround_runtime_end neoverse_n2, ERRATUM(2346952) |
| 182 | |
| 183 | check_erratum_ls neoverse_n2, ERRATUM(2346952), CPU_REV(0, 2) |
| 184 | |
Arvind Ram Prakash | 7aea56c | 2023-06-26 15:05:40 -0500 | [diff] [blame] | 185 | workaround_reset_start neoverse_n2, ERRATUM(2376738), ERRATA_N2_2376738 |
Akram Ahmad | b621bda | 2022-07-18 12:27:29 +0100 | [diff] [blame] | 186 | /* Set CPUACTLR2_EL1[0] to 1 to force PLDW/PFRM |
| 187 | * ST to behave like PLD/PFRM LD and not cause |
| 188 | * invalidations to other PE caches. |
| 189 | */ |
Arvind Ram Prakash | 05464d9 | 2023-06-27 09:54:23 -0500 | [diff] [blame] | 190 | sysreg_bit_set NEOVERSE_N2_CPUACTLR2_EL1, NEOVERSE_N2_CPUACTLR2_EL1_BIT_0 |
Arvind Ram Prakash | 7aea56c | 2023-06-26 15:05:40 -0500 | [diff] [blame] | 191 | workaround_reset_end neoverse_n2, ERRATUM(2376738) |
Akram Ahmad | b621bda | 2022-07-18 12:27:29 +0100 | [diff] [blame] | 192 | |
Arvind Ram Prakash | f99b798 | 2023-06-29 16:17:23 -0500 | [diff] [blame] | 193 | check_erratum_ls neoverse_n2, ERRATUM(2376738), CPU_REV(0, 3) |
Daniel Boulby | 1af2b11 | 2022-07-06 14:33:13 +0100 | [diff] [blame] | 194 | |
Arvind Ram Prakash | 7aea56c | 2023-06-26 15:05:40 -0500 | [diff] [blame] | 195 | workaround_reset_start neoverse_n2, ERRATUM(2388450), ERRATA_N2_2388450 |
Daniel Boulby | 1af2b11 | 2022-07-06 14:33:13 +0100 | [diff] [blame] | 196 | /*Set bit 40 in ACTLR2_EL1 */ |
Arvind Ram Prakash | 05464d9 | 2023-06-27 09:54:23 -0500 | [diff] [blame] | 197 | sysreg_bit_set NEOVERSE_N2_CPUACTLR2_EL1, NEOVERSE_N2_CPUACTLR2_EL1_BIT_40 |
Arvind Ram Prakash | 7aea56c | 2023-06-26 15:05:40 -0500 | [diff] [blame] | 198 | workaround_reset_end neoverse_n2, ERRATUM(2388450) |
Daniel Boulby | 1af2b11 | 2022-07-06 14:33:13 +0100 | [diff] [blame] | 199 | |
Arvind Ram Prakash | 7aea56c | 2023-06-26 15:05:40 -0500 | [diff] [blame] | 200 | check_erratum_ls neoverse_n2, ERRATUM(2388450), CPU_REV(0, 0) |
Daniel Boulby | 1af2b11 | 2022-07-06 14:33:13 +0100 | [diff] [blame] | 201 | |
Arvind Ram Prakash | 465f93b | 2023-07-05 17:24:23 -0500 | [diff] [blame] | 202 | workaround_reset_start neoverse_n2, ERRATUM(2743014), ERRATA_N2_2743014 |
| 203 | /* Set CPUACTLR5_EL1[56:55] to 2'b01 */ |
| 204 | sysreg_bit_set NEOVERSE_N2_CPUACTLR5_EL1, NEOVERSE_N2_CPUACTLR5_EL1_BIT_55 |
| 205 | sysreg_bit_clear NEOVERSE_N2_CPUACTLR5_EL1, NEOVERSE_N2_CPUACTLR5_EL1_BIT_56 |
| 206 | workaround_reset_end neoverse_n2, ERRATUM(2743014) |
| 207 | |
| 208 | check_erratum_ls neoverse_n2, ERRATUM(2743014), CPU_REV(0, 2) |
| 209 | |
Arvind Ram Prakash | 7aea56c | 2023-06-26 15:05:40 -0500 | [diff] [blame] | 210 | workaround_runtime_start neoverse_n2, ERRATUM(2743089), ERRATA_N2_2743089 |
Bipin Ravi | cc744bf | 2022-12-07 17:01:26 -0600 | [diff] [blame] | 211 | /* dsb before isb of power down sequence */ |
| 212 | dsb sy |
Arvind Ram Prakash | 7aea56c | 2023-06-26 15:05:40 -0500 | [diff] [blame] | 213 | workaround_runtime_end neoverse_n2, ERRATUM(2743089) |
Bipin Ravi | cc744bf | 2022-12-07 17:01:26 -0600 | [diff] [blame] | 214 | |
Arvind Ram Prakash | 7aea56c | 2023-06-26 15:05:40 -0500 | [diff] [blame] | 215 | check_erratum_ls neoverse_n2, ERRATUM(2743089), CPU_REV(0, 2) |
Bipin Ravi | cc744bf | 2022-12-07 17:01:26 -0600 | [diff] [blame] | 216 | |
Arvind Ram Prakash | 189622a | 2023-07-17 14:46:14 -0500 | [diff] [blame] | 217 | workaround_reset_start neoverse_n2, ERRATUM(2779511), ERRATA_N2_2779511 |
| 218 | /* Set bit 47 in ACTLR3_EL1 */ |
| 219 | sysreg_bit_set NEOVERSE_N2_CPUACTLR3_EL1, NEOVERSE_N2_CPUACTLR3_EL1_BIT_47 |
| 220 | workaround_reset_end neoverse_n2, ERRATUM(2779511) |
| 221 | |
| 222 | check_erratum_ls neoverse_n2, ERRATUM(2779511), CPU_REV(0, 2) |
| 223 | |
Arvind Ram Prakash | 7aea56c | 2023-06-26 15:05:40 -0500 | [diff] [blame] | 224 | workaround_reset_start neoverse_n2, CVE(2022,23960), WORKAROUND_CVE_2022_23960 |
| 225 | #if IMAGE_BL31 |
| 226 | /* |
| 227 | * The Neoverse-N2 generic vectors are overridden to apply errata |
| 228 | * mitigation on exception entry from lower ELs. |
| 229 | */ |
Arvind Ram Prakash | 05464d9 | 2023-06-27 09:54:23 -0500 | [diff] [blame] | 230 | override_vector_table wa_cve_vbar_neoverse_n2 |
Arvind Ram Prakash | 7aea56c | 2023-06-26 15:05:40 -0500 | [diff] [blame] | 231 | #endif /* IMAGE_BL31 */ |
| 232 | workaround_reset_end neoverse_n2, CVE(2022,23960) |
| 233 | |
| 234 | check_erratum_chosen neoverse_n2, CVE(2022, 23960), WORKAROUND_CVE_2022_23960 |
Bipin Ravi | 8649974 | 2022-01-18 01:59:06 -0600 | [diff] [blame] | 235 | |
Bipin Ravi | 7f56547 | 2021-03-31 10:10:27 -0500 | [diff] [blame] | 236 | /* ------------------------------------------- |
Javier Almansa Sobrino | 9faad3c | 2020-10-23 13:22:07 +0100 | [diff] [blame] | 237 | * The CPU Ops reset function for Neoverse N2. |
Bipin Ravi | 7f56547 | 2021-03-31 10:10:27 -0500 | [diff] [blame] | 238 | * ------------------------------------------- |
Javier Almansa Sobrino | 9faad3c | 2020-10-23 13:22:07 +0100 | [diff] [blame] | 239 | */ |
Arvind Ram Prakash | 7aea56c | 2023-06-26 15:05:40 -0500 | [diff] [blame] | 240 | cpu_reset_func_start neoverse_n2 |
nayanpatel-arm | 277581e | 2021-08-06 17:46:10 -0700 | [diff] [blame] | 241 | |
Javier Almansa Sobrino | 9faad3c | 2020-10-23 13:22:07 +0100 | [diff] [blame] | 242 | /* Check if the PE implements SSBS */ |
| 243 | mrs x0, id_aa64pfr1_el1 |
| 244 | tst x0, #(ID_AA64PFR1_EL1_SSBS_MASK << ID_AA64PFR1_EL1_SSBS_SHIFT) |
| 245 | b.eq 1f |
| 246 | |
| 247 | /* Disable speculative loads */ |
| 248 | msr SSBS, xzr |
| 249 | 1: |
| 250 | /* Force all cacheable atomic instructions to be near */ |
Arvind Ram Prakash | 05464d9 | 2023-06-27 09:54:23 -0500 | [diff] [blame] | 251 | sysreg_bit_set NEOVERSE_N2_CPUACTLR2_EL1, NEOVERSE_N2_CPUACTLR2_EL1_BIT_2 |
Javier Almansa Sobrino | 9faad3c | 2020-10-23 13:22:07 +0100 | [diff] [blame] | 252 | |
Andre Przywara | 0b7f1b0 | 2023-03-21 13:53:19 +0000 | [diff] [blame] | 253 | #if ENABLE_FEAT_AMU |
Javier Almansa Sobrino | 9faad3c | 2020-10-23 13:22:07 +0100 | [diff] [blame] | 254 | /* Make sure accesses from EL0/EL1 and EL2 are not trapped to EL3 */ |
Arvind Ram Prakash | 05464d9 | 2023-06-27 09:54:23 -0500 | [diff] [blame] | 255 | sysreg_bit_set cptr_el3, TAM_BIT |
Javier Almansa Sobrino | 9faad3c | 2020-10-23 13:22:07 +0100 | [diff] [blame] | 256 | /* Make sure accesses from EL0/EL1 are not trapped to EL2 */ |
Arvind Ram Prakash | 05464d9 | 2023-06-27 09:54:23 -0500 | [diff] [blame] | 257 | sysreg_bit_set cptr_el2, TAM_BIT |
Javier Almansa Sobrino | 9faad3c | 2020-10-23 13:22:07 +0100 | [diff] [blame] | 258 | /* No need to enable the counters as this would be done at el3 exit */ |
| 259 | #endif |
| 260 | |
| 261 | #if NEOVERSE_Nx_EXTERNAL_LLC |
| 262 | /* Some systems may have External LLC, core needs to be made aware */ |
Arvind Ram Prakash | 05464d9 | 2023-06-27 09:54:23 -0500 | [diff] [blame] | 263 | sysreg_bit_set NEOVERSE_N2_CPUECTLR_EL1, NEOVERSE_N2_CPUECTLR_EL1_EXTLLC_BIT |
Javier Almansa Sobrino | 9faad3c | 2020-10-23 13:22:07 +0100 | [diff] [blame] | 264 | #endif |
Arvind Ram Prakash | 7aea56c | 2023-06-26 15:05:40 -0500 | [diff] [blame] | 265 | cpu_reset_func_end neoverse_n2 |
Javier Almansa Sobrino | 9faad3c | 2020-10-23 13:22:07 +0100 | [diff] [blame] | 266 | |
| 267 | func neoverse_n2_core_pwr_dwn |
Boyan Karatotev | d3f8b4d | 2022-10-03 14:07:08 +0100 | [diff] [blame] | 268 | |
Bipin Ravi | dd5bc63 | 2023-08-29 13:59:09 -0500 | [diff] [blame] | 269 | apply_erratum neoverse_n2, ERRATUM(2009478), ERRATA_N2_2009478 |
| 270 | apply_erratum neoverse_n2, ERRATUM(2326639), ERRATA_N2_2326639, NO_GET_CPU_REV |
| 271 | |
Bipin Ravi | 7f56547 | 2021-03-31 10:10:27 -0500 | [diff] [blame] | 272 | /* --------------------------------------------------- |
Javier Almansa Sobrino | 9faad3c | 2020-10-23 13:22:07 +0100 | [diff] [blame] | 273 | * Enable CPU power down bit in power control register |
| 274 | * No need to do cache maintenance here. |
Bipin Ravi | 7f56547 | 2021-03-31 10:10:27 -0500 | [diff] [blame] | 275 | * --------------------------------------------------- |
Javier Almansa Sobrino | 9faad3c | 2020-10-23 13:22:07 +0100 | [diff] [blame] | 276 | */ |
Arvind Ram Prakash | 05464d9 | 2023-06-27 09:54:23 -0500 | [diff] [blame] | 277 | sysreg_bit_set NEOVERSE_N2_CPUPWRCTLR_EL1, NEOVERSE_N2_CORE_PWRDN_EN_BIT |
| 278 | |
| 279 | apply_erratum neoverse_n2, ERRATUM(2743089), ERRATA_N2_2743089 |
| 280 | |
Javier Almansa Sobrino | 9faad3c | 2020-10-23 13:22:07 +0100 | [diff] [blame] | 281 | isb |
| 282 | ret |
| 283 | endfunc neoverse_n2_core_pwr_dwn |
| 284 | |
Arvind Ram Prakash | 7aea56c | 2023-06-26 15:05:40 -0500 | [diff] [blame] | 285 | errata_report_shim neoverse_n2 |
Javier Almansa Sobrino | 9faad3c | 2020-10-23 13:22:07 +0100 | [diff] [blame] | 286 | |
| 287 | /* --------------------------------------------- |
| 288 | * This function provides Neoverse N2 specific |
| 289 | * register information for crash reporting. |
| 290 | * It needs to return with x6 pointing to |
| 291 | * a list of register names in ASCII and |
| 292 | * x8 - x15 having values of registers to be |
| 293 | * reported. |
| 294 | * --------------------------------------------- |
| 295 | */ |
| 296 | .section .rodata.neoverse_n2_regs, "aS" |
| 297 | neoverse_n2_regs: /* The ASCII list of register names to be reported */ |
| 298 | .asciz "cpupwrctlr_el1", "" |
| 299 | |
| 300 | func neoverse_n2_cpu_reg_dump |
| 301 | adr x6, neoverse_n2_regs |
| 302 | mrs x8, NEOVERSE_N2_CPUPWRCTLR_EL1 |
| 303 | ret |
| 304 | endfunc neoverse_n2_cpu_reg_dump |
| 305 | |
| 306 | declare_cpu_ops neoverse_n2, NEOVERSE_N2_MIDR, \ |
| 307 | neoverse_n2_reset_func, \ |
| 308 | neoverse_n2_core_pwr_dwn |