Yatharth Kochar | 63af687 | 2016-02-09 12:00:03 +0000 | [diff] [blame] | 1 | /* |
Louis Mayencourt | 4405de6 | 2019-02-21 16:38:16 +0000 | [diff] [blame] | 2 | * Copyright (c) 2016-2019, ARM Limited and Contributors. All rights reserved. |
Yatharth Kochar | 63af687 | 2016-02-09 12:00:03 +0000 | [diff] [blame] | 3 | * |
dp-arm | fa3cf0b | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 4 | * SPDX-License-Identifier: BSD-3-Clause |
Yatharth Kochar | 63af687 | 2016-02-09 12:00:03 +0000 | [diff] [blame] | 5 | */ |
| 6 | #include <arch.h> |
| 7 | #include <asm_macros.S> |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 8 | #include <common/bl_common.h> |
Yatharth Kochar | 63af687 | 2016-02-09 12:00:03 +0000 | [diff] [blame] | 9 | #include <cortex_a73.h> |
| 10 | #include <cpu_macros.S> |
| 11 | #include <plat_macros.S> |
| 12 | |
| 13 | /* --------------------------------------------- |
| 14 | * Disable L1 data cache |
| 15 | * --------------------------------------------- |
| 16 | */ |
| 17 | func cortex_a73_disable_dcache |
| 18 | mrs x1, sctlr_el3 |
| 19 | bic x1, x1, #SCTLR_C_BIT |
| 20 | msr sctlr_el3, x1 |
| 21 | isb |
| 22 | ret |
| 23 | endfunc cortex_a73_disable_dcache |
| 24 | |
| 25 | /* --------------------------------------------- |
| 26 | * Disable intra-cluster coherency |
| 27 | * --------------------------------------------- |
| 28 | */ |
| 29 | func cortex_a73_disable_smp |
| 30 | mrs x0, CORTEX_A73_CPUECTLR_EL1 |
| 31 | bic x0, x0, #CORTEX_A73_CPUECTLR_SMP_BIT |
| 32 | msr CORTEX_A73_CPUECTLR_EL1, x0 |
| 33 | isb |
| 34 | dsb sy |
| 35 | ret |
| 36 | endfunc cortex_a73_disable_smp |
| 37 | |
Louis Mayencourt | 4405de6 | 2019-02-21 16:38:16 +0000 | [diff] [blame] | 38 | /* --------------------------------------------------- |
Louis Mayencourt | d69722c | 2019-02-27 14:24:16 +0000 | [diff] [blame] | 39 | * Errata Workaround for Cortex A73 Errata #852427. |
| 40 | * This applies only to revision r0p0 of Cortex A73. |
| 41 | * Inputs: |
| 42 | * x0: variant[4:7] and revision[0:3] of current cpu. |
| 43 | * Shall clobber: x0-x17 |
| 44 | * --------------------------------------------------- |
| 45 | */ |
| 46 | func errata_a73_852427_wa |
| 47 | /* |
| 48 | * Compare x0 against revision r0p0 |
| 49 | */ |
| 50 | mov x17, x30 |
| 51 | bl check_errata_852427 |
| 52 | cbz x0, 1f |
| 53 | mrs x1, CORTEX_A73_DIAGNOSTIC_REGISTER |
| 54 | orr x1, x1, #(1 << 12) |
| 55 | msr CORTEX_A73_DIAGNOSTIC_REGISTER, x1 |
| 56 | isb |
| 57 | 1: |
| 58 | ret x17 |
| 59 | endfunc errata_a73_852427_wa |
| 60 | |
| 61 | func check_errata_852427 |
| 62 | mov x1, #0x00 |
| 63 | b cpu_rev_var_ls |
| 64 | endfunc check_errata_852427 |
| 65 | |
| 66 | /* --------------------------------------------------- |
Louis Mayencourt | 4405de6 | 2019-02-21 16:38:16 +0000 | [diff] [blame] | 67 | * Errata Workaround for Cortex A73 Errata #855423. |
| 68 | * This applies only to revision <= r0p1 of Cortex A73. |
| 69 | * Inputs: |
| 70 | * x0: variant[4:7] and revision[0:3] of current cpu. |
| 71 | * Shall clobber: x0-x17 |
| 72 | * --------------------------------------------------- |
| 73 | */ |
| 74 | func errata_a73_855423_wa |
| 75 | /* |
| 76 | * Compare x0 against revision r0p1 |
| 77 | */ |
| 78 | mov x17, x30 |
| 79 | bl check_errata_855423 |
| 80 | cbz x0, 1f |
| 81 | mrs x1, CORTEX_A73_IMP_DEF_REG2 |
| 82 | orr x1, x1, #(1 << 7) |
| 83 | msr CORTEX_A73_IMP_DEF_REG2, x1 |
| 84 | isb |
| 85 | 1: |
| 86 | ret x17 |
| 87 | endfunc errata_a73_855423_wa |
| 88 | |
| 89 | func check_errata_855423 |
| 90 | mov x1, #0x01 |
| 91 | b cpu_rev_var_ls |
| 92 | endfunc check_errata_855423 |
| 93 | |
| 94 | /* ------------------------------------------------- |
| 95 | * The CPU Ops reset function for Cortex-A73. |
| 96 | * ------------------------------------------------- |
| 97 | */ |
| 98 | |
Yatharth Kochar | 63af687 | 2016-02-09 12:00:03 +0000 | [diff] [blame] | 99 | func cortex_a73_reset_func |
Louis Mayencourt | 4405de6 | 2019-02-21 16:38:16 +0000 | [diff] [blame] | 100 | mov x19, x30 |
| 101 | bl cpu_get_rev_var |
Louis Mayencourt | d69722c | 2019-02-27 14:24:16 +0000 | [diff] [blame] | 102 | mov x18, x0 |
| 103 | |
| 104 | #if ERRATA_A73_852427 |
| 105 | mov x0, x18 |
| 106 | bl errata_a73_852427_wa |
| 107 | #endif |
Louis Mayencourt | 4405de6 | 2019-02-21 16:38:16 +0000 | [diff] [blame] | 108 | |
| 109 | #if ERRATA_A73_855423 |
Louis Mayencourt | d69722c | 2019-02-27 14:24:16 +0000 | [diff] [blame] | 110 | mov x0, x18 |
Louis Mayencourt | 4405de6 | 2019-02-21 16:38:16 +0000 | [diff] [blame] | 111 | bl errata_a73_855423_wa |
| 112 | #endif |
| 113 | |
Dimitris Papastamos | c52ebdc | 2017-12-18 13:46:21 +0000 | [diff] [blame] | 114 | #if IMAGE_BL31 && WORKAROUND_CVE_2017_5715 |
Dimitris Papastamos | 780cc95 | 2018-03-12 13:27:02 +0000 | [diff] [blame] | 115 | cpu_check_csv2 x0, 1f |
Dimitris Papastamos | 570c06a | 2018-04-06 15:29:34 +0100 | [diff] [blame] | 116 | adr x0, wa_cve_2017_5715_bpiall_vbar |
Dimitris Papastamos | c52ebdc | 2017-12-18 13:46:21 +0000 | [diff] [blame] | 117 | msr vbar_el3, x0 |
Dimitris Papastamos | bb0aa39 | 2018-06-07 13:20:19 +0100 | [diff] [blame] | 118 | /* isb will be performed before returning from this function */ |
Dimitris Papastamos | 780cc95 | 2018-03-12 13:27:02 +0000 | [diff] [blame] | 119 | 1: |
Dimitris Papastamos | c52ebdc | 2017-12-18 13:46:21 +0000 | [diff] [blame] | 120 | #endif |
| 121 | |
Dimitris Papastamos | e6625ec | 2018-04-05 14:38:26 +0100 | [diff] [blame] | 122 | #if WORKAROUND_CVE_2018_3639 |
| 123 | mrs x0, CORTEX_A73_IMP_DEF_REG1 |
| 124 | orr x0, x0, #CORTEX_A73_IMP_DEF_REG1_DISABLE_LOAD_PASS_STORE |
| 125 | msr CORTEX_A73_IMP_DEF_REG1, x0 |
| 126 | isb |
| 127 | #endif |
| 128 | |
Yatharth Kochar | 63af687 | 2016-02-09 12:00:03 +0000 | [diff] [blame] | 129 | /* --------------------------------------------- |
| 130 | * Enable the SMP bit. |
| 131 | * Clobbers : x0 |
| 132 | * --------------------------------------------- |
| 133 | */ |
| 134 | mrs x0, CORTEX_A73_CPUECTLR_EL1 |
| 135 | orr x0, x0, #CORTEX_A73_CPUECTLR_SMP_BIT |
| 136 | msr CORTEX_A73_CPUECTLR_EL1, x0 |
| 137 | isb |
Louis Mayencourt | 4405de6 | 2019-02-21 16:38:16 +0000 | [diff] [blame] | 138 | ret x19 |
Yatharth Kochar | 63af687 | 2016-02-09 12:00:03 +0000 | [diff] [blame] | 139 | endfunc cortex_a73_reset_func |
| 140 | |
| 141 | func cortex_a73_core_pwr_dwn |
| 142 | mov x18, x30 |
| 143 | |
| 144 | /* --------------------------------------------- |
| 145 | * Turn off caches. |
| 146 | * --------------------------------------------- |
| 147 | */ |
| 148 | bl cortex_a73_disable_dcache |
| 149 | |
| 150 | /* --------------------------------------------- |
| 151 | * Flush L1 caches. |
| 152 | * --------------------------------------------- |
| 153 | */ |
| 154 | mov x0, #DCCISW |
| 155 | bl dcsw_op_level1 |
| 156 | |
| 157 | /* --------------------------------------------- |
| 158 | * Come out of intra cluster coherency |
| 159 | * --------------------------------------------- |
| 160 | */ |
| 161 | mov x30, x18 |
| 162 | b cortex_a73_disable_smp |
| 163 | endfunc cortex_a73_core_pwr_dwn |
| 164 | |
| 165 | func cortex_a73_cluster_pwr_dwn |
| 166 | mov x18, x30 |
| 167 | |
| 168 | /* --------------------------------------------- |
| 169 | * Turn off caches. |
| 170 | * --------------------------------------------- |
| 171 | */ |
| 172 | bl cortex_a73_disable_dcache |
| 173 | |
| 174 | /* --------------------------------------------- |
| 175 | * Flush L1 caches. |
| 176 | * --------------------------------------------- |
| 177 | */ |
| 178 | mov x0, #DCCISW |
| 179 | bl dcsw_op_level1 |
| 180 | |
| 181 | /* --------------------------------------------- |
| 182 | * Disable the optional ACP. |
| 183 | * --------------------------------------------- |
| 184 | */ |
| 185 | bl plat_disable_acp |
| 186 | |
| 187 | /* --------------------------------------------- |
| 188 | * Flush L2 caches. |
| 189 | * --------------------------------------------- |
| 190 | */ |
| 191 | mov x0, #DCCISW |
| 192 | bl dcsw_op_level2 |
| 193 | |
| 194 | /* --------------------------------------------- |
| 195 | * Come out of intra cluster coherency |
| 196 | * --------------------------------------------- |
| 197 | */ |
| 198 | mov x30, x18 |
| 199 | b cortex_a73_disable_smp |
| 200 | endfunc cortex_a73_cluster_pwr_dwn |
| 201 | |
Dimitris Papastamos | 858bd61 | 2018-01-16 10:32:47 +0000 | [diff] [blame] | 202 | func check_errata_cve_2017_5715 |
Dimitris Papastamos | 780cc95 | 2018-03-12 13:27:02 +0000 | [diff] [blame] | 203 | cpu_check_csv2 x0, 1f |
Dimitris Papastamos | 858bd61 | 2018-01-16 10:32:47 +0000 | [diff] [blame] | 204 | #if WORKAROUND_CVE_2017_5715 |
| 205 | mov x0, #ERRATA_APPLIES |
| 206 | #else |
| 207 | mov x0, #ERRATA_MISSING |
| 208 | #endif |
| 209 | ret |
Dimitris Papastamos | 780cc95 | 2018-03-12 13:27:02 +0000 | [diff] [blame] | 210 | 1: |
| 211 | mov x0, #ERRATA_NOT_APPLIES |
| 212 | ret |
Dimitris Papastamos | 858bd61 | 2018-01-16 10:32:47 +0000 | [diff] [blame] | 213 | endfunc check_errata_cve_2017_5715 |
| 214 | |
Dimitris Papastamos | e6625ec | 2018-04-05 14:38:26 +0100 | [diff] [blame] | 215 | func check_errata_cve_2018_3639 |
| 216 | #if WORKAROUND_CVE_2018_3639 |
| 217 | mov x0, #ERRATA_APPLIES |
| 218 | #else |
| 219 | mov x0, #ERRATA_MISSING |
| 220 | #endif |
| 221 | ret |
| 222 | endfunc check_errata_cve_2018_3639 |
| 223 | |
Dimitris Papastamos | 858bd61 | 2018-01-16 10:32:47 +0000 | [diff] [blame] | 224 | #if REPORT_ERRATA |
| 225 | /* |
| 226 | * Errata printing function for Cortex A75. Must follow AAPCS. |
| 227 | */ |
| 228 | func cortex_a73_errata_report |
| 229 | stp x8, x30, [sp, #-16]! |
| 230 | |
| 231 | bl cpu_get_rev_var |
| 232 | mov x8, x0 |
| 233 | |
| 234 | /* |
| 235 | * Report all errata. The revision-variant information is passed to |
| 236 | * checking functions of each errata. |
| 237 | */ |
Louis Mayencourt | d69722c | 2019-02-27 14:24:16 +0000 | [diff] [blame] | 238 | report_errata ERRATA_A73_852427, cortex_a73, 852427 |
Louis Mayencourt | 4405de6 | 2019-02-21 16:38:16 +0000 | [diff] [blame] | 239 | report_errata ERRATA_A73_855423, cortex_a73, 855423 |
Dimitris Papastamos | 858bd61 | 2018-01-16 10:32:47 +0000 | [diff] [blame] | 240 | report_errata WORKAROUND_CVE_2017_5715, cortex_a73, cve_2017_5715 |
Dimitris Papastamos | e6625ec | 2018-04-05 14:38:26 +0100 | [diff] [blame] | 241 | report_errata WORKAROUND_CVE_2018_3639, cortex_a73, cve_2018_3639 |
Dimitris Papastamos | 858bd61 | 2018-01-16 10:32:47 +0000 | [diff] [blame] | 242 | |
| 243 | ldp x8, x30, [sp], #16 |
| 244 | ret |
| 245 | endfunc cortex_a73_errata_report |
| 246 | #endif |
| 247 | |
Yatharth Kochar | 63af687 | 2016-02-09 12:00:03 +0000 | [diff] [blame] | 248 | /* --------------------------------------------- |
| 249 | * This function provides cortex_a73 specific |
| 250 | * register information for crash reporting. |
| 251 | * It needs to return with x6 pointing to |
| 252 | * a list of register names in ascii and |
| 253 | * x8 - x15 having values of registers to be |
| 254 | * reported. |
| 255 | * --------------------------------------------- |
| 256 | */ |
| 257 | .section .rodata.cortex_a73_regs, "aS" |
| 258 | cortex_a73_regs: /* The ascii list of register names to be reported */ |
Naga Sureshkumar Relli | 6a72a91 | 2016-07-01 12:52:41 +0530 | [diff] [blame] | 259 | .asciz "cpuectlr_el1", "l2merrsr_el1", "" |
Yatharth Kochar | 63af687 | 2016-02-09 12:00:03 +0000 | [diff] [blame] | 260 | |
| 261 | func cortex_a73_cpu_reg_dump |
| 262 | adr x6, cortex_a73_regs |
| 263 | mrs x8, CORTEX_A73_CPUECTLR_EL1 |
Naga Sureshkumar Relli | 6a72a91 | 2016-07-01 12:52:41 +0530 | [diff] [blame] | 264 | mrs x9, CORTEX_A73_L2MERRSR_EL1 |
Yatharth Kochar | 63af687 | 2016-02-09 12:00:03 +0000 | [diff] [blame] | 265 | ret |
| 266 | endfunc cortex_a73_cpu_reg_dump |
| 267 | |
Dimitris Papastamos | ba51d9e | 2018-05-16 11:36:14 +0100 | [diff] [blame] | 268 | declare_cpu_ops_wa cortex_a73, CORTEX_A73_MIDR, \ |
Jeenu Viswambharan | ee5eb80 | 2016-11-18 12:58:28 +0000 | [diff] [blame] | 269 | cortex_a73_reset_func, \ |
Dimitris Papastamos | 914757c | 2018-03-12 14:47:09 +0000 | [diff] [blame] | 270 | check_errata_cve_2017_5715, \ |
Dimitris Papastamos | ba51d9e | 2018-05-16 11:36:14 +0100 | [diff] [blame] | 271 | CPU_NO_EXTRA2_FUNC, \ |
Jeenu Viswambharan | ee5eb80 | 2016-11-18 12:58:28 +0000 | [diff] [blame] | 272 | cortex_a73_core_pwr_dwn, \ |
| 273 | cortex_a73_cluster_pwr_dwn |