summary refs log tree commit diff
path: root/arch/loongarch
diff options
context:
space:
mode:
authorTiezhu Yang <yangtiezhu@loongson.cn>2023-07-28 10:30:42 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-08-03 10:24:15 +0200
commit8a5e0c1f71dc4a57acee3e76f0074f6b867e8611 (patch)
treeeec084349df342eb707170c3100858f0131781cc /arch/loongarch
parent024ed3b9b8e38472705c5fa3a5207bafe2183ad9 (diff)
downloadlinux-8a5e0c1f71dc4a57acee3e76f0074f6b867e8611.tar.gz
LoongArch: BPF: Fix check condition to call lu32id in move_imm()
commit 4eece7e6de94d833c8aeed2f438faf487cbf94ff upstream.

As the code comment says, the initial aim is to reduce one instruction
in some corner cases, if bit[51:31] is all 0 or all 1, no need to call
lu32id. That is to say, it should call lu32id only if bit[51:31] is not
all 0 and not all 1. The current code always call lu32id, the result is
right but the logic is unexpected and wrong, fix it.

Cc: stable@vger.kernel.org # 6.1
Fixes: 5dc615520c4d ("LoongArch: Add BPF JIT support")
Reported-by: Colin King (gmail) <colin.i.king@gmail.com>
Closes: https://lore.kernel.org/all/bcf97046-e336-712a-ac68-7fd194f2953e@gmail.com/
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'arch/loongarch')
-rw-r--r--arch/loongarch/net/bpf_jit.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/arch/loongarch/net/bpf_jit.h b/arch/loongarch/net/bpf_jit.h
index 093885539e70..684b22f54ccc 100644
--- a/arch/loongarch/net/bpf_jit.h
+++ b/arch/loongarch/net/bpf_jit.h
@@ -148,7 +148,7 @@ static inline void move_imm(struct jit_ctx *ctx, enum loongarch_gpr rd, long imm
 			 * no need to call lu32id to do a new filled operation.
 			 */
 			imm_51_31 = (imm >> 31) & 0x1fffff;
-			if (imm_51_31 != 0 || imm_51_31 != 0x1fffff) {
+			if (imm_51_31 != 0 && imm_51_31 != 0x1fffff) {
 				/* lu32id rd, imm_51_32 */
 				imm_51_32 = (imm >> 32) & 0xfffff;
 				emit_insn(ctx, lu32id, rd, imm_51_32);