Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ARM: 9279/1: support function error injection

This enables HAVE_FUNCTION_ERROR_INJECTION by adding necessary
regs_set_return_value() and override_function_with_return().

Simply tested according to Documentation/fault-injection/fault-injection.rst.

Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>

authored by

Wang Kefeng and committed by
Russell King (Oracle)
aaa4dd1b ba290d4f

+17
+1
arch/arm/Kconfig
··· 97 97 select HAVE_EXIT_THREAD 98 98 select HAVE_FAST_GUP if ARM_LPAE 99 99 select HAVE_FTRACE_MCOUNT_RECORD if !XIP_KERNEL 100 + select HAVE_FUNCTION_ERROR_INJECTION 100 101 select HAVE_FUNCTION_GRAPH_TRACER 101 102 select HAVE_FUNCTION_TRACER if !XIP_KERNEL 102 103 select HAVE_GCC_PLUGINS
+4
arch/arm/include/asm/ptrace.h
··· 163 163 ((current_stack_pointer | (THREAD_SIZE - 1)) - 7) - 1; \ 164 164 }) 165 165 166 + static inline void regs_set_return_value(struct pt_regs *regs, unsigned long rc) 167 + { 168 + regs->ARM_r0 = rc; 169 + } 166 170 167 171 /* 168 172 * Update ITSTATE after normal execution of an IT block instruction.
+2
arch/arm/lib/Makefile
··· 44 44 CFLAGS_xor-neon.o += $(NEON_FLAGS) 45 45 obj-$(CONFIG_XOR_BLOCKS) += xor-neon.o 46 46 endif 47 + 48 + obj-$(CONFIG_FUNCTION_ERROR_INJECTION) += error-inject.o
+10
arch/arm/lib/error-inject.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + 3 + #include <linux/error-injection.h> 4 + #include <linux/kprobes.h> 5 + 6 + void override_function_with_return(struct pt_regs *regs) 7 + { 8 + instruction_pointer_set(regs, regs->ARM_lr); 9 + } 10 + NOKPROBE_SYMBOL(override_function_with_return);