• Jiong Wang's avatar
    selftests: bpf: adjust several test_verifier helpers for insn insertion · f3b55abb
    Jiong Wang authored
    - bpf_fill_ld_abs_vlan_push_pop:
        Prevent zext happens inside PUSH_CNT loop. This could happen because
        of BPF_LD_ABS (32-bit def) + BPF_JMP (64-bit use), or BPF_LD_ABS +
        EXIT (64-bit use of R0). So, change BPF_JMP to BPF_JMP32 and redefine
        R0 at exit path to cut off the data-flow from inside the loop.
    
      - bpf_fill_jump_around_ld_abs:
        Jump range is limited to 16 bit. every ld_abs is replaced by 6 insns,
        but on arches like arm, ppc etc, there will be one BPF_ZEXT inserted
        to extend the error value of the inlined ld_abs sequence which then
        contains 7 insns. so, set the dividend to 7 so the testcase could
        work on all arches.
    
      - bpf_fill_scale1/bpf_fill_scale2:
        Both contains ~1M BPF_ALU32_IMM which will trigger ~1M insn patcher
        call because of hi32 randomization later when BPF_F_TEST_RND_HI32 is
        set for bpf selftests. Insn patcher is not efficient that 1M call to
        it will hang computer. So , change to BPF_ALU64_IMM to avoid hi32
        randomization.
    Signed-off-by: default avatarJiong Wang <jiong.wang@netronome.com>
    Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
    f3b55abb
test_verifier.c 28.8 KB