Re: [PATCH bpf-next v4 1/2] bpf: Get better reg range with ldsx and 32bit compare

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 2024-07-19 at 15:46 -0700, Andrii Nakryiko wrote:

[...]

> > +       /* Here we would like to handle a special case after sign extending load,
> > +        * when upper bits for a 64-bit range are all 1s or all 0s.
> > +        *
> > +        * Upper bits are all 1s when register is in a range:
> > +        *   [0xffff_ffff_0000_0000, 0xffff_ffff_ffff_ffff]
> > +        * Upper bits are all 0s when register is in a range:
> > +        *   [0x0000_0000_0000_0000, 0x0000_0000_ffff_ffff]
> > +        * Together this forms are continuous range:
> > +        *   [0xffff_ffff_0000_0000, 0x0000_0000_ffff_ffff]
> > +        *
> > +        * Now, suppose that register range is in fact tighter:
> > +        *   [0xffff_ffff_8000_0000, 0x0000_0000_ffff_ffff] (R)
> > +        * Also suppose that it's 32-bit range is positive,
> > +        * meaning that lower 32-bits of the full 64-bit register
> > +        * are in the range:
> > +        *   [0x0000_0000, 0x7fff_ffff] (W)
> > +        *
> > +        * If this happens, then any value in a range:
> > +        *   [0xffff_ffff_0000_0000, 0xffff_ffff_7fff_ffff]
> > +        * is smaller than a lowest bound of the range (R):
> > +        *   0xffff_ffff_8000_0000
> > +        * which means that upper bits of the full 64-bit register
> > +        * can't be all 1s, when lower bits are in range (W).
> > +        *
> > +        * Note that:
> > +        *  - 0xffff_ffff_8000_0000 == (s64)S32_MIN
> > +        *  - 0x0000_0000_ffff_ffff == (s64)S32_MAX
> 
> ?? S32_MAX = 0x7fffffff, so should the right part be U32_MAX or the
> left part should be 0x0000_0000_7fff_ffff ?

Oops, that's on me, yes it should be 0x0000_0000_7fff_ffff here.

[...]





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux