xref: /linux/arch/riscv/include/asm/kprobes.h (revision 0ea5c948cb64bab5bc7a5516774eb8536f05aa0d)
11802d0beSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */
27db91e57SPalmer Dabbelt /*
37db91e57SPalmer Dabbelt  * Copied from arch/arm64/include/asm/kprobes.h
47db91e57SPalmer Dabbelt  *
57db91e57SPalmer Dabbelt  * Copyright (C) 2013 Linaro Limited
67db91e57SPalmer Dabbelt  * Copyright (C) 2017 SiFive
77db91e57SPalmer Dabbelt  */
87db91e57SPalmer Dabbelt 
96b57ba8eSZong Li #ifndef _ASM_RISCV_KPROBES_H
106b57ba8eSZong Li #define _ASM_RISCV_KPROBES_H
117db91e57SPalmer Dabbelt 
127db91e57SPalmer Dabbelt #include <asm-generic/kprobes.h>
137db91e57SPalmer Dabbelt 
14c22b0bcbSGuo Ren #ifdef CONFIG_KPROBES
15c22b0bcbSGuo Ren #include <linux/types.h>
16c22b0bcbSGuo Ren #include <linux/ptrace.h>
17c22b0bcbSGuo Ren #include <linux/percpu.h>
18c22b0bcbSGuo Ren 
19c22b0bcbSGuo Ren #define __ARCH_WANT_KPROBES_INSN_SLOT
20c22b0bcbSGuo Ren #define MAX_INSN_SIZE			2
21c22b0bcbSGuo Ren 
22c22b0bcbSGuo Ren #define flush_insn_slot(p)		do { } while (0)
23c22b0bcbSGuo Ren #define kretprobe_blacklist_size	0
24c22b0bcbSGuo Ren 
25c22b0bcbSGuo Ren #include <asm/probes.h>
26c22b0bcbSGuo Ren 
27c22b0bcbSGuo Ren struct prev_kprobe {
28c22b0bcbSGuo Ren 	struct kprobe *kp;
29c22b0bcbSGuo Ren 	unsigned int status;
30c22b0bcbSGuo Ren };
31c22b0bcbSGuo Ren 
32c22b0bcbSGuo Ren /* per-cpu kprobe control block */
33c22b0bcbSGuo Ren struct kprobe_ctlblk {
34c22b0bcbSGuo Ren 	unsigned int kprobe_status;
35c22b0bcbSGuo Ren 	unsigned long saved_status;
36c22b0bcbSGuo Ren 	struct prev_kprobe prev_kprobe;
37c22b0bcbSGuo Ren };
38c22b0bcbSGuo Ren 
39c22b0bcbSGuo Ren void arch_remove_kprobe(struct kprobe *p);
40c22b0bcbSGuo Ren int kprobe_fault_handler(struct pt_regs *regs, unsigned int trapnr);
41c22b0bcbSGuo Ren bool kprobe_breakpoint_handler(struct pt_regs *regs);
42c22b0bcbSGuo Ren bool kprobe_single_step_handler(struct pt_regs *regs);
43*9f564b92SBjörn Töpel #else
kprobe_breakpoint_handler(struct pt_regs * regs)44*9f564b92SBjörn Töpel static inline bool kprobe_breakpoint_handler(struct pt_regs *regs)
45*9f564b92SBjörn Töpel {
46*9f564b92SBjörn Töpel 	return false;
47*9f564b92SBjörn Töpel }
48c22b0bcbSGuo Ren 
kprobe_single_step_handler(struct pt_regs * regs)49*9f564b92SBjörn Töpel static inline bool kprobe_single_step_handler(struct pt_regs *regs)
50*9f564b92SBjörn Töpel {
51*9f564b92SBjörn Töpel 	return false;
52*9f564b92SBjörn Töpel }
53c22b0bcbSGuo Ren #endif /* CONFIG_KPROBES */
546b57ba8eSZong Li #endif /* _ASM_RISCV_KPROBES_H */
55