Add EXPORT_MACRO_SYMBOL() for asm
Subsystems (2)
RFC PATCH 1/1 Add EXPORT_MACRO_SYMBOL() for asm
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 eithe mcount or __fentry__ depending on the support from gcc. But instead of adding more #ifdefs like x8684_ksyms_64.c had, I suggest having another export that can handle this similar to the way __string() works with converting macros to strings. By having:
EXPORT_MACRO_SYMBOL(function_hook)
Where we have:
#define EXPORT_MACRO_SYMBOL(x) EXPORT_SYMBOL(x)
It will convert the macro into what it is defined as before calling EXPORT_SYMBOL(), and this will just work properly again.
--- arch/x86/kernel/mcount_64.S | 2 +- include/asm-generic/export.h | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-)
arch/x86/kernel/mcount_64.S +1 -1
@@ -295,7 +295,7 @@ trace: jmp fgraph_trace END(function_hook) #endif /* CONFIG_DYNAMIC_FTRACE */ -EXPORT_SYMBOL(function_hook) +EXPORT_MACRO_SYMBOL(function_hook) #endif /* CONFIG_FUNCTION_TRACER */ #ifdef CONFIG_FUNCTION_GRAPH_TRACER
include/asm-generic/export.h +5 -0
@@ -90,5 +90,10 @@ __EXPORT_SYMBOL(name, KSYM(name),) #define EXPORT_DATA_SYMBOL_GPL(name) \ __EXPORT_SYMBOL(name, KSYM(name),_gpl) +/* + * If "name" is a macro of a function and not a function itself, + * it needs a second pass. + */ +#define EXPORT_MACRO_SYMBOL(x) EXPORT_SYMBOL(x)#endif
Signature · 1 line
1.9.3
Quoted 44 lines · On Fri, 21 Oct 2016 12:17:59 -0400 Steven Rostedt <[email protected]> wrote:
Commit
784d5699eddc5("x86: move exports to actual definitions") removed theEXPORT_SYMBOL(__fentry__)andEXPORT_SYMBOL(mcount)fromx8664_ksyms_64.c, and addedEXPORT_SYMBOL(function_hook)inmcount_64.Sinstead. The problem is thatfunction_hookisn't a function at all, but a macro that is defined as eithe mcount or__fentry__depending on the support from gcc. But instead of adding more #ifdefs likex8684_ksyms_64.chad, I suggest having another export that can handle this similar to the way__string()works with converting macros to strings. By having:
EXPORT_MACRO_SYMBOL(function_hook)Where we have:
#define
EXPORT_MACRO_SYMBOL(x)EXPORT_SYMBOL(x)It will convert the macro into what it is defined as before calling
EXPORT_SYMBOL(), and this will just work properly again.Fixes Commit 784d5699eddc5 ("x86: move exports to actual definitions")Signed-off-by Steven Rostedt <[email protected]>--- arch/x86/kernel/mcount_64.S | 2 +- include/asm-generic/export.h | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-)arch/x86/kernel/mcount_64.S +1
-1@@ -295,7 +295,7 @@ trace: jmp fgraph_trace END(function_hook) #endif /* CONFIG_DYNAMIC_FTRACE */ -EXPORT_SYMBOL(function_hook) +EXPORT_MACRO_SYMBOL(function_hook) #endif /* CONFIG_FUNCTION_TRACER */ #ifdef CONFIG_FUNCTION_GRAPH_TRACERinclude/asm-generic/export.h +0
-0
include/asm-generic/export.h line 97
Quoted 8 lines
include/asm-generic/export.h +5
-0@@ -90,5 +90,10 @@ __EXPORT_SYMBOL(name, KSYM(name),) #define EXPORT_DATA_SYMBOL_GPL(name) \ __EXPORT_SYMBOL(name, KSYM(name),_gpl) +/* + * If "name" is a macro of a function and not a function itself, + * it needs a second pass. + */ +#define EXPORT_MACRO_SYMBOL(x) EXPORT_SYMBOL(x)
Seems okay, but what about just calling it EXPORT_SYMBOL?
Thanks,
Nick
Quoted 8 lines · On Sat, 22 Oct 2016 10:44:41 +1100 Nicholas Piggin <[email protected]> wrote:
Quoted 8 lines
#ifdef
CONFIG_FUNCTION_GRAPH_TRACERinclude/asm-generic/export.h +0
-0@@ -90,5 +90,10 @@ __EXPORT_SYMBOL(name, KSYM(name),) #define EXPORT_DATA_SYMBOL_GPL(name) \
Quoted 8 lines
include/asm-generic/export.h line 97
Quoted 6 lines
include/asm-generic/export.h +5
-0__EXPORT_SYMBOL (name,KSYM (name),_gpl) +/* +* If "name" is a macro of a function and not a function itself, +* it needs a second pass. + */ +#define EXPORT_MACRO_SYMBOL (x) EXPORT_SYMBOL(x)Seems okay, but what about just calling it
EXPORT_SYMBOL?
Actually, this doesn't work. There's some magic going on it Makefile.build in the scripts directory that causes this to fail.
I have another patch I'll be sending on Monday that fixes this.
-- Steve
Quoted 21 lines · On Sat, 22 Oct 2016 15:08:52 -0400 Steven Rostedt <[email protected]> wrote:
Quoted 8 lines · On Sat, 22 Oct 2016 10:44:41 +1100 Nicholas Piggin <[email protected]> wrote:
Quoted 8 lines
#ifdef
CONFIG_FUNCTION_GRAPH_TRACERinclude/asm-generic/export.h +0
-0@@ -90,5 +90,10 @@ __EXPORT_SYMBOL(name, KSYM(name),) #define EXPORT_DATA_SYMBOL_GPL(name) \Quoted 8 lines
include/asm-generic/export.h line 97
Quoted 6 lines
include/asm-generic/export.h +5
-0__EXPORT_SYMBOL (name,KSYM (name),_gpl) +/* +* If "name" is a macro of a function and not a function itself, +* it needs a second pass. + */ +#define EXPORT_MACRO_SYMBOL (x) EXPORT_SYMBOL(x)Seems okay, but what about just calling it
EXPORT_SYMBOL?
Quoted 4 lines
Actually, this doesn't work. There's some magic going on it Makefile.build in the scripts directory that causes this to fail.
I have another patch I'll be sending on Monday that fixes this.
Yes it's grepping for EXPORT_SYMBOL_* I think. If you need to create a new name, EXPORT_SYMBOL prefix would be preferred. But yeah if you make the standard macro do macro expansion, it should just work, no?
Quoted 4 lines · On Mon, 24 Oct 2016 12:25:45 +1100 Nicholas Piggin <[email protected]> wrote:
Yes it's grepping for EXPORT_SYMBOL_* I think. If you need to create a new name,
EXPORT_SYMBOLprefix would be preferred. But yeah if you make the standard macro do macro expansion, it should just work, no?
Unfortunately, that's not enough. There's some magic in the Makefile that seems to use the names found in EXPORT_SYMBOL*, which fails when that name is just a macro to another name.
I'm just going to punt and include both names depending on the config.
-- Steve