blob: b5c24e143d9e0490f7cd4489f160c3b43ddc596d [file] [log] [blame]
Louis Mayencourtf57f1082019-05-14 11:00:45 +01001/*
Govindraj Raja805dc802023-06-15 12:39:48 -05002 * Copyright (c) 2019-2023, Arm Limited. All rights reserved.
Louis Mayencourtf57f1082019-05-14 11:00:45 +01003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <arch.h>
8#include <asm_macros.S>
9#include <common/bl_common.h>
Jimmy Brisson7ec175e2020-06-01 16:49:34 -050010#include <cortex_a78.h>
Louis Mayencourtf57f1082019-05-14 11:00:45 +010011#include <cpu_macros.S>
12#include <plat_macros.S>
Bipin Ravi86499742022-01-18 01:59:06 -060013#include "wa_cve_2022_23960_bhb_vector.S"
Louis Mayencourtf57f1082019-05-14 11:00:45 +010014
15/* Hardware handled coherency */
16#if HW_ASSISTED_COHERENCY == 0
Jimmy Brisson3571fb92020-06-01 10:18:22 -050017#error "cortex_a78 must be compiled with HW_ASSISTED_COHERENCY enabled"
Louis Mayencourtf57f1082019-05-14 11:00:45 +010018#endif
19
Saurabh Gorechab8493012022-04-05 00:11:52 +053020.globl cortex_a78_reset_func
21.globl cortex_a78_core_pwr_dwn
22
Bipin Ravi86499742022-01-18 01:59:06 -060023#if WORKAROUND_CVE_2022_23960
24 wa_cve_2022_23960_bhb_vector_table CORTEX_A78_BHB_LOOP_COUNT, cortex_a78
25#endif /* WORKAROUND_CVE_2022_23960 */
Madhukar Pappireddy4efede72019-12-18 15:56:27 -060026
Govindraj Raja3f957e72023-06-15 15:17:38 -050027workaround_reset_start cortex_a78, ERRATUM(1688305), ERRATA_A78_1688305
Govindraj Raja1087d502023-06-15 15:23:58 -050028 sysreg_bit_set CORTEX_A78_ACTLR2_EL1, CORTEX_A78_ACTLR2_EL1_BIT_1
Govindraj Raja3f957e72023-06-15 15:17:38 -050029workaround_reset_end cortex_a78, ERRATUM(1688305)
Madhukar Pappireddy4efede72019-12-18 15:56:27 -060030
Govindraj Raja3f957e72023-06-15 15:17:38 -050031check_erratum_ls cortex_a78, ERRATUM(1688305), CPU_REV(1, 0)
Govindraj Raja805dc802023-06-15 12:39:48 -050032
Govindraj Raja3f957e72023-06-15 15:17:38 -050033workaround_reset_start cortex_a78, ERRATUM(1821534), ERRATA_A78_1821534
Govindraj Raja1087d502023-06-15 15:23:58 -050034 sysreg_bit_set CORTEX_A78_ACTLR2_EL1, CORTEX_A78_ACTLR2_EL1_BIT_2
Govindraj Raja3f957e72023-06-15 15:17:38 -050035workaround_reset_end cortex_a78, ERRATUM(1821534)
Govindraj Raja805dc802023-06-15 12:39:48 -050036
Govindraj Raja3f957e72023-06-15 15:17:38 -050037check_erratum_ls cortex_a78, ERRATUM(1821534), CPU_REV(1, 0)
Govindraj Raja805dc802023-06-15 12:39:48 -050038
Govindraj Raja3f957e72023-06-15 15:17:38 -050039workaround_reset_start cortex_a78, ERRATUM(1941498), ERRATA_A78_1941498
Govindraj Raja1087d502023-06-15 15:23:58 -050040 sysreg_bit_set CORTEX_A78_CPUECTLR_EL1, CORTEX_A78_CPUECTLR_EL1_BIT_8
Govindraj Raja3f957e72023-06-15 15:17:38 -050041workaround_reset_end cortex_a78, ERRATUM(1941498)
johpow019131eb82020-10-06 17:55:25 -050042
Govindraj Raja3f957e72023-06-15 15:17:38 -050043check_erratum_ls cortex_a78, ERRATUM(1941498), CPU_REV(1, 1)
johpow019131eb82020-10-06 17:55:25 -050044
Govindraj Raja3f957e72023-06-15 15:17:38 -050045workaround_reset_start cortex_a78, ERRATUM(1951500), ERRATA_A78_1951500
johpow0185ea43d2020-10-07 15:08:01 -050046 msr S3_6_c15_c8_0, xzr
47 ldr x0, =0x10E3900002
48 msr S3_6_c15_c8_2, x0
49 ldr x0, =0x10FFF00083
50 msr S3_6_c15_c8_3, x0
51 ldr x0, =0x2001003FF
52 msr S3_6_c15_c8_1, x0
53
54 mov x0, #1
55 msr S3_6_c15_c8_0, x0
56 ldr x0, =0x10E3800082
57 msr S3_6_c15_c8_2, x0
58 ldr x0, =0x10FFF00083
59 msr S3_6_c15_c8_3, x0
60 ldr x0, =0x2001003FF
61 msr S3_6_c15_c8_1, x0
62
63 mov x0, #2
64 msr S3_6_c15_c8_0, x0
65 ldr x0, =0x10E3800200
66 msr S3_6_c15_c8_2, x0
67 ldr x0, =0x10FFF003E0
68 msr S3_6_c15_c8_3, x0
69 ldr x0, =0x2001003FF
70 msr S3_6_c15_c8_1, x0
Govindraj Raja3f957e72023-06-15 15:17:38 -050071workaround_reset_end cortex_a78, ERRATUM(1951500)
johpow0185ea43d2020-10-07 15:08:01 -050072
Govindraj Raja3f957e72023-06-15 15:17:38 -050073check_erratum_range cortex_a78, ERRATUM(1951500), CPU_REV(1, 0), CPU_REV(1, 1)
nayanpatel-arm80bf7a52021-08-11 13:33:00 -070074
Govindraj Raja3f957e72023-06-15 15:17:38 -050075workaround_reset_start cortex_a78, ERRATUM(1952683), ERRATA_A78_1952683
nayanpatel-arm80bf7a52021-08-11 13:33:00 -070076 ldr x0,=0x5
77 msr S3_6_c15_c8_0,x0
78 ldr x0,=0xEEE10A10
79 msr S3_6_c15_c8_2,x0
80 ldr x0,=0xFFEF0FFF
81 msr S3_6_c15_c8_3,x0
82 ldr x0,=0x0010F000
83 msr S3_6_c15_c8_4,x0
84 ldr x0,=0x0010F000
85 msr S3_6_c15_c8_5,x0
86 ldr x0,=0x40000080023ff
87 msr S3_6_c15_c8_1,x0
88 ldr x0,=0x6
89 msr S3_6_c15_c8_0,x0
90 ldr x0,=0xEE640F34
91 msr S3_6_c15_c8_2,x0
92 ldr x0,=0xFFEF0FFF
93 msr S3_6_c15_c8_3,x0
94 ldr x0,=0x40000080023ff
95 msr S3_6_c15_c8_1,x0
Govindraj Raja3f957e72023-06-15 15:17:38 -050096workaround_reset_end cortex_a78, ERRATUM(1952683)
nayanpatel-arm80bf7a52021-08-11 13:33:00 -070097
Govindraj Raja3f957e72023-06-15 15:17:38 -050098check_erratum_ls cortex_a78, ERRATUM(1952683), CPU_REV(0, 0)
nayanpatel-arm39e08652021-09-28 17:31:50 -070099
Govindraj Raja3f957e72023-06-15 15:17:38 -0500100workaround_reset_start cortex_a78, ERRATUM(2132060), ERRATA_A78_2132060
nayanpatel-arm39e08652021-09-28 17:31:50 -0700101 /* Apply the workaround. */
102 mrs x1, CORTEX_A78_CPUECTLR_EL1
103 mov x0, #CORTEX_A78_CPUECTLR_EL1_PF_MODE_CNSRV
104 bfi x1, x0, #CPUECTLR_EL1_PF_MODE_LSB, #CPUECTLR_EL1_PF_MODE_WIDTH
105 msr CORTEX_A78_CPUECTLR_EL1, x1
Govindraj Raja3f957e72023-06-15 15:17:38 -0500106workaround_reset_end cortex_a78, ERRATUM(2132060)
nayanpatel-arm39e08652021-09-28 17:31:50 -0700107
Govindraj Raja3f957e72023-06-15 15:17:38 -0500108check_erratum_ls cortex_a78, ERRATUM(2132060), CPU_REV(1, 2)
nayanpatel-arm39e08652021-09-28 17:31:50 -0700109
Govindraj Raja3f957e72023-06-15 15:17:38 -0500110workaround_reset_start cortex_a78, ERRATUM(2242635), ERRATA_A78_2242635
johpow0145c17242021-09-02 17:53:30 -0500111 ldr x0, =0x5
112 msr S3_6_c15_c8_0, x0 /* CPUPSELR_EL3 */
113 ldr x0, =0x10F600E000
114 msr S3_6_c15_c8_2, x0 /* CPUPOR_EL3 */
115 ldr x0, =0x10FF80E000
116 msr S3_6_c15_c8_3, x0 /* CPUPMR_EL3 */
117 ldr x0, =0x80000000003FF
118 msr S3_6_c15_c8_1, x0 /* CPUPCR_EL3 */
Govindraj Raja3f957e72023-06-15 15:17:38 -0500119workaround_reset_end cortex_a78, ERRATUM(2242635)
johpow0145c17242021-09-02 17:53:30 -0500120
Govindraj Raja3f957e72023-06-15 15:17:38 -0500121check_erratum_range cortex_a78, ERRATUM(2242635), CPU_REV(1, 0), CPU_REV(1, 2)
johpow0145c17242021-09-02 17:53:30 -0500122
Govindraj Raja3f957e72023-06-15 15:17:38 -0500123workaround_reset_start cortex_a78, ERRATUM(2376745), ERRATA_A78_2376745
Govindraj Raja1087d502023-06-15 15:23:58 -0500124 sysreg_bit_set CORTEX_A78_ACTLR2_EL1, BIT(0)
Govindraj Raja3f957e72023-06-15 15:17:38 -0500125workaround_reset_end cortex_a78, ERRATUM(2376745)
John Powell12bc0de2022-05-03 15:22:57 -0500126
Govindraj Raja3f957e72023-06-15 15:17:38 -0500127check_erratum_ls cortex_a78, ERRATUM(2376745), CPU_REV(1, 2)
John Powella93b7e52022-05-03 15:52:11 -0500128
Govindraj Raja3f957e72023-06-15 15:17:38 -0500129workaround_reset_start cortex_a78, ERRATUM(2395406), ERRATA_A78_2395406
Govindraj Raja1087d502023-06-15 15:23:58 -0500130 sysreg_bit_set CORTEX_A78_ACTLR2_EL1, BIT(40)
Govindraj Raja3f957e72023-06-15 15:17:38 -0500131workaround_reset_end cortex_a78, ERRATUM(2395406)
John Powella93b7e52022-05-03 15:52:11 -0500132
Govindraj Raja3f957e72023-06-15 15:17:38 -0500133check_erratum_ls cortex_a78, ERRATUM(2395406), CPU_REV(1, 2)
John Powella93b7e52022-05-03 15:52:11 -0500134
Govindraj Raja3f957e72023-06-15 15:17:38 -0500135workaround_reset_start cortex_a78, ERRATUM(2742426), ERRATA_A78_2742426
Bipin Ravi33100ef2023-02-28 14:51:28 -0600136 /* Apply the workaround */
137 mrs x1, CORTEX_A78_ACTLR5_EL1
138 bic x1, x1, #BIT(56)
139 orr x1, x1, #BIT(55)
140 msr CORTEX_A78_ACTLR5_EL1, x1
Govindraj Raja3f957e72023-06-15 15:17:38 -0500141workaround_reset_end cortex_a78, ERRATUM(2742426)
Bipin Ravi33100ef2023-02-28 14:51:28 -0600142
Govindraj Raja3f957e72023-06-15 15:17:38 -0500143check_erratum_ls cortex_a78, ERRATUM(2742426), CPU_REV(1, 2)
Bipin Ravi33100ef2023-02-28 14:51:28 -0600144
Govindraj Raja3f957e72023-06-15 15:17:38 -0500145workaround_runtime_start cortex_a78, ERRATUM(2772019), ERRATA_A78_2772019
Bipin Ravi8f78e0d2022-12-15 14:48:21 -0600146 /* dsb before isb of power down sequence */
147 dsb sy
Govindraj Raja3f957e72023-06-15 15:17:38 -0500148workaround_runtime_end cortex_a78, ERRATUM(2772019)
Bipin Ravi8f78e0d2022-12-15 14:48:21 -0600149
Govindraj Raja3f957e72023-06-15 15:17:38 -0500150check_erratum_ls cortex_a78, ERRATUM(2772019), CPU_REV(1, 2)
Bipin Ravi8f78e0d2022-12-15 14:48:21 -0600151
Govindraj Raja3f957e72023-06-15 15:17:38 -0500152workaround_reset_start cortex_a78, ERRATUM(2779479), ERRATA_A78_2779479
Govindraj Raja1087d502023-06-15 15:23:58 -0500153 sysreg_bit_set CORTEX_A78_ACTLR3_EL1, BIT(47)
Govindraj Raja3f957e72023-06-15 15:17:38 -0500154workaround_reset_end cortex_a78, ERRATUM(2779479)
Sona Mathewf13c1a92023-01-11 12:55:30 -0600155
Govindraj Raja3f957e72023-06-15 15:17:38 -0500156check_erratum_ls cortex_a78, ERRATUM(2779479), CPU_REV(1, 2)
Sona Mathewf13c1a92023-01-11 12:55:30 -0600157
Govindraj Raja3f957e72023-06-15 15:17:38 -0500158workaround_reset_start cortex_a78, CVE(2022, 23960), WORKAROUND_CVE_2022_23960
159#if IMAGE_BL31
160 /*
161 * The Cortex-X1 generic vectors are overridden to apply errata
162 * mitigation on exception entry from lower ELs.
Balint Dobszaydb2ec852019-07-15 11:46:20 +0200163 */
Govindraj Raja1087d502023-06-15 15:23:58 -0500164 override_vector_table wa_cve_vbar_cortex_a78
Govindraj Raja3f957e72023-06-15 15:17:38 -0500165#endif /* IMAGE_BL31 */
166workaround_reset_end cortex_a78, CVE(2022, 23960)
Bipin Ravi33100ef2023-02-28 14:51:28 -0600167
Govindraj Raja3f957e72023-06-15 15:17:38 -0500168check_erratum_chosen cortex_a78, CVE(2022, 23960), WORKAROUND_CVE_2022_23960
Sona Mathewf13c1a92023-01-11 12:55:30 -0600169
Govindraj Raja3f957e72023-06-15 15:17:38 -0500170cpu_reset_func_start cortex_a78
Andre Przywara0b7f1b02023-03-21 13:53:19 +0000171#if ENABLE_FEAT_AMU
Balint Dobszaydb2ec852019-07-15 11:46:20 +0200172 /* Make sure accesses from EL0/EL1 and EL2 are not trapped to EL3 */
Govindraj Raja1087d502023-06-15 15:23:58 -0500173 sysreg_bit_clear actlr_el3, CORTEX_A78_ACTLR_TAM_BIT
Balint Dobszaydb2ec852019-07-15 11:46:20 +0200174
175 /* Make sure accesses from non-secure EL0/EL1 are not trapped to EL2 */
Govindraj Raja1087d502023-06-15 15:23:58 -0500176 sysreg_bit_clear actlr_el2, CORTEX_A78_ACTLR_TAM_BIT
Balint Dobszaydb2ec852019-07-15 11:46:20 +0200177
178 /* Enable group0 counters */
Jimmy Brisson3571fb92020-06-01 10:18:22 -0500179 mov x0, #CORTEX_A78_AMU_GROUP0_MASK
Balint Dobszaydb2ec852019-07-15 11:46:20 +0200180 msr CPUAMCNTENSET0_EL0, x0
181
182 /* Enable group1 counters */
Jimmy Brisson3571fb92020-06-01 10:18:22 -0500183 mov x0, #CORTEX_A78_AMU_GROUP1_MASK
Balint Dobszaydb2ec852019-07-15 11:46:20 +0200184 msr CPUAMCNTENSET1_EL0, x0
Madhukar Pappireddy4efede72019-12-18 15:56:27 -0600185#endif
Govindraj Raja3f957e72023-06-15 15:17:38 -0500186cpu_reset_func_end cortex_a78
Balint Dobszaydb2ec852019-07-15 11:46:20 +0200187
Louis Mayencourtf57f1082019-05-14 11:00:45 +0100188 /* ---------------------------------------------
189 * HW will do the cache maintenance while powering down
190 * ---------------------------------------------
191 */
Jimmy Brisson3571fb92020-06-01 10:18:22 -0500192func cortex_a78_core_pwr_dwn
Govindraj Raja1087d502023-06-15 15:23:58 -0500193 sysreg_bit_set CORTEX_A78_CPUPWRCTLR_EL1, CORTEX_A78_CPUPWRCTLR_EL1_CORE_PWRDN_EN_BIT
Govindraj Raja3f957e72023-06-15 15:17:38 -0500194
195 apply_erratum cortex_a78, ERRATUM(2772019), ERRATA_A78_2772019
196
Louis Mayencourtf57f1082019-05-14 11:00:45 +0100197 isb
198 ret
Jimmy Brisson3571fb92020-06-01 10:18:22 -0500199endfunc cortex_a78_core_pwr_dwn
Louis Mayencourtf57f1082019-05-14 11:00:45 +0100200
Govindraj Raja3f957e72023-06-15 15:17:38 -0500201errata_report_shim cortex_a78
Louis Mayencourtf57f1082019-05-14 11:00:45 +0100202
203 /* ---------------------------------------------
Jimmy Brisson3571fb92020-06-01 10:18:22 -0500204 * This function provides cortex_a78 specific
Louis Mayencourtf57f1082019-05-14 11:00:45 +0100205 * register information for crash reporting.
206 * It needs to return with x6 pointing to
207 * a list of register names in ascii and
208 * x8 - x15 having values of registers to be
209 * reported.
210 * ---------------------------------------------
211 */
Jimmy Brisson3571fb92020-06-01 10:18:22 -0500212.section .rodata.cortex_a78_regs, "aS"
213cortex_a78_regs: /* The ascii list of register names to be reported */
Louis Mayencourtf57f1082019-05-14 11:00:45 +0100214 .asciz "cpuectlr_el1", ""
215
Jimmy Brisson3571fb92020-06-01 10:18:22 -0500216func cortex_a78_cpu_reg_dump
217 adr x6, cortex_a78_regs
218 mrs x8, CORTEX_A78_CPUECTLR_EL1
Louis Mayencourtf57f1082019-05-14 11:00:45 +0100219 ret
Jimmy Brisson3571fb92020-06-01 10:18:22 -0500220endfunc cortex_a78_cpu_reg_dump
Louis Mayencourtf57f1082019-05-14 11:00:45 +0100221
Jimmy Brisson3571fb92020-06-01 10:18:22 -0500222declare_cpu_ops cortex_a78, CORTEX_A78_MIDR, \
223 cortex_a78_reset_func, \
224 cortex_a78_core_pwr_dwn