Skip to content

Commit 694896a

Browse files
Pu LehuiAlexei Starovoitov
authored andcommitted
riscv, bpf: Support sign-extension mov insns
Add support sign-extension mov instructions for RV64. Signed-off-by: Pu Lehui <pulehui@huawei.com> Acked-by: Björn Töpel <bjorn@kernel.org> Link: https://lore.kernel.org/r/20230824095001.3408573-4-pulehui@huaweicloud.com Signed-off-by: Alexei Starovoitov <ast@kernel.org>
1 parent 3d06d81 commit 694896a

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

arch/riscv/net/bpf_jit_comp64.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1047,7 +1047,19 @@ int bpf_jit_emit_insn(const struct bpf_insn *insn, struct rv_jit_context *ctx,
10471047
emit_zext_32(rd, ctx);
10481048
break;
10491049
}
1050-
emit_mv(rd, rs, ctx);
1050+
switch (insn->off) {
1051+
case 0:
1052+
emit_mv(rd, rs, ctx);
1053+
break;
1054+
case 8:
1055+
case 16:
1056+
emit_slli(RV_REG_T1, rs, 64 - insn->off, ctx);
1057+
emit_srai(rd, RV_REG_T1, 64 - insn->off, ctx);
1058+
break;
1059+
case 32:
1060+
emit_addiw(rd, rs, 0, ctx);
1061+
break;
1062+
}
10511063
if (!is64 && !aux->verifier_zext)
10521064
emit_zext_32(rd, ctx);
10531065
break;

0 commit comments

Comments
 (0)