ptrace.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. /*
  2. * S390 version
  3. * Copyright IBM Corp. 1999, 2000
  4. * Author(s): Denis Joseph Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com)
  5. */
  6. #ifndef _S390_PTRACE_H
  7. #define _S390_PTRACE_H
  8. #include <linux/const.h>
  9. #include <uapi/asm/ptrace.h>
  10. #define PIF_SYSCALL 0 /* inside a system call */
  11. #define PIF_PER_TRAP 1 /* deliver sigtrap on return to user */
  12. #define _PIF_SYSCALL _BITUL(PIF_SYSCALL)
  13. #define _PIF_PER_TRAP _BITUL(PIF_PER_TRAP)
  14. #ifndef __ASSEMBLY__
  15. #define PSW_KERNEL_BITS (PSW_DEFAULT_KEY | PSW_MASK_BASE | PSW_ASC_HOME | \
  16. PSW_MASK_EA | PSW_MASK_BA)
  17. #define PSW_USER_BITS (PSW_MASK_DAT | PSW_MASK_IO | PSW_MASK_EXT | \
  18. PSW_DEFAULT_KEY | PSW_MASK_BASE | PSW_MASK_MCHECK | \
  19. PSW_MASK_PSTATE | PSW_ASC_PRIMARY)
  20. struct psw_bits {
  21. unsigned long : 1;
  22. unsigned long r : 1; /* PER-Mask */
  23. unsigned long : 3;
  24. unsigned long t : 1; /* DAT Mode */
  25. unsigned long i : 1; /* Input/Output Mask */
  26. unsigned long e : 1; /* External Mask */
  27. unsigned long key : 4; /* PSW Key */
  28. unsigned long : 1;
  29. unsigned long m : 1; /* Machine-Check Mask */
  30. unsigned long w : 1; /* Wait State */
  31. unsigned long p : 1; /* Problem State */
  32. unsigned long as : 2; /* Address Space Control */
  33. unsigned long cc : 2; /* Condition Code */
  34. unsigned long pm : 4; /* Program Mask */
  35. unsigned long ri : 1; /* Runtime Instrumentation */
  36. unsigned long : 6;
  37. unsigned long eaba : 2; /* Addressing Mode */
  38. unsigned long : 31;
  39. unsigned long ia : 64; /* Instruction Address */
  40. };
  41. enum {
  42. PSW_AMODE_24BIT = 0,
  43. PSW_AMODE_31BIT = 1,
  44. PSW_AMODE_64BIT = 3
  45. };
  46. enum {
  47. PSW_AS_PRIMARY = 0,
  48. PSW_AS_ACCREG = 1,
  49. PSW_AS_SECONDARY = 2,
  50. PSW_AS_HOME = 3
  51. };
  52. #define psw_bits(__psw) (*({ \
  53. typecheck(psw_t, __psw); \
  54. &(*(struct psw_bits *)(&(__psw))); \
  55. }))
  56. /*
  57. * The pt_regs struct defines the way the registers are stored on
  58. * the stack during a system call.
  59. */
  60. struct pt_regs
  61. {
  62. unsigned long args[1];
  63. psw_t psw;
  64. unsigned long gprs[NUM_GPRS];
  65. unsigned long orig_gpr2;
  66. unsigned int int_code;
  67. unsigned int int_parm;
  68. unsigned long int_parm_long;
  69. unsigned long flags;
  70. };
  71. /*
  72. * Program event recording (PER) register set.
  73. */
  74. struct per_regs {
  75. unsigned long control; /* PER control bits */
  76. unsigned long start; /* PER starting address */
  77. unsigned long end; /* PER ending address */
  78. };
  79. /*
  80. * PER event contains information about the cause of the last PER exception.
  81. */
  82. struct per_event {
  83. unsigned short cause; /* PER code, ATMID and AI */
  84. unsigned long address; /* PER address */
  85. unsigned char paid; /* PER access identification */
  86. };
  87. /*
  88. * Simplified per_info structure used to decode the ptrace user space ABI.
  89. */
  90. struct per_struct_kernel {
  91. unsigned long cr9; /* PER control bits */
  92. unsigned long cr10; /* PER starting address */
  93. unsigned long cr11; /* PER ending address */
  94. unsigned long bits; /* Obsolete software bits */
  95. unsigned long starting_addr; /* User specified start address */
  96. unsigned long ending_addr; /* User specified end address */
  97. unsigned short perc_atmid; /* PER trap ATMID */
  98. unsigned long address; /* PER trap instruction address */
  99. unsigned char access_id; /* PER trap access identification */
  100. };
  101. #define PER_EVENT_MASK 0xEB000000UL
  102. #define PER_EVENT_BRANCH 0x80000000UL
  103. #define PER_EVENT_IFETCH 0x40000000UL
  104. #define PER_EVENT_STORE 0x20000000UL
  105. #define PER_EVENT_STORE_REAL 0x08000000UL
  106. #define PER_EVENT_TRANSACTION_END 0x02000000UL
  107. #define PER_EVENT_NULLIFICATION 0x01000000UL
  108. #define PER_CONTROL_MASK 0x00e00000UL
  109. #define PER_CONTROL_BRANCH_ADDRESS 0x00800000UL
  110. #define PER_CONTROL_SUSPENSION 0x00400000UL
  111. #define PER_CONTROL_ALTERATION 0x00200000UL
  112. static inline void set_pt_regs_flag(struct pt_regs *regs, int flag)
  113. {
  114. regs->flags |= (1UL << flag);
  115. }
  116. static inline void clear_pt_regs_flag(struct pt_regs *regs, int flag)
  117. {
  118. regs->flags &= ~(1UL << flag);
  119. }
  120. static inline int test_pt_regs_flag(struct pt_regs *regs, int flag)
  121. {
  122. return !!(regs->flags & (1UL << flag));
  123. }
  124. /*
  125. * These are defined as per linux/ptrace.h, which see.
  126. */
  127. #define arch_has_single_step() (1)
  128. #define arch_has_block_step() (1)
  129. #define user_mode(regs) (((regs)->psw.mask & PSW_MASK_PSTATE) != 0)
  130. #define instruction_pointer(regs) ((regs)->psw.addr)
  131. #define user_stack_pointer(regs)((regs)->gprs[15])
  132. #define profile_pc(regs) instruction_pointer(regs)
  133. static inline long regs_return_value(struct pt_regs *regs)
  134. {
  135. return regs->gprs[2];
  136. }
  137. static inline void instruction_pointer_set(struct pt_regs *regs,
  138. unsigned long val)
  139. {
  140. regs->psw.addr = val;
  141. }
  142. int regs_query_register_offset(const char *name);
  143. const char *regs_query_register_name(unsigned int offset);
  144. unsigned long regs_get_register(struct pt_regs *regs, unsigned int offset);
  145. unsigned long regs_get_kernel_stack_nth(struct pt_regs *regs, unsigned int n);
  146. static inline unsigned long kernel_stack_pointer(struct pt_regs *regs)
  147. {
  148. return regs->gprs[15];
  149. }
  150. #endif /* __ASSEMBLY__ */
  151. #endif /* _S390_PTRACE_H */