Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
5373db88 JG |
2 | #ifndef _ASM_S390_JUMP_LABEL_H |
3 | #define _ASM_S390_JUMP_LABEL_H | |
4 | ||
55dd0df7 AB |
5 | #ifndef __ASSEMBLY__ |
6 | ||
5373db88 | 7 | #include <linux/types.h> |
ac314184 | 8 | #include <linux/stringify.h> |
5373db88 JG |
9 | |
10 | #define JUMP_LABEL_NOP_SIZE 6 | |
d5caa4db | 11 | #define JUMP_LABEL_NOP_OFFSET 2 |
5373db88 | 12 | |
d5caa4db HC |
13 | /* |
14 | * We use a brcl 0,2 instruction for jump labels at compile time so it | |
15 | * can be easily distinguished from a hotpatch generated instruction. | |
16 | */ | |
11276d53 | 17 | static __always_inline bool arch_static_branch(struct static_key *key, bool branch) |
5373db88 | 18 | { |
d5caa4db | 19 | asm_volatile_goto("0: brcl 0,"__stringify(JUMP_LABEL_NOP_OFFSET)"\n" |
5373db88 | 20 | ".pushsection __jump_table, \"aw\"\n" |
5a79859a HC |
21 | ".balign 8\n" |
22 | ".quad 0b, %l[label], %0\n" | |
5373db88 | 23 | ".popsection\n" |
11276d53 PZ |
24 | : : "X" (&((char *)key)[branch]) : : label); |
25 | ||
26 | return false; | |
27 | label: | |
28 | return true; | |
29 | } | |
30 | ||
31 | static __always_inline bool arch_static_branch_jump(struct static_key *key, bool branch) | |
32 | { | |
33 | asm_volatile_goto("0: brcl 15, %l[label]\n" | |
34 | ".pushsection __jump_table, \"aw\"\n" | |
35 | ".balign 8\n" | |
36 | ".quad 0b, %l[label], %0\n" | |
37 | ".popsection\n" | |
38 | : : "X" (&((char *)key)[branch]) : : label); | |
39 | ||
5373db88 JG |
40 | return false; |
41 | label: | |
42 | return true; | |
43 | } | |
44 | ||
45 | typedef unsigned long jump_label_t; | |
46 | ||
47 | struct jump_entry { | |
48 | jump_label_t code; | |
49 | jump_label_t target; | |
50 | jump_label_t key; | |
51 | }; | |
52 | ||
55dd0df7 | 53 | #endif /* __ASSEMBLY__ */ |
5373db88 | 54 | #endif |