ttable.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _SPARC64_TTABLE_H
  3. #define _SPARC64_TTABLE_H
  4. #include <asm/utrap.h>
  5. #include <asm/pil.h>
  6. #ifdef __ASSEMBLY__
  7. #include <asm/thread_info.h>
  8. #endif
  9. #define BOOT_KERNEL b sparc64_boot; nop; nop; nop; nop; nop; nop; nop;
  10. /* We need a "cleaned" instruction... */
  11. #define CLEAN_WINDOW \
  12. rdpr %cleanwin, %l0; add %l0, 1, %l0; \
  13. wrpr %l0, 0x0, %cleanwin; \
  14. clr %o0; clr %o1; clr %o2; clr %o3; \
  15. clr %o4; clr %o5; clr %o6; clr %o7; \
  16. clr %l0; clr %l1; clr %l2; clr %l3; \
  17. clr %l4; clr %l5; clr %l6; clr %l7; \
  18. retry; \
  19. nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;
  20. #define TRAP(routine) \
  21. sethi %hi(109f), %g7; \
  22. ba,pt %xcc, etrap; \
  23. 109: or %g7, %lo(109b), %g7; \
  24. call routine; \
  25. add %sp, PTREGS_OFF, %o0; \
  26. ba,pt %xcc, rtrap; \
  27. nop; \
  28. nop;
  29. #define TRAP_7INSNS(routine) \
  30. sethi %hi(109f), %g7; \
  31. ba,pt %xcc, etrap; \
  32. 109: or %g7, %lo(109b), %g7; \
  33. call routine; \
  34. add %sp, PTREGS_OFF, %o0; \
  35. ba,pt %xcc, rtrap; \
  36. nop;
  37. #define TRAP_SAVEFPU(routine) \
  38. sethi %hi(109f), %g7; \
  39. ba,pt %xcc, do_fptrap; \
  40. 109: or %g7, %lo(109b), %g7; \
  41. call routine; \
  42. add %sp, PTREGS_OFF, %o0; \
  43. ba,pt %xcc, rtrap; \
  44. nop; \
  45. nop;
  46. #define TRAP_NOSAVE(routine) \
  47. ba,pt %xcc, routine; \
  48. nop; \
  49. nop; nop; nop; nop; nop; nop;
  50. #define TRAP_NOSAVE_7INSNS(routine) \
  51. ba,pt %xcc, routine; \
  52. nop; \
  53. nop; nop; nop; nop; nop;
  54. #define TRAPTL1(routine) \
  55. sethi %hi(109f), %g7; \
  56. ba,pt %xcc, etraptl1; \
  57. 109: or %g7, %lo(109b), %g7; \
  58. call routine; \
  59. add %sp, PTREGS_OFF, %o0; \
  60. ba,pt %xcc, rtrap; \
  61. nop; \
  62. nop;
  63. #define TRAP_ARG(routine, arg) \
  64. sethi %hi(109f), %g7; \
  65. ba,pt %xcc, etrap; \
  66. 109: or %g7, %lo(109b), %g7; \
  67. add %sp, PTREGS_OFF, %o0; \
  68. call routine; \
  69. mov arg, %o1; \
  70. ba,pt %xcc, rtrap; \
  71. nop;
  72. #define TRAPTL1_ARG(routine, arg) \
  73. sethi %hi(109f), %g7; \
  74. ba,pt %xcc, etraptl1; \
  75. 109: or %g7, %lo(109b), %g7; \
  76. add %sp, PTREGS_OFF, %o0; \
  77. call routine; \
  78. mov arg, %o1; \
  79. ba,pt %xcc, rtrap; \
  80. nop;
  81. #define SYSCALL_TRAP(routine, systbl) \
  82. rdpr %pil, %g2; \
  83. mov TSTATE_SYSCALL, %g3; \
  84. sethi %hi(109f), %g7; \
  85. ba,pt %xcc, etrap_syscall; \
  86. 109: or %g7, %lo(109b), %g7; \
  87. sethi %hi(systbl), %l7; \
  88. ba,pt %xcc, routine; \
  89. or %l7, %lo(systbl), %l7;
  90. #define TRAP_UTRAP(handler,lvl) \
  91. mov handler, %g3; \
  92. ba,pt %xcc, utrap_trap; \
  93. mov lvl, %g4; \
  94. nop; \
  95. nop; \
  96. nop; \
  97. nop; \
  98. nop;
  99. #ifdef CONFIG_COMPAT
  100. #define LINUX_32BIT_SYSCALL_TRAP SYSCALL_TRAP(linux_sparc_syscall32, sys_call_table32)
  101. #else
  102. #define LINUX_32BIT_SYSCALL_TRAP BTRAP(0x110)
  103. #endif
  104. #define LINUX_64BIT_SYSCALL_TRAP SYSCALL_TRAP(linux_sparc_syscall, sys_call_table64)
  105. #define GETCC_TRAP TRAP(getcc)
  106. #define SETCC_TRAP TRAP(setcc)
  107. #define BREAKPOINT_TRAP TRAP(breakpoint_trap)
  108. #ifdef CONFIG_TRACE_IRQFLAGS
  109. #define TRAP_IRQ(routine, level) \
  110. rdpr %pil, %g2; \
  111. wrpr %g0, PIL_NORMAL_MAX, %pil; \
  112. sethi %hi(1f-4), %g7; \
  113. ba,pt %xcc, etrap_irq; \
  114. or %g7, %lo(1f-4), %g7; \
  115. nop; \
  116. nop; \
  117. nop; \
  118. .subsection 2; \
  119. 1: call trace_hardirqs_off; \
  120. nop; \
  121. mov level, %o0; \
  122. call routine; \
  123. add %sp, PTREGS_OFF, %o1; \
  124. ba,a,pt %xcc, rtrap_irq; \
  125. .previous;
  126. #else
  127. #define TRAP_IRQ(routine, level) \
  128. rdpr %pil, %g2; \
  129. wrpr %g0, PIL_NORMAL_MAX, %pil; \
  130. ba,pt %xcc, etrap_irq; \
  131. rd %pc, %g7; \
  132. mov level, %o0; \
  133. call routine; \
  134. add %sp, PTREGS_OFF, %o1; \
  135. ba,a,pt %xcc, rtrap_irq;
  136. #endif
  137. #define TRAP_NMI_IRQ(routine, level) \
  138. rdpr %pil, %g2; \
  139. wrpr %g0, PIL_NMI, %pil; \
  140. ba,pt %xcc, etrap_irq; \
  141. rd %pc, %g7; \
  142. mov level, %o0; \
  143. call routine; \
  144. add %sp, PTREGS_OFF, %o1; \
  145. ba,a,pt %xcc, rtrap_nmi;
  146. #define TRAP_IVEC TRAP_NOSAVE(do_ivec)
  147. #define BTRAP(lvl) TRAP_ARG(bad_trap, lvl)
  148. #define BTRAPTL1(lvl) TRAPTL1_ARG(bad_trap_tl1, lvl)
  149. #define FLUSH_WINDOW_TRAP \
  150. ba,pt %xcc, etrap; \
  151. rd %pc, %g7; \
  152. flushw; \
  153. ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1; \
  154. add %l1, 4, %l2; \
  155. stx %l1, [%sp + PTREGS_OFF + PT_V9_TPC]; \
  156. ba,pt %xcc, rtrap; \
  157. stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC];
  158. #ifdef CONFIG_KPROBES
  159. #define KPROBES_TRAP(lvl) TRAP_IRQ(kprobe_trap, lvl)
  160. #else
  161. #define KPROBES_TRAP(lvl) TRAP_ARG(bad_trap, lvl)
  162. #endif
  163. #ifdef CONFIG_UPROBES
  164. #define UPROBES_TRAP(lvl) TRAP_ARG(uprobe_trap, lvl)
  165. #else
  166. #define UPROBES_TRAP(lvl) TRAP_ARG(bad_trap, lvl)
  167. #endif
  168. #ifdef CONFIG_KGDB
  169. #define KGDB_TRAP(lvl) TRAP_IRQ(kgdb_trap, lvl)
  170. #else
  171. #define KGDB_TRAP(lvl) TRAP_ARG(bad_trap, lvl)
  172. #endif
  173. #define SUN4V_ITSB_MISS \
  174. ldxa [%g0] ASI_SCRATCHPAD, %g2; \
  175. ldx [%g2 + HV_FAULT_I_ADDR_OFFSET], %g4; \
  176. ldx [%g2 + HV_FAULT_I_CTX_OFFSET], %g5; \
  177. srlx %g4, 22, %g6; \
  178. ba,pt %xcc, sun4v_itsb_miss; \
  179. nop; \
  180. nop; \
  181. nop;
  182. #define SUN4V_DTSB_MISS \
  183. ldxa [%g0] ASI_SCRATCHPAD, %g2; \
  184. ldx [%g2 + HV_FAULT_D_ADDR_OFFSET], %g4; \
  185. ldx [%g2 + HV_FAULT_D_CTX_OFFSET], %g5; \
  186. srlx %g4, 22, %g6; \
  187. ba,pt %xcc, sun4v_dtsb_miss; \
  188. nop; \
  189. nop; \
  190. nop;
  191. #define SUN4V_MCD_PRECISE \
  192. ldxa [%g0] ASI_SCRATCHPAD, %g2; \
  193. ldx [%g2 + HV_FAULT_D_ADDR_OFFSET], %g4; \
  194. ldx [%g2 + HV_FAULT_D_CTX_OFFSET], %g5; \
  195. ba,pt %xcc, etrap; \
  196. rd %pc, %g7; \
  197. ba,pt %xcc, sun4v_mcd_detect_precise; \
  198. nop; \
  199. nop;
  200. /* Before touching these macros, you owe it to yourself to go and
  201. * see how arch/sparc64/kernel/winfixup.S works... -DaveM
  202. *
  203. * For the user cases we used to use the %asi register, but
  204. * it turns out that the "wr xxx, %asi" costs ~5 cycles, so
  205. * now we use immediate ASI loads and stores instead. Kudos
  206. * to Greg Onufer for pointing out this performance anomaly.
  207. *
  208. * Further note that we cannot use the g2, g4, g5, and g7 alternate
  209. * globals in the spill routines, check out the save instruction in
  210. * arch/sparc64/kernel/etrap.S to see what I mean about g2, and
  211. * g4/g5 are the globals which are preserved by etrap processing
  212. * for the caller of it. The g7 register is the return pc for
  213. * etrap. Finally, g6 is the current thread register so we cannot
  214. * us it in the spill handlers either. Most of these rules do not
  215. * apply to fill processing, only g6 is not usable.
  216. */
  217. /* Normal kernel spill */
  218. #define SPILL_0_NORMAL \
  219. stx %l0, [%sp + STACK_BIAS + 0x00]; \
  220. stx %l1, [%sp + STACK_BIAS + 0x08]; \
  221. stx %l2, [%sp + STACK_BIAS + 0x10]; \
  222. stx %l3, [%sp + STACK_BIAS + 0x18]; \
  223. stx %l4, [%sp + STACK_BIAS + 0x20]; \
  224. stx %l5, [%sp + STACK_BIAS + 0x28]; \
  225. stx %l6, [%sp + STACK_BIAS + 0x30]; \
  226. stx %l7, [%sp + STACK_BIAS + 0x38]; \
  227. stx %i0, [%sp + STACK_BIAS + 0x40]; \
  228. stx %i1, [%sp + STACK_BIAS + 0x48]; \
  229. stx %i2, [%sp + STACK_BIAS + 0x50]; \
  230. stx %i3, [%sp + STACK_BIAS + 0x58]; \
  231. stx %i4, [%sp + STACK_BIAS + 0x60]; \
  232. stx %i5, [%sp + STACK_BIAS + 0x68]; \
  233. stx %i6, [%sp + STACK_BIAS + 0x70]; \
  234. stx %i7, [%sp + STACK_BIAS + 0x78]; \
  235. saved; retry; nop; nop; nop; nop; nop; nop; \
  236. nop; nop; nop; nop; nop; nop; nop; nop;
  237. #define SPILL_0_NORMAL_ETRAP \
  238. etrap_kernel_spill: \
  239. stx %l0, [%sp + STACK_BIAS + 0x00]; \
  240. stx %l1, [%sp + STACK_BIAS + 0x08]; \
  241. stx %l2, [%sp + STACK_BIAS + 0x10]; \
  242. stx %l3, [%sp + STACK_BIAS + 0x18]; \
  243. stx %l4, [%sp + STACK_BIAS + 0x20]; \
  244. stx %l5, [%sp + STACK_BIAS + 0x28]; \
  245. stx %l6, [%sp + STACK_BIAS + 0x30]; \
  246. stx %l7, [%sp + STACK_BIAS + 0x38]; \
  247. stx %i0, [%sp + STACK_BIAS + 0x40]; \
  248. stx %i1, [%sp + STACK_BIAS + 0x48]; \
  249. stx %i2, [%sp + STACK_BIAS + 0x50]; \
  250. stx %i3, [%sp + STACK_BIAS + 0x58]; \
  251. stx %i4, [%sp + STACK_BIAS + 0x60]; \
  252. stx %i5, [%sp + STACK_BIAS + 0x68]; \
  253. stx %i6, [%sp + STACK_BIAS + 0x70]; \
  254. stx %i7, [%sp + STACK_BIAS + 0x78]; \
  255. saved; \
  256. sub %g1, 2, %g1; \
  257. ba,pt %xcc, etrap_save; \
  258. wrpr %g1, %cwp; \
  259. nop; nop; nop; nop; nop; nop; nop; nop; \
  260. nop; nop; nop; nop;
  261. /* Normal 64bit spill */
  262. #define SPILL_1_GENERIC(ASI) \
  263. add %sp, STACK_BIAS + 0x00, %g1; \
  264. stxa %l0, [%g1 + %g0] ASI; \
  265. mov 0x08, %g3; \
  266. stxa %l1, [%g1 + %g3] ASI; \
  267. add %g1, 0x10, %g1; \
  268. stxa %l2, [%g1 + %g0] ASI; \
  269. stxa %l3, [%g1 + %g3] ASI; \
  270. add %g1, 0x10, %g1; \
  271. stxa %l4, [%g1 + %g0] ASI; \
  272. stxa %l5, [%g1 + %g3] ASI; \
  273. add %g1, 0x10, %g1; \
  274. stxa %l6, [%g1 + %g0] ASI; \
  275. stxa %l7, [%g1 + %g3] ASI; \
  276. add %g1, 0x10, %g1; \
  277. stxa %i0, [%g1 + %g0] ASI; \
  278. stxa %i1, [%g1 + %g3] ASI; \
  279. add %g1, 0x10, %g1; \
  280. stxa %i2, [%g1 + %g0] ASI; \
  281. stxa %i3, [%g1 + %g3] ASI; \
  282. add %g1, 0x10, %g1; \
  283. stxa %i4, [%g1 + %g0] ASI; \
  284. stxa %i5, [%g1 + %g3] ASI; \
  285. add %g1, 0x10, %g1; \
  286. stxa %i6, [%g1 + %g0] ASI; \
  287. stxa %i7, [%g1 + %g3] ASI; \
  288. saved; \
  289. retry; nop; nop; \
  290. b,a,pt %xcc, spill_fixup_dax; \
  291. b,a,pt %xcc, spill_fixup_mna; \
  292. b,a,pt %xcc, spill_fixup;
  293. #define SPILL_1_GENERIC_ETRAP \
  294. etrap_user_spill_64bit: \
  295. stxa %l0, [%sp + STACK_BIAS + 0x00] %asi; \
  296. stxa %l1, [%sp + STACK_BIAS + 0x08] %asi; \
  297. stxa %l2, [%sp + STACK_BIAS + 0x10] %asi; \
  298. stxa %l3, [%sp + STACK_BIAS + 0x18] %asi; \
  299. stxa %l4, [%sp + STACK_BIAS + 0x20] %asi; \
  300. stxa %l5, [%sp + STACK_BIAS + 0x28] %asi; \
  301. stxa %l6, [%sp + STACK_BIAS + 0x30] %asi; \
  302. stxa %l7, [%sp + STACK_BIAS + 0x38] %asi; \
  303. stxa %i0, [%sp + STACK_BIAS + 0x40] %asi; \
  304. stxa %i1, [%sp + STACK_BIAS + 0x48] %asi; \
  305. stxa %i2, [%sp + STACK_BIAS + 0x50] %asi; \
  306. stxa %i3, [%sp + STACK_BIAS + 0x58] %asi; \
  307. stxa %i4, [%sp + STACK_BIAS + 0x60] %asi; \
  308. stxa %i5, [%sp + STACK_BIAS + 0x68] %asi; \
  309. stxa %i6, [%sp + STACK_BIAS + 0x70] %asi; \
  310. stxa %i7, [%sp + STACK_BIAS + 0x78] %asi; \
  311. saved; \
  312. sub %g1, 2, %g1; \
  313. ba,pt %xcc, etrap_save; \
  314. wrpr %g1, %cwp; \
  315. nop; nop; nop; nop; nop; \
  316. nop; nop; nop; nop; \
  317. ba,a,pt %xcc, etrap_spill_fixup_64bit; \
  318. ba,a,pt %xcc, etrap_spill_fixup_64bit; \
  319. ba,a,pt %xcc, etrap_spill_fixup_64bit;
  320. #define SPILL_1_GENERIC_ETRAP_FIXUP \
  321. etrap_spill_fixup_64bit: \
  322. ldub [%g6 + TI_WSAVED], %g1; \
  323. sll %g1, 3, %g3; \
  324. add %g6, %g3, %g3; \
  325. stx %sp, [%g3 + TI_RWIN_SPTRS]; \
  326. sll %g1, 7, %g3; \
  327. add %g6, %g3, %g3; \
  328. stx %l0, [%g3 + TI_REG_WINDOW + 0x00]; \
  329. stx %l1, [%g3 + TI_REG_WINDOW + 0x08]; \
  330. stx %l2, [%g3 + TI_REG_WINDOW + 0x10]; \
  331. stx %l3, [%g3 + TI_REG_WINDOW + 0x18]; \
  332. stx %l4, [%g3 + TI_REG_WINDOW + 0x20]; \
  333. stx %l5, [%g3 + TI_REG_WINDOW + 0x28]; \
  334. stx %l6, [%g3 + TI_REG_WINDOW + 0x30]; \
  335. stx %l7, [%g3 + TI_REG_WINDOW + 0x38]; \
  336. stx %i0, [%g3 + TI_REG_WINDOW + 0x40]; \
  337. stx %i1, [%g3 + TI_REG_WINDOW + 0x48]; \
  338. stx %i2, [%g3 + TI_REG_WINDOW + 0x50]; \
  339. stx %i3, [%g3 + TI_REG_WINDOW + 0x58]; \
  340. stx %i4, [%g3 + TI_REG_WINDOW + 0x60]; \
  341. stx %i5, [%g3 + TI_REG_WINDOW + 0x68]; \
  342. stx %i6, [%g3 + TI_REG_WINDOW + 0x70]; \
  343. stx %i7, [%g3 + TI_REG_WINDOW + 0x78]; \
  344. add %g1, 1, %g1; \
  345. stb %g1, [%g6 + TI_WSAVED]; \
  346. saved; \
  347. rdpr %cwp, %g1; \
  348. sub %g1, 2, %g1; \
  349. ba,pt %xcc, etrap_save; \
  350. wrpr %g1, %cwp; \
  351. nop; nop; nop
  352. /* Normal 32bit spill */
  353. #define SPILL_2_GENERIC(ASI) \
  354. and %sp, 1, %g3; \
  355. brnz,pn %g3, (. - (128 + 4)); \
  356. srl %sp, 0, %sp; \
  357. stwa %l0, [%sp + %g0] ASI; \
  358. mov 0x04, %g3; \
  359. stwa %l1, [%sp + %g3] ASI; \
  360. add %sp, 0x08, %g1; \
  361. stwa %l2, [%g1 + %g0] ASI; \
  362. stwa %l3, [%g1 + %g3] ASI; \
  363. add %g1, 0x08, %g1; \
  364. stwa %l4, [%g1 + %g0] ASI; \
  365. stwa %l5, [%g1 + %g3] ASI; \
  366. add %g1, 0x08, %g1; \
  367. stwa %l6, [%g1 + %g0] ASI; \
  368. stwa %l7, [%g1 + %g3] ASI; \
  369. add %g1, 0x08, %g1; \
  370. stwa %i0, [%g1 + %g0] ASI; \
  371. stwa %i1, [%g1 + %g3] ASI; \
  372. add %g1, 0x08, %g1; \
  373. stwa %i2, [%g1 + %g0] ASI; \
  374. stwa %i3, [%g1 + %g3] ASI; \
  375. add %g1, 0x08, %g1; \
  376. stwa %i4, [%g1 + %g0] ASI; \
  377. stwa %i5, [%g1 + %g3] ASI; \
  378. add %g1, 0x08, %g1; \
  379. stwa %i6, [%g1 + %g0] ASI; \
  380. stwa %i7, [%g1 + %g3] ASI; \
  381. saved; \
  382. retry; \
  383. b,a,pt %xcc, spill_fixup_dax; \
  384. b,a,pt %xcc, spill_fixup_mna; \
  385. b,a,pt %xcc, spill_fixup;
  386. #define SPILL_2_GENERIC_ETRAP \
  387. etrap_user_spill_32bit: \
  388. and %sp, 1, %g3; \
  389. brnz,pn %g3, etrap_user_spill_64bit; \
  390. srl %sp, 0, %sp; \
  391. stwa %l0, [%sp + 0x00] %asi; \
  392. stwa %l1, [%sp + 0x04] %asi; \
  393. stwa %l2, [%sp + 0x08] %asi; \
  394. stwa %l3, [%sp + 0x0c] %asi; \
  395. stwa %l4, [%sp + 0x10] %asi; \
  396. stwa %l5, [%sp + 0x14] %asi; \
  397. stwa %l6, [%sp + 0x18] %asi; \
  398. stwa %l7, [%sp + 0x1c] %asi; \
  399. stwa %i0, [%sp + 0x20] %asi; \
  400. stwa %i1, [%sp + 0x24] %asi; \
  401. stwa %i2, [%sp + 0x28] %asi; \
  402. stwa %i3, [%sp + 0x2c] %asi; \
  403. stwa %i4, [%sp + 0x30] %asi; \
  404. stwa %i5, [%sp + 0x34] %asi; \
  405. stwa %i6, [%sp + 0x38] %asi; \
  406. stwa %i7, [%sp + 0x3c] %asi; \
  407. saved; \
  408. sub %g1, 2, %g1; \
  409. ba,pt %xcc, etrap_save; \
  410. wrpr %g1, %cwp; \
  411. nop; nop; nop; nop; \
  412. nop; nop; \
  413. ba,a,pt %xcc, etrap_spill_fixup_32bit; \
  414. ba,a,pt %xcc, etrap_spill_fixup_32bit; \
  415. ba,a,pt %xcc, etrap_spill_fixup_32bit;
  416. #define SPILL_2_GENERIC_ETRAP_FIXUP \
  417. etrap_spill_fixup_32bit: \
  418. ldub [%g6 + TI_WSAVED], %g1; \
  419. sll %g1, 3, %g3; \
  420. add %g6, %g3, %g3; \
  421. stx %sp, [%g3 + TI_RWIN_SPTRS]; \
  422. sll %g1, 7, %g3; \
  423. add %g6, %g3, %g3; \
  424. stw %l0, [%g3 + TI_REG_WINDOW + 0x00]; \
  425. stw %l1, [%g3 + TI_REG_WINDOW + 0x04]; \
  426. stw %l2, [%g3 + TI_REG_WINDOW + 0x08]; \
  427. stw %l3, [%g3 + TI_REG_WINDOW + 0x0c]; \
  428. stw %l4, [%g3 + TI_REG_WINDOW + 0x10]; \
  429. stw %l5, [%g3 + TI_REG_WINDOW + 0x14]; \
  430. stw %l6, [%g3 + TI_REG_WINDOW + 0x18]; \
  431. stw %l7, [%g3 + TI_REG_WINDOW + 0x1c]; \
  432. stw %i0, [%g3 + TI_REG_WINDOW + 0x20]; \
  433. stw %i1, [%g3 + TI_REG_WINDOW + 0x24]; \
  434. stw %i2, [%g3 + TI_REG_WINDOW + 0x28]; \
  435. stw %i3, [%g3 + TI_REG_WINDOW + 0x2c]; \
  436. stw %i4, [%g3 + TI_REG_WINDOW + 0x30]; \
  437. stw %i5, [%g3 + TI_REG_WINDOW + 0x34]; \
  438. stw %i6, [%g3 + TI_REG_WINDOW + 0x38]; \
  439. stw %i7, [%g3 + TI_REG_WINDOW + 0x3c]; \
  440. add %g1, 1, %g1; \
  441. stb %g1, [%g6 + TI_WSAVED]; \
  442. saved; \
  443. rdpr %cwp, %g1; \
  444. sub %g1, 2, %g1; \
  445. ba,pt %xcc, etrap_save; \
  446. wrpr %g1, %cwp; \
  447. nop; nop; nop
  448. #define SPILL_1_NORMAL SPILL_1_GENERIC(ASI_AIUP)
  449. #define SPILL_2_NORMAL SPILL_2_GENERIC(ASI_AIUP)
  450. #define SPILL_3_NORMAL SPILL_0_NORMAL
  451. #define SPILL_4_NORMAL SPILL_0_NORMAL
  452. #define SPILL_5_NORMAL SPILL_0_NORMAL
  453. #define SPILL_6_NORMAL SPILL_0_NORMAL
  454. #define SPILL_7_NORMAL SPILL_0_NORMAL
  455. #define SPILL_0_OTHER SPILL_0_NORMAL
  456. #define SPILL_1_OTHER SPILL_1_GENERIC(ASI_AIUS)
  457. #define SPILL_2_OTHER SPILL_2_GENERIC(ASI_AIUS)
  458. #define SPILL_3_OTHER SPILL_3_NORMAL
  459. #define SPILL_4_OTHER SPILL_4_NORMAL
  460. #define SPILL_5_OTHER SPILL_5_NORMAL
  461. #define SPILL_6_OTHER SPILL_6_NORMAL
  462. #define SPILL_7_OTHER SPILL_7_NORMAL
  463. /* Normal kernel fill */
  464. #define FILL_0_NORMAL \
  465. ldx [%sp + STACK_BIAS + 0x00], %l0; \
  466. ldx [%sp + STACK_BIAS + 0x08], %l1; \
  467. ldx [%sp + STACK_BIAS + 0x10], %l2; \
  468. ldx [%sp + STACK_BIAS + 0x18], %l3; \
  469. ldx [%sp + STACK_BIAS + 0x20], %l4; \
  470. ldx [%sp + STACK_BIAS + 0x28], %l5; \
  471. ldx [%sp + STACK_BIAS + 0x30], %l6; \
  472. ldx [%sp + STACK_BIAS + 0x38], %l7; \
  473. ldx [%sp + STACK_BIAS + 0x40], %i0; \
  474. ldx [%sp + STACK_BIAS + 0x48], %i1; \
  475. ldx [%sp + STACK_BIAS + 0x50], %i2; \
  476. ldx [%sp + STACK_BIAS + 0x58], %i3; \
  477. ldx [%sp + STACK_BIAS + 0x60], %i4; \
  478. ldx [%sp + STACK_BIAS + 0x68], %i5; \
  479. ldx [%sp + STACK_BIAS + 0x70], %i6; \
  480. ldx [%sp + STACK_BIAS + 0x78], %i7; \
  481. restored; retry; nop; nop; nop; nop; nop; nop; \
  482. nop; nop; nop; nop; nop; nop; nop; nop;
  483. #define FILL_0_NORMAL_RTRAP \
  484. kern_rtt_fill: \
  485. rdpr %cwp, %g1; \
  486. sub %g1, 1, %g1; \
  487. wrpr %g1, %cwp; \
  488. ldx [%sp + STACK_BIAS + 0x00], %l0; \
  489. ldx [%sp + STACK_BIAS + 0x08], %l1; \
  490. ldx [%sp + STACK_BIAS + 0x10], %l2; \
  491. ldx [%sp + STACK_BIAS + 0x18], %l3; \
  492. ldx [%sp + STACK_BIAS + 0x20], %l4; \
  493. ldx [%sp + STACK_BIAS + 0x28], %l5; \
  494. ldx [%sp + STACK_BIAS + 0x30], %l6; \
  495. ldx [%sp + STACK_BIAS + 0x38], %l7; \
  496. ldx [%sp + STACK_BIAS + 0x40], %i0; \
  497. ldx [%sp + STACK_BIAS + 0x48], %i1; \
  498. ldx [%sp + STACK_BIAS + 0x50], %i2; \
  499. ldx [%sp + STACK_BIAS + 0x58], %i3; \
  500. ldx [%sp + STACK_BIAS + 0x60], %i4; \
  501. ldx [%sp + STACK_BIAS + 0x68], %i5; \
  502. ldx [%sp + STACK_BIAS + 0x70], %i6; \
  503. ldx [%sp + STACK_BIAS + 0x78], %i7; \
  504. restored; \
  505. add %g1, 1, %g1; \
  506. ba,pt %xcc, kern_rtt_restore; \
  507. wrpr %g1, %cwp; \
  508. nop; nop; nop; nop; nop; \
  509. nop; nop; nop; nop;
  510. /* Normal 64bit fill */
  511. #define FILL_1_GENERIC(ASI) \
  512. add %sp, STACK_BIAS + 0x00, %g1; \
  513. ldxa [%g1 + %g0] ASI, %l0; \
  514. mov 0x08, %g2; \
  515. mov 0x10, %g3; \
  516. ldxa [%g1 + %g2] ASI, %l1; \
  517. mov 0x18, %g5; \
  518. ldxa [%g1 + %g3] ASI, %l2; \
  519. ldxa [%g1 + %g5] ASI, %l3; \
  520. add %g1, 0x20, %g1; \
  521. ldxa [%g1 + %g0] ASI, %l4; \
  522. ldxa [%g1 + %g2] ASI, %l5; \
  523. ldxa [%g1 + %g3] ASI, %l6; \
  524. ldxa [%g1 + %g5] ASI, %l7; \
  525. add %g1, 0x20, %g1; \
  526. ldxa [%g1 + %g0] ASI, %i0; \
  527. ldxa [%g1 + %g2] ASI, %i1; \
  528. ldxa [%g1 + %g3] ASI, %i2; \
  529. ldxa [%g1 + %g5] ASI, %i3; \
  530. add %g1, 0x20, %g1; \
  531. ldxa [%g1 + %g0] ASI, %i4; \
  532. ldxa [%g1 + %g2] ASI, %i5; \
  533. ldxa [%g1 + %g3] ASI, %i6; \
  534. ldxa [%g1 + %g5] ASI, %i7; \
  535. restored; \
  536. retry; nop; nop; nop; nop; \
  537. b,a,pt %xcc, fill_fixup_dax; \
  538. b,a,pt %xcc, fill_fixup_mna; \
  539. b,a,pt %xcc, fill_fixup;
  540. #define FILL_1_GENERIC_RTRAP \
  541. user_rtt_fill_64bit: \
  542. ldxa [%sp + STACK_BIAS + 0x00] %asi, %l0; \
  543. ldxa [%sp + STACK_BIAS + 0x08] %asi, %l1; \
  544. ldxa [%sp + STACK_BIAS + 0x10] %asi, %l2; \
  545. ldxa [%sp + STACK_BIAS + 0x18] %asi, %l3; \
  546. ldxa [%sp + STACK_BIAS + 0x20] %asi, %l4; \
  547. ldxa [%sp + STACK_BIAS + 0x28] %asi, %l5; \
  548. ldxa [%sp + STACK_BIAS + 0x30] %asi, %l6; \
  549. ldxa [%sp + STACK_BIAS + 0x38] %asi, %l7; \
  550. ldxa [%sp + STACK_BIAS + 0x40] %asi, %i0; \
  551. ldxa [%sp + STACK_BIAS + 0x48] %asi, %i1; \
  552. ldxa [%sp + STACK_BIAS + 0x50] %asi, %i2; \
  553. ldxa [%sp + STACK_BIAS + 0x58] %asi, %i3; \
  554. ldxa [%sp + STACK_BIAS + 0x60] %asi, %i4; \
  555. ldxa [%sp + STACK_BIAS + 0x68] %asi, %i5; \
  556. ldxa [%sp + STACK_BIAS + 0x70] %asi, %i6; \
  557. ldxa [%sp + STACK_BIAS + 0x78] %asi, %i7; \
  558. ba,pt %xcc, user_rtt_pre_restore; \
  559. restored; \
  560. nop; nop; nop; nop; nop; nop; \
  561. nop; nop; nop; nop; nop; \
  562. ba,a,pt %xcc, user_rtt_fill_fixup_dax; \
  563. ba,a,pt %xcc, user_rtt_fill_fixup_mna; \
  564. ba,a,pt %xcc, user_rtt_fill_fixup;
  565. /* Normal 32bit fill */
  566. #define FILL_2_GENERIC(ASI) \
  567. and %sp, 1, %g3; \
  568. brnz,pn %g3, (. - (128 + 4)); \
  569. srl %sp, 0, %sp; \
  570. lduwa [%sp + %g0] ASI, %l0; \
  571. mov 0x04, %g2; \
  572. mov 0x08, %g3; \
  573. lduwa [%sp + %g2] ASI, %l1; \
  574. mov 0x0c, %g5; \
  575. lduwa [%sp + %g3] ASI, %l2; \
  576. lduwa [%sp + %g5] ASI, %l3; \
  577. add %sp, 0x10, %g1; \
  578. lduwa [%g1 + %g0] ASI, %l4; \
  579. lduwa [%g1 + %g2] ASI, %l5; \
  580. lduwa [%g1 + %g3] ASI, %l6; \
  581. lduwa [%g1 + %g5] ASI, %l7; \
  582. add %g1, 0x10, %g1; \
  583. lduwa [%g1 + %g0] ASI, %i0; \
  584. lduwa [%g1 + %g2] ASI, %i1; \
  585. lduwa [%g1 + %g3] ASI, %i2; \
  586. lduwa [%g1 + %g5] ASI, %i3; \
  587. add %g1, 0x10, %g1; \
  588. lduwa [%g1 + %g0] ASI, %i4; \
  589. lduwa [%g1 + %g2] ASI, %i5; \
  590. lduwa [%g1 + %g3] ASI, %i6; \
  591. lduwa [%g1 + %g5] ASI, %i7; \
  592. restored; \
  593. retry; nop; nop; \
  594. b,a,pt %xcc, fill_fixup_dax; \
  595. b,a,pt %xcc, fill_fixup_mna; \
  596. b,a,pt %xcc, fill_fixup;
  597. #define FILL_2_GENERIC_RTRAP \
  598. user_rtt_fill_32bit: \
  599. and %sp, 1, %g3; \
  600. brnz,pn %g3, user_rtt_fill_64bit; \
  601. srl %sp, 0, %sp; \
  602. lduwa [%sp + 0x00] %asi, %l0; \
  603. lduwa [%sp + 0x04] %asi, %l1; \
  604. lduwa [%sp + 0x08] %asi, %l2; \
  605. lduwa [%sp + 0x0c] %asi, %l3; \
  606. lduwa [%sp + 0x10] %asi, %l4; \
  607. lduwa [%sp + 0x14] %asi, %l5; \
  608. lduwa [%sp + 0x18] %asi, %l6; \
  609. lduwa [%sp + 0x1c] %asi, %l7; \
  610. lduwa [%sp + 0x20] %asi, %i0; \
  611. lduwa [%sp + 0x24] %asi, %i1; \
  612. lduwa [%sp + 0x28] %asi, %i2; \
  613. lduwa [%sp + 0x2c] %asi, %i3; \
  614. lduwa [%sp + 0x30] %asi, %i4; \
  615. lduwa [%sp + 0x34] %asi, %i5; \
  616. lduwa [%sp + 0x38] %asi, %i6; \
  617. lduwa [%sp + 0x3c] %asi, %i7; \
  618. ba,pt %xcc, user_rtt_pre_restore; \
  619. restored; \
  620. nop; nop; nop; nop; nop; \
  621. nop; nop; nop; \
  622. ba,a,pt %xcc, user_rtt_fill_fixup_dax; \
  623. ba,a,pt %xcc, user_rtt_fill_fixup_mna; \
  624. ba,a,pt %xcc, user_rtt_fill_fixup;
  625. #define FILL_1_NORMAL FILL_1_GENERIC(ASI_AIUP)
  626. #define FILL_2_NORMAL FILL_2_GENERIC(ASI_AIUP)
  627. #define FILL_3_NORMAL FILL_0_NORMAL
  628. #define FILL_4_NORMAL FILL_0_NORMAL
  629. #define FILL_5_NORMAL FILL_0_NORMAL
  630. #define FILL_6_NORMAL FILL_0_NORMAL
  631. #define FILL_7_NORMAL FILL_0_NORMAL
  632. #define FILL_0_OTHER FILL_0_NORMAL
  633. #define FILL_1_OTHER FILL_1_GENERIC(ASI_AIUS)
  634. #define FILL_2_OTHER FILL_2_GENERIC(ASI_AIUS)
  635. #define FILL_3_OTHER FILL_3_NORMAL
  636. #define FILL_4_OTHER FILL_4_NORMAL
  637. #define FILL_5_OTHER FILL_5_NORMAL
  638. #define FILL_6_OTHER FILL_6_NORMAL
  639. #define FILL_7_OTHER FILL_7_NORMAL
  640. #endif /* !(_SPARC64_TTABLE_H) */