blob: e121b7da8036bb694400ac4006ab3497fd7506d8 [file] [log] [blame]
David Wang805c2c72016-11-09 16:29:02 +00001/*
Dimitris Papastamos858bd612018-01-16 10:32:47 +00002 * Copyright (c) 2017-2018, 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
Dimitris Papastamosfcedb692017-10-16 11:40:10 +010013func cortex_a75_reset_func
John Tsichritzis4daa1de2018-07-23 09:11:59 +010014 mov x19, x30
Dimitris Papastamosc52ebdc2017-12-18 13:46:21 +000015#if IMAGE_BL31 && WORKAROUND_CVE_2017_5715
Dimitris Papastamos780cc952018-03-12 13:27:02 +000016 cpu_check_csv2 x0, 1f
Dimitris Papastamos570c06a2018-04-06 15:29:34 +010017 adr x0, wa_cve_2017_5715_bpiall_vbar
Dimitris Papastamosc52ebdc2017-12-18 13:46:21 +000018 msr vbar_el3, x0
Dimitris Papastamosbb0aa392018-06-07 13:20:19 +010019 isb
Dimitris Papastamos43e05ec2018-01-02 15:53:01 +0000201:
Dimitris Papastamosc52ebdc2017-12-18 13:46:21 +000021#endif
22
Dimitris Papastamose6625ec2018-04-05 14:38:26 +010023#if WORKAROUND_CVE_2018_3639
24 mrs x0, CORTEX_A75_CPUACTLR_EL1
25 orr x0, x0, #CORTEX_A75_CPUACTLR_EL1_DISABLE_LOAD_PASS_STORE
26 msr CORTEX_A75_CPUACTLR_EL1, x0
27 isb
28#endif
29
John Tsichritzis4daa1de2018-07-23 09:11:59 +010030#if ERRATA_DSU_936184
31 bl errata_dsu_936184_wa
32#endif
33
Dimitris Papastamosfcedb692017-10-16 11:40:10 +010034#if ENABLE_AMU
35 /* Make sure accesses from EL0/EL1 and EL2 are not trapped to EL3 */
36 mrs x0, actlr_el3
37 orr x0, x0, #CORTEX_A75_ACTLR_AMEN_BIT
38 msr actlr_el3, x0
39 isb
40
41 /* Make sure accesses from EL0/EL1 are not trapped to EL2 */
42 mrs x0, actlr_el2
43 orr x0, x0, #CORTEX_A75_ACTLR_AMEN_BIT
44 msr actlr_el2, x0
45 isb
46
47 /* Enable group0 counters */
48 mov x0, #CORTEX_A75_AMU_GROUP0_MASK
49 msr CPUAMCNTENSET_EL0, x0
50 isb
51
52 /* Enable group1 counters */
53 mov x0, #CORTEX_A75_AMU_GROUP1_MASK
54 msr CPUAMCNTENSET_EL0, x0
55 isb
56#endif
John Tsichritzis4daa1de2018-07-23 09:11:59 +010057 ret x19
Dimitris Papastamosfcedb692017-10-16 11:40:10 +010058endfunc cortex_a75_reset_func
59
Dimitris Papastamos858bd612018-01-16 10:32:47 +000060func check_errata_cve_2017_5715
Dimitris Papastamos780cc952018-03-12 13:27:02 +000061 cpu_check_csv2 x0, 1f
Dimitris Papastamos858bd612018-01-16 10:32:47 +000062#if WORKAROUND_CVE_2017_5715
63 mov x0, #ERRATA_APPLIES
64#else
65 mov x0, #ERRATA_MISSING
66#endif
67 ret
681:
69 mov x0, #ERRATA_NOT_APPLIES
70 ret
71endfunc check_errata_cve_2017_5715
72
Dimitris Papastamose6625ec2018-04-05 14:38:26 +010073func check_errata_cve_2018_3639
74#if WORKAROUND_CVE_2018_3639
75 mov x0, #ERRATA_APPLIES
76#else
77 mov x0, #ERRATA_MISSING
78#endif
79 ret
80endfunc check_errata_cve_2018_3639
81
David Wang805c2c72016-11-09 16:29:02 +000082 /* ---------------------------------------------
83 * HW will do the cache maintenance while powering down
84 * ---------------------------------------------
85 */
86func cortex_a75_core_pwr_dwn
87 /* ---------------------------------------------
88 * Enable CPU power down bit in power control register
89 * ---------------------------------------------
90 */
91 mrs x0, CORTEX_A75_CPUPWRCTLR_EL1
92 orr x0, x0, #CORTEX_A75_CORE_PWRDN_EN_MASK
93 msr CORTEX_A75_CPUPWRCTLR_EL1, x0
94 isb
95 ret
96endfunc cortex_a75_core_pwr_dwn
97
Dimitris Papastamos858bd612018-01-16 10:32:47 +000098#if REPORT_ERRATA
99/*
100 * Errata printing function for Cortex A75. Must follow AAPCS.
101 */
102func cortex_a75_errata_report
103 stp x8, x30, [sp, #-16]!
104
105 bl cpu_get_rev_var
106 mov x8, x0
107
108 /*
109 * Report all errata. The revision-variant information is passed to
110 * checking functions of each errata.
111 */
112 report_errata WORKAROUND_CVE_2017_5715, cortex_a75, cve_2017_5715
Dimitris Papastamose6625ec2018-04-05 14:38:26 +0100113 report_errata WORKAROUND_CVE_2018_3639, cortex_a75, cve_2018_3639
John Tsichritzis4daa1de2018-07-23 09:11:59 +0100114 report_errata ERRATA_DSU_936184, cortex_a75, dsu_936184
Dimitris Papastamos858bd612018-01-16 10:32:47 +0000115
116 ldp x8, x30, [sp], #16
117 ret
118endfunc cortex_a75_errata_report
119#endif
120
David Wang805c2c72016-11-09 16:29:02 +0000121 /* ---------------------------------------------
122 * This function provides cortex_a75 specific
123 * register information for crash reporting.
124 * It needs to return with x6 pointing to
125 * a list of register names in ascii and
126 * x8 - x15 having values of registers to be
127 * reported.
128 * ---------------------------------------------
129 */
130.section .rodata.cortex_a75_regs, "aS"
131cortex_a75_regs: /* The ascii list of register names to be reported */
132 .asciz "cpuectlr_el1", ""
133
134func cortex_a75_cpu_reg_dump
135 adr x6, cortex_a75_regs
136 mrs x8, CORTEX_A75_CPUECTLR_EL1
137 ret
138endfunc cortex_a75_cpu_reg_dump
139
Dimitris Papastamosba51d9e2018-05-16 11:36:14 +0100140declare_cpu_ops_wa cortex_a75, CORTEX_A75_MIDR, \
Dimitris Papastamosfcedb692017-10-16 11:40:10 +0100141 cortex_a75_reset_func, \
Dimitris Papastamos914757c2018-03-12 14:47:09 +0000142 check_errata_cve_2017_5715, \
Dimitris Papastamosba51d9e2018-05-16 11:36:14 +0100143 CPU_NO_EXTRA2_FUNC, \
David Wang805c2c72016-11-09 16:29:02 +0000144 cortex_a75_core_pwr_dwn