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