cpu_errata.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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/types.h>
  19. #include <asm/cpu.h>
  20. #include <asm/cputype.h>
  21. #include <asm/cpufeature.h>
  22. #define MIDR_CORTEX_A53 MIDR_CPU_PART(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A53)
  23. #define MIDR_CORTEX_A57 MIDR_CPU_PART(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A57)
  24. #define MIDR_THUNDERX MIDR_CPU_PART(ARM_CPU_IMP_CAVIUM, CAVIUM_CPU_PART_THUNDERX)
  25. #define CPU_MODEL_MASK (MIDR_IMPLEMENTOR_MASK | MIDR_PARTNUM_MASK | \
  26. MIDR_ARCHITECTURE_MASK)
  27. static bool __maybe_unused
  28. is_affected_midr_range(const struct arm64_cpu_capabilities *entry)
  29. {
  30. u32 midr = read_cpuid_id();
  31. if ((midr & CPU_MODEL_MASK) != entry->midr_model)
  32. return false;
  33. midr &= MIDR_REVISION_MASK | MIDR_VARIANT_MASK;
  34. return (midr >= entry->midr_range_min && midr <= entry->midr_range_max);
  35. }
  36. #define MIDR_RANGE(model, min, max) \
  37. .matches = is_affected_midr_range, \
  38. .midr_model = model, \
  39. .midr_range_min = min, \
  40. .midr_range_max = max
  41. const struct arm64_cpu_capabilities arm64_errata[] = {
  42. #if defined(CONFIG_ARM64_ERRATUM_826319) || \
  43. defined(CONFIG_ARM64_ERRATUM_827319) || \
  44. defined(CONFIG_ARM64_ERRATUM_824069)
  45. {
  46. /* Cortex-A53 r0p[012] */
  47. .desc = "ARM errata 826319, 827319, 824069",
  48. .capability = ARM64_WORKAROUND_CLEAN_CACHE,
  49. MIDR_RANGE(MIDR_CORTEX_A53, 0x00, 0x02),
  50. },
  51. #endif
  52. #ifdef CONFIG_ARM64_ERRATUM_819472
  53. {
  54. /* Cortex-A53 r0p[01] */
  55. .desc = "ARM errata 819472",
  56. .capability = ARM64_WORKAROUND_CLEAN_CACHE,
  57. MIDR_RANGE(MIDR_CORTEX_A53, 0x00, 0x01),
  58. },
  59. #endif
  60. #ifdef CONFIG_ARM64_ERRATUM_832075
  61. {
  62. /* Cortex-A57 r0p0 - r1p2 */
  63. .desc = "ARM erratum 832075",
  64. .capability = ARM64_WORKAROUND_DEVICE_LOAD_ACQUIRE,
  65. MIDR_RANGE(MIDR_CORTEX_A57, 0x00,
  66. (1 << MIDR_VARIANT_SHIFT) | 2),
  67. },
  68. #endif
  69. #ifdef CONFIG_ARM64_ERRATUM_834220
  70. {
  71. /* Cortex-A57 r0p0 - r1p2 */
  72. .desc = "ARM erratum 834220",
  73. .capability = ARM64_WORKAROUND_834220,
  74. MIDR_RANGE(MIDR_CORTEX_A57, 0x00,
  75. (1 << MIDR_VARIANT_SHIFT) | 2),
  76. },
  77. #endif
  78. #ifdef CONFIG_ARM64_ERRATUM_845719
  79. {
  80. /* Cortex-A53 r0p[01234] */
  81. .desc = "ARM erratum 845719",
  82. .capability = ARM64_WORKAROUND_845719,
  83. MIDR_RANGE(MIDR_CORTEX_A53, 0x00, 0x04),
  84. },
  85. #endif
  86. #ifdef CONFIG_CAVIUM_ERRATUM_23154
  87. {
  88. /* Cavium ThunderX, pass 1.x */
  89. .desc = "Cavium erratum 23154",
  90. .capability = ARM64_WORKAROUND_CAVIUM_23154,
  91. MIDR_RANGE(MIDR_THUNDERX, 0x00, 0x01),
  92. },
  93. #endif
  94. #ifdef CONFIG_CAVIUM_ERRATUM_27456
  95. {
  96. /* Cavium ThunderX, T88 pass 1.x - 2.1 */
  97. .desc = "Cavium erratum 27456",
  98. .capability = ARM64_WORKAROUND_CAVIUM_27456,
  99. MIDR_RANGE(MIDR_THUNDERX, 0x00,
  100. (1 << MIDR_VARIANT_SHIFT) | 1),
  101. },
  102. #endif
  103. {
  104. }
  105. };
  106. void check_local_cpu_errata(void)
  107. {
  108. update_cpu_capabilities(arm64_errata, "enabling workaround for");
  109. }