Andre Przywara | e116a37 | 2014-11-14 15:54:09 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Contains CPU specific errata definitions |
| 3 | * |
| 4 | * Copyright (C) 2014 ARM Ltd. |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License version 2 as |
| 8 | * published by the Free Software Foundation. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 | */ |
| 18 | |
Arnd Bergmann | 94a5d87 | 2018-06-05 13:50:07 +0200 | [diff] [blame] | 19 | #include <linux/arm-smccc.h> |
| 20 | #include <linux/psci.h> |
Andre Przywara | e116a37 | 2014-11-14 15:54:09 +0000 | [diff] [blame] | 21 | #include <linux/types.h> |
| 22 | #include <asm/cpu.h> |
| 23 | #include <asm/cputype.h> |
| 24 | #include <asm/cpufeature.h> |
| 25 | |
Andre Przywara | 301bcfa | 2014-11-14 15:54:10 +0000 | [diff] [blame] | 26 | static bool __maybe_unused |
Suzuki K Poulose | 92406f0 | 2016-04-22 12:25:31 +0100 | [diff] [blame] | 27 | is_affected_midr_range(const struct arm64_cpu_capabilities *entry, int scope) |
Andre Przywara | 301bcfa | 2014-11-14 15:54:10 +0000 | [diff] [blame] | 28 | { |
Ard Biesheuvel | e8002e0 | 2018-03-06 17:15:34 +0000 | [diff] [blame] | 29 | const struct arm64_midr_revidr *fix; |
| 30 | u32 midr = read_cpuid_id(), revidr; |
| 31 | |
Suzuki K Poulose | 92406f0 | 2016-04-22 12:25:31 +0100 | [diff] [blame] | 32 | WARN_ON(scope != SCOPE_LOCAL_CPU || preemptible()); |
Suzuki K Poulose | 1df3105 | 2018-03-26 15:12:44 +0100 | [diff] [blame] | 33 | if (!is_midr_in_range(midr, &entry->midr_range)) |
Ard Biesheuvel | e8002e0 | 2018-03-06 17:15:34 +0000 | [diff] [blame] | 34 | return false; |
| 35 | |
| 36 | midr &= MIDR_REVISION_MASK | MIDR_VARIANT_MASK; |
| 37 | revidr = read_cpuid(REVIDR_EL1); |
| 38 | for (fix = entry->fixed_revs; fix && fix->revidr_mask; fix++) |
| 39 | if (midr == fix->midr_rv && (revidr & fix->revidr_mask)) |
| 40 | return false; |
| 41 | |
| 42 | return true; |
Andre Przywara | 301bcfa | 2014-11-14 15:54:10 +0000 | [diff] [blame] | 43 | } |
| 44 | |
Stephen Boyd | bb48711 | 2017-12-13 14:19:37 -0800 | [diff] [blame] | 45 | static bool __maybe_unused |
Suzuki K Poulose | be5b299 | 2018-03-26 15:12:45 +0100 | [diff] [blame] | 46 | is_affected_midr_range_list(const struct arm64_cpu_capabilities *entry, |
| 47 | int scope) |
| 48 | { |
| 49 | WARN_ON(scope != SCOPE_LOCAL_CPU || preemptible()); |
| 50 | return is_midr_in_range_list(read_cpuid_id(), entry->midr_range_list); |
Andre Przywara | 301bcfa | 2014-11-14 15:54:10 +0000 | [diff] [blame] | 51 | } |
| 52 | |
Stephen Boyd | bb48711 | 2017-12-13 14:19:37 -0800 | [diff] [blame] | 53 | static bool __maybe_unused |
| 54 | is_kryo_midr(const struct arm64_cpu_capabilities *entry, int scope) |
| 55 | { |
| 56 | u32 model; |
| 57 | |
| 58 | WARN_ON(scope != SCOPE_LOCAL_CPU || preemptible()); |
| 59 | |
| 60 | model = read_cpuid_id(); |
| 61 | model &= MIDR_IMPLEMENTOR_MASK | (0xf00 << MIDR_PARTNUM_SHIFT) | |
| 62 | MIDR_ARCHITECTURE_MASK; |
| 63 | |
Suzuki K Poulose | 1df3105 | 2018-03-26 15:12:44 +0100 | [diff] [blame] | 64 | return model == entry->midr_range.model; |
Stephen Boyd | bb48711 | 2017-12-13 14:19:37 -0800 | [diff] [blame] | 65 | } |
| 66 | |
Suzuki K Poulose | 116c81f | 2016-09-09 14:07:16 +0100 | [diff] [blame] | 67 | static bool |
Suzuki K Poulose | 314d53d | 2018-07-04 23:07:46 +0100 | [diff] [blame] | 68 | has_mismatched_cache_type(const struct arm64_cpu_capabilities *entry, |
| 69 | int scope) |
Suzuki K Poulose | 116c81f | 2016-09-09 14:07:16 +0100 | [diff] [blame] | 70 | { |
Suzuki K Poulose | 1602df0 | 2018-10-09 14:47:06 +0100 | [diff] [blame] | 71 | u64 mask = arm64_ftr_reg_ctrel0.strict_mask; |
| 72 | u64 sys = arm64_ftr_reg_ctrel0.sys_val & mask; |
| 73 | u64 ctr_raw, ctr_real; |
Suzuki K Poulose | 314d53d | 2018-07-04 23:07:46 +0100 | [diff] [blame] | 74 | |
Suzuki K Poulose | 116c81f | 2016-09-09 14:07:16 +0100 | [diff] [blame] | 75 | WARN_ON(scope != SCOPE_LOCAL_CPU || preemptible()); |
Suzuki K Poulose | 1602df0 | 2018-10-09 14:47:06 +0100 | [diff] [blame] | 76 | |
| 77 | /* |
| 78 | * We want to make sure that all the CPUs in the system expose |
| 79 | * a consistent CTR_EL0 to make sure that applications behaves |
| 80 | * correctly with migration. |
| 81 | * |
| 82 | * If a CPU has CTR_EL0.IDC but does not advertise it via CTR_EL0 : |
| 83 | * |
| 84 | * 1) It is safe if the system doesn't support IDC, as CPU anyway |
| 85 | * reports IDC = 0, consistent with the rest. |
| 86 | * |
| 87 | * 2) If the system has IDC, it is still safe as we trap CTR_EL0 |
| 88 | * access on this CPU via the ARM64_HAS_CACHE_IDC capability. |
| 89 | * |
| 90 | * So, we need to make sure either the raw CTR_EL0 or the effective |
| 91 | * CTR_EL0 matches the system's copy to allow a secondary CPU to boot. |
| 92 | */ |
| 93 | ctr_raw = read_cpuid_cachetype() & mask; |
| 94 | ctr_real = read_cpuid_effective_cachetype() & mask; |
| 95 | |
| 96 | return (ctr_real != sys) && (ctr_raw != sys); |
Suzuki K Poulose | 116c81f | 2016-09-09 14:07:16 +0100 | [diff] [blame] | 97 | } |
| 98 | |
Dave Martin | c0cda3b | 2018-03-26 15:12:28 +0100 | [diff] [blame] | 99 | static void |
| 100 | cpu_enable_trap_ctr_access(const struct arm64_cpu_capabilities *__unused) |
Suzuki K Poulose | 116c81f | 2016-09-09 14:07:16 +0100 | [diff] [blame] | 101 | { |
Suzuki K Poulose | 4afe8e7 | 2018-10-09 14:47:07 +0100 | [diff] [blame] | 102 | u64 mask = arm64_ftr_reg_ctrel0.strict_mask; |
| 103 | |
| 104 | /* Trap CTR_EL0 access on this CPU, only if it has a mismatch */ |
| 105 | if ((read_cpuid_cachetype() & mask) != |
| 106 | (arm64_ftr_reg_ctrel0.sys_val & mask)) |
| 107 | sysreg_clear_set(sctlr_el1, SCTLR_EL1_UCT, 0); |
Suzuki K Poulose | 116c81f | 2016-09-09 14:07:16 +0100 | [diff] [blame] | 108 | } |
| 109 | |
Marc Zyngier | 4205a89 | 2018-03-13 12:40:39 +0000 | [diff] [blame] | 110 | atomic_t arm64_el2_vector_last_slot = ATOMIC_INIT(-1); |
| 111 | |
Will Deacon | 0f15adb | 2018-01-03 11:17:58 +0000 | [diff] [blame] | 112 | #ifdef CONFIG_HARDEN_BRANCH_PREDICTOR |
| 113 | #include <asm/mmu_context.h> |
| 114 | #include <asm/cacheflush.h> |
| 115 | |
| 116 | DEFINE_PER_CPU_READ_MOSTLY(struct bp_hardening_data, bp_hardening_data); |
| 117 | |
Marc Zyngier | e8b22d0f | 2018-04-10 11:36:45 +0100 | [diff] [blame] | 118 | #ifdef CONFIG_KVM_INDIRECT_VECTORS |
Marc Zyngier | b092201 | 2018-02-06 17:56:20 +0000 | [diff] [blame] | 119 | extern char __smccc_workaround_1_smc_start[]; |
| 120 | extern char __smccc_workaround_1_smc_end[]; |
Will Deacon | aa6acde | 2018-01-03 12:46:21 +0000 | [diff] [blame] | 121 | |
Will Deacon | 0f15adb | 2018-01-03 11:17:58 +0000 | [diff] [blame] | 122 | static void __copy_hyp_vect_bpi(int slot, const char *hyp_vecs_start, |
| 123 | const char *hyp_vecs_end) |
| 124 | { |
| 125 | void *dst = lm_alias(__bp_harden_hyp_vecs_start + slot * SZ_2K); |
| 126 | int i; |
| 127 | |
| 128 | for (i = 0; i < SZ_2K; i += 0x80) |
| 129 | memcpy(dst + i, hyp_vecs_start, hyp_vecs_end - hyp_vecs_start); |
| 130 | |
Will Deacon | 3b8c9f1 | 2018-06-11 14:22:09 +0100 | [diff] [blame] | 131 | __flush_icache_range((uintptr_t)dst, (uintptr_t)dst + SZ_2K); |
Will Deacon | 0f15adb | 2018-01-03 11:17:58 +0000 | [diff] [blame] | 132 | } |
| 133 | |
| 134 | static void __install_bp_hardening_cb(bp_hardening_cb_t fn, |
| 135 | const char *hyp_vecs_start, |
| 136 | const char *hyp_vecs_end) |
| 137 | { |
James Morse | d8797b1 | 2018-11-27 15:35:21 +0000 | [diff] [blame] | 138 | static DEFINE_RAW_SPINLOCK(bp_lock); |
Will Deacon | 0f15adb | 2018-01-03 11:17:58 +0000 | [diff] [blame] | 139 | int cpu, slot = -1; |
| 140 | |
James Morse | 4debef5 | 2018-09-21 21:49:19 +0100 | [diff] [blame] | 141 | /* |
| 142 | * enable_smccc_arch_workaround_1() passes NULL for the hyp_vecs |
| 143 | * start/end if we're a guest. Skip the hyp-vectors work. |
| 144 | */ |
| 145 | if (!hyp_vecs_start) { |
| 146 | __this_cpu_write(bp_hardening_data.fn, fn); |
| 147 | return; |
| 148 | } |
| 149 | |
James Morse | d8797b1 | 2018-11-27 15:35:21 +0000 | [diff] [blame] | 150 | raw_spin_lock(&bp_lock); |
Will Deacon | 0f15adb | 2018-01-03 11:17:58 +0000 | [diff] [blame] | 151 | for_each_possible_cpu(cpu) { |
| 152 | if (per_cpu(bp_hardening_data.fn, cpu) == fn) { |
| 153 | slot = per_cpu(bp_hardening_data.hyp_vectors_slot, cpu); |
| 154 | break; |
| 155 | } |
| 156 | } |
| 157 | |
| 158 | if (slot == -1) { |
Marc Zyngier | 4205a89 | 2018-03-13 12:40:39 +0000 | [diff] [blame] | 159 | slot = atomic_inc_return(&arm64_el2_vector_last_slot); |
| 160 | BUG_ON(slot >= BP_HARDEN_EL2_SLOTS); |
Will Deacon | 0f15adb | 2018-01-03 11:17:58 +0000 | [diff] [blame] | 161 | __copy_hyp_vect_bpi(slot, hyp_vecs_start, hyp_vecs_end); |
| 162 | } |
| 163 | |
| 164 | __this_cpu_write(bp_hardening_data.hyp_vectors_slot, slot); |
| 165 | __this_cpu_write(bp_hardening_data.fn, fn); |
James Morse | d8797b1 | 2018-11-27 15:35:21 +0000 | [diff] [blame] | 166 | raw_spin_unlock(&bp_lock); |
Will Deacon | 0f15adb | 2018-01-03 11:17:58 +0000 | [diff] [blame] | 167 | } |
| 168 | #else |
Marc Zyngier | b092201 | 2018-02-06 17:56:20 +0000 | [diff] [blame] | 169 | #define __smccc_workaround_1_smc_start NULL |
| 170 | #define __smccc_workaround_1_smc_end NULL |
Will Deacon | aa6acde | 2018-01-03 12:46:21 +0000 | [diff] [blame] | 171 | |
Will Deacon | 0f15adb | 2018-01-03 11:17:58 +0000 | [diff] [blame] | 172 | static void __install_bp_hardening_cb(bp_hardening_cb_t fn, |
| 173 | const char *hyp_vecs_start, |
| 174 | const char *hyp_vecs_end) |
| 175 | { |
| 176 | __this_cpu_write(bp_hardening_data.fn, fn); |
| 177 | } |
Marc Zyngier | e8b22d0f | 2018-04-10 11:36:45 +0100 | [diff] [blame] | 178 | #endif /* CONFIG_KVM_INDIRECT_VECTORS */ |
Will Deacon | 0f15adb | 2018-01-03 11:17:58 +0000 | [diff] [blame] | 179 | |
| 180 | static void install_bp_hardening_cb(const struct arm64_cpu_capabilities *entry, |
| 181 | bp_hardening_cb_t fn, |
| 182 | const char *hyp_vecs_start, |
| 183 | const char *hyp_vecs_end) |
| 184 | { |
| 185 | u64 pfr0; |
| 186 | |
| 187 | if (!entry->matches(entry, SCOPE_LOCAL_CPU)) |
| 188 | return; |
| 189 | |
| 190 | pfr0 = read_cpuid(ID_AA64PFR0_EL1); |
| 191 | if (cpuid_feature_extract_unsigned_field(pfr0, ID_AA64PFR0_CSV2_SHIFT)) |
| 192 | return; |
| 193 | |
| 194 | __install_bp_hardening_cb(fn, hyp_vecs_start, hyp_vecs_end); |
| 195 | } |
Will Deacon | aa6acde | 2018-01-03 12:46:21 +0000 | [diff] [blame] | 196 | |
Marc Zyngier | b092201 | 2018-02-06 17:56:20 +0000 | [diff] [blame] | 197 | #include <uapi/linux/psci.h> |
| 198 | #include <linux/arm-smccc.h> |
Will Deacon | aa6acde | 2018-01-03 12:46:21 +0000 | [diff] [blame] | 199 | #include <linux/psci.h> |
| 200 | |
Marc Zyngier | b092201 | 2018-02-06 17:56:20 +0000 | [diff] [blame] | 201 | static void call_smc_arch_workaround_1(void) |
| 202 | { |
| 203 | arm_smccc_1_1_smc(ARM_SMCCC_ARCH_WORKAROUND_1, NULL); |
| 204 | } |
| 205 | |
| 206 | static void call_hvc_arch_workaround_1(void) |
| 207 | { |
| 208 | arm_smccc_1_1_hvc(ARM_SMCCC_ARCH_WORKAROUND_1, NULL); |
| 209 | } |
| 210 | |
Shanker Donthineni | 4bc352f | 2018-04-10 11:36:42 +0100 | [diff] [blame] | 211 | static void qcom_link_stack_sanitization(void) |
| 212 | { |
| 213 | u64 tmp; |
| 214 | |
| 215 | asm volatile("mov %0, x30 \n" |
| 216 | ".rept 16 \n" |
| 217 | "bl . + 4 \n" |
| 218 | ".endr \n" |
| 219 | "mov x30, %0 \n" |
| 220 | : "=&r" (tmp)); |
| 221 | } |
| 222 | |
Dave Martin | c0cda3b | 2018-03-26 15:12:28 +0100 | [diff] [blame] | 223 | static void |
| 224 | enable_smccc_arch_workaround_1(const struct arm64_cpu_capabilities *entry) |
Marc Zyngier | b092201 | 2018-02-06 17:56:20 +0000 | [diff] [blame] | 225 | { |
| 226 | bp_hardening_cb_t cb; |
| 227 | void *smccc_start, *smccc_end; |
| 228 | struct arm_smccc_res res; |
Shanker Donthineni | 4bc352f | 2018-04-10 11:36:42 +0100 | [diff] [blame] | 229 | u32 midr = read_cpuid_id(); |
Marc Zyngier | b092201 | 2018-02-06 17:56:20 +0000 | [diff] [blame] | 230 | |
| 231 | if (!entry->matches(entry, SCOPE_LOCAL_CPU)) |
Dave Martin | c0cda3b | 2018-03-26 15:12:28 +0100 | [diff] [blame] | 232 | return; |
Marc Zyngier | b092201 | 2018-02-06 17:56:20 +0000 | [diff] [blame] | 233 | |
| 234 | if (psci_ops.smccc_version == SMCCC_VERSION_1_0) |
Dave Martin | c0cda3b | 2018-03-26 15:12:28 +0100 | [diff] [blame] | 235 | return; |
Marc Zyngier | b092201 | 2018-02-06 17:56:20 +0000 | [diff] [blame] | 236 | |
| 237 | switch (psci_ops.conduit) { |
| 238 | case PSCI_CONDUIT_HVC: |
| 239 | arm_smccc_1_1_hvc(ARM_SMCCC_ARCH_FEATURES_FUNC_ID, |
| 240 | ARM_SMCCC_ARCH_WORKAROUND_1, &res); |
Marc Zyngier | e21da1c | 2018-03-09 15:40:50 +0000 | [diff] [blame] | 241 | if ((int)res.a0 < 0) |
Dave Martin | c0cda3b | 2018-03-26 15:12:28 +0100 | [diff] [blame] | 242 | return; |
Marc Zyngier | b092201 | 2018-02-06 17:56:20 +0000 | [diff] [blame] | 243 | cb = call_hvc_arch_workaround_1; |
Marc Zyngier | 22765f3 | 2018-04-10 11:36:44 +0100 | [diff] [blame] | 244 | /* This is a guest, no need to patch KVM vectors */ |
| 245 | smccc_start = NULL; |
| 246 | smccc_end = NULL; |
Marc Zyngier | b092201 | 2018-02-06 17:56:20 +0000 | [diff] [blame] | 247 | break; |
| 248 | |
| 249 | case PSCI_CONDUIT_SMC: |
| 250 | arm_smccc_1_1_smc(ARM_SMCCC_ARCH_FEATURES_FUNC_ID, |
| 251 | ARM_SMCCC_ARCH_WORKAROUND_1, &res); |
Marc Zyngier | e21da1c | 2018-03-09 15:40:50 +0000 | [diff] [blame] | 252 | if ((int)res.a0 < 0) |
Dave Martin | c0cda3b | 2018-03-26 15:12:28 +0100 | [diff] [blame] | 253 | return; |
Marc Zyngier | b092201 | 2018-02-06 17:56:20 +0000 | [diff] [blame] | 254 | cb = call_smc_arch_workaround_1; |
| 255 | smccc_start = __smccc_workaround_1_smc_start; |
| 256 | smccc_end = __smccc_workaround_1_smc_end; |
| 257 | break; |
| 258 | |
| 259 | default: |
Dave Martin | c0cda3b | 2018-03-26 15:12:28 +0100 | [diff] [blame] | 260 | return; |
Marc Zyngier | b092201 | 2018-02-06 17:56:20 +0000 | [diff] [blame] | 261 | } |
| 262 | |
Shanker Donthineni | 4bc352f | 2018-04-10 11:36:42 +0100 | [diff] [blame] | 263 | if (((midr & MIDR_CPU_MODEL_MASK) == MIDR_QCOM_FALKOR) || |
| 264 | ((midr & MIDR_CPU_MODEL_MASK) == MIDR_QCOM_FALKOR_V1)) |
| 265 | cb = qcom_link_stack_sanitization; |
| 266 | |
Marc Zyngier | b092201 | 2018-02-06 17:56:20 +0000 | [diff] [blame] | 267 | install_bp_hardening_cb(entry, cb, smccc_start, smccc_end); |
| 268 | |
Dave Martin | c0cda3b | 2018-03-26 15:12:28 +0100 | [diff] [blame] | 269 | return; |
Will Deacon | aa6acde | 2018-01-03 12:46:21 +0000 | [diff] [blame] | 270 | } |
Will Deacon | 0f15adb | 2018-01-03 11:17:58 +0000 | [diff] [blame] | 271 | #endif /* CONFIG_HARDEN_BRANCH_PREDICTOR */ |
| 272 | |
Marc Zyngier | 8e29062 | 2018-05-29 13:11:06 +0100 | [diff] [blame] | 273 | #ifdef CONFIG_ARM64_SSBD |
Marc Zyngier | 5cf9ce6 | 2018-05-29 13:11:07 +0100 | [diff] [blame] | 274 | DEFINE_PER_CPU_READ_MOSTLY(u64, arm64_ssbd_callback_required); |
| 275 | |
Marc Zyngier | a43ae4d | 2018-05-29 13:11:09 +0100 | [diff] [blame] | 276 | int ssbd_state __read_mostly = ARM64_SSBD_KERNEL; |
| 277 | |
| 278 | static const struct ssbd_options { |
| 279 | const char *str; |
| 280 | int state; |
| 281 | } ssbd_options[] = { |
| 282 | { "force-on", ARM64_SSBD_FORCE_ENABLE, }, |
| 283 | { "force-off", ARM64_SSBD_FORCE_DISABLE, }, |
| 284 | { "kernel", ARM64_SSBD_KERNEL, }, |
| 285 | }; |
| 286 | |
| 287 | static int __init ssbd_cfg(char *buf) |
| 288 | { |
| 289 | int i; |
| 290 | |
| 291 | if (!buf || !buf[0]) |
| 292 | return -EINVAL; |
| 293 | |
| 294 | for (i = 0; i < ARRAY_SIZE(ssbd_options); i++) { |
| 295 | int len = strlen(ssbd_options[i].str); |
| 296 | |
| 297 | if (strncmp(buf, ssbd_options[i].str, len)) |
| 298 | continue; |
| 299 | |
| 300 | ssbd_state = ssbd_options[i].state; |
| 301 | return 0; |
| 302 | } |
| 303 | |
| 304 | return -EINVAL; |
| 305 | } |
| 306 | early_param("ssbd", ssbd_cfg); |
| 307 | |
Marc Zyngier | 8e29062 | 2018-05-29 13:11:06 +0100 | [diff] [blame] | 308 | void __init arm64_update_smccc_conduit(struct alt_instr *alt, |
| 309 | __le32 *origptr, __le32 *updptr, |
| 310 | int nr_inst) |
| 311 | { |
| 312 | u32 insn; |
| 313 | |
| 314 | BUG_ON(nr_inst != 1); |
| 315 | |
| 316 | switch (psci_ops.conduit) { |
| 317 | case PSCI_CONDUIT_HVC: |
| 318 | insn = aarch64_insn_get_hvc_value(); |
| 319 | break; |
| 320 | case PSCI_CONDUIT_SMC: |
| 321 | insn = aarch64_insn_get_smc_value(); |
| 322 | break; |
| 323 | default: |
| 324 | return; |
| 325 | } |
| 326 | |
| 327 | *updptr = cpu_to_le32(insn); |
| 328 | } |
Marc Zyngier | a725e3d | 2018-05-29 13:11:08 +0100 | [diff] [blame] | 329 | |
Marc Zyngier | 986372c | 2018-05-29 13:11:11 +0100 | [diff] [blame] | 330 | void __init arm64_enable_wa2_handling(struct alt_instr *alt, |
| 331 | __le32 *origptr, __le32 *updptr, |
| 332 | int nr_inst) |
| 333 | { |
| 334 | BUG_ON(nr_inst != 1); |
| 335 | /* |
| 336 | * Only allow mitigation on EL1 entry/exit and guest |
| 337 | * ARCH_WORKAROUND_2 handling if the SSBD state allows it to |
| 338 | * be flipped. |
| 339 | */ |
| 340 | if (arm64_get_ssbd_state() == ARM64_SSBD_KERNEL) |
| 341 | *updptr = cpu_to_le32(aarch64_insn_gen_nop()); |
| 342 | } |
| 343 | |
Marc Zyngier | 647d051 | 2018-05-29 13:11:12 +0100 | [diff] [blame] | 344 | void arm64_set_ssbd_mitigation(bool state) |
Marc Zyngier | a725e3d | 2018-05-29 13:11:08 +0100 | [diff] [blame] | 345 | { |
Will Deacon | 8f04e8e | 2018-08-07 13:47:06 +0100 | [diff] [blame] | 346 | if (this_cpu_has_cap(ARM64_SSBS)) { |
| 347 | if (state) |
| 348 | asm volatile(SET_PSTATE_SSBS(0)); |
| 349 | else |
| 350 | asm volatile(SET_PSTATE_SSBS(1)); |
| 351 | return; |
| 352 | } |
| 353 | |
Marc Zyngier | a725e3d | 2018-05-29 13:11:08 +0100 | [diff] [blame] | 354 | switch (psci_ops.conduit) { |
| 355 | case PSCI_CONDUIT_HVC: |
| 356 | arm_smccc_1_1_hvc(ARM_SMCCC_ARCH_WORKAROUND_2, state, NULL); |
| 357 | break; |
| 358 | |
| 359 | case PSCI_CONDUIT_SMC: |
| 360 | arm_smccc_1_1_smc(ARM_SMCCC_ARCH_WORKAROUND_2, state, NULL); |
| 361 | break; |
| 362 | |
| 363 | default: |
| 364 | WARN_ON_ONCE(1); |
| 365 | break; |
| 366 | } |
| 367 | } |
| 368 | |
| 369 | static bool has_ssbd_mitigation(const struct arm64_cpu_capabilities *entry, |
| 370 | int scope) |
| 371 | { |
| 372 | struct arm_smccc_res res; |
Marc Zyngier | a43ae4d | 2018-05-29 13:11:09 +0100 | [diff] [blame] | 373 | bool required = true; |
| 374 | s32 val; |
Marc Zyngier | a725e3d | 2018-05-29 13:11:08 +0100 | [diff] [blame] | 375 | |
| 376 | WARN_ON(scope != SCOPE_LOCAL_CPU || preemptible()); |
| 377 | |
Will Deacon | 8f04e8e | 2018-08-07 13:47:06 +0100 | [diff] [blame] | 378 | if (this_cpu_has_cap(ARM64_SSBS)) { |
| 379 | required = false; |
| 380 | goto out_printmsg; |
| 381 | } |
| 382 | |
Marc Zyngier | a43ae4d | 2018-05-29 13:11:09 +0100 | [diff] [blame] | 383 | if (psci_ops.smccc_version == SMCCC_VERSION_1_0) { |
| 384 | ssbd_state = ARM64_SSBD_UNKNOWN; |
Marc Zyngier | a725e3d | 2018-05-29 13:11:08 +0100 | [diff] [blame] | 385 | return false; |
Marc Zyngier | a43ae4d | 2018-05-29 13:11:09 +0100 | [diff] [blame] | 386 | } |
Marc Zyngier | a725e3d | 2018-05-29 13:11:08 +0100 | [diff] [blame] | 387 | |
Marc Zyngier | a725e3d | 2018-05-29 13:11:08 +0100 | [diff] [blame] | 388 | switch (psci_ops.conduit) { |
| 389 | case PSCI_CONDUIT_HVC: |
| 390 | arm_smccc_1_1_hvc(ARM_SMCCC_ARCH_FEATURES_FUNC_ID, |
| 391 | ARM_SMCCC_ARCH_WORKAROUND_2, &res); |
Marc Zyngier | a725e3d | 2018-05-29 13:11:08 +0100 | [diff] [blame] | 392 | break; |
| 393 | |
| 394 | case PSCI_CONDUIT_SMC: |
| 395 | arm_smccc_1_1_smc(ARM_SMCCC_ARCH_FEATURES_FUNC_ID, |
| 396 | ARM_SMCCC_ARCH_WORKAROUND_2, &res); |
Marc Zyngier | a725e3d | 2018-05-29 13:11:08 +0100 | [diff] [blame] | 397 | break; |
| 398 | |
| 399 | default: |
Marc Zyngier | a43ae4d | 2018-05-29 13:11:09 +0100 | [diff] [blame] | 400 | ssbd_state = ARM64_SSBD_UNKNOWN; |
| 401 | return false; |
Marc Zyngier | a725e3d | 2018-05-29 13:11:08 +0100 | [diff] [blame] | 402 | } |
| 403 | |
Marc Zyngier | a43ae4d | 2018-05-29 13:11:09 +0100 | [diff] [blame] | 404 | val = (s32)res.a0; |
| 405 | |
| 406 | switch (val) { |
| 407 | case SMCCC_RET_NOT_SUPPORTED: |
| 408 | ssbd_state = ARM64_SSBD_UNKNOWN; |
| 409 | return false; |
| 410 | |
| 411 | case SMCCC_RET_NOT_REQUIRED: |
| 412 | pr_info_once("%s mitigation not required\n", entry->desc); |
| 413 | ssbd_state = ARM64_SSBD_MITIGATED; |
| 414 | return false; |
| 415 | |
| 416 | case SMCCC_RET_SUCCESS: |
| 417 | required = true; |
| 418 | break; |
| 419 | |
| 420 | case 1: /* Mitigation not required on this CPU */ |
| 421 | required = false; |
| 422 | break; |
| 423 | |
| 424 | default: |
| 425 | WARN_ON(1); |
| 426 | return false; |
| 427 | } |
| 428 | |
| 429 | switch (ssbd_state) { |
| 430 | case ARM64_SSBD_FORCE_DISABLE: |
Marc Zyngier | a43ae4d | 2018-05-29 13:11:09 +0100 | [diff] [blame] | 431 | arm64_set_ssbd_mitigation(false); |
| 432 | required = false; |
| 433 | break; |
| 434 | |
| 435 | case ARM64_SSBD_KERNEL: |
| 436 | if (required) { |
| 437 | __this_cpu_write(arm64_ssbd_callback_required, 1); |
| 438 | arm64_set_ssbd_mitigation(true); |
| 439 | } |
| 440 | break; |
| 441 | |
| 442 | case ARM64_SSBD_FORCE_ENABLE: |
Marc Zyngier | a725e3d | 2018-05-29 13:11:08 +0100 | [diff] [blame] | 443 | arm64_set_ssbd_mitigation(true); |
Marc Zyngier | a43ae4d | 2018-05-29 13:11:09 +0100 | [diff] [blame] | 444 | required = true; |
| 445 | break; |
| 446 | |
| 447 | default: |
| 448 | WARN_ON(1); |
| 449 | break; |
Marc Zyngier | a725e3d | 2018-05-29 13:11:08 +0100 | [diff] [blame] | 450 | } |
| 451 | |
Will Deacon | 8f04e8e | 2018-08-07 13:47:06 +0100 | [diff] [blame] | 452 | out_printmsg: |
| 453 | switch (ssbd_state) { |
| 454 | case ARM64_SSBD_FORCE_DISABLE: |
| 455 | pr_info_once("%s disabled from command-line\n", entry->desc); |
| 456 | break; |
| 457 | |
| 458 | case ARM64_SSBD_FORCE_ENABLE: |
| 459 | pr_info_once("%s forced from command-line\n", entry->desc); |
| 460 | break; |
| 461 | } |
| 462 | |
Marc Zyngier | a43ae4d | 2018-05-29 13:11:09 +0100 | [diff] [blame] | 463 | return required; |
Marc Zyngier | a725e3d | 2018-05-29 13:11:08 +0100 | [diff] [blame] | 464 | } |
Marc Zyngier | 8e29062 | 2018-05-29 13:11:06 +0100 | [diff] [blame] | 465 | #endif /* CONFIG_ARM64_SSBD */ |
| 466 | |
Will Deacon | b8925ee | 2018-08-07 13:53:41 +0100 | [diff] [blame] | 467 | static void __maybe_unused |
| 468 | cpu_enable_cache_maint_trap(const struct arm64_cpu_capabilities *__unused) |
| 469 | { |
| 470 | sysreg_clear_set(sctlr_el1, SCTLR_EL1_UCI, 0); |
| 471 | } |
| 472 | |
Suzuki K Poulose | 5e7951c | 2018-03-26 15:12:43 +0100 | [diff] [blame] | 473 | #define CAP_MIDR_RANGE(model, v_min, r_min, v_max, r_max) \ |
| 474 | .matches = is_affected_midr_range, \ |
Suzuki K Poulose | 1df3105 | 2018-03-26 15:12:44 +0100 | [diff] [blame] | 475 | .midr_range = MIDR_RANGE(model, v_min, r_min, v_max, r_max) |
Andre Przywara | 301bcfa | 2014-11-14 15:54:10 +0000 | [diff] [blame] | 476 | |
Suzuki K Poulose | 5e7951c | 2018-03-26 15:12:43 +0100 | [diff] [blame] | 477 | #define CAP_MIDR_ALL_VERSIONS(model) \ |
| 478 | .matches = is_affected_midr_range, \ |
Suzuki K Poulose | 1df3105 | 2018-03-26 15:12:44 +0100 | [diff] [blame] | 479 | .midr_range = MIDR_ALL_VERSIONS(model) |
Marc Zyngier | 06f1494 | 2017-02-01 14:38:46 +0000 | [diff] [blame] | 480 | |
Ard Biesheuvel | e8002e0 | 2018-03-06 17:15:34 +0000 | [diff] [blame] | 481 | #define MIDR_FIXED(rev, revidr_mask) \ |
| 482 | .fixed_revs = (struct arm64_midr_revidr[]){{ (rev), (revidr_mask) }, {}} |
| 483 | |
Suzuki K Poulose | 5e7951c | 2018-03-26 15:12:43 +0100 | [diff] [blame] | 484 | #define ERRATA_MIDR_RANGE(model, v_min, r_min, v_max, r_max) \ |
| 485 | .type = ARM64_CPUCAP_LOCAL_CPU_ERRATUM, \ |
| 486 | CAP_MIDR_RANGE(model, v_min, r_min, v_max, r_max) |
| 487 | |
Suzuki K Poulose | be5b299 | 2018-03-26 15:12:45 +0100 | [diff] [blame] | 488 | #define CAP_MIDR_RANGE_LIST(list) \ |
| 489 | .matches = is_affected_midr_range_list, \ |
| 490 | .midr_range_list = list |
| 491 | |
Suzuki K Poulose | 5e7951c | 2018-03-26 15:12:43 +0100 | [diff] [blame] | 492 | /* Errata affecting a range of revisions of given model variant */ |
| 493 | #define ERRATA_MIDR_REV_RANGE(m, var, r_min, r_max) \ |
| 494 | ERRATA_MIDR_RANGE(m, var, r_min, var, r_max) |
| 495 | |
| 496 | /* Errata affecting a single variant/revision of a model */ |
| 497 | #define ERRATA_MIDR_REV(model, var, rev) \ |
| 498 | ERRATA_MIDR_RANGE(model, var, rev, var, rev) |
| 499 | |
| 500 | /* Errata affecting all variants/revisions of a given a model */ |
| 501 | #define ERRATA_MIDR_ALL_VERSIONS(model) \ |
| 502 | .type = ARM64_CPUCAP_LOCAL_CPU_ERRATUM, \ |
| 503 | CAP_MIDR_ALL_VERSIONS(model) |
| 504 | |
Suzuki K Poulose | be5b299 | 2018-03-26 15:12:45 +0100 | [diff] [blame] | 505 | /* Errata affecting a list of midr ranges, with same work around */ |
| 506 | #define ERRATA_MIDR_RANGE_LIST(midr_list) \ |
| 507 | .type = ARM64_CPUCAP_LOCAL_CPU_ERRATUM, \ |
| 508 | CAP_MIDR_RANGE_LIST(midr_list) |
| 509 | |
| 510 | #ifdef CONFIG_HARDEN_BRANCH_PREDICTOR |
| 511 | |
| 512 | /* |
| 513 | * List of CPUs where we need to issue a psci call to |
| 514 | * harden the branch predictor. |
| 515 | */ |
| 516 | static const struct midr_range arm64_bp_harden_smccc_cpus[] = { |
| 517 | MIDR_ALL_VERSIONS(MIDR_CORTEX_A57), |
| 518 | MIDR_ALL_VERSIONS(MIDR_CORTEX_A72), |
| 519 | MIDR_ALL_VERSIONS(MIDR_CORTEX_A73), |
| 520 | MIDR_ALL_VERSIONS(MIDR_CORTEX_A75), |
| 521 | MIDR_ALL_VERSIONS(MIDR_BRCM_VULCAN), |
| 522 | MIDR_ALL_VERSIONS(MIDR_CAVIUM_THUNDERX2), |
Suzuki K Poulose | be5b299 | 2018-03-26 15:12:45 +0100 | [diff] [blame] | 523 | MIDR_ALL_VERSIONS(MIDR_QCOM_FALKOR_V1), |
| 524 | MIDR_ALL_VERSIONS(MIDR_QCOM_FALKOR), |
David Gilhooley | 0583a4e | 2018-05-08 15:49:43 -0700 | [diff] [blame] | 525 | MIDR_ALL_VERSIONS(MIDR_NVIDIA_DENVER), |
Suzuki K Poulose | be5b299 | 2018-03-26 15:12:45 +0100 | [diff] [blame] | 526 | {}, |
| 527 | }; |
| 528 | |
| 529 | #endif |
Andre Przywara | 301bcfa | 2014-11-14 15:54:10 +0000 | [diff] [blame] | 530 | |
Marc Zyngier | 8892b71 | 2018-04-10 11:36:43 +0100 | [diff] [blame] | 531 | #ifdef CONFIG_HARDEN_EL2_VECTORS |
| 532 | |
| 533 | static const struct midr_range arm64_harden_el2_vectors[] = { |
| 534 | MIDR_ALL_VERSIONS(MIDR_CORTEX_A57), |
| 535 | MIDR_ALL_VERSIONS(MIDR_CORTEX_A72), |
| 536 | {}, |
| 537 | }; |
| 538 | |
Marc Zyngier | dc6ed61 | 2018-03-28 12:46:07 +0100 | [diff] [blame] | 539 | #endif |
| 540 | |
Catalin Marinas | ce8c80c | 2018-11-19 11:27:28 +0000 | [diff] [blame] | 541 | #ifdef CONFIG_ARM64_WORKAROUND_REPEAT_TLBI |
| 542 | |
| 543 | static const struct midr_range arm64_repeat_tlbi_cpus[] = { |
| 544 | #ifdef CONFIG_QCOM_FALKOR_ERRATUM_1009 |
| 545 | MIDR_RANGE(MIDR_QCOM_FALKOR_V1, 0, 0, 0, 0), |
| 546 | #endif |
| 547 | #ifdef CONFIG_ARM64_ERRATUM_1286807 |
| 548 | MIDR_RANGE(MIDR_CORTEX_A76, 0, 0, 3, 0), |
| 549 | #endif |
| 550 | {}, |
| 551 | }; |
| 552 | |
| 553 | #endif |
| 554 | |
Suzuki K Poulose | f58cdf7 | 2018-11-30 17:18:01 +0000 | [diff] [blame] | 555 | #ifdef CONFIG_CAVIUM_ERRATUM_27456 |
Will Deacon | b89d82e | 2019-01-08 16:19:01 +0000 | [diff] [blame] | 556 | const struct midr_range cavium_erratum_27456_cpus[] = { |
Suzuki K Poulose | f58cdf7 | 2018-11-30 17:18:01 +0000 | [diff] [blame] | 557 | /* Cavium ThunderX, T88 pass 1.x - 2.1 */ |
| 558 | MIDR_RANGE(MIDR_THUNDERX, 0, 0, 1, 1), |
| 559 | /* Cavium ThunderX, T81 pass 1.0 */ |
| 560 | MIDR_REV(MIDR_THUNDERX_81XX, 0, 0), |
| 561 | {}, |
| 562 | }; |
| 563 | #endif |
| 564 | |
| 565 | #ifdef CONFIG_CAVIUM_ERRATUM_30115 |
| 566 | static const struct midr_range cavium_erratum_30115_cpus[] = { |
| 567 | /* Cavium ThunderX, T88 pass 1.x - 2.2 */ |
| 568 | MIDR_RANGE(MIDR_THUNDERX, 0, 0, 1, 2), |
| 569 | /* Cavium ThunderX, T81 pass 1.0 - 1.2 */ |
| 570 | MIDR_REV_RANGE(MIDR_THUNDERX_81XX, 0, 0, 2), |
| 571 | /* Cavium ThunderX, T83 pass 1.0 */ |
| 572 | MIDR_REV(MIDR_THUNDERX_83XX, 0, 0), |
| 573 | {}, |
| 574 | }; |
| 575 | #endif |
| 576 | |
Suzuki K Poulose | a3dcea2c | 2018-11-30 17:18:02 +0000 | [diff] [blame] | 577 | #ifdef CONFIG_QCOM_FALKOR_ERRATUM_1003 |
| 578 | static const struct arm64_cpu_capabilities qcom_erratum_1003_list[] = { |
| 579 | { |
| 580 | ERRATA_MIDR_REV(MIDR_QCOM_FALKOR_V1, 0, 0), |
| 581 | }, |
| 582 | { |
| 583 | .midr_range.model = MIDR_QCOM_KRYO, |
| 584 | .matches = is_kryo_midr, |
| 585 | }, |
| 586 | {}, |
| 587 | }; |
| 588 | #endif |
| 589 | |
Suzuki K Poulose | c9460dc | 2018-11-30 17:18:00 +0000 | [diff] [blame] | 590 | #ifdef CONFIG_ARM64_WORKAROUND_CLEAN_CACHE |
| 591 | static const struct midr_range workaround_clean_cache[] = { |
Andre Przywara | e116a37 | 2014-11-14 15:54:09 +0000 | [diff] [blame] | 592 | #if defined(CONFIG_ARM64_ERRATUM_826319) || \ |
| 593 | defined(CONFIG_ARM64_ERRATUM_827319) || \ |
| 594 | defined(CONFIG_ARM64_ERRATUM_824069) |
Suzuki K Poulose | c9460dc | 2018-11-30 17:18:00 +0000 | [diff] [blame] | 595 | /* Cortex-A53 r0p[012]: ARM errata 826319, 827319, 824069 */ |
| 596 | MIDR_REV_RANGE(MIDR_CORTEX_A53, 0, 0, 2), |
Andre Przywara | c0a01b8 | 2014-11-14 15:54:12 +0000 | [diff] [blame] | 597 | #endif |
Suzuki K Poulose | c9460dc | 2018-11-30 17:18:00 +0000 | [diff] [blame] | 598 | #ifdef CONFIG_ARM64_ERRATUM_819472 |
| 599 | /* Cortex-A53 r0p[01] : ARM errata 819472 */ |
| 600 | MIDR_REV_RANGE(MIDR_CORTEX_A53, 0, 0, 1), |
| 601 | #endif |
| 602 | {}, |
| 603 | }; |
| 604 | #endif |
| 605 | |
| 606 | const struct arm64_cpu_capabilities arm64_errata[] = { |
| 607 | #ifdef CONFIG_ARM64_WORKAROUND_CLEAN_CACHE |
Andre Przywara | c0a01b8 | 2014-11-14 15:54:12 +0000 | [diff] [blame] | 608 | { |
Suzuki K Poulose | c9460dc | 2018-11-30 17:18:00 +0000 | [diff] [blame] | 609 | .desc = "ARM errata 826319, 827319, 824069, 819472", |
Andre Przywara | c0a01b8 | 2014-11-14 15:54:12 +0000 | [diff] [blame] | 610 | .capability = ARM64_WORKAROUND_CLEAN_CACHE, |
Suzuki K Poulose | c9460dc | 2018-11-30 17:18:00 +0000 | [diff] [blame] | 611 | ERRATA_MIDR_RANGE_LIST(workaround_clean_cache), |
Dave Martin | c0cda3b | 2018-03-26 15:12:28 +0100 | [diff] [blame] | 612 | .cpu_enable = cpu_enable_cache_maint_trap, |
Andre Przywara | c0a01b8 | 2014-11-14 15:54:12 +0000 | [diff] [blame] | 613 | }, |
| 614 | #endif |
| 615 | #ifdef CONFIG_ARM64_ERRATUM_832075 |
Andre Przywara | 301bcfa | 2014-11-14 15:54:10 +0000 | [diff] [blame] | 616 | { |
Andre Przywara | 5afaa1f | 2014-11-14 15:54:11 +0000 | [diff] [blame] | 617 | /* Cortex-A57 r0p0 - r1p2 */ |
| 618 | .desc = "ARM erratum 832075", |
| 619 | .capability = ARM64_WORKAROUND_DEVICE_LOAD_ACQUIRE, |
Suzuki K Poulose | 5e7951c | 2018-03-26 15:12:43 +0100 | [diff] [blame] | 620 | ERRATA_MIDR_RANGE(MIDR_CORTEX_A57, |
| 621 | 0, 0, |
| 622 | 1, 2), |
Andre Przywara | 5afaa1f | 2014-11-14 15:54:11 +0000 | [diff] [blame] | 623 | }, |
Andre Przywara | c0a01b8 | 2014-11-14 15:54:12 +0000 | [diff] [blame] | 624 | #endif |
Marc Zyngier | 498cd5c | 2015-11-16 10:28:18 +0000 | [diff] [blame] | 625 | #ifdef CONFIG_ARM64_ERRATUM_834220 |
| 626 | { |
| 627 | /* Cortex-A57 r0p0 - r1p2 */ |
| 628 | .desc = "ARM erratum 834220", |
| 629 | .capability = ARM64_WORKAROUND_834220, |
Suzuki K Poulose | 5e7951c | 2018-03-26 15:12:43 +0100 | [diff] [blame] | 630 | ERRATA_MIDR_RANGE(MIDR_CORTEX_A57, |
| 631 | 0, 0, |
| 632 | 1, 2), |
Marc Zyngier | 498cd5c | 2015-11-16 10:28:18 +0000 | [diff] [blame] | 633 | }, |
| 634 | #endif |
Ard Biesheuvel | ca79acc | 2018-03-06 17:15:35 +0000 | [diff] [blame] | 635 | #ifdef CONFIG_ARM64_ERRATUM_843419 |
| 636 | { |
| 637 | /* Cortex-A53 r0p[01234] */ |
| 638 | .desc = "ARM erratum 843419", |
| 639 | .capability = ARM64_WORKAROUND_843419, |
Suzuki K Poulose | 5e7951c | 2018-03-26 15:12:43 +0100 | [diff] [blame] | 640 | ERRATA_MIDR_REV_RANGE(MIDR_CORTEX_A53, 0, 0, 4), |
Ard Biesheuvel | ca79acc | 2018-03-06 17:15:35 +0000 | [diff] [blame] | 641 | MIDR_FIXED(0x4, BIT(8)), |
Will Deacon | 905e8c5 | 2015-03-23 19:07:02 +0000 | [diff] [blame] | 642 | }, |
Robert Richter | 6d4e11c | 2015-09-21 22:58:35 +0200 | [diff] [blame] | 643 | #endif |
| 644 | #ifdef CONFIG_ARM64_ERRATUM_845719 |
| 645 | { |
| 646 | /* Cortex-A53 r0p[01234] */ |
| 647 | .desc = "ARM erratum 845719", |
| 648 | .capability = ARM64_WORKAROUND_845719, |
Suzuki K Poulose | 5e7951c | 2018-03-26 15:12:43 +0100 | [diff] [blame] | 649 | ERRATA_MIDR_REV_RANGE(MIDR_CORTEX_A53, 0, 0, 4), |
Marc Zyngier | 359b706 | 2015-03-27 13:09:23 +0000 | [diff] [blame] | 650 | }, |
Andre Przywara | e116a37 | 2014-11-14 15:54:09 +0000 | [diff] [blame] | 651 | #endif |
Robert Richter | 6d4e11c | 2015-09-21 22:58:35 +0200 | [diff] [blame] | 652 | #ifdef CONFIG_CAVIUM_ERRATUM_23154 |
| 653 | { |
| 654 | /* Cavium ThunderX, pass 1.x */ |
| 655 | .desc = "Cavium erratum 23154", |
| 656 | .capability = ARM64_WORKAROUND_CAVIUM_23154, |
Suzuki K Poulose | 5e7951c | 2018-03-26 15:12:43 +0100 | [diff] [blame] | 657 | ERRATA_MIDR_REV_RANGE(MIDR_THUNDERX, 0, 0, 1), |
Robert Richter | 6d4e11c | 2015-09-21 22:58:35 +0200 | [diff] [blame] | 658 | }, |
| 659 | #endif |
Andrew Pinski | 104a0c0 | 2016-02-24 17:44:57 -0800 | [diff] [blame] | 660 | #ifdef CONFIG_CAVIUM_ERRATUM_27456 |
| 661 | { |
Andrew Pinski | 104a0c0 | 2016-02-24 17:44:57 -0800 | [diff] [blame] | 662 | .desc = "Cavium erratum 27456", |
| 663 | .capability = ARM64_WORKAROUND_CAVIUM_27456, |
Suzuki K Poulose | f58cdf7 | 2018-11-30 17:18:01 +0000 | [diff] [blame] | 664 | ERRATA_MIDR_RANGE_LIST(cavium_erratum_27456_cpus), |
Ganapatrao Kulkarni | 47c459b | 2016-07-07 10:18:17 +0530 | [diff] [blame] | 665 | }, |
Andrew Pinski | 104a0c0 | 2016-02-24 17:44:57 -0800 | [diff] [blame] | 666 | #endif |
David Daney | 690a341 | 2017-06-09 12:49:48 +0100 | [diff] [blame] | 667 | #ifdef CONFIG_CAVIUM_ERRATUM_30115 |
| 668 | { |
David Daney | 690a341 | 2017-06-09 12:49:48 +0100 | [diff] [blame] | 669 | .desc = "Cavium erratum 30115", |
| 670 | .capability = ARM64_WORKAROUND_CAVIUM_30115, |
Suzuki K Poulose | f58cdf7 | 2018-11-30 17:18:01 +0000 | [diff] [blame] | 671 | ERRATA_MIDR_RANGE_LIST(cavium_erratum_30115_cpus), |
David Daney | 690a341 | 2017-06-09 12:49:48 +0100 | [diff] [blame] | 672 | }, |
| 673 | #endif |
Andre Przywara | e116a37 | 2014-11-14 15:54:09 +0000 | [diff] [blame] | 674 | { |
Will Deacon | 880f7cc | 2018-09-19 11:41:21 +0100 | [diff] [blame] | 675 | .desc = "Mismatched cache type (CTR_EL0)", |
Suzuki K Poulose | 314d53d | 2018-07-04 23:07:46 +0100 | [diff] [blame] | 676 | .capability = ARM64_MISMATCHED_CACHE_TYPE, |
| 677 | .matches = has_mismatched_cache_type, |
Suzuki K Poulose | 5b4747c | 2018-03-26 15:12:32 +0100 | [diff] [blame] | 678 | .type = ARM64_CPUCAP_LOCAL_CPU_ERRATUM, |
Dave Martin | c0cda3b | 2018-03-26 15:12:28 +0100 | [diff] [blame] | 679 | .cpu_enable = cpu_enable_trap_ctr_access, |
Suzuki K Poulose | 116c81f | 2016-09-09 14:07:16 +0100 | [diff] [blame] | 680 | }, |
Christopher Covington | 38fd94b | 2017-02-08 15:08:37 -0500 | [diff] [blame] | 681 | #ifdef CONFIG_QCOM_FALKOR_ERRATUM_1003 |
| 682 | { |
Suzuki K Poulose | a3dcea2c | 2018-11-30 17:18:02 +0000 | [diff] [blame] | 683 | .desc = "Qualcomm Technologies Falkor/Kryo erratum 1003", |
Christopher Covington | 38fd94b | 2017-02-08 15:08:37 -0500 | [diff] [blame] | 684 | .capability = ARM64_WORKAROUND_QCOM_FALKOR_E1003, |
Will Deacon | 1e013d0 | 2018-12-12 15:53:54 +0000 | [diff] [blame] | 685 | .matches = cpucap_multi_entry_cap_matches, |
Suzuki K Poulose | a3dcea2c | 2018-11-30 17:18:02 +0000 | [diff] [blame] | 686 | .match_list = qcom_erratum_1003_list, |
Stephen Boyd | bb48711 | 2017-12-13 14:19:37 -0800 | [diff] [blame] | 687 | }, |
Christopher Covington | 38fd94b | 2017-02-08 15:08:37 -0500 | [diff] [blame] | 688 | #endif |
Catalin Marinas | ce8c80c | 2018-11-19 11:27:28 +0000 | [diff] [blame] | 689 | #ifdef CONFIG_ARM64_WORKAROUND_REPEAT_TLBI |
Christopher Covington | d9ff80f | 2017-01-31 12:50:19 -0500 | [diff] [blame] | 690 | { |
Catalin Marinas | ce8c80c | 2018-11-19 11:27:28 +0000 | [diff] [blame] | 691 | .desc = "Qualcomm erratum 1009, ARM erratum 1286807", |
Christopher Covington | d9ff80f | 2017-01-31 12:50:19 -0500 | [diff] [blame] | 692 | .capability = ARM64_WORKAROUND_REPEAT_TLBI, |
Catalin Marinas | ce8c80c | 2018-11-19 11:27:28 +0000 | [diff] [blame] | 693 | ERRATA_MIDR_RANGE_LIST(arm64_repeat_tlbi_cpus), |
Christopher Covington | d9ff80f | 2017-01-31 12:50:19 -0500 | [diff] [blame] | 694 | }, |
| 695 | #endif |
Marc Zyngier | eeb1efb | 2017-03-20 17:18:06 +0000 | [diff] [blame] | 696 | #ifdef CONFIG_ARM64_ERRATUM_858921 |
| 697 | { |
| 698 | /* Cortex-A73 all versions */ |
| 699 | .desc = "ARM erratum 858921", |
| 700 | .capability = ARM64_WORKAROUND_858921, |
Suzuki K Poulose | 5e7951c | 2018-03-26 15:12:43 +0100 | [diff] [blame] | 701 | ERRATA_MIDR_ALL_VERSIONS(MIDR_CORTEX_A73), |
Marc Zyngier | eeb1efb | 2017-03-20 17:18:06 +0000 | [diff] [blame] | 702 | }, |
| 703 | #endif |
Will Deacon | aa6acde | 2018-01-03 12:46:21 +0000 | [diff] [blame] | 704 | #ifdef CONFIG_HARDEN_BRANCH_PREDICTOR |
| 705 | { |
| 706 | .capability = ARM64_HARDEN_BRANCH_PREDICTOR, |
Shanker Donthineni | 4bc352f | 2018-04-10 11:36:42 +0100 | [diff] [blame] | 707 | .cpu_enable = enable_smccc_arch_workaround_1, |
| 708 | ERRATA_MIDR_RANGE_LIST(arm64_bp_harden_smccc_cpus), |
Jayachandran C | f3d795d | 2018-01-19 04:22:47 -0800 | [diff] [blame] | 709 | }, |
Will Deacon | aa6acde | 2018-01-03 12:46:21 +0000 | [diff] [blame] | 710 | #endif |
Marc Zyngier | 4b472ff | 2018-02-15 11:49:20 +0000 | [diff] [blame] | 711 | #ifdef CONFIG_HARDEN_EL2_VECTORS |
| 712 | { |
Marc Zyngier | 8892b71 | 2018-04-10 11:36:43 +0100 | [diff] [blame] | 713 | .desc = "EL2 vector hardening", |
Marc Zyngier | 4b472ff | 2018-02-15 11:49:20 +0000 | [diff] [blame] | 714 | .capability = ARM64_HARDEN_EL2_VECTORS, |
Marc Zyngier | 8892b71 | 2018-04-10 11:36:43 +0100 | [diff] [blame] | 715 | ERRATA_MIDR_RANGE_LIST(arm64_harden_el2_vectors), |
Marc Zyngier | 4b472ff | 2018-02-15 11:49:20 +0000 | [diff] [blame] | 716 | }, |
| 717 | #endif |
Marc Zyngier | a725e3d | 2018-05-29 13:11:08 +0100 | [diff] [blame] | 718 | #ifdef CONFIG_ARM64_SSBD |
| 719 | { |
| 720 | .desc = "Speculative Store Bypass Disable", |
| 721 | .capability = ARM64_SSBD, |
| 722 | .type = ARM64_CPUCAP_LOCAL_CPU_ERRATUM, |
| 723 | .matches = has_ssbd_mitigation, |
| 724 | }, |
| 725 | #endif |
Marc Zyngier | 95b861a4 | 2018-09-27 17:15:34 +0100 | [diff] [blame] | 726 | #ifdef CONFIG_ARM64_ERRATUM_1188873 |
| 727 | { |
| 728 | /* Cortex-A76 r0p0 to r2p0 */ |
| 729 | .desc = "ARM erratum 1188873", |
| 730 | .capability = ARM64_WORKAROUND_1188873, |
| 731 | ERRATA_MIDR_RANGE(MIDR_CORTEX_A76, 0, 0, 2, 0), |
| 732 | }, |
| 733 | #endif |
Marc Zyngier | 8b2cca9 | 2018-12-06 17:31:23 +0000 | [diff] [blame] | 734 | #ifdef CONFIG_ARM64_ERRATUM_1165522 |
| 735 | { |
| 736 | /* Cortex-A76 r0p0 to r2p0 */ |
| 737 | .desc = "ARM erratum 1165522", |
| 738 | .capability = ARM64_WORKAROUND_1165522, |
| 739 | ERRATA_MIDR_RANGE(MIDR_CORTEX_A76, 0, 0, 2, 0), |
| 740 | }, |
| 741 | #endif |
Suzuki K Poulose | 116c81f | 2016-09-09 14:07:16 +0100 | [diff] [blame] | 742 | { |
Andre Przywara | e116a37 | 2014-11-14 15:54:09 +0000 | [diff] [blame] | 743 | } |
| 744 | }; |