mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
Merge branch 'bpf-mips-add-jit-support-for-v4-instructions'
Johan Almbladh says:
====================
bpf, mips: Add JIT support for v4 instructions
The MIPS eBPF JIT currently lacks support for several BPF instructions
introduced by later revisions of the BPF ISA. This series adds JIT
support for unconditional BSWAP and JMP32_JA. Together with the recent
work of Nicholas Dudar, this completes support for the BPF v4 ISA in
the JIT.
The series was applied with Nicholas Dudar's patch for MEMSX added on
top ("bpf, mips: Add BPF_MEMSX support to the JITs"). The JIT was then
tested on QEMU MIPS targets, with the following results.
MIPS32r1/r2/r6 big and little endian:
test_bpf: Summary: 1062 PASSED, 0 FAILED, [1050/1050 JIT'ed]
MIPS64r1/r2/r6 big and little endian:
test_bpf: Summary: 1061 PASSED, 0 FAILED, [1049/1049 JIT'ed]
All JIT-eligible tests were JITed and all tests pass on all 12 QEMU
MIPS targets. No physical MIPS hardware was used in the tests.
====================
Link: https://patch.msgid.link/20260925231932.1063678-1-johan.almbladh@anyfinetworks.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
This commit is contained in:
commit
5db16a1249
|
|
@ -850,7 +850,7 @@ void emit_jmp_r(struct jit_context *ctx, u8 dst, u8 src, s32 off, u8 op)
|
|||
}
|
||||
|
||||
/* Jump always */
|
||||
int emit_ja(struct jit_context *ctx, s16 off)
|
||||
int emit_ja(struct jit_context *ctx, s32 off)
|
||||
{
|
||||
int target = get_target(ctx, ctx->bpf_index + off + 1);
|
||||
|
||||
|
|
|
|||
|
|
@ -204,7 +204,7 @@ void emit_jmp_i(struct jit_context *ctx, u8 dst, s32 imm, s32 off, u8 op);
|
|||
void emit_jmp_r(struct jit_context *ctx, u8 dst, u8 src, s32 off, u8 op);
|
||||
|
||||
/* Jump always */
|
||||
int emit_ja(struct jit_context *ctx, s16 off);
|
||||
int emit_ja(struct jit_context *ctx, s32 off);
|
||||
|
||||
/* Jump to epilogue */
|
||||
int emit_exit(struct jit_context *ctx);
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
@ -1873,6 +1877,13 @@ int build_insn(const struct bpf_insn *insn, struct jit_context *ctx)
|
|||
if (finish_jmp(ctx, jmp, off) < 0)
|
||||
goto toofar;
|
||||
break;
|
||||
/* PC += imm */
|
||||
case BPF_JMP32 | BPF_JA:
|
||||
if (imm == 0)
|
||||
break;
|
||||
if (emit_ja(ctx, imm) < 0)
|
||||
goto toofar;
|
||||
break;
|
||||
/* PC += off if dst == src */
|
||||
/* PC += off if dst != src */
|
||||
/* PC += off if dst & src */
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
@ -1037,6 +1041,13 @@ int build_insn(const struct bpf_insn *insn, struct jit_context *ctx)
|
|||
if (finish_jmp(ctx, jmp, off) < 0)
|
||||
goto toofar;
|
||||
break;
|
||||
/* PC += imm */
|
||||
case BPF_JMP32 | BPF_JA:
|
||||
if (imm == 0)
|
||||
break;
|
||||
if (emit_ja(ctx, imm) < 0)
|
||||
goto toofar;
|
||||
break;
|
||||
/* PC += off if dst == src */
|
||||
/* PC += off if dst != src */
|
||||
/* PC += off if dst & src */
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user