ptrace.h 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
  2. /*
  3. * Copyright (C) 2001 PPC64 Team, IBM Corp
  4. *
  5. * This struct defines the way the registers are stored on the
  6. * kernel stack during a system call or other kernel entry.
  7. *
  8. * this should only contain volatile regs
  9. * since we can keep non-volatile in the thread_struct
  10. * should set this up when only volatiles are saved
  11. * by intr code.
  12. *
  13. * Since this is going on the stack, *CARE MUST BE TAKEN* to insure
  14. * that the overall structure is a multiple of 16 bytes in length.
  15. *
  16. * Note that the offsets of the fields in this struct correspond with
  17. * the PT_* values below. This simplifies arch/powerpc/kernel/ptrace.c.
  18. *
  19. * This program is free software; you can redistribute it and/or
  20. * modify it under the terms of the GNU General Public License
  21. * as published by the Free Software Foundation; either version
  22. * 2 of the License, or (at your option) any later version.
  23. */
  24. #ifndef _UAPI_ASM_POWERPC_PTRACE_H
  25. #define _UAPI_ASM_POWERPC_PTRACE_H
  26. #include <linux/types.h>
  27. #ifndef __ASSEMBLY__
  28. #ifdef __KERNEL__
  29. struct user_pt_regs
  30. #else
  31. struct pt_regs
  32. #endif
  33. {
  34. unsigned long gpr[32];
  35. unsigned long nip;
  36. unsigned long msr;
  37. unsigned long orig_gpr3; /* Used for restarting system calls */
  38. unsigned long ctr;
  39. unsigned long link;
  40. unsigned long xer;
  41. unsigned long ccr;
  42. #ifdef __powerpc64__
  43. unsigned long softe; /* Soft enabled/disabled */
  44. #else
  45. unsigned long mq; /* 601 only (not used at present) */
  46. /* Used on APUS to hold IPL value. */
  47. #endif
  48. unsigned long trap; /* Reason for being here */
  49. /* N.B. for critical exceptions on 4xx, the dar and dsisr
  50. fields are overloaded to hold srr0 and srr1. */
  51. unsigned long dar; /* Fault registers */
  52. unsigned long dsisr; /* on 4xx/Book-E used for ESR */
  53. unsigned long result; /* Result of a system call */
  54. };
  55. #endif /* __ASSEMBLY__ */
  56. /*
  57. * Offsets used by 'ptrace' system call interface.
  58. * These can't be changed without breaking binary compatibility
  59. * with MkLinux, etc.
  60. */
  61. #define PT_R0 0
  62. #define PT_R1 1
  63. #define PT_R2 2
  64. #define PT_R3 3
  65. #define PT_R4 4
  66. #define PT_R5 5
  67. #define PT_R6 6
  68. #define PT_R7 7
  69. #define PT_R8 8
  70. #define PT_R9 9
  71. #define PT_R10 10
  72. #define PT_R11 11
  73. #define PT_R12 12
  74. #define PT_R13 13
  75. #define PT_R14 14
  76. #define PT_R15 15
  77. #define PT_R16 16
  78. #define PT_R17 17
  79. #define PT_R18 18
  80. #define PT_R19 19
  81. #define PT_R20 20
  82. #define PT_R21 21
  83. #define PT_R22 22
  84. #define PT_R23 23
  85. #define PT_R24 24
  86. #define PT_R25 25
  87. #define PT_R26 26
  88. #define PT_R27 27
  89. #define PT_R28 28
  90. #define PT_R29 29
  91. #define PT_R30 30
  92. #define PT_R31 31
  93. #define PT_NIP 32
  94. #define PT_MSR 33
  95. #define PT_ORIG_R3 34
  96. #define PT_CTR 35
  97. #define PT_LNK 36
  98. #define PT_XER 37
  99. #define PT_CCR 38
  100. #ifndef __powerpc64__
  101. #define PT_MQ 39
  102. #else
  103. #define PT_SOFTE 39
  104. #endif
  105. #define PT_TRAP 40
  106. #define PT_DAR 41
  107. #define PT_DSISR 42
  108. #define PT_RESULT 43
  109. #define PT_DSCR 44
  110. #define PT_REGS_COUNT 44
  111. #define PT_FPR0 48 /* each FP reg occupies 2 slots in this space */
  112. #ifndef __powerpc64__
  113. #define PT_FPR31 (PT_FPR0 + 2*31)
  114. #define PT_FPSCR (PT_FPR0 + 2*32 + 1)
  115. #else /* __powerpc64__ */
  116. #define PT_FPSCR (PT_FPR0 + 32) /* each FP reg occupies 1 slot in 64-bit space */
  117. #define PT_VR0 82 /* each Vector reg occupies 2 slots in 64-bit */
  118. #define PT_VSCR (PT_VR0 + 32*2 + 1)
  119. #define PT_VRSAVE (PT_VR0 + 33*2)
  120. /*
  121. * Only store first 32 VSRs here. The second 32 VSRs in VR0-31
  122. */
  123. #define PT_VSR0 150 /* each VSR reg occupies 2 slots in 64-bit */
  124. #define PT_VSR31 (PT_VSR0 + 2*31)
  125. #endif /* __powerpc64__ */
  126. /*
  127. * Get/set all the altivec registers v0..v31, vscr, vrsave, in one go.
  128. * The transfer totals 34 quadword. Quadwords 0-31 contain the
  129. * corresponding vector registers. Quadword 32 contains the vscr as the
  130. * last word (offset 12) within that quadword. Quadword 33 contains the
  131. * vrsave as the first word (offset 0) within the quadword.
  132. *
  133. * This definition of the VMX state is compatible with the current PPC32
  134. * ptrace interface. This allows signal handling and ptrace to use the same
  135. * structures. This also simplifies the implementation of a bi-arch
  136. * (combined (32- and 64-bit) gdb.
  137. */
  138. #define PTRACE_GETVRREGS 0x12
  139. #define PTRACE_SETVRREGS 0x13
  140. /* Get/set all the upper 32-bits of the SPE registers, accumulator, and
  141. * spefscr, in one go */
  142. #define PTRACE_GETEVRREGS 0x14
  143. #define PTRACE_SETEVRREGS 0x15
  144. /* Get the first 32 128bit VSX registers */
  145. #define PTRACE_GETVSRREGS 0x1b
  146. #define PTRACE_SETVSRREGS 0x1c
  147. /* Syscall emulation defines */
  148. #define PTRACE_SYSEMU 0x1d
  149. #define PTRACE_SYSEMU_SINGLESTEP 0x1e
  150. /*
  151. * Get or set a debug register. The first 16 are DABR registers and the
  152. * second 16 are IABR registers.
  153. */
  154. #define PTRACE_GET_DEBUGREG 0x19
  155. #define PTRACE_SET_DEBUGREG 0x1a
  156. /* (new) PTRACE requests using the same numbers as x86 and the same
  157. * argument ordering. Additionally, they support more registers too
  158. */
  159. #define PTRACE_GETREGS 0xc
  160. #define PTRACE_SETREGS 0xd
  161. #define PTRACE_GETFPREGS 0xe
  162. #define PTRACE_SETFPREGS 0xf
  163. #define PTRACE_GETREGS64 0x16
  164. #define PTRACE_SETREGS64 0x17
  165. /* Calls to trace a 64bit program from a 32bit program */
  166. #define PPC_PTRACE_PEEKTEXT_3264 0x95
  167. #define PPC_PTRACE_PEEKDATA_3264 0x94
  168. #define PPC_PTRACE_POKETEXT_3264 0x93
  169. #define PPC_PTRACE_POKEDATA_3264 0x92
  170. #define PPC_PTRACE_PEEKUSR_3264 0x91
  171. #define PPC_PTRACE_POKEUSR_3264 0x90
  172. #define PTRACE_SINGLEBLOCK 0x100 /* resume execution until next branch */
  173. #define PPC_PTRACE_GETHWDBGINFO 0x89
  174. #define PPC_PTRACE_SETHWDEBUG 0x88
  175. #define PPC_PTRACE_DELHWDEBUG 0x87
  176. #ifndef __ASSEMBLY__
  177. struct ppc_debug_info {
  178. __u32 version; /* Only version 1 exists to date */
  179. __u32 num_instruction_bps;
  180. __u32 num_data_bps;
  181. __u32 num_condition_regs;
  182. __u32 data_bp_alignment;
  183. __u32 sizeof_condition; /* size of the DVC register */
  184. __u64 features;
  185. };
  186. #endif /* __ASSEMBLY__ */
  187. /*
  188. * features will have bits indication whether there is support for:
  189. */
  190. #define PPC_DEBUG_FEATURE_INSN_BP_RANGE 0x0000000000000001
  191. #define PPC_DEBUG_FEATURE_INSN_BP_MASK 0x0000000000000002
  192. #define PPC_DEBUG_FEATURE_DATA_BP_RANGE 0x0000000000000004
  193. #define PPC_DEBUG_FEATURE_DATA_BP_MASK 0x0000000000000008
  194. #define PPC_DEBUG_FEATURE_DATA_BP_DAWR 0x0000000000000010
  195. #define PPC_DEBUG_FEATURE_DATA_BP_ARCH_31 0x0000000000000020
  196. #ifndef __ASSEMBLY__
  197. struct ppc_hw_breakpoint {
  198. __u32 version; /* currently, version must be 1 */
  199. __u32 trigger_type; /* only some combinations allowed */
  200. __u32 addr_mode; /* address match mode */
  201. __u32 condition_mode; /* break/watchpoint condition flags */
  202. __u64 addr; /* break/watchpoint address */
  203. __u64 addr2; /* range end or mask */
  204. __u64 condition_value; /* contents of the DVC register */
  205. };
  206. #endif /* __ASSEMBLY__ */
  207. /*
  208. * Trigger Type
  209. */
  210. #define PPC_BREAKPOINT_TRIGGER_EXECUTE 0x00000001
  211. #define PPC_BREAKPOINT_TRIGGER_READ 0x00000002
  212. #define PPC_BREAKPOINT_TRIGGER_WRITE 0x00000004
  213. #define PPC_BREAKPOINT_TRIGGER_RW \
  214. (PPC_BREAKPOINT_TRIGGER_READ | PPC_BREAKPOINT_TRIGGER_WRITE)
  215. /*
  216. * Address Mode
  217. */
  218. #define PPC_BREAKPOINT_MODE_EXACT 0x00000000
  219. #define PPC_BREAKPOINT_MODE_RANGE_INCLUSIVE 0x00000001
  220. #define PPC_BREAKPOINT_MODE_RANGE_EXCLUSIVE 0x00000002
  221. #define PPC_BREAKPOINT_MODE_MASK 0x00000003
  222. /*
  223. * Condition Mode
  224. */
  225. #define PPC_BREAKPOINT_CONDITION_MODE 0x00000003
  226. #define PPC_BREAKPOINT_CONDITION_NONE 0x00000000
  227. #define PPC_BREAKPOINT_CONDITION_AND 0x00000001
  228. #define PPC_BREAKPOINT_CONDITION_EXACT PPC_BREAKPOINT_CONDITION_AND
  229. #define PPC_BREAKPOINT_CONDITION_OR 0x00000002
  230. #define PPC_BREAKPOINT_CONDITION_AND_OR 0x00000003
  231. #define PPC_BREAKPOINT_CONDITION_BE_ALL 0x00ff0000
  232. #define PPC_BREAKPOINT_CONDITION_BE_SHIFT 16
  233. #define PPC_BREAKPOINT_CONDITION_BE(n) \
  234. (1<<((n)+PPC_BREAKPOINT_CONDITION_BE_SHIFT))
  235. #endif /* _UAPI_ASM_POWERPC_PTRACE_H */