kprobes.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. flush_icache_range((unsigned long)p->addr, \
  36. (unsigned long)p->addr + \
  37. (MAX_INSN_SIZE * sizeof(kprobe_opcode_t))); \
  38. } while (0)
  39. #define kretprobe_blacklist_size 0
  40. void arch_remove_kprobe(struct kprobe *p);
  41. /* Architecture specific copy of original instruction*/
  42. struct arch_specific_insn {
  43. /* copy of the original instruction */
  44. kprobe_opcode_t *insn;
  45. };
  46. struct prev_kprobe {
  47. struct kprobe *kp;
  48. unsigned long status;
  49. unsigned long old_SR;
  50. unsigned long saved_SR;
  51. unsigned long saved_epc;
  52. };
  53. #define MAX_JPROBES_STACK_SIZE 128
  54. #define MAX_JPROBES_STACK_ADDR \
  55. (((unsigned long)current_thread_info()) + THREAD_SIZE - 32 - sizeof(struct pt_regs))
  56. #define MIN_JPROBES_STACK_SIZE(ADDR) \
  57. ((((ADDR) + MAX_JPROBES_STACK_SIZE) > MAX_JPROBES_STACK_ADDR) \
  58. ? MAX_JPROBES_STACK_ADDR - (ADDR) \
  59. : MAX_JPROBES_STACK_SIZE)
  60. #define SKIP_DELAYSLOT 0x0001
  61. /* per-cpu kprobe control block */
  62. struct kprobe_ctlblk {
  63. unsigned long kprobe_status;
  64. unsigned long kprobe_old_SR;
  65. unsigned long kprobe_saved_SR;
  66. unsigned long kprobe_saved_epc;
  67. unsigned long jprobe_saved_sp;
  68. struct pt_regs jprobe_saved_regs;
  69. /* Per-thread fields, used while emulating branches */
  70. unsigned long flags;
  71. unsigned long target_epc;
  72. u8 jprobes_stack[MAX_JPROBES_STACK_SIZE];
  73. struct prev_kprobe prev_kprobe;
  74. };
  75. extern int kprobe_exceptions_notify(struct notifier_block *self,
  76. unsigned long val, void *data);
  77. #endif /* _ASM_KPROBES_H */