blob: c90be679480cfbf655a98bd9327eabd35176caa8 [file] [log] [blame]
David Wang805c2c72016-11-09 16:29:02 +00001/*
Govindraj Rajaeee28e72023-08-01 15:52:40 -05002 * Copyright (c) 2017-2023, Arm Limited and Contributors. All rights reserved.
David Wang805c2c72016-11-09 16:29:02 +00003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <arch.h>
8#include <asm_macros.S>
David Wang805c2c72016-11-09 16:29:02 +00009#include <cortex_a75.h>
Dimitris Papastamos1be747f2018-02-14 10:28:36 +000010#include <cpuamu.h>
11#include <cpu_macros.S>
Dimitris Papastamosd7e2e9e2017-12-11 11:45:35 +000012
John Tsichritzisfe6df392019-03-19 17:20:52 +000013/* Hardware handled coherency */
14#if HW_ASSISTED_COHERENCY == 0
15#error "Cortex-A75 must be compiled with HW_ASSISTED_COHERENCY enabled"
16#endif
17
Kathleen Capellabd06ca22023-04-13 18:36:57 -040018workaround_reset_start cortex_a75, ERRATUM(764081), ERRATA_A75_764081
Kathleen Capella65a3ce72023-06-09 14:11:53 -040019 sysreg_bit_set sctlr_el3, SCTLR_IESB_BIT
Kathleen Capellabd06ca22023-04-13 18:36:57 -040020workaround_reset_end cortex_a75, ERRATUM(764081)
Louis Mayencourt78a0aed2019-02-20 12:11:41 +000021
Kathleen Capellabd06ca22023-04-13 18:36:57 -040022check_erratum_ls cortex_a75, ERRATUM(764081), CPU_REV(0, 0)
Louis Mayencourt78a0aed2019-02-20 12:11:41 +000023
Kathleen Capellabd06ca22023-04-13 18:36:57 -040024workaround_reset_start cortex_a75, ERRATUM(790748), ERRATA_A75_790748
Kathleen Capella65a3ce72023-06-09 14:11:53 -040025 sysreg_bit_set CORTEX_A75_CPUACTLR_EL1, (1 << 13)
Kathleen Capellabd06ca22023-04-13 18:36:57 -040026workaround_reset_end cortex_a75, ERRATUM(790748)
Louis Mayencourt8d868702019-02-25 14:57:57 +000027
Kathleen Capellabd06ca22023-04-13 18:36:57 -040028check_erratum_ls cortex_a75, ERRATUM(790748), CPU_REV(0, 0)
Louis Mayencourt78a0aed2019-02-20 12:11:41 +000029
Kathleen Capellabd06ca22023-04-13 18:36:57 -040030/* ERRATA_DSU_798953 :
31 * The errata is defined in dsu_helpers.S but applies to cortex_a75
32 * as well. Henceforth creating symbolic names to the already existing errata
33 * workaround functions to get them registered under the Errata Framework.
34 */
35.equ check_erratum_cortex_a75_798953, check_errata_dsu_798953
36.equ erratum_cortex_a75_798953_wa, errata_dsu_798953_wa
37add_erratum_entry cortex_a75, ERRATUM(798953), ERRATA_DSU_798953, APPLY_AT_RESET
Louis Mayencourt78a0aed2019-02-20 12:11:41 +000038
Kathleen Capellabd06ca22023-04-13 18:36:57 -040039/* ERRATA_DSU_936184 :
40 * The errata is defined in dsu_helpers.S but applies to cortex_a75
41 * as well. Henceforth creating symbolic names to the already existing errata
42 * workaround functions to get them registered under the Errata Framework.
43 */
44.equ check_erratum_cortex_a75_936184, check_errata_dsu_936184
45.equ erratum_cortex_a75_936184_wa, errata_dsu_936184_wa
46add_erratum_entry cortex_a75, ERRATUM(936184), ERRATA_DSU_936184, APPLY_AT_RESET
Louis Mayencourt8d868702019-02-25 14:57:57 +000047
Kathleen Capellabd06ca22023-04-13 18:36:57 -040048workaround_reset_start cortex_a75, CVE(2017, 5715), WORKAROUND_CVE_2017_5715
49#if IMAGE_BL31
Kathleen Capella65a3ce72023-06-09 14:11:53 -040050 override_vector_table wa_cve_2017_5715_bpiall_vbar
Kathleen Capellabd06ca22023-04-13 18:36:57 -040051#endif /* IMAGE_BL31 */
52workaround_reset_end cortex_a75, CVE(2017, 5715)
53
54check_erratum_custom_start cortex_a75, CVE(2017, 5715)
55 cpu_check_csv2 x0, 1f
56#if WORKAROUND_CVE_2017_5715
57 mov x0, #ERRATA_APPLIES
58#else
59 mov x0, #ERRATA_MISSING
Dimitris Papastamosc52ebdc2017-12-18 13:46:21 +000060#endif
Kathleen Capellabd06ca22023-04-13 18:36:57 -040061 ret
621:
63 mov x0, #ERRATA_NOT_APPLIES
64 ret
65check_erratum_custom_end cortex_a75, CVE(2017, 5715)
Dimitris Papastamosc52ebdc2017-12-18 13:46:21 +000066
Kathleen Capellabd06ca22023-04-13 18:36:57 -040067workaround_reset_start cortex_a75, CVE(2018, 3639), WORKAROUND_CVE_2018_3639
Kathleen Capella65a3ce72023-06-09 14:11:53 -040068 sysreg_bit_set CORTEX_A75_CPUACTLR_EL1, CORTEX_A75_CPUACTLR_EL1_DISABLE_LOAD_PASS_STORE
Kathleen Capellabd06ca22023-04-13 18:36:57 -040069workaround_reset_end cortex_a75, CVE(2018, 3639)
Dimitris Papastamose6625ec2018-04-05 14:38:26 +010070
Kathleen Capellabd06ca22023-04-13 18:36:57 -040071check_erratum_chosen cortex_a75, CVE(2018, 3639), WORKAROUND_CVE_2018_3639
Louis Mayencourt4498b152019-04-09 16:29:01 +010072
Kathleen Capellabd06ca22023-04-13 18:36:57 -040073workaround_reset_start cortex_a75, CVE(2022, 23960), WORKAROUND_CVE_2022_23960
74#if IMAGE_BL31
75 /* Skip installing vector table again if already done for CVE(2017, 5715) */
76 adr x0, wa_cve_2017_5715_bpiall_vbar
77 mrs x1, vbar_el3
78 cmp x0, x1
79 b.eq 1f
80 msr vbar_el3, x0
811:
82#endif /* IMAGE_BL31 */
83workaround_reset_end cortex_a75, CVE(2022, 23960)
84
85check_erratum_custom_start cortex_a75, CVE(2022, 23960)
86#if WORKAROUND_CVE_2017_5715 || WORKAROUND_CVE_2022_23960
87 cpu_check_csv2 x0, 1f
88 mov x0, #ERRATA_APPLIES
89 ret
901:
91# if WORKAROUND_CVE_2022_23960
92 mov x0, #ERRATA_APPLIES
93# else
94 mov x0, #ERRATA_MISSING
95# endif /* WORKAROUND_CVE_2022_23960 */
96 ret
97#endif /* WORKAROUND_CVE_2017_5715 || WORKAROUND_CVE_2022_23960 */
98 mov x0, #ERRATA_MISSING
99 ret
100check_erratum_custom_end cortex_a75, CVE(2022, 23960)
John Tsichritzis4daa1de2018-07-23 09:11:59 +0100101
Kathleen Capellabd06ca22023-04-13 18:36:57 -0400102 /* -------------------------------------------------
103 * The CPU Ops reset function for Cortex-A75.
104 * -------------------------------------------------
105 */
106
107cpu_reset_func_start cortex_a75
Andre Przywara0b7f1b02023-03-21 13:53:19 +0000108#if ENABLE_FEAT_AMU
Dimitris Papastamosfcedb692017-10-16 11:40:10 +0100109 /* Make sure accesses from EL0/EL1 and EL2 are not trapped to EL3 */
Kathleen Capella65a3ce72023-06-09 14:11:53 -0400110 sysreg_bit_set actlr_el3, CORTEX_A75_ACTLR_AMEN_BIT
Dimitris Papastamosfcedb692017-10-16 11:40:10 +0100111 isb
112
113 /* Make sure accesses from EL0/EL1 are not trapped to EL2 */
Kathleen Capella65a3ce72023-06-09 14:11:53 -0400114 sysreg_bit_set actlr_el2, CORTEX_A75_ACTLR_AMEN_BIT
Dimitris Papastamosfcedb692017-10-16 11:40:10 +0100115 isb
116
117 /* Enable group0 counters */
118 mov x0, #CORTEX_A75_AMU_GROUP0_MASK
119 msr CPUAMCNTENSET_EL0, x0
120 isb
121
122 /* Enable group1 counters */
123 mov x0, #CORTEX_A75_AMU_GROUP1_MASK
124 msr CPUAMCNTENSET_EL0, x0
Kathleen Capellabd06ca22023-04-13 18:36:57 -0400125 /* isb included in cpu_reset_func_end macro */
Dimitris Papastamose6625ec2018-04-05 14:38:26 +0100126#endif
Kathleen Capellabd06ca22023-04-13 18:36:57 -0400127cpu_reset_func_end cortex_a75
Bipin Ravicaa2e052022-02-23 23:45:50 -0600128
129func check_smccc_arch_workaround_3
130 mov x0, #ERRATA_APPLIES
131 ret
132endfunc check_smccc_arch_workaround_3
133
David Wang805c2c72016-11-09 16:29:02 +0000134 /* ---------------------------------------------
135 * HW will do the cache maintenance while powering down
136 * ---------------------------------------------
137 */
138func cortex_a75_core_pwr_dwn
139 /* ---------------------------------------------
140 * Enable CPU power down bit in power control register
141 * ---------------------------------------------
142 */
Kathleen Capella65a3ce72023-06-09 14:11:53 -0400143 sysreg_bit_set CORTEX_A75_CPUPWRCTLR_EL1, \
144 CORTEX_A75_CORE_PWRDN_EN_MASK
David Wang805c2c72016-11-09 16:29:02 +0000145 isb
146 ret
147endfunc cortex_a75_core_pwr_dwn
148
Kathleen Capellabd06ca22023-04-13 18:36:57 -0400149errata_report_shim cortex_a75
Dimitris Papastamos858bd612018-01-16 10:32:47 +0000150
David Wang805c2c72016-11-09 16:29:02 +0000151 /* ---------------------------------------------
152 * This function provides cortex_a75 specific
153 * register information for crash reporting.
154 * It needs to return with x6 pointing to
155 * a list of register names in ascii and
156 * x8 - x15 having values of registers to be
157 * reported.
158 * ---------------------------------------------
159 */
160.section .rodata.cortex_a75_regs, "aS"
161cortex_a75_regs: /* The ascii list of register names to be reported */
162 .asciz "cpuectlr_el1", ""
163
164func cortex_a75_cpu_reg_dump
165 adr x6, cortex_a75_regs
166 mrs x8, CORTEX_A75_CPUECTLR_EL1
167 ret
168endfunc cortex_a75_cpu_reg_dump
169
Dimitris Papastamosba51d9e2018-05-16 11:36:14 +0100170declare_cpu_ops_wa cortex_a75, CORTEX_A75_MIDR, \
Dimitris Papastamosfcedb692017-10-16 11:40:10 +0100171 cortex_a75_reset_func, \
Kathleen Capellabd06ca22023-04-13 18:36:57 -0400172 check_erratum_cortex_a75_5715, \
Dimitris Papastamosba51d9e2018-05-16 11:36:14 +0100173 CPU_NO_EXTRA2_FUNC, \
Bipin Ravicaa2e052022-02-23 23:45:50 -0600174 check_smccc_arch_workaround_3, \
David Wang805c2c72016-11-09 16:29:02 +0000175 cortex_a75_core_pwr_dwn