sigtramp.S 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. /*
  2. * Signal trampolines for 32 bits processes in a ppc64 kernel for
  3. * use in the vDSO
  4. *
  5. * Copyright (C) 2004 Benjamin Herrenschmuidt (benh@kernel.crashing.org), IBM Corp.
  6. * Copyright (C) 2004 Alan Modra (amodra@au.ibm.com)), IBM Corp.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License
  10. * as published by the Free Software Foundation; either version
  11. * 2 of the License, or (at your option) any later version.
  12. */
  13. #include <asm/processor.h>
  14. #include <asm/ppc_asm.h>
  15. #include <asm/unistd.h>
  16. #include <asm/vdso.h>
  17. .text
  18. /* The nop here is a hack. The dwarf2 unwind routines subtract 1 from
  19. the return address to get an address in the middle of the presumed
  20. call instruction. Since we don't have a call here, we artificially
  21. extend the range covered by the unwind info by adding a nop before
  22. the real start. */
  23. nop
  24. V_FUNCTION_BEGIN(__kernel_sigtramp32)
  25. .Lsig_start = . - 4
  26. li r0,__NR_sigreturn
  27. sc
  28. .Lsig_end:
  29. V_FUNCTION_END(__kernel_sigtramp32)
  30. .Lsigrt_start:
  31. nop
  32. V_FUNCTION_BEGIN(__kernel_sigtramp_rt32)
  33. li r0,__NR_rt_sigreturn
  34. sc
  35. .Lsigrt_end:
  36. V_FUNCTION_END(__kernel_sigtramp_rt32)
  37. .section .eh_frame,"a",@progbits
  38. /* Register r1 can be found at offset 4 of a pt_regs structure.
  39. A pointer to the pt_regs is stored in memory at the old sp plus PTREGS. */
  40. #define cfa_save \
  41. .byte 0x0f; /* DW_CFA_def_cfa_expression */ \
  42. .uleb128 9f - 1f; /* length */ \
  43. 1: \
  44. .byte 0x71; .sleb128 PTREGS; /* DW_OP_breg1 */ \
  45. .byte 0x06; /* DW_OP_deref */ \
  46. .byte 0x23; .uleb128 RSIZE; /* DW_OP_plus_uconst */ \
  47. .byte 0x06; /* DW_OP_deref */ \
  48. 9:
  49. /* Register REGNO can be found at offset OFS of a pt_regs structure.
  50. A pointer to the pt_regs is stored in memory at the old sp plus PTREGS. */
  51. #define rsave(regno, ofs) \
  52. .byte 0x10; /* DW_CFA_expression */ \
  53. .uleb128 regno; /* regno */ \
  54. .uleb128 9f - 1f; /* length */ \
  55. 1: \
  56. .byte 0x71; .sleb128 PTREGS; /* DW_OP_breg1 */ \
  57. .byte 0x06; /* DW_OP_deref */ \
  58. .ifne ofs; \
  59. .byte 0x23; .uleb128 ofs; /* DW_OP_plus_uconst */ \
  60. .endif; \
  61. 9:
  62. /* If msr bit 1<<25 is set, then VMX register REGNO is at offset REGNO*16
  63. of the VMX reg struct. The VMX reg struct is at offset VREGS of
  64. the pt_regs struct. This macro is for REGNO == 0, and contains
  65. 'subroutines' that the other macros jump to. */
  66. #define vsave_msr0(regno) \
  67. .byte 0x10; /* DW_CFA_expression */ \
  68. .uleb128 regno + 77; /* regno */ \
  69. .uleb128 9f - 1f; /* length */ \
  70. 1: \
  71. .byte 0x30 + regno; /* DW_OP_lit0 */ \
  72. 2: \
  73. .byte 0x40; /* DW_OP_lit16 */ \
  74. .byte 0x1e; /* DW_OP_mul */ \
  75. 3: \
  76. .byte 0x71; .sleb128 PTREGS; /* DW_OP_breg1 */ \
  77. .byte 0x06; /* DW_OP_deref */ \
  78. .byte 0x12; /* DW_OP_dup */ \
  79. .byte 0x23; /* DW_OP_plus_uconst */ \
  80. .uleb128 33*RSIZE; /* msr offset */ \
  81. .byte 0x06; /* DW_OP_deref */ \
  82. .byte 0x0c; .long 1 << 25; /* DW_OP_const4u */ \
  83. .byte 0x1a; /* DW_OP_and */ \
  84. .byte 0x12; /* DW_OP_dup, ret 0 if bra taken */ \
  85. .byte 0x30; /* DW_OP_lit0 */ \
  86. .byte 0x29; /* DW_OP_eq */ \
  87. .byte 0x28; .short 0x7fff; /* DW_OP_bra to end */ \
  88. .byte 0x13; /* DW_OP_drop, pop the 0 */ \
  89. .byte 0x23; .uleb128 VREGS; /* DW_OP_plus_uconst */ \
  90. .byte 0x22; /* DW_OP_plus */ \
  91. .byte 0x2f; .short 0x7fff; /* DW_OP_skip to end */ \
  92. 9:
  93. /* If msr bit 1<<25 is set, then VMX register REGNO is at offset REGNO*16
  94. of the VMX reg struct. REGNO is 1 thru 31. */
  95. #define vsave_msr1(regno) \
  96. .byte 0x10; /* DW_CFA_expression */ \
  97. .uleb128 regno + 77; /* regno */ \
  98. .uleb128 9f - 1f; /* length */ \
  99. 1: \
  100. .byte 0x30 + regno; /* DW_OP_lit n */ \
  101. .byte 0x2f; .short 2b - 9f; /* DW_OP_skip */ \
  102. 9:
  103. /* If msr bit 1<<25 is set, then VMX register REGNO is at offset OFS of
  104. the VMX save block. */
  105. #define vsave_msr2(regno, ofs) \
  106. .byte 0x10; /* DW_CFA_expression */ \
  107. .uleb128 regno + 77; /* regno */ \
  108. .uleb128 9f - 1f; /* length */ \
  109. 1: \
  110. .byte 0x0a; .short ofs; /* DW_OP_const2u */ \
  111. .byte 0x2f; .short 3b - 9f; /* DW_OP_skip */ \
  112. 9:
  113. /* VMX register REGNO is at offset OFS of the VMX save area. */
  114. #define vsave(regno, ofs) \
  115. .byte 0x10; /* DW_CFA_expression */ \
  116. .uleb128 regno + 77; /* regno */ \
  117. .uleb128 9f - 1f; /* length */ \
  118. 1: \
  119. .byte 0x71; .sleb128 PTREGS; /* DW_OP_breg1 */ \
  120. .byte 0x06; /* DW_OP_deref */ \
  121. .byte 0x23; .uleb128 VREGS; /* DW_OP_plus_uconst */ \
  122. .byte 0x23; .uleb128 ofs; /* DW_OP_plus_uconst */ \
  123. 9:
  124. /* This is where the pt_regs pointer can be found on the stack. */
  125. #define PTREGS 64+28
  126. /* Size of regs. */
  127. #define RSIZE 4
  128. /* This is the offset of the VMX regs. */
  129. #define VREGS 48*RSIZE+34*8
  130. /* Describe where general purpose regs are saved. */
  131. #define EH_FRAME_GEN \
  132. cfa_save; \
  133. rsave ( 0, 0*RSIZE); \
  134. rsave ( 2, 2*RSIZE); \
  135. rsave ( 3, 3*RSIZE); \
  136. rsave ( 4, 4*RSIZE); \
  137. rsave ( 5, 5*RSIZE); \
  138. rsave ( 6, 6*RSIZE); \
  139. rsave ( 7, 7*RSIZE); \
  140. rsave ( 8, 8*RSIZE); \
  141. rsave ( 9, 9*RSIZE); \
  142. rsave (10, 10*RSIZE); \
  143. rsave (11, 11*RSIZE); \
  144. rsave (12, 12*RSIZE); \
  145. rsave (13, 13*RSIZE); \
  146. rsave (14, 14*RSIZE); \
  147. rsave (15, 15*RSIZE); \
  148. rsave (16, 16*RSIZE); \
  149. rsave (17, 17*RSIZE); \
  150. rsave (18, 18*RSIZE); \
  151. rsave (19, 19*RSIZE); \
  152. rsave (20, 20*RSIZE); \
  153. rsave (21, 21*RSIZE); \
  154. rsave (22, 22*RSIZE); \
  155. rsave (23, 23*RSIZE); \
  156. rsave (24, 24*RSIZE); \
  157. rsave (25, 25*RSIZE); \
  158. rsave (26, 26*RSIZE); \
  159. rsave (27, 27*RSIZE); \
  160. rsave (28, 28*RSIZE); \
  161. rsave (29, 29*RSIZE); \
  162. rsave (30, 30*RSIZE); \
  163. rsave (31, 31*RSIZE); \
  164. rsave (67, 32*RSIZE); /* ap, used as temp for nip */ \
  165. rsave (65, 36*RSIZE); /* lr */ \
  166. rsave (70, 38*RSIZE) /* cr */
  167. /* Describe where the FP regs are saved. */
  168. #define EH_FRAME_FP \
  169. rsave (32, 48*RSIZE + 0*8); \
  170. rsave (33, 48*RSIZE + 1*8); \
  171. rsave (34, 48*RSIZE + 2*8); \
  172. rsave (35, 48*RSIZE + 3*8); \
  173. rsave (36, 48*RSIZE + 4*8); \
  174. rsave (37, 48*RSIZE + 5*8); \
  175. rsave (38, 48*RSIZE + 6*8); \
  176. rsave (39, 48*RSIZE + 7*8); \
  177. rsave (40, 48*RSIZE + 8*8); \
  178. rsave (41, 48*RSIZE + 9*8); \
  179. rsave (42, 48*RSIZE + 10*8); \
  180. rsave (43, 48*RSIZE + 11*8); \
  181. rsave (44, 48*RSIZE + 12*8); \
  182. rsave (45, 48*RSIZE + 13*8); \
  183. rsave (46, 48*RSIZE + 14*8); \
  184. rsave (47, 48*RSIZE + 15*8); \
  185. rsave (48, 48*RSIZE + 16*8); \
  186. rsave (49, 48*RSIZE + 17*8); \
  187. rsave (50, 48*RSIZE + 18*8); \
  188. rsave (51, 48*RSIZE + 19*8); \
  189. rsave (52, 48*RSIZE + 20*8); \
  190. rsave (53, 48*RSIZE + 21*8); \
  191. rsave (54, 48*RSIZE + 22*8); \
  192. rsave (55, 48*RSIZE + 23*8); \
  193. rsave (56, 48*RSIZE + 24*8); \
  194. rsave (57, 48*RSIZE + 25*8); \
  195. rsave (58, 48*RSIZE + 26*8); \
  196. rsave (59, 48*RSIZE + 27*8); \
  197. rsave (60, 48*RSIZE + 28*8); \
  198. rsave (61, 48*RSIZE + 29*8); \
  199. rsave (62, 48*RSIZE + 30*8); \
  200. rsave (63, 48*RSIZE + 31*8)
  201. /* Describe where the VMX regs are saved. */
  202. #ifdef CONFIG_ALTIVEC
  203. #define EH_FRAME_VMX \
  204. vsave_msr0 ( 0); \
  205. vsave_msr1 ( 1); \
  206. vsave_msr1 ( 2); \
  207. vsave_msr1 ( 3); \
  208. vsave_msr1 ( 4); \
  209. vsave_msr1 ( 5); \
  210. vsave_msr1 ( 6); \
  211. vsave_msr1 ( 7); \
  212. vsave_msr1 ( 8); \
  213. vsave_msr1 ( 9); \
  214. vsave_msr1 (10); \
  215. vsave_msr1 (11); \
  216. vsave_msr1 (12); \
  217. vsave_msr1 (13); \
  218. vsave_msr1 (14); \
  219. vsave_msr1 (15); \
  220. vsave_msr1 (16); \
  221. vsave_msr1 (17); \
  222. vsave_msr1 (18); \
  223. vsave_msr1 (19); \
  224. vsave_msr1 (20); \
  225. vsave_msr1 (21); \
  226. vsave_msr1 (22); \
  227. vsave_msr1 (23); \
  228. vsave_msr1 (24); \
  229. vsave_msr1 (25); \
  230. vsave_msr1 (26); \
  231. vsave_msr1 (27); \
  232. vsave_msr1 (28); \
  233. vsave_msr1 (29); \
  234. vsave_msr1 (30); \
  235. vsave_msr1 (31); \
  236. vsave_msr2 (33, 32*16+12); \
  237. vsave (32, 32*16)
  238. #else
  239. #define EH_FRAME_VMX
  240. #endif
  241. .Lcie:
  242. .long .Lcie_end - .Lcie_start
  243. .Lcie_start:
  244. .long 0 /* CIE ID */
  245. .byte 1 /* Version number */
  246. .string "zRS" /* NUL-terminated augmentation string */
  247. .uleb128 4 /* Code alignment factor */
  248. .sleb128 -4 /* Data alignment factor */
  249. .byte 67 /* Return address register column, ap */
  250. .uleb128 1 /* Augmentation value length */
  251. .byte 0x1b /* DW_EH_PE_pcrel | DW_EH_PE_sdata4. */
  252. .byte 0x0c,1,0 /* DW_CFA_def_cfa: r1 ofs 0 */
  253. .balign 4
  254. .Lcie_end:
  255. .long .Lfde0_end - .Lfde0_start
  256. .Lfde0_start:
  257. .long .Lfde0_start - .Lcie /* CIE pointer. */
  258. .long .Lsig_start - . /* PC start, length */
  259. .long .Lsig_end - .Lsig_start
  260. .uleb128 0 /* Augmentation */
  261. EH_FRAME_GEN
  262. EH_FRAME_FP
  263. EH_FRAME_VMX
  264. .balign 4
  265. .Lfde0_end:
  266. /* We have a different stack layout for rt_sigreturn. */
  267. #undef PTREGS
  268. #define PTREGS 64+16+128+20+28
  269. .long .Lfde1_end - .Lfde1_start
  270. .Lfde1_start:
  271. .long .Lfde1_start - .Lcie /* CIE pointer. */
  272. .long .Lsigrt_start - . /* PC start, length */
  273. .long .Lsigrt_end - .Lsigrt_start
  274. .uleb128 0 /* Augmentation */
  275. EH_FRAME_GEN
  276. EH_FRAME_FP
  277. EH_FRAME_VMX
  278. .balign 4
  279. .Lfde1_end: