Jan Glauber | 5373db8 | 2011-03-16 15:58:30 -0400 | [diff] [blame] | 1 | #ifndef _ASM_S390_JUMP_LABEL_H |
| 2 | #define _ASM_S390_JUMP_LABEL_H |
| 3 | |
Anton Blanchard | 55dd0df | 2015-04-09 13:51:30 +1000 | [diff] [blame] | 4 | #ifndef __ASSEMBLY__ |
| 5 | |
Jan Glauber | 5373db8 | 2011-03-16 15:58:30 -0400 | [diff] [blame] | 6 | #include <linux/types.h> |
| 7 | |
| 8 | #define JUMP_LABEL_NOP_SIZE 6 |
Heiko Carstens | d5caa4d | 2015-01-29 14:10:22 +0100 | [diff] [blame] | 9 | #define JUMP_LABEL_NOP_OFFSET 2 |
Jan Glauber | 5373db8 | 2011-03-16 15:58:30 -0400 | [diff] [blame] | 10 | |
Heiko Carstens | d5caa4d | 2015-01-29 14:10:22 +0100 | [diff] [blame] | 11 | /* |
| 12 | * We use a brcl 0,2 instruction for jump labels at compile time so it |
| 13 | * can be easily distinguished from a hotpatch generated instruction. |
| 14 | */ |
Peter Zijlstra | 11276d5 | 2015-07-24 15:09:55 +0200 | [diff] [blame^] | 15 | static __always_inline bool arch_static_branch(struct static_key *key, bool branch) |
Jan Glauber | 5373db8 | 2011-03-16 15:58:30 -0400 | [diff] [blame] | 16 | { |
Heiko Carstens | d5caa4d | 2015-01-29 14:10:22 +0100 | [diff] [blame] | 17 | asm_volatile_goto("0: brcl 0,"__stringify(JUMP_LABEL_NOP_OFFSET)"\n" |
Jan Glauber | 5373db8 | 2011-03-16 15:58:30 -0400 | [diff] [blame] | 18 | ".pushsection __jump_table, \"aw\"\n" |
Heiko Carstens | 5a79859 | 2015-02-12 13:08:27 +0100 | [diff] [blame] | 19 | ".balign 8\n" |
| 20 | ".quad 0b, %l[label], %0\n" |
Jan Glauber | 5373db8 | 2011-03-16 15:58:30 -0400 | [diff] [blame] | 21 | ".popsection\n" |
Peter Zijlstra | 11276d5 | 2015-07-24 15:09:55 +0200 | [diff] [blame^] | 22 | : : "X" (&((char *)key)[branch]) : : label); |
| 23 | |
| 24 | return false; |
| 25 | label: |
| 26 | return true; |
| 27 | } |
| 28 | |
| 29 | static __always_inline bool arch_static_branch_jump(struct static_key *key, bool branch) |
| 30 | { |
| 31 | asm_volatile_goto("0: brcl 15, %l[label]\n" |
| 32 | ".pushsection __jump_table, \"aw\"\n" |
| 33 | ".balign 8\n" |
| 34 | ".quad 0b, %l[label], %0\n" |
| 35 | ".popsection\n" |
| 36 | : : "X" (&((char *)key)[branch]) : : label); |
| 37 | |
Jan Glauber | 5373db8 | 2011-03-16 15:58:30 -0400 | [diff] [blame] | 38 | return false; |
| 39 | label: |
| 40 | return true; |
| 41 | } |
| 42 | |
| 43 | typedef unsigned long jump_label_t; |
| 44 | |
| 45 | struct jump_entry { |
| 46 | jump_label_t code; |
| 47 | jump_label_t target; |
| 48 | jump_label_t key; |
| 49 | }; |
| 50 | |
Anton Blanchard | 55dd0df | 2015-04-09 13:51:30 +1000 | [diff] [blame] | 51 | #endif /* __ASSEMBLY__ */ |
Jan Glauber | 5373db8 | 2011-03-16 15:58:30 -0400 | [diff] [blame] | 52 | #endif |