• Eduard Zingerman's avatar
    selftests/bpf: Add notion of auxiliary programs for test_loader · 63bb645b
    Eduard Zingerman authored
    In order to express test cases that use bpf_tail_call() intrinsic it
    is necessary to have several programs to be loaded at a time.
    This commit adds __auxiliary annotation to the set of annotations
    supported by test_loader.c. Programs marked as auxiliary are always
    loaded but are not treated as a separate test.
    
    For example:
    
        void dummy_prog1(void);
    
        struct {
                __uint(type, BPF_MAP_TYPE_PROG_ARRAY);
                __uint(max_entries, 4);
                __uint(key_size, sizeof(int));
                __array(values, void (void));
        } prog_map SEC(".maps") = {
                .values = {
                        [0] = (void *) &dummy_prog1,
                },
        };
    
        SEC("tc")
        __auxiliary
        __naked void dummy_prog1(void) {
                asm volatile ("r0 = 42; exit;");
        }
    
        SEC("tc")
        __description("reference tracking: check reference or tail call")
        __success __retval(0)
        __naked void check_reference_or_tail_call(void)
        {
                asm volatile (
                "r2 = %[prog_map] ll;"
                "r3 = 0;"
                "call %[bpf_tail_call];"
                "r0 = 0;"
                "exit;"
                :: __imm(bpf_tail_call),
                :  __clobber_all);
        }
    Signed-off-by: default avatarEduard Zingerman <eddyz87@gmail.com>
    Link: https://lore.kernel.org/r/20230421174234.2391278-2-eddyz87@gmail.comSigned-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
    63bb645b
test_loader.c 18.3 KB