ptrace.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501
  1. /*
  2. * include/asm-s390/ptrace.h
  3. *
  4. * S390 version
  5. * Copyright (C) 1999,2000 IBM Deutschland Entwicklung GmbH, IBM Corporation
  6. * Author(s): Denis Joseph Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com)
  7. */
  8. #ifndef _S390_PTRACE_H
  9. #define _S390_PTRACE_H
  10. /*
  11. * Offsets in the user_regs_struct. They are used for the ptrace
  12. * system call and in entry.S
  13. */
  14. #ifndef __s390x__
  15. #define PT_PSWMASK 0x00
  16. #define PT_PSWADDR 0x04
  17. #define PT_GPR0 0x08
  18. #define PT_GPR1 0x0C
  19. #define PT_GPR2 0x10
  20. #define PT_GPR3 0x14
  21. #define PT_GPR4 0x18
  22. #define PT_GPR5 0x1C
  23. #define PT_GPR6 0x20
  24. #define PT_GPR7 0x24
  25. #define PT_GPR8 0x28
  26. #define PT_GPR9 0x2C
  27. #define PT_GPR10 0x30
  28. #define PT_GPR11 0x34
  29. #define PT_GPR12 0x38
  30. #define PT_GPR13 0x3C
  31. #define PT_GPR14 0x40
  32. #define PT_GPR15 0x44
  33. #define PT_ACR0 0x48
  34. #define PT_ACR1 0x4C
  35. #define PT_ACR2 0x50
  36. #define PT_ACR3 0x54
  37. #define PT_ACR4 0x58
  38. #define PT_ACR5 0x5C
  39. #define PT_ACR6 0x60
  40. #define PT_ACR7 0x64
  41. #define PT_ACR8 0x68
  42. #define PT_ACR9 0x6C
  43. #define PT_ACR10 0x70
  44. #define PT_ACR11 0x74
  45. #define PT_ACR12 0x78
  46. #define PT_ACR13 0x7C
  47. #define PT_ACR14 0x80
  48. #define PT_ACR15 0x84
  49. #define PT_ORIGGPR2 0x88
  50. #define PT_FPC 0x90
  51. /*
  52. * A nasty fact of life that the ptrace api
  53. * only supports passing of longs.
  54. */
  55. #define PT_FPR0_HI 0x98
  56. #define PT_FPR0_LO 0x9C
  57. #define PT_FPR1_HI 0xA0
  58. #define PT_FPR1_LO 0xA4
  59. #define PT_FPR2_HI 0xA8
  60. #define PT_FPR2_LO 0xAC
  61. #define PT_FPR3_HI 0xB0
  62. #define PT_FPR3_LO 0xB4
  63. #define PT_FPR4_HI 0xB8
  64. #define PT_FPR4_LO 0xBC
  65. #define PT_FPR5_HI 0xC0
  66. #define PT_FPR5_LO 0xC4
  67. #define PT_FPR6_HI 0xC8
  68. #define PT_FPR6_LO 0xCC
  69. #define PT_FPR7_HI 0xD0
  70. #define PT_FPR7_LO 0xD4
  71. #define PT_FPR8_HI 0xD8
  72. #define PT_FPR8_LO 0XDC
  73. #define PT_FPR9_HI 0xE0
  74. #define PT_FPR9_LO 0xE4
  75. #define PT_FPR10_HI 0xE8
  76. #define PT_FPR10_LO 0xEC
  77. #define PT_FPR11_HI 0xF0
  78. #define PT_FPR11_LO 0xF4
  79. #define PT_FPR12_HI 0xF8
  80. #define PT_FPR12_LO 0xFC
  81. #define PT_FPR13_HI 0x100
  82. #define PT_FPR13_LO 0x104
  83. #define PT_FPR14_HI 0x108
  84. #define PT_FPR14_LO 0x10C
  85. #define PT_FPR15_HI 0x110
  86. #define PT_FPR15_LO 0x114
  87. #define PT_CR_9 0x118
  88. #define PT_CR_10 0x11C
  89. #define PT_CR_11 0x120
  90. #define PT_IEEE_IP 0x13C
  91. #define PT_LASTOFF PT_IEEE_IP
  92. #define PT_ENDREGS 0x140-1
  93. #define GPR_SIZE 4
  94. #define CR_SIZE 4
  95. #define STACK_FRAME_OVERHEAD 96 /* size of minimum stack frame */
  96. #else /* __s390x__ */
  97. #define PT_PSWMASK 0x00
  98. #define PT_PSWADDR 0x08
  99. #define PT_GPR0 0x10
  100. #define PT_GPR1 0x18
  101. #define PT_GPR2 0x20
  102. #define PT_GPR3 0x28
  103. #define PT_GPR4 0x30
  104. #define PT_GPR5 0x38
  105. #define PT_GPR6 0x40
  106. #define PT_GPR7 0x48
  107. #define PT_GPR8 0x50
  108. #define PT_GPR9 0x58
  109. #define PT_GPR10 0x60
  110. #define PT_GPR11 0x68
  111. #define PT_GPR12 0x70
  112. #define PT_GPR13 0x78
  113. #define PT_GPR14 0x80
  114. #define PT_GPR15 0x88
  115. #define PT_ACR0 0x90
  116. #define PT_ACR1 0x94
  117. #define PT_ACR2 0x98
  118. #define PT_ACR3 0x9C
  119. #define PT_ACR4 0xA0
  120. #define PT_ACR5 0xA4
  121. #define PT_ACR6 0xA8
  122. #define PT_ACR7 0xAC
  123. #define PT_ACR8 0xB0
  124. #define PT_ACR9 0xB4
  125. #define PT_ACR10 0xB8
  126. #define PT_ACR11 0xBC
  127. #define PT_ACR12 0xC0
  128. #define PT_ACR13 0xC4
  129. #define PT_ACR14 0xC8
  130. #define PT_ACR15 0xCC
  131. #define PT_ORIGGPR2 0xD0
  132. #define PT_FPC 0xD8
  133. #define PT_FPR0 0xE0
  134. #define PT_FPR1 0xE8
  135. #define PT_FPR2 0xF0
  136. #define PT_FPR3 0xF8
  137. #define PT_FPR4 0x100
  138. #define PT_FPR5 0x108
  139. #define PT_FPR6 0x110
  140. #define PT_FPR7 0x118
  141. #define PT_FPR8 0x120
  142. #define PT_FPR9 0x128
  143. #define PT_FPR10 0x130
  144. #define PT_FPR11 0x138
  145. #define PT_FPR12 0x140
  146. #define PT_FPR13 0x148
  147. #define PT_FPR14 0x150
  148. #define PT_FPR15 0x158
  149. #define PT_CR_9 0x160
  150. #define PT_CR_10 0x168
  151. #define PT_CR_11 0x170
  152. #define PT_IEEE_IP 0x1A8
  153. #define PT_LASTOFF PT_IEEE_IP
  154. #define PT_ENDREGS 0x1B0-1
  155. #define GPR_SIZE 8
  156. #define CR_SIZE 8
  157. #define STACK_FRAME_OVERHEAD 160 /* size of minimum stack frame */
  158. #endif /* __s390x__ */
  159. #define NUM_GPRS 16
  160. #define NUM_FPRS 16
  161. #define NUM_CRS 16
  162. #define NUM_ACRS 16
  163. #define NUM_CR_WORDS 3
  164. #define FPR_SIZE 8
  165. #define FPC_SIZE 4
  166. #define FPC_PAD_SIZE 4 /* gcc insists on aligning the fpregs */
  167. #define ACR_SIZE 4
  168. #define PTRACE_OLDSETOPTIONS 21
  169. #ifndef __ASSEMBLY__
  170. #include <linux/stddef.h>
  171. #include <linux/types.h>
  172. typedef union
  173. {
  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. {
  185. __u32 fpc;
  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. #define FPC_VALID_MASK 0xF8F8FF03
  193. /* this typedef defines how a Program Status Word looks like */
  194. typedef struct
  195. {
  196. unsigned long mask;
  197. unsigned long addr;
  198. } __attribute__ ((aligned(8))) psw_t;
  199. typedef struct
  200. {
  201. __u32 mask;
  202. __u32 addr;
  203. } __attribute__ ((aligned(8))) psw_compat_t;
  204. #ifndef __s390x__
  205. #define PSW_MASK_PER 0x40000000UL
  206. #define PSW_MASK_DAT 0x04000000UL
  207. #define PSW_MASK_IO 0x02000000UL
  208. #define PSW_MASK_EXT 0x01000000UL
  209. #define PSW_MASK_KEY 0x00F00000UL
  210. #define PSW_MASK_MCHECK 0x00040000UL
  211. #define PSW_MASK_WAIT 0x00020000UL
  212. #define PSW_MASK_PSTATE 0x00010000UL
  213. #define PSW_MASK_ASC 0x0000C000UL
  214. #define PSW_MASK_CC 0x00003000UL
  215. #define PSW_MASK_PM 0x00000F00UL
  216. #define PSW_ADDR_AMODE 0x80000000UL
  217. #define PSW_ADDR_INSN 0x7FFFFFFFUL
  218. #define PSW_BASE_BITS 0x00080000UL
  219. #define PSW_DEFAULT_KEY (((unsigned long) PAGE_DEFAULT_ACC) << 20)
  220. #define PSW_ASC_PRIMARY 0x00000000UL
  221. #define PSW_ASC_ACCREG 0x00004000UL
  222. #define PSW_ASC_SECONDARY 0x00008000UL
  223. #define PSW_ASC_HOME 0x0000C000UL
  224. #else /* __s390x__ */
  225. #define PSW_MASK_PER 0x4000000000000000UL
  226. #define PSW_MASK_DAT 0x0400000000000000UL
  227. #define PSW_MASK_IO 0x0200000000000000UL
  228. #define PSW_MASK_EXT 0x0100000000000000UL
  229. #define PSW_MASK_KEY 0x00F0000000000000UL
  230. #define PSW_MASK_MCHECK 0x0004000000000000UL
  231. #define PSW_MASK_WAIT 0x0002000000000000UL
  232. #define PSW_MASK_PSTATE 0x0001000000000000UL
  233. #define PSW_MASK_ASC 0x0000C00000000000UL
  234. #define PSW_MASK_CC 0x0000300000000000UL
  235. #define PSW_MASK_PM 0x00000F0000000000UL
  236. #define PSW_ADDR_AMODE 0x0000000000000000UL
  237. #define PSW_ADDR_INSN 0xFFFFFFFFFFFFFFFFUL
  238. #define PSW_BASE_BITS 0x0000000180000000UL
  239. #define PSW_BASE32_BITS 0x0000000080000000UL
  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. #ifdef __KERNEL__
  247. extern long psw_kernel_bits;
  248. extern long psw_user_bits;
  249. #ifdef CONFIG_64BIT
  250. extern long psw_user32_bits;
  251. #endif
  252. #endif
  253. /* This macro merges a NEW PSW mask specified by the user into
  254. the currently active PSW mask CURRENT, modifying only those
  255. bits in CURRENT that the user may be allowed to change: this
  256. is the condition code and the program mask bits. */
  257. #define PSW_MASK_MERGE(CURRENT,NEW) \
  258. (((CURRENT) & ~(PSW_MASK_CC|PSW_MASK_PM)) | \
  259. ((NEW) & (PSW_MASK_CC|PSW_MASK_PM)))
  260. /*
  261. * The s390_regs structure is used to define the elf_gregset_t.
  262. */
  263. typedef struct
  264. {
  265. psw_t psw;
  266. unsigned long gprs[NUM_GPRS];
  267. unsigned int acrs[NUM_ACRS];
  268. unsigned long orig_gpr2;
  269. } s390_regs;
  270. typedef struct
  271. {
  272. psw_compat_t psw;
  273. __u32 gprs[NUM_GPRS];
  274. __u32 acrs[NUM_ACRS];
  275. __u32 orig_gpr2;
  276. } s390_compat_regs;
  277. #ifdef __KERNEL__
  278. /*
  279. * The pt_regs struct defines the way the registers are stored on
  280. * the stack during a system call.
  281. */
  282. struct pt_regs
  283. {
  284. unsigned long args[1];
  285. psw_t psw;
  286. unsigned long gprs[NUM_GPRS];
  287. unsigned long orig_gpr2;
  288. unsigned short svcnr;
  289. unsigned short ilc;
  290. };
  291. #endif
  292. /*
  293. * Now for the program event recording (trace) definitions.
  294. */
  295. typedef struct
  296. {
  297. unsigned long cr[NUM_CR_WORDS];
  298. } per_cr_words;
  299. #define PER_EM_MASK 0xE8000000UL
  300. typedef struct
  301. {
  302. #ifdef __s390x__
  303. unsigned : 32;
  304. #endif /* __s390x__ */
  305. unsigned em_branching : 1;
  306. unsigned em_instruction_fetch : 1;
  307. /*
  308. * Switching on storage alteration automatically fixes
  309. * the storage alteration event bit in the users std.
  310. */
  311. unsigned em_storage_alteration : 1;
  312. unsigned em_gpr_alt_unused : 1;
  313. unsigned em_store_real_address : 1;
  314. unsigned : 3;
  315. unsigned branch_addr_ctl : 1;
  316. unsigned : 1;
  317. unsigned storage_alt_space_ctl : 1;
  318. unsigned : 21;
  319. unsigned long starting_addr;
  320. unsigned long ending_addr;
  321. } per_cr_bits;
  322. typedef struct
  323. {
  324. unsigned short perc_atmid;
  325. unsigned long address;
  326. unsigned char access_id;
  327. } per_lowcore_words;
  328. typedef struct
  329. {
  330. unsigned perc_branching : 1;
  331. unsigned perc_instruction_fetch : 1;
  332. unsigned perc_storage_alteration : 1;
  333. unsigned perc_gpr_alt_unused : 1;
  334. unsigned perc_store_real_address : 1;
  335. unsigned : 3;
  336. unsigned atmid_psw_bit_31 : 1;
  337. unsigned atmid_validity_bit : 1;
  338. unsigned atmid_psw_bit_32 : 1;
  339. unsigned atmid_psw_bit_5 : 1;
  340. unsigned atmid_psw_bit_16 : 1;
  341. unsigned atmid_psw_bit_17 : 1;
  342. unsigned si : 2;
  343. unsigned long address;
  344. unsigned : 4;
  345. unsigned access_id : 4;
  346. } per_lowcore_bits;
  347. typedef struct
  348. {
  349. union {
  350. per_cr_words words;
  351. per_cr_bits bits;
  352. } control_regs;
  353. /*
  354. * Use these flags instead of setting em_instruction_fetch
  355. * directly they are used so that single stepping can be
  356. * switched on & off while not affecting other tracing
  357. */
  358. unsigned single_step : 1;
  359. unsigned instruction_fetch : 1;
  360. unsigned : 30;
  361. /*
  362. * These addresses are copied into cr10 & cr11 if single
  363. * stepping is switched off
  364. */
  365. unsigned long starting_addr;
  366. unsigned long ending_addr;
  367. union {
  368. per_lowcore_words words;
  369. per_lowcore_bits bits;
  370. } lowcore;
  371. } per_struct;
  372. typedef struct
  373. {
  374. unsigned int len;
  375. unsigned long kernel_addr;
  376. unsigned long process_addr;
  377. } ptrace_area;
  378. /*
  379. * S/390 specific non posix ptrace requests. I chose unusual values so
  380. * they are unlikely to clash with future ptrace definitions.
  381. */
  382. #define PTRACE_PEEKUSR_AREA 0x5000
  383. #define PTRACE_POKEUSR_AREA 0x5001
  384. #define PTRACE_PEEKTEXT_AREA 0x5002
  385. #define PTRACE_PEEKDATA_AREA 0x5003
  386. #define PTRACE_POKETEXT_AREA 0x5004
  387. #define PTRACE_POKEDATA_AREA 0x5005
  388. /*
  389. * PT_PROT definition is loosely based on hppa bsd definition in
  390. * gdb/hppab-nat.c
  391. */
  392. #define PTRACE_PROT 21
  393. typedef enum
  394. {
  395. ptprot_set_access_watchpoint,
  396. ptprot_set_write_watchpoint,
  397. ptprot_disable_watchpoint
  398. } ptprot_flags;
  399. typedef struct
  400. {
  401. unsigned long lowaddr;
  402. unsigned long hiaddr;
  403. ptprot_flags prot;
  404. } ptprot_area;
  405. /* Sequence of bytes for breakpoint illegal instruction. */
  406. #define S390_BREAKPOINT {0x0,0x1}
  407. #define S390_BREAKPOINT_U16 ((__u16)0x0001)
  408. #define S390_SYSCALL_OPCODE ((__u16)0x0a00)
  409. #define S390_SYSCALL_SIZE 2
  410. /*
  411. * The user_regs_struct defines the way the user registers are
  412. * store on the stack for signal handling.
  413. */
  414. struct user_regs_struct
  415. {
  416. psw_t psw;
  417. unsigned long gprs[NUM_GPRS];
  418. unsigned int acrs[NUM_ACRS];
  419. unsigned long orig_gpr2;
  420. s390_fp_regs fp_regs;
  421. /*
  422. * These per registers are in here so that gdb can modify them
  423. * itself as there is no "official" ptrace interface for hardware
  424. * watchpoints. This is the way intel does it.
  425. */
  426. per_struct per_info;
  427. unsigned long ieee_instruction_pointer;
  428. /* Used to give failing instruction back to user for ieee exceptions */
  429. };
  430. #ifdef __KERNEL__
  431. /*
  432. * These are defined as per linux/ptrace.h, which see.
  433. */
  434. #define arch_has_single_step() (1)
  435. struct task_struct;
  436. extern void user_enable_single_step(struct task_struct *);
  437. extern void user_disable_single_step(struct task_struct *);
  438. #define user_mode(regs) (((regs)->psw.mask & PSW_MASK_PSTATE) != 0)
  439. #define instruction_pointer(regs) ((regs)->psw.addr & PSW_ADDR_INSN)
  440. #define user_stack_pointer(regs)((regs)->gprs[15])
  441. #define regs_return_value(regs)((regs)->gprs[2])
  442. #define profile_pc(regs) instruction_pointer(regs)
  443. extern void show_regs(struct pt_regs * regs);
  444. #endif /* __KERNEL__ */
  445. #endif /* __ASSEMBLY__ */
  446. #endif /* _S390_PTRACE_H */