Soby Mathew | c704cbc | 2014-08-14 11:33:56 +0100 | [diff] [blame] | 1 | /* |
Varun Wadekar | 4d034c5 | 2019-01-11 14:47:48 -0800 | [diff] [blame] | 2 | * Copyright (c) 2014-2019, ARM Limited and Contributors. All rights reserved. |
Soby Mathew | c704cbc | 2014-08-14 11:33:56 +0100 | [diff] [blame] | 3 | * |
dp-arm | fa3cf0b | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 4 | * SPDX-License-Identifier: BSD-3-Clause |
Soby Mathew | c704cbc | 2014-08-14 11:33:56 +0100 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <arch.h> |
| 8 | #include <asm_macros.S> |
| 9 | #include <assert_macros.S> |
Varun Wadekar | 4d034c5 | 2019-01-11 14:47:48 -0800 | [diff] [blame] | 10 | #include <common/bl_common.h> |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 11 | #include <common/debug.h> |
David Cunado | 1f5f812 | 2017-01-17 14:40:15 +0000 | [diff] [blame] | 12 | #include <cpu_macros.S> |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 13 | #include <lib/cpus/errata_report.h> |
| 14 | #include <lib/el3_runtime/cpu_data.h> |
Soby Mathew | c704cbc | 2014-08-14 11:33:56 +0100 | [diff] [blame] | 15 | |
| 16 | /* Reset fn is needed in BL at reset vector */ |
Roberto Vargas | e0e9946 | 2017-10-30 14:43:43 +0000 | [diff] [blame] | 17 | #if defined(IMAGE_BL1) || defined(IMAGE_BL31) || (defined(IMAGE_BL2) && BL2_AT_EL3) |
Soby Mathew | c704cbc | 2014-08-14 11:33:56 +0100 | [diff] [blame] | 18 | /* |
| 19 | * The reset handler common to all platforms. After a matching |
| 20 | * cpu_ops structure entry is found, the correponding reset_handler |
| 21 | * in the cpu_ops is invoked. |
Soby Mathew | b5a6304 | 2015-01-29 12:00:58 +0000 | [diff] [blame] | 22 | * Clobbers: x0 - x19, x30 |
Soby Mathew | c704cbc | 2014-08-14 11:33:56 +0100 | [diff] [blame] | 23 | */ |
| 24 | .globl reset_handler |
| 25 | func reset_handler |
Soby Mathew | c088433 | 2014-09-22 12:11:36 +0100 | [diff] [blame] | 26 | mov x19, x30 |
Soby Mathew | c704cbc | 2014-08-14 11:33:56 +0100 | [diff] [blame] | 27 | |
Soby Mathew | b5a6304 | 2015-01-29 12:00:58 +0000 | [diff] [blame] | 28 | /* The plat_reset_handler can clobber x0 - x18, x30 */ |
Soby Mathew | f1785fd | 2014-08-14 12:22:32 +0100 | [diff] [blame] | 29 | bl plat_reset_handler |
| 30 | |
Soby Mathew | c704cbc | 2014-08-14 11:33:56 +0100 | [diff] [blame] | 31 | /* Get the matching cpu_ops pointer */ |
| 32 | bl get_cpu_ops_ptr |
Antonio Nino Diaz | 7c65c1e | 2017-04-20 09:58:28 +0100 | [diff] [blame] | 33 | #if ENABLE_ASSERTIONS |
Soby Mathew | c704cbc | 2014-08-14 11:33:56 +0100 | [diff] [blame] | 34 | cmp x0, #0 |
| 35 | ASM_ASSERT(ne) |
| 36 | #endif |
| 37 | |
| 38 | /* Get the cpu_ops reset handler */ |
| 39 | ldr x2, [x0, #CPU_RESET_FUNC] |
Soby Mathew | c088433 | 2014-09-22 12:11:36 +0100 | [diff] [blame] | 40 | mov x30, x19 |
Soby Mathew | c704cbc | 2014-08-14 11:33:56 +0100 | [diff] [blame] | 41 | cbz x2, 1f |
Soby Mathew | b5a6304 | 2015-01-29 12:00:58 +0000 | [diff] [blame] | 42 | |
| 43 | /* The cpu_ops reset handler can clobber x0 - x19, x30 */ |
Soby Mathew | c088433 | 2014-09-22 12:11:36 +0100 | [diff] [blame] | 44 | br x2 |
Soby Mathew | c704cbc | 2014-08-14 11:33:56 +0100 | [diff] [blame] | 45 | 1: |
Soby Mathew | c088433 | 2014-09-22 12:11:36 +0100 | [diff] [blame] | 46 | ret |
Kévin Petit | a877c25 | 2015-03-24 14:03:57 +0000 | [diff] [blame] | 47 | endfunc reset_handler |
Soby Mathew | f1785fd | 2014-08-14 12:22:32 +0100 | [diff] [blame] | 48 | |
Roberto Vargas | e0e9946 | 2017-10-30 14:43:43 +0000 | [diff] [blame] | 49 | #endif |
Soby Mathew | c704cbc | 2014-08-14 11:33:56 +0100 | [diff] [blame] | 50 | |
Masahiro Yamada | 441bfdd | 2016-12-25 23:36:24 +0900 | [diff] [blame] | 51 | #ifdef IMAGE_BL31 /* The power down core and cluster is needed only in BL31 */ |
Soby Mathew | 8e2f287 | 2014-08-14 12:49:05 +0100 | [diff] [blame] | 52 | /* |
Jeenu Viswambharan | ee5eb80 | 2016-11-18 12:58:28 +0000 | [diff] [blame] | 53 | * void prepare_cpu_pwr_dwn(unsigned int power_level) |
| 54 | * |
| 55 | * Prepare CPU power down function for all platforms. The function takes |
| 56 | * a domain level to be powered down as its parameter. After the cpu_ops |
| 57 | * pointer is retrieved from cpu_data, the handler for requested power |
| 58 | * level is called. |
Soby Mathew | 8e2f287 | 2014-08-14 12:49:05 +0100 | [diff] [blame] | 59 | */ |
Jeenu Viswambharan | ee5eb80 | 2016-11-18 12:58:28 +0000 | [diff] [blame] | 60 | .globl prepare_cpu_pwr_dwn |
| 61 | func prepare_cpu_pwr_dwn |
Soby Mathew | 8e2f287 | 2014-08-14 12:49:05 +0100 | [diff] [blame] | 62 | /* |
Jeenu Viswambharan | ee5eb80 | 2016-11-18 12:58:28 +0000 | [diff] [blame] | 63 | * If the given power level exceeds CPU_MAX_PWR_DWN_OPS, we call the |
| 64 | * power down handler for the last power level |
Soby Mathew | 8e2f287 | 2014-08-14 12:49:05 +0100 | [diff] [blame] | 65 | */ |
Jeenu Viswambharan | ee5eb80 | 2016-11-18 12:58:28 +0000 | [diff] [blame] | 66 | mov_imm x2, (CPU_MAX_PWR_DWN_OPS - 1) |
| 67 | cmp x0, x2 |
| 68 | csel x2, x2, x0, hi |
| 69 | |
Soby Mathew | 8e2f287 | 2014-08-14 12:49:05 +0100 | [diff] [blame] | 70 | mrs x1, tpidr_el3 |
| 71 | ldr x0, [x1, #CPU_DATA_CPU_OPS_PTR] |
Antonio Nino Diaz | 7c65c1e | 2017-04-20 09:58:28 +0100 | [diff] [blame] | 72 | #if ENABLE_ASSERTIONS |
Soby Mathew | 8e2f287 | 2014-08-14 12:49:05 +0100 | [diff] [blame] | 73 | cmp x0, #0 |
| 74 | ASM_ASSERT(ne) |
| 75 | #endif |
| 76 | |
Jeenu Viswambharan | ee5eb80 | 2016-11-18 12:58:28 +0000 | [diff] [blame] | 77 | /* Get the appropriate power down handler */ |
| 78 | mov x1, #CPU_PWR_DWN_OPS |
| 79 | add x1, x1, x2, lsl #3 |
| 80 | ldr x1, [x0, x1] |
Varun Wadekar | 718c876 | 2019-10-01 09:34:10 -0700 | [diff] [blame] | 81 | #if ENABLE_ASSERTIONS |
| 82 | cmp x1, #0 |
| 83 | ASM_ASSERT(ne) |
| 84 | #endif |
Soby Mathew | 8e2f287 | 2014-08-14 12:49:05 +0100 | [diff] [blame] | 85 | br x1 |
Jeenu Viswambharan | ee5eb80 | 2016-11-18 12:58:28 +0000 | [diff] [blame] | 86 | endfunc prepare_cpu_pwr_dwn |
Soby Mathew | 8e2f287 | 2014-08-14 12:49:05 +0100 | [diff] [blame] | 87 | |
| 88 | |
| 89 | /* |
| 90 | * Initializes the cpu_ops_ptr if not already initialized |
Vikram Kanigiri | 9b38fc8 | 2015-01-29 18:27:38 +0000 | [diff] [blame] | 91 | * in cpu_data. This can be called without a runtime stack, but may |
| 92 | * only be called after the MMU is enabled. |
Soby Mathew | 8e2f287 | 2014-08-14 12:49:05 +0100 | [diff] [blame] | 93 | * clobbers: x0 - x6, x10 |
| 94 | */ |
| 95 | .globl init_cpu_ops |
| 96 | func init_cpu_ops |
| 97 | mrs x6, tpidr_el3 |
| 98 | ldr x0, [x6, #CPU_DATA_CPU_OPS_PTR] |
| 99 | cbnz x0, 1f |
| 100 | mov x10, x30 |
| 101 | bl get_cpu_ops_ptr |
Antonio Nino Diaz | 7c65c1e | 2017-04-20 09:58:28 +0100 | [diff] [blame] | 102 | #if ENABLE_ASSERTIONS |
Soby Mathew | 8e2f287 | 2014-08-14 12:49:05 +0100 | [diff] [blame] | 103 | cmp x0, #0 |
| 104 | ASM_ASSERT(ne) |
| 105 | #endif |
Soby Mathew | 7d861ea | 2014-11-18 10:14:14 +0000 | [diff] [blame] | 106 | str x0, [x6, #CPU_DATA_CPU_OPS_PTR]! |
Soby Mathew | 8e2f287 | 2014-08-14 12:49:05 +0100 | [diff] [blame] | 107 | mov x30, x10 |
| 108 | 1: |
| 109 | ret |
Kévin Petit | a877c25 | 2015-03-24 14:03:57 +0000 | [diff] [blame] | 110 | endfunc init_cpu_ops |
Soby Mathew | 8e2f287 | 2014-08-14 12:49:05 +0100 | [diff] [blame] | 111 | #endif /* IMAGE_BL31 */ |
| 112 | |
Masahiro Yamada | 441bfdd | 2016-12-25 23:36:24 +0900 | [diff] [blame] | 113 | #if defined(IMAGE_BL31) && CRASH_REPORTING |
Soby Mathew | 38b4bc9 | 2014-08-14 13:36:41 +0100 | [diff] [blame] | 114 | /* |
| 115 | * The cpu specific registers which need to be reported in a crash |
| 116 | * are reported via cpu_ops cpu_reg_dump function. After a matching |
| 117 | * cpu_ops structure entry is found, the correponding cpu_reg_dump |
| 118 | * in the cpu_ops is invoked. |
| 119 | */ |
| 120 | .globl do_cpu_reg_dump |
| 121 | func do_cpu_reg_dump |
| 122 | mov x16, x30 |
| 123 | |
| 124 | /* Get the matching cpu_ops pointer */ |
| 125 | bl get_cpu_ops_ptr |
| 126 | cbz x0, 1f |
| 127 | |
| 128 | /* Get the cpu_ops cpu_reg_dump */ |
| 129 | ldr x2, [x0, #CPU_REG_DUMP] |
| 130 | cbz x2, 1f |
| 131 | blr x2 |
| 132 | 1: |
| 133 | mov x30, x16 |
| 134 | ret |
Kévin Petit | a877c25 | 2015-03-24 14:03:57 +0000 | [diff] [blame] | 135 | endfunc do_cpu_reg_dump |
Soby Mathew | 38b4bc9 | 2014-08-14 13:36:41 +0100 | [diff] [blame] | 136 | #endif |
| 137 | |
Soby Mathew | c704cbc | 2014-08-14 11:33:56 +0100 | [diff] [blame] | 138 | /* |
| 139 | * The below function returns the cpu_ops structure matching the |
| 140 | * midr of the core. It reads the MIDR_EL1 and finds the matching |
| 141 | * entry in cpu_ops entries. Only the implementation and part number |
| 142 | * are used to match the entries. |
| 143 | * Return : |
| 144 | * x0 - The matching cpu_ops pointer on Success |
| 145 | * x0 - 0 on failure. |
| 146 | * Clobbers : x0 - x5 |
| 147 | */ |
| 148 | .globl get_cpu_ops_ptr |
| 149 | func get_cpu_ops_ptr |
| 150 | /* Get the cpu_ops start and end locations */ |
| 151 | adr x4, (__CPU_OPS_START__ + CPU_MIDR) |
| 152 | adr x5, (__CPU_OPS_END__ + CPU_MIDR) |
| 153 | |
| 154 | /* Initialize the return parameter */ |
| 155 | mov x0, #0 |
| 156 | |
| 157 | /* Read the MIDR_EL1 */ |
| 158 | mrs x2, midr_el1 |
| 159 | mov_imm x3, CPU_IMPL_PN_MASK |
| 160 | |
| 161 | /* Retain only the implementation and part number using mask */ |
| 162 | and w2, w2, w3 |
| 163 | 1: |
| 164 | /* Check if we have reached end of list */ |
| 165 | cmp x4, x5 |
| 166 | b.eq error_exit |
| 167 | |
| 168 | /* load the midr from the cpu_ops */ |
| 169 | ldr x1, [x4], #CPU_OPS_SIZE |
| 170 | and w1, w1, w3 |
| 171 | |
| 172 | /* Check if midr matches to midr of this core */ |
| 173 | cmp w1, w2 |
| 174 | b.ne 1b |
| 175 | |
| 176 | /* Subtract the increment and offset to get the cpu-ops pointer */ |
| 177 | sub x0, x4, #(CPU_OPS_SIZE + CPU_MIDR) |
Varun Wadekar | 718c876 | 2019-10-01 09:34:10 -0700 | [diff] [blame] | 178 | #if ENABLE_ASSERTIONS |
| 179 | cmp x0, #0 |
| 180 | ASM_ASSERT(ne) |
| 181 | #endif |
Soby Mathew | c704cbc | 2014-08-14 11:33:56 +0100 | [diff] [blame] | 182 | error_exit: |
| 183 | ret |
Kévin Petit | a877c25 | 2015-03-24 14:03:57 +0000 | [diff] [blame] | 184 | endfunc get_cpu_ops_ptr |
Soby Mathew | c088433 | 2014-09-22 12:11:36 +0100 | [diff] [blame] | 185 | |
Jeenu Viswambharan | d5ec367 | 2017-01-03 11:01:51 +0000 | [diff] [blame] | 186 | /* |
| 187 | * Extract CPU revision and variant, and combine them into a single numeric for |
| 188 | * easier comparison. |
| 189 | */ |
| 190 | .globl cpu_get_rev_var |
| 191 | func cpu_get_rev_var |
| 192 | mrs x1, midr_el1 |
Soby Mathew | c088433 | 2014-09-22 12:11:36 +0100 | [diff] [blame] | 193 | |
Sandrine Bailleux | d481759 | 2016-01-13 14:57:38 +0000 | [diff] [blame] | 194 | /* |
Jeenu Viswambharan | d5ec367 | 2017-01-03 11:01:51 +0000 | [diff] [blame] | 195 | * Extract the variant[23:20] and revision[3:0] from MIDR, and pack them |
| 196 | * as variant[7:4] and revision[3:0] of x0. |
Sandrine Bailleux | d481759 | 2016-01-13 14:57:38 +0000 | [diff] [blame] | 197 | * |
Jeenu Viswambharan | d5ec367 | 2017-01-03 11:01:51 +0000 | [diff] [blame] | 198 | * First extract x1[23:16] to x0[7:0] and zero fill the rest. Then |
| 199 | * extract x1[3:0] into x0[3:0] retaining other bits. |
Sandrine Bailleux | d481759 | 2016-01-13 14:57:38 +0000 | [diff] [blame] | 200 | */ |
Jeenu Viswambharan | d5ec367 | 2017-01-03 11:01:51 +0000 | [diff] [blame] | 201 | ubfx x0, x1, #(MIDR_VAR_SHIFT - MIDR_REV_BITS), #(MIDR_REV_BITS + MIDR_VAR_BITS) |
| 202 | bfxil x0, x1, #MIDR_REV_SHIFT, #MIDR_REV_BITS |
| 203 | ret |
| 204 | endfunc cpu_get_rev_var |
| 205 | |
| 206 | /* |
| 207 | * Compare the CPU's revision-variant (x0) with a given value (x1), for errata |
| 208 | * application purposes. If the revision-variant is less than or same as a given |
| 209 | * value, indicates that errata applies; otherwise not. |
Jonathan Wright | efb1f33 | 2018-03-28 15:52:03 +0100 | [diff] [blame] | 210 | * |
| 211 | * Shall clobber: x0-x3 |
Jeenu Viswambharan | d5ec367 | 2017-01-03 11:01:51 +0000 | [diff] [blame] | 212 | */ |
| 213 | .globl cpu_rev_var_ls |
| 214 | func cpu_rev_var_ls |
| 215 | mov x2, #ERRATA_APPLIES |
| 216 | mov x3, #ERRATA_NOT_APPLIES |
| 217 | cmp x0, x1 |
| 218 | csel x0, x2, x3, ls |
| 219 | ret |
| 220 | endfunc cpu_rev_var_ls |
| 221 | |
Andre Przywara | 00eefd9 | 2016-10-06 16:54:53 +0100 | [diff] [blame] | 222 | /* |
| 223 | * Compare the CPU's revision-variant (x0) with a given value (x1), for errata |
| 224 | * application purposes. If the revision-variant is higher than or same as a |
| 225 | * given value, indicates that errata applies; otherwise not. |
Jonathan Wright | efb1f33 | 2018-03-28 15:52:03 +0100 | [diff] [blame] | 226 | * |
| 227 | * Shall clobber: x0-x3 |
Andre Przywara | 00eefd9 | 2016-10-06 16:54:53 +0100 | [diff] [blame] | 228 | */ |
| 229 | .globl cpu_rev_var_hs |
| 230 | func cpu_rev_var_hs |
| 231 | mov x2, #ERRATA_APPLIES |
| 232 | mov x3, #ERRATA_NOT_APPLIES |
| 233 | cmp x0, x1 |
| 234 | csel x0, x2, x3, hs |
| 235 | ret |
| 236 | endfunc cpu_rev_var_hs |
| 237 | |
laurenw-arm | 94accd3 | 2019-08-20 15:51:24 -0500 | [diff] [blame] | 238 | /* |
| 239 | * Compare the CPU's revision-variant (x0) with a given range (x1 - x2), for errata |
| 240 | * application purposes. If the revision-variant is between or includes the given |
| 241 | * values, this indicates that errata applies; otherwise not. |
| 242 | * |
| 243 | * Shall clobber: x0-x4 |
| 244 | */ |
| 245 | .globl cpu_rev_var_range |
| 246 | func cpu_rev_var_range |
| 247 | mov x3, #ERRATA_APPLIES |
| 248 | mov x4, #ERRATA_NOT_APPLIES |
| 249 | cmp x0, x1 |
| 250 | csel x1, x3, x4, hs |
| 251 | cbz x1, 1f |
| 252 | cmp x0, x2 |
| 253 | csel x1, x3, x4, ls |
| 254 | 1: |
| 255 | mov x0, x1 |
| 256 | ret |
| 257 | endfunc cpu_rev_var_range |
| 258 | |
Jeenu Viswambharan | d5ec367 | 2017-01-03 11:01:51 +0000 | [diff] [blame] | 259 | #if REPORT_ERRATA |
| 260 | /* |
| 261 | * void print_errata_status(void); |
| 262 | * |
| 263 | * Function to print errata status for CPUs of its class. Must be called only: |
| 264 | * |
| 265 | * - with MMU and data caches are enabled; |
| 266 | * - after cpu_ops have been initialized in per-CPU data. |
| 267 | */ |
| 268 | .globl print_errata_status |
| 269 | func print_errata_status |
| 270 | #ifdef IMAGE_BL1 |
| 271 | /* |
| 272 | * BL1 doesn't have per-CPU data. So retrieve the CPU operations |
| 273 | * directly. |
| 274 | */ |
| 275 | stp xzr, x30, [sp, #-16]! |
| 276 | bl get_cpu_ops_ptr |
| 277 | ldp xzr, x30, [sp], #16 |
| 278 | ldr x1, [x0, #CPU_ERRATA_FUNC] |
| 279 | cbnz x1, .Lprint |
| 280 | #else |
| 281 | /* |
| 282 | * Retrieve pointer to cpu_ops from per-CPU data, and further, the |
| 283 | * errata printing function. If it's non-NULL, jump to the function in |
| 284 | * turn. |
| 285 | */ |
| 286 | mrs x0, tpidr_el3 |
Varun Wadekar | 718c876 | 2019-10-01 09:34:10 -0700 | [diff] [blame] | 287 | #if ENABLE_ASSERTIONS |
| 288 | cmp x0, #0 |
| 289 | ASM_ASSERT(ne) |
| 290 | #endif |
Jeenu Viswambharan | d5ec367 | 2017-01-03 11:01:51 +0000 | [diff] [blame] | 291 | ldr x1, [x0, #CPU_DATA_CPU_OPS_PTR] |
Varun Wadekar | 718c876 | 2019-10-01 09:34:10 -0700 | [diff] [blame] | 292 | #if ENABLE_ASSERTIONS |
| 293 | cmp x1, #0 |
| 294 | ASM_ASSERT(ne) |
| 295 | #endif |
Jeenu Viswambharan | d5ec367 | 2017-01-03 11:01:51 +0000 | [diff] [blame] | 296 | ldr x0, [x1, #CPU_ERRATA_FUNC] |
| 297 | cbz x0, .Lnoprint |
| 298 | |
| 299 | /* |
| 300 | * Printing errata status requires atomically testing the printed flag. |
| 301 | */ |
dp-arm | 815faa8 | 2017-05-05 12:21:03 +0100 | [diff] [blame] | 302 | stp x19, x30, [sp, #-16]! |
| 303 | mov x19, x0 |
Soby Mathew | c088433 | 2014-09-22 12:11:36 +0100 | [diff] [blame] | 304 | |
Jeenu Viswambharan | d5ec367 | 2017-01-03 11:01:51 +0000 | [diff] [blame] | 305 | /* |
| 306 | * Load pointers to errata lock and printed flag. Call |
| 307 | * errata_needs_reporting to check whether this CPU needs to report |
| 308 | * errata status pertaining to its class. |
| 309 | */ |
| 310 | ldr x0, [x1, #CPU_ERRATA_LOCK] |
| 311 | ldr x1, [x1, #CPU_ERRATA_PRINTED] |
| 312 | bl errata_needs_reporting |
dp-arm | 815faa8 | 2017-05-05 12:21:03 +0100 | [diff] [blame] | 313 | mov x1, x19 |
| 314 | ldp x19, x30, [sp], #16 |
Jeenu Viswambharan | d5ec367 | 2017-01-03 11:01:51 +0000 | [diff] [blame] | 315 | cbnz x0, .Lprint |
| 316 | #endif |
| 317 | .Lnoprint: |
| 318 | ret |
| 319 | .Lprint: |
| 320 | /* Jump to errata reporting function for this CPU */ |
| 321 | br x1 |
| 322 | endfunc print_errata_status |
| 323 | #endif |
Dimitris Papastamos | 914757c | 2018-03-12 14:47:09 +0000 | [diff] [blame] | 324 | |
| 325 | /* |
Dimitris Papastamos | 570c06a | 2018-04-06 15:29:34 +0100 | [diff] [blame] | 326 | * int check_wa_cve_2017_5715(void); |
Dimitris Papastamos | 914757c | 2018-03-12 14:47:09 +0000 | [diff] [blame] | 327 | * |
| 328 | * This function returns: |
| 329 | * - ERRATA_APPLIES when firmware mitigation is required. |
| 330 | * - ERRATA_NOT_APPLIES when firmware mitigation is _not_ required. |
| 331 | * - ERRATA_MISSING when firmware mitigation would be required but |
| 332 | * is not compiled in. |
| 333 | * |
| 334 | * NOTE: Must be called only after cpu_ops have been initialized |
| 335 | * in per-CPU data. |
| 336 | */ |
Dimitris Papastamos | 570c06a | 2018-04-06 15:29:34 +0100 | [diff] [blame] | 337 | .globl check_wa_cve_2017_5715 |
| 338 | func check_wa_cve_2017_5715 |
Dimitris Papastamos | 914757c | 2018-03-12 14:47:09 +0000 | [diff] [blame] | 339 | mrs x0, tpidr_el3 |
| 340 | #if ENABLE_ASSERTIONS |
| 341 | cmp x0, #0 |
| 342 | ASM_ASSERT(ne) |
| 343 | #endif |
| 344 | ldr x0, [x0, #CPU_DATA_CPU_OPS_PTR] |
Varun Wadekar | 718c876 | 2019-10-01 09:34:10 -0700 | [diff] [blame] | 345 | #if ENABLE_ASSERTIONS |
| 346 | cmp x0, #0 |
| 347 | ASM_ASSERT(ne) |
| 348 | #endif |
Dimitris Papastamos | 914757c | 2018-03-12 14:47:09 +0000 | [diff] [blame] | 349 | ldr x0, [x0, #CPU_EXTRA1_FUNC] |
| 350 | /* |
| 351 | * If the reserved function pointer is NULL, this CPU |
| 352 | * is unaffected by CVE-2017-5715 so bail out. |
| 353 | */ |
| 354 | cmp x0, #0 |
| 355 | beq 1f |
| 356 | br x0 |
| 357 | 1: |
| 358 | mov x0, #ERRATA_NOT_APPLIES |
| 359 | ret |
Dimitris Papastamos | 570c06a | 2018-04-06 15:29:34 +0100 | [diff] [blame] | 360 | endfunc check_wa_cve_2017_5715 |
Dimitris Papastamos | ba51d9e | 2018-05-16 11:36:14 +0100 | [diff] [blame] | 361 | |
| 362 | /* |
| 363 | * void *wa_cve_2018_3639_get_disable_ptr(void); |
| 364 | * |
| 365 | * Returns a function pointer which is used to disable mitigation |
| 366 | * for CVE-2018-3639. |
| 367 | * The function pointer is only returned on cores that employ |
| 368 | * dynamic mitigation. If the core uses static mitigation or is |
| 369 | * unaffected by CVE-2018-3639 this function returns NULL. |
| 370 | * |
| 371 | * NOTE: Must be called only after cpu_ops have been initialized |
| 372 | * in per-CPU data. |
| 373 | */ |
| 374 | .globl wa_cve_2018_3639_get_disable_ptr |
| 375 | func wa_cve_2018_3639_get_disable_ptr |
| 376 | mrs x0, tpidr_el3 |
| 377 | #if ENABLE_ASSERTIONS |
| 378 | cmp x0, #0 |
| 379 | ASM_ASSERT(ne) |
| 380 | #endif |
| 381 | ldr x0, [x0, #CPU_DATA_CPU_OPS_PTR] |
Varun Wadekar | 718c876 | 2019-10-01 09:34:10 -0700 | [diff] [blame] | 382 | #if ENABLE_ASSERTIONS |
| 383 | cmp x0, #0 |
| 384 | ASM_ASSERT(ne) |
| 385 | #endif |
Dimitris Papastamos | ba51d9e | 2018-05-16 11:36:14 +0100 | [diff] [blame] | 386 | ldr x0, [x0, #CPU_EXTRA2_FUNC] |
| 387 | ret |
| 388 | endfunc wa_cve_2018_3639_get_disable_ptr |