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: Wed, 20 Aug 2025 17:26:28 +0800 [thread overview]
Message-ID: <20250820092628.GA1289807@chenghao-pc> (raw)
In-Reply-To: <8b836b6e-103a-41c2-b111-0417d8db4dce@huawei.com>
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
>
> 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
> > 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;
WARNING: multiple messages have this Message-ID (diff)
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: Wed, 20 Aug 2025 17:26:28 +0800 [thread overview]
Message-ID: <20250820092628.GA1289807@chenghao-pc> (raw)
In-Reply-To: <8b836b6e-103a-41c2-b111-0417d8db4dce@huawei.com>
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
>
> 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
> > 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;
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
next prev parent reply other threads:[~2025-08-20 9:26 UTC|newest]
Thread overview: 14+ 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:25 ` Chenghao Duan
2025-08-20 6:52 ` Pu Lehui
2025-08-20 6:52 ` Pu Lehui
2025-08-20 9:26 ` Chenghao Duan [this message]
2025-08-20 9:26 ` Chenghao Duan
2025-08-20 10:10 ` Pu Lehui
2025-08-20 10:10 ` Pu Lehui
2025-08-20 10:35 ` Chenghao Duan
2025-08-20 10:35 ` Chenghao Duan
2025-08-21 1:58 ` Pu Lehui
2025-08-21 1:58 ` Pu Lehui
2025-08-21 2:55 ` Chenghao Duan
2025-08-21 2:55 ` Chenghao Duan
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=20250820092628.GA1289807@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.