[PATCH 3.16 08/86] jump_label: Allow asm/jump_label.h to be included in assembly

From: Ben Hutchings
Date: Thu May 16 2019 - 12:05:24 EST


3.16.68-rc1 review patch. If anyone has any objections, please let me know.

------------------

From: Anton Blanchard <anton@xxxxxxxxx>

commit 55dd0df781e58ec23d218376ea4a676e7362a98c upstream.

Wrap asm/jump_label.h for all archs with #ifndef __ASSEMBLY__.
Since these are kernel only headers, we don't need #ifdef
__KERNEL__ so can simplify things a bit.

If an architecture wants to use jump labels in assembly, it
will still need to define a macro to create the __jump_table
entries (see ARCH_STATIC_BRANCH in the powerpc asm/jump_label.h
for an example).

Signed-off-by: Anton Blanchard <anton@xxxxxxxxx>
Acked-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>
Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
Cc: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
Cc: Paul E. McKenney <paulmck@xxxxxxxxxxxxxxxxxx>
Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
Cc: benh@xxxxxxxxxxxxxxxxxxx
Cc: catalin.marinas@xxxxxxx
Cc: davem@xxxxxxxxxxxxx
Cc: heiko.carstens@xxxxxxxxxx
Cc: jbaron@xxxxxxxxxx
Cc: linux@xxxxxxxxxxxxxxxx
Cc: linuxppc-dev@xxxxxxxxxxxxxxxx
Cc: liuj97@xxxxxxxxx
Cc: mgorman@xxxxxxx
Cc: mmarek@xxxxxxx
Cc: mpe@xxxxxxxxxxxxxx
Cc: paulus@xxxxxxxxx
Cc: ralf@xxxxxxxxxxxxxx
Cc: rostedt@xxxxxxxxxxx
Cc: schwidefsky@xxxxxxxxxx
Cc: will.deacon@xxxxxxx
Link: http://lkml.kernel.org/r/1428551492-21977-1-git-send-email-anton@xxxxxxxxx
Signed-off-by: Ingo Molnar <mingo@xxxxxxxxxx>
Signed-off-by: Ben Hutchings <ben@xxxxxxxxxxxxxxx>
---
arch/arm/include/asm/jump_label.h | 5 ++---
arch/arm64/include/asm/jump_label.h | 8 ++++----
arch/mips/include/asm/jump_label.h | 7 +++----
arch/s390/include/asm/jump_label.h | 3 +++
arch/sparc/include/asm/jump_label.h | 5 ++---
arch/x86/include/asm/jump_label.h | 5 ++---
6 files changed, 16 insertions(+), 17 deletions(-)

--- a/arch/arm/include/asm/jump_label.h
+++ b/arch/arm/include/asm/jump_label.h
@@ -1,7 +1,7 @@
#ifndef _ASM_ARM_JUMP_LABEL_H
#define _ASM_ARM_JUMP_LABEL_H

-#ifdef __KERNEL__
+#ifndef __ASSEMBLY__

#include <linux/types.h>

@@ -27,8 +27,6 @@ l_yes:
return true;
}

-#endif /* __KERNEL__ */
-
typedef u32 jump_label_t;

struct jump_entry {
@@ -37,4 +35,5 @@ struct jump_entry {
jump_label_t key;
};

+#endif /* __ASSEMBLY__ */
#endif
--- a/arch/arm64/include/asm/jump_label.h
+++ b/arch/arm64/include/asm/jump_label.h
@@ -18,11 +18,12 @@
*/
#ifndef __ASM_JUMP_LABEL_H
#define __ASM_JUMP_LABEL_H
+
+#ifndef __ASSEMBLY__
+
#include <linux/types.h>
#include <asm/insn.h>

-#ifdef __KERNEL__
-
#define JUMP_LABEL_NOP_SIZE AARCH64_INSN_SIZE

static __always_inline bool arch_static_branch(struct static_key *key)
@@ -39,8 +40,6 @@ l_yes:
return true;
}

-#endif /* __KERNEL__ */
-
typedef u64 jump_label_t;

struct jump_entry {
@@ -49,4 +48,5 @@ struct jump_entry {
jump_label_t key;
};

+#endif /* __ASSEMBLY__ */
#endif /* __ASM_JUMP_LABEL_H */
--- a/arch/mips/include/asm/jump_label.h
+++ b/arch/mips/include/asm/jump_label.h
@@ -8,9 +8,9 @@
#ifndef _ASM_MIPS_JUMP_LABEL_H
#define _ASM_MIPS_JUMP_LABEL_H

-#include <linux/types.h>
+#ifndef __ASSEMBLY__

-#ifdef __KERNEL__
+#include <linux/types.h>

#define JUMP_LABEL_NOP_SIZE 4

@@ -39,8 +39,6 @@ l_yes:
return true;
}

-#endif /* __KERNEL__ */
-
#ifdef CONFIG_64BIT
typedef u64 jump_label_t;
#else
@@ -53,4 +51,5 @@ struct jump_entry {
jump_label_t key;
};

+#endif /* __ASSEMBLY__ */
#endif /* _ASM_MIPS_JUMP_LABEL_H */
--- a/arch/s390/include/asm/jump_label.h
+++ b/arch/s390/include/asm/jump_label.h
@@ -1,6 +1,8 @@
#ifndef _ASM_S390_JUMP_LABEL_H
#define _ASM_S390_JUMP_LABEL_H

+#ifndef __ASSEMBLY__
+
#include <linux/types.h>

#define JUMP_LABEL_NOP_SIZE 6
@@ -39,4 +41,5 @@ struct jump_entry {
jump_label_t key;
};

+#endif /* __ASSEMBLY__ */
#endif
--- a/arch/sparc/include/asm/jump_label.h
+++ b/arch/sparc/include/asm/jump_label.h
@@ -1,7 +1,7 @@
#ifndef _ASM_SPARC_JUMP_LABEL_H
#define _ASM_SPARC_JUMP_LABEL_H

-#ifdef __KERNEL__
+#ifndef __ASSEMBLY__

#include <linux/types.h>

@@ -22,8 +22,6 @@ l_yes:
return true;
}

-#endif /* __KERNEL__ */
-
typedef u32 jump_label_t;

struct jump_entry {
@@ -32,4 +30,5 @@ struct jump_entry {
jump_label_t key;
};

+#endif /* __ASSEMBLY__ */
#endif
--- a/arch/x86/include/asm/jump_label.h
+++ b/arch/x86/include/asm/jump_label.h
@@ -1,7 +1,7 @@
#ifndef _ASM_X86_JUMP_LABEL_H
#define _ASM_X86_JUMP_LABEL_H

-#ifdef __KERNEL__
+#ifndef __ASSEMBLY__

#include <linux/stringify.h>
#include <linux/types.h>
@@ -30,8 +30,6 @@ l_yes:
return true;
}

-#endif /* __KERNEL__ */
-
#ifdef CONFIG_X86_64
typedef u64 jump_label_t;
#else
@@ -44,4 +42,5 @@ struct jump_entry {
jump_label_t key;
};

+#endif /* __ASSEMBLY__ */
#endif