ptrace.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  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 unsigned long
  59. convert_ip_to_linear(struct task_struct *child, struct pt_regs *regs);
  60. extern void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs, int error_code);
  61. /*
  62. * user_mode_vm(regs) determines whether a register set came from user mode.
  63. * This is true if V8086 mode was enabled OR if the register set was from
  64. * protected mode with RPL-3 CS value. This tricky test checks that with
  65. * one comparison. Many places in the kernel can bypass this full check
  66. * if they have already ruled out V8086 mode, so user_mode(regs) can be used.
  67. */
  68. static inline int user_mode(struct pt_regs *regs)
  69. {
  70. return (regs->cs & SEGMENT_RPL_MASK) == USER_RPL;
  71. }
  72. static inline int user_mode_vm(struct pt_regs *regs)
  73. {
  74. return ((regs->cs & SEGMENT_RPL_MASK) |
  75. (regs->flags & VM_MASK)) >= USER_RPL;
  76. }
  77. static inline int v8086_mode(struct pt_regs *regs)
  78. {
  79. return (regs->flags & VM_MASK);
  80. }
  81. #define instruction_pointer(regs) ((regs)->ip)
  82. #define frame_pointer(regs) ((regs)->bp)
  83. #define stack_pointer(regs) ((unsigned long)(regs))
  84. #define regs_return_value(regs) ((regs)->ax)
  85. extern unsigned long profile_pc(struct pt_regs *regs);
  86. #endif /* __KERNEL__ */
  87. #else /* __i386__ */
  88. #ifndef __KERNEL__
  89. struct pt_regs {
  90. unsigned long r15;
  91. unsigned long r14;
  92. unsigned long r13;
  93. unsigned long r12;
  94. unsigned long rbp;
  95. unsigned long rbx;
  96. /* arguments: non interrupts/non tracing syscalls only save upto here*/
  97. unsigned long r11;
  98. unsigned long r10;
  99. unsigned long r9;
  100. unsigned long r8;
  101. unsigned long rax;
  102. unsigned long rcx;
  103. unsigned long rdx;
  104. unsigned long rsi;
  105. unsigned long rdi;
  106. unsigned long orig_rax;
  107. /* end of arguments */
  108. /* cpu exception frame or undefined */
  109. unsigned long rip;
  110. unsigned long cs;
  111. unsigned long eflags;
  112. unsigned long rsp;
  113. unsigned long ss;
  114. /* top of stack page */
  115. };
  116. #else /* __KERNEL__ */
  117. struct pt_regs {
  118. unsigned long r15;
  119. unsigned long r14;
  120. unsigned long r13;
  121. unsigned long r12;
  122. unsigned long bp;
  123. unsigned long bx;
  124. /* arguments: non interrupts/non tracing syscalls only save upto here*/
  125. unsigned long r11;
  126. unsigned long r10;
  127. unsigned long r9;
  128. unsigned long r8;
  129. unsigned long ax;
  130. unsigned long cx;
  131. unsigned long dx;
  132. unsigned long si;
  133. unsigned long di;
  134. unsigned long orig_ax;
  135. /* end of arguments */
  136. /* cpu exception frame or undefined */
  137. unsigned long ip;
  138. unsigned long cs;
  139. unsigned long flags;
  140. unsigned long sp;
  141. unsigned long ss;
  142. /* top of stack page */
  143. };
  144. #define user_mode(regs) (!!((regs)->cs & 3))
  145. #define user_mode_vm(regs) user_mode(regs)
  146. #define v8086_mode(regs) 0 /* No V86 mode support in long mode */
  147. #define instruction_pointer(regs) ((regs)->ip)
  148. #define frame_pointer(regs) ((regs)->bp)
  149. #define stack_pointer(regs) ((regs)->sp)
  150. #define regs_return_value(regs) ((regs)->ax)
  151. extern unsigned long profile_pc(struct pt_regs *regs);
  152. void signal_fault(struct pt_regs *regs, void __user *frame, char *where);
  153. struct task_struct;
  154. extern unsigned long
  155. convert_ip_to_linear(struct task_struct *child, struct pt_regs *regs);
  156. #endif /* __KERNEL__ */
  157. #endif /* !__i386__ */
  158. #ifdef __KERNEL__
  159. /*
  160. * These are defined as per linux/ptrace.h, which see.
  161. */
  162. #define arch_has_single_step() (1)
  163. extern void user_enable_single_step(struct task_struct *);
  164. extern void user_disable_single_step(struct task_struct *);
  165. extern void user_enable_block_step(struct task_struct *);
  166. #ifdef CONFIG_X86_DEBUGCTLMSR
  167. #define arch_has_block_step() (1)
  168. #else
  169. #define arch_has_block_step() (boot_cpu_data.x86 >= 6)
  170. #endif
  171. struct user_desc;
  172. extern int do_get_thread_area(struct task_struct *p, int idx,
  173. struct user_desc __user *info);
  174. extern int do_set_thread_area(struct task_struct *p, int idx,
  175. struct user_desc __user *info, int can_allocate);
  176. #endif /* __KERNEL__ */
  177. #endif /* !__ASSEMBLY__ */
  178. #endif