These changes are the raw update to linux-4.4.6-rt14. Kernel sources
[kvmfornfv.git] / kernel / arch / powerpc / include / asm / jump_label.h
1 #ifndef _ASM_POWERPC_JUMP_LABEL_H
2 #define _ASM_POWERPC_JUMP_LABEL_H
3
4 /*
5  * Copyright 2010 Michael Ellerman, IBM Corp.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version
10  * 2 of the License, or (at your option) any later version.
11  */
12
13 #ifndef __ASSEMBLY__
14 #include <linux/types.h>
15
16 #include <asm/feature-fixups.h>
17
18 #define JUMP_ENTRY_TYPE         stringify_in_c(FTR_ENTRY_LONG)
19 #define JUMP_LABEL_NOP_SIZE     4
20
21 static __always_inline bool arch_static_branch(struct static_key *key, bool branch)
22 {
23         asm_volatile_goto("1:\n\t"
24                  "nop\n\t"
25                  ".pushsection __jump_table,  \"aw\"\n\t"
26                  JUMP_ENTRY_TYPE "1b, %l[l_yes], %c0\n\t"
27                  ".popsection \n\t"
28                  : :  "i" (&((char *)key)[branch]) : : l_yes);
29
30         return false;
31 l_yes:
32         return true;
33 }
34
35 static __always_inline bool arch_static_branch_jump(struct static_key *key, bool branch)
36 {
37         asm_volatile_goto("1:\n\t"
38                  "b %l[l_yes]\n\t"
39                  ".pushsection __jump_table,  \"aw\"\n\t"
40                  JUMP_ENTRY_TYPE "1b, %l[l_yes], %c0\n\t"
41                  ".popsection \n\t"
42                  : :  "i" (&((char *)key)[branch]) : : l_yes);
43
44         return false;
45 l_yes:
46         return true;
47 }
48
49 #ifdef CONFIG_PPC64
50 typedef u64 jump_label_t;
51 #else
52 typedef u32 jump_label_t;
53 #endif
54
55 struct jump_entry {
56         jump_label_t code;
57         jump_label_t target;
58         jump_label_t key;
59 };
60
61 #else
62 #define ARCH_STATIC_BRANCH(LABEL, KEY)          \
63 1098:   nop;                                    \
64         .pushsection __jump_table, "aw";        \
65         FTR_ENTRY_LONG 1098b, LABEL, KEY;       \
66         .popsection
67 #endif
68
69 #endif /* _ASM_POWERPC_JUMP_LABEL_H */