spm_shim_exceptions.S 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /*
  2. * Copyright (c) 2017-2022, 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 <common/bl_common.h>
  9. #include <context.h>
  10. /* -----------------------------------------------------------------------------
  11. * Very simple stackless exception handlers used by the spm shim layer.
  12. * -----------------------------------------------------------------------------
  13. */
  14. .globl spm_shim_exceptions_ptr
  15. vector_base spm_shim_exceptions_ptr, .spm_shim_exceptions
  16. /* -----------------------------------------------------
  17. * Current EL with SP0 : 0x0 - 0x200
  18. * -----------------------------------------------------
  19. */
  20. vector_entry SynchronousExceptionSP0, .spm_shim_exceptions
  21. b .
  22. end_vector_entry SynchronousExceptionSP0
  23. vector_entry IrqSP0, .spm_shim_exceptions
  24. b .
  25. end_vector_entry IrqSP0
  26. vector_entry FiqSP0, .spm_shim_exceptions
  27. b .
  28. end_vector_entry FiqSP0
  29. vector_entry SErrorSP0, .spm_shim_exceptions
  30. b .
  31. end_vector_entry SErrorSP0
  32. /* -----------------------------------------------------
  33. * Current EL with SPx: 0x200 - 0x400
  34. * -----------------------------------------------------
  35. */
  36. vector_entry SynchronousExceptionSPx, .spm_shim_exceptions
  37. b .
  38. end_vector_entry SynchronousExceptionSPx
  39. vector_entry IrqSPx, .spm_shim_exceptions
  40. b .
  41. end_vector_entry IrqSPx
  42. vector_entry FiqSPx, .spm_shim_exceptions
  43. b .
  44. end_vector_entry FiqSPx
  45. vector_entry SErrorSPx, .spm_shim_exceptions
  46. b .
  47. end_vector_entry SErrorSPx
  48. /* -----------------------------------------------------
  49. * Lower EL using AArch64 : 0x400 - 0x600. No exceptions
  50. * are handled since secure_partition does not implement
  51. * a lower EL
  52. * -----------------------------------------------------
  53. */
  54. vector_entry SynchronousExceptionA64, .spm_shim_exceptions
  55. msr tpidr_el1, x30
  56. mrs x30, esr_el1
  57. ubfx x30, x30, #ESR_EC_SHIFT, #ESR_EC_LENGTH
  58. cmp x30, #EC_AARCH64_SVC
  59. b.eq do_smc
  60. cmp x30, #EC_AARCH32_SVC
  61. b.eq do_smc
  62. cmp x30, #EC_AARCH64_SYS
  63. b.eq handle_sys_trap
  64. /* Fail in all the other cases */
  65. b panic
  66. /* ---------------------------------------------
  67. * Tell SPM that we are done initialising
  68. * ---------------------------------------------
  69. */
  70. do_smc:
  71. mrs x30, tpidr_el1
  72. smc #0
  73. exception_return
  74. /* AArch64 system instructions trap are handled as a panic for now */
  75. handle_sys_trap:
  76. panic:
  77. b panic
  78. end_vector_entry SynchronousExceptionA64
  79. vector_entry IrqA64, .spm_shim_exceptions
  80. b .
  81. end_vector_entry IrqA64
  82. vector_entry FiqA64, .spm_shim_exceptions
  83. b .
  84. end_vector_entry FiqA64
  85. vector_entry SErrorA64, .spm_shim_exceptions
  86. b .
  87. end_vector_entry SErrorA64
  88. /* -----------------------------------------------------
  89. * Lower EL using AArch32 : 0x600 - 0x800
  90. * -----------------------------------------------------
  91. */
  92. vector_entry SynchronousExceptionA32, .spm_shim_exceptions
  93. b .
  94. end_vector_entry SynchronousExceptionA32
  95. vector_entry IrqA32, .spm_shim_exceptions
  96. b .
  97. end_vector_entry IrqA32
  98. vector_entry FiqA32, .spm_shim_exceptions
  99. b .
  100. end_vector_entry FiqA32
  101. vector_entry SErrorA32, .spm_shim_exceptions
  102. b .
  103. end_vector_entry SErrorA32