sigtramp.S 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Signal trampolines for 64 bit processes.
  4. *
  5. * Copyright (C) 2006 Randolph Chung <[email protected]>
  6. * Copyright (C) 2018-2022 Helge Deller <[email protected]>
  7. * Copyright (C) 2022 John David Anglin <[email protected]>
  8. */
  9. #include <asm/unistd.h>
  10. #include <linux/linkage.h>
  11. #include <generated/asm-offsets.h>
  12. .text
  13. /* Gdb expects the trampoline is on the stack and the pc is offset from
  14. a 64-byte boundary by 0, 4 or 5 instructions. Since the vdso trampoline
  15. is not on the stack, we need a new variant with different offsets and
  16. data to tell gdb where to find the signal context on the stack.
  17. Here we put the offset to the context data at the start of the trampoline
  18. region and offset the first trampoline by 2 instructions. Please do
  19. not change the trampoline as the code in gdb depends on the following
  20. instruction sequence exactly.
  21. */
  22. .align 64
  23. .word SIGFRAME_CONTEXT_REGS
  24. /* The nop here is a hack. The dwarf2 unwind routines subtract 1 from
  25. the return address to get an address in the middle of the presumed
  26. call instruction. Since we don't have a call here, we artifically
  27. extend the range covered by the unwind info by adding a nop before
  28. the real start.
  29. */
  30. nop
  31. .globl __kernel_sigtramp_rt
  32. .type __kernel_sigtramp_rt, @function
  33. __kernel_sigtramp_rt:
  34. .proc
  35. .callinfo FRAME=ASM_SIGFRAME_SIZE,CALLS,SAVE_RP
  36. .entry
  37. .Lsigrt_start = . - 4
  38. 0: ldi 0, %r25 /* (in_syscall=0) */
  39. ldi __NR_rt_sigreturn, %r20
  40. ble 0x100(%sr2, %r0)
  41. nop
  42. 1: ldi 1, %r25 /* (in_syscall=1) */
  43. ldi __NR_rt_sigreturn, %r20
  44. ble 0x100(%sr2, %r0)
  45. nop
  46. .Lsigrt_end:
  47. .exit
  48. .procend
  49. .size __kernel_sigtramp_rt,.-__kernel_sigtramp_rt
  50. .section .eh_frame,"a",@progbits
  51. /* This is where the mcontext_t struct can be found on the stack. */
  52. #define PTREGS SIGFRAME_CONTEXT_REGS /* 64-bit process offset is -720 */
  53. /* Register REGNO can be found at offset OFS of the mcontext_t structure. */
  54. .macro rsave regno,ofs
  55. .byte 0x05 /* DW_CFA_offset_extended */
  56. .uleb128 \regno; /* regno */
  57. .uleb128 \ofs /* factored offset */
  58. .endm
  59. .Lcie:
  60. .long .Lcie_end - .Lcie_start
  61. .Lcie_start:
  62. .long 0 /* CIE ID */
  63. .byte 1 /* Version number */
  64. .stringz "zRS" /* NUL-terminated augmentation string */
  65. .uleb128 4 /* Code alignment factor */
  66. .sleb128 8 /* Data alignment factor */
  67. .byte 61 /* Return address register column, iaoq[0] */
  68. .uleb128 1 /* Augmentation value length */
  69. .byte 0x1b /* DW_EH_PE_pcrel | DW_EH_PE_sdata4. */
  70. .byte 0x0f /* DW_CFA_def_cfa_expresion */
  71. .uleb128 9f - 1f /* length */
  72. 1:
  73. .byte 0x8e /* DW_OP_breg30 */
  74. .sleb128 PTREGS
  75. 9:
  76. .balign 8
  77. .Lcie_end:
  78. .long .Lfde0_end - .Lfde0_start
  79. .Lfde0_start:
  80. .long .Lfde0_start - .Lcie /* CIE pointer. */
  81. .long .Lsigrt_start - . /* PC start, length */
  82. .long .Lsigrt_end - .Lsigrt_start
  83. .uleb128 0 /* Augmentation */
  84. /* General registers */
  85. rsave 1, 2
  86. rsave 2, 3
  87. rsave 3, 4
  88. rsave 4, 5
  89. rsave 5, 6
  90. rsave 6, 7
  91. rsave 7, 8
  92. rsave 8, 9
  93. rsave 9, 10
  94. rsave 10, 11
  95. rsave 11, 12
  96. rsave 12, 13
  97. rsave 13, 14
  98. rsave 14, 15
  99. rsave 15, 16
  100. rsave 16, 17
  101. rsave 17, 18
  102. rsave 18, 19
  103. rsave 19, 20
  104. rsave 20, 21
  105. rsave 21, 22
  106. rsave 22, 23
  107. rsave 23, 24
  108. rsave 24, 25
  109. rsave 25, 26
  110. rsave 26, 27
  111. rsave 27, 28
  112. rsave 28, 29
  113. rsave 29, 30
  114. rsave 30, 31
  115. rsave 31, 32
  116. /* Floating-point registers */
  117. rsave 32, 36
  118. rsave 33, 37
  119. rsave 34, 38
  120. rsave 35, 39
  121. rsave 36, 40
  122. rsave 37, 41
  123. rsave 38, 42
  124. rsave 39, 43
  125. rsave 40, 44
  126. rsave 41, 45
  127. rsave 42, 46
  128. rsave 43, 47
  129. rsave 44, 48
  130. rsave 45, 49
  131. rsave 46, 50
  132. rsave 47, 51
  133. rsave 48, 52
  134. rsave 49, 53
  135. rsave 50, 54
  136. rsave 51, 55
  137. rsave 52, 56
  138. rsave 53, 57
  139. rsave 54, 58
  140. rsave 55, 59
  141. rsave 56, 60
  142. rsave 57, 61
  143. rsave 58, 62
  144. rsave 59, 63
  145. /* SAR register */
  146. rsave 60, 67
  147. /* iaoq[0] return address register */
  148. rsave 61, 65
  149. .balign 8
  150. .Lfde0_end: