Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests/bpf: verifier/btf_ctx_access converted to inline assembly

Test verifier/btf_ctx_access automatically converted to use inline assembly.

Signed-off-by: Eduard Zingerman <eddyz87@gmail.com>
Link: https://lore.kernel.org/r/20230421174234.2391278-5-eddyz87@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>

authored by

Eduard Zingerman and committed by
Alexei Starovoitov
37467c79 965a3f91

+34 -25
+2
tools/testing/selftests/bpf/prog_tests/verifier.c
··· 11 11 #include "verifier_bounds_deduction_non_const.skel.h" 12 12 #include "verifier_bounds_mix_sign_unsign.skel.h" 13 13 #include "verifier_bpf_get_stack.skel.h" 14 + #include "verifier_btf_ctx_access.skel.h" 14 15 #include "verifier_cfg.skel.h" 15 16 #include "verifier_cgroup_inv_retcode.skel.h" 16 17 #include "verifier_cgroup_skb.skel.h" ··· 90 89 void test_verifier_bounds_deduction_non_const(void) { RUN(verifier_bounds_deduction_non_const); } 91 90 void test_verifier_bounds_mix_sign_unsign(void) { RUN(verifier_bounds_mix_sign_unsign); } 92 91 void test_verifier_bpf_get_stack(void) { RUN(verifier_bpf_get_stack); } 92 + void test_verifier_btf_ctx_access(void) { RUN(verifier_btf_ctx_access); } 93 93 void test_verifier_cfg(void) { RUN(verifier_cfg); } 94 94 void test_verifier_cgroup_inv_retcode(void) { RUN(verifier_cgroup_inv_retcode); } 95 95 void test_verifier_cgroup_skb(void) { RUN(verifier_cgroup_skb); }
+32
tools/testing/selftests/bpf/progs/verifier_btf_ctx_access.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* Converted from tools/testing/selftests/bpf/verifier/btf_ctx_access.c */ 3 + 4 + #include <linux/bpf.h> 5 + #include <bpf/bpf_helpers.h> 6 + #include "bpf_misc.h" 7 + 8 + SEC("fentry/bpf_modify_return_test") 9 + __description("btf_ctx_access accept") 10 + __success __retval(0) 11 + __naked void btf_ctx_access_accept(void) 12 + { 13 + asm volatile (" \ 14 + r2 = *(u32*)(r1 + 8); /* load 2nd argument value (int pointer) */\ 15 + r0 = 0; \ 16 + exit; \ 17 + " ::: __clobber_all); 18 + } 19 + 20 + SEC("fentry/bpf_fentry_test9") 21 + __description("btf_ctx_access u32 pointer accept") 22 + __success __retval(0) 23 + __naked void ctx_access_u32_pointer_accept(void) 24 + { 25 + asm volatile (" \ 26 + r2 = *(u32*)(r1 + 0); /* load 1nd argument value (u32 pointer) */\ 27 + r0 = 0; \ 28 + exit; \ 29 + " ::: __clobber_all); 30 + } 31 + 32 + char _license[] SEC("license") = "GPL";
-25
tools/testing/selftests/bpf/verifier/btf_ctx_access.c
··· 1 - { 2 - "btf_ctx_access accept", 3 - .insns = { 4 - BPF_LDX_MEM(BPF_W, BPF_REG_2, BPF_REG_1, 8), /* load 2nd argument value (int pointer) */ 5 - BPF_MOV64_IMM(BPF_REG_0, 0), 6 - BPF_EXIT_INSN(), 7 - }, 8 - .result = ACCEPT, 9 - .prog_type = BPF_PROG_TYPE_TRACING, 10 - .expected_attach_type = BPF_TRACE_FENTRY, 11 - .kfunc = "bpf_modify_return_test", 12 - }, 13 - 14 - { 15 - "btf_ctx_access u32 pointer accept", 16 - .insns = { 17 - BPF_LDX_MEM(BPF_W, BPF_REG_2, BPF_REG_1, 0), /* load 1nd argument value (u32 pointer) */ 18 - BPF_MOV64_IMM(BPF_REG_0, 0), 19 - BPF_EXIT_INSN(), 20 - }, 21 - .result = ACCEPT, 22 - .prog_type = BPF_PROG_TYPE_TRACING, 23 - .expected_attach_type = BPF_TRACE_FENTRY, 24 - .kfunc = "bpf_fentry_test9", 25 - },