summaryrefslogtreecommitdiff
path: root/arch/csky/include/asm
diff options
context:
space:
mode:
authorGuo Ren <guoren@linux.alibaba.com>2022-04-18 16:01:54 +0300
committerGuo Ren <guoren@linux.alibaba.com>2022-07-30 18:12:03 +0300
commit4e8bb4ba5a558159ffbfa7e60322a1c151c3903c (patch)
treec7dd06510ade6d45e5d67799ada379795d489437 /arch/csky/include/asm
parent01ab4649ef5a377074d2ad4bf2ba6d2270d2807b (diff)
downloadlinux-4e8bb4ba5a558159ffbfa7e60322a1c151c3903c.tar.xz
csky: Add jump-label implementation
Add jump-label implementation for static branch Signed-off-by: Guo Ren <guoren@linux.alibaba.com> Signed-off-by: Guo Ren <guoren@kernel.org>
Diffstat (limited to 'arch/csky/include/asm')
-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 */