* [PATCH bpf] bpf: Make CONFIG_DEBUG_INFO_BTF depend upon CONFIG_BPF_SYSCALL
@ 2021-11-12 1:59 Kumar Kartikeya Dwivedi
2021-11-12 3:42 ` kernel test robot
2021-11-12 6:18 ` kernel test robot
0 siblings, 2 replies; 3+ messages in thread
From: Kumar Kartikeya Dwivedi @ 2021-11-12 1:59 UTC (permalink / raw)
To: bpf
Cc: Vinicius Costa Gomes, Alexei Starovoitov, Andrii Nakryiko,
Daniel Borkmann, Martin KaFai Lau, Song Liu, Yonghong Song
Vinicius Costa Gomes reported [0] that build fails when
CONFIG_DEBUG_INFO_BTF is enabled and CONFIG_BPF_SYSCALL is disabled.
This leads to btf.c not being compiled, and then no symbol being present
in vmlinux for the declarations in btf.h. Since BTF is not useful
without enabling BPF subsystem, disallow this combination.
However, theoretically disabling both now could still fail, as the
symbol for kfunc_btf_id_list variables is not available. This isn't a
problem as the compiler usually optimizes the whole register/unregister
call, but at lower optimization levels it can fail the build in linking
stage.
Fix that by adding dummy variables so that modules taking address of
them still work, but the whole thing is a noop.
[0]: https://lore.kernel.org/bpf/20211110205418.332403-1-vinicius.gomes@intel.com
Fixes: 14f267d95fe4 ("bpf: btf: Introduce helpers for dynamic BTF set registration")
Reported-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
---
include/linux/btf.h | 10 +++++++---
lib/Kconfig.debug | 1 +
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/include/linux/btf.h b/include/linux/btf.h
index 203eef993d76..db935b9a0074 100644
--- a/include/linux/btf.h
+++ b/include/linux/btf.h
@@ -254,6 +254,9 @@ void unregister_kfunc_btf_id_set(struct kfunc_btf_id_list *l,
struct kfunc_btf_id_set *s);
bool bpf_check_mod_kfunc_call(struct kfunc_btf_id_list *klist, u32 kfunc_id,
struct module *owner);
+
+extern struct kfunc_btf_id_list bpf_tcp_ca_kfunc_list;
+extern struct kfunc_btf_id_list prog_test_kfunc_list;
#else
static inline void register_kfunc_btf_id_set(struct kfunc_btf_id_list *l,
struct kfunc_btf_id_set *s)
@@ -268,13 +271,14 @@ static inline bool bpf_check_mod_kfunc_call(struct kfunc_btf_id_list *klist,
{
return false;
}
+
+struct kfunc_btf_id_list {};
+static struct kfunc_btf_id_list bpf_tcp_ca_kfunc_list __maybe_unused;
+static struct kfunc_btf_id_list prog_test_kfunc_list __maybe_unused;
#endif
#define DEFINE_KFUNC_BTF_ID_SET(set, name) \
struct kfunc_btf_id_set name = { LIST_HEAD_INIT(name.list), (set), \
THIS_MODULE }
-extern struct kfunc_btf_id_list bpf_tcp_ca_kfunc_list;
-extern struct kfunc_btf_id_list prog_test_kfunc_list;
-
#endif
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 6fdbf9613aec..eae860c86e26 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -316,6 +316,7 @@ config DEBUG_INFO_BTF
bool "Generate BTF typeinfo"
depends on !DEBUG_INFO_SPLIT && !DEBUG_INFO_REDUCED
depends on !GCC_PLUGIN_RANDSTRUCT || COMPILE_TEST
+ depends on BPF_SYSCALL
help
Generate deduplicated BTF type information from DWARF debug info.
Turning this on expects presence of pahole tool, which will convert
--
2.33.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH bpf] bpf: Make CONFIG_DEBUG_INFO_BTF depend upon CONFIG_BPF_SYSCALL
2021-11-12 1:59 [PATCH bpf] bpf: Make CONFIG_DEBUG_INFO_BTF depend upon CONFIG_BPF_SYSCALL Kumar Kartikeya Dwivedi
@ 2021-11-12 3:42 ` kernel test robot
2021-11-12 6:18 ` kernel test robot
1 sibling, 0 replies; 3+ messages in thread
From: kernel test robot @ 2021-11-12 3:42 UTC (permalink / raw)
To: Kumar Kartikeya Dwivedi, bpf
Cc: kbuild-all, Vinicius Costa Gomes, Alexei Starovoitov,
Andrii Nakryiko, Daniel Borkmann, Martin KaFai Lau, Song Liu,
Yonghong Song
[-- Attachment #1: Type: text/plain, Size: 8628 bytes --]
Hi Kumar,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on bpf/master]
url: https://github.com/0day-ci/linux/commits/Kumar-Kartikeya-Dwivedi/bpf-Make-CONFIG_DEBUG_INFO_BTF-depend-upon-CONFIG_BPF_SYSCALL/20211112-100114
base: https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf.git master
config: openrisc-buildonly-randconfig-r003-20211111 (attached as .config)
compiler: or1k-linux-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/ea181ce7046ae7f916b4ede6b04c48416d89b0b2
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Kumar-Kartikeya-Dwivedi/bpf-Make-CONFIG_DEBUG_INFO_BTF-depend-upon-CONFIG_BPF_SYSCALL/20211112-100114
git checkout ea181ce7046ae7f916b4ede6b04c48416d89b0b2
# save the attached .config to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=openrisc SHELL=/bin/bash kernel/bpf/
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
All errors (new ones prefixed by >>):
kernel/bpf/btf.c: In function 'btf_seq_show':
kernel/bpf/btf.c:5876:29: error: function 'btf_seq_show' might be a candidate for 'gnu_printf' format attribute [-Werror=suggest-attribute=format]
5876 | seq_vprintf((struct seq_file *)show->target, fmt, args);
| ^~~~~~~~
kernel/bpf/btf.c: In function 'btf_snprintf_show':
kernel/bpf/btf.c:5913:9: error: function 'btf_snprintf_show' might be a candidate for 'gnu_printf' format attribute [-Werror=suggest-attribute=format]
5913 | len = vsnprintf(show->target, ssnprintf->len_left, fmt, args);
| ^~~
kernel/bpf/btf.c: At top level:
>> kernel/bpf/btf.c:6349:8: error: redefinition of 'struct kfunc_btf_id_list'
6349 | struct kfunc_btf_id_list {
| ^~~~~~~~~~~~~~~~~
In file included from include/linux/bpf_verifier.h:8,
from kernel/bpf/btf.c:19:
include/linux/btf.h:275:8: note: originally defined here
275 | struct kfunc_btf_id_list {};
| ^~~~~~~~~~~~~~~~~
>> kernel/bpf/btf.c:6399:26: error: conflicting types for 'bpf_tcp_ca_kfunc_list'; have 'struct kfunc_btf_id_list'
6399 | DEFINE_KFUNC_BTF_ID_LIST(bpf_tcp_ca_kfunc_list);
| ^~~~~~~~~~~~~~~~~~~~~
kernel/bpf/btf.c:6395:34: note: in definition of macro 'DEFINE_KFUNC_BTF_ID_LIST'
6395 | struct kfunc_btf_id_list name = { LIST_HEAD_INIT(name.list), \
| ^~~~
In file included from include/linux/bpf_verifier.h:8,
from kernel/bpf/btf.c:19:
include/linux/btf.h:276:33: note: previous declaration of 'bpf_tcp_ca_kfunc_list' with type 'struct kfunc_btf_id_list'
276 | static struct kfunc_btf_id_list bpf_tcp_ca_kfunc_list __maybe_unused;
| ^~~~~~~~~~~~~~~~~~~~~
>> kernel/bpf/btf.c:6400:26: error: conflicting types for 'prog_test_kfunc_list'; have 'struct kfunc_btf_id_list'
6400 | DEFINE_KFUNC_BTF_ID_LIST(prog_test_kfunc_list);
| ^~~~~~~~~~~~~~~~~~~~
kernel/bpf/btf.c:6395:34: note: in definition of macro 'DEFINE_KFUNC_BTF_ID_LIST'
6395 | struct kfunc_btf_id_list name = { LIST_HEAD_INIT(name.list), \
| ^~~~
In file included from include/linux/bpf_verifier.h:8,
from kernel/bpf/btf.c:19:
include/linux/btf.h:277:33: note: previous declaration of 'prog_test_kfunc_list' with type 'struct kfunc_btf_id_list'
277 | static struct kfunc_btf_id_list prog_test_kfunc_list __maybe_unused;
| ^~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
vim +6349 kernel/bpf/btf.c
14f267d95fe4b08 Kumar Kartikeya Dwivedi 2021-10-02 6348
14f267d95fe4b08 Kumar Kartikeya Dwivedi 2021-10-02 @6349 struct kfunc_btf_id_list {
14f267d95fe4b08 Kumar Kartikeya Dwivedi 2021-10-02 6350 struct list_head list;
14f267d95fe4b08 Kumar Kartikeya Dwivedi 2021-10-02 6351 struct mutex mutex;
14f267d95fe4b08 Kumar Kartikeya Dwivedi 2021-10-02 6352 };
14f267d95fe4b08 Kumar Kartikeya Dwivedi 2021-10-02 6353
14f267d95fe4b08 Kumar Kartikeya Dwivedi 2021-10-02 6354 #ifdef CONFIG_DEBUG_INFO_BTF_MODULES
14f267d95fe4b08 Kumar Kartikeya Dwivedi 2021-10-02 6355
14f267d95fe4b08 Kumar Kartikeya Dwivedi 2021-10-02 6356 void register_kfunc_btf_id_set(struct kfunc_btf_id_list *l,
14f267d95fe4b08 Kumar Kartikeya Dwivedi 2021-10-02 6357 struct kfunc_btf_id_set *s)
14f267d95fe4b08 Kumar Kartikeya Dwivedi 2021-10-02 6358 {
14f267d95fe4b08 Kumar Kartikeya Dwivedi 2021-10-02 6359 mutex_lock(&l->mutex);
14f267d95fe4b08 Kumar Kartikeya Dwivedi 2021-10-02 6360 list_add(&s->list, &l->list);
14f267d95fe4b08 Kumar Kartikeya Dwivedi 2021-10-02 6361 mutex_unlock(&l->mutex);
14f267d95fe4b08 Kumar Kartikeya Dwivedi 2021-10-02 6362 }
14f267d95fe4b08 Kumar Kartikeya Dwivedi 2021-10-02 6363 EXPORT_SYMBOL_GPL(register_kfunc_btf_id_set);
14f267d95fe4b08 Kumar Kartikeya Dwivedi 2021-10-02 6364
14f267d95fe4b08 Kumar Kartikeya Dwivedi 2021-10-02 6365 void unregister_kfunc_btf_id_set(struct kfunc_btf_id_list *l,
14f267d95fe4b08 Kumar Kartikeya Dwivedi 2021-10-02 6366 struct kfunc_btf_id_set *s)
14f267d95fe4b08 Kumar Kartikeya Dwivedi 2021-10-02 6367 {
14f267d95fe4b08 Kumar Kartikeya Dwivedi 2021-10-02 6368 mutex_lock(&l->mutex);
14f267d95fe4b08 Kumar Kartikeya Dwivedi 2021-10-02 6369 list_del_init(&s->list);
14f267d95fe4b08 Kumar Kartikeya Dwivedi 2021-10-02 6370 mutex_unlock(&l->mutex);
14f267d95fe4b08 Kumar Kartikeya Dwivedi 2021-10-02 6371 }
14f267d95fe4b08 Kumar Kartikeya Dwivedi 2021-10-02 6372 EXPORT_SYMBOL_GPL(unregister_kfunc_btf_id_set);
14f267d95fe4b08 Kumar Kartikeya Dwivedi 2021-10-02 6373
14f267d95fe4b08 Kumar Kartikeya Dwivedi 2021-10-02 6374 bool bpf_check_mod_kfunc_call(struct kfunc_btf_id_list *klist, u32 kfunc_id,
14f267d95fe4b08 Kumar Kartikeya Dwivedi 2021-10-02 6375 struct module *owner)
14f267d95fe4b08 Kumar Kartikeya Dwivedi 2021-10-02 6376 {
14f267d95fe4b08 Kumar Kartikeya Dwivedi 2021-10-02 6377 struct kfunc_btf_id_set *s;
14f267d95fe4b08 Kumar Kartikeya Dwivedi 2021-10-02 6378
14f267d95fe4b08 Kumar Kartikeya Dwivedi 2021-10-02 6379 if (!owner)
14f267d95fe4b08 Kumar Kartikeya Dwivedi 2021-10-02 6380 return false;
14f267d95fe4b08 Kumar Kartikeya Dwivedi 2021-10-02 6381 mutex_lock(&klist->mutex);
14f267d95fe4b08 Kumar Kartikeya Dwivedi 2021-10-02 6382 list_for_each_entry(s, &klist->list, list) {
14f267d95fe4b08 Kumar Kartikeya Dwivedi 2021-10-02 6383 if (s->owner == owner && btf_id_set_contains(s->set, kfunc_id)) {
14f267d95fe4b08 Kumar Kartikeya Dwivedi 2021-10-02 6384 mutex_unlock(&klist->mutex);
14f267d95fe4b08 Kumar Kartikeya Dwivedi 2021-10-02 6385 return true;
14f267d95fe4b08 Kumar Kartikeya Dwivedi 2021-10-02 6386 }
14f267d95fe4b08 Kumar Kartikeya Dwivedi 2021-10-02 6387 }
14f267d95fe4b08 Kumar Kartikeya Dwivedi 2021-10-02 6388 mutex_unlock(&klist->mutex);
14f267d95fe4b08 Kumar Kartikeya Dwivedi 2021-10-02 6389 return false;
14f267d95fe4b08 Kumar Kartikeya Dwivedi 2021-10-02 6390 }
14f267d95fe4b08 Kumar Kartikeya Dwivedi 2021-10-02 6391
14f267d95fe4b08 Kumar Kartikeya Dwivedi 2021-10-02 6392 #endif
14f267d95fe4b08 Kumar Kartikeya Dwivedi 2021-10-02 6393
14f267d95fe4b08 Kumar Kartikeya Dwivedi 2021-10-02 6394 #define DEFINE_KFUNC_BTF_ID_LIST(name) \
14f267d95fe4b08 Kumar Kartikeya Dwivedi 2021-10-02 6395 struct kfunc_btf_id_list name = { LIST_HEAD_INIT(name.list), \
14f267d95fe4b08 Kumar Kartikeya Dwivedi 2021-10-02 6396 __MUTEX_INITIALIZER(name.mutex) }; \
14f267d95fe4b08 Kumar Kartikeya Dwivedi 2021-10-02 6397 EXPORT_SYMBOL_GPL(name)
0e32dfc80bae53b Kumar Kartikeya Dwivedi 2021-10-02 6398
0e32dfc80bae53b Kumar Kartikeya Dwivedi 2021-10-02 @6399 DEFINE_KFUNC_BTF_ID_LIST(bpf_tcp_ca_kfunc_list);
c48e51c8b07aba8 Kumar Kartikeya Dwivedi 2021-10-02 @6400 DEFINE_KFUNC_BTF_ID_LIST(prog_test_kfunc_list);
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 23077 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH bpf] bpf: Make CONFIG_DEBUG_INFO_BTF depend upon CONFIG_BPF_SYSCALL
2021-11-12 1:59 [PATCH bpf] bpf: Make CONFIG_DEBUG_INFO_BTF depend upon CONFIG_BPF_SYSCALL Kumar Kartikeya Dwivedi
2021-11-12 3:42 ` kernel test robot
@ 2021-11-12 6:18 ` kernel test robot
1 sibling, 0 replies; 3+ messages in thread
From: kernel test robot @ 2021-11-12 6:18 UTC (permalink / raw)
To: Kumar Kartikeya Dwivedi, bpf
Cc: kbuild-all, Vinicius Costa Gomes, Alexei Starovoitov,
Andrii Nakryiko, Daniel Borkmann, Martin KaFai Lau, Song Liu,
Yonghong Song
[-- Attachment #1: Type: text/plain, Size: 4577 bytes --]
Hi Kumar,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on bpf/master]
url: https://github.com/0day-ci/linux/commits/Kumar-Kartikeya-Dwivedi/bpf-Make-CONFIG_DEBUG_INFO_BTF-depend-upon-CONFIG_BPF_SYSCALL/20211112-100114
base: https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf.git master
config: i386-debian-10.3 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce (this is a W=1 build):
# https://github.com/0day-ci/linux/commit/ea181ce7046ae7f916b4ede6b04c48416d89b0b2
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Kumar-Kartikeya-Dwivedi/bpf-Make-CONFIG_DEBUG_INFO_BTF-depend-upon-CONFIG_BPF_SYSCALL/20211112-100114
git checkout ea181ce7046ae7f916b4ede6b04c48416d89b0b2
# save the attached .config to linux build tree
mkdir build_dir
make W=1 O=build_dir ARCH=i386 SHELL=/bin/bash
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
All errors (new ones prefixed by >>):
kernel/bpf/btf.c: In function 'btf_seq_show':
kernel/bpf/btf.c:5876:22: warning: function 'btf_seq_show' might be a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format]
5876 | seq_vprintf((struct seq_file *)show->target, fmt, args);
| ^~~~~~~~
kernel/bpf/btf.c: In function 'btf_snprintf_show':
kernel/bpf/btf.c:5913:2: warning: function 'btf_snprintf_show' might be a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format]
5913 | len = vsnprintf(show->target, ssnprintf->len_left, fmt, args);
| ^~~
kernel/bpf/btf.c: At top level:
kernel/bpf/btf.c:6349:8: error: redefinition of 'struct kfunc_btf_id_list'
6349 | struct kfunc_btf_id_list {
| ^~~~~~~~~~~~~~~~~
In file included from include/linux/bpf_verifier.h:8,
from kernel/bpf/btf.c:19:
include/linux/btf.h:275:8: note: originally defined here
275 | struct kfunc_btf_id_list {};
| ^~~~~~~~~~~~~~~~~
>> kernel/bpf/btf.c:6399:26: error: conflicting types for 'bpf_tcp_ca_kfunc_list'
6399 | DEFINE_KFUNC_BTF_ID_LIST(bpf_tcp_ca_kfunc_list);
| ^~~~~~~~~~~~~~~~~~~~~
kernel/bpf/btf.c:6395:27: note: in definition of macro 'DEFINE_KFUNC_BTF_ID_LIST'
6395 | struct kfunc_btf_id_list name = { LIST_HEAD_INIT(name.list), \
| ^~~~
In file included from include/linux/bpf_verifier.h:8,
from kernel/bpf/btf.c:19:
include/linux/btf.h:276:33: note: previous declaration of 'bpf_tcp_ca_kfunc_list' was here
276 | static struct kfunc_btf_id_list bpf_tcp_ca_kfunc_list __maybe_unused;
| ^~~~~~~~~~~~~~~~~~~~~
>> kernel/bpf/btf.c:6400:26: error: conflicting types for 'prog_test_kfunc_list'
6400 | DEFINE_KFUNC_BTF_ID_LIST(prog_test_kfunc_list);
| ^~~~~~~~~~~~~~~~~~~~
kernel/bpf/btf.c:6395:27: note: in definition of macro 'DEFINE_KFUNC_BTF_ID_LIST'
6395 | struct kfunc_btf_id_list name = { LIST_HEAD_INIT(name.list), \
| ^~~~
In file included from include/linux/bpf_verifier.h:8,
from kernel/bpf/btf.c:19:
include/linux/btf.h:277:33: note: previous declaration of 'prog_test_kfunc_list' was here
277 | static struct kfunc_btf_id_list prog_test_kfunc_list __maybe_unused;
| ^~~~~~~~~~~~~~~~~~~~
vim +/bpf_tcp_ca_kfunc_list +6399 kernel/bpf/btf.c
14f267d95fe4b0 Kumar Kartikeya Dwivedi 2021-10-02 6393
14f267d95fe4b0 Kumar Kartikeya Dwivedi 2021-10-02 6394 #define DEFINE_KFUNC_BTF_ID_LIST(name) \
14f267d95fe4b0 Kumar Kartikeya Dwivedi 2021-10-02 6395 struct kfunc_btf_id_list name = { LIST_HEAD_INIT(name.list), \
14f267d95fe4b0 Kumar Kartikeya Dwivedi 2021-10-02 6396 __MUTEX_INITIALIZER(name.mutex) }; \
14f267d95fe4b0 Kumar Kartikeya Dwivedi 2021-10-02 6397 EXPORT_SYMBOL_GPL(name)
0e32dfc80bae53 Kumar Kartikeya Dwivedi 2021-10-02 6398
0e32dfc80bae53 Kumar Kartikeya Dwivedi 2021-10-02 @6399 DEFINE_KFUNC_BTF_ID_LIST(bpf_tcp_ca_kfunc_list);
c48e51c8b07aba Kumar Kartikeya Dwivedi 2021-10-02 @6400 DEFINE_KFUNC_BTF_ID_LIST(prog_test_kfunc_list);
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 34176 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-11-12 6:19 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-11-12 1:59 [PATCH bpf] bpf: Make CONFIG_DEBUG_INFO_BTF depend upon CONFIG_BPF_SYSCALL Kumar Kartikeya Dwivedi
2021-11-12 3:42 ` kernel test robot
2021-11-12 6:18 ` kernel test robot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox