mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH bpf-next v1] riscv, bpf: Remove invoke_bpf_mod_ret in code comment
@ 2026-11-30  9:00 Tiezhu Yang
  2026-11-30 11:56 ` Pu Lehui
  0 siblings, 1 reply; 3+ messages in thread
From: Tiezhu Yang @ 2026-11-30  9:00 UTC (permalink / raw)
  To: Björn Töpel, Pu Lehui, Puranjay Mohan
  Cc: linux-riscv, bpf, linux-kernel

There is no function invoke_bpf_mod_ret(), remove it in the code comment
to reflect the reality.

Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---
I guess this is a copy-paste issue from other architectures,
because there was already no invoke_bpf_mod_ret() in the initial
commit 49b5e77ae3e2 ("riscv, bpf: Add bpf trampoline support for RV64"):

$ grep -rn "branches saved in invoke_bpf_mod_ret with" .
./arch/x86/net/bpf_jit_comp.c:4552:		/* Update the branches saved in invoke_bpf_mod_ret with the
./arch/arm64/net/bpf_jit_comp.c:3524:	/* update the branches saved in invoke_bpf_mod_ret with cbnz */
./arch/powerpc/net/bpf_jit_comp.c:1150:	/* Update branches saved in invoke_bpf_mod_ret with address of do_fexit */
./arch/riscv/net/bpf_jit_comp64.c:1300:	/* update branches saved in invoke_bpf_mod_ret with bnez */

 arch/riscv/net/bpf_jit_comp64.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/riscv/net/bpf_jit_comp64.c b/arch/riscv/net/bpf_jit_comp64.c
index a7a7d2f9da85..fb58524cd095 100644
--- a/arch/riscv/net/bpf_jit_comp64.c
+++ b/arch/riscv/net/bpf_jit_comp64.c
@@ -1297,7 +1297,7 @@ static int __arch_prepare_bpf_trampoline(struct bpf_tramp_image *im,
 		emit_sd(RV_REG_FP, -(retval_off - 8), regmap[BPF_REG_0], ctx);
 	}
 
-	/* update branches saved in invoke_bpf_mod_ret with bnez */
+	/* update branches with bnez */
 	for (i = 0; ctx->insns && i < fmod_ret->nr_nodes; i++) {
 		offset = ninsns_rvoff(ctx->ninsns - branches_off[i]);
 		insn = rv_bne(RV_REG_T1, RV_REG_ZERO, offset >> 1);
-- 
2.42.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH bpf-next v1] riscv, bpf: Remove invoke_bpf_mod_ret in code comment
  2026-11-30  9:00 [PATCH bpf-next v1] riscv, bpf: Remove invoke_bpf_mod_ret in code comment Tiezhu Yang
@ 2026-11-30 11:56 ` Pu Lehui
  2026-11-30 12:21   ` Tiezhu Yang
  0 siblings, 1 reply; 3+ messages in thread
From: Pu Lehui @ 2026-11-30 11:56 UTC (permalink / raw)
  To: Tiezhu Yang, Björn Töpel, Puranjay Mohan
  Cc: linux-riscv, bpf, linux-kernel



On 2026/11/30 17:00, Tiezhu Yang wrote:
> There is no function invoke_bpf_mod_ret(), remove it in the code comment
> to reflect the reality.
> 
> Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
> ---
> I guess this is a copy-paste issue from other architectures,
> because there was already no invoke_bpf_mod_ret() in the initial
> commit 49b5e77ae3e2 ("riscv, bpf: Add bpf trampoline support for RV64"):
> 
> $ grep -rn "branches saved in invoke_bpf_mod_ret with" .
> ./arch/x86/net/bpf_jit_comp.c:4552:		/* Update the branches saved in invoke_bpf_mod_ret with the
> ./arch/arm64/net/bpf_jit_comp.c:3524:	/* update the branches saved in invoke_bpf_mod_ret with cbnz */
> ./arch/powerpc/net/bpf_jit_comp.c:1150:	/* Update branches saved in invoke_bpf_mod_ret with address of do_fexit */
> ./arch/riscv/net/bpf_jit_comp64.c:1300:	/* update branches saved in invoke_bpf_mod_ret with bnez */
> 
>   arch/riscv/net/bpf_jit_comp64.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/riscv/net/bpf_jit_comp64.c b/arch/riscv/net/bpf_jit_comp64.c
> index a7a7d2f9da85..fb58524cd095 100644
> --- a/arch/riscv/net/bpf_jit_comp64.c
> +++ b/arch/riscv/net/bpf_jit_comp64.c
> @@ -1297,7 +1297,7 @@ static int __arch_prepare_bpf_trampoline(struct bpf_tramp_image *im,
>   		emit_sd(RV_REG_FP, -(retval_off - 8), regmap[BPF_REG_0], ctx);
>   	}
>   
> -	/* update branches saved in invoke_bpf_mod_ret with bnez */

I think this is a bit vague. How about:
/* patch fmod_ret nops with bnez to skip orig_call */

> +	/* update branches with bnez */
>   	for (i = 0; ctx->insns && i < fmod_ret->nr_nodes; i++) {
>   		offset = ninsns_rvoff(ctx->ninsns - branches_off[i]);
>   		insn = rv_bne(RV_REG_T1, RV_REG_ZERO, offset >> 1);

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH bpf-next v1] riscv, bpf: Remove invoke_bpf_mod_ret in code comment
  2026-11-30 11:56 ` Pu Lehui
@ 2026-11-30 12:21   ` Tiezhu Yang
  0 siblings, 0 replies; 3+ messages in thread
From: Tiezhu Yang @ 2026-11-30 12:21 UTC (permalink / raw)
  To: Pu Lehui, Björn Töpel, Puranjay Mohan
  Cc: linux-riscv, bpf, linux-kernel

On 11/30/26 7:56 PM, Pu Lehui wrote:
> 
> 
> On 2026/11/30 17:00, Tiezhu Yang wrote:
>> There is no function invoke_bpf_mod_ret(), remove it in the code comment
>> to reflect the reality.
>>
>> Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
>> ---
>> I guess this is a copy-paste issue from other architectures,
>> because there was already no invoke_bpf_mod_ret() in the initial
>> commit 49b5e77ae3e2 ("riscv, bpf: Add bpf trampoline support for RV64"):
>>
>> $ grep -rn "branches saved in invoke_bpf_mod_ret with" .
>> ./arch/x86/net/bpf_jit_comp.c:4552:        /* Update the branches 
>> saved in invoke_bpf_mod_ret with the
>> ./arch/arm64/net/bpf_jit_comp.c:3524:    /* update the branches saved 
>> in invoke_bpf_mod_ret with cbnz */
>> ./arch/powerpc/net/bpf_jit_comp.c:1150:    /* Update branches saved in 
>> invoke_bpf_mod_ret with address of do_fexit */
>> ./arch/riscv/net/bpf_jit_comp64.c:1300:    /* update branches saved in 
>> invoke_bpf_mod_ret with bnez */
>>
>>   arch/riscv/net/bpf_jit_comp64.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/arch/riscv/net/bpf_jit_comp64.c 
>> b/arch/riscv/net/bpf_jit_comp64.c
>> index a7a7d2f9da85..fb58524cd095 100644
>> --- a/arch/riscv/net/bpf_jit_comp64.c
>> +++ b/arch/riscv/net/bpf_jit_comp64.c
>> @@ -1297,7 +1297,7 @@ static int __arch_prepare_bpf_trampoline(struct 
>> bpf_tramp_image *im,
>>           emit_sd(RV_REG_FP, -(retval_off - 8), regmap[BPF_REG_0], ctx);
>>       }
>> -    /* update branches saved in invoke_bpf_mod_ret with bnez */
> 
> I think this is a bit vague. How about:
> /* patch fmod_ret nops with bnez to skip orig_call */
> 
>> +    /* update branches with bnez */
>>       for (i = 0; ctx->insns && i < fmod_ret->nr_nodes; i++) {
>>           offset = ninsns_rvoff(ctx->ninsns - branches_off[i]);
>>           insn = rv_bne(RV_REG_T1, RV_REG_ZERO, offset >> 1);

The reason I wrote
/* update branches with bnez */
is to keep it symmetric with the earlier comment
/* update branch with beqz */
in invoke_bpf_prog(), and also consistent with the LoongArch
BPF JIT implementation (arch/loongarch/net/bpf_jit.c), which
uses the exact same phrasing in both places.

Also, branches_off[] is populated right above this loop with
the comment /* nop reserved for conditional jump */, so the
context is quite close and clear here.

I am fine with either way, let's see what Björn and Puranjay
think, and I can send a v2 if the more descriptive comment is
preferred.

Thanks,
Tiezhu


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-30 12:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-30  9:00 [PATCH bpf-next v1] riscv, bpf: Remove invoke_bpf_mod_ret in code comment Tiezhu Yang
2026-11-30 11:56 ` Pu Lehui
2026-11-30 12:21   ` Tiezhu Yang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®