neoverse_v2.S 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /*
  2. * Copyright (c) 2021-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 <neoverse_v2.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 "Neoverse V2 must be compiled with HW_ASSISTED_COHERENCY enabled"
  16. #endif
  17. /* 64-bit only core */
  18. #if CTX_INCLUDE_AARCH32_REGS == 1
  19. #error "Neoverse V2 supports only AArch64. Compile with CTX_INCLUDE_AARCH32_REGS=0"
  20. #endif
  21. /* Disable hardware page aggregation. Enables mitigation for `CVE-2024-5660` */
  22. workaround_reset_start neoverse_v2, CVE(2024, 5660), WORKAROUND_CVE_2024_5660
  23. sysreg_bit_set NEOVERSE_V2_CPUECTLR_EL1, BIT(46)
  24. workaround_reset_end neoverse_v2, CVE(2024, 5660)
  25. check_erratum_ls neoverse_v2, CVE(2024, 5660), CPU_REV(0, 2)
  26. workaround_reset_start neoverse_v2, ERRATUM(2331132), ERRATA_V2_2331132
  27. sysreg_bitfield_insert NEOVERSE_V2_CPUECTLR2_EL1, NEOVERSE_V2_CPUECTLR2_EL1_PF_MODE_CNSRV, \
  28. NEOVERSE_V2_CPUECTLR2_EL1_PF_MODE_LSB, NEOVERSE_V2_CPUECTLR2_EL1_PF_MODE_WIDTH
  29. workaround_reset_end neoverse_v2, ERRATUM(2331132)
  30. check_erratum_ls neoverse_v2, ERRATUM(2331132), CPU_REV(0, 2)
  31. workaround_reset_start neoverse_v2, ERRATUM(2618597), ERRATA_V2_2618597
  32. /* Disable retention control for WFI and WFE. */
  33. mrs x0, NEOVERSE_V2_CPUPWRCTLR_EL1
  34. bfi x0, xzr, #NEOVERSE_V2_CPUPWRCTLR_EL1_WFI_RET_CTRL_SHIFT, \
  35. #NEOVERSE_V2_CPUPWRCTLR_EL1_WFI_RET_CTRL_WIDTH
  36. bfi x0, xzr, #NEOVERSE_V2_CPUPWRCTLR_EL1_WFE_RET_CTRL_SHIFT, \
  37. #NEOVERSE_V2_CPUPWRCTLR_EL1_WFE_RET_CTRL_WIDTH
  38. msr NEOVERSE_V2_CPUPWRCTLR_EL1, x0
  39. workaround_reset_end neoverse_v2, ERRATUM(2618597)
  40. check_erratum_ls neoverse_v2, ERRATUM(2618597), CPU_REV(0, 1)
  41. workaround_reset_start neoverse_v2, ERRATUM(2662553), ERRATA_V2_2662553
  42. sysreg_bitfield_insert NEOVERSE_V2_CPUECTLR2_EL1, NEOVERSE_V2_CPUECTLR2_EL1_TXREQ_STATIC_FULL, \
  43. NEOVERSE_V2_CPUECTLR2_EL1_TXREQ_LSB, NEOVERSE_V2_CPUECTLR2_EL1_TXREQ_WIDTH
  44. workaround_reset_end neoverse_v2, ERRATUM(2662553)
  45. check_erratum_ls neoverse_v2, ERRATUM(2662553), CPU_REV(0, 1)
  46. workaround_reset_start neoverse_v2, ERRATUM(2719105), ERRATA_V2_2719105
  47. sysreg_bit_set NEOVERSE_V2_CPUACTLR2_EL1, NEOVERSE_V2_CPUACTLR2_EL1_BIT_0
  48. workaround_reset_end neoverse_v2, ERRATUM(2719105)
  49. check_erratum_ls neoverse_v2, ERRATUM(2719105), CPU_REV(0, 1)
  50. workaround_reset_start neoverse_v2, ERRATUM(2743011), ERRATA_V2_2743011
  51. sysreg_bit_set NEOVERSE_V2_CPUACTLR5_EL1, NEOVERSE_V2_CPUACTLR5_EL1_BIT_55
  52. sysreg_bit_clear NEOVERSE_V2_CPUACTLR5_EL1, NEOVERSE_V2_CPUACTLR5_EL1_BIT_56
  53. workaround_reset_end neoverse_v2, ERRATUM(2743011)
  54. check_erratum_ls neoverse_v2, ERRATUM(2743011), CPU_REV(0, 1)
  55. workaround_reset_start neoverse_v2, ERRATUM(2779510), ERRATA_V2_2779510
  56. sysreg_bit_set NEOVERSE_V2_CPUACTLR3_EL1, NEOVERSE_V2_CPUACTLR3_EL1_BIT_47
  57. workaround_reset_end neoverse_v2, ERRATUM(2779510)
  58. check_erratum_ls neoverse_v2, ERRATUM(2779510), CPU_REV(0, 1)
  59. workaround_runtime_start neoverse_v2, ERRATUM(2801372), ERRATA_V2_2801372
  60. /* dsb before isb of power down sequence */
  61. dsb sy
  62. workaround_runtime_end neoverse_v2, ERRATUM(2801372), ERRATA_V2_2801372
  63. check_erratum_ls neoverse_v2, ERRATUM(2801372), CPU_REV(0, 1)
  64. workaround_reset_start neoverse_v2, CVE(2022,23960), WORKAROUND_CVE_2022_23960
  65. #if IMAGE_BL31
  66. /*
  67. * The Neoverse-V2 generic vectors are overridden to apply errata
  68. * mitigation on exception entry from lower ELs.
  69. */
  70. override_vector_table wa_cve_vbar_neoverse_v2
  71. #endif /* IMAGE_BL31 */
  72. workaround_reset_end neoverse_v2, CVE(2022,23960)
  73. check_erratum_chosen neoverse_v2, CVE(2022, 23960), WORKAROUND_CVE_2022_23960
  74. #if WORKAROUND_CVE_2022_23960
  75. wa_cve_2022_23960_bhb_vector_table NEOVERSE_V2_BHB_LOOP_COUNT, neoverse_v2
  76. #endif /* WORKAROUND_CVE_2022_23960 */
  77. /* ----------------------------------------------------
  78. * HW will do the cache maintenance while powering down
  79. * ----------------------------------------------------
  80. */
  81. func neoverse_v2_core_pwr_dwn
  82. /* ---------------------------------------------------
  83. * Enable CPU power down bit in power control register
  84. * ---------------------------------------------------
  85. */
  86. sysreg_bit_set NEOVERSE_V2_CPUPWRCTLR_EL1, NEOVERSE_V2_CPUPWRCTLR_EL1_CORE_PWRDN_BIT
  87. apply_erratum neoverse_v2, ERRATUM(2801372), ERRATA_V2_2801372, NO_GET_CPU_REV
  88. isb
  89. ret
  90. endfunc neoverse_v2_core_pwr_dwn
  91. cpu_reset_func_start neoverse_v2
  92. /* Disable speculative loads */
  93. msr SSBS, xzr
  94. #if NEOVERSE_Vx_EXTERNAL_LLC
  95. /* Some systems may have External LLC, core needs to be made aware */
  96. sysreg_bit_set NEOVERSE_V2_CPUECTLR_EL1, NEOVERSE_V2_CPUECTLR_EL1_EXTLLC_BIT
  97. #endif
  98. cpu_reset_func_end neoverse_v2
  99. /* ---------------------------------------------
  100. * This function provides Neoverse V2-
  101. * specific register information for crash
  102. * reporting. It needs to return with x6
  103. * pointing to a list of register names in ascii
  104. * and x8 - x15 having values of registers to be
  105. * reported.
  106. * ---------------------------------------------
  107. */
  108. .section .rodata.neoverse_v2_regs, "aS"
  109. neoverse_v2_regs: /* The ascii list of register names to be reported */
  110. .asciz "cpuectlr_el1", ""
  111. func neoverse_v2_cpu_reg_dump
  112. adr x6, neoverse_v2_regs
  113. mrs x8, NEOVERSE_V2_CPUECTLR_EL1
  114. ret
  115. endfunc neoverse_v2_cpu_reg_dump
  116. declare_cpu_ops neoverse_v2, NEOVERSE_V2_MIDR, \
  117. neoverse_v2_reset_func, \
  118. neoverse_v2_core_pwr_dwn