diff options
author | Alexei Starovoitov <ast@kernel.org> | 2023-03-17 23:19:17 +0300 |
---|---|---|
committer | Andrii Nakryiko <andrii@kernel.org> | 2023-03-18 01:44:26 +0300 |
commit | 58aa2afbb1e61fcf35bfcc819952a3c13d9f9203 (patch) | |
tree | d113fe44c262fb22750d6f191cb74ccb76db9750 /tools/testing/selftests/bpf/prog_tests/autoload.c | |
parent | 0f10f647f45545004ea50b73a7a7c5c3309ff286 (diff) | |
download | linux-58aa2afbb1e61fcf35bfcc819952a3c13d9f9203.tar.xz |
bpf: Allow ld_imm64 instruction to point to kfunc.
Allow ld_imm64 insn with BPF_PSEUDO_BTF_ID to hold the address of kfunc. The
ld_imm64 pointing to a valid kfunc will be seen as non-null PTR_TO_MEM by
is_branch_taken() logic of the verifier, while libbpf will resolve address to
unknown kfunc as ld_imm64 reg, 0 which will also be recognized by
is_branch_taken() and the verifier will proceed dead code elimination. BPF
programs can use this logic to detect at load time whether kfunc is present in
the kernel with bpf_ksym_exists() macro that is introduced in the next patches.
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Reviewed-by: Martin KaFai Lau <martin.lau@kernel.org>
Reviewed-by: Toke Høiland-Jørgensen <toke@redhat.com>
Acked-by: John Fastabend <john.fastabend@gmail.com>
Link: https://lore.kernel.org/bpf/20230317201920.62030-2-alexei.starovoitov@gmail.com
Diffstat (limited to 'tools/testing/selftests/bpf/prog_tests/autoload.c')
0 files changed, 0 insertions, 0 deletions