From: Yonghong Song <yhs@meta.com>
To: Nathan Chancellor <nathan@kernel.org>,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>
Cc: "John Fastabend" <john.fastabend@gmail.com>,
"Jiri Olsa" <jolsa@kernel.org>,
"Peter Zijlstra" <peterz@infradead.org>,
"Björn Töpel" <bjorn@kernel.org>,
"Nick Desaulniers" <ndesaulniers@google.com>,
"Tom Rix" <trix@redhat.com>,
bpf@vger.kernel.org, linux-kernel@vger.kernel.org,
llvm@lists.linux.dev, patches@lists.linux.dev,
"kernel test robot" <lkp@intel.com>,
"kernelci.org bot" <bot@kernelci.org>
Subject: Re: [PATCH bpf] bpf: Add explicit cast to 'void *' for __BPF_DISPATCHER_UPDATE()
Date: Mon, 7 Nov 2022 10:45:34 -0800 [thread overview]
Message-ID: <40da21f7-19d7-142f-0380-41abd0d47d1d@meta.com> (raw)
In-Reply-To: <20221107170711.42409-1-nathan@kernel.org>
On 11/7/22 9:07 AM, Nathan Chancellor wrote:
> When building with clang:
>
> kernel/bpf/dispatcher.c:126:33: error: pointer type mismatch ('void *' and 'unsigned int (*)(const void *, const struct bpf_insn *, bpf_func_t)' (aka 'unsigned int (*)(const void *, const struct bpf_insn *, unsigned int (*)(const void *, const struct bpf_insn *))')) [-Werror,-Wpointer-type-mismatch]
> __BPF_DISPATCHER_UPDATE(d, new ?: &bpf_dispatcher_nop_func);
> ~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~
> ./include/linux/bpf.h:1045:54: note: expanded from macro '__BPF_DISPATCHER_UPDATE'
> __static_call_update((_d)->sc_key, (_d)->sc_tramp, (_new))
> ^~~~
> 1 error generated.
>
> The warning is pointing out that the type of new ('void *') and
> &bpf_dispatcher_nop_func are not compatible, which could have side
> effects coming out of a conditional operator due to promotion rules.
>
> Add the explicit cast to 'void *' to make it clear that this is
> expected, as __BPF_DISPATCHER_UPDATE() expands to a call to
> __static_call_update(), which expects a 'void *' as its final argument.
>
> Fixes: c86df29d11df ("bpf: Convert BPF_DISPATCHER to use static_call() (not ftrace)")
> Link: https://github.com/ClangBuiltLinux/linux/issues/1755
> Reported-by: kernel test robot <lkp@intel.com>
> Reported-by: "kernelci.org bot" <bot@kernelci.org>
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Acked-by: Yonghong Song <yhs@fb.com>
next prev parent reply other threads:[~2022-11-07 18:46 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-07 17:07 [PATCH bpf] bpf: Add explicit cast to 'void *' for __BPF_DISPATCHER_UPDATE() Nathan Chancellor
2022-11-07 17:51 ` Björn Töpel
2022-11-07 18:45 ` Yonghong Song [this message]
2022-11-08 0:10 ` patchwork-bot+netdevbpf
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=40da21f7-19d7-142f-0380-41abd0d47d1d@meta.com \
--to=yhs@meta.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bjorn@kernel.org \
--cc=bot@kernelci.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lkp@intel.com \
--cc=llvm@lists.linux.dev \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=patches@lists.linux.dev \
--cc=peterz@infradead.org \
--cc=trix@redhat.com \
/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