cpu_errata.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685
  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. #include <linux/arm-smccc.h>
  19. #include <linux/psci.h>
  20. #include <linux/types.h>
  21. #include <asm/cpu.h>
  22. #include <asm/cputype.h>
  23. #include <asm/cpufeature.h>
  24. static bool __maybe_unused
  25. is_affected_midr_range(const struct arm64_cpu_capabilities *entry, int scope)
  26. {
  27. const struct arm64_midr_revidr *fix;
  28. u32 midr = read_cpuid_id(), revidr;
  29. WARN_ON(scope != SCOPE_LOCAL_CPU || preemptible());
  30. if (!is_midr_in_range(midr, &entry->midr_range))
  31. return false;
  32. midr &= MIDR_REVISION_MASK | MIDR_VARIANT_MASK;
  33. revidr = read_cpuid(REVIDR_EL1);
  34. for (fix = entry->fixed_revs; fix && fix->revidr_mask; fix++)
  35. if (midr == fix->midr_rv && (revidr & fix->revidr_mask))
  36. return false;
  37. return true;
  38. }
  39. static bool __maybe_unused
  40. is_affected_midr_range_list(const struct arm64_cpu_capabilities *entry,
  41. int scope)
  42. {
  43. WARN_ON(scope != SCOPE_LOCAL_CPU || preemptible());
  44. return is_midr_in_range_list(read_cpuid_id(), entry->midr_range_list);
  45. }
  46. static bool __maybe_unused
  47. is_kryo_midr(const struct arm64_cpu_capabilities *entry, int scope)
  48. {
  49. u32 model;
  50. WARN_ON(scope != SCOPE_LOCAL_CPU || preemptible());
  51. model = read_cpuid_id();
  52. model &= MIDR_IMPLEMENTOR_MASK | (0xf00 << MIDR_PARTNUM_SHIFT) |
  53. MIDR_ARCHITECTURE_MASK;
  54. return model == entry->midr_range.model;
  55. }
  56. static bool
  57. has_mismatched_cache_type(const struct arm64_cpu_capabilities *entry,
  58. int scope)
  59. {
  60. u64 mask = CTR_CACHE_MINLINE_MASK;
  61. /* Skip matching the min line sizes for cache type check */
  62. if (entry->capability == ARM64_MISMATCHED_CACHE_TYPE)
  63. mask ^= arm64_ftr_reg_ctrel0.strict_mask;
  64. WARN_ON(scope != SCOPE_LOCAL_CPU || preemptible());
  65. return (read_cpuid_cachetype() & mask) !=
  66. (arm64_ftr_reg_ctrel0.sys_val & mask);
  67. }
  68. static void
  69. cpu_enable_trap_ctr_access(const struct arm64_cpu_capabilities *__unused)
  70. {
  71. sysreg_clear_set(sctlr_el1, SCTLR_EL1_UCT, 0);
  72. }
  73. atomic_t arm64_el2_vector_last_slot = ATOMIC_INIT(-1);
  74. #ifdef CONFIG_HARDEN_BRANCH_PREDICTOR
  75. #include <asm/mmu_context.h>
  76. #include <asm/cacheflush.h>
  77. DEFINE_PER_CPU_READ_MOSTLY(struct bp_hardening_data, bp_hardening_data);
  78. #ifdef CONFIG_KVM_INDIRECT_VECTORS
  79. extern char __smccc_workaround_1_smc_start[];
  80. extern char __smccc_workaround_1_smc_end[];
  81. static void __copy_hyp_vect_bpi(int slot, const char *hyp_vecs_start,
  82. const char *hyp_vecs_end)
  83. {
  84. void *dst = lm_alias(__bp_harden_hyp_vecs_start + slot * SZ_2K);
  85. int i;
  86. for (i = 0; i < SZ_2K; i += 0x80)
  87. memcpy(dst + i, hyp_vecs_start, hyp_vecs_end - hyp_vecs_start);
  88. __flush_icache_range((uintptr_t)dst, (uintptr_t)dst + SZ_2K);
  89. }
  90. static void __install_bp_hardening_cb(bp_hardening_cb_t fn,
  91. const char *hyp_vecs_start,
  92. const char *hyp_vecs_end)
  93. {
  94. static DEFINE_SPINLOCK(bp_lock);
  95. int cpu, slot = -1;
  96. spin_lock(&bp_lock);
  97. for_each_possible_cpu(cpu) {
  98. if (per_cpu(bp_hardening_data.fn, cpu) == fn) {
  99. slot = per_cpu(bp_hardening_data.hyp_vectors_slot, cpu);
  100. break;
  101. }
  102. }
  103. if (slot == -1) {
  104. slot = atomic_inc_return(&arm64_el2_vector_last_slot);
  105. BUG_ON(slot >= BP_HARDEN_EL2_SLOTS);
  106. __copy_hyp_vect_bpi(slot, hyp_vecs_start, hyp_vecs_end);
  107. }
  108. __this_cpu_write(bp_hardening_data.hyp_vectors_slot, slot);
  109. __this_cpu_write(bp_hardening_data.fn, fn);
  110. spin_unlock(&bp_lock);
  111. }
  112. #else
  113. #define __smccc_workaround_1_smc_start NULL
  114. #define __smccc_workaround_1_smc_end NULL
  115. static void __install_bp_hardening_cb(bp_hardening_cb_t fn,
  116. const char *hyp_vecs_start,
  117. const char *hyp_vecs_end)
  118. {
  119. __this_cpu_write(bp_hardening_data.fn, fn);
  120. }
  121. #endif /* CONFIG_KVM_INDIRECT_VECTORS */
  122. static void install_bp_hardening_cb(const struct arm64_cpu_capabilities *entry,
  123. bp_hardening_cb_t fn,
  124. const char *hyp_vecs_start,
  125. const char *hyp_vecs_end)
  126. {
  127. u64 pfr0;
  128. if (!entry->matches(entry, SCOPE_LOCAL_CPU))
  129. return;
  130. pfr0 = read_cpuid(ID_AA64PFR0_EL1);
  131. if (cpuid_feature_extract_unsigned_field(pfr0, ID_AA64PFR0_CSV2_SHIFT))
  132. return;
  133. __install_bp_hardening_cb(fn, hyp_vecs_start, hyp_vecs_end);
  134. }
  135. #include <uapi/linux/psci.h>
  136. #include <linux/arm-smccc.h>
  137. #include <linux/psci.h>
  138. static void call_smc_arch_workaround_1(void)
  139. {
  140. arm_smccc_1_1_smc(ARM_SMCCC_ARCH_WORKAROUND_1, NULL);
  141. }
  142. static void call_hvc_arch_workaround_1(void)
  143. {
  144. arm_smccc_1_1_hvc(ARM_SMCCC_ARCH_WORKAROUND_1, NULL);
  145. }
  146. static void qcom_link_stack_sanitization(void)
  147. {
  148. u64 tmp;
  149. asm volatile("mov %0, x30 \n"
  150. ".rept 16 \n"
  151. "bl . + 4 \n"
  152. ".endr \n"
  153. "mov x30, %0 \n"
  154. : "=&r" (tmp));
  155. }
  156. static void
  157. enable_smccc_arch_workaround_1(const struct arm64_cpu_capabilities *entry)
  158. {
  159. bp_hardening_cb_t cb;
  160. void *smccc_start, *smccc_end;
  161. struct arm_smccc_res res;
  162. u32 midr = read_cpuid_id();
  163. if (!entry->matches(entry, SCOPE_LOCAL_CPU))
  164. return;
  165. if (psci_ops.smccc_version == SMCCC_VERSION_1_0)
  166. return;
  167. switch (psci_ops.conduit) {
  168. case PSCI_CONDUIT_HVC:
  169. arm_smccc_1_1_hvc(ARM_SMCCC_ARCH_FEATURES_FUNC_ID,
  170. ARM_SMCCC_ARCH_WORKAROUND_1, &res);
  171. if ((int)res.a0 < 0)
  172. return;
  173. cb = call_hvc_arch_workaround_1;
  174. /* This is a guest, no need to patch KVM vectors */
  175. smccc_start = NULL;
  176. smccc_end = NULL;
  177. break;
  178. case PSCI_CONDUIT_SMC:
  179. arm_smccc_1_1_smc(ARM_SMCCC_ARCH_FEATURES_FUNC_ID,
  180. ARM_SMCCC_ARCH_WORKAROUND_1, &res);
  181. if ((int)res.a0 < 0)
  182. return;
  183. cb = call_smc_arch_workaround_1;
  184. smccc_start = __smccc_workaround_1_smc_start;
  185. smccc_end = __smccc_workaround_1_smc_end;
  186. break;
  187. default:
  188. return;
  189. }
  190. if (((midr & MIDR_CPU_MODEL_MASK) == MIDR_QCOM_FALKOR) ||
  191. ((midr & MIDR_CPU_MODEL_MASK) == MIDR_QCOM_FALKOR_V1))
  192. cb = qcom_link_stack_sanitization;
  193. install_bp_hardening_cb(entry, cb, smccc_start, smccc_end);
  194. return;
  195. }
  196. #endif /* CONFIG_HARDEN_BRANCH_PREDICTOR */
  197. #ifdef CONFIG_ARM64_SSBD
  198. DEFINE_PER_CPU_READ_MOSTLY(u64, arm64_ssbd_callback_required);
  199. int ssbd_state __read_mostly = ARM64_SSBD_KERNEL;
  200. static const struct ssbd_options {
  201. const char *str;
  202. int state;
  203. } ssbd_options[] = {
  204. { "force-on", ARM64_SSBD_FORCE_ENABLE, },
  205. { "force-off", ARM64_SSBD_FORCE_DISABLE, },
  206. { "kernel", ARM64_SSBD_KERNEL, },
  207. };
  208. static int __init ssbd_cfg(char *buf)
  209. {
  210. int i;
  211. if (!buf || !buf[0])
  212. return -EINVAL;
  213. for (i = 0; i < ARRAY_SIZE(ssbd_options); i++) {
  214. int len = strlen(ssbd_options[i].str);
  215. if (strncmp(buf, ssbd_options[i].str, len))
  216. continue;
  217. ssbd_state = ssbd_options[i].state;
  218. return 0;
  219. }
  220. return -EINVAL;
  221. }
  222. early_param("ssbd", ssbd_cfg);
  223. void __init arm64_update_smccc_conduit(struct alt_instr *alt,
  224. __le32 *origptr, __le32 *updptr,
  225. int nr_inst)
  226. {
  227. u32 insn;
  228. BUG_ON(nr_inst != 1);
  229. switch (psci_ops.conduit) {
  230. case PSCI_CONDUIT_HVC:
  231. insn = aarch64_insn_get_hvc_value();
  232. break;
  233. case PSCI_CONDUIT_SMC:
  234. insn = aarch64_insn_get_smc_value();
  235. break;
  236. default:
  237. return;
  238. }
  239. *updptr = cpu_to_le32(insn);
  240. }
  241. void __init arm64_enable_wa2_handling(struct alt_instr *alt,
  242. __le32 *origptr, __le32 *updptr,
  243. int nr_inst)
  244. {
  245. BUG_ON(nr_inst != 1);
  246. /*
  247. * Only allow mitigation on EL1 entry/exit and guest
  248. * ARCH_WORKAROUND_2 handling if the SSBD state allows it to
  249. * be flipped.
  250. */
  251. if (arm64_get_ssbd_state() == ARM64_SSBD_KERNEL)
  252. *updptr = cpu_to_le32(aarch64_insn_gen_nop());
  253. }
  254. void arm64_set_ssbd_mitigation(bool state)
  255. {
  256. switch (psci_ops.conduit) {
  257. case PSCI_CONDUIT_HVC:
  258. arm_smccc_1_1_hvc(ARM_SMCCC_ARCH_WORKAROUND_2, state, NULL);
  259. break;
  260. case PSCI_CONDUIT_SMC:
  261. arm_smccc_1_1_smc(ARM_SMCCC_ARCH_WORKAROUND_2, state, NULL);
  262. break;
  263. default:
  264. WARN_ON_ONCE(1);
  265. break;
  266. }
  267. }
  268. static bool has_ssbd_mitigation(const struct arm64_cpu_capabilities *entry,
  269. int scope)
  270. {
  271. struct arm_smccc_res res;
  272. bool required = true;
  273. s32 val;
  274. WARN_ON(scope != SCOPE_LOCAL_CPU || preemptible());
  275. if (psci_ops.smccc_version == SMCCC_VERSION_1_0) {
  276. ssbd_state = ARM64_SSBD_UNKNOWN;
  277. return false;
  278. }
  279. switch (psci_ops.conduit) {
  280. case PSCI_CONDUIT_HVC:
  281. arm_smccc_1_1_hvc(ARM_SMCCC_ARCH_FEATURES_FUNC_ID,
  282. ARM_SMCCC_ARCH_WORKAROUND_2, &res);
  283. break;
  284. case PSCI_CONDUIT_SMC:
  285. arm_smccc_1_1_smc(ARM_SMCCC_ARCH_FEATURES_FUNC_ID,
  286. ARM_SMCCC_ARCH_WORKAROUND_2, &res);
  287. break;
  288. default:
  289. ssbd_state = ARM64_SSBD_UNKNOWN;
  290. return false;
  291. }
  292. val = (s32)res.a0;
  293. switch (val) {
  294. case SMCCC_RET_NOT_SUPPORTED:
  295. ssbd_state = ARM64_SSBD_UNKNOWN;
  296. return false;
  297. case SMCCC_RET_NOT_REQUIRED:
  298. pr_info_once("%s mitigation not required\n", entry->desc);
  299. ssbd_state = ARM64_SSBD_MITIGATED;
  300. return false;
  301. case SMCCC_RET_SUCCESS:
  302. required = true;
  303. break;
  304. case 1: /* Mitigation not required on this CPU */
  305. required = false;
  306. break;
  307. default:
  308. WARN_ON(1);
  309. return false;
  310. }
  311. switch (ssbd_state) {
  312. case ARM64_SSBD_FORCE_DISABLE:
  313. pr_info_once("%s disabled from command-line\n", entry->desc);
  314. arm64_set_ssbd_mitigation(false);
  315. required = false;
  316. break;
  317. case ARM64_SSBD_KERNEL:
  318. if (required) {
  319. __this_cpu_write(arm64_ssbd_callback_required, 1);
  320. arm64_set_ssbd_mitigation(true);
  321. }
  322. break;
  323. case ARM64_SSBD_FORCE_ENABLE:
  324. pr_info_once("%s forced from command-line\n", entry->desc);
  325. arm64_set_ssbd_mitigation(true);
  326. required = true;
  327. break;
  328. default:
  329. WARN_ON(1);
  330. break;
  331. }
  332. return required;
  333. }
  334. #endif /* CONFIG_ARM64_SSBD */
  335. #define CAP_MIDR_RANGE(model, v_min, r_min, v_max, r_max) \
  336. .matches = is_affected_midr_range, \
  337. .midr_range = MIDR_RANGE(model, v_min, r_min, v_max, r_max)
  338. #define CAP_MIDR_ALL_VERSIONS(model) \
  339. .matches = is_affected_midr_range, \
  340. .midr_range = MIDR_ALL_VERSIONS(model)
  341. #define MIDR_FIXED(rev, revidr_mask) \
  342. .fixed_revs = (struct arm64_midr_revidr[]){{ (rev), (revidr_mask) }, {}}
  343. #define ERRATA_MIDR_RANGE(model, v_min, r_min, v_max, r_max) \
  344. .type = ARM64_CPUCAP_LOCAL_CPU_ERRATUM, \
  345. CAP_MIDR_RANGE(model, v_min, r_min, v_max, r_max)
  346. #define CAP_MIDR_RANGE_LIST(list) \
  347. .matches = is_affected_midr_range_list, \
  348. .midr_range_list = list
  349. /* Errata affecting a range of revisions of given model variant */
  350. #define ERRATA_MIDR_REV_RANGE(m, var, r_min, r_max) \
  351. ERRATA_MIDR_RANGE(m, var, r_min, var, r_max)
  352. /* Errata affecting a single variant/revision of a model */
  353. #define ERRATA_MIDR_REV(model, var, rev) \
  354. ERRATA_MIDR_RANGE(model, var, rev, var, rev)
  355. /* Errata affecting all variants/revisions of a given a model */
  356. #define ERRATA_MIDR_ALL_VERSIONS(model) \
  357. .type = ARM64_CPUCAP_LOCAL_CPU_ERRATUM, \
  358. CAP_MIDR_ALL_VERSIONS(model)
  359. /* Errata affecting a list of midr ranges, with same work around */
  360. #define ERRATA_MIDR_RANGE_LIST(midr_list) \
  361. .type = ARM64_CPUCAP_LOCAL_CPU_ERRATUM, \
  362. CAP_MIDR_RANGE_LIST(midr_list)
  363. /*
  364. * Generic helper for handling capabilties with multiple (match,enable) pairs
  365. * of call backs, sharing the same capability bit.
  366. * Iterate over each entry to see if at least one matches.
  367. */
  368. static bool __maybe_unused
  369. multi_entry_cap_matches(const struct arm64_cpu_capabilities *entry, int scope)
  370. {
  371. const struct arm64_cpu_capabilities *caps;
  372. for (caps = entry->match_list; caps->matches; caps++)
  373. if (caps->matches(caps, scope))
  374. return true;
  375. return false;
  376. }
  377. /*
  378. * Take appropriate action for all matching entries in the shared capability
  379. * entry.
  380. */
  381. static void __maybe_unused
  382. multi_entry_cap_cpu_enable(const struct arm64_cpu_capabilities *entry)
  383. {
  384. const struct arm64_cpu_capabilities *caps;
  385. for (caps = entry->match_list; caps->matches; caps++)
  386. if (caps->matches(caps, SCOPE_LOCAL_CPU) &&
  387. caps->cpu_enable)
  388. caps->cpu_enable(caps);
  389. }
  390. #ifdef CONFIG_HARDEN_BRANCH_PREDICTOR
  391. /*
  392. * List of CPUs where we need to issue a psci call to
  393. * harden the branch predictor.
  394. */
  395. static const struct midr_range arm64_bp_harden_smccc_cpus[] = {
  396. MIDR_ALL_VERSIONS(MIDR_CORTEX_A57),
  397. MIDR_ALL_VERSIONS(MIDR_CORTEX_A72),
  398. MIDR_ALL_VERSIONS(MIDR_CORTEX_A73),
  399. MIDR_ALL_VERSIONS(MIDR_CORTEX_A75),
  400. MIDR_ALL_VERSIONS(MIDR_BRCM_VULCAN),
  401. MIDR_ALL_VERSIONS(MIDR_CAVIUM_THUNDERX2),
  402. MIDR_ALL_VERSIONS(MIDR_QCOM_FALKOR_V1),
  403. MIDR_ALL_VERSIONS(MIDR_QCOM_FALKOR),
  404. MIDR_ALL_VERSIONS(MIDR_NVIDIA_DENVER),
  405. {},
  406. };
  407. #endif
  408. #ifdef CONFIG_HARDEN_EL2_VECTORS
  409. static const struct midr_range arm64_harden_el2_vectors[] = {
  410. MIDR_ALL_VERSIONS(MIDR_CORTEX_A57),
  411. MIDR_ALL_VERSIONS(MIDR_CORTEX_A72),
  412. {},
  413. };
  414. #endif
  415. const struct arm64_cpu_capabilities arm64_errata[] = {
  416. #if defined(CONFIG_ARM64_ERRATUM_826319) || \
  417. defined(CONFIG_ARM64_ERRATUM_827319) || \
  418. defined(CONFIG_ARM64_ERRATUM_824069)
  419. {
  420. /* Cortex-A53 r0p[012] */
  421. .desc = "ARM errata 826319, 827319, 824069",
  422. .capability = ARM64_WORKAROUND_CLEAN_CACHE,
  423. ERRATA_MIDR_REV_RANGE(MIDR_CORTEX_A53, 0, 0, 2),
  424. .cpu_enable = cpu_enable_cache_maint_trap,
  425. },
  426. #endif
  427. #ifdef CONFIG_ARM64_ERRATUM_819472
  428. {
  429. /* Cortex-A53 r0p[01] */
  430. .desc = "ARM errata 819472",
  431. .capability = ARM64_WORKAROUND_CLEAN_CACHE,
  432. ERRATA_MIDR_REV_RANGE(MIDR_CORTEX_A53, 0, 0, 1),
  433. .cpu_enable = cpu_enable_cache_maint_trap,
  434. },
  435. #endif
  436. #ifdef CONFIG_ARM64_ERRATUM_832075
  437. {
  438. /* Cortex-A57 r0p0 - r1p2 */
  439. .desc = "ARM erratum 832075",
  440. .capability = ARM64_WORKAROUND_DEVICE_LOAD_ACQUIRE,
  441. ERRATA_MIDR_RANGE(MIDR_CORTEX_A57,
  442. 0, 0,
  443. 1, 2),
  444. },
  445. #endif
  446. #ifdef CONFIG_ARM64_ERRATUM_834220
  447. {
  448. /* Cortex-A57 r0p0 - r1p2 */
  449. .desc = "ARM erratum 834220",
  450. .capability = ARM64_WORKAROUND_834220,
  451. ERRATA_MIDR_RANGE(MIDR_CORTEX_A57,
  452. 0, 0,
  453. 1, 2),
  454. },
  455. #endif
  456. #ifdef CONFIG_ARM64_ERRATUM_843419
  457. {
  458. /* Cortex-A53 r0p[01234] */
  459. .desc = "ARM erratum 843419",
  460. .capability = ARM64_WORKAROUND_843419,
  461. ERRATA_MIDR_REV_RANGE(MIDR_CORTEX_A53, 0, 0, 4),
  462. MIDR_FIXED(0x4, BIT(8)),
  463. },
  464. #endif
  465. #ifdef CONFIG_ARM64_ERRATUM_845719
  466. {
  467. /* Cortex-A53 r0p[01234] */
  468. .desc = "ARM erratum 845719",
  469. .capability = ARM64_WORKAROUND_845719,
  470. ERRATA_MIDR_REV_RANGE(MIDR_CORTEX_A53, 0, 0, 4),
  471. },
  472. #endif
  473. #ifdef CONFIG_CAVIUM_ERRATUM_23154
  474. {
  475. /* Cavium ThunderX, pass 1.x */
  476. .desc = "Cavium erratum 23154",
  477. .capability = ARM64_WORKAROUND_CAVIUM_23154,
  478. ERRATA_MIDR_REV_RANGE(MIDR_THUNDERX, 0, 0, 1),
  479. },
  480. #endif
  481. #ifdef CONFIG_CAVIUM_ERRATUM_27456
  482. {
  483. /* Cavium ThunderX, T88 pass 1.x - 2.1 */
  484. .desc = "Cavium erratum 27456",
  485. .capability = ARM64_WORKAROUND_CAVIUM_27456,
  486. ERRATA_MIDR_RANGE(MIDR_THUNDERX,
  487. 0, 0,
  488. 1, 1),
  489. },
  490. {
  491. /* Cavium ThunderX, T81 pass 1.0 */
  492. .desc = "Cavium erratum 27456",
  493. .capability = ARM64_WORKAROUND_CAVIUM_27456,
  494. ERRATA_MIDR_REV(MIDR_THUNDERX_81XX, 0, 0),
  495. },
  496. #endif
  497. #ifdef CONFIG_CAVIUM_ERRATUM_30115
  498. {
  499. /* Cavium ThunderX, T88 pass 1.x - 2.2 */
  500. .desc = "Cavium erratum 30115",
  501. .capability = ARM64_WORKAROUND_CAVIUM_30115,
  502. ERRATA_MIDR_RANGE(MIDR_THUNDERX,
  503. 0, 0,
  504. 1, 2),
  505. },
  506. {
  507. /* Cavium ThunderX, T81 pass 1.0 - 1.2 */
  508. .desc = "Cavium erratum 30115",
  509. .capability = ARM64_WORKAROUND_CAVIUM_30115,
  510. ERRATA_MIDR_REV_RANGE(MIDR_THUNDERX_81XX, 0, 0, 2),
  511. },
  512. {
  513. /* Cavium ThunderX, T83 pass 1.0 */
  514. .desc = "Cavium erratum 30115",
  515. .capability = ARM64_WORKAROUND_CAVIUM_30115,
  516. ERRATA_MIDR_REV(MIDR_THUNDERX_83XX, 0, 0),
  517. },
  518. #endif
  519. {
  520. .desc = "Mismatched cache line size",
  521. .capability = ARM64_MISMATCHED_CACHE_LINE_SIZE,
  522. .matches = has_mismatched_cache_type,
  523. .type = ARM64_CPUCAP_LOCAL_CPU_ERRATUM,
  524. .cpu_enable = cpu_enable_trap_ctr_access,
  525. },
  526. {
  527. .desc = "Mismatched cache type",
  528. .capability = ARM64_MISMATCHED_CACHE_TYPE,
  529. .matches = has_mismatched_cache_type,
  530. .type = ARM64_CPUCAP_LOCAL_CPU_ERRATUM,
  531. .cpu_enable = cpu_enable_trap_ctr_access,
  532. },
  533. #ifdef CONFIG_QCOM_FALKOR_ERRATUM_1003
  534. {
  535. .desc = "Qualcomm Technologies Falkor erratum 1003",
  536. .capability = ARM64_WORKAROUND_QCOM_FALKOR_E1003,
  537. ERRATA_MIDR_REV(MIDR_QCOM_FALKOR_V1, 0, 0),
  538. },
  539. {
  540. .desc = "Qualcomm Technologies Kryo erratum 1003",
  541. .capability = ARM64_WORKAROUND_QCOM_FALKOR_E1003,
  542. .type = ARM64_CPUCAP_LOCAL_CPU_ERRATUM,
  543. .midr_range.model = MIDR_QCOM_KRYO,
  544. .matches = is_kryo_midr,
  545. },
  546. #endif
  547. #ifdef CONFIG_QCOM_FALKOR_ERRATUM_1009
  548. {
  549. .desc = "Qualcomm Technologies Falkor erratum 1009",
  550. .capability = ARM64_WORKAROUND_REPEAT_TLBI,
  551. ERRATA_MIDR_REV(MIDR_QCOM_FALKOR_V1, 0, 0),
  552. },
  553. #endif
  554. #ifdef CONFIG_ARM64_ERRATUM_858921
  555. {
  556. /* Cortex-A73 all versions */
  557. .desc = "ARM erratum 858921",
  558. .capability = ARM64_WORKAROUND_858921,
  559. ERRATA_MIDR_ALL_VERSIONS(MIDR_CORTEX_A73),
  560. },
  561. #endif
  562. #ifdef CONFIG_HARDEN_BRANCH_PREDICTOR
  563. {
  564. .capability = ARM64_HARDEN_BRANCH_PREDICTOR,
  565. .cpu_enable = enable_smccc_arch_workaround_1,
  566. ERRATA_MIDR_RANGE_LIST(arm64_bp_harden_smccc_cpus),
  567. },
  568. #endif
  569. #ifdef CONFIG_HARDEN_EL2_VECTORS
  570. {
  571. .desc = "EL2 vector hardening",
  572. .capability = ARM64_HARDEN_EL2_VECTORS,
  573. ERRATA_MIDR_RANGE_LIST(arm64_harden_el2_vectors),
  574. },
  575. #endif
  576. #ifdef CONFIG_ARM64_SSBD
  577. {
  578. .desc = "Speculative Store Bypass Disable",
  579. .capability = ARM64_SSBD,
  580. .type = ARM64_CPUCAP_LOCAL_CPU_ERRATUM,
  581. .matches = has_ssbd_mitigation,
  582. },
  583. #endif
  584. {
  585. }
  586. };