Commit | Line | Data |
---|---|---|
ac5f89c7 ME |
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 | ||
cc1adb5f | 13 | #ifndef __ASSEMBLY__ |
ac5f89c7 ME |
14 | #include <linux/types.h> |
15 | ||
16 | #include <asm/feature-fixups.h> | |
5411fd7f | 17 | #include <asm/asm-compat.h> |
ac5f89c7 ME |
18 | |
19 | #define JUMP_ENTRY_TYPE stringify_in_c(FTR_ENTRY_LONG) | |
20 | #define JUMP_LABEL_NOP_SIZE 4 | |
21 | ||
11276d53 | 22 | static __always_inline bool arch_static_branch(struct static_key *key, bool branch) |
ac5f89c7 | 23 | { |
3f0116c3 | 24 | asm_volatile_goto("1:\n\t" |
e2985fd9 | 25 | "nop # arch_static_branch\n\t" |
ac5f89c7 | 26 | ".pushsection __jump_table, \"aw\"\n\t" |
ac5f89c7 ME |
27 | JUMP_ENTRY_TYPE "1b, %l[l_yes], %c0\n\t" |
28 | ".popsection \n\t" | |
11276d53 PZ |
29 | : : "i" (&((char *)key)[branch]) : : l_yes); |
30 | ||
31 | return false; | |
32 | l_yes: | |
33 | return true; | |
34 | } | |
35 | ||
36 | static __always_inline bool arch_static_branch_jump(struct static_key *key, bool branch) | |
37 | { | |
38 | asm_volatile_goto("1:\n\t" | |
e2985fd9 | 39 | "b %l[l_yes] # arch_static_branch_jump\n\t" |
11276d53 PZ |
40 | ".pushsection __jump_table, \"aw\"\n\t" |
41 | JUMP_ENTRY_TYPE "1b, %l[l_yes], %c0\n\t" | |
42 | ".popsection \n\t" | |
43 | : : "i" (&((char *)key)[branch]) : : l_yes); | |
44 | ||
ac5f89c7 ME |
45 | return false; |
46 | l_yes: | |
47 | return true; | |
48 | } | |
49 | ||
50 | #ifdef CONFIG_PPC64 | |
51 | typedef u64 jump_label_t; | |
52 | #else | |
53 | typedef u32 jump_label_t; | |
54 | #endif | |
55 | ||
56 | struct jump_entry { | |
57 | jump_label_t code; | |
58 | jump_label_t target; | |
59 | jump_label_t key; | |
ac5f89c7 ME |
60 | }; |
61 | ||
cc1adb5f AB |
62 | #else |
63 | #define ARCH_STATIC_BRANCH(LABEL, KEY) \ | |
64 | 1098: nop; \ | |
65 | .pushsection __jump_table, "aw"; \ | |
66 | FTR_ENTRY_LONG 1098b, LABEL, KEY; \ | |
67 | .popsection | |
68 | #endif | |
69 | ||
ac5f89c7 | 70 | #endif /* _ASM_POWERPC_JUMP_LABEL_H */ |