[PATCH bpf-next v1 12/14] resolve_btfids: Drop KF_ARENA_ARG flag support
Kumar Kartikeya Dwivedi <[email protected]>
| Newsgroups | org.kernel.vger.bpf |
|---|---|
| Message-ID | <[email protected]> |
Arena argument suffixes now describe the address-space contract at any parameter position, while the kernel no longer publishes KF_ARENA_ARG1 or KF_ARENA_ARG2. Keeping private copies in resolve_btfids would leave an obsolete second annotation mechanism and silently accept flags the kernel no longer understands. Derive arena arguments exclusively from their suffixes and retain KF_ARENA_RET for functions returning arena pointers. Update the resolver selftest to distinguish return-only flags, unannotated pointer arguments, and suffix-annotated arguments. Signed-off-by: Kumar Kartikeya Dwivedi <[email protected]> --- tools/bpf/resolve_btfids/main.c | 22 ++----------------- .../selftests/bpf/prog_tests/resolve_btfids.c | 22 ++++++------------- 2 files changed, 9 insertions(+), 35 deletions(-) diff --git a/tools/bpf/resolve_btfids/main.c b/tools/bpf/resolve_btfids/main.c index 37d7e7224207..3dbf329edb46 100644 --- a/tools/bpf/resolve_btfids/main.c +++ b/tools/bpf/resolve_btfids/main.c @@ -177,8 +177,6 @@ struct object { #define KF_FASTCALL (1 << 12) #define KF_ARENA_RET (1 << 13) -#define KF_ARENA_ARG1 (1 << 14) -#define KF_ARENA_ARG2 (1 << 15) #define KF_IMPLICIT_ARGS (1 << 16) #define KF_IMPL_SUFFIX "_impl" #define TYPE_ATTR_ARENA "address_space(1)" @@ -1317,22 +1315,6 @@ static int process_kfunc_with_implicit_args(struct btf2btf_context *ctx, struct return 0; } -static bool is_arena_arg(const struct btf *btf, const struct kfunc *kfunc, - const struct btf_param *param, u32 idx) -{ - if (is_arena_param(btf, param)) - return true; - - switch (idx) { - case 0: - return kfunc->flags & KF_ARENA_ARG1; - case 1: - return kfunc->flags & KF_ARENA_ARG2; - default: - return false; - } -} - static s32 arena_tag_ptr(struct btf *btf, u32 ptr_id, struct kfunc *kfunc) { const struct btf_type *ptr = btf__type_by_id(btf, ptr_id); @@ -1382,7 +1364,7 @@ static s32 add_arena_tagged_proto(struct btf *btf, struct kfunc *kfunc) int err, i; for (i = 0; i < nr_params; i++) { - if (is_arena_arg(btf, kfunc, ¶ms[i], i)) { + if (is_arena_param(btf, ¶ms[i])) { has_arena_arg = true; break; } @@ -1420,7 +1402,7 @@ static s32 add_arena_tagged_proto(struct btf *btf, struct kfunc *kfunc) for (i = 0; i < nr_params; i++) { t = btf__type_by_id(btf, new_proto_id); tag_params = btf_params(t); - if (!is_arena_arg(btf, kfunc, &tag_params[i], i)) + if (!is_arena_param(btf, &tag_params[i])) continue; id = arena_tag_ptr(btf, tag_params[i].type, kfunc); diff --git a/tools/testing/selftests/bpf/prog_tests/resolve_btfids.c b/tools/testing/selftests/bpf/prog_tests/resolve_btfids.c index 3f9949e8227d..a4381c7fa7da 100644 --- a/tools/testing/selftests/bpf/prog_tests/resolve_btfids.c +++ b/tools/testing/selftests/bpf/prog_tests/resolve_btfids.c @@ -23,13 +23,6 @@ #ifndef KF_ARENA_RET #define KF_ARENA_RET (1 << 13) #endif -#ifndef KF_ARENA_ARG1 -#define KF_ARENA_ARG1 (1 << 14) -#endif -#ifndef KF_ARENA_ARG2 -#define KF_ARENA_ARG2 (1 << 15) -#endif - struct symbol { const char *name; int type; @@ -57,9 +50,8 @@ struct kfunc_symbol { static struct kfunc_symbol kfunc_symbols[] = { { "kfunc_a", -1, 0, 0, false }, { "kfunc_b", -1, KF_FASTCALL, 0, false }, - { "kfunc_c", -1, KF_ARENA_RET | KF_ARENA_ARG1 | KF_ARENA_ARG2, - ARENA_ARG(0) | ARENA_ARG(1), true }, - { "kfunc_d", -1, KF_ARENA_ARG2, ARENA_ARG(1), false }, + { "kfunc_c", -1, KF_ARENA_RET, 0, true }, + { "kfunc_d", -1, 0, 0, false }, { "kfunc_e", -1, 0, ARENA_ARG(0) | ARENA_ARG(1) | ARENA_ARG(2) | ARENA_ARG(3) | ARENA_ARG(4), false }, { "kfunc_f", -1, 0, ARENA_ARG(1), false }, @@ -111,8 +103,8 @@ BTF_SET_END(test_set) BTF_KFUNCS_START(test_kfunc_set) BTF_ID_FLAGS(func, kfunc_a) BTF_ID_FLAGS(func, kfunc_b, KF_FASTCALL) -BTF_ID_FLAGS(func, kfunc_c, KF_ARENA_RET | KF_ARENA_ARG1 | KF_ARENA_ARG2) -BTF_ID_FLAGS(func, kfunc_d, KF_ARENA_ARG2) +BTF_ID_FLAGS(func, kfunc_c, KF_ARENA_RET) +BTF_ID_FLAGS(func, kfunc_d) BTF_ID_FLAGS(func, kfunc_e) BTF_ID_FLAGS(func, kfunc_f) BTF_ID_FLAGS(func, kfunc_g, KF_ARENA_RET) @@ -126,8 +118,8 @@ BTF_KFUNCS_START(test_kfunc_set_rev) BTF_ID_FLAGS(func, kfunc_g, KF_ARENA_RET) BTF_ID_FLAGS(func, kfunc_f) BTF_ID_FLAGS(func, kfunc_e) -BTF_ID_FLAGS(func, kfunc_d, KF_ARENA_ARG2) -BTF_ID_FLAGS(func, kfunc_c, KF_ARENA_RET | KF_ARENA_ARG1 | KF_ARENA_ARG2) +BTF_ID_FLAGS(func, kfunc_d) +BTF_ID_FLAGS(func, kfunc_c, KF_ARENA_RET) BTF_ID_FLAGS(func, kfunc_b, KF_FASTCALL) BTF_ID_FLAGS(func, kfunc_a) BTF_KFUNCS_END(test_kfunc_set_rev) @@ -315,7 +307,7 @@ void test_resolve_btfids(void) } /* - * Check resolve_btfids wrapped exactly the arena-flagged or suffixed + * Check resolve_btfids wrapped exactly the arena return or suffixed * return/args with the address_space(1) type attribute, and left other * pointers/returns untouched. */ -- 2.53.0