diff options
author | Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com> | 2018-06-07 05:52:02 -0400 |
---|---|---|
committer | Michael Ellerman <mpe@ellerman.id.au> | 2018-10-19 22:26:43 -0400 |
commit | 7cd01b08d35f1b7d55686ed8cd57c94d3406ec8f (patch) | |
tree | ba2112d797cf4e9ba7c690fe9bbe07dad8d5a873 /arch/powerpc/lib/error-inject.c | |
parent | b4d16ab58c41ff0125822464bdff074cebd0fe47 (diff) |
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>
Diffstat (limited to 'arch/powerpc/lib/error-inject.c')
-rw-r--r-- | arch/powerpc/lib/error-inject.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/arch/powerpc/lib/error-inject.c b/arch/powerpc/lib/error-inject.c new file mode 100644 index 000000000000..407b992fb02f --- /dev/null +++ b/arch/powerpc/lib/error-inject.c | |||
@@ -0,0 +1,16 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0+ | ||
2 | |||
3 | #include <linux/error-injection.h> | ||
4 | #include <linux/kprobes.h> | ||
5 | #include <linux/uaccess.h> | ||
6 | |||
7 | void override_function_with_return(struct pt_regs *regs) | ||
8 | { | ||
9 | /* | ||
10 | * Emulate 'blr'. 'regs' represents the state on entry of a predefined | ||
11 | * function in the kernel/module, captured on a kprobe. We don't need | ||
12 | * to worry about 32-bit userspace on a 64-bit kernel. | ||
13 | */ | ||
14 | regs->nip = regs->link; | ||
15 | } | ||
16 | NOKPROBE_SYMBOL(override_function_with_return); | ||