summaryrefslogtreecommitdiffstats
path: root/arch/riscv/include
diff options
context:
space:
mode:
authorZong Li <zong.li@sifive.com>2024-02-02 01:51:02 +0000
committerPalmer Dabbelt <palmer@rivosinc.com>2024-02-22 12:17:47 -0800
commit680341382da56bd192ebfa4e58eaf4fec2e5bca7 (patch)
tree60f39c539e677ba1a1b17691ae9188abd503781c /arch/riscv/include
parent4af24146aa24d06f4594a427354f7ac878118d38 (diff)
downloadlinux-stable-680341382da56bd192ebfa4e58eaf4fec2e5bca7.tar.gz
linux-stable-680341382da56bd192ebfa4e58eaf4fec2e5bca7.tar.bz2
linux-stable-680341382da56bd192ebfa4e58eaf4fec2e5bca7.zip
riscv: add CALLER_ADDRx support
CALLER_ADDRx returns caller's address at specified level, they are used for several tracers. These macros eventually use __builtin_return_address(n) to get the caller's address if arch doesn't define their own implementation. In RISC-V, __builtin_return_address(n) only works when n == 0, we need to walk the stack frame to get the caller's address at specified level. data.level started from 'level + 3' due to the call flow of getting caller's address in RISC-V implementation. If we don't have additional three iteration, the level is corresponding to follows: callsite -> return_address -> arch_stack_walk -> walk_stackframe | | | | level 3 level 2 level 1 level 0 Fixes: 10626c32e382 ("riscv/ftrace: Add basic support") Cc: stable@vger.kernel.org Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com> Signed-off-by: Zong Li <zong.li@sifive.com> Link: https://lore.kernel.org/r/20240202015102.26251-1-zong.li@sifive.com Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
Diffstat (limited to 'arch/riscv/include')
-rw-r--r--arch/riscv/include/asm/ftrace.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/arch/riscv/include/asm/ftrace.h b/arch/riscv/include/asm/ftrace.h
index 329172122952..15055f9df4da 100644
--- a/arch/riscv/include/asm/ftrace.h
+++ b/arch/riscv/include/asm/ftrace.h
@@ -25,6 +25,11 @@
#define ARCH_SUPPORTS_FTRACE_OPS 1
#ifndef __ASSEMBLY__
+
+extern void *return_address(unsigned int level);
+
+#define ftrace_return_address(n) return_address(n)
+
void MCOUNT_NAME(void);
static inline unsigned long ftrace_call_adjust(unsigned long addr)
{