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

--- Comment #2 from David Faust <dfaust at gcc dot gnu.org> ---
I see net improvement in kernel selftests results with above patch;
several sub-tests which were failing now pass.

But there is one regression in the verifier_sockmap_mutate test,
which used to pass:

libbpf: failed to load object 'verifier_sockmap_mutate'
run_subtest:FAIL:unexpected_load_failure unexpected error: -22 (errno 22)
VERIFIER LOG:
=============
0: R1=ctx() R10=fp0
0: <invalid CO-RE relocation>
failed to resolve CO-RE relocation <byte_off> [1] struct bpf_iter__sockmap (0:0
@ offset 0)


It looks like one part of the CO-RE relo has been dropped.

with clang and gcc prior to the patch:

$ pk-bpfcoredump -v verifier_sockmap_mutate.bpf.o

CO-RE RELOCATION RECORDS FOR [iter/sockmap]:  1 total
R field:byte_offset "0:0:0"
    @0U#B
    ldxdw       %r6, [%r1+0]
  0: struct bpf_iter__sockmap (id=42)
  0:   struct bpf_iter__sockmap (id=42).<anon>
  0:     union <anon> (id=43).sk
    ptr <anon> (id=44) -> fwd sock (id=111)


gcc after the patch:

$ pk-bpfcoredump -v bpf_gcc/verifier_sockmap_mutate.bpf.o

CO-RE RELOCATION RECORDS FOR [iter/sockmap]:  1 total
R field:byte_offset "0:0"
    @0U#B
    ldxdw       %r6, [%r1+0]
  0: struct bpf_iter__sockmap (id=1)
  0:   struct bpf_iter__sockmap (id=1).<anon>
    union <anon> (id=2)


The problematic bit of the test is:

struct sock {
} __attribute__((preserve_access_index));

struct bpf_iter__sockmap {
        union {
                struct sock *sk;
        };
} __attribute__((preserve_access_index));

SEC("iter/sockmap")
int test_trace_iter(struct bpf_iter__sockmap *ctx)
{
        test_sockmap_mutate(ctx->sk);
        return 0;
}

Reply via email to