2011-03-17 03:58:30 +08:00
|
|
|
#ifndef _ASM_S390_JUMP_LABEL_H
|
|
|
|
#define _ASM_S390_JUMP_LABEL_H
|
|
|
|
|
2015-04-09 11:51:30 +08:00
|
|
|
#ifndef __ASSEMBLY__
|
|
|
|
|
2011-03-17 03:58:30 +08:00
|
|
|
#include <linux/types.h>
|
|
|
|
|
|
|
|
#define JUMP_LABEL_NOP_SIZE 6
|
2015-01-29 21:10:22 +08:00
|
|
|
#define JUMP_LABEL_NOP_OFFSET 2
|
2011-03-17 03:58:30 +08:00
|
|
|
|
2015-01-29 21:10:22 +08:00
|
|
|
/*
|
|
|
|
* We use a brcl 0,2 instruction for jump labels at compile time so it
|
|
|
|
* can be easily distinguished from a hotpatch generated instruction.
|
|
|
|
*/
|
2015-07-24 21:09:55 +08:00
|
|
|
static __always_inline bool arch_static_branch(struct static_key *key, bool branch)
|
2011-03-17 03:58:30 +08:00
|
|
|
{
|
2015-01-29 21:10:22 +08:00
|
|
|
asm_volatile_goto("0: brcl 0,"__stringify(JUMP_LABEL_NOP_OFFSET)"\n"
|
2011-03-17 03:58:30 +08:00
|
|
|
".pushsection __jump_table, \"aw\"\n"
|
2015-02-12 20:08:27 +08:00
|
|
|
".balign 8\n"
|
|
|
|
".quad 0b, %l[label], %0\n"
|
2011-03-17 03:58:30 +08:00
|
|
|
".popsection\n"
|
2015-07-24 21:09:55 +08:00
|
|
|
: : "X" (&((char *)key)[branch]) : : label);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
label:
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static __always_inline bool arch_static_branch_jump(struct static_key *key, bool branch)
|
|
|
|
{
|
|
|
|
asm_volatile_goto("0: brcl 15, %l[label]\n"
|
|
|
|
".pushsection __jump_table, \"aw\"\n"
|
|
|
|
".balign 8\n"
|
|
|
|
".quad 0b, %l[label], %0\n"
|
|
|
|
".popsection\n"
|
|
|
|
: : "X" (&((char *)key)[branch]) : : label);
|
|
|
|
|
2011-03-17 03:58:30 +08:00
|
|
|
return false;
|
|
|
|
label:
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
typedef unsigned long jump_label_t;
|
|
|
|
|
|
|
|
struct jump_entry {
|
|
|
|
jump_label_t code;
|
|
|
|
jump_label_t target;
|
|
|
|
jump_label_t key;
|
|
|
|
};
|
|
|
|
|
2015-04-09 11:51:30 +08:00
|
|
|
#endif /* __ASSEMBLY__ */
|
2011-03-17 03:58:30 +08:00
|
|
|
#endif
|