Commit 796ef5a7 authored by Naman Jain's avatar Naman Jain Committed by Wei Liu
Browse files

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: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: default avatarNaman Jain <namjain@linux.microsoft.com>
Signed-off-by: default avatarWei Liu <wei.liu@kernel.org>
parent c91fe5f1
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -11,6 +11,10 @@
#define __has_builtin(x) (0)
#endif

/* Indirect macros required for expanded argument pasting, eg. __LINE__. */
#define ___PASTE(a, b) a##b
#define __PASTE(a, b) ___PASTE(a, b)

#ifndef __ASSEMBLY__

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

/* Indirect macros required for expanded argument pasting, eg. __LINE__. */
#define ___PASTE(a,b) a##b
#define __PASTE(a,b) ___PASTE(a,b)

#ifdef __KERNEL__

/* Attributes */
+4 −0
Original line number Diff line number Diff line
@@ -25,6 +25,8 @@
#define STATIC_CALL_SITE_INIT 2UL	/* init section */
#define STATIC_CALL_SITE_FLAGS 3UL

#ifndef __ASSEMBLY__

/*
 * The static call site table needs to be created by external tooling (objtool
 * or a compiler plugin).
@@ -100,4 +102,6 @@ struct static_call_key {

#endif /* CONFIG_HAVE_STATIC_CALL */

#endif /* __ASSEMBLY__ */

#endif /* _STATIC_CALL_TYPES_H */
+4 −0
Original line number Diff line number Diff line
@@ -25,6 +25,8 @@
#define STATIC_CALL_SITE_INIT 2UL	/* init section */
#define STATIC_CALL_SITE_FLAGS 3UL

#ifndef __ASSEMBLY__

/*
 * The static call site table needs to be created by external tooling (objtool
 * or a compiler plugin).
@@ -100,4 +102,6 @@ struct static_call_key {

#endif /* CONFIG_HAVE_STATIC_CALL */

#endif /* __ASSEMBLY__ */

#endif /* _STATIC_CALL_TYPES_H */