| 1 | // SPDX-License-Identifier: GPL-2.0 |
|---|---|
| 2 | /* |
| 3 | * Generic return hook for LoongArch. |
| 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, frame: 0); |
| 14 | } |
| 15 | NOKPROBE_SYMBOL(arch_rethook_trampoline_callback); |
| 16 | |
| 17 | void arch_rethook_prepare(struct rethook_node *rhn, struct pt_regs *regs, bool mcount) |
| 18 | { |
| 19 | rhn->frame = 0; |
| 20 | rhn->ret_addr = regs->regs[1]; |
| 21 | |
| 22 | /* replace return addr with trampoline */ |
| 23 | regs->regs[1] = (unsigned long)arch_rethook_trampoline; |
| 24 | } |
| 25 | NOKPROBE_SYMBOL(arch_rethook_prepare); |
| 26 | |
| 27 | /* ASM function that handles the rethook must not be probed itself */ |
| 28 | NOKPROBE_SYMBOL(arch_rethook_trampoline); |
| 29 |
