blob: 2797bc2c8c6a88ec4687eefbdfaf558d8fa761e9 [file] [log] [blame]
Andre Przywarae116a372014-11-14 15:54:09 +00001/*
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
Andre Przywarae116a372014-11-14 15:54:09 +000019#include <linux/types.h>
20#include <asm/cpu.h>
21#include <asm/cputype.h>
22#include <asm/cpufeature.h>
23
Andre Przywara301bcfa2014-11-14 15:54:10 +000024static bool __maybe_unused
Suzuki K Poulose92406f02016-04-22 12:25:31 +010025is_affected_midr_range(const struct arm64_cpu_capabilities *entry, int scope)
Andre Przywara301bcfa2014-11-14 15:54:10 +000026{
Ard Biesheuvele8002e02018-03-06 17:15:34 +000027 const struct arm64_midr_revidr *fix;
28 u32 midr = read_cpuid_id(), revidr;
29
Suzuki K Poulose92406f02016-04-22 12:25:31 +010030 WARN_ON(scope != SCOPE_LOCAL_CPU || preemptible());
Suzuki K Poulose1df31052018-03-26 15:12:44 +010031 if (!is_midr_in_range(midr, &entry->midr_range))
Ard Biesheuvele8002e02018-03-06 17:15:34 +000032 return false;
33
34 midr &= MIDR_REVISION_MASK | MIDR_VARIANT_MASK;
35 revidr = read_cpuid(REVIDR_EL1);
36 for (fix = entry->fixed_revs; fix && fix->revidr_mask; fix++)
37 if (midr == fix->midr_rv && (revidr & fix->revidr_mask))
38 return false;
39
40 return true;
Andre Przywara301bcfa2014-11-14 15:54:10 +000041}
42
Stephen Boydbb487112017-12-13 14:19:37 -080043static bool __maybe_unused
Suzuki K Poulosebe5b2992018-03-26 15:12:45 +010044is_affected_midr_range_list(const struct arm64_cpu_capabilities *entry,
45 int scope)
46{
47 WARN_ON(scope != SCOPE_LOCAL_CPU || preemptible());
48 return is_midr_in_range_list(read_cpuid_id(), entry->midr_range_list);
Andre Przywara301bcfa2014-11-14 15:54:10 +000049}
50
Stephen Boydbb487112017-12-13 14:19:37 -080051static bool __maybe_unused
52is_kryo_midr(const struct arm64_cpu_capabilities *entry, int scope)
53{
54 u32 model;
55
56 WARN_ON(scope != SCOPE_LOCAL_CPU || preemptible());
57
58 model = read_cpuid_id();
59 model &= MIDR_IMPLEMENTOR_MASK | (0xf00 << MIDR_PARTNUM_SHIFT) |
60 MIDR_ARCHITECTURE_MASK;
61
Suzuki K Poulose1df31052018-03-26 15:12:44 +010062 return model == entry->midr_range.model;
Stephen Boydbb487112017-12-13 14:19:37 -080063}
64
Suzuki K Poulose116c81f2016-09-09 14:07:16 +010065static bool
66has_mismatched_cache_line_size(const struct arm64_cpu_capabilities *entry,
67 int scope)
68{
69 WARN_ON(scope != SCOPE_LOCAL_CPU || preemptible());
70 return (read_cpuid_cachetype() & arm64_ftr_reg_ctrel0.strict_mask) !=
71 (arm64_ftr_reg_ctrel0.sys_val & arm64_ftr_reg_ctrel0.strict_mask);
72}
73
Dave Martinc0cda3b2018-03-26 15:12:28 +010074static void
75cpu_enable_trap_ctr_access(const struct arm64_cpu_capabilities *__unused)
Suzuki K Poulose116c81f2016-09-09 14:07:16 +010076{
77 /* Clear SCTLR_EL1.UCT */
78 config_sctlr_el1(SCTLR_EL1_UCT, 0);
79}
80
Marc Zyngier4205a892018-03-13 12:40:39 +000081atomic_t arm64_el2_vector_last_slot = ATOMIC_INIT(-1);
82
Will Deacon0f15adb2018-01-03 11:17:58 +000083#ifdef CONFIG_HARDEN_BRANCH_PREDICTOR
84#include <asm/mmu_context.h>
85#include <asm/cacheflush.h>
86
87DEFINE_PER_CPU_READ_MOSTLY(struct bp_hardening_data, bp_hardening_data);
88
Marc Zyngiere8b22d0f2018-04-10 11:36:45 +010089#ifdef CONFIG_KVM_INDIRECT_VECTORS
Marc Zyngierb0922012018-02-06 17:56:20 +000090extern char __smccc_workaround_1_smc_start[];
91extern char __smccc_workaround_1_smc_end[];
Will Deaconaa6acde2018-01-03 12:46:21 +000092
Will Deacon0f15adb2018-01-03 11:17:58 +000093static void __copy_hyp_vect_bpi(int slot, const char *hyp_vecs_start,
94 const char *hyp_vecs_end)
95{
96 void *dst = lm_alias(__bp_harden_hyp_vecs_start + slot * SZ_2K);
97 int i;
98
99 for (i = 0; i < SZ_2K; i += 0x80)
100 memcpy(dst + i, hyp_vecs_start, hyp_vecs_end - hyp_vecs_start);
101
102 flush_icache_range((uintptr_t)dst, (uintptr_t)dst + SZ_2K);
103}
104
105static void __install_bp_hardening_cb(bp_hardening_cb_t fn,
106 const char *hyp_vecs_start,
107 const char *hyp_vecs_end)
108{
Will Deacon0f15adb2018-01-03 11:17:58 +0000109 static DEFINE_SPINLOCK(bp_lock);
110 int cpu, slot = -1;
111
112 spin_lock(&bp_lock);
113 for_each_possible_cpu(cpu) {
114 if (per_cpu(bp_hardening_data.fn, cpu) == fn) {
115 slot = per_cpu(bp_hardening_data.hyp_vectors_slot, cpu);
116 break;
117 }
118 }
119
120 if (slot == -1) {
Marc Zyngier4205a892018-03-13 12:40:39 +0000121 slot = atomic_inc_return(&arm64_el2_vector_last_slot);
122 BUG_ON(slot >= BP_HARDEN_EL2_SLOTS);
Will Deacon0f15adb2018-01-03 11:17:58 +0000123 __copy_hyp_vect_bpi(slot, hyp_vecs_start, hyp_vecs_end);
124 }
125
126 __this_cpu_write(bp_hardening_data.hyp_vectors_slot, slot);
127 __this_cpu_write(bp_hardening_data.fn, fn);
128 spin_unlock(&bp_lock);
129}
130#else
Marc Zyngierb0922012018-02-06 17:56:20 +0000131#define __smccc_workaround_1_smc_start NULL
132#define __smccc_workaround_1_smc_end NULL
Will Deaconaa6acde2018-01-03 12:46:21 +0000133
Will Deacon0f15adb2018-01-03 11:17:58 +0000134static void __install_bp_hardening_cb(bp_hardening_cb_t fn,
135 const char *hyp_vecs_start,
136 const char *hyp_vecs_end)
137{
138 __this_cpu_write(bp_hardening_data.fn, fn);
139}
Marc Zyngiere8b22d0f2018-04-10 11:36:45 +0100140#endif /* CONFIG_KVM_INDIRECT_VECTORS */
Will Deacon0f15adb2018-01-03 11:17:58 +0000141
142static void install_bp_hardening_cb(const struct arm64_cpu_capabilities *entry,
143 bp_hardening_cb_t fn,
144 const char *hyp_vecs_start,
145 const char *hyp_vecs_end)
146{
147 u64 pfr0;
148
149 if (!entry->matches(entry, SCOPE_LOCAL_CPU))
150 return;
151
152 pfr0 = read_cpuid(ID_AA64PFR0_EL1);
153 if (cpuid_feature_extract_unsigned_field(pfr0, ID_AA64PFR0_CSV2_SHIFT))
154 return;
155
156 __install_bp_hardening_cb(fn, hyp_vecs_start, hyp_vecs_end);
157}
Will Deaconaa6acde2018-01-03 12:46:21 +0000158
Marc Zyngierb0922012018-02-06 17:56:20 +0000159#include <uapi/linux/psci.h>
160#include <linux/arm-smccc.h>
Will Deaconaa6acde2018-01-03 12:46:21 +0000161#include <linux/psci.h>
162
Marc Zyngierb0922012018-02-06 17:56:20 +0000163static void call_smc_arch_workaround_1(void)
164{
165 arm_smccc_1_1_smc(ARM_SMCCC_ARCH_WORKAROUND_1, NULL);
166}
167
168static void call_hvc_arch_workaround_1(void)
169{
170 arm_smccc_1_1_hvc(ARM_SMCCC_ARCH_WORKAROUND_1, NULL);
171}
172
Shanker Donthineni4bc352f2018-04-10 11:36:42 +0100173static void qcom_link_stack_sanitization(void)
174{
175 u64 tmp;
176
177 asm volatile("mov %0, x30 \n"
178 ".rept 16 \n"
179 "bl . + 4 \n"
180 ".endr \n"
181 "mov x30, %0 \n"
182 : "=&r" (tmp));
183}
184
Dave Martinc0cda3b2018-03-26 15:12:28 +0100185static void
186enable_smccc_arch_workaround_1(const struct arm64_cpu_capabilities *entry)
Marc Zyngierb0922012018-02-06 17:56:20 +0000187{
188 bp_hardening_cb_t cb;
189 void *smccc_start, *smccc_end;
190 struct arm_smccc_res res;
Shanker Donthineni4bc352f2018-04-10 11:36:42 +0100191 u32 midr = read_cpuid_id();
Marc Zyngierb0922012018-02-06 17:56:20 +0000192
193 if (!entry->matches(entry, SCOPE_LOCAL_CPU))
Dave Martinc0cda3b2018-03-26 15:12:28 +0100194 return;
Marc Zyngierb0922012018-02-06 17:56:20 +0000195
196 if (psci_ops.smccc_version == SMCCC_VERSION_1_0)
Dave Martinc0cda3b2018-03-26 15:12:28 +0100197 return;
Marc Zyngierb0922012018-02-06 17:56:20 +0000198
199 switch (psci_ops.conduit) {
200 case PSCI_CONDUIT_HVC:
201 arm_smccc_1_1_hvc(ARM_SMCCC_ARCH_FEATURES_FUNC_ID,
202 ARM_SMCCC_ARCH_WORKAROUND_1, &res);
Marc Zyngiere21da1c2018-03-09 15:40:50 +0000203 if ((int)res.a0 < 0)
Dave Martinc0cda3b2018-03-26 15:12:28 +0100204 return;
Marc Zyngierb0922012018-02-06 17:56:20 +0000205 cb = call_hvc_arch_workaround_1;
Marc Zyngier22765f32018-04-10 11:36:44 +0100206 /* This is a guest, no need to patch KVM vectors */
207 smccc_start = NULL;
208 smccc_end = NULL;
Marc Zyngierb0922012018-02-06 17:56:20 +0000209 break;
210
211 case PSCI_CONDUIT_SMC:
212 arm_smccc_1_1_smc(ARM_SMCCC_ARCH_FEATURES_FUNC_ID,
213 ARM_SMCCC_ARCH_WORKAROUND_1, &res);
Marc Zyngiere21da1c2018-03-09 15:40:50 +0000214 if ((int)res.a0 < 0)
Dave Martinc0cda3b2018-03-26 15:12:28 +0100215 return;
Marc Zyngierb0922012018-02-06 17:56:20 +0000216 cb = call_smc_arch_workaround_1;
217 smccc_start = __smccc_workaround_1_smc_start;
218 smccc_end = __smccc_workaround_1_smc_end;
219 break;
220
221 default:
Dave Martinc0cda3b2018-03-26 15:12:28 +0100222 return;
Marc Zyngierb0922012018-02-06 17:56:20 +0000223 }
224
Shanker Donthineni4bc352f2018-04-10 11:36:42 +0100225 if (((midr & MIDR_CPU_MODEL_MASK) == MIDR_QCOM_FALKOR) ||
226 ((midr & MIDR_CPU_MODEL_MASK) == MIDR_QCOM_FALKOR_V1))
227 cb = qcom_link_stack_sanitization;
228
Marc Zyngierb0922012018-02-06 17:56:20 +0000229 install_bp_hardening_cb(entry, cb, smccc_start, smccc_end);
230
Dave Martinc0cda3b2018-03-26 15:12:28 +0100231 return;
Will Deaconaa6acde2018-01-03 12:46:21 +0000232}
Will Deacon0f15adb2018-01-03 11:17:58 +0000233#endif /* CONFIG_HARDEN_BRANCH_PREDICTOR */
234
Marc Zyngier8e290622018-05-29 13:11:06 +0100235#ifdef CONFIG_ARM64_SSBD
Marc Zyngier5cf9ce62018-05-29 13:11:07 +0100236DEFINE_PER_CPU_READ_MOSTLY(u64, arm64_ssbd_callback_required);
237
Marc Zyngiera43ae4d2018-05-29 13:11:09 +0100238int ssbd_state __read_mostly = ARM64_SSBD_KERNEL;
239
240static const struct ssbd_options {
241 const char *str;
242 int state;
243} ssbd_options[] = {
244 { "force-on", ARM64_SSBD_FORCE_ENABLE, },
245 { "force-off", ARM64_SSBD_FORCE_DISABLE, },
246 { "kernel", ARM64_SSBD_KERNEL, },
247};
248
249static int __init ssbd_cfg(char *buf)
250{
251 int i;
252
253 if (!buf || !buf[0])
254 return -EINVAL;
255
256 for (i = 0; i < ARRAY_SIZE(ssbd_options); i++) {
257 int len = strlen(ssbd_options[i].str);
258
259 if (strncmp(buf, ssbd_options[i].str, len))
260 continue;
261
262 ssbd_state = ssbd_options[i].state;
263 return 0;
264 }
265
266 return -EINVAL;
267}
268early_param("ssbd", ssbd_cfg);
269
Marc Zyngier8e290622018-05-29 13:11:06 +0100270void __init arm64_update_smccc_conduit(struct alt_instr *alt,
271 __le32 *origptr, __le32 *updptr,
272 int nr_inst)
273{
274 u32 insn;
275
276 BUG_ON(nr_inst != 1);
277
278 switch (psci_ops.conduit) {
279 case PSCI_CONDUIT_HVC:
280 insn = aarch64_insn_get_hvc_value();
281 break;
282 case PSCI_CONDUIT_SMC:
283 insn = aarch64_insn_get_smc_value();
284 break;
285 default:
286 return;
287 }
288
289 *updptr = cpu_to_le32(insn);
290}
Marc Zyngiera725e3d2018-05-29 13:11:08 +0100291
Marc Zyngier986372c2018-05-29 13:11:11 +0100292void __init arm64_enable_wa2_handling(struct alt_instr *alt,
293 __le32 *origptr, __le32 *updptr,
294 int nr_inst)
295{
296 BUG_ON(nr_inst != 1);
297 /*
298 * Only allow mitigation on EL1 entry/exit and guest
299 * ARCH_WORKAROUND_2 handling if the SSBD state allows it to
300 * be flipped.
301 */
302 if (arm64_get_ssbd_state() == ARM64_SSBD_KERNEL)
303 *updptr = cpu_to_le32(aarch64_insn_gen_nop());
304}
305
Marc Zyngiera725e3d2018-05-29 13:11:08 +0100306static void arm64_set_ssbd_mitigation(bool state)
307{
308 switch (psci_ops.conduit) {
309 case PSCI_CONDUIT_HVC:
310 arm_smccc_1_1_hvc(ARM_SMCCC_ARCH_WORKAROUND_2, state, NULL);
311 break;
312
313 case PSCI_CONDUIT_SMC:
314 arm_smccc_1_1_smc(ARM_SMCCC_ARCH_WORKAROUND_2, state, NULL);
315 break;
316
317 default:
318 WARN_ON_ONCE(1);
319 break;
320 }
321}
322
323static bool has_ssbd_mitigation(const struct arm64_cpu_capabilities *entry,
324 int scope)
325{
326 struct arm_smccc_res res;
Marc Zyngiera43ae4d2018-05-29 13:11:09 +0100327 bool required = true;
328 s32 val;
Marc Zyngiera725e3d2018-05-29 13:11:08 +0100329
330 WARN_ON(scope != SCOPE_LOCAL_CPU || preemptible());
331
Marc Zyngiera43ae4d2018-05-29 13:11:09 +0100332 if (psci_ops.smccc_version == SMCCC_VERSION_1_0) {
333 ssbd_state = ARM64_SSBD_UNKNOWN;
Marc Zyngiera725e3d2018-05-29 13:11:08 +0100334 return false;
Marc Zyngiera43ae4d2018-05-29 13:11:09 +0100335 }
Marc Zyngiera725e3d2018-05-29 13:11:08 +0100336
Marc Zyngiera725e3d2018-05-29 13:11:08 +0100337 switch (psci_ops.conduit) {
338 case PSCI_CONDUIT_HVC:
339 arm_smccc_1_1_hvc(ARM_SMCCC_ARCH_FEATURES_FUNC_ID,
340 ARM_SMCCC_ARCH_WORKAROUND_2, &res);
Marc Zyngiera725e3d2018-05-29 13:11:08 +0100341 break;
342
343 case PSCI_CONDUIT_SMC:
344 arm_smccc_1_1_smc(ARM_SMCCC_ARCH_FEATURES_FUNC_ID,
345 ARM_SMCCC_ARCH_WORKAROUND_2, &res);
Marc Zyngiera725e3d2018-05-29 13:11:08 +0100346 break;
347
348 default:
Marc Zyngiera43ae4d2018-05-29 13:11:09 +0100349 ssbd_state = ARM64_SSBD_UNKNOWN;
350 return false;
Marc Zyngiera725e3d2018-05-29 13:11:08 +0100351 }
352
Marc Zyngiera43ae4d2018-05-29 13:11:09 +0100353 val = (s32)res.a0;
354
355 switch (val) {
356 case SMCCC_RET_NOT_SUPPORTED:
357 ssbd_state = ARM64_SSBD_UNKNOWN;
358 return false;
359
360 case SMCCC_RET_NOT_REQUIRED:
361 pr_info_once("%s mitigation not required\n", entry->desc);
362 ssbd_state = ARM64_SSBD_MITIGATED;
363 return false;
364
365 case SMCCC_RET_SUCCESS:
366 required = true;
367 break;
368
369 case 1: /* Mitigation not required on this CPU */
370 required = false;
371 break;
372
373 default:
374 WARN_ON(1);
375 return false;
376 }
377
378 switch (ssbd_state) {
379 case ARM64_SSBD_FORCE_DISABLE:
380 pr_info_once("%s disabled from command-line\n", entry->desc);
381 arm64_set_ssbd_mitigation(false);
382 required = false;
383 break;
384
385 case ARM64_SSBD_KERNEL:
386 if (required) {
387 __this_cpu_write(arm64_ssbd_callback_required, 1);
388 arm64_set_ssbd_mitigation(true);
389 }
390 break;
391
392 case ARM64_SSBD_FORCE_ENABLE:
393 pr_info_once("%s forced from command-line\n", entry->desc);
Marc Zyngiera725e3d2018-05-29 13:11:08 +0100394 arm64_set_ssbd_mitigation(true);
Marc Zyngiera43ae4d2018-05-29 13:11:09 +0100395 required = true;
396 break;
397
398 default:
399 WARN_ON(1);
400 break;
Marc Zyngiera725e3d2018-05-29 13:11:08 +0100401 }
402
Marc Zyngiera43ae4d2018-05-29 13:11:09 +0100403 return required;
Marc Zyngiera725e3d2018-05-29 13:11:08 +0100404}
Marc Zyngier8e290622018-05-29 13:11:06 +0100405#endif /* CONFIG_ARM64_SSBD */
406
Suzuki K Poulose5e7951c2018-03-26 15:12:43 +0100407#define CAP_MIDR_RANGE(model, v_min, r_min, v_max, r_max) \
408 .matches = is_affected_midr_range, \
Suzuki K Poulose1df31052018-03-26 15:12:44 +0100409 .midr_range = MIDR_RANGE(model, v_min, r_min, v_max, r_max)
Andre Przywara301bcfa2014-11-14 15:54:10 +0000410
Suzuki K Poulose5e7951c2018-03-26 15:12:43 +0100411#define CAP_MIDR_ALL_VERSIONS(model) \
412 .matches = is_affected_midr_range, \
Suzuki K Poulose1df31052018-03-26 15:12:44 +0100413 .midr_range = MIDR_ALL_VERSIONS(model)
Marc Zyngier06f14942017-02-01 14:38:46 +0000414
Ard Biesheuvele8002e02018-03-06 17:15:34 +0000415#define MIDR_FIXED(rev, revidr_mask) \
416 .fixed_revs = (struct arm64_midr_revidr[]){{ (rev), (revidr_mask) }, {}}
417
Suzuki K Poulose5e7951c2018-03-26 15:12:43 +0100418#define ERRATA_MIDR_RANGE(model, v_min, r_min, v_max, r_max) \
419 .type = ARM64_CPUCAP_LOCAL_CPU_ERRATUM, \
420 CAP_MIDR_RANGE(model, v_min, r_min, v_max, r_max)
421
Suzuki K Poulosebe5b2992018-03-26 15:12:45 +0100422#define CAP_MIDR_RANGE_LIST(list) \
423 .matches = is_affected_midr_range_list, \
424 .midr_range_list = list
425
Suzuki K Poulose5e7951c2018-03-26 15:12:43 +0100426/* Errata affecting a range of revisions of given model variant */
427#define ERRATA_MIDR_REV_RANGE(m, var, r_min, r_max) \
428 ERRATA_MIDR_RANGE(m, var, r_min, var, r_max)
429
430/* Errata affecting a single variant/revision of a model */
431#define ERRATA_MIDR_REV(model, var, rev) \
432 ERRATA_MIDR_RANGE(model, var, rev, var, rev)
433
434/* Errata affecting all variants/revisions of a given a model */
435#define ERRATA_MIDR_ALL_VERSIONS(model) \
436 .type = ARM64_CPUCAP_LOCAL_CPU_ERRATUM, \
437 CAP_MIDR_ALL_VERSIONS(model)
438
Suzuki K Poulosebe5b2992018-03-26 15:12:45 +0100439/* Errata affecting a list of midr ranges, with same work around */
440#define ERRATA_MIDR_RANGE_LIST(midr_list) \
441 .type = ARM64_CPUCAP_LOCAL_CPU_ERRATUM, \
442 CAP_MIDR_RANGE_LIST(midr_list)
443
Suzuki K Pouloseba7d9232018-03-26 15:12:46 +0100444/*
445 * Generic helper for handling capabilties with multiple (match,enable) pairs
446 * of call backs, sharing the same capability bit.
447 * Iterate over each entry to see if at least one matches.
448 */
Will Deacon12eb3692018-03-27 11:51:12 +0100449static bool __maybe_unused
450multi_entry_cap_matches(const struct arm64_cpu_capabilities *entry, int scope)
Suzuki K Pouloseba7d9232018-03-26 15:12:46 +0100451{
452 const struct arm64_cpu_capabilities *caps;
453
454 for (caps = entry->match_list; caps->matches; caps++)
455 if (caps->matches(caps, scope))
456 return true;
457
458 return false;
459}
460
461/*
462 * Take appropriate action for all matching entries in the shared capability
463 * entry.
464 */
Will Deacon12eb3692018-03-27 11:51:12 +0100465static void __maybe_unused
Suzuki K Pouloseba7d9232018-03-26 15:12:46 +0100466multi_entry_cap_cpu_enable(const struct arm64_cpu_capabilities *entry)
467{
468 const struct arm64_cpu_capabilities *caps;
469
470 for (caps = entry->match_list; caps->matches; caps++)
471 if (caps->matches(caps, SCOPE_LOCAL_CPU) &&
472 caps->cpu_enable)
473 caps->cpu_enable(caps);
474}
475
Suzuki K Poulosebe5b2992018-03-26 15:12:45 +0100476#ifdef CONFIG_HARDEN_BRANCH_PREDICTOR
477
478/*
479 * List of CPUs where we need to issue a psci call to
480 * harden the branch predictor.
481 */
482static const struct midr_range arm64_bp_harden_smccc_cpus[] = {
483 MIDR_ALL_VERSIONS(MIDR_CORTEX_A57),
484 MIDR_ALL_VERSIONS(MIDR_CORTEX_A72),
485 MIDR_ALL_VERSIONS(MIDR_CORTEX_A73),
486 MIDR_ALL_VERSIONS(MIDR_CORTEX_A75),
487 MIDR_ALL_VERSIONS(MIDR_BRCM_VULCAN),
488 MIDR_ALL_VERSIONS(MIDR_CAVIUM_THUNDERX2),
Suzuki K Poulosebe5b2992018-03-26 15:12:45 +0100489 MIDR_ALL_VERSIONS(MIDR_QCOM_FALKOR_V1),
490 MIDR_ALL_VERSIONS(MIDR_QCOM_FALKOR),
491 {},
492};
493
494#endif
Andre Przywara301bcfa2014-11-14 15:54:10 +0000495
Marc Zyngier8892b712018-04-10 11:36:43 +0100496#ifdef CONFIG_HARDEN_EL2_VECTORS
497
498static const struct midr_range arm64_harden_el2_vectors[] = {
499 MIDR_ALL_VERSIONS(MIDR_CORTEX_A57),
500 MIDR_ALL_VERSIONS(MIDR_CORTEX_A72),
501 {},
502};
503
Marc Zyngierdc6ed612018-03-28 12:46:07 +0100504#endif
505
Andre Przywarae116a372014-11-14 15:54:09 +0000506const struct arm64_cpu_capabilities arm64_errata[] = {
507#if defined(CONFIG_ARM64_ERRATUM_826319) || \
508 defined(CONFIG_ARM64_ERRATUM_827319) || \
509 defined(CONFIG_ARM64_ERRATUM_824069)
Andre Przywara301bcfa2014-11-14 15:54:10 +0000510 {
511 /* Cortex-A53 r0p[012] */
512 .desc = "ARM errata 826319, 827319, 824069",
513 .capability = ARM64_WORKAROUND_CLEAN_CACHE,
Suzuki K Poulose5e7951c2018-03-26 15:12:43 +0100514 ERRATA_MIDR_REV_RANGE(MIDR_CORTEX_A53, 0, 0, 2),
Dave Martinc0cda3b2018-03-26 15:12:28 +0100515 .cpu_enable = cpu_enable_cache_maint_trap,
Andre Przywara301bcfa2014-11-14 15:54:10 +0000516 },
Andre Przywarac0a01b82014-11-14 15:54:12 +0000517#endif
518#ifdef CONFIG_ARM64_ERRATUM_819472
519 {
520 /* Cortex-A53 r0p[01] */
521 .desc = "ARM errata 819472",
522 .capability = ARM64_WORKAROUND_CLEAN_CACHE,
Suzuki K Poulose5e7951c2018-03-26 15:12:43 +0100523 ERRATA_MIDR_REV_RANGE(MIDR_CORTEX_A53, 0, 0, 1),
Dave Martinc0cda3b2018-03-26 15:12:28 +0100524 .cpu_enable = cpu_enable_cache_maint_trap,
Andre Przywarac0a01b82014-11-14 15:54:12 +0000525 },
526#endif
527#ifdef CONFIG_ARM64_ERRATUM_832075
Andre Przywara301bcfa2014-11-14 15:54:10 +0000528 {
Andre Przywara5afaa1f2014-11-14 15:54:11 +0000529 /* Cortex-A57 r0p0 - r1p2 */
530 .desc = "ARM erratum 832075",
531 .capability = ARM64_WORKAROUND_DEVICE_LOAD_ACQUIRE,
Suzuki K Poulose5e7951c2018-03-26 15:12:43 +0100532 ERRATA_MIDR_RANGE(MIDR_CORTEX_A57,
533 0, 0,
534 1, 2),
Andre Przywara5afaa1f2014-11-14 15:54:11 +0000535 },
Andre Przywarac0a01b82014-11-14 15:54:12 +0000536#endif
Marc Zyngier498cd5c2015-11-16 10:28:18 +0000537#ifdef CONFIG_ARM64_ERRATUM_834220
538 {
539 /* Cortex-A57 r0p0 - r1p2 */
540 .desc = "ARM erratum 834220",
541 .capability = ARM64_WORKAROUND_834220,
Suzuki K Poulose5e7951c2018-03-26 15:12:43 +0100542 ERRATA_MIDR_RANGE(MIDR_CORTEX_A57,
543 0, 0,
544 1, 2),
Marc Zyngier498cd5c2015-11-16 10:28:18 +0000545 },
546#endif
Ard Biesheuvelca79acc2018-03-06 17:15:35 +0000547#ifdef CONFIG_ARM64_ERRATUM_843419
548 {
549 /* Cortex-A53 r0p[01234] */
550 .desc = "ARM erratum 843419",
551 .capability = ARM64_WORKAROUND_843419,
Suzuki K Poulose5e7951c2018-03-26 15:12:43 +0100552 ERRATA_MIDR_REV_RANGE(MIDR_CORTEX_A53, 0, 0, 4),
Ard Biesheuvelca79acc2018-03-06 17:15:35 +0000553 MIDR_FIXED(0x4, BIT(8)),
Will Deacon905e8c52015-03-23 19:07:02 +0000554 },
Robert Richter6d4e11c2015-09-21 22:58:35 +0200555#endif
556#ifdef CONFIG_ARM64_ERRATUM_845719
557 {
558 /* Cortex-A53 r0p[01234] */
559 .desc = "ARM erratum 845719",
560 .capability = ARM64_WORKAROUND_845719,
Suzuki K Poulose5e7951c2018-03-26 15:12:43 +0100561 ERRATA_MIDR_REV_RANGE(MIDR_CORTEX_A53, 0, 0, 4),
Marc Zyngier359b7062015-03-27 13:09:23 +0000562 },
Andre Przywarae116a372014-11-14 15:54:09 +0000563#endif
Robert Richter6d4e11c2015-09-21 22:58:35 +0200564#ifdef CONFIG_CAVIUM_ERRATUM_23154
565 {
566 /* Cavium ThunderX, pass 1.x */
567 .desc = "Cavium erratum 23154",
568 .capability = ARM64_WORKAROUND_CAVIUM_23154,
Suzuki K Poulose5e7951c2018-03-26 15:12:43 +0100569 ERRATA_MIDR_REV_RANGE(MIDR_THUNDERX, 0, 0, 1),
Robert Richter6d4e11c2015-09-21 22:58:35 +0200570 },
571#endif
Andrew Pinski104a0c02016-02-24 17:44:57 -0800572#ifdef CONFIG_CAVIUM_ERRATUM_27456
573 {
574 /* Cavium ThunderX, T88 pass 1.x - 2.1 */
575 .desc = "Cavium erratum 27456",
576 .capability = ARM64_WORKAROUND_CAVIUM_27456,
Suzuki K Poulose5e7951c2018-03-26 15:12:43 +0100577 ERRATA_MIDR_RANGE(MIDR_THUNDERX,
578 0, 0,
579 1, 1),
Andrew Pinski104a0c02016-02-24 17:44:57 -0800580 },
Ganapatrao Kulkarni47c459b2016-07-07 10:18:17 +0530581 {
582 /* Cavium ThunderX, T81 pass 1.0 */
583 .desc = "Cavium erratum 27456",
584 .capability = ARM64_WORKAROUND_CAVIUM_27456,
Suzuki K Poulose5e7951c2018-03-26 15:12:43 +0100585 ERRATA_MIDR_REV(MIDR_THUNDERX_81XX, 0, 0),
Ganapatrao Kulkarni47c459b2016-07-07 10:18:17 +0530586 },
Andrew Pinski104a0c02016-02-24 17:44:57 -0800587#endif
David Daney690a3412017-06-09 12:49:48 +0100588#ifdef CONFIG_CAVIUM_ERRATUM_30115
589 {
590 /* Cavium ThunderX, T88 pass 1.x - 2.2 */
591 .desc = "Cavium erratum 30115",
592 .capability = ARM64_WORKAROUND_CAVIUM_30115,
Suzuki K Poulose5e7951c2018-03-26 15:12:43 +0100593 ERRATA_MIDR_RANGE(MIDR_THUNDERX,
594 0, 0,
595 1, 2),
David Daney690a3412017-06-09 12:49:48 +0100596 },
597 {
598 /* Cavium ThunderX, T81 pass 1.0 - 1.2 */
599 .desc = "Cavium erratum 30115",
600 .capability = ARM64_WORKAROUND_CAVIUM_30115,
Suzuki K Poulose5e7951c2018-03-26 15:12:43 +0100601 ERRATA_MIDR_REV_RANGE(MIDR_THUNDERX_81XX, 0, 0, 2),
David Daney690a3412017-06-09 12:49:48 +0100602 },
603 {
604 /* Cavium ThunderX, T83 pass 1.0 */
605 .desc = "Cavium erratum 30115",
606 .capability = ARM64_WORKAROUND_CAVIUM_30115,
Suzuki K Poulose5e7951c2018-03-26 15:12:43 +0100607 ERRATA_MIDR_REV(MIDR_THUNDERX_83XX, 0, 0),
David Daney690a3412017-06-09 12:49:48 +0100608 },
609#endif
Andre Przywarae116a372014-11-14 15:54:09 +0000610 {
Suzuki K Poulose116c81f2016-09-09 14:07:16 +0100611 .desc = "Mismatched cache line size",
612 .capability = ARM64_MISMATCHED_CACHE_LINE_SIZE,
613 .matches = has_mismatched_cache_line_size,
Suzuki K Poulose5b4747c2018-03-26 15:12:32 +0100614 .type = ARM64_CPUCAP_LOCAL_CPU_ERRATUM,
Dave Martinc0cda3b2018-03-26 15:12:28 +0100615 .cpu_enable = cpu_enable_trap_ctr_access,
Suzuki K Poulose116c81f2016-09-09 14:07:16 +0100616 },
Christopher Covington38fd94b2017-02-08 15:08:37 -0500617#ifdef CONFIG_QCOM_FALKOR_ERRATUM_1003
618 {
619 .desc = "Qualcomm Technologies Falkor erratum 1003",
620 .capability = ARM64_WORKAROUND_QCOM_FALKOR_E1003,
Suzuki K Poulose5e7951c2018-03-26 15:12:43 +0100621 ERRATA_MIDR_REV(MIDR_QCOM_FALKOR_V1, 0, 0),
Christopher Covington38fd94b2017-02-08 15:08:37 -0500622 },
Stephen Boydbb487112017-12-13 14:19:37 -0800623 {
624 .desc = "Qualcomm Technologies Kryo erratum 1003",
625 .capability = ARM64_WORKAROUND_QCOM_FALKOR_E1003,
Suzuki K Poulose5b4747c2018-03-26 15:12:32 +0100626 .type = ARM64_CPUCAP_LOCAL_CPU_ERRATUM,
Suzuki K Poulose1df31052018-03-26 15:12:44 +0100627 .midr_range.model = MIDR_QCOM_KRYO,
Stephen Boydbb487112017-12-13 14:19:37 -0800628 .matches = is_kryo_midr,
629 },
Christopher Covington38fd94b2017-02-08 15:08:37 -0500630#endif
Christopher Covingtond9ff80f2017-01-31 12:50:19 -0500631#ifdef CONFIG_QCOM_FALKOR_ERRATUM_1009
632 {
633 .desc = "Qualcomm Technologies Falkor erratum 1009",
634 .capability = ARM64_WORKAROUND_REPEAT_TLBI,
Suzuki K Poulose5e7951c2018-03-26 15:12:43 +0100635 ERRATA_MIDR_REV(MIDR_QCOM_FALKOR_V1, 0, 0),
Christopher Covingtond9ff80f2017-01-31 12:50:19 -0500636 },
637#endif
Marc Zyngiereeb1efb2017-03-20 17:18:06 +0000638#ifdef CONFIG_ARM64_ERRATUM_858921
639 {
640 /* Cortex-A73 all versions */
641 .desc = "ARM erratum 858921",
642 .capability = ARM64_WORKAROUND_858921,
Suzuki K Poulose5e7951c2018-03-26 15:12:43 +0100643 ERRATA_MIDR_ALL_VERSIONS(MIDR_CORTEX_A73),
Marc Zyngiereeb1efb2017-03-20 17:18:06 +0000644 },
645#endif
Will Deaconaa6acde2018-01-03 12:46:21 +0000646#ifdef CONFIG_HARDEN_BRANCH_PREDICTOR
647 {
648 .capability = ARM64_HARDEN_BRANCH_PREDICTOR,
Suzuki K Pouloseba7d9232018-03-26 15:12:46 +0100649 .type = ARM64_CPUCAP_LOCAL_CPU_ERRATUM,
Shanker Donthineni4bc352f2018-04-10 11:36:42 +0100650 .cpu_enable = enable_smccc_arch_workaround_1,
651 ERRATA_MIDR_RANGE_LIST(arm64_bp_harden_smccc_cpus),
Jayachandran Cf3d795d2018-01-19 04:22:47 -0800652 },
Will Deaconaa6acde2018-01-03 12:46:21 +0000653#endif
Marc Zyngier4b472ff2018-02-15 11:49:20 +0000654#ifdef CONFIG_HARDEN_EL2_VECTORS
655 {
Marc Zyngier8892b712018-04-10 11:36:43 +0100656 .desc = "EL2 vector hardening",
Marc Zyngier4b472ff2018-02-15 11:49:20 +0000657 .capability = ARM64_HARDEN_EL2_VECTORS,
Marc Zyngier8892b712018-04-10 11:36:43 +0100658 .type = ARM64_CPUCAP_LOCAL_CPU_ERRATUM,
659 ERRATA_MIDR_RANGE_LIST(arm64_harden_el2_vectors),
Marc Zyngier4b472ff2018-02-15 11:49:20 +0000660 },
661#endif
Marc Zyngiera725e3d2018-05-29 13:11:08 +0100662#ifdef CONFIG_ARM64_SSBD
663 {
664 .desc = "Speculative Store Bypass Disable",
665 .capability = ARM64_SSBD,
666 .type = ARM64_CPUCAP_LOCAL_CPU_ERRATUM,
667 .matches = has_ssbd_mitigation,
668 },
669#endif
Suzuki K Poulose116c81f2016-09-09 14:07:16 +0100670 {
Andre Przywarae116a372014-11-14 15:54:09 +0000671 }
672};