errata.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*
  2. * Copyright (c) 2017-2024, Arm Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #ifndef ERRATA_REPORT_H
  7. #define ERRATA_REPORT_H
  8. #include <lib/cpus/cpu_ops.h>
  9. #define ERRATUM_WA_FUNC_SIZE CPU_WORD_SIZE
  10. #define ERRATUM_CHECK_FUNC_SIZE CPU_WORD_SIZE
  11. #define ERRATUM_ID_SIZE 4
  12. #define ERRATUM_CVE_SIZE 2
  13. #define ERRATUM_CHOSEN_SIZE 1
  14. #define ERRATUM_MITIGATED_SIZE 1
  15. #define ERRATUM_WA_FUNC 0
  16. #define ERRATUM_CHECK_FUNC ERRATUM_WA_FUNC + ERRATUM_WA_FUNC_SIZE
  17. #define ERRATUM_ID ERRATUM_CHECK_FUNC + ERRATUM_CHECK_FUNC_SIZE
  18. #define ERRATUM_CVE ERRATUM_ID + ERRATUM_ID_SIZE
  19. #define ERRATUM_CHOSEN ERRATUM_CVE + ERRATUM_CVE_SIZE
  20. #define ERRATUM_MITIGATED ERRATUM_CHOSEN + ERRATUM_CHOSEN_SIZE
  21. #define ERRATUM_ENTRY_SIZE ERRATUM_MITIGATED + ERRATUM_MITIGATED_SIZE
  22. /* Errata status */
  23. #define ERRATA_NOT_APPLIES 0
  24. #define ERRATA_APPLIES 1
  25. #define ERRATA_MISSING 2
  26. #ifndef __ASSEMBLER__
  27. #include <lib/cassert.h>
  28. void print_errata_status(void);
  29. #if ERRATA_A75_764081
  30. bool errata_a75_764081_applies(void);
  31. #else
  32. static inline bool errata_a75_764081_applies(void)
  33. {
  34. return false;
  35. }
  36. #endif
  37. #if ERRATA_A520_2938996 || ERRATA_X4_2726228
  38. unsigned int check_if_affected_core(void);
  39. #endif
  40. /*
  41. * NOTE that this structure will be different on AArch32 and AArch64. The
  42. * uintptr_t will reflect the change and the alignment will be correct in both.
  43. */
  44. struct erratum_entry {
  45. uintptr_t (*wa_func)(uint64_t cpu_rev);
  46. uintptr_t (*check_func)(uint64_t cpu_rev);
  47. /* Will fit CVEs with up to 10 character in the ID field */
  48. uint32_t id;
  49. /* Denote CVEs with their year or errata with 0 */
  50. uint16_t cve;
  51. uint8_t chosen;
  52. /* TODO(errata ABI): placeholder for the mitigated field */
  53. uint8_t _mitigated;
  54. } __packed;
  55. CASSERT(sizeof(struct erratum_entry) == ERRATUM_ENTRY_SIZE,
  56. assert_erratum_entry_asm_c_different_sizes);
  57. #else
  58. /*
  59. * errata framework macro helpers
  60. *
  61. * NOTE an erratum and CVE id could clash. However, both numbers are very large
  62. * and the probablity is minuscule. Working around this makes code very
  63. * complicated and extremely difficult to read so it is not considered. In the
  64. * unlikely event that this does happen, prepending the CVE id with a 0 should
  65. * resolve the conflict
  66. */
  67. #define ERRATUM(id) 0, id
  68. #define CVE(year, id) year, id
  69. #define NO_ISB 1
  70. #define NO_ASSERT 0
  71. #define NO_APPLY_AT_RESET 0
  72. #define APPLY_AT_RESET 1
  73. #define GET_CPU_REV 1
  74. #define NO_GET_CPU_REV 0
  75. /* useful for errata that end up always being worked around */
  76. #define ERRATUM_ALWAYS_CHOSEN 1
  77. #endif /* __ASSEMBLER__ */
  78. /* Macro to get CPU revision code for checking errata version compatibility. */
  79. #define CPU_REV(r, p) ((r << 4) | p)
  80. #endif /* ERRATA_REPORT_H */