cortex_x4.S 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. /*
  2. * Copyright (c) 2022-2024, Arm Limited. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <arch.h>
  7. #include <asm_macros.S>
  8. #include <common/bl_common.h>
  9. #include <cortex_x4.h>
  10. #include <cpu_macros.S>
  11. #include <plat_macros.S>
  12. #include "wa_cve_2022_23960_bhb_vector.S"
  13. /* Hardware handled coherency */
  14. #if HW_ASSISTED_COHERENCY == 0
  15. #error "Cortex X4 must be compiled with HW_ASSISTED_COHERENCY enabled"
  16. #endif
  17. /* 64-bit only core */
  18. #if CTX_INCLUDE_AARCH32_REGS == 1
  19. #error "Cortex X4 supports only AArch64. Compile with CTX_INCLUDE_AARCH32_REGS=0"
  20. #endif
  21. .global check_erratum_cortex_x4_2726228
  22. #if WORKAROUND_CVE_2022_23960
  23. wa_cve_2022_23960_bhb_vector_table CORTEX_X4_BHB_LOOP_COUNT, cortex_x4
  24. #endif /* WORKAROUND_CVE_2022_23960 */
  25. workaround_runtime_start cortex_x4, ERRATUM(2726228), ERRATA_X4_2726228, CORTEX_X4_MIDR
  26. workaround_runtime_end cortex_x4, ERRATUM(2726228)
  27. check_erratum_custom_start cortex_x4, ERRATUM(2726228)
  28. /* This erratum needs to be enabled for r0p0 and r0p1.
  29. * Check if revision is less than or equal to r0p1.
  30. */
  31. #if ERRATA_X4_2726228
  32. mov x1, #1
  33. b cpu_rev_var_ls
  34. #else
  35. mov x0, #ERRATA_MISSING
  36. #endif
  37. ret
  38. check_erratum_custom_end cortex_x4, ERRATUM(2726228)
  39. /* Disable hardware page aggregation. Enables mitigation for `CVE-2024-5660` */
  40. workaround_reset_start cortex_x4, CVE(2024, 5660), WORKAROUND_CVE_2024_5660
  41. sysreg_bit_set CORTEX_X4_CPUECTLR_EL1, BIT(46)
  42. workaround_reset_end cortex_x4, CVE(2024, 5660)
  43. check_erratum_ls cortex_x4, CVE(2024, 5660), CPU_REV(0, 2)
  44. workaround_runtime_start cortex_x4, ERRATUM(2740089), ERRATA_X4_2740089
  45. /* dsb before isb of power down sequence */
  46. dsb sy
  47. workaround_runtime_end cortex_x4, ERRATUM(2740089)
  48. check_erratum_ls cortex_x4, ERRATUM(2740089), CPU_REV(0, 1)
  49. workaround_reset_start cortex_x4, ERRATUM(2763018), ERRATA_X4_2763018
  50. sysreg_bit_set CORTEX_X4_CPUACTLR3_EL1, BIT(47)
  51. workaround_reset_end cortex_x4, ERRATUM(2763018)
  52. check_erratum_ls cortex_x4, ERRATUM(2763018), CPU_REV(0, 1)
  53. workaround_reset_start cortex_x4, ERRATUM(2816013), ERRATA_X4_2816013
  54. mrs x1, id_aa64pfr1_el1
  55. ubfx x2, x1, ID_AA64PFR1_EL1_MTE_SHIFT, #4
  56. cbz x2, #1f
  57. sysreg_bit_set CORTEX_X4_CPUACTLR5_EL1, BIT(14)
  58. 1:
  59. workaround_reset_end cortex_x4, ERRATUM(2816013)
  60. check_erratum_ls cortex_x4, ERRATUM(2816013), CPU_REV(0, 1)
  61. workaround_reset_start cortex_x4, ERRATUM(2897503), ERRATA_X4_2897503
  62. sysreg_bit_set CORTEX_X4_CPUACTLR4_EL1, BIT(8)
  63. workaround_reset_end cortex_x4, ERRATUM(2897503)
  64. check_erratum_ls cortex_x4, ERRATUM(2897503), CPU_REV(0, 1)
  65. workaround_reset_start cortex_x4, ERRATUM(2923985), ERRATA_X4_2923985
  66. sysreg_bit_set CORTEX_X4_CPUACTLR4_EL1, (BIT(11) | BIT(10))
  67. workaround_reset_end cortex_x4, ERRATUM(2923985)
  68. check_erratum_ls cortex_x4, ERRATUM(2923985), CPU_REV(0, 1)
  69. workaround_reset_start cortex_x4, ERRATUM(3076789), ERRATA_X4_3076789
  70. sysreg_bit_set CORTEX_X4_CPUACTLR3_EL1, BIT(14)
  71. sysreg_bit_set CORTEX_X4_CPUACTLR3_EL1, BIT(13)
  72. sysreg_bit_set CORTEX_X4_CPUACTLR_EL1, BIT(52)
  73. workaround_reset_end cortex_x4, ERRATUM(3076789)
  74. check_erratum_ls cortex_x4, ERRATUM(3076789), CPU_REV(0, 1)
  75. workaround_reset_start cortex_x4, CVE(2022, 23960), WORKAROUND_CVE_2022_23960
  76. #if IMAGE_BL31
  77. /*
  78. * The Cortex X4 generic vectors are overridden to apply errata
  79. * mitigation on exception entry from lower ELs.
  80. */
  81. override_vector_table wa_cve_vbar_cortex_x4
  82. #endif /* IMAGE_BL31 */
  83. workaround_reset_end cortex_x4, CVE(2022, 23960)
  84. check_erratum_chosen cortex_x4, CVE(2022, 23960), WORKAROUND_CVE_2022_23960
  85. cpu_reset_func_start cortex_x4
  86. /* Disable speculative loads */
  87. msr SSBS, xzr
  88. cpu_reset_func_end cortex_x4
  89. /* ----------------------------------------------------
  90. * HW will do the cache maintenance while powering down
  91. * ----------------------------------------------------
  92. */
  93. func cortex_x4_core_pwr_dwn
  94. /* ---------------------------------------------------
  95. * Enable CPU power down bit in power control register
  96. * ---------------------------------------------------
  97. */
  98. sysreg_bit_set CORTEX_X4_CPUPWRCTLR_EL1, CORTEX_X4_CPUPWRCTLR_EL1_CORE_PWRDN_BIT
  99. apply_erratum cortex_x4, ERRATUM(2740089), ERRATA_X4_2740089, NO_GET_CPU_REV
  100. isb
  101. ret
  102. endfunc cortex_x4_core_pwr_dwn
  103. /* ---------------------------------------------
  104. * This function provides Cortex X4-specific
  105. * register information for crash reporting.
  106. * It needs to return with x6 pointing to
  107. * a list of register names in ascii and
  108. * x8 - x15 having values of registers to be
  109. * reported.
  110. * ---------------------------------------------
  111. */
  112. .section .rodata.cortex_x4_regs, "aS"
  113. cortex_x4_regs: /* The ascii list of register names to be reported */
  114. .asciz "cpuectlr_el1", ""
  115. func cortex_x4_cpu_reg_dump
  116. adr x6, cortex_x4_regs
  117. mrs x8, CORTEX_X4_CPUECTLR_EL1
  118. ret
  119. endfunc cortex_x4_cpu_reg_dump
  120. declare_cpu_ops cortex_x4, CORTEX_X4_MIDR, \
  121. cortex_x4_reset_func, \
  122. cortex_x4_core_pwr_dwn