ptrace.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. #ifndef _ASM_X86_PTRACE_H
  2. #define _ASM_X86_PTRACE_H
  3. #include <linux/compiler.h> /* For __user */
  4. #include <asm/ptrace-abi.h>
  5. #ifndef __ASSEMBLY__
  6. #ifdef __KERNEL__
  7. /* the DS BTS struct is used for ptrace as well */
  8. #include <asm/ds.h>
  9. struct task_struct;
  10. extern void ptrace_bts_take_timestamp(struct task_struct *, enum bts_qualifier);
  11. #endif /* __KERNEL__ */
  12. #ifdef __i386__
  13. /* this struct defines the way the registers are stored on the
  14. stack during a system call. */
  15. #ifndef __KERNEL__
  16. struct pt_regs {
  17. long ebx;
  18. long ecx;
  19. long edx;
  20. long esi;
  21. long edi;
  22. long ebp;
  23. long eax;
  24. int xds;
  25. int xes;
  26. int xfs;
  27. /* int gs; */
  28. long orig_eax;
  29. long eip;
  30. int xcs;
  31. long eflags;
  32. long esp;
  33. int xss;
  34. };
  35. #else /* __KERNEL__ */
  36. struct pt_regs {
  37. long bx;
  38. long cx;
  39. long dx;
  40. long si;
  41. long di;
  42. long bp;
  43. long ax;
  44. int ds;
  45. int es;
  46. int fs;
  47. /* int gs; */
  48. long orig_ax;
  49. long ip;
  50. int cs;
  51. long flags;
  52. long sp;
  53. int ss;
  54. };
  55. #include <asm/vm86.h>
  56. #include <asm/segment.h>
  57. struct task_struct;
  58. extern void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs, int error_code);
  59. /*
  60. * user_mode_vm(regs) determines whether a register set came from user mode.
  61. * This is true if V8086 mode was enabled OR if the register set was from
  62. * protected mode with RPL-3 CS value. This tricky test checks that with
  63. * one comparison. Many places in the kernel can bypass this full check
  64. * if they have already ruled out V8086 mode, so user_mode(regs) can be used.
  65. */
  66. static inline int user_mode(struct pt_regs *regs)
  67. {
  68. return (regs->cs & SEGMENT_RPL_MASK) == USER_RPL;
  69. }
  70. static inline int user_mode_vm(struct pt_regs *regs)
  71. {
  72. return ((regs->cs & SEGMENT_RPL_MASK) |
  73. (regs->flags & VM_MASK)) >= USER_RPL;
  74. }
  75. static inline int v8086_mode(struct pt_regs *regs)
  76. {
  77. return (regs->flags & VM_MASK);
  78. }
  79. #define instruction_pointer(regs) ((regs)->ip)
  80. #define frame_pointer(regs) ((regs)->bp)
  81. #define stack_pointer(regs) ((unsigned long)(regs))
  82. #define regs_return_value(regs) ((regs)->ax)
  83. extern unsigned long profile_pc(struct pt_regs *regs);
  84. #endif /* __KERNEL__ */
  85. #else /* __i386__ */
  86. #ifndef __KERNEL__
  87. struct pt_regs {
  88. unsigned long r15;
  89. unsigned long r14;
  90. unsigned long r13;
  91. unsigned long r12;
  92. unsigned long rbp;
  93. unsigned long rbx;
  94. /* arguments: non interrupts/non tracing syscalls only save upto here*/
  95. unsigned long r11;
  96. unsigned long r10;
  97. unsigned long r9;
  98. unsigned long r8;
  99. unsigned long rax;
  100. unsigned long rcx;
  101. unsigned long rdx;
  102. unsigned long rsi;
  103. unsigned long rdi;
  104. unsigned long orig_rax;
  105. /* end of arguments */
  106. /* cpu exception frame or undefined */
  107. unsigned long rip;
  108. unsigned long cs;
  109. unsigned long eflags;
  110. unsigned long rsp;
  111. unsigned long ss;
  112. /* top of stack page */
  113. };
  114. #else /* __KERNEL__ */
  115. struct pt_regs {
  116. unsigned long r15;
  117. unsigned long r14;
  118. unsigned long r13;
  119. unsigned long r12;
  120. unsigned long bp;
  121. unsigned long bx;
  122. /* arguments: non interrupts/non tracing syscalls only save upto here*/
  123. unsigned long r11;
  124. unsigned long r10;
  125. unsigned long r9;
  126. unsigned long r8;
  127. unsigned long ax;
  128. unsigned long cx;
  129. unsigned long dx;
  130. unsigned long si;
  131. unsigned long di;
  132. unsigned long orig_ax;
  133. /* end of arguments */
  134. /* cpu exception frame or undefined */
  135. unsigned long ip;
  136. unsigned long cs;
  137. unsigned long flags;
  138. unsigned long sp;
  139. unsigned long ss;
  140. /* top of stack page */
  141. };
  142. #define user_mode(regs) (!!((regs)->cs & 3))
  143. #define user_mode_vm(regs) user_mode(regs)
  144. #define v8086_mode(regs) 0 /* No V86 mode support in long mode */
  145. #define instruction_pointer(regs) ((regs)->ip)
  146. #define frame_pointer(regs) ((regs)->bp)
  147. #define stack_pointer(regs) ((regs)->sp)
  148. #define regs_return_value(regs) ((regs)->ax)
  149. extern unsigned long profile_pc(struct pt_regs *regs);
  150. void signal_fault(struct pt_regs *regs, void __user *frame, char *where);
  151. struct task_struct;
  152. extern unsigned long
  153. convert_rip_to_linear(struct task_struct *child, struct pt_regs *regs);
  154. #endif /* __KERNEL__ */
  155. #endif /* !__i386__ */
  156. #ifdef __KERNEL__
  157. unsigned long get_segment_eip(struct pt_regs *regs, unsigned long *eip_limit);
  158. /*
  159. * These are defined as per linux/ptrace.h, which see.
  160. */
  161. #define arch_has_single_step() (1)
  162. extern void user_enable_single_step(struct task_struct *);
  163. extern void user_disable_single_step(struct task_struct *);
  164. extern void user_enable_block_step(struct task_struct *);
  165. #ifdef CONFIG_X86_DEBUGCTLMSR
  166. #define arch_has_block_step() (1)
  167. #else
  168. #define arch_has_block_step() (boot_cpu_data.x86 >= 6)
  169. #endif
  170. struct user_desc;
  171. extern int do_get_thread_area(struct task_struct *p, int idx,
  172. struct user_desc __user *info);
  173. extern int do_set_thread_area(struct task_struct *p, int idx,
  174. struct user_desc __user *info, int can_allocate);
  175. #endif /* __KERNEL__ */
  176. #endif /* !__ASSEMBLY__ */
  177. #endif