bpf, mips: Add JIT support for unconditional BSWAP

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@anyfinetworks.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://patch.msgid.link/20260925231932.1063678-2-johan.almbladh@anyfinetworks.com
This commit is contained in:
Johan Almbladh 2026-09-26 01:19:31 +02:00 committed by Alexei Starovoitov
parent 6ac134ec93
commit 89d8e19811
No known key found for this signature in database
2 changed files with 8 additions and 0 deletions

View File

@ -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:

View File

@ -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: