mirror of
https://gitee.com/open-loongarch/linux-6.12.git
synced 2026-10-25 12:37:11 +08:00
samples/ftrace: Adjust LoongArch register restore order in direct calls
Ensure that in the ftrace direct call logic, the CPU register state (with ra = parent return address) is restored to the correct state after the execution of the custom trampoline function and before returning to the traced function. Additionally, guarantee the correctness of the jump logic for jr t0 (traced function address). Cc: stable@vger.kernel.org Fixes: 9cdc3b6a299c ("LoongArch: ftrace: Add direct call support") Reported-by: Youling Tang <tangyouling@kylinos.cn> Acked-by: Steven Rostedt (Google) <rostedt@goodmis.org> Signed-off-by: Chenghao Duan <duanchenghao@kylinos.cn> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn> Signed-off-by: maoxiaochuan <maoxiaochuan@loongson.cn>
This commit is contained in:
committed by
maoxiaochuan
parent
df18654a87
commit
f7c0f697c3
@@ -176,8 +176,8 @@ asm (
|
||||
" st.d $t0, $sp, 0\n"
|
||||
" st.d $ra, $sp, 8\n"
|
||||
" bl my_direct_func1\n"
|
||||
" ld.d $t0, $sp, 0\n"
|
||||
" ld.d $ra, $sp, 8\n"
|
||||
" ld.d $ra, $sp, 0\n"
|
||||
" ld.d $t0, $sp, 8\n"
|
||||
" addi.d $sp, $sp, 16\n"
|
||||
" jr $t0\n"
|
||||
" .size my_tramp1, .-my_tramp1\n"
|
||||
@@ -189,8 +189,8 @@ asm (
|
||||
" st.d $t0, $sp, 0\n"
|
||||
" st.d $ra, $sp, 8\n"
|
||||
" bl my_direct_func2\n"
|
||||
" ld.d $t0, $sp, 0\n"
|
||||
" ld.d $ra, $sp, 8\n"
|
||||
" ld.d $ra, $sp, 0\n"
|
||||
" ld.d $t0, $sp, 8\n"
|
||||
" addi.d $sp, $sp, 16\n"
|
||||
" jr $t0\n"
|
||||
" .size my_tramp2, .-my_tramp2\n"
|
||||
|
||||
@@ -199,8 +199,8 @@ asm (
|
||||
" move $a0, $t0\n"
|
||||
" bl my_direct_func1\n"
|
||||
" ld.d $a0, $sp, 0\n"
|
||||
" ld.d $t0, $sp, 8\n"
|
||||
" ld.d $ra, $sp, 16\n"
|
||||
" ld.d $ra, $sp, 8\n"
|
||||
" ld.d $t0, $sp, 16\n"
|
||||
" addi.d $sp, $sp, 32\n"
|
||||
" jr $t0\n"
|
||||
" .size my_tramp1, .-my_tramp1\n"
|
||||
@@ -215,8 +215,8 @@ asm (
|
||||
" move $a0, $t0\n"
|
||||
" bl my_direct_func2\n"
|
||||
" ld.d $a0, $sp, 0\n"
|
||||
" ld.d $t0, $sp, 8\n"
|
||||
" ld.d $ra, $sp, 16\n"
|
||||
" ld.d $ra, $sp, 8\n"
|
||||
" ld.d $t0, $sp, 16\n"
|
||||
" addi.d $sp, $sp, 32\n"
|
||||
" jr $t0\n"
|
||||
" .size my_tramp2, .-my_tramp2\n"
|
||||
|
||||
@@ -131,8 +131,8 @@ asm (
|
||||
" 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"
|
||||
" ld.d $ra, $sp, 8\n"
|
||||
" ld.d $t0, $sp, 16\n"
|
||||
" addi.d $sp, $sp, 32\n"
|
||||
" jr $t0\n"
|
||||
" .size my_tramp, .-my_tramp\n"
|
||||
|
||||
@@ -143,8 +143,8 @@ asm (
|
||||
" ld.d $a0, $sp, 0\n"
|
||||
" ld.d $a1, $sp, 8\n"
|
||||
" ld.d $a2, $sp, 16\n"
|
||||
" ld.d $t0, $sp, 24\n"
|
||||
" ld.d $ra, $sp, 32\n"
|
||||
" ld.d $ra, $sp, 24\n"
|
||||
" ld.d $t0, $sp, 32\n"
|
||||
" addi.d $sp, $sp, 48\n"
|
||||
" jr $t0\n"
|
||||
" .size my_tramp, .-my_tramp\n"
|
||||
|
||||
@@ -124,8 +124,8 @@ asm (
|
||||
" 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"
|
||||
" ld.d $ra, $sp, 8\n"
|
||||
" ld.d $t0, $sp, 16\n"
|
||||
" addi.d $sp, $sp, 32\n"
|
||||
" jr $t0\n"
|
||||
" .size my_tramp, .-my_tramp\n"
|
||||
|
||||
Reference in New Issue
Block a user