From: Alan Maguire <alan.maguire@oracle.com>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Cc: Alan Maguire <alan.maguire@oracle.com>,
Andrii Nakryiko <andrii@kernel.org>, bpf <bpf@vger.kernel.org>,
Networking <netdev@vger.kernel.org>,
Alexei Starovoitov <ast@fb.com>,
Daniel Borkmann <daniel@iogearbox.net>,
Kernel Team <kernel-team@fb.com>
Subject: Re: [PATCH bpf-next] libbpf: support module BTF for BPF_TYPE_ID_TARGET CO-RE relocation
Date: Tue, 8 Dec 2020 22:02:01 +0000 (GMT) [thread overview]
Message-ID: <alpine.LRH.2.23.451.2012082156300.25628@localhost> (raw)
In-Reply-To: <CAEf4BzbB87SDiD+=4u2u5iLhQiXUCc0Bf-7SX6BXZ4tkhjFU=g@mail.gmail.com>
On Mon, 7 Dec 2020, Andrii Nakryiko wrote:
> On Sat, Dec 5, 2020 at 4:38 PM Alan Maguire <alan.maguire@oracle.com> wrote:
> > Thanks so much for doing this Andrii! When I tested, I ran into a problem;
> > it turns out when a module struct such as "veth_stats" is used, it's
> > classified as BTF_KIND_FWD, and as a result when we iterate over
> > the modules and look in the veth module, "struct veth_stats" does not
> > match since its module kind (BTF_KIND_STRUCT) does not match the candidate
> > kind (BTF_KIND_FWD). I'm kind of out of my depth here, but the below
> > patch (on top of your patch) worked.
>
> I'm not quite clear on the situation. BTF_KIND_FWD is for the local
> type or the remote type? Maybe a small example would help, before we
> go straight to assuming FWD can be always resolved into a concrete
> STRUCT/UNION.
>
The local type was BTF_KIND_FWD, and the target type was BTF_KIND_STRUCT
IIRC; I'll try and get some libbpf debug output for you showing the
relocation info. If it helps, I think the situation was this; I was
referencing __builtin_btf_type_id(struct veth_stats), and hadn't
included a BTF-generated veth header, so I'm guessing libbpf classified
it as a fwd declaration. My patch was a bit too general I suspect in
that it assumed that either target or local could be BTF_KIND_FWD and
should match BTF_KIND_STRUCT in local/target, wheres I _think_ the
local only should permit BTF_KIND_FWD. Does that make sense?
>
> > However without it - when we find
> > 0 candidate matches - as well as not substituting the module object
> > id/type id - we hit a segfault:
>
> Yep, I missed the null check in:
>
> targ_spec->btf != prog->obj->btf_vmlinux
>
> I'll fix that.
>
Thanks! I think the core_reloc selftests trigger the segfault
also if you need a test case to verify.
Alan
next prev parent reply other threads:[~2020-12-08 22:03 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-05 2:51 [PATCH bpf-next] libbpf: support module BTF for BPF_TYPE_ID_TARGET CO-RE relocation Andrii Nakryiko
2020-12-06 0:37 ` Alan Maguire
2020-12-08 3:28 ` Andrii Nakryiko
2020-12-08 22:02 ` Alan Maguire [this message]
2020-12-07 16:38 ` Alan Maguire
2020-12-08 3:12 ` Alexei Starovoitov
2020-12-08 3:40 ` Andrii Nakryiko
2020-12-08 22:13 ` Alan Maguire
2020-12-08 23:39 ` Alexei Starovoitov
2020-12-09 23:21 ` Alan Maguire
2020-12-15 22:38 ` one prog multi fentry. Was: " Alexei Starovoitov
2020-12-16 16:18 ` Alan Maguire
2020-12-16 22:27 ` Andrii Nakryiko
2020-12-17 7:16 ` Alexei Starovoitov
2020-12-17 17:46 ` Alan Maguire
2020-12-17 18:22 ` Alexei Starovoitov
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=alpine.LRH.2.23.451.2012082156300.25628@localhost \
--to=alan.maguire@oracle.com \
--cc=andrii.nakryiko@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@fb.com \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=kernel-team@fb.com \
--cc=netdev@vger.kernel.org \
/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).