Path: blob/master/arch/openrisc/include/asm/jump_label.h
29524 views
/* SPDX-License-Identifier: GPL-2.0-only */1/*2* Copyright (C) 2025 Chen Miao3*4* Based on arch/arm/include/asm/jump_label.h5*/6#ifndef __ASM_OPENRISC_JUMP_LABEL_H7#define __ASM_OPENRISC_JUMP_LABEL_H89#ifndef __ASSEMBLER__1011#include <linux/types.h>12#include <asm/insn-def.h>1314#define HAVE_JUMP_LABEL_BATCH1516#define JUMP_LABEL_NOP_SIZE OPENRISC_INSN_SIZE1718/**19* JUMP_TABLE_ENTRY - Create a jump table entry20* @key: Jump key identifier (typically a symbol address)21* @label: Target label address22*23* This macro creates a jump table entry in the dedicated kernel section (__jump_table).24* Each entry contains the following information:25* Offset from current instruction to jump instruction (1b - .)26* Offset from current instruction to target label (label - .)27* Offset from current instruction to key identifier (key - .)28*/29#define JUMP_TABLE_ENTRY(key, label) \30".pushsection __jump_table, \"aw\" \n\t" \31".align 4 \n\t" \32".long 1b - ., " label " - . \n\t" \33".long " key " - . \n\t" \34".popsection \n\t"3536#define ARCH_STATIC_BRANCH_ASM(key, label) \37".align 4 \n\t" \38"1: l.nop \n\t" \39" l.nop \n\t" \40JUMP_TABLE_ENTRY(key, label)4142static __always_inline bool arch_static_branch(struct static_key *const key,43const bool branch)44{45asm goto (ARCH_STATIC_BRANCH_ASM("%0", "%l[l_yes]")46::"i"(&((char *)key)[branch])::l_yes);4748return false;49l_yes:50return true;51}5253#define ARCH_STATIC_BRANCH_JUMP_ASM(key, label) \54".align 4 \n\t" \55"1: l.j " label " \n\t" \56" l.nop \n\t" \57JUMP_TABLE_ENTRY(key, label)5859static __always_inline bool60arch_static_branch_jump(struct static_key *const key, const bool branch)61{62asm goto (ARCH_STATIC_BRANCH_JUMP_ASM("%0", "%l[l_yes]")63::"i"(&((char *)key)[branch])::l_yes);6465return false;66l_yes:67return true;68}6970#endif /* __ASSEMBLER__ */71#endif /* __ASM_OPENRISC_JUMP_LABEL_H */727374