[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241015113915.12623-6-yangtiezhu@loongson.cn>
Date: Tue, 15 Oct 2024 19:39:14 +0800
From: Tiezhu Yang <yangtiezhu@...ngson.cn>
To: Huacai Chen <chenhuacai@...nel.org>,
Josh Poimboeuf <jpoimboe@...nel.org>,
Peter Zijlstra <peterz@...radead.org>
Cc: loongarch@...ts.linux.dev,
bpf@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH v1 5/6] LoongArch: Define specified arch_prepare_goto()
In order to figure out the address of goto table by interpreting the
LoongArch machine code, define specified arch_prepare_goto() to insert
the relocation information of goto table address, then it can find the
destination address of the table jump instruction.
Suggested-by: Xi Ruoyao <xry111@...111.site>
Signed-off-by: Tiezhu Yang <yangtiezhu@...ngson.cn>
---
arch/loongarch/Kconfig | 1 +
arch/loongarch/include/asm/compiler.h | 13 +++++++++++++
2 files changed, 14 insertions(+)
create mode 100644 arch/loongarch/include/asm/compiler.h
diff --git a/arch/loongarch/Kconfig b/arch/loongarch/Kconfig
index 49ed776cb253..9eed0bde678f 100644
--- a/arch/loongarch/Kconfig
+++ b/arch/loongarch/Kconfig
@@ -106,6 +106,7 @@ config LOONGARCH
select GPIOLIB
select HAS_IOPORT
select HAVE_ARCH_AUDITSYSCALL
+ select HAVE_ARCH_COMPILER_H
select HAVE_ARCH_JUMP_LABEL
select HAVE_ARCH_JUMP_LABEL_RELATIVE
select HAVE_ARCH_KASAN
diff --git a/arch/loongarch/include/asm/compiler.h b/arch/loongarch/include/asm/compiler.h
new file mode 100644
index 000000000000..424268a92c40
--- /dev/null
+++ b/arch/loongarch/include/asm/compiler.h
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2024 Loongson Technology Corporation Limited
+ */
+#ifndef _ASM_COMPILER_H
+#define _ASM_COMPILER_H
+
+#ifndef CONFIG_BPF_JIT_ALWAYS_ON
+#define arch_prepare_goto() \
+ asm volatile(".reloc\t., R_LARCH_NONE, %0" : : "i" (jumptable))
+#endif
+
+#endif /* _ASM_COMPILER_H */
--
2.42.0
Powered by blists - more mailing lists