File tree Expand file tree Collapse file tree 7 files changed +40
-19
lines changed Expand file tree Collapse file tree 7 files changed +40
-19
lines changed Original file line number Diff line number Diff line change @@ -101,6 +101,7 @@ config RISCV
101
101
select HAVE_KPROBES if !XIP_KERNEL
102
102
select HAVE_KPROBES_ON_FTRACE if !XIP_KERNEL
103
103
select HAVE_KRETPROBES if !XIP_KERNEL
104
+ select HAVE_RETHOOK if !XIP_KERNEL
104
105
select HAVE_MOVE_PMD
105
106
select HAVE_MOVE_PUD
106
107
select HAVE_PCI
Original file line number Diff line number Diff line change @@ -40,8 +40,6 @@ void arch_remove_kprobe(struct kprobe *p);
40
40
int kprobe_fault_handler (struct pt_regs * regs , unsigned int trapnr );
41
41
bool kprobe_breakpoint_handler (struct pt_regs * regs );
42
42
bool kprobe_single_step_handler (struct pt_regs * regs );
43
- void __kretprobe_trampoline (void );
44
- void __kprobes * trampoline_probe_handler (struct pt_regs * regs );
45
43
46
44
#endif /* CONFIG_KPROBES */
47
45
#endif /* _ASM_RISCV_KPROBES_H */
Original file line number Diff line number Diff line change 1
1
# SPDX-License-Identifier: GPL-2.0
2
2
obj-$(CONFIG_KPROBES) += kprobes.o decode-insn.o simulate-insn.o
3
- obj-$(CONFIG_KPROBES ) += kprobes_trampoline .o
3
+ obj-$(CONFIG_RETHOOK ) += rethook.o rethook_trampoline .o
4
4
obj-$(CONFIG_KPROBES_ON_FTRACE) += ftrace.o
5
5
obj-$(CONFIG_UPROBES) += uprobes.o decode-insn.o simulate-insn.o
6
6
CFLAGS_REMOVE_simulate-insn.o = $(CC_FLAGS_FTRACE )
Original file line number Diff line number Diff line change @@ -345,19 +345,6 @@ int __init arch_populate_kprobe_blacklist(void)
345
345
return ret ;
346
346
}
347
347
348
- void __kprobes __used * trampoline_probe_handler (struct pt_regs * regs )
349
- {
350
- return (void * )kretprobe_trampoline_handler (regs , NULL );
351
- }
352
-
353
- void __kprobes arch_prepare_kretprobe (struct kretprobe_instance * ri ,
354
- struct pt_regs * regs )
355
- {
356
- ri -> ret_addr = (kprobe_opcode_t * )regs -> ra ;
357
- ri -> fp = NULL ;
358
- regs -> ra = (unsigned long ) & __kretprobe_trampoline ;
359
- }
360
-
361
348
int __kprobes arch_trampoline_kprobe (struct kprobe * p )
362
349
{
363
350
return 0 ;
Original file line number Diff line number Diff line change
1
+ // SPDX-License-Identifier: GPL-2.0-only
2
+ /*
3
+ * Generic return hook for riscv.
4
+ */
5
+
6
+ #include <linux/kprobes.h>
7
+ #include <linux/rethook.h>
8
+ #include "rethook.h"
9
+
10
+ /* This is called from arch_rethook_trampoline() */
11
+ unsigned long __used arch_rethook_trampoline_callback (struct pt_regs * regs )
12
+ {
13
+ return rethook_trampoline_handler (regs , regs -> s0 );
14
+ }
15
+
16
+ NOKPROBE_SYMBOL (arch_rethook_trampoline_callback );
17
+
18
+ void arch_rethook_prepare (struct rethook_node * rhn , struct pt_regs * regs , bool mcount )
19
+ {
20
+ rhn -> ret_addr = regs -> ra ;
21
+ rhn -> frame = regs -> s0 ;
22
+
23
+ /* replace return addr with trampoline */
24
+ regs -> ra = (unsigned long )arch_rethook_trampoline ;
25
+ }
26
+
27
+ NOKPROBE_SYMBOL (arch_rethook_prepare );
Original file line number Diff line number Diff line change
1
+ /* SPDX-License-Identifier: GPL-2.0-only */
2
+ #ifndef __RISCV_RETHOOK_H
3
+ #define __RISCV_RETHOOK_H
4
+
5
+ unsigned long arch_rethook_trampoline_callback (struct pt_regs * regs );
6
+ void arch_rethook_prepare (struct rethook_node * rhn , struct pt_regs * regs , bool mcount );
7
+
8
+ #endif
Original file line number Diff line number Diff line change 75
75
REG_L x31, PT_T6(sp )
76
76
.endm
77
77
78
- ENTRY (__kretprobe_trampoline )
78
+ ENTRY (arch_rethook_trampoline )
79
79
addi sp , sp , -(PT_SIZE_ON_STACK)
80
80
save_all_base_regs
81
81
82
82
move a0 , sp /* pt_regs */
83
83
84
- call trampoline_probe_handler
84
+ call arch_rethook_trampoline_callback
85
85
86
86
/* use the result as the return-address */
87
87
move ra, a0
@@ -90,4 +90,4 @@ ENTRY(__kretprobe_trampoline)
90
90
addi sp , sp , PT_SIZE_ON_STACK
91
91
92
92
ret
93
- ENDPROC (__kretprobe_trampoline )
93
+ ENDPROC (arch_rethook_trampoline )
You can’t perform that action at this time.
0 commit comments