From: Tiezhu Yang <yangtiezhu@loongson.cn>
To: Huacai Chen <chenhuacai@kernel.org>,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>
Cc: bpf@vger.kernel.org, loongarch@lists.linux.dev
Subject: [PATCH bpf-next v1 1/4] LoongArch: Move {signed,unsigned}_imm_check() to inst.h
Date: Sat, 20 Aug 2022 19:50:57 +0800 [thread overview]
Message-ID: <1660996260-11337-2-git-send-email-yangtiezhu@loongson.cn> (raw)
In-Reply-To: <1660996260-11337-1-git-send-email-yangtiezhu@loongson.cn>
{signed,unsigned}_imm_check() will also be used in the bpf jit, so move
them from module.c to inst.h, this is preparation for later patch.
By the way, no need to explicitly include asm/inst.h in module.c, because
the header file has been included indirectly.
arch/loongarch/kernel/module.c
include/linux/moduleloader.h
include/linux/module.h
arch/loongarch/include/asm/module.h
arch/loongarch/include/asm/inst.h
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---
arch/loongarch/include/asm/inst.h | 10 ++++++++++
arch/loongarch/kernel/module.c | 10 ----------
2 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/arch/loongarch/include/asm/inst.h b/arch/loongarch/include/asm/inst.h
index 7b07cbb..7b37509 100644
--- a/arch/loongarch/include/asm/inst.h
+++ b/arch/loongarch/include/asm/inst.h
@@ -166,4 +166,14 @@ u32 larch_insn_gen_lu32id(enum loongarch_gpr rd, int imm);
u32 larch_insn_gen_lu52id(enum loongarch_gpr rd, enum loongarch_gpr rj, int imm);
u32 larch_insn_gen_jirl(enum loongarch_gpr rd, enum loongarch_gpr rj, unsigned long pc, unsigned long dest);
+static inline bool signed_imm_check(long val, unsigned int bit)
+{
+ return -(1L << (bit - 1)) <= val && val < (1L << (bit - 1));
+}
+
+static inline bool unsigned_imm_check(unsigned long val, unsigned int bit)
+{
+ return val < (1UL << bit);
+}
+
#endif /* _ASM_INST_H */
diff --git a/arch/loongarch/kernel/module.c b/arch/loongarch/kernel/module.c
index 638427f..edaee67 100644
--- a/arch/loongarch/kernel/module.c
+++ b/arch/loongarch/kernel/module.c
@@ -18,16 +18,6 @@
#include <linux/string.h>
#include <linux/kernel.h>
-static inline bool signed_imm_check(long val, unsigned int bit)
-{
- return -(1L << (bit - 1)) <= val && val < (1L << (bit - 1));
-}
-
-static inline bool unsigned_imm_check(unsigned long val, unsigned int bit)
-{
- return val < (1UL << bit);
-}
-
static int rela_stack_push(s64 stack_value, s64 *rela_stack, size_t *rela_stack_top)
{
if (*rela_stack_top >= RELA_STACK_DEPTH)
--
2.1.0
next prev parent reply other threads:[~2022-08-20 11:51 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-20 11:50 [PATCH bpf-next v1 0/4] Add BPF JIT support for LoongArch Tiezhu Yang
2022-08-20 11:50 ` Tiezhu Yang [this message]
2022-08-20 11:50 ` [PATCH bpf-next v1 2/4] LoongArch: Add some instruction opcodes and formats Tiezhu Yang
2022-08-20 11:50 ` [PATCH bpf-next v1 3/4] LoongArch: Add BPF JIT support Tiezhu Yang
2022-08-20 13:41 ` kernel test robot
2022-08-22 1:33 ` Tiezhu Yang
2022-08-22 1:58 ` Youling Tang
2022-08-22 2:03 ` Youling Tang
2022-08-22 2:49 ` Tiezhu Yang
2022-08-22 2:50 ` Jinyang He
2022-08-25 2:27 ` Tiezhu Yang
2022-08-20 11:51 ` [PATCH bpf-next v1 4/4] LoongArch: Enable BPF_JIT and TEST_BPF in default config Tiezhu Yang
2022-08-22 1:36 ` [PATCH bpf-next v1 0/4] Add BPF JIT support for LoongArch Tiezhu Yang
2022-08-23 0:46 ` Alexei Starovoitov
2022-08-23 12:08 ` Huacai Chen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1660996260-11337-2-git-send-email-yangtiezhu@loongson.cn \
--to=yangtiezhu@loongson.cn \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=chenhuacai@kernel.org \
--cc=daniel@iogearbox.net \
--cc=loongarch@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).