Re: [PATCH bpf-next v2 1/2] bpf, mips: Factor out div/mod emission helpers
From: bot+bpf-ci
Date: Wed Jul 29 2026 - 13:24:38 EST
> diff --git a/arch/mips/net/bpf_jit_comp.c b/arch/mips/net/bpf_jit_comp.c
> index 6ee4abe6a1f7..f99bb5705d00 100644
> --- a/arch/mips/net/bpf_jit_comp.c
> +++ b/arch/mips/net/bpf_jit_comp.c
> @@ -338,6 +338,26 @@ void emit_alu_i(struct jit_context *ctx, u8 dst, s32 imm, u8 op)
> clobber_reg(ctx, dst);
> }
>
> +static void emit_div(struct jit_context *ctx, u8 dst, u8 src)
> +{
> + if (cpu_has_mips32r6) {
> + emit(ctx, divu_r6, dst, dst, src);
> + } else {
> + emit(ctx, divu, dst, src);
> + emit(ctx, mflo, dst);
> + }
> +}
> +
> +static void emit_mod(struct jit_context *ctx, u8 dst, u8 src)
> +{
> + if (cpu_has_mips32r6) {
> + emit(ctx, modu, dst, dst, src);
> + } else {
> + emit(ctx, divu, dst, src);
> + emit(ctx, mfhi, dst);
> + }
> +}
This isn't a bug, but would a short header comment on emit_div() and
emit_mod(), in the style of the neighbouring '/* ALU register operation
(32-bit) */', keep these consistent with the rest of the file? Every
other emitter here carries one.
[ ... ]
> diff --git a/arch/mips/net/bpf_jit_comp64.c b/arch/mips/net/bpf_jit_comp64.c
> index fa7e9aa37f49..befeb63ae447 100644
> --- a/arch/mips/net/bpf_jit_comp64.c
> +++ b/arch/mips/net/bpf_jit_comp64.c
> @@ -197,6 +197,26 @@ static void emit_alu_i64(struct jit_context *ctx, u8 dst, s32 imm, u8 op)
> clobber_reg(ctx, dst);
> }
>
> +static void emit_div64(struct jit_context *ctx, u8 dst, u8 src)
> +{
> + if (cpu_has_mips64r6) {
> + emit(ctx, ddivu_r6, dst, dst, src);
> + } else {
> + emit(ctx, ddivu, dst, src);
> + emit(ctx, mflo, dst);
> + }
> +}
> +
> +static void emit_mod64(struct jit_context *ctx, u8 dst, u8 src)
> +{
> + if (cpu_has_mips64r6) {
> + emit(ctx, dmodu, dst, dst, src);
> + } else {
> + emit(ctx, ddivu, dst, src);
> + emit(ctx, mfhi, dst);
> + }
> +}
Same for emit_div64() and emit_mod64() here.
---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md
CI run summary: https://github.com/kernel-patches/bpf/actions/runs/30472129214