Files
Zong Li 8a732c8ea5 riscv: add CALLER_ADDRx support
commit 680341382d upstream.

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: 10626c32e3 ("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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-03-18 12:51:50 +00:00
..
2023-11-28 17:19:49 +00:00
2023-08-23 14:16:39 -07:00
2023-03-23 08:47:00 -07:00
2024-02-05 20:14:31 +00:00
2022-12-29 06:59:47 -08:00
2024-03-18 12:51:50 +00:00
2023-08-23 14:16:38 -07:00
2022-05-19 19:30:30 +02:00
2021-01-07 19:00:50 -08:00
2023-08-23 14:16:36 -07:00