Skip to content

Commit 4eece7e

Browse files
seehearfeelchenhuacai
authored andcommitted
LoongArch: BPF: Fix check condition to call lu32id in move_imm()
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: [email protected] # 6.1 Fixes: 5dc6155 ("LoongArch: Add BPF JIT support") Reported-by: Colin King (gmail) <[email protected]> Closes: https://lore.kernel.org/all/[email protected]/ Signed-off-by: Tiezhu Yang <[email protected]> Signed-off-by: Huacai Chen <[email protected]>
1 parent de0e30b commit 4eece7e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

arch/loongarch/net/bpf_jit.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ static inline void move_imm(struct jit_ctx *ctx, enum loongarch_gpr rd, long imm
150150
* no need to call lu32id to do a new filled operation.
151151
*/
152152
imm_51_31 = (imm >> 31) & 0x1fffff;
153-
if (imm_51_31 != 0 || imm_51_31 != 0x1fffff) {
153+
if (imm_51_31 != 0 && imm_51_31 != 0x1fffff) {
154154
/* lu32id rd, imm_51_32 */
155155
imm_51_32 = (imm >> 32) & 0xfffff;
156156
emit_insn(ctx, lu32id, rd, imm_51_32);

0 commit comments

Comments
 (0)