-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
riscv: add riscv rethook implementation
Implement the kretprobes on riscv arch by using rethook machenism which abstracts general kretprobe info into a struct rethook_node to be embedded in the struct kretprobe_instance. Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org> Signed-off-by: Binglei Wang <l3b2w1@gmail.com> Signed-off-by: Conor Dooley <conor.dooley@microchip.com> Link: https://lore.kernel.org/r/20221025151831.1097417-1-conor@kernel.org Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
- Loading branch information
Binglei Wang
authored and
Palmer Dabbelt
committed
Dec 2, 2022
1 parent
d8bf77a
commit b57c2f1
Showing
7 changed files
with
40 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# SPDX-License-Identifier: GPL-2.0 | ||
obj-$(CONFIG_KPROBES) += kprobes.o decode-insn.o simulate-insn.o | ||
obj-$(CONFIG_KPROBES) += kprobes_trampoline.o | ||
obj-$(CONFIG_RETHOOK) += rethook.o rethook_trampoline.o | ||
obj-$(CONFIG_KPROBES_ON_FTRACE) += ftrace.o | ||
obj-$(CONFIG_UPROBES) += uprobes.o decode-insn.o simulate-insn.o | ||
CFLAGS_REMOVE_simulate-insn.o = $(CC_FLAGS_FTRACE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// SPDX-License-Identifier: GPL-2.0-only | ||
/* | ||
* Generic return hook for riscv. | ||
*/ | ||
|
||
#include <linux/kprobes.h> | ||
#include <linux/rethook.h> | ||
#include "rethook.h" | ||
|
||
/* This is called from arch_rethook_trampoline() */ | ||
unsigned long __used arch_rethook_trampoline_callback(struct pt_regs *regs) | ||
{ | ||
return rethook_trampoline_handler(regs, regs->s0); | ||
} | ||
|
||
NOKPROBE_SYMBOL(arch_rethook_trampoline_callback); | ||
|
||
void arch_rethook_prepare(struct rethook_node *rhn, struct pt_regs *regs, bool mcount) | ||
{ | ||
rhn->ret_addr = regs->ra; | ||
rhn->frame = regs->s0; | ||
|
||
/* replace return addr with trampoline */ | ||
regs->ra = (unsigned long)arch_rethook_trampoline; | ||
} | ||
|
||
NOKPROBE_SYMBOL(arch_rethook_prepare); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/* SPDX-License-Identifier: GPL-2.0-only */ | ||
#ifndef __RISCV_RETHOOK_H | ||
#define __RISCV_RETHOOK_H | ||
|
||
unsigned long arch_rethook_trampoline_callback(struct pt_regs *regs); | ||
void arch_rethook_prepare(struct rethook_node *rhn, struct pt_regs *regs, bool mcount); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters