Skip to content

Commit 39ef362

Browse files
madvenka786ctmarinas
authored andcommitted
arm64: Make return_address() use arch_stack_walk()
To enable RELIABLE_STACKTRACE and LIVEPATCH on arm64, we need to substantially rework arm64's unwinding code. As part of this, we want to minimize the set of unwind interfaces we expose, and avoid open-coding of unwind logic outside of stacktrace.c. Currently return_address() walks the stack of the current task by calling start_backtrace() with return_address as the PC and the frame pointer of return_address() as the next frame, iterating unwind steps using walk_stackframe(). This is functionally equivalent to calling arch_stack_walk() for the current stack, which will start from its caller (i.e. return_address()) as the PC and it's caller's frame record as the next frame. Make return_address() use arch_stackwalk(). This simplifies return_address(), and in future will alow us to make walk_stackframe() private to stacktrace.c. There should be no functional change as a result of this patch. Signed-off-by: Madhavan T. Venkataraman <[email protected]> Tested-by: Mark Rutland <[email protected]> Reviewed-by: Mark Brown <[email protected]> Reviewed-by: Mark Rutland <[email protected]> [Mark: elaborate commit message, fix includes] Signed-off-by: Mark Rutland <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Catalin Marinas <[email protected]>
1 parent 4f62bb7 commit 39ef362

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

arch/arm64/kernel/return_address.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
#include <linux/export.h>
1010
#include <linux/ftrace.h>
1111
#include <linux/kprobes.h>
12+
#include <linux/stacktrace.h>
1213

1314
#include <asm/stack_pointer.h>
14-
#include <asm/stacktrace.h>
1515

1616
struct return_address_data {
1717
unsigned int level;
@@ -35,15 +35,11 @@ NOKPROBE_SYMBOL(save_return_addr);
3535
void *return_address(unsigned int level)
3636
{
3737
struct return_address_data data;
38-
struct stackframe frame;
3938

4039
data.level = level + 2;
4140
data.addr = NULL;
4241

43-
start_backtrace(&frame,
44-
(unsigned long)__builtin_frame_address(0),
45-
(unsigned long)return_address);
46-
walk_stackframe(current, &frame, save_return_addr, &data);
42+
arch_stack_walk(save_return_addr, &data, current, NULL);
4743

4844
if (!data.level)
4945
return data.addr;

0 commit comments

Comments
 (0)