public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: linux-kernel@vger.kernel.org, Ingo Molnar <mingo@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Miroslav Benes <mbenes@suse.cz>,
	Thomas Gleixner <tglx@linutronix.de>,
	Masami Hiramatsu <mhiramat@kernel.org>
Subject: Re: [PATCH 2/3 v4] ftrace/x86: Allow for arguments to be passed in to ftrace_regs by default
Date: Mon, 9 Nov 2020 12:10:43 +0100	[thread overview]
Message-ID: <20201109111043.GD2594@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20201106214403.328699055@goodmis.org>

On Fri, Nov 06, 2020 at 04:42:36PM -0500, Steven Rostedt wrote:
> +static __always_inline struct pt_regs *
> +arch_ftrace_get_regs(struct ftrace_regs *fregs)
> +{
> +	/* Only when FL_SAVE_REGS is set, cs will be non zero */
> +	if (!fregs->regs.cs)
> +		return NULL;
> +	return &fregs->regs;
> +}
> +#endif
> +
>  #endif /*  CONFIG_DYNAMIC_FTRACE */
>  #endif /* __ASSEMBLY__ */
>  #endif /* CONFIG_FUNCTION_TRACER */
> diff --git a/arch/x86/kernel/ftrace_64.S b/arch/x86/kernel/ftrace_64.S
> index ac3d5f22fe64..60e3b64f5ea6 100644
> --- a/arch/x86/kernel/ftrace_64.S
> +++ b/arch/x86/kernel/ftrace_64.S
> @@ -140,12 +140,19 @@ SYM_FUNC_START(ftrace_caller)
>  	/* save_mcount_regs fills in first two parameters */
>  	save_mcount_regs
>  
> +	/* Stack - skipping return address of ftrace_caller */
> +	leaq MCOUNT_REG_SIZE+8(%rsp), %rcx
> +	movq %rcx, RSP(%rsp)
> +
>  SYM_INNER_LABEL(ftrace_caller_op_ptr, SYM_L_GLOBAL)
>  	/* Load the ftrace_ops into the 3rd parameter */
>  	movq function_trace_op(%rip), %rdx
>  
> -	/* regs go into 4th parameter (but make it NULL) */
> -	movq $0, %rcx
> +	/* regs go into 4th parameter */
> +	leaq (%rsp), %rcx
> +
> +	/* Only ops with REGS flag set should have CS register set */
> +	movq $0, CS(%rsp)
>  
>  SYM_INNER_LABEL(ftrace_call, SYM_L_GLOBAL)
>  	call ftrace_stub

You now seem to be relying on save_mcount_regs() resulting in a cleared
CS, however, AFAICT CS is uninitialized stack garbage.

  reply	other threads:[~2020-11-09 11:10 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-06 21:42 [PATCH 0/3 v4] ftrace: Add access to function arguments for all callbacks Steven Rostedt
2020-11-06 21:42 ` [PATCH 1/3 v4] ftrace: Have the callbacks receive a struct ftrace_regs instead of pt_regs Steven Rostedt
2020-11-07  4:29   ` Masami Hiramatsu
2020-11-06 21:42 ` [PATCH 2/3 v4] ftrace/x86: Allow for arguments to be passed in to ftrace_regs by default Steven Rostedt
2020-11-09 11:10   ` Peter Zijlstra [this message]
2020-11-09 23:16     ` Steven Rostedt
2020-11-10  9:20       ` Peter Zijlstra
2020-11-06 21:42 ` [PATCH 3/3 v4] livepatch: Use the default ftrace_ops instead of REGS when ARGS is available 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=20201109111043.GD2594@hirez.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mbenes@suse.cz \
    --cc=mhiramat@kernel.org \
    --cc=mingo@kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    /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