/* SPDX-License-Identifier: GPL-2.0 */1#ifndef _ASM_ARC_JUMP_LABEL_H2#define _ASM_ARC_JUMP_LABEL_H34#ifndef __ASSEMBLER__56#include <linux/stringify.h>7#include <linux/types.h>89#define JUMP_LABEL_NOP_SIZE 41011/*12* NOTE about '.balign 4':13*14* To make atomic update of patched instruction available we need to guarantee15* that this instruction doesn't cross L1 cache line boundary.16*17* As of today we simply align instruction which can be patched by 4 byte using18* ".balign 4" directive. In that case patched instruction is aligned with one19* 16-bit NOP_S if this is required.20* However 'align by 4' directive is much stricter than it actually required.21* It's enough that our 32-bit instruction don't cross L1 cache line boundary /22* L1 I$ fetch block boundary which can be achieved by using23* ".bundle_align_mode" assembler directive. That will save us from adding24* useless NOP_S padding in most of the cases.25*26* TODO: switch to ".bundle_align_mode" directive using whin it will be27* supported by ARC toolchain.28*/2930static __always_inline bool arch_static_branch(struct static_key *key,31bool branch)32{33asm goto(".balign "__stringify(JUMP_LABEL_NOP_SIZE)" \n"34"1: \n"35"nop \n"36".pushsection __jump_table, \"aw\" \n"37".word 1b, %l[l_yes], %c0 \n"38".popsection \n"39: : "i" (&((char *)key)[branch]) : : l_yes);4041return false;42l_yes:43return true;44}4546static __always_inline bool arch_static_branch_jump(struct static_key *key,47bool branch)48{49asm goto(".balign "__stringify(JUMP_LABEL_NOP_SIZE)" \n"50"1: \n"51"b %l[l_yes] \n"52".pushsection __jump_table, \"aw\" \n"53".word 1b, %l[l_yes], %c0 \n"54".popsection \n"55: : "i" (&((char *)key)[branch]) : : l_yes);5657return false;58l_yes:59return true;60}6162typedef u32 jump_label_t;6364struct jump_entry {65jump_label_t code;66jump_label_t target;67jump_label_t key;68};6970#endif /* __ASSEMBLER__ */71#endif727374