Skip to content

Commit f48012f

Browse files
chenhengqichenhuacai
authored andcommitted
LoongArch: BPF: Support sign-extension mov instructions
Add support for sign-extension mov instructions. Signed-off-by: Hengqi Chen <hengqi.chen@gmail.com> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
1 parent 7111afe commit f48012f

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

arch/loongarch/net/bpf_jit.c

+17-2
Original file line numberDiff line numberDiff line change
@@ -472,8 +472,23 @@ static int build_insn(const struct bpf_insn *insn, struct jit_ctx *ctx, bool ext
472472
/* dst = src */
473473
case BPF_ALU | BPF_MOV | BPF_X:
474474
case BPF_ALU64 | BPF_MOV | BPF_X:
475-
move_reg(ctx, dst, src);
476-
emit_zext_32(ctx, dst, is32);
475+
switch (off) {
476+
case 0:
477+
move_reg(ctx, dst, src);
478+
emit_zext_32(ctx, dst, is32);
479+
break;
480+
case 8:
481+
move_reg(ctx, t1, src);
482+
emit_insn(ctx, extwb, dst, t1);
483+
break;
484+
case 16:
485+
move_reg(ctx, t1, src);
486+
emit_insn(ctx, extwh, dst, t1);
487+
break;
488+
case 32:
489+
emit_insn(ctx, addw, dst, src, LOONGARCH_GPR_ZERO);
490+
break;
491+
}
477492
break;
478493

479494
/* dst = imm */

0 commit comments

Comments
 (0)