cpu_errata.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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 CPU_MODEL_MASK (MIDR_IMPLEMENTOR_MASK | MIDR_PARTNUM_MASK | \
  25. MIDR_ARCHITECTURE_MASK)
  26. static bool __maybe_unused
  27. is_affected_midr_range(const struct arm64_cpu_capabilities *entry)
  28. {
  29. u32 midr = read_cpuid_id();
  30. if ((midr & CPU_MODEL_MASK) != entry->midr_model)
  31. return false;
  32. midr &= MIDR_REVISION_MASK | MIDR_VARIANT_MASK;
  33. return (midr >= entry->midr_range_min && midr <= entry->midr_range_max);
  34. }
  35. #define MIDR_RANGE(model, min, max) \
  36. .matches = is_affected_midr_range, \
  37. .midr_model = model, \
  38. .midr_range_min = min, \
  39. .midr_range_max = max
  40. const struct arm64_cpu_capabilities arm64_errata[] = {
  41. #if defined(CONFIG_ARM64_ERRATUM_826319) || \
  42. defined(CONFIG_ARM64_ERRATUM_827319) || \
  43. defined(CONFIG_ARM64_ERRATUM_824069)
  44. {
  45. /* Cortex-A53 r0p[012] */
  46. .desc = "ARM errata 826319, 827319, 824069",
  47. .capability = ARM64_WORKAROUND_CLEAN_CACHE,
  48. MIDR_RANGE(MIDR_CORTEX_A53, 0x00, 0x02),
  49. },
  50. #endif
  51. #ifdef CONFIG_ARM64_ERRATUM_819472
  52. {
  53. /* Cortex-A53 r0p[01] */
  54. .desc = "ARM errata 819472",
  55. .capability = ARM64_WORKAROUND_CLEAN_CACHE,
  56. MIDR_RANGE(MIDR_CORTEX_A53, 0x00, 0x01),
  57. },
  58. #endif
  59. #ifdef CONFIG_ARM64_ERRATUM_832075
  60. {
  61. /* Cortex-A57 r0p0 - r1p2 */
  62. .desc = "ARM erratum 832075",
  63. .capability = ARM64_WORKAROUND_DEVICE_LOAD_ACQUIRE,
  64. MIDR_RANGE(MIDR_CORTEX_A57, 0x00,
  65. (1 << MIDR_VARIANT_SHIFT) | 2),
  66. },
  67. #endif
  68. #ifdef CONFIG_ARM64_ERRATUM_845719
  69. {
  70. /* Cortex-A53 r0p[01234] */
  71. .desc = "ARM erratum 845719",
  72. .capability = ARM64_WORKAROUND_845719,
  73. MIDR_RANGE(MIDR_CORTEX_A53, 0x00, 0x04),
  74. },
  75. #endif
  76. {
  77. }
  78. };
  79. void check_local_cpu_errata(void)
  80. {
  81. check_cpu_capabilities(arm64_errata, "enabling workaround for");
  82. }