BPF List
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Yonghong Song" <yonghong.song@linux.dev>, bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next v2 3/4] libbpf: Accept sign-extended 32-bit enum values in CO-RE relocations
Date: Thu, 19 Nov 2026 05:21:38 +0000	[thread overview]
Message-ID: <sashiko-outbox-222472@kernel.org> (raw)
In-Reply-To: <20261119051459.1902876-1-yonghong.song@linux.dev>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] libbpf: non-standard multi-line comment style above
  bpf_core_enumval_is_sext()
--

commit 2ec397921876fd311cd75d218c792d79da6cd995
Author: Yonghong Song <yonghong.song@linux.dev>

libbpf: Accept sign-extended 32-bit enum values in CO-RE relocations

This commit accepts sign-extended 32-bit unsigned enum values in
BPF_CORE_ENUMVAL_VALUE relocations and sign-extends the patched 32-bit
target value to match GCC's output.

> diff --git a/tools/lib/bpf/relo_core.c b/tools/lib/bpf/relo_core.c
> index 7aa7eb4e4021b..76efee8e876f0 100644
> --- a/tools/lib/bpf/relo_core.c
> +++ b/tools/lib/bpf/relo_core.c
> @@ -1032,6 +1032,19 @@ static int insn_bytes_to_bpf_size(__u32 sz)
>  	}
>  }
>  
> +/* A 32-bit enum value is in the low 32 bits of the ld_imm64, extended as
> + * the compiler chooses: clang zero-extends an unsigned value, GCC
> + * sign-extends every value, as its __builtin_preserve_enum_value() returns
> + * int. Check whether the instruction has the sign-extended form of an
> + * unsigned value, so that the target value gets that form too.
> + */
> +static bool bpf_core_enumval_is_sext(const struct bpf_core_relo *relo,
> +				     __u64 imm, __u64 orig_val)
> +{
> +	return relo->kind == BPF_CORE_ENUMVAL_VALUE && orig_val <= UINT_MAX &&
> +	       imm != orig_val && imm == (__u64)(__s32)orig_val;
> +}

[Severity: Low]
This isn't a bug, but BPF code uses the multi-line comment style where the
opening /* is placed on its own line.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261119051443.1902163-1-yonghong.song@linux.dev?part=3

  reply	other threads:[~2026-11-19  5:21 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19  5:14 [PATCH bpf-next v2 0/4] libbpf: Fix CO-RE relocations of unsigned 32-bit enum values Yonghong Song
2026-11-19  5:14 ` [PATCH bpf-next v2 1/4] libbpf: Zero-extend unsigned 32-bit enum values in CO-RE relocations Yonghong Song
2026-11-19  5:54   ` bot+bpf-ci
2026-11-19  5:14 ` [PATCH bpf-next v2 2/4] selftests/bpf: Test CO-RE relocations of unsigned 32-bit enum values Yonghong Song
2026-11-19  5:54   ` bot+bpf-ci
2026-11-19  5:14 ` [PATCH bpf-next v2 3/4] libbpf: Accept sign-extended 32-bit enum values in CO-RE relocations Yonghong Song
2026-11-19  5:21   ` sashiko-bot [this message]
2026-11-19  5:15 ` [PATCH bpf-next v2 4/4] selftests/bpf: Take unsigned enum values as unsigned int for GCC Yonghong Song

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=sashiko-outbox-222472@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=yonghong.song@linux.dev \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox