xref: /openbmc/linux/arch/riscv/include/asm/kprobes.h (revision 9dbbc3b9)
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 /* Single step context for kprobe */
33 struct kprobe_step_ctx {
34 	unsigned long ss_pending;
35 	unsigned long match_addr;
36 };
37 
38 /* per-cpu kprobe control block */
39 struct kprobe_ctlblk {
40 	unsigned int kprobe_status;
41 	unsigned long saved_status;
42 	struct prev_kprobe prev_kprobe;
43 	struct kprobe_step_ctx ss_ctx;
44 };
45 
46 void arch_remove_kprobe(struct kprobe *p);
47 int kprobe_fault_handler(struct pt_regs *regs, unsigned int trapnr);
48 bool kprobe_breakpoint_handler(struct pt_regs *regs);
49 bool kprobe_single_step_handler(struct pt_regs *regs);
50 void kretprobe_trampoline(void);
51 void __kprobes *trampoline_probe_handler(struct pt_regs *regs);
52 
53 #endif /* CONFIG_KPROBES */
54 #endif /* _ASM_RISCV_KPROBES_H */
55