ARM: clang: Do not rely on lr register for stacktrace
authorMasami Hiramatsu <mhiramat@kernel.org>
Thu, 21 Oct 2021 00:55:17 +0000 (09:55 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 18 Nov 2021 18:16:19 +0000 (19:16 +0100)
commit7d341b27013e183e002043b2ec0db6ec6f24fa80
tree9e4ed37f6aa2212c0c6fd14352073a187d890b40
parent7f11e51f0c9d158e06eb240b5316b60e80a49fc1
ARM: clang: Do not rely on lr register for stacktrace

[ Upstream commit b3ea5d56f212ad81328c82454829a736197ebccc ]

Currently the stacktrace on clang compiled arm kernel uses the 'lr'
register to find the first frame address from pt_regs. However, that
is wrong after calling another function, because the 'lr' register
is used by 'bl' instruction and never be recovered.

As same as gcc arm kernel, directly use the frame pointer (r11) of
the pt_regs to find the first frame address.

Note that this fixes kretprobe stacktrace issue only with
CONFIG_UNWINDER_FRAME_POINTER=y. For the CONFIG_UNWINDER_ARM,
we need another fix.

Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
arch/arm/kernel/stacktrace.c