Isla Mitchell | ea84d6b | 2017-08-03 16:04:46 +0100 | [diff] [blame] | 1 | /* |
laurenw-arm | 521510a | 2023-06-27 14:41:38 -0500 | [diff] [blame] | 2 | * Copyright (c) 2017-2023, Arm Limited and Contributors. All rights reserved. |
Isla Mitchell | ea84d6b | 2017-08-03 16:04:46 +0100 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #include <arch.h> |
| 8 | #include <asm_macros.S> |
Dimitris Papastamos | 89736dd | 2018-02-13 11:28:02 +0000 | [diff] [blame] | 9 | #include <cpuamu.h> |
Isla Mitchell | ea84d6b | 2017-08-03 16:04:46 +0100 | [diff] [blame] | 10 | #include <cpu_macros.S> |
Javier Almansa Sobrino | 9faad3c | 2020-10-23 13:22:07 +0100 | [diff] [blame] | 11 | #include <neoverse_n1.h> |
Bipin Ravi | 8649974 | 2022-01-18 01:59:06 -0600 | [diff] [blame] | 12 | #include "wa_cve_2022_23960_bhb_vector.S" |
Dimitris Papastamos | 89736dd | 2018-02-13 11:28:02 +0000 | [diff] [blame] | 13 | |
John Tsichritzis | fe6df39 | 2019-03-19 17:20:52 +0000 | [diff] [blame] | 14 | /* Hardware handled coherency */ |
| 15 | #if HW_ASSISTED_COHERENCY == 0 |
| 16 | #error "Neoverse N1 must be compiled with HW_ASSISTED_COHERENCY enabled" |
| 17 | #endif |
| 18 | |
John Tsichritzis | 7557c66 | 2019-06-03 13:54:30 +0100 | [diff] [blame] | 19 | /* 64-bit only core */ |
| 20 | #if CTX_INCLUDE_AARCH32_REGS == 1 |
| 21 | #error "Neoverse-N1 supports only AArch64. Compile with CTX_INCLUDE_AARCH32_REGS=0" |
| 22 | #endif |
| 23 | |
laurenw-arm | 94accd3 | 2019-08-20 15:51:24 -0500 | [diff] [blame] | 24 | .global neoverse_n1_errata_ic_trap_handler |
laurenw-arm | 94accd3 | 2019-08-20 15:51:24 -0500 | [diff] [blame] | 25 | |
Bipin Ravi | 8649974 | 2022-01-18 01:59:06 -0600 | [diff] [blame] | 26 | #if WORKAROUND_CVE_2022_23960 |
| 27 | wa_cve_2022_23960_bhb_vector_table NEOVERSE_N1_BHB_LOOP_COUNT, neoverse_n1 |
| 28 | #endif /* WORKAROUND_CVE_2022_23960 */ |
| 29 | |
laurenw-arm | 41c3e26 | 2023-06-06 16:53:15 -0500 | [diff] [blame] | 30 | /* |
| 31 | * ERRATA_DSU_936184: |
| 32 | * The errata is defined in dsu_helpers.S and applies to Neoverse N1. |
| 33 | * Henceforth creating symbolic names to the already existing errata |
| 34 | * workaround functions to get them registered under the Errata Framework. |
Dimitris Papastamos | 7ca21db | 2018-03-26 16:46:01 +0100 | [diff] [blame] | 35 | */ |
laurenw-arm | 41c3e26 | 2023-06-06 16:53:15 -0500 | [diff] [blame] | 36 | .equ check_erratum_neoverse_n1_936184, check_errata_dsu_936184 |
| 37 | .equ erratum_neoverse_n1_936184_wa, errata_dsu_936184_wa |
| 38 | add_erratum_entry neoverse_n1, ERRATUM(936184), ERRATA_DSU_936184, APPLY_AT_RESET |
Dimitris Papastamos | 7ca21db | 2018-03-26 16:46:01 +0100 | [diff] [blame] | 39 | |
laurenw-arm | 41c3e26 | 2023-06-06 16:53:15 -0500 | [diff] [blame] | 40 | workaround_reset_start neoverse_n1, ERRATUM(1043202), ERRATA_N1_1043202 |
Dimitris Papastamos | 7ca21db | 2018-03-26 16:46:01 +0100 | [diff] [blame] | 41 | /* Apply instruction patching sequence */ |
| 42 | ldr x0, =0x0 |
| 43 | msr CPUPSELR_EL3, x0 |
| 44 | ldr x0, =0xF3BF8F2F |
| 45 | msr CPUPOR_EL3, x0 |
| 46 | ldr x0, =0xFFFFFFFF |
| 47 | msr CPUPMR_EL3, x0 |
| 48 | ldr x0, =0x800200071 |
| 49 | msr CPUPCR_EL3, x0 |
laurenw-arm | 41c3e26 | 2023-06-06 16:53:15 -0500 | [diff] [blame] | 50 | workaround_reset_end neoverse_n1, ERRATUM(1043202) |
Dimitris Papastamos | 7ca21db | 2018-03-26 16:46:01 +0100 | [diff] [blame] | 51 | |
laurenw-arm | 41c3e26 | 2023-06-06 16:53:15 -0500 | [diff] [blame] | 52 | check_erratum_ls neoverse_n1, ERRATUM(1043202), CPU_REV(1, 0) |
Dimitris Papastamos | 7ca21db | 2018-03-26 16:46:01 +0100 | [diff] [blame] | 53 | |
laurenw-arm | 41c3e26 | 2023-06-06 16:53:15 -0500 | [diff] [blame] | 54 | workaround_reset_start neoverse_n1, ERRATUM(1073348), ERRATA_N1_1073348 |
laurenw-arm | b45d7d7 | 2023-06-07 13:26:23 -0500 | [diff] [blame] | 55 | sysreg_bit_set NEOVERSE_N1_CPUACTLR_EL1, NEOVERSE_N1_CPUACTLR_EL1_BIT_6 |
laurenw-arm | 41c3e26 | 2023-06-06 16:53:15 -0500 | [diff] [blame] | 56 | workaround_reset_end neoverse_n1, ERRATUM(1073348) |
lauwal01 | bd555f4 | 2019-06-24 11:23:50 -0500 | [diff] [blame] | 57 | |
laurenw-arm | 41c3e26 | 2023-06-06 16:53:15 -0500 | [diff] [blame] | 58 | check_erratum_ls neoverse_n1, ERRATUM(1073348), CPU_REV(1, 0) |
lauwal01 | bd555f4 | 2019-06-24 11:23:50 -0500 | [diff] [blame] | 59 | |
laurenw-arm | 41c3e26 | 2023-06-06 16:53:15 -0500 | [diff] [blame] | 60 | workaround_reset_start neoverse_n1, ERRATUM(1130799), ERRATA_N1_1130799 |
laurenw-arm | b45d7d7 | 2023-06-07 13:26:23 -0500 | [diff] [blame] | 61 | sysreg_bit_set NEOVERSE_N1_CPUACTLR2_EL1, NEOVERSE_N1_CPUACTLR2_EL1_BIT_59 |
laurenw-arm | 41c3e26 | 2023-06-06 16:53:15 -0500 | [diff] [blame] | 62 | workaround_reset_end neoverse_n1, ERRATUM(1130799) |
lauwal01 | 363ee3c | 2019-06-24 11:28:34 -0500 | [diff] [blame] | 63 | |
laurenw-arm | 41c3e26 | 2023-06-06 16:53:15 -0500 | [diff] [blame] | 64 | check_erratum_ls neoverse_n1, ERRATUM(1130799), CPU_REV(2, 0) |
lauwal01 | 363ee3c | 2019-06-24 11:28:34 -0500 | [diff] [blame] | 65 | |
laurenw-arm | 41c3e26 | 2023-06-06 16:53:15 -0500 | [diff] [blame] | 66 | workaround_reset_start neoverse_n1, ERRATUM(1165347), ERRATA_N1_1165347 |
laurenw-arm | b45d7d7 | 2023-06-07 13:26:23 -0500 | [diff] [blame] | 67 | sysreg_bit_set NEOVERSE_N1_CPUACTLR2_EL1, NEOVERSE_N1_CPUACTLR2_EL1_BIT_0 |
| 68 | sysreg_bit_set NEOVERSE_N1_CPUACTLR2_EL1, NEOVERSE_N1_CPUACTLR2_EL1_BIT_15 |
laurenw-arm | 41c3e26 | 2023-06-06 16:53:15 -0500 | [diff] [blame] | 69 | workaround_reset_end neoverse_n1, ERRATUM(1165347) |
lauwal01 | f2adb13 | 2019-06-24 11:32:40 -0500 | [diff] [blame] | 70 | |
laurenw-arm | 41c3e26 | 2023-06-06 16:53:15 -0500 | [diff] [blame] | 71 | check_erratum_ls neoverse_n1, ERRATUM(1165347), CPU_REV(2, 0) |
lauwal01 | f2adb13 | 2019-06-24 11:32:40 -0500 | [diff] [blame] | 72 | |
laurenw-arm | 41c3e26 | 2023-06-06 16:53:15 -0500 | [diff] [blame] | 73 | workaround_reset_start neoverse_n1, ERRATUM(1207823), ERRATA_N1_1207823 |
laurenw-arm | b45d7d7 | 2023-06-07 13:26:23 -0500 | [diff] [blame] | 74 | sysreg_bit_set NEOVERSE_N1_CPUACTLR2_EL1, NEOVERSE_N1_CPUACTLR2_EL1_BIT_11 |
laurenw-arm | 41c3e26 | 2023-06-06 16:53:15 -0500 | [diff] [blame] | 75 | workaround_reset_end neoverse_n1, ERRATUM(1207823) |
lauwal01 | e159044 | 2019-06-24 11:35:37 -0500 | [diff] [blame] | 76 | |
laurenw-arm | 41c3e26 | 2023-06-06 16:53:15 -0500 | [diff] [blame] | 77 | check_erratum_ls neoverse_n1, ERRATUM(1207823), CPU_REV(2, 0) |
lauwal01 | e159044 | 2019-06-24 11:35:37 -0500 | [diff] [blame] | 78 | |
laurenw-arm | 41c3e26 | 2023-06-06 16:53:15 -0500 | [diff] [blame] | 79 | workaround_reset_start neoverse_n1, ERRATUM(1220197), ERRATA_N1_1220197 |
laurenw-arm | b45d7d7 | 2023-06-07 13:26:23 -0500 | [diff] [blame] | 80 | sysreg_bit_set NEOVERSE_N1_CPUECTLR_EL1, NEOVERSE_N1_WS_THR_L2_MASK |
laurenw-arm | 41c3e26 | 2023-06-06 16:53:15 -0500 | [diff] [blame] | 81 | workaround_reset_end neoverse_n1, ERRATUM(1220197) |
lauwal01 | 197f14c | 2019-06-24 11:38:53 -0500 | [diff] [blame] | 82 | |
laurenw-arm | 41c3e26 | 2023-06-06 16:53:15 -0500 | [diff] [blame] | 83 | check_erratum_ls neoverse_n1, ERRATUM(1220197), CPU_REV(2, 0) |
lauwal01 | 197f14c | 2019-06-24 11:38:53 -0500 | [diff] [blame] | 84 | |
laurenw-arm | 41c3e26 | 2023-06-06 16:53:15 -0500 | [diff] [blame] | 85 | workaround_reset_start neoverse_n1, ERRATUM(1257314), ERRATA_N1_1257314 |
laurenw-arm | b45d7d7 | 2023-06-07 13:26:23 -0500 | [diff] [blame] | 86 | sysreg_bit_set NEOVERSE_N1_CPUACTLR3_EL1, NEOVERSE_N1_CPUACTLR3_EL1_BIT_10 |
laurenw-arm | 41c3e26 | 2023-06-06 16:53:15 -0500 | [diff] [blame] | 87 | workaround_reset_end neoverse_n1, ERRATUM(1257314) |
lauwal01 | 07c2a23 | 2019-06-24 11:42:02 -0500 | [diff] [blame] | 88 | |
laurenw-arm | 41c3e26 | 2023-06-06 16:53:15 -0500 | [diff] [blame] | 89 | check_erratum_ls neoverse_n1, ERRATUM(1257314), CPU_REV(3, 0) |
lauwal01 | 07c2a23 | 2019-06-24 11:42:02 -0500 | [diff] [blame] | 90 | |
laurenw-arm | 41c3e26 | 2023-06-06 16:53:15 -0500 | [diff] [blame] | 91 | workaround_reset_start neoverse_n1, ERRATUM(1262606), ERRATA_N1_1262606 |
laurenw-arm | b45d7d7 | 2023-06-07 13:26:23 -0500 | [diff] [blame] | 92 | sysreg_bit_set NEOVERSE_N1_CPUACTLR_EL1, NEOVERSE_N1_CPUACTLR_EL1_BIT_13 |
laurenw-arm | 41c3e26 | 2023-06-06 16:53:15 -0500 | [diff] [blame] | 93 | workaround_reset_end neoverse_n1, ERRATUM(1262606) |
lauwal01 | 42771af | 2019-06-24 11:44:58 -0500 | [diff] [blame] | 94 | |
laurenw-arm | 41c3e26 | 2023-06-06 16:53:15 -0500 | [diff] [blame] | 95 | check_erratum_ls neoverse_n1, ERRATUM(1262606), CPU_REV(3, 0) |
lauwal01 | 42771af | 2019-06-24 11:44:58 -0500 | [diff] [blame] | 96 | |
laurenw-arm | 41c3e26 | 2023-06-06 16:53:15 -0500 | [diff] [blame] | 97 | workaround_reset_start neoverse_n1, ERRATUM(1262888), ERRATA_N1_1262888 |
laurenw-arm | b45d7d7 | 2023-06-07 13:26:23 -0500 | [diff] [blame] | 98 | sysreg_bit_set NEOVERSE_N1_CPUECTLR_EL1, NEOVERSE_N1_CPUECTLR_EL1_MM_TLBPF_DIS_BIT |
laurenw-arm | 41c3e26 | 2023-06-06 16:53:15 -0500 | [diff] [blame] | 99 | workaround_reset_end neoverse_n1, ERRATUM(1262888) |
lauwal01 | 00396bf | 2019-06-24 11:47:30 -0500 | [diff] [blame] | 100 | |
laurenw-arm | 41c3e26 | 2023-06-06 16:53:15 -0500 | [diff] [blame] | 101 | check_erratum_ls neoverse_n1, ERRATUM(1262888), CPU_REV(3, 0) |
lauwal01 | 00396bf | 2019-06-24 11:47:30 -0500 | [diff] [blame] | 102 | |
laurenw-arm | 41c3e26 | 2023-06-06 16:53:15 -0500 | [diff] [blame] | 103 | workaround_reset_start neoverse_n1, ERRATUM(1275112), ERRATA_N1_1275112 |
laurenw-arm | b45d7d7 | 2023-06-07 13:26:23 -0500 | [diff] [blame] | 104 | sysreg_bit_set NEOVERSE_N1_CPUACTLR_EL1, NEOVERSE_N1_CPUACTLR_EL1_BIT_13 |
laurenw-arm | 41c3e26 | 2023-06-06 16:53:15 -0500 | [diff] [blame] | 105 | workaround_reset_end neoverse_n1, ERRATUM(1275112) |
lauwal01 | 644b6ed | 2019-06-24 11:49:01 -0500 | [diff] [blame] | 106 | |
laurenw-arm | 41c3e26 | 2023-06-06 16:53:15 -0500 | [diff] [blame] | 107 | check_erratum_ls neoverse_n1, ERRATUM(1275112), CPU_REV(3, 0) |
Andre Przywara | b934740 | 2019-05-20 14:57:06 +0100 | [diff] [blame] | 108 | |
laurenw-arm | 41c3e26 | 2023-06-06 16:53:15 -0500 | [diff] [blame] | 109 | workaround_reset_start neoverse_n1, ERRATUM(1315703), ERRATA_N1_1315703 |
laurenw-arm | b45d7d7 | 2023-06-07 13:26:23 -0500 | [diff] [blame] | 110 | sysreg_bit_set NEOVERSE_N1_CPUACTLR2_EL1, NEOVERSE_N1_CPUACTLR2_EL1_BIT_16 |
laurenw-arm | 41c3e26 | 2023-06-06 16:53:15 -0500 | [diff] [blame] | 111 | workaround_reset_end neoverse_n1, ERRATUM(1315703) |
Andre Przywara | b934740 | 2019-05-20 14:57:06 +0100 | [diff] [blame] | 112 | |
laurenw-arm | 41c3e26 | 2023-06-06 16:53:15 -0500 | [diff] [blame] | 113 | check_erratum_ls neoverse_n1, ERRATUM(1315703), CPU_REV(3, 0) |
laurenw-arm | 94accd3 | 2019-08-20 15:51:24 -0500 | [diff] [blame] | 114 | |
laurenw-arm | 41c3e26 | 2023-06-06 16:53:15 -0500 | [diff] [blame] | 115 | workaround_reset_start neoverse_n1, ERRATUM(1542419), ERRATA_N1_1542419 |
laurenw-arm | cd9a943 | 2019-10-11 15:45:24 -0500 | [diff] [blame] | 116 | /* Apply instruction patching sequence */ |
laurenw-arm | 94accd3 | 2019-08-20 15:51:24 -0500 | [diff] [blame] | 117 | ldr x0, =0x0 |
| 118 | msr CPUPSELR_EL3, x0 |
| 119 | ldr x0, =0xEE670D35 |
| 120 | msr CPUPOR_EL3, x0 |
| 121 | ldr x0, =0xFFFF0FFF |
| 122 | msr CPUPMR_EL3, x0 |
| 123 | ldr x0, =0x08000020007D |
| 124 | msr CPUPCR_EL3, x0 |
| 125 | isb |
laurenw-arm | 41c3e26 | 2023-06-06 16:53:15 -0500 | [diff] [blame] | 126 | workaround_reset_end neoverse_n1, ERRATUM(1542419) |
laurenw-arm | 94accd3 | 2019-08-20 15:51:24 -0500 | [diff] [blame] | 127 | |
laurenw-arm | 41c3e26 | 2023-06-06 16:53:15 -0500 | [diff] [blame] | 128 | check_erratum_range neoverse_n1, ERRATUM(1542419), CPU_REV(3, 0), CPU_REV(4, 0) |
laurenw-arm | 94accd3 | 2019-08-20 15:51:24 -0500 | [diff] [blame] | 129 | |
laurenw-arm | 41c3e26 | 2023-06-06 16:53:15 -0500 | [diff] [blame] | 130 | workaround_reset_start neoverse_n1, ERRATUM(1868343), ERRATA_N1_1868343 |
laurenw-arm | b45d7d7 | 2023-06-07 13:26:23 -0500 | [diff] [blame] | 131 | sysreg_bit_set NEOVERSE_N1_CPUACTLR_EL1, NEOVERSE_N1_CPUACTLR_EL1_BIT_13 |
laurenw-arm | 41c3e26 | 2023-06-06 16:53:15 -0500 | [diff] [blame] | 132 | workaround_reset_end neoverse_n1, ERRATUM(1868343) |
johpow01 | e2428fd | 2020-08-05 12:27:12 -0500 | [diff] [blame] | 133 | |
laurenw-arm | 41c3e26 | 2023-06-06 16:53:15 -0500 | [diff] [blame] | 134 | check_erratum_ls neoverse_n1, ERRATUM(1868343), CPU_REV(4, 0) |
johpow01 | f1a84f5 | 2020-10-07 14:33:15 -0500 | [diff] [blame] | 135 | |
laurenw-arm | 41c3e26 | 2023-06-06 16:53:15 -0500 | [diff] [blame] | 136 | workaround_reset_start neoverse_n1, ERRATUM(1946160), ERRATA_N1_1946160 |
johpow01 | f1a84f5 | 2020-10-07 14:33:15 -0500 | [diff] [blame] | 137 | mov x0, #3 |
| 138 | msr S3_6_C15_C8_0, x0 |
| 139 | ldr x0, =0x10E3900002 |
| 140 | msr S3_6_C15_C8_2, x0 |
| 141 | ldr x0, =0x10FFF00083 |
| 142 | msr S3_6_C15_C8_3, x0 |
| 143 | ldr x0, =0x2001003FF |
| 144 | msr S3_6_C15_C8_1, x0 |
johpow01 | f1a84f5 | 2020-10-07 14:33:15 -0500 | [diff] [blame] | 145 | mov x0, #4 |
| 146 | msr S3_6_C15_C8_0, x0 |
| 147 | ldr x0, =0x10E3800082 |
| 148 | msr S3_6_C15_C8_2, x0 |
| 149 | ldr x0, =0x10FFF00083 |
| 150 | msr S3_6_C15_C8_3, x0 |
| 151 | ldr x0, =0x2001003FF |
| 152 | msr S3_6_C15_C8_1, x0 |
johpow01 | f1a84f5 | 2020-10-07 14:33:15 -0500 | [diff] [blame] | 153 | mov x0, #5 |
| 154 | msr S3_6_C15_C8_0, x0 |
| 155 | ldr x0, =0x10E3800200 |
| 156 | msr S3_6_C15_C8_2, x0 |
| 157 | ldr x0, =0x10FFF003E0 |
| 158 | msr S3_6_C15_C8_3, x0 |
| 159 | ldr x0, =0x2001003FF |
| 160 | msr S3_6_C15_C8_1, x0 |
johpow01 | f1a84f5 | 2020-10-07 14:33:15 -0500 | [diff] [blame] | 161 | isb |
laurenw-arm | 41c3e26 | 2023-06-06 16:53:15 -0500 | [diff] [blame] | 162 | workaround_reset_end neoverse_n1, ERRATUM(1946160) |
johpow01 | f1a84f5 | 2020-10-07 14:33:15 -0500 | [diff] [blame] | 163 | |
laurenw-arm | 41c3e26 | 2023-06-06 16:53:15 -0500 | [diff] [blame] | 164 | check_erratum_range neoverse_n1, ERRATUM(1946160), CPU_REV(3, 0), CPU_REV(4, 1) |
Bipin Ravi | 9edf249 | 2022-11-02 16:12:01 -0500 | [diff] [blame] | 165 | |
laurenw-arm | 41c3e26 | 2023-06-06 16:53:15 -0500 | [diff] [blame] | 166 | workaround_runtime_start neoverse_n1, ERRATUM(2743102), ERRATA_N1_2743102 |
Bipin Ravi | 9edf249 | 2022-11-02 16:12:01 -0500 | [diff] [blame] | 167 | /* dsb before isb of power down sequence */ |
| 168 | dsb sy |
laurenw-arm | 41c3e26 | 2023-06-06 16:53:15 -0500 | [diff] [blame] | 169 | workaround_runtime_end neoverse_n1, ERRATUM(2743102) |
Bipin Ravi | 9edf249 | 2022-11-02 16:12:01 -0500 | [diff] [blame] | 170 | |
laurenw-arm | 41c3e26 | 2023-06-06 16:53:15 -0500 | [diff] [blame] | 171 | check_erratum_ls neoverse_n1, ERRATUM(2743102), CPU_REV(4, 1) |
Bipin Ravi | 9edf249 | 2022-11-02 16:12:01 -0500 | [diff] [blame] | 172 | |
laurenw-arm | 41c3e26 | 2023-06-06 16:53:15 -0500 | [diff] [blame] | 173 | workaround_reset_start neoverse_n1, CVE(2022, 23960), WORKAROUND_CVE_2022_23960 |
| 174 | #if IMAGE_BL31 |
| 175 | /* |
| 176 | * The Neoverse-N1 generic vectors are overridden to apply errata |
| 177 | * mitigation on exception entry from lower ELs. |
| 178 | */ |
laurenw-arm | b45d7d7 | 2023-06-07 13:26:23 -0500 | [diff] [blame] | 179 | override_vector_table wa_cve_vbar_neoverse_n1 |
laurenw-arm | 41c3e26 | 2023-06-06 16:53:15 -0500 | [diff] [blame] | 180 | #endif /* IMAGE_BL31 */ |
| 181 | workaround_reset_end neoverse_n1, CVE(2022, 23960) |
| 182 | |
| 183 | check_erratum_chosen neoverse_n1, CVE(2022, 23960), WORKAROUND_CVE_2022_23960 |
Bipin Ravi | 8649974 | 2022-01-18 01:59:06 -0600 | [diff] [blame] | 184 | |
laurenw-arm | 521510a | 2023-06-27 14:41:38 -0500 | [diff] [blame] | 185 | /* -------------------------------------------------- |
| 186 | * Disable speculative loads if Neoverse N1 supports |
| 187 | * SSBS. |
| 188 | * |
| 189 | * Shall clobber: x0. |
| 190 | * -------------------------------------------------- |
| 191 | */ |
| 192 | func neoverse_n1_disable_speculative_loads |
| 193 | /* Check if the PE implements SSBS */ |
| 194 | mrs x0, id_aa64pfr1_el1 |
| 195 | tst x0, #(ID_AA64PFR1_EL1_SSBS_MASK << ID_AA64PFR1_EL1_SSBS_SHIFT) |
| 196 | b.eq 1f |
| 197 | |
| 198 | /* Disable speculative loads */ |
| 199 | msr SSBS, xzr |
| 200 | |
| 201 | 1: |
| 202 | ret |
| 203 | endfunc neoverse_n1_disable_speculative_loads |
| 204 | |
laurenw-arm | 41c3e26 | 2023-06-06 16:53:15 -0500 | [diff] [blame] | 205 | cpu_reset_func_start neoverse_n1 |
Sami Mujawar | a8722e9 | 2019-05-10 14:28:37 +0100 | [diff] [blame] | 206 | bl neoverse_n1_disable_speculative_loads |
John Tsichritzis | 1f9ff49 | 2019-03-04 16:41:26 +0000 | [diff] [blame] | 207 | |
Louis Mayencourt | b58142b | 2019-04-18 14:34:11 +0100 | [diff] [blame] | 208 | /* Forces all cacheable atomic instructions to be near */ |
laurenw-arm | b45d7d7 | 2023-06-07 13:26:23 -0500 | [diff] [blame] | 209 | sysreg_bit_set NEOVERSE_N1_CPUACTLR2_EL1, NEOVERSE_N1_CPUACTLR2_EL1_BIT_2 |
Louis Mayencourt | b58142b | 2019-04-18 14:34:11 +0100 | [diff] [blame] | 210 | isb |
| 211 | |
Andre Przywara | 0b7f1b0 | 2023-03-21 13:53:19 +0000 | [diff] [blame] | 212 | #if ENABLE_FEAT_AMU |
Dimitris Papastamos | 89736dd | 2018-02-13 11:28:02 +0000 | [diff] [blame] | 213 | /* Make sure accesses from EL0/EL1 and EL2 are not trapped to EL3 */ |
laurenw-arm | b45d7d7 | 2023-06-07 13:26:23 -0500 | [diff] [blame] | 214 | sysreg_bit_set actlr_el3, NEOVERSE_N1_ACTLR_AMEN_BIT |
Dimitris Papastamos | 89736dd | 2018-02-13 11:28:02 +0000 | [diff] [blame] | 215 | /* Make sure accesses from EL0/EL1 are not trapped to EL2 */ |
laurenw-arm | b45d7d7 | 2023-06-07 13:26:23 -0500 | [diff] [blame] | 216 | sysreg_bit_set actlr_el2, NEOVERSE_N1_ACTLR_AMEN_BIT |
Dimitris Papastamos | 89736dd | 2018-02-13 11:28:02 +0000 | [diff] [blame] | 217 | /* Enable group0 counters */ |
John Tsichritzis | 56369c1 | 2019-02-19 13:49:06 +0000 | [diff] [blame] | 218 | mov x0, #NEOVERSE_N1_AMU_GROUP0_MASK |
Dimitris Papastamos | 89736dd | 2018-02-13 11:28:02 +0000 | [diff] [blame] | 219 | msr CPUAMCNTENSET_EL0, x0 |
Dimitris Papastamos | 89736dd | 2018-02-13 11:28:02 +0000 | [diff] [blame] | 220 | #endif |
Louis Mayencourt | 8b8b13b | 2019-06-10 16:43:39 +0100 | [diff] [blame] | 221 | |
Javier Almansa Sobrino | 9faad3c | 2020-10-23 13:22:07 +0100 | [diff] [blame] | 222 | #if NEOVERSE_Nx_EXTERNAL_LLC |
Manish Pandey | 3880a36 | 2020-01-24 11:54:44 +0000 | [diff] [blame] | 223 | /* Some system may have External LLC, core needs to be made aware */ |
laurenw-arm | b45d7d7 | 2023-06-07 13:26:23 -0500 | [diff] [blame] | 224 | sysreg_bit_set NEOVERSE_N1_CPUECTLR_EL1, NEOVERSE_N1_CPUECTLR_EL1_EXTLLC_BIT |
Manish Pandey | 3880a36 | 2020-01-24 11:54:44 +0000 | [diff] [blame] | 225 | #endif |
laurenw-arm | 41c3e26 | 2023-06-06 16:53:15 -0500 | [diff] [blame] | 226 | cpu_reset_func_end neoverse_n1 |
Isla Mitchell | ea84d6b | 2017-08-03 16:04:46 +0100 | [diff] [blame] | 227 | |
| 228 | /* --------------------------------------------- |
| 229 | * HW will do the cache maintenance while powering down |
| 230 | * --------------------------------------------- |
| 231 | */ |
John Tsichritzis | 56369c1 | 2019-02-19 13:49:06 +0000 | [diff] [blame] | 232 | func neoverse_n1_core_pwr_dwn |
Isla Mitchell | ea84d6b | 2017-08-03 16:04:46 +0100 | [diff] [blame] | 233 | /* --------------------------------------------- |
| 234 | * Enable CPU power down bit in power control register |
| 235 | * --------------------------------------------- |
| 236 | */ |
laurenw-arm | b45d7d7 | 2023-06-07 13:26:23 -0500 | [diff] [blame] | 237 | sysreg_bit_set NEOVERSE_N1_CPUPWRCTLR_EL1, NEOVERSE_N1_CORE_PWRDN_EN_MASK |
| 238 | |
| 239 | apply_erratum neoverse_n1, ERRATUM(2743102), ERRATA_N1_2743102 |
| 240 | |
Isla Mitchell | ea84d6b | 2017-08-03 16:04:46 +0100 | [diff] [blame] | 241 | isb |
| 242 | ret |
John Tsichritzis | 56369c1 | 2019-02-19 13:49:06 +0000 | [diff] [blame] | 243 | endfunc neoverse_n1_core_pwr_dwn |
Isla Mitchell | ea84d6b | 2017-08-03 16:04:46 +0100 | [diff] [blame] | 244 | |
laurenw-arm | 41c3e26 | 2023-06-06 16:53:15 -0500 | [diff] [blame] | 245 | errata_report_shim neoverse_n1 |
laurenw-arm | 94accd3 | 2019-08-20 15:51:24 -0500 | [diff] [blame] | 246 | |
| 247 | /* |
| 248 | * Handle trap of EL0 IC IVAU instructions to EL3 by executing a TLB |
| 249 | * inner-shareable invalidation to an arbitrary address followed by a DSB. |
| 250 | * |
| 251 | * x1: Exception Syndrome |
| 252 | */ |
| 253 | func neoverse_n1_errata_ic_trap_handler |
| 254 | cmp x1, #NEOVERSE_N1_EC_IC_TRAP |
| 255 | b.ne 1f |
| 256 | tlbi vae3is, xzr |
| 257 | dsb sy |
| 258 | |
laurenw-arm | cd9a943 | 2019-10-11 15:45:24 -0500 | [diff] [blame] | 259 | # Skip the IC instruction itself |
| 260 | mrs x3, elr_el3 |
| 261 | add x3, x3, #4 |
| 262 | msr elr_el3, x3 |
laurenw-arm | 94accd3 | 2019-08-20 15:51:24 -0500 | [diff] [blame] | 263 | |
| 264 | ldp x0, x1, [sp, #CTX_GPREGS_OFFSET + CTX_GPREG_X0] |
| 265 | ldp x2, x3, [sp, #CTX_GPREGS_OFFSET + CTX_GPREG_X2] |
| 266 | ldp x4, x5, [sp, #CTX_GPREGS_OFFSET + CTX_GPREG_X4] |
| 267 | ldr x30, [sp, #CTX_GPREGS_OFFSET + CTX_GPREG_LR] |
| 268 | |
laurenw-arm | 94accd3 | 2019-08-20 15:51:24 -0500 | [diff] [blame] | 269 | /* |
| 270 | * Issue Error Synchronization Barrier to synchronize SErrors before |
| 271 | * exiting EL3. We're running with EAs unmasked, so any synchronized |
| 272 | * errors would be taken immediately; therefore no need to inspect |
| 273 | * DISR_EL1 register. |
| 274 | */ |
| 275 | esb |
Anthony Steinhauser | 0f7e601 | 2020-01-07 15:44:06 -0800 | [diff] [blame] | 276 | exception_return |
laurenw-arm | 94accd3 | 2019-08-20 15:51:24 -0500 | [diff] [blame] | 277 | 1: |
| 278 | ret |
| 279 | endfunc neoverse_n1_errata_ic_trap_handler |
Dimitris Papastamos | 7ca21db | 2018-03-26 16:46:01 +0100 | [diff] [blame] | 280 | |
Isla Mitchell | ea84d6b | 2017-08-03 16:04:46 +0100 | [diff] [blame] | 281 | /* --------------------------------------------- |
John Tsichritzis | 56369c1 | 2019-02-19 13:49:06 +0000 | [diff] [blame] | 282 | * This function provides neoverse_n1 specific |
Isla Mitchell | ea84d6b | 2017-08-03 16:04:46 +0100 | [diff] [blame] | 283 | * register information for crash reporting. |
| 284 | * It needs to return with x6 pointing to |
| 285 | * a list of register names in ascii and |
| 286 | * x8 - x15 having values of registers to be |
| 287 | * reported. |
| 288 | * --------------------------------------------- |
| 289 | */ |
John Tsichritzis | 56369c1 | 2019-02-19 13:49:06 +0000 | [diff] [blame] | 290 | .section .rodata.neoverse_n1_regs, "aS" |
| 291 | neoverse_n1_regs: /* The ascii list of register names to be reported */ |
Isla Mitchell | ea84d6b | 2017-08-03 16:04:46 +0100 | [diff] [blame] | 292 | .asciz "cpuectlr_el1", "" |
| 293 | |
John Tsichritzis | 56369c1 | 2019-02-19 13:49:06 +0000 | [diff] [blame] | 294 | func neoverse_n1_cpu_reg_dump |
| 295 | adr x6, neoverse_n1_regs |
| 296 | mrs x8, NEOVERSE_N1_CPUECTLR_EL1 |
Isla Mitchell | ea84d6b | 2017-08-03 16:04:46 +0100 | [diff] [blame] | 297 | ret |
John Tsichritzis | 56369c1 | 2019-02-19 13:49:06 +0000 | [diff] [blame] | 298 | endfunc neoverse_n1_cpu_reg_dump |
Isla Mitchell | ea84d6b | 2017-08-03 16:04:46 +0100 | [diff] [blame] | 299 | |
laurenw-arm | 94accd3 | 2019-08-20 15:51:24 -0500 | [diff] [blame] | 300 | declare_cpu_ops_eh neoverse_n1, NEOVERSE_N1_MIDR, \ |
John Tsichritzis | 56369c1 | 2019-02-19 13:49:06 +0000 | [diff] [blame] | 301 | neoverse_n1_reset_func, \ |
laurenw-arm | 94accd3 | 2019-08-20 15:51:24 -0500 | [diff] [blame] | 302 | neoverse_n1_errata_ic_trap_handler, \ |
John Tsichritzis | 56369c1 | 2019-02-19 13:49:06 +0000 | [diff] [blame] | 303 | neoverse_n1_core_pwr_dwn |