linux-stable/arch
Guo Ren ee55ff803b
riscv: Add support for function error injection
Inspired by the commit 42d038c4fb ("arm64: Add support for function
error injection"), this patch supports function error injection for
riscv.

This patch mainly support two functions: one is regs_set_return_value()
which is used to overwrite the return value; the another function is
override_function_with_return() which is to override the probed
function returning and jump to its caller.

Test log:
 cd /sys/kernel/debug/fail_function
 echo sys_clone > inject
 echo 100 > probability
 echo 1 > interval
 ls /
[  313.176875] FAULT_INJECTION: forcing a failure.
[  313.176875] name fail_function, interval 1, probability 100, space 0, times 1
[  313.184357] CPU: 0 PID: 87 Comm: sh Not tainted 5.8.0-rc5-00007-g6a758cc #117
[  313.187616] Call Trace:
[  313.189100] [<ffffffe0002036b6>] walk_stackframe+0x0/0xc2
[  313.191626] [<ffffffe00020395c>] show_stack+0x40/0x4c
[  313.193927] [<ffffffe000556c60>] dump_stack+0x7c/0x96
[  313.194795] [<ffffffe0005522e8>] should_fail+0x140/0x142
[  313.195923] [<ffffffe000299ffc>] fei_kprobe_handler+0x2c/0x5a
[  313.197687] [<ffffffe0009e2ec4>] kprobe_breakpoint_handler+0xb4/0x18a
[  313.200054] [<ffffffe00020357e>] do_trap_break+0x36/0xca
[  313.202147] [<ffffffe000201bca>] ret_from_exception+0x0/0xc
[  313.204556] [<ffffffe000201bbc>] ret_from_syscall+0x0/0x2
-sh: can't fork: Invalid argument

Signed-off-by: Guo Ren <guoren@linux.alibaba.com>
Reviewed-by: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Palmer Dabbelt <palmerdabbelt@google.com>
Cc: Paul Walmsley <paul.walmsley@sifive.com>
Signed-off-by: Palmer Dabbelt <palmerdabbelt@google.com>
2021-01-14 15:09:09 -08:00
..
alpha local64.h: make <asm/local64.h> mandatory 2020-12-29 15:36:49 -08:00
arc local64.h: make <asm/local64.h> mandatory 2020-12-29 15:36:49 -08:00
arm local64.h: make <asm/local64.h> mandatory 2020-12-29 15:36:49 -08:00
arm64 numa: Move numa implementation to common code 2021-01-14 15:08:55 -08:00
c6x tif-task_work.arch-2020-12-14 2020-12-16 12:33:35 -08:00
csky local64.h: make <asm/local64.h> mandatory 2020-12-29 15:36:49 -08:00
h8300 local64.h: make <asm/local64.h> mandatory 2020-12-29 15:36:49 -08:00
hexagon local64.h: make <asm/local64.h> mandatory 2020-12-29 15:36:49 -08:00
ia64 local64.h: make <asm/local64.h> mandatory 2020-12-29 15:36:49 -08:00
m68k local64.h: make <asm/local64.h> mandatory 2020-12-29 15:36:49 -08:00
microblaze local64.h: make <asm/local64.h> mandatory 2020-12-29 15:36:49 -08:00
mips local64.h: make <asm/local64.h> mandatory 2020-12-29 15:36:49 -08:00
nds32 local64.h: make <asm/local64.h> mandatory 2020-12-29 15:36:49 -08:00
nios2 tif-task_work.arch-2020-12-14 2020-12-16 12:33:35 -08:00
openrisc local64.h: make <asm/local64.h> mandatory 2020-12-29 15:36:49 -08:00
parisc local64.h: make <asm/local64.h> mandatory 2020-12-29 15:36:49 -08:00
powerpc local64.h: make <asm/local64.h> mandatory 2020-12-29 15:36:49 -08:00
riscv riscv: Add support for function error injection 2021-01-14 15:09:09 -08:00
s390 - Update defconfigs and sort config select list. 2021-01-02 12:22:46 -08:00
sh local64.h: make <asm/local64.h> mandatory 2020-12-29 15:36:49 -08:00
sparc local64.h: make <asm/local64.h> mandatory 2020-12-29 15:36:49 -08:00
um This pull request contains the following changes for UML: 2020-12-17 17:56:44 -08:00
x86 local64.h: make <asm/local64.h> mandatory 2020-12-29 15:36:49 -08:00
xtensa local64.h: make <asm/local64.h> mandatory 2020-12-29 15:36:49 -08:00
.gitignore
Kconfig kasan: allow VMAP_STACK for HW_TAGS mode 2020-12-22 12:55:08 -08:00