1*91f16700Schasinglulu/* 2*91f16700Schasinglulu * Copyright (c) 2021-2023, Arm Limited. All rights reserved. 3*91f16700Schasinglulu * 4*91f16700Schasinglulu * SPDX-License-Identifier: BSD-3-Clause 5*91f16700Schasinglulu */ 6*91f16700Schasinglulu 7*91f16700Schasinglulu#include <arch.h> 8*91f16700Schasinglulu#include <asm_macros.S> 9*91f16700Schasinglulu#include <common/bl_common.h> 10*91f16700Schasinglulu#include <neoverse_v2.h> 11*91f16700Schasinglulu#include <cpu_macros.S> 12*91f16700Schasinglulu#include <plat_macros.S> 13*91f16700Schasinglulu#include "wa_cve_2022_23960_bhb_vector.S" 14*91f16700Schasinglulu 15*91f16700Schasinglulu/* Hardware handled coherency */ 16*91f16700Schasinglulu#if HW_ASSISTED_COHERENCY == 0 17*91f16700Schasinglulu#error "Neoverse V2 must be compiled with HW_ASSISTED_COHERENCY enabled" 18*91f16700Schasinglulu#endif 19*91f16700Schasinglulu 20*91f16700Schasinglulu/* 64-bit only core */ 21*91f16700Schasinglulu#if CTX_INCLUDE_AARCH32_REGS == 1 22*91f16700Schasinglulu#error "Neoverse V2 supports only AArch64. Compile with CTX_INCLUDE_AARCH32_REGS=0" 23*91f16700Schasinglulu#endif 24*91f16700Schasinglulu 25*91f16700Schasingluluworkaround_reset_start neoverse_v2, ERRATUM(2331132), ERRATA_V2_2331132 26*91f16700Schasinglulu sysreg_bitfield_insert NEOVERSE_V2_CPUECTLR2_EL1, NEOVERSE_V2_CPUECTLR2_EL1_PF_MODE_CNSRV, \ 27*91f16700Schasinglulu NEOVERSE_V2_CPUECTLR2_EL1_PF_MODE_LSB, NEOVERSE_V2_CPUECTLR2_EL1_PF_MODE_WIDTH 28*91f16700Schasingluluworkaround_reset_end neoverse_v2, ERRATUM(2331132) 29*91f16700Schasinglulu 30*91f16700Schasinglulucheck_erratum_ls neoverse_v2, ERRATUM(2331132), CPU_REV(0, 2) 31*91f16700Schasinglulu 32*91f16700Schasingluluworkaround_reset_start neoverse_v2, ERRATUM(2719105), ERRATA_V2_2719105 33*91f16700Schasinglulu sysreg_bit_set NEOVERSE_V2_CPUACTLR2_EL1, NEOVERSE_V2_CPUACTLR2_EL1_BIT_0 34*91f16700Schasingluluworkaround_reset_end neoverse_v2, ERRATUM(2719105) 35*91f16700Schasinglulu 36*91f16700Schasinglulucheck_erratum_ls neoverse_v2, ERRATUM(2719105), CPU_REV(0, 1) 37*91f16700Schasinglulu 38*91f16700Schasingluluworkaround_reset_start neoverse_v2, ERRATUM(2743011), ERRATA_V2_2743011 39*91f16700Schasinglulu sysreg_bit_set NEOVERSE_V2_CPUACTLR5_EL1, NEOVERSE_V2_CPUACTLR5_EL1_BIT_55 40*91f16700Schasinglulu sysreg_bit_clear NEOVERSE_V2_CPUACTLR5_EL1, NEOVERSE_V2_CPUACTLR5_EL1_BIT_56 41*91f16700Schasingluluworkaround_reset_end neoverse_v2, ERRATUM(2743011) 42*91f16700Schasinglulu 43*91f16700Schasinglulucheck_erratum_ls neoverse_v2, ERRATUM(2743011), CPU_REV(0, 1) 44*91f16700Schasinglulu 45*91f16700Schasingluluworkaround_reset_start neoverse_v2, ERRATUM(2779510), ERRATA_V2_2779510 46*91f16700Schasinglulu sysreg_bit_set NEOVERSE_V2_CPUACTLR3_EL1, NEOVERSE_V2_CPUACTLR3_EL1_BIT_47 47*91f16700Schasingluluworkaround_reset_end neoverse_v2, ERRATUM(2779510) 48*91f16700Schasinglulu 49*91f16700Schasinglulucheck_erratum_ls neoverse_v2, ERRATUM(2779510), CPU_REV(0, 1) 50*91f16700Schasinglulu 51*91f16700Schasingluluworkaround_runtime_start neoverse_v2, ERRATUM(2801372), ERRATA_V2_2801372 52*91f16700Schasinglulu /* dsb before isb of power down sequence */ 53*91f16700Schasinglulu dsb sy 54*91f16700Schasingluluworkaround_runtime_end neoverse_v2, ERRATUM(2801372), ERRATA_V2_2801372 55*91f16700Schasinglulu 56*91f16700Schasinglulucheck_erratum_ls neoverse_v2, ERRATUM(2801372), CPU_REV(0, 1) 57*91f16700Schasinglulu 58*91f16700Schasingluluworkaround_reset_start neoverse_v2, CVE(2022,23960), WORKAROUND_CVE_2022_23960 59*91f16700Schasinglulu#if IMAGE_BL31 60*91f16700Schasinglulu /* 61*91f16700Schasinglulu * The Neoverse-V2 generic vectors are overridden to apply errata 62*91f16700Schasinglulu * mitigation on exception entry from lower ELs. 63*91f16700Schasinglulu */ 64*91f16700Schasinglulu override_vector_table wa_cve_vbar_neoverse_v2 65*91f16700Schasinglulu#endif /* IMAGE_BL31 */ 66*91f16700Schasingluluworkaround_reset_end neoverse_v2, CVE(2022,23960) 67*91f16700Schasinglulu 68*91f16700Schasinglulucheck_erratum_chosen neoverse_v2, CVE(2022, 23960), WORKAROUND_CVE_2022_23960 69*91f16700Schasinglulu 70*91f16700Schasinglulu#if WORKAROUND_CVE_2022_23960 71*91f16700Schasinglulu wa_cve_2022_23960_bhb_vector_table NEOVERSE_V2_BHB_LOOP_COUNT, neoverse_v2 72*91f16700Schasinglulu#endif /* WORKAROUND_CVE_2022_23960 */ 73*91f16700Schasinglulu 74*91f16700Schasinglulu /* ---------------------------------------------------- 75*91f16700Schasinglulu * HW will do the cache maintenance while powering down 76*91f16700Schasinglulu * ---------------------------------------------------- 77*91f16700Schasinglulu */ 78*91f16700Schasinglulufunc neoverse_v2_core_pwr_dwn 79*91f16700Schasinglulu /* --------------------------------------------------- 80*91f16700Schasinglulu * Enable CPU power down bit in power control register 81*91f16700Schasinglulu * --------------------------------------------------- 82*91f16700Schasinglulu */ 83*91f16700Schasinglulu sysreg_bit_set NEOVERSE_V2_CPUPWRCTLR_EL1, NEOVERSE_V2_CPUPWRCTLR_EL1_CORE_PWRDN_BIT 84*91f16700Schasinglulu apply_erratum neoverse_v2, ERRATUM(2801372), ERRATA_V2_2801372 85*91f16700Schasinglulu 86*91f16700Schasinglulu isb 87*91f16700Schasinglulu ret 88*91f16700Schasingluluendfunc neoverse_v2_core_pwr_dwn 89*91f16700Schasinglulu 90*91f16700Schasinglulucpu_reset_func_start neoverse_v2 91*91f16700Schasinglulu /* Disable speculative loads */ 92*91f16700Schasinglulu msr SSBS, xzr 93*91f16700Schasinglulucpu_reset_func_end neoverse_v2 94*91f16700Schasinglulu 95*91f16700Schasingluluerrata_report_shim neoverse_v2 96*91f16700Schasinglulu /* --------------------------------------------- 97*91f16700Schasinglulu * This function provides Neoverse V2- 98*91f16700Schasinglulu * specific register information for crash 99*91f16700Schasinglulu * reporting. It needs to return with x6 100*91f16700Schasinglulu * pointing to a list of register names in ascii 101*91f16700Schasinglulu * and x8 - x15 having values of registers to be 102*91f16700Schasinglulu * reported. 103*91f16700Schasinglulu * --------------------------------------------- 104*91f16700Schasinglulu */ 105*91f16700Schasinglulu.section .rodata.neoverse_v2_regs, "aS" 106*91f16700Schasingluluneoverse_v2_regs: /* The ascii list of register names to be reported */ 107*91f16700Schasinglulu .asciz "cpuectlr_el1", "" 108*91f16700Schasinglulu 109*91f16700Schasinglulufunc neoverse_v2_cpu_reg_dump 110*91f16700Schasinglulu adr x6, neoverse_v2_regs 111*91f16700Schasinglulu mrs x8, NEOVERSE_V2_CPUECTLR_EL1 112*91f16700Schasinglulu ret 113*91f16700Schasingluluendfunc neoverse_v2_cpu_reg_dump 114*91f16700Schasinglulu 115*91f16700Schasingluludeclare_cpu_ops neoverse_v2, NEOVERSE_V2_MIDR, \ 116*91f16700Schasinglulu neoverse_v2_reset_func, \ 117*91f16700Schasinglulu neoverse_v2_core_pwr_dwn 118