blob: 1d7c2d7bb5fa9ea38fdde6357c42403008a68b40 [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
Jimmy Brisson3571fb92020-06-01 10:18:22 -050028 mrs x1, CORTEX_A78_ACTLR2_EL1
johpow019131eb82020-10-06 17:55:25 -050029 orr x1, x1, #CORTEX_A78_ACTLR2_EL1_BIT_1
Jimmy Brisson3571fb92020-06-01 10:18:22 -050030 msr CORTEX_A78_ACTLR2_EL1, x1
Govindraj Raja3f957e72023-06-15 15:17:38 -050031workaround_reset_end cortex_a78, ERRATUM(1688305)
Madhukar Pappireddy4efede72019-12-18 15:56:27 -060032
Govindraj Raja3f957e72023-06-15 15:17:38 -050033check_erratum_ls cortex_a78, ERRATUM(1688305), CPU_REV(1, 0)
Govindraj Raja805dc802023-06-15 12:39:48 -050034
Govindraj Raja3f957e72023-06-15 15:17:38 -050035workaround_reset_start cortex_a78, ERRATUM(1821534), ERRATA_A78_1821534
Govindraj Raja805dc802023-06-15 12:39:48 -050036 /* Set bit 2 in ACTLR2_EL1 */
37 mrs x1, CORTEX_A78_ACTLR2_EL1
38 orr x1, x1, #CORTEX_A78_ACTLR2_EL1_BIT_2
39 msr CORTEX_A78_ACTLR2_EL1, x1
Govindraj Raja3f957e72023-06-15 15:17:38 -050040workaround_reset_end cortex_a78, ERRATUM(1821534)
Govindraj Raja805dc802023-06-15 12:39:48 -050041
Govindraj Raja3f957e72023-06-15 15:17:38 -050042check_erratum_ls cortex_a78, ERRATUM(1821534), CPU_REV(1, 0)
Govindraj Raja805dc802023-06-15 12:39:48 -050043
Govindraj Raja3f957e72023-06-15 15:17:38 -050044workaround_reset_start cortex_a78, ERRATUM(1941498), ERRATA_A78_1941498
johpow019131eb82020-10-06 17:55:25 -050045 /* Set bit 8 in ECTLR_EL1 */
46 mrs x1, CORTEX_A78_CPUECTLR_EL1
47 orr x1, x1, #CORTEX_A78_CPUECTLR_EL1_BIT_8
48 msr CORTEX_A78_CPUECTLR_EL1, x1
Govindraj Raja3f957e72023-06-15 15:17:38 -050049workaround_reset_end cortex_a78, ERRATUM(1941498)
johpow019131eb82020-10-06 17:55:25 -050050
Govindraj Raja3f957e72023-06-15 15:17:38 -050051check_erratum_ls cortex_a78, ERRATUM(1941498), CPU_REV(1, 1)
johpow019131eb82020-10-06 17:55:25 -050052
Govindraj Raja3f957e72023-06-15 15:17:38 -050053workaround_reset_start cortex_a78, ERRATUM(1951500), ERRATA_A78_1951500
johpow0185ea43d2020-10-07 15:08:01 -050054 msr S3_6_c15_c8_0, xzr
55 ldr x0, =0x10E3900002
56 msr S3_6_c15_c8_2, x0
57 ldr x0, =0x10FFF00083
58 msr S3_6_c15_c8_3, x0
59 ldr x0, =0x2001003FF
60 msr S3_6_c15_c8_1, x0
61
62 mov x0, #1
63 msr S3_6_c15_c8_0, x0
64 ldr x0, =0x10E3800082
65 msr S3_6_c15_c8_2, x0
66 ldr x0, =0x10FFF00083
67 msr S3_6_c15_c8_3, x0
68 ldr x0, =0x2001003FF
69 msr S3_6_c15_c8_1, x0
70
71 mov x0, #2
72 msr S3_6_c15_c8_0, x0
73 ldr x0, =0x10E3800200
74 msr S3_6_c15_c8_2, x0
75 ldr x0, =0x10FFF003E0
76 msr S3_6_c15_c8_3, x0
77 ldr x0, =0x2001003FF
78 msr S3_6_c15_c8_1, x0
Govindraj Raja3f957e72023-06-15 15:17:38 -050079workaround_reset_end cortex_a78, ERRATUM(1951500)
johpow0185ea43d2020-10-07 15:08:01 -050080
Govindraj Raja3f957e72023-06-15 15:17:38 -050081check_erratum_range cortex_a78, ERRATUM(1951500), CPU_REV(1, 0), CPU_REV(1, 1)
nayanpatel-arm80bf7a52021-08-11 13:33:00 -070082
Govindraj Raja3f957e72023-06-15 15:17:38 -050083workaround_reset_start cortex_a78, ERRATUM(1952683), ERRATA_A78_1952683
nayanpatel-arm80bf7a52021-08-11 13:33:00 -070084 ldr x0,=0x5
85 msr S3_6_c15_c8_0,x0
86 ldr x0,=0xEEE10A10
87 msr S3_6_c15_c8_2,x0
88 ldr x0,=0xFFEF0FFF
89 msr S3_6_c15_c8_3,x0
90 ldr x0,=0x0010F000
91 msr S3_6_c15_c8_4,x0
92 ldr x0,=0x0010F000
93 msr S3_6_c15_c8_5,x0
94 ldr x0,=0x40000080023ff
95 msr S3_6_c15_c8_1,x0
96 ldr x0,=0x6
97 msr S3_6_c15_c8_0,x0
98 ldr x0,=0xEE640F34
99 msr S3_6_c15_c8_2,x0
100 ldr x0,=0xFFEF0FFF
101 msr S3_6_c15_c8_3,x0
102 ldr x0,=0x40000080023ff
103 msr S3_6_c15_c8_1,x0
Govindraj Raja3f957e72023-06-15 15:17:38 -0500104workaround_reset_end cortex_a78, ERRATUM(1952683)
nayanpatel-arm80bf7a52021-08-11 13:33:00 -0700105
Govindraj Raja3f957e72023-06-15 15:17:38 -0500106check_erratum_ls cortex_a78, ERRATUM(1952683), CPU_REV(0, 0)
nayanpatel-arm39e08652021-09-28 17:31:50 -0700107
Govindraj Raja3f957e72023-06-15 15:17:38 -0500108workaround_reset_start cortex_a78, ERRATUM(2132060), ERRATA_A78_2132060
nayanpatel-arm39e08652021-09-28 17:31:50 -0700109 /* Apply the workaround. */
110 mrs x1, CORTEX_A78_CPUECTLR_EL1
111 mov x0, #CORTEX_A78_CPUECTLR_EL1_PF_MODE_CNSRV
112 bfi x1, x0, #CPUECTLR_EL1_PF_MODE_LSB, #CPUECTLR_EL1_PF_MODE_WIDTH
113 msr CORTEX_A78_CPUECTLR_EL1, x1
Govindraj Raja3f957e72023-06-15 15:17:38 -0500114workaround_reset_end cortex_a78, ERRATUM(2132060)
nayanpatel-arm39e08652021-09-28 17:31:50 -0700115
Govindraj Raja3f957e72023-06-15 15:17:38 -0500116check_erratum_ls cortex_a78, ERRATUM(2132060), CPU_REV(1, 2)
nayanpatel-arm39e08652021-09-28 17:31:50 -0700117
Govindraj Raja3f957e72023-06-15 15:17:38 -0500118workaround_reset_start cortex_a78, ERRATUM(2242635), ERRATA_A78_2242635
johpow0145c17242021-09-02 17:53:30 -0500119 ldr x0, =0x5
120 msr S3_6_c15_c8_0, x0 /* CPUPSELR_EL3 */
121 ldr x0, =0x10F600E000
122 msr S3_6_c15_c8_2, x0 /* CPUPOR_EL3 */
123 ldr x0, =0x10FF80E000
124 msr S3_6_c15_c8_3, x0 /* CPUPMR_EL3 */
125 ldr x0, =0x80000000003FF
126 msr S3_6_c15_c8_1, x0 /* CPUPCR_EL3 */
Govindraj Raja3f957e72023-06-15 15:17:38 -0500127workaround_reset_end cortex_a78, ERRATUM(2242635)
johpow0145c17242021-09-02 17:53:30 -0500128
Govindraj Raja3f957e72023-06-15 15:17:38 -0500129check_erratum_range cortex_a78, ERRATUM(2242635), CPU_REV(1, 0), CPU_REV(1, 2)
johpow0145c17242021-09-02 17:53:30 -0500130
Govindraj Raja3f957e72023-06-15 15:17:38 -0500131workaround_reset_start cortex_a78, ERRATUM(2376745), ERRATA_A78_2376745
John Powell12bc0de2022-05-03 15:22:57 -0500132 /* Apply the workaround. */
133 mrs x1, CORTEX_A78_ACTLR2_EL1
134 orr x1, x1, #BIT(0)
135 msr CORTEX_A78_ACTLR2_EL1, x1
Govindraj Raja3f957e72023-06-15 15:17:38 -0500136workaround_reset_end cortex_a78, ERRATUM(2376745)
John Powell12bc0de2022-05-03 15:22:57 -0500137
Govindraj Raja3f957e72023-06-15 15:17:38 -0500138check_erratum_ls cortex_a78, ERRATUM(2376745), CPU_REV(1, 2)
John Powella93b7e52022-05-03 15:52:11 -0500139
Govindraj Raja3f957e72023-06-15 15:17:38 -0500140workaround_reset_start cortex_a78, ERRATUM(2395406), ERRATA_A78_2395406
John Powella93b7e52022-05-03 15:52:11 -0500141 /* Apply the workaround. */
142 mrs x1, CORTEX_A78_ACTLR2_EL1
143 orr x1, x1, #BIT(40)
144 msr CORTEX_A78_ACTLR2_EL1, x1
Govindraj Raja3f957e72023-06-15 15:17:38 -0500145workaround_reset_end cortex_a78, ERRATUM(2395406)
John Powella93b7e52022-05-03 15:52:11 -0500146
Govindraj Raja3f957e72023-06-15 15:17:38 -0500147check_erratum_ls cortex_a78, ERRATUM(2395406), CPU_REV(1, 2)
John Powella93b7e52022-05-03 15:52:11 -0500148
Govindraj Raja3f957e72023-06-15 15:17:38 -0500149workaround_reset_start cortex_a78, ERRATUM(2742426), ERRATA_A78_2742426
Bipin Ravi33100ef2023-02-28 14:51:28 -0600150 /* Apply the workaround */
151 mrs x1, CORTEX_A78_ACTLR5_EL1
152 bic x1, x1, #BIT(56)
153 orr x1, x1, #BIT(55)
154 msr CORTEX_A78_ACTLR5_EL1, x1
Govindraj Raja3f957e72023-06-15 15:17:38 -0500155workaround_reset_end cortex_a78, ERRATUM(2742426)
Bipin Ravi33100ef2023-02-28 14:51:28 -0600156
Govindraj Raja3f957e72023-06-15 15:17:38 -0500157check_erratum_ls cortex_a78, ERRATUM(2742426), CPU_REV(1, 2)
Bipin Ravi33100ef2023-02-28 14:51:28 -0600158
Govindraj Raja3f957e72023-06-15 15:17:38 -0500159workaround_runtime_start cortex_a78, ERRATUM(2772019), ERRATA_A78_2772019
Bipin Ravi8f78e0d2022-12-15 14:48:21 -0600160 /* dsb before isb of power down sequence */
161 dsb sy
Govindraj Raja3f957e72023-06-15 15:17:38 -0500162workaround_runtime_end cortex_a78, ERRATUM(2772019)
Bipin Ravi8f78e0d2022-12-15 14:48:21 -0600163
Govindraj Raja3f957e72023-06-15 15:17:38 -0500164check_erratum_ls cortex_a78, ERRATUM(2772019), CPU_REV(1, 2)
Bipin Ravi8f78e0d2022-12-15 14:48:21 -0600165
Govindraj Raja3f957e72023-06-15 15:17:38 -0500166workaround_reset_start cortex_a78, ERRATUM(2779479), ERRATA_A78_2779479
Sona Mathewf13c1a92023-01-11 12:55:30 -0600167 /* Apply the workaround */
168 mrs x1, CORTEX_A78_ACTLR3_EL1
169 orr x1, x1, #BIT(47)
170 msr CORTEX_A78_ACTLR3_EL1, x1
Govindraj Raja3f957e72023-06-15 15:17:38 -0500171workaround_reset_end cortex_a78, ERRATUM(2779479)
Sona Mathewf13c1a92023-01-11 12:55:30 -0600172
Govindraj Raja3f957e72023-06-15 15:17:38 -0500173check_erratum_ls cortex_a78, ERRATUM(2779479), CPU_REV(1, 2)
Sona Mathewf13c1a92023-01-11 12:55:30 -0600174
Govindraj Raja3f957e72023-06-15 15:17:38 -0500175workaround_reset_start cortex_a78, CVE(2022, 23960), WORKAROUND_CVE_2022_23960
176#if IMAGE_BL31
177 /*
178 * The Cortex-X1 generic vectors are overridden to apply errata
179 * mitigation on exception entry from lower ELs.
Balint Dobszaydb2ec852019-07-15 11:46:20 +0200180 */
Govindraj Raja3f957e72023-06-15 15:17:38 -0500181 adr x0, wa_cve_vbar_cortex_a78
182 msr vbar_el3, x0
183#endif /* IMAGE_BL31 */
184workaround_reset_end cortex_a78, CVE(2022, 23960)
Bipin Ravi33100ef2023-02-28 14:51:28 -0600185
Govindraj Raja3f957e72023-06-15 15:17:38 -0500186check_erratum_chosen cortex_a78, CVE(2022, 23960), WORKAROUND_CVE_2022_23960
Sona Mathewf13c1a92023-01-11 12:55:30 -0600187
Govindraj Raja3f957e72023-06-15 15:17:38 -0500188cpu_reset_func_start cortex_a78
Andre Przywara0b7f1b02023-03-21 13:53:19 +0000189#if ENABLE_FEAT_AMU
Balint Dobszaydb2ec852019-07-15 11:46:20 +0200190 /* Make sure accesses from EL0/EL1 and EL2 are not trapped to EL3 */
191 mrs x0, actlr_el3
Jimmy Brisson3571fb92020-06-01 10:18:22 -0500192 bic x0, x0, #CORTEX_A78_ACTLR_TAM_BIT
Balint Dobszaydb2ec852019-07-15 11:46:20 +0200193 msr actlr_el3, x0
194
195 /* Make sure accesses from non-secure EL0/EL1 are not trapped to EL2 */
196 mrs x0, actlr_el2
Jimmy Brisson3571fb92020-06-01 10:18:22 -0500197 bic x0, x0, #CORTEX_A78_ACTLR_TAM_BIT
Balint Dobszaydb2ec852019-07-15 11:46:20 +0200198 msr actlr_el2, x0
199
200 /* Enable group0 counters */
Jimmy Brisson3571fb92020-06-01 10:18:22 -0500201 mov x0, #CORTEX_A78_AMU_GROUP0_MASK
Balint Dobszaydb2ec852019-07-15 11:46:20 +0200202 msr CPUAMCNTENSET0_EL0, x0
203
204 /* Enable group1 counters */
Jimmy Brisson3571fb92020-06-01 10:18:22 -0500205 mov x0, #CORTEX_A78_AMU_GROUP1_MASK
Balint Dobszaydb2ec852019-07-15 11:46:20 +0200206 msr CPUAMCNTENSET1_EL0, x0
Madhukar Pappireddy4efede72019-12-18 15:56:27 -0600207#endif
Govindraj Raja3f957e72023-06-15 15:17:38 -0500208cpu_reset_func_end cortex_a78
Balint Dobszaydb2ec852019-07-15 11:46:20 +0200209
Louis Mayencourtf57f1082019-05-14 11:00:45 +0100210 /* ---------------------------------------------
211 * HW will do the cache maintenance while powering down
212 * ---------------------------------------------
213 */
Jimmy Brisson3571fb92020-06-01 10:18:22 -0500214func cortex_a78_core_pwr_dwn
Louis Mayencourtf57f1082019-05-14 11:00:45 +0100215 /* ---------------------------------------------
216 * Enable CPU power down bit in power control register
217 * ---------------------------------------------
218 */
Jimmy Brisson3571fb92020-06-01 10:18:22 -0500219 mrs x0, CORTEX_A78_CPUPWRCTLR_EL1
220 orr x0, x0, #CORTEX_A78_CPUPWRCTLR_EL1_CORE_PWRDN_EN_BIT
221 msr CORTEX_A78_CPUPWRCTLR_EL1, x0
Govindraj Raja3f957e72023-06-15 15:17:38 -0500222
223 apply_erratum cortex_a78, ERRATUM(2772019), ERRATA_A78_2772019
224
Louis Mayencourtf57f1082019-05-14 11:00:45 +0100225 isb
226 ret
Jimmy Brisson3571fb92020-06-01 10:18:22 -0500227endfunc cortex_a78_core_pwr_dwn
Louis Mayencourtf57f1082019-05-14 11:00:45 +0100228
Govindraj Raja3f957e72023-06-15 15:17:38 -0500229errata_report_shim cortex_a78
Louis Mayencourtf57f1082019-05-14 11:00:45 +0100230
231 /* ---------------------------------------------
Jimmy Brisson3571fb92020-06-01 10:18:22 -0500232 * This function provides cortex_a78 specific
Louis Mayencourtf57f1082019-05-14 11:00:45 +0100233 * register information for crash reporting.
234 * It needs to return with x6 pointing to
235 * a list of register names in ascii and
236 * x8 - x15 having values of registers to be
237 * reported.
238 * ---------------------------------------------
239 */
Jimmy Brisson3571fb92020-06-01 10:18:22 -0500240.section .rodata.cortex_a78_regs, "aS"
241cortex_a78_regs: /* The ascii list of register names to be reported */
Louis Mayencourtf57f1082019-05-14 11:00:45 +0100242 .asciz "cpuectlr_el1", ""
243
Jimmy Brisson3571fb92020-06-01 10:18:22 -0500244func cortex_a78_cpu_reg_dump
245 adr x6, cortex_a78_regs
246 mrs x8, CORTEX_A78_CPUECTLR_EL1
Louis Mayencourtf57f1082019-05-14 11:00:45 +0100247 ret
Jimmy Brisson3571fb92020-06-01 10:18:22 -0500248endfunc cortex_a78_cpu_reg_dump
Louis Mayencourtf57f1082019-05-14 11:00:45 +0100249
Jimmy Brisson3571fb92020-06-01 10:18:22 -0500250declare_cpu_ops cortex_a78, CORTEX_A78_MIDR, \
251 cortex_a78_reset_func, \
252 cortex_a78_core_pwr_dwn