blob: 9988c349ecf7ca8307c9a7ed6fa8c3b37fb16d42 [file] [log] [blame]
Yatharth Kochar63af6872016-02-09 12:00:03 +00001/*
Sona Mathewadc7b322023-06-19 15:37:09 -05002 * Copyright (c) 2016-2023, Arm Limited and Contributors. All rights reserved.
Yatharth Kochar63af6872016-02-09 12:00:03 +00003 *
dp-armfa3cf0b2017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
Yatharth Kochar63af6872016-02-09 12:00:03 +00005 */
6#include <arch.h>
7#include <asm_macros.S>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +00008#include <common/bl_common.h>
Yatharth Kochar63af6872016-02-09 12:00:03 +00009#include <cortex_a73.h>
10#include <cpu_macros.S>
11#include <plat_macros.S>
12
13 /* ---------------------------------------------
14 * Disable L1 data cache
15 * ---------------------------------------------
16 */
17func cortex_a73_disable_dcache
18 mrs x1, sctlr_el3
19 bic x1, x1, #SCTLR_C_BIT
20 msr sctlr_el3, x1
21 isb
22 ret
23endfunc cortex_a73_disable_dcache
24
25 /* ---------------------------------------------
26 * Disable intra-cluster coherency
27 * ---------------------------------------------
28 */
29func cortex_a73_disable_smp
30 mrs x0, CORTEX_A73_CPUECTLR_EL1
31 bic x0, x0, #CORTEX_A73_CPUECTLR_SMP_BIT
32 msr CORTEX_A73_CPUECTLR_EL1, x0
33 isb
34 dsb sy
35 ret
36endfunc cortex_a73_disable_smp
37
Sona Mathewadc7b322023-06-19 15:37:09 -050038func check_smccc_arch_workaround_3
39 mov x0, #ERRATA_APPLIES
40 ret
41endfunc check_smccc_arch_workaround_3
42
Sona Mathewc1f65de2023-06-19 18:52:45 -050043workaround_reset_start cortex_a73, ERRATUM(852427), ERRATA_A73_852427
Louis Mayencourtd69722c2019-02-27 14:24:16 +000044 mrs x1, CORTEX_A73_DIAGNOSTIC_REGISTER
45 orr x1, x1, #(1 << 12)
46 msr CORTEX_A73_DIAGNOSTIC_REGISTER, x1
Sona Mathewc1f65de2023-06-19 18:52:45 -050047workaround_reset_end cortex_a73, ERRATUM(852427)
Louis Mayencourtd69722c2019-02-27 14:24:16 +000048
Sona Mathewc1f65de2023-06-19 18:52:45 -050049check_erratum_ls cortex_a73, ERRATUM(852427), CPU_REV(0, 0)
Louis Mayencourtd69722c2019-02-27 14:24:16 +000050
Sona Mathewc1f65de2023-06-19 18:52:45 -050051workaround_reset_start cortex_a73, ERRATUM(855423), ERRATA_A73_855423
Louis Mayencourt4405de62019-02-21 16:38:16 +000052 mrs x1, CORTEX_A73_IMP_DEF_REG2
53 orr x1, x1, #(1 << 7)
54 msr CORTEX_A73_IMP_DEF_REG2, x1
Sona Mathewc1f65de2023-06-19 18:52:45 -050055workaround_reset_end cortex_a73, ERRATUM(855423)
Louis Mayencourt4405de62019-02-21 16:38:16 +000056
Sona Mathewc1f65de2023-06-19 18:52:45 -050057check_erratum_ls cortex_a73, ERRATUM(855423), CPU_REV(0, 1)
Louis Mayencourt4405de62019-02-21 16:38:16 +000058
Sona Mathewc1f65de2023-06-19 18:52:45 -050059workaround_reset_start cortex_a73, CVE(2017, 5715), WORKAROUND_CVE_2017_5715
60#if IMAGE_BL31
61 adr x0, wa_cve_2017_5715_bpiall_vbar
62 msr vbar_el3, x0
63#endif /* IMAGE_BL31 */
64workaround_reset_end cortex_a73, CVE(2017, 5715)
65
66check_erratum_custom_start cortex_a73, CVE(2017, 5715)
Sona Mathewadc7b322023-06-19 15:37:09 -050067 cpu_check_csv2 x0, 1f
68#if WORKAROUND_CVE_2017_5715
69 mov x0, #ERRATA_APPLIES
70#else
71 mov x0, #ERRATA_MISSING
72#endif
73 ret
741:
75 mov x0, #ERRATA_NOT_APPLIES
76 ret
Sona Mathewc1f65de2023-06-19 18:52:45 -050077check_erratum_custom_end cortex_a73, CVE(2017, 5715)
Sona Mathewadc7b322023-06-19 15:37:09 -050078
Sona Mathewc1f65de2023-06-19 18:52:45 -050079workaround_reset_start cortex_a73, CVE(2018, 3639), WORKAROUND_CVE_2018_3639
80 mrs x0, CORTEX_A73_IMP_DEF_REG1
81 orr x0, x0, #CORTEX_A73_IMP_DEF_REG1_DISABLE_LOAD_PASS_STORE
82 msr CORTEX_A73_IMP_DEF_REG1, x0
83workaround_reset_end cortex_a73, CVE(2018, 3639)
84
85check_erratum_chosen cortex_a73, CVE(2018, 3639), WORKAROUND_CVE_2018_3639
86
87workaround_reset_start cortex_a73, CVE(2022, 23960), WORKAROUND_CVE_2022_23960
88#if IMAGE_BL31
89 /* Skip installing vector table again for CVE_2022_23960 */
90 adr x0, wa_cve_2017_5715_bpiall_vbar
91 mrs x1, vbar_el3
92 cmp x0, x1
93 b.eq 1f
94 msr vbar_el3, x0
951:
96#endif /* IMAGE_BL31 */
97workaround_reset_end cortex_a73, CVE(2022, 23960)
Sona Mathewadc7b322023-06-19 15:37:09 -050098
Sona Mathewc1f65de2023-06-19 18:52:45 -050099check_erratum_custom_start cortex_a73, CVE(2022, 23960)
Sona Mathewadc7b322023-06-19 15:37:09 -0500100#if WORKAROUND_CVE_2017_5715 || WORKAROUND_CVE_2022_23960
Sona Mathewc1f65de2023-06-19 18:52:45 -0500101 cpu_check_csv2 x0, 1f
Sona Mathewadc7b322023-06-19 15:37:09 -0500102 mov x0, #ERRATA_APPLIES
103 ret
104 1:
Sona Mathewc1f65de2023-06-19 18:52:45 -0500105#if WORKAROUND_CVE_2022_23960
Sona Mathewadc7b322023-06-19 15:37:09 -0500106 mov x0, #ERRATA_APPLIES
Sona Mathewc1f65de2023-06-19 18:52:45 -0500107#else
Sona Mathewadc7b322023-06-19 15:37:09 -0500108 mov x0, #ERRATA_MISSING
Sona Mathewc1f65de2023-06-19 18:52:45 -0500109#endif /* WORKAROUND_CVE_2022_23960 */
Sona Mathewadc7b322023-06-19 15:37:09 -0500110 ret
111#endif /* WORKAROUND_CVE_2017_5715 || WORKAROUND_CVE_2022_23960 */
112 mov x0, #ERRATA_MISSING
113 ret
Sona Mathewc1f65de2023-06-19 18:52:45 -0500114check_erratum_custom_end cortex_a73, CVE(2022, 23960)
Sona Mathewadc7b322023-06-19 15:37:09 -0500115
Louis Mayencourt4405de62019-02-21 16:38:16 +0000116 /* -------------------------------------------------
117 * The CPU Ops reset function for Cortex-A73.
118 * -------------------------------------------------
119 */
120
Sona Mathewc1f65de2023-06-19 18:52:45 -0500121cpu_reset_func_start cortex_a73
Yatharth Kochar63af6872016-02-09 12:00:03 +0000122 /* ---------------------------------------------
123 * Enable the SMP bit.
124 * Clobbers : x0
125 * ---------------------------------------------
126 */
127 mrs x0, CORTEX_A73_CPUECTLR_EL1
128 orr x0, x0, #CORTEX_A73_CPUECTLR_SMP_BIT
129 msr CORTEX_A73_CPUECTLR_EL1, x0
Sona Mathewc1f65de2023-06-19 18:52:45 -0500130cpu_reset_func_end cortex_a73
Yatharth Kochar63af6872016-02-09 12:00:03 +0000131
132func cortex_a73_core_pwr_dwn
133 mov x18, x30
134
135 /* ---------------------------------------------
136 * Turn off caches.
137 * ---------------------------------------------
138 */
139 bl cortex_a73_disable_dcache
140
141 /* ---------------------------------------------
142 * Flush L1 caches.
143 * ---------------------------------------------
144 */
145 mov x0, #DCCISW
146 bl dcsw_op_level1
147
148 /* ---------------------------------------------
149 * Come out of intra cluster coherency
150 * ---------------------------------------------
151 */
152 mov x30, x18
153 b cortex_a73_disable_smp
154endfunc cortex_a73_core_pwr_dwn
155
156func cortex_a73_cluster_pwr_dwn
157 mov x18, x30
158
159 /* ---------------------------------------------
160 * Turn off caches.
161 * ---------------------------------------------
162 */
163 bl cortex_a73_disable_dcache
164
165 /* ---------------------------------------------
166 * Flush L1 caches.
167 * ---------------------------------------------
168 */
169 mov x0, #DCCISW
170 bl dcsw_op_level1
171
172 /* ---------------------------------------------
173 * Disable the optional ACP.
174 * ---------------------------------------------
175 */
176 bl plat_disable_acp
177
178 /* ---------------------------------------------
179 * Flush L2 caches.
180 * ---------------------------------------------
181 */
182 mov x0, #DCCISW
183 bl dcsw_op_level2
184
185 /* ---------------------------------------------
186 * Come out of intra cluster coherency
187 * ---------------------------------------------
188 */
189 mov x30, x18
190 b cortex_a73_disable_smp
191endfunc cortex_a73_cluster_pwr_dwn
192
Bipin Ravicaa2e052022-02-23 23:45:50 -0600193
Sona Mathewc1f65de2023-06-19 18:52:45 -0500194errata_report_shim cortex_a73
Dimitris Papastamos858bd612018-01-16 10:32:47 +0000195
Yatharth Kochar63af6872016-02-09 12:00:03 +0000196 /* ---------------------------------------------
197 * This function provides cortex_a73 specific
198 * register information for crash reporting.
199 * It needs to return with x6 pointing to
200 * a list of register names in ascii and
201 * x8 - x15 having values of registers to be
202 * reported.
203 * ---------------------------------------------
204 */
205.section .rodata.cortex_a73_regs, "aS"
206cortex_a73_regs: /* The ascii list of register names to be reported */
Naga Sureshkumar Relli6a72a912016-07-01 12:52:41 +0530207 .asciz "cpuectlr_el1", "l2merrsr_el1", ""
Yatharth Kochar63af6872016-02-09 12:00:03 +0000208
209func cortex_a73_cpu_reg_dump
210 adr x6, cortex_a73_regs
211 mrs x8, CORTEX_A73_CPUECTLR_EL1
Naga Sureshkumar Relli6a72a912016-07-01 12:52:41 +0530212 mrs x9, CORTEX_A73_L2MERRSR_EL1
Yatharth Kochar63af6872016-02-09 12:00:03 +0000213 ret
214endfunc cortex_a73_cpu_reg_dump
215
Dimitris Papastamosba51d9e2018-05-16 11:36:14 +0100216declare_cpu_ops_wa cortex_a73, CORTEX_A73_MIDR, \
Jeenu Viswambharanee5eb802016-11-18 12:58:28 +0000217 cortex_a73_reset_func, \
Sona Mathewc1f65de2023-06-19 18:52:45 -0500218 check_erratum_cortex_a73_5715, \
Dimitris Papastamosba51d9e2018-05-16 11:36:14 +0100219 CPU_NO_EXTRA2_FUNC, \
Bipin Ravicaa2e052022-02-23 23:45:50 -0600220 check_smccc_arch_workaround_3, \
Jeenu Viswambharanee5eb802016-11-18 12:58:28 +0000221 cortex_a73_core_pwr_dwn, \
222 cortex_a73_cluster_pwr_dwn