blob: 533559c7d2b31bb3cb6db6af22c00d0dbf4d0225 [file] [log] [blame]
David Brazdil0f672f62019-12-10 10:32:29 +00001// SPDX-License-Identifier: GPL-2.0-only
Andrew Scullb4b6d4a2019-01-02 15:54:55 +00002/*
3 * Contains CPU specific errata definitions
4 *
5 * Copyright (C) 2014 ARM Ltd.
Andrew Scullb4b6d4a2019-01-02 15:54:55 +00006 */
7
8#include <linux/arm-smccc.h>
Andrew Scullb4b6d4a2019-01-02 15:54:55 +00009#include <linux/types.h>
David Brazdil0f672f62019-12-10 10:32:29 +000010#include <linux/cpu.h>
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000011#include <asm/cpu.h>
12#include <asm/cputype.h>
13#include <asm/cpufeature.h>
Olivier Deprez157378f2022-04-04 15:47:50 +020014#include <asm/kvm_asm.h>
David Brazdil0f672f62019-12-10 10:32:29 +000015#include <asm/smp_plat.h>
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000016
17static bool __maybe_unused
18is_affected_midr_range(const struct arm64_cpu_capabilities *entry, int scope)
19{
20 const struct arm64_midr_revidr *fix;
21 u32 midr = read_cpuid_id(), revidr;
22
23 WARN_ON(scope != SCOPE_LOCAL_CPU || preemptible());
24 if (!is_midr_in_range(midr, &entry->midr_range))
25 return false;
26
27 midr &= MIDR_REVISION_MASK | MIDR_VARIANT_MASK;
28 revidr = read_cpuid(REVIDR_EL1);
29 for (fix = entry->fixed_revs; fix && fix->revidr_mask; fix++)
30 if (midr == fix->midr_rv && (revidr & fix->revidr_mask))
31 return false;
32
33 return true;
34}
35
36static bool __maybe_unused
37is_affected_midr_range_list(const struct arm64_cpu_capabilities *entry,
38 int scope)
39{
40 WARN_ON(scope != SCOPE_LOCAL_CPU || preemptible());
41 return is_midr_in_range_list(read_cpuid_id(), entry->midr_range_list);
42}
43
44static bool __maybe_unused
45is_kryo_midr(const struct arm64_cpu_capabilities *entry, int scope)
46{
47 u32 model;
48
49 WARN_ON(scope != SCOPE_LOCAL_CPU || preemptible());
50
51 model = read_cpuid_id();
52 model &= MIDR_IMPLEMENTOR_MASK | (0xf00 << MIDR_PARTNUM_SHIFT) |
53 MIDR_ARCHITECTURE_MASK;
54
55 return model == entry->midr_range.model;
56}
57
58static bool
59has_mismatched_cache_type(const struct arm64_cpu_capabilities *entry,
60 int scope)
61{
David Brazdil0f672f62019-12-10 10:32:29 +000062 u64 mask = arm64_ftr_reg_ctrel0.strict_mask;
63 u64 sys = arm64_ftr_reg_ctrel0.sys_val & mask;
64 u64 ctr_raw, ctr_real;
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000065
66 WARN_ON(scope != SCOPE_LOCAL_CPU || preemptible());
David Brazdil0f672f62019-12-10 10:32:29 +000067
68 /*
69 * We want to make sure that all the CPUs in the system expose
70 * a consistent CTR_EL0 to make sure that applications behaves
71 * correctly with migration.
72 *
73 * If a CPU has CTR_EL0.IDC but does not advertise it via CTR_EL0 :
74 *
75 * 1) It is safe if the system doesn't support IDC, as CPU anyway
76 * reports IDC = 0, consistent with the rest.
77 *
78 * 2) If the system has IDC, it is still safe as we trap CTR_EL0
79 * access on this CPU via the ARM64_HAS_CACHE_IDC capability.
80 *
81 * So, we need to make sure either the raw CTR_EL0 or the effective
82 * CTR_EL0 matches the system's copy to allow a secondary CPU to boot.
83 */
84 ctr_raw = read_cpuid_cachetype() & mask;
85 ctr_real = read_cpuid_effective_cachetype() & mask;
86
87 return (ctr_real != sys) && (ctr_raw != sys);
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000088}
89
90static void
Olivier Deprez0e641232021-09-23 10:07:05 +020091cpu_enable_trap_ctr_access(const struct arm64_cpu_capabilities *cap)
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000092{
David Brazdil0f672f62019-12-10 10:32:29 +000093 u64 mask = arm64_ftr_reg_ctrel0.strict_mask;
Olivier Deprez0e641232021-09-23 10:07:05 +020094 bool enable_uct_trap = false;
David Brazdil0f672f62019-12-10 10:32:29 +000095
96 /* Trap CTR_EL0 access on this CPU, only if it has a mismatch */
97 if ((read_cpuid_cachetype() & mask) !=
98 (arm64_ftr_reg_ctrel0.sys_val & mask))
Olivier Deprez0e641232021-09-23 10:07:05 +020099 enable_uct_trap = true;
100
101 /* ... or if the system is affected by an erratum */
102 if (cap->capability == ARM64_WORKAROUND_1542419)
103 enable_uct_trap = true;
104
105 if (enable_uct_trap)
David Brazdil0f672f62019-12-10 10:32:29 +0000106 sysreg_clear_set(sctlr_el1, SCTLR_EL1_UCT, 0);
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000107}
108
David Brazdil0f672f62019-12-10 10:32:29 +0000109#ifdef CONFIG_ARM64_ERRATUM_1463225
110DEFINE_PER_CPU(int, __in_cortex_a76_erratum_1463225_wa);
111
112static bool
113has_cortex_a76_erratum_1463225(const struct arm64_cpu_capabilities *entry,
114 int scope)
115{
Olivier Deprez157378f2022-04-04 15:47:50 +0200116 return is_affected_midr_range_list(entry, scope) && is_kernel_in_hyp_mode();
David Brazdil0f672f62019-12-10 10:32:29 +0000117}
118#endif
119
120static void __maybe_unused
121cpu_enable_cache_maint_trap(const struct arm64_cpu_capabilities *__unused)
122{
123 sysreg_clear_set(sctlr_el1, SCTLR_EL1_UCI, 0);
124}
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000125
126#define CAP_MIDR_RANGE(model, v_min, r_min, v_max, r_max) \
127 .matches = is_affected_midr_range, \
128 .midr_range = MIDR_RANGE(model, v_min, r_min, v_max, r_max)
129
130#define CAP_MIDR_ALL_VERSIONS(model) \
131 .matches = is_affected_midr_range, \
132 .midr_range = MIDR_ALL_VERSIONS(model)
133
134#define MIDR_FIXED(rev, revidr_mask) \
135 .fixed_revs = (struct arm64_midr_revidr[]){{ (rev), (revidr_mask) }, {}}
136
137#define ERRATA_MIDR_RANGE(model, v_min, r_min, v_max, r_max) \
138 .type = ARM64_CPUCAP_LOCAL_CPU_ERRATUM, \
139 CAP_MIDR_RANGE(model, v_min, r_min, v_max, r_max)
140
141#define CAP_MIDR_RANGE_LIST(list) \
142 .matches = is_affected_midr_range_list, \
143 .midr_range_list = list
144
145/* Errata affecting a range of revisions of given model variant */
146#define ERRATA_MIDR_REV_RANGE(m, var, r_min, r_max) \
147 ERRATA_MIDR_RANGE(m, var, r_min, var, r_max)
148
149/* Errata affecting a single variant/revision of a model */
150#define ERRATA_MIDR_REV(model, var, rev) \
151 ERRATA_MIDR_RANGE(model, var, rev, var, rev)
152
153/* Errata affecting all variants/revisions of a given a model */
154#define ERRATA_MIDR_ALL_VERSIONS(model) \
155 .type = ARM64_CPUCAP_LOCAL_CPU_ERRATUM, \
156 CAP_MIDR_ALL_VERSIONS(model)
157
158/* Errata affecting a list of midr ranges, with same work around */
159#define ERRATA_MIDR_RANGE_LIST(midr_list) \
160 .type = ARM64_CPUCAP_LOCAL_CPU_ERRATUM, \
161 CAP_MIDR_RANGE_LIST(midr_list)
162
David Brazdil0f672f62019-12-10 10:32:29 +0000163static const __maybe_unused struct midr_range tx2_family_cpus[] = {
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000164 MIDR_ALL_VERSIONS(MIDR_BRCM_VULCAN),
165 MIDR_ALL_VERSIONS(MIDR_CAVIUM_THUNDERX2),
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000166 {},
167};
168
David Brazdil0f672f62019-12-10 10:32:29 +0000169static bool __maybe_unused
170needs_tx2_tvm_workaround(const struct arm64_cpu_capabilities *entry,
171 int scope)
172{
173 int i;
174
175 if (!is_affected_midr_range_list(entry, scope) ||
176 !is_hyp_mode_available())
177 return false;
178
179 for_each_possible_cpu(i) {
180 if (MPIDR_AFFINITY_LEVEL(cpu_logical_map(i), 0) != 0)
181 return true;
182 }
183
184 return false;
185}
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000186
Olivier Deprez0e641232021-09-23 10:07:05 +0200187static bool __maybe_unused
188has_neoverse_n1_erratum_1542419(const struct arm64_cpu_capabilities *entry,
189 int scope)
190{
191 u32 midr = read_cpuid_id();
192 bool has_dic = read_cpuid_cachetype() & BIT(CTR_DIC_SHIFT);
193 const struct midr_range range = MIDR_ALL_VERSIONS(MIDR_NEOVERSE_N1);
194
195 WARN_ON(scope != SCOPE_LOCAL_CPU || preemptible());
196 return is_midr_in_range(midr, &range) && has_dic;
197}
198
Olivier Deprez157378f2022-04-04 15:47:50 +0200199#ifdef CONFIG_RANDOMIZE_BASE
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000200
Olivier Deprez157378f2022-04-04 15:47:50 +0200201static const struct midr_range ca57_a72[] = {
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000202 MIDR_ALL_VERSIONS(MIDR_CORTEX_A57),
203 MIDR_ALL_VERSIONS(MIDR_CORTEX_A72),
204 {},
205};
206
207#endif
208
David Brazdil0f672f62019-12-10 10:32:29 +0000209#ifdef CONFIG_ARM64_WORKAROUND_REPEAT_TLBI
210static const struct arm64_cpu_capabilities arm64_repeat_tlbi_list[] = {
211#ifdef CONFIG_QCOM_FALKOR_ERRATUM_1009
212 {
213 ERRATA_MIDR_REV(MIDR_QCOM_FALKOR_V1, 0, 0)
214 },
215 {
216 .midr_range.model = MIDR_QCOM_KRYO,
217 .matches = is_kryo_midr,
218 },
219#endif
220#ifdef CONFIG_ARM64_ERRATUM_1286807
221 {
222 ERRATA_MIDR_RANGE(MIDR_CORTEX_A76, 0, 0, 3, 0),
223 },
224#endif
225 {},
226};
227#endif
228
229#ifdef CONFIG_CAVIUM_ERRATUM_27456
230const struct midr_range cavium_erratum_27456_cpus[] = {
231 /* Cavium ThunderX, T88 pass 1.x - 2.1 */
232 MIDR_RANGE(MIDR_THUNDERX, 0, 0, 1, 1),
233 /* Cavium ThunderX, T81 pass 1.0 */
234 MIDR_REV(MIDR_THUNDERX_81XX, 0, 0),
235 {},
236};
237#endif
238
239#ifdef CONFIG_CAVIUM_ERRATUM_30115
240static const struct midr_range cavium_erratum_30115_cpus[] = {
241 /* Cavium ThunderX, T88 pass 1.x - 2.2 */
242 MIDR_RANGE(MIDR_THUNDERX, 0, 0, 1, 2),
243 /* Cavium ThunderX, T81 pass 1.0 - 1.2 */
244 MIDR_REV_RANGE(MIDR_THUNDERX_81XX, 0, 0, 2),
245 /* Cavium ThunderX, T83 pass 1.0 */
246 MIDR_REV(MIDR_THUNDERX_83XX, 0, 0),
247 {},
248};
249#endif
250
251#ifdef CONFIG_QCOM_FALKOR_ERRATUM_1003
252static const struct arm64_cpu_capabilities qcom_erratum_1003_list[] = {
253 {
254 ERRATA_MIDR_REV(MIDR_QCOM_FALKOR_V1, 0, 0),
255 },
256 {
257 .midr_range.model = MIDR_QCOM_KRYO,
258 .matches = is_kryo_midr,
259 },
260 {},
261};
262#endif
263
264#ifdef CONFIG_ARM64_WORKAROUND_CLEAN_CACHE
265static const struct midr_range workaround_clean_cache[] = {
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000266#if defined(CONFIG_ARM64_ERRATUM_826319) || \
267 defined(CONFIG_ARM64_ERRATUM_827319) || \
268 defined(CONFIG_ARM64_ERRATUM_824069)
David Brazdil0f672f62019-12-10 10:32:29 +0000269 /* Cortex-A53 r0p[012]: ARM errata 826319, 827319, 824069 */
270 MIDR_REV_RANGE(MIDR_CORTEX_A53, 0, 0, 2),
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000271#endif
David Brazdil0f672f62019-12-10 10:32:29 +0000272#ifdef CONFIG_ARM64_ERRATUM_819472
273 /* Cortex-A53 r0p[01] : ARM errata 819472 */
274 MIDR_REV_RANGE(MIDR_CORTEX_A53, 0, 0, 1),
275#endif
276 {},
277};
278#endif
279
280#ifdef CONFIG_ARM64_ERRATUM_1418040
281/*
282 * - 1188873 affects r0p0 to r2p0
283 * - 1418040 affects r0p0 to r3p1
284 */
285static const struct midr_range erratum_1418040_list[] = {
286 /* Cortex-A76 r0p0 to r3p1 */
287 MIDR_RANGE(MIDR_CORTEX_A76, 0, 0, 3, 1),
288 /* Neoverse-N1 r0p0 to r3p1 */
289 MIDR_RANGE(MIDR_NEOVERSE_N1, 0, 0, 3, 1),
Olivier Deprez157378f2022-04-04 15:47:50 +0200290 /* Kryo4xx Gold (rcpe to rfpf) => (r0p0 to r3p1) */
291 MIDR_RANGE(MIDR_QCOM_KRYO_4XX_GOLD, 0xc, 0xe, 0xf, 0xf),
David Brazdil0f672f62019-12-10 10:32:29 +0000292 {},
293};
294#endif
295
296#ifdef CONFIG_ARM64_ERRATUM_845719
297static const struct midr_range erratum_845719_list[] = {
298 /* Cortex-A53 r0p[01234] */
299 MIDR_REV_RANGE(MIDR_CORTEX_A53, 0, 0, 4),
300 /* Brahma-B53 r0p[0] */
301 MIDR_REV(MIDR_BRAHMA_B53, 0, 0),
Olivier Deprez157378f2022-04-04 15:47:50 +0200302 /* Kryo2XX Silver rAp4 */
303 MIDR_REV(MIDR_QCOM_KRYO_2XX_SILVER, 0xa, 0x4),
David Brazdil0f672f62019-12-10 10:32:29 +0000304 {},
305};
306#endif
307
308#ifdef CONFIG_ARM64_ERRATUM_843419
309static const struct arm64_cpu_capabilities erratum_843419_list[] = {
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000310 {
David Brazdil0f672f62019-12-10 10:32:29 +0000311 /* Cortex-A53 r0p[01234] */
312 .matches = is_affected_midr_range,
313 ERRATA_MIDR_REV_RANGE(MIDR_CORTEX_A53, 0, 0, 4),
314 MIDR_FIXED(0x4, BIT(8)),
315 },
316 {
317 /* Brahma-B53 r0p[0] */
318 .matches = is_affected_midr_range,
319 ERRATA_MIDR_REV(MIDR_BRAHMA_B53, 0, 0),
320 },
321 {},
322};
323#endif
324
Olivier Deprez157378f2022-04-04 15:47:50 +0200325#ifdef CONFIG_ARM64_WORKAROUND_SPECULATIVE_AT
326static const struct midr_range erratum_speculative_at_list[] = {
327#ifdef CONFIG_ARM64_ERRATUM_1165522
328 /* Cortex A76 r0p0 to r2p0 */
329 MIDR_RANGE(MIDR_CORTEX_A76, 0, 0, 2, 0),
330#endif
331#ifdef CONFIG_ARM64_ERRATUM_1319367
332 MIDR_ALL_VERSIONS(MIDR_CORTEX_A57),
333 MIDR_ALL_VERSIONS(MIDR_CORTEX_A72),
334#endif
335#ifdef CONFIG_ARM64_ERRATUM_1530923
336 /* Cortex A55 r0p0 to r2p0 */
337 MIDR_RANGE(MIDR_CORTEX_A55, 0, 0, 2, 0),
338 /* Kryo4xx Silver (rdpe => r1p0) */
339 MIDR_REV(MIDR_QCOM_KRYO_4XX_SILVER, 0xd, 0xe),
340#endif
341 {},
342};
343#endif
344
345#ifdef CONFIG_ARM64_ERRATUM_1463225
346static const struct midr_range erratum_1463225[] = {
347 /* Cortex-A76 r0p0 - r3p1 */
348 MIDR_RANGE(MIDR_CORTEX_A76, 0, 0, 3, 1),
349 /* Kryo4xx Gold (rcpe to rfpf) => (r0p0 to r3p1) */
350 MIDR_RANGE(MIDR_QCOM_KRYO_4XX_GOLD, 0xc, 0xe, 0xf, 0xf),
351 {},
352};
353#endif
354
David Brazdil0f672f62019-12-10 10:32:29 +0000355const struct arm64_cpu_capabilities arm64_errata[] = {
356#ifdef CONFIG_ARM64_WORKAROUND_CLEAN_CACHE
357 {
Olivier Deprez157378f2022-04-04 15:47:50 +0200358 .desc = "ARM errata 826319, 827319, 824069, or 819472",
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000359 .capability = ARM64_WORKAROUND_CLEAN_CACHE,
David Brazdil0f672f62019-12-10 10:32:29 +0000360 ERRATA_MIDR_RANGE_LIST(workaround_clean_cache),
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000361 .cpu_enable = cpu_enable_cache_maint_trap,
362 },
363#endif
364#ifdef CONFIG_ARM64_ERRATUM_832075
365 {
366 /* Cortex-A57 r0p0 - r1p2 */
367 .desc = "ARM erratum 832075",
368 .capability = ARM64_WORKAROUND_DEVICE_LOAD_ACQUIRE,
369 ERRATA_MIDR_RANGE(MIDR_CORTEX_A57,
370 0, 0,
371 1, 2),
372 },
373#endif
374#ifdef CONFIG_ARM64_ERRATUM_834220
375 {
376 /* Cortex-A57 r0p0 - r1p2 */
377 .desc = "ARM erratum 834220",
378 .capability = ARM64_WORKAROUND_834220,
379 ERRATA_MIDR_RANGE(MIDR_CORTEX_A57,
380 0, 0,
381 1, 2),
382 },
383#endif
384#ifdef CONFIG_ARM64_ERRATUM_843419
385 {
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000386 .desc = "ARM erratum 843419",
387 .capability = ARM64_WORKAROUND_843419,
David Brazdil0f672f62019-12-10 10:32:29 +0000388 .type = ARM64_CPUCAP_LOCAL_CPU_ERRATUM,
389 .matches = cpucap_multi_entry_cap_matches,
390 .match_list = erratum_843419_list,
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000391 },
392#endif
393#ifdef CONFIG_ARM64_ERRATUM_845719
394 {
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000395 .desc = "ARM erratum 845719",
396 .capability = ARM64_WORKAROUND_845719,
David Brazdil0f672f62019-12-10 10:32:29 +0000397 ERRATA_MIDR_RANGE_LIST(erratum_845719_list),
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000398 },
399#endif
400#ifdef CONFIG_CAVIUM_ERRATUM_23154
401 {
402 /* Cavium ThunderX, pass 1.x */
403 .desc = "Cavium erratum 23154",
404 .capability = ARM64_WORKAROUND_CAVIUM_23154,
405 ERRATA_MIDR_REV_RANGE(MIDR_THUNDERX, 0, 0, 1),
406 },
407#endif
408#ifdef CONFIG_CAVIUM_ERRATUM_27456
409 {
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000410 .desc = "Cavium erratum 27456",
411 .capability = ARM64_WORKAROUND_CAVIUM_27456,
David Brazdil0f672f62019-12-10 10:32:29 +0000412 ERRATA_MIDR_RANGE_LIST(cavium_erratum_27456_cpus),
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000413 },
414#endif
415#ifdef CONFIG_CAVIUM_ERRATUM_30115
416 {
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000417 .desc = "Cavium erratum 30115",
418 .capability = ARM64_WORKAROUND_CAVIUM_30115,
David Brazdil0f672f62019-12-10 10:32:29 +0000419 ERRATA_MIDR_RANGE_LIST(cavium_erratum_30115_cpus),
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000420 },
421#endif
422 {
David Brazdil0f672f62019-12-10 10:32:29 +0000423 .desc = "Mismatched cache type (CTR_EL0)",
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000424 .capability = ARM64_MISMATCHED_CACHE_TYPE,
425 .matches = has_mismatched_cache_type,
426 .type = ARM64_CPUCAP_LOCAL_CPU_ERRATUM,
427 .cpu_enable = cpu_enable_trap_ctr_access,
428 },
429#ifdef CONFIG_QCOM_FALKOR_ERRATUM_1003
430 {
David Brazdil0f672f62019-12-10 10:32:29 +0000431 .desc = "Qualcomm Technologies Falkor/Kryo erratum 1003",
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000432 .capability = ARM64_WORKAROUND_QCOM_FALKOR_E1003,
433 .type = ARM64_CPUCAP_LOCAL_CPU_ERRATUM,
David Brazdil0f672f62019-12-10 10:32:29 +0000434 .matches = cpucap_multi_entry_cap_matches,
435 .match_list = qcom_erratum_1003_list,
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000436 },
437#endif
David Brazdil0f672f62019-12-10 10:32:29 +0000438#ifdef CONFIG_ARM64_WORKAROUND_REPEAT_TLBI
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000439 {
Olivier Deprez157378f2022-04-04 15:47:50 +0200440 .desc = "Qualcomm erratum 1009, or ARM erratum 1286807",
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000441 .capability = ARM64_WORKAROUND_REPEAT_TLBI,
David Brazdil0f672f62019-12-10 10:32:29 +0000442 .type = ARM64_CPUCAP_LOCAL_CPU_ERRATUM,
443 .matches = cpucap_multi_entry_cap_matches,
444 .match_list = arm64_repeat_tlbi_list,
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000445 },
446#endif
447#ifdef CONFIG_ARM64_ERRATUM_858921
448 {
449 /* Cortex-A73 all versions */
450 .desc = "ARM erratum 858921",
451 .capability = ARM64_WORKAROUND_858921,
452 ERRATA_MIDR_ALL_VERSIONS(MIDR_CORTEX_A73),
453 },
454#endif
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000455 {
Olivier Deprez157378f2022-04-04 15:47:50 +0200456 .desc = "Spectre-v2",
457 .capability = ARM64_SPECTRE_V2,
David Brazdil0f672f62019-12-10 10:32:29 +0000458 .type = ARM64_CPUCAP_LOCAL_CPU_ERRATUM,
Olivier Deprez157378f2022-04-04 15:47:50 +0200459 .matches = has_spectre_v2,
460 .cpu_enable = spectre_v2_enable_mitigation,
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000461 },
Olivier Deprez157378f2022-04-04 15:47:50 +0200462#ifdef CONFIG_RANDOMIZE_BASE
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000463 {
464 .desc = "EL2 vector hardening",
465 .capability = ARM64_HARDEN_EL2_VECTORS,
Olivier Deprez157378f2022-04-04 15:47:50 +0200466 ERRATA_MIDR_RANGE_LIST(ca57_a72),
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000467 },
468#endif
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000469 {
Olivier Deprez157378f2022-04-04 15:47:50 +0200470 .desc = "Spectre-v4",
471 .capability = ARM64_SPECTRE_V4,
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000472 .type = ARM64_CPUCAP_LOCAL_CPU_ERRATUM,
Olivier Deprez157378f2022-04-04 15:47:50 +0200473 .matches = has_spectre_v4,
474 .cpu_enable = spectre_v4_enable_mitigation,
475 },
476 {
477 .desc = "Spectre-BHB",
478 .capability = ARM64_SPECTRE_BHB,
479 .type = ARM64_CPUCAP_LOCAL_CPU_ERRATUM,
480 .matches = is_spectre_bhb_affected,
481 .cpu_enable = spectre_bhb_enable_mitigation,
David Brazdil0f672f62019-12-10 10:32:29 +0000482 },
483#ifdef CONFIG_ARM64_ERRATUM_1418040
484 {
485 .desc = "ARM erratum 1418040",
486 .capability = ARM64_WORKAROUND_1418040,
487 ERRATA_MIDR_RANGE_LIST(erratum_1418040_list),
Olivier Deprez0e641232021-09-23 10:07:05 +0200488 /*
489 * We need to allow affected CPUs to come in late, but
490 * also need the non-affected CPUs to be able to come
491 * in at any point in time. Wonderful.
492 */
493 .type = ARM64_CPUCAP_WEAK_LOCAL_CPU_FEATURE,
David Brazdil0f672f62019-12-10 10:32:29 +0000494 },
495#endif
Olivier Deprez157378f2022-04-04 15:47:50 +0200496#ifdef CONFIG_ARM64_WORKAROUND_SPECULATIVE_AT
David Brazdil0f672f62019-12-10 10:32:29 +0000497 {
Olivier Deprez157378f2022-04-04 15:47:50 +0200498 .desc = "ARM errata 1165522, 1319367, or 1530923",
499 .capability = ARM64_WORKAROUND_SPECULATIVE_AT,
500 ERRATA_MIDR_RANGE_LIST(erratum_speculative_at_list),
David Brazdil0f672f62019-12-10 10:32:29 +0000501 },
502#endif
503#ifdef CONFIG_ARM64_ERRATUM_1463225
504 {
505 .desc = "ARM erratum 1463225",
506 .capability = ARM64_WORKAROUND_1463225,
507 .type = ARM64_CPUCAP_LOCAL_CPU_ERRATUM,
508 .matches = has_cortex_a76_erratum_1463225,
Olivier Deprez157378f2022-04-04 15:47:50 +0200509 .midr_range_list = erratum_1463225,
David Brazdil0f672f62019-12-10 10:32:29 +0000510 },
511#endif
512#ifdef CONFIG_CAVIUM_TX2_ERRATUM_219
513 {
514 .desc = "Cavium ThunderX2 erratum 219 (KVM guest sysreg trapping)",
515 .capability = ARM64_WORKAROUND_CAVIUM_TX2_219_TVM,
516 ERRATA_MIDR_RANGE_LIST(tx2_family_cpus),
517 .matches = needs_tx2_tvm_workaround,
518 },
519 {
520 .desc = "Cavium ThunderX2 erratum 219 (PRFM removal)",
521 .capability = ARM64_WORKAROUND_CAVIUM_TX2_219_PRFM,
522 ERRATA_MIDR_RANGE_LIST(tx2_family_cpus),
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000523 },
524#endif
Olivier Deprez0e641232021-09-23 10:07:05 +0200525#ifdef CONFIG_ARM64_ERRATUM_1542419
526 {
527 /* we depend on the firmware portion for correctness */
528 .desc = "ARM erratum 1542419 (kernel portion)",
529 .capability = ARM64_WORKAROUND_1542419,
530 .type = ARM64_CPUCAP_LOCAL_CPU_ERRATUM,
531 .matches = has_neoverse_n1_erratum_1542419,
532 .cpu_enable = cpu_enable_trap_ctr_access,
533 },
534#endif
Olivier Deprez157378f2022-04-04 15:47:50 +0200535#ifdef CONFIG_ARM64_ERRATUM_1508412
536 {
537 /* we depend on the firmware portion for correctness */
538 .desc = "ARM erratum 1508412 (kernel portion)",
539 .capability = ARM64_WORKAROUND_1508412,
540 ERRATA_MIDR_RANGE(MIDR_CORTEX_A77,
541 0, 0,
542 1, 0),
543 },
544#endif
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000545 {
546 }
547};