forked from microsoft/WSL2-Linux-Kernel
-
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.
LoongArch: Replace kretprobe with rethook
This is an adaptation of commit f3a112c ("x86,rethook,kprobes: Replace kretprobe with rethook on x86") and commit b57c2f1 ("riscv: add riscv rethook implementation") to LoongArch. Mainly refer to commit b57c2f1 ("riscv: add riscv rethook implementation"). Replaces the kretprobe code with rethook on LoongArch. With this patch, kretprobe on LoongArch uses the rethook instead of kretprobe specific trampoline code. Signed-off-by: Haoran Jiang <jianghaoran@kylinos.cn> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
- Loading branch information
1 parent
f02644e
commit 7b0a096
Showing
7 changed files
with
44 additions
and
28 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
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,28 @@ | ||
// SPDX-License-Identifier: GPL-2.0 | ||
/* | ||
* Generic return hook for LoongArch. | ||
*/ | ||
|
||
#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, 0); | ||
} | ||
NOKPROBE_SYMBOL(arch_rethook_trampoline_callback); | ||
|
||
void arch_rethook_prepare(struct rethook_node *rhn, struct pt_regs *regs, bool mcount) | ||
{ | ||
rhn->frame = 0; | ||
rhn->ret_addr = regs->regs[1]; | ||
|
||
/* replace return addr with trampoline */ | ||
regs->regs[1] = (unsigned long)arch_rethook_trampoline; | ||
} | ||
NOKPROBE_SYMBOL(arch_rethook_prepare); | ||
|
||
/* ASM function that handles the rethook must not be probed itself */ | ||
NOKPROBE_SYMBOL(arch_rethook_trampoline); |
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 */ | ||
#ifndef __LOONGARCH_RETHOOK_H | ||
#define __LOONGARCH_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