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.
powerpc: Add support for function error injection
We implement regs_set_return_value() and override_function_with_return() for this purpose. On powerpc, a return from a function (blr) just branches to the location contained in the link register. So, we can just update pt_regs rather than redirecting execution to a dummy function that returns. Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com> Reviewed-by: Samuel Mendoza-Jonas <sam@mendozajonas.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
- Loading branch information
Showing
5 changed files
with
37 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* SPDX-License-Identifier: GPL-2.0+ */ | ||
|
||
#ifndef _ASM_ERROR_INJECTION_H | ||
#define _ASM_ERROR_INJECTION_H | ||
|
||
#include <linux/compiler.h> | ||
#include <linux/linkage.h> | ||
#include <asm/ptrace.h> | ||
#include <asm-generic/error-injection.h> | ||
|
||
void override_function_with_return(struct pt_regs *regs); | ||
|
||
#endif /* _ASM_ERROR_INJECTION_H */ |
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,16 @@ | ||
// SPDX-License-Identifier: GPL-2.0+ | ||
|
||
#include <linux/error-injection.h> | ||
#include <linux/kprobes.h> | ||
#include <linux/uaccess.h> | ||
|
||
void override_function_with_return(struct pt_regs *regs) | ||
{ | ||
/* | ||
* Emulate 'blr'. 'regs' represents the state on entry of a predefined | ||
* function in the kernel/module, captured on a kprobe. We don't need | ||
* to worry about 32-bit userspace on a 64-bit kernel. | ||
*/ | ||
regs->nip = regs->link; | ||
} | ||
NOKPROBE_SYMBOL(override_function_with_return); |