1b04ea14bSJohn Tsichritzis/* 2*263ee781Sjohpow01 * Copyright (c) 2017-2021, Arm Limited and Contributors. All rights reserved. 3b04ea14bSJohn Tsichritzis * 4b04ea14bSJohn Tsichritzis * SPDX-License-Identifier: BSD-3-Clause 5b04ea14bSJohn Tsichritzis */ 6b04ea14bSJohn Tsichritzis 7b04ea14bSJohn Tsichritzis#include <arch.h> 8b04ea14bSJohn Tsichritzis#include <asm_macros.S> 9b04ea14bSJohn Tsichritzis#include <cpuamu.h> 10b04ea14bSJohn Tsichritzis#include <cpu_macros.S> 1180942622Slaurenw-arm#include <context.h> 1225bbbd2dSJavier Almansa Sobrino#include <neoverse_n1.h> 13b04ea14bSJohn Tsichritzis 14076b5f02SJohn Tsichritzis/* Hardware handled coherency */ 15076b5f02SJohn Tsichritzis#if HW_ASSISTED_COHERENCY == 0 16076b5f02SJohn Tsichritzis#error "Neoverse N1 must be compiled with HW_ASSISTED_COHERENCY enabled" 17076b5f02SJohn Tsichritzis#endif 18076b5f02SJohn Tsichritzis 19629d04f5SJohn Tsichritzis/* 64-bit only core */ 20629d04f5SJohn Tsichritzis#if CTX_INCLUDE_AARCH32_REGS == 1 21629d04f5SJohn Tsichritzis#error "Neoverse-N1 supports only AArch64. Compile with CTX_INCLUDE_AARCH32_REGS=0" 22629d04f5SJohn Tsichritzis#endif 23629d04f5SJohn Tsichritzis 2480942622Slaurenw-arm .global neoverse_n1_errata_ic_trap_handler 2580942622Slaurenw-arm 26b04ea14bSJohn Tsichritzis/* -------------------------------------------------- 275f5d0763SAndre Przywara * Errata Workaround for Neoverse N1 Erratum 1043202. 28da6d75a0SJohn Tsichritzis * This applies to revision r0p0 and r1p0 of Neoverse N1. 29b04ea14bSJohn Tsichritzis * Inputs: 30b04ea14bSJohn Tsichritzis * x0: variant[4:7] and revision[0:3] of current cpu. 31b04ea14bSJohn Tsichritzis * Shall clobber: x0-x17 32b04ea14bSJohn Tsichritzis * -------------------------------------------------- 33b04ea14bSJohn Tsichritzis */ 34da6d75a0SJohn Tsichritzisfunc errata_n1_1043202_wa 35b04ea14bSJohn Tsichritzis /* Compare x0 against revision r1p0 */ 36b04ea14bSJohn Tsichritzis mov x17, x30 37b04ea14bSJohn Tsichritzis bl check_errata_1043202 38b04ea14bSJohn Tsichritzis cbz x0, 1f 39b04ea14bSJohn Tsichritzis 40b04ea14bSJohn Tsichritzis /* Apply instruction patching sequence */ 41b04ea14bSJohn Tsichritzis ldr x0, =0x0 42b04ea14bSJohn Tsichritzis msr CPUPSELR_EL3, x0 43b04ea14bSJohn Tsichritzis ldr x0, =0xF3BF8F2F 44b04ea14bSJohn Tsichritzis msr CPUPOR_EL3, x0 45b04ea14bSJohn Tsichritzis ldr x0, =0xFFFFFFFF 46b04ea14bSJohn Tsichritzis msr CPUPMR_EL3, x0 47b04ea14bSJohn Tsichritzis ldr x0, =0x800200071 48b04ea14bSJohn Tsichritzis msr CPUPCR_EL3, x0 49a33ec1e7Slaurenw-arm isb 50b04ea14bSJohn Tsichritzis1: 51b04ea14bSJohn Tsichritzis ret x17 52da6d75a0SJohn Tsichritzisendfunc errata_n1_1043202_wa 53b04ea14bSJohn Tsichritzis 54b04ea14bSJohn Tsichritzisfunc check_errata_1043202 55b04ea14bSJohn Tsichritzis /* Applies to r0p0 and r1p0 */ 56b04ea14bSJohn Tsichritzis mov x1, #0x10 57b04ea14bSJohn Tsichritzis b cpu_rev_var_ls 58b04ea14bSJohn Tsichritzisendfunc check_errata_1043202 59b04ea14bSJohn Tsichritzis 60eca6e453SSami Mujawar/* -------------------------------------------------- 61eca6e453SSami Mujawar * Disable speculative loads if Neoverse N1 supports 62eca6e453SSami Mujawar * SSBS. 63eca6e453SSami Mujawar * 64eca6e453SSami Mujawar * Shall clobber: x0. 65eca6e453SSami Mujawar * -------------------------------------------------- 66eca6e453SSami Mujawar */ 67eca6e453SSami Mujawarfunc neoverse_n1_disable_speculative_loads 68eca6e453SSami Mujawar /* Check if the PE implements SSBS */ 69eca6e453SSami Mujawar mrs x0, id_aa64pfr1_el1 70eca6e453SSami Mujawar tst x0, #(ID_AA64PFR1_EL1_SSBS_MASK << ID_AA64PFR1_EL1_SSBS_SHIFT) 71eca6e453SSami Mujawar b.eq 1f 72eca6e453SSami Mujawar 73eca6e453SSami Mujawar /* Disable speculative loads */ 74eca6e453SSami Mujawar msr SSBS, xzr 75eca6e453SSami Mujawar 76eca6e453SSami Mujawar1: 77eca6e453SSami Mujawar ret 78eca6e453SSami Mujawarendfunc neoverse_n1_disable_speculative_loads 79eca6e453SSami Mujawar 805f5d0763SAndre Przywara/* -------------------------------------------------- 81a601afe1Slauwal01 * Errata Workaround for Neoverse N1 Errata #1073348 82a601afe1Slauwal01 * This applies to revision r0p0 and r1p0 of Neoverse N1. 83a601afe1Slauwal01 * Inputs: 84a601afe1Slauwal01 * x0: variant[4:7] and revision[0:3] of current cpu. 85a601afe1Slauwal01 * Shall clobber: x0-x17 86a601afe1Slauwal01 * -------------------------------------------------- 87a601afe1Slauwal01 */ 88a601afe1Slauwal01func errata_n1_1073348_wa 89a601afe1Slauwal01 /* Compare x0 against revision r1p0 */ 90a601afe1Slauwal01 mov x17, x30 91a601afe1Slauwal01 bl check_errata_1073348 92a601afe1Slauwal01 cbz x0, 1f 93a601afe1Slauwal01 mrs x1, NEOVERSE_N1_CPUACTLR_EL1 94a601afe1Slauwal01 orr x1, x1, NEOVERSE_N1_CPUACTLR_EL1_BIT_6 95a601afe1Slauwal01 msr NEOVERSE_N1_CPUACTLR_EL1, x1 96a601afe1Slauwal011: 97a601afe1Slauwal01 ret x17 98a601afe1Slauwal01endfunc errata_n1_1073348_wa 99a601afe1Slauwal01 100a601afe1Slauwal01func check_errata_1073348 101a601afe1Slauwal01 /* Applies to r0p0 and r1p0 */ 102a601afe1Slauwal01 mov x1, #0x10 103a601afe1Slauwal01 b cpu_rev_var_ls 104a601afe1Slauwal01endfunc check_errata_1073348 105a601afe1Slauwal01 106a601afe1Slauwal01/* -------------------------------------------------- 107e34606f2Slauwal01 * Errata Workaround for Neoverse N1 Errata #1130799 108e34606f2Slauwal01 * This applies to revision <=r2p0 of Neoverse N1. 109e34606f2Slauwal01 * Inputs: 110e34606f2Slauwal01 * x0: variant[4:7] and revision[0:3] of current cpu. 111e34606f2Slauwal01 * Shall clobber: x0-x17 112e34606f2Slauwal01 * -------------------------------------------------- 113e34606f2Slauwal01 */ 114e34606f2Slauwal01func errata_n1_1130799_wa 115e34606f2Slauwal01 /* Compare x0 against revision r2p0 */ 116e34606f2Slauwal01 mov x17, x30 117e34606f2Slauwal01 bl check_errata_1130799 118e34606f2Slauwal01 cbz x0, 1f 119e34606f2Slauwal01 mrs x1, NEOVERSE_N1_CPUACTLR2_EL1 120e34606f2Slauwal01 orr x1, x1, NEOVERSE_N1_CPUACTLR2_EL1_BIT_59 121e34606f2Slauwal01 msr NEOVERSE_N1_CPUACTLR2_EL1, x1 122e34606f2Slauwal011: 123e34606f2Slauwal01 ret x17 124e34606f2Slauwal01endfunc errata_n1_1130799_wa 125e34606f2Slauwal01 126e34606f2Slauwal01func check_errata_1130799 127e34606f2Slauwal01 /* Applies to <=r2p0 */ 128e34606f2Slauwal01 mov x1, #0x20 129e34606f2Slauwal01 b cpu_rev_var_ls 130e34606f2Slauwal01endfunc check_errata_1130799 131e34606f2Slauwal01 132e34606f2Slauwal01/* -------------------------------------------------- 1332017ab24Slauwal01 * Errata Workaround for Neoverse N1 Errata #1165347 1342017ab24Slauwal01 * This applies to revision <=r2p0 of Neoverse N1. 1352017ab24Slauwal01 * Inputs: 1362017ab24Slauwal01 * x0: variant[4:7] and revision[0:3] of current cpu. 1372017ab24Slauwal01 * Shall clobber: x0-x17 1382017ab24Slauwal01 * -------------------------------------------------- 1392017ab24Slauwal01 */ 1402017ab24Slauwal01func errata_n1_1165347_wa 1412017ab24Slauwal01 /* Compare x0 against revision r2p0 */ 1422017ab24Slauwal01 mov x17, x30 1432017ab24Slauwal01 bl check_errata_1165347 1442017ab24Slauwal01 cbz x0, 1f 1452017ab24Slauwal01 mrs x1, NEOVERSE_N1_CPUACTLR2_EL1 1462017ab24Slauwal01 orr x1, x1, NEOVERSE_N1_CPUACTLR2_EL1_BIT_0 1472017ab24Slauwal01 orr x1, x1, NEOVERSE_N1_CPUACTLR2_EL1_BIT_15 1482017ab24Slauwal01 msr NEOVERSE_N1_CPUACTLR2_EL1, x1 1492017ab24Slauwal011: 1502017ab24Slauwal01 ret x17 1512017ab24Slauwal01endfunc errata_n1_1165347_wa 1522017ab24Slauwal01 1532017ab24Slauwal01func check_errata_1165347 1542017ab24Slauwal01 /* Applies to <=r2p0 */ 1552017ab24Slauwal01 mov x1, #0x20 1562017ab24Slauwal01 b cpu_rev_var_ls 1572017ab24Slauwal01endfunc check_errata_1165347 1582017ab24Slauwal01 1592017ab24Slauwal01/* -------------------------------------------------- 160ef5fa7d4Slauwal01 * Errata Workaround for Neoverse N1 Errata #1207823 161ef5fa7d4Slauwal01 * This applies to revision <=r2p0 of Neoverse N1. 162ef5fa7d4Slauwal01 * Inputs: 163ef5fa7d4Slauwal01 * x0: variant[4:7] and revision[0:3] of current cpu. 164ef5fa7d4Slauwal01 * Shall clobber: x0-x17 165ef5fa7d4Slauwal01 * -------------------------------------------------- 166ef5fa7d4Slauwal01 */ 167ef5fa7d4Slauwal01func errata_n1_1207823_wa 168ef5fa7d4Slauwal01 /* Compare x0 against revision r2p0 */ 169ef5fa7d4Slauwal01 mov x17, x30 170ef5fa7d4Slauwal01 bl check_errata_1207823 171ef5fa7d4Slauwal01 cbz x0, 1f 172ef5fa7d4Slauwal01 mrs x1, NEOVERSE_N1_CPUACTLR2_EL1 173ef5fa7d4Slauwal01 orr x1, x1, NEOVERSE_N1_CPUACTLR2_EL1_BIT_11 174ef5fa7d4Slauwal01 msr NEOVERSE_N1_CPUACTLR2_EL1, x1 175ef5fa7d4Slauwal011: 176ef5fa7d4Slauwal01 ret x17 177ef5fa7d4Slauwal01endfunc errata_n1_1207823_wa 178ef5fa7d4Slauwal01 179ef5fa7d4Slauwal01func check_errata_1207823 180ef5fa7d4Slauwal01 /* Applies to <=r2p0 */ 181ef5fa7d4Slauwal01 mov x1, #0x20 182ef5fa7d4Slauwal01 b cpu_rev_var_ls 183ef5fa7d4Slauwal01endfunc check_errata_1207823 184ef5fa7d4Slauwal01 185ef5fa7d4Slauwal01/* -------------------------------------------------- 1869eceb020Slauwal01 * Errata Workaround for Neoverse N1 Errata #1220197 1879eceb020Slauwal01 * This applies to revision <=r2p0 of Neoverse N1. 1889eceb020Slauwal01 * Inputs: 1899eceb020Slauwal01 * x0: variant[4:7] and revision[0:3] of current cpu. 1909eceb020Slauwal01 * Shall clobber: x0-x17 1919eceb020Slauwal01 * -------------------------------------------------- 1929eceb020Slauwal01 */ 1939eceb020Slauwal01func errata_n1_1220197_wa 1949eceb020Slauwal01 /* Compare x0 against revision r2p0 */ 1959eceb020Slauwal01 mov x17, x30 1969eceb020Slauwal01 bl check_errata_1220197 1979eceb020Slauwal01 cbz x0, 1f 1989eceb020Slauwal01 mrs x1, NEOVERSE_N1_CPUECTLR_EL1 1999eceb020Slauwal01 orr x1, x1, NEOVERSE_N1_WS_THR_L2_MASK 2009eceb020Slauwal01 msr NEOVERSE_N1_CPUECTLR_EL1, x1 2019eceb020Slauwal011: 2029eceb020Slauwal01 ret x17 2039eceb020Slauwal01endfunc errata_n1_1220197_wa 2049eceb020Slauwal01 2059eceb020Slauwal01func check_errata_1220197 2069eceb020Slauwal01 /* Applies to <=r2p0 */ 2079eceb020Slauwal01 mov x1, #0x20 2089eceb020Slauwal01 b cpu_rev_var_ls 2099eceb020Slauwal01endfunc check_errata_1220197 2109eceb020Slauwal01 2119eceb020Slauwal01/* -------------------------------------------------- 212335b3c79Slauwal01 * Errata Workaround for Neoverse N1 Errata #1257314 213335b3c79Slauwal01 * This applies to revision <=r3p0 of Neoverse N1. 214335b3c79Slauwal01 * Inputs: 215335b3c79Slauwal01 * x0: variant[4:7] and revision[0:3] of current cpu. 216335b3c79Slauwal01 * Shall clobber: x0-x17 217335b3c79Slauwal01 * -------------------------------------------------- 218335b3c79Slauwal01 */ 219335b3c79Slauwal01func errata_n1_1257314_wa 220335b3c79Slauwal01 /* Compare x0 against revision r3p0 */ 221335b3c79Slauwal01 mov x17, x30 222335b3c79Slauwal01 bl check_errata_1257314 223335b3c79Slauwal01 cbz x0, 1f 224335b3c79Slauwal01 mrs x1, NEOVERSE_N1_CPUACTLR3_EL1 225335b3c79Slauwal01 orr x1, x1, NEOVERSE_N1_CPUACTLR3_EL1_BIT_10 226335b3c79Slauwal01 msr NEOVERSE_N1_CPUACTLR3_EL1, x1 227335b3c79Slauwal011: 228335b3c79Slauwal01 ret x17 229335b3c79Slauwal01endfunc errata_n1_1257314_wa 230335b3c79Slauwal01 231335b3c79Slauwal01func check_errata_1257314 232335b3c79Slauwal01 /* Applies to <=r3p0 */ 233335b3c79Slauwal01 mov x1, #0x30 234335b3c79Slauwal01 b cpu_rev_var_ls 235335b3c79Slauwal01endfunc check_errata_1257314 236335b3c79Slauwal01 237335b3c79Slauwal01/* -------------------------------------------------- 238411f4959Slauwal01 * Errata Workaround for Neoverse N1 Errata #1262606 239411f4959Slauwal01 * This applies to revision <=r3p0 of Neoverse N1. 240411f4959Slauwal01 * Inputs: 241411f4959Slauwal01 * x0: variant[4:7] and revision[0:3] of current cpu. 242411f4959Slauwal01 * Shall clobber: x0-x17 243411f4959Slauwal01 * -------------------------------------------------- 244411f4959Slauwal01 */ 245411f4959Slauwal01func errata_n1_1262606_wa 246411f4959Slauwal01 /* Compare x0 against revision r3p0 */ 247411f4959Slauwal01 mov x17, x30 248411f4959Slauwal01 bl check_errata_1262606 249411f4959Slauwal01 cbz x0, 1f 250411f4959Slauwal01 mrs x1, NEOVERSE_N1_CPUACTLR_EL1 251411f4959Slauwal01 orr x1, x1, NEOVERSE_N1_CPUACTLR_EL1_BIT_13 252411f4959Slauwal01 msr NEOVERSE_N1_CPUACTLR_EL1, x1 253411f4959Slauwal011: 254411f4959Slauwal01 ret x17 255411f4959Slauwal01endfunc errata_n1_1262606_wa 256411f4959Slauwal01 257411f4959Slauwal01func check_errata_1262606 258411f4959Slauwal01 /* Applies to <=r3p0 */ 259411f4959Slauwal01 mov x1, #0x30 260411f4959Slauwal01 b cpu_rev_var_ls 261411f4959Slauwal01endfunc check_errata_1262606 262411f4959Slauwal01 263411f4959Slauwal01/* -------------------------------------------------- 26411c48370Slauwal01 * Errata Workaround for Neoverse N1 Errata #1262888 26511c48370Slauwal01 * This applies to revision <=r3p0 of Neoverse N1. 26611c48370Slauwal01 * Inputs: 26711c48370Slauwal01 * x0: variant[4:7] and revision[0:3] of current cpu. 26811c48370Slauwal01 * Shall clobber: x0-x17 26911c48370Slauwal01 * -------------------------------------------------- 27011c48370Slauwal01 */ 27111c48370Slauwal01func errata_n1_1262888_wa 27211c48370Slauwal01 /* Compare x0 against revision r3p0 */ 27311c48370Slauwal01 mov x17, x30 27411c48370Slauwal01 bl check_errata_1262888 27511c48370Slauwal01 cbz x0, 1f 27611c48370Slauwal01 mrs x1, NEOVERSE_N1_CPUECTLR_EL1 27711c48370Slauwal01 orr x1, x1, NEOVERSE_N1_CPUECTLR_EL1_MM_TLBPF_DIS_BIT 27811c48370Slauwal01 msr NEOVERSE_N1_CPUECTLR_EL1, x1 27911c48370Slauwal011: 28011c48370Slauwal01 ret x17 28111c48370Slauwal01endfunc errata_n1_1262888_wa 28211c48370Slauwal01 28311c48370Slauwal01func check_errata_1262888 28411c48370Slauwal01 /* Applies to <=r3p0 */ 28511c48370Slauwal01 mov x1, #0x30 28611c48370Slauwal01 b cpu_rev_var_ls 28711c48370Slauwal01endfunc check_errata_1262888 28811c48370Slauwal01 28911c48370Slauwal01/* -------------------------------------------------- 2904d8801feSlauwal01 * Errata Workaround for Neoverse N1 Errata #1275112 2914d8801feSlauwal01 * This applies to revision <=r3p0 of Neoverse N1. 2924d8801feSlauwal01 * Inputs: 2934d8801feSlauwal01 * x0: variant[4:7] and revision[0:3] of current cpu. 2944d8801feSlauwal01 * Shall clobber: x0-x17 2954d8801feSlauwal01 * -------------------------------------------------- 2964d8801feSlauwal01 */ 2974d8801feSlauwal01func errata_n1_1275112_wa 2984d8801feSlauwal01 /* Compare x0 against revision r3p0 */ 2994d8801feSlauwal01 mov x17, x30 3004d8801feSlauwal01 bl check_errata_1275112 3014d8801feSlauwal01 cbz x0, 1f 3024d8801feSlauwal01 mrs x1, NEOVERSE_N1_CPUACTLR_EL1 3034d8801feSlauwal01 orr x1, x1, NEOVERSE_N1_CPUACTLR_EL1_BIT_13 3044d8801feSlauwal01 msr NEOVERSE_N1_CPUACTLR_EL1, x1 3054d8801feSlauwal011: 3064d8801feSlauwal01 ret x17 3074d8801feSlauwal01endfunc errata_n1_1275112_wa 3084d8801feSlauwal01 3094d8801feSlauwal01func check_errata_1275112 3104d8801feSlauwal01 /* Applies to <=r3p0 */ 3114d8801feSlauwal01 mov x1, #0x30 3124d8801feSlauwal01 b cpu_rev_var_ls 3134d8801feSlauwal01endfunc check_errata_1275112 3144d8801feSlauwal01 3154d8801feSlauwal01/* -------------------------------------------------- 3165f5d0763SAndre Przywara * Errata Workaround for Neoverse N1 Erratum 1315703. 3175f5d0763SAndre Przywara * This applies to revision <= r3p0 of Neoverse N1. 3185f5d0763SAndre Przywara * Inputs: 3195f5d0763SAndre Przywara * x0: variant[4:7] and revision[0:3] of current cpu. 3205f5d0763SAndre Przywara * Shall clobber: x0-x17 3215f5d0763SAndre Przywara * -------------------------------------------------- 3225f5d0763SAndre Przywara */ 3235f5d0763SAndre Przywarafunc errata_n1_1315703_wa 3245f5d0763SAndre Przywara /* Compare x0 against revision r3p1 */ 3255f5d0763SAndre Przywara mov x17, x30 3265f5d0763SAndre Przywara bl check_errata_1315703 3275f5d0763SAndre Przywara cbz x0, 1f 3285f5d0763SAndre Przywara 3295f5d0763SAndre Przywara mrs x0, NEOVERSE_N1_CPUACTLR2_EL1 3305f5d0763SAndre Przywara orr x0, x0, #NEOVERSE_N1_CPUACTLR2_EL1_BIT_16 3315f5d0763SAndre Przywara msr NEOVERSE_N1_CPUACTLR2_EL1, x0 3325f5d0763SAndre Przywara 3335f5d0763SAndre Przywara1: 3345f5d0763SAndre Przywara ret x17 3355f5d0763SAndre Przywaraendfunc errata_n1_1315703_wa 3365f5d0763SAndre Przywara 3375f5d0763SAndre Przywarafunc check_errata_1315703 3385f5d0763SAndre Przywara /* Applies to everything <= r3p0. */ 3395f5d0763SAndre Przywara mov x1, #0x30 3405f5d0763SAndre Przywara b cpu_rev_var_ls 3415f5d0763SAndre Przywaraendfunc check_errata_1315703 3425f5d0763SAndre Przywara 34380942622Slaurenw-arm/* -------------------------------------------------- 34480942622Slaurenw-arm * Errata Workaround for Neoverse N1 Erratum 1542419. 34580942622Slaurenw-arm * This applies to revisions r3p0 - r4p0 of Neoverse N1 34680942622Slaurenw-arm * Inputs: 34780942622Slaurenw-arm * x0: variant[4:7] and revision[0:3] of current cpu. 34880942622Slaurenw-arm * Shall clobber: x0-x17 34980942622Slaurenw-arm * -------------------------------------------------- 35080942622Slaurenw-arm */ 35180942622Slaurenw-armfunc errata_n1_1542419_wa 35280942622Slaurenw-arm /* Compare x0 against revision r3p0 and r4p0 */ 35380942622Slaurenw-arm mov x17, x30 35480942622Slaurenw-arm bl check_errata_1542419 35580942622Slaurenw-arm cbz x0, 1f 35680942622Slaurenw-arm 35780942622Slaurenw-arm /* Apply instruction patching sequence */ 35880942622Slaurenw-arm ldr x0, =0x0 35980942622Slaurenw-arm msr CPUPSELR_EL3, x0 36080942622Slaurenw-arm ldr x0, =0xEE670D35 36180942622Slaurenw-arm msr CPUPOR_EL3, x0 36280942622Slaurenw-arm ldr x0, =0xFFFF0FFF 36380942622Slaurenw-arm msr CPUPMR_EL3, x0 36480942622Slaurenw-arm ldr x0, =0x08000020007D 36580942622Slaurenw-arm msr CPUPCR_EL3, x0 36680942622Slaurenw-arm isb 36780942622Slaurenw-arm1: 36880942622Slaurenw-arm ret x17 36980942622Slaurenw-armendfunc errata_n1_1542419_wa 37080942622Slaurenw-arm 37180942622Slaurenw-armfunc check_errata_1542419 37280942622Slaurenw-arm /* Applies to everything r3p0 - r4p0. */ 37380942622Slaurenw-arm mov x1, #0x30 37480942622Slaurenw-arm mov x2, #0x40 37580942622Slaurenw-arm b cpu_rev_var_range 37680942622Slaurenw-armendfunc check_errata_1542419 37780942622Slaurenw-arm 37861f0ffc4Sjohpow01 /* -------------------------------------------------- 37961f0ffc4Sjohpow01 * Errata Workaround for Neoverse N1 Errata #1868343. 38061f0ffc4Sjohpow01 * This applies to revision <= r4p0 of Neoverse N1. 38161f0ffc4Sjohpow01 * This workaround is the same as the workaround for 38261f0ffc4Sjohpow01 * errata 1262606 and 1275112 but applies to a wider 38361f0ffc4Sjohpow01 * revision range. 38461f0ffc4Sjohpow01 * Inputs: 38561f0ffc4Sjohpow01 * x0: variant[4:7] and revision[0:3] of current cpu. 38661f0ffc4Sjohpow01 * Shall clobber: x0-x17 38761f0ffc4Sjohpow01 * -------------------------------------------------- 38861f0ffc4Sjohpow01 */ 38961f0ffc4Sjohpow01func errata_n1_1868343_wa 39061f0ffc4Sjohpow01 /* 39161f0ffc4Sjohpow01 * Compare x0 against revision r4p0 39261f0ffc4Sjohpow01 */ 39361f0ffc4Sjohpow01 mov x17, x30 39461f0ffc4Sjohpow01 bl check_errata_1868343 39561f0ffc4Sjohpow01 cbz x0, 1f 39661f0ffc4Sjohpow01 mrs x1, NEOVERSE_N1_CPUACTLR_EL1 39761f0ffc4Sjohpow01 orr x1, x1, NEOVERSE_N1_CPUACTLR_EL1_BIT_13 39861f0ffc4Sjohpow01 msr NEOVERSE_N1_CPUACTLR_EL1, x1 39961f0ffc4Sjohpow01 isb 40061f0ffc4Sjohpow011: 40161f0ffc4Sjohpow01 ret x17 40261f0ffc4Sjohpow01endfunc errata_n1_1868343_wa 40361f0ffc4Sjohpow01 40461f0ffc4Sjohpow01func check_errata_1868343 40561f0ffc4Sjohpow01 /* Applies to everything <= r4p0 */ 40661f0ffc4Sjohpow01 mov x1, #0x40 40761f0ffc4Sjohpow01 b cpu_rev_var_ls 40861f0ffc4Sjohpow01endfunc check_errata_1868343 40961f0ffc4Sjohpow01 410*263ee781Sjohpow01 /* -------------------------------------------------- 411*263ee781Sjohpow01 * Errata Workaround for Neoverse N1 Errata #1946160. 412*263ee781Sjohpow01 * This applies to revisions r3p0, r3p1, r4p0, and 413*263ee781Sjohpow01 * r4p1 of Neoverse N1. It also exists in r0p0, r1p0, 414*263ee781Sjohpow01 * and r2p0 but there is no fix in these revisions. 415*263ee781Sjohpow01 * Inputs: 416*263ee781Sjohpow01 * x0: variant[4:7] and revision[0:3] of current cpu. 417*263ee781Sjohpow01 * Shall clobber: x0-x17 418*263ee781Sjohpow01 * -------------------------------------------------- 419*263ee781Sjohpow01 */ 420*263ee781Sjohpow01func errata_n1_1946160_wa 421*263ee781Sjohpow01 /* 422*263ee781Sjohpow01 * Compare x0 against r3p0 - r4p1 423*263ee781Sjohpow01 */ 424*263ee781Sjohpow01 mov x17, x30 425*263ee781Sjohpow01 bl check_errata_1946160 426*263ee781Sjohpow01 cbz x0, 1f 427*263ee781Sjohpow01 428*263ee781Sjohpow01 mov x0, #3 429*263ee781Sjohpow01 msr S3_6_C15_C8_0, x0 430*263ee781Sjohpow01 ldr x0, =0x10E3900002 431*263ee781Sjohpow01 msr S3_6_C15_C8_2, x0 432*263ee781Sjohpow01 ldr x0, =0x10FFF00083 433*263ee781Sjohpow01 msr S3_6_C15_C8_3, x0 434*263ee781Sjohpow01 ldr x0, =0x2001003FF 435*263ee781Sjohpow01 msr S3_6_C15_C8_1, x0 436*263ee781Sjohpow01 437*263ee781Sjohpow01 mov x0, #4 438*263ee781Sjohpow01 msr S3_6_C15_C8_0, x0 439*263ee781Sjohpow01 ldr x0, =0x10E3800082 440*263ee781Sjohpow01 msr S3_6_C15_C8_2, x0 441*263ee781Sjohpow01 ldr x0, =0x10FFF00083 442*263ee781Sjohpow01 msr S3_6_C15_C8_3, x0 443*263ee781Sjohpow01 ldr x0, =0x2001003FF 444*263ee781Sjohpow01 msr S3_6_C15_C8_1, x0 445*263ee781Sjohpow01 446*263ee781Sjohpow01 mov x0, #5 447*263ee781Sjohpow01 msr S3_6_C15_C8_0, x0 448*263ee781Sjohpow01 ldr x0, =0x10E3800200 449*263ee781Sjohpow01 msr S3_6_C15_C8_2, x0 450*263ee781Sjohpow01 ldr x0, =0x10FFF003E0 451*263ee781Sjohpow01 msr S3_6_C15_C8_3, x0 452*263ee781Sjohpow01 ldr x0, =0x2001003FF 453*263ee781Sjohpow01 msr S3_6_C15_C8_1, x0 454*263ee781Sjohpow01 455*263ee781Sjohpow01 isb 456*263ee781Sjohpow011: 457*263ee781Sjohpow01 ret x17 458*263ee781Sjohpow01endfunc errata_n1_1946160_wa 459*263ee781Sjohpow01 460*263ee781Sjohpow01func check_errata_1946160 461*263ee781Sjohpow01 /* Applies to r3p0 - r4p1. */ 462*263ee781Sjohpow01 mov x1, #0x30 463*263ee781Sjohpow01 mov x2, #0x41 464*263ee781Sjohpow01 b cpu_rev_var_range 465*263ee781Sjohpow01endfunc check_errata_1946160 466*263ee781Sjohpow01 467da6d75a0SJohn Tsichritzisfunc neoverse_n1_reset_func 468b04ea14bSJohn Tsichritzis mov x19, x30 4698074448fSJohn Tsichritzis 470eca6e453SSami Mujawar bl neoverse_n1_disable_speculative_loads 4718074448fSJohn Tsichritzis 472632ab3ebSLouis Mayencourt /* Forces all cacheable atomic instructions to be near */ 473632ab3ebSLouis Mayencourt mrs x0, NEOVERSE_N1_CPUACTLR2_EL1 474632ab3ebSLouis Mayencourt orr x0, x0, #NEOVERSE_N1_CPUACTLR2_EL1_BIT_2 475632ab3ebSLouis Mayencourt msr NEOVERSE_N1_CPUACTLR2_EL1, x0 476632ab3ebSLouis Mayencourt isb 477632ab3ebSLouis Mayencourt 478b04ea14bSJohn Tsichritzis bl cpu_get_rev_var 479b04ea14bSJohn Tsichritzis mov x18, x0 480b04ea14bSJohn Tsichritzis 481da6d75a0SJohn Tsichritzis#if ERRATA_N1_1043202 482b04ea14bSJohn Tsichritzis mov x0, x18 483da6d75a0SJohn Tsichritzis bl errata_n1_1043202_wa 484b04ea14bSJohn Tsichritzis#endif 485b04ea14bSJohn Tsichritzis 486a601afe1Slauwal01#if ERRATA_N1_1073348 487a601afe1Slauwal01 mov x0, x18 488a601afe1Slauwal01 bl errata_n1_1073348_wa 489a601afe1Slauwal01#endif 490a601afe1Slauwal01 491e34606f2Slauwal01#if ERRATA_N1_1130799 492e34606f2Slauwal01 mov x0, x18 493e34606f2Slauwal01 bl errata_n1_1130799_wa 494e34606f2Slauwal01#endif 495e34606f2Slauwal01 4962017ab24Slauwal01#if ERRATA_N1_1165347 4972017ab24Slauwal01 mov x0, x18 4982017ab24Slauwal01 bl errata_n1_1165347_wa 4992017ab24Slauwal01#endif 5002017ab24Slauwal01 501ef5fa7d4Slauwal01#if ERRATA_N1_1207823 502ef5fa7d4Slauwal01 mov x0, x18 503ef5fa7d4Slauwal01 bl errata_n1_1207823_wa 504ef5fa7d4Slauwal01#endif 505ef5fa7d4Slauwal01 5069eceb020Slauwal01#if ERRATA_N1_1220197 5079eceb020Slauwal01 mov x0, x18 5089eceb020Slauwal01 bl errata_n1_1220197_wa 5099eceb020Slauwal01#endif 5109eceb020Slauwal01 511335b3c79Slauwal01#if ERRATA_N1_1257314 512335b3c79Slauwal01 mov x0, x18 513335b3c79Slauwal01 bl errata_n1_1257314_wa 514335b3c79Slauwal01#endif 515335b3c79Slauwal01 516411f4959Slauwal01#if ERRATA_N1_1262606 517411f4959Slauwal01 mov x0, x18 518411f4959Slauwal01 bl errata_n1_1262606_wa 519411f4959Slauwal01#endif 520411f4959Slauwal01 52111c48370Slauwal01#if ERRATA_N1_1262888 52211c48370Slauwal01 mov x0, x18 52311c48370Slauwal01 bl errata_n1_1262888_wa 52411c48370Slauwal01#endif 52511c48370Slauwal01 5264d8801feSlauwal01#if ERRATA_N1_1275112 5274d8801feSlauwal01 mov x0, x18 5284d8801feSlauwal01 bl errata_n1_1275112_wa 5294d8801feSlauwal01#endif 5304d8801feSlauwal01 5315f5d0763SAndre Przywara#if ERRATA_N1_1315703 5325f5d0763SAndre Przywara mov x0, x18 5335f5d0763SAndre Przywara bl errata_n1_1315703_wa 5345f5d0763SAndre Przywara#endif 5355f5d0763SAndre Przywara 53680942622Slaurenw-arm#if ERRATA_N1_1542419 53780942622Slaurenw-arm mov x0, x18 53880942622Slaurenw-arm bl errata_n1_1542419_wa 53980942622Slaurenw-arm#endif 54080942622Slaurenw-arm 54161f0ffc4Sjohpow01#if ERRATA_N1_1868343 54261f0ffc4Sjohpow01 mov x0, x18 54361f0ffc4Sjohpow01 bl errata_n1_1868343_wa 54461f0ffc4Sjohpow01#endif 54561f0ffc4Sjohpow01 546*263ee781Sjohpow01#if ERRATA_N1_1946160 547*263ee781Sjohpow01 mov x0, x18 548*263ee781Sjohpow01 bl errata_n1_1946160_wa 549*263ee781Sjohpow01#endif 550*263ee781Sjohpow01 551b04ea14bSJohn Tsichritzis#if ENABLE_AMU 552b04ea14bSJohn Tsichritzis /* Make sure accesses from EL0/EL1 and EL2 are not trapped to EL3 */ 553b04ea14bSJohn Tsichritzis mrs x0, actlr_el3 554da6d75a0SJohn Tsichritzis orr x0, x0, #NEOVERSE_N1_ACTLR_AMEN_BIT 555b04ea14bSJohn Tsichritzis msr actlr_el3, x0 556b04ea14bSJohn Tsichritzis 557b04ea14bSJohn Tsichritzis /* Make sure accesses from EL0/EL1 are not trapped to EL2 */ 558b04ea14bSJohn Tsichritzis mrs x0, actlr_el2 559da6d75a0SJohn Tsichritzis orr x0, x0, #NEOVERSE_N1_ACTLR_AMEN_BIT 560b04ea14bSJohn Tsichritzis msr actlr_el2, x0 561b04ea14bSJohn Tsichritzis 562b04ea14bSJohn Tsichritzis /* Enable group0 counters */ 563da6d75a0SJohn Tsichritzis mov x0, #NEOVERSE_N1_AMU_GROUP0_MASK 564b04ea14bSJohn Tsichritzis msr CPUAMCNTENSET_EL0, x0 565b04ea14bSJohn Tsichritzis#endif 566bb2f077aSLouis Mayencourt 56725bbbd2dSJavier Almansa Sobrino#if NEOVERSE_Nx_EXTERNAL_LLC 568f2d6b4eeSManish Pandey /* Some system may have External LLC, core needs to be made aware */ 569f2d6b4eeSManish Pandey mrs x0, NEOVERSE_N1_CPUECTLR_EL1 570f2d6b4eeSManish Pandey orr x0, x0, NEOVERSE_N1_CPUECTLR_EL1_EXTLLC_BIT 571f2d6b4eeSManish Pandey msr NEOVERSE_N1_CPUECTLR_EL1, x0 572f2d6b4eeSManish Pandey#endif 573f2d6b4eeSManish Pandey 574bb2f077aSLouis Mayencourt#if ERRATA_DSU_936184 575bb2f077aSLouis Mayencourt bl errata_dsu_936184_wa 576bb2f077aSLouis Mayencourt#endif 577bb2f077aSLouis Mayencourt 5787d6f7518Slauwal01 isb 579b04ea14bSJohn Tsichritzis ret x19 580da6d75a0SJohn Tsichritzisendfunc neoverse_n1_reset_func 581b04ea14bSJohn Tsichritzis 582b04ea14bSJohn Tsichritzis /* --------------------------------------------- 583b04ea14bSJohn Tsichritzis * HW will do the cache maintenance while powering down 584b04ea14bSJohn Tsichritzis * --------------------------------------------- 585b04ea14bSJohn Tsichritzis */ 586da6d75a0SJohn Tsichritzisfunc neoverse_n1_core_pwr_dwn 587b04ea14bSJohn Tsichritzis /* --------------------------------------------- 588b04ea14bSJohn Tsichritzis * Enable CPU power down bit in power control register 589b04ea14bSJohn Tsichritzis * --------------------------------------------- 590b04ea14bSJohn Tsichritzis */ 591da6d75a0SJohn Tsichritzis mrs x0, NEOVERSE_N1_CPUPWRCTLR_EL1 592da6d75a0SJohn Tsichritzis orr x0, x0, #NEOVERSE_N1_CORE_PWRDN_EN_MASK 593da6d75a0SJohn Tsichritzis msr NEOVERSE_N1_CPUPWRCTLR_EL1, x0 594b04ea14bSJohn Tsichritzis isb 595b04ea14bSJohn Tsichritzis ret 596da6d75a0SJohn Tsichritzisendfunc neoverse_n1_core_pwr_dwn 597b04ea14bSJohn Tsichritzis 598b04ea14bSJohn Tsichritzis#if REPORT_ERRATA 599b04ea14bSJohn Tsichritzis/* 600da6d75a0SJohn Tsichritzis * Errata printing function for Neoverse N1. Must follow AAPCS. 601b04ea14bSJohn Tsichritzis */ 602da6d75a0SJohn Tsichritzisfunc neoverse_n1_errata_report 603b04ea14bSJohn Tsichritzis stp x8, x30, [sp, #-16]! 604b04ea14bSJohn Tsichritzis 605b04ea14bSJohn Tsichritzis bl cpu_get_rev_var 606b04ea14bSJohn Tsichritzis mov x8, x0 607b04ea14bSJohn Tsichritzis 608b04ea14bSJohn Tsichritzis /* 609b04ea14bSJohn Tsichritzis * Report all errata. The revision-variant information is passed to 610b04ea14bSJohn Tsichritzis * checking functions of each errata. 611b04ea14bSJohn Tsichritzis */ 612da6d75a0SJohn Tsichritzis report_errata ERRATA_N1_1043202, neoverse_n1, 1043202 613a601afe1Slauwal01 report_errata ERRATA_N1_1073348, neoverse_n1, 1073348 614e34606f2Slauwal01 report_errata ERRATA_N1_1130799, neoverse_n1, 1130799 6152017ab24Slauwal01 report_errata ERRATA_N1_1165347, neoverse_n1, 1165347 616ef5fa7d4Slauwal01 report_errata ERRATA_N1_1207823, neoverse_n1, 1207823 6179eceb020Slauwal01 report_errata ERRATA_N1_1220197, neoverse_n1, 1220197 618335b3c79Slauwal01 report_errata ERRATA_N1_1257314, neoverse_n1, 1257314 619411f4959Slauwal01 report_errata ERRATA_N1_1262606, neoverse_n1, 1262606 62011c48370Slauwal01 report_errata ERRATA_N1_1262888, neoverse_n1, 1262888 6214d8801feSlauwal01 report_errata ERRATA_N1_1275112, neoverse_n1, 1275112 6225f5d0763SAndre Przywara report_errata ERRATA_N1_1315703, neoverse_n1, 1315703 62380942622Slaurenw-arm report_errata ERRATA_N1_1542419, neoverse_n1, 1542419 62461f0ffc4Sjohpow01 report_errata ERRATA_N1_1868343, neoverse_n1, 1868343 625*263ee781Sjohpow01 report_errata ERRATA_N1_1946160, neoverse_n1, 1946160 626bb2f077aSLouis Mayencourt report_errata ERRATA_DSU_936184, neoverse_n1, dsu_936184 627b04ea14bSJohn Tsichritzis 628b04ea14bSJohn Tsichritzis ldp x8, x30, [sp], #16 629b04ea14bSJohn Tsichritzis ret 630da6d75a0SJohn Tsichritzisendfunc neoverse_n1_errata_report 631b04ea14bSJohn Tsichritzis#endif 632b04ea14bSJohn Tsichritzis 63380942622Slaurenw-arm/* 63480942622Slaurenw-arm * Handle trap of EL0 IC IVAU instructions to EL3 by executing a TLB 63580942622Slaurenw-arm * inner-shareable invalidation to an arbitrary address followed by a DSB. 63680942622Slaurenw-arm * 63780942622Slaurenw-arm * x1: Exception Syndrome 63880942622Slaurenw-arm */ 63980942622Slaurenw-armfunc neoverse_n1_errata_ic_trap_handler 64080942622Slaurenw-arm cmp x1, #NEOVERSE_N1_EC_IC_TRAP 64180942622Slaurenw-arm b.ne 1f 64280942622Slaurenw-arm tlbi vae3is, xzr 64380942622Slaurenw-arm dsb sy 64480942622Slaurenw-arm 64580942622Slaurenw-arm # Skip the IC instruction itself 64680942622Slaurenw-arm mrs x3, elr_el3 64780942622Slaurenw-arm add x3, x3, #4 64880942622Slaurenw-arm msr elr_el3, x3 64980942622Slaurenw-arm 65080942622Slaurenw-arm ldp x0, x1, [sp, #CTX_GPREGS_OFFSET + CTX_GPREG_X0] 65180942622Slaurenw-arm ldp x2, x3, [sp, #CTX_GPREGS_OFFSET + CTX_GPREG_X2] 65280942622Slaurenw-arm ldp x4, x5, [sp, #CTX_GPREGS_OFFSET + CTX_GPREG_X4] 65380942622Slaurenw-arm ldr x30, [sp, #CTX_GPREGS_OFFSET + CTX_GPREG_LR] 65480942622Slaurenw-arm 65580942622Slaurenw-arm#if IMAGE_BL31 && RAS_EXTENSION 65680942622Slaurenw-arm /* 65780942622Slaurenw-arm * Issue Error Synchronization Barrier to synchronize SErrors before 65880942622Slaurenw-arm * exiting EL3. We're running with EAs unmasked, so any synchronized 65980942622Slaurenw-arm * errors would be taken immediately; therefore no need to inspect 66080942622Slaurenw-arm * DISR_EL1 register. 66180942622Slaurenw-arm */ 66280942622Slaurenw-arm esb 66380942622Slaurenw-arm#endif 664f461fe34SAnthony Steinhauser exception_return 66580942622Slaurenw-arm1: 66680942622Slaurenw-arm ret 66780942622Slaurenw-armendfunc neoverse_n1_errata_ic_trap_handler 66880942622Slaurenw-arm 669b04ea14bSJohn Tsichritzis /* --------------------------------------------- 670da6d75a0SJohn Tsichritzis * This function provides neoverse_n1 specific 671b04ea14bSJohn Tsichritzis * register information for crash reporting. 672b04ea14bSJohn Tsichritzis * It needs to return with x6 pointing to 673b04ea14bSJohn Tsichritzis * a list of register names in ascii and 674b04ea14bSJohn Tsichritzis * x8 - x15 having values of registers to be 675b04ea14bSJohn Tsichritzis * reported. 676b04ea14bSJohn Tsichritzis * --------------------------------------------- 677b04ea14bSJohn Tsichritzis */ 678da6d75a0SJohn Tsichritzis.section .rodata.neoverse_n1_regs, "aS" 679da6d75a0SJohn Tsichritzisneoverse_n1_regs: /* The ascii list of register names to be reported */ 680b04ea14bSJohn Tsichritzis .asciz "cpuectlr_el1", "" 681b04ea14bSJohn Tsichritzis 682da6d75a0SJohn Tsichritzisfunc neoverse_n1_cpu_reg_dump 683da6d75a0SJohn Tsichritzis adr x6, neoverse_n1_regs 684da6d75a0SJohn Tsichritzis mrs x8, NEOVERSE_N1_CPUECTLR_EL1 685b04ea14bSJohn Tsichritzis ret 686da6d75a0SJohn Tsichritzisendfunc neoverse_n1_cpu_reg_dump 687b04ea14bSJohn Tsichritzis 68880942622Slaurenw-armdeclare_cpu_ops_eh neoverse_n1, NEOVERSE_N1_MIDR, \ 689da6d75a0SJohn Tsichritzis neoverse_n1_reset_func, \ 69080942622Slaurenw-arm neoverse_n1_errata_ic_trap_handler, \ 691da6d75a0SJohn Tsichritzis neoverse_n1_core_pwr_dwn 692