summaryrefslogtreecommitdiff
path: root/arch/loongarch/kernel/kprobes.c
diff options
context:
space:
mode:
authorTiezhu Yang <yangtiezhu@loongson.cn>2023-02-25 10:52:57 +0300
committerHuacai Chen <chenhuacai@loongson.cn>2023-02-25 17:12:17 +0300
commit3f5536860086d906b01ec5ed68cf50c7edcc40af (patch)
tree542900b59d0c7f793bb979e0b728dfbbccba0bb2 /arch/loongarch/kernel/kprobes.c
parent6d4cc40fb5f58147defc6c0e9d86e6232fe31616 (diff)
downloadlinux-3f5536860086d906b01ec5ed68cf50c7edcc40af.tar.xz
LoongArch: Add kretprobes support
Use the generic kretprobe trampoline handler to add kretprobes support for LoongArch. Tested-by: Jeff Xie <xiehuan09@gmail.com> Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Diffstat (limited to 'arch/loongarch/kernel/kprobes.c')
-rw-r--r--arch/loongarch/kernel/kprobes.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/arch/loongarch/kernel/kprobes.c b/arch/loongarch/kernel/kprobes.c
index 73eddd76f37c..56c8c4b09a42 100644
--- a/arch/loongarch/kernel/kprobes.c
+++ b/arch/loongarch/kernel/kprobes.c
@@ -377,3 +377,30 @@ 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)
+{
+ return 0;
+}
+NOKPROBE_SYMBOL(arch_trampoline_kprobe);