docs/bpf: Add description for CO-RE relocations
Subsystems (2)
Eduard Zingerman
maintainerv3 cover docs/bpf: Add description for CO-RE relocations
Add a section on CO-RE relocations to llvm_relo.rst. Based on doc-strings from include/uapi/linux/bpf.h and tools/lib/bpf/relo_core.c
Changelog:
V2 -> V3:
- Small fixes suggested by Yonghong;
- Added ack from Yonghong;
V1 -> V2:
- Small fixes suggested by Yonghong and Andrii;
- C example extended to include all 13 relocation kinds (Yonghong);
- Description of which fields are patched for which instruction classes (Andrii);
- Details for BPF_CORE_TYPE_MATCHES relocation kind;
- Details for BPF_CORE_FIELD_{LR}SHIFT_U64 relocation kinds.
[V1] https://lore.kernel.org/bpf/[email protected]/
[V2] https://lore.kernel.org/bpf/[email protected]/
*** BLURB HERE ***
Eduard Zingerman (1):
docs/bpf: Add description for CO-RE relocations
Documentation/bpf/btf.rst | 31 +++- Documentation/bpf/llvm_reloc.rst | 304 +++++++++++++++++++++++++++++++ 2 files changed, 329 insertions(+), 6 deletions(-)
Signature · 1 line
2.41.0
Eduard Zingerman
maintainerPATCH v3 1/1 docs/bpf: Add description for CO-RE relocations
Add a section on CO-RE relocations to llvm_relo.rst. Describe relevant .BTF.ext structure, enum bpf_core_relo_kind and struct bpf_core_relo in some detail. Description is based on doc-strings from:
- include/uapi/linux/bpf.h:struct bpf_core_relo
- tools/lib/bpf/relo_core.c:__bpf_core_types_match()
--- Documentation/bpf/btf.rst | 31 +++- Documentation/bpf/llvm_reloc.rst | 304 +++++++++++++++++++++++++++++++ 2 files changed, 329 insertions(+), 6 deletions(-)
Documentation/bpf/btf.rst +25 -6
@@ -726,8 +726,8 @@ same as the one describe in :ref:`BTF_Type_String`. 4.2 .BTF.ext section -------------------- -The .BTF.ext section encodes func_info and line_info which needs loader -manipulation before loading into the kernel. +The .BTF.ext section encodes func_info, line_info and CO-RE relocations +which needs loader manipulation before loading into the kernel. The specification for .BTF.ext section is defined at ``tools/lib/bpf/btf.h`` and ``tools/lib/bpf/btf.c``.
@@ -745,15 +745,20 @@ The current header of .BTF.ext section:: __u32 func_info_len; __u32 line_info_off; __u32 line_info_len; + + /* optional part of .BTF.ext header */ + __u32 core_relo_off; + __u32 core_relo_len; }; It is very similar to .BTF section. Instead of type/string section, it -contains func_info and line_info section. See :ref:`BPF_Prog_Load` for details -about func_info and line_info record format. +contains func_info, line_info and core_relo sub-sections. +See :ref:`BPF_Prog_Load` for details about func_info and line_info +record format. The func_info is organized as below.:: - func_info_rec_size + func_info_rec_size /* __u32 value */ btf_ext_info_sec for section #1 /* func_info for section #1 */ btf_ext_info_sec for section #2 /* func_info for section #2 */ ...
@@ -773,7 +778,7 @@ Here, num_info must be greater than 0. The line_info is organized as below.:: - line_info_rec_size + line_info_rec_size /* __u32 value */ btf_ext_info_sec for section #1 /* line_info for section #1 */ btf_ext_info_sec for section #2 /* line_info for section #2 */ ...
@@ -787,6 +792,20 @@ kernel API, the ``insn_off`` is the instruction offset in the unit of ``struct bpf_insn``. For ELF API, the ``insn_off`` is the byte offset from the beginning of section (``btf_ext_info_sec->sec_name_off``). +The core_relo is organized as below.:: + + core_relo_rec_size /* __u32 value */ + btf_ext_info_sec for section #1 /* core_relo for section #1 */ + btf_ext_info_sec for section #2 /* core_relo for section #2 */ + +``core_relo_rec_size`` specifies the size of ``bpf_core_relo`` +structure when .BTF.ext is generated. All ``bpf_core_relo`` structures +within a single ``btf_ext_info_sec`` describe relocations applied to +section named by ``btf_ext_info_sec->sec_name_off``. + +See :ref:`Documentation/bpf/llvm_reloc <btf-co-re-relocations>` +for more information on CO-RE relocations. + 4.2 .BTF_ids section --------------------
Documentation/bpf/llvm_reloc.rst +304 -0
307 lines not on this page · raw message
Signature · 1 line
2.41.0
This patch was applied to bpf/bpf.git (master) by Daniel Borkmann <[email protected]>:
Hello:
This patch was applied to bpf/bpf.git (master)
by Daniel Borkmann <[email protected]>:
Quoted 16 lines · On Sun, 27 Aug 2023 01:29:11 +0300 you wrote:
Add a section on CO-RE relocations to
llvm_relo.rst. Based on doc-strings frominclude/uapi/linux/bpf.handtools/lib/bpf/relo_core.cChangelog:
V2 -> V3:
- Small fixes suggested by Yonghong;
- Added ack from Yonghong;
V1 -> V2:
- Small fixes suggested by Yonghong and Andrii;
- C example extended to include all 13 relocation kinds (Yonghong);
- Description of which fields are patched for which instruction classes (Andrii);
- Details forBPF_CORE_TYPE_MATCHESrelocation kind;
- Details for BPF_CORE_FIELD_{LR}SHIFT_U64 relocation kinds.
Quoted 1 line
[...]
Here is the summary with links:
- [bpf-next,v3,1/1] docs/bpf: Add description for CO-RE relocations
https://git.kernel.org/bpf/bpf/c/be4033d36070
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html