ptrace.h 4.4 KB

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