* [PATCH bpf 1/2] bpf, mips: Fix immediate JMP JEQ/JNE on MIPS32
@ 2026-09-23 10:51 Johan Almbladh
2026-09-23 10:51 ` [PATCH bpf 2/2] bpf, mips: Fix BSWAP 32 and 16 on MIPS64 Johan Almbladh
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Johan Almbladh @ 2026-09-23 10:51 UTC (permalink / raw)
To: tsbogend, ast, daniel, andrii, eddyz87, memxor, paulburton,
main.kalliope
Cc: martin.lau, song, yonghong.song, jolsa, emil, ihor.solodrai,
linux-mips, linux-kernel, bpf, philmd, Johan Almbladh
An addu instruction was emitted instead of addiu, causing the immediate
value 1 to be interpreted as register $at. This made the comparison
result invalid when the immediate operand was negative. Note that $at
is mapped to BPF_REG_AX, which is used for constant blinding.
Fix the instruction to use the immediate form.
Found with test_bpf on MIPS32r1 emulated by QEMU.
Fixes: eb63cfcd2ee8 ("mips, bpf: Add eBPF JIT for 32-bit MIPS")
Signed-off-by: Johan Almbladh <johan.almbladh@anyfinetworks.com>
---
arch/mips/net/bpf_jit_comp32.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/mips/net/bpf_jit_comp32.c b/arch/mips/net/bpf_jit_comp32.c
index 40a878b672f5..15a2a153dc87 100644
--- a/arch/mips/net/bpf_jit_comp32.c
+++ b/arch/mips/net/bpf_jit_comp32.c
@@ -1111,7 +1111,7 @@ static void emit_jmp_i64(struct jit_context *ctx,
emit(ctx, xor, tmp, lo(dst), tmp);
}
if (imm < 0) { /* Compare sign extension */
- emit(ctx, addu, MIPS_R_T9, hi(dst), 1);
+ emit(ctx, addiu, MIPS_R_T9, hi(dst), 1);
emit(ctx, or, tmp, tmp, MIPS_R_T9);
} else { /* Compare zero extension */
emit(ctx, or, tmp, tmp, hi(dst));
--
2.43.0
^ permalink raw reply [flat|nested] 4+ messages in thread* [PATCH bpf 2/2] bpf, mips: Fix BSWAP 32 and 16 on MIPS64
2026-09-23 10:51 [PATCH bpf 1/2] bpf, mips: Fix immediate JMP JEQ/JNE on MIPS32 Johan Almbladh
@ 2026-09-23 10:51 ` Johan Almbladh
2026-09-24 2:00 ` [PATCH bpf 1/2] bpf, mips: Fix immediate JMP JEQ/JNE on MIPS32 patchwork-bot+netdevbpf
2026-09-24 8:22 ` David Laight
2 siblings, 0 replies; 4+ messages in thread
From: Johan Almbladh @ 2026-09-23 10:51 UTC (permalink / raw)
To: tsbogend, ast, daniel, andrii, eddyz87, memxor, paulburton,
main.kalliope
Cc: martin.lau, song, yonghong.song, jolsa, emil, ihor.solodrai,
linux-mips, linux-kernel, bpf, philmd, Johan Almbladh
The 16/32-bit byteswap implementations for MIPS64r1 and earlier do
not have an explicit zero extension afterwards. The input is first
sign-extended to 64 bits, and the byteswap sequence can then leave
the result sign-extended depending on the value of the low bits.
Add the missing zero-extension.
Found with test_bpf on MIPS64r1 emulated by QEMU.
Fixes: fbc802de6b10 ("mips, bpf: Add new eBPF JIT for 64-bit MIPS")
Signed-off-by: Johan Almbladh <johan.almbladh@anyfinetworks.com>
---
arch/mips/net/bpf_jit_comp64.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/arch/mips/net/bpf_jit_comp64.c b/arch/mips/net/bpf_jit_comp64.c
index fa7e9aa37f49..6681ccac9dd9 100644
--- a/arch/mips/net/bpf_jit_comp64.c
+++ b/arch/mips/net/bpf_jit_comp64.c
@@ -305,8 +305,7 @@ static void emit_bswap_r64(struct jit_context *ctx, u8 dst, u32 width)
case 16:
emit_sext(ctx, dst, dst);
emit_bswap_r(ctx, dst, width);
- if (cpu_has_mips64r2 || cpu_has_mips64r6)
- emit_zext(ctx, dst);
+ emit_zext(ctx, dst);
break;
}
clobber_reg(ctx, dst);
--
2.43.0
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH bpf 1/2] bpf, mips: Fix immediate JMP JEQ/JNE on MIPS32
2026-09-23 10:51 [PATCH bpf 1/2] bpf, mips: Fix immediate JMP JEQ/JNE on MIPS32 Johan Almbladh
2026-09-23 10:51 ` [PATCH bpf 2/2] bpf, mips: Fix BSWAP 32 and 16 on MIPS64 Johan Almbladh
@ 2026-09-24 2:00 ` patchwork-bot+netdevbpf
2026-09-24 8:22 ` David Laight
2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-09-24 2:00 UTC (permalink / raw)
To: Johan Almbladh
Cc: tsbogend, ast, daniel, andrii, eddyz87, memxor, paulburton,
main.kalliope, martin.lau, song, yonghong.song, jolsa, emil,
ihor.solodrai, linux-mips, linux-kernel, bpf, philmd
Hello:
This series was applied to bpf/bpf.git (master)
by Alexei Starovoitov <ast@kernel.org>:
On Wed, 23 Sep 2026 12:51:57 +0200 you wrote:
> An addu instruction was emitted instead of addiu, causing the immediate
> value 1 to be interpreted as register $at. This made the comparison
> result invalid when the immediate operand was negative. Note that $at
> is mapped to BPF_REG_AX, which is used for constant blinding.
>
> Fix the instruction to use the immediate form.
>
> [...]
Here is the summary with links:
- [bpf,1/2] bpf, mips: Fix immediate JMP JEQ/JNE on MIPS32
https://git.kernel.org/bpf/bpf/c/db762fd96be2
- [bpf,2/2] bpf, mips: Fix BSWAP 32 and 16 on MIPS64
https://git.kernel.org/bpf/bpf/c/8110ba097778
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH bpf 1/2] bpf, mips: Fix immediate JMP JEQ/JNE on MIPS32
2026-09-23 10:51 [PATCH bpf 1/2] bpf, mips: Fix immediate JMP JEQ/JNE on MIPS32 Johan Almbladh
2026-09-23 10:51 ` [PATCH bpf 2/2] bpf, mips: Fix BSWAP 32 and 16 on MIPS64 Johan Almbladh
2026-09-24 2:00 ` [PATCH bpf 1/2] bpf, mips: Fix immediate JMP JEQ/JNE on MIPS32 patchwork-bot+netdevbpf
@ 2026-09-24 8:22 ` David Laight
2 siblings, 0 replies; 4+ messages in thread
From: David Laight @ 2026-09-24 8:22 UTC (permalink / raw)
To: Johan Almbladh
Cc: tsbogend, ast, daniel, andrii, eddyz87, memxor, paulburton,
main.kalliope, martin.lau, song, yonghong.song, jolsa, emil,
ihor.solodrai, linux-mips, linux-kernel, bpf, philmd
On Wed, 23 Sep 2026 12:51:57 +0200
Johan Almbladh <johan.almbladh@anyfinetworks.com> wrote:
> An addu instruction was emitted instead of addiu, causing the immediate
> value 1 to be interpreted as register $at. This made the comparison
> result invalid when the immediate operand was negative. Note that $at
> is mapped to BPF_REG_AX, which is used for constant blinding.
^^ building??
David
>
> Fix the instruction to use the immediate form.
>
> Found with test_bpf on MIPS32r1 emulated by QEMU.
>
> Fixes: eb63cfcd2ee8 ("mips, bpf: Add eBPF JIT for 32-bit MIPS")
> Signed-off-by: Johan Almbladh <johan.almbladh@anyfinetworks.com>
> ---
> arch/mips/net/bpf_jit_comp32.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/mips/net/bpf_jit_comp32.c b/arch/mips/net/bpf_jit_comp32.c
> index 40a878b672f5..15a2a153dc87 100644
> --- a/arch/mips/net/bpf_jit_comp32.c
> +++ b/arch/mips/net/bpf_jit_comp32.c
> @@ -1111,7 +1111,7 @@ static void emit_jmp_i64(struct jit_context *ctx,
> emit(ctx, xor, tmp, lo(dst), tmp);
> }
> if (imm < 0) { /* Compare sign extension */
> - emit(ctx, addu, MIPS_R_T9, hi(dst), 1);
> + emit(ctx, addiu, MIPS_R_T9, hi(dst), 1);
> emit(ctx, or, tmp, tmp, MIPS_R_T9);
> } else { /* Compare zero extension */
> emit(ctx, or, tmp, tmp, hi(dst));
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-09-24 8:22 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-23 10:51 [PATCH bpf 1/2] bpf, mips: Fix immediate JMP JEQ/JNE on MIPS32 Johan Almbladh
2026-09-23 10:51 ` [PATCH bpf 2/2] bpf, mips: Fix BSWAP 32 and 16 on MIPS64 Johan Almbladh
2026-09-24 2:00 ` [PATCH bpf 1/2] bpf, mips: Fix immediate JMP JEQ/JNE on MIPS32 patchwork-bot+netdevbpf
2026-09-24 8:22 ` David Laight
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®