From 22f367a689ceceb08d9ce6a65c43c9640f5cb935 Mon Sep 17 00:00:00 2001 From: Youling Tang Date: Mon, 1 May 2023 17:19:53 +0800 Subject: 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 Signed-off-by: Youling Tang Signed-off-by: Huacai Chen --- samples/ftrace/ftrace-direct.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'samples/ftrace/ftrace-direct.c') diff --git a/samples/ftrace/ftrace-direct.c b/samples/ftrace/ftrace-direct.c index 1d3d307ca33d..9be720957bf8 100644 --- a/samples/ftrace/ftrace-direct.c +++ b/samples/ftrace/ftrace-direct.c @@ -63,6 +63,29 @@ asm ( #endif /* CONFIG_S390 */ +#ifdef CONFIG_LOONGARCH + +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" +" 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 int __init ftrace_direct_init(void) { return register_ftrace_direct((unsigned long)wake_up_process, -- cgit v1.2.3