David Wang | 805c2c7 | 2016-11-09 16:29:02 +0000 | [diff] [blame] | 1 | /* |
Louis Mayencourt | 78a0aed | 2019-02-20 12:11:41 +0000 | [diff] [blame] | 2 | * Copyright (c) 2017-2019, ARM Limited and Contributors. All rights reserved. |
David Wang | 805c2c7 | 2016-11-09 16:29:02 +0000 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #include <arch.h> |
| 8 | #include <asm_macros.S> |
David Wang | 805c2c7 | 2016-11-09 16:29:02 +0000 | [diff] [blame] | 9 | #include <cortex_a75.h> |
Dimitris Papastamos | 1be747f | 2018-02-14 10:28:36 +0000 | [diff] [blame] | 10 | #include <cpuamu.h> |
| 11 | #include <cpu_macros.S> |
Dimitris Papastamos | d7e2e9e | 2017-12-11 11:45:35 +0000 | [diff] [blame] | 12 | |
John Tsichritzis | fe6df39 | 2019-03-19 17:20:52 +0000 | [diff] [blame] | 13 | /* Hardware handled coherency */ |
| 14 | #if HW_ASSISTED_COHERENCY == 0 |
| 15 | #error "Cortex-A75 must be compiled with HW_ASSISTED_COHERENCY enabled" |
| 16 | #endif |
| 17 | |
Louis Mayencourt | 78a0aed | 2019-02-20 12:11:41 +0000 | [diff] [blame] | 18 | /* -------------------------------------------------- |
| 19 | * Errata Workaround for Cortex A75 Errata #764081. |
| 20 | * This applies only to revision r0p0 of Cortex A75. |
| 21 | * Inputs: |
| 22 | * x0: variant[4:7] and revision[0:3] of current cpu. |
| 23 | * Shall clobber: x0-x17 |
| 24 | * -------------------------------------------------- |
| 25 | */ |
| 26 | func errata_a75_764081_wa |
| 27 | /* |
| 28 | * Compare x0 against revision r0p0 |
| 29 | */ |
| 30 | mov x17, x30 |
| 31 | bl check_errata_764081 |
| 32 | cbz x0, 1f |
| 33 | mrs x1, sctlr_el3 |
| 34 | orr x1, x1 ,#SCTLR_IESB_BIT |
| 35 | msr sctlr_el3, x1 |
| 36 | isb |
| 37 | 1: |
| 38 | ret x17 |
| 39 | endfunc errata_a75_764081_wa |
| 40 | |
| 41 | func check_errata_764081 |
| 42 | mov x1, #0x00 |
| 43 | b cpu_rev_var_ls |
| 44 | endfunc check_errata_764081 |
| 45 | |
Louis Mayencourt | 8d86870 | 2019-02-25 14:57:57 +0000 | [diff] [blame] | 46 | /* -------------------------------------------------- |
| 47 | * Errata Workaround for Cortex A75 Errata #790748. |
| 48 | * This applies only to revision r0p0 of Cortex A75. |
| 49 | * Inputs: |
| 50 | * x0: variant[4:7] and revision[0:3] of current cpu. |
| 51 | * Shall clobber: x0-x17 |
| 52 | * -------------------------------------------------- |
| 53 | */ |
| 54 | func errata_a75_790748_wa |
| 55 | /* |
| 56 | * Compare x0 against revision r0p0 |
| 57 | */ |
| 58 | mov x17, x30 |
| 59 | bl check_errata_790748 |
| 60 | cbz x0, 1f |
| 61 | mrs x1, CORTEX_A75_CPUACTLR_EL1 |
| 62 | orr x1, x1 ,#(1 << 13) |
| 63 | msr CORTEX_A75_CPUACTLR_EL1, x1 |
| 64 | isb |
| 65 | 1: |
| 66 | ret x17 |
| 67 | endfunc errata_a75_790748_wa |
| 68 | |
| 69 | func check_errata_790748 |
| 70 | mov x1, #0x00 |
| 71 | b cpu_rev_var_ls |
| 72 | endfunc check_errata_790748 |
| 73 | |
Louis Mayencourt | 78a0aed | 2019-02-20 12:11:41 +0000 | [diff] [blame] | 74 | /* ------------------------------------------------- |
| 75 | * The CPU Ops reset function for Cortex-A75. |
| 76 | * ------------------------------------------------- |
| 77 | */ |
Dimitris Papastamos | fcedb69 | 2017-10-16 11:40:10 +0100 | [diff] [blame] | 78 | func cortex_a75_reset_func |
John Tsichritzis | 4daa1de | 2018-07-23 09:11:59 +0100 | [diff] [blame] | 79 | mov x19, x30 |
Louis Mayencourt | 78a0aed | 2019-02-20 12:11:41 +0000 | [diff] [blame] | 80 | bl cpu_get_rev_var |
Louis Mayencourt | 8d86870 | 2019-02-25 14:57:57 +0000 | [diff] [blame] | 81 | mov x18, x0 |
Louis Mayencourt | 78a0aed | 2019-02-20 12:11:41 +0000 | [diff] [blame] | 82 | |
| 83 | #if ERRATA_A75_764081 |
Louis Mayencourt | 8d86870 | 2019-02-25 14:57:57 +0000 | [diff] [blame] | 84 | mov x0, x18 |
Louis Mayencourt | 78a0aed | 2019-02-20 12:11:41 +0000 | [diff] [blame] | 85 | bl errata_a75_764081_wa |
| 86 | #endif |
| 87 | |
Louis Mayencourt | 8d86870 | 2019-02-25 14:57:57 +0000 | [diff] [blame] | 88 | #if ERRATA_A75_790748 |
| 89 | mov x0, x18 |
| 90 | bl errata_a75_790748_wa |
| 91 | #endif |
| 92 | |
Dimitris Papastamos | c52ebdc | 2017-12-18 13:46:21 +0000 | [diff] [blame] | 93 | #if IMAGE_BL31 && WORKAROUND_CVE_2017_5715 |
Dimitris Papastamos | 780cc95 | 2018-03-12 13:27:02 +0000 | [diff] [blame] | 94 | cpu_check_csv2 x0, 1f |
Dimitris Papastamos | 570c06a | 2018-04-06 15:29:34 +0100 | [diff] [blame] | 95 | adr x0, wa_cve_2017_5715_bpiall_vbar |
Dimitris Papastamos | c52ebdc | 2017-12-18 13:46:21 +0000 | [diff] [blame] | 96 | msr vbar_el3, x0 |
Dimitris Papastamos | bb0aa39 | 2018-06-07 13:20:19 +0100 | [diff] [blame] | 97 | isb |
Dimitris Papastamos | 43e05ec | 2018-01-02 15:53:01 +0000 | [diff] [blame] | 98 | 1: |
Dimitris Papastamos | c52ebdc | 2017-12-18 13:46:21 +0000 | [diff] [blame] | 99 | #endif |
| 100 | |
Dimitris Papastamos | e6625ec | 2018-04-05 14:38:26 +0100 | [diff] [blame] | 101 | #if WORKAROUND_CVE_2018_3639 |
| 102 | mrs x0, CORTEX_A75_CPUACTLR_EL1 |
| 103 | orr x0, x0, #CORTEX_A75_CPUACTLR_EL1_DISABLE_LOAD_PASS_STORE |
| 104 | msr CORTEX_A75_CPUACTLR_EL1, x0 |
| 105 | isb |
| 106 | #endif |
| 107 | |
Louis Mayencourt | 4498b15 | 2019-04-09 16:29:01 +0100 | [diff] [blame] | 108 | #if ERRATA_DSU_798953 |
| 109 | bl errata_dsu_798953_wa |
| 110 | #endif |
| 111 | |
John Tsichritzis | 4daa1de | 2018-07-23 09:11:59 +0100 | [diff] [blame] | 112 | #if ERRATA_DSU_936184 |
| 113 | bl errata_dsu_936184_wa |
| 114 | #endif |
| 115 | |
Dimitris Papastamos | fcedb69 | 2017-10-16 11:40:10 +0100 | [diff] [blame] | 116 | #if ENABLE_AMU |
| 117 | /* Make sure accesses from EL0/EL1 and EL2 are not trapped to EL3 */ |
| 118 | mrs x0, actlr_el3 |
| 119 | orr x0, x0, #CORTEX_A75_ACTLR_AMEN_BIT |
| 120 | msr actlr_el3, x0 |
| 121 | isb |
| 122 | |
| 123 | /* Make sure accesses from EL0/EL1 are not trapped to EL2 */ |
| 124 | mrs x0, actlr_el2 |
| 125 | orr x0, x0, #CORTEX_A75_ACTLR_AMEN_BIT |
| 126 | msr actlr_el2, x0 |
| 127 | isb |
| 128 | |
| 129 | /* Enable group0 counters */ |
| 130 | mov x0, #CORTEX_A75_AMU_GROUP0_MASK |
| 131 | msr CPUAMCNTENSET_EL0, x0 |
| 132 | isb |
| 133 | |
| 134 | /* Enable group1 counters */ |
| 135 | mov x0, #CORTEX_A75_AMU_GROUP1_MASK |
| 136 | msr CPUAMCNTENSET_EL0, x0 |
| 137 | isb |
| 138 | #endif |
John Tsichritzis | 4daa1de | 2018-07-23 09:11:59 +0100 | [diff] [blame] | 139 | ret x19 |
Dimitris Papastamos | fcedb69 | 2017-10-16 11:40:10 +0100 | [diff] [blame] | 140 | endfunc cortex_a75_reset_func |
| 141 | |
Dimitris Papastamos | 858bd61 | 2018-01-16 10:32:47 +0000 | [diff] [blame] | 142 | func check_errata_cve_2017_5715 |
Dimitris Papastamos | 780cc95 | 2018-03-12 13:27:02 +0000 | [diff] [blame] | 143 | cpu_check_csv2 x0, 1f |
Dimitris Papastamos | 858bd61 | 2018-01-16 10:32:47 +0000 | [diff] [blame] | 144 | #if WORKAROUND_CVE_2017_5715 |
| 145 | mov x0, #ERRATA_APPLIES |
| 146 | #else |
| 147 | mov x0, #ERRATA_MISSING |
| 148 | #endif |
| 149 | ret |
| 150 | 1: |
| 151 | mov x0, #ERRATA_NOT_APPLIES |
| 152 | ret |
| 153 | endfunc check_errata_cve_2017_5715 |
| 154 | |
Dimitris Papastamos | e6625ec | 2018-04-05 14:38:26 +0100 | [diff] [blame] | 155 | func check_errata_cve_2018_3639 |
| 156 | #if WORKAROUND_CVE_2018_3639 |
| 157 | mov x0, #ERRATA_APPLIES |
| 158 | #else |
| 159 | mov x0, #ERRATA_MISSING |
| 160 | #endif |
| 161 | ret |
| 162 | endfunc check_errata_cve_2018_3639 |
| 163 | |
David Wang | 805c2c7 | 2016-11-09 16:29:02 +0000 | [diff] [blame] | 164 | /* --------------------------------------------- |
| 165 | * HW will do the cache maintenance while powering down |
| 166 | * --------------------------------------------- |
| 167 | */ |
| 168 | func cortex_a75_core_pwr_dwn |
| 169 | /* --------------------------------------------- |
| 170 | * Enable CPU power down bit in power control register |
| 171 | * --------------------------------------------- |
| 172 | */ |
| 173 | mrs x0, CORTEX_A75_CPUPWRCTLR_EL1 |
| 174 | orr x0, x0, #CORTEX_A75_CORE_PWRDN_EN_MASK |
| 175 | msr CORTEX_A75_CPUPWRCTLR_EL1, x0 |
| 176 | isb |
| 177 | ret |
| 178 | endfunc cortex_a75_core_pwr_dwn |
| 179 | |
Dimitris Papastamos | 858bd61 | 2018-01-16 10:32:47 +0000 | [diff] [blame] | 180 | #if REPORT_ERRATA |
| 181 | /* |
| 182 | * Errata printing function for Cortex A75. Must follow AAPCS. |
| 183 | */ |
| 184 | func cortex_a75_errata_report |
| 185 | stp x8, x30, [sp, #-16]! |
| 186 | |
| 187 | bl cpu_get_rev_var |
| 188 | mov x8, x0 |
| 189 | |
| 190 | /* |
| 191 | * Report all errata. The revision-variant information is passed to |
| 192 | * checking functions of each errata. |
| 193 | */ |
Louis Mayencourt | 78a0aed | 2019-02-20 12:11:41 +0000 | [diff] [blame] | 194 | report_errata ERRATA_A75_764081, cortex_a75, 764081 |
Louis Mayencourt | 8d86870 | 2019-02-25 14:57:57 +0000 | [diff] [blame] | 195 | report_errata ERRATA_A75_790748, cortex_a75, 790748 |
Dimitris Papastamos | 858bd61 | 2018-01-16 10:32:47 +0000 | [diff] [blame] | 196 | report_errata WORKAROUND_CVE_2017_5715, cortex_a75, cve_2017_5715 |
Dimitris Papastamos | e6625ec | 2018-04-05 14:38:26 +0100 | [diff] [blame] | 197 | report_errata WORKAROUND_CVE_2018_3639, cortex_a75, cve_2018_3639 |
Louis Mayencourt | 4498b15 | 2019-04-09 16:29:01 +0100 | [diff] [blame] | 198 | report_errata ERRATA_DSU_798953, cortex_a75, dsu_798953 |
John Tsichritzis | 4daa1de | 2018-07-23 09:11:59 +0100 | [diff] [blame] | 199 | report_errata ERRATA_DSU_936184, cortex_a75, dsu_936184 |
Dimitris Papastamos | 858bd61 | 2018-01-16 10:32:47 +0000 | [diff] [blame] | 200 | |
| 201 | ldp x8, x30, [sp], #16 |
| 202 | ret |
| 203 | endfunc cortex_a75_errata_report |
| 204 | #endif |
| 205 | |
David Wang | 805c2c7 | 2016-11-09 16:29:02 +0000 | [diff] [blame] | 206 | /* --------------------------------------------- |
| 207 | * This function provides cortex_a75 specific |
| 208 | * register information for crash reporting. |
| 209 | * It needs to return with x6 pointing to |
| 210 | * a list of register names in ascii and |
| 211 | * x8 - x15 having values of registers to be |
| 212 | * reported. |
| 213 | * --------------------------------------------- |
| 214 | */ |
| 215 | .section .rodata.cortex_a75_regs, "aS" |
| 216 | cortex_a75_regs: /* The ascii list of register names to be reported */ |
| 217 | .asciz "cpuectlr_el1", "" |
| 218 | |
| 219 | func cortex_a75_cpu_reg_dump |
| 220 | adr x6, cortex_a75_regs |
| 221 | mrs x8, CORTEX_A75_CPUECTLR_EL1 |
| 222 | ret |
| 223 | endfunc cortex_a75_cpu_reg_dump |
| 224 | |
Dimitris Papastamos | ba51d9e | 2018-05-16 11:36:14 +0100 | [diff] [blame] | 225 | declare_cpu_ops_wa cortex_a75, CORTEX_A75_MIDR, \ |
Dimitris Papastamos | fcedb69 | 2017-10-16 11:40:10 +0100 | [diff] [blame] | 226 | cortex_a75_reset_func, \ |
Dimitris Papastamos | 914757c | 2018-03-12 14:47:09 +0000 | [diff] [blame] | 227 | check_errata_cve_2017_5715, \ |
Dimitris Papastamos | ba51d9e | 2018-05-16 11:36:14 +0100 | [diff] [blame] | 228 | CPU_NO_EXTRA2_FUNC, \ |
David Wang | 805c2c7 | 2016-11-09 16:29:02 +0000 | [diff] [blame] | 229 | cortex_a75_core_pwr_dwn |