ptrace.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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. struct pt_regs {
  10. long ebx;
  11. long ecx;
  12. long edx;
  13. long esi;
  14. long edi;
  15. long ebp;
  16. long eax;
  17. int xds;
  18. int xes;
  19. int xfs;
  20. /* int xgs; */
  21. long orig_eax;
  22. long eip;
  23. int xcs;
  24. long eflags;
  25. long esp;
  26. int xss;
  27. };
  28. #ifdef __KERNEL__
  29. #include <asm/vm86.h>
  30. #include <asm/segment.h>
  31. struct task_struct;
  32. extern void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs, int error_code);
  33. /*
  34. * user_mode_vm(regs) determines whether a register set came from user mode.
  35. * This is true if V8086 mode was enabled OR if the register set was from
  36. * protected mode with RPL-3 CS value. This tricky test checks that with
  37. * one comparison. Many places in the kernel can bypass this full check
  38. * if they have already ruled out V8086 mode, so user_mode(regs) can be used.
  39. */
  40. static inline int user_mode(struct pt_regs *regs)
  41. {
  42. return (regs->xcs & SEGMENT_RPL_MASK) == USER_RPL;
  43. }
  44. static inline int user_mode_vm(struct pt_regs *regs)
  45. {
  46. return ((regs->xcs & SEGMENT_RPL_MASK) | (regs->eflags & VM_MASK)) >= USER_RPL;
  47. }
  48. static inline int v8086_mode(struct pt_regs *regs)
  49. {
  50. return (regs->eflags & VM_MASK);
  51. }
  52. #define instruction_pointer(regs) ((regs)->eip)
  53. #define frame_pointer(regs) ((regs)->ebp)
  54. #define stack_pointer(regs) ((unsigned long)(regs))
  55. #define regs_return_value(regs) ((regs)->eax)
  56. extern unsigned long profile_pc(struct pt_regs *regs);
  57. #endif /* __KERNEL__ */
  58. #else /* __i386__ */
  59. struct pt_regs {
  60. unsigned long r15;
  61. unsigned long r14;
  62. unsigned long r13;
  63. unsigned long r12;
  64. unsigned long rbp;
  65. unsigned long rbx;
  66. /* arguments: non interrupts/non tracing syscalls only save upto here*/
  67. unsigned long r11;
  68. unsigned long r10;
  69. unsigned long r9;
  70. unsigned long r8;
  71. unsigned long rax;
  72. unsigned long rcx;
  73. unsigned long rdx;
  74. unsigned long rsi;
  75. unsigned long rdi;
  76. unsigned long orig_rax;
  77. /* end of arguments */
  78. /* cpu exception frame or undefined */
  79. unsigned long rip;
  80. unsigned long cs;
  81. unsigned long eflags;
  82. unsigned long rsp;
  83. unsigned long ss;
  84. /* top of stack page */
  85. };
  86. #ifdef __KERNEL__
  87. #define user_mode(regs) (!!((regs)->cs & 3))
  88. #define user_mode_vm(regs) user_mode(regs)
  89. #define instruction_pointer(regs) ((regs)->rip)
  90. #define frame_pointer(regs) ((regs)->rbp)
  91. #define stack_pointer(regs) ((regs)->rsp)
  92. #define regs_return_value(regs) ((regs)->rax)
  93. extern unsigned long profile_pc(struct pt_regs *regs);
  94. void signal_fault(struct pt_regs *regs, void __user *frame, char *where);
  95. struct task_struct;
  96. extern unsigned long
  97. convert_rip_to_linear(struct task_struct *child, struct pt_regs *regs);
  98. enum {
  99. EF_CF = 0x00000001,
  100. EF_PF = 0x00000004,
  101. EF_AF = 0x00000010,
  102. EF_ZF = 0x00000040,
  103. EF_SF = 0x00000080,
  104. EF_TF = 0x00000100,
  105. EF_IE = 0x00000200,
  106. EF_DF = 0x00000400,
  107. EF_OF = 0x00000800,
  108. EF_IOPL = 0x00003000,
  109. EF_IOPL_RING0 = 0x00000000,
  110. EF_IOPL_RING1 = 0x00001000,
  111. EF_IOPL_RING2 = 0x00002000,
  112. EF_NT = 0x00004000, /* nested task */
  113. EF_RF = 0x00010000, /* resume */
  114. EF_VM = 0x00020000, /* virtual mode */
  115. EF_AC = 0x00040000, /* alignment */
  116. EF_VIF = 0x00080000, /* virtual interrupt */
  117. EF_VIP = 0x00100000, /* virtual interrupt pending */
  118. EF_ID = 0x00200000, /* id */
  119. };
  120. #endif /* __KERNEL__ */
  121. #endif /* !__i386__ */
  122. #endif /* !__ASSEMBLY__ */
  123. #endif