| 1 |
/* |
| 2 |
* Copyright (c) 2021-2025, Arm Limited. All rights reserved. |
| 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 <cortex_a710.h> |
| 11 |
#include <cpu_macros.S> |
| 12 |
#include <plat_macros.S> |
| 13 |
#include "wa_cve_2022_23960_bhb_vector.S" |
| 14 |
|
| 15 |
/* Hardware handled coherency */ |
| 16 |
#if HW_ASSISTED_COHERENCY == 0 |
| 17 |
#error "Cortex A710 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 "Cortex A710 supports only AArch64. Compile with CTX_INCLUDE_AARCH32_REGS=0" |
| 23 |
#endif |
| 24 |
|
| 25 |
.global check_erratum_cortex_a710_3701772 |
| 26 |
|
| 27 |
#if WORKAROUND_CVE_2022_23960 |
| 28 |
wa_cve_2022_23960_bhb_vector_table CORTEX_A710_BHB_LOOP_COUNT, cortex_a710 |
| 29 |
#endif /* WORKAROUND_CVE_2022_23960 */ |
| 30 |
|
| 31 |
/* Disable hardware page aggregation. Enables mitigation for `CVE-2024-5660` */ |
| 32 |
workaround_reset_start cortex_a710, CVE(2024, 5660), WORKAROUND_CVE_2024_5660 |
| 33 |
sysreg_bit_set CORTEX_A710_CPUECTLR_EL1, BIT(46) |
| 34 |
workaround_reset_end cortex_a710, CVE(2024, 5660) |
| 35 |
|
| 36 |
check_erratum_ls cortex_a710, CVE(2024, 5660), CPU_REV(2, 1) |
| 37 |
|
| 38 |
workaround_reset_start cortex_a710, ERRATUM(1987031), ERRATA_A710_1987031 |
| 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 |
| 55 |
workaround_reset_end cortex_a710, ERRATUM(1987031) |
| 56 |
|
| 57 |
check_erratum_ls cortex_a710, ERRATUM(1987031), CPU_REV(2, 0) |
| 58 |
|
| 59 |
workaround_runtime_start cortex_a710, ERRATUM(2008768), ERRATA_A710_2008768 |
| 60 |
/* Stash ERRSELR_EL1 in x2 */ |
| 61 |
mrs x2, ERRSELR_EL1 |
| 62 |
|
| 63 |
/* Select error record 0 and clear ED bit */ |
| 64 |
msr ERRSELR_EL1, xzr |
| 65 |
mrs x1, ERXCTLR_EL1 |
| 66 |
bfi x1, xzr, #ERXCTLR_ED_SHIFT, #1 |
| 67 |
msr ERXCTLR_EL1, x1 |
| 68 |
|
| 69 |
/* Select error record 1 and clear ED bit */ |
| 70 |
mov x0, #1 |
| 71 |
msr ERRSELR_EL1, x0 |
| 72 |
mrs x1, ERXCTLR_EL1 |
| 73 |
bfi x1, xzr, #ERXCTLR_ED_SHIFT, #1 |
| 74 |
msr ERXCTLR_EL1, x1 |
| 75 |
|
| 76 |
/* Restore ERRSELR_EL1 from x2 */ |
| 77 |
msr ERRSELR_EL1, x2 |
| 78 |
workaround_runtime_end cortex_a710, ERRATUM(2008768), NO_ISB |
| 79 |
|
| 80 |
check_erratum_ls cortex_a710, ERRATUM(2008768), CPU_REV(2, 0) |
| 81 |
|
| 82 |
workaround_reset_start cortex_a710, ERRATUM(2017096), ERRATA_A710_2017096 |
| 83 |
sysreg_bit_set CORTEX_A710_CPUECTLR_EL1, CORTEX_A710_CPUECTLR_EL1_PFSTIDIS_BIT |
| 84 |
workaround_reset_end cortex_a710, ERRATUM(2017096) |
| 85 |
|
| 86 |
check_erratum_ls cortex_a710, ERRATUM(2017096), CPU_REV(2, 0) |
| 87 |
|
| 88 |
workaround_reset_start cortex_a710, ERRATUM(2055002), ERRATA_A710_2055002 |
| 89 |
sysreg_bit_set CORTEX_A710_CPUACTLR_EL1, CORTEX_A710_CPUACTLR_EL1_BIT_46 |
| 90 |
workaround_reset_end cortex_a710, ERRATUM(2055002) |
| 91 |
|
| 92 |
check_erratum_range cortex_a710, ERRATUM(2055002), CPU_REV(1, 0), CPU_REV(2, 0) |
| 93 |
|
| 94 |
workaround_reset_start cortex_a710, ERRATUM(2058056), ERRATA_A710_2058056 |
| 95 |
sysreg_bitfield_insert CORTEX_A710_CPUECTLR2_EL1, CORTEX_A710_CPUECTLR2_EL1_PF_MODE_CNSRV, \ |
| 96 |
CPUECTLR2_EL1_PF_MODE_LSB, CPUECTLR2_EL1_PF_MODE_WIDTH |
| 97 |
workaround_reset_end cortex_a710, ERRATUM(2058056) |
| 98 |
|
| 99 |
check_erratum_ls cortex_a710, ERRATUM(2058056), CPU_REV(2, 1) |
| 100 |
|
| 101 |
workaround_reset_start cortex_a710, ERRATUM(2081180), ERRATA_A710_2081180 |
| 102 |
ldr x0,=0x3 |
| 103 |
msr S3_6_c15_c8_0,x0 |
| 104 |
ldr x0,=0xF3A08002 |
| 105 |
msr S3_6_c15_c8_2,x0 |
| 106 |
ldr x0,=0xFFF0F7FE |
| 107 |
msr S3_6_c15_c8_3,x0 |
| 108 |
ldr x0,=0x10002001003FF |
| 109 |
msr S3_6_c15_c8_1,x0 |
| 110 |
ldr x0,=0x4 |
| 111 |
msr S3_6_c15_c8_0,x0 |
| 112 |
ldr x0,=0xBF200000 |
| 113 |
msr S3_6_c15_c8_2,x0 |
| 114 |
ldr x0,=0xFFEF0000 |
| 115 |
msr S3_6_c15_c8_3,x0 |
| 116 |
ldr x0,=0x10002001003F3 |
| 117 |
msr S3_6_c15_c8_1,x0 |
| 118 |
workaround_reset_end cortex_a710, ERRATUM(2081180) |
| 119 |
|
| 120 |
check_erratum_ls cortex_a710, ERRATUM(2081180), CPU_REV(2, 0) |
| 121 |
|
| 122 |
workaround_reset_start cortex_a710, ERRATUM(2083908), ERRATA_A710_2083908 |
| 123 |
sysreg_bit_set CORTEX_A710_CPUACTLR5_EL1, CORTEX_A710_CPUACTLR5_EL1_BIT_13 |
| 124 |
workaround_reset_end cortex_a710, ERRATUM(2083908) |
| 125 |
|
| 126 |
check_erratum_range cortex_a710, ERRATUM(2083908), CPU_REV(2, 0), CPU_REV(2, 0) |
| 127 |
|
| 128 |
workaround_reset_start cortex_a710, ERRATUM(2136059), ERRATA_A710_2136059 |
| 129 |
sysreg_bit_set CORTEX_A710_CPUACTLR5_EL1, CORTEX_A710_CPUACTLR5_EL1_BIT_44 |
| 130 |
workaround_reset_end cortex_a710, ERRATUM(2136059) |
| 131 |
|
| 132 |
check_erratum_ls cortex_a710, ERRATUM(2136059), CPU_REV(2, 0) |
| 133 |
|
| 134 |
workaround_reset_start cortex_a710, ERRATUM(2147715), ERRATA_A710_2147715 |
| 135 |
sysreg_bit_set CORTEX_A710_CPUACTLR_EL1, CORTEX_A710_CPUACTLR_EL1_BIT_22 |
| 136 |
workaround_reset_end cortex_a710, ERRATUM(2147715) |
| 137 |
|
| 138 |
check_erratum_range cortex_a710, ERRATUM(2147715), CPU_REV(2, 0), CPU_REV(2, 0) |
| 139 |
|
| 140 |
workaround_reset_start cortex_a710, ERRATUM(2216384), ERRATA_A710_2216384 |
| 141 |
sysreg_bit_set CORTEX_A710_CPUACTLR5_EL1, CORTEX_A710_CPUACTLR5_EL1_BIT_17 |
| 142 |
|
| 143 |
ldr x0,=0x5 |
| 144 |
msr CORTEX_A710_CPUPSELR_EL3, x0 |
| 145 |
ldr x0,=0x10F600E000 |
| 146 |
msr CORTEX_A710_CPUPOR_EL3, x0 |
| 147 |
ldr x0,=0x10FF80E000 |
| 148 |
msr CORTEX_A710_CPUPMR_EL3, x0 |
| 149 |
ldr x0,=0x80000000003FF |
| 150 |
msr CORTEX_A710_CPUPCR_EL3, x0 |
| 151 |
workaround_reset_end cortex_a710, ERRATUM(2216384) |
| 152 |
|
| 153 |
check_erratum_ls cortex_a710, ERRATUM(2216384), CPU_REV(2, 0) |
| 154 |
|
| 155 |
workaround_reset_start cortex_a710, ERRATUM(2267065), ERRATA_A710_2267065 |
| 156 |
sysreg_bit_set CORTEX_A710_CPUACTLR_EL1, CORTEX_A710_CPUACTLR_EL1_BIT_22 |
| 157 |
workaround_reset_end cortex_a710, ERRATUM(2267065) |
| 158 |
|
| 159 |
check_erratum_ls cortex_a710, ERRATUM(2267065), CPU_REV(2, 0) |
| 160 |
|
| 161 |
workaround_reset_start cortex_a710, ERRATUM(2282622), ERRATA_A710_2282622 |
| 162 |
sysreg_bit_set CORTEX_A710_CPUACTLR2_EL1, BIT(0) |
| 163 |
workaround_reset_end cortex_a710, ERRATUM(2282622) |
| 164 |
|
| 165 |
check_erratum_ls cortex_a710, ERRATUM(2282622), CPU_REV(2, 1) |
| 166 |
|
| 167 |
workaround_runtime_start cortex_a710, ERRATUM(2291219), ERRATA_A710_2291219 |
| 168 |
/* Set bit 36 in ACTLR2_EL1 */ |
| 169 |
sysreg_bit_set CORTEX_A710_CPUACTLR2_EL1, CORTEX_A710_CPUACTLR2_EL1_BIT_36 |
| 170 |
workaround_runtime_end cortex_a710, ERRATUM(2291219), NO_ISB |
| 171 |
|
| 172 |
check_erratum_ls cortex_a710, ERRATUM(2291219), CPU_REV(2, 0) |
| 173 |
|
| 174 |
/* |
| 175 |
* ERRATA_DSU_2313941 is defined in dsu_helpers.S but applies to Cortex-A710 as |
| 176 |
* well. Create a symbollic link to existing errata workaround to get them |
| 177 |
* registered under the Errata Framework. |
| 178 |
*/ |
| 179 |
.equ check_erratum_cortex_a710_2313941, check_errata_dsu_2313941 |
| 180 |
.equ erratum_cortex_a710_2313941_wa, errata_dsu_2313941_wa |
| 181 |
add_erratum_entry cortex_a710, ERRATUM(2313941), ERRATA_DSU_2313941, APPLY_AT_RESET |
| 182 |
|
| 183 |
workaround_reset_start cortex_a710, ERRATUM(2371105), ERRATA_A710_2371105 |
| 184 |
/* Set bit 40 in CPUACTLR2_EL1 */ |
| 185 |
sysreg_bit_set CORTEX_A710_CPUACTLR2_EL1, CORTEX_A710_CPUACTLR2_EL1_BIT_40 |
| 186 |
workaround_reset_end cortex_a710, ERRATUM(2371105) |
| 187 |
|
| 188 |
check_erratum_ls cortex_a710, ERRATUM(2371105), CPU_REV(2, 0) |
| 189 |
|
| 190 |
workaround_reset_start cortex_a710, ERRATUM(2742423), ERRATA_A710_2742423 |
| 191 |
/* Set CPUACTLR5_EL1[56:55] to 2'b01 */ |
| 192 |
sysreg_bit_set CORTEX_A710_CPUACTLR5_EL1, BIT(55) |
| 193 |
sysreg_bit_clear CORTEX_A710_CPUACTLR5_EL1, BIT(56) |
| 194 |
workaround_reset_end cortex_a710, ERRATUM(2742423) |
| 195 |
|
| 196 |
check_erratum_ls cortex_a710, ERRATUM(2742423), CPU_REV(2, 1) |
| 197 |
|
| 198 |
workaround_runtime_start cortex_a710, ERRATUM(2768515), ERRATA_A710_2768515 |
| 199 |
/* dsb before isb of power down sequence */ |
| 200 |
dsb sy |
| 201 |
workaround_runtime_end cortex_a710, ERRATUM(2768515), NO_ISB |
| 202 |
|
| 203 |
check_erratum_ls cortex_a710, ERRATUM(2768515), CPU_REV(2, 1) |
| 204 |
|
| 205 |
workaround_reset_start cortex_a710, ERRATUM(2778471), ERRATA_A710_2778471 |
| 206 |
sysreg_bit_set CORTEX_A710_CPUACTLR3_EL1, BIT(47) |
| 207 |
workaround_reset_end cortex_a710, ERRATUM(2778471) |
| 208 |
|
| 209 |
check_erratum_ls cortex_a710, ERRATUM(2778471), CPU_REV(2, 1) |
| 210 |
|
| 211 |
workaround_reset_start cortex_a710, CVE(2022, 23960), WORKAROUND_CVE_2022_23960 |
| 212 |
#if IMAGE_BL31 |
| 213 |
/* |
| 214 |
* The Cortex-A710 generic vectors are overridden to apply errata |
| 215 |
* mitigation on exception entry from lower ELs. |
| 216 |
*/ |
| 217 |
override_vector_table wa_cve_vbar_cortex_a710 |
| 218 |
#endif /* IMAGE_BL31 */ |
| 219 |
workaround_reset_end cortex_a710, CVE(2022, 23960) |
| 220 |
|
| 221 |
check_erratum_chosen cortex_a710, CVE(2022, 23960), WORKAROUND_CVE_2022_23960 |
| 222 |
|
| 223 |
add_erratum_entry cortex_a710, ERRATUM(3701772), ERRATA_A710_3701772, NO_APPLY_AT_RESET |
| 224 |
|
| 225 |
check_erratum_ls cortex_a710, ERRATUM(3701772), CPU_REV(2, 1) |
| 226 |
|
| 227 |
/* ---------------------------------------------------- |
| 228 |
* HW will do the cache maintenance while powering down |
| 229 |
* ---------------------------------------------------- |
| 230 |
*/ |
| 231 |
func cortex_a710_core_pwr_dwn |
| 232 |
apply_erratum cortex_a710, ERRATUM(2008768), ERRATA_A710_2008768, NO_GET_CPU_REV |
| 233 |
apply_erratum cortex_a710, ERRATUM(2291219), ERRATA_A710_2291219, NO_GET_CPU_REV |
| 234 |
|
| 235 |
/* --------------------------------------------------- |
| 236 |
* Enable CPU power down bit in power control register |
| 237 |
* --------------------------------------------------- |
| 238 |
*/ |
| 239 |
sysreg_bit_set CORTEX_A710_CPUPWRCTLR_EL1, CORTEX_A710_CPUPWRCTLR_EL1_CORE_PWRDN_BIT |
| 240 |
apply_erratum cortex_a710, ERRATUM(2768515), ERRATA_A710_2768515, NO_GET_CPU_REV |
| 241 |
isb |
| 242 |
ret |
| 243 |
endfunc cortex_a710_core_pwr_dwn |
| 244 |
|
| 245 |
cpu_reset_func_start cortex_a710 |
| 246 |
/* Disable speculative loads */ |
| 247 |
msr SSBS, xzr |
| 248 |
cpu_reset_func_end cortex_a710 |
| 249 |
|
| 250 |
/* --------------------------------------------- |
| 251 |
* This function provides Cortex-A710 specific |
| 252 |
* register information for crash reporting. |
| 253 |
* It needs to return with x6 pointing to |
| 254 |
* a list of register names in ascii and |
| 255 |
* x8 - x15 having values of registers to be |
| 256 |
* reported. |
| 257 |
* --------------------------------------------- |
| 258 |
*/ |
| 259 |
.section .rodata.cortex_a710_regs, "aS" |
| 260 |
cortex_a710_regs: /* The ascii list of register names to be reported */ |
| 261 |
.asciz "cpuectlr_el1", "" |
| 262 |
|
| 263 |
func cortex_a710_cpu_reg_dump |
| 264 |
adr x6, cortex_a710_regs |
| 265 |
mrs x8, CORTEX_A710_CPUECTLR_EL1 |
| 266 |
ret |
| 267 |
endfunc cortex_a710_cpu_reg_dump |
| 268 |
|
| 269 |
declare_cpu_ops cortex_a710, CORTEX_A710_MIDR, \ |
| 270 |
cortex_a710_reset_func, \ |
| 271 |
cortex_a710_core_pwr_dwn |