Skip to content

Commit

Permalink
jump_label: Allow jump labels to be used in assembly
Browse files Browse the repository at this point in the history
To use jump labels in assembly we need the HAVE_JUMP_LABEL
define, so we select a fallback version if the toolchain does
not support them.

Modify linux/jump_label.h so it can be included by assembly
files. We also need to add -DCC_HAVE_ASM_GOTO to KBUILD_AFLAGS.

Signed-off-by: Anton Blanchard <[email protected]>
Acked-by: Peter Zijlstra (Intel) <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: Paul E. McKenney <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
  • Loading branch information
antonblanchard authored and Ingo Molnar committed Apr 9, 2015
1 parent 55dd0df commit c0ccf6f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,7 @@ KBUILD_ARFLAGS := $(call ar-option,D)
# check for 'asm goto'
ifeq ($(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-goto.sh $(CC)), y)
KBUILD_CFLAGS += -DCC_HAVE_ASM_GOTO
KBUILD_AFLAGS += -DCC_HAVE_ASM_GOTO
endif

include $(srctree)/scripts/Makefile.kasan
Expand Down
21 changes: 17 additions & 4 deletions include/linux/jump_label.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@
* same as using STATIC_KEY_INIT_FALSE.
*/

#if defined(CC_HAVE_ASM_GOTO) && defined(CONFIG_JUMP_LABEL)
# define HAVE_JUMP_LABEL
#endif

#ifndef __ASSEMBLY__

#include <linux/types.h>
#include <linux/compiler.h>
#include <linux/bug.h>
Expand All @@ -55,7 +61,7 @@ extern bool static_key_initialized;
"%s used before call to jump_label_init", \
__func__)

#if defined(CC_HAVE_ASM_GOTO) && defined(CONFIG_JUMP_LABEL)
#ifdef HAVE_JUMP_LABEL

struct static_key {
atomic_t enabled;
Expand All @@ -66,13 +72,18 @@ struct static_key {
#endif
};

# include <asm/jump_label.h>
# define HAVE_JUMP_LABEL
#else
struct static_key {
atomic_t enabled;
};
#endif /* CC_HAVE_ASM_GOTO && CONFIG_JUMP_LABEL */
#endif /* HAVE_JUMP_LABEL */
#endif /* __ASSEMBLY__ */

#ifdef HAVE_JUMP_LABEL
#include <asm/jump_label.h>
#endif

#ifndef __ASSEMBLY__

enum jump_label_type {
JUMP_LABEL_DISABLE = 0,
Expand Down Expand Up @@ -203,3 +214,5 @@ static inline bool static_key_enabled(struct static_key *key)
}

#endif /* _LINUX_JUMP_LABEL_H */

#endif /* __ASSEMBLY__ */

0 comments on commit c0ccf6f

Please sign in to comment.