bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Huacai Chen <chenhuacai@gmail.com>
To: Tiezhu Yang <yangtiezhu@loongson.cn>
Cc: Huacai Chen <chenhuacai@loongson.cn>,
	Alexei Starovoitov <ast@kernel.org>,
	 Daniel Borkmann <daniel@iogearbox.net>,
	John Fastabend <john.fastabend@gmail.com>,
	bpf@vger.kernel.org,  Hengqi Chen <hengqi.chen@gmail.com>,
	George Guo <guodongtai@kylinos.cn>,
	 Chenghao Duan <duanchenghao@kylinos.cn>,
	loongarch@lists.linux.dev,  kernel test robot <lkp@intel.com>,
	Dan Carpenter <dan.carpenter@linaro.org>
Subject: Re: [PATCH] LoongArch: BPF: Fix uninitialized symbol 'retval_off'
Date: Tue, 26 Aug 2025 16:40:21 +0800	[thread overview]
Message-ID: <CAAhV-H7UnPBpa7jK4WwqQJGnAP+cnsoggxkt1T3spoed4OfkTw@mail.gmail.com> (raw)
In-Reply-To: <1378057e-4fc1-2bcd-4d60-1a10bd98e5bb@loongson.cn>

On Tue, Aug 26, 2025 at 3:08 PM Tiezhu Yang <yangtiezhu@loongson.cn> wrote:
>
> On 2025/8/19 下午7:19, Huacai Chen wrote:
> > In __arch_prepare_bpf_trampoline(), retval_off is meaningful only when
> > save_ret is not 0, so the current logic is correct. But it may cause a
> > build warning:
> >
> > arch/loongarch/net/bpf_jit.c:1547 __arch_prepare_bpf_trampoline() error: uninitialized symbol 'retval_off'.
> >
> > So initialize retval_off unconditionally to fix it.
> >
> > Fixes: f9b6b41f0cf3 ("LoongArch: BPF: Add basic bpf trampoline support")
> > Closes: https://lore.kernel.org/r/202508191020.PBBh07cK-lkp@intel.com/
> > Reported-by: kernel test robot <lkp@intel.com>
> > Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
> > Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
> > ---
> >   arch/loongarch/net/bpf_jit.c | 9 ++++-----
> >   1 file changed, 4 insertions(+), 5 deletions(-)
> >
> > diff --git a/arch/loongarch/net/bpf_jit.c b/arch/loongarch/net/bpf_jit.c
> > index abfdb6bb5c38..a73f6ea4ed4a 100644
> > --- a/arch/loongarch/net/bpf_jit.c
> > +++ b/arch/loongarch/net/bpf_jit.c
> > @@ -1504,11 +1504,10 @@ static int __arch_prepare_bpf_trampoline(struct jit_ctx *ctx, struct bpf_tramp_i
> >       stack_size += 16;
> >
> >       save_ret = flags & (BPF_TRAMP_F_CALL_ORIG | BPF_TRAMP_F_RET_FENTRY_RET);
> > -     if (save_ret) {
> > -             /* Save BPF R0 and A0 */
> > -             stack_size += 16;
> > -             retval_off = stack_size;
> > -     }
> > +     if (save_ret)
> > +             stack_size += 16; /* Save BPF R0 and A0 */
> > +
> > +     retval_off = stack_size;
>
> Just init retval_off as 0 at the beginning of this function?
> What is the difference? which is better?
This patch is more like ARM64 does.

In addition, if save_ret is true, "init retval_off as 0" causes
retval_off to be evaluated twice, while this patch is only evaluated
once. But surely this is not a big deal.

Huacai

>
> Thanks,
> Tiezhu
>

  reply	other threads:[~2025-08-26  8:40 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-19 11:19 [PATCH] LoongArch: BPF: Fix uninitialized symbol 'retval_off' Huacai Chen
2025-08-22 18:43 ` Andrii Nakryiko
2025-08-23  4:10   ` Huacai Chen
2025-08-26  7:07 ` Tiezhu Yang
2025-08-26  8:40   ` Huacai Chen [this message]
2025-08-26  9:41 ` Dan Carpenter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAAhV-H7UnPBpa7jK4WwqQJGnAP+cnsoggxkt1T3spoed4OfkTw@mail.gmail.com \
    --to=chenhuacai@gmail.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=chenhuacai@loongson.cn \
    --cc=dan.carpenter@linaro.org \
    --cc=daniel@iogearbox.net \
    --cc=duanchenghao@kylinos.cn \
    --cc=guodongtai@kylinos.cn \
    --cc=hengqi.chen@gmail.com \
    --cc=john.fastabend@gmail.com \
    --cc=lkp@intel.com \
    --cc=loongarch@lists.linux.dev \
    --cc=yangtiezhu@loongson.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).