diff options
author | Youling Tang <tangyouling@loongson.cn> | 2023-05-01 17:19:53 +0800 |
---|---|---|
committer | Huacai Chen <chenhuacai@loongson.cn> | 2023-05-01 17:19:53 +0800 |
commit | 22f367a689ceceb08d9ce6a65c43c9640f5cb935 (patch) | |
tree | 7147bf854ddf5513492435dfdb2fa041da76e829 /samples/ftrace/ftrace-direct-multi.c | |
parent | 9cdc3b6a299c6314485bcfb695546c11d35dac4c (diff) | |
download | linux-stable-22f367a689ceceb08d9ce6a65c43c9640f5cb935.tar.gz linux-stable-22f367a689ceceb08d9ce6a65c43c9640f5cb935.tar.bz2 linux-stable-22f367a689ceceb08d9ce6a65c43c9640f5cb935.zip |
LoongArch: ftrace: Add direct call trampoline samples support
The ftrace samples need per-architecture trampoline implementations to
save and restore argument registers around the calls to my_direct_func*
and to restore polluted registers (e.g: ra).
Signed-off-by: Qing Zhang <zhangqing@loongson.cn>
Signed-off-by: Youling Tang <tangyouling@loongson.cn>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Diffstat (limited to 'samples/ftrace/ftrace-direct-multi.c')
-rw-r--r-- | samples/ftrace/ftrace-direct-multi.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/samples/ftrace/ftrace-direct-multi.c b/samples/ftrace/ftrace-direct-multi.c index c27cf130c319..c2f1652c67bc 100644 --- a/samples/ftrace/ftrace-direct-multi.c +++ b/samples/ftrace/ftrace-direct-multi.c @@ -66,6 +66,31 @@ asm ( #endif /* CONFIG_S390 */ +#ifdef CONFIG_LOONGARCH + +#include <asm/asm.h> +asm ( +" .pushsection .text, \"ax\", @progbits\n" +" .type my_tramp, @function\n" +" .globl my_tramp\n" +" my_tramp:\n" +" addi.d $sp, $sp, -32\n" +" st.d $a0, $sp, 0\n" +" st.d $t0, $sp, 8\n" +" st.d $ra, $sp, 16\n" +" move $a0, $t0\n" +" bl my_direct_func\n" +" ld.d $a0, $sp, 0\n" +" ld.d $t0, $sp, 8\n" +" ld.d $ra, $sp, 16\n" +" addi.d $sp, $sp, 32\n" +" jr $t0\n" +" .size my_tramp, .-my_tramp\n" +" .popsection\n" +); + +#endif /* CONFIG_LOONGARCH */ + static struct ftrace_ops direct; static int __init ftrace_direct_multi_init(void) |