/arch/powerpc/kernel/vdso64/sigtramp.S

http://github.com/mirrors/linux · Assembly · 307 lines · 251 code · 18 blank · 38 comment · 0 complexity · 35f9430d2b112da0e687ee3aa4e01639 MD5 · raw file

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