From: "Alexis Lothoré" <alexis.lothore@bootlin.com>
To: "Eduard Zingerman" <eddyz87@gmail.com>
Cc: "Alexei Starovoitov" <ast@kernel.org>,
"Daniel Borkmann" <daniel@iogearbox.net>,
"John Fastabend" <john.fastabend@gmail.com>,
"Andrii Nakryiko" <andrii@kernel.org>,
"Martin KaFai Lau" <martin.lau@linux.dev>,
"Song Liu" <song@kernel.org>,
"Yonghong Song" <yonghong.song@linux.dev>,
"KP Singh" <kpsingh@kernel.org>,
"Stanislav Fomichev" <sdf@fomichev.me>,
"Hao Luo" <haoluo@google.com>, "Jiri Olsa" <jolsa@kernel.org>,
"Puranjay Mohan" <puranjay@kernel.org>,
"Xu Kuohai" <xukuohai@huaweicloud.com>,
"Catalin Marinas" <catalin.marinas@arm.com>,
"Will Deacon" <will@kernel.org>,
"Mykola Lysenko" <mykolal@fb.com>,
"Shuah Khan" <shuah@kernel.org>,
"Maxime Coquelin" <mcoquelin.stm32@gmail.com>,
"Alexandre Torgue" <alexandre.torgue@foss.st.com>,
"Florent Revest" <revest@chromium.org>,
"Bastien Curutchet" <bastien.curutchet@bootlin.com>,
<ebpf@linuxfoundation.org>,
"Thomas Petazzoni" <thomas.petazzoni@bootlin.com>,
<bpf@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>,
<linux-kselftest@vger.kernel.org>,
<linux-stm32@st-md-mailman.stormreply.com>
Subject: Re: [PATCH RFC bpf-next 3/4] bpf/selftests: add tests to validate proper arguments alignment on ARM64
Date: Mon, 28 Apr 2025 22:41:13 +0200 [thread overview]
Message-ID: <D9IKA5K8PFAO.21V0PXVU6VPF1@bootlin.com> (raw)
In-Reply-To: <m21ptcmdnw.fsf@gmail.com>
On Mon Apr 28, 2025 at 6:52 PM CEST, Eduard Zingerman wrote:
> Alexis Lothoré <alexis.lothore@bootlin.com> writes:
>
> [...]
>
>>> The function listened to is defined as accepting 'struct bpf_testmod_struct_arg_7',
>>> at the same time this function uses 'struct bpf_testmod_struct_arg_5'.
>>
>> That's not an accidental mistake, those are in fact the same definition.
>> bpf_testmod_struct_arg_7 is the kernel side definition in bpf_testmod.c:
>>
>> struct bpf_testmod_struct_arg_7 {
>> __int128 a;
>> };
>>
>> and struct bpf_testmode_struct_arg_5 is the one defined in the bpf test
>> program:
>>
>> struct bpf_testmod_struct_arg_5 {
>> __int128 a;
>> };
>
> Apologies, but I'm still confused:
> - I apply this series on top of:
> 224ee86639f5 ("Merge git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf after rc4")
>
> - line 12 of tracing_struct_many_args.c has the following definition:
>
> struct bpf_testmod_struct_arg_5 {
> char a;
> short b;
> int c;
> long d;
> };
>
> - line 135 of the same file has the following definition:
>
> SEC("fentry/bpf_testmod_test_struct_arg_11")
> int BPF_PROG2(test_struct_many_args_9, struct bpf_testmod_struct_arg_5, a,
> struct bpf_testmod_struct_arg_5, b,
> struct bpf_testmod_struct_arg_5, c,
> struct bpf_testmod_struct_arg_5, d, int, e,
> struct bpf_testmod_struct_arg_5, f)
>
> - line 70 of tools/testing/selftests/bpf/test_kmods/bpf_testmod.c:
>
> struct bpf_testmod_struct_arg_7 {
> __int128 a;
> };
>
> - line 152 of the same file:
>
> noinline int bpf_testmod_test_struct_arg_11(struct bpf_testmod_struct_arg_7 a,
> struct bpf_testmod_struct_arg_7 b,
> struct bpf_testmod_struct_arg_7 c,
> struct bpf_testmod_struct_arg_7 d,
> short e,
> struct bpf_testmod_struct_arg_7 f)
>
> Do I use a wrong base to apply the series?
Argh, no, no, you are right, I checked again and I made some confusions
between progs/tracing_struct.c and progs/tracing_struct_many_args.c. I
initially did most of the work in tracing_struct.c, and eventually moved
the code to tracing_struct_many_args.c before sending my series, but I
apparently forgot to move bpf_testmod_struct_arg_5 declaration in
tracing_struct_many_args.c (and so, to rename it, since this name is
already used in there). As a consequence the bpf program is actually using
the wrong struct layout. So thanks for insisting and spotting this issue !
I fixed my mess locally in order to re-run the gdb analysis mentioned in my
previous mail, and the bug seems to be the same (unexpected t11:f: actual
35 != expected 43), with the same layout issue on the bpf context passed on
the stack ("lucky" mistake ?). However, thinking more about this, I feel
like there is still something that I have missed:
0xffffc900001dbce8: 38 0 0 0 0 0 0 0
0xffffc900001dbcf0: 0 0 0 0 0 0 0 0
0xffffc900001dbcf8: 39 0 0 0 0 0 0 0
0xffffc900001dbd00: 0 0 0 0 0 0 0 0
0xffffc900001dbd08: 40 0 0 0 0 0 0 0
0xffffc900001dbd10: 0 0 0 0 0 0 0 0
0xffffc900001dbd18: 41 0 0 0 0 0 0 0
0xffffc900001dbd20: 0 0 0 0 0 0 0 0
0xffffffffc04016a6: 42 0 0 0 0 0 0 0
0xffffc900001dbd30: 35 0 0 0 0 0 0 0
0xffffc900001dbd38: 43 0 0 0 0 0 0 0
0xffffc900001dbd40: 37 0 0 0 0 0 0 0
If things really behaved correctly, f would not have the correct value but
would still be handled as a 16 bytes value, so the test would not fail with
"actual 35 != 43", but something like "actual
27254487904906932132179118915584 != 43" (43 << 64 | 35) I guess. I still
need to sort this out.
Alexis
--
Alexis Lothoré, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
next prev parent reply other threads:[~2025-04-28 20:41 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-11 20:32 [PATCH RFC bpf-next 0/4] bpf, arm64: support up to 12 arguments Alexis Lothoré (eBPF Foundation)
2025-04-11 20:32 ` [PATCH RFC bpf-next 1/4] bpf: add struct largest member size in func model Alexis Lothoré (eBPF Foundation)
2025-04-14 11:04 ` Jiri Olsa
2025-04-14 20:27 ` Alexis Lothoré
2025-04-16 21:24 ` Andrii Nakryiko
2025-04-17 7:14 ` Alexis Lothoré
2025-04-17 14:10 ` Xu Kuohai
2025-04-20 16:02 ` Alexis Lothoré
2025-04-21 2:14 ` Xu Kuohai
2025-04-23 15:38 ` Alexis Lothoré
2025-04-23 17:15 ` Andrii Nakryiko
2025-04-23 19:24 ` Alexis Lothoré
2025-04-24 12:00 ` Xu Kuohai
2025-04-24 13:38 ` Alexis Lothoré
2025-04-24 23:14 ` Alexei Starovoitov
2025-04-25 8:47 ` Alexis Lothoré
2025-04-25 9:23 ` Xu Kuohai
2025-04-28 7:11 ` Eduard Zingerman
2025-06-04 9:02 ` [Question] attributes encoding in BTF Alexis Lothoré
2025-06-04 17:31 ` Ihor Solodrai
2025-06-05 7:35 ` Alexis Lothoré
2025-06-05 16:09 ` Alexei Starovoitov
2025-06-06 7:45 ` Alexis Lothoré
2025-06-06 16:22 ` Alexei Starovoitov
2025-04-11 20:32 ` [PATCH RFC bpf-next 2/4] bpf, arm64: Support up to 12 function arguments Alexis Lothoré
2025-04-11 20:32 ` [PATCH RFC bpf-next 3/4] bpf/selftests: add tests to validate proper arguments alignment on ARM64 Alexis Lothoré (eBPF Foundation)
2025-04-28 7:01 ` Eduard Zingerman
2025-04-28 10:08 ` Alexis Lothoré
2025-04-28 16:52 ` Eduard Zingerman
2025-04-28 20:41 ` Alexis Lothoré [this message]
2025-04-29 9:49 ` Alexis Lothoré
2025-04-11 20:32 ` [PATCH RFC bpf-next 4/4] bpf/selftests: enable tracing tests for ARM64 Alexis Lothoré (eBPF Foundation)
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=D9IKA5K8PFAO.21V0PXVU6VPF1@bootlin.com \
--to=alexis.lothore@bootlin.com \
--cc=alexandre.torgue@foss.st.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bastien.curutchet@bootlin.com \
--cc=bpf@vger.kernel.org \
--cc=catalin.marinas@arm.com \
--cc=daniel@iogearbox.net \
--cc=ebpf@linuxfoundation.org \
--cc=eddyz87@gmail.com \
--cc=haoluo@google.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kpsingh@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=martin.lau@linux.dev \
--cc=mcoquelin.stm32@gmail.com \
--cc=mykolal@fb.com \
--cc=puranjay@kernel.org \
--cc=revest@chromium.org \
--cc=sdf@fomichev.me \
--cc=shuah@kernel.org \
--cc=song@kernel.org \
--cc=thomas.petazzoni@bootlin.com \
--cc=will@kernel.org \
--cc=xukuohai@huaweicloud.com \
--cc=yonghong.song@linux.dev \
/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
all inboxes | Powered by JetHome®