libbpf / libbpf-bootstrap

Scaffolding for BPF application development with libbpf and BPF CO-RE
BSD 3-Clause "New" or "Revised" License
1.05k stars 287 forks source link

sudo ./minimal run failed #102

Closed yanchdh closed 2 years ago

yanchdh commented 2 years ago

libbpf: loading object 'minimal_bpf' from buffer libbpf: elf: section(2) tp/syscalls/sys_enter_write, size 104, link 0, flags 6, type=1 libbpf: sec 'tp/syscalls/sys_enter_write': found program 'handle_tp' at insn offset 0 (0 bytes), code size 13 insns (104 bytes) libbpf: elf: section(3) license, size 13, link 0, flags 3, type=1 libbpf: license of minimal_bpf is Dual BSD/GPL libbpf: elf: section(4) .bss, size 4, link 0, flags 3, type=8 libbpf: elf: section(5) .rodata, size 28, link 0, flags 2, type=1 libbpf: elf: section(6) .BTF, size 601, link 0, flags 0, type=1 libbpf: elf: section(7) .BTF.ext, size 160, link 0, flags 0, type=1 libbpf: elf: section(8) .symtab, size 192, link 13, flags 0, type=2 libbpf: elf: section(9) .reltp/syscalls/sys_enterwrite, size 32, link 8, flags 0, type=9 libbpf: looking for externs among 8 symbols... libbpf: collected 0 externs total libbpf: map 'minimal.bss' (global data): at secidx 4, offset 0, flags 400. libbpf: map 0 is "minimal.bss" libbpf: map 'minimal_.rodata' (global data): at secidx 5, offset 0, flags 480. libbpf: map 1 is "minimal.rodata" libbpf: sec '.reltp/syscalls/sys_enter_write': collecting relocation for section(2) 'tp/syscalls/sys_enter_write' libbpf: sec '.reltp/syscalls/sys_enter_write': relo #0: insn #2 against 'my_pid' libbpf: prog 'handletp': found data map 0 (minimal.bss, sec 4, off 0) for insn 2 libbpf: sec '.reltp/syscalls/sys_enter_write': relo #1: insn #6 against '.rodata' libbpf: prog 'handletp': found data map 1 (minimal.rodata, sec 5, off 0) for insn 6 libbpf: BTF loading error: -22 libbpf: -- BEGIN BTF LOAD LOG --- magic: 0xeb9f version: 1 flags: 0x0 hdr_len: 24 type_off: 0 type_len: 272 str_off: 272 str_len: 305 btf_total_size: 601 [1] PTR (anon) type_id=0 [2] ENUM (anon) size=4 vlen=1 ctx val=1 [3] INT int size=4 bits_offset=0 nr_bits=32 encoding=SIGNED [4] TYPEDEF handle_tp type_id=2 [5] INT char size=1 bits_offset=0 nr_bits=8 encoding=SIGNED [6] ARRAY (anon) type_id=5 index_type_id=7 nr_elems=13 [7] INT ARRAY_SIZE_TYPE size=4 bits_offset=0 nr_bits=32 encoding=(none) [8] INT LICENSE size=1 bits_offset=0 nr_bits=8 encoding=(none) [9] INT my_pid size=1 bits_offset=0 nr_bits=8 encoding=(none) [10] CONST (anon) type_id=5 [11] ARRAY (anon) type_id=10 index_type_id=7 nr_elems=28 [12] INT handle_tp.fmt size=1 bits_offset=0 nr_bits=8 encoding=(none) [13] STRUCT _bss size=4 vlen=1 my_pid type_id=9 bits_offset=0 [14] STRUCT _rodata size=28 vlen=1 handle_tp.fmt type_id=12 bits_offset=0 Invalid name

-- END BTF LOAD LOG -- libbpf: Error loading .BTF into kernel: -22. BTF is optional, ignoring. libbpf: map 'minimal.bss': skipped auto-creating... libbpf: map 'minimal.rodata': skipped auto-creating... libbpf: prog 'handletp': relo #0: poisoning insn #2 that loads map #0 'minimal.bss' libbpf: prog 'handletp': relo #1: poisoning insn #6 that loads map #1 'minimal.rodata' libbpf: prog 'handle_tp': BPF program load failed: Invalid argument libbpf: prog 'handle_tp': -- BEGIN PROG LOAD LOG -- 0: (85) call bpf_get_current_pidtgid#14 1: (77) r0 >>= 32 2: BPF map 'minimal.bss' is referenced but wasn't created -- END PROG LOAD LOG -- libbpf: prog 'handle_tp': failed to load: -22 libbpf: failed to load object 'minimal_bpf' libbpf: failed to load BPF skeleton 'minimal_bpf': -22 Failed to load and verify BPF skeleton

anakryiko commented 2 years ago

Your kernel is too old to support BPF global variables (those .bss and .rodata maps). You'll have to upgrade your kernel or try minimal_legacy to avoid relying on BPF global variables.

yuki429 commented 1 year ago

@anakryiko could you please tell me which kernel to start support it ? our kernel version 5.10.104 and have the same problem. hardware : aarch64,NVIDIA orin

Failed to load and verify BPF skeleton

chenhengqi commented 1 year ago

Do you have CONFIG_DEBUG_INFO_BTF enabled ?

ziyangfu commented 1 year ago

@chenhengqi yes, it is enabled.

CONFIG_DEBUG_INFO_BTF=y
anakryiko commented 1 year ago

@yuki429 It should be supported starting from 5.2 kernel, look for d8eca5bbb2be ("bpf: implement lookup-free direct value access for maps") commit.