Message ID | 1392406515-27835-1-git-send-email-olof@lixom.net (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On 14 Feb 2014, at 19:35, Olof Johansson <olof@lixom.net> wrote: > The frame PC value in the unwind code used to just take the saved LR > value and use that. That's incorrect as a stack trace, since it shows > the return path stack, not the call path stack. > > In particular, it shows faulty information in case the bl is done as > the very last instruction of one label, since the return point will be > in the next label. That can easily be seen with tail calls to panic(), > which is marked __noreturn and thus doesn't have anything useful after it. > > Easiest here is to just correct the unwind code and do a -4, to get the > actual call site for the backtrace instead of the return site. > > Signed-off-by: Olof Johansson <olof@lixom.net> > Cc: stable@vger.kernel.org Looks fine. I’ll push it sometime next week. Thanks. Catalin -- IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you. ARM Limited, Registered office 110 Fulbourn Road, Cambridge CB1 9NJ, Registered in England & Wales, Company No: 2557590 ARM Holdings plc, Registered office 110 Fulbourn Road, Cambridge CB1 9NJ, Registered in England & Wales, Company No: 2548782
On 15 February 2014 10:28, Catalin Marinas <Catalin.Marinas@arm.com> wrote:
> -- IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
And BTW, please ignore this, I picked the wrong smtp server.
diff --git a/arch/arm64/kernel/stacktrace.c b/arch/arm64/kernel/stacktrace.c index c3b6c63..463a757 100644 --- a/arch/arm64/kernel/stacktrace.c +++ b/arch/arm64/kernel/stacktrace.c @@ -48,7 +48,11 @@ int unwind_frame(struct stackframe *frame) frame->sp = fp + 0x10; frame->fp = *(unsigned long *)(fp); - frame->pc = *(unsigned long *)(fp + 8); + /* + * -4 here because we care about the PC at time of bl, + * not where the return will go. + */ + frame->pc = *(unsigned long *)(fp + 8) - 4; return 0; }
The frame PC value in the unwind code used to just take the saved LR value and use that. That's incorrect as a stack trace, since it shows the return path stack, not the call path stack. In particular, it shows faulty information in case the bl is done as the very last instruction of one label, since the return point will be in the next label. That can easily be seen with tail calls to panic(), which is marked __noreturn and thus doesn't have anything useful after it. Easiest here is to just correct the unwind code and do a -4, to get the actual call site for the backtrace instead of the return site. Signed-off-by: Olof Johansson <olof@lixom.net> Cc: stable@vger.kernel.org --- arch/arm64/kernel/stacktrace.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)