xref: /openbmc/linux/arch/sh/include/asm/kprobes.h (revision 037c10a6)
1d39f5450SChris Smith #ifndef __ASM_SH_KPROBES_H
2d39f5450SChris Smith #define __ASM_SH_KPROBES_H
3d39f5450SChris Smith 
4d39f5450SChris Smith #ifdef CONFIG_KPROBES
5d39f5450SChris Smith 
6d39f5450SChris Smith #include <linux/types.h>
7d39f5450SChris Smith #include <linux/ptrace.h>
8d39f5450SChris Smith 
9d39f5450SChris Smith typedef u16 kprobe_opcode_t;
10d39f5450SChris Smith #define BREAKPOINT_INSTRUCTION	0xc3ff
11d39f5450SChris Smith 
12d39f5450SChris Smith #define MAX_INSN_SIZE 16
13d39f5450SChris Smith #define MAX_STACK_SIZE 64
14d39f5450SChris Smith #define MIN_STACK_SIZE(ADDR) (((MAX_STACK_SIZE) < \
15d39f5450SChris Smith 	(((unsigned long)current_thread_info()) + THREAD_SIZE - (ADDR))) \
16d39f5450SChris Smith 	? (MAX_STACK_SIZE) \
17d39f5450SChris Smith 	: (((unsigned long)current_thread_info()) + THREAD_SIZE - (ADDR)))
18d39f5450SChris Smith 
19d39f5450SChris Smith #define regs_return_value(regs)		((regs)->regs[0])
20d39f5450SChris Smith #define flush_insn_slot(p)		do { } while (0)
21d39f5450SChris Smith #define kretprobe_blacklist_size	0
22d39f5450SChris Smith 
23d39f5450SChris Smith struct kprobe;
24d39f5450SChris Smith 
25d39f5450SChris Smith void arch_remove_kprobe(struct kprobe *);
26d39f5450SChris Smith void kretprobe_trampoline(void);
27d39f5450SChris Smith void jprobe_return_end(void);
28d39f5450SChris Smith 
29d39f5450SChris Smith /* Architecture specific copy of original instruction*/
30d39f5450SChris Smith struct arch_specific_insn {
31d39f5450SChris Smith 	/* copy of the original instruction */
32d39f5450SChris Smith 	kprobe_opcode_t insn[MAX_INSN_SIZE];
33d39f5450SChris Smith };
34d39f5450SChris Smith 
35d39f5450SChris Smith struct prev_kprobe {
36d39f5450SChris Smith 	struct kprobe *kp;
37d39f5450SChris Smith 	unsigned long status;
38d39f5450SChris Smith };
39d39f5450SChris Smith 
40d39f5450SChris Smith /* per-cpu kprobe control block */
41d39f5450SChris Smith struct kprobe_ctlblk {
42d39f5450SChris Smith 	unsigned long kprobe_status;
43d39f5450SChris Smith 	unsigned long jprobe_saved_r15;
44d39f5450SChris Smith 	struct pt_regs jprobe_saved_regs;
45d39f5450SChris Smith 	kprobe_opcode_t jprobes_stack[MAX_STACK_SIZE];
46d39f5450SChris Smith 	struct prev_kprobe prev_kprobe;
47d39f5450SChris Smith };
48d39f5450SChris Smith 
49037c10a6SPaul Mundt extern int kprobe_fault_handler(struct pt_regs *regs, int trapnr);
50d39f5450SChris Smith extern int kprobe_exceptions_notify(struct notifier_block *self,
51d39f5450SChris Smith 				    unsigned long val, void *data);
52d39f5450SChris Smith extern int kprobe_handle_illslot(unsigned long pc);
53d39f5450SChris Smith #else
54d39f5450SChris Smith 
55d39f5450SChris Smith #define kprobe_handle_illslot(pc)	(-1)
56d39f5450SChris Smith 
57d39f5450SChris Smith #endif /* CONFIG_KPROBES */
58d39f5450SChris Smith #endif /* __ASM_SH_KPROBES_H */
59