From: Eduard Zingerman <eddyz87@gmail.com>
To: Anton Protopopov <a.s.protopopov@gmail.com>,
bpf@vger.kernel.org, Alexei Starovoitov <ast@kernel.org>,
Andrii Nakryiko <andrii@kernel.org>,
Anton Protopopov <aspsk@isovalent.com>,
Daniel Borkmann <daniel@iogearbox.net>,
Quentin Monnet <qmo@kernel.org>,
Yonghong Song <yonghong.song@linux.dev>
Subject: Re: [PATCH v8 bpf-next 08/11] libbpf: support llvm-generated indirect jumps
Date: Wed, 29 Oct 2025 14:31:40 -0700 [thread overview]
Message-ID: <68754a9c03b960d5057de816b217e824e51021a1.camel@gmail.com> (raw)
In-Reply-To: <20251028142049.1324520-9-a.s.protopopov@gmail.com>
On Tue, 2025-10-28 at 14:20 +0000, Anton Protopopov wrote:
> For v4 instruction set LLVM is allowed to generate indirect jumps for
> switch statements and for 'goto *rX' assembly. Every such a jump will
> be accompanied by necessary metadata, e.g. (`llvm-objdump -Sr ...`):
>
> 0: r2 = 0x0 ll
> 0000000000000030: R_BPF_64_64 BPF.JT.0.0
>
> Here BPF.JT.1.0 is a symbol residing in the .jumptables section:
>
> Symbol table:
> 4: 0000000000000000 240 OBJECT GLOBAL DEFAULT 4 BPF.JT.0.0
>
> The -bpf-min-jump-table-entries llvm option may be used to control the
> minimal size of a switch which will be converted to an indirect jumps.
>
> Signed-off-by: Anton Protopopov <a.s.protopopov@gmail.com>
> Acked-by: Eduard Zingerman <eddyz87@gmail.com>
> ---
The update looks good to me, but I noticed one more thing.
I'm seeing the following messages when rebuilding bpf_gotox using
llvm main, where Yonghong added __BPF_FEATURE_GOTOX.
CLNG-BPF [test_progs-cpuv4] bpf_gotox.bpf.o
GEN-SKEL [test_progs-cpuv4] bpf_gotox.skel.h
libbpf: elf: skipping relo section(13) .rel.jumptables for section(6) .jumptables
libbpf: elf: skipping relo section(13) .rel.jumptables for section(6) .jumptables
Looking at the llvm-readelf results for the object file:
Relocation section '.rel.jumptables' at offset 0x5a28 contains 263 entries:
Offset Info Type Symbol's Value Symbol's Name
0000000000000000 0000000300000002 R_BPF_64_ABS64 0000000000000000 syscall
0000000000000008 0000000300000002 R_BPF_64_ABS64 0000000000000000 syscall
0000000000000010 0000000300000002 R_BPF_64_ABS64 0000000000000000 syscall
...
Note the number of entries (263) above.
When compiled with -S instead of -c, jump tables are printed as:
.section .jumptables,"",@progbits
BPF.JT.4.0:
.quad LBB4_5
.quad LBB4_4
...
Counting these LBBs gives 263 as well, so I assume the relocations are
for label references.
Given that relocation addend is always zero, I don't think we need
these relocations, but I can't figure at the moment, on how to
convince llvm not to emit these.
Yonghong, do you have any ideas?
This is done for OutStreamer->emitValue(Value: LHS, Size: EntrySize);
entries in BPFAsmPrinter::emitJumpTableInfo().
Or I might be wrong and addend is not guaranteed to be zero.
Then we need to handle these on libbpf side.
Spent two hours trying to figure this out, no definite answer yet,
will continue investigation later.
[...]
next prev parent reply other threads:[~2025-10-29 21:31 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-28 14:20 [PATCH v8 bpf-next 00/11] BPF indirect jumps Anton Protopopov
2025-10-28 14:20 ` [PATCH v8 bpf-next 01/11] bpf, x86: add new map type: instructions array Anton Protopopov
2025-10-30 22:50 ` Alexei Starovoitov
2025-10-31 7:23 ` Anton Protopopov
2025-10-31 15:04 ` Alexei Starovoitov
2025-10-31 15:20 ` Anton Protopopov
2025-10-28 14:20 ` [PATCH v8 bpf-next 02/11] selftests/bpf: add selftests for new insn_array map Anton Protopopov
2025-10-28 14:20 ` [PATCH v8 bpf-next 03/11] bpf: support instructions arrays with constants blinding Anton Protopopov
2025-10-28 14:20 ` [PATCH v8 bpf-next 04/11] selftests/bpf: test instructions arrays with blinding Anton Protopopov
2025-10-28 14:20 ` [PATCH v8 bpf-next 05/11] bpf, x86: allow indirect jumps to r8...r15 Anton Protopopov
2025-10-28 14:20 ` [PATCH v8 bpf-next 06/11] bpf, x86: add support for indirect jumps Anton Protopopov
2025-10-28 14:20 ` [PATCH v8 bpf-next 07/11] bpf: disasm: add support for BPF_JMP|BPF_JA|BPF_X Anton Protopopov
2025-10-28 14:20 ` [PATCH v8 bpf-next 08/11] libbpf: support llvm-generated indirect jumps Anton Protopopov
2025-10-29 21:31 ` Eduard Zingerman [this message]
2025-11-03 4:15 ` Yonghong Song
2025-10-30 21:00 ` Andrii Nakryiko
2025-10-31 7:30 ` Anton Protopopov
2025-10-28 14:20 ` [PATCH v8 bpf-next 09/11] bpftool: Recognize insn_array map type Anton Protopopov
2025-10-28 14:20 ` [PATCH v8 bpf-next 10/11] selftests/bpf: add new verifier_gotox test Anton Protopopov
2025-10-28 14:45 ` bot+bpf-ci
2025-10-28 15:05 ` Anton Protopopov
2025-10-28 14:20 ` [PATCH v8 bpf-next 11/11] selftests/bpf: add C-level selftests for indirect jumps Anton Protopopov
2025-10-29 21:49 ` Eduard Zingerman
2025-10-30 7:46 ` Anton Protopopov
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=68754a9c03b960d5057de816b217e824e51021a1.camel@gmail.com \
--to=eddyz87@gmail.com \
--cc=a.s.protopopov@gmail.com \
--cc=andrii@kernel.org \
--cc=aspsk@isovalent.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=qmo@kernel.org \
--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