From: "Hou Wenlong" <houwenlong.hwl@antgroup.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: <linux-kernel@vger.kernel.org>,
"Thomas Garnier" <thgarnie@chromium.org>,
"Lai Jiangshan" <jiangshan.ljs@antgroup.com>,
"Kees Cook" <keescook@chromium.org>,
"Masami Hiramatsu" <mhiramat@kernel.org>,
"Mark Rutland" <mark.rutland@arm.com>,
"Thomas Gleixner" <tglx@linutronix.de>,
"Ingo Molnar" <mingo@redhat.com>,
"Borislav Petkov" <bp@alien8.de>,
"Dave Hansen" <dave.hansen@linux.intel.com>, <x86@kernel.org>,
"H. Peter Anvin" <hpa@zytor.com>,
<linux-trace-kernel@vger.kernel.org>
Subject: Re: [PATCH RFC 21/43] x86/ftrace: Adapt assembly for PIE support
Date: Sat, 29 Apr 2023 11:43:15 +0800 [thread overview]
Message-ID: <20230429034315.GB91541@k08j02272.eu95sqa> (raw)
In-Reply-To: <20230428093719.037081e3@gandalf.local.home>
On Fri, Apr 28, 2023 at 09:37:19PM +0800, Steven Rostedt wrote:
> On Fri, 28 Apr 2023 17:51:01 +0800
> "Hou Wenlong" <houwenlong.hwl@antgroup.com> wrote:
>
> > Change the assembly code to use only relative references of symbols for
> > the kernel to be PIE compatible.
> >
> > Signed-off-by: Hou Wenlong <houwenlong.hwl@antgroup.com>
> > Cc: Thomas Garnier <thgarnie@chromium.org>
> > Cc: Lai Jiangshan <jiangshan.ljs@antgroup.com>
> > Cc: Kees Cook <keescook@chromium.org>
> > ---
> > arch/x86/kernel/ftrace_64.S | 9 ++++++++-
> > 1 file changed, 8 insertions(+), 1 deletion(-)
> >
> > diff --git a/arch/x86/kernel/ftrace_64.S b/arch/x86/kernel/ftrace_64.S
> > index eddb4fabc16f..411fa4148e18 100644
> > --- a/arch/x86/kernel/ftrace_64.S
> > +++ b/arch/x86/kernel/ftrace_64.S
> > @@ -315,7 +315,14 @@ STACK_FRAME_NON_STANDARD_FP(ftrace_regs_caller)
> > SYM_FUNC_START(__fentry__)
> > CALL_DEPTH_ACCOUNT
> >
> > +#ifdef CONFIG_X86_PIE
> > + pushq %r8
> > + leaq ftrace_stub(%rip), %r8
> > + cmpq %r8, ftrace_trace_function(%rip)
> > + popq %r8
> > +#else
> > cmpq $ftrace_stub, ftrace_trace_function
> > +#endif
> > jnz trace
> > RET
> >
> > @@ -329,7 +336,7 @@ trace:
> > * ip and parent ip are used and the list function is called when
> > * function tracing is enabled.
> > */
> > - movq ftrace_trace_function, %r8
> > + movq ftrace_trace_function(%rip), %r8
> > CALL_NOSPEC r8
> > restore_mcount_regs
> >
>
> I really don't want to add more updates to !DYNAMIC_FTRACE. This code only
> exists to make sure I don't break it for other architectures.
>
> How about
>
> diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
> index 442eccc00960..ee4d0713139d 100644
> --- a/arch/x86/Kconfig
> +++ b/arch/x86/Kconfig
> @@ -37,7 +37,7 @@ config X86_64
>
> config FORCE_DYNAMIC_FTRACE
> def_bool y
> - depends on X86_32
> + depends on X86_32 || X86_PIE
> depends on FUNCTION_TRACER
> select DYNAMIC_FTRACE
> help
>
>
> ?
>
OK, I'll drop it. Actually, I select DYNAMIC_FTRACE when
CONFIG_RETPOLINE is enabled for PIE due to the indirect call for
__fentry__() in patch 34.
Thanks.
> -- Steve
next prev parent reply other threads:[~2023-04-29 3:43 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <cover.1682673542.git.houwenlong.hwl@antgroup.com>
2023-04-28 9:51 ` [PATCH RFC 21/43] x86/ftrace: Adapt assembly for PIE support Hou Wenlong
2023-04-28 13:37 ` Steven Rostedt
2023-04-29 3:43 ` Hou Wenlong [this message]
2023-04-28 9:51 ` [PATCH RFC 22/43] x86/ftrace: Adapt ftrace nop patching " Hou Wenlong
2023-04-28 13:44 ` Steven Rostedt
2023-04-29 3:38 ` Hou Wenlong
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=20230429034315.GB91541@k08j02272.eu95sqa \
--to=houwenlong.hwl@antgroup.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=jiangshan.ljs@antgroup.com \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mhiramat@kernel.org \
--cc=mingo@redhat.com \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
--cc=thgarnie@chromium.org \
--cc=x86@kernel.org \
/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