From: Yonghong Song <yonghong.song@linux.dev>
To: bot+bpf-ci@kernel.org, bpf@vger.kernel.org
Cc: ast@kernel.org, andrii@kernel.org, daniel@iogearbox.net,
eddyz87@gmail.com, kernel-team@fb.com, martin.lau@kernel.org,
mason@kernel.org, ihor.solodrai@linux.dev
Subject: Re: [PATCH bpf-next v5 3/3] selftests/bpf: Test CO-RE relocations of signed enum values without kflag
Date: Fri, 20 Nov 2026 16:21:40 -0800 [thread overview]
Message-ID: <c0fe98fe-767d-4f6d-8c43-20dc111984d9@linux.dev> (raw)
In-Reply-To: <21bcff8573207e9277c3d209e6712adb4b6e76712b893cfba2e710443bf546d1@mail.kernel.org>
On 11/20/26 2:39 PM, bot+bpf-ci@kernel.org wrote:
>> selftests/bpf: Test CO-RE relocations of signed enum values without kflag
> TL;DR: Test issue: the new signed named_int_enum checks in test_core_enumval()
> may fail the enumval and enumval___no_kflag subtests on clang 12-14, which
> lack enum signedness kflag; should they be guarded by __clang_major__ >= 15?
>
>> diff --git a/tools/testing/selftests/bpf/progs/test_core_reloc_enumval.c b/tools/testing/selftests/bpf/progs/test_core_reloc_enumval.c
>> --- a/tools/testing/selftests/bpf/progs/test_core_reloc_enumval.c
>> +++ b/tools/testing/selftests/bpf/progs/test_core_reloc_enumval.c
> [ ... ]
>
>> @@ -85,6 +93,12 @@ int test_core_enumval(void *ctx)
>> out->uint_val1 = UINT_ENUM_VALUE(UINT_ENUM_VAL1);
>> if (bpf_core_enum_value_exists(enum named_uint_enum, UINT_ENUM_VAL2))
>> out->uint_val2 = UINT_ENUM_VALUE(UINT_ENUM_VAL2);
>> +
>> + /* enum named_int_enum is optional */
>> + if (bpf_core_enum_value_exists(enum named_int_enum, INT_ENUM_VAL1))
>> + out->int_val1 = bpf_core_enum_value(enum named_int_enum, INT_ENUM_VAL1);
>> + if (bpf_core_enum_value_exists(enum named_int_enum, INT_ENUM_VAL2))
>> + out->int_val2 = bpf_core_enum_value(enum named_int_enum, INT_ENUM_VAL2);
>> #else
>> data.skip = true;
>> #endif
> Is this part of test_core_enumval() safe with clang 12 to 14?
>
> These checks sit under the same guard as the rest of the function,
> #if __has_builtin(__builtin_preserve_enum_value), which clang 12 and later
> already satisfy. But clang only records enum signedness in the BTF kflag
> starting with LLVM 15 (enum64 support). Before that, the local
> named_int_enum gets kflag 0, and so does the target enum built by the same
> compiler.
>
> With the libbpf change in this series, bpf_core_zext_enumval() then does not
> return early, and zero-extends the target value:
>
> if (btf_is_enum(targ_t) && !BTF_INFO_KFLAG(targ_t->info))
> res->new_val = (__u32)res->new_val;
>
> For INT_ENUM_VAL2 the local value is 1, so the GCC-form fixup in
> bpf_core_patch_insn() does not apply and the instruction is patched with
> 0xfffffffd. out->int_val2 would then be 4294967293 while
> run_core_reloc_tests() expects .int_val2 = -3. That would make both the
> existing enumval subtest and the new enumval___no_kflag subtest fail with
> clang 12 to 14.
>
> The neighbouring programs guard this compiler dependency, for example
> test_core_reloc_enum64val.c uses "#if __clang_major__ >= 15" and
> test_core_reloc_type_based.c uses
> "__has_builtin(__builtin_preserve_type_info) && __clang_major__ >= 15",
> both falling back to data.skip = true. tools/testing/selftests/bpf/README.rst
> also says core_reloc sub-tests are skipped if Clang is too old to support
> them rather than failing.
>
> Should the named_int_enum part depend on __clang_major__ >= 15 so that it
> skips instead of failing, or silently leaving int_val1 and int_val2 at 0
> (which would also fail the comparison)?
I think we should be fine. In Documentation/process/changes.rst, the clang
minimum version is 17.0.1. Also, for this selftest, I don't think people will
build/run this selftest with `< 15' clang compiler.
>
>
> ---
> AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
> See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md
>
> CI run summary: https://github.com/kernel-patches/bpf/actions/runs/44827034192
prev parent reply other threads:[~2026-11-21 0:21 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 21:49 [PATCH bpf-next v5 0/3] libbpf: Fix CO-RE relocations of unsigned 32-bit enum values Yonghong Song
2026-11-20 21:50 ` [PATCH bpf-next v5 1/3] " Yonghong Song
2026-11-20 21:50 ` [PATCH bpf-next v5 2/3] selftests/bpf: Test " Yonghong Song
2026-11-20 21:50 ` [PATCH bpf-next v5 3/3] selftests/bpf: Test CO-RE relocations of signed enum values without kflag Yonghong Song
2026-11-20 22:39 ` bot+bpf-ci
2026-11-21 0:21 ` Yonghong Song [this message]
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=c0fe98fe-767d-4f6d-8c43-20dc111984d9@linux.dev \
--to=yonghong.song@linux.dev \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bot+bpf-ci@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=ihor.solodrai@linux.dev \
--cc=kernel-team@fb.com \
--cc=martin.lau@kernel.org \
--cc=mason@kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.