ptrace.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * Copyright (C) 1994, 95, 96, 97, 98, 99, 2000 by Ralf Baechle
  7. * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
  8. */
  9. #ifndef _ASM_PTRACE_H
  10. #define _ASM_PTRACE_H
  11. /* 0 - 31 are integer registers, 32 - 63 are fp registers. */
  12. #define FPR_BASE 32
  13. #define PC 64
  14. #define CAUSE 65
  15. #define BADVADDR 66
  16. #define MMHI 67
  17. #define MMLO 68
  18. #define FPC_CSR 69
  19. #define FPC_EIR 70
  20. #define DSP_BASE 71 /* 3 more hi / lo register pairs */
  21. #define DSP_CONTROL 77
  22. #define ACX 78
  23. /*
  24. * This struct defines the way the registers are stored on the stack during a
  25. * system call/exception. As usual the registers k0/k1 aren't being saved.
  26. */
  27. struct pt_regs {
  28. #ifdef CONFIG_32BIT
  29. /* Pad bytes for argument save space on the stack. */
  30. unsigned long pad0[6];
  31. #endif
  32. /* Saved main processor registers. */
  33. unsigned long regs[32];
  34. /* Saved special registers. */
  35. unsigned long cp0_status;
  36. unsigned long hi;
  37. unsigned long lo;
  38. #ifdef CONFIG_CPU_HAS_SMARTMIPS
  39. unsigned long acx;
  40. #endif
  41. unsigned long cp0_badvaddr;
  42. unsigned long cp0_cause;
  43. unsigned long cp0_epc;
  44. #ifdef CONFIG_MIPS_MT_SMTC
  45. unsigned long cp0_tcstatus;
  46. #endif /* CONFIG_MIPS_MT_SMTC */
  47. #ifdef CONFIG_CPU_CAVIUM_OCTEON
  48. unsigned long long mpl[3]; /* MTM{0,1,2} */
  49. unsigned long long mtp[3]; /* MTP{0,1,2} */
  50. #endif
  51. } __attribute__ ((aligned (8)));
  52. /* Arbitrarily choose the same ptrace numbers as used by the Sparc code. */
  53. #define PTRACE_GETREGS 12
  54. #define PTRACE_SETREGS 13
  55. #define PTRACE_GETFPREGS 14
  56. #define PTRACE_SETFPREGS 15
  57. /* #define PTRACE_GETFPXREGS 18 */
  58. /* #define PTRACE_SETFPXREGS 19 */
  59. #define PTRACE_OLDSETOPTIONS 21
  60. #define PTRACE_GET_THREAD_AREA 25
  61. #define PTRACE_SET_THREAD_AREA 26
  62. /* Calls to trace a 64bit program from a 32bit program. */
  63. #define PTRACE_PEEKTEXT_3264 0xc0
  64. #define PTRACE_PEEKDATA_3264 0xc1
  65. #define PTRACE_POKETEXT_3264 0xc2
  66. #define PTRACE_POKEDATA_3264 0xc3
  67. #define PTRACE_GET_THREAD_AREA_3264 0xc4
  68. /* Read and write watchpoint registers. */
  69. enum pt_watch_style {
  70. pt_watch_style_mips32,
  71. pt_watch_style_mips64
  72. };
  73. struct mips32_watch_regs {
  74. unsigned int watchlo[8];
  75. /* Lower 16 bits of watchhi. */
  76. unsigned short watchhi[8];
  77. /* Valid mask and I R W bits.
  78. * bit 0 -- 1 if W bit is usable.
  79. * bit 1 -- 1 if R bit is usable.
  80. * bit 2 -- 1 if I bit is usable.
  81. * bits 3 - 11 -- Valid watchhi mask bits.
  82. */
  83. unsigned short watch_masks[8];
  84. /* The number of valid watch register pairs. */
  85. unsigned int num_valid;
  86. } __attribute__((aligned(8)));
  87. struct mips64_watch_regs {
  88. unsigned long long watchlo[8];
  89. unsigned short watchhi[8];
  90. unsigned short watch_masks[8];
  91. unsigned int num_valid;
  92. } __attribute__((aligned(8)));
  93. struct pt_watch_regs {
  94. enum pt_watch_style style;
  95. union {
  96. struct mips32_watch_regs mips32;
  97. struct mips64_watch_regs mips64;
  98. };
  99. };
  100. #define PTRACE_GET_WATCH_REGS 0xd0
  101. #define PTRACE_SET_WATCH_REGS 0xd1
  102. #ifdef __KERNEL__
  103. #include <linux/compiler.h>
  104. #include <linux/linkage.h>
  105. #include <linux/types.h>
  106. #include <asm/isadep.h>
  107. struct task_struct;
  108. extern int ptrace_getregs(struct task_struct *child, __s64 __user *data);
  109. extern int ptrace_setregs(struct task_struct *child, __s64 __user *data);
  110. extern int ptrace_getfpregs(struct task_struct *child, __u32 __user *data);
  111. extern int ptrace_setfpregs(struct task_struct *child, __u32 __user *data);
  112. extern int ptrace_get_watch_regs(struct task_struct *child,
  113. struct pt_watch_regs __user *addr);
  114. extern int ptrace_set_watch_regs(struct task_struct *child,
  115. struct pt_watch_regs __user *addr);
  116. /*
  117. * Does the process account for user or for system time?
  118. */
  119. #define user_mode(regs) (((regs)->cp0_status & KU_MASK) == KU_USER)
  120. static inline int is_syscall_success(struct pt_regs *regs)
  121. {
  122. return !regs->regs[7];
  123. }
  124. static inline long regs_return_value(struct pt_regs *regs)
  125. {
  126. if (is_syscall_success(regs))
  127. return regs->regs[2];
  128. else
  129. return -regs->regs[2];
  130. }
  131. #define instruction_pointer(regs) ((regs)->cp0_epc)
  132. #define profile_pc(regs) instruction_pointer(regs)
  133. extern asmlinkage void syscall_trace_enter(struct pt_regs *regs);
  134. extern asmlinkage void syscall_trace_leave(struct pt_regs *regs);
  135. extern void die(const char *, struct pt_regs *) __noreturn;
  136. static inline void die_if_kernel(const char *str, struct pt_regs *regs)
  137. {
  138. if (unlikely(!user_mode(regs)))
  139. die(str, regs);
  140. }
  141. #endif
  142. #endif /* _ASM_PTRACE_H */