blob: 3a6b92263da13597798e70f0839fb07da0db7a51 [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
Sona Mathew3b018932023-06-19 19:08:18 -050018 sysreg_bit_clear sctlr_el3, SCTLR_C_BIT
Yatharth Kochar63af6872016-02-09 12:00:03 +000019 isb
20 ret
21endfunc cortex_a73_disable_dcache
22
23 /* ---------------------------------------------
24 * Disable intra-cluster coherency
25 * ---------------------------------------------
26 */
27func cortex_a73_disable_smp
Sona Mathew3b018932023-06-19 19:08:18 -050028 sysreg_bit_clear CORTEX_A73_CPUECTLR_EL1, CORTEX_A73_CPUECTLR_SMP_BIT
Yatharth Kochar63af6872016-02-09 12:00:03 +000029 isb
30 dsb sy
31 ret
32endfunc cortex_a73_disable_smp
33
Sona Mathewadc7b322023-06-19 15:37:09 -050034func check_smccc_arch_workaround_3
35 mov x0, #ERRATA_APPLIES
36 ret
37endfunc check_smccc_arch_workaround_3
38
Sona Mathewc1f65de2023-06-19 18:52:45 -050039workaround_reset_start cortex_a73, ERRATUM(852427), ERRATA_A73_852427
Sona Mathew3b018932023-06-19 19:08:18 -050040 sysreg_bit_set CORTEX_A73_DIAGNOSTIC_REGISTER, BIT(12)
Sona Mathewc1f65de2023-06-19 18:52:45 -050041workaround_reset_end cortex_a73, ERRATUM(852427)
Louis Mayencourtd69722c2019-02-27 14:24:16 +000042
Sona Mathewc1f65de2023-06-19 18:52:45 -050043check_erratum_ls cortex_a73, ERRATUM(852427), CPU_REV(0, 0)
Louis Mayencourtd69722c2019-02-27 14:24:16 +000044
Sona Mathewc1f65de2023-06-19 18:52:45 -050045workaround_reset_start cortex_a73, ERRATUM(855423), ERRATA_A73_855423
Sona Mathew3b018932023-06-19 19:08:18 -050046 sysreg_bit_set CORTEX_A73_IMP_DEF_REG2, BIT(7)
Sona Mathewc1f65de2023-06-19 18:52:45 -050047workaround_reset_end cortex_a73, ERRATUM(855423)
Louis Mayencourt4405de62019-02-21 16:38:16 +000048
Sona Mathewc1f65de2023-06-19 18:52:45 -050049check_erratum_ls cortex_a73, ERRATUM(855423), CPU_REV(0, 1)
Louis Mayencourt4405de62019-02-21 16:38:16 +000050
Sona Mathewc1f65de2023-06-19 18:52:45 -050051workaround_reset_start cortex_a73, CVE(2017, 5715), WORKAROUND_CVE_2017_5715
52#if IMAGE_BL31
Sona Mathew3b018932023-06-19 19:08:18 -050053 override_vector_table wa_cve_2017_5715_bpiall_vbar
Sona Mathewc1f65de2023-06-19 18:52:45 -050054#endif /* IMAGE_BL31 */
55workaround_reset_end cortex_a73, CVE(2017, 5715)
56
57check_erratum_custom_start cortex_a73, CVE(2017, 5715)
Sona Mathewadc7b322023-06-19 15:37:09 -050058 cpu_check_csv2 x0, 1f
59#if WORKAROUND_CVE_2017_5715
60 mov x0, #ERRATA_APPLIES
61#else
62 mov x0, #ERRATA_MISSING
63#endif
64 ret
651:
66 mov x0, #ERRATA_NOT_APPLIES
67 ret
Sona Mathewc1f65de2023-06-19 18:52:45 -050068check_erratum_custom_end cortex_a73, CVE(2017, 5715)
Sona Mathewadc7b322023-06-19 15:37:09 -050069
Sona Mathewc1f65de2023-06-19 18:52:45 -050070workaround_reset_start cortex_a73, CVE(2018, 3639), WORKAROUND_CVE_2018_3639
Sona Mathew3b018932023-06-19 19:08:18 -050071 sysreg_bit_set CORTEX_A73_IMP_DEF_REG1, CORTEX_A73_IMP_DEF_REG1_DISABLE_LOAD_PASS_STORE
Sona Mathewc1f65de2023-06-19 18:52:45 -050072workaround_reset_end cortex_a73, CVE(2018, 3639)
73
74check_erratum_chosen cortex_a73, CVE(2018, 3639), WORKAROUND_CVE_2018_3639
75
76workaround_reset_start cortex_a73, CVE(2022, 23960), WORKAROUND_CVE_2022_23960
77#if IMAGE_BL31
78 /* Skip installing vector table again for CVE_2022_23960 */
Sona Mathew613ef672023-08-07 18:16:27 -050079 adr x0, wa_cve_2017_5715_bpiall_vbar
80 mrs x1, vbar_el3
81
Sona Mathewc1f65de2023-06-19 18:52:45 -050082 cmp x0, x1
83 b.eq 1f
84 msr vbar_el3, x0
851:
86#endif /* IMAGE_BL31 */
87workaround_reset_end cortex_a73, CVE(2022, 23960)
Sona Mathewadc7b322023-06-19 15:37:09 -050088
Sona Mathewc1f65de2023-06-19 18:52:45 -050089check_erratum_custom_start cortex_a73, CVE(2022, 23960)
Sona Mathewadc7b322023-06-19 15:37:09 -050090#if WORKAROUND_CVE_2017_5715 || WORKAROUND_CVE_2022_23960
Sona Mathewc1f65de2023-06-19 18:52:45 -050091 cpu_check_csv2 x0, 1f
Sona Mathewadc7b322023-06-19 15:37:09 -050092 mov x0, #ERRATA_APPLIES
93 ret
94 1:
Sona Mathewc1f65de2023-06-19 18:52:45 -050095#if WORKAROUND_CVE_2022_23960
Sona Mathewadc7b322023-06-19 15:37:09 -050096 mov x0, #ERRATA_APPLIES
Sona Mathewc1f65de2023-06-19 18:52:45 -050097#else
Sona Mathewadc7b322023-06-19 15:37:09 -050098 mov x0, #ERRATA_MISSING
Sona Mathewc1f65de2023-06-19 18:52:45 -050099#endif /* WORKAROUND_CVE_2022_23960 */
Sona Mathewadc7b322023-06-19 15:37:09 -0500100 ret
101#endif /* WORKAROUND_CVE_2017_5715 || WORKAROUND_CVE_2022_23960 */
102 mov x0, #ERRATA_MISSING
103 ret
Sona Mathewc1f65de2023-06-19 18:52:45 -0500104check_erratum_custom_end cortex_a73, CVE(2022, 23960)
Sona Mathewadc7b322023-06-19 15:37:09 -0500105
Louis Mayencourt4405de62019-02-21 16:38:16 +0000106 /* -------------------------------------------------
107 * The CPU Ops reset function for Cortex-A73.
108 * -------------------------------------------------
109 */
110
Sona Mathewc1f65de2023-06-19 18:52:45 -0500111cpu_reset_func_start cortex_a73
Yatharth Kochar63af6872016-02-09 12:00:03 +0000112 /* ---------------------------------------------
113 * Enable the SMP bit.
114 * Clobbers : x0
115 * ---------------------------------------------
116 */
Sona Mathew3b018932023-06-19 19:08:18 -0500117 sysreg_bit_set CORTEX_A73_CPUECTLR_EL1, CORTEX_A73_CPUECTLR_SMP_BIT
Sona Mathewc1f65de2023-06-19 18:52:45 -0500118cpu_reset_func_end cortex_a73
Yatharth Kochar63af6872016-02-09 12:00:03 +0000119
120func cortex_a73_core_pwr_dwn
121 mov x18, x30
122
123 /* ---------------------------------------------
124 * Turn off caches.
125 * ---------------------------------------------
126 */
127 bl cortex_a73_disable_dcache
128
129 /* ---------------------------------------------
130 * Flush L1 caches.
131 * ---------------------------------------------
132 */
133 mov x0, #DCCISW
134 bl dcsw_op_level1
135
136 /* ---------------------------------------------
137 * Come out of intra cluster coherency
138 * ---------------------------------------------
139 */
140 mov x30, x18
141 b cortex_a73_disable_smp
142endfunc cortex_a73_core_pwr_dwn
143
144func cortex_a73_cluster_pwr_dwn
145 mov x18, x30
146
147 /* ---------------------------------------------
148 * Turn off caches.
149 * ---------------------------------------------
150 */
151 bl cortex_a73_disable_dcache
152
153 /* ---------------------------------------------
154 * Flush L1 caches.
155 * ---------------------------------------------
156 */
157 mov x0, #DCCISW
158 bl dcsw_op_level1
159
160 /* ---------------------------------------------
161 * Disable the optional ACP.
162 * ---------------------------------------------
163 */
164 bl plat_disable_acp
165
166 /* ---------------------------------------------
167 * Flush L2 caches.
168 * ---------------------------------------------
169 */
170 mov x0, #DCCISW
171 bl dcsw_op_level2
172
173 /* ---------------------------------------------
174 * Come out of intra cluster coherency
175 * ---------------------------------------------
176 */
177 mov x30, x18
178 b cortex_a73_disable_smp
179endfunc cortex_a73_cluster_pwr_dwn
180
Bipin Ravicaa2e052022-02-23 23:45:50 -0600181
Sona Mathewc1f65de2023-06-19 18:52:45 -0500182errata_report_shim cortex_a73
Dimitris Papastamos858bd612018-01-16 10:32:47 +0000183
Yatharth Kochar63af6872016-02-09 12:00:03 +0000184 /* ---------------------------------------------
185 * This function provides cortex_a73 specific
186 * register information for crash reporting.
187 * It needs to return with x6 pointing to
188 * a list of register names in ascii and
189 * x8 - x15 having values of registers to be
190 * reported.
191 * ---------------------------------------------
192 */
193.section .rodata.cortex_a73_regs, "aS"
194cortex_a73_regs: /* The ascii list of register names to be reported */
Naga Sureshkumar Relli6a72a912016-07-01 12:52:41 +0530195 .asciz "cpuectlr_el1", "l2merrsr_el1", ""
Yatharth Kochar63af6872016-02-09 12:00:03 +0000196
197func cortex_a73_cpu_reg_dump
198 adr x6, cortex_a73_regs
199 mrs x8, CORTEX_A73_CPUECTLR_EL1
Naga Sureshkumar Relli6a72a912016-07-01 12:52:41 +0530200 mrs x9, CORTEX_A73_L2MERRSR_EL1
Yatharth Kochar63af6872016-02-09 12:00:03 +0000201 ret
202endfunc cortex_a73_cpu_reg_dump
203
Dimitris Papastamosba51d9e2018-05-16 11:36:14 +0100204declare_cpu_ops_wa cortex_a73, CORTEX_A73_MIDR, \
Jeenu Viswambharanee5eb802016-11-18 12:58:28 +0000205 cortex_a73_reset_func, \
Sona Mathewc1f65de2023-06-19 18:52:45 -0500206 check_erratum_cortex_a73_5715, \
Dimitris Papastamosba51d9e2018-05-16 11:36:14 +0100207 CPU_NO_EXTRA2_FUNC, \
Bipin Ravicaa2e052022-02-23 23:45:50 -0600208 check_smccc_arch_workaround_3, \
Jeenu Viswambharanee5eb802016-11-18 12:58:28 +0000209 cortex_a73_core_pwr_dwn, \
210 cortex_a73_cluster_pwr_dwn