blob: 73f566f4b36b700339e6774e6b520ada36f1e3f8 [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
Dimitris Papastamosc52ebdc2017-12-18 13:46:21 +000014#if IMAGE_BL31 && WORKAROUND_CVE_2017_5715
Dimitris Papastamos780cc952018-03-12 13:27:02 +000015 cpu_check_csv2 x0, 1f
Dimitris Papastamos570c06a2018-04-06 15:29:34 +010016 adr x0, wa_cve_2017_5715_bpiall_vbar
Dimitris Papastamosc52ebdc2017-12-18 13:46:21 +000017 msr vbar_el3, x0
Dimitris Papastamosbb0aa392018-06-07 13:20:19 +010018 isb
Dimitris Papastamos43e05ec2018-01-02 15:53:01 +0000191:
Dimitris Papastamosc52ebdc2017-12-18 13:46:21 +000020#endif
21
Dimitris Papastamose6625ec2018-04-05 14:38:26 +010022#if WORKAROUND_CVE_2018_3639
23 mrs x0, CORTEX_A75_CPUACTLR_EL1
24 orr x0, x0, #CORTEX_A75_CPUACTLR_EL1_DISABLE_LOAD_PASS_STORE
25 msr CORTEX_A75_CPUACTLR_EL1, x0
26 isb
27#endif
28
Dimitris Papastamosfcedb692017-10-16 11:40:10 +010029#if ENABLE_AMU
30 /* Make sure accesses from EL0/EL1 and EL2 are not trapped to EL3 */
31 mrs x0, actlr_el3
32 orr x0, x0, #CORTEX_A75_ACTLR_AMEN_BIT
33 msr actlr_el3, x0
34 isb
35
36 /* Make sure accesses from EL0/EL1 are not trapped to EL2 */
37 mrs x0, actlr_el2
38 orr x0, x0, #CORTEX_A75_ACTLR_AMEN_BIT
39 msr actlr_el2, x0
40 isb
41
42 /* Enable group0 counters */
43 mov x0, #CORTEX_A75_AMU_GROUP0_MASK
44 msr CPUAMCNTENSET_EL0, x0
45 isb
46
47 /* Enable group1 counters */
48 mov x0, #CORTEX_A75_AMU_GROUP1_MASK
49 msr CPUAMCNTENSET_EL0, x0
50 isb
51#endif
52 ret
53endfunc cortex_a75_reset_func
54
Dimitris Papastamos858bd612018-01-16 10:32:47 +000055func check_errata_cve_2017_5715
Dimitris Papastamos780cc952018-03-12 13:27:02 +000056 cpu_check_csv2 x0, 1f
Dimitris Papastamos858bd612018-01-16 10:32:47 +000057#if WORKAROUND_CVE_2017_5715
58 mov x0, #ERRATA_APPLIES
59#else
60 mov x0, #ERRATA_MISSING
61#endif
62 ret
631:
64 mov x0, #ERRATA_NOT_APPLIES
65 ret
66endfunc check_errata_cve_2017_5715
67
Dimitris Papastamose6625ec2018-04-05 14:38:26 +010068func check_errata_cve_2018_3639
69#if WORKAROUND_CVE_2018_3639
70 mov x0, #ERRATA_APPLIES
71#else
72 mov x0, #ERRATA_MISSING
73#endif
74 ret
75endfunc check_errata_cve_2018_3639
76
David Wang805c2c72016-11-09 16:29:02 +000077 /* ---------------------------------------------
78 * HW will do the cache maintenance while powering down
79 * ---------------------------------------------
80 */
81func cortex_a75_core_pwr_dwn
82 /* ---------------------------------------------
83 * Enable CPU power down bit in power control register
84 * ---------------------------------------------
85 */
86 mrs x0, CORTEX_A75_CPUPWRCTLR_EL1
87 orr x0, x0, #CORTEX_A75_CORE_PWRDN_EN_MASK
88 msr CORTEX_A75_CPUPWRCTLR_EL1, x0
89 isb
90 ret
91endfunc cortex_a75_core_pwr_dwn
92
Dimitris Papastamos858bd612018-01-16 10:32:47 +000093#if REPORT_ERRATA
94/*
95 * Errata printing function for Cortex A75. Must follow AAPCS.
96 */
97func cortex_a75_errata_report
98 stp x8, x30, [sp, #-16]!
99
100 bl cpu_get_rev_var
101 mov x8, x0
102
103 /*
104 * Report all errata. The revision-variant information is passed to
105 * checking functions of each errata.
106 */
107 report_errata WORKAROUND_CVE_2017_5715, cortex_a75, cve_2017_5715
Dimitris Papastamose6625ec2018-04-05 14:38:26 +0100108 report_errata WORKAROUND_CVE_2018_3639, cortex_a75, cve_2018_3639
Dimitris Papastamos858bd612018-01-16 10:32:47 +0000109
110 ldp x8, x30, [sp], #16
111 ret
112endfunc cortex_a75_errata_report
113#endif
114
David Wang805c2c72016-11-09 16:29:02 +0000115 /* ---------------------------------------------
116 * This function provides cortex_a75 specific
117 * register information for crash reporting.
118 * It needs to return with x6 pointing to
119 * a list of register names in ascii and
120 * x8 - x15 having values of registers to be
121 * reported.
122 * ---------------------------------------------
123 */
124.section .rodata.cortex_a75_regs, "aS"
125cortex_a75_regs: /* The ascii list of register names to be reported */
126 .asciz "cpuectlr_el1", ""
127
128func cortex_a75_cpu_reg_dump
129 adr x6, cortex_a75_regs
130 mrs x8, CORTEX_A75_CPUECTLR_EL1
131 ret
132endfunc cortex_a75_cpu_reg_dump
133
Dimitris Papastamosba51d9e2018-05-16 11:36:14 +0100134declare_cpu_ops_wa cortex_a75, CORTEX_A75_MIDR, \
Dimitris Papastamosfcedb692017-10-16 11:40:10 +0100135 cortex_a75_reset_func, \
Dimitris Papastamos914757c2018-03-12 14:47:09 +0000136 check_errata_cve_2017_5715, \
Dimitris Papastamosba51d9e2018-05-16 11:36:14 +0100137 CPU_NO_EXTRA2_FUNC, \
David Wang805c2c72016-11-09 16:29:02 +0000138 cortex_a75_core_pwr_dwn