1*b57c2f12SBinglei Wang // SPDX-License-Identifier: GPL-2.0-only 2*b57c2f12SBinglei Wang /* 3*b57c2f12SBinglei Wang * Generic return hook for riscv. 4*b57c2f12SBinglei Wang */ 5*b57c2f12SBinglei Wang 6*b57c2f12SBinglei Wang #include <linux/kprobes.h> 7*b57c2f12SBinglei Wang #include <linux/rethook.h> 8*b57c2f12SBinglei Wang #include "rethook.h" 9*b57c2f12SBinglei Wang 10*b57c2f12SBinglei Wang /* This is called from arch_rethook_trampoline() */ arch_rethook_trampoline_callback(struct pt_regs * regs)11*b57c2f12SBinglei Wangunsigned long __used arch_rethook_trampoline_callback(struct pt_regs *regs) 12*b57c2f12SBinglei Wang { 13*b57c2f12SBinglei Wang return rethook_trampoline_handler(regs, regs->s0); 14*b57c2f12SBinglei Wang } 15*b57c2f12SBinglei Wang 16*b57c2f12SBinglei Wang NOKPROBE_SYMBOL(arch_rethook_trampoline_callback); 17*b57c2f12SBinglei Wang arch_rethook_prepare(struct rethook_node * rhn,struct pt_regs * regs,bool mcount)18*b57c2f12SBinglei Wangvoid arch_rethook_prepare(struct rethook_node *rhn, struct pt_regs *regs, bool mcount) 19*b57c2f12SBinglei Wang { 20*b57c2f12SBinglei Wang rhn->ret_addr = regs->ra; 21*b57c2f12SBinglei Wang rhn->frame = regs->s0; 22*b57c2f12SBinglei Wang 23*b57c2f12SBinglei Wang /* replace return addr with trampoline */ 24*b57c2f12SBinglei Wang regs->ra = (unsigned long)arch_rethook_trampoline; 25*b57c2f12SBinglei Wang } 26*b57c2f12SBinglei Wang 27*b57c2f12SBinglei Wang NOKPROBE_SYMBOL(arch_rethook_prepare); 28