All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Eelco Chaudron" <echaudro@redhat.com>
To: "Yonghong Song" <yhs@fb.com>
Cc: bpf@vger.kernel.org, netdev@vger.kernel.org, ast@kernel.org,
	daniel@iogearbox.net, kafai@fb.com, songliubraving@fb.com,
	andriin@fb.com, toke@redhat.com
Subject: Re: fentry/fexit attach to EXT type XDP program does not work
Date: Tue, 09 Jun 2020 10:52:34 +0200	[thread overview]
Message-ID: <88B08061-F85B-454C-9E9D-234154B9F000@redhat.com> (raw)
In-Reply-To: <42b0c8d3-e855-7531-b01c-a05414360aff@fb.com>



On 8 Jun 2020, at 18:58, Yonghong Song wrote:

> On 6/8/20 7:11 AM, Eelco Chaudron wrote:
>> I'm trying for a while to do a fentry/fexit trace an EXT program
>> attached to an XDP program. To make it easier to explain I've
>> created a test case (see patch below) to show the issue.
>>
>> Without the changes to test_xdp_bpf2bpf.c I'll get the following 
>> error:
>>
>>    libbpf: -- BEGIN DUMP LOG ---
>>    libbpf:
>>    arg#0 type is not a struct
>>    Unrecognized arg#0 type PTR
>>    ; int BPF_PROG(trace_on_entry, struct xdp_buff *xdp)
>>    0: (79) r6 = *(u64 *)(r1 +0)
>>    invalid bpf_context access off=0 size=8
>>    processed 1 insns (limit 1000000) max_states_per_insn 0 
>> total_states 0 peak_states 0 mark_read 0
>>
>>    libbpf: -- END LOG --
>>    libbpf: failed to load program 'fentry/FUNC'
>>    libbpf: failed to load object 'test_xdp_bpf2bpf'
>>    libbpf: failed to load BPF skeleton 'test_xdp_bpf2bpf': -4007
>>    test_xdp_fentry_ext:FAIL:__load ftrace skeleton failed
>>    #91 xdp_fentry_ext:FAIL
>>    Summary: 0/0 PASSED, 0 SKIPPED, 1 FAILED
>>
>> With the change I get the following (but I do feel this change
>> should not be needed):
>>
>>    libbpf: -- BEGIN DUMP LOG ---
>>    libbpf:
>>    Unrecognized arg#0 type PTR
>>    ; int trace_on_entry(struct xdp_buff *xdp)
>>    0: (bf) r6 = r1
>>    ; void *data = (void *)(long)xdp->data;
>>    1: (79) r1 = *(u64 *)(r6 +0)
>>    invalid bpf_context access off=0 size=8
>>    processed 2 insns (limit 1000000) max_states_per_insn 0 
>> total_states 0 peak_states 0 mark_read 0
>>
>>    libbpf: -- END LOG --
>>    libbpf: failed to load program 'fentry/FUNC'
>>    libbpf: failed to load object 'test_xdp_bpf2bpf'
>>    libbpf: failed to load BPF skeleton 'test_xdp_bpf2bpf': -4007
>>    test_xdp_fentry_ext:FAIL:__load ftrace skeleton failed
>>    #91 xdp_fentry_ext:FAIL
>>    Summary: 0/0 PASSED, 0 SKIPPED, 1 FAILED
>>
>> Any idea what could be the case here? The same fentry/fexit attach
>> code works fine in the xdp_bpf2bpf.c tests case.

<SNIP>
>
> I think this is not supported now. That is, you cannot attach a fentry 
> trace
> to the EXT program. The current implementation for fentry program 
> simply
> trying to find and match the signature of freplace program which by 
> default
> is a pointer to void.
>
> It is doable in that in kernel we could recognize to-be-attached 
> program is
> a freplace and further trace down to find the real signature. The 
> related
> kernel function is btf_get_prog_ctx_type(). You can try to implement 
> by yourself
> or I can have a patch for this once bpf-next opens.

I’m not familiar with this area of the code, so if you could prepare a 
patch that would nice.
You can also send it to me before bpf-next opens and I can verify it, 
and clean up the self-test so it can be included as well.


  reply	other threads:[~2020-06-09  8:52 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-08 14:11 fentry/fexit attach to EXT type XDP program does not work Eelco Chaudron
2020-06-08 16:58 ` Yonghong Song
2020-06-09  8:52   ` Eelco Chaudron [this message]
2020-07-26 12:24     ` Jiri Olsa
2020-07-27  7:59       ` Eelco Chaudron
2020-07-27 14:53         ` Jiri Olsa
2020-07-29  6:23           ` Eelco Chaudron
2020-07-29  8:09             ` Jiri Olsa

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=88B08061-F85B-454C-9E9D-234154B9F000@redhat.com \
    --to=echaudro@redhat.com \
    --cc=andriin@fb.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=kafai@fb.com \
    --cc=netdev@vger.kernel.org \
    --cc=songliubraving@fb.com \
    --cc=toke@redhat.com \
    --cc=yhs@fb.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 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.