xref: /linux/arch/riscv/include/asm/kprobes.h (revision d642ef71)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Copied from arch/arm64/include/asm/kprobes.h
4  *
5  * Copyright (C) 2013 Linaro Limited
6  * Copyright (C) 2017 SiFive
7  */
8 
9 #ifndef _ASM_RISCV_KPROBES_H
10 #define _ASM_RISCV_KPROBES_H
11 
12 #include <asm-generic/kprobes.h>
13 
14 #ifdef CONFIG_KPROBES
15 #include <linux/types.h>
16 #include <linux/ptrace.h>
17 #include <linux/percpu.h>
18 
19 #define __ARCH_WANT_KPROBES_INSN_SLOT
20 #define MAX_INSN_SIZE			2
21 
22 #define flush_insn_slot(p)		do { } while (0)
23 #define kretprobe_blacklist_size	0
24 
25 #include <asm/probes.h>
26 
27 struct prev_kprobe {
28 	struct kprobe *kp;
29 	unsigned int status;
30 };
31 
32 /* per-cpu kprobe control block */
33 struct kprobe_ctlblk {
34 	unsigned int kprobe_status;
35 	unsigned long saved_status;
36 	struct prev_kprobe prev_kprobe;
37 };
38 
39 void arch_remove_kprobe(struct kprobe *p);
40 int kprobe_fault_handler(struct pt_regs *regs, unsigned int trapnr);
41 bool kprobe_breakpoint_handler(struct pt_regs *regs);
42 bool kprobe_single_step_handler(struct pt_regs *regs);
43 #else
44 static inline bool kprobe_breakpoint_handler(struct pt_regs *regs)
45 {
46 	return false;
47 }
48 
49 static inline bool kprobe_single_step_handler(struct pt_regs *regs)
50 {
51 	return false;
52 }
53 #endif /* CONFIG_KPROBES */
54 #endif /* _ASM_RISCV_KPROBES_H */
55