xref: /openbmc/linux/arch/riscv/include/asm/uprobes.h (revision f3dfffb3)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #ifndef _ASM_RISCV_UPROBES_H
4 #define _ASM_RISCV_UPROBES_H
5 
6 #include <asm/probes.h>
7 #include <asm/patch.h>
8 #include <asm/bug.h>
9 
10 #define MAX_UINSN_BYTES		8
11 
12 #ifdef CONFIG_RISCV_ISA_C
13 #define UPROBE_SWBP_INSN	__BUG_INSN_16
14 #define UPROBE_SWBP_INSN_SIZE	2
15 #else
16 #define UPROBE_SWBP_INSN	__BUG_INSN_32
17 #define UPROBE_SWBP_INSN_SIZE	4
18 #endif
19 #define UPROBE_XOL_SLOT_BYTES	MAX_UINSN_BYTES
20 
21 typedef u32 uprobe_opcode_t;
22 
23 struct arch_uprobe_task {
24 	unsigned long   saved_cause;
25 };
26 
27 struct arch_uprobe {
28 	union {
29 		u8 insn[MAX_UINSN_BYTES];
30 		u8 ixol[MAX_UINSN_BYTES];
31 	};
32 	struct arch_probe_insn api;
33 	unsigned long insn_size;
34 	bool simulate;
35 };
36 
37 #ifdef CONFIG_UPROBES
38 bool uprobe_breakpoint_handler(struct pt_regs *regs);
39 bool uprobe_single_step_handler(struct pt_regs *regs);
40 #else
41 static inline bool uprobe_breakpoint_handler(struct pt_regs *regs)
42 {
43 	return false;
44 }
45 
46 static inline bool uprobe_single_step_handler(struct pt_regs *regs)
47 {
48 	return false;
49 }
50 #endif /* CONFIG_UPROBES */
51 #endif /* _ASM_RISCV_UPROBES_H */
52