mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mark Rutland <mark.rutland@arm.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: linux-kernel@vger.kernel.org,
	Joel Fernandes <joel@joelfernandes.org>,
	Jiping Ma <jiping.ma2@windriver.com>,
	mingo@redhat.com, catalin.marinas@arm.com, will.deacon@arm.com,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH 0/2] tracing/arm: Fix the stack tracer when LR is saved after local storage
Date: Wed, 7 Aug 2019 18:08:14 +0100	[thread overview]
Message-ID: <20190807170814.GA45351@lakrids.cambridge.arm.com> (raw)
In-Reply-To: <20190807163401.570339297@goodmis.org>

Hi Steve,

On Wed, Aug 07, 2019 at 12:34:01PM -0400, Steven Rostedt wrote:
> As arm64 saves the link register after a function's local variables are
> stored, it causes the max stack tracer to be off by one in its output
> of which function has the bloated stack frame.

For reference, it's a bit more complex than that. :/

Our procedure call standard (the AAPCS) says that the frame record may
be placed anywhere within a stackframe, so we don't have a guarantee as
to where the saved lr will fall w.r.t local variables.

Today, GCC happens to create the stack frame by creating the stack
record, so the LR is saved at a lower addresss than the local variables.

However, I am aware that there are reasons why a compiler may choose to
place the frame record at a different locations, e.g. using pointer
authentication to provide an implicit stack canary, so this could change
in future, or potentially differ across functions.

Maybe that's a bridge we'll have to cross in future.

Thanks,
Mark.

> 
> The first patch fixes this by creating a ARCH_RET_ADDR_BEFORE_LOCAL_VARS
> define that an achitecture (arm64) may set in asm/ftrace.h, and this
> will cause the stack tracer to make the shift.
> 
> As it has been proven that the stack tracer isn't the most trivial
> algorithm to understand by staring at the code, the second patch adds
> comments to the code to explain the algorithm with and without the
> ARCH_RET_ADDR_BEFORE_LOCAL_VARS.
> 
> Hmm, should this be sent to stable (and for inclusion now?)
> 
> -- Steve
> 
> Steven Rostedt (VMware) (2):
>       tracing/arm64: Have max stack tracer handle the case of return address after data
>       tracing: Document the stack trace algorithm in the comments
> 
> ----
>  arch/arm64/include/asm/ftrace.h |   1 +
>  kernel/trace/trace_stack.c      | 112 ++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 113 insertions(+)

  parent reply	other threads:[~2019-08-07 17:08 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-07 16:34 Steven Rostedt
2019-08-07 16:34 ` [PATCH 1/2] tracing/arm64: Have max stack tracer handle the case of return address after data Steven Rostedt
2019-08-07 16:34 ` [PATCH 2/2] tracing: Document the stack trace algorithm in the comments Steven Rostedt
2019-08-07 16:40   ` Steven Rostedt
2019-08-07 17:08 ` Mark Rutland [this message]
2019-08-07 17:20   ` [PATCH 0/2] tracing/arm: Fix the stack tracer when LR is saved after local storage Steven Rostedt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190807170814.GA45351@lakrids.cambridge.arm.com \
    --to=mark.rutland@arm.com \
    --cc=catalin.marinas@arm.com \
    --cc=jiping.ma2@windriver.com \
    --cc=joel@joelfernandes.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=rostedt@goodmis.org \
    --cc=will.deacon@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®