@@ -1107,13 +1107,19 @@ int bpf_jit_emit_insn(const struct bpf_insn *insn, struct rv_jit_context *ctx,
1107
1107
break ;
1108
1108
case BPF_ALU | BPF_DIV | BPF_X :
1109
1109
case BPF_ALU64 | BPF_DIV | BPF_X :
1110
- emit (is64 ? rv_divu (rd , rd , rs ) : rv_divuw (rd , rd , rs ), ctx );
1110
+ if (off )
1111
+ emit (is64 ? rv_div (rd , rd , rs ) : rv_divw (rd , rd , rs ), ctx );
1112
+ else
1113
+ emit (is64 ? rv_divu (rd , rd , rs ) : rv_divuw (rd , rd , rs ), ctx );
1111
1114
if (!is64 && !aux -> verifier_zext )
1112
1115
emit_zext_32 (rd , ctx );
1113
1116
break ;
1114
1117
case BPF_ALU | BPF_MOD | BPF_X :
1115
1118
case BPF_ALU64 | BPF_MOD | BPF_X :
1116
- emit (is64 ? rv_remu (rd , rd , rs ) : rv_remuw (rd , rd , rs ), ctx );
1119
+ if (off )
1120
+ emit (is64 ? rv_rem (rd , rd , rs ) : rv_remw (rd , rd , rs ), ctx );
1121
+ else
1122
+ emit (is64 ? rv_remu (rd , rd , rs ) : rv_remuw (rd , rd , rs ), ctx );
1117
1123
if (!is64 && !aux -> verifier_zext )
1118
1124
emit_zext_32 (rd , ctx );
1119
1125
break ;
@@ -1284,16 +1290,24 @@ int bpf_jit_emit_insn(const struct bpf_insn *insn, struct rv_jit_context *ctx,
1284
1290
case BPF_ALU | BPF_DIV | BPF_K :
1285
1291
case BPF_ALU64 | BPF_DIV | BPF_K :
1286
1292
emit_imm (RV_REG_T1 , imm , ctx );
1287
- emit (is64 ? rv_divu (rd , rd , RV_REG_T1 ) :
1288
- rv_divuw (rd , rd , RV_REG_T1 ), ctx );
1293
+ if (off )
1294
+ emit (is64 ? rv_div (rd , rd , RV_REG_T1 ) :
1295
+ rv_divw (rd , rd , RV_REG_T1 ), ctx );
1296
+ else
1297
+ emit (is64 ? rv_divu (rd , rd , RV_REG_T1 ) :
1298
+ rv_divuw (rd , rd , RV_REG_T1 ), ctx );
1289
1299
if (!is64 && !aux -> verifier_zext )
1290
1300
emit_zext_32 (rd , ctx );
1291
1301
break ;
1292
1302
case BPF_ALU | BPF_MOD | BPF_K :
1293
1303
case BPF_ALU64 | BPF_MOD | BPF_K :
1294
1304
emit_imm (RV_REG_T1 , imm , ctx );
1295
- emit (is64 ? rv_remu (rd , rd , RV_REG_T1 ) :
1296
- rv_remuw (rd , rd , RV_REG_T1 ), ctx );
1305
+ if (off )
1306
+ emit (is64 ? rv_rem (rd , rd , RV_REG_T1 ) :
1307
+ rv_remw (rd , rd , RV_REG_T1 ), ctx );
1308
+ else
1309
+ emit (is64 ? rv_remu (rd , rd , RV_REG_T1 ) :
1310
+ rv_remuw (rd , rd , RV_REG_T1 ), ctx );
1297
1311
if (!is64 && !aux -> verifier_zext )
1298
1312
emit_zext_32 (rd , ctx );
1299
1313
break ;
0 commit comments