aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/net/ebpf_jit.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/mips/net/ebpf_jit.c')
-rw-r--r--arch/mips/net/ebpf_jit.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/arch/mips/net/ebpf_jit.c b/arch/mips/net/ebpf_jit.c
index b16710a8a9e7..76e9bf88d3b9 100644
--- a/arch/mips/net/ebpf_jit.c
+++ b/arch/mips/net/ebpf_jit.c
@@ -79,8 +79,6 @@ enum reg_val_type {
79 REG_64BIT_32BIT, 79 REG_64BIT_32BIT,
80 /* 32-bit compatible, need truncation for 64-bit ops. */ 80 /* 32-bit compatible, need truncation for 64-bit ops. */
81 REG_32BIT, 81 REG_32BIT,
82 /* 32-bit zero extended. */
83 REG_32BIT_ZERO_EX,
84 /* 32-bit no sign/zero extension needed. */ 82 /* 32-bit no sign/zero extension needed. */
85 REG_32BIT_POS 83 REG_32BIT_POS
86}; 84};
@@ -343,12 +341,15 @@ static int build_int_epilogue(struct jit_ctx *ctx, int dest_reg)
343 const struct bpf_prog *prog = ctx->skf; 341 const struct bpf_prog *prog = ctx->skf;
344 int stack_adjust = ctx->stack_size; 342 int stack_adjust = ctx->stack_size;
345 int store_offset = stack_adjust - 8; 343 int store_offset = stack_adjust - 8;
344 enum reg_val_type td;
346 int r0 = MIPS_R_V0; 345 int r0 = MIPS_R_V0;
347 346
348 if (dest_reg == MIPS_R_RA && 347 if (dest_reg == MIPS_R_RA) {
349 get_reg_val_type(ctx, prog->len, BPF_REG_0) == REG_32BIT_ZERO_EX)
350 /* Don't let zero extended value escape. */ 348 /* Don't let zero extended value escape. */
351 emit_instr(ctx, sll, r0, r0, 0); 349 td = get_reg_val_type(ctx, prog->len, BPF_REG_0);
350 if (td == REG_64BIT)
351 emit_instr(ctx, sll, r0, r0, 0);
352 }
352 353
353 if (ctx->flags & EBPF_SAVE_RA) { 354 if (ctx->flags & EBPF_SAVE_RA) {
354 emit_instr(ctx, ld, MIPS_R_RA, store_offset, MIPS_R_SP); 355 emit_instr(ctx, ld, MIPS_R_RA, store_offset, MIPS_R_SP);
@@ -692,7 +693,7 @@ static int build_one_insn(const struct bpf_insn *insn, struct jit_ctx *ctx,
692 if (dst < 0) 693 if (dst < 0)
693 return dst; 694 return dst;
694 td = get_reg_val_type(ctx, this_idx, insn->dst_reg); 695 td = get_reg_val_type(ctx, this_idx, insn->dst_reg);
695 if (td == REG_64BIT || td == REG_32BIT_ZERO_EX) { 696 if (td == REG_64BIT) {
696 /* sign extend */ 697 /* sign extend */
697 emit_instr(ctx, sll, dst, dst, 0); 698 emit_instr(ctx, sll, dst, dst, 0);
698 } 699 }
@@ -707,7 +708,7 @@ static int build_one_insn(const struct bpf_insn *insn, struct jit_ctx *ctx,
707 if (dst < 0) 708 if (dst < 0)
708 return dst; 709 return dst;
709 td = get_reg_val_type(ctx, this_idx, insn->dst_reg); 710 td = get_reg_val_type(ctx, this_idx, insn->dst_reg);
710 if (td == REG_64BIT || td == REG_32BIT_ZERO_EX) { 711 if (td == REG_64BIT) {
711 /* sign extend */ 712 /* sign extend */
712 emit_instr(ctx, sll, dst, dst, 0); 713 emit_instr(ctx, sll, dst, dst, 0);
713 } 714 }
@@ -721,7 +722,7 @@ static int build_one_insn(const struct bpf_insn *insn, struct jit_ctx *ctx,
721 if (dst < 0) 722 if (dst < 0)
722 return dst; 723 return dst;
723 td = get_reg_val_type(ctx, this_idx, insn->dst_reg); 724 td = get_reg_val_type(ctx, this_idx, insn->dst_reg);
724 if (td == REG_64BIT || td == REG_32BIT_ZERO_EX) 725 if (td == REG_64BIT)
725 /* sign extend */ 726 /* sign extend */
726 emit_instr(ctx, sll, dst, dst, 0); 727 emit_instr(ctx, sll, dst, dst, 0);
727 if (insn->imm == 1) { 728 if (insn->imm == 1) {
@@ -860,13 +861,13 @@ static int build_one_insn(const struct bpf_insn *insn, struct jit_ctx *ctx,
860 if (src < 0 || dst < 0) 861 if (src < 0 || dst < 0)
861 return -EINVAL; 862 return -EINVAL;
862 td = get_reg_val_type(ctx, this_idx, insn->dst_reg); 863 td = get_reg_val_type(ctx, this_idx, insn->dst_reg);
863 if (td == REG_64BIT || td == REG_32BIT_ZERO_EX) { 864 if (td == REG_64BIT) {
864 /* sign extend */ 865 /* sign extend */
865 emit_instr(ctx, sll, dst, dst, 0); 866 emit_instr(ctx, sll, dst, dst, 0);
866 } 867 }
867 did_move = false; 868 did_move = false;
868 ts = get_reg_val_type(ctx, this_idx, insn->src_reg); 869 ts = get_reg_val_type(ctx, this_idx, insn->src_reg);
869 if (ts == REG_64BIT || ts == REG_32BIT_ZERO_EX) { 870 if (ts == REG_64BIT) {
870 int tmp_reg = MIPS_R_AT; 871 int tmp_reg = MIPS_R_AT;
871 872
872 if (bpf_op == BPF_MOV) { 873 if (bpf_op == BPF_MOV) {
@@ -1254,8 +1255,7 @@ jeq_common:
1254 if (insn->imm == 64 && td == REG_32BIT) 1255 if (insn->imm == 64 && td == REG_32BIT)
1255 emit_instr(ctx, dinsu, dst, MIPS_R_ZERO, 32, 32); 1256 emit_instr(ctx, dinsu, dst, MIPS_R_ZERO, 32, 32);
1256 1257
1257 if (insn->imm != 64 && 1258 if (insn->imm != 64 && td == REG_64BIT) {
1258 (td == REG_64BIT || td == REG_32BIT_ZERO_EX)) {
1259 /* sign extend */ 1259 /* sign extend */
1260 emit_instr(ctx, sll, dst, dst, 0); 1260 emit_instr(ctx, sll, dst, dst, 0);
1261 } 1261 }