ptrace.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458
  1. /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
  2. /*
  3. * S390 version
  4. * Copyright IBM Corp. 1999, 2000
  5. * Author(s): Denis Joseph Barrow ([email protected],[email protected])
  6. */
  7. #ifndef _UAPI_S390_PTRACE_H
  8. #define _UAPI_S390_PTRACE_H
  9. /*
  10. * Offsets in the user_regs_struct. They are used for the ptrace
  11. * system call and in entry.S
  12. */
  13. #ifndef __s390x__
  14. #define PT_PSWMASK 0x00
  15. #define PT_PSWADDR 0x04
  16. #define PT_GPR0 0x08
  17. #define PT_GPR1 0x0C
  18. #define PT_GPR2 0x10
  19. #define PT_GPR3 0x14
  20. #define PT_GPR4 0x18
  21. #define PT_GPR5 0x1C
  22. #define PT_GPR6 0x20
  23. #define PT_GPR7 0x24
  24. #define PT_GPR8 0x28
  25. #define PT_GPR9 0x2C
  26. #define PT_GPR10 0x30
  27. #define PT_GPR11 0x34
  28. #define PT_GPR12 0x38
  29. #define PT_GPR13 0x3C
  30. #define PT_GPR14 0x40
  31. #define PT_GPR15 0x44
  32. #define PT_ACR0 0x48
  33. #define PT_ACR1 0x4C
  34. #define PT_ACR2 0x50
  35. #define PT_ACR3 0x54
  36. #define PT_ACR4 0x58
  37. #define PT_ACR5 0x5C
  38. #define PT_ACR6 0x60
  39. #define PT_ACR7 0x64
  40. #define PT_ACR8 0x68
  41. #define PT_ACR9 0x6C
  42. #define PT_ACR10 0x70
  43. #define PT_ACR11 0x74
  44. #define PT_ACR12 0x78
  45. #define PT_ACR13 0x7C
  46. #define PT_ACR14 0x80
  47. #define PT_ACR15 0x84
  48. #define PT_ORIGGPR2 0x88
  49. #define PT_FPC 0x90
  50. /*
  51. * A nasty fact of life that the ptrace api
  52. * only supports passing of longs.
  53. */
  54. #define PT_FPR0_HI 0x98
  55. #define PT_FPR0_LO 0x9C
  56. #define PT_FPR1_HI 0xA0
  57. #define PT_FPR1_LO 0xA4
  58. #define PT_FPR2_HI 0xA8
  59. #define PT_FPR2_LO 0xAC
  60. #define PT_FPR3_HI 0xB0
  61. #define PT_FPR3_LO 0xB4
  62. #define PT_FPR4_HI 0xB8
  63. #define PT_FPR4_LO 0xBC
  64. #define PT_FPR5_HI 0xC0
  65. #define PT_FPR5_LO 0xC4
  66. #define PT_FPR6_HI 0xC8
  67. #define PT_FPR6_LO 0xCC
  68. #define PT_FPR7_HI 0xD0
  69. #define PT_FPR7_LO 0xD4
  70. #define PT_FPR8_HI 0xD8
  71. #define PT_FPR8_LO 0XDC
  72. #define PT_FPR9_HI 0xE0
  73. #define PT_FPR9_LO 0xE4
  74. #define PT_FPR10_HI 0xE8
  75. #define PT_FPR10_LO 0xEC
  76. #define PT_FPR11_HI 0xF0
  77. #define PT_FPR11_LO 0xF4
  78. #define PT_FPR12_HI 0xF8
  79. #define PT_FPR12_LO 0xFC
  80. #define PT_FPR13_HI 0x100
  81. #define PT_FPR13_LO 0x104
  82. #define PT_FPR14_HI 0x108
  83. #define PT_FPR14_LO 0x10C
  84. #define PT_FPR15_HI 0x110
  85. #define PT_FPR15_LO 0x114
  86. #define PT_CR_9 0x118
  87. #define PT_CR_10 0x11C
  88. #define PT_CR_11 0x120
  89. #define PT_IEEE_IP 0x13C
  90. #define PT_LASTOFF PT_IEEE_IP
  91. #define PT_ENDREGS 0x140-1
  92. #define GPR_SIZE 4
  93. #define CR_SIZE 4
  94. #define STACK_FRAME_OVERHEAD 96 /* size of minimum stack frame */
  95. #else /* __s390x__ */
  96. #define PT_PSWMASK 0x00
  97. #define PT_PSWADDR 0x08
  98. #define PT_GPR0 0x10
  99. #define PT_GPR1 0x18
  100. #define PT_GPR2 0x20
  101. #define PT_GPR3 0x28
  102. #define PT_GPR4 0x30
  103. #define PT_GPR5 0x38
  104. #define PT_GPR6 0x40
  105. #define PT_GPR7 0x48
  106. #define PT_GPR8 0x50
  107. #define PT_GPR9 0x58
  108. #define PT_GPR10 0x60
  109. #define PT_GPR11 0x68
  110. #define PT_GPR12 0x70
  111. #define PT_GPR13 0x78
  112. #define PT_GPR14 0x80
  113. #define PT_GPR15 0x88
  114. #define PT_ACR0 0x90
  115. #define PT_ACR1 0x94
  116. #define PT_ACR2 0x98
  117. #define PT_ACR3 0x9C
  118. #define PT_ACR4 0xA0
  119. #define PT_ACR5 0xA4
  120. #define PT_ACR6 0xA8
  121. #define PT_ACR7 0xAC
  122. #define PT_ACR8 0xB0
  123. #define PT_ACR9 0xB4
  124. #define PT_ACR10 0xB8
  125. #define PT_ACR11 0xBC
  126. #define PT_ACR12 0xC0
  127. #define PT_ACR13 0xC4
  128. #define PT_ACR14 0xC8
  129. #define PT_ACR15 0xCC
  130. #define PT_ORIGGPR2 0xD0
  131. #define PT_FPC 0xD8
  132. #define PT_FPR0 0xE0
  133. #define PT_FPR1 0xE8
  134. #define PT_FPR2 0xF0
  135. #define PT_FPR3 0xF8
  136. #define PT_FPR4 0x100
  137. #define PT_FPR5 0x108
  138. #define PT_FPR6 0x110
  139. #define PT_FPR7 0x118
  140. #define PT_FPR8 0x120
  141. #define PT_FPR9 0x128
  142. #define PT_FPR10 0x130
  143. #define PT_FPR11 0x138
  144. #define PT_FPR12 0x140
  145. #define PT_FPR13 0x148
  146. #define PT_FPR14 0x150
  147. #define PT_FPR15 0x158
  148. #define PT_CR_9 0x160
  149. #define PT_CR_10 0x168
  150. #define PT_CR_11 0x170
  151. #define PT_IEEE_IP 0x1A8
  152. #define PT_LASTOFF PT_IEEE_IP
  153. #define PT_ENDREGS 0x1B0-1
  154. #define GPR_SIZE 8
  155. #define CR_SIZE 8
  156. #define STACK_FRAME_OVERHEAD 160 /* size of minimum stack frame */
  157. #endif /* __s390x__ */
  158. #define NUM_GPRS 16
  159. #define NUM_FPRS 16
  160. #define NUM_CRS 16
  161. #define NUM_ACRS 16
  162. #define NUM_CR_WORDS 3
  163. #define FPR_SIZE 8
  164. #define FPC_SIZE 4
  165. #define FPC_PAD_SIZE 4 /* gcc insists on aligning the fpregs */
  166. #define ACR_SIZE 4
  167. #define PTRACE_OLDSETOPTIONS 21
  168. #define PTRACE_SYSEMU 31
  169. #define PTRACE_SYSEMU_SINGLESTEP 32
  170. #ifndef __ASSEMBLY__
  171. #include <linux/stddef.h>
  172. #include <linux/types.h>
  173. typedef union {
  174. float f;
  175. double d;
  176. __u64 ui;
  177. struct
  178. {
  179. __u32 hi;
  180. __u32 lo;
  181. } fp;
  182. } freg_t;
  183. typedef struct {
  184. __u32 fpc;
  185. __u32 pad;
  186. freg_t fprs[NUM_FPRS];
  187. } s390_fp_regs;
  188. #define FPC_EXCEPTION_MASK 0xF8000000
  189. #define FPC_FLAGS_MASK 0x00F80000
  190. #define FPC_DXC_MASK 0x0000FF00
  191. #define FPC_RM_MASK 0x00000003
  192. /* this typedef defines how a Program Status Word looks like */
  193. typedef struct {
  194. unsigned long mask;
  195. unsigned long addr;
  196. } __attribute__ ((aligned(8))) psw_t;
  197. #ifndef __s390x__
  198. #define PSW_MASK_PER 0x40000000UL
  199. #define PSW_MASK_DAT 0x04000000UL
  200. #define PSW_MASK_IO 0x02000000UL
  201. #define PSW_MASK_EXT 0x01000000UL
  202. #define PSW_MASK_KEY 0x00F00000UL
  203. #define PSW_MASK_BASE 0x00080000UL /* always one */
  204. #define PSW_MASK_MCHECK 0x00040000UL
  205. #define PSW_MASK_WAIT 0x00020000UL
  206. #define PSW_MASK_PSTATE 0x00010000UL
  207. #define PSW_MASK_ASC 0x0000C000UL
  208. #define PSW_MASK_CC 0x00003000UL
  209. #define PSW_MASK_PM 0x00000F00UL
  210. #define PSW_MASK_RI 0x00000000UL
  211. #define PSW_MASK_EA 0x00000000UL
  212. #define PSW_MASK_BA 0x00000000UL
  213. #define PSW_MASK_USER 0x0000FF00UL
  214. #define PSW_ADDR_AMODE 0x80000000UL
  215. #define PSW_ADDR_INSN 0x7FFFFFFFUL
  216. #define PSW_DEFAULT_KEY (((unsigned long) PAGE_DEFAULT_ACC) << 20)
  217. #define PSW_ASC_PRIMARY 0x00000000UL
  218. #define PSW_ASC_ACCREG 0x00004000UL
  219. #define PSW_ASC_SECONDARY 0x00008000UL
  220. #define PSW_ASC_HOME 0x0000C000UL
  221. #else /* __s390x__ */
  222. #define PSW_MASK_PER 0x4000000000000000UL
  223. #define PSW_MASK_DAT 0x0400000000000000UL
  224. #define PSW_MASK_IO 0x0200000000000000UL
  225. #define PSW_MASK_EXT 0x0100000000000000UL
  226. #define PSW_MASK_BASE 0x0000000000000000UL
  227. #define PSW_MASK_KEY 0x00F0000000000000UL
  228. #define PSW_MASK_MCHECK 0x0004000000000000UL
  229. #define PSW_MASK_WAIT 0x0002000000000000UL
  230. #define PSW_MASK_PSTATE 0x0001000000000000UL
  231. #define PSW_MASK_ASC 0x0000C00000000000UL
  232. #define PSW_MASK_CC 0x0000300000000000UL
  233. #define PSW_MASK_PM 0x00000F0000000000UL
  234. #define PSW_MASK_RI 0x0000008000000000UL
  235. #define PSW_MASK_EA 0x0000000100000000UL
  236. #define PSW_MASK_BA 0x0000000080000000UL
  237. #define PSW_MASK_USER 0x0000FF0180000000UL
  238. #define PSW_ADDR_AMODE 0x0000000000000000UL
  239. #define PSW_ADDR_INSN 0xFFFFFFFFFFFFFFFFUL
  240. #define PSW_DEFAULT_KEY (((unsigned long) PAGE_DEFAULT_ACC) << 52)
  241. #define PSW_ASC_PRIMARY 0x0000000000000000UL
  242. #define PSW_ASC_ACCREG 0x0000400000000000UL
  243. #define PSW_ASC_SECONDARY 0x0000800000000000UL
  244. #define PSW_ASC_HOME 0x0000C00000000000UL
  245. #endif /* __s390x__ */
  246. /*
  247. * The s390_regs structure is used to define the elf_gregset_t.
  248. */
  249. typedef struct {
  250. psw_t psw;
  251. unsigned long gprs[NUM_GPRS];
  252. unsigned int acrs[NUM_ACRS];
  253. unsigned long orig_gpr2;
  254. } s390_regs;
  255. /*
  256. * The user_pt_regs structure exports the beginning of
  257. * the in-kernel pt_regs structure to user space.
  258. */
  259. typedef struct {
  260. unsigned long args[1];
  261. psw_t psw;
  262. unsigned long gprs[NUM_GPRS];
  263. } user_pt_regs;
  264. /*
  265. * Now for the user space program event recording (trace) definitions.
  266. * The following structures are used only for the ptrace interface, don't
  267. * touch or even look at it if you don't want to modify the user-space
  268. * ptrace interface. In particular stay away from it for in-kernel PER.
  269. */
  270. typedef struct {
  271. unsigned long cr[NUM_CR_WORDS];
  272. } per_cr_words;
  273. #define PER_EM_MASK 0xE8000000UL
  274. typedef struct {
  275. #ifdef __s390x__
  276. unsigned : 32;
  277. #endif /* __s390x__ */
  278. unsigned em_branching : 1;
  279. unsigned em_instruction_fetch : 1;
  280. /*
  281. * Switching on storage alteration automatically fixes
  282. * the storage alteration event bit in the users std.
  283. */
  284. unsigned em_storage_alteration : 1;
  285. unsigned em_gpr_alt_unused : 1;
  286. unsigned em_store_real_address : 1;
  287. unsigned : 3;
  288. unsigned branch_addr_ctl : 1;
  289. unsigned : 1;
  290. unsigned storage_alt_space_ctl : 1;
  291. unsigned : 21;
  292. unsigned long starting_addr;
  293. unsigned long ending_addr;
  294. } per_cr_bits;
  295. typedef struct {
  296. unsigned short perc_atmid;
  297. unsigned long address;
  298. unsigned char access_id;
  299. } per_lowcore_words;
  300. typedef struct {
  301. unsigned perc_branching : 1;
  302. unsigned perc_instruction_fetch : 1;
  303. unsigned perc_storage_alteration : 1;
  304. unsigned perc_gpr_alt_unused : 1;
  305. unsigned perc_store_real_address : 1;
  306. unsigned : 3;
  307. unsigned atmid_psw_bit_31 : 1;
  308. unsigned atmid_validity_bit : 1;
  309. unsigned atmid_psw_bit_32 : 1;
  310. unsigned atmid_psw_bit_5 : 1;
  311. unsigned atmid_psw_bit_16 : 1;
  312. unsigned atmid_psw_bit_17 : 1;
  313. unsigned si : 2;
  314. unsigned long address;
  315. unsigned : 4;
  316. unsigned access_id : 4;
  317. } per_lowcore_bits;
  318. typedef struct {
  319. union {
  320. per_cr_words words;
  321. per_cr_bits bits;
  322. } control_regs;
  323. /*
  324. * The single_step and instruction_fetch bits are obsolete,
  325. * the kernel always sets them to zero. To enable single
  326. * stepping use ptrace(PTRACE_SINGLESTEP) instead.
  327. */
  328. unsigned single_step : 1;
  329. unsigned instruction_fetch : 1;
  330. unsigned : 30;
  331. /*
  332. * These addresses are copied into cr10 & cr11 if single
  333. * stepping is switched off
  334. */
  335. unsigned long starting_addr;
  336. unsigned long ending_addr;
  337. union {
  338. per_lowcore_words words;
  339. per_lowcore_bits bits;
  340. } lowcore;
  341. } per_struct;
  342. typedef struct {
  343. unsigned int len;
  344. unsigned long kernel_addr;
  345. unsigned long process_addr;
  346. } ptrace_area;
  347. /*
  348. * S/390 specific non posix ptrace requests. I chose unusual values so
  349. * they are unlikely to clash with future ptrace definitions.
  350. */
  351. #define PTRACE_PEEKUSR_AREA 0x5000
  352. #define PTRACE_POKEUSR_AREA 0x5001
  353. #define PTRACE_PEEKTEXT_AREA 0x5002
  354. #define PTRACE_PEEKDATA_AREA 0x5003
  355. #define PTRACE_POKETEXT_AREA 0x5004
  356. #define PTRACE_POKEDATA_AREA 0x5005
  357. #define PTRACE_GET_LAST_BREAK 0x5006
  358. #define PTRACE_PEEK_SYSTEM_CALL 0x5007
  359. #define PTRACE_POKE_SYSTEM_CALL 0x5008
  360. #define PTRACE_ENABLE_TE 0x5009
  361. #define PTRACE_DISABLE_TE 0x5010
  362. #define PTRACE_TE_ABORT_RAND 0x5011
  363. /*
  364. * The numbers chosen here are somewhat arbitrary but absolutely MUST
  365. * not overlap with any of the number assigned in <linux/ptrace.h>.
  366. */
  367. #define PTRACE_SINGLEBLOCK 12 /* resume execution until next branch */
  368. /*
  369. * PT_PROT definition is loosely based on hppa bsd definition in
  370. * gdb/hppab-nat.c
  371. */
  372. #define PTRACE_PROT 21
  373. typedef enum {
  374. ptprot_set_access_watchpoint,
  375. ptprot_set_write_watchpoint,
  376. ptprot_disable_watchpoint
  377. } ptprot_flags;
  378. typedef struct {
  379. unsigned long lowaddr;
  380. unsigned long hiaddr;
  381. ptprot_flags prot;
  382. } ptprot_area;
  383. /* Sequence of bytes for breakpoint illegal instruction. */
  384. #define S390_BREAKPOINT {0x0,0x1}
  385. #define S390_BREAKPOINT_U16 ((__u16)0x0001)
  386. #define S390_SYSCALL_OPCODE ((__u16)0x0a00)
  387. #define S390_SYSCALL_SIZE 2
  388. /*
  389. * The user_regs_struct defines the way the user registers are
  390. * store on the stack for signal handling.
  391. */
  392. struct user_regs_struct {
  393. psw_t psw;
  394. unsigned long gprs[NUM_GPRS];
  395. unsigned int acrs[NUM_ACRS];
  396. unsigned long orig_gpr2;
  397. s390_fp_regs fp_regs;
  398. /*
  399. * These per registers are in here so that gdb can modify them
  400. * itself as there is no "official" ptrace interface for hardware
  401. * watchpoints. This is the way intel does it.
  402. */
  403. per_struct per_info;
  404. unsigned long ieee_instruction_pointer; /* obsolete, always 0 */
  405. };
  406. #endif /* __ASSEMBLY__ */
  407. #endif /* _UAPI_S390_PTRACE_H */