https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124974

            Bug ID: 124974
           Summary: bpf: support for bpf arenas
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dfaust at gcc dot gnu.org
  Target Milestone: ---

The kernel bpf selftests related to BPF arenas fail when compiled with gcc with
verifier logs like:

libbpf: prog 'arena_strsearch': -- BEGIN PROG LOAD LOG --
arg#0 reference type('UNKNOWN ') size cannot be determined: -22
...
;  @ arena_strsearch.c:134
10: (bf) r1 = r8                      ;
R1=map_value(map=arena_st.rodata,ks=4,vs=748,imm=1)
R8=map_value(map=arena_st.rodata,ks=4,vs=748,imm=1)
11: (85) call pc+28
R1 is not a pointer to arena or scalar.
Caller passes invalid args into func#1 ('bpf_arena_strlen')

The issues appear to originate from the __arena and cast_user/cast_kern macro
definitions (see bpf_arena_common.h and bpf_experimental.h).
The BTF is semantically equivalent to that produced by clang, except for the
specific objects annotated with __arena.

We may need to introduce a target specific address_space attribute which
is compatible with LLVM's for the bpf target.

For the cast_user/cast_kern macros, it appears there is a specific encoding of
the register-register mov instruction which encodes additional information in
the offset and immediate fields to form a new specialized instruction.

Needs further investigation.

kernel BPF arena patches:
https://lore.kernel.org/bpf/[email protected]/

LLVM PR with details on instruction encoding:
https://github.com/llvm/llvm-project/pull/84410

Reply via email to