]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
bpf: Use KF_FASTCALL to mark kfuncs supporting fastcall contract
authorEduard Zingerman <eddyz87@gmail.com>
Mon, 16 Sep 2024 09:17:11 +0000 (02:17 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 4 Oct 2024 00:47:53 +0000 (17:47 -0700)
In order to allow pahole add btf_decl_tag("bpf_fastcall") for kfuncs
supporting bpf_fastcall, mark such functions with KF_FASTCALL in
id_set8 objects.

Signed-off-by: Eduard Zingerman <eddyz87@gmail.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20240916091712.2929279-4-eddyz87@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
include/linux/btf.h
kernel/bpf/helpers.c
kernel/bpf/verifier.c

index b8a583194c4a978a8279612dbf445e0ff183d8c9..631060e3ad146427955d83f0ecfca1423d4d0803 100644 (file)
@@ -75,6 +75,7 @@
 #define KF_ITER_NEXT    (1 << 9) /* kfunc implements BPF iter next method */
 #define KF_ITER_DESTROY (1 << 10) /* kfunc implements BPF iter destructor */
 #define KF_RCU_PROTECTED (1 << 11) /* kfunc should be protected by rcu cs when they are invoked */
+#define KF_FASTCALL     (1 << 12) /* kfunc supports bpf_fastcall protocol */
 
 /*
  * Tag marking a kernel function as a kfunc. This is meant to minimize the
index 1a43d06eab286c26e80be35ff2c6f426de3cf66a..4053f279ed4cc7ab4141e99d9387273daa0a24a0 100644 (file)
@@ -3052,8 +3052,8 @@ BTF_ID(func, bpf_cgroup_release_dtor)
 #endif
 
 BTF_KFUNCS_START(common_btf_ids)
-BTF_ID_FLAGS(func, bpf_cast_to_kern_ctx)
-BTF_ID_FLAGS(func, bpf_rdonly_cast)
+BTF_ID_FLAGS(func, bpf_cast_to_kern_ctx, KF_FASTCALL)
+BTF_ID_FLAGS(func, bpf_rdonly_cast, KF_FASTCALL)
 BTF_ID_FLAGS(func, bpf_rcu_read_lock)
 BTF_ID_FLAGS(func, bpf_rcu_read_unlock)
 BTF_ID_FLAGS(func, bpf_dynptr_slice, KF_RET_NULL)
index 9a7ed527e47e343070cf9ccb899ee1fc6fcfdd49..7d9b38ffd2204a207116abbb091034f7149be373 100644 (file)
@@ -16176,10 +16176,7 @@ static u32 kfunc_fastcall_clobber_mask(struct bpf_kfunc_call_arg_meta *meta)
 /* Same as verifier_inlines_helper_call() but for kfuncs, see comment above */
 static bool is_fastcall_kfunc_call(struct bpf_kfunc_call_arg_meta *meta)
 {
-       if (meta->btf == btf_vmlinux)
-               return meta->func_id == special_kfunc_list[KF_bpf_cast_to_kern_ctx] ||
-                      meta->func_id == special_kfunc_list[KF_bpf_rdonly_cast];
-       return false;
+       return meta->kfunc_flags & KF_FASTCALL;
 }
 
 /* LLVM define a bpf_fastcall function attribute.