Release 4.14 arch/x86/include/asm/jump_label.h
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _ASM_X86_JUMP_LABEL_H
#define _ASM_X86_JUMP_LABEL_H
#ifndef HAVE_JUMP_LABEL
/*
* For better or for worse, if jump labels (the gcc extension) are missing,
* then the entire static branch patching infrastructure is compiled out.
* If that happens, the code in here will malfunction. Raise a compiler
* error instead.
*
* In theory, jump labels and the static branch patching infrastructure
* could be decoupled to fix this.
*/
#error asm/jump_label.h included on a non-jump-label kernel
#endif
#define JUMP_LABEL_NOP_SIZE 5
#ifdef CONFIG_X86_64
# define STATIC_KEY_INIT_NOP P6_NOP5_ATOMIC
#else
# define STATIC_KEY_INIT_NOP GENERIC_NOP5_ATOMIC
#endif
#include <asm/asm.h>
#include <asm/nops.h>
#ifndef __ASSEMBLY__
#include <linux/stringify.h>
#include <linux/types.h>
static __always_inline bool arch_static_branch(struct static_key *key, bool branch)
{
asm_volatile_goto("1:"
".byte " __stringify(STATIC_KEY_INIT_NOP) "\n\t"
".pushsection __jump_table, \"aw\" \n\t"
_ASM_ALIGN "\n\t"
_ASM_PTR "1b, %l[l_yes], %c0 + %c1 \n\t"
".popsection \n\t"
: : "i" (key), "i" (branch) : : l_yes);
return false;
l_yes:
return true;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Peter Zijlstra | 25 | 46.30% | 2 | 28.57% |
Ingo Molnar | 17 | 31.48% | 2 | 28.57% |
Jason Baron | 10 | 18.52% | 2 | 28.57% |
Steven Rostedt | 2 | 3.70% | 1 | 14.29% |
Total | 54 | 100.00% | 7 | 100.00% |
static __always_inline bool arch_static_branch_jump(struct static_key *key, bool branch)
{
asm_volatile_goto("1:"
".byte 0xe9\n\t .long %l[l_yes] - 2f\n\t"
"2:\n\t"
".pushsection __jump_table, \"aw\" \n\t"
_ASM_ALIGN "\n\t"
_ASM_PTR "1b, %l[l_yes], %c0 + %c1 \n\t"
".popsection \n\t"
: : "i" (key), "i" (branch) : : l_yes);
return false;
l_yes:
return true;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Peter Zijlstra | 34 | 68.00% | 2 | 40.00% |
Jason Baron | 8 | 16.00% | 1 | 20.00% |
Ingo Molnar | 7 | 14.00% | 1 | 20.00% |
Steven Rostedt | 1 | 2.00% | 1 | 20.00% |
Total | 50 | 100.00% | 5 | 100.00% |
#ifdef CONFIG_X86_64
typedef u64 jump_label_t;
#else
typedef u32 jump_label_t;
#endif
struct jump_entry {
jump_label_t code;
jump_label_t target;
jump_label_t key;
};
#else /* __ASSEMBLY__ */
.macro STATIC_JUMP_IF_TRUE target, key, def
.Lstatic_jump_\@:
.if \def
/* Equivalent to "jmp.d32 \target" */
.byte 0xe9
.long \target - .Lstatic_jump_after_\@
.Lstatic_jump_after_\@:
.else
.byte STATIC_KEY_INIT_NOP
.endif
.pushsection __jump_table, "aw"
_ASM_ALIGN
_ASM_PTR .Lstatic_jump_\@, \target, \key
.popsection
.endm
.macro STATIC_JUMP_IF_FALSE target, key, def
.Lstatic_jump_\@:
.if \def
.byte STATIC_KEY_INIT_NOP
.else
/* Equivalent to "jmp.d32 \target" */
.byte 0xe9
.long \target - .Lstatic_jump_after_\@
.Lstatic_jump_after_\@:
.endif
.pushsection __jump_table, "aw"
_ASM_ALIGN
_ASM_PTR .Lstatic_jump_\@, \target, \key + 1
.popsection
.endm
#endif /* __ASSEMBLY__ */
#endif
Overall Contributors
Person | Tokens | Prop | Commits | CommitProp |
Andrew Lutomirski | 97 | 36.88% | 2 | 16.67% |
Peter Zijlstra | 59 | 22.43% | 2 | 16.67% |
Jason Baron | 57 | 21.67% | 2 | 16.67% |
Ingo Molnar | 26 | 9.89% | 2 | 16.67% |
Steven Rostedt | 18 | 6.84% | 2 | 16.67% |
Anton Blanchard | 5 | 1.90% | 1 | 8.33% |
Greg Kroah-Hartman | 1 | 0.38% | 1 | 8.33% |
Total | 263 | 100.00% | 12 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.