Skip to content

Commit 796ef5a

Browse files
Naman Jainliuw
authored andcommitted
static_call: allow using STATIC_CALL_TRAMP_STR() from assembly
STATIC_CALL_TRAMP_STR() could not be used from .S files because static_call_types.h was not safe to include in assembly as it pulled in C types/constructs that are unavailable under __ASSEMBLY__. Make the header assembly-friendly by adding __ASSEMBLY__ checks and providing only the minimal definitions needed for assembly, so that it can be safely included by .S code. This enables emitting the static call trampoline symbol name via STATIC_CALL_TRAMP_STR() directly in assembly sources, to be used with 'call' instruction. Also, move a certain definitions out of __ASSEMBLY__ checks in compiler_types.h to meet the dependencies. No functional change for C compilation. Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Signed-off-by: Naman Jain <namjain@linux.microsoft.com> Signed-off-by: Wei Liu <wei.liu@kernel.org>
1 parent c91fe5f commit 796ef5a

3 files changed

Lines changed: 12 additions & 4 deletions

File tree

include/linux/compiler_types.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
#define __has_builtin(x) (0)
1212
#endif
1313

14+
/* Indirect macros required for expanded argument pasting, eg. __LINE__. */
15+
#define ___PASTE(a, b) a##b
16+
#define __PASTE(a, b) ___PASTE(a, b)
17+
1418
#ifndef __ASSEMBLY__
1519

1620
/*
@@ -79,10 +83,6 @@ static inline void __chk_io_ptr(const volatile void __iomem *ptr) { }
7983
# define __builtin_warning(x, y...) (1)
8084
#endif /* __CHECKER__ */
8185

82-
/* Indirect macros required for expanded argument pasting, eg. __LINE__. */
83-
#define ___PASTE(a,b) a##b
84-
#define __PASTE(a,b) ___PASTE(a,b)
85-
8686
#ifdef __KERNEL__
8787

8888
/* Attributes */

include/linux/static_call_types.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
#define STATIC_CALL_SITE_INIT 2UL /* init section */
2626
#define STATIC_CALL_SITE_FLAGS 3UL
2727

28+
#ifndef __ASSEMBLY__
29+
2830
/*
2931
* The static call site table needs to be created by external tooling (objtool
3032
* or a compiler plugin).
@@ -100,4 +102,6 @@ struct static_call_key {
100102

101103
#endif /* CONFIG_HAVE_STATIC_CALL */
102104

105+
#endif /* __ASSEMBLY__ */
106+
103107
#endif /* _STATIC_CALL_TYPES_H */

tools/include/linux/static_call_types.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
#define STATIC_CALL_SITE_INIT 2UL /* init section */
2626
#define STATIC_CALL_SITE_FLAGS 3UL
2727

28+
#ifndef __ASSEMBLY__
29+
2830
/*
2931
* The static call site table needs to be created by external tooling (objtool
3032
* or a compiler plugin).
@@ -100,4 +102,6 @@ struct static_call_key {
100102

101103
#endif /* CONFIG_HAVE_STATIC_CALL */
102104

105+
#endif /* __ASSEMBLY__ */
106+
103107
#endif /* _STATIC_CALL_TYPES_H */

0 commit comments

Comments
 (0)