ptrace.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #ifndef _I386_PTRACE_H
  2. #define _I386_PTRACE_H
  3. #include <asm/ptrace-abi.h>
  4. /* this struct defines the way the registers are stored on the
  5. stack during a system call. */
  6. struct pt_regs {
  7. long ebx;
  8. long ecx;
  9. long edx;
  10. long esi;
  11. long edi;
  12. long ebp;
  13. long eax;
  14. int xds;
  15. int xes;
  16. int xfs;
  17. /* int xgs; */
  18. long orig_eax;
  19. long eip;
  20. int xcs;
  21. long eflags;
  22. long esp;
  23. int xss;
  24. };
  25. #ifdef __KERNEL__
  26. #include <asm/vm86.h>
  27. #include <asm/segment.h>
  28. struct task_struct;
  29. extern void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs, int error_code);
  30. /*
  31. * user_mode_vm(regs) determines whether a register set came from user mode.
  32. * This is true if V8086 mode was enabled OR if the register set was from
  33. * protected mode with RPL-3 CS value. This tricky test checks that with
  34. * one comparison. Many places in the kernel can bypass this full check
  35. * if they have already ruled out V8086 mode, so user_mode(regs) can be used.
  36. */
  37. static inline int user_mode(struct pt_regs *regs)
  38. {
  39. return (regs->xcs & SEGMENT_RPL_MASK) == USER_RPL;
  40. }
  41. static inline int user_mode_vm(struct pt_regs *regs)
  42. {
  43. return ((regs->xcs & SEGMENT_RPL_MASK) | (regs->eflags & VM_MASK)) >= USER_RPL;
  44. }
  45. static inline int v8086_mode(struct pt_regs *regs)
  46. {
  47. return (regs->eflags & VM_MASK);
  48. }
  49. #define instruction_pointer(regs) ((regs)->eip)
  50. #define regs_return_value(regs) ((regs)->eax)
  51. extern unsigned long profile_pc(struct pt_regs *regs);
  52. #endif /* __KERNEL__ */
  53. #endif