1c58b9a8eSRupinderjit Singh/* 226437afdSGovindraj Raja * Copyright (c) 2021-2025, Arm Limited. All rights reserved. 3c58b9a8eSRupinderjit Singh * 4c58b9a8eSRupinderjit Singh * SPDX-License-Identifier: BSD-3-Clause 5c58b9a8eSRupinderjit Singh */ 6c58b9a8eSRupinderjit Singh 7c58b9a8eSRupinderjit Singh#include <arch.h> 8c58b9a8eSRupinderjit Singh#include <asm_macros.S> 9c58b9a8eSRupinderjit Singh#include <common/bl_common.h> 1015889d13SHarrison Mutai#include <cortex_a715.h> 11c58b9a8eSRupinderjit Singh#include <cpu_macros.S> 12c58b9a8eSRupinderjit Singh#include <plat_macros.S> 13c58b9a8eSRupinderjit Singh#include "wa_cve_2022_23960_bhb_vector.S" 14c58b9a8eSRupinderjit Singh 15c58b9a8eSRupinderjit Singh/* Hardware handled coherency */ 16c58b9a8eSRupinderjit Singh#if HW_ASSISTED_COHERENCY == 0 1715889d13SHarrison Mutai#error "Cortex-A715 must be compiled with HW_ASSISTED_COHERENCY enabled" 18c58b9a8eSRupinderjit Singh#endif 19c58b9a8eSRupinderjit Singh 20c58b9a8eSRupinderjit Singh/* 64-bit only core */ 21c58b9a8eSRupinderjit Singh#if CTX_INCLUDE_AARCH32_REGS == 1 2215889d13SHarrison Mutai#error "Cortex-A715 supports only AArch64. Compile with CTX_INCLUDE_AARCH32_REGS=0" 23c58b9a8eSRupinderjit Singh#endif 24c58b9a8eSRupinderjit Singh 2526437afdSGovindraj Raja.global check_erratum_cortex_a715_3699560 2626437afdSGovindraj Raja 27c58b9a8eSRupinderjit Singh#if WORKAROUND_CVE_2022_23960 2815889d13SHarrison Mutai wa_cve_2022_23960_bhb_vector_table CORTEX_A715_BHB_LOOP_COUNT, cortex_a715 29c58b9a8eSRupinderjit Singh#endif /* WORKAROUND_CVE_2022_23960 */ 30c58b9a8eSRupinderjit Singh 3189dba82dSBoyan Karatotevcpu_reset_prologue cortex_a715 3289dba82dSBoyan Karatotev 3353b3cd25SBipin Raviworkaround_reset_start cortex_a715, ERRATUM(2331818), ERRATA_A715_2331818 3453b3cd25SBipin Ravi sysreg_bit_set CORTEX_A715_CPUACTLR2_EL1, BIT(20) 3553b3cd25SBipin Raviworkaround_reset_end cortex_a715, ERRATUM(2331818) 3653b3cd25SBipin Ravi 3753b3cd25SBipin Ravicheck_erratum_ls cortex_a715, ERRATUM(2331818), CPU_REV(1, 0) 3853b3cd25SBipin Ravi 3933c665aeSHarrison Mutaiworkaround_reset_start cortex_a715, ERRATUM(2344187), ERRATA_A715_2344187 4033c665aeSHarrison Mutai /* GCR_EL1 is only present with FEAT_MTE2. */ 4133c665aeSHarrison Mutai mrs x1, ID_AA64PFR1_EL1 4233c665aeSHarrison Mutai ubfx x0, x1, ID_AA64PFR1_EL1_MTE_SHIFT, #4 4333c665aeSHarrison Mutai cmp x0, #MTE_IMPLEMENTED_ELX 4433c665aeSHarrison Mutai bne #1f 4533c665aeSHarrison Mutai sysreg_bit_set GCR_EL1, GCR_EL1_RRND_BIT 4633c665aeSHarrison Mutai 4733c665aeSHarrison Mutai1: 4833c665aeSHarrison Mutai /* Mitigation upon ERETAA and ERETAB. */ 4933c665aeSHarrison Mutai mov x0, #2 5033c665aeSHarrison Mutai msr CORTEX_A715_CPUPSELR_EL3, x0 5133c665aeSHarrison Mutai isb 5233c665aeSHarrison Mutai ldr x0, =0xd69f0bff 5333c665aeSHarrison Mutai msr CORTEX_A715_CPUPOR_EL3, x0 5433c665aeSHarrison Mutai ldr x0, =0xfffffbff 5533c665aeSHarrison Mutai msr CORTEX_A715_CPUPMR_EL3, x0 5633c665aeSHarrison Mutai mov x1, #0 5733c665aeSHarrison Mutai orr x1, x1, #(1<<0) 5833c665aeSHarrison Mutai orr x1, x1, #(3<<4) 5933c665aeSHarrison Mutai orr x1, x1, #(0xf<<6) 6033c665aeSHarrison Mutai orr x1, x1, #(1<<13) 6133c665aeSHarrison Mutai orr x1, x1, #(1<<53) 6233c665aeSHarrison Mutai msr CORTEX_A715_CPUPCR_EL3, x1 6333c665aeSHarrison Mutaiworkaround_reset_end cortex_a715, ERRATUM(2344187) 6433c665aeSHarrison Mutai 6533c665aeSHarrison Mutaicheck_erratum_ls cortex_a715, ERRATUM(2344187), CPU_REV(1, 0) 6633c665aeSHarrison Mutai 674fca3ee4SJohn Powellworkaround_reset_start cortex_a715, ERRATUM(2376701), ERRATA_A715_2376701 684fca3ee4SJohn Powellsysreg_bit_set CORTEX_A715_CPUACTLR_EL1, BIT(0) 694fca3ee4SJohn Powellworkaround_reset_end cortex_a715, ERRATUM(2376701) 704fca3ee4SJohn Powell 714fca3ee4SJohn Powellcheck_erratum_ls cortex_a715, ERRATUM(2376701), CPU_REV(1, 0) 724fca3ee4SJohn Powell 73d6e941e2SJohn Powellworkaround_reset_start cortex_a715, ERRATUM(2409570), ERRATA_A715_2409570 74d6e941e2SJohn Powellsysreg_bit_set CORTEX_A715_CPUACTLR2_EL1, BIT(32) 75d6e941e2SJohn Powellworkaround_reset_end cortex_a715, ERRATUM(2409570) 76d6e941e2SJohn Powell 77d6e941e2SJohn Powellcheck_erratum_range cortex_a715, ERRATUM(2409570), CPU_REV(1, 0), CPU_REV(1, 0) 78d6e941e2SJohn Powell 7915a04615SSona Mathewworkaround_reset_start cortex_a715, ERRATUM(2413290), ERRATA_A715_2413290 80bd2f7d32SSona Mathew/* Erratum 2413290 workaround is required only if SPE is enabled */ 81bd2f7d32SSona Mathew#if ENABLE_SPE_FOR_NS != 0 82bd2f7d32SSona Mathew /* Check if Static profiling extension is implemented or present. */ 8315a04615SSona Mathew mrs x1, id_aa64dfr0_el1 8415a04615SSona Mathew ubfx x0, x1, ID_AA64DFR0_PMS_SHIFT, #4 8515a04615SSona Mathew cbz x0, 1f 86bd2f7d32SSona Mathew /* Apply the workaround by setting CPUACTLR_EL1[58:57] = 0b11. */ 8715a04615SSona Mathew sysreg_bit_set CORTEX_A715_CPUACTLR_EL1, BIT(57) 8815a04615SSona Mathew sysreg_bit_set CORTEX_A715_CPUACTLR_EL1, BIT(58) 8915a04615SSona Mathew1: 90bd2f7d32SSona Mathew#endif 9115a04615SSona Mathewworkaround_reset_end cortex_a715, ERRATUM(2413290) 9215a04615SSona Mathew 9315a04615SSona Mathewcheck_erratum_range cortex_a715, ERRATUM(2413290), CPU_REV(1,0), CPU_REV(1, 0) 9415a04615SSona Mathew 951f732471SBipin Raviworkaround_reset_start cortex_a715, ERRATUM(2420947), ERRATA_A715_2420947 961f732471SBipin Ravi sysreg_bit_set CORTEX_A715_CPUACTLR2_EL1, BIT(33) 971f732471SBipin Raviworkaround_reset_end cortex_a715, ERRATUM(2420947) 981f732471SBipin Ravi 991f732471SBipin Ravicheck_erratum_range cortex_a715, ERRATUM(2420947), CPU_REV(1, 0), CPU_REV(1, 0) 1001f732471SBipin Ravi 101262dc9f7SBipin Raviworkaround_reset_start cortex_a715, ERRATUM(2429384), ERRATA_A715_2429384 102262dc9f7SBipin Ravi sysreg_bit_set CORTEX_A715_CPUACTLR2_EL1, BIT(27) 103262dc9f7SBipin Raviworkaround_reset_end cortex_a715, ERRATUM(2429384) 104262dc9f7SBipin Ravi 105262dc9f7SBipin Ravicheck_erratum_range cortex_a715, ERRATUM(2429384), CPU_REV(1, 0), CPU_REV(1, 0) 106262dc9f7SBipin Ravi 10757ab6d89SBipin Raviworkaround_reset_start cortex_a715, ERRATUM(2561034), ERRATA_A715_2561034 1086a6b2823SBipin Ravi sysreg_bit_set CORTEX_A715_CPUACTLR2_EL1, BIT(26) 10957ab6d89SBipin Raviworkaround_reset_end cortex_a715, ERRATUM(2561034) 1106a6b2823SBipin Ravi 1116a6b2823SBipin Ravicheck_erratum_range cortex_a715, ERRATUM(2561034), CPU_REV(1, 0), CPU_REV(1, 0) 1126a6b2823SBipin Ravi 11310134e35SBipin Raviworkaround_reset_start cortex_a715, ERRATUM(2728106), ERRATA_A715_2728106 11410134e35SBipin Ravi mov x0, #3 11510134e35SBipin Ravi msr CORTEX_A715_CPUPSELR_EL3, x0 11610134e35SBipin Ravi isb 11710134e35SBipin Ravi ldr x0, =0xd503339f 11810134e35SBipin Ravi msr CORTEX_A715_CPUPOR_EL3, x0 11910134e35SBipin Ravi ldr x0, =0xfffff3ff 12010134e35SBipin Ravi msr CORTEX_A715_CPUPMR_EL3, x0 12110134e35SBipin Ravi mov x0, #1 12210134e35SBipin Ravi orr x0, x0, #(3<<4) 12310134e35SBipin Ravi orr x0, x0, #(0xf<<6) 12410134e35SBipin Ravi orr x0, x0, #(1<<13) 12510134e35SBipin Ravi orr x0, x0, #(1<<20) 12610134e35SBipin Ravi orr x0, x0, #(1<<22) 12710134e35SBipin Ravi orr x0, x0, #(1<<31) 12810134e35SBipin Ravi orr x0, x0, #(1<<50) 12910134e35SBipin Ravi msr CORTEX_A715_CPUPCR_EL3, x0 13010134e35SBipin Raviworkaround_reset_end cortex_a715, ERRATUM(2728106) 13110134e35SBipin Ravi 13210134e35SBipin Ravicheck_erratum_ls cortex_a715, ERRATUM(2728106), CPU_REV(1, 1) 13310134e35SBipin Ravi 134fcf2ab71SJohn Powellworkaround_reset_start cortex_a715, ERRATUM(2804830), ERRATA_A715_2804830 135fcf2ab71SJohn Powell /* Workaround changes based on CORE_CACHE_PROTECTIONS field (bit 1) */ 136fcf2ab71SJohn Powell mrs x0, CORTEX_A715_CPUCFR_EL1 137fcf2ab71SJohn Powell tbz x0, #1, wa_2804830_core_cache_prot_false 138fcf2ab71SJohn Powell 139fcf2ab71SJohn Powell /* CORE_CACHE_PROTECTIONS==true */ 140fcf2ab71SJohn Powell sysreg_bit_set CORTEX_A715_CPUACTLR3_EL1, BIT(2) 141fcf2ab71SJohn Powell sysreg_bit_set CORTEX_A715_CPUECTLR_EL1, BIT(23) 142fcf2ab71SJohn Powell b wa_2804830_done 143fcf2ab71SJohn Powell 144fcf2ab71SJohn Powell /* CORE_CACHE_PROTECTIONS==false */ 145fcf2ab71SJohn Powellwa_2804830_core_cache_prot_false: 146fcf2ab71SJohn Powell sysreg_bit_set CORTEX_A715_CPUECTLR2_EL1, BIT(7) 147fcf2ab71SJohn Powell 148fcf2ab71SJohn Powellwa_2804830_done: 149fcf2ab71SJohn Powellworkaround_reset_end cortex_a715, ERRATUM(2804830) 150fcf2ab71SJohn Powell 151fcf2ab71SJohn Powellcheck_erratum_ls cortex_a715, ERRATUM(2804830), CPU_REV(1, 2) 152fcf2ab71SJohn Powell 153fcf2ab71SJohn Powelladd_erratum_entry cortex_a715, ERRATUM(3699560), ERRATA_A715_3699560 154fcf2ab71SJohn Powell 155fcf2ab71SJohn Powellcheck_erratum_ls cortex_a715, ERRATUM(3699560), CPU_REV(1, 3) 156fcf2ab71SJohn Powell 157*5c5b9e3eSJohn Powellworkaround_reset_start cortex_a715, ERRATUM(3711916), ERRATA_A715_3711916 158*5c5b9e3eSJohn Powell mov x0, #5 159*5c5b9e3eSJohn Powell msr CORTEX_A715_CPUPSELR_EL3, x0 160*5c5b9e3eSJohn Powell ldr x0, =0xd503329f 161*5c5b9e3eSJohn Powell msr CORTEX_A715_CPUPOR_EL3, x0 162*5c5b9e3eSJohn Powell ldr x0, =0xfffff3ff 163*5c5b9e3eSJohn Powell msr CORTEX_A715_CPUPMR_EL3, x0 164*5c5b9e3eSJohn Powell ldr x0, =0x1004003F1 165*5c5b9e3eSJohn Powell msr CORTEX_A715_CPUPCR_EL3, x0 166*5c5b9e3eSJohn Powellworkaround_reset_end cortex_a715, ERRATUM(3711916) 167*5c5b9e3eSJohn Powell 168*5c5b9e3eSJohn Powellcheck_erratum_ls cortex_a715, ERRATUM(3711916), CPU_REV(1, 3) 169*5c5b9e3eSJohn Powell 170c82fb382SHarrison Mutaiworkaround_reset_start cortex_a715, CVE(2022, 23960), WORKAROUND_CVE_2022_23960 171c82fb382SHarrison Mutai#if IMAGE_BL31 172c58b9a8eSRupinderjit Singh /* 17315889d13SHarrison Mutai * The Cortex-A715 generic vectors are overridden to apply errata 174c58b9a8eSRupinderjit Singh * mitigation on exception entry from lower ELs. 175c58b9a8eSRupinderjit Singh */ 176c82fb382SHarrison Mutai override_vector_table wa_cve_vbar_cortex_a715 177c82fb382SHarrison Mutai#endif /* IMAGE_BL31 */ 178c82fb382SHarrison Mutaiworkaround_reset_end cortex_a715, CVE(2022, 23960) 179c58b9a8eSRupinderjit Singh 180ad0e8487SGovindraj Rajacheck_erratum_ls cortex_a715, CVE(2022, 23960), CPU_REV(1, 0) 181c82fb382SHarrison Mutai 182c82fb382SHarrison Mutaicpu_reset_func_start cortex_a715 183c82fb382SHarrison Mutai /* Disable speculative loads */ 184c82fb382SHarrison Mutai msr SSBS, xzr 1852590e819SBoyan Karatotev enable_mpmm 186c82fb382SHarrison Mutaicpu_reset_func_end cortex_a715 187c58b9a8eSRupinderjit Singh 188c58b9a8eSRupinderjit Singh /* ---------------------------------------------------- 189c58b9a8eSRupinderjit Singh * HW will do the cache maintenance while powering down 190c58b9a8eSRupinderjit Singh * ---------------------------------------------------- 191c58b9a8eSRupinderjit Singh */ 19215889d13SHarrison Mutaifunc cortex_a715_core_pwr_dwn 193c58b9a8eSRupinderjit Singh /* --------------------------------------------------- 194c58b9a8eSRupinderjit Singh * Enable CPU power down bit in power control register 195c58b9a8eSRupinderjit Singh * --------------------------------------------------- 196c58b9a8eSRupinderjit Singh */ 19715889d13SHarrison Mutai mrs x0, CORTEX_A715_CPUPWRCTLR_EL1 19815889d13SHarrison Mutai orr x0, x0, #CORTEX_A715_CPUPWRCTLR_EL1_CORE_PWRDN_BIT 19915889d13SHarrison Mutai msr CORTEX_A715_CPUPWRCTLR_EL1, x0 200c58b9a8eSRupinderjit Singh isb 201c58b9a8eSRupinderjit Singh ret 20215889d13SHarrison Mutaiendfunc cortex_a715_core_pwr_dwn 203c58b9a8eSRupinderjit Singh 204c58b9a8eSRupinderjit Singh /* --------------------------------------------- 20515889d13SHarrison Mutai * This function provides Cortex-A715 specific 206c58b9a8eSRupinderjit Singh * register information for crash reporting. 207c58b9a8eSRupinderjit Singh * It needs to return with x6 pointing to 208c58b9a8eSRupinderjit Singh * a list of register names in ascii and 209c58b9a8eSRupinderjit Singh * x8 - x15 having values of registers to be 210c58b9a8eSRupinderjit Singh * reported. 211c58b9a8eSRupinderjit Singh * --------------------------------------------- 212c58b9a8eSRupinderjit Singh */ 21315889d13SHarrison Mutai.section .rodata.cortex_a715_regs, "aS" 21415889d13SHarrison Mutaicortex_a715_regs: /* The ascii list of register names to be reported */ 215c58b9a8eSRupinderjit Singh .asciz "cpuectlr_el1", "" 216c58b9a8eSRupinderjit Singh 21715889d13SHarrison Mutaifunc cortex_a715_cpu_reg_dump 21815889d13SHarrison Mutai adr x6, cortex_a715_regs 21915889d13SHarrison Mutai mrs x8, CORTEX_A715_CPUECTLR_EL1 220c58b9a8eSRupinderjit Singh ret 22115889d13SHarrison Mutaiendfunc cortex_a715_cpu_reg_dump 222c58b9a8eSRupinderjit Singh 22315889d13SHarrison Mutaideclare_cpu_ops cortex_a715, CORTEX_A715_MIDR, \ 22415889d13SHarrison Mutai cortex_a715_reset_func, \ 22515889d13SHarrison Mutai cortex_a715_core_pwr_dwn 226