From 7cd01b08d35f1b7d55686ed8cd57c94d3406ec8f Mon Sep 17 00:00:00 2001 From: "Naveen N. Rao" Date: Thu, 7 Jun 2018 15:22:02 +0530 Subject: 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 Reviewed-by: Samuel Mendoza-Jonas Signed-off-by: Michael Ellerman --- arch/powerpc/lib/error-inject.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 arch/powerpc/lib/error-inject.c (limited to 'arch/powerpc/lib/error-inject.c') 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 @@ +// SPDX-License-Identifier: GPL-2.0+ + +#include +#include +#include + +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); -- cgit v1.2.3