blob: 69972b7957ee40cd7fe3e61cbc7ed28884b4ea15 [file] [log] [blame]
Jan Glauber5373db82011-03-16 15:58:30 -04001#ifndef _ASM_S390_JUMP_LABEL_H
2#define _ASM_S390_JUMP_LABEL_H
3
Anton Blanchard55dd0df2015-04-09 13:51:30 +10004#ifndef __ASSEMBLY__
5
Jan Glauber5373db82011-03-16 15:58:30 -04006#include <linux/types.h>
7
8#define JUMP_LABEL_NOP_SIZE 6
Heiko Carstensd5caa4d2015-01-29 14:10:22 +01009#define JUMP_LABEL_NOP_OFFSET 2
Jan Glauber5373db82011-03-16 15:58:30 -040010
Heiko Carstensd5caa4d2015-01-29 14:10:22 +010011/*
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 */
Ingo Molnarc5905af2012-02-24 08:31:31 +010015static __always_inline bool arch_static_branch(struct static_key *key)
Jan Glauber5373db82011-03-16 15:58:30 -040016{
Heiko Carstensd5caa4d2015-01-29 14:10:22 +010017 asm_volatile_goto("0: brcl 0,"__stringify(JUMP_LABEL_NOP_OFFSET)"\n"
Jan Glauber5373db82011-03-16 15:58:30 -040018 ".pushsection __jump_table, \"aw\"\n"
Heiko Carstens5a798592015-02-12 13:08:27 +010019 ".balign 8\n"
20 ".quad 0b, %l[label], %0\n"
Jan Glauber5373db82011-03-16 15:58:30 -040021 ".popsection\n"
22 : : "X" (key) : : label);
23 return false;
24label:
25 return true;
26}
27
28typedef unsigned long jump_label_t;
29
30struct jump_entry {
31 jump_label_t code;
32 jump_label_t target;
33 jump_label_t key;
34};
35
Anton Blanchard55dd0df2015-04-09 13:51:30 +100036#endif /* __ASSEMBLY__ */
Jan Glauber5373db82011-03-16 15:58:30 -040037#endif