rethook.c 674 B

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