Skip to content

Commit aaa4dd1

Browse files
Wang KefengRussell King (Oracle)
authored andcommitted
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 <[email protected]> Signed-off-by: Russell King (Oracle) <[email protected]>
1 parent ba290d4 commit aaa4dd1

File tree

4 files changed

+17
-0
lines changed

4 files changed

+17
-0
lines changed

arch/arm/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ config ARM
9797
select HAVE_EXIT_THREAD
9898
select HAVE_FAST_GUP if ARM_LPAE
9999
select HAVE_FTRACE_MCOUNT_RECORD if !XIP_KERNEL
100+
select HAVE_FUNCTION_ERROR_INJECTION
100101
select HAVE_FUNCTION_GRAPH_TRACER
101102
select HAVE_FUNCTION_TRACER if !XIP_KERNEL
102103
select HAVE_GCC_PLUGINS

arch/arm/include/asm/ptrace.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,10 @@ static inline unsigned long user_stack_pointer(struct pt_regs *regs)
163163
((current_stack_pointer | (THREAD_SIZE - 1)) - 7) - 1; \
164164
})
165165

166+
static inline void regs_set_return_value(struct pt_regs *regs, unsigned long rc)
167+
{
168+
regs->ARM_r0 = rc;
169+
}
166170

167171
/*
168172
* Update ITSTATE after normal execution of an IT block instruction.

arch/arm/lib/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,5 @@ ifeq ($(CONFIG_KERNEL_MODE_NEON),y)
4444
CFLAGS_xor-neon.o += $(NEON_FLAGS)
4545
obj-$(CONFIG_XOR_BLOCKS) += xor-neon.o
4646
endif
47+
48+
obj-$(CONFIG_FUNCTION_ERROR_INJECTION) += error-inject.o

arch/arm/lib/error-inject.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
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);

0 commit comments

Comments
 (0)