blob: a32b18ce6eadae461d712a6c49b172387cdbbfd1 [file] [log] [blame]
Jason Barond9f5ab72010-09-17 11:09:22 -04001#ifndef _ASM_X86_JUMP_LABEL_H
2#define _ASM_X86_JUMP_LABEL_H
3
4#ifdef __KERNEL__
5
6#include <linux/types.h>
7#include <asm/nops.h>
Jason Barond430d3d2011-03-16 17:29:47 -04008#include <asm/asm.h>
Jason Barond9f5ab72010-09-17 11:09:22 -04009
10#define JUMP_LABEL_NOP_SIZE 5
11
Jason Barond430d3d2011-03-16 17:29:47 -040012#define JUMP_LABEL_INITIAL_NOP ".byte 0xe9 \n\t .long 0\n\t"
Jason Barond9f5ab72010-09-17 11:09:22 -040013
Jason Barond430d3d2011-03-16 17:29:47 -040014static __always_inline bool arch_static_branch(struct jump_label_key *key)
15{
16 asm goto("1:"
17 JUMP_LABEL_INITIAL_NOP
18 ".pushsection __jump_table, \"aw\" \n\t"
Jason Baronef647892011-03-16 15:58:27 -040019 _ASM_ALIGN "\n\t"
Jason Barond430d3d2011-03-16 17:29:47 -040020 _ASM_PTR "1b, %l[l_yes], %c0 \n\t"
21 ".popsection \n\t"
22 : : "i" (key) : : l_yes);
23 return false;
24l_yes:
25 return true;
26}
Jason Barond9f5ab72010-09-17 11:09:22 -040027
28#endif /* __KERNEL__ */
29
30#ifdef CONFIG_X86_64
Jason Barond9f5ab72010-09-17 11:09:22 -040031typedef u64 jump_label_t;
Jason Barond9f5ab72010-09-17 11:09:22 -040032#else
Jason Barond9f5ab72010-09-17 11:09:22 -040033typedef u32 jump_label_t;
Steven Rostedt95fccd42010-09-22 17:37:43 -040034#endif
Jason Barond9f5ab72010-09-17 11:09:22 -040035
36struct jump_entry {
37 jump_label_t code;
38 jump_label_t target;
39 jump_label_t key;
40};
41
42#endif