From: Chenghao Duan <duanchenghao@kylinos.cn>
To: Pu Lehui <pulehui@huawei.com>
Cc: ast@kernel.org, bjorn@kernel.org, puranjay@kernel.org,
paul.walmsley@sifive.com, palmer@dabbelt.com,
aou@eecs.berkeley.edu, daniel@iogearbox.net, andrii@kernel.org,
martin.lau@linux.dev, eddyz87@gmail.com, song@kernel.org,
yonghong.song@linux.dev, john.fastabend@gmail.com,
kpsingh@kernel.org, sdf@fomichev.me, haoluo@google.com,
jolsa@kernel.org, alex@ghiti.fr, bpf@vger.kernel.org,
linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] riscv: bpf: Fix uninitialized symbol 'retval_off'
Date: Thu, 21 Aug 2025 10:55:32 +0800 [thread overview]
Message-ID: <20250821025532.GA287128@chenghao-pc> (raw)
In-Reply-To: <9cbdefd6-a757-44b3-a1db-69ca8117aacb@huawei.com>
On Thu, Aug 21, 2025 at 09:58:20AM +0800, Pu Lehui wrote:
>
>
> On 2025/8/20 18:35, Chenghao Duan wrote:
> > On Wed, Aug 20, 2025 at 06:10:07PM +0800, Pu Lehui wrote:
> > >
> > >
> > > On 2025/8/20 17:26, Chenghao Duan wrote:
> > > > On Wed, Aug 20, 2025 at 02:52:01PM +0800, Pu Lehui wrote:
> > > > >
> > > > >
> > > > > On 2025/8/20 14:25, Chenghao Duan wrote:
> > > > > > In __arch_prepare_bpf_trampoline(), retval_off is only meaningful when
> > > > > > save_ret is true, so the current logic is correct. However, in the
>
> OK, I think we should make commit msg more explicit. Such like the follow.
> wdyt?
>
> `However, in the fmod_ret logic, the compiler is not aware that the flags of
> the fmod_ret prog have set BPF_TRAMP_F_CALL_ORIG, resulting in an
> uninitialized symbol compilation warning.`
>
Good idea
> > > > >
> > > > > lgtm, and same for `ip_off`, pls patch it together.
> > > >
> > > > I also checked at the time that ip_off is only initialized and assigned
> > > > when flags & BPF_TRAMP_F_IP_ARG is true. However, I noticed that the use
> > > > of ip_off also requires this condition, so the compiler did not issue a
> > > > warning.
> > > >
> > > > Chenghao
> > > >
> > > > >
> > > > > > original logic, retval_off is only initialized under certain
> > >
> > > Can you show how to replay this warning? I guess the warning path is as
> > > follow. Compiler didn't know fmod_ret prog need BPF_TRAMP_F_CALL_ORIG.
> > >
> > > ```
> > > if (fmod_ret->nr_links) {
> > > ...
> > > emit_sd(RV_REG_FP, -retval_off, RV_REG_ZERO, ctx);
> > > }
> > > ```
> > >
> >
> > Exactly, the compiler sees the unconditional use of retval_off.
> >
> > Chenghao
> >
> > > > > > conditions, which may cause a build warning.
> > > > > >
> > > > > > So initialize retval_off unconditionally to fix it.
> > > > > >
> > > > > > Signed-off-by: Chenghao Duan <duanchenghao@kylinos.cn>
> > > > > > ---
> > > > > > arch/riscv/net/bpf_jit_comp64.c | 5 ++---
> > > > > > 1 file changed, 2 insertions(+), 3 deletions(-)
> > > > > >
> > > > > > diff --git a/arch/riscv/net/bpf_jit_comp64.c b/arch/riscv/net/bpf_jit_comp64.c
> > > > > > index 10e01ff06312..49bbda8372b0 100644
> > > > > > --- a/arch/riscv/net/bpf_jit_comp64.c
> > > > > > +++ b/arch/riscv/net/bpf_jit_comp64.c
> > > > > > @@ -1079,10 +1079,9 @@ static int __arch_prepare_bpf_trampoline(struct bpf_tramp_image *im,
> > > > > > stack_size += 16;
> > > > > > save_ret = flags & (BPF_TRAMP_F_CALL_ORIG | BPF_TRAMP_F_RET_FENTRY_RET);
> > > > > > - if (save_ret) {
> > > > > > + if (save_ret)
> > > > > > stack_size += 16; /* Save both A5 (BPF R0) and A0 */
> > > > > > - retval_off = stack_size;
> > > > > > - }
> > > > > > + retval_off = stack_size;
> > > > > > stack_size += nr_arg_slots * 8;
> > > > > > args_off = stack_size;
prev parent reply other threads:[~2025-08-21 2:55 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-20 6:25 [PATCH] riscv: bpf: Fix uninitialized symbol 'retval_off' Chenghao Duan
2025-08-20 6:52 ` Pu Lehui
2025-08-20 9:26 ` Chenghao Duan
2025-08-20 10:10 ` Pu Lehui
2025-08-20 10:35 ` Chenghao Duan
2025-08-21 1:58 ` Pu Lehui
2025-08-21 2:55 ` Chenghao Duan [this message]
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=20250821025532.GA287128@chenghao-pc \
--to=duanchenghao@kylinos.cn \
--cc=alex@ghiti.fr \
--cc=andrii@kernel.org \
--cc=aou@eecs.berkeley.edu \
--cc=ast@kernel.org \
--cc=bjorn@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=haoluo@google.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kpsingh@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=martin.lau@linux.dev \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.com \
--cc=pulehui@huawei.com \
--cc=puranjay@kernel.org \
--cc=sdf@fomichev.me \
--cc=song@kernel.org \
--cc=yonghong.song@linux.dev \
/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).