1b04ea14bSJohn Tsichritzis/* 2f461fe34SAnthony Steinhauser * Copyright (c) 2017-2020, 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> 9da6d75a0SJohn Tsichritzis#include <neoverse_n1.h> 10b04ea14bSJohn Tsichritzis#include <cpuamu.h> 11b04ea14bSJohn Tsichritzis#include <cpu_macros.S> 1280942622Slaurenw-arm#include <context.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 25942013e1SPramod Kumar .global is_scu_present_in_dsu 26942013e1SPramod Kumar 27942013e1SPramod Kumar/* 28942013e1SPramod Kumar * Check DSU is configured with SCU and L3 unit 29942013e1SPramod Kumar * 1-> SCU present 30942013e1SPramod Kumar * 0-> SCU not present 31942013e1SPramod Kumar */ 32942013e1SPramod Kumarfunc is_scu_present_in_dsu 33942013e1SPramod Kumar mrs x0, CPUCFR_EL1 34942013e1SPramod Kumar ubfx x0, x0, #SCU_SHIFT, #1 35942013e1SPramod Kumar eor x0, x0, #1 36942013e1SPramod Kumar ret 37942013e1SPramod Kumarendfunc is_scu_present_in_dsu 3880942622Slaurenw-arm 39b04ea14bSJohn Tsichritzis/* -------------------------------------------------- 405f5d0763SAndre Przywara * Errata Workaround for Neoverse N1 Erratum 1043202. 41da6d75a0SJohn Tsichritzis * This applies to revision r0p0 and r1p0 of Neoverse N1. 42b04ea14bSJohn Tsichritzis * Inputs: 43b04ea14bSJohn Tsichritzis * x0: variant[4:7] and revision[0:3] of current cpu. 44b04ea14bSJohn Tsichritzis * Shall clobber: x0-x17 45b04ea14bSJohn Tsichritzis * -------------------------------------------------- 46b04ea14bSJohn Tsichritzis */ 47da6d75a0SJohn Tsichritzisfunc errata_n1_1043202_wa 48b04ea14bSJohn Tsichritzis /* Compare x0 against revision r1p0 */ 49b04ea14bSJohn Tsichritzis mov x17, x30 50b04ea14bSJohn Tsichritzis bl check_errata_1043202 51b04ea14bSJohn Tsichritzis cbz x0, 1f 52b04ea14bSJohn Tsichritzis 53b04ea14bSJohn Tsichritzis /* Apply instruction patching sequence */ 54b04ea14bSJohn Tsichritzis ldr x0, =0x0 55b04ea14bSJohn Tsichritzis msr CPUPSELR_EL3, x0 56b04ea14bSJohn Tsichritzis ldr x0, =0xF3BF8F2F 57b04ea14bSJohn Tsichritzis msr CPUPOR_EL3, x0 58b04ea14bSJohn Tsichritzis ldr x0, =0xFFFFFFFF 59b04ea14bSJohn Tsichritzis msr CPUPMR_EL3, x0 60b04ea14bSJohn Tsichritzis ldr x0, =0x800200071 61b04ea14bSJohn Tsichritzis msr CPUPCR_EL3, x0 62a33ec1e7Slaurenw-arm isb 63b04ea14bSJohn Tsichritzis1: 64b04ea14bSJohn Tsichritzis ret x17 65da6d75a0SJohn Tsichritzisendfunc errata_n1_1043202_wa 66b04ea14bSJohn Tsichritzis 67b04ea14bSJohn Tsichritzisfunc check_errata_1043202 68b04ea14bSJohn Tsichritzis /* Applies to r0p0 and r1p0 */ 69b04ea14bSJohn Tsichritzis mov x1, #0x10 70b04ea14bSJohn Tsichritzis b cpu_rev_var_ls 71b04ea14bSJohn Tsichritzisendfunc check_errata_1043202 72b04ea14bSJohn Tsichritzis 73eca6e453SSami Mujawar/* -------------------------------------------------- 74eca6e453SSami Mujawar * Disable speculative loads if Neoverse N1 supports 75eca6e453SSami Mujawar * SSBS. 76eca6e453SSami Mujawar * 77eca6e453SSami Mujawar * Shall clobber: x0. 78eca6e453SSami Mujawar * -------------------------------------------------- 79eca6e453SSami Mujawar */ 80eca6e453SSami Mujawarfunc neoverse_n1_disable_speculative_loads 81eca6e453SSami Mujawar /* Check if the PE implements SSBS */ 82eca6e453SSami Mujawar mrs x0, id_aa64pfr1_el1 83eca6e453SSami Mujawar tst x0, #(ID_AA64PFR1_EL1_SSBS_MASK << ID_AA64PFR1_EL1_SSBS_SHIFT) 84eca6e453SSami Mujawar b.eq 1f 85eca6e453SSami Mujawar 86eca6e453SSami Mujawar /* Disable speculative loads */ 87eca6e453SSami Mujawar msr SSBS, xzr 88eca6e453SSami Mujawar 89eca6e453SSami Mujawar1: 90eca6e453SSami Mujawar ret 91eca6e453SSami Mujawarendfunc neoverse_n1_disable_speculative_loads 92eca6e453SSami Mujawar 935f5d0763SAndre Przywara/* -------------------------------------------------- 94a601afe1Slauwal01 * Errata Workaround for Neoverse N1 Errata #1073348 95a601afe1Slauwal01 * This applies to revision r0p0 and r1p0 of Neoverse N1. 96a601afe1Slauwal01 * Inputs: 97a601afe1Slauwal01 * x0: variant[4:7] and revision[0:3] of current cpu. 98a601afe1Slauwal01 * Shall clobber: x0-x17 99a601afe1Slauwal01 * -------------------------------------------------- 100a601afe1Slauwal01 */ 101a601afe1Slauwal01func errata_n1_1073348_wa 102a601afe1Slauwal01 /* Compare x0 against revision r1p0 */ 103a601afe1Slauwal01 mov x17, x30 104a601afe1Slauwal01 bl check_errata_1073348 105a601afe1Slauwal01 cbz x0, 1f 106a601afe1Slauwal01 mrs x1, NEOVERSE_N1_CPUACTLR_EL1 107a601afe1Slauwal01 orr x1, x1, NEOVERSE_N1_CPUACTLR_EL1_BIT_6 108a601afe1Slauwal01 msr NEOVERSE_N1_CPUACTLR_EL1, x1 109a601afe1Slauwal011: 110a601afe1Slauwal01 ret x17 111a601afe1Slauwal01endfunc errata_n1_1073348_wa 112a601afe1Slauwal01 113a601afe1Slauwal01func check_errata_1073348 114a601afe1Slauwal01 /* Applies to r0p0 and r1p0 */ 115a601afe1Slauwal01 mov x1, #0x10 116a601afe1Slauwal01 b cpu_rev_var_ls 117a601afe1Slauwal01endfunc check_errata_1073348 118a601afe1Slauwal01 119a601afe1Slauwal01/* -------------------------------------------------- 120e34606f2Slauwal01 * Errata Workaround for Neoverse N1 Errata #1130799 121e34606f2Slauwal01 * This applies to revision <=r2p0 of Neoverse N1. 122e34606f2Slauwal01 * Inputs: 123e34606f2Slauwal01 * x0: variant[4:7] and revision[0:3] of current cpu. 124e34606f2Slauwal01 * Shall clobber: x0-x17 125e34606f2Slauwal01 * -------------------------------------------------- 126e34606f2Slauwal01 */ 127e34606f2Slauwal01func errata_n1_1130799_wa 128e34606f2Slauwal01 /* Compare x0 against revision r2p0 */ 129e34606f2Slauwal01 mov x17, x30 130e34606f2Slauwal01 bl check_errata_1130799 131e34606f2Slauwal01 cbz x0, 1f 132e34606f2Slauwal01 mrs x1, NEOVERSE_N1_CPUACTLR2_EL1 133e34606f2Slauwal01 orr x1, x1, NEOVERSE_N1_CPUACTLR2_EL1_BIT_59 134e34606f2Slauwal01 msr NEOVERSE_N1_CPUACTLR2_EL1, x1 135e34606f2Slauwal011: 136e34606f2Slauwal01 ret x17 137e34606f2Slauwal01endfunc errata_n1_1130799_wa 138e34606f2Slauwal01 139e34606f2Slauwal01func check_errata_1130799 140e34606f2Slauwal01 /* Applies to <=r2p0 */ 141e34606f2Slauwal01 mov x1, #0x20 142e34606f2Slauwal01 b cpu_rev_var_ls 143e34606f2Slauwal01endfunc check_errata_1130799 144e34606f2Slauwal01 145e34606f2Slauwal01/* -------------------------------------------------- 1462017ab24Slauwal01 * Errata Workaround for Neoverse N1 Errata #1165347 1472017ab24Slauwal01 * This applies to revision <=r2p0 of Neoverse N1. 1482017ab24Slauwal01 * Inputs: 1492017ab24Slauwal01 * x0: variant[4:7] and revision[0:3] of current cpu. 1502017ab24Slauwal01 * Shall clobber: x0-x17 1512017ab24Slauwal01 * -------------------------------------------------- 1522017ab24Slauwal01 */ 1532017ab24Slauwal01func errata_n1_1165347_wa 1542017ab24Slauwal01 /* Compare x0 against revision r2p0 */ 1552017ab24Slauwal01 mov x17, x30 1562017ab24Slauwal01 bl check_errata_1165347 1572017ab24Slauwal01 cbz x0, 1f 1582017ab24Slauwal01 mrs x1, NEOVERSE_N1_CPUACTLR2_EL1 1592017ab24Slauwal01 orr x1, x1, NEOVERSE_N1_CPUACTLR2_EL1_BIT_0 1602017ab24Slauwal01 orr x1, x1, NEOVERSE_N1_CPUACTLR2_EL1_BIT_15 1612017ab24Slauwal01 msr NEOVERSE_N1_CPUACTLR2_EL1, x1 1622017ab24Slauwal011: 1632017ab24Slauwal01 ret x17 1642017ab24Slauwal01endfunc errata_n1_1165347_wa 1652017ab24Slauwal01 1662017ab24Slauwal01func check_errata_1165347 1672017ab24Slauwal01 /* Applies to <=r2p0 */ 1682017ab24Slauwal01 mov x1, #0x20 1692017ab24Slauwal01 b cpu_rev_var_ls 1702017ab24Slauwal01endfunc check_errata_1165347 1712017ab24Slauwal01 1722017ab24Slauwal01/* -------------------------------------------------- 173ef5fa7d4Slauwal01 * Errata Workaround for Neoverse N1 Errata #1207823 174ef5fa7d4Slauwal01 * This applies to revision <=r2p0 of Neoverse N1. 175ef5fa7d4Slauwal01 * Inputs: 176ef5fa7d4Slauwal01 * x0: variant[4:7] and revision[0:3] of current cpu. 177ef5fa7d4Slauwal01 * Shall clobber: x0-x17 178ef5fa7d4Slauwal01 * -------------------------------------------------- 179ef5fa7d4Slauwal01 */ 180ef5fa7d4Slauwal01func errata_n1_1207823_wa 181ef5fa7d4Slauwal01 /* Compare x0 against revision r2p0 */ 182ef5fa7d4Slauwal01 mov x17, x30 183ef5fa7d4Slauwal01 bl check_errata_1207823 184ef5fa7d4Slauwal01 cbz x0, 1f 185ef5fa7d4Slauwal01 mrs x1, NEOVERSE_N1_CPUACTLR2_EL1 186ef5fa7d4Slauwal01 orr x1, x1, NEOVERSE_N1_CPUACTLR2_EL1_BIT_11 187ef5fa7d4Slauwal01 msr NEOVERSE_N1_CPUACTLR2_EL1, x1 188ef5fa7d4Slauwal011: 189ef5fa7d4Slauwal01 ret x17 190ef5fa7d4Slauwal01endfunc errata_n1_1207823_wa 191ef5fa7d4Slauwal01 192ef5fa7d4Slauwal01func check_errata_1207823 193ef5fa7d4Slauwal01 /* Applies to <=r2p0 */ 194ef5fa7d4Slauwal01 mov x1, #0x20 195ef5fa7d4Slauwal01 b cpu_rev_var_ls 196ef5fa7d4Slauwal01endfunc check_errata_1207823 197ef5fa7d4Slauwal01 198ef5fa7d4Slauwal01/* -------------------------------------------------- 1999eceb020Slauwal01 * Errata Workaround for Neoverse N1 Errata #1220197 2009eceb020Slauwal01 * This applies to revision <=r2p0 of Neoverse N1. 2019eceb020Slauwal01 * Inputs: 2029eceb020Slauwal01 * x0: variant[4:7] and revision[0:3] of current cpu. 2039eceb020Slauwal01 * Shall clobber: x0-x17 2049eceb020Slauwal01 * -------------------------------------------------- 2059eceb020Slauwal01 */ 2069eceb020Slauwal01func errata_n1_1220197_wa 2079eceb020Slauwal01 /* Compare x0 against revision r2p0 */ 2089eceb020Slauwal01 mov x17, x30 2099eceb020Slauwal01 bl check_errata_1220197 2109eceb020Slauwal01 cbz x0, 1f 2119eceb020Slauwal01 mrs x1, NEOVERSE_N1_CPUECTLR_EL1 2129eceb020Slauwal01 orr x1, x1, NEOVERSE_N1_WS_THR_L2_MASK 2139eceb020Slauwal01 msr NEOVERSE_N1_CPUECTLR_EL1, x1 2149eceb020Slauwal011: 2159eceb020Slauwal01 ret x17 2169eceb020Slauwal01endfunc errata_n1_1220197_wa 2179eceb020Slauwal01 2189eceb020Slauwal01func check_errata_1220197 2199eceb020Slauwal01 /* Applies to <=r2p0 */ 2209eceb020Slauwal01 mov x1, #0x20 2219eceb020Slauwal01 b cpu_rev_var_ls 2229eceb020Slauwal01endfunc check_errata_1220197 2239eceb020Slauwal01 2249eceb020Slauwal01/* -------------------------------------------------- 225335b3c79Slauwal01 * Errata Workaround for Neoverse N1 Errata #1257314 226335b3c79Slauwal01 * This applies to revision <=r3p0 of Neoverse N1. 227335b3c79Slauwal01 * Inputs: 228335b3c79Slauwal01 * x0: variant[4:7] and revision[0:3] of current cpu. 229335b3c79Slauwal01 * Shall clobber: x0-x17 230335b3c79Slauwal01 * -------------------------------------------------- 231335b3c79Slauwal01 */ 232335b3c79Slauwal01func errata_n1_1257314_wa 233335b3c79Slauwal01 /* Compare x0 against revision r3p0 */ 234335b3c79Slauwal01 mov x17, x30 235335b3c79Slauwal01 bl check_errata_1257314 236335b3c79Slauwal01 cbz x0, 1f 237335b3c79Slauwal01 mrs x1, NEOVERSE_N1_CPUACTLR3_EL1 238335b3c79Slauwal01 orr x1, x1, NEOVERSE_N1_CPUACTLR3_EL1_BIT_10 239335b3c79Slauwal01 msr NEOVERSE_N1_CPUACTLR3_EL1, x1 240335b3c79Slauwal011: 241335b3c79Slauwal01 ret x17 242335b3c79Slauwal01endfunc errata_n1_1257314_wa 243335b3c79Slauwal01 244335b3c79Slauwal01func check_errata_1257314 245335b3c79Slauwal01 /* Applies to <=r3p0 */ 246335b3c79Slauwal01 mov x1, #0x30 247335b3c79Slauwal01 b cpu_rev_var_ls 248335b3c79Slauwal01endfunc check_errata_1257314 249335b3c79Slauwal01 250335b3c79Slauwal01/* -------------------------------------------------- 251411f4959Slauwal01 * Errata Workaround for Neoverse N1 Errata #1262606 252411f4959Slauwal01 * This applies to revision <=r3p0 of Neoverse N1. 253411f4959Slauwal01 * Inputs: 254411f4959Slauwal01 * x0: variant[4:7] and revision[0:3] of current cpu. 255411f4959Slauwal01 * Shall clobber: x0-x17 256411f4959Slauwal01 * -------------------------------------------------- 257411f4959Slauwal01 */ 258411f4959Slauwal01func errata_n1_1262606_wa 259411f4959Slauwal01 /* Compare x0 against revision r3p0 */ 260411f4959Slauwal01 mov x17, x30 261411f4959Slauwal01 bl check_errata_1262606 262411f4959Slauwal01 cbz x0, 1f 263411f4959Slauwal01 mrs x1, NEOVERSE_N1_CPUACTLR_EL1 264411f4959Slauwal01 orr x1, x1, NEOVERSE_N1_CPUACTLR_EL1_BIT_13 265411f4959Slauwal01 msr NEOVERSE_N1_CPUACTLR_EL1, x1 266411f4959Slauwal011: 267411f4959Slauwal01 ret x17 268411f4959Slauwal01endfunc errata_n1_1262606_wa 269411f4959Slauwal01 270411f4959Slauwal01func check_errata_1262606 271411f4959Slauwal01 /* Applies to <=r3p0 */ 272411f4959Slauwal01 mov x1, #0x30 273411f4959Slauwal01 b cpu_rev_var_ls 274411f4959Slauwal01endfunc check_errata_1262606 275411f4959Slauwal01 276411f4959Slauwal01/* -------------------------------------------------- 27711c48370Slauwal01 * Errata Workaround for Neoverse N1 Errata #1262888 27811c48370Slauwal01 * This applies to revision <=r3p0 of Neoverse N1. 27911c48370Slauwal01 * Inputs: 28011c48370Slauwal01 * x0: variant[4:7] and revision[0:3] of current cpu. 28111c48370Slauwal01 * Shall clobber: x0-x17 28211c48370Slauwal01 * -------------------------------------------------- 28311c48370Slauwal01 */ 28411c48370Slauwal01func errata_n1_1262888_wa 28511c48370Slauwal01 /* Compare x0 against revision r3p0 */ 28611c48370Slauwal01 mov x17, x30 28711c48370Slauwal01 bl check_errata_1262888 28811c48370Slauwal01 cbz x0, 1f 28911c48370Slauwal01 mrs x1, NEOVERSE_N1_CPUECTLR_EL1 29011c48370Slauwal01 orr x1, x1, NEOVERSE_N1_CPUECTLR_EL1_MM_TLBPF_DIS_BIT 29111c48370Slauwal01 msr NEOVERSE_N1_CPUECTLR_EL1, x1 29211c48370Slauwal011: 29311c48370Slauwal01 ret x17 29411c48370Slauwal01endfunc errata_n1_1262888_wa 29511c48370Slauwal01 29611c48370Slauwal01func check_errata_1262888 29711c48370Slauwal01 /* Applies to <=r3p0 */ 29811c48370Slauwal01 mov x1, #0x30 29911c48370Slauwal01 b cpu_rev_var_ls 30011c48370Slauwal01endfunc check_errata_1262888 30111c48370Slauwal01 30211c48370Slauwal01/* -------------------------------------------------- 3034d8801feSlauwal01 * Errata Workaround for Neoverse N1 Errata #1275112 3044d8801feSlauwal01 * This applies to revision <=r3p0 of Neoverse N1. 3054d8801feSlauwal01 * Inputs: 3064d8801feSlauwal01 * x0: variant[4:7] and revision[0:3] of current cpu. 3074d8801feSlauwal01 * Shall clobber: x0-x17 3084d8801feSlauwal01 * -------------------------------------------------- 3094d8801feSlauwal01 */ 3104d8801feSlauwal01func errata_n1_1275112_wa 3114d8801feSlauwal01 /* Compare x0 against revision r3p0 */ 3124d8801feSlauwal01 mov x17, x30 3134d8801feSlauwal01 bl check_errata_1275112 3144d8801feSlauwal01 cbz x0, 1f 3154d8801feSlauwal01 mrs x1, NEOVERSE_N1_CPUACTLR_EL1 3164d8801feSlauwal01 orr x1, x1, NEOVERSE_N1_CPUACTLR_EL1_BIT_13 3174d8801feSlauwal01 msr NEOVERSE_N1_CPUACTLR_EL1, x1 3184d8801feSlauwal011: 3194d8801feSlauwal01 ret x17 3204d8801feSlauwal01endfunc errata_n1_1275112_wa 3214d8801feSlauwal01 3224d8801feSlauwal01func check_errata_1275112 3234d8801feSlauwal01 /* Applies to <=r3p0 */ 3244d8801feSlauwal01 mov x1, #0x30 3254d8801feSlauwal01 b cpu_rev_var_ls 3264d8801feSlauwal01endfunc check_errata_1275112 3274d8801feSlauwal01 3284d8801feSlauwal01/* -------------------------------------------------- 3295f5d0763SAndre Przywara * Errata Workaround for Neoverse N1 Erratum 1315703. 3305f5d0763SAndre Przywara * This applies to revision <= r3p0 of Neoverse N1. 3315f5d0763SAndre Przywara * Inputs: 3325f5d0763SAndre Przywara * x0: variant[4:7] and revision[0:3] of current cpu. 3335f5d0763SAndre Przywara * Shall clobber: x0-x17 3345f5d0763SAndre Przywara * -------------------------------------------------- 3355f5d0763SAndre Przywara */ 3365f5d0763SAndre Przywarafunc errata_n1_1315703_wa 3375f5d0763SAndre Przywara /* Compare x0 against revision r3p1 */ 3385f5d0763SAndre Przywara mov x17, x30 3395f5d0763SAndre Przywara bl check_errata_1315703 3405f5d0763SAndre Przywara cbz x0, 1f 3415f5d0763SAndre Przywara 3425f5d0763SAndre Przywara mrs x0, NEOVERSE_N1_CPUACTLR2_EL1 3435f5d0763SAndre Przywara orr x0, x0, #NEOVERSE_N1_CPUACTLR2_EL1_BIT_16 3445f5d0763SAndre Przywara msr NEOVERSE_N1_CPUACTLR2_EL1, x0 3455f5d0763SAndre Przywara 3465f5d0763SAndre Przywara1: 3475f5d0763SAndre Przywara ret x17 3485f5d0763SAndre Przywaraendfunc errata_n1_1315703_wa 3495f5d0763SAndre Przywara 3505f5d0763SAndre Przywarafunc check_errata_1315703 3515f5d0763SAndre Przywara /* Applies to everything <= r3p0. */ 3525f5d0763SAndre Przywara mov x1, #0x30 3535f5d0763SAndre Przywara b cpu_rev_var_ls 3545f5d0763SAndre Przywaraendfunc check_errata_1315703 3555f5d0763SAndre Przywara 35680942622Slaurenw-arm/* -------------------------------------------------- 35780942622Slaurenw-arm * Errata Workaround for Neoverse N1 Erratum 1542419. 35880942622Slaurenw-arm * This applies to revisions r3p0 - r4p0 of Neoverse N1 35980942622Slaurenw-arm * Inputs: 36080942622Slaurenw-arm * x0: variant[4:7] and revision[0:3] of current cpu. 36180942622Slaurenw-arm * Shall clobber: x0-x17 36280942622Slaurenw-arm * -------------------------------------------------- 36380942622Slaurenw-arm */ 36480942622Slaurenw-armfunc errata_n1_1542419_wa 36580942622Slaurenw-arm /* Compare x0 against revision r3p0 and r4p0 */ 36680942622Slaurenw-arm mov x17, x30 36780942622Slaurenw-arm bl check_errata_1542419 36880942622Slaurenw-arm cbz x0, 1f 36980942622Slaurenw-arm 37080942622Slaurenw-arm /* Apply instruction patching sequence */ 37180942622Slaurenw-arm ldr x0, =0x0 37280942622Slaurenw-arm msr CPUPSELR_EL3, x0 37380942622Slaurenw-arm ldr x0, =0xEE670D35 37480942622Slaurenw-arm msr CPUPOR_EL3, x0 37580942622Slaurenw-arm ldr x0, =0xFFFF0FFF 37680942622Slaurenw-arm msr CPUPMR_EL3, x0 37780942622Slaurenw-arm ldr x0, =0x08000020007D 37880942622Slaurenw-arm msr CPUPCR_EL3, x0 37980942622Slaurenw-arm isb 38080942622Slaurenw-arm1: 38180942622Slaurenw-arm ret x17 38280942622Slaurenw-armendfunc errata_n1_1542419_wa 38380942622Slaurenw-arm 38480942622Slaurenw-armfunc check_errata_1542419 38580942622Slaurenw-arm /* Applies to everything r3p0 - r4p0. */ 38680942622Slaurenw-arm mov x1, #0x30 38780942622Slaurenw-arm mov x2, #0x40 38880942622Slaurenw-arm b cpu_rev_var_range 38980942622Slaurenw-armendfunc check_errata_1542419 39080942622Slaurenw-arm 391*61f0ffc4Sjohpow01 /* -------------------------------------------------- 392*61f0ffc4Sjohpow01 * Errata Workaround for Neoverse N1 Errata #1868343. 393*61f0ffc4Sjohpow01 * This applies to revision <= r4p0 of Neoverse N1. 394*61f0ffc4Sjohpow01 * This workaround is the same as the workaround for 395*61f0ffc4Sjohpow01 * errata 1262606 and 1275112 but applies to a wider 396*61f0ffc4Sjohpow01 * revision range. 397*61f0ffc4Sjohpow01 * Inputs: 398*61f0ffc4Sjohpow01 * x0: variant[4:7] and revision[0:3] of current cpu. 399*61f0ffc4Sjohpow01 * Shall clobber: x0-x17 400*61f0ffc4Sjohpow01 * -------------------------------------------------- 401*61f0ffc4Sjohpow01 */ 402*61f0ffc4Sjohpow01func errata_n1_1868343_wa 403*61f0ffc4Sjohpow01 /* 404*61f0ffc4Sjohpow01 * Compare x0 against revision r4p0 405*61f0ffc4Sjohpow01 */ 406*61f0ffc4Sjohpow01 mov x17, x30 407*61f0ffc4Sjohpow01 bl check_errata_1868343 408*61f0ffc4Sjohpow01 cbz x0, 1f 409*61f0ffc4Sjohpow01 mrs x1, NEOVERSE_N1_CPUACTLR_EL1 410*61f0ffc4Sjohpow01 orr x1, x1, NEOVERSE_N1_CPUACTLR_EL1_BIT_13 411*61f0ffc4Sjohpow01 msr NEOVERSE_N1_CPUACTLR_EL1, x1 412*61f0ffc4Sjohpow01 isb 413*61f0ffc4Sjohpow011: 414*61f0ffc4Sjohpow01 ret x17 415*61f0ffc4Sjohpow01endfunc errata_n1_1868343_wa 416*61f0ffc4Sjohpow01 417*61f0ffc4Sjohpow01func check_errata_1868343 418*61f0ffc4Sjohpow01 /* Applies to everything <= r4p0 */ 419*61f0ffc4Sjohpow01 mov x1, #0x40 420*61f0ffc4Sjohpow01 b cpu_rev_var_ls 421*61f0ffc4Sjohpow01endfunc check_errata_1868343 422*61f0ffc4Sjohpow01 423da6d75a0SJohn Tsichritzisfunc neoverse_n1_reset_func 424b04ea14bSJohn Tsichritzis mov x19, x30 4258074448fSJohn Tsichritzis 426eca6e453SSami Mujawar bl neoverse_n1_disable_speculative_loads 4278074448fSJohn Tsichritzis 428632ab3ebSLouis Mayencourt /* Forces all cacheable atomic instructions to be near */ 429632ab3ebSLouis Mayencourt mrs x0, NEOVERSE_N1_CPUACTLR2_EL1 430632ab3ebSLouis Mayencourt orr x0, x0, #NEOVERSE_N1_CPUACTLR2_EL1_BIT_2 431632ab3ebSLouis Mayencourt msr NEOVERSE_N1_CPUACTLR2_EL1, x0 432632ab3ebSLouis Mayencourt isb 433632ab3ebSLouis Mayencourt 434b04ea14bSJohn Tsichritzis bl cpu_get_rev_var 435b04ea14bSJohn Tsichritzis mov x18, x0 436b04ea14bSJohn Tsichritzis 437da6d75a0SJohn Tsichritzis#if ERRATA_N1_1043202 438b04ea14bSJohn Tsichritzis mov x0, x18 439da6d75a0SJohn Tsichritzis bl errata_n1_1043202_wa 440b04ea14bSJohn Tsichritzis#endif 441b04ea14bSJohn Tsichritzis 442a601afe1Slauwal01#if ERRATA_N1_1073348 443a601afe1Slauwal01 mov x0, x18 444a601afe1Slauwal01 bl errata_n1_1073348_wa 445a601afe1Slauwal01#endif 446a601afe1Slauwal01 447e34606f2Slauwal01#if ERRATA_N1_1130799 448e34606f2Slauwal01 mov x0, x18 449e34606f2Slauwal01 bl errata_n1_1130799_wa 450e34606f2Slauwal01#endif 451e34606f2Slauwal01 4522017ab24Slauwal01#if ERRATA_N1_1165347 4532017ab24Slauwal01 mov x0, x18 4542017ab24Slauwal01 bl errata_n1_1165347_wa 4552017ab24Slauwal01#endif 4562017ab24Slauwal01 457ef5fa7d4Slauwal01#if ERRATA_N1_1207823 458ef5fa7d4Slauwal01 mov x0, x18 459ef5fa7d4Slauwal01 bl errata_n1_1207823_wa 460ef5fa7d4Slauwal01#endif 461ef5fa7d4Slauwal01 4629eceb020Slauwal01#if ERRATA_N1_1220197 4639eceb020Slauwal01 mov x0, x18 4649eceb020Slauwal01 bl errata_n1_1220197_wa 4659eceb020Slauwal01#endif 4669eceb020Slauwal01 467335b3c79Slauwal01#if ERRATA_N1_1257314 468335b3c79Slauwal01 mov x0, x18 469335b3c79Slauwal01 bl errata_n1_1257314_wa 470335b3c79Slauwal01#endif 471335b3c79Slauwal01 472411f4959Slauwal01#if ERRATA_N1_1262606 473411f4959Slauwal01 mov x0, x18 474411f4959Slauwal01 bl errata_n1_1262606_wa 475411f4959Slauwal01#endif 476411f4959Slauwal01 47711c48370Slauwal01#if ERRATA_N1_1262888 47811c48370Slauwal01 mov x0, x18 47911c48370Slauwal01 bl errata_n1_1262888_wa 48011c48370Slauwal01#endif 48111c48370Slauwal01 4824d8801feSlauwal01#if ERRATA_N1_1275112 4834d8801feSlauwal01 mov x0, x18 4844d8801feSlauwal01 bl errata_n1_1275112_wa 4854d8801feSlauwal01#endif 4864d8801feSlauwal01 4875f5d0763SAndre Przywara#if ERRATA_N1_1315703 4885f5d0763SAndre Przywara mov x0, x18 4895f5d0763SAndre Przywara bl errata_n1_1315703_wa 4905f5d0763SAndre Przywara#endif 4915f5d0763SAndre Przywara 49280942622Slaurenw-arm#if ERRATA_N1_1542419 49380942622Slaurenw-arm mov x0, x18 49480942622Slaurenw-arm bl errata_n1_1542419_wa 49580942622Slaurenw-arm#endif 49680942622Slaurenw-arm 497*61f0ffc4Sjohpow01#if ERRATA_N1_1868343 498*61f0ffc4Sjohpow01 mov x0, x18 499*61f0ffc4Sjohpow01 bl errata_n1_1868343_wa 500*61f0ffc4Sjohpow01#endif 501*61f0ffc4Sjohpow01 502b04ea14bSJohn Tsichritzis#if ENABLE_AMU 503b04ea14bSJohn Tsichritzis /* Make sure accesses from EL0/EL1 and EL2 are not trapped to EL3 */ 504b04ea14bSJohn Tsichritzis mrs x0, actlr_el3 505da6d75a0SJohn Tsichritzis orr x0, x0, #NEOVERSE_N1_ACTLR_AMEN_BIT 506b04ea14bSJohn Tsichritzis msr actlr_el3, x0 507b04ea14bSJohn Tsichritzis 508b04ea14bSJohn Tsichritzis /* Make sure accesses from EL0/EL1 are not trapped to EL2 */ 509b04ea14bSJohn Tsichritzis mrs x0, actlr_el2 510da6d75a0SJohn Tsichritzis orr x0, x0, #NEOVERSE_N1_ACTLR_AMEN_BIT 511b04ea14bSJohn Tsichritzis msr actlr_el2, x0 512b04ea14bSJohn Tsichritzis 513b04ea14bSJohn Tsichritzis /* Enable group0 counters */ 514da6d75a0SJohn Tsichritzis mov x0, #NEOVERSE_N1_AMU_GROUP0_MASK 515b04ea14bSJohn Tsichritzis msr CPUAMCNTENSET_EL0, x0 516b04ea14bSJohn Tsichritzis#endif 517bb2f077aSLouis Mayencourt 518f2d6b4eeSManish Pandey#if NEOVERSE_N1_EXTERNAL_LLC 519f2d6b4eeSManish Pandey /* Some system may have External LLC, core needs to be made aware */ 520f2d6b4eeSManish Pandey mrs x0, NEOVERSE_N1_CPUECTLR_EL1 521f2d6b4eeSManish Pandey orr x0, x0, NEOVERSE_N1_CPUECTLR_EL1_EXTLLC_BIT 522f2d6b4eeSManish Pandey msr NEOVERSE_N1_CPUECTLR_EL1, x0 523f2d6b4eeSManish Pandey#endif 524f2d6b4eeSManish Pandey 525bb2f077aSLouis Mayencourt#if ERRATA_DSU_936184 526bb2f077aSLouis Mayencourt bl errata_dsu_936184_wa 527bb2f077aSLouis Mayencourt#endif 528bb2f077aSLouis Mayencourt 5297d6f7518Slauwal01 isb 530b04ea14bSJohn Tsichritzis ret x19 531da6d75a0SJohn Tsichritzisendfunc neoverse_n1_reset_func 532b04ea14bSJohn Tsichritzis 533b04ea14bSJohn Tsichritzis /* --------------------------------------------- 534b04ea14bSJohn Tsichritzis * HW will do the cache maintenance while powering down 535b04ea14bSJohn Tsichritzis * --------------------------------------------- 536b04ea14bSJohn Tsichritzis */ 537da6d75a0SJohn Tsichritzisfunc neoverse_n1_core_pwr_dwn 538b04ea14bSJohn Tsichritzis /* --------------------------------------------- 539b04ea14bSJohn Tsichritzis * Enable CPU power down bit in power control register 540b04ea14bSJohn Tsichritzis * --------------------------------------------- 541b04ea14bSJohn Tsichritzis */ 542da6d75a0SJohn Tsichritzis mrs x0, NEOVERSE_N1_CPUPWRCTLR_EL1 543da6d75a0SJohn Tsichritzis orr x0, x0, #NEOVERSE_N1_CORE_PWRDN_EN_MASK 544da6d75a0SJohn Tsichritzis msr NEOVERSE_N1_CPUPWRCTLR_EL1, x0 545b04ea14bSJohn Tsichritzis isb 546b04ea14bSJohn Tsichritzis ret 547da6d75a0SJohn Tsichritzisendfunc neoverse_n1_core_pwr_dwn 548b04ea14bSJohn Tsichritzis 549b04ea14bSJohn Tsichritzis#if REPORT_ERRATA 550b04ea14bSJohn Tsichritzis/* 551da6d75a0SJohn Tsichritzis * Errata printing function for Neoverse N1. Must follow AAPCS. 552b04ea14bSJohn Tsichritzis */ 553da6d75a0SJohn Tsichritzisfunc neoverse_n1_errata_report 554b04ea14bSJohn Tsichritzis stp x8, x30, [sp, #-16]! 555b04ea14bSJohn Tsichritzis 556b04ea14bSJohn Tsichritzis bl cpu_get_rev_var 557b04ea14bSJohn Tsichritzis mov x8, x0 558b04ea14bSJohn Tsichritzis 559b04ea14bSJohn Tsichritzis /* 560b04ea14bSJohn Tsichritzis * Report all errata. The revision-variant information is passed to 561b04ea14bSJohn Tsichritzis * checking functions of each errata. 562b04ea14bSJohn Tsichritzis */ 563da6d75a0SJohn Tsichritzis report_errata ERRATA_N1_1043202, neoverse_n1, 1043202 564a601afe1Slauwal01 report_errata ERRATA_N1_1073348, neoverse_n1, 1073348 565e34606f2Slauwal01 report_errata ERRATA_N1_1130799, neoverse_n1, 1130799 5662017ab24Slauwal01 report_errata ERRATA_N1_1165347, neoverse_n1, 1165347 567ef5fa7d4Slauwal01 report_errata ERRATA_N1_1207823, neoverse_n1, 1207823 5689eceb020Slauwal01 report_errata ERRATA_N1_1220197, neoverse_n1, 1220197 569335b3c79Slauwal01 report_errata ERRATA_N1_1257314, neoverse_n1, 1257314 570411f4959Slauwal01 report_errata ERRATA_N1_1262606, neoverse_n1, 1262606 57111c48370Slauwal01 report_errata ERRATA_N1_1262888, neoverse_n1, 1262888 5724d8801feSlauwal01 report_errata ERRATA_N1_1275112, neoverse_n1, 1275112 5735f5d0763SAndre Przywara report_errata ERRATA_N1_1315703, neoverse_n1, 1315703 57480942622Slaurenw-arm report_errata ERRATA_N1_1542419, neoverse_n1, 1542419 575*61f0ffc4Sjohpow01 report_errata ERRATA_N1_1868343, neoverse_n1, 1868343 576bb2f077aSLouis Mayencourt report_errata ERRATA_DSU_936184, neoverse_n1, dsu_936184 577b04ea14bSJohn Tsichritzis 578b04ea14bSJohn Tsichritzis ldp x8, x30, [sp], #16 579b04ea14bSJohn Tsichritzis ret 580da6d75a0SJohn Tsichritzisendfunc neoverse_n1_errata_report 581b04ea14bSJohn Tsichritzis#endif 582b04ea14bSJohn Tsichritzis 58380942622Slaurenw-arm/* 58480942622Slaurenw-arm * Handle trap of EL0 IC IVAU instructions to EL3 by executing a TLB 58580942622Slaurenw-arm * inner-shareable invalidation to an arbitrary address followed by a DSB. 58680942622Slaurenw-arm * 58780942622Slaurenw-arm * x1: Exception Syndrome 58880942622Slaurenw-arm */ 58980942622Slaurenw-armfunc neoverse_n1_errata_ic_trap_handler 59080942622Slaurenw-arm cmp x1, #NEOVERSE_N1_EC_IC_TRAP 59180942622Slaurenw-arm b.ne 1f 59280942622Slaurenw-arm tlbi vae3is, xzr 59380942622Slaurenw-arm dsb sy 59480942622Slaurenw-arm 59580942622Slaurenw-arm # Skip the IC instruction itself 59680942622Slaurenw-arm mrs x3, elr_el3 59780942622Slaurenw-arm add x3, x3, #4 59880942622Slaurenw-arm msr elr_el3, x3 59980942622Slaurenw-arm 60080942622Slaurenw-arm ldp x0, x1, [sp, #CTX_GPREGS_OFFSET + CTX_GPREG_X0] 60180942622Slaurenw-arm ldp x2, x3, [sp, #CTX_GPREGS_OFFSET + CTX_GPREG_X2] 60280942622Slaurenw-arm ldp x4, x5, [sp, #CTX_GPREGS_OFFSET + CTX_GPREG_X4] 60380942622Slaurenw-arm ldr x30, [sp, #CTX_GPREGS_OFFSET + CTX_GPREG_LR] 60480942622Slaurenw-arm 60580942622Slaurenw-arm#if IMAGE_BL31 && RAS_EXTENSION 60680942622Slaurenw-arm /* 60780942622Slaurenw-arm * Issue Error Synchronization Barrier to synchronize SErrors before 60880942622Slaurenw-arm * exiting EL3. We're running with EAs unmasked, so any synchronized 60980942622Slaurenw-arm * errors would be taken immediately; therefore no need to inspect 61080942622Slaurenw-arm * DISR_EL1 register. 61180942622Slaurenw-arm */ 61280942622Slaurenw-arm esb 61380942622Slaurenw-arm#endif 614f461fe34SAnthony Steinhauser exception_return 61580942622Slaurenw-arm1: 61680942622Slaurenw-arm ret 61780942622Slaurenw-armendfunc neoverse_n1_errata_ic_trap_handler 61880942622Slaurenw-arm 619b04ea14bSJohn Tsichritzis /* --------------------------------------------- 620da6d75a0SJohn Tsichritzis * This function provides neoverse_n1 specific 621b04ea14bSJohn Tsichritzis * register information for crash reporting. 622b04ea14bSJohn Tsichritzis * It needs to return with x6 pointing to 623b04ea14bSJohn Tsichritzis * a list of register names in ascii and 624b04ea14bSJohn Tsichritzis * x8 - x15 having values of registers to be 625b04ea14bSJohn Tsichritzis * reported. 626b04ea14bSJohn Tsichritzis * --------------------------------------------- 627b04ea14bSJohn Tsichritzis */ 628da6d75a0SJohn Tsichritzis.section .rodata.neoverse_n1_regs, "aS" 629da6d75a0SJohn Tsichritzisneoverse_n1_regs: /* The ascii list of register names to be reported */ 630b04ea14bSJohn Tsichritzis .asciz "cpuectlr_el1", "" 631b04ea14bSJohn Tsichritzis 632da6d75a0SJohn Tsichritzisfunc neoverse_n1_cpu_reg_dump 633da6d75a0SJohn Tsichritzis adr x6, neoverse_n1_regs 634da6d75a0SJohn Tsichritzis mrs x8, NEOVERSE_N1_CPUECTLR_EL1 635b04ea14bSJohn Tsichritzis ret 636da6d75a0SJohn Tsichritzisendfunc neoverse_n1_cpu_reg_dump 637b04ea14bSJohn Tsichritzis 63880942622Slaurenw-armdeclare_cpu_ops_eh neoverse_n1, NEOVERSE_N1_MIDR, \ 639da6d75a0SJohn Tsichritzis neoverse_n1_reset_func, \ 64080942622Slaurenw-arm neoverse_n1_errata_ic_trap_handler, \ 641da6d75a0SJohn Tsichritzis neoverse_n1_core_pwr_dwn 642