All of lore.kernel.org
 help / color / mirror / Atom feed
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 v7 20/22] selftests/bpf: Add __set_global() and __ret_global() test tags
Date: Tue, 29 Sep 2026 18:46:43 -0700	[thread overview]
Message-ID: <9d4aebc7-47a7-4de2-9feb-a47df40c5999@linux.dev> (raw)
In-Reply-To: <d9813f2fa7409b21b9688959b70d04f46ceb1da43f0ded88a921acaee62df4e3@mail.kernel.org>



On 9/28/26 5:52 PM, bot+bpf-ci@kernel.org wrote:
>> diff --git a/tools/testing/selftests/bpf/progs/bpf_misc.h b/tools/testing/selftests/bpf/progs/bpf_misc.h
>> index f3dbc3b59bff..9afa163fac5a 100644
>> --- a/tools/testing/selftests/bpf/progs/bpf_misc.h
>> +++ b/tools/testing/selftests/bpf/progs/bpf_misc.h
>> @@ -93,6 +93,11 @@
>>    * __failure         Expect program load failure in privileged mode.
>>    * __failure_unpriv  Expect program load failure in unprivileged mode.
>>    *
>> + * __set_global      Set a global variable of the program to a value before
>> + *                   executing it.
>> + * __ret_global      Execute the program and check that a global variable
>> + *                   holds the given value afterwards. The variable has to
>> + *                   live in .bss or .data and be four or eight bytes wide.
>>    * __retval          Execute the program using BPF_PROG_TEST_RUN command,
>>    *                   expect return value to match passed parameter:
>>    *                   - a decimal number
> [ ... ]
>
>> diff --git a/tools/testing/selftests/bpf/test_loader.c b/tools/testing/selftests/bpf/test_loader.c
>> index 25eeb1c1248b..2492841f7a49 100644
>> --- a/tools/testing/selftests/bpf/test_loader.c
>> +++ b/tools/testing/selftests/bpf/test_loader.c
> [ ... ]
>
>> +static int find_global_var(struct bpf_object *obj, const char *name,
>> +			   struct bpf_map **map, __u32 *off, __u32 *sz,
>> +			   bool *is_signed)
>> +{
>> +	static const char * const secs[] = { ".bss", ".data" };
>> +	struct btf *btf = bpf_object__btf(obj);
>> +	int i, s;
>> +	__u32 vsz;
>> +
>> +	if (!btf) {
>> +		PRINT_FAIL("no BTF for object\n");
>> +		return -ENOENT;
>> +	}
>> +
>> +	for (s = 0; s < ARRAY_SIZE(secs); s++) {
>> +		const struct btf_type *sec, *vt;
>> +		const struct btf_var_secinfo *vsi;
>> +		struct bpf_map *m = NULL, *iter;
>> +		size_t slen = strlen(secs[s]);
>> +		int id;
>> +
>> +		bpf_object__for_each_map(iter, obj) {
>> +			const char *mname = bpf_map__name(iter);
>> +			size_t len = mname ? strlen(mname) : 0;
>> +
>> +			if (len >= slen && strcmp(mname + len - slen, secs[s]) == 0) {
>> +				m = iter;
>> +				break;
>> +			}
>> +		}
> This isn't a bug, but could the map loop here be replaced with
> bpf_object__find_map_by_name(obj, secs[s]), as veristat's
> set_global_vars() does? That would tie the map to the DATASEC by its
> section name and make the comment about the two lookups not agreeing on a
> size unnecessary.

Will do. Thanks!

>
>> +		id = btf__find_by_name_kind(btf, secs[s], BTF_KIND_DATASEC);
>> +		if (!m || id < 0)
>> +			continue;
>> +
>> +		sec = btf__type_by_id(btf, id);
>> +		vsi = btf_var_secinfos(sec);
>> +		for (i = 0; i < btf_vlen(sec); i++, vsi++) {
>> +			const struct btf_type *var = btf__type_by_id(btf, vsi->type);
>> +
>> +			if (strcmp(btf__name_by_offset(btf, var->name_off), name))
>> +				continue;
>> +			if (vsi->size != 4 && vsi->size != 8) {
>> +				PRINT_FAIL("'%s' is %u bytes, only 4 and 8 are supported\n",
>> +					   name, vsi->size);
>> +				return -EINVAL;
>> +			}
>> +			vt = btf__type_by_id(btf, btf__resolve_type(btf, var->type));
>> +			if (!vt || !(btf_is_int(vt) || btf_is_any_enum(vt))) {
>> +				PRINT_FAIL("'%s' is not an int or an enum\n", name);
>> +				return -EINVAL;
>> +			}
>> +			*is_signed = global_var_is_signed(vt);
>> +			/*
>> +			 * The map is found by the suffix of its name and the
>> +			 * section by its own, so nothing so far has made the
>> +			 * two agree on a size.
>> +			 */
>> +			vsz = bpf_map__value_size(m);
>> +			if (vsi->offset > vsz || vsi->size > vsz - vsi->offset) {
>> +				PRINT_FAIL("'%s' at %u+%u is outside '%s' of %u bytes\n",
>> +					   name, vsi->offset, vsi->size,
>> +					   bpf_map__name(m), vsz);
>> +				return -EINVAL;
>> +			}
>> +			*map = m;
>> +			*off = vsi->offset;
>> +			*sz = vsi->size;
>> +			return 0;
>> +		}
>> +	}
>> +
>> +	PRINT_FAIL("no global variable '%s'\n", name);
>> +	return -ENOENT;
>> +}
> [ ... ]
>
>
> ---
> 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/36502848904


  reply	other threads:[~2026-09-30  1:46 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-29  0:16 [PATCH bpf-next v7 00/22] bpf: Run exception cleanup landing pads when bpf_unwind() unwinds Yonghong Song
2026-09-29  0:16 ` [PATCH bpf-next v7 01/22] bpf: Pack bpf_insn_aux_data flags into bit fields Yonghong Song
2026-09-29  0:16 ` [PATCH bpf-next v7 02/22] bpf: Accept the compiler's exception cleanup table at program load Yonghong Song
2026-09-29  0:16 ` [PATCH bpf-next v7 03/22] bpf: Add the bpf_unwind() and bpf_unwind_resume() kfuncs Yonghong Song
2026-09-29  0:16 ` [PATCH bpf-next v7 04/22] bpf: Add lookups for exception cleanup resumes and landing pads Yonghong Song
2026-09-29  0:33   ` sashiko-bot
2026-09-29 21:58     ` Yonghong Song
2026-09-29  0:16 ` [PATCH bpf-next v7 05/22] bpf: Prepare for an exception cleanup table before the CFG walk Yonghong Song
2026-09-29  0:31   ` sashiko-bot
2026-09-29 22:04     ` Yonghong Song
2026-09-29  0:16 ` [PATCH bpf-next v7 06/22] bpf: Make exception landing pads reachable in the CFG Yonghong Song
2026-09-29  0:16 ` [PATCH bpf-next v7 07/22] bpf: Resume a covered call at its landing pad Yonghong Song
2026-09-29  0:31   ` sashiko-bot
2026-09-30  0:28     ` Yonghong Song
2026-09-29  0:16 ` [PATCH bpf-next v7 08/22] bpf: Require an unwind to leave a frame holding what it entered with Yonghong Song
2026-09-29  0:36   ` sashiko-bot
2026-09-30  1:09     ` Yonghong Song
2026-09-29  0:52   ` bot+bpf-ci
2026-09-30  1:10     ` Yonghong Song
2026-09-29  0:16 ` [PATCH bpf-next v7 09/22] bpf: Refuse a landing pad that does not resume Yonghong Song
2026-09-29  0:16 ` [PATCH bpf-next v7 10/22] bpf: Refuse a private stack for a program that can unwind Yonghong Song
2026-09-29  0:16 ` [PATCH bpf-next v7 11/22] bpf: Dispatch cleanup pads by rewriting return addresses Yonghong Song
2026-09-29  1:14   ` bot+bpf-ci
2026-09-30  1:18     ` Yonghong Song
2026-09-29  0:17 ` [PATCH bpf-next v7 12/22] bpf, x86: Dispatch exception cleanup pads at run time Yonghong Song
2026-09-29  0:30   ` sashiko-bot
2026-09-30  1:34     ` Yonghong Song
2026-09-29  0:17 ` [PATCH bpf-next v7 13/22] bpf, arm64: " Yonghong Song
2026-09-29  1:14   ` bot+bpf-ci
2026-09-29  0:17 ` [PATCH bpf-next v7 14/22] libbpf: Resolve the compiler's _Unwind_Resume to the kernel's kfunc Yonghong Song
2026-09-29  0:17 ` [PATCH bpf-next v7 15/22] libbpf: Add cleanup_info to bpf_prog_load_opts Yonghong Song
2026-09-29  0:17 ` [PATCH bpf-next v7 16/22] libbpf: Collect .bpf_cleanup records and pass them to the kernel Yonghong Song
2026-09-29  0:17 ` [PATCH bpf-next v7 17/22] libbpf: Carry the exception cleanup table through the light skeleton Yonghong Song
2026-09-29  0:17 ` [PATCH bpf-next v7 18/22] libbpf: Let the static linker carry .bpf_cleanup relocations Yonghong Song
2026-09-29  0:17 ` [PATCH bpf-next v7 19/22] selftests/bpf: Add end-to-end and negative .bpf_cleanup exception tests Yonghong Song
2026-09-29  0:52   ` bot+bpf-ci
2026-09-30  1:42     ` Yonghong Song
2026-09-29  0:17 ` [PATCH bpf-next v7 20/22] selftests/bpf: Add __set_global() and __ret_global() test tags Yonghong Song
2026-09-29  0:52   ` bot+bpf-ci
2026-09-30  1:46     ` Yonghong Song [this message]
2026-09-29  0:17 ` [PATCH bpf-next v7 21/22] selftests/bpf: Cover more accepted .bpf_cleanup exception shapes Yonghong Song
2026-09-29  0:52   ` bot+bpf-ci
2026-09-30  2:19     ` Yonghong Song
2026-09-29  0:17 ` [PATCH bpf-next v7 22/22] selftests/bpf: Load an exception cleanup program from a light skeleton Yonghong Song
2026-09-29  0:52   ` bot+bpf-ci
2026-09-30  3:12     ` 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=9d4aebc7-47a7-4de2-9feb-a47df40c5999@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.