Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at v6.18-rc2 60 lines 1.5 kB view raw
1/* SPDX-License-Identifier: GPL-2.0 */ 2#ifndef _ASM_X86_JUMP_LABEL_H 3#define _ASM_X86_JUMP_LABEL_H 4 5#define HAVE_JUMP_LABEL_BATCH 6 7#include <asm/asm.h> 8#include <asm/nops.h> 9 10#ifndef __ASSEMBLER__ 11 12#include <linux/stringify.h> 13#include <linux/types.h> 14 15#define JUMP_TABLE_ENTRY(key, label) \ 16 ".pushsection __jump_table, \"aw\" \n\t" \ 17 _ASM_ALIGN "\n\t" \ 18 ".long 1b - . \n\t" \ 19 ".long " label " - . \n\t" \ 20 _ASM_PTR " " key " - . \n\t" \ 21 ".popsection \n\t" 22 23/* This macro is also expanded on the Rust side. */ 24#ifdef CONFIG_HAVE_JUMP_LABEL_HACK 25#define ARCH_STATIC_BRANCH_ASM(key, label) \ 26 "1: jmp " label " # objtool NOPs this \n\t" \ 27 JUMP_TABLE_ENTRY(key " + 2", label) 28#else /* !CONFIG_HAVE_JUMP_LABEL_HACK */ 29#define ARCH_STATIC_BRANCH_ASM(key, label) \ 30 "1: .byte " __stringify(BYTES_NOP5) "\n\t" \ 31 JUMP_TABLE_ENTRY(key, label) 32#endif /* CONFIG_HAVE_JUMP_LABEL_HACK */ 33 34static __always_inline bool arch_static_branch(struct static_key * const key, const bool branch) 35{ 36 asm goto(ARCH_STATIC_BRANCH_ASM("%c0 + %c1", "%l[l_yes]") 37 : : "i" (key), "i" (branch) : : l_yes); 38 39 return false; 40l_yes: 41 return true; 42} 43 44static __always_inline bool arch_static_branch_jump(struct static_key * const key, const bool branch) 45{ 46 asm goto("1:" 47 "jmp %l[l_yes]\n\t" 48 JUMP_TABLE_ENTRY("%c0 + %c1", "%l[l_yes]") 49 : : "i" (key), "i" (branch) : : l_yes); 50 51 return false; 52l_yes: 53 return true; 54} 55 56extern int arch_jump_entry_size(struct jump_entry *entry); 57 58#endif /* __ASSEMBLER__ */ 59 60#endif