[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAEf4BzZzi8CJ=YWxcqVwQLu6uJvz556qZcryOjhWD59m1q9yCQ@mail.gmail.com>
Date: Thu, 18 Jun 2020 10:51:25 -0700
From: Andrii Nakryiko <andrii.nakryiko@...il.com>
To: Hao Luo <haoluo@...gle.com>
Cc: Andrii Nakryiko <andriin@...com>, bpf <bpf@...r.kernel.org>,
Networking <netdev@...r.kernel.org>,
Alexei Starovoitov <ast@...com>,
Daniel Borkmann <daniel@...earbox.net>,
Kernel Team <kernel-team@...com>,
Arnaldo Carvalho de Melo <acme@...nel.org>,
Song Liu <songliubraving@...com>,
Quentin Monnet <quentin@...valent.com>
Subject: Re: [PATCH bpf-next 1/9] libbpf: generalize libbpf externs support
On Thu, Jun 18, 2020 at 12:38 AM Hao Luo <haoluo@...gle.com> wrote:
>
> On Wed, Jun 17, 2020 at 9:21 AM Andrii Nakryiko <andriin@...com> wrote:
> >
> > Switch existing Kconfig externs to be just one of few possible kinds of more
> > generic externs. This refactoring is in preparation for ksymbol extern
> > support, added in the follow up patch. There are no functional changes
> > intended.
> >
> > Signed-off-by: Andrii Nakryiko <andriin@...com>
> > ---
>
> [...]
>
> > @@ -5572,30 +5635,33 @@ static int bpf_object__resolve_externs(struct bpf_object *obj,
> > {
> > bool need_config = false;
> > struct extern_desc *ext;
> > + void *kcfg_data;
> > int err, i;
> > - void *data;
> >
> > if (obj->nr_extern == 0)
> > return 0;
> >
> > - data = obj->maps[obj->kconfig_map_idx].mmaped;
> > + if (obj->kconfig_map_idx >= 0)
> > + kcfg_data = obj->maps[obj->kconfig_map_idx].mmaped;
> >
> > for (i = 0; i < obj->nr_extern; i++) {
> > ext = &obj->externs[i];
> >
> > - if (strcmp(ext->name, "LINUX_KERNEL_VERSION") == 0) {
> > - void *ext_val = data + ext->data_off;
> > + if (ext->type == EXT_KCFG &&
> > + strcmp(ext->name, "LINUX_KERNEL_VERSION") == 0) {
> > + void *ext_val = kcfg_data + ext->kcfg.data_off;
> > __u32 kver = get_kernel_version();
> >
> > if (!kver) {
> > pr_warn("failed to get kernel version\n");
> > return -EINVAL;
> > }
> > - err = set_ext_value_num(ext, ext_val, kver);
> > + err = set_kcfg_value_num(ext, ext_val, kver);
> > if (err)
> > return err;
> > - pr_debug("extern %s=0x%x\n", ext->name, kver);
> > - } else if (strncmp(ext->name, "CONFIG_", 7) == 0) {
> > + pr_debug("extern (kcfg) %s=0x%x\n", ext->name, kver);
> > + } else if (ext->type == EXT_KCFG &&
> > + strncmp(ext->name, "CONFIG_", 7) == 0) {
> > need_config = true;
> > } else {
> > pr_warn("unrecognized extern '%s'\n", ext->name);
>
> Ah, we need to initialize kcfg_data, otherwise the compiler will give
> a warning on potentially uninitialized data.
yep, good catch
Powered by blists - more mailing lists