neoverse_v1.S 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  1. /*
  2. * Copyright (c) 2019-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_v1.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 V1 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-V1 supports only AArch64. Compile with CTX_INCLUDE_AARCH32_REGS=0"
  20. #endif
  21. #if WORKAROUND_CVE_2022_23960
  22. wa_cve_2022_23960_bhb_vector_table NEOVERSE_V1_BHB_LOOP_COUNT, neoverse_v1
  23. #endif /* WORKAROUND_CVE_2022_23960 */
  24. /* Disable hardware page aggregation. Enables mitigation for `CVE-2024-5660` */
  25. workaround_reset_start neoverse_v1, CVE(2024, 5660), WORKAROUND_CVE_2024_5660
  26. sysreg_bit_set NEOVERSE_V1_CPUECTLR_EL1, BIT(46)
  27. workaround_reset_end neoverse_v1, CVE(2024, 5660)
  28. check_erratum_ls neoverse_v1, CVE(2024, 5660), CPU_REV(1, 2)
  29. workaround_reset_start neoverse_v1, ERRATUM(1618635), ERRATA_V1_1618635
  30. /* Inserts a DMB SY before and after MRS PAR_EL1 */
  31. ldr x0, =0x0
  32. msr NEOVERSE_V1_CPUPSELR_EL3, x0
  33. ldr x0, = 0xEE070F14
  34. msr NEOVERSE_V1_CPUPOR_EL3, x0
  35. ldr x0, = 0xFFFF0FFF
  36. msr NEOVERSE_V1_CPUPMR_EL3, x0
  37. ldr x0, =0x4005027FF
  38. msr NEOVERSE_V1_CPUPCR_EL3, x0
  39. /* Inserts a DMB SY before STREX imm offset */
  40. ldr x0, =0x1
  41. msr NEOVERSE_V1_CPUPSELR_EL3, x0
  42. ldr x0, =0x00e8400000
  43. msr NEOVERSE_V1_CPUPOR_EL3, x0
  44. ldr x0, =0x00fff00000
  45. msr NEOVERSE_V1_CPUPMR_EL3, x0
  46. ldr x0, = 0x4001027FF
  47. msr NEOVERSE_V1_CPUPCR_EL3, x0
  48. /* Inserts a DMB SY before STREX[BHD}/STLEX* */
  49. ldr x0, =0x2
  50. msr NEOVERSE_V1_CPUPSELR_EL3, x0
  51. ldr x0, =0x00e8c00040
  52. msr NEOVERSE_V1_CPUPOR_EL3, x0
  53. ldr x0, =0x00fff00040
  54. msr NEOVERSE_V1_CPUPMR_EL3, x0
  55. ldr x0, = 0x4001027FF
  56. msr NEOVERSE_V1_CPUPCR_EL3, x0
  57. /* Inserts a DMB SY after STREX imm offset */
  58. ldr x0, =0x3
  59. msr NEOVERSE_V1_CPUPSELR_EL3, x0
  60. ldr x0, =0x00e8400000
  61. msr NEOVERSE_V1_CPUPOR_EL3, x0
  62. ldr x0, =0x00fff00000
  63. msr NEOVERSE_V1_CPUPMR_EL3, x0
  64. ldr x0, = 0x4004027FF
  65. msr NEOVERSE_V1_CPUPCR_EL3, x0
  66. /* Inserts a DMB SY after STREX[BHD}/STLEX* */
  67. ldr x0, =0x4
  68. msr NEOVERSE_V1_CPUPSELR_EL3, x0
  69. ldr x0, =0x00e8c00040
  70. msr NEOVERSE_V1_CPUPOR_EL3, x0
  71. ldr x0, =0x00fff00040
  72. msr NEOVERSE_V1_CPUPMR_EL3, x0
  73. ldr x0, = 0x4004027FF
  74. msr NEOVERSE_V1_CPUPCR_EL3, x0
  75. workaround_reset_end neoverse_v1, ERRATUM(1618635)
  76. check_erratum_ls neoverse_v1, ERRATUM(1618635), CPU_REV(0, 0)
  77. workaround_reset_start neoverse_v1, ERRATUM(1774420), ERRATA_V1_1774420
  78. /* Set bit 53 in CPUECTLR_EL1 */
  79. sysreg_bit_set NEOVERSE_V1_CPUECTLR_EL1, NEOVERSE_V1_CPUECTLR_EL1_BIT_53
  80. workaround_reset_end neoverse_v1, ERRATUM(1774420)
  81. check_erratum_ls neoverse_v1, ERRATUM(1774420), CPU_REV(1, 0)
  82. workaround_reset_start neoverse_v1, ERRATUM(1791573), ERRATA_V1_1791573
  83. /* Set bit 2 in ACTLR2_EL1 */
  84. sysreg_bit_set NEOVERSE_V1_ACTLR2_EL1, NEOVERSE_V1_ACTLR2_EL1_BIT_2
  85. workaround_reset_end neoverse_v1, ERRATUM(1791573)
  86. check_erratum_ls neoverse_v1, ERRATUM(1791573), CPU_REV(1, 0)
  87. workaround_reset_start neoverse_v1, ERRATUM(1852267), ERRATA_V1_1852267
  88. /* Set bit 28 in ACTLR2_EL1 */
  89. sysreg_bit_set NEOVERSE_V1_ACTLR2_EL1, NEOVERSE_V1_ACTLR2_EL1_BIT_28
  90. workaround_reset_end neoverse_v1, ERRATUM(1852267)
  91. check_erratum_ls neoverse_v1, ERRATUM(1852267), CPU_REV(1, 0)
  92. workaround_reset_start neoverse_v1, ERRATUM(1925756), ERRATA_V1_1925756
  93. /* Set bit 8 in CPUECTLR_EL1 */
  94. sysreg_bit_set NEOVERSE_V1_CPUECTLR_EL1, NEOVERSE_V1_CPUECTLR_EL1_BIT_8
  95. workaround_reset_end neoverse_v1, ERRATUM(1925756)
  96. check_erratum_ls neoverse_v1, ERRATUM(1925756), CPU_REV(1, 1)
  97. workaround_reset_start neoverse_v1, ERRATUM(1940577), ERRATA_V1_1940577
  98. mov x0, #0
  99. msr S3_6_C15_C8_0, x0
  100. ldr x0, =0x10E3900002
  101. msr S3_6_C15_C8_2, x0
  102. ldr x0, =0x10FFF00083
  103. msr S3_6_C15_C8_3, x0
  104. ldr x0, =0x2001003FF
  105. msr S3_6_C15_C8_1, x0
  106. mov x0, #1
  107. msr S3_6_C15_C8_0, x0
  108. ldr x0, =0x10E3800082
  109. msr S3_6_C15_C8_2, x0
  110. ldr x0, =0x10FFF00083
  111. msr S3_6_C15_C8_3, x0
  112. ldr x0, =0x2001003FF
  113. msr S3_6_C15_C8_1, x0
  114. mov x0, #2
  115. msr S3_6_C15_C8_0, x0
  116. ldr x0, =0x10E3800200
  117. msr S3_6_C15_C8_2, x0
  118. ldr x0, =0x10FFF003E0
  119. msr S3_6_C15_C8_3, x0
  120. ldr x0, =0x2001003FF
  121. msr S3_6_C15_C8_1, x0
  122. workaround_reset_end neoverse_v1, ERRATUM(1940577)
  123. check_erratum_range neoverse_v1, ERRATUM(1940577), CPU_REV(1, 0), CPU_REV(1, 1)
  124. workaround_reset_start neoverse_v1, ERRATUM(1966096), ERRATA_V1_1966096
  125. mov x0, #0x3
  126. msr S3_6_C15_C8_0, x0
  127. ldr x0, =0xEE010F12
  128. msr S3_6_C15_C8_2, x0
  129. ldr x0, =0xFFFF0FFF
  130. msr S3_6_C15_C8_3, x0
  131. ldr x0, =0x80000000003FF
  132. msr S3_6_C15_C8_1, x0
  133. workaround_reset_end neoverse_v1, ERRATUM(1966096)
  134. check_erratum_range neoverse_v1, ERRATUM(1966096), CPU_REV(1, 0), CPU_REV(1, 1)
  135. workaround_reset_start neoverse_v1, ERRATUM(2108267), ERRATA_V1_2108267
  136. mrs x1, NEOVERSE_V1_CPUECTLR_EL1
  137. mov x0, #NEOVERSE_V1_CPUECTLR_EL1_PF_MODE_CNSRV
  138. bfi x1, x0, #CPUECTLR_EL1_PF_MODE_LSB, #CPUECTLR_EL1_PF_MODE_WIDTH
  139. msr NEOVERSE_V1_CPUECTLR_EL1, x1
  140. workaround_reset_end neoverse_v1, ERRATUM(2108267)
  141. check_erratum_ls neoverse_v1, ERRATUM(2108267), CPU_REV(1, 2)
  142. workaround_reset_start neoverse_v1, ERRATUM(2139242), ERRATA_V1_2139242
  143. mov x0, #0x3
  144. msr S3_6_C15_C8_0, x0
  145. ldr x0, =0xEE720F14
  146. msr S3_6_C15_C8_2, x0
  147. ldr x0, =0xFFFF0FDF
  148. msr S3_6_C15_C8_3, x0
  149. ldr x0, =0x40000005003FF
  150. msr S3_6_C15_C8_1, x0
  151. workaround_reset_end neoverse_v1, ERRATUM(2139242)
  152. check_erratum_ls neoverse_v1, ERRATUM(2139242), CPU_REV(1, 1)
  153. workaround_reset_start neoverse_v1, ERRATUM(2216392), ERRATA_V1_2216392
  154. ldr x0, =0x5
  155. msr S3_6_c15_c8_0, x0 /* CPUPSELR_EL3 */
  156. ldr x0, =0x10F600E000
  157. msr S3_6_c15_c8_2, x0 /* CPUPOR_EL3 */
  158. ldr x0, =0x10FF80E000
  159. msr S3_6_c15_c8_3, x0 /* CPUPMR_EL3 */
  160. ldr x0, =0x80000000003FF
  161. msr S3_6_c15_c8_1, x0 /* CPUPCR_EL3 */
  162. workaround_reset_end neoverse_v1, ERRATUM(2216392)
  163. check_erratum_range neoverse_v1, ERRATUM(2216392), CPU_REV(1, 0), CPU_REV(1, 1)
  164. workaround_reset_start neoverse_v1, ERRATUM(2294912), ERRATA_V1_2294912
  165. /* Set bit 0 in ACTLR2_EL1 */
  166. sysreg_bit_set NEOVERSE_V1_ACTLR2_EL1, NEOVERSE_V1_ACTLR2_EL1_BIT_0
  167. workaround_reset_end neoverse_v1, ERRATUM(2294912)
  168. check_erratum_ls neoverse_v1, ERRATUM(2294912), CPU_REV(1, 2)
  169. workaround_runtime_start neoverse_v1, ERRATUM(2348377), ERRATA_V1_2348377
  170. /* Set bit 61 in CPUACTLR5_EL1 */
  171. sysreg_bit_set NEOVERSE_V1_ACTLR5_EL1, NEOVERSE_V1_ACTLR5_EL1_BIT_61
  172. workaround_runtime_end neoverse_v1, ERRATUM(2348377)
  173. check_erratum_ls neoverse_v1, ERRATUM(2348377), CPU_REV(1, 1)
  174. workaround_reset_start neoverse_v1, ERRATUM(2372203), ERRATA_V1_2372203
  175. /* Set bit 40 in ACTLR2_EL1 */
  176. sysreg_bit_set NEOVERSE_V1_ACTLR2_EL1, NEOVERSE_V1_ACTLR2_EL1_BIT_40
  177. workaround_reset_end neoverse_v1, ERRATUM(2372203)
  178. check_erratum_ls neoverse_v1, ERRATUM(2372203), CPU_REV(1, 1)
  179. workaround_runtime_start neoverse_v1, ERRATUM(2743093), ERRATA_V1_2743093
  180. /* dsb before isb of power down sequence */
  181. dsb sy
  182. workaround_runtime_end neoverse_v1, ERRATUM(2743093)
  183. check_erratum_ls neoverse_v1, ERRATUM(2743093), CPU_REV(1, 2)
  184. workaround_reset_start neoverse_v1, ERRATUM(2743233), ERRATA_V1_2743233
  185. sysreg_bit_clear NEOVERSE_V1_ACTLR5_EL1, NEOVERSE_V1_ACTLR5_EL1_BIT_56
  186. sysreg_bit_set NEOVERSE_V1_ACTLR5_EL1, NEOVERSE_V1_ACTLR5_EL1_BIT_55
  187. workaround_reset_end neoverse_v1, ERRATUM(2743233)
  188. check_erratum_ls neoverse_v1, ERRATUM(2743233), CPU_REV(1, 2)
  189. workaround_reset_start neoverse_v1, ERRATUM(2779461), ERRATA_V1_2779461
  190. sysreg_bit_set NEOVERSE_V1_ACTLR3_EL1, NEOVERSE_V1_ACTLR3_EL1_BIT_47
  191. workaround_reset_end neoverse_v1, ERRATUM(2779461)
  192. check_erratum_ls neoverse_v1, ERRATUM(2779461), CPU_REV(1, 2)
  193. workaround_reset_start neoverse_v1, CVE(2022,23960), WORKAROUND_CVE_2022_23960
  194. #if IMAGE_BL31
  195. /*
  196. * The Neoverse-V1 generic vectors are overridden to apply errata
  197. * mitigation on exception entry from lower ELs.
  198. */
  199. override_vector_table wa_cve_vbar_neoverse_v1
  200. #endif /* IMAGE_BL31 */
  201. workaround_reset_end neoverse_v1, CVE(2022,23960)
  202. check_erratum_chosen neoverse_v1, CVE(2022, 23960), WORKAROUND_CVE_2022_23960
  203. /* ---------------------------------------------
  204. * HW will do the cache maintenance while powering down
  205. * ---------------------------------------------
  206. */
  207. func neoverse_v1_core_pwr_dwn
  208. /* ---------------------------------------------
  209. * Enable CPU power down bit in power control register
  210. * ---------------------------------------------
  211. */
  212. sysreg_bit_set NEOVERSE_V1_CPUPWRCTLR_EL1, NEOVERSE_V1_CPUPWRCTLR_EL1_CORE_PWRDN_BIT
  213. apply_erratum neoverse_v1, ERRATUM(2743093), ERRATA_V1_2743093, NO_GET_CPU_REV
  214. isb
  215. ret
  216. endfunc neoverse_v1_core_pwr_dwn
  217. cpu_reset_func_start neoverse_v1
  218. /* Disable speculative loads */
  219. msr SSBS, xzr
  220. cpu_reset_func_end neoverse_v1
  221. /* ---------------------------------------------
  222. * This function provides Neoverse-V1 specific
  223. * register information for crash reporting.
  224. * It needs to return with x6 pointing to
  225. * a list of register names in ascii and
  226. * x8 - x15 having values of registers to be
  227. * reported.
  228. * ---------------------------------------------
  229. */
  230. .section .rodata.neoverse_v1_regs, "aS"
  231. neoverse_v1_regs: /* The ascii list of register names to be reported */
  232. .asciz "cpuectlr_el1", ""
  233. func neoverse_v1_cpu_reg_dump
  234. adr x6, neoverse_v1_regs
  235. mrs x8, NEOVERSE_V1_CPUECTLR_EL1
  236. ret
  237. endfunc neoverse_v1_cpu_reg_dump
  238. declare_cpu_ops neoverse_v1, NEOVERSE_V1_MIDR, \
  239. neoverse_v1_reset_func, \
  240. neoverse_v1_core_pwr_dwn