mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-11 07:03:09 -04:00
UPSTREAM: bpf: Use BTF_ID to resolve bpf_ctx_convert struct
This way the ID is resolved during compile time, and we can remove the runtime name search. Change-Id: I473cfe49f663c28f852ee113332ead58b044d7de Signed-off-by: Jiri Olsa <jolsa@kernel.org> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Tested-by: Andrii Nakryiko <andriin@fb.com> Acked-by: Andrii Nakryiko <andriin@fb.com> Link: https://lore.kernel.org/bpf/20200711215329.41165-7-jolsa@kernel.org
This commit is contained in:
parent
85ae421124
commit
b67fc7aaa1
1 changed files with 6 additions and 8 deletions
|
|
@ -18,6 +18,7 @@
|
|||
#include <linux/sort.h>
|
||||
#include <linux/bpf_verifier.h>
|
||||
#include <linux/btf.h>
|
||||
#include <linux/btf_ids.h>
|
||||
#include <linux/skmsg.h>
|
||||
#include <linux/perf_event.h>
|
||||
#include <net/sock.h>
|
||||
|
|
@ -3627,12 +3628,15 @@ static int btf_translate_to_vmlinux(struct bpf_verifier_log *log,
|
|||
return kern_ctx_type->type;
|
||||
}
|
||||
|
||||
BTF_ID_LIST(bpf_ctx_convert_btf_id)
|
||||
BTF_ID(struct, bpf_ctx_convert)
|
||||
|
||||
struct btf *btf_parse_vmlinux(void)
|
||||
{
|
||||
struct btf_verifier_env *env = NULL;
|
||||
struct bpf_verifier_log *log;
|
||||
struct btf *btf = NULL;
|
||||
int err, btf_id;
|
||||
int err;
|
||||
|
||||
env = kzalloc(sizeof(*env), GFP_KERNEL | __GFP_NOWARN);
|
||||
if (!env)
|
||||
|
|
@ -3666,14 +3670,8 @@ struct btf *btf_parse_vmlinux(void)
|
|||
if (err)
|
||||
goto errout;
|
||||
|
||||
/* find struct bpf_ctx_convert for type checking later */
|
||||
btf_id = btf_find_by_name_kind(btf, "bpf_ctx_convert", BTF_KIND_STRUCT);
|
||||
if (btf_id < 0) {
|
||||
err = btf_id;
|
||||
goto errout;
|
||||
}
|
||||
/* btf_parse_vmlinux() runs under bpf_verifier_lock */
|
||||
bpf_ctx_convert.t = btf_type_by_id(btf, btf_id);
|
||||
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);
|
||||
|
|
|
|||
Loading…
Reference in a new issue