1/* 2 * Copyright (c) 2021-2026, 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_a715.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-A715 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-A715 supports only AArch64. Compile with CTX_INCLUDE_AARCH32_REGS=0" 23#endif 24 25.global check_erratum_cortex_a715_3699560 26 27#if WORKAROUND_CVE_2022_23960 28 wa_cve_2022_23960_bhb_vector_table CORTEX_A715_BHB_LOOP_COUNT, cortex_a715 29#endif /* WORKAROUND_CVE_2022_23960 */ 30 31cpu_reset_prologue cortex_a715 32 33workaround_reset_start cortex_a715, ERRATUM(2238661), ERRATA_A715_2238661 34 sysreg_bit_set CORTEX_A715_CPUACTLR_EL1, BIT(0) 35workaround_reset_end cortex_a715, ERRATUM(2238661) 36 37check_erratum_ls cortex_a715, ERRATUM(2238661), CPU_REV(0, 0) 38 39workaround_reset_start cortex_a715, ERRATUM(2239006), ERRATA_A715_2239006 40 sysreg_bit_set CORTEX_A715_CPUACTLR2_EL1, BIT(9) 41workaround_reset_end cortex_a715, ERRATUM(2239006) 42 43check_erratum_ls cortex_a715, ERRATUM(2239006), CPU_REV(0, 0) 44 45workaround_reset_start cortex_a715, ERRATUM(2275754), ERRATA_A715_2275754 46 sysreg_bit_set CORTEX_A715_CPUACTLR2_EL1, BIT(20) 47workaround_reset_end cortex_a715, ERRATUM(2275754) 48 49check_erratum_ls cortex_a715, ERRATUM(2275754), CPU_REV(0, 0) 50 51workaround_reset_start cortex_a715, ERRATUM(2284544), ERRATA_A715_2284544 52 sysreg_bit_set CORTEX_A715_CPUACTLR2_EL1, BIT(20) 53workaround_reset_end cortex_a715, ERRATUM(2284544) 54 55check_erratum_ls cortex_a715, ERRATUM(2284544), CPU_REV(0, 0) 56 57workaround_reset_start cortex_a715, ERRATUM(2285473), ERRATA_A715_2285473 58 sysreg_bit_set CORTEX_A715_CPUACTLR3_EL1, BIT(12) 59workaround_reset_end cortex_a715, ERRATUM(2285473) 60 61check_erratum_ls cortex_a715, ERRATUM(2285473), CPU_REV(0, 0) 62 63workaround_reset_start cortex_a715, ERRATUM(2292761), ERRATA_A715_2292761 64 sysreg_bit_set CORTEX_A715_CPUACTLR4_EL1, BIT(13) 65workaround_reset_end cortex_a715, ERRATUM(2292761) 66 67check_erratum_ls cortex_a715, ERRATUM(2292761), CPU_REV(0, 0) 68 69workaround_reset_start cortex_a715, ERRATUM(2331818), ERRATA_A715_2331818 70 sysreg_bit_set CORTEX_A715_CPUACTLR2_EL1, BIT(20) 71workaround_reset_end cortex_a715, ERRATUM(2331818) 72 73check_erratum_ls cortex_a715, ERRATUM(2331818), CPU_REV(1, 0) 74 75workaround_reset_start cortex_a715, ERRATUM(2344187), ERRATA_A715_2344187 76 /* GCR_EL1 is only present with FEAT_MTE2. */ 77 mrs x1, ID_AA64PFR1_EL1 78 ubfx x0, x1, ID_AA64PFR1_EL1_MTE_SHIFT, #4 79 cmp x0, #MTE_IMPLEMENTED_ELX 80 bne #1f 81 sysreg_bit_set GCR_EL1, GCR_EL1_RRND_BIT 82 831: 84 /* Mitigation upon ERETAA and ERETAB. */ 85 mov x0, #2 86 msr CORTEX_A715_CPUPSELR_EL3, x0 87 isb 88 ldr x0, =0xd69f0bff 89 msr CORTEX_A715_CPUPOR_EL3, x0 90 ldr x0, =0xfffffbff 91 msr CORTEX_A715_CPUPMR_EL3, x0 92 mov x1, #0 93 orr x1, x1, #(1<<0) 94 orr x1, x1, #(3<<4) 95 orr x1, x1, #(0xf<<6) 96 orr x1, x1, #(1<<13) 97 orr x1, x1, #(1<<53) 98 msr CORTEX_A715_CPUPCR_EL3, x1 99workaround_reset_end cortex_a715, ERRATUM(2344187) 100 101check_erratum_ls cortex_a715, ERRATUM(2344187), CPU_REV(1, 0) 102 103workaround_reset_start cortex_a715, ERRATUM(2376701), ERRATA_A715_2376701 104sysreg_bit_set CORTEX_A715_CPUACTLR_EL1, BIT(0) 105workaround_reset_end cortex_a715, ERRATUM(2376701) 106 107check_erratum_ls cortex_a715, ERRATUM(2376701), CPU_REV(1, 0) 108 109workaround_reset_start cortex_a715, ERRATUM(2409570), ERRATA_A715_2409570 110sysreg_bit_set CORTEX_A715_CPUACTLR2_EL1, BIT(32) 111workaround_reset_end cortex_a715, ERRATUM(2409570) 112 113check_erratum_range cortex_a715, ERRATUM(2409570), CPU_REV(1, 0), CPU_REV(1, 0) 114 115workaround_reset_start cortex_a715, ERRATUM(2413290), ERRATA_A715_2413290 116/* Erratum 2413290 workaround is required only if SPE is enabled */ 117#if ENABLE_SPE_FOR_NS != 0 118 /* Check if Static profiling extension is implemented or present. */ 119 mrs x1, id_aa64dfr0_el1 120 ubfx x0, x1, ID_AA64DFR0_PMS_SHIFT, #4 121 cbz x0, 1f 122 /* Apply the workaround by setting CPUACTLR_EL1[58:57] = 0b11. */ 123 sysreg_lazy_start CORTEX_A715_CPUACTLR_EL1 124 sysreg_lazy_set BIT(57) 125 sysreg_lazy_set BIT(58) 126 sysreg_lazy_commit CORTEX_A715_CPUACTLR_EL1 1271: 128#endif 129workaround_reset_end cortex_a715, ERRATUM(2413290) 130 131check_erratum_range cortex_a715, ERRATUM(2413290), CPU_REV(1,0), CPU_REV(1, 0) 132 133workaround_reset_start cortex_a715, ERRATUM(2420947), ERRATA_A715_2420947 134 sysreg_bit_set CORTEX_A715_CPUACTLR2_EL1, BIT(33) 135workaround_reset_end cortex_a715, ERRATUM(2420947) 136 137check_erratum_range cortex_a715, ERRATUM(2420947), CPU_REV(1, 0), CPU_REV(1, 0) 138 139workaround_reset_start cortex_a715, ERRATUM(2429384), ERRATA_A715_2429384 140 sysreg_bit_set CORTEX_A715_CPUACTLR2_EL1, BIT(27) 141workaround_reset_end cortex_a715, ERRATUM(2429384) 142 143check_erratum_range cortex_a715, ERRATUM(2429384), CPU_REV(1, 0), CPU_REV(1, 0) 144 145workaround_reset_start cortex_a715, ERRATUM(2561034), ERRATA_A715_2561034 146 sysreg_bit_set CORTEX_A715_CPUACTLR2_EL1, BIT(26) 147workaround_reset_end cortex_a715, ERRATUM(2561034) 148 149check_erratum_range cortex_a715, ERRATUM(2561034), CPU_REV(1, 0), CPU_REV(1, 0) 150 151workaround_reset_start cortex_a715, ERRATUM(2728106), ERRATA_A715_2728106 152 mov x0, #3 153 msr CORTEX_A715_CPUPSELR_EL3, x0 154 isb 155 ldr x0, =0xd503339f 156 msr CORTEX_A715_CPUPOR_EL3, x0 157 ldr x0, =0xfffff3ff 158 msr CORTEX_A715_CPUPMR_EL3, x0 159 mov x0, #1 160 orr x0, x0, #(3<<4) 161 orr x0, x0, #(0xf<<6) 162 orr x0, x0, #(1<<13) 163 orr x0, x0, #(1<<20) 164 orr x0, x0, #(1<<22) 165 orr x0, x0, #(1<<31) 166 orr x0, x0, #(1<<50) 167 msr CORTEX_A715_CPUPCR_EL3, x0 168workaround_reset_end cortex_a715, ERRATUM(2728106) 169 170check_erratum_ls cortex_a715, ERRATUM(2728106), CPU_REV(1, 1) 171 172workaround_reset_start cortex_a715, ERRATUM(2804830), ERRATA_A715_2804830 173 /* Workaround changes based on CORE_CACHE_PROTECTIONS field (bit 1) */ 174 mrs x0, CORTEX_A715_CPUCFR_EL1 175 tbz x0, #1, wa_2804830_core_cache_prot_false 176 177 /* CORE_CACHE_PROTECTIONS==true */ 178 sysreg_bit_set CORTEX_A715_CPUACTLR3_EL1, BIT(2) 179 sysreg_bit_set CORTEX_A715_CPUECTLR_EL1, BIT(23) 180 b wa_2804830_done 181 182 /* CORE_CACHE_PROTECTIONS==false */ 183wa_2804830_core_cache_prot_false: 184 sysreg_bit_set CORTEX_A715_CPUECTLR2_EL1, BIT(7) 185 186wa_2804830_done: 187workaround_reset_end cortex_a715, ERRATUM(2804830) 188 189check_erratum_ls cortex_a715, ERRATUM(2804830), CPU_REV(1, 2) 190 191workaround_runtime_start cortex_a715, ERRATUM(3456084), ERRATA_A715_3456084 192 speculation_barrier 193workaround_runtime_end cortex_a715, ERRATUM(3456084) 194 195check_erratum_ls cortex_a715, ERRATUM(3456084), CPU_REV(1, 3) 196 197add_erratum_entry cortex_a715, ERRATUM(3699560), ERRATA_A715_3699560 198 199check_erratum_ls cortex_a715, ERRATUM(3699560), CPU_REV(1, 3) 200 201workaround_reset_start cortex_a715, ERRATUM(3711916), ERRATA_A715_3711916 202 mov x0, #5 203 msr CORTEX_A715_CPUPSELR_EL3, x0 204 ldr x0, =0xd503329f 205 msr CORTEX_A715_CPUPOR_EL3, x0 206 ldr x0, =0xfffff3ff 207 msr CORTEX_A715_CPUPMR_EL3, x0 208 ldr x0, =0x1004003F1 209 msr CORTEX_A715_CPUPCR_EL3, x0 210workaround_reset_end cortex_a715, ERRATUM(3711916) 211 212check_erratum_ls cortex_a715, ERRATUM(3711916), CPU_REV(1, 3) 213 214workaround_reset_start cortex_a715, CVE(2022, 23960), WORKAROUND_CVE_2022_23960 215#if IMAGE_BL31 216 /* 217 * The Cortex-A715 generic vectors are overridden to apply errata 218 * mitigation on exception entry from lower ELs. 219 */ 220 override_vector_table wa_cve_vbar_cortex_a715 221#endif /* IMAGE_BL31 */ 222workaround_reset_end cortex_a715, CVE(2022, 23960) 223 224check_erratum_ls cortex_a715, CVE(2022, 23960), CPU_REV(1, 0) 225 226cpu_reset_func_start cortex_a715 227 /* Disable speculative loads */ 228 msr SSBS, xzr 229 apply_erratum cortex_a715, ERRATUM(3456084), ERRATA_A715_3456084 230 231 enable_mpmm 232cpu_reset_func_end cortex_a715 233 234 /* ---------------------------------------------------- 235 * HW will do the cache maintenance while powering down 236 * ---------------------------------------------------- 237 */ 238func cortex_a715_core_pwr_dwn 239 /* --------------------------------------------------- 240 * Enable CPU power down bit in power control register 241 * --------------------------------------------------- 242 */ 243 mrs x0, CORTEX_A715_CPUPWRCTLR_EL1 244 orr x0, x0, #CORTEX_A715_CPUPWRCTLR_EL1_CORE_PWRDN_BIT 245 msr CORTEX_A715_CPUPWRCTLR_EL1, x0 246 isb 247 ret 248endfunc cortex_a715_core_pwr_dwn 249 250 /* --------------------------------------------- 251 * This function provides Cortex-A715 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_a715_regs, "aS" 260cortex_a715_regs: /* The ascii list of register names to be reported */ 261 .asciz "cpuectlr_el1", "" 262 263func cortex_a715_cpu_reg_dump 264 adr x6, cortex_a715_regs 265 mrs x8, CORTEX_A715_CPUECTLR_EL1 266 ret 267endfunc cortex_a715_cpu_reg_dump 268 269declare_cpu_ops cortex_a715, CORTEX_A715_MIDR, \ 270 cortex_a715_reset_func, \ 271 cortex_a715_core_pwr_dwn 272