aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/arch/loongarch/kernel/jump_label.c
diff options
context:
space:
mode:
authorYouling Tang <tangyouling@loongson.cn>2023-06-29 20:58:44 +0800
committerHuacai Chen <chenhuacai@loongson.cn>2023-06-29 20:58:44 +0800
commitf02644e32c9e4bd1a9b286dc0b84f9cbe294f4e2 (patch)
tree3742c78f2f4c61b1463b9a40c98835182ed6ac13 /arch/loongarch/kernel/jump_label.c
parentLoongArch: Select HAVE_DEBUG_KMEMLEAK to support kmemleak (diff)
downloadwireguard-linux-f02644e32c9e4bd1a9b286dc0b84f9cbe294f4e2.tar.xz
wireguard-linux-f02644e32c9e4bd1a9b286dc0b84f9cbe294f4e2.zip
LoongArch: Add jump-label implementation
Add support for jump labels based on the ARM64 version. Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org> Signed-off-by: Youling Tang <tangyouling@loongson.cn> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Diffstat (limited to '')
-rw-r--r--arch/loongarch/kernel/jump_label.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/arch/loongarch/kernel/jump_label.c b/arch/loongarch/kernel/jump_label.c
new file mode 100644
index 000000000000..31891214b767
--- /dev/null
+++ b/arch/loongarch/kernel/jump_label.c
@@ -0,0 +1,22 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (C) 2023 Loongson Technology Corporation Limited
+ *
+ * Based on arch/arm64/kernel/jump_label.c
+ */
+#include <linux/kernel.h>
+#include <linux/jump_label.h>
+#include <asm/inst.h>
+
+void arch_jump_label_transform(struct jump_entry *entry, enum jump_label_type type)
+{
+ u32 insn;
+ void *addr = (void *)jump_entry_code(entry);
+
+ if (type == JUMP_LABEL_JMP)
+ insn = larch_insn_gen_b(jump_entry_code(entry), jump_entry_target(entry));
+ else
+ insn = larch_insn_gen_nop();
+
+ larch_insn_patch_text(addr, insn);
+}