]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
riscv: Fix fp alignment bug in perf_callchain_user()
authorJinjie Ruan <ruanjinjie@huawei.com>
Mon, 8 Jul 2024 03:28:46 +0000 (11:28 +0800)
committerPalmer Dabbelt <palmer@rivosinc.com>
Sun, 15 Sep 2024 06:57:15 +0000 (23:57 -0700)
The standard RISC-V calling convention said:
"The stack grows downward and the stack pointer is always
kept 16-byte aligned".

So perf_callchain_user() should check whether 16-byte aligned for fp.

Link: https://riscv.org/wp-content/uploads/2015/01/riscv-calling.pdf
Fixes: dbeb90b0c1eb ("riscv: Add perf callchain support")
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
Cc: Björn Töpel <bjorn@kernel.org>
Link: https://lore.kernel.org/r/20240708032847.2998158-2-ruanjinjie@huawei.com
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
arch/riscv/kernel/perf_callchain.c

index 3348a61de7d998c6a87ce8e7113d67fefc1c955a..2932791e93882176bd1a515781f9e9f0d1145424 100644 (file)
@@ -62,7 +62,7 @@ void perf_callchain_user(struct perf_callchain_entry_ctx *entry,
        perf_callchain_store(entry, regs->epc);
 
        fp = user_backtrace(entry, fp, regs->ra);
-       while (fp && !(fp & 0x3) && entry->nr < entry->max_stack)
+       while (fp && !(fp & 0x7) && entry->nr < entry->max_stack)
                fp = user_backtrace(entry, fp, 0);
 }