File tree Expand file tree Collapse file tree 5 files changed +77
-1
lines changed
Documentation/features/core/jump-labels Expand file tree Collapse file tree 5 files changed +77
-1
lines changed Original file line number Diff line number Diff line change 1313 | csky: | ok |
1414 | hexagon: | TODO |
1515 | ia64: | TODO |
16- | loongarch: | TODO |
16+ | loongarch: | ok |
1717 | m68k: | TODO |
1818 | microblaze: | TODO |
1919 | mips: | ok |
Original file line number Diff line number Diff line change @@ -87,6 +87,8 @@ config LOONGARCH
8787 select GPIOLIB
8888 select HAS_IOPORT
8989 select HAVE_ARCH_AUDITSYSCALL
90+ select HAVE_ARCH_JUMP_LABEL
91+ select HAVE_ARCH_JUMP_LABEL_RELATIVE
9092 select HAVE_ARCH_MMAP_RND_BITS if MMU
9193 select HAVE_ARCH_SECCOMP_FILTER
9294 select HAVE_ARCH_TRACEHOOK
Original file line number Diff line number Diff line change 1+ /* SPDX-License-Identifier: GPL-2.0-only */
2+ /*
3+ * Copyright (C) 2023 Loongson Technology Corporation Limited
4+ *
5+ * Based on arch/arm64/include/asm/jump_label.h
6+ */
7+ #ifndef __ASM_JUMP_LABEL_H
8+ #define __ASM_JUMP_LABEL_H
9+
10+ #ifndef __ASSEMBLY__
11+
12+ #include <linux/types.h>
13+
14+ #define JUMP_LABEL_NOP_SIZE 4
15+
16+ #define JUMP_TABLE_ENTRY \
17+ ".pushsection __jump_table, \"aw\" \n\t" \
18+ ".align 3 \n\t" \
19+ ".long 1b - ., %l[l_yes] - . \n\t" \
20+ ".quad %0 - . \n\t" \
21+ ".popsection \n\t"
22+
23+ static __always_inline bool arch_static_branch (struct static_key * const key , const bool branch )
24+ {
25+ asm_volatile_goto (
26+ "1: nop \n\t"
27+ JUMP_TABLE_ENTRY
28+ : : "i" (& ((char * )key )[branch ]) : : l_yes );
29+
30+ return false;
31+
32+ l_yes :
33+ return true;
34+ }
35+
36+ static __always_inline bool arch_static_branch_jump (struct static_key * const key , const bool branch )
37+ {
38+ asm_volatile_goto (
39+ "1: b %l[l_yes] \n\t"
40+ JUMP_TABLE_ENTRY
41+ : : "i" (& ((char * )key )[branch ]) : : l_yes );
42+
43+ return false;
44+
45+ l_yes :
46+ return true;
47+ }
48+
49+ #endif /* __ASSEMBLY__ */
50+ #endif /* __ASM_JUMP_LABEL_H */
Original file line number Diff line number Diff line change @@ -54,4 +54,6 @@ obj-$(CONFIG_HAVE_HW_BREAKPOINT) += hw_breakpoint.o
5454
5555obj-$(CONFIG_KPROBES) += kprobes.o kprobes_trampoline.o
5656
57+ obj-$(CONFIG_JUMP_LABEL) += jump_label.o
58+
5759CPPFLAGS_vmlinux.lds := $(KBUILD_CFLAGS )
Original file line number Diff line number Diff line change 1+ // SPDX-License-Identifier: GPL-2.0-only
2+ /*
3+ * Copyright (C) 2023 Loongson Technology Corporation Limited
4+ *
5+ * Based on arch/arm64/kernel/jump_label.c
6+ */
7+ #include <linux/kernel.h>
8+ #include <linux/jump_label.h>
9+ #include <asm/inst.h>
10+
11+ void arch_jump_label_transform (struct jump_entry * entry , enum jump_label_type type )
12+ {
13+ u32 insn ;
14+ void * addr = (void * )jump_entry_code (entry );
15+
16+ if (type == JUMP_LABEL_JMP )
17+ insn = larch_insn_gen_b (jump_entry_code (entry ), jump_entry_target (entry ));
18+ else
19+ insn = larch_insn_gen_nop ();
20+
21+ larch_insn_patch_text (addr , insn );
22+ }
You can’t perform that action at this time.
0 commit comments