Skip to content

Commit ee94b90

Browse files
Jiong WangAlexei Starovoitov
authored andcommitted
mips: bpf: implement jitting of BPF_ALU | BPF_ARSH | BPF_X
Jitting of BPF_K is supported already, but not BPF_X. This patch complete the support for the latter on both MIPS and microMIPS. Cc: Paul Burton <paul.burton@mips.com> Cc: linux-mips@vger.kernel.org Acked-by: Paul Burton <paul.burton@mips.com> Signed-off-by: Jiong Wang <jiong.wang@netronome.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org>
1 parent 17f6c83 commit ee94b90

File tree

6 files changed

+13
-4
lines changed

6 files changed

+13
-4
lines changed

arch/mips/include/asm/uasm.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ Ip_u2u1s3(_slti);
157157
Ip_u2u1s3(_sltiu);
158158
Ip_u3u1u2(_sltu);
159159
Ip_u2u1u3(_sra);
160+
Ip_u3u2u1(_srav);
160161
Ip_u2u1u3(_srl);
161162
Ip_u3u2u1(_srlv);
162163
Ip_u3u1u2(_subu);

arch/mips/include/uapi/asm/inst.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,7 @@ enum mm_32a_minor_op {
371371
mm_srl32_op = 0x040,
372372
mm_srlv32_op = 0x050,
373373
mm_sra_op = 0x080,
374+
mm_srav_op = 0x090,
374375
mm_rotr_op = 0x0c0,
375376
mm_lwxs_op = 0x118,
376377
mm_addu32_op = 0x150,

arch/mips/mm/uasm-micromips.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ static const struct insn insn_table_MM[insn_invalid] = {
104104
[insn_sltiu] = {M(mm_sltiu32_op, 0, 0, 0, 0, 0), RT | RS | SIMM},
105105
[insn_sltu] = {M(mm_pool32a_op, 0, 0, 0, 0, mm_sltu_op), RT | RS | RD},
106106
[insn_sra] = {M(mm_pool32a_op, 0, 0, 0, 0, mm_sra_op), RT | RS | RD},
107+
[insn_srav] = {M(mm_pool32a_op, 0, 0, 0, 0, mm_srav_op), RT | RS | RD},
107108
[insn_srl] = {M(mm_pool32a_op, 0, 0, 0, 0, mm_srl32_op), RT | RS | RD},
108109
[insn_srlv] = {M(mm_pool32a_op, 0, 0, 0, 0, mm_srlv32_op), RT | RS | RD},
109110
[insn_rotr] = {M(mm_pool32a_op, 0, 0, 0, 0, mm_rotr_op), RT | RS | RD},

arch/mips/mm/uasm-mips.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ static const struct insn insn_table[insn_invalid] = {
171171
[insn_sltiu] = {M(sltiu_op, 0, 0, 0, 0, 0), RS | RT | SIMM},
172172
[insn_sltu] = {M(spec_op, 0, 0, 0, 0, sltu_op), RS | RT | RD},
173173
[insn_sra] = {M(spec_op, 0, 0, 0, 0, sra_op), RT | RD | RE},
174+
[insn_srav] = {M(spec_op, 0, 0, 0, 0, srav_op), RS | RT | RD},
174175
[insn_srl] = {M(spec_op, 0, 0, 0, 0, srl_op), RT | RD | RE},
175176
[insn_srlv] = {M(spec_op, 0, 0, 0, 0, srlv_op), RS | RT | RD},
176177
[insn_subu] = {M(spec_op, 0, 0, 0, 0, subu_op), RS | RT | RD},

arch/mips/mm/uasm.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ enum opcode {
6161
insn_mthc0, insn_mthi, insn_mtlo, insn_mul, insn_multu, insn_nor,
6262
insn_or, insn_ori, insn_pref, insn_rfe, insn_rotr, insn_sb,
6363
insn_sc, insn_scd, insn_sd, insn_sh, insn_sll, insn_sllv,
64-
insn_slt, insn_slti, insn_sltiu, insn_sltu, insn_sra, insn_srl,
65-
insn_srlv, insn_subu, insn_sw, insn_sync, insn_syscall, insn_tlbp,
66-
insn_tlbr, insn_tlbwi, insn_tlbwr, insn_wait, insn_wsbh, insn_xor,
67-
insn_xori, insn_yield,
64+
insn_slt, insn_slti, insn_sltiu, insn_sltu, insn_sra, insn_srav,
65+
insn_srl, insn_srlv, insn_subu, insn_sw, insn_sync, insn_syscall,
66+
insn_tlbp, insn_tlbr, insn_tlbwi, insn_tlbwr, insn_wait, insn_wsbh,
67+
insn_xor, insn_xori, insn_yield,
6868
insn_invalid /* insn_invalid must be last */
6969
};
7070

@@ -353,6 +353,7 @@ I_u2u1s3(_slti)
353353
I_u2u1s3(_sltiu)
354354
I_u3u1u2(_sltu)
355355
I_u2u1u3(_sra)
356+
I_u3u2u1(_srav)
356357
I_u2u1u3(_srl)
357358
I_u3u2u1(_srlv)
358359
I_u2u1u3(_rotr)

arch/mips/net/ebpf_jit.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -854,6 +854,7 @@ static int build_one_insn(const struct bpf_insn *insn, struct jit_ctx *ctx,
854854
case BPF_ALU | BPF_MOD | BPF_X: /* ALU_REG */
855855
case BPF_ALU | BPF_LSH | BPF_X: /* ALU_REG */
856856
case BPF_ALU | BPF_RSH | BPF_X: /* ALU_REG */
857+
case BPF_ALU | BPF_ARSH | BPF_X: /* ALU_REG */
857858
src = ebpf_to_mips_reg(ctx, insn, src_reg_no_fp);
858859
dst = ebpf_to_mips_reg(ctx, insn, dst_reg);
859860
if (src < 0 || dst < 0)
@@ -913,6 +914,9 @@ static int build_one_insn(const struct bpf_insn *insn, struct jit_ctx *ctx,
913914
case BPF_RSH:
914915
emit_instr(ctx, srlv, dst, dst, src);
915916
break;
917+
case BPF_ARSH:
918+
emit_instr(ctx, srav, dst, dst, src);
919+
break;
916920
default:
917921
pr_err("ALU_REG NOT HANDLED\n");
918922
return -EINVAL;

0 commit comments

Comments
 (0)