Loading...
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() */
11unsigned long __used arch_rethook_trampoline_callback(struct pt_regs *regs)
12{
13 return rethook_trampoline_handler(regs, regs->s0);
14}
15
16NOKPROBE_SYMBOL(arch_rethook_trampoline_callback);
17
18void 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
27NOKPROBE_SYMBOL(arch_rethook_prepare);