Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Jan Glauber | 5373db8 | 2011-03-16 15:58:30 -0400 | [diff] [blame] | 2 | #ifndef _ASM_S390_JUMP_LABEL_H |
| 3 | #define _ASM_S390_JUMP_LABEL_H |
| 4 | |
Anton Blanchard | 55dd0df | 2015-04-09 13:51:30 +1000 | [diff] [blame] | 5 | #ifndef __ASSEMBLY__ |
| 6 | |
Jan Glauber | 5373db8 | 2011-03-16 15:58:30 -0400 | [diff] [blame] | 7 | #include <linux/types.h> |
Jason Baron | ac31418 | 2016-05-20 17:16:35 -0400 | [diff] [blame] | 8 | #include <linux/stringify.h> |
Jan Glauber | 5373db8 | 2011-03-16 15:58:30 -0400 | [diff] [blame] | 9 | |
| 10 | #define JUMP_LABEL_NOP_SIZE 6 |
Heiko Carstens | d5caa4d | 2015-01-29 14:10:22 +0100 | [diff] [blame] | 11 | #define JUMP_LABEL_NOP_OFFSET 2 |
Jan Glauber | 5373db8 | 2011-03-16 15:58:30 -0400 | [diff] [blame] | 12 | |
Ilya Leoshkevich | 1464485 | 2019-02-06 12:35:58 +0100 | [diff] [blame] | 13 | #if __GNUC__ < 9 |
| 14 | #define JUMP_LABEL_STATIC_KEY_CONSTRAINT "X" |
| 15 | #else |
| 16 | #define JUMP_LABEL_STATIC_KEY_CONSTRAINT "jdd" |
| 17 | #endif |
| 18 | |
Heiko Carstens | d5caa4d | 2015-01-29 14:10:22 +0100 | [diff] [blame] | 19 | /* |
| 20 | * We use a brcl 0,2 instruction for jump labels at compile time so it |
| 21 | * can be easily distinguished from a hotpatch generated instruction. |
| 22 | */ |
Heiko Carstens | 7f032fe | 2019-10-04 12:29:18 +0200 | [diff] [blame] | 23 | 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] | 24 | { |
Heiko Carstens | 13ddb52 | 2018-09-18 23:51:44 -0700 | [diff] [blame] | 25 | asm_volatile_goto("0: brcl 0,"__stringify(JUMP_LABEL_NOP_OFFSET)"\n" |
| 26 | ".pushsection __jump_table,\"aw\"\n" |
| 27 | ".balign 8\n" |
| 28 | ".long 0b-.,%l[label]-.\n" |
Ilya Leoshkevich | 1464485 | 2019-02-06 12:35:58 +0100 | [diff] [blame] | 29 | ".quad %0+%1-.\n" |
Heiko Carstens | 13ddb52 | 2018-09-18 23:51:44 -0700 | [diff] [blame] | 30 | ".popsection\n" |
Ilya Leoshkevich | 1464485 | 2019-02-06 12:35:58 +0100 | [diff] [blame] | 31 | : : JUMP_LABEL_STATIC_KEY_CONSTRAINT (key), "i" (branch) : : label); |
Peter Zijlstra | 11276d5 | 2015-07-24 15:09:55 +0200 | [diff] [blame] | 32 | return false; |
| 33 | label: |
| 34 | return true; |
| 35 | } |
| 36 | |
Heiko Carstens | 7f032fe | 2019-10-04 12:29:18 +0200 | [diff] [blame] | 37 | static __always_inline bool arch_static_branch_jump(struct static_key *key, bool branch) |
Peter Zijlstra | 11276d5 | 2015-07-24 15:09:55 +0200 | [diff] [blame] | 38 | { |
Heiko Carstens | 13ddb52 | 2018-09-18 23:51:44 -0700 | [diff] [blame] | 39 | asm_volatile_goto("0: brcl 15,%l[label]\n" |
| 40 | ".pushsection __jump_table,\"aw\"\n" |
| 41 | ".balign 8\n" |
| 42 | ".long 0b-.,%l[label]-.\n" |
Ilya Leoshkevich | 1464485 | 2019-02-06 12:35:58 +0100 | [diff] [blame] | 43 | ".quad %0+%1-.\n" |
Heiko Carstens | 13ddb52 | 2018-09-18 23:51:44 -0700 | [diff] [blame] | 44 | ".popsection\n" |
Ilya Leoshkevich | 1464485 | 2019-02-06 12:35:58 +0100 | [diff] [blame] | 45 | : : JUMP_LABEL_STATIC_KEY_CONSTRAINT (key), "i" (branch) : : label); |
Jan Glauber | 5373db8 | 2011-03-16 15:58:30 -0400 | [diff] [blame] | 46 | return false; |
| 47 | label: |
| 48 | return true; |
| 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 |