On Thu, Dec 16, 2021 at 1:34 PM Christy Lee <christylee@xxxxxx> wrote: > > Make the verifier logs more readable, print the verifier states > on the corresponding instruction line. If the previous line was > not a bpf instruction, then print the verifier states on its own > line. > > Before: > > Validating test_pkt_access_subprog3() func#3... > 86: R1=invP(id=0) R2=ctx(id=0,off=0,imm=0) R10=fp0 > ; int test_pkt_access_subprog3(int val, struct __sk_buff *skb) > 86: (bf) r6 = r2 > 87: R2=ctx(id=0,off=0,imm=0) R6_w=ctx(id=0,off=0,imm=0) > 87: (bc) w7 = w1 > 88: R1=invP(id=0) R7_w=invP(id=0,umax_value=4294967295,var_off=(0x0; 0xffffffff)) > ; return get_skb_len(skb) * get_skb_ifindex(val, skb, get_constant(123)); > 88: (bf) r1 = r6 > 89: R1_w=ctx(id=0,off=0,imm=0) R6_w=ctx(id=0,off=0,imm=0) > 89: (85) call pc+9 > Func#4 is global and valid. Skipping. > 90: R0_w=invP(id=0) > 90: (bc) w8 = w0 > 91: R0_w=invP(id=0) R8_w=invP(id=0,umax_value=4294967295,var_off=(0x0; 0xffffffff)) > ; return get_skb_len(skb) * get_skb_ifindex(val, skb, get_constant(123)); > 91: (b7) r1 = 123 > 92: R1_w=invP123 > 92: (85) call pc+65 > Func#5 is global and valid. Skipping. > 93: R0=invP(id=0) > > After: > > 86: R1=invP(id=0) R2=ctx(id=0,off=0,imm=0) R10=fp0 > ; int test_pkt_access_subprog3(int val, struct __sk_buff *skb) > 86: (bf) r6 = r2 ; R2=ctx(id=0,off=0,imm=0) R6_w=ctx(id=0,off=0,imm=0) > 87: (bc) w7 = w1 ; R1=invP(id=0) R7_w=invP(id=0,umax_value=4294967295,var_off=(0x0; 0xffffffff)) > ; return get_skb_len(skb) * get_skb_ifindex(val, skb, get_constant(123)); > 88: (bf) r1 = r6 ; R1_w=ctx(id=0,off=0,imm=0) R6_w=ctx(id=0,off=0,imm=0) > 89: (85) call pc+9 > Func#4 is global and valid. Skipping. > 90: R0_w=invP(id=0) > 90: (bc) w8 = w0 ; R0_w=invP(id=0) R8_w=invP(id=0,umax_value=4294967295,var_off=(0x0; 0xffffffff)) > ; return get_skb_len(skb) * get_skb_ifindex(val, skb, get_constant(123)); > 91: (b7) r1 = 123 ; R1_w=invP123 > 92: (85) call pc+65 > Func#5 is global and valid. Skipping. > 93: R0=invP(id=0) > > Signed-off-by: Christy Lee <christylee@xxxxxx> > --- > include/linux/bpf_verifier.h | 3 + > kernel/bpf/verifier.c | 61 ++++-- > .../testing/selftests/bpf/prog_tests/align.c | 196 ++++++++++-------- > 3 files changed, 147 insertions(+), 113 deletions(-) > Checked pyperf50 output, looks great. Thanks for improving verifier logs! Acked-by: Andrii Nakryiko <andrii@xxxxxxxxxx> > diff --git a/include/linux/bpf_verifier.h b/include/linux/bpf_verifier.h > index c66f238c538d..ee931398f311 100644 > --- a/include/linux/bpf_verifier.h > +++ b/include/linux/bpf_verifier.h > @@ -388,6 +388,8 @@ static inline bool bpf_verifier_log_full(const struct bpf_verifier_log *log) > #define BPF_LOG_LEVEL (BPF_LOG_LEVEL1 | BPF_LOG_LEVEL2) > #define BPF_LOG_MASK (BPF_LOG_LEVEL | BPF_LOG_STATS) > #define BPF_LOG_KERNEL (BPF_LOG_MASK + 1) /* kernel internal flag */ > +#define BPF_LOG_MIN_ALIGNMENT 8U > +#define BPF_LOG_ALIGNMENT 40U > [...]