forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
arm64: Add support for function error injection
Inspired by the commit 7cd01b0 ("powerpc: Add support for function error injection"), this patch supports function error injection for Arm64. This patch mainly support two functions: one is regs_set_return_value() which is used to overwrite the return value; the another function is override_function_with_return() which is to override the probed function returning and jump to its caller. Reviewed-by: Masami Hiramatsu <mhiramat@kernel.org> Signed-off-by: Leo Yan <leo.yan@linaro.org> Signed-off-by: Will Deacon <will@kernel.org>
- Loading branch information
1 parent
45880f7
commit 42d038c
Showing
4 changed files
with
26 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// SPDX-License-Identifier: GPL-2.0 | ||
|
||
#include <linux/error-injection.h> | ||
#include <linux/kprobes.h> | ||
|
||
void override_function_with_return(struct pt_regs *regs) | ||
{ | ||
/* | ||
* 'regs' represents the state on entry of a predefined function in | ||
* the kernel/module and which is captured on a kprobe. | ||
* | ||
* When kprobe returns back from exception it will override the end | ||
* of probed function and directly return to the predefined | ||
* function's caller. | ||
*/ | ||
instruction_pointer_set(regs, procedure_link_pointer(regs)); | ||
} | ||
NOKPROBE_SYMBOL(override_function_with_return); |