aboutsummaryrefslogtreecommitdiff
path: root/arch/csky/include/asm/jump_label.h
diff options
context:
space:
mode:
authorGravatar Linus Torvalds <torvalds@linux-foundation.org> 2022-08-04 15:27:20 -0700
committerGravatar Linus Torvalds <torvalds@linux-foundation.org> 2022-08-04 15:27:20 -0700
commit7df9075e232e09d99cf23b657b6cb04c9506e618 (patch)
tree2f1853fc2310fee78a91067315b78fdd733578d4 /arch/csky/include/asm/jump_label.h
parentMerge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/egt... (diff)
parentcsky: abiv1: Fixup compile error (diff)
downloadlinux-7df9075e232e09d99cf23b657b6cb04c9506e618.tar.gz
linux-7df9075e232e09d99cf23b657b6cb04c9506e618.tar.bz2
linux-7df9075e232e09d99cf23b657b6cb04c9506e618.zip
Merge tag 'csky-for-linus-6.0-rc1' of https://github.com/c-sky/csky-linux
Pull csky updates from Guo Ren: - Add jump-label implementation - Add qspinlock support - Enable ARCH_INLINE_READ*/WRITE*/SPIN* - Some fixups and a coding convention * tag 'csky-for-linus-6.0-rc1' of https://github.com/c-sky/csky-linux: csky: abiv1: Fixup compile error csky: cmpxchg: Coding convention for BUILD_BUG() csky: Enable ARCH_INLINE_READ*/WRITE*/SPIN* csky: Add qspinlock support csky: Add jump-label implementation csky: Move HEAD_TEXT_SECTION out of __init_begin-end csky: Correct position of _stext csky: Use the bitmap API to allocate bitmaps csky/kprobe: reclaim insn_slot on kprobe unregistration
Diffstat (limited to 'arch/csky/include/asm/jump_label.h')
-rw-r--r--arch/csky/include/asm/jump_label.h47
1 files changed, 47 insertions, 0 deletions
diff --git a/arch/csky/include/asm/jump_label.h b/arch/csky/include/asm/jump_label.h
new file mode 100644
index 000000000000..d488ba6084bc
--- /dev/null
+++ b/arch/csky/include/asm/jump_label.h
@@ -0,0 +1,47 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#ifndef __ASM_CSKY_JUMP_LABEL_H
+#define __ASM_CSKY_JUMP_LABEL_H
+
+#ifndef __ASSEMBLY__
+
+#include <linux/types.h>
+
+#define JUMP_LABEL_NOP_SIZE 4
+
+static __always_inline bool arch_static_branch(struct static_key *key,
+ bool branch)
+{
+ asm_volatile_goto(
+ "1: nop32 \n"
+ " .pushsection __jump_table, \"aw\" \n"
+ " .align 2 \n"
+ " .long 1b - ., %l[label] - . \n"
+ " .long %0 - . \n"
+ " .popsection \n"
+ : : "i"(&((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(
+ "1: bsr32 %l[label] \n"
+ " .pushsection __jump_table, \"aw\" \n"
+ " .align 2 \n"
+ " .long 1b - ., %l[label] - . \n"
+ " .long %0 - . \n"
+ " .popsection \n"
+ : : "i"(&((char *)key)[branch]) : : label);
+
+ return false;
+label:
+ return true;
+}
+
+#endif /* __ASSEMBLY__ */
+#endif /* __ASM_CSKY_JUMP_LABEL_H */