[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAADnVQ+5CbptcUpjJN8bP64zrwu1j3doz+iyDEoH6mApELLNWQ@mail.gmail.com>
Date: Fri, 25 Sep 2020 16:56:10 -0700
From: Alexei Starovoitov <alexei.starovoitov@...il.com>
To: John Fastabend <john.fastabend@...il.com>
Cc: Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Network Development <netdev@...r.kernel.org>,
bpf <bpf@...r.kernel.org>
Subject: Re: [bpf-next PATCH 1/2] bpf, verifier: Remove redundant
var_off.value ops in scalar known reg cases
On Thu, Sep 24, 2020 at 11:45 AM John Fastabend
<john.fastabend@...il.com> wrote:
>
> In BPF_AND and BPF_OR alu cases we have this pattern when the src and dst
> tnum is a constant.
>
> 1 dst_reg->var_off = tnum_[op](dst_reg->var_off, src_reg.var_off)
> 2 scalar32_min_max_[op]
> 3 if (known) return
> 4 scalar_min_max_[op]
> 5 if (known)
> 6 __mark_reg_known(dst_reg,
> dst_reg->var_off.value [op] src_reg.var_off.value)
>
> The result is in 1 we calculate the var_off value and store it in the
> dst_reg. Then in 6 we duplicate this logic doing the op again on the
> value.
>
> The duplication comes from the the tnum_[op] handlers because they have
> already done the value calcuation. For example this is tnum_and().
>
> struct tnum tnum_and(struct tnum a, struct tnum b)
> {
> u64 alpha, beta, v;
>
> alpha = a.value | a.mask;
> beta = b.value | b.mask;
> v = a.value & b.value;
> return TNUM(v, alpha & beta & ~v);
> }
>
> So lets remove the redundant op calculation. Its confusing for readers
> and unnecessary. Its also not harmful because those ops have the
> property, r1 & r1 = r1 and r1 | r1 = r1.
>
> Signed-off-by: John Fastabend <john.fastabend@...il.com>
Applied. Thanks for the follow up.
In the future please always cc bpf@...r for two reasons:
- to get proper 'Link:' integrated in git commit
- to get them into a new instance of
https://patchwork.kernel.org/project/bpf/list
which we will start using soon to send automatic 'applied' emails.
Powered by blists - more mailing lists