[PATCH bpf-next 1/2] bpf, mips: Add JIT support for unconditional BSWAP
From: Johan Almbladh
Date: Fri Sep 25 2026 - 19:21:35 EST
The unconditional BSWAP instruction from the eBPF v4 ISA was not
implemented. This caused programs using the instruction to fall
back to the interpreter.
Implement the unconditional BSWAP instruction.
Signed-off-by: Johan Almbladh <johan.almbladh@xxxxxxxxxxxxxxxxx>
---
arch/mips/net/bpf_jit_comp32.c | 4 ++++
arch/mips/net/bpf_jit_comp64.c | 4 ++++
2 files changed, 8 insertions(+)
diff --git a/arch/mips/net/bpf_jit_comp32.c b/arch/mips/net/bpf_jit_comp32.c
index bbbe4a737825..158e69718c09 100644
--- a/arch/mips/net/bpf_jit_comp32.c
+++ b/arch/mips/net/bpf_jit_comp32.c
@@ -1701,6 +1701,10 @@ int build_insn(const struct bpf_insn *insn, struct jit_context *ctx)
case BPF_ALU64 | BPF_MOD | BPF_X:
emit_divmod_r64(ctx, dst, src, BPF_OP(code), off);
break;
+ /* dst = bswap(dst) */
+ case BPF_ALU64 | BPF_END:
+ emit_bswap_r64(ctx, dst, imm);
+ break;
/* dst = htole(dst) */
/* dst = htobe(dst) */
case BPF_ALU | BPF_END | BPF_FROM_LE:
diff --git a/arch/mips/net/bpf_jit_comp64.c b/arch/mips/net/bpf_jit_comp64.c
index b04b68fa5ace..8359ad3f6992 100644
--- a/arch/mips/net/bpf_jit_comp64.c
+++ b/arch/mips/net/bpf_jit_comp64.c
@@ -876,6 +876,10 @@ int build_insn(const struct bpf_insn *insn, struct jit_context *ctx)
case BPF_ALU64 | BPF_MOD | BPF_X:
emit_alu_r64(ctx, dst, src, BPF_OP(code), off);
break;
+ /* dst = bswap(dst) */
+ case BPF_ALU64 | BPF_END:
+ emit_bswap_r64(ctx, dst, imm);
+ break;
/* dst = htole(dst) */
/* dst = htobe(dst) */
case BPF_ALU | BPF_END | BPF_FROM_LE:
--
2.43.0