Re: [PATCH] bpf: init map_btf_id during compiling

From
Alexei Starovoitov <hidden>
Date
2022-04-26 18:30:57
Also in
lkml
Reply to
Alexei Starovoitov, 2022-04-26
On Tue, Apr 26, 2022 at 11:26 AM Alexei Starovoitov
[off-list ref] wrote:
On Sun, Apr 24, 2022 at 05:26:13PM +0800, menglong8.dong@gmail.com wrote:
quoted
diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c
index 0918a39279f6..588a001cc767 100644
--- a/kernel/bpf/btf.c
+++ b/kernel/bpf/btf.c
@@ -4727,30 +4727,6 @@ static const struct bpf_map_ops * const btf_vmlinux_map_ops[] = {
 #undef BPF_MAP_TYPE
 };

-static int btf_vmlinux_map_ids_init(const struct btf *btf,
-                                 struct bpf_verifier_log *log)
-{
-     const struct bpf_map_ops *ops;
-     int i, btf_id;
-
-     for (i = 0; i < ARRAY_SIZE(btf_vmlinux_map_ops); ++i) {
-             ops = btf_vmlinux_map_ops[i];
-             if (!ops || (!ops->map_btf_name && !ops->map_btf_id))
-                     continue;
-             if (!ops->map_btf_name || !ops->map_btf_id) {
-                     bpf_log(log, "map type %d is misconfigured\n", i);
-                     return -EINVAL;
-             }
-             btf_id = btf_find_by_name_kind(btf, ops->map_btf_name,
-                                            BTF_KIND_STRUCT);
-             if (btf_id < 0)
-                     return btf_id;
-             *ops->map_btf_id = btf_id;
-     }
-
-     return 0;
-}
-
 static int btf_translate_to_vmlinux(struct bpf_verifier_log *log,
                                   struct btf *btf,
                                   const struct btf_type *t,
@@ -4812,11 +4788,6 @@ struct btf *btf_parse_vmlinux(void)
      /* btf_parse_vmlinux() runs under bpf_verifier_lock */
      bpf_ctx_convert.t = btf_type_by_id(btf, bpf_ctx_convert_btf_id[0]);

-     /* find bpf map structs for map_ptr access checking */
-     err = btf_vmlinux_map_ids_init(btf, log);
-     if (err < 0)
-             goto errout;
-
Looks nice. Please address build warn and resubmit.
Just noticed v2. Ignore the above.
Thread (4 messages) 4 messages, 3 authors, last reply 2022-04-26
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help