0001
0002 #ifndef _ASM_X86_KPROBES_H
0003 #define _ASM_X86_KPROBES_H
0004
0005
0006
0007
0008
0009
0010
0011
0012 #include <asm-generic/kprobes.h>
0013
0014 #ifdef CONFIG_KPROBES
0015 #include <linux/types.h>
0016 #include <linux/ptrace.h>
0017 #include <linux/percpu.h>
0018 #include <asm/text-patching.h>
0019 #include <asm/insn.h>
0020
0021 #define __ARCH_WANT_KPROBES_INSN_SLOT
0022
0023 struct pt_regs;
0024 struct kprobe;
0025
0026 typedef u8 kprobe_opcode_t;
0027
0028 #define MAX_STACK_SIZE 64
0029 #define CUR_STACK_SIZE(ADDR) \
0030 (current_top_of_stack() - (unsigned long)(ADDR))
0031 #define MIN_STACK_SIZE(ADDR) \
0032 (MAX_STACK_SIZE < CUR_STACK_SIZE(ADDR) ? \
0033 MAX_STACK_SIZE : CUR_STACK_SIZE(ADDR))
0034
0035 #define flush_insn_slot(p) do { } while (0)
0036
0037
0038 extern __visible kprobe_opcode_t optprobe_template_entry[];
0039 extern __visible kprobe_opcode_t optprobe_template_clac[];
0040 extern __visible kprobe_opcode_t optprobe_template_val[];
0041 extern __visible kprobe_opcode_t optprobe_template_call[];
0042 extern __visible kprobe_opcode_t optprobe_template_end[];
0043 #define MAX_OPTIMIZED_LENGTH (MAX_INSN_SIZE + DISP32_SIZE)
0044 #define MAX_OPTINSN_SIZE \
0045 (((unsigned long)optprobe_template_end - \
0046 (unsigned long)optprobe_template_entry) + \
0047 MAX_OPTIMIZED_LENGTH + JMP32_INSN_SIZE)
0048
0049 extern const int kretprobe_blacklist_size;
0050
0051 void arch_remove_kprobe(struct kprobe *p);
0052
0053 extern void arch_kprobe_override_function(struct pt_regs *regs);
0054
0055
0056 struct arch_specific_insn {
0057
0058 kprobe_opcode_t *insn;
0059
0060
0061
0062
0063
0064
0065
0066 unsigned boostable:1;
0067 unsigned char size;
0068 union {
0069 unsigned char opcode;
0070 struct {
0071 unsigned char type;
0072 } jcc;
0073 struct {
0074 unsigned char type;
0075 unsigned char asize;
0076 } loop;
0077 struct {
0078 unsigned char reg;
0079 } indirect;
0080 };
0081 s32 rel32;
0082 void (*emulate_op)(struct kprobe *p, struct pt_regs *regs);
0083
0084 int tp_len;
0085 };
0086
0087 struct arch_optimized_insn {
0088
0089 kprobe_opcode_t copied_insn[DISP32_SIZE];
0090
0091 kprobe_opcode_t *insn;
0092
0093 size_t size;
0094 };
0095
0096
0097 static inline int arch_prepared_optinsn(struct arch_optimized_insn *optinsn)
0098 {
0099 return optinsn->size;
0100 }
0101
0102 struct prev_kprobe {
0103 struct kprobe *kp;
0104 unsigned long status;
0105 unsigned long old_flags;
0106 unsigned long saved_flags;
0107 };
0108
0109
0110 struct kprobe_ctlblk {
0111 unsigned long kprobe_status;
0112 unsigned long kprobe_old_flags;
0113 unsigned long kprobe_saved_flags;
0114 struct prev_kprobe prev_kprobe;
0115 };
0116
0117 extern int kprobe_fault_handler(struct pt_regs *regs, int trapnr);
0118 extern int kprobe_exceptions_notify(struct notifier_block *self,
0119 unsigned long val, void *data);
0120 extern int kprobe_int3_handler(struct pt_regs *regs);
0121
0122 #else
0123
0124 static inline int kprobe_debug_handler(struct pt_regs *regs) { return 0; }
0125
0126 #endif
0127 #endif