kprobes.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. * Kernel Probes (KProbes)
  3. * include/asm-mips/kprobes.h
  4. *
  5. * Copyright 2006 Sony Corp.
  6. * Copyright 2010 Cavium Networks
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; version 2 of the License.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  20. */
  21. #ifndef _ASM_KPROBES_H
  22. #define _ASM_KPROBES_H
  23. #include <linux/ptrace.h>
  24. #include <linux/types.h>
  25. #include <asm/cacheflush.h>
  26. #include <asm/kdebug.h>
  27. #include <asm/inst.h>
  28. #define __ARCH_WANT_KPROBES_INSN_SLOT
  29. struct kprobe;
  30. struct pt_regs;
  31. typedef union mips_instruction kprobe_opcode_t;
  32. #define MAX_INSN_SIZE 2
  33. #define flush_insn_slot(p) \
  34. do { \
  35. if (p->addr) \
  36. flush_icache_range((unsigned long)p->addr, \
  37. (unsigned long)p->addr + \
  38. (MAX_INSN_SIZE * sizeof(kprobe_opcode_t))); \
  39. } while (0)
  40. #define kretprobe_blacklist_size 0
  41. void arch_remove_kprobe(struct kprobe *p);
  42. /* Architecture specific copy of original instruction*/
  43. struct arch_specific_insn {
  44. /* copy of the original instruction */
  45. kprobe_opcode_t *insn;
  46. };
  47. struct prev_kprobe {
  48. struct kprobe *kp;
  49. unsigned long status;
  50. unsigned long old_SR;
  51. unsigned long saved_SR;
  52. unsigned long saved_epc;
  53. };
  54. #define MAX_JPROBES_STACK_SIZE 128
  55. #define MAX_JPROBES_STACK_ADDR \
  56. (((unsigned long)current_thread_info()) + THREAD_SIZE - 32 - sizeof(struct pt_regs))
  57. #define MIN_JPROBES_STACK_SIZE(ADDR) \
  58. ((((ADDR) + MAX_JPROBES_STACK_SIZE) > MAX_JPROBES_STACK_ADDR) \
  59. ? MAX_JPROBES_STACK_ADDR - (ADDR) \
  60. : MAX_JPROBES_STACK_SIZE)
  61. #define SKIP_DELAYSLOT 0x0001
  62. /* per-cpu kprobe control block */
  63. struct kprobe_ctlblk {
  64. unsigned long kprobe_status;
  65. unsigned long kprobe_old_SR;
  66. unsigned long kprobe_saved_SR;
  67. unsigned long kprobe_saved_epc;
  68. unsigned long jprobe_saved_sp;
  69. struct pt_regs jprobe_saved_regs;
  70. /* Per-thread fields, used while emulating branches */
  71. unsigned long flags;
  72. unsigned long target_epc;
  73. u8 jprobes_stack[MAX_JPROBES_STACK_SIZE];
  74. struct prev_kprobe prev_kprobe;
  75. };
  76. extern int kprobe_exceptions_notify(struct notifier_block *self,
  77. unsigned long val, void *data);
  78. #endif /* _ASM_KPROBES_H */