xref: /linux/arch/mips/include/asm/kprobes.h (revision 0ea5c948cb64bab5bc7a5516774eb8536f05aa0d)
1873e65bcSThomas 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);
44*b98cca44SAnshuman Khandual int kprobe_fault_handler(struct pt_regs *regs, int trapnr);
45c1bf207dSDavid Daney 
46c1bf207dSDavid Daney /* Architecture specific copy of original instruction*/
47c1bf207dSDavid Daney struct arch_specific_insn {
48c1bf207dSDavid Daney 	/* copy of the original instruction */
49c1bf207dSDavid Daney 	kprobe_opcode_t *insn;
50c1bf207dSDavid Daney };
51c1bf207dSDavid Daney 
52c1bf207dSDavid Daney struct prev_kprobe {
53c1bf207dSDavid Daney 	struct kprobe *kp;
54c1bf207dSDavid Daney 	unsigned long status;
55c1bf207dSDavid Daney 	unsigned long old_SR;
56c1bf207dSDavid Daney 	unsigned long saved_SR;
57c1bf207dSDavid Daney 	unsigned long saved_epc;
58c1bf207dSDavid Daney };
59c1bf207dSDavid Daney 
606457a396SManeesh Soni #define SKIP_DELAYSLOT 0x0001
616457a396SManeesh Soni 
62c1bf207dSDavid Daney /* per-cpu kprobe control block */
63c1bf207dSDavid Daney struct kprobe_ctlblk {
64c1bf207dSDavid Daney 	unsigned long kprobe_status;
65c1bf207dSDavid Daney 	unsigned long kprobe_old_SR;
66c1bf207dSDavid Daney 	unsigned long kprobe_saved_SR;
67c1bf207dSDavid Daney 	unsigned long kprobe_saved_epc;
686457a396SManeesh Soni 	/* Per-thread fields, used while emulating branches */
696457a396SManeesh Soni 	unsigned long flags;
706457a396SManeesh Soni 	unsigned long target_epc;
71c1bf207dSDavid Daney 	struct prev_kprobe prev_kprobe;
72c1bf207dSDavid Daney };
73c1bf207dSDavid Daney 
74c1bf207dSDavid Daney 
757d134b2cSLuis R. Rodriguez #endif /* CONFIG_KPROBES */
76c1bf207dSDavid Daney #endif /* _ASM_KPROBES_H */
77