That's an adaptation of commit f3a112c0c40d ("x86,rethook,kprobes:
Replace kretprobe with rethook on x86") to loongarch.
Replaces the kretprobe code with rethook on loongarch. With this patch,
kretprobe on loongarch uses the rethook instead of kretprobe specific
trampoline code.
Signed-off-by: jianghaoran<jianghaoran@xxxxxxxxxx>
Signed-off-by: jhrhhao<jhrhhao@xxxxxxx>
---
arch/loongarch/Kconfig | 1 +
arch/loongarch/include/asm/kprobes.h | 3 ---
arch/loongarch/kernel/Makefile | 3 ++-
arch/loongarch/kernel/kprobes.c | 20 --------------
arch/loongarch/kernel/rethook.c | 27 +++++++++++++++++++
arch/loongarch/kernel/rethook.h | 9 +++++++
...obes_trampoline.S => rethook_trampoline.S} | 6 ++---
7 files changed, 42 insertions(+), 27 deletions(-)
create mode 100644 arch/loongarch/kernel/rethook.c
create mode 100644 arch/loongarch/kernel/rethook.h
rename arch/loongarch/kernel/{kprobes_trampoline.S => rethook_trampoline.S} (93%)
--- a/arch/loongarch/kernel/kprobes.c
+++ b/arch/loongarch/kernel/kprobes.c
@@ -378,26 +378,6 @@ int __init arch_init_kprobes(void)
return 0;
}
-/* ASM function that handles the kretprobes must not be probed */
-NOKPROBE_SYMBOL(__kretprobe_trampoline);
-
-/* Called from __kretprobe_trampoline */
-void __used *trampoline_probe_handler(struct pt_regs *regs)
-{
- return (void *)kretprobe_trampoline_handler(regs, NULL);
-}
-NOKPROBE_SYMBOL(trampoline_probe_handler);
-
-void arch_prepare_kretprobe(struct kretprobe_instance *ri,
- struct pt_regs *regs)
-{
- ri->ret_addr = (kprobe_opcode_t *)regs->regs[1];
- ri->fp = NULL;
-
- /* Replace the return addr with trampoline addr */
- regs->regs[1] = (unsigned long)&__kretprobe_trampoline;
-}
-NOKPROBE_SYMBOL(arch_prepare_kretprobe);
int arch_trampoline_kprobe(struct kprobe *p)
-SYM_CODE_END(__kretprobe_trampoline)
+SYM_CODE_END(arch_rethook_trampoline)