entry-table.S 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  1. /* entry-table.S: main trap vector tables and exception jump table
  2. *
  3. * Copyright (C) 2003 Red Hat, Inc. All Rights Reserved.
  4. * Written by David Howells (dhowells@redhat.com)
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * as published by the Free Software Foundation; either version
  9. * 2 of the License, or (at your option) any later version.
  10. *
  11. */
  12. #include <linux/sys.h>
  13. #include <linux/linkage.h>
  14. #include <asm/spr-regs.h>
  15. ###############################################################################
  16. #
  17. # Declare the main trap and vector tables
  18. #
  19. # There are six tables:
  20. #
  21. # (1) The trap table for debug mode
  22. # (2) The trap table for kernel mode
  23. # (3) The trap table for user mode
  24. #
  25. # The CPU jumps to an appropriate slot in the appropriate table to perform
  26. # exception processing. We have three different tables for the three
  27. # different CPU modes because there is no hardware differentiation between
  28. # stack pointers for these three modes, and so we have to invent one when
  29. # crossing mode boundaries.
  30. #
  31. # (4) The exception handler vector table
  32. #
  33. # The user and kernel trap tables use the same prologue for normal
  34. # exception processing. The prologue then jumps to the handler in this
  35. # table, as indexed by the exception ID from the TBR.
  36. #
  37. # (5) The fixup table for kernel-trap single-step
  38. # (6) The fixup table for user-trap single-step
  39. #
  40. # Due to the way single-stepping works on this CPU (single-step is not
  41. # disabled when crossing exception boundaries, only when in debug mode),
  42. # we have to catch the single-step event in break.S and jump to the fixup
  43. # routine pointed to by this table.
  44. #
  45. # The linker script places the user mode and kernel mode trap tables on to
  46. # the same 8Kb page, so that break.S can be more efficient when performing
  47. # single-step bypass management
  48. #
  49. ###############################################################################
  50. # trap table for entry from debug mode
  51. .section .trap.break,"ax"
  52. .balign 256*16
  53. .globl __entry_breaktrap_table
  54. __entry_breaktrap_table:
  55. # trap table for entry from user mode
  56. .section .trap.user,"ax"
  57. .balign 256*16
  58. .globl __entry_usertrap_table
  59. __entry_usertrap_table:
  60. # trap table for entry from kernel mode
  61. .section .trap.kernel,"ax"
  62. .balign 256*16
  63. .globl __entry_kerneltrap_table
  64. __entry_kerneltrap_table:
  65. # exception handler jump table
  66. .section .trap.vector,"ax"
  67. .balign 256*4
  68. .globl __entry_vector_table
  69. __entry_vector_table:
  70. # trap fixup table for single-stepping in user mode
  71. .section .trap.fixup.user,"a"
  72. .balign 256*4
  73. .globl __break_usertrap_fixup_table
  74. __break_usertrap_fixup_table:
  75. # trap fixup table for single-stepping in user mode
  76. .section .trap.fixup.kernel,"a"
  77. .balign 256*4
  78. .globl __break_kerneltrap_fixup_table
  79. __break_kerneltrap_fixup_table:
  80. # handler declaration for a software or program interrupt
  81. .macro VECTOR_SOFTPROG tbr_tt, vec
  82. .section .trap.user
  83. .org \tbr_tt
  84. bra __entry_uspace_softprog_interrupt
  85. .section .trap.fixup.user
  86. .org \tbr_tt >> 2
  87. .long __break_step_uspace_softprog_interrupt
  88. .section .trap.kernel
  89. .org \tbr_tt
  90. bra __entry_kernel_softprog_interrupt
  91. .section .trap.fixup.kernel
  92. .org \tbr_tt >> 2
  93. .long __break_step_kernel_softprog_interrupt
  94. .section .trap.vector
  95. .org \tbr_tt >> 2
  96. .long \vec
  97. .endm
  98. # handler declaration for a maskable external interrupt
  99. .macro VECTOR_IRQ tbr_tt, vec
  100. .section .trap.user
  101. .org \tbr_tt
  102. bra __entry_uspace_external_interrupt
  103. .section .trap.fixup.user
  104. .org \tbr_tt >> 2
  105. .long __break_step_uspace_external_interrupt
  106. .section .trap.kernel
  107. .org \tbr_tt
  108. # deal with virtual interrupt disablement
  109. beq icc2,#0,__entry_kernel_external_interrupt_virtually_disabled
  110. bra __entry_kernel_external_interrupt
  111. .section .trap.fixup.kernel
  112. .org \tbr_tt >> 2
  113. .long __break_step_kernel_external_interrupt
  114. .section .trap.vector
  115. .org \tbr_tt >> 2
  116. .long \vec
  117. .endm
  118. # handler declaration for an NMI external interrupt
  119. .macro VECTOR_NMI tbr_tt, vec
  120. .section .trap.user
  121. .org \tbr_tt
  122. break
  123. break
  124. break
  125. break
  126. .section .trap.kernel
  127. .org \tbr_tt
  128. break
  129. break
  130. break
  131. break
  132. .section .trap.vector
  133. .org \tbr_tt >> 2
  134. .long \vec
  135. .endm
  136. # handler declaration for an MMU only software or program interrupt
  137. .macro VECTOR_SP_MMU tbr_tt, vec
  138. #ifdef CONFIG_MMU
  139. VECTOR_SOFTPROG \tbr_tt, \vec
  140. #else
  141. VECTOR_NMI \tbr_tt, 0
  142. #endif
  143. .endm
  144. ###############################################################################
  145. #
  146. # specification of the vectors
  147. # - note: each macro inserts code into multiple sections
  148. #
  149. ###############################################################################
  150. VECTOR_SP_MMU TBR_TT_INSTR_MMU_MISS, __entry_insn_mmu_miss
  151. VECTOR_SOFTPROG TBR_TT_INSTR_ACC_ERROR, __entry_insn_access_error
  152. VECTOR_SOFTPROG TBR_TT_INSTR_ACC_EXCEP, __entry_insn_access_exception
  153. VECTOR_SOFTPROG TBR_TT_PRIV_INSTR, __entry_privileged_instruction
  154. VECTOR_SOFTPROG TBR_TT_ILLEGAL_INSTR, __entry_illegal_instruction
  155. VECTOR_SOFTPROG TBR_TT_FP_EXCEPTION, __entry_media_exception
  156. VECTOR_SOFTPROG TBR_TT_MP_EXCEPTION, __entry_media_exception
  157. VECTOR_SOFTPROG TBR_TT_DATA_ACC_ERROR, __entry_data_access_error
  158. VECTOR_SP_MMU TBR_TT_DATA_MMU_MISS, __entry_data_mmu_miss
  159. VECTOR_SOFTPROG TBR_TT_DATA_ACC_EXCEP, __entry_data_access_exception
  160. VECTOR_SOFTPROG TBR_TT_DATA_STR_ERROR, __entry_data_store_error
  161. VECTOR_SOFTPROG TBR_TT_DIVISION_EXCEP, __entry_division_exception
  162. #ifdef CONFIG_MMU
  163. .section .trap.user
  164. .org TBR_TT_INSTR_TLB_MISS
  165. .globl __trap_user_insn_tlb_miss
  166. __trap_user_insn_tlb_miss:
  167. movsg ear0,gr28 /* faulting address */
  168. movsg scr0,gr31 /* get mapped PTD coverage start address */
  169. xor.p gr28,gr31,gr31 /* compare addresses */
  170. bra __entry_user_insn_tlb_miss
  171. .org TBR_TT_DATA_TLB_MISS
  172. .globl __trap_user_data_tlb_miss
  173. __trap_user_data_tlb_miss:
  174. movsg ear0,gr28 /* faulting address */
  175. movsg scr1,gr31 /* get mapped PTD coverage start address */
  176. xor.p gr28,gr31,gr31 /* compare addresses */
  177. bra __entry_user_data_tlb_miss
  178. .section .trap.kernel
  179. .org TBR_TT_INSTR_TLB_MISS
  180. .globl __trap_kernel_insn_tlb_miss
  181. __trap_kernel_insn_tlb_miss:
  182. movsg ear0,gr29 /* faulting address */
  183. movsg scr0,gr31 /* get mapped PTD coverage start address */
  184. xor.p gr29,gr31,gr31 /* compare addresses */
  185. bra __entry_kernel_insn_tlb_miss
  186. .org TBR_TT_DATA_TLB_MISS
  187. .globl __trap_kernel_data_tlb_miss
  188. __trap_kernel_data_tlb_miss:
  189. movsg ear0,gr29 /* faulting address */
  190. movsg scr1,gr31 /* get mapped PTD coverage start address */
  191. xor.p gr29,gr31,gr31 /* compare addresses */
  192. bra __entry_kernel_data_tlb_miss
  193. .section .trap.fixup.user
  194. .org TBR_TT_INSTR_TLB_MISS >> 2
  195. .globl __trap_fixup_user_insn_tlb_miss
  196. __trap_fixup_user_insn_tlb_miss:
  197. .long __break_user_insn_tlb_miss
  198. .org TBR_TT_DATA_TLB_MISS >> 2
  199. .globl __trap_fixup_user_data_tlb_miss
  200. __trap_fixup_user_data_tlb_miss:
  201. .long __break_user_data_tlb_miss
  202. .section .trap.fixup.kernel
  203. .org TBR_TT_INSTR_TLB_MISS >> 2
  204. .globl __trap_fixup_kernel_insn_tlb_miss
  205. __trap_fixup_kernel_insn_tlb_miss:
  206. .long __break_kernel_insn_tlb_miss
  207. .org TBR_TT_DATA_TLB_MISS >> 2
  208. .globl __trap_fixup_kernel_data_tlb_miss
  209. __trap_fixup_kernel_data_tlb_miss:
  210. .long __break_kernel_data_tlb_miss
  211. .section .trap.vector
  212. .org TBR_TT_INSTR_TLB_MISS >> 2
  213. .long __entry_insn_mmu_fault
  214. .org TBR_TT_DATA_TLB_MISS >> 2
  215. .long __entry_data_mmu_fault
  216. #endif
  217. VECTOR_SP_MMU TBR_TT_DATA_DAT_EXCEP, __entry_data_dat_fault
  218. VECTOR_NMI TBR_TT_DECREMENT_TIMER, __entry_do_NMI
  219. VECTOR_SOFTPROG TBR_TT_COMPOUND_EXCEP, __entry_compound_exception
  220. VECTOR_IRQ TBR_TT_INTERRUPT_1, __entry_do_IRQ
  221. VECTOR_IRQ TBR_TT_INTERRUPT_2, __entry_do_IRQ
  222. VECTOR_IRQ TBR_TT_INTERRUPT_3, __entry_do_IRQ
  223. VECTOR_IRQ TBR_TT_INTERRUPT_4, __entry_do_IRQ
  224. VECTOR_IRQ TBR_TT_INTERRUPT_5, __entry_do_IRQ
  225. VECTOR_IRQ TBR_TT_INTERRUPT_6, __entry_do_IRQ
  226. VECTOR_IRQ TBR_TT_INTERRUPT_7, __entry_do_IRQ
  227. VECTOR_IRQ TBR_TT_INTERRUPT_8, __entry_do_IRQ
  228. VECTOR_IRQ TBR_TT_INTERRUPT_9, __entry_do_IRQ
  229. VECTOR_IRQ TBR_TT_INTERRUPT_10, __entry_do_IRQ
  230. VECTOR_IRQ TBR_TT_INTERRUPT_11, __entry_do_IRQ
  231. VECTOR_IRQ TBR_TT_INTERRUPT_12, __entry_do_IRQ
  232. VECTOR_IRQ TBR_TT_INTERRUPT_13, __entry_do_IRQ
  233. VECTOR_IRQ TBR_TT_INTERRUPT_14, __entry_do_IRQ
  234. VECTOR_NMI TBR_TT_INTERRUPT_15, __entry_do_NMI
  235. # miscellaneous user mode entry points
  236. .section .trap.user
  237. .org TBR_TT_TRAP0
  238. .rept 127
  239. bra __entry_uspace_softprog_interrupt
  240. .long 0,0,0
  241. .endr
  242. .org TBR_TT_BREAK
  243. bra __entry_break
  244. .long 0,0,0
  245. .section .trap.fixup.user
  246. .org TBR_TT_TRAP0 >> 2
  247. .rept 127
  248. .long __break_step_uspace_softprog_interrupt
  249. .endr
  250. .org TBR_TT_BREAK >> 2
  251. .long 0
  252. # miscellaneous kernel mode entry points
  253. .section .trap.kernel
  254. .org TBR_TT_TRAP0
  255. bra __entry_kernel_softprog_interrupt
  256. .org TBR_TT_TRAP1
  257. bra __entry_kernel_softprog_interrupt
  258. # trap #2 in kernel - reenable interrupts
  259. .org TBR_TT_TRAP2
  260. bra __entry_kernel_external_interrupt_virtual_reenable
  261. # miscellaneous kernel traps
  262. .org TBR_TT_TRAP3
  263. .rept 124
  264. bra __entry_kernel_softprog_interrupt
  265. .long 0,0,0
  266. .endr
  267. .org TBR_TT_BREAK
  268. bra __entry_break
  269. .long 0,0,0
  270. .section .trap.fixup.kernel
  271. .org TBR_TT_TRAP0 >> 2
  272. .long __break_step_kernel_softprog_interrupt
  273. .long __break_step_kernel_softprog_interrupt
  274. .long __break_step_kernel_external_interrupt_virtual_reenable
  275. .rept 124
  276. .long __break_step_kernel_softprog_interrupt
  277. .endr
  278. .org TBR_TT_BREAK >> 2
  279. .long 0
  280. # miscellaneous debug mode entry points
  281. .section .trap.break
  282. .org TBR_TT_BREAK
  283. movsg bpcsr,gr30
  284. jmpl @(gr30,gr0)
  285. # miscellaneous vectors
  286. .section .trap.vector
  287. .org TBR_TT_TRAP0 >> 2
  288. .long system_call
  289. .rept 119
  290. .long __entry_unsupported_trap
  291. .endr
  292. # userspace atomic op emulation, traps 120-126
  293. .rept 7
  294. .long __entry_atomic_op
  295. .endr
  296. .org TBR_TT_BREAK >> 2
  297. .long __entry_debug_exception