All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jiri Olsa <olsajiri@gmail.com>
To: Eduard Zingerman <eddyz87@gmail.com>
Cc: Tony Ambardar <tony.ambardar@gmail.com>,
	bpf@vger.kernel.org, linux-kselftest@vger.kernel.org,
	Andrii Nakryiko <andrii@kernel.org>,
	Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Martin KaFai Lau <martin.lau@linux.dev>,
	Song Liu <song@kernel.org>,
	Yonghong Song <yonghong.song@linux.dev>,
	John Fastabend <john.fastabend@gmail.com>,
	KP Singh <kpsingh@kernel.org>,
	Stanislav Fomichev <sdf@fomichev.me>, Hao Luo <haoluo@google.com>,
	Mykola Lysenko <mykolal@fb.com>, Shuah Khan <shuah@kernel.org>,
	Jean-Philippe Brucker <jean-philippe@linaro.org>,
	Viktor Malik <vmalik@redhat.com>
Subject: Re: [PATCH bpf-next v1 2/3] bpf: btf: Ensure natural alignment of .BTF_ids section
Date: Mon, 23 Sep 2024 12:54:56 +0200	[thread overview]
Message-ID: <ZvFJAJdEdK3wnyXs@krava> (raw)
In-Reply-To: <46d8d74883926245829f8aac3d1ab6dc5b5e4b98.camel@gmail.com>

On Sat, Sep 21, 2024 at 02:46:17AM -0700, Eduard Zingerman wrote:
> On Fri, 2024-09-20 at 00:49 -0700, Tony Ambardar wrote:
> > While building of vmlinux employs a linker script to align the .BTF_ids
> > section to 4 bytes, other usage leaves .BTF_ids unaligned and may lead to
> > problems (e.g. [1]). Post-processing and libelf-based endian translation by
> > resolve_btfids may also potentially suffer from misalignment.
> > 
> > Update encoding macros in btf_ids.h to always align BTF ID data to 4 bytes.
> > 
> > [1]: 3effc06a4dde ("selftests/bpf: Fix alignment of .BTF_ids")
> > 
> > Signed-off-by: Tony Ambardar <tony.ambardar@gmail.com>
> > ---
> >  include/linux/btf_ids.h | 1 +
> >  1 file changed, 1 insertion(+)
> > 
> > diff --git a/include/linux/btf_ids.h b/include/linux/btf_ids.h
> > index c0e3e1426a82..c10b163dc340 100644
> > --- a/include/linux/btf_ids.h
> > +++ b/include/linux/btf_ids.h
> > @@ -89,6 +89,7 @@ word							\
> >  #define __BTF_ID_LIST(name, scope)			\
> >  asm(							\
> >  ".pushsection " BTF_IDS_SECTION ",\"a\";       \n"	\
> > +".balign 4, 0;                                 \n"	\
> >  "." #scope " " #name ";                        \n"	\
> >  #name ":;                                      \n"	\
> >  ".popsection;                                  \n");
> 
> This forces all id list symbols to be aligned on 4 bytes.
> Should the same be done for __BTF_SET_START?

it seems all the set macros use __BTF_ID_LIST, so it should be taken
care of by that

> 
> Also, is it guaranteed that all btf ids are organized in lists and sets?
> Grepping through the code it seems they are, but it looks like resolve_btfids
> does not really enforce this, simply looking for symbols matching a special name
> __BTF_ID__<type>__<symbol>[__<id>] .

yes, you need the BTF_ID to be part of list or set to be able to access it

resolve_btfids does not enforce some loose BTF_ID definition without list/set,
but that does not seem to be a problem

thanks,
jirka

  reply	other threads:[~2024-09-23 10:55 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-20  7:49 [PATCH bpf-next v1 0/3] Improve .BTF_ids patching and alignment Tony Ambardar
2024-09-20  7:49 ` [PATCH bpf-next v1 1/3] tools/resolve_btfids: Simplify handling cross-endian compilation Tony Ambardar
2024-09-21  9:38   ` Eduard Zingerman
2024-09-23 10:55   ` Jiri Olsa
2024-10-14 12:56   ` Viktor Malik
2024-09-20  7:49 ` [PATCH bpf-next v1 2/3] bpf: btf: Ensure natural alignment of .BTF_ids section Tony Ambardar
2024-09-21  9:46   ` Eduard Zingerman
2024-09-23 10:54     ` Jiri Olsa [this message]
2024-09-23 11:39       ` Eduard Zingerman
2024-09-20  7:49 ` [PATCH bpf-next v1 3/3] tools/bpf, selftests/bpf : Sync btf_ids.h to tools Tony Ambardar
2024-09-23 11:07 ` [PATCH bpf-next v1 0/3] Improve .BTF_ids patching and alignment 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=ZvFJAJdEdK3wnyXs@krava \
    --to=olsajiri@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=haoluo@google.com \
    --cc=jean-philippe@linaro.org \
    --cc=john.fastabend@gmail.com \
    --cc=kpsingh@kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=mykolal@fb.com \
    --cc=sdf@fomichev.me \
    --cc=shuah@kernel.org \
    --cc=song@kernel.org \
    --cc=tony.ambardar@gmail.com \
    --cc=vmalik@redhat.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 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.