xref: /linux/arch/mips/include/asm/kprobes.h (revision 873e65bc09078e56eaa51af2c9c60da2fad6fdbf)
1*873e65bcSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */
2c1bf207dSDavid Daney /*
3c1bf207dSDavid Daney  *  Kernel Probes (KProbes)
4c1bf207dSDavid Daney  *  include/asm-mips/kprobes.h
5c1bf207dSDavid Daney  *
6c1bf207dSDavid Daney  *  Copyright 2006 Sony Corp.
7c1bf207dSDavid Daney  *  Copyright 2010 Cavium Networks
8c1bf207dSDavid Daney  */
9c1bf207dSDavid Daney 
10c1bf207dSDavid Daney #ifndef _ASM_KPROBES_H
11c1bf207dSDavid Daney #define _ASM_KPROBES_H
12c1bf207dSDavid Daney 
137d134b2cSLuis R. Rodriguez #include <asm-generic/kprobes.h>
147d134b2cSLuis R. Rodriguez 
157d134b2cSLuis R. Rodriguez #ifdef CONFIG_KPROBES
16c1bf207dSDavid Daney #include <linux/ptrace.h>
17c1bf207dSDavid Daney #include <linux/types.h>
18c1bf207dSDavid Daney 
19c1bf207dSDavid Daney #include <asm/cacheflush.h>
20c1bf207dSDavid Daney #include <asm/kdebug.h>
21c1bf207dSDavid Daney #include <asm/inst.h>
22c1bf207dSDavid Daney 
23c1bf207dSDavid Daney #define	 __ARCH_WANT_KPROBES_INSN_SLOT
24c1bf207dSDavid Daney 
25c1bf207dSDavid Daney struct kprobe;
26c1bf207dSDavid Daney struct pt_regs;
27c1bf207dSDavid Daney 
28c1bf207dSDavid Daney typedef union mips_instruction kprobe_opcode_t;
29c1bf207dSDavid Daney 
30c1bf207dSDavid Daney #define MAX_INSN_SIZE 2
31c1bf207dSDavid Daney 
32c1bf207dSDavid Daney #define flush_insn_slot(p)						\
33c1bf207dSDavid Daney do {									\
34698b8510SMarcin Nowakowski 	if (p->addr)							\
35c1bf207dSDavid Daney 		flush_icache_range((unsigned long)p->addr,		\
36c1bf207dSDavid Daney 			   (unsigned long)p->addr +			\
37c1bf207dSDavid Daney 			   (MAX_INSN_SIZE * sizeof(kprobe_opcode_t)));	\
38c1bf207dSDavid Daney } while (0)
39c1bf207dSDavid Daney 
40c1bf207dSDavid Daney 
41c1bf207dSDavid Daney #define kretprobe_blacklist_size 0
42c1bf207dSDavid Daney 
43c1bf207dSDavid Daney void arch_remove_kprobe(struct kprobe *p);
44c1bf207dSDavid Daney 
45c1bf207dSDavid Daney /* Architecture specific copy of original instruction*/
46c1bf207dSDavid Daney struct arch_specific_insn {
47c1bf207dSDavid Daney 	/* copy of the original instruction */
48c1bf207dSDavid Daney 	kprobe_opcode_t *insn;
49c1bf207dSDavid Daney };
50c1bf207dSDavid Daney 
51c1bf207dSDavid Daney struct prev_kprobe {
52c1bf207dSDavid Daney 	struct kprobe *kp;
53c1bf207dSDavid Daney 	unsigned long status;
54c1bf207dSDavid Daney 	unsigned long old_SR;
55c1bf207dSDavid Daney 	unsigned long saved_SR;
56c1bf207dSDavid Daney 	unsigned long saved_epc;
57c1bf207dSDavid Daney };
58c1bf207dSDavid Daney 
596457a396SManeesh Soni #define SKIP_DELAYSLOT 0x0001
606457a396SManeesh Soni 
61c1bf207dSDavid Daney /* per-cpu kprobe control block */
62c1bf207dSDavid Daney struct kprobe_ctlblk {
63c1bf207dSDavid Daney 	unsigned long kprobe_status;
64c1bf207dSDavid Daney 	unsigned long kprobe_old_SR;
65c1bf207dSDavid Daney 	unsigned long kprobe_saved_SR;
66c1bf207dSDavid Daney 	unsigned long kprobe_saved_epc;
676457a396SManeesh Soni 	/* Per-thread fields, used while emulating branches */
686457a396SManeesh Soni 	unsigned long flags;
696457a396SManeesh Soni 	unsigned long target_epc;
70c1bf207dSDavid Daney 	struct prev_kprobe prev_kprobe;
71c1bf207dSDavid Daney };
72c1bf207dSDavid Daney 
73c1bf207dSDavid Daney extern int kprobe_exceptions_notify(struct notifier_block *self,
74c1bf207dSDavid Daney 				    unsigned long val, void *data);
75c1bf207dSDavid Daney 
767d134b2cSLuis R. Rodriguez #endif /* CONFIG_KPROBES */
77c1bf207dSDavid Daney #endif /* _ASM_KPROBES_H */
78