19b476841SSoby Mathew/* 2*2e61d687SOlivier Deprez * Copyright (c) 2014-2021, Arm Limited and Contributors. All rights reserved. 39b476841SSoby Mathew * 482cb2c1aSdp-arm * SPDX-License-Identifier: BSD-3-Clause 59b476841SSoby Mathew */ 69b476841SSoby Mathew 79b476841SSoby Mathew#include <arch.h> 89b476841SSoby Mathew#include <asm_macros.S> 99b476841SSoby Mathew#include <assert_macros.S> 10c2ad38ceSVarun Wadekar#include <common/bl_common.h> 1109d40e0eSAntonio Nino Diaz#include <common/debug.h> 1255c70cb7SDavid Cunado#include <cpu_macros.S> 1309d40e0eSAntonio Nino Diaz#include <lib/cpus/errata_report.h> 1409d40e0eSAntonio Nino Diaz#include <lib/el3_runtime/cpu_data.h> 159b476841SSoby Mathew 169b476841SSoby Mathew /* Reset fn is needed in BL at reset vector */ 17b1d27b48SRoberto Vargas#if defined(IMAGE_BL1) || defined(IMAGE_BL31) || (defined(IMAGE_BL2) && BL2_AT_EL3) 189b476841SSoby Mathew /* 199b476841SSoby Mathew * The reset handler common to all platforms. After a matching 209b476841SSoby Mathew * cpu_ops structure entry is found, the correponding reset_handler 219b476841SSoby Mathew * in the cpu_ops is invoked. 22683f788fSSoby Mathew * Clobbers: x0 - x19, x30 239b476841SSoby Mathew */ 249b476841SSoby Mathew .globl reset_handler 259b476841SSoby Mathewfunc reset_handler 267395a725SSoby Mathew mov x19, x30 279b476841SSoby Mathew 28683f788fSSoby Mathew /* The plat_reset_handler can clobber x0 - x18, x30 */ 2924fb838fSSoby Mathew bl plat_reset_handler 3024fb838fSSoby Mathew 319b476841SSoby Mathew /* Get the matching cpu_ops pointer */ 329b476841SSoby Mathew bl get_cpu_ops_ptr 33044bb2faSAntonio Nino Diaz#if ENABLE_ASSERTIONS 349b476841SSoby Mathew cmp x0, #0 359b476841SSoby Mathew ASM_ASSERT(ne) 369b476841SSoby Mathew#endif 379b476841SSoby Mathew 389b476841SSoby Mathew /* Get the cpu_ops reset handler */ 399b476841SSoby Mathew ldr x2, [x0, #CPU_RESET_FUNC] 407395a725SSoby Mathew mov x30, x19 419b476841SSoby Mathew cbz x2, 1f 42683f788fSSoby Mathew 43683f788fSSoby Mathew /* The cpu_ops reset handler can clobber x0 - x19, x30 */ 447395a725SSoby Mathew br x2 459b476841SSoby Mathew1: 467395a725SSoby Mathew ret 478b779620SKévin Petitendfunc reset_handler 4824fb838fSSoby Mathew 49b1d27b48SRoberto Vargas#endif 509b476841SSoby Mathew 513d8256b2SMasahiro Yamada#ifdef IMAGE_BL31 /* The power down core and cluster is needed only in BL31 */ 52add40351SSoby Mathew /* 535dd9dbb5SJeenu Viswambharan * void prepare_cpu_pwr_dwn(unsigned int power_level) 545dd9dbb5SJeenu Viswambharan * 555dd9dbb5SJeenu Viswambharan * Prepare CPU power down function for all platforms. The function takes 565dd9dbb5SJeenu Viswambharan * a domain level to be powered down as its parameter. After the cpu_ops 575dd9dbb5SJeenu Viswambharan * pointer is retrieved from cpu_data, the handler for requested power 585dd9dbb5SJeenu Viswambharan * level is called. 59add40351SSoby Mathew */ 605dd9dbb5SJeenu Viswambharan .globl prepare_cpu_pwr_dwn 615dd9dbb5SJeenu Viswambharanfunc prepare_cpu_pwr_dwn 62add40351SSoby Mathew /* 635dd9dbb5SJeenu Viswambharan * If the given power level exceeds CPU_MAX_PWR_DWN_OPS, we call the 645dd9dbb5SJeenu Viswambharan * power down handler for the last power level 65add40351SSoby Mathew */ 665dd9dbb5SJeenu Viswambharan mov_imm x2, (CPU_MAX_PWR_DWN_OPS - 1) 675dd9dbb5SJeenu Viswambharan cmp x0, x2 685dd9dbb5SJeenu Viswambharan csel x2, x2, x0, hi 695dd9dbb5SJeenu Viswambharan 70add40351SSoby Mathew mrs x1, tpidr_el3 71add40351SSoby Mathew ldr x0, [x1, #CPU_DATA_CPU_OPS_PTR] 72044bb2faSAntonio Nino Diaz#if ENABLE_ASSERTIONS 73add40351SSoby Mathew cmp x0, #0 74add40351SSoby Mathew ASM_ASSERT(ne) 75add40351SSoby Mathew#endif 76add40351SSoby Mathew 775dd9dbb5SJeenu Viswambharan /* Get the appropriate power down handler */ 785dd9dbb5SJeenu Viswambharan mov x1, #CPU_PWR_DWN_OPS 795dd9dbb5SJeenu Viswambharan add x1, x1, x2, lsl #3 805dd9dbb5SJeenu Viswambharan ldr x1, [x0, x1] 81601e3ed2SVarun Wadekar#if ENABLE_ASSERTIONS 82601e3ed2SVarun Wadekar cmp x1, #0 83601e3ed2SVarun Wadekar ASM_ASSERT(ne) 84601e3ed2SVarun Wadekar#endif 85add40351SSoby Mathew br x1 865dd9dbb5SJeenu Viswambharanendfunc prepare_cpu_pwr_dwn 87add40351SSoby Mathew 88add40351SSoby Mathew 89add40351SSoby Mathew /* 90add40351SSoby Mathew * Initializes the cpu_ops_ptr if not already initialized 9112e7c4abSVikram Kanigiri * in cpu_data. This can be called without a runtime stack, but may 9212e7c4abSVikram Kanigiri * only be called after the MMU is enabled. 93add40351SSoby Mathew * clobbers: x0 - x6, x10 94add40351SSoby Mathew */ 95add40351SSoby Mathew .globl init_cpu_ops 96add40351SSoby Mathewfunc init_cpu_ops 97add40351SSoby Mathew mrs x6, tpidr_el3 98add40351SSoby Mathew ldr x0, [x6, #CPU_DATA_CPU_OPS_PTR] 99add40351SSoby Mathew cbnz x0, 1f 100add40351SSoby Mathew mov x10, x30 101add40351SSoby Mathew bl get_cpu_ops_ptr 102044bb2faSAntonio Nino Diaz#if ENABLE_ASSERTIONS 103add40351SSoby Mathew cmp x0, #0 104add40351SSoby Mathew ASM_ASSERT(ne) 105add40351SSoby Mathew#endif 10609997346SSoby Mathew str x0, [x6, #CPU_DATA_CPU_OPS_PTR]! 107add40351SSoby Mathew mov x30, x10 108add40351SSoby Mathew1: 109add40351SSoby Mathew ret 1108b779620SKévin Petitendfunc init_cpu_ops 111add40351SSoby Mathew#endif /* IMAGE_BL31 */ 112add40351SSoby Mathew 1133d8256b2SMasahiro Yamada#if defined(IMAGE_BL31) && CRASH_REPORTING 114d3f70af6SSoby Mathew /* 115d3f70af6SSoby Mathew * The cpu specific registers which need to be reported in a crash 116d3f70af6SSoby Mathew * are reported via cpu_ops cpu_reg_dump function. After a matching 117d3f70af6SSoby Mathew * cpu_ops structure entry is found, the correponding cpu_reg_dump 118d3f70af6SSoby Mathew * in the cpu_ops is invoked. 119d3f70af6SSoby Mathew */ 120d3f70af6SSoby Mathew .globl do_cpu_reg_dump 121d3f70af6SSoby Mathewfunc do_cpu_reg_dump 122d3f70af6SSoby Mathew mov x16, x30 123d3f70af6SSoby Mathew 124d3f70af6SSoby Mathew /* Get the matching cpu_ops pointer */ 125d3f70af6SSoby Mathew bl get_cpu_ops_ptr 126d3f70af6SSoby Mathew cbz x0, 1f 127d3f70af6SSoby Mathew 128d3f70af6SSoby Mathew /* Get the cpu_ops cpu_reg_dump */ 129d3f70af6SSoby Mathew ldr x2, [x0, #CPU_REG_DUMP] 130d3f70af6SSoby Mathew cbz x2, 1f 131d3f70af6SSoby Mathew blr x2 132d3f70af6SSoby Mathew1: 133d3f70af6SSoby Mathew mov x30, x16 134d3f70af6SSoby Mathew ret 1358b779620SKévin Petitendfunc do_cpu_reg_dump 136d3f70af6SSoby Mathew#endif 137d3f70af6SSoby Mathew 1389b476841SSoby Mathew /* 1399b476841SSoby Mathew * The below function returns the cpu_ops structure matching the 1409b476841SSoby Mathew * midr of the core. It reads the MIDR_EL1 and finds the matching 1419b476841SSoby Mathew * entry in cpu_ops entries. Only the implementation and part number 1429b476841SSoby Mathew * are used to match the entries. 1431994e562SJavier Almansa Sobrino * 1441994e562SJavier Almansa Sobrino * If cpu_ops for the MIDR_EL1 cannot be found and 1451994e562SJavier Almansa Sobrino * SUPPORT_UNKNOWN_MPID is enabled, it will try to look for a 1461994e562SJavier Almansa Sobrino * default cpu_ops with an MIDR value of 0. 147*2e61d687SOlivier Deprez * (Implementation number 0x0 should be reserved for software use 1481994e562SJavier Almansa Sobrino * and therefore no clashes should happen with that default value). 1491994e562SJavier Almansa Sobrino * 1509b476841SSoby Mathew * Return : 1519b476841SSoby Mathew * x0 - The matching cpu_ops pointer on Success 1529b476841SSoby Mathew * x0 - 0 on failure. 1539b476841SSoby Mathew * Clobbers : x0 - x5 1549b476841SSoby Mathew */ 1559b476841SSoby Mathew .globl get_cpu_ops_ptr 1569b476841SSoby Mathewfunc get_cpu_ops_ptr 1579b476841SSoby Mathew /* Read the MIDR_EL1 */ 1589b476841SSoby Mathew mrs x2, midr_el1 1599b476841SSoby Mathew mov_imm x3, CPU_IMPL_PN_MASK 1609b476841SSoby Mathew 1619b476841SSoby Mathew /* Retain only the implementation and part number using mask */ 1629b476841SSoby Mathew and w2, w2, w3 1631994e562SJavier Almansa Sobrino 1641994e562SJavier Almansa Sobrino /* Get the cpu_ops end location */ 1651994e562SJavier Almansa Sobrino adr x5, (__CPU_OPS_END__ + CPU_MIDR) 1661994e562SJavier Almansa Sobrino 1671994e562SJavier Almansa Sobrino /* Initialize the return parameter */ 1681994e562SJavier Almansa Sobrino mov x0, #0 1699b476841SSoby Mathew1: 1701994e562SJavier Almansa Sobrino /* Get the cpu_ops start location */ 1711994e562SJavier Almansa Sobrino adr x4, (__CPU_OPS_START__ + CPU_MIDR) 1721994e562SJavier Almansa Sobrino 1731994e562SJavier Almansa Sobrino2: 1749b476841SSoby Mathew /* Check if we have reached end of list */ 1759b476841SSoby Mathew cmp x4, x5 1761994e562SJavier Almansa Sobrino b.eq search_def_ptr 1779b476841SSoby Mathew 1789b476841SSoby Mathew /* load the midr from the cpu_ops */ 1799b476841SSoby Mathew ldr x1, [x4], #CPU_OPS_SIZE 1809b476841SSoby Mathew and w1, w1, w3 1819b476841SSoby Mathew 1829b476841SSoby Mathew /* Check if midr matches to midr of this core */ 1839b476841SSoby Mathew cmp w1, w2 1841994e562SJavier Almansa Sobrino b.ne 2b 1859b476841SSoby Mathew 1869b476841SSoby Mathew /* Subtract the increment and offset to get the cpu-ops pointer */ 1879b476841SSoby Mathew sub x0, x4, #(CPU_OPS_SIZE + CPU_MIDR) 188601e3ed2SVarun Wadekar#if ENABLE_ASSERTIONS 189601e3ed2SVarun Wadekar cmp x0, #0 190601e3ed2SVarun Wadekar ASM_ASSERT(ne) 191601e3ed2SVarun Wadekar#endif 1921994e562SJavier Almansa Sobrino#ifdef SUPPORT_UNKNOWN_MPID 1931994e562SJavier Almansa Sobrino cbnz x2, exit_mpid_found 1941994e562SJavier Almansa Sobrino /* Mark the unsupported MPID flag */ 1951994e562SJavier Almansa Sobrino adrp x1, unsupported_mpid_flag 1961994e562SJavier Almansa Sobrino add x1, x1, :lo12:unsupported_mpid_flag 1971994e562SJavier Almansa Sobrino str w2, [x1] 1981994e562SJavier Almansa Sobrinoexit_mpid_found: 1991994e562SJavier Almansa Sobrino#endif 2001994e562SJavier Almansa Sobrino ret 2011994e562SJavier Almansa Sobrino 2021994e562SJavier Almansa Sobrino /* 2031994e562SJavier Almansa Sobrino * Search again for a default pointer (MIDR = 0x0) 2041994e562SJavier Almansa Sobrino * or return error if already searched. 2051994e562SJavier Almansa Sobrino */ 2061994e562SJavier Almansa Sobrinosearch_def_ptr: 2071994e562SJavier Almansa Sobrino#ifdef SUPPORT_UNKNOWN_MPID 2081994e562SJavier Almansa Sobrino cbz x2, error_exit 2091994e562SJavier Almansa Sobrino mov x2, #0 2101994e562SJavier Almansa Sobrino b 1b 2119b476841SSoby Mathewerror_exit: 2121994e562SJavier Almansa Sobrino#endif 2139b476841SSoby Mathew ret 2148b779620SKévin Petitendfunc get_cpu_ops_ptr 2157395a725SSoby Mathew 21610bcd761SJeenu Viswambharan/* 21710bcd761SJeenu Viswambharan * Extract CPU revision and variant, and combine them into a single numeric for 21810bcd761SJeenu Viswambharan * easier comparison. 21910bcd761SJeenu Viswambharan */ 22010bcd761SJeenu Viswambharan .globl cpu_get_rev_var 22110bcd761SJeenu Viswambharanfunc cpu_get_rev_var 22210bcd761SJeenu Viswambharan mrs x1, midr_el1 2237395a725SSoby Mathew 22454035fc4SSandrine Bailleux /* 22510bcd761SJeenu Viswambharan * Extract the variant[23:20] and revision[3:0] from MIDR, and pack them 22610bcd761SJeenu Viswambharan * as variant[7:4] and revision[3:0] of x0. 22754035fc4SSandrine Bailleux * 22810bcd761SJeenu Viswambharan * First extract x1[23:16] to x0[7:0] and zero fill the rest. Then 22910bcd761SJeenu Viswambharan * extract x1[3:0] into x0[3:0] retaining other bits. 23054035fc4SSandrine Bailleux */ 23110bcd761SJeenu Viswambharan ubfx x0, x1, #(MIDR_VAR_SHIFT - MIDR_REV_BITS), #(MIDR_REV_BITS + MIDR_VAR_BITS) 23210bcd761SJeenu Viswambharan bfxil x0, x1, #MIDR_REV_SHIFT, #MIDR_REV_BITS 23310bcd761SJeenu Viswambharan ret 23410bcd761SJeenu Viswambharanendfunc cpu_get_rev_var 2357395a725SSoby Mathew 23610bcd761SJeenu Viswambharan/* 23710bcd761SJeenu Viswambharan * Compare the CPU's revision-variant (x0) with a given value (x1), for errata 23810bcd761SJeenu Viswambharan * application purposes. If the revision-variant is less than or same as a given 23910bcd761SJeenu Viswambharan * value, indicates that errata applies; otherwise not. 2409ec3921cSJonathan Wright * 2419ec3921cSJonathan Wright * Shall clobber: x0-x3 24210bcd761SJeenu Viswambharan */ 24310bcd761SJeenu Viswambharan .globl cpu_rev_var_ls 24410bcd761SJeenu Viswambharanfunc cpu_rev_var_ls 24510bcd761SJeenu Viswambharan mov x2, #ERRATA_APPLIES 24610bcd761SJeenu Viswambharan mov x3, #ERRATA_NOT_APPLIES 24710bcd761SJeenu Viswambharan cmp x0, x1 24810bcd761SJeenu Viswambharan csel x0, x2, x3, ls 24910bcd761SJeenu Viswambharan ret 25010bcd761SJeenu Viswambharanendfunc cpu_rev_var_ls 25110bcd761SJeenu Viswambharan 252b75dc0e4SAndre Przywara/* 253b75dc0e4SAndre Przywara * Compare the CPU's revision-variant (x0) with a given value (x1), for errata 254b75dc0e4SAndre Przywara * application purposes. If the revision-variant is higher than or same as a 255b75dc0e4SAndre Przywara * given value, indicates that errata applies; otherwise not. 2569ec3921cSJonathan Wright * 2579ec3921cSJonathan Wright * Shall clobber: x0-x3 258b75dc0e4SAndre Przywara */ 259b75dc0e4SAndre Przywara .globl cpu_rev_var_hs 260b75dc0e4SAndre Przywarafunc cpu_rev_var_hs 261b75dc0e4SAndre Przywara mov x2, #ERRATA_APPLIES 262b75dc0e4SAndre Przywara mov x3, #ERRATA_NOT_APPLIES 263b75dc0e4SAndre Przywara cmp x0, x1 264b75dc0e4SAndre Przywara csel x0, x2, x3, hs 265b75dc0e4SAndre Przywara ret 266b75dc0e4SAndre Przywaraendfunc cpu_rev_var_hs 267b75dc0e4SAndre Przywara 26880942622Slaurenw-arm/* 26980942622Slaurenw-arm * Compare the CPU's revision-variant (x0) with a given range (x1 - x2), for errata 27080942622Slaurenw-arm * application purposes. If the revision-variant is between or includes the given 27180942622Slaurenw-arm * values, this indicates that errata applies; otherwise not. 27280942622Slaurenw-arm * 27380942622Slaurenw-arm * Shall clobber: x0-x4 27480942622Slaurenw-arm */ 27580942622Slaurenw-arm .globl cpu_rev_var_range 27680942622Slaurenw-armfunc cpu_rev_var_range 27780942622Slaurenw-arm mov x3, #ERRATA_APPLIES 27880942622Slaurenw-arm mov x4, #ERRATA_NOT_APPLIES 27980942622Slaurenw-arm cmp x0, x1 28080942622Slaurenw-arm csel x1, x3, x4, hs 28180942622Slaurenw-arm cbz x1, 1f 28280942622Slaurenw-arm cmp x0, x2 28380942622Slaurenw-arm csel x1, x3, x4, ls 28480942622Slaurenw-arm1: 28580942622Slaurenw-arm mov x0, x1 28680942622Slaurenw-arm ret 28780942622Slaurenw-armendfunc cpu_rev_var_range 28880942622Slaurenw-arm 28910bcd761SJeenu Viswambharan#if REPORT_ERRATA 29010bcd761SJeenu Viswambharan/* 29110bcd761SJeenu Viswambharan * void print_errata_status(void); 29210bcd761SJeenu Viswambharan * 29310bcd761SJeenu Viswambharan * Function to print errata status for CPUs of its class. Must be called only: 29410bcd761SJeenu Viswambharan * 29510bcd761SJeenu Viswambharan * - with MMU and data caches are enabled; 29610bcd761SJeenu Viswambharan * - after cpu_ops have been initialized in per-CPU data. 29710bcd761SJeenu Viswambharan */ 29810bcd761SJeenu Viswambharan .globl print_errata_status 29910bcd761SJeenu Viswambharanfunc print_errata_status 30010bcd761SJeenu Viswambharan#ifdef IMAGE_BL1 30110bcd761SJeenu Viswambharan /* 30210bcd761SJeenu Viswambharan * BL1 doesn't have per-CPU data. So retrieve the CPU operations 30310bcd761SJeenu Viswambharan * directly. 30410bcd761SJeenu Viswambharan */ 30510bcd761SJeenu Viswambharan stp xzr, x30, [sp, #-16]! 30610bcd761SJeenu Viswambharan bl get_cpu_ops_ptr 30710bcd761SJeenu Viswambharan ldp xzr, x30, [sp], #16 30810bcd761SJeenu Viswambharan ldr x1, [x0, #CPU_ERRATA_FUNC] 30910bcd761SJeenu Viswambharan cbnz x1, .Lprint 31010bcd761SJeenu Viswambharan#else 31110bcd761SJeenu Viswambharan /* 31210bcd761SJeenu Viswambharan * Retrieve pointer to cpu_ops from per-CPU data, and further, the 31310bcd761SJeenu Viswambharan * errata printing function. If it's non-NULL, jump to the function in 31410bcd761SJeenu Viswambharan * turn. 31510bcd761SJeenu Viswambharan */ 31610bcd761SJeenu Viswambharan mrs x0, tpidr_el3 317601e3ed2SVarun Wadekar#if ENABLE_ASSERTIONS 318601e3ed2SVarun Wadekar cmp x0, #0 319601e3ed2SVarun Wadekar ASM_ASSERT(ne) 320601e3ed2SVarun Wadekar#endif 32110bcd761SJeenu Viswambharan ldr x1, [x0, #CPU_DATA_CPU_OPS_PTR] 322601e3ed2SVarun Wadekar#if ENABLE_ASSERTIONS 323601e3ed2SVarun Wadekar cmp x1, #0 324601e3ed2SVarun Wadekar ASM_ASSERT(ne) 325601e3ed2SVarun Wadekar#endif 32610bcd761SJeenu Viswambharan ldr x0, [x1, #CPU_ERRATA_FUNC] 32710bcd761SJeenu Viswambharan cbz x0, .Lnoprint 32810bcd761SJeenu Viswambharan 32910bcd761SJeenu Viswambharan /* 33010bcd761SJeenu Viswambharan * Printing errata status requires atomically testing the printed flag. 33110bcd761SJeenu Viswambharan */ 33222fa58cbSdp-arm stp x19, x30, [sp, #-16]! 33322fa58cbSdp-arm mov x19, x0 33410bcd761SJeenu Viswambharan 33510bcd761SJeenu Viswambharan /* 33610bcd761SJeenu Viswambharan * Load pointers to errata lock and printed flag. Call 33710bcd761SJeenu Viswambharan * errata_needs_reporting to check whether this CPU needs to report 33810bcd761SJeenu Viswambharan * errata status pertaining to its class. 33910bcd761SJeenu Viswambharan */ 34010bcd761SJeenu Viswambharan ldr x0, [x1, #CPU_ERRATA_LOCK] 34110bcd761SJeenu Viswambharan ldr x1, [x1, #CPU_ERRATA_PRINTED] 34210bcd761SJeenu Viswambharan bl errata_needs_reporting 34322fa58cbSdp-arm mov x1, x19 34422fa58cbSdp-arm ldp x19, x30, [sp], #16 34510bcd761SJeenu Viswambharan cbnz x0, .Lprint 34610bcd761SJeenu Viswambharan#endif 34710bcd761SJeenu Viswambharan.Lnoprint: 34810bcd761SJeenu Viswambharan ret 34910bcd761SJeenu Viswambharan.Lprint: 35010bcd761SJeenu Viswambharan /* Jump to errata reporting function for this CPU */ 35110bcd761SJeenu Viswambharan br x1 35210bcd761SJeenu Viswambharanendfunc print_errata_status 35310bcd761SJeenu Viswambharan#endif 354a205a56eSDimitris Papastamos 355a205a56eSDimitris Papastamos/* 3562c3a1078SDimitris Papastamos * int check_wa_cve_2017_5715(void); 357a205a56eSDimitris Papastamos * 358a205a56eSDimitris Papastamos * This function returns: 359a205a56eSDimitris Papastamos * - ERRATA_APPLIES when firmware mitigation is required. 360a205a56eSDimitris Papastamos * - ERRATA_NOT_APPLIES when firmware mitigation is _not_ required. 361a205a56eSDimitris Papastamos * - ERRATA_MISSING when firmware mitigation would be required but 362a205a56eSDimitris Papastamos * is not compiled in. 363a205a56eSDimitris Papastamos * 364a205a56eSDimitris Papastamos * NOTE: Must be called only after cpu_ops have been initialized 365a205a56eSDimitris Papastamos * in per-CPU data. 366a205a56eSDimitris Papastamos */ 3672c3a1078SDimitris Papastamos .globl check_wa_cve_2017_5715 3682c3a1078SDimitris Papastamosfunc check_wa_cve_2017_5715 369a205a56eSDimitris Papastamos mrs x0, tpidr_el3 370a205a56eSDimitris Papastamos#if ENABLE_ASSERTIONS 371a205a56eSDimitris Papastamos cmp x0, #0 372a205a56eSDimitris Papastamos ASM_ASSERT(ne) 373a205a56eSDimitris Papastamos#endif 374a205a56eSDimitris Papastamos ldr x0, [x0, #CPU_DATA_CPU_OPS_PTR] 375601e3ed2SVarun Wadekar#if ENABLE_ASSERTIONS 376601e3ed2SVarun Wadekar cmp x0, #0 377601e3ed2SVarun Wadekar ASM_ASSERT(ne) 378601e3ed2SVarun Wadekar#endif 379a205a56eSDimitris Papastamos ldr x0, [x0, #CPU_EXTRA1_FUNC] 380a205a56eSDimitris Papastamos /* 381a205a56eSDimitris Papastamos * If the reserved function pointer is NULL, this CPU 382a205a56eSDimitris Papastamos * is unaffected by CVE-2017-5715 so bail out. 383a205a56eSDimitris Papastamos */ 384a205a56eSDimitris Papastamos cmp x0, #0 385a205a56eSDimitris Papastamos beq 1f 386a205a56eSDimitris Papastamos br x0 387a205a56eSDimitris Papastamos1: 388a205a56eSDimitris Papastamos mov x0, #ERRATA_NOT_APPLIES 389a205a56eSDimitris Papastamos ret 3902c3a1078SDimitris Papastamosendfunc check_wa_cve_2017_5715 391fe007b2eSDimitris Papastamos 392fe007b2eSDimitris Papastamos/* 393fe007b2eSDimitris Papastamos * void *wa_cve_2018_3639_get_disable_ptr(void); 394fe007b2eSDimitris Papastamos * 395fe007b2eSDimitris Papastamos * Returns a function pointer which is used to disable mitigation 396fe007b2eSDimitris Papastamos * for CVE-2018-3639. 397fe007b2eSDimitris Papastamos * The function pointer is only returned on cores that employ 398fe007b2eSDimitris Papastamos * dynamic mitigation. If the core uses static mitigation or is 399fe007b2eSDimitris Papastamos * unaffected by CVE-2018-3639 this function returns NULL. 400fe007b2eSDimitris Papastamos * 401fe007b2eSDimitris Papastamos * NOTE: Must be called only after cpu_ops have been initialized 402fe007b2eSDimitris Papastamos * in per-CPU data. 403fe007b2eSDimitris Papastamos */ 404fe007b2eSDimitris Papastamos .globl wa_cve_2018_3639_get_disable_ptr 405fe007b2eSDimitris Papastamosfunc wa_cve_2018_3639_get_disable_ptr 406fe007b2eSDimitris Papastamos mrs x0, tpidr_el3 407fe007b2eSDimitris Papastamos#if ENABLE_ASSERTIONS 408fe007b2eSDimitris Papastamos cmp x0, #0 409fe007b2eSDimitris Papastamos ASM_ASSERT(ne) 410fe007b2eSDimitris Papastamos#endif 411fe007b2eSDimitris Papastamos ldr x0, [x0, #CPU_DATA_CPU_OPS_PTR] 412601e3ed2SVarun Wadekar#if ENABLE_ASSERTIONS 413601e3ed2SVarun Wadekar cmp x0, #0 414601e3ed2SVarun Wadekar ASM_ASSERT(ne) 415601e3ed2SVarun Wadekar#endif 416fe007b2eSDimitris Papastamos ldr x0, [x0, #CPU_EXTRA2_FUNC] 417fe007b2eSDimitris Papastamos ret 418fe007b2eSDimitris Papastamosendfunc wa_cve_2018_3639_get_disable_ptr 419