tsp_exceptions.S 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. /*
  2. * Copyright (c) 2013-2020, ARM Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <arch.h>
  7. #include <asm_macros.S>
  8. #include <bl32/tsp/tsp.h>
  9. #include <common/bl_common.h>
  10. /* ----------------------------------------------------
  11. * The caller-saved registers x0-x18 and LR are saved
  12. * here.
  13. * ----------------------------------------------------
  14. */
  15. #define SCRATCH_REG_SIZE #(20 * 8)
  16. .macro save_caller_regs_and_lr
  17. sub sp, sp, SCRATCH_REG_SIZE
  18. stp x0, x1, [sp]
  19. stp x2, x3, [sp, #0x10]
  20. stp x4, x5, [sp, #0x20]
  21. stp x6, x7, [sp, #0x30]
  22. stp x8, x9, [sp, #0x40]
  23. stp x10, x11, [sp, #0x50]
  24. stp x12, x13, [sp, #0x60]
  25. stp x14, x15, [sp, #0x70]
  26. stp x16, x17, [sp, #0x80]
  27. stp x18, x30, [sp, #0x90]
  28. .endm
  29. .macro restore_caller_regs_and_lr
  30. ldp x0, x1, [sp]
  31. ldp x2, x3, [sp, #0x10]
  32. ldp x4, x5, [sp, #0x20]
  33. ldp x6, x7, [sp, #0x30]
  34. ldp x8, x9, [sp, #0x40]
  35. ldp x10, x11, [sp, #0x50]
  36. ldp x12, x13, [sp, #0x60]
  37. ldp x14, x15, [sp, #0x70]
  38. ldp x16, x17, [sp, #0x80]
  39. ldp x18, x30, [sp, #0x90]
  40. add sp, sp, SCRATCH_REG_SIZE
  41. .endm
  42. /* ----------------------------------------------------
  43. * Common TSP interrupt handling routine
  44. * ----------------------------------------------------
  45. */
  46. .macro handle_tsp_interrupt label
  47. /* Enable the SError interrupt */
  48. msr daifclr, #DAIF_ABT_BIT
  49. save_caller_regs_and_lr
  50. bl tsp_common_int_handler
  51. cbz x0, interrupt_exit_\label
  52. /*
  53. * This interrupt was not targetted to S-EL1 so send it to
  54. * the monitor and wait for execution to resume.
  55. */
  56. smc #0
  57. interrupt_exit_\label:
  58. restore_caller_regs_and_lr
  59. exception_return
  60. .endm
  61. .globl tsp_exceptions
  62. /* -----------------------------------------------------
  63. * TSP exception handlers.
  64. * -----------------------------------------------------
  65. */
  66. vector_base tsp_exceptions
  67. /* -----------------------------------------------------
  68. * Current EL with _sp_el0 : 0x0 - 0x200. No exceptions
  69. * are expected and treated as irrecoverable errors.
  70. * -----------------------------------------------------
  71. */
  72. vector_entry sync_exception_sp_el0
  73. b plat_panic_handler
  74. end_vector_entry sync_exception_sp_el0
  75. vector_entry irq_sp_el0
  76. b plat_panic_handler
  77. end_vector_entry irq_sp_el0
  78. vector_entry fiq_sp_el0
  79. b plat_panic_handler
  80. end_vector_entry fiq_sp_el0
  81. vector_entry serror_sp_el0
  82. b plat_panic_handler
  83. end_vector_entry serror_sp_el0
  84. /* -----------------------------------------------------
  85. * Current EL with SPx: 0x200 - 0x400. Only IRQs/FIQs
  86. * are expected and handled
  87. * -----------------------------------------------------
  88. */
  89. vector_entry sync_exception_sp_elx
  90. b plat_panic_handler
  91. end_vector_entry sync_exception_sp_elx
  92. vector_entry irq_sp_elx
  93. handle_tsp_interrupt irq_sp_elx
  94. end_vector_entry irq_sp_elx
  95. vector_entry fiq_sp_elx
  96. handle_tsp_interrupt fiq_sp_elx
  97. end_vector_entry fiq_sp_elx
  98. vector_entry serror_sp_elx
  99. b plat_panic_handler
  100. end_vector_entry serror_sp_elx
  101. /* -----------------------------------------------------
  102. * Lower EL using AArch64 : 0x400 - 0x600. No exceptions
  103. * are handled since TSP does not implement a lower EL
  104. * -----------------------------------------------------
  105. */
  106. vector_entry sync_exception_aarch64
  107. b plat_panic_handler
  108. end_vector_entry sync_exception_aarch64
  109. vector_entry irq_aarch64
  110. b plat_panic_handler
  111. end_vector_entry irq_aarch64
  112. vector_entry fiq_aarch64
  113. b plat_panic_handler
  114. end_vector_entry fiq_aarch64
  115. vector_entry serror_aarch64
  116. b plat_panic_handler
  117. end_vector_entry serror_aarch64
  118. /* -----------------------------------------------------
  119. * Lower EL using AArch32 : 0x600 - 0x800. No exceptions
  120. * handled since the TSP does not implement a lower EL.
  121. * -----------------------------------------------------
  122. */
  123. vector_entry sync_exception_aarch32
  124. b plat_panic_handler
  125. end_vector_entry sync_exception_aarch32
  126. vector_entry irq_aarch32
  127. b plat_panic_handler
  128. end_vector_entry irq_aarch32
  129. vector_entry fiq_aarch32
  130. b plat_panic_handler
  131. end_vector_entry fiq_aarch32
  132. vector_entry serror_aarch32
  133. b plat_panic_handler
  134. end_vector_entry serror_aarch32