<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel/linux.git/arch/riscv/lib/error-inject.c, branch v6.12.80</title>
<subtitle>Linux kernel stable tree (mirror)</subtitle>
<id>https://git.radix-linux.su/kernel/linux.git/atom?h=v6.12.80</id>
<link rel='self' href='https://git.radix-linux.su/kernel/linux.git/atom?h=v6.12.80'/>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/'/>
<updated>2021-01-14T23:09:09+00:00</updated>
<entry>
<title>riscv: Add support for function error injection</title>
<updated>2021-01-14T23:09:09+00:00</updated>
<author>
<name>Guo Ren</name>
<email>guoren@linux.alibaba.com</email>
</author>
<published>2020-12-17T16:01:45+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=ee55ff803b383e03d0855661d3416aa1763e54f9'/>
<id>urn:sha1:ee55ff803b383e03d0855661d3416aa1763e54f9</id>
<content type='text'>
Inspired by the commit 42d038c4fb00 ("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 &gt; inject
 echo 100 &gt; probability
 echo 1 &gt; 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] [&lt;ffffffe0002036b6&gt;] walk_stackframe+0x0/0xc2
[  313.191626] [&lt;ffffffe00020395c&gt;] show_stack+0x40/0x4c
[  313.193927] [&lt;ffffffe000556c60&gt;] dump_stack+0x7c/0x96
[  313.194795] [&lt;ffffffe0005522e8&gt;] should_fail+0x140/0x142
[  313.195923] [&lt;ffffffe000299ffc&gt;] fei_kprobe_handler+0x2c/0x5a
[  313.197687] [&lt;ffffffe0009e2ec4&gt;] kprobe_breakpoint_handler+0xb4/0x18a
[  313.200054] [&lt;ffffffe00020357e&gt;] do_trap_break+0x36/0xca
[  313.202147] [&lt;ffffffe000201bca&gt;] ret_from_exception+0x0/0xc
[  313.204556] [&lt;ffffffe000201bbc&gt;] ret_from_syscall+0x0/0x2
-sh: can't fork: Invalid argument

Signed-off-by: Guo Ren &lt;guoren@linux.alibaba.com&gt;
Reviewed-by: Masami Hiramatsu &lt;mhiramat@kernel.org&gt;
Cc: Palmer Dabbelt &lt;palmerdabbelt@google.com&gt;
Cc: Paul Walmsley &lt;paul.walmsley@sifive.com&gt;
Signed-off-by: Palmer Dabbelt &lt;palmerdabbelt@google.com&gt;
</content>
</entry>
</feed>
