blob: a7435c70fd1ea0ed37154bd5679cd3f684ebe771 [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 Mathew3b018932023-06-19 19:08:18 -050079 override_vector_table wa_cve_2017_5715_bpiall_vbar
Sona Mathewc1f65de2023-06-19 18:52:45 -050080 cmp x0, x1
81 b.eq 1f
82 msr vbar_el3, x0
831:
84#endif /* IMAGE_BL31 */
85workaround_reset_end cortex_a73, CVE(2022, 23960)
Sona Mathewadc7b322023-06-19 15:37:09 -050086
Sona Mathewc1f65de2023-06-19 18:52:45 -050087check_erratum_custom_start cortex_a73, CVE(2022, 23960)
Sona Mathewadc7b322023-06-19 15:37:09 -050088#if WORKAROUND_CVE_2017_5715 || WORKAROUND_CVE_2022_23960
Sona Mathewc1f65de2023-06-19 18:52:45 -050089 cpu_check_csv2 x0, 1f
Sona Mathewadc7b322023-06-19 15:37:09 -050090 mov x0, #ERRATA_APPLIES
91 ret
92 1:
Sona Mathewc1f65de2023-06-19 18:52:45 -050093#if WORKAROUND_CVE_2022_23960
Sona Mathewadc7b322023-06-19 15:37:09 -050094 mov x0, #ERRATA_APPLIES
Sona Mathewc1f65de2023-06-19 18:52:45 -050095#else
Sona Mathewadc7b322023-06-19 15:37:09 -050096 mov x0, #ERRATA_MISSING
Sona Mathewc1f65de2023-06-19 18:52:45 -050097#endif /* WORKAROUND_CVE_2022_23960 */
Sona Mathewadc7b322023-06-19 15:37:09 -050098 ret
99#endif /* WORKAROUND_CVE_2017_5715 || WORKAROUND_CVE_2022_23960 */
100 mov x0, #ERRATA_MISSING
101 ret
Sona Mathewc1f65de2023-06-19 18:52:45 -0500102check_erratum_custom_end cortex_a73, CVE(2022, 23960)
Sona Mathewadc7b322023-06-19 15:37:09 -0500103
Louis Mayencourt4405de62019-02-21 16:38:16 +0000104 /* -------------------------------------------------
105 * The CPU Ops reset function for Cortex-A73.
106 * -------------------------------------------------
107 */
108
Sona Mathewc1f65de2023-06-19 18:52:45 -0500109cpu_reset_func_start cortex_a73
Yatharth Kochar63af6872016-02-09 12:00:03 +0000110 /* ---------------------------------------------
111 * Enable the SMP bit.
112 * Clobbers : x0
113 * ---------------------------------------------
114 */
Sona Mathew3b018932023-06-19 19:08:18 -0500115 sysreg_bit_set CORTEX_A73_CPUECTLR_EL1, CORTEX_A73_CPUECTLR_SMP_BIT
Sona Mathewc1f65de2023-06-19 18:52:45 -0500116cpu_reset_func_end cortex_a73
Yatharth Kochar63af6872016-02-09 12:00:03 +0000117
118func cortex_a73_core_pwr_dwn
119 mov x18, x30
120
121 /* ---------------------------------------------
122 * Turn off caches.
123 * ---------------------------------------------
124 */
125 bl cortex_a73_disable_dcache
126
127 /* ---------------------------------------------
128 * Flush L1 caches.
129 * ---------------------------------------------
130 */
131 mov x0, #DCCISW
132 bl dcsw_op_level1
133
134 /* ---------------------------------------------
135 * Come out of intra cluster coherency
136 * ---------------------------------------------
137 */
138 mov x30, x18
139 b cortex_a73_disable_smp
140endfunc cortex_a73_core_pwr_dwn
141
142func cortex_a73_cluster_pwr_dwn
143 mov x18, x30
144
145 /* ---------------------------------------------
146 * Turn off caches.
147 * ---------------------------------------------
148 */
149 bl cortex_a73_disable_dcache
150
151 /* ---------------------------------------------
152 * Flush L1 caches.
153 * ---------------------------------------------
154 */
155 mov x0, #DCCISW
156 bl dcsw_op_level1
157
158 /* ---------------------------------------------
159 * Disable the optional ACP.
160 * ---------------------------------------------
161 */
162 bl plat_disable_acp
163
164 /* ---------------------------------------------
165 * Flush L2 caches.
166 * ---------------------------------------------
167 */
168 mov x0, #DCCISW
169 bl dcsw_op_level2
170
171 /* ---------------------------------------------
172 * Come out of intra cluster coherency
173 * ---------------------------------------------
174 */
175 mov x30, x18
176 b cortex_a73_disable_smp
177endfunc cortex_a73_cluster_pwr_dwn
178
Bipin Ravicaa2e052022-02-23 23:45:50 -0600179
Sona Mathewc1f65de2023-06-19 18:52:45 -0500180errata_report_shim cortex_a73
Dimitris Papastamos858bd612018-01-16 10:32:47 +0000181
Yatharth Kochar63af6872016-02-09 12:00:03 +0000182 /* ---------------------------------------------
183 * This function provides cortex_a73 specific
184 * register information for crash reporting.
185 * It needs to return with x6 pointing to
186 * a list of register names in ascii and
187 * x8 - x15 having values of registers to be
188 * reported.
189 * ---------------------------------------------
190 */
191.section .rodata.cortex_a73_regs, "aS"
192cortex_a73_regs: /* The ascii list of register names to be reported */
Naga Sureshkumar Relli6a72a912016-07-01 12:52:41 +0530193 .asciz "cpuectlr_el1", "l2merrsr_el1", ""
Yatharth Kochar63af6872016-02-09 12:00:03 +0000194
195func cortex_a73_cpu_reg_dump
196 adr x6, cortex_a73_regs
197 mrs x8, CORTEX_A73_CPUECTLR_EL1
Naga Sureshkumar Relli6a72a912016-07-01 12:52:41 +0530198 mrs x9, CORTEX_A73_L2MERRSR_EL1
Yatharth Kochar63af6872016-02-09 12:00:03 +0000199 ret
200endfunc cortex_a73_cpu_reg_dump
201
Dimitris Papastamosba51d9e2018-05-16 11:36:14 +0100202declare_cpu_ops_wa cortex_a73, CORTEX_A73_MIDR, \
Jeenu Viswambharanee5eb802016-11-18 12:58:28 +0000203 cortex_a73_reset_func, \
Sona Mathewc1f65de2023-06-19 18:52:45 -0500204 check_erratum_cortex_a73_5715, \
Dimitris Papastamosba51d9e2018-05-16 11:36:14 +0100205 CPU_NO_EXTRA2_FUNC, \
Bipin Ravicaa2e052022-02-23 23:45:50 -0600206 check_smccc_arch_workaround_3, \
Jeenu Viswambharanee5eb802016-11-18 12:58:28 +0000207 cortex_a73_core_pwr_dwn, \
208 cortex_a73_cluster_pwr_dwn