mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] x86: Fix export for mcount and __fentry__
@ 2016-10-24 19:01 Steven Rostedt
  2016-10-24 19:17 ` Borislav Petkov
  2016-10-26 10:43 ` [tip:x86/urgent] " tip-bot for Steven Rostedt
  0 siblings, 2 replies; 3+ messages in thread
From: Steven Rostedt @ 2016-10-24 19:01 UTC (permalink / raw)
  To: LKML
  Cc: Nicholas Piggin, Al Viro, Borislav Petkov, Thomas Gleixner,
	Ingo Molnar, Gabriel C

Commit 784d5699eddc5 ("x86: move exports to actual definitions") removed the
EXPORT_SYMBOL(__fentry__) and EXPORT_SYMBOL(mcount) from x8664_ksyms_64.c,
and added EXPORT_SYMBOL(function_hook) in mcount_64.S instead. The problem
is that function_hook isn't a function at all, but a macro that is defined
as either mcount or __fentry__ depending on the support from gcc.

Originally, I thought this was a macro issue, like what __stringify()
is used for. But the problem is a bit deeper. The Makefile.build has
some magic that does post processing of files to create the CRC
bindings. It does some searches for EXPORT_SYMBOL() and because it
finds a macro name and not the actual functions, this causes
function_hook not to be converted into mcount or __fentry__ and they
are missed.

Instead of adding more magic to Makefile.build, just add
EXPORT_SYMBOL() for mcount and __fentry__ where the ifdef is used.
Since this is assembly and not C, it doesn't require being set after
the function is defined.

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 arch/x86/kernel/mcount_64.S |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Index: linux-trace.git/arch/x86/kernel/mcount_64.S
===================================================================
--- linux-trace.git.orig/arch/x86/kernel/mcount_64.S	2016-10-24 11:35:14.410524414 -0400
+++ linux-trace.git/arch/x86/kernel/mcount_64.S	2016-10-24 11:37:23.593443665 -0400
@@ -18,8 +18,10 @@
 
 #ifdef CC_USING_FENTRY
 # define function_hook	__fentry__
+EXPORT_SYMBOL(__fentry__)
 #else
 # define function_hook	mcount
+EXPORT_SYMBOL(mcount)
 #endif
 
 /* All cases save the original rbp (8 bytes) */
@@ -295,7 +297,6 @@ trace:
 	jmp fgraph_trace
 END(function_hook)
 #endif /* CONFIG_DYNAMIC_FTRACE */
-EXPORT_SYMBOL(function_hook)
 #endif /* CONFIG_FUNCTION_TRACER */
 
 #ifdef CONFIG_FUNCTION_GRAPH_TRACER

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] x86: Fix export for mcount and __fentry__
  2016-10-24 19:01 [PATCH] x86: Fix export for mcount and __fentry__ Steven Rostedt
@ 2016-10-24 19:17 ` Borislav Petkov
  2016-10-26 10:43 ` [tip:x86/urgent] " tip-bot for Steven Rostedt
  1 sibling, 0 replies; 3+ messages in thread
From: Borislav Petkov @ 2016-10-24 19:17 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: LKML, Nicholas Piggin, Al Viro, Thomas Gleixner, Ingo Molnar, Gabriel C

On Mon, Oct 24, 2016 at 03:01:48PM -0400, Steven Rostedt wrote:
> Commit 784d5699eddc5 ("x86: move exports to actual definitions") removed the
> EXPORT_SYMBOL(__fentry__) and EXPORT_SYMBOL(mcount) from x8664_ksyms_64.c,
> and added EXPORT_SYMBOL(function_hook) in mcount_64.S instead. The problem
> is that function_hook isn't a function at all, but a macro that is defined
> as either mcount or __fentry__ depending on the support from gcc.
> 
> Originally, I thought this was a macro issue, like what __stringify()
> is used for. But the problem is a bit deeper. The Makefile.build has
> some magic that does post processing of files to create the CRC
> bindings. It does some searches for EXPORT_SYMBOL() and because it
> finds a macro name and not the actual functions, this causes
> function_hook not to be converted into mcount or __fentry__ and they
> are missed.
> 
> Instead of adding more magic to Makefile.build, just add
> EXPORT_SYMBOL() for mcount and __fentry__ where the ifdef is used.
> Since this is assembly and not C, it doesn't require being set after
> the function is defined.
> 
> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>

Tested-by: Borislav Petkov <bp@suse.de>

-- 
Regards/Gruss,
    Boris.

ECO tip #101: Trim your mails when you reply.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [tip:x86/urgent] x86: Fix export for mcount and __fentry__
  2016-10-24 19:01 [PATCH] x86: Fix export for mcount and __fentry__ Steven Rostedt
  2016-10-24 19:17 ` Borislav Petkov
@ 2016-10-26 10:43 ` tip-bot for Steven Rostedt
  1 sibling, 0 replies; 3+ messages in thread
From: tip-bot for Steven Rostedt @ 2016-10-26 10:43 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: hpa, linux-kernel, mingo, viro, npiggin, tglx, rostedt, bp, nix.or.die

Commit-ID:  5de0a8c0c240338cb5b73363b0673c6aa804bb1c
Gitweb:     http://git.kernel.org/tip/5de0a8c0c240338cb5b73363b0673c6aa804bb1c
Author:     Steven Rostedt <rostedt@goodmis.org>
AuthorDate: Mon, 24 Oct 2016 15:01:48 -0400
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Wed, 26 Oct 2016 12:38:17 +0200

x86: Fix export for mcount and __fentry__

Commit 784d5699eddc5 ("x86: move exports to actual definitions") removed the
EXPORT_SYMBOL(__fentry__) and EXPORT_SYMBOL(mcount) from x8664_ksyms_64.c,
and added EXPORT_SYMBOL(function_hook) in mcount_64.S instead. The problem
is that function_hook isn't a function at all, but a macro that is defined
as either mcount or __fentry__ depending on the support from gcc.

Originally, I thought this was a macro issue, like what __stringify()
is used for. But the problem is a bit deeper. The Makefile.build has
some magic that does post processing of files to create the CRC
bindings. It does some searches for EXPORT_SYMBOL() and because it
finds a macro name and not the actual functions, this causes
function_hook not to be converted into mcount or __fentry__ and they
are missed.

Instead of adding more magic to Makefile.build, just add
EXPORT_SYMBOL() for mcount and __fentry__ where the ifdef is used.
Since this is assembly and not C, it doesn't require being set after
the function is defined.

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Tested-by: Borislav Petkov <bp@alien8.de>
Cc: Gabriel C <nix.or.die@gmail.com>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Al Viro <viro@ZenIV.linux.org.uk>
Link: http://lkml.kernel.org/r/20161024150148.4f9d90e4@gandalf.local.home
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

---
 arch/x86/kernel/mcount_64.S | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kernel/mcount_64.S b/arch/x86/kernel/mcount_64.S
index efe73aa..7b0d3da 100644
--- a/arch/x86/kernel/mcount_64.S
+++ b/arch/x86/kernel/mcount_64.S
@@ -18,8 +18,10 @@
 
 #ifdef CC_USING_FENTRY
 # define function_hook	__fentry__
+EXPORT_SYMBOL(__fentry__)
 #else
 # define function_hook	mcount
+EXPORT_SYMBOL(mcount)
 #endif
 
 /* All cases save the original rbp (8 bytes) */
@@ -295,7 +297,6 @@ trace:
 	jmp fgraph_trace
 END(function_hook)
 #endif /* CONFIG_DYNAMIC_FTRACE */
-EXPORT_SYMBOL(function_hook)
 #endif /* CONFIG_FUNCTION_TRACER */
 
 #ifdef CONFIG_FUNCTION_GRAPH_TRACER

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-10-26 10:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-24 19:01 [PATCH] x86: Fix export for mcount and __fentry__ Steven Rostedt
2016-10-24 19:17 ` Borislav Petkov
2016-10-26 10:43 ` [tip:x86/urgent] " tip-bot for Steven Rostedt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome