cregit-Linux how code gets into the kernel

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

PersonTokensPropCommitsCommitProp
Peter Zijlstra2546.30%228.57%
Ingo Molnar1731.48%228.57%
Jason Baron1018.52%228.57%
Steven Rostedt23.70%114.29%
Total54100.00%7100.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

PersonTokensPropCommitsCommitProp
Peter Zijlstra3468.00%240.00%
Jason Baron816.00%120.00%
Ingo Molnar714.00%120.00%
Steven Rostedt12.00%120.00%
Total50100.00%5100.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

PersonTokensPropCommitsCommitProp
Andrew Lutomirski9736.88%216.67%
Peter Zijlstra5922.43%216.67%
Jason Baron5721.67%216.67%
Ingo Molnar269.89%216.67%
Steven Rostedt186.84%216.67%
Anton Blanchard51.90%18.33%
Greg Kroah-Hartman10.38%18.33%
Total263100.00%12100.00%
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.
Created with cregit.