rethook.c 780 B

12345678910111213141516171819202122232425262728
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Generic return hook for LoongArch.
  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, 0);
  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->frame = 0;
  17. rhn->ret_addr = regs->regs[1];
  18. /* replace return addr with trampoline */
  19. regs->regs[1] = (unsigned long)arch_rethook_trampoline;
  20. }
  21. NOKPROBE_SYMBOL(arch_rethook_prepare);
  22. /* ASM function that handles the rethook must not be probed itself */
  23. NOKPROBE_SYMBOL(arch_rethook_trampoline);